CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
edm::RootInputFileSequence Class Reference

#include <RootInputFileSequence.h>

Public Types

typedef std::shared_ptr< RootFileRootFileSharedPtr
 

Public Member Functions

void closeFile_ ()
 
bool containedInCurrentFile (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
 
void dropUnwantedBranches_ (std::vector< std::string > const &wantedBranches)
 
void endJob ()
 
std::shared_ptr
< BranchIDListHelper const > 
fileBranchIDListHelper () const
 
std::shared_ptr
< ProductRegistry const > 
fileProductRegistry () const
 
ProcessingController::ForwardState forwardState () const
 
InputSource::ItemType getNextItemType (RunNumber_t &run, LuminosityBlockNumber_t &lumi, EventNumber_t &event)
 
bool goToEvent (EventID const &eventID)
 
void initAssociationsFromSecondary (std::set< BranchID > const &)
 
RootInputFileSequenceoperator= (RootInputFileSequence const &)=delete
 
ProcessHistoryRegistry const & processHistoryRegistry () const
 
ProcessHistoryRegistryprocessHistoryRegistryForUpdate ()
 
void readEvent (EventPrincipal &cache)
 
std::unique_ptr< FileBlockreadFile_ ()
 
void readLuminosityBlock_ (LuminosityBlockPrincipal &lumiPrincipal)
 
std::shared_ptr
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary_ ()
 
void readOneRandom (EventPrincipal &cache, size_t &fileNameHash, CLHEP::HepRandomEngine *)
 
bool readOneRandomWithID (EventPrincipal &cache, size_t &fileNameHash, LuminosityBlockID const &id, CLHEP::HepRandomEngine *)
 
bool readOneSequential (EventPrincipal &cache, size_t &fileNameHash)
 
bool readOneSequentialWithID (EventPrincipal &cache, size_t &fileNameHash, LuminosityBlockID const &id)
 
void readOneSpecified (EventPrincipal &cache, size_t &fileNameHash, SecondaryEventIDAndFileInfo const &id)
 
void readRun_ (RunPrincipal &runPrincipal)
 
std::shared_ptr< RunAuxiliaryreadRunAuxiliary_ ()
 
ProcessingController::ReverseState reverseState () const
 
void rewind_ ()
 
 RootInputFileSequence (ParameterSet const &pset, PoolSource &input, InputFileCatalog const &catalog, unsigned int nStreams, InputType inputType)
 
 RootInputFileSequence (RootInputFileSequence const &)=delete
 
bool skipEvents (int offset)
 
bool skipToItem (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, size_t fileNameHash=0U, bool currentFileFirst=true)
 
bool skipToItemInNewFile (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
 
bool skipToItemInNewFile (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, size_t fileNameHash)
 
virtual ~RootInputFileSequence ()
 

Static Public Member Functions

static void fillDescription (ParameterSetDescription &desc)
 

Private Member Functions

std::vector< FileCatalogItem >
const & 
fileCatalogItems () const
 
void initFile (bool skipBadFiles)
 
bool nextFile ()
 
bool previousFile ()
 
ProcessConfiguration const & processConfiguration () const
 
std::shared_ptr
< ProductRegistry const > 
productRegistry () const
 
ProductRegistryproductRegistryUpdate () const
 
int remainingEvents () const
 
int remainingLuminosityBlocks () const
 
void rewindFile ()
 

Private Attributes

std::vector< BranchIDassociationsFromSecondary_
 
BranchDescription::MatchMode branchesMustMatch_
 
bool bypassVersionCheck_
 
InputFileCatalog const & catalog_
 
bool dropDescendants_
 
std::shared_ptr< DuplicateCheckerduplicateChecker_
 
bool enablePrefetching_
 
std::shared_ptr< EventSkipperByIDeventSkipperByID_
 
int eventsRemainingInFile_
 
std::vector< FileCatalogItem >
::const_iterator 
fileIter_
 
std::vector< FileCatalogItem >
::const_iterator 
fileIterBegin_
 
std::vector< FileCatalogItem >
::const_iterator 
fileIterEnd_
 
std::vector< FileCatalogItem >
::const_iterator 
fileIterLastOpened_
 
std::unique_ptr
< std::unordered_multimap
< size_t, size_t > > 
findFileForSpecifiedID_
 
bool firstFile_
 
std::vector< std::shared_ptr
< IndexIntoFile > > 
indexesIntoFiles_
 
int initialNumberOfEventsToSkip_
 
PoolSourceinput_
 
InputType inputType_
 
bool labelRawDataLikeMC_
 
std::string lfn_
 
size_t lfnHash_
 
bool noEventSort_
 
unsigned int nStreams_
 
std::vector< ProcessHistoryIDorderedProcessHistoryIDs_
 
ProductSelectorRules productSelectorRules_
 
RootFileSharedPtr rootFile_
 
RunNumber_t setRun_
 
bool skipBadFiles_
 
unsigned int treeCacheSize_
 
int const treeMaxVirtualSize_
 
bool usedFallback_
 
bool usingGoToEvent_
 

Detailed Description

Definition at line 40 of file RootInputFileSequence.h.

Member Typedef Documentation

Definition at line 52 of file RootInputFileSequence.h.

Constructor & Destructor Documentation

edm::RootInputFileSequence::RootInputFileSequence ( ParameterSet const &  pset,
PoolSource input,
InputFileCatalog const &  catalog,
unsigned int  nStreams,
InputType  inputType 
)
explicit

Definition at line 28 of file RootInputFileSequence.cc.

References StorageFactory::activateTimeout(), branchesMustMatch_, enablePrefetching_, fileIter_, fileIterBegin_, fileIterEnd_, StorageFactory::get(), edm::ParameterSet::getUntrackedParameter(), initFile(), initialNumberOfEventsToSkip_, inputType_, edm::Service< T >::isAvailable(), edm::Primary, productRegistryUpdate(), rootFile_, edm::SecondarySource, skipBadFiles_, skipEvents(), StorageFactory::stagein(), edm::BranchDescription::Strict, AlCaHLTBitMon_QueryRunRegistry::string, treeCacheSize_, and edm::ProductRegistry::updateFromInput().

33  :
34  input_(input),
35  inputType_(inputType),
37  firstFile_(true),
38  lfn_("unknown"),
39  lfnHash_(0U),
40  findFileForSpecifiedID_(nullptr),
45  rootFile_(),
49  nStreams_(nStreams),
52  // The default value provided as the second argument to the getUntrackedParameter function call
53  // is not used when the ParameterSet has been validated and the parameters are not optional
54  // in the description. This is currently true when PoolSource is the primary input source.
55  // The modules that use PoolSource as a SecSource have not defined their fillDescriptions function
56  // yet, so the ParameterSet does not get validated yet. As soon as all the modules with a SecSource
57  // have defined descriptions, the defaults in the getUntrackedParameterSet function calls can
58  // and should be deleted from the code.
59  initialNumberOfEventsToSkip_(inputType == InputType::Primary ? pset.getUntrackedParameter<unsigned int>("skipEvents", 0U) : 0U),
60  noEventSort_(inputType == InputType::Primary ? pset.getUntrackedParameter<bool>("noEventSort", true) : false),
61  skipBadFiles_(pset.getUntrackedParameter<bool>("skipBadFiles", false)),
62  bypassVersionCheck_(pset.getUntrackedParameter<bool>("bypassVersionCheck", false)),
63  treeCacheSize_(noEventSort_ ? pset.getUntrackedParameter<unsigned int>("cacheSize", roottree::defaultCacheSize) : 0U),
64  treeMaxVirtualSize_(pset.getUntrackedParameter<int>("treeMaxVirtualSize", -1)),
65  setRun_(pset.getUntrackedParameter<unsigned int>("setRunNumber", 0U)),
66  productSelectorRules_(pset, "inputCommands", "InputSource"),
67  duplicateChecker_(inputType == InputType::Primary ? new DuplicateChecker(pset) : 0),
68  dropDescendants_(pset.getUntrackedParameter<bool>("dropDescendantsOfDroppedBranches", inputType != InputType::SecondarySource)),
69  labelRawDataLikeMC_(pset.getUntrackedParameter<bool>("labelRawDataLikeMC", true)),
70  usingGoToEvent_(false),
71  enablePrefetching_(false),
72  usedFallback_(false) {
73 
74  // The SiteLocalConfig controls the TTreeCache size and the prefetching settings.
76  if(pSLC.isAvailable()) {
77  if(treeCacheSize_ != 0U && pSLC->sourceTTreeCacheSize()) {
78  treeCacheSize_ = *(pSLC->sourceTTreeCacheSize());
79  }
80  enablePrefetching_ = pSLC->enablePrefetching();
81  }
82 
85  factory->activateTimeout(fileIter_->fileName());
86  factory->stagein(fileIter_->fileName());
87  //NOTE: we do not want to stage in all secondary files since we can be given a list of
88  // thousands of files and prestaging all those files can cause a site to fail.
89  // So, we stage in the first secondary file only.
91  break;
92  }
93  }
94 
95  std::string branchesMustMatch = pset.getUntrackedParameter<std::string>("branchesMustMatch", std::string("permissive"));
96  if(branchesMustMatch == std::string("strict")) branchesMustMatch_ = BranchDescription::Strict;
97 
100  if(rootFile_) break;
101  }
102  if(rootFile_) {
103  productRegistryUpdate().updateFromInput(rootFile_->productRegistry()->productList());
106  }
107  }
108  }
void stagein(const std::string &url)
void initFile(bool skipBadFiles)
ProductSelectorRules productSelectorRules_
std::vector< FileCatalogItem >::const_iterator fileIter_
std::shared_ptr< EventSkipperByID > eventSkipperByID_
ProductRegistry & productRegistryUpdate() const
unsigned int const defaultCacheSize
Definition: RootTree.h:37
static std::string const input
Definition: EdmProvDump.cc:43
static StorageFactory * get(void)
std::shared_ptr< DuplicateChecker > duplicateChecker_
std::vector< FileCatalogItem >::const_iterator fileIterLastOpened_
std::vector< FileCatalogItem > const & fileCatalogItems() const
#define end
Definition: vmac.h:37
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
std::unique_ptr< std::unordered_multimap< size_t, size_t > > findFileForSpecifiedID_
std::vector< ProcessHistoryID > orderedProcessHistoryIDs_
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
#define begin
Definition: vmac.h:30
void updateFromInput(ProductList const &other)
void activateTimeout(const std::string &url)
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
BranchDescription::MatchMode branchesMustMatch_
static std::auto_ptr< EventSkipperByID > create(ParameterSet const &pset)
tuple size
Write out results.
InputFileCatalog const & catalog_
edm::RootInputFileSequence::~RootInputFileSequence ( )
virtual

