I have a root file, which has a TTree named “CollectionTree”, It has a branch (class), which has sub-branches (also class) and sub-sub-branches (class member). The branch is named “McEventCollection_p5_GEN_EVENT”, and it has a sub-branch “m_genParticles”, and the sub-sub-branches are “m_pz”…etc.Then how could I read the deepest class members? For example, I can draw it in command lines by:
(Beside the setup that your experiment might already provide to read the files) you have a few choices. You could use the result TTree::MakeSelector or TTree:::MakeProxy or you could use the TTreeFormula class directly.
Cheers,
Philippe.
PS. [quote]But it cannot work for TBranch *b1 = (TBranch *) CollectionTree->GetBranch(“McEventCollection_p5_GEN_EVENT.m_genParticles.m_pz”);[/quote]This is likely because either the event collection or m_genParticles is not split and does not have its own branch.
I am in the same situation, I want to read event by event but reading the latest comment “This is likely because either the event collection or m_genParticles is not split and does not have its own branch.” it seems it is not possible. Could you please confirm it?
Basically what I want is to access the branch in an event by event basis. I have tried with CollectionTree->MakeClass(“test”) but the variables m_signalProcessId, m_eventNbr, etc (I can see then with TBRowser and plot with CollectionTree->Draw) that are inside McEventCollection_p5_GEN_EVENT are not included in test.h
I have copied a root file and the test.C/h files here: ~cescobar/public/RootTalk
Your print output did not show there there was a sub-branch for McEventCollection_p5_GEN_EVENT.m_genParticles.m_pz and if it is missing from the result of MakeClass that would confirm that it is not there.
Well, with MakeProxy it seems the sub-structure is shown (see attachment) but not sure how to integrate the output of MakeProxy in my framework. I was expecting something similar to the output of MakeClass. So, I am wondering if it is a possibility of using MakeClass but unrolling the classes that are not split as MakeProxy does? I think this will solve my problem.
You should be able to use the result of MakeProxy in a similar way as the MakeClass result (You may have to copy/paste the Loop routine from a MakeClass to the MakeProxy).
I have been trying to integrate the output of MakeProxy in my framework but it seems this is not trivial at all. I would be happier if I could use something more similar to the output of MakeClass (which is much simpler). Anyhow, after investigating a bit it seems the problem is that the leaves in the tree CollectionTree are TNonSplitBrowsable.
I have been trying to see how to loop over these king of objects but I couldn’t find anything.
There is only a few ways. Use the result of MakeProxy or use the TTreeReader (available only ROOT 6) or load the shared library that defines the classes of the object.
I am not sure ‘why’ it is harder to use/embed the result of MakeProxy in your environment. In first approximation you should be able to derive a class from the skeleton and make it behave similarly to MakeClass.
You should be able to use a loop very similar to the one in MakeClass except that the GetEntry ought to be replace by fDirector.SetReadEntry(entry);
and then you can use the name of the branch directly without having to worry about loading the branch.