/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
SimMuon/Neutron/src/RootChamberReader.cc
41 строка
1 KB
Cms Build
Clang-Format
09 май 2019, 07:18
09 май 2019, 07:18
90d84a5
Код
Авторство
О чём код?
#include "SimMuon/Neutron/src/RootChamberReader.h" #include "SimMuon/Neutron/src/RootSimHit.h" #include "FWCore/MessageLogger/interface/MessageLogger.h" #include "TClonesArray.h" using namespace std; RootChamberReader::RootChamberReader() : theTree(nullptr), theHits(nullptr), thePosition(0), theSize(0) {} RootChamberReader::RootChamberReader(TFile *file, const std::string &treeName) : theTree((TTree *)file->Get(treeName.c_str())), theHits(new TClonesArray("RootSimHit")), thePosition(-1), theSize(0) { if (theTree != nullptr) { theTree->SetBranchAddress("Hits", &theHits); theSize = theTree->GetEntries(); } } RootChamberReader::~RootChamberReader() { // delete theHits; // delete theTree; } void RootChamberReader::read(edm::PSimHitContainer &hits) { // if there's no tree, make no events if (theTree != nullptr && theSize != 0) { ++thePosition; // start again from the beginning, if needed if (thePosition >= theSize) thePosition = 0; theTree->GetEntry(thePosition); TIter next(theHits); RootSimHit *rootHit; while ((rootHit = (RootSimHit *)next())) { hits.push_back(rootHit->get()); } LogTrace("Neutrons") << "Event " << thePosition << " OF " << theSize << " has " << hits.size() << " hits "; } }