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 boost::shared_ptr
< RootFile
RootFileSharedPtr
 

Public Member Functions

void closeFile_ ()
 
void dropUnwantedBranches_ (std::vector< std::string > const &wantedBranches)
 
void endJob ()
 
boost::shared_ptr
< ProductRegistry const > 
fileProductRegistry () const
 
ProcessingController::ForwardState forwardState () const
 
InputSource::ItemType getNextItemType ()
 
bool goToEvent (EventID const &eventID)
 
RootInputFileSequenceoperator= (RootInputFileSequence const &)=delete
 
EventPrincipalreadEvent (EventPrincipal &cache, boost::shared_ptr< LuminosityBlockPrincipal > lb)
 
boost::shared_ptr< FileBlockreadFile_ (PrincipalCache &cache)
 
boost::shared_ptr
< LuminosityBlockPrincipal
readLuminosityBlock_ (boost::shared_ptr< LuminosityBlockPrincipal > lbCache)
 
boost::shared_ptr
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary_ ()
 
EventPrincipalreadOneRandom ()
 
EventPrincipalreadOneRandomWithID (LuminosityBlockID const &id)
 
EventPrincipalreadOneSequential ()
 
EventPrincipalreadOneSequentialWithID (LuminosityBlockID const &id)
 
EventPrincipalreadOneSpecified (EventID const &id)
 
boost::shared_ptr< RunPrincipalreadRun_ (boost::shared_ptr< RunPrincipal > rpCache)
 
boost::shared_ptr< RunAuxiliaryreadRunAuxiliary_ ()
 
void reset (PrincipalCache &cache)
 
ProcessingController::ReverseState reverseState () const
 
void rewind_ ()
 
 RootInputFileSequence (ParameterSet const &pset, PoolSource const &input, InputFileCatalog const &catalog, PrincipalCache &cache, InputType::InputType inputType)
 
 RootInputFileSequence (RootInputFileSequence const &)=delete
 
bool skipEvents (int offset, PrincipalCache &cache)
 
bool skipToItem (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, bool currentFileFirst=true)
 
bool skipToItemInNewFile (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
 
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 (PrincipalCache &cache)
 
bool previousFile (PrincipalCache &cache)
 
ProcessConfiguration const & processConfiguration () const
 
boost::shared_ptr
< ProductRegistry const > 
productRegistry () const
 
ProductRegistryproductRegistryUpdate () const
 
int remainingEvents () const
 
int remainingLuminosityBlocks () const
 
void rewindFile ()
 

Private Attributes

BranchDescription::MatchMode branchesMustMatch_
 
bool bypassVersionCheck_
 
InputFileCatalog const & catalog_
 
bool dropDescendants_
 
boost::shared_ptr
< DuplicateChecker
duplicateChecker_
 
boost::shared_ptr
< EventSkipperByID
eventSkipperByID_
 
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_
 
bool firstFile_
 
std::unique_ptr< CLHEP::RandFlat > flatDistribution_
 
GroupSelectorRules groupSelectorRules_
 
std::vector< boost::shared_ptr
< IndexIntoFile > > 
indexesIntoFiles_
 
PoolSource const & input_
 
InputType::InputType inputType_
 
bool labelRawDataLikeMC_
 
bool noEventSort_
 
int numberOfEventsToSkip_
 
std::vector< ProcessHistoryIDorderedProcessHistoryIDs_
 
BranchDescription::MatchMode parametersMustMatch_
 
RootFileSharedPtr rootFile_
 
RunNumber_t setRun_
 
bool skipBadFiles_
 
unsigned int treeCacheSize_
 
int const treeMaxVirtualSize_
 
bool usingGoToEvent_
 

Detailed Description

Definition at line 38 of file RootInputFileSequence.h.

Member Typedef Documentation

Definition at line 46 of file RootInputFileSequence.h.

Constructor & Destructor Documentation

edm::RootInputFileSequence::RootInputFileSequence ( ParameterSet const &  pset,
PoolSource const &  input,
InputFileCatalog const &  catalog,
PrincipalCache cache,
InputType::InputType  inputType 
)
explicit

Definition at line 26 of file RootInputFileSequence.cc.

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

31  :
32  input_(input),
33  inputType_(inputType),
35  firstFile_(true),
40  rootFile_(),
48  // The default value provided as the second argument to the getUntrackedParameter function call
49  // is not used when the ParameterSet has been validated and the parameters are not optional
50  // in the description. This is currently true when PoolSource is the primary input source.
51  // The modules that use PoolSource as a SecSource have not defined their fillDescriptions function
52  // yet, so the ParameterSet does not get validated yet. As soon as all the modules with a SecSource
53  // have defined descriptions, the defaults in the getUntrackedParameterSet function calls can
54  // and should be deleted from the code.
55  numberOfEventsToSkip_(inputType == InputType::Primary ? pset.getUntrackedParameter<unsigned int>("skipEvents", 0U) : 0U),
56  noEventSort_(inputType == InputType::Primary ? pset.getUntrackedParameter<bool>("noEventSort", true) : false),
57  skipBadFiles_(pset.getUntrackedParameter<bool>("skipBadFiles", false)),
58  bypassVersionCheck_(pset.getUntrackedParameter<bool>("bypassVersionCheck", false)),
59  treeCacheSize_(noEventSort_ ? pset.getUntrackedParameter<unsigned int>("cacheSize", roottree::defaultCacheSize) : 0U),
60  treeMaxVirtualSize_(pset.getUntrackedParameter<int>("treeMaxVirtualSize", -1)),
61  setRun_(pset.getUntrackedParameter<unsigned int>("setRunNumber", 0U)),
62  groupSelectorRules_(pset, "inputCommands", "InputSource"),
63  duplicateChecker_(inputType == InputType::Primary ? new DuplicateChecker(pset) : 0),
64  dropDescendants_(pset.getUntrackedParameter<bool>("dropDescendantsOfDroppedBranches", inputType != InputType::SecondarySource)),
65  labelRawDataLikeMC_(pset.getUntrackedParameter<bool>("labelRawDataLikeMC", true)),
66  usingGoToEvent_(false) {
67 
68  //we now allow the site local config to specify what the TTree cache size should be
70  if(treeCacheSize_ != 0U && pSLC.isAvailable() && pSLC->sourceTTreeCacheSize()) {
71  treeCacheSize_ = *(pSLC->sourceTTreeCacheSize());
72  }
73 
75  //NOTE: we do not want to stage in secondary files since we can be given a list of
76  // thousands of files and prestaging all those files can cause a site to fail
79  factory->activateTimeout(fileIter_->fileName());
80  factory->stagein(fileIter_->fileName());
81  }
82  }
83 
84  std::string parametersMustMatch = pset.getUntrackedParameter<std::string>("parametersMustMatch", std::string("permissive"));
85  if(parametersMustMatch == std::string("strict")) parametersMustMatch_ = BranchDescription::Strict;
86 
87  std::string branchesMustMatch = pset.getUntrackedParameter<std::string>("branchesMustMatch", std::string("permissive"));
88  if(branchesMustMatch == std::string("strict")) branchesMustMatch_ = BranchDescription::Strict;
89 
90  if(inputType != InputType::SecondarySource) {
93  if(rootFile_) break;
94  }
95  if(rootFile_) {
96  productRegistryUpdate().updateFromInput(rootFile_->productRegistry()->productList());
97  if(numberOfEventsToSkip_ != 0) {
99  }
100  }
101  }
102  }
std::vector< boost::shared_ptr< IndexIntoFile > > indexesIntoFiles_
void stagein(const std::string &url)
void initFile(bool skipBadFiles)
std::vector< FileCatalogItem >::const_iterator fileIter_
ProductRegistry & productRegistryUpdate() const
GroupSelectorRules groupSelectorRules_
unsigned int const defaultCacheSize
Definition: RootTree.h:34
bool skipEvents(int offset, PrincipalCache &cache)
static StorageFactory * get(void)
std::vector< FileCatalogItem >::const_iterator fileIterLastOpened_
std::vector< FileCatalogItem > const & fileCatalogItems() const
boost::shared_ptr< DuplicateChecker > duplicateChecker_
#define end
Definition: vmac.h:38
std::unique_ptr< CLHEP::RandFlat > flatDistribution_
std::vector< ProcessHistoryID > orderedProcessHistoryIDs_
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
#define begin
Definition: vmac.h:31
boost::shared_ptr< EventSkipperByID > eventSkipperByID_
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)
BranchDescription::MatchMode parametersMustMatch_
InputType::InputType inputType_
tuple size
Write out results.
InputFileCatalog const & catalog_
edm::RootInputFileSequence::~RootInputFileSequence ( )
virtual

