Reading a TTree which contains a TCloneArray

Hello,
I have a maybe trivial question, but I couldn’t find the answer in the tutorial.
I’m trying to read a TTree with contains different branches, and one of them is a TCloneArray, containing different arrays.
I read the different branches by:
Short_t Multiplicity;
tree->SetBranchAddress(“fNParticles”,&Multiplicity);
if they are scalars, and by
Int_t *Z[MAX];
tree->SetBranchAddress(“charges”, Z);
if they are vectors.
But I don’t know how to access to the contain of the TCloneArray (ParticleList). It contains different arrays, such as A[], csi[] etc and when I type
tree->Print()
I get:

*Br 5 :stuck_out_tongue:articleList.A : A[fParticleList_] *
*Entries : 246306 : Total Size= 11168958 bytes File Size = 2646108 *
*Baskets : 118 : Basket Size= 102400 bytes Compression= 4.18 *

How can I read, for each entry, the contents of A[ ]?
I have tried:
Int_t *A[MAX];
tree->SetBranchAddress(“ParticleList.A”, A);
but, when I loop on the entries by
tree->GetEntry(i)
A[] is always empty.

Thanks in advance for your help
Cheers

Paola

Hi,

I recommend that you study the result of running MakeSelector (or MakeClass) on your TTree. Not only would it contain the exact syntax you are looking for but you can then use as the skeleton for your analysis.

Cheers,
Philippe.

Hi,
I guess that your answer means that there is no an easier method to read that Branch, right?
Thank you for your answer, I’ll try to study MakeSelector() to figure out how to access to that variable.
Cheers
Paola

Hi Philippe,
thank you very much! It works fine and I’ve found the answers to my question!
Cheers
Paola

Hello,
I still have a very similar problem. My TTree contains a TClonesArray, which in turn contains different arrays (among these fA[]). This time when I type
t->Print()
I don’t get any indication that the arrays in TClonesArray are present (I cannot see their name etc) and when i run t->MakeSelector(“my_code”) in my_code.h and .c these arrays are not present. But I’m sure that they are there, because I can type
t->Draw(“fParticleList.fA”)
and get the particle mass distribution.
From the ROOT terminal, when I run:
TTree *t
Int_t fParticleList_;
TBranch *b_event_fParticleList_;
TBranch *b_fParticleList_A;
Int_t *A[MAX];
t->SetMakeClass(1);
t->SetBranchAddress(“fParticleList”, &fParticleList_, &b_event_fParticleList_);
t->SetBranchAddress(“fParticleList.fA”, A, &b_fParticleList_A);

according to what I obtain from t->MakeSelector(“code”) for a similar TTree (where instead I can see the arrays contained in the TClonesArray), it seems that there isn’t any branch named fA
Error in TTree::SetBranchAddress: unknown branch -> fParticleList.fA
but, again, I’m sure that it’s there because I don’t get any error typing: t->Draw(“fParticleList.fA”)

Where am I wrong? How can I access to fA if it seems that even MakeSelector doesn’t see that branch?
Thank you for your help

Cheers
Paola

PS I don’t now if it helps, but when I do b_event_fParticleList_->SplitLevel() I get 0

[quote] But I’m sure that they are there, because I can type t->Draw(“fParticleList.fA”) and get the particle mass distribution.[/quote]This indicates that the data is present but does not say anything about the presence of the branch.

[quote]This time when I type t->Print() I don’t get any indication that the arrays in TClonesArray are present [/quote]This indeed indicates that that the (sub)branches are not present.

[quote]PS I don’t now if it helps, but when I do b_event_fParticleList_->SplitLevel() I get 0[/quote]This confirms the information gather above. The fParticleList branch is not split and thus has not sub-branches. This means that you can not access the various parts of fParticleList independently and that you must always read them as whole. This also means that this data is not accessible via the MakeSelector skeleton (as it requires the setting MakeClass(1) which prevent the use of objects … which are necessary to read un-split branches).

If you can not regenerate the file in split mode, you can try out the skeleton produced by MakeProxy that will give you access to the content of unsplit branches.

Cheers,
Philippe.

Thank you very much Philippe, it helps me to understand the structure of the file.
Cheers
Paola