CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Types | Protected Member Functions | Private Member Functions | Private Attributes
edm::RootInputFileSequence Class Referenceabstract

#include <RootInputFileSequence.h>

Inheritance diagram for edm::RootInputFileSequence:
edm::RootEmbeddedFileSequence edm::RootPrimaryFileSequence edm::RootSecondaryFileSequence

Public Member Functions

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
 
RootInputFileSequenceoperator= (RootInputFileSequence const &)=delete
 
void readEvent (EventPrincipal &cache)
 
void readLuminosityBlock_ (LuminosityBlockPrincipal &lumiPrincipal)
 
std::shared_ptr< LuminosityBlockAuxiliaryreadLuminosityBlockAuxiliary_ ()
 
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 ()
 

Protected Types

typedef std::shared_ptr< RootFileRootFileSharedPtr
 

Protected Member Functions

bool atFirstFile () const
 
bool atLastFile () const
 
std::string const & fallbackFileName () const
 
std::vector< FileCatalogItem > const & fileCatalogItems () const
 
std::string const & fileName () 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
 

Private Member Functions

virtual void closeFile_ ()=0
 
virtual void initFile_ (bool skipBadFiles)=0
 
virtual RootFileSharedPtr makeRootFile (std::shared_ptr< InputFile > filePtr)=0
 

Private Attributes

InputFileCatalog const & catalog_
 
std::vector< FileCatalogItem >::const_iterator fileIter_
 
std::vector< FileCatalogItem >::const_iterator const fileIterBegin_
 
std::vector< FileCatalogItem >::const_iterator const fileIterEnd_
 
std::vector< FileCatalogItem >::const_iterator fileIterLastOpened_
 
edm::propagate_const< std::unique_ptr< std::unordered_multimap< size_t, size_t > > > findFileForSpecifiedID_
 
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
 
std::string lfn_
 
size_t lfnHash_
 
edm::propagate_const< RootFileSharedPtrrootFile_
 
bool usedFallback_
 

Detailed Description

Definition at line 29 of file RootInputFileSequence.h.

Member Typedef Documentation

typedef std::shared_ptr<RootFile> edm::RootInputFileSequence::RootFileSharedPtr
protected

Definition at line 52 of file RootInputFileSequence.h.

Constructor & Destructor Documentation

edm::RootInputFileSequence::RootInputFileSequence ( ParameterSet const &  pset,
InputFileCatalog const &  catalog 
)
explicit

Definition at line 22 of file RootInputFileSequence.cc.

23  : catalog_(catalog),
24  lfn_("unknown"),
25  lfnHash_(0U),
26  usedFallback_(false),
27  findFileForSpecifiedID_(nullptr),
32  rootFile_(),
size
Write out results.
std::vector< FileCatalogItem >::const_iterator fileIter_
std::vector< FileCatalogItem >::const_iterator const fileIterEnd_
std::vector< FileCatalogItem >::const_iterator const fileIterBegin_
std::vector< FileCatalogItem >::const_iterator fileIterLastOpened_
std::vector< FileCatalogItem > const & fileCatalogItems() const
#define end
Definition: vmac.h:39
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
edm::propagate_const< RootFileSharedPtr > rootFile_
#define begin
Definition: vmac.h:32
edm::propagate_const< std::unique_ptr< std::unordered_multimap< size_t, size_t > > > findFileForSpecifiedID_
InputFileCatalog const & catalog_
edm::RootInputFileSequence::~RootInputFileSequence ( )
virtual

Definition at line 49 of file RootInputFileSequence.cc.

49 {}
edm::RootInputFileSequence::RootInputFileSequence ( RootInputFileSequence const &  )
delete

Member Function Documentation

bool edm::RootInputFileSequence::atFirstFile ( ) const
inlineprotected
bool edm::RootInputFileSequence::atLastFile ( ) const
inlineprotected

Definition at line 63 of file RootInputFileSequence.h.

References fileIter_, and fileIterEnd_.

Referenced by edm::RootPrimaryFileSequence::forwardState(), and edm::RootPrimaryFileSequence::getNextItemType().

