void DrawEmpirical(const char* filename="Empirical.root", Bool_t fmd=true) { gStyle->SetOptTitle(0); TFile* file = TFile::Open(filename, "READ"); if (!file) return; Double_t yr = 0.3; TCanvas* c = new TCanvas("c","c", 1000,1000); TPad* p1 = new TPad("p1","p1",0,0,1,yr); TPad* p2 = new TPad("p2","p2",0,yr,1,1); c->cd(); p1->Draw(); c->cd(); p2->Draw(); gDirectory->cd("Forward"); THStack* r = DrawOne(p1, yr, false, gDirectory, "ratios"); THStack* e = DrawOne(p2, yr, true, gDirectory, "empirical"); r->SetMinimum(0.945); r->SetMaximum(1.055); r->GetXaxis()->SetTitle("#it{#eta}"); r->GetYaxis()->SetTitle("Ratio to mean"); e->SetMinimum(0.005); e->GetYaxis()->SetTitle("#it{E_{c}}(#it{#eta})"); TIter nextE(e->GetHists()); TIter nextR(r->GetHists()); TH1* hist = 0; Color_t cols[] = { kRed+2, kGreen+2, kBlue+2, kMagenta+2, 0 }; Color_t *ptr = cols; Style_t stys[] = { 20, 21, 22, 23 }; Style_t* sty = stys; while (*ptr) { hist = static_cast<TH1*>(nextE()); hist->SetMarkerColor(*ptr); hist->SetMarkerSize(2); hist->SetMarkerStyle(*sty); hist = static_cast<TH1*>(nextR()); hist->SetMarkerColor(*ptr); hist->SetMarkerSize(2); hist->SetMarkerStyle(*sty); ptr++; sty++; } TLegend* l = p2->BuildLegend(0.35, .2, .65, .8); l->SetFillColor(0); l->SetFillStyle(0); l->SetBorderSize(0); c->Modified(); c->Update(); c->cd(); c->Print("empirical.png"); }
//____________________________________________________________________ void Run(const char* newName, const char* oldName, const char* newTitle="New", const char* oldTitle="Old") { TFile* newFile = TFile::Open(newName,"READ"); TFile* oldFile = TFile::Open(oldName,"READ"); if (!newFile || !oldFile) return; TH1* newCent = GetH1(newFile, "realCent"); TH1* oldCent = GetH1(oldFile, "realCent"); if (!newCent || !oldCent) return; TString t; t.Form("#it{R}=#frac{%s}{%s}", newTitle, oldTitle); TCanvas* c = new TCanvas("c", t, 1200, 800); c->SetTopMargin(0.01); c->SetRightMargin(0.20); fLegend = new TLegend(1-c->GetRightMargin(), c->GetBottomMargin(), 1, 1-c->GetTopMargin(), t); fLegend->SetFillStyle(0); fLegend->SetBorderSize(0); THStack* stack = new THStack("ratios",""); fMin = +1e6; fMax = -1e6; TH1* one = 0; for (Int_t i = newCent->GetNbinsX(); i--;) { Double_t c1 = newCent->GetXaxis()->GetBinLowEdge(i+1); Double_t c2 = newCent->GetXaxis()->GetBinUpEdge(i+1); Info("", "c1=%f c2=%f", c1, c2); TH1* r = One(newFile, oldFile, c1, c2); if (!r) continue; if (!one) { one = static_cast<TH1*>(r->Clone("one")); one->SetDirectory(0); one->Reset(); for (Int_t j = 1; j <= one->GetNbinsX(); j++) { one->SetBinContent(j,1); one->SetBinError (j,0); } } // r->Add(one, i-1); // r->Scale(TMath::Power(10,i)); stack->Add(r); } stack->Draw("nostack"); stack->SetMinimum(0.95*fMin); stack->SetMaximum(1.05*fMax); stack->GetHistogram()->SetXTitle("#eta"); stack->GetHistogram()->SetYTitle("#it{R}"); fLegend->Draw(); c->Modified(); c->Update(); c->cd(); c->SaveAs(Form("%sover%s.png", newTitle, oldTitle)); }
void StackPlots( TFile* f1, vector<string> hist, vector<string> leg, vector<Color_t> color, string xtitle_, string ytitle_, string xunit, string savePath, bool ylog=0, int rebin=1){ int Bins = 0; int x1 = 0; int x2 = 0; int size = hist.size(); float binwidth = 0; char title[100], xtitle[100], ytitle[100]; TH1F* h1[size]; for(int i=0; i<size; i++){ h1[i] = (TH1F*)f1->Get(hist[i].c_str()); h1[i]->UseCurrentStyle(); h1[i]->Rebin(rebin); if( Bins != 0 ){ if( h1[i]->GetXaxis()->GetLast() != Bins ) { cout<<"Error: Exist different bin size( plot: "<<i<<")"<<endl; }} Bins = h1[i]->GetXaxis()->GetLast(); binwidth = h1[i]->GetBinWidth(1); x1 = h1[i]->GetXaxis()->GetBinLowEdge(1); x2 = h1[i]->GetXaxis()->GetBinUpEdge(Bins); h1[i]->SetLineWidth(1); h1[i]->SetLineColor(color[i]); h1[i]->SetFillColor(color[i]); } sprintf(xtitle,"%s [%s]",xtitle_.c_str(),xunit.c_str()); sprintf(ytitle,"%s / [%3.0f%s]",ytitle_.c_str(),binwidth,xunit.c_str()); sprintf(title,";%s;%s",xtitle,ytitle); cout<<Bins<<" "<<x1<<" "<<x2<<endl; TH1F* hs_stack = new TH1F("hs_stack",title,Bins,x1,x2); THStack *hs = new THStack("hs",""); TLegend* leg_ = new TLegend(0.65,0.65,0.85,0.85); TCanvas* c1 = new TCanvas("c1", "", 850, 700); c1->SetGridx(); c1->SetGridy(); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); hs_stack->UseCurrentStyle(); hs->SetHistogram(hs_stack); for(int i=0; i<size; i++){ hs->Add(h1[i]); leg_->AddEntry(h1[i],leg[i].c_str(),"f"); } leg_->SetFillStyle(0); leg_->SetBorderSize(0); leg_->SetTextSize(0.042); if( ylog ) gPad->SetLogy(); hs->SetMinimum(1); hs->SetMaximum(1e+13); hs->Draw(); leg_->Draw(); c1->SaveAs(savePath.c_str()); }
//void VHPlotter(string title="", int plot=0) { void VHPlotter(string title="", int plot=0, TCanvas* c1=0 ) { string subdir="0"; string postfix=""; string dirbSel=""; double norm11 = ((Lumi2016_ele * Xsec_dy_amc1) / Ngen_dy_amc1); double norm12 = ((Lumi2016_ele * Xsec_dy_amc2) / Ngen_dy_amc2); double norm13 = ((Lumi2016_ele * Xsec_dy_amc3) / Ngen_dy_amc3); double norm14 = ((Lumi2016_ele * Xsec_dy_amc4) / Ngen_dy_amc4); double norm2 = ((Lumi2016_ele * Xsec_tt) / Ngen_tt); double norm3 = ((Lumi2016_ele * Xsec_zz) / Ngen_zz); double norm4 = ((Lumi2016_ele * Xsec_wz) / Ngen_wz); double norm6 = ((Lumi2016_ele * Xsec_ww) / Ngen_ww); double norm7 = ((Lumi2016_ele * Xsec_zhm) / Ngen_zhm); double norm8 = ((Lumi2016_ele * Xsec_zhp) / Ngen_zhp); //if (ilepton==1) Lumi2016 = Lumi2016_ele; /*double enorm1 = ((Lumi2012 * eXsec_dy) / Ngen_dy); double enorm1_amc = ((Lumi2012 * eXsec_dy_amc) / Ngen_dy_amc); double enorm1_1 = ((Lumi2012 * eXsec_dy_1) / Ngen_dy_1); double enorm1_2=0; double enorm2 = ((Lumi2012 * eXsec_tt) / Ngen_tt); double enorm4 = ((Lumi2012 * eXsec_wz) / Ngen_wz); double enorm5 = ((Lumi2012 * eXsec_qcd) / Ngen_qcd); double enorm6 = ((Lumi2012 * eXsec_ww) / Ngen_ww); double enorm7 = ((Lumi2012 * eXsec_wj) / Ngen_wj); double enorm8 = ((Lumi2012 * eXsec_tS) / Ngen_tS); double enorm9 = ((Lumi2012 * eXsec_tT) / Ngen_tT); double enorm10 = ((Lumi2012 * eXsec_tW) / Ngen_tW); double enorm11 = ((Lumi2012 * eXsec_tSb) / Ngen_tSb); double enorm12 = ((Lumi2012 * eXsec_tTb) / Ngen_tTb); double enorm13 = ((Lumi2012 * eXsec_tWb) / Ngen_tWb); */ TFile* mc11 = TFile::Open((path + "DYJetsToLL_M-50_HT-100to200_13TeV.root").c_str()); TH1F* h_mc11 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc12 = TFile::Open((path + "DYJetsToLL_M-50_HT-200to400_13TeV.root").c_str()); TH1F* h_mc12 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc13 = TFile::Open((path + "DYJetsToLL_M-50_HT-400to600_13TeV.root").c_str()); TH1F* h_mc13 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc14 = TFile::Open((path + "DYJetsToLL_M-50_HT-600toInf_13TeV.root").c_str()); TH1F* h_mc14 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc2 = TFile::Open((path + "TT_TuneCUETP8M1_13TeV.root").c_str()); TH1F* h_mc2 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc3 = TFile::Open((path + "ZZ_TuneCUETP8M1_13TeV.root").c_str()); TH1F* h_mc3 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc4 = TFile::Open((path + "WZ_TuneCUETP8M1_13TeV.root").c_str()); TH1F* h_mc4 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc6 = TFile::Open((path + "WW_TuneCUETP8M1_13TeV.root").c_str()); TH1F* h_mc6 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc7 = TFile::Open((path + "ZH_HToBB_ZToLL_M125_13TeV_amcatnlo.root").c_str()); TH1F* h_mc7 = (TH1F*)gDirectory->Get(title.c_str()); TFile* mc8 = TFile::Open((path + "ZH_HToBB_ZToLL_M125_13TeV_powheg.root").c_str()); TH1F* h_mc8 = (TH1F*)gDirectory->Get(title.c_str()); //TFile* data = TFile::Open((path + "SingleElectron-Run2016B-v2.root").c_str());; //TH1F* h_data = (TH1F*)gDirectory->Get(title.c_str()); TFile* data_runB = TFile::Open((path + "SingleElectron-Run2016B-v2.root").c_str()); TH1F* h_data_runB = (TH1F*)gDirectory->Get(title.c_str()); TFile* data_runC = TFile::Open((path + "SingleElectron-Run2016C-v2.root").c_str()); TH1F* h_data_runC = (TH1F*)gDirectory->Get(title.c_str()); TFile* data_runD = TFile::Open((path + "SingleElectron-Run2016D-v2.root").c_str()); TH1F* h_data_runD = (TH1F*)gDirectory->Get(title.c_str()); TH1F* h_data = (TH1F*)h_data_runB ->Clone("h_data"); h_data->Reset(); h_data->Add( h_data_runB ); h_data->Add( h_data_runC ); h_data->Add( h_data_runD ); h_mc2 -> SetLineColor(kBlack); h_mc2 -> SetFillColor(kBlue); //h_mc2 -> SetFillStyle(3004); h_mc3 -> SetLineColor(kBlack); h_mc3 -> SetFillColor(kGray+2); //h_mc3 -> SetFillStyle(3004); //h_mc4 -> SetLineColor(kBlack); //h_mc4 -> SetFillColor(kGray+3); //h_mc4 -> SetFillStyle(3004); //h_mc6 -> SetLineColor(kBlack); //h_mc6 -> SetFillColor(kRed+2); //h_mc6 -> SetFillStyle(3004); h_mc7 -> SetLineColor(kBlack); h_mc7 -> SetFillColor(kMagenta); //h_mc7 -> SetFillStyle(3004); h_mc8 -> SetLineColor(kGreen); //h_mc8 -> SetLineColor(kBlack); //h_mc8 -> SetFillColor(kPink); //h_mc8 -> SetFillStyle(3004); h_mc8 ->SetLineWidth(3); h_mc11->Scale(norm11); h_mc12->Scale(norm12); h_mc13->Scale(norm13); h_mc14->Scale(norm14); h_mc2->Scale(norm2); h_mc3->Scale(norm3); h_mc4->Scale(norm4); h_mc6->Scale(norm6); h_mc7->Scale(norm7); h_mc8->Scale(norm8); TH1F* h_mcDY = (TH1F*)h_mc11->Clone("h_mcDY"); h_mcDY->Reset(); h_mcDY->Add(h_mc14); h_mcDY->Add(h_mc13); h_mcDY->Add(h_mc12); h_mcDY->Add(h_mc11); h_mcDY -> SetLineColor(kBlack); h_mcDY -> SetFillColor(kYellow-4); //h_mcDY -> SetFillStyle(3004); TH1F* h_mcDiboson = (TH1F*)h_mc3->Clone("h_mcDiboson"); h_mcDiboson->Reset(); h_mcDiboson->Add(h_mc3); h_mcDiboson->Add(h_mc4); h_mcDiboson->Add(h_mc6); TH1F *ht = (TH1F*)h_mcDY->Clone("ht"); ht->Reset(); //ht->Add(h_mc8); ht->Add(h_mc7); //ht->Add(h_mc6); //ht->Add(h_mc4); //ht->Add(h_mc3); ht->Add(h_mcDiboson); ht->Add(h_mc2); ht->Add(h_mcDY); THStack *hs = new THStack("hs",""); //hs->Add(h_mc8); // ZH powheg hs->Add(h_mc7); // ZH madgraph //hs->Add(h_mc6); //hs->Add(h_mc4); //hs->Add(h_mc3); hs->Add(h_mcDiboson); hs->Add(h_mc2); hs->Add(h_mcDY); //TCanvas* c1 = 0; //c1 = new TCanvas("c","c",10,10,800,600); c1->cd(); TPad *pad1 = new TPad("pad1","pad1",0.0,0.3,1.0,1.0); pad1->SetBottomMargin(0.001); pad1->Draw(); pad1->cd(); if( title=="FATjetSDmass" || title=="FATjetSDmassCorr" || title=="FATjetPRmass" || title=="FATjetPRmassCorr" || title=="FATnSubjet" || title=="ZHmass" ) { pad1->SetLogy(); } hs->Draw("HIST"); hs->GetYaxis()->SetTitle("Events"); hs->GetYaxis()->SetTitleSize(0.05); hs->GetYaxis()->SetLabelSize(0.045); hs->GetYaxis()->SetTitleOffset(1.0);// 0.7 //hs->SetMinimum(8); hs->SetMinimum(0.1); hs->SetMaximum(1.2*hs->GetMaximum()); if (title=="ZHmass") { hs->GetXaxis()->SetRangeUser(0, 3000); } h_mc8->Draw("same hist"); h_data->Draw("EPX0SAMES"); h_data->SetMarkerColor(kBlack); h_data->SetMarkerStyle(20); h_data->SetMarkerSize (1.0); h_data->SetStats(0); TLegend *leg; if (title=="FATjetTau2dvTau1") { leg = new TLegend(0.15, 0.547, 0.41, 0.88); } else { leg = new TLegend(0.65, 0.547, 0.91, 0.88); } //leg = new TLegend(0.65, 0.547, 0.91, 0.88); leg->SetBorderSize(0); leg->SetEntrySeparation(0.01); leg->SetFillColor(0); leg->SetFillStyle(0); leg->AddEntry(h_data,"Data","p"); leg->AddEntry(h_mcDY,"DY","f"); leg->AddEntry(h_mc2,"t#bar{t}","f"); //leg->AddEntry(h_mc3,"ZZ","f"); //leg->AddEntry(h_mc4,"WZ","f"); //leg->AddEntry(h_mc6,"WW","f"); leg->AddEntry(h_mcDiboson,"Diboson","f"); leg->AddEntry(h_mc7,"ZH madgraph","f"); leg->AddEntry(h_mc8,"ZH powheg (not in stack)","f"); leg->Draw(); TLatex *lar = new TLatex(); lar->SetNDC(kTRUE); lar->SetTextSize(0.04); lar->SetLineWidth(5); lar->DrawLatex(0.14, 0.94, "CMS #it{#bf{2016}}"); lar->DrawLatex(0.60, 0.94, "L = 12.7 fb^{-1} at #sqrt{s} = 13 TeV"); pad1->Update(); c1->Update(); c1->cd(); TH1F *h_ratio = (TH1F*)h_data->Clone("h_ratio"); TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.3);// 0.3 pad2->SetTopMargin(0); pad2->SetBottomMargin(0.3); pad2->Draw(); pad2->cd(); h_ratio->SetTitle(""); h_ratio->SetStats(0); if (title=="Zpt") { h_ratio->GetXaxis ()->SetTitle("p_{T}(Z) [GeV/c]"); } else if (title=="Zmass") { h_ratio->GetXaxis ()->SetTitle("M(Z) [GeV/c^{2}]");// } else if (title=="ZRapidity") { h_ratio->GetXaxis ()->SetTitle("y(Z)"); } else if (title=="Zeta") { h_ratio->GetXaxis ()->SetTitle("#eta(Z)"); } else if (title=="nVtx") { h_ratio->GetXaxis ()->SetTitle("Number of Vertices"); } else if (title=="leadElePt") { h_ratio->GetXaxis ()->SetTitle("Leading Electron p_{T} [GeV/c]"); } else if (title=="subleadElePt") { h_ratio->GetXaxis ()->SetTitle("Sub-Leading Electron p_{T} [GeV/c]"); } else if (title=="leadEleEta") { h_ratio->GetXaxis ()->SetTitle("Leading Electron #eta"); } else if (title=="subleadEleEta") { h_ratio->GetXaxis ()->SetTitle("Sub-Leading Electron #eta"); } else if (title=="FATjetPt") { h_ratio->GetXaxis ()->SetTitle("FAT Jet p_{T} [GeV/c]"); } else if (title=="FATjetEta") { h_ratio->GetXaxis ()->SetTitle("FAT Jet #eta"); } else if (title=="FATjetCISVV2") { h_ratio->GetXaxis ()->SetTitle("FAT Jet CSVv2"); } else if (title=="FATjetSDmass") { h_ratio->GetXaxis ()->SetTitle("FAT Jet Soft Drop Mass [GeV/c^{2}]"); } else if (title=="FATjetSDmassCorr") { h_ratio->GetXaxis ()->SetTitle("FAT Jet Corrected Soft Drop Mass [GeV/c^{2}]"); } else if (title=="FATjetPRmass") { h_ratio->GetXaxis ()->SetTitle("FAT Jet Pruned Mass [GeV/c^{2}]"); } else if (title=="FATjetPRmassCorr") { h_ratio->GetXaxis ()->SetTitle("FAT Jet L2L3 Corrected Pruned Mass [GeV/c^{2}]"); } else if (title=="FATjetTau1") { h_ratio->GetXaxis ()->SetTitle("FAT Jet #tau_{1}"); } else if (title=="FATjetTau2") { h_ratio->GetXaxis ()->SetTitle("FAT Jet #tau_{2}"); } else if (title=="FATjetTau2dvTau1") { h_ratio->GetXaxis ()->SetTitle("FAT Jet #tau_{21}"); } else if (title=="FATnSubjet") { h_ratio->GetXaxis ()->SetTitle("Number of Subjets"); } else if (title=="FATsubjetLeadingPt") { h_ratio->GetXaxis ()->SetTitle("Leading SubJet p_{T} [GeV/c]"); } else if (title=="FATsubjetLeadingEta") { h_ratio->GetXaxis ()->SetTitle("Leading SubJet #eta"); } else if (title=="FATsubjetLeadingSDCSV") { h_ratio->GetXaxis ()->SetTitle("Leading SubJet Soft Drop CSV"); } else if (title=="FATsubjetSubLeadingPt") { h_ratio->GetXaxis ()->SetTitle("Sub-Leading SubJet p_{T} [GeV/c]"); } else if (title=="FATsubjetSubLeadingEta") { h_ratio->GetXaxis ()->SetTitle("Sub-Leading SubJet #eta"); } else if (title=="FATsubjetSubLeadingSDCSV") { h_ratio->GetXaxis ()->SetTitle("Sub-Leading SubJet Soft Drop CSV"); } else if (title=="ADDjet_DoubleSV") { h_ratio->GetXaxis ()->SetTitle("ADDjet double b-tagger discriminator"); } else if (title=="ZHmass") { h_ratio->GetXaxis ()->SetTitle("ZH invariant mass [GeV/c^{2}]"); } if (title=="ZHmass") { h_ratio->GetXaxis()->SetRangeUser(0, 3000); } h_ratio->GetXaxis()->SetTitleSize(0.11); h_ratio->GetXaxis()->SetLabelFont(42); h_ratio->GetXaxis()->SetLabelSize(0.10); h_ratio->GetXaxis()->SetTitleFont(42); h_ratio->GetYaxis()->SetTitle("Data/MC"); h_ratio->GetYaxis()->SetNdivisions(505); h_ratio->GetYaxis()->SetTitleSize(0.11); h_ratio->GetYaxis()->SetLabelSize(0.10); h_ratio->GetYaxis()->SetRangeUser(0.2, 2); h_ratio->GetYaxis()->SetTitleOffset(0.33); h_ratio->Divide(ht); h_ratio->SetMarkerStyle(20); h_ratio->Draw("E0PX0"); TLine *OLine = new TLine(h_ratio->GetXaxis()->GetXmin(),1.,h_ratio->GetXaxis()->GetXmax(),1.); OLine->SetLineColor(kRed); OLine->SetLineWidth(2); OLine->Draw(); /* TLatex *lar = new TLatex(); lar->SetNDC(kTRUE); lar->SetTextSize(0.04); lar->SetLineWidth(5); lar->DrawLatex(0.14, 0.94, "CMS #it{#bf{2016}}"); lar->DrawLatex(0.60, 0.94, "L = 4.327 fb^{-1} at #sqrt{s} = 13 TeV"); */ c1->cd(); //c1->SaveAs((path + title + ".pdf").c_str()); }
// *************************************** // // this is a function that takes a set of // // histograms and draws them on a canvas // // in a stack, returning the canvas // // just for MC- no ratio and no data. // // This one includes syst and stat or just // // stat errors // // *************************************** // TCanvas* drawPlots::plot_MC_noRatio_wError(std::vector<TH1D*> histos, std::vector<std::string> names, std::string axisName, TH1D* signal, TH1D* errDown, TH1D* errUp){ const unsigned int MAINPLOT_WIDTH = 800; const unsigned int MAINPLOT_HEIGHT = 600; TCanvas* canvas = new TCanvas("canvas","canvas",0,0,MAINPLOT_WIDTH,MAINPLOT_HEIGHT); canvas->SetMargin(0.,0.,0.,0.); canvas->cd(); double main_y_max = -99; double main_y_min = -99; double main_x_max = -99; double main_x_min = -99; for(int a=0; a<histos.size(); a++){ GetAxisLimits(histos[a], main_x_min, main_x_max, main_y_min, main_y_max); } // create main pad TPad* mainPad = new TPad("main","main",0.,0.,1.,1.); mainPad->SetMargin(0.15,0.05,0.15,.05); // left, right, bottom, top mainPad->Draw(); mainPad->cd(); SetAtlasStyle(); THStack* Stack = new THStack(); std::string title = std::string(";") + axisName + ";Events"; Stack->SetTitle(title.c_str()); for(int b=0; b<histos.size(); b++){ histos[b]->SetLineColor(1); histos[b]->SetFillColor(tools::setColor(names[b])); Stack->Add(histos[b]); } main_y_max = main_y_max*1.5; Stack->SetMaximum(main_y_max); Stack->Draw("hist"); errDown->Draw("E2same"); errUp->Draw("E2Same"); signal->SetLineStyle(2); signal->SetLineColor(kRed); signal->Draw("hist same"); TLegend* leg = new TLegend(0.7,0.7,0.93,0.9); leg->SetFillStyle(0); leg->SetBorderSize(0); leg->AddEntry(signal, "Signal", "f"); for(int q=0; q<histos.size(); q++){ leg->AddEntry(histos[q], names[q].c_str(), "f"); } leg->Draw("lpe"); ATLAS_LABEL(0.2,0.85,1); char text[]="#sqrt{s}=8 TeV"; myText(0.2,0.7,1,text); return canvas; }
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 PaintOverflow(THStack *h); void SamMacroModBinWidth(){ float value = 2.5; TCanvas *c1 = new TCanvas("c1", "c1",800,500); TPad* spectrumPad=0; TPad* ratioPad=0; //c1->Divide(1,2); //gStyle->SetOptStat(111111); gStyle->SetOptFit(kFALSE); gStyle->SetOptStat(kFALSE); gStyle->SetStatX(0.457589); gStyle->SetStatY(0.312937); gStyle->SetStatW(0.29241/2+0.0185); gStyle->SetStatH(0.169580+0.05); gStyle->SetStatFontSize(0.0402098); gStyle->SetStatFont(0.02); gStyle->SetFitFormat("5.2g"); gStyle->SetStatBorderSize(0); gStyle->SetStatFontSize(0.040209); gStyle->SetStatFontSize(0.035209); c1->Range(1.592761,-5.173913,3.533814,6.006211); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetLogx(1); c1->SetLogy(1); c1->SetTickx(1); c1->SetTicky(1); c1->SetLeftMargin(0.13); c1->SetRightMargin(0.07); c1->SetFrameBorderMode(0); c1->SetFrameBorderMode(0); c1->SetTopMargin(0.085); c1->SetBottomMargin(0.11); // Build the histo with constant log bin width const int NMBINS = 100; const double MMIN = 60., MMAX = 3000.; double logMbins[NMBINS+1]; float binNormNr=0.; for (int ibin = 0; ibin <= NMBINS; ibin++) { logMbins[ibin] = exp(log(MMIN) + (log(MMAX)-log(MMIN))*ibin/NMBINS); cout << logMbins[ibin] << endl; } TH1* hTTbarDiboson = new TH1F("hTTbarDiboson","",NMBINS, logMbins); TH1* hDijetWjets = new TH1F("hDijetWjets","",NMBINS, logMbins); TH1* ttbarHist = new TH1F("ttbarHist","",NMBINS, logMbins); TH1* dibosonsBkgHist = new TH1F("dibosonsBkgHist","",NMBINS, logMbins); //========================================================== // // Get the histograms //========================================================== //TFile *file1 = new TFile("h_ZprimeRecomass_DYBinWidth.root","READ"); //TH1* zeeHist = (TH1*) file1->Get("ZprimeRecomassBinWidth"); TFile *file1 = new TFile("DY-MuMu-MC-OS-allbins-MC-2673pb.root","READ"); TH1* zeeHist = (TH1*) file1->Get("hMassDYAll6"); TFile *file2 = new TFile("h_ZprimeRecomass_Tlike.root","READ"); TH1* ttbarHist = (TH1*) file2->Get("ZprimeRecomassBinWidth"); TFile *file3 = new TFile("h_ZprimeRecomass_DiBoson.root","READ"); TH1* dibosonsBkgHist = (TH1*) file3->Get("ZprimeRecomassBinWidth"); TFile *file4 = new TFile("h_ZprimeRecomass_data.root","READ"); TH1* dataHistTempbar = (TH1*) file4->Get("ZprimeRecomassBinWidth"); TFile *file5 = new TFile("FR-DiJets-Data-OS-BinWidth-2673pb.root","READ"); TH1* jetBkgHist = (TH1*) file5->Get("DataSub"); TFile *file6 = new TFile("FR-Wjets-25nsMC-OS-BinWidth-2673pb.root","READ"); TH1* WjetsBkgHist = (TH1*) file6->Get("WjetsHisto"); std::cout<<"nbQCD(dijets,Data) = "<<jetBkgHist->Integral()<<endl; std::cout<<"nb.Wjets(MC) = "<<WjetsBkgHist->Integral()<<endl; hTTbarDiboson->Add(ttbarHist,dibosonsBkgHist,1,1); hDijetWjets->Add(jetBkgHist,WjetsBkgHist,1,1); zeeHist->Rebin(value); hTTbarDiboson->Rebin(value); dibosonsBkgHist->Rebin(value); dataHistTempbar->Rebin(value); hDijetWjets->Rebin(value); WjetsBkgHist->Rebin(value); float binWidthNorm=1; int zeeColour = TColor::GetColor("#99ccff"); int jetBkgColour = TColor::GetColor("#ffff66"); int ttbarColour = TColor::GetColor("#ff6666"); int bosonColour = TColor::GetColorDark(3); int WjetsColour = TColor::GetColorDark(5); int font = 42; //float xAxisMin = 60; //72 //float xAxisMax = 1000.0; //float yAxisMin = 1e-4; //float yAxisMax = 1e3; TGraphAsymmErrors* dataHist = makeDataGraph(dataHistTempbar,binWidthNorm,0); normHistToBinWidth(zeeHist,binWidthNorm); normHistToBinWidth(hTTbarDiboson,binWidthNorm); //normHistToBinWidth(dibosonsBkgHist,binWidthNorm); normHistToBinWidth(hDijetWjets,binWidthNorm); //normHistToBinWidth(WjetsBkgHist,binWidthNorm); //gStyle->SetOptStat(111111); //PaintOverflow(zeeHist); //PaintOverflow(ttbarHist); //PaintOverflow(dibosonsBkgHist); //PaintOverflow(dataHistTempbar); //PaintOverflow(jetBkgHist); //PaintOverflow(WjetsBkgHist); THStack *axisHist = new THStack("axisHist",""); zeeHist->SetFillColor(zeeColour); zeeHist->SetLineWidth(2); zeeHist->SetLineColor(1); zeeHist->SetTitle(""); hTTbarDiboson->SetFillColor(ttbarColour); hTTbarDiboson->SetLineWidth(2); hTTbarDiboson->SetLineColor(1); //dibosonsBkgHist->SetFillColor(bosonColour); //dibosonsBkgHist->SetLineWidth(2); //dibosonsBkgHist->SetLineColor(1); //WjetsBkgHist->SetFillColor(WjetsColour); //WjetsBkgHist->SetFillColor(jetBkgColour); //WjetsBkgHist->SetLineWidth(2); //WjetsBkgHist->SetLineColor(1); hDijetWjets->SetFillColor(jetBkgColour); hDijetWjets->SetLineWidth(2); hDijetWjets->SetLineColor(1); axisHist->Add(hDijetWjets,"histo"); //axisHist->Add(WjetsBkgHist,"histo"); axisHist->Add(hTTbarDiboson); //axisHist->Add(dibosonsBkgHist); axisHist->Add(zeeHist); axisHist->Draw("histo"); //axisHist->GetYaxis()->SetTitle("Events / 20 GeV"); axisHist->GetXaxis()->SetTitle("M(#mu^{+}#mu^{-}) [GeV]"); axisHist->GetYaxis()->SetTitle("Events/GeV"); //axisHist->GetXaxis()->SetTitleOffset(1.1); //axisHist->GetYaxis()->SetTitleOffset(1.1); axisHist->GetXaxis()->SetTitleSize(0.047); axisHist->GetYaxis()->SetTitleSize(0.047); axisHist->GetXaxis()->SetLabelSize(0.050); axisHist->GetYaxis()->SetLabelSize(0.050); axisHist->GetXaxis()->SetMoreLogLabels(); axisHist->GetXaxis()->SetNoExponent(); axisHist->GetXaxis()->SetRangeUser(70.0,2999.0); //axisHist->SetMinimum(0.01); //axisHist->SetMaximum(20000.0); axisHist->SetMinimum(0.0001); axisHist->SetMaximum(2000.0); dataHist->SetMarkerStyle(20); dataHist->SetMarkerSize(0.9); dataHist->GetXaxis()->SetRange(5,83); dataHist->GetXaxis()->SetTitleSize(0.047); dataHist->GetXaxis()->SetTitleOffset(0.9); dataHist->GetYaxis()->SetTitleSize(0.047); dataHist->GetYaxis()->SetTitleOffset(1.2); dataHist->Draw("PZ"); //========================================================== TLegend *leg = new TLegend(0.56741,0.62671,0.820536,0.87664,NULL,"brNDC"); //for lumi in plot leg->AddEntry(dataHist,"Data","PE"); leg->AddEntry(zeeHist,"#gamma^{*}/Z#rightarrow#mu^{+}#mu^{-}","F"); leg->AddEntry(hTTbarDiboson,"t#bar{t}, tW, WW, WZ, ZZ, #tau^{+}#tau^{-}","F"); //leg->AddEntry(dibosonsBkgHist,"di-boson, #gamma^{*}/Z#rightarrow#tau^{+}#tau^{-}","F"); //leg->AddEntry(WjetsBkgHist,"W+jets (FR)","F"); leg->AddEntry(hDijetWjets,"Jets (data)","F"); leg->SetBorderSize(0); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(19); leg->SetFillStyle(0); leg->SetTextFont(font); leg->SetTextSize(0.04); leg->Draw(); //========================================================== TPaveText* tText1 = new TPaveText(0.75, 0.92, 0.87, 0.98, "brNDC"); tText1->SetBorderSize(0); tText1->SetFillColor(0); tText1->SetFillStyle(0); TText *t1 = tText1->AddText("2.8 fb^{-1} (13 TeV)"); tText1->SetTextSize(0.04); tText1->Draw(); //========================================================== TPaveText* tText2 = new TPaveText(0.85, 0.86, 0.88, 0.87, "brNDC"); tText2->SetBorderSize(0); tText2->SetFillColor(0); tText2->SetFillStyle(0); TText *t1 = tText2->AddText("CMS"); tText2->SetTextSize(0.04); tText2->Draw(); //========================================================== TPaveText* tText3 = new TPaveText(0.80, 0.81, 0.85, 0.83, "brNDC"); tText3->SetBorderSize(0); tText3->SetFillColor(0); tText3->SetFillStyle(0); TText *t1 = tText3->AddText("#it{Preliminary}"); tText3->SetTextSize(0.04); tText3->Draw(); //--------------------------------------------------------------------- //--------------------------------------------------------------------- //=================================================================================== c1->Print("Stack-DY-Spring15MCs-Data2015-mass-spectrum-MuMu-OS-2800pb_logx.png","png"); c1->Print("Stack-DY-Spring15MCs-Data2015-mass-spectrum-MuMu-OS-2673pb_logx.pdf","pdf"); //========================================================================= //========================================================================= //========================================================================= //========================================================================= //========================================================================= //========================================================================= TCanvas *c2 = new TCanvas("c2", "c2",800,500); TPad* spectrumPad=0; TPad* ratioPad=0; // Build the histo with constant log bin width const int NMBINS = 100; const double MMIN = 60., MMAX = 3000.; double logMbins[NMBINS+1]; float binNormNr=0.; for (int ibin = 0; ibin <= NMBINS; ibin++) { logMbins[ibin] = exp(log(MMIN) + (log(MMAX)-log(MMIN))*ibin/NMBINS); cout << logMbins[ibin] << endl; } TH1* hTTbarDiboson = new TH1F("hTTbarDiboson","",NMBINS, logMbins); TH1* hDijetWjets = new TH1F("hDijetWjets","",NMBINS, logMbins); TH1* ttbarHist = new TH1F("ttbarHist","",NMBINS, logMbins); TH1* dibosonsBkgHist = new TH1F("dibosonsBkgHist","",NMBINS, logMbins); TH1F* hDivideHisto2 = new TH1F("hDivideHisto2","",150,0.0,3000.0); //TH1F* hMass1 = new TH1F("hMass1","",150,0.0,3000.0); //TH1F* hMass2 = new TH1F("hMass2","",150,0.0,3000.0); //TH1F* hMass3 = new TH1F("hMass3","",150,0.0,3000.0); //TH1F* hMass5 = new TH1F("hMass5","",150,0.0,3000.0); //TH1F* hMass6 = new TH1F("hMass6","",150,0.0,3000.0); //TH1F* AllEKWbkg = new TH1F("AllEKWbkg","",150,0.0,3000.0); gStyle->SetOptFit(1111); gStyle->SetOptStat(0); gStyle->SetStatX(0.457589); gStyle->SetStatY(0.312937); gStyle->SetStatW(0.29241/2+0.0185); gStyle->SetStatH(0.169580+0.05); gStyle->SetStatFontSize(0.0402098); gStyle->SetStatFont(0.03); gStyle->SetFitFormat("5.2g"); gStyle->SetStatBorderSize(0); gStyle->SetStatFontSize(0.040209); gStyle->SetStatFontSize(0.035209); c2->Range(1.592761,-5.173913,3.533814,6.006211); c2->SetFillColor(0); c2->SetBorderMode(0); c2->SetBorderSize(2); c2->SetLogx(1); c2->SetLogy(1); c2->SetTickx(1); c2->SetTicky(1); c2->SetLeftMargin(0.13); c2->SetRightMargin(0.07); c2->SetFrameBorderMode(0); c2->SetFrameBorderMode(0); c2->SetTopMargin(0.085); c2->SetBottomMargin(0.11); //========================================================== // // Get the histograms //========================================================== //TFile *file1 = new TFile("h_ZprimeRecomass_DYBinWidth.root","READ"); //TH1* zeeHist = (TH1*) file1->Get("ZprimeRecomassBinWidth"); TFile *file1 = new TFile("DY-MuMu-MC-OS-allbins-MC-2673pb.root","READ"); TH1* zeeHist = (TH1*) file1->Get("hMassDYAll6"); TFile *file2 = new TFile("h_ZprimeRecomass_Tlike.root","READ"); TH1* ttbarHist = (TH1*) file2->Get("ZprimeRecomassBinWidth"); TFile *file3 = new TFile("h_ZprimeRecomass_DiBoson.root","READ"); TH1* dibosonsBkgHist = (TH1*) file3->Get("ZprimeRecomassBinWidth"); TFile *file4 = new TFile("h_ZprimeRecomass_data.root","READ"); TH1* dataHistTempbar = (TH1*) file4->Get("ZprimeRecomassBinWidth"); TFile *file5 = new TFile("FR-DiJets-Data-OS-BinWidth-2673pb.root","READ"); TH1* jetBkgHist = (TH1*) file5->Get("DataSub"); TFile *file6 = new TFile("FR-Wjets-25nsMC-OS-BinWidth-2673pb.root","READ"); TH1* WjetsBkgHist = (TH1*) file6->Get("WjetsHisto"); std::cout<<"nbQCD(dijets,Data) = "<<jetBkgHist->Integral()<<endl; std::cout<<"nb.Wjets(MC) = "<<WjetsBkgHist->Integral()<<endl; hTTbarDiboson->Add(ttbarHist,dibosonsBkgHist,1,1); hDijetWjets->Add(jetBkgHist,WjetsBkgHist,1,1); //zeeHist->Rebin(value); //hTTbarDiboson->Rebin(value); //dibosonsBkgHist->Rebin(value); //dataHistTempbar->Rebin(value); //hDijetWjets->Rebin(value); //WjetsBkgHist->Rebin(value); float binWidthNorm2=-1; int zeeColour = TColor::GetColor("#99ccff"); int jetBkgColour = TColor::GetColor("#ffff66"); int ttbarColour = TColor::GetColor("#ff6666"); int bosonColour = TColor::GetColorDark(3); int WjetsColour = TColor::GetColorDark(5); int font = 42; float xAxisMin = 60; //72 float xAxisMax = 1000.0; float yAxisMin = 1e-4; float yAxisMax = 1e4; dataHistTempbar = makeIntHist(dataHistTempbar); zeeHist = makeIntHist(zeeHist); hTTbarDiboson = makeIntHist(hTTbarDiboson); hDijetWjets = makeIntHist(hDijetWjets); TGraphAsymmErrors* dataHist = makeDataGraph(dataHistTempbar,binWidthNorm2,0); THStack *axisHist2 = new THStack("axisHist2",""); zeeHist->SetFillColor(zeeColour); zeeHist->SetLineWidth(2); zeeHist->SetLineColor(1); zeeHist->SetTitle(""); hTTbarDiboson->SetFillColor(ttbarColour); hTTbarDiboson->SetLineWidth(2); hTTbarDiboson->SetLineColor(1); //dibosonsBkgHist->SetFillColor(bosonColour); //dibosonsBkgHist->SetLineWidth(2); //dibosonsBkgHist->SetLineColor(1); hDijetWjets->SetFillColor(jetBkgColour); hDijetWjets->SetLineWidth(2); hDijetWjets->SetLineColor(1); //WjetsBkgHist->SetFillColor(WjetsColour); //WjetsBkgHist->SetLineWidth(2); //WjetsBkgHist->SetLineColor(1); axisHist2->Add(hDijetWjets,"histo"); //axisHist2->Add(WjetsBkgHist,"histo"); //axisHist2->Add(dibosonsBkgHist,"histo"); axisHist2->Add(hTTbarDiboson,"histo"); axisHist2->Add(zeeHist,"histo"); axisHist2->Draw(); axisHist2->GetXaxis()->SetTitle("M(#mu^{+}#mu^{-}) [GeV]"); axisHist2->GetYaxis()->SetTitle("Events #geq M(#mu^{+}#mu^{-}) [GeV]"); axisHist2->GetXaxis()->SetTitleOffset(1.1); axisHist2->GetYaxis()->SetTitleOffset(1.1); axisHist2->GetXaxis()->SetTitleSize(0.047); axisHist2->GetYaxis()->SetTitleSize(0.047); axisHist2->GetXaxis()->SetLabelSize(0.040); axisHist2->GetYaxis()->SetLabelSize(0.040); axisHist2->GetXaxis()->SetMoreLogLabels(); axisHist2->GetXaxis()->SetNoExponent(); axisHist2->GetXaxis()->SetRangeUser(70.0,4000.0); axisHist2->SetMinimum(0.01); axisHist2->SetMaximum(60000.0); dataHist->SetMarkerStyle(20); dataHist->SetMarkerSize(0.9); dataHist->Draw("PZsames"); //========================================================== TLegend *leg = new TLegend(0.56741,0.62671,0.820536,0.87664,NULL,"brNDC"); //for lumi in plot leg->AddEntry(dataHist,"Data","PE"); leg->AddEntry(zeeHist,"#gamma^{*}/Z#rightarrow#mu^{+}#mu^{-}","F"); leg->AddEntry(hTTbarDiboson,"t#bar{t}, tW, WW, WZ, ZZ, #tau^{+}#tau^{-}","F"); leg->AddEntry(hDijetWjets,"Jets (data)","F"); leg->SetBorderSize(0); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(19); leg->SetFillStyle(0); leg->SetTextFont(font); leg->SetTextSize(0.04); leg->Draw(); //========================================================== TPaveText* tText1 = new TPaveText(0.75, 0.92, 0.87, 0.98, "brNDC"); tText1->SetBorderSize(0); tText1->SetFillColor(0); tText1->SetFillStyle(0); TText *t1 = tText1->AddText("2.8 fb^{-1} (13 TeV)"); tText1->SetTextSize(0.04); tText1->Draw(); //========================================================== TPaveText* tText2 = new TPaveText(0.85, 0.86, 0.88, 0.87, "brNDC"); tText2->SetBorderSize(0); tText2->SetFillColor(0); tText2->SetFillStyle(0); TText *t1 = tText2->AddText("CMS"); tText2->SetTextSize(0.04); tText2->Draw(); //========================================================== TPaveText* tText3 = new TPaveText(0.80, 0.81, 0.85, 0.83, "brNDC"); tText3->SetBorderSize(0); tText3->SetFillColor(0); tText3->SetFillStyle(0); TText *t1 = tText3->AddText("#it{Preliminary}"); tText3->SetTextSize(0.04); tText3->Draw(); //=================================================================================== //=================================================================================== c2->Print("Stack-DY-Spring15MCs-Data2015-cumulative-spectrum-MuMu-OS-2800pb-logx.png","png"); //c2->Print("Stack-DY-Spring15MCs-Data2015-cumulative-spectrum-MuMu-OS-2673pb-logx.pdf","pdf"); }
void CCProtonPi0_SideBandTool::Plot(int ind, std::string sb_name, std::string var_name, MnvH1D* data, MnvH1D* mc_total, MnvH1D* signal, MnvH1D* WithPi0, MnvH1D* QELike, MnvH1D* SinglePiPlus, MnvH1D* Other) { std::string type; if (ind == 0) type = "Nominal"; else type = "Fitted"; std::string norm = "POT"; std::string plot_title = "Side Band: " + sb_name + " " + type + " " + norm + " Normalized"; // Get Histograms -- Use new Histograms not to change originals ColorHists(data, signal, WithPi0, QELike, SinglePiPlus, Other); TH1D* h_data = new TH1D(data->GetBinNormalizedCopy().GetCVHistoWithError()); TH1D* h_signal = new TH1D(signal->GetBinNormalizedCopy().GetCVHistoWithError()); TH1D* h_WithPi0 = new TH1D(WithPi0->GetBinNormalizedCopy().GetCVHistoWithError()); TH1D* h_QELike = new TH1D(QELike->GetBinNormalizedCopy().GetCVHistoWithError()); TH1D* h_SinglePiPlus = new TH1D(SinglePiPlus->GetBinNormalizedCopy().GetCVHistoWithError()); TH1D* h_Other = new TH1D(Other->GetBinNormalizedCopy().GetCVHistoWithError()); // MC Total depend on the Modification // If Raws - take the mc_total directly // If Modified - Add all mc models; TH1D* h_mc_total; if (ind == 0){ h_mc_total = new TH1D(mc_total->GetBinNormalizedCopy().GetCVHistoWithError()); }else{ h_mc_total = new TH1D(*h_signal); h_mc_total->Add(h_WithPi0); h_mc_total->Add(h_QELike); h_mc_total->Add(h_SinglePiPlus); h_mc_total->Add(h_Other); } // Scale Histograms double mc_ratio = POT_ratio; h_mc_total->Scale(mc_ratio); h_signal->Scale(mc_ratio); h_WithPi0->Scale(mc_ratio); h_QELike->Scale(mc_ratio); h_SinglePiPlus->Scale(mc_ratio); h_Other->Scale(mc_ratio); // ------------------------------------------------------------------------ // Unique Plot for Single Error Band, Single Universe // Comment this section out // ------------------------------------------------------------------------ //std::string err_band = "GENIE_MaRES"; //int hist_ind = 1; //TH1D* h_data = new TH1D(*(data->GetVertErrorBand(err_band)->GetHist(hist_ind))); //TH1D* h_signal = new TH1D(*(signal->GetVertErrorBand(err_band)->GetHist(hist_ind))); //TH1D* h_WithPi0 = new TH1D(*(WithPi0->GetVertErrorBand(err_band)->GetHist(hist_ind))); //TH1D* h_QELike = new TH1D(*(QELike->GetVertErrorBand(err_band)->GetHist(hist_ind))); //TH1D* h_SinglePiPlus = new TH1D(*(SinglePiPlus->GetVertErrorBand(err_band)->GetHist(hist_ind))); //TH1D* h_Other = new TH1D(*(Other->GetVertErrorBand(err_band)->GetHist(hist_ind))); //TH1D* h_mc_total; //if (ind == 0){ // h_mc_total = new TH1D(*(mc_total->GetVertErrorBand(err_band)->GetHist(hist_ind))); //}else{ // h_mc_total = new TH1D(*h_signal); // h_mc_total->Add(h_WithPi0); // h_mc_total->Add(h_QELike); // h_mc_total->Add(h_SinglePiPlus); // h_mc_total->Add(h_Other); //} //ColorHists(h_data, h_signal, h_WithPi0, h_QELike, h_SinglePiPlus, h_Other); //// Scale Histograms //h_data->Scale(1,"width"); //double mc_ratio = POT_ratio; //h_mc_total->Scale(mc_ratio,"width"); //h_signal->Scale(mc_ratio,"width"); //h_WithPi0->Scale(mc_ratio,"width"); //h_QELike->Scale(mc_ratio,"width"); //h_SinglePiPlus->Scale(mc_ratio,"width"); //h_Other->Scale(mc_ratio,"width"); // ------------------------------------------------------------------------ // Create Canvas and Divide it into two TCanvas* c = new TCanvas("c","c",1280,1280); // Upper Pad is the Data vs MC TPad *pad1 = new TPad("pad1", "pad1", 0.05, 0.3, 1, 1.0); pad1->SetBottomMargin(0); // Top and Bottom Plots attached pad1->Draw(); pad1->cd(); // pad1 is the current pad // Plot MC Models as THStack THStack* hs = new THStack("hs",plot_title.c_str()); hs->Add(h_WithPi0); hs->Add(h_QELike); hs->Add(h_SinglePiPlus); hs->Add(h_Other); hs->Add(h_signal); hs->Draw("HIST"); // Styling gStyle->SetOptTitle(0); gStyle->SetOptStat(0); hs->GetYaxis()->SetTitle("N(Events)"); hs->GetYaxis()->SetTitleFont(62); hs->GetYaxis()->SetTitleSize(0.06); //hs->GetYaxis()->CenterTitle(); //hs->GetYaxis()->SetTitleOffset(1.2); hs->GetYaxis()->SetLabelFont(42); hs->GetYaxis()->SetLabelSize(0.05); double hist_max = hs->GetMaximum(); hs->SetMaximum(hist_max * 1.5); // Add Data Plot h_data->GetXaxis()->SetTitle(""); h_data->Draw("SAME E1 X0"); // Add Legend TLegend *legend = new TLegend(0.6,0.65,0.9,0.9); legend->AddEntry(h_data, "Data"); legend->AddEntry(h_signal, "Signal", "f"); legend->AddEntry(h_Other, "Bckg: Other", "f"); legend->AddEntry(h_SinglePiPlus, "Bckg: 1 #pi^{+}", "f"); legend->AddEntry(h_QELike, "Bckg: QE Like", "f"); legend->AddEntry(h_WithPi0, "Bckg: #pi^{0} + X", "f"); legend->SetTextSize(0.04); legend->SetTextFont(42); legend->Draw(); // // Add Pi0 InvMass Lines // TLine line; // line.SetLineWidth(3); // line.SetLineColor(kBlack); // // TArrow arrow; // arrow.SetLineWidth(4); // arrow.SetLineStyle(1); // arrow.SetLineColor(1); // // // Low Inv Mass Region // line.DrawLine(60.0,0,60.0,hist_max); // arrow.DrawArrow(60.0,hist_max,60-20,hist_max,0.01,">"); // // // High Inv Mass Region // line.DrawLine(200.0,0,200.0,hist_max); // arrow.DrawArrow(200.0,hist_max,200+20,hist_max,0.01,">"); // Add Weights as Text to Modified Plot if (ind != 0){ int nPars = 3; int nPoints = 136; TLatex* text = new TLatex; text->SetTextSize(0.03); text->SetNDC(); text->DrawLatex(0.55, 0.60, Form("Fit Results with %d points, %d pars", nPoints, nPars)); text->DrawLatex(0.55, 0.57, Form("Before Fit #chi^{2} = %3.2f", ChiSq_before_fit[0])); text->DrawLatex(0.55, 0.54, Form("Before Fit #chi^{2}/dof = %3.2f", ChiSq_before_fit[0]/(nPoints-nPars))); text->DrawLatex(0.55, 0.51, Form("After Fit #chi^{2} = %3.2f", ChiSq_after_fit[0])); text->DrawLatex(0.55, 0.48, Form("After Fit #chi^{2}/dof = %3.2f", ChiSq_after_fit[0]/(nPoints-nPars))); text->DrawLatex(0.55, 0.45, Form("#color[4]{wgt(ChargedPion) = %3.2f#pm %3.2f}", wgt_SinglePiPlus[0], err_SinglePiPlus[0])); text->DrawLatex(0.55, 0.42, Form("wgt(QELike) = %3.2f#pm %3.2f", wgt_QELike[0], err_QELike[0])); text->DrawLatex(0.55, 0.39, Form("#color[2]{wgt(WithPi0) = %3.2f#pm %3.2f}", wgt_WithPi0[0], err_WithPi0[0])); delete text; } // Add Plot-ChiSq TLatex* text = new TLatex; text->SetNDC(); text->SetTextSize(0.04); text->SetTextColor(kBlue); //double plot_chisq = calc_ChiSq(data, signal, WithPi0, QELike, SinglePiPlus, Other); double plot_chisq = calc_ChiSq(h_data, h_signal, h_WithPi0, h_QELike, h_SinglePiPlus, h_Other); double nPoints = h_data->GetNbinsX()-1; //text->DrawLatex(0.15, 0.85, Form("Plot #chi^{2} = %3.2f", plot_chisq)); text->DrawLatex(0.15, 0.85, Form("Plot #chi^{2}/dof = %3.2f", plot_chisq/nPoints)); delete text; // Plot Lower Plot: Data vs MC Ratio c->cd(); // Go back to default Canvas before creating 2nd Pad TPad *pad2 = new TPad("pad2", "pad2", 0.05, 0.05, 1, 0.3); pad2->SetTopMargin(0); pad2->SetBottomMargin(0.2); pad2->Draw(); pad2->cd(); // Calculate the Ratio TH1D* h_data_mc_ratio = new TH1D(*(h_data)); h_data_mc_ratio->Divide(h_mc_total); // Style Ratio Plot h_data_mc_ratio->SetTitle(""); h_data_mc_ratio->SetLineColor(kRed); h_data_mc_ratio->SetLineWidth(3); h_data_mc_ratio->SetFillColor(kWhite); h_data_mc_ratio->SetMinimum(0.5); h_data_mc_ratio->SetMaximum(1.5); // X axis ratio plot settings //h_data_mc_ratio->GetXaxis()->SetTitle(data->GetXaxis()->GetTitle()); h_data_mc_ratio->GetXaxis()->SetTitle("#gamma#gamma Invariant Mass [MeV]"); h_data_mc_ratio->GetXaxis()->SetNdivisions(408); h_data_mc_ratio->GetXaxis()->CenterTitle(); h_data_mc_ratio->GetXaxis()->SetTitleFont(62); h_data_mc_ratio->GetXaxis()->SetTitleSize(0.18); //h_data_mc_ratio->GetXaxis()->SetTitleOffset(1.2); h_data_mc_ratio->GetXaxis()->SetLabelFont(42); // Absolute font size in pixel (precision 3) h_data_mc_ratio->GetXaxis()->SetLabelSize(0.12); // Y axis ratio plot settings h_data_mc_ratio->GetYaxis()->CenterTitle(); h_data_mc_ratio->GetYaxis()->SetNdivisions(408); h_data_mc_ratio->GetYaxis()->SetTitle("Data/MC"); h_data_mc_ratio->GetYaxis()->SetTitleFont(62); h_data_mc_ratio->GetYaxis()->SetTitleSize(0.18); h_data_mc_ratio->GetYaxis()->SetTitleOffset(0.35); h_data_mc_ratio->GetYaxis()->SetLabelFont(42); // Absolute font size in pixel (precision 3) h_data_mc_ratio->GetYaxis()->SetLabelSize(0.12); // Add Ratio Plot h_data_mc_ratio->Draw("HIST"); // Add Ratio = 1 Line TLine ratio_1; ratio_1.SetLineWidth(2); ratio_1.SetLineStyle(7); ratio_1.SetLineColor(kBlue); double line_min = h_data->GetBinLowEdge(1); double line_max = h_data->GetBinLowEdge(h_data->GetNbinsX()+1); ratio_1.DrawLine(line_min,1,line_max,1); // Plot Output c->Update(); std::string plotDir = Folder_List::plotDir_SideBand; std::string out_name; out_name = plotDir + var_name + "_" + sb_name + "_" + type + "_" + norm + ".png"; c->Print(out_name.c_str(),"png"); delete legend; delete hs; delete pad1; delete pad2; delete c; }
void draw_from_trees(TString var, TCut other_cuts, TString weights, TString title, int nbinsx, double xlow, double xup, TString options="plotSig:plotLog:plotData", double cut_low=-1, double cut_high=-1, TString plot_title="default") { bool plotSig = options.Contains("plotSig") && (!options.Contains("!plotSig")); bool plotLog = options.Contains("plotLog") && (!options.Contains("!plotLog")); bool plotData = options.Contains("plotData") && (!options.Contains("!plotData")); bool sigStack = options.Contains("sigStack") && (!options.Contains("!sigStack")); // Book histograms TH1D * httbar = new TH1D("ttbar" , title, nbinsx, xlow, xup); TH1D * hqcd = new TH1D("qcd" , title, nbinsx, xlow, xup); TH1D * hznn = new TH1D("znn" , title, nbinsx, xlow, xup); TH1D * hwjets = new TH1D("wjets" , title, nbinsx, xlow, xup); TH1D * hother = new TH1D("other" , title, nbinsx, xlow, xup); TH1D * hmc_exp = new TH1D("mc_exp" , title, nbinsx, xlow, xup); TH1D * hsingle_top = new TH1D("single_top" , title, nbinsx, xlow, xup); TH1D * ht1bbbb_1500_100 = new TH1D("t1bbbb_1500_100" , title, nbinsx, xlow, xup); TH1D * ht1bbbb_1000_900 = new TH1D("t1bbbb_1000_900" , title, nbinsx, xlow, xup); TH1D * ht1tttt_1500_100 = new TH1D("t1tttt_1500_100" , title, nbinsx, xlow, xup); TH1D * ht1tttt_1200_800 = new TH1D("t1tttt_1200_800" , title, nbinsx, xlow, xup); TH1D * ht1qqqq_1400_100 = new TH1D("t1qqqq_1400_100" , title, nbinsx, xlow, xup); TH1D * ht1qqqq_1000_800 = new TH1D("t1qqqq_1000_800" , title, nbinsx, xlow, xup); // Format cuts TCut cut(other_cuts); // TCut ttbar_weight("(weightppb*4000)/top_pt_weight_official"); TCut ttbar_weight("(3.17760399999999981e-05*4000)"); cout << "Filling histograms for " << var.Data() << endl; ttbar_ch->Project("ttbar",var,(cut)*ttbar_weight); qcd_ch->Project("qcd",var,cut*weights); znn_ch->Project("znn",var,cut*weights); wjets_ch->Project("wjets",var,(cut)*weights); other_ch->Project("other",var,cut*weights); single_top_ch->Project("single_top",var,cut*weights); t1bbbb_1500_100_ch->Project("t1bbbb_1500_100",var,(cut)*weights); t1bbbb_1000_900_ch->Project("t1bbbb_1000_900",var,(cut)*weights); t1tttt_1500_100_ch->Project("t1tttt_1500_100",var,(cut)*weights); t1tttt_1200_800_ch->Project("t1tttt_1200_800",var,(cut)*weights); t1qqqq_1400_100_ch->Project("t1qqqq_1400_100",var,(cut)*weights); t1qqqq_1000_800_ch->Project("t1qqqq_1000_800",var,(cut)*weights); bool addOverflow(true); Double_t e_overflow(0.), i_overflow(0.); if (addOverflow) { i_overflow=httbar->IntegralAndError(nbinsx,nbinsx+1,e_overflow); httbar->SetBinContent(nbinsx, i_overflow); httbar->SetBinError(nbinsx, e_overflow); i_overflow=hqcd->IntegralAndError(nbinsx,nbinsx+1,e_overflow); hqcd->SetBinContent(nbinsx, i_overflow); hqcd->SetBinError(nbinsx, e_overflow); i_overflow=hznn->IntegralAndError(nbinsx,nbinsx+1,e_overflow); hznn->SetBinContent(nbinsx, i_overflow); hznn->SetBinError(nbinsx, e_overflow); i_overflow=hwjets->IntegralAndError(nbinsx,nbinsx+1,e_overflow); hwjets->SetBinContent(nbinsx, i_overflow); hwjets->SetBinError(nbinsx, e_overflow); i_overflow=hsingle_top->IntegralAndError(nbinsx,nbinsx+1,e_overflow); hsingle_top->SetBinContent(nbinsx, i_overflow); hsingle_top->SetBinError(nbinsx, e_overflow); i_overflow=hother->IntegralAndError(nbinsx,nbinsx+1,e_overflow); hother->SetBinContent(nbinsx, i_overflow); hother->SetBinError(nbinsx, e_overflow); i_overflow=ht1bbbb_1500_100->IntegralAndError(nbinsx,nbinsx+1,e_overflow); ht1bbbb_1500_100->SetBinContent(nbinsx, i_overflow); ht1bbbb_1500_100->SetBinError(nbinsx, e_overflow); i_overflow=ht1bbbb_1000_900->IntegralAndError(nbinsx,nbinsx+1,e_overflow); ht1bbbb_1000_900->SetBinContent(nbinsx, i_overflow); ht1bbbb_1000_900->SetBinError(nbinsx, e_overflow); i_overflow=ht1tttt_1500_100->IntegralAndError(nbinsx,nbinsx+1,e_overflow); ht1tttt_1500_100->SetBinContent(nbinsx, i_overflow); ht1tttt_1500_100->SetBinError(nbinsx, e_overflow); i_overflow=ht1tttt_1200_800->IntegralAndError(nbinsx,nbinsx+1,e_overflow); ht1tttt_1200_800->SetBinContent(nbinsx, i_overflow); ht1tttt_1200_800->SetBinError(nbinsx, e_overflow); i_overflow=ht1qqqq_1400_100->IntegralAndError(nbinsx,nbinsx+1,e_overflow); ht1qqqq_1400_100->SetBinContent(nbinsx, i_overflow); ht1qqqq_1400_100->SetBinError(nbinsx, e_overflow); i_overflow=ht1qqqq_1000_800->IntegralAndError(nbinsx,nbinsx+1,e_overflow); ht1qqqq_1000_800->SetBinContent(nbinsx, i_overflow); ht1qqqq_1000_800->SetBinError(nbinsx, e_overflow); } // Add up MC histograms hmc_exp->Add(httbar); hmc_exp->Add(hqcd); hmc_exp->Add(hznn); hmc_exp->Add(hwjets); hmc_exp->Add(hsingle_top); hmc_exp->Add(hother); double binwidth = (xup - xlow) / nbinsx; TString ytitle = Form("Events / %.3f", binwidth); hmc_exp->GetXaxis()->SetTitle(httbar->GetXaxis()->GetTitle()); hmc_exp->GetYaxis()->SetTitle(ytitle); cout << "... DONE: add all backgrounds to mc_exp." << endl; Double_t ttbar_e(0.), qcd_e(0.), znn_e(0.), wjets_e(0.), other_e(0.), single_top_e(0.), bg_tot_e(0.), t1tttt_1500_100_e(0.); double ttbar_n(httbar->IntegralAndError(0,nbinsx+1, ttbar_e)); double qcd_n(hqcd->IntegralAndError(0,nbinsx+1, qcd_e)); double znn_n(hznn->IntegralAndError(0,nbinsx+1, znn_e)); double wjets_n(hwjets->IntegralAndError(0,nbinsx+1, wjets_e)); double other_n(hother->IntegralAndError(0,nbinsx+1, other_e)); double single_top_n(hsingle_top->IntegralAndError(0,nbinsx+1, single_top_e)); double bg_tot(hmc_exp->IntegralAndError(0,nbinsx+1, bg_tot_e)); double t1tttt_1500_100_n(ht1tttt_1500_100->IntegralAndError(0,nbinsx+1, t1tttt_1500_100_e)); printf("Counts before cut: %s\n",var.Data()); printf("&ttbar&qcd&znn&wjets&single top&other&t1bbbb_1500_100\\\\ \n"); printf("%s & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f & %3.2f+-%3.2f \\\\\n", var.Data(), ttbar_n,ttbar_e, qcd_n,qcd_e, znn_n,znn_e, wjets_n,wjets_e, single_top_n,single_top_e, other_n,other_e, // hmc_exp->GetBinContent(1), hmc_exp->GetBinError(1), bg_tot,bg_tot_e, t1tttt_1500_100_n,t1tttt_1500_100_e); cout << "... DONE: filled histograms." << endl; if (sigStack) { for (int bin(0); bin<nbinsx; bin++) { ht1bbbb_1500_100->SetBinContent(bin+1, hmc_exp->GetBinContent(bin+1)); ht1bbbb_1000_900->SetBinContent(bin+1, hmc_exp->GetBinContent(bin+1)); ht1tttt_1500_100->SetBinContent(bin+1, hmc_exp->GetBinContent(bin+1)); ht1tttt_1200_800->SetBinContent(bin+1, hmc_exp->GetBinContent(bin+1)); } } THStack * hs = new THStack("hs", ""); hs->Add(hother); hs->Add(hsingle_top); hs->Add(hwjets); hs->Add(hznn); if (httbar->Integral()>hqcd->Integral()) { hs->Add(hqcd); hs->Add(httbar); } else { hs->Add(httbar); hs->Add(hqcd); } //hs->GetYaxis()->SetTitle("Events / 5 fb^{-1}"); //hs->GetXaxis()->SetTitle(httbar->GetXaxis()->GetTitle()); // Setup histogram styles set_style(httbar, "ttbar"); set_style(hqcd, "qcd"); set_style(hznn, "znn"); set_style(hwjets, "wjets"); set_style(hother, "other"); set_style(hsingle_top, "single_top"); // Setup auxiliary histograms (ratios, errors, etc) TH1D * staterr = (TH1D *) hmc_exp->Clone("staterr"); staterr->Sumw2(); //staterr->SetFillColor(kRed); staterr->SetFillColor(kGray+3); staterr->SetMarkerSize(0); staterr->SetFillStyle(3013); // Setup legends TLegend * leg1 = new TLegend(0.48, 0.6, 0.72, 0.92); set_style(leg1,0.025); if (plotData) leg1->AddEntry(hsingle_top, "Data", "pel"); if (plotSig) { leg1->AddEntry(ht1bbbb_1500_100, "#splitline{T1bbbb}{(1500,100) GeV}", "l"); leg1->AddEntry(ht1bbbb_1000_900, "#splitline{T1bbbb}{(1000,900) GeV}", "l"); leg1->AddEntry(ht1tttt_1500_100, "#splitline{T1tttt}{(1500,100) GeV}", "l"); leg1->AddEntry(ht1tttt_1200_800, "#splitline{T1tttt}{(1200,800) GeV}", "l"); leg1->AddEntry(ht1qqqq_1400_100, "#splitline{T1qqqq}{(1400,100) GeV}", "l"); leg1->AddEntry(ht1qqqq_1000_800, "#splitline{T1qqqq}{(1000,800) GeV}", "l"); } TLegend * leg2 = new TLegend(0.72, 0.6, 0.94, 0.92); set_style(leg2,0.025); if (httbar->Integral()>hqcd->Integral()) { leg2->AddEntry(httbar, "t#bar{t}", "f"); leg2->AddEntry(hqcd, "QCD", "f"); } else { leg2->AddEntry(hqcd, "QCD", "f"); leg2->AddEntry(httbar, "t#bar{t}", "f"); } leg2->AddEntry(hznn, "Z+jets", "f"); leg2->AddEntry(hwjets, "W+jets", "f"); leg2->AddEntry(hsingle_top, "Single Top", "f"); leg2->AddEntry(hother, "Other", "f"); leg2->AddEntry(staterr, "MC uncert.", "f"); double ymax = hs->GetMaximum(); if (ht1tttt_1500_100->GetMaximum()>ymax) ymax=ht1tttt_1500_100->GetMaximum(); if (ht1bbbb_1500_100->GetMaximum()>ymax) ymax=ht1bbbb_1500_100->GetMaximum(); if (ht1qqqq_1400_100->GetMaximum()>ymax) ymax=ht1qqqq_1400_100->GetMaximum(); if(plotLog) { hs->SetMaximum(200*ymax); hs->SetMinimum(0.1); } else { hs->SetMaximum(2*ymax); if (plot_title.Contains("baseline")) hs->SetMaximum(1.3*ymax); } // Vertical lines for cuts TLine* line_low = new TLine(cut_low,0,cut_low,1.5*ymax); TLine* line_high = new TLine(cut_high,0,cut_high,1.5*ymax); set_style(line_low); set_style(line_high); // Setup canvas and pads TCanvas * c1 = new TCanvas("c1", "c1", 700, 700); TPad * pad1 = new TPad("pad1", "top pad" , 0.0, 0.3, 1.0, 1.0); TPad * pad2 = new TPad("pad2", "bottom pad", 0.0, 0.0, 1.0, 0.3); if(plotData) { pad1->SetBottomMargin(0.0); pad1->Draw(); pad2->SetTopMargin(0.0); pad2->SetBottomMargin(0.35); pad2->Draw(); pad1->cd(); pad1->SetLogy(plotLog); } else { c1->cd(); c1->SetLogy(plotLog); } // Draw hists hs->Draw("hist"); hs->SetTitle(hmc_exp->GetTitle()); hs->GetXaxis()->SetTitle(httbar->GetXaxis()->GetTitle()); hs->GetYaxis()->SetTitle(ytitle); hs->GetXaxis()->SetLabelSize(0.03); hs->GetYaxis()->SetLabelSize(0.03); if (plotData) { // hsingle_top->Draw("e1 same"); hs->GetXaxis()->SetLabelSize(0); } staterr->Draw("e2 same"); if (plotSig) { ht1bbbb_1500_100->SetLineColor(2); ht1bbbb_1500_100->SetLineWidth(4); ht1bbbb_1500_100->SetFillColor(0); ht1bbbb_1000_900->SetLineColor(2); ht1bbbb_1000_900->SetLineWidth(4); ht1bbbb_1000_900->SetLineStyle(7); ht1bbbb_1000_900->SetFillColor(0); ht1tttt_1500_100->SetLineColor(kGreen); ht1tttt_1500_100->SetLineWidth(4); ht1tttt_1500_100->SetFillColor(0); ht1tttt_1200_800->SetLineColor(kGreen); ht1tttt_1200_800->SetLineStyle(7); ht1tttt_1200_800->SetLineWidth(4); ht1tttt_1200_800->SetFillColor(0); ht1qqqq_1400_100->SetLineColor(1006); ht1qqqq_1400_100->SetLineWidth(4); ht1qqqq_1400_100->SetFillColor(0); ht1qqqq_1000_800->SetLineColor(1006); ht1qqqq_1000_800->SetLineWidth(4); ht1qqqq_1000_800->SetLineStyle(7); ht1qqqq_1000_800->SetFillColor(0); ht1bbbb_1500_100->Draw("hist same"); ht1bbbb_1000_900->Draw("hist same"); ht1tttt_1500_100->Draw("hist same"); ht1tttt_1200_800->Draw("hist same"); ht1qqqq_1400_100->Draw("hist same"); ht1qqqq_1000_800->Draw("hist same"); } if (cut_low>0) line_low->Draw("same"); if (cut_high>0) line_high->Draw("same"); // Draw legends leg1->Draw(); leg2->Draw(); TLatex * latex = new TLatex(); latex->SetNDC(); latex->SetTextAlign(12); latex->SetTextFont(62); latex->SetTextSize(0.042); latex->DrawLatex(0.19, 0.89, "CMS Simulation"); latex->SetTextSize(0.03); latex->DrawLatex(0.19, 0.84, "#sqrt{s} = 13 TeV, L = 4 fb^{-1}"); // Print cout << "MakePlots(): Printing..." << endl; c1->cd(); if (plot_title.EqualTo("default")) plot_title=plotdir+var; gPad->Print(plotdir+plot_title+".pdf"); // Clean up delete staterr; delete leg1; delete leg2; delete latex; // delete pave; delete hs; delete pad1; delete pad2; delete c1; delete httbar; delete hqcd; delete hznn; delete hwjets; delete hsingle_top; delete hother; delete hmc_exp; delete ht1bbbb_1500_100; delete ht1bbbb_1000_900; delete ht1tttt_1500_100; delete ht1tttt_1200_800; delete ht1qqqq_1400_100; delete ht1qqqq_1000_800; cout << "MakePlots(): DONE!" << endl; return; }
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 Draw(const int &rebin=1) { Color_t _sampleColor[nSamples]; //_sampleColor[iHWW ] = kRed+1; //_sampleColor[iWW ] = kAzure-9; //_sampleColor[iZJets] = kGreen+2; //_sampleColor[iZTau] = kGreen+2; //_sampleColor[iTop ] = kYellow; //_sampleColor[iWZ ] = kAzure-2; //_sampleColor[iWJets] = kGray+1; //_sampleColor[iWJets] = kViolet-9; //_sampleColor[iWJets] = kCyan; _sampleColor[itH ] = kRed; _sampleColor[iWZ ] = kAzure-9; _sampleColor[iZZ ] = kAzure-5; _sampleColor[iWW ] = kAzure-1; _sampleColor[itt ] = kGray; _sampleColor[ittw ] = kOrange+7; _sampleColor[ittz ] = kOrange+1; _sampleColor[iwww ] = kSpring+9; _sampleColor[iwwz ] = kSpring+3; _sampleColor[iwzz ] = kSpring-7; _sampleColor[idyl ] = kViolet-1; _sampleColor[idy ] = kViolet-1; //setUpStyle(); if(!gPad) new TCanvas(); THStack* hstack = new THStack(); for (int i=0; i<nSamples; i++) { // in case the user doesn't set it if( !_hist[i] ) continue; _hist[i]->Rebin(rebin); _hist[i]->SetLineColor(_sampleColor[i]); // signal gets overlaid if (i == itH) continue; _hist[i]->SetFillColor(_sampleColor[i]); _hist[i]->SetFillStyle(1001); hstack->Add(_hist[i]); } if(_hist[itH]) _hist[itH]->SetLineWidth(3); if(_data) _data->Rebin(rebin); if(_data) _data->SetLineColor (kBlack); if(_data) _data->SetMarkerStyle(kFullCircle); if(_nostack) { for(int ihist=0;ihist<(int)_hist.size();ihist++) { _hist[ihist]->SetFillStyle(0); _hist[ihist]->SetLineWidth(2); } hstack->Draw("hist,nostack"); if(_hist[itH]) _hist[itH]->Draw("hist,same"); if(_data) _data->Draw("ep,same"); } else { hstack->Draw("hist"); if(_hist[itH]) _hist[itH]->Draw("hist,same"); if(_data) _data->Draw("ep,same"); } //hstack->SetTitle("CMS preliminary"); Float_t theMax = hstack->GetMaximum(); Float_t theMin = hstack->GetMinimum(); theMax = 1.0; //Float_t theMin = hstack->GetMinimum(); if (_hist[itH]) { if (_hist[itH]->GetMaximum() > theMax) theMax = _hist[itH]->GetMaximum(); if (_hist[itH]->GetMinimum() < theMin) theMin = _hist[itH]->GetMinimum(); } if (_data) { Float_t dataMax = GetMaximumIncludingErrors(_data); if (dataMax > theMax) theMax = dataMax; } if (gPad->GetLogy()) { hstack->SetMaximum(500 * theMax); hstack->SetMinimum(0.05); } else { hstack->SetMaximum(1.55 * theMax); } if(_breakdown) { THStackAxisFonts(hstack, "y", "entries"); hstack->GetHistogram()->LabelsOption("v"); } else { THStackAxisFonts(hstack, "x", TString::Format("%s [%s]",_xLabel.Data(),_units.Data())); if(_units.Sizeof() == 1) { THStackAxisFonts(hstack, "x", _xLabel.Data()); THStackAxisFonts(hstack, "y", "entries"); } else { THStackAxisFonts(hstack, "x", TString::Format("%s [%s]",_xLabel.Data(),_units.Data())); THStackAxisFonts(hstack, "y", TString::Format("entries / %.0f %s", _hist[iWZ]->GetBinWidth(0),_units.Data())); } } // total mess to get it nice, should be redone size_t j=0; TString higgsLabel = " tH x 100"; //if(_mass != 0) higgsLabel.Form(" m_{H}=%d",_mass); if(_data ) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _data, " data", "lp"); j++; } if(_hist[itH ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[itH ], higgsLabel, "l" ); j++; } if(_hist[iWZ ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[iWZ ], " WZ", "f" ); j++; } if(_hist[iZZ ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[iZZ ], " ZZ", "f" ); j++; } if(_hist[iWW ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[iWW ], " WW", "f" ); j++; } if(_hist[itt ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[itt ], " tt", "f" ); j++; } if(_hist[ittw ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[ittw ], " ttW", "f" ); j++; } if(_hist[ittz ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[ittz ], " ttZ", "f" ); j++; } if(_hist[iwww ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[iwww ], " WWW", "f" ); j++; } if(_hist[iwwz ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[iwwz ], " WWZ", "f" ); j++; } if(_hist[iwzz ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[iwzz ], " WZZ", "f" ); j++; } if(_hist[idy ]) { DrawLegend(xPos[j], 0.84 - yOff[j]*_yoffset, _hist[idy ], " Drell-Yan","f" ); j++; } //TLatex* luminosity = new TLatex(0.9, 0.815, TString::Format("L = %.1f fb^{-1}",_lumi)); TLatex* luminosity = new TLatex(0.9, 0.95, TString::Format("CMS Preliminary \\sqrt{s} = 8 TeV, L = %.1f fb^{-1}",_lumi)); luminosity->SetNDC(); luminosity->SetTextAlign(32); luminosity->SetTextFont(42); luminosity->SetTextSize(_tsize); luminosity->Draw("same"); // if(_extraLabel) _extraLabel->Draw("same"); // return hstack->GetHistogram(); }
// *************************************** // // this is a function that takes a set of // // histograms and draws them on a canvas // // in a stack, returning the canvas. // // It also plots the signal as a dashed // // line and the data with a ratio at the // // the bottom of data/allBackgrounds // // *************************************** // TCanvas* drawPlots::plotAll(std::vector<TH1D*> histos, std::vector<std::string> names, std::string axisName, TH1D* signal, TH1D* data, TH1D* errDown, TH1D* errUp, bool isSignalRegion, bool doLogAxis){ const unsigned int MAINPLOT_WIDTH = 800; const unsigned int MAINPLOT_HEIGHT = 500; const unsigned int RATIOPLOT_HEIGHT = 125; const unsigned int OFFSET = 10; //LUKE: Title offset and title size are proportional in //root, so you have to change them together, //this makes me a sad panda const double RATIOPLOT_YAXIS_TITLE_OFFSET = 0.4; const double RATIOPLOT_YAXIS_TITLE_SIZE = 0.14; const double RATIOPLOT_YAXIS_TICK_LENGTH = 0.01; const double RATIOPLOT_YAXIS_LABEL_SIZE = 0.15; const double RATIOPLOT_XAXIS_TITLE_OFFSET = 0.9; const double RATIOPLOT_XAXIS_TITLE_SIZE = 0.2; const double RATIOPLOT_XAXIS_TICK_LENGTH = 0.05; const double RATIOPLOT_XAXIS_LABEL_SIZE = 0.2; const double CANVAS_HEIGHT = MAINPLOT_HEIGHT+RATIOPLOT_HEIGHT+OFFSET; TCanvas* canvas = new TCanvas("canvas","canvas",0,0,MAINPLOT_WIDTH,CANVAS_HEIGHT); canvas->SetMargin(0.,0.,0.,0.); canvas->Clear(); canvas->cd(); // create main pad const double mainPad_ylow = (CANVAS_HEIGHT - MAINPLOT_HEIGHT)/CANVAS_HEIGHT; const double mainPad_yhigh = 1.; const double pad_margin_left = 0.15; const double pad_margin_right = 0.05; double main_y_max = -99; double main_y_min = -99; double main_x_max = -99; double main_x_min = -99; for(int a=0; a<histos.size(); a++){ if(histos[a]){ if(histos[a]->GetEntries()> 0.){ GetAxisLimits(histos[a], main_x_min, main_x_max, main_y_min, main_y_max); } } } if(data){ int maxBinData = data->GetMaximumBin(); double dataYmax = data->GetBinContent(maxBinData); if(dataYmax > main_y_max) main_y_max = dataYmax; } // create main pad TPad* mainPad = new TPad("main","main",0.,mainPad_ylow,1.,mainPad_yhigh); mainPad->SetMargin(pad_margin_left,pad_margin_right,0.,.05); // left, right, bottom, top mainPad->Draw(); mainPad->cd(); SetAtlasStyle(); if(doLogAxis)mainPad->SetLogy(); // clone signal or data because one should exist for each plot TH1D* allBackgrounds; bool gotSomething=false; if(signal) allBackgrounds = (TH1D*)signal->Clone("all_backgrounds"); else if(data) allBackgrounds = (TH1D*)data->Clone("all_backgrounds"); else{ for(int b=0; b<histos.size(); b++){ if(histos[b] && !gotSomething){ allBackgrounds = (TH1D*)histos[b]->Clone("all_backgrounds"); gotSomething=true; } } } // set all bins to zero so that you can add all histograms to it for(int i=0; i<=allBackgrounds->GetNbinsX()+1; i++) allBackgrounds->SetBinContent(i,0); THStack* Stack = new THStack(); std::string title = std::string(";") + axisName + ";Events"; Stack->SetTitle(title.c_str()); for(int b=0; b<histos.size(); b++){ if(histos[b]){ if(histos[b]->GetEntries() > 0.){ histos[b]->SetLineColor(1); histos[b]->SetFillColor(tools::setColor(names[b])); Stack->Add(histos[b]); for(int j=0; j<=allBackgrounds->GetNbinsX()+1; j++){ double binContent=allBackgrounds->GetBinContent(j)+histos[b]->GetBinContent(j); allBackgrounds->SetBinContent(j,binContent); } } } } TH1D* backgroundsForRatio = (TH1D*)allBackgrounds->Clone("bkgds_for_ratio"); if(doLogAxis){ main_y_max = main_y_max*10; if(Stack->GetMinimum()>.1) Stack->SetMinimum(.1); } else main_y_max = main_y_max*1.4; Stack->SetMaximum(main_y_max); Stack->Draw("hist"); errDown->Draw("E2same"); errUp->Draw("E2Same"); // make error histograms for the ratio plot TH1D* ratioErrDown = (TH1D*) errDown->Clone("ratio_error_down"); TH1D* ratioErrUp = (TH1D*) errUp->Clone("ratio_error_up"); ratioErrDown->Divide(backgroundsForRatio); ratioErrUp->Divide(backgroundsForRatio); if(!isSignalRegion && data) data->Draw("e same"); if(signal){ signal->SetLineStyle(2); signal->SetLineColor(kRed); signal->SetLineWidth(5); signal->Draw("hist same"); } TLegend* leg = new TLegend(0.8,0.65,0.95,0.9); leg->SetFillStyle(0); leg->SetBorderSize(0); if(signal) leg->AddEntry(signal, "Signal", "l"); if(!isSignalRegion) leg->AddEntry(data, "Data"); for(int q=0; q<histos.size(); q++){ if(histos[q]){ if(histos[q]->GetEntries() > 0.) leg->AddEntry(histos[q], names[q].c_str(), "f"); } } leg->Draw("lpe"); ATLAS_LABEL(0.2,0.85,1); char text[]="#sqrt{s}=8 TeV"; myText(0.6,0.75,1,.04, text); char text_L[]="#int L dt = 20.3 fb^{-1}"; myText(0.6, 0.85,1, .04, text_L); char inText[100]; int t; if(signal) t=sprintf(inText, "N_{Signal} = %.1f", signal->Integral(0,signal->GetNbinsX()+1)); else t=sprintf(inText, "N_{Signal} = %.1f", 0.); myText(0.2, 0.75, 1, .04, inText); double back_int = allBackgrounds->Integral(0,allBackgrounds->GetNbinsX()+1); if(back_int > 10000.) t=sprintf(inText, "N_{Bkgd} = %.3e", back_int); else t=sprintf(inText, "N_{Bkgd} = %.1f", back_int); myText(0.2, 0.7, 1, .04, inText); if(!isSignalRegion){ if(data) t=sprintf(inText, "N_{Data} = %.0f", data->Integral(0,data->GetNbinsX()+1)); else t=sprintf(inText, "N_{Data} = %.0f", 0.); myText(0.2, 0.65, 1, .04, inText); } canvas->cd(); // Draw Ratio plot double ratio_max = 1.6; double ratio_min = 0.4; const double x_axis_size = 0.4; const double ratio_pad_height = RATIOPLOT_HEIGHT/CANVAS_HEIGHT; double pad_xlow = 0.,pad_xhigh = 1.; double pad_ylow = OFFSET/CANVAS_HEIGHT,pad_yhigh = ratio_pad_height; const char* pad_name = "pad"; TPad* pad4ratio = new TPad(pad_name,pad_name,pad_xlow,pad_ylow,pad_xhigh,pad_yhigh); pad4ratio->SetMargin(pad_margin_left,pad_margin_right,x_axis_size,0.); pad4ratio->Draw(); pad4ratio->cd(); TH1D* ratioPlot; if(data) ratioPlot = (TH1D*)data->Clone("ratio"); else if(signal) ratioPlot = (TH1D*)signal->Clone("ratio"); // if there is no data then use signal for axis ratioPlot->SetTitle(""); ratioPlot->GetYaxis()->SetTitle("Data/MC"); ratioPlot->GetXaxis()->SetTitle(axisName.c_str()); if(data){ ratioPlot->Divide(allBackgrounds); // here change ratio_min and ratio_max if the ratio plot is quite flat double maxDeviation=0; double tempDev=0; for(int ibin=1; ibin<=allBackgrounds->GetNbinsX(); ibin++){ tempDev = std::abs(ratioPlot->GetBinContent(ibin)-1.); if(tempDev > maxDeviation) maxDeviation = tempDev; } if(maxDeviation < 0.1){ ratio_max = 1.12; ratio_min = 0.88; } else if(maxDeviation < 0.2){ ratio_max = 1.25; ratio_min = .75; } ratioPlot->SetMinimum(ratio_min); ratioPlot->SetMaximum(ratio_max); } ratioPlot->GetXaxis()->SetLabelSize(RATIOPLOT_XAXIS_LABEL_SIZE); ratioPlot->GetXaxis()->SetTickLength(RATIOPLOT_XAXIS_TICK_LENGTH); ratioPlot->GetYaxis()->SetLabelSize(RATIOPLOT_YAXIS_LABEL_SIZE); ratioPlot->GetYaxis()->SetTickLength(RATIOPLOT_YAXIS_TICK_LENGTH); ratioPlot->GetYaxis()->SetNdivisions(3); ratioPlot->GetYaxis()->SetTitleSize(RATIOPLOT_YAXIS_TITLE_SIZE); ratioPlot->GetYaxis()->SetTitleOffset(RATIOPLOT_YAXIS_TITLE_OFFSET); ratioPlot->GetXaxis()->SetTitleSize(RATIOPLOT_XAXIS_TITLE_SIZE); ratioPlot->GetXaxis()->SetTitleOffset(RATIOPLOT_XAXIS_TITLE_OFFSET); if(!isSignalRegion && data){ ratioPlot->Draw(); // plot horizontal line at y=1 TF1* horizontal = new TF1("horizontal","pol1",-10000,10000); horizontal->SetParameter(0,1.); horizontal->SetParameter(1,0.); horizontal->SetLineColor(kBlack); horizontal->SetLineStyle(2); horizontal->SetLineWidth(1); horizontal->Draw("same"); ratioErrDown->Draw("E2same"); ratioErrUp->Draw("E2same"); }else if(isSignalRegion){ ratioPlot->Draw("axis"); char text[]="DATA IS BLINDED HERE"; myText(0.4,0.6,1,.2,text); }else{ // in this case it is not the signal region but there is no data ratioPlot->Draw("axis"); char text[]="NO DATA"; myText(0.4,0.6,1,.2,text); } return canvas; }
void plotsNoFitETau(bool mine=false,TString name="collMass",TString file="LFV_vbf_collMass_fakeRate_zjetsEmbed_newSignal.root", TString dir="preselectionMetFix_Nov2", TString dirInternal="vbfmutau",double blindA=100, double blindB=160, bool blind=false, TString Xaxis="M_{#mu,#tau}_{coll} [GeV]", TString Yaxis="Events / 20 GeV", TString Tex="#mu#tau_{h} 0 Jet", double xmin=0, double xmax=300, int rebinning=1, bool setLogY=false, double legx1=0.6, double legy1=0.9, double legx2=0.9, double legy2=0.5, double MAX=-1, double MIN=-1, double CORRFR=1., double scaleSignal=1.0, double ymin=-0.95, double ymax=0.95){ //gROOT->LoadMacro("tdrstyle.C"); setTDRStyle(); //gROOT->LoadMacro("CMS_lumi.C"); writeExtraText = false; int iPeriod = 2; // second parameter in example_plot is iPos, which drives the position of the CMS logo in the plot int iPos=11;// : top-left, left-aligned // iPos=33 : top-right, right-aligned // iPos=22 : center, centered // mode generally : // iPos = 10*(alignement 1/2/3) + position (1/2/3 = left/center/right) // example_plot( iPeriod, 11 ); // left-aligned // example_plot( iPeriod, 33 ); // right-aligned // example_plot( iPeriod, 0 ); // out of frame (in exceptional cases) // example_plot( iPeriod, 11 ); // default: left-aligned // example_plot( iPeriod, 22 ); // centered // example_plot( iPeriod, 33 ); // right-aligned double kForPlotting=1; double branchingratioTauTau=0.063; double branchingratioTauMu=0.1; double Lumi=19717; // Get Plots // Get Plots TFile *_file0= new TFile(dir+"/"+file); TString find="DYrightarrowlljets"; if(!mine) find="zjetsother"; TH1F *hDY=_file0->Get(dirInternal+find); hDY->SetName("DY"); find="Diboson"; if(!mine) find="ww"; TH1F *hWW=_file0->Get(dirInternal+find); hWW->SetName("WW"); find="SingleTop"; if(!mine) find="singlet"; TH1F *hTOP=_file0->Get(dirInternal+find); hTOP->SetName("TOP"); find="tbart"; if(!mine) find="ttbar"; TH1F *hTT=_file0->Get(dirInternal+find); hTT->SetName("TT"); find="Zrightarrowtautauembedded"; if(!mine) find="ztautau"; TH1F *hZTauTau=_file0->Get(dirInternal+find); hZTauTau->SetName("ZTauTau"); find="Fakes"; if(!mine) find="fakes"; TH1F *hFAKES=_file0->Get(dirInternal+find); hFAKES->SetName("fakes"); hFAKES->Scale(CORRFR); TH1F *hLFVVBF126=_file0->Get(dirInternal+"LFVvbfHiggsBR=1"); hLFVVBF126->SetName("LFVVBF126"); TH1F *hSMVBF126=_file0->Get(dirInternal+"SMvbfHiggs"); hSMVBF126->SetName("SMVBF126"); TH1F *hLFVGG126=_file0->Get(dirInternal+"LFVggHiggsBR=1"); hLFVGG126->SetName("LFVGG126"); TH1F *hSMGG126=_file0->Get(dirInternal+"SMHiggs"); hSMGG126->SetName("SMGG126"); find="Observed"; if(!mine) find="data_obs"; TH1F* hdata_obsNoErrFix=_file0->Get(dirInternal+find); TH1F* hdata_obs = hdata_obsNoErrFix->Clone(); std::cout << hdata_obsNoErrFix->GetEntries() << std::endl; for (i = 1; i <= hdata_obs->GetNbinsX(); i++){ if (hdata_obs->GetBinContent(i) == 0){ hdata_obs->SetBinContent(i,0.0); hdata_obs->SetBinError(i,1.8); } } hdata_obs->SetName("data_obs"); TH1F* hSMHIGGS=hSMGG126->Clone(); hSMHIGGS->SetName("HIGGSSM"); hSMHIGGS->Add(hSMVBF126); // For the Control plots only we want signal to be scaled to 100% Br hLFVVBF126->Scale(scaleSignal); hLFVGG126->Scale(scaleSignal); // From the fit /* hDY->Scale(1.122280); hWW->Scale(1.254172); hTOP->Scale(1.348162); hTT->Scale(1.082784); hZTauTau->Scale(1.157596); hFAKES->Scale(0.901000); */ // Daniel's Colors /* WGammaStar=kCyan ZTauTauEmbedded=kOrange-4 ZLL_residual=kAzure+3 TTBar=40 SingleTop=kGreen-2 EWKDiBoson=kRed+2 WJets/QCD Multijets=kMagenta-10 SMHToTauTau=kMagenta */ hFAKES->SetFillColor(kMagenta-10); hFAKES->SetLineColor(kMagenta+4); hFAKES->SetLineWidth(1); hZTauTau->SetFillColor(kOrange-4); hZTauTau->SetLineColor(kOrange+4); hZTauTau->SetLineWidth(1); hDY->SetFillColor(kAzure+3); hDY->SetLineColor(kAzure+4); hDY->SetLineWidth(1); hWW->SetFillColor(kAzure+3); hWW->SetLineColor(kAzure+3); hWW->SetLineWidth(1); hTOP->SetFillColor(kGreen-2); hTOP->SetLineColor(kGreen+4); hTOP->SetLineWidth(1); hTT->SetFillColor(kGreen-2); hTT->SetLineColor(kGreen-2); hTT->SetLineWidth(1); hLFVGG126->SetLineColor(kBlue+1); hLFVGG126->SetLineWidth(3); hLFVVBF126->SetLineColor(kBlue+1); hLFVVBF126->SetLineWidth(3); hLFVVBF126->SetLineStyle(kDashed); hSMVBF126->SetLineColor(kMagenta); hSMVBF126->SetLineWidth(3); hSMVBF126->SetLineStyle(kDashed); hSMGG126->SetLineColor(kMagenta); hSMGG126->SetLineWidth(3); hSMHIGGS->SetFillColor(kMagenta); hSMHIGGS->SetLineColor(kMagenta+1); hSMHIGGS->SetLineWidth(1); hdata_obs->SetMarkerSize(1); // Closer to Daniel's // Rebin hFAKES->Rebin(rebinning); hZTauTau->Rebin(rebinning); hDY->Rebin(rebinning); hTOP->Rebin(rebinning); hTT->Rebin(rebinning); hWW->Rebin(rebinning); hLFVGG126->Rebin(rebinning); hLFVVBF126->Rebin(rebinning); hSMVBF126->Rebin(rebinning); hSMGG126->Rebin(rebinning); hdata_obs->Rebin(rebinning); hSMHIGGS->Rebin(rebinning); // PLOT TCanvas *c1 = new TCanvas("canvas_"+name); TPad *Pad1= new TPad("pad1","",0,0.2,1,1); Pad1->Draw(); Pad1->cd();; Pad1->SetLeftMargin(0.2147651); Pad1->SetRightMargin(0.06543624); Pad1->SetTopMargin(0.07); Pad1->SetBottomMargin(0.04); for (int i=0; i<hFAKES->GetNbinsX()+1; i++){ double content=hFAKES->GetBinContent(i); double contentErr=0;//sqrt(content);//hFAKES->GetBinError(i); double err=sqrt(0.3*0.3*content*content+contentErr*contentErr); hFAKES->SetBinError(i,err); } TH1F* fullMC2=hZTauTau->Clone(); fullMC2->Add(hFAKES); fullMC2->Add(hTT); fullMC2->Add(hWW); fullMC2->Add(hDY); fullMC2->Add(hTOP); fullMC2->SetFillColorAlpha(kGray+2, 0.35); //fullMC2->SetFillStyle(3002); fullMC2->SetMarkerSize(0); fullMC2->Draw("hist"); fullMC2->GetXaxis()->SetTitle(""); fullMC2->GetYaxis()->SetTitle(Yaxis); fullMC2->GetXaxis()->SetRangeUser(xmin,xmax); fullMC2->GetYaxis()->SetTitleOffset(1.2); fullMC2->GetYaxis()->SetTitleSize(0.05); fullMC2->GetXaxis()->SetNdivisions(505); fullMC2->GetYaxis()->SetLabelSize(0.04); fullMC2->GetXaxis()->SetLabelSize(0); THStack* stack = new THStack("stack",""); stack->Add(hFAKES); stack->Add(hWW); stack->Add(hDY); stack->Add(hTT); stack->Add(hTOP); stack->Add(hZTauTau); stack->Add(hSMHIGGS); cout<<"Yields"<<endl; cout<<"VV " <<hWW->Integral()<<endl; cout<<"TOP " <<hTOP->Integral()<<endl; cout<<"TT " <<hTT->Integral()<<endl; cout<<"DY " <<hDY->Integral()<<endl; cout<<"ZTauTau " <<hZTauTau->Integral()<<endl; cout<<"FAKES " <<hFAKES->Integral()<<endl; cout<<"LFVGG126 " <<hLFVGG126->Integral()<<endl; cout<<"LFVVBF126 " <<hLFVVBF126->Integral()<<endl; stack->Draw("samehist"); fullMC2->Draw("sames,E2"); hLFVVBF126->Draw("sameshist"); hLFVGG126->Draw("sameshist"); double maxData=hdata_obs->GetMaximum(); double maxMC=stack->GetMaximum()*1.2; double maxLFV=hLFVGG126->GetMaximum(); double maxLFV2=hLFVVBF126->GetMaximum(); double minMC=stack->GetMinimum(); if(maxData>maxMC) {maxMC=1.2*maxData;} if(maxLFV>maxMC) {maxMC=1.2*maxLFV;} if(maxLFV2>maxMC) {maxMC=1.2*maxLFV2;} if(MAX!=-1) {maxMC=MAX;} stack->SetMaximum(maxMC); stack->GetYaxis()->SetRangeUser(minMC,maxMC); fullMC2->SetMaximum(maxMC); fullMC2->GetYaxis()->SetRangeUser(minMC,maxMC); if(setLogY){fullMC2->SetMinimum(0.1); fullMC2->GetYaxis()->SetRangeUser(1,maxMC*1000);} TH1F* histoDataUnblindedV4=hdata_obs->Clone(); histoDataUnblindedV4->SetName("data_unblinded"); if(!blind) hdata_obs->Draw("sames"); else { int findBinA=hdata_obs->FindBin(blindA); int findBinB=hdata_obs->FindBin(blindB); for (int i=findBinA; i<findBinB; i++) hdata_obs->SetBinContent(i,-1000); hdata_obs->Draw("sames"); TPave *pave = new TPave(blindA,minMC,blindB,maxMC,4,"br"); //pave->SetFillColorAlpha(kGray+3,0.35); pave->SetFillColor(1); pave->SetFillStyle(3003); pave->SetDrawOption(0); pave->SetBorderSize(0); pave->Draw(); } TLegend *leg = new TLegend(legx1,legy1,legx2,legy2,NULL,"brNDC"); leg->SetFillColor(0); leg->SetBorderSize(0); leg->SetFillStyle(0); TLegendEntry *entry; entry=leg->AddEntry(hdata_obs,"Data, e#tau_{h}","p"); entry=leg->AddEntry(fullMC2,"Bkgd. uncertainty","f"); entry=leg->AddEntry(hSMHIGGS,"SM Higgs","f"); eblindBy=leg->AddEntry(hZTauTau,"Z#rightarrow#tau#tau","f"); entry=leg->AddEntry(hTOP,"t#bar{t}, t, #bar{t}","f"); entry=leg->AddEntry(hDY,"Other","f"); entry=leg->AddEntry(hFAKES,"MisID'd #tau","f"); entry=leg->AddEntry(hLFVGG126,"LFV GG Higgs (B=100%)","l"); entry=leg->AddEntry(hLFVVBF126,"LFV VBF Higgs (B=100%)","l"); leg->Draw(); CMS_lumi( Pad1, iPeriod, iPos ); TLatex latex; latex.SetNDC(); latex.SetTextAngle(0); latex.SetTextColor(kBlack); latex.SetTextFont(42); latex.SetTextAlign(31); latex.SetTextSize(.05); latex.DrawLatex(0.39,0.8,Tex); //cmsPrelim(Lumi); Pad1->SetLogy(setLogY); gPad->RedrawAxis(); c1->cd(); TPad *Pad2= new TPad("pad2","",0,0,1,0.23); Pad2->Draw(); Pad2->cd(); Pad2->SetGridy(); Pad2->SetLeftMargin(0.2147651); Pad2->SetRightMargin(0.06543624); Pad2->SetTopMargin(0.0); Pad2->SetBottomMargin(0.37); Pad2->SetFillStyle(0); TH1F * Ratio=fullMC2->Clone(); Ratio->SetName("Ratio"); Ratio->Scale(-1); Ratio->Add(hdata_obs,1); Ratio->Divide(fullMC2); Ratio->SetLineColor(kBlack); Ratio->GetXaxis()->SetLabelFont(42); Ratio->GetXaxis()->SetTitleFont(42); Ratio->GetYaxis()->SetNdivisions(505); Ratio->GetYaxis()->SetLabelFont(42); Ratio->GetYaxis()->SetLabelSize(0.122); Ratio->GetYaxis()->SetRangeUser(ymin,ymax); Ratio->GetXaxis()->SetRangeUser(xmin,xmax); Ratio->GetXaxis()->SetLabelSize(0.12); Ratio->GetXaxis()->SetLabelFont(42); Ratio->SetYTitle("#frac{Data-Bkgd}{Bkgd}"); Ratio->SetXTitle(Xaxis); Ratio->GetXaxis()->SetNdivisions(505); Ratio->GetYaxis()->CenterTitle(true); Ratio->GetYaxis()->SetTitleOffset(0.4); Ratio->GetYaxis()->SetTitleSize(0.11); Ratio->GetXaxis()->SetTitleOffset(0.75); Ratio->GetXaxis()->SetTitleSize(0.20); Ratio->SetMarkerSize(1.); TH1F* RatioError = Ratio->Clone(); RatioError->SetName("RatioError"); for (int i=0; i<RatioError->GetNbinsX()+1; i++){ double error=fullMC2->GetBinError(i)*hdata_obs->GetBinContent(i)/fullMC2->GetBinContent(i)/fullMC2->GetBinContent(i); RatioError->SetBinContent(i,0); RatioError->SetBinError(i,error); } //RatioError->SetFillStyle(3002); RatioError->SetFillColorAlpha(kGray+2,0.35); RatioError->SetMarkerSize(0); RatioError->Draw("E2"); //Ratio->Draw("samesE0"); //errorbarswithoutdatapoints Ratio->Draw("sames"); if(!blind) Ratio->Draw("sames"); else { int findBinA=Ratio->FindBin(blindA); int findBinB=Ratio->FindBin(blindB); for (int i=findBinA; i<findBinB; i++) Ratio->SetBinContent(i,-100); Ratio->Draw("sames"); TPave *pave = new TPave(blindA,-1.0,blindB,1.0,4,"br"); pave->SetFillColor(1); pave->SetFillStyle(3003); //pave->SetFillColorAlpha(kGray+3,0.35); pave->SetDrawOption(0); pave->SetBorderSize(0); pave->Draw(); } if(!setLogY){ // c1->SaveAs(name+"ErrorBarsWithoutDataPoints.png"); // c1->SaveAs(name+"ErrorBarsWithoutDataPoints.pdf"); c1->SaveAs(name+".png"); c1->SaveAs(name+".pdf"); } else { c1->SaveAs(name+"_log.png"); c1->SaveAs(name+"_log.pdf"); } }
void Draw(string filename, bool norm, bool logy, bool eff, bool cum, TLine* line){ if(debug) printf(" Draw (norm is %i) %s\n",norm, filename.c_str()); TCanvas c1; if(logy) c1.SetLogy(); string title; if(Data.size()){ title = Data[0].hist->GetTitle(); title += ";"; title += Data[0].hist->GetXaxis()->GetTitle(); title += ";"; title += Data[0].hist->GetYaxis()->GetTitle(); }else if(Bkg.size()){ title = Bkg[0].hist->GetTitle(); title += ";"; title += Bkg[0].hist->GetXaxis()->GetTitle(); title += ";"; title += Bkg[0].hist->GetYaxis()->GetTitle(); } TH1F* hData = NULL; for(uint i=0; i<Data.size(); i++){ if(i==0) hData = (TH1F*)Data[i].hist->Clone("hData"); else hData->Add(Data[i].hist); } hData->SetMarkerSize(5); if(!eff){ THStack* sBkg = new THStack("sBkg",title.c_str()); THStack* sSigs[Sig.size()]; for(uint i=0; i<Bkg.size(); i++){ sBkg->Add(Bkg[i].hist); } for(uint i=0; i<Sig.size(); i++){ sSigs[i] = (THStack*) sBkg->Clone(); sSigs[i]->Add(Sig[i].hist); } Double_t max = sBkg->GetMaximum(); sBkg->Draw("HIST"); for(unsigned int i=0; i<Sig.size(); i++){ max = TMath::Max(max, sSigs[i]->GetMaximum()); sSigs[i]->Draw("HIST SAME"); } if(hData){ max = TMath::Max(max, hData->GetMaximum()); hData->Draw("E1 SAME"); } sBkg->SetMaximum(1.1*max); }else{ THStack* hs = new THStack("hs",title.c_str()); hs->Add(hData); for(unsigned int i=0; i<Bkg.size(); ++i){ hs->Add(Bkg[i].hist); } for(unsigned int i=0; i<Sig.size(); ++i){ hs->Add(Sig[i].hist); } hs->Draw("nostack HIST"); } if(debug) cout<<"Title: "<<title<<endl; if(debug) cout<<"Creating Legend\n"; TLegend *legend = new TLegend(0.65,0.50,0.88,0.89,""); if(Data.size()) legend->AddEntry(hData, "Data", "PLE"); for(unsigned int i=0; i<Bkg.size(); ++i){ legend->AddEntry(Bkg[i].hist,SampleNames[Bkg[i].name].c_str(), "L"); } for(unsigned int i=0; i<Sig.size(); ++i){ legend->AddEntry(Sig[i].hist,SampleNames[Sig[i].name].c_str(), "L"); } if(norm){//???? //TAxis* axis = samples[0]->at(0).hist->GetXaxis(); //int first = axis->GetFirst(); //int last = axis->GetLast(); //float sum = hists[i]->Integral(first,last); //hists[i]->Scale(1./sum); //axis->SetRange(first,last); } //hs->GetXaxis()->SetNdivisions(10); if(debug) printf("Setting title\n"); legend->SetTextSize(0.03); legend->SetBorderSize(0); legend->SetFillStyle(0); legend->Draw(); if(line) line->Draw(); c1.SaveAs(filename.c_str()); c1.Print("Summary.pdf","pdf"); }
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 fake() { gROOT->SetBatch(); gROOT->SetStyle("Plain"); gStyle->SetOptStat(0); SetStyle(); TCanvas *c1 = new TCanvas("c1","c1",0,0,600,500); c1->Draw(); c1->cd(); TPad *c1_1; gStyle->SetHistTopMargin(0); TLegend *leg = new TLegend(0.65,0.90,0.90,0.70); leg->SetFillColor(253); leg->SetBorderSize(0); std::string fpath = "histTEST_MERGED/QCD_Pt_170to300_TuneCUETP8M1_13TeV_pythia8/data.root"; // std::string histnameFake = "h_muFake_pt"; // std::string histnameReal = "h_muReal_pt"; // std::string histnameFake = "h_muFake_trackerLayersWithMeasurement"; // std::string histnameReal = "h_muReal_trackerLayersWithMeasurement"; // std::string histnameFake = "h_muFake_numberOfValidMuonHits"; // std::string histnameReal = "h_muReal_numberOfValidMuonHits"; // std::string histnameFake = "h_muFake_numberOfMatches"; // std::string histnameReal = "h_muReal_numberOfMatches"; // std::string histnameFake = "h_muFake_numberOfMatchedStations"; // std::string histnameReal = "h_muReal_numberOfMatchedStations"; // std::string histnameFake = "h_muFake_numberOfValidHits"; // std::string histnameReal = "h_muReal_numberOfValidHits"; // std::string histnameFake = "h_muFake_numberOfValidPixelHits"; // std::string histnameReal = "h_muReal_numberOfValidPixelHits"; std::string histnameFake = "h_muFake_numberOfHits"; std::string histnameReal = "h_muReal_numberOfHits"; // std::string histnameFake = "h_muFake_normalizedChi2GlobalTrack"; // std::string histnameReal = "h_muReal_normalizedChi2GlobalTrack"; // std::string histnameFake = "h_muFake_normalizedChi2InnerTrack"; // std::string histnameReal = "h_muReal_normalizedChi2InnerTrack"; TFile *f; TH1D *hFake; TH1D *hReal; f = TFile::Open(fpath.c_str()); { TH1D *hFake_c = (TH1D*)f->Get(histnameFake.c_str()); hFake_c->SetMarkerSize(0.0); TH1D *hReal_c = (TH1D*)f->Get(histnameReal.c_str()); hReal_c->SetMarkerSize(0.0); hFake = (TH1D*)hFake_c->Clone("hFake"); hReal = (TH1D*)hReal_c->Clone("hReal"); } addbin(hFake); addbin(hReal); std::cout << hReal->Integral() << std::endl; std::cout << hFake->Integral() << std::endl; double iFake = hFake->Integral(); double iReal = hReal->Integral(); // double iAll = iFake+iReal; // hFake->Scale(1./iAll); // hReal->Scale(1./iAll); hFake->SetLineColor(9); hFake->SetFillColor(9); hReal->SetLineColor(46); hReal->SetFillColor(46); THStack *hst = new THStack(); hst->Add(hReal); hst->Add(hFake); hst->Draw("hist e1"); float max = hst->GetMaximum(); hst->SetMaximum(1.3*max); hst->SetMinimum(0.); if( histnameFake == "h_muFake_pt" ) hst->GetXaxis()->SetTitle("p_{T} [GeV]"); hst->GetYaxis()->SetTitle("Number of muons"); leg->AddEntry(hFake,"Fake","f"); leg->AddEntry(hReal,"Real","f"); leg->Draw(); c1->Print("pics/fake.eps"); c1->Clear(); TH1F *hRealScaled = (TH1F*)hReal->Clone("hRealScaled"); hRealScaled->Scale(1./iReal); TH1F *hFakeScaled = (TH1F*)hFake->Clone("hFakeScaled"); hFakeScaled->Scale(1./iFake); hFakeScaled->SetLineColor(9); hFakeScaled->SetFillColor(0); hRealScaled->SetLineColor(46); hRealScaled->SetFillColor(0); hRealScaled->Draw("hist e1"); hFakeScaled->Draw("hist e1 same"); float max1 = hRealScaled->GetMaximum(); float max2 = hFakeScaled->GetMaximum(); max = (max1 > max2) ? max1 : max2; hRealScaled->SetMaximum(1.3*max); hRealScaled->SetMinimum(0.); if( histnameFake == "h_muFake_pt" ) hRealScaled->GetXaxis()->SetTitle("p_{T} [GeV]"); if( histnameFake == "h_muFake_trackerLayersWithMeasurement" ) hRealScaled->GetXaxis()->SetTitle("trackerLayersWithMeasurement"); if( histnameFake == "h_muFake_numberOfValidMuonHits" ) hRealScaled->GetXaxis()->SetTitle("numberOfValidMuonHits"); if( histnameFake == "h_muFake_numberOfMatches" ) hRealScaled->GetXaxis()->SetTitle("numberOfMatches"); if( histnameFake == "h_muFake_numberOfMatchedStations" ) hRealScaled->GetXaxis()->SetTitle("numberOfMatchedStations"); if( histnameFake == "h_muFake_numberOfValidHits" ) hRealScaled->GetXaxis()->SetTitle("numberOfValidHits"); if( histnameFake == "h_muFake_numberOfValidPixelHits" ) hRealScaled->GetXaxis()->SetTitle("numberOfValidPixelHits"); if( histnameFake == "h_muFake_numberOfHits" ) hRealScaled->GetXaxis()->SetTitle("numberOfHits"); if( histnameFake == "h_muFake_normalizedChi2GlobalTrack" ) hRealScaled->GetXaxis()->SetTitle("normalizedChi2GlobalTrack"); if( histnameFake == "h_muFake_normalizedChi2InnerTrack" ) hRealScaled->GetXaxis()->SetTitle("normalizedChi2InnerTrack"); hRealScaled->GetYaxis()->SetTitle("Normalized to unity"); leg->Draw(); c1->Print("pics/fakeComp.eps"); c1->Clear(); gApplication->Terminate(); }
THStack* BasePlot::GetStack(bool isLog) { THStack* hstack = new THStack(); float binWidth = 0; for (int i=0; i<nSamples; i++) if( _hist[i] && i != iHWW) { _hist[i]->SetLineColor(sampleColor[i]); _hist[i]->SetFillColor(sampleColor[i]); _hist[i]->SetFillStyle(1001); binWidth = _hist[i]->GetBinWidth(1); hstack->Add(_hist[i]); } for (size_t i=0; i<_autreHists.size(); i++) { _autreHists[i].second->SetLineColor(autreColors[i]); _autreHists[i].second->SetFillColor(autreColors[i]); _autreHists[i].second->SetFillStyle(1001); hstack->Add(_autreHists[i].second); } hstack->Draw("GOFF"); if(_prelim) hstack->SetTitle("CMS preliminary"); else hstack->SetTitle("CMS, #sqrt{s} = 7 TeV"); Float_t theMax = hstack->GetMaximum(); Float_t theMin = hstack->GetMinimum(); if (_hist[iHWW]) { if (_hist[iHWW]->GetMaximum() > theMax) theMax = _hist[iHWW]->GetMaximum(); if (_hist[iHWW]->GetMinimum() < theMin) theMin = _hist[iHWW]->GetMinimum(); } if (_data) { Float_t dataMax = GetMaximumIncludingErrors(_data); if (dataMax > theMax) theMax = dataMax; } int sampCount = GetSampCount(); float scaleBy = 1.35 + 0.2*(sampCount>6) + 0.2*(sampCount>10) + 0.2*(sampCount>14); // Min --- only need to change if log theMin = theMin==0?0.1:theMin/10; if(isLog) hstack->SetMinimum(theMin); // Max if (_myMax != -1) { hstack->SetMaximum(_myMax); } else if (isLog) { hstack->SetMaximum(pow(10,(log(theMax)/log(10)-log(theMin)/log(10)+1)*scaleBy+log(theMin)/log(10)-1)); } else { hstack->SetMaximum(scaleBy * theMax); } if(_breakdown) { THStackAxisFonts(hstack, "y", "entries"); hstack->GetHistogram()->LabelsOption("v"); } else { THStackAxisFonts(hstack, "x", TString::Format("%s [%s]",_xLabel.Data(),_units.Data())); THStackAxisFonts(hstack, "y", TString::Format("entries / %.1f %s", binWidth,_units.Data())); if(_units.Sizeof() == 1) { THStackAxisFonts(hstack, "x", _xLabel.Data()); // THStackAxisFonts(hstack, "y", "entries"); } } return hstack; }
double etaFit(TString bin, TString valReturn, TString dir){ setTDRStyle(); bool savePlots = false; //these only need to be global is using constraints double Nwjets, Nzjets, NQCD; bool inclZ = false; bool inclW = false; if(dir == "Scale_up" || dir == "Scale_down" || dir == "Match_up" || dir == "Match_down"){ inclZ = true; inclW = true; } //choose object TString Obj = bin; int rebinFact = 1; double MinX = 0.; double MaxX = 2.6; TString Xtitle = "#left|#eta#right|_{#mu}"; //Data data = getSample("SingleMu", 1, rebinFact, Obj, "central"); //MC TH1D* tt = getSample("TTJet", lumi*225.2/6920475, rebinFact, Obj, dir); TH1D* tt_tot = getSample("TTJet", lumi*225.2/6920475, rebinFact, "Muon", dir); TH1D* wjets; //TH1D* w1jets = getSample("W1Jet", lumi*5400.0/23140779, rebinFact, Obj, dir); TH1D* w2jets = getSample("W2Jets", lumi*1750.0/34041404, rebinFact, Obj, dir); TH1D* w3jets = getSample("W3Jets", lumi*519.0/15536443, rebinFact, Obj, dir); TH1D* w4jets = getSample("W4Jets", lumi*214.0/13370904, rebinFact, Obj, dir); TH1D* zjets; //TH1D* z1jets = getSample("DY1JetsToLL", lumi*561.0/24042904, rebinFact, Obj, dir); TH1D* z2jets = getSample("DY2JetsToLL", lumi*181.0/21835749, rebinFact, Obj, dir); TH1D* z3jets = getSample("DY3JetsToLL", lumi*51.1/11010628, rebinFact, Obj, dir); TH1D* z4jets = getSample("DY4JetsToLL", lumi*23.04/6391785, rebinFact, Obj, dir); TH1D* qcd = getQCD(rebinFact); TH1D* qcd_mc = getSample("QCD_Pt-15to20_MuEnrichedPt5", lumi*7.022e8 * 0.0039/1722678, rebinFact, Obj, dir); TH1D* qcd2 = getSample("QCD_Pt-20to30_MuEnrichedPt5", lumi*2.87e8 * 0.0065/8486893, rebinFact, Obj, dir); TH1D* qcd3 = getSample("QCD_Pt-30to50_MuEnrichedPt5", lumi*6.609e7 * 0.0122/8928999, rebinFact, Obj, dir); TH1D* qcd4 = getSample("QCD_Pt-50to80_MuEnrichedPt5", lumi*8082000.0 * 0.0218/7256011, rebinFact, Obj, dir); TH1D* qcd5 = getSample("QCD_Pt-80to120_MuEnrichedPt5", lumi*1024000.0 * 0.0395/9030624, rebinFact, Obj, dir); TH1D* qcd6 = getSample("QCD_Pt-120to170_MuEnrichedPt5", lumi*157800.0 * 0.0473/8500505, rebinFact, Obj, dir); TH1D* qcd7 = getSample("QCD_Pt-170to300_MuEnrichedPt5", lumi*34020.0 * 0.0676/7662483, rebinFact, Obj, dir); TH1D* qcd8 = getSample("QCD_Pt-300to470_MuEnrichedPt5", lumi*1757.0 * 0.0864/7797481, rebinFact, Obj, dir); TH1D* qcd9 = getSample("QCD_Pt-470to600_MuEnrichedPt5", lumi*115.2 * 0.1024/2995767, rebinFact, Obj, dir); TH1D* qcd10 = getSample("QCD_Pt-800to1000_MuEnrichedPt5",lumi*3.57 * 0.1033/4047142, rebinFact, Obj, dir); TH1D* qcd11 = getSample("QCD_Pt-1000_MuEnrichedPt5", lumi*0.774 * 0.1097/3807263, rebinFact, Obj, dir); qcd_mc->Add(qcd2); qcd_mc->Add(qcd3); qcd_mc->Add(qcd4); qcd_mc->Add(qcd5); qcd_mc->Add(qcd6); qcd_mc->Add(qcd7); qcd_mc->Add(qcd8); qcd_mc->Add(qcd9); qcd_mc->Add(qcd10); qcd_mc->Add(qcd11); qcd->Scale(qcd_mc->Integral()); cout << "NQCD: " << qcd_mc->Integral() << endl; TH1D* top_t = getSample("T_t-channel", lumi*56.4/3757707, rebinFact, Obj, dir); TH1D* top_tw = getSample("T_tW-channel", lumi*11.1/497395, rebinFact, Obj, dir); TH1D* top_s = getSample("T_s-channel", lumi*3.79/249516, rebinFact, Obj, dir); TH1D* tbar_t = getSample("Tbar_t-channel", lumi*30.7/1934817, rebinFact, Obj, dir); TH1D* tbar_tw = getSample("Tbar_tW-channel", lumi*11.1/493239, rebinFact, Obj, dir); TH1D* tbar_s = getSample("Tbar_s-channel", lumi*1.76/139948, rebinFact, Obj, dir); //make combined top and single top template TH1D* top = (TH1D*)tt->Clone("top"); top->Add(top_t); top->Add(top_tw);top->Add(top_s); top->Add(tbar_t); top->Add(tbar_tw);top->Add(tbar_s); //sum single top into one TH1D* single_top = (TH1D*)top_t->Clone("single top"); single_top->Add(top_tw);single_top->Add(top_s); single_top->Add(tbar_t); single_top->Add(tbar_tw);single_top->Add(tbar_s); THStack *hs = new THStack("hs","test"); hs->Add(qcd); if(inclZ == true){ zjets = getSample("DYJetsToLL", lumi*5745.25/30457954, rebinFact, Obj, dir); }else{ zjets = getSample("DY1JetsToLL", lumi*561.0/24042904, rebinFact, Obj, dir); zjets->Add(z2jets); zjets->Add(z3jets); zjets->Add(z4jets); } if(inclW == true){ wjets = getSample("WJetsToLNu", lumi*37509/57708550, rebinFact, Obj, dir); }else{ wjets = getSample("W1Jet", lumi*5400.0/23140779, rebinFact, Obj, dir); 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); //combined histo for pseudo? TH1D* allMC = (TH1D*)top->Clone("allMC"); allMC->Add(wjets); allMC->Add(zjets); allMC->Add(qcd); if(savePlots ==true){ //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.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(); TString plotName("plots/Control/Muon/"); plotName += "absEta"; plotName += "_ge2btags.pdf"; // c1->SaveAs(plotName); delete c1; } //clone and scale top_fit = (TH1D*)top->Clone("top fit"); wjets_fit = (TH1D*)wjets->Clone("wjets fit"); zjets_fit = (TH1D*)zjets->Clone("zjets fit"); qcd_fit = (TH1D*)qcd->Clone("qcd fit"); bg_fit = (TH1D*)wjets_fit->Clone("bg fit"); bg_fit->Add(zjets_fit); bg_fit->Add(qcd_fit); top_fit->Scale(1./ top_fit->Integral()); wjets_fit->Scale(1./ wjets_fit->Integral()); zjets_fit->Scale(1./ zjets_fit->Integral()); qcd_fit->Scale(1./ qcd_fit->Integral()); bg_fit->Scale(1./ bg_fit->Integral()); if(savePlots == true){ //draw histos to files TCanvas *c2 = new TCanvas("Plot","Plot",900, 600); top_fit->SetFillColor(kWhite); wjets_fit->SetFillColor(kWhite); zjets_fit->SetFillColor(kWhite); qcd_fit->SetFillColor(kWhite); bg_fit->SetFillColor(kWhite); bg_fit->SetLineColor(kBlack); top_fit->Draw(); bg_fit->Draw("same"); wjets_fit->Draw("same"); zjets_fit->Draw("same"); qcd_fit->Draw("same"); top_fit->SetAxisRange(MinX, MaxX); top_fit->GetXaxis()->SetTitle(Xtitle); top_fit->GetXaxis()->SetTitleSize(0.05); top_fit->GetYaxis()->SetTitle("Normalised Events");top_fit->GetYaxis()->SetTitleSize(0.05); TLegend *tleg3; tleg3 = new TLegend(0.65,0.7,0.8,0.9); tleg3->SetTextSize(0.04); tleg3->SetBorderSize(0); tleg3->SetFillColor(10); tleg3->AddEntry(top_fit , "signal", "l"); tleg3->AddEntry(bg_fit , "background", "l"); tleg3->AddEntry(wjets_fit , "w+jets", "l"); tleg3->AddEntry(zjets_fit , "z+jets", "l"); tleg3->AddEntry(qcd_fit , "QCD", "l"); tleg3->Draw("same"); TText* textPrelim2 = doPrelim(0.17,0.96); textPrelim2->Draw(); c2->SaveAs("plots/Fits/"+bin+"_Template.pdf"); delete c2; } int Ntotal = data->Integral(); double Nsignal = top->Integral(); Nwjets = wjets->Integral(); Nzjets = zjets->Integral(); NQCD = qcd->Integral(); // Initialize minuit, set initial values etc. of parameters. const int npar = 2; // the number of parameters TMinuit minuit(npar); minuit.SetFCN(fcn); minuit.SetPrintLevel(-1); minuit.SetErrorDef(1.); int ierflg = 0; double Nbg= wjets->Integral()+zjets->Integral()+qcd->Integral(); string parName[npar] = {"ttbar+single-top", "background"}; //background parameters double par[npar] = {top->Integral(), Nbg}; //using the MC estimation as the start values 1fb cout << "total data events: " << Ntotal << endl; for(int i=0; i<npar; i++){ //minuit.mnparm(i, parName[i], par[i],10., -1.e6, 1.e6, ierflg); minuit.mnparm(i, parName[i], par[i], 10., 0, Ntotal, ierflg); } //the following is copied from Fabian's fitting code to improve minimum, but you can comment it, it won't affect the fitting results. // 1 standard // 2 try to improve minimum (slower) double arglist[10]; arglist[0]=2; minuit.mnexcm("SET STR",arglist,1,ierflg); minuit.Migrad(); double outpar[npar], err[npar]; for (int i=0; i<npar; i++){ minuit.GetParameter(i,outpar[i],err[i]); } for (int i=0; i<top_fit->GetNbinsX() ; i++){ top_fit->SetBinContent(i+1, top_fit->GetBinContent(i+1)*outpar[0]); bg_fit->SetBinContent(i+1, wjets_fit->GetBinContent(i+1)*outpar[1]); //zjets_fit->SetBinContent(i+1, zjets_fit->GetBinContent(i+1)*outpar[2]); //qcd_fit->SetBinContent(i+1, qcd_fit->GetBinContent(i+1)*outpar[3]); } //print out the results for all templates // cout <<" \n Total number of events after the fit" << endl; // cout<<" & ttbar+single top & w+jets & z+jets & qcd "<<endl; // cout << " & " << Nsignal << " & " << Nwjets << " & " << Nzjets << " & " << NQCD <<endl; // cout<< " & "<<outpar[0]<<"+-"<<err[0]<<" & "<<outpar[1]<<"+-"<<err[1]<<" & "<<outpar[2]<<"+-"<<err[2]<<" & "<<outpar[3]<<"+-"<<err[3]<<endl; cout <<" \n Total number of events after the fit" << endl; cout<<" & ttbar+single top & w+jets & z+jets & qcd "<<endl; cout << " & " << Nsignal << " & " << Nwjets + Nzjets + NQCD <<endl; cout<< " & "<<outpar[0] << "+-" <<err[0] << " & " <<outpar[1]<<"+-"<<err[1] <<endl; if(savePlots == true){ TCanvas *c3 = new TCanvas("Plot","Plot",900, 600); THStack* sum_fit = new THStack("sum fit","stacked histograms"); //used for stack plot qcd_fit->SetFillColor(kYellow); zjets_fit->SetFillColor(kBlue); wjets_fit->SetFillColor(kGreen); top_fit->SetFillColor(kRed); //sum_fit->Add(qcd_fit); sum_fit->Add(zjets_fit); sum_fit->Add(wjets_fit); top_fit->SetLineColor(kBlack); bg_fit->SetFillColor(kGreen); sum_fit->Add(bg_fit);sum_fit->Add(top_fit); sum_fit->Draw(); data->Draw("E same"); sum_fit->GetXaxis()->SetLimits(MinX, MaxX); sum_fit->GetXaxis()->SetTitle(Xtitle); sum_fit->GetXaxis()->SetTitleSize(0.05); sum_fit->GetYaxis()->SetTitle("Number of Events");sum_fit->GetYaxis()->SetTitleSize(0.05); TLegend *tleg4; tleg4 = new TLegend(0.65,0.7,0.8,0.9); tleg4->SetTextSize(0.04); tleg4->SetBorderSize(0); tleg4->SetFillColor(10); tleg4->AddEntry(top_fit , "signal", "ef"); tleg4->AddEntry(bg_fit , "background", "ef"); tleg4->Draw("same"); TText* textPrelim3 = doPrelim(0.17,0.96); textPrelim3->Draw(); c3->SaveAs("plots/Fits/"+bin+"_Fit.pdf"); delete c3; } //cout << "cross section is: " << ((outpar[0]-single_top->Integral())/ tt_tot->Integral())*225.2 << endl; if(valReturn == "measured"){ return outpar[0]; }else if(valReturn == "measuredErr"){ return err[0]; }else if(valReturn == "bgscale"){ return (outpar[1]/Nbg); } return 0; }
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; } }
int Plot_tauPt_Stage1_DD() { double totalMC =0.0; double lumi= 35.865; //20.011 ; // B->5.882 // C->2.646 D->4.353 ; // E->4.049 ; F->3.16 ; G->7.554; H->5.942 //--inv fb--// unsigned long long evt_DYJetsToLL_M50=1; unsigned long long evt_DYJetsToLL_M5to50=1; unsigned long long evt_TT=1; TFile *file_DYJetsToLL_M50 = new TFile("../python/crab_projects_March3/crab_DYJetsToLL_M-50_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/results/hist.root"); double xs_DYJetsToLL_M50=4895000; //--fb--// TFile *file_DYJetsToLL_M5to50 = new TFile("../python/crab_projects_March3/crab_DYJetsToLL_M-10to50_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/results/hist.root"); double xs_DYJetsToLL_M5to50=7160000; //--fb--// TFile *file_TT = new TFile("../python/crab_projects_March3/crab_TT_TuneCUETP8M2T4_13TeV-powheg-pythia8/results/hist.root"); double xs_TT=730000; //--fb--// double kfact_TT= 1.139; TFile *file_TT_Mtt_700to1000 = new TFile("../python/crab_projects_March3/crab_TT_Mtt-700to1000_TuneCUETP8M1_13TeV-powheg-pythia8/results/hist.root"); double xs_TT_Mtt_700to1000=730000; //--fb--// double kfact_TT_Mtt_700to1000= 0.0921; TFile *file_TT_Mtt_1000toInf = new TFile("../python/crab_projects_March3/crab_TT_Mtt-1000toInf_TuneCUETP8M1_13TeV-powheg-pythia8/results/hist.root"); double xs_TT_Mtt_1000toInf=730000; //--fb--// double kfact_TT_Mtt_1000toInf= 0.02474; //TFile *file_WJetsToLNu = new TFile("../python/crab_projects_March3/crab_WJetsToLNu_TuneCUETP8M1_13TeV-amcatnloFXFX-pythia8/results/hist.root"); //double xs_WJetsToLNu=60290000; //--fb--// TFile *file_WJetsToLNu = new TFile("../python/crab_projects_March3/crab_WJetsToLNu_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/results/hist.root"); double xs_WJetsToLNu= 50690000; //--fb--// // TFile *file_WToTauNu_M100 = new TFile("../python/crab_projects_March3/crab_WToTauNu_M-100_TuneCUETP8M1_13TeV-pythia8-tauola/results/hist.root"); double xs_WToTauNu_M100 = 165000; //--fb--// double kfact_WToTauNu_M100 = 1.0 ; // TFile *file_WToTauNu_M200 = new TFile("../python/crab_projects_March3/crab_WToTauNu_M-200_TuneCUETP8M1_13TeV-pythia8-tauola/results/hist.root"); double xs_WToTauNu_M200 = 6370; //--fb--// double kfact_WToTauNu_M200 = 1.0 ; // TFile *file_WToTauNu_M500 = new TFile("../python/crab_projects_March3/crab_WToTauNu_M-500_TuneCUETP8M1_13TeV-pythia8-tauola/results/hist.root"); double xs_WToTauNu_M500 = 224.0; //--fb--// double kfact_WToTauNu_M500 = 1.0 ; // TFile *file_WToTauNu_M1000 = new TFile("../python/crab_projects_March3/crab_WToTauNu_M-1000_TuneCUETP8M1_13TeV-pythia8-tauola/results/hist.root"); double xs_WToTauNu_M1000 = 13.7; //--fb--// double kfact_WToTauNu_M1000 = 1.0 ; // TFile *file_WToTauNu_M2000 = new TFile("../python/crab_projects_March3/crab_WToTauNu_M-2000_TuneCUETP8M1_13TeV-pythia8-tauola/results/hist.root"); double xs_WToTauNu_M2000 = 0.437; //--fb--// double kfact_WToTauNu_M2000 = 1.0 ; // TFile *file_WToTauNu_M3000 = new TFile("../python/crab_projects_March3/crab_WToTauNu_M-3000_TuneCUETP8M1_13TeV-pythia8-tauola/results/hist.root"); double xs_WToTauNu_M3000 = 0.0342; //--fb--// double kfact_WToTauNu_M3000 = 1.0 ; // TFile *file_WToTauNu_M4000 = new TFile("../python/crab_projects_March3/crab_WToTauNu_M-4000_TuneCUETP8M1_13TeV-pythia8-tauola/results/hist.root"); double xs_WToTauNu_M4000 = 0.00292; //--fb--// double kfact_WToTauNu_M4000 = 1.0 ; // TFile *file_WToTauNu_M5000 = new TFile("../python/crab_projects_March3/crab_WToTauNu_M-5000_TuneCUETP8M1_13TeV-pythia8-tauola/results/hist.root"); double xs_WToTauNu_M5000 = 0.000233; //--fb--// double kfact_WToTauNu_M5000 = 1.0 ; // TFile *file_WToTauNu_M6000 = new TFile("../python/crab_projects_March3/crab_WToTauNu_M-6000_TuneCUETP8M1_13TeV-pythia8-tauola/results/hist.root"); double xs_WToTauNu_M6000 = 0.000015; //--fb--// double kfact_WToTauNu_M6000 = 1.0 ; // TFile *file_WJetsToLNu_HT100To200 = new TFile("../python/crab_projects_March3/crab_WJetsToLNu_HT-100To200_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/results/hist.root"); double xs_WJetsToLNu_HT100To200 = 1345000 ; //--fb--// double kfact_WJetsToLNu_HT100To200 = 1.0 ; TFile *file_WJetsToLNu_HT200To400 = new TFile("../python/crab_projects_March3/crab_WJetsToLNu_HT-200To400_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/results/hist.root"); double xs_WJetsToLNu_HT200To400 = 359700 ; //--fb--// double kfact_WJetsToLNu_HT200To400 = 1.0 ; TFile *file_WJetsToLNu_HT400To600 = new TFile("../python/crab_projects_March3/crab_WJetsToLNu_HT-400To600_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/results/hist.root"); double xs_WJetsToLNu_HT400To600 = 48910 ; //--fb--// double kfact_WJetsToLNu_HT400To600 = 1.0 ; TFile *file_WJetsToLNu_HT600To800 = new TFile("../python/crab_projects_March3/crab_WJetsToLNu_HT-600To800_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/results/hist.root"); double xs_WJetsToLNu_HT600To800 = 12050 ; //--fb--// double kfact_WJetsToLNu_HT600To800 = 1.0 ; TFile *file_WJetsToLNu_HT800To1200 = new TFile("../python/crab_projects_March3/crab_WJetsToLNu_HT-800To1200_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/results/hist.root"); double xs_WJetsToLNu_HT800To1200 = 5501 ; //--fb--// double kfact_WJetsToLNu_HT800To1200 = 1.0 ; TFile *file_WJetsToLNu_HT1200To2500 = new TFile("../python/crab_projects_March3/crab_WJetsToLNu_HT-1200To2500_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/results/hist.root"); double xs_WJetsToLNu_HT1200To2500 = 1329 ; //--fb--// double kfact_WJetsToLNu_HT1200To2500 = 1.0 ; TFile *file_WJetsToLNu_HT2500ToInf = new TFile("../python/crab_projects_March3/crab_WJetsToLNu_HT-2500ToInf_TuneCUETP8M1_13TeV-madgraphMLM-pythia8/results/hist.root"); double xs_WJetsToLNu_HT2500ToInf = 32.16 ; //--fb--// double kfact_WJetsToLNu_HT2500ToInf = 1.0 ; TFile *file_ST_tchannel_antitop=new TFile("../python/crab_projects_March3/crab_ST_t-channel_antitop_4f_inclusiveDecays_TuneCUETP8M2T4_13TeV-powhegV2-madspin/results/hist.root"); double xs_ST_tchannel_antitop = 80950; //--fb--// double kfact_ST_tchannel_antitop = 1.0; //0.326; // TFile *file_ST_tchannel_top=new TFile("../python/crab_projects_March3/crab_ST_t-channel_top_4f_inclusiveDecays_TuneCUETP8M2T4_13TeV-powhegV2-madspin/results/hist.root"); double xs_ST_tchannel_top =136020; //103200; //--fb--// double kfact_ST_tchannel_top = 1.0; //0.43; // TFile *file_ST_tW_antitop=new TFile("../python/crab_projects_March3/crab_ST_tW_antitop_5f_inclusiveDecays_13TeV-powheg-pythia8_TuneCUETP8M2T4/results/hist.root"); double xs_ST_tW_antitop = 38090; //--fb--// double kfact_ST_tW_antitop =1.0; // 0.94; // TFile *file_ST_tW_top=new TFile("../python/crab_projects_March3/crab_ST_tW_top_5f_inclusiveDecays_13TeV-powheg-pythia8_TuneCUETP8M2T4/results/hist.root"); double xs_ST_tW_top = 38090; //--fb--// double kfact_ST_tW_top = 1.0; //0.94; // TFile *file_WW=new TFile("../python/crab_projects_March3/crab_WW_TuneCUETP8M1_13TeV-pythia8/results/hist.root"); double xs_WW = 63210; //--fb--// // TFile *file_WZ=new TFile("../python/crab_projects_March3/crab_WZ_TuneCUETP8M1_13TeV-pythia8/results/hist.root"); double xs_WZ = 22820; //--fb--// double kfact_WZ = 2.06; // 47.13/22.82 // TFile *file_ZZ=new TFile("../python/crab_projects_March3/crab_ZZ_TuneCUETP8M1_13TeV-pythia8/results/hist.root"); double xs_ZZ = 10320; //--fb--// double kfact_ZZ = 1.60 ; //16523/10320 // std::cout << "get datadriven root file" << std::endl; TFile *file_Datadriven = new TFile("/net/scratch_cms3a/materok/wprime/qcd/dataDrivenTree15_pt_base_Mar7_fromData.root"); /// DATA /// TFile *file_Tau_Run2016B = new TFile("../python/crab_projects_March3/crab_Tau_Run2016B/results/hist.root"); TFile *file_Tau_Run2016C = new TFile("../python/crab_projects_March3/crab_Tau_Run2016C/results/hist.root"); TFile *file_Tau_Run2016D = new TFile("../python/crab_projects_March3/crab_Tau_Run2016D/results/hist.root"); TFile *file_Tau_Run2016E = new TFile("../python/crab_projects_March3/crab_Tau_Run2016E/results/hist.root"); TFile *file_Tau_Run2016F = new TFile("../python/crab_projects_March3/crab_Tau_Run2016F/results/hist.root"); TFile *file_Tau_Run2016G = new TFile("../python/crab_projects_March3/crab_Tau_Run2016G/results/hist.root"); TFile *file_Tau_Run2016H_v2 = new TFile("../python/crab_projects_March3/crab_Tau_Run2016H_1/results/hist.root"); TFile *file_Tau_Run2016H_v3 = new TFile("../python/crab_projects_March3/crab_Tau_Run2016H_2/results/hist.root"); /// Signal /// TFile *file_Wprime_M4000 = new TFile("../python/crab_projects_March3/crab_WprimeToTauNu_M-4000_TuneCUETP8M1_13TeV-pythia8-tauola/results/hist.root"); double xs_Wprime_M4000= 2.04; // --fb-- // //--// TH1D* h1_evt_DYJetsToLL_M50 = (TH1D*)file_DYJetsToLL_M50->Get("demo/histoDir/eventCount"); evt_DYJetsToLL_M50 = h1_evt_DYJetsToLL_M50->GetEntries(); // Integral(); double wt_DYJetsToLL_M50 = (xs_DYJetsToLL_M50*lumi)/evt_DYJetsToLL_M50 ; TH1D* tauPt_Stage1_DYJetsToLL_M50 = (TH1D*)file_DYJetsToLL_M50->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_DYJetsToLL_M50->Scale(wt_DYJetsToLL_M50); std::cout << "DYJetsToLL_M50 weighted nevt=" << tauPt_Stage1_DYJetsToLL_M50->Integral() << std::endl; totalMC += tauPt_Stage1_DYJetsToLL_M50->Integral(); TH1D* h1_evt_DYJetsToLL_M5to50 = (TH1D*)file_DYJetsToLL_M5to50->Get("demo/histoDir/eventCount"); evt_DYJetsToLL_M5to50 = h1_evt_DYJetsToLL_M5to50->GetEntries(); // Integral(); double wt_DYJetsToLL_M5to50 = (xs_DYJetsToLL_M5to50*lumi)/evt_DYJetsToLL_M5to50 ; TH1D* tauPt_Stage1_DYJetsToLL_M5to50 = (TH1D*)file_DYJetsToLL_M5to50->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_DYJetsToLL_M5to50->Scale(wt_DYJetsToLL_M5to50); std::cout << "DYJetsToLL_M5to50 weighted nevt=" << tauPt_Stage1_DYJetsToLL_M5to50->Integral() << std::endl; totalMC += tauPt_Stage1_DYJetsToLL_M5to50->Integral() ; // TH1D* total_DY = (TH1D*)tauPt_Stage1_DYJetsToLL_M50->Clone(); total_DY->Add(tauPt_Stage1_DYJetsToLL_M5to50); total_DY->SetFillColorAlpha(kRed,0.5); total_DY->SetLineColor(kBlack); total_DY->Rebin(10); // TH1D* h1_evt_TT = (TH1D*)file_TT->Get("demo/histoDir/eventCount"); evt_TT = h1_evt_TT->GetEntries(); // Integral(); double wt_TT = (xs_TT*lumi)/evt_TT ; TH1D* tauPt_Stage1_TT = (TH1D*)file_TT->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_TT->Scale(wt_TT); tauPt_Stage1_TT->Scale(kfact_TT); std::cout << "TTbar weighted nevt=" << tauPt_Stage1_TT->Integral() << std::endl; totalMC += tauPt_Stage1_TT->Integral(); //file_TT_Mtt_700to1000 TH1D* h1_evt_TT_Mtt_700to1000 = (TH1D*)file_TT_Mtt_700to1000->Get("demo/histoDir/eventCount"); evt_TT_Mtt_700to1000 = h1_evt_TT_Mtt_700to1000->GetEntries(); // Integral(); double wt_TT_Mtt_700to1000 = (xs_TT_Mtt_700to1000*lumi)/evt_TT_Mtt_700to1000 ; TH1D* tauPt_Stage1_TT_Mtt_700to1000 = (TH1D*)file_TT_Mtt_700to1000->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_TT_Mtt_700to1000->Scale(wt_TT_Mtt_700to1000); tauPt_Stage1_TT_Mtt_700to1000->Scale(kfact_TT_Mtt_700to1000); std::cout << "TT_Mtt_700to1000bar weighted nevt=" << tauPt_Stage1_TT_Mtt_700to1000->Integral() << std::endl; totalMC += tauPt_Stage1_TT_Mtt_700to1000->Integral() ; //file_TT_Mtt_1000toInf TH1D* h1_evt_TT_Mtt_1000toInf = (TH1D*)file_TT_Mtt_1000toInf->Get("demo/histoDir/eventCount"); evt_TT_Mtt_1000toInf = h1_evt_TT_Mtt_1000toInf->GetEntries(); // Integral(); double wt_TT_Mtt_1000toInf = (xs_TT_Mtt_1000toInf*lumi)/evt_TT_Mtt_1000toInf ; TH1D* tauPt_Stage1_TT_Mtt_1000toInf = (TH1D*)file_TT_Mtt_1000toInf->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_TT_Mtt_1000toInf->Scale(wt_TT_Mtt_1000toInf); tauPt_Stage1_TT_Mtt_1000toInf->Scale(kfact_TT_Mtt_1000toInf); std::cout << "TT_Mtt_1000toInfbar weighted nevt=" << tauPt_Stage1_TT_Mtt_1000toInf->Integral() << std::endl; totalMC += tauPt_Stage1_TT_Mtt_1000toInf->Integral() ; TH1D* total_TT = (TH1D*)tauPt_Stage1_TT->Clone(); total_TT->Add(tauPt_Stage1_TT_Mtt_700to1000); total_TT->Add(tauPt_Stage1_TT_Mtt_1000toInf); total_TT->SetFillColor(kBlue-7); total_TT->SetLineColor(kBlack); total_TT->Rebin(10); /* TH1D* h1_evt_WJetsToLNu = (TH1D*)file_WJetsToLNu->Get("demo/histoDir/eventCount"); evt_WJetsToLNu = h1_evt_WJetsToLNu->GetEntries(); //Integral(); std::cout << "evt_WJetsToLNu = " << evt_WJetsToLNu << std::endl; double wt_WJetsToLNu = (xs_WJetsToLNu*lumi)/evt_WJetsToLNu ; TH1D* tauPt_Stage1_WJetsToLNu = (TH1D*)file_WJetsToLNu->Get("demo/histoDir/tauPt_Stage1"); // Poisson error // tauPt_Stage1_WJetsToLNu->Sumw2(kFALSE); tauPt_Stage1_WJetsToLNu->SetBinErrorOption(TH1::kPoisson); std::cout << "**WJets** unweighted nevt=" << tauPt_Stage1_WJetsToLNu->Integral() << std::endl; std::cout << "wt_WJetsToLNu = " << wt_WJetsToLNu << std::endl; tauPt_Stage1_WJetsToLNu->Scale(wt_WJetsToLNu); tauPt_Stage1_WJetsToLNu->SetFillColorAlpha(kGreen-7,0.5); tauPt_Stage1_WJetsToLNu->SetLineColor(kGreen-7); tauPt_Stage1_WJetsToLNu->Rebin(40); std::cout << "**WJets** weighted nevt=" << tauPt_Stage1_WJetsToLNu->Integral() << std::endl; */ //file_ST_tchannel_antitop TH1D* h1_evt_ST_tchannel_antitop = (TH1D*)file_ST_tchannel_antitop->Get("demo/histoDir/eventCount"); unsigned long long evt_ST_tchannel_antitop = h1_evt_ST_tchannel_antitop->GetEntries(); //Integral(); double wt_ST_tchannel_antitop = (xs_ST_tchannel_antitop*lumi)/evt_ST_tchannel_antitop ; TH1D* tauPt_Stage1_ST_tchannel_antitop = (TH1D*)file_ST_tchannel_antitop->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_ST_tchannel_antitop->Scale(wt_ST_tchannel_antitop); tauPt_Stage1_ST_tchannel_antitop->Scale(kfact_ST_tchannel_antitop); std::cout << "ST_tchannel_antitop weighted nevt=" << tauPt_Stage1_ST_tchannel_antitop->Integral() << std::endl; totalMC += tauPt_Stage1_ST_tchannel_antitop->Integral(); //file_ST_tchannel_top TH1D* h1_evt_ST_tchannel_top = (TH1D*)file_ST_tchannel_top->Get("demo/histoDir/eventCount"); unsigned long long evt_ST_tchannel_top = h1_evt_ST_tchannel_top->GetEntries(); //Integral(); double wt_ST_tchannel_top = (xs_ST_tchannel_top*lumi)/evt_ST_tchannel_top ; TH1D* tauPt_Stage1_ST_tchannel_top = (TH1D*)file_ST_tchannel_top->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_ST_tchannel_top->Scale(wt_ST_tchannel_top); tauPt_Stage1_ST_tchannel_top->Scale(kfact_ST_tchannel_top); std::cout << "ST_tchannel_top weighted nevt=" << tauPt_Stage1_ST_tchannel_top->Integral() << std::endl; totalMC += tauPt_Stage1_ST_tchannel_top->Integral() ; //file_ST_tW_antitop TH1D* h1_evt_ST_tW_antitop = (TH1D*)file_ST_tW_antitop->Get("demo/histoDir/eventCount"); unsigned long long evt_ST_tW_antitop = h1_evt_ST_tW_antitop->GetEntries(); //Integral(); double wt_ST_tW_antitop = (xs_ST_tW_antitop*lumi)/evt_ST_tW_antitop ; TH1D* tauPt_Stage1_ST_tW_antitop = (TH1D*)file_ST_tW_antitop->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_ST_tW_antitop->Scale(wt_ST_tW_antitop); tauPt_Stage1_ST_tW_antitop->Scale(kfact_ST_tW_antitop); std::cout << "ST_tW_antitop weighted nevt=" << tauPt_Stage1_ST_tW_antitop->Integral() << std::endl; totalMC += tauPt_Stage1_ST_tW_antitop->Integral(); //file_ST_tW_top TH1D* h1_evt_ST_tW_top = (TH1D*)file_ST_tW_top->Get("demo/histoDir/eventCount"); unsigned long long evt_ST_tW_top = h1_evt_ST_tW_top->GetEntries(); //Integral(); double wt_ST_tW_top = (xs_ST_tW_top*lumi)/evt_ST_tW_top ; TH1D* tauPt_Stage1_ST_tW_top = (TH1D*)file_ST_tW_top->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_ST_tW_top->Scale(wt_ST_tW_top); tauPt_Stage1_ST_tW_top->Scale(kfact_ST_tW_top); std::cout << "ST_tW_top weighted nevt=" << tauPt_Stage1_ST_tW_top->Integral() << std::endl; totalMC += tauPt_Stage1_ST_tW_top->Integral() ; TH1D* total_ST = (TH1D*)tauPt_Stage1_ST_tchannel_antitop->Clone(); total_ST->Add(tauPt_Stage1_ST_tchannel_top); total_ST->Add(tauPt_Stage1_ST_tW_antitop); total_ST->Add(tauPt_Stage1_ST_tW_top); total_ST->SetFillColorAlpha(kCyan,0.5); total_ST->SetLineColor(kBlack); total_ST->Rebin(10); //file_WJetsToLNu_HT100To200 TH1D* h1_evt_WJetsToLNu_HT100To200 = (TH1D*)file_WJetsToLNu_HT100To200->Get("demo/histoDir/eventCount"); unsigned long long evt_WJetsToLNu_HT100To200 = h1_evt_WJetsToLNu_HT100To200->GetEntries(); //Integral(); double wt_WJetsToLNu_HT100To200 = (xs_WJetsToLNu_HT100To200*lumi)/evt_WJetsToLNu_HT100To200 ; TH1D* tauPt_Stage1_WJetsToLNu_HT100To200 = (TH1D*)file_WJetsToLNu_HT100To200->Get("demo/histoDir/tauPt_Stage1"); // Poisson error // // tauPt_Stage1_WJetsToLNu_HT100To200->Sumw2(kFALSE); //tauPt_Stage1_WJetsToLNu_HT100To200->SetBinErrorOption(TH1::kPoisson); tauPt_Stage1_WJetsToLNu_HT100To200->Scale(wt_WJetsToLNu_HT100To200); std::cout << "WJetsToLNu_HT100To200 weighted nevt=" << tauPt_Stage1_WJetsToLNu_HT100To200->Integral() << std::endl; totalMC += tauPt_Stage1_WJetsToLNu_HT100To200->Integral(); //tauPt_Stage1_WJetsToLNu_HT100To200->Scale(kfact_WJetsToLNu_HT100To200); // std::cout << tauPt_Stage1_WJetsToLNu_HT100To200->GetBinError(300) << std::endl; //file_WJetsToLNu_HT200To400 TH1D* h1_evt_WJetsToLNu_HT200To400 = (TH1D*)file_WJetsToLNu_HT200To400->Get("demo/histoDir/eventCount"); unsigned long long evt_WJetsToLNu_HT200To400 = h1_evt_WJetsToLNu_HT200To400->GetEntries(); //Integral(); double wt_WJetsToLNu_HT200To400 = (xs_WJetsToLNu_HT200To400*lumi)/evt_WJetsToLNu_HT200To400 ; TH1D* tauPt_Stage1_WJetsToLNu_HT200To400 = (TH1D*)file_WJetsToLNu_HT200To400->Get("demo/histoDir/tauPt_Stage1"); // Poisson error // // tauPt_Stage1_WJetsToLNu_HT200To400->Sumw2(kFALSE); //tauPt_Stage1_WJetsToLNu_HT200To400->SetBinErrorOption(TH1::kPoisson); tauPt_Stage1_WJetsToLNu_HT200To400->Scale(wt_WJetsToLNu_HT200To400); std::cout << "WJetsToLNu_HT200To400 weighted nevt=" << tauPt_Stage1_WJetsToLNu_HT200To400->Integral() << std::endl; totalMC += tauPt_Stage1_WJetsToLNu_HT200To400->Integral(); //tauPt_Stage1_WJetsToLNu_HT200To400->Scale(kfact_WJetsToLNu_HT200To400); //std::cout << tauPt_Stage1_WJetsToLNu_HT200To400->GetBinError(300) << std::endl; //file_WJetsToLNu_HT400To600 TH1D* h1_evt_WJetsToLNu_HT400To600 = (TH1D*)file_WJetsToLNu_HT400To600->Get("demo/histoDir/eventCount"); unsigned long long evt_WJetsToLNu_HT400To600 = h1_evt_WJetsToLNu_HT400To600->GetEntries(); //Integral(); double wt_WJetsToLNu_HT400To600 = (xs_WJetsToLNu_HT400To600*lumi)/evt_WJetsToLNu_HT400To600 ; TH1D* tauPt_Stage1_WJetsToLNu_HT400To600 = (TH1D*)file_WJetsToLNu_HT400To600->Get("demo/histoDir/tauPt_Stage1"); // Poisson error // // tauPt_Stage1_WJetsToLNu_HT400To600->Sumw2(kFALSE); //tauPt_Stage1_WJetsToLNu_HT400To600->SetBinErrorOption(TH1::kPoisson); tauPt_Stage1_WJetsToLNu_HT400To600->Scale(wt_WJetsToLNu_HT400To600); std::cout << "WJetsToLNu_HT400To600 weighted nevt=" << tauPt_Stage1_WJetsToLNu_HT400To600->Integral() << std::endl; totalMC += tauPt_Stage1_WJetsToLNu_HT400To600->Integral(); // tauPt_Stage1_WJetsToLNu_HT400To600->Scale(kfact_WJetsToLNu_HT400To600); // std::cout << tauPt_Stage1_WJetsToLNu_HT400To600->GetBinError(300) << std::endl; //file_WJetsToLNu_HT600To800 TH1D* h1_evt_WJetsToLNu_HT600To800 = (TH1D*)file_WJetsToLNu_HT600To800->Get("demo/histoDir/eventCount"); unsigned long long evt_WJetsToLNu_HT600To800 = h1_evt_WJetsToLNu_HT600To800->GetEntries(); //Integral(); double wt_WJetsToLNu_HT600To800 = (xs_WJetsToLNu_HT600To800*lumi)/evt_WJetsToLNu_HT600To800 ; TH1D* tauPt_Stage1_WJetsToLNu_HT600To800 = (TH1D*)file_WJetsToLNu_HT600To800->Get("demo/histoDir/tauPt_Stage1"); // Poisson error // // tauPt_Stage1_WJetsToLNu_HT600To800->Sumw2(kFALSE); // tauPt_Stage1_WJetsToLNu_HT600To800->SetBinErrorOption(TH1::kPoisson); tauPt_Stage1_WJetsToLNu_HT600To800->Scale(wt_WJetsToLNu_HT600To800); std::cout << "WJetsToLNu_HT600To800 weighted nevt=" << tauPt_Stage1_WJetsToLNu_HT600To800->Integral() << std::endl; totalMC += tauPt_Stage1_WJetsToLNu_HT600To800->Integral(); // tauPt_Stage1_WJetsToLNu_HT600To800->Scale(kfact_WJetsToLNu_HT600To800); // std::cout << tauPt_Stage1_WJetsToLNu_HT600To800->GetBinError(300) << std::endl; //file_WJetsToLNu_HT800To1200 TH1D* h1_evt_WJetsToLNu_HT800To1200 = (TH1D*)file_WJetsToLNu_HT800To1200->Get("demo/histoDir/eventCount"); unsigned long long evt_WJetsToLNu_HT800To1200 = h1_evt_WJetsToLNu_HT800To1200->GetEntries(); //Integral(); double wt_WJetsToLNu_HT800To1200 = (xs_WJetsToLNu_HT800To1200*lumi)/evt_WJetsToLNu_HT800To1200 ; TH1D* tauPt_Stage1_WJetsToLNu_HT800To1200 = (TH1D*)file_WJetsToLNu_HT800To1200->Get("demo/histoDir/tauPt_Stage1"); // Poisson error // // tauPt_Stage1_WJetsToLNu_HT800To1200->Sumw2(kFALSE); //tauPt_Stage1_WJetsToLNu_HT800To1200->SetBinErrorOption(TH1::kPoisson); tauPt_Stage1_WJetsToLNu_HT800To1200->Scale(wt_WJetsToLNu_HT800To1200); std::cout << "WJetsToLNu_HT800To1200 weighted nevt=" << tauPt_Stage1_WJetsToLNu_HT800To1200->Integral() << std::endl; totalMC += tauPt_Stage1_WJetsToLNu_HT800To1200->Integral(); //tauPt_Stage1_WJetsToLNu_HT800To1200->Scale(kfact_WJetsToLNu_HT800To1200); // std::cout << tauPt_Stage1_WJetsToLNu_HT800To1200->GetBinError(300) << std::endl; //file_WJetsToLNu_HT1200To2500 TH1D* h1_evt_WJetsToLNu_HT1200To2500 = (TH1D*)file_WJetsToLNu_HT1200To2500->Get("demo/histoDir/eventCount"); unsigned long long evt_WJetsToLNu_HT1200To2500 = h1_evt_WJetsToLNu_HT1200To2500->GetEntries(); //Integral(); double wt_WJetsToLNu_HT1200To2500 = (xs_WJetsToLNu_HT1200To2500*lumi)/evt_WJetsToLNu_HT1200To2500 ; TH1D* tauPt_Stage1_WJetsToLNu_HT1200To2500 = (TH1D*)file_WJetsToLNu_HT1200To2500->Get("demo/histoDir/tauPt_Stage1"); // Poisson error // // tauPt_Stage1_WJetsToLNu_HT1200To2500->Sumw2(kFALSE); //tauPt_Stage1_WJetsToLNu_HT1200To2500->SetBinErrorOption(TH1::kPoisson); tauPt_Stage1_WJetsToLNu_HT1200To2500->Scale(wt_WJetsToLNu_HT1200To2500); std::cout << "WJetsToLNu_HT1200To2500 weighted nevt=" << tauPt_Stage1_WJetsToLNu_HT1200To2500->Integral() << std::endl; totalMC += tauPt_Stage1_WJetsToLNu_HT1200To2500->Integral(); // tauPt_Stage1_WJetsToLNu_HT1200To2500->Scale(kfact_WJetsToLNu_HT1200To2500); //std::cout << tauPt_Stage1_WJetsToLNu_HT1200To2500->GetBinError(300) << std::endl; //file_WJetsToLNu_HT2500ToInf TH1D* h1_evt_WJetsToLNu_HT2500ToInf = (TH1D*)file_WJetsToLNu_HT2500ToInf->Get("demo/histoDir/eventCount"); unsigned long long evt_WJetsToLNu_HT2500ToInf = h1_evt_WJetsToLNu_HT2500ToInf->GetEntries(); //Integral(); double wt_WJetsToLNu_HT2500ToInf = (xs_WJetsToLNu_HT2500ToInf*lumi)/evt_WJetsToLNu_HT2500ToInf ; TH1D* tauPt_Stage1_WJetsToLNu_HT2500ToInf = (TH1D*)file_WJetsToLNu_HT2500ToInf->Get("demo/histoDir/tauPt_Stage1"); // Poisson error // //tauPt_Stage1_WJetsToLNu_HT2500ToInf->Sumw2(kFALSE); //tauPt_Stage1_WJetsToLNu_HT2500ToInf->SetBinErrorOption(TH1::kPoisson); tauPt_Stage1_WJetsToLNu_HT2500ToInf->Scale(wt_WJetsToLNu_HT2500ToInf); std::cout << "WJetsToLNu_HT2500ToInf weighted nevt=" << tauPt_Stage1_WJetsToLNu_HT2500ToInf->Integral() << std::endl; totalMC += tauPt_Stage1_WJetsToLNu_HT2500ToInf->Integral(); //tauPt_Stage1_WJetsToLNu_HT2500ToInf->Scale(kfact_WJetsToLNu_HT2500ToInf); ///std::cout << tauPt_Stage1_WJetsToLNu_HT2500ToInf->GetBinError(300) << std::endl; //file_WToTauNu_M100 TH1D* h1_evt_WToTauNu_M100 = (TH1D*)file_WToTauNu_M100->Get("demo/histoDir/eventCount"); unsigned long long evt_WToTauNu_M100 = h1_evt_WToTauNu_M100->GetEntries(); //Integral(); double wt_WToTauNu_M100 = (xs_WToTauNu_M100*lumi)/evt_WToTauNu_M100 ; TH1D* tauPt_Stage1_WToTauNu_M100 = (TH1D*)file_WToTauNu_M100->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_WToTauNu_M100->Scale(wt_WToTauNu_M100); std::cout << "WToTauNu_M100 weighted nevt=" << tauPt_Stage1_WToTauNu_M100->Integral() << std::endl; totalMC += tauPt_Stage1_WToTauNu_M100->Integral() ; //file_WToTauNu_M200 TH1D* h1_evt_WToTauNu_M200 = (TH1D*)file_WToTauNu_M200->Get("demo/histoDir/eventCount"); unsigned long long evt_WToTauNu_M200 = h1_evt_WToTauNu_M200->GetEntries(); //Integral(); double wt_WToTauNu_M200 = (xs_WToTauNu_M200*lumi)/evt_WToTauNu_M200 ; TH1D* tauPt_Stage1_WToTauNu_M200 = (TH1D*)file_WToTauNu_M200->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_WToTauNu_M200->Scale(wt_WToTauNu_M200); std::cout << "WToTauNu_M200 weighted nevt=" << tauPt_Stage1_WToTauNu_M200->Integral() << std::endl; totalMC += tauPt_Stage1_WToTauNu_M200->Integral(); //file_WToTauNu_M500 TH1D* h1_evt_WToTauNu_M500 = (TH1D*)file_WToTauNu_M500->Get("demo/histoDir/eventCount"); unsigned long long evt_WToTauNu_M500 = h1_evt_WToTauNu_M500->GetEntries(); //Integral(); double wt_WToTauNu_M500 = (xs_WToTauNu_M500*lumi)/evt_WToTauNu_M500 ; TH1D* tauPt_Stage1_WToTauNu_M500 = (TH1D*)file_WToTauNu_M500->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_WToTauNu_M500->Scale(wt_WToTauNu_M500); std::cout << "WToTauNu_M500 weighted nevt=" << tauPt_Stage1_WToTauNu_M500->Integral() << std::endl; totalMC += tauPt_Stage1_WToTauNu_M500->Integral() ; //file_WToTauNu_M1000 TH1D* h1_evt_WToTauNu_M1000 = (TH1D*)file_WToTauNu_M1000->Get("demo/histoDir/eventCount"); unsigned long long evt_WToTauNu_M1000 = h1_evt_WToTauNu_M1000->GetEntries(); //Integral(); double wt_WToTauNu_M1000 = (xs_WToTauNu_M1000*lumi)/evt_WToTauNu_M1000 ; TH1D* tauPt_Stage1_WToTauNu_M1000 = (TH1D*)file_WToTauNu_M1000->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_WToTauNu_M1000->Scale(wt_WToTauNu_M1000); std::cout << "WToTauNu_M1000 weighted nevt=" << tauPt_Stage1_WToTauNu_M1000->Integral() << std::endl; totalMC += tauPt_Stage1_WToTauNu_M1000->Integral(); //file_WToTauNu_M2000 TH1D* h1_evt_WToTauNu_M2000 = (TH1D*)file_WToTauNu_M2000->Get("demo/histoDir/eventCount"); unsigned long long evt_WToTauNu_M2000 = h1_evt_WToTauNu_M2000->GetEntries(); //Integral(); double wt_WToTauNu_M2000 = (xs_WToTauNu_M2000*lumi)/evt_WToTauNu_M2000 ; TH1D* tauPt_Stage1_WToTauNu_M2000 = (TH1D*)file_WToTauNu_M2000->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_WToTauNu_M2000->Scale(wt_WToTauNu_M2000); std::cout << "WToTauNu_M2000 weighted nevt=" << tauPt_Stage1_WToTauNu_M2000->Integral() << std::endl; totalMC += tauPt_Stage1_WToTauNu_M2000->Integral(); //file_WToTauNu_M3000 TH1D* h1_evt_WToTauNu_M3000 = (TH1D*)file_WToTauNu_M3000->Get("demo/histoDir/eventCount"); unsigned long long evt_WToTauNu_M3000 = h1_evt_WToTauNu_M3000->GetEntries(); //Integral(); double wt_WToTauNu_M3000 = (xs_WToTauNu_M3000*lumi)/evt_WToTauNu_M3000 ; TH1D* tauPt_Stage1_WToTauNu_M3000 = (TH1D*)file_WToTauNu_M3000->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_WToTauNu_M3000->Scale(wt_WToTauNu_M3000); std::cout << "WToTauNu_M3000 weighted nevt=" << tauPt_Stage1_WToTauNu_M3000->Integral() << std::endl; totalMC += tauPt_Stage1_WToTauNu_M3000->Integral(); //file_WToTauNu_M4000 TH1D* h1_evt_WToTauNu_M4000 = (TH1D*)file_WToTauNu_M4000->Get("demo/histoDir/eventCount"); unsigned long long evt_WToTauNu_M4000 = h1_evt_WToTauNu_M4000->GetEntries(); //Integral(); double wt_WToTauNu_M4000 = (xs_WToTauNu_M4000*lumi)/evt_WToTauNu_M4000 ; TH1D* tauPt_Stage1_WToTauNu_M4000 = (TH1D*)file_WToTauNu_M4000->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_WToTauNu_M4000->Scale(wt_WToTauNu_M4000); std::cout << "WToTauNu_M4000 weighted nevt=" << tauPt_Stage1_WToTauNu_M4000->Integral() << std::endl; totalMC += tauPt_Stage1_WToTauNu_M4000->Integral(); //file_WToTauNu_M5000 TH1D* h1_evt_WToTauNu_M5000 = (TH1D*)file_WToTauNu_M5000->Get("demo/histoDir/eventCount"); unsigned long long evt_WToTauNu_M5000 = h1_evt_WToTauNu_M5000->GetEntries(); //Integral(); double wt_WToTauNu_M5000 = (xs_WToTauNu_M5000*lumi)/evt_WToTauNu_M5000 ; TH1D* tauPt_Stage1_WToTauNu_M5000 = (TH1D*)file_WToTauNu_M5000->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_WToTauNu_M5000->Scale(wt_WToTauNu_M5000); std::cout << "WToTauNu_M5000 weighted nevt=" << tauPt_Stage1_WToTauNu_M5000->Integral() << std::endl; totalMC += tauPt_Stage1_WToTauNu_M5000->Integral(); //file_WToTauNu_M6000 TH1D* h1_evt_WToTauNu_M6000 = (TH1D*)file_WToTauNu_M6000->Get("demo/histoDir/eventCount"); unsigned long long evt_WToTauNu_M6000 = h1_evt_WToTauNu_M6000->GetEntries(); //Integral(); double wt_WToTauNu_M6000 = (xs_WToTauNu_M6000*lumi)/evt_WToTauNu_M6000 ; TH1D* tauPt_Stage1_WToTauNu_M6000 = (TH1D*)file_WToTauNu_M6000->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_WToTauNu_M6000->Scale(wt_WToTauNu_M6000); std::cout << "WToTauNu_M6000 weighted nevt=" << tauPt_Stage1_WToTauNu_M6000->Integral() << std::endl; totalMC += tauPt_Stage1_WToTauNu_M6000->Integral(); //file_WJetsToLNu TH1D* h1_evt_WJetsToLNu = (TH1D*)file_WJetsToLNu->Get("demo/histoDir/eventCount"); unsigned long long evt_WJetsToLNu = h1_evt_WJetsToLNu->GetEntries(); //Integral(); double wt_WJetsToLNu = (xs_WJetsToLNu*lumi)/evt_WJetsToLNu ; TH1D* tauPt_Stage1_WJetsToLNu = (TH1D*)file_WJetsToLNu->Get("demo/histoDir/tauPt_Stage1"); tauPt_Stage1_WJetsToLNu->Scale(wt_WJetsToLNu); std::cout << "WJetsToLNu weighted nevt=" << tauPt_Stage1_WJetsToLNu->Integral() << std::endl; totalMC += tauPt_Stage1_WJetsToLNu->Integral(); TH1D* total_WJets = (TH1D*)tauPt_Stage1_WJetsToLNu_HT100To200->Clone(); total_WJets->Add(tauPt_Stage1_WJetsToLNu_HT200To400); total_WJets->Add(tauPt_Stage1_WJetsToLNu_HT400To600); total_WJets->Add(tauPt_Stage1_WJetsToLNu_HT600To800); total_WJets->Add(tauPt_Stage1_WJetsToLNu_HT800To1200); total_WJets->Add(tauPt_Stage1_WJetsToLNu_HT1200To2500); total_WJets->Add(tauPt_Stage1_WJetsToLNu_HT2500ToInf); total_WJets->Add(tauPt_Stage1_WToTauNu_M100); total_WJets->Add(tauPt_Stage1_WToTauNu_M200); total_WJets->Add(tauPt_Stage1_WToTauNu_M500); total_WJets->Add(tauPt_Stage1_WToTauNu_M1000); total_WJets->Add(tauPt_Stage1_WToTauNu_M2000); total_WJets->Add(tauPt_Stage1_WToTauNu_M3000); total_WJets->Add(tauPt_Stage1_WToTauNu_M4000); total_WJets->Add(tauPt_Stage1_WToTauNu_M5000); total_WJets->Add(tauPt_Stage1_WToTauNu_M6000); total_WJets->Add(tauPt_Stage1_WJetsToLNu); total_WJets->SetFillColorAlpha(kGreen-8,0.5); total_WJets->SetLineColor(kBlack); //std::cout << "Wjets " << total_WJets->GetBinError(300) << std::endl; total_WJets->Rebin(10); //file_WW TH1D* h1_evt_WW = (TH1D*)file_WW->Get("demo/histoDir/eventCount"); unsigned long long evt_WW = h1_evt_WW->GetEntries(); //Integral(); double wt_WW = (xs_WW*lumi)/evt_WW ; TH1D* tauPt_Stage1_WW = (TH1D*)file_WW->Get("demo/histoDir/tauPt_Stage1"); // Poisson error // //tauPt_Stage1_WW->Sumw2(kFALSE); //tauPt_Stage1_WW->SetBinErrorOption(TH1::kPoisson); tauPt_Stage1_WW->Scale(wt_WW); std::cout << "WW weighted nevt=" << tauPt_Stage1_WW->Integral() << std::endl; totalMC +=tauPt_Stage1_WW->Integral() ; //file_WZ TH1D* h1_evt_WZ = (TH1D*)file_WZ->Get("demo/histoDir/eventCount"); unsigned long long evt_WZ = h1_evt_WZ->GetEntries(); //Integral(); double wt_WZ = (xs_WZ*lumi)/evt_WZ ; TH1D* tauPt_Stage1_WZ = (TH1D*)file_WZ->Get("demo/histoDir/tauPt_Stage1"); // Poisson error // //tauPt_Stage1_WZ->Sumw2(kFALSE); // tauPt_Stage1_WZ->SetBinErrorOption(TH1::kPoisson); tauPt_Stage1_WZ->Scale(wt_WZ); tauPt_Stage1_WZ->Scale(kfact_WZ); std::cout << "WZ weighted nevt=" << tauPt_Stage1_WZ->Integral() << std::endl; totalMC += tauPt_Stage1_WZ->Integral(); //file_ZZ TH1D* h1_evt_ZZ = (TH1D*)file_ZZ->Get("demo/histoDir/eventCount"); unsigned long long evt_ZZ = h1_evt_ZZ->GetEntries(); //Integral(); double wt_ZZ = (xs_ZZ*lumi)/evt_ZZ ; TH1D* tauPt_Stage1_ZZ = (TH1D*)file_ZZ->Get("demo/histoDir/tauPt_Stage1"); // Poisson error // //tauPt_Stage1_ZZ->Sumw2(kFALSE); //tauPt_Stage1_ZZ->SetBinErrorOption(TH1::kPoisson); tauPt_Stage1_ZZ->Scale(wt_ZZ); tauPt_Stage1_ZZ->Scale(kfact_ZZ); std::cout << "ZZ weighted nevt=" << tauPt_Stage1_ZZ->Integral() << std::endl; totalMC += tauPt_Stage1_ZZ->Integral(); TH1D* total_diboson = (TH1D*)tauPt_Stage1_WW->Clone(); total_diboson->Add(tauPt_Stage1_WZ); total_diboson->Add(tauPt_Stage1_ZZ); total_diboson->SetFillColorAlpha(kOrange+2,0.5); total_diboson->SetLineColor(kBlack); total_diboson->Rebin(10); //datadriven // double wt_Datadriven = (lumi/33.507) ; TH1D* total_QCD = (TH1D*)file_Datadriven->Get("demo/histoDir/tauPt_Stage1"); total_QCD->SetFillStyle(3001); total_QCD->SetFillColor(kPink+1); total_QCD->SetLineColor(kBlack); total_QCD->Rebin(10); //datadriven std::cout << "totalMC(w/o DD) =" << totalMC << std::endl; std::cout << "will do data" << std::endl; //--Data--// TH1D* tauPt_Stage1_Run2016F = (TH1D*)file_Tau_Run2016F->Get("demo/histoDir/tauPt_Stage1"); TH1D* tauPt_Stage1_Run2016E = (TH1D*)file_Tau_Run2016E->Get("demo/histoDir/tauPt_Stage1"); TH1D* tauPt_Stage1_Run2016D = (TH1D*)file_Tau_Run2016D->Get("demo/histoDir/tauPt_Stage1"); TH1D* tauPt_Stage1_Run2016C = (TH1D*)file_Tau_Run2016C->Get("demo/histoDir/tauPt_Stage1"); TH1D* tauPt_Stage1_Run2016B = (TH1D*)file_Tau_Run2016B->Get("demo/histoDir/tauPt_Stage1"); TH1D* tauPt_Stage1_Run2016G = (TH1D*)file_Tau_Run2016G->Get("demo/histoDir/tauPt_Stage1"); TH1D* tauPt_Stage1_Run2016H_v2 = (TH1D*)file_Tau_Run2016H_v2->Get("demo/histoDir/tauPt_Stage1"); TH1D* tauPt_Stage1_Run2016H_v3 = (TH1D*)file_Tau_Run2016H_v3->Get("demo/histoDir/tauPt_Stage1"); /* std::cout << "Will Clone B" << std::endl; TH1D* tauPt_Stage1_Run2016BCD = (TH1D*)tauPt_Stage1_Run2016B->Clone(); std::cout << "Will add C" << std::endl; tauPt_Stage1_Run2016BCD->Add(tauPt_Stage1_Run2016C); std::cout << "Will add D" << std::endl; tauPt_Stage1_Run2016BCD->Add(tauPt_Stage1_Run2016D); // std::cout << "Will add E" << std::endl; // tauPt_Stage1_Run2016BCDEF->Add(tauPt_Stage1_Run2016E); // std::cout << "Will add F" << std::endl; // tauPt_Stage1_Run2016BCDEF->Add(tauPt_Stage1_Run2016F); */ TH1D* tauPt_Stage1_Run2016all = (TH1D*)tauPt_Stage1_Run2016B->Clone(); tauPt_Stage1_Run2016all->Add(tauPt_Stage1_Run2016C); tauPt_Stage1_Run2016all->Add(tauPt_Stage1_Run2016D); tauPt_Stage1_Run2016all->Add(tauPt_Stage1_Run2016E); tauPt_Stage1_Run2016all->Add(tauPt_Stage1_Run2016F); tauPt_Stage1_Run2016all->Add(tauPt_Stage1_Run2016G); tauPt_Stage1_Run2016all->Add(tauPt_Stage1_Run2016H_v2); tauPt_Stage1_Run2016all->Add(tauPt_Stage1_Run2016H_v3); tauPt_Stage1_Run2016all->SetMarkerStyle(20); tauPt_Stage1_Run2016all->SetMarkerColor(kBlack); tauPt_Stage1_Run2016all->SetLineColor(kBlack); tauPt_Stage1_Run2016all->Rebin(10); std::cout << "will do signal " << std::endl; //--Signal--// TH1D* h1_evt_Wprime_M4000 = (TH1D*)file_Wprime_M4000->Get("demo/histoDir/eventCount"); unsigned long long evt_Wprime_M4000 = h1_evt_Wprime_M4000->GetEntries(); //Integral(); // std::cout << "evt_Wprime_M4000 = " << evt_Wprime_M4000 << std::endl; double wt_Wprime_M4000 = (xs_Wprime_M4000*lumi)/evt_Wprime_M4000 ; TH1D* tauPt_Stage1_Wprime_M4000 = (TH1D*)file_Wprime_M4000->Get("demo/histoDir/tauPt_Stage1"); std::cout << "Sig Eff W' M4000 : " << ( tauPt_Stage1_Wprime_M4000->GetEntries() / evt_Wprime_M4000 ) << std::endl; tauPt_Stage1_Wprime_M4000->Scale(wt_Wprime_M4000); // tauPt_Stage1_Wprime_M4000->SetFillColorAlpha(kGreen-7,0.5); tauPt_Stage1_Wprime_M4000->SetLineColor(kMagenta); tauPt_Stage1_Wprime_M4000->SetLineWidth(2); tauPt_Stage1_Wprime_M4000->SetLineStyle(5); tauPt_Stage1_Wprime_M4000->Rebin(10) ; //--Plotting Styles// gStyle->SetPadLeftMargin(0.15); gStyle->SetPadRightMargin(0.05); gStyle->SetPadBottomMargin(0.12); gStyle->SetPadTopMargin(0.05); gStyle->SetTitleXSize(0.05); gStyle->SetTitleXOffset(1.05); gStyle->SetTitleYSize(0.05); gStyle->SetTitleYOffset(1.05); //////// Output File ///////// TFile* outputFile = new TFile("Out_tauPt_Stage1.root","RECREATE"); outputFile->cd(); //--// THStack *hs = new THStack("hs",""); // hs->Add(tauPt_Stage1_WJetsToLNu); hs->Add(total_diboson); hs->Add(total_DY); hs->Add(total_ST); hs->Add(total_TT); // hs->Add(tauPt_Stage1_DYJetsToLL_M50); hs->Add(total_QCD); // hs->Add(total_ZJets); hs->Add(total_WJets); //tauPt_Stage1_->SetTitle(""); /* eff1->GetYaxis()->SetTitle("Events"); //eff1->SetMarkerStyle(0); //eff1->SetMarkerColor(kBlack); eff1->SetLineColor(kBlack); eff1->SetLineWidth(2); */ TCanvas* my_canvas = new TCanvas("canvas","canvas",800,600); my_canvas->cd(); // hs->Draw(); gPad->SetLogy(); hs->Draw("HIST"); hs->SetMaximum(100000); hs->SetMinimum(0.1); hs->GetXaxis()->SetRangeUser(0, 1000); // hs->GetXaxis()->SetLimits(40, 3200); hs->GetXaxis()->SetTitle("#tau pT [GeV]"); hs->GetYaxis()->SetTitle("Events"); TH1F* total = (TH1F*)hs->GetStack()->Last()->Clone(); // total->SetFillStyle(3004); // total->SetFillColor(kGray+1); // total->SetMarkerColor(0); // total->Draw("SAME E2"); //hs->GetStack()->Last()->Draw("same E"); // hs->Draw("SAME HIST"); // tauPt_Stage1_Run2016E->Draw("SAME E0"); tauPt_Stage1_Run2016all->Draw("SAME E0"); TH1F* mydata = (TH1F*)tauPt_Stage1_Run2016all->Clone(); //tauPt_Stage1_Run2016C->Draw("SAME E0"); //tauPt_Stage1_Run2016CDE->Draw("SAME E0"); // tauPt_Stage1_Wprime_M4000->Draw("SAME HIST"); // hs->SetOption("HIST L"); TLatex* CMS_text = new TLatex(0.20,0.90,"CMS"); CMS_text->SetNDC(); CMS_text->SetTextSize(0.05); CMS_text->SetTextAngle(0); CMS_text->Draw("same"); TLatex* CMS_text_2 = new TLatex(0.20,0.85,"Preliminary"); CMS_text_2->SetNDC(); CMS_text_2->SetTextFont(42); CMS_text_2->SetTextSize(0.05); CMS_text_2->SetTextAngle(0); CMS_text_2->Draw("same"); TLatex* lumiText = new TLatex(0.92,0.975,"35.9 fb^{-1} (13 TeV)"); lumiText->SetNDC(); lumiText->SetTextFont(42); lumiText->SetTextSize(0.04); lumiText->SetTextAlign(32); lumiText->Draw("same"); TLegend *leg_example = new TLegend(0.75,0.50,0.94,0.94); leg_example->SetFillColor(0); leg_example->SetTextFont(42); leg_example->SetBorderSize(0); leg_example->AddEntry(total_WJets, "Wjets","f"); leg_example->AddEntry(total_DY, "DY","f"); leg_example->AddEntry(total_TT, "TT","f"); //leg_example->AddEntry(tauPt_Stage1_WJetsToLNu, "Wjets","f"); leg_example->AddEntry(total_ST, "Single Top", "f"); leg_example->AddEntry(total_diboson, "Diboson", "f"); leg_example->AddEntry(total_QCD, "QCD datadriven", "f"); // leg_example->AddEntry(total_ZJets, "Z", "f"); leg_example->AddEntry(tauPt_Stage1_Wprime_M4000, "SSM W' 4 TeV", "l"); leg_example->AddEntry(tauPt_Stage1_Run2016all, "Data", "pl" ); // leg_example->AddEntry(tauPt_Stage1_Run2016E, "Data", "pl" ); // leg_example->AddEntry(tauPt_Stage1_Run2016D, "Data", "pl" ); leg_example->Draw("same"); my_canvas->Write(); my_canvas->Print("tauPt_Stage1_DD.pdf"); /* TCanvas* my_canvas2 = new TCanvas("canvas2","canvas2"); my_canvas2->cd(); gPad->SetLogy(); total->SetMaximum(1000); total->SetMarkerStyle(20); total->Draw("E"); my_canvas2->Write(); */ TCanvas* ratio_c = new TCanvas("ratio","ratio_canvas",800,700); ratio_c->SetTopMargin(0.); ratio_c->SetBottomMargin(0.); ratio_c->Update(); ratio_c->Divide(1, 2); ratio_c->cd(1); gPad->SetPad(.005, .30, .995, .995); TPad* pad1 = (TPad*)ratio_c->GetPad(1); pad1->SetTopMargin(0.05); pad1->SetBottomMargin(0.05); ratio_c->Update(); gPad->SetLogy(); hs->Draw("HIST"); hs->SetMaximum(100000); hs->SetMinimum(0.01); // hs->GetXaxis()->SetLimits(40, 3200); hs->GetXaxis()->SetRangeUser(0, 1000); hs->GetXaxis()->SetTitle(""); // total->Draw("SAME E2"); mydata->Draw("SAME E1"); tauPt_Stage1_Wprime_M4000->Draw("SAME HIST"); CMS_text->Draw("same"); CMS_text_2->Draw("same"); lumiText->Draw("same"); leg_example->Draw("same"); ratio_c->cd(2); gPad->SetPad(.005, .08, .995, .28); gStyle->SetOptStat(false); ratio_c->Update(); TPad* pad2 = (TPad*)ratio_c->GetPad(2); pad2->SetTopMargin(0.04); pad2->SetBottomMargin(0.30); pad2->SetGridx(); pad2->SetGridy(); std::cout << "data bins = " << mydata->GetNbinsX() << " width=" << mydata->GetBinWidth(2); std::cout << " MC bins = " << total->GetNbinsX() << " width=" << total->GetBinWidth(2) << std::endl; int nbin=mydata->GetNbinsX() ; float width=mydata->GetBinWidth(2); TH1F *data_by_MC = new TH1F("h1", "ratio", nbin, 0, 4000); std::cout << "before D/MC bins=" << data_by_MC->GetNbinsX() << " width=" << data_by_MC->GetBinWidth(2) << std::endl; for (int i=0; i<nbin; i++) { float data = mydata->GetBinContent(i); float MC = total->GetBinContent(i); float ratio=0; if (MC>0) ratio=data/MC ; data_by_MC->SetBinContent(i,ratio); if (data>0) { float stat_err = sqrt(data)/data ; data_by_MC->SetBinError(i,stat_err); } // data_by_MC->SetBinWidth(i,width); } // TH1F* data_by_MC = (TH1F*)mydata->Clone(); // data_by_MC->Divide(total); data_by_MC->SetMarkerStyle(20); data_by_MC->Draw("E"); data_by_MC->GetXaxis()->SetTitle("#tau pT [GeV]"); data_by_MC->GetYaxis()->SetTitle("#frac{DATA}{MC}"); data_by_MC->GetYaxis()->SetLabelSize(0.12); data_by_MC->GetXaxis()->SetLabelSize(0.12); data_by_MC->GetYaxis()->SetTitleSize(0.18); data_by_MC->GetXaxis()->SetTitleSize(0.18); data_by_MC->GetYaxis()->SetTitleOffset(0.20); data_by_MC->GetXaxis()->SetTitleOffset(0.75); data_by_MC->SetTitle(""); data_by_MC->GetXaxis()->SetRangeUser(0, 1000); data_by_MC->SetMaximum(4); data_by_MC->SetMinimum(0); data_by_MC->GetYaxis()->SetNdivisions(4); TLine *l=new TLine(0,1,1000,1); l->SetLineColor(kRed); l->Draw("same"); std::cout << "D/MC bins=" << data_by_MC->GetNbinsX() << " width=" << data_by_MC->GetBinWidth(2) << std::endl; ratio_c->Write(); ratio_c->Print("tauPt_Stage1_ratio_DD.pdf"); return 0; }
int shape() { vector<variable> vvariable; variable LepPt("LepPt","LepPt",20,0,35,"p_{T} (l) [GeV]"); variable LepEta("LepEta","LepEta",20,-3,3,"#eta (l)"); variable Njet("Njet","Njet",11,-0.5,10.5,"Njet"); variable Jet1Pt("Jet1Pt","Jet1Pt",20,100,500,"p_{T} (Jet1) [GeV]"); variable Jet1Eta("Jet1Eta","Jet1Eta",20,-3,3,"Eta (Jet1)"); variable Met("Met","Met",20,300,600,"Met [GeV]",1); variable CosDPhi("CosDeltaPhi","CosDeltaPhi",20,-1.2,1.2,"Cos(#Delta #Phi)"); variable DrJet1Lep("DrJet1Lep","DrJet1Lep",10,0,6,"Dr Jet1 Lep"); variable DrJet2Lep("DrJet2Lep","DrJet2Lep",10,0,6,"Dr Jet2 Lep"); variable Jet2Pt("Jet2Pt","Jet2Pt",20,0,400,"p_{T} (Jet2) [GeV]",1); variable mt("mt","mt",15,0,150,"mt [GeV]"); variable HT20("HT20","HT20",20,0,1400,"HT20 [GeV]"); variable HT30("HT30","HT30",20,0,1400,"HT30 [GeV]"); variable Q80("Q80","Q80",20,-2,1,"Q80 [GeV]"); variable JetLepMass("JetLepMass","JetLepMass",20,0,250,"M_{Jet+Lep}"); variable JetHBPt("JetHBpt","JetHBpt",20,0,200,"p_{T} (JetHB)"); // vvariable.push_back(LepPt); // vvariable.push_back(LepEta); // vvariable.push_back(Njet); // vvariable.push_back(Jet1Pt); // vvariable.push_back(Jet2Pt); // vvariable.push_back(Jet1Eta); vvariable.push_back(Met); vvariable.push_back(CosDPhi); // vvariable.push_back(DrJet1Lep); // vvariable.push_back(DrJet2Lep); vvariable.push_back(mt); // vvariable.push_back(HT20); vvariable.push_back(Q80); // vvariable.push_back(HT30); // vvariable.push_back(JetLepMass); // vvariable.push_back(JetHBPt); // Open input file(s) string basedirectory = "/lstore/cms/cbeiraod/Stop4Body/LepFix/"; TFile* ttbarFile = new TFile((basedirectory + "TTJets_LO_bdt.root").c_str(), "READ"); TFile* stopFile = new TFile((basedirectory + "T2DegStop_300_270_bdt.root").c_str(), "READ"); TChain* wjetsTree = new TChain("bdttree"); //creates a chain to process a Tree called "bdttree" wjetsTree->Add((basedirectory + "Wjets_100to200_bdt.root").c_str()); wjetsTree->Add((basedirectory + "Wjets_200to400_bdt.root").c_str()); wjetsTree->Add((basedirectory + "Wjets_400to600_bdt.root").c_str()); wjetsTree->Add((basedirectory + "Wjets_600toInf_bdt.root").c_str()); // Get ttree(s) from input file(s) TTree* ttbarTree = static_cast<TTree*>(ttbarFile->Get("bdttree")); TTree* stopTree = static_cast<TTree*>(stopFile->Get("bdttree")); // Create canvas TCanvas * c1 = new TCanvas("Stop","Stop", 800, 600); if(vvariable.size()!=1) { if(vvariable.size()==2) c1->Divide(2,1); else { if(vvariable.size()%2==0) c1->Divide(vvariable.size()/2,2); else c1->Divide((vvariable.size()+1)/2,2); } } vector<TH1D*> ttbarH; vector<TH1D*> wjetsH; vector<TH1D*> stopH; vector<TH1D*> backgroundH; // Plots for(int i=0;i<int(vvariable.size());i++) { TCanvas * c2 = new TCanvas("variable","variable", 800, 600); string sttbarH = "ttbarH"+std::to_string(i); string swjetsH = "wjetsH"+std::to_string(i); string sstopH = "stopH"+std::to_string(i); string sbackgroundH = "background"+std::to_string(i); // Create histogram(s) ttbarH.push_back(new TH1D(sttbarH.c_str(), "ttbar", vvariable[i].GetBins(), vvariable[i].GetXMin(), vvariable[i].GetXMax())); wjetsH.push_back(new TH1D(swjetsH.c_str(), "wjets", vvariable[i].GetBins(), vvariable[i].GetXMin(), vvariable[i].GetXMax())); stopH.push_back(new TH1D(sstopH.c_str(), "Signal", vvariable[i].GetBins(), vvariable[i].GetXMin(), vvariable[i].GetXMax())); backgroundH.push_back(new TH1D(sbackgroundH.c_str(), "Background", vvariable[i].GetBins(), vvariable[i].GetXMin(), vvariable[i].GetXMax())); ttbarH[i]->SetFillColor(kGreen-7); ttbarH[i]->SetLineColor(kGreen-7); wjetsH[i]->SetFillColor(kAzure+5); wjetsH[i]->SetLineColor(kAzure+5); //stopH->SetFillColor(kRed); stopH[i]->SetLineColor(kRed); if(vvariable.size()!=1) c1->cd(i+1); else c1->cd(); //Create TCuts TCut muon = "(abs(LepID)==13)&&(LepIso03<0.2)"; TCut electron = "(abs(LepID)==11)&&(LepIso03<0.2)"; TCut emu = muon||electron; TCut ISRjet = "Jet1Pt > 110"; TCut met = "Met > 300"; TCut jetLepMass = "JetLepMass < 100"; //TCut njets = "Njet > 1"; TCut lepPt = "LepPt < 17"; //TCut ht30 = "HT30 > 300"; //TCut ht20 = "HT20 > 450"; //TCut mt = "mt < 70"; TCut jethbpt = "JetHBpt < 80"; TCut selection = emu && ISRjet && met; // Fill histogram(s) signal & BACKGROUND & DATA ttbarTree->Draw((vvariable[i].GetExpression()+">>"+sttbarH).c_str(),"XS*5000/Nevt"*(selection),"goff"); wjetsTree->Draw((vvariable[i].GetExpression()+">>"+swjetsH).c_str(),"XS*5000/Nevt"*(selection),"goff"); stopTree->Draw((vvariable[i].GetExpression()+">>"+sstopH).c_str(),"XS*5000/Nevt"*(selection),"goff"); //MULTIPLICAR O SINAL // Normalize double BGIntegral = ttbarH[i]->Integral(0,ttbarH[i]->GetNbinsX()+2) + wjetsH[i]->Integral(0,wjetsH[i]->GetNbinsX()+2); double stopIntegral = stopH[i]->Integral(0,stopH[i]->GetNbinsX()+2); for(int j=0; j < stopH[i]->GetNbinsX()+2; j++) { stopH[i]->SetBinContent(j, stopH[i]->GetBinContent(j)/stopIntegral); ttbarH[i]->SetBinContent(j, ttbarH[i]->GetBinContent(j)/BGIntegral); wjetsH[i]->SetBinContent(j, wjetsH[i]->GetBinContent(j)/BGIntegral); } THStack *Stack = new THStack(vvariable[i].GetName().c_str(), (vvariable[i].GetName()+";"+vvariable[i].GetLeg().c_str()+";AU").c_str()); Stack->Add(ttbarH[i]); Stack->Add(wjetsH[i]); gPad->SetLogy(vvariable[i].GetLogy()); // Draw plots gStyle->SetOptStat(0); Stack->Draw("HIST"); stopH[i]->Draw("HIST same"); if(Stack->GetMaximum() > stopH[i]->GetMaximum()) { Stack->SetMaximum(Stack->GetMaximum()*1.05); } else { Stack->SetMaximum(stopH[i]->GetMaximum()*1.05); } //TLegend * legenda = gPad->BuildLegend(0.895,0.69,0.65,0.89,"NDC"); // Draw in Canvas c2 - Pad1 c2->cd(); gPad->SetLogy(vvariable[i].GetLogy()); Stack->Draw("HIST goff"); stopH[i]->Draw("HIST same goff"); //TLegend * legenda2 = gPad->BuildLegend(0.8,0.69,0.65,0.89,"NDC"); // Save individual plots as .pdf and .C //c2->SaveAs(("plots/"+vvariable[i].GetName()+".pdf").c_str()); //c2->SaveAs(("plots/"+vvariable[i].GetName()+".C").c_str()); delete c2; } //delete the vectors //Save file with all the plots c1->SaveAs("plots/shape.png"); c1->SaveAs("plots/shape.C"); return 0; }
//------------------------------------------------------------------------------ // PlotHiggsRes_LP //------------------------------------------------------------------------------ void RunMakeRazorPlots ( string signalfile, string signalLabel, vector<string> bkgfiles,vector<string> bkgLabels, int boxOption = 0, int option = -1, string label = "", string latexlabel = "") { //-------------------------------------------------------------------------------------------------------------- // Settings //============================================================================================================== double intLumi = 2100; //in units of pb^-1 string Label = ""; if (label != "") Label = "_" + label; vector<string> inputfiles; vector<string> processLabels; bool hasSignal = false; if (signalfile != "") { hasSignal = true; inputfiles.push_back(signalfile); processLabels.push_back(signalLabel); } assert(bkgfiles.size() == bkgLabels.size()); for (int i=0; i < bkgfiles.size(); ++i) { inputfiles.push_back(bkgfiles[i]); processLabels.push_back(bkgLabels[i]); } //******************************************************************************************* //Define Histograms //******************************************************************************************* vector<TH1F*> histUnrolled; float MRBinLowEdges[] = {500, 600, 700, 900, 1200, 1600, 2500, 4000}; // Multijet Bins float RsqBinLowEdges[] = {0.25, 0.30, 0.41, 0.52, 0.64, 1.5}; // Multijet Bins const int nMRBins = 7; const int nRsqBins = 5; TH1F* histMRAllBkg = new TH1F( "MRAllBkg",";M_{R} [GeV/c^{2}];Number of Events", nMRBins, MRBinLowEdges); TH1F* histRsqAllBkg = new TH1F( "RsqAllBkg", ";R^{2};Number of Events", nRsqBins, RsqBinLowEdges); histMRAllBkg->SetStats(false); histRsqAllBkg->SetStats(false); histRsqAllBkg->Sumw2(); histMRAllBkg->Sumw2(); TH1F* histMRQCD = new TH1F( "MRQCD",";M_{R} [GeV/c^{2}];Number of Events", nMRBins, MRBinLowEdges); TH1F* histRsqQCD = new TH1F( "RsqQCD", ";R^{2};Number of Events", nRsqBins, RsqBinLowEdges); histMRQCD->SetStats(false); histRsqQCD->SetStats(false); histRsqQCD->Sumw2(); histMRQCD->Sumw2(); TH1F* histMRData = new TH1F( "MRData",";M_{R} [GeV/c^{2}];Number of Events", nMRBins, MRBinLowEdges); TH1F* histRsqData = new TH1F( "RsqData", ";R^{2};Number of Events", nRsqBins, RsqBinLowEdges); vector<TH1F*> histMR; vector<TH1F*> histRsq; vector<TH2F*> histMRRsq; histMRQCD->SetFillColor(kAzure+4); histMRAllBkg->SetFillColor(kMagenta); histMRQCD->SetFillStyle(1001); histMRAllBkg->SetFillStyle(1001); histMRQCD->SetLineColor(kAzure+4); histMRAllBkg->SetLineColor(kMagenta); assert (inputfiles.size() == processLabels.size()); for (int i=0; i < inputfiles.size(); ++i) { histMRRsq.push_back( new TH2F( Form("MRRsq_%s",processLabels[i].c_str()), ";M_{R} [GeV/c^{2}]; R^{2}", nMRBins, MRBinLowEdges, nRsqBins, RsqBinLowEdges)); if (!hasSignal || i != 0) histMRRsq[i]->SetFillColor(color[i]); if (hasSignal && i==0) histMRRsq[i]->SetLineWidth(3); histMRRsq[i]->SetLineColor(color[i]); histMRRsq[i]->SetStats(false); histMRRsq[i]->Sumw2(); histUnrolled.push_back( new TH1F( Form("Unrolled_%s",processLabels[i].c_str()), ";Bin Number ;Number of Events", nMRBins*nRsqBins, 0, nMRBins*nRsqBins)); if (!hasSignal || i != 0) histUnrolled[i]->SetFillColor(color[i]); if (hasSignal && i==0) histUnrolled[i]->SetLineWidth(3); histUnrolled[i]->SetLineColor(color[i]); histUnrolled[i]->SetStats(false); } THStack *stackUnrolled = new THStack(); //******************************************************************************************* //Define Counts //******************************************************************************************* //******************************************************************************************* //Read files //******************************************************************************************* for (uint i=0; i < inputfiles.size(); ++i) { TFile* inputFile = new TFile(inputfiles[i].c_str(),"READ"); assert(inputFile); TTree* tree = 0; tree = (TTree*)inputFile->Get("RazorInclusive"); // if (box == 0) { // tree = (TTree*)inputFile->Get("MultiJet"); // } else if (box == 1) { // tree = (TTree*)inputFile->Get("LooseLeptonMultiJet"); // } else if (box == 2) { // tree = (TTree*)inputFile->Get("MuMultiJet"); // } else if (box == 3) { // tree = (TTree*)inputFile->Get("EleMultiJet"); // } float weight = 0; int box = -1; int nBTaggedJets = 0; float dPhiRazor = 0; float MR = 0; float Rsq = 0; float mT = 0; tree->SetBranchAddress("weight",&weight); tree->SetBranchAddress("box",&box); tree->SetBranchAddress("nBTaggedJets",&nBTaggedJets); tree->SetBranchAddress("dPhiRazor",&dPhiRazor); tree->SetBranchAddress("MR",&MR); tree->SetBranchAddress("Rsq",&Rsq); tree->SetBranchAddress("mT",&mT); cout << "Process : " << processLabels[i] << " : Total Events: " << tree->GetEntries() << "\n"; for (int n=0;n<tree->GetEntries();n++) { // for (int n=0;n<1000;n++) { tree->GetEntry(n); if (n % 1000000 == 0) cout << "Processing Event " << n << "\n"; // if (intLumi*weight > 100) continue; //Box Options if (option == 0 ) { if (nBTaggedJets != 0) continue; } if (option == 1 ) { if (nBTaggedJets != 1) continue; } if (option == 2 ) { if (nBTaggedJets != 2) continue; } if (option == 3 ) { if (nBTaggedJets < 3) continue; } if (option == 4 ) { if (nBTaggedJets < 0) continue; // all b-tag categories combined } if (boxOption == 0) { // Multijet Box for Jamboree if( !(box == 11 || box == 12) ) continue; } if (boxOption == 1) { // LeptonJet Box for Jamboree if( !(box == 3 || box == 4 || box == 6 || box == 7) ) continue; } if (boxOption == 2) { // Multijet Box for Jamboree if( !(box == 14) ) continue; } //apply baseline cuts if (!(MR > 400 && Rsq > 0.25)) continue; // if (!(MR < 500 )) continue; // if (!(Rsq < 0.3)) continue; if (!(fabs(dPhiRazor) > 2.8)) continue; if (!hasSignal || i>1) { histMRAllBkg->Fill(MR, intLumi*weight); histRsqAllBkg->Fill(Rsq, intLumi*weight); histMRRsq[i]->Fill(MR, Rsq, intLumi*weight); } if(i==1){ if (intLumi*weight > 30) continue; float qcdweight = 1.56841; histMRQCD->Fill(MR, intLumi*weight*qcdweight); histRsqQCD->Fill(Rsq, intLumi*weight*qcdweight); histMRRsq[i]->Fill(MR, Rsq, intLumi*weight*qcdweight); } if (hasSignal && i==0) { histMRData->Fill(MR); histRsqData->Fill(Rsq); histMRRsq[i]->Fill(MR, Rsq); } } inputFile->Close(); delete inputFile; } std::cout<<"Data: "<<histMRData->Integral()<<", All Backgrounds: "<<histMRAllBkg->Integral()<<" , QCD: "<<histMRQCD->Integral()<<", Data2 "<< histMRRsq[0]->Integral() <<" QCD2 "<<histMRRsq[1]->Integral() <<std::endl; //******************************************************************************************* //Draw Plots //******************************************************************************************* // fill out the unrolled histograms std::cout<<"Rsq bins: "<<nRsqBins<<" "<<nMRBins<<std::endl; for (uint i=0; i < histMRRsq.size(); ++i) { int binN = 0; for(int ii = 0; ii<nMRBins; ii++) for (int jj = 0; jj<nRsqBins; jj++) { float value = (histMRRsq[i]->GetBinContent(ii+1, jj+1) > 0) ? histMRRsq[i]->GetBinContent(ii+1, jj+1) : 0. ; float Xrange = histMRRsq[i]->GetXaxis()->GetBinLowEdge(jj+2) - histMRRsq[i]->GetXaxis()->GetBinLowEdge(jj+1); float Yrange = histMRRsq[i]->GetYaxis()->GetBinLowEdge(ii+2) - histMRRsq[i]->GetYaxis()->GetBinLowEdge(ii+1); float area =1.; if(density) area = Xrange*Yrange; //normalize each bin by its area histUnrolled[i]->SetBinContent(binN+1, value/area); binN++; } histUnrolled[i]->SetMinimum(0.00001); if ( histUnrolled[i]->Integral() > 0) { if( !hasSignal || i > 0 ) stackUnrolled->Add(histUnrolled[i]); } cout << "Process : " << processLabels[i] << "\n"; } TCanvas *cv = 0; TLegend *legend = 0; TLatex *tex = 0; cv = new TCanvas("cv","cv", 800,600); legend = new TLegend(0.7,0.53,0.90,0.88); legend->SetTextSize(0.03); legend->SetBorderSize(0); legend->SetFillStyle(0); for (Int_t i = histMRRsq.size()-1 ; i >= 0; --i) { if (hasSignal && i==0) { legend->AddEntry(histMRRsq[i],processLabels[i].c_str(), "L"); } else { legend->AddEntry(histMRRsq[i],processLabels[i].c_str(), "F"); } } /// Unrolled plots in bins of R&MR TLatex t1(0.1,0.92, "CMS Preliminary"); TLatex t2(0.6,0.92, "#sqrt{s}=13 TeV, L = 2.1 fb^{-1}"); TLatex t3(0.4,0.92, Form("%s",latexlabel.c_str()) ); t1.SetNDC(); t2.SetNDC(); t3.SetNDC(); t1.SetTextSize(0.05); t2.SetTextSize(0.05); t3.SetTextSize(0.02); t1.SetTextFont(42); t2.SetTextFont(42); t3.SetTextFont(42); stackUnrolled->Draw(); stackUnrolled->SetMinimum(0.01); stackUnrolled->SetMaximum(1000); cv->SetLogy(); stackUnrolled->GetHistogram()->GetXaxis()->SetTitle(((TH1F*)(stackUnrolled->GetHists()->At(0)))->GetXaxis()->GetTitle()); stackUnrolled->GetHistogram()->GetYaxis()->SetTitle(((TH1F*)(stackUnrolled->GetHists()->At(0)))->GetYaxis()->GetTitle()); stackUnrolled->Draw(); if(hasSignal) histUnrolled[0]->Draw("same PE"); legend->Draw(); t1.Draw(); t2.Draw(); t3.Draw(); cv->SaveAs(Form("Unrolled_QCD%s.root",Label.c_str())); //// //******************************************************************************************* //MR //******************************************************************************************* cv = new TCanvas("cv","cv", 800,600); legend = new TLegend(0.50,0.54,0.90,0.84); legend->SetTextSize(0.03); legend->SetBorderSize(0); legend->SetFillStyle(0); tex = new TLatex(); tex->SetNDC(); tex->SetTextSize(0.030); tex->SetTextFont(42); tex->SetTextColor(kBlack); tex->DrawLatex(0.2, 0.92, Form("CMS Simulation #sqrt{s} = 13 TeV, #int L = %d fb^{-1}, %s",int(intLumi/1000), latexlabel.c_str())); THStack *stackMR = new THStack("stackMR", ""); THStack *stackRsq = new THStack(); //******************************************************************************************* //MR Before and After DPhi Cut //******************************************************************************************* ////////////////// stackMR->Add(histMRAllBkg); stackMR->Add(histMRQCD); cv = new TCanvas("cv","cv", 800,600); legend = new TLegend(0.50,0.54,0.90,0.84); legend->SetTextSize(0.03); legend->SetBorderSize(0); legend->SetFillStyle(0); stackMR->Draw(); stackMR->GetHistogram()->GetXaxis()->SetTitle(((TH1F*)(stackMR->GetHists()->At(0)))->GetXaxis()->GetTitle()); stackMR->GetHistogram()->GetYaxis()->SetTitle(((TH1F*)(stackMR->GetHists()->At(0)))->GetYaxis()->GetTitle()); stackMR->Draw(""); histMRData->Draw("same PE"); legend->Draw(); cv->SetLogy(); cv->SaveAs(Form("MRStack_QCD_%s.pdf",Label.c_str())); /////////////////////// cv = new TCanvas("cv","cv", 800,600); legend = new TLegend(0.50,0.54,0.90,0.84); legend->SetTextSize(0.03); legend->SetBorderSize(0); legend->SetFillStyle(0); histMRAllBkg->SetLineColor(kRed); histMRAllBkg->GetYaxis()->SetTitle("Number of Events"); histMRAllBkg->GetYaxis()->SetTitleOffset(1.2); histMRData->SetMarkerStyle(8); legend->AddEntry(histMRAllBkg, "All Backgrounds", "L"); legend->AddEntry(histMRData, "Data", "L"); histMRAllBkg->Add(histMRQCD, 1.0); histMRAllBkg->Draw("hist"); histMRData->Draw("PE same"); legend->Draw(); cv->SetLogy(); cv->SaveAs(Form("MR_QCD_%s.pdf",Label.c_str())); ////// cv = new TCanvas("cv","cv", 800,600); legend = new TLegend(0.50,0.54,0.90,0.84); legend->SetTextSize(0.03); legend->SetBorderSize(0); legend->SetFillStyle(0); histRsqAllBkg->SetLineColor(kRed); histRsqAllBkg->GetYaxis()->SetTitle("Number of Events"); histRsqAllBkg->GetYaxis()->SetTitleOffset(1.2); histRsqData->SetMarkerStyle(8); legend->AddEntry(histRsqAllBkg, "All Backgrounds", "L"); legend->AddEntry(histRsqData, "Data", "L"); histRsqAllBkg->Add(histRsqQCD, 1.0); histRsqAllBkg->Draw("hist"); histRsqData->Draw("PE same"); legend->Draw(); cv->SetLogy(); cv->SaveAs(Form("Rsq_QCD_%s.pdf",Label.c_str())); ////////////////// histRsqQCD->SetFillColor(kAzure+4); histRsqAllBkg->SetFillColor(kMagenta); stackRsq->Add(histRsqAllBkg); stackRsq->Add(histRsqQCD); cv = new TCanvas("cv","cv", 800,600); legend = new TLegend(0.50,0.54,0.90,0.84); legend->SetTextSize(0.03); legend->SetBorderSize(0); legend->SetFillStyle(0); stackRsq->Draw(); stackRsq->GetHistogram()->GetXaxis()->SetTitle(((TH1F*)(stackRsq->GetHists()->At(0)))->GetXaxis()->GetTitle()); stackRsq->GetHistogram()->GetYaxis()->SetTitle(((TH1F*)(stackRsq->GetHists()->At(0)))->GetYaxis()->GetTitle()); stackRsq->Draw(); histRsqData->Draw("same PE"); legend->Draw(); cv->SetLogy(); cv->SaveAs(Form("RsqStack_QCD_%s.pdf",Label.c_str())); //-------------------------------------------------------------------------------------------------------------- // Output //============================================================================================================== TFile *file = TFile::Open(("RazorPlots"+Label+".root").c_str(), "RECREATE"); file->cd(); for(int i=0; i<int(inputfiles.size()); i++) { file->WriteTObject(histMRRsq[i], Form("histMRRsq_%s",processLabels[i].c_str()), "WriteDelete"); histUnrolled[i]->Write(); } stackUnrolled->Write(); }
void HistogramPlotter::makePlot(std::map<std::string, TH1F*> plotMap, std::string plotName, std::string subLabel, std::vector<std::string> xAxisLabels){ std::cerr << "Making a plot called: " << plotName << std::endl; //Make the legend. This is clearly the first thing I should do. TLegend legend_ = TLegend(0.7,0.7,0.94,0.94); legend_.SetFillStyle(1001); legend_.SetBorderSize(1); legend_.SetFillColor(kWhite); for (std::vector<std::string>::iterator leg_iter = legOrder_.begin(); leg_iter != legOrder_.end(); leg_iter++){ legend_.AddEntry(plotMap[*leg_iter], dsetMap_[*leg_iter].legLabel.c_str(), dsetMap_[*leg_iter].legType.c_str()); } //Initialise the stack THStack mcStack = THStack(plotName.c_str(),plotName.c_str()); //Do a few colour changing things and add MC to the stack. for (std::vector<std::string>::reverse_iterator plot_iter = plotOrder_.rbegin(); plot_iter != plotOrder_.rend(); plot_iter++){ plotMap[*plot_iter]->SetFillColor(dsetMap_[*plot_iter].colour); plotMap[*plot_iter]->SetLineColor(kBlack); plotMap[*plot_iter]->SetLineWidth(1); if( *plot_iter == "data"){ plotMap["data"]->SetMarkerStyle(20); plotMap["data"]->SetMarkerSize(1.2); plotMap["data"]->SetMarkerColor(kBlack); continue; } mcStack.Add(plotMap[*plot_iter]); } TCanvas * canvy = new TCanvas((plotName + subLabel + postfix_).c_str(), (plotName + subLabel + postfix_).c_str()); canvy->cd(); mcStack.Draw(""); if (xAxisLabels.size() > 0){ for (unsigned int i = 1; i <= xAxisLabels.size(); i++){ mcStack.GetXaxis()->SetBinLabel(i,xAxisLabels[i-1].c_str()); } } setLabelThree(subLabel); //labelThree_->Draw(); // labelTwo_->Draw(); // labelOne_->Draw(); float max = mcStack.GetMaximum(); if (plotMap.find("data") != plotMap.end()){ max = TMath::Max(mcStack.GetMaximum(),plotMap["data"]->GetMaximum()); plotMap["data"]->Draw("e x0, same"); } mcStack.SetMaximum(max*1.3); legend_.Draw(); // Save the plots. for (unsigned int ext_it = 0; ext_it < extensions_.size(); ext_it++){ canvy->SaveAs((outputFolder_ + plotName + subLabel + postfix_ + extensions_[ext_it]).c_str()); } //Make log plots canvy->SetLogy(); mcStack.SetMaximum(max*10); //Save the log plots for (unsigned int ext_it = 0; ext_it < extensions_.size(); ext_it++){ canvy->SaveAs((outputFolder_ + plotName + subLabel + postfix_ + "_log" + extensions_[ext_it]).c_str()); } delete canvy; }
void Draw(TString name, TString histotitle, bool log, int move_legend) { TH1F* hist_b; TH1F* hist_c; TH1F* hist_gsplit; TH1F* hist_l; TH1F* hist_data; TFile *myFile = new TFile(filename); myFile->cd(); hist_b = (TH1F*)gROOT->FindObject(name+"_b"); hist_c = (TH1F*)gROOT->FindObject(name+"_c"); hist_gsplit = (TH1F*)gROOT->FindObject(name+"_bfromg"); hist_l = (TH1F*)gROOT->FindObject(name+"_l"); hist_data = (TH1F*)gROOT->FindObject(name+"_data"); if (bOverflow && name!="SSV" && name!="SSVHP") { OverFlowBinFix(hist_b); OverFlowBinFix(hist_c); OverFlowBinFix(hist_gsplit); OverFlowBinFix(hist_l); OverFlowBinFix(hist_data); } TH1F* histo_tot = (TH1F*) hist_b->Clone(); histo_tot->Sumw2(); histo_tot ->Add(hist_c); histo_tot ->Add(hist_gsplit); histo_tot ->Add(hist_l); float scale_f = (hist_data->Integral())/(hist_b->Integral() + hist_c ->Integral()+ hist_gsplit->Integral() + hist_l->Integral()); hist_b ->Scale(scale_f); hist_c ->Scale(scale_f); hist_gsplit ->Scale(scale_f); hist_l ->Scale(scale_f); histo_tot ->Scale(scale_f); double titleoffsety=0.2; double titlesizex=0.17; double titlesizey=0.2; double labelsizex=0.14; double labelsizey=0.12; hist_data ->GetYaxis()->SetLabelSize(labelsizey); hist_data ->GetYaxis()->SetTitleSize(titlesizey); hist_data ->GetYaxis()->SetTitleOffset(titleoffsety); hist_b ->GetYaxis()->SetLabelSize(labelsizey); hist_b ->GetYaxis()->SetTitleSize(titlesizey); hist_b ->GetYaxis()->SetTitleOffset(titleoffsety); TH1F* histo_ratio; histo_ratio = (TH1F*) hist_data->Clone(); histo_ratio->SetName("histo_ratio"); histo_ratio->SetTitle(""); histo_ratio->Divide(histo_tot); hist_data ->SetLineWidth(2); hist_data ->SetMarkerStyle(20); hist_data ->SetMarkerSize(0.75); hist_c ->SetFillColor(8); hist_b ->SetFillColor(2); hist_gsplit->SetFillColor(7); hist_l ->SetFillColor(4); histo_tot ->SetLineColor(2); THStack *stack = new THStack("stack","stack"); if (b_ordering){ stack ->Add(hist_b); stack ->Add(hist_gsplit); stack ->Add(hist_c); stack ->Add(hist_l); } else { stack ->Add(hist_l); stack ->Add(hist_c); stack ->Add(hist_gsplit); stack ->Add(hist_b); } gStyle->SetOptTitle(0); gStyle->SetOptStat(0); //gStyle->SetLogy(log); TCanvas *c1 = new TCanvas("c1", "c1",10,32,782,552); c1->SetFillColor(10); c1-> cd(); TPad* canvas_1 = new TPad("canvas_1", "canvas_1",0,0.25,1.0,0.98); canvas_1 ->Draw(); canvas_1 ->cd(); canvas_1->SetLogy(log); if (hist_data->GetMaximum() > stack->GetMaximum() ) stack->SetMaximum( hist_data->GetMaximum()*1.1) ; float xmov=1; if (move_legend==2) { if (log) xmov=5; else xmov=1.1; stack->SetMaximum( xmov*stack->GetMaximum() ) ; } if (stack->GetMinimum()> hist_l->GetMinimum()) { if (log && hist_l->GetMinimum()>0.) stack->SetMinimum(hist_l->GetMinimum()); else if (!log) stack->SetMinimum(hist_l->GetMinimum()); } stack ->Draw("hist"); stack ->GetHistogram()->GetXaxis()->SetTitle(name); stack ->GetHistogram()->GetYaxis()->SetTitle("entries"); stack ->GetHistogram()->SetTitleSize(0.08,"Y"); stack ->GetHistogram()->SetTitleOffset(0.65,"Y"); hist_data->Draw("same e"); // TLegend* qw = new TLegend(0.54,0.63,0.88,0.9); TLegend* qw; if (move_legend==1) { qw = new TLegend(0.35,0.15,0.70,0.42); } else if (move_legend==3) { qw = new TLegend(0.35,0.63,0.70,0.90); } else qw = new TLegend(0.6,0.73,0.95,1.); //Legend qw->AddEntry(hist_data, "e#mu ttbar data", "p"); qw->AddEntry(hist_b, "b quark" , "f"); qw->AddEntry(hist_gsplit, "b from gluon splitting" ,"f"); qw->AddEntry(hist_c, "c quark" , "f"); qw->AddEntry(hist_l, "uds quark or gluon" , "f"); qw->SetFillColor(0); qw->Draw(); TLatex *latex = new TLatex(); latex->SetNDC(); latex->SetTextSize(0.055); latex->SetTextFont(42); //22 latex->SetTextAlign(13); latex->DrawLatex(0.08, 0.96, title); c1->cd(); TPad* canvas_2 = new TPad("canvas_2", "canvas_2",0,0.,1.0,0.32); canvas_2->Draw(); canvas_2->cd(); gPad->SetBottomMargin(0.375); gPad->SetGridy(); histo_ratio->SetMarkerStyle(20); histo_ratio->SetMarkerSize(0.75); histo_ratio->SetLineWidth(2); histo_ratio->GetYaxis()->SetTitle("Data/MC"); histo_ratio->GetXaxis()->SetTitle(histotitle); histo_ratio->GetYaxis()->SetNdivisions( 505 ); histo_ratio->GetXaxis()->SetLabelSize( labelsizex); histo_ratio->GetXaxis()->SetTitleSize( titlesizex ); histo_ratio->SetMinimum(0.4); histo_ratio->SetMaximum(1.6); histo_ratio->Draw("E1X0"); c1->cd(); TString name_plot=name+"_Linear"+format; if(log) name_plot=name+"_Log"+format; c1->SaveAs("Commissioning_plots/"+name_plot); if (log && web) { // save also _Linear for web canvas_1 ->cd(); canvas_1->SetLogy(false); if (xmov==5) { stack->SetMaximum( 1.1*stack->GetMaximum() ) ; } c1->cd(); c1->SaveAs("Commissioning_plots/"+name+"_Linear"+format); } }
void ttbar_looseLep2Pt_logy() { //=========Macro generated from canvas: c1/c1 //========= (Sun Dec 11 15:16:17 2016) by ROOT version6.06/01 TCanvas *c1 = new TCanvas("c1", "c1",1,1,1200,1416); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); c1->SetHighLightColor(2); c1->Range(0,0,1,1); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetTickx(1); c1->SetTicky(1); c1->SetLeftMargin(0.15); c1->SetRightMargin(0.05); c1->SetTopMargin(0.07); c1->SetBottomMargin(0.13); c1->SetFrameFillStyle(0); c1->SetFrameBorderMode(0); // ------------>Primitives in pad: pad1 TPad *pad1 = new TPad("pad1", "pad1",0,0.3,1,1); pad1->Draw(); pad1->cd(); pad1->Range(-93.75,-6.459411,531.25,2.538922); pad1->SetFillColor(0); pad1->SetBorderMode(0); pad1->SetBorderSize(2); pad1->SetLogy(); pad1->SetTickx(1); pad1->SetTicky(1); pad1->SetLeftMargin(0.15); pad1->SetRightMargin(0.05); pad1->SetTopMargin(0.07); pad1->SetBottomMargin(0); pad1->SetFrameFillStyle(0); pad1->SetFrameBorderMode(0); pad1->SetFrameFillStyle(0); pad1->SetFrameBorderMode(0); THStack *h = new THStack(); h->SetName("h"); h->SetTitle(""); h->SetMinimum(1.61613e-06); h->SetMaximum(32.94396); TH1F *h_stack_8 = new TH1F("h_stack_8","",20,0,500); h_stack_8->SetMinimum(3.472076e-07); h_stack_8->SetMaximum(81.10342); h_stack_8->SetDirectory(0); h_stack_8->SetStats(0); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#000099"); h_stack_8->SetLineColor(ci); h_stack_8->GetXaxis()->SetLabelFont(42); h_stack_8->GetXaxis()->SetLabelOffset(0.007); h_stack_8->GetXaxis()->SetTitleSize(0.05); h_stack_8->GetXaxis()->SetTickLength(0.025); h_stack_8->GetXaxis()->SetTitleFont(42); h_stack_8->GetYaxis()->SetTitle("a.u./25 GeV"); h_stack_8->GetYaxis()->SetLabelFont(42); h_stack_8->GetYaxis()->SetLabelOffset(0.007); h_stack_8->GetYaxis()->SetTitleSize(0.05); h_stack_8->GetYaxis()->SetTickLength(0.025); h_stack_8->GetYaxis()->SetTitleOffset(1.5); h_stack_8->GetYaxis()->SetTitleFont(42); h_stack_8->GetZaxis()->SetLabelFont(42); h_stack_8->GetZaxis()->SetLabelOffset(0.007); h_stack_8->GetZaxis()->SetTitleSize(0.05); h_stack_8->GetZaxis()->SetTickLength(0.025); h_stack_8->GetZaxis()->SetTitleFont(42); h->SetHistogram(h_stack_8); TH1D *h_looseLep2Pt_QCD__85 = new TH1D("h_looseLep2Pt_QCD__85","",20,0,500); h_looseLep2Pt_QCD__85->SetBinContent(1,0.004168645); h_looseLep2Pt_QCD__85->SetBinContent(2,0.004299542); h_looseLep2Pt_QCD__85->SetBinContent(3,0.001765161); h_looseLep2Pt_QCD__85->SetBinContent(4,0.0008868067); h_looseLep2Pt_QCD__85->SetBinContent(6,0.0004026872); h_looseLep2Pt_QCD__85->SetBinContent(7,6.27175e-05); h_looseLep2Pt_QCD__85->SetBinError(1,0.001669574); h_looseLep2Pt_QCD__85->SetBinError(2,0.002080688); h_looseLep2Pt_QCD__85->SetBinError(3,0.001425843); h_looseLep2Pt_QCD__85->SetBinError(4,0.0005754946); h_looseLep2Pt_QCD__85->SetBinError(6,0.0004026872); h_looseLep2Pt_QCD__85->SetBinError(7,4.443558e-05); h_looseLep2Pt_QCD__85->SetEntries(25); h_looseLep2Pt_QCD__85->SetStats(0); ci = TColor::GetColor("#cccccc"); h_looseLep2Pt_QCD__85->SetFillColor(ci); h_looseLep2Pt_QCD__85->GetXaxis()->SetTitle("Sub-leading lep p_{T} [GeV]"); h_looseLep2Pt_QCD__85->GetXaxis()->SetLabelFont(42); h_looseLep2Pt_QCD__85->GetXaxis()->SetLabelOffset(0.007); h_looseLep2Pt_QCD__85->GetXaxis()->SetTitleSize(0.05); h_looseLep2Pt_QCD__85->GetXaxis()->SetTickLength(0.025); h_looseLep2Pt_QCD__85->GetXaxis()->SetTitleFont(42); h_looseLep2Pt_QCD__85->GetYaxis()->SetTitle("a.u./25 GeV"); h_looseLep2Pt_QCD__85->GetYaxis()->SetLabelFont(42); h_looseLep2Pt_QCD__85->GetYaxis()->SetLabelOffset(0.007); h_looseLep2Pt_QCD__85->GetYaxis()->SetTitleSize(0.05); h_looseLep2Pt_QCD__85->GetYaxis()->SetTickLength(0.025); h_looseLep2Pt_QCD__85->GetYaxis()->SetTitleFont(42); h_looseLep2Pt_QCD__85->GetZaxis()->SetLabelFont(42); h_looseLep2Pt_QCD__85->GetZaxis()->SetLabelOffset(0.007); h_looseLep2Pt_QCD__85->GetZaxis()->SetTitleSize(0.05); h_looseLep2Pt_QCD__85->GetZaxis()->SetTickLength(0.025); h_looseLep2Pt_QCD__85->GetZaxis()->SetTitleFont(42); h->Add(h_looseLep2Pt_QCD,""); TH1D *h_looseLep2Pt_Diboson__86 = new TH1D("h_looseLep2Pt_Diboson__86","",20,0,500); h_looseLep2Pt_Diboson__86->SetBinContent(1,0.01174144); h_looseLep2Pt_Diboson__86->SetBinContent(2,0.01187664); h_looseLep2Pt_Diboson__86->SetBinContent(3,0.004759406); h_looseLep2Pt_Diboson__86->SetBinContent(4,0.002930753); h_looseLep2Pt_Diboson__86->SetBinContent(5,0.00175143); h_looseLep2Pt_Diboson__86->SetBinContent(6,0.0008561466); h_looseLep2Pt_Diboson__86->SetBinContent(7,0.000727361); h_looseLep2Pt_Diboson__86->SetBinContent(8,0.0006566697); h_looseLep2Pt_Diboson__86->SetBinContent(9,0.0001931429); h_looseLep2Pt_Diboson__86->SetBinContent(10,0.0004155724); h_looseLep2Pt_Diboson__86->SetBinContent(11,0.0002518857); h_looseLep2Pt_Diboson__86->SetBinContent(14,0.0002218985); h_looseLep2Pt_Diboson__86->SetBinContent(15,0.0002412745); h_looseLep2Pt_Diboson__86->SetBinContent(19,0.0001695579); h_looseLep2Pt_Diboson__86->SetBinError(1,0.001495699); h_looseLep2Pt_Diboson__86->SetBinError(2,0.001560382); h_looseLep2Pt_Diboson__86->SetBinError(3,0.0009896295); h_looseLep2Pt_Diboson__86->SetBinError(4,0.0007445459); h_looseLep2Pt_Diboson__86->SetBinError(5,0.0005817517); h_looseLep2Pt_Diboson__86->SetBinError(6,0.00038167); h_looseLep2Pt_Diboson__86->SetBinError(7,0.0003371659); h_looseLep2Pt_Diboson__86->SetBinError(8,0.0003965161); h_looseLep2Pt_Diboson__86->SetBinError(9,0.0001370432); h_looseLep2Pt_Diboson__86->SetBinError(10,0.0002946848); h_looseLep2Pt_Diboson__86->SetBinError(11,0.0002518857); h_looseLep2Pt_Diboson__86->SetBinError(14,0.0002218985); h_looseLep2Pt_Diboson__86->SetBinError(15,0.0002412745); h_looseLep2Pt_Diboson__86->SetBinError(19,0.0001695579); h_looseLep2Pt_Diboson__86->SetEntries(227); h_looseLep2Pt_Diboson__86->SetStats(0); ci = TColor::GetColor("#9966cc"); h_looseLep2Pt_Diboson__86->SetFillColor(ci); h_looseLep2Pt_Diboson__86->GetXaxis()->SetTitle("Sub-leading lep p_{T} [GeV]"); h_looseLep2Pt_Diboson__86->GetXaxis()->SetLabelFont(42); h_looseLep2Pt_Diboson__86->GetXaxis()->SetLabelOffset(0.007); h_looseLep2Pt_Diboson__86->GetXaxis()->SetTitleSize(0.05); h_looseLep2Pt_Diboson__86->GetXaxis()->SetTickLength(0.025); h_looseLep2Pt_Diboson__86->GetXaxis()->SetTitleFont(42); h_looseLep2Pt_Diboson__86->GetYaxis()->SetTitle("a.u./25 GeV"); h_looseLep2Pt_Diboson__86->GetYaxis()->SetLabelFont(42); h_looseLep2Pt_Diboson__86->GetYaxis()->SetLabelOffset(0.007); h_looseLep2Pt_Diboson__86->GetYaxis()->SetTitleSize(0.05); h_looseLep2Pt_Diboson__86->GetYaxis()->SetTickLength(0.025); h_looseLep2Pt_Diboson__86->GetYaxis()->SetTitleFont(42); h_looseLep2Pt_Diboson__86->GetZaxis()->SetLabelFont(42); h_looseLep2Pt_Diboson__86->GetZaxis()->SetLabelOffset(0.007); h_looseLep2Pt_Diboson__86->GetZaxis()->SetTitleSize(0.05); h_looseLep2Pt_Diboson__86->GetZaxis()->SetTickLength(0.025); h_looseLep2Pt_Diboson__86->GetZaxis()->SetTitleFont(42); h->Add(h_looseLep2Pt_Diboson,""); TH1D *h_looseLep2Pt_ZpLjets__87 = new TH1D("h_looseLep2Pt_ZpLjets__87","",20,0,500); h_looseLep2Pt_ZpLjets__87->SetBinContent(1,0.02667925); h_looseLep2Pt_ZpLjets__87->SetBinContent(2,0.01473475); h_looseLep2Pt_ZpLjets__87->SetBinContent(3,0.003756899); h_looseLep2Pt_ZpLjets__87->SetBinContent(4,0.001254256); h_looseLep2Pt_ZpLjets__87->SetBinContent(5,0.0004467979); h_looseLep2Pt_ZpLjets__87->SetBinContent(6,0.0002317029); h_looseLep2Pt_ZpLjets__87->SetBinContent(7,0.0001188745); h_looseLep2Pt_ZpLjets__87->SetBinContent(8,5.180996e-05); h_looseLep2Pt_ZpLjets__87->SetBinContent(9,3.953698e-05); h_looseLep2Pt_ZpLjets__87->SetBinContent(10,5.25799e-05); h_looseLep2Pt_ZpLjets__87->SetBinContent(11,8.216096e-06); h_looseLep2Pt_ZpLjets__87->SetBinContent(12,1.278228e-05); h_looseLep2Pt_ZpLjets__87->SetBinContent(13,9.580175e-06); h_looseLep2Pt_ZpLjets__87->SetBinContent(14,1.588075e-06); h_looseLep2Pt_ZpLjets__87->SetBinContent(15,1.177547e-05); h_looseLep2Pt_ZpLjets__87->SetBinContent(16,1.223887e-06); h_looseLep2Pt_ZpLjets__87->SetBinContent(17,7.306459e-07); h_looseLep2Pt_ZpLjets__87->SetBinContent(20,1.45491e-06); h_looseLep2Pt_ZpLjets__87->SetBinError(1,0.0005258423); h_looseLep2Pt_ZpLjets__87->SetBinError(2,0.0003466748); h_looseLep2Pt_ZpLjets__87->SetBinError(3,0.0001526343); h_looseLep2Pt_ZpLjets__87->SetBinError(4,8.095507e-05); h_looseLep2Pt_ZpLjets__87->SetBinError(5,4.333559e-05); h_looseLep2Pt_ZpLjets__87->SetBinError(6,3.359842e-05); h_looseLep2Pt_ZpLjets__87->SetBinError(7,2.459211e-05); h_looseLep2Pt_ZpLjets__87->SetBinError(8,1.436585e-05); h_looseLep2Pt_ZpLjets__87->SetBinError(9,1.618837e-05); h_looseLep2Pt_ZpLjets__87->SetBinError(10,2.012392e-05); h_looseLep2Pt_ZpLjets__87->SetBinError(11,3.870226e-06); h_looseLep2Pt_ZpLjets__87->SetBinError(12,6.226944e-06); h_looseLep2Pt_ZpLjets__87->SetBinError(13,5.393688e-06); h_looseLep2Pt_ZpLjets__87->SetBinError(14,6.993857e-07); h_looseLep2Pt_ZpLjets__87->SetBinError(15,7.943273e-06); h_looseLep2Pt_ZpLjets__87->SetBinError(16,7.962562e-07); h_looseLep2Pt_ZpLjets__87->SetBinError(17,5.208535e-07); h_looseLep2Pt_ZpLjets__87->SetBinError(20,1.161384e-06); h_looseLep2Pt_ZpLjets__87->SetEntries(24915); h_looseLep2Pt_ZpLjets__87->SetStats(0); ci = TColor::GetColor("#3399cc"); h_looseLep2Pt_ZpLjets__87->SetFillColor(ci); h_looseLep2Pt_ZpLjets__87->GetXaxis()->SetTitle("Sub-leading lep p_{T} [GeV]"); h_looseLep2Pt_ZpLjets__87->GetXaxis()->SetLabelFont(42); h_looseLep2Pt_ZpLjets__87->GetXaxis()->SetLabelOffset(0.007); h_looseLep2Pt_ZpLjets__87->GetXaxis()->SetTitleSize(0.05); h_looseLep2Pt_ZpLjets__87->GetXaxis()->SetTickLength(0.025); h_looseLep2Pt_ZpLjets__87->GetXaxis()->SetTitleFont(42); h_looseLep2Pt_ZpLjets__87->GetYaxis()->SetTitle("a.u./25 GeV"); h_looseLep2Pt_ZpLjets__87->GetYaxis()->SetLabelFont(42); h_looseLep2Pt_ZpLjets__87->GetYaxis()->SetLabelOffset(0.007); h_looseLep2Pt_ZpLjets__87->GetYaxis()->SetTitleSize(0.05); h_looseLep2Pt_ZpLjets__87->GetYaxis()->SetTickLength(0.025); h_looseLep2Pt_ZpLjets__87->GetYaxis()->SetTitleFont(42); h_looseLep2Pt_ZpLjets__87->GetZaxis()->SetLabelFont(42); h_looseLep2Pt_ZpLjets__87->GetZaxis()->SetLabelOffset(0.007); h_looseLep2Pt_ZpLjets__87->GetZaxis()->SetTitleSize(0.05); h_looseLep2Pt_ZpLjets__87->GetZaxis()->SetTickLength(0.025); h_looseLep2Pt_ZpLjets__87->GetZaxis()->SetTitleFont(42); h->Add(h_looseLep2Pt_Z+jets,""); TH1D *h_looseLep2Pt_WpLjets__88 = new TH1D("h_looseLep2Pt_WpLjets__88","",20,0,500); h_looseLep2Pt_WpLjets__88->SetBinContent(1,0.02932453); h_looseLep2Pt_WpLjets__88->SetBinContent(2,0.006497682); h_looseLep2Pt_WpLjets__88->SetBinContent(3,0.002693998); h_looseLep2Pt_WpLjets__88->SetBinContent(4,0.001997142); h_looseLep2Pt_WpLjets__88->SetBinContent(5,0.001838293); h_looseLep2Pt_WpLjets__88->SetBinContent(6,0.0008665013); h_looseLep2Pt_WpLjets__88->SetBinContent(7,0.001024588); h_looseLep2Pt_WpLjets__88->SetBinContent(8,0.0007202847); h_looseLep2Pt_WpLjets__88->SetBinContent(9,0.0001418163); h_looseLep2Pt_WpLjets__88->SetBinContent(10,0.0002837216); h_looseLep2Pt_WpLjets__88->SetBinContent(11,0.0001795552); h_looseLep2Pt_WpLjets__88->SetBinContent(12,1.395914e-05); h_looseLep2Pt_WpLjets__88->SetBinContent(13,1.974067e-05); h_looseLep2Pt_WpLjets__88->SetBinContent(14,5.586989e-06); h_looseLep2Pt_WpLjets__88->SetBinContent(15,4.838904e-05); h_looseLep2Pt_WpLjets__88->SetBinContent(16,8.80718e-06); h_looseLep2Pt_WpLjets__88->SetBinContent(17,2.15012e-06); h_looseLep2Pt_WpLjets__88->SetBinContent(18,3.517553e-06); h_looseLep2Pt_WpLjets__88->SetBinContent(19,3.815246e-07); h_looseLep2Pt_WpLjets__88->SetBinContent(20,1.212912e-05); h_looseLep2Pt_WpLjets__88->SetBinError(1,0.001351271); h_looseLep2Pt_WpLjets__88->SetBinError(2,0.0006213388); h_looseLep2Pt_WpLjets__88->SetBinError(3,0.0004390932); h_looseLep2Pt_WpLjets__88->SetBinError(4,0.0003469893); h_looseLep2Pt_WpLjets__88->SetBinError(5,0.0003545163); h_looseLep2Pt_WpLjets__88->SetBinError(6,0.0002163202); h_looseLep2Pt_WpLjets__88->SetBinError(7,0.0002255816); h_looseLep2Pt_WpLjets__88->SetBinError(8,0.0001927611); h_looseLep2Pt_WpLjets__88->SetBinError(9,6.565621e-05); h_looseLep2Pt_WpLjets__88->SetBinError(10,0.0001456303); h_looseLep2Pt_WpLjets__88->SetBinError(11,9.307131e-05); h_looseLep2Pt_WpLjets__88->SetBinError(12,4.209394e-06); h_looseLep2Pt_WpLjets__88->SetBinError(13,1.131021e-05); h_looseLep2Pt_WpLjets__88->SetBinError(14,3.172661e-06); h_looseLep2Pt_WpLjets__88->SetBinError(15,4.146079e-05); h_looseLep2Pt_WpLjets__88->SetBinError(16,5.369418e-06); h_looseLep2Pt_WpLjets__88->SetBinError(17,8.346041e-07); h_looseLep2Pt_WpLjets__88->SetBinError(18,2.861137e-06); h_looseLep2Pt_WpLjets__88->SetBinError(19,2.949137e-07); h_looseLep2Pt_WpLjets__88->SetBinError(20,6.047119e-06); h_looseLep2Pt_WpLjets__88->SetEntries(3309); h_looseLep2Pt_WpLjets__88->SetStats(0); ci = TColor::GetColor("#66cc66"); h_looseLep2Pt_WpLjets__88->SetFillColor(ci); h_looseLep2Pt_WpLjets__88->GetXaxis()->SetTitle("Sub-leading lep p_{T} [GeV]"); h_looseLep2Pt_WpLjets__88->GetXaxis()->SetLabelFont(42); h_looseLep2Pt_WpLjets__88->GetXaxis()->SetLabelOffset(0.007); h_looseLep2Pt_WpLjets__88->GetXaxis()->SetTitleSize(0.05); h_looseLep2Pt_WpLjets__88->GetXaxis()->SetTickLength(0.025); h_looseLep2Pt_WpLjets__88->GetXaxis()->SetTitleFont(42); h_looseLep2Pt_WpLjets__88->GetYaxis()->SetTitle("a.u./25 GeV"); h_looseLep2Pt_WpLjets__88->GetYaxis()->SetLabelFont(42); h_looseLep2Pt_WpLjets__88->GetYaxis()->SetLabelOffset(0.007); h_looseLep2Pt_WpLjets__88->GetYaxis()->SetTitleSize(0.05); h_looseLep2Pt_WpLjets__88->GetYaxis()->SetTickLength(0.025); h_looseLep2Pt_WpLjets__88->GetYaxis()->SetTitleFont(42); h_looseLep2Pt_WpLjets__88->GetZaxis()->SetLabelFont(42); h_looseLep2Pt_WpLjets__88->GetZaxis()->SetLabelOffset(0.007); h_looseLep2Pt_WpLjets__88->GetZaxis()->SetTitleSize(0.05); h_looseLep2Pt_WpLjets__88->GetZaxis()->SetTickLength(0.025); h_looseLep2Pt_WpLjets__88->GetZaxis()->SetTitleFont(42); h->Add(h_looseLep2Pt_W+jets,""); TH1D *h_looseLep2Pt_TopsPoPLFcP__89 = new TH1D("h_looseLep2Pt_TopsPoPLFcP__89","",20,0,500); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(1,0.09566986); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(2,0.1184424); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(3,0.0578968); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(4,0.02776582); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(5,0.01352875); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(6,0.006884179); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(7,0.003658057); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(8,0.001948227); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(9,0.001021047); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(10,0.000535609); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(11,0.000252071); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(12,0.0001040926); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(13,0.0002597359); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(14,4.685411e-05); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(15,2.316069e-05); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(16,7.098286e-06); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(17,1.098163e-05); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(18,5.405239e-06); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(19,1.254191e-05); h_looseLep2Pt_TopsPoPLFcP__89->SetBinContent(20,6.416628e-06); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(1,0.001032897); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(2,0.001159746); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(3,0.0008366751); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(4,0.0005883119); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(5,0.0003798421); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(6,0.0002961909); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(7,0.0002252512); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(8,0.0001593319); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(9,9.938102e-05); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(10,9.688184e-05); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(11,3.857011e-05); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(12,2.361438e-05); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(13,0.0001125534); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(14,1.684722e-05); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(15,1.087063e-05); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(16,7.098286e-06); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(17,7.125221e-06); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(18,3.836305e-06); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(19,8.954834e-06); h_looseLep2Pt_TopsPoPLFcP__89->SetBinError(20,4.538739e-06); h_looseLep2Pt_TopsPoPLFcP__89->SetEntries(45754); h_looseLep2Pt_TopsPoPLFcP__89->SetStats(0); ci = TColor::GetColor("#cc33cc"); h_looseLep2Pt_TopsPoPLFcP__89->SetFillColor(ci); h_looseLep2Pt_TopsPoPLFcP__89->GetXaxis()->SetTitle("Sub-leading lep p_{T} [GeV]"); h_looseLep2Pt_TopsPoPLFcP__89->GetXaxis()->SetLabelFont(42); h_looseLep2Pt_TopsPoPLFcP__89->GetXaxis()->SetLabelOffset(0.007); h_looseLep2Pt_TopsPoPLFcP__89->GetXaxis()->SetTitleSize(0.05); h_looseLep2Pt_TopsPoPLFcP__89->GetXaxis()->SetTickLength(0.025); h_looseLep2Pt_TopsPoPLFcP__89->GetXaxis()->SetTitleFont(42); h_looseLep2Pt_TopsPoPLFcP__89->GetYaxis()->SetTitle("a.u./25 GeV"); h_looseLep2Pt_TopsPoPLFcP__89->GetYaxis()->SetLabelFont(42); h_looseLep2Pt_TopsPoPLFcP__89->GetYaxis()->SetLabelOffset(0.007); h_looseLep2Pt_TopsPoPLFcP__89->GetYaxis()->SetTitleSize(0.05); h_looseLep2Pt_TopsPoPLFcP__89->GetYaxis()->SetTickLength(0.025); h_looseLep2Pt_TopsPoPLFcP__89->GetYaxis()->SetTitleFont(42); h_looseLep2Pt_TopsPoPLFcP__89->GetZaxis()->SetLabelFont(42); h_looseLep2Pt_TopsPoPLFcP__89->GetZaxis()->SetLabelOffset(0.007); h_looseLep2Pt_TopsPoPLFcP__89->GetZaxis()->SetTitleSize(0.05); h_looseLep2Pt_TopsPoPLFcP__89->GetZaxis()->SetTickLength(0.025); h_looseLep2Pt_TopsPoPLFcP__89->GetZaxis()->SetTitleFont(42); h->Add(h_looseLep2Pt_Top (LF),""); TH1D *h_looseLep2Pt_TopsPoPHFcP__90 = new TH1D("h_looseLep2Pt_TopsPoPHFcP__90","",20,0,500); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(1,0.1041412); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(2,0.1735886); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(3,0.1116258); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(4,0.06454315); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(5,0.03441357); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(6,0.01992067); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(7,0.01014646); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(8,0.005947886); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(9,0.002876054); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(10,0.001475723); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(11,0.0007236292); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(12,0.0004357554); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(13,0.0002249375); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(14,0.0001475853); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(15,0.0001020681); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(16,6.402955e-05); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(17,1.980568e-05); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(18,2.33998e-05); h_looseLep2Pt_TopsPoPHFcP__90->SetBinContent(20,2.517288e-05); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(1,0.001126128); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(2,0.001474884); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(3,0.001116875); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(4,0.0008934187); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(5,0.0006246887); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(6,0.0005076532); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(7,0.0003555866); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(8,0.000286312); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(9,0.0001737097); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(10,0.0001517557); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(11,6.387877e-05); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(12,5.265571e-05); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(13,3.442087e-05); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(14,2.732865e-05); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(15,2.352865e-05); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(16,1.915664e-05); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(17,1.063003e-05); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(18,1.102394e-05); h_looseLep2Pt_TopsPoPHFcP__90->SetBinError(20,1.216417e-05); h_looseLep2Pt_TopsPoPHFcP__90->SetEntries(77950); h_looseLep2Pt_TopsPoPHFcP__90->SetStats(0); ci = TColor::GetColor("#ff9900"); h_looseLep2Pt_TopsPoPHFcP__90->SetFillColor(ci); h_looseLep2Pt_TopsPoPHFcP__90->GetXaxis()->SetTitle("Sub-leading lep p_{T} [GeV]"); h_looseLep2Pt_TopsPoPHFcP__90->GetXaxis()->SetLabelFont(42); h_looseLep2Pt_TopsPoPHFcP__90->GetXaxis()->SetLabelOffset(0.007); h_looseLep2Pt_TopsPoPHFcP__90->GetXaxis()->SetTitleSize(0.05); h_looseLep2Pt_TopsPoPHFcP__90->GetXaxis()->SetTickLength(0.025); h_looseLep2Pt_TopsPoPHFcP__90->GetXaxis()->SetTitleFont(42); h_looseLep2Pt_TopsPoPHFcP__90->GetYaxis()->SetTitle("a.u./25 GeV"); h_looseLep2Pt_TopsPoPHFcP__90->GetYaxis()->SetLabelFont(42); h_looseLep2Pt_TopsPoPHFcP__90->GetYaxis()->SetLabelOffset(0.007); h_looseLep2Pt_TopsPoPHFcP__90->GetYaxis()->SetTitleSize(0.05); h_looseLep2Pt_TopsPoPHFcP__90->GetYaxis()->SetTickLength(0.025); h_looseLep2Pt_TopsPoPHFcP__90->GetYaxis()->SetTitleFont(42); h_looseLep2Pt_TopsPoPHFcP__90->GetZaxis()->SetLabelFont(42); h_looseLep2Pt_TopsPoPHFcP__90->GetZaxis()->SetLabelOffset(0.007); h_looseLep2Pt_TopsPoPHFcP__90->GetZaxis()->SetTitleSize(0.05); h_looseLep2Pt_TopsPoPHFcP__90->GetZaxis()->SetTickLength(0.025); h_looseLep2Pt_TopsPoPHFcP__90->GetZaxis()->SetTitleFont(42); h->Add(h_looseLep2Pt_Top (HF),""); h->Draw("hist"); TH1D *hsum__91 = new TH1D("hsum__91","",20,0,500); hsum__91->SetBinContent(1,0.271725); hsum__91->SetBinContent(2,0.3294396); hsum__91->SetBinContent(3,0.1824981); hsum__91->SetBinContent(4,0.09937792); hsum__91->SetBinContent(5,0.05197885); hsum__91->SetBinContent(6,0.02916189); hsum__91->SetBinContent(7,0.01573805); hsum__91->SetBinContent(8,0.009324878); hsum__91->SetBinContent(9,0.004271597); hsum__91->SetBinContent(10,0.002763206); hsum__91->SetBinContent(11,0.001415357); hsum__91->SetBinContent(12,0.0005665895); hsum__91->SetBinContent(13,0.0005139942); hsum__91->SetBinContent(14,0.000423513); hsum__91->SetBinContent(15,0.0004266677); hsum__91->SetBinContent(16,8.11589e-05); hsum__91->SetBinContent(17,3.366807e-05); hsum__91->SetBinContent(18,3.232259e-05); hsum__91->SetBinContent(19,0.0001824813); hsum__91->SetBinContent(20,4.517354e-05); hsum__91->SetBinError(1,0.003076049); hsum__91->SetBinError(2,0.003284904); hsum__91->SetBinError(3,0.002275067); hsum__91->SetBinError(4,0.001468607); hsum__91->SetBinError(5,0.001000255); hsum__91->SetBinError(6,0.0008373727); hsum__91->SetBinError(7,0.0005867939); hsum__91->SetBinError(8,0.0005494993); hsum__91->SetBinError(9,0.0002518041); hsum__91->SetBinError(10,0.0003753241); hsum__91->SetBinError(11,0.0002787325); hsum__91->SetBinError(12,5.819584e-05); hsum__91->SetBinError(13,0.0001183642); hsum__91->SetBinError(14,0.0002242324); hsum__91->SetBinError(15,0.0002463072); hsum__91->SetBinError(16,2.113829e-05); hsum__91->SetBinError(17,1.283488e-05); hsum__91->SetBinError(18,1.201793e-05); hsum__91->SetBinError(19,0.0001697944); hsum__91->SetBinError(20,1.436954e-05); hsum__91->SetEntries(65); hsum__91->SetStats(0); ci = 1187; color = new TColor(ci, 0, 0, 0, " ", 0.99); hsum__91->SetFillColor(ci); hsum__91->SetFillStyle(3003); hsum__91->SetLineWidth(0); hsum__91->GetXaxis()->SetTitle("Sub-leading lep p_{T} [GeV]"); hsum__91->GetXaxis()->SetLabelFont(42); hsum__91->GetXaxis()->SetLabelOffset(0.007); hsum__91->GetXaxis()->SetTitleSize(0.05); hsum__91->GetXaxis()->SetTickLength(0.025); hsum__91->GetXaxis()->SetTitleFont(42); hsum__91->GetYaxis()->SetTitle("a.u./25 GeV"); hsum__91->GetYaxis()->SetLabelFont(42); hsum__91->GetYaxis()->SetLabelOffset(0.007); hsum__91->GetYaxis()->SetTitleSize(0.05); hsum__91->GetYaxis()->SetTickLength(0.025); hsum__91->GetYaxis()->SetTitleFont(42); hsum__91->GetZaxis()->SetLabelFont(42); hsum__91->GetZaxis()->SetLabelOffset(0.007); hsum__91->GetZaxis()->SetTitleSize(0.05); hsum__91->GetZaxis()->SetTickLength(0.025); hsum__91->GetZaxis()->SetTitleFont(42); hsum__91->Draw("e2 same"); TH1D *h_looseLep2Pt_Data__92 = new TH1D("h_looseLep2Pt_Data__92","",20,0,500); h_looseLep2Pt_Data__92->SetBinContent(1,0.2915764); h_looseLep2Pt_Data__92->SetBinContent(2,0.3247432); h_looseLep2Pt_Data__92->SetBinContent(3,0.1760106); h_looseLep2Pt_Data__92->SetBinContent(4,0.0916329); h_looseLep2Pt_Data__92->SetBinContent(5,0.04946763); h_looseLep2Pt_Data__92->SetBinContent(6,0.02920946); h_looseLep2Pt_Data__92->SetBinContent(7,0.01620654); h_looseLep2Pt_Data__92->SetBinContent(8,0.008904174); h_looseLep2Pt_Data__92->SetBinContent(9,0.004805427); h_looseLep2Pt_Data__92->SetBinContent(10,0.002732498); h_looseLep2Pt_Data__92->SetBinContent(11,0.001837369); h_looseLep2Pt_Data__92->SetBinContent(12,0.001177801); h_looseLep2Pt_Data__92->SetBinContent(13,0.0008951286); h_looseLep2Pt_Data__92->SetBinContent(14,0.0002826722); h_looseLep2Pt_Data__92->SetBinContent(15,0.0001413361); h_looseLep2Pt_Data__92->SetBinContent(16,0.0001884481); h_looseLep2Pt_Data__92->SetBinContent(17,0.0001413361); h_looseLep2Pt_Data__92->SetBinContent(20,4.711203e-05); h_looseLep2Pt_Data__92->SetBinError(1,0.003706313); h_looseLep2Pt_Data__92->SetBinError(2,0.003911434); h_looseLep2Pt_Data__92->SetBinError(3,0.002879621); h_looseLep2Pt_Data__92->SetBinError(4,0.002077742); h_looseLep2Pt_Data__92->SetBinError(5,0.001526604); h_looseLep2Pt_Data__92->SetBinError(6,0.00117308); h_looseLep2Pt_Data__92->SetBinError(7,0.000873798); h_looseLep2Pt_Data__92->SetBinError(8,0.0006476834); h_looseLep2Pt_Data__92->SetBinError(9,0.0004758082); h_looseLep2Pt_Data__92->SetBinError(10,0.0003587945); h_looseLep2Pt_Data__92->SetBinError(11,0.0002942145); h_looseLep2Pt_Data__92->SetBinError(12,0.0002355602); h_looseLep2Pt_Data__92->SetBinError(13,0.0002053566); h_looseLep2Pt_Data__92->SetBinError(14,0.0001154004); h_looseLep2Pt_Data__92->SetBinError(15,8.160043e-05); h_looseLep2Pt_Data__92->SetBinError(16,9.422406e-05); h_looseLep2Pt_Data__92->SetBinError(17,8.160043e-05); h_looseLep2Pt_Data__92->SetBinError(20,4.711203e-05); h_looseLep2Pt_Data__92->SetEntries(21226); h_looseLep2Pt_Data__92->SetStats(0); h_looseLep2Pt_Data__92->SetLineWidth(3); h_looseLep2Pt_Data__92->SetMarkerStyle(20); h_looseLep2Pt_Data__92->SetMarkerSize(2); h_looseLep2Pt_Data__92->GetXaxis()->SetTitle("Sub-leading lep p_{T} [GeV]"); h_looseLep2Pt_Data__92->GetXaxis()->SetLabelFont(42); h_looseLep2Pt_Data__92->GetXaxis()->SetLabelOffset(0.007); h_looseLep2Pt_Data__92->GetXaxis()->SetTitleSize(0.05); h_looseLep2Pt_Data__92->GetXaxis()->SetTickLength(0.025); h_looseLep2Pt_Data__92->GetXaxis()->SetTitleFont(42); h_looseLep2Pt_Data__92->GetYaxis()->SetTitle("a.u./25 GeV"); h_looseLep2Pt_Data__92->GetYaxis()->SetLabelFont(42); h_looseLep2Pt_Data__92->GetYaxis()->SetLabelOffset(0.007); h_looseLep2Pt_Data__92->GetYaxis()->SetTitleSize(0.05); h_looseLep2Pt_Data__92->GetYaxis()->SetTickLength(0.025); h_looseLep2Pt_Data__92->GetYaxis()->SetTitleFont(42); h_looseLep2Pt_Data__92->GetZaxis()->SetLabelFont(42); h_looseLep2Pt_Data__92->GetZaxis()->SetLabelOffset(0.007); h_looseLep2Pt_Data__92->GetZaxis()->SetTitleSize(0.05); h_looseLep2Pt_Data__92->GetZaxis()->SetTickLength(0.025); h_looseLep2Pt_Data__92->GetZaxis()->SetTitleFont(42); h_looseLep2Pt_Data__92->Draw("elp same"); TLegend *leg = new TLegend(0.6,0.55,0.88,0.9,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(0); TLegendEntry *entry=leg->AddEntry("h_looseLep2Pt_Data","Data","ELP"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(3); entry->SetMarkerColor(1); entry->SetMarkerStyle(20); entry->SetMarkerSize(2); entry->SetTextFont(42); entry=leg->AddEntry("h_looseLep2Pt_Top (HF)","Top (HF)","F"); ci = TColor::GetColor("#ff9900"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_looseLep2Pt_Top (LF)","Top (LF)","F"); ci = TColor::GetColor("#cc33cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_looseLep2Pt_W+jets","W+jets","F"); ci = TColor::GetColor("#66cc66"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_looseLep2Pt_Z+jets","Z+jets","F"); ci = TColor::GetColor("#3399cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_looseLep2Pt_Diboson","Diboson","F"); ci = TColor::GetColor("#9966cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_looseLep2Pt_QCD","QCD","F"); ci = TColor::GetColor("#cccccc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); leg->Draw(); leg = new TLegend(0.6,0.55,0.88,0.9,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(0); entry=leg->AddEntry("h_looseLep2Pt_Data","Data","ELP"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(3); entry->SetMarkerColor(1); entry->SetMarkerStyle(20); entry->SetMarkerSize(2); entry->SetTextFont(42); entry=leg->AddEntry("h_looseLep2Pt_Top (HF)","Top (HF)","F"); ci = TColor::GetColor("#ff9900"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_looseLep2Pt_Top (LF)","Top (LF)","F"); ci = TColor::GetColor("#cc33cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_looseLep2Pt_W+jets","W+jets","F"); ci = TColor::GetColor("#66cc66"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_looseLep2Pt_Z+jets","Z+jets","F"); ci = TColor::GetColor("#3399cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_looseLep2Pt_Diboson","Diboson","F"); ci = TColor::GetColor("#9966cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_looseLep2Pt_QCD","QCD","F"); ci = TColor::GetColor("#cccccc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); leg->Draw(); TLatex * tex = new TLatex(0.18,0.85,"CMS"); tex->SetNDC(); tex->SetTextSize(0.06); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.28,0.85,"Preliminary"); tex->SetNDC(); tex->SetTextFont(52); tex->SetTextSize(0.06); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.9,0.94,"36.6 fb^{-1} (13 TeV)"); tex->SetNDC(); tex->SetTextAlign(31); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); pad1->Modified(); c1->cd(); // ------------>Primitives in pad: pad2 TPad *pad2 = new TPad("pad2", "pad2",0,0.05,1,0.3); pad2->Draw(); pad2->cd(); pad2->Range(-93.75,-0.8914286,531.25,0.48); pad2->SetFillColor(0); pad2->SetBorderMode(0); pad2->SetBorderSize(2); pad2->SetGridy(); pad2->SetTickx(1); pad2->SetTicky(1); pad2->SetLeftMargin(0.15); pad2->SetRightMargin(0.05); pad2->SetTopMargin(0); pad2->SetBottomMargin(0.3); pad2->SetFrameFillStyle(0); pad2->SetFrameBorderMode(0); pad2->SetFrameFillStyle(0); pad2->SetFrameBorderMode(0); TH1D *ratio__93 = new TH1D("ratio__93","",20,0,500); ratio__93->SetBinContent(1,0.07305694); ratio__93->SetBinContent(2,-0.01425564); ratio__93->SetBinContent(3,-0.03554857); ratio__93->SetBinContent(4,-0.07793492); ratio__93->SetBinContent(5,-0.04831219); ratio__93->SetBinContent(6,0.00163126); ratio__93->SetBinContent(7,0.02976763); ratio__93->SetBinContent(8,-0.04511625); ratio__93->SetBinContent(9,0.1249721); ratio__93->SetBinContent(10,-0.01111317); ratio__93->SetBinContent(11,0.2981665); ratio__93->SetBinContent(12,1.078755); ratio__93->SetBinContent(13,0.741515); ratio__93->SetBinContent(14,-0.3325537); ratio__93->SetBinContent(15,-0.6687443); ratio__93->SetBinContent(16,1.321965); ratio__93->SetBinContent(17,3.197927); ratio__93->SetBinContent(18,-999); ratio__93->SetBinContent(19,-999); ratio__93->SetBinContent(20,0.04291213); ratio__93->SetBinError(1,0.0001); ratio__93->SetBinError(2,0.0001); ratio__93->SetBinError(3,0.0001); ratio__93->SetBinError(4,0.0001); ratio__93->SetBinError(5,0.0001); ratio__93->SetBinError(6,0.0001); ratio__93->SetBinError(7,0.0001); ratio__93->SetBinError(8,0.0001); ratio__93->SetBinError(9,0.0001); ratio__93->SetBinError(10,0.0001); ratio__93->SetBinError(11,0.0001); ratio__93->SetBinError(12,0.0001); ratio__93->SetBinError(13,0.0001); ratio__93->SetBinError(14,0.0001); ratio__93->SetBinError(15,0.0001); ratio__93->SetBinError(16,0.0001); ratio__93->SetBinError(17,0.0001); ratio__93->SetBinError(18,0.0001); ratio__93->SetBinError(19,0.0001); ratio__93->SetBinError(20,0.0001); ratio__93->SetMinimum(-0.48); ratio__93->SetMaximum(0.48); ratio__93->SetEntries(21246); ratio__93->SetStats(0); ratio__93->SetLineWidth(3); ratio__93->SetMarkerStyle(20); ratio__93->SetMarkerSize(2); ratio__93->GetXaxis()->SetTitle("Sub-leading lep p_{T} [GeV]"); ratio__93->GetXaxis()->SetLabelFont(43); ratio__93->GetXaxis()->SetLabelOffset(0.007); ratio__93->GetXaxis()->SetLabelSize(30); ratio__93->GetXaxis()->SetTitleSize(40); ratio__93->GetXaxis()->SetTickLength(0.025); ratio__93->GetXaxis()->SetTitleOffset(5); ratio__93->GetXaxis()->SetTitleFont(43); ratio__93->GetYaxis()->SetTitle("#frac{Data-Exp}{Exp}"); ratio__93->GetYaxis()->SetNdivisions(5); ratio__93->GetYaxis()->SetLabelFont(43); ratio__93->GetYaxis()->SetLabelOffset(0.007); ratio__93->GetYaxis()->SetLabelSize(30); ratio__93->GetYaxis()->SetTitleSize(40); ratio__93->GetYaxis()->SetTickLength(0.025); ratio__93->GetYaxis()->SetTitleOffset(2.5); ratio__93->GetYaxis()->SetTitleFont(43); ratio__93->GetZaxis()->SetLabelFont(42); ratio__93->GetZaxis()->SetLabelOffset(0.007); ratio__93->GetZaxis()->SetTitleSize(0.05); ratio__93->GetZaxis()->SetTickLength(0.025); ratio__93->GetZaxis()->SetTitleFont(42); ratio__93->Draw("elp"); TH1D *zero__94 = new TH1D("zero__94","",20,0,500); zero__94->SetBinError(1,0.003706313); zero__94->SetBinError(2,0.003911434); zero__94->SetBinError(3,0.002879621); zero__94->SetBinError(4,0.002077742); zero__94->SetBinError(5,0.001526604); zero__94->SetBinError(6,0.00117308); zero__94->SetBinError(7,0.000873798); zero__94->SetBinError(8,0.0006476834); zero__94->SetBinError(9,0.0004758082); zero__94->SetBinError(10,0.0003587945); zero__94->SetBinError(11,0.0002942145); zero__94->SetBinError(12,0.0002355602); zero__94->SetBinError(13,0.0002053566); zero__94->SetBinError(14,0.0001154004); zero__94->SetBinError(15,8.160043e-05); zero__94->SetBinError(16,9.422406e-05); zero__94->SetBinError(17,8.160043e-05); zero__94->SetBinError(20,4.711203e-05); zero__94->SetEntries(21246); zero__94->SetStats(0); zero__94->SetLineWidth(3); zero__94->SetMarkerStyle(20); zero__94->SetMarkerSize(2); zero__94->GetXaxis()->SetTitle("Sub-leading lep p_{T} [GeV]"); zero__94->GetXaxis()->SetLabelFont(42); zero__94->GetXaxis()->SetLabelOffset(0.007); zero__94->GetXaxis()->SetTitleSize(0.05); zero__94->GetXaxis()->SetTickLength(0.025); zero__94->GetXaxis()->SetTitleFont(42); zero__94->GetYaxis()->SetTitle("a.u./25 GeV"); zero__94->GetYaxis()->SetLabelFont(42); zero__94->GetYaxis()->SetLabelOffset(0.007); zero__94->GetYaxis()->SetTitleSize(0.05); zero__94->GetYaxis()->SetTickLength(0.025); zero__94->GetYaxis()->SetTitleFont(42); zero__94->GetZaxis()->SetLabelFont(42); zero__94->GetZaxis()->SetLabelOffset(0.007); zero__94->GetZaxis()->SetTitleSize(0.05); zero__94->GetZaxis()->SetTickLength(0.025); zero__94->GetZaxis()->SetTitleFont(42); zero__94->Draw("hist same"); TH1D *sumratioup__95 = new TH1D("sumratioup__95","",20,0,500); sumratioup__95->SetBinContent(1,0.01132045); sumratioup__95->SetBinContent(2,0.009971187); sumratioup__95->SetBinContent(3,0.01246625); sumratioup__95->SetBinContent(4,0.014778); sumratioup__95->SetBinContent(5,0.01924351); sumratioup__95->SetBinContent(6,0.02871463); sumratioup__95->SetBinContent(7,0.03728504); sumratioup__95->SetBinContent(8,0.05892831); sumratioup__95->SetBinContent(9,0.05894846); sumratioup__95->SetBinContent(10,0.1358292); sumratioup__95->SetBinContent(11,0.1969344); sumratioup__95->SetBinContent(12,0.1027125); sumratioup__95->SetBinContent(13,0.2302831); sumratioup__95->SetBinContent(14,0.5294582); sumratioup__95->SetBinContent(15,0.577281); sumratioup__95->SetBinContent(16,0.2604556); sumratioup__95->SetBinContent(17,0.3812182); sumratioup__95->SetBinContent(18,0.3718119); sumratioup__95->SetBinContent(19,0.9304757); sumratioup__95->SetBinContent(20,0.3180965); sumratioup__95->SetBinError(1,0.003076049); sumratioup__95->SetBinError(2,0.003284904); sumratioup__95->SetBinError(3,0.002275067); sumratioup__95->SetBinError(4,0.001468607); sumratioup__95->SetBinError(5,0.001000255); sumratioup__95->SetBinError(6,0.0008373727); sumratioup__95->SetBinError(7,0.0005867939); sumratioup__95->SetBinError(8,0.0005494993); sumratioup__95->SetBinError(9,0.0002518041); sumratioup__95->SetBinError(10,0.0003753241); sumratioup__95->SetBinError(11,0.0002787325); sumratioup__95->SetBinError(12,5.819584e-05); sumratioup__95->SetBinError(13,0.0001183642); sumratioup__95->SetBinError(14,0.0002242324); sumratioup__95->SetBinError(15,0.0002463072); sumratioup__95->SetBinError(16,2.113829e-05); sumratioup__95->SetBinError(17,1.283488e-05); sumratioup__95->SetBinError(18,1.201793e-05); sumratioup__95->SetBinError(19,0.0001697944); sumratioup__95->SetBinError(20,1.436954e-05); sumratioup__95->SetEntries(85); sumratioup__95->SetStats(0); ci = 1187; color = new TColor(ci, 0, 0, 0, " ", 0.99); sumratioup__95->SetFillColor(ci); sumratioup__95->SetFillStyle(3003); sumratioup__95->GetXaxis()->SetTitle("Sub-leading lep p_{T} [GeV]"); sumratioup__95->GetXaxis()->SetLabelFont(42); sumratioup__95->GetXaxis()->SetLabelOffset(0.007); sumratioup__95->GetXaxis()->SetTitleSize(0.05); sumratioup__95->GetXaxis()->SetTickLength(0.025); sumratioup__95->GetXaxis()->SetTitleFont(42); sumratioup__95->GetYaxis()->SetTitle("a.u./25 GeV"); sumratioup__95->GetYaxis()->SetLabelFont(42); sumratioup__95->GetYaxis()->SetLabelOffset(0.007); sumratioup__95->GetYaxis()->SetTitleSize(0.05); sumratioup__95->GetYaxis()->SetTickLength(0.025); sumratioup__95->GetYaxis()->SetTitleFont(42); sumratioup__95->GetZaxis()->SetLabelFont(42); sumratioup__95->GetZaxis()->SetLabelOffset(0.007); sumratioup__95->GetZaxis()->SetTitleSize(0.05); sumratioup__95->GetZaxis()->SetTickLength(0.025); sumratioup__95->GetZaxis()->SetTitleFont(42); sumratioup__95->Draw("hist same"); TH1D *sumratiodown__96 = new TH1D("sumratiodown__96","",20,0,500); sumratiodown__96->SetBinContent(1,-0.01132045); sumratiodown__96->SetBinContent(2,-0.009971187); sumratiodown__96->SetBinContent(3,-0.01246625); sumratiodown__96->SetBinContent(4,-0.014778); sumratiodown__96->SetBinContent(5,-0.01924351); sumratiodown__96->SetBinContent(6,-0.02871463); sumratiodown__96->SetBinContent(7,-0.03728504); sumratiodown__96->SetBinContent(8,-0.05892831); sumratiodown__96->SetBinContent(9,-0.05894846); sumratiodown__96->SetBinContent(10,-0.1358292); sumratiodown__96->SetBinContent(11,-0.1969344); sumratiodown__96->SetBinContent(12,-0.1027125); sumratiodown__96->SetBinContent(13,-0.2302831); sumratiodown__96->SetBinContent(14,-0.5294582); sumratiodown__96->SetBinContent(15,-0.577281); sumratiodown__96->SetBinContent(16,-0.2604556); sumratiodown__96->SetBinContent(17,-0.3812182); sumratiodown__96->SetBinContent(18,-0.3718119); sumratiodown__96->SetBinContent(19,-0.9304757); sumratiodown__96->SetBinContent(20,-0.3180965); sumratiodown__96->SetBinError(1,0.003076049); sumratiodown__96->SetBinError(2,0.003284904); sumratiodown__96->SetBinError(3,0.002275067); sumratiodown__96->SetBinError(4,0.001468607); sumratiodown__96->SetBinError(5,0.001000255); sumratiodown__96->SetBinError(6,0.0008373727); sumratiodown__96->SetBinError(7,0.0005867939); sumratiodown__96->SetBinError(8,0.0005494993); sumratiodown__96->SetBinError(9,0.0002518041); sumratiodown__96->SetBinError(10,0.0003753241); sumratiodown__96->SetBinError(11,0.0002787325); sumratiodown__96->SetBinError(12,5.819584e-05); sumratiodown__96->SetBinError(13,0.0001183642); sumratiodown__96->SetBinError(14,0.0002242324); sumratiodown__96->SetBinError(15,0.0002463072); sumratiodown__96->SetBinError(16,2.113829e-05); sumratiodown__96->SetBinError(17,1.283488e-05); sumratiodown__96->SetBinError(18,1.201793e-05); sumratiodown__96->SetBinError(19,0.0001697944); sumratiodown__96->SetBinError(20,1.436954e-05); sumratiodown__96->SetEntries(85); sumratiodown__96->SetStats(0); ci = 1187; color = new TColor(ci, 0, 0, 0, " ", 0.99); sumratiodown__96->SetFillColor(ci); sumratiodown__96->SetFillStyle(3003); sumratiodown__96->GetXaxis()->SetTitle("Sub-leading lep p_{T} [GeV]"); sumratiodown__96->GetXaxis()->SetLabelFont(42); sumratiodown__96->GetXaxis()->SetLabelOffset(0.007); sumratiodown__96->GetXaxis()->SetTitleSize(0.05); sumratiodown__96->GetXaxis()->SetTickLength(0.025); sumratiodown__96->GetXaxis()->SetTitleFont(42); sumratiodown__96->GetYaxis()->SetTitle("a.u./25 GeV"); sumratiodown__96->GetYaxis()->SetLabelFont(42); sumratiodown__96->GetYaxis()->SetLabelOffset(0.007); sumratiodown__96->GetYaxis()->SetTitleSize(0.05); sumratiodown__96->GetYaxis()->SetTickLength(0.025); sumratiodown__96->GetYaxis()->SetTitleFont(42); sumratiodown__96->GetZaxis()->SetLabelFont(42); sumratiodown__96->GetZaxis()->SetLabelOffset(0.007); sumratiodown__96->GetZaxis()->SetTitleSize(0.05); sumratiodown__96->GetZaxis()->SetTickLength(0.025); sumratiodown__96->GetZaxis()->SetTitleFont(42); sumratiodown__96->Draw("hist same"); Double_t Graph0_fx1008[20] = { 12.5, 37.5, 62.5, 87.5, 112.5, 137.5, 162.5, 187.5, 212.5, 237.5, 262.5, 287.5, 312.5, 337.5, 362.5, 387.5, 412.5, 437.5, 462.5, 487.5}; Double_t Graph0_fy1008[20] = { 0.07305694, -0.01425564, -0.03554857, -0.07793492, -0.04831219, 0.00163126, 0.02976763, -0.04511625, 0.1249721, -0.01111317, 0.2981665, 1.078755, 0.741515, -0.3325537, -0.6687443, 1.321965, 3.197927, -999, -999, 0.04291213}; Double_t Graph0_fex1008[20] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; Double_t Graph0_fey1008[20] = { 0.01363994, 0.01187299, 0.01577891, 0.02090748, 0.02936972, 0.04022648, 0.05552135, 0.06945757, 0.1113888, 0.1298472, 0.207873, 0.415751, 0.3995309, 0.2724838, 0.1912505, 1.160983, 2.423674, 0, 0, 1.042912}; TGraphErrors *gre = new TGraphErrors(20,Graph0_fx1008,Graph0_fy1008,Graph0_fex1008,Graph0_fey1008); gre->SetName("Graph0"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetLineWidth(3); TH1F *Graph_Graph1008 = new TH1F("Graph_Graph1008","Graph",100,0,535); Graph_Graph1008->SetMinimum(-1099.462); Graph_Graph1008->SetMaximum(106.0838); Graph_Graph1008->SetDirectory(0); Graph_Graph1008->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1008->SetLineColor(ci); Graph_Graph1008->GetXaxis()->SetLabelFont(42); Graph_Graph1008->GetXaxis()->SetLabelOffset(0.007); Graph_Graph1008->GetXaxis()->SetTitleSize(0.05); Graph_Graph1008->GetXaxis()->SetTickLength(0.025); Graph_Graph1008->GetXaxis()->SetTitleFont(42); Graph_Graph1008->GetYaxis()->SetLabelFont(42); Graph_Graph1008->GetYaxis()->SetLabelOffset(0.007); Graph_Graph1008->GetYaxis()->SetTitleSize(0.05); Graph_Graph1008->GetYaxis()->SetTickLength(0.025); Graph_Graph1008->GetYaxis()->SetTitleFont(42); Graph_Graph1008->GetZaxis()->SetLabelFont(42); Graph_Graph1008->GetZaxis()->SetLabelOffset(0.007); Graph_Graph1008->GetZaxis()->SetTitleSize(0.05); Graph_Graph1008->GetZaxis()->SetTickLength(0.025); Graph_Graph1008->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1008); gre->Draw("pe0"); pad2->Modified(); c1->cd(); c1->Modified(); c1->cd(); c1->SetSelected(c1); }
void DrawTTbar(TString name, TString histotitle, bool log, int move_legend) { TH1F* hist_ttbar; TH1F* hist_dy; TH1F* hist_st; TH1F* hist_data; TFile *myFile = new TFile(filename); myFile->cd(); hist_ttbar = (TH1F*)gROOT->FindObject(name+"_ttbar"); hist_dy = (TH1F*)gROOT->FindObject(name+"_dy"); hist_st = (TH1F*)gROOT->FindObject(name+"_st"); hist_data = (TH1F*)gROOT->FindObject(name+"_data"); if (bOverflow) { OverFlowBinFix(hist_ttbar); OverFlowBinFix(hist_dy); OverFlowBinFix(hist_st); OverFlowBinFix(hist_data); } TH1F* histo_tot = (TH1F*) hist_ttbar->Clone(); histo_tot->Sumw2(); histo_tot ->Add(hist_dy); histo_tot ->Add(hist_st); /* float scale_f = (hist_data->Integral())/(hist_tot->Integral()); hist_ttbar ->Scale(scale_f); hist_dy ->Scale(scale_f); hist_st ->Scale(scale_f); histo_tot ->Scale(scale_f); */ double titleoffsety=0.2; double titlesizex=0.17; double titlesizey=0.2; double labelsizex=0.14; double labelsizey=0.12; hist_data ->GetYaxis()->SetLabelSize(labelsizey); hist_data ->GetYaxis()->SetTitleSize(titlesizey); hist_data ->GetYaxis()->SetTitleOffset(titleoffsety); hist_ttbar ->GetYaxis()->SetLabelSize(labelsizey); hist_ttbar ->GetYaxis()->SetTitleSize(titlesizey); hist_ttbar ->GetYaxis()->SetTitleOffset(titleoffsety); TH1F* histo_ratio; histo_ratio = (TH1F*) hist_data->Clone(); histo_ratio->SetName("histo_ratio"); histo_ratio->SetTitle(""); histo_ratio->Divide(histo_tot); hist_data ->SetLineWidth(2); hist_data ->SetMarkerStyle(20); hist_data ->SetMarkerSize(0.75); hist_dy ->SetFillColor(kAzure-2); hist_ttbar ->SetFillColor(kRed+1); hist_st ->SetFillColor(kMagenta); THStack *stack = new THStack("stack","stack"); stack ->Add(hist_ttbar); stack ->Add(hist_st); stack ->Add(hist_dy); gStyle->SetOptTitle(0); gStyle->SetOptStat(0); //gStyle->SetLogy(log); TCanvas *c1 = new TCanvas("c1", "c1",10,32,782,552); c1->SetFillColor(10); c1-> cd(); TPad* canvas_1 = new TPad("canvas_1", "canvas_1",0,0.25,1.0,0.98); canvas_1 ->Draw(); canvas_1 ->cd(); canvas_1->SetLogy(log); if (hist_data->GetMaximum() > stack->GetMaximum() ) stack->SetMaximum( hist_data->GetMaximum()*1.1) ; if (move_legend==2) { if (log) stack->SetMaximum( 5.*stack->GetMaximum() ) ; else stack->SetMaximum( 1.1*stack->GetMaximum() ) ; } stack ->Draw("hist"); stack ->GetHistogram()->GetXaxis()->SetTitle(name); stack ->GetHistogram()->GetYaxis()->SetTitle("entries"); stack ->GetHistogram()->SetTitleSize(0.08,"Y"); stack ->GetHistogram()->SetTitleOffset(0.65,"Y"); hist_data->Draw("same e"); // TLegend* qw = new TLegend(0.54,0.63,0.88,0.9); TLegend* qw; if (move_legend==1) { qw = new TLegend(0.35,0.15,0.70,0.42); } else if (move_legend==3) { qw = new TLegend(0.35,0.63,0.70,0.90); } else qw = new TLegend(0.6,0.73,0.95,1.); //Legend qw->AddEntry(hist_data, "e#mu data", "p"); qw->AddEntry(hist_ttbar, "t#bar{t}" , "f"); qw->AddEntry(hist_dy, "DY" ,"f"); qw->AddEntry(hist_st, "tW" , "f"); qw->SetFillColor(0); qw->Draw(); TLatex *latex = new TLatex(); latex->SetNDC(); latex->SetTextSize(0.055); latex->SetTextFont(42); //22 latex->SetTextAlign(13); latex->DrawLatex(0.08, 0.96, title); c1->cd(); TPad* canvas_2 = new TPad("canvas_2", "canvas_2",0,0.,1.0,0.32); canvas_2->Draw(); canvas_2->cd(); gPad->SetBottomMargin(0.375); gPad->SetGridy(); histo_ratio->SetMarkerStyle(20); histo_ratio->SetMarkerSize(0.75); histo_ratio->SetLineWidth(2); histo_ratio->GetYaxis()->SetTitle("Data/MC"); histo_ratio->GetXaxis()->SetTitle(histotitle); histo_ratio->GetYaxis()->SetNdivisions( 505 ); histo_ratio->GetXaxis()->SetLabelSize( labelsizex); histo_ratio->GetXaxis()->SetTitleSize( titlesizex ); histo_ratio->SetMinimum(0.4); histo_ratio->SetMaximum(1.6); histo_ratio->Draw("E1X0"); c1->cd(); TString name_plot="ttbar_"+name+"_Linear"+format; if(log) name_plot="ttbar_"+name+"_Log"+format; c1->SaveAs("Commissioning_plots/"+name_plot); }
void makeStack(TString myVar, TString myCut, TString myName, TString myAxisNameX, TString myAxisNameY, vector<const Sample*>& listOfSignals, vector<const Sample*>& listOfSamples, vector<const Sample*> listOfDatasets, TString inFileName, bool isBlind, bool isLog, bool drawSignal, bool drawLegend, int nBins, float xLow, float xHigh, float* xlowVec) { // prepare the input file TFile* infile = new TFile(inFileName, "READ"); infile -> cd(); // prepare the stack THStack *hs = new THStack("hs",""); // prepare the histos pointers TH1F* hist[20]; // prepare the tree pointers TTree* tree[20]; // prepare the legend TLegend* leg = new TLegend(.7485,.7225,.9597,.9604); leg->SetFillColor(0); // prepare the colors Int_t col[20] = {46,2,12,5,3,4,9,7,47,49,49,50,51,52,53,54,55,56,57,58}; // prepare the cut if (isBlind) myCut += "*(phoMetDeltaPhi < 2.9)"; // prepare the Y axis lable if (xlowVec != 0) myAxisNameY = "Events/" + myAxisNameY; else { float binWidth = (xHigh-xLow)/nBins; TString tempString; tempString.Form("%.2f ",binWidth); myAxisNameY = "Events/" + tempString + myAxisNameY; } // prepare the legend strings vector<TString> theLegends; // loop through the datasets and produce the plots TH1F* hdata; TH1F* hsignal; //prepare data and signal histos if (xlowVec != 0) hdata = new TH1F("hdata","",nBins,xlowVec); else hdata = new TH1F("hdata","",nBins,xLow,xHigh); if (xlowVec != 0) hsignal = new TH1F("hsignal","",nBins,xlowVec); else hsignal = new TH1F("hsignal","",nBins,xLow,xHigh); TTree* treedata[20]; for (UInt_t iDatas=0; iDatas < listOfDatasets.size(); iDatas++) { //get the tree treedata[iDatas] = (TTree*) infile -> Get(listOfDatasets.at(iDatas)->Name()->Data()); //fill the histogram if ( iDatas == 0 ) treedata[iDatas] -> Draw(myVar + " >> hdata","evt_weight*kf_weight*pu_weight" + myCut); else treedata[iDatas] -> Draw(myVar + " >>+ hdata","evt_weight*kf_weight*pu_weight" + myCut); if ( isBlind && iDatas == 0 ) leg -> AddEntry(hdata, "DATA (19.8 fb^{-1})", "pl"); }//end loop on datasets if (xlowVec != 0) { for (int iBin = 1; iBin <= nBins; iBin++) hdata->SetBinError (iBin,hdata->GetBinError(iBin)/hdata->GetBinWidth(iBin)); for (int iBin = 1; iBin <= nBins; iBin++) hdata->SetBinContent(iBin,hdata->GetBinContent(iBin)/hdata->GetBinWidth(iBin)); } TTree* treesignal[20]; for (UInt_t iSignal=0; iSignal < listOfSignals.size(); iSignal++) { //get the tree treesignal[iSignal] = (TTree*) infile -> Get(listOfSignals.at(iSignal)->Name()->Data()); //fill the histogram TString thisScale = Form("%f *", *(listOfSignals.at(iSignal)->Scale())); if ( iSignal == 0 ) treesignal[iSignal] -> Draw(myVar + " >> hsignal",thisScale + "evt_weight*kf_weight*pu_weight" + myCut); else treesignal[iSignal] -> Draw(myVar + " >>+ hsignal",thisScale + "evt_weight*kf_weight*pu_weight" + myCut); if ( drawSignal && iSignal == 0 ) leg -> AddEntry(hsignal, "Signal", "l"); }//end loop on signals if (xlowVec != 0) { for (int iBin = 1; iBin <= nBins; iBin++) hsignal->SetBinError (iBin,hsignal->GetBinError(iBin)/hsignal->GetBinWidth(iBin)); for (int iBin = 1; iBin <= nBins; iBin++) hsignal->SetBinContent(iBin,hsignal->GetBinContent(iBin)/hsignal->GetBinWidth(iBin)); } hsignal -> SetLineColor(49); hsignal -> SetLineWidth(4.0); int theHistCounter = 0; // loop through the samples and produce the plots for (UInt_t iSample=0; iSample < listOfSamples.size(); iSample++) { //determine if the histo is first of the series bool isFirstOfSerie = (*listOfSamples.at(iSample)->Legend()).CompareTo(" "); bool isLastOfSerie = false; if (iSample == listOfSamples.size() - 1) isLastOfSerie = true; if (iSample < listOfSamples.size() - 1 && (*listOfSamples.at(iSample+1)->Legend()).CompareTo(" ") != 0) isLastOfSerie = true; //get the tree tree[iSample] = (TTree*) infile -> Get(listOfSamples.at(iSample)->Name()->Data()); //if sample first of the list create a new histogram if (isFirstOfSerie) { TString thisHistName = "h_" + *(listOfSamples.at(iSample)->Name()); //variable bin histo if (xlowVec != 0) hist[theHistCounter] = new TH1F(thisHistName,thisHistName,nBins,xlowVec); //fixed bin histo else hist[theHistCounter] = new TH1F(thisHistName,thisHistName,nBins,xLow,xHigh); hist[theHistCounter] -> Sumw2(); hist[theHistCounter] -> SetFillColor(col[theHistCounter]); hist[theHistCounter] -> SetFillStyle(1001); theLegends.push_back(*listOfSamples.at(iSample)->Legend()); } //fill the histogram TString thisScale = Form("%f *", *(listOfSamples.at(iSample)->Scale())); if (isFirstOfSerie) tree[iSample] -> Draw(myVar + " >> " + TString(hist[theHistCounter] -> GetName()),thisScale + "evt_weight*kf_weight*pu_weight" + myCut); else tree[iSample] -> Draw(myVar + " >>+ " + TString(hist[theHistCounter] -> GetName()),thisScale + "evt_weight*kf_weight*pu_weight" + myCut); //add the histogram to the stack if the last of the series: //either last sample or ~ sample followed by non ~ sample if (isLastOfSerie) { if (xlowVec != 0) { for (int iBin = 1; iBin <= nBins; iBin++) hist[theHistCounter]->SetBinError (iBin,hist[theHistCounter]->GetBinError(iBin)/hist[theHistCounter]->GetBinWidth(iBin)); for (int iBin = 1; iBin <= nBins; iBin++) hist[theHistCounter]->SetBinContent(iBin,hist[theHistCounter]->GetBinContent(iBin)/hist[theHistCounter]->GetBinWidth(iBin)); } hs -> Add(hist[theHistCounter]); theHistCounter++; } }//end loop on samples //Fix the legend for (int iHisto = theHistCounter-1; iHisto >= 0; iHisto--) { leg -> AddEntry(hist[iHisto], theLegends[iHisto], "f"); } //get the maximum to properly set the frame float theMax = hdata -> GetBinContent(hdata -> GetMaximumBin()) + hdata -> GetBinError(hdata -> GetMaximumBin()); TH1* theMCSum = (TH1*) hs->GetStack()->Last(); float theMaxMC = theMCSum->GetBinContent(theMCSum->GetMaximumBin()) + theMCSum->GetBinError(theMCSum->GetMaximumBin()); if (theMaxMC > theMax) theMax = theMaxMC; //prepare the ratio band and plot TH1* theMCRatioBand = makeRatioBand(theMCSum); TH1* theRatioPlot = makeRatioPlot(hdata,theMCSum); TCanvas* can = new TCanvas(); can -> SetLogy(isLog); TPad *pad1 = new TPad("pad1","top pad",0,0.30,1,1); pad1->SetBottomMargin(0.02); pad1->SetLeftMargin(0.13); pad1->Draw(); TPad *pad2 = new TPad("pad2","bottom pad",0,0.0,1,0.30); pad2->SetTopMargin(0.02); pad2->SetLeftMargin(0.13); pad2->SetBottomMargin(0.4); pad2->SetGridy(); pad2->Draw(); pad1->cd(); hs->Draw("hist"); hdata->Draw("same,pe"); if (drawSignal) hsignal->Draw("same,hist"); if (drawLegend) leg->Draw("same"); //hs->GetXaxis()->SetTitle(myAxisNameX); hs->GetYaxis()->SetTitle(myAxisNameY); hs->GetXaxis()->SetLabelSize(0.04); hs->GetYaxis()->SetLabelSize(0.04); hs->GetXaxis()->SetLabelOffset(0.025); hs->GetYaxis()->SetLabelOffset(0.035); //hs->GetXaxis()->SetTitleOffset(1.1); hs->GetYaxis()->SetTitleOffset(1.1); hs->SetMaximum(theMax); if (isLog) hs->SetMinimum(0.01); pad2->cd(); theMCRatioBand->GetXaxis()->SetTitle(myAxisNameX); theMCRatioBand->GetXaxis()->SetTitleSize(0.16); theMCRatioBand->GetXaxis()->SetTitleOffset(1.1); theMCRatioBand->GetXaxis()->SetLabelSize(0.12); theMCRatioBand->GetXaxis()->SetLabelOffset(0.07); theMCRatioBand->GetYaxis()->SetTitle("Data/MC"); theMCRatioBand->GetYaxis()->SetTitleSize(0.10); theMCRatioBand->GetYaxis()->SetTitleOffset(0.6); theMCRatioBand->GetYaxis()->SetLabelSize(0.06); theMCRatioBand->GetYaxis()->SetLabelOffset(0.03); theMCRatioBand->SetFillStyle(3001); theMCRatioBand->SetFillColor(kBlue); theMCRatioBand->SetLineWidth(1); theMCRatioBand->SetLineColor(kBlack); theMCRatioBand->SetMarkerSize(0.1); theMCRatioBand->SetMaximum(4.); theMCRatioBand->SetMinimum(0.); theMCRatioBand->Draw("E2"); TLine *line = new TLine(xLow,1,xHigh,1); line->SetLineColor(kBlack); line->Draw("same"); theRatioPlot->Draw("same,pe"); can->cd(); can->Modified(); can -> SaveAs(myName + ".pdf","pdf"); //cleanup the memory allocation delete theMCSum; delete hs; delete leg; delete hdata; delete pad1; delete pad2; delete can; delete theMCRatioBand; delete theRatioPlot; infile -> Close(); delete infile; return; }
void browseStacks( bool makePictures=false, bool wait=true , bool addHistName = false, Double_t maxYScaleF = 1., bool logScale = false, bool setMinZero = true) { gStyle->SetOptTitle(0); bool keep2D=false; //fix the hNJet histos TList *list = gDirectory->GetList(); TIterator *iter = list->MakeIterator(); TObject *obj = 0; while(obj = iter->Next()) { if(TString(obj->GetName()).Contains("hnJet") && obj->InheritsFrom(TH1::Class())) { int nbins = ((TH1F*)obj)->GetNbinsX(); float overflow = ((TH1F*)obj)->GetBinContent(nbins+1); float lastbinval = ((TH1F*)obj)->GetBinContent(nbins); ((TH1F*)obj)->SetBinContent(nbins, overflow+lastbinval); ((TH1F*)obj)->GetXaxis()->SetBinLabel(nbins, "#geq4"); } } // Find out what the names of the existing histograms are // The histogram names are XX_YY_ZZ, where XX is the sample, // eg, "tt", YY is the actual name, ZZ is the final state, eg, "ee" TObjArray* myNames = getMyHistosNames("ttdil","ee",keep2D); // Now loop over histograms, and make stacks TCanvas *c = new TCanvas(); c->Divide(2,2); char* suffix[4]; suffix[0] = "ee"; suffix[1] = "mm"; suffix[2] = "em"; suffix[3] = "all"; if (makePictures) c->Print("out/stacks.ps["); for (int i=0; i<myNames->GetEntries(); i++) { for (int sample=0; sample<4; sample++) { hist::stack(Form("st_%s_%s",myNames->At(i)->GetName(),suffix[sample]), Form("%s_%s$",myNames->At(i)->GetName(), suffix[sample])); THStack* thisStack = (THStack*) gROOT->FindObjectAny( Form("st_%s_%s", myNames->At(i)->GetName(), suffix[sample])); thisStack->SetMaximum(thisStack->GetMaximum()*maxYScaleF); if(TString(myNames->At(i)->GetName()).Contains("hnJet")) { TList* histolist = thisStack->GetHists(); int hatchcount = 0; // for(int j = 0; j<histolist->GetSize();j++) { // if(TString(histolist->At(j)->GetName()).Contains("tt") || // TString(histolist->At(j)->GetName()).Contains("tautau") || // TString(histolist->At(j)->GetName()).Contains("ww") ) continue; // hatch(histolist->At(j)->GetName(), FavoriteHatches[hatchcount]); // hatchcount++; // } } TLegend* thisLeg = hist::legend(thisStack, "lpf", 0, 0, 0.75, 0.65, 0.99, 0.99); c->cd(sample+1); if (logScale) gPad->SetLogy(); else gPad->SetLogy(0); double stackMax = ((TH1*)thisStack->GetHists()->At(0))->GetMaximum(); double stackMin = ((TH1*)thisStack->GetHists()->At(0))->GetMinimum(); thisStack->SetMinimum(stackMin); if (setMinZero) thisStack->SetMinimum(0); if (logScale && stackMin <=0) thisStack->SetMinimum(1e-2*stackMax); if (logScale && stackMax == 0) thisStack->SetMinimum(1e-12); thisStack->Draw("hist"); string xtitle( ((TH1*)gROOT->FindObjectAny(Form("ttdil_%s_%s", myNames->At(i)->GetName(), suffix[sample])))->GetXaxis()->GetTitle()); string ytitle( ((TH1*)gROOT->FindObjectAny(Form("ttdil_%s_%s", myNames->At(i)->GetName(), suffix[sample])))->GetYaxis()->GetTitle()); thisStack->GetXaxis()->SetTitle(xtitle.c_str()); thisStack->GetYaxis()->SetTitle(ytitle.c_str()); TString hname = thisStack->GetName(); if(hname.Contains("hnJet")) { thisStack->GetXaxis()->SetLabelSize(0.075); thisStack->GetYaxis()->SetLabelSize(0.05); thisStack->GetXaxis()->SetTitle("N_{jets}"); } thisLeg->Draw(); TPaveText *pt1 = new TPaveText(0.1, 0.95, 0.4, 0.999, "brNDC"); pt1->SetName("pt1name"); pt1->SetBorderSize(0); pt1->SetFillStyle(0); TText *blah; if (addHistName) blah = pt1->AddText(hname); else blah = pt1->AddText("CMS Preliminary"); blah->SetTextSize(0.05); pt1->Draw(); c->Modified(); c->Update(); } if (makePictures) { c->Print("out/stacks.ps"); // c->Print(Form("out/stacks_%d.png",i+1)); //c->Print(Form("out/stacks_%s.png",myNames->At(i)->GetName())); c->Print(Form("out/stacks_%s.eps",myNames->At(i)->GetName())); } if (wait) { cout << "Enter carriage return for the next set of plots....q to quit" << endl; char in = getchar(); if (in == 'q') break; } } if (makePictures) c->Print("out/stacks.ps]"); }
void ttbar_isojet1CSV() { //=========Macro generated from canvas: c1/c1 //========= (Sun Dec 11 15:16:19 2016) by ROOT version6.06/01 TCanvas *c1 = new TCanvas("c1", "c1",1,1,1200,1416); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); c1->SetHighLightColor(2); c1->Range(0,0,1,1); c1->SetFillColor(0); c1->SetBorderMode(0); c1->SetBorderSize(2); c1->SetTickx(1); c1->SetTicky(1); c1->SetLeftMargin(0.15); c1->SetRightMargin(0.05); c1->SetTopMargin(0.07); c1->SetBottomMargin(0.13); c1->SetFrameFillStyle(0); c1->SetFrameBorderMode(0); // ------------>Primitives in pad: pad1 TPad *pad1 = new TPad("pad1", "pad1",0,0.3,1,1); pad1->Draw(); pad1->cd(); pad1->Range(-0.1875,0,1.0625,0.6289089); pad1->SetFillColor(0); pad1->SetBorderMode(0); pad1->SetBorderSize(2); pad1->SetTickx(1); pad1->SetTicky(1); pad1->SetLeftMargin(0.15); pad1->SetRightMargin(0.05); pad1->SetTopMargin(0.07); pad1->SetBottomMargin(0); pad1->SetFrameFillStyle(0); pad1->SetFrameBorderMode(0); pad1->SetFrameFillStyle(0); pad1->SetFrameBorderMode(0); THStack *h = new THStack(); h->SetName("h"); h->SetTitle(""); h->SetMinimum(0); h->SetMaximum(0.5570336); TH1F *h_stack_23 = new TH1F("h_stack_23","",10,0,1); h_stack_23->SetMinimum(0); h_stack_23->SetMaximum(0.5848853); h_stack_23->SetDirectory(0); h_stack_23->SetStats(0); Int_t ci; // for color index setting TColor *color; // for color definition with alpha ci = TColor::GetColor("#000099"); h_stack_23->SetLineColor(ci); h_stack_23->GetXaxis()->SetLabelFont(42); h_stack_23->GetXaxis()->SetLabelOffset(0.007); h_stack_23->GetXaxis()->SetTitleSize(0.05); h_stack_23->GetXaxis()->SetTickLength(0.025); h_stack_23->GetXaxis()->SetTitleFont(42); h_stack_23->GetYaxis()->SetTitle("a.u."); h_stack_23->GetYaxis()->SetLabelFont(42); h_stack_23->GetYaxis()->SetLabelOffset(0.007); h_stack_23->GetYaxis()->SetTitleSize(0.05); h_stack_23->GetYaxis()->SetTickLength(0.025); h_stack_23->GetYaxis()->SetTitleOffset(1.5); h_stack_23->GetYaxis()->SetTitleFont(42); h_stack_23->GetZaxis()->SetLabelFont(42); h_stack_23->GetZaxis()->SetLabelOffset(0.007); h_stack_23->GetZaxis()->SetTitleSize(0.05); h_stack_23->GetZaxis()->SetTickLength(0.025); h_stack_23->GetZaxis()->SetTitleFont(42); h->SetHistogram(h_stack_23); TH1D *h_isojet1CSV_QCD__265 = new TH1D("h_isojet1CSV_QCD__265","",10,0,1); h_isojet1CSV_QCD__265->SetBinContent(1,0.002129117); h_isojet1CSV_QCD__265->SetBinContent(2,0.001248327); h_isojet1CSV_QCD__265->SetBinContent(3,0.0006205357); h_isojet1CSV_QCD__265->SetBinContent(4,0.001430306); h_isojet1CSV_QCD__265->SetBinContent(5,0.001031553); h_isojet1CSV_QCD__265->SetBinContent(6,0.0005098467); h_isojet1CSV_QCD__265->SetBinContent(7,0.0002095089); h_isojet1CSV_QCD__265->SetBinContent(8,9.216642e-05); h_isojet1CSV_QCD__265->SetBinContent(10,0.004314199); h_isojet1CSV_QCD__265->SetBinError(1,0.001510477); h_isojet1CSV_QCD__265->SetBinError(2,0.0006911766); h_isojet1CSV_QCD__265->SetBinError(3,0.0004578373); h_isojet1CSV_QCD__265->SetBinError(4,0.0008388365); h_isojet1CSV_QCD__265->SetBinError(5,0.0008715622); h_isojet1CSV_QCD__265->SetBinError(6,0.0005098467); h_isojet1CSV_QCD__265->SetBinError(7,0.0002095089); h_isojet1CSV_QCD__265->SetBinError(8,9.216642e-05); h_isojet1CSV_QCD__265->SetBinError(10,0.002213733); h_isojet1CSV_QCD__265->SetEntries(25); h_isojet1CSV_QCD__265->SetStats(0); ci = TColor::GetColor("#cccccc"); h_isojet1CSV_QCD__265->SetFillColor(ci); h_isojet1CSV_QCD__265->GetXaxis()->SetTitle("isojet 1 CSV"); h_isojet1CSV_QCD__265->GetXaxis()->SetLabelFont(42); h_isojet1CSV_QCD__265->GetXaxis()->SetLabelOffset(0.007); h_isojet1CSV_QCD__265->GetXaxis()->SetTitleSize(0.05); h_isojet1CSV_QCD__265->GetXaxis()->SetTickLength(0.025); h_isojet1CSV_QCD__265->GetXaxis()->SetTitleFont(42); h_isojet1CSV_QCD__265->GetYaxis()->SetTitle("a.u."); h_isojet1CSV_QCD__265->GetYaxis()->SetLabelFont(42); h_isojet1CSV_QCD__265->GetYaxis()->SetLabelOffset(0.007); h_isojet1CSV_QCD__265->GetYaxis()->SetTitleSize(0.05); h_isojet1CSV_QCD__265->GetYaxis()->SetTickLength(0.025); h_isojet1CSV_QCD__265->GetYaxis()->SetTitleFont(42); h_isojet1CSV_QCD__265->GetZaxis()->SetLabelFont(42); h_isojet1CSV_QCD__265->GetZaxis()->SetLabelOffset(0.007); h_isojet1CSV_QCD__265->GetZaxis()->SetTitleSize(0.05); h_isojet1CSV_QCD__265->GetZaxis()->SetTickLength(0.025); h_isojet1CSV_QCD__265->GetZaxis()->SetTitleFont(42); h->Add(h_isojet1CSV_QCD,""); TH1D *h_isojet1CSV_Diboson__266 = new TH1D("h_isojet1CSV_Diboson__266","",10,0,1); h_isojet1CSV_Diboson__266->SetBinContent(1,0.006910874); h_isojet1CSV_Diboson__266->SetBinContent(2,0.01156259); h_isojet1CSV_Diboson__266->SetBinContent(3,0.00597142); h_isojet1CSV_Diboson__266->SetBinContent(4,0.003397186); h_isojet1CSV_Diboson__266->SetBinContent(5,0.003453268); h_isojet1CSV_Diboson__266->SetBinContent(6,0.001659304); h_isojet1CSV_Diboson__266->SetBinContent(7,0.001617052); h_isojet1CSV_Diboson__266->SetBinContent(8,0.001259235); h_isojet1CSV_Diboson__266->SetBinContent(9,0.000286628); h_isojet1CSV_Diboson__266->SetBinContent(10,0.00067562); h_isojet1CSV_Diboson__266->SetBinError(1,0.001086007); h_isojet1CSV_Diboson__266->SetBinError(2,0.001467728); h_isojet1CSV_Diboson__266->SetBinError(3,0.001077108); h_isojet1CSV_Diboson__266->SetBinError(4,0.0008370875); h_isojet1CSV_Diboson__266->SetBinError(5,0.0009085276); h_isojet1CSV_Diboson__266->SetBinError(6,0.000631351); h_isojet1CSV_Diboson__266->SetBinError(7,0.0006254813); h_isojet1CSV_Diboson__266->SetBinError(8,0.0005614698); h_isojet1CSV_Diboson__266->SetBinError(9,0.0001726014); h_isojet1CSV_Diboson__266->SetBinError(10,0.0003333104); h_isojet1CSV_Diboson__266->SetEntries(227); h_isojet1CSV_Diboson__266->SetStats(0); ci = TColor::GetColor("#9966cc"); h_isojet1CSV_Diboson__266->SetFillColor(ci); h_isojet1CSV_Diboson__266->GetXaxis()->SetTitle("isojet 1 CSV"); h_isojet1CSV_Diboson__266->GetXaxis()->SetLabelFont(42); h_isojet1CSV_Diboson__266->GetXaxis()->SetLabelOffset(0.007); h_isojet1CSV_Diboson__266->GetXaxis()->SetTitleSize(0.05); h_isojet1CSV_Diboson__266->GetXaxis()->SetTickLength(0.025); h_isojet1CSV_Diboson__266->GetXaxis()->SetTitleFont(42); h_isojet1CSV_Diboson__266->GetYaxis()->SetTitle("a.u."); h_isojet1CSV_Diboson__266->GetYaxis()->SetLabelFont(42); h_isojet1CSV_Diboson__266->GetYaxis()->SetLabelOffset(0.007); h_isojet1CSV_Diboson__266->GetYaxis()->SetTitleSize(0.05); h_isojet1CSV_Diboson__266->GetYaxis()->SetTickLength(0.025); h_isojet1CSV_Diboson__266->GetYaxis()->SetTitleFont(42); h_isojet1CSV_Diboson__266->GetZaxis()->SetLabelFont(42); h_isojet1CSV_Diboson__266->GetZaxis()->SetLabelOffset(0.007); h_isojet1CSV_Diboson__266->GetZaxis()->SetTitleSize(0.05); h_isojet1CSV_Diboson__266->GetZaxis()->SetTickLength(0.025); h_isojet1CSV_Diboson__266->GetZaxis()->SetTitleFont(42); h->Add(h_isojet1CSV_Diboson,""); TH1D *h_isojet1CSV_ZpLjets__267 = new TH1D("h_isojet1CSV_ZpLjets__267","",10,0,1); h_isojet1CSV_ZpLjets__267->SetBinContent(1,0.00997839); h_isojet1CSV_ZpLjets__267->SetBinContent(2,0.01450317); h_isojet1CSV_ZpLjets__267->SetBinContent(3,0.006432142); h_isojet1CSV_ZpLjets__267->SetBinContent(4,0.004194575); h_isojet1CSV_ZpLjets__267->SetBinContent(5,0.003727646); h_isojet1CSV_ZpLjets__267->SetBinContent(6,0.002569373); h_isojet1CSV_ZpLjets__267->SetBinContent(7,0.001898935); h_isojet1CSV_ZpLjets__267->SetBinContent(8,0.001314676); h_isojet1CSV_ZpLjets__267->SetBinContent(9,0.001323422); h_isojet1CSV_ZpLjets__267->SetBinContent(10,0.001471477); h_isojet1CSV_ZpLjets__267->SetBinError(1,0.0002843835); h_isojet1CSV_ZpLjets__267->SetBinError(2,0.0003526741); h_isojet1CSV_ZpLjets__267->SetBinError(3,0.0002379666); h_isojet1CSV_ZpLjets__267->SetBinError(4,0.0002075278); h_isojet1CSV_ZpLjets__267->SetBinError(5,0.0001971644); h_isojet1CSV_ZpLjets__267->SetBinError(6,0.0001564817); h_isojet1CSV_ZpLjets__267->SetBinError(7,0.0001321731); h_isojet1CSV_ZpLjets__267->SetBinError(8,0.0001133749); h_isojet1CSV_ZpLjets__267->SetBinError(9,0.0001162263); h_isojet1CSV_ZpLjets__267->SetBinError(10,0.0001379738); h_isojet1CSV_ZpLjets__267->SetEntries(24915); h_isojet1CSV_ZpLjets__267->SetStats(0); ci = TColor::GetColor("#3399cc"); h_isojet1CSV_ZpLjets__267->SetFillColor(ci); h_isojet1CSV_ZpLjets__267->GetXaxis()->SetTitle("isojet 1 CSV"); h_isojet1CSV_ZpLjets__267->GetXaxis()->SetLabelFont(42); h_isojet1CSV_ZpLjets__267->GetXaxis()->SetLabelOffset(0.007); h_isojet1CSV_ZpLjets__267->GetXaxis()->SetTitleSize(0.05); h_isojet1CSV_ZpLjets__267->GetXaxis()->SetTickLength(0.025); h_isojet1CSV_ZpLjets__267->GetXaxis()->SetTitleFont(42); h_isojet1CSV_ZpLjets__267->GetYaxis()->SetTitle("a.u."); h_isojet1CSV_ZpLjets__267->GetYaxis()->SetLabelFont(42); h_isojet1CSV_ZpLjets__267->GetYaxis()->SetLabelOffset(0.007); h_isojet1CSV_ZpLjets__267->GetYaxis()->SetTitleSize(0.05); h_isojet1CSV_ZpLjets__267->GetYaxis()->SetTickLength(0.025); h_isojet1CSV_ZpLjets__267->GetYaxis()->SetTitleFont(42); h_isojet1CSV_ZpLjets__267->GetZaxis()->SetLabelFont(42); h_isojet1CSV_ZpLjets__267->GetZaxis()->SetLabelOffset(0.007); h_isojet1CSV_ZpLjets__267->GetZaxis()->SetTitleSize(0.05); h_isojet1CSV_ZpLjets__267->GetZaxis()->SetTickLength(0.025); h_isojet1CSV_ZpLjets__267->GetZaxis()->SetTitleFont(42); h->Add(h_isojet1CSV_Z+jets,""); TH1D *h_isojet1CSV_WpLjets__268 = new TH1D("h_isojet1CSV_WpLjets__268","",10,0,1); h_isojet1CSV_WpLjets__268->SetBinContent(1,0.01060448); h_isojet1CSV_WpLjets__268->SetBinContent(2,0.01194981); h_isojet1CSV_WpLjets__268->SetBinContent(3,0.007295854); h_isojet1CSV_WpLjets__268->SetBinContent(4,0.004201536); h_isojet1CSV_WpLjets__268->SetBinContent(5,0.003315037); h_isojet1CSV_WpLjets__268->SetBinContent(6,0.002154035); h_isojet1CSV_WpLjets__268->SetBinContent(7,0.001704806); h_isojet1CSV_WpLjets__268->SetBinContent(8,0.001590696); h_isojet1CSV_WpLjets__268->SetBinContent(9,0.001506952); h_isojet1CSV_WpLjets__268->SetBinContent(10,0.00135957); h_isojet1CSV_WpLjets__268->SetBinError(1,0.0007760229); h_isojet1CSV_WpLjets__268->SetBinError(2,0.0008063374); h_isojet1CSV_WpLjets__268->SetBinError(3,0.0006567409); h_isojet1CSV_WpLjets__268->SetBinError(4,0.0005519722); h_isojet1CSV_WpLjets__268->SetBinError(5,0.0004860992); h_isojet1CSV_WpLjets__268->SetBinError(6,0.0003673486); h_isojet1CSV_WpLjets__268->SetBinError(7,0.0003806515); h_isojet1CSV_WpLjets__268->SetBinError(8,0.0003677212); h_isojet1CSV_WpLjets__268->SetBinError(9,0.0003252218); h_isojet1CSV_WpLjets__268->SetBinError(10,0.0002763251); h_isojet1CSV_WpLjets__268->SetEntries(3309); h_isojet1CSV_WpLjets__268->SetStats(0); ci = TColor::GetColor("#66cc66"); h_isojet1CSV_WpLjets__268->SetFillColor(ci); h_isojet1CSV_WpLjets__268->GetXaxis()->SetTitle("isojet 1 CSV"); h_isojet1CSV_WpLjets__268->GetXaxis()->SetLabelFont(42); h_isojet1CSV_WpLjets__268->GetXaxis()->SetLabelOffset(0.007); h_isojet1CSV_WpLjets__268->GetXaxis()->SetTitleSize(0.05); h_isojet1CSV_WpLjets__268->GetXaxis()->SetTickLength(0.025); h_isojet1CSV_WpLjets__268->GetXaxis()->SetTitleFont(42); h_isojet1CSV_WpLjets__268->GetYaxis()->SetTitle("a.u."); h_isojet1CSV_WpLjets__268->GetYaxis()->SetLabelFont(42); h_isojet1CSV_WpLjets__268->GetYaxis()->SetLabelOffset(0.007); h_isojet1CSV_WpLjets__268->GetYaxis()->SetTitleSize(0.05); h_isojet1CSV_WpLjets__268->GetYaxis()->SetTickLength(0.025); h_isojet1CSV_WpLjets__268->GetYaxis()->SetTitleFont(42); h_isojet1CSV_WpLjets__268->GetZaxis()->SetLabelFont(42); h_isojet1CSV_WpLjets__268->GetZaxis()->SetLabelOffset(0.007); h_isojet1CSV_WpLjets__268->GetZaxis()->SetTitleSize(0.05); h_isojet1CSV_WpLjets__268->GetZaxis()->SetTickLength(0.025); h_isojet1CSV_WpLjets__268->GetZaxis()->SetTitleFont(42); h->Add(h_isojet1CSV_W+jets,""); TH1D *h_isojet1CSV_TopsPoPLFcP__269 = new TH1D("h_isojet1CSV_TopsPoPLFcP__269","",10,0,1); h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(1,0.09097508); h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(2,0.09232326); h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(3,0.04269338); h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(4,0.02949662); h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(5,0.02281892); h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(6,0.01709603); h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(7,0.01404044); h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(8,0.009499499); h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(9,0.006095059); h_isojet1CSV_TopsPoPLFcP__269->SetBinContent(10,0.003040849); h_isojet1CSV_TopsPoPLFcP__269->SetBinError(1,0.0009372855); h_isojet1CSV_TopsPoPLFcP__269->SetBinError(2,0.0009857636); h_isojet1CSV_TopsPoPLFcP__269->SetBinError(3,0.0007155424); h_isojet1CSV_TopsPoPLFcP__269->SetBinError(4,0.0005977933); h_isojet1CSV_TopsPoPLFcP__269->SetBinError(5,0.0005373378); h_isojet1CSV_TopsPoPLFcP__269->SetBinError(6,0.0004781073); h_isojet1CSV_TopsPoPLFcP__269->SetBinError(7,0.0004489056); h_isojet1CSV_TopsPoPLFcP__269->SetBinError(8,0.0003875753); h_isojet1CSV_TopsPoPLFcP__269->SetBinError(9,0.0003337873); h_isojet1CSV_TopsPoPLFcP__269->SetBinError(10,0.0003173281); h_isojet1CSV_TopsPoPLFcP__269->SetEntries(45754); h_isojet1CSV_TopsPoPLFcP__269->SetStats(0); ci = TColor::GetColor("#cc33cc"); h_isojet1CSV_TopsPoPLFcP__269->SetFillColor(ci); h_isojet1CSV_TopsPoPLFcP__269->GetXaxis()->SetTitle("isojet 1 CSV"); h_isojet1CSV_TopsPoPLFcP__269->GetXaxis()->SetLabelFont(42); h_isojet1CSV_TopsPoPLFcP__269->GetXaxis()->SetLabelOffset(0.007); h_isojet1CSV_TopsPoPLFcP__269->GetXaxis()->SetTitleSize(0.05); h_isojet1CSV_TopsPoPLFcP__269->GetXaxis()->SetTickLength(0.025); h_isojet1CSV_TopsPoPLFcP__269->GetXaxis()->SetTitleFont(42); h_isojet1CSV_TopsPoPLFcP__269->GetYaxis()->SetTitle("a.u."); h_isojet1CSV_TopsPoPLFcP__269->GetYaxis()->SetLabelFont(42); h_isojet1CSV_TopsPoPLFcP__269->GetYaxis()->SetLabelOffset(0.007); h_isojet1CSV_TopsPoPLFcP__269->GetYaxis()->SetTitleSize(0.05); h_isojet1CSV_TopsPoPLFcP__269->GetYaxis()->SetTickLength(0.025); h_isojet1CSV_TopsPoPLFcP__269->GetYaxis()->SetTitleFont(42); h_isojet1CSV_TopsPoPLFcP__269->GetZaxis()->SetLabelFont(42); h_isojet1CSV_TopsPoPLFcP__269->GetZaxis()->SetLabelOffset(0.007); h_isojet1CSV_TopsPoPLFcP__269->GetZaxis()->SetTitleSize(0.05); h_isojet1CSV_TopsPoPLFcP__269->GetZaxis()->SetTickLength(0.025); h_isojet1CSV_TopsPoPLFcP__269->GetZaxis()->SetTitleFont(42); h->Add(h_isojet1CSV_Top (LF),""); TH1D *h_isojet1CSV_TopsPoPHFcP__270 = new TH1D("h_isojet1CSV_TopsPoPHFcP__270","",10,0,1); h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(1,0.01878166); h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(2,0.02708098); h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(3,0.01896531); h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(4,0.01870601); h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(5,0.01924485); h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(6,0.02077131); h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(7,0.02899544); h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(8,0.03698897); h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(9,0.07325594); h_isojet1CSV_TopsPoPHFcP__270->SetBinContent(10,0.2676551); h_isojet1CSV_TopsPoPHFcP__270->SetBinError(1,0.0004640739); h_isojet1CSV_TopsPoPHFcP__270->SetBinError(2,0.0005643558); h_isojet1CSV_TopsPoPHFcP__270->SetBinError(3,0.0004957084); h_isojet1CSV_TopsPoPHFcP__270->SetBinError(4,0.0004766015); h_isojet1CSV_TopsPoPHFcP__270->SetBinError(5,0.0004665302); h_isojet1CSV_TopsPoPHFcP__270->SetBinError(6,0.0005070097); h_isojet1CSV_TopsPoPHFcP__270->SetBinError(7,0.0006476121); h_isojet1CSV_TopsPoPHFcP__270->SetBinError(8,0.0007056579); h_isojet1CSV_TopsPoPHFcP__270->SetBinError(9,0.0009826258); h_isojet1CSV_TopsPoPHFcP__270->SetBinError(10,0.001744809); h_isojet1CSV_TopsPoPHFcP__270->SetEntries(77950); h_isojet1CSV_TopsPoPHFcP__270->SetStats(0); ci = TColor::GetColor("#ff9900"); h_isojet1CSV_TopsPoPHFcP__270->SetFillColor(ci); h_isojet1CSV_TopsPoPHFcP__270->GetXaxis()->SetTitle("isojet 1 CSV"); h_isojet1CSV_TopsPoPHFcP__270->GetXaxis()->SetLabelFont(42); h_isojet1CSV_TopsPoPHFcP__270->GetXaxis()->SetLabelOffset(0.007); h_isojet1CSV_TopsPoPHFcP__270->GetXaxis()->SetTitleSize(0.05); h_isojet1CSV_TopsPoPHFcP__270->GetXaxis()->SetTickLength(0.025); h_isojet1CSV_TopsPoPHFcP__270->GetXaxis()->SetTitleFont(42); h_isojet1CSV_TopsPoPHFcP__270->GetYaxis()->SetTitle("a.u."); h_isojet1CSV_TopsPoPHFcP__270->GetYaxis()->SetLabelFont(42); h_isojet1CSV_TopsPoPHFcP__270->GetYaxis()->SetLabelOffset(0.007); h_isojet1CSV_TopsPoPHFcP__270->GetYaxis()->SetTitleSize(0.05); h_isojet1CSV_TopsPoPHFcP__270->GetYaxis()->SetTickLength(0.025); h_isojet1CSV_TopsPoPHFcP__270->GetYaxis()->SetTitleFont(42); h_isojet1CSV_TopsPoPHFcP__270->GetZaxis()->SetLabelFont(42); h_isojet1CSV_TopsPoPHFcP__270->GetZaxis()->SetLabelOffset(0.007); h_isojet1CSV_TopsPoPHFcP__270->GetZaxis()->SetTitleSize(0.05); h_isojet1CSV_TopsPoPHFcP__270->GetZaxis()->SetTickLength(0.025); h_isojet1CSV_TopsPoPHFcP__270->GetZaxis()->SetTitleFont(42); h->Add(h_isojet1CSV_Top (HF),""); h->Draw("hist"); TH1D *hsum__271 = new TH1D("hsum__271","",10,0,1); hsum__271->SetBinContent(1,0.1393796); hsum__271->SetBinContent(2,0.1586681); hsum__271->SetBinContent(3,0.08197864); hsum__271->SetBinContent(4,0.06142623); hsum__271->SetBinContent(5,0.05359128); hsum__271->SetBinContent(6,0.0447599); hsum__271->SetBinContent(7,0.04846618); hsum__271->SetBinContent(8,0.05074524); hsum__271->SetBinContent(9,0.082468); hsum__271->SetBinContent(10,0.2785168); hsum__271->SetBinError(1,0.002288647); hsum__271->SetBinError(2,0.002167196); hsum__271->SetBinError(3,0.001617233); hsum__271->SetBinError(4,0.001528597); hsum__271->SetBinError(5,0.001538373); hsum__271->SetBinError(6,0.001141764); hsum__271->SetBinError(7,0.001103813); hsum__271->SetBinError(8,0.001058293); hsum__271->SetBinError(9,0.001107265); hsum__271->SetBinError(10,0.002872657); hsum__271->SetEntries(45); hsum__271->SetStats(0); ci = 1202; color = new TColor(ci, 0, 0, 0, " ", 0.99); hsum__271->SetFillColor(ci); hsum__271->SetFillStyle(3003); hsum__271->SetLineWidth(0); hsum__271->GetXaxis()->SetTitle("isojet 1 CSV"); hsum__271->GetXaxis()->SetLabelFont(42); hsum__271->GetXaxis()->SetLabelOffset(0.007); hsum__271->GetXaxis()->SetTitleSize(0.05); hsum__271->GetXaxis()->SetTickLength(0.025); hsum__271->GetXaxis()->SetTitleFont(42); hsum__271->GetYaxis()->SetTitle("a.u."); hsum__271->GetYaxis()->SetLabelFont(42); hsum__271->GetYaxis()->SetLabelOffset(0.007); hsum__271->GetYaxis()->SetTitleSize(0.05); hsum__271->GetYaxis()->SetTickLength(0.025); hsum__271->GetYaxis()->SetTitleFont(42); hsum__271->GetZaxis()->SetLabelFont(42); hsum__271->GetZaxis()->SetLabelOffset(0.007); hsum__271->GetZaxis()->SetTitleSize(0.05); hsum__271->GetZaxis()->SetTickLength(0.025); hsum__271->GetZaxis()->SetTitleFont(42); hsum__271->Draw("e2 same"); TH1D *h_isojet1CSV_Data__272 = new TH1D("h_isojet1CSV_Data__272","",10,0,1); h_isojet1CSV_Data__272->SetBinContent(1,0.138368); h_isojet1CSV_Data__272->SetBinContent(2,0.1592858); h_isojet1CSV_Data__272->SetBinContent(3,0.08381231); h_isojet1CSV_Data__272->SetBinContent(4,0.06152831); h_isojet1CSV_Data__272->SetBinContent(5,0.05196457); h_isojet1CSV_Data__272->SetBinContent(6,0.04475643); h_isojet1CSV_Data__272->SetBinContent(7,0.04833695); h_isojet1CSV_Data__272->SetBinContent(8,0.05059832); h_isojet1CSV_Data__272->SetBinContent(9,0.08235183); h_isojet1CSV_Data__272->SetBinContent(10,0.2789975); h_isojet1CSV_Data__272->SetBinError(1,0.002553194); h_isojet1CSV_Data__272->SetBinError(2,0.002739394); h_isojet1CSV_Data__272->SetBinError(3,0.0019871); h_isojet1CSV_Data__272->SetBinError(4,0.001702564); h_isojet1CSV_Data__272->SetBinError(5,0.001564659); h_isojet1CSV_Data__272->SetBinError(6,0.00145209); h_isojet1CSV_Data__272->SetBinError(7,0.001509057); h_isojet1CSV_Data__272->SetBinError(8,0.001543953); h_isojet1CSV_Data__272->SetBinError(9,0.001969711); h_isojet1CSV_Data__272->SetBinError(10,0.003625484); h_isojet1CSV_Data__272->SetEntries(21226); h_isojet1CSV_Data__272->SetStats(0); h_isojet1CSV_Data__272->SetLineWidth(3); h_isojet1CSV_Data__272->SetMarkerStyle(20); h_isojet1CSV_Data__272->SetMarkerSize(2); h_isojet1CSV_Data__272->GetXaxis()->SetTitle("isojet 1 CSV"); h_isojet1CSV_Data__272->GetXaxis()->SetLabelFont(42); h_isojet1CSV_Data__272->GetXaxis()->SetLabelOffset(0.007); h_isojet1CSV_Data__272->GetXaxis()->SetTitleSize(0.05); h_isojet1CSV_Data__272->GetXaxis()->SetTickLength(0.025); h_isojet1CSV_Data__272->GetXaxis()->SetTitleFont(42); h_isojet1CSV_Data__272->GetYaxis()->SetTitle("a.u."); h_isojet1CSV_Data__272->GetYaxis()->SetLabelFont(42); h_isojet1CSV_Data__272->GetYaxis()->SetLabelOffset(0.007); h_isojet1CSV_Data__272->GetYaxis()->SetTitleSize(0.05); h_isojet1CSV_Data__272->GetYaxis()->SetTickLength(0.025); h_isojet1CSV_Data__272->GetYaxis()->SetTitleFont(42); h_isojet1CSV_Data__272->GetZaxis()->SetLabelFont(42); h_isojet1CSV_Data__272->GetZaxis()->SetLabelOffset(0.007); h_isojet1CSV_Data__272->GetZaxis()->SetTitleSize(0.05); h_isojet1CSV_Data__272->GetZaxis()->SetTickLength(0.025); h_isojet1CSV_Data__272->GetZaxis()->SetTitleFont(42); h_isojet1CSV_Data__272->Draw("elp same"); TLegend *leg = new TLegend(0.6,0.55,0.88,0.9,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(0); TLegendEntry *entry=leg->AddEntry("h_isojet1CSV_Data","Data","ELP"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(3); entry->SetMarkerColor(1); entry->SetMarkerStyle(20); entry->SetMarkerSize(2); entry->SetTextFont(42); entry=leg->AddEntry("h_isojet1CSV_Top (HF)","Top (HF)","F"); ci = TColor::GetColor("#ff9900"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_isojet1CSV_Top (LF)","Top (LF)","F"); ci = TColor::GetColor("#cc33cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_isojet1CSV_W+jets","W+jets","F"); ci = TColor::GetColor("#66cc66"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_isojet1CSV_Z+jets","Z+jets","F"); ci = TColor::GetColor("#3399cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_isojet1CSV_Diboson","Diboson","F"); ci = TColor::GetColor("#9966cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_isojet1CSV_QCD","QCD","F"); ci = TColor::GetColor("#cccccc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); leg->Draw(); leg = new TLegend(0.6,0.55,0.88,0.9,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(0); leg->SetFillStyle(0); entry=leg->AddEntry("h_isojet1CSV_Data","Data","ELP"); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(3); entry->SetMarkerColor(1); entry->SetMarkerStyle(20); entry->SetMarkerSize(2); entry->SetTextFont(42); entry=leg->AddEntry("h_isojet1CSV_Top (HF)","Top (HF)","F"); ci = TColor::GetColor("#ff9900"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_isojet1CSV_Top (LF)","Top (LF)","F"); ci = TColor::GetColor("#cc33cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_isojet1CSV_W+jets","W+jets","F"); ci = TColor::GetColor("#66cc66"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_isojet1CSV_Z+jets","Z+jets","F"); ci = TColor::GetColor("#3399cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_isojet1CSV_Diboson","Diboson","F"); ci = TColor::GetColor("#9966cc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); entry=leg->AddEntry("h_isojet1CSV_QCD","QCD","F"); ci = TColor::GetColor("#cccccc"); entry->SetFillColor(ci); entry->SetFillStyle(1001); entry->SetLineColor(1); entry->SetLineStyle(1); entry->SetLineWidth(1); entry->SetMarkerColor(1); entry->SetMarkerStyle(21); entry->SetMarkerSize(1); entry->SetTextFont(42); leg->Draw(); TLatex * tex = new TLatex(0.18,0.85,"CMS"); tex->SetNDC(); tex->SetTextSize(0.06); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.28,0.85,"Preliminary"); tex->SetNDC(); tex->SetTextFont(52); tex->SetTextSize(0.06); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.9,0.94,"36.6 fb^{-1} (13 TeV)"); tex->SetNDC(); tex->SetTextAlign(31); tex->SetTextFont(42); tex->SetTextSize(0.04); tex->SetLineWidth(2); tex->Draw(); pad1->Modified(); c1->cd(); // ------------>Primitives in pad: pad2 TPad *pad2 = new TPad("pad2", "pad2",0,0.05,1,0.3); pad2->Draw(); pad2->cd(); pad2->Range(-0.1875,-0.8914286,1.0625,0.48); pad2->SetFillColor(0); pad2->SetBorderMode(0); pad2->SetBorderSize(2); pad2->SetGridy(); pad2->SetTickx(1); pad2->SetTicky(1); pad2->SetLeftMargin(0.15); pad2->SetRightMargin(0.05); pad2->SetTopMargin(0); pad2->SetBottomMargin(0.3); pad2->SetFrameFillStyle(0); pad2->SetFrameBorderMode(0); pad2->SetFrameFillStyle(0); pad2->SetFrameBorderMode(0); TH1D *ratio__273 = new TH1D("ratio__273","",10,0,1); ratio__273->SetBinContent(1,-0.00725764); ratio__273->SetBinContent(2,0.003892779); ratio__273->SetBinContent(3,0.0223676); ratio__273->SetBinContent(4,0.001661897); ratio__273->SetBinContent(5,-0.0303539); ratio__273->SetBinContent(6,-7.754564e-05); ratio__273->SetBinContent(7,-0.002666473); ratio__273->SetBinContent(8,-0.002895236); ratio__273->SetBinContent(9,-0.001408637); ratio__273->SetBinContent(10,0.001725793); ratio__273->SetBinError(1,0.0001); ratio__273->SetBinError(2,0.0001); ratio__273->SetBinError(3,0.0001); ratio__273->SetBinError(4,0.0001); ratio__273->SetBinError(5,0.0001); ratio__273->SetBinError(6,0.0001); ratio__273->SetBinError(7,0.0001); ratio__273->SetBinError(8,0.0001); ratio__273->SetBinError(9,0.0001); ratio__273->SetBinError(10,0.0001); ratio__273->SetMinimum(-0.48); ratio__273->SetMaximum(0.48); ratio__273->SetEntries(21236); ratio__273->SetStats(0); ratio__273->SetLineWidth(3); ratio__273->SetMarkerStyle(20); ratio__273->SetMarkerSize(2); ratio__273->GetXaxis()->SetTitle("isojet 1 CSV"); ratio__273->GetXaxis()->SetLabelFont(43); ratio__273->GetXaxis()->SetLabelOffset(0.007); ratio__273->GetXaxis()->SetLabelSize(30); ratio__273->GetXaxis()->SetTitleSize(40); ratio__273->GetXaxis()->SetTickLength(0.025); ratio__273->GetXaxis()->SetTitleOffset(5); ratio__273->GetXaxis()->SetTitleFont(43); ratio__273->GetYaxis()->SetTitle("#frac{Data-Exp}{Exp}"); ratio__273->GetYaxis()->SetNdivisions(5); ratio__273->GetYaxis()->SetLabelFont(43); ratio__273->GetYaxis()->SetLabelOffset(0.007); ratio__273->GetYaxis()->SetLabelSize(30); ratio__273->GetYaxis()->SetTitleSize(40); ratio__273->GetYaxis()->SetTickLength(0.025); ratio__273->GetYaxis()->SetTitleOffset(2.5); ratio__273->GetYaxis()->SetTitleFont(43); ratio__273->GetZaxis()->SetLabelFont(42); ratio__273->GetZaxis()->SetLabelOffset(0.007); ratio__273->GetZaxis()->SetTitleSize(0.05); ratio__273->GetZaxis()->SetTickLength(0.025); ratio__273->GetZaxis()->SetTitleFont(42); ratio__273->Draw("elp"); TH1D *zero__274 = new TH1D("zero__274","",10,0,1); zero__274->SetBinError(1,0.002553194); zero__274->SetBinError(2,0.002739394); zero__274->SetBinError(3,0.0019871); zero__274->SetBinError(4,0.001702564); zero__274->SetBinError(5,0.001564659); zero__274->SetBinError(6,0.00145209); zero__274->SetBinError(7,0.001509057); zero__274->SetBinError(8,0.001543953); zero__274->SetBinError(9,0.001969711); zero__274->SetBinError(10,0.003625484); zero__274->SetEntries(21236); zero__274->SetStats(0); zero__274->SetLineWidth(3); zero__274->SetMarkerStyle(20); zero__274->SetMarkerSize(2); zero__274->GetXaxis()->SetTitle("isojet 1 CSV"); zero__274->GetXaxis()->SetLabelFont(42); zero__274->GetXaxis()->SetLabelOffset(0.007); zero__274->GetXaxis()->SetTitleSize(0.05); zero__274->GetXaxis()->SetTickLength(0.025); zero__274->GetXaxis()->SetTitleFont(42); zero__274->GetYaxis()->SetTitle("a.u."); zero__274->GetYaxis()->SetLabelFont(42); zero__274->GetYaxis()->SetLabelOffset(0.007); zero__274->GetYaxis()->SetTitleSize(0.05); zero__274->GetYaxis()->SetTickLength(0.025); zero__274->GetYaxis()->SetTitleFont(42); zero__274->GetZaxis()->SetLabelFont(42); zero__274->GetZaxis()->SetLabelOffset(0.007); zero__274->GetZaxis()->SetTitleSize(0.05); zero__274->GetZaxis()->SetTickLength(0.025); zero__274->GetZaxis()->SetTitleFont(42); zero__274->Draw("hist same"); TH1D *sumratioup__275 = new TH1D("sumratioup__275","",10,0,1); sumratioup__275->SetBinContent(1,0.01642024); sumratioup__275->SetBinContent(2,0.01365867); sumratioup__275->SetBinContent(3,0.01972749); sumratioup__275->SetBinContent(4,0.02488509); sumratioup__275->SetBinContent(5,0.02870566); sumratioup__275->SetBinContent(6,0.02550863); sumratioup__275->SetBinContent(7,0.02277492); sumratioup__275->SetBinContent(8,0.02085501); sumratioup__275->SetBinContent(9,0.01342661); sumratioup__275->SetBinContent(10,0.01031412); sumratioup__275->SetBinError(1,0.002288647); sumratioup__275->SetBinError(2,0.002167196); sumratioup__275->SetBinError(3,0.001617233); sumratioup__275->SetBinError(4,0.001528597); sumratioup__275->SetBinError(5,0.001538373); sumratioup__275->SetBinError(6,0.001141764); sumratioup__275->SetBinError(7,0.001103813); sumratioup__275->SetBinError(8,0.001058293); sumratioup__275->SetBinError(9,0.001107265); sumratioup__275->SetBinError(10,0.002872657); sumratioup__275->SetEntries(55); sumratioup__275->SetStats(0); ci = 1202; color = new TColor(ci, 0, 0, 0, " ", 0.99); sumratioup__275->SetFillColor(ci); sumratioup__275->SetFillStyle(3003); sumratioup__275->GetXaxis()->SetTitle("isojet 1 CSV"); sumratioup__275->GetXaxis()->SetLabelFont(42); sumratioup__275->GetXaxis()->SetLabelOffset(0.007); sumratioup__275->GetXaxis()->SetTitleSize(0.05); sumratioup__275->GetXaxis()->SetTickLength(0.025); sumratioup__275->GetXaxis()->SetTitleFont(42); sumratioup__275->GetYaxis()->SetTitle("a.u."); sumratioup__275->GetYaxis()->SetLabelFont(42); sumratioup__275->GetYaxis()->SetLabelOffset(0.007); sumratioup__275->GetYaxis()->SetTitleSize(0.05); sumratioup__275->GetYaxis()->SetTickLength(0.025); sumratioup__275->GetYaxis()->SetTitleFont(42); sumratioup__275->GetZaxis()->SetLabelFont(42); sumratioup__275->GetZaxis()->SetLabelOffset(0.007); sumratioup__275->GetZaxis()->SetTitleSize(0.05); sumratioup__275->GetZaxis()->SetTickLength(0.025); sumratioup__275->GetZaxis()->SetTitleFont(42); sumratioup__275->Draw("hist same"); TH1D *sumratiodown__276 = new TH1D("sumratiodown__276","",10,0,1); sumratiodown__276->SetBinContent(1,-0.01642024); sumratiodown__276->SetBinContent(2,-0.01365867); sumratiodown__276->SetBinContent(3,-0.01972749); sumratiodown__276->SetBinContent(4,-0.02488509); sumratiodown__276->SetBinContent(5,-0.02870566); sumratiodown__276->SetBinContent(6,-0.02550863); sumratiodown__276->SetBinContent(7,-0.02277492); sumratiodown__276->SetBinContent(8,-0.02085501); sumratiodown__276->SetBinContent(9,-0.01342661); sumratiodown__276->SetBinContent(10,-0.01031412); sumratiodown__276->SetBinError(1,0.002288647); sumratiodown__276->SetBinError(2,0.002167196); sumratiodown__276->SetBinError(3,0.001617233); sumratiodown__276->SetBinError(4,0.001528597); sumratiodown__276->SetBinError(5,0.001538373); sumratiodown__276->SetBinError(6,0.001141764); sumratiodown__276->SetBinError(7,0.001103813); sumratiodown__276->SetBinError(8,0.001058293); sumratiodown__276->SetBinError(9,0.001107265); sumratiodown__276->SetBinError(10,0.002872657); sumratiodown__276->SetEntries(55); sumratiodown__276->SetStats(0); ci = 1202; color = new TColor(ci, 0, 0, 0, " ", 0.99); sumratiodown__276->SetFillColor(ci); sumratiodown__276->SetFillStyle(3003); sumratiodown__276->GetXaxis()->SetTitle("isojet 1 CSV"); sumratiodown__276->GetXaxis()->SetLabelFont(42); sumratiodown__276->GetXaxis()->SetLabelOffset(0.007); sumratiodown__276->GetXaxis()->SetTitleSize(0.05); sumratiodown__276->GetXaxis()->SetTickLength(0.025); sumratiodown__276->GetXaxis()->SetTitleFont(42); sumratiodown__276->GetYaxis()->SetTitle("a.u."); sumratiodown__276->GetYaxis()->SetLabelFont(42); sumratiodown__276->GetYaxis()->SetLabelOffset(0.007); sumratiodown__276->GetYaxis()->SetTitleSize(0.05); sumratiodown__276->GetYaxis()->SetTickLength(0.025); sumratiodown__276->GetYaxis()->SetTitleFont(42); sumratiodown__276->GetZaxis()->SetLabelFont(42); sumratiodown__276->GetZaxis()->SetLabelOffset(0.007); sumratiodown__276->GetZaxis()->SetTitleSize(0.05); sumratiodown__276->GetZaxis()->SetTickLength(0.025); sumratiodown__276->GetZaxis()->SetTitleFont(42); sumratiodown__276->Draw("hist same"); Double_t Graph0_fx1023[10] = { 0.05, 0.15, 0.25, 0.35, 0.45, 0.55, 0.65, 0.75, 0.85, 0.95}; Double_t Graph0_fy1023[10] = { -0.00725764, 0.003892779, 0.0223676, 0.001661897, -0.0303539, -7.754564e-05, -0.002666473, -0.002895236, -0.001408637, 0.001725793}; Double_t Graph0_fex1023[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; Double_t Graph0_fey1023[10] = { 0.01831827, 0.01726493, 0.02423924, 0.02771721, 0.02919614, 0.03244177, 0.03113628, 0.03042557, 0.02388455, 0.01301711}; TGraphErrors *gre = new TGraphErrors(10,Graph0_fx1023,Graph0_fy1023,Graph0_fex1023,Graph0_fey1023); gre->SetName("Graph0"); gre->SetTitle("Graph"); gre->SetFillColor(1); gre->SetLineWidth(3); TH1F *Graph_Graph1023 = new TH1F("Graph_Graph1023","Graph",100,0,1.04); Graph_Graph1023->SetMinimum(-0.07016574); Graph_Graph1023->SetMaximum(0.05722253); Graph_Graph1023->SetDirectory(0); Graph_Graph1023->SetStats(0); ci = TColor::GetColor("#000099"); Graph_Graph1023->SetLineColor(ci); Graph_Graph1023->GetXaxis()->SetLabelFont(42); Graph_Graph1023->GetXaxis()->SetLabelOffset(0.007); Graph_Graph1023->GetXaxis()->SetTitleSize(0.05); Graph_Graph1023->GetXaxis()->SetTickLength(0.025); Graph_Graph1023->GetXaxis()->SetTitleFont(42); Graph_Graph1023->GetYaxis()->SetLabelFont(42); Graph_Graph1023->GetYaxis()->SetLabelOffset(0.007); Graph_Graph1023->GetYaxis()->SetTitleSize(0.05); Graph_Graph1023->GetYaxis()->SetTickLength(0.025); Graph_Graph1023->GetYaxis()->SetTitleFont(42); Graph_Graph1023->GetZaxis()->SetLabelFont(42); Graph_Graph1023->GetZaxis()->SetLabelOffset(0.007); Graph_Graph1023->GetZaxis()->SetTitleSize(0.05); Graph_Graph1023->GetZaxis()->SetTickLength(0.025); Graph_Graph1023->GetZaxis()->SetTitleFont(42); gre->SetHistogram(Graph_Graph1023); gre->Draw("pe0"); pad2->Modified(); c1->cd(); c1->Modified(); c1->cd(); c1->SetSelected(c1); }
void allCutFlow(){ 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); //MC TH1D* tt = getSample("TTJet", lumi*225.2/6920475); //TH1D* wjets = getSample("W1Jet", lumi*37509/57708550); TH1D* wjets = 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* zjets = 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* qcd = 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* single_t = getSample("T_t-channel", lumi*56.4/3757707); 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); TH1D* all_MC = getSample("TTJet", lumi*225.2/6920475); THStack *hs = new THStack("hs","test"); 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); hs->Add(qcd); zjets->Add(z2jets); zjets->Add(z3jets); zjets->Add(z4jets); hs->Add(zjets); wjets->Add(w2jets); wjets->Add(w3jets); wjets->Add(w4jets); 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); 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); TH1D * allMC = (TH1D*) tt->Clone("all"); allMC->Add(wjets);allMC->Add(zjets);allMC->Add(single_t);allMC->Add(qcd); TH1D* dataEff = new TH1D("cut eff","cut eff",10,0,10); TH1D* mcEff = new TH1D("cut eff","cut eff",10,0,10); TString step[11] = {"Skim" ,"Cleaning and HLT","one isolated #mu", "loose #mu veto", "loose e veto", "#geq 1 jets", "#geq 2 jets","#geq 3 jets", "#geq 4 jets", "#geq1 CSV b-tag", "#geq2 CSV b-tag" }; dataEff->Sumw2(); for(int i =1; i<11; i++){ mcEff->GetXaxis()->SetBinLabel(i, step[i]); dataEff->SetBinContent(i, data->GetBinContent(i+1)/data->GetBinContent(i)); dataEff->SetBinError(i, sqrt(pow(data->GetBinContent(i+1),2)+pow(data->GetBinContent(i),2))); mcEff->SetBinContent(i, allMC->GetBinContent(i+1)/allMC->GetBinContent(i)); } TCanvas *c2 = new TCanvas("cutflow eff","cutflow eff",600, 500); mcEff->SetLineColor(kRed); mcEff->Draw(); dataEff->Draw("Esame"); TLegend *tleg3; tleg3 = new TLegend(0.7,0.7,0.8,0.9); tleg3->SetTextSize(0.04); tleg3->SetBorderSize(0); tleg3->SetFillColor(10); tleg3->AddEntry(dataEff , "data", "l"); tleg3->AddEntry(mcEff , "mc", "l"); tleg3->Draw("same"); c2->SaveAs("plots/cutFlow/cutEff_data.png"); delete c2; //draw histos to files TCanvas *c1 = new TCanvas("cutflow","cutflow",900, 600); hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.3); if(logPlot ==true) hs->SetMinimum(10000.); hs->Draw(); for(int i =0; i<tt->GetNbinsX(); i++) hs->GetXaxis()->SetBinLabel(i+1, step[i]); 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.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/cutFlow/"); if(logPlot ==true){ plotName += Variable+"_Log"; plotName += Nbtags+".png"; }else{ plotName += Variable+""; plotName += Nbtags+".png"; } c1->SaveAs(plotName); delete c1; //print out std::cout.setf(std::ios::fixed); std::cout.precision(0); cout << " & ttbar & wjets & zjets & single-t & qcd & all MC & data " << endl; for(int i = 0; i < tt->GetNbinsX(); i++){ cout << step[i] << " & " << tt->GetBinContent(i+1) << " $\\pm$ " << tt->GetBinError(i+1) << " & " << wjets->GetBinContent(i+1) << " $\\pm$ " << wjets->GetBinError(i+1) << " & " << zjets->GetBinContent(i+1) << " $\\pm$ " << zjets->GetBinError(i+1) << " & " << single_t->GetBinContent(i+1) << " $\\pm$ " << single_t->GetBinError(i+1) << " & " << qcd->GetBinContent(i+1) << " $\\pm$ " << qcd->GetBinError(i+1) << " & " << allMC->GetBinContent(i+1) << " $\\pm$ " << allMC->GetBinError(i+1) << " & " << data->GetBinContent(i+1) << " $\\pm$ " << data->GetBinError(i+1) << endl; } } }