Definition at line 339 of file RootInputFileSequence.cc.

339  {
340  }
edm::RootInputFileSequence::RootInputFileSequence ( RootInputFileSequence const &  )
delete

Member Function Documentation

void edm::RootInputFileSequence::closeFile_ ( )

Definition at line 133 of file RootInputFileSequence.cc.

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

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

133  {
134  // close the currently open file, if any, and delete the RootFile object.
135  if(rootFile_) {
137  std::unique_ptr<InputSource::FileCloseSentry>
138  sentry((inputType_ == InputType::Primary) ? new InputSource::FileCloseSentry(input_) : 0);
139  rootFile_->close();
140  if(duplicateChecker_) duplicateChecker_->inputFileClosed();
141  }
142  rootFile_.reset();
143  }
144  }
boost::shared_ptr< DuplicateChecker > duplicateChecker_
InputType::InputType inputType_
void edm::RootInputFileSequence::dropUnwantedBranches_ ( std::vector< std::string > const &  wantedBranches)

Definition at line 590 of file RootInputFileSequence.cc.

References edm::ParameterSet::addUntrackedParameter(), groupSelectorRules_, and cmsCodeRulesChecker::rules.

590  {
591  std::vector<std::string> rules;
592  rules.reserve(wantedBranches.size() + 1);
593  rules.emplace_back("drop *");
594  for(std::vector<std::string>::const_iterator it = wantedBranches.begin(), itEnd = wantedBranches.end();
595  it != itEnd; ++it) {
596  rules.push_back("keep " + *it + "_*");
597  }
598  ParameterSet pset;
599  pset.addUntrackedParameter("inputCommands", rules);
600  groupSelectorRules_ = GroupSelectorRules(pset, "inputCommands", "InputSource");
601  }
GroupSelectorRules groupSelectorRules_
void edm::RootInputFileSequence::endJob ( void  )

Definition at line 110 of file RootInputFileSequence.cc.

References closeFile_().

110  {
111  closeFile_();
112  }
std::vector< FileCatalogItem > const & edm::RootInputFileSequence::fileCatalogItems ( ) const
private

Definition at line 105 of file RootInputFileSequence.cc.

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

Referenced by readOneRandom().

105  {
106  return catalog_.fileCatalogItems();
107  }
std::vector< FileCatalogItem > const & fileCatalogItems() const
InputFileCatalog const & catalog_
boost::shared_ptr< ProductRegistry const > edm::RootInputFileSequence::fileProductRegistry ( ) const

Definition at line 273 of file RootInputFileSequence.cc.

References rootFile_.

273  {
274  assert(rootFile_);
275  return rootFile_->productRegistry();
276  }
void edm::RootInputFileSequence::fillDescription ( ParameterSetDescription desc)
static

Definition at line 750 of file RootInputFileSequence.cc.

References edm::ParameterSetDescription::addUntracked(), edm::roottree::defaultCacheSize, edm::EventSkipperByID::fillDescription(), edm::GroupSelectorRules::fillDescription(), and edm::DuplicateChecker::fillDescription().

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