Definition at line 373 of file RootInputFileSequence.cc.

373  {
374  }
edm::RootInputFileSequence::RootInputFileSequence ( RootInputFileSequence const &  )
delete

Member Function Documentation

void edm::RootInputFileSequence::closeFile_ ( )

Definition at line 139 of file RootInputFileSequence.cc.

References duplicateChecker_, input_, inputType_, lfn_, edm::Primary, rootFile_, edm::SecondarySource, and usedFallback_.

Referenced by endJob(), initFile(), and rewind_().

139  {
140  // close the currently open file, if any, and delete the RootFile object.
141  if(rootFile_) {
143  std::unique_ptr<InputSource::FileCloseSentry>
144  sentry((inputType_ == InputType::Primary) ? new InputSource::FileCloseSentry(input_, lfn_, usedFallback_) : 0);
145  rootFile_->close();
146  if(duplicateChecker_) duplicateChecker_->inputFileClosed();
147  }
148  rootFile_.reset();
149  }
150  }
std::shared_ptr< DuplicateChecker > duplicateChecker_
bool edm::RootInputFileSequence::containedInCurrentFile ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const

Definition at line 445 of file RootInputFileSequence.cc.

References rootFile_.

445  {
446  if(!rootFile_) return false;
447  return rootFile_->containsItem(run, lumi, event);
448  }
tuple lumi
Definition: fjr2json.py:35
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
void edm::RootInputFileSequence::dropUnwantedBranches_ ( std::vector< std::string > const &  wantedBranches)

Definition at line 670 of file RootInputFileSequence.cc.

References edm::ParameterSet::addUntrackedParameter(), productSelectorRules_, cmsCodeRulesChecker::rules, and AlCaHLTBitMon_QueryRunRegistry::string.

670  {
671  std::vector<std::string> rules;
672  rules.reserve(wantedBranches.size() + 1);
673  rules.emplace_back("drop *");
674  for(std::string const& branch : wantedBranches) {
675  rules.push_back("keep " + branch + "_*");
676  }
677  ParameterSet pset;
678  pset.addUntrackedParameter("inputCommands", rules);
679  productSelectorRules_ = ProductSelectorRules(pset, "inputCommands", "InputSource");
680  }
ProductSelectorRules productSelectorRules_
void edm::RootInputFileSequence::endJob ( void  )

Definition at line 116 of file RootInputFileSequence.cc.

References closeFile_().

116  {
117  closeFile_();
118  }
std::shared_ptr< BranchIDListHelper const > edm::RootInputFileSequence::fileBranchIDListHelper ( ) const

Definition at line 319 of file RootInputFileSequence.cc.

References assert(), and rootFile_.

319  {
320  assert(rootFile_);
321  return rootFile_->branchIDListHelper();
322  }
assert(m_qm.get())
std::vector< FileCatalogItem > const & edm::RootInputFileSequence::fileCatalogItems ( ) const
private

Definition at line 111 of file RootInputFileSequence.cc.

References catalog_, and edm::InputFileCatalog::fileCatalogItems().

Referenced by readOneRandom().

111  {
112  return catalog_.fileCatalogItems();
113  }
std::vector< FileCatalogItem > const & fileCatalogItems() const
InputFileCatalog const & catalog_
std::shared_ptr< ProductRegistry const > edm::RootInputFileSequence::fileProductRegistry ( ) const

Definition at line 313 of file RootInputFileSequence.cc.

References assert(), and rootFile_.

313  {
314  assert(rootFile_);
315  return rootFile_->productRegistry();
316  }
assert(m_qm.get())
void edm::RootInputFileSequence::fillDescription ( ParameterSetDescription desc)
static

Definition at line 841 of file RootInputFileSequence.cc.

