#include <SimMuon/Neutron/src/RootChamberReader.h>
Public Member Functions | |
void | read (edm::PSimHitContainer &hits) |
RootChamberReader (TFile *file, const std::string &treeName) | |
RootChamberReader () | |
default ctor, for STL | |
~RootChamberReader () | |
writes the tree, and deletes everything | |
Private Attributes | |
TClonesArray * | theHits |
int | thePosition |
int | theSize |
TTree * | theTree |
Definition at line 8 of file RootChamberReader.h.
RootChamberReader::RootChamberReader | ( | ) |
default ctor, for STL
Definition at line 7 of file RootChamberReader.cc.
00008 : theTree(0), 00009 theHits(0), 00010 thePosition(0), 00011 theSize(0) 00012 { 00013 }
RootChamberReader::RootChamberReader | ( | TFile * | file, | |
const std::string & | treeName | |||
) |
Definition at line 16 of file RootChamberReader.cc.
References theHits, theSize, and theTree.
00017 : theTree( (TTree *) file->Get(treeName.c_str()) ), 00018 theHits(new TClonesArray("RootSimHit")), 00019 thePosition(-1), 00020 theSize(0) 00021 { 00022 if(theTree != 0) 00023 { 00024 theTree->SetBranchAddress("Hits", &theHits); 00025 theSize = theTree->GetEntries(); 00026 } 00027 }
RootChamberReader::~RootChamberReader | ( | ) |
void RootChamberReader::read | ( | edm::PSimHitContainer & | hits | ) |
Definition at line 37 of file RootChamberReader.cc.
References RootSimHit::get(), LogTrace, theHits, thePosition, theSize, and theTree.
Referenced by RootNeutronReader::readNextEvent().
00038 { 00039 // if there's no tree, make no events 00040 if(theTree != 0 && theSize != 0) 00041 { 00042 ++thePosition; 00043 // start again from the beginning, if needed 00044 if(thePosition >= theSize) thePosition = 0; 00045 theTree->GetEntry(thePosition); 00046 00047 TIter next(theHits); 00048 RootSimHit * rootHit; 00049 while( (rootHit = (RootSimHit *) next()) ) 00050 { 00051 hits.push_back(rootHit->get()); 00052 } 00053 LogTrace("Neutrons") << "Event " << thePosition << " OF " << theSize 00054 << " has " << hits.size() << " hits "; 00055 } 00056 }
TClonesArray* RootChamberReader::theHits [private] |
int RootChamberReader::thePosition [private] |
int RootChamberReader::theSize [private] |
TTree* RootChamberReader::theTree [private] |