1 #include "StGammaTreeReader.h"
15 StGammaTreeReader::StGammaTreeReader(
const Char_t *name,
const Char_t *bname):
StMaker(name)
17 mChain=
new TChain(name,
"gamma");
26 Int_t StGammaTreeReader::Init()
30 return StMaker::Init();
38 if ( !stat )
return kStEOF;
45 if ( mFirst ) treeDetails();
46 Int_t stat=
mChain->GetEntry(i);
53 Long64_t mykey = key(run,myevent);
54 Long64_t entry = mIndex[ mykey ];
63 void StGammaTreeReader::treeDetails()
66 std::cout << GetCVS() << std::endl;
67 std::cout <<
mChain->GetTitle() << std::endl;
80 if ( fname.Contains(matches) )
82 std::cout << Form(
"[%02i] add %s",mNumberOfFiles++,file ) << std::endl;
89 void StGammaTreeReader::buildIndex()
97 std::cout <<
GetName() <<
"::Indexing " << N <<
" entries" << std::endl;
99 for ( Long64_t i=0;i<N;i++ )
104 Long64_t mykey = key(run,event);
105 mIndex[ mykey ] = i + 1;
107 std::cout << Form(
"[%i] RUN: %i EVENT: %i KEY: ",(Int_t)i,run,event) << mykey <<
" INDEX: " << i << std::endl;
115 std::cout <<
"[Time to build index for "<<N<<
" events -- ";
116 std::cout << Form(
"real: %.2f s cpu: %.2f s]",timer.RealTime(),timer.CpuTime()) << std::endl;
124 static Int_t ngood=0;
129 for ( Long64_t i=0;i<N;i++ )
140 std::random_shuffle( ids.begin(), ids.end() );
142 std::cout << Form(
"Verifying indexing scheme for %g events",(
double)N)
145 for ( Long64_t i=0;i<N;i++ )
148 if (!
getEvent( ids[i].run, ids[i].evt ))
continue;
161 std::cout << Form(
"run=%i event=%i state=%s",ids[i].run,ids[i].evt,
"bad")
169 std::cout << Form(
"Verified %g of %g events were properly indexed",(
double)ngood,(
double)N) << std::endl;
173 Long64_t StGammaTreeReader::key( Int_t run, Int_t event )
177 mykey = (Long64_t)run;
179 mykey *= (Long64_t)1.0E10;
Int_t runNumber() const
Return ith candidate.
void Test()
This is a "self test". Do not feed it alot of data.
Long64_t getNumberOfEvents()
Returns the total number of entries for this chain of events.
virtual const char * GetName() const
special overload
Int_t eventNumber() const
Returns run number.
void Clear(Option_t *opts="")
User defined functions.
void chainFile(const Char_t *name, const Char_t *matches=".root")
Add a file to the list of files in the chain being processed.
Int_t getEvent(Long64_t entry)
Loads the specified entry in the chain. Access using event() defined above.