Hi Rene, Thanks for your speedy reply. In fact EventNum has no relation to the TTree event entry number, it's just an "event identifier" in that tree1-Scan() produces something like: ************************************* * Row * EventNum * X * Y * Z * ************************************* * 0 * 3* 0.2* 0.4* 0.1* * 1 * 7* 0.6* 0.1* 0.4* * 2 * 9* 0.3* 0.2* 0.6* etc and I'd like to select EventNum == 3,7,9 in tree2. HOWEVER, I noticed from a similar posting today by Stilianos that my code snippet below works if I replace sprintf(myString,"\"EventNum == %d \"",EventNum) with sprintf(myString,"EventNum == %d",EventNum), though I'm not quite sure why! The problem is that it takes a long time to scan tree1 and create the TEventList. I'll check out TTree::BuildIndex. Thanks, Mike. On Tue, 24 Feb 2004, Rene Brun wrote: > Hi Mike, > > To answer your question, I must know the relationship between > your variable "EventNum" and the TTree entry number > in your two Trees. Solutions to this kind of problem are typically > using TEventList or TTree::BuildIndex > > Rene Brun > > On Tue, 24 > Feb 2004, Mike Carson wrote: > > > > > Dear Rooters, > > > > I've got two TTrees, tree1 and tree2, with the same variable list > > (EventNum X Y Z). I'd like to select those events in tree2 which have the > > same EventNum as the events in tree1. I can do this with a couple of for > > loops but it takes too long. I also tried this: > > > > Int_t numberOfEvents = tree1->GetEntries(); > > Char_t myString[20]; > > > > for (Int_t i=0; i<numberOfEvents; i++) { > > tree1->GetEvent(i); > > sprintf(myString,"\"EventNum == %d \"",EventNum); > > tree2->Draw(">>+eventList",myString); > > } > > > > but that didn't work. I tried a similar thing with a TCut object instead > > of myString...didn't work either. Any ideas? > > > > I'm using root version 3.10/02, gcc 3.2.2, RH9.0. > > > > Many thanks, > > Mike. > > > > -- --------------------------------------------------------------------------- Michael Carson tel: +44 (0)114 2223543 Dept. of Physics and Astronomy fax: +44 (0)114 2728079 University of Sheffield email: m.j.carson@sheffield.ac.uk Hicks Building, Hounsfield Road web: www.shef.ac.uk/physics Sheffield, S3 7RH UK ---------------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET