Hi Chris, I do not think that it is a good idea to use TTreeFormula within a TSelector. If you already have a TSelector derived class, you should implement the function MySelector::ProcessCut. In this function, you should call the TBranch::GetEntry (not TTree::GetEntry) in the order where you eliminate as many candidates as possible and minimizing the I/O. You can see an example in $ROOTSYS/tutorials/h1analysis.C Use TBranch::GetEntry as shown in this example instead of the mechanism via TTree::SetBranchStatus. The pointers to the branches are already declared and precomputed for you in mySelector.h Rene Brun Chris Roat wrote: > > Hi Philipe, > > Thanks so much for your solution. It worked great and I'm now back up and > running. I have another question on a related note. > > I need to be sure that my TSelector reads in the branches necessary (and > *only* those branches, since I have 100s) for the TTreeFormulas I am > using. But I don't see the need to add/change SetBranchStatus lines in my > TSelector::Init method everytime I add/change my TTreeFormulas. > > Is there a way to do this more easily, like by looping over the leaves a > TTreeFormula needs? > > Cheers, > Chris > > *** Today, you (Philippe Canal) wrote *** > > >Hi Chris, > > > >The problem was that the TTreeFormula were not informed properly that > >the chain loaded a need TTree. To fix that you need to add at the end of > >generic::Notify the following: > > > > // fChain->LoadTree(fChain->GetReadEntry()); > > // Also update the formulas: > > for (Int_t cut=0; cut<_cs->nCuts(); cut++) { > > ttform[cut]->UpdateFormulaLeaves(); > > } > > > >Now in your sample case (only one file), it should not have been loading > >any new file in the first place. The reason why it was, is that you have > >in all your selector's Notify method (like generic::Notify) calls like: > > > > fChain->SetBranchStatus("*",kFALSE); > > > >This forces a reload of the current file. The SetBranchStatus actually > >belongs in the generic::Init method because they only need to be once > >by chain. The chain (at least in newer ROOT) keeps track of the > >info and pass it to each TTree. If for some reasons (very old ROOT > >version) this does not work, then uncomment the first like in my > >first code fragment. > > > >Cheers, > >Philipe. > > > > > >-----Original Message----- > >From: owner-roottalk@pcroot.cern.ch > >[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Chris Roat > >Sent: Wednesday, December 19, 2001 1:03 PM > >To: roottalk@pcroot.cern.ch > >Subject: [ROOT] TTreeFormula within TSelector::ProcessCut > > > > > >Hi ROOT, > > > >I'm having problems finding out if a particular entry in a tree passes a > >cut. I'm using a TSelector which takes recieves a list of strings (which > >are cuts, of the form "p>3" or "myBool" from the outside world). During > >ProcessCut/ProcessFill, I would like to see if the entry I'm on passes any > >of the strings. > > > >I am trying to use TTreeFormula to tackle this, but without prolonged > >luck. It works fine on the first entry - EvalInstance(0) returns the > >correct answer, so I'm on the right track. However, EvalInstance(0) seg > >faults on subsequent entries. > > > >Could there be a problem with ProcessCut() and EvalInstance() both getting > >info from the tree? > > > >Thanks for any insight, > >Chris > > > > > >
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:13 MET