Hi, TTreeFormulaManager is in charge of 'synchronizing' the array indices of several TTreeFormula object. If you have only one TTreeFormula, you do not need to worry about the TTreeFormulaManager (a default one is provided). So you current code could be simplified with cut=new TTreeFormula("some_name",cut,tree); for(;;) { ii=LoadTree(i); fChain->GetEntry(ii); Double_t cut_result=cut->EvalInstance(); ... } delete cut; > I suppose I should also add manager->UpdateFormulaLeaves() to my ::Notify(), right? Is there something else which is > needed? Yes (or cut->UpdateFormulaLeaves()). The TTreeFormula object need to be poked any time the branch objects are changes (i.e. when the chain opens a new file). Also note that if your cut has arrays in it (or any other collection that has more than one value per entry), you might have to use something like: int ndata = cut->GetNdata(); for(int i = 0; i<ndata; ++i) { cut_result = cut->EvalInstance(i); } Cheers, Philippe. -----Original Message----- From: owner-roottalk@pcroot.cern.ch [mailto:owner-roottalk@pcroot.cern.ch] On Behalf Of Roland Kuhn Sent: Thursday, October 14, 2004 12:25 PM To: Rene Brun Cc: roottalk@pcroot.cern.ch Subject: Re: [ROOT] TFormula parameter name parsing Hi Rene! On Oct 13, 2004, at 8:54 AM, Rene Brun wrote: > Hi Roland, > > I agree with your comments about TTreeFormula. > This class is a key element of TTree::Draw, but it can also be used > independently. > It requires a much better documentation. > I tried to understand what's going on, and I must admit that I didn't really have enough brain memory to get a complete picture (at least not in a reasonable timeframe). From what I've seen TTreeFormula is always managed by a TTreeFormulaManager. I have already found out that the main use of this class is to manage the (up to four) expressions in the varexp of TTree::Draw plus the selection criterion, but from the code it is not immediately clear to me what the semantics are. What do I need to get it working reliably with a TChain? I'm currently looping with a custom MakeClass-generated class, filling my own arbirarily dimensioned histograms. Now I want to include a cut criterion, which should be parsed like a selection to TTree::Draw. I figure I need something a la in constructor: manager=new TTreeFormulaManager; in Loop(): cut=new TTreeFormula("some_name",cut,tree); manager->Add(cut); manager->Sync(); for(;;) { ii=LoadTree(i); fChain->GetEntry(ii); Double_t cut_result=cut->EvalInstance(); ... } manager->Remove(cut); manager->Sync(); I suppose I should also add manager->UpdateFormulaLeaves() to my ::Notify(), right? Is there something else which is needed? Thanks very much for your help! Ciao, Roland -- TU Muenchen, Physik-Department E18, James-Franck-Str. 85747 Garching Telefon 089/289-12592; Telefax 089/289-12570 -- A mouse is a device used to point at the xterm you want to type in. Kim Alm on a.s.r.
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:10 MET