void CutFlow::standardCutFlowPlot(TH1D* data, THStack *hs, AllSamples samples, Variable variable){ //Style TdrStyle style; style.setTDRStyle(); //draw histos to files TCanvas *c1 = new TCanvas("Plot","Plot",900, 600); data->Draw(); hs->Draw("hist"); setBinLabels(hs, data); if(Globals::addHashErrors){ TH1D* hashErrs = hashErrors(samples, variable); hashErrs->Draw("same e2"); } data->Draw("E same"); data->SetMarkerStyle(20); data->SetMarkerSize(0.5); hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.3); hs->GetXaxis()->SetLimits(variable.minX, variable.maxX); hs->GetXaxis()->SetTitle(variable.xTitle); hs->GetXaxis()->SetTitleSize(0.05); hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05); TLegend* leg = legend(samples); leg->Draw(); TText* textChan = doChan(0.12,0.96); textChan->Draw(); TText* textPrelim = doPrelim(0.58,0.96); textPrelim->Draw(); c1->SetLogy(); c1->SaveAs("Plots/ControlPlots/"+objName+"/Log/"+variable.name+".png"); c1->SaveAs("Plots/ControlPlots/"+objName+"/Log/"+variable.name+".pdf"); delete c1; delete leg; delete textChan; delete textPrelim; }
void Plots2D::standardPlot(TH2D* ttbar, Variable variable){ //Style TdrStyle style; style.setTDRStyle(); gStyle->SetPalette(1); gStyle->SetPadRightMargin(0.12); //draw histos to files TCanvas *c1 = new TCanvas("Plot","Plot",900, 800); ttbar->Draw("COLZ"); // ttbar->SetMaximum(ttbar->GetBinContent(ttbar->GetMaximumBin())*1.3); ttbar->SetAxisRange(variable.minX, variable.maxX, "X"); ttbar->SetAxisRange(variable.minX, variable.maxX, "Y"); ttbar->GetXaxis()->SetTitle("Gen " +variable.xTitle); ttbar->GetXaxis()->SetTitleSize(0.05); ttbar->GetYaxis()->SetTitle("Reco " +variable.xTitle); ttbar->GetYaxis()->SetTitleSize(0.05); for(unsigned int i = 0; i < bins.size(); i++){ TLine *line = new TLine(bins[i],variable.minX,bins[i], variable.maxX); TLine *liney = new TLine(variable.minX,bins[i], variable.maxX, bins[i]); line->SetLineWidth(2); liney->SetLineWidth(2); liney->Draw(); line->Draw(); } TText* textChan = doChan(0.12,0.96); textChan->Draw(); TText* textPrelim = doPrelim(0.58,0.96); textPrelim->Draw(); c1->SaveAs("Plots/ControlPlots/2DPlots/"+variable.name+".png"); c1->SaveAs("Plots/ControlPlots/2DPlots/"+variable.name+".pdf"); delete c1; delete textChan; delete textPrelim; }
void CutFlow::ratioCutFlowPlot(TH1D* data, THStack *hs, AllSamples samples, Variable variable){ //draw histos with ratio plot float r = 0.3; float epsilon = 0.02; TCanvas *c2 = new TCanvas("Plot","Plot",635, 600); c2->SetFillColor(0); c2->SetFrameFillStyle(0); TPad *pad1 = new TPad("pad1","pad1",0,r-epsilon,1,1); pad1->SetBottomMargin(epsilon); c2->cd(); pad1->Draw(); pad1->cd(); hs->Draw("hist"); hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.3); hs->GetXaxis()->SetLimits(variable.minX, variable.maxX); hs->GetXaxis()->SetTitle(variable.xTitle); hs->GetXaxis()->SetTitleSize(0.05); hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05); if(Globals::addHashErrors){ TH1D* hashErrs = hashErrors(samples, variable); hashErrs->Draw("same e2"); } data->Draw("E same"); //data->SetMarkerStyle(20); data->SetMarkerSize(0.5); TLegend* leg = legend(samples); leg->Draw(); TText* textChan = doChan(0.12,0.96); textChan->Draw(); TText* textPrelim = doPrelim(0.58,0.96); textPrelim->Draw(); TPad *pad2 = new TPad("pad2","pad2",0,0,1,r*(1-epsilon)); pad2->SetTopMargin(0); pad2->SetFrameFillStyle(4000); pad2->SetBottomMargin(0.4); c2->cd(); pad2->Draw(); pad2->cd(); TH1D * allMC = allMChisto(samples, variable); TH1D * ratio = (TH1D*)data->Clone("ratio plot"); ratio->Sumw2(); ratio->SetStats(0); cout << "ratio bins: " << ratio->GetNbinsX() << endl; cout << "all mc bins: " << allMC->GetNbinsX() << endl; ratio->Divide(allMC); ratio->SetMaximum(2); ratio->SetMinimum(0.); setBinLabels(hs, ratio); // Will need to see if this works in other situations ratio->SetLabelSize(0.1, "X"); ratio->SetTitleOffset(0.5, "Y"); ratio->SetTitleOffset(0.8, "X"); ratio->GetYaxis()->SetTitle("data/MC");ratio->GetYaxis()->SetTitleSize(0.1); ratio->GetXaxis()->SetTitle(variable.xTitle);ratio->GetXaxis()->SetTitleSize(0.15); ratio->Draw("ep"); TLine *line = new TLine(variable.minX,1,variable.maxX,1); line->Draw(); pad1->cd(); pad1->SetLogy(); c2->SaveAs("Plots/ControlPlots/"+objName+"/Log/"+variable.name+"_ratio.png"); c2->SaveAs("Plots/ControlPlots/"+objName+"/Log/"+variable.name+"_ratio.pdf"); delete c2; delete leg; delete textChan; delete textPrelim; }