#include <RootInputFileSequence.h>
Definition at line 39 of file RootInputFileSequence.h.
Definition at line 44 of file RootInputFileSequence.h.
typedef boost::shared_ptr<RootFile> edm::RootInputFileSequence::RootFileSharedPtr |
Definition at line 45 of file RootInputFileSequence.h.
edm::RootInputFileSequence::RootInputFileSequence | ( | ParameterSet const & | pset, |
PoolSource const & | input, | ||
InputFileCatalog const & | catalog, | ||
PrincipalCache & | cache, | ||
bool | primaryFiles | ||
) | [explicit] |
Definition at line 29 of file RootInputFileSequence.cc.
References StorageFactory::activateTimeout(), branchesMustMatch_, fileIter_, fileIterBegin_, fileIterEnd_, reco::get(), edm::ParameterSet::getUntrackedParameter(), initFile(), edm::Service< T >::isAvailable(), numberOfEventsToSkip_, parametersMustMatch_, primary(), primaryFiles_, productRegistryUpdate(), rootFile_, skipBadFiles_, skipEvents(), StorageFactory::stagein(), edm::BranchDescription::Strict, treeCacheSize_, and edm::ProductRegistry::updateFromInput().
: input_(input), catalog_(catalog), firstFile_(true), fileIterBegin_(fileCatalogItems().begin()), fileIterEnd_(fileCatalogItems().end()), fileIter_(fileIterEnd_), fileIterLastOpened_(fileIterEnd_), rootFile_(), parametersMustMatch_(BranchDescription::Permissive), branchesMustMatch_(BranchDescription::Permissive), flatDistribution_(), indexesIntoFiles_(fileCatalogItems().size()), orderedProcessHistoryIDs_(), eventSkipperByID_(primaryFiles ? EventSkipperByID::create(pset).release() : 0), eventsRemainingInFile_(0), // The default value provided as the second argument to the getUntrackedParameter function call // is not used when the ParameterSet has been validated and the parameters are not optional // in the description. This is currently true when PoolSource is the primary input source. // The modules that use PoolSource as a SecSource have not defined their fillDescriptions function // yet, so the ParameterSet does not get validated yet. As soon as all the modules with a SecSource // have defined descriptions, the defaults in the getUntrackedParameterSet function calls can // and should be deleted from the code. numberOfEventsToSkip_(primaryFiles ? pset.getUntrackedParameter<unsigned int>("skipEvents", 0U) : 0U), noEventSort_(primaryFiles ? pset.getUntrackedParameter<bool>("noEventSort", true) : false), skipBadFiles_(pset.getUntrackedParameter<bool>("skipBadFiles", false)), treeCacheSize_(noEventSort_ ? pset.getUntrackedParameter<unsigned int>("cacheSize", roottree::defaultCacheSize) : 0U), treeMaxVirtualSize_(pset.getUntrackedParameter<int>("treeMaxVirtualSize", -1)), setRun_(pset.getUntrackedParameter<unsigned int>("setRunNumber", 0U)), groupSelectorRules_(pset, "inputCommands", "InputSource"), primaryFiles_(primaryFiles), duplicateChecker_(primaryFiles ? new DuplicateChecker(pset) : 0), dropDescendants_(pset.getUntrackedParameter<bool>("dropDescendantsOfDroppedBranches", primary())), usingGoToEvent_(false) { //we now allow the site local config to specify what the TTree cache size should be Service<SiteLocalConfig> pSLC; if(treeCacheSize_ != 0U && pSLC.isAvailable() && pSLC->sourceTTreeCacheSize()) { treeCacheSize_ = *(pSLC->sourceTTreeCacheSize()); } if(primaryFiles_) { //NOTE: we do not want to stage in secondary files since we can be given a list of // thousands of files and prestaging all those files can cause a site to fail StorageFactory *factory = StorageFactory::get(); for(fileIter_ = fileIterBegin_; fileIter_ != fileIterEnd_; ++fileIter_) { factory->activateTimeout(fileIter_->fileName()); factory->stagein(fileIter_->fileName()); } } std::string parametersMustMatch = pset.getUntrackedParameter<std::string>("parametersMustMatch", std::string("permissive")); if(parametersMustMatch == std::string("strict")) parametersMustMatch_ = BranchDescription::Strict; std::string branchesMustMatch = pset.getUntrackedParameter<std::string>("branchesMustMatch", std::string("permissive")); if(branchesMustMatch == std::string("strict")) branchesMustMatch_ = BranchDescription::Strict; if(primary()) { for(fileIter_ = fileIterBegin_; fileIter_ != fileIterEnd_; ++fileIter_) { initFile(skipBadFiles_); if(rootFile_) break; } if(rootFile_) { productRegistryUpdate().updateFromInput(rootFile_->productRegistry()->productList()); if(numberOfEventsToSkip_ != 0) { skipEvents(numberOfEventsToSkip_, cache); } } } }
edm::RootInputFileSequence::~RootInputFileSequence | ( | ) | [virtual] |
Definition at line 317 of file RootInputFileSequence.cc.
{ }
void edm::RootInputFileSequence::closeFile_ | ( | ) |
Definition at line 134 of file RootInputFileSequence.cc.
References duplicateChecker_, input_, primary(), primaryFiles_, and rootFile_.
Referenced by endJob(), initFile(), and rewind_().
{ // close the currently open file, if any, and delete the RootFile object. if(rootFile_) { if (primary()) { std::auto_ptr<InputSource::FileCloseSentry> sentry((primaryFiles_) ? new InputSource::FileCloseSentry(input_) : 0); rootFile_->close(); if(duplicateChecker_) duplicateChecker_->inputFileClosed(); } rootFile_.reset(); } }
void edm::RootInputFileSequence::dropUnwantedBranches_ | ( | std::vector< std::string > const & | wantedBranches | ) |
Definition at line 565 of file RootInputFileSequence.cc.
References edm::ParameterSet::addUntrackedParameter(), groupSelectorRules_, MultipleCompare::pset, and cmsCodeRulesChecker::rules.
{ std::vector<std::string> rules; rules.reserve(wantedBranches.size() + 1); rules.push_back(std::string("drop *")); for(std::vector<std::string>::const_iterator it = wantedBranches.begin(), itEnd = wantedBranches.end(); it != itEnd; ++it) { rules.push_back("keep " + *it + "_*"); } ParameterSet pset; pset.addUntrackedParameter("inputCommands", rules); groupSelectorRules_ = GroupSelectorRules(pset, "inputCommands", "InputSource"); }
void edm::RootInputFileSequence::endJob | ( | void | ) |
std::vector< FileCatalogItem > const & edm::RootInputFileSequence::fileCatalogItems | ( | ) | const [private] |
Definition at line 106 of file RootInputFileSequence.cc.
References catalog_, and edm::InputFileCatalog::fileCatalogItems().
Referenced by readManyRandom().
{ return catalog_.fileCatalogItems(); }
boost::shared_ptr< ProductRegistry const > edm::RootInputFileSequence::fileProductRegistry | ( | ) | const |
Definition at line 252 of file RootInputFileSequence.cc.
References rootFile_.
{ return rootFile_->productRegistry(); }
void edm::RootInputFileSequence::fillDescription | ( | ParameterSetDescription & | desc | ) | [static] |
Definition at line 698 of file RootInputFileSequence.cc.
References edm::ParameterSetDescription::addUntracked(), and edm::roottree::defaultCacheSize.
{ desc.addUntracked<unsigned int>("skipEvents", 0U) ->setComment("Skip the first 'skipEvents' events that otherwise would have been processed."); desc.addUntracked<bool>("noEventSort", true) ->setComment("True: Process runs, lumis and events in the order they appear in the file (but see notes 1 and 2).\n" "False: Process runs, lumis and events in each file in numerical order (run#, lumi#, event#) (but see note 3).\n" "Note 1: Events within the same lumi will always be processed contiguously.\n" "Note 2: Lumis within the same run will always be processed contiguously.\n" "Note 3: Any sorting occurs independently in each input file (no sorting across input files)."); desc.addUntracked<bool>("skipBadFiles", false) ->setComment("True: Ignore any missing or unopenable input file.\n" "False: Throw exception if missing or unopenable input file."); desc.addUntracked<unsigned int>("cacheSize", roottree::defaultCacheSize) ->setComment("Size of ROOT TTree prefetch cache. Affects performance."); desc.addUntracked<int>("treeMaxVirtualSize", -1) ->setComment("Size of ROOT TTree TBasket cache. Affects performance."); desc.addUntracked<unsigned int>("setRunNumber", 0U) ->setComment("If non-zero, change number of first run to this number. Apply same offset to all runs. Allowed only for simulation."); desc.addUntracked<bool>("dropDescendantsOfDroppedBranches", true) ->setComment("If True, also drop on input any descendent of any branch dropped on input."); std::string defaultString("permissive"); desc.addUntracked<std::string>("parametersMustMatch", defaultString) ->setComment("'strict': Values of tracked parameters must be unique across all input files.\n" "'permissive': Values of tracked parameters may differ across or within files."); desc.addUntracked<std::string>("branchesMustMatch", defaultString) ->setComment("'strict': Branches in each input file must match those in the first file.\n" "'permissive': Branches in each input file may be any subset of those in the first file."); GroupSelectorRules::fillDescription(desc, "inputCommands"); EventSkipperByID::fillDescription(desc); DuplicateChecker::fillDescription(desc); }
ProcessingController::ForwardState edm::RootInputFileSequence::forwardState | ( | ) | const |
Definition at line 732 of file RootInputFileSequence.cc.
References fileIter_, fileIterEnd_, edm::ProcessingController::kAtLastEvent, edm::ProcessingController::kEventsAheadInFile, edm::ProcessingController::kNextFileExists, edm::ProcessingController::kUnknownForward, and rootFile_.
{ if (rootFile_) { if (!rootFile_->wasLastEventJustRead()) { return ProcessingController::kEventsAheadInFile; } std::vector<FileCatalogItem>::const_iterator itr(fileIter_); if (itr != fileIterEnd_) ++itr; if (itr != fileIterEnd_) { return ProcessingController::kNextFileExists; } return ProcessingController::kAtLastEvent; } return ProcessingController::kUnknownForward; }
InputSource::ItemType edm::RootInputFileSequence::getNextItemType | ( | ) |
Definition at line 361 of file RootInputFileSequence.cc.
References fileIter_, fileIterEnd_, firstFile_, edm::InputSource::IsEvent, edm::InputSource::IsFile, edm::InputSource::IsLumi, edm::InputSource::IsRun, edm::InputSource::IsStop, edm::IndexIntoFile::kEnd, edm::IndexIntoFile::kEvent, edm::IndexIntoFile::kLumi, edm::IndexIntoFile::kRun, and rootFile_.
{ if(fileIter_ == fileIterEnd_) { return InputSource::IsStop; } if(firstFile_) { return InputSource::IsFile; } if(rootFile_) { IndexIntoFile::EntryType entryType = rootFile_->getNextEntryTypeWanted(); if(entryType == IndexIntoFile::kEvent) { return InputSource::IsEvent; } else if(entryType == IndexIntoFile::kLumi) { return InputSource::IsLumi; } else if(entryType == IndexIntoFile::kRun) { return InputSource::IsRun; } assert(entryType == IndexIntoFile::kEnd); } if(fileIter_ + 1 == fileIterEnd_) { return InputSource::IsStop; } return InputSource::IsFile; }
bool edm::RootInputFileSequence::goToEvent | ( | EventID const & | eventID, |
PrincipalCache & | cache | ||
) |
Definition at line 444 of file RootInputFileSequence.cc.
References edm::EventID::event(), fileIter_, fileIterBegin_, newFWLiteAna::found, indexesIntoFiles_, initFile(), edm::EventID::luminosityBlock(), rootFile_, edm::EventID::run(), and usingGoToEvent_.
{ usingGoToEvent_ = true; if (rootFile_) { if (rootFile_->goToEvent(eventID)) { return true; } // If only one input file, give up now, to save time. if(rootFile_ && indexesIntoFiles_.size() == 1) { return false; } // Save the current file and position so that we can restore them // if we fail to restore the desired event bool closedOriginalFile = false; std::vector<FileCatalogItem>::const_iterator originalFile = fileIter_; IndexIntoFile::IndexIntoFileItr originalPosition = rootFile_->indexIntoFileIter(); // Look for item (run/lumi/event) in files previously opened without reopening unnecessary files. typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter; for(Iter it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) { if(*it && (*it)->containsItem(eventID.run(), eventID.luminosityBlock(), eventID.event())) { // We found it. Close the currently open file, and open the correct one. fileIter_ = fileIterBegin_ + (it - indexesIntoFiles_.begin()); initFile(false); // Now get the item from the correct file. bool found = rootFile_->goToEvent(eventID); assert (found); return true; } } // Look for item in files not yet opened. for(Iter it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) { if(!*it) { fileIter_ = fileIterBegin_ + (it - indexesIntoFiles_.begin()); initFile(false); closedOriginalFile = true; if ((*it)->containsItem(eventID.run(), eventID.luminosityBlock(), eventID.event())) { if (rootFile_->goToEvent(eventID)) { return true; } } } } if (closedOriginalFile) { fileIter_ = originalFile; initFile(false); rootFile_->setPosition(originalPosition); } } return false; }
void edm::RootInputFileSequence::initFile | ( | bool | skipBadFiles | ) | [private] |
Definition at line 147 of file RootInputFileSequence.cc.
References closeFile_(), dropDescendants_, duplicateChecker_, eventSkipperByID_, Exception, cms::Exception::explainSelf(), fileIter_, fileIterBegin_, fileIterEnd_, fileIterLastOpened_, edm::errors::FileOpenError, edm::errors::FileReadError, groupSelectorRules_, indexesIntoFiles_, input_, RPC_Client_on_RootFile::InputFile, noEventSort_, numberOfEventsToSkip_, orderedProcessHistoryIDs_, primary(), primaryFiles_, processConfiguration(), edm::InputSource::processingMode(), remainingEvents(), remainingLuminosityBlocks(), edm::InputFile::reportSkippedFile(), rootFile_, setRun_, treeCacheSize_, treeMaxVirtualSize_, and usingGoToEvent_.
Referenced by goToEvent(), nextFile(), previousFile(), readFile_(), readManyRandom(), readManySequential(), reset(), rewind_(), RootInputFileSequence(), and skipToItem().
{ // We are really going to close the open file. // If this is the primary sequence, we are not duplicate checking across files // and we are not using random access to find events, then we can delete the // IndexIntoFile for the file we are closing. If we can't delete all of it, // then we can delete the parts we do not need. if (fileIterLastOpened_ != fileIterEnd_) { size_t currentIndexIntoFile = fileIterLastOpened_ - fileIterBegin_; bool needIndexesForDuplicateChecker = duplicateChecker_ && duplicateChecker_->checkingAllFiles() && !duplicateChecker_->checkDisabled(); bool deleteIndexIntoFile = primaryFiles_ && !needIndexesForDuplicateChecker && !usingGoToEvent_; if (deleteIndexIntoFile) { indexesIntoFiles_[currentIndexIntoFile].reset(); } else { if (indexesIntoFiles_[currentIndexIntoFile]) indexesIntoFiles_[currentIndexIntoFile]->inputFileClosed(); } fileIterLastOpened_ = fileIterEnd_; } closeFile_(); // Check if the logical file name was found. if(fileIter_->fileName().empty()) { // LFN not found in catalog. InputFile::reportSkippedFile(fileIter_->fileName(), fileIter_->logicalFileName()); if(!skipBadFiles) { throw cms::Exception("LogicalFileNameNotFound", "RootInputFileSequence::initFile()\n") << "Logical file name '" << fileIter_->logicalFileName() << "' was not found in the file catalog.\n" << "If you wanted a local file, you forgot the 'file:' prefix\n" << "before the file name in your configuration file.\n"; } LogWarning("") << "Input logical file: " << fileIter_->logicalFileName() << " was not found in the catalog, and will be skipped.\n"; return; } // Determine whether we have a fallback URL specified; if so, prepare it; // Only valid if it is non-empty and differs from the original filename. std::string fallbackName = fileIter_->fallbackFileName(); bool hasFallbackUrl = (!fallbackName.empty()) || (fallbackName == fileIter_->fileName()); boost::shared_ptr<InputFile> filePtr; try { std::auto_ptr<InputSource::FileOpenSentry> sentry(primaryFiles_ ? new InputSource::FileOpenSentry(input_) : 0); filePtr.reset(new InputFile(gSystem->ExpandPathName(fileIter_->fileName().c_str()), " Initiating request to open file ")); } catch (cms::Exception const& e) { if(!skipBadFiles && !hasFallbackUrl) { InputFile::reportSkippedFile(fileIter_->fileName(), fileIter_->logicalFileName()); if(e.explainSelf().find(streamerInfo) != std::string::npos) { throw Exception(errors::FileReadError) << e.explainSelf() << "\n" << "RootInputFileSequence::initFile(): Input file " << fileIter_->fileName() << " could not be read properly.\n" << "Possibly the format is incompatible with the current release.\n"; } throw Exception(errors::FileOpenError) << e.explainSelf() << "\n" << "RootInputFileSequence::initFile(): Input file " << fileIter_->fileName() << " was not found, could not be opened, or is corrupted.\n"; } } if(!filePtr && (hasFallbackUrl)) { try { std::auto_ptr<InputSource::FileOpenSentry> sentry(primaryFiles_ ? new InputSource::FileOpenSentry(input_) : 0); filePtr.reset(new InputFile(gSystem->ExpandPathName(fallbackName.c_str()), " Fallback request to file ")); } catch (cms::Exception const& e) { if(!skipBadFiles) { InputFile::reportSkippedFile(fileIter_->fileName(), fileIter_->logicalFileName()); if(e.explainSelf().find(streamerInfo) != std::string::npos) { throw Exception(errors::FileReadError) << e.explainSelf() << "\n" << "RootInputFileSequence::initFile(): Input file " << fileIter_->fileName() << " could not be read properly.\n" << "Possibly the format is incompatible with the current release.\n"; } throw Exception(errors::FileOpenError) << e.explainSelf() << "\n" << "RootInputFileSequence::initFile(): Input fallback file " << fallbackName << " was not found, could not be opened, or is corrupted.\n"; } } } if(filePtr) { std::vector<boost::shared_ptr<IndexIntoFile> >::size_type currentIndexIntoFile = fileIter_ - fileIterBegin_; rootFile_ = RootFileSharedPtr(new RootFile(fileIter_->fileName(), processConfiguration(), fileIter_->logicalFileName(), filePtr, eventSkipperByID_, numberOfEventsToSkip_ != 0, remainingEvents(), remainingLuminosityBlocks(), treeCacheSize_, treeMaxVirtualSize_, input_.processingMode(), setRun_, noEventSort_, groupSelectorRules_, !primaryFiles_, duplicateChecker_, dropDescendants_, indexesIntoFiles_, currentIndexIntoFile, orderedProcessHistoryIDs_, usingGoToEvent_)); fileIterLastOpened_ = fileIter_; indexesIntoFiles_[currentIndexIntoFile] = rootFile_->indexIntoFileSharedPtr(); rootFile_->reportOpened(primary() ? (primaryFiles_ ? "primaryFiles" : "secondaryFiles") : "mixingFiles"); } else { InputFile::reportSkippedFile(fileIter_->fileName(), fileIter_->logicalFileName()); if(!skipBadFiles) { throw Exception(errors::FileOpenError) << "RootInputFileSequence::initFile(): Input file " << fileIter_->fileName() << " was not found or could not be opened.\n"; } LogWarning("") << "Input file: " << fileIter_->fileName() << " was not found or could not be opened, and will be skipped.\n"; } }
bool edm::RootInputFileSequence::nextFile | ( | PrincipalCache & | cache | ) | [private] |
Definition at line 256 of file RootInputFileSequence.cc.
References edm::PrincipalCache::adjustEventToNewProductRegistry(), edm::PrincipalCache::adjustIndexesAfterProductRegistryAddition(), branchesMustMatch_, Exception, fileIter_, fileIterBegin_, fileIterEnd_, initFile(), edm::ProductRegistry::merge(), edm::errors::MismatchedInputFiles, parametersMustMatch_, primaryFiles_, productRegistry(), productRegistryUpdate(), rootFile_, findQualityFiles::size, and skipBadFiles_.
Referenced by readFile_(), and skipEvents().
{ if(fileIter_ != fileIterEnd_) ++fileIter_; if(fileIter_ == fileIterEnd_) { if(primaryFiles_) { return false; } else { fileIter_ = fileIterBegin_; } } initFile(skipBadFiles_); if(primaryFiles_ && rootFile_) { size_t size = productRegistry()->size(); // make sure the new product registry is compatible with the main one std::string mergeInfo = productRegistryUpdate().merge(*rootFile_->productRegistry(), fileIter_->fileName(), parametersMustMatch_, branchesMustMatch_); if(!mergeInfo.empty()) { throw Exception(errors::MismatchedInputFiles,"RootInputFileSequence::nextFile()") << mergeInfo; } if (productRegistry()->size() > size) { cache.adjustIndexesAfterProductRegistryAddition(); } cache.adjustEventToNewProductRegistry(productRegistry()); } return true; }
bool edm::RootInputFileSequence::previousFile | ( | PrincipalCache & | cache | ) | [private] |
Definition at line 286 of file RootInputFileSequence.cc.
References edm::PrincipalCache::adjustEventToNewProductRegistry(), edm::PrincipalCache::adjustIndexesAfterProductRegistryAddition(), branchesMustMatch_, Exception, fileIter_, fileIterBegin_, fileIterEnd_, initFile(), edm::ProductRegistry::merge(), edm::errors::MismatchedInputFiles, parametersMustMatch_, primaryFiles_, productRegistry(), productRegistryUpdate(), rootFile_, and findQualityFiles::size.
Referenced by skipEvents().
{ if(fileIter_ == fileIterBegin_) { if(primaryFiles_) { return false; } else { fileIter_ = fileIterEnd_; } } --fileIter_; initFile(false); if(primaryFiles_ && rootFile_) { size_t size = productRegistry()->size(); // make sure the new product registry is compatible to the main one std::string mergeInfo = productRegistryUpdate().merge(*rootFile_->productRegistry(), fileIter_->fileName(), parametersMustMatch_, branchesMustMatch_); if(!mergeInfo.empty()) { throw Exception(errors::MismatchedInputFiles,"RootInputFileSequence::previousEvent()") << mergeInfo; } if (productRegistry()->size() > size) { cache.adjustIndexesAfterProductRegistryAddition(); } cache.adjustEventToNewProductRegistry(productRegistry()); } if(rootFile_) rootFile_->setToLastEntry(); return true; }
bool const edm::RootInputFileSequence::primary | ( | ) | const [private] |
Definition at line 535 of file RootInputFileSequence.cc.
References input_, and edm::InputSource::primary().
Referenced by closeFile_(), initFile(), reset(), and RootInputFileSequence().
{ return input_.primary(); }
ProcessConfiguration const & edm::RootInputFileSequence::processConfiguration | ( | ) | const [private] |
Definition at line 540 of file RootInputFileSequence.cc.
References input_, and edm::InputSource::processConfiguration().
Referenced by initFile(), readMany(), readManyRandom(), readManySequential(), and readManySpecified().
{ return input_.processConfiguration(); }
boost::shared_ptr< ProductRegistry const > edm::RootInputFileSequence::productRegistry | ( | ) | const [private] |
Definition at line 560 of file RootInputFileSequence.cc.
References input_, and edm::InputSource::productRegistry().
Referenced by nextFile(), and previousFile().
{ return input_.productRegistry(); }
ProductRegistry & edm::RootInputFileSequence::productRegistryUpdate | ( | ) | const [private] |
Definition at line 555 of file RootInputFileSequence.cc.
References input_, and edm::InputSource::productRegistryUpdate().
Referenced by nextFile(), previousFile(), and RootInputFileSequence().
{ return input_.productRegistryUpdate(); }
EventPrincipal * edm::RootInputFileSequence::readEvent | ( | EventPrincipal & | cache, |
boost::shared_ptr< LuminosityBlockPrincipal > | lb | ||
) |
Definition at line 356 of file RootInputFileSequence.cc.
References rootFile_.
boost::shared_ptr< FileBlock > edm::RootInputFileSequence::readFile_ | ( | PrincipalCache & | cache | ) |
Definition at line 116 of file RootInputFileSequence.cc.
References firstFile_, initFile(), nextFile(), rootFile_, and skipBadFiles_.
{ if(firstFile_) { // The first input file has already been opened. firstFile_ = false; if(!rootFile_) { initFile(skipBadFiles_); } } else { if(!nextFile(cache)) { assert(0); } } if(!rootFile_) { return boost::shared_ptr<FileBlock>(new FileBlock); } return rootFile_->createFileBlock(); }
boost::shared_ptr< LuminosityBlockPrincipal > edm::RootInputFileSequence::readLuminosityBlock_ | ( | boost::shared_ptr< LuminosityBlockPrincipal > | lbCache | ) |
Definition at line 338 of file RootInputFileSequence.cc.
References rootFile_.
{ return rootFile_->readLumi(lbCache); }
boost::shared_ptr< LuminosityBlockAuxiliary > edm::RootInputFileSequence::readLuminosityBlockAuxiliary_ | ( | ) |
Definition at line 327 of file RootInputFileSequence.cc.
References printConversionInfo::aux, and rootFile_.
void edm::RootInputFileSequence::readMany | ( | int | number, |
EventPrincipalVector & | result | ||
) |
Definition at line 579 of file RootInputFileSequence.cc.
References i, processConfiguration(), and rootFile_.
{ for(int i = 0; i < number; ++i) { boost::shared_ptr<EventPrincipal> ep(new EventPrincipal(rootFile_->productRegistry(), processConfiguration())); EventPrincipal* ev = rootFile_->readCurrentEvent(*ep, rootFile_); if(ev == 0) { return; } assert(ev == ep.get()); result.push_back(ep); rootFile_->nextEventEntry(); } }
void edm::RootInputFileSequence::readManyRandom | ( | int | number, |
EventPrincipalVector & | result, | ||
unsigned int & | fileSeqNumber | ||
) |
Definition at line 593 of file RootInputFileSequence.cc.
References edm::errors::Configuration, eventsRemainingInFile_, Exception, fileCatalogItems(), fileIter_, fileIterBegin_, fileIterEnd_, flatDistribution_, i, initFile(), edm::errors::NotFound, processConfiguration(), rewindFile(), rootFile_, findQualityFiles::size, and skipBadFiles_.
{ if(0 != number && (fileIterEnd_ == fileIterBegin_) ) { throw Exception(errors::Configuration) << "RootInputFileSequence::readManyRandom(): no input files specified.\n"; } result.reserve(number); if (!flatDistribution_) { Service<RandomNumberGenerator> rng; CLHEP::HepRandomEngine& engine = rng->getEngine(); flatDistribution_.reset(new CLHEP::RandFlat(engine)); } skipBadFiles_ = false; unsigned int currentSeqNumber = fileIter_ - fileIterBegin_; while(eventsRemainingInFile_ < number) { fileIter_ = fileIterBegin_ + flatDistribution_->fireInt(fileCatalogItems().size()); unsigned int newSeqNumber = fileIter_ - fileIterBegin_; if(newSeqNumber != currentSeqNumber) { initFile(false); currentSeqNumber = newSeqNumber; } eventsRemainingInFile_ = rootFile_->eventTree().entries(); if(eventsRemainingInFile_ == 0) { throw Exception(errors::NotFound) << "RootInputFileSequence::readManyRandom_(): Secondary Input file " << fileIter_->fileName() << " contains no events.\n"; } rootFile_->setAtEventEntry(flatDistribution_->fireInt(eventsRemainingInFile_)); } fileSeqNumber = fileIter_ - fileIterBegin_; for(int i = 0; i < number; ++i) { boost::shared_ptr<EventPrincipal> ep(new EventPrincipal(rootFile_->productRegistry(), processConfiguration())); EventPrincipal* ev = rootFile_->readCurrentEvent(*ep, rootFile_); if(ev == 0) { rewindFile(); ev = rootFile_->readCurrentEvent(*ep, rootFile_); assert(ev != 0); } assert(ev == ep.get()); result.push_back(ep); --eventsRemainingInFile_; rootFile_->nextEventEntry(); } }
void edm::RootInputFileSequence::readManySequential | ( | int | number, |
EventPrincipalVector & | result, | ||
unsigned int & | fileSeqNumber | ||
) |
Definition at line 636 of file RootInputFileSequence.cc.
References edm::errors::Configuration, Exception, fileIter_, fileIterBegin_, fileIterEnd_, i, initFile(), processConfiguration(), rootFile_, and skipBadFiles_.
{ if(0 != number && (fileIterEnd_ == fileIterBegin_) ) { throw Exception(errors::Configuration) << "RootInputFileSequence::readManySequential(): no input files specified.\n"; } result.reserve(number); skipBadFiles_ = false; if (fileIter_ == fileIterEnd_ || !rootFile_) { fileIter_ = fileIterBegin_; initFile(false); rootFile_->setAtEventEntry(0); } fileSeqNumber = fileIter_ - fileIterBegin_; unsigned int numberRead = 0; for(int i = 0; i < number; ++i) { boost::shared_ptr<EventPrincipal> ep(new EventPrincipal(rootFile_->productRegistry(), processConfiguration())); EventPrincipal* ev = rootFile_->readCurrentEvent(*ep, rootFile_); if(ev == 0) { if (numberRead == 0) { ++fileIter_; fileSeqNumber = fileIter_ - fileIterBegin_; if (fileIter_ == fileIterEnd_) { return; } initFile(false); rootFile_->setAtEventEntry(0); return readManySequential(number, result, fileSeqNumber); } return; } assert(ev == ep.get()); result.push_back(ep); ++numberRead; rootFile_->nextEventEntry(); } }
void edm::RootInputFileSequence::readManySpecified | ( | std::vector< EventID > const & | events, |
EventPrincipalVector & | result | ||
) |
Definition at line 673 of file RootInputFileSequence.cc.
References edm::errors::EventCorruption, Exception, fileIter_, newFWLiteAna::found, edm::errors::NotFound, processConfiguration(), rootFile_, skipBadFiles_, and skipToItem().
{ skipBadFiles_ = false; result.reserve(events.size()); for (std::vector<EventID>::const_iterator it = events.begin(), itEnd = events.end(); it != itEnd; ++it) { bool found = skipToItem(it->run(), it->luminosityBlock(), it->event()); if (!found) { throw Exception(errors::NotFound) << "RootInputFileSequence::readManySpecified_(): Secondary Input file " << fileIter_->fileName() << " does not contain specified event:\n" << *it << "\n"; } boost::shared_ptr<EventPrincipal> ep(new EventPrincipal(rootFile_->productRegistry(), processConfiguration())); EventPrincipal* ev = rootFile_->readCurrentEvent(*ep, rootFile_); if (ev == 0) { throw Exception(errors::EventCorruption) << "RootInputFileSequence::readManySpecified_(): Secondary Input file " << fileIter_->fileName() << " contains specified event " << *it << " that cannot be read.\n"; } assert(ev == ep.get()); result.push_back(ep); } }
boost::shared_ptr< RunPrincipal > edm::RootInputFileSequence::readRun_ | ( | boost::shared_ptr< RunPrincipal > | rpCache | ) |
Definition at line 333 of file RootInputFileSequence.cc.
References rootFile_.
{ return rootFile_->readRun_(rpCache); }
boost::shared_ptr< RunAuxiliary > edm::RootInputFileSequence::readRunAuxiliary_ | ( | ) |
Definition at line 321 of file RootInputFileSequence.cc.
References printConversionInfo::aux, and rootFile_.
int edm::RootInputFileSequence::remainingEvents | ( | ) | const [private] |
Definition at line 545 of file RootInputFileSequence.cc.
References input_, and edm::InputSource::remainingEvents().
Referenced by initFile().
{ return input_.remainingEvents(); }
int edm::RootInputFileSequence::remainingLuminosityBlocks | ( | ) | const [private] |
Definition at line 550 of file RootInputFileSequence.cc.
References input_, and edm::InputSource::remainingLuminosityBlocks().
Referenced by initFile().
{ return input_.remainingLuminosityBlocks(); }
void edm::RootInputFileSequence::reset | ( | PrincipalCache & | cache | ) |
Definition at line 406 of file RootInputFileSequence.cc.
References fileIter_, fileIterBegin_, fileIterEnd_, firstFile_, initFile(), numberOfEventsToSkip_, primary(), rootFile_, skipBadFiles_, and skipEvents().
{ //NOTE: Need to handle duplicate checker // Also what if skipBadFiles_==true and the first time we succeeded but after a reset we fail? if(primary()) { firstFile_ = true; for(fileIter_ = fileIterBegin_; fileIter_ != fileIterEnd_; ++fileIter_) { initFile(skipBadFiles_); if(rootFile_) break; } if(rootFile_) { if(numberOfEventsToSkip_ != 0) { skipEvents(numberOfEventsToSkip_, cache); } } } }
ProcessingController::ReverseState edm::RootInputFileSequence::reverseState | ( | ) | const |
Definition at line 748 of file RootInputFileSequence.cc.
References fileIter_, fileIterBegin_, edm::ProcessingController::kAtFirstEvent, edm::ProcessingController::kEventsBackwardsInFile, edm::ProcessingController::kPreviousFileExists, edm::ProcessingController::kUnknownReverse, and rootFile_.
{ if (rootFile_) { if (!rootFile_->wasFirstEventJustRead()) { return ProcessingController::kEventsBackwardsInFile; } if (fileIter_ != fileIterBegin_) { return ProcessingController::kPreviousFileExists; } return ProcessingController::kAtFirstEvent; } return ProcessingController::kUnknownReverse; }
void edm::RootInputFileSequence::rewind_ | ( | ) |
Definition at line 387 of file RootInputFileSequence.cc.
References closeFile_(), fileIter_, fileIterBegin_, firstFile_, initFile(), rewindFile(), and rootFile_.
{ if (fileIter_ != fileIterBegin_) { closeFile_(); fileIter_ = fileIterBegin_; } if (!rootFile_) { initFile(false); } rewindFile(); firstFile_ = true; }
void edm::RootInputFileSequence::rewindFile | ( | ) | [private] |
Definition at line 401 of file RootInputFileSequence.cc.
References rootFile_.
Referenced by readManyRandom(), and rewind_().
{ rootFile_->rewind(); }
bool edm::RootInputFileSequence::skipEvents | ( | int | offset, |
PrincipalCache & | cache | ||
) |
Definition at line 425 of file RootInputFileSequence.cc.
References fileIter_, fileIterEnd_, nextFile(), numberOfEventsToSkip_, evf::evtn::offset(), previousFile(), and rootFile_.
Referenced by reset(), and RootInputFileSequence().
{ assert (numberOfEventsToSkip_ == 0 || numberOfEventsToSkip_ == offset); numberOfEventsToSkip_ = offset; while(numberOfEventsToSkip_ != 0) { bool atEnd = rootFile_->skipEvents(numberOfEventsToSkip_); if((numberOfEventsToSkip_ > 0 || atEnd) && !nextFile(cache)) { numberOfEventsToSkip_ = 0; return false; } if(numberOfEventsToSkip_ < 0 && !previousFile(cache)) { numberOfEventsToSkip_ = 0; fileIter_ = fileIterEnd_; return false; } } return true; }
bool edm::RootInputFileSequence::skipToItem | ( | RunNumber_t | run, |
LuminosityBlockNumber_t | lumi, | ||
EventNumber_t | event | ||
) |
Definition at line 496 of file RootInputFileSequence.cc.
References fileIter_, fileIterBegin_, newFWLiteAna::found, indexesIntoFiles_, initFile(), and rootFile_.
Referenced by readManySpecified().
{ // Attempt to find item in currently open input file. bool found = rootFile_ && rootFile_->setEntryAtItem(run, lumi, event); if(!found) { // If only one input file, give up now, to save time. if(rootFile_ && indexesIntoFiles_.size() == 1) { return false; } // Look for item (run/lumi/event) in files previously opened without reopening unnecessary files. typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter; for(Iter it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) { if(*it && (*it)->containsItem(run, lumi, event)) { // We found it. Close the currently open file, and open the correct one. fileIter_ = fileIterBegin_ + (it - indexesIntoFiles_.begin()); initFile(false); // Now get the item from the correct file. found = rootFile_->setEntryAtItem(run, lumi, event); assert (found); return true; } } // Look for item in files not yet opened. for(Iter it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) { if(!*it) { fileIter_ = fileIterBegin_ + (it - indexesIntoFiles_.begin()); initFile(false); found = rootFile_->setEntryAtItem(run, lumi, event); if(found) { return true; } } } // Not found return false; } return true; }
Definition at line 92 of file RootInputFileSequence.h.
Referenced by nextFile(), previousFile(), and RootInputFileSequence().
InputFileCatalog const& edm::RootInputFileSequence::catalog_ [private] |
Definition at line 84 of file RootInputFileSequence.h.
Referenced by fileCatalogItems().
bool edm::RootInputFileSequence::dropDescendants_ [private] |
Definition at line 109 of file RootInputFileSequence.h.
Referenced by initFile().
boost::shared_ptr<DuplicateChecker> edm::RootInputFileSequence::duplicateChecker_ [private] |
Definition at line 108 of file RootInputFileSequence.h.
Referenced by closeFile_(), and initFile().
boost::shared_ptr<EventSkipperByID> edm::RootInputFileSequence::eventSkipperByID_ [private] |
Definition at line 98 of file RootInputFileSequence.h.
Referenced by initFile().
int edm::RootInputFileSequence::eventsRemainingInFile_ [private] |
Definition at line 99 of file RootInputFileSequence.h.
Referenced by readManyRandom().
std::vector<FileCatalogItem>::const_iterator edm::RootInputFileSequence::fileIter_ [private] |
Definition at line 88 of file RootInputFileSequence.h.
Referenced by forwardState(), getNextItemType(), goToEvent(), initFile(), nextFile(), previousFile(), readManyRandom(), readManySequential(), readManySpecified(), reset(), reverseState(), rewind_(), RootInputFileSequence(), skipEvents(), and skipToItem().
std::vector<FileCatalogItem>::const_iterator edm::RootInputFileSequence::fileIterBegin_ [private] |
Definition at line 86 of file RootInputFileSequence.h.
Referenced by goToEvent(), initFile(), nextFile(), previousFile(), readManyRandom(), readManySequential(), reset(), reverseState(), rewind_(), RootInputFileSequence(), and skipToItem().
std::vector<FileCatalogItem>::const_iterator edm::RootInputFileSequence::fileIterEnd_ [private] |
Definition at line 87 of file RootInputFileSequence.h.
Referenced by forwardState(), getNextItemType(), initFile(), nextFile(), previousFile(), readManyRandom(), readManySequential(), reset(), RootInputFileSequence(), and skipEvents().
std::vector<FileCatalogItem>::const_iterator edm::RootInputFileSequence::fileIterLastOpened_ [private] |
Definition at line 89 of file RootInputFileSequence.h.
Referenced by initFile().
bool edm::RootInputFileSequence::firstFile_ [private] |
Definition at line 85 of file RootInputFileSequence.h.
Referenced by getNextItemType(), readFile_(), reset(), and rewind_().
boost::scoped_ptr<CLHEP::RandFlat> edm::RootInputFileSequence::flatDistribution_ [private] |
Definition at line 94 of file RootInputFileSequence.h.
Referenced by readManyRandom().
Definition at line 106 of file RootInputFileSequence.h.
Referenced by dropUnwantedBranches_(), and initFile().
std::vector<boost::shared_ptr<IndexIntoFile> > edm::RootInputFileSequence::indexesIntoFiles_ [private] |
Definition at line 95 of file RootInputFileSequence.h.
Referenced by goToEvent(), initFile(), and skipToItem().
PoolSource const& edm::RootInputFileSequence::input_ [private] |
Definition at line 83 of file RootInputFileSequence.h.
Referenced by closeFile_(), initFile(), primary(), processConfiguration(), productRegistry(), productRegistryUpdate(), remainingEvents(), and remainingLuminosityBlocks().
bool edm::RootInputFileSequence::noEventSort_ [private] |
Definition at line 101 of file RootInputFileSequence.h.
Referenced by initFile().
int edm::RootInputFileSequence::numberOfEventsToSkip_ [private] |
Definition at line 100 of file RootInputFileSequence.h.
Referenced by initFile(), reset(), RootInputFileSequence(), and skipEvents().
std::vector<ProcessHistoryID> edm::RootInputFileSequence::orderedProcessHistoryIDs_ [private] |
Definition at line 96 of file RootInputFileSequence.h.
Referenced by initFile().
Definition at line 91 of file RootInputFileSequence.h.
Referenced by nextFile(), previousFile(), and RootInputFileSequence().
bool edm::RootInputFileSequence::primaryFiles_ [private] |
Definition at line 107 of file RootInputFileSequence.h.
Referenced by closeFile_(), initFile(), nextFile(), previousFile(), and RootInputFileSequence().
Definition at line 90 of file RootInputFileSequence.h.
Referenced by closeFile_(), fileProductRegistry(), forwardState(), getNextItemType(), goToEvent(), initFile(), nextFile(), previousFile(), readEvent(), readFile_(), readLuminosityBlock_(), readLuminosityBlockAuxiliary_(), readMany(), readManyRandom(), readManySequential(), readManySpecified(), readRun_(), readRunAuxiliary_(), reset(), reverseState(), rewind_(), rewindFile(), RootInputFileSequence(), skipEvents(), and skipToItem().
Definition at line 105 of file RootInputFileSequence.h.
Referenced by initFile().
bool edm::RootInputFileSequence::skipBadFiles_ [private] |
Definition at line 102 of file RootInputFileSequence.h.
Referenced by nextFile(), readFile_(), readManyRandom(), readManySequential(), readManySpecified(), reset(), and RootInputFileSequence().
unsigned int edm::RootInputFileSequence::treeCacheSize_ [private] |
Definition at line 103 of file RootInputFileSequence.h.
Referenced by initFile(), and RootInputFileSequence().
int const edm::RootInputFileSequence::treeMaxVirtualSize_ [private] |
Definition at line 104 of file RootInputFileSequence.h.
Referenced by initFile().
bool edm::RootInputFileSequence::usingGoToEvent_ [private] |
Definition at line 110 of file RootInputFileSequence.h.
Referenced by goToEvent(), and initFile().