CMS 3D CMS Logo

RootChamberReader.cc
Go to the documentation of this file.
4 #include "TClonesArray.h"
5 using namespace std;
6 
8 : theTree(0),
9  theHits(0),
10  thePosition(0),
11  theSize(0)
12 {
13 }
14 
15 
17 : theTree( (TTree *) file->Get(treeName.c_str()) ),
18  theHits(new TClonesArray("RootSimHit")),
19  thePosition(-1),
20  theSize(0)
21 {
22  if(theTree != 0)
23  {
24  theTree->SetBranchAddress("Hits", &theHits);
25  theSize = theTree->GetEntries();
26  }
27 }
28 
29 
31 {
32 // delete theHits;
33 // delete theTree;
34 }
35 
36 
38 {
39  // if there's no tree, make no events
40  if(theTree != 0 && theSize != 0)
41  {
42  ++thePosition;
43  // start again from the beginning, if needed
44  if(thePosition >= theSize) thePosition = 0;
45  theTree->GetEntry(thePosition);
46 
47  TIter next(theHits);
48  RootSimHit * rootHit;
49  while( (rootHit = (RootSimHit *) next()) )
50  {
51  hits.push_back(rootHit->get());
52  }
53  LogTrace("Neutrons") << "Event " << thePosition << " OF " << theSize
54  << " has " << hits.size() << " hits ";
55  }
56 }
57 
58 
PSimHit get() const
Definition: RootSimHit.cc:22
TClonesArray * theHits
void read(edm::PSimHitContainer &hits)
RootChamberReader()
default ctor, for STL
#define LogTrace(id)
~RootChamberReader()
writes the tree, and deletes everything
std::vector< PSimHit > PSimHitContainer