CMS 3D CMS Logo

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

edm::RootFile Class Reference

#include <RootFile.h>

List of all members.

Public Types

typedef std::array< RootTree
*, NumBranchTypes > 
RootTreePtrArray

Public Member Functions

BranchIDListRegistry::collection_type
const & 
branchIDLists ()
bool branchListIndexesUnchanged () const
EventPrincipalclearAndReadCurrentEvent (EventPrincipal &cache, boost::shared_ptr< LuminosityBlockPrincipal > lb=boost::shared_ptr< LuminosityBlockPrincipal >())
void close ()
boost::shared_ptr< FileBlockcreateFileBlock () const
EventAuxiliary const & eventAux () const
EventID const & eventID () const
RootTree const & eventTree () const
std::string const & file () const
FileFormatVersion fileFormatVersion () const
IndexIntoFile::EntryType getNextEntryTypeWanted ()
bool goToEvent (EventID const &eventID)
std::array< bool,
NumBranchTypes > const & 
hasNewlyDroppedBranch () const
IndexIntoFile::IndexIntoFileItr indexIntoFileIter () const
boost::shared_ptr< IndexIntoFileindexIntoFileSharedPtr () const
RootTree const & lumiTree () const
bool modifiedIDs () const
bool nextEventEntry ()
RootFileoperator= (RootFile const &)
boost::shared_ptr
< ProductRegistry const > 
productRegistry () const
EventPrincipalreadCurrentEvent (EventPrincipal &cache, boost::shared_ptr< LuminosityBlockPrincipal > lb=boost::shared_ptr< LuminosityBlockPrincipal >())
EventPrincipalreadEvent (EventPrincipal &cache, boost::shared_ptr< LuminosityBlockPrincipal > lb=boost::shared_ptr< LuminosityBlockPrincipal >())
boost::shared_ptr
< LuminosityBlockPrincipal
readLumi (boost::shared_ptr< LuminosityBlockPrincipal > lbCache)
boost::shared_ptr
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary_ ()
boost::shared_ptr< RunPrincipalreadRun_ (boost::shared_ptr< RunPrincipal > rpCache)
boost::shared_ptr< RunAuxiliaryreadRunAuxiliary_ ()
void reportOpened (std::string const &inputType)
void rewind ()
 RootFile (std::string const &fileName, ProcessConfiguration const &processConfiguration, std::string const &logicalFileName, boost::shared_ptr< InputFile > filePtr, boost::shared_ptr< EventSkipperByID > eventSkipperByID, bool skipAnyEvents, int remainingEvents, int remainingLumis, unsigned int treeCacheSize, int treeMaxVirtualSize, InputSource::ProcessingMode processingMode, RunNumber_t const &forcedRunNumber, bool noEventSort, GroupSelectorRules const &groupSelectorRules, InputType::InputType inputType, boost::shared_ptr< DuplicateChecker > duplicateChecker, bool dropDescendantsOfDroppedProducts, std::vector< boost::shared_ptr< IndexIntoFile > > const &indexesIntoFiles, std::vector< boost::shared_ptr< IndexIntoFile > >::size_type currentIndexIntoFile, std::vector< ProcessHistoryID > &orderedProcessHistoryIDs, bool labelRawDataLikeMC, bool usingGoToEvent)
 RootFile (RootFile const &)
