void drawHistos(TString rfile) { TH1::AddDirectory(0); TFile f(rfile); f.ls(); TH1D *hpp = (TH1D*)f.Get("hpp"); TH1D *hpn = (TH1D*)f.Get("hpn"); TH1D *hnp = (TH1D*)f.Get("hnp"); TH1D *hnn = (TH1D*)f.Get("hnn"); hpp->Print(); hnn->Print(); hpn->Print(); hnp->Print(); TCanvas *cv = new TCanvas("cv", "Delta t", 500, 700); cv->Divide(1,2); cv->cd(1); drawOverlay(hpp, hnn); cv->cd(2); drawOverlay(hpn, hnp); f.Close(); }
void compareOldandNew() { TCanvas * c1 = new TCanvas("c1","c1",800,600); TLatex lat; int centBounds[6] = {60,80,100,120,140,200}; for(int i = 0 ; i<5; i++){ const char * histName = "pPbPbp_FF"; TFile * fold = TFile::Open("FragmentationFunctionsUE2_nominal.root","read"); TFile * fnew = TFile::Open("FragmentationFunctionsUE2.root","read"); TH1D * num = (TH1D*)fnew->Get(Form("%s_%d_%d",histName,centBounds[i],centBounds[i+1])); TH1D * den = (TH1D*)fold->Get(Form("%s_%d_%d",histName,centBounds[i],centBounds[i+1])); //den->Add(num); num->Divide(den); //num->Scale(2); num->GetYaxis()->SetTitle("(no L2 residual)/(Nominal)"); num->GetYaxis()->SetRangeUser(0.7,1.3); num->GetXaxis()->SetTitle("p_{T}"); num->GetXaxis()->SetRangeUser(0.5,200); num->Print("All"); num->Draw(); lat.DrawLatex(1,1.2,Form("%d < p_{T}^{jet} < %d",centBounds[i],centBounds[i+1])); c1->SetLogx(); c1->SaveAs(Form("diffPlots/noL2Residual_%d_%d.png",centBounds[i],centBounds[i+1])); c1->SaveAs(Form("diffPlots/noL2Residual_%d_%d.pdf",centBounds[i],centBounds[i+1])); fnew->Close(); fold->Close(); } /*const char * histName = "PbPbTrackSpectrum_0_5"; TFile * fnew = TFile::Open("Spectra_Jun9_noChi2Cut.root","read"); TFile * fold = TFile::Open("Spectra_Jun9_withChi2Cut.root","read"); TH1D * num = (TH1D*)fnew->Get(histName); TH1D * den = (TH1D*)fold->Get(histName); //den->Add(num); num->Divide(den); //num->Scale(2); num->GetYaxis()->SetTitle("(No Chi2)/(With Chi2)"); num->GetYaxis()->SetRangeUser(0.7,1.5); num->GetXaxis()->SetRangeUser(0.7,350); num->Print("All"); num->Draw(); c1->SetLogx(); c1->SaveAs("plots/comparisonPlots/Chi2CutTest_PbPb_0_5.png"); c1->SaveAs("plots/comparisonPlots/Chi2CutTest_PbPb_0_5.pdf"); */ //c1->SaveAs("plots/comparisonPlots/ppChargeFraction2.C"); }
void MakeClosurePlot(TH1D* hObs, TH1D* hPred, TString name, bool logy=true) { set_style(hObs,"data_obs"); set_style(hPred,"pred"); // Setup canvas and pads TCanvas * c1 = new TCanvas("c1", "c1", 700, 700); c1->SetFillStyle(4000); TPad * pad1 = new TPad("pad1", "top pad" , 0.0, 0.3, 1.0, 1.0); pad1->SetFillStyle(4000); pad1->SetBottomMargin(0.0); pad1->Draw(); TPad * pad2 = new TPad("pad2", "bottom pad", 0.0, 0.0, 1.0, 0.3); pad2->SetFillStyle(4000); pad2->SetTopMargin(0.0); pad2->SetBottomMargin(0.35); pad2->Draw(); pad1->cd(); pad1->SetLogy(logy); TH1D * staterr = (TH1D *) hPred->Clone("staterr"); // staterr->Sumw2(); //staterr->SetFillColor(kRed); staterr->SetFillColor(kGray+3); staterr->SetMarkerSize(0); staterr->SetFillStyle(3013); //cout << "Compute ratio hist..." << endl; TH1D * ratio = (TH1D *) hPred->Clone("ratio"); //ratio->Sumw2(); ratio->SetMarkerSize(0.8); ratio->SetMarkerColor(1); //ratio->SetMarkerSize(0.5); ratio->Divide(hObs, hPred, 1., 1., "B"); ratio->Print("all"); TH1D * ratiostaterr = (TH1D *) hObs->Clone("ratiostaterr"); // ratiostaterr->Sumw2(); ratiostaterr->SetStats(0); ratiostaterr->SetTitle(hPred->GetTitle()); ratiostaterr->GetYaxis()->SetTitle("Obs/Pred."); ratiostaterr->SetMaximum(2.2); ratiostaterr->SetMinimum(0); ratiostaterr->SetMarkerSize(0); //ratiostaterr->SetFillColor(kRed); ratiostaterr->SetFillColor(kGray+3); ratiostaterr->SetFillStyle(3013); ratiostaterr->GetXaxis()->SetLabelSize(0.2); ratiostaterr->GetXaxis()->SetLabelOffset(0.03); ratiostaterr->GetXaxis()->SetTitleSize(0.14); ratiostaterr->GetXaxis()->SetTitleOffset(1.10); ratiostaterr->GetYaxis()->SetLabelSize(0.10); ratiostaterr->GetYaxis()->SetTitleSize(0.12); ratiostaterr->GetYaxis()->SetTitleOffset(0.6); ratiostaterr->GetYaxis()->SetNdivisions(505); TLine* ratiounity = new TLine(hPred->GetBinLowEdge(1),1,hPred->GetBinLowEdge(hPred->GetNbinsX()+1),1); ratiounity->SetLineStyle(2); for (Int_t i = 0; i < hPred->GetNbinsX()+2; i++) { // if (hObs->GetBinContent(i)>0.) ratio->SetBinError(i, hObs->GetBinError(i)/hObs->GetBinContent(i)); // just the fractional uncertainty on the observation ratiostaterr->SetBinContent(i, 1.0); if (hPred->GetBinContent(i) > 1e-6) { //< not empty double binerror = hPred->GetBinError(i) / hPred->GetBinContent(i); ratiostaterr->SetBinError(i, binerror); } else { ratiostaterr->SetBinError(i, 999.); } } TH1D * ratiosysterr = (TH1D *) ratiostaterr->Clone("ratiosysterr"); // ratiosysterr->Sumw2(); ratiosysterr->SetMarkerSize(0); ratiosysterr->SetFillColor(kYellow-4); //ratiosysterr->SetFillStyle(3002); ratiosysterr->SetFillStyle(1001); for (Int_t i = 0; i < hPred->GetNbinsX()+2; i++) { if (hPred->GetBinContent(i) > 1e-6) { //< not empty double binerror2 = (pow(hPred->GetBinError(i), 2)); double binerror = sqrt(binerror2); ratiosysterr->SetBinError(i, binerror / hPred->GetBinContent(i)); } } double max = hObs->GetMaximum(); if (hPred->GetMaximum() > max) max = hPred->GetMaximum(); if (logy) { hPred->SetMaximum(max*10); hPred->SetMinimum(0.09); } else { hPred->SetMaximum(max*1.5); hPred->SetMinimum(0.); } hPred->GetYaxis()->SetTitle("Events / bin"); hPred->Draw("hist"); hObs->Draw("e1,same"); staterr->Draw("e2 same"); hPred->GetXaxis()->SetTitleSize(0.035); hPred->GetXaxis()->SetLabelSize(0.035); /* hObs->GetYaxis()->SetTitleSize(0.035); */ /* hObs->GetYaxis()->SetLabelSize(0.035); */ TLegend * leg2 = new TLegend(0.72, 0.68, 0.94, 0.92); set_style(leg2,0.035); leg2->AddEntry(hObs,"Obs.","elp"); leg2->AddEntry(hPred,"Pred.","f"); leg2->AddEntry(staterr, "Syst. uncert.", "f"); 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); TString stamp = Form("#sqrt{s} = 13 TeV, L = %3.1f fb^{-1}", int_lumi); latex->DrawLatex(0.19, 0.84, stamp); pad2->cd(); pad2->SetGridy(0); ratiostaterr->GetXaxis()->SetRangeUser(0,6); ratiostaterr->Draw("e2"); //ratiosysterr->Draw("e2 same"); ratiostaterr->Draw("e2 same"); ratiounity->Draw(); ratio->Draw("e1 same"); TPaveText * pave = new TPaveText(0.18, 0.86, 0.4, 0.96, "brNDC"); pave->SetLineColor(0); pave->SetFillColor(kWhite); pave->SetShadowColor(0); pave->SetBorderSize(1); double nchisq = hObs->Chi2Test(hPred, "UWCHI2/NDF, P"); // MC uncert. (stat) double p_value = hObs->Chi2Test(hPred, "UW"); // MC uncert. (stat) // //double kolprob = hdata_obs->KolmogorovTest(hmc_pred); // MC uncert. (stat) TText * text = pave->AddText(Form("#chi_{#nu}^{2}/ndf = %.3f, p = %.3f", nchisq, p_value)); // //TText * text = pave->AddText(Form("#chi_{#nu}^{2} = %.3f, K_{s} = %.3f", nchisq, kolprob)); text->SetTextFont(62); text->SetTextSize(0.07); // text->SetTextSize(0.06); pave->Draw(); /* TLegend * ratioleg = new TLegend(0.72, 0.88, 0.94, 0.96); */ /* set_style(ratioleg); */ /* ratioleg->SetTextSize(0.07); */ /* ratioleg->AddEntry(ratiostaterr, "MC uncert. (stat)", "f"); */ /* ratioleg->Draw(); */ pad1->cd(); gPad->RedrawAxis(); gPad->Modified(); gPad->Update(); pad2->cd(); gPad->RedrawAxis(); gPad->Modified(); gPad->Update(); c1->cd(); c1->Print("Closure/plots/no_dp_cut/"+name+".pdf"); delete staterr; delete ratio; delete ratiostaterr; delete ratiosysterr; delete leg2; // delete ratioleg; delete pad1; delete pad2; delete c1; delete latex; }
void Plot_searchBin_full_ICHEP_wQCD(string option="", int pull=0){ // string option="QCD" // Use option="QCD" to produce plots in QCD binning char tempname[200]; // Open root file sprintf(tempname,"LLPrediction_QCD.root"); // true: do closure test (MC prediction vs MC truth) // false: do data driven prediction and compare to MC truth bool doDataVsMC = false; // Add systematics in quadrature to stat. uncertainty on prediction // Non-closure systematic not included yet! bool showSystematics = false; bool doClosurewoIsoTrackVeto = false; /////////////////////////////////////////////////////////////////////////////////////////// ////Some cosmetic work for official documents. // // Set basic style // setTDRStyle(); gStyle->SetPalette(1) ; // for better color output // // Canvas size int W = 1200; int H = 740; int H_ref = 740; int W_ref = 800; float T = 0.10*H_ref; float B = 0.06*H_ref; float L = 0.16*W_ref; float R = 0.04*W_ref; // // Various vertical line coordinates float ymax_top = 40000.; float ymin_top = 0.015; float ymax2_top = 1000.; float ymax3_top = 200.; float ymax4_top = 30.; float ymax5_top = 5.; float ymax_bottom = 1.99; float ymin_bottom = 0.01; float ymax2_bottom = 2.15; float ymax3_bottom = 2.15; float ymax4_bottom = 2.15; // // Luminosity information for scaling double lumi = 7.6; // normaliza to this lumi (fb-1) double lumi_ref = 7.6; // normaliza to 3 (fb-1) /////////////////////////////////////////////////////////////////////////////////////////// // // More specific style set, opening input files etc gStyle->SetOptStat(0); ///to avoid the stat. on the plots //gStyle->SetErrorX(0); char xtitlename[200]; char ytitlename[200]; TFile * LLFile = new TFile(tempname,"R"); printf("Opened %s\n",tempname); // // Define legend // Float_t legendX1 = .655; //.50; Float_t legendX2 = .955; //.70; Float_t legendY1 = .53; //.65; Float_t legendY2 = .78; TLegend* catLeg1 = new TLegend(legendX1,legendY1,legendX2,legendY2); //catLeg1->SetTextSize(0.060); catLeg1->SetTextSize(0.044); catLeg1->SetTextFont(42); catLeg1->SetFillColor(0); catLeg1->SetLineColor(1); catLeg1->SetBorderSize(1); // // Define canvas // TCanvas *canvas = new TCanvas("canvas","canvas",10,10,W,H); canvas->SetFillColor(0); canvas->SetBorderMode(0); canvas->SetFrameFillStyle(0); canvas->SetFrameBorderMode(0); canvas->SetLeftMargin( L/W ); canvas->SetRightMargin( R/W ); canvas->SetTopMargin( T/H ); canvas->SetBottomMargin( B/H ); canvas->SetTickx(0); canvas->SetTicky(0); canvas->Divide(1, 2); // // Define pads // TPad* canvas_up = (TPad*) canvas->GetListOfPrimitives()->FindObject("canvas_1"); TPad* canvas_dw = (TPad*) canvas->GetListOfPrimitives()->FindObject("canvas_2"); // // define the size double up_height = 0.8; // please tune so that the upper figures size will meet your requirement double dw_correction = 1.30; // please tune so that the smaller canvas size will work in your environment double font_size_dw = 0.1; // please tune the font size parameter for bottom figure double dw_height = (1. - up_height) * dw_correction; double dw_height_offset = 0.04; // KH, added to put the bottom one closer to the top panel // // set pad size canvas_up->SetPad(0., 1 - up_height, 1., 1.00); canvas_dw->SetPad(0., 0., 1., dw_height+dw_height_offset); // canvas_up->SetFrameFillColor(0); canvas_up->SetFillColor(0); canvas_up->SetTopMargin(0.12); canvas_up->SetLeftMargin(0.1); // canvas_dw->SetFillColor(0); canvas_dw->SetFrameFillColor(0); canvas_dw->SetBottomMargin(0.35); canvas_dw->SetTopMargin(0); canvas_dw->SetLeftMargin(0.1); // // draw top figure canvas_up->cd(); TH1D * GenHist, * EstHist,* thist; TH1D * GenHistTemp, * EstHistTemp; TH1D * GenHistD, * EstHistD; TH1D * GenHistDTemp, * EstHistDTemp; TH1D * EstSystematics; TH1D * histTemplate; double HT_x_max=2500.; double HT_x_min=400.; double MHT_x_max=1000.; double NJet_x_max=15.; double NBtag_x_max=4.; double search_x_max=208.-0.5; if(option.find("QCD")!=string::npos)search_x_max=208.-0.5; double search_x_min=1.-0.5; TDirectory *dPre = 0; TDirectory *dExp = (TDirectory*)LLFile->Get("Expectation"); if(doDataVsMC){ dPre = (TDirectory*)LLFile->Get("Prediction_data"); }else{ dPre = (TDirectory*)LLFile->Get("Prediction_MC"); } if(doDataVsMC){ EstHistTemp=(TH1D*) dPre->Get("totalPred_LL")->Clone(); EstHistDTemp=(TH1D*) dPre->Get("totalPred_LL")->Clone(); }else{ if(doClosurewoIsoTrackVeto){ EstHistTemp=(TH1D*) dPre->Get("totalPred_woIsoTrack_LL_MC")->Clone(); EstHistDTemp=(TH1D*) dPre->Get("totalPred_woIsoTrack_LL_MC")->Clone(); }else{ EstHistTemp=(TH1D*) dPre->Get("totalPred_LL_MC")->Clone(); EstHistDTemp=(TH1D*) dPre->Get("totalPred_LL_MC")->Clone(); } } if(doClosurewoIsoTrackVeto){ GenHistTemp=(TH1D*) dExp->Get("totalExp_woIsoTrack_LL")->Clone(); GenHistDTemp=(TH1D*) dExp->Get("totalExp_woIsoTrack_LL")->Clone();; }else{ GenHistTemp=(TH1D*) dExp->Get("totalExp_LL")->Clone(); GenHistDTemp=(TH1D*) dExp->Get("totalExp_LL")->Clone(); } if(showSystematics){ TDirectory *dSys = (TDirectory*)LLFile->Get("AdditionalContent"); if(doDataVsMC){ EstSystematics=(TH1D*) dSys->Get("totalPropSysUp_LL")->Clone(); }else{ EstSystematics=(TH1D*) dSys->Get("totalPropSysUp_LL_MC")->Clone(); } } if(EstHistTemp->GetNbinsX() != GenHistTemp->GetNbinsX()) std::cout<<"NbinsX of Expectation and Prediction don't agree!"<<std::endl; EstHist = new TH1D("Exp", "Exp", EstHistTemp->GetNbinsX(), 0.5, EstHistTemp->GetNbinsX()+0.5); EstHistD = new TH1D("ExpD", "ExpD", EstHistDTemp->GetNbinsX(), 0.5, EstHistDTemp->GetNbinsX()+0.5); GenHist = new TH1D("Pred", "Pred", GenHistTemp->GetNbinsX(), 0.5, GenHistTemp->GetNbinsX()+0.5); GenHistD = new TH1D("PredD", "PredD", GenHistDTemp->GetNbinsX(), 0.5, GenHistDTemp->GetNbinsX()+0.5); for(int i = 0; i <= EstHistTemp->GetNbinsX()+1; i++){ EstHist->SetBinContent(i, EstHistTemp->GetBinContent(i)); EstHistD->SetBinContent(i, EstHistDTemp->GetBinContent(i)); if(showSystematics){ EstHist->SetBinError(i, std::sqrt(EstHistTemp->GetBinError(i)*EstHistTemp->GetBinError(i)+EstSystematics->GetBinContent(i)*EstSystematics->GetBinContent(i)*EstHistTemp->GetBinError(i)*EstHistTemp->GetBinError(i))); EstHistD->SetBinError(i, std::sqrt(EstHistDTemp->GetBinError(i)*EstHistDTemp->GetBinError(i)+EstSystematics->GetBinContent(i)*EstSystematics->GetBinContent(i)*EstHistDTemp->GetBinError(i)*EstHistDTemp->GetBinError(i))); }else{ EstHist->SetBinError(i, EstHistTemp->GetBinError(i)); EstHistD->SetBinError(i, EstHistDTemp->GetBinError(i)); } GenHist->SetBinContent(i, GenHistTemp->GetBinContent(i)); GenHist->SetBinError(i, GenHistTemp->GetBinError(i)); GenHistD->SetBinContent(i, GenHistDTemp->GetBinContent(i)); GenHistD->SetBinError(i, GenHistDTemp->GetBinError(i)); } GenHist->SetLineColor(4); EstHist->SetLineColor(4); //GenHist->GetXaxis()->SetLabelFont(42); //GenHist->GetXaxis()->SetLabelOffset(0.007); //GenHist->GetXaxis()->SetLabelSize(0.04); //GenHist->GetXaxis()->SetTitleSize(0.05); //GenHist->GetXaxis()->SetTitleOffset(0.9); //GenHist->GetXaxis()->SetTitleOffset(0.5); //GenHist->GetXaxis()->SetTitleFont(42); //GenHist->GetYaxis()->SetLabelFont(42); //GenHist->GetYaxis()->SetLabelOffset(0.007); //GenHist->GetYaxis()->SetLabelSize(0.04); GenHist->GetYaxis()->SetLabelSize(0.045*1.15); GenHist->GetYaxis()->SetTitleSize(0.06*1.15); GenHist->GetYaxis()->SetTitleOffset(0.6); GenHist->GetYaxis()->SetTitleFont(42); //EstHist->GetXaxis()->SetLabelFont(42); //EstHist->GetXaxis()->SetLabelOffset(0.007); //EstHist->GetXaxis()->SetLabelSize(0.04); //EstHist->GetXaxis()->SetTitleSize(0.05); //EstHist->GetXaxis()->SetTitleOffset(0.9); //EstHist->GetXaxis()->SetTitleFont(42); //EstHist->GetYaxis()->SetLabelFont(42); //EstHist->GetYaxis()->SetLabelOffset(0.007); //EstHist->GetYaxis()->SetLabelSize(0.04); //EstHist->GetYaxis()->SetTitleSize(0.08); //EstHist->GetYaxis()->SetTitleOffset(2.0); //EstHist->GetYaxis()->SetTitleFont(42); sprintf(xtitlename,"Search region bin number"); sprintf(ytitlename,"Events"); gPad->SetLogy(); GenHist->SetMaximum(ymax_top); GenHist->SetMinimum(ymin_top); GenHist->GetXaxis()->SetRangeUser(search_x_min,search_x_max); //GenHist->GetYaxis()->SetTickLength(0.015); //GenHist->GetXaxis()->SetTickLength(0.02); //gPad->SetGridx(1); TExec *ex1 = new TExec("ex1","gStyle->SetErrorX(0);"); TExec *ex2 = new TExec("ex2","gStyle->SetErrorX(0.5);"); GenHist->SetTitle(""); GenHist->SetMarkerStyle(20); GenHist->SetMarkerSize(1.2); GenHist->SetLineColor(1); GenHist->GetXaxis()->SetTitle(xtitlename); GenHist->GetYaxis()->SetTitle(ytitlename); GenHist->Scale(lumi/lumi_ref); EstHist->Scale(lumi/lumi_ref); TH1D * GenHist_Normalize = static_cast<TH1D*>(GenHist->Clone("GenHist_Normalize")); GenHist_Normalize->SetMaximum(ymax_top); GenHist_Normalize->SetMinimum(ymin_top); ex1->Draw(); //GenHist_Normalize->GetListOfFunctions()->Add(ex1); GenHist_Normalize->DrawCopy("e"); EstHist->SetFillStyle(3144); EstHist->SetFillColor(kRed-10); EstHist->SetMarkerStyle(20); EstHist->SetMarkerSize(0.0001); TH1D * EstHist_Normalize = static_cast<TH1D*>(EstHist->Clone("EstHist_Normalize")); ex2->Draw(); //EstHist_Normalize->GetListOfFunctions()->Add(ex2); EstHist_Normalize->DrawCopy("e2same"); //EstHist_Normalize->DrawCopy("esame"); TH1D *EstHist_Normalize_Clone = (TH1D*)EstHist_Normalize->Clone(); for(int i=1; i<208; i++) { EstHist_Normalize_Clone->SetBinError(i,0); } EstHist_Normalize_Clone->SetFillColor(kWhite); EstHist_Normalize_Clone->Draw("esame"); GenHist->Print("all"); EstHist->Print("all"); // // Re-draw to have "expectation" on top of "prediction" ex1->Draw(); GenHist_Normalize->DrawCopy("esame"); // TString line = ""; sprintf(tempname,"%8.1f",lumi); line+=tempname; line+=" fb^{-1} (13 TeV)"; int iPeriod = 0; // 1=7TeV, 2=8TeV, 3=7+8TeV, 7=7+8+13TeV, 0=free form (uses lumi_sqrtS) int iPos=0; writeExtraText = true; if(doDataVsMC) extraText = " Preliminary"; else extraText = " Simulation"; //float extraTextFont = 52; // default is helvetica-italics // text sizes and text offsets with respect to the top frame // in unit of the top margin size //lumiTextSize = 0.5; //float lumiTextOffset = 0.2; //cmsTextSize = 0.65; //float cmsTextOffset = 0.1; // only used in outOfFrame version //relPosX = 0.045; //relPosY = 0.035; //relExtraDY = 1.2; // ratio of "CMS" and extra text size //float extraOverCmsTextSize = 0.76; //TString lumi_13TeV = "20.1 fb^{-1}"; //TString lumi_8TeV = "19.7 fb^{-1}"; //TString lumi_7TeV = "5.1 fb^{-1}"; TString lumi_sqrtS = line; // if(option.find("QCD")==string::npos ){ //----------------------------------------------------------- // Putting lines and labels explaining search region definitions //----------------------------------------------------------- //TString CMSlabel = ""; //cmsText = "#bf{CMS} #it{Simulation}"; //CMSlabel += "#splitline{#bf{CMS}}{#scale[0.6]{#it{Simulation}}}"; /* double x0 = gStyle->GetPadLeftMargin(); double x1 = 1.-gStyle->GetPadRightMargin(); double y0 = 1.005-gStyle->GetPadTopMargin(); double y1 = 0.96; TPaveText *Lumitxt = new TPaveText(x0,y0,x1,y1,"NDC"); Lumitxt->SetBorderSize(0); Lumitxt->SetFillColor(0); Lumitxt->SetTextFont(42); Lumitxt->SetTextAlign(31); Lumitxt->SetTextSize(1.2*gStyle->GetPadTopMargin()); Lumitxt->SetMargin(0.); Lumitxt->AddText(line); //Lumitxt->Draw("same"); x0 = gStyle->GetPadLeftMargin()+0.03; x1 = gStyle->GetPadLeftMargin()+0.13; y0 = 0.905-gStyle->GetPadTopMargin(); y1 = 0.88; TPaveText *CMStxt = new TPaveText(x0,y0,x1,y1,"NDC"); CMStxt->SetBorderSize(0); CMStxt->SetFillColor(0); CMStxt->SetTextFont(42); CMStxt->SetTextAlign(11); CMStxt->SetTextSize(1.2*gStyle->GetPadTopMargin()); CMStxt->SetMargin(0.); CMStxt->AddText(CMSlabel); //CMStxt->Draw("same"); */ // Njet separation lines TLine *tl_njet = new TLine(); tl_njet->SetLineStyle(2); tl_njet->DrawLine(53.-0.5,ymin_top,53.-0.5,ymax_top); tl_njet->DrawLine(105.-0.5,ymin_top,105.-0.5,ymax_top); tl_njet->DrawLine(157.-0.5,ymin_top,157.-0.5,ymax_top); // Njet labels TLatex * ttext_njet = new TLatex(); ttext_njet->SetTextFont(42); ttext_njet->SetTextSize(0.04); ttext_njet->SetTextAlign(22); ttext_njet->DrawLatex(26.-0.5 , ymax_top/4. , "3 #leq N_{#scale[0.2]{ }jet} #leq 4"); ttext_njet->DrawLatex(78.-0.5 , ymax_top/4. , "5 #leq N_{#scale[0.2]{ }jet} #leq 6"); ttext_njet->DrawLatex(130.-0.5 , ymax_top/4. , "7 #leq N_{#scale[0.2]{ }jet} #leq 8"); ttext_njet->DrawLatex(182.-0.5 , ymax_top/4. , "N_{#scale[0.2]{ }jet} #geq 9"); // Nb separation lines TLine *tl_nb = new TLine(); tl_nb->SetLineStyle(3); tl_nb->DrawLine(14.-0.5,ymin_top,14.-0.5,ymax2_top); tl_nb->DrawLine(27.-0.5,ymin_top,27.-0.5,ymax2_top); tl_nb->DrawLine(40.-0.5,ymin_top,40.-0.5,ymax2_top); tl_nb->DrawLine(53.-0.5,ymin_top,53.-0.5,ymax2_top); tl_nb->DrawLine(66.-0.5,ymin_top,66.-0.5,ymax3_top); tl_nb->DrawLine(79.-0.5,ymin_top,79.-0.5,ymax3_top); tl_nb->DrawLine(92.-0.5,ymin_top,92.-0.5,ymax3_top); tl_nb->DrawLine(105.-0.5,ymin_top,105.-0.5,ymax3_top); tl_nb->DrawLine(118.-0.5,ymin_top,118.-0.5,ymax4_top); tl_nb->DrawLine(131.-0.5,ymin_top,131.-0.5,ymax4_top); tl_nb->DrawLine(144.-0.5,ymin_top,144.-0.5,ymax4_top); tl_nb->DrawLine(157.-0.5,ymin_top,157.-0.5,ymax4_top); tl_nb->DrawLine(170.-0.5,ymin_top,170.-0.5,ymax5_top); tl_nb->DrawLine(183.-0.5,ymin_top,183.-0.5,ymax5_top); tl_nb->DrawLine(196.-0.5,ymin_top,196.-0.5,ymax5_top); // Nb labels TLatex * ttext_nb = new TLatex(); ttext_nb->SetTextFont(42); ttext_nb->SetTextSize(0.04); ttext_nb->SetTextAlign(22); ttext_nb->DrawLatex(9.-0.5 , ymax_top/12. , "N_{#scale[0.2]{ }b-jet}"); ttext_nb->DrawLatex(8.-0.5 , ymax_top/40. , "0"); ttext_nb->DrawLatex(20.-0.5 , ymax_top/40. , "1"); ttext_nb->DrawLatex(33.-0.5 , ymax_top/40. , "2"); ttext_nb->DrawLatex(46.-0.5 , ymax_top/40. , "#geq 3"); // } else { //----------------------------------------------------------- // Putting lines and labels explaining search region definitions //----------------------------------------------------------- // Njet separation lines TLine *tl_njet = new TLine(); tl_njet->SetLineStyle(2); tl_njet->DrawLine( 45.,ymin_top, 45.,ymax_top); tl_njet->DrawLine( 89.,ymin_top, 89.,ymax_top); tl_njet->DrawLine(133.,ymin_top,133.,ymax_top); tl_njet->DrawLine(177.,ymin_top,177.,ymax_top); // Njet labels TLatex * ttext_njet = new TLatex(); ttext_njet->SetTextFont(42); ttext_njet->SetTextSize(0.04); ttext_njet->SetTextAlign(22); ttext_njet->DrawLatex(23. , ymax_top/4. , "N_{jets} = 4"); ttext_njet->DrawLatex(67. , ymax_top/4. , "N_{jets} = 5"); ttext_njet->DrawLatex(111., ymax_top/4. , "N_{jets} = 6"); ttext_njet->DrawLatex(155., ymax_top/4. , "7 #leq N_{jets} #leq 8"); ttext_njet->DrawLatex(199., ymax_top/4. , "N_{jets} #geq 9"); // Nb separation lines TLine *tl_nb = new TLine(); tl_nb->SetLineStyle(3); tl_nb->DrawLine(12.,ymin_top,12.,ymax2_top); tl_nb->DrawLine(23.,ymin_top,23.,ymax2_top); tl_nb->DrawLine(34.,ymin_top,34.,ymax2_top); tl_nb->DrawLine(56.,ymin_top,56.,ymax2_top); tl_nb->DrawLine(67.,ymin_top,67.,ymax2_top); tl_nb->DrawLine(78.,ymin_top,78.,ymax2_top); tl_nb->DrawLine(100.,ymin_top,100.,ymax2_top); tl_nb->DrawLine(111.,ymin_top,111.,ymax2_top); tl_nb->DrawLine(122.,ymin_top,122.,ymax2_top); tl_nb->DrawLine(144.,ymin_top,144.,ymax3_top); tl_nb->DrawLine(155.,ymin_top,155.,ymax3_top); tl_nb->DrawLine(166.,ymin_top,166.,ymax3_top); tl_nb->DrawLine(188.,ymin_top,188.,ymax4_top); tl_nb->DrawLine(199.,ymin_top,199.,ymax4_top); tl_nb->DrawLine(210.,ymin_top,210.,ymax4_top); // Nb labels TLatex * ttext_nb = new TLatex(); ttext_nb->SetTextFont(42); ttext_nb->SetTextSize(0.04); ttext_nb->SetTextAlign(22); ttext_nb->SetTextAngle(90); ttext_nb->DrawLatex( 6. , ymax_top/50. , "N_{b} = 0"); ttext_nb->DrawLatex(17. , ymax_top/50. , "N_{b} = 1"); ttext_nb->DrawLatex(28. , ymax_top/50. , "N_{b} = 2"); ttext_nb->DrawLatex(39. , ymax_top/50. , "N_{b} #geq 3"); TText * ttext = new TLatex(160. , ymax_top/50. , "Normalized to 10 fb^{-1}"); ttext->SetTextFont(42); ttext->SetTextSize(0.045); ttext->SetTextAlign(22); ttext->Draw(); } // Legend & texts sprintf(tempname,"Lost-lepton background"); catLeg1->SetHeader(tempname); //sprintf(tempname,"#tau_{hadronic} BG expectation (MC truth)"); sprintf(tempname,"Direct from simulation"); catLeg1->AddEntry(GenHist,tempname,"p"); //sprintf(tempname,"Prediction from MC"); if(doDataVsMC) sprintf(tempname,"Prediction from data"); else sprintf(tempname,"Treat simulation like data"); catLeg1->AddEntry(EstHist,tempname); catLeg1->Draw(); gPad->RedrawAxis(); // // Bottom ratio plot // // ---------- // // Preparing ratio histograms TH1D * numerator = static_cast<TH1D*>(GenHist->Clone("numerator")); TH1D * numerator_fullstaterr = static_cast<TH1D*>(GenHist->Clone("numerator_fullstaterr")); TH1D * denominator = static_cast<TH1D*>(EstHist->Clone("denominator")); TH1D * GenHist_Clone = static_cast<TH1D*>(GenHist->Clone("GenHist_Clone")); TH1D * EstHist_Clone = static_cast<TH1D*>(EstHist->Clone("EstHist_Clone")); TH1D * EstHist_NoError = static_cast<TH1D*>(EstHist->Clone("EstHist_NoError")); TH1D * One_NoError = static_cast<TH1D*>(EstHist->Clone("EstHist_NoError")); for (int ibin=0; ibin<EstHist_NoError->GetNbinsX()+2; ibin++){ // scan including underflow and overflow bins EstHist_NoError->SetBinError(ibin,0.); One_NoError->SetBinContent(ibin,1.); One_NoError->SetBinError(ibin,0.); } //EstHistD->Add(GenHistD,-1); numerator->Divide(GenHist_Clone,EstHist_NoError,1,1,""); denominator->Divide(EstHist_Clone,EstHist_NoError,1,1,""); numerator_fullstaterr->Divide(GenHist_Clone,EstHist_Clone,1,1,""); // Expectation/Prediction numerator_fullstaterr->Add(One_NoError,-1.); // Expectation/Prediction-1 // draw bottom figure canvas_dw->cd(); // font size numerator->GetXaxis()->SetLabelSize(font_size_dw); numerator->GetXaxis()->SetTitleSize(font_size_dw); numerator->GetYaxis()->SetLabelSize(font_size_dw); numerator->GetYaxis()->SetTitleSize(font_size_dw); // // Horizontal Lines TLine *tline = new TLine(search_x_min,1.,search_x_max,1.); TLine *tline0 = new TLine(search_x_min,0.,search_x_max,0.); // // Common to all bottom plots // //sprintf(ytitlename,"#frac{Estimate - #tau_{had} BG}{#tau_{had} BG} "); sprintf(ytitlename,"#frac{Direct}{Prediction} "); numerator->SetMaximum(ymax_bottom); numerator->SetMinimum(ymin_bottom); // // Specific to each bottom plot // // Setting style //numerator->SetMaximum(1.4); //numerator->GetXaxis()->SetLabelFont(42); //numerator->GetXaxis()->SetLabelOffset(0.007); numerator->GetXaxis()->SetLabelSize(0.18*0.045/0.06); numerator->GetXaxis()->SetTitleSize(0.18); numerator->GetXaxis()->SetTitleOffset(0.9); numerator->GetXaxis()->SetTitleFont(42); //numerator->GetYaxis()->SetLabelFont(42); //numerator->GetYaxis()->SetLabelOffset(0.007); numerator->GetYaxis()->SetLabelSize(0.18*0.045/0.06); numerator->GetYaxis()->SetTitleSize(0.18); //numerator->GetYaxis()->SetTitleOffset(0.5); numerator->GetYaxis()->SetTitleOffset(0.25); numerator->GetYaxis()->SetTitleFont(42); numerator->GetXaxis()->SetTitle(xtitlename); numerator->GetYaxis()->SetTitle(ytitlename); //gPad->SetGridx(1); if (pull==1){ sprintf(ytitlename,"#frac{Exp - Pre}{Stat Error} "); numerator->SetMaximum(8.); numerator->SetMinimum(-8.); // // Specific to each bottom plot // // Setting style for (int ibin=0; ibin<numerator_fullstaterr->GetNbinsX()+2; ibin++){ // scan including underflow and overflow bins numerator_fullstaterr->SetBinContent(ibin,numerator_fullstaterr->GetBinContent(ibin)/numerator_fullstaterr->GetBinError(ibin)); numerator_fullstaterr->SetBinError(ibin,0.); } numerator_fullstaterr->Print("all"); numerator_fullstaterr->GetXaxis()->SetLabelSize(font_size_dw); numerator_fullstaterr->GetXaxis()->SetTitleSize(font_size_dw); numerator_fullstaterr->GetYaxis()->SetLabelSize(font_size_dw); numerator_fullstaterr->GetYaxis()->SetTitleSize(font_size_dw); numerator_fullstaterr->GetXaxis()->SetTitleSize(0.12); numerator_fullstaterr->GetXaxis()->SetTitleOffset(0.9); numerator_fullstaterr->GetXaxis()->SetTitleFont(42); numerator_fullstaterr->GetYaxis()->SetTitleSize(0.13); numerator_fullstaterr->GetYaxis()->SetTitleOffset(0.5); numerator_fullstaterr->GetYaxis()->SetTitleFont(42); numerator_fullstaterr->GetXaxis()->SetTitle(xtitlename); numerator_fullstaterr->GetYaxis()->SetTitle(ytitlename); //numerator_fullstaterr->SetFillColor(kGreen-3); numerator_fullstaterr->SetFillColor(kRed-10); numerator_fullstaterr->DrawCopy(); // // Drawing lines tline0->SetLineStyle(2); //tline0->Draw(); } else { // // Plotting numerator->GetYaxis()->SetNdivisions(505); numerator->GetYaxis()->SetTickLength(0.015); numerator->GetXaxis()->SetTickLength(0.08); numerator->SetTitle(""); ex1->Draw(); numerator->DrawCopy(); ex2->Draw(); denominator->DrawCopy("e2same"); //denominator->DrawCopy("same"); TH1D *denominator_Clone = (TH1D*)denominator->Clone(); denominator_Clone->SetFillColor(kWhite); denominator_Clone->Draw("hist same"); ex1->Draw(); numerator->DrawCopy("same"); numerator->Print("all"); denominator->Print("all"); numerator_fullstaterr->Print("all"); // // Drawing lines tline->SetLineStyle(2); //tline->Draw(); } // if(option.find("QCD")==string::npos ){ // Njet separation lines TLine *tl_njet = new TLine(); tl_njet->SetLineStyle(2); tl_njet->DrawLine(53.-0.5,ymin_bottom,53.-0.5,ymax_bottom); tl_njet->DrawLine(105.-0.5,ymin_bottom,105.-0.5,ymax_bottom); tl_njet->DrawLine(157.-0.5,ymin_bottom,157.-0.5,ymax_bottom); // Nb separation lines TLine *tl_nb = new TLine(); tl_nb->SetLineStyle(3); tl_nb->DrawLine(14.-0.5,ymin_bottom,14.-0.5,ymax2_bottom); tl_nb->DrawLine(27.-0.5,ymin_bottom,27.-0.5,ymax2_bottom); tl_nb->DrawLine(40.-0.5,ymin_bottom,40.-0.5,ymax2_bottom); tl_nb->DrawLine(53.-0.5,ymin_bottom,53.-0.5,ymax2_bottom); tl_nb->DrawLine(66.-0.5,ymin_bottom,66.-0.5,ymax2_bottom); tl_nb->DrawLine(79.-0.5,ymin_bottom,79.-0.5,ymax2_bottom); tl_nb->DrawLine(92.-0.5,ymin_bottom,92.-0.5,ymax2_bottom); tl_nb->DrawLine(105.-0.5,ymin_bottom,105.-0.5,ymax2_bottom); tl_nb->DrawLine(118.-0.5,ymin_bottom,118.-0.5,ymax2_bottom); tl_nb->DrawLine(131.-0.5,ymin_bottom,131.-0.5,ymax2_bottom); tl_nb->DrawLine(144.-0.5,ymin_bottom,144.-0.5,ymax2_bottom); tl_nb->DrawLine(157.-0.5,ymin_bottom,157.-0.5,ymax2_bottom); tl_nb->DrawLine(170.-0.5,ymin_bottom,170.-0.5,ymax2_bottom); tl_nb->DrawLine(183.-0.5,ymin_bottom,183.-0.5,ymax2_bottom); tl_nb->DrawLine(196.-0.5,ymin_bottom,196.-0.5,ymax2_bottom); } else { // Njet separation lines TLine *tl_njet = new TLine(); tl_njet->SetLineStyle(2); tl_njet->DrawLine( 45.,ymin_bottom, 45.,ymax_bottom); tl_njet->DrawLine( 89.,ymin_bottom, 89.,ymax_bottom); tl_njet->DrawLine(133.,ymin_bottom,133.,ymax_bottom); tl_njet->DrawLine(177.,ymin_bottom,177.,ymax_bottom); // Nb separation lines TLine *tl_nb = new TLine(); tl_nb->SetLineStyle(3); tl_nb->DrawLine(12.,ymin_bottom,12.,ymax2_bottom); tl_nb->DrawLine(23.,ymin_bottom,23.,ymax2_bottom); tl_nb->DrawLine(34.,ymin_bottom,34.,ymax2_bottom); tl_nb->DrawLine(56.,ymin_bottom,56.,ymax2_bottom); tl_nb->DrawLine(67.,ymin_bottom,67.,ymax2_bottom); tl_nb->DrawLine(78.,ymin_bottom,78.,ymax2_bottom); tl_nb->DrawLine(100.,ymin_bottom,100.,ymax2_bottom); tl_nb->DrawLine(111.,ymin_bottom,111.,ymax2_bottom); tl_nb->DrawLine(122.,ymin_bottom,122.,ymax2_bottom); tl_nb->DrawLine(144.,ymin_bottom,144.,ymax2_bottom); tl_nb->DrawLine(155.,ymin_bottom,155.,ymax2_bottom); tl_nb->DrawLine(166.,ymin_bottom,166.,ymax2_bottom); tl_nb->DrawLine(188.,ymin_bottom,188.,ymax2_bottom); tl_nb->DrawLine(199.,ymin_bottom,199.,ymax2_bottom); tl_nb->DrawLine(210.,ymin_bottom,210.,ymax2_bottom); } gPad->RedrawAxis(); // // CMS_lumi(canvas, iPeriod, iPos, lumi_sqrtS); if(doDataVsMC){ sprintf(tempname,"DataMC_Full_Plot.pdf"); if (pull==1) sprintf(tempname,"DataMCPull_Full_Plot.pdf"); }else{ if(doClosurewoIsoTrackVeto){ if(option.find("QCD")!=string::npos) sprintf(tempname,"Closure_QCD_HDP_woIsoTrack_Full_Plot.pdf"); else sprintf(tempname,"Closure_woIsoTrack_Full_Plot.pdf"); if (pull==1) sprintf(tempname,"ClosurePull_woIsoTrack_Full_Plot.pdf"); }else{ if(option.find("QCD")!=string::npos) sprintf(tempname,"Closure_QCD_HDP_Full_Plot.pdf"); else sprintf(tempname,"Closure_Full_Plot.pdf"); if (pull==1) sprintf(tempname,"ClosurePull_Full_Plot.pdf"); } } canvas->Print(tempname); }
Scale_ByLumi(double newLum=3, int imode=1){ // Scale histogram contents and uncertainty to xxx fb^{-1} char tempname[200]; TH1D * temphist; const int sampleSize=11; string sample[sampleSize]={"TTbar", "WJet_100_200","WJet_200_400","WJet_400_600","WJet_600_inf", "t_top","tW_top","t_antitop","tW_antitop"}; /* TTbar: 806.1 (pb), Wjets HT=100-200: 1.23 * 1817.0 (pb), Wjets HT=200-400: 1.23 * 471.6 (pb), Wjets HT=400-600: 1.23 * 55.61 (pb), Wjets HT=600-inf: 1.23 * 18.81 (pb), Single top T_s: 2 (pb) Single top Tbar_s: 1 (pb) Single top T_t: 103.4 (pb) Single top Tbar_t: 61.6 (pb) Single top T_tW: 35 (pb) Single top Tbar_tW: 35 (pb) */ double sample_xsec[sampleSize]={806.1, 1.23*1817.0, 1.23*471.6, 1.23*55.61, 1.23*18.81, 2.,103.4,35.,1.,61.3,35.}; // in pb double sample_nevents[sampleSize]={25348009, 5257344,4936077,4640594,4581841, 500000,3941400,986100, 250000,1999800,971800}; // total number of events in ntuples double sample_lumi[sampleSize]; // // Looping over different samples // for(int filei=0;filei<sampleSize;filei++){ //####### // Prediction //####### cout << " \n Working on sample: " << sample[filei] << endl; sprintf(tempname,"TauHad2/HadTauEstimation_%s_org.root",sample[filei].c_str()); TFile * file_in = new TFile(tempname,"READ"); if (imode==1) sprintf(tempname,"TauHad2/HadTauEstimation_%s_LumiScaledTo%.1ffbinv.root",sample[filei].c_str(),newLum); else if (imode==0) sprintf(tempname,"TauHad2/HadTauEstimation_%s_%.1ffbinv_OrigRelStatError.root",sample[filei].c_str(),newLum); else { printf("This mode is not supported\n"); break; } TFile * file_out = new TFile(tempname,"UPDATE"); //####### // QCD_Low //####### temphist = (TH1D*) file_in->Get("QCD_Low")->Clone(); cout << " QCD_Low: Before fix: \n ############### \n "; temphist->GetXaxis()->SetRange(1,1); if (filei==0) temphist->Print("all"); else temphist->Print("range"); //sprintf(tempname,"allEvents/PreSel/MHT_PreSel_allEvents"); //double nevents_from_root_file = (* (TH1D*)file_in->Get(tempname)).GetEntries(); sprintf(tempname,"cutflow_preselection"); double nevents_from_root_file = (* (TH1D*)file_in->Get(tempname)).GetBinContent(1); double originalSampleLum = nevents_from_root_file / sample_xsec[filei] / 1000.; // original sample luminosity in terms of fb^{-1} // 1/1000. to convert pb^{-1} to fb^{-1} printf("Sample name = %10s, sample lumi = %8.3f, total events = %8.0f, events from allEvent folder = %8.0f\n", sample[filei].c_str(),originalSampleLum,sample_nevents[filei],nevents_from_root_file ); for (int ibin=0; ibin<temphist->GetNbinsX()+2; ibin++){ // scan including underflow and overflow bins double bin=temphist->GetBinContent(ibin); temphist->SetBinContent(ibin, bin*newLum/originalSampleLum ); double binEr=temphist->GetBinError(ibin); if (imode==1) temphist->SetBinError(ibin, binEr*sqrt(newLum/originalSampleLum) ); else if (imode==0) temphist->SetBinError(ibin, binEr*newLum/originalSampleLum ); } cout << " QCD_Low: After fix: \n ############### \n "; if (filei==0) temphist->Print("all"); else temphist->Print("range"); temphist->GetXaxis()->SetRange(); temphist->Write(); //####### // QCD_Up //####### temphist = (TH1D*) file_in->Get("QCD_Up")->Clone(); cout << " QCD_Up: Before fix: \n ############### \n "; temphist->GetXaxis()->SetRange(1,1); temphist->Print("range"); double originalSampleLum = sample_nevents[filei] / sample_xsec[filei] / 1000.; // original sample luminosity in terms of fb^{-1} for (int ibin=0; ibin<temphist->GetNbinsX()+2; ibin++){ // scan including underflow and overflow bins double bin=temphist->GetBinContent(ibin); temphist->SetBinContent(ibin, bin*newLum/originalSampleLum ); double binEr=temphist->GetBinError(ibin); if (imode==1) temphist->SetBinError(ibin, binEr*sqrt(newLum/originalSampleLum) ); else if (imode==0) temphist->SetBinError(ibin, binEr*newLum/originalSampleLum ); } cout << " QCD_Up: After fix: \n ############### \n "; temphist->Print("range"); temphist->GetXaxis()->SetRange(); temphist->Write(); //####### // searchH_b //####### temphist = (TH1D*) file_in->Get("searchH_b")->Clone(); cout << " searchH_b: Before fix: \n ############### \n "; temphist->GetXaxis()->SetRange(1,1); temphist->Print("range"); double originalSampleLum = sample_nevents[filei] / sample_xsec[filei] / 1000.; // original sample luminosity in terms of fb^{-1} for (int ibin=0; ibin<temphist->GetNbinsX()+2; ibin++){ // scan including underflow and overflow bins double bin=temphist->GetBinContent(ibin); temphist->SetBinContent(ibin, bin*newLum/originalSampleLum ); double binEr=temphist->GetBinError(ibin); if (imode==1) temphist->SetBinError(ibin, binEr*sqrt(newLum/originalSampleLum) ); else if (imode==0) temphist->SetBinError(ibin, binEr*newLum/originalSampleLum ); } cout << " searchH_b: After fix: \n ############### \n "; temphist->Print("range"); temphist->GetXaxis()->SetRange(); temphist->Write(); file_out->Close(); } // Expectation for(int filei=0;filei<sampleSize;filei++){ cout << " \n Working on sample: " << sample[filei] << endl; sprintf(tempname,"TauHad/GenInfo_HadTauEstimation_%s_org.root",sample[filei].c_str()); TFile * file_in = new TFile(tempname,"READ"); if (imode==1) sprintf(tempname,"TauHad/GenInfo_HadTauEstimation_%s_LumiScaledTo%.1ffbinv.root",sample[filei].c_str(),newLum); else if (imode==0) sprintf(tempname,"TauHad/GenInfo_HadTauEstimation_%s_%.1ffbinv_OrigRelStatError.root",sample[filei].c_str(),newLum); TFile * file_out = new TFile(tempname,"UPDATE"); //####### // QCD_Low //####### temphist = (TH1D*) file_in->Get("QCD_Low")->Clone(); cout << " QCD_Low: Before fix: \n ############### \n "; temphist->GetXaxis()->SetRange(1,1); temphist->Print("range"); sprintf(tempname,"cutflow_preselection"); double nevents_from_root_file = (* (TH1D*)file_in->Get(tempname)).GetBinContent(1); double originalSampleLum = nevents_from_root_file / sample_xsec[filei] / 1000.; // original sample luminosity in terms of fb^{-1} // 1/1000. to convert pb^{-1} to fb^{-1} printf("Sample name = %10s, sample lumi = %8.3f, total events = %8.0f, events from allEvent folder = %8.0f\n", sample[filei].c_str(),originalSampleLum,sample_nevents[filei],nevents_from_root_file ); for (int ibin=0; ibin<temphist->GetNbinsX()+2; ibin++){ // scan including underflow and overflow bins double bin=temphist->GetBinContent(ibin); temphist->SetBinContent(ibin, bin*newLum/originalSampleLum ); double binEr=temphist->GetBinError(ibin); if (imode==1) temphist->SetBinError(ibin, binEr*sqrt(newLum/originalSampleLum) ); else if (imode==0) temphist->SetBinError(ibin, binEr*newLum/originalSampleLum ); } cout << " QCD_Low: After fix: \n ############### \n "; temphist->Print("range"); temphist->GetXaxis()->SetRange(); temphist->Write(); //####### // QCD_Up //####### temphist = (TH1D*) file_in->Get("QCD_Up")->Clone(); cout << " QCD_Up: Before fix: \n ############### \n "; temphist->GetXaxis()->SetRange(1,1); temphist->Print("range"); double originalSampleLum = sample_nevents[filei] / sample_xsec[filei] / 1000.; // original sample luminosity in terms of fb^{-1} for (int ibin=0; ibin<temphist->GetNbinsX()+2; ibin++){ // scan including underflow and overflow bins double bin=temphist->GetBinContent(ibin); temphist->SetBinContent(ibin, bin*newLum/originalSampleLum ); double binEr=temphist->GetBinError(ibin); if (imode==1) temphist->SetBinError(ibin, binEr*sqrt(newLum/originalSampleLum) ); else if (imode==0) temphist->SetBinError(ibin, binEr*newLum/originalSampleLum ); } cout << " QCD_Up: After fix: \n ############### \n "; temphist->Print("range"); temphist->GetXaxis()->SetRange(); temphist->Write(); //####### // searchH_b //####### temphist = (TH1D*) file_in->Get("searchH_b")->Clone(); cout << " searchH_b: Before fix: \n ############### \n "; temphist->GetXaxis()->SetRange(1,1); temphist->Print("range"); double originalSampleLum = sample_nevents[filei] / sample_xsec[filei] / 1000.; // original sample luminosity in terms of fb^{-1} for (int ibin=0; ibin<temphist->GetNbinsX()+2; ibin++){ // scan including underflow and overflow bins double bin=temphist->GetBinContent(ibin); temphist->SetBinContent(ibin, bin*newLum/originalSampleLum ); double binEr=temphist->GetBinError(ibin); if (imode==1) temphist->SetBinError(ibin, binEr*sqrt(newLum/originalSampleLum) ); else if (imode==0) temphist->SetBinError(ibin, binEr*newLum/originalSampleLum ); } cout << " searchH_b: After fix: \n ############### \n "; temphist->Print("range"); temphist->GetXaxis()->SetRange(); temphist->Write(); file_out->Close(); } }
// ============================================================================ /// finalize the algorithm // ============================================================================ StatusCode Aida2Root::finalize() { always() << "Get the native ROOT representation of histograms!" << endmsg ; { // loop over all 1D-histograms for ( List::const_iterator ipath = m_1Ds.begin() ; m_1Ds.end() != ipath ; ++ipath ) { /// retrieve the historam by full path: AIDA::IHistogram1D* aida = 0 ; StatusCode sc = histoSvc()->retrieveObject( *ipath , aida ) ; if ( sc.isFailure() || 0 == aida ) { return Error ( "Unable to retrieve 1D-histogram '" + (*ipath) + "'" ) ; } /// convert it to ROOT TH1D* root = Gaudi::Utils::Aida2ROOT::aida2root ( aida ) ; if ( 0 == root ) { return Error ( "Unable to convert to ROOT the 1D-histogram '"+(*ipath)+"'") ; } /// use the native printout from ROOT info() << "The native ROOT printout for 1D-histogram '" << (*ipath) << "':" << endmsg ; root->Print() ; info () << " | Compare | AIDA/HistoStats | ROOT/TH1 | Delta | " << endmsg ; const std::string format = " | %1$-14.14s | %2$ 15.8g | %3$- 15.8g | %4$= 15.8g | " ; info () << print ( Gaudi::Utils::HistoStats::mean ( aida ) , root->GetMean () , "'mean'" , format ) << endmsg ; info () << print ( Gaudi::Utils::HistoStats::meanErr ( aida ) , root->GetMeanError () , "'meanErr'" , format ) << endmsg ; info () << print ( Gaudi::Utils::HistoStats::rms ( aida ) , root->GetRMS () , "'rms'" , format ) << endmsg ; info () << print ( Gaudi::Utils::HistoStats::rmsErr ( aida ) , root->GetRMSError () , "'rmsErr'" , format ) << endmsg ; info () << print ( Gaudi::Utils::HistoStats::skewness ( aida ) , root->GetSkewness () , "'skewness'" , format ) << endmsg ; info () << print ( Gaudi::Utils::HistoStats::skewnessErr ( aida ) , root->GetSkewness ( 11 ) , "'skewnessErr'" , format ) << endmsg ; info () << print ( Gaudi::Utils::HistoStats::kurtosis ( aida ) , root->GetKurtosis () , "'kurtosis'" , format ) << endmsg ; info () << print ( Gaudi::Utils::HistoStats::kurtosisErr ( aida ) , root->GetKurtosis ( 11 ) , "'kurtosisErr'" , format ) << endmsg ; } } { // loop over all 2D-histograms for ( List::const_iterator ipath = m_2Ds.begin() ; m_2Ds.end() != ipath ; ++ipath ) { /// retrieve the historam by full path: AIDA::IHistogram2D* aida = 0 ; StatusCode sc = histoSvc()->retrieveObject( *ipath , aida ) ; if ( sc.isFailure() || 0 == aida ) { return Error ( "Unable to retrieve 2D-histogram '" + (*ipath) + "'" ) ; } /// convert it to ROOT TH2D* root = Gaudi::Utils::Aida2ROOT::aida2root ( aida ) ; if ( 0 == root ) { return Error ( "Unable to convert to ROOT the 2D-histogram '"+(*ipath)+"'") ; } /// use the native printout from ROOT info() << "The native ROOT printout for 2D-histogram '" << (*ipath) << "':" << endmsg ; root->Print() ; } } { // loop over all 3D-histograms for ( List::const_iterator ipath = m_3Ds.begin() ; m_3Ds.end() != ipath ; ++ipath ) { /// retrieve the historam by full path: AIDA::IHistogram3D* aida = 0 ; StatusCode sc = histoSvc()->retrieveObject( *ipath , aida ) ; if ( sc.isFailure() || 0 == aida ) { return Error ( "Unable to retrieve 3D-histogram '" + (*ipath) + "'" ) ; } /// convert it to ROOT TH3D* root = Gaudi::Utils::Aida2ROOT::aida2root ( aida ) ; if ( 0 == root ) { return Error ( "Unable to convert to ROOT the 3D-histogram '"+(*ipath)+"'") ; } /// use the native printout from ROOT info() << "The native ROOT printout for 3D-histogram '" << (*ipath) << "':" << endmsg ; root->Print() ; } } { // loop over all 1D-profiles for ( List::const_iterator ipath = m_1Ps.begin() ; m_1Ps.end() != ipath ; ++ipath ) { /// retrieve the historam by full path: AIDA::IProfile1D* aida = 0 ; StatusCode sc = histoSvc()->retrieveObject( *ipath , aida ) ; if ( sc.isFailure() || 0 == aida ) { return Error ( "Unable to retrieve 1D-profile '" + (*ipath) + "'" ) ; } /// convert it to ROOT TProfile* root = Gaudi::Utils::Aida2ROOT::aida2root ( aida ) ; if ( 0 == root ) { return Error ( "Unable to convert to ROOT the 1D-profile '"+(*ipath)+"'") ; } /// use the native printout from ROOT info() << "The native ROOT printout for 1D-profile '" << (*ipath) << "':" << endmsg ; root->Print() ; } } { // loop over all 2D-profiles for ( List::const_iterator ipath = m_2Ps.begin() ; m_2Ps.end() != ipath ; ++ipath ) { /// retrieve the historam by full path: AIDA::IProfile2D* aida = 0 ; StatusCode sc = histoSvc()->retrieveObject( *ipath , aida ) ; if ( sc.isFailure() || 0 == aida ) { Error ( "Unable to retrieve 2D-profile '" + (*ipath) + "'" ) ; } /// convert it to ROOT TProfile2D* root = Gaudi::Utils::Aida2ROOT::aida2root ( aida ) ; if ( 0 == root ) { Error ( "Unable to convert to ROOT the 2D-profile '"+(*ipath)+"'") ; } /// use the native printout from ROOT info() << "The native ROOT printout for 2D-profile '" << (*ipath) << "':" << endmsg ; root->Print() ; } } return GaudiHistoAlg::finalize() ; }
void makePlotsPP(Settings s) { for(int j = 0; j<s.nTriggers; j++) { s.ppByTrigger[j]->SetLineColor(j+1); s.ppByTrigger[j]->SetLineWidth(1); s.ppByTrigger[j]->SetMarkerColor(j+1); s.ppByTrigger[j]->SetFillColor(j+1); s.ppUsedByTrigger[j]->SetLineColor(kBlack); s.ppUsedByTrigger[j]->SetLineWidth(2); s.ppUsedByTrigger[j]->SetMarkerColor(j+1); s.ppUsedByTrigger[j]->SetMarkerSize(0); s.ppUsedByTrigger[j]->SetFillColor(j+1); s.ppJetsByTrigger[j]->SetLineColor(j+1); s.ppJetsByTrigger[j]->SetLineWidth(1); s.ppJetsByTrigger[j]->SetMarkerColor(j+1); s.ppJetsByTrigger[j]->SetMarkerSize(0.8); s.ppJetsByTrigger[j]->SetFillColor(j+1); } for(int j = 0; j<s.nTriggers_trk; j++) { s.ppByTrigger_trk[j]->SetLineColor(j+1); s.ppByTrigger_trk[j]->SetLineWidth(1); s.ppByTrigger_trk[j]->SetMarkerColor(j+1); s.ppByTrigger_trk[j]->SetFillColor(j+1); s.ppUsedByTrigger_trk[j]->SetLineColor(kBlack); s.ppUsedByTrigger_trk[j]->SetLineWidth(2); s.ppUsedByTrigger_trk[j]->SetMarkerColor(j+1); s.ppUsedByTrigger_trk[j]->SetMarkerSize(0); s.ppUsedByTrigger_trk[j]->SetFillColor(j+1); s.ppMaxtrkByTrigger[j]->SetLineColor(j+1); s.ppMaxtrkByTrigger[j]->SetLineWidth(1); s.ppMaxtrkByTrigger[j]->SetMarkerColor(j+1); s.ppMaxtrkByTrigger[j]->SetMarkerSize(0.8); s.ppMaxtrkByTrigger[j]->SetFillColor(j+1); } //****************************************************************************************************************** //************************************************JET TRIGGER PLOTS********************************************************** //****************************************************************************************************************** TCanvas * c1 = new TCanvas("c1","c1",800,600); c1->SetLogy(); s.ppJets->Scale(100); float Ymin = 0.00000000001; float Ymax = 10; s.ppJets->GetYaxis()->SetRangeUser(Ymin,Ymax); s.ppJets->Draw("h"); for(int i = 0; i<s.nTriggers; i++) s.ppJetsByTrigger[i]->Draw("same"); TLegend * leg = new TLegend(0.47,0.62,0.87,0.92); leg->AddEntry(s.ppJets,"Jet Spectrum (x100)","l"); leg->AddEntry(s.ppJetsByTrigger[0],"MB (I)","p"); leg->AddEntry(s.ppJetsByTrigger[1],"jet 40 (II)","p"); leg->AddEntry(s.ppJetsByTrigger[2],"jet 60 (III)","p"); leg->AddEntry(s.ppJetsByTrigger[3],"jet 80 (IV)","p"); leg->AddEntry((TObject*)0,"ak4Calo Jets, |#eta|<2",""); leg->Draw("same"); c1->SaveAs("plots/png/ppJets_FullSpectrum.png"); c1->SaveAs("plots/pdf/ppJets_FullSpectrum.pdf"); s.ppJets->GetXaxis()->SetRangeUser(20,200); Ymin = 0.0000001; Ymax = 100; s.ppJets->GetYaxis()->SetRangeUser(0.0000001,100); s.ppJets->Draw("h"); for(int i = 0; i<s.nTriggers; i++) s.ppJetsByTrigger[i]->Draw("same"); leg->Draw("same"); TLine * l[3]; for(int i = 0; i<3; i++) { l[i] = new TLine(s.triggerBins[i+1],Ymin,s.triggerBins[i+1],Ymax); l[i]->SetLineWidth(2); l[i]->SetLineStyle(2); l[i]->SetLineColor(1); l[i]->Draw("same"); } TLatex * lat = new TLatex(1,1,"test"); lat->DrawLatex(45,Ymin*3,"I"); lat->DrawLatex(65,Ymin*3,"II"); lat->DrawLatex(85,Ymin*3,"III"); lat->DrawLatex(105,Ymin*3,"IV"); c1->SaveAs("plots/png/ppJets_FullSpectrum_XZoom.png"); c1->SaveAs("plots/pdf/ppJets_FullSpectrum_XZoom.pdf"); c1->SetLogy(0); for(int i = 0; i<s.nTriggers-1; i++) s.ppJetsByTrigger[s.nTriggers-1-i]->Divide(s.ppJetsByTrigger[s.nTriggers-2-i]); s.ppJetsByTrigger[1]->GetYaxis()->SetRangeUser(0,2); s.ppJetsByTrigger[1]->GetXaxis()->SetRangeUser(20,140); s.ppJetsByTrigger[1]->GetXaxis()->SetTitle("Leading jet p_{T}"); s.ppJetsByTrigger[1]->Draw(); s.ppJetsByTrigger[2]->Draw("same"); s.ppJetsByTrigger[3]->Draw("same"); TLegend * leg2 = new TLegend(0.2,0.6,0.5,0.9); leg2->AddEntry(s.ppJetsByTrigger[1],"Jet40/MB","p"); leg2->AddEntry(s.ppJetsByTrigger[2],"Jet60/Jet40","p"); leg2->AddEntry(s.ppJetsByTrigger[3],"Jet80/Jet60","p"); leg2->Draw("same"); c1->SaveAs("plots/png/JetRelativeTurnOnes.png"); c1->SaveAs("plots/pdf/JetRelativeTurnOnes.pdf"); c1->SetLogy(); c1->SetLogx(); s.pp->SetMarkerSize(0.8); s.pp->GetXaxis()->SetRangeUser(0.7,400); s.pp->Draw(); s.ppUsedByTrigger[0]->SetFillColor(kGray); s.ppUsedByTrigger[3]->SetFillColor(kCyan+2); s.ppUsedByTrigger[2]->Add(s.ppUsedByTrigger[3]); s.ppUsedByTrigger[1]->Add(s.ppUsedByTrigger[2]); s.ppUsedByTrigger[0]->Add(s.ppUsedByTrigger[1]); for(int i = 0; i<s.nTriggers; i++) s.ppUsedByTrigger[i]->Draw("HIST same"); s.pp->Draw("sameaxis"); s.pp->Draw("same"); leg->Clear(); leg->AddEntry(s.pp,"pp track Spectrum","p"); leg->AddEntry(s.ppUsedByTrigger[0],"MB trigger","f"); leg->AddEntry(s.ppUsedByTrigger[1],"Jet40 trigger","f"); leg->AddEntry(s.ppUsedByTrigger[2],"Jet60 trigger","f"); leg->AddEntry(s.ppUsedByTrigger[3],"Jet80 trigger","f"); leg->AddEntry((TObject*)0,"|#eta|<1",""); leg->Draw("same"); c1->SaveAs("plots/png/ppTrack_FullSpectrum.png"); c1->SaveAs("plots/pdf/ppTrack_FullSpectrum.pdf"); c1->SetLogy(0); for(int i = 0; i<s.nTriggers; i++) s.ppUsedByTrigger[i]->Divide(s.pp); s.ppUsedByTrigger[0]->GetYaxis()->SetRangeUser(0,2); s.ppUsedByTrigger[0]->GetYaxis()->SetTitle("Relative Contribution to Bin"); s.ppUsedByTrigger[0]->Draw("HIST"); for(int i = 1; i<s.nTriggers; i++) s.ppUsedByTrigger[i]->Draw("HIST same"); s.ppUsedByTrigger[0]->Draw("sameaxis"); leg->Draw("same"); c1->SaveAs("plots/png/ppTrack_FullSpectrum_relativeContribution.png"); c1->SaveAs("plots/pdf/ppTrack_FullSpectrum_relativeContribution.pdf"); c1->SetLogy(); TH1D * jtVsTrk = (TH1D*)s.pp->Clone("jtVsTrkRatio"); //xt plot TFile * outF = TFile::Open("Spectra.root","UPDATE"); TH1D * pp_perMBTrigger_xt = (TH1D*)s.pp_perMBTrigger->Clone("pp_perMBTrigger_xt"); pp_perMBTrigger_xt->Scale(TMath::Power(5020,4.9)); TH1D * pp_xt = new TH1D("ppTrackSpectrum_xt",";x_{T};#sqrt{s}^{4.9}E#frac{d^{3}#sigma}{d^{3}p} (mb/GeV^{2})",s.ntrkBins,s.xt_xtrkbins); for(int i = 1; i< pp_xt->GetSize()-1; i++){ pp_xt->SetBinContent(i,pp_perMBTrigger_xt->GetBinContent(i)); pp_xt->SetBinError(i,pp_perMBTrigger_xt->GetBinError(i)); } pp_xt->Draw(); pp_xt->Print("All"); pp_xt->Write(); c1->SaveAs("plots/png/ppTrack_xt_FullSpectrum.png"); c1->SaveAs("plots/pdf/ppTrack_xt_FullSpectrum.pdf"); outF->Close(); //RpPb bin shift correction //interpolation points float ppintyvals[37+1] = {4.1202/0.5946, 2.8116/0.6211, 1.9778/0.6552, 1.4330/0.6984, 1.0405/0.7219, 0.7719/0.7515, 0.5816/0.7809, 0.3893/0.825, 0.23381/0.866, 0.14395/0.901, 0.09103/0.925, 0.05937/0.965, 0.03906/0.984, 0.014787/1.023, 0.003806/1.052, 0.001181/1.056, 0.0004290/1.048, 0.0001787/1.054, 0.00008152/1.031, 0.00002216/1.023, 0.000004653/1.036, 0.000001402/1.054, 0.0000003180/1.072, 0.00000006850/1.142, 0.00000001971/1.189, 0.000000006013/1.259, 0.000000001910/1.308, 0.0000000007181/1.342, 0.0000000002083/1.382,0.00000000005311/1.407,0.00000000001639/1.363,0.000000000005354/1.381,0.000000000001709/1.316,0,0 };//first 2 points were 4.1202/0.5946*0.999, 2.8116/0.6211*1.003 //float ppintyvals_pPb[s.ntrkBins+1] = {4.1202*0.999, 2.8116*1.003, 1.9778*1.002, 1.4330*0.994 , 1.0405*1.002, 0.7719*1.002, 0.5816*1.002, 0.3893*1.001, 0.23381*1.000, 0.14395*1.004, 0.09103*1.005, 0.05937*0.997, 0.03906*0.998, 0.014787*1.062, 0.003806*1.042, 0.001181*1.033, 0.0004290*1.024, 0.0001787*1.018, 0.00008152*1.015, 0.00002216* 1.109, 0.000004653*1.061, 0.000001402*1.040, 0.0000003180*1.111, 0.00000006850*1.065, 0.00000001971*1.044, 0.000000006013*1.051, 0.000000001910*1.033, 0.0000000007181*1.024, 0.0000000002083*1.078,0.00000000005311*1.05,0.00000000001639*1.034386,0.000000000005354*1.047316,0.000000000001709*1.032760,0,0 }; float ppintyvals_pPb[37+1] = { 4.1202, 2.8116,1.9778, 1.4330 , 1.0405, 0.7719, 0.5816, 0.3893, 0.23381, 0.14395, 0.09103, 0.05937, 0.03906, 0.014787, 0.003806, 0.001181, 0.0004290, 0.0001787, 0.00008152, 0.00002216, 0.000004653, 0.000001402, 0.0000003180, 0.00000006850, 0.00000001971, 0.000000006013, 0.000000001910, 0.0000000007181, 0.0000000002083,0.00000000005311,0.00000000001639,0.000000000005354,0.000000000001709,0,0 };//first 2 points were 4.1202, 2.8116 float ppintyvals_RpPb[37+1] = { 0.5946, 0.6211, 0.6552, 0.6984,0.7219,0.7515, 0.7809, 0.825, 0.866, 0.901, 0.925, 0.965, 0.984, 1.023, 1.052,1.056, 1.048, 1.054, 1.031, 1.023, 1.036, 1.054, 1.072, 1.142, 1.189, 1.259, 1.308, 1.342,1.382,1.407,1.363,1.381,1.316,0,0 };//first 2 points were 0.5946, 0.6211 float ppintyerrRpPb[37+1] = {0.0027/0.5946,0.0028/0.6211, 0.0030/0.6552,0.0032/0.6984,0.0033/0.7219,0.0034/0.7515,0.0036/0.7809,0.003/0.825,0.003/0.866,0.003/0.901,0.003/0.925,0.003/0.965,0.003/0.984,0.002/1.023,0.002/1.052,0.002/1.056,0.002/1.048,0.003/1.054,0.003/1.031,0.003/1.023,0.005/1.036,0.008/1.054,0.001/1.072,0.002/1.142,0.001/1.189,0.002/1.259,0.002/1.308,0.004/1.342,0.004/1.382,0.008/1.407,0.013/1.363,0.019/1.381,0.030/1.316,0,0 };//first 2 points were 0.0027/0.5946,0.0028/0.6211 float ppintyerr_pPb[37+1] = {0.0188/4.1202,0.0128/2.8116, 0.0090/1.9778,0.0065/1.4330,0.0047/1.0405,0.0035/0.7719,0.0026/0.5816,0.0013/0.3893,0.00076/0.23381,0.00047/0.14395,0.00029/0.09103,0.00019/0.05937,0.00013/0.03906,0.000026/0.014787,0.000007/0.003806,0.000002/0.001181,0.0000009/0.0004290,0.0000004/0.0001787,0.00000025/0.00008152,0.00000025/0.00002216,0.00000006/0.000004653,0.000000023/0.000001402,0.000000011/0.0000003180,0.0000000004/0.00000006850,0.00000000011/0.00000001971,0.00000000002/0.000000006013,0.000000000009/0.000000001910,0.000000000004/0.0000000007181,0.0000000000020/0.0000000002083,0.0000000000007/0.00000000005311,0.00000000000031/0.00000000001639,0.00000000000016/0.000000000005354,0.000000000000073/0.000000000001709,0,0 };//first 2 points were 0.0188/4.1202,0.0128/2.8116 TH1D * RpPb = new TH1D("pp_interpolation",";pt;E#frac{d^{3}N}{dPtdyd#phi}",s.ntrkBins,s.xtrkbins); TH1D * RpPbSpectrum = new TH1D("RpPb_interp",";pt;RpPb",s.ntrkBins,s.xtrkbins); TH1D * pPbSpectrum = new TH1D("pPb_data",";pt;E#frac{d^{3}N}{dPtdyd#phi}",s.ntrkBins,s.xtrkbins); for(int i=1; i<s.ntrkBins+1; i++) RpPb->SetBinContent(i,ppintyvals[i-1]); for(int i=1; i<s.ntrkBins+1; i++) RpPb->SetBinError(i,TMath::Power(TMath::Abs(TMath::Power(ppintyerrRpPb[i-1],2)-TMath::Power(ppintyerr_pPb[i-1],2)),0.5)*ppintyvals[i-1]); for(int i=1; i<s.ntrkBins+1; i++) RpPbSpectrum->SetBinContent(i,ppintyvals_RpPb[i-1]); for(int i=1; i<s.ntrkBins+1; i++) RpPbSpectrum->SetBinError(i,ppintyvals_RpPb[i-1]*ppintyerrRpPb[i-1]); for(int i=1; i<s.ntrkBins+1; i++) pPbSpectrum->SetBinContent(i,ppintyvals_pPb[i-1]); for(int i=1; i<s.ntrkBins+1; i++) pPbSpectrum->SetBinError(i,ppintyvals_pPb[i-1]*ppintyerr_pPb[i-1]); //float ppScale = RpPb->GetBinContent(17)/s.pp->GetBinContent(17); //s.pp->Scale(ppScale); TFile * binShift = TFile::Open("BinningAndResolutionCorrection_TrackTrigger.root","read"); TH1D *hBinningAndResol_extendedPt = (TH1D*)binShift->Get("hPt_pseudo2_copy1"); hBinningAndResol_extendedPt->SetDirectory(0); binShift->Close(); /*TH1D *pp_BinShift = (TH1D*)s.pp->Clone("pp_BinShift"); for(int i = 2; i<hBinningAndResol_extendedPt->GetSize()+1; i++) { pp_BinShift->SetBinContent(i-1,pp_BinShift->GetBinContent(i-1)/hBinningAndResol_extendedPt->GetBinContent(i)); pp_BinShift->SetBinError(i-1,pp_BinShift->GetBinError(i-1)/hBinningAndResol_extendedPt->GetBinError(i)); }*/ TFile * outBinF = TFile::Open("Spectra.root","update"); hBinningAndResol_extendedPt->Write("RpPb_binShift_Correction"); TH1D *pp_BinShift = (TH1D*)s.pp_perMBTrigger->Clone("pp_BinShift"); TH1D *pp_BinShift_MB = (TH1D*)s.ppByTrigger[0]->Clone("pp_BinShift_MB"); for(int i = 2; i<hBinningAndResol_extendedPt->GetSize()+1; i++) { pp_BinShift->SetBinContent(i-1,pp_BinShift->GetBinContent(i-1)/hBinningAndResol_extendedPt->GetBinContent(i)); pp_BinShift->SetBinError(i-1,pp_BinShift->GetBinError(i-1)/hBinningAndResol_extendedPt->GetBinContent(i)); pp_BinShift_MB->SetBinContent(i-1,pp_BinShift_MB->GetBinContent(i-1)/hBinningAndResol_extendedPt->GetBinContent(i)); pp_BinShift_MB->SetBinError(i-1,pp_BinShift_MB->GetBinError(i-1)/hBinningAndResol_extendedPt->GetBinContent(i)); } pp_BinShift->Write(); pp_BinShift_MB->Write(); RpPbSpectrum->Write("RpPb_Published"); c1->SetLogy(0); //pPbSpectrum->Divide(s.pp); pPbSpectrum->Divide(pp_BinShift); pPbSpectrum->Scale(1.0/0.098);//<T_{pPb}> From HIN-012-017 pPbSpectrum->Print("All"); pPbSpectrum->GetYaxis()->SetTitle("RpPb"); pPbSpectrum->GetYaxis()->SetRangeUser(0.5,1.5); pPbSpectrum->Draw(); pPbSpectrum->Write("RpPb"); c1->SaveAs("plots/png/pp_RpPb.png"); c1->SaveAs("plots/png/pp_RpPb.pdf"); c1->SaveAs("plots/png/pp_RpPb.C"); /*s.pp->Divide(RpPb); s.pp->GetYaxis()->SetTitle("data/interp"); s.pp->Draw(); */ pp_BinShift->Divide(RpPb); pp_BinShift->GetYaxis()->SetTitle("data/interp"); pp_BinShift->Scale(0.098); pp_BinShift->GetYaxis()->SetRangeUser(0.5,1.5); pp_BinShift->Draw(); pp_BinShift->Write("RpPb_ppVsInterpolation"); float TAAUncert = 0.177; TBox* bTAA = new TBox(0.15,0.1,0.2,0.2); bTAA->SetFillColor(kBlue-9); bTAA->SetFillStyle(1001); bTAA->SetLineWidth(0); bTAA->DrawBox(200,1-TAAUncert,300,1+TAAUncert); c1->SaveAs("plots/png/pp_dataVsInterp.png"); c1->SaveAs("plots/pdf/pp_dataVsInterp.pdf"); c1->SaveAs("plots/png/pp_dataVsInterp.C"); pp_BinShift_MB->Divide(RpPb); pp_BinShift_MB->GetYaxis()->SetTitle("MB data/interp"); //take lumi normalization from the previous made plot (should be same at low pt) float MBScale = pp_BinShift_MB->GetBinContent(5)/pp_BinShift->GetBinContent(5); pp_BinShift_MB->Scale(1/MBScale); pp_BinShift_MB->GetYaxis()->SetRangeUser(0.5,1.5); pp_BinShift_MB->SetMarkerColor(kRed); pp_BinShift_MB->SetLineColor(kRed); pp_BinShift_MB->Draw("same"); TLegend * ppCompareLeg = new TLegend(0.2,0.2,0.5,0.5); ppCompareLeg->AddEntry(pp_BinShift,"Trigger Combined","p"); ppCompareLeg->AddEntry(pp_BinShift_MB,"Only MB","p"); ppCompareLeg->Draw("same"); c1->SaveAs("plots/png/pp_dataVsInterp_MBData_PlusTrigger.png"); c1->SaveAs("plots/pdf/pp_dataVsInterp_MBData_PlusTrigger.pdf"); c1->SaveAs("plots/png/pp_dataVsInterp_MBData_PlusTrigger.C"); delete ppCompareLeg; pp_BinShift_MB->SetMarkerColor(kBlack); pp_BinShift_MB->SetLineColor(kBlack); pp_BinShift_MB->Draw(); pp_BinShift_MB->Write("RpPb_ppVsInterpolation_MBData"); c1->SaveAs("plots/png/pp_dataVsInterp_MBData.png"); c1->SaveAs("plots/pdf/pp_dataVsInterp_MBData.pdf"); c1->SaveAs("plots/png/pp_dataVsInterp_MBData.C"); outBinF->Close(); //************************************************************************************************************ //***********************************************TRACK TRIGGER PLOTS****************************************** //************************************************************************************************************ TCanvas * c2 = new TCanvas("c2","c2",800,600); s.ppMaxtrkByTrigger[4]->SetMarkerColor(kOrange); s.ppMaxtrkByTrigger[4]->SetLineColor(kOrange); c2->SetLogy(); s.ppMaxtrk->Scale(100); Ymin = 0.00000000001; Ymax = 10; s.ppMaxtrk->GetYaxis()->SetRangeUser(Ymin,Ymax); s.ppMaxtrk->Draw("h"); for(int i = 0; i<s.nTriggers_trk; i++) s.ppMaxtrkByTrigger[i]->Draw("same"); TLegend * leg_trk = new TLegend(0.6,0.6,0.9,0.9); leg_trk->AddEntry(s.ppMaxtrk,"Leading Trk p_{T}Spectrum (x100)","l"); leg_trk->AddEntry(s.ppMaxtrkByTrigger[0],"MB (I)","p"); leg_trk->AddEntry(s.ppMaxtrkByTrigger[1],"Track 18 (II)","p"); leg_trk->AddEntry(s.ppMaxtrkByTrigger[2],"Track 24 (III)","p"); leg_trk->AddEntry(s.ppMaxtrkByTrigger[3],"Track 34 (IV)","p"); leg_trk->AddEntry(s.ppMaxtrkByTrigger[4],"Track 45 (V)","p"); leg_trk->AddEntry(s.ppMaxtrkByTrigger[5],"Track 53 (VI)","p"); leg_trk->Draw("same"); c2->SaveAs("plots/png/ppMaxtrk_FullSpectrum.png"); c2->SaveAs("plots/pdf/ppMaxtrk_FullSpectrum.pdf"); s.ppMaxtrk->GetXaxis()->SetRangeUser(10,90); Ymin = 0.0000000001; Ymax = 1; s.ppMaxtrk->GetYaxis()->SetRangeUser(Ymin,Ymax); s.ppMaxtrk->Draw("h"); for(int i = 0; i<s.nTriggers_trk; i++) s.ppMaxtrkByTrigger[i]->Draw("same"); leg_trk->Draw("same"); TLine * l_trk[5]; for(int i = 0; i<5; i++) { l_trk[i] = new TLine(s.triggerBins_trk[i+1],Ymin,s.triggerBins_trk[i+1],Ymax); l_trk[i]->SetLineWidth(2); l_trk[i]->SetLineStyle(2); l_trk[i]->SetLineColor(1); l_trk[i]->Draw("same"); } lat->DrawLatex(16,Ymin*3,"I"); lat->DrawLatex(22,Ymin*3,"II"); lat->DrawLatex(28,Ymin*3,"III"); lat->DrawLatex(40,Ymin*3,"IV"); lat->DrawLatex(49,Ymin*3,"V"); lat->DrawLatex(57,Ymin*3,"VI"); c2->SaveAs("plots/png/ppMaxtrk_FullSpectrum_XZoom.png"); c2->SaveAs("plots/pdf/ppMaxtrk_FullSpectrum_XZoom.pdf"); c2->SetLogy(0); for(int i = 0; i<s.nTriggers_trk; i++) s.ppMaxtrkByTrigger[i]->Rebin(2); for(int i = 0; i<s.nTriggers_trk-1; i++) s.ppMaxtrkByTrigger[s.nTriggers_trk-1-i]->Divide(s.ppMaxtrkByTrigger[s.nTriggers_trk-2-i]); s.ppMaxtrkByTrigger[1]->GetYaxis()->SetRangeUser(0,2); s.ppMaxtrkByTrigger[1]->GetXaxis()->SetRangeUser(10,90); s.ppMaxtrkByTrigger[1]->GetXaxis()->SetTitle("Leading Track p_{T}"); s.ppMaxtrkByTrigger[1]->Draw(); s.ppMaxtrkByTrigger[2]->Draw("same"); s.ppMaxtrkByTrigger[3]->Draw("same"); s.ppMaxtrkByTrigger[4]->Draw("same"); s.ppMaxtrkByTrigger[5]->Draw("same"); TLegend * leg2_trk = new TLegend(0.2,0.6,0.5,0.9); leg2_trk->AddEntry(s.ppMaxtrkByTrigger[1],"Trk18/MB","p"); leg2_trk->AddEntry(s.ppMaxtrkByTrigger[2],"Trk24/Trk18","p"); leg2_trk->AddEntry(s.ppMaxtrkByTrigger[3],"Trk34/Trk24","p"); leg2_trk->AddEntry(s.ppMaxtrkByTrigger[4],"Trk45/Trk34","p"); leg2_trk->AddEntry(s.ppMaxtrkByTrigger[5],"Trk53/Trk45","p"); leg2_trk->Draw("same"); c2->SaveAs("plots/png/TrackRelativeTurnOnes.png"); c2->SaveAs("plots/pdf/TrackRelativeTurnOnes.pdf"); c2->SetLogy(); c2->SetLogx(); s.pp_trk->SetMarkerSize(0.8); s.pp_trk->GetXaxis()->SetRangeUser(0.7,400); s.pp_trk->Draw(); s.ppUsedByTrigger_trk[0]->SetFillColor(kGray); s.ppUsedByTrigger_trk[3]->SetFillColor(kBlue); s.ppUsedByTrigger_trk[4]->SetFillColor(kViolet); s.ppUsedByTrigger_trk[5]->SetFillColor(kCyan+2); s.ppUsedByTrigger_trk[4]->Add(s.ppUsedByTrigger_trk[5]); s.ppUsedByTrigger_trk[3]->Add(s.ppUsedByTrigger_trk[4]); s.ppUsedByTrigger_trk[2]->Add(s.ppUsedByTrigger_trk[3]); s.ppUsedByTrigger_trk[1]->Add(s.ppUsedByTrigger_trk[2]); s.ppUsedByTrigger_trk[0]->Add(s.ppUsedByTrigger_trk[1]); for(int i = 0; i<s.nTriggers_trk; i++) s.ppUsedByTrigger_trk[i]->Draw("HIST same"); s.pp_trk->Draw("sameaxis"); s.pp_trk->Draw("same"); leg_trk->Clear(); leg_trk->AddEntry(s.pp_trk,"pp track Spectrum","p"); leg_trk->AddEntry(s.ppUsedByTrigger_trk[0],"MB trigger","f"); leg_trk->AddEntry(s.ppUsedByTrigger_trk[1],"Track18 trigger","f"); leg_trk->AddEntry(s.ppUsedByTrigger_trk[2],"Track24 trigger","f"); leg_trk->AddEntry(s.ppUsedByTrigger_trk[3],"Track34 trigger","f"); leg_trk->AddEntry(s.ppUsedByTrigger_trk[4],"Track45 trigger","f"); leg_trk->AddEntry(s.ppUsedByTrigger_trk[5],"Track53 trigger","f"); leg_trk->AddEntry((TObject*)0,"|#eta|<1",""); leg_trk->Draw("same"); c2->SaveAs("plots/png/ppTrack_FullSpectrum_trk.png"); c2->SaveAs("plots/pdf/ppTrack_FullSpectrum_trk.pdf"); c2->SetLogy(0); for(int i = 0; i<s.nTriggers_trk; i++) s.ppUsedByTrigger_trk[i]->Divide(s.pp_trk); s.ppUsedByTrigger_trk[0]->GetYaxis()->SetRangeUser(0,2); s.ppUsedByTrigger_trk[0]->GetYaxis()->SetTitle("Relative Contribution to Bin"); s.ppUsedByTrigger_trk[0]->Draw("HIST"); for(int i = 1; i<s.nTriggers_trk; i++) s.ppUsedByTrigger_trk[i]->Draw("HIST same"); s.ppUsedByTrigger_trk[0]->Draw("sameaxis"); leg_trk->Draw("same"); c2->SaveAs("plots/png/ppTrack_FullSpectrum_trk_relativeContribution.png"); c2->SaveAs("plots/pdf/ppTrack_FullSpectrum_trk_relativeContribution.pdf"); c2->SetLogy(); c2->SetLogy(0); jtVsTrk->Divide(s.pp_trk); jtVsTrk->GetYaxis()->SetTitle("pp Jet triggers/pp Track triggers"); jtVsTrk->GetYaxis()->SetRangeUser(0.5,1.5); jtVsTrk->Draw(); TLegend *leg3 = new TLegend(0.2,0.7,0.4,0.9); leg3->AddEntry((TObject*)0,"|#eta|<1 pp",""); leg3->Draw("same"); c2->SaveAs("plots/png/pp_jetVsTrkTriggers.png"); c2->SaveAs("plots/pdf/pp_JetVsTrkTriggers.pdf"); delete c1; delete c2; delete lat; delete leg; delete leg2; delete leg3; delete leg_trk; delete leg2_trk; delete RpPb; delete RpPbSpectrum; delete pPbSpectrum; return; }