References edm::ParameterSetDescription::addUntracked(), edm::roottree::defaultCacheSize, edm::EventSkipperByID::fillDescription(), edm::ProductSelectorRules::fillDescription(), edm::DuplicateChecker::fillDescription(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by edm::PoolSource::fillDescriptions().

841  {
842  desc.addUntracked<unsigned int>("skipEvents", 0U)
843  ->setComment("Skip the first 'skipEvents' events that otherwise would have been processed.");
844  desc.addUntracked<bool>("noEventSort", true)
845  ->setComment("True: Process runs, lumis and events in the order they appear in the file (but see notes 1 and 2).\n"
846  "False: Process runs, lumis and events in each file in numerical order (run#, lumi#, event#) (but see note 3).\n"
847  "Note 1: Events within the same lumi will always be processed contiguously.\n"
848  "Note 2: Lumis within the same run will always be processed contiguously.\n"
849  "Note 3: Any sorting occurs independently in each input file (no sorting across input files).");
850  desc.addUntracked<bool>("skipBadFiles", false)
851  ->setComment("True: Ignore any missing or unopenable input file.\n"
852  "False: Throw exception if missing or unopenable input file.");
853  desc.addUntracked<bool>("bypassVersionCheck", false)
854  ->setComment("True: Bypass release version check.\n"
855  "False: Throw exception if reading file in a release prior to the release in which the file was written.");
856  desc.addUntracked<unsigned int>("cacheSize", roottree::defaultCacheSize)
857  ->setComment("Size of ROOT TTree prefetch cache. Affects performance.");
858  desc.addUntracked<int>("treeMaxVirtualSize", -1)
859  ->setComment("Size of ROOT TTree TBasket cache. Affects performance.");
860  desc.addUntracked<unsigned int>("setRunNumber", 0U)
861  ->setComment("If non-zero, change number of first run to this number. Apply same offset to all runs. Allowed only for simulation.");
862  desc.addUntracked<bool>("dropDescendantsOfDroppedBranches", true)
863  ->setComment("If True, also drop on input any descendent of any branch dropped on input.");
864  std::string defaultString("permissive");
865  desc.addUntracked<std::string>("branchesMustMatch", defaultString)
866  ->setComment("'strict': Branches in each input file must match those in the first file.\n"
867  "'permissive': Branches in each input file may be any subset of those in the first file.");
868  desc.addUntracked<bool>("labelRawDataLikeMC", true)
869  ->setComment("If True: replace module label for raw data to match MC. Also use 'LHC' as process.");
870 
871  ProductSelectorRules::fillDescription(desc, "inputCommands");
874  }
static void fillDescription(ParameterSetDescription &desc, char const *parameterName)
static void fillDescription(ParameterSetDescription &desc)
unsigned int const defaultCacheSize
Definition: RootTree.h:37
static void fillDescription(ParameterSetDescription &desc)
ProcessingController::ForwardState edm::RootInputFileSequence::forwardState ( ) const
InputSource::ItemType edm::RootInputFileSequence::getNextItemType ( RunNumber_t run,
LuminosityBlockNumber_t lumi,
EventNumber_t event 
)

Definition at line 420 of file RootInputFileSequence.cc.

References assert(), 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_.

420  {
421  if(fileIter_ == fileIterEnd_) {
422  return InputSource::IsStop;
423  }
424  if(firstFile_) {
425  return InputSource::IsFile;
426  }
427  if(rootFile_) {
428  IndexIntoFile::EntryType entryType = rootFile_->getNextItemType(run, lumi, event);
429  if(entryType == IndexIntoFile::kEvent) {
430  return InputSource::IsEvent;
431  } else if(entryType == IndexIntoFile::kLumi) {
432  return InputSource::IsLumi;
433  } else if(entryType == IndexIntoFile::kRun) {
434  return InputSource::IsRun;
435  }
436  assert(entryType == IndexIntoFile::kEnd);
437  }
438  if(fileIter_ + 1 == fileIterEnd_) {
439  return InputSource::IsStop;
440  }
441  return InputSource::IsFile;
442  }
std::vector< FileCatalogItem >::const_iterator fileIter_
tuple lumi
Definition: fjr2json.py:35
assert(m_qm.get())
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
bool edm::RootInputFileSequence::goToEvent ( EventID const &  eventID)

Definition at line 497 of file RootInputFileSequence.cc.

References assert(), edm::EventID::event(), fileIter_, fileIterBegin_, newFWLiteAna::found, indexesIntoFiles_, initFile(), edm::EventID::luminosityBlock(), rootFile_, edm::EventID::run(), and usingGoToEvent_.

497  {
498  usingGoToEvent_ = true;
499  if(rootFile_) {
500  if(rootFile_->goToEvent(eventID)) {
501  return true;
502  }
503  // If only one input file, give up now, to save time.
504  if(rootFile_ && indexesIntoFiles_.size() == 1) {
505  return false;
506  }
507  // Save the current file and position so that we can restore them
508  // if we fail to restore the desired event
509  bool closedOriginalFile = false;
510  std::vector<FileCatalogItem>::const_iterator originalFile = fileIter_;
511  IndexIntoFile::IndexIntoFileItr originalPosition = rootFile_->indexIntoFileIter();
512 
513  // Look for item (run/lumi/event) in files previously opened without reopening unnecessary files.
514  typedef std::vector<std::shared_ptr<IndexIntoFile> >::const_iterator Iter;
515  for(Iter it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) {
516  if(*it && (*it)->containsItem(eventID.run(), eventID.luminosityBlock(), eventID.event())) {
517  // We found it. Close the currently open file, and open the correct one.
518  fileIter_ = fileIterBegin_ + (it - indexesIntoFiles_.begin());
519  initFile(false);
520  // Now get the item from the correct file.
521  assert(rootFile_);
522  bool found = rootFile_->goToEvent(eventID);
523  assert(found);
524  return true;
525  }
526  }
527  // Look for item in files not yet opened.
528  for(Iter it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) {
529  if(!*it) {
530  fileIter_ = fileIterBegin_ + (it - indexesIntoFiles_.begin());
531  initFile(false);
532  closedOriginalFile = true;
533  if((*it)->containsItem(eventID.run(), eventID.luminosityBlock(), eventID.event())) {
534  assert(rootFile_);
535  if(rootFile_->goToEvent(eventID)) {
536  return true;
537  }
538  }
539  }
540  }
541  if(closedOriginalFile) {
542  fileIter_ = originalFile;
543  initFile(false);
544  assert(rootFile_);
545  rootFile_->setPosition(originalPosition);
546  }
547  }
548  return false;
549  }
void initFile(bool skipBadFiles)
std::vector< FileCatalogItem >::const_iterator fileIter_
assert(m_qm.get())
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
void edm::RootInputFileSequence::initAssociationsFromSecondary ( std::set< BranchID > const &  associationsFromSecondary)

Definition at line 906 of file RootInputFileSequence.cc.

References associationsFromSecondary_, and rootFile_.

906  {
907  for(auto const& branchID : associationsFromSecondary) {
908  associationsFromSecondary_.push_back(branchID);
909  }
910  rootFile_->initAssociationsFromSecondary(associationsFromSecondary_);
911  }
std::vector< BranchID > associationsFromSecondary_
void edm::RootInputFileSequence::initFile ( bool  skipBadFiles)
private

Definition at line 152 of file RootInputFileSequence.cc.

References StorageFactory::activateTimeout(), cms::Exception::additionalInfo(), assert(), associationsFromSecondary_, edm::InputSource::branchIDListHelper(), bypassVersionCheck_, closeFile_(), dropDescendants_, duplicateChecker_, alignCSCRings::e, enablePrefetching_, eventSkipperByID_, edm::hlt::Exception, cms::Exception::explainSelf(), edm::errors::FallbackFileOpenError, fileIter_, fileIterBegin_, fileIterEnd_, fileIterLastOpened_, edm::errors::FileOpenError, StorageFactory::get(), indexesIntoFiles_, initialNumberOfEventsToSkip_, input_, RPC_Client_on_RootFile::InputFile, inputType_, labelRawDataLikeMC_, lfn_, lfnHash_, noEventSort_, nStreams_, orderedProcessHistoryIDs_, dbtoconf::out, dbtoconf::pfn, edm::Primary, processConfiguration(), processHistoryRegistryForUpdate(), edm::InputSource::processingMode(), productSelectorRules_, remainingEvents(), remainingLuminosityBlocks(), edm::InputFile::reportFallbackAttempt(), edm::InputFile::reportSkippedFile(), rootFile_, alignCSCRings::s, edm::SecondaryFile, edm::SecondarySource, setRun_, AlCaHLTBitMon_QueryRunRegistry::string, edm::InputSource::thinnedAssociationsHelper(), treeCacheSize_, treeMaxVirtualSize_, usedFallback_, and usingGoToEvent_.

Referenced by goToEvent(), nextFile(), previousFile(), readFile_(), readOneRandom(), readOneSequential(), rewind_(), RootInputFileSequence(), skipToItem(), and skipToItemInNewFile().

152  {
153  // We are really going to close the open file.
154 
155  // If this is the primary sequence, we are not duplicate checking across files
156  // and we are not using random access to find events, then we can delete the
157  // IndexIntoFile for the file we are closing. If we can't delete all of it,
158  // then we can delete the parts we do not need.
160  size_t currentIndexIntoFile = fileIterLastOpened_ - fileIterBegin_;
161  bool needIndexesForDuplicateChecker = duplicateChecker_ && duplicateChecker_->checkingAllFiles() && !duplicateChecker_->checkDisabled();
162  bool deleteIndexIntoFile = inputType_ == InputType::Primary &&
163  !needIndexesForDuplicateChecker &&
165  if(deleteIndexIntoFile) {
166  indexesIntoFiles_[currentIndexIntoFile].reset();
167  } else {
168  if(indexesIntoFiles_[currentIndexIntoFile]) indexesIntoFiles_[currentIndexIntoFile]->inputFileClosed();
169  }
171  }
172  closeFile_();
173 
174  if(fileIter_ == fileIterEnd_) {
175  // No files specified
176  return;
177  }
178 
179  // Check if the logical file name was found.
180  if(fileIter_->fileName().empty()) {
181  // LFN not found in catalog.
182  InputFile::reportSkippedFile(fileIter_->fileName(), fileIter_->logicalFileName());
183  if(!skipBadFiles) {
184  throw cms::Exception("LogicalFileNameNotFound", "RootInputFileSequence::initFile()\n")
185  << "Logical file name '" << fileIter_->logicalFileName() << "' was not found in the file catalog.\n"
186  << "If you wanted a local file, you forgot the 'file:' prefix\n"
187  << "before the file name in your configuration file.\n";
188  }
189  LogWarning("") << "Input logical file: " << fileIter_->logicalFileName() << " was not found in the catalog, and will be skipped.\n";
190  return;
191  }
192 
193  lfn_ = fileIter_->logicalFileName().empty() ? fileIter_->fileName() : fileIter_->logicalFileName();
194  lfnHash_ = std::hash<std::string>()(lfn_);
195  usedFallback_ = false;
196 
197  // Determine whether we have a fallback URL specified; if so, prepare it;
198  // Only valid if it is non-empty and differs from the original filename.
199  std::string fallbackName = fileIter_->fallbackFileName();
200  bool hasFallbackUrl = !fallbackName.empty() && fallbackName != fileIter_->fileName();
201 
202  std::shared_ptr<InputFile> filePtr;
203  std::list<std::string> originalInfo;
204  try {
205  std::unique_ptr<InputSource::FileOpenSentry>
206  sentry(inputType_ == InputType::Primary ? new InputSource::FileOpenSentry(input_, lfn_, usedFallback_) : 0);
207  filePtr.reset(new InputFile(gSystem->ExpandPathName(fileIter_->fileName().c_str()), " Initiating request to open file ", inputType_));
208  }
209  catch (cms::Exception const& e) {
210  if(!skipBadFiles) {
211  if(hasFallbackUrl) {
212  std::ostringstream out;
213  out << e.explainSelf();
214  std::string pfn(gSystem->ExpandPathName(fallbackName.c_str()));
215  InputFile::reportFallbackAttempt(pfn, fileIter_->logicalFileName(), out.str());
216  originalInfo = e.additionalInfo();
217  } else {
218  InputFile::reportSkippedFile(fileIter_->fileName(), fileIter_->logicalFileName());
219  Exception ex(errors::FileOpenError, "", e);
220  ex.addContext("Calling RootInputFileSequence::initFile()");
221  std::ostringstream out;
222  out << "Input file " << fileIter_->fileName() << " could not be opened.";
223  ex.addAdditionalInfo(out.str());
224  throw ex;
225  }
226  }
227  }
228  if(!filePtr && (hasFallbackUrl)) {
229  try {
230  usedFallback_ = true;
231  std::unique_ptr<InputSource::FileOpenSentry>
232  sentry(inputType_ == InputType::Primary ? new InputSource::FileOpenSentry(input_, lfn_, usedFallback_) : 0);
233  std::string fallbackFullName = gSystem->ExpandPathName(fallbackName.c_str());
234  StorageFactory *factory = StorageFactory::get();
235  if (factory) {factory->activateTimeout(fallbackFullName);}
236  filePtr.reset(new InputFile(fallbackFullName.c_str(), " Fallback request to file ", inputType_));
237  }
238  catch (cms::Exception const& e) {
239  if(!skipBadFiles) {
240  InputFile::reportSkippedFile(fileIter_->fileName(), fileIter_->logicalFileName());
242  ex.addContext("Calling RootInputFileSequence::initFile()");
243  std::ostringstream out;
244  out << "Input file " << fileIter_->fileName() << " could not be opened.\n";
245  out << "Fallback Input file " << fallbackName << " also could not be opened.";
246  if (originalInfo.size()) {
247  out << std::endl << "Original exception info is above; fallback exception info is below.";
248  ex.addAdditionalInfo(out.str());
249  for (auto const & s : originalInfo) {
250  ex.addAdditionalInfo(s);
251  }
252  } else {
253  ex.addAdditionalInfo(out.str());
254  }
255  throw ex;
256  }
257  }
258  }
259  if(filePtr) {
260  std::vector<std::shared_ptr<IndexIntoFile> >::size_type currentIndexIntoFile = fileIter_ - fileIterBegin_;
261  rootFile_ = RootFileSharedPtr(new RootFile(
262  fileIter_->fileName(),
264  fileIter_->logicalFileName(),
265  filePtr,
268  remainingEvents(),
270  nStreams_,
274  setRun_,
275  noEventSort_,
277  inputType_,
278  (inputType_ == InputType::SecondarySource ? std::make_shared<BranchIDListHelper>() : input_.branchIDListHelper()),
279  (inputType_ == InputType::SecondarySource ? std::shared_ptr<ThinnedAssociationsHelper>() : input_.thinnedAssociationsHelper()),
285  currentIndexIntoFile,
291 
292  assert(rootFile_);
294  indexesIntoFiles_[currentIndexIntoFile] = rootFile_->indexIntoFileSharedPtr();
295  char const* inputType = 0;
296  switch(inputType_) {
297  case InputType::Primary: inputType = "primaryFiles"; break;
298  case InputType::SecondaryFile: inputType = "secondaryFiles"; break;
299  case InputType::SecondarySource: inputType = "mixingFiles"; break;
300  }
301  rootFile_->reportOpened(inputType);
302  } else {
303  InputFile::reportSkippedFile(fileIter_->fileName(), fileIter_->logicalFileName());
304  if(!skipBadFiles) {
306  "RootInputFileSequence::initFile(): Input file " << fileIter_->fileName() << " was not found or could not be opened.\n";
307  }
308  LogWarning("") << "Input file: " << fileIter_->fileName() << " was not found or could not be opened, and will be skipped.\n";
309  }
310  }
list pfn
Definition: dbtoconf.py:76
ProductSelectorRules productSelectorRules_
ProcessConfiguration const & processConfiguration() const
virtual std::string explainSelf() const
Definition: Exception.cc:146
std::vector< FileCatalogItem >::const_iterator fileIter_
std::shared_ptr< EventSkipperByID > eventSkipperByID_
assert(m_qm.get())
std::shared_ptr< ThinnedAssociationsHelper > thinnedAssociationsHelper() const
Accessor for thinnedAssociationsHelper.
Definition: InputSource.h:181
ProcessingMode processingMode() const
RunsLumisAndEvents (default), RunsAndLumis, or Runs.
Definition: InputSource.h:257
uint16_t size_type
std::list< std::string > const & additionalInfo() const
Definition: Exception.cc:195
static StorageFactory * get(void)
std::shared_ptr< RootFile > RootFileSharedPtr
tuple InputFile
Open Root file and provide MEs ############.
std::vector< BranchID > associationsFromSecondary_
static void reportFallbackAttempt(std::string const &pfn, std::string const &logicalFileName, std::string const &errorMessage)
Definition: InputFile.cc:86
std::shared_ptr< DuplicateChecker > duplicateChecker_
std::vector< FileCatalogItem >::const_iterator fileIterLastOpened_
std::shared_ptr< BranchIDListHelper > branchIDListHelper() const
Accessor for branchIDListHelper.
Definition: InputSource.h:178
static void reportSkippedFile(std::string const &fileName, std::string const &logicalFileName)
Definition: InputFile.cc:80
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
tuple out
Definition: dbtoconf.py:99
std::vector< ProcessHistoryID > orderedProcessHistoryIDs_
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
tuple skipBadFiles
Definition: example_cfg.py:64
ProcessHistoryRegistry & processHistoryRegistryForUpdate()
void activateTimeout(const std::string &url)
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
bool edm::RootInputFileSequence::nextFile ( )
private

Definition at line 324 of file RootInputFileSequence.cc.

References branchesMustMatch_, edm::hlt::Exception, fileIter_, fileIterBegin_, fileIterEnd_, initFile(), inputType_, edm::ProductRegistry::merge(), edm::errors::MismatchedInputFiles, edm::Primary, productRegistryUpdate(), rootFile_, skipBadFiles_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by readFile_(), and skipEvents().

324  {
326  if(fileIter_ == fileIterEnd_) {
328  return false;
329  } else {
331  }
332  }
333 
335 
337  // make sure the new product registry is compatible with the main one
338  std::string mergeInfo = productRegistryUpdate().merge(*rootFile_->productRegistry(),
339  fileIter_->fileName(),
341  if(!mergeInfo.empty()) {
342  throw Exception(errors::MismatchedInputFiles,"RootInputFileSequence::nextFile()") << mergeInfo;
343  }
344  }
345  return true;
346  }
void initFile(bool skipBadFiles)
std::vector< FileCatalogItem >::const_iterator fileIter_
ProductRegistry & productRegistryUpdate() const
std::string merge(ProductRegistry const &other, std::string const &fileName, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
BranchDescription::MatchMode branchesMustMatch_
RootInputFileSequence& edm::RootInputFileSequence::operator= ( RootInputFileSequence const &  )
delete
bool edm::RootInputFileSequence::previousFile ( )
private

Definition at line 348 of file RootInputFileSequence.cc.

References branchesMustMatch_, edm::hlt::Exception, fileIter_, fileIterBegin_, fileIterEnd_, initFile(), inputType_, edm::ProductRegistry::merge(), edm::errors::MismatchedInputFiles, edm::Primary, productRegistryUpdate(), rootFile_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by skipEvents().

348  {
349  if(fileIter_ == fileIterBegin_) {
351  return false;
352  } else {
354  }
355  }
356  --fileIter_;
357 
358  initFile(false);
359 
361  // make sure the new product registry is compatible to the main one
362  std::string mergeInfo = productRegistryUpdate().merge(*rootFile_->productRegistry(),
363  fileIter_->fileName(),
365  if(!mergeInfo.empty()) {
366  throw Exception(errors::MismatchedInputFiles,"RootInputFileSequence::previousEvent()") << mergeInfo;
367  }
368  }
369  if(rootFile_) rootFile_->setToLastEntry();
370  return true;
371  }
void initFile(bool skipBadFiles)
std::vector< FileCatalogItem >::const_iterator fileIter_
ProductRegistry & productRegistryUpdate() const
std::string merge(ProductRegistry const &other, std::string const &fileName, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
BranchDescription::MatchMode branchesMustMatch_
ProcessConfiguration const & edm::RootInputFileSequence::processConfiguration ( ) const
private

Definition at line 645 of file RootInputFileSequence.cc.

References input_, and edm::InputSource::processConfiguration().

Referenced by initFile().

645  {
646  return input_.processConfiguration();
647  }
ProcessConfiguration const & processConfiguration() const
Accessor for Process Configuration.
Definition: InputSource.h:212
ProcessHistoryRegistry const & edm::RootInputFileSequence::processHistoryRegistry ( ) const

Definition at line 635 of file RootInputFileSequence.cc.

References input_, and edm::InputSource::processHistoryRegistry().

635  {
637  }
ProcessHistoryRegistry const & processHistoryRegistry() const
Const accessor for process history registry.
Definition: InputSource.h:172
ProcessHistoryRegistry & edm::RootInputFileSequence::processHistoryRegistryForUpdate ( )

Definition at line 640 of file RootInputFileSequence.cc.

References input_, and edm::InputSource::processHistoryRegistryForUpdate().

Referenced by initFile().

640  {
642  }
ProcessHistoryRegistry & processHistoryRegistryForUpdate()
Non-const accessor for process history registry.
Definition: InputSource.h:175
std::shared_ptr< ProductRegistry const > edm::RootInputFileSequence::productRegistry ( ) const
private

Definition at line 665 of file RootInputFileSequence.cc.

References input_, and edm::InputSource::productRegistry().

665  {
666  return input_.productRegistry();
667  }
std::shared_ptr< ProductRegistry const > productRegistry() const
Accessor for product registry.
Definition: InputSource.h:169
ProductRegistry & edm::RootInputFileSequence::productRegistryUpdate ( ) const
private

Definition at line 660 of file RootInputFileSequence.cc.

References input_, and edm::InputSource::productRegistryUpdate().

Referenced by nextFile(), previousFile(), and RootInputFileSequence().

660  {
661  return input_.productRegistryUpdate();
662  }
ProductRegistry & productRegistryUpdate() const
Definition: InputSource.h:351
void edm::RootInputFileSequence::readEvent ( EventPrincipal cache)

Definition at line 414 of file RootInputFileSequence.cc.

References assert(), and rootFile_.

414  {
415  assert(rootFile_);
416  rootFile_->readEvent(eventPrincipal);
417  }
assert(m_qm.get())
std::unique_ptr< FileBlock > edm::RootInputFileSequence::readFile_ ( )

Definition at line 121 of file RootInputFileSequence.cc.

References assert(), firstFile_, initFile(), nextFile(), rootFile_, and skipBadFiles_.

121  {
122  if(firstFile_) {
123  // The first input file has already been opened.
124  firstFile_ = false;
125  if(!rootFile_) {
127  }
128  } else {
129  if(!nextFile()) {
130  assert(0);
131  }
132  }
133  if(!rootFile_) {
134  return std::unique_ptr<FileBlock>(new FileBlock);
135  }
136  return rootFile_->createFileBlock();
137  }
void initFile(bool skipBadFiles)
assert(m_qm.get())
void edm::RootInputFileSequence::readLuminosityBlock_ ( LuminosityBlockPrincipal lumiPrincipal)

Definition at line 395 of file RootInputFileSequence.cc.

References assert(), and rootFile_.

395  {
396  assert(rootFile_);
397  rootFile_->readLuminosityBlock_(lumiPrincipal);
398  }
assert(m_qm.get())
std::shared_ptr< LuminosityBlockAuxiliary > edm::RootInputFileSequence::readLuminosityBlockAuxiliary_ ( )

Definition at line 383 of file RootInputFileSequence.cc.

References assert(), and rootFile_.

383  {
384  assert(rootFile_);
385  return rootFile_->readLuminosityBlockAuxiliary_();
386  }
assert(m_qm.get())
void edm::RootInputFileSequence::readOneRandom ( EventPrincipal cache,
size_t &  fileNameHash,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 764 of file RootInputFileSequence.cc.

References assert(), edm::errors::Configuration, eventsRemainingInFile_, edm::hlt::Exception, fileCatalogItems(), fileIter_, fileIterBegin_, fileIterEnd_, newFWLiteAna::found, initFile(), lfnHash_, edm::errors::NotFound, rootFile_, findQualityFiles::size, and skipBadFiles_.

764  {
766  throw Exception(errors::Configuration) << "RootInputFileSequence::readOneRandom(): no input files specified for secondary input source.\n";
767  }
768  assert(rootFile_);
769  skipBadFiles_ = false;
770  unsigned int currentSeqNumber = fileIter_ - fileIterBegin_;
771  while(eventsRemainingInFile_ == 0) {
772 
773  fileIter_ = fileIterBegin_ + CLHEP::RandFlat::shootInt(engine, fileCatalogItems().size());
774  unsigned int newSeqNumber = fileIter_ - fileIterBegin_;
775  if(newSeqNumber != currentSeqNumber) {
776  initFile(false);
777  currentSeqNumber = newSeqNumber;
778  }
779  eventsRemainingInFile_ = rootFile_->eventTree().entries();
780  if(eventsRemainingInFile_ == 0) {
781  throw Exception(errors::NotFound) <<
782  "RootInputFileSequence::readOneRandom(): Secondary Input file " << fileIter_->fileName() << " contains no events.\n";
783  }
784  rootFile_->setAtEventEntry(CLHEP::RandFlat::shootInt(engine, eventsRemainingInFile_) - 1);
785  }
786  rootFile_->nextEventEntry();
787 
788  bool found = rootFile_->readCurrentEvent(cache);
789  if(!found) {
790  rootFile_->setAtEventEntry(0);
791  bool found = rootFile_->readCurrentEvent(cache);
792  assert(found);
793  }
794  fileNameHash = lfnHash_;
796  }
void initFile(bool skipBadFiles)
std::vector< FileCatalogItem >::const_iterator fileIter_
assert(m_qm.get())
std::vector< FileCatalogItem > const & fileCatalogItems() const
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
tuple size
Write out results.
bool edm::RootInputFileSequence::readOneRandomWithID ( EventPrincipal cache,
size_t &  fileNameHash,
LuminosityBlockID const &  id,
CLHEP::HepRandomEngine *  engine 
)

Definition at line 801 of file RootInputFileSequence.cc.

References assert(), edm::errors::Configuration, edm::hlt::Exception, fileIter_, fileIterBegin_, fileIterEnd_, newFWLiteAna::found, i, lfnHash_, rootFile_, DTTTrigCorrFirst::run, skipBadFiles_, and skipToItem().

801  {
803  throw Exception(errors::Configuration) << "RootInputFileSequence::readOneRandomWithID(): no input files specified for secondary input source.\n";
804  }
805  skipBadFiles_ = false;
806  if(fileIter_ == fileIterEnd_ || !rootFile_ ||
807  rootFile_->indexIntoFileIter().run() != id.run() ||
808  rootFile_->indexIntoFileIter().lumi() != id.luminosityBlock()) {
809  bool found = skipToItem(id.run(), id.luminosityBlock(), 0);
810  if(!found) {
811  return false;
812  }
813  int eventsInLumi = 0;
814  assert(rootFile_);
815  while(rootFile_->setEntryAtNextEventInLumi(id.run(), id.luminosityBlock())) ++eventsInLumi;
816  found = skipToItem(id.run(), id.luminosityBlock(), 0);
817  assert(found);
818  int eventInLumi = CLHEP::RandFlat::shootInt(engine, eventsInLumi);
819  for(int i = 0; i < eventInLumi; ++i) {
820  bool found = rootFile_->setEntryAtNextEventInLumi(id.run(), id.luminosityBlock());
821  assert(found);
822  }
823  }
824  assert(rootFile_);
825  bool found = rootFile_->setEntryAtNextEventInLumi(id.run(), id.luminosityBlock());
826  if(found) {
827  found = rootFile_->readCurrentEvent(cache);
828  }
829  if(!found) {
830  bool found = rootFile_->setEntryAtItem(id.run(), id.luminosityBlock(), 0);
831  if(!found) {
832  return false;
833  }
834  return readOneRandomWithID(cache, fileNameHash, id, engine);
835  }
836  fileNameHash = lfnHash_;
837  return true;
838  }
int i
Definition: DBlmapReader.cc:9
std::vector< FileCatalogItem >::const_iterator fileIter_
assert(m_qm.get())
bool readOneRandomWithID(EventPrincipal &cache, size_t &fileNameHash, LuminosityBlockID const &id, CLHEP::HepRandomEngine *)
bool skipToItem(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, size_t fileNameHash=0U, bool currentFileFirst=true)
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
bool edm::RootInputFileSequence::readOneSequential ( EventPrincipal cache,
size_t &  fileNameHash 
)

Definition at line 683 of file RootInputFileSequence.cc.

References assert(), edm::errors::Configuration, edm::hlt::Exception, fileIter_, fileIterBegin_, fileIterEnd_, newFWLiteAna::found, initFile(), edm::IndexIntoFile::invalidEntry, lfnHash_, rootFile_, and skipBadFiles_.

683  {
684  skipBadFiles_ = false;
685  if(fileIter_ == fileIterEnd_ || !rootFile_) {
687  throw Exception(errors::Configuration) << "RootInputFileSequence::readOneSequential(): no input files specified for secondary input source.\n";
688  }
690  initFile(false);
691  assert(rootFile_);
692  rootFile_->setAtEventEntry(IndexIntoFile::invalidEntry);
693  }
694  assert(rootFile_);
695  rootFile_->nextEventEntry();
696  bool found = rootFile_->readCurrentEvent(cache);
697  if(!found) {
698  ++fileIter_;
699  if(fileIter_ == fileIterEnd_) {
700  return false;
701  }
702  initFile(false);
703  assert(rootFile_);
704  rootFile_->setAtEventEntry(IndexIntoFile::invalidEntry);
705  return readOneSequential(cache, fileNameHash);
706  }
707  fileNameHash = lfnHash_;
708  return true;
709  }
void initFile(bool skipBadFiles)
std::vector< FileCatalogItem >::const_iterator fileIter_
assert(m_qm.get())
static EntryNumber_t const invalidEntry
bool readOneSequential(EventPrincipal &cache, size_t &fileNameHash)
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
bool edm::RootInputFileSequence::readOneSequentialWithID ( EventPrincipal cache,
size_t &  fileNameHash,
LuminosityBlockID const &  id 
)

