当前位置: 首页>>代码示例>>C++>>正文


C++ TH1::Write方法代码示例

本文整理汇总了C++中TH1::Write方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1::Write方法的具体用法?C++ TH1::Write怎么用?C++ TH1::Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TH1的用法示例。


在下文中一共展示了TH1::Write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: write

 void write()
     {
         met_->Write();
         mt2_->Write();
         nt_->Write();
         nb_->Write();
         baseline_met_->Write();
         baseline_mt2_->Write();
         baseline_nt_->Write();
         baseline_nb_->Write();
         baseline_nSearchBin_->Write();
     }
开发者ID:scarletnorberg,项目名称:SusyAnaTools,代码行数:12,代码来源:makeSignalHistograms.C

示例2: Plot2hists1D

// If two histograms from two files are to be ploted onto
// the same plot.  Open the first, and make a copy of the
// histogram and place it in the 2nd file. Then
void Plot2hists1D(TString hist1Name, 
		TString hist2Name, 
		TString file1Name, 
		TString file2Name, 
                TString hist1Label = "",
                TString hist2Label = "",
		Double_t scaleFactor1 = 1.0, 
		Double_t scaleFactor2 = 1.0) {

  // Open the 1st file
  TFile *file1 = new TFile(file1Name);

  // Grab a copy of its histogram
  TH1* histTemp = (TH1*)file1->Get(hist1Name);

  // Open the 2nd file
  TFile *file2 = new TFile(file2Name,"UPDATE");
  file2->cd();

  // Change the name 
  histTemp->SetName(hist1Name+"1");

  // Write the histogram to the 2nd file
  histTemp->Write();

  // Now file2 is the currently active file
  Plot2hists1D(hist1Name+"1",hist2Name, scaleFactor1, scaleFactor2, hist1Label, hist2Label);

  // Close the files, but if they close, the histograms disappear
  //file1->Close();
  //file2->Close();
}
开发者ID:TENorbert,项目名称:SOME-TOOLS,代码行数:35,代码来源:Plot2hists1D.C

示例3: turn2Dinto1Ds

void turn2Dinto1Ds(char* myf, char *myh, char* myfo)
{
   
  TFile* mytfile = new TFile(myf);
  TH2* my2dh = (TH2*) mytfile->Get(myh);
  my2dh->SetDirectory(0);
  TFile* myoftile = new TFile(myfo,"RECREATE");
  myoftile->cd();
  //std::vector<TH1*> vechist;
  Int_t ybins = my2dh->GetNbinsX();
  std::cout << " Full bins " << ybins << std::endl;
  std::cout << " Entries " << my2dh->GetEntries();
   
  for (Int_t Ybin = 1; Ybin <= ybins; ++Ybin)
    {
      TH1* onehist = (TH1*) my2dh->ProjectionY(Form("rap%d",Ybin), Ybin,Ybin,"");
      std::cout << " Entries: " << onehist->GetEntries() << std::endl;
     
      onehist->Write();
     
    }
   
  myoftile->Write();
  myoftile->Close();
  mytfile->Close();
   
   
}
开发者ID:UMN-CMS,项目名称:ZShape_Analysis,代码行数:28,代码来源:turn2Dinto1Ds.C

示例4: analyzer

