I am sorry to bother but I am not sure I understood your point.
I know what a TTree and a TChain are and why are they useful in analysis…
…but I don’t understand: why the TChain OBJ is not appearing with the .ls command?
This was very kind and so useful: thank you so much!!
Considering your extremely clarity and patience in explaining things,
could you please tell me how can I get a list of the chains declared in a session?
Hi mmoo,
to answer your original question, a TChain is just a useful wrapper around files and TTrees, which lets you read multiple TTrees in multiple files as if you were manipulating just one TTree (the chain takes care of switching between files and extracting the trees from it for you).
As a consequence, TChains are not something that is stored in TFile, and therefore do not appear in .ls.
Usually this is not a problem: you should know what variables you have created; .ls is commonly used to check what’s inside the latest file you opened, and should be equivalent to gDirectory->ls().
Thank you so much for the explanation, Enrico!
But, if I create a TTree and a TChain in the interactive session, is there a way to access them by object type?
More generally, is it possible to access all the object created in an interactive session without pretending to actually know their names?
Hi,
see @Wile_E_Coyote’s latest reply for methods that return certain subsets of objects registered in ROOT.
I don’t know whether there are methods to retrieve “anything with a name”, but what’s your use-case exactly (i.e. why do you need such a thing)? There might be an easier way to reach whatever your goal is.
Hi Enrico,
methods suggested by Wile_E_Coyote are fine to list TChain, but “just” that.
To answer to your question, I would like to crate a sort of SaveSession function which saves certain type of objects (like TChain) that I created in the interactive ROOT session.
More precisely, in my analysis I use lots of chains and I have to perform several selections both with TCut and TCutG and I would like to save each one of them in order to be able to resume/reload the session with all the cuts I have already created.
Uhm I wouldn’t know how to save the state of an interactive session, sorry (I don’t do that much work in the root interpreter).
Of course you could keep your TCuts and TCutGs in a collection and write those to file before exiting the session.
You could also write smll helper functions StoreAndApply(TCut &, TChain &) and WriteCuts() that append to the collection of applied cuts and write the current state of the collection to a file, so you don’t have to do it manually.
Thanks Enrico for the suggestion: I was thinking to something similar too!
About that, do you have any idea of how can I add each TCut and TCutG to a TList for example?
Because I wanted to write something general and almost automatic…