Re: Typical analysis: add leaves to existing tree. Efficient ? Doable ?

T Auger (thauger@phns27.cern.ch)
Thu, 3 Sep 1998 14:10:31 +0200


Stephen Bailey writes:
>
> The additional information is helpful, but I have also wanted
> to do the general case of adding information to a pre-existing
> TNtuple as David described. e.g. I have an ntuple coming from
> h2root which contains particle track parameters. I loop through
> the events, making invariant masses for candidate decays, etc.
> It would be very nice if I could add this invariant mass info back
> to the original TNtuple so that all of the original information would
> still be there for when I want to make interactive cuts later. For
> now I put the invariant mass info into another ntuple along with any
> data from the original ntuple that I think I might need. Copying the
> data seems a bit wasteful, but I'm not sure how else to do it for
> now.
>
> But I'm not sure how realistic this request is, both in terms of
> ease of implementation and efficiency of running. But if it was
> possible to add leaves to an existing TNtuple, I'd use that feature...
>
> Regards,
>
> Stephen
>
>
>
It makes a lot of sense to be able to add leaves to a tree after it
was created, at one point I wanted to do that myself. However, I use a
different approach which can be useful for small event size type analysis.
To be able to use the tree.Draw() function and make cuts on it, I
defined a Event class which does contain method returning invariant
masses, missing masses, angles for certain type of particle, etc... :

Float_t TClasEvent::InvM_gp() {
...
return(inv_mass);
}

Then when creating the tree, I use the split switch set to 0. That
way, the event is saved as a TObject and is no longer a collection of
leaves. Then when I want to draw a quantity I simply need to call the
method I defined InvM_gp() like that :
T.Draw("event.InvM_gp()","event.InvM_gp()>0&&event.Mm_ppip()>0.5")

All of that works because I store the event with the non-split method.

Therefore, I do not want to store these kinematic quantities anymore
since I can recalculate them on the fly.
Of course the drawback is that I have to read back the entire event
from the file which means that it takes longer to draw my
histograms. But I still prefer it because, I do not need to re-create
my tree when I add a cut, I just change the shared library TClasEvent that I
created.

hope this helps,
Thierry