void analyzer()
{

  TString processName = "ZJets";

  TFile* f = TFile::Open(Form("hist_%s.root", processName.Data()), "recreate");

  // Create chain of root trees
  TChain chain("DelphesMA5tune");
  //kisti
  //chain.Add("/cms/home/tjkim/fcnc/sample/ZToLL50-0Jet_sm-no_masses/events_*.root");
  //hep
  chain.Add("/Users/tjkim/Work/fcnc/samples/ZToLL50-0Jet_sm-no_masses/events_*.root");  

  // Create object of class ExRootTreeReader
  ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);
  Long64_t numberOfEntries = treeReader->GetEntries();
  
  // Get pointers to branches used in this analysis
  TClonesArray *branchMuon = treeReader->UseBranch("DelphesMA5tuneMuon");
  
  // Book histograms
  TH1 *histDiMuonMass = new TH1F("dimuon_mass","Di-Muon Invariant Mass (GeV)",100, 50, 150);
 
  // Loop over all events

  for(Int_t entry = 0; entry < numberOfEntries; ++entry)
  {
    // Load selected branches with data from specified event
    treeReader->ReadEntry(entry);
 
    int nmuon = 0; 
    for( int i = 0; i < branchMuon->GetEntries(); i++)
    {
      Muon *muon = (Muon*) branchMuon->At(i);
      if( muon->PT <= 20 || abs(muon->Eta) >= 2.4 ) continue;
      nmuon = nmuon + 1 ;
    }

    if( nmuon >= 2){

      Muon *mu1 = (Muon*) branchMuon->At(0);
      Muon *mu2 = (Muon*) branchMuon->At(1);

      // Plot di-muon invariant mass 
      histDiMuonMass->Fill(((mu1->P4()) + (mu2->P4())).M());
    }
 
  }

  // Show resulting histograms
  histDiMuonMass->Write();

  f->Close();

}
开发者ID:Somhammer,项目名称:pheno,代码行数:56,代码来源:analyzer.C

示例5: putspe

/*=========================================================*/
Int_t putspe(Char_t *rn, Char_t *hn)
{
  TH1 *hist;
  TFile *f2;;

  hist = (TH1*)f1->Get(hn);
  f2 = new TFile(rn,"UPDATE");
  hist->Write();
  f2->ls();
  f2->Close();
  return 0;
}
开发者ID:adamhayes,项目名称:ChicoSort,代码行数:13,代码来源:gatemat.cpp

示例6: TFile

makeMuonTriggerEfficiencyLUT()
{
  TH1* histoLUT = new TH2F("muonTriggerEfficiencyCorrection", "muonTriggerEfficiencyCorrection", 
			   1, -2.5, +2.5, 1, 0., 10000.);

  histoLUT->SetBinContent(1, 1, 0.98);
  histoLUT->SetBinError(1, 1, 0.02);

  TFile* outputFile = new TFile("../data/muonTriggerEfficiencyCorrection.root", "RECREATE");
  histoLUT->Write();
  delete outputFile;
}
开发者ID:aashaqshah,项目名称:cmssw-1,代码行数:12,代码来源:makeMuonTriggerEfficiencyLUT.C

示例7: getspe

/*=========================================================*/
Int_t getspe(Char_t *rn, Char_t *hn)
{
  TH1 *hist;
  TFile *f2,*f3;

  f1->Close();
  f2 = new TFile(rn,"READ");
  hist = (TH1*)f2->Get(hn);
  f3 = new TFile(rootfilename,"UPDATE");
  hist->Write();
  f3->Close();
  f2->Close();
  f1 = new TFile(rootfilename,"READ");
  f1->ls(hn);
  return 0;
}
开发者ID:adamhayes,项目名称:ChicoSort,代码行数:17,代码来源:gatemat.cpp

示例8: Hijing

void Hijing()
{
  TFile *fin = TFile::Open("/sphenix/user/pinkenbu/jade/hijingdat2.root");
  gROOT->cd();
  TH1 *hjbkg = new TH1F("hjbkg","Hijing Background",100,0.,0.5);
  TNtuple *de = (TNtuple *) fin->Get("de");
  de->Project("hjbkg","dtotal","(ID<=2)*edep/250.");

       char fname [100];
       sprintf(fname, "Gamma_Neutron_Hijing_Energy_Graphs.root");
       TFile *fout = TFile::Open(fname,"UPDATE");
       hjbkg->Write();
       fout->Write();
       fout->Close();
  fin->Close();
}
开发者ID:kurthill,项目名称:analysis,代码行数:16,代码来源:GammaNeutronEnergyHijing.C

示例9: makefinal

