CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
RootChamberReader Class Reference

#include <RootChamberReader.h>

Public Member Functions

void read (edm::PSimHitContainer &hits)
 
 RootChamberReader ()
 default ctor, for STL More...
 
 RootChamberReader (TFile *file, const std::string &treeName)
 
 ~RootChamberReader ()
 writes the tree, and deletes everything More...
 

Private Attributes

TClonesArray * theHits
 
int thePosition
 
int theSize
 
TTree * theTree
 

Detailed Description

Definition at line 8 of file RootChamberReader.h.

Constructor & Destructor Documentation

RootChamberReader::RootChamberReader ( )

default ctor, for STL

Definition at line 7 of file RootChamberReader.cc.

8 : theTree(0),
9  theHits(0),
10  thePosition(0),
11  theSize(0)
12 {
13 }
TClonesArray * theHits
RootChamberReader::RootChamberReader ( TFile *  file,
const std::string &  treeName 
)

Definition at line 16 of file RootChamberReader.cc.

References theHits, theSize, and theTree.

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 }
TClonesArray * theHits
RootChamberReader::~RootChamberReader ( )

writes the tree, and deletes everything

Definition at line 30 of file RootChamberReader.cc.

31 {
32 // delete theHits;
33 // delete theTree;
34 }

Member Function Documentation

void RootChamberReader::read ( edm::PSimHitContainer hits)

Definition at line 37 of file RootChamberReader.cc.

References RootSimHit::get(), LogTrace, GetRecoTauVFromDQM_MC_cff::next, theHits, thePosition, theSize, and theTree.

Referenced by RootNeutronReader::readNextEvent().

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 }
PSimHit get() const
Definition: RootSimHit.cc:22
TClonesArray * theHits
#define LogTrace(id)

Member Data Documentation

TClonesArray* RootChamberReader::theHits
private

Definition at line 21 of file RootChamberReader.h.

Referenced by read(), and RootChamberReader().

int RootChamberReader::thePosition
private

Definition at line 22 of file RootChamberReader.h.

Referenced by read().

int RootChamberReader::theSize
private

Definition at line 23 of file RootChamberReader.h.

Referenced by read(), and RootChamberReader().

TTree* RootChamberReader::theTree
private

Definition at line 20 of file RootChamberReader.h.

Referenced by read(), and RootChamberReader().