CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
edm::RootPrimaryFileSequence Class Reference

#include <RootPrimaryFileSequence.h>

Inheritance diagram for edm::RootPrimaryFileSequence:
edm::RootInputFileSequence

Public Member Functions

void endJob ()
 
ProcessingController::ForwardState forwardState () const
 
InputSource::ItemType getNextItemType (RunNumber_t &run, LuminosityBlockNumber_t &lumi, EventNumber_t &event)
 
bool goToEvent (EventID const &eventID)
 
RootPrimaryFileSequenceoperator= (RootPrimaryFileSequence const &)=delete
 
std::shared_ptr< FileBlockreadFile_ ()
 
ProcessingController::ReverseState reverseState () const
 
void rewind_ ()
 
 RootPrimaryFileSequence (ParameterSet const &pset, PoolSource &input, InputFileCatalog const &catalog)
 
 RootPrimaryFileSequence (RootPrimaryFileSequence const &)=delete
 
void skipEvents (int offset)
 
void skipEventsAtBeginning (int offset)
 
 ~RootPrimaryFileSequence () override
 
- Public Member Functions inherited from edm::RootInputFileSequence
void closeFile ()
 
bool containedInCurrentFile (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event) const
 
std::shared_ptr< BranchIDListHelper const > fileBranchIDListHelper () const
 
std::shared_ptr< ProductRegistry const > fileProductRegistry () const
 
void fillProcessBlockHelper_ ()
 
bool nextProcessBlock_ (ProcessBlockPrincipal &)
 
RootInputFileSequenceoperator= (RootInputFileSequence const &)=delete
 
bool readEvent (EventPrincipal &cache)
 
bool readLuminosityBlock_ (LuminosityBlockPrincipal &lumiPrincipal)
 
std::shared_ptr< LuminosityBlockAuxiliaryreadLuminosityBlockAuxiliary_ ()
 
void readProcessBlock_ (ProcessBlockPrincipal &)
 
bool readRun_ (RunPrincipal &runPrincipal)
 
std::shared_ptr< RunAuxiliaryreadRunAuxiliary_ ()
 
 RootInputFileSequence (ParameterSet const &pset, InputFileCatalog const &catalog)
 
 RootInputFileSequence (RootInputFileSequence const &)=delete
 
bool skipToItem (RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event, size_t fileNameHash=0U, bool currentFileFirst=true)
 
virtual ~RootInputFileSequence ()
 

Static Public Member Functions

static void fillDescription (ParameterSetDescription &desc)
 

Private Member Functions

void closeFile_ () override
 
std::shared_ptr< DuplicateChecker const > duplicateChecker () const
 
std::shared_ptr< DuplicateChecker > & duplicateChecker ()
 
std::shared_ptr< EventSkipperByID const > eventSkipperByID () const
 
std::shared_ptr< EventSkipperByID > & eventSkipperByID ()
 
void initFile_ (bool skipBadFiles) override
 
RootFileSharedPtr makeRootFile (std::shared_ptr< InputFile > filePtr) override
 
bool nextFile ()
 
bool previousFile ()
 
int remainingEvents () const
 
int remainingLuminosityBlocks () const
 
void rewindFile ()
 

Private Attributes

BranchDescription::MatchMode branchesMustMatch_
 
edm::propagate_const< std::shared_ptr< DuplicateChecker > > duplicateChecker_
 
bool enablePrefetching_
 
bool enforceGUIDInFileName_
 
edm::propagate_const< std::shared_ptr< EventSkipperByID > > eventSkipperByID_
 
edm::propagate_const< std::shared_ptr< FileBlock > > fb_
 
bool firstFile_
 
EventID goToEventID_
 
bool goToEventInNewFile_ = false
 
size_t goToFileSequenceOffset_ = 0
 
int initialNumberOfEventsToSkip_
 
PoolSourceinput_
 
bool noEventSort_
 
bool noRunLumiSort_
 
std::vector< ProcessHistoryIDorderedProcessHistoryIDs_
 
bool skipIntoNewFile_ = false
 
size_t skipToFileSequenceNumber_ = 0
 
int skipToOffsetInFinalFile_ = 0
 
bool skipToStop_ = false
 
unsigned int treeCacheSize_
 
bool usingGoToEvent_
 

Additional Inherited Members

- Protected Types inherited from edm::RootInputFileSequence
typedef std::shared_ptr< RootFileRootFileSharedPtr
 
- Protected Member Functions inherited from edm::RootInputFileSequence
bool atFirstFile () const
 
bool atLastFile () const
 
std::vector< FileCatalogItem > const & fileCatalogItems () const
 
std::vector< std::string > const & fileNames () const
 
std::vector< std::shared_ptr< IndexIntoFile > > const & indexesIntoFiles () const
 
void initFile (bool skipBadFiles)
 
void initTheFile (bool skipBadFiles, bool deleteIndexIntoFile, InputSource *input, char const *inputTypeName, InputType inputType)
 
std::string const & lfn () const
 
size_t lfnHash () const
 
std::string const & logicalFileName () const
 
bool noFiles () const
 
bool noMoreFiles () const
 
size_t numberOfFiles () const
 
std::shared_ptr< RootFile const > rootFile () const
 
