#include "rootstyle.cc" void plot(){ rootstyle(); TH1::SetDefaultSumw2; // input file auto file = new TFile ("hist.root"); if ( !file->IsOpen() ) printf("File no found!!\n"); string dir {"MediumLLH_Smooth_v11/MediumLLH_Smooth_v11_"}; //const vector v_temp {"tempFailedLoose", "tempVar1", "temp6"}; const vector v_temp {"tempFailedLoose"}; //const vector v_temp {"temp6"}; const vector v_region {"peak", "tail"}; const vector v_eta {"barrel", "endcap"}; const vector v_pt {"l0-20", "20-25", "25-40", "gt40"}; string name; const int ntemp = v_temp.size(); const int nregion = v_region.size(); const int neta = v_eta.size(); const int npt = v_pt.size(); // retrive hist fron input file TH1D * templates [ntemp][nregion][neta][npt]; TH1D * templates_ref[ntemp][nregion][neta][npt]; for (int temp = 0; temp < ntemp; temp++) { for (int region = 0; region < nregion; region++) { for (int eta = 0; eta < neta; eta++) { for (int pt = 0; pt < npt; pt++) { name = dir + v_temp[temp] + "_" + v_region[region] + "_" + v_eta[eta] + "_" + v_pt[pt]; templates [temp][region][eta][pt] = (TH1D*)file -> Get(name.c_str()); if(temp == 0) { name = dir + "tempFailedLoose_ref_" + v_region[region] + "_" + v_eta[eta] + "_" + v_pt[pt]; templates_ref[temp][region][eta][pt] = (TH1D*)file -> Get(name.c_str()); } } // pt } // eta } // region } // temp // canvas TCanvas *canvas[3]; for (int temp = 0; temp < ntemp; temp++) { name = v_temp[temp]; canvas[temp] = new TCanvas (name.c_str(), name.c_str(), 1300, 790); canvas[temp] -> Divide(4, 2); } // legend auto legend = new TLegend(0.2, 0.1, 0.9, 0.9); legend ->SetTextSize(0.04); legend ->SetTextFont(102); // determine scale from tail for a given pt and eta, temp/temp_ref double scale[3][0][2][4]{}; // [temp][ratio so 0!!][eta][pt] for (int temp = 0; temp < ntemp; temp++) { for (int eta = 0; eta < neta; eta++) { for (int pt = 0; pt < npt; pt++) { double num = templates [temp][1][eta][pt] -> Integral(); double den = templates_ref[ 0 ][1][eta][pt] -> Integral(); double scale{1}; if (den != 0) scale = num / den; // scale tail and peak hist templates_ref[0][1][eta][pt] -> Scale(scale); // not necessary templates_ref[0][0][eta][pt] -> Scale(scale); // to measure distorsion // draw hist if (temp == 0) { int pad = 4*eta + pt + 1; canvas[temp] -> cd(pad); name = v_pt[pt] + "_" + v_eta[eta]; double maxhist = std::max(templates[temp][0][eta][pt] -> GetMaximum(), templates_ref[0][0][eta][pt] -> GetMaximum()); templates [temp][0][eta][pt] -> SetLineColor(kRed); templates [temp][0][eta][pt] -> SetTitle(name.c_str()); templates [temp][0][eta][pt] -> GetXaxis() -> SetTitle("E_{T}^{cone0.3}/25 GeV"); templates [temp][0][eta][pt] -> GetXaxis() -> SetTitleOffset(2.5); templates [temp][0][eta][pt] -> GetYaxis() -> SetTitle("Entries"); templates [temp][0][eta][pt] -> GetYaxis() -> SetTitleOffset(2.5); templates [temp][0][eta][pt] -> GetYaxis() -> SetRangeUser(0, maxhist + maxhist*0.2); templates [temp][0][eta][pt] -> GetXaxis() -> SetRangeUser(0, 0.3); templates_ref[0][0][eta][pt] -> SetLineColor(kBlue); templates_ref[0][0][eta][pt] -> GetXaxis() -> SetRangeUser(0, 0.3); // ratio auto ratio = new TRatioPlot(templates[temp][0][eta][pt], templates_ref[0][0][eta][pt]); canvas[temp] -> SetTicks(0, 1); std::vector lines = {0.8, 0.9, 1., 1.1, 1.2}; ratio -> SetGridlines(lines); ratio -> Draw(); ratio -> GetLowerRefGraph() -> SetMinimum(-1); ratio -> GetLowerRefGraph() -> SetMaximum(2); canvas[temp] -> Update(); } // template failed loose } // pt } // eta } // temp } // void