750  {
751  desc.addUntracked<unsigned int>("skipEvents", 0U)
752  ->setComment("Skip the first 'skipEvents' events that otherwise would have been processed.");
753  desc.addUntracked<bool>("noEventSort", true)
754  ->setComment("True: Process runs, lumis and events in the order they appear in the file (but see notes 1 and 2).\n"
755  "False: Process runs, lumis and events in each file in numerical order (run#, lumi#, event#) (but see note 3).\n"
756  "Note 1: Events within the same lumi will always be processed contiguously.\n"
757  "Note 2: Lumis within the same run will always be processed contiguously.\n"
758  "Note 3: Any sorting occurs independently in each input file (no sorting across input files).");
759  desc.addUntracked<bool>("skipBadFiles", false)
760  ->setComment("True: Ignore any missing or unopenable input file.\n"
761  "False: Throw exception if missing or unopenable input file.");
762  desc.addUntracked<bool>("bypassVersionCheck", false)
763  ->setComment("True: Bypass release version check.\n"
764  "False: Throw exception if reading file in a release prior to the release in which the file was written.");
765  desc.addUntracked<unsigned int>("cacheSize", roottree::defaultCacheSize)
766  ->setComment("Size of ROOT TTree prefetch cache. Affects performance.");
767  desc.addUntracked<int>("treeMaxVirtualSize", -1)
768  ->setComment("Size of ROOT TTree TBasket cache. Affects performance.");
769  desc.addUntracked<unsigned int>("setRunNumber", 0U)
770  ->setComment("If non-zero, change number of first run to this number. Apply same offset to all runs. Allowed only for simulation.");
771  desc.addUntracked<bool>("dropDescendantsOfDroppedBranches", true)
772  ->setComment("If True, also drop on input any descendent of any branch dropped on input.");
773  std::string defaultString("permissive");
774  desc.addUntracked<std::string>("parametersMustMatch", defaultString)
775  ->setComment("'strict': Values of tracked parameters must be unique across all input files.\n"
776  "'permissive': Values of tracked parameters may differ across or within files.");
777  desc.addUntracked<std::string>("branchesMustMatch", defaultString)
778  ->setComment("'strict': Branches in each input file must match those in the first file.\n"
779  "'permissive': Branches in each input file may be any subset of those in the first file.");
780  desc.addUntracked<bool>("labelRawDataLikeMC", true)
781  ->setComment("If True: replace module label for raw data to match MC. Also use 'LHC' as process.");
782 
783  GroupSelectorRules::fillDescription(desc, "inputCommands");
786  }
static void fillDescription(ParameterSetDescription &desc)
static void fillDescription(ParameterSetDescription &desc, char const *parameterName)
unsigned int const defaultCacheSize
Definition: RootTree.h:34
static void fillDescription(ParameterSetDescription &desc)
ProcessingController::ForwardState edm::RootInputFileSequence::forwardState ( ) const
InputSource::ItemType edm::RootInputFileSequence::getNextItemType ( )

Definition at line 381 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_.

381  {
382  if(fileIter_ == fileIterEnd_) {
383  return InputSource::IsStop;
384  }
385  if(firstFile_) {
386  return InputSource::IsFile;
387  }
388  if(rootFile_) {
389  IndexIntoFile::EntryType entryType = rootFile_->getNextEntryTypeWanted();
390  if(entryType == IndexIntoFile::kEvent) {
391  return InputSource::IsEvent;
392  } else if(entryType == IndexIntoFile::kLumi) {
393  return InputSource::IsLumi;
394  } else if(entryType == IndexIntoFile::kRun) {
395  return InputSource::IsRun;
396  }
397  assert(entryType == IndexIntoFile::kEnd);
398  }
399  if(fileIter_ + 1 == fileIterEnd_) {
400  return InputSource::IsStop;
401  }
402  return InputSource::IsFile;
403  }
std::vector< FileCatalogItem >::const_iterator fileIter_
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
bool edm::RootInputFileSequence::goToEvent ( EventID const &  eventID)

Definition at line 464 of file RootInputFileSequence.cc.

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

464  {
465  usingGoToEvent_ = true;
466  if(rootFile_) {
467  if(rootFile_->goToEvent(eventID)) {
468  return true;
469  }
470  // If only one input file, give up now, to save time.
471  if(rootFile_ && indexesIntoFiles_.size() == 1) {
472  return false;
473  }
474  // Save the current file and position so that we can restore them
475  // if we fail to restore the desired event
476  bool closedOriginalFile = false;
477  std::vector<FileCatalogItem>::const_iterator originalFile = fileIter_;
478  IndexIntoFile::IndexIntoFileItr originalPosition = rootFile_->indexIntoFileIter();
479 
480  // Look for item (run/lumi/event) in files previously opened without reopening unnecessary files.
481  typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
482  for(Iter it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) {
483  if(*it && (*it)->containsItem(eventID.run(), eventID.luminosityBlock(), eventID.event())) {
484  // We found it. Close the currently open file, and open the correct one.
485  fileIter_ = fileIterBegin_ + (it - indexesIntoFiles_.begin());
486  initFile(false);
487  // Now get the item from the correct file.
488  bool found = rootFile_->goToEvent(eventID);
489  assert (found);
490  return true;
491  }
492  }
493  // Look for item in files not yet opened.
494  for(Iter it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) {
495  if(!*it) {
496  fileIter_ = fileIterBegin_ + (it - indexesIntoFiles_.begin());
497  initFile(false);
498  closedOriginalFile = true;
499  if((*it)->containsItem(eventID.run(), eventID.luminosityBlock(), eventID.event())) {
500  if (rootFile_->goToEvent(eventID)) {
501  return true;
502  }
503  }
504  }
505  }
506  if(closedOriginalFile) {
507  fileIter_ = originalFile;
508  initFile(false);
509  rootFile_->setPosition(originalPosition);
510  }
511  }
512  return false;
513  }
std::vector< boost::shared_ptr< IndexIntoFile > > indexesIntoFiles_
void initFile(bool skipBadFiles)
std::vector< FileCatalogItem >::const_iterator fileIter_
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
void edm::RootInputFileSequence::initFile ( bool  skipBadFiles)
private

Definition at line 146 of file RootInputFileSequence.cc.

References bypassVersionCheck_, closeFile_(), dropDescendants_, duplicateChecker_, alignCSCRings::e, eventSkipperByID_, edm::hlt::Exception, cms::Exception::explainSelf(), edm::errors::FallbackFileOpenError, fileIter_, fileIterBegin_, fileIterEnd_, fileIterLastOpened_, edm::errors::FileOpenError, groupSelectorRules_, indexesIntoFiles_, input_, RPC_Client_on_RootFile::InputFile, inputType_, labelRawDataLikeMC_, noEventSort_, numberOfEventsToSkip_, orderedProcessHistoryIDs_, dbtoconf::out, dbtoconf::pfn, edm::InputType::Primary, processConfiguration(), edm::InputSource::processingMode(), remainingEvents(), remainingLuminosityBlocks(), edm::InputFile::reportFallbackAttempt(), edm::InputFile::reportSkippedFile(), rootFile_, edm::InputType::SecondaryFile, edm::InputType::SecondarySource, setRun_, treeCacheSize_, treeMaxVirtualSize_, and usingGoToEvent_.

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