std::shared_ptr< RootFile > & rootFile ()
 
size_t sequenceNumberOfFile () const
 
void setAtFileSequenceNumber (size_t offset)
 
void setAtFirstFile ()
 
void setAtNextFile ()
 
void setAtPreviousFile ()
 
void setIndexIntoFile (size_t index)
 
void setNoMoreFiles ()
 
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)
 
bool usedFallback () const
 

Detailed Description

Definition at line 34 of file RootPrimaryFileSequence.h.

Constructor & Destructor Documentation

◆ RootPrimaryFileSequence() [1/2]

edm::RootPrimaryFileSequence::RootPrimaryFileSequence ( ParameterSet const &  pset,
PoolSource input,
InputFileCatalog const &  catalog 
)
explicit

Definition at line 22 of file RootPrimaryFileSequence.cc.

References branchesMustMatch_, edm::errors::Configuration, enablePrefetching_, Exception, edm::RootInputFileSequence::fileNames(), edm::storage::StorageFactory::get(), edm::RootInputFileSequence::initFile(), initialNumberOfEventsToSkip_, input_, edm::Service< T >::isAvailable(), edm::RootInputFileSequence::noMoreFiles(), noRunLumiSort_, edm::PoolSource::productRegistryUpdate(), muonDTDigis_cfi::pset, remainingEvents(), remainingLuminosityBlocks(), edm::RootInputFileSequence::rootFile(), edm::RootInputFileSequence::setAtFirstFile(), edm::RootInputFileSequence::setAtNextFile(), edm::PoolSource::skipBadFiles(), skipEventsAtBeginning(), edm::storage::StorageFactory::stagein(), edm::BranchDescription::Strict, AlCaHLTBitMon_QueryRunRegistry::string, treeCacheSize_, mitigatedMETSequence_cff::U, and edm::ProductRegistry::updateFromInput().

26  input_(input),
27  firstFile_(true),
31  initialNumberOfEventsToSkip_(pset.getUntrackedParameter<unsigned int>("skipEvents")),
32  noRunLumiSort_(pset.getUntrackedParameter<bool>("noRunLumiSort")),
33  noEventSort_(noRunLumiSort_ ? true : pset.getUntrackedParameter<bool>("noEventSort")),
34  treeCacheSize_(noEventSort_ ? pset.getUntrackedParameter<unsigned int>("cacheSize") : 0U),
35  duplicateChecker_(new DuplicateChecker(pset)),
36  usingGoToEvent_(false),
37  enablePrefetching_(false),
38  enforceGUIDInFileName_(pset.getUntrackedParameter<bool>("enforceGUIDInFileName")) {
39  if (noRunLumiSort_ && (remainingEvents() >= 0 || remainingLuminosityBlocks() >= 0)) {
40  // There would need to be some Framework development work to allow stopping
41  // early with noRunLumiSort set true related to closing lumis and runs that
42  // were supposed to be continued but were not... We cannot have events written
43  // to output with no run or lumi written to output.
45  "Illegal to configure noRunLumiSort and limit the number of events or luminosityBlocks");
46  }
47  // The SiteLocalConfig controls the TTreeCache size and the prefetching settings.
49  if (pSLC.isAvailable()) {
50  if (treeCacheSize_ != 0U && pSLC->sourceTTreeCacheSize()) {
51  treeCacheSize_ = *(pSLC->sourceTTreeCacheSize());
52  }
53  enablePrefetching_ = pSLC->enablePrefetching();
54  }
55 
56  std::string branchesMustMatch =
57  pset.getUntrackedParameter<std::string>("branchesMustMatch", std::string("permissive"));
58  if (branchesMustMatch == std::string("strict"))
60 
61  // Prestage the files
64  }
65  // Open the first file.
68  if (rootFile())
69  break;
70  }
71  if (rootFile()) {
72  input_.productRegistryUpdate().updateFromInput(rootFile()->productRegistry()->productList());
75  }
76  }
77  }
void initFile(bool skipBadFiles)
static std::unique_ptr< EventSkipperByID > create(ParameterSet const &pset)
edm::propagate_const< std::shared_ptr< EventSkipperByID > > eventSkipperByID_
bool skipBadFiles() const
Definition: PoolSource.h:40
ProductRegistry & productRegistryUpdate()
Definition: InputSource.h:330
std::vector< std::string > const & fileNames() const
static std::string const input
Definition: EdmProvDump.cc:50
std::vector< ProcessHistoryID > orderedProcessHistoryIDs_
std::shared_ptr< RootFile const > rootFile() const
void stagein(const std::string &url) const
edm::propagate_const< std::shared_ptr< DuplicateChecker > > duplicateChecker_
BranchDescription::MatchMode branchesMustMatch_
void updateFromInput(ProductList const &other)
RootInputFileSequence(ParameterSet const &pset, InputFileCatalog const &catalog)
static const StorageFactory * get(void)

◆ ~RootPrimaryFileSequence()

edm::RootPrimaryFileSequence::~RootPrimaryFileSequence ( )
override

Definition at line 79 of file RootPrimaryFileSequence.cc.

79 {}

◆ RootPrimaryFileSequence() [2/2]