Definition at line 712 of file RootInputFileSequence.cc.

References assert(), edm::errors::Configuration, edm::hlt::Exception, fileIter_, fileIterBegin_, fileIterEnd_, newFWLiteAna::found, lfnHash_, rootFile_, DTTTrigCorrFirst::run, skipBadFiles_, skipToItem(), and skipToItemInNewFile().

712  {
714  throw Exception(errors::Configuration) << "RootInputFileSequence::readOneSequentialWithID(): no input files specified for secondary input source.\n";
715  }
716  skipBadFiles_ = false;
717  if(fileIter_ == fileIterEnd_ || !rootFile_ ||
718  rootFile_->indexIntoFileIter().run() != id.run() ||
719  rootFile_->indexIntoFileIter().lumi() != id.luminosityBlock()) {
720  bool found = skipToItem(id.run(), id.luminosityBlock(), 0, 0, false);
721  if(!found) {
722  return false;
723  }
724  }
725  assert(rootFile_);
726  bool found = rootFile_->setEntryAtNextEventInLumi(id.run(), id.luminosityBlock());
727  if(found) {
728  found = rootFile_->readCurrentEvent(cache);
729  }
730  if(!found) {
731  found = skipToItemInNewFile(id.run(), id.luminosityBlock(), 0);
732  if(!found) {
733  return false;
734  }
735  return readOneSequentialWithID(cache, fileNameHash, id);
736  }
737  fileNameHash = lfnHash_;
738  return true;
739  }
std::vector< FileCatalogItem >::const_iterator fileIter_
assert(m_qm.get())
bool skipToItem(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, size_t fileNameHash=0U, bool currentFileFirst=true)
bool skipToItemInNewFile(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
bool readOneSequentialWithID(EventPrincipal &cache, size_t &fileNameHash, LuminosityBlockID const &id)
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
void edm::RootInputFileSequence::readOneSpecified ( EventPrincipal cache,
size_t &  fileNameHash,
SecondaryEventIDAndFileInfo const &  id 
)

Definition at line 742 of file RootInputFileSequence.cc.

References assert(), edm::errors::Configuration, event(), edm::SecondaryEventIDAndFileInfo::eventID(), edm::hlt::Exception, fileIterBegin_, fileIterEnd_, edm::SecondaryEventIDAndFileInfo::fileNameHash(), newFWLiteAna::found, lfnHash_, edm::errors::NotFound, rootFile_, DTTTrigCorrFirst::run, skipBadFiles_, and skipToItem().

742  {
744  throw Exception(errors::Configuration) << "RootInputFileSequence::readOneSpecified(): no input files specified for secondary input source.\n";
745  }
746  skipBadFiles_ = false;
747  EventID const& id = idx.eventID();
748  bool found = skipToItem(id.run(), id.luminosityBlock(), id.event(), idx.fileNameHash());
749  if(!found) {
750  throw Exception(errors::NotFound) <<
751  "RootInputFileSequence::readOneSpecified(): Secondary Input files" <<
752  " do not contain specified event:\n" << id << "\n";
753  }
754  assert(rootFile_);
755  found = rootFile_->readCurrentEvent(cache);
756  assert(found);
757  fileNameHash = idx.fileNameHash();
758  if(fileNameHash == 0U) {
759  fileNameHash = lfnHash_;
760  }
761  }
assert(m_qm.get())
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool skipToItem(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, size_t fileNameHash=0U, bool currentFileFirst=true)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
void edm::RootInputFileSequence::readRun_ ( RunPrincipal runPrincipal)

