#include "rootstyle.cc" void correlation(){ 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_h_iso_"}; const vector v_name {"f1", "f3", "weta2" , "wtots1", "reta", "rhad", "rhad1", "rphi", "eratio", "deltaEta1", "deltaPhiRescaled2", "d0", "d0significance", "e_over_p", "numberOfInnermostPixelLayerHits", "numberOfPixelHits", "numberOfSCTHits", "eProbabilityHT", "DeltaPOverP"}; const vector v_name_hist {"f_{1}", "f_{3}", "w_{#eta^{2}}" , "w_{tots1}", "R_{eta}", "R_{had}", "R_{had1}", "R#phi", "e_{ratio}", "#Delta#eta1", "#Delta#phiRescaled2", "d0", "d0sig", "e/p", "nInnermostPixHits", "nPixelHits", "nSCTHits", "eProbHT", "#DeltaP/P"}; const int n_name = v_name.size(); // retrive hist from input file TH2D * h_corr [n_name]; // 2d correlation plot //TH1D * h_projx[n_name]; // projectionx of 2d in 1d TProfile * h_projx[n_name]; // projectionx of 2d in 1d TH1D * h_projy[n_name]; // projectiony of 2d in 1d auto * h_corr_all = new TH1D("correlation", "correlation", 19, 0, 19); // 1d hist with all the correlation factor string name; // canvas const int n_canva {1}; TCanvas *canvas[n_canva]; for(int canva = 0; canva < n_canva; canva++) { name = to_string(canva); canvas[canva] = new TCanvas (name.c_str(), name.c_str(), 1100, 800); canvas[canva] -> Divide(2, 3); } for(int var = 0; var < n_name; var++) { name = dir + v_name[var]; h_corr[var] = (TH2D*)file -> Get(name.c_str()); string new_name = name.substr(name.find_last_of("_") + 1); //cout << "new name: " << new_name << endl; h_corr[var] -> SetTitle(v_name_hist[var].c_str()); h_corr[var] -> GetXaxis() -> SetTitle("E_{T}^{cone0.3} / 25 GeV"); h_corr[var] -> GetYaxis() -> SetTitle(v_name_hist[var].c_str()); h_corr[var] -> GetXaxis() -> SetTitleOffset(1.5); h_corr[var] -> GetYaxis() -> SetTitleOffset(0.8); h_corr[var] -> GetXaxis() -> SetTitleSize(.03); h_corr[var] -> GetYaxis() -> SetTitleSize(.05); h_projx[var] = h_corr[var] -> ProfileX(v_name_hist[var].c_str(), 0, -1); //h_projy[var] = h_corr[var] -> ProjectionY(v_name [var].c_str(), 0, -1, "eo"); // just for y min value!! h_projy[var] = h_corr[var] -> ProjectionY(v_name[var].c_str(), 0, 10); // just for y min value!! if(var < 6) { canvas[0] -> cd(var + 1); h_corr[var] -> Draw(); h_projx[var] -> Draw("hist&l&same"); double xaxis_max = 1.5; double yaxis_min = h_projy[var] -> GetXaxis() -> GetXmin(); Float_t rightmax = h_projx[var] -> GetMaximum(); //cout<<"name: "<< h_projx[var] -> GetName()<GetUymax()/rightmax; //cout<<"pad_max: "<< gPad->GetUymax()<SetLineColor(kRed); h_projx[var]->SetLineWidth(2); //h_projx[var]->Scale(scale); //draw an axis on the right side TGaxis *axis = new TGaxis(xaxis_max, yaxis_min, xaxis_max, rightmax, 0, rightmax, 510, "+L"); axis->SetLineColor(kRed); axis->SetLabelColor(kRed); axis->Draw(); } } // var } // void