edm::RootPrimaryFileSequence::RootPrimaryFileSequence ( RootPrimaryFileSequence const &  )
delete

Member Function Documentation

◆ closeFile_()

void edm::RootPrimaryFileSequence::closeFile_ ( )
overrideprivatevirtual

Implements edm::RootInputFileSequence.

Definition at line 126 of file RootPrimaryFileSequence.cc.

References duplicateChecker_, input_, edm::RootInputFileSequence::lfn(), and edm::RootInputFileSequence::rootFile().

126  {
127  // close the currently open file, if any, and delete the RootFile object.
128  if (rootFile()) {
129  auto sentry = std::make_unique<InputSource::FileCloseSentry>(input_, lfn());
130  rootFile()->close();
131  if (duplicateChecker_)
132  duplicateChecker_->inputFileClosed();
133  rootFile().reset();
134  }
135  }
std::shared_ptr< RootFile const > rootFile() const
edm::propagate_const< std::shared_ptr< DuplicateChecker > > duplicateChecker_
std::string const & lfn() const

◆ duplicateChecker() [1/2]

std::shared_ptr<DuplicateChecker const> edm::RootPrimaryFileSequence::duplicateChecker ( ) const
inlineprivate

Definition at line 71 of file RootPrimaryFileSequence.h.

References duplicateChecker_, and edm::get_underlying_safe().

Referenced by makeRootFile().

constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< std::shared_ptr< DuplicateChecker > > duplicateChecker_

◆ duplicateChecker() [2/2]

std::shared_ptr<DuplicateChecker>& edm::RootPrimaryFileSequence::duplicateChecker ( )
inlineprivate

Definition at line 72 of file RootPrimaryFileSequence.h.

References duplicateChecker_, and edm::get_underlying_safe().

constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< std::shared_ptr< DuplicateChecker > > duplicateChecker_

◆ endJob()

void edm::RootPrimaryFileSequence::endJob ( void  )

◆ eventSkipperByID() [1/2]

std::shared_ptr<EventSkipperByID const> edm::RootPrimaryFileSequence::eventSkipperByID ( ) const
inlineprivate

Definition at line 69 of file RootPrimaryFileSequence.h.

References eventSkipperByID_, and edm::get_underlying_safe().

Referenced by makeRootFile().

edm::propagate_const< std::shared_ptr< EventSkipperByID > > eventSkipperByID_
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)

◆ eventSkipperByID() [2/2]

std::shared_ptr<EventSkipperByID>& edm::RootPrimaryFileSequence::eventSkipperByID ( )
inlineprivate

Definition at line 70 of file RootPrimaryFileSequence.h.

References eventSkipperByID_, and edm::get_underlying_safe().

edm::propagate_const< std::shared_ptr< EventSkipperByID > > eventSkipperByID_
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)

◆ fillDescription()

void edm::RootPrimaryFileSequence::fillDescription ( ParameterSetDescription desc)
static

Definition at line 413 of file RootPrimaryFileSequence.cc.

References edm::roottree::defaultCacheSize, submitPVResolutionJobs::desc, edm::EventSkipperByID::fillDescription(), edm::DuplicateChecker::fillDescription(), AlCaHLTBitMon_QueryRunRegistry::string, and mitigatedMETSequence_cff::U.

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

413  {
414  desc.addUntracked<unsigned int>("skipEvents", 0U)
415  ->setComment("Skip the first 'skipEvents' events that otherwise would have been processed.");
416  desc.addUntracked<bool>("noEventSort", true)
417  ->setComment(
418  "True: Process runs, lumis and events in the order they appear in the file (but see notes 1 and 2).\n"
419  "False: Process runs, lumis and events in each file in numerical order (run#, lumi#, event#) (but see note "
420  "3).\n"
421  "Note 1: Events within the same lumi will always be processed contiguously.\n"
422  "Note 2: Lumis within the same run will always be processed contiguously.\n"
423  "Note 3: Any sorting occurs independently in each input file (no sorting across input files).");
424  desc.addUntracked<bool>("noRunLumiSort", false)
425  ->setComment(
426  "True: Process runs, lumis and events in the order they appear in the file.\n"
427  "False: Follow settings based on 'noEventSort' setting.");
428  desc.addUntracked<unsigned int>("cacheSize", roottree::defaultCacheSize)
429  ->setComment("Size of ROOT TTree prefetch cache. Affects performance.");
430  std::string defaultString("permissive");
431  desc.addUntracked<std::string>("branchesMustMatch", defaultString)
432  ->setComment(
433  "'strict': Branches in each input file must match those in the first file.\n"
434  "'permissive': Branches in each input file may be any subset of those in the first file.");
435  desc.addUntracked<bool>("enforceGUIDInFileName", false)
436  ->setComment(
437  "True: file name part is required to be equal to the GUID of the file\n"
438  "False: file name can be anything");
439 
442  }
static void fillDescription(ParameterSetDescription &desc)
unsigned int const defaultCacheSize
Definition: RootTree.h:38
static void fillDescription(ParameterSetDescription &desc)

◆ forwardState()

ProcessingController::ForwardState edm::RootPrimaryFileSequence::forwardState ( ) const

◆ getNextItemType()