63 { return fileIter_ + 1 == fileIterEnd_; }
std::vector< FileCatalogItem >::const_iterator const fileIterEnd_
std::vector< FileCatalogItem >::const_iterator fileIter_
virtual void edm::RootInputFileSequence::closeFile_ ( )
privatepure virtual
bool edm::RootInputFileSequence::containedInCurrentFile ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const

Definition at line 89 of file RootInputFileSequence.cc.

References rootFile().

91  {
92  if (!rootFile())
93  return false;
94  return rootFile()->containsItem(run, lumi, event);
95  }
std::shared_ptr< RootFile const > rootFile() const
Definition: event.py:1
std::string const& edm::RootInputFileSequence::fallbackFileName ( ) const
inlineprotected

Definition at line 77 of file RootInputFileSequence.h.

References fileIter_.

Referenced by initTheFile().

77 { return fileIter_->fallbackFileName(); }
std::vector< FileCatalogItem >::const_iterator fileIter_
std::shared_ptr< BranchIDListHelper const > edm::RootInputFileSequence::fileBranchIDListHelper ( ) const

Definition at line 44 of file RootInputFileSequence.cc.

References rootFile().

44  {
45  assert(rootFile());
46  return rootFile()->branchIDListHelper();
47  }
std::shared_ptr< RootFile const > rootFile() const
std::vector< FileCatalogItem > const & edm::RootInputFileSequence::fileCatalogItems ( ) const
protected

Definition at line 35 of file RootInputFileSequence.cc.

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

Referenced by lfn(), and edm::RootEmbeddedFileSequence::readOneRandom().

35  {
36  return catalog_.fileCatalogItems();
37  }
std::vector< FileCatalogItem > const & fileCatalogItems() const
InputFileCatalog const & catalog_
std::string const& edm::RootInputFileSequence::fileName ( ) const
inlineprotected
std::shared_ptr< ProductRegistry const > edm::RootInputFileSequence::fileProductRegistry ( ) const

Definition at line 39 of file RootInputFileSequence.cc.

References rootFile().

39  {
40  assert(rootFile());
41  return rootFile()->productRegistry();
42  }
std::shared_ptr< RootFile const > rootFile() const
std::vector<std::shared_ptr<IndexIntoFile> > const& edm::RootInputFileSequence::indexesIntoFiles ( ) const
inlineprotected
void edm::RootInputFileSequence::initFile ( bool  skipBadFiles)
inlineprotected
virtual void edm::RootInputFileSequence::initFile_ ( bool  skipBadFiles)
privatepure virtual
void edm::RootInputFileSequence::initTheFile ( bool  skipBadFiles,
bool  deleteIndexIntoFile,
InputSource input,
char const *  inputTypeName,
InputType  inputType 
)
protected

Definition at line 181 of file RootInputFileSequence.cc.

References cms::Exception::addAdditionalInfo(), cms::Exception::addContext(), cms::Exception::additionalInfo(), closeFile_(), MillePedeFileConverter_cfg::e, relativeConstraints::empty, Exception, cms::Exception::explainSelf(), fallbackFileName(), edm::errors::FallbackFileOpenError, fileIter_, fileIterBegin_, fileIterEnd_, fileIterLastOpened_, fileName(), edm::errors::FileOpenError, indexesIntoFiles_, ElectronMcFakePostValidator_cfi::InputFile, lfn_, lfnHash_, logicalFileName(), makeRootFile(), dataset::name, noMoreFiles(), MillePedeFileConverter_cfg::out, edm::InputSource::postEventReadFromSourceSignal_, edm::InputSource::preEventReadFromSourceSignal_, edm::InputFile::reportFallbackAttempt(), edm::InputFile::reportSkippedFile(), rootFile_, alignCSCRings::s, setIndexIntoFile(), AlCaHLTBitMon_QueryRunRegistry::string, and usedFallback_.

Referenced by initFile(), edm::RootSecondaryFileSequence::initFile_(), edm::RootPrimaryFileSequence::initFile_(), and edm::RootEmbeddedFileSequence::initFile_().

