Extract a histogram from a root file

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


I am trying to extract a histogram from a file. My code is like this

TH1F *nom_hist=0;

hist_files_ = TFile::Open(“nominal_ZJets.root”, “read”);

Or this

TFile hist_files_=new TFile(“nominal_ZJets.root”,“read”);
nom_hist = (TH1F

it seems not working. Could somebody help me to figure out what is going wrong? I am also attaching the root file and the code

getH.cpp (433 Bytes)
nominal_ZJets.root (3.8 KB)


thank you,

the final v in "m4l_ggF_2mu2e_13Tev" is lower case, you are writing it upper case, could that be it?

$ root nominal_ZJets.root
root [0]  _file0->ls()
TFile**		nominal_ZJets.root	
 TFile*		nominal_ZJets.root	
  KEY: TH1F	m4l_ggF_2mu2e_13Tev;1	ZJets
root [1] _file0->Get("m4l_ggF_2mu2e_13Tev") // works
(TObject *) 0x564ffa787af0
root [2]

Yes right, it was so obvious eventually…

thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.