InputSource::ItemType edm::RootPrimaryFileSequence::getNextItemType ( RunNumber_t run,
LuminosityBlockNumber_t lumi,
EventNumber_t event 
)

Definition at line 229 of file RootPrimaryFileSequence.cc.

References cms::cuda::assert(), edm::RootInputFileSequence::atLastFile(), firstFile_, goToEventInNewFile_, 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, edm::RootInputFileSequence::noMoreFiles(), edm::RootInputFileSequence::rootFile(), writedatasetfile::run, skipIntoNewFile_, and skipToStop_.

231  {
232  if (noMoreFiles() || skipToStop_) {
233  skipToStop_ = false;
234  return InputSource::IsStop;
235  }
237  return InputSource::IsFile;
238  }
239  if (rootFile()) {
240  IndexIntoFile::EntryType entryType = rootFile()->getNextItemType(run, lumi, event);
241  if (entryType == IndexIntoFile::kEvent) {
242  return InputSource::IsEvent;
243  } else if (entryType == IndexIntoFile::kLumi) {
244  return InputSource::IsLumi;
245  } else if (entryType == IndexIntoFile::kRun) {
246  return InputSource::IsRun;
247  }
248  assert(entryType == IndexIntoFile::kEnd);
249  }
250  if (atLastFile()) {
251  return InputSource::IsStop;
252  }
253  return InputSource::IsFile;
254  }
assert(be >=bs)
std::shared_ptr< RootFile const > rootFile() const
Definition: event.py:1

◆ goToEvent()

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

Definition at line 356 of file RootPrimaryFileSequence.cc.

References cms::cuda::assert(), edm::EventID::event(), fb_, goToEventID_, goToEventInNewFile_, goToFileSequenceOffset_, edm::RootInputFileSequence::indexesIntoFiles(), edm::RootInputFileSequence::initFile(), edm::EventID::luminosityBlock(), edm::RootInputFileSequence::rootFile(), edm::EventID::run(), edm::RootInputFileSequence::sequenceNumberOfFile(), edm::RootInputFileSequence::setAtFileSequenceNumber(), and usingGoToEvent_.

356  {
357  usingGoToEvent_ = true;
358  if (rootFile()) {
359  if (rootFile()->goToEvent(eventID)) {
360  return true;
361  }
362  // If only one input file, give up now, to save time.
363  if (rootFile() && indexesIntoFiles().size() == 1) {
364  return false;
365  }
366  // Look for item (run/lumi/event) in files previously opened without reopening unnecessary files.
367  for (auto it = indexesIntoFiles().begin(), itEnd = indexesIntoFiles().end(); it != itEnd; ++it) {
368  if (*it && (*it)->containsItem(eventID.run(), eventID.luminosityBlock(), eventID.event())) {
369  goToEventInNewFile_ = true;
370  goToFileSequenceOffset_ = it - indexesIntoFiles().begin();
371  goToEventID_ = eventID;
372  return true;
373  }
374  }
375 
376  // Save the current file and position so that we can restore them
377  bool closedOriginalFile = false;
378  size_t const originalFileSequenceNumber = sequenceNumberOfFile();
379  IndexIntoFile::IndexIntoFileItr originalPosition = rootFile()->indexIntoFileIter();
380 
381  // Look for item in files not yet opened.
382  bool foundIt = false;
383  for (auto it = indexesIntoFiles().begin(), itEnd = indexesIntoFiles().end(); it != itEnd; ++it) {
384  if (!*it) {
386  initFile(false);
387  assert(rootFile());
388  closedOriginalFile = true;
389  if ((*it)->containsItem(eventID.run(), eventID.luminosityBlock(), eventID.event())) {
390  foundIt = true;
391  goToEventInNewFile_ = true;
392  goToFileSequenceOffset_ = it - indexesIntoFiles().begin();
393  goToEventID_ = eventID;
394  }
395  }
396  }
397  if (closedOriginalFile) {
398  setAtFileSequenceNumber(originalFileSequenceNumber);
399  initFile(false);
400  assert(rootFile());
401  rootFile()->setPosition(originalPosition);
402  rootFile()->updateFileBlock(*fb_);
403  }
404  return foundIt;
405  }
406  return false;
407  }
size
Write out results.
void initFile(bool skipBadFiles)
void setAtFileSequenceNumber(size_t offset)
assert(be >=bs)
bool goToEvent(EventID const &eventID)
std::shared_ptr< RootFile const > rootFile() const
edm::propagate_const< std::shared_ptr< FileBlock > > fb_
std::vector< std::shared_ptr< IndexIntoFile > > const & indexesIntoFiles() const

◆ initFile_()

void edm::RootPrimaryFileSequence::initFile_ ( bool  skipBadFiles)
overrideprivatevirtual

Implements edm::RootInputFileSequence.

Definition at line 137 of file RootPrimaryFileSequence.cc.

References duplicateChecker_, edm::RootInputFileSequence::initTheFile(), input_, edm::Primary, remoteMonitoring_LASER_era2018_cfg::skipBadFiles, and usingGoToEvent_.

