CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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)
 
void readLuminosityBlock_ (LuminosityBlockPrincipal &lumiPrincipal)
 
std::shared_ptr
< LuminosityBlockAuxiliary
readLuminosityBlockAuxiliary_ ()
 
void readProcessBlock_ (ProcessBlockPrincipal &)
 
void 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

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

Definition at line 22 of file RootPrimaryFileSequence.cc.

References branchesMustMatch_, enablePrefetching_, edm::RootInputFileSequence::fileNames(), edm::storage::StorageFactory::get(), edm::ParameterSet::getUntrackedParameter(), edm::RootInputFileSequence::initFile(), initialNumberOfEventsToSkip_, input_, edm::Service< T >::isAvailable(), edm::RootInputFileSequence::noMoreFiles(), edm::InputSource::productRegistryUpdate(), edm::RootInputFileSequence::rootFile(), edm::RootInputFileSequence::setAtFirstFile(), edm::RootInputFileSequence::setAtNextFile(), edm::PoolSource::skipBadFiles(), skipEventsAtBeginning(), edm::storage::StorageFactory::stagein(), edm::BranchDescription::Strict, AlCaHLTBitMon_QueryRunRegistry::string, treeCacheSize_, 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  // The SiteLocalConfig controls the TTreeCache size and the prefetching settings.
41  if (pSLC.isAvailable()) {
42  if (treeCacheSize_ != 0U && pSLC->sourceTTreeCacheSize()) {
43  treeCacheSize_ = *(pSLC->sourceTTreeCacheSize());
44  }
45  enablePrefetching_ = pSLC->enablePrefetching();
46  }
47 
48  std::string branchesMustMatch =
49  pset.getUntrackedParameter<std::string>("branchesMustMatch", std::string("permissive"));
50  if (branchesMustMatch == std::string("strict"))
52 
53  // Prestage the files
56  }
57  // Open the first file.
60  if (rootFile())
61  break;
62  }
63  if (rootFile()) {
64  input_.productRegistryUpdate().updateFromInput(rootFile()->productRegistry()->productList());
67  }
68  }
69  }
void initFile(bool skipBadFiles)
ProductRegistry & productRegistryUpdate()
Definition: InputSource.h:330
std::vector< std::string > const & fileNames() const
static std::unique_ptr< EventSkipperByID > create(ParameterSet const &pset)
edm::propagate_const< std::shared_ptr< EventSkipperByID > > eventSkipperByID_
static std::string const input
Definition: EdmProvDump.cc:47
std::vector< ProcessHistoryID > orderedProcessHistoryIDs_
std::shared_ptr< RootFile const > rootFile() const
bool skipBadFiles() const
Definition: PoolSource.h:40
edm::propagate_const< std::shared_ptr< DuplicateChecker > > duplicateChecker_
BranchDescription::MatchMode branchesMustMatch_
void updateFromInput(ProductList const &other)
RootInputFileSequence(ParameterSet const &pset, InputFileCatalog const &catalog)
void stagein(const std::string &url) const
static const StorageFactory * get(void)
edm::RootPrimaryFileSequence::~RootPrimaryFileSequence ( )
override

Definition at line 71 of file RootPrimaryFileSequence.cc.

71 {}
edm::RootPrimaryFileSequence::RootPrimaryFileSequence ( RootPrimaryFileSequence const &  )
delete

Member Function Documentation

void edm::RootPrimaryFileSequence::closeFile_ ( )
overrideprivatevirtual

Implements edm::RootInputFileSequence.

Definition at line 118 of file RootPrimaryFileSequence.cc.

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

118  {
119  // close the currently open file, if any, and delete the RootFile object.
120  if (rootFile()) {
121  auto sentry = std::make_unique<InputSource::FileCloseSentry>(input_, lfn(), usedFallback());
122  rootFile()->close();
123  if (duplicateChecker_)
124  duplicateChecker_->inputFileClosed();
125  rootFile().reset();
126  }
127  }
std::string const & lfn() const
std::shared_ptr< RootFile const > rootFile() const
edm::propagate_const< std::shared_ptr< DuplicateChecker > > duplicateChecker_
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_
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_
void edm::RootPrimaryFileSequence::endJob ( void  )
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)
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)
void edm::RootPrimaryFileSequence::fillDescription ( ParameterSetDescription desc)
static

Definition at line 405 of file RootPrimaryFileSequence.cc.

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

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

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

Definition at line 221 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(), skipIntoNewFile_, and skipToStop_.

