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
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:22 MET