void runcorr(int filenum) { string buffer; vector<string> listoffiles; int nlines = 0; ifstream infile("/net/hisrv0001/home/dav2105/corrana/makecorrhists/oldstuff/sortedforests.txt"); if (!infile.is_open()) { cout << "Error opening file. Exiting." << endl; return; } else { while (!infile.eof()) { infile >> buffer; listoffiles.push_back(buffer); nlines++; } } corrana(listoffiles[filenum].data()); double pttriglow[] = {1,4}; double pttrighigh[] = {2,8}; double ptasslow[] = {1,2}; double ptasshigh[] = {2,3}; int centmin[] = {0,4,8,12,16,20,24,28,32}; int centmax[] = {40,8,12,16,20,24,28,32,36}; TFile * outf = new TFile(Form("corrhists_%d.root",filenum),"recreate"); // for(int i = 0 ; i < 9 ; ++i) // for(int i = 0 ; i < 2 ; ++i) for(int i = 0 ; i < 1 ; ++i) { cout<<"pt iteration "<<i<<endl; // for(int cent = 0 ; cent < 3 ; ++cent) // for(int cent = 0 ; cent < 9 ; ++cent) for(int cent = 0 ; cent < 1 ; ++cent) { cout<<"cent iteration "<<cent<<endl; TH2D * ttsig = TrackTrackSignal(pttriglow[i],pttrighigh[i],ptasslow[i],ptasshigh[i],centmin[cent],centmax[cent]); TH2D * ttbak = TrackTrackBackground(pttriglow[i],pttrighigh[i],ptasslow[i],ptasshigh[i],centmin[cent],centmax[cent]); // TCanvas * c1 = new TCanvas(); // ttsig->Draw("surf1"); // TCanvas * c2 = new TCanvas(); // ttbak->Draw("surf1"); // TCanvas * c3 = new TCanvas(); TH2D * ttcorr = (TH2D*)ttsig->Clone(Form("corr_trg%d_%d_ass%d_%d_cmin%d_cmax%d",(int)pttriglow[i],(int)pttrighigh[i],(int)ptasslow[i],(int)ptasshigh[i],centmin[cent],centmax[cent])); ttcorr->Divide(ttbak); ttcorr->Scale(ttbak->GetBinContent(ttbak->FindBin(0,0))); ttcorr->GetXaxis()->SetRange(ttcorr->GetXaxis()->FindBin(-4.0),ttcorr->GetXaxis()->FindBin(4.0)); ttcorr->GetYaxis()->SetRange(ttcorr->GetYaxis()->FindBin(-3.1415926/2.0),ttcorr->GetYaxis()->FindBin(3*3.1415926/2.0)); // ttcorr->Draw("surf1"); } } outf->Write(); outf->Close(); }
//======================== void PlotRatio2D(Int_t iEff, Int_t iRap){ gStyle->SetOptStat(0); gStyle->SetPaintTextFormat("5.2f"); Char_t name[100]; sprintf(name, "ratio2D_%sEff_%d", effName[iEff], iRap); TCanvas *c1 = new TCanvas(name, name); sprintf(name, "hRatio2D_%sEff_rap%d", effName[iEff], iRap); TH2D *hRatio = (TH2D *) hEffTP2D[iEff][iRap]->Clone(name); hRatio->Divide(hEffMCTruth2D[iEff][iRap]); hRatio->SetMinimum(0.); hRatio->SetMaximum(1.5); hRatio->Draw("colz text"); sprintf(name, "Figures/ratio2D_%sEff_rap%d.pdf", effName[iEff], iRap); c1->Print(name); }
void signalEff2012_PDF_details(const TString what="CTEQMSTW",const TString sample="T1bbbb",const int minnjets=3,const bool useisr=false) { TString njetsstring="."; if (minnjets==3) { //do nothing } else if (minnjets==5) { njetsstring = ".minnjets5."; } else { cout<<" minnjets = "<<minnjets<<" is not ok"<<endl; return; } TString stub1="eventcounts2x2.mergebbins"; if (sample.Contains("pMSSM") ||sample.Contains("T1ttcc") ||sample.Contains("14TeV")||sample.Contains("TChi")) stub1="eventcounts.mergebbins"; TString stub2=stub1; stub2+=".withpdfs"; if ( useisr) { stub1+=".Isr0"; stub2+=".Isr0"; } // TString nominalstub="CSVM_PF2PATjets_JES0_JER0_PFMETTypeI_METunc0_PUunc0_BTagEff05_HLTEff0."; //old TString nominalstub="JES0_JERbias_PFMETTypeI_METunc0_PUunc0_hpt20."; //new, and with JERbias TString f0file = stub1+njetsstring+nominalstub+sample+".root"; TString fpdffile = stub2+njetsstring+nominalstub+sample+".root"; TFile f0(f0file); TFile fpdf(fpdffile); vector<TH2D*> effratios; for (int ih = 0; ih<fpdf.GetListOfKeys()->GetEntries(); ih++) { TString histname = fpdf.GetListOfKeys()->At(ih)->GetName(); if (! (histname.BeginsWith("events_")&&histname.Contains(what))) continue; TString histnametotal = histname; histnametotal.ReplaceAll("events_","eventstotal_"); TString histname0=histname; histname0.ReplaceAll("_"+what+"0",""); TString histname0total = histnametotal; histname0total.ReplaceAll("_"+what+"0",""); TH2D* h0c = (TH2D*) f0.Get(histname0); TH2D* h0t = (TH2D*) f0.Get(histname0total); TH2D* hpdfc = (TH2D*) fpdf.Get(histname); TH2D* hpdft = (TH2D*) fpdf.Get(histnametotal); //now calculate efficiency TH2D* h0r = (TH2D*) h0c->Clone("h0r_"+histname); h0r->Reset(); h0r->Divide(h0c,h0t); TH2D* hpdfr = (TH2D*) hpdfc->Clone("hpdfr_"+histname); hpdfr->Reset(); hpdfr->Divide(hpdfc,hpdft); //and then the ratio of efficiencies TString rname = histname; rname.ReplaceAll("events_","effratio_"); TH2D* heffratio = (TH2D*) h0r->Clone(rname); heffratio->Reset(); heffratio->Divide(hpdfr,h0r); effratios.push_back(heffratio); } TFile fout("signalsyst_PDF_"+what+"."+sample+njetsstring+"root","recreate"); for (unsigned int ii=0; ii<effratios.size();ii++) { effratios.at(ii)->Write(); } fout.Close(); /* quick and dirty version TH2D* h0c = (TH2D*) f0.Get("events_b1_HT1000to100000_MET350to100000_2x2"); TH2D* h0t = (TH2D*) f0.Get("eventstotal_b1_HT1000to100000_MET350to100000_2x2"); TH2D* h0r = (TH2D*) h0c->Clone("h0r"); h0r->Reset(); h0r->Divide(h0c,h0t); TH2D* hpdfc = (TH2D*) fpdf.Get("events_b1_HT1000to100000_MET350to100000_CTEQMSTW0_2x2"); TH2D* hpdft = (TH2D*) fpdf.Get("eventstotal_b1_HT1000to100000_MET350to100000_CTEQMSTW0_2x2"); TH2D* hpdfr = (TH2D*) hpdfc->Clone("hpdfr"); hpdfr->Reset(); hpdfr->Divide(hpdfc,hpdft); TH2D* heffratio = (TH2D*) h0r->Clone("heffratio"); heffratio->Reset(); heffratio->Divide(hpdfr,h0r); heffratio->Draw("COLZ"); */ }
void mcruncorr(int filenum = 0) { string buffer; vector<string> listoffiles; int nlines = 0; ifstream infile("/net/hisrv0001/home/dav2105/corrana/makecorrhists/franksorted.txt"); if (!infile.is_open()) { cout << "Error opening file. Exiting." << endl; return; } else { while (!infile.eof()) { infile >> buffer; listoffiles.push_back(buffer); nlines++; } } // int filenum = 13; cout<<"opening: "<<listoffiles[filenum].data()<<endl; // alicecorrana("/mnt/hadoop/cms/store/user/velicanu/mergedv1_sortedforest/mergesortv1_2.root"); mccorrana(listoffiles[filenum].data()); // double leadingjetptlow[] = {0 ,70 ,70 ,120,90 ,60 ,120,90 ,60 }; // double leadingjetpthigh[] = {300,90 ,300,300,300,300,300,300,300}; // double subleadingjetptlow[] = {70 ,0 ,50 ,50 ,50 ,50 ,50 ,50 ,50 }; // double subleadingjetpthigh[] = {90 ,300,300,300,300,300,300,300,300}; // double ptasslow[] = {1,1,1,2,2,2,3,3,3}; // double ptasshigh[] = {2,2,2,3,3,3,4,4,4}; // int centmin[] = {0,4,8,16,24}; // int centmax[] = {4,8,16,24,28}; double leadingjetptlow[] = {0 ,70 ,0 ,70 ,0 ,70 ,90 ,90 ,90 }; double leadingjetpthigh[] = {300,90 ,300,90 ,300,90 ,300,300,300}; double subleadingjetptlow[] = {70 ,0 ,70 ,0 ,70 ,0 ,50 ,50 ,50 }; double subleadingjetpthigh[] = {90 ,300,300,300,300,300,300,300,300}; double ptasslow[] = {1 ,1 ,2 ,2 ,3 ,3 ,1 ,2 ,3 }; double ptasshigh[] = {2 ,2 ,3 ,3 ,4 ,4 ,2 ,3 ,4 }; int centmin[] = {0,4,8,12,16,20}; int centmax[] = {4,8,12,16,20,24}; TFile * outf = new TFile(Form("frank_pf3_%d.root",filenum),"recreate"); for(int i = 6 ; i < 9 ; ++i) { cout<<"pt iteration "<<i<<endl; // for(int cent = 0 ; cent < 3 ; ++cent) // for(int cent = 0 ; cent < 9 ; ++cent) for(int cent = 0 ; cent < 6 ; ++cent) { cout<<"cent iteration "<<cent<<endl; TH2D * ljtsig = JetTrackSignal(0, leadingjetptlow[i], leadingjetpthigh[i] , subleadingjetptlow[i] , subleadingjetpthigh[i] , ptasslow[i] , ptasshigh[i], centmin[cent], centmax[cent]); TH2D * ljtbak = JetTrackBackground(0, leadingjetptlow[i], leadingjetpthigh[i] , subleadingjetptlow[i] , subleadingjetpthigh[i] , ptasslow[i] , ptasshigh[i], centmin[cent], centmax[cent]); TH2D * ljtcorr = (TH2D*)ljtsig->Clone(Form("corr_leadingjet%d_%d_ass%d_%d_cmin%d_cmax%d",(int)leadingjetptlow[i],(int)leadingjetpthigh[i],(int)ptasslow[i],(int)ptasshigh[i],centmin[cent],centmax[cent])); ljtcorr->Divide(ljtbak); ljtcorr->Scale(ljtbak->GetBinContent(ljtbak->FindBin(0,0))); ljtcorr->GetXaxis()->SetRange(ljtcorr->GetXaxis()->FindBin(-1.6),ljtcorr->GetXaxis()->FindBin(1.6)); ljtcorr->GetYaxis()->SetRange(ljtcorr->GetYaxis()->FindBin(-3.1415926/2.0),ljtcorr->GetYaxis()->FindBin(3*3.1415926/2.0)); TH2D * sljtsig = JetTrackSignal(1, leadingjetptlow[i], leadingjetpthigh[i] , subleadingjetptlow[i] , subleadingjetpthigh[i] , ptasslow[i] , ptasshigh[i], centmin[cent], centmax[cent]); TH2D * sljtbak = JetTrackBackground(1, leadingjetptlow[i], leadingjetpthigh[i] , subleadingjetptlow[i] , subleadingjetpthigh[i] , ptasslow[i] , ptasshigh[i], centmin[cent], centmax[cent]); TH2D * sljtcorr = (TH2D*)sljtsig->Clone(Form("corr_subleadingjet%d_%d_ass%d_%d_cmin%d_cmax%d",(int)leadingjetptlow[i],(int)leadingjetpthigh[i],(int)ptasslow[i],(int)ptasshigh[i],centmin[cent],centmax[cent])); sljtcorr->Divide(sljtbak); sljtcorr->Scale(sljtbak->GetBinContent(sljtbak->FindBin(0,0))); sljtcorr->GetXaxis()->SetRange(sljtcorr->GetXaxis()->FindBin(-1.6),sljtcorr->GetXaxis()->FindBin(1.6)); sljtcorr->GetYaxis()->SetRange(sljtcorr->GetYaxis()->FindBin(-3.1415926/2.0),sljtcorr->GetYaxis()->FindBin(3*3.1415926/2.0)); } } outf->Write(); outf->Close(); }
void makeEfficiency_74X_setBr(bool isPrompt=false, bool isPair=true, bool isEmbedded=true, bool isPtCut = false, bool doWeight = false) { gROOT->Macro("./JpsiStyle.C"); gStyle->SetPaintTextFormat(".3f"); // for text colz //string strDir = "eff_74X_setBr"; // directory name //string strDir = "eff_74X_setBr_wDetached"; // directory name string strDir = "eff_74X_noRegitMuDetached"; // directory name int initev =0; int nevt = -1; //all //int nevt = 1000; int ptbin = 11.; double ptmin = 0.; double ptmax = 11.; if (isEmbedded && !isPrompt) { ptbin = 22.; ptmax = 22.; } int rapbin = 12; double rapmin = -2.4; double rapmax = 2.4; int lxybin = 10; double lxymin = 0.; double lxymax = 1.; string strPrompt; string strEmbd; string strPair; if(isPrompt){ strPrompt = "prompt"; } else { strPrompt = "nonprompt"; } if(isEmbedded){ strEmbd = "embd"; } else { strEmbd = "nonembd"; } if(isPair){ strPair = "Pair"; } else { strPair = "Trk"; } cout << "strPrompt = " << strPrompt.c_str() << endl; cout << "strEmbd = " << strEmbd.c_str() << endl; cout << "strPair = " << strPair.c_str() << endl; ////// read-in file & tree TFile * refFile; if (isEmbedded){ ////// 740pre3 -embd //if (isPrompt){ refFile = new TFile("/home/songkyo/kyo/regitSample/tot_Pythiagun_PromptJpsi_step2nMatch_KYO_regit_embd_20150211.root");} //else { refFile = new TFile("/home/songkyo/kyo/regitSample/tot_Pythiagun_B2JpsiMuMu_step2nMatch_KYO_regit_embd_20150211.root");} ////// 740pre3 -embd with HiDetachedTripletStep //if (isPrompt){ refFile = new TFile("/home/songkyo/kyo/regitSample/tot_Pythiagun_PromptJpsi_step2nMatch_KYO_regit_wDetached_embd_20150224.root");} //else { refFile = new TFile("/home/songkyo/kyo/regitSample/tot_Pythiagun_B2JpsiMuMu_step2nMatch_KYO_regit_wDetached_embd_20150224.root");} ////// 740pre3 - remove some regit : noRegitMuDetached if (isPrompt){ refFile = new TFile("/home/songkyo/kyo/regitSample/tot_Pythiagun_PromptJpsi_step2nMatch_KYO_regit_noRegitMuDetached_embd_20150310.root");} else { refFile = new TFile("/home/songkyo/kyo/regitSample/tot_Pythiagun_B2JpsiMuMu_step2nMatch_KYO_regit_noRegitMuDetached_embd_20150310.root");} } else { //730pre2 -nonembd if (isPrompt){ refFile = new TFile("/home/songkyo/kyo/regitSample/tot_Pythiagun_PromptJpsi_step2nMatch_KYO_regit_20141121.root");} else { refFile = new TFile("/home/songkyo/kyo/regitSample/tot_Pythiagun_B2Jpsi_step2nMatch_KYO_regit_20141203_no9_32_90.root");} } TTree *tr = new TTree(); if(isPair) { tr = (TTree*)refFile->Get("mcmatchanalysis/pnSimRecoPairType1");} else { tr = (TTree*)refFile->Get("mcmatchanalysis/pnSimRecoTrkType1"); } /* //for pT-|y| weight TFile *fWeight; if (isPrompt){ fWeight = new TFile("./pTdist_diffY/pTdist_diffY_prompt.root");} else {fWeight = new TFile("./pTdist_diffY/pTdist_diffY_nonprompt.root");} const int nYBin = 4; TH1D* hWeight[nYBin]; for (int i=0; i< nYBin; i++){ if (isPair) { hWeight[i] = (TH1D*)fWeight->Get(Form("hPairRatio_%d",i)); } else { hWeight[i] = (TH1D*)fWeight->Get(Form("hTrkRatio_%d",i)); }; //cout << i << "th hWeight = " << hWeight[i] << endl; cout << i << "th hWeight Name= " << hWeight[i]->GetName() << endl; } */ /////////////////////////////////////// ////// Pair ////// //gen Float_t pt; Float_t y; Float_t pt1; Float_t eta1; Float_t npixelhits1; Float_t nmuonhits1; Float_t pt2; Float_t eta2; Float_t npixelhits2; Float_t nmuonhits2; //reco Float_t ptreco; Float_t yreco; Float_t minvreco; Float_t ptreco1; Float_t etareco1; Float_t nvalidpixelhitsreco1; Float_t nvalidmuonhitsreco1; Float_t nmatch1; Float_t chi2ndofreco1; Float_t ptreco2; Float_t etareco2; Float_t nvalidpixelhitsreco2; Float_t nvalidmuonhitsreco2; Float_t nmatch2; Float_t chi2ndofreco2; // for lxy Float_t vtxz1; Float_t vtxy1; Float_t bx; Float_t by; ////// Trk (additional)////// //gen Float_t eta; Float_t idparent; Float_t npixelhits; Float_t nmuonhits; //reco Float_t etareco; Float_t nvalidpixelhitsreco; Float_t nvalidmuonhitsreco; Float_t nmatch; Float_t chi2ndofreco; // for lxy Float_t vtxz; Float_t vtxy; /////////////////////////////////////// //Branches /////////////////////////////////////// TBranch *b_pt; TBranch *b_y; TBranch *b_pt1; TBranch *b_eta1; TBranch *b_npixelhits1; TBranch *b_nmuonhits1; TBranch *b_pt2; TBranch *b_eta2; TBranch *b_npixelhits2; TBranch *b_nmuonhits2; //reco TBranch *b_ptreco; TBranch *b_yreco; TBranch *b_minvreco; TBranch *b_ptreco1; TBranch *b_etareco1; TBranch *b_nvalidpixelhitsreco1; TBranch *b_nvalidmuonhitsreco1; TBranch *b_nmatch1; TBranch *b_chi2ndofreco1; TBranch *b_ptreco2; TBranch *b_etareco2; TBranch *b_nvalidpixelhitsreco2; TBranch *b_nvalidmuonhitsreco2; TBranch *b_nmatch2; TBranch *b_chi2ndofreco2; // for lxy TBranch *b_vtxz1; TBranch *b_vtxy1; TBranch *b_bx; TBranch *b_by; ////// Trk (additional)////// //gen TBranch *b_eta; TBranch *b_idparent; TBranch *b_npixelhits; TBranch *b_nmuonhits; //reco TBranch *b_etareco; TBranch *b_nvalidpixelhitsreco; TBranch *b_nvalidmuonhitsreco; TBranch *b_nmatch; TBranch *b_chi2ndofreco; // for lxy TBranch *b_vtxz; TBranch *b_vtxy; /////////////////////////////////////// //BranchAddress /////////////////////////////////////// tr->SetBranchAddress("pt",&pt,&b_pt); tr->SetBranchAddress("ptreco",&ptreco,&b_ptreco); tr->SetBranchAddress("bx",&bx,&b_bx); tr->SetBranchAddress("by",&by,&b_by); if (isPair) { tr->SetBranchAddress("y",&y,&b_y); tr->SetBranchAddress("pt1",&pt1,&b_pt1); tr->SetBranchAddress("eta1",&eta1,&b_eta1); tr->SetBranchAddress("npixelhits1",&npixelhits1,&b_npixelhits1); tr->SetBranchAddress("nmuonhits1",&nmuonhits1,&b_nmuonhits1); tr->SetBranchAddress("pt2",&pt2,&b_pt2); tr->SetBranchAddress("eta2",&eta2,&b_eta2); tr->SetBranchAddress("npixelhits2",&npixelhits2,&b_npixelhits2); tr->SetBranchAddress("nmuonhits2",&nmuonhits2,&b_nmuonhits2); tr->SetBranchAddress("yreco",&yreco,&b_yreco); tr->SetBranchAddress("minvreco",&minvreco,&b_minvreco); tr->SetBranchAddress("ptreco1",&ptreco1,&b_ptreco1); tr->SetBranchAddress("etareco1",&etareco1,&b_etareco1); tr->SetBranchAddress("nvalidpixelhitsreco1",&nvalidpixelhitsreco1,&b_nvalidpixelhitsreco1); tr->SetBranchAddress("nvalidmuonhitsreco1",&nvalidmuonhitsreco1,&b_nvalidmuonhitsreco1); tr->SetBranchAddress("nmatch1",&nmatch1,&b_nmatch1); tr->SetBranchAddress("chi2ndofreco1",&chi2ndofreco1,&b_chi2ndofreco1); tr->SetBranchAddress("ptreco2",&ptreco2,&b_ptreco2); tr->SetBranchAddress("etareco2",&etareco2,&b_etareco2); tr->SetBranchAddress("nvalidpixelhitsreco2",&nvalidpixelhitsreco2,&b_nvalidpixelhitsreco2); tr->SetBranchAddress("nvalidmuonhitsreco2",&nvalidmuonhitsreco2,&b_nvalidmuonhitsreco2); tr->SetBranchAddress("nmatch2",&nmatch2,&b_nmatch2); tr->SetBranchAddress("chi2ndofreco2",&chi2ndofreco2,&b_chi2ndofreco2); tr->SetBranchAddress("vtxz1",&vtxz1,&b_vtxz1); tr->SetBranchAddress("vtxy1",&vtxy1,&b_vtxy1); } else { tr->SetBranchAddress("eta",&eta,&b_eta); tr->SetBranchAddress("etareco",&etareco,&b_etareco); tr->SetBranchAddress("idparent",&idparent,&b_idparent); tr->SetBranchAddress("npixelhits",&npixelhits,&b_npixelhits); tr->SetBranchAddress("nmuonhits",&nmuonhits,&b_nmuonhits); tr->SetBranchAddress("nvalidpixelhitsreco",&nvalidpixelhitsreco,&b_nvalidpixelhitsreco); tr->SetBranchAddress("nvalidmuonhitsreco",&nvalidmuonhitsreco,&b_nvalidmuonhitsreco); tr->SetBranchAddress("nmatch",&nmatch,&b_nmatch); tr->SetBranchAddress("chi2ndofreco",&chi2ndofreco,&b_chi2ndofreco); tr->SetBranchAddress("vtxz",&vtxz,&b_vtxz); tr->SetBranchAddress("vtxy",&vtxy,&b_vtxy); } //2D hist. just check TH2D* hGenPtY = new TH2D("hGenPtY","hGenPtY",50,rapmin,rapmax,50,ptmin,ptmax); TH2D* hRecoPtY = new TH2D("hRecoPtY","hRecoPtY",50,rapmin,rapmax,50,ptmin,ptmax); TH2D* hEffPtY = new TH2D("hEffPtY","hEffPtY",50,rapmin,rapmax,50,ptmin,ptmax); TH1D* hGenPt = new TH1D("hGenPt","hGenPt",ptbin,ptmin,ptmax); TH1D* hRecoPt = new TH1D("hRecoPt","hRecoPt",ptbin,ptmin,ptmax); TH1D* hEffPt = new TH1D("hEffPt","hEffPt",ptbin,ptmin,ptmax); TH1D* hGenRap = new TH1D("hGenRap","hGenRap",rapbin,rapmin,rapmax); TH1D* hRecoRap = new TH1D("hRecoRap","hRecoRap",rapbin,rapmin,rapmax); TH1D* hEffRap = new TH1D("hEffRap","hEffRap",rapbin,rapmin,rapmax); TH1D* hGenLxy = new TH1D("hGenLxy","hGenLxy",lxybin,lxymin,lxymax); TH1D* hRecoLxy = new TH1D("hRecoLxy","hRecoLxy",lxybin,lxymin,lxymax); TH1D* hEffLxy = new TH1D("hEffLxy","hEffLxy",lxybin,lxymin,lxymax); hGenPtY->Sumw2(); hRecoPtY->Sumw2(); hEffPtY->Sumw2(); hGenPt->Sumw2(); hRecoPt->Sumw2(); hEffPt->Sumw2(); hGenRap->Sumw2(); hRecoRap->Sumw2(); hEffRap->Sumw2(); hGenLxy->Sumw2(); hRecoLxy->Sumw2(); hEffLxy->Sumw2(); //event loop start if(nevt == -1) nevt = tr->GetEntries(); for (int iev=initev; iev<nevt; iev++){ tr->GetEntry(iev); bool yngen = false; bool ynreco = false; float weightF = 1.; float lxy = -531.; /// give a cut to Gen and Reco separately if (isPair) { if (isPtCut) { if ( !(pt<15.) ) continue; } /// define IP lxy = TMath::Sqrt((vtxz1-bx)*(vtxz1-bx)+(vtxy1-by)*(vtxy1-by)); if (kineCut(pt1,eta1) && kineCut(pt2,eta2) && idCut(npixelhits1,nmuonhits1) && idCut(npixelhits2,nmuonhits2) ) { yngen=true; } if (kineCut(ptreco1,etareco1) && kineCut(ptreco2,etareco2) && idCut(nvalidpixelhitsreco1,nvalidmuonhitsreco1) && idCut(nvalidpixelhitsreco2,nvalidmuonhitsreco2) //&& idRecoCut(nmatch1, chi2ndofreco1) //&& idRecoCut(nmatch2, chi2ndofreco2) && chi2ndofreco1 < 4. && chi2ndofreco2 < 4. && massCut(minvreco) ) { ynreco=true;} } else { if (isPtCut) { if (!(pt >1. && pt<15. ) ) continue; } /// define IP lxy = TMath::Sqrt((vtxz-bx)*(vtxz-bx)+(vtxy-by)*(vtxy-by)); if ( (!isEmbedded) && TMath::Abs(eta) < 2.4 && TMath::Abs(idparent)>442 && TMath::Abs(idparent)<550 && idCut(npixelhits,nmuonhits) ) { yngen=true; } else if ( isEmbedded && TMath::Abs(eta) < 2.4 //&& TMath::Abs(idparent)>442 //&& TMath::Abs(idparent)<550 && idCut(npixelhits,nmuonhits) ) { yngen=true; } if ( (!isEmbedded) //TMath::Abs(etareco) < 2.4 && TMath::Abs(eta) < 2.4 && TMath::Abs(idparent)>442 && TMath::Abs(idparent)<550 && idCut(nvalidpixelhitsreco,nvalidmuonhitsreco) && idRecoCut(nmatch, chi2ndofreco) ) { ynreco=true;} else if ( isEmbedded //TMath::Abs(etareco) < 2.4 && TMath::Abs(eta) < 2.4 //&& TMath::Abs(idparent)>442 //&& TMath::Abs(idparent)<550 && idCut(nvalidpixelhitsreco,nvalidmuonhitsreco) && idRecoCut(nmatch, chi2ndofreco) ) { ynreco=true;} } /// weight if "doWeight" && fill the histogram if (isPair){ if (doWeight) {weightF = getWeight(isPrompt, isPair, pt,y);} // cout << "weightF = " <<weightF << endl; if (yngen) { hGenPtY->Fill(y,pt,weightF); hGenPt->Fill(pt,weightF); hGenRap->Fill(y,weightF); hGenLxy->Fill(lxy,weightF); } if (ynreco) { hRecoPtY->Fill(yreco,ptreco,weightF); hRecoPt->Fill(ptreco, weightF); hRecoRap->Fill(yreco, weightF); hRecoLxy->Fill(lxy, weightF); } }else { if (doWeight) {weightF = getWeight(isPrompt, isPair, pt,eta);} // cout << "weightF = " <<weightF << endl; if (yngen) { hGenPtY->Fill(eta,pt,weightF); hGenPt->Fill(pt,weightF); hGenRap->Fill(eta,weightF); hGenLxy->Fill(lxy,weightF); } if (ynreco) { hRecoPtY->Fill(etareco,ptreco,weightF); hRecoPt->Fill(ptreco,weightF); hRecoRap->Fill(etareco,weightF); hRecoLxy->Fill(lxy, weightF); } } }// end of event loop cout << "hGenPt integral = " << hGenPt->Integral() << endl; cout << "hRecoPt integral = " << hRecoPt->Integral() << endl; cout << "hGenRap integral = " << hGenRap->Integral() << endl; cout << "hRecoRap integral = " << hRecoRap->Integral() << endl; cout << "hGenLxy integral = " << hGenLxy->Integral() << endl; cout << "hRecoLxy integral = " << hRecoLxy->Integral() << endl; //calculate efficiency hEffPtY->Divide(hRecoPtY,hGenPtY,1,1,"b"); hEffPt->Divide(hRecoPt,hGenPt,1,1,"b"); hEffRap->Divide(hRecoRap,hGenRap,1,1,"b"); hEffLxy->Divide(hRecoLxy,hGenLxy,1,1,"b"); //Legend TLegend *legUR = new TLegend(0.56,0.68,0.90,0.90,NULL,"brNDC"); TLegend *legUL = new TLegend(0.17,0.68,0.51,0.90,NULL,"brNDC"); TLegend *legBM = new TLegend(0.40,0.20,0.75,0.35,NULL,"brNDC"); TLegend *legBR = new TLegend(0.56,0.20,0.90,0.42,NULL,"brNDC"); SetLegendStyle(legUR); SetLegendStyle(legUL); SetLegendStyle(legBM); SetLegendStyle(legBR); TCanvas *c1 = new TCanvas("c1","c1",600,600); //draw 2D Pt-y TPaletteAxis* pal; hEffPtY->SetMinimum(0.0); hEffPtY->SetMaximum(1.0); if (isPair) hEffPtY->GetXaxis()->SetTitle("y"); else hEffPtY->GetXaxis()->SetTitle("#eta"); hEffPtY->GetXaxis()->CenterTitle(); hEffPtY->GetYaxis()->SetTitle("p_{T} (GeV)"); hEffPtY->Draw("colz"); c1->Update(); pal = (TPaletteAxis*)hEffPtY->GetListOfFunctions()->FindObject("palette"); pal->SetX2NDC(0.92); c1->Modified(); c1->Update(); c1->SaveAs(Form("%s/EffPtY_isPtCut%d_doWeight%d_isEmbedded%d_%s_%s_%s.pdf",strDir.c_str(),(int)isPtCut,(int)doWeight,(int)isEmbedded,strPrompt.c_str(),strEmbd.c_str(),strPair.c_str())); c1->Clear(); //draw EffPt SetHistStyle(hEffPt,3,0); hEffPt->SetMinimum(0.0); hEffPt->SetMaximum(1.0); if (isPair) hEffPt->GetXaxis()->SetTitle("Pair p_{T} (GeV)"); else hEffPt->GetXaxis()->SetTitle("Trk p_{T} (GeV)"); hEffPt->GetYaxis()->SetTitle("Efficiency"); hEffPt->Draw("pe"); c1->SaveAs(Form("%s/EffPt_isPtCut%d_doWeight%d_isEmbedded%d_%s_%s_%s.pdf",strDir.c_str(),(int)isPtCut,(int)doWeight,(int)isEmbedded,strPrompt.c_str(),strEmbd.c_str(),strPair.c_str())); c1->Clear(); //draw EffRap SetHistStyle(hEffRap,3,0); hEffRap->SetMinimum(0.0); hEffRap->SetMaximum(1.0); if (isPair) hEffRap->GetXaxis()->SetTitle("y"); else hEffRap->GetXaxis()->SetTitle("#eta"); hEffRap->GetXaxis()->CenterTitle(); hEffRap->GetYaxis()->SetTitle("Efficiency"); hEffRap->Draw("pe"); c1->SaveAs(Form("%s/EffRap_isPtCut%d_doWeight%d_isEmbedded%d_%s_%s_%s.pdf",strDir.c_str(),(int)isPtCut,(int)doWeight,(int)isEmbedded,strPrompt.c_str(),strEmbd.c_str(),strPair.c_str())); c1->Clear(); //draw EffLxy SetHistStyle(hEffLxy,3,0); hEffLxy->SetMinimum(0.0); hEffLxy->SetMaximum(1.0); hEffLxy->GetXaxis()->SetTitle("Lxy"); hEffLxy->GetYaxis()->SetTitle("Efficiency"); hEffLxy->Draw("pe"); c1->SaveAs(Form("%s/EffLxy_isPtCut%d_doWeight%d_isEmbedded%d_%s_%s_%s.pdf",strDir.c_str(),(int)isPtCut,(int)doWeight,(int)isEmbedded,strPrompt.c_str(),strEmbd.c_str(),strPair.c_str())); c1->Clear(); //save as a root file TFile* outFile = new TFile(Form("%s/Eff_isPtCut%d_doWeight%d_isEmbedded%d_%s_%s_%s.root",strDir.c_str(),(int)isPtCut,(int)doWeight,(int)isEmbedded,strPrompt.c_str(),strEmbd.c_str(),strPair.c_str()),"RECREATE"); outFile->cd(); hGenPtY->Write(); hRecoPtY->Write(); hEffPtY->Write(); hGenPt->Write(); hGenRap->Write(); hGenLxy->Write(); hRecoPt->Write(); hRecoRap->Write(); hRecoLxy->Write(); hEffPt->Write(); hEffRap->Write(); hEffLxy->Write(); outFile->Close(); return; }
int genbod_diff(const char* filename1, const char* filename2, bool ifSave = false) { TFile* f1 = new TFile(filename1,"READ"); TFile* f2 = new TFile(filename2,"READ"); TH2D* numF1 = ((TH2D*) f1->Get("cnumepNonIdEP")); TH2D* numF2 = ((TH2D*) f2->Get("cnumepNonIdEP")); TH2D* denF1 = ((TH2D*) f1->Get("cdenepNonIdEP")); TH2D* denF2 = ((TH2D*) f2->Get("cdenepNonIdEP")); TH2D* numB1 = ((TH2D*) f1->Get("cnumepNonIdEPTrue")); TH2D* numB2 = ((TH2D*) f2->Get("cnumepNonIdEPTrue")); TH2D* denB1 = ((TH2D*) numF1->Clone()); TH2D* denB2 = ((TH2D*) numF2->Clone()); TH2D* numC1 = ((TH2D*) numB1->Clone()); TH2D* numC2 = ((TH2D*) numB2->Clone()); TH2D* denC1 = ((TH2D*) f1->Get("cdenepNonIdEPTrue")); TH2D* denC2 = ((TH2D*) f2->Get("cdenepNonIdEPTrue")); double eta = 1.1; gStyle->SetOptStat(111); //TCanvas* canv = new TCanvas("canv", "GENBOD results", 10,10,800,600); TCanvas* canv = new TCanvas("canv", "GENBOD results", 10,10,1600,1200); canv->Divide(3,3); //TCanvas* canvND = new TCanvas("canvND", "liczniki i mianowniki ", 10,10,800,600); TCanvas* canvND = new TCanvas("canvND", "liczniki i mianowniki ", 10,10,1600,1200); canvND->Divide(2,2); ////// Pure Corr fun TH2D* numdiff = (TH2D*)numF1->Clone(); numdiff->Divide(numF2); canvND->cd(1); numdiff->DrawCopy("colz"); TH2D* dendiff = (TH2D*)denF1->Clone(); dendiff->Divide(denF2); canvND->cd(2); dendiff->DrawCopy("colz"); double sF1 = numF1->GetEntries()/denF1->GetEntries(); numF1->Divide(denF1); numF1->Scale(1./sF1); numF1->GetYaxis()->SetRangeUser(-eta,eta); double sF2 = numF2->GetEntries()/denF2->GetEntries(); numF2->Divide(denF2); numF2->Scale(1./sF2); numF2->GetYaxis()->SetRangeUser(-eta,eta); canv->cd(1); TH2D* corrF1 = (TH2D*) numF1->Clone(); corrF1->Draw("surf1"); DrawNicely(corrF1, 0,0, filename1); canv->cd(2); TH2D* corrF2 = (TH2D*) numF2->Clone(); corrF2->Draw("surf1"); DrawNicely(corrF2, 0,0, filename2); canv->cd(3); numF1->Divide(numF2); DrawNicely(numF1, 0,0, "Femtoscopic component"); numF1->Draw("colz"); ////// Pure Bkg TH2D* numdiffTrue = (TH2D*)numB1->Clone(); numdiffTrue->Divide(numB2); canvND->cd(3); numdiffTrue->DrawCopy("colz"); double sB1 = numB1->GetEntries()/denB1->GetEntries(); numB1->Divide(denB1); numB1->Scale(1./sB1); numB1->GetYaxis()->SetRangeUser(-eta,eta); double sB2 = numB2->GetEntries()/denB2->GetEntries(); numB2->Divide(denB2); numB2->Scale(1./sB2); numB2->GetYaxis()->SetRangeUser(-eta,eta); canv->cd(4); TH2D* corrB1 = (TH2D*) numB1->Clone(); corrB1->Draw("surf1"); DrawNicely(corrB1, 0,0, filename1); canv->cd(5); TH2D* corrB2 = (TH2D*) numB2->Clone(); corrB2->Draw("surf1"); DrawNicely(corrB2, 0,0, filename2); canv->cd(6); numB1->Divide(numB2); DrawNicely(numB1, 0,0, "Background component"); numB1->DrawCopy("colz"); ////// Norm Corr fun TH2D* dendiffTrue = (TH2D*)denC1->Clone(); dendiffTrue->Divide(denC2); canvND->cd(4); dendiffTrue->DrawCopy("colz"); double sC1 = numC1->GetEntries()/denC1->GetEntries(); numC1->Divide(denC1); numC1->Scale(1./sC1); numC1->GetYaxis()->SetRangeUser(-eta,eta); double sC2 = numC2->GetEntries()/denC2->GetEntries(); numC2->Divide(denC2); numC2->Scale(1./sC2); numC2->GetYaxis()->SetRangeUser(-eta,eta); canv->cd(7); TH2D* corrC1 = (TH2D*) numC1->Clone(); corrC1->Draw("surf1"); DrawNicely(corrC1, 0,0, filename1); canv->cd(8); TH2D* corrC2 = (TH2D*) numC2->Clone(); corrC2->Draw("surf1"); DrawNicely(corrC2, 0,0, filename2); canv->cd(9); numC1->Divide(numC2); DrawNicely(numC1, 0,0, "Correlation function"); numC1->DrawCopy("colz"); //save if (ifSave) { canv->Print(Form("diff_%s_%s_global.png",filename1,filename2)); canvND->Print(Form("diff_%s_%s_global_NumDen.png",filename1,filename2)); } }
TFile* SUSYLooperHists::Loop() { // In a ROOT session, you can do: // Root > .L SUSYLooperHists.C // Root > SUSYLooperHists t // Root > t.GetEntry(12); // Fill t data members with entry number 12 // Root > t.Show(); // Show values of entry 12 // Root > t.Show(16); // Read and show values of entry 16 // Root > t.Loop(); // Loop on all entries // // This is the loop skeleton where: // jentry is the global entry number in the chain // ientry is the entry number in the current Tree // Note that the argument to GetEntry must be: // jentry for TChain::GetEntry // ientry for TTree::GetEntry and TBranch::GetEntry // // To read only selected branches, Insert statements like: // METHOD1: // fChain->SetBranchStatus("*",0); // disable all branches // fChain->SetBranchStatus("branchname",1); // activate branchname // METHOD2: replace line // fChain->GetEntry(jentry); //read all branches //by b_branchname->GetEntry(ientry); //read only this branch if (fChain == 0) return NULL; Long64_t nentries = fChain->GetEntriesFast(); TFile* myFile = new TFile(outputFileName,"recreate"); // checks the Mtt mass ++ simple plot example ++ TH1D* LepTwoZmass= new TH1D("LepTwoZmass",";approximate Z(#tau#tau) mass [GeV];",100,0,2000); LepTwoZmass->Sumw2(); // baseline plots +++++++++++++++++++++ // allow to fill cutflow to sychronize to others TH1D* CutFlow = new TH1D("CutFlow",";CutFlow [unweighted];",20,-0.5,19.5); CutFlow->Sumw2(); TH1D* Sig = new TH1D("Sig",";3DSig;",25,-0.,50); Sig->Sumw2(); TH1D* Dxy = new TH1D("Dxy",";Dxy;",50,-0.,0.2); Dxy->Sumw2(); TH1D* Dz = new TH1D("Dz",";Dz;",50,-0.,0.2); Dz->Sumw2(); TH2D* DxyDz = new TH2D("DxyDz",";3DSig;",100,-0.,0.2,100,-0.,0.2); DxyDz->Sumw2(); TH1D* IP3D = new TH1D("IP3D",";IP3D;",500,-0.,.5); IP3D->Sumw2(); TH1D* Sig0 = new TH1D("Sig0",";3DSig;",50,-0.,50); Sig0->Sumw2(); TH1D* Pt = new TH1D("Pt",";Pt;",200,-0.,25); Pt->Sumw2(); TH1D* Iso = new TH1D("Is",";Is;",200,-0.,5); Iso->Sumw2(); TH1D* LooseBPt = new TH1D("LooseBPt",";Pt;",200,-0.,500); LooseBPt->Sumw2(); // a scan should be filled without weight*puWeights before any cut to get the efficiency. The reason is that for a scan each points have different x-section, which are not accessable during the loop TH2D* scan = new TH2D("scan","scan",8,112.5,312.5,40,112.5,312.5); // fill after some cuts the scans to get efficiency, i.e. ->Divide(scan) after the loop TH2D* scanA = new TH2D("scanA","scan",8,112.5,312.5,40,112.5,312.5); TH2D* scanB = new TH2D("scanB","scan",8,112.5,312.5,40,112.5,312.5); TH2D* scanC = new TH2D("scanC","scan",8,112.5,312.5,40,112.5,312.5); // plot a mass TH1D* GenMll = new TH1D("GenMll",";GenMll;",200,-0,200); GenMll->Sumw2(); Long64_t nbytes = 0, nb = 0; for (Long64_t jentry=0; jentry<nentries;jentry++) { Long64_t ientry = LoadTree(jentry); if (ientry < 0) break; nb = fChain->GetEntry(jentry); nbytes += nb; if(jentry%100000==0) cout << "Event: "<<jentry <<endl; scan->Fill(GenSusyMStop,GenSusyMNeutralino); // select lepton and put it into TLorentzvector TLorentzVector lep; TLorentzVector met; vector <TLorentzVector> lepVec; for(int i =0;i<nLepGood;i++) { TLorentzVector aLep; aLep.SetPtEtaPhiM(LepGood_pt[i],LepGood_eta[i],LepGood_phi[i],0.1); lepVec.push_back(aLep); } if(nLepGood>0) lep.SetPtEtaPhiM(LepGood_pt[0],LepGood_eta[0],LepGood_phi[0],0.1); else lep.SetPtEtaPhiM(0,0,0,0.1); met.SetPtEtaPhiM(met_pt,0.,met_phi,0); float MT = sqrt(lep.Pt()*2*met.Pt()*(1-cos(lep.DeltaPhi(met)))); TLorentzVector jetSum; vector <TLorentzVector> myVecJets; jetSum.SetPtEtaPhiM(0,0,0,0); unsigned int nb40=0; unsigned int nb30L=0; float HT30 = 0; for (int i=0;i<nJet;i++) { TLorentzVector myjet; //cout <<" pt: " << Jet_pt[i] << " "<< Jet_eta[i]<< " "<< Jet_phi[i]<< " QG "<< Jet_quarkGluonID[i] <<endl; myjet.SetPtEtaPhiM(Jet_pt[i],Jet_eta[i],Jet_phi[i],Jet_mass[i]); jetSum=jetSum+myjet; myVecJets.push_back(myjet); if(Jet_btagCSV[i]>0.679) { nb40++; } if(Jet_btagCSV[i]>0.244) { nb30L++; } if(fabs(Jet_eta[i])<4.5&&Jet_pt[i]>30) HT30=HT30+Jet_pt[i]; // QG->Fill(Jet_quarkGluonID[i]); } // preselection syncronizd to Antonis ++++++++++++++++++++ if( nLepGood == 0 ) continue; CutFlow->Fill(0.); if(HLT_MetTrigger!=1) continue; if(met.Pt()<200) continue; if(nLepGood<2) continue; if(nJet==0) continue; if(nTauGood!=0) continue; CutFlow->Fill(1.); // if(fabs(LepGood_pdgId[0]* LepGood_pdgId[1])<122) continue; CutFlow->Fill(2.); if(lep.Pt()<5||fabs(lep.Eta())>1.5||lep.Pt()>60) continue; CutFlow->Fill(3.); if(fabs(LepGood_pdgId[0])==11&&lep.Pt()<7) continue; CutFlow->Fill(4.); // check that a cut was ahead in nLepton !!!!!!!! TLorentzVector secondLep; secondLep.SetPtEtaPhiM(LepGood_pt[1], LepGood_eta[1], LepGood_phi[1],0.1); if(secondLep.Pt()<3||fabs(secondLep.Eta())>1.5||secondLep.Pt()>60) continue; CutFlow->Fill(5.); // lepton cuts if(LepGood_relIso[0]*lep.Pt()>10.) continue; if(LepGood_relIso[1]*secondLep.Pt()>5.) continue; if(LepGood_relIso[1]>.5) continue; CutFlow->Fill(6.); // JET CUTS if(nJet>0){ if (Jet_pt[0] < 150) continue; if(fabs(Jet_eta[0]) > 2.4) continue; } if(nJet>2){ if (Jet_pt[2] > 60) continue; } CutFlow->Fill(7.); if(met.Pt()/HT30<2./3.) continue; if(nb40!=0) continue; CutFlow->Fill(9.); // preselection syncronized to ++++++++++++++++++++ if(MT>60&&MT<100) continue; if (weight==1) puWeight=1; // to not effect data float pairmass = DiTau_InvMass(met,lep,secondLep,0); if(lep.Pt()>25||secondLep.Pt()>15) continue; if(fabs(LepGood_dz[1]) > 0.02||fabs(LepGood_dz[0]) > 0.02 ||fabs(LepGood_dxy[1])> 0.02 || fabs(LepGood_dxy[0])> 0.02 ) continue; // define some over and underflow if (pairmass>2000) pairmass=1999.; if (pairmass<0) pairmass=0.; LepTwoZmass->Fill(pairmass,weight*puWeight); // cout << LepGood_pdgId[0]* LepGood_pdgId[1] << " Ids "<<endl; if(LepGood_pdgId[0]*LepGood_pdgId[1]>121) //same sign { if((pairmass>160||pairmass<20)){ CutFlow->Fill(10., weight*puWeight); scanB->Fill(GenSusyMStop,GenSusyMNeutralino); // if (weight<0) weight=1; Sig->Fill(LepGood_sip3d[1],weight*puWeight); Sig0->Fill(LepGood_sip3d[0],weight*puWeight); IP3D->Fill(LepGood_ip3d[0],weight*puWeight); Pt->Fill(secondLep.Pt(),weight*puWeight); Iso->Fill(LepGood_relIso[1]*secondLep.Pt(),weight*puWeight); Dxy->Fill(fabs(LepGood_dxy[1]),weight*puWeight); Dz->Fill(fabs(LepGood_dz[1]),weight*puWeight); DxyDz->Fill(fabs(LepGood_dxy[1]),fabs(LepGood_dz[1]),weight*puWeight); if(nb30L==0) { scanC->Fill(GenSusyMStop,GenSusyMNeutralino); } for (int i=0;i<nJet;i++) { if(Jet_btagCSV[i]>0.244 ) { LooseBPt->Fill(Jet_pt[i],weight*puWeight ); } // QG->Fill(Jet_quarkGluonID[i]); } } else // same sign leptons { } } } scanA->Divide(scan); scanB->Divide(scan); scanC->Divide(scan); // CutFlow->DrawCopy(); myFile->Write(); return (myFile); // if (Cut(ientry) < 0) continue; }
//iteration code void iterate(TrkSettings s,int iter, int stepType, bool doCondor, bool testErrors = false) { float pt, eta, phi, weight, centPU, rmin, maxJetPt,trkStatus,pNRec,mpt,mtrkQual,nEv; TFile * histFile; std::string ifPP = ""; if(s.nPb==0) ifPP = "pp_"; if(iter==0) histFile = TFile::Open(Form("%scorrHists_job%d.root",ifPP.c_str(),s.job),"recreate"); else histFile = TFile::Open(Form("%scorrHists_job%d.root",ifPP.c_str(),s.job),"update"); //make needed gen skim if it hasn't been done yet if(iter==0) { TH1D *genPre[20], *mrecoPre[20]; TH2D *genPre2[20], *mrecoPre2[20]; std::cout << "Denominator info not yet calculated; calculating and saving it..." << std::endl; for(int i = 0; i<8; i++) { if(i==6) continue; if(i != 1 && i!=7) { genPre[i] = makeTH1(s,i,"gen"); mrecoPre[i] = makeTH1(s,i,"mreco"); } else { genPre2[i] = makeTH2(s,i,"gen"); mrecoPre2[i]= makeTH2(s,i,"mreco"); } } TFile * skim; if(doCondor) { if(s.reuseSkim) skim = TFile::Open(Form("/mnt/hadoop/cms/store/user/abaty/tracking_Efficiencies/ntuples/%strackSkim_job%d.root",ifPP.c_str(),s.job),"read"); else skim = TFile::Open(Form("%strackSkim_job%d.root",ifPP.c_str(),s.job),"read"); } else skim = TFile::Open(Form("/export/d00/scratch/abaty/trackingEff/ntuples/%strackSkim_job%d.root",ifPP.c_str(),s.job),"read"); //for efficiency std::cout << "Doing Efficiency denominator" << std::endl; TNtuple * gen = (TNtuple*) skim->Get("Gen"); gen->SetBranchAddress("genPt",&pt); gen->SetBranchAddress("genEta",&eta); gen->SetBranchAddress("genPhi",&phi); gen->SetBranchAddress("weight",&weight); gen->SetBranchAddress("centPU",¢PU); gen->SetBranchAddress("rmin",&rmin); gen->SetBranchAddress("jtpt",&maxJetPt); gen->SetBranchAddress("pNRec",&pNRec); gen->SetBranchAddress("nEv",&nEv); for(int i = 0; i<gen->GetEntries(); i++) { gen->GetEntry(i); if(s.doSplit && nEv==1) continue; genPre[0]->Fill(pt,weight); genPre2[1]->Fill(eta,phi,weight); genPre[2]->Fill(centPU,weight); genPre[3]->Fill(maxJetPt,weight); genPre[4]->Fill(eta,weight); genPre[5]->Fill(rmin,weight); genPre2[7]->Fill(eta,pt,weight); } //for fake std::cout << "Doing Fake denominator" << std::endl; TNtuple * reco = (TNtuple*) skim->Get("Reco"); reco->SetBranchAddress("trkPt",&pt); reco->SetBranchAddress("trkEta",&eta); reco->SetBranchAddress("trkPhi",&phi); reco->SetBranchAddress("weight",&weight); reco->SetBranchAddress("centPU",¢PU); reco->SetBranchAddress("rmin",&rmin); reco->SetBranchAddress("jtpt",&maxJetPt); reco->SetBranchAddress("trkStatus",&trkStatus); reco->SetBranchAddress("nEv",&nEv); for(int i = 0; i<reco->GetEntries(); i++) { reco->GetEntry(i); if(s.doSplit && nEv==1) continue; if(trkStatus<-100) continue; mrecoPre[0]->Fill(pt,weight); mrecoPre2[1]->Fill(eta,phi,weight); mrecoPre[2]->Fill(centPU,weight); mrecoPre[3]->Fill(maxJetPt,weight); mrecoPre[4]->Fill(eta,weight); mrecoPre[5]->Fill(rmin,weight); mrecoPre2[7]->Fill(eta,pt,weight); } //Secondary calculation (no iterations) std::cout << "Quickly calculating the Secondary Rate from the reco tree (No further iterations needed)" << std::endl; TH2D * Secondary_Matched = new TH2D("Secondary_Matched",";pt;",s.multiRecoBins.at(s.job/s.nPtBinCoarse),s.ptMin,s.ptMax,24,-2.4,2.4); TH2D * Secondary_Secondaries = new TH2D("Secondary_Secondaries",";pt;",s.multiRecoBins.at(s.job/s.nPtBinCoarse),s.ptMin,s.ptMax,24,-2.4,2.4); for(int i = 0; i<reco->GetEntries(); i++) { reco->GetEntry(i); if(s.doSplit && nEv==1) continue; if(trkStatus>-100) { Secondary_Matched->Fill(pt,eta,weight); if(trkStatus==-99) Secondary_Secondaries->Fill(pt,eta,weight); } } TH2D * Secondary = (TH2D*)Secondary_Secondaries->Clone("SecondaryRate"); Secondary->Divide(Secondary_Matched); Secondary->SetDirectory(histFile); Secondary_Matched->SetDirectory(histFile); Secondary_Secondaries->SetDirectory(histFile); //end Secondary Reco calculation //multiReco calculation (no iterations) std::cout << "Quickly calculating the Multiple Reconstruction Rate from the gen tree (No further iterations needed)" << std::endl; TH1D * MultiGen = new TH1D("MultiGen",";pt;",s.multiRecoBins.at(s.job/s.nPtBinCoarse),s.ptMin,s.ptMax); TH1D * MultiReco = new TH1D("MultiMatchedReco",";pt;",s.multiRecoBins.at(s.job/s.nPtBinCoarse),s.ptMin,s.ptMax); for(int i = 0; i<gen->GetEntries(); i++) { gen->GetEntry(i); if(s.doSplit && nEv==1) continue; if(pNRec>-1) { MultiGen->Fill(pt,weight); if(pNRec>1) MultiReco->Fill(pt,(pNRec-1)*weight); } } TH1D * Multi = (TH1D*)MultiReco->Clone("MultipleRecoRate"); Multi->Divide(MultiGen); Multi->SetDirectory(histFile); MultiReco->SetDirectory(histFile); MultiGen->SetDirectory(histFile); //end Multiple Reco calculation skim->Close(); histFile->Write(); } //redundant for first step, but needed if the gen file was made and saved previously std::cout << "Loading appropriate information for denominator (gen for efficiency, reco for fake)..." << std::endl; TH1D * genHist[20], *recoHist[20]; TH2D * genHist2[20], *recoHist2[20]; genHist[0] = (TH1D*)histFile->Get("gen_pt"); genHist2[1] = (TH2D*)histFile->Get("gen_accept"); genHist[2] = (TH1D*)histFile->Get("gen_centPU"); genHist[3] = (TH1D*)histFile->Get("gen_maxJetPt"); genHist[4] = (TH1D*)histFile->Get("gen_eta"); genHist[5] = (TH1D*)histFile->Get("gen_rmin"); genHist2[7] = (TH2D*)histFile->Get("gen_etaPt"); std::cout << "Efficiency denominator histogram available now." << std::endl; recoHist[0] = (TH1D*)histFile->Get("mreco_pt"); recoHist2[1] = (TH2D*)histFile->Get("mreco_accept"); recoHist[2] = (TH1D*)histFile->Get("mreco_centPU"); recoHist[3] = (TH1D*)histFile->Get("mreco_maxJetPt"); recoHist[4] = (TH1D*)histFile->Get("mreco_eta"); recoHist[5] = (TH1D*)histFile->Get("mreco_rmin"); recoHist2[7] = (TH2D*)histFile->Get("mreco_etaPt"); std::cout << "Fake denominator histogram available now." << std::endl; //************************************************************************************************************ std::cout << "Calculating numerator for efficiency/fake calculation..." << std::endl; TH1D *mrecoHist, *divHist, *frecoHist, *fdivHist; TH2D *mrecoHist2,*divHist2, *frecoHist2, *fdivHist2; //getting old eff histograms to calculate the updated efficiency (the number 30 is arbitrary, increase if more are needed) TH1D * previousEff[30], *previousFake[30]; TH2D * previousEff2[30], *previousFake2[30]; for(int i=0; i<iter; i++) { int type = s.stepOrder.at(i%s.nStep); if(type==0 || type==2 || type==3 || type==4 || type==5) { previousEff[i] = (TH1D*)histFile->Get(Form("eff_step%d",i)); previousFake[i] = (TH1D*)histFile->Get(Form("fake_step%d",i)); } if(type==1 || type==7) { previousEff2[i] = (TH2D*)histFile->Get(Form("eff_step%d",i)); previousFake2[i] = (TH2D*)histFile->Get(Form("fake_step%d",i)); } } //setting up stuff for reading out of skim TH1D * mrecoErr; TH1D * mrecoW; TH2D * mrecoErr2; TH2D * mrecoW2; if(stepType == 0 || stepType==2 || stepType==3 || stepType==4 || stepType==5) { mrecoHist = makeTH1(s,stepType,Form("mreco_eff_step%d",iter)); frecoHist = makeTH1(s,stepType,Form("reco_fake_step%d",iter)); if(testErrors) { mrecoErr = (TH1D*)mrecoHist->Clone("mrecoErr"); mrecoW = (TH1D*)mrecoHist->Clone("mrecoW"); } } if(stepType == 1 || stepType == 7) { mrecoHist2 = makeTH2(s,stepType,Form("mreco_eff_step%d",iter)); frecoHist2 = makeTH2(s,stepType,Form("reco_fake_step%d",iter)); if(testErrors) { mrecoErr2 = (TH2D*)mrecoHist2->Clone("mrecoErr"); mrecoW2 = (TH2D*)mrecoHist2->Clone("mrecoW"); } } TFile * skim; if(doCondor) { if(s.reuseSkim) skim = TFile::Open(Form("/mnt/hadoop/cms/store/user/abaty/tracking_Efficiencies/ntuples/%strackSkim_job%d.root",ifPP.c_str(),s.job),"read"); else skim = TFile::Open(Form("%strackSkim_job%d.root",ifPP.c_str(),s.job),"read"); } else skim = TFile::Open(Form("/export/d00/scratch/abaty/trackingEff/ntuples/%strackSkim_job%d.root",ifPP.c_str(),s.job),"read"); TNtuple * reco = (TNtuple*) skim->Get("Reco"); reco->SetBranchAddress("trkPt",&pt); reco->SetBranchAddress("trkEta",&eta); reco->SetBranchAddress("trkPhi",&phi); reco->SetBranchAddress("weight",&weight); reco->SetBranchAddress("centPU",¢PU); reco->SetBranchAddress("rmin",&rmin); reco->SetBranchAddress("jtpt",&maxJetPt); reco->SetBranchAddress("trkStatus",&trkStatus); reco->SetBranchAddress("nEv",&nEv); //reading out of skim for(int i = 0; i<reco->GetEntries(); i++) { //applying efficiencies from all previous steps float previousFakeCorr = 1; reco->GetEntry(i); if(s.doSplit && nEv==1) continue; //fake part if(iter!=0) { for(int n = 0; n<iter; n++) { int type = s.stepOrder.at(n%s.nStep); if(type==0) previousFakeCorr *= previousFake[n]->GetBinContent(previousFake[n]->FindBin(pt)); if(type==1) previousFakeCorr *= previousFake2[n]->GetBinContent(previousFake2[n]->GetXaxis()->FindBin(eta),previousFake2[n]->GetYaxis()->FindBin(phi)); if(type==2) previousFakeCorr *= previousFake[n]->GetBinContent(previousFake[n]->FindBin(centPU)); if(type==3) previousFakeCorr *= previousFake[n]->GetBinContent(previousFake[n]->FindBin(maxJetPt)); if(type==4) previousFakeCorr *= previousFake[n]->GetBinContent(previousFake[n]->FindBin(eta)); if(type==5) previousFakeCorr *= previousFake[n]->GetBinContent(previousFake[n]->FindBin(rmin)); if(type==7) previousFakeCorr *= previousFake2[n]->GetBinContent(previousFake2[n]->GetXaxis()->FindBin(eta),previousFake2[n]->GetYaxis()->FindBin(pt)); } } if(previousFakeCorr==0) std::cout << "\nWarning!!! A correction is going to infinity. This usually indicates an empty bin somewhere, try using a coarser binning or more events! \n" << std::endl; //filling histograms if(stepType==0) frecoHist->Fill(pt,weight/previousFakeCorr); if(stepType==1) frecoHist2->Fill(eta,phi,weight/previousFakeCorr); if(stepType==2) frecoHist->Fill(centPU,weight/previousFakeCorr); if(stepType==3) frecoHist->Fill(maxJetPt,weight/previousFakeCorr); if(stepType==4) frecoHist->Fill(eta,weight/previousFakeCorr); if(stepType==5) frecoHist->Fill(rmin,weight/previousFakeCorr); if(stepType==7) frecoHist2->Fill(eta,pt,weight/previousFakeCorr); } //eff part TNtuple * gen = (TNtuple*) skim->Get("Gen"); gen->SetBranchAddress("genPt",&pt); gen->SetBranchAddress("genEta",&eta); gen->SetBranchAddress("genPhi",&phi); gen->SetBranchAddress("weight",&weight); gen->SetBranchAddress("centPU",¢PU); gen->SetBranchAddress("rmin",&rmin); gen->SetBranchAddress("jtpt",&maxJetPt); gen->SetBranchAddress("pNRec",&pNRec); gen->SetBranchAddress("mtrkPt",&mpt); gen->SetBranchAddress("mtrkQual",&mtrkQual); gen->SetBranchAddress("nEv",&nEv); //reading out of skim for(int i = 0; i<gen->GetEntries(); i++) { //applying efficiencies from all previous steps float previousEffCorr = 1; float previousEffCorrErr = 0; gen->GetEntry(i); if(s.doSplit && nEv==1) continue; if(mtrkQual<1|| mpt<=0) continue; if(iter!=0) { for(int n = 0; n<iter; n++)//calculating current efficiency correction { int type = s.stepOrder.at(n%s.nStep); if(type==0){ previousEffCorr *= previousEff[n]->GetBinContent(previousEff[n]->FindBin(pt)); if(testErrors) previousEffCorrErr += TMath::Power(previousEff[n]->GetBinError(previousEff[n]->FindBin(pt))/previousEff[n]->GetBinContent(previousEff[n]->FindBin(pt)),2); } if(type==1){ previousEffCorr *= previousEff2[n]->GetBinContent(previousEff2[n]->GetXaxis()->FindBin(eta),previousEff2[n]->GetYaxis()->FindBin(phi)); if(testErrors) previousEffCorrErr += TMath::Power(previousEff2[n]->GetBinError(previousEff2[n]->GetXaxis()->FindBin(eta),previousEff2[n]->GetYaxis()->FindBin(phi))/previousEff2[n]->GetBinContent(previousEff2[n]->GetXaxis()->FindBin(eta),previousEff2[n]->GetYaxis()->FindBin(phi)),2); } if(type==2){ previousEffCorr *= previousEff[n]->GetBinContent(previousEff[n]->FindBin(centPU)); if(testErrors) previousEffCorrErr += TMath::Power(previousEff[n]->GetBinError(previousEff[n]->FindBin(centPU))/previousEff[n]->GetBinContent(previousEff[n]->FindBin(centPU)),2); } if(type==3){ previousEffCorr *= previousEff[n]->GetBinContent(previousEff[n]->FindBin(maxJetPt)); if(testErrors) previousEffCorrErr += TMath::Power(previousEff[n]->GetBinError(previousEff[n]->FindBin(maxJetPt))/previousEff[n]->GetBinContent(previousEff[n]->FindBin(maxJetPt)),2); } if(type==4){ previousEffCorr *= previousEff[n]->GetBinContent(previousEff[n]->FindBin(eta)); if(testErrors) previousEffCorrErr += TMath::Power(previousEff[n]->GetBinError(previousEff[n]->FindBin(eta))/previousEff[n]->GetBinContent(previousEff[n]->FindBin(eta)),2); } if(type==5){ previousEffCorr *= previousEff[n]->GetBinContent(previousEff[n]->FindBin(rmin)); if(testErrors) previousEffCorrErr += TMath::Power(previousEff[n]->GetBinError(previousEff[n]->FindBin(rmin))/previousEff[n]->GetBinContent(previousEff[n]->FindBin(rmin)),2); } if(type==7){ previousEffCorr *= previousEff2[n]->GetBinContent(previousEff2[n]->GetXaxis()->FindBin(eta),previousEff2[n]->GetYaxis()->FindBin(pt)); if(testErrors) previousEffCorrErr += TMath::Power(previousEff2[n]->GetBinError(previousEff2[n]->GetXaxis()->FindBin(eta),previousEff2[n]->GetYaxis()->FindBin(pt))/previousEff2[n]->GetBinContent(previousEff2[n]->GetXaxis()->FindBin(eta),previousEff2[n]->GetYaxis()->FindBin(pt)),2); } } if(testErrors) previousEffCorrErr = previousEffCorrErr/TMath::Power(previousEffCorr,2); } if(previousEffCorr==0) std::cout << "\nWarning!!! A correction is going to infinity. This usually indicates an empty bin somewhere, try using a coarser binning or more events! \n" << std::endl; //filling histograms float var1, var2; if(stepType==0) var1 = pt; if(stepType==1){var1 = eta; var2 = phi;} if(stepType==2) var1 = centPU; if(stepType==3) var1 = maxJetPt; if(stepType==4) var1 = eta; if(stepType==5) var1 = rmin; if(stepType==7){var1 = eta; var2 = pt;} if(stepType!=1 && stepType!=7){ mrecoHist->Fill(var1,weight/previousEffCorr); if(testErrors){ mrecoErr->Fill(var1,weight*weight*previousEffCorrErr); mrecoW->Fill(var1,weight); } } else{ mrecoHist2->Fill(var1,var2,weight/previousEffCorr); if(testErrors){ mrecoErr2->Fill(var1,var2,weight*weight*previousEffCorrErr); mrecoW2->Fill(var1,var2,weight); } } } skim->Close(); //saving reco and efficiencies/fake rates std::cout << "Calculating updated Efficiency/Fake Rate and saving histograms" << std::endl; histFile->cd(); if(stepType==0 || stepType == 2 || stepType == 3 || stepType==4 || stepType==5) { if(testErrors) { mrecoErr->Divide(mrecoW); mrecoErr->Divide(mrecoW); for(int i = 1 ; i<mrecoErr->GetSize()-1; i++) mrecoHist->SetBinError(i,TMath::Power(mrecoErr->GetBinContent(i),0.5)); } divHist = (TH1D*)mrecoHist->Clone(Form("eff_step%d",iter)); divHist->Divide(genHist[stepType]); mrecoHist->Write(); divHist->Write(); fdivHist = (TH1D*)frecoHist->Clone(Form("fake_step%d",iter)); fdivHist->Divide(recoHist[stepType]); frecoHist->Write(); fdivHist->Write(); } if(stepType==1 || stepType==7) { if(testErrors) { mrecoErr2->Divide(mrecoW2); mrecoErr2->Divide(mrecoW2); for(int i = 1 ; i<mrecoErr2->GetNbinsX()+1; i++) for(int j = 1; j<mrecoErr2->GetNbinsY()+1; j++) mrecoHist2->SetBinError(i,j,TMath::Power(mrecoErr2->GetBinContent(i,j),0.5)); } divHist2 = (TH2D*)mrecoHist2->Clone(Form("eff_step%d",iter)); divHist2->Divide(genHist2[stepType]); mrecoHist2->Write(); divHist2->Write(); fdivHist2 = (TH2D*)frecoHist2->Clone(Form("fake_step%d",iter)); fdivHist2->Divide(recoHist2[stepType]); frecoHist2->Write(); fdivHist2->Write(); } //********************************************************************************************* //********************************************************************************************* //Only executed on last step before exiting program if(iter>=s.nStep*s.fullIterations && s.terminateStep==stepType) { //writing final correction tables (consolidating multiple steps of the same variable) //once again 10 is an arbitrary number, increase if needed... std::cout << "Consolidating into final histograms by multiplying out efficiencies/fake rates per variable" << std::endl; TH1D * finalEff[10], *finalFake[10]; TH2D * finalEff2[10], *finalFake2[10]; for(int i=0; i<s.nStep; i++) { int type = s.stepOrder.at(i%s.nStep); if(type == 0 || type==2 || type==3 || type==4 || type==5) { finalEff[i] = (TH1D*)previousEff[i]->Clone(Form("finalEff_type%d",i)); finalFake[i] = (TH1D*)previousFake[i]->Clone(Form("finalFake_type%d",i)); } if(type == 1 || type==7) { finalEff2[i] = (TH2D*)previousEff2[i]->Clone(Form("finalEff_type%d",i)); finalFake2[i] = (TH2D*)previousFake2[i]->Clone(Form("finalFake_type%d",i)); } } for(int n = s.nStep; n<iter; n++) { int type2 = s.stepOrder.at(n%s.nStep); if(type2==0 || type2==2 || type2==3 || type2==4 || type2==5) { finalEff[n%s.nStep]->Multiply(previousEff[n]); finalFake[n%s.nStep]->Multiply(previousFake[n]); } if(type2==1 || type2==7) { finalEff2[n%s.nStep]->Multiply(previousEff2[n]); finalFake2[n%s.nStep]->Multiply(previousFake2[n]); } } if(stepType == 0 || stepType==2 || stepType==3 || stepType==4 || stepType==5) { finalEff[iter%s.nStep]->Multiply((TH1D*)histFile->Get(Form("eff_step%d",iter))); finalFake[iter%s.nStep]->Multiply((TH1D*)histFile->Get(Form("fake_step%d",iter))); } if(stepType == 1 || stepType == 7) { finalEff2[iter%s.nStep]->Multiply((TH2D*)histFile->Get(Form("eff_step%d",iter))); finalFake2[iter%s.nStep]->Multiply((TH2D*)histFile->Get(Form("fake_step%d",iter))); } for(int i=0; i<s.nStep; i++) { int type = s.stepOrder.at(i%s.nStep); if(type == 0 || type==2 || type==3 || type==4 || type == 5){ finalEff[i]->Write(); finalFake[i]->Write();} if(type == 1 || type == 7){ finalEff2[i]->Write(); finalFake2[i]->Write();} } //******************************************************************************************************* //writing calculating final closures in each variable checked after applying corrections std::cout << "Calculating Final Closures..." << std::endl; TH1D * finalEffClosure[10], *finalFakeClosure[10]; TH2D * finalEffClosure2[10], *finalFakeClosure2[10]; for(int i=0; i<8; i++) { int type = i; if(type==0 || type==2 || type==3 || type==4 || type==5) { finalEffClosure[i] = (TH1D*)genHist[i]->Clone(Form("finalEffClosure_var%d",i)); finalFakeClosure[i] = (TH1D*)recoHist[i]->Clone(Form("finalFakeClosure_var%d",i)); finalEffClosure[i]->Reset(); finalFakeClosure[i]->Reset(); } if(type==1 || type==7) { finalEffClosure2[i] = (TH2D*)genHist2[i]->Clone(Form("finalEffClosure_var%d",i)); finalFakeClosure2[i] = (TH2D*)recoHist2[i]->Clone(Form("finalFakeClosure_var%d",i)); finalEffClosure2[i]->Reset(); finalFakeClosure2[i]->Reset(); } } if(doCondor) { if(s.reuseSkim) skim = TFile::Open(Form("/mnt/hadoop/cms/store/user/abaty/tracking_Efficiencies/ntuples/%strackSkim_job%d.root",ifPP.c_str(),s.job),"read"); else skim = TFile::Open(Form("%strackSkim_job%d.root",ifPP.c_str(),s.job),"read"); } else skim = TFile::Open(Form("/export/d00/scratch/abaty/trackingEff/ntuples/%strackSkim_job%d.root",ifPP.c_str(),s.job),"read"); reco = (TNtuple*) skim->Get("Reco"); reco->SetBranchAddress("trkPt",&pt); reco->SetBranchAddress("trkEta",&eta); reco->SetBranchAddress("trkPhi",&phi); reco->SetBranchAddress("weight",&weight); reco->SetBranchAddress("centPU",¢PU); reco->SetBranchAddress("rmin",&rmin); reco->SetBranchAddress("jtpt",&maxJetPt); reco->SetBranchAddress("trkStatus",&trkStatus); reco->SetBranchAddress("nEv",&nEv); //reading out of skim for(int i = 0; i<reco->GetEntries(); i++) { //applying efficiencies from all previous steps float previousFakeCorr = 1; reco->GetEntry(i); if(s.doSplit && nEv==1) continue; for(int n=0; n<s.nStep; n++)//getting correction { int type = s.stepOrder.at(n%s.nStep); if(type==0) previousFakeCorr *= finalFake[n]->GetBinContent(finalFake[n]->FindBin(pt)); if(type==1) previousFakeCorr *= finalFake2[n]->GetBinContent(finalFake2[n]->GetXaxis()->FindBin(eta),finalFake2[n]->GetYaxis()->FindBin(phi)); if(type==2) previousFakeCorr *= finalFake[n]->GetBinContent(finalFake[n]->FindBin(centPU)); if(type==3) previousFakeCorr *= finalFake[n]->GetBinContent(finalFake[n]->FindBin(maxJetPt)); if(type==4) previousFakeCorr *= finalFake[n]->GetBinContent(finalFake[n]->FindBin(eta)); if(type==5) previousFakeCorr *= finalFake[n]->GetBinContent(finalFake[n]->FindBin(rmin)); if(type==7) previousFakeCorr *= finalFake2[n]->GetBinContent(finalFake2[n]->GetXaxis()->FindBin(eta),finalFake2[n]->GetYaxis()->FindBin(pt)); } if(previousFakeCorr<1) previousFakeCorr==1; finalFakeClosure[0]->Fill(pt,weight/previousFakeCorr); finalFakeClosure2[1]->Fill(eta,phi,weight/previousFakeCorr); finalFakeClosure[2]->Fill(centPU,weight/previousFakeCorr); finalFakeClosure[3]->Fill(maxJetPt,weight/previousFakeCorr); finalFakeClosure[4]->Fill(eta,weight/previousFakeCorr); finalFakeClosure[5]->Fill(rmin,weight/previousFakeCorr); finalFakeClosure2[7]->Fill(eta,pt,weight/previousFakeCorr); } gen = (TNtuple*) skim->Get("Gen"); gen->SetBranchAddress("genPt",&pt); gen->SetBranchAddress("genEta",&eta); gen->SetBranchAddress("genPhi",&phi); gen->SetBranchAddress("weight",&weight); gen->SetBranchAddress("centPU",¢PU); gen->SetBranchAddress("rmin",&rmin); gen->SetBranchAddress("jtpt",&maxJetPt); gen->SetBranchAddress("pNRec",&pNRec); gen->SetBranchAddress("mtrkPt",&mpt); gen->SetBranchAddress("mtrkQual",&mtrkQual); gen->SetBranchAddress("nEv",&nEv); //reading out of skim for(int i = 0; i<gen->GetEntries(); i++) { //applying efficiencies from all previous steps float previousEffCorr = 1; gen->GetEntry(i); if(s.doSplit && nEv==1) continue; if(mtrkQual<1 || mpt<=0) continue; for(int n=0; n<s.nStep; n++)//getting correction { int type = s.stepOrder.at(n%s.nStep); if(type==0) previousEffCorr *= finalEff[n]->GetBinContent(finalEff[n]->FindBin(pt)); if(type==1) previousEffCorr *= finalEff2[n]->GetBinContent(finalEff2[n]->GetXaxis()->FindBin(eta),finalEff2[n]->GetYaxis()->FindBin(phi)); if(type==2) previousEffCorr *= finalEff[n]->GetBinContent(finalEff[n]->FindBin(centPU)); if(type==3) previousEffCorr *= finalEff[n]->GetBinContent(finalEff[n]->FindBin(maxJetPt)); if(type==4) previousEffCorr *= finalEff[n]->GetBinContent(finalEff[n]->FindBin(eta)); if(type==5) previousEffCorr *= finalEff[n]->GetBinContent(finalEff[n]->FindBin(rmin)); if(type==7) previousEffCorr *= finalEff2[n]->GetBinContent(finalEff2[n]->GetXaxis()->FindBin(eta), finalEff2[n]->GetYaxis()->FindBin(pt)); } if(previousEffCorr>1) previousEffCorr==1; finalEffClosure[0]->Fill(pt,weight/previousEffCorr); finalEffClosure2[1]->Fill(eta,phi,weight/previousEffCorr); finalEffClosure[2]->Fill(centPU,weight/previousEffCorr); finalEffClosure[3]->Fill(maxJetPt,weight/previousEffCorr); finalEffClosure[4]->Fill(eta,weight/previousEffCorr); finalEffClosure[5]->Fill(rmin,weight/previousEffCorr); finalEffClosure2[7]->Fill(eta,pt,weight/previousEffCorr); } histFile->cd(); for(int i=0; i<8; i++) { if(i==6) continue; if(i!=1 && i!=7) { finalFakeClosure[i]->Divide(recoHist[i]); finalEffClosure[i]->Divide(genHist[i]); finalFakeClosure[i]->Write(); finalEffClosure[i]->Write(); } else { finalFakeClosure2[i]->Divide(recoHist2[i]); finalEffClosure2[i]->Divide(genHist2[i]); finalFakeClosure2[i]->Write(); finalEffClosure2[i]->Write(); } } std::cout << "Calculating Final Closures..." << std::endl; } histFile->Close(); std::cout << "Finished with iteration \n" << std::endl; return; }
void runcorr(int condor_iter, int trackqual) { const int nptbins = 2; const int ncentbins = 1; const int najbins = 1; string buffer; vector<string> listoffiles; int nlines = 0; // ifstream infile("sortedforests.txt"); // ifstream infile("doeproposalforests.txt"); // ifstream infile("ppb_unmerged_minbias_forests.txt"); ifstream infile("HIRun2013-PromptReco-v1-HLT_PAPixelTracks_Multiplicity190_v1-forest-v2.txt"); if (!infile.is_open()) { cout << "Error opening file. Exiting." << endl; return; } else { while (!infile.eof()) { infile >> buffer; listoffiles.push_back(buffer); nlines++; } } bool dostdhists = (condor_iter%(nptbins * ncentbins * najbins) == 0); int ptbin = condor_iter % nptbins; int centbin = (condor_iter / nptbins) % ncentbins; int ajbin = (condor_iter / (nptbins * ncentbins)) % najbins; int filenum = (condor_iter / (nptbins * ncentbins * najbins)); cout << "ipt: " << ptbin << " icent: " << centbin << " iaj: " << ajbin << " filenum: " << filenum << " dostdhists: " << dostdhists << " condor_iter "<<condor_iter<< endl; int nmin = 190 , nmax = 1000; //! for first iteration of forest production /* if(filenum==0) { nmin = 110 ; nmax = 1000; } if(filenum==1) { nmin = 90 ; nmax = 110 ; } if(filenum>1 ) { nmin = 0 ; nmax = 35 ; } if(filenum>9 ) { nmin = 35 ; nmax = 90 ; } */ //! for second iteration of forest production // /* // if(filenum<24 ) { nmin = 90 ; nmax = 110 ; } // if(filenum<22 ) { nmin = 35 ; nmax = 90 ; } // if(filenum<12 ) { nmin = 110 ; nmax = 1000; } // if(filenum<10 ) { nmin = 0 ; nmax = 35 ; } // */ //! for second iteration of forest production /* if(filenum<26 ) { nmin = 90 ; nmax = 110 ; } if(filenum<23 ) { nmin = 35 ; nmax = 90 ; } if(filenum<13) { nmin = 110 ; nmax = 1000; } if(filenum<10) { nmin = 0 ; nmax = 35 ; } */ corrana(listoffiles[filenum].data(),trackqual); double pttriglow[] = {1 ,1 ,1 ,3, 1}; double pttrighigh[] = {3 ,3 ,3 ,4, 3}; double ptasslow[] = {0.25 ,2 ,0.25 ,3, 1}; double ptasshigh[] = {0.5 ,3 ,3 ,4, 3}; int centmin[] = {1,0,4,8,12,16,20,24,28,32}; int centmax[] = {1,41,8,12,16,20,24,28,32,36}; TFile * outf = new TFile(Form("corrhists_trkhfminus_trkqaul%d_nmin%d_nmax%d_ptmin%d_ptmax%d_hfmin%d_hfmax%d_%d.root",trackqual,nmin,nmax,(int)pttriglow[ptbin],(int)pttrighigh[ptbin],(int)ptasslow[ptbin],(int)ptasshigh[ptbin],filenum),"recreate"); int i = 0; int cent = 0; cout<<"cent iteration "<<cent<<endl; TH2D * ttsig = HFTrackSignal(pttriglow[ptbin],pttrighigh[ptbin],ptasslow[ptbin],ptasshigh[ptbin],centmin[cent],centmax[cent],nmin,nmax); TH2D * ttbak = HFTrackBackground(pttriglow[ptbin],pttrighigh[ptbin],ptasslow[ptbin],ptasshigh[ptbin],centmin[cent],centmax[cent],nmin,nmax); // TH1I * hntottrig = new TH1I(Form("nttottrig_trg%d_%d_ass%d_%d_cmin%d_cmax%d",(int)pttriglow[ptbin],(int)pttrighigh[ptbin],(int)ptasslow[ptbin],(int)ptasshigh[ptbin],centmin[cent],centmax[cent]),"",1,0.5,1.5); // int myntottrig = GetNTotTrig(); // hntottrig->Fill(1,myntottrig); // cout<<"ntottrig: "<<myntottrig<<endl; TH2D * ttcorr = (TH2D*)ttsig->Clone(Form("corr_trg%d_%d_ass%d_%d_cmin%d_cmax%d",(int)pttriglow[ptbin],(int)pttrighigh[ptbin],(int)ptasslow[ptbin],(int)ptasshigh[ptbin],centmin[cent],centmax[cent])); ttcorr->Divide(ttbak); ttcorr->Scale(ttbak->GetBinContent(ttbak->FindBin(4,0))); ttcorr->Scale(1/0.0594998609); //! bin width ttcorr->GetXaxis()->SetRange(ttcorr->GetXaxis()->FindBin(1),ttcorr->GetXaxis()->FindBin(7)); ttcorr->GetYaxis()->SetRange(ttcorr->GetYaxis()->FindBin(-3.1415926/2.0),ttcorr->GetYaxis()->FindBin(3*3.1415926/2.0)); outf->Write(); outf->Close(); }
void runcorr(int condor_iter, int trackqual, string flist = "", string tag = "", int nmin = 220, int nmax = 1000, float pttrigmin = 1, float pttrigmax = 2, float ptassmin = 1, float ptassmax = 1) { const int nptbins = 1; const int ncentbins = 1; const int najbins = 1; string buffer; vector<string> listoffiles; int nlines = 0; // ifstream infile("sortedforests.txt"); // ifstream infile("doeproposalforests.txt"); // ifstream infile("PA2013_PromptReco_Json_FullTrack12_v84_prod2.txt"); // ifstream infile("PA2013_PromptReco_Json_FullTrack12_v84_prod2_MIT.txt"); // ifstream infile("HIMinBiasUPC_PbPbUPC_pptracking_452p1_forest_v2.txt"); ifstream infile(flist.data()); if (!infile.is_open()) { cout << "Error opening file. Exiting." << endl; return; } else { while (!infile.eof()) { infile >> buffer; listoffiles.push_back(buffer); nlines++; } } bool dostdhists = (condor_iter%(nptbins * ncentbins * najbins) == 0); int ptbin = condor_iter % nptbins; int centbin = (condor_iter / nptbins) % ncentbins; int ajbin = (condor_iter / (nptbins * ncentbins)) % najbins; int filenum = (condor_iter / (nptbins * ncentbins * najbins)); cout << "ipt: " << ptbin << " icent: " << centbin << " iaj: " << ajbin << " filenum: " << filenum << " dostdhists: " << dostdhists << endl; // int nmin = 220 , nmax = 1000, one = 1; //! for first iteration of forest production /* if(filenum==0) { nmin = 110 ; nmax = 1000; } if(filenum==1) { nmin = 90 ; nmax = 110 ; } if(filenum>1 ) { nmin = 0 ; nmax = 35 ; } if(filenum>9 ) { nmin = 35 ; nmax = 90 ; } */ //! for second iteration of forest production // /* // if(filenum<24 ) { nmin = 90 ; nmax = 110 ; } // if(filenum<22 ) { nmin = 35 ; nmax = 90 ; } // if(filenum<12 ) { nmin = 110 ; nmax = 1000; } // if(filenum<10 ) { nmin = 0 ; nmax = 35 ; } // */ //! for second iteration of forest production /* if(filenum<26 ) { nmin = 90 ; nmax = 110 ; } if(filenum<23 ) { nmin = 35 ; nmax = 90 ; } if(filenum<13) { nmin = 110 ; nmax = 1000; } if(filenum<10) { nmin = 0 ; nmax = 35 ; } */ corrana(listoffiles[filenum].data(),trackqual); // double pttriglow[] = {1 ,14 ,16 ,20, 1}; // double pttrighigh[] = {2 ,16 ,20 ,24, 3}; // double ptasslow[] = {1 ,1 ,1 ,1 , 1}; // double ptasshigh[] = {2 ,2 ,2 ,2 , 3}; int centmin[] = {0,4,8,12,16,20,24,28,32}; int centmax[] = {41,8,12,16,20,24,28,32,36}; // TFile * outf = new TFile(Form("%s_trkqaul%d_nmin%d_nmax%d_tptmin%d_tptmax%d_aptmin%d_aptmax%d_%d.root",tag.data(),trackqual,nmin,nmax,(int)pttrigmin/one,(int)pttrigmax/one,(int)ptassmin/one,(int)ptassmax/one,filenum),"recreate"); cout<<Form("%s_trkqaul%d_nmin%d_nmax%d_tptmin%d_tptmax%d_aptmin%d_aptmax%d_%d.root",tag.data(),trackqual,nmin,nmax,(int)pttrigmin,(int)pttrigmax,(int)ptassmin,(int)ptassmax,filenum)<<endl; TFile * outf = new TFile(Form("%s_trkqaul%d_nmin%d_nmax%d_tptmin%d_tptmax%d_aptmin%d_aptmax%d_%d.root",tag.data(),trackqual,nmin,nmax,(int)pttrigmin,(int)pttrigmax,(int)ptassmin,(int)ptassmax,filenum),"recreate"); // int i = 0; int cent = 0; cout<<"cent iteration "<<cent<<endl; TH2D * ttsig = TrackTrackSignal(pttrigmin,pttrigmax,ptassmin,ptassmax,centmin[cent],centmax[cent],nmin,nmax); TH2D * ttbak = TrackTrackBackground(pttrigmin,pttrigmax,ptassmin,ptassmax,centmin[cent],centmax[cent],nmin,nmax); TH1I * hntottrig = new TH1I(Form("nttottrig_trg%d_%d_ass%d_%d_cmin%d_cmax%d",(int)pttrigmin,(int)pttrigmax,(int)ptassmin,(int)ptassmax,centmin[cent],centmax[cent]),"",1,0.5,1.5); int myntottrig = GetNTotTrig(); hntottrig->Fill(1,myntottrig); cout<<"ntottrig: "<<myntottrig<<endl; TH2D * ttcorr = (TH2D*)ttsig->Clone(Form("corr_trg%d_%d_ass%d_%d_cmin%d_cmax%d",(int)pttrigmin,(int)pttrigmax,(int)ptassmin,(int)ptassmax,centmin[cent],centmax[cent])); ttcorr->Divide(ttbak); ttcorr->Scale(ttbak->GetBinContent(ttbak->FindBin(0,0))); ttcorr->Scale(1/0.0594998609); //! bin width ttcorr->GetXaxis()->SetRange(ttcorr->GetXaxis()->FindBin(-4.0),ttcorr->GetXaxis()->FindBin(4.0)); ttcorr->GetYaxis()->SetRange(ttcorr->GetYaxis()->FindBin(-3.1415926/2.0),ttcorr->GetYaxis()->FindBin(3*3.1415926/2.0)); outf->Write(); outf->Close(); }
void stdruncorr(int filenum = 0) { string buffer; vector<string> listoffiles; int nlines = 0; ifstream infile("/net/hisrv0001/home/dav2105/corrana/makecorrhists/mcsorted.txt"); if (!infile.is_open()) { cout << "Error opening file. Exiting." << endl; return; } else { while (!infile.eof()) { infile >> buffer; listoffiles.push_back(buffer); nlines++; } } cout<<"opening: "<<listoffiles[filenum].data()<<endl; stdcorrana(listoffiles[filenum].data()); double leadingjetptlow[] = {100,100,100,100,100,100,100,100,100}; double leadingjetpthigh[] = {120,120,120,300,300,300,300,300,300}; double subleadingjetptlow[] = {50 ,50 ,50 ,50 ,50 ,50 ,50 ,50 ,50 }; double subleadingjetpthigh[] = {120,120,120,300,300,300,300,300,300}; double ptasslow[] = {2 ,3 ,5 ,2 ,3 ,3 ,1 ,2 ,3 }; double ptasshigh[] = {3 ,5 ,8 ,3 ,4 ,4 ,2 ,3 ,4 }; int centmin[] = {0,4,12,20}; int centmax[] = {4,12,20,40}; float ajmin[] = { 0.00, 0.13, 0.24, 0.35 }; float ajmax[] = { 0.13, 0.24, 0.35, 1.00 }; TFile * outf = new TFile(Form("stdmcv2_%d.root",filenum),"recreate"); for(int i = 0 ; i < 3 ; ++i) { cout<<"pt iteration "<<i<<endl; for(int cent = 0 ; cent < 4 ; ++cent) { cout<<"cent iteration "<<cent<<endl; for(int aj = 0 ; aj < 4 ; ++aj) { cout<<"aj iteration "<<aj<<endl; TH2D * ljtsig = JetTrackSignal (0, leadingjetptlow[i], leadingjetpthigh[i] , subleadingjetptlow[i] , subleadingjetpthigh[i] , ptasslow[i] , ptasshigh[i], centmin[cent], centmax[cent],ajmin[aj],ajmax[aj]); TH2D * ljtbak = JetTrackBackground(0, leadingjetptlow[i], leadingjetpthigh[i] , subleadingjetptlow[i] , subleadingjetpthigh[i] , ptasslow[i] , ptasshigh[i], centmin[cent], centmax[cent],ajmin[aj],ajmax[aj]); TH2D * ljtcorr = (TH2D*)ljtsig->Clone(Form("corr_leadingjet%d_%d_ass%d_%d_cmin%d_cmax%d_ajmin%2.2f_ajmax%2.2f",(int)leadingjetptlow[i],(int)leadingjetpthigh[i],(int)ptasslow[i],(int)ptasshigh[i],centmin[cent],centmax[cent],ajmin[aj],ajmax[aj])); ljtcorr->Divide(ljtbak); ljtcorr->Scale(ljtbak->GetBinContent(ljtbak->FindBin(0,0))); ljtcorr->GetXaxis()->SetRange(ljtcorr->GetXaxis()->FindBin(-1.6),ljtcorr->GetXaxis()->FindBin(1.6)); ljtcorr->GetYaxis()->SetRange(ljtcorr->GetYaxis()->FindBin(-3.1415926/2.0),ljtcorr->GetYaxis()->FindBin(3*3.1415926/2.0)); TH2D * sljtsig = JetTrackSignal (1, leadingjetptlow[i], leadingjetpthigh[i] , subleadingjetptlow[i] , subleadingjetpthigh[i] , ptasslow[i] , ptasshigh[i], centmin[cent], centmax[cent],ajmin[aj],ajmax[aj]); TH2D * sljtbak = JetTrackBackground(1, leadingjetptlow[i], leadingjetpthigh[i] , subleadingjetptlow[i] , subleadingjetpthigh[i] , ptasslow[i] , ptasshigh[i], centmin[cent], centmax[cent],ajmin[aj],ajmax[aj]); TH2D * sljtcorr = (TH2D*)sljtsig->Clone(Form("corr_subleadingjet%d_%d_ass%d_%d_cmin%d_cmax%d_ajmin%2.2f_ajmax%2.2f",(int)leadingjetptlow[i],(int)leadingjetpthigh[i],(int)ptasslow[i],(int)ptasshigh[i],centmin[cent],centmax[cent],ajmin[aj],ajmax[aj])); sljtcorr->Divide(sljtbak); sljtcorr->Scale(sljtbak->GetBinContent(sljtbak->FindBin(0,0))); sljtcorr->GetXaxis()->SetRange(sljtcorr->GetXaxis()->FindBin(-4.0),sljtcorr->GetXaxis()->FindBin(4.0)); sljtcorr->GetYaxis()->SetRange(sljtcorr->GetYaxis()->FindBin(-3.1415926/2.0),sljtcorr->GetYaxis()->FindBin(3*3.1415926/2.0)); } } } outf->Write(); outf->Close(); }
void SimplePlot2D(){ //string filename = "data/scan_CH1-64_unmasked.root"; //string filename = "data/scan_CH1-50_masked.root"; string filename = "test.root"; string varXname = "VMM #"; string varYname = "CH #"; // delay count stuff int CH = 21; double delays[5]; double count_tot[5]; double count_right[5]; for(int i = 0; i < 5; i++){ delays[i] = double(i)*5.; count_tot[i] = 0.; count_right[i] = 0.; } /////////////////////////////////////////////////////// TChain* tree = new TChain("MMFE8","MMFE8"); tree->AddFile(filename.c_str()); MMFE8Base* base = new MMFE8Base(tree); int N = tree->GetEntries(); TH2D* hist = new TH2D("hist","hist", 8, 0.5, 8.5, 64, 0.5,64.5); TH2D* histN = (TH2D*) hist->Clone("norm"); TH2D* histchch = new TH2D("histchch","histchch", 64, 0.5, 64.5, 64, 0.5,64.5); TH2D* histDelay = new TH2D("histN","histN", 31, 9.5, 40.5, 5,-0.5, 4.5); TH2D* histDelayD = new TH2D("histD","histD", 31, 9.5, 40.5, 5,-0.5, 4.5); for(int i = 0; i < N; i++){ base->GetEntry(i); if(base->CHpulse == CH){ //count_tot[base->Delay] += 1.; count_tot[(base->TPDAC-80)/20] += 1.; if(base->CHpulse == base->CHword) //count_right[base->Delay] += base->TDO; count_right[(base->TPDAC-80)/20] += base->PDO; } //histDelayD->Fill(base->CHpulse,base->Delay); histDelayD->Fill(base->CHpulse,(base->TPDAC-80)/20); if(base->CHpulse == base->CHword) //histDelay->Fill(base->CHpulse,base->Delay,base->TDO); histDelay->Fill(base->CHpulse,(base->TPDAC-80)/20,base->PDO); if((base->CHpulse != base->CHword || true) && base->VMM == 6) histchch->Fill(base->CHpulse,base->CHword); if(base->CHpulse != base->CHword) continue; hist->Fill(base->VMM,base->CHpulse,base->PDO); histN->Fill(base->VMM,base->CHpulse); } for(int x = 0; x < 8; x++){ for(int y = 0; y < 64; y++){ double v = hist->GetBinContent(x+1,y+1); double N = histN->GetBinContent(x+1,y+1); hist->SetBinContent(x+1,y+1,v/max(int(N),1)); } } TLatex l; //l.NDC(); TCanvas* can = new TCanvas("can","can",600,500); can->SetTopMargin(0.05); can->SetLeftMargin(0.12); can->SetRightMargin(0.15); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); can->Draw(); can->SetGridx(); can->SetGridy(); can->cd(); hist->Draw("COLZ"); hist->GetXaxis()->SetTitle(varXname.c_str()); hist->GetXaxis()->CenterTitle(); hist->GetYaxis()->SetTitle(varYname.c_str()); hist->GetYaxis()->CenterTitle(); hist->GetYaxis()->SetTitleOffset(1.4); hist->GetYaxis()->CenterTitle(); //hist->GetYaxis()->SetRangeUser(0.,hist->GetMaximum()*1.1) ; TCanvas* canN = new TCanvas("canN","canN",600,500); canN->SetTopMargin(0.05); canN->SetLeftMargin(0.12); canN->SetRightMargin(0.15); canN->Draw(); canN->SetGridx(); canN->SetGridy(); canN->cd(); histN->Draw("COLZ"); histN->GetXaxis()->SetTitle(varXname.c_str()); histN->GetXaxis()->CenterTitle(); histN->GetYaxis()->SetTitle(varYname.c_str()); histN->GetYaxis()->CenterTitle(); histN->GetYaxis()->SetTitleOffset(1.4); histN->GetYaxis()->CenterTitle(); TCanvas* canchch = new TCanvas("canchch","canchch",600,500); canchch->SetTopMargin(0.05); canchch->SetLeftMargin(0.12); canchch->SetRightMargin(0.15); canchch->Draw(); canchch->SetGridx(); canchch->SetGridy(); canchch->cd(); histchch->Draw("COLZ"); histchch->GetXaxis()->SetTitle("CH pulsed"); histchch->GetXaxis()->CenterTitle(); histchch->GetYaxis()->SetTitle("CH data"); histchch->GetYaxis()->CenterTitle(); histchch->GetYaxis()->SetTitleOffset(1.4); histchch->GetYaxis()->CenterTitle(); histchch->GetZaxis()->SetTitle("Number of data events"); histchch->GetZaxis()->SetTitleOffset(1.4); histchch->GetZaxis()->CenterTitle(); l.DrawLatex(.54,65.2,"VMM 2"); TCanvas* can_delay = new TCanvas("can_delay","can_delay",600,500); can_delay->Draw(); can_delay->cd(); for(int i = 0; i < 5; i++) count_tot[i] = count_right[i]/count_tot[i]; TGraph* gr = new TGraph(5,delays,count_tot); gr->SetMarkerSize(4); gr->SetMarkerStyle(5); gr->Draw("AP"); histDelay->Divide(histDelayD); TCanvas* canDelay = new TCanvas("canDelay","canDelay",600,500); canDelay->SetTopMargin(0.05); canDelay->SetLeftMargin(0.12); canDelay->SetRightMargin(0.15); canDelay->Draw(); canDelay->SetGridx(); canDelay->SetGridy(); canDelay->cd(); histDelay->Draw("COLZ"); histDelay->GetXaxis()->SetTitle("CH pulsed"); histDelay->GetXaxis()->CenterTitle(); histDelay->GetYaxis()->SetTitle("Delay Count"); histDelay->GetYaxis()->CenterTitle(); histDelay->GetYaxis()->SetTitleOffset(1.4); histDelay->GetYaxis()->CenterTitle(); histDelay->GetZaxis()->SetTitle("Fraction zeroes"); histDelay->GetZaxis()->SetTitleOffset(1.4); histDelay->GetZaxis()->CenterTitle(); }
int genbod_drawNice2(const char* filename1, const char* filename2, bool ifSave = false) { TFile* f1 = new TFile(filename1,"READ"); TFile* f2 = new TFile(filename2,"READ"); TH2D* numF1 = ((TH2D*) f1->Get("cnumepNonIdEP")); TH2D* numF2 = ((TH2D*) f2->Get("cnumepNonIdEP")); TH2D* denF1 = ((TH2D*) f1->Get("cdenepNonIdEP")); TH2D* denF2 = ((TH2D*) f2->Get("cdenepNonIdEP")); TH2D* numB1 = ((TH2D*) f1->Get("cnumepNonIdEPTrue")); TH2D* numB2 = ((TH2D*) f2->Get("cnumepNonIdEPTrue")); TH2D* denB1 = ((TH2D*) numF1->Clone()); TH2D* denB2 = ((TH2D*) numF2->Clone()); TH2D* numC1 = ((TH2D*) numB1->Clone()); TH2D* numC2 = ((TH2D*) numB2->Clone()); TH2D* denC1 = ((TH2D*) f1->Get("cdenepNonIdEPTrue")); TH2D* denC2 = ((TH2D*) f2->Get("cdenepNonIdEPTrue")); double eta = 1.1; gStyle->SetOptStat(000);//111); int drawDifference = 0; const char* first = "";//Cons. laws only"; const char* second = "";//Minijets"; int drawWhich = 0; // 0 - cons. laws, 1 - femto, 2 - full corr fun //TCanvas* canv = new TCanvas("canv", "GENBOD results", 10,10,800,600); TCanvas* canv = new TCanvas("canv", "GENBOD results", 10,10,(2+drawDifference)*550,400); canv->Divide(2+drawDifference,1); //TCanvas* canvND = new TCanvas("canvND", "liczniki i mianowniki ", 10,10,800,600); // TCanvas* canvND = new TCanvas("canvND", "liczniki i mianowniki ", 10,10,1600,1200); // canvND->Divide(2,2); if(drawWhich==1){ ////// Pure Corr fun TH2D* numdiff = (TH2D*)numF1->Clone(); numdiff->Divide(numF2); //canvND->cd(1); numdiff->DrawCopy("colz"); TH2D* dendiff = (TH2D*)denF1->Clone(); dendiff->Divide(denF2); //canvND->cd(2); dendiff->DrawCopy("colz"); double sF1 = numF1->GetEntries()/denF1->GetEntries(); numF1->Divide(denF1); numF1->Scale(1./sF1); numF1->GetYaxis()->SetRangeUser(-eta,eta); double sF2 = numF2->GetEntries()/denF2->GetEntries(); numF2->Divide(denF2); numF2->Scale(1./sF2); numF2->GetYaxis()->SetRangeUser(-eta,eta); canv->cd(1); TH2D* corrF1 = (TH2D*) numF1->Clone(); corrF1->Draw("surf1"); DrawNicely(corrF1, 0,0, filename1); canv->cd(2); TH2D* corrF2 = (TH2D*) numF2->Clone(); corrF2->Draw("surf1"); DrawNicely(corrF2, 0,0, filename2); if(drawDifference){ canv->cd(3); numF1->Divide(numF2); DrawNicely(numF1, 0,0, "Femtoscopic component"); numF1->Draw("colz"); } } if(drawWhich==0){ ////// Pure Bkg TH2D* numdiffTrue = (TH2D*)numB1->Clone(); numdiffTrue->Divide(numB2); //canvND->cd(3); numdiffTrue->DrawCopy("colz"); double sB1 = numB1->GetEntries()/denB1->GetEntries(); numB1->Divide(denB1); numB1->Scale(1./sB1); numB1->GetYaxis()->SetRangeUser(-eta,eta); double sB2 = numB2->GetEntries()/denB2->GetEntries(); numB2->Divide(denB2); numB2->Scale(1./sB2); numB2->GetYaxis()->SetRangeUser(-eta,eta); canv->cd(1); TH2D* corrB1 = (TH2D*) numB1->Clone(); corrB1->Draw("surf1"); DrawNicely(corrB1, 0.7,1.4, first);//filename1); canv->cd(2); TH2D* corrB2 = (TH2D*) numB2->Clone(); corrB2->Draw("surf1"); DrawNicely(corrB2, 0.7,1.4, second);//filename2); if(drawDifference){ canv->cd(3); numB1->Divide(numB2); DrawNicely(numB1, 0,0, "Background component"); numB1->DrawCopy("colz"); } } if(drawWhich==2){ ////// Norm Corr fun TH2D* dendiffTrue = (TH2D*)denC1->Clone(); dendiffTrue->Divide(denC2); //canvND->cd(4); dendiffTrue->DrawCopy("colz"); double sC1 = numC1->GetEntries()/denC1->GetEntries(); numC1->Divide(denC1); numC1->Scale(1./sC1); numC1->GetYaxis()->SetRangeUser(-eta,eta); double sC2 = numC2->GetEntries()/denC2->GetEntries(); numC2->Divide(denC2); numC2->Scale(1./sC2); numC2->GetYaxis()->SetRangeUser(-eta,eta); canv->cd(1); TH2D* corrC1 = (TH2D*) numC1->Clone(); corrC1->Draw("surf1"); DrawNicely(corrC1, 0,0, first);//filename1); canv->cd(2); TH2D* corrC2 = (TH2D*) numC2->Clone(); corrC2->Draw("surf1"); DrawNicely(corrC2, 0,0, second);//filename2); if(drawDifference){ canv->cd(3); numC1->Divide(numC2); DrawNicely(numC1, 0,0, "Correlation function"); numC1->DrawCopy("colz"); } } //save if (ifSave) { canv->Print(Form("diff_%s_%s_global.png",filename1,filename2)); //canvND->Print(Form("diff_%s_%s_global_NumDen.png",filename1,filename2)); } }