146  {
147  // We are really going to close the open file.
148 
149  // If this is the primary sequence, we are not duplicate checking across files
150  // and we are not using random access to find events, then we can delete the
151  // IndexIntoFile for the file we are closing. If we can't delete all of it,
152  // then we can delete the parts we do not need.
154  size_t currentIndexIntoFile = fileIterLastOpened_ - fileIterBegin_;
155  bool needIndexesForDuplicateChecker = duplicateChecker_ && duplicateChecker_->checkingAllFiles() && !duplicateChecker_->checkDisabled();
156  bool deleteIndexIntoFile = inputType_ == InputType::Primary &&
157  !needIndexesForDuplicateChecker &&
159  if(deleteIndexIntoFile) {
160  indexesIntoFiles_[currentIndexIntoFile].reset();
161  } else {
162  if(indexesIntoFiles_[currentIndexIntoFile]) indexesIntoFiles_[currentIndexIntoFile]->inputFileClosed();
163  }
165  }
166  closeFile_();
167 
168  if(fileIter_ == fileIterEnd_) {
169  // No files specified
170  return;
171  }
172 
173  // Check if the logical file name was found.
174  if(fileIter_->fileName().empty()) {
175  // LFN not found in catalog.
176  InputFile::reportSkippedFile(fileIter_->fileName(), fileIter_->logicalFileName());
177  if(!skipBadFiles) {
178  throw cms::Exception("LogicalFileNameNotFound", "RootInputFileSequence::initFile()\n")
179  << "Logical file name '" << fileIter_->logicalFileName() << "' was not found in the file catalog.\n"
180  << "If you wanted a local file, you forgot the 'file:' prefix\n"
181  << "before the file name in your configuration file.\n";
182  }
183  LogWarning("") << "Input logical file: " << fileIter_->logicalFileName() << " was not found in the catalog, and will be skipped.\n";
184  return;
185  }
186 
187  // Determine whether we have a fallback URL specified; if so, prepare it;
188  // Only valid if it is non-empty and differs from the original filename.
189  std::string fallbackName = fileIter_->fallbackFileName();
190  bool hasFallbackUrl = !fallbackName.empty() && fallbackName != fileIter_->fileName();
191 
192  boost::shared_ptr<InputFile> filePtr;
193  try {
194  std::unique_ptr<InputSource::FileOpenSentry>
195  sentry(inputType_ == InputType::Primary ? new InputSource::FileOpenSentry(input_) : 0);
196  filePtr.reset(new InputFile(gSystem->ExpandPathName(fileIter_->fileName().c_str()), " Initiating request to open file "));
197  }
198  catch (cms::Exception const& e) {
199  if(!skipBadFiles) {
200  if(hasFallbackUrl) {
201  std::ostringstream out;
202  out << e.explainSelf();
203  std::string pfn(gSystem->ExpandPathName(fallbackName.c_str()));
204  InputFile::reportFallbackAttempt(pfn, fileIter_->logicalFileName(), out.str());
205  } else {
206  InputFile::reportSkippedFile(fileIter_->fileName(), fileIter_->logicalFileName());
207  Exception ex(errors::FileOpenError, "", e);
208  ex.addContext("Calling RootInputFileSequence::initFile()");
209  ex.clearMessage();
210  ex << "Input file " << fileIter_->fileName() << " was not found, could not be opened, or is corrupted.\n";
211  throw ex;
212  }
213  }
214  }
215  if(!filePtr && (hasFallbackUrl)) {
216  try {
217  std::unique_ptr<InputSource::FileOpenSentry>
218  sentry(inputType_ == InputType::Primary ? new InputSource::FileOpenSentry(input_) : 0);
219  filePtr.reset(new InputFile(gSystem->ExpandPathName(fallbackName.c_str()), " Fallback request to file "));
220  }
221  catch (cms::Exception const& e) {
222  if(!skipBadFiles) {
223  InputFile::reportSkippedFile(fileIter_->fileName(), fileIter_->logicalFileName());
225  ex.addContext("Calling RootInputFileSequence::initFile()");
226  ex.clearMessage();
227  ex << "Input file " << fileIter_->fileName() << " was not found, could not be opened, or is corrupted.\n";
228  ex << "Fallback Input file " << fallbackName << " also was not found, could not be opened, or is corrupted.\n";
229  throw ex;
230  }
231  }
232  }
233  if(filePtr) {
234  std::vector<boost::shared_ptr<IndexIntoFile> >::size_type currentIndexIntoFile = fileIter_ - fileIterBegin_;
235  rootFile_ = RootFileSharedPtr(new RootFile(fileIter_->fileName(),
236  processConfiguration(), fileIter_->logicalFileName(), filePtr,
240  setRun_,
241  noEventSort_,
243  inputType_,
247  currentIndexIntoFile,
251  usingGoToEvent_));
252 
254  indexesIntoFiles_[currentIndexIntoFile] = rootFile_->indexIntoFileSharedPtr();
255  char const* inputType = 0;
256  switch(inputType_) {
257  case InputType::Primary: inputType = "primaryFiles"; break;
258  case InputType::SecondaryFile: inputType = "secondaryFiles"; break;
259  case InputType::SecondarySource: inputType = "mixingFiles"; break;
260  }
261  rootFile_->reportOpened(inputType);
262  } else {
263  InputFile::reportSkippedFile(fileIter_->fileName(), fileIter_->logicalFileName());
264  if(!skipBadFiles) {
266  "RootInputFileSequence::initFile(): Input file " << fileIter_->fileName() << " was not found or could not be opened.\n";
267  }
268  LogWarning("") << "Input file: " << fileIter_->fileName() << " was not found or could not be opened, and will be skipped.\n";
269  }
270  }
std::vector< boost::shared_ptr< IndexIntoFile > > indexesIntoFiles_
list pfn
Definition: dbtoconf.py:76
ProcessConfiguration const & processConfiguration() const
virtual std::string explainSelf() const
Definition: Exception.cc:146
std::vector< FileCatalogItem >::const_iterator fileIter_
GroupSelectorRules groupSelectorRules_
ProcessingMode processingMode() const
RunsLumisAndEvents (default), RunsAndLumis, or Runs.
Definition: InputSource.h:229
static void reportSkippedFile(std::string const &fileName, std::string const &logicalFileName)
Definition: InputFile.cc:67
uint16_t size_type
tuple InputFile
Open Root file and provide MEs ############.
static void reportFallbackAttempt(std::string const &pfn, std::string const &logicalFileName, std::string const &errorMessage)
Definition: InputFile.cc:73
std::vector< FileCatalogItem >::const_iterator fileIterLastOpened_
boost::shared_ptr< DuplicateChecker > duplicateChecker_
tuple out
Definition: dbtoconf.py:99
std::vector< ProcessHistoryID > orderedProcessHistoryIDs_
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
tuple skipBadFiles
Definition: example_cfg.py:64
boost::shared_ptr< EventSkipperByID > eventSkipperByID_
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
InputType::InputType inputType_
boost::shared_ptr< RootFile > RootFileSharedPtr
bool edm::RootInputFileSequence::nextFile ( PrincipalCache cache)
private