182  {
183  // We are really going to close the open file.
184 
186  size_t currentIndexIntoFile = fileIterLastOpened_ - fileIterBegin_;
187  if (deleteIndexIntoFile) {
188  indexesIntoFiles_[currentIndexIntoFile].reset();
189  } else {
190  if (indexesIntoFiles_[currentIndexIntoFile])
191  indexesIntoFiles_[currentIndexIntoFile]->inputFileClosed();
192  }
194  }
195  closeFile_();
196 
197  if (noMoreFiles()) {
198  // No files specified
199  return;
200  }
201 
202  // Check if the logical file name was found.
203  if (fileName().empty()) {
204  // LFN not found in catalog.
206  if (!skipBadFiles) {
207  throw cms::Exception("LogicalFileNameNotFound", "RootFileSequenceBase::initTheFile()\n")
208  << "Logical file name '" << logicalFileName() << "' was not found in the file catalog.\n"
209  << "If you wanted a local file, you forgot the 'file:' prefix\n"
210  << "before the file name in your configuration file.\n";
211  }
212  LogWarning("") << "Input logical file: " << logicalFileName()
213  << " was not found in the catalog, and will be skipped.\n";
214  return;
215  }
216 
217  lfn_ = logicalFileName().empty() ? fileName() : logicalFileName();
218  lfnHash_ = std::hash<std::string>()(lfn_);
219  usedFallback_ = false;
220 
221  // Determine whether we have a fallback URL specified; if so, prepare it;
222  // Only valid if it is non-empty and differs from the original filename.
223  bool hasFallbackUrl = !fallbackFileName().empty() && fallbackFileName() != fileName();
224 
225  std::shared_ptr<InputFile> filePtr;
226  std::list<std::string> originalInfo;
227  try {
228  std::unique_ptr<InputSource::FileOpenSentry> sentry(
229  input ? std::make_unique<InputSource::FileOpenSentry>(*input, lfn_, usedFallback_) : nullptr);
230  std::unique_ptr<char[]> name(gSystem->ExpandPathName(fileName().c_str()));
231  ;
232  filePtr = std::make_shared<InputFile>(name.get(), " Initiating request to open file ", inputType);
233  } catch (cms::Exception const& e) {
234  if (!skipBadFiles) {
235  if (hasFallbackUrl) {
236  std::ostringstream out;
237  out << e.explainSelf();
238 
239  std::unique_ptr<char[]> name(gSystem->ExpandPathName(fallbackFileName().c_str()));
240  std::string pfn(name.get());
242  originalInfo = e.additionalInfo();
243  } else {
245  Exception ex(errors::FileOpenError, "", e);
246  ex.addContext("Calling RootFileSequenceBase::initTheFile()");
247  std::ostringstream out;
248  out << "Input file " << fileName() << " could not be opened.";
249  ex.addAdditionalInfo(out.str());
250  throw ex;
251  }
252  }
253  }
254  if (!filePtr && (hasFallbackUrl)) {
255  try {
256  usedFallback_ = true;
257  std::unique_ptr<InputSource::FileOpenSentry> sentry(
258  input ? std::make_unique<InputSource::FileOpenSentry>(*input, lfn_, usedFallback_) : nullptr);
259  std::unique_ptr<char[]> fallbackFullName(gSystem->ExpandPathName(fallbackFileName().c_str()));
260  filePtr.reset(new InputFile(fallbackFullName.get(), " Fallback request to file ", inputType));
261  } catch (cms::Exception const& e) {
262  if (!skipBadFiles) {
265  ex.addContext("Calling RootFileSequenceBase::initTheFile()");
266  std::ostringstream out;
267  out << "Input file " << fileName() << " could not be opened.\n";
268  out << "Fallback Input file " << fallbackFileName() << " also could not be opened.";
269  if (!originalInfo.empty()) {
270  out << std::endl << "Original exception info is above; fallback exception info is below.";
271  ex.addAdditionalInfo(out.str());
272  for (auto const& s : originalInfo) {
273  ex.addAdditionalInfo(s);
274  }
275  } else {
276  ex.addAdditionalInfo(out.str());
277  }
278  throw ex;
279  }
280  }
281  }
282  if (filePtr) {
283  size_t currentIndexIntoFile = fileIter_ - fileIterBegin_;
284  rootFile_ = makeRootFile(filePtr);
285  if (input) {
286  rootFile_->setSignals(&(input->preEventReadFromSourceSignal_), &(input->postEventReadFromSourceSignal_));
287  }
288  assert(rootFile_);
290  setIndexIntoFile(currentIndexIntoFile);
291  rootFile_->reportOpened(inputTypeName);
292  } else {
294  if (!skipBadFiles) {
295  throw Exception(errors::FileOpenError) << "RootFileSequenceBase::initTheFile(): Input file " << fileName()
296  << " was not found or could not be opened.\n";
297  }
298  LogWarning("") << "Input file: " << fileName() << " was not found or could not be opened, and will be skipped.\n";
299  }
300  }
std::string const & logicalFileName() const
std::string const & fileName() const
virtual std::string explainSelf() const
Definition: Exception.cc:108
std::vector< FileCatalogItem >::const_iterator fileIter_
std::vector< FileCatalogItem >::const_iterator const fileIterEnd_
std::vector< FileCatalogItem >::const_iterator const fileIterBegin_
std::list< std::string > const & additionalInfo() const
Definition: Exception.cc:149
static void reportFallbackAttempt(std::string const &pfn, std::string const &logicalFileName, std::string const &errorMessage)
Definition: InputFile.cc:80
std::vector< FileCatalogItem >::const_iterator fileIterLastOpened_
static void reportSkippedFile(std::string const &fileName, std::string const &logicalFileName)
Definition: InputFile.cc:75
virtual RootFileSharedPtr makeRootFile(std::shared_ptr< InputFile > filePtr)=0
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
edm::propagate_const< RootFileSharedPtr > rootFile_
virtual void closeFile_()=0
std::string const & fallbackFileName() const
std::string const& edm::RootInputFileSequence::lfn ( ) const
inlineprotected