223  {
224  if (noMoreFiles() || skipToStop_) {
225  skipToStop_ = false;
226  return InputSource::IsStop;
227  }
229  return InputSource::IsFile;
230  }
231  if (rootFile()) {
232  IndexIntoFile::EntryType entryType = rootFile()->getNextItemType(run, lumi, event);
233  if (entryType == IndexIntoFile::kEvent) {
234  return InputSource::IsEvent;
235  } else if (entryType == IndexIntoFile::kLumi) {
236  return InputSource::IsLumi;
237  } else if (entryType == IndexIntoFile::kRun) {
238  return InputSource::IsRun;
239  }
240  assert(entryType == IndexIntoFile::kEnd);
241  }
242  if (atLastFile()) {
243  return InputSource::IsStop;
244  }
245  return InputSource::IsFile;
246  }
assert(be >=bs)
list lumi
Definition: dqmdumpme.py:53
std::shared_ptr< RootFile const > rootFile() const
bool edm::RootPrimaryFileSequence::goToEvent ( EventID const &  eventID)

Definition at line 348 of file RootPrimaryFileSequence.cc.

References cms::cuda::assert(), SplitLinear::begin, dataset::end, 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(), findQualityFiles::size, and usingGoToEvent_.

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

Implements edm::RootInputFileSequence.

Definition at line 129 of file RootPrimaryFileSequence.cc.

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

129  {
130  // If we are not duplicate checking across files and we are not using random access to find events,
131  // then we can delete the IndexIntoFile for the file we are closing.
132  // If we can't delete all of it, then we can delete the parts we do not need.
133  bool deleteIndexIntoFile = !usingGoToEvent_ && !(duplicateChecker_ && duplicateChecker_->checkingAllFiles() &&
134  !duplicateChecker_->checkDisabled());
135  initTheFile(skipBadFiles, deleteIndexIntoFile, &input_, "primaryFiles", InputType::Primary);
136  }
void initTheFile(bool skipBadFiles, bool deleteIndexIntoFile, InputSource *input, char const *inputTypeName, InputType inputType)
edm::propagate_const< std::shared_ptr< DuplicateChecker > > duplicateChecker_
RootPrimaryFileSequence::RootFileSharedPtr edm::RootPrimaryFileSequence::makeRootFile ( std::shared_ptr< InputFile filePtr)
overrideprivatevirtual

Implements edm::RootInputFileSequence.

Definition at line 138 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::InputSource::processHistoryRegistryForUpdate(), edm::InputSource::processingMode(), edm::PoolSource::productSelectorRules(), remainingEvents(), remainingLuminosityBlocks(), edm::PoolSource::runHelper(), edm::RootInputFileSequence::sequenceNumberOfFile(), edm::InputSource::thinnedAssociationsHelper(), treeCacheSize_, edm::PoolSource::treeMaxVirtualSize(), and usingGoToEvent_.

