void DrawPlots(TString fn="rootplots/ttbar_partonLevel_histos_"+run+".root") { TFile *f = TFile::Open(fn); if (f==NULL) fatal("Cannot open file "+fn); TString pdf("Pdfs/top_plot_"+run+".pdf"); c = new TCanvas(); c->Print(pdf+"["); //divide canvas into quadrants c->Divide(2,2); TLatex tex; tex.SetNDC(); tex.DrawLatex(0.35,0.49,"Leptonic pseudotop"); c->cd(1); GetHisto(f,"pseudo_mass_matched")->Draw("e1"); c->Update(); c->cd(2); GetHisto(f,"pseudo_mass_unmatched")->Draw("e1"); c->Update(); c->cd(3); GetHisto(f,"pseudo_pt_matched")->Draw("e1 "); c->Update(); c->cd(4); GetHisto(f,"pseudo_pt_unmatched") ->Draw("e1 "); c->Print(pdf); c->cd(1); GetHisto(f,"pseudo_eta_matched")->Draw("e1 "); c->Update(); c->cd(2); GetHisto(f,"pseudo_eta_unmatched")->Draw("e1 "); c->Update(); c->cd(3); GetHisto(f,"whadronic")->Draw("e1 y+ "); c->Update(); c->cd(4); GetHisto(f,"wleptonic")->Draw("e1"); c->Print(pdf); c->cd(1); GetHisto(f,"m_top")->Draw("e1"); c->cd(2); GetHisto(f,"eta_top")->Draw("e1 c "); c->cd(3); GetHisto(f,"pt_top") ->Draw("e1 "); c->cd(4); GetHisto(f,"y_top")->Draw("e1 "); c->Print(pdf); c->cd(1); GetHisto(f,"eff_vs_topPt")->Draw("e1 "); c->cd(2); GetHisto(f,"neff_vs_topPt")->Draw("e1 "); c->cd(3); GetHisto(f,"eff_vs_topMass") ->Draw("e1 "); c->cd(4); GetHisto(f,"eff_vs_topeta") ->Draw("e1"); c->Print(pdf); c->cd(1); GetHisto(f,"pseudo_btop_mass")->Draw("e1 "); c->cd(2); GetHisto(f,"pseudo_HW_top")->Draw("e1 "); c->cd(3); GetHisto(f,"pseudb")->Draw("e1"); c->cd(4); GetHisto(f,"eff_vs_bmass")->Draw("e1"); c->Print(pdf); c->Print(pdf+"]"); }
void sanityChecker_babies(){ int rebin = 1 ; char* version = (char*) "V00-00-11"; //------------------------------- // choose config/PU scenario //------------------------------- // char* phase = (char*) "PhaseI"; char* phase = (char*) "PhaseII"; // char* config = (char*) "Configuration0"; // char* config = (char*) "Conf4"; char* config = (char*) ""; // char* PU = (char*) "NoPileUp"; //char* PU = (char*) "40PileUp"; // char* PU = (char*) "140PileUp"; char* PU = (char*) "140PU"; // //------------------------------- // // diboson filenames and labels // //------------------------------- // const unsigned int n = 5; // char* names[n] = {Form("BB-4p-0-300-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , // Form("BB-4p-300-700-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , // Form("BB-4p-700-1300-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , // Form("BB-4p-1300-2100-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , // Form("BB-4p-2100-100000_14TEV_%s_%s_%s" , phase , config , PU ) // }; // char* labels[n] = {"S*_{T} < 0.3 TeV", // "S*_{T} 0.3-0.7 TeV", // "S*_{T} 0.7-1.3 TeV", // "S*_{T} 1.3-2.1 TeV", // "S*_{T} > 2.1 TeV"}; // char* filename = "plots/BB-ST.pdf"; // ------------------------------- // boson+jets filenames and labels // ------------------------------- const unsigned int n = 7; char* names[n] = {Form("Bj-4p-0-300-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , Form("Bj-4p-300-600-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , Form("Bj-4p-600-1100-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , Form("Bj-4p-1100-1800-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , Form("Bj-4p-1800-2700-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , Form("Bj-4p-2700-3700-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , Form("Bj-4p-3700-100000-v1510_14TEV_%s_%s_%s" , phase , config , PU ) }; char* labels[n] = {"S*_{T} < 0.3 TeV", "S*_{T} 0.3-0.6 TeV", "S*_{T} 0.6-1.1 TeV", "S*_{T} 1.1-1.8 TeV", "S*_{T} 1.8-2.7 TeV", "S*_{T} 2.7-3.7 TeV", "S*_{T} > 3.7 TeV"}; char* filename = "plots/Bj-ST.pdf"; // //------------------------------- // // ttbar filenames and labels // //------------------------------- // const unsigned int n = 5; // char* names[n] = {Form("tt-4p-0-600-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , // Form("tt-4p-600-1100-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , // Form("tt-4p-1100-1700-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , // Form("tt-4p-1700-2500-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , // Form("tt-4p-2500-100000-v1510_14TEV_%s_%s_%s" , phase , config , PU ) // }; // char* labels[n] = {"S*_{T} < 0.6 TeV", // "S*_{T} 0.6-1.1 TeV", // "S*_{T} 1.1-1.7 TeV", // "S*_{T} 1.7-2.5 TeV", // "S*_{T} > 2.5 TeV" // }; // char* filename = "plots/tt-ST.pdf"; // //------------------------------- // // single top filenames and labels // //------------------------------- // const unsigned int n = 5; // char* names[n] = {Form("tj-4p-0-500-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , // Form("tj-4p-500-1000-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , // Form("tj-4p-1000-1600-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , // Form("tj-4p-1600-2400-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , // Form("tj-4p-2400-100000-v1510_14TEV_%s_%s_%s" , phase , config , PU ) // }; // char* labels[n] = {"S*_{T} < 0.5 TeV", // "S*_{T} 0.5-1.0 TeV", // "S*_{T} 1.0-1.6 TeV", // "S*_{T} 1.6-2.4 TeV", // "S*_{T} > 2.4 TeV" // }; // char* filename = "plots/tj-ST.pdf"; // //------------------------------- // // tW filenames and labels // //------------------------------- // const unsigned int n = 5; // char* names[n] = {Form("tB-4p-0-500-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , // Form("tB-4p-500-900-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , // Form("tB-4p-900-1500-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , // Form("tB-4p-1500-2200-v1510_14TEV_%s_%s_%s" , phase , config , PU ) , // Form("tB-4p-2200-100000-v1510_14TEV_%s_%s_%s" , phase , config , PU ) // }; // char* labels[n] = {"S*_{T} < 0.5 TeV", // "S*_{T} 0.5-0.9 TeV", // "S*_{T} 0.9-1.5 TeV", // "S*_{T} 1.5-2.2 TeV", // "S*_{T} > 2.2 TeV" // }; // char* filename = "plots/tB-ST.pdf"; //-------------------------------------------- // NO NEED TO MODIFY ANYTHING BELOW HERE //-------------------------------------------- TChain* chains[n]; //TFile* files[n]; int colors[7] = { 2 , 3 , 4 , 5 , 6 , 7 , 8 }; // need double precision here for largest samples!! TH1D* hst[n]; TH1D* hstlo[n]; THStack* htstack = new THStack(); TLegend *leg = new TLegend(0.5,0.5,0.8,0.8); cout << endl << endl; cout << "Printing out yields in 1/fb using cross sections from:" << endl; cout << "https://twiki.cern.ch/twiki/bin/viewauth/CMS/HiggsWG/Phase2UpgradeStudies#Background_samples" << endl; cout << "The unweighted yields should match the cross sections on this page (X1000)." << endl; cout << "The weighted yields have the additional Event.Weight applied." << endl; for( int i = 0 ; i < n ; i++ ){ chains[i] = new TChain("t"); chains[i]->Add(Form("output/%s/%s_baby.root",version,names[i])); hst[i] = new TH1D("hst" ,"weighted S_{T} [GeV]",100,0,10000); hstlo[i] = new TH1D("hstlo","unweighted S_{T} [GeV]",100,0,10000); chains[i]->Draw("st>>hst" ,"weight*genweight"); chains[i]->Draw("st>>hstlo","weight"); hst[i]->SetFillColor(colors[i]); hst[i]->Rebin(rebin); hst[i]->SetMinimum(1); cout << endl; cout << "1 pb yields for sample " << names[i] << endl; cout << "Unweighted yield " << hstlo[i]->Integral() << endl; cout << "Weighted yield " << hst[i]->Integral() << endl; hst[i]->GetXaxis()->SetTitle("S_{T} [GeV]"); hst[i]->GetYaxis()->SetTitle("events"); leg->AddEntry( hst[i] , labels[i] , "lf" ); htstack->Add(hst[i]); } TCanvas *c2 = new TCanvas("c2","c2",1200,600); c2->cd(); gStyle->SetOptStat(0); gPad->SetLogy(); htstack->Draw(); htstack->GetXaxis()->SetTitle("S_{T} [GeV]"); htstack->GetYaxis()->SetTitle("events"); TLatex *t = new TLatex(); t->SetNDC(); t->DrawLatex(0.5,0.85,"14 TeV, L = 1 pb^{-1}"); leg->SetBorderSize(0); leg->SetFillColor(0); leg->Draw(); }
void draw_light(){ gStyle->SetOptStat(0); TCanvas* c1= new TCanvas("c1","c1"); TLatex b; TLatex res; TFile* f1=NULL;TFile* f2=NULL; TH1F *h1=NULL;TH1F *h2=NULL;TGraphAsymmErrors *h5=NULL;TGraphAsymmErrors *h4=NULL; // f1=new TFile("../rootfiles/mc2dstd_EBEB__DiPhoJets.root","read"); // f1=new TFile("../forroofit/mc2dpp_fulletarange.root","read"); f1=new TFile("../forroofit/mc2dpp_fulletarange_madgraph.root","read"); // f1=new TFile("../forroofit/mc1f1p_fulletarange.root","read"); f2=new TFile("../forroofit/mc2dpp_fulletarange.root","read"); // f2=new TFile("../rootfiles/mc1p1f_EBEB__.root","read"); assert(f1);assert(f2); if(iso){ h1=(TH1F*)f1->Get("h_iso"); h2=(TH1F*)f2->Get("h_isogen"); TLegend* leg = new TLegend(0.55, 0.65, .9, .9); b.SetNDC();b.SetTextSize(0.06);b.SetTextColor(kRed); b.DrawLatex(0.55,0.5,"PRELIMINARY"); c1->cd(); if(logplot){ c1->SetLogy(); } c1->SetGridx(); h1->SetMarkerColor(kBlue+1);h1->SetLineColor(kBlue+1);h1->SetMarkerStyle(20); // h1->SetTitle("both photons in EB, true pp photons in DiPhotonBox+ DiPhotonJets madgraph"); h1->SetTitle("EBEB, fake photon from Gamma Jets, true photon from DiPhotonBox+ DiPhotonJets madgraph"); h1->GetXaxis()->SetTitle("Charged Iso (GeV)"); h2->SetMarkerColor(kRed+1);h2->SetLineColor(kRed+1); h2->SetMarkerStyle(20); h1->Draw(); h2->Draw("SAME"); leg->AddEntry(h1,"true p with h2gg vertex" ,"p"); leg->AddEntry(h2,"true f with primary vertex", "p"); leg->Draw(); } if(eff){ c4= new TCanvas("c4","c4"); c4->cd(); // TCanvas* c2= (TCanvas*)f1->Get("eff_h2ggv_diphopt"); h4=(TGraphAsymmErrors*)f1->Get("eff_h2ggv_diphopt"); h5=(TGraphAsymmErrors*)f1->Get("eff_pv_diphopt"); // TCanvas* c3= (TCanvas*)f1->Get("eff_pv_diphopt"); // h5=(TGraphAsymmErrors*)f1->GetPrimitive("eff_pv_diphopt"); TLegend* leg2 = new TLegend(0.12, 0.12, .4, .2); leg2->SetFillColor(kWhite); c4->SetGridx(); h4->SetMarkerColor(kBlue+1);h4->SetLineColor(kBlue+1);h4->SetMarkerStyle(20); //h4->GetXaxis()->SetRangeUser(0.,500.); h5->SetMarkerColor(kRed+1);h5->SetLineColor(kRed+1);h5->SetMarkerStyle(20); //h4->SetTitle("both photons in EB, true pp photons in DiPhotonBox+ DiPhotonJets madgraph");h4->GetXaxis()->SetTitle("Diphoton pt (GeV)"); // h4->SetTitle("true pp photons in DiPhotonBox+ Jets Sherpa, matching within 1 cm in z");h4->GetXaxis()->SetTitle("Diphoton pt (GeV)"); // h4->SetTitle("1 true 1 fake photon in GJets MC, matching within 1 cm in z");h4->GetXaxis()->SetTitle("Diphoton pt (GeV)"); h4->SetTitle("true pp photons in DiPhotonBox+ Jets madgraph, matching within 1 cm in z");h4->GetXaxis()->SetTitle("Diphoton pt (GeV)"); c4->Draw(); h4->Draw("AP"); h5->Draw("P SAME"); leg2->AddEntry(h4,"vertex by legacy algorithm" ,"p"); leg2->AddEntry(h5,"primary vertex", "p"); leg2->Draw(); b.SetNDC();b.SetTextSize(0.06);b.SetTextColor(kRed); b.DrawLatex(0.12,0.4,"PRELIMINARY"); res.SetNDC();res.SetTextSize(0.04);res.SetTextColor(kBlack); // res.DrawLatex(0.12,0.3,"hggv eff 0.75, pv eff 0.53"); // res.DrawLatex(0.12,0.3,"hggv eff 0.79, pv eff 0.65"); res.DrawLatex(0.12,0.3,"hggv eff 0.77, pv eff 0.62"); c4->Update(); } ///////////////////////////// //Save const char* outfileiso=Form("../plots/1p1f2ppisolation_pvvertex_comp_EB_%s.root", ((logplot)? "log" : "lin")); c1->SaveAs(outfileiso); const char* outfileiso2=Form("../plots/1p1f2ppisolation_pvvertex_comp_EB_%s.pdf", ((logplot)? "log" : "lin")); c1->SaveAs(outfileiso2); if(eff){ const char* outfileeff="../plots/efficiency_vertex_comp_madgraph_fulletarange.root"; c4->SaveAs(outfileeff); const char* outfileeff2="../plots/efficiency_vertex_comp_madgraph_fulletarange.png"; c4->SaveAs(outfileeff2);} }
PostProcessQAV0(Bool_t lAttemptInvMassFit = kTRUE, Char_t *output = "pdf" // "eps", "png" or "pdf" ){ CustomGStyleSettings(); //============================================================== //Open Output File TFile* file = TFile::Open("AnalysisResults.root"), "READ"); if (!file){ cout<<"Output file not found!"<<endl; return; } file->cd("PWGLFQAV0_QA"); TList* clist = (TList*)file->FindObjectAny("clist"); if (!clist){ cout<<"File does not seem to hold QA list output!"<<endl; return; } //============================================================== //============================================================== //Open Event Histogram: first canvas TH1D* fHistEvent = (TH1D*)clist->FindObject("fHistEvent"); TCanvas *cHistEvent = new TCanvas("cHistEvent","",800,670); cHistEvent->SetTopMargin(0.15); cHistEvent->SetGridx(); cHistEvent->SetGridy(); fHistEvent->Draw(); fHistEvent->SetMarkerSize(1.35); fHistEvent->GetXaxis()->SetTitleOffset(1.2); fHistEvent->GetYaxis()->SetTitleOffset(1.2); fHistEvent->Draw("same text00"); TLatex Tl; Tl.SetNDC(); Tl.SetTextSize(0.05); Tl.DrawLatex(.35, .9277, "Event Counters") ; if (output == "png") cHistEvent->SaveAs("LF_QAanalysis_V0_page1.png"); else if (output == "eps") cHistEvent->SaveAs("LF_QAanalysis_V0_page1.eps"); else if (output == "pdf") cHistEvent->SaveAs("LF_QAanalysis_V0.pdf("); //============================================================== //============================================================== //Invariant Mass Plots: Base, no dE/dx /* TH2D *f2dHistInvMassK0Short = (TH2D*)clist->FindObject("f2dHistInvMassK0Short"); TH2D *f2dHistInvMassLambda = (TH2D*)clist->FindObject("f2dHistInvMassLambda"); TH2D *f2dHistInvMassAntiLambda = (TH2D*)clist->FindObject("f2dHistInvMassAntiLambda"); f2dHistInvMassK0Short -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); f2dHistInvMassLambda -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); f2dHistInvMassAntiLambda -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); TCanvas *cInvMassK0Short = new TCanvas ( "cInvMassK0Short", "", 1200,800); cInvMassK0Short->Divide(1,2); cInvMassK0Short->cd(2)->Divide(3,1); cInvMassK0Short->cd(1); cInvMassK0Short->cd(1)->SetLogz(); cInvMassK0Short->cd(1)->SetLeftMargin(0.065); cInvMassK0Short->cd(1)->SetTopMargin(0.13); cInvMassK0Short->cd(1)->SetBottomMargin(0.11); f2dHistInvMassK0Short->GetYaxis()->SetTitleSize(0.05); f2dHistInvMassK0Short->GetYaxis()->SetTitleOffset(0.6); f2dHistInvMassK0Short->GetXaxis()->SetTitleSize(0.05); f2dHistInvMassK0Short->GetXaxis()->SetTitle("p_{T} (GeV/c)"); f2dHistInvMassK0Short->GetZaxis()->SetTitle("Counts / Event"); f2dHistInvMassK0Short->GetZaxis()->SetTitleOffset(0.7); f2dHistInvMassK0Short->GetZaxis()->SetRangeUser( f2dHistInvMassK0Short->GetMinimum(1e-10)*0.9, f2dHistInvMassK0Short->GetMaximum()*1.2 ); f2dHistInvMassK0Short->Draw("colz"); Tl.DrawLatex(.35, .9277, "Mass under K^{0}_{S} hypothesis, no TPC dE/dx") ; TH1D *fLowPtK0ShortSample = (TH1D*) f2dHistInvMassK0Short->ProjectionY( "fLowPtK0ShortSample", f2dHistInvMassK0Short->GetXaxis()->FindBin(0.5001), f2dHistInvMassK0Short->GetXaxis()->FindBin(0.9999) ); TH1D *fMidPtK0ShortSample = (TH1D*) f2dHistInvMassK0Short->ProjectionY( "fMidPtK0ShortSample", f2dHistInvMassK0Short->GetXaxis()->FindBin(1.5001), f2dHistInvMassK0Short->GetXaxis()->FindBin(2.4999) ); TH1D *fHiPtK0ShortSample = (TH1D*) f2dHistInvMassK0Short->ProjectionY( "fHiPtK0ShortSample", f2dHistInvMassK0Short->GetXaxis()->FindBin(5.0001), f2dHistInvMassK0Short->GetXaxis()->FindBin(9.9999) ); for(Int_t ic = 1; ic<4; ic++){ cInvMassK0Short->cd(2)->cd(ic)->SetTopMargin(0.14); cInvMassK0Short->cd(2)->cd(ic)->SetLeftMargin(0.15); cInvMassK0Short->cd(2)->cd(ic)->SetBottomMargin(0.11); cInvMassK0Short->cd(2)->cd(ic)->SetGridx(); cInvMassK0Short->cd(2)->cd(ic)->SetGridy(); } cInvMassK0Short->cd(2)->cd(1); fLowPtK0ShortSample->GetXaxis()->SetTitleOffset(1.1); fLowPtK0ShortSample->GetYaxis()->SetTitleOffset(2.33); fLowPtK0ShortSample->GetYaxis()->SetTitle("Counts/Event"); fLowPtK0ShortSample->Draw(); Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0"); cInvMassK0Short->cd(2)->cd(2); fMidPtK0ShortSample->GetXaxis()->SetTitleOffset(1.1); fMidPtK0ShortSample->GetYaxis()->SetTitleOffset(2.33); fMidPtK0ShortSample->GetYaxis()->SetTitle("Counts/Event"); fMidPtK0ShortSample->Draw(); Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5"); cInvMassK0Short->cd(2)->cd(3); fHiPtK0ShortSample->GetXaxis()->SetTitleOffset(1.1); fHiPtK0ShortSample->GetYaxis()->SetTitleOffset(2.33); fHiPtK0ShortSample->GetYaxis()->SetTitle("Counts/Event"); fHiPtK0ShortSample->Draw(); Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10"); if (output == "png") cInvMassK0Short->SaveAs("LF_QAanalysis_V0_pageX.png"); else if (output == "eps") cInvMassK0Short->SaveAs("LF_QAanalysis_V0_pageX.eps"); else if (output == "pdf") cInvMassK0Short->SaveAs("LF_QAanalysis_V0.pdf"); */ //============================================================== //============================================================== //Invariant Mass Plots: WITH dE/dx TH2D *f2dHistInvMassWithdEdxK0Short = (TH2D*)clist->FindObject("f2dHistInvMassWithdEdxK0Short"); TH2D *f2dHistInvMassWithdEdxLambda = (TH2D*)clist->FindObject("f2dHistInvMassWithdEdxLambda"); TH2D *f2dHistInvMassWithdEdxAntiLambda = (TH2D*)clist->FindObject("f2dHistInvMassWithdEdxAntiLambda"); f2dHistInvMassWithdEdxK0Short -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); f2dHistInvMassWithdEdxLambda -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); f2dHistInvMassWithdEdxAntiLambda -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); TCanvas *cInvMassK0ShortWithdEdx = new TCanvas ( "cInvMassK0ShortWithdEdx", "", 1200,800); cInvMassK0ShortWithdEdx->Divide(1,2); cInvMassK0ShortWithdEdx->cd(2)->Divide(3,1); cInvMassK0ShortWithdEdx->cd(1); cInvMassK0ShortWithdEdx->cd(1)->SetLogz(); cInvMassK0ShortWithdEdx->cd(1)->SetLeftMargin(0.065); cInvMassK0ShortWithdEdx->cd(1)->SetTopMargin(0.13); cInvMassK0ShortWithdEdx->cd(1)->SetBottomMargin(0.11); f2dHistInvMassWithdEdxK0Short->GetYaxis()->SetTitleSize(0.05); f2dHistInvMassWithdEdxK0Short->GetYaxis()->SetTitleOffset(0.6); f2dHistInvMassWithdEdxK0Short->GetXaxis()->SetTitleSize(0.05); f2dHistInvMassWithdEdxK0Short->GetXaxis()->SetTitle("p_{T} (GeV/c)"); f2dHistInvMassWithdEdxK0Short->GetZaxis()->SetTitle("Counts / Event"); f2dHistInvMassWithdEdxK0Short->GetZaxis()->SetTitleOffset(0.7); f2dHistInvMassWithdEdxK0Short->GetZaxis()->SetRangeUser( f2dHistInvMassWithdEdxK0Short->GetMinimum(1e-10)*0.9, f2dHistInvMassWithdEdxK0Short->GetMaximum()*1.2 ); f2dHistInvMassWithdEdxK0Short->Draw("colz"); Tl.DrawLatex(.35, .9277, "Mass under K^{0}_{S} hypothesis, With TPC dE/dx") ; TH1D *fLowPtK0ShortSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxK0Short->ProjectionY( "fLowPtK0ShortSampleWithdEdx", f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(0.5001), f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(0.9999) ); TH1D *fMidPtK0ShortSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxK0Short->ProjectionY( "fMidPtK0ShortSampleWithdEdx", f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(1.5001), f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(2.4999) ); TH1D *fHiPtK0ShortSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxK0Short->ProjectionY( "fHiPtK0ShortSampleWithdEdx", f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(5.0001), f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(9.9999) ); for(Int_t ic = 1; ic<4; ic++){ cInvMassK0ShortWithdEdx->cd(2)->cd(ic)->SetTopMargin(0.14); cInvMassK0ShortWithdEdx->cd(2)->cd(ic)->SetLeftMargin(0.15); cInvMassK0ShortWithdEdx->cd(2)->cd(ic)->SetBottomMargin(0.11); cInvMassK0ShortWithdEdx->cd(2)->cd(ic)->SetGridx(); cInvMassK0ShortWithdEdx->cd(2)->cd(ic)->SetGridy(); } cInvMassK0ShortWithdEdx->cd(2)->cd(1); fLowPtK0ShortSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fLowPtK0ShortSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fLowPtK0ShortSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fLowPtK0ShortSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0"); cInvMassK0ShortWithdEdx->cd(2)->cd(2); fMidPtK0ShortSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fMidPtK0ShortSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fMidPtK0ShortSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fMidPtK0ShortSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5"); cInvMassK0ShortWithdEdx->cd(2)->cd(3); fHiPtK0ShortSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fHiPtK0ShortSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fHiPtK0ShortSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fHiPtK0ShortSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10"); TLatex Tli; Tli.SetNDC(); Tli.SetTextSize(0.05); if( lAttemptInvMassFit ){ //Attempt rough signal extraction TF1 *f1 = new TF1("f1","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",0.435, 0.565); //Reasonable first guess f1->SetParameter(0, fLowPtK0ShortSampleWithdEdx -> GetBinContent( fLowPtK0ShortSampleWithdEdx->FindBin(0.497-0.01) ) ); f1->SetParameter(1, 0 ); f1->SetParameter(2, 0 ); f1->SetParameter(3, 0.5*fLowPtK0ShortSampleWithdEdx->GetMaximum() ); f1->SetParameter(4, 0.497); f1->SetParameter(5, 0.0045); cout<<"Will now fit, please wait!"<<endl; fLowPtK0ShortSampleWithdEdx->Fit("f1","REM0"); cInvMassK0ShortWithdEdx->cd(2)->cd(1); f1->Draw("same"); //Peak Position, Width: printout fLowPtK0ShortSampleWithdEdx->GetYaxis()->SetRangeUser(0,fLowPtK0ShortSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",f1->GetParameter(4),f1->GetParameter(5)) ) ; //Attempt rough signal extraction TF1 *f2 = new TF1("f2","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",0.375, 0.635); //Reasonable first guess f2->SetParameter(0, fMidPtK0ShortSampleWithdEdx -> GetBinContent( fMidPtK0ShortSampleWithdEdx->FindBin(0.497-0.01) ) ); f2->SetParameter(1, 0 ); f2->SetParameter(2, 0 ); f2->SetParameter(3, 0.5*fMidPtK0ShortSampleWithdEdx->GetMaximum() ); f2->SetParameter(4, 0.497); f2->SetParameter(5, 0.0045); cout<<"Will now fit, please wait!"<<endl; fMidPtK0ShortSampleWithdEdx->Fit("f2","REM0"); cInvMassK0ShortWithdEdx->cd(2)->cd(2); f2->Draw("same"); //Peak Position, Width: printout fMidPtK0ShortSampleWithdEdx->GetYaxis()->SetRangeUser(0,fMidPtK0ShortSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",f2->GetParameter(4),f2->GetParameter(5)) ) ; //Attempt rough signal extraction TF1 *f3 = new TF1("f3","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",0.375, 0.665); //Reasonable first guess f3->SetParameter(0, fHiPtK0ShortSampleWithdEdx -> GetBinContent( fHiPtK0ShortSampleWithdEdx->FindBin(0.497-0.01) ) ); f3->SetParameter(1, 0 ); f3->SetParameter(2, 0 ); f3->SetParameter(3, 0.5*fHiPtK0ShortSampleWithdEdx->GetMaximum() ); f3->SetParameter(4, 0.497); f3->SetParameter(5, 0.0045); cout<<"Will now fit, please wait!"<<endl; fHiPtK0ShortSampleWithdEdx->Fit("f3","REM0"); cInvMassK0ShortWithdEdx->cd(2)->cd(3); f3->Draw("same"); //Peak Position, Width: printout fHiPtK0ShortSampleWithdEdx->GetYaxis()->SetRangeUser(0,fHiPtK0ShortSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",f3->GetParameter(4),f3->GetParameter(5)) ) ; } if (output == "png") cInvMassK0ShortWithdEdx->SaveAs("LF_QAanalysis_V0_page2.png"); else if (output == "eps") cInvMassK0ShortWithdEdx->SaveAs("LF_QAanalysis_V0_page2.eps"); else if (output == "pdf") cInvMassK0ShortWithdEdx->SaveAs("LF_QAanalysis_V0.pdf"); //============================================================== //============================================================== //Invariant Mass Plots: Base, no dE/dx /* TCanvas *cInvMassLambda = new TCanvas ( "cInvMassLambda", "", 1200,800); cInvMassLambda->Divide(1,2); cInvMassLambda->cd(2)->Divide(3,1); cInvMassLambda->cd(1); cInvMassLambda->cd(1)->SetLogz(); cInvMassLambda->cd(1)->SetLeftMargin(0.065); cInvMassLambda->cd(1)->SetTopMargin(0.13); cInvMassLambda->cd(1)->SetBottomMargin(0.11); f2dHistInvMassLambda->GetYaxis()->SetTitleSize(0.05); f2dHistInvMassLambda->GetYaxis()->SetTitleOffset(0.6); f2dHistInvMassLambda->GetXaxis()->SetTitleSize(0.05); f2dHistInvMassLambda->GetXaxis()->SetTitle("p_{T} (GeV/c)"); f2dHistInvMassLambda->GetZaxis()->SetTitle("Counts / Event"); f2dHistInvMassLambda->GetZaxis()->SetTitleOffset(0.7); f2dHistInvMassLambda->GetZaxis()->SetRangeUser( f2dHistInvMassLambda->GetMinimum(1e-10)*0.9, f2dHistInvMassLambda->GetMaximum()*1.2 ); f2dHistInvMassLambda->Draw("colz"); Tl.DrawLatex(.35, .9277, "Mass under #Lambda hypothesis, no TPC dE/dx") ; TH1D *fLowPtLambdaSample = (TH1D*) f2dHistInvMassLambda->ProjectionY( "fLowPtLambdaSample", f2dHistInvMassLambda->GetXaxis()->FindBin(0.5001), f2dHistInvMassLambda->GetXaxis()->FindBin(0.9999) ); TH1D *fMidPtLambdaSample = (TH1D*) f2dHistInvMassLambda->ProjectionY( "fMidPtLambdaSample", f2dHistInvMassLambda->GetXaxis()->FindBin(1.5001), f2dHistInvMassLambda->GetXaxis()->FindBin(2.4999) ); TH1D *fHiPtLambdaSample = (TH1D*) f2dHistInvMassLambda->ProjectionY( "fHiPtLambdaSample", f2dHistInvMassLambda->GetXaxis()->FindBin(5.0001), f2dHistInvMassLambda->GetXaxis()->FindBin(9.9999) ); for(Int_t ic = 1; ic<4; ic++){ cInvMassLambda->cd(2)->cd(ic)->SetTopMargin(0.14); cInvMassLambda->cd(2)->cd(ic)->SetLeftMargin(0.15); cInvMassLambda->cd(2)->cd(ic)->SetBottomMargin(0.11); cInvMassLambda->cd(2)->cd(ic)->SetGridx(); cInvMassLambda->cd(2)->cd(ic)->SetGridy(); } cInvMassLambda->cd(2)->cd(1); fLowPtLambdaSample->GetXaxis()->SetTitleOffset(1.1); fLowPtLambdaSample->GetYaxis()->SetTitleOffset(2.33); fLowPtLambdaSample->GetYaxis()->SetTitle("Counts/Event"); fLowPtLambdaSample->Draw(); Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0"); cInvMassLambda->cd(2)->cd(2); fMidPtLambdaSample->GetXaxis()->SetTitleOffset(1.1); fMidPtLambdaSample->GetYaxis()->SetTitleOffset(2.33); fMidPtLambdaSample->GetYaxis()->SetTitle("Counts/Event"); fMidPtLambdaSample->Draw(); Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5"); cInvMassLambda->cd(2)->cd(3); fHiPtLambdaSample->GetXaxis()->SetTitleOffset(1.1); fHiPtLambdaSample->GetYaxis()->SetTitleOffset(2.33); fHiPtLambdaSample->GetYaxis()->SetTitle("Counts/Event"); fHiPtLambdaSample->Draw(); Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10"); if (output == "png") cInvMassLambda->SaveAs("LF_QAanalysis_V0_pageY.png"); else if (output == "eps") cInvMassLambda->SaveAs("LF_QAanalysis_V0_pageY.eps"); else if (output == "pdf") cInvMassLambda->SaveAs("LF_QAanalysis_V0.pdf"); */ //============================================================== //============================================================== //Invariant Mass Plots: WITH dE/dx TCanvas *cInvMassLambdaWithdEdx = new TCanvas ( "cInvMassLambdaWithdEdx", "", 1200,800); cInvMassLambdaWithdEdx->Divide(1,2); cInvMassLambdaWithdEdx->cd(2)->Divide(3,1); cInvMassLambdaWithdEdx->cd(1); cInvMassLambdaWithdEdx->cd(1)->SetLogz(); cInvMassLambdaWithdEdx->cd(1)->SetLeftMargin(0.065); cInvMassLambdaWithdEdx->cd(1)->SetTopMargin(0.13); cInvMassLambdaWithdEdx->cd(1)->SetBottomMargin(0.11); f2dHistInvMassWithdEdxLambda->GetYaxis()->SetTitleSize(0.05); f2dHistInvMassWithdEdxLambda->GetYaxis()->SetTitleOffset(0.6); f2dHistInvMassWithdEdxLambda->GetXaxis()->SetTitleSize(0.05); f2dHistInvMassWithdEdxLambda->GetXaxis()->SetTitle("p_{T} (GeV/c)"); f2dHistInvMassWithdEdxLambda->GetZaxis()->SetTitle("Counts / Event"); f2dHistInvMassWithdEdxLambda->GetZaxis()->SetTitleOffset(0.7); f2dHistInvMassWithdEdxLambda->GetZaxis()->SetRangeUser( f2dHistInvMassWithdEdxLambda->GetMinimum(1e-10)*0.9, f2dHistInvMassWithdEdxLambda->GetMaximum()*1.2 ); f2dHistInvMassWithdEdxLambda->Draw("colz"); Tl.DrawLatex(.35, .9277, "Mass under #Lambda hypothesis, With TPC dE/dx") ; TH1D *fLowPtLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxLambda->ProjectionY( "fLowPtLambdaSampleWithdEdx", f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(0.5001), f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(0.9999) ); TH1D *fMidPtLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxLambda->ProjectionY( "fMidPtLambdaSampleWithdEdx", f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(1.5001), f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(2.4999) ); TH1D *fHiPtLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxLambda->ProjectionY( "fHiPtLambdaSampleWithdEdx", f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(5.0001), f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(9.9999) ); for(Int_t ic = 1; ic<4; ic++){ cInvMassLambdaWithdEdx->cd(2)->cd(ic)->SetTopMargin(0.14); cInvMassLambdaWithdEdx->cd(2)->cd(ic)->SetLeftMargin(0.15); cInvMassLambdaWithdEdx->cd(2)->cd(ic)->SetBottomMargin(0.11); cInvMassLambdaWithdEdx->cd(2)->cd(ic)->SetGridx(); cInvMassLambdaWithdEdx->cd(2)->cd(ic)->SetGridy(); } cInvMassLambdaWithdEdx->cd(2)->cd(1); fLowPtLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fLowPtLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fLowPtLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fLowPtLambdaSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0"); cInvMassLambdaWithdEdx->cd(2)->cd(2); fMidPtLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fMidPtLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fMidPtLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fMidPtLambdaSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5"); cInvMassLambdaWithdEdx->cd(2)->cd(3); fHiPtLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fHiPtLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fHiPtLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fHiPtLambdaSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10"); if( lAttemptInvMassFit ){ //Attempt rough signal extraction TF1 *fl1 = new TF1("fl1","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.095, 1.14); //Reasonable first guess fl1->SetParameter(0, fLowPtLambdaSampleWithdEdx -> GetBinContent( fLowPtLambdaSampleWithdEdx->FindBin(1.116+0.01) ) ); fl1->SetParameter(1, 0 ); fl1->SetParameter(2, 0 ); fl1->SetParameter(3, 0.35*fLowPtLambdaSampleWithdEdx->GetMaximum() ); fl1->SetParameter(4, 1.115683); fl1->SetParLimits(4,1.116-0.01,1.116+0.01); fl1->SetParameter(5, 0.002); fl1->SetParLimits(5,0.0005,0.01); cout<<"Will now fit, please wait!"<<endl; fLowPtLambdaSampleWithdEdx->Fit("fl1","REM0"); cInvMassLambdaWithdEdx->cd(2)->cd(1); fl1->Draw("same"); //Peak Position, Width: printout fLowPtLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fLowPtLambdaSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fl1->GetParameter(4),fl1->GetParameter(5)) ) ; //Attempt rough signal extraction TF1 *fl2 = new TF1("fl2","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.085, 1.15); //Reasonable first guess fl2->SetParameter(0, fMidPtLambdaSampleWithdEdx -> GetBinContent( fMidPtLambdaSampleWithdEdx->FindBin(1.116+0.01) ) ); fl2->SetParameter(1, 0 ); fl2->SetParameter(2, 0 ); fl2->SetParameter(3, 0.6*fMidPtLambdaSampleWithdEdx->GetMaximum() ); fl2->SetParLimits(4,1.116-0.01,1.116+0.01); fl2->SetParameter(4, 1.116); fl2->SetParameter(5, 0.0025); fl2->SetParLimits(5,0.0005,0.01); cout<<"Will now fit, please wait!"<<endl; fMidPtLambdaSampleWithdEdx->Fit("fl2","REM0"); cInvMassLambdaWithdEdx->cd(2)->cd(2); fl2->Draw("same"); //Peak Position, Width: printout fMidPtLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fMidPtLambdaSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fl2->GetParameter(4),fl2->GetParameter(5)) ) ; //Attempt rough signal extraction TF1 *fl3 = new TF1("fl3","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.095, 1.15); //Reasonable first guess fl3->SetParameter(0, fHiPtLambdaSampleWithdEdx -> GetBinContent( fHiPtLambdaSampleWithdEdx->FindBin(1.116+0.01) ) ); fl3->SetParameter(1, 0 ); fl3->SetParameter(2, 0 ); fl3->SetParameter(3, 0.6*fHiPtLambdaSampleWithdEdx->GetMaximum() ); fl3->SetParameter(4, 1.116); fl3->SetParLimits(4,1.116-0.005,1.116+0.005); fl3->SetParameter(5, 0.0035); fl3->SetParLimits(5,0.0005,0.01); cout<<"Will now fit, please wait!"<<endl; fHiPtLambdaSampleWithdEdx->Fit("fl3","REM0"); cInvMassLambdaWithdEdx->cd(2)->cd(3); fl3->Draw("same"); //Peak Position, Width: printout fHiPtLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fHiPtLambdaSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fl3->GetParameter(4),fl3->GetParameter(5)) ) ; } if (output == "png") cInvMassLambdaWithdEdx->SaveAs("LF_QAanalysis_V0_page3.png"); else if (output == "eps") cInvMassLambdaWithdEdx->SaveAs("LF_QAanalysis_V0_page3.eps"); else if (output == "pdf") cInvMassLambdaWithdEdx->SaveAs("LF_QAanalysis_V0.pdf"); //============================================================== //============================================================== //Invariant Mass Plots: Base, no dE/dx /* TCanvas *cInvMassAntiLambda = new TCanvas ( "cInvMassAntiLambda", "", 1200,800); cInvMassAntiLambda->Divide(1,2); cInvMassAntiLambda->cd(2)->Divide(3,1); cInvMassAntiLambda->cd(1); cInvMassAntiLambda->cd(1)->SetLogz(); cInvMassAntiLambda->cd(1)->SetLeftMargin(0.065); cInvMassAntiLambda->cd(1)->SetTopMargin(0.13); cInvMassAntiLambda->cd(1)->SetBottomMargin(0.11); f2dHistInvMassAntiLambda->GetYaxis()->SetTitleSize(0.05); f2dHistInvMassAntiLambda->GetYaxis()->SetTitleOffset(0.6); f2dHistInvMassAntiLambda->GetXaxis()->SetTitleSize(0.05); f2dHistInvMassAntiLambda->GetXaxis()->SetTitle("p_{T} (GeV/c)"); f2dHistInvMassAntiLambda->GetZaxis()->SetTitle("Counts / Event"); f2dHistInvMassAntiLambda->GetZaxis()->SetTitleOffset(0.7); f2dHistInvMassAntiLambda->GetZaxis()->SetRangeUser( f2dHistInvMassAntiLambda->GetMinimum(1e-10)*0.9, f2dHistInvMassAntiLambda->GetMaximum()*1.2 ); f2dHistInvMassAntiLambda->Draw("colz"); Tl.DrawLatex(.35, .9277, "Mass under #bar{#Lambda} hypothesis, no TPC dE/dx") ; TH1D *fLowPtAntiLambdaSample = (TH1D*) f2dHistInvMassAntiLambda->ProjectionY( "fLowPtAntiLambdaSample", f2dHistInvMassAntiLambda->GetXaxis()->FindBin(0.5001), f2dHistInvMassAntiLambda->GetXaxis()->FindBin(0.9999) ); TH1D *fMidPtAntiLambdaSample = (TH1D*) f2dHistInvMassAntiLambda->ProjectionY( "fMidPtAntiLambdaSample", f2dHistInvMassAntiLambda->GetXaxis()->FindBin(1.5001), f2dHistInvMassAntiLambda->GetXaxis()->FindBin(2.4999) ); TH1D *fHiPtAntiLambdaSample = (TH1D*) f2dHistInvMassAntiLambda->ProjectionY( "fHiPtAntiLambdaSample", f2dHistInvMassAntiLambda->GetXaxis()->FindBin(5.0001), f2dHistInvMassAntiLambda->GetXaxis()->FindBin(9.9999) ); for(Int_t ic = 1; ic<4; ic++){ cInvMassAntiLambda->cd(2)->cd(ic)->SetTopMargin(0.14); cInvMassAntiLambda->cd(2)->cd(ic)->SetLeftMargin(0.15); cInvMassAntiLambda->cd(2)->cd(ic)->SetBottomMargin(0.11); cInvMassAntiLambda->cd(2)->cd(ic)->SetGridx(); cInvMassAntiLambda->cd(2)->cd(ic)->SetGridy(); } cInvMassAntiLambda->cd(2)->cd(1); fLowPtAntiLambdaSample->GetXaxis()->SetTitleOffset(1.1); fLowPtAntiLambdaSample->GetYaxis()->SetTitleOffset(2.33); fLowPtAntiLambdaSample->GetYaxis()->SetTitle("Counts/Event"); fLowPtAntiLambdaSample->Draw(); Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0"); cInvMassAntiLambda->cd(2)->cd(2); fMidPtAntiLambdaSample->GetXaxis()->SetTitleOffset(1.1); fMidPtAntiLambdaSample->GetYaxis()->SetTitleOffset(2.33); fMidPtAntiLambdaSample->GetYaxis()->SetTitle("Counts/Event"); fMidPtAntiLambdaSample->Draw(); Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5"); cInvMassAntiLambda->cd(2)->cd(3); fHiPtAntiLambdaSample->GetXaxis()->SetTitleOffset(1.1); fHiPtAntiLambdaSample->GetYaxis()->SetTitleOffset(2.33); fHiPtAntiLambdaSample->GetYaxis()->SetTitle("Counts/Event"); fHiPtAntiLambdaSample->Draw(); Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10"); if (output == "png") cInvMassAntiLambda->SaveAs("LF_QAanalysis_V0_pageZ.png"); else if (output == "eps") cInvMassAntiLambda->SaveAs("LF_QAanalysis_V0_pageZ.eps"); else if (output == "pdf") cInvMassAntiLambda->SaveAs("LF_QAanalysis_V0.pdf"); */ //============================================================== //============================================================== //Invariant Mass Plots: WITH dE/dx TCanvas *cInvMassAntiLambdaWithdEdx = new TCanvas ( "cInvMassAntiLambdaWithdEdx", "", 1200,800); cInvMassAntiLambdaWithdEdx->Divide(1,2); cInvMassAntiLambdaWithdEdx->cd(2)->Divide(3,1); cInvMassAntiLambdaWithdEdx->cd(1); cInvMassAntiLambdaWithdEdx->cd(1)->SetLogz(); cInvMassAntiLambdaWithdEdx->cd(1)->SetLeftMargin(0.065); cInvMassAntiLambdaWithdEdx->cd(1)->SetTopMargin(0.13); cInvMassAntiLambdaWithdEdx->cd(1)->SetBottomMargin(0.11); f2dHistInvMassWithdEdxAntiLambda->GetYaxis()->SetTitleSize(0.05); f2dHistInvMassWithdEdxAntiLambda->GetYaxis()->SetTitleOffset(0.6); f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->SetTitleSize(0.05); f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->SetTitle("p_{T} (GeV/c)"); f2dHistInvMassWithdEdxAntiLambda->GetZaxis()->SetTitle("Counts / Event"); f2dHistInvMassWithdEdxAntiLambda->GetZaxis()->SetTitleOffset(0.7); f2dHistInvMassWithdEdxAntiLambda->GetZaxis()->SetRangeUser( f2dHistInvMassWithdEdxAntiLambda->GetMinimum(1e-10)*0.9, f2dHistInvMassWithdEdxAntiLambda->GetMaximum()*1.2 ); f2dHistInvMassWithdEdxAntiLambda->Draw("colz"); Tl.DrawLatex(.35, .9277, "Mass under #bar{#Lambda} hypothesis, With TPC dE/dx") ; TH1D *fLowPtAntiLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxAntiLambda->ProjectionY( "fLowPtAntiLambdaSampleWithdEdx", f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(0.5001), f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(0.9999) ); TH1D *fMidPtAntiLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxAntiLambda->ProjectionY( "fMidPtAntiLambdaSampleWithdEdx", f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(1.5001), f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(2.4999) ); TH1D *fHiPtAntiLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxAntiLambda->ProjectionY( "fHiPtAntiLambdaSampleWithdEdx", f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(5.0001), f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(9.9999) ); for(Int_t ic = 1; ic<4; ic++){ cInvMassAntiLambdaWithdEdx->cd(2)->cd(ic)->SetTopMargin(0.14); cInvMassAntiLambdaWithdEdx->cd(2)->cd(ic)->SetLeftMargin(0.15); cInvMassAntiLambdaWithdEdx->cd(2)->cd(ic)->SetBottomMargin(0.11); cInvMassAntiLambdaWithdEdx->cd(2)->cd(ic)->SetGridx(); cInvMassAntiLambdaWithdEdx->cd(2)->cd(ic)->SetGridy(); } cInvMassAntiLambdaWithdEdx->cd(2)->cd(1); fLowPtAntiLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fLowPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fLowPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fLowPtAntiLambdaSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0"); cInvMassAntiLambdaWithdEdx->cd(2)->cd(2); fMidPtAntiLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fMidPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fMidPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fMidPtAntiLambdaSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5"); cInvMassAntiLambdaWithdEdx->cd(2)->cd(3); fHiPtAntiLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1); fHiPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33); fHiPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event"); fHiPtAntiLambdaSampleWithdEdx->Draw(); Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10"); if( lAttemptInvMassFit ){ //Attempt rough signal extraction TF1 *fal1 = new TF1("fal1","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.095, 1.14); //Reasonable first guess fal1->SetParameter(0, fLowPtAntiLambdaSampleWithdEdx -> GetBinContent( fLowPtAntiLambdaSampleWithdEdx->FindBin(1.116+0.01) ) ); fal1->SetParameter(1, 0 ); fal1->SetParameter(2, 0 ); fal1->SetParameter(3, 0.35*fLowPtAntiLambdaSampleWithdEdx->GetMaximum() ); fal1->SetParameter(4, 1.115683); fal1->SetParLimits(4,1.116-0.01,1.116+0.01); fal1->SetParameter(5, 0.002); fal1->SetParLimits(5,0.0005,0.01); cout<<"Will now fit, please wait!"<<endl; fLowPtAntiLambdaSampleWithdEdx->Fit("fal1","REM0"); cInvMassAntiLambdaWithdEdx->cd(2)->cd(1); fal1->Draw("same"); //Peak Position, Width: printout fLowPtAntiLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fLowPtAntiLambdaSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fal1->GetParameter(4),fal1->GetParameter(5)) ) ; //Attempt rough signal extraction TF1 *fal2 = new TF1("fal2","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.085, 1.15); //Reasonable first guess fal2->SetParameter(0, fMidPtAntiLambdaSampleWithdEdx -> GetBinContent( fMidPtAntiLambdaSampleWithdEdx->FindBin(1.116+0.01) ) ); fal2->SetParameter(1, 0 ); fal2->SetParameter(2, 0 ); fal2->SetParameter(3, 0.6*fMidPtAntiLambdaSampleWithdEdx->GetMaximum() ); fal2->SetParLimits(4,1.116-0.01,1.116+0.01); fal2->SetParameter(4, 1.116); fal2->SetParameter(5, 0.0025); fal2->SetParLimits(5,0.0005,0.01); cout<<"Will now fit, please wait!"<<endl; fMidPtAntiLambdaSampleWithdEdx->Fit("fal2","REM0"); cInvMassAntiLambdaWithdEdx->cd(2)->cd(2); fal2->Draw("same"); //Peak Position, Width: printout fMidPtAntiLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fMidPtAntiLambdaSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fal2->GetParameter(4),fal2->GetParameter(5)) ) ; //Attempt rough signal extraction TF1 *fal3 = new TF1("fal3","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.095, 1.15); //Reasonable first guess fal3->SetParameter(0, fHiPtAntiLambdaSampleWithdEdx -> GetBinContent( fHiPtAntiLambdaSampleWithdEdx->FindBin(1.116+0.01) ) ); fal3->SetParameter(1, 0 ); fal3->SetParameter(2, 0 ); fal3->SetParameter(3, 0.6*fHiPtAntiLambdaSampleWithdEdx->GetMaximum() ); fal3->SetParameter(4, 1.116); fal3->SetParLimits(4,1.116-0.005,1.116+0.005); fal3->SetParameter(5, 0.0035); fal3->SetParLimits(5,0.0005,0.01); cout<<"Will now fit, please wait!"<<endl; fHiPtAntiLambdaSampleWithdEdx->Fit("fal3","REM0"); cInvMassAntiLambdaWithdEdx->cd(2)->cd(3); fal3->Draw("same"); //Peak Position, Width: printout fHiPtAntiLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fHiPtAntiLambdaSampleWithdEdx->GetMaximum() * 1.2); Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fal3->GetParameter(4),fal3->GetParameter(5)) ) ; } if (output == "png") cInvMassAntiLambdaWithdEdx->SaveAs("LF_QAanalysis_V0_page4.png"); else if (output == "eps") cInvMassAntiLambdaWithdEdx->SaveAs("LF_QAanalysis_V0_page4.eps"); else if (output == "pdf") cInvMassAntiLambdaWithdEdx->SaveAs("LF_QAanalysis_V0.pdf"); //============================================================== //============================================================== // Strict Lambda Analysis for dE/dx Calibration Check TH2D *f2dHistdEdxSignalPionFromLambda = (TH2D*)clist->FindObject("f2dHistdEdxSignalPionFromLambda"); TH2D *f2dHistdEdxSignalProtonFromLambda = (TH2D*)clist->FindObject("f2dHistdEdxSignalProtonFromLambda"); TH2D *f2dHistResponsePionFromLambda = (TH2D*)clist->FindObject("f2dHistResponsePionFromLambda"); TH2D *f2dHistResponseProtonFromLambda = (TH2D*)clist->FindObject("f2dHistResponseProtonFromLambda"); f2dHistdEdxSignalPionFromLambda->Rebin2D(2,10); f2dHistdEdxSignalProtonFromLambda->Rebin2D(2,10); TH1D *fLowPtPionResponse = (TH1D*) f2dHistResponsePionFromLambda->ProjectionY( "fLowPtPionResponse", f2dHistResponsePionFromLambda->GetXaxis()->FindBin(0.5001), f2dHistResponsePionFromLambda->GetXaxis()->FindBin(0.9999) ); TH1D *fMidPtPionResponse = (TH1D*) f2dHistResponsePionFromLambda->ProjectionY( "fMidPtPionResponse", f2dHistResponsePionFromLambda->GetXaxis()->FindBin(1.5001), f2dHistResponsePionFromLambda->GetXaxis()->FindBin(2.4999) ); TH1D *fLowPtProtonResponse = (TH1D*) f2dHistResponseProtonFromLambda->ProjectionY( "fLowPtProtonResponse", f2dHistResponseProtonFromLambda->GetXaxis()->FindBin(0.5001), f2dHistResponseProtonFromLambda->GetXaxis()->FindBin(0.9999) ); TH1D *fMidPtProtonResponse = (TH1D*) f2dHistResponseProtonFromLambda->ProjectionY( "fMidPtProtonResponse", f2dHistResponseProtonFromLambda->GetXaxis()->FindBin(1.5001), f2dHistResponseProtonFromLambda->GetXaxis()->FindBin(2.4999) ); TCanvas *cdEdxPure = new TCanvas("cdEdxPure","",1500,800); cdEdxPure->Divide(4,2); for(Int_t ic = 1; ic<9; ic++){ cdEdxPure->SetLeftMargin(0.15); cdEdxPure->cd(ic)->SetLogz(); //cdEdxPure->cd(ic)->SetTopMargin(0.133); if( ic%4 == 1 || ic%4 == 2){ cdEdxPure->cd(ic)->SetRightMargin(0.133); } if( ic%4 != 1 && ic%4 != 2){ cdEdxPure->cd(ic)->SetGridx(); cdEdxPure->cd(ic)->SetGridy(); } } cdEdxPure->cd(1); f2dHistdEdxSignalPionFromLambda->Draw("colz"); cdEdxPure->cd(2); f2dHistResponsePionFromLambda->Draw("colz"); cdEdxPure->cd(3); fLowPtPionResponse->Draw(); cdEdxPure->cd(4); fMidPtPionResponse->Draw(); cdEdxPure->cd(5); f2dHistdEdxSignalProtonFromLambda->Draw("colz"); cdEdxPure->cd(6); f2dHistResponseProtonFromLambda->Draw("colz"); cdEdxPure->cd(7); fLowPtProtonResponse->Draw(); cdEdxPure->cd(8); fMidPtProtonResponse->Draw(); //Write explanations on canvases cdEdxPure->cd(1); Tl.DrawLatex(.25, .9277, "#pi^{-} from #Lambda: TPC Signal"); cdEdxPure->cd(2); Tl.DrawLatex(.15, .9277, "#pi^{-} from #Lambda: AliPIDResponse Value"); cdEdxPure->cd(3); Tl.DrawLatex(.21, .9277, "#pi^{-} N#sigma, 0.5 < p_{T} (GeV/c) < 1.0"); cdEdxPure->cd(4); Tl.DrawLatex(.21, .9277, "#pi^{-} N#sigma, 1.5 < p_{T} (GeV/c) < 2.5"); cdEdxPure->cd(5); Tl.DrawLatex(.25, .9277, "p from #Lambda: TPC Signal"); cdEdxPure->cd(6); Tl.DrawLatex(.15, .9277, "p from #Lambda: AliPIDResponse Value"); cdEdxPure->cd(7); Tl.DrawLatex(.21, .9277, "p N#sigma, 0.5 < p_{T} (GeV/c) < 1.0"); cdEdxPure->cd(8); Tl.DrawLatex(.21, .9277, "p N#sigma, 1.5 < p_{T} (GeV/c) < 2.5"); Double_t lLowPtPeakPion = fLowPtPionResponse->GetBinCenter( fLowPtPionResponse->GetMaximumBin() ); Double_t lMidPtPeakPion = fMidPtPionResponse->GetBinCenter( fMidPtPionResponse->GetMaximumBin() ); Double_t lLowPtPeakProton = fLowPtProtonResponse->GetBinCenter( fLowPtProtonResponse->GetMaximumBin() ); Double_t lMidPtPeakProton = fMidPtProtonResponse->GetBinCenter( fMidPtProtonResponse->GetMaximumBin() ); //List Maximal Values cout<<"Maximal Value for pion from Lambda at low pt...............: " <<lLowPtPeakPion<<endl; cout<<"Maximal Value for pion from Lambda at mid pt...............: " <<lMidPtPeakPion<<endl; cout<<"Maximal Value for proton from Lambda at low pt.............: " <<lLowPtPeakProton<<endl; cout<<"Maximal Value for proton from Lambda at mid pt.............: " <<lMidPtPeakProton<<endl; if( TMath::Abs( lLowPtPeakPion ) > 0.3) cout<<"*** WARNING: Check Low Pt pion PID Response! ***"<<endl; if( TMath::Abs( lMidPtPeakPion ) > 0.3) cout<<"*** WARNING: Check Mid Pt pion PID Response! ***"<<endl; if( TMath::Abs( lLowPtPeakProton ) > 0.3) cout<<"*** WARNING: Check Low Pt proton PID Response! ***"<<endl; if( TMath::Abs( lMidPtPeakProton ) > 0.3) cout<<"*** WARNING: Check Mid Pt proton PID Response! ***"<<endl; TLatex Tlq; Tlq.SetNDC(); Tlq.SetTextSize(0.06); //Draw Arrows to be sure! Double_t lFractionHeight = 0.33; cdEdxPure->cd(3); TArrow *ar1 = new TArrow(lLowPtPeakPion,lFractionHeight * fLowPtPionResponse->GetMaximum(),lLowPtPeakPion,0.0, 0.008 ,"|>"); ar1->SetLineWidth(2); ar1->Draw(); if( TMath::Abs( lLowPtPeakPion ) < 0.3) { Tlq.SetTextColor(8); Tlq.DrawLatex ( 0.15,0.8, "OK!"); } else { Tlq.SetTextColor(kRed); Tlq.DrawLatex ( 0.15,0.8, "Prob.! Check dEd/x!"); } cdEdxPure->cd(4); TArrow *ar2 = new TArrow(lMidPtPeakPion,lFractionHeight * fMidPtPionResponse->GetMaximum(),lLowPtPeakPion,0.0, 0.008 ,"|>"); ar2->SetLineWidth(2); ar2->Draw(); if( TMath::Abs( lMidPtPeakPion ) < 0.3) { Tlq.SetTextColor(8); Tlq.DrawLatex ( 0.15,0.8, "OK!"); } else { Tlq.SetTextColor(kRed); Tlq.DrawLatex ( 0.15,0.8, "Prob.! Check dEd/x!"); } cdEdxPure->cd(7); TArrow *ar3 = new TArrow(lLowPtPeakProton,lFractionHeight * fLowPtProtonResponse->GetMaximum(),lLowPtPeakPion,0.0, 0.008 ,"|>"); ar3->SetLineWidth(2); ar3->Draw(); if( TMath::Abs( lLowPtPeakProton ) < 0.3) { Tlq.SetTextColor(8); Tlq.DrawLatex ( 0.15,0.8, "OK!"); } else { Tlq.SetTextColor(kRed); Tlq.DrawLatex ( 0.15,0.8, "Prob.! Check dEd/x!"); } cdEdxPure->cd(8); TArrow *ar4 = new TArrow(lMidPtPeakProton,lFractionHeight * fMidPtProtonResponse->GetMaximum(),lLowPtPeakPion,0.0, 0.008 ,"|>"); ar4->SetLineWidth(2); ar4->Draw(); if( TMath::Abs( lMidPtPeakProton ) < 0.3) { Tlq.SetTextColor(8); Tlq.DrawLatex ( 0.15,0.8, "OK!"); } else { Tlq.SetTextColor(kRed); Tlq.DrawLatex ( 0.15,0.8, "Prob.! Check dEd/x!"); } if (output == "png") cdEdxPure->SaveAs("LF_QAanalysis_V0_page5.png"); else if (output == "eps") cdEdxPure->SaveAs("LF_QAanalysis_V0_page5.eps"); else if (output == "pdf") cdEdxPure->SaveAs("LF_QAanalysis_V0.pdf"); //============================================================== //============================================================== //Topological variable QA // FIXME: This is still only a rough first version. // Adjustments will be required for easy / long-term operation. TH1D *fHistTopDCAPosToPV = (TH1D*)clist->FindObject("fHistSelectedTopDCAPosToPV"); TH1D *fHistTopDCANegToPV = (TH1D*)clist->FindObject("fHistSelectedTopDCANegToPV"); TH1D *fHistTopDCAV0Daughters = (TH1D*)clist->FindObject("fHistSelectedTopDCAV0Daughters"); TH1D *fHistTopCosinePA = (TH1D*)clist->FindObject("fHistSelectedTopCosinePA"); TH1D *fHistTopV0Radius = (TH1D*)clist->FindObject("fHistSelectedTopV0Radius"); //Zoom in on selection in Cosine of pointing angle... Int_t iLowBin=-1; Int_t iLowBin2 = -1; Int_t iLowBin3 = -1; //Normalize to per-event fHistTopDCAPosToPV -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); fHistTopDCANegToPV -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); fHistTopDCAV0Daughters -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); fHistTopCosinePA -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); fHistTopV0Radius -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) ); fHistTopDCAPosToPV -> GetYaxis() -> SetTitle("Counts / Event"); fHistTopDCANegToPV -> GetYaxis() -> SetTitle("Counts / Event"); fHistTopDCAV0Daughters -> GetYaxis() -> SetTitle("Counts / Event"); fHistTopCosinePA -> GetYaxis() -> SetTitle("Counts / Event"); fHistTopV0Radius -> GetYaxis() -> SetTitle("Counts / Event"); fHistTopDCAPosToPV -> GetYaxis() -> SetTitleSize(0.05); fHistTopDCANegToPV -> GetYaxis() -> SetTitleSize(0.05); fHistTopDCAV0Daughters -> GetYaxis() -> SetTitleSize(0.05); fHistTopCosinePA -> GetYaxis() -> SetTitleSize(0.05); fHistTopV0Radius -> GetYaxis() -> SetTitleSize(0.05); fHistTopDCAPosToPV -> GetXaxis() -> SetTitleSize(0.05); fHistTopDCANegToPV -> GetXaxis() -> SetTitleSize(0.05); fHistTopDCAV0Daughters -> GetXaxis() -> SetTitleSize(0.05); fHistTopCosinePA -> GetXaxis() -> SetTitleSize(0.05); fHistTopV0Radius -> GetXaxis() -> SetTitleSize(0.05); Double_t lMinimumCosPADraw = 1.-1.25*(1.-GetXForMinValue ( fHistTopCosinePA ) ); //assumes monotonically increasing dist cout<<"Function test: "<< lMinimumCosPADraw <<endl; fHistTopCosinePA->GetXaxis()->SetRangeUser(lMinimumCosPADraw,1.001); Double_t lmin[5]; Double_t lminPrecision[5]; lmin[3] = GetXForMinValue ( fHistTopCosinePA ); lmin[4] = GetXForMinValue ( fHistTopV0Radius ); lmin[0] = GetXForMaxValue ( fHistTopDCAPosToPV ); lmin[1] = GetXForMaxValue ( fHistTopDCANegToPV ); lmin[2] = GetXForMinValue ( fHistTopDCAV0Daughters ); lminPrecision[3] = fHistTopCosinePA -> GetBinWidth(1); lminPrecision[4] = fHistTopV0Radius -> GetBinWidth(1); lminPrecision[0] = fHistTopDCAPosToPV -> GetBinWidth(1); lminPrecision[1] = fHistTopDCANegToPV -> GetBinWidth(1); lminPrecision[2] = fHistTopDCAV0Daughters -> GetBinWidth(1); cout<<"Minimum Values Found: "<<endl; cout<<"Cosine of Pointing Angle...........: "<<GetXForMinValue (fHistTopCosinePA )<<" precision = "<<lminPrecision[3]<<endl; cout<<"DCA Neg Daughter to PV.............: "<<GetXForMaxValue (fHistTopDCAPosToPV )<<" precision = "<<lminPrecision[1]<<endl; cout<<"DCA Pos Daughter to PV.............: "<<GetXForMaxValue (fHistTopDCANegToPV )<<" precision = "<<lminPrecision[0]<<endl; cout<<"DCA V0 Daughers....................: "<<GetXForMinValue (fHistTopDCAV0Daughters )<<" precision = "<<lminPrecision[2]<<endl; cout<<"V0 Decay Radius....................: "<<GetXForMinValue (fHistTopV0Radius )<<" precision = "<<lminPrecision[4]<<endl; TCanvas *cTopo = new TCanvas ("cTopo","",1200,800); cTopo->Divide(3,2); for(Int_t ic = 1; ic<7; ic++){ cTopo->cd(ic)->SetLeftMargin(0.15); cTopo->cd(ic)->SetGridx(); cTopo->cd(ic)->SetGridy(); } cTopo->cd(1); fHistTopDCAPosToPV->Draw(); cTopo->cd(2); fHistTopDCANegToPV->Draw(); cTopo->cd(3); fHistTopDCAV0Daughters->Draw(); cTopo->cd(4); fHistTopCosinePA->Draw(); cTopo->cd(5); fHistTopV0Radius->Draw(); TLatex Tlt; Tlt.SetNDC(); Tlt.SetTextSize(0.05); cTopo->cd(6); Tlt.DrawLatex(.22, .9, "Boundary Checks") ; TString lCut[5]; lCut [ 0 ] = "Min DCA Pos D. To PV (cm)"; lCut [ 1 ] = "Min DCA Neg D. To PV (cm)"; lCut [ 2 ] = "Max DCA V0 Daughters (#sigma)"; lCut [ 3 ] = "Min Cosine PA"; lCut [ 4 ] = "Min 2D Decay Radius (cm)"; TString lCutVal[5]; TString lCutValPrec[5]; Tlt.SetTextSize(0.04); Tlt.SetTextFont(42); Tlt.DrawLatex(.01, .80, "Topological Var.") ; Tlt.DrawLatex(.6, .80, "Value") ; Tlt.DrawLatex(.75, .80, "Precision") ; for (Int_t il=0;il<5;il++){ Tlt.DrawLatex(.01,0.72-((double)il)*0.075, lCut[il].Data() ); lCutVal[il] = Form( "%.4f", lmin[il] ); Tlt.DrawLatex(.5925,0.72-((double)il)*0.075, lCutVal[il].Data() ); lCutValPrec[il] = Form( "%.4f", lminPrecision[il] ); Tlt.DrawLatex(.7675,0.72-((double)il)*0.075, lCutValPrec[il].Data() ); } Tlt.SetTextSize(0.05); Tlt.SetTextFont(42); //Try to make a wild guess... if ( TMath::Abs( lmin[0] - 0.100 ) < 2*lminPrecision[0] && TMath::Abs( lmin[1] - 0.100 ) < 2*lminPrecision[1] && TMath::Abs( lmin[2] - 1.000 ) < 2*lminPrecision[2] && TMath::Abs( lmin[3] - 0.998 ) < 2*lminPrecision[3] && TMath::Abs( lmin[4] - 0.500 ) < 2*lminPrecision[4] ){ Tlt.DrawLatex( 0.17, 0.275, "#bf{Autodetect Interpretation}: "); Tlt.DrawLatex( 0.1, 0.2, "Typical #bf{Pb-Pb} Reconstruction Cuts"); } if ( TMath::Abs( lmin[0] - 0.020 ) < 2*lminPrecision[0] && TMath::Abs( lmin[1] - 0.020 ) < 2*lminPrecision[1] && TMath::Abs( lmin[2] - 1.500 ) < 2*lminPrecision[2] && TMath::Abs( lmin[3] - 0.98 ) < 2*lminPrecision[3] && TMath::Abs( lmin[4] - 0.500 ) < 2*lminPrecision[4] ){ Tlt.DrawLatex( 0.15, 0.29, "#bf{Autodetect Interpretation}: "); Tlt.DrawLatex( 0.1, 0.2, "Typical pp Reconstruction Cuts"); //To be checked } if (output == "png") cTopo->SaveAs("LF_QAanalysis_V0_page6.png"); else if (output == "eps") cTopo->SaveAs("LF_QAanalysis_V0_page6.eps"); else if (output == "pdf") cTopo->SaveAs("LF_QAanalysis_V0.pdf)"); }
TCanvas* example_plot( int iPeriod, int iPos, bool t, int nt,double miPt, double maPt,string c,string hname, string lbl1, string lbl2,string lbl3 ) { // if( iPos==0 ) relPosX = 0.12; int W = 800; int H = 600; int H_ref = 600; int W_ref = 800; // references for T, B, L, R float T = 0.08*H_ref; float B = 0.12*H_ref; float L = 0.12*W_ref; float R = 0.04*W_ref; TString canvName = "FigMass_"; canvName += W; canvName += "_"; canvName += H; canvName += "_"; canvName += iPeriod; if( writeExtraText ) canvName += "_prelim"; if( iPos%10==0 ) canvName += "_out"; else if( iPos%10==1 ) canvName += "_left"; else if( iPos%10==2 ) canvName += "_center"; else if( iPos%10==3 ) canvName += "_right"; TCanvas* canv = new TCanvas(canvName,canvName,50,50,W,H); canv->SetFillColor(0); canv->SetBorderMode(0); canv->SetFrameFillStyle(0); canv->SetFrameBorderMode(0); canv->SetLeftMargin( L/W ); canv->SetRightMargin( R/W ); canv->SetTopMargin( T/H ); canv->SetBottomMargin( B/H ); canv->SetTickx(0); canv->SetTicky(0); fit(4,t,nt,miPt,maPt,c); // fit(4,1,32,"Mass>8.6 && Mass<11.0 && TMath::Abs(EtaMuP)<1.2 && TMath::Abs(EtaMuM)<1.2 && Rapidity<1.2 "); { TLatex latex; int n_ = 3; float x1_l = 0.95; float y1_l = 0.70; float dx_l = 0.37; float dy_l = 0.23; float x0_l = x1_l-dx_l; float y0_l = y1_l-dy_l; TPad* legend = new TPad("legend_0","legend_0",x0_l,y0_l,x1_l, y1_l ); // legend->SetFillColor( kGray ); legend->Draw(); legend->cd(); float gap_ = 1./(n_+1); float bwx_ = 0.12; x_l[0] = 1.2*bwx_; y_l[0] = 1-gap_; latex.SetTextFont(42); latex.SetTextAngle(0); latex.SetTextColor(kBlack); latex.SetTextSize(0.20); latex.SetTextAlign(12); float xx_ = x_l[0]; float yy_ = y_l[0]; //latex.DrawLatex(xx_+1.*bwx_,yy_,"#sigma = 26.5 #pm 2.2 MeV"); //latex.DrawLatex(xx_+1.*bwx_,yy_,"#sigma = 13 MeV"); // latex.DrawLatex(xx_+0.5*bwx_,yy_,"#sqrt{f_{1}#sigma_{1}^{2}+f_{2}#sigma_{2}^{2}} = 110 MeV"); latex.DrawLatex(xx_+0.5*bwx_,yy_,lbl1.c_str()); yy_ -= gap_; // latex.DrawLatex(xx_+0.5*bwx_,yy_,"p_{T}^{#mu^{+}#mu^{-}} > 13 GeV"); latex.DrawLatex(xx_+0.5*bwx_,yy_,lbl2.c_str()); yy_ -= gap_; latex.DrawLatex(xx_+0.5*bwx_,yy_,lbl3.c_str()); // latex.DrawLatex(xx_+1.*bwx_,yy_,"|#eta_{#mu}| < 0.5"); canv->cd(); } // writing the lumi information and the CMS "logo" CMS_lumi( canv, iPeriod, iPos ); canv->Update(); canv->RedrawAxis(); canv->GetFrame()->Draw(); string hn="Plots/"+hname+".pdf"; string hnpng ="Plots/"+hname+".png"; canv->SaveAs(hn.c_str()); canv->SaveAs(hnpng.c_str()); // canv->Print(hname+".png",".png"); return canv; }
void TestSPD(const TString& which, Double_t nVar=2) { TFile* file = TFile::Open("forward.root", "READ"); if (!file) return; Bool_t spd = which.EqualTo("spd", TString::kIgnoreCase); TList* l = 0; if (spd) l = static_cast<TList*>(file->Get("CentralSums")); else l = static_cast<TList*>(file->Get("ForwardSums")); if (!l) { Warning("", "%sSums not found", spd ? "Central" : "Forward"); return; } TList* ei = static_cast<TList*>(l->FindObject("fmdEventInspector")); if (!l) { Warning("", "fmdEventInspector not found"); return; } TObject* run = ei->FindObject("runNo"); if (!run) Warning("", "No run number found"); ULong_t runNo = run ? run->GetUniqueID() : 0; TH2* h = 0; if (spd) h = static_cast<TH2*>(l->FindObject("nClusterVsnTracklet")); else { TList* den = static_cast<TList*>(l->FindObject("fmdDensityCalculator")); if (!den) { Error("", "fmdDensityCalculator not found"); return; } TList* rng = static_cast<TList*>(den->FindObject(which)); if (!rng) { Error("", "%s not found", which.Data()); return; } h = static_cast<TH2*>(rng->FindObject("elossVsPoisson")); } if (!h) { Warning("", "%s not found", spd ? nClusterVsnTracklet : "elossVsPoisson"); return; } gStyle->SetOptFit(1111); gStyle->SetOptStat(0); TCanvas* c = new TCanvas("c", Form("Run %u", runNo)); c->Divide(2,2); TVirtualPad* p = c->cd(1); if (spd) { p->SetLogx(); p->SetLogy(); } p->SetLogz(); h->Draw("colz"); TObjArray* fits = new TObjArray; h->FitSlicesY(0, 1, -1, 0, "QN", fits); TF1* mean = new TF1("mean", "pol1"); TF1* var = new TF1("var", "pol1"); // mean->FixParameter(0, 0); // var->FixParameter(0, 0); for (Int_t i = 0; i < 3; i++) { p = c->cd(2+i); if (spd) { p->SetLogx(); p->SetLogy(); } TH1* hh = static_cast<TH1*>(fits->At(i)); hh->Draw(); if (i == 0) continue; hh->Fit((i == 1? mean : var), "+Q"); } TGraphErrors* g1 = new TGraphErrors(h->GetNbinsX()); g1->SetFillColor(kBlue-10); g1->SetFillStyle(3001); g1->SetLineStyle(1); TGraph* u1 = new TGraph(h->GetNbinsX()); TGraph* l1 = new TGraph(h->GetNbinsX()); u1->SetLineColor(kBlue+1); l1->SetLineColor(kBlue+1); u1->SetName("u1"); l1->SetName("l1"); TGraphErrors* g2 = new TGraphErrors(h->GetNbinsX()); g2->SetFillColor(kRed-10); g2->SetFillStyle(3001); g2->SetLineStyle(2); TGraph* u2 = new TGraph(h->GetNbinsX()); TGraph* l2 = new TGraph(h->GetNbinsX()); u2->SetLineColor(kRed+1); l2->SetLineColor(kRed+1); u2->SetName("u2"); l2->SetName("l2"); for (Int_t i = 1; i <= h->GetNbinsX(); i++) { Double_t x = hh->GetXaxis()->GetBinCenter(i); Double_t y = mean->Eval(x); Double_t e = var->Eval(y); Double_t e1 = nVar * e; if (spd) e1 *= TMath::Log10(e); // Printf("%10e -> %10e +/- %10e", x, y, ee); g1->SetPoint(i-1, x, y); g1->SetPointError(i-1, 0, e1); u1->SetPoint(i-1, x, y+e1); l1->SetPoint(i-1, x, y-e1); // Printf("%3d: %f -> %f +/- %f", i, x, y, ee); Double_t e2 = nVar*0.05*x; g2->SetPoint(i-1, x, x); g2->SetPointError(i-1, 0, e2); u2->SetPoint(i-1, x, x+e2); l2->SetPoint(i-1, x, x-e2); } p = c->cd(1); c->Clear(); c->cd(); c->SetLogz(); h->Draw("colz"); g1->Draw("3 same"); u1->Draw("l same"); l1->Draw("l same"); g2->Draw("3 same"); u2->Draw("l same"); l2->Draw("l same"); Double_t ly = 0.9; Double_t dy = 0.06; TLatex* ltx = new TLatex(0.15, ly, Form("#LTy#GT = %f + %f x", mean->GetParameter(0), mean->GetParameter(1))); ltx->SetNDC(); ltx->SetTextSize(dy); ltx->SetTextAlign(13); ltx->Draw(); ly -= dy + 0.01; ltx->DrawLatex(0.15, ly, Form("#sigma_{y} = %f + %f x", var->GetParameter(0), var->GetParameter(1))); ly -= dy + 0.01; ltx->DrawLatex(0.15, ly, Form("#delta = %f #sigma %s", nVar, (spd ? "log_{10}(#sigma" : ""))); }
//void pi0_mfitpeak(char *FileName, char *HistName, Int_t etapi0flag) void pi0_mfitpeak(TH1F *mh1, Int_t etapi0flag, float xmin, float xmax, int npol,float res[],int posFlag, const char *dirName, const char *histName, float text_x, float text_y, const char *texName) { TGaxis::SetMaxDigits(3); // TVirtualFitter::SetDefaultFitter("Minuit"); // This script attempts to fit any pi0 peak so that the freaking fit function would converge // currently background is fitted to a pol4 function and the peak by a gaussian; // results are not very nice // usage .x pi0_mfitpeak.C++ ("pi0calib.root","minv_spb") // or eg. .x pi0_mfitpeak.C ("../pi0anal/pi0ana_punorm.root","minv_spb",0) gROOT->Reset(); // gStyle->SetOptFit(); // gStyle->SetOptFit(0); // gStyle->SetOptStat(0); // gStyle->SetOptTitle(0); Bool_t NOTE=1; if(NOTE) gStyle->SetCanvasBorderMode(0); gStyle->SetPadTopMargin(0.08); gStyle->SetPadBottomMargin(0.12); gStyle->SetPadLeftMargin(0.15); gStyle->SetPadRightMargin(0.08); mh1->GetXaxis()->SetRangeUser(xmin,xmax); Int_t highx=500; TCanvas *c2 = new TCanvas("c2","",200,10,highx,500); // cout<<FileName<<" "<<HistName<<endl; // TFile f(FileName); // TH1F *mh1 = (TH1F*) f.Get(HistName); mh1->SetMarkerStyle(20); mh1->SetMarkerSize(1.); mh1->SetStats(0); // 1/0 to set the stat box mh1->GetXaxis()->SetTitle("Invariant Mass of Photon Pairs (GeV/c^{2})"); float binwidth = mh1->GetBinWidth(1); char *ytitle = new char[100]; sprintf(ytitle,"Photon Pairs / %4.3f GeV/c^{2}",binwidth); mh1->GetYaxis()->SetTitle(ytitle); mh1->GetXaxis()->SetTitleSize(0.055); mh1->GetYaxis()->SetTitleSize(0.055); mh1->GetXaxis()->SetLabelSize(0.045); mh1->GetYaxis()->SetLabelSize(0.045); mh1->GetXaxis()->SetTitleOffset(0.90); mh1->GetXaxis()->CenterTitle(); mh1->GetYaxis()->SetTitleOffset(1.32); // First work with the histogram and find the peak and fit ranges TAxis *xaxis = mh1->GetXaxis(); Float_t binsiz= xaxis->GetBinCenter(3) - xaxis->GetBinCenter(2); Int_t nbins = xaxis->GetNbins(); Float_t nevtperbin0[10000]; Float_t errorbin0[10000]; Float_t nevttot; Float_t maxbin=0; Int_t nmaxbin=0, nminbord=0, nmaxbord=nbins; for (Int_t nn=1; nn <= nbins; nn++) { nevtperbin0[nn] = mh1->GetBinContent(nn); if(nevtperbin0[nn] > maxbin) { maxbin=nevtperbin0[nn]; nmaxbin=nn; } errorbin0[nn] = mh1->GetBinError(nn); nevttot+=nevtperbin0[nn]; if(nevtperbin0[nn] > 0 && nminbord == 0) nminbord=nn; if(nevtperbin0[nn] == 0 && (nn > nminbord +10) && nmaxbord==0 && nminbord > 0) nmaxbord=nn; } cout<<"Minbordl "<<nminbord<<" with events: "<<nevtperbin0[nminbord]<<endl; cout<<"Maxbordl "<<nmaxbord<<" with events: "<<nevtperbin0[nmaxbord]<<endl; nminbord+=0; nmaxbord-=0; Int_t nmin0=nminbord; while(nevtperbin0[nminbord] < nevtperbin0[nmaxbin]*0.025) nminbord++; while(nevtperbin0[nmaxbord] < nevtperbin0[nmaxbin]*0.025) nmaxbord--; // the above was just to get the info and low/high bins // Set the fit range ! This is for total fit ! Float_t fitl=xmin; float fith=xmax; // Float_t fitl=0.07, fith=0.2;// this works better for pileup // Float_t fitl=0.08, fith=0.18;// this works even better for pileup // if(etapi0flag == 1) // { // fitl=0.35; fith=0.75; //} // if(fitl < xaxis->GetBinCenter(nmin0)) fitl = xaxis->GetBinCenter(nmin0); //if(fith > xaxis->GetBinCenter(nmaxbord)) fith = xaxis->GetBinCenter(nmaxbord); cout<<" fit range "<<fitl<<" -- "<<fith<<endl; cout <<"Bin size "<<binsiz<<endl; cout<<"Total events "<<nevttot<<endl; cout<<"MaxBin "<<nmaxbin<<" with events: "<<nevtperbin0[nmaxbin]<<endl; cout<<"Minbord "<<nminbord<<" with events: "<<nevtperbin0[nminbord]<<endl; cout<<"Maxbord "<<nmaxbord<<" with events: "<<nevtperbin0[nmaxbord]<<endl; mh1->DrawCopy("sep"); Float_t lowgauss=0.135-4.*0.010; Float_t highgauss=0.135+4.*0.010; if(etapi0flag == 1) { lowgauss=0.55-5.*0.025; highgauss=0.55+5.*0.025; } Int_t nlowgauss=Int_t((lowgauss-xaxis->GetBinCenter(1))/Float_t(binsiz)+0.5); Int_t nhighgauss=Int_t((highgauss-xaxis->GetBinCenter(1))/Float_t(binsiz)+0.5); cout <<xaxis->GetBinCenter(nlowgauss)<<" "<<xaxis->GetBinCenter(nhighgauss)<<endl; // now make the "background" histogram and fit it with p4 Float_t lowvalgauss=nevtperbin0[nlowgauss]; Float_t increm=(nevtperbin0[nhighgauss]-nevtperbin0[nlowgauss])/Float_t(nhighgauss-nlowgauss); TH1F *hbkg = (TH1F*)mh1->Clone(); hbkg->SetName("bkg_clone"); for (Int_t nn=nlowgauss; nn<=nhighgauss; nn++) { hbkg->SetBinContent(nn,Float_t(lowvalgauss+(nn-nlowgauss)*increm)); hbkg->SetBinError(nn,sqrt(lowvalgauss+(nn-nlowgauss)*increm)); } hbkg->DrawCopy("samesep"); // break; // Now define the "gaussian" histogram TH1F *hgauss = (TH1F*)mh1->Clone(); hgauss->SetName("gauss_clone"); hgauss->Sumw2(); hgauss->Add(mh1,hbkg,1,-1); // if errors are independent Add needs to be used ! for (Int_t nn=1; nn <= nbins; nn++) { if(hgauss->GetBinContent(nn) < 0.) hgauss->SetBinContent(nn,0.001*nevtperbin0[nmaxbin]); hgauss->SetBinError(nn,sqrt(hgauss->GetBinContent(nn))); } // Declare function with wich to fit TF1 *g1 = new TF1("g1","gaus",lowgauss,highgauss); hgauss->Fit(g1,"R0"); hgauss->DrawCopy("sep"); g1->Draw("same"); // break; char *polff = new char[20]; sprintf(polff,"pol%d",npol); TF1 *p4bkg; if(etapi0flag != 1) p4bkg = new TF1("pm2",polff, xaxis->GetBinCenter(nminbord),xaxis->GetBinCenter(nmaxbord)); else p4bkg = new TF1("pm2",polff, 0.35,0.75); hbkg->Fit(p4bkg,"R0"); hbkg->DrawCopy("sep"); p4bkg->SetLineStyle(kDashed); p4bkg->Draw("same"); // break; Double_t par[20],parf[20],errparf[20]; g1->GetParameters(&par[0]); p4bkg->GetParameters(&par[3]); char *totff = new char[20]; sprintf(totff,"gaus(0)+pol%d(3)",npol); TF1 *total = new TF1("total",totff,fitl,fith); TF1 *p4bkgfin = new TF1("pm2",polff,fitl,fith); total->SetParameters(par); if(etapi0flag==0){ total->SetParLimits(1,0.10,0.15); total->SetParLimits(2,0.135*0.06,0.135*0.3); }else{ total->SetParLimits(1,0.35,0.65); } // total->FixParameter(1,1.21340e-01); // total->FixParameter(2,2.69780e-02); mh1->Fit(total,"R0"); cout<<" yield.. "<< total->GetParameter(0) <<"+/- " << total->GetParError(0)<<endl; total->GetParameters(parf); for( Int_t nn=0; nn < 3+npol+1; nn++) errparf[nn]=total->GetParError(nn); g1->SetParameters(&parf[0]); p4bkgfin->SetParameters(&parf[3]); cout <<" Piz Mass = "<<parf[1]*1000.<<" +- "<<errparf[1]*1000.<< " Sigma ="<<parf[2]*1000.<<" +- "<<errparf[2]*1000.<<endl; cout << " Sigma Rel. = "<< parf[2]/parf[1]<<" +- " << errparf[2]/parf[1] <<endl; Float_t int_min=parf[1]-3.*parf[2]; Float_t int_max=parf[1]+3.*parf[2]; Float_t sig_peak=g1->Integral(int_min,int_max)/binsiz; Float_t bkgd_peak=p4bkgfin->Integral(int_min,int_max)/binsiz; cout<<" In +-3. sigma window: Signal="<<sig_peak<<" Bkgd="<<bkgd_peak<<endl; Float_t SB=sig_peak/bkgd_peak; Float_t SBerr=SB*(sqrt(1./sig_peak+1./bkgd_peak)); cout<<" Signal/Bkgd "<<SB<<" +- "<<SBerr<<endl; int_min=parf[1]-2.*parf[2]; int_max=parf[1]+2.*parf[2]; sig_peak=g1->Integral(int_min,int_max)/binsiz; bkgd_peak=p4bkgfin->Integral(int_min,int_max)/binsiz; cout<<" In +-2.sigma window: Signal="<<sig_peak<<" Bkgd="<<bkgd_peak<<endl; SB=sig_peak/bkgd_peak; SBerr=SB*(sqrt(1./sig_peak+1./bkgd_peak)); cout<<" Signal/Bkgd "<<SB<<" +- "<<SBerr<<endl; float S = sig_peak; float B = bkgd_peak; int_min=parf[1]-20.*parf[2]; int_max=parf[1]+20.*parf[2]; float S_all = g1->Integral(int_min,int_max)/binsiz; float test_sall = parf[0] * parf[2] * sqrt(acos(-1)) / binsiz; cout<<"signal all: "<< S_all << " "<< test_sall <<endl; float Serr_all = errparf[0]/ parf[0] * S_all; res[0] = S_all; res[1] = Serr_all; res[2] = parf[1]; res[3] = errparf[1]; res[4] = parf[2]; res[5] = errparf[2]; res[6] = SB; res[7] = SBerr; total->SetLineWidth(3); total->SetLineColor(kBlue); p4bkgfin->SetLineWidth(3); p4bkgfin->SetLineColor(kRed); mh1->DrawCopy("sep"); // total->SetRange(0.07,0.185); // p4bkgfin->SetRange(0.07,0.185); total->Draw("same"); p4bkgfin->SetLineStyle(kDashed); p4bkgfin->Draw("same"); TLatex l; // l.SetTextSize(0.06); l.SetTextSize(0.05); l.SetTextColor(1); l.SetNDC(); float sigma = parf[2]/ parf[1]*100; float sigmaerr = errparf[2]/ parf[1]*100; char *sigma_name = new char[50]; if(sigmaerr>0.005) sprintf(sigma_name,"#sigma = %3.2f #pm %3.2f %% ",sigma,sigmaerr); else sprintf(sigma_name,"#sigma = %3.2f %% ",sigma); if(posFlag==1){ l.DrawLatex(0.54,0.75,sigma_name); }else if( posFlag==2){ l.DrawLatex(0.54,0.3,sigma_name); } // sprintf(sigma_name,"S/B = %3.2f #pm %3.2f ",SB,SBerr); // sprintf(sigma_name,"S = %2.1f #pm %2.1f",S_all,Serr_all); // // l.DrawLatex(0.5,0.5,sigma_name); sprintf(sigma_name,"M = %3.1f #pm %3.1f MeV",parf[1]*1000.,errparf[1]*1000); if(posFlag==1){ l.DrawLatex(0.54,0.82,sigma_name); }else if( posFlag==2){ l.DrawLatex(0.54,0.37,sigma_name); } ///l.DrawLatex(0.169,470.,"d)"); c2->Modified(); c2->Update(); // c2->SaveAs("nice_pi0.gif"); if( text_x >0 && text_y >0){ TLatex * tex = new TLatex(text_x, text_y, texName); tex->SetNDC(); tex->SetTextSize(0.06); tex->SetLineWidth(2); tex->Draw(); } char *filename = new char[1000]; sprintf(filename,"%s/%s.gif",dirName,histName); c2->Print(filename); sprintf(filename,"%s/%s.C",dirName,histName); c2->Print(filename); // .x pi0_mfitpeak.C ("pi0ana_508030.root","minv_spb",0) // .x pi0_mfitpeak.C ("pi0ana_npu.root","minv_bkg",0) // .x pi0_mfitpeak.C ("pi0ana_punormv2.root","minv_spb",0) }
void latex4() { TCanvas *c1 = new TCanvas("greek","greek",600,700); TLatex l; l.SetTextSize(0.03); // Draw the columns titles l.SetTextAlign(22); l.DrawLatex(0.165, 0.95, "Lower case"); l.DrawLatex(0.495, 0.95, "Upper case"); l.DrawLatex(0.825, 0.95, "Variations"); // Draw the lower case letters l.SetTextAlign(12); float y, x1, x2; y = 0.90; x1 = 0.07; x2 = x1+0.2; l.DrawLatex(x1, y, "alpha : ") ; l.DrawLatex(x2, y, "#alpha"); y -= 0.0375 ; l.DrawLatex(x1, y, "beta : ") ; l.DrawLatex(x2, y, "#beta"); y -= 0.0375 ; l.DrawLatex(x1, y, "gamma : ") ; l.DrawLatex(x2, y, "#gamma"); y -= 0.0375 ; l.DrawLatex(x1, y, "delta : ") ; l.DrawLatex(x2, y, "#delta"); y -= 0.0375 ; l.DrawLatex(x1, y, "epsilon : ") ; l.DrawLatex(x2, y, "#epsilon"); y -= 0.0375 ; l.DrawLatex(x1, y, "zeta : ") ; l.DrawLatex(x2, y, "#zeta"); y -= 0.0375 ; l.DrawLatex(x1, y, "eta : ") ; l.DrawLatex(x2, y, "#eta"); y -= 0.0375 ; l.DrawLatex(x1, y, "theta : ") ; l.DrawLatex(x2, y, "#theta"); y -= 0.0375 ; l.DrawLatex(x1, y, "iota : ") ; l.DrawLatex(x2, y, "#iota"); y -= 0.0375 ; l.DrawLatex(x1, y, "kappa : ") ; l.DrawLatex(x2, y, "#kappa"); y -= 0.0375 ; l.DrawLatex(x1, y, "lambda : ") ; l.DrawLatex(x2, y, "#lambda"); y -= 0.0375 ; l.DrawLatex(x1, y, "mu : ") ; l.DrawLatex(x2, y, "#mu"); y -= 0.0375 ; l.DrawLatex(x1, y, "nu : ") ; l.DrawLatex(x2, y, "#nu"); y -= 0.0375 ; l.DrawLatex(x1, y, "xi : ") ; l.DrawLatex(x2, y, "#xi"); y -= 0.0375 ; l.DrawLatex(x1, y, "omicron : ") ; l.DrawLatex(x2, y, "#omicron"); y -= 0.0375 ; l.DrawLatex(x1, y, "pi : ") ; l.DrawLatex(x2, y, "#pi"); y -= 0.0375 ; l.DrawLatex(x1, y, "rho : ") ; l.DrawLatex(x2, y, "#rho"); y -= 0.0375 ; l.DrawLatex(x1, y, "sigma : ") ; l.DrawLatex(x2, y, "#sigma"); y -= 0.0375 ; l.DrawLatex(x1, y, "tau : ") ; l.DrawLatex(x2, y, "#tau"); y -= 0.0375 ; l.DrawLatex(x1, y, "upsilon : ") ; l.DrawLatex(x2, y, "#upsilon"); y -= 0.0375 ; l.DrawLatex(x1, y, "phi : ") ; l.DrawLatex(x2, y, "#phi"); y -= 0.0375 ; l.DrawLatex(x1, y, "chi : ") ; l.DrawLatex(x2, y, "#chi"); y -= 0.0375 ; l.DrawLatex(x1, y, "psi : ") ; l.DrawLatex(x2, y, "#psi"); y -= 0.0375 ; l.DrawLatex(x1, y, "omega : ") ; l.DrawLatex(x2, y, "#omega"); // Draw the upper case letters y = 0.90; x1 = 0.40; x2 = x1+0.2; l.DrawLatex(x1, y, "Alpha : ") ; l.DrawLatex(x2, y, "#Alpha"); y -= 0.0375 ; l.DrawLatex(x1, y, "Beta : ") ; l.DrawLatex(x2, y, "#Beta"); y -= 0.0375 ; l.DrawLatex(x1, y, "Gamma : ") ; l.DrawLatex(x2, y, "#Gamma"); y -= 0.0375 ; l.DrawLatex(x1, y, "Delta : ") ; l.DrawLatex(x2, y, "#Delta"); y -= 0.0375 ; l.DrawLatex(x1, y, "Epsilon : ") ; l.DrawLatex(x2, y, "#Epsilon"); y -= 0.0375 ; l.DrawLatex(x1, y, "Zeta : ") ; l.DrawLatex(x2, y, "#Zeta"); y -= 0.0375 ; l.DrawLatex(x1, y, "Eta : ") ; l.DrawLatex(x2, y, "#Eta"); y -= 0.0375 ; l.DrawLatex(x1, y, "Theta : ") ; l.DrawLatex(x2, y, "#Theta"); y -= 0.0375 ; l.DrawLatex(x1, y, "Iota : ") ; l.DrawLatex(x2, y, "#Iota"); y -= 0.0375 ; l.DrawLatex(x1, y, "Kappa : ") ; l.DrawLatex(x2, y, "#Kappa"); y -= 0.0375 ; l.DrawLatex(x1, y, "Lambda : ") ; l.DrawLatex(x2, y, "#Lambda"); y -= 0.0375 ; l.DrawLatex(x1, y, "Mu : ") ; l.DrawLatex(x2, y, "#Mu"); y -= 0.0375 ; l.DrawLatex(x1, y, "Nu : ") ; l.DrawLatex(x2, y, "#Nu"); y -= 0.0375 ; l.DrawLatex(x1, y, "Xi : ") ; l.DrawLatex(x2, y, "#Xi"); y -= 0.0375 ; l.DrawLatex(x1, y, "Omicron : ") ; l.DrawLatex(x2, y, "#Omicron"); y -= 0.0375 ; l.DrawLatex(x1, y, "Pi : ") ; l.DrawLatex(x2, y, "#Pi"); y -= 0.0375 ; l.DrawLatex(x1, y, "Rho : ") ; l.DrawLatex(x2, y, "#Rho"); y -= 0.0375 ; l.DrawLatex(x1, y, "Sigma : ") ; l.DrawLatex(x2, y, "#Sigma"); y -= 0.0375 ; l.DrawLatex(x1, y, "Tau : ") ; l.DrawLatex(x2, y, "#Tau"); y -= 0.0375 ; l.DrawLatex(x1, y, "Upsilon : ") ; l.DrawLatex(x2, y, "#Upsilon"); y -= 0.0375 ; l.DrawLatex(x1, y, "Phi : ") ; l.DrawLatex(x2, y, "#Phi"); y -= 0.0375 ; l.DrawLatex(x1, y, "Chi : ") ; l.DrawLatex(x2, y, "#Chi"); y -= 0.0375 ; l.DrawLatex(x1, y, "Psi : ") ; l.DrawLatex(x2, y, "#Psi"); y -= 0.0375 ; l.DrawLatex(x1, y, "Omega : ") ; l.DrawLatex(x2, y, "#Omega"); // Draw the variations x1 = 0.73; x2 = x1+0.2; y = 0.7500 ; l.DrawLatex(x1, y, "varepsilon : ") ; l.DrawLatex(x2, y, "#varepsilon"); y = 0.6375 ; l.DrawLatex(x1, y, "vartheta : ") ; l.DrawLatex(x2, y, "#vartheta"); y = 0.2625 ; l.DrawLatex(x1, y, "varsigma : ") ; l.DrawLatex(x2, y, "#varsigma"); y = 0.1875 ; l.DrawLatex(x1, y, "varUpsilon : ") ; l.DrawLatex(x2, y, "#varUpsilon"); y = 0.1500 ; l.DrawLatex(x1, y, "varphi : ") ; l.DrawLatex(x2, y, "#varphi"); y = 0.0375 ; l.DrawLatex(x1, y, "varomega : ") ; l.DrawLatex(x2, y, "#varomega"); // Save the picture in various formats c1->Print("greek.ps"); c1->Print("greek.gif"); c1->Print("greek.pdf"); c1->Print("greek.svg"); }
void spectra_mw(const char *prefix = "pt/PhiNsigma_KTPCnsig30_STD2010_00_DEFAULT_00") { TGraphErrors *g = ReadMWGraph(Form("%s/mass", prefix), 1); g->Draw("ACP"); TLatex latex; latex.SetTextFont(42); latex.SetTextAlign(12); latex.SetTextSize(0.03); latex.SetTextColor(kBlue+1); latex.DrawLatex(1.2, 1.01877, "MC generated"); latex.SetTextColor(kGreen+1); latex.DrawLatex(1.2, 1.01877-0.00015, "MC reconstructed"); latex.SetTextColor(kRed+1); latex.DrawLatex(1.2, 1.01877-2*0.000155, "Real data (uncorrected)"); latex.SetTextColor(kBlack); latex.DrawLatex(1.2, 1.01877-3*0.00016, "Real data (corrected)"); gPad->Print(Form("%s.pdf", g->GetName())); gPad->Clear(); gPad->SetLogy(0); TGraphErrors *g = ReadMWGraph(Form("%s/mass", prefix), 3); g->Draw("AP"); latex.SetTextAlign(22); latex.SetTextSize(0.04); latex.SetTextColor(kBlack); latex.DrawLatex(2.0, 1.0207, "pp @ #sqrt{s} = 2.76 TeV"); latex.DrawLatex(2.0, 1.0205, "TPC 3.0 #sigma"); latex.DrawLatex(2.0, 1.0202, "#phi #rightarrow K^{ +} K^{ -}"); latex.SetTextSize(0.035); latex.DrawLatex(1.7, 1.0182, "uncertainties: stat. (bars) & syst. (boxes)"); gPad->Print(Form("%s.pdf", g->GetName())); gPad->Clear(); TGraphErrors *g = ReadMWGraph(Form("%s/width", prefix), 2); g->Draw("AP"); TLatex latex; latex.SetTextAlign(22); latex.SetTextSize(0.04); latex.SetTextColor(kBlack); latex.DrawLatex(1.7, 0.0090, "pp @ #sqrt{s} = 2.76 TeV"); latex.DrawLatex(1.7, 0.0085, "TPC 3.0 #sigma"); latex.DrawLatex(1.7, 0.0077, "#phi #rightarrow K^{ +} K^{ -}"); latex.SetTextSize(0.035); latex.DrawLatex(1.7, 0.0007, "uncertainties: stat. (bars) & syst. (boxes)"); gPad->Print(Form("%s.pdf", g->GetName())); // gPad->Clear(); // gPad->SetLogy(); // TGraphErrors *g = ReadPtGraphSys("pt/out.txt"); // if (!g) return; // g->Draw("AP"); // gPad->Print(Form("%s.pdf", g->GetName())); }
void fill_stack_eventcategories(TString variable_name, TString data_name, std::vector<TString> signal_names, std::vector<TString> names){ TString canvas_name=variable_name+"_stack_canvas"; CreateCanvas(canvas_name,"",900,600); TString stack_name=variable_name+"_stack"; CreateStack(stack_name,""); int Nbkg=names.size(); vector<int> colors; colors.push_back(4); colors.push_back(9); colors.push_back(5); colors.push_back(419); colors.push_back(7); if(colors.size()<Nbkg) { cout << "please specify colors" << endl; return; } TLegend *L = new TLegend(0.6,0.57,0.89,0.89); L->SetFillColor(10); L->SetLineColor(10); L->SetLineWidth(0); for(int ibkg=0; ibkg<Nbkg; ibkg++){ TString histName=variable_name+names.at(ibkg); hName[histName]->SetFillColor(colors.at(ibkg)); stackName[stack_name]->Add(hName[histName]); L->AddEntry(hName[histName], names.at(ibkg)); } TString eventspad_name="eventspad_"+variable_name; TString ratiopad_name="ratiopad_"+variable_name; TPad *events_pad = new TPad(eventspad_name,"Events",0.0,0.3,1,1); TPad *ratio_pad = new TPad(ratiopad_name,"Ratio",0,0.,1,0.3); events_pad->SetTopMargin(0.1); events_pad->SetBottomMargin(0.05); ratio_pad->SetTopMargin(0.05); ratio_pad->SetBottomMargin(0.3); CName[canvas_name]->cd(); events_pad->Draw(); ratio_pad->Draw(); events_pad->cd(); gPad->SetLogy(); hName[variable_name+data_name]->GetYaxis()->SetTitleOffset(0.65); hName[variable_name+data_name]->GetYaxis()->SetTitleSize(0.08); hName[variable_name+data_name]->GetYaxis()->SetLabelSize(0.05); hName[variable_name+data_name]->GetXaxis()->SetLabelSize(0); hName[variable_name+data_name]->GetXaxis()->SetTitleSize(0); hName[variable_name+data_name]->SetMarkerSize(0.5); hName[variable_name+data_name]->SetMarkerStyle(20); hName[variable_name+data_name]->DrawCopy("E1"); stackName[stack_name]->DrawClone("histo same"); hName[variable_name+data_name]->DrawCopy("E1 same");// draw data on top of MC and MC on top of data, so that data will always be visible TLatex txt; txt.SetNDC(kTRUE); txt.DrawLatex(0.2,0.85,"S_{T} > 300 GeV"); txt.DrawLatex(0.4,0.75,"S_{T} > 500 GeV"); txt.DrawLatex(0.65,0.42,"S_{T} > 1000 GeV"); for(int isig=0; isig<signal_names.size();isig++){ TString sigName=variable_name+signal_names.at(isig); hName[sigName]->SetLineWidth(3); hName[sigName]->SetLineStyle(kDashed); hName[sigName]->SetLineColor(1+isig); L->AddEntry(hName[sigName], signal_names.at(isig)); hName[sigName]->DrawCopy("hist same"); } L->DrawClone("same"); ratio_pad->cd(); TString dataMC=variable_name+"_RatioDataMC"; hName[dataMC]->GetYaxis()->SetTitleOffset(0.45); hName[dataMC]->GetYaxis()->SetTitleSize(0.15); hName[dataMC]->GetYaxis()->SetTitleOffset(0.45); hName[dataMC]->GetYaxis()->SetLabelSize(0.08); hName[dataMC]->GetXaxis()->SetTitleSize(0.15); hName[dataMC]->GetXaxis()->SetLabelSize(0.12); hName[dataMC]->GetXaxis()->SetTitleSize(0.15); hName[dataMC]->DrawCopy("E1"); }
/** * * * @param o * @param useWeights * @param correct * * @ingroup pwglf_forward_scripts_tests */ void TestPoisson(Double_t o=.3, bool useWeights=false, bool correct=true) { const char* load = "$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C"; if (!gROOT->GetClass("AliAODForwardMult")) { gROOT->Macro(load); gROOT->GetInterpreter()->UnloadFile(gSystem->ExpandPathName(load)); } // --- Parameters of this script ----------------------------------- Int_t nBin = 5; // Our detector matrix size Int_t nMax = TMath::Max(Int_t(nBin * nBin * o + .5)+nBin/2,nBin); Int_t nEv = 10000; // Number of events Double_t mp = o; // The 'hit' probability TH2D* base = new TH2D("base", "Basic histogram", nBin,-.5, nBin-.5, nBin, -.5, nBin-.5); base->SetXTitle("#eta"); base->SetYTitle("#varphi"); base->SetDirectory(0); base->SetOption("colz"); Int_t tN1=nMax; Double_t tMin1; Double_t tMax1; Int_t tN2=nMax*10; Double_t tMin2; Double_t tMax2=nMax; MakeIntegerAxis(tN1, tMin1, tMax1); MakeIntegerAxis(tN2, tMin2, tMax2); TH2D* corr = new TH2D("comp", "Comparison", tN1, tMin1, tMax1, tN2, tMin2, tMax2); corr->SetXTitle("Input"); corr->SetYTitle("Poisson"); corr->SetDirectory(0); corr->SetOption("colz"); corr->SetStats(0); TLine* lcorr = new TLine(0, 0, tMax2, tMax2); Int_t mm = TMath::Max(Int_t(nBin * o + .5),nBin/2); tN2=mm*10; tMax2 = mm; MakeIntegerAxis(tN2, tMin2, tMax2); Info("", "Making mean w/nbins=%d,range=[%f,%f]", tN2, tMin2, tMax2); TH2D* mean = new TH2D("mean", "Mean comparison", tN2, tMin2, tMax2, tN2, tMin2, tMax2); mean->SetXTitle("Input"); mean->SetYTitle("Poisson"); mean->SetDirectory(0); mean->SetOption("colz"); mean->SetStats(0); TLine* lmean = new TLine(tMin2, tMin2, tMax2, tMax2); TH1D* dist = new TH1D("dist", "Distribution of hits", tN1, tMin1, tMax1); dist->SetXTitle("s"); dist->SetYTitle("P(s)"); dist->SetFillColor(kRed+1); dist->SetFillStyle(3001); dist->SetDirectory(0); TH1D* diff = new TH1D("diff", "P-T", 100, -25, 25); diff->SetXTitle("Difference"); diff->SetFillColor(kRed+1); diff->SetFillStyle(3001); diff->SetYTitle("Prob"); AliPoissonCalculator* c = new AliPoissonCalculator("ignored"); c->Init(nBin ,nBin); for (Int_t i = 0; i < nEv; i++) { c->Reset(base); base->Reset(); for (Int_t iEta = 0; iEta < nBin; iEta++) { for (Int_t iPhi = 0; iPhi < nBin; iPhi++) { // Throw a die Int_t m = gRandom->Poisson(mp); dist->Fill(m); // Fill into our base histogram base->Fill(iEta, iPhi, m); // Fill into poisson calculator c->Fill(iEta, iPhi, m > 0, (useWeights ? m : 1)); } } // Calculate the result TH2D* res = c->Result(correct); // Now loop and compare Double_t mBase = 0; Double_t mPois = 0; for (Int_t iEta = 0; iEta < nBin; iEta++) { for (Int_t iPhi = 0; iPhi < nBin; iPhi++) { Double_t p = res->GetBinContent(iEta, iPhi); Double_t t = base->GetBinContent(iEta, iPhi); mBase += t; mPois += p; corr->Fill(t, p); diff->Fill(p-t); } } Int_t nn = nBin * nBin; mean->Fill(mBase / nn, mPois / nn); } TCanvas* cc = new TCanvas("c", "c", 900, 900); cc->SetFillColor(0); cc->SetFillStyle(0); cc->SetBorderMode(0); cc->SetRightMargin(0.02); cc->SetTopMargin(0.02); cc->Divide(2,2); TVirtualPad* pp = cc->cd(1); pp->SetFillColor(0); pp->SetFillStyle(0); pp->SetBorderMode(0); pp->SetRightMargin(0.15); pp->SetTopMargin(0.02); pp->SetLogz(); pp->SetGridx(); pp->SetGridy(); corr->Draw(); lcorr->Draw(); pp = cc->cd(2); pp->SetFillColor(0); pp->SetFillStyle(0); pp->SetBorderMode(0); pp->SetRightMargin(0.02); pp->SetTopMargin(0.02); #if 0 c->GetMean()->Draw(); #elif 1 pp->SetLogy(); diff->Draw(); #elif 1 c->GetOccupancy()->Draw(); #else pp->SetLogy(); dist->SetStats(0); dist->Scale(1. / dist->Integral()); dist->Draw(); TH1D* m1 = c->GetMean(); m1->Scale(1. / m1->Integral()); m1->Draw("same"); Double_t eI; Double_t ii = 100 * dist->Integral(2, 0); TLatex* ll = new TLatex(.97, .85, Form("Input #bar{m}: %5.3f", mp)); ll->SetNDC(); ll->SetTextFont(132); ll->SetTextAlign(31); ll->Draw(); ll->DrawLatex(.97, .75, Form("Result #bar{m}: %5.3f", dist->GetMean())); ll->DrawLatex(.97, .65, Form("Occupancy: #int_{1}^{#infty}P(s)ds = %6.2f%%", ii)); #endif pp = cc->cd(3); pp->SetFillColor(0); pp->SetFillStyle(0); pp->SetBorderMode(0); pp->SetRightMargin(0.15); pp->SetTopMargin(0.02); pp->SetGridx(); pp->SetGridy(); c->GetCorrection()->Draw(); pp = cc->cd(4); pp->SetFillColor(0); pp->SetFillStyle(0); pp->SetBorderMode(0); pp->SetRightMargin(0.15); pp->SetTopMargin(0.02); pp->SetLogz(); pp->SetGridx(); pp->SetGridy(); mean->Draw(); lmean->Draw(); cc->cd(); }
void fitRatio_kyo01(bool isPrompt=true, bool isPbp=true, char* dirName="8rap9pt2gev"){ gRandom->SetSeed(time(0)); gROOT->Macro("./JpsiStyle.C"); //latex box for beam, rapidity, pT info TLatex* latex = new TLatex(); latex->SetNDC(); latex->SetTextAlign(12); latex->SetTextSize(0.04); string rapArr[nRap]; for (Int_t iy=0; iy<nRap; iy++) { formRapArr(rapArrNumFB[iy+1], rapArrNumFB[iy], &rapArr[iy]); cout << iy <<"th rapArr = " << rapArr[iy] << endl; } // TFile* fin = new TFile(Form("../pPbJPsiAnalysis/2015/004_closure/DataMcReco_8rap9pt/DataMcRecoPt_isPropmt%d.root",(int)isPrompt));//in KNU TFile* fin = new TFile(Form("../004_closure/DataMcReco_%s/DataMcRecoPt_isPropmt%d.root",dirName,(int)isPrompt));//in KNU //KYO string runstring; string runstringOverlay; if(isPbp) {runstring="Pbp"; runstringOverlay="pPb";} else {runstring="pPb"; runstringOverlay="Pbp"; } TGraphAsymmErrors* gRatio[nRap]; TGraphAsymmErrors* gRatioOverlay[nRap]; for(int iy=0;iy<nRap;iy++){ gRatio[iy]=(TGraphAsymmErrors*)fin->Get(Form("gRatio_%s_%d",runstring.c_str(),iy)); gRatioOverlay[iy]=(TGraphAsymmErrors*)fin->Get(Form("gRatio_%s_%d",runstringOverlay.c_str(),iy)); gRatio[iy]->SetName(Form("gRatio_%d",iy)); gRatioOverlay[iy]->SetName(Form("gRatioOverlay_%d",iy)); } //TFile* fout= new TFile(Form("ToyGaussian_isPrompt%d_%s.root",(int)isPrompt,runstring.c_str()),"recreate"); //TFile* fout= new TFile(Form("ToyGaussian_isPrompt%d_%s_kyo01.root",(int)isPrompt,runstring.c_str()),"recreate");//KYO TFile* fout= new TFile(Form("fitRatio_isPrompt%d_%s_kyo01.root",(int)isPrompt,runstring.c_str()),"recreate");//KYO //////////////////////////////////////////////////////////// // Output gaussian parameter histograms TH1D* hWeight[nRap]; // TH1D* hWeightSigma[nRap]; for(int iy=0;iy<nRap;iy++){ // if (iy!=0) continue ; //KYO hWeight[iy]=new TH1D(Form("hWeight_%s_%d",runstring.c_str(),iy), Form("hWeight_%s_%d",runstring.c_str(),iy), nPtFine, ptFineArrNum); // hWeightSigma[iy]=new TH1D(Form("hWeightSigma_%s_%d",runstring.c_str(),iy), Form("hWeightSigma_%s_%d",runstring.c_str(),iy), nPtFine, ptFineArrNum); } #if 0 int rapiditybin[nRap],nfpt[nRap]; double mean[nRap][nPtFine],sigma[nRap][nPtFine]; TTree* toyGaus[nRap]; for(int iy=0;iy<nRap;iy++){ toyGaus[iy]=new TTree(Form("toyGaus%d",iy),Form("rapidity bin %dth",iy)); toyGaus[iy]->Branch("rapiditybin", &rapiditybin[iy]); toyGaus[iy]->Branch("nfpt", &nfpt[iy]); toyGaus[iy]->Branch("mean", mean[iy],"mean[nfpt]/D"); toyGaus[iy]->Branch("sigma", sigma[iy],"sigma[nfpt]/D"); } #endif //////////////////////////////////////////////////////////// // Fitting // TF1* fhevi= new TF1("fhevi","[0]/(exp((-x+[1])/[2] +1)+[3])+[4]",0,30); // fhevi->SetParameters(-4.795, 1.653, 0.923, 3.018, 2.369); // TF1* fexp= new TF1("fexp","[0]/(1+exp([1]*x))+[2]/x",0.0,30.0);//Prompt TF1* func[nRap]; // TCanvas* c1 = new TCanvas("c1", "", 1200,1500); // c1 -> Divide(3,3); TCanvas* c1 = new TCanvas("c1", "", 1600,800); //KYO c1 -> Divide(4,2); // KYO for(int iy=0;iy<nRap;iy++){ c1->cd(iy+1); if(iy==0 || iy==nRap-1){ func[iy] = new TF1(Form("func_%d",iy), fitHevi,0.0,30.0,5); func[iy]->SetParameters(-4.795, 1.653, 0.923, 3.018, 2.369); if(isPrompt==1 && isPbp==0 && iy==0) { // func[iy]->SetParameters(-51.7167, -0.694876, 0.491544,4.55470,12.1672); #if 1 func[iy]->FixParameter(0,-5.17167e+01 ); func[iy]->FixParameter(1,-6.94876e-01 ); //func[iy]->FixParameter(2,4.91544e-01 ); func[iy]->FixParameter(2,9.91544e-01 ); //func[iy]->FixParameter(3,4.55470e+00 ); //func[iy]->FixParameter(3,3.55470e+00 ); //func[iy]->FixParameter(4,1.11672e+01 ); #endif } else if(isPrompt==1 && isPbp==1 && iy==0) { //func[iy]->FixParameter(0,-5.17167e+01 ); func[iy]->FixParameter(1,2.06705e+00 ); func[iy]->FixParameter(2,3.72512e-01 ); func[iy]->FixParameter(3,3.11521e+00 ); //func[iy]->FixParameter(4,1.11672e+01 ); } else if (isPrompt==0 && isPbp==1 && iy==7) { func[iy]->FixParameter(0, -3.40711e+02); func[iy]->FixParameter(1, 3.20176e+00); func[iy]->FixParameter(2, 1.09760e+00); } } //else if(isPrompt==1 && isPbp==0 && iy==4){ // func[iy] = new TF1(Form("func_%d",iy), fitHevi,0.0,30.0,5); // func[iy]->SetParameters(-3.40747e+02,3.32373e+00,6.51294e-01,2.98861e+00,1.14947e+02); //} else{ func[iy] = new TF1(Form("func_%d",iy), fitHevi,0.0,30.0,5); //func[iy]->SetParameters(-3.40711e+02,-2.02319e+00,1.42753e+00,2.98897e+00,1.14958e+02); //yeonju 0509 func[iy]->SetParameters(-3.40711e+02,-5.20176e+00,1.79760e+00,2.98896e+00,1.14958e+02); //yeonju 0509 //func[iy]->SetParameters(-3.40747e+02,3.32373e+00,6.51294e-01,2.98861e+00,1.14947e+02); //yeonju //yeonju if (isPrompt==0 && iy==2) { func[iy]->FixParameter(0, -3.40711e+02); func[iy]->FixParameter(1, -5.20176e+00); func[iy]->FixParameter(2, 1.79760e+00); func[iy]->FixParameter(3, 2.98896); } else if (isPrompt==0 && iy==6) { func[iy]->FixParameter(0, -3.40711e+02); func[iy]->FixParameter(1, 3.20176e+00); func[iy]->FixParameter(2, 1.79760e+00); } //KYO if (isPrompt && iy==6) { func[iy]->FixParameter(0,-3.40743e+02); func[iy]->FixParameter(1,-2.56691e+01); func[iy]->FixParameter(2,5.14736e+00); } else if (isPrompt && (iy==2 || iy==1)) { func[iy]->FixParameter(0,-3.40743e+02); func[iy]->FixParameter(1,-1.37032e-01); func[iy]->FixParameter(2,1.19902); } /* func[iy] = new TF1(Form("func_%d",iy), fitExp,0.0,30.0,3); if(isPrompt==0 && isPbp==1 && (iy==2 || iy==3 || iy==4 || iy==5) ) func[iy]->SetParameters(-1.01556e+01,1.51712e-01,2.80282e+01); if(isPrompt==0 && isPbp==0 && (iy==2 || iy==3 || iy==4) ) func[iy]->SetParameters(-1.01556e+01,1.51712e-01,2.80282e+01); if(isPrompt==1 && isPbp==0 && (iy==3) ) func[iy]->SetParameters(-1.01556e+01,1.51712e-01,2.80282e+01); if(isPrompt==1 && isPbp==1 && (iy==3) ) func[iy]->SetParameters(-1.01556e+01,1.51712e-01,2.80282e+01); */ } //KYO for TGraphAsymmErrors only if (!isPrompt && iy==0){ func[iy]->SetParameters(-1.04829e+01,-5.38813e+00,2.10443e+00,1.74460e+00,6.89848e+02); func[iy]->FixParameter(0,-1.04829e+01); func[iy]->FixParameter(1,-5.38813e+00); func[iy]->FixParameter(2,2.10443e+00); } SetGraphStyle(gRatio[iy],2,0); SetGraphStyle(gRatioOverlay[iy],4,10); func[iy]->SetLineColor(kRed); gRatio[iy]->Fit(Form("func_%d",iy)); gRatio[iy]->Draw("AP"); gRatioOverlay[iy]->Draw("P"); //func[iy]->Draw("same"); if (iy==0){ if (isPrompt) latex->DrawLatex(0.23,0.23,"Prompt J/#psi Pbp"); else latex->DrawLatex(0.23, 0.23,"Non-prompt J/#psi Pbp"); } latex->DrawLatex(0.56,0.80,Form("%s",rapArr[iy].c_str())); dashedLine(0.,1.,25.,1.,1,1); /* for(int ifpt=0;ifpt<nPtFine;ifpt++){ int hBin = gRatio[iy]->FindBin(ptFineArrNum[ifpt+1]-0.1); double mean = func[iy]->Eval(ptFineArrNum[ifpt+1]); double sigma = gRatio[iy]->GetBinError(hBin) / mean; hWeight[iy]->SetBinContent(ifpt+1, mean); hWeight[iy]->SetBinError(ifpt+1, sigma); //cout <<"x : "<<ptFineArrNum[ifpt+1]-0.01<< ", gRatio bin : " <<hBin << ", Ratio error value : " << gRatio[iy]->GetBinError(hBin) << endl; //cout << iy+1 << "th rapidity, "<< ifpt<<"th fine ptbin, mean = "<< mean <<", sigma = "<<sigma<<endl; } */ } c1 -> Update(); for(int iy=0;iy<nRap;iy++){ cout << " **** " <<iy<< "th rap, values at min pT = " <<func[iy]->Eval(minPt[iy])<<endl; } fout->cd(); for(int iy=0;iy<nRap;iy++){ //hWeight[iy]->Write(); gRatio[iy]->Write(); func[iy]->Write(); } c1->Write(); fout->Close(); }//end of main func.
void Sigmoide(TGraphAsymmErrors* Efficiency,TGraphErrors* EfficiencyStat,OutFileRoot& out,std::string name,Reader& read) { double min=999999; double max=-99999; int lLimit=0; int uLimit=0; for (int i = 0; i < Efficiency->GetN(); i++) { double x=0.0; double y=0.0; Efficiency->GetPoint(i, x, y); if(x>max)max=x; if(x<min)min=x; double errorY = Efficiency->GetErrorYlow(i); double errorYlow_stat = EfficiencyStat->GetErrorYlow(i); double errorYhigh_stat = EfficiencyStat->GetErrorYhigh(i); double errorYhigh = sqrt(errorY/2*errorY/2+errorYhigh_stat*errorYhigh_stat); double errorYlow = sqrt(errorY/2*errorY/2 + errorYlow_stat*errorYlow_stat); Efficiency->SetPoint(i, x, y-errorY/2); Efficiency->SetPointEYhigh (i, errorYhigh); Efficiency->SetPointEYlow (i, errorYlow); if (i == 0) lLimit = x; else if (i == Efficiency->GetN()-1) uLimit = x; std::cout<<yellow << "HV = " << x << " eff = " << y-errorY/2 << " errorY = " << errorY/2 << " errorYhigh_stat = " << errorYhigh_stat << " errorYlow_stat = " << errorYlow_stat <<normal<<std::endl; } int color = 2; int marker = 20; TCanvas* c1 = new TCanvas(); c1->SetTitle((name+Efficiency->GetTitle()).c_str()); c1->SetName((name+Efficiency->GetTitle()).c_str()); TH1D* PLOTTER = new TH1D("PLOTTER", "", 1, min, max); PLOTTER->SetStats(0); std::string xLabel = "HV_{eff} (V)"; if (read.getType() == "volEff" || read.getType() == "noisevolEff") { xLabel = "Voltage_{eff} (V)"; } else if (read.getType() == "thrEff" ||read.getType() == "noisethrEff") { xLabel = "Threshod ("+unitthr(read)+")"; } else if (read.getType() == "srcEff" ||read.getType() == "noisesrcEff") { xLabel = "Attenuator"; } else if (read.getType() == "PulEff" ||read.getType() == "noisePulEff") { xLabel = "Pulse (ns)"; } std::string lName = "Sigmoid for RE11 GRPC; " + xLabel + "; Efficiency"; PLOTTER->SetTitle(lName.c_str()); PLOTTER->SetMaximum(1); PLOTTER->SetMinimum(0); PLOTTER->Draw(""); Efficiency->SetMarkerColor(color); Efficiency->SetMarkerStyle(marker); Efficiency->Draw("SAMEPE"); int HVhalf = (lLimit+uLimit)/2; //**************************************************** TF1* sigmoid = new TF1("sigmoid","[0]/(1+exp([1]*([2]-x)))",lLimit,uLimit); sigmoid->SetParName(0,"#epsilon_{max}"); sigmoid->SetParName(1,"#lambda"); sigmoid->SetParName(2,"HV_{50%}"); sigmoid->SetParameter(0,0.98); sigmoid->SetParameter(1,0.01); sigmoid->SetParameter(2,HVhalf); Efficiency->Fit(sigmoid); Efficiency->GetFunction("sigmoid")->SetLineColor(kBlue); double p1 = sigmoid->GetParameter(0); double p2 = sigmoid->GetParameter(1); double p3 = sigmoid->GetParameter(2); TLatex* ltx = new TLatex(); ltx->SetTextSize(0.04); double knee = p3 - log(1/0.95-1)/p2; TLine* lKnee = new TLine(knee, 0, knee, 1); lKnee->SetLineStyle(2); lKnee->Draw(); double WP = knee+150; double add = (uLimit-lLimit)/11.; if (uLimit-knee < 4/11.*(uLimit-lLimit)) add = -add*4; ltx->DrawLatex(knee+add, 0.22, Form("WP = %.f V", WP)); ltx->DrawLatex(knee+add, 0.15, Form("knee = %.f V", knee)); ltx->DrawLatex(knee+add, 0.08, Form("HV(50%) = %.f V", p3)); TLine* plateau = new TLine(lLimit-50, p1, uLimit+50, p1); plateau->SetLineStyle(2); plateau->Draw(); if ((knee - lLimit) < (uLimit-lLimit)*(3/11.)) add = knee + add; else add = lLimit+add; ltx->DrawLatex(add, p1+0.04, Form("plateau = %.2f", p1)); c1->Update(); out.writeObject("Sigmoid",c1); delete c1; delete ltx; delete sigmoid; delete PLOTTER; }
void Plot_2D(string filename){ //string filename = "data/scan_CH1-50_masked.root"; // string varXname = "VMM # [1-8]"; // string varYname = "CH # [1-64]"; string varXname = "Pulsed CH # [1-64]"; string varYname = "Recorded CH # [1-64]"; string varZname = "# Recorded Pulses [/100 pulsed]"; //string varZname = "#sigma(PDO) / #bar{PDO}"; // int Nx = 8; // double Xmin = 0.5; // double Xmax = 8.5; int Nx = 64; double Xmin = 0.5; double Xmax = 64.5; // int Ny = 64; // double Ymin = 0.5; // double Ymax = 64.5; int Ny = 4097; double Ymin = -0.5; double Ymax = 4096.5; /////////////////////////////////////////////////////// setstyle(0); TChain* tree = new TChain("VMM_data","VMM_data"); tree->AddFile(filename.c_str()); MMFE8Base* base = new MMFE8Base(tree); int N = tree->GetEntries(); TH2D* hist = new TH2D("hist","hist", Nx, Xmin, Xmax, Ny, Ymin, Ymax); TH2D* hist2 = new TH2D("hist2","hist2", Nx, Xmin, Xmax, Ny, Ymin, Ymax); TH2D* histN = new TH2D("histN","histN", Nx, Xmin, Xmax, Ny, Ymin, Ymax); for(int i = 0; i < N; i++){ base->GetEntry(i); if(base->VMM != 0) continue; if(base->CHword == 24) continue; if(base->Delay != 30) continue; // hist->Fill(base->CHpulse,base->CHword,base->PDO); //histN->Fill(base->CHpulse,base->CHword); histN->Fill(base->CHpulse,base->BCID); // if(base->CHpulse != 5) // continue; // base->CHpulse = base->CHword; hist->Fill(base->VMM,base->CHpulse,base->PDO); hist2->Fill(base->VMM,base->CHpulse,base->PDO*base->PDO); // if(histN->GetBinContent(base->VMM,base->CHpulse) <= 0) // histN->SetBinContent(base->VMM,base->CHpulse,base->BCID); // else // if(histN->GetBinContent(base->VMM,base->CHpulse) > base->BCID) // histN->SetBinContent(base->VMM,base->CHpulse,base->BCID); // histN->Fill(base->VMM,base->CHpulse); } for(int x = 0; x < Nx; x++){ for(int y = 0; y < Ny; y++){ double v = hist->GetBinContent(x+1,y+1); double v2 = hist2->GetBinContent(x+1,y+1); double N = histN->GetBinContent(x+1,y+1); double vbar = v/max(int(N),1); double v2bar = v2/max(int(N),1); //hist->SetBinContent(x+1,y+1,sqrt(v2bar-vbar*vbar)/vbar); hist->SetBinContent(x+1,y+1,vbar); } } TCanvas* can = new TCanvas("can","can",600,500); can->SetLeftMargin(0.15); can->SetRightMargin(0.22); can->SetBottomMargin(0.15); can->SetTopMargin(0.08); can->Draw(); can->SetGridx(); can->SetGridy(); can->cd(); hist = histN; hist->Draw("COLZ"); hist->GetXaxis()->CenterTitle(); hist->GetXaxis()->SetTitleFont(132); hist->GetXaxis()->SetTitleSize(0.06); hist->GetXaxis()->SetTitleOffset(1.06); hist->GetXaxis()->SetLabelFont(132); hist->GetXaxis()->SetLabelSize(0.05); hist->GetXaxis()->SetTitle(varXname.c_str()); hist->GetYaxis()->CenterTitle(); hist->GetYaxis()->SetTitleFont(132); hist->GetYaxis()->SetTitleSize(0.06); hist->GetYaxis()->SetTitleOffset(1.12); hist->GetYaxis()->SetLabelFont(132); hist->GetYaxis()->SetLabelSize(0.05); hist->GetYaxis()->SetTitle(varYname.c_str()); hist->GetZaxis()->CenterTitle(); hist->GetZaxis()->SetTitleFont(132); hist->GetZaxis()->SetTitleSize(0.06); hist->GetZaxis()->SetTitleOffset(1.3); hist->GetZaxis()->SetLabelFont(132); hist->GetZaxis()->SetLabelSize(0.05); hist->GetZaxis()->SetTitle(varZname.c_str()); hist->GetZaxis()->SetRangeUser(0.9*hist->GetMinimum(),1.1*hist->GetMaximum()); TLatex l; l.SetTextFont(132); l.SetNDC(); l.SetTextSize(0.05); l.SetTextFont(132); l.DrawLatex(0.5,0.943,"MMFE8 Analysis"); l.SetTextSize(0.04); l.SetTextFont(42); l.DrawLatex(0.15,0.943,"#bf{#it{ATLAS}} Internal"); l.SetTextSize(0.06); l.SetTextFont(132); l.DrawLatex(0.80,0.04, "VMM #6"); }
int main() { ic::Plot::SetHTTStyle(); std::string dir="/vols/cms04/pjd12/invcmssws/CMSSW_7_1_5/src/HiggsAnalysis/CombinedLimit/exocombcards/"; std::vector<Scan> scans; // scans.push_back({"higgsCombinefullScan.MultiDimFit.mH125.root", "Observed", 1, nullptr}); // scans.push_back({"higgsCombineexpected.MultiDimFit.mH125.root", "Exp. for SM H", 32, nullptr}); // scans.push_back({"higgsCombinenoBBBScan.MultiDimFit.mH125.root", "no bbb syst.", 38, nullptr}); scans.push_back({dir+"higgsCombineCombExp.MultiDimFit.mH125.root", "Exp. for SM H", 1, nullptr}); scans.push_back({dir+"higgsCombineCombObs.MultiDimFit.mH125.root", "Obs. for SM H", 1, nullptr}); TCanvas c1("canvas","canvas"); std::vector<TLine *> lines; TLegend *leg = new TLegend(0.65,0.75,0.9,0.9,"","brNDC"); unsigned counter = 0; for (auto & sc : scans) { TFile f1(sc.file.c_str()); TTree *t1 = dynamic_cast<TTree*>(f1.Get("limit")); double best1 = 0.0; TString res; sc.gr = new TGraph(ExtractGraph(t1, best1)); if(counter==1){ auto x1 = GetCrossings(*(sc.gr), 1.0); auto x2 = GetCrossings(*(sc.gr), 3.84); lines.push_back(new TLine(x1[0],0,x1[0],1.0)); lines.back()->SetLineColor(2); lines.back()->SetLineWidth(2); lines.push_back(new TLine(x2[0],0,x2[0],3.84)); lines.back()->SetLineColor(2); lines.back()->SetLineWidth(2); } sc.gr->SetLineColor(sc.color); sc.gr->SetLineWidth(3); sc.gr->Draw(counter ? "LSAME" : "AL"); TString leg_text = "#splitline{"+sc.label+"}{"+res+"}"; leg->AddEntry(sc.gr, leg_text, "L"); counter++; } // c1.cd(); // // g1.Print(); // g1.SetLineColor(1); // g1.SetLineWidth(2); // // g1.SetMarkerColor(7); // g1.Draw("AC"); scans[0].gr->SetMaximum(9); scans[0].gr->SetMinimum(0.); scans[0].gr->GetXaxis()->SetRangeUser(0., 0.9); scans[0].gr->GetXaxis()->SetTitle("BR_{inv}"); scans[0].gr->GetXaxis()->SetTitleOffset(1.1); scans[0].gr->GetXaxis()->SetNdivisions(1005,true); scans[0].gr->GetXaxis()->SetLabelSize(0.05); scans[0].gr->GetYaxis()->SetLabelSize(0.05); scans[0].gr->GetXaxis()->SetLabelOffset(0.02); scans[0].gr->GetYaxis()->SetLabelOffset(0.02); scans[0].gr->GetYaxis()->SetTitle("-2 #Delta ln L"); scans[0].gr->SetLineStyle(2); scans[0].gr->SetLineColor(1); leg->SetBorderSize(1); leg->SetTextFont(42); leg->SetTextSize(0.03); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(1001); leg->Draw(); lines.push_back(new TLine(0.,1,0.9,1.0)); lines.back()->SetLineColor(2); lines.push_back(new TLine(0.,3.84,0.9,3.84)); lines.back()->SetLineColor(2); // for (auto l : lines) l->Draw(); DrawCMSLogoTest(&c1,"CMS","preliminary",10); TLatex lat = TLatex(); lat.SetNDC(); lat.SetTextSize(0.04); lat.SetTextFont(42); TLatex lat2 = TLatex(); lat2.SetNDC(); lat2.SetTextSize(0.03); lat2.SetTextFont(42); lat.DrawLatex(0.2,0.73,"Combination of all"); lat.DrawLatex(0.2,0.68,"H#rightarrow inv. channels"); c1.Update(); c1.SaveAs("scan.pdf"); return 0; }
void CMS_lumi( TPad* pad, int iPeriod, int iPosX ) { bool outOfFrame = false; if( iPosX/10==0 ) { outOfFrame = true; } int alignY_=3; int alignX_=2; if( iPosX/10==0 ) alignX_=1; if( iPosX==0 ) alignX_=1; if( iPosX==0 ) alignY_=1; if( iPosX/10==1 ) alignX_=1; if( iPosX/10==2 ) alignX_=2; if( iPosX/10==3 ) alignX_=3; //if( iPosX == 0 ) relPosX = 0.12; int align_ = 10*alignX_ + alignY_; float H = pad->GetWh(); float W = pad->GetWw(); float l = pad->GetLeftMargin(); float t = pad->GetTopMargin(); float r = pad->GetRightMargin(); float b = pad->GetBottomMargin(); // float e = 0.025; pad->cd(); TString lumiText; if( iPeriod==1 ) { lumiText += "E_{#mu} = 150 GeV"; } else if ( iPeriod==2 ) { lumiText += ""; } std::cout << lumiText << endl; TLatex latex; latex.SetNDC(); latex.SetTextAngle(0); latex.SetTextColor(kBlack); float extraTextSize = extraOverCmsTextSize*cmsTextSize; latex.SetTextFont(42); latex.SetTextAlign(31); latex.SetTextSize(lumiTextSize*t); latex.DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); if( outOfFrame ) { latex.SetTextFont(cmsTextFont); latex.SetTextAlign(11); latex.SetTextSize(cmsTextSize*t); latex.DrawLatex(l,1-t+lumiTextOffset*t,cmsText); } pad->cd(); float posX_=0; if( iPosX%10<=1 ) { posX_ = l + relPosX*(1-l-r); } else if( iPosX%10==2 ) { posX_ = l + 0.5*(1-l-r); } else if( iPosX%10==3 ) { posX_ = 1-r - relPosX*(1-l-r); } float posY_ = 1-t - relPosY*(1-t-b); if( !outOfFrame ) { if( drawLogo ) { posX_ = l + 0.045*(1-l-r)*W/H; posY_ = 1-t - 0.045*(1-t-b); float xl_0 = posX_; float yl_0 = posY_ - 0.15; float xl_1 = posX_ + 0.15*H/W; float yl_1 = posY_; TASImage* CMS_logo = new TASImage("CMS-BW-label.png"); TPad* pad_logo = new TPad("logo","logo", xl_0, yl_0, xl_1, yl_1 ); pad_logo->Draw(); pad_logo->cd(); CMS_logo->Draw("X"); pad_logo->Modified(); pad->cd(); } else { latex.SetTextFont(cmsTextFont); latex.SetTextSize(cmsTextSize*t); latex.SetTextAlign(align_); latex.DrawLatex(posX_, posY_, cmsText); if( writeExtraText ) { latex.SetTextFont(extraTextFont); latex.SetTextAlign(align_); latex.SetTextSize(extraTextSize*t); latex.DrawLatex(posX_, posY_- relExtraDY*cmsTextSize*t, extraText); } } } else if( writeExtraText ) { if( iPosX==0) { posX_ = l + relPosX*(1-l-r); posY_ = 1-t+lumiTextOffset*t; } latex.SetTextFont(extraTextFont); latex.SetTextSize(extraTextSize*t); latex.SetTextAlign(align_); latex.DrawLatex(posX_, posY_, extraText); } return; }
void drawplot(int ipt=0, int ic=0){ sprintf(name,"cpt%d_c%d",ipt,ic); c = new TCanvas(name,name,730,420); Divide(c,2,1,0,0); for(int qs=0;qs<2;qs++){ c->cd(qs+1); if(qs!=0) continue; double mmax = hCorr_1D[ic][ipt][1]->GetMaximum(); double mmin = hCorr_1D[ic][ipt][1]->GetMinimum(); double del = mmax-mmin; cout<<mmax<<" "<<mmin<<endl; hCorr_1D[ic][ipt][0]->SetMaximum(mmax+0.65*del); hCorr_1D[ic][ipt][0]->SetMinimum(mmin-0.12*del); cout<<hCorr_1D[ic][ipt][0]->GetMaximum()<<" "<<hCorr_1D[ic][ipt][0]->GetMinimum()<<endl; setstyle(hCorr_1D[ic][ipt][0]); hCorr_1D[ic][ipt][0]->SetXTitle("#Delta#phi [rad]"); hCorr_1D[ic][ipt][0]->SetYTitle("C(#Delta#phi)"); hCorr_1D[ic][ipt][0]->DrawCopy(); // txt.DrawCopyLatex(0.6,0.2,"ATLAS internal"); //hCorr_1D[ic][ipt][0]->GetYaxis()->SetRangeUser(mmin-0.3*del, mmax+0.45*del); if(qs==1){ hCorr_1D[ic][ipt][0]->SetMaximum(hCorr_1D[ic][ipt][0]->GetMaximum()); hCorr_1D[ic][ipt][0]->SetMinimum(hCorr_1D[ic][ipt][0]->GetMinimum()); } line.DrawLine(-0.5*PI,1,1.5*PI,1); hCorr_1D[ic][ipt][1]->DrawCopy("same"); hCorr_1D[ic][ipt][2]->DrawCopy("same"); hCorr_1D[ic][ipt][3]->DrawCopy("same"); //hcor[ic][ipt][3]->Draw("same"); //hcor[ic][ipt][4]->Draw("same"); float xs=-0.4,ys=-0.; lab1.DrawLatex(xs+0.63,ys+0.92,"ATLAS"); lab2.DrawLatex(xs+0.79,ys+0.92,"Internal"); lab3.DrawLatex(xs+0.63, ys+0.85,"#sqrt{s_{NN}}=5.02 TeV"); // lab3.DrawLatex(xs+0.65,ys+0.78,"L_{int} = 7 #mub^{-1}"); // if(qs==0) text1.DrawLatex(0.21,0.93,"(a)"); if(qs==1) text1.DrawLatex(0.21,0.93,"(b)"); int icbin = cbins[ic]; sprintf(name,"Centrality %d-%d%%",icbin*5,icbin*5+5); lab3.DrawLatex(0.6,0.92,name); l = new TLegend(0.53,0.70,1,0.91); l->SetTextFont(43); l->SetTextSize(15); l->SetFillStyle(0); l->SetBorderSize(0); if(qs==0){ l->AddEntry(hCorr_1D[ic][ipt][1],"v_{2} trigger ","pl"); l->AddEntry(hCorr_1D[ic][ipt][2],"v_{3} trigger","pl"); l->AddEntry(hCorr_1D[ic][ipt][3],"large v_{2} & v_{3} trigger","pl"); }else{ l->AddEntry(hCorr_1D[ic][ipt][0],"largest 10% q_{3}","pl"); l->AddEntry(hCorr_1D[ic][ipt][1],"smallest 10% q_{3}","pl"); } l->AddEntry(hCorr_1D[ic][ipt][0],"MiniBias","pl"); l->Draw(); lab2.DrawLatex(0.65,0.2,ptnames[ipt]); lab2.DrawLatex(0.31,0.2,"2<|#Delta#eta|<4.8"); }//qs for(int qs=0;qs<2;qs++){ c->cd(qs+1); if(qs!=1) continue; ic = ic+1; double mmax = hCorr_1D[ic][ipt][1]->GetMaximum(); double mmin = hCorr_1D[ic][ipt][1]->GetMinimum(); double del = mmax-mmin; cout<<ic<<endl; cout<<mmax<<" "<<mmin<<endl; hCorr_1D[ic][ipt][0]->SetMaximum(mmax+0.65*del); hCorr_1D[ic][ipt][0]->SetMinimum(mmin-0.12*del); cout<<hCorr_1D[ic][ipt][0]->GetMaximum()<<" "<<hCorr_1D[ic][ipt][0]->GetMinimum()<<endl; setstyle(hCorr_1D[ic][ipt][0]); hCorr_1D[ic][ipt][0]->SetXTitle("#Delta#phi [rad]"); hCorr_1D[ic][ipt][0]->SetYTitle("C(#Delta#phi)"); hCorr_1D[ic][ipt][0]->DrawCopy(); // txt.DrawCopyLatex(0.6,0.2,"ATLAS internal"); //hCorr_1D[ic][ipt][0]->GetYaxis()->SetRangeUser(mmin-0.3*del, mmax+0.45*del); if(qs==1){ // hCorr_1D[ic][ipt][0]->SetMaximum(hCorr_1D[ic][ipt][0]->GetMaximum()); // hCorr_1D[ic][ipt][0]->SetMinimum(hCorr_1D[ic][ipt][0]->GetMinimum()); } line.DrawLine(-0.5*PI,1,1.5*PI,1); hCorr_1D[ic][ipt][1]->DrawCopy("same"); hCorr_1D[ic][ipt][2]->DrawCopy("same"); hCorr_1D[ic][ipt][3]->DrawCopy("same"); //hcor[ic][ipt][3]->Draw("same"); //hcor[ic][ipt][4]->Draw("same"); float xs=-0.35,ys=-0.; lab1.DrawLatex(xs+0.63,ys+0.92,"ATLAS"); lab2.DrawLatex(xs+0.79,ys+0.92,"Internal"); lab3.DrawLatex(xs+0.63, ys+0.85,"#sqrt{s_{NN}}=5.02 TeV"); // lab3.DrawLatex(xs+0.65,ys+0.78,"L_{int} = 7 #mub^{-1}"); // if(qs==0) text1.DrawLatex(0.21,0.93,"(a)"); if(qs==1) text1.DrawLatex(0.21,0.93,"(b)"); int icbin = cbins[ic]; sprintf(name,"Centrality %d-%d%%",icbin*5,icbin*5+5); lab3.DrawLatex(0.6,0.92,name); l = new TLegend(0.55,0.70,1,0.91); l->SetTextFont(43); l->SetTextSize(15); l->SetFillStyle(0); l->SetBorderSize(0); if(qs==1){ l->AddEntry(hCorr_1D[ic][ipt][1],"v_{2} trigger ","pl"); l->AddEntry(hCorr_1D[ic][ipt][2],"v_{3} trigger","pl"); l->AddEntry(hCorr_1D[ic][ipt][3],"large v_{2} & v_{3} trigger","pl"); }else{ // l->AddEntry(hCorr_1D[ic][ipt][0],"largest 10% q_{3}","pl"); // l->AddEntry(hCorr_1D[ic][ipt][1],"smallest 10% q_{3}","pl"); } l->AddEntry(hCorr_1D[ic][ipt][0],"MiniBias","pl"); l->Draw(); lab2.DrawLatex(0.65,0.2,ptnames[ipt]); lab2.DrawLatex(0.31,0.2,"2<|#Delta#eta|<4.8"); }//qs sprintf(name,"%s.eps", c->GetName()); c->Print(name); sprintf(name,"%s.pdf", c->GetName()); c->Print(name); }
void absoluteCS_CSnPb() { TStyle * style = (TStyle*)gROOT->FindObject("graphStyle"); if(!style) { style = new TStyle("graphStyle","graphStyle"); } TCanvas* c = new TCanvas("c1","",1200,1200); style->SetOptStat(0); style->SetOptTitle(0); style->SetPalette(1,0); style->SetCanvasColor(10); style->SetCanvasBorderMode(0); style->SetFrameLineWidth(3); style->SetFrameFillColor(10); style->SetPadColor(10); style->SetHistLineWidth(3); style->SetHistLineColor(kBlue); style->SetMarkerSize(0.9); style->SetMarkerStyle(8); style->SetFuncWidth(3); style->SetFuncColor(kRed); style->SetLabelColor(kBlack,"xyz"); style->SetTitleSize(0.06,"xyz"); style->SetTitleFillColor(10); style->SetTitleTextColor(kBlack); style->SetEndErrorSize(0); gROOT->SetStyle("graphStyle"); gROOT->ForceStyle(); // read graphs string expFileName = "/data2/analysis/total.root"; string litFileName = "/data2/analysis/literatureData.root"; TFile* expFile = new TFile(expFileName.c_str(),"READ"); TFile* litFile = new TFile(litFileName.c_str(),"READ"); string expCGraphName = "CNat"; string expSnGraphName = "SnNat"; string expPbGraphName = "PbNat"; string litCGraphName = "Natural C (n,tot)"; string litSnGraphName = "Natural Sn (n,tot)"; string litPbGraphName = "Natural Pb (n,tot)"; TGraphAsymmErrors* expCGraph = (TGraphAsymmErrors*)expFile->Get(expCGraphName.c_str()); TGraphAsymmErrors* expSnGraph = (TGraphAsymmErrors*)expFile->Get(expSnGraphName.c_str()); TGraphAsymmErrors* expPbGraph = (TGraphAsymmErrors*)expFile->Get(expPbGraphName.c_str()); TGraphAsymmErrors* litCGraph = (TGraphAsymmErrors*)litFile->Get(litCGraphName.c_str()); TGraphAsymmErrors* litSnGraph = (TGraphAsymmErrors*)litFile->Get(litSnGraphName.c_str()); TGraphAsymmErrors* litPbGraph = (TGraphAsymmErrors*)litFile->Get(litPbGraphName.c_str()); // Set graph point and line characteristics expCGraph->SetLineColor(kRed); expCGraph->SetLineWidth(5); expCGraph->SetLineStyle(0); expCGraph->SetMarkerColor(kRed); expSnGraph->SetLineColor(kRed); expSnGraph->SetLineWidth(5); expSnGraph->SetLineStyle(0); expSnGraph->SetMarkerColor(kRed); expPbGraph->SetLineColor(kRed); expPbGraph->SetLineWidth(5); expPbGraph->SetLineStyle(0); expPbGraph->SetMarkerColor(kRed); litCGraph->SetLineColor(kBlack); litCGraph->SetLineWidth(3); litCGraph->SetLineStyle(2); litCGraph->SetMarkerColor(kBlack); litSnGraph->SetLineColor(kBlack); litSnGraph->SetLineWidth(3); litSnGraph->SetLineStyle(2); litSnGraph->SetMarkerColor(kBlack); litPbGraph->SetLineColor(kBlack); litPbGraph->SetLineWidth(3); litPbGraph->SetLineStyle(2); litPbGraph->SetMarkerColor(kBlack); // Pad dimensions and margins gPad->SetPad(0.005, 0.995, 0.995, 0.005); gPad->SetLeftMargin(0.15); gPad->SetRightMargin(0.01); gPad->SetTopMargin(0.03); gPad->SetBottomMargin(0.15); gPad->SetTicky(2); // X-axis parameters expCGraph->GetXaxis()->SetTitle("Energy (MeV)"); expCGraph->GetXaxis()->SetTitleSize(0.05); expCGraph->GetXaxis()->SetTitleFont(2); expCGraph->GetXaxis()->SetTitleOffset(1.4); expCGraph->GetXaxis()->CenterTitle(); expCGraph->GetXaxis()->SetLabelOffset(0.01); expCGraph->GetXaxis()->SetLabelSize(0.05); expCGraph->GetXaxis()->SetLabelFont(2); expCGraph->GetXaxis()->SetNdivisions(10); expCGraph->GetXaxis()->SetTickLength(0.03); // Y-axis parameters expCGraph->GetYaxis()->SetTitle("#sigma_{tot} (barns)"); expCGraph->GetYaxis()->SetTitleSize(0.06); expCGraph->GetYaxis()->SetTitleFont(2); expCGraph->GetYaxis()->SetTitleOffset(0.8); expCGraph->GetYaxis()->CenterTitle(); expCGraph->GetYaxis()->SetLabelOffset(0.01); expCGraph->GetYaxis()->SetLabelSize(0.05); expCGraph->GetYaxis()->SetLabelFont(2); expCGraph->GetYaxis()->SetNdivisions(10); expCGraph->GetYaxis()->SetTickLength(0.02); expCGraph->Draw(""); expSnGraph->Draw("same"); expPbGraph->Draw("same"); litCGraph->Draw("same"); litSnGraph->Draw("same"); litPbGraph->Draw("same"); expCGraph->Draw("same"); expSnGraph->Draw("same"); expPbGraph->Draw("same"); gPad->SetLogx(1); expCGraph->GetYaxis()->SetRangeUser(0,9); TLatex latex; latex.SetNDC(); latex.SetTextSize(0.035); latex.SetTextAlign(13); // align at top latex.DrawLatex(0.65,0.65,"Pb (elem.)"); latex.DrawLatex(0.35,0.52,"Sn (elem.)"); latex.DrawLatex(0.32,0.4,"C (elem.)"); // Define legend format and contents TLegend *legend = new TLegend(0.7,0.8,0.9,0.9); legend->AddEntry(litCGraph,"lit data (analog)","l"); legend->AddEntry(expCGraph,"new data (DSP)","l"); legend->Draw(); expFile->Close(); litFile->Close(); }
void draw_hist_merge4050_control(int muonidsel_int){ gStyle->SetOptStat(0); TString var[5] = {"met", "lead_pt", "lead_eta", "n_jets", "n_bjets"}; TString additional_cut[6] = {"before_dR", "dR", "dR_W", "dR_chi2", "dR_chi2_lambda", "dR_nbjets"}; TString mass[3] = {"40", "50", "60"}; TString muonidsel; TString additional_cut_latex[5] = { "#splitline{Before}{#splitline{Additional}{Cuts}}", "#splitline{#DeltaR > 0.5}{#splitline{ }{ }}", "#splitline{#DeltaR > 0.5}{#splitline{m(W_{RECO}) < 100 GeV}{ }}", "#splitline{#DeltaR > 0.5}{#splitline{#chi^{2} < 0.1}{ }}", "#splitline{#DeltaR > 0.5}{#splitline{#chi^{2} < 0.1}{#lambda = 0}}"}; double y_max_loose[6*5] = { // met lead_pt lead_eta n_jets n_bjets 1000, 1000, 1000, 2000, 10000, // before_dR 800, 800, 800, 1200, 10000, // dR 100, 100, 100, 100, 1000, // dR_W 60, 80, 60, 60, 1000, // dR_chi2 60, 80, 60, 60, 1000, // dR_chi2_lambda 100, 100, 100, 150, 1000 // dR_nbjets }; double y_max_tight[6*5] = { // met lead_pt lead_eta n_jets n_bjets 500, 600, 800, 600, 600, // before_dR 350, 600, 200, 200, 600, // dR 100, 100, 100, 60, 60, // dR_W 70, 100, 80, 40, 40, // dR_chi2 70, 100, 80, 40, 40, // dR_chi2_lambda 70, 100, 80, 40, 40 // dR_nbjets }; double *y_max; if(muonidsel_int == 0){ muonidsel = "loose"; y_max = y_max_loose; } if(muonidsel_int == 1){ muonidsel = "tight"; y_max = y_max_tight; } for(int i=0;i<6;i++){ // cut double coupling_const; if(i==0 || i==1){ coupling_const=0.001; } else{ coupling_const=0.0001; } for(int j=0;j<5;j++){ // var TFile *file[3]; TCanvas *can[3]; file[0] = new TFile("./"+additional_cut[i]+"/"+muonidsel+"_40_"+var[j]+".root"); file[1] = new TFile("./"+additional_cut[i]+"/"+muonidsel+"_50_"+var[j]+".root"); file[2] = new TFile("./"+additional_cut[i]+"/"+muonidsel+"_60_"+var[j]+".root"); can[0] = (TCanvas*)file[0]->Get("c"+TString::Itoa(j+1,10)); can[0]->Draw(); can[1] = (TCanvas*)file[1]->Get("c"+TString::Itoa(j+1,10)); can[2] = (TCanvas*)file[2]->Get("c"+TString::Itoa(j+1,10)); TPad *pad[3]; pad[0] = (TPad*)can[0]->GetPrimitive("c"+TString::Itoa(j+1,10)+"_up"); pad[1] = (TPad*)can[1]->GetPrimitive("c"+TString::Itoa(j+1,10)+"_up"); pad[2] = (TPad*)can[2]->GetPrimitive("c"+TString::Itoa(j+1,10)+"_up"); pad[0]->cd(); THStack *bkg_40 = (THStack*)pad[0]->GetPrimitive("bkgstack_"+var[j]); bkg_40->SetMaximum(y_max[5*i+j]); TH1D *hist_sig_50 = (TH1D*)pad[1]->GetPrimitive("hist_"+var[j]+"0"); hist_sig_50->SetLineColor(kBlack); hist_sig_50->Draw("histsame"); TH1D *hist_sig_60 = (TH1D*)pad[2]->GetPrimitive("hist_"+var[j]+"0"); hist_sig_60->SetLineColor(kBlue); hist_sig_60->Draw("histsame"); TLegend *lg = (TLegend*)pad[0]->GetPrimitive("TPave")->Clone(); pad[0]->GetPrimitive("TPave")->Delete(); lg->AddEntry(hist_sig_50, "HN50, |V_{N#mu}|^{2}=10^{"+TString::Itoa(TMath::Log10(coupling_const), 10)+"}", "l"); lg->AddEntry(hist_sig_60, "HN60, |V_{N#mu}|^{2}=10^{"+TString::Itoa(TMath::Log10(coupling_const), 10)+"}", "l"); lg->Draw(); TLatex t; t.SetTextFont(43); t.SetTextColor(2); t.SetTextSize(20); double x_max = bkg_40->GetXaxis()->GetXmax(), x_min = bkg_40->GetXaxis()->GetXmin(); if(j==4){ bkg_40->SetMinimum(0.5); t.DrawLatex(x_min+0.72*(x_max-x_min), TMath::Power(10, 0.50*(TMath::Log10(y_max[5*i+j])-0.8)), additional_cut_latex[i]); } else{ t.DrawLatex(x_min+0.72*(x_max-x_min), 0.50*y_max[5*i+j], additional_cut_latex[i]); } can[0]->SaveAs("./"+additional_cut[i]+"/"+muonidsel+"_"+TString::Itoa(405060,10)+"_"+var[j]+".pdf"); can[0]->Close(); } } }
int singleMu_plots() { // Parameters FLAG *flag = new FLAG; flag->doSta = true; flag->doGlb = false; string data2010 = "/castor/cern.ch/user/m/miheejo/openHLT/cms442p5/HICorePhysics_Skim_MinimumBias_RAW/openhlt_2010HICorePhysicsMB.root"; string data2011 = "/castor/cern.ch/user/m/miheejo/openHLT/RD2011/HIDiMuon_HIRun2011-PromptReco-v1_RECO/openhlt_PromptReco_181611_181778.root"; //"/castor/cern.ch/user/m/miheejo/openHLT/RD2011/HIData2011_rawToRecoV3_LSF/openhlt_HIData2011_rawToRecoV3_LSF.root"; // Check trigger list vector<string> triglist; triglist.push_back("HLT_HIL1DoubleMu0_HighQ_v1"); triglist.push_back("HLT_HIL2DoubleMu3_v1"); triglist.push_back("HLT_HIL3DoubleMuOpen_v1"); triglist.push_back("HLT_HIL3DoubleMuOpen_Mgt2_OS_NoCowboy_v1"); triglist.push_back("HLT_HIL2Mu3_v1"); triglist.push_back("HLT_HIL2Mu7_v1"); triglist.push_back("HLT_HIL2Mu15_v1"); triglist.push_back("HLT_HIL2Mu3_NHitQ_v1"); triglist.push_back("HLT_HIL3Mu3_v1"); // Histograms TH2F *SingleGlb_Etapt_2010 = new TH2F("SingleGlb_etapt_2010","SingleGlb_etapt_2010;single mu #eta;single mu p_{T}",ETA,-2.4,2.4,PT,0,20); TH2F *SingleGlb_Etapt_2011 = new TH2F("SingleGlb_etapt_2011","SingleGlb_etapt_2011;single mu #eta;single mu p_{T}",ETA,-2.4,2.4,PT,0,20); TH2F *SingleGlb_Etaphi_2010 = new TH2F("SingleGlb_etaphi_2010","SingleGlb_etaphi_2010;single mu #eta;single mu #phi",ETA,-2.4,2.4,20,-PI,PI); TH2F *SingleGlb_Etaphi_2011 = new TH2F("SingleGlb_etaphi_2011","SingleGlb_etaphi_2011;single mu #eta;single mu #phi",ETA,-2.4,2.4,20,-PI,PI); TH1F *SingleGlb_Eta_2010 = new TH1F("SingleGlb_eta_2010","SingleGlb_eta_2010;single mu #eta",ETA,-2.4,2.4); TH1F *SingleGlb_Eta_2011 = new TH1F("SingleGlb_eta_2011","SingleGlb_eta_2011;single mu #eta",ETA,-2.4,2.4); TH1F *SingleGlb_Phi_2010 = new TH1F("SingleGlb_phi_2010","SingleGlb_phi_2010;single mu #phi",20,-PI,PI); TH1F *SingleGlb_Phi_2011 = new TH1F("SingleGlb_phi_2011","SingleGlb_phi_2011;single mu #phi",20,-PI,PI); TH1F *SingleGlb_Pt_2010 = new TH1F("SingleGlb_pt_2010","SingleGlb_pt_2010;single mu p_{T}",PT,0,20); TH1F *SingleGlb_Pt_2011 = new TH1F("SingleGlb_pt_2011","SingleGlb_pt_2011;single mu p_{T}",PT,0,20); TH2F *SingleGlb_Etapt_2010_qual = new TH2F("SingleGlb_etapt_2010_qual","SingleGlb_etapt_2010_qual;single mu #eta;single mu p_{T}",ETA,-2.4,2.4,PT,0,20); TH2F *SingleGlb_Etapt_2011_qual = new TH2F("SingleGlb_etapt_2011_qual","SingleGlb_etapt_2011_qual;single mu #eta;single mu p_{T}",ETA,-2.4,2.4,PT,0,20); TH2F *SingleGlb_Etaphi_2010_qual = new TH2F("SingleGlb_etaphi_2010_qual","SingleGlb_etaphi_2010_qual;single mu #eta;single mu #phi",ETA,-2.4,2.4,20,-PI,PI); TH2F *SingleGlb_Etaphi_2011_qual = new TH2F("SingleGlb_etaphi_2011_qual","SingleGlb_etaphi_2011_qual;single mu #eta;single mu #phi",ETA,-2.4,2.4,20,-PI,PI); TH1F *SingleGlb_Eta_2010_qual = new TH1F("SingleGlb_eta_2010_qual","SingleGlb_eta_2010_qual;single mu #eta",ETA,-2.4,2.4); TH1F *SingleGlb_Eta_2011_qual = new TH1F("SingleGlb_eta_2011_qual","SingleGlb_eta_2011_qual;single mu #eta",ETA,-2.4,2.4); TH1F *SingleGlb_Phi_2010_qual = new TH1F("SingleGlb_phi_2010_qual","SingleGlb_phi_2010_qual;single mu #phi",20,-PI,PI); TH1F *SingleGlb_Phi_2011_qual = new TH1F("SingleGlb_phi_2011_qual","SingleGlb_phi_2011_qual;single mu #phi",20,-PI,PI); TH1F *SingleGlb_Pt_2010_qual = new TH1F("SingleGlb_pt_2010_qual","SingleGlb_pt_2010_qual;single mu p_{T}",PT,0,20); TH1F *SingleGlb_Pt_2011_qual = new TH1F("SingleGlb_pt_2011_qual","SingleGlb_pt_2011_qual;single mu p_{T}",PT,0,20); // Input files // 2010 datafile TCastorFile *input_2010 = new TCastorFile(data2010.c_str()); FriendMuTree *mutree_2010 = new FriendMuTree(input_2010,true); // Load HLTMuTree HltTree *ohTree_2010 = new HltTree(input_2010,true,"hltana/HltTree"); // Load HltTree TTree *muon_tree_2010; // Hold HLTMuTree TTree *open_tree_2010; // Hold HltTree MUTREE *muTree_2010 = new MUTREE; // 2011 datafile TCastorFile *input_2011 = new TCastorFile(data2011.c_str()); FriendMuTree *mutree_2011 = new FriendMuTree(input_2011,true); // Load HLTMuTree HltTree *ohTree_2011 = new HltTree(input_2011,true,"hltanalysis/HltTree"); // Load HltTree TTree *muon_tree_2011; // Hold HLTMuTree TTree *open_tree_2011; // Hold HltTree MUTREE *muTree_2011 = new MUTREE; const unsigned int ntrig = triglist.size(); int trig_2010[ntrig]; // Trigger bits for muons int trig_2011[ntrig]; // Trigger bits for muons open_tree_2010 = ohTree_2010->fChain; // Get TTree for trigger bits open_tree_2011 = ohTree_2011->fChain; // Get TTree for trigger bits for (unsigned int i=0; i < ntrig; i++) { string tmptrig = triglist[i]; open_tree_2010->SetBranchAddress(tmptrig.c_str(),&trig_2010[i]); // SetBranchAddress for trigger bits open_tree_2011->SetBranchAddress(tmptrig.c_str(),&trig_2011[i]); // SetBranchAddress for trigger bits } muon_tree_2010 = mutree_2010->fChain; // Get TTree for muon objects muon_tree_2010->SetBranchAddress("Run",&muTree_2010->run); muon_tree_2010->SetBranchAddress("Event",&muTree_2010->event); muon_tree_2011 = mutree_2011->fChain; // Get TTree for muon objects muon_tree_2011->SetBranchAddress("Run",&muTree_2011->run); muon_tree_2011->SetBranchAddress("Event",&muTree_2011->event); if (flag->doSta && !flag->doGlb) { muon_tree_2010->SetBranchAddress("Sta_eta",muTree_2010->eta); muon_tree_2010->SetBranchAddress("Sta_pt",muTree_2010->pt); muon_tree_2010->SetBranchAddress("Sta_phi",muTree_2010->phi); muon_tree_2010->SetBranchAddress("Sta_nptl",&muTree_2010->nptl); muon_tree_2010->SetBranchAddress("Sta_charge",muTree_2010->charge); muon_tree_2011->SetBranchAddress("Sta_eta",muTree_2011->eta); muon_tree_2011->SetBranchAddress("Sta_pt",muTree_2011->pt); muon_tree_2011->SetBranchAddress("Sta_phi",muTree_2011->phi); muon_tree_2011->SetBranchAddress("Sta_nptl",&muTree_2011->nptl); muon_tree_2011->SetBranchAddress("Sta_charge",muTree_2011->charge); } else if (flag->doGlb && !flag->doSta) { muon_tree_2011->SetBranchAddress("Glb_eta",muTree_2011->eta); muon_tree_2011->SetBranchAddress("Glb_pt",muTree_2011->pt); muon_tree_2011->SetBranchAddress("Glb_phi",muTree_2011->phi); muon_tree_2011->SetBranchAddress("Glb_nptl",&muTree_2011->nptl); muon_tree_2011->SetBranchAddress("Glb_charge",muTree_2011->charge); muon_tree_2011->SetBranchAddress("Glb_nValMuHits",muTree_2011->nValMuHits); muon_tree_2011->SetBranchAddress("Glb_nValTrkHits",muTree_2011->nValTrkHits); muon_tree_2011->SetBranchAddress("Glb_nTrkFound",muTree_2011->nTrkFound); muon_tree_2011->SetBranchAddress("Glb_glbChi2_ndof",muTree_2011->glbChi2_ndof); muon_tree_2011->SetBranchAddress("Glb_trkChi2_ndof",muTree_2011->trkChi2_ndof); muon_tree_2011->SetBranchAddress("Glb_pixLayerWMeas",muTree_2011->pixLayerWMeas); muon_tree_2011->SetBranchAddress("Glb_trkDxy",muTree_2011->trkDxy); muon_tree_2011->SetBranchAddress("Glb_trkDz",muTree_2011->trkDz); muon_tree_2010->SetBranchAddress("Glb_eta",muTree_2010->eta); muon_tree_2010->SetBranchAddress("Glb_pt",muTree_2010->pt); muon_tree_2010->SetBranchAddress("Glb_phi",muTree_2010->phi); muon_tree_2010->SetBranchAddress("Glb_nptl",&muTree_2010->nptl); muon_tree_2010->SetBranchAddress("Glb_charge",muTree_2010->charge); muon_tree_2010->SetBranchAddress("Glb_nValMuHits",muTree_2010->nValMuHits); muon_tree_2010->SetBranchAddress("Glb_nValTrkHits",muTree_2010->nValTrkHits); muon_tree_2010->SetBranchAddress("Glb_nTrkFound",muTree_2010->nTrkFound); muon_tree_2010->SetBranchAddress("Glb_glbChi2_ndof",muTree_2010->glbChi2_ndof); muon_tree_2010->SetBranchAddress("Glb_trkChi2_ndof",muTree_2010->trkChi2_ndof); muon_tree_2010->SetBranchAddress("Glb_pixLayerWMeas",muTree_2010->pixLayerWMeas); muon_tree_2010->SetBranchAddress("Glb_trkDxy",muTree_2010->trkDxy); muon_tree_2010->SetBranchAddress("Glb_trkDz",muTree_2010->trkDz); } else { cout << "Choose doSta or doGlb or doGen!\n"; return -1; } int nevt_2010=0; // # of events that has at least 1 muon trigger fired int nevt_2010_qual=0; // # of events that has at least 1 muon trigger fired // Loop over trees over 2010 trees for (int i=0; i<muon_tree_2010->GetEntries(); i++) { muon_tree_2010->GetEntry(i); ohTree_2010->GetEntry(i); open_tree_2010->GetEntry(i); ////////// Check muon trigger list /* flag->trig = false; for (unsigned int tidx=0; tidx<ntrig; tidx++) { if (trig_2010[tidx]) { // At least one of the muon trigger is fired. flag->trig = true; break; } } if (!flag->trig) continue; // If no muon triggers fired, go to the next event! */ nevt_2010++; bool qual=false; ////////// Load muons and fill up histograms for (int a=0; a < muTree_2010->nptl; a++) { SingleGlb_Etapt_2010->Fill(muTree_2010->eta[a],muTree_2010->pt[a]); SingleGlb_Etaphi_2010->Fill(muTree_2010->eta[a],muTree_2010->phi[a]); SingleGlb_Eta_2010->Fill(muTree_2010->eta[a]); SingleGlb_Pt_2010->Fill(muTree_2010->pt[a]); SingleGlb_Phi_2010->Fill(muTree_2010->phi[a]); if (flag->doGlb) { if(!isValidMu(flag, muTree_2010, a)) continue; //Check glb muons are within acceptance range } else if (flag->doSta) { if(!isMuInAcc(flag, muTree_2010->eta[a], muTree_2010->pt[a])) continue; //Check sta muons are within acceptance range } qual = true; SingleGlb_Etapt_2010_qual->Fill(muTree_2010->eta[a],muTree_2010->pt[a]); SingleGlb_Etaphi_2010_qual->Fill(muTree_2010->eta[a],muTree_2010->phi[a]); SingleGlb_Eta_2010_qual->Fill(muTree_2010->eta[a]); SingleGlb_Pt_2010_qual->Fill(muTree_2010->pt[a]); SingleGlb_Phi_2010_qual->Fill(muTree_2010->phi[a]); } if (qual) nevt_2010_qual++; if (i%1000 ==0) cout << "Event in 2010 datasets: " << i+1 << endl; } int nevt_2011=0; // # of events that has at least 1 muon trigger fired int nevt_2011_qual=0; // # of events that has at least 1 muon trigger fired // Loop over trees over 2011 trees for (int i=0; i<muon_tree_2011->GetEntries(); i++) { muon_tree_2011->GetEntry(i); ohTree_2011->GetEntry(i); open_tree_2011->GetEntry(i); ////////// Check muon trigger list flag->trig = false; for (unsigned int tidx=0; tidx<ntrig; tidx++) { if (trig_2011[tidx]) { // At least one of the muon trigger is fired. flag->trig = true; break; } } if (!flag->trig) continue; // If no muon triggers fired, go to the next event! nevt_2011++; bool qual=false; ////////// Load muons and fill up histograms for (int a=0; a < muTree_2011->nptl; a++) { SingleGlb_Etapt_2011->Fill(muTree_2011->eta[a],muTree_2011->pt[a]); SingleGlb_Etaphi_2011->Fill(muTree_2011->eta[a],muTree_2011->phi[a]); SingleGlb_Eta_2011->Fill(muTree_2011->eta[a]); SingleGlb_Pt_2011->Fill(muTree_2011->pt[a]); SingleGlb_Phi_2011->Fill(muTree_2011->phi[a]); if (flag->doGlb) { if(!isValidMu(flag, muTree_2011, a)) continue; //Check glb muons are within acceptance range } else if (flag->doSta) { if(!isMuInAcc(flag, muTree_2011->eta[a], muTree_2011->pt[a])) continue; //Check sta muons are within acceptance range } qual = true; SingleGlb_Etapt_2011_qual->Fill(muTree_2011->eta[a],muTree_2011->pt[a]); SingleGlb_Etaphi_2011_qual->Fill(muTree_2011->eta[a],muTree_2011->phi[a]); SingleGlb_Eta_2011_qual->Fill(muTree_2011->eta[a]); SingleGlb_Pt_2011_qual->Fill(muTree_2011->pt[a]); SingleGlb_Phi_2011_qual->Fill(muTree_2011->phi[a]); } if (qual) nevt_2011_qual++; if (i%1000 ==0) cout << "Event in 2011 datasets: " << i+1 << endl; } double ratio_2010 = SingleGlb_Eta_2010->GetEntries()/nevt_2010; double ratio_2011 = SingleGlb_Eta_2011->GetEntries()/nevt_2011; double ratio_2010_qual = SingleGlb_Eta_2010_qual->GetEntries()/nevt_2010_qual; double ratio_2011_qual = SingleGlb_Eta_2011_qual->GetEntries()/nevt_2011_qual; // Draw final histograms and save it into .png files gROOT->Macro("~miheejo/public/HIMuTrig/TrigStyle.C"); //For plot style TCanvas *canv = new TCanvas("canv","canv",800,600); canv->Draw(); SingleGlb_Etapt_2010->DrawNormalized("colz",ratio_2010); canv->SaveAs("SingleGlb_Etapt_2010.png"); canv->Clear(); canv->Draw(); SingleGlb_Etapt_2011->DrawNormalized("colz",ratio_2011); canv->SaveAs("SingleGlb_Etapt_2011.png"); canv->Clear(); canv->Draw(); SingleGlb_Etaphi_2010->DrawNormalized("colz",ratio_2010); canv->SaveAs("SingleGlb_Etaphi_2010.png"); canv->Clear(); canv->Draw(); SingleGlb_Etaphi_2011->DrawNormalized("colz",ratio_2011); canv->SaveAs("SingleGlb_Etaphi_2011.png"); canv->Clear(); canv->Draw(); SingleGlb_Etapt_2010_qual->DrawNormalized("colz",ratio_2010_qual); canv->SaveAs("SingleGlb_Etapt_2010_qual.png"); canv->Clear(); canv->Draw(); SingleGlb_Etapt_2011_qual->DrawNormalized("colz",ratio_2011_qual); canv->SaveAs("SingleGlb_Etapt_2011_qual.png"); canv->Clear(); canv->Draw(); SingleGlb_Etaphi_2010_qual->DrawNormalized("colz",ratio_2010_qual); canv->SaveAs("SingleGlb_Etaphi_2010_qual.png"); canv->Clear(); canv->Draw(); SingleGlb_Etaphi_2011_qual->DrawNormalized("colz",ratio_2011_qual); canv->SaveAs("SingleGlb_Etaphi_2011_qual.png"); delete canv; TLegend *leg = new TLegend(0.5,0.70,0.65,0.83); leg->SetFillColor(0); leg->SetBorderSize(0); leg->SetTextSize(0.05); TLegend *leg2 = new TLegend(0.35,0.50,0.45,0.63); leg2->SetFillColor(0); leg2->SetBorderSize(0); leg2->SetTextSize(0.05); TLatex *lax = new TLatex(); lax->SetTextSize(0.04); canv = new TCanvas("canv","canv",1300,1000); canv->Divide(2,2); canv->cd(1); SingleGlb_Eta_2010_qual->Sumw2(); SingleGlb_Eta_2010_qual->SetMarkerStyle(20); SingleGlb_Eta_2010_qual->DrawNormalized("p e",ratio_2010_qual); SingleGlb_Eta_2011_qual->Sumw2(); SingleGlb_Eta_2011_qual->SetMarkerColor(kRed); SingleGlb_Eta_2011_qual->SetMarkerStyle(20); SingleGlb_Eta_2011_qual->DrawNormalized("p e same",ratio_2011_qual); leg->AddEntry(SingleGlb_Eta_2010_qual,"2010 data","lp"); leg->AddEntry(SingleGlb_Eta_2011_qual,"2011 data","lp"); leg2->AddEntry(SingleGlb_Eta_2010_qual,"2010 data","lp"); leg2->AddEntry(SingleGlb_Eta_2011_qual,"2011 data","lp"); leg->Draw(); canv->cd(2); SingleGlb_Pt_2010_qual->Sumw2(); SingleGlb_Pt_2010_qual->SetMarkerStyle(20); SingleGlb_Pt_2010_qual->DrawNormalized("p e",ratio_2010_qual); SingleGlb_Pt_2011_qual->Sumw2(); SingleGlb_Pt_2011_qual->SetMarkerColor(kRed); SingleGlb_Pt_2011_qual->SetMarkerStyle(20); SingleGlb_Pt_2011_qual->DrawNormalized("p e same",ratio_2011_qual); leg->Draw(); canv->cd(3); SingleGlb_Phi_2011_qual->Sumw2(); SingleGlb_Phi_2011_qual->SetMarkerColor(kRed); SingleGlb_Phi_2011_qual->SetMarkerStyle(20); SingleGlb_Phi_2011_qual->DrawNormalized("p e",ratio_2011_qual); SingleGlb_Phi_2010_qual->Sumw2(); SingleGlb_Phi_2010_qual->SetMarkerStyle(20); SingleGlb_Phi_2010_qual->DrawNormalized("p e same",ratio_2010_qual); leg->Draw(); canv->cd(4); stringstream title; title.str(""); title << "2010 # muons (mu trig fired + quality cuts): " << SingleGlb_Eta_2010_qual->GetEntries(); lax->DrawLatex(0.0,0.95,title.str().c_str()); title.str(""); title << "2010 # events (mu trig fired + quality cuts): " << nevt_2010_qual; lax->DrawLatex(0.0,0.90,title.str().c_str()); title.str(""); title << "2011 # muons (mu trig fired + quality cuts): " << SingleGlb_Eta_2011_qual->GetEntries(); lax->DrawLatex(0.0,0.85,title.str().c_str()); title.str(""); title << "2011 # events (mu trig fired + quality cuts): " << nevt_2011_qual; lax->DrawLatex(0.0,0.80,title.str().c_str()); canv->SaveAs("SingleGlb_qual.png"); canv->Clear(); canv->Divide(2,2); canv->cd(1); SingleGlb_Eta_2011->Sumw2(); SingleGlb_Eta_2011->SetMarkerColor(kRed); SingleGlb_Eta_2011->SetMarkerStyle(20); SingleGlb_Eta_2011->DrawNormalized("p e",ratio_2011); SingleGlb_Eta_2010->Sumw2(); SingleGlb_Eta_2010->SetMarkerStyle(20); SingleGlb_Eta_2010->DrawNormalized("p e same",ratio_2010); leg->Draw(); canv->cd(2); SingleGlb_Pt_2011->Sumw2(); SingleGlb_Pt_2011->SetMarkerColor(kRed); SingleGlb_Pt_2011->SetMarkerStyle(20); SingleGlb_Pt_2011->DrawNormalized("p e",ratio_2011); SingleGlb_Pt_2010->Sumw2(); SingleGlb_Pt_2010->SetMarkerStyle(20); SingleGlb_Pt_2010->DrawNormalized("p e same",ratio_2010); leg->Draw(); canv->cd(3); SingleGlb_Phi_2011->Sumw2(); SingleGlb_Phi_2011->SetMarkerColor(kRed); SingleGlb_Phi_2011->SetMarkerStyle(20); SingleGlb_Phi_2011->DrawNormalized("p e",ratio_2011); SingleGlb_Phi_2010->Sumw2(); SingleGlb_Phi_2010->SetMarkerStyle(20); SingleGlb_Phi_2010->DrawNormalized("p e same",ratio_2010); leg2->Draw(); canv->cd(4); title.str(""); title << "2010 # muons (mu trig fired): " << SingleGlb_Eta_2010->GetEntries(); lax->DrawLatex(0.0,0.95,title.str().c_str()); title.str(""); title << "2010 # events (mu trig fired): " << nevt_2010; lax->DrawLatex(0.0,0.90,title.str().c_str()); title.str(""); title << "2011 # muons (mu trig fired): " << SingleGlb_Eta_2011->GetEntries(); lax->DrawLatex(0.0,0.85,title.str().c_str()); title.str(""); title << "2011 # events (mu trig fired): " << nevt_2011; lax->DrawLatex(0.0,0.80,title.str().c_str()); canv->SaveAs("SingleGlb_noqual.png"); return 0; }
void buildPlotAxial_DD(){ TH2F *dummyHist = new TH2F("dum","",1,1,900,1,6E-43,1E-37); dummyHist->GetYaxis()->SetTitle("#sigma_{SD} (cm^{2})"); dummyHist->GetXaxis()->SetTitle("m_{DM} (GeV)"); dummyHist->GetYaxis()->SetTitleOffset(1.5); dummyHist->GetYaxis()->SetTitleSize(0.046); dummyHist->GetXaxis()->SetTitleSize(0.046); dummyHist->GetYaxis()->SetTitleOffset(1.5); dummyHist->GetXaxis()->SetTitleOffset(1.25); dummyHist->GetYaxis()->SetTitleSize(0.045); dummyHist->GetXaxis()->SetTitleSize(0.045); dummyHist->GetYaxis()->SetLabelSize(0.04); dummyHist->GetXaxis()->SetLabelSize(0.04); gROOT->ProcessLine(".x paperStyle.C"); gStyle->SetOptStat(0); gStyle->SetPalette(51); TFile *fiDD = TFile::Open("MassLimit_1_801_0_Both_updatePICO.root"); TGraph *DDF = (TGraph*)fiDD->Get("DD"); TFile *fi = TFile::Open("MassLimit_1_801_0_Both.root"); TCanvas *can = new TCanvas(); dummyHist->Draw("AXIS"); TGraph *combinedD = makeOBV(combined_obs); combinedD->SetLineColor(1); combinedD->SetName("EXP"); TGraph *combined_obsD = makeOBV(combined); combined_obsD->SetLineColor(1);combined_obsD->SetName("OBS"); TGraph *monojetD = makeOBV(monojet); monojetD->SetLineColor(kBlue); monojetD->SetName("mjet"); // Phil swapped boosted and resolved TGraph *boostedD = makeOBV(resolved); boostedD->SetLineColor(kMagenta); boostedD->SetName("bjet"); TGraph *resolvedD = makeOBV(boosted); resolvedD->SetLineColor(kGreen); resolvedD->SetName("rjet"); TGraph *monovD = makeOBV(monov); monovD->SetLineColor(kRed); monovD->SetName("MV"); /* other lines */ combinedD->Draw("lsame"); combined_obsD->Draw("lsame"); monojetD->Draw("lsame"); boostedD->Draw("lsame"); resolvedD->Draw("lsame"); monovD->Draw("lsame"); DDF->Draw("lsame"); TLegend *leg = new TLegend(0.19,0.40,0.51,0.63,NULL,"brNDC"); leg->SetFillStyle(0); leg->AddEntry(combinedD,"Median Expected","L"); leg->AddEntry(combined_obsD,"Observed","L"); leg->AddEntry(monojetD,"Monojet","L"); leg->AddEntry(boostedD,"Boosted","L"); leg->AddEntry(resolvedD,"Resolved","L"); leg->AddEntry(monovD,"V-tagged","L"); leg->AddEntry(DDF,"PICO-2L","L"); leg->Draw(); TLatex * texCMS = new TLatex(0.20,0.84,"#bf{CMS}"); //TLegend *WHITEBOX = new TLegend(0.18,0.83,0.3,0.89); //TLatex * texCMS = new TLatex(0.20,0.84,"#bf{CMS}#it{Preliminary}"); TLegend *WHITEBOX = new TLegend(0.18,0.83,0.42,0.89); WHITEBOX->SetFillColor(kWhite); //WHITEBOX->Draw(); texCMS->SetNDC(); texCMS->SetTextFont(42); texCMS->SetLineWidth(2); texCMS->SetTextSize(0.042); texCMS->Draw(); //tex->SetFillColor(kWhite); TLatex * tex = new TLatex(); tex->SetNDC(); tex->SetTextFont(42); tex->SetLineWidth(2); tex->SetTextSize(0.035); tex->Draw(); tex->DrawLatex(0.69,0.94,"19.7 fb^{-1} (8 TeV)"); tex->DrawLatex(0.20,0.8,"g_{DM}=g_{SM}=1"); tex->DrawLatex(0.20,0.7,"Axial"); can->SetRightMargin(0.11); can->SetLogx(); can->SetLogy(); can->RedrawAxis(); can->SaveAs("MassLimit_1_801_0_Both_DD.pdf"); TFile *rout = new TFile("axialDD_out.root","RECREATE"); rout->WriteTObject(combined_obsD,"combined"); rout->WriteTObject(combinedD,"combined_expected"); rout->WriteTObject(DDF,"DD_mass"); rout->Close(); /* KEY: TCanvas A;1 A KEY: TGraph DD_mass;1 DD_mass KEY: TGraph DD;1 DD KEY: TGraph monojet;1 monojet KEY: TGraph resolved;1 resolved KEY: TGraph boosted;1 boosted KEY: TGraph monov;1 monov KEY: TGraph combined;1 combined KEY: TGraph combinedUp;1 combinedUp KEY: TGraph combinedDown;1 combinedDown KEY: TGraph monojet_obs;1 monojet_obs KEY: TGraph resolved_obs;1 resolved_obs KEY: TGraph boosted_obs;1 boosted_obs KEY: TGraph monov_obs;1 monov_obs KEY: TGraph combined_obs;1 combined_obs KEY: TGraph2D 2D;1 2D */ }
void svdComp(){ const int norder_ = 2; double ratioMin = 0.95; double ratioMax = 1.05; double ratioMinVn8Vn6 = 0.99; double ratioMaxVn8Vn6 = 1.01; double ratioMinG1E = 0.5; double ratioMaxG1E = 3.2; double histMin = -0.2; double histMax = 1.2; double cumuMin = 0.00; double cumuMax = 0.13; double cumuRatMin = 0.95; double cumuRatMax = 1.03; double cumuRatMin86 = 0.997; double cumuRatMax86 = 1.003; double g1eMin = -1; double g1eMax = 0.5; //-- D'Agostini TFile * fDAgUnf; TH1D * hUnfoldStatDAg[NCENT]; TH1D * hUnfoldSysDAg[NCENT]; TH1D * hUnfoldStatAndSysDAg[NCENT]; TFile * fDAgPhysics; TGraphErrors * grVn2RawDAg; TGraphErrors * grVn2RawDAgSys; TGraphErrors * grVn4RawDAg; TGraphErrors * grVn4RawDAgSys; TGraphErrors * grVn6RawDAg; TGraphErrors * grVn6RawDAgSys; TGraphErrors * grVn8RawDAg; TGraphErrors * grVn8RawDAgSys; TGraphErrors * grvn6vn4RatioDAg; TGraphErrors * grvn6vn4RatioDAgSys; TGraphErrors * grvn8vn4RatioDAg; TGraphErrors * grvn8vn4RatioDAgSys; TGraphErrors * grvn8vn6RatioDAg; TGraphErrors * grvn8vn6RatioDAgSys; TGraphErrors * grGamma1ExpDAg; TGraphErrors * grGamma1ExpDAgSys; //-- SVD TFile * fSVDPhysics; TH1D * hUnfoldSVD[NCENT]; TGraphErrors * grVn2RawSVD; TGraphErrors * grVn4RawSVD; TGraphErrors * grVn6RawSVD; TGraphErrors * grVn8RawSVD; TGraphErrors * grvn6vn4RatioSVD; TGraphErrors * grvn8vn4RatioSVD; TGraphErrors * grvn8vn6RatioSVD; TGraphErrors * grGamma1ExpSVD; //-- Unfold ratios TCanvas * cUnfold; TCanvas * cUnfoldRatio_SVD_DAg; TH1D * hUnfoldRatio_SVD_DAg[NCENT]; //-- Physics ratios double vn2SVD_DAg[NCENT]; double vn4SVD_DAg[NCENT]; double vn6SVD_DAg[NCENT]; double vn8SVD_DAg[NCENT]; double vn6vn4SVD_DAg[NCENT]; double vn8vn4SVD_DAg[NCENT]; double vn8vn6SVD_DAg[NCENT]; double g1eSVD_DAg[NCENT]; double vn2SVD_DAg_err[NCENT]; double vn4SVD_DAg_err[NCENT]; double vn6SVD_DAg_err[NCENT]; double vn8SVD_DAg_err[NCENT]; double vn6vn4SVD_DAg_err[NCENT]; double vn8vn4SVD_DAg_err[NCENT]; double vn8vn6SVD_DAg_err[NCENT]; double g1eSVD_DAg_err[NCENT]; TGraphErrors * grVn2RawRatio_SVD_DAg; TGraphErrors * grVn4RawRatio_SVD_DAg; TGraphErrors * grVn6RawRatio_SVD_DAg; TGraphErrors * grVn8RawRatio_SVD_DAg; TGraphErrors * grvn6vn4Ratio_SVD_DAg; TGraphErrors * grvn8vn4Ratio_SVD_DAg; TGraphErrors * grvn8vn6Ratio_SVD_DAg; TGraphErrors * grGamma1ExpRatio_SVD_DAg; TLatex latex; // // MAIN // setTDRStyle(); latex.SetNDC(); TExec *setex2 = new TExec("setex2","gStyle->SetErrorX(0.5)"); //-- Get D'Agostini objects fDAgUnf = new TFile( Form("../../systematicStudies/SysUnfoldDistns_v%i.root", norder_) ); for(int icent = 0; icent < NCENT; icent++){ hUnfoldStatDAg[icent] = (TH1D*) fDAgUnf->Get( Form("hFinalUnfoldStat_c%i", icent) ); hUnfoldStatDAg[icent]->SetLineColor(1); hUnfoldStatDAg[icent]->SetMarkerColor(1); hUnfoldSysDAg[icent] = (TH1D*) fDAgUnf->Get( Form("hFinalUnfoldSys_c%i", icent) ); hUnfoldStatAndSysDAg[icent] = (TH1D*) fDAgUnf->Get( Form("hFinalUnfoldStatAndSys_c%i", icent) ); } fDAgPhysics = new TFile( "../../systematicStudies/PhysicsResults.root" ); grVn2RawDAg = (TGraphErrors*) fDAgPhysics->Get( "grVn2Raw" ); grVn2RawDAgSys = (TGraphErrors*) fDAgPhysics->Get( "grVn2RawSys" ); grVn4RawDAg = (TGraphErrors*) fDAgPhysics->Get( "grVn4Raw" ); grVn4RawDAgSys = (TGraphErrors*) fDAgPhysics->Get( "grVn4RawSys" ); grVn6RawDAg = (TGraphErrors*) fDAgPhysics->Get( "grVn6Raw" ); grVn6RawDAgSys = (TGraphErrors*) fDAgPhysics->Get( "grVn6RawSys" ); grVn8RawDAg = (TGraphErrors*) fDAgPhysics->Get( "grVn8Raw" ); grVn8RawDAgSys = (TGraphErrors*) fDAgPhysics->Get( "grVn8RawSys" ); grvn6vn4RatioDAg = (TGraphErrors*) fDAgPhysics->Get( "grvn6vn4Ratio" ); grvn6vn4RatioDAgSys = (TGraphErrors*) fDAgPhysics->Get( "grvn6vn4RatioSys" ); grvn8vn4RatioDAg = (TGraphErrors*) fDAgPhysics->Get( "grvn8vn4Ratio" ); grvn8vn4RatioDAgSys = (TGraphErrors*) fDAgPhysics->Get( "grvn8vn4RatioSys" ); grvn8vn6RatioDAg = (TGraphErrors*) fDAgPhysics->Get( "grvn8vn6Ratio" ); grvn8vn6RatioDAgSys = (TGraphErrors*) fDAgPhysics->Get( "grvn8vn6RatioSys" ); grGamma1ExpDAg = (TGraphErrors*) fDAgPhysics->Get( "grGamma1Exp" ); grGamma1ExpDAgSys = (TGraphErrors*) fDAgPhysics->Get( "grGamma1ExpSys" ); grVn2RawDAgSys->GetYaxis()->SetTitle( Form("v_{%i}{2}", norder_) ); grVn4RawDAgSys->GetYaxis()->SetTitle( Form("v_{%i}{4}", norder_) ); grVn6RawDAgSys->GetYaxis()->SetTitle( Form("v_{%i}{6}", norder_) ); grVn8RawDAgSys->GetYaxis()->SetTitle( Form("v_{%i}{8}", norder_) ); grvn6vn4RatioDAgSys->GetYaxis()->SetTitle( Form("v_{%i}{6}/v_{%i}{4}", norder_, norder_) ); grvn8vn4RatioDAgSys->GetYaxis()->SetTitle( Form("v_{%i}{8}/v_{%i}{4}", norder_, norder_) ); grvn8vn6RatioDAgSys->GetYaxis()->SetTitle( Form("v_{%i}{8}/v_{%i}{6}", norder_, norder_) ); grGamma1ExpDAgSys->GetYaxis()->SetTitle("#gamma_{1}^{exp}"); grVn2RawDAgSys->GetYaxis()->SetRangeUser(cumuMin, cumuMax); grVn4RawDAgSys->GetYaxis()->SetRangeUser(cumuMin, cumuMax); grVn6RawDAgSys->GetYaxis()->SetRangeUser(cumuMin, cumuMax); grVn8RawDAgSys->GetYaxis()->SetRangeUser(cumuMin, cumuMax); grvn6vn4RatioDAgSys->GetYaxis()->SetRangeUser(cumuRatMin, cumuRatMax); grvn8vn4RatioDAgSys->GetYaxis()->SetRangeUser(cumuRatMin, cumuRatMax); grvn8vn6RatioDAgSys->GetYaxis()->SetRangeUser(cumuRatMin86, cumuRatMax86); grGamma1ExpDAgSys->GetYaxis()->SetRangeUser(g1eMin, g1eMax); grVn2RawDAgSys->GetXaxis()->SetTitle("Centrality %"); grVn4RawDAgSys->GetXaxis()->SetTitle("Centrality %"); grVn6RawDAgSys->GetXaxis()->SetTitle("Centrality %"); grVn8RawDAgSys->GetXaxis()->SetTitle("Centrality %"); grvn6vn4RatioDAgSys->GetXaxis()->SetTitle("Centrality %"); grvn8vn4RatioDAgSys->GetXaxis()->SetTitle("Centrality %"); grvn8vn6RatioDAgSys->GetXaxis()->SetTitle("Centrality %"); grGamma1ExpDAgSys->GetXaxis()->SetTitle("Centrality %"); //-- Get SVD objects fSVDPhysics = new TFile( "../../systematicStudies/SVDPhysics.root" ); for(int icent = 0; icent < NCENT; icent++){ hUnfoldSVD[icent] = (TH1D*) fSVDPhysics->Get( Form("hrecokreg4_c%i", icent) ); hUnfoldSVD[icent]->SetLineColor(2); hUnfoldSVD[icent]->SetMarkerColor(2); hUnfoldSVD[icent]->Scale( 1./hUnfoldSVD[icent]->Integral() ); //-- Ratio to D'Agostini hUnfoldRatio_SVD_DAg[icent] = (TH1D*) hUnfoldSVD[icent]->Clone( Form("hUnfoldRatio_SVD_DAg_c%i", icent) ); hUnfoldRatio_SVD_DAg[icent]->Divide( hUnfoldStatAndSysDAg[icent] ); hUnfoldRatio_SVD_DAg[icent]->SetMinimum(histMin); hUnfoldRatio_SVD_DAg[icent]->SetMaximum(histMax); } grVn2RawSVD = (TGraphErrors*) fSVDPhysics->Get( "grVn2" ); grVn4RawSVD = (TGraphErrors*) fSVDPhysics->Get( "grVn4" ); grVn6RawSVD = (TGraphErrors*) fSVDPhysics->Get( "grVn6" ); grVn8RawSVD = (TGraphErrors*) fSVDPhysics->Get( "grVn8" ); grvn6vn4RatioSVD = (TGraphErrors*) fSVDPhysics->Get( "grVn6Vn4" ); grvn8vn4RatioSVD = (TGraphErrors*) fSVDPhysics->Get( "grVn8Vn4" ); grvn8vn6RatioSVD = (TGraphErrors*) fSVDPhysics->Get( "grVn8Vn6" ); grGamma1ExpSVD = (TGraphErrors*) fSVDPhysics->Get( "grG1E" ); //-- Fill Ratio Arrays for(int icent = 0; icent < NCENT; icent++){ //-- D'Agostini double vn2D = grVn2RawDAg->GetY()[icent]; double vn4D = grVn4RawDAg->GetY()[icent]; double vn6D = grVn6RawDAg->GetY()[icent]; double vn8D = grVn8RawDAg->GetY()[icent]; double vn6vn4D = grvn6vn4RatioDAg->GetY()[icent]; double vn8vn4D = grvn8vn4RatioDAg->GetY()[icent]; double vn8vn6D = grvn8vn6RatioDAg->GetY()[icent]; double g1eD = grGamma1ExpDAg->GetY()[icent]; double vn2D_Ste = grVn2RawDAg->GetErrorY(icent); double vn4D_Ste = grVn4RawDAg->GetErrorY(icent); double vn6D_Ste = grVn6RawDAg->GetErrorY(icent); double vn8D_Ste = grVn8RawDAg->GetErrorY(icent); double vn6vn4D_Ste = grvn6vn4RatioDAg->GetErrorY(icent); double vn8vn4D_Ste = grvn8vn4RatioDAg->GetErrorY(icent); double vn8vn6D_Ste = grvn8vn6RatioDAg->GetErrorY(icent); double g1eD_Ste = grGamma1ExpDAg->GetErrorY(icent); double vn2D_Sye = grVn2RawDAgSys->GetErrorY(icent); double vn4D_Sye = grVn4RawDAgSys->GetErrorY(icent); double vn6D_Sye = grVn6RawDAgSys->GetErrorY(icent); double vn8D_Sye = grVn8RawDAgSys->GetErrorY(icent); double vn6vn4D_Sye = grvn6vn4RatioDAgSys->GetErrorY(icent); double vn8vn4D_Sye = grvn8vn4RatioDAgSys->GetErrorY(icent); double vn8vn6D_Sye = grvn8vn6RatioDAgSys->GetErrorY(icent); double g1eD_Sye = grGamma1ExpDAgSys->GetErrorY(icent); double vn2D_Tote = sqrt( pow(vn2D_Ste, 2) + pow(vn2D_Sye, 2) ); double vn4D_Tote = sqrt( pow(vn4D_Ste, 2) + pow(vn4D_Sye, 2) ); double vn6D_Tote = sqrt( pow(vn6D_Ste, 2) + pow(vn6D_Sye, 2) ); double vn8D_Tote = sqrt( pow(vn8D_Ste, 2) + pow(vn8D_Sye, 2) ); double vn6vn4D_Tote = sqrt( pow(vn6vn4D_Ste, 2) + pow(vn6vn4D_Sye, 2) ); double vn8vn4D_Tote = sqrt( pow(vn8vn4D_Ste, 2) + pow(vn8vn4D_Sye, 2) ); double vn8vn6D_Tote = sqrt( pow(vn8vn6D_Ste, 2) + pow(vn8vn6D_Sye, 2) ); double g1eD_Tote = sqrt( pow(g1eD_Ste, 2) + pow(g1eD_Sye, 2) ); //-- SVD double vn2S = grVn2RawSVD->GetY()[icent]; double vn4S = grVn4RawSVD->GetY()[icent]; double vn6S = grVn6RawSVD->GetY()[icent]; double vn8S = grVn8RawSVD->GetY()[icent]; double vn6vn4S = grvn6vn4RatioSVD->GetY()[icent]; double vn8vn4S = grvn8vn4RatioSVD->GetY()[icent]; double vn8vn6S = grvn8vn6RatioSVD->GetY()[icent]; double g1eS = grGamma1ExpSVD->GetY()[icent]; double vn2S_Ste = grVn2RawSVD->GetErrorY(icent); double vn4S_Ste = grVn4RawSVD->GetErrorY(icent); double vn6S_Ste = grVn6RawSVD->GetErrorY(icent); double vn8S_Ste = grVn8RawSVD->GetErrorY(icent); double vn6vn4S_Ste = grvn6vn4RatioSVD->GetErrorY(icent); double vn8vn4S_Ste = grvn8vn4RatioSVD->GetErrorY(icent); double vn8vn6S_Ste = grvn8vn6RatioSVD->GetErrorY(icent); double g1eS_Ste = grGamma1ExpSVD->GetErrorY(icent); //-- Ratios double vn2SD; double vn4SD; double vn6SD; double vn8SD; double vn6vn4SD; double vn8vn4SD; double vn8vn6SD; double g1eSD; if(vn2D <= 0 || vn2S <= 0) vn2SD = -1; else vn2SD = vn2S / vn2D; if(vn4D <= 0 || vn4S <= 0) vn4SD = -1; else vn4SD = vn4S / vn4D; if(vn6D <= 0 || vn6S <= 0) vn6SD = -1; else vn6SD = vn6S / vn6D; if(vn8D <= 0 || vn8S <= 0) vn8SD = -1; else vn8SD = vn8S / vn8D; if(vn6vn4D <= 0 || vn6vn4S <= 0) vn6vn4SD = -1; else vn6vn4SD = vn6vn4S / vn6vn4D; if(vn8vn4D <= 0 || vn8vn4S <= 0) vn8vn4SD =-1; else vn8vn4SD =vn8vn4S/ vn8vn4D; if(vn8vn6D <= 0 || vn8vn6S <= 0) vn8vn6SD =-1; else vn8vn6SD =vn8vn6S/ vn8vn6D; if(g1eS < -100. || g1eD < -100.) g1eSD = -10000.; else g1eSD = g1eS / g1eD; double vn2SDe = sqrt( pow(vn2S_Ste/vn2D, 2) + pow(vn2S*vn2D_Tote/vn2D/vn2D, 2) ); double vn4SDe = sqrt( pow(vn4S_Ste/vn4D, 2) + pow(vn4S*vn4D_Tote/vn4D/vn4D, 2) ); double vn6SDe = sqrt( pow(vn6S_Ste/vn6D, 2) + pow(vn6S*vn6D_Tote/vn6D/vn6D, 2) ); double vn8SDe = sqrt( pow(vn8S_Ste/vn8D, 2) + pow(vn8S*vn8D_Tote/vn8D/vn8D, 2) ); double vn6vn4SDe = sqrt( pow(vn6vn4S_Ste/vn6vn4D, 2) + pow(vn6vn4S*vn6vn4D_Tote/vn6vn4D/vn6vn4D, 2) ); double vn8vn4SDe = sqrt( pow(vn8vn4S_Ste/vn8vn4D, 2) + pow(vn8vn4S*vn8vn4D_Tote/vn8vn4D/vn8vn4D, 2) ); double vn8vn6SDe = sqrt( pow(vn8vn6S_Ste/vn8vn6D, 2) + pow(vn8vn6S*vn8vn6D_Tote/vn8vn6D/vn8vn6D, 2) ); double g1eSDe = sqrt( pow(g1eS_Ste/g1eD, 2) + pow(g1eS*g1eD_Tote/g1eD/g1eD, 2) ); vn2SVD_DAg[icent] = vn2SD; vn4SVD_DAg[icent] = vn4SD; vn6SVD_DAg[icent] = vn6SD; vn8SVD_DAg[icent] = vn8SD; vn6vn4SVD_DAg[icent] = vn6vn4SD; vn8vn4SVD_DAg[icent] = vn8vn4SD; vn8vn6SVD_DAg[icent] = vn8vn6SD; g1eSVD_DAg[icent] = g1eSD; vn2SVD_DAg_err[icent] = vn2SDe; vn4SVD_DAg_err[icent] = vn4SDe; vn6SVD_DAg_err[icent] = vn6SDe; vn8SVD_DAg_err[icent] = vn8SDe; vn6vn4SVD_DAg_err[icent] = vn6vn4SDe; vn8vn4SVD_DAg_err[icent] = vn8vn4SDe; vn8vn6SVD_DAg_err[icent] = vn8vn6SDe; g1eSVD_DAg_err[icent] = g1eSDe; } //-- TGraph time grVn2RawRatio_SVD_DAg = new TGraphErrors(NCENT, centBinCenter, vn2SVD_DAg, CERR, vn2SVD_DAg_err); grVn4RawRatio_SVD_DAg = new TGraphErrors(NCENT, centBinCenter, vn4SVD_DAg, CERR, vn4SVD_DAg_err); grVn6RawRatio_SVD_DAg = new TGraphErrors(NCENT, centBinCenter, vn6SVD_DAg, CERR, vn6SVD_DAg_err); grVn8RawRatio_SVD_DAg = new TGraphErrors(NCENT, centBinCenter, vn8SVD_DAg, CERR, vn8SVD_DAg_err); grvn6vn4Ratio_SVD_DAg = new TGraphErrors(NCENT, centBinCenter, vn6vn4SVD_DAg, CERR, vn6vn4SVD_DAg_err); grvn8vn4Ratio_SVD_DAg = new TGraphErrors(NCENT, centBinCenter, vn8vn4SVD_DAg, CERR, vn8vn4SVD_DAg_err); grvn8vn6Ratio_SVD_DAg = new TGraphErrors(NCENT, centBinCenter, vn8vn6SVD_DAg, CERR, vn8vn6SVD_DAg_err); grGamma1ExpRatio_SVD_DAg = new TGraphErrors(NCENT, centBinCenter, g1eSVD_DAg, CERR, g1eSVD_DAg_err); formatGraph(grVn2RawRatio_SVD_DAg, "Centrality %", ratioMin, ratioMax, Form("v_{%i}{2} Ratio: SVD/DAg", norder_), 1, 20, "grVn2RawRatio_SVD_DAg"); formatGraph(grVn4RawRatio_SVD_DAg, "Centrality %", ratioMin, ratioMax, Form("v_{%i}{4} Ratio: SVD/DAg", norder_), 1, 20, "grVn4RawRatio_SVD_DAg"); formatGraph(grVn6RawRatio_SVD_DAg, "Centrality %", ratioMin, ratioMax, Form("v_{%i}{6} Ratio: SVD/DAg", norder_), 1, 20, "grVn6RawRatio_SVD_DAg"); formatGraph(grVn8RawRatio_SVD_DAg, "Centrality %", ratioMin, ratioMax, Form("v_{%i}{8} Ratio: SVD/DAg", norder_), 1, 20, "grVn8RawRatio_SVD_DAg"); formatGraph(grvn6vn4Ratio_SVD_DAg, "Centrality %", ratioMin, ratioMax, Form("v_{%i}{6}/v_{%i}{4} Ratio: SVD/DAg", norder_, norder_), 1, 20, "grvn6vn4Ratio_SVD_DAg"); formatGraph(grvn8vn4Ratio_SVD_DAg, "Centrality %", ratioMin, ratioMax, Form("v_{%i}{8}/v_{%i}{4} Ratio: SVD/DAg", norder_, norder_), 1, 20, "grvn8vn4Ratio_SVD_DAg"); formatGraph(grvn8vn6Ratio_SVD_DAg, "Centrality %", ratioMinVn8Vn6, ratioMaxVn8Vn6, Form("v_{%i}{8}/v_{%i}{6} Ratio: SVD/DAg", norder_, norder_), 1, 20, "grvn8vn6Ratio_SVD_DAg"); formatGraph(grGamma1ExpRatio_SVD_DAg, "Centrality %", ratioMinG1E, ratioMaxG1E, "#gamma_{1}^{exp} Ratio: SVD/DAg", 1, 20, "grGamma1ExpRatio_SVD_DAg"); grVn2RawSVD->SetLineColor(1); grVn4RawSVD->SetLineColor(1); grVn6RawSVD->SetLineColor(1); grVn8RawSVD->SetLineColor(1); grvn6vn4RatioSVD->SetLineColor(1); grvn8vn4RatioSVD->SetLineColor(1); grvn8vn6RatioSVD->SetLineColor(1); grGamma1ExpSVD->SetLineColor(1); grVn2RawSVD->SetMarkerColor(1); grVn4RawSVD->SetMarkerColor(1); grVn6RawSVD->SetMarkerColor(1); grVn8RawSVD->SetMarkerColor(1); grvn6vn4RatioSVD->SetMarkerColor(1); grvn8vn4RatioSVD->SetMarkerColor(1); grvn8vn6RatioSVD->SetMarkerColor(1); grGamma1ExpSVD->SetMarkerColor(1); //-- DRAW TLine * lOne = new TLine(0, 1.0, grVn2RawRatio_SVD_DAg->GetXaxis()->GetXmax(), 1.0); lOne->SetLineStyle(2); lOne->SetLineWidth(2); //-- cumus TLegend * legvn2 = new TLegend(0.4939, 0.2013, 0.8977, 0.3675); legvn2->SetBorderSize(0); legvn2->SetFillStyle(0); legvn2->AddEntry(grVn2RawDAg, "D'Agostini", "lp"); legvn2->AddEntry(grVn2RawSVD, "SVD", "lp"); TLegend * legvn4 = new TLegend(0.4939, 0.2013, 0.8977, 0.3675); legvn4->SetBorderSize(0); legvn4->SetFillStyle(0); legvn4->AddEntry(grVn4RawDAg, "D'Agostini", "lp"); legvn4->AddEntry(grVn4RawSVD, "SVD", "lp"); TLegend * legvn6 = new TLegend(0.4939, 0.2013, 0.8977, 0.3675); legvn6->SetBorderSize(0); legvn6->SetFillStyle(0); legvn6->AddEntry(grVn6RawDAg, "D'Agostini", "lp"); legvn6->AddEntry(grVn6RawSVD, "SVD", "lp"); TLegend * legvn8 = new TLegend(0.4939, 0.2013, 0.8977, 0.3675); legvn8->SetBorderSize(0); legvn8->SetFillStyle(0); legvn8->AddEntry(grVn8RawDAg, "D'Agostini", "lp"); legvn8->AddEntry(grVn8RawSVD, "SVD", "lp"); TCanvas * cCumu = new TCanvas("cCumu", "cCumu", 2000, 1000); cCumu->Divide(4, 2); double mar = 0.2; double offs = 1.6; grVn2RawDAgSys->GetYaxis()->SetTitleOffset(offs); grVn4RawDAgSys->GetYaxis()->SetTitleOffset(offs); grVn6RawDAgSys->GetYaxis()->SetTitleOffset(offs); grVn8RawDAgSys->GetYaxis()->SetTitleOffset(offs); grVn2RawRatio_SVD_DAg->GetYaxis()->SetTitleOffset(offs); grVn4RawRatio_SVD_DAg->GetYaxis()->SetTitleOffset(offs); grVn6RawRatio_SVD_DAg->GetYaxis()->SetTitleOffset(offs); grVn8RawRatio_SVD_DAg->GetYaxis()->SetTitleOffset(offs); cCumu->cd(1)->SetLeftMargin(mar); grVn2RawDAgSys->Draw("apE2"); grVn2RawDAg->Draw("psame"); grVn2RawSVD->Draw("psame"); legvn2->Draw("same"); cCumu->cd(2)->SetLeftMargin(mar); grVn4RawDAgSys->Draw("apE2"); grVn4RawDAg->Draw("psame"); grVn4RawSVD->Draw("psame"); legvn4->Draw("same"); cCumu->cd(3)->SetLeftMargin(mar); grVn6RawDAgSys->Draw("apE2"); grVn6RawDAg->Draw("psame"); grVn6RawSVD->Draw("psame"); legvn6->Draw("same"); cCumu->cd(4)->SetLeftMargin(mar); grVn8RawDAgSys->Draw("apE2"); grVn8RawDAg->Draw("psame"); grVn8RawSVD->Draw("psame"); legvn8->Draw("same"); cCumu->cd(5)->SetLeftMargin(mar); grVn2RawRatio_SVD_DAg->Draw("ap"); lOne->Draw("same"); cCumu->cd(6)->SetLeftMargin(mar); grVn4RawRatio_SVD_DAg->Draw("ap"); lOne->Draw("same"); cCumu->cd(7)->SetLeftMargin(mar); grVn6RawRatio_SVD_DAg->Draw("ap"); lOne->Draw("same"); cCumu->cd(8)->SetLeftMargin(mar); grVn8RawRatio_SVD_DAg->Draw("ap"); lOne->Draw("same"); cCumu->SaveAs("cumu.pdf"); //-- cumu Ratios TLegend * legvn6vn4 = new TLegend(0.2146, 0.1898, 0.6194, 0.3560); legvn6vn4->SetBorderSize(0); legvn6vn4->SetFillStyle(0); legvn6vn4->AddEntry(grvn6vn4RatioDAg, "D'Agostini", "lp"); legvn6vn4->AddEntry(grvn6vn4RatioSVD, "SVD", "lp"); TLegend * legvn8vn4 = new TLegend(0.2146, 0.1898, 0.6194, 0.3560); legvn8vn4->SetBorderSize(0); legvn8vn4->SetFillStyle(0); legvn8vn4->AddEntry(grvn8vn4RatioDAg, "D'Agostini", "lp"); legvn8vn4->AddEntry(grvn8vn4RatioSVD, "SVD", "lp"); TLegend * legvn8vn6 = new TLegend(0.2146, 0.1898, 0.6194, 0.3560); legvn8vn6->SetBorderSize(0); legvn8vn6->SetFillStyle(0); legvn8vn6->AddEntry(grvn8vn6RatioDAg, "D'Agostini", "lp"); legvn8vn6->AddEntry(grvn8vn6RatioSVD, "SVD", "lp"); TCanvas * cCumuRatio = new TCanvas("cCumuRatio", "cCumuRatio", 1500, 1000); cCumuRatio->Divide(3, 2); grvn6vn4RatioDAgSys->GetYaxis()->SetTitleOffset(offs); grvn8vn4RatioDAgSys->GetYaxis()->SetTitleOffset(offs); grvn8vn6RatioDAgSys->GetYaxis()->SetTitleOffset(offs+0.1); grvn6vn4Ratio_SVD_DAg->GetYaxis()->SetTitleOffset(offs); grvn8vn4Ratio_SVD_DAg->GetYaxis()->SetTitleOffset(offs); grvn8vn6Ratio_SVD_DAg->GetYaxis()->SetTitleOffset(offs+0.1); cCumuRatio->cd(1)->SetLeftMargin(mar); grvn6vn4RatioDAgSys->Draw("apE2"); grvn6vn4RatioDAg->Draw("psame"); grvn6vn4RatioSVD->Draw("psame"); legvn6vn4->Draw("same"); cCumuRatio->cd(2)->SetLeftMargin(mar); grvn8vn4RatioDAgSys->Draw("apE2"); grvn8vn4RatioDAg->Draw("psame"); grvn8vn4RatioSVD->Draw("psame"); legvn8vn4->Draw("same"); cCumuRatio->cd(3)->SetLeftMargin(mar); grvn8vn6RatioDAgSys->Draw("apE2"); grvn8vn6RatioDAg->Draw("psame"); grvn8vn6RatioSVD->Draw("psame"); legvn8vn6->Draw("same"); cCumuRatio->cd(4)->SetLeftMargin(mar); grvn6vn4Ratio_SVD_DAg->Draw("ap"); lOne->Draw("same"); cCumuRatio->cd(5)->SetLeftMargin(mar); grvn8vn4Ratio_SVD_DAg->Draw("ap"); lOne->Draw("same"); cCumuRatio->cd(6)->SetLeftMargin(mar); grvn8vn6Ratio_SVD_DAg->Draw("ap"); lOne->Draw("same"); cCumuRatio->SaveAs("cumuRatio.pdf"); //-- Gamma1Exp TLegend * legg1e = new TLegend(0.1846, 0.1898, 0.5894, 0.3560); legg1e->SetBorderSize(0); legg1e->SetFillStyle(0); legg1e->AddEntry(grGamma1ExpDAg, "D'Agostini", "lp"); legg1e->AddEntry(grGamma1ExpSVD, "SVD", "lp"); TCanvas * cG1E = new TCanvas("cG1E", "cG1E", 1000, 500); cG1E->Divide(2, 1); cG1E->cd(1); grGamma1ExpDAgSys->Draw("apE2"); grGamma1ExpDAg->Draw("psame"); grGamma1ExpSVD->Draw("psame"); legg1e->Draw("same"); cG1E->cd(2); grGamma1ExpRatio_SVD_DAg->Draw("ap"); lOne->Draw("same"); cG1E->SaveAs("G1E.pdf"); //-- Unfold Distns TLegend * legUnf = new TLegend(0.6, 0.6, 0.9, 0.8); legInit(legUnf); legUnf->AddEntry(hUnfoldStatDAg[0], "D'Agostini", "lp"); legUnf->AddEntry(hUnfoldSVD[0], "SVD", "lp"); cUnfold = new TCanvas("cUnfold", "cUnfold", 2000, 1500); cUnfold->Divide(4,3); for(int icent = 0; icent < NCENT; icent++){ cUnfold->cd(icent+1); cUnfold->cd(icent+1)->SetLogy(); hUnfoldSysDAg[icent]->Draw("e2"); setex2->Draw(); if(icent == 0) legUnf->Draw("same"); } for(int icent= 0; icent < NCENT; icent++){ cUnfold->cd(icent+1); hUnfoldStatDAg[icent]->Draw("same"); hUnfoldSVD[icent]->Draw("same"); latex.DrawLatex(0.67, 0.88, Form( "Cent %i-%i%s", cent_min[icent], cent_max[icent], "%") ); } cUnfold->SaveAs("UnfoldCompare.pdf"); //-- Unfold Ratio SVD/DAg cUnfoldRatio_SVD_DAg = new TCanvas("cUnfoldRatio_SVD_DAg", "cUnfoldRatio_SVD_DAg", 2000, 1500); cUnfoldRatio_SVD_DAg->Divide(4,3); for(int icent= 0; icent < NCENT; icent++){ cUnfoldRatio_SVD_DAg->cd(icent+1); hUnfoldRatio_SVD_DAg[icent]->Draw(); latex.DrawLatex(0.67, 0.88, Form( "Cent %i-%i%s", cent_min[icent], cent_max[icent], "%") ); } cUnfoldRatio_SVD_DAg->SaveAs("UnfoldRatioCompare.pdf"); }
void drawMassFrom2DPlot(RooWorkspace& myws, // Local workspace string outputDir, // Output directory struct InputOpt opt, // Variable with run information (kept for legacy purpose) struct KinCuts cut, // Variable with current kinematic cuts map<string, string> parIni, // Variable containing all initial parameters string plotLabel, // The label used to define the output file name // Select the type of datasets to fit string DSTAG, // Specifies the type of datasets: i.e, DATA, MCJPSINP, ... bool isPbPb, // Define if it is PbPb (True) or PP (False) // Select the type of object to fit bool incJpsi, // Includes Jpsi model bool incPsi2S, // Includes Psi(2S) model bool incBkg, // Includes Background model // Select the fitting options // Select the drawing options bool setLogScale, // Draw plot with log scale bool incSS, // Include Same Sign data double binWidth, // Bin width bool paperStyle=false // if true, print less info ) { RooMsgService::instance().getStream(0).removeTopic(Caching); RooMsgService::instance().getStream(1).removeTopic(Caching); RooMsgService::instance().getStream(0).removeTopic(Plotting); RooMsgService::instance().getStream(1).removeTopic(Plotting); RooMsgService::instance().getStream(0).removeTopic(Integration); RooMsgService::instance().getStream(1).removeTopic(Integration); RooMsgService::instance().setGlobalKillBelow(RooFit::WARNING) ; if (DSTAG.find("_")!=std::string::npos) DSTAG.erase(DSTAG.find("_")); int nBins = min(int( round((cut.dMuon.M.Max - cut.dMuon.M.Min)/binWidth) ), 1000); string pdfTotName = Form("pdfCTAUMASS_Tot_%s", (isPbPb?"PbPb":"PP")); string pdfJpsiPRName = Form("pdfCTAUMASS_JpsiPR_%s", (isPbPb?"PbPb":"PP")); string pdfJpsiNoPRName = Form("pdfCTAUMASS_JpsiNoPR_%s", (isPbPb?"PbPb":"PP")); string pdfPsi2SPRName = Form("pdfCTAUMASS_Psi2SPR_%s", (isPbPb?"PbPb":"PP")); string pdfPsi2SNoPRName = Form("pdfCTAUMASS_Psi2SNoPR_%s", (isPbPb?"PbPb":"PP")); string dsOSName = Form("dOS_%s_%s", DSTAG.c_str(), (isPbPb?"PbPb":"PP")); string dsOSNameCut = dsOSName+"_CTAUCUT"; string dsSSName = Form("dSS_%s_%s", DSTAG.c_str(), (isPbPb?"PbPb":"PP")); bool isWeighted = myws.data(dsOSName.c_str())->isWeighted(); bool isMC = (DSTAG.find("MC")!=std::string::npos); double normDSTot = 1.0; if (myws.data(dsOSNameCut.c_str())) { normDSTot = myws.data(dsOSName.c_str())->sumEntries()/myws.data(dsOSNameCut.c_str())->sumEntries(); } // Create the main plot of the fit RooPlot* frame = myws.var("invMass")->frame(Bins(nBins), Range(cut.dMuon.M.Min, cut.dMuon.M.Max)); myws.data(dsOSName.c_str())->plotOn(frame, Name("dOS"), DataError(RooAbsData::SumW2), XErrorSize(0), MarkerColor(kBlack), LineColor(kBlack), MarkerSize(1.2)); if (paperStyle) TGaxis::SetMaxDigits(3); // to display powers of 10 myws.pdf(pdfTotName.c_str())->plotOn(frame,Name("BKG"),Components(RooArgSet(*myws.pdf(Form("pdfMASS_Bkg_%s", (isPbPb?"PbPb":"PP"))))), FillStyle(paperStyle ? 0 : 1001), FillColor(kAzure-9), VLines(), DrawOption("LCF"), LineColor(kBlue), LineStyle(kDashed) ); if (!paperStyle) { if (incJpsi) { if ( myws.pdf(Form("pdfCTAUMASS_JpsiPR_%s", (isPbPb?"PbPb":"PP"))) ) { myws.pdf(pdfTotName.c_str())->plotOn(frame,Name("JPSIPR"),Components(RooArgSet(*myws.pdf(Form("pdfCTAUMASS_JpsiPR_%s", (isPbPb?"PbPb":"PP"))), *myws.pdf(Form("pdfCTAUMASS_Bkg_%s", (isPbPb?"PbPb":"PP"))))), ProjWData(RooArgSet(*myws.var("ctauErr")), *myws.data(dsOSName.c_str()), kTRUE), Normalization(normDSTot, RooAbsReal::NumEvent), LineColor(kRed+3), LineStyle(1), Precision(1e-4), NumCPU(32) ); } if ( myws.pdf(Form("pdfCTAUMASS_JpsiNoPR_%s", (isPbPb?"PbPb":"PP"))) ) { myws.pdf(pdfTotName.c_str())->plotOn(frame,Name("JPSINOPR"),Components(RooArgSet(*myws.pdf(Form("pdfCTAUMASS_JpsiNoPR_%s", (isPbPb?"PbPb":"PP"))), *myws.pdf(Form("pdfCTAUMASS_Bkg_%s", (isPbPb?"PbPb":"PP"))))), ProjWData(RooArgSet(*myws.var("ctauErr")), *myws.data(dsOSName.c_str()), kTRUE), Normalization(normDSTot, RooAbsReal::NumEvent), LineColor(kGreen+3), LineStyle(1), Precision(1e-4), NumCPU(32) ); } } if (incPsi2S) { if ( myws.pdf(Form("pdfCTAUMASS_Psi2SPR_%s", (isPbPb?"PbPb":"PP"))) ) { myws.pdf(pdfTotName.c_str())->plotOn(frame,Name("PSI2SPR"),Components(RooArgSet(*myws.pdf(Form("pdfCTAUMASS_Psi2SPR_%s", (isPbPb?"PbPb":"PP"))))), ProjWData(RooArgSet(*myws.var("ctauErr")), *myws.data(dsOSName.c_str()), kTRUE), Normalization(normDSTot, RooAbsReal::NumEvent), LineColor(kRed+3), LineStyle(1), Precision(1e-4), NumCPU(32) ); } if ( myws.pdf(Form("pdfCTAUMASS_Psi2SNoPR_%s", (isPbPb?"PbPb":"PP"))) ) { myws.pdf(pdfTotName.c_str())->plotOn(frame,Name("PSI2SNOPR"),Components(RooArgSet(*myws.pdf(Form("pdfCTAUMASS_Psi2SNoPR_%s", (isPbPb?"PbPb":"PP"))))), ProjWData(RooArgSet(*myws.var("ctauErr")), *myws.data(dsOSName.c_str()), kTRUE), Normalization(normDSTot, RooAbsReal::NumEvent), LineColor(kGreen+3), LineStyle(1), Precision(1e-4), NumCPU(32) ); } } } if (incSS) { myws.data(dsSSName.c_str())->plotOn(frame, Name("dSS"), MarkerColor(kRed), LineColor(kRed), MarkerSize(1.2)); } myws.data(dsOSName.c_str())->plotOn(frame, Name("dOS"), DataError(RooAbsData::SumW2), XErrorSize(0), MarkerColor(kBlack), LineColor(kBlack), MarkerSize(1.2)); myws.pdf(pdfTotName.c_str())->plotOn(frame,Name("PDF"), ProjWData(RooArgSet(*myws.var("ctauErr")), *myws.data(dsOSName.c_str()), kTRUE), Normalization(normDSTot, RooAbsReal::NumEvent), LineColor(kBlack), NumCPU(32) ); // Create the pull distribution of the fit RooPlot* frameTMP = (RooPlot*)frame->Clone("TMP"); int nBinsTMP = nBins; RooHist *hpull = frameTMP->pullHist(0, 0, true); hpull->SetName("hpull"); RooPlot* frame2 = myws.var("invMass")->frame(Title("Pull Distribution"), Bins(nBins), Range(cut.dMuon.M.Min, cut.dMuon.M.Max)); frame2->addPlotable(hpull, "PX"); // set the CMS style setTDRStyle(); // Create the main canvas TCanvas *cFig = new TCanvas(Form("cMassFig_%s", (isPbPb?"PbPb":"PP")), "cMassFig",800,800); TPad *pad1 = new TPad(Form("pad1_%s", (isPbPb?"PbPb":"PP")),"",0,paperStyle ? 0 : 0.23,1,1); TPad *pad2 = new TPad(Form("pad2_%s", (isPbPb?"PbPb":"PP")),"",0,0,1,.228); TLine *pline = new TLine(cut.dMuon.M.Min, 0.0, cut.dMuon.M.Max, 0.0); // TPad *pad4 = new TPad("pad4","This is pad4",0.55,0.46,0.97,0.87); TPad *pad4 = new TPad("pad4","This is pad4",0.55,paperStyle ? 0.29 : 0.36,0.97,paperStyle ? 0.70 : 0.77); pad4->SetFillStyle(0); pad4->SetLeftMargin(0.28); pad4->SetRightMargin(0.10); pad4->SetBottomMargin(0.21); pad4->SetTopMargin(0.072); frame->SetTitle(""); frame->GetXaxis()->CenterTitle(kTRUE); if (!paperStyle) { frame->GetXaxis()->SetTitle(""); frame->GetXaxis()->SetTitleSize(0.045); frame->GetXaxis()->SetTitleFont(42); frame->GetXaxis()->SetTitleOffset(3); frame->GetXaxis()->SetLabelOffset(3); frame->GetYaxis()->SetLabelSize(0.04); frame->GetYaxis()->SetTitleSize(0.04); frame->GetYaxis()->SetTitleOffset(1.7); frame->GetYaxis()->SetTitleFont(42); } else { frame->GetXaxis()->SetTitle("m_{#mu^{+}#mu^{-}} (GeV/c^{2})"); frame->GetXaxis()->SetTitleOffset(1.1); frame->GetYaxis()->SetTitleOffset(1.45); frame->GetXaxis()->SetTitleSize(0.05); frame->GetYaxis()->SetTitleSize(0.05); } setMassFrom2DRange(myws, frame, dsOSName, setLogScale); if (paperStyle) { double Ydown = 0.;//frame->GetMinimum(); double Yup = 0.9*frame->GetMaximum(); frame->GetYaxis()->SetRangeUser(Ydown,Yup); } cFig->cd(); pad2->SetTopMargin(0.02); pad2->SetBottomMargin(0.4); pad2->SetFillStyle(4000); pad2->SetFrameFillStyle(4000); if (!paperStyle) pad1->SetBottomMargin(0.015); //plot fit pad1->Draw(); pad1->cd(); frame->Draw(); printMassFrom2DParameters(myws, pad1, isPbPb, pdfTotName, isWeighted); pad1->SetLogy(setLogScale); // Drawing the text in the plot TLatex *t = new TLatex(); t->SetNDC(); t->SetTextSize(0.032); float dy = 0; t->SetTextSize(0.03); if (!paperStyle) { // do not print selection details for paper style t->DrawLatex(0.20, 0.86-dy, "2015 HI Soft Muon ID"); dy+=0.045; if (isPbPb) { t->DrawLatex(0.20, 0.86-dy, "HLT_HIL1DoubleMu0_v1"); dy+=2.0*0.045; } else { t->DrawLatex(0.20, 0.86-dy, "HLT_HIL1DoubleMu0_v1"); dy+=2.0*0.045; } } if (cut.dMuon.AbsRap.Min>0.1) {t->DrawLatex(0.5175, 0.86-dy, Form("%.1f < |y^{#mu#mu}| < %.1f",cut.dMuon.AbsRap.Min,cut.dMuon.AbsRap.Max)); dy+=0.045;} else {t->DrawLatex(0.5175, 0.86-dy, Form("|y^{#mu#mu}| < %.1f",cut.dMuon.AbsRap.Max)); dy+=0.045;} t->DrawLatex(0.5175, 0.86-dy, Form("%g < p_{T}^{#mu#mu} < %g GeV/c",cut.dMuon.Pt.Min,cut.dMuon.Pt.Max)); dy+=0.045; if (isPbPb) {t->DrawLatex(0.5175, 0.86-dy, Form("Cent. %d-%d%%", (int)(cut.Centrality.Start/2), (int)(cut.Centrality.End/2))); dy+=0.045;} // Drawing the Legend double ymin = 0.7602; if (incPsi2S && incJpsi && incSS) { ymin = 0.7202; } if (incPsi2S && incJpsi && !incSS) { ymin = 0.7452; } if (paperStyle) { ymin = 0.72; } TLegend* leg = new TLegend(0.5175, ymin, 0.7180, 0.8809); leg->SetTextSize(0.03); if (frame->findObject("dOS")) { leg->AddEntry(frame->findObject("dOS"), (incSS?"Opposite Charge":"Data"),"pe"); } if (incSS) { leg->AddEntry(frame->findObject("dSS"),"Same Charge","pe"); } if (frame->findObject("PDF")) { leg->AddEntry(frame->findObject("PDF"),"Total fit","l"); } if (frame->findObject("JPSIPR")) { leg->AddEntry(frame->findObject("JPSIPR"),"Prompt J/#psi","l"); } if (frame->findObject("JPSINOPR")) { leg->AddEntry(frame->findObject("JPSINOPR"),"Non-Prompt J/#psi","l"); } if (incBkg && frame->findObject("BKG")) { leg->AddEntry(frame->findObject("BKG"),"Background",paperStyle ? "l" : "fl"); } leg->Draw("same"); //Drawing the title TString label; if (isPbPb) { if (opt.PbPb.RunNb.Start==opt.PbPb.RunNb.End){ label = Form("PbPb Run %d", opt.PbPb.RunNb.Start); } else { label = Form("%s [%s %d-%d]", "PbPb", "HIOniaL1DoubleMu0", opt.PbPb.RunNb.Start, opt.PbPb.RunNb.End); } } else { if (opt.pp.RunNb.Start==opt.pp.RunNb.End){ label = Form("PP Run %d", opt.pp.RunNb.Start); } else { label = Form("%s [%s %d-%d]", "PP", "DoubleMu0", opt.pp.RunNb.Start, opt.pp.RunNb.End); } } // CMS_lumi(pad1, isPbPb ? 105 : 104, 33, label); CMS_lumi(pad1, isPbPb ? 108 : 107, 33, ""); if (!paperStyle) gStyle->SetTitleFontSize(0.05); pad1->Update(); cFig->cd(); if (!paperStyle) { //---plot pull pad2->Draw(); pad2->cd(); frame2->SetTitle(""); frame2->GetYaxis()->CenterTitle(kTRUE); frame2->GetYaxis()->SetTitleOffset(0.4); frame2->GetYaxis()->SetTitleSize(0.1); frame2->GetYaxis()->SetLabelSize(0.1); frame2->GetYaxis()->SetTitle("Pull"); frame2->GetXaxis()->CenterTitle(kTRUE); frame2->GetXaxis()->SetTitleOffset(1); frame2->GetXaxis()->SetTitleSize(0.12); frame2->GetXaxis()->SetLabelSize(0.1); frame2->GetXaxis()->SetTitle("m_{#mu^{+}#mu^{-}} (GeV/c^{2})"); frame2->GetYaxis()->SetRangeUser(-7.0, 7.0); frame2->Draw(); // *** Print chi2/ndof printChi2(myws, pad2, frameTMP, "invMass", dsOSName.c_str(), pdfTotName.c_str(), nBinsTMP, false); pline->Draw("same"); pad2->Update(); } // Save the plot in different formats gSystem->mkdir(Form("%sctauMass/%s/plot/root/", outputDir.c_str(), DSTAG.c_str()), kTRUE); cFig->SaveAs(Form("%sctauMass/%s/plot/root/PLOT_%s_%s_%s%s_pt%.0f%.0f_rap%.0f%.0f_cent%d%d.root", outputDir.c_str(), DSTAG.c_str(), "MASS", DSTAG.c_str(), (isPbPb?"PbPb":"PP"), plotLabel.c_str(), (cut.dMuon.Pt.Min*10.0), (cut.dMuon.Pt.Max*10.0), (cut.dMuon.AbsRap.Min*10.0), (cut.dMuon.AbsRap.Max*10.0), cut.Centrality.Start, cut.Centrality.End)); gSystem->mkdir(Form("%sctauMass/%s/plot/png/", outputDir.c_str(), DSTAG.c_str()), kTRUE); cFig->SaveAs(Form("%sctauMass/%s/plot/png/PLOT_%s_%s_%s%s_pt%.0f%.0f_rap%.0f%.0f_cent%d%d.png", outputDir.c_str(), DSTAG.c_str(), "MASS", DSTAG.c_str(), (isPbPb?"PbPb":"PP"), plotLabel.c_str(), (cut.dMuon.Pt.Min*10.0), (cut.dMuon.Pt.Max*10.0), (cut.dMuon.AbsRap.Min*10.0), (cut.dMuon.AbsRap.Max*10.0), cut.Centrality.Start, cut.Centrality.End)); gSystem->mkdir(Form("%sctauMass/%s/plot/pdf/", outputDir.c_str(), DSTAG.c_str()), kTRUE); cFig->SaveAs(Form("%sctauMass/%s/plot/pdf/PLOT_%s_%s_%s%s_pt%.0f%.0f_rap%.0f%.0f_cent%d%d.pdf", outputDir.c_str(), DSTAG.c_str(), "MASS", DSTAG.c_str(), (isPbPb?"PbPb":"PP"), plotLabel.c_str(), (cut.dMuon.Pt.Min*10.0), (cut.dMuon.Pt.Max*10.0), (cut.dMuon.AbsRap.Min*10.0), (cut.dMuon.AbsRap.Max*10.0), cut.Centrality.Start, cut.Centrality.End)); cFig->Clear(); cFig->Close(); };
void printHisto( TCanvas *can , TChain *data , TChain *mc , TCut num , TCut denom , char* var , int nbins , float xmin , float xmax , char* xtitle , char* ytitle) { can->cd(); TPad *plotpad = new TPad("plotpad","plotpad",0.0,0.0,1.0,0.8); plotpad->Draw(); plotpad->cd(); float ptbin[] = {30., 40., 60. , 80. , 100. , 120. , 150. , 200 , 300 }; int nptbin = 8; //TH1F* hpass = new TH1F(Form("hpass_%i",iplot),Form("hpass_%i",iplot),nptbin,ptbin); //TH1F* hall = new TH1F(Form("hall_%i" ,iplot),Form("hall_%i" ,iplot),nptbin,ptbin); // TH1F* hpass_data = new TH1F(Form("hpass_data_%i",iplot),Form("hpass_data_%i",iplot),nbins,xmin,xmax); // TH1F* hall_data = new TH1F(Form("hall_data_%i" ,iplot),Form("hall_data_%i" ,iplot),nbins,xmin,xmax); // TH1F* hpass_mc = new TH1F(Form("hpass_mc_%i" ,iplot),Form("hpass_mc_%i" ,iplot),nbins,xmin,xmax); // TH1F* hall_mc = new TH1F(Form("hall_mc_%i" ,iplot),Form("hall_mc_%i" ,iplot),nbins,xmin,xmax); TH1F* hpass_data = new TH1F(Form("hpass_data_%i" ,iplot),Form("hpass_data_%i" ,iplot),nptbin,ptbin); TH1F* hall_data = new TH1F(Form("hall_data_%i" ,iplot),Form("hall_data_%i" ,iplot),nptbin,ptbin); TH1F* hratio_data = new TH1F(Form("hratio_data_%i" ,iplot),Form("hratio_data_%i" ,iplot),nptbin,ptbin); TH1F* hpass_mc = new TH1F(Form("hpass_mc_%i" ,iplot),Form("hpass_mc_%i" ,iplot),nptbin,ptbin); TH1F* hall_mc = new TH1F(Form("hall_mc_%i" ,iplot),Form("hall_mc_%i" ,iplot),nptbin,ptbin); TH1F* hratio_mc = new TH1F(Form("hratio_mc_%i" ,iplot),Form("hratio_mc_%i" ,iplot),nptbin,ptbin); TH1F* hsf = new TH1F(Form("hsf_%i" ,iplot),Form("hsf_%i" ,iplot),nptbin,ptbin); hpass_data->Sumw2(); hall_data->Sumw2(); hratio_data->Sumw2(); hpass_mc->Sumw2(); hall_mc->Sumw2(); hratio_mc->Sumw2(); hsf->Sumw2(); //TCanvas *can = new TCanvas(Form("can_%i",iplot),Form("can_%i",iplot),600,600); //can->cd(); data->Draw(Form("min(%s,%f)>>hpass_data_%i" , var,xmax-0.0001,iplot),denom+num); data->Draw(Form("min(%s,%f)>>hall_data_%i" , var,xmax-0.0001,iplot),denom); mc->Draw (Form("min(%s,%f)>>hpass_mc_%i" , var,xmax-0.0001,iplot),denom+num); mc->Draw (Form("min(%s,%f)>>hall_mc_%i" , var,xmax-0.0001,iplot),denom); TGraphAsymmErrors *grdata = new TGraphAsymmErrors(); grdata->BayesDivide(hpass_data,hall_data); TGraphAsymmErrors *grmc = new TGraphAsymmErrors(); grmc->BayesDivide(hpass_mc,hall_mc); // cout << "data all " << hall_data->GetBinContent(8) << endl; // cout << "data pass " << hpass_data->GetBinContent(8) << endl; // cout << "data eff " << hpass_data->GetBinContent(8) / hall_data->GetBinContent(8) << endl; // Double_t x; // Double_t y; // grdata->GetPoint(7,x,y); // cout << "data eff2 " << y << endl; gPad->SetGridx(); gPad->SetGridy(); grdata->SetMarkerColor(2); grdata->SetLineColor(2); grmc->SetMarkerColor(4); grmc->SetLineColor(4); grmc->SetMarkerStyle(25); grdata->GetXaxis()->SetRangeUser(30,300); grdata->GetYaxis()->SetRangeUser(0.8,1.0); grdata->GetXaxis()->SetTitle(xtitle); grdata->GetYaxis()->SetTitle(ytitle); grdata->Draw("AP"); grmc->Draw("sameP"); TLegend *leg = new TLegend(0.5,0.2,0.7,0.4); leg->AddEntry(grdata ,"data","lp"); leg->AddEntry(grmc ,"mc" ,"lp"); leg->SetBorderSize(1); leg->SetFillColor(0); //leg->Draw(); TLatex *t = new TLatex(); t->SetNDC(); if( TString(denom.GetTitle()).Contains("njets==0") ) t->DrawLatex(0.2,0.2,"n_{jets}=0"); if( TString(denom.GetTitle()).Contains("njets==1") ) t->DrawLatex(0.2,0.2,"n_{jets}=1"); if( TString(denom.GetTitle()).Contains("njets==2") ) t->DrawLatex(0.2,0.2,"n_{jets}=2"); if( TString(denom.GetTitle()).Contains("njets==3") ) t->DrawLatex(0.2,0.2,"n_{jets}=3"); if( TString(denom.GetTitle()).Contains("njets>=4") ) t->DrawLatex(0.2,0.2,"n_{jets}#geq4"); can->cd(); TPad *respad = new TPad("respad","respad",0.0,0.8,1.0,1.0); respad->Draw(); respad->cd(); respad->SetGridy(); // TGraphAsymmErrors* gr_ratio = (TGraphAsymmErrors*) grdata->Clone("gr_ratio"); // gr_ratio->Divide(grmc); // gr_ratio->Draw(); hratio_data->Divide(hpass_data,hall_data,1,1,"B"); hratio_mc ->Divide(hpass_mc ,hall_mc,1,1,"B"); hsf ->Divide(hratio_data,hratio_mc,1,1); hsf->GetYaxis()->SetRangeUser(0.9,1.1); hsf->GetYaxis()->SetNdivisions(3); hsf->GetYaxis()->SetLabelSize(0.2); hsf->GetXaxis()->SetLabelSize(0.0); hsf->Draw("E1"); iplot ++; }
void plotExclusion() { //CMSstyle(); setTDRStyle(); gROOT->ForceStyle(); //gStyle->SetOptStat(0); TMultiGraph *mg = new TMultiGraph("mg", ";M_{W'} (GeV);W'#rightarrowWZ Coupling"); TCanvas* c1 = new TCanvas("c1"); c1->SetLogy(1); float masses[15]; masses[0] = 200; masses[1] = 250; masses[2] = 300; masses[3] = 400; masses[4] = 500; masses[5] = 600; masses[6] = 700; masses[7] = 800; masses[8] = 900; masses[9] = 1000; masses[10] = 1100; masses[11] = 1200; masses[12] = 1300; masses[13] = 1400; masses[14] = 1500; float masses2D[30]; masses2D[0] = 200; masses2D[29] = 200; masses2D[1] = 250; masses2D[28] = 250; masses2D[2] = 300; masses2D[27] = 300; masses2D[3] = 400; masses2D[26] = 400; masses2D[4] = 500; masses2D[25] = 500; masses2D[5] = 600; masses2D[24] = 600; masses2D[6] = 700; masses2D[23] = 700; masses2D[7] = 800; masses2D[22] = 800; masses2D[8] = 900; masses2D[21] = 900; masses2D[9] = 1000; masses2D[20] = 1000; masses2D[10] = 1100; masses2D[19] = 1100; masses2D[11] = 1200; masses2D[18] = 1200; masses2D[12] = 1300; masses2D[17] = 1300; masses2D[13] = 1400; masses2D[16] = 1400; masses2D[14] = 1500; masses2D[15] = 1500; float exp[15]; float obs[15]; float exp1[30]; float exp2[30]; exp[0] = 0.258951497072; obs[0] = 0.264236507723; exp1[0] = 0.302958978755; exp1[29] = 0.221380623691; exp2[0] = 0.361484816545; exp2[29] = 0.134881244455; exp[1] = 0.238074875871; obs[1] = 0.262501951025; exp1[1] = 0.271489954939; exp1[28] = 0.212149800065; exp2[1] = 0.31212926296; exp2[28] = 0.188396377283; exp[2] = 0.203941984681; obs[2] = 0.195862072551; exp1[2] = 0.228775587519; exp1[27] = 0.15388234499; exp2[2] = 0.258549678245; exp2[27] = 0.0761613633144; exp[3] = 0.221149265622; obs[3] = 0.197161298736; exp1[3] = 0.25146417874; exp1[26] = 0.195849275574; exp2[3] = 0.302745675541; exp2[26] = 0.102178773493; exp[4] = 0.265859426326; obs[4] = 0.281814245586; exp1[4] = 0.316136059804; exp1[25] = 0.241393072817; exp2[4] = 0.39001755547; exp2[25] = 0.221096337301; exp[5] = 0.318011210571; obs[5] = 0.27969609314; exp1[5] = 0.37957804241; exp1[24] = 0.276992405418; exp2[5] = 0.447262299127; exp2[24] = 0.222377913436; exp[6] = 0.398436976666; obs[6] = 0.42176421485; exp1[6] = 0.459808375625; exp1[23] = 0.364154826684; exp2[6] = 0.537189459921; exp2[23] = 0.357480425803; exp[7] = 0.46411170267; obs[7] = 0.481806072966; exp1[7] = 0.565467804363; exp1[22] = 0.425115372019; exp2[7] = 0.672064509509; exp2[22] = 0.4120593318; exp[8] = 0.563947415859; obs[8] = 0.536922403468; exp1[8] = 0.672650081221; exp1[21] = 0.534487182571; exp2[8] = 0.808457381294; exp2[21] = 0.514649041607; exp[9] = 0.700579859433; obs[9] = 0.676280384249; exp1[9] = 0.798482092783; exp1[20] = 0.674378686191; exp2[9] = 1.0120004248; exp2[20] = 0.663954563503; exp[10] = 0.918970653344; obs[10] = 0.889845853577; exp1[10] = 1.04923440155; exp1[19] = 0.858375432352; exp2[10] = 1.24717913491; exp2[19] = 0.746731022724; exp[11] = 1.19793401961; obs[11] = 1.17653186674; exp1[11] = 1.39512272299; exp1[18] = 1.16185610477; exp2[11] = 1.62812001722; exp2[18] = 1.01020656441; exp[12] = 1.58254134376; obs[12] = 1.56834374153; exp1[12] = 1.84607923047; exp1[17] = 1.51628586669; exp2[12] = 2.18103685499; exp2[17] = 1.31304946585; exp[13] = 2.30981854338; obs[13] = 2.30117260535; exp1[13] = 2.42189837009; exp1[16] = 2.13395645197; exp2[13] = 2.92307163497; exp2[16] = 2.04337780276; exp[14] = 3.19375101546; obs[14] = 3.16458908761; exp1[14] = 3.28113723449; exp1[15] = 2.99139611866; exp2[14] = 4.07139223438; exp2[15] = 2.84407249777; TGraph* grExp = new TGraph(15, masses, exp); TGraph* grObs = new TGraph(15, masses, obs); TGraph* grExp1 = new TGraph(30, masses2D, exp1); TGraph* grExp2 = new TGraph(30, masses2D, exp2); grExp->SetLineColor(kBlack); grExp->SetMarkerColor(kBlack); grExp->SetLineStyle(kDashed); grObs->SetLineColor(kBlack); grObs->SetMarkerColor(kBlack); grObs->SetMarkerStyle(20); grExp1->SetFillStyle(1001); grExp1->SetFillColor(kGreen); grExp2->SetFillStyle(1001); grExp2->SetFillColor(kYellow); mg->Add(grExp2, "F"); mg->Add(grExp1, "F"); mg->Add(grExp, "L"); mg->Add(grObs, "P"); mg->SetMinimum(0.1); mg->SetMaximum(10.); mg->Draw("a"); TLine* line = new TLine(200, 1, 1500, 1); line->Draw(); TLegend* leg = new TLegend(0.2, 0.62, 0.58, 0.92); leg->SetTextSize(0.05); leg->SetTextFont(42); leg->AddEntry(grObs, "Obs. Limit", "p"); leg->AddEntry(grExp, "Exp. Limit", "l"); leg->AddEntry(grExp1, "Exp. #pm 1#sigma", "f"); leg->AddEntry(grExp2, "Exp. #pm 2#sigma", "f"); leg->AddEntry(line, "W'_{SSM}#rightarrowWZ Coupling", "l"); leg->SetBorderSize(0); leg->SetFillColor(0); leg->Draw(); TLatex latexLabel; latexLabel.SetNDC(); latexLabel.SetTextSize(0.05); latexLabel.SetTextFont(42); latexLabel.DrawLatex(0.33, 0.96, "CMS Preliminary 2011"); latexLabel.DrawLatex(0.67, 0.38, "#sqrt{s} = 7 TeV"); latexLabel.DrawLatex(0.62, 0.25, Form("#intL dt = %.2f fb^{-1}",4.98)); c1->RedrawAxis(); c1->Print("wprimewz_limits.C"); c1->Print("wprimewz_limits.pdf"); c1->Print("wprimewz_limits.png"); }
void plotDistribution( TChain* data , TChain *mc , TCut sel , TCut vtxweight , char* var , int nbins , float xmin , float xmax , char* xtitle , char* plottitle = "" , bool printplot = false , bool residual = false , bool log = false ) { //-------------------------------------- // define histograms and TGraphs //-------------------------------------- TH1F* hdata = new TH1F(Form("hdata_%i" , iplot),Form("hdata_%i" , iplot),nbins,xmin,xmax); TH1F* hmc = new TH1F(Form("hmc_%i" , iplot),Form("hmc_%i" , iplot),nbins,xmin,xmax); TH1F* hmc_novtx = new TH1F(Form("hmc_novtx_%i" , iplot),Form("hmc_novtx%i" , iplot),nbins,xmin,xmax); hdata->Sumw2(); hmc->Sumw2(); TGraphAsymmErrors* grdata = new TGraphAsymmErrors(); TGraphAsymmErrors* grmc = new TGraphAsymmErrors(); TH1F* hdata_denom = new TH1F(Form("hdata_denom_%i",iplot),"",nbins,xmin,xmax); TH1F* hmc_denom = new TH1F(Form("hmc_denom_%i" ,iplot),"",nbins,xmin,xmax); //-------------------------------------- // set up canvas and pads //-------------------------------------- TCanvas *can = new TCanvas(Form("can_%i",iplot),Form("can_%i",iplot),600,600); can->cd(); if( log ) gPad->SetLogy(); TPad *mainpad = new TPad("mainpad","mainpad",0.0,0.0,1.0,0.8); if( residual ) { mainpad->Draw(); mainpad->cd(); if( log ) mainpad->SetLogy(); } //-------------------------------------- // fill histos and TGraphs //-------------------------------------- data->Draw(Form("min(%s,%f)>>hdata_%i" , var,xmax-0.0001,iplot),sel); mc ->Draw(Form("min(%s,%f)>>hmc_%i" , var,xmax-0.0001,iplot),sel*vtxweight); mc ->Draw(Form("min(%s,%f)>>hmc_novtx_%i" , var,xmax-0.0001,iplot),sel); for( int ibin = 1 ; ibin <= nbins ; ibin++ ) { hdata_denom->SetBinContent(ibin,hdata->Integral()); hmc_denom->SetBinContent(ibin,hmc->Integral()); } grdata->BayesDivide(hdata,hdata_denom); grmc->BayesDivide(hmc_novtx,hmc_denom); //-------------------------------------- // get efficiencies and errors //-------------------------------------- /* float ndata1 = (float) hdata->GetBinContent(1); float ndata = (float) hdata->Integral(); float effdata = 1-ndata1 / ndata; // TGraphAsymmErrors* grdata_temp = new TGraphAsymmErrors(); // TH1F* hdata_num_temp = new TH1F(Form("hdata_num_temp_%i",iplot),"",1,0,1); // TH1F* hdata_den_temp = new TH1F(Form("hdata_den_temp_%i",iplot),"",1,0,1); // hdata_num_temp->SetBinContent(1,ndata-ndata1); // hdata_den_temp->SetBinContent(1,ndata); // grdata_temp->BayesDivide(hdata_num_temp,hdata_den_temp); //float effdataerr = sqrt(ndata1) / ndata; float effdataerr = 0.5 * ( grdata->GetErrorYlow(0) + grdata->GetErrorYhigh(0) ); //float effdataerr = 0.5 * ( grdata_temp->GetErrorYlow(0) + grdata_temp->GetErrorYhigh(0) ); float nmc1 = (float) hmc->GetBinContent(1); float nmc = (float) hmc->Integral(); float effmc = 1-nmc1 / nmc; //float effmcerr = hmc->GetBinError(1) / nmc; float effmcerr = 0.5 * ( grmc->GetErrorYlow(0) + grmc->GetErrorYhigh(0) ); float datatot = hdata->Integral(); float mctot = hmc->Integral(); cout << endl; cout << plottitle << endl; cout << "Data eff " << Form("%.2f +/- %.3f",effdata,effdataerr) << endl; cout << "MC eff " << Form("%.2f +/- %.3f",effmc ,effmcerr) << endl; cout << "Data/MC " << Form("%.2f +/- %.2f",ratio ,ratioerr) << endl; */ float ndata = hdata->Integral(); float ndata1 = hdata->Integral(2,20); float ndata2 = hdata->Integral(3,20); float ndata3 = hdata->Integral(4,20); float ndata4 = hdata->Integral(5,20); float ndata5 = hdata->Integral(6,20); float nmc = hmc->Integral(); float nmc1 = hmc->Integral(2,20); float nmc2 = hmc->Integral(3,20); float nmc3 = hmc->Integral(4,20); float nmc4 = hmc->Integral(5,20); float nmc5 = hmc->Integral(6,20); float effdata1 = ndata1/ndata; float effdata2 = ndata2/ndata; float effdata3 = ndata3/ndata; float effdata4 = ndata4/ndata; float effdata5 = ndata5/ndata; float effmc1 = nmc1/nmc; float effmc2 = nmc2/nmc; float effmc3 = nmc3/nmc; float effmc4 = nmc4/nmc; float effmc5 = nmc5/nmc; float effdata1err = getBinomialError(ndata1,ndata); float effdata2err = getBinomialError(ndata2,ndata); float effdata3err = getBinomialError(ndata3,ndata); float effdata4err = getBinomialError(ndata4,ndata); float effdata5err = getBinomialError(ndata5,ndata); float effmc1err = getBinomialError(nmc1,nmc); float effmc2err = getBinomialError(nmc2,nmc); float effmc3err = getBinomialError(nmc3,nmc); float effmc4err = getBinomialError(nmc4,nmc); float effmc5err = getBinomialError(nmc5,nmc); float ratio1 = effdata1/effmc1; float ratio2 = effdata2/effmc2; float ratio3 = effdata3/effmc3; float ratio4 = effdata4/effmc4; float ratio5 = effdata5/effmc5; float ratio1err = ratio1 * sqrt(pow(effdata1err/effdata1,2)+pow(effmc1err/effmc1,2)); float ratio2err = ratio2 * sqrt(pow(effdata2err/effdata2,2)+pow(effmc2err/effmc2,2)); float ratio3err = ratio3 * sqrt(pow(effdata3err/effdata3,2)+pow(effmc3err/effmc3,2)); float ratio4err = ratio4 * sqrt(pow(effdata4err/effdata4,2)+pow(effmc4err/effmc4,2)); float ratio5err = ratio5 * sqrt(pow(effdata5err/effdata5,2)+pow(effmc5err/effmc5,2)); cout << endl << endl << plottitle << endl; int left = 20; // char* delimstart = "|"; // char* delim = "|"; // char* delimend = "|"; // char* pm = "+/-"; char* delimstart = ""; char* delim = "&"; char* delimend = "\\\\"; char* pm = "$\\pm$"; cout << delimstart << setw(10) << "" << setw(4) << delim << setw(left) << "$>$ 1 GeV" << setw(4) << delim << setw(left) << "$>$ 2 GeV" << setw(4) << delim << setw(left) << "$>$ 3 GeV" << setw(4) << delim << setw(left) << "$>$ 4 GeV" << setw(4) << delim << setw(left) << "$>$ 5 GeV" << setw(4) << delimend << endl; cout << delimstart << setw(10) << "data" << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata1,pm,effdata1err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata2,pm,effdata2err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata3,pm,effdata3err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata4,pm,effdata4err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effdata5,pm,effdata5err) << setw(4) << delimend << endl; cout << delimstart << setw(10) << "mc" << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc1,pm,effmc1err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc2,pm,effmc2err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc3,pm,effmc3err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc4,pm,effmc4err) << setw(4) << delim << setw(left) << Form("%.3f %s %.4f",effmc5,pm,effmc5err) << setw(4) << delimend << endl; cout << delimstart << setw(10) << "data/mc" << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio1,pm,ratio1err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio2,pm,ratio2err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio3,pm,ratio3err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio4,pm,ratio4err) << setw(4) << delim << setw(left) << Form("%.2f %s %.2f",ratio5,pm,ratio5err) << setw(4) << delimend << endl; //-------------------------------------- // draw stuff //-------------------------------------- hdata->Scale(1.0/hdata->Integral()); hmc->Scale(1.0/hmc->Integral()); if( log ) hmc->GetYaxis()->SetRangeUser(0.0001,5); else hmc->GetYaxis()->SetRangeUser(0.0,1); hmc->GetXaxis()->SetTitle(xtitle); hmc->SetLineColor(2); hmc->SetMarkerColor(2); hmc->DrawNormalized("hist"); hmc->DrawNormalized("sameE1"); hdata->SetLineColor(4); hdata->SetMarkerColor(4); hdata->Draw("sameE1"); grdata->SetLineColor(6); grmc->SetLineColor(7); //grdata->Draw("sameP"); //grmc->Draw("sameP"); TLegend *leg = new TLegend(0.6,0.7,0.8,0.9); leg->AddEntry(hdata , "data" , "lp"); leg->AddEntry(hmc , "MC" , "lp"); leg->SetBorderSize(0); leg->SetFillColor(0); leg->Draw(); TLatex *t = new TLatex(); t->SetNDC(); if( TString(plottitle).Contains("el") ) t->DrawLatex(0.6,0.6,"electrons"); if( TString(plottitle).Contains("mu") ) t->DrawLatex(0.6,0.6,"muons"); if( TString(plottitle).Contains("0j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 0"); if( TString(plottitle).Contains("1j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 1"); if( TString(plottitle).Contains("2j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 2"); if( TString(plottitle).Contains("3j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 3"); if( TString(plottitle).Contains("4j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 4"); //-------------------------------------- // draw residual plots //-------------------------------------- if( residual ) { can->cd(); TPad *respad = new TPad("respad","respad",0.0,0.8,1.0,1.0); respad->Draw(); respad->cd(); respad->SetGridy(); TH1F* hratio = (TH1F*) hdata->Clone(Form("hratio_%i",iplot)); hratio->Divide(hmc); hratio->SetMarkerColor(1); hratio->SetLineColor(1); hratio->Draw(); hratio->GetYaxis()->SetRangeUser(0.5,1.5); hratio->GetYaxis()->SetNdivisions(5); hratio->GetYaxis()->SetLabelSize(0.2); hratio->GetXaxis()->SetLabelSize(0.0); TLine line; line.DrawLine(xmin,1.0,xmax,1.0); } //data->Scan("run:lumi:event:probe->pt():probe->eta():tkisonew:met:mt:njets:nbl:nbm",sel+"tkisonew>20"); //data->Scan("run:lumi:event:probe->pt():probe->eta():tkisonew:met:mt:njets:nbl:nbm",sel); if( printplot ) can->Print(Form("plots/%s.pdf",plottitle)); iplot++; // TCanvas *c2 = new TCanvas(); // c2->cd(); // grdata->Draw("AP"); }
//void plot_Asymptotic(string outputname) //void plot_Asymptotic() TGraphAsymmErrors * plot_Asymptotic(TString dir_path ,TGraphAsymmErrors *grmedian_cls ) //void plot_Asymptotic( TGraphAsymmErrors *grmedian_cls ) { string outputname = "counting"; bool useNewStyle = true; if (useNewStyle) setFPStyle(); // gROOT->LoadMacro("CMS_lumi.C"); TFile *fFREQ[nXm]; TTree *t[nXm]; // int Xmass[nXm]={800,900,1000,1100,1200,1300,1400,1500,1600,1700,1800,1900,2000}; int Xmass[nXm]={800,1000,1200,1400,1600,1800,2000,2500,3000,3500,4000}; //int Xmass[nXm]={800,900,1100,1400,1700,1900}; vector<double> v_mh, v_median, v_68l, v_68h, v_95l, v_95h, v_obs; for(int n=0;n<nXm;n++) { char limitfile[200]; // if(outputname.find("counting")!= std::string::npos) sprintf(limitfile,"Datacards_txt_files/YuHsiang_DY_h_ele_1st_pT_cut_115/higgsCombineTest.Asymptotic.mH%d.root",Xmass[n]); if(outputname.find("counting")!= std::string::npos) sprintf(limitfile,"higgsCombineTest.Asymptotic.mH%d.root",Xmass[n]); // const string dirLimitFile = "Datacards_txt_files/YuHsiang_DY_h_ele_1st_pT_cut_115/"; TString LimitFile = limitfile; LimitFile = dir_path + LimitFile; // LimitFile = "Datacards_txt_files/YuHsiang_DY_h_ele_1st_pT_cut_115/" + LimitFile; // limitfile = "Datacards_txt_files/YuHsiang_DY_h_ele_1st_pT_cut_115/" + limitfile; // limitfile = dirLimitFile + limitfile; // fFREQ[n] = new TFile(limitfile, "READ"); fFREQ[n] = new TFile( LimitFile , "READ"); cout<<" Read limit file: "<<limitfile<<endl; t[n] = (TTree*)fFREQ[n]->Get("limit"); double mh, limit; float quant; t[n]->SetBranchAddress("mh", &mh); t[n]->SetBranchAddress("limit", &limit); t[n]->SetBranchAddress("quantileExpected", &quant); //int iMH = 0; //while (iMH < n) { for (int i = 0; i < t[n]->GetEntries(); i++) { t[n]->GetEntry(i); cout<<" quant : "<<quant<<" limit : " <<limit<<endl; /// Map: mh --> observed, 95low, 68low, expected, 68hi, 95hi, xsec if (quant > -1.01 && quant < -0.99) { v_obs.push_back(limit); } else if (quant > 0.02 && quant < 0.03) { v_95l.push_back(limit); } else if (quant > 0.15 && quant < 0.17) { v_68l.push_back(limit); } else if (quant > 0.49 && quant < 0.51) { v_median.push_back(limit); v_mh.push_back(mh); } else if (quant > 0.83 && quant < 0.85) { v_68h.push_back(limit); } else if (quant > 0.965 && quant < 0.98) { v_95h.push_back(limit); } else { cout << "Error! Quantile = " << quant << endl; } } // iMH++; // }//end while loop }//file loop //string xsect_file_th = dirXSect + "xsec_Zhllbb.txt"; //string xsect_file_th = dirXSect + "13TeV_xsec_Zhllbb.txt"; string xsect_file_th = dirXSect + "13TeV_xsec_Zh.txt"; ifstream xsect_file(xsect_file_th.c_str(), ios::in); if (! xsect_file.is_open()) { cout << "Failed to open file with xsections: " << xsect_file_th << endl; } float mH, CS; vector<float> v_mhxs, v_xs, v_toterrh, v_toterrl; while (xsect_file.good()) { xsect_file >> mH >> CS; v_mhxs.push_back(mH); v_xs.push_back(CS);//*BRZZ2l2q (multyply by BRZZ2l2q only if exp rates in cards are for process X->ZZ->2l2q !) //unavailable theory errors for graviton float tot_err_p = 0.0; float tot_err_m = 0.0; v_toterrh.push_back(1.0 + (tot_err_p)); v_toterrl.push_back(1.0 - (tot_err_m)); } cout << "Size of theory xsects vector" << v_mhxs.size() << endl; xsect_file.close(); /////////////////////////// // END THEORY INPUT PART // /////////////////////////// /// Here we multiply the limits in terms of signal strength by the cross-section. /// There are also some hooks to exclude sick mass points. double mass[nXm], obs_lim_cls[nXm]; double medianD[nXm]; double up68err[nXm], down68err[nXm], up95err[nXm], down95err[nXm]; double xs[nXm], xs_uperr[nXm], xs_downerr[nXm]; double xs10[nXm], xs10_uperr[nXm], xs10_downerr[nXm]; int nMassEff = 0; for (int im = 0; im < nXm; im++) { double fl_xs = double(v_xs.at(im)); //*1000.0 double fl_xs10 = 0;//double(v_xs10.at(ind)); //*1000.0 fl_xs = (fl_xs); fl_xs10 = (fl_xs10); mass[nMassEff] = Xmass[im]; /// This is the part where we multiply the limits in terms of signal strength /// by the cross-section, in order to have limits in picobarns. //std::cerr << mass[nMassEff] << ":" << v_obs.at(im) << std::endl; obs_lim_cls[nMassEff] = v_obs.at(im) * fl_xs; medianD[nMassEff] = v_median.at(im) * fl_xs; up68err[nMassEff] = (v_68h.at(im) - v_median.at(im)) * fl_xs; down68err[nMassEff] = (v_median.at(im) - v_68l.at(im)) * fl_xs; //scale factor 100 for making the xsect visible xs[nMassEff] = fl_xs; //*100.0; xs_uperr[nMassEff] = double(v_toterrh.at(im)) * xs[nMassEff] - xs[nMassEff]; xs_downerr[nMassEff] = xs[nMassEff] - double(v_toterrl.at(im)) * xs[nMassEff]; xs10[nMassEff] = fl_xs10; //*100.0; xs10_uperr[nMassEff] = double(v_toterrh.at(im)) * xs10[nMassEff] - xs10[nMassEff]; xs10_downerr[nMassEff] = xs10[nMassEff] - double(v_toterrl.at(im)) * xs10[nMassEff]; up95err[nMassEff] = (v_95h.at(im) - v_median.at(im)) * fl_xs; down95err[nMassEff] = (v_median.at(im) - v_95l.at(im)) * fl_xs; cout<<"fl_xs:"<<fl_xs<<" v_obs"<<v_obs.at(im)<<" obs_lim_cls: "<<obs_lim_cls[nMassEff] <<medianD[nMassEff] <<" mass: "<<mass[nMassEff]<<endl; nMassEff++; }//end loop over im (mass points) /// The TGraphs themselves. //cout<<"Working on TGraph"<<endl; TGraphAsymmErrors *grobslim_cls = new TGraphAsymmErrors(nMassEff, mass, obs_lim_cls); grobslim_cls->SetName("LimitObservedCLs"); // TGraphAsymmErrors *grmedian_cls = new TGraphAsymmErrors(nMassEff, mass, medianD); grmedian_cls = new TGraphAsymmErrors(nMassEff, mass, medianD); grmedian_cls->SetName("LimitExpectedCLs"); TGraphAsymmErrors *gr68_cls = new TGraphAsymmErrors(nMassEff, mass, medianD, 0, 0, down68err, up68err); gr68_cls->SetName("Limit68CLs"); TGraphAsymmErrors *gr95_cls = new TGraphAsymmErrors(nMassEff, mass, medianD, 0, 0, down95err, up95err); gr95_cls->SetName("Limit95CLs"); // TGraphAsymmErrors *grthSM=new TGraphAsymmErrors(nMassEff1,mass1,xs,0,0,0,0);//xs_downerr,xs_uperr); TGraph *grthSM=new TGraph(nMassEff,mass,xs);//xs_downerr,xs_uperr); /// For the time being we have to do it like this, given that /// the cards and the limits were made with the old, wrong xsects. // TGraph *grthSM10 = new TGraph(35); // grthSM10->SetPoint(0, 600, 7.1185E-03); // grthSM10->SetPoint(1, 650, 4.1893E-03); // grthSM10->SetPoint(2, 700, 2.5592E-03); // grthSM10->SetPoint(3, 750, 1.6182E-03); // grthSM10->SetPoint(4, 800, 1.0564E-03); // grthSM10->SetPoint(5, 850, 7.0295E-04); // grthSM10->SetPoint(6, 900, 4.7877E-04); // grthSM10->SetPoint(7, 950, 3.3017E-04); // grthSM10->SetPoint(8, 1000, 2.3212E-04); // grthSM10->SetPoint(9, 1050, 1.6574E-04); // grthSM10->SetPoint(10, 1100, 1.1917E-04); // grthSM10->SetPoint(11, 1150, 8.6629E-05); // grthSM10->SetPoint(12, 1200, 6.3987E-05); // grthSM10->SetPoint(13, 1250, 4.7353E-05); // grthSM10->SetPoint(14, 1300, 3.5511E-05); // grthSM10->SetPoint(15, 1350, 2.6631E-05); // grthSM10->SetPoint(16, 1400, 2.0199E-05); // grthSM10->SetPoint(17, 1450, 1.5333E-05); // grthSM10->SetPoint(18, 1500, 1.1758E-05); // grthSM10->SetPoint(19, 1550, 9.0363E-06); // grthSM10->SetPoint(20, 1600, 6.9870E-06); // grthSM10->SetPoint(21, 1650, 5.4316E-06); // grthSM10->SetPoint(22, 1700, 4.2252E-06); // grthSM10->SetPoint(23, 1750, 3.3172E-06); // grthSM10->SetPoint(24, 1800, 2.6083E-06); // grthSM10->SetPoint(25, 1850, 2.0499E-06); // grthSM10->SetPoint(26, 1900, 1.6186E-06); // grthSM10->SetPoint(27, 1950, 1.2799E-06); // grthSM10->SetPoint(28, 2000, 1.0205E-06); // grthSM10->SetPoint(29, 2050, 8.0867E-07); // grthSM10->SetPoint(30, 2100, 6.4555E-07); // grthSM10->SetPoint(31, 2150, 5.1755E-07); // grthSM10->SetPoint(32, 2200, 4.1408E-07); // grthSM10->SetPoint(33, 2250, 3.3170E-07); // grthSM10->SetPoint(34, 2300, 2.6637E-07); // grthSM10->SetPoint(35, 2350, 2.1366E-07); // grthSM10->SetPoint(36, 2400, 1.7285E-07); // grthSM10->SetPoint(37, 2450, 1.3896E-07); // grthSM10->SetPoint(38, 2500, 1.1238E-07); // if (!isZZChannel) { // grthSM10->SetPoint(0, 800, 2.0523E-03); // grthSM10->SetPoint(1, 850, 1.3726E-03); // grthSM10->SetPoint(2, 900, 9.3786E-04); // grthSM10->SetPoint(3, 950, 6.4928E-04); // grthSM10->SetPoint(4, 1000, 4.5618E-04); // grthSM10->SetPoint(5, 1050, 3.2571E-04); // grthSM10->SetPoint(6, 1100, 2.3543E-04); // grthSM10->SetPoint(7, 1150, 1.7157E-04); // grthSM10->SetPoint(8, 1200, 1.2611E-04); // grthSM10->SetPoint(9, 1250, 9.3461E-05); // grthSM10->SetPoint(10, 1300, 6.9899E-05); // grthSM10->SetPoint(11, 1350, 5.2749E-05); // grthSM10->SetPoint(12, 1400, 4.0048E-05); // grthSM10->SetPoint(13, 1450, 3.0363E-05); // grthSM10->SetPoint(14, 1500, 2.3324E-05); // grthSM10->SetPoint(15, 1550, 1.8008E-05); // grthSM10->SetPoint(16, 1600, 1.3876E-05); // grthSM10->SetPoint(17, 1650, 1.0812E-05); // grthSM10->SetPoint(18, 1700, 8.4385E-06); // grthSM10->SetPoint(19, 1750, 6.5972E-06); // grthSM10->SetPoint(20, 1800, 5.1608E-06); // grthSM10->SetPoint(21, 1850, 4.0824E-06); // grthSM10->SetPoint(22, 1900, 3.2292E-06); // grthSM10->SetPoint(23, 1950, 2.5502E-06); // grthSM10->SetPoint(24, 2000, 2.0281E-06); // grthSM10->SetPoint(25, 2050, 1.6179E-06); // grthSM10->SetPoint(26, 2100, 1.2893E-06); // grthSM10->SetPoint(27, 2150, 1.0313E-06); // grthSM10->SetPoint(28, 2200, 8.2293E-07); // grthSM10->SetPoint(29, 2250, 6.6187E-07); // grthSM10->SetPoint(30, 2300, 5.3108E-07); // grthSM10->SetPoint(31, 2350, 4.2755E-07); // grthSM10->SetPoint(32, 2400, 3.4315E-07); // grthSM10->SetPoint(33, 2450, 2.7803E-07); // grthSM10->SetPoint(34, 2500, 2.2432E-07); // } grthSM->SetName("SMXSection"); // TGraphAsymmErrors *grthSM10=new TGraphAsymmErrors(nMassEff1,mass1,xs10,0,0,0,0); TGraph *grthSM10=new TGraph(nMassEff,mass,xs10); // TGraph *grthSM = new TGraph(35); // grthSM->SetPoint(0, 600, 4.4387E-02); // grthSM->SetPoint(1, 650, 2.6088E-02); // grthSM->SetPoint(2, 700, 1.5907E-02); // grthSM->SetPoint(3, 750, 1.0045E-02); // grthSM->SetPoint(4, 800, 6.5582E-03); // grthSM->SetPoint(5, 850, 4.3560E-03); // grthSM->SetPoint(6, 900, 2.9701E-03); // grthSM->SetPoint(7, 950, 2.0553E-03); // grthSM->SetPoint(8, 1000, 1.4410E-03); // grthSM->SetPoint(9, 1050, 1.0283E-03); // grthSM->SetPoint(10, 1100, 7.3979E-04); // grthSM->SetPoint(11, 1150, 5.4086E-04); // grthSM->SetPoint(12, 1200, 3.9717E-04); // grthSM->SetPoint(13, 1250, 2.9347E-04); // grthSM->SetPoint(14, 1300, 2.1957E-04); // grthSM->SetPoint(15, 1350, 1.6507E-04); // grthSM->SetPoint(16, 1400, 1.2514E-04); // grthSM->SetPoint(17, 1450, 9.5937E-05); // grthSM->SetPoint(18, 1500, 7.3300E-05); // grthSM->SetPoint(19, 1550, 5.6376E-05); // grthSM->SetPoint(20, 1600, 4.3715E-05); // grthSM->SetPoint(21, 1650, 3.3834E-05); // grthSM->SetPoint(22, 1700, 2.6389E-05); // grthSM->SetPoint(23, 1750, 2.0691E-05); // grthSM->SetPoint(24, 1800, 1.6259E-05); // grthSM->SetPoint(25, 1850, 1.2809E-05); // grthSM->SetPoint(26, 1900, 1.0131E-05); // grthSM->SetPoint(27, 1950, 8.0235E-06); // grthSM->SetPoint(28, 2000, 6.3711E-06); // grthSM->SetPoint(29, 2050, 5.0725E-06); // grthSM->SetPoint(30, 2100, 4.0513E-06); // grthSM->SetPoint(31, 2150, 3.2469E-06); // grthSM->SetPoint(32, 2200, 2.6006E-06); // grthSM->SetPoint(33, 2250, 2.0899E-06); // grthSM->SetPoint(34, 2300, 1.6810E-06); // grthSM->SetPoint(35, 2350, 1.3586E-06); // grthSM->SetPoint(36, 2400, 1.0964E-06); // grthSM->SetPoint(37, 2450, 8.8416E-07); // grthSM->SetPoint(38, 2500, 7.1662E-07); // if (!isZZChannel) { // grthSM->SetPoint(0, 800, 1.2713E-02); // grthSM->SetPoint(1, 850, 8.5015E-03); // grthSM->SetPoint(2, 900, 5.8030E-03); // grthSM->SetPoint(3, 950, 4.0261E-03); // grthSM->SetPoint(4, 1000, 2.8289E-03); // grthSM->SetPoint(5, 1050, 2.0214E-03); // grthSM->SetPoint(6, 1100, 1.4580E-03); // grthSM->SetPoint(7, 1150, 1.0625E-03); // grthSM->SetPoint(8, 1200, 7.8079E-04); // grthSM->SetPoint(9, 1250, 5.7987E-04); // grthSM->SetPoint(10, 1300, 4.3448E-04); // grthSM->SetPoint(11, 1350, 3.2719E-04); // grthSM->SetPoint(12, 1400, 2.4778E-04); // grthSM->SetPoint(13, 1450, 1.8896E-04); // grthSM->SetPoint(14, 1500, 1.4543E-04); // grthSM->SetPoint(15, 1550, 1.1200E-04); // grthSM->SetPoint(16, 1600, 8.6492E-05); // grthSM->SetPoint(17, 1650, 6.7405E-05); // grthSM->SetPoint(18, 1700, 5.2283E-05); // grthSM->SetPoint(19, 1750, 4.1121E-05); // grthSM->SetPoint(20, 1800, 3.2378E-05); // grthSM->SetPoint(21, 1850, 2.5507E-05); // grthSM->SetPoint(22, 1900, 2.0215E-05); // grthSM->SetPoint(23, 1950, 1.6020E-05); // grthSM->SetPoint(24, 2000, 1.2714E-05); // grthSM->SetPoint(25, 2050, 1.0133E-05); // grthSM->SetPoint(26, 2100, 8.0785E-06); // grthSM->SetPoint(27, 2150, 6.4583E-06); // grthSM->SetPoint(28, 2200, 5.1774E-06); // grthSM->SetPoint(29, 2250, 4.1620E-06); // grthSM->SetPoint(30, 2300, 3.3440E-06); // grthSM->SetPoint(31, 2350, 2.7018E-06); // grthSM->SetPoint(32, 2400, 2.1753E-06); // grthSM->SetPoint(33, 2450, 1.7626E-06); // grthSM->SetPoint(34, 2500, 1.4225E-06); // } grthSM10->SetName("SMXSection_2nd"); // double fr_left = 590.0, fr_down = 1E-5, fr_right = 2000.0, fr_up = 0.5; // double fr_left = 590.0, fr_down = 5E-5, fr_right = 2000.0, fr_up = 5; double fr_left = 500.0, fr_down = 5E-7, fr_right = 4500.0, fr_up = 5E-1; TCanvas *cMCMC = new TCanvas("c_lim_Asymptotic", "canvas with limits for Asymptotic CLs", 630, 600); cMCMC->cd(); cMCMC->SetGridx(1); cMCMC->SetGridy(1); // draw a frame to define the range TH1F *hr = cMCMC->DrawFrame(fr_left, fr_down, fr_right, fr_up, ""); TString VV = "ZH"; hr->SetXTitle("M_{X} [GeV]"); hr->SetYTitle("#sigma_{95%} [pb]"); // #rightarrow 2l2q gr95_cls->SetFillColor(kYellow); gr95_cls->SetFillStyle(1001);//solid gr95_cls->SetLineStyle(kDashed); gr95_cls->SetLineWidth(3); gr95_cls->GetXaxis()->SetTitle("M_{V'} [GeV]"); gr95_cls->GetYaxis()->SetTitle("#sigma_{95%} #times BR(V' #rightarrow " + VV + ") [pb]"); // #rightarrow 2l2q gr95_cls->GetXaxis()->SetRangeUser(fr_left, fr_right); // gr95_cls->Draw("3"); gr68_cls->SetFillColor(kGreen); gr68_cls->SetFillStyle(1001);//solid gr68_cls->SetLineStyle(kDashed); gr68_cls->SetLineWidth(3); // gr68_cls->Draw("3same"); grmedian_cls->GetXaxis()->SetTitle("M_{V'} [GeV]"); grmedian_cls->GetYaxis()->SetTitle("#sigma_{95%} #times BR(V' #rightarrow " + VV + ") [pb]"); // #rightarrow 2l2q grmedian_cls->SetMarkerStyle(24);//25=hollow squre grmedian_cls->SetMarkerColor(kBlack); grmedian_cls->SetLineStyle(2); grmedian_cls->SetLineWidth(3); grmedian_cls->SetMinimum(0.0); grmedian_cls->SetMaximum(8.0); grobslim_cls->SetMarkerColor(kBlack); grobslim_cls->SetMarkerStyle(21);//24=hollow circle grobslim_cls->SetMarkerSize(1.0); grobslim_cls->SetLineStyle(1); grobslim_cls->SetLineWidth(3); grthSM->SetLineColor(kRed); grthSM->SetLineWidth(2); grthSM->SetLineStyle(kSolid); grthSM->SetFillColor(kRed); grthSM->SetFillStyle(3344); grthSM10->SetLineColor(kRed); grthSM10->SetLineWidth(2); grthSM10->SetLineStyle(1); grthSM10->SetLineStyle(kDashed); grthSM10->SetFillColor(kRed); grthSM10->SetFillStyle(3344); // grthSM->Draw("L3"); grmedian_cls->Draw("L"); // grobslim_cls->Draw("LP"); /* TFile *fUnMPlus=new TFile("AsymptoticCLs_UnmatchedPlus_TGraph.root","READ"); TGraph *grobs_ump=(TGraph*)fUnMPlus->Get("LimitObservedCLs"); TGraph *grmedian_ump=(TGraph*)fUnMPlus->Get("LimitExpectedCLs"); grobs_ump->SetName("LimitObs_UnmatchedPlus"); grmedian_ump->SetName("LimitExp_UnmatchedPlus"); grobs_ump->SetMarkerColor(kBlue); grobs_ump->SetLineColor(kBlue); grobs_ump->SetMarkerStyle(25); grmedian_ump->SetMarkerColor(kBlue); grmedian_ump->SetLineColor(kBlue); grmedian_ump->SetMarkerStyle(25); grobs_ump->Draw("P"); grmedian_ump->Draw("L"); */ //draw grid on top of limits gStyle->SetOptStat(0); TH1D* postGrid = new TH1D("postGrid", "", 1, fr_left, fr_right); postGrid->GetYaxis()->SetRangeUser(fr_down, fr_up); postGrid->Draw("AXIGSAME"); //more graphics TLegend *leg = new TLegend(.20, .2, .75, .35); // TLegend *leg = new TLegend(.35,.71,.90,.90); leg->SetFillColor(0); leg->SetShadowColor(0); leg->SetTextFont(42); leg->SetTextSize(0.03); // leg->SetBorderMode(0); leg->AddEntry(grmedian_cls, "CL_{S} Expected limit central value", "L"); // leg->AddEntry(grobslim_cls, "Frequentist CL_{S} Observed", "LP"); // leg->AddEntry(gr68_cls, "Frequentist CL_{S} Expected #pm 1#sigma", "LF"); // leg->AddEntry(gr95_cls, "Frequentist CL_{S} Expected #pm 2#sigma", "LF"); // leg->AddEntry(grthSM, "#sigma_{TH}", "L"); // leg->AddEntry(grthSM, "#sigma_{TH} x BR(Z' #rightarrow " + VV + "), #tilde{k}=0.50", "L"); // #rightarrow 2l2q // leg->AddEntry(grthSM10, "#sigma_{TH} x BR(Z' #rightarrow " + VV + "), #tilde{k}=0.20", "L"); // #rightarrow 2l2q leg->Draw(); TLatex * latex = new TLatex(); latex->SetNDC(); latex->SetTextSize(0.04); latex->SetTextAlign(31); latex->SetTextAlign(11); // align left // latex->DrawLatex(0.18, 0.96, "CMS preliminary 2012"); // latex->DrawLatex(0.60, 0.96, Form("%.1f fb^{-1} at #sqrt{s} = 8 TeV", intLumi)); latex->DrawLatex(0.18, 0.96, "CMS preliminary 2015"); latex->DrawLatex(0.60, 0.96, Form("%.1f fb^{-1} at #sqrt{s} = 13 TeV", intLumi)); // cMCMC->RedrawAxis(""); gPad->RedrawAxis(""); // hr->GetYaxis()->DrawClone(); cMCMC->Update(); char fnam[50]; //string outputname="shape2d"; //string outputname="shape1d"; //string outputname="counting"; sprintf(fnam, "XZHllbb_%s_Asymptotic.root",outputname.data() ); // cMCMC->SaveAs(fnam); //sprintf(fnam, "XZHllbb_%s_Asymptotic.eps", outputname.data()); //cMCMC->SaveAs(fnam); sprintf(fnam, "XZHllbb_%s_Asymptotic.png", outputname.data()); // cMCMC->SaveAs(fnam); //sprintf(fnam, "XZHllbb_%s_Asymptotic.pdf", outputname.data()); //cMCMC->SaveAs(fnam); gPad->SetLogy(); //sprintf(fnam, "XZHllbb_%s_Asymptotic_log.eps", outputname.data()); //cMCMC->SaveAs(fnam); sprintf(fnam, "XZHllbb_%s_Asymptotic_log.png", outputname.data()); // cMCMC->SaveAs(fnam); //sprintf(fnam, "XZHllbb_%s_Asymptotic_log.pdf", outputname.data()); //cMCMC->SaveAs(fnam); cMCMC->Draw(); return grmedian_cls; }//end main
void DrawCMSLogoTest(TPad* pad, TString cmsText, TString extraText, int iPosX, float relPosX, float relPosY, float relExtraDY) { TVirtualPad *pad_backup = gPad; pad->cd(); float cmsTextFont = 61; // default is helvetic-bold bool writeExtraText = extraText.Length() > 0; float extraTextFont = 52; // default is helvetica-italics // text sizes and text offsets with respect to the top frame // in unit of the top margin size TString lumiText; float lumiTextOffset = 0.2; float cmsTextSize = 0.8; float lumiTextSize = 0.6; // float cmsTextOffset = 0.1; // only used in outOfFrame version // ratio of "CMS" and extra text size float extraOverCmsTextSize = 0.76; //!!MAKE CHOICE CONFIGURABLE TString lumi_13TeV = "20.1 fb^{-1}"; TString lumi_8TeV = "18.9-19.7 fb^{-1}"; TString lumi_7TeV = "0-4.9 fb^{-1}"; lumiText +=lumi_8TeV; lumiText +=" (8 TeV) + "; lumiText +=lumi_7TeV; lumiText +=" (7 TeV)"; bool outOfFrame = false; if (iPosX / 10 == 0) { outOfFrame = true; } int alignY_ = 3; int alignX_ = 2; if (iPosX / 10 == 0) alignX_ = 1; if (iPosX == 0) alignX_ = 1; if (iPosX == 0) alignY_ = 1; if (iPosX / 10 == 1) alignX_ = 1; if (iPosX / 10 == 2) alignX_ = 2; if (iPosX / 10 == 3) alignX_ = 3; if (iPosX == 0) relPosX = 0.14; int align_ = 10 * alignX_ + alignY_; float l = pad->GetLeftMargin(); float t = pad->GetTopMargin(); float r = pad->GetRightMargin(); float b = pad->GetBottomMargin(); TLatex latex; latex.SetNDC(); latex.SetTextAngle(0); latex.SetTextColor(kBlack); float extraTextSize = extraOverCmsTextSize * cmsTextSize; float pad_ratio = (static_cast<float>(pad->GetWh()) * pad->GetAbsHNDC()) / (static_cast<float>(pad->GetWw()) * pad->GetAbsWNDC()); if (pad_ratio < 1.) pad_ratio = 1.; latex.SetTextFont(42); latex.SetTextAlign(31); latex.SetTextSize(lumiTextSize*t*pad_ratio); latex.DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText); if (outOfFrame) { latex.SetTextFont(cmsTextFont); latex.SetTextAlign(11); latex.SetTextSize(cmsTextSize * t * pad_ratio); latex.DrawLatex(l, 1 - t + lumiTextOffset * t, cmsText); } float posX_ = 0; if (iPosX % 10 <= 1) { posX_ = l + relPosX * (1 - l - r); } else if (iPosX % 10 == 2) { posX_ = l + 0.5 * (1 - l - r); } else if (iPosX % 10 == 3) { posX_ = 1 - r - relPosX * (1 - l - r); } float posY_ = 1 - t - relPosY * (1 - t - b); if (!outOfFrame) { latex.SetTextFont(cmsTextFont); latex.SetTextSize(cmsTextSize * t * pad_ratio); latex.SetTextAlign(align_); latex.DrawLatex(posX_, posY_, cmsText); if (writeExtraText) { latex.SetTextFont(extraTextFont); latex.SetTextAlign(align_); latex.SetTextSize(extraTextSize * t * pad_ratio); latex.DrawLatex(posX_, posY_ - relExtraDY * cmsTextSize * t, extraText); } } else if (writeExtraText) { if (iPosX == 0) { posX_ = l + relPosX * (1 - l - r); posY_ = 1 - t + lumiTextOffset * t; } latex.SetTextFont(extraTextFont); latex.SetTextSize(extraTextSize * t * pad_ratio); latex.SetTextAlign(align_); latex.DrawLatex(posX_, posY_, extraText); } pad_backup->cd(); }
void plotr0vstheta(){ TFile *f; int isSum=0; const int ntotbin=5; const int trkpointmin[ntotbin] = {120,150,185,220,260}; const int trkpointmax[ntotbin] = {150,185,220,260,300}; int trkbin=1; int xbin=0; c1 = new TCanvas("c1"," ",1200,700); makeMultiPanelCanvas(c1,3,2,0,0,0.25,0.2,0.03); gStyle->SetOptFit(1); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetErrorX(0); TH1D *hFrame = new TH1D("","",100,0,2); hFrame->SetTitle(""); hFrame->GetXaxis()->SetTitle("#theta"); hFrame->GetYaxis()->SetTitle("r_{0}"); hFrame->GetYaxis()->SetTitleOffset(1.1); hFrame->GetXaxis()->SetTitleSize(0.04); hFrame->GetYaxis()->SetTitleSize(0.04); hFrame->GetXaxis()->SetRangeUser(0,1.5); hFrame->SetMinimum(0.05); hFrame->SetMaximum(0.30); for(int trkbin=0;trkbin<ntotbin; trkbin++){ if(isSum==0){ f = TFile::Open(Form("M%d%d/mergedV_Prod.root",trkpointmax[trkbin],trkpointmin[trkbin])); } else{ f = TFile::Open(Form("M%d%d/mergedV_Sum.root",trkpointmax[trkbin],trkpointmin[trkbin])); } TVectorD* vecr0 = (TVectorD*)f->Get(Form("D_%d/D_0/r0",xbin)); double *r0 = vecr0->GetMatrixArray(); double r0mean = getmean(r0,ntheta); double theta[ntheta]; for(int itheta=0;itheta<ntheta;itheta++){ theta[itheta]=itheta*TMath::Pi()/ntheta/nn; } int maxper10 = findmaxper(r0,ntheta,r0mean); double maxper = (double)(maxper10+1)/10; c1->cd(trkbin+1); hFrame->Draw(); TGraph *gr0theta = new TGraph(ntheta,theta,r0); gr0theta->SetMarkerStyle(20); gr0theta->SetMarkerSize(1.3); gr0theta->SetMarkerColor(1); gr0theta->SetLineColor(1); gr0theta->Draw("Psame"); TLine *lup = new TLine(gr0theta->GetXaxis()->GetXmin(),r0mean*(1+maxper), gr0theta->GetXaxis()->GetXmax(),r0mean*(1+maxper)); TLine *ldown = new TLine(gr0theta->GetXaxis()->GetXmin(),r0mean*(1-maxper), gr0theta->GetXaxis()->GetXmax(),r0mean*(1-maxper)); TLine *l = new TLine(hFrame->GetXaxis()->GetXmin(),r0mean, hFrame->GetXaxis()->GetXmax(),r0mean); l->SetLineStyle(2); lup->SetLineStyle(2); ldown->SetLineStyle(2); l->SetLineWidth(1.2); lup->SetLineWidth(1.2); ldown->SetLineWidth(1.2); TLatex *tl = new TLatex(); // tl->SetNDC(); tl->SetTextFont(42); tl->SetTextSize(0.04); // tl->SetBorderStyle(0); tl->DrawLatex(0,r0mean*(1+maxper),Form("mean up %.f%%",maxper*100)); tl->DrawLatex(0,r0mean*(1-maxper),Form("mean down %.f%%",maxper*100)); tl->SetNDC(); tl->DrawLatex(0.7,0.85,Form("Multiplicity %d to %d",trkpointmin[trkbin],trkpointmax[trkbin])); l->Draw("same"); lup->Draw("same"); ldown->Draw("same"); } c1->cd(ntotbin+1); TLatex *tlx0 = new TLatex(0.12,0.3,Form("PF candi")); TLatex *tlx1 = new TLatex(0.12,0.25,Form("%.1f<p_{T}<%.1f (GeV/c)",0.3,6.0)); tlx0->SetNDC(); tlx1->SetNDC(); tlx0->SetTextSize(0.045); tlx1->SetTextSize(0.045); hFrame->Draw(); tlx0->Draw("same"); tlx1->Draw("same"); if(isSum==0)c1->SaveAs("hr0theta_Prod.png"); else c1->SaveAs("hr0theta_Sum.png"); }
int draw_closure_differential(int isPA=1, bool useZvtxWeight=false, bool useSF = false, bool isLog = false) { gROOT->Macro("../Style.C"); using namespace std; TString szPA; if (isPA==0) szPA="pp"; else if (isPA==1) szPA="pA"; else {cout << "select among isPA = 0, or 1"<< endl; return 0; } ////rap array in yCM (from forward to backward) const Int_t nRap = 8; const Int_t nPt = 9; const int nRapTmp = nRap +1; const int nPtTmp = nPt +1; Double_t rapArrNumFB[nRapTmp]; Double_t rapArrNumFB_pp[nRapTmp] = {2.4, 1.93, 1.5, 0.9, 0., -0.9, -1.5, -1.93, -2.4};// for pt dist. Double_t rapArrNumFB_pA[nRapTmp] = {1.93, 1.5, 0.9, 0., -0.9, -1.5, -1.93, -2.4, -2.87};// for pt dist. //Double_t rapArrNumBF[nRapTmp]; //Double_t rapArrNumBF_pp[nRapTmp] = {-2.4, -1.93, -1.5, -0.9, 0., 0.9, 1.5, 1.93, 2.4};// for rap dist. //Double_t rapArrNumBF_pA[nRapTmp] = {-2.87, -2.4, -1.93, -1.5, -0.9, 0., 0.9, 1.5, 1.93};// for rap dist. for (int iy=0; iy<nRapTmp; iy++){ if (isPA==0) { rapArrNumFB[iy]=rapArrNumFB_pp[iy];} else { rapArrNumFB[iy]=rapArrNumFB_pA[iy];} } ////pt array Double_t ptArrNum[10] = {2.0, 3.0, 4.0, 5.0, 6.5, 7.5, 8.5, 10., 14., 30.}; //// array string string rapArr[nRap]; for (Int_t iy=0; iy<nRap; iy++) { formRapArr(rapArrNumFB[iy+1], rapArrNumFB[iy], &rapArr[iy]); cout << iy <<"th rapArr = " << rapArr[iy] << endl; } string ptArr[nPt]; for (Int_t ipt=0; ipt<nPt; ipt++) { formPtArr(ptArrNum[ipt], ptArrNum[ipt+1], &ptArr[ipt]); cout << ipt <<"th ptArr = " << ptArr[ipt] << endl; } // --- read-in file TFile * f2D = new TFile(Form("../FittingResult/totalHist_%s_8rap9pt_newcut_Zvtx%d_SF%d_noPtWeight.root",szPA.Data(),(int)useZvtxWeight,(int)useSF),"READ"); // --- read-in 2D hist for "MC corrected yield" and "gen distributions" TH2D* h2D_MCCorrY_PR = (TH2D*)f2D->Get(Form("otherMCInfo/h2D_MCCorrY_PR_%s",szPA.Data())); TH2D* h2D_MCCorrY_NP = (TH2D*)f2D->Get(Form("otherMCInfo/h2D_MCCorrY_NP_%s",szPA.Data())); TH2D* h2D_Acc_Den_PR = (TH2D*)f2D->Get(Form("otherMCInfo/h2D_Acc_Den_PR_%s",szPA.Data())); TH2D* h2D_Acc_Den_NP = (TH2D*)f2D->Get(Form("otherMCInfo/h2D_Acc_Den_NP_%s",szPA.Data())); const int nbinsX = h2D_MCCorrY_PR->GetNbinsX(); const int nbinsY = h2D_MCCorrY_PR->GetNbinsY(); cout << "nbinsX = " << nbinsX << ", nbinsY = " << nbinsY << endl; if (nbinsX != nRap) { cout << " *** Error!!! nbinsX != nRap"; return 0; }; if (nbinsY != nPt) { cout << " *** Error!!! nbinsY != nPt"; return 0; }; // --- projection to 1D hist TH1D* h1D_MCCorrY_PR[nbinsX]; TH1D* h1D_MCCorrY_NP[nbinsX]; TH1D* h1D_Acc_Den_PR[nbinsX]; TH1D* h1D_Acc_Den_NP[nbinsX]; // iy=0 refers to forwards !!! (ordering here) for (Int_t iy = 0; iy < nbinsX; iy++) { if (isPA==0){ h1D_MCCorrY_PR[iy] = h2D_MCCorrY_PR->ProjectionY(Form("h1D_MCCorrY_PR_%d",iy),nbinsX-iy,nbinsX-iy); h1D_MCCorrY_NP[iy] = h2D_MCCorrY_NP->ProjectionY(Form("h1D_MCCorrY_NP_%d",iy),nbinsX-iy,nbinsX-iy); h1D_Acc_Den_PR[iy] = h2D_Acc_Den_PR->ProjectionY(Form("h1D_Acc_Den_PR_%d",iy),nbinsX-iy,nbinsX-iy); h1D_Acc_Den_NP[iy] = h2D_Acc_Den_NP->ProjectionY(Form("h1D_Acc_Den_NP_%d",iy),nbinsX-iy,nbinsX-iy); } else { h1D_MCCorrY_PR[iy] = h2D_MCCorrY_PR->ProjectionY(Form("h1D_MCCorrY_PR_%d",iy),iy+1,iy+1); h1D_MCCorrY_NP[iy] = h2D_MCCorrY_NP->ProjectionY(Form("h1D_MCCorrY_NP_%d",iy),iy+1,iy+1); h1D_Acc_Den_PR[iy] = h2D_Acc_Den_PR->ProjectionY(Form("h1D_Acc_Den_PR_%d",iy),iy+1,iy+1); h1D_Acc_Den_NP[iy] = h2D_Acc_Den_NP->ProjectionY(Form("h1D_Acc_Den_NP_%d",iy),iy+1,iy+1); } } ////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// //// set values as zero for unused bins for (Int_t iy = 0; iy < nbinsX; iy++) { if (iy>=1 && iy<=6) { h1D_MCCorrY_PR[iy]->SetBinContent(1,0); h1D_MCCorrY_NP[iy]->SetBinContent(1,0); h1D_MCCorrY_PR[iy]->SetBinError(1,0); h1D_MCCorrY_NP[iy]->SetBinError(1,0); h1D_MCCorrY_PR[iy]->SetBinContent(2,0); h1D_MCCorrY_NP[iy]->SetBinContent(2,0); h1D_MCCorrY_PR[iy]->SetBinError(2,0); h1D_MCCorrY_NP[iy]->SetBinError(2,0); h1D_Acc_Den_PR[iy]->SetBinContent(1,0); h1D_Acc_Den_NP[iy]->SetBinContent(1,0); h1D_Acc_Den_PR[iy]->SetBinError(1,0); h1D_Acc_Den_NP[iy]->SetBinError(1,0); h1D_Acc_Den_PR[iy]->SetBinContent(2,0); h1D_Acc_Den_NP[iy]->SetBinContent(2,0); h1D_Acc_Den_PR[iy]->SetBinError(2,0); h1D_Acc_Den_NP[iy]->SetBinError(2,0); } if (iy>=2 && iy<=5) { h1D_MCCorrY_PR[iy]->SetBinContent(3,0); h1D_MCCorrY_NP[iy]->SetBinContent(3,0); h1D_MCCorrY_PR[iy]->SetBinError(3,0); h1D_MCCorrY_NP[iy]->SetBinError(3,0); h1D_Acc_Den_PR[iy]->SetBinContent(3,0); h1D_Acc_Den_NP[iy]->SetBinContent(3,0); h1D_Acc_Den_PR[iy]->SetBinError(3,0); h1D_Acc_Den_NP[iy]->SetBinError(3,0); } if (isPA ==0){ //for_pp if (iy>=2 && iy<=5) { h1D_MCCorrY_PR[iy]->SetBinContent(4,0); h1D_MCCorrY_NP[iy]->SetBinContent(4,0); h1D_MCCorrY_PR[iy]->SetBinError(4,0); h1D_MCCorrY_NP[iy]->SetBinError(4,0); h1D_Acc_Den_PR[iy]->SetBinContent(4,0); h1D_Acc_Den_NP[iy]->SetBinContent(4,0); h1D_Acc_Den_PR[iy]->SetBinError(4,0); h1D_Acc_Den_NP[iy]->SetBinError(4,0); } } else { if (iy>=2 && iy<=4) { // for_pA h1D_MCCorrY_PR[iy]->SetBinContent(4,0); h1D_MCCorrY_NP[iy]->SetBinContent(4,0); h1D_MCCorrY_PR[iy]->SetBinError(4,0); h1D_MCCorrY_NP[iy]->SetBinError(4,0); h1D_Acc_Den_PR[iy]->SetBinContent(4,0); h1D_Acc_Den_NP[iy]->SetBinContent(4,0); h1D_Acc_Den_PR[iy]->SetBinError(4,0); h1D_Acc_Den_NP[iy]->SetBinError(4,0); } } } ////// after zero-bin setting, normalize! for (Int_t iy = 0; iy < nbinsX; iy++) { h1D_MCCorrY_PR[iy]->Scale(1./h1D_MCCorrY_PR[iy]->Integral()); h1D_MCCorrY_NP[iy]->Scale(1./h1D_MCCorrY_NP[iy]->Integral()); h1D_Acc_Den_PR[iy]->Scale(1./h1D_Acc_Den_PR[iy]->Integral()); h1D_Acc_Den_NP[iy]->Scale(1./h1D_Acc_Den_NP[iy]->Integral()); h1D_MCCorrY_PR[iy]->Scale(1,"width"); h1D_MCCorrY_NP[iy]->Scale(1,"width"); h1D_Acc_Den_PR[iy]->Scale(1,"width"); h1D_Acc_Den_NP[iy]->Scale(1,"width"); } // hRatio TH1D* hRatio_PR[nRap]; TH1D* hRatio_NP[nRap]; for (Int_t iy = 0; iy < nbinsX; iy++) { hRatio_PR[iy]=(TH1D*)h1D_MCCorrY_PR[iy]->Clone(Form("hRatio_PR_%d",iy)); hRatio_PR[iy]->Divide(h1D_Acc_Den_PR[iy]); hRatio_NP[iy]=(TH1D*)h1D_MCCorrY_NP[iy]->Clone(Form("hRatio_NP_%d",iy)); hRatio_NP[iy]->Divide(h1D_Acc_Den_NP[iy]); } ////////////////////////////////////////////////////////////////// //// --- Draw histograms TLegend *legUR = new TLegend(0.45, 0.75, 0.86, 0.92); SetLegendStyle(legUR); TLatex* latex = new TLatex(); latex->SetNDC(); latex->SetTextAlign(12); latex->SetTextSize(0.04); ///// prompt TCanvas* c_PR_01 = new TCanvas("c_PR_01","c_PR_01",1600,800); c_PR_01->Divide(4,2); TGraphAsymmErrors* g_MCCorrY_PR[nbinsX]; TGraphAsymmErrors* g_Acc_Den_PR[nbinsX]; for (Int_t iy = 0; iy < nbinsX; iy++) { c_PR_01->cd(iy+1); if (isLog) gPad->SetLogy(1); else gPad->SetLogy(0); g_MCCorrY_PR[iy]=new TGraphAsymmErrors(h1D_MCCorrY_PR[iy]); g_Acc_Den_PR[iy]=new TGraphAsymmErrors(h1D_Acc_Den_PR[iy]); SetGraphStyle(g_MCCorrY_PR[iy],1,0); SetGraphStyle(g_Acc_Den_PR[iy],2,10); g_MCCorrY_PR[iy]->GetXaxis()->SetTitle("p_{T} (GeV/c)"); g_MCCorrY_PR[iy]->GetXaxis()->CenterTitle(); g_MCCorrY_PR[iy]->GetXaxis()->SetLimits(0.,30.); g_MCCorrY_PR[iy]->GetYaxis()->SetTitle(""); g_MCCorrY_PR[iy]->Draw("ap"); g_Acc_Den_PR[iy]->Draw("p"); if (iy==0) { legUR -> SetHeader(Form("%s Prompt J/#psi",szPA.Data())); legUR -> AddEntry(h1D_MCCorrY_PR[iy],"RECO/(Acc*Eff)","lp"); legUR -> AddEntry(h1D_Acc_Den_PR[iy],"GEN","lp"); legUR->Draw(); } latex->DrawLatex(0.46,0.68,Form("%s",rapArr[iy].c_str())); } c_PR_01->SaveAs(Form("dir_closure/%s_PR_differential_isLog%d.pdf",szPA.Data(),(int)isLog)); ///// non-prompt TCanvas* c_NP_01 = new TCanvas("c_NP_01","c_NP_01",1600,800); c_NP_01->Divide(4,2); TGraphAsymmErrors* g_MCCorrY_NP[nbinsX]; TGraphAsymmErrors* g_Acc_Den_NP[nbinsX]; for (Int_t iy = 0; iy < nbinsX; iy++) { c_NP_01->cd(iy+1); if (isLog) gPad->SetLogy(1); else gPad->SetLogy(0); g_MCCorrY_NP[iy]=new TGraphAsymmErrors(h1D_MCCorrY_NP[iy]); g_Acc_Den_NP[iy]=new TGraphAsymmErrors(h1D_Acc_Den_NP[iy]); SetGraphStyle(g_MCCorrY_NP[iy],1,0); SetGraphStyle(g_Acc_Den_NP[iy],2,10); g_MCCorrY_NP[iy]->GetXaxis()->SetTitle("p_{T} (GeV/c)"); g_MCCorrY_NP[iy]->GetXaxis()->CenterTitle(); g_MCCorrY_NP[iy]->GetXaxis()->SetLimits(0.,30.); g_MCCorrY_NP[iy]->GetYaxis()->SetTitle(""); g_MCCorrY_NP[iy]->Draw("ap"); g_Acc_Den_NP[iy]->Draw("p"); if (iy==0) { legUR -> SetHeader(Form("%s Non-prompt J/#psi",szPA.Data())); legUR->Draw(); } latex->DrawLatex(0.46,0.68,Form("%s",rapArr[iy].c_str())); } c_NP_01->SaveAs(Form("dir_closure/%s_NP_differential_isLog%d.pdf",szPA.Data(),(int)isLog)); ////////////////////////////////////////////////////////////////// //// ratio ////////////////////////////////////////////////////////////////// ///// prompt TCanvas* c_PR_02 = new TCanvas("c_PR_02","c_PR_02",1600,800); c_PR_02->Divide(4,2); TGraphAsymmErrors* gRatio_PR[nbinsX]; for (Int_t iy = 0; iy < nbinsX; iy++) { c_PR_02->cd(iy+1); gPad->SetLogy(0); gRatio_PR[iy]=new TGraphAsymmErrors(hRatio_PR[iy]); SetGraphStyle(gRatio_PR[iy],1,0); gRatio_PR[iy]->GetXaxis()->SetTitle("p_{T} (GeV/c)"); gRatio_PR[iy]->GetYaxis()->SetTitle("corrected RECO / GEN"); gRatio_PR[iy]->GetXaxis()->SetLimits(0.,30.); gRatio_PR[iy]->GetYaxis()->SetRangeUser(0.5,1.5); gRatio_PR[iy]->Draw("ap"); latex->DrawLatex(0.56,0.88,Form("%s",rapArr[iy].c_str())); dashedLine(0.,1.,30.,1.,1,1); } c_PR_02->SaveAs(Form("dir_closure/%s_PR_differential_ratio.pdf",szPA.Data())); // --- non-prompt pp TCanvas* c_NP_02 = new TCanvas("c_NP_02","c_NP_02",1600,800); c_NP_02->Divide(4,2); TGraphAsymmErrors* gRatio_NP[nbinsX]; for (Int_t iy = 0; iy < nbinsX; iy++) { c_NP_02->cd(iy+1); gPad->SetLogy(0); gRatio_NP[iy]=new TGraphAsymmErrors(hRatio_NP[iy]); SetGraphStyle(gRatio_NP[iy],1,0); gRatio_NP[iy]->GetXaxis()->SetTitle("p_{T} (GeV/c)"); gRatio_NP[iy]->GetYaxis()->SetTitle("corrected RECO / GEN"); gRatio_NP[iy]->GetXaxis()->SetLimits(0.,30.); gRatio_NP[iy]->GetYaxis()->SetRangeUser(0.5,1.5); gRatio_NP[iy]->Draw("ap"); latex->DrawLatex(0.56,0.88,Form("%s",rapArr[iy].c_str())); dashedLine(0.,1.,30.,1.,1,1); } c_NP_02->SaveAs(Form("dir_closure/%s_NP_differential_ratio.pdf",szPA.Data())); return 0; } // end of main func.