//////////takes file with correct folder hierarcy and does rebinning IF WANTED, and customizes bin length //////////User Needs to specify in the beginning 1. varname, 2.number of bins in the final histo, 3. REBIN 4. if REBIN, array with binning, FileName #include "TH1.h" #include "TH1F.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "TRint.h" #include "TStyle.h" #include "TLatex.h" #include "THStack.h" #include "TROOT.h" #include #include "TLine.h" #include "TLatex.h" #include "TPave.h" #include "TH1.h" #include "TMarker.h" #include #include "TGraphErrors.h" #include "TGraphAsymmErrors.h" #define REBIN 1 using namespace std; void reform_step2_stack(){ //////CHANGE!!!!!!!!!!! string varName ="mJJ"; const int newhist_size=7; string filename_out="final_F_"+varName+"_7bins_180_v2_stack.root"; Double_t xbins[8]={0,150,300,500,650,800,900,2500};//mjjBbins (7bins_180_v2) TFile *f_undercheck = TFile::Open("output2/intermediate_F_mJJ_v1.root"); TFile *top2 = new TFile(("output2/stack"+filename_out).data(),"recreate"); TDirectory *folders1[5]; TDirectory *folders2[10]; TDirectory *folders3[5]; string sys_cases[3]; string srlist[5]; string samplelist[10]; int colorlist[10]; string channellist[5]; ///CHANGE_CR srlist[0]="WZjj"; srlist[1]="WZQCD"; srlist[2]="ttbar"; srlist[3]="zz"; srlist[4]="WZjj150"; TH1F *hnew; TH1F* pt1; TH1F *final = new TH1F("final","",newhist_size,0,newhist_size); sys_cases[0]="nom"; sys_cases[1]="sys_up"; sys_cases[2]="sys_down"; ///CHANGE_SAMPLELIST samplelist[0]="WZjj"; samplelist[1]="WZEW"; samplelist[2]="ttbar"; samplelist[3]="ttbarV"; samplelist[4]="Zgamma"; samplelist[5]="tZ"; samplelist[6]="Zll"; samplelist[7]="VVV"; samplelist[8]="ZZ"; samplelist[9]="data"; colorlist[0]=0; colorlist[1]=2; colorlist[2]=3; colorlist[3]=4; colorlist[4]=5; colorlist[5]=6; colorlist[6]=7; colorlist[7]=8; colorlist[8]=9; colorlist[9]=40; channellist[0]="EEE"; channellist[1]="EMM"; channellist[2]="MEE"; channellist[3]="MMM"; channellist[4]="eee"; cout<< "CREATED folders"<Get(histo_name2.c_str()); pt1->SetFillColor(kGreen); if (REBIN) { hnew = (TH1F*)pt1->Rebin(newhist_size,"hnew",xbins); // cout<<"REBIN!"<Clone("hnew"); } // hnew->SetFillColor(colorlist[sample_iter]); // hnew->SetLineColor(2); hnew->SetFillColor(kGreen); hnew->SetFillStyle(3001); TCanvas *c0= new TCanvas(); hnew->Draw(); delete c0; // hs->Add(hnew); } // auto dir = top2->GetDirectory((pathname.data())); string stackname =srlist[cregion_iter]+"_"+channellist[channel_iter]+".pdf"; hs->SetName(stackname.data()); hs->Write(); TCanvas *c1= new TCanvas(); hnew->SetFillColor(kGreen); hnew->SetFillStyle(3001); hnew->Draw("HIST"); c1->Update(); c1->SaveAs(stackname.data()); delete c1; } } TCanvas *c1= new TCanvas(); pt1->Draw(); c1->Update(); TCanvas *c2= new TCanvas(); hnew->Draw(); c2->Update(); cout<<"File was written and saved as: "<