Definition at line 78 of file RootInputFileSequence.h.

References fileCatalogItems(), and lfn_.

Referenced by edm::RootPrimaryFileSequence::closeFile_().

78 { return lfn_; }
size_t edm::RootInputFileSequence::lfnHash ( ) const
inlineprotected
std::string const& edm::RootInputFileSequence::logicalFileName ( ) const
inlineprotected

Definition at line 76 of file RootInputFileSequence.h.

References fileIter_.

Referenced by initTheFile(), edm::RootSecondaryFileSequence::makeRootFile(), edm::RootPrimaryFileSequence::makeRootFile(), and edm::RootEmbeddedFileSequence::makeRootFile().

76 { return fileIter_->logicalFileName(); }
std::vector< FileCatalogItem >::const_iterator fileIter_
virtual RootFileSharedPtr edm::RootInputFileSequence::makeRootFile ( std::shared_ptr< InputFile filePtr)
privatepure virtual
bool edm::RootInputFileSequence::noFiles ( ) const
inlineprotected

Definition at line 65 of file RootInputFileSequence.h.

References fileIterBegin_, and fileIterEnd_.

Referenced by edm::RootEmbeddedFileSequence::RootEmbeddedFileSequence().

65 { return fileIterBegin_ == fileIterEnd_; }
std::vector< FileCatalogItem >::const_iterator const fileIterEnd_
std::vector< FileCatalogItem >::const_iterator const fileIterBegin_
bool edm::RootInputFileSequence::noMoreFiles ( ) const
inlineprotected
size_t edm::RootInputFileSequence::numberOfFiles ( ) const
inlineprotected

Definition at line 67 of file RootInputFileSequence.h.

References fileIterBegin_, and fileIterEnd_.

Referenced by edm::RootEmbeddedFileSequence::RootEmbeddedFileSequence().

67 { return fileIterEnd_ - fileIterBegin_; }
std::vector< FileCatalogItem >::const_iterator const fileIterEnd_
std::vector< FileCatalogItem >::const_iterator const fileIterBegin_
RootInputFileSequence& edm::RootInputFileSequence::operator= ( RootInputFileSequence const &  )
delete
void edm::RootInputFileSequence::readEvent ( EventPrincipal cache)

