Error when reading histogram from root file

Hi

I get the following error when trying to read histogram that I previously saved in a root file:

root -l plot.C -q
root [0]
Processing plot.C…
Error: illegal pointer to class object h 0x0 138 plot.C:4:
*** Interpreter error recovered ***

My macro is this:

void plot() {
TFile *f=new TFile(“output_MC10.126046.SherpaWWaTGC1_lnulnu.root”);
TH1F h=(TH1F)f->Get(“m_WplusPt”);
h->Draw();
}

If I open the file in a TBrowser, I can see the histograms perfectly.

Any ideas why my macro doesn’t work?

Thanks,
Kristian

… I left this reply by mistake - please ignore it

Hi,

Either the histogram name is not ‘exactly’ “m_WplusPt” or it is actually in a sub-TDirectory of the TFile (or it is not a TH1F).

Cheers,
Philippe.

Hi Philippe

I used the wrong name - now it works.

Thanks