Re: TTreeFormula using a TTreeFormula?

From: Damir Buskulic (buskulic@lapp.in2p3.fr)
Date: Thu Mar 30 2000 - 14:33:31 MEST


Just a comment, this would also be useful if someone wants to define a
very specific ObjectFormula. I had to reimplement TreeFormula to suit my
needs for a very specific case where the names of the variables I wanted
to cut on were not only the names of the branches, but names of
variables in some C structures inside an object.
Anyway, this works now but Gene's second suggestion would certainly
simplify my implementation.

Cheers

Damir

Rene Brun wrote:
> 
> Hi Gene,
> I agree with your comments. Note that is is not complicated to obtain
> what you want with the current version and with no changes to ROOT.
> Simply, make your TTreeFormula known to the list of formula, eg:
> 
> TTreeFormula f3("form3","v1+4",t1);
> gROOT->GetListOfFunctions()->Add(&f3);  //<====add this line
> TTreeFormula f4("form4","form3+v1",t1);
> 
> Rene Brun
> 
> Gene Van Buren wrote:
> >
> > Hi. I'm curious as to why TTreeFormula does not recognize
> > other TTreeFormulas during Analyze()? It does recognize
> > normal TFormulas, but not TTreeFormulas.
> >
> > For example, let's say I have a TTree* t1 with variable v1:
> >
> > This works:
> >
> > TFormula f1("form1","3+5");
> > TTreeFormula f2("form2","form1+v1",t1);
> >
> > But this does not:
> >
> > TTreeFormula f3("form3","v1+4",t1);
> > TTreeFormula f4("form4","form3+v1",t1);
> >
> > When creating f4, it cannot find form3. It seems useful to me
> > that a TTreeFormula associated with a given TTree
> > be able to use any other TTreeFormula associated
> > with that TTree. This would simply mean that each TTree
> > keeps a list of its associated formulae, just as gROOT keeps
> > a list of regular TFormulas, and that this list be searched
> > for matching formula names within Analyze().
> >
> > On the technical side, I think this could be done by moving
> > the "Look for an already defined expression" portion of
> > Analyze() into a second member function
> > AnalyzeDefinedExpression() or something like that, which
> > would be virtual and re-defined in TTreeFormula so that
> > it can search the associated TTree's list of formula in
> > addition to gROOT's list.
> >
> > Another way to do it would be to add a line in TFormula at:
> >               oldformula =
> > (TFormula*)gROOT->GetListOfFunctions()->FindObject((const char*)chaine);
> >
> >              if (!oldformula) oldformula =
> > LookForSpecialFormula(chaine);
> >
> > Then, TFormula* LookForSpecialFormula() could be a virtual
> > function with {return 0;} in TFormula, but a search of the
> > associated TTree's formulas in TTreeFormula.
> >
> > The end result of all of this would be that someone could define
> > TTreeFormula's to use in the TTree::Scan() and TTree::Draw()
> > member functions. That would be nice:
> >
> > (t1 points to a TTree with variables Px,Py,rapidity)
> > TTreeFormula f5("Pt","sqrt((Px^2)+(Py^2))",t1);
> > t1->Draw("Pt:rapidity");
> >
> > -Gene Van Buren
-- 
=====================================================================
| Damir Buskulic                  | Universite de Savoie/LAPP       |
|                                 | Chemin de Bellevue, B.P. 110    |
| Tel : +33 (0)450091600          | F-74941 Annecy-le-Vieux Cedex   |
| e-mail: buskulic@lapp.in2p3.fr  | FRANCE                          |
=====================================================================
mailto:buskulic@lapp.in2p3.fr



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:22 MET