RootTree const & runTree () const
EventPrincipalsecondaryEventPrincipal ()
void setAtEventEntry (IndexIntoFile::EntryNumber_t entry)
bool setEntryAtEvent (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
bool setEntryAtItem (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
bool setEntryAtLumi (RunNumber_t run, LuminosityBlockNumber_t lumi)
bool setEntryAtNextEventInLumi (RunNumber_t run, LuminosityBlockNumber_t lumi)
bool setEntryAtRun (RunNumber_t run)
void setPosition (IndexIntoFile::IndexIntoFileItr const &position)
void setToLastEntry ()
bool skipEvents (int &offset)
bool wasFirstEventJustRead () const
bool wasLastEventJustRead () const
int whyNotFastClonable () const
 ~RootFile ()

Private Member Functions

void checkReleaseVersion ()
void dropOnInput (ProductRegistry &reg, GroupSelectorRules const &rules, bool dropDescendants, InputType::InputType inputType)
void fillEventAuxiliary ()
void fillHistory ()
void fillIndexIntoFile ()
boost::shared_ptr
< LuminosityBlockAuxiliary
fillLumiAuxiliary ()
boost::shared_ptr< RunAuxiliaryfillRunAuxiliary ()
void fillThisEventAuxiliary ()
IndexIntoFile::EntryType getEntryTypeWithSkipping ()
void initializeDuplicateChecker (std::vector< boost::shared_ptr< IndexIntoFile > > const &indexesIntoFiles, std::vector< boost::shared_ptr< IndexIntoFile > >::size_type currentIndexIntoFile)
bool isDuplicateEvent ()
boost::shared_ptr< BranchMappermakeBranchMapper ()
std::unique_ptr
< MakeProvenanceReader
makeProvenanceReaderMaker () const
std::string const & newBranchToOldBranch (std::string const &newBranch) const
void overrideRunNumber (EventID &id, bool isRealData)
void overrideRunNumber (RunID &id)
void overrideRunNumber (LuminosityBlockID &id)
void readEntryDescriptionTree ()
void readEventHistoryTree ()
void readParentageTree ()
void setIfFastClonable (int remainingEvents, int remainingLumis)
bool skipThisEntry ()
RootTreePtrArraytreePointers ()
void validateFile (InputType::InputType inputType, bool usingGoToEvent)

Private Attributes

boost::shared_ptr< BranchChildrenbranchChildren_
boost::shared_ptr
< BranchIDListRegistry::collection_type
const > 
branchIDLists_
boost::shared_ptr
< BranchListIndexes
branchListIndexes_
bool branchListIndexesUnchanged_
std::unique_ptr
< DaqProvenanceHelper
daqProvenanceHelper_
boost::shared_ptr
< DuplicateChecker
duplicateChecker_
EventAuxiliary eventAux_
boost::shared_ptr< BranchMappereventBranchMapper_
TTree * eventHistoryTree_
std::vector
< EventProcessHistoryID
eventProcessHistoryIDs_
std::vector
< EventProcessHistoryID >
::const_iterator 
eventProcessHistoryIter_
boost::shared_ptr
< EventSelectionIDVector
eventSelectionIDs_
boost::shared_ptr
< EventSkipperByID
eventSkipperByID_
RootTree eventTree_
FileID fid_
std::string const file_
FileFormatVersion fileFormatVersion_
boost::shared_ptr< InputFilefilePtr_
int forcedRunOffset_
std::array< bool, NumBranchTypes > hasNewlyDroppedBranch_
std::unique_ptr< Historyhistory_
IndexIntoFileindexIntoFile_
IndexIntoFile::IndexIntoFileItr indexIntoFileBegin_
IndexIntoFile::IndexIntoFileItr indexIntoFileEnd_
IndexIntoFile::IndexIntoFileItr indexIntoFileIter_
boost::shared_ptr< IndexIntoFileindexIntoFileSharedPtr_
IndexIntoFile::EntryNumber_t lastEventEntryNumberRead_
std::string const logicalFile_
RootTree lumiTree_
std::map< std::string,
std::string > 
newBranchToOldBranch_
bool noEventSort_
std::vector< ProcessHistoryID > & orderedProcessHistoryIDs_
std::vector< ParentageIDparentageIDLookup_
ProcessConfiguration const & processConfiguration_
ProcessConfigurationVector processConfigurations_
InputSource::ProcessingMode processingMode_
boost::shared_ptr
< ProductRegistry const > 
productRegistry_
std::unique_ptr
< ProvenanceAdaptor
provenanceAdaptor_
std::unique_ptr
< MakeProvenanceReader
provenanceReaderMaker_
RootTree runTree_
boost::shared_ptr< RunAuxiliarysavedRunAuxiliary_
std::unique_ptr< EventPrincipalsecondaryEventPrincipal_
bool skipAnyEvents_
RootTreePtrArray treePointers_
int whyNotFastClonable_

Detailed Description

Definition at line 50 of file RootFile.h.


Member Typedef Documentation

typedef std::array<RootTree*, NumBranchTypes> edm::RootFile::RootTreePtrArray

Definition at line 52 of file RootFile.h.


Constructor & Destructor Documentation

edm::RootFile::RootFile ( std::string const &  fileName,
ProcessConfiguration const &  processConfiguration,
std::string const &  logicalFileName,
boost::shared_ptr< InputFile filePtr,
boost::shared_ptr< EventSkipperByID eventSkipperByID,
bool  skipAnyEvents,
int  remainingEvents,
int  remainingLumis,
unsigned int  treeCacheSize,
int  treeMaxVirtualSize,
InputSource::ProcessingMode  processingMode,
RunNumber_t const &  forcedRunNumber,
bool  noEventSort,
GroupSelectorRules const &  groupSelectorRules,
InputType::InputType  inputType,
boost::shared_ptr< DuplicateChecker duplicateChecker,
bool  dropDescendantsOfDroppedProducts,
std::vector< boost::shared_ptr< IndexIntoFile > > const &  indexesIntoFiles,
std::vector< boost::shared_ptr< IndexIntoFile > >::size_type  currentIndexIntoFile,
std::vector< ProcessHistoryID > &  orderedProcessHistoryIDs,
bool  labelRawDataLikeMC,
bool  usingGoToEvent 
)

Definition at line 125 of file RootFile.cc.

References edm::IndexIntoFile::begin(), branchChildren_, edm::poolNames::branchIDListBranchName(), branchIDLists_, branchListIndexesUnchanged_, edm::BranchDescription::branchName(), edm::BranchDescription::branchType(), edm::BranchTypeToAuxiliaryBranchName(), checkReleaseVersion(), edm::BranchDescription::className(), edm::ProductRegistry::copyProduct(), daqProvenanceHelper_, edm::roottree::defaultNonEventCacheSize, edm::IndexIntoFile::doneFileInitialization(), dropOnInput(), edm::IndexIntoFile::end(), edm::errors::EventCorruption, edm::poolNames::eventHistoryBranchName(), eventProcessHistoryIDs_, eventProcessHistoryIter_, eventSkipperByID_, edm::FileBlock::EventsOrLumisSelectedByID, eventTree_, Exception, fid_, file_, fileFormatVersion(), fileFormatVersion_, edm::poolNames::fileFormatVersionBranchName(), edm::poolNames::fileIdentifierBranchName(), filePtr_, edm::errors::FileReadError, edm::fillProductRegistryTransients(), edm::IndexIntoFile::firstAppearanceOrder, forcedRunOffset_, edm::BranchDescription::friendlyClassName(), edm::friendlyname::friendlyName(), edm::roottree::getEntry(), hasNewlyDroppedBranch_, i, edm::poolNames::idToParameterSetBlobsBranchName(), indexIntoFile_, indexIntoFileBegin_, edm::poolNames::indexIntoFileBranchName(), indexIntoFileEnd_, indexIntoFileIter_, edm::InEvent, edm::BranchDescription::init(), initializeDuplicateChecker(), edm::InLumi, edm::InRun, edm::detail::ThreadSafeRegistry< KEY, T, E >::insertMapped(), instance, lumiTree_, makeProvenanceReaderMaker(), edm::poolNames::metaDataTreeName(), edm::poolNames::moduleDescriptionMapBranchName(), newBranchToOldBranch(), newBranchToOldBranch_, edm::IndexIntoFile::numericalOrder, edm::poolNames::parameterSetMapBranchName(), edm::poolNames::parameterSetsTreeName(), edm::InputType::Primary, edm::poolNames::processConfigurationBranchName(), processConfigurations_, edm::poolNames::processHistoryBranchName(), edm::poolNames::processHistoryMapBranchName(), parseEventContent::prod, edm::poolNames::productDependenciesBranchName(), edm::poolNames::productDescriptionBranchName(), edm::ProductRegistry::productList(), edm::ProductRegistry::productListUpdator(), productRegistry(), productRegistry_, provenanceAdaptor_, provenanceReaderMaker_, readEventHistoryTree(), readParentageTree(), fetchall_from_DQM_v2::release, edm::RootTree::resetTraining(), runTree_, secondaryEventPrincipal_, edm::InputType::SecondarySource, edm::ParameterSet::setID(), setIfFastClonable(), edm::setRefCoreStreamer(), LaserTracksInput_cfi::source, edm::RootTree::trainCache(), edm::roottree::trainCache(), treePointers_, edm::errors::UnimplementedFeature, edm::BranchDescription::updateFriendlyClassName(), edm::BranchIDListHelper::updateFromInput(), validateFile(), and whyNotFastClonable_.

                                          :
      file_(fileName),
      logicalFile_(logicalFileName),
      processConfiguration_(processConfiguration),
      processConfigurations_(),
      filePtr_(filePtr),
      eventSkipperByID_(eventSkipperByID),
      fileFormatVersion_(),
      fid_(),
      indexIntoFileSharedPtr_(new IndexIntoFile),
      indexIntoFile_(*indexIntoFileSharedPtr_),
      orderedProcessHistoryIDs_(orderedProcessHistoryIDs),
      indexIntoFileBegin_(indexIntoFile_.begin(noEventSort ? IndexIntoFile::firstAppearanceOrder : IndexIntoFile::numericalOrder)),
      indexIntoFileEnd_(indexIntoFileBegin_),
      indexIntoFileIter_(indexIntoFileBegin_),
      eventProcessHistoryIDs_(),
      eventProcessHistoryIter_(eventProcessHistoryIDs_.begin()),
      savedRunAuxiliary_(),
      skipAnyEvents_(skipAnyEvents),
      noEventSort_(noEventSort),
      whyNotFastClonable_(0),
      hasNewlyDroppedBranch_(),
      branchListIndexesUnchanged_(false),
      eventAux_(),
      eventTree_(filePtr_, InEvent, treeMaxVirtualSize, treeCacheSize, roottree::defaultLearningEntries),
      lumiTree_(filePtr_, InLumi, treeMaxVirtualSize, roottree::defaultNonEventCacheSize, roottree::defaultNonEventLearningEntries),
      runTree_(filePtr_, InRun, treeMaxVirtualSize, roottree::defaultNonEventCacheSize, roottree::defaultNonEventLearningEntries),
      treePointers_(),
      lastEventEntryNumberRead_(-1LL),
      productRegistry_(),
      branchIDLists_(),
      processingMode_(processingMode),
      forcedRunOffset_(0),
      newBranchToOldBranch_(),
      eventHistoryTree_(0),
      eventSelectionIDs_(new EventSelectionIDVector),
      branchListIndexes_(new BranchListIndexes),
      history_(),
      branchChildren_(new BranchChildren),
      duplicateChecker_(duplicateChecker),
      provenanceAdaptor_(),
      provenanceReaderMaker_(),
      secondaryEventPrincipal_(),
      eventBranchMapper_(),
      parentageIDLookup_(),
      daqProvenanceHelper_() {

    hasNewlyDroppedBranch_.fill(false);

    treePointers_[InEvent] = &eventTree_;
    treePointers_[InLumi]  = &lumiTree_;
    treePointers_[InRun]   = &runTree_;

    // Read the metadata tree.
    // We use a smart pointer so the tree will be deleted after use, and not kept for the life of the file.
    std::unique_ptr<TTree> metaDataTree(dynamic_cast<TTree *>(filePtr_->Get(poolNames::metaDataTreeName().c_str())));
    if(0 == metaDataTree.get()) {
      throw Exception(errors::FileReadError) << "Could not find tree " << poolNames::metaDataTreeName()
                                             << " in the input file.\n";
    }

    // To keep things simple, we just read in every possible branch that exists.
    // We don't pay attention to which branches exist in which file format versions

    FileFormatVersion *fftPtr = &fileFormatVersion_;
    if(metaDataTree->FindBranch(poolNames::fileFormatVersionBranchName().c_str()) != 0) {
      TBranch *fft = metaDataTree->GetBranch(poolNames::fileFormatVersionBranchName().c_str());
      fft->SetAddress(&fftPtr);
      roottree::getEntry(fft, 0);
      metaDataTree->SetBranchAddress(poolNames::fileFormatVersionBranchName().c_str(), &fftPtr);
    }

    FileID *fidPtr = &fid_;
    if(metaDataTree->FindBranch(poolNames::fileIdentifierBranchName().c_str()) != 0) {
      metaDataTree->SetBranchAddress(poolNames::fileIdentifierBranchName().c_str(), &fidPtr);
    }

    IndexIntoFile *iifPtr = &indexIntoFile_;
    if(metaDataTree->FindBranch(poolNames::indexIntoFileBranchName().c_str()) != 0) {
      metaDataTree->SetBranchAddress(poolNames::indexIntoFileBranchName().c_str(), &iifPtr);
    }

    // Need to read to a temporary registry so we can do a translation of the BranchKeys.
    // This preserves backward compatibility against friendly class name algorithm changes.
    ProductRegistry inputProdDescReg;
    ProductRegistry *ppReg = &inputProdDescReg;
    metaDataTree->SetBranchAddress(poolNames::productDescriptionBranchName().c_str(), (&ppReg));

    typedef std::map<ParameterSetID, ParameterSetBlob> PsetMap;
    PsetMap psetMap;
    PsetMap *psetMapPtr = &psetMap;
    if(metaDataTree->FindBranch(poolNames::parameterSetMapBranchName().c_str()) != 0) {
      //backward compatibility
      assert(!fileFormatVersion().parameterSetsTree());
      metaDataTree->SetBranchAddress(poolNames::parameterSetMapBranchName().c_str(), &psetMapPtr);
    } else {
      assert(fileFormatVersion().parameterSetsTree());
      // We use a smart pointer so the tree will be deleted after use, and not kept for the life of the file.
      std::unique_ptr<TTree> psetTree(dynamic_cast<TTree *>(filePtr_->Get(poolNames::parameterSetsTreeName().c_str())));
      if(0 == psetTree.get()) {
        throw Exception(errors::FileReadError) << "Could not find tree " << poolNames::parameterSetsTreeName()
        << " in the input file.\n";
      }

      typedef std::pair<ParameterSetID, ParameterSetBlob> IdToBlobs;
      IdToBlobs idToBlob;
      IdToBlobs* pIdToBlob = &idToBlob;
      psetTree->SetBranchAddress(poolNames::idToParameterSetBlobsBranchName().c_str(), &pIdToBlob);

      std::unique_ptr<TTreeCache> psetTreeCache = roottree::trainCache(psetTree.get(), *filePtr_, roottree::defaultNonEventCacheSize, "*");
      filePtr_->SetCacheRead(psetTreeCache.get());
      for(Long64_t i = 0; i != psetTree->GetEntries(); ++i) {
        psetTree->GetEntry(i);
        psetMap.insert(idToBlob);
      }
      filePtr_->SetCacheRead(0);
    }

    // backward compatibility
    ProcessHistoryRegistry::collection_type pHistMap;
    ProcessHistoryRegistry::collection_type *pHistMapPtr = &pHistMap;
    if(metaDataTree->FindBranch(poolNames::processHistoryMapBranchName().c_str()) != 0) {
      metaDataTree->SetBranchAddress(poolNames::processHistoryMapBranchName().c_str(), &pHistMapPtr);
    }

    ProcessHistoryRegistry::vector_type pHistVector;
    ProcessHistoryRegistry::vector_type *pHistVectorPtr = &pHistVector;
    if(metaDataTree->FindBranch(poolNames::processHistoryBranchName().c_str()) != 0) {
      metaDataTree->SetBranchAddress(poolNames::processHistoryBranchName().c_str(), &pHistVectorPtr);
    }

    ProcessConfigurationVector* procConfigVectorPtr = &processConfigurations_;
    if(metaDataTree->FindBranch(poolNames::processConfigurationBranchName().c_str()) != 0) {
      metaDataTree->SetBranchAddress(poolNames::processConfigurationBranchName().c_str(), &procConfigVectorPtr);
    }

    std::unique_ptr<BranchIDListRegistry::collection_type> branchIDListsAPtr(new BranchIDListRegistry::collection_type);
    BranchIDListRegistry::collection_type *branchIDListsPtr = branchIDListsAPtr.get();
    if(metaDataTree->FindBranch(poolNames::branchIDListBranchName().c_str()) != 0) {
      metaDataTree->SetBranchAddress(poolNames::branchIDListBranchName().c_str(), &branchIDListsPtr);
    }

    BranchChildren* branchChildrenBuffer = branchChildren_.get();
    if(metaDataTree->FindBranch(poolNames::productDependenciesBranchName().c_str()) != 0) {
      metaDataTree->SetBranchAddress(poolNames::productDependenciesBranchName().c_str(), &branchChildrenBuffer);
    }

    // backward compatibility
    std::vector<EventProcessHistoryID> *eventHistoryIDsPtr = &eventProcessHistoryIDs_;
    if(metaDataTree->FindBranch(poolNames::eventHistoryBranchName().c_str()) != 0) {
      metaDataTree->SetBranchAddress(poolNames::eventHistoryBranchName().c_str(), &eventHistoryIDsPtr);
    }

    if(metaDataTree->FindBranch(poolNames::moduleDescriptionMapBranchName().c_str()) != 0) {
      if(metaDataTree->GetBranch(poolNames::moduleDescriptionMapBranchName().c_str())->GetSplitLevel() != 0) {
        metaDataTree->SetBranchStatus((poolNames::moduleDescriptionMapBranchName() + ".*").c_str(), 0);
      } else {
        metaDataTree->SetBranchStatus(poolNames::moduleDescriptionMapBranchName().c_str(), 0);
      }
    }

    // Here we read the metadata tree
    roottree::getEntry(metaDataTree.get(), 0);

    checkReleaseVersion();

    eventProcessHistoryIter_ = eventProcessHistoryIDs_.begin();

    // Here we read the event history tree, if we have one.
    readEventHistoryTree();

    ParameterSetConverter::ParameterSetIdConverter psetIdConverter;
    if(!fileFormatVersion().triggerPathsTracked()) {
      ParameterSetConverter converter(psetMap, psetIdConverter, fileFormatVersion().parameterSetsByReference());
    } else {
      // Merge into the parameter set registry.
      pset::Registry& psetRegistry = *pset::Registry::instance();
      for(PsetMap::const_iterator i = psetMap.begin(), iEnd = psetMap.end(); i != iEnd; ++i) {
        ParameterSet pset(i->second.pset());
        pset.setID(i->first);
        psetRegistry.insertMapped(pset);
      }
    }
    if(!fileFormatVersion().splitProductIDs()) {
      // Old provenance format input file.  Create a provenance adaptor.
      provenanceAdaptor_.reset(new ProvenanceAdaptor(
            inputProdDescReg, pHistMap, pHistVector, processConfigurations_, psetIdConverter, true));
      // Fill in the branchIDLists branch from the provenance adaptor
      branchIDLists_ = provenanceAdaptor_->branchIDLists();
    } else {
      if(!fileFormatVersion().triggerPathsTracked()) {
        // New provenance format, but change in ParameterSet Format. Create a provenance adaptor.
        provenanceAdaptor_.reset(new ProvenanceAdaptor(
            inputProdDescReg, pHistMap, pHistVector, processConfigurations_, psetIdConverter, false));
      }
      // New provenance format input file. The branchIDLists branch was read directly from the input file.
      if(metaDataTree->FindBranch(poolNames::branchIDListBranchName().c_str()) == 0) {
        throw Exception(errors::EventCorruption)
          << "Failed to find branchIDLists branch in metaData tree.\n";
      }
      branchIDLists_.reset(branchIDListsAPtr.release());
    }

    if(labelRawDataLikeMC) {
      std::string const rawData("FEDRawDataCollection");
      std::string const source("source");
      ProductRegistry::ProductList& pList = inputProdDescReg.productListUpdator();
      BranchKey finder(rawData, source, "", "");
      ProductRegistry::ProductList::iterator it = pList.lower_bound(finder);
      if(it != pList.end() && it->first.friendlyClassName_ == rawData && it->first.moduleLabel_ == source) {
        // We found raw data with a module label of source.
        // We need to change the module label and process name.
        // Create helper.
        it->second.init();
        daqProvenanceHelper_.reset(new DaqProvenanceHelper(it->second.typeID()));
        // Create the new branch description
        BranchDescription const& newBD = daqProvenanceHelper_->constBranchDescription_.me();
        // Save info from the old and new branch descriptions
        daqProvenanceHelper_->saveInfo(it->second, newBD);
        // Map the new branch name to the old branch name.
        it->second.init();
        newBranchToOldBranch_.insert(std::make_pair(newBD.branchName(), it->second.branchName()));
        // Remove the old branch description from the product Registry.
        pList.erase(it);
        // Check that there was only one.
        it = pList.lower_bound(finder);
        assert(!(it != pList.end() && it->first.friendlyClassName_ == rawData && it->first.moduleLabel_ == source));
        // Insert the new branch description into the product registry.
        inputProdDescReg.copyProduct(newBD);
        // Fix up other per file metadata.
        daqProvenanceHelper_->fixMetaData(processConfigurations_);
        daqProvenanceHelper_->fixMetaData(pHistVector);
        daqProvenanceHelper_->fixMetaData(*branchIDLists_);
        daqProvenanceHelper_->fixMetaData(*branchChildren_);
      }
    }

    ProcessHistoryRegistry::instance()->insertCollection(pHistVector);
    ProcessConfigurationRegistry::instance()->insertCollection(processConfigurations_);

    eventTree_.trainCache(BranchTypeToAuxiliaryBranchName(InEvent).c_str());

    validateFile(inputType, usingGoToEvent);

    // Read the parentage tree.  Old format files are handled internally in readParentageTree().
    readParentageTree();

    // Merge into the hashed registries.
    if(eventSkipperByID_ && eventSkipperByID_->somethingToSkip()) {
      whyNotFastClonable_ += FileBlock::EventsOrLumisSelectedByID;
    }

    initializeDuplicateChecker(indexesIntoFiles, currentIndexIntoFile);
    indexIntoFileIter_ = indexIntoFileBegin_ = indexIntoFile_.begin(noEventSort ? IndexIntoFile::firstAppearanceOrder : IndexIntoFile::numericalOrder);
    indexIntoFileEnd_ = indexIntoFile_.end(noEventSort ? IndexIntoFile::firstAppearanceOrder : IndexIntoFile::numericalOrder);
    forcedRunOffset_ = forcedRunOffset(forcedRunNumber, indexIntoFileBegin_, indexIntoFileEnd_);
    eventProcessHistoryIter_ = eventProcessHistoryIDs_.begin();

    // Set product presence information in the product registry.
    ProductRegistry::ProductList const& pList = inputProdDescReg.productList();
    for(ProductRegistry::ProductList::const_iterator it = pList.begin(), itEnd = pList.end();
        it != itEnd; ++it) {
      BranchDescription const& prod = it->second;
      prod.init();
      treePointers_[prod.branchType()]->setPresence(prod, newBranchToOldBranch(prod.branchName()));
    }

    fillProductRegistryTransients(processConfigurations_, inputProdDescReg);

    std::unique_ptr<ProductRegistry> newReg(new ProductRegistry);

    // Do the translation from the old registry to the new one
    {
      ProductRegistry::ProductList const& prodList = inputProdDescReg.productList();
      for(ProductRegistry::ProductList::const_iterator it = prodList.begin(), itEnd = prodList.end();
           it != itEnd; ++it) {
        BranchDescription const& prod = it->second;
        std::string newFriendlyName = friendlyname::friendlyName(prod.className());
        if(newFriendlyName == prod.friendlyClassName()) {
          newReg->copyProduct(prod);
        } else {
          if(fileFormatVersion().splitProductIDs()) {
            throw Exception(errors::UnimplementedFeature)
              << "Cannot change friendly class name algorithm without more development work\n"
              << "to update BranchIDLists.  Contact the framework group.\n";
          }
          BranchDescription newBD(prod);
          newBD.updateFriendlyClassName();
          newReg->copyProduct(newBD);
          newBranchToOldBranch_.insert(std::make_pair(newBD.branchName(), prod.branchName()));
        }
      }
      dropOnInput(*newReg, groupSelectorRules, dropDescendants, inputType);
      // freeze the product registry
      newReg->setFrozen(inputType != InputType::Primary);
      productRegistry_.reset(newReg.release());
    }

    // Here, we make the class that will make the ProvenanceReader
    provenanceReaderMaker_.reset(makeProvenanceReaderMaker().release());

    // Set up information from the product registry.
    ProductRegistry::ProductList const& prodList = productRegistry()->productList();
    for(ProductRegistry::ProductList::const_iterator it = prodList.begin(), itEnd = prodList.end();
        it != itEnd; ++it) {
      BranchDescription const& prod = it->second;
      treePointers_[prod.branchType()]->addBranch(it->first, prod,
                                                  newBranchToOldBranch(prod.branchName()));
    }

    // Event Principal cache for secondary input source
    if(inputType == InputType::SecondarySource) {
      secondaryEventPrincipal_.reset(new EventPrincipal(productRegistry(), processConfiguration));
    }

    // Determine if this file is fast clonable.
    setIfFastClonable(remainingEvents, remainingLumis);

    // Update the branch id info.
    if(inputType == InputType::Primary) {
      branchListIndexesUnchanged_ = BranchIDListHelper::updateFromInput(*branchIDLists_, file_);
    }

    setRefCoreStreamer(true);  // backward compatibility

    // We are done with our initial reading of EventAuxiliary.
    indexIntoFile_.doneFileInitialization();

    // Tell the event tree to begin training at the next read.
    eventTree_.resetTraining();

    // Train the run and lumi trees.
    runTree_.trainCache("*");
    lumiTree_.trainCache("*");
  }

  RootFile::~RootFile() {
  }
edm::RootFile::~RootFile ( )

Definition at line 482 of file RootFile.cc.

References fileFormatVersion().

                                     {
edm::RootFile::RootFile ( RootFile const &  )

Member Function Documentation

BranchIDListRegistry::collection_type const& edm::RootFile::branchIDLists ( ) [inline]

Definition at line 95 of file RootFile.h.

References branchIDLists_.

{return *branchIDLists_;}
bool edm::RootFile::branchListIndexesUnchanged ( ) const [inline]

Definition at line 107 of file RootFile.h.

References branchListIndexesUnchanged_.

void edm::RootFile::checkReleaseVersion ( ) [private]

Definition at line 1652 of file RootFile.cc.

References Exception, file(), edm::errors::FormatIncompatibility, edm::getReleaseVersion(), and edm::releaseversion::isEarlierRelease().

Referenced by RootFile().

                           {
      if(releaseversion::isEarlierRelease(currentRelease, it->releaseVersion())) {
        throw Exception(errors::FormatIncompatibility)
          << "The release you are using, " << getReleaseVersion() << " , predates\n"
          << "a release (" << it->releaseVersion() << ") used in writing the input file, " << file() <<".\n"
          << "Forward compatibility cannot be supported.\n";
      }
    }
  }

  void
  RootFile::initializeDuplicateChecker(
EventPrincipal * edm::RootFile::clearAndReadCurrentEvent ( EventPrincipal cache,
boost::shared_ptr< LuminosityBlockPrincipal lb = boost::shared_ptr<LuminosityBlockPrincipal>() 
)

Definition at line 1410 of file RootFile.cc.

                                                            {
void edm::RootFile::close ( void  )

Definition at line 1115 of file RootFile.cc.

                                                                                                             {
      (*it)->close();
      (*it) = 0;
    }
    filePtr_->Close();
    filePtr_.reset();
  }

  void
  RootFile::fillThisEventAuxiliary() {
boost::shared_ptr< FileBlock > edm::RootFile::createFileBlock ( ) const

Definition at line 624 of file RootFile.cc.

                                                                 {
void edm::RootFile::dropOnInput ( ProductRegistry reg,
GroupSelectorRules const &  rules,
bool  dropDescendants,
InputType::InputType  inputType 
) [private]

Definition at line 1683 of file RootFile.cc.

References branchChildren_, edm::BranchDescription::branchID(), and parseEventContent::prod.

Referenced by RootFile().

                           {
      BranchDescription const& prod = it->second;
      if(!groupSelector.selected(prod)) {
        if(dropDescendants) {
          branchChildren_->appendToDescendants(prod.branchID(), branchesToDrop);
        } else {
          branchesToDrop.insert(prod.branchID());
        }
      }
    }

    // On this pass, actually drop the branches.
    std::set<BranchID>::const_iterator branchesToDropEnd = branchesToDrop.end();
    for(ProductRegistry::ProductList::iterator it = prodList.begin(), itEnd = prodList.end(); it != itEnd;) {
      BranchDescription const& prod = it->second;
      bool drop = branchesToDrop.find(prod.branchID()) != branchesToDropEnd;
      if(drop) {
        if(groupSelector.selected(prod)) {
          LogWarning("RootFile")
            << "Branch '" << prod.branchName() << "' is being dropped from the input\n"
            << "of file '" << file_ << "' because it is dependent on a branch\n"
            << "that was explicitly dropped.\n";
        }
        treePointers_[prod.branchType()]->dropBranch(newBranchToOldBranch(prod.branchName()));
        hasNewlyDroppedBranch_[prod.branchType()] = true;
        ProductRegistry::ProductList::iterator icopy = it;
        ++it;
        prodList.erase(icopy);
      } else {
        ++it;
      }
    }

    // Drop on input mergeable run and lumi products, this needs to be invoked for secondary file input
    if(inputType == InputType::SecondaryFile) {
      TString tString;
      for(ProductRegistry::ProductList::iterator it = prodList.begin(), itEnd = prodList.end(); it != itEnd;) {
        BranchDescription const& prod = it->second;
        if(prod.branchType() != InEvent) {
          TClass *cp = gROOT->GetClass(prod.wrappedName().c_str());
          WrapperOwningHolder edp(cp->New(), prod.getInterface());
          if(edp.isMergeable()) {
            treePointers_[prod.branchType()]->dropBranch(newBranchToOldBranch(prod.branchName()));
            ProductRegistry::ProductList::iterator icopy = it;
            ++it;
            prodList.erase(icopy);
          } else {
            ++it;
          }
        }
        else ++it;
      }
    }
  }

  std::unique_ptr<MakeProvenanceReader>
  RootFile::makeProvenanceReaderMaker() const {
EventAuxiliary const& edm::RootFile::eventAux ( ) const [inline]
EventID const& edm::RootFile::eventID ( ) const [inline]

Definition at line 100 of file RootFile.h.

References eventAux(), and edm::EventAuxiliary::id().

{return eventAux().id();}
RootTree const& edm::RootFile::eventTree ( ) const [inline]

Definition at line 101 of file RootFile.h.

References eventTree_.

{return eventTree_;}
std::string const& edm::RootFile::file ( ) const [inline]

Definition at line 93 of file RootFile.h.

References file_.

Referenced by checkReleaseVersion().

{return file_;}
FileFormatVersion edm::RootFile::fileFormatVersion ( ) const [inline]

Definition at line 104 of file RootFile.h.

References fileFormatVersion_.

Referenced by RootFile(), and ~RootFile().

void edm::RootFile::fillEventAuxiliary ( ) [private]

Definition at line 1146 of file RootFile.cc.

                        {
void edm::RootFile::fillHistory ( ) [private]

Definition at line 1152 of file RootFile.cc.

References event(), eventAux(), eventAux_, eventProcessHistoryIDs_, eventProcessHistoryIter_, errorMatrix2Lands_multiChannel::id, edm::lower_bound_all(), DTTTrigCorrFirst::run, edm::EventAuxiliary::setProcessHistoryID(), and filterCSVwithJSON::target.

                                                 {
      // Lumi block number was not in EventID for the relevant releases.
      EventID id(eventAux().id().run(), 0, eventAux().id().event());
      if(eventProcessHistoryIter_->eventID() != id) {
        EventProcessHistoryID target(id, ProcessHistoryID());
        eventProcessHistoryIter_ = lower_bound_all(eventProcessHistoryIDs_, target);
        assert(eventProcessHistoryIter_->eventID() == id);
      }
      eventAux_.setProcessHistoryID(eventProcessHistoryIter_->processHistoryID());
      ++eventProcessHistoryIter_;
    } else if(fileFormatVersion().eventHistoryTree()) {
      // for backward compatibility.
      History* pHistory = history_.get();
      TBranch* eventHistoryBranch = eventHistoryTree_->GetBranch(poolNames::eventHistoryBranchName().c_str());
      if(!eventHistoryBranch) {
        throw Exception(errors::EventCorruption)
          << "Failed to find history branch in event history tree.\n";
      }
      eventHistoryBranch->SetAddress(&pHistory);
      roottree::getEntry(eventHistoryTree_, eventTree_.entryNumber());
      eventAux_.setProcessHistoryID(history_->processHistoryID());
      eventSelectionIDs_.reset(&history_->eventSelectionIDs(), do_nothing_deleter());
      branchListIndexes_.reset(&history_->branchListIndexes(), do_nothing_deleter());
    } else if(fileFormatVersion().noMetaDataTrees()) {
      // Current format
      EventSelectionIDVector* pESV = eventSelectionIDs_.get();
      TBranch* eventSelectionIDBranch = eventTree_.tree()->GetBranch(poolNames::eventSelectionsBranchName().c_str());
      assert(eventSelectionIDBranch != 0);
      eventTree_.fillBranchEntry(eventSelectionIDBranch, pESV);
      BranchListIndexes* pBLI = branchListIndexes_.get();
      TBranch* branchListIndexesBranch = eventTree_.tree()->GetBranch(poolNames::branchListIndexesBranchName().c_str());
      assert(branchListIndexesBranch != 0);
      eventTree_.fillBranchEntry(branchListIndexesBranch, pBLI);
    }
    if(provenanceAdaptor_) {
      eventAux_.setProcessHistoryID(provenanceAdaptor_->convertID(eventAux().processHistoryID()));
      for(EventSelectionIDVector::iterator i = eventSelectionIDs_->begin(), e = eventSelectionIDs_->end(); i != e; ++i) {
        (*i) = provenanceAdaptor_->convertID(*i);
      }
    }
    if(daqProvenanceHelper_) {
      eventAux_.setProcessHistoryID(daqProvenanceHelper_->mapProcessHistoryID(eventAux_.processHistoryID()));
    }
    if(!fileFormatVersion().splitProductIDs()) {
      // old format.  branchListIndexes_ must be filled in from the ProvenanceAdaptor.
      provenanceAdaptor_->branchListIndexes(*branchListIndexes_);
    }
    BranchIDListHelper::fixBranchListIndexes(*branchListIndexes_);
  }

  boost::shared_ptr<LuminosityBlockAuxiliary>
  RootFile::fillLumiAuxiliary() {
void edm::RootFile::fillIndexIntoFile ( ) [private]

Definition at line 826 of file RootFile.cc.

                             {
      bool newRun = false;
      bool newLumi = false;
      fillThisEventAuxiliary();
      fillHistory();

      // Save the event numbers as we loop through the event auxiliary to avoid
      // having to read through the event auxiliary again later. These event numbers
      // are not actually used in this function, but could be needed elsewhere.
      indexIntoFile_.unsortedEventNumbers().push_back(eventAux().event());

      ProcessHistoryID reducedPHID = ProcessHistoryRegistry::instance()->extra().reduceProcessHistoryID(eventAux().processHistoryID());

      if(iFirst || prevPhid != reducedPHID || prevRun != eventAux().run()) {
        iFirst = false;
        newRun = newLumi = true;
      } else if(prevLumi != eventAux().luminosityBlock()) {
        newLumi = true;
      }
      prevPhid = reducedPHID;
      prevRun = eventAux().run();
      prevLumi = eventAux().luminosityBlock();
      if(newLumi) {
        lumis.emplace_back(reducedPHID,
          eventAux().run(), eventAux().luminosityBlock(), eventTree_.entryNumber()); // (insert 1)
        runLumiSet.insert(LuminosityBlockID(eventAux().run(), eventAux().luminosityBlock())); // (insert 2)
      } else {
        LumiItem& currentLumi = lumis.back();
        assert(currentLumi.lastEventEntry_ == eventTree_.entryNumber());
        ++currentLumi.lastEventEntry_;
      }
      if(newRun) {
        // Insert run in list if it is not already there.
        RunItem item(reducedPHID, eventAux().run());
        if(runItemSet.insert(item).second) { // (check 3, insert 3)
          runs.push_back(std::move(item)); // (insert 5)
          runSet.insert(eventAux().run()); // (insert 4)
          phidMap.insert(std::make_pair(eventAux().run(), reducedPHID));
        }
      }
    }
    // now clean up.
    eventTree_.setEntryNumber(-1);
    eventAux_ = EventAuxiliary();
    lastEventEntryNumberRead_ = -1LL;

    // Loop over run entries and fill information.

    typedef std::map<RunNumber_t, EntryNumber_t> RunMap;
    RunMap runMap; // (declare 11)

    typedef std::vector<RunItem> RunVector;
    RunVector emptyRuns; // (declare 12)

    if(runTree_.isValid()) {
      while(runTree_.next()) {
        // Note: adjacent duplicates will be skipped without an explicit check.

        boost::shared_ptr<RunAuxiliary> runAux = fillRunAuxiliary();
        ProcessHistoryID reducedPHID = ProcessHistoryRegistry::instance()->extra().reduceProcessHistoryID(runAux->processHistoryID());

        if(runSet.insert(runAux->run()).second) { // (check 4, insert 4)
          // This run was not associated with any events.
          emptyRuns.emplace_back(reducedPHID, runAux->run()); // (insert 12)
        }
        runMap.insert(std::make_pair(runAux->run(), runTree_.entryNumber())); // (insert 11)
        phidMap.insert(std::make_pair(runAux->run(), reducedPHID));
      }
      // now clean up.
      runTree_.setEntryNumber(-1);
    }

    // Insert the ordered empty runs into the run list.
    RunItemSortByRun runItemSortByRun;
    stable_sort_all(emptyRuns, runItemSortByRun);

    RunList::iterator itRuns = runs.begin(), endRuns = runs.end();
    for(RunVector::const_iterator i = emptyRuns.begin(), iEnd = emptyRuns.end(); i != iEnd; ++i) {
      for(; itRuns != endRuns; ++itRuns) {
        if(runItemSortByRun(*i, *itRuns)) {
          break;
        }
      }
      runs.insert(itRuns, *i);
    }

    // Loop over luminosity block entries and fill information.

    typedef std::vector<LumiItem> LumiVector;
    LumiVector emptyLumis; // (declare 7)

    typedef std::map<LuminosityBlockID, EntryNumber_t> RunLumiMap;
    RunLumiMap runLumiMap; // (declare 6)

    if(lumiTree_.isValid()) {
      while(lumiTree_.next()) {
        // Note: adjacent duplicates will be skipped without an explicit check.
        boost::shared_ptr<LuminosityBlockAuxiliary> lumiAux = fillLumiAuxiliary();
        LuminosityBlockID lumiID = LuminosityBlockID(lumiAux->run(), lumiAux->luminosityBlock());
        if(runLumiSet.insert(lumiID).second) { // (check 2, insert 2)
          // This lumi was not associated with any events.
          // Use the process history ID from the corresponding run.  In cases of practical
          // importance, this should be the correct process history ID,  but it is possible
          // to construct files where this is not the correct process history ID ...
          PHIDMap::const_iterator iPhidMap = phidMap.find(lumiAux->run());
          assert(iPhidMap != phidMap.end());
          emptyLumis.emplace_back(iPhidMap->second, lumiAux->run(), lumiAux->luminosityBlock(), -1LL); // (insert 7)
        }
        runLumiMap.insert(std::make_pair(lumiID, lumiTree_.entryNumber()));
      }
      // now clean up.
      lumiTree_.setEntryNumber(-1);
    }

    // Insert the ordered empty lumis into the lumi list.
    LumiItemSortByRunLumi lumiItemSortByRunLumi;
    stable_sort_all(emptyLumis, lumiItemSortByRunLumi);

    LumiList::iterator itLumis = lumis.begin(), endLumis = lumis.end();
    for(LumiVector::const_iterator i = emptyLumis.begin(), iEnd = emptyLumis.end(); i != iEnd; ++i) {
      for(; itLumis != endLumis; ++itLumis) {
        if(lumiItemSortByRunLumi(*i, *itLumis)) {
          break;
        }
      }
      lumis.insert(itLumis, *i);
    }

    // Create a map of RunItems that gives the order of first appearance in the list.
    // Also fill in the vector of process history IDs
    typedef std::map<RunItem, int, RunItemSortByRunPhid> RunCountMap;
    RunCountMap runCountMap; // Declare (17)
    std::vector<ProcessHistoryID>& phids = indexIntoFile_.setProcessHistoryIDs();
    assert(phids.empty());
    std::vector<IndexIntoFile::RunOrLumiEntry>& entries = indexIntoFile_.setRunOrLumiEntries();
    assert(entries.empty());
    int rcount = 0;
    for(RunList::iterator it = runs.begin(), itEnd = runs.end(); it != itEnd; ++it) {
      RunCountMap::const_iterator countMapItem = runCountMap.find(*it);
      if(countMapItem == runCountMap.end()) {
        countMapItem = runCountMap.insert(std::make_pair(*it, rcount)).first; // Insert (17)
        assert(countMapItem != runCountMap.end());
        ++rcount;
      }
      std::vector<ProcessHistoryID>::const_iterator phidItem = find_in_all(phids, it->phid_);
      if(phidItem == phids.end()) {
        phids.push_back(it->phid_);
        phidItem = phids.end() - 1;
      }
      entries.emplace_back(
        countMapItem->second, // use (17)
        -1LL,
        runMap[it->run_], // use (11)
        phidItem - phids.begin(),
        it->run_,
        0U,
        -1LL,
        -1LL);
    }

    // Create a map of LumiItems that gives the order of first appearance in the list.
    typedef std::map<LumiItem, int, LumiItemSortByRunLumiPhid> LumiCountMap;
    LumiCountMap lumiCountMap; // Declare (19)
    int lcount = 0;
    for(LumiList::iterator it = lumis.begin(), itEnd = lumis.end(); it != itEnd; ++it) {
      RunCountMap::const_iterator runCountMapItem = runCountMap.find(RunItem(it->phid_, it->run_));
      assert(runCountMapItem != runCountMap.end());
      LumiCountMap::const_iterator countMapItem = lumiCountMap.find(*it);
      if(countMapItem == lumiCountMap.end()) {
        countMapItem = lumiCountMap.insert(std::make_pair(*it, lcount)).first; // Insert (17)
        assert(countMapItem != lumiCountMap.end());
        ++lcount;
      }
      std::vector<ProcessHistoryID>::const_iterator phidItem = find_in_all(phids, it->phid_);
      assert(phidItem != phids.end());
      entries.emplace_back(
        runCountMapItem->second,
        countMapItem->second,
        runLumiMap[LuminosityBlockID(it->run_, it->lumi_)],
        phidItem - phids.begin(),
        it->run_,
        it->lumi_,
        it->firstEventEntry_,
        it->lastEventEntry_);
    }
    stable_sort_all(entries);
  }

  void
  RootFile::validateFile(InputType::InputType inputType, bool usingGoToEvent) {
boost::shared_ptr< LuminosityBlockAuxiliary > edm::RootFile::fillLumiAuxiliary ( ) [private]

Definition at line 1208 of file RootFile.cc.

           {
      LuminosityBlockAux lumiAux;
      LuminosityBlockAux *pLumiAux = &lumiAux;
      lumiTree_.fillAux<LuminosityBlockAux>(pLumiAux);
      conversion(lumiAux, *lumiAuxiliary);
    }
    if(provenanceAdaptor_) {
      lumiAuxiliary->setProcessHistoryID(provenanceAdaptor_->convertID(lumiAuxiliary->processHistoryID()));
    }
    if(daqProvenanceHelper_) {
      lumiAuxiliary->setProcessHistoryID(daqProvenanceHelper_->mapProcessHistoryID(lumiAuxiliary->processHistoryID()));
    }
    if(lumiAuxiliary->luminosityBlock() == 0 && !fileFormatVersion().runsAndLumis()) {
      lumiAuxiliary->id() = LuminosityBlockID(RunNumber_t(1), LuminosityBlockNumber_t(1));
    }
    return lumiAuxiliary;
  }

  boost::shared_ptr<RunAuxiliary>
  RootFile::fillRunAuxiliary() {
boost::shared_ptr< RunAuxiliary > edm::RootFile::fillRunAuxiliary ( ) [private]

Definition at line 1232 of file RootFile.cc.

           {
      RunAux runAux;
      RunAux *pRunAux = &runAux;
      runTree_.fillAux<RunAux>(pRunAux);
      conversion(runAux, *runAuxiliary);
    }
    if(provenanceAdaptor_) {
      runAuxiliary->setProcessHistoryID(provenanceAdaptor_->convertID(runAuxiliary->processHistoryID()));
    }
    if(daqProvenanceHelper_) {
      runAuxiliary->setProcessHistoryID(daqProvenanceHelper_->mapProcessHistoryID(runAuxiliary->processHistoryID()));
    }
    return runAuxiliary;
  }

  bool
  RootFile::skipEvents(int& offset) {
void edm::RootFile::fillThisEventAuxiliary ( ) [private]

Definition at line 1127 of file RootFile.cc.

Referenced by initializeDuplicateChecker(), readLuminosityBlockAuxiliary_(), readRunAuxiliary_(), and skipEvents().

                                           {
      EventAuxiliary *pEvAux = &eventAux_;
      eventTree_.fillAux<EventAuxiliary>(pEvAux);
    } else {
      // for backward compatibility.
      EventAux eventAux;
      EventAux *pEvAux = &eventAux;
      eventTree_.fillAux<EventAux>(pEvAux);
      conversion(eventAux, eventAux_);
    }
    lastEventEntryNumberRead_ = eventTree_.entryNumber();
  }

  void
  RootFile::fillEventAuxiliary() {
IndexIntoFile::EntryType edm::RootFile::getEntryTypeWithSkipping ( ) [private]

Definition at line 704 of file RootFile.cc.

                                                                       {
        indexIntoFileIter_.advanceToNextLumiOrRun();
      }
      else {
        ++indexIntoFileIter_;
      }
    }
    return indexIntoFileIter_.getEntryType();
  }

  bool
  RootFile::isDuplicateEvent() {
IndexIntoFile::EntryType edm::RootFile::getNextEntryTypeWanted ( )

Definition at line 731 of file RootFile.cc.

bool edm::RootFile::goToEvent ( EventID const &  eventID)

Definition at line 1324 of file RootFile.cc.

References duplicateChecker_.

                          {
      duplicateChecker_->disable();
    }

    IndexIntoFile::SortOrder sortOrder = IndexIntoFile::numericalOrder;
    if(noEventSort_) sortOrder = IndexIntoFile::firstAppearanceOrder;

    IndexIntoFile::IndexIntoFileItr iter =
      indexIntoFile_.findPosition(sortOrder, eventID.run(), eventID.luminosityBlock(), eventID.event());

    if(iter == indexIntoFile_.end(sortOrder)) {
      return false;
    }
    indexIntoFileIter_ = iter;
    return true;
  }

  // readEvent() is responsible for creating, and setting up, the
  // EventPrincipal.
std::array<bool, NumBranchTypes> const& edm::RootFile::hasNewlyDroppedBranch ( ) const [inline]

Definition at line 106 of file RootFile.h.

References hasNewlyDroppedBranch_.

IndexIntoFile::IndexIntoFileItr edm::RootFile::indexIntoFileIter ( ) const
boost::shared_ptr<IndexIntoFile> edm::RootFile::indexIntoFileSharedPtr ( ) const [inline]

Definition at line 133 of file RootFile.h.

References indexIntoFileSharedPtr_.

void edm::RootFile::initializeDuplicateChecker ( std::vector< boost::shared_ptr< IndexIntoFile > > const &  indexesIntoFiles,
std::vector< boost::shared_ptr< IndexIntoFile > >::size_type  currentIndexIntoFile 
) [private]

Definition at line 1667 of file RootFile.cc.

References duplicateChecker_, eventAux(), eventTree_, fillThisEventAuxiliary(), indexIntoFile_, edm::RootTree::next(), and edm::RootTree::setEntryNumber().

Referenced by RootFile().

                          {
      if(eventTree_.next()) {
        fillThisEventAuxiliary();
        duplicateChecker_->inputFileOpened(eventAux().isRealData(),
                                           indexIntoFile_,
                                           indexesIntoFiles,
                                           currentIndexIntoFile);
      }
      eventTree_.setEntryNumber(-1);
    }
  }

  void
  RootFile::dropOnInput (ProductRegistry& reg, GroupSelectorRules const& rules, bool dropDescendants, InputType::InputType inputType) {
bool edm::RootFile::isDuplicateEvent ( ) [private]

Definition at line 720 of file RootFile.cc.

                                   {
RootTree const& edm::RootFile::lumiTree ( ) const [inline]

Definition at line 102 of file RootFile.h.

References lumiTree_.

{return lumiTree_;}
boost::shared_ptr< BranchMapper > edm::RootFile::makeBranchMapper ( ) [private]

Definition at line 1761 of file RootFile.cc.

                                : public ProvenanceReaderBase {
  public:
std::unique_ptr< MakeProvenanceReader > edm::RootFile::makeProvenanceReaderMaker ( ) const [private]

Definition at line 1748 of file RootFile.cc.

Referenced by RootFile().

                                                    {
      return std::unique_ptr<MakeProvenanceReader>(new MakeFullProvenanceReader);
    } else if(fileFormatVersion_.perEventProductIDs()) {
      return std::unique_ptr<MakeProvenanceReader>(new MakeOldProvenanceReader);
    } else {
      return std::unique_ptr<MakeProvenanceReader>(new MakeDummyProvenanceReader);
    }
  }

  boost::shared_ptr<BranchMapper>
  RootFile::makeBranchMapper() {
bool edm::RootFile::modifiedIDs ( ) const [inline]

Definition at line 108 of file RootFile.h.

References daqProvenanceHelper_.

{return daqProvenanceHelper_.get() != 0;}
std::string const & edm::RootFile::newBranchToOldBranch ( std::string const &  newBranch) const [private]

Definition at line 641 of file RootFile.cc.

Referenced by RootFile().

                                    {
bool edm::RootFile::nextEventEntry ( ) [inline]

Definition at line 131 of file RootFile.h.

References eventTree_, and edm::RootTree::next().

{return eventTree_.next();}
RootFile& edm::RootFile::operator= ( RootFile const &  )
void edm::RootFile::overrideRunNumber ( RunID id) [private]

Definition at line 1608 of file RootFile.cc.

Referenced by readLuminosityBlockAuxiliary_(), and readRunAuxiliary_().

                                                   {
void edm::RootFile::overrideRunNumber ( EventID id,
bool  isRealData 
) [private]

Definition at line 1624 of file RootFile.cc.

                                               {
      id = EventID(RunID::firstValidRun().run(), LuminosityBlockID::firstValidLuminosityBlock().luminosityBlock(), id.event());
    }
  }


  void
void edm::RootFile::overrideRunNumber ( LuminosityBlockID id) [private]

Definition at line 1616 of file RootFile.cc.

                                                          {
boost::shared_ptr<ProductRegistry const> edm::RootFile::productRegistry ( ) const [inline]

Definition at line 94 of file RootFile.h.

References productRegistry_.

Referenced by RootFile().

{return productRegistry_;}
EventPrincipal * edm::RootFile::readCurrentEvent ( EventPrincipal cache,
boost::shared_ptr< LuminosityBlockPrincipal lb = boost::shared_ptr<LuminosityBlockPrincipal>() 
)

Definition at line 1382 of file RootFile.cc.

                                             {
        //ugly, but will disappear when the backward compatibility is done with schema evolution.
        const_cast<EventID&>(eventAux_.id()).setLuminosityBlockNumber(eventAux_.oldLuminosityBlock());
        eventAux_.resetObsoleteInfo();
    }
    fillHistory();
    overrideRunNumber(eventAux_.id(), eventAux().isRealData());

    // We're not done ... so prepare the EventPrincipal
    cache.fillEventPrincipal(eventAux(),
                             lb,
                             eventSelectionIDs_,
                             branchListIndexes_,
                             makeBranchMapper(),
                             eventTree_.rootDelayedReader());

    // report event read from file
    filePtr_->eventReadFromFile(eventID().run(), eventID().event());
    return &cache;
  }

  EventPrincipal*
  RootFile::clearAndReadCurrentEvent(EventPrincipal& cache,
void edm::RootFile::readEntryDescriptionTree ( ) [private]

Definition at line 486 of file RootFile.cc.

References edm::poolNames::entryDescriptionTreeName(), Exception, and edm::errors::FileReadError.

                                        {
      throw Exception(errors::FileReadError) << "Could not find tree " << poolNames::entryDescriptionTreeName()
                                             << " in the input file.\n";
    }

    EntryDescriptionID idBuffer;
    EntryDescriptionID* pidBuffer = &idBuffer;
    entryDescriptionTree->SetBranchAddress(poolNames::entryDescriptionIDBranchName().c_str(), &pidBuffer);

    EntryDescriptionRegistry& oldregistry = *EntryDescriptionRegistry::instance();

    EventEntryDescription entryDescriptionBuffer;
    EventEntryDescription *pEntryDescriptionBuffer = &entryDescriptionBuffer;
    entryDescriptionTree->SetBranchAddress(poolNames::entryDescriptionBranchName().c_str(), &pEntryDescriptionBuffer);

    // Fill in the parentage registry.
    ParentageRegistry& registry = *ParentageRegistry::instance();

    for(Long64_t i = 0, numEntries = entryDescriptionTree->GetEntries(); i < numEntries; ++i) {
      roottree::getEntry(entryDescriptionTree.get(), i);
      if(idBuffer != entryDescriptionBuffer.id()) {
        throw Exception(errors::EventCorruption) << "Corruption of EntryDescription tree detected.\n";
      }
      oldregistry.insertMapped(entryDescriptionBuffer);
      Parentage parents;
      parents.parents() = entryDescriptionBuffer.parents();
      if(daqProvenanceHelper_) {
        ParentageID const oldID = parents.id();
        daqProvenanceHelper_->fixMetaData(parents.parents());
        ParentageID newID = parents.id();
        if(newID != oldID) {
          daqProvenanceHelper_->parentageIDMap_.insert(std::make_pair(oldID, newID));
        }
      }
      registry.insertMapped(parents);
    }
    entryDescriptionTree->SetBranchAddress(poolNames::entryDescriptionIDBranchName().c_str(), 0);
    entryDescriptionTree->SetBranchAddress(poolNames::entryDescriptionBranchName().c_str(), 0);
  }

  void
  RootFile::readParentageTree() {
EventPrincipal * edm::RootFile::readEvent ( EventPrincipal cache,
boost::shared_ptr< LuminosityBlockPrincipal lb = boost::shared_ptr<LuminosityBlockPrincipal>() 
)

Definition at line 1359 of file RootFile.cc.

                                                                                                                                                         : eventAux().processHistoryID());
    ProcessHistoryID const& reducedPHID = ProcessHistoryRegistry::instance()->extra().reduceProcessHistoryID(idToCheck);
    assert(reducedPHID == indexIntoFile_.processHistoryID(indexIntoFileIter_.processHistoryIDIndex()));

    ++indexIntoFileIter_;
    return ep;
  }

  // Reads event at the current entry in the event tree
  EventPrincipal*
void edm::RootFile::readEventHistoryTree ( ) [private]

Definition at line 1639 of file RootFile.cc.

References edm::errors::EventCorruption, and Exception.

Referenced by RootFile().

                             {
        throw Exception(errors::EventCorruption)
          << "Failed to find the event history tree.\n";
      }
    }
  }

  void
  RootFile::checkReleaseVersion() {
boost::shared_ptr< LuminosityBlockPrincipal > edm::RootFile::readLumi ( boost::shared_ptr< LuminosityBlockPrincipal lbCache)

Definition at line 1553 of file RootFile.cc.

References indexIntoFileIter_.

                             {
      ++indexIntoFileIter_;
      return lbCache;
    }
    // End code for backward compatibility before the existence of lumi trees.
    lumiTree_.setEntryNumber(indexIntoFileIter_.entry());
    lbCache->fillLuminosityBlockPrincipal(lumiTree_.rootDelayedReader());
    // Read in all the products now.
    lbCache->readImmediate();
    ++indexIntoFileIter_;
    return lbCache;
  }

  bool
  RootFile::setEntryAtEvent(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) {
boost::shared_ptr< LuminosityBlockAuxiliary > edm::RootFile::readLuminosityBlockAuxiliary_ ( )

Definition at line 1509 of file RootFile.cc.

References edm::RootTree::current(), edm::RootTree::entryNumber(), eventAux(), eventTree_, fillThisEventAuxiliary(), edm::IndexIntoFile::IndexIntoFileItr::firstEventEntryThisLumi(), indexIntoFileIter_, edm::IndexIntoFile::invalidEntry, edm::Timestamp::invalidTimestamp(), edm::IndexIntoFile::IndexIntoFileItr::lumi(), edm::LuminosityBlockID::luminosityBlock(), overrideRunNumber(), edm::LuminosityBlockID::run(), edm::IndexIntoFile::IndexIntoFileItr::run(), edm::RootTree::setEntryNumber(), and edm::EventAuxiliary::time().

                             {
      IndexIntoFile::EntryNumber_t eventEntry = indexIntoFileIter_.firstEventEntryThisLumi();
      assert(eventEntry != IndexIntoFile::invalidEntry);
      RootTree::EntryNumber savedEntry = eventTree_.entryNumber();
      eventTree_.setEntryNumber(eventEntry);
      assert(eventTree_.current());
      fillThisEventAuxiliary();
      eventTree_.setEntryNumber(savedEntry);

      LuminosityBlockID lumi = LuminosityBlockID(indexIntoFileIter_.run(), indexIntoFileIter_.lumi());
      overrideRunNumber(lumi);
      return boost::shared_ptr<LuminosityBlockAuxiliary>(new LuminosityBlockAuxiliary(lumi.run(), lumi.luminosityBlock(), eventAux().time(), Timestamp::invalidTimestamp()));
    }
    // End code for backward compatibility before the existence of lumi trees.
    lumiTree_.setEntryNumber(indexIntoFileIter_.entry());
    boost::shared_ptr<LuminosityBlockAuxiliary> lumiAuxiliary = fillLumiAuxiliary();
    assert(lumiAuxiliary->run() == indexIntoFileIter_.run());
    assert(lumiAuxiliary->luminosityBlock() == indexIntoFileIter_.lumi());
    overrideRunNumber(lumiAuxiliary->id());
    filePtr_->reportInputLumiSection(lumiAuxiliary->run(), lumiAuxiliary->luminosityBlock());
    if(lumiAuxiliary->beginTime() == Timestamp::invalidTimestamp()) {
      IndexIntoFile::EntryNumber_t eventEntry = indexIntoFileIter_.firstEventEntryThisLumi();
      if(eventEntry != IndexIntoFile::invalidEntry) {
        RootTree::EntryNumber savedEntry = eventTree_.entryNumber();
        eventTree_.setEntryNumber(eventEntry);
        assert(eventTree_.current());
        fillThisEventAuxiliary();
        eventTree_.setEntryNumber(savedEntry);

        lumiAuxiliary->setBeginTime(eventAux().time());
      }
      lumiAuxiliary->setEndTime(Timestamp::invalidTimestamp());
    }
    if(!fileFormatVersion().processHistorySameWithinRun() && savedRunAuxiliary_) {
      lumiAuxiliary->setProcessHistoryID(savedRunAuxiliary_->processHistoryID());
    }
    return lumiAuxiliary;
  }

  boost::shared_ptr<LuminosityBlockPrincipal>
  RootFile::readLumi(boost::shared_ptr<LuminosityBlockPrincipal> lbCache) {
void edm::RootFile::readParentageTree ( ) [private]

Definition at line 532 of file RootFile.cc.

Referenced by RootFile().

                                 {
      throw Exception(errors::FileReadError) << "Could not find tree " << poolNames::parentageTreeName()
                                             << " in the input file.\n";
    }

    Parentage parents;
    Parentage *pParentageBuffer = &parents;
    parentageTree->SetBranchAddress(poolNames::parentageBranchName().c_str(), &pParentageBuffer);

    ParentageRegistry& registry = *ParentageRegistry::instance();

    parentageIDLookup_.reserve(parentageTree->GetEntries());
    for(Long64_t i = 0, numEntries = parentageTree->GetEntries(); i < numEntries; ++i) {
      roottree::getEntry(parentageTree.get(), i);
      if(daqProvenanceHelper_) {
        ParentageID const oldID = parents.id();
        daqProvenanceHelper_->fixMetaData(parents.parents());
        ParentageID newID = parents.id();
        if(newID != oldID) {
          daqProvenanceHelper_->parentageIDMap_.insert(std::make_pair(oldID, newID));
        }
      }
      registry.insertMapped(parents);
      parentageIDLookup_.push_back(parents.id());
    }
    parentageTree->SetBranchAddress(poolNames::parentageBranchName().c_str(), 0);
  }

  void
  RootFile::setIfFastClonable(int remainingEvents, int remainingLumis) {
boost::shared_ptr< RunPrincipal > edm::RootFile::readRun_ ( boost::shared_ptr< RunPrincipal rpCache)

Definition at line 1492 of file RootFile.cc.

References indexIntoFileIter_.

                            {
      ++indexIntoFileIter_;
      return rpCache;
    }
    // End code for backward compatibility before the existence of run trees.
    rpCache->fillRunPrincipal(runTree_.rootDelayedReader());
    // Read in all the products now.
    rpCache->readImmediate();
    ++indexIntoFileIter_;
    return rpCache;
  }

  boost::shared_ptr<LuminosityBlockAuxiliary>
  RootFile::readLuminosityBlockAuxiliary_() {
boost::shared_ptr< RunAuxiliary > edm::RootFile::readRunAuxiliary_ ( )

Definition at line 1422 of file RootFile.cc.

References edm::RootTree::current(), edm::RootTree::entryNumber(), eventAux(), eventTree_, fillThisEventAuxiliary(), edm::IndexIntoFile::IndexIntoFileItr::firstEventEntryThisRun(), indexIntoFileIter_, edm::IndexIntoFile::invalidEntry, edm::Timestamp::invalidTimestamp(), overrideRunNumber(), edm::IndexIntoFile::IndexIntoFileItr::run(), edm::RunID::run(), edm::RootTree::setEntryNumber(), and edm::EventAuxiliary::time().

                            {

      // prior to the support of run trees.
      // RunAuxiliary did not contain a valid timestamp.  Take it from the next event.
      IndexIntoFile::EntryNumber_t eventEntry = indexIntoFileIter_.firstEventEntryThisRun();
      assert(eventEntry != IndexIntoFile::invalidEntry);
      RootTree::EntryNumber savedEntry = eventTree_.entryNumber();
      eventTree_.setEntryNumber(eventEntry);
      assert(eventTree_.current());
      fillThisEventAuxiliary();
      eventTree_.setEntryNumber(savedEntry);

      RunID run = RunID(indexIntoFileIter_.run());
      overrideRunNumber(run);
      return boost::shared_ptr<RunAuxiliary>(new RunAuxiliary(run.run(), eventAux().time(), Timestamp::invalidTimestamp()));
    }
    // End code for backward compatibility before the existence of run trees.
    runTree_.setEntryNumber(indexIntoFileIter_.entry());
    boost::shared_ptr<RunAuxiliary> runAuxiliary = fillRunAuxiliary();
    assert(runAuxiliary->run() == indexIntoFileIter_.run());
    overrideRunNumber(runAuxiliary->id());
    filePtr_->reportInputRunNumber(runAuxiliary->run());
    // If RunAuxiliary did not contain a valid begin timestamp, invalidate any end timestamp.
    if(runAuxiliary->beginTime() == Timestamp::invalidTimestamp()) {
      runAuxiliary->setEndTime(Timestamp::invalidTimestamp());
    }

    // If RunAuxiliary did not contain a valid timestamp, or if this an old format file from
    // when the Run's ProcessHistory included only processes where products were added to the Run itself,
    // we attempt to read the first event in the run to get appropriate info.
    if(runAuxiliary->beginTime() == Timestamp::invalidTimestamp() ||
       !fileFormatVersion().processHistorySameWithinRun()) {

      IndexIntoFile::EntryNumber_t eventEntry = indexIntoFileIter_.firstEventEntryThisRun();
      // If we have a valid event, use its information.
      if(eventEntry != IndexIntoFile::invalidEntry) {
        RootTree::EntryNumber savedEntry = eventTree_.entryNumber();
        eventTree_.setEntryNumber(eventEntry);
        assert(eventTree_.current());
        fillThisEventAuxiliary();

        // RunAuxiliary did not contain a valid timestamp.  Take it from the next event in this run if there is one.
        if(runAuxiliary->beginTime() == Timestamp::invalidTimestamp()) {
          runAuxiliary->setBeginTime(eventAux().time());
        }

        // For backwards compatibility when the Run's ProcessHistory included only processes where products were added to the
        // Run, and then the Run and Event auxiliaries could be different.  Use the event ProcessHistoryID if there is one. It should
        // almost always be correct by the current definition (processes included if any products are added. This makes the run, lumi,
        // and event ProcessHistory's always be the same if no file merging occurs).
        if(!fileFormatVersion().processHistorySameWithinRun()) {
          fillHistory();
          runAuxiliary->setProcessHistoryID(eventAux().processHistoryID());
          savedRunAuxiliary_ = runAuxiliary;
        }
        eventTree_.setEntryNumber(savedEntry);
      } else {
        // No valid event, just use what is there, because it is the best we can do.
        savedRunAuxiliary_ = runAuxiliary;
      }
    }
    return runAuxiliary;
  }

  boost::shared_ptr<RunPrincipal>
  RootFile::readRun_(boost::shared_ptr<RunPrincipal> rpCache) {
void edm::RootFile::reportOpened ( std::string const &  inputType)

Definition at line 1101 of file RootFile.cc.

                  {
void edm::RootFile::rewind ( ) [inline]
RootTree const& edm::RootFile::runTree ( ) const [inline]

Definition at line 103 of file RootFile.h.

References runTree_.

{return runTree_;}
EventPrincipal& edm::RootFile::secondaryEventPrincipal ( ) [inline]

Definition at line 140 of file RootFile.h.

References secondaryEventPrincipal_.

void edm::RootFile::setAtEventEntry ( IndexIntoFile::EntryNumber_t  entry)
bool edm::RootFile::setEntryAtEvent ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
)

Definition at line 1571 of file RootFile.cc.

Referenced by setEntryAtItem().

                                                                        {
bool edm::RootFile::setEntryAtItem ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) [inline]

Definition at line 110 of file RootFile.h.

References setEntryAtEvent(), setEntryAtLumi(), and setEntryAtRun().

bool edm::RootFile::setEntryAtLumi ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
)

Definition at line 1579 of file RootFile.cc.

Referenced by setEntryAtItem().

                                         {
bool edm::RootFile::setEntryAtNextEventInLumi ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi 
)

Definition at line 1595 of file RootFile.cc.

                                       {
bool edm::RootFile::setEntryAtRun ( RunNumber_t  run)

Definition at line 1587 of file RootFile.cc.

Referenced by setEntryAtItem().

                                                                                   {
void edm::RootFile::setIfFastClonable ( int  remainingEvents,
int  remainingLumis 
) [private]

Definition at line 570 of file RootFile.cc.

Referenced by RootFile().

                                               {
      whyNotFastClonable_ += FileBlock::FileTooOld;
      return;
    }
    if(processingMode_ != InputSource::RunsLumisAndEvents) {
      whyNotFastClonable_ += FileBlock::NotProcessingEvents;
      return;
    }
    // Find entry for first event in file
    IndexIntoFile::IndexIntoFileItr it = indexIntoFileBegin_;
    while(it != indexIntoFileEnd_ && it.getEntryType() != IndexIntoFile::kEvent) {
      ++it;
    }
    if(it == indexIntoFileEnd_) {
      whyNotFastClonable_ += FileBlock::NoEventsInFile;
      return;
    }

    // From here on, record all reasons we can't fast clone.
    IndexIntoFile::SortOrder sortOrder = (noEventSort_ ? IndexIntoFile::firstAppearanceOrder : IndexIntoFile::numericalOrder);
    if(!indexIntoFile_.iterationWillBeInEntryOrder(sortOrder)) {
      whyNotFastClonable_ += (noEventSort_ ? FileBlock::RunOrLumiNotContiguous : FileBlock::EventsToBeSorted);
    }
    if(skipAnyEvents_) {
      whyNotFastClonable_ += FileBlock::InitialEventsSkipped;
    }
    if(remainingEvents >= 0 && eventTree_.entries() > remainingEvents) {
      whyNotFastClonable_ += FileBlock::MaxEventsTooSmall;
    }
    if(remainingLumis >= 0 && lumiTree_.entries() > remainingLumis) {
      whyNotFastClonable_ += FileBlock::MaxLumisTooSmall;
    }
    // We no longer fast copy the EventAuxiliary branch, so there
    // is no longer any need to disable fast copying because the run
    // number is being modified.   Also, this check did not work anyway
    // because this function is called before forcedRunOffset_ is set.

    // if(forcedRunOffset_ != 0) {
    //   whyNotFastClonable_ += FileBlock::RunNumberModified;
    // }
    if(duplicateChecker_ &&
      !duplicateChecker_->checkDisabled() &&
      !duplicateChecker_->noDuplicatesInFile()) {
      whyNotFastClonable_ += FileBlock::DuplicateEventsRemoved;
    }
  }

  boost::shared_ptr<FileBlock>
  RootFile::createFileBlock() const {
void edm::RootFile::setPosition ( IndexIntoFile::IndexIntoFileItr const &  position)

Definition at line 655 of file RootFile.cc.

References indexIntoFileEnd_, and indexIntoFileIter_.

                          {
void edm::RootFile::setToLastEntry ( ) [inline]

Definition at line 125 of file RootFile.h.

References indexIntoFileEnd_, and indexIntoFileIter_.

bool edm::RootFile::skipEvents ( int &  offset)

Definition at line 1253 of file RootFile.cc.

References edm::EventID::event(), eventAux_, eventSkipperByID_, eventTree_, fillThisEventAuxiliary(), edm::EventAuxiliary::id(), and edm::RootTree::setEntryNumber().

                                                                    {
        eventTree_.setEntryNumber(skippedEventEntry);
        fillThisEventAuxiliary();
        if(eventSkipperByID_->skipIt(runOfSkippedEvent, lumiOfSkippedEvent, eventAux_.id().event())) {
            continue;
        }
      }
      if(duplicateChecker_ &&
         !duplicateChecker_->checkDisabled() &&
         !duplicateChecker_->noDuplicatesInFile()) {

        eventTree_.setEntryNumber(skippedEventEntry);
        fillThisEventAuxiliary();
        if(duplicateChecker_->isDuplicateAndCheckActive(phIndexOfSkippedEvent,
                                                         runOfSkippedEvent,
                                                         lumiOfSkippedEvent,
                                                         eventAux_.id().event(),
                                                         file_)) {
          continue;
        }
      }
      --offset;
    }

    while(offset < 0) {

      if(duplicateChecker_) {
        duplicateChecker_->disable();
      }

      int phIndexOfEvent = IndexIntoFile::invalidIndex;
      RunNumber_t runOfEvent =  IndexIntoFile::invalidRun;
      LuminosityBlockNumber_t lumiOfEvent = IndexIntoFile::invalidLumi;
      EntryNumber_t eventEntry = IndexIntoFile::invalidEntry;

      indexIntoFileIter_.skipEventBackward(phIndexOfEvent,
                                           runOfEvent,
                                           lumiOfEvent,
                                           eventEntry);

      if(eventEntry == IndexIntoFile::invalidEntry) break;

      if(eventSkipperByID_ && eventSkipperByID_->somethingToSkip()) {
        eventTree_.setEntryNumber(eventEntry);
        fillEventAuxiliary();
        if(eventSkipperByID_->skipIt(runOfEvent, lumiOfEvent, eventAux_.id().event())) {
          continue;
        }
      }
      ++offset;
    }
    return(indexIntoFileIter_ == indexIntoFileEnd_);
  }

  bool
  RootFile::goToEvent(EventID const& eventID) {
bool edm::RootFile::skipThisEntry ( ) [private]

Definition at line 660 of file RootFile.cc.

                                                                  {

      // See first if the entire lumi or run is skipped, so we won't have to read the event Auxiliary in that case.
      if(eventSkipperByID_->skipIt(indexIntoFileIter_.run(), indexIntoFileIter_.lumi(), 0U)) {
        return true;
      }

      // The Lumi is not skipped.  If this is an event, see if the event is skipped.
      if(indexIntoFileIter_.getEntryType() == IndexIntoFile::kEvent) {
        fillEventAuxiliary();
        if(eventSkipperByID_->skipIt(indexIntoFileIter_.run(),
                                      indexIntoFileIter_.lumi(),
                                      eventAux_.id().event())) {
          return true;
        }
      }

      // Skip runs with no lumis if either lumisToSkip or lumisToProcess have been set to select lumis
      if(indexIntoFileIter_.getEntryType() == IndexIntoFile::kRun &&
          eventSkipperByID_->skippingLumis()) {
        IndexIntoFile::IndexIntoFileItr iterLumi = indexIntoFileIter_;

        // There are no lumis in this run, not even ones we will skip
        if(iterLumi.peekAheadAtLumi() == IndexIntoFile::invalidLumi) {
          return true;
        }
        // If we get here there are lumis in the run, check to see if we are skipping all of them
        do {
          if(!eventSkipperByID_->skipIt(iterLumi.run(), iterLumi.peekAheadAtLumi(), 0U)) {
            return false;
          }
        }
        while(iterLumi.skipLumiInRun());
        return true;
      }
    }
    return false;
  }

  IndexIntoFile::EntryType
  RootFile::getEntryTypeWithSkipping() {
RootTreePtrArray& edm::RootFile::treePointers ( ) [inline, private]

Definition at line 146 of file RootFile.h.

References treePointers_.

{return treePointers_;}
void edm::RootFile::validateFile ( InputType::InputType  inputType,
bool  usingGoToEvent 
) [private]

Definition at line 1052 of file RootFile.cc.

Referenced by RootFile().

                              {
      throw Exception(errors::EventCorruption) <<
         "'Events' tree is corrupted or not present\n" << "in the input file.\n";
    }

    if(fileFormatVersion().hasIndexIntoFile()) {
      if(runTree().entries() > 0) {
        assert(!indexIntoFile_.empty());
      }
      if(!fileFormatVersion().useReducedProcessHistoryID()) {
        if(daqProvenanceHelper_) {
          std::vector<ProcessHistoryID>& phidVec = indexIntoFile_.setProcessHistoryIDs();
          for(std::vector<ProcessHistoryID>::iterator it = phidVec.begin(), itEnd = phidVec.end();
              it != itEnd;
              ++it) {
            *it = daqProvenanceHelper_->mapProcessHistoryID(*it);
          }
        }
        indexIntoFile_.reduceProcessHistoryIDs();
      }
    }
    else {
      assert(indexIntoFile_.empty());
      fillIndexIntoFile();
    }

    indexIntoFile_.fixIndexes(orderedProcessHistoryIDs_);
    indexIntoFile_.setNumberOfEvents(eventTree_.entries());
    indexIntoFile_.setEventFinder(boost::shared_ptr<IndexIntoFile::EventFinder>(new RootFileEventFinder(eventTree_)));
    // We fill the event numbers explicitly if we need to find events in closed files,
    // such as for secondary files (or secondary sources) or if duplicate checking across files.
    bool needEventNumbers = false;
    bool needIndexesForDuplicateChecker = duplicateChecker_ && duplicateChecker_->checkingAllFiles() && !duplicateChecker_->checkDisabled();
    if(inputType != InputType::Primary || needIndexesForDuplicateChecker || usingGoToEvent) {
      needEventNumbers = true;
    }
    bool needEventEntries = false;
    if(inputType != InputType::Primary || !noEventSort_) {
      // We need event entries for sorting or for secondary files or sources.
      needEventEntries = true;
    }
    indexIntoFile_.fillEventNumbersOrEntries(needEventNumbers, needEventEntries);
  }

  void
  RootFile::reportOpened(std::string const& inputType) {
bool edm::RootFile::wasFirstEventJustRead ( ) const

Definition at line 763 of file RootFile.cc.

            {
    typedef IndexIntoFile::EntryNumber_t  EntryNumber_t;
bool edm::RootFile::wasLastEventJustRead ( ) const

Definition at line 756 of file RootFile.cc.

                                        {
int edm::RootFile::whyNotFastClonable ( ) const [inline]

Definition at line 105 of file RootFile.h.

References whyNotFastClonable_.


Member Data Documentation

boost::shared_ptr<BranchChildren> edm::RootFile::branchChildren_ [private]

Definition at line 210 of file RootFile.h.

Referenced by dropOnInput(), and RootFile().

Definition at line 202 of file RootFile.h.

Referenced by branchIDLists(), and RootFile().

Definition at line 208 of file RootFile.h.

Definition at line 194 of file RootFile.h.

Referenced by branchListIndexesUnchanged(), and RootFile().

Definition at line 217 of file RootFile.h.

Referenced by modifiedIDs(), and RootFile().

boost::shared_ptr<DuplicateChecker> edm::RootFile::duplicateChecker_ [private]

Definition at line 211 of file RootFile.h.

Referenced by goToEvent(), and initializeDuplicateChecker().

Definition at line 195 of file RootFile.h.

Referenced by eventAux(), fillHistory(), and skipEvents().

boost::shared_ptr<BranchMapper> edm::RootFile::eventBranchMapper_ [mutable, private]

Definition at line 215 of file RootFile.h.

Definition at line 206 of file RootFile.h.

Definition at line 187 of file RootFile.h.

Referenced by fillHistory(), and RootFile().

std::vector<EventProcessHistoryID>::const_iterator edm::RootFile::eventProcessHistoryIter_ [private]

Definition at line 188 of file RootFile.h.

Referenced by fillHistory(), and RootFile().

Definition at line 207 of file RootFile.h.

boost::shared_ptr<EventSkipperByID> edm::RootFile::eventSkipperByID_ [private]

Definition at line 178 of file RootFile.h.

Referenced by RootFile(), and skipEvents().

Definition at line 180 of file RootFile.h.

Referenced by RootFile().

std::string const edm::RootFile::file_ [private]

Definition at line 173 of file RootFile.h.

Referenced by file(), and RootFile().

Definition at line 179 of file RootFile.h.

Referenced by fileFormatVersion(), and RootFile().

boost::shared_ptr<InputFile> edm::RootFile::filePtr_ [private]

Definition at line 177 of file RootFile.h.

Referenced by RootFile().

Definition at line 204 of file RootFile.h.

Referenced by RootFile().

std::array<bool, NumBranchTypes> edm::RootFile::hasNewlyDroppedBranch_ [private]

Definition at line 193 of file RootFile.h.

Referenced by hasNewlyDroppedBranch(), and RootFile().

std::unique_ptr<History> edm::RootFile::history_ [private]

Definition at line 209 of file RootFile.h.

Definition at line 182 of file RootFile.h.

Referenced by initializeDuplicateChecker(), and RootFile().

Definition at line 184 of file RootFile.h.

Referenced by rewind(), and RootFile().

Definition at line 185 of file RootFile.h.

Referenced by RootFile(), setAtEventEntry(), setPosition(), and setToLastEntry().

Definition at line 181 of file RootFile.h.

Referenced by indexIntoFileSharedPtr().

Definition at line 200 of file RootFile.h.

std::string const edm::RootFile::logicalFile_ [private]

Definition at line 174 of file RootFile.h.

Definition at line 197 of file RootFile.h.

Referenced by lumiTree(), rewind(), and RootFile().

std::map<std::string, std::string> edm::RootFile::newBranchToOldBranch_ [private]

Definition at line 205 of file RootFile.h.

Referenced by RootFile().

Definition at line 191 of file RootFile.h.

Definition at line 183 of file RootFile.h.

Definition at line 216 of file RootFile.h.

Definition at line 175 of file RootFile.h.

Definition at line 176 of file RootFile.h.

Referenced by RootFile().

Definition at line 203 of file RootFile.h.

boost::shared_ptr<ProductRegistry const> edm::RootFile::productRegistry_ [private]

Definition at line 201 of file RootFile.h.

Referenced by productRegistry(), and RootFile().

Definition at line 212 of file RootFile.h.

Referenced by RootFile().

Definition at line 213 of file RootFile.h.

Referenced by RootFile().

Definition at line 198 of file RootFile.h.

Referenced by rewind(), RootFile(), and runTree().

boost::shared_ptr<RunAuxiliary> edm::RootFile::savedRunAuxiliary_ [private]

Definition at line 189 of file RootFile.h.

std::unique_ptr<EventPrincipal> edm::RootFile::secondaryEventPrincipal_ [mutable, private]

Definition at line 214 of file RootFile.h.

Referenced by RootFile(), and secondaryEventPrincipal().

Definition at line 190 of file RootFile.h.

Definition at line 199 of file RootFile.h.

Referenced by RootFile(), and treePointers().

Definition at line 192 of file RootFile.h.

Referenced by RootFile(), and whyNotFastClonable().