Definition at line 389 of file RootInputFileSequence.cc.

References assert(), and rootFile_.

389  {
390  assert(rootFile_);
391  rootFile_->readRun_(runPrincipal);
392  }
assert(m_qm.get())
std::shared_ptr< RunAuxiliary > edm::RootInputFileSequence::readRunAuxiliary_ ( )

Definition at line 377 of file RootInputFileSequence.cc.

References assert(), and rootFile_.

377  {
378  assert(rootFile_);
379  return rootFile_->readRunAuxiliary_();
380  }
assert(m_qm.get())
int edm::RootInputFileSequence::remainingEvents ( ) const
private

Definition at line 650 of file RootInputFileSequence.cc.

References input_, and edm::InputSource::remainingEvents().

Referenced by initFile().

650  {
651  return input_.remainingEvents();
652  }
int remainingEvents() const
Definition: InputSource.h:198
int edm::RootInputFileSequence::remainingLuminosityBlocks ( ) const
private

Definition at line 655 of file RootInputFileSequence.cc.

References input_, and edm::InputSource::remainingLuminosityBlocks().

Referenced by initFile().

655  {
657  }
int remainingLuminosityBlocks() const
Definition: InputSource.h:206
ProcessingController::ReverseState edm::RootInputFileSequence::reverseState ( ) const
void edm::RootInputFileSequence::rewind_ ( )

