#include <ChainEvent.h>
Public Member Functions | |
virtual bool | atEnd () const |
ChainEvent (std::vector< std::string > const &iFileNames) | |
Event const * | event () const |
virtual edm::EventAuxiliary const & | eventAuxiliary () const |
Long64_t | eventIndex () const |
virtual Long64_t | fileIndex () const |
void | fillParameterSetRegistry () const |
std::vector < edm::BranchDescription > const & | getBranchDescriptions () const |
virtual std::string const | getBranchNameFor (std::type_info const &, char const *, char const *, char const *) const |
virtual bool | getByLabel (std::type_info const &, char const *, char const *, char const *, void *) const |
virtual bool | getByLabel (std::type_info const &, char const *, char const *, char const *, edm::WrapperHolder &) const |
edm::WrapperHolder | getByProductID (edm::ProductID const &) const |
fwlite::LuminosityBlock const & | getLuminosityBlock () |
std::vector< std::string > const & | getProcessHistory () const |
fwlite::Run const & | getRun () |
TFile * | getTFile () const |
bool | isValid () const |
operator bool () const | |
ChainEvent const & | operator++ () |
virtual edm::ProcessHistory const & | processHistory () const |
void | setGetter (boost::shared_ptr< edm::EDProductGetter > getter) |
Long64_t | size () const |
bool | to (edm::RunNumber_t run, edm::EventNumber_t event) |
bool | to (edm::RunNumber_t run, edm::LuminosityBlockNumber_t lumi, edm::EventNumber_t event) |
bool | to (const edm::EventID &id) |
Go to event with event id "id". | |
bool | to (Long64_t iIndex) |
Go to the event at index iIndex. | |
ChainEvent const & | toBegin () |
virtual edm::TriggerNames const & | triggerNames (edm::TriggerResults const &triggerResults) const |
virtual edm::TriggerResultsByName | triggerResultsByName (std::string const &process) const |
virtual | ~ChainEvent () |
Static Public Member Functions | |
static void | throwProductNotFoundException (std::type_info const &, char const *, char const *, char const *) |
Private Member Functions | |
ChainEvent (Event const &) | |
void | findSizes () |
ChainEvent const & | operator= (Event const &) |
void | switchToFile (Long64_t) |
Private Attributes | |
std::vector< Long64_t > | accumulatedSize_ |
boost::shared_ptr< Event > | event_ |
Long64_t | eventIndex_ |
boost::shared_ptr< TFile > | file_ |
std::vector< std::string > | fileNames_ |
boost::shared_ptr < edm::EDProductGetter > | getter_ |
Friends | |
class | MultiChainEvent |
Definition at line 46 of file ChainEvent.h.
ChainEvent::ChainEvent | ( | std::vector< std::string > const & | iFileNames | ) |
Definition at line 35 of file ChainEvent.cc.
References accumulatedSize_, edm::poolNames::eventTreeName(), Exception, file_, fileNames_, nEvents, switchToFile(), and diffTreeTool::tree.
: fileNames_(), file_(), event_(), eventIndex_(0), accumulatedSize_() { Long64_t summedSize=0; accumulatedSize_.reserve(iFileNames.size()+1); fileNames_.reserve(iFileNames.size()); for (std::vector<std::string>::const_iterator it= iFileNames.begin(), itEnd = iFileNames.end(); it!=itEnd; ++it) { TFile *tfilePtr = TFile::Open(it->c_str()); file_ = boost::shared_ptr<TFile>(tfilePtr); gROOT->GetListOfFiles()->Remove(tfilePtr); TTree* tree = dynamic_cast<TTree*>(file_->Get(edm::poolNames::eventTreeName().c_str())); if (0 == tree) { throw cms::Exception("NotEdmFile")<<"The file "<<*it<<" has no 'Events' TTree and therefore is not an EDM ROOT file"; } Long64_t nEvents = tree->GetEntries(); if (nEvents > 0) { // skip empty files fileNames_.push_back(*it); // accumulatedSize_ is the entry # at the beginning of this file accumulatedSize_.push_back(summedSize); summedSize += nEvents; } } // total accumulated size (last enry + 1) at the end of last file accumulatedSize_.push_back(summedSize); if (fileNames_.size() > 0) switchToFile(0); }
ChainEvent::~ChainEvent | ( | ) | [virtual] |
Definition at line 76 of file ChainEvent.cc.
{ }
fwlite::ChainEvent::ChainEvent | ( | Event const & | ) | [private] |
bool ChainEvent::atEnd | ( | ) | const [virtual] |
Implements fwlite::EventBase.
Definition at line 302 of file ChainEvent.cc.
References event_, eventIndex_, and fileNames_.
Referenced by fwlite::AnalyzerWrapper< T >::analyze(), and main().
{ if (eventIndex_ == static_cast<Long64_t>(fileNames_.size())-1) { return event_->atEnd(); } return false; }
Event const* fwlite::ChainEvent::event | ( | ) | const [inline] |
Definition at line 101 of file ChainEvent.h.
References event_.
Referenced by to().
{ return &*event_; }
edm::EventAuxiliary const & ChainEvent::eventAuxiliary | ( | ) | const [virtual] |
Implements edm::EventBase.
Definition at line 251 of file ChainEvent.cc.
References event_.
{ return event_->eventAuxiliary(); }
Long64_t fwlite::ChainEvent::eventIndex | ( | ) | const [inline] |
virtual Long64_t fwlite::ChainEvent::fileIndex | ( | ) | const [inline, virtual] |
Reimplemented from fwlite::EventBase.
Definition at line 95 of file ChainEvent.h.
References eventIndex_.
{ return eventIndex_; }
void ChainEvent::fillParameterSetRegistry | ( | ) | const |
Definition at line 323 of file ChainEvent.cc.
References event_.
{ event_->fillParameterSetRegistry(); }
void fwlite::ChainEvent::findSizes | ( | ) | [private] |
std::vector< edm::BranchDescription > const & ChainEvent::getBranchDescriptions | ( | ) | const |
Definition at line 233 of file ChainEvent.cc.
References event_.
{ return event_->getBranchDescriptions(); }
std::string const ChainEvent::getBranchNameFor | ( | std::type_info const & | iType, |
char const * | iModule, | ||
char const * | iInstance, | ||
char const * | iProcess | ||
) | const [virtual] |
Implements fwlite::EventBase.
Definition at line 224 of file ChainEvent.cc.
References event_.
{ return event_->getBranchNameFor(iType,iModule,iInstance,iProcess); }
bool ChainEvent::getByLabel | ( | std::type_info const & | iType, |
char const * | iModule, | ||
char const * | iInstance, | ||
char const * | iProcess, | ||
void * | iValue | ||
) | const [virtual] |
Implements fwlite::EventBase.
Definition at line 267 of file ChainEvent.cc.
References event_.
{ return event_->getByLabel(iType, iModule, iInstance, iProcess, iValue); }
bool ChainEvent::getByLabel | ( | std::type_info const & | iType, |
char const * | iModule, | ||
char const * | iInstance, | ||
char const * | iProcess, | ||
edm::WrapperHolder & | holder | ||
) | const [virtual] |
Implements fwlite::EventBase.
Definition at line 277 of file ChainEvent.cc.
References event_.
{ return event_->getByLabel(iType, iModule, iInstance, iProcess, holder); }
edm::WrapperHolder ChainEvent::getByProductID | ( | edm::ProductID const & | iID | ) | const |
Definition at line 286 of file ChainEvent.cc.
References event_.
{ return event_->getByProductID(iID); }
fwlite::LuminosityBlock const & ChainEvent::getLuminosityBlock | ( | ) |
Definition at line 256 of file ChainEvent.cc.
References event_.
{ return event_->getLuminosityBlock(); }
std::vector< std::string > const & ChainEvent::getProcessHistory | ( | ) | const |
Definition at line 239 of file ChainEvent.cc.
References event_.
{ return event_->getProcessHistory(); }
fwlite::Run const & ChainEvent::getRun | ( | ) |
TFile* fwlite::ChainEvent::getTFile | ( | ) | const [inline] |
Definition at line 90 of file ChainEvent.h.
References event_.
Referenced by PFRootEventManager::reset().
{ return event_->getTFile(); }
bool ChainEvent::isValid | ( | void | ) | const |
Definition at line 292 of file ChainEvent.cc.
References event_.
Referenced by PFRootEventManager::connect(), and PFRootEventManager::reset().
{ return event_->isValid(); }
ChainEvent::operator bool | ( | ) | const |
ChainEvent const & ChainEvent::operator++ | ( | ) | [virtual] |
Implements fwlite::EventBase.
Definition at line 97 of file ChainEvent.cc.
References event_, eventIndex_, fileNames_, and switchToFile().
{ if(eventIndex_ != static_cast<Long64_t>(fileNames_.size())-1) { ++(*event_); if(event_->atEnd()) { switchToFile(++eventIndex_); } } else { if(*event_) { ++(*event_); } } return *this; }
ChainEvent const& fwlite::ChainEvent::operator= | ( | Event const & | ) | [private] |
edm::ProcessHistory const & ChainEvent::processHistory | ( | ) | const [virtual] |
Implements edm::EventBase.
Definition at line 245 of file ChainEvent.cc.
References event_.
{ return event_->processHistory(); }
void fwlite::ChainEvent::setGetter | ( | boost::shared_ptr< edm::EDProductGetter > | getter | ) | [inline] |
Long64_t ChainEvent::size | ( | void | ) | const |
Definition at line 311 of file ChainEvent.cc.
References accumulatedSize_.
Referenced by PFRootEventManager::connect(), DisplayManager::DisplayManager(), and PFRootEventManager::initializeEventInformation().
{ return accumulatedSize_.back(); }
void ChainEvent::switchToFile | ( | Long64_t | iIndex | ) | [private] |
Definition at line 211 of file ChainEvent.cc.
References event_, eventIndex_, file_, and fileNames_.
Referenced by ChainEvent(), operator++(), to(), and toBegin().
{ eventIndex_= iIndex; TFile *tfilePtr = TFile::Open(fileNames_[iIndex].c_str()); file_ = boost::shared_ptr<TFile>(tfilePtr); gROOT->GetListOfFiles()->Remove(tfilePtr); event_ = boost::shared_ptr<Event>(new Event(file_.get())); }
void ChainEvent::throwProductNotFoundException | ( | std::type_info const & | iType, |
char const * | iModule, | ||
char const * | iInstance, | ||
char const * | iProcess | ||
) | [static] |
Definition at line 337 of file ChainEvent.cc.
{ Event::throwProductNotFoundException(iType,iModule,iInstance,iProcess); }
bool ChainEvent::to | ( | const edm::EventID & | id | ) |
Go to event with event id "id".
Definition at line 146 of file ChainEvent.cc.
References event(), edm::EventBase::luminosityBlock(), DTTTrigCorrFirst::run, and to().
{ return to(id.run(), id.luminosityBlock(), id.event()); }
bool ChainEvent::to | ( | edm::RunNumber_t | run, |
edm::EventNumber_t | event | ||
) |
bool ChainEvent::to | ( | Long64_t | iIndex | ) |
Go to the event at index iIndex.
Definition at line 115 of file ChainEvent.cc.
References accumulatedSize_, event_, eventIndex_, and switchToFile().
Referenced by PFRootEventManager::initializeEventInformation(), PFRootEventManager::processEntry(), and to().
{ if (iIndex >= accumulatedSize_.back()) { // if we're here, then iIndex was not valid return false; } Long64_t offsetIndex = eventIndex_; // we're going backwards, so start from the beginning if (iIndex < accumulatedSize_[offsetIndex]) { offsetIndex = 0; } // is it past the end of this file? while (iIndex >= accumulatedSize_[offsetIndex+1]) { ++offsetIndex; } if(offsetIndex != eventIndex_) { switchToFile(eventIndex_ = offsetIndex); } // adjust to entry # in this file return event_->to(iIndex-accumulatedSize_[offsetIndex]); }
bool ChainEvent::to | ( | edm::RunNumber_t | run, |
edm::LuminosityBlockNumber_t | lumi, | ||
edm::EventNumber_t | event | ||
) |
If lumi is non-zero, go to event with given run, lumi, and event number If lumi is zero, go to event with given run and event number
Definition at line 154 of file ChainEvent.cc.
References event_, eventIndex_, fileNames_, compare_using_db::ifile, and switchToFile().
{ // First try this file if (event_->to(run, lumi, event)) { // found it, return return true; } else { // Did not find it, try the other files sequentially. // Someday I can make this smarter. For now... we get something working. Long64_t thisFile = eventIndex_; std::vector<std::string>::const_iterator filesBegin = fileNames_.begin(), filesEnd = fileNames_.end(), ifile = filesBegin; for (; ifile != filesEnd; ++ifile) { // skip the "first" file that we tried if (ifile - filesBegin != thisFile) { // switch to the next file switchToFile(ifile - filesBegin); // check that tree for the desired event if (event_->to(run, lumi, event)) { // found it, return return true; } }// end ignore "first" file that we tried }// end loop over files // did not find the event with id "id". return false; }// end if we did not find event id in "first" file }
ChainEvent const & ChainEvent::toBegin | ( | ) | [virtual] |
Go to the very first Event
Implements fwlite::EventBase.
Definition at line 200 of file ChainEvent.cc.
References event_, eventIndex_, and switchToFile().
Referenced by fwlite::AnalyzerWrapper< T >::analyze(), and main().
{ if (eventIndex_ != 0) { switchToFile(0); } event_->toBegin(); return *this; }
edm::TriggerNames const & ChainEvent::triggerNames | ( | edm::TriggerResults const & | triggerResults | ) | const [virtual] |
Implements edm::EventBase.
Definition at line 317 of file ChainEvent.cc.
References event_.
{ return event_->triggerNames(triggerResults); }
edm::TriggerResultsByName ChainEvent::triggerResultsByName | ( | std::string const & | process | ) | const [virtual] |
friend class MultiChainEvent [friend] |
Definition at line 118 of file ChainEvent.h.
std::vector<Long64_t> fwlite::ChainEvent::accumulatedSize_ [private] |
Definition at line 131 of file ChainEvent.h.
Referenced by ChainEvent(), size(), and to().
boost::shared_ptr<Event> fwlite::ChainEvent::event_ [private] |
Definition at line 129 of file ChainEvent.h.
Referenced by atEnd(), event(), eventAuxiliary(), fillParameterSetRegistry(), getBranchDescriptions(), getBranchNameFor(), getByLabel(), getByProductID(), getLuminosityBlock(), getProcessHistory(), getRun(), getTFile(), isValid(), operator bool(), operator++(), processHistory(), setGetter(), switchToFile(), to(), toBegin(), triggerNames(), and triggerResultsByName().
Long64_t fwlite::ChainEvent::eventIndex_ [private] |
Definition at line 130 of file ChainEvent.h.
Referenced by atEnd(), eventIndex(), fileIndex(), operator++(), switchToFile(), to(), and toBegin().
boost::shared_ptr<TFile> fwlite::ChainEvent::file_ [private] |
Definition at line 128 of file ChainEvent.h.
Referenced by ChainEvent(), and switchToFile().
std::vector<std::string> fwlite::ChainEvent::fileNames_ [private] |
Definition at line 127 of file ChainEvent.h.
Referenced by atEnd(), ChainEvent(), operator++(), switchToFile(), and to().
boost::shared_ptr<edm::EDProductGetter> fwlite::ChainEvent::getter_ [private] |
Definition at line 132 of file ChainEvent.h.