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 EntryNumber_t const 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_() {}
edm::IndexIntoFile indexIntoFile_
Definition: EntryFinder.h:44
edm::FileIndex fileIndex_
Definition: EntryFinder.h:45

◆ ~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.

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

Referenced by fillIndex().

34 { return indexIntoFile_.empty() && fileIndex_.empty(); }
bool empty() const
Definition: FileIndex.h:99
edm::IndexIntoFile indexIntoFile_
Definition: EntryFinder.h:44
bool empty() const
True if no runs, lumis, or events are in the file.
edm::FileIndex fileIndex_
Definition: EntryFinder.h:45

◆ fillIndex()

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

Definition at line 107 of file EntryFinder.cc.

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().

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  }
std::string const & metaDataTreeName()
Definition: BranchType.cc:159
edm::IndexIntoFile indexIntoFile_
Definition: EntryFinder.h:44
assert(be >=bs)
void setNumberOfEvents(EntryNumber_t nevents)
std::string const & fileIndexBranchName()
Definition: BranchType.cc:195
double b
Definition: hdecay.h:120
std::string const & eventTreeName()
Definition: BranchType.cc:220
edm::FileIndex fileIndex_
Definition: EntryFinder.h:45
bool empty() const
Definition: EntryFinder.h:34
std::string const & indexIntoFileBranchName()
Definition: BranchType.cc:198
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:116
void setEventFinder(std::shared_ptr< EventFinder > ptr)

◆ findEvent()

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 56 of file EntryFinder.cc.

References edm::IndexIntoFile::empty(), edm::FileIndex::end(), edm::IndexIntoFile::end(), fileIndex_, edm::FileIndex::findEventPosition(), edm::IndexIntoFile::findEventPosition(), mps_fire::i, indexIntoFile_, invalidEntry, edm::IndexIntoFile::numericalOrder, runTheMatrix::ret, and writedatasetfile::run.

Referenced by fwlite::Event::indexFromEventId(), and fwlite::Event::to().

58  {
60  if (!indexIntoFile_.empty()) {
63  ret = i.entry();
64  }
65  } else {
67  if (fileIndex_.end() != i) {
68  ret = i->entry_;
69  }
70  }
71  return ret;
72  }
IndexIntoFileItr end(SortOrder sortOrder) const
Used to end an iteration over the Runs, Lumis, and Events in a file.
const_iterator end() const
Definition: FileIndex.h:87
ret
prodAgent to be discontinued
const_iterator findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
Definition: FileIndex.cc:91
edm::IndexIntoFile indexIntoFile_
Definition: EntryFinder.h:44
IndexIntoFileItr findEventPosition(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
std::vector< Element >::const_iterator const_iterator
Definition: FileIndex.h:49
edm::IndexIntoFile::EntryNumber_t EntryNumber_t
Definition: EntryFinder.h:33
bool empty() const
True if no runs, lumis, or events are in the file.
static EntryNumber_t const invalidEntry
Definition: EntryFinder.h:41
edm::FileIndex fileIndex_
Definition: EntryFinder.h:45
Definition: event.py:1

◆ findLumi()

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(), fileIndex_, edm::FileIndex::findLumiPosition(), edm::IndexIntoFile::findLumiPosition(), mps_fire::i, indexIntoFile_, invalidEntry, edm::IndexIntoFile::numericalOrder, runTheMatrix::ret, and writedatasetfile::run.

Referenced by fwlite::LuminosityBlock::to().

75  {
77  if (!indexIntoFile_.empty()) {
80  ret = i.entry();
81  }
82  } else {
84  if (fileIndex_.end() != i) {
85  ret = i->entry_;
86  }
87  }
88  return ret;
89  }
IndexIntoFileItr end(SortOrder sortOrder) const
Used to end an iteration over the Runs, Lumis, and Events in a file.
IndexIntoFileItr findLumiPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const
const_iterator end() const
Definition: FileIndex.h:87
ret
prodAgent to be discontinued
edm::IndexIntoFile indexIntoFile_
Definition: EntryFinder.h:44
std::vector< Element >::const_iterator const_iterator
Definition: FileIndex.h:49
edm::IndexIntoFile::EntryNumber_t EntryNumber_t
Definition: EntryFinder.h:33
bool empty() const
True if no runs, lumis, or events are in the file.
static EntryNumber_t const invalidEntry
Definition: EntryFinder.h:41
const_iterator findLumiPosition(RunNumber_t run, LuminosityBlockNumber_t lumi) const
Definition: FileIndex.cc:120
edm::FileIndex fileIndex_
Definition: EntryFinder.h:45

◆ findRun()

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(), fileIndex_, edm::FileIndex::findRunPosition(), edm::IndexIntoFile::findRunPosition(), mps_fire::i, indexIntoFile_, invalidEntry, edm::IndexIntoFile::numericalOrder, runTheMatrix::ret, and writedatasetfile::run.

Referenced by fwlite::Run::to().

91  {
93  if (!indexIntoFile_.empty()) {
96  ret = i.entry();
97  }
98  } else {
100  if (fileIndex_.end() != i) {
101  ret = i->entry_;
102  }
103  }
104  return ret;
105  }
IndexIntoFileItr end(SortOrder sortOrder) const
Used to end an iteration over the Runs, Lumis, and Events in a file.
const_iterator findRunPosition(RunNumber_t run) const
Definition: FileIndex.cc:135
const_iterator end() const
Definition: FileIndex.h:87
ret
prodAgent to be discontinued
edm::IndexIntoFile indexIntoFile_
Definition: EntryFinder.h:44
std::vector< Element >::const_iterator const_iterator
Definition: FileIndex.h:49
edm::IndexIntoFile::EntryNumber_t EntryNumber_t
Definition: EntryFinder.h:33
bool empty() const
True if no runs, lumis, or events are in the file.
static EntryNumber_t const invalidEntry
Definition: EntryFinder.h:41
edm::FileIndex fileIndex_
Definition: EntryFinder.h:45
IndexIntoFileItr findRunPosition(RunNumber_t run) const
Same as findPosition.

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

EntryNumber_t const fwlite::EntryFinder::invalidEntry = -1LL
static