Definition at line 278 of file RootInputFileSequence.cc.

References edm::PrincipalCache::adjustEventToNewProductRegistry(), edm::PrincipalCache::adjustIndexesAfterProductRegistryAddition(), branchesMustMatch_, edm::hlt::Exception, fileIter_, fileIterBegin_, fileIterEnd_, initFile(), inputType_, edm::ProductRegistry::merge(), edm::errors::MismatchedInputFiles, parametersMustMatch_, edm::InputType::Primary, productRegistry(), productRegistryUpdate(), rootFile_, findQualityFiles::size, and skipBadFiles_.

Referenced by readFile_(), and skipEvents().

278  {
280  if(fileIter_ == fileIterEnd_) {
282  return false;
283  } else {
285  }
286  }
287 
289 
291  size_t size = productRegistry()->size();
292  // make sure the new product registry is compatible with the main one
293  std::string mergeInfo = productRegistryUpdate().merge(*rootFile_->productRegistry(),
294  fileIter_->fileName(),
297  if(!mergeInfo.empty()) {
298  throw Exception(errors::MismatchedInputFiles,"RootInputFileSequence::nextFile()") << mergeInfo;
299  }
300  if(productRegistry()->size() > size) {
301  cache.adjustIndexesAfterProductRegistryAddition();
302  }
303  cache.adjustEventToNewProductRegistry(productRegistry());
304  }
305  return true;
306  }
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 parametersMustMatch=BranchDescription::Permissive, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
BranchDescription::MatchMode branchesMustMatch_
BranchDescription::MatchMode parametersMustMatch_
InputType::InputType inputType_
tuple size
Write out results.
boost::shared_ptr< ProductRegistry const > productRegistry() const
RootInputFileSequence& edm::RootInputFileSequence::operator= ( RootInputFileSequence const &  )
delete
bool edm::RootInputFileSequence::previousFile ( PrincipalCache cache)
private

Definition at line 308 of file RootInputFileSequence.cc.

References edm::PrincipalCache::adjustEventToNewProductRegistry(), edm::PrincipalCache::adjustIndexesAfterProductRegistryAddition(), branchesMustMatch_, edm::hlt::Exception, fileIter_, fileIterBegin_, fileIterEnd_, initFile(), inputType_, edm::ProductRegistry::merge(), edm::errors::MismatchedInputFiles, parametersMustMatch_, edm::InputType::Primary, productRegistry(), productRegistryUpdate(), rootFile_, and findQualityFiles::size.

Referenced by skipEvents().

308  {
309  if(fileIter_ == fileIterBegin_) {
311  return false;
312  } else {
314  }
315  }
316  --fileIter_;
317 
318  initFile(false);
319 
321  size_t size = productRegistry()->size();
322  // make sure the new product registry is compatible to the main one
323  std::string mergeInfo = productRegistryUpdate().merge(*rootFile_->productRegistry(),
324  fileIter_->fileName(),
327  if(!mergeInfo.empty()) {
328  throw Exception(errors::MismatchedInputFiles,"RootInputFileSequence::previousEvent()") << mergeInfo;
329  }
330  if(productRegistry()->size() > size) {
331  cache.adjustIndexesAfterProductRegistryAddition();
332  }
333  cache.adjustEventToNewProductRegistry(productRegistry());
334  }
335  if(rootFile_) rootFile_->setToLastEntry();
336  return true;
337  }
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 parametersMustMatch=BranchDescription::Permissive, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
BranchDescription::MatchMode branchesMustMatch_
BranchDescription::MatchMode parametersMustMatch_
InputType::InputType inputType_
tuple size
Write out results.
boost::shared_ptr< ProductRegistry const > productRegistry() const
ProcessConfiguration const & edm::RootInputFileSequence::processConfiguration ( ) const
private

Definition at line 565 of file RootInputFileSequence.cc.

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

Referenced by initFile().

565  {
566  return input_.processConfiguration();
567  }
ProcessConfiguration const & processConfiguration() const
Accessor for Process Configuration.
Definition: InputSource.h:184
boost::shared_ptr< ProductRegistry const > edm::RootInputFileSequence::productRegistry ( ) const
private

Definition at line 585 of file RootInputFileSequence.cc.

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

Referenced by nextFile(), and previousFile().

585  {
586  return input_.productRegistry();
587  }
boost::shared_ptr< ProductRegistry const > productRegistry() const
Accessor for product registry.
Definition: InputSource.h:155
ProductRegistry & edm::RootInputFileSequence::productRegistryUpdate ( ) const
private

Definition at line 580 of file RootInputFileSequence.cc.

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

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

580  {
581  return input_.productRegistryUpdate();
582  }
ProductRegistry & productRegistryUpdate() const
Definition: InputSource.h:295
EventPrincipal * edm::RootInputFileSequence::readEvent ( EventPrincipal cache,
boost::shared_ptr< LuminosityBlockPrincipal lb 
)

Definition at line 376 of file RootInputFileSequence.cc.