Definition at line 84 of file RootInputFileSequence.cc.

References rootFile().

84  {
85  assert(rootFile());
86  rootFile()->readEvent(eventPrincipal);
87  }
std::shared_ptr< RootFile const > rootFile() const
void edm::RootInputFileSequence::readLuminosityBlock_ ( LuminosityBlockPrincipal lumiPrincipal)

Definition at line 66 of file RootInputFileSequence.cc.

References rootFile().

66  {
67  assert(rootFile());
68  rootFile()->readLuminosityBlock_(lumiPrincipal);
69  }
std::shared_ptr< RootFile const > rootFile() const
std::shared_ptr< LuminosityBlockAuxiliary > edm::RootInputFileSequence::readLuminosityBlockAuxiliary_ ( )

Definition at line 56 of file RootInputFileSequence.cc.

References rootFile().

56  {
57  assert(rootFile());
58  return rootFile()->readLuminosityBlockAuxiliary_();
59  }
std::shared_ptr< RootFile const > rootFile() const
void edm::RootInputFileSequence::readRun_ ( RunPrincipal runPrincipal)

Definition at line 61 of file RootInputFileSequence.cc.

References rootFile().

61  {
62  assert(rootFile());
63  rootFile()->readRun_(runPrincipal);
64  }
std::shared_ptr< RootFile const > rootFile() const
std::shared_ptr< RunAuxiliary > edm::RootInputFileSequence::readRunAuxiliary_ ( )

Definition at line 51 of file RootInputFileSequence.cc.

References rootFile().

51  {
52  assert(rootFile());
53  return rootFile()->readRunAuxiliary_();
54  }
std::shared_ptr< RootFile const > rootFile() const
std::shared_ptr<RootFile const> edm::RootInputFileSequence::rootFile ( ) const
inlineprotected

Definition at line 86 of file RootInputFileSequence.h.

References edm::get_underlying_safe(), and rootFile_.

Referenced by edm::RootSecondaryFileSequence::closeFile_(), edm::RootEmbeddedFileSequence::closeFile_(), edm::RootPrimaryFileSequence::closeFile_(), containedInCurrentFile(), fileBranchIDListHelper(), fileProductRegistry(), edm::RootPrimaryFileSequence::forwardState(), edm::RootPrimaryFileSequence::getNextItemType(), edm::RootPrimaryFileSequence::goToEvent(), edm::RootSecondaryFileSequence::initAssociationsFromSecondary(), edm::RootPrimaryFileSequence::nextFile(), edm::RootPrimaryFileSequence::previousFile(), readEvent(), edm::RootPrimaryFileSequence::readFile_(), readLuminosityBlock_(), readLuminosityBlockAuxiliary_(), edm::RootEmbeddedFileSequence::readOneRandom(), edm::RootEmbeddedFileSequence::readOneRandomWithID(), edm::RootEmbeddedFileSequence::readOneSequential(), edm::RootEmbeddedFileSequence::readOneSequentialWithID(), edm::RootEmbeddedFileSequence::readOneSpecified(), readRun_(), readRunAuxiliary_(), edm::RootPrimaryFileSequence::reverseState(), edm::RootPrimaryFileSequence::rewind_(), edm::RootPrimaryFileSequence::rewindFile(), edm::RootEmbeddedFileSequence::RootEmbeddedFileSequence(), edm::RootPrimaryFileSequence::RootPrimaryFileSequence(), edm::RootSecondaryFileSequence::RootSecondaryFileSequence(), setIndexIntoFile(), edm::RootEmbeddedFileSequence::skipEntries(), edm::RootPrimaryFileSequence::skipEvents(), skipToItem(), and skipToItemInNewFile().

86 { return get_underlying_safe(rootFile_); }
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< RootFileSharedPtr > rootFile_
std::shared_ptr<RootFile>& edm::RootInputFileSequence::rootFile ( )
inlineprotected

Definition at line 87 of file RootInputFileSequence.h.

References edm::get_underlying_safe(), and rootFile_.

