Re: [ROOT] Leaves that are a dynamic array. (fwd)

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed May 08 2002 - 23:24:54 MEST


Hi Martin

Apparently you did not get my reply to your mail.

See an example at$ROOTSYS/tutorials/tree2.C

Rene Brun

On Wed, 8 May 2002, Martin Turner wrote:

> 
> 
> ---------- Forwarded message ----------
> From: Martin Turner <martin@hep.ph.liv.ac.uk>
> To: Rene Brun <Rene.Brun@cern.ch>
> Date: Wed, 8 May 2002 21:59:59 +0100 (BST)
> Subject: Leaves that are a dynamic array.
> 
> Hi Root experts. I'm afraid I stumbled across another problem. Hopefully
> this will be quick.
> I want to build arrays of variable size onto a single branch. What is
> wrong with these code snippets:
> 
> fLambdaBfile = new TFile("LambdaB_analysis.root","recreate");
> fLambdaB_tree = new TTree("LambdaB_analysis","lambdaB analysis tree");
> fLambda_selection.fcandidate=10;//initialize size of the arrays to
> 					something
> 
> fLambdaB_tree->Branch("Lambda_selection",&fLambda_selection,"fcandidate/I:==>
> flambda_momx[fcandidate]/D:flambda_momy[fcandidate]:flambda_momz[fcandidate]:==>
> ftrack_idi[fcandidate]/I:ftrack_idj[fcandidate]:ftrack_motheridi[fcandidate]:==>
> ftrack_motheridj[fcandidate]:ftrack_granidi[fcandidate]:==>
> ftrack_granidj[fcandidate]:fientry");
> 
> members are defined in the header file like this:
> 
>   struct Lambda_selection{
> Int_t        fcandidate;
> Double_t     flambda_momx[10];
> Double_t     flambda_momy[10];
> Double_t     flambda_momz[10];
> Int_t        ftrack_idi[10],ftrack_idj[10];
> Int_t        ftrack_motheridi[10],ftrack_motheridj[10];
> Int_t        ftrack_granidi[10],ftrack_granidj[10];
> Int_t        fientry;
> };
>  Lambda_selection    fLambda_selection;
> 
> When defining the branch, if I replace [fcandidate] with [10] I don't have
> a problem, just a lot of wasted memory. fcandidate never exceeds 10. At
> the TTree::Branch the error is:
> 
> ERROR leaf:flambda_momx, len=10 and max=0
> ERROR leaf:flambda_momy, len=10 and max=0
> etc.
> Putting fcandidate last on the list gives an "Illegal leaf" error. How do
> I get round this without splitting my leaves onto seperate branches?
> 
> Thanks for yor help.
> Martin
> 
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:52 MET