void CutFlow::standardCutFlowPlot(TH1D* data, THStack *hs, AllSamples samples, Variable variable){ //Style TdrStyle style; style.setTDRStyle(); //draw histos to files TCanvas *c1 = new TCanvas("Plot","Plot",900, 600); data->Draw(); hs->Draw("hist"); setBinLabels(hs, data); if(Globals::addHashErrors){ TH1D* hashErrs = hashErrors(samples, variable); hashErrs->Draw("same e2"); } data->Draw("E same"); data->SetMarkerStyle(20); data->SetMarkerSize(0.5); hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.3); hs->GetXaxis()->SetLimits(variable.minX, variable.maxX); hs->GetXaxis()->SetTitle(variable.xTitle); hs->GetXaxis()->SetTitleSize(0.05); hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05); TLegend* leg = legend(samples); leg->Draw(); TText* textChan = doChan(0.12,0.96); textChan->Draw(); TText* textPrelim = doPrelim(0.58,0.96); textPrelim->Draw(); c1->SetLogy(); c1->SaveAs("Plots/ControlPlots/"+objName+"/Log/"+variable.name+".png"); c1->SaveAs("Plots/ControlPlots/"+objName+"/Log/"+variable.name+".pdf"); delete c1; delete leg; delete textChan; delete textPrelim; }
void Plots2D::standardPlot(TH2D* ttbar, Variable variable){ //Style TdrStyle style; style.setTDRStyle(); gStyle->SetPalette(1); gStyle->SetPadRightMargin(0.12); //draw histos to files TCanvas *c1 = new TCanvas("Plot","Plot",900, 800); ttbar->Draw("COLZ"); // ttbar->SetMaximum(ttbar->GetBinContent(ttbar->GetMaximumBin())*1.3); ttbar->SetAxisRange(variable.minX, variable.maxX, "X"); ttbar->SetAxisRange(variable.minX, variable.maxX, "Y"); ttbar->GetXaxis()->SetTitle("Gen " +variable.xTitle); ttbar->GetXaxis()->SetTitleSize(0.05); ttbar->GetYaxis()->SetTitle("Reco " +variable.xTitle); ttbar->GetYaxis()->SetTitleSize(0.05); for(unsigned int i = 0; i < bins.size(); i++){ TLine *line = new TLine(bins[i],variable.minX,bins[i], variable.maxX); TLine *liney = new TLine(variable.minX,bins[i], variable.maxX, bins[i]); line->SetLineWidth(2); liney->SetLineWidth(2); liney->Draw(); line->Draw(); } TText* textChan = doChan(0.12,0.96); textChan->Draw(); TText* textPrelim = doPrelim(0.58,0.96); textPrelim->Draw(); c1->SaveAs("Plots/ControlPlots/2DPlots/"+variable.name+".png"); c1->SaveAs("Plots/ControlPlots/2DPlots/"+variable.name+".pdf"); delete c1; delete textChan; delete textPrelim; }
void fineBinPU(){ //setTDRStyle(); TFile* file_2011_64600 = new TFile("PileUp/PileUp_2011_truth_finebin_64600microbarn.root"); TFile* file_2011_68000 = new TFile("PileUp/PileUp_2011_truth_finebin_68000microbarn.root"); TFile* file_2011_71400 = new TFile("PileUp/PileUp_2011_truth_finebin_71400microbarn.root"); TFile* file_2012_65835 = new TFile("PileUp/PileUp_2012_65835_truth_finebin.root"); TFile* file_2012_69300 = new TFile("PileUp/PileUp_2012_69300_truth_finebin.root"); TFile* file_2012_72765 = new TFile("PileUp/PileUp_2012_72765_truth_finebin.root"); TH1D* plot_2011_64600 = (TH1D*) file_2011_64600->Get("pileup"); TH1D* plot_2011_68000 = (TH1D*) file_2011_68000->Get("pileup"); TH1D* plot_2011_71400 = (TH1D*) file_2011_71400->Get("pileup"); TH1D* plot_2012_65835 = (TH1D*) file_2012_65835->Get("pileup"); TH1D* plot_2012_69300 = (TH1D*) file_2012_69300->Get("pileup"); TH1D* plot_2012_72765 = (TH1D*) file_2012_72765->Get("pileup"); plot_2011_64600->Scale(1/plot_2011_64600->Integral()); plot_2011_68000->Scale(1/plot_2011_68000->Integral()); plot_2011_71400->Scale(1/plot_2011_71400->Integral()); plot_2012_65835->Scale(1/plot_2012_65835->Integral()); plot_2012_69300->Scale(1/plot_2012_69300->Integral()); plot_2012_72765->Scale(1/plot_2012_72765->Integral()); plot_2011_64600->SetLineColor(kRed); plot_2011_68000->SetLineColor(kGreen); plot_2011_71400->SetLineColor(kBlack); plot_2012_65835->SetLineColor(kYellow); plot_2012_69300->SetLineColor(kBlue); plot_2012_72765->SetLineColor(kMagenta); //draw histos to files TCanvas *c1 = new TCanvas("Plot","Plot",900, 600); plot_2012_65835->Draw(); plot_2012_69300->Draw("same"); plot_2012_72765->Draw("same"); plot_2011_64600->Draw("same"); plot_2011_68000->Draw("same"); plot_2011_71400->Draw("same"); plot_2012_65835->SetMaximum(plot_2011_71400->GetBinContent(plot_2011_71400->GetMaximumBin())*1.2); plot_2012_65835->GetXaxis()->SetLimits(0, 50); plot_2012_65835->GetXaxis()->SetTitle("Number of interactions per crossing"); plot_2012_65835->GetXaxis()->SetTitleSize(0.05); plot_2012_65835->GetYaxis()->SetTitle("Normalised Events");plot_2012_65835->GetYaxis()->SetTitleSize(0.05); TLegend *tleg2; tleg2 = new TLegend(0.5,0.6,0.9,0.9); tleg2->SetTextSize(0.04); tleg2->SetBorderSize(0); tleg2->SetFillColor(10); tleg2->AddEntry(plot_2012_65835 , "#sqrt{s} = 8 TeV, #sigma_{pp} = 65835 pb", "l"); tleg2->AddEntry(plot_2012_69300 , "#sqrt{s} = 8 TeV, #sigma_{pp} = 69300 pb", "l"); tleg2->AddEntry(plot_2012_72765 , "#sqrt{s} = 8 TeV, #sigma_{pp} = 72765 pb", "l"); tleg2->AddEntry(plot_2011_64600 , "#sqrt{s} = 7 TeV, #sigma_{pp} = 64600 pb", "l"); tleg2->AddEntry(plot_2011_68000 , "#sqrt{s} = 7 TeV, #sigma_{pp} = 68000 pb", "l"); tleg2->AddEntry(plot_2011_71400 , "#sqrt{s} = 7 TeV, #sigma_{pp} = 71400 pb", "l"); tleg2->Draw("same"); TText* textPrelim = doPrelim(0.3,0.96); textPrelim->Draw(); c1->SaveAs("Plots/TTbarPlusVarAnalysis/PileUp/PileUp_2012_truth_data.pdf"); c1->SaveAs("Plots/TTbarPlusVarAnalysis/PileUp/PileUp_2012_truth_data.png"); delete c1; }
void doPlotsBtag_Log(bool logPlot){ setTDRStyle(); double lumi = 5800; //stuff to choose //bool logPlot = false; //true for log plot int rebinFact = 1; //isolation selection //TString Isolation = "QCD No Iso/"; TString Isolation = "Ref selection/"; //TString Isolation = "QCD mu+jets PFRelIso/"; //TString Isolation = "QCD non iso mu+jets/"; TString Systematic = "central"; // number of btags TString Nbtags = "2btags"; //standard "2btags" , qcd "0btag" //choose object TString Obj = ""; //TString Obj = "MET/"; //muon variables const int N = 2; TString Variable; TString Variables[N] = {"N_BJets", "N_BJets_reweighted"}; double MinXs[N] = {-0.5,-0.5}; double MaxXs[N] = {7.5,7.5}; TString XTitles[N] = {"B-tag Multiplicity", "B-tag Multiplicity"}; //loop over variables for(int i = 0; i<2; i++){ double MinX = MinXs[i]; double MaxX = MaxXs[i]; Variable = Variables[i]; TString Xtitle = XTitles[i]; //Data TH1D* data = getSample("SingleMu", 1, Obj, Variable, Isolation, rebinFact, "central"); //MC TH1D* tt = getSample("TTJet", lumi*225.2/6920475, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* wjets = getSample("W1Jet", lumi*37509/57708550, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* w2jets = getSample("W2Jets", lumi*1750.0/34041404, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* w3jets = getSample("W3Jets", lumi*519.0/15536443, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* w4jets = getSample("W4Jets", lumi*214.0/13370904, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* zjets = getSample("DY1JetsToLL", lumi*5745.25/30457954, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* z2jets = getSample("DY2JetsToLL", lumi*181.0/21835749, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* z3jets = getSample("DY3JetsToLL", lumi*51.1/11010628, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* z4jets = getSample("DY4JetsToLL", lumi*23.04/6391785, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd = getSample("QCD_Pt-15to20_MuEnrichedPt5", lumi*34679.3/8500505, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd2 = getSample("QCD_Pt-20to30_MuEnrichedPt5", lumi*2.87e8 * 0.0065/8486893, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd3 = getSample("QCD_Pt-30to50_MuEnrichedPt5", lumi*6.609e7 * 0.0122/8928999, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd4 = getSample("QCD_Pt-50to80_MuEnrichedPt5", lumi*8082000.0 * 0.0218/7256011, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd5 = getSample("QCD_Pt-80to120_MuEnrichedPt5", lumi*1024000.0 * 0.0395/9030624, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd6 = getSample("QCD_Pt-120to170_MuEnrichedPt5", lumi*157800.0 * 0.0473/8500505, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd7 = getSample("QCD_Pt-170to300_MuEnrichedPt5", lumi*34020.0 * 0.0676/7662483, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd8 = getSample("QCD_Pt-300to470_MuEnrichedPt5", lumi*1757.0 * 0.0864/7797481, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd9 = getSample("QCD_Pt-470to600_MuEnrichedPt5", lumi*115.2 * 0.1024/2995767, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd10 = getSample("QCD_Pt-800to1000_MuEnrichedPt5",lumi*3.57 * 0.1033/4047142, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd11 = getSample("QCD_Pt-1000_MuEnrichedPt5", lumi*0.774 * 0.1097/3807263, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* top_t = getSample("T_t-channel", lumi*56.4/3757707, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* top_tw = getSample("T_tW-channel", lumi*11.1/497395, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* top_s = getSample("T_s-channel", lumi*3.79/249516, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* tbar_t = getSample("Tbar_t-channel", lumi*30.7/1934817, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* tbar_tw = getSample("Tbar_tW-channel", lumi*11.1/493239, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* tbar_s = getSample("Tbar_s-channel", lumi*1.76/139948, Obj, Variable, Isolation, rebinFact, Systematic); //make combined top and single top template TH1D* sing_top = (TH1D*)top_t->Clone("top"); sing_top->Add(top_tw);sing_top->Add(top_s); sing_top->Add(tbar_t); sing_top->Add(tbar_tw);sing_top->Add(tbar_s); zjets->Add(z2jets); zjets->Add(z3jets); zjets->Add(z4jets); wjets->Add(w2jets); wjets->Add(w3jets); wjets->Add(w4jets); //make combined top and single top template TH1D* qcd_all = (TH1D*)qcd->Clone("qcd_all"); qcd_all->Add(qcd2); qcd_all->Add(qcd3); qcd_all->Add(qcd4); qcd_all->Add(qcd5); qcd_all->Add(qcd6); qcd_all->Add(qcd7); qcd_all->Add(qcd8); qcd_all->Add(qcd9); qcd_all->Add(qcd10); qcd_all->Add(qcd11); THStack *hs = new THStack("hs","test"); qcd_all->SetLineColor(kBlack); zjets->SetLineColor(kBlack); wjets->SetLineColor(kBlack); sing_top->SetLineColor(kBlack); tt->SetLineColor(kBlack); hs->Add(qcd_all); hs->Add(zjets); hs->Add(wjets); hs->Add(sing_top); hs->Add(tt); //draw histos to files TCanvas *c1 = new TCanvas("Plot","Plot",900, 600); hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.2); hs->SetMinimum(1.); hs->Draw(); data->Draw("E same"); data->SetMarkerStyle(20); //events: cout << "ttbar: " << tt->Integral() << endl; cout << "data: " << data->Integral() << endl; if(logPlot == true){ hs->GetXaxis()->SetLimits(MinX, MaxX); }else{ hs->GetXaxis()->SetLimits(MinX, 4.5); } hs->GetXaxis()->SetTitle(Xtitle); hs->GetXaxis()->SetTitleSize(0.05); hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05); TLegend *tleg2; tleg2 = new TLegend(0.7,0.7,0.8,0.9); tleg2->SetTextSize(0.04); tleg2->SetBorderSize(0); tleg2->SetFillColor(10); tleg2->AddEntry(data , "2012 data", "lpe"); tleg2->AddEntry(tt , "t#bar{t}", "f"); tleg2->AddEntry(sing_top, "single top", "f"); tleg2->AddEntry(wjets , "w+jets", "f"); tleg2->AddEntry(zjets , "z+jets", "f"); tleg2->AddEntry(qcd_all , "QCD", "f"); //tleg2->AddEntry(singtEff, "single-t" , "l"); //tleg2->AddEntry(singtwEff, "single-tW" , "l"); tleg2->Draw("same"); if(logPlot == true){ TText* textPrelim = doPrelim(0.12,0.96, "#geq 0 btags"); textPrelim->Draw(); }else{ TText* textPrelim = doPrelim(0.2,0.96, ""); textPrelim->Draw(); } if(logPlot ==true){ c1->SetLogy(); } TString plotName("Plots/TTbarPlusVarAnalysis/Nbtags/"); if(logPlot ==true){ plotName += Variable+"_Log"; }else{ plotName += Variable; } c1->SaveAs(plotName+".pdf"); c1->SaveAs(plotName+".png"); delete c1; } }
void doPlotsMuon(){ setTDRStyle(); //loop over variables for(int i = 0; i<1; i++){ double MinX = MinXs[i]; double MaxX = MaxXs[i]; Variable = Variables[i]; TString Xtitle = XTitles[i]; //Data TH1D* data = getSample("SingleMu", 1, Obj, Variable, Isolation, rebinFact, "central"); //MC TH1D* tt = getSample("TTJet", lumi*225.2/6920475, Obj, Variable, Isolation, rebinFact, Systematic); //ttbar individual // TH1D* tt_semi = getSample("TTJet_SemiLept", lumi*225.2/6920475, Obj, Variable, Isolation, rebinFact, Systematic); // TH1D* tt_lep = getSample("TTJet_FullLept", lumi*225.2/6920475, Obj, Variable, Isolation, rebinFact, Systematic); // TH1D* tt_had = getSample("TTJet_Hadronic", lumi*225.2/6920475, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* wjets = getSample("W1Jet", lumi*37509/57708550, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* w1jets = getSample("W1Jet", lumi*5400.0/23140779, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* w2jets = getSample("W2Jets", lumi*1750.0/34041404, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* w3jets = getSample("W3Jets", lumi*519.0/15536443, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* w4jets = getSample("W4Jets", lumi*214.0/13370904, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* zjets = getSample("DY1JetsToLL", lumi*5745.25/30457954, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* z1jets = getSample("DY1JetsToLL", lumi*561.0/24042904, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* z2jets = getSample("DY2JetsToLL", lumi*181.0/21835749, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* z3jets = getSample("DY3JetsToLL", lumi*51.1/11010628, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* z4jets = getSample("DY4JetsToLL", lumi*23.04/6391785, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd = getSample("QCD_Pt-15to20_MuEnrichedPt5", lumi*34679.3/8500505, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd1 = getSample("QCD_Pt-15to20_MuEnrichedPt5", lumi*7.022e8 * 0.0039/1722678, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd2 = getSample("QCD_Pt-20to30_MuEnrichedPt5", lumi*2.87e8 * 0.0065/8486893, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd3 = getSample("QCD_Pt-30to50_MuEnrichedPt5", lumi*6.609e7 * 0.0122/8928999, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd4 = getSample("QCD_Pt-50to80_MuEnrichedPt5", lumi*8082000.0 * 0.0218/7256011, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd5 = getSample("QCD_Pt-80to120_MuEnrichedPt5", lumi*1024000.0 * 0.0395/9030624, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd6 = getSample("QCD_Pt-120to170_MuEnrichedPt5", lumi*157800.0 * 0.0473/8500505, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd7 = getSample("QCD_Pt-170to300_MuEnrichedPt5", lumi*34020.0 * 0.0676/7662483, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd8 = getSample("QCD_Pt-300to470_MuEnrichedPt5", lumi*1757.0 * 0.0864/7797481, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd9 = getSample("QCD_Pt-470to600_MuEnrichedPt5", lumi*115.2 * 0.1024/2995767, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd10 = getSample("QCD_Pt-800to1000_MuEnrichedPt5",lumi*3.57 * 0.1033/4047142, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd11 = getSample("QCD_Pt-1000_MuEnrichedPt5", lumi*0.774 * 0.1097/3807263, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* top_t = getSample("T_t-channel", lumi*56.4/3757707, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* top_tw = getSample("T_tW-channel", lumi*11.1/497395, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* top_s = getSample("T_s-channel", lumi*3.79/249516, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* tbar_t = getSample("Tbar_t-channel", lumi*30.7/1934817, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* tbar_tw = getSample("Tbar_tW-channel", lumi*11.1/493239, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* tbar_s = getSample("Tbar_s-channel", lumi*1.76/139948, Obj, Variable, Isolation, rebinFact, Systematic); //make combined top and single top template TH1D* sing_top = (TH1D*)top_t->Clone("top"); sing_top->Add(top_tw);sing_top->Add(top_s); sing_top->Add(tbar_t); sing_top->Add(tbar_tw);sing_top->Add(tbar_s); if(inclQ == true){ qcd->Add(qcd); }else{ qcd1->Add(qcd2); qcd1->Add(qcd3); qcd1->Add(qcd4); qcd1->Add(qcd5); qcd1->Add(qcd6); qcd1->Add(qcd7); qcd1->Add(qcd8); qcd1->Add(qcd9); qcd1->Add(qcd10); qcd1->Add(qcd11); } TH1D* qcd_data = getQCD(Obj, Variable, rebinFact); qcd_data->Scale(qcd1->Integral()); THStack *hs = new THStack("hs","test"); if(inclQ == true){ hs->Add(qcd_data); }else{ hs->Add(qcd_data); } zjets->Add(z2jets); zjets->Add(z3jets); zjets->Add(z4jets); wjets->Add(w2jets); wjets->Add(w3jets); wjets->Add(w4jets); hs->Add(zjets); hs->Add(wjets); hs->Add(top_t); hs->Add(top_tw); hs->Add(top_s); hs->Add(tbar_t); hs->Add(tbar_tw); hs->Add(tbar_s); hs->Add(tt); TH1D* allMC = (TH1D*)tt->Clone("allMC"); allMC->Add(sing_top); allMC->Add(wjets); allMC->Add(zjets); allMC->Add(qcd1); cout << "tt: " << tt->Integral() << " wjets: " << wjets->Integral() << " zjets: " << zjets->Integral() << " single top: " << sing_top->Integral() << " qcd: " << qcd1->Integral() << " all: " << allMC->Integral() << " data: " << data->Integral() << endl; //draw histos to files TCanvas *c1 = new TCanvas("Plot","Plot",900, 600); hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.3); hs->Draw(); data->Draw("E same"); data->SetMarkerStyle(20); hs->GetXaxis()->SetLimits(MinX, MaxX); hs->GetXaxis()->SetTitle(Xtitle); hs->GetXaxis()->SetTitleSize(0.05); hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05); TLegend *tleg2; tleg2 = new TLegend(0.6,0.6,0.8,0.9); tleg2->SetTextSize(0.04); tleg2->SetBorderSize(0); tleg2->SetFillColor(10); tleg2->AddEntry(data , "2012 data", "lpe"); tleg2->AddEntry(tt , "t#bar{t} l+jets", "lf"); //tleg2->AddEntry(tt_lep , "t#bar{t} di-lepton", "lf"); tleg2->AddEntry(top_t, "single top", "lf"); tleg2->AddEntry(wjets , "w+jets", "lf"); tleg2->AddEntry(zjets , "z+jets", "lf"); tleg2->AddEntry(qcd , "QCD", "lf"); //tleg2->AddEntry(singtEff, "single-t" , "l"); //tleg2->AddEntry(singtwEff, "single-tW" , "l"); tleg2->Draw("same"); TText* textPrelim = doPrelim(0.12,0.96); textPrelim->Draw(); if(logPlot ==true){ c1->SetLogy(); } TString plotName("plots/Control/Muon/"); if(logPlot ==true){ plotName += Variable+"Log"; plotName += Nbtags+".pdf"; }else{ plotName += Variable; plotName += Nbtags+".pdf"; } c1->SaveAs(plotName); delete c1; } }
void doControlPlotsMuons(){ setTDRStyle(); //loop over variables for(int i = 0; i<N; i++){ //double MinX = MinXs[i]; //double MaxX = MaxXs[i]; RebinFact = RebinFacts[i]; Variable = Variables[i]; TString Xtitle = XTitles[i]; //Data TH1D* data = getSample("DoubleMu", 1, Obj, Next, Variable, RebinFact, Systematic); std::cout << data->Integral() << std::endl; //MC TH1D* tt = getSample("TTJet", 1, Obj, Next, Variable, RebinFact, Systematic); TH1D* wjets = getSample("WJetsToLNu", 1, Obj, Next, Variable, RebinFact, Systematic); TH1D* DY1 = getSample("DYJetsToLL_M-10To50", 1, Obj, Next, Variable, RebinFact, Systematic); TH1D* DY2 = getSample("DYJetsToLL_M-50", 1, Obj, Next, Variable, RebinFact, Systematic); TH1D* T_tW = getSample("T_tW-channel", 1, Obj, Next, Variable, RebinFact, Systematic); TH1D* Tbar_tW = getSample("Tbar_tW-channel",1, Obj, Next, Variable, RebinFact, Systematic); THStack *hs = new THStack("hs","test"); hs->Add(wjets); hs->Add(DY1); hs->Add(DY2); hs->Add(T_tW); hs->Add(Tbar_tW); hs->Add(tt); //draw histos to files TCanvas *c1 = new TCanvas("Plot","Plot",900, 600); hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.3); hs->Draw(); data->Draw("E same"); data->SetMarkerStyle(20); // hs->GetXaxis()->SetLimits(MinX, MaxX); hs->GetXaxis()->SetTitle(Xtitle); hs->GetXaxis()->SetTitleSize(0.05); hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05); if(logPlot == true){ c1->SetLogy(); } TLegend *tleg2; tleg2 = new TLegend(0.6,0.7,0.8,0.9); tleg2->SetTextSize(0.04); tleg2->SetBorderSize(0); tleg2->SetFillColor(10); tleg2->AddEntry(data , "2012 data", "lpe"); tleg2->AddEntry(tt , "t#bar{t}", "lf"); tleg2->AddEntry(T_tW, "single-t", "lf"); tleg2->AddEntry(Tbar_tW, "single-#bar{t}", "lf"); tleg2->AddEntry(DY1 , "DYJetsToLL-10To50", "lf"); tleg2->AddEntry(DY2 , "DYJetsToLL-50", "lf"); tleg2->AddEntry(wjets , "W+jets", "lf"); tleg2->Draw("same"); TString plotName("plots/Control/PassesCutsUpTo1Btag/Muons/"); if(logPlot == true){ plotName += Variable+"Log.pdf"; // plotName += Nbtags+".pdf"; }else{ plotName += Variable+".pdf"; // plotName += Nbtags+".pdf"; } TText* textPrelim = doPrelim(0.16,0.96); textPrelim->Draw(); c1->SaveAs(plotName); delete c1; } }
void CutFlow::ratioCutFlowPlot(TH1D* data, THStack *hs, AllSamples samples, Variable variable){ //draw histos with ratio plot float r = 0.3; float epsilon = 0.02; TCanvas *c2 = new TCanvas("Plot","Plot",635, 600); c2->SetFillColor(0); c2->SetFrameFillStyle(0); TPad *pad1 = new TPad("pad1","pad1",0,r-epsilon,1,1); pad1->SetBottomMargin(epsilon); c2->cd(); pad1->Draw(); pad1->cd(); hs->Draw("hist"); hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.3); hs->GetXaxis()->SetLimits(variable.minX, variable.maxX); hs->GetXaxis()->SetTitle(variable.xTitle); hs->GetXaxis()->SetTitleSize(0.05); hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05); if(Globals::addHashErrors){ TH1D* hashErrs = hashErrors(samples, variable); hashErrs->Draw("same e2"); } data->Draw("E same"); //data->SetMarkerStyle(20); data->SetMarkerSize(0.5); TLegend* leg = legend(samples); leg->Draw(); TText* textChan = doChan(0.12,0.96); textChan->Draw(); TText* textPrelim = doPrelim(0.58,0.96); textPrelim->Draw(); TPad *pad2 = new TPad("pad2","pad2",0,0,1,r*(1-epsilon)); pad2->SetTopMargin(0); pad2->SetFrameFillStyle(4000); pad2->SetBottomMargin(0.4); c2->cd(); pad2->Draw(); pad2->cd(); TH1D * allMC = allMChisto(samples, variable); TH1D * ratio = (TH1D*)data->Clone("ratio plot"); ratio->Sumw2(); ratio->SetStats(0); cout << "ratio bins: " << ratio->GetNbinsX() << endl; cout << "all mc bins: " << allMC->GetNbinsX() << endl; ratio->Divide(allMC); ratio->SetMaximum(2); ratio->SetMinimum(0.); setBinLabels(hs, ratio); // Will need to see if this works in other situations ratio->SetLabelSize(0.1, "X"); ratio->SetTitleOffset(0.5, "Y"); ratio->SetTitleOffset(0.8, "X"); ratio->GetYaxis()->SetTitle("data/MC");ratio->GetYaxis()->SetTitleSize(0.1); ratio->GetXaxis()->SetTitle(variable.xTitle);ratio->GetXaxis()->SetTitleSize(0.15); ratio->Draw("ep"); TLine *line = new TLine(variable.minX,1,variable.maxX,1); line->Draw(); pad1->cd(); pad1->SetLogy(); c2->SaveAs("Plots/ControlPlots/"+objName+"/Log/"+variable.name+"_ratio.png"); c2->SaveAs("Plots/ControlPlots/"+objName+"/Log/"+variable.name+"_ratio.pdf"); delete c2; delete leg; delete textChan; delete textPrelim; }
void doPlotsBtag(){ setTDRStyle(); //loop over variables for(int i = 0; i<2; i++){ double MinX = MinXs[i]; double MaxX = MaxXs[i]; Variable = Variables[i]; TString Xtitle = XTitles[i]; //Data TH1D* data = getSample("SingleMu", 1); //MC TH1D* tt = getSample("TTJet", lumi*225.2/6920475); TH1D* wjets = getSample("W1Jet", lumi*37509/57708550); TH1D* w1jets = getSample("W1Jet", lumi*5400.0/23140779); TH1D* w2jets = getSample("W2Jets", lumi*1750.0/34041404); TH1D* w3jets = getSample("W3Jets", lumi*519.0/15536443); TH1D* w4jets = getSample("W4Jets", lumi*214.0/13370904); TH1D* zjets = getSample("DY1JetsToLL", lumi*5745.25/30457954); TH1D* z1jets = getSample("DY1JetsToLL", lumi*561.0/24042904); TH1D* z2jets = getSample("DY2JetsToLL", lumi*181.0/21835749); TH1D* z3jets = getSample("DY3JetsToLL", lumi*51.1/11010628); TH1D* z4jets = getSample("DY4JetsToLL", lumi*23.04/6391785); TH1D* qcd = getSample("QCD_Pt-15to20_MuEnrichedPt5", lumi*34679.3/8500505); TH1D* qcd1 = getSample("QCD_Pt-15to20_MuEnrichedPt5", lumi*7.022e8 * 0.0039/1722678); TH1D* qcd2 = getSample("QCD_Pt-20to30_MuEnrichedPt5", lumi*2.87e8 * 0.0065/8486893); TH1D* qcd3 = getSample("QCD_Pt-30to50_MuEnrichedPt5", lumi*6.609e7 * 0.0122/8928999); TH1D* qcd4 = getSample("QCD_Pt-50to80_MuEnrichedPt5", lumi*8082000.0 * 0.0218/7256011); TH1D* qcd5 = getSample("QCD_Pt-80to120_MuEnrichedPt5", lumi*1024000.0 * 0.0395/9030624); TH1D* qcd6 = getSample("QCD_Pt-120to170_MuEnrichedPt5", lumi*157800.0 * 0.0473/8500505); TH1D* qcd7 = getSample("QCD_Pt-170to300_MuEnrichedPt5", lumi*34020.0 * 0.0676/7662483); TH1D* qcd8 = getSample("QCD_Pt-300to470_MuEnrichedPt5", lumi*1757.0 * 0.0864/7797481); TH1D* qcd9 = getSample("QCD_Pt-470to600_MuEnrichedPt5", lumi*115.2 * 0.1024/2995767); TH1D* qcd10 = getSample("QCD_Pt-800to1000_MuEnrichedPt5",lumi*3.57 * 0.1033/4047142); TH1D* qcd11 = getSample("QCD_Pt-1000_MuEnrichedPt5", lumi*0.774 * 0.1097/3807263); TH1D* top_t = getSample("T_t-channel", lumi*56.4/3757707); TH1D* top_tw = getSample("T_tW-channel", lumi*11.1/497395); TH1D* top_s = getSample("T_s-channel", lumi*3.79/249516); TH1D* tbar_t = getSample("Tbar_t-channel", lumi*30.7/1934817); TH1D* tbar_tw = getSample("Tbar_tW-channel", lumi*11.1/493239); TH1D* tbar_s = getSample("Tbar_s-channel", lumi*1.76/139948); THStack *hs = new THStack("hs","test"); if(inclQ == true){ hs->Add(qcd); }else{ hs->Add(qcd1); hs->Add(qcd2); hs->Add(qcd3); hs->Add(qcd4); hs->Add(qcd5); hs->Add(qcd6); hs->Add(qcd7); hs->Add(qcd8); hs->Add(qcd9); hs->Add(qcd10); hs->Add(qcd11); } if(inclZ == true){ hs->Add(zjets); }else{ hs->Add(z1jets); hs->Add(z2jets); hs->Add(z3jets); hs->Add(z4jets); } if(inclW == true){ hs->Add(wjets); }else{ hs->Add(w1jets); hs->Add(w2jets); hs->Add(w3jets); hs->Add(w4jets); } hs->Add(top_t); hs->Add(top_tw); hs->Add(top_s); hs->Add(tbar_t); hs->Add(tbar_tw); hs->Add(tbar_s); hs->Add(tt); //draw histos to files TCanvas *c1 = new TCanvas("Plot","Plot",900, 600); hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.2); hs->Draw(); data->Draw("E same"); data->SetMarkerStyle(20); //events: cout << "ttbar: " << tt->Integral() << endl; cout << "data: " << data->Integral() << endl; hs->GetXaxis()->SetLimits(MinX, MaxX); hs->GetXaxis()->SetTitle(Xtitle); hs->GetXaxis()->SetTitleSize(0.05); hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05); TLegend *tleg2; tleg2 = new TLegend(0.7,0.7,0.8,0.9); tleg2->SetTextSize(0.04); tleg2->SetBorderSize(0); tleg2->SetFillColor(10); tleg2->AddEntry(data , "2012 data", "lpe"); tleg2->AddEntry(tt , "t#bar{t}", "lf"); tleg2->AddEntry(top_t, "single top", "lf"); tleg2->AddEntry(wjets , "w+jets", "lf"); tleg2->AddEntry(zjets , "z+jets", "lf"); tleg2->AddEntry(qcd , "QCD", "lf"); //tleg2->AddEntry(singtEff, "single-t" , "l"); //tleg2->AddEntry(singtwEff, "single-tW" , "l"); tleg2->Draw("same"); TText* textPrelim = doPrelim(0.17,0.96); textPrelim->Draw(); if(logPlot ==true){ c1->SetLogy(); } TString plotName("plots/Control/Btags/"); if(logPlot ==true){ plotName += Variable+"Test_Log"; plotName += ".pdf"; }else{ plotName += Variable; plotName += ".pdf"; } c1->SaveAs(plotName); delete c1; } }
void QCDxcheck_shape() { setTDRStyle(); //MET will need choice of variable at the top // TString Variable = "MET"; // int Nbins = 6; // TString bins[6] = {"_bin_0-25", "_bin_25-45", "_bin_45-70", "_bin_70-100", "_bin_100-150", "_bin_150-inf"}; // double xbins[7] = {0,25,45,70,100,150, 250}; // TString Xtitle = "E_{T}^{miss} "; TString Variable ="WPT"; int Nbins = 6; TString bins[6] = {"_bin_0-40", "_bin_40-70", "_bin_70-100", "_bin_100-130", "_bin_130-170", "_bin_170-inf"}; double xbins[7] = {1,40,70,100,130,170,220}; TString Xtitle = "p_{T}(W)"; // TString Variable ="MT"; // int Nbins = 5; // TString bins[5] = {"_bin_0-30", "_bin_30-50", "_bin_50-80", "_bin_80-100", "_bin_100-inf"}; // double xbins[6] = {1,30,50,80,100,150}; // TString Xtitle = "M(W)_{T}"; // TString Variable ="ST"; // int Nbins = 7; // TString bins[7] = {"_bin_0-350","_bin_350-400", "_bin_400-450", "_bin_450-500", "_bin_500-580", "_bin_580-700", "_bin_700-inf"}; // double xbins[8] = {1,350,400,450,500,580,700,1000}; // TString Xtitle = "S_{T}"; // TString Variable ="HT"; // int Nbins = 7; // TString bins[7] = {"_bin_0-240", "_bin_240-280", "_bin_280-330", "_bin_330-380", "_bin_380-450", "_bin_450-600", "_bin_600-inf"}; // double xbins[8] = {1,240,280,330,380,450,600,800}; // TString Xtitle = "H_{T}"; //differential histo TH1D *qcd_data = new TH1D("qcd data", "", Nbins, xbins); for(int i = 0; i < Nbins; i++) { TString Obj; if(Variable == "MET") { Obj = "Binned_"+Variable+"_Analysis/patType1CorrectedPFMet"+bins[i]+"/muon_absolute_eta_"; } else if(Variable == "HT") { Obj = "Binned_"+Variable+"_Analysis/HT"+bins[i]+"/muon_absolute_eta_"; } else { Obj = "Binned_"+Variable+"_Analysis/"+Variable+"_with_patType1CorrectedPFMet"+bins[i]+"/muon_absolute_eta_"; } double error; double content = getQCD(Variable, Obj, 1, &error); qcd_data->SetBinContent(i+1, content); qcd_data->SetBinError(i+1, error); } qcd_data->Sumw2(); qcd_data->Scale(1./qcd_data->Integral()); for(int i = 0; i < Nbins; i++) { cout << qcd_data->GetBinContent(i+1) << ", "; } cout << " " << endl; //get fit results TFile* fit_file = new TFile("outFiles/diffResults_"+Variable+"_bin_0-40.root"); TH1D* fit = (TH1D*) fit_file->Get("central_dir/central_qcd_fit"); fit->SetLineColor(kRed); fit->SetMarkerColor(kRed); fit->SetMarkerSize(0.1); fit->Sumw2(); fit->Scale(1./fit->Integral()); TFile* fit_200f = new TFile("outFiles/diffResults_"+Variable+".root"); TH1D* fit_200 = (TH1D*) fit_200f->Get("central_dir/central_qcd_fit"); fit_200->SetLineColor(kGreen); fit_200->SetMarkerColor(kGreen); fit_200->SetMarkerSize(0.1); fit_200->Sumw2(); fit_200->Scale(1./fit_200->Integral()); TFile* fit_noconf = new TFile("outFiles/diffResults_"+Variable+"_bin_100-130.root"); TH1D* fit_nocon = (TH1D*) fit_noconf->Get("central_dir/central_qcd_fit"); fit_nocon->SetLineColor(kMagenta); fit_nocon->SetMarkerColor(kMagenta); fit_nocon->SetMarkerSize(0.1); fit_nocon->Sumw2(); fit_nocon->Scale(1./fit_nocon->Integral()); TFile* fit_dataf = new TFile("outFiles/diffResults_"+Variable+"_bins.root"); TH1D* fit_data = (TH1D*) fit_dataf->Get("central_dir/central_qcd_fit"); fit_data->SetLineColor(kYellow); fit_data->SetMarkerColor(kYellow); fit_data->Sumw2(); fit_data->Scale(1./fit_data->Integral()); TCanvas *c1 = new TCanvas("Plot","Plot",900, 600); //qcd_data->Draw("E"); //qcd_data->SetAxisRange(MinXs[3], MaxXs[3], "X"); fit_200->Draw("E1"); fit->Draw("E1same"); fit_data->Draw("E1same"); fit_nocon->Draw("E1same"); //qcd_data->Draw("E1same"); TLegend *tleg; tleg = new TLegend(0.45,0.55,0.85,0.9); tleg->SetTextSize(0.03); tleg->SetBorderSize(0); tleg->SetFillColor(10); //tleg->AddEntry(qcd_data , "Data Driven E_{T}^{miss} (QCD non-iso)" , "lep"); tleg->AddEntry(fit_data , "Fit Results, different bins " , "lep"); tleg->AddEntry(fit , "Fit Results, |#eta| from WPT 0-40" , "lep"); tleg->AddEntry(fit_200 , "Fit Results, nominal |#eta|" , "lep"); tleg->AddEntry(fit_nocon , "Fit Results, |#eta| from WPT 100-130" , "lep"); tleg->Draw(); fit_200->GetYaxis()->SetTitle("Normalised Events"); fit_200->GetYaxis()->SetTitleSize(0.05); fit_200->GetXaxis()->SetTitle(Xtitle+" [GeV]"); fit_200->GetXaxis()->SetTitleSize(0.05); TText* textPrelim = doPrelim(0.12,0.96); textPrelim->Draw(); c1->SaveAs("plots/QCDxcheck_shape/"+Variable+"shapecheck.png"); }
void doControlPlotsMET(){ setTDRStyle(); gROOT->SetBatch(); gStyle->SetErrorX(0.5); //loop over variables for(int i = 0; i<N; i++){ double MinX = MinXs[i]; double MaxX = MaxXs[i]; Variable = Variables[i]; TString Xtitle = XTitles[i]; int RebinFact = RebinFacts[i]; //Data TH1D* data; if(Obj == "MuMu/") data = getSample("DoubleMu", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); if(Obj == "EE/") data = getSample("DoubleElectron", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); if(Obj == "EMu/") data = getSample("MuEG", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); //MC TH1D* ttgamma = getSample("TTGamma", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); //this to get all ttbar TH1D* tt; TH1D* tt_lep; TH1D* tt_sig; if(inclTop == false){ //fake ttgamma tt = getSample("TTJet", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut, "fake"); tt_lep = getSample("TTJet", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut, "lep"); tt_sig = getSample("TTJet", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut, "sig"); }else{ tt = getSample("TTJet", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); } TH1D* wjets = getSample("WJetsToLNu", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); TH1D* DY1 = getSample("DYJetsToLL_M-10To50", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); TH1D* DY2 = getSample("DYJetsToLL_M-50", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); TH1D* T_tW = getSample("T_tW-channel", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); TH1D* Tbar_tW = getSample("Tbar_tW-channel",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); TH1D* ZZ = getSample("ZZtoAnything",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); TH1D* WW = getSample("WWtoAnything",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); TH1D* WZ = getSample("WZtoAnything",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); //QCD TH1D* QCD_Pt_20_30_BCtoE = getSample("QCD_Pt_20_30_BCtoE",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); TH1D* QCD_Pt_20_30_EMEnriched = getSample("QCD_Pt_20_30_EMEnriched",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); //TH1D* QCD_Pt_20_MuEnrichedPt_15 = getSample("QCD_Pt_20_MuEnrichedPt_15",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); TH1D* QCD_Pt_30_80_BCtoE = getSample("QCD_Pt_30_80_BCtoE",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); TH1D* QCD_Pt_30_80_EMEnriched = getSample("QCD_Pt_30_80_EMEnriched",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); TH1D* QCD_Pt_80_170_BCtoE = getSample("QCD_Pt_80_170_BCtoE",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); TH1D* QCD_Pt_80_170_EMEnriched = getSample("QCD_Pt_80_170_EMEnriched",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); TH1D* QCD_all = getSample("QCD_Pt_20_MuEnrichedPt_15",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut); QCD_all->Add(QCD_Pt_20_30_BCtoE); QCD_all->Add(QCD_Pt_20_30_EMEnriched); QCD_all->Add(QCD_Pt_30_80_BCtoE); QCD_all->Add(QCD_Pt_30_80_EMEnriched); QCD_all->Add(QCD_Pt_80_170_BCtoE); QCD_all->Add(QCD_Pt_80_170_EMEnriched); TH1D* allMC = (TH1D*)ttgamma->Clone("ratio"); allMC->Add(tt); if(inclTop == false){ allMC->Add(tt_lep); allMC->Add(tt_sig); } allMC->Add(wjets); allMC->Add(DY1); allMC->Add(DY2); allMC->Add(T_tW); allMC->Add(Tbar_tW); allMC->Add(ZZ); allMC->Add(WW); allMC->Add(WZ); allMC->Add(QCD_all); allMC->SetFillColor(kBlack); allMC->SetFillStyle(3354); allMC->SetMarkerSize(0.); allMC->SetStats(0); THStack *hs = new THStack("hs","test"); hs->Add(QCD_all); hs->Add(wjets); hs->Add(WZ); hs->Add(WW); hs->Add(ZZ); hs->Add(DY1); hs->Add(DY2); hs->Add(T_tW); hs->Add(Tbar_tW); hs->Add(tt); if(inclTop == false){ hs->Add(tt_lep); hs->Add(tt_sig); } hs->Add(ttgamma); std::cout << "Total number of events" << std::endl; std::cout << "Data: " << data->Integral() << std::endl; std::cout << "ttbar + gamma: " << ttgamma->Integral() << std::endl; std::cout << "Inclusive ttbar: " << tt->Integral() << std::endl; std::cout << "W+Jets: " << wjets->Integral() << std::endl; std::cout << "Drell-Yan1: " << DY1->Integral() << std::endl; std::cout << "Drell-Yan2: " << DY2->Integral() << std::endl; std::cout << "Single top: " << T_tW->Integral() << std::endl; std::cout << "Anti-Single top: " << Tbar_tW->Integral() << std::endl; std::cout << "ZZ: " << ZZ->Integral() << std::endl; std::cout << "WW: " << WW->Integral() << std::endl; std::cout << "WZ: " << WZ->Integral() << std::endl; std::cout << "QCD: " << QCD_all->Integral() << std::endl; //draw histos to files TCanvas *c1 = new TCanvas("Plot","Plot",900, 600); TPad *pad1 = new TPad("pad1","pad1",0,0.3,1,1); pad1->SetBottomMargin(0); pad1->Draw(); pad1->cd(); data->Draw("e x0"); data->SetAxisRange(MinX, MaxX, "X"); hs->Draw("hist"); allMC->Draw("same e2"); hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.3); data->Draw("E same"); data->SetMarkerStyle(20); hs->GetXaxis()->SetLimits(MinX, MaxX); hs->GetXaxis()->SetTitle(Xtitle); hs->GetXaxis()->SetTitleSize(0.05); hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05); TLegend *tleg2; tleg2 = new TLegend(0.7, 0.6, 0.8, 0.9); tleg2->SetTextSize(0.04); tleg2->SetBorderSize(0); tleg2->SetFillColor(10); tleg2->AddEntry(data , "2012 data", "lpe"); tleg2->AddEntry(ttgamma , "t#bar{t}#gamma", "lf"); if(inclTop == false){ tleg2->AddEntry(tt_sig , "t#bar{t}#gamma (MG)", "lf"); tleg2->AddEntry(tt_lep , "t#bar{t} l #rightarrow #gamma (MG)", "lf"); tleg2->AddEntry(tt , "t#bar{t} fake (MG)", "lf"); }else{ tleg2->AddEntry(tt , "t#bar{t}", "lf"); } tleg2->AddEntry(T_tW, "Single Top" , "lf"); // tleg2->AddEntry(Tbar_tW, "anti-single-tW" , "lf"); tleg2->AddEntry(DY1 , "Z+Jets", "lf"); // tleg2->AddEntry(DY2 , "DYJetsToLL", "lf"); tleg2->AddEntry(ZZ, "Diboson", "lf"); // tleg2->AddEntry(WW, "WW", "lf"); // tleg2->AddEntry(WZ , "WZ", "lf"); tleg2->AddEntry(wjets , "W+Jets", "lf"); tleg2->AddEntry(QCD_all, "QCD", "lf"); tleg2->Draw("same"); TText* textPrelim = doPrelim(0.20, 0.96, Cut, Obj); textPrelim->Draw(); c1->cd(); if(logPlot == true){ c1->SetLogy(); } TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.3); pad2->SetTopMargin(0); pad2->SetBottomMargin(0.4); pad2->Draw(); pad2->cd(); TH1D * ratio = (TH1D*)data->Clone("ratio plot"); //ratio->Sumw2(); ratio->SetStats(0); ratio->Divide(allMC); ratio->SetMinimum(0); ratio->SetMaximum(2); ratio->SetFillColor(kBlack); ratio->SetFillStyle(3354); ratio->SetMarkerSize(0.); cout << "width: " << ratio->GetBinWidth(1) << std::endl; if(MaxX <= 0.1){ ratio->SetAxisRange(MinX, MaxX); }else{ ratio->SetAxisRange(MinX, MaxX-ratio->GetBinWidth(1)); } ratio->SetLabelSize(0.1, "X"); ratio->SetTitleOffset(0.5, "Y"); ratio->GetYaxis()->SetTitle("data/MC");ratio->GetYaxis()->SetTitleSize(0.1); ratio->GetXaxis()->SetTitle(Xtitle);ratio->GetXaxis()->SetTitleSize(0.15); ratio->Draw("ep"); TLine *line; if(MaxX <= 0.1){ line = new TLine(MinX,1,MaxX,1); }else{ line = new TLine(MinX,1,MaxX-ratio->GetBinWidth(1),1); } line->Draw(); TString plotName("plots/Control/"+ Obj + Cut + Type + Next ); if(logPlot == true){ plotName += Variable+"ge1b_Log.pdf"; }else{ plotName += Variable+"ge1b"; } c1->SaveAs(plotName+".pdf"); c1->SaveAs(plotName+".png"); delete c1; } }
void controlPostFit() { setTDRStyle(); //loop over variables for(int i = 0; i<N; i++) { int rebinFact = rebinFactor[i]; double MinX = MinXs[i]; double MaxX = MaxXs[i]; Variable = Variables[i]; TString Xtitle = XTitles[i]; Var = i; //Data TH1D* data = getSample("SingleMu", 1, Obj, Variable, Isolation, rebinFact, "central"); //MC TH1D* tt = getSample("TTJetPTRW", lumi*225.2/6920475, Obj, Variable, Isolation, rebinFact, Systematic); //TH1D* tt = getSample("TTJet_POWHEG", lumi*225.2/6920475, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* vjets = getSample("VJets", lumi*5400.0/23140779, Obj, Variable, Isolation, rebinFact, Systematic); //TH1D* qcd = getSample("QCD_Pt-15to20_MuEnrichedPt5", lumi*34679.3/8500505, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd = getSample("QCD_Pt-15to20_MuEnrichedPt5", lumi*7.022e8 * 0.0039/1722678, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd2 = getSample("QCD_Pt-20to30_MuEnrichedPt5", lumi*2.87e8 * 0.0065/8486893, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd3 = getSample("QCD_Pt-30to50_MuEnrichedPt5", lumi*6.609e7 * 0.0122/8928999, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd4 = getSample("QCD_Pt-50to80_MuEnrichedPt5", lumi*8082000.0 * 0.0218/7256011, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd5 = getSample("QCD_Pt-80to120_MuEnrichedPt5", lumi*1024000.0 * 0.0395/9030624, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd6 = getSample("QCD_Pt-120to170_MuEnrichedPt5", lumi*157800.0 * 0.0473/8500505, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd7 = getSample("QCD_Pt-170to300_MuEnrichedPt5", lumi*34020.0 * 0.0676/7662483, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd8 = getSample("QCD_Pt-300to470_MuEnrichedPt5", lumi*1757.0 * 0.0864/7797481, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd9 = getSample("QCD_Pt-470to600_MuEnrichedPt5", lumi*115.2 * 0.1024/2995767, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd10 = getSample("QCD_Pt-800to1000_MuEnrichedPt5",lumi*3.57 * 0.1033/4047142, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* qcd11 = getSample("QCD_Pt-1000_MuEnrichedPt5", lumi*0.774 * 0.1097/3807263, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* single_t = getSample("T_t-channel", lumi*56.4/3757707, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* top_t = getSample("T_t-channel", lumi*56.4/3757707, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* top_tw = getSample("T_tW-channel", lumi*11.1/497395, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* top_s = getSample("T_s-channel", lumi*3.79/249516, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* tbar_t = getSample("Tbar_t-channel", lumi*30.7/1934817, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* tbar_tw = getSample("Tbar_tW-channel", lumi*11.1/493239, Obj, Variable, Isolation, rebinFact, Systematic); TH1D* tbar_s = getSample("Tbar_s-channel", lumi*1.76/139948, Obj, Variable, Isolation, rebinFact, Systematic); single_t->Add(top_tw); single_t->Add(top_s); single_t->Add(tbar_t); single_t->Add(tbar_tw); single_t->Add(tbar_s); qcd->Add(qcd2); qcd->Add(qcd3); qcd->Add(qcd4); qcd->Add(qcd5); qcd->Add(qcd6); qcd->Add(qcd7); qcd->Add(qcd8); qcd->Add(qcd9); qcd->Add(qcd10); qcd->Add(qcd11); TH1D* qcd_data = getQCD(Obj, Variable, rebinFact); qcd_data->Scale(qcd->Integral()); //tt->Add(single_t); //scales from fits with V constraint // tt->Scale(17771.9/tt->Integral()); // vjets->Scale(600.4/vjets->Integral()); // qcd_data->Scale(1801.9/qcd_data->Integral()); //tt->Scale(17541.7/tt->Integral()); //vjets->Scale(1557.4/vjets->Integral()); //qcd_data->Scale(1078.0/qcd_data->Integral()); //50% mad and 200% qcd // tt->Scale(19190.3/tt->Integral()); // vjets->Scale(774.0/vjets->Integral()); // qcd_data->Scale(198.0/qcd_data->Integral()); //no consts new // tt->Scale(70722.9/tt->Integral()); // vjets->Scale(5290.4/vjets->Integral()); // qcd_data->Scale(6006.9/qcd_data->Integral()); //all 50% mad and 200% qcd consts new tt->Scale(76278.2/tt->Integral()); vjets->Scale(3597.5/vjets->Integral()); qcd_data->Scale(2086.8/qcd_data->Integral()); TH1D * allMC = (TH1D*)tt->Clone("ratio"); allMC->Add(vjets); allMC->Add(qcd_data); //powheg // tt->Scale(18629.55/tt->Integral()); // vjets->Scale(1055.54/vjets->Integral()); // qcd_data->Scale(492.10/qcd_data->Integral()); // //powheg ST fit // tt->Scale(18668.3634/tt->Integral()); // vjets->Scale(1139.9548/vjets->Integral()); // qcd_data->Scale(368.7360/qcd_data->Integral()); THStack *hs = new THStack("hs","test"); hs->Add(qcd_data); hs->Add(vjets); hs->Add(top_t); hs->Add(top_tw); hs->Add(top_s); hs->Add(tbar_t); hs->Add(tbar_tw); hs->Add(tbar_s); single_t->Add(top_tw); single_t->Add(top_s); single_t->Add(tbar_t); single_t->Add(tbar_tw); single_t->Add(tbar_s); hs->Add(tt); std::cout << "tot data: " << data->Integral() << std::endl; std::cout << "tot tt & " << "tot v & " << "sing & "<< "qcd & " << std::endl; std::cout << tt->Integral() << " & " << vjets->Integral() << " & " << single_t->Integral() << " & "<< qcd->Integral()<< " & "<< std::endl; //draw histos to files TCanvas *c1 = new TCanvas("Plot","Plot",900, 600); TPad *pad1 = new TPad("pad1","pad1",0,0.3,1,1); pad1->SetBottomMargin(0); pad1->Draw(); pad1->cd(); data->Draw(); data->SetAxisRange(MinX, MaxX, "X"); data->Draw(); hs->Draw("H"); hs->GetXaxis()->SetLimits(MinX, MaxX); data->SetMarkerStyle(20); hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.3); hs->GetXaxis()->SetTitle(Xtitle); hs->GetXaxis()->SetTitleSize(0.05); hs->GetYaxis()->SetTitle("Number of Events"); hs->GetYaxis()->SetTitleSize(0.05); hs->Draw("H"); data->Draw("E same"); TLegend *tleg2; tleg2 = new TLegend(0.7,0.7,0.8,0.9); tleg2->SetTextSize(0.04); tleg2->SetBorderSize(0); tleg2->SetFillColor(10); tleg2->AddEntry(data , "2012 data", "lpe"); tleg2->AddEntry(tt , "t#bar{t}", "lf"); tleg2->AddEntry(top_t, "single top" , "lf"); tleg2->AddEntry(vjets , "v+jets", "lf"); tleg2->AddEntry(qcd, "QCD" , "lf"); //tleg2->AddEntry(singtwEff, "single-tW" , "l"); tleg2->Draw("same"); TText* textPrelim = doPrelim(0.12,0.96); textPrelim->Draw(); c1->cd(); if(logPlot ==true) { c1->SetLogy(); } TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.3); pad2->SetTopMargin(0); pad2->SetBottomMargin(0.4); pad2->Draw(); pad2->cd(); TH1D * ratio = (TH1D*)data->Clone("ratio plot"); ratio->Sumw2(); ratio->SetStats(0); ratio->Divide(allMC); ratio->SetMinimum(0.5); ratio->SetMaximum(1.5); cout << "width: " << ratio->GetBinWidth(1); ratio->SetAxisRange(MinX, MaxX-ratio->GetBinWidth(1)); //ratio->GetXaxis()->SetLimits(MinX, MaxX); ratio->SetLabelSize(0.1, "X"); ratio->SetTitleOffset(0.5, "Y"); ratio->GetYaxis()->SetTitle("data/MC"); ratio->GetYaxis()->SetTitleSize(0.1); ratio->GetXaxis()->SetTitle(Xtitle); ratio->GetXaxis()->SetTitleSize(0.15); ratio->Draw("ep"); TLine *line = new TLine(MinX,1,MaxX,1); line->Draw(); // c1->cd(); // pad1->cd(); // pad1->Draw(); // hs->Draw("H"); // data->Draw("E same"); TString plotName("plots/Control/"+Obj); if(logPlot == true) { plotName += Variable+"_Log"; plotName += Nbtags+"_ptreweight.pdf"; } else { plotName += Variable +Systematic+ "_" ; plotName += Nbtags+"_ptreweight.pdf"; //plotName += Nbtags+"_postfit.pdf"; } c1->SaveAs(plotName); delete c1; } }