/////////////////////////////////////////////////////////////////////////////// // the 1st histogram is drawn with "ep" (data) // the secong one - as a histogram (MC) // assume that we have module_name/Hist/hist_name /////////////////////////////////////////////////////////////////////////////// TH1F* get_hist(TString FName, TString ModuleName, TString HistName) { TFile *file; TFolder *fol; const char folder_name[200]; if (FName != "root") { file = gROOT->GetFile(FName.Data()); if (!file) file = new TFile(FName.Data()); if (! file->IsOpen()) { printf(" get_hist: can't open file %s \n",FName.Data()); return 0; } TString s = FName; s.ReplaceAll("/","_"); sprintf(folder_name,"%s_Ana",s.Data()); } else { sprintf(folder_name,"Ana"); } fol = (TFolder*) gROOT->GetRootFolder()->FindObject(folder_name); if (! fol) { fol = (TFolder*) file->Get("Ana"); fol->SetName(folder_name); gROOT->GetRootFolder()->Add(fol); } TString hname = ModuleName+"/Hist/"+HistName; TH1F* h = (TH1F*) fol->FindObject(hname.Data()); return h; }