CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Attributes | Private Attributes
fwlite::EntryFinder Class Reference

#include <EntryFinder.h>

Public Types

typedef edm::IndexIntoFile::EntryNumber_t EntryNumber_t
 

Public Member Functions

bool empty () const
 
 EntryFinder ()
 
void fillIndex (BranchMapReader &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 const EntryNumber_t invalidEntry = -1LL
 

Private Attributes

edm::FileIndex fileIndex_
 
edm::IndexIntoFile indexIntoFile_
 

Detailed Description

Definition at line 29 of file EntryFinder.h.

Member Typedef Documentation

◆ EntryNumber_t

Definition at line 33 of file EntryFinder.h.

Constructor & Destructor Documentation

◆ EntryFinder()

fwlite::EntryFinder::EntryFinder ( )

Definition at line 53 of file EntryFinder.cc.

53 : indexIntoFile_(), fileIndex_() {}

◆ ~EntryFinder()

fwlite::EntryFinder::~EntryFinder ( )

Definition at line 54 of file EntryFinder.cc.

54 {}

Member Function Documentation

◆ empty()

bool fwlite::EntryFinder::empty ( ) const
inline

Definition at line 34 of file EntryFinder.h.

34 { return indexIntoFile_.empty() && fileIndex_.empty(); }

References edm::FileIndex::empty(), edm::IndexIntoFile::empty(), fileIndex_, and indexIntoFile_.

Referenced by fillIndex().

◆ fillIndex()

void fwlite::EntryFinder::fillIndex ( BranchMapReader branchMap)

Definition at line 107 of file EntryFinder.cc.

107  {
108  if (empty()) {
109  TTree* meta = dynamic_cast<TTree*>(branchMap.getFile()->Get(edm::poolNames::metaDataTreeName().c_str()));
110  if (nullptr == meta) {
111  throw cms::Exception("NoMetaTree")
112  << "The TFile does not contain a TTree named " << edm::poolNames::metaDataTreeName();
113  }
114  if (meta->FindBranch(edm::poolNames::indexIntoFileBranchName().c_str()) != nullptr) {
115  edm::IndexIntoFile* indexPtr = &indexIntoFile_;
116  TBranch* b = meta->GetBranch(edm::poolNames::indexIntoFileBranchName().c_str());
117  b->SetAddress(&indexPtr);
118  b->GetEntry(0);
119  TTree* eventTree = branchMap.getEventTree();
120  TBranch* auxBranch = eventTree->GetBranch(edm::BranchTypeToAuxiliaryBranchName(edm::InEvent).c_str());
121  if (nullptr == auxBranch) {
122  throw cms::Exception("NoEventAuxilliary")
123  << "The TTree " << edm::poolNames::eventTreeName() << " does not contain a branch named 'EventAuxiliary'";
124  }
125 
126  indexIntoFile_.setNumberOfEvents(auxBranch->GetEntries());
128  std::shared_ptr<edm::IndexIntoFile::EventFinder>(std::make_shared<FWLiteEventFinder>(auxBranch)));
129 
130  } else if (meta->FindBranch(edm::poolNames::fileIndexBranchName().c_str()) != nullptr) {
131  edm::FileIndex* findexPtr = &fileIndex_;
132  TBranch* b = meta->GetBranch(edm::poolNames::fileIndexBranchName().c_str());
133  b->SetAddress(&findexPtr);
134  b->GetEntry(0);
135  } else {
136  // TBD: fill the FileIndex for old file formats (prior to CMSSW 2_0_0)
137  throw cms::Exception("NoIndexBranch")
138  << "The TFile does not contain a TBranch named " << edm::poolNames::indexIntoFileBranchName().c_str()
139  << " or " << edm::poolNames::fileIndexBranchName().c_str();
140  }
141  }
142  assert(!empty());
143  }

References cms::cuda::assert(), 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::LuminosityBlock::to(), and fwlite::Event::to().

◆ findEvent()

EntryFinder::EntryNumber_t fwlite::EntryFinder::findEvent ( edm::RunNumber_t const &  run,
edm::LuminosityBlockNumber_t const &  lumi,
edm::EventNumber_t const &  event 
) const

◆ findLumi()

EntryFinder::EntryNumber_t fwlite::EntryFinder::findLumi ( edm::RunNumber_t const &  run,
edm::LuminosityBlockNumber_t const &  lumi 
) const

◆ findRun()