void makefinal(TFile* fp, TFile *fm,  TFile* of=0) {
  setTDRStyle();
  
  TH1 *hp = (TH1*) fp->Get("MYHA");
  TH1 *hm = (TH1*) fm->Get("MYHA");
  
  TH1 *h = hp->Clone("MYNA");
  for (int k=1; k<=h->GetNbinsX(); k++) {
    std::cout << hp->GetBinContent(k) <<  " " << hm->GetBinContent(k) << std::endl;
    h->SetBinContent(k,hp->GetBinContent(k)*.5 +hm->GetBinContent(k)*.5);
    std::cout << " NEW " << h->GetBinContent(k) << std::endl;
    //h->SetBinEntries(k,1);
  }
  
  if (of!=0) { of->cd(); h->Write();}

  
}
开发者ID:UMN-CMS,项目名称:ZShape_Analysis,代码行数:18,代码来源:plotEffStat.C

示例10: savehistos

void savehistos(const string& filewithlist,
		const string& outputfilename,
		const string& openmode="RECREATE")
{
  FILE *fp = fopen(filewithlist.c_str(),"r");
  if (!fp) {
    cerr << "File not found, " << filewithlist << endl;
    return;
  }

  TFile *rootfile = new TFile(outputfilename.c_str(),openmode.c_str());
  if (rootfile->IsZombie()) {
    cerr << "File failed to open, " << outputfilename << endl;
    return;
  }

  string theline,newname;
  vector<string> tokens;
  while (getLine(fp,theline)) {
    if (theline[0] == '#') continue; // "comments are welcome"
    Tokenize(theline,tokens,"\t");

    TH1 *h1     = getHisto(tokens[0]);

    if (!h1) {
      cerr << "Couldn't get histo " << tokens[0] << endl;
      return;
    }
    TH1 *target = h1;

    if( tokens.size() > 1 && tokens[1].length() ) {
      newname = tokens[1];
      cout<<"Writing histo "<<newname<<" to file "<<outputfilename<<endl;
      target = (TH1 *)h1->Clone(newname.c_str());
    } else
      cout<<"Writing histo "<<h1->GetName()<<" to file "<<outputfilename<<endl;

    target->SetDirectory(rootfile);
    rootfile->cd();
    target->Write();
  }
  rootfile->Close();
}
开发者ID:TENorbert,项目名称:HeavyNu,代码行数:43,代码来源:savehistos.C

示例11: Save

void HistoProofMan::Save(){

  if(!fname[0])return;
  printf("HistoMan::Save ----> Saving %s\n",fname);
  TDirectory *dsave = gDirectory;
  TFile* pp=TFile::Open(fname,"RECREATE");
  pp->cd();
  hashtable<TH1*>::iterator it;
  for(it=hlist.begin();it!=hlist.end();it++) {
    TH1 *obj = it->second;
    if (obj && obj->GetEntries() > 0) obj->Write();
  }
  pp->Write();
  pp->Close();
  printf(" ..... done\n");
  if (dsave) dsave->cd();
  //  fdir->Purge();
  return;
}
开发者ID:krafczyk,项目名称:AMS,代码行数:19,代码来源:HistoProofMan.C

示例12: rescaleBoundaryHists

void rescaleBoundaryHists(std::string infile, int numSamples=-1){

  TFile* f = new TFile(infile.c_str(), "UPDATE");
  TDirectory* dir = 0;

  TIter dir_it(f->GetListOfKeys());
  TKey* dir_k;
  while ((dir_k = (TKey *)dir_it())) {
    if (TString(dir_k->GetClassName()) != "TDirectoryFile") continue;
    std::string dir_name = std::string(dir_k->GetTitle());
    if(dir_name == "") continue;
    dir = (TDirectory*)dir_k->ReadObj();
    if(dir == 0) continue;
    TIter hist_it(dir->GetListOfKeys(), kIterBackward);
    TKey* hist_k;
    while ((hist_k = (TKey *)hist_it())) {
      std::string hist_name = (hist_k->GetTitle());
      if (hist_name.find("_HI") != std::string::npos || hist_name.find("_LOW") != std::string::npos || hist_name.find("h_n_mt2bins") != std::string::npos) {
        TH1* h = (TH1*)hist_k->ReadObj();
        if(numSamples==-1)
            h->Scale(1.0/h->GetEntries());
        else
            h->Scale(1.0/numSamples);
        dir->cd();
        h->Write("",TObject::kOverwrite);
      }
    }
  }

  delete dir;

  gDirectory->GetList()->Delete();
  
  f->Write("",TObject::kOverwrite);
  f->Close();
  delete f;

}
开发者ID:cmstas,项目名称:MT2Analysis,代码行数:38,代码来源:rescaleBoundaryHists.C

