eventa.cxx

Go to the documentation of this file.
00001 // @(#)root/test:$Id: eventa.cxx 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Rene Brun   10/01/97
00003 
00004 {
00005 //  This macro read all events generated by the test program Event
00006 //  provided in $ROOTSYS/test.
00007 //
00008 //  NOTE: Before executing this macro, you must have executed the macro eventload.
00009 //
00010 //  This small program simply counts the number of bytes read and dump
00011 //  the first 3 events.
00012 
00013    gROOT->Reset();
00014 
00015 //   Connect file generated in $ROOTSYS/test
00016    TFile f("Event.root");
00017 
00018 //   Read Tree named "T" in memory. Tree pointer is assigned the same name
00019    TTree *T = (TTree*)f.Get("T");
00020 
00021 //   Create a timer object to benchmark this loop
00022    TStopwatch timer;
00023    timer.Start();
00024 
00025 //   Start main loop on all events
00026    Event *event = new Event();
00027    T->SetBranchAddress("event", &event);
00028    Int_t nevent = T->GetEntries();
00029    Int_t nb = 0;
00030    for (Int_t i=0;i<nevent;i++) {
00031       if(i%50 == 0) printf("Event:%d\n",i);
00032       nb += T->GetEntry(i);                  //read complete event in memory
00033       if (i < 3) event->Dump();              //dump the first 3 events
00034    }
00035 
00036 //  Stop timer and print results
00037    timer.Stop();
00038    Float_t mbytes = 0.000001*nb;
00039    Double_t rtime = timer.RealTime();
00040    Double_t ctime = timer.CpuTime();
00041    printf("RealTime=%f seconds, CpuTime=%f seconds\n",rtime,ctime);
00042    printf("You read %f Mbytes/Realtime seconds\n",mbytes/rtime);
00043    printf("You read %f Mbytes/Cputime seconds\n",mbytes/ctime);
00044    printf("%d events and %d bytes read.\n",nevent,nb);
00045 
00046    f.Close();
00047 }

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