void Plot_McollRatio(TString file, TString fakefile, TString sample, TString SR, bool subtractFakes) { SetAtlasStyle(); #ifdef __CINT__ gROOT->LoadMacro("AtlasUtils.C"); #endif double xmin = 50; double xmax = 400; TFile* f = new TFile(file); TFile* fakef = new TFile(fakefile); TH1D* hME; TH1D* hEM; //if (isScaled){ // hME =(TH1D*)f->Get("ME_scaled");//nom/ME_McollHiggs_Unblind"); // hEM =(TH1D*)f->Get("EM");//nom/EM_McollHiggs_Unblind"); // hME_orig = (TH1D*)f->Get("ME_original"); // hEM_orig = (TH1D*)f->Get("EM_original"); //} //else{ hME =(TH1D*)f->Get("nom/ME_McollHiggs_Unblind"); hEM =(TH1D*)f->Get("nom/EM_McollHiggs_Unblind"); //} if (subtractFakes){ TH1D* hME_fake = (TH1D*)fakef->Get("nom/ME_McollHiggs_Unblind"); TH1D* hEM_fake = (TH1D*)fakef->Get("nom/EM_McollHiggs_Unblind"); hME->Add(hME_fake,-1); hEM->Add(hEM_fake,-1); } hEM->SetMarkerStyle(8); hEM->SetMarkerSize(0.7); hEM->SetLineColor(kPink + 8);hEM->SetOption("e1"); hEM->SetMarkerColor(kPink + 8); hME->SetMarkerStyle(8); hME->SetMarkerSize(0.7); hME->SetLineColor(kTeal - 6);hME->SetOption("e1"); hME->SetMarkerColor(kTeal - 6); hME->GetXaxis()->SetLabelOffset(0); hME->GetXaxis()->SetLabelSize(0); hEM->GetXaxis()->SetLabelOffset(0); hEM->GetXaxis()->SetLabelSize(0); hEM->GetXaxis()->SetRangeUser(xmin,xmax); hME->GetXaxis()->SetRangeUser(xmin,xmax); hEM->GetYaxis()->SetTitleOffset(1.0); hME->GetYaxis()->SetTitleOffset(1.0); // hEM_orig->SetMarkerStyle(8); hEM_orig->SetMarkerSize(0.7); // hEM_orig->SetLineColor(kPink + 8);hEM_orig->SetOption("e1"); // hEM_orig->SetMarkerColor(kPink + 8); // hME_orig->SetMarkerStyle(8); hME_orig->SetMarkerSize(0.7); // hME_orig->SetLineColor(kTeal - 6);hME_orig->SetOption("e1"); // hME_orig->SetMarkerColor(kTeal - 6); // hME_orig->GetXaxis()->SetLabelOffset(0); hME_orig->GetXaxis()->SetLabelSize(0); // hEM_orig->GetXaxis()->SetLabelOffset(0); hEM_orig->GetXaxis()->SetLabelSize(0); // hEM_orig->GetXaxis()->SetRangeUser(xmin,xmax); hME_orig->GetXaxis()->SetRangeUser(xmin,xmax); // hEM_orig->GetYaxis()->SetTitleOffset(1.0); // hME_orig->GetYaxis()->SetTitleOffset(1.0); double numEM = hEM->Integral(); double numME = hME->Integral(); cout<<"# entries EM = " << numEM << endl; cout<<"# entries ME = " << numME << endl; // TH1D* ratio2 = GetRatio(hEM_orig,hME_orig,xmin,xmax); // TH1D* diff2 = GetDiff(hEM_orig,hME_orig,xmin,xmax); TH1D* ratio = GetRatio(hEM,hME,xmin,xmax); TH1D* diff = GetDiff(hEM,hME,xmin,xmax); TLegend* leg = new TLegend(0.6,0.45,0.75,0.55); leg->SetFillColor(kWhite); leg->SetBorderSize(1); leg->SetLineColor(0); leg->SetTextFont(42); leg->SetTextSize(.05); TLine* line1 = new TLine(xmin,1,xmax,1); line1->SetLineColor(kRed); line1->SetLineStyle(2); TLine* line14 = new TLine(xmin,1.5,xmax,1.5); line14->SetLineStyle(9); line14->SetLineColor(kBlack); TLine* line13 = new TLine(xmin,2./3,xmax,2./3); line13->SetLineStyle(2); line13->SetLineColor(kRed); TLine* line12 = new TLine(xmin,2,xmax,2); line12->SetLineStyle(9); line12->SetLineColor(kBlack); TLine* line15 = new TLine(xmin,0.5,xmax,0.5); line15->SetLineStyle(9); line15->SetLineColor(kBlack); TLine* line2 = new TLine(xmin,0,xmax,0); line2->SetLineColor(kBlack); line2->SetLineStyle(9); TLine* vline1 = new TLine(100,0,100,3000); vline1->SetLineStyle(2); TLine* vline2 = new TLine(150,0,150,3000); vline2->SetLineStyle(2); TCanvas* c0 = new TCanvas("mcoll ","mcoll ",600,600); c0=c0; TPad *pad1 = new TPad("pad1", "12<L1<15",0.0,0.2,1,1.0,21); pad1->SetMargin(0.1,0.1,0.02,0.2); TPad *pad2 = new TPad("pad2", "ratio", 0.0,0,1,0.2,21); pad2->SetMargin(0.1,0.1,0.3,0.02); // TPad *pad3 = new TPad("pad3", "diff", 0.0,0,1,0.2,21); pad3->SetMargin(0.1,0.1,0.3,0.02); pad1->SetFillColor(0);pad2->SetFillColor(0);//pad3->SetFillColor(0); pad1->Draw(); pad2->Draw();//pad3->Draw(); pad1->cd(); #ifdef __CINT__ gROOT->LoadMacro("AtlasLabels.C"); #endif leg->AddEntry(hME,"#mue","le"); leg->AddEntry(hEM,"e#mu","le"); hEM->Draw("e1"); hME->Draw("e1 sames"); vline1->Draw(); vline2->Draw(); pad2->cd(); ratio->Draw(); line14->Draw();line15->Draw();line1->Draw(); // pad3->cd(); // diff->Draw(); // line2->Draw(); pad1->cd(); myText(0.5,0.65,1,"#int L dt = 20.3 fb^{-1} #sqrt{s} = 8 TeV"); myText(0.6,0.35,1,sample); myText(0.6,0.25,1,SR); ATLASLabel(0.62,0.75,"Internal"); leg->Draw(); c0->Update(); // TCanvas* c1 = new TCanvas("mcoll original","mcoll original",600,600); c0=c0; // TPad *pad1_2 = new TPad("pad1", "12<L1<15",0.0,0.4,1,1.0,21); pad1_2->SetMargin(0.1,0.1,0.02,0.2); // TPad *pad2_2 = new TPad("pad2", "ratio", 0.0,0.2,1,0.4,21); pad2_2->SetMargin(0.1,0.1,0.02,0.02); // TPad *pad3_2 = new TPad("pad3", "diff", 0.0,0,1,0.2,21); pad3_2->SetMargin(0.1,0.1,0.3,0.02); // // pad1_2->SetFillColor(0);pad2_2->SetFillColor(0);pad3_2->SetFillColor(0); // pad1_2->Draw(); pad2_2->Draw();pad3_2->Draw(); // // // pad1_2->cd(); // hEM_orig->Draw("e1"); hME_orig->Draw("e1 sames"); // vline1->Draw(); vline2->Draw(); // pad2_2->cd(); // ratio2->Draw(); // line14->Draw();line15->Draw();line1->Draw(); // pad3_2->cd(); // diff2->Draw(); // line2->Draw(); // pad1_2->cd(); // myText(0.5,0.65,1,"#int L dt = 20.3 fb^{-1} #sqrt{s} = 8 TeV"); // myText(0.6,0.35,1,sample); // // ATLASLabel(0.62,0.75,"Internal"); // // leg->Draw(); // // // c1->Update(); return; }
void plot_eta(void){ TFile* inputFileML = new TFile ("Xeta_LooserML.root", "READ"); TFile* inputFileLH = new TFile ("Xeta_LH_3.5.root", "READ"); TH1D *hZee_XLooserML_eta = (TH1D *) inputFileML->Get("hZee_X_eta"); TH1D *hZuu_XLooserML_eta = (TH1D *) inputFileML->Get("hZuu_X_eta"); TH1D *hZee_ELooserML_eta = (TH1D *) inputFileML->Get("hZee_E_eta"); TH1D *hZuu_ELooserML_eta = (TH1D *) inputFileML->Get("hZuu_E_eta"); TH1D *hZee_FLooserML_eta = (TH1D *) inputFileML->Get("hZee_F_eta"); TH1D *hZuu_FLooserML_eta = (TH1D *) inputFileML->Get("hZuu_F_eta"); hZee_XLooserML_eta->SetDirectory(0); hZuu_XLooserML_eta->SetDirectory(0); hZee_ELooserML_eta->SetDirectory(0); hZuu_ELooserML_eta->SetDirectory(0); hZee_FLooserML_eta->SetDirectory(0); hZuu_FLooserML_eta->SetDirectory(0); TH1D *hZee_XLH35_eta = (TH1D *) inputFileLH->Get("hZee_X_eta"); TH1D *hZuu_XLH35_eta = (TH1D *) inputFileLH->Get("hZuu_X_eta"); TH1D *hZee_ELH35_eta = (TH1D *) inputFileLH->Get("hZee_E_eta"); TH1D *hZuu_ELH35_eta = (TH1D *) inputFileLH->Get("hZuu_E_eta"); TH1D *hZee_FLH35_eta = (TH1D *) inputFileLH->Get("hZee_F_eta"); TH1D *hZuu_FLH35_eta = (TH1D *) inputFileLH->Get("hZuu_F_eta"); hZee_XLH35_eta->SetDirectory(0); hZuu_XLH35_eta->SetDirectory(0); hZee_ELH35_eta->SetDirectory(0); hZuu_ELH35_eta->SetDirectory(0); hZee_FLH35_eta->SetDirectory(0); hZuu_FLH35_eta->SetDirectory(0); //--------------------------------------// //--------------------------------------// // X // //--------------------------------------// //--------------------------------------// TCanvas *cnvs_ZX = new TCanvas("cnvs_ZX","cnvs_ZX"); TH1F*hFrame_X=cnvs_ZX->DrawFrame(-2.47,0,2.47,0.03,"frame"); hFrame_X->SetXTitle("#eta_{X}"); hFrame_X->SetYTitle("Arbitrary units"); hZuu_XLooserML_eta->SetMarkerStyle(26); hZee_XLooserML_eta->SetMarkerStyle(32); hZuu_XLooserML_eta->SetLineColor(kBlue); hZee_XLooserML_eta->SetLineColor(kRed); hZuu_XLooserML_eta->SetMarkerColor(kBlue); hZee_XLooserML_eta->SetMarkerColor(kRed); hZuu_XLH35_eta->SetMarkerStyle(22); hZee_XLH35_eta->SetMarkerStyle(23); hZuu_XLH35_eta->SetLineColor(kBlue); hZee_XLH35_eta->SetLineColor(kRed); hZuu_XLH35_eta->SetMarkerColor(kBlue); hZee_XLH35_eta->SetMarkerColor(kRed); TLegend*leg_ZX=new TLegend(0.35,0.6,0.75,0.82); leg_ZX->SetFillColor(0); leg_ZX->SetShadowColor(0); leg_ZX->SetBorderSize(0); leg_ZX->AddEntry(hZee_XLooserML_eta,"Z #rightarrow ee + X(relaxed ML)","lp"); leg_ZX->AddEntry(hZuu_XLooserML_eta,"Z #rightarrow #mu#mu + X(relaxed ML)","lp"); leg_ZX->AddEntry(hZee_XLH35_eta,"Z #rightarrow ee + X(LH 3.5)","lp"); leg_ZX->AddEntry(hZuu_XLH35_eta,"Z #rightarrow #mu#mu + X(LH 3.5)","lp"); hFrame_X->Draw(); leg_ZX->Draw("PEsame"); hZee_XLooserML_eta->Draw("same"); hZuu_XLooserML_eta->Draw("Same"); hZee_XLH35_eta->Draw("Same"); hZuu_XLH35_eta->Draw("Same"); ATLASLabel(0.2, 0.9, true, kBlack); TLatex l; l.SetNDC(); l.SetTextFont(42); l.DrawLatex(0.6, 0.9, "2012 data Ldt ~ 20fb^{-1}"); cnvs_ZX->SaveAs("Efficiencies_plot/Z_X_eta.eps"); //--------------------------------------// //--------------------------------------// // E // //--------------------------------------// //--------------------------------------// TCanvas *cnvs_ZE = new TCanvas("cnvs_ZE","cnvs_ZE"); TH1F*hFrame_E=cnvs_ZE->DrawFrame(-2.47,0,2.47,0.03,"frame"); hFrame_E->SetXTitle("#eta_{electron-like reco(E)}"); hFrame_E->SetYTitle("Arbitrary units"); hZuu_ELooserML_eta->SetMarkerStyle(26); hZee_ELooserML_eta->SetMarkerStyle(32); hZuu_ELooserML_eta->SetLineColor(kBlue); hZee_ELooserML_eta->SetLineColor(kRed); hZuu_ELooserML_eta->SetMarkerColor(kBlue); hZee_ELooserML_eta->SetMarkerColor(kRed); hZuu_ELH35_eta->SetMarkerStyle(22); hZee_ELH35_eta->SetMarkerStyle(23); hZuu_ELH35_eta->SetLineColor(kBlue); hZee_ELH35_eta->SetLineColor(kRed); hZuu_ELH35_eta->SetMarkerColor(kBlue); hZee_ELH35_eta->SetMarkerColor(kRed); TLegend*leg_ZE=new TLegend(0.35,0.6,0.75,0.82); leg_ZE->SetFillColor(0); leg_ZE->SetShadowColor(0); leg_ZE->SetBorderSize(0); leg_ZE->AddEntry(hZee_ELooserML_eta,"Z #rightarrow ee + E(relaxed ML)","lp"); leg_ZE->AddEntry(hZuu_ELooserML_eta,"Z #rightarrow #mu#mu + E(relaxed ML)","lp"); leg_ZE->AddEntry(hZee_ELH35_eta,"Z #rightarrow ee + E(LH 3.5)","lp"); leg_ZE->AddEntry(hZuu_ELH35_eta,"Z #rightarrow #mu#mu + E(LH 3.5)","lp"); hFrame_E->Draw(); leg_ZE->Draw("PEsame"); hZee_ELooserML_eta->Draw("same"); hZuu_ELooserML_eta->Draw("Same"); hZee_ELH35_eta->Draw("Same"); hZuu_ELH35_eta->Draw("Same"); ATLASLabel(0.2, 0.9, true, kBlack); TLatex l; l.SetNDC(); l.SetTextFont(42); l.DrawLatex(0.6, 0.9, "2012 data Ldt ~ 20fb^{-1}"); cnvs_ZE->SaveAs("Efficiencies_plot/Z_E_eta.eps"); //--------------------------------------// //--------------------------------------// // F // //--------------------------------------// //--------------------------------------// TCanvas *cnvs_ZF = new TCanvas("cnvs_ZF","cnvs_ZF"); TH1F*hFrame_F=cnvs_ZF->DrawFrame(-2.47,0,2.47,0.03,"frame"); hFrame_F->SetXTitle("#eta_{fake-like reco(F)}"); hFrame_F->SetYTitle("Arbitrary units"); hZuu_FLooserML_eta->SetMarkerStyle(26); hZee_FLooserML_eta->SetMarkerStyle(32); hZuu_FLooserML_eta->SetLineColor(kBlue); hZee_FLooserML_eta->SetLineColor(kRed); hZuu_FLooserML_eta->SetMarkerColor(kBlue); hZee_FLooserML_eta->SetMarkerColor(kRed); hZuu_FLH35_eta->SetMarkerStyle(22); hZee_FLH35_eta->SetMarkerStyle(23); hZuu_FLH35_eta->SetLineColor(kBlue); hZee_FLH35_eta->SetLineColor(kRed); hZuu_FLH35_eta->SetMarkerColor(kBlue); hZee_FLH35_eta->SetMarkerColor(kRed); TLegend*leg_ZF=new TLegend(0.35,0.6,0.75,0.82); leg_ZF->SetFillColor(0); leg_ZF->SetShadowColor(0); leg_ZF->SetBorderSize(0); leg_ZF->AddEntry(hZee_FLooserML_eta,"Z #rightarrow ee + F(relaxed ML)","lp"); leg_ZF->AddEntry(hZuu_FLooserML_eta,"Z #rightarrow #mu#mu + F(relaxed ML)","lp"); leg_ZF->AddEntry(hZee_FLH35_eta,"Z #rightarrow ee + F(LH 3.5)","lp"); leg_ZF->AddEntry(hZuu_FLH35_eta,"Z #rightarrow #mu#mu + F(LH 3.5)","lp"); hFrame_F->Draw(); leg_ZF->Draw("PEsame"); hZee_FLooserML_eta->Draw("same"); hZuu_FLooserML_eta->Draw("Same"); hZee_FLH35_eta->Draw("Same"); hZuu_FLH35_eta->Draw("Same"); ATLASLabel(0.2, 0.9, true, kBlack); TLatex l; l.SetNDC(); l.SetTextFont(42); l.DrawLatex(0.6, 0.9, "2012 data Ldt ~ 20fb^{-1}"); cnvs_ZF->SaveAs("Efficiencies_plot/Z_F_eta.eps"); }
void makeFitPlotSFJVF() { gROOT->SetBatch(); gROOT->SetStyle("Plain"); gStyle->SetOptStat(0); gROOT->ProcessLine(".x def.C"); gROOT->ProcessLine(".x common.C"); bool doSubPlot = 0; std::string sel = "MV160"; std::string var = "Sd0t1"; const int nf = 2; std::string fv[nf] = {"","_JVF0"}; double sf[100][100]; double sferr[100][100]; double sfX[100]; double sfXerr[100]; TCanvas *c1 = new TCanvas("c1","c1",0,0,600,500); c1->Draw(); c1->cd(); TPad *c1_1; if( doSubPlot ) { c1->Range(0,0,1,1); c1_1 = new TPad("c1_1","main",0.01,0.30,0.99,0.99); c1_1->Draw(); c1_1->cd(); } gStyle->SetHistTopMargin(0); TLegend *leg = new TLegend(0.70,0.90,0.90,0.70); leg->SetFillColor(253); leg->SetBorderSize(0); int nbins = 0; int im = 0; TH1F *hc; TH1F *hsf[nf]; for(int f=0;f<nf;f++) { std::string fname = "results/sfoverlay/fit_EFF_beauty_"+var+"_"+sel+fv[f]+".root"; TFile *file = new TFile(fname.c_str()); TH1F *h = (TH1F*)file->Get("h1c"); nbins = h->GetXaxis()->GetNbins(); for(int ib=1;ib<nbins+1;ib++) { double cont = h->GetBinContent(ib); double err = h->GetBinError(ib); sfXerr[ib-1] = h->GetBinWidth(ib)/2.0; sfX[ib-1] = h->GetBinLowEdge(ib) + sfXerr[ib-1]; sf[ib-1][im] = cont; sferr[ib-1][im] = err; } if( f == 0 ) {h->SetMarkerStyle(20);h->SetMarkerColor(kRed);h->SetLineColor(kRed);} if( f == 1 ) {h->SetMarkerStyle(25);h->SetMarkerColor(kBlack);h->SetLineColor(kBlack);} if( f == 2 ) {h->SetMarkerStyle(22);h->SetMarkerColor(kBlue);h->SetLineColor(kBlue);} if( f == 3 ) {h->SetMarkerStyle(23);h->SetMarkerColor(kMagenta);h->SetLineColor(kMagenta);} std::string tit = ""; if( f == 0 ) tit = "JVF > 0.5"; if( f == 1 ) tit = "JVF > 0"; if( f == 2 ) tit = "S_{d_{0}}(t_{3})"; if( f == 3 ) tit = "S_{d_{0}}(#mu)"; leg->AddEntry(h,tit.c_str(),"lep"); if( f == 0 ) h->Draw("e1"); else h->Draw("e1 same"); ATLASLabel(0.20,0.85,"Internal",1); h->GetYaxis()->SetRangeUser(0.3,1.6); h->GetXaxis()->SetRangeUser(0.0,0.04); im++; std::string hname = "hsf"+std::string(Form("%d",f)); hsf[f] = (TH1F*)h->Clone(hname.c_str()); } leg->Draw(); gPad->RedrawAxis("g"); /* if( doSubPlot ) { std::string foutStr = "results/fit_EFF_beauty_SFOVERLAY_"+sel+".root"; TFile *fout = new TFile(foutStr.c_str(),"RECREATE"); int inb = hsf[0]->GetXaxis()->GetNbins(); const int nb = inb; double av[nb]; double errSum[nb]; double absv[nb]; for(int ib=1;ib<=nb;ib++) { av[ib-1] = 0.; absv[ib-1] = 0.; errSum[ib-1] = 0.; } for(int ih=0;ih<nf;ih++) { for(int ib=1;ib<=nb;ib++) { double err = hsf[ih]->GetBinError(ib); // av[ib-1] += (err > 0) ? hsf[ih]->GetBinContent(ib)/pow(err,2) : 0.; av[ib-1] += hsf[ih]->GetBinContent(ib)/float(nf); errSum[ib-1] += (err > 0) ? 1./pow(err,2) : 0.; } } for(int ih=0;ih<nf;ih++) { for(int ib=1;ib<=nb;ib++) { double err = hsf[ih]->GetBinError(ib); absv[ib-1] += pow(err,2); } } for(int ib=1;ib<=nb;ib++) { // av[ib-1] /= errSum[ib-1]; } for(int ib=1;ib<=nb;ib++) { absv[ib-1] = sqrt(absv[ib-1])/float(nf); // absv[ib-1] = 1./sqrt(errSum[ib-1]); std::cout << av[ib-1] << " +- " << absv[ib-1] << std::endl; } c1->cd(); TPad *c1_2 = new TPad("c1_2", "ratio",0.01,0.01,0.99,0.37); c1_2->Draw(); c1_2->cd(); c1_2->SetBottomMargin(0.37); c1_2->SetGrid(0,1); TH1F *h1c = (TH1F*)hsf[0]->Clone("h1c"); for(int ib=1;ib<=nb;ib++) { h1c->SetBinContent(ib,av[ib-1]); h1c->SetBinError(ib,absv[ib-1]); } h1c->SetMarkerStyle(20); h1c->SetMarkerSize(0.8); h1c->GetYaxis()->SetNdivisions(5); h1c->GetYaxis()->SetTitle("Data/MC"); h1c->GetYaxis()->SetTitleSize((h1c->GetYaxis()->GetTitleSize())*2); h1c->GetYaxis()->SetTitleOffset(h1c->GetYaxis()->GetTitleOffset()/2); h1c->GetXaxis()->SetTitleSize((h1c->GetXaxis()->GetTitleSize())*2); h1c->GetXaxis()->SetTitleOffset(h1c->GetXaxis()->GetTitleOffset()+0.2); h1c->GetYaxis()->SetLabelSize((h1c->GetYaxis()->GetLabelSize())*2); h1c->GetXaxis()->SetLabelSize((h1c->GetXaxis()->GetLabelSize())*2); h1c->GetXaxis()->SetTitle(h1c->GetXaxis()->GetTitle()); h1c->SetLineColor(kBlack); h1c->SetMarkerColor(kBlack); h1c->Draw("e1"); h1c->GetYaxis()->SetRangeUser(0.5,1.5); c1->Update(); for(int ih=0;ih<nf;ih++) { hsf[ih]->Write(); } fout->Write(); fout->Close(); }*/ std::string fsave = "pics/fit_SFJVF_"+sel+".eps"; c1->Print(fsave.c_str()); gApplication->Terminate(); }