示例13: Fit


//.........这里部分代码省略.........
  double N = hDat->Integral();
  double B = hBkg->Integral();
  double S = hSgn->Integral();
  double m = f.getVal();
  double e = f.getError();
  cout<<"k-factor = "<<k_factor<<endl;
  cout<<N<<" "<<B<<" "<<S<<endl;
  cout<<"Total cross section =       "<<N/lumi<<" pb"<<endl;
  cout<<"Model cross section =       "<<S/lumi<<" pb"<<endl;
  cout<<"Fitted signal strength =    "<<m*N/S<<endl;
  cout<<"Fitted signal error =       "<<e*N/S<<endl;
  double p = 0.95;
  double xup = (N/S)*(m+sqrt(2.)*e*TMath::ErfInverse((1-p)*TMath::Erf(m/e)+p));
  cout<<"Bayesian Upper limit =      "<<xup<<endl;
  RooPlot* frame1 = x.frame();  
  data.plotOn(frame1);
  model.plotOn(frame1,Components("sgnPDF*"),LineStyle(1),LineWidth(2),LineColor(kGreen+1));
  model.plotOn(frame1,Components("bkgPDF*"),LineStyle(1),LineWidth(2),LineColor(kRed));
  model.plotOn(frame1,LineStyle(1),LineWidth(2),LineColor(kBlue));
  
  //cout<<frame1->chiSquare()<<endl;
  RooHist* hresid = frame1->residHist();
  RooHist* hpull = frame1->pullHist();
  RooPlot* frame2 = x.frame(Title("Residual Distribution"));
  frame2->addPlotable(hresid,"P") ;
  
  // Create a new frame to draw the pull distribution and add the distribution to the frame
  RooPlot* frame3 = x.frame(Title("Pull Distribution"));
  frame3->addPlotable(hpull,"P");
  
  TCanvas* cFit = new TCanvas("fitANN_"+SIGNAL,"fitANN_"+SIGNAL,900,600);
  gPad->SetLogy();
  frame1->SetMaximum(1e+4);
  frame1->SetMinimum(0.5);
  frame1->GetXaxis()->SetTitle("ANN Output");
  frame1->GetYaxis()->SetTitle("Events");
  frame1->Draw();
  cout<<frame1->nameOf(3)<<endl;
  TLegend *leg = new TLegend(0.7,0.65,0.9,0.9);
  leg->SetHeader(SIGNAL);
  leg->AddEntry(frame1->findObject("h_data"),"data","P");
  leg->AddEntry(frame1->findObject("model_Norm[x]"),"QCD+Signal","L");
  leg->AddEntry(frame1->findObject("model_Norm[x]_Comp[bkgPDF*]"),"QCD","L");
  leg->AddEntry(frame1->findObject("model_Norm[x]_Comp[sgnPDF*]"),"Signal","L");
  leg->SetFillColor(0);
  leg->SetBorderSize(0);
  leg->SetTextFont(42);
  leg->SetTextSize(0.04);
  leg->Draw();

  TCanvas* cPull = new TCanvas("pullANN_"+SIGNAL,"pullANN_"+SIGNAL,900,400); 
  frame3->GetXaxis()->SetTitle("ANN Output");
  frame3->GetYaxis()->SetTitle("Pull");
  frame3->Draw();
  
  cout<<"Creating datacard"<<endl;
  ofstream datacard;
  datacard.open("datacard_"+SIGNAL+"_"+HISTO+".txt");
  datacard.setf(ios::right);
  datacard<<"imax 1"<<"\n";
  datacard<<"jmax 1"<<"\n";
  datacard<<"kmax *"<<"\n";
  datacard<<"----------------"<<"\n";
  datacard<<"shapes * * "<<SIGNAL+"_"+HISTO+"_input.root $PROCESS $PROCESS_$SYSTEMATIC"<<"\n";
  datacard<<"----------------"<<"\n";
  datacard<<"bin         1"<<"\n";
  datacard<<"observation "<<N<<"\n";
  datacard<<"----------------"<<"\n";
  datacard<<"bin         1       1"<<"\n";
  datacard<<"process     signal  background  "<<"\n";
  datacard<<"process     0       1"<<"\n";
  datacard<<"rate       "<<S<<"    "<<B<<"\n";
  datacard<<"----------------"<<"\n";
  datacard<<"lumi        lnN       1.022    1.022"<<"\n";
  datacard<<"jes         shape     1        1"<<"\n";
  datacard<<"mcstat      shape     1        1"<<"\n";
  datacard<<"jer         shape     0        0"<<"\n";
  datacard.close();
  
  TFile *out = new TFile(SIGNAL+"_"+HISTO+"_input.root","RECREATE");
  out->cd();
  hDat->Write("data_obs");
  hBkg->Write("background");
  hSgn->Write("signal");
  hDat_JESlo->Write("data_obs_jesDown");
  hBkg_JESlo->Write("background_jesDown");
  hBkg_STATlo->Write("background_mcstatDown");
  hSgn_STATlo->Write("signal_mcstatDown");
  hSgn_JESlo->Write("signal_jesDown");
  hDat_JESup->Write("data_obs_jesUp");
  hBkg_JESup->Write("background_jesUp");
  hBkg_STATup->Write("background_mcstatUp");
  hSgn_JESup->Write("signal_jesUp");
  hSgn_STATup->Write("signal_mcstatUp");
  //----- JER placeholder ----------------
  hBkg_JESlo->Write("background_jerDown");
  hSgn_JESlo->Write("signal_jerDown"); 
  hBkg_JESup->Write("background_jerUp");
  hSgn_JESup->Write("signal_jerUp");
}
开发者ID:ForwardGroupBrazil,项目名称:QCDCodes,代码行数:101,代码来源:Fit.C