Definition at line 452 of file RootInputFileSequence.cc.

References closeFile_(), fileIter_, fileIterBegin_, firstFile_, initFile(), initialNumberOfEventsToSkip_, rewindFile(), rootFile_, and skipEvents().

452  {
453  if(fileIter_ != fileIterBegin_) {
454  closeFile_();
456  }
457  if(!rootFile_) {
458  initFile(false);
459  }
460  rewindFile();
461  firstFile_ = true;
462  if(rootFile_) {
465  }
466  }
467  }
void initFile(bool skipBadFiles)
std::vector< FileCatalogItem >::const_iterator fileIter_
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
void edm::RootInputFileSequence::rewindFile ( )
private

Definition at line 471 of file RootInputFileSequence.cc.

References rootFile_.

Referenced by rewind_().

471  {
472  if(rootFile_) rootFile_->rewind();
473  }
bool edm::RootInputFileSequence::skipEvents ( int  offset)

Definition at line 477 of file RootInputFileSequence.cc.

References assert(), fileIter_, fileIterEnd_, inputType_, nextFile(), previousFile(), rootFile_, and edm::SecondaryFile.

Referenced by rewind_(), and RootInputFileSequence().

477  {
478  // We never call skipEvents for secondary input files. If we did,
479  // we would have to implement synchronization if a new file is opened.
480  // To avoid this, just assert.
482  assert(rootFile_);
483  while(offset != 0) {
484  bool atEnd = rootFile_->skipEvents(offset);
485  if((offset > 0 || atEnd) && !nextFile()) {
486  return false;
487  }
488  if(offset < 0 && !previousFile()) {
490  return false;
491  }
492  }
493  return true;
494  }
std::vector< FileCatalogItem >::const_iterator fileIter_
assert(m_qm.get())
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
bool edm::RootInputFileSequence::skipToItem ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event,
size_t  fileNameHash = 0U,
bool  currentFileFirst = true 
)

