Hi Sean, Your problem is not related at all to Paul Eugenio's problem. I am proposing below the recommended way of looping on any container. the same code will work if the container is a Tlist, ThashList, TObjArray or TClonesArray. It uses a TIter object. Proposed modification to your code ================================== TIter nextTop(event->topPtr()); Top *top; while ((top=(Top*)nextTop())) { chiSqRed->Fill(top->GetRedChiSq()); } I made a timing test on my Linux box to test the performance of this iterator using the Root test/Event example. I am always using the same event to ignore I/O and concentrate only on the access time to the TClonesArray and histogram filling. This macro executes in 3.01 seconds. If I do not fill the histogram, the macro executes in 2.1 seconds. This is obtained with the interpreter. Compiled version will probably be 3 times faster. There are 603000 entries in the histogram. each histogram fill takes about 1.3 microseconds. I think this performance is remarquable. You do not mention how long it takes to execute your function. I would suggest you remove the chiSqRed->Fill statement to see how long it takes. Let me know. Rene Brun my simple test with test/Event ============================== { gSystem->Load("test/libEvent"); TFile f("test/Event.root"); TTree *T = (TTree*)f.Get("T"); TH1F *hPx = new TH1F("hPx","Px distribution",100,-5,5); Event *event = 0; T->SetBranchAddress("event",&event); T->GetEvent(500); Track *track; for (Int_t i=0;i<1000;i++) { TIter next(event->GetTracks()); while ((track=(Track*)next())) { hx->Fill(track->GetPx()); } } hPx->Draw(); } Sean Kelly wrote: > > Hi Rene, > > I have a problem similar to Paul's. I have an event class similar to the > example provided with the Root distribution. With each event I have a > three TClonesArrays containing a number of objects of type Trk, Top, Phy. > I loop over these arrays filling histograms as shown in the frag below. > This takes ages for 10k events, ultimately I will have to do it for many > more than that. I don't understand your suggestion for speeding this > process up.. can you explain in more detail. > > much thanks > > Sean Kelly > > fill(){ > > Int_t nTrk=0; > Float_t *topPar=0; > topCount->Fill(event->GetNTop()); > > for (Int_t iTop = 0; iTop < event->GetNTop(); iTop++){ > top = (Top*) (*(event->topPtr))[iTop]; > chiSqRed->Fill(top->GetRedChiSq()); > } > return 1; > > }
This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:29 MET