示例14: if


//.........这里部分代码省略.........
  const UShort_t             nQ = maxH - 1;
  correlations::ResultVector qs[nbin];
    for(int ibin=0;ibin<nbin;ibin++)
        qs[ibin] = correlations::ResultVector(nQ);

  // --- Event loop --------------------------------------------------
  Int_t nEvents = tree->GetEntries();
  for (Int_t event = 0; event < nEvents; event++) {
    tree->GetEntry(event);
    int ntrk = M; int xbin=-1;
    for(int j=0;j<nbin;j++)
        if(ntrk<trkbin[j]&&ntrk>=trkbin[j+1])
            xbin=j;
        if(xbin<0 || xbin==nbin) continue;
    tottrk[xbin]+=ntrk;
    q[xbin].reset();
 //   printf("Event # %4u  %4d particles ", event++, phis.GetSize());
    for (UShort_t pa = 0; pa < M; pa++){
	if(fabs(eta[pa])>etamax) continue;
        if(pt[pa]<ptmin||pt[pa]>ptmax) continue; //event selection
  //  phis.Set(n,pPhis);
      q[xbin].fill(phi[pa], 1.);
    }
    for (UShort_t i = 0; i < nQ; i++) {
      UShort_t n = i + 2;
   //   printf("%s%d", i == 0 ? "" : "..", n);
      timer.Reset();
      timer.Start();
      qs[xbin][i] += c[xbin]->calculate(n, h);
      timer.Stop();
      timing->Fill(n+.5, timer.RealTime());
    }

  //  printf(" done\n");
  Nevent[xbin]++;
  }
  file->Close();

    for(int ibin=0;ibin<nbin;ibin++){
  for (UShort_t i = 0; i < nQ; i++) {
 //   UShort_t iq = i+2;
 //   Double_t              t  = timing->GetBinContent(i+1);
 //   correlations::Complex rc = qs[i].eval();
   // Printf("QC{%2d}: %12g + %12gi  <t>: %10gs",
//	   iq, rc.real(), rc.imag(), t);
   // if(i==0)Printf("v2{%2d}: %3g\n",2,sqrt(qs[0].eval().real()));
   // if(i==2)Printf("v2{%2d}: %3g\n",4,TMath::Power(fabs(qs[2].eval().real()),1./4));
   // if(i==4)Printf("v2{%2d}: %3g\n",6,TMath::Power(fabs(qs[4].eval().real()),1./6));
    sumreals[ibin]->SetBinContent(i+1,qs[ibin][i]._sum.real());
    sumimags[ibin]->SetBinContent(i+1,qs[ibin][i]._sum.imag());
    weights[ibin]->SetBinContent(i+1,qs[ibin][i]._weights);
    //reals->SetBinContent(i+1, rc.real());
    //imags->SetBinContent(i+1, rc.imag());
  }
    }

