CMS 3D CMS Logo

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() [1/2]

RootChamberReader::RootChamberReader ( )

default ctor, for STL

Definition at line 7 of file RootChamberReader.cc.

7 : theTree(nullptr), theHits(nullptr), thePosition(0), theSize(0) {}

◆ RootChamberReader() [2/2]

RootChamberReader::RootChamberReader ( TFile *  file,
const std::string &  treeName 
)

Definition at line 9 of file RootChamberReader.cc.

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 }

References theHits, theSize, and theTree.

◆ ~RootChamberReader()

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

◆ read()

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

Definition at line 25 of file RootChamberReader.cc.

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 }

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

Referenced by RootNeutronReader::readNextEvent().

Member Data Documentation

◆ theHits

TClonesArray* RootChamberReader::theHits
private

Definition at line 20 of file RootChamberReader.h.

Referenced by read(), and RootChamberReader().

◆ thePosition

int RootChamberReader::thePosition
private

Definition at line 21 of file RootChamberReader.h.

Referenced by read().

◆ theSize

int RootChamberReader::theSize
private

Definition at line 22 of file RootChamberReader.h.

Referenced by read(), and RootChamberReader().

◆ theTree

TTree* RootChamberReader::theTree
private

Definition at line 19 of file RootChamberReader.h.

Referenced by read(), and RootChamberReader().

hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
RootChamberReader::thePosition
int thePosition
Definition: RootChamberReader.h:21
RootChamberReader::theTree
TTree * theTree
Definition: RootChamberReader.h:19
RootChamberReader::theSize
int theSize
Definition: RootChamberReader.h:22
RootSimHit
Definition: RootSimHit.h:7
FrontierConditions_GlobalTag_cff.file
file
Definition: FrontierConditions_GlobalTag_cff.py:13
RootSimHit::get
PSimHit get() const
Definition: RootSimHit.cc:21
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
RootChamberReader::theHits
TClonesArray * theHits
Definition: RootChamberReader.h:20