Definition at line 604 of file RootInputFileSequence.cc.

References assert(), fileIter_, fileIterBegin_, newFWLiteAna::found, indexesIntoFiles_, initFile(), rootFile_, and skipToItemInNewFile().

Referenced by readOneRandomWithID(), readOneSequentialWithID(), and readOneSpecified().

604  {
605  // Attempt to find item in currently open input file.
606  bool found = currentFileFirst && rootFile_ && rootFile_->setEntryAtItem(run, lumi, event);
607  if(!found) {
608  // If only one input file, give up now, to save time.
609  if(currentFileFirst && rootFile_ && indexesIntoFiles_.size() == 1) {
610  return false;
611  }
612  // Look for item (run/lumi/event) in files previously opened without reopening unnecessary files.
613  typedef std::vector<std::shared_ptr<IndexIntoFile> >::const_iterator Iter;
614  for(Iter it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) {
615  if(*it && (*it)->containsItem(run, lumi, event)) {
616  // We found it. Close the currently open file, and open the correct one.
617  std::vector<FileCatalogItem>::const_iterator currentIter = fileIter_;
618  fileIter_ = fileIterBegin_ + (it - indexesIntoFiles_.begin());
619  if(fileIter_ != currentIter) {
620  initFile(false);
621  }
622  // Now get the item from the correct file.
623  assert(rootFile_);
624  found = rootFile_->setEntryAtItem(run, lumi, event);
625  assert(found);
626  return true;
627  }
628  }
629  return (fileNameHash != 0U && skipToItemInNewFile(run, lumi, event, fileNameHash)) || skipToItemInNewFile(run, lumi, event);
630  }
631  return true;
632  }
void initFile(bool skipBadFiles)
std::vector< FileCatalogItem >::const_iterator fileIter_
tuple lumi
Definition: fjr2json.py:35
assert(m_qm.get())
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
bool skipToItemInNewFile(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
bool edm::RootInputFileSequence::skipToItemInNewFile ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
)

Definition at line 584 of file RootInputFileSequence.cc.

References assert(), fileIter_, fileIterBegin_, newFWLiteAna::found, indexesIntoFiles_, initFile(), and rootFile_.

Referenced by readOneSequentialWithID(), and skipToItem().