References rootFile_.

376  {
377  return rootFile_->readEvent(cache, lb);
378  }
boost::shared_ptr< FileBlock > edm::RootInputFileSequence::readFile_ ( PrincipalCache cache)

Definition at line 115 of file RootInputFileSequence.cc.

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

115  {
116  if(firstFile_) {
117  // The first input file has already been opened.
118  firstFile_ = false;
119  if(!rootFile_) {
121  }
122  } else {
123  if(!nextFile(cache)) {
124  assert(0);
125  }
126  }
127  if(!rootFile_) {
128  return boost::shared_ptr<FileBlock>(new FileBlock);
129  }
130  return rootFile_->createFileBlock();
131  }
void initFile(bool skipBadFiles)
bool nextFile(PrincipalCache &cache)
boost::shared_ptr< LuminosityBlockPrincipal > edm::RootInputFileSequence::readLuminosityBlock_ ( boost::shared_ptr< LuminosityBlockPrincipal lbCache)

Definition at line 358 of file RootInputFileSequence.cc.

References rootFile_.

358  {
359  return rootFile_->readLumi(lbCache);
360  }
boost::shared_ptr< LuminosityBlockAuxiliary > edm::RootInputFileSequence::readLuminosityBlockAuxiliary_ ( )

Definition at line 348 of file RootInputFileSequence.cc.

References rootFile_.

348  {
349  return rootFile_->readLuminosityBlockAuxiliary_();
350  }
EventPrincipal * edm::RootInputFileSequence::readOneRandom ( )

Definition at line 671 of file RootInputFileSequence.cc.

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

671  {
673  throw Exception(errors::Configuration) << "RootInputFileSequence::readOneRandom(): no input files specified for secondary input source.\n";
674  }
675  if(!flatDistribution_) {
677  CLHEP::HepRandomEngine& engine = rng->getEngine();
678  flatDistribution_.reset(new CLHEP::RandFlat(engine));
679  }
680  skipBadFiles_ = false;
681  unsigned int currentSeqNumber = fileIter_ - fileIterBegin_;
682  while(eventsRemainingInFile_ == 0) {
683  fileIter_ = fileIterBegin_ + flatDistribution_->fireInt(fileCatalogItems().size());
684  unsigned int newSeqNumber = fileIter_ - fileIterBegin_;
685  if(newSeqNumber != currentSeqNumber) {
686  initFile(false);
687  currentSeqNumber = newSeqNumber;
688  }
689  eventsRemainingInFile_ = rootFile_->eventTree().entries();
690  if(eventsRemainingInFile_ == 0) {
691  throw Exception(errors::NotFound) <<
692  "RootInputFileSequence::readOneRandom(): Secondary Input file " << fileIter_->fileName() << " contains no events.\n";
693  }
694  rootFile_->setAtEventEntry(flatDistribution_->fireInt(eventsRemainingInFile_) - 1);
695  }
696  rootFile_->nextEventEntry();
697 
698  EventPrincipal* ep = rootFile_->clearAndReadCurrentEvent(rootFile_->secondaryEventPrincipal());
699  if(ep == 0) {
700  rootFile_->setAtEventEntry(0);
701  ep = rootFile_->clearAndReadCurrentEvent(rootFile_->secondaryEventPrincipal());
702  assert(ep != 0);
703  }
705  return ep;
706  }
void initFile(bool skipBadFiles)
std::vector< FileCatalogItem >::const_iterator fileIter_
std::vector< FileCatalogItem > const & fileCatalogItems() const
std::unique_ptr< CLHEP::RandFlat > flatDistribution_
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
tuple size
Write out results.
EventPrincipal * edm::RootInputFileSequence::readOneRandomWithID ( LuminosityBlockID const &  id)

Definition at line 711 of file RootInputFileSequence.cc.

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

711  {
713  throw Exception(errors::Configuration) << "RootInputFileSequence::readOneRandomWithID(): no input files specified for secondary input source.\n";
714  }
715  if(!flatDistribution_) {
717  CLHEP::HepRandomEngine& engine = rng->getEngine();
718  flatDistribution_.reset(new CLHEP::RandFlat(engine));
719  }
720  skipBadFiles_ = false;
721  if(fileIter_ == fileIterEnd_ || !rootFile_ ||
722  rootFile_->indexIntoFileIter().run() != id.run() ||
723  rootFile_->indexIntoFileIter().lumi() != id.luminosityBlock()) {
724  bool found = skipToItem(id.run(), id.luminosityBlock(), 0);
725  if(!found) {
726  return 0;
727  }
728  int eventsInLumi = 0;
729  while(rootFile_->setEntryAtNextEventInLumi(id.run(), id.luminosityBlock())) ++eventsInLumi;
730  found = skipToItem(id.run(), id.luminosityBlock(), 0);
731  assert(found);
732  int eventInLumi = flatDistribution_->fireInt(eventsInLumi);
733  for(int i = 0; i < eventInLumi; ++i) {
734  bool found = rootFile_->setEntryAtNextEventInLumi(id.run(), id.luminosityBlock());
735  assert(found);
736  }
737  }
738  bool nextFound = rootFile_->setEntryAtNextEventInLumi(id.run(), id.luminosityBlock());
739  EventPrincipal* ep = (nextFound ? rootFile_->clearAndReadCurrentEvent(rootFile_->secondaryEventPrincipal()) : 0);
740  if(ep == 0) {
741  bool found = rootFile_->setEntryAtItem(id.run(), id.luminosityBlock(), 0);
742  if(found) {
743  return readOneRandomWithID(id);
744  }
745  }
746  return ep;
747  }
int i
Definition: DBlmapReader.cc:9
EventPrincipal * readOneRandomWithID(LuminosityBlockID const &id)
std::vector< FileCatalogItem >::const_iterator fileIter_
bool skipToItem(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, bool currentFileFirst=true)
std::unique_ptr< CLHEP::RandFlat > flatDistribution_
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
EventPrincipal * edm::RootInputFileSequence::readOneSequential ( )

Definition at line 604 of file RootInputFileSequence.cc.

References edm::errors::Configuration, edm::hlt::Exception, fileIter_, fileIterBegin_, fileIterEnd_, initFile(), rootFile_, and skipBadFiles_.