/*
  TCanvas* can = new TCanvas("C", "C");
  can->SetTopMargin(0.15);
  can->SetBottomMargin(0.15);
  can->SetRightMargin(0.03);
  can->Divide(1,3, 0, 0);

  DrawInPad(can, 3, timing, true);
  DrawInPad(can, 1, reals);
  DrawInPad(can, 2, imags);

  can->cd(0);
  TLatex* ltx = new TLatex(0.5,0.995,c->name());
  ltx->SetNDC(true);
  ltx->SetTextAlign(23);
  ltx->SetTextSize(0.04);
  ltx->Draw();

  can->Modified();
  can->Update();
  can->cd();
*/
  TString out(mode);
  out.ToLower();
  file = TFile::Open(Form("%s/%s_%d.root",outdir.Data(),out.Data(),ifile), "RECREATE");
    for(int ibin=0;ibin<nbin;ibin++){
  sumimags[ibin]->Write();
  sumreals[ibin]->Write();
  weights[ibin]->Write();
    }
  Nevent.Write("Nevent");
  tottrk.Write("tottrk");
  timing->Write();
  hs->Write();
  file->Write();
  file->Close();
    for(int ibin=0;ibin<nbin;ibin++){
  delete sumimags[ibin];
  delete sumreals[ibin];
  delete weights[ibin];
    }
  delete timing;
  delete hs;
}
开发者ID:XuQiao,项目名称:HI,代码行数:101,代码来源:Analyze.C

示例15: main


//.........这里部分代码省略.........
        //New #Jet
        int newNJet = HT3JetVec.size();
        if(verbose==1)printf("newNJet: %d \n ",newNJet);



      // Acceptance determination 1: Counter for all events
      // with muons at generator level
      hAccAll->Fill( binMap_mht_nj[utils2::findBin_mht_nj(evt->nJets(),evt->mht()).c_str()] );
