Can't get TTree from file located on CASTOR

Hello all,

Could someone please help with my problem?

I’m trying to read ROOT file located on CASTOR:

[kskovpen@lxplus232]~/work/testarea/15.6.5.5/PhysicsAnalysis/AnalysisCommon/UserAnalysis/run/proc% root
root [0] f=TFile::Open(“rfio:/castor/cern.ch/user/k/kskovpen/data09_900GeV.root”);
root [1] TTree tr = (TTree)f->Get(“rfio:/castor/cern.ch/user/k/kskovpen/data09_900GeV.root:/StudyElectrons/elec_1”);
root [2] tr->GetName();
Error: illegal pointer to class object tr 0x0 2522 (tmpfile):1:
*** Interpreter error recovered ***
root [3]

So, the pointer is NULL… It’s quite strange because this TTree was properly filled. Maybe I’m doing something completely wrong here?

Thank you in advance,

Kirill

Hi,

I’m surprised that you would have to state the filename again when extracting the tree from the file - but then again I’ve never used castor… Anyway, try that:

TTree tr = (TTree)f->Get(“StudyElectrons/elec_1”);

Cheers, Axel.

Hi Axel!

Thanks again for the help! It worked! Though it’s still interesting why it is not working if given the whole link to TTree…

Thanks,

Kirill

[quote]Though it’s still interesting why it is not working if given the whole link to TTree… [/quote]The function TFile::Get expects a name relative to the file it is being called on ; In the general case supporting the syntax as you expected it would require TFile::Get to open yet another TFile object hence effectively executing an action on a TFile object different from the one you explicitly requested the action to be executed on … leading to confusion …

Philippe.

Thank you! All clear!