#include <EntryFinder.h>
Public Types | |
typedef edm::IndexIntoFile::EntryNumber_t | EntryNumber_t |
Public Member Functions | |
bool | empty () const |
EntryFinder () | |
void | fillIndex (BranchMapReader const &branchMap) |
EntryNumber_t | findEvent (edm::RunNumber_t const &run, edm::LuminosityBlockNumber_t const &lumi, edm::EventNumber_t const &event) const |
EntryNumber_t | findLumi (edm::RunNumber_t const &run, edm::LuminosityBlockNumber_t const &lumi) const |
EntryNumber_t | findRun (edm::RunNumber_t const &run) const |
~EntryFinder () | |
Static Public Attributes | |
static EntryNumber_t const | invalidEntry = -1LL |
Private Attributes | |
edm::FileIndex | fileIndex_ |
edm::IndexIntoFile | indexIntoFile_ |
Definition at line 30 of file EntryFinder.h.
Definition at line 34 of file EntryFinder.h.
fwlite::EntryFinder::EntryFinder | ( | ) |
Definition at line 53 of file EntryFinder.cc.
: indexIntoFile_(), fileIndex_() {}
fwlite::EntryFinder::~EntryFinder | ( | ) |
Definition at line 54 of file EntryFinder.cc.
{}
bool fwlite::EntryFinder::empty | ( | ) | const [inline] |
Definition at line 35 of file EntryFinder.h.
References edm::IndexIntoFile::empty(), edm::FileIndex::empty(), fileIndex_, and indexIntoFile_.
Referenced by fillIndex().
{return indexIntoFile_.empty() && fileIndex_.empty();}
void fwlite::EntryFinder::fillIndex | ( | BranchMapReader const & | branchMap | ) |
Definition at line 108 of file EntryFinder.cc.
References b, edm::BranchTypeToAuxiliaryBranchName(), empty(), edm::poolNames::eventTreeName(), Exception, fileIndex_, edm::poolNames::fileIndexBranchName(), fwlite::BranchMapReader::getEventTree(), fwlite::BranchMapReader::getFile(), indexIntoFile_, edm::poolNames::indexIntoFileBranchName(), edm::InEvent, edm::poolNames::metaDataTreeName(), edm::IndexIntoFile::setEventFinder(), and edm::IndexIntoFile::setNumberOfEvents().
Referenced by fwlite::Event::indexFromEventId(), fwlite::Run::to(), fwlite::Event::to(), and fwlite::LuminosityBlock::to().
{ if (empty()) { TTree* meta = dynamic_cast<TTree*>(branchMap.getFile()->Get(edm::poolNames::metaDataTreeName().c_str())); if (0 == meta) { throw cms::Exception("NoMetaTree") << "The TFile does not contain a TTree named " << edm::poolNames::metaDataTreeName(); } if (meta->FindBranch(edm::poolNames::indexIntoFileBranchName().c_str()) != 0) { edm::IndexIntoFile* indexPtr = &indexIntoFile_; TBranch* b = meta->GetBranch(edm::poolNames::indexIntoFileBranchName().c_str()); b->SetAddress(&indexPtr); b->GetEntry(0); TTree* eventTree = branchMap.getEventTree(); TBranch* auxBranch = eventTree->GetBranch(edm::BranchTypeToAuxiliaryBranchName(edm::InEvent).c_str()); if(0 == auxBranch) { throw cms::Exception("NoEventAuxilliary") << "The TTree " << edm::poolNames::eventTreeName() << " does not contain a branch named 'EventAuxiliary'"; } indexIntoFile_.setNumberOfEvents(auxBranch->GetEntries()); indexIntoFile_.setEventFinder(boost::shared_ptr<edm::IndexIntoFile::EventFinder>(new FWLiteEventFinder(auxBranch))); } else if (meta->FindBranch(edm::poolNames::fileIndexBranchName().c_str()) != 0) { edm::FileIndex* findexPtr = &fileIndex_; TBranch* b = meta->GetBranch(edm::poolNames::fileIndexBranchName().c_str()); b->SetAddress(&findexPtr); b->GetEntry(0); } else { // TBD: fill the FileIndex for old file formats (prior to CMSSW 2_0_0) throw cms::Exception("NoIndexBranch") << "The TFile does not contain a TBranch named " << edm::poolNames::indexIntoFileBranchName().c_str() << " or " << edm::poolNames::fileIndexBranchName().c_str(); } } assert(!empty()); }
EntryFinder::EntryNumber_t fwlite::EntryFinder::findEvent | ( | edm::RunNumber_t const & | run, |
edm::LuminosityBlockNumber_t const & | lumi, | ||
edm::EventNumber_t const & | event | ||
) | const |
Definition at line 57 of file EntryFinder.cc.
References edm::IndexIntoFile::empty(), edm::FileIndex::end(), edm::IndexIntoFile::end(), edm::IndexIntoFile::IndexIntoFileItr::entry(), fileIndex_, edm::IndexIntoFile::findEventPosition(), edm::FileIndex::findEventPosition(), i, indexIntoFile_, invalidEntry, edm::IndexIntoFile::numericalOrder, and runTheMatrix::ret.
Referenced by fwlite::Event::indexFromEventId(), and fwlite::Event::to().
{ EntryFinder::EntryNumber_t ret = invalidEntry; if (!indexIntoFile_.empty()) { edm::IndexIntoFile::IndexIntoFileItr i = indexIntoFile_.findEventPosition(run, lumi, event); if (indexIntoFile_.end(edm::IndexIntoFile::numericalOrder) != i) { ret = i.entry(); } } else { edm::FileIndex::const_iterator i = fileIndex_.findEventPosition(run, lumi, event); if (fileIndex_.end() != i) { ret = i->entry_; } } return ret; }
EntryFinder::EntryNumber_t fwlite::EntryFinder::findLumi | ( | edm::RunNumber_t const & | run, |
edm::LuminosityBlockNumber_t const & | lumi | ||
) | const |
Definition at line 74 of file EntryFinder.cc.
References edm::IndexIntoFile::empty(), edm::FileIndex::end(), edm::IndexIntoFile::end(), edm::IndexIntoFile::IndexIntoFileItr::entry(), fileIndex_, edm::FileIndex::findLumiPosition(), edm::IndexIntoFile::findLumiPosition(), i, indexIntoFile_, invalidEntry, edm::IndexIntoFile::numericalOrder, and runTheMatrix::ret.
Referenced by fwlite::LuminosityBlock::to().
{ EntryFinder::EntryNumber_t ret = invalidEntry; if (!indexIntoFile_.empty()) { edm::IndexIntoFile::IndexIntoFileItr i = indexIntoFile_.findLumiPosition(run, lumi); if (indexIntoFile_.end(edm::IndexIntoFile::numericalOrder) != i) { ret = i.entry(); } } else { edm::FileIndex::const_iterator i = fileIndex_.findLumiPosition(run, lumi); if (fileIndex_.end() != i) { ret = i->entry_; } } return ret; }
EntryFinder::EntryNumber_t fwlite::EntryFinder::findRun | ( | edm::RunNumber_t const & | run | ) | const |
Definition at line 91 of file EntryFinder.cc.
References edm::IndexIntoFile::empty(), edm::FileIndex::end(), edm::IndexIntoFile::end(), edm::IndexIntoFile::IndexIntoFileItr::entry(), fileIndex_, edm::FileIndex::findRunPosition(), edm::IndexIntoFile::findRunPosition(), i, indexIntoFile_, invalidEntry, edm::IndexIntoFile::numericalOrder, and runTheMatrix::ret.
Referenced by fwlite::Run::to().
{ EntryFinder::EntryNumber_t ret = invalidEntry; if (!indexIntoFile_.empty()) { edm::IndexIntoFile::IndexIntoFileItr i = indexIntoFile_.findRunPosition(run); if (indexIntoFile_.end(edm::IndexIntoFile::numericalOrder) != i) { ret = i.entry(); } } else { edm::FileIndex::const_iterator i = fileIndex_.findRunPosition(run); if (fileIndex_.end() != i) { ret = i->entry_; } } return ret; }
Definition at line 43 of file EntryFinder.h.
Referenced by empty(), fillIndex(), findEvent(), findLumi(), and findRun().
Definition at line 42 of file EntryFinder.h.
Referenced by empty(), fillIndex(), findEvent(), findLumi(), and findRun().
EntryNumber_t const fwlite::EntryFinder::invalidEntry = -1LL [static] |
Definition at line 40 of file EntryFinder.h.
Referenced by findEvent(), findLumi(), findRun(), fwlite::Event::indexFromEventId(), fwlite::Run::to(), fwlite::Event::to(), and fwlite::LuminosityBlock::to().