I was wandering if there is a way to access the linux file name of a file that contains a tree aded to a chain when using TSelector.
Then if i process the chain ch, using TSelector, can I access the individual filename being process event by event?
Thank you and best regards,
const char *current_file_name = ch.GetFile()->GetName();
With your suggestion I managed to get the solution as follows:
const char *current_file_name = Myselector::fChain->GetCurrentFile()->GetName();
Are you saying that the http://root.cern.ch/root/html/TChain.html#TChain:GetFile doesn’t work and you have to use http://root.cern.ch/root/html/TTree.html#TTree:GetCurrentFile (note that this method may easily return 0, I believe)?
Maybe you could try:
const char *current_file_name = ((TChain*)(Myselector::fChain))->GetFile()->GetName(); where the “(TChain*)fChain” casting may be needed because the automatically generated skeleton source code often defines a “TTree *fChain;” instead of a “TChain *fChain;”.
Yes, that’s right. The TSelector skeleton built a TTree for fChain.
Now casting TChain, the method “GetFile()” works fine.