604  {
605  skipBadFiles_ = false;
606  if(fileIter_ == fileIterEnd_ || !rootFile_) {
608  throw Exception(errors::Configuration) << "RootInputFileSequence::readOneSequential(): no input files specified for secondary input source.\n";
609  }
611  initFile(false);
612  rootFile_->setAtEventEntry(-1);
613  }
614  rootFile_->nextEventEntry();
615  EventPrincipal* ep = rootFile_->clearAndReadCurrentEvent(rootFile_->secondaryEventPrincipal());
616  if(ep == 0) {
617  ++fileIter_;
618  if(fileIter_ == fileIterEnd_) {
619  return 0;
620  }
621  initFile(false);
622  rootFile_->setAtEventEntry(-1);
623  return readOneSequential();
624  }
625  return ep;
626  }
void initFile(bool skipBadFiles)
std::vector< FileCatalogItem >::const_iterator fileIter_
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
EventPrincipal * edm::RootInputFileSequence::readOneSequentialWithID ( LuminosityBlockID const &  id)

Definition at line 629 of file RootInputFileSequence.cc.

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

629  {
631  throw Exception(errors::Configuration) << "RootInputFileSequence::readOneSequentialWithID(): no input files specified for secondary input source.\n";
632  }
633  skipBadFiles_ = false;
634  if(fileIter_ == fileIterEnd_ || !rootFile_ ||
635  rootFile_->indexIntoFileIter().run() != id.run() ||
636  rootFile_->indexIntoFileIter().lumi() != id.luminosityBlock()) {
637  bool found = skipToItem(id.run(), id.luminosityBlock(), 0, false);
638  if(!found) {
639  return 0;
640  }
641  }
642  bool nextFound = rootFile_->setEntryAtNextEventInLumi(id.run(), id.luminosityBlock());
643  EventPrincipal* ep = (nextFound ? rootFile_->clearAndReadCurrentEvent(rootFile_->secondaryEventPrincipal()) : 0);
644  if(ep == 0) {
645  bool found = skipToItemInNewFile(id.run(), id.luminosityBlock(), 0);
646  if(found) {
647  return readOneSequentialWithID(id);
648  }
649  }
650  return ep;
651  }
std::vector< FileCatalogItem >::const_iterator fileIter_
EventPrincipal * readOneSequentialWithID(LuminosityBlockID const &id)
bool skipToItem(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, bool currentFileFirst=true)
bool skipToItemInNewFile(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
EventPrincipal * edm::RootInputFileSequence::readOneSpecified ( EventID const &  id)

Definition at line 654 of file RootInputFileSequence.cc.

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

654  {
656  throw Exception(errors::Configuration) << "RootInputFileSequence::readOneSequential(): no input files specified for secondary input source.\n";
657  }
658  skipBadFiles_ = false;
659  bool found = skipToItem(id.run(), id.luminosityBlock(), id.event());
660  if(!found) {
661  throw Exception(errors::NotFound) <<
662  "RootInputFileSequence::readOneSpecified(): Secondary Input files" <<
663  " do not contain specified event:\n" << id << "\n";
664  }
665  EventPrincipal* ep = rootFile_->clearAndReadCurrentEvent(rootFile_->secondaryEventPrincipal());
666  assert(ep != 0);
667  return ep;
668  }
bool skipToItem(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, bool currentFileFirst=true)
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 fileIterBegin_
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
boost::shared_ptr< RunPrincipal > edm::RootInputFileSequence::readRun_ ( boost::shared_ptr< RunPrincipal rpCache)

Definition at line 353 of file RootInputFileSequence.cc.

References rootFile_.

353  {
354  return rootFile_->readRun_(rpCache);
355  }
boost::shared_ptr< RunAuxiliary > edm::RootInputFileSequence::readRunAuxiliary_ ( )

Definition at line 343 of file RootInputFileSequence.cc.

References rootFile_.

343  {
344  return rootFile_->readRunAuxiliary_();
345  }
int edm::RootInputFileSequence::remainingEvents ( ) const
private

Definition at line 570 of file RootInputFileSequence.cc.

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

Referenced by initFile().

570  {
571  return input_.remainingEvents();
572  }
int remainingEvents() const
Definition: InputSource.h:170
int edm::RootInputFileSequence::remainingLuminosityBlocks ( ) const
private

Definition at line 575 of file RootInputFileSequence.cc.

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

Referenced by initFile().

575  {
577  }
int remainingLuminosityBlocks() const
Definition: InputSource.h:178
void edm::RootInputFileSequence::reset ( PrincipalCache cache)

Definition at line 426 of file RootInputFileSequence.cc.

References fileIter_, fileIterBegin_, fileIterEnd_, firstFile_, initFile(), inputType_, numberOfEventsToSkip_, rootFile_, edm::InputType::SecondarySource, skipBadFiles_, and skipEvents().

426  {
427  //NOTE: Need to handle duplicate checker
428  // Also what if skipBadFiles_==true and the first time we succeeded but after a reset we fail?
430  firstFile_ = true;
433  if(rootFile_) break;
434  }
435  if(rootFile_) {
436  if(numberOfEventsToSkip_ != 0) {
438  }
439  }
440  }
441  }
void initFile(bool skipBadFiles)
std::vector< FileCatalogItem >::const_iterator fileIter_
bool skipEvents(int offset, PrincipalCache &cache)
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
InputType::InputType inputType_
ProcessingController::ReverseState edm::RootInputFileSequence::reverseState ( ) const
void edm::RootInputFileSequence::rewind_ ( )

Definition at line 407 of file RootInputFileSequence.cc.

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

407  {
408  if(fileIter_ != fileIterBegin_) {
409  closeFile_();
411  }
412  if(!rootFile_) {
413  initFile(false);
414  }
415  rewindFile();
416  firstFile_ = true;
417  }
void initFile(bool skipBadFiles)
std::vector< FileCatalogItem >::const_iterator fileIter_
std::vector< FileCatalogItem >::const_iterator fileIterBegin_
void edm::RootInputFileSequence::rewindFile ( )
private

Definition at line 421 of file RootInputFileSequence.cc.

References rootFile_.

Referenced by rewind_().

