CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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.

7 : theTree(nullptr), theHits(nullptr), thePosition(0), theSize(0) {}
TClonesArray * theHits
RootChamberReader::RootChamberReader ( TFile *  file,
const std::string &  treeName 
)

Definition at line 9 of file RootChamberReader.cc.

References theHits, theSize, and theTree.

10  : theTree((TTree *)file->Get(treeName.c_str())),
11  theHits(new TClonesArray("RootSimHit")),
12  thePosition(-1),
13  theSize(0) {
14  if (theTree != nullptr) {
15  theTree->SetBranchAddress("Hits", &theHits);
16  theSize = theTree->GetEntries();
17  }
18 }
TClonesArray * theHits
RootChamberReader::~RootChamberReader ( )

writes the tree, and deletes everything

Definition at line 20 of file RootChamberReader.cc.

20  {
21  // delete theHits;
22  // delete theTree;
23 }

Member Function Documentation

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

Definition at line 25 of file RootChamberReader.cc.

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

Referenced by RootNeutronReader::readNextEvent().

25  {
26  // if there's no tree, make no events
27  if (theTree != nullptr && theSize != 0) {
28  ++thePosition;
29  // start again from the beginning, if needed
30  if (thePosition >= theSize)
31  thePosition = 0;
32  theTree->GetEntry(thePosition);
33 
34  TIter next(theHits);
35  RootSimHit *rootHit;
36  while ((rootHit = (RootSimHit *)next())) {
37  hits.push_back(rootHit->get());
38  }
39  LogTrace("Neutrons") << "Event " << thePosition << " OF " << theSize << " has " << hits.size() << " hits ";
40  }
41 }
PSimHit get() const
Definition: RootSimHit.cc:21
TClonesArray * theHits
#define LogTrace(id)

Member Data Documentation

TClonesArray* RootChamberReader::theHits
private

Definition at line 20 of file RootChamberReader.h.

Referenced by read(), and RootChamberReader().

int RootChamberReader::thePosition
private

Definition at line 21 of file RootChamberReader.h.

Referenced by read().

int RootChamberReader::theSize
private

Definition at line 22 of file RootChamberReader.h.

Referenced by read(), and RootChamberReader().

TTree* RootChamberReader::theTree
private

Definition at line 19 of file RootChamberReader.h.

Referenced by read(), and RootChamberReader().