Re: [ROOT] on the fly complex calculations in TTree::Draw

From: Luiz Martins Mundim Filho (mundim@uerj.br)
Date: Sat Oct 27 2001 - 01:44:20 MEST


Hi

Is it possible to use your solution when the formula is a C++ file? If
so, I would like to have a copy of your macro too, if possible. Thanks in
advance.

Cheers

Luiz


Gene Van Buren wrote:

> Hi Andre,
>
> I was looking through the roottalk archives and saw your post at
> the bottom of this email. I saw Rene's reply, but thought I'd tell you
> what I do. I create TTreeFormulas (as you suggested). I then add
> these formulas to the Root list of functions:
>
> TSeqCollection* ListOfFuncs = gROOT->GetListOfFunctions();
> f1 = new TTreeFormulas(.....);
> f2 = new TTreeFormulas(.....);
> ...
> ListOfFuncs->Add(f1);
> ListOfFuncs->Add(f2);
> ...
>
> In fact, I wrote a macro which defines all my "functions" for
> me, and in it I wrote a function "formulate()" which takes
> the TTreeFormula arguments and automatically creates
> and adds the function to the global list.
>
> It works not only for selections but for drawing purposes
> and it's great! My macro defines ~1000 functions this way  :-)
> I'd be happy to send you the macro so you can see what
> I do if you'd like.
>
> The power of this is fantastic because you can make
> new formulas that use the other formulas. It thus becomes
> similar to writing a C++ class of member functions using
> the data members of the class (tree) as a base. In this way,
> I have "implemented" all the member functions for any
> functions I would have wanted to make hsitograms of
> in a way that they can be used with TTree::Draw, which
> can be MUCH faster than using MakeClass-created
> event loops. Depends on how many of the tree variables
> you use and if the TTree is on a file.
>
> -Gene Van Buren
>
> ---------------------------------------------
> You wrote:
> Hello rooters,
>
> I have some TTree of events. For each event, I'd like to perform
> a complex calculation (e.g. calculate the value of a pdf based
> on a variable in the event or combine multiple pdf values).
>
> I currently have a method in this calculation class to which
> I can give a TTree and it plots the distribution of this value
> (possibly after some cuts).
>
> However, I would find it much more convenient, if I could
> use such a calculation directly in TTree::Draw (as a value,
> as a cut would also be useful !).
>
> I'm thinking of the following example:
>
>     TTree *signal_events, *background_events, *data_events;
>     ...
>
>     MyCalculation *calc = new MyCalculation;
>     calc->calculate_pdfs_from_mc(signal_events,background_events);
>     calc->SetName("final_discriminant");
>     ...
>     data_events->Draw("final_discriminant");
>     data_events->Draw("mass","final_discriminant>0.9");
>
> So here's my question: Is it possible in root
> to have a class (which e.g. inherits from TTreeFormula ??)
> which can be registered in some dictionary and then can be
> used in TTree::Draw in an expression ?
>
> thanks for the advice,
>
> André



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:04 MET