Hi Matthieu, Did you take a look at the TEventList class. From your original tree you can do: mytree->Draw(">>mylistof_events","cut"); .... mytree->SetEventList(mylistof_events); ... // Do more cut on the sub-set. Philippe. > - > -----Original Message----- > From: owner-roottalk@pcroot.cern.ch > [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Matthieu Guillo > Sent: Monday, October 30, 2000 11:52 AM > To: roottalk@pcroot.cern.ch > Subject: [ROOT] selecting events in a TTree > > > Hello rooters, > > I am trying to write a function which selects events in a TTree. I would > like to have the selection done the same way the Draw() is implemented. > The only way I know how to do it is to use the CopyTree() method but there > is an overhead of memory if I have a lot of branches (let's say 50) I > don't want to use. The cut can be applied on other branches I am not > interested in (for instance on variable "y"). > > For instance: > > Float_t Sum_X_Square(TTree* T, TCut cut){ > TTree* T_new = T->CopyTree(cut); > Float_t x; > T_new->SetBranchAdress("x",&x); > T_new->SetBranchStatus("*",0); // disable all branches > T_new->SetBranchStatus("x",1); // able the "x" branch > > Float total = 0; > Int_t nEntries = T_new->GetEntries(); > for (Int_t i = 0; i < nEntries; i++) { > T_new->GetEvent(i); > total += x * x; > } > > delete T_new; > return(total); > } > > Is there a better way to do it, without going through the overhead of the > T_new object? The problem I have is that if T is too big, I have a crash > because my machine hasn't got enough memory. > > Regards, > > Matthieu Guillo > Thomas Jefferson National Laboratory > Office 71 trailer 16 > Phone: 757-269-5551 > > >
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:36 MET