EntryFinder::EntryNumber_t fwlite::EntryFinder::findRun ( edm::RunNumber_t const &  run) const

Member Data Documentation

◆ fileIndex_

edm::FileIndex fwlite::EntryFinder::fileIndex_
private

Definition at line 45 of file EntryFinder.h.

Referenced by empty(), fillIndex(), findEvent(), findLumi(), and findRun().

◆ indexIntoFile_

edm::IndexIntoFile fwlite::EntryFinder::indexIntoFile_
private

Definition at line 44 of file EntryFinder.h.

Referenced by empty(), fillIndex(), findEvent(), findLumi(), and findRun().

◆ invalidEntry

const EntryNumber_t fwlite::EntryFinder::invalidEntry = -1LL
static
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
edm::FileIndex
Definition: FileIndex.h:21
edm::FileIndex::findLumiPosition
const_iterator findLumiPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const
Definition: FileIndex.cc:120
mps_fire.i
i
Definition: mps_fire.py:355
edm::poolNames::eventTreeName
std::string const & eventTreeName()
Definition: BranchType.cc:218
fwlite::EntryFinder::invalidEntry
static const EntryNumber_t invalidEntry
Definition: EntryFinder.h:41
edm::IndexIntoFile::findRunPosition
IndexIntoFileItr findRunPosition(RunNumber_t run) const
Same as findPosition.
Definition: IndexIntoFile.cc:692
edm::FileIndex::findEventPosition
const_iterator findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: FileIndex.cc:91
edm::IndexIntoFile::setNumberOfEvents
void setNumberOfEvents(EntryNumber_t nevents)
Definition: IndexIntoFile.h:945
edm::IndexIntoFile::numericalOrder
Definition: IndexIntoFile.h:266
edm::IndexIntoFile
Definition: IndexIntoFile.h:225
cms::cuda::assert
assert(be >=bs)
edm::poolNames::indexIntoFileBranchName
std::string const & indexIntoFileBranchName()
Definition: BranchType.cc:201
fwlite::EntryFinder::EntryNumber_t
edm::IndexIntoFile::EntryNumber_t EntryNumber_t
Definition: EntryFinder.h:33
edm::IndexIntoFile::empty
bool empty() const
True if no runs, lumis, or events are in the file.
Definition: IndexIntoFile.cc:487
edm::BranchTypeToAuxiliaryBranchName
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:115
edm::IndexIntoFile::setEventFinder
void setEventFinder(std::shared_ptr< EventFinder > ptr)
Definition: IndexIntoFile.h:952
edm::InEvent
Definition: BranchType.h:11
b
double b
Definition: hdecay.h:118
edm::FileIndex::end
const_iterator end() const
Definition: FileIndex.h:87
edm::FileIndex::const_iterator
std::vector< Element >::const_iterator const_iterator
Definition: FileIndex.h:49
edm::FileIndex::empty
bool empty() const
Definition: FileIndex.h:99
edm::IndexIntoFile::IndexIntoFileItr
Definition: IndexIntoFile.h:681
fwlite::EntryFinder::empty
bool empty() const
Definition: EntryFinder.h:34
edm::IndexIntoFile::findLumiPosition
IndexIntoFileItr findLumiPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const
Definition: IndexIntoFile.cc:685
edm::IndexIntoFile::end
IndexIntoFileItr end(SortOrder sortOrder) const
Used to end an iteration over the Runs, Lumis, and Events in a file.
Definition: IndexIntoFile.cc:470
edm::IndexIntoFile::findEventPosition
IndexIntoFileItr findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: IndexIntoFile.cc:676
writedatasetfile.run
run
Definition: writedatasetfile.py:27
edm::FileIndex::findRunPosition
const_iterator findRunPosition(RunNumber_t run) const
Definition: FileIndex.cc:135
edm::poolNames::metaDataTreeName
std::string const & metaDataTreeName()
Definition: BranchType.cc:162
fwlite::EntryFinder::indexIntoFile_
edm::IndexIntoFile indexIntoFile_
Definition: EntryFinder.h:44
Exception
Definition: hltDiff.cc:246
fwlite::EntryFinder::fileIndex_
edm::FileIndex fileIndex_
Definition: EntryFinder.h:45
edm::poolNames::fileIndexBranchName
std::string const & fileIndexBranchName()
Definition: BranchType.cc:198
event
Definition: event.py:1
lumi
Definition: LumiSectionData.h:20