eventb.cxx

Go to the documentation of this file.
00001 // @(#)root/test:$Id: eventb.cxx 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Rene Brun   10/01/97
00003 
00004 {
00005 //  This macro is a variant of the macro eventa.
00006 //
00007 //  NOTE: Before executing this macro, you must have executed the macro eventload.
00008 //
00009 //  This small program loop on all events:
00010 //    - It reads the small branch containing the number of tracks per event
00011 //    - It reads the full event only for events having less than 587 tracks
00012 //    - It dumps the selected events.
00013 
00014    gROOT->Reset();
00015 
00016 //   Connect file generated in $ROOTSYS/test
00017    TFile f("Event.root");
00018 
00019 //   Read Tree named "T" in memory. Tree pointer is assigned the same name
00020    TTree *T = (TTree*)f.Get("T");
00021 
00022 //   Create a timer object to benchmark this loop
00023    TStopwatch timer;
00024    timer.Start();
00025 
00026 //   Start main loop on all events
00027    Event *event = new Event();   //we create the event object once outside the loop
00028 
00029    TBranch *bntrack = T->GetBranch("fNtrack");
00030    TBranch *branch  = T->GetBranch("event");
00031    branch->SetAddress(&event);
00032    Int_t nevent = T->GetEntries();
00033    Int_t nselected = 0;
00034    Int_t nb = 0;
00035    for (Int_t i=0;i<nevent;i++) {
00036       if(i%50 == 0) printf("Event:%d\n",i);
00037       bntrack->GetEntry(i);                  //read branch "fNtrack" only
00038       if (event->GetNtrack() > 587)continue; //reject events with more than 587 tracks
00039       nb += T->GetEntry(i);                  //read complete accepted event in memory
00040       nselected++;
00041       if (nselected == 1) event->Dump();     //dump the first accepted event
00042       event->Clear();                        //clear tracks array
00043    }
00044 
00045 //  Stop timer and print results
00046    timer.Stop();
00047    Float_t mbytes = T->GetTotBytes()*1.e-6;
00048    Double_t rtime = timer.RealTime();
00049    Double_t ctime = timer.CpuTime();
00050    printf("You have selected %d events out of %d\n",nselected,nevent);
00051    printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
00052    printf("You have scanned %f Mbytes/Realtime seconds\n",mbytes/rtime);
00053    printf("You have scanned %f Mbytes/Cputime seconds\n",mbytes/ctime);
00054 
00055    f.Close();
00056 }

Generated on Tue Jul 5 15:14:50 2011 for ROOT_528-00b_version by  doxygen 1.5.1