421  {
422  if(rootFile_) rootFile_->rewind();
423  }
bool edm::RootInputFileSequence::skipEvents ( int  offset,
PrincipalCache cache 
)

Definition at line 445 of file RootInputFileSequence.cc.

References fileIter_, fileIterEnd_, nextFile(), numberOfEventsToSkip_, evf::evtn::offset(), previousFile(), and rootFile_.

Referenced by reset(), and RootInputFileSequence().

445  {
448  while(numberOfEventsToSkip_ != 0) {
449  bool atEnd = rootFile_->skipEvents(numberOfEventsToSkip_);
450  if((numberOfEventsToSkip_ > 0 || atEnd) && !nextFile(cache)) {
452  return false;
453  }
454  if(numberOfEventsToSkip_ < 0 && !previousFile(cache)) {
457  return false;
458  }
459  }
460  return true;
461  }
std::vector< FileCatalogItem >::const_iterator fileIter_
unsigned int offset(bool)
bool nextFile(PrincipalCache &cache)
bool previousFile(PrincipalCache &cache)
std::vector< FileCatalogItem >::const_iterator fileIterEnd_
bool edm::RootInputFileSequence::skipToItem ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event,
bool  currentFileFirst = true 
)

Definition at line 534 of file RootInputFileSequence.cc.

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

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

534  {
535  // Attempt to find item in currently open input file.
536  bool found = currentFileFirst && rootFile_ && rootFile_->setEntryAtItem(run, lumi, event);
537  if(!found) {
538  // If only one input file, give up now, to save time.
539  if(currentFileFirst && rootFile_ && indexesIntoFiles_.size() == 1) {
540  return false;
541  }
542  // Look for item (run/lumi/event) in files previously opened without reopening unnecessary files.
543  typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
544  for(Iter it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) {
545  if(*it && (*it)->containsItem(run, lumi, event)) {
546  // We found it. Close the currently open file, and open the correct one.
547  std::vector<FileCatalogItem>::const_iterator currentIter = fileIter_;
548  fileIter_ = fileIterBegin_ + (it - indexesIntoFiles_.begin());
549  if(fileIter_ != currentIter) {
550  initFile(false);
551  }
552  // Now get the item from the correct file.
553  found = rootFile_->setEntryAtItem(run, lumi, event);
554  assert (found);
555  return true;
556  }
557  }
558  // Look for item in files not yet opened.
559  return skipToItemInNewFile(run, lumi, event);
560  }
561  return true;
562  }
std::vector< boost::shared_ptr< IndexIntoFile > > indexesIntoFiles_
void initFile(bool skipBadFiles)
std::vector< FileCatalogItem >::const_iterator fileIter_
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
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 516 of file RootInputFileSequence.cc.

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

Referenced by readOneSequentialWithID(), and skipToItem().

516  {
517  // Look for item in files not yet opened.
518  typedef std::vector<boost::shared_ptr<IndexIntoFile> >::const_iterator Iter;
519  for(Iter it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) {
520  if(!*it) {
521  fileIter_ = fileIterBegin_ + (it - indexesIntoFiles_.begin());
522  initFile(false);
523  bool found = rootFile_->setEntryAtItem(run, lumi, event);
524  if(found) {
525  return true;
526  }
527  }
528  }
529  // Not found
530  return false;
531  }
std::vector< boost::shared_ptr< IndexIntoFile > > indexesIntoFiles_
void initFile(bool skipBadFiles)
std::vector< FileCatalogItem >::const_iterator fileIter_
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
std::vector< FileCatalogItem >::const_iterator fileIterBegin_

Member Data Documentation

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

Definition at line 96 of file RootInputFileSequence.h.

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

bool edm::RootInputFileSequence::bypassVersionCheck_
private

Definition at line 107 of file RootInputFileSequence.h.

Referenced by initFile().

InputFileCatalog const& edm::RootInputFileSequence::catalog_
private

Definition at line 88 of file RootInputFileSequence.h.

Referenced by fileCatalogItems().

bool edm::RootInputFileSequence::dropDescendants_
private

Definition at line 113 of file RootInputFileSequence.h.

Referenced by initFile().

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

Definition at line 112 of file RootInputFileSequence.h.

Referenced by closeFile_(), and initFile().

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

Definition at line 102 of file RootInputFileSequence.h.

Referenced by initFile().

int edm::RootInputFileSequence::eventsRemainingInFile_
private

Definition at line 103 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 93 of file RootInputFileSequence.h.

Referenced by initFile().

bool edm::RootInputFileSequence::firstFile_
private

Definition at line 89 of file RootInputFileSequence.h.

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

std::unique_ptr<CLHEP::RandFlat> edm::RootInputFileSequence::flatDistribution_
private

Definition at line 98 of file RootInputFileSequence.h.

Referenced by readOneRandom(), and readOneRandomWithID().

GroupSelectorRules edm::RootInputFileSequence::groupSelectorRules_
private

Definition at line 111 of file RootInputFileSequence.h.

Referenced by dropUnwantedBranches_(), and initFile().

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

Definition at line 99 of file RootInputFileSequence.h.

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

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

Definition at line 114 of file RootInputFileSequence.h.

Referenced by initFile().

bool edm::RootInputFileSequence::noEventSort_
private

Definition at line 105 of file RootInputFileSequence.h.

Referenced by initFile().

int edm::RootInputFileSequence::numberOfEventsToSkip_
private

Definition at line 104 of file RootInputFileSequence.h.

Referenced by initFile(), reset(), RootInputFileSequence(), and skipEvents().

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

Definition at line 100 of file RootInputFileSequence.h.

Referenced by initFile().

BranchDescription::MatchMode edm::RootInputFileSequence::parametersMustMatch_
private

Definition at line 95 of file RootInputFileSequence.h.

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

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

Definition at line 110 of file RootInputFileSequence.h.

Referenced by initFile().

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

Definition at line 108 of file RootInputFileSequence.h.

Referenced by initFile(), and RootInputFileSequence().

int const edm::RootInputFileSequence::treeMaxVirtualSize_
private

Definition at line 109 of file RootInputFileSequence.h.

Referenced by initFile().

bool edm::RootInputFileSequence::usingGoToEvent_
private

Definition at line 115 of file RootInputFileSequence.h.

Referenced by goToEvent(), and initFile().