584  {
585  // Look for item in files not yet opened. We do not have a valid hash of the logical file name.
586  typedef std::vector<std::shared_ptr<IndexIntoFile> >::const_iterator Iter;
587  for(Iter it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) {
588  if(!*it) {
589  // File not yet opened.
590  fileIter_ = fileIterBegin_ + (it - indexesIntoFiles_.begin());
591  initFile(false);
592  assert(rootFile_);
593  bool found = rootFile_->setEntryAtItem(run, lumi, event);
594  if(found) {
595  return true;
596  }
597  }
598  }
599  // Not found
600  return false;
601  }
void initFile(bool skipBadFiles)
std::vector< FileCatalogItem >::const_iterator fileIter_
tuple lumi
Definition: fjr2json.py:35
assert(m_qm.get())
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
bool edm::RootInputFileSequence::skipToItemInNewFile ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event,
size_t  fileNameHash 
)

Definition at line 552 of file RootInputFileSequence.cc.

References assert(), fileIter_, fileIterBegin_, fileIterEnd_, findFileForSpecifiedID_, newFWLiteAna::found, indexesIntoFiles_, initFile(), getDQMSummary::iter, and rootFile_.

552  {
553  // Look for item in files not yet opened. We have a hash of the logical file name
554  assert(fileNameHash != 0U);
555  // If the lookup table is not yet filled in, fill it.
557  // We use a multimap because there may be hash collisions (Two different LFNs could have the same hash).
558  // We map the hash of the LFN to the index into the list of files.
559  findFileForSpecifiedID_.reset(new std::unordered_multimap<size_t, size_t>);
560  auto hasher = std::hash<std::string>();
561  for(auto fileIter = fileIterBegin_; fileIter != fileIterEnd_; ++fileIter) {
562  findFileForSpecifiedID_->insert(std::make_pair(hasher(fileIter->logicalFileName()), fileIter - fileIterBegin_));
563  }
564  }
565  // Look up the logical file name in the table
566  auto range = findFileForSpecifiedID_->equal_range(fileNameHash);
567  for(auto iter = range.first; iter != range.second; ++iter) {
568  // Don't look in files previously opened, because those have already been searched.
569  if(!indexesIntoFiles_[iter->second]) {
570  fileIter_ = fileIterBegin_ + iter->second;
571  initFile(false);
572  assert(rootFile_);
573  bool found = rootFile_->setEntryAtItem(run, lumi, event);
574  if(found) {
575  return true;
576  }
577  }
578  }
579  // Not found
580  return false;
581  }
void initFile(bool skipBadFiles)
std::vector< FileCatalogItem >::const_iterator fileIter_
tuple lumi
Definition: fjr2json.py:35
assert(m_qm.get())
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
std::unique_ptr< std::unordered_multimap< size_t, size_t > > findFileForSpecifiedID_
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
std::vector< FileCatalogItem >::const_iterator fileIterEnd_

Member Data Documentation

std::vector<BranchID> edm::RootInputFileSequence::associationsFromSecondary_
private

Definition at line 113 of file RootInputFileSequence.h.

Referenced by initAssociationsFromSecondary(), and initFile().

BranchDescription::MatchMode edm::RootInputFileSequence::branchesMustMatch_
private

Definition at line 109 of file RootInputFileSequence.h.

Referenced by nextFile(), previousFile(), and RootInputFileSequence().

bool edm::RootInputFileSequence::bypassVersionCheck_
private

Definition at line 121 of file RootInputFileSequence.h.

Referenced by initFile().

InputFileCatalog const& edm::RootInputFileSequence::catalog_
private

Definition at line 99 of file RootInputFileSequence.h.

Referenced by fileCatalogItems().

bool edm::RootInputFileSequence::dropDescendants_
private

Definition at line 127 of file RootInputFileSequence.h.

Referenced by initFile().

std::shared_ptr<DuplicateChecker> edm::RootInputFileSequence::duplicateChecker_
private

Definition at line 126 of file RootInputFileSequence.h.

Referenced by closeFile_(), and initFile().

bool edm::RootInputFileSequence::enablePrefetching_
private

Definition at line 130 of file RootInputFileSequence.h.

Referenced by initFile(), and RootInputFileSequence().

std::shared_ptr<EventSkipperByID> edm::RootInputFileSequence::eventSkipperByID_
private

Definition at line 116 of file RootInputFileSequence.h.

Referenced by initFile().

int edm::RootInputFileSequence::eventsRemainingInFile_
private

Definition at line 117 of file RootInputFileSequence.h.

Referenced by readOneRandom().

std::vector<FileCatalogItem>::const_iterator edm::RootInputFileSequence::fileIter_
private
std::vector<FileCatalogItem>::const_iterator edm::RootInputFileSequence::fileIterBegin_
private
std::vector<FileCatalogItem>::const_iterator edm::RootInputFileSequence::fileIterEnd_
private
std::vector<FileCatalogItem>::const_iterator edm::RootInputFileSequence::fileIterLastOpened_
private

Definition at line 107 of file RootInputFileSequence.h.

Referenced by initFile().

std::unique_ptr<std::unordered_multimap<size_t, size_t> > edm::RootInputFileSequence::findFileForSpecifiedID_
private

Definition at line 103 of file RootInputFileSequence.h.

Referenced by skipToItemInNewFile().

bool edm::RootInputFileSequence::firstFile_
private

Definition at line 100 of file RootInputFileSequence.h.

Referenced by getNextItemType(), readFile_(), and rewind_().

std::vector<std::shared_ptr<IndexIntoFile> > edm::RootInputFileSequence::indexesIntoFiles_
private

Definition at line 111 of file RootInputFileSequence.h.

Referenced by goToEvent(), initFile(), skipToItem(), and skipToItemInNewFile().

int edm::RootInputFileSequence::initialNumberOfEventsToSkip_
private

Definition at line 118 of file RootInputFileSequence.h.

Referenced by initFile(), rewind_(), and RootInputFileSequence().

PoolSource& edm::RootInputFileSequence::input_
private
InputType edm::RootInputFileSequence::inputType_
private
bool edm::RootInputFileSequence::labelRawDataLikeMC_
private

Definition at line 128 of file RootInputFileSequence.h.

Referenced by initFile().

std::string edm::RootInputFileSequence::lfn_
private

Definition at line 101 of file RootInputFileSequence.h.

Referenced by closeFile_(), and initFile().

size_t edm::RootInputFileSequence::lfnHash_
private
bool edm::RootInputFileSequence::noEventSort_
private

Definition at line 119 of file RootInputFileSequence.h.

Referenced by initFile().

unsigned int edm::RootInputFileSequence::nStreams_
private

Definition at line 115 of file RootInputFileSequence.h.

Referenced by initFile().

std::vector<ProcessHistoryID> edm::RootInputFileSequence::orderedProcessHistoryIDs_
private

Definition at line 112 of file RootInputFileSequence.h.

Referenced by initFile().

ProductSelectorRules edm::RootInputFileSequence::productSelectorRules_
private

Definition at line 125 of file RootInputFileSequence.h.

Referenced by dropUnwantedBranches_(), and initFile().

RootFileSharedPtr edm::RootInputFileSequence::rootFile_
private
RunNumber_t edm::RootInputFileSequence::setRun_
private

Definition at line 124 of file RootInputFileSequence.h.

Referenced by initFile().

bool edm::RootInputFileSequence::skipBadFiles_
private
unsigned int edm::RootInputFileSequence::treeCacheSize_
private

Definition at line 122 of file RootInputFileSequence.h.

Referenced by initFile(), and RootInputFileSequence().

int const edm::RootInputFileSequence::treeMaxVirtualSize_
private

Definition at line 123 of file RootInputFileSequence.h.

Referenced by initFile().

bool edm::RootInputFileSequence::usedFallback_
private

Definition at line 131 of file RootInputFileSequence.h.

Referenced by closeFile_(), and initFile().

bool edm::RootInputFileSequence::usingGoToEvent_
private

Definition at line 129 of file RootInputFileSequence.h.

Referenced by goToEvent(), and initFile().