Re: variable length array leafs in TTree

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Wed, 19 Jan 2011 14:39:58 +0100


Hi,

we got all three of your emails :-)

You could simply define

Int_t Length;
Int_t* Array; //[Length]

That way, ROOT knows that only Length elements in Array are filled.

Now to your real question: you could use Alt$(Array[0]==1 && Array[1]==-1, Array[0]==-1) where the second parameter is used if the first doesn't exist. See the documentation for TTree::Draw():
<http://root.cern.ch/root/html/TTree#TTree:Draw%2>

Cheers, Axel.

gerontas wrote on 01/19/2011 08:23 AM:
> Hello roottalk,
>
> I have a TTree which includes an integer value, Length, and an
> integer array Array, with 'Length' elements.
> In the way it is created (to save space), Array[i] is only written
> if Length>=i.
>
> When I try to project (or draw, or...) from this tree the following
> >tree->Draw("somevariable","(Length>0 && Array[0]==-1)||(Length>1 &&
> Array[0]==1 && Array[1]==-1)
> only the entries for which there exists an Array[1] element are
> selected. (In other words, ROOT does check the existence of all
> elements making up the varexp for validity, irrespective of the
> "local logic" validity). Then only the AND of the two expressions
> instead of the OR is returned.
> I think this is the correct thing to do (it would be dangerous to
> assume the existence of all variables), but I am not sure how to
> circumvent this problem...Should I revert to a fixed array length?
>
> Thanks,
> PS
>
>
Received on Wed Jan 19 2011 - 14:40:02 CET

This archive was generated by hypermail 2.2.0 : Wed Jan 19 2011 - 17:50:01 CET