137  {
138  // If we are not duplicate checking across files and we are not using random access to find events,
139  // then we can delete the IndexIntoFile for the file we are closing.
140  // If we can't delete all of it, then we can delete the parts we do not need.
141  bool deleteIndexIntoFile = !usingGoToEvent_ && !(duplicateChecker_ && duplicateChecker_->checkingAllFiles() &&
142  !duplicateChecker_->checkDisabled());
143  initTheFile(skipBadFiles, deleteIndexIntoFile, &input_, "primaryFiles", InputType::Primary);
144  }
void initTheFile(bool skipBadFiles, bool deleteIndexIntoFile, InputSource *input, char const *inputTypeName, InputType inputType)
edm::propagate_const< std::shared_ptr< DuplicateChecker > > duplicateChecker_

◆ makeRootFile()

RootPrimaryFileSequence::RootFileSharedPtr edm::RootPrimaryFileSequence::makeRootFile ( std::shared_ptr< InputFile filePtr)
overrideprivatevirtual

Implements edm::RootInputFileSequence.

Definition at line 146 of file RootPrimaryFileSequence.cc.

References edm::InputSource::branchIDListHelper(), edm::PoolSource::bypassVersionCheck(), edm::PoolSource::dropDescendants(), duplicateChecker(), enablePrefetching_, enforceGUIDInFileName_, eventSkipperByID(), edm::RootInputFileSequence::fileNames(), edm::RootInputFileSequence::indexesIntoFiles(), initialNumberOfEventsToSkip_, input_, edm::PoolSource::labelRawDataLikeMC(), edm::RootInputFileSequence::logicalFileName(), noEventSort_, noRunLumiSort_, edm::PoolSource::nStreams(), orderedProcessHistoryIDs_, edm::Primary, edm::InputSource::processBlockHelper(), edm::InputSource::processConfiguration(), edm::PoolSource::processHistoryRegistryForUpdate(), edm::InputSource::processingMode(), edm::PoolSource::productSelectorRules(), remainingEvents(), remainingLuminosityBlocks(), edm::PoolSource::runHelper(), edm::RootInputFileSequence::sequenceNumberOfFile(), edm::InputSource::thinnedAssociationsHelper(), treeCacheSize_, edm::PoolSource::treeMaxVirtualSize(), and usingGoToEvent_.