87 { return get_underlying_safe(rootFile_); }
std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< RootFileSharedPtr > rootFile_
size_t edm::RootInputFileSequence::sequenceNumberOfFile ( ) const
inlineprotected
void edm::RootInputFileSequence::setAtFileSequenceNumber ( size_t  offset)
inlineprotected
void edm::RootInputFileSequence::setAtFirstFile ( )
inlineprotected
void edm::RootInputFileSequence::setAtNextFile ( )
inlineprotected
void edm::RootInputFileSequence::setAtPreviousFile ( )
inlineprotected

Definition at line 73 of file RootInputFileSequence.h.

References fileIter_.

Referenced by edm::RootPrimaryFileSequence::previousFile().

73 { --fileIter_; }
std::vector< FileCatalogItem >::const_iterator fileIter_
void edm::RootInputFileSequence::setIndexIntoFile ( size_t  index)
protected

Definition at line 302 of file RootInputFileSequence.cc.

References indexesIntoFiles_, and rootFile().

Referenced by indexesIntoFiles(), and initTheFile().

302  {
303  indexesIntoFiles_[index] = rootFile()->indexIntoFileSharedPtr();
304  }
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
std::shared_ptr< RootFile const > rootFile() const
void edm::RootInputFileSequence::setNoMoreFiles ( )
inlineprotected

Definition at line 71 of file RootInputFileSequence.h.

References fileIter_, and fileIterEnd_.

Referenced by edm::RootPrimaryFileSequence::skipEvents().

std::vector< FileCatalogItem >::const_iterator const fileIterEnd_
std::vector< FileCatalogItem >::const_iterator fileIter_
bool edm::RootInputFileSequence::skipToItem ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event,
size_t  fileNameHash = 0U,
bool  currentFileFirst = true 
)

Definition at line 150 of file RootInputFileSequence.cc.

References fileIter_, runEdmFileComparison::found, indexesIntoFiles_, initFile(), rootFile(), setAtFileSequenceNumber(), skipToItemInNewFile(), and mitigatedMETSequence_cff::U.

Referenced by edm::RootEmbeddedFileSequence::readOneRandomWithID(), edm::RootEmbeddedFileSequence::readOneSequentialWithID(), and edm::RootEmbeddedFileSequence::readOneSpecified().

151  {
152  // Attempt to find item in currently open input file.
153  bool found = currentFileFirst && rootFile() && rootFile()->setEntryAtItem(run, lumi, event);
154  if (!found) {
155  // If only one input file, give up now, to save time.
156  if (currentFileFirst && rootFile() && indexesIntoFiles_.size() == 1) {
157  return false;
158  }
159  // Look for item (run/lumi/event) in files previously opened without reopening unnecessary files.
160  for (auto it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) {
161  if (*it && (*it)->containsItem(run, lumi, event)) {
162  // We found it. Close the currently open file, and open the correct one.
163  std::vector<FileCatalogItem>::const_iterator currentIter = fileIter_;
165  if (fileIter_ != currentIter) {
166  initFile(false);
167  }
168  // Now get the item from the correct file.
169  assert(rootFile());
170  found = rootFile()->setEntryAtItem(run, lumi, event);
171  assert(found);
172  return true;
173  }
174  }
175  return (fileNameHash != 0U && skipToItemInNewFile(run, lumi, event, fileNameHash)) ||
177  }
178  return true;
179  }
void initFile(bool skipBadFiles)
void setAtFileSequenceNumber(size_t offset)
std::vector< FileCatalogItem >::const_iterator fileIter_
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
std::shared_ptr< RootFile const > rootFile() const
bool skipToItemInNewFile(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
Definition: event.py:1
bool edm::RootInputFileSequence::skipToItemInNewFile ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
)
protected

Definition at line 132 of file RootInputFileSequence.cc.

References runEdmFileComparison::found, indexesIntoFiles_, initFile_(), rootFile(), and setAtFileSequenceNumber().

Referenced by initFile(), edm::RootEmbeddedFileSequence::readOneSequentialWithID(), and skipToItem().

