/** * Helper function to extract the histograms from the canvas file. <br> * Takes references to pointers in order to fill them. */ void getHistograms(const TString canvasName, TH1F * & histo1, TH1D * & histo2, const TString & resonance) { std::cout << "canvasName = " << canvasName << std::endl; TFile * inputFile = new TFile("plotMassOutput.root"); TCanvas * canvas = (TCanvas*)inputFile->Get(canvasName); TString resonanceNum("_1"); if( resonance == "Upsilon3S" ) resonanceNum = "_2"; if( resonance == "Upsilon2S" ) resonanceNum = "_3"; if( resonance == "Upsilon" ) resonanceNum = "_4"; if( resonance == "Psi2S" ) resonanceNum = "_5"; if( resonance == "JPsi" ) resonanceNum = "_6"; if( resonance == "Psis" ) resonanceNum = "_1"; if( resonance == "Upsilons" ) resonanceNum = "_2"; if( resonance == "LowPtResonances" ) resonanceNum = "_3"; if( resonance == "AllResonances" ) resonanceNum = "_4"; TPad * pad = (TPad*)canvas->GetPrimitive(canvasName+resonanceNum); histo1 = (TH1F*)pad->GetPrimitive("hRecBestResAllEvents_Mass"); if( resonance == "Z" || resonance == "AllResonances" ) histo2 = (TH1D*)pad->GetPrimitive("Mass_PProf"); else histo2 = (TH1D*)pad->GetPrimitive("Mass_fine_PProf"); // if( resonance == "Z" || resonance == "AllResonances" ) histo2 = (TH1D*)pad->GetPrimitive("Mass_Probability"); // else histo2 = (TH1D*)pad->GetPrimitive("Mass_fine_Probability"); // cout << "histo1 = " << histo1 << ", histo2 = " << histo2 << endl; // cout << "histo1 = " << histo1->GetEntries() << ", histo2 = " << histo2->GetEntries() << endl; }
//---------- Retrieve data histo ----------------- TH1F* GetData(TFile* fin, string region, string varname) { string cname = CHANNEL_NAME+string("/")+region+"/"+varname; TCanvas* c = (TCanvas*) fin->Get(cname.c_str()); TList* l = c->GetListOfPrimitives(); TPad* pad = (TPad*) l->At(0); string hname = "v:"+varname+"|r:"+region+string("|c:")+CHANNEL_NAME+string("|t:1DSumData"); TH1F* h = (TH1F*) pad->GetPrimitive(hname.c_str()); return (TH1F*) h->Clone(); }
TH1F* GetHisto(TFile* fin, string region, string process, string varname, float& norm, bool do_norm, float input_norm) { string cname = CHANNEL_NAME+string("/")+region+"/"+varname; TCanvas* c = (TCanvas*) fin->Get(cname.c_str()); string hname = "v:"+varname+"|p:"+process+"|r:"+region+string("|c:")+CHANNEL_NAME+string("|t:1DEntries"); TH1F* h = 0; if(VERBOSE>0){ cerr<<"cname :"<<cname<<endl; cerr<<"histo name: "<<hname<<endl; cerr<<"pointer: "<<c<<endl; } TList* l = c->GetListOfPrimitives(); TPad* pad = (TPad*) l->At(0); THStack* stack = (THStack*) pad->GetPrimitive(""); h = (TH1F*) stack->GetHists()->FindObject(hname.c_str()); if(do_norm) h->Scale(input_norm/h->Integral()); norm = h->Integral(); return (TH1F*) h->Clone(); }