138  {
139  size_t currentIndexIntoFile = sequenceNumberOfFile();
140  return std::make_shared<RootFile>(fileNames()[0],
142  logicalFileName(),
143  filePtr,
146  remainingEvents(),
148  input_.nStreams(),
152  input_.runHelper(),
154  noEventSort_,
158  input_.processBlockHelper().get(),
160  nullptr, // associationsFromSecondary
165  currentIndexIntoFile,
172  }
std::string const & logicalFileName() const
std::shared_ptr< ProcessBlockHelper const > processBlockHelper() const
Accessors for processBlockHelper.
Definition: InputSource.h:150
std::vector< std::string > const & fileNames() const
std::vector< std::shared_ptr< IndexIntoFile > > const & indexesIntoFiles() const
ProcessingMode processingMode() const
RunsLumisAndEvents (default), RunsAndLumis, or Runs.
Definition: InputSource.h:224
RunHelperBase * runHelper()
Definition: PoolSource.h:47
std::vector< ProcessHistoryID > orderedProcessHistoryIDs_
unsigned int nStreams() const
Definition: PoolSource.h:44
bool dropDescendants() const
Definition: PoolSource.h:41
bool bypassVersionCheck() const
Definition: PoolSource.h:42
int treeMaxVirtualSize() const
Definition: PoolSource.h:45
std::shared_ptr< EventSkipperByID const > eventSkipperByID() const
std::shared_ptr< BranchIDListHelper const > branchIDListHelper() const
Accessors for branchIDListHelper.
Definition: InputSource.h:144
bool labelRawDataLikeMC() const
Definition: PoolSource.h:43
ProcessHistoryRegistry & processHistoryRegistryForUpdate()
Definition: InputSource.h:331
std::shared_ptr< ThinnedAssociationsHelper const > thinnedAssociationsHelper() const
Accessors for thinnedAssociationsHelper.
Definition: InputSource.h:156
ProcessConfiguration const & processConfiguration() const
Accessor for Process Configuration.
Definition: InputSource.h:192
std::shared_ptr< DuplicateChecker const > duplicateChecker() const
ProductSelectorRules const & productSelectorRules() const
Definition: PoolSource.h:46
bool edm::RootPrimaryFileSequence::nextFile ( )
private

Definition at line 174 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::InputSource::productRegistryUpdate(), edm::RootInputFileSequence::rootFile(), edm::RootInputFileSequence::setAtNextFile(), edm::PoolSource::skipBadFiles(), and AlCaHLTBitMon_QueryRunRegistry::string.

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

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

Definition at line 200 of file RootPrimaryFileSequence.cc.

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

Referenced by skipEvents().

200  {
201  if (atFirstFile()) {
202  return false;
203  }
205 
206  initFile(false);
207 
208  if (rootFile()) {
209  // make sure the new product registry is compatible to the main one
210  std::string mergeInfo =
211  input_.productRegistryUpdate().merge(*rootFile()->productRegistry(), fileNames()[0], branchesMustMatch_);
212  if (!mergeInfo.empty()) {
213  throw Exception(errors::MismatchedInputFiles, "RootPrimaryFileSequence::previousEvent()") << mergeInfo;
214  }
215  }
216  if (rootFile())
217  rootFile()->setToLastEntry();
218  return true;
219  }
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_
std::shared_ptr< FileBlock > edm::RootPrimaryFileSequence::readFile_ ( )

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

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

Definition at line 401 of file RootPrimaryFileSequence.cc.

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

Referenced by makeRootFile().

401 { return input_.remainingEvents(); }
int remainingEvents() const
Definition: InputSource.h:178
int edm::RootPrimaryFileSequence::remainingLuminosityBlocks ( ) const
private

Definition at line 403 of file RootPrimaryFileSequence.cc.

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

Referenced by makeRootFile().

403 { return input_.remainingLuminosityBlocks(); }
int remainingLuminosityBlocks() const
Definition: InputSource.h:186
ProcessingController::ReverseState edm::RootPrimaryFileSequence::reverseState ( ) const
void edm::RootPrimaryFileSequence::rewind_ ( )

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

249  {
250  if (!atFirstFile()) {
251  closeFile();
252  setAtFirstFile();
253  }
254  if (!rootFile()) {
255  initFile(false);
256  }
257  rewindFile();
258  firstFile_ = true;
259  goToEventInNewFile_ = false;
260  skipIntoNewFile_ = false;
261  skipToStop_ = false;
262  if (rootFile()) {
263  if (initialNumberOfEventsToSkip_ != 0) {
265  }
266  }
267  }
void initFile(bool skipBadFiles)
std::shared_ptr< RootFile const > rootFile() const
void edm::RootPrimaryFileSequence::rewindFile ( )
private

Definition at line 270 of file RootPrimaryFileSequence.cc.

References edm::RootInputFileSequence::rootFile().

Referenced by rewind_().

270  {
271  if (rootFile())
272  rootFile()->rewind();
273  }
std::shared_ptr< RootFile const > rootFile() const
void edm::RootPrimaryFileSequence::skipEvents ( int  offset)

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

288  {
289  assert(rootFile());
290 
291  bool atEnd = rootFile()->skipEvents(offset);
292  if (!atEnd && offset == 0) {
293  // successfully completed skip within current file
294  return;
295  }
296 
297  // Return, if without closing the current file we know the skip cannot be completed
298  skipToStop_ = false;
299  if (offset > 0 || atEnd) {
300  if (atLastFile() || noMoreFiles()) {
301  skipToStop_ = true;
302  return;
303  }
304  }
305  if (offset < 0 && atFirstFile()) {
306  skipToStop_ = true;
307  return;
308  }
309 
310  // Save the current file and position so that we can restore them
311  size_t const originalFileSequenceNumber = sequenceNumberOfFile();
312  IndexIntoFile::IndexIntoFileItr originalPosition = rootFile()->indexIntoFileIter();
313 
314  if ((offset > 0 || atEnd) && !nextFile()) {
315  skipToStop_ = true; // Can only get here if skipBadFiles is true
316  }
317  if (offset < 0 && !previousFile()) {
318  skipToStop_ = true; // Can't actually get here
319  }
320 
321  if (!skipToStop_) {
322  while (offset != 0) {
324  bool atEnd = rootFile()->skipEvents(offset);
325  if ((offset > 0 || atEnd) && !nextFile()) {
326  skipToStop_ = true;
327  break;
328  }
329  if (offset < 0 && !previousFile()) {
330  skipToStop_ = true;
331  break;
332  }
333  }
334  if (!skipToStop_) {
335  skipIntoNewFile_ = true;
336  }
337  }
339 
340  // Restore the original file and position
341  setAtFileSequenceNumber(originalFileSequenceNumber);
342  initFile(false);
343  assert(rootFile());
344  rootFile()->setPosition(originalPosition);
345  rootFile()->updateFileBlock(*fb_);
346  }
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_
void edm::RootPrimaryFileSequence::skipEventsAtBeginning ( int  offset)

Definition at line 276 of file RootPrimaryFileSequence.cc.

References cms::cuda::assert(), nextFile(), and edm::RootInputFileSequence::rootFile().

Referenced by rewind_(), and RootPrimaryFileSequence().

276  {
277  assert(rootFile());
278  assert(offset >= 0);
279  while (offset != 0) {
280  bool atEnd = rootFile()->skipEvents(offset);
281  if ((offset > 0 || atEnd) && !nextFile()) {
282  return;
283  }
284  }
285  }
assert(be >=bs)
std::shared_ptr< RootFile const > rootFile() const

Member Data Documentation

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

Definition at line 66 of file RootPrimaryFileSequence.h.

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

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

bool edm::RootPrimaryFileSequence::enablePrefetching_
private

Definition at line 89 of file RootPrimaryFileSequence.h.

Referenced by makeRootFile(), and RootPrimaryFileSequence().

bool edm::RootPrimaryFileSequence::enforceGUIDInFileName_
private

Definition at line 90 of file RootPrimaryFileSequence.h.

Referenced by makeRootFile().

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

Definition at line 75 of file RootPrimaryFileSequence.h.

Referenced by eventSkipperByID().

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().

bool edm::RootPrimaryFileSequence::firstFile_
private

Definition at line 65 of file RootPrimaryFileSequence.h.

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

EventID edm::RootPrimaryFileSequence::goToEventID_
private

Definition at line 84 of file RootPrimaryFileSequence.h.

Referenced by goToEvent(), and readFile_().

bool edm::RootPrimaryFileSequence::goToEventInNewFile_ = false
private

Definition at line 82 of file RootPrimaryFileSequence.h.

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

size_t edm::RootPrimaryFileSequence::goToFileSequenceOffset_ = 0
private

Definition at line 83 of file RootPrimaryFileSequence.h.

Referenced by goToEvent(), and readFile_().

int edm::RootPrimaryFileSequence::initialNumberOfEventsToSkip_
private

Definition at line 76 of file RootPrimaryFileSequence.h.

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

PoolSource& edm::RootPrimaryFileSequence::input_
private
bool edm::RootPrimaryFileSequence::noEventSort_
private

Definition at line 78 of file RootPrimaryFileSequence.h.

Referenced by makeRootFile().

bool edm::RootPrimaryFileSequence::noRunLumiSort_
private

Definition at line 77 of file RootPrimaryFileSequence.h.

Referenced by makeRootFile().

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

Definition at line 67 of file RootPrimaryFileSequence.h.

Referenced by makeRootFile().

bool edm::RootPrimaryFileSequence::skipIntoNewFile_ = false
private

Definition at line 86 of file RootPrimaryFileSequence.h.

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

size_t edm::RootPrimaryFileSequence::skipToFileSequenceNumber_ = 0
private

Definition at line 87 of file RootPrimaryFileSequence.h.

Referenced by readFile_(), and skipEvents().

int edm::RootPrimaryFileSequence::skipToOffsetInFinalFile_ = 0
private

Definition at line 88 of file RootPrimaryFileSequence.h.

Referenced by readFile_(), and skipEvents().

bool edm::RootPrimaryFileSequence::skipToStop_ = false
private

Definition at line 85 of file RootPrimaryFileSequence.h.

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

unsigned int edm::RootPrimaryFileSequence::treeCacheSize_
private

Definition at line 79 of file RootPrimaryFileSequence.h.

Referenced by makeRootFile(), and RootPrimaryFileSequence().

bool edm::RootPrimaryFileSequence::usingGoToEvent_
private

Definition at line 81 of file RootPrimaryFileSequence.h.

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