132  {
133  // Look for item in files not yet opened. We do not have a valid hash of the logical file name.
134  for (auto it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) {
135  if (!*it) {
136  // File not yet opened.
138  initFile_(false);
139  assert(rootFile());
140  bool found = rootFile()->setEntryAtItem(run, lumi, event);
141  if (found) {
142  return true;
143  }
144  }
145  }
146  // Not found
147  return false;
148  }
void setAtFileSequenceNumber(size_t offset)
virtual void initFile_(bool skipBadFiles)=0
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
std::shared_ptr< RootFile const > rootFile() const
Definition: event.py:1
bool edm::RootInputFileSequence::skipToItemInNewFile ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event,
size_t  fileNameHash 
)
protected

Definition at line 97 of file RootInputFileSequence.cc.

References fileIterBegin_, fileIterEnd_, findFileForSpecifiedID_, runEdmFileComparison::found, indexesIntoFiles_, initFile_(), rootFile(), setAtFileSequenceNumber(), and mitigatedMETSequence_cff::U.

100  {
101  // Look for item in files not yet opened. We have a hash of the logical file name
102  assert(fileNameHash != 0U);
103  // If the lookup table is not yet filled in, fill it.
105  // We use a multimap because there may be hash collisions (Two different LFNs could have the same hash).
106  // We map the hash of the LFN to the index into the list of files.
108  std::make_unique<std::unordered_multimap<size_t, size_t>>(); // propagate_const<T> has no reset() function
109  auto hasher = std::hash<std::string>();
110  for (auto fileIter = fileIterBegin_; fileIter != fileIterEnd_; ++fileIter) {
111  findFileForSpecifiedID_->insert(std::make_pair(hasher(fileIter->logicalFileName()), fileIter - fileIterBegin_));
112  }
113  }
114  // Look up the logical file name in the table
115  auto range = findFileForSpecifiedID_->equal_range(fileNameHash);
116  for (auto iter = range.first; iter != range.second; ++iter) {
117  // Don't look in files previously opened, because those have already been searched.
118  if (!indexesIntoFiles_[iter->second]) {
119  setAtFileSequenceNumber(iter->second);
120  initFile_(false);
121  assert(rootFile());
122  bool found = rootFile()->setEntryAtItem(run, lumi, event);
123  if (found) {
124  return true;
125  }
126  }
127  }
128  // Not found
129  return false;
130  }
void setAtFileSequenceNumber(size_t offset)
std::vector< FileCatalogItem >::const_iterator const fileIterEnd_
std::vector< FileCatalogItem >::const_iterator const fileIterBegin_
virtual void initFile_(bool skipBadFiles)=0
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
std::shared_ptr< RootFile const > rootFile() const
edm::propagate_const< std::unique_ptr< std::unordered_multimap< size_t, size_t > > > findFileForSpecifiedID_
Definition: event.py:1
bool edm::RootInputFileSequence::usedFallback ( ) const
inlineprotected

Definition at line 84 of file RootInputFileSequence.h.

References usedFallback_.

Referenced by edm::RootPrimaryFileSequence::closeFile_().

Member Data Documentation

InputFileCatalog const& edm::RootInputFileSequence::catalog_
private

Definition at line 90 of file RootInputFileSequence.h.

Referenced by fileCatalogItems().

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

Definition at line 98 of file RootInputFileSequence.h.

Referenced by initTheFile().

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

Definition at line 94 of file RootInputFileSequence.h.

Referenced by skipToItemInNewFile().

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

Definition at line 91 of file RootInputFileSequence.h.

Referenced by initTheFile(), and lfn().

size_t edm::RootInputFileSequence::lfnHash_
private

Definition at line 92 of file RootInputFileSequence.h.

Referenced by initTheFile(), and lfnHash().

edm::propagate_const<RootFileSharedPtr> edm::RootInputFileSequence::rootFile_
private

Definition at line 99 of file RootInputFileSequence.h.

Referenced by initTheFile(), and rootFile().

bool edm::RootInputFileSequence::usedFallback_
private

Definition at line 93 of file RootInputFileSequence.h.

Referenced by initTheFile(), and usedFallback().