void plot(int mass) { double myQCDRelUncert = 0.038; double myEWKRelUncert = 0.131; double myFakesRelUncert = 0.238; double delta = 1.4; double br = 0.05; bool debug = false; bool log = false; double ymin = 0.001; double ymax = 48; static bool bMessage = false; if (!bMessage) { cout << "Values used as relative uncertainty (please check):" << endl; cout << " QCD: " << myQCDRelUncert << endl; cout << " EWK genuine tau: " << myEWKRelUncert << endl; cout << " EWK fake tau: " << myFakesRelUncert << endl << endl; bMessage = true; } cout << "Processing mass point: " << mass << " GeV/c2" << endl; gStyle->SetOptFit(1); gStyle->SetOptStat(0); gStyle->SetOptTitle(0); gStyle->SetTitleFont(43, "xyz"); gStyle->SetTitleSize(33, "xyz"); gStyle->SetLabelFont(43, "xyz"); gStyle->SetLabelSize(27, "xyz"); //std::string infile = "EPS_data_nodeltaphi/hplus_100.root"; //std::string infile = "EPS_data_deltaphi160/hplus_100.root"; std::stringstream s; s << "lands_histograms_hplushadronic_m" << mass << ".root"; std::string infile = s.str(); // Canvas TCanvas *myCanvas = new TCanvas("myCanvas", "",0,0,600,600); myCanvas->SetHighLightColor(2); myCanvas->Range(0,0,1,1); myCanvas->SetFillColor(0); myCanvas->SetBorderMode(0); myCanvas->SetBorderSize(2); if (log) myCanvas->SetLogy(); myCanvas->SetTickx(1); myCanvas->SetTicky(1); myCanvas->SetLeftMargin(0.16); myCanvas->SetRightMargin(0.05); myCanvas->SetTopMargin(0.05); myCanvas->SetBottomMargin(0.08); myCanvas->SetFrameFillStyle(0); myCanvas->SetFrameBorderMode(0); myCanvas->SetFrameFillStyle(0); myCanvas->SetFrameBorderMode(0); myCanvas->cd(); Int_t ci; TFile* f = TFile::Open(infile.c_str()); s.str(""); s << "HW" << mass << "_1"; TH1* hw = (TH1*)f->Get(s.str().c_str()); s.str(""); s << "HH" << mass << "_1"; TH1* hh = (TH1*)f->Get(s.str().c_str()); TH1* data = (TH1*)f->Get("data_obs"); data->SetLineWidth(2); data->SetMarkerStyle(20); data->SetMarkerSize(1.2); TH1* ewktau = (TH1*)f->Get("EWK_Tau"); ci = TColor::GetColor("#993399"); ewktau->SetFillColor(ci); ewktau->SetLineWidth(0); TH1* ewkDY = (TH1*)f->Get("EWK_DYx"); TH1* ewkVV = (TH1*)f->Get("EWK_VVx"); ewktau->Add(ewkDY); ewktau->Add(ewkVV); //TH1* qcd = (TH1*)f->Get("QCDInv"); TH1* qcd = (TH1*)f->Get("QCD"); ci = TColor::GetColor("#ffcc33"); qcd->SetFillColor(ci); qcd->SetLineWidth(0); TH1* fakett = (TH1*)f->Get("fake_tt"); ci = TColor::GetColor("#669900"); fakett->SetFillColor(ci); fakett->SetLineWidth(0); TH1* fakeW = (TH1*)f->Get("fake_W"); ci = TColor::GetColor("#cc3300"); fakeW->SetFillColor(ci); fakeW->SetLineWidth(0); TH1* faket = (TH1*)f->Get("fake_t"); TH1F *hFrame = new TH1F("hFrame","",20,0,400); hFrame->SetMinimum(ymin); if (log) hFrame->SetMaximum(ymax*1.5); else hFrame->SetMaximum(ymax); hFrame->SetDirectory(0); hFrame->SetStats(0); hFrame->SetLineStyle(0); hFrame->SetMarkerStyle(20); hFrame->SetXTitle("Transverse mass (#tau jet, E_{T}^{miss}), (GeV/c^{2})"); if (paperStatus) hFrame->SetXTitle("Transverse mass (#tau_{h}, E_{T}^{miss}), (GeV/c^{2})"); hFrame->SetYTitle("Events / 20 GeV/c^{2}"); hFrame->GetXaxis()->SetTitleSize(0); hFrame->GetXaxis()->SetLabelSize(0); hFrame->GetYaxis()->SetTitleFont(43); hFrame->GetYaxis()->SetTitleSize(27); hFrame->GetYaxis()->SetTitleOffset(1.3); // signal hh->Scale(br*br); hw->Scale(2*br*(1.0-br)); TH1* signal = (TH1*)hh->Clone(); signal->Add(hw); ci = TColor::GetColor("#ff3399"); signal->SetLineColor(ci); signal->SetLineStyle(2); signal->SetLineWidth(2); // Fakes TH1* fakes = (TH1*)(fakett->Clone()); fakes->Add(fakeW); fakes->Add(faket); // stacked backgrounds THStack *exp = new THStack(); exp->SetName("exp"); exp->SetTitle("exp"); exp->Add(fakes); exp->Add(ewktau); exp->Add(qcd); exp->Add(signal); TH1* hExpBkg = (TH1*)fakes->Clone(); hExpBkg->Add(ewktau); hExpBkg->Add(qcd); // uncertainty TH1* uncert = (TH1*)fakeW->Clone(); uncert->Add(fakett); uncert->Add(ewktau); uncert->Add(qcd); uncert->SetFillColor(1); uncert->SetFillStyle(3344); uncert->SetLineColor(0); uncert->SetLineStyle(0); uncert->SetLineWidth(0); TH1* hExpBkgTotalUncert = (TH1*)uncert->Clone(); hExpBkgTotalUncert->SetFillStyle(3354); TH1* hAgreement = (TH1*)data->Clone(); hAgreement->Divide(hExpBkg); TGraphErrors* hAgreementRelUncert = new TGraphErrors(hAgreement->GetNbinsX()); hAgreementRelUncert->SetLineWidth(2); hAgreementRelUncert->SetLineColor(kBlack); for (int i = 1; i <= hFrame->GetNbinsX(); ++i) { double myQCDTotalUncert = TMath::Power(qcd->GetBinError(i), 2) + TMath::Power(qcd->GetBinContent(i)*myQCDRelUncert, 2); double myEWKTotalUncert = TMath::Power(ewktau->GetBinError(i), 2) + TMath::Power(ewktau->GetBinContent(i)*myEWKRelUncert, 2); double myFakesTotalUncert = TMath::Power(fakes->GetBinError(i), 2) + TMath::Power(fakes->GetBinContent(i)*myFakesRelUncert, 2); hExpBkgTotalUncert->SetBinError(i, TMath::Sqrt(myQCDTotalUncert + myEWKTotalUncert + myFakesTotalUncert)); if (hExpBkg->GetBinContent(i) > 0) { hAgreementRelUncert->SetPoint(i-1, hExpBkg->GetBinCenter(i), data->GetBinContent(i) / hExpBkg->GetBinContent(i)); double myUncertData = 0; if (data->GetBinContent(i) > 0) myUncertData = TMath::Power(data->GetBinError(i) / data->GetBinContent(i), 2); double myUncertBkg = (myQCDTotalUncert + myEWKTotalUncert + myFakesTotalUncert) / TMath::Power(hExpBkg->GetBinContent(i), 2); hAgreementRelUncert->SetPointError(i-1, 0, data->GetBinContent(i) / hExpBkg->GetBinContent(i) * TMath::Sqrt(myUncertData + myUncertBkg)); } else { hAgreementRelUncert->SetPoint(i-1, hExpBkg->GetBinCenter(i), 0); hAgreementRelUncert->SetPointError(i-1, 0, 0); } if (debug) { cout << "Point: " << hAgreementRelUncert->GetX()[i-1]-10 << "-" << hAgreementRelUncert->GetX()[i-1]+10 << " GeV/c2, agreement: " << hAgreementRelUncert->GetY()[i-1] << ", uncert: " << hAgreement->GetBinError(i) << ", " << hAgreementRelUncert->GetErrorY(i-1) << endl; cout << " bkg. stat. uncert. " << hExpBkg->GetBinError(i) << " (i.e. " << hExpBkg->GetBinError(i) / hExpBkg->GetBinContent(i) * 100.0 << " %)" << ", stat+syst uncert. " << TMath::Sqrt(myQCDTotalUncert + myEWKTotalUncert + myFakesTotalUncert) << " (i.e. " << TMath::Sqrt(myQCDTotalUncert + myEWKTotalUncert + myFakesTotalUncert) / hExpBkg->GetBinContent(i) * 100.0 << " %)" << endl; } } // Agreement pad TPad* pad = new TPad("ratiopad","ratiopad",0.,0.,1.,.3); pad->Draw(); pad->cd(); pad->Range(0,0,1,1); pad->SetFillColor(0); pad->SetFillStyle(4000); pad->SetBorderMode(0); pad->SetBorderSize(2); pad->SetTickx(1); pad->SetTicky(1); pad->SetLeftMargin(0.16); pad->SetRightMargin(0.05); pad->SetTopMargin(0); pad->SetBottomMargin(0.34); pad->SetFrameFillStyle(0); pad->SetFrameBorderMode(0); // Plot here ratio if (1.0-delta > 0) hAgreement->SetMinimum(1.0-delta); else hAgreement->SetMinimum(0.); hAgreement->SetMaximum(1.0+delta); hAgreement->GetXaxis()->SetLabelOffset(0.007); hAgreement->GetXaxis()->SetLabelFont(43); hAgreement->GetXaxis()->SetLabelSize(27); hAgreement->GetYaxis()->SetLabelFont(43); hAgreement->GetYaxis()->SetLabelSize(27); hAgreement->GetYaxis()->SetLabelOffset(0.007); hAgreement->GetYaxis()->SetNdivisions(505); hAgreement->GetXaxis()->SetTitleFont(43); hAgreement->GetYaxis()->SetTitleFont(43); hAgreement->GetXaxis()->SetTitleSize(33); hAgreement->GetYaxis()->SetTitleSize(33); hAgreement->SetTitleSize(27, "xyz"); hAgreement->GetXaxis()->SetTitleOffset(3.2); hAgreement->GetYaxis()->SetTitleOffset(1.3); hAgreement->SetXTitle(hFrame->GetXaxis()->GetTitle()); hAgreement->SetYTitle("Data/#Sigmabkg"); hAgreement->Draw("e2"); // Plot line at zero TH1* hAgreementLine = dynamic_cast<TH1*>(hAgreement->Clone()); for (int i = 1; i <= hAgreementLine->GetNbinsX(); ++i) { hAgreementLine->SetBinContent(i,1.0); hAgreementLine->SetBinError(i,0.0); } hAgreementLine->SetLineColor(kRed); hAgreementLine->SetLineWidth(2); hAgreementLine->SetLineStyle(3); hAgreementLine->Draw("hist same"); hAgreement->Draw("same"); hAgreementRelUncert->Draw("[]"); pad->RedrawAxis(); myCanvas->cd(); TPad* plotpad = new TPad("plotpad", "plotpad",0,0.3,1.,1.); plotpad->Draw(); plotpad->cd(); plotpad->Range(0,0,1,1); plotpad->SetFillColor(0); plotpad->SetFillStyle(4000); plotpad->SetBorderMode(0); plotpad->SetBorderSize(2); //if (logy) // plotpad->SetLogy(); plotpad->SetTickx(1); plotpad->SetTicky(1); plotpad->SetLeftMargin(0.16); plotpad->SetRightMargin(0.05); plotpad->SetTopMargin(0.065); plotpad->SetBottomMargin(0.0); plotpad->SetFrameFillStyle(0); plotpad->SetFrameBorderMode(0); hFrame->GetXaxis()->SetTitleSize(0); hFrame->GetXaxis()->SetLabelSize(0); hFrame->GetYaxis()->SetTitleFont(43); hFrame->GetYaxis()->SetTitleSize(33); hFrame->GetYaxis()->SetTitleOffset(1.3); // Draw objects hFrame->Draw(); exp->Draw("hist same"); uncert->Draw("E2 same"); hExpBkgTotalUncert->Draw("E2 same"); // Data data->Draw("same"); //signal->Draw("same"); TLegend *leg = new TLegend(0.53,0.6,0.87,0.91,NULL,"brNDC"); leg->SetBorderSize(0); leg->SetTextFont(63); leg->SetTextSize(18); leg->SetLineColor(1); leg->SetLineStyle(1); leg->SetLineWidth(1); leg->SetFillColor(kWhite); //leg->SetFillStyle(4000); // enabling this will cause the plot to be erased from the pad TLegendEntry* entry = leg->AddEntry(data, "Data", "P"); s.str(""); s << "with H^{#pm}#rightarrow#tau^{#pm}#nu"; entry = leg->AddEntry(signal, s.str().c_str(), "L"); entry = leg->AddEntry(qcd, "QCD (meas.)", "F"); entry = leg->AddEntry(ewktau, "EWK genuine #tau (meas.)", "F"); entry = leg->AddEntry(fakes, "EWK fake #tau (MC)", "F"); entry = leg->AddEntry(uncert, "stat. uncert.", "F"); entry = leg->AddEntry(hExpBkgTotalUncert, "stat. #oplus syst. uncert.", "F"); leg->Draw(); string myTitle = "CMS Preliminary"; if (paperStatus) myTitle = "CMS"; TLatex *tex = new TLatex(0.62,0.945,myTitle.c_str()); tex->SetNDC(); tex->SetTextFont(43); tex->SetTextSize(27); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.2,0.945,"#sqrt{s} = 7 TeV"); tex->SetNDC(); tex->SetTextFont(43); tex->SetTextSize(27); tex->SetLineWidth(2); tex->Draw(); tex = new TLatex(0.43,0.945,"2.2 fb^{-1}"); tex->SetNDC(); tex->SetTextFont(43); tex->SetTextSize(27); tex->SetLineWidth(2); tex->Draw(); s.str(""); s << "m_{H^{#pm}} = " << mass << " GeV/c^{2}"; tex = new TLatex(0.28,0.865,s.str().c_str()); tex->SetNDC(); tex->SetTextFont(63); tex->SetTextSize(20); tex->SetLineWidth(2); tex->Draw(); s.str(""); s << "BR(t#rightarrowbH^{#pm})=" << setprecision(2) << br; tex = new TLatex(0.28,0.805,s.str().c_str()); tex->SetNDC(); tex->SetTextFont(63); tex->SetTextSize(20); tex->SetLineWidth(2); tex->Draw(); plotpad->RedrawAxis(); plotpad->Modified(); s.str(""); s << "mT_datadriven_m" << mass << ".png"; myCanvas->Print(s.str().c_str()); s.str(""); s << "mT_datadriven_m" << mass << ".C"; myCanvas->Print(s.str().c_str()); s.str(""); s << "mT_datadriven_m" << mass << ".eps"; myCanvas->Print(s.str().c_str()); }
//void makeHist(const int sample, const int dataset=1) void makeHist(const string title="") { vector<Hist> hist2print; TPaveText *tx = new TPaveText(.05,.1,.95,.8); // tx->AddText("Using Deafult JERs for all jets"); // tx->AddText("Using b-Jet JERs"); /* string title("QCD MG:"); //if (sample==1) title += "NJet(70/50/30>=2/4/5), #slash{E}_{T}>175, Triplet>1, 80<TopMass<270, TOP+0.5*BJET>500, MT2>300, #Delta#Phi(.5,.5,.3), BJets>=1"; if (sample==1) title += "All Stop cuts applied (use default JERs for all jets)"; else if (sample==2) title += "All Stop cuts applied + Inverted #Delta#Phi (use default JERs for all jets)"; else if (sample==3) title += "All Stop cuts applied (use b-Jet JERs)"; else if (sample==4) title += "All Stop cuts applied + Inverted #Delta#Phi (use b-Jet JERs)"; else if (sample==5) title += "No cuts applied"; */ unsigned bitMaskArray[] = {0,1,2,3,129,130,131,195,257,258,269,323}; vector<unsigned> vBitMaskArray(bitMaskArray, bitMaskArray + sizeof(bitMaskArray) / sizeof(unsigned)); stringstream unclmet_title; unclmet_title << title << "Unclutered MET"; hist2print.push_back(Hist("met",title,2,0.0, 400.0,1)); hist2print.push_back(Hist("unclmet",unclmet_title.str().c_str(),2,0.0, 100.0,1)); hist2print.push_back(Hist("mht",title,2,0.0, 400.0,1)); hist2print.push_back(Hist("ht",title,2,0,2000,1)); hist2print.push_back(Hist("njet30eta5p0",title,1,0,15,1)); hist2print.push_back(Hist("nbjets",title,1,0,10,1)); // hist2print.push_back(Hist("bjetPt",title,2)); hist2print.push_back(Hist("M123",title,2)); // hist2print.push_back(Hist("M23overM123",title)); hist2print.push_back(Hist("MT2",title,2)); hist2print.push_back(Hist("MTb",title,4)); hist2print.push_back(Hist("MTt",title,4)); hist2print.push_back(Hist("MTb_p_MTt",title,2,400,1000,1)); //hist2print.push_back(Hist("jet1_pt",title,2)); //hist2print.push_back("bjetPt"); // hist2print.push_back(Hist("bjetMass",title,2,0,200)); // hist2print.push_back(Hist("dphimin",title,4)); TFile *outRootFile = new TFile("Merged.root"); /*TPad *c1=0, *c2=0; TCanvas *c = GetCanvas(c1, c2); if (c ==NULL|| c1 == 0 ||c2 == 0) { cout << " A drawing pad is null !"<< endl; cout << "c = " << c << endl; cout << "c1 = " << c1 << endl; cout << "c2 = " << c2 << endl; assert(false); }*/ TCanvas *c = new TCanvas("c1"); c->Range(0,0,1,1); c->SetBorderSize(2); c->SetFrameFillColor(0); // ------------>Primitives in pad: c1_1 TPad *c1_1 = new TPad("c1_1", "c1_1",0.01,0.30,0.99,0.99); c1_1->Draw(); c1_1->cd(); c1_1->SetBorderSize(2); c1_1->SetTickx(1); c1_1->SetTicky(1); c1_1->SetTopMargin(0.1); c1_1->SetBottomMargin(0.0); //c1_1->SetFrameFillColor(3); //c1_1->SetLogy(); c->cd(); // ------------>Primitives in pad: c1_2 TPad *c1_2 = new TPad("c1_2", "c1_2",0.01,0.01,0.99,0.30); c1_2->Draw(); c1_2->cd(); c1_2->SetBorderSize(2); c1_2->SetTickx(1); c1_2->SetTicky(1); c1_2->SetTopMargin(0.0); c1_2->SetBottomMargin(0.24); c1_2->SetFrameFillColor(0); c1_2->SetGridx(); c1_2->SetGridy(); c->cd(); gStyle->SetOptStat(0); gPad->Print("samples.eps["); for (unsigned i=0;i<vBitMaskArray.size(); ++i) { unsigned mask = vBitMaskArray.at(i); for (unsigned ihist=0; ihist < hist2print.size(); ++ihist) { stringstream path, reco_hist_name, gen_hist_name, smear_hist_name; stringstream reco_hist, gen_hist, smear_hist; stringstream folder; folder << "Hist/Mask"<< mask << "HT0to8000MHT0to8000/"; //cout << "folder = " << folder.str() << endl; /* if ((hist2print.at(ihist).Name()).find("Jet")) { reco_hist_name << folder.str() << "reco" << hist2print.at(ihist).Name() << "_copy"; reco_hist << folder.str() << "reco" << hist2print.at(ihist).Name(); smear_hist_name << folder.str() << "smeared" << hist2print.at(ihist).Name() << "_copy"; smear_hist << folder.str() << "smeared" << hist2print.at(ihist).Name(); gen_hist_name << folder.str() << "gen" << hist2print.at(ihist).Name() << "_copy"; gen_hist << folder.str() << "gen" << hist2print.at(ihist).Name(); } else */ { reco_hist_name << folder.str() << "reco_" << hist2print.at(ihist).Name() << "_copy"; reco_hist << folder.str() << "reco_" << hist2print.at(ihist).Name(); smear_hist_name << folder.str() << "smeared_" << hist2print.at(ihist).Name() << "_copy"; smear_hist << folder.str() << "smeared_" << hist2print.at(ihist).Name(); gen_hist_name << folder.str() << "gen_" << hist2print.at(ihist).Name() << "_copy"; gen_hist << folder.str() << "gen_" << hist2print.at(ihist).Name(); } TH1* hreco = (TH1*) (outRootFile->Get(reco_hist.str().c_str())); if (hreco == NULL) { cout << "hreco = " << reco_hist.str() << " was not found!" << endl; assert(false); } hreco->SetDirectory(0); TH1* hsmear = (TH1*) (outRootFile->Get(smear_hist.str().c_str())); if (hsmear == NULL) { cout << "hsmear = " << smear_hist.str() << " was not found!" << endl; assert(false); } hsmear->SetDirectory(0); TH1* hgen = (TH1*) (outRootFile->Get(gen_hist.str().c_str())); //->Clone(gen_hist_name.str().c_str())); if (hgen == NULL) { cout << "hgen = " << gen_hist.str() << " was not found!" << endl; assert(false); } hgen->SetDirectory(0); hreco->Sumw2(); hsmear->Sumw2(); hgen->Sumw2(); const int rebin = hist2print.at(ihist).Rebin(); const string title = hist2print.at(ihist).Title(); const double xmin = hist2print.at(ihist).Xmin(); const double xmax = hist2print.at(ihist).Xmax(); if (rebin>1) { hreco->Rebin(rebin); hsmear->Rebin(rebin); hgen->Rebin(rebin); } if (title.length()>0) { hreco->SetTitle(title.c_str()); hsmear->SetTitle(title.c_str()); hgen->SetTitle(title.c_str()); } if (xmin != LargeNegNum || xmax != LargeNegNum) { hreco->GetXaxis()->SetRangeUser(xmin,xmax); hsmear->GetXaxis()->SetRangeUser(xmin,xmax); hgen->GetXaxis()->SetRangeUser(xmin,xmax); } const double reco_max_y = hreco->GetBinContent(hreco->GetMaximumBin()); const double smear_max_y = hsmear->GetBinContent(hsmear->GetMaximumBin()); const double y_max = max(reco_max_y, smear_max_y); double y_min = 9999.0; for (unsigned bin=1; bin<hreco->GetNbinsX(); ++bin) { const double v1 = hreco->GetBinContent(bin); const double v2 = hsmear->GetBinContent(bin); const double minv = min(v1,v2); if (minv != 0 && minv < y_min) y_min = minv; } cout << hreco->GetName() << "->ymin/max = " << y_min << "(" << y_min/2.0 << ")/" << y_max << "(" << y_max*2.0 << ")" << endl; hreco->GetYaxis()->SetRangeUser(y_min/2.0, y_max*2.0); hsmear->GetYaxis()->SetRangeUser(y_min/2.0, y_max*2.0); hgen->SetLineColor(kBlue); hgen->SetMarkerColor(kBlue); hgen->SetMarkerStyle(24); hgen->SetLineWidth(2); hsmear->SetLineColor(kRed); hsmear->SetMarkerColor(kRed); hsmear->SetMarkerStyle(24); hsmear->SetLineWidth(2); hreco->SetLineWidth(2); hreco->SetMarkerStyle(kDot); hreco->SetLineColor(kBlack); hreco->SetMarkerColor(kBlack); //hreco->GetXaxis()->SetRangeUser(0,300); //hsmear->GetXaxis()->SetRangeUser(0,300); hreco->GetYaxis()->CenterTitle(1); hreco->SetLabelFont(42,"XYZ"); hreco->SetTitleFont(42,"XYZ"); hreco->GetYaxis()->SetTitleOffset(0.8); hreco->SetLabelSize(0.05,"XYZ"); hreco->SetTitleSize(0.06,"XYZ"); TH1 *hsmeartoreco_ratio = (TH1*) (hsmear->Clone("hsmear_copy")); hsmeartoreco_ratio->Divide(hreco); hsmeartoreco_ratio->SetTitle(""); hsmeartoreco_ratio->GetYaxis()->SetTitle("Smear/Reco"); hsmeartoreco_ratio->GetYaxis()->SetRangeUser(0,2.); hsmeartoreco_ratio->GetYaxis()->SetTitleOffset(0.4); hsmeartoreco_ratio->GetXaxis()->SetTitleOffset(0.9); hsmeartoreco_ratio->GetYaxis()->CenterTitle(1); hsmeartoreco_ratio->GetXaxis()->CenterTitle(1); hsmeartoreco_ratio->SetLabelSize(0.125,"XYZ"); hsmeartoreco_ratio->SetTitleSize(0.125,"XYZ"); // hsmeartoreco_ratio->SetLabelFont(labelfont,"XYZ"); // hsmeartoreco_ratio->SetTitleFont(titlefont,"XYZ"); hsmeartoreco_ratio->GetXaxis()->SetTickLength(0.07); stringstream recoleg,smearleg, genleg; const double sum_reco = hreco->Integral(1, hreco->GetNbinsX()+1); const double sum_smear = hsmear->Integral(1, hsmear->GetNbinsX()+1); const double sum_gen = hgen->Integral(1, hgen->GetNbinsX()+1); const double err_reco = StatErr(hreco); const double err_smear = StatErr(hsmear); cout << setprecision(1) << fixed; recoleg << "Reco (" << sum_reco << "#pm" << err_reco << ")"; smearleg << "Smear (" << sum_smear << "#pm" << err_smear << ")"; genleg << "Gen (" << sum_gen << ")"; cout << smear_hist_name.str() << "::reco/smear = " << sum_reco << "/" << sum_smear << endl; TLegend *l2 = new TLegend(0.6,0.6,0.9,0.9); l2->AddEntry(hreco, recoleg.str().c_str()); //l2->AddEntry(hgen, genleg.str().c_str()); l2->AddEntry(hsmear, smearleg.str().c_str()); c1_1->cd(); gPad->SetLogy(hist2print.at(ihist).LogY()); hreco->DrawCopy(); //hgen->DrawCopy("same"); hsmear->DrawCopy("same"); l2->Draw(); //tx->Draw(); c1_2->cd(); hsmeartoreco_ratio->DrawCopy(); c->cd(); gPad->Print("samples.eps"); } } gPad->Print("samples.eps]"); }
TCanvas* overlay_Merged_RecoSmeared(const vector<string>& folders, const hist_t& h ) { TLegend *leg = new TLegend(0.6,0.65,0.9,0.9); leg->SetTextFont(42); vector<TH1*> hists; vector<string> jetcoll; jetcoll.push_back("reco"); jetcoll.push_back("gen"); jetcoll.push_back("smeared"); stringstream title; const string njets("3-5"); //const string eta("2.5"); const string eta("5.0"); title << njets << " Jets, MHT from Jets with P_{T}>30 GeV, |#eta |<" << eta << ", L = 10 fb^{-1}" << ";" << h.title ; for (unsigned j=0; j< jetcoll.size(); ++j) { TH1* Hist = 0; for (unsigned i = 0; i < folders.size(); ++i) { stringstream histname; histname << folders.at(i) << "/" << jetcoll.at(j) << h.name; cout << __LINE__ << ": Looking for hist: " << histname.str().c_str() << endl; TH1* htemp = GetHist(histname.str()); if (Hist == 0) Hist = htemp; else Hist->Add(htemp); } Hist->Rebin(h.rebin); Hist->SetTitle(title.str().c_str()); Hist->SetMarkerStyle(20+j); Hist->SetLineWidth(2); Hist->SetStats(0); stringstream legname; if (j==0) { legname << "Reco"; } else if (j==1) { legname << "Gen"; Hist->SetLineColor(kBlue); Hist->SetMarkerColor(kBlue); } else if (j==2) { legname << "Smeared"; Hist->SetLineColor(kRed); Hist->SetMarkerColor(kRed); } const double sum = Hist->Integral(); legname << " (" << sum << ")"; if (j!=1) leg->AddEntry(Hist, legname.str().c_str()); hists.push_back(Hist); } //end jetcoll TH1* ratio = dynamic_cast<TH1*> (hists.at(2)->Clone("ratio")); ratio->GetYaxis()->SetTitle("Smeared/Reco"); ratio->SetTitle(""); ratio->Divide(hists.at(0)); ratio->GetYaxis()->SetRangeUser(-0.01,2.01); //ratio->SetTickLength (+0.01,"Y"); //TCanvas *c1 = new TCanvas("c1", "c1",15,60,550,600); TCanvas *c1 = new TCanvas("c1"); c1->Range(0,0,1,1); c1->SetBorderSize(2); c1->SetFrameFillColor(0); // ------------>Primitives in pad: c1_1 TPad *c1_1 = new TPad("c1_1", "c1_1",0.01,0.30,0.99,0.99); c1_1->Draw(); c1_1->cd(); c1_1->SetBorderSize(2); c1_1->SetTickx(1); c1_1->SetTicky(1); c1_1->SetTopMargin(0.1); c1_1->SetBottomMargin(0.0); //c1_1->SetFrameFillColor(3); c1_1->SetLogy(); hists.at(0)->GetYaxis()->CenterTitle(1); hists.at(0)->SetLabelFont(42,"XYZ"); hists.at(0)->SetTitleFont(42,"XYZ"); hists.at(0)->GetYaxis()->SetTitleOffset(0.8); hists.at(0)->SetLabelSize(0.05,"XYZ"); hists.at(0)->SetTitleSize(0.06,"XYZ"); hists.at(0)->Draw("P"); hists.at(2)->Draw("same P"); leg->Draw(); c1_1->Modified(); c1->cd(); // ------------>Primitives in pad: c1_2 TPad *c1_2 = new TPad("c1_2", "c1_2",0.01,0.01,0.99,0.30); c1_2->Draw(); c1_2->cd(); c1_2->SetBorderSize(2); c1_2->SetTickx(1); c1_2->SetTicky(1); c1_2->SetTopMargin(0.0); c1_2->SetBottomMargin(0.24); c1_2->SetFrameFillColor(0); c1_2->SetGridx(); c1_2->SetGridy(); ratio->GetYaxis()->SetTitleOffset(0.4); ratio->GetXaxis()->SetTitleOffset(0.9); ratio->GetYaxis()->CenterTitle(1); ratio->GetXaxis()->CenterTitle(1); ratio->SetLabelSize(0.125,"XYZ"); ratio->SetTitleSize(0.125,"XYZ"); // ratio->SetLabelFont(labelfont,"XYZ"); // ratio->SetTitleFont(titlefont,"XYZ"); ratio->GetXaxis()->SetTickLength(0.07); ratio->Draw(""); c1_2->Modified(); c1->cd(); //c1->Modified(); //c1->cd(); //c1->SetSelected(c1); return c1; }