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

Nick van Eijndhoven (Nick@phys.uu.nl)
Thu, 03 Sep 1998 09:18:08 +0200


Stephen Bailey wrote:
>
> On Wed, 2 Sep 1998, Rene Brun wrote:
>
> > David Rousseau, CERN wrote:
> > >
> > > Hi Rooters,
> > >
> > > Browsing the documentation, it's not clear to me how I should do the
> > > following (not unusual) thing:
> > > Starting from a TTree (a converted Ntuple) with lots of events and variables,
> > > I want to compute a few complex variables for each of a few selected events,
> > > and store them to be able to use them many times (for example
> > > to do an unbinned maximum likelihood fit).
> > > With Fortran/Hbook I would read the ntuple, select the events, and put
> > > the few complex variables for each of a few selected events in a common. Then
> > > my MINUIT FCN would use this common.
> > > With Root, I imagine I can do exactly the same thing, create a new
> > > TTree with only the variables I need and the events I need. Then my MINUIT
> > > FCN would use this TTree. But I would have lost all links to the original
> > > event data.
> > > But since I was told in C++ course that I have to think completely different,
> > > I thought I could do the following: add a selection flag as a leaf
> > > to all events (not even sure if and how it is doable), add my complex
> > > variables as new leaves to the event which are selected. Then my MINUIT FCN
> > > would read first the event flag, then the complex variables only for the good
> > > events (as explained in the web pages).
> > > So, what is the right way ?
> > >
> > > Note: the examples on the web are in the style: I loop once on the events and
> > > fill histograms. I would like to do (but maybe I shouldn't):
> > > I loop on the events, and add information to be used later.
> > >
> > > Thanks a lot
> > >
> > > David Rousseau
> >
> > David,
> > What you want to do makes a lot of sense.
> > I recently added in version 2.00/11 a few utilities in this direction.
> > Look at the documentation of TTree::Draw ("Getting more info").
> > After a TTree::Draw call, you have access to all the information
> > computed in the function. You can call TMinuit with the resulting
> > arrays.
> >
> > Rene Brun
> >
>
> 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

Hi Stephen,
I am playing around with some ALICE calorimeter data to do exactly the
same (i.e. reconstruct pi0's from photon pairs).
The way I solved the problem is to have h2root create a Tree with
'original data'. Then I read this data tree and each read-in
useful variable I use to provide data to the ALICE Track, Jet etc...
objects. In addition I create Invmass objects for the found pi0's.
At the end I write all my objects to an output Tree (which now
contains all data) and afterwards I delete the original h2root produced
tree whic is not needed any longer.
Afterwards it is easy to interactively investigate the data from the
newly produced data Tree using the ALICE class library.

So the message is that one should regard the h2root produced Tree
only as an intermediate product in the process of converting old data
to pure C++/ROOT class objects and not as some final data bank for analysis.

Hope this helps you forward a bit.

-- 

Cheers,

_/_/ _/ _/ _/_/_/_/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ _/ _/_/ _/ _/ _/ _/ _/ _/ _/ _/_/_/_/ _/ _/

*----------------------------------------------------------------------* Dr. Nick van Eijndhoven Department of Subatomic Physics email : nick@phys.uu.nl Utrecht University / NIKHEF tel. +31-30-2532331 (direct) P.O. Box 80.000 tel. +31-30-2531492 (secr.) NL-3508 TA Utrecht fax. +31-30-2518689 The Netherlands WWW : http://www.phys.uu.nl/~nick Office : Ornstein lab. 172 ---------------------------------------------------------------------- tel. +41-22-7679751 (direct) CERN PPE Division / ALICE exp. tel. +41-22-7675857 (secr.) CH-1211 Geneva 23 fax. +41-22-7679480 Switzerland CERN beep : 13+7294 Office : B 160 1-012 *----------------------------------------------------------------------*