//      hAccAll->Fill( binMap_mht_nj[utils2::findBin_mht_nj(newNJet,newMHT).c_str()] ); // this doesn't work good

      // Check if generator-level muon is in acceptance
      if( genMuPt > LeptonAcceptance::muonPtMin() && std::abs(genMuEta) < LeptonAcceptance::muonEtaMax() ) {
        if(verbose!=0)printf("Muon is in acceptance \n ");
        // Acceptance determination 2: Counter for only those events
        // with generator-level muons inside acceptance
        // hAccPass->Fill( binMap[utils2::findBin(cntNJetsPt30Eta24,nbtag,HT,template_mht).c_str()] );
        hAccPass->Fill( binMap_mht_nj[utils2::findBin_mht_nj(evt->nJets(),evt->mht()).c_str()] );
//        hAccPass->Fill( binMap_mht_nj[utils2::findBin_mht_nj(newNJet,newMHT).c_str()] );

        // Reconstruction-efficiency determination 1: Counter for all events
        // with generator-level muons inside acceptance, regardless of whether
        // the muon has also been reconstructed or not.
        // hIsoRecoAll->Fill( binMap[utils2::findBin(cntNJetsPt30Eta24,nbtag,HT,template_mht).c_str()]);
        hIsoRecoAll->Fill( binMap[utils2::findBin_NoB(evt->nJets(),evt->ht(),evt->mht()).c_str()]);

        // Check if the muon has been reconstructed: check if a reconstructed
        // muon is present in the event that matches the generator-level muon
        // Isolation-efficiency determination 1: Counter for all events with a
        // reconstructed muon that has a generator-level muon match inside the
        // the acceptance, regardless of whether the reconstructed muon is also
        // isolated or not.

//if( evt->MuPtVec_().size()>0 )printf(" RecoMu--> Pt: %g eta: %g phi: %g deltaRMax: %g ",evt->MuPtVec_()[0],evt->MuEtaVec_()[0],evt->MuPhiVec_()[0],deltaRMax); // Ahmad3
//else cout << " Muon size is 0 \n " ;
        // in R and in pt
        int matchedMuonIdx = -1;
        if(evt->MuPtVec_().size()>0 && utils->findMatchedObject(matchedMuonIdx,genMuEta,genMuPhi,evt->MuPtVec_(),evt->MuEtaVec_(),evt->MuPhiVec_(),deltaRMax,verbose) ) {
          // Muon is reconstructed
          const double relDeltaPtMu = std::abs(genMuPt - evt->MuPtVec_().at(matchedMuonIdx) ) / evt->MuPtVec_().at(matchedMuonIdx) ;
          if(verbose!=0)printf(" relDeltaPtMu: %g \n ",relDeltaPtMu);
          if( relDeltaPtMu < deltaPtMax ) {
            // and matches generated pt
            if(verbose!=0)printf("Muon is reconstructed \n ");
            // Check if the muon is also isolated: check if an isolated muon is present
            // in the event that matches the reconstructed muon in R
            if( /*muonsRelIso->at(matchedMuonIdx) <= Selection::muIso()*/ true ){
                //.................//.................//
                // Currently muons are picked if they are isolated.
                // So we don't need to put a cut here.     
                //.................//.................//
              // Muon is isolated
              if(verbose!=0)printf("Muon is isolated \n ");
              // Reconstruction-efficiency determination 2: Counter for those events
              // with generator-level muons inside acceptance where the muon has also
              // been reconstructed.
              // Isolation-efficiency determination 2: Counter for those events where
              // the muon is also isolated.
              // hIsoRecoPass->Fill( binMap[utils2::findBin(cntNJetsPt30Eta24,nbtag,HT,template_mht).c_str()] );
              hIsoRecoPass->Fill( binMap[utils2::findBin_NoB(evt->nJets(),evt->ht(),evt->mht()).c_str()] );
            } // End of muon is isolated
          } // End of pt matching
        } // End of reconstructed muon
      } // End of muon in acceptance



    } // end of loop over events


     // Compute acceptance
    TH1* hAcc = static_cast<TH1*>(hAccPass->Clone("hAcc"));
    hAcc->Divide(hAccPass,hAccAll,1,1,"B");// we use B option here because the two histograms are correlated. see TH1 page in the root manual.

    // Compute efficiencies
    TH1* hEff = static_cast<TH1*>(hIsoRecoPass->Clone("hEff"));
    hEff->Divide(hIsoRecoPass,hIsoRecoAll,1,1,"B");

    if(verbose!=0){
      for(int j=1; j<= totNbins; j++){
        printf("hAccAll: %g hAccPass: %g hAcc: %g hIsoRecoAll: %g hIsoRecoPass: %g hEff: %g \n ",hAccAll->GetBinContent(j),hAccPass->GetBinContent(j),hAcc->GetBinContent(j),hIsoRecoAll->GetBinContent(j),hIsoRecoPass->GetBinContent(j),hEff->GetBinContent(j));
      }
    }


    // --- Save the Histograms to File -----------------------------------
    sprintf(tempname,"LostLepton/LostLepton2_MuonEfficienciesFrom%s_%s.root",subSampleKey.c_str(),inputnumber.c_str());
    TFile outFile(tempname,"RECREATE");
    hAcc->Write();
    hEff->Write();
    hAccAll->Write();
    hAccPass->Write();
    hIsoRecoAll->Write();
    hIsoRecoPass->Write();
    outFile.Close();




  } // end of main
开发者ID:hatakeyamak,项目名称:RA2-RA2b-2015,代码行数:101,代码来源:lostLepton.cpp


注:本文中的TH1::Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。