Tfile & TFolder

I have a root file (attached) with my histograms contained within folders, but I seem completely unable to access the histograms using FindObjectAny:

However, if I do something which is completely incorrect, I can access the histograms:

So what am I doing wrong? Apologies from a Root newby - and thanks in advance.

A.
lem06_his_0744.root (190 KB)

Do:

TFile* f = new TFile("/Users/alan/Documents/data/LEM_SCFM_June06/lem06_his_0744.root","READ"); TH1F *hDecayHisto = (TH1F*)f->Get("LEMAnaModule/hDecay00"); hDecayHisto ->Draw();
Rene

Thanks for the quick response. Unfortunately, this was one of the many variants I have tried to do over the last few days - and here is the result:

[quote]
root [1] TFile* f = new TFile("/Users/alan/Documents/data/LEM_SCFM_June06/lem06_his_0744.root",“READ”);
root [2] TH1F hDecayHisto = (TH1F)f->Get(“LEMAnaModule/hDecay00”);
root [3] hDecayHisto ->Draw();
Error: illegal pointer to class object hDecayHisto 0x0 149 (tmpfile):1:
*** Interpreter error recovered ***
root [4] [/quote]

Am I doing something wrong, or is there something fishy with the root files (see original post for attached root file)?

Sorry, I did not realize that you had an attachment and that you had saved a TFolder in the ROOT file. The solution is:

TFile f("lem.root") TFolder *histos = (TFolder*)f.Get("histos") TH1F *hDecay = (TH1F*)histos->FindObjectAny("hDecay00"); hDecay->Draw()
Rene

Unfortunately, the solution posted above does not seem to work anymore.

13:32:39 | piet@lxplus206:~/scratch0/TriggerAnalysis> root -l root [0] TFile f("/tmp/piet/TriggerAnalysis/SingleMuon/noise0_g3/results_merge_TriggerAnalysis_SingleMuon_noise0_g3.root"); root [1] TFolder* deff1 = (TFolder*) f.Get("Eta1-5"); root [2] TH1F* heff1 = (TH1F*) deff1->FindObjectAny("Eff.pt5 Eta 1_5"); root [3] heff1->Draw(); Error: illegal pointer to class object heff1 0x0 402 (tmpfile):1: *** Interpreter error recovered *** root [4]

I tried to follow the instructions above, but this didn’t work for me. Are there any comments or maybe a solution. All help would be appreciated. Thanks in advance.
Piet Verwilligen
results_merge_TriggerAnalysis_SingleMuon_noise0_g3.root (37.5 KB)

Hi,

The is a missing white space in your spelling of the histogram name (in general it is not a good idea to have white spaces in names …).

Try:root [0] TFile f("/tmp/piet/TriggerAnalysis/SingleMuon/noise0_g3/results_merge_TriggerAnalysis_SingleMuon_noise0_g3.root"); root [1] TFolder* deff1 = (TFolder*) f.Get("Eta1-5"); root [2] TH1F* heff1 = (TH1F*) deff1->FindObjectAny("Eff. pt5 Eta 1_5"); root [3] heff1->Draw();(i.e. white space after the period ‘.’ after Eff)

Cheers,
Philippe.

Thanks a lot. I never stop making silly mistakes… It’s not my idea, I better change those thinks.
Thanks
Piet