Hi Peter,
Peter H Fisher wrote:
>
> 2. Given the above, it might be worthwhile for me to make a reduced data
> set containing only a fraction of the events. Do you have an example of
> how to do this?
>
One way to speed up your analysis is to use the TEventList class. This allows
you to store the entry numbers corresponding to a specific selection. This
can be used the following way:
for example, if you have a tree containing a branch named "X", and you want
to select entries for which X is greater than 20, you can do:
mychain->Draw(">> evlist","X > 20");
This generates a TEventList object named "evlist". To use it, you have to do:
TEventList *evl=(TEventList *)gROOT->FindObject("evlist"); // obtaining the
pointer to "evlist"
mychain->SetEventList(evl);
The next mychain->Draw() or mychain->Process() calls will only read entries
contained in the TEventList named "evlist". To come back to the "usual"
behavior (reding all entries of the TChain), you just have to type:
mychain->SetEventList(0);
In a treatment routine, you can add an entry number to the TEventList by
using the Enter(Int_t entry) method:
TEventList *evl=new TEventList("evlist");
......
// some declarations
......
// treatment loop
for(Int_t entry=0;entry<mychain->GetEntries();entry++)
{
Bool_t ok=kFALSE;
.....
// some selection algorithm setting ok to kTRUE if the selection condition
is filled
if(ok)
{
evl->Enter(entry); // Adding the entry number to the TEventList
}
}
...
// some code
...
evl->Write(); // to write the TEventList in a file
To use this eventlist in another analyses, you just have to do, if filep is
the poiter to the TFile which contains the TEventList:
TEventList *evl=(TEventList *)filep->FindObject("evlist"); // obtaining the
pointer to "evlist"
mychain->SetEventList(evl);
The use of TEventList objects is very efficient if the selection algorithm is
complicated and/or a CPU consumer. For more complete information on
TEventList, look at
http://root.cern.ch/cgi-bin/print_hit_bold.pl/root/html/TEventList.html?TEventList#first_hit
I hope this helps
-
Daniel
LPC Caen
Boulevard du Marechal Juin
14050 CAEN CEDEX
e-mail : cussol@in2p3.fr
Tel : +33-(0)2-31-45-29-73
FAX : +33-(0)2-31-45-25-49
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET