Hi Gene,
I am happy that you find TTreeFormula useful. Your implementation
could be certainly generalized and introduced in the system.
I just want to make a remark about your comparison with MakeClass.
The code generated by TTree::MakeClass/MakeSelector has never been
thought as a replacement for TTree::Draw. Using this generated code
you can do many things that you cannot do in TTree::Draw.
The main limitations of TTree::Draw are:
- You produce one single histogram as result
- The selection mechanism is limitated by what you can specify
to TTreeFormula
- TTreeFormula uses interpreted code in many places.
With the code generated by TTree::MakeClass, you can:
- organize the event loop yourself
- process multiple Trees in parallel. For example select some events
from a first Tree (TAG). Using the info for the selected events,
access other Trees (DST,RAW), etc
- produce hundred of histograms if you like or any other object
saved in a Root file
- run with interpreted or/and compiled code
- use all the poser of C++
- and you can be as fast (or faster) than TTree::Draw if you use
selective branch read with TBranch::GetEntry instead of
TTree::GetEntry.
With the code generated by TTree::MakeSelector, you have all
the advantages of the MakeClass solution above. In addition,
this code is generated in such a way that the code can be used
in a parallel architecture such as the one that will come with PROOF.
Rene Brun
On Fri, 26 Oct 2001, 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