CMS 3D CMS Logo

Public Types | Public Member Functions | Static Public Attributes | Private Attributes

fwlite::EntryFinder Class Reference

#include <EntryFinder.h>

List of all members.

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_

Detailed Description

Definition at line 30 of file EntryFinder.h.


Member Typedef Documentation

Definition at line 34 of file EntryFinder.h.


Constructor & Destructor Documentation

fwlite::EntryFinder::EntryFinder ( )

Definition at line 53 of file EntryFinder.cc.

fwlite::EntryFinder::~EntryFinder ( )

Definition at line 54 of file EntryFinder.cc.

{}

Member Function Documentation

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

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
EntryFinder::EntryNumber_t fwlite::EntryFinder::findLumi ( edm::RunNumber_t const &  run,
edm::LuminosityBlockNumber_t const &  lumi 
) const
EntryFinder::EntryNumber_t fwlite::EntryFinder::findRun ( edm::RunNumber_t const &  run) const

Member Data Documentation

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