146  {
147  size_t currentIndexIntoFile = sequenceNumberOfFile();
148  return std::make_shared<RootFile>(fileNames()[0],
150  logicalFileName(),
151  filePtr,
154  remainingEvents(),
156  input_.nStreams(),
160  input_.runHelper(),
162  noEventSort_,
166  input_.processBlockHelper().get(),
168  nullptr, // associationsFromSecondary
173  currentIndexIntoFile,
180  }
bool labelRawDataLikeMC() const
Definition: PoolSource.h:43
std::string const & logicalFileName() const
std::shared_ptr< ProcessBlockHelper const > processBlockHelper() const
Accessors for processBlockHelper.
Definition: InputSource.h:149
unsigned int nStreams() const
Definition: PoolSource.h:44
ProcessHistoryRegistry & processHistoryRegistryForUpdate()
Definition: InputSource.h:331
std::shared_ptr< ThinnedAssociationsHelper const > thinnedAssociationsHelper() const
Accessors for thinnedAssociationsHelper.
Definition: InputSource.h:155
std::vector< std::string > const & fileNames() const
std::shared_ptr< DuplicateChecker const > duplicateChecker() const
std::shared_ptr< EventSkipperByID const > eventSkipperByID() const
RunHelperBase * runHelper()
Definition: PoolSource.h:47
std::shared_ptr< BranchIDListHelper const > branchIDListHelper() const
Accessors for branchIDListHelper.
Definition: InputSource.h:143
std::vector< ProcessHistoryID > orderedProcessHistoryIDs_
ProcessConfiguration const & processConfiguration() const
Accessor for Process Configuration.
Definition: InputSource.h:194
int treeMaxVirtualSize() const
Definition: PoolSource.h:45
ProductSelectorRules const & productSelectorRules() const
Definition: PoolSource.h:46
bool bypassVersionCheck() const
Definition: PoolSource.h:42
bool dropDescendants() const
Definition: PoolSource.h:41
ProcessingMode processingMode() const
RunsLumisAndEvents (default), RunsAndLumis, or Runs.
Definition: InputSource.h:226
std::vector< std::shared_ptr< IndexIntoFile > > const & indexesIntoFiles() const

◆ nextFile()

bool edm::RootPrimaryFileSequence::nextFile ( )
private

Definition at line 182 of file RootPrimaryFileSequence.cc.

References cms::cuda::assert(), branchesMustMatch_, Exception, edm::RootInputFileSequence::fileNames(), edm::RootInputFileSequence::initFile(), input_, edm::ProductRegistry::merge(), edm::errors::MismatchedInputFiles, edm::RootInputFileSequence::noMoreFiles(), edm::PoolSource::productRegistryUpdate(), edm::RootInputFileSequence::rootFile(), edm::RootInputFileSequence::setAtNextFile(), edm::PoolSource::skipBadFiles(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by readFile_(), skipEvents(), and skipEventsAtBeginning().

182  {
183  do {
184  if (!noMoreFiles())
185  setAtNextFile();
186  if (noMoreFiles()) {
187  return false;
188  }
189 
191  if (rootFile()) {
192  break;
193  }
194  // If we are not skipping bad files and the file
195  // open failed, then initFile should have thrown
197  } while (true);
198 
199  // make sure the new product registry is compatible with the main one
200  std::string mergeInfo =
201  input_.productRegistryUpdate().merge(*rootFile()->productRegistry(), fileNames()[0], branchesMustMatch_);
202  if (!mergeInfo.empty()) {
203  throw Exception(errors::MismatchedInputFiles, "RootPrimaryFileSequence::nextFile()") << mergeInfo;
204  }
205  return true;
206  }
void initFile(bool skipBadFiles)
bool skipBadFiles() const
Definition: PoolSource.h:40
ProductRegistry & productRegistryUpdate()
Definition: InputSource.h:330
assert(be >=bs)
std::vector< std::string > const & fileNames() const
std::string merge(ProductRegistry const &other, std::string const &fileName, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
std::shared_ptr< RootFile const > rootFile() const
BranchDescription::MatchMode branchesMustMatch_

◆ operator=()

RootPrimaryFileSequence& edm::RootPrimaryFileSequence::operator= ( RootPrimaryFileSequence const &  )
delete

◆ previousFile()

bool edm::RootPrimaryFileSequence::previousFile ( )
private

Definition at line 208 of file RootPrimaryFileSequence.cc.

References edm::RootInputFileSequence::atFirstFile(), branchesMustMatch_, Exception, edm::RootInputFileSequence::fileNames(), edm::RootInputFileSequence::initFile(), input_, edm::ProductRegistry::merge(), edm::errors::MismatchedInputFiles, edm::PoolSource::productRegistryUpdate(), edm::RootInputFileSequence::rootFile(), edm::RootInputFileSequence::setAtPreviousFile(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by skipEvents().

208  {
209  if (atFirstFile()) {
210  return false;
211  }
213 
214  initFile(false);
215 
216  if (rootFile()) {
217  // make sure the new product registry is compatible to the main one
218  std::string mergeInfo =
219  input_.productRegistryUpdate().merge(*rootFile()->productRegistry(), fileNames()[0], branchesMustMatch_);
220  if (!mergeInfo.empty()) {
221  throw Exception(errors::MismatchedInputFiles, "RootPrimaryFileSequence::previousEvent()") << mergeInfo;
222  }
223  }
224  if (rootFile())
225  rootFile()->setToLastEntry();
226  return true;
227  }
void initFile(bool skipBadFiles)
ProductRegistry & productRegistryUpdate()
Definition: InputSource.h:330
std::vector< std::string > const & fileNames() const
std::string merge(ProductRegistry const &other, std::string const &fileName, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
std::shared_ptr< RootFile const > rootFile() const
BranchDescription::MatchMode branchesMustMatch_

◆ readFile_()

std::shared_ptr< FileBlock > edm::RootPrimaryFileSequence::readFile_ ( )

Definition at line 83 of file RootPrimaryFileSequence.cc.

References cms::cuda::assert(), fb_, firstFile_, newFWLiteAna::found, goToEventID_, goToEventInNewFile_, goToFileSequenceOffset_, edm::RootInputFileSequence::initFile(), input_, nextFile(), edm::RootInputFileSequence::rootFile(), edm::RootInputFileSequence::setAtFileSequenceNumber(), edm::PoolSource::skipBadFiles(), skipIntoNewFile_, skipToFileSequenceNumber_, and skipToOffsetInFinalFile_.

83  {
84  std::shared_ptr<FileBlock> fileBlock;
85  if (firstFile_) {
86  firstFile_ = false;
87  // Usually the first input file will already be open
88  if (!rootFile()) {
90  }
91  } else if (goToEventInNewFile_) {
92  goToEventInNewFile_ = false;
94  initFile(false);
95  assert(rootFile());
96  bool found = rootFile()->goToEvent(goToEventID_);
97  assert(found);
98  } else if (skipIntoNewFile_) {
99  skipIntoNewFile_ = false;
101  initFile(false);
102  assert(rootFile());
103  if (skipToOffsetInFinalFile_ < 0) {
104  rootFile()->setToLastEntry();
105  }
106  bool atEnd = rootFile()->skipEvents(skipToOffsetInFinalFile_);
107  assert(!atEnd && skipToOffsetInFinalFile_ == 0);
108  } else {
109  if (!nextFile()) {
110  // handle case with last file bad and
111  // skipBadFiles true
112  fb_ = fileBlock;
113  return fileBlock;
114  }
115  }
116  if (!rootFile()) {
117  fileBlock = std::make_shared<FileBlock>();
118  fb_ = fileBlock;
119  return fileBlock;
120  }
121  fileBlock = rootFile()->createFileBlock();
122  fb_ = fileBlock;
123  return fileBlock;
124  }
void initFile(bool skipBadFiles)
void setAtFileSequenceNumber(size_t offset)
bool skipBadFiles() const
Definition: PoolSource.h:40
assert(be >=bs)
std::shared_ptr< RootFile const > rootFile() const
edm::propagate_const< std::shared_ptr< FileBlock > > fb_

◆ remainingEvents()

int edm::RootPrimaryFileSequence::remainingEvents ( ) const
private

Definition at line 409 of file RootPrimaryFileSequence.cc.

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

Referenced by makeRootFile(), and RootPrimaryFileSequence().

409 { return input_.remainingEvents(); }
int remainingEvents() const
Definition: InputSource.h:180

◆ remainingLuminosityBlocks()

int edm::RootPrimaryFileSequence::remainingLuminosityBlocks ( ) const
private

◆ reverseState()

ProcessingController::ReverseState edm::RootPrimaryFileSequence::reverseState ( ) const

◆ rewind_()

void edm::RootPrimaryFileSequence::rewind_ ( )

Definition at line 257 of file RootPrimaryFileSequence.cc.

References edm::RootInputFileSequence::atFirstFile(), edm::RootInputFileSequence::closeFile(), firstFile_, goToEventInNewFile_, edm::RootInputFileSequence::initFile(), initialNumberOfEventsToSkip_, rewindFile(), edm::RootInputFileSequence::rootFile(), edm::RootInputFileSequence::setAtFirstFile(), skipEventsAtBeginning(), skipIntoNewFile_, and skipToStop_.

257  {
258  if (!atFirstFile()) {
259  closeFile();
260  setAtFirstFile();
261  }
262  if (!rootFile()) {
263  initFile(false);
264  }
265  rewindFile();
266  firstFile_ = true;
267  goToEventInNewFile_ = false;
268  skipIntoNewFile_ = false;
269  skipToStop_ = false;
270  if (rootFile()) {
271  if (initialNumberOfEventsToSkip_ != 0) {
273  }
274  }
275  }
void initFile(bool skipBadFiles)
std::shared_ptr< RootFile const > rootFile() const

◆ rewindFile()

void edm::RootPrimaryFileSequence::rewindFile ( )
private

Definition at line 278 of file RootPrimaryFileSequence.cc.

References edm::RootInputFileSequence::rootFile().

Referenced by rewind_().

278  {
279  if (rootFile())
280  rootFile()->rewind();
281  }
std::shared_ptr< RootFile const > rootFile() const

◆ skipEvents()

void edm::RootPrimaryFileSequence::skipEvents ( int  offset)

Definition at line 296 of file RootPrimaryFileSequence.cc.

References cms::cuda::assert(), edm::RootInputFileSequence::atFirstFile(), edm::RootInputFileSequence::atLastFile(), fb_, edm::RootInputFileSequence::initFile(), nextFile(), edm::RootInputFileSequence::noMoreFiles(), hltrates_dqm_sourceclient-live_cfg::offset, previousFile(), edm::RootInputFileSequence::rootFile(), edm::RootInputFileSequence::sequenceNumberOfFile(), edm::RootInputFileSequence::setAtFileSequenceNumber(), skipIntoNewFile_, skipToFileSequenceNumber_, skipToOffsetInFinalFile_, and skipToStop_.

296  {
297  assert(rootFile());
298 
299  bool atEnd = rootFile()->skipEvents(offset);
300  if (!atEnd && offset == 0) {
301  // successfully completed skip within current file
302  return;
303  }
304 
305  // Return, if without closing the current file we know the skip cannot be completed
306  skipToStop_ = false;
307  if (offset > 0 || atEnd) {
308  if (atLastFile() || noMoreFiles()) {
309  skipToStop_ = true;
310  return;
311  }
312  }
313  if (offset < 0 && atFirstFile()) {
314  skipToStop_ = true;
315  return;
316  }
317 
318  // Save the current file and position so that we can restore them
319  size_t const originalFileSequenceNumber = sequenceNumberOfFile();
320  IndexIntoFile::IndexIntoFileItr originalPosition = rootFile()->indexIntoFileIter();
321 
322  if ((offset > 0 || atEnd) && !nextFile()) {
323  skipToStop_ = true; // Can only get here if skipBadFiles is true
324  }
325  if (offset < 0 && !previousFile()) {
326  skipToStop_ = true; // Can't actually get here
327  }
328 
329  if (!skipToStop_) {
330  while (offset != 0) {
332  bool atEnd = rootFile()->skipEvents(offset);
333  if ((offset > 0 || atEnd) && !nextFile()) {
334  skipToStop_ = true;
335  break;
336  }
337  if (offset < 0 && !previousFile()) {
338  skipToStop_ = true;
339  break;
340  }
341  }
342  if (!skipToStop_) {
343  skipIntoNewFile_ = true;
344  }
345  }
347 
348  // Restore the original file and position
349  setAtFileSequenceNumber(originalFileSequenceNumber);
350  initFile(false);
351  assert(rootFile());
352  rootFile()->setPosition(originalPosition);
353  rootFile()->updateFileBlock(*fb_);
354  }
void initFile(bool skipBadFiles)
void setAtFileSequenceNumber(size_t offset)
assert(be >=bs)
std::shared_ptr< RootFile const > rootFile() const
edm::propagate_const< std::shared_ptr< FileBlock > > fb_

◆ skipEventsAtBeginning()

void edm::RootPrimaryFileSequence::skipEventsAtBeginning ( int  offset)

Definition at line 284 of file RootPrimaryFileSequence.cc.

References cms::cuda::assert(), nextFile(), hltrates_dqm_sourceclient-live_cfg::offset, and edm::RootInputFileSequence::rootFile().

Referenced by rewind_(), and RootPrimaryFileSequence().

284  {
285  assert(rootFile());
286  assert(offset >= 0);
287  while (offset != 0) {
288  bool atEnd = rootFile()->skipEvents(offset);
289  if ((offset > 0 || atEnd) && !nextFile()) {
290  return;
291  }
292  }
293  }
assert(be >=bs)
std::shared_ptr< RootFile const > rootFile() const

Member Data Documentation

◆ branchesMustMatch_

BranchDescription::MatchMode edm::RootPrimaryFileSequence::branchesMustMatch_
private

Definition at line 66 of file RootPrimaryFileSequence.h.

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

◆ duplicateChecker_

edm::propagate_const<std::shared_ptr<DuplicateChecker> > edm::RootPrimaryFileSequence::duplicateChecker_
private

Definition at line 80 of file RootPrimaryFileSequence.h.

Referenced by closeFile_(), duplicateChecker(), and initFile_().

◆ enablePrefetching_

bool edm::RootPrimaryFileSequence::enablePrefetching_
private

Definition at line 89 of file RootPrimaryFileSequence.h.

Referenced by makeRootFile(), and RootPrimaryFileSequence().

◆ enforceGUIDInFileName_

bool edm::RootPrimaryFileSequence::enforceGUIDInFileName_
private

Definition at line 90 of file RootPrimaryFileSequence.h.

Referenced by makeRootFile().

◆ eventSkipperByID_

edm::propagate_const<std::shared_ptr<EventSkipperByID> > edm::RootPrimaryFileSequence::eventSkipperByID_
private

Definition at line 75 of file RootPrimaryFileSequence.h.

Referenced by eventSkipperByID().

◆ fb_

edm::propagate_const<std::shared_ptr<FileBlock> > edm::RootPrimaryFileSequence::fb_
private

Definition at line 74 of file RootPrimaryFileSequence.h.

Referenced by goToEvent(), readFile_(), and skipEvents().

◆ firstFile_

bool edm::RootPrimaryFileSequence::firstFile_
private

Definition at line 65 of file RootPrimaryFileSequence.h.

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

◆ goToEventID_

EventID edm::RootPrimaryFileSequence::goToEventID_
private

Definition at line 84 of file RootPrimaryFileSequence.h.

Referenced by goToEvent(), and readFile_().

◆ goToEventInNewFile_

bool edm::RootPrimaryFileSequence::goToEventInNewFile_ = false
private

Definition at line 82 of file RootPrimaryFileSequence.h.

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

◆ goToFileSequenceOffset_

size_t edm::RootPrimaryFileSequence::goToFileSequenceOffset_ = 0
private

Definition at line 83 of file RootPrimaryFileSequence.h.

Referenced by goToEvent(), and readFile_().

◆ initialNumberOfEventsToSkip_

int edm::RootPrimaryFileSequence::initialNumberOfEventsToSkip_
private

Definition at line 76 of file RootPrimaryFileSequence.h.

Referenced by makeRootFile(), rewind_(), and RootPrimaryFileSequence().

◆ input_

PoolSource& edm::RootPrimaryFileSequence::input_
private

◆ noEventSort_

bool edm::RootPrimaryFileSequence::noEventSort_
private

Definition at line 78 of file RootPrimaryFileSequence.h.

Referenced by makeRootFile().

◆ noRunLumiSort_

bool edm::RootPrimaryFileSequence::noRunLumiSort_
private

Definition at line 77 of file RootPrimaryFileSequence.h.

Referenced by makeRootFile(), and RootPrimaryFileSequence().

◆ orderedProcessHistoryIDs_

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

Definition at line 67 of file RootPrimaryFileSequence.h.

Referenced by makeRootFile().

◆ skipIntoNewFile_

bool edm::RootPrimaryFileSequence::skipIntoNewFile_ = false
private

Definition at line 86 of file RootPrimaryFileSequence.h.

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

◆ skipToFileSequenceNumber_

size_t edm::RootPrimaryFileSequence::skipToFileSequenceNumber_ = 0
private

Definition at line 87 of file RootPrimaryFileSequence.h.

Referenced by readFile_(), and skipEvents().

◆ skipToOffsetInFinalFile_

int edm::RootPrimaryFileSequence::skipToOffsetInFinalFile_ = 0
private

Definition at line 88 of file RootPrimaryFileSequence.h.

Referenced by readFile_(), and skipEvents().

◆ skipToStop_

bool edm::RootPrimaryFileSequence::skipToStop_ = false
private

Definition at line 85 of file RootPrimaryFileSequence.h.

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

◆ treeCacheSize_

unsigned int edm::RootPrimaryFileSequence::treeCacheSize_
private

Definition at line 79 of file RootPrimaryFileSequence.h.

Referenced by makeRootFile(), and RootPrimaryFileSequence().

◆ usingGoToEvent_

bool edm::RootPrimaryFileSequence::usingGoToEvent_
private

Definition at line 81 of file RootPrimaryFileSequence.h.

Referenced by goToEvent(), initFile_(), and makeRootFile().