forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventb.cxx
56 lines (47 loc) · 1.96 KB
/
eventb.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// @(#)root/test:$Id$
// Author: Rene Brun 10/01/97
{
// This macro is a variant of the macro eventa.
//
// NOTE: Before executing this macro, you must have executed the macro eventload.
//
// This small program loop on all events:
// - It reads the small branch containing the number of tracks per event
// - It reads the full event only for events having less than 587 tracks
// - It dumps the selected events.
gROOT->Reset();
// Connect file generated in $ROOTSYS/test
TFile f("Event.root");
// Read Tree named "T" in memory. Tree pointer is assigned the same name
TTree *T = (TTree*)f.Get("T");
// Create a timer object to benchmark this loop
TStopwatch timer;
timer.Start();
// Start main loop on all events
Event *event = new Event(); //we create the event object once outside the loop
TBranch *bntrack = T->GetBranch("fNtrack");
TBranch *branch = T->GetBranch("event");
branch->SetAddress(&event);
Int_t nevent = T->GetEntries();
Int_t nselected = 0;
Int_t nb = 0;
for (Int_t i=0;i<nevent;i++) {
if(i%50 == 0) printf("Event:%d\n",i);
bntrack->GetEntry(i); //read branch "fNtrack" only
if (event->GetNtrack() > 587)continue; //reject events with more than 587 tracks
nb += T->GetEntry(i); //read complete accepted event in memory
nselected++;
if (nselected == 1) event->Dump(); //dump the first accepted event
event->Clear(); //clear tracks array
}
// Stop timer and print results
timer.Stop();
Float_t mbytes = T->GetTotBytes()*1.e-6;
Double_t rtime = timer.RealTime();
Double_t ctime = timer.CpuTime();
printf("You have selected %d events out of %d\n",nselected,nevent);
printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
printf("You have scanned %f Mbytes/Realtime seconds\n",mbytes/rtime);
printf("You have scanned %f Mbytes/Cputime seconds\n",mbytes/ctime);
f.Close();
}