CMS 3D CMS Logo

RootChamberReader.cc
Go to the documentation of this file.
4 #include "TClonesArray.h"
5 using namespace std;
6 
7 RootChamberReader::RootChamberReader() : theTree(nullptr), theHits(nullptr), thePosition(0), theSize(0) {}
8 
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 }
19 
21  // delete theHits;
22  // delete theTree;
23 }
24 
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 }
MessageLogger.h
hfClusterShapes_cfi.hits
hits
Definition: hfClusterShapes_cfi.py:5
RootChamberReader::thePosition
int thePosition
Definition: RootChamberReader.h:21
RootChamberReader::read
void read(edm::PSimHitContainer &hits)
Definition: RootChamberReader.cc:25
RootChamberReader.h
RootChamberReader::theTree
TTree * theTree
Definition: RootChamberReader.h:19
RootChamberReader::theSize
int theSize
Definition: RootChamberReader.h:22
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RootSimHit.h
RootChamberReader::RootChamberReader
RootChamberReader()
default ctor, for STL
Definition: RootChamberReader.cc:7
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
std
Definition: JetResolutionObject.h:76
bscTrigger_cfi.theHits
theHits
Definition: bscTrigger_cfi.py:18
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
edm::PSimHitContainer
std::vector< PSimHit > PSimHitContainer
Definition: PSimHitContainer.h:11
RootChamberReader::~RootChamberReader
~RootChamberReader()
writes the tree, and deletes everything
Definition: RootChamberReader.cc:20
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
RootChamberReader::theHits
TClonesArray * theHits
Definition: RootChamberReader.h:20