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

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

Protected Types

typedef std::shared_ptr< RootFileRootFileSharedPtr
 

Protected Member Functions

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
 

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 32 of file RootInputFileSequence.h.

Member Typedef Documentation

◆ RootFileSharedPtr

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

Definition at line 60 of file RootInputFileSequence.h.

Constructor & Destructor Documentation

◆ RootInputFileSequence() [1/2]

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

Definition at line 24 of file RootInputFileSequence.cc.

25  : catalog_(catalog),
26  lfn_("unknown"),
27  lfnHash_(0U),
28  usedFallback_(false),
29  findFileForSpecifiedID_(nullptr),
34  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< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
std::vector< FileCatalogItem > const & fileCatalogItems() const
edm::propagate_const< RootFileSharedPtr > rootFile_
edm::propagate_const< std::unique_ptr< std::unordered_multimap< size_t, size_t > > > findFileForSpecifiedID_
InputFileCatalog const & catalog_

◆ ~RootInputFileSequence()

edm::RootInputFileSequence::~RootInputFileSequence ( )
virtual

Definition at line 51 of file RootInputFileSequence.cc.

51 {}

◆ RootInputFileSequence() [2/2]

edm::RootInputFileSequence::RootInputFileSequence ( RootInputFileSequence const &  )
delete

Member Function Documentation

◆ atFirstFile()

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

◆ atLastFile()

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

Definition at line 72 of file RootInputFileSequence.h.

References fileIter_, and fileIterEnd_.

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

72 { return fileIter_ + 1 == fileIterEnd_; }
std::vector< FileCatalogItem >::const_iterator const fileIterEnd_
std::vector< FileCatalogItem >::const_iterator fileIter_

◆ closeFile()

void edm::RootInputFileSequence::closeFile ( )

◆ closeFile_()

virtual void edm::RootInputFileSequence::closeFile_ ( )
privatepure virtual

◆ containedInCurrentFile()

bool edm::RootInputFileSequence::containedInCurrentFile ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
) const

Definition at line 106 of file RootInputFileSequence.cc.

References rootFile(), and writedatasetfile::run.

108  {
109  if (!rootFile())
110  return false;
111  return rootFile()->containsItem(run, lumi, event);
112  }
std::shared_ptr< RootFile const > rootFile() const
Definition: event.py:1

◆ fileBranchIDListHelper()

std::shared_ptr< BranchIDListHelper const > edm::RootInputFileSequence::fileBranchIDListHelper ( ) const

Definition at line 46 of file RootInputFileSequence.cc.

References cms::cuda::assert(), and rootFile().

46  {
47  assert(rootFile());
48  return rootFile()->branchIDListHelper();
49  }
assert(be >=bs)
std::shared_ptr< RootFile const > rootFile() const

◆ fileCatalogItems()

std::vector< FileCatalogItem > const & edm::RootInputFileSequence::fileCatalogItems ( ) const
protected

Definition at line 37 of file RootInputFileSequence.cc.

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

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

37  {
38  return catalog_.fileCatalogItems();
39  }
std::vector< FileCatalogItem > const & fileCatalogItems() const
InputFileCatalog const & catalog_

◆ fileNames()

std::vector<std::string> const& edm::RootInputFileSequence::fileNames ( ) const
inlineprotected

◆ fileProductRegistry()

std::shared_ptr< ProductRegistry const > edm::RootInputFileSequence::fileProductRegistry ( ) const

Definition at line 41 of file RootInputFileSequence.cc.

References cms::cuda::assert(), and rootFile().

41  {
42  assert(rootFile());
43  return rootFile()->productRegistry();
44  }
assert(be >=bs)
std::shared_ptr< RootFile const > rootFile() const

◆ fillProcessBlockHelper_()

void edm::RootInputFileSequence::fillProcessBlockHelper_ ( )

Definition at line 68 of file RootInputFileSequence.cc.

References cms::cuda::assert(), and rootFile().

68  {
69  assert(rootFile());
70  return rootFile()->fillProcessBlockHelper_();
71  }
assert(be >=bs)
std::shared_ptr< RootFile const > rootFile() const

◆ indexesIntoFiles()

std::vector<std::shared_ptr<IndexIntoFile> > const& edm::RootInputFileSequence::indexesIntoFiles ( ) const
inlineprotected

◆ initFile()

void edm::RootInputFileSequence::initFile ( bool  skipBadFiles)
inlineprotected

◆ initFile_()

virtual void edm::RootInputFileSequence::initFile_ ( bool  skipBadFiles)
privatepure virtual

◆ initTheFile()

void edm::RootInputFileSequence::initTheFile ( bool  skipBadFiles,
bool  deleteIndexIntoFile,
InputSource input,
char const *  inputTypeName,
InputType  inputType 
)
protected

Definition at line 199 of file RootInputFileSequence.cc.

References cms::Exception::addAdditionalInfo(), cms::Exception::addContext(), cms::cuda::assert(), closeFile(), MillePedeFileConverter_cfg::e, relativeConstraints::empty, Exception, fileIter_, fileIterBegin_, fileIterEnd_, fileIterLastOpened_, fileNames(), edm::errors::FileOpenError, MainPageGenerator::fName, indexesIntoFiles_, input, lfn(), lfn_, lfnHash_, logicalFileName(), makeRootFile(), Skims_PA_cff::name, GetRecoTauVFromDQM_MC_cff::next, noMoreFiles(), MillePedeFileConverter_cfg::out, edm::InputFile::reportSkippedFile(), rootFile_, alignCSCRings::s, setIndexIntoFile(), remoteMonitoring_LASER_era2018_cfg::skipBadFiles, AlCaHLTBitMon_QueryRunRegistry::string, and usedFallback_.

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

200  {
201  // We are really going to close the open file.
202 
204  size_t currentIndexIntoFile = fileIterLastOpened_ - fileIterBegin_;
205  if (deleteIndexIntoFile) {
206  indexesIntoFiles_[currentIndexIntoFile].reset();
207  } else {
208  if (indexesIntoFiles_[currentIndexIntoFile])
209  indexesIntoFiles_[currentIndexIntoFile]->inputFileClosed();
210  }
212  }
213  closeFile();
214 
215  if (noMoreFiles()) {
216  // No files specified
217  return;
218  }
219 
220  // Check if the logical file name was found.
221  if (fileNames()[0].empty()) {
222  // LFN not found in catalog.
224  if (!skipBadFiles) {
225  throw cms::Exception("LogicalFileNameNotFound", "RootFileSequenceBase::initTheFile()\n")
226  << "Logical file name '" << logicalFileName() << "' was not found in the file catalog.\n"
227  << "If you wanted a local file, you forgot the 'file:' prefix\n"
228  << "before the file name in your configuration file.\n";
229  }
230  LogWarning("") << "Input logical file: " << logicalFileName()
231  << " was not found in the catalog, and will be skipped.\n";
232  return;
233  }
234 
235  lfn_ = logicalFileName().empty() ? fileNames()[0] : logicalFileName();
236  lfnHash_ = std::hash<std::string>()(lfn_);
237  usedFallback_ = false;
238 
239  std::shared_ptr<InputFile> filePtr;
240  std::list<std::string> originalInfo;
241 
242  std::vector<std::string> const& fNames = fileNames();
243 
244  //this tries to open the file using multiple PFNs corresponding to different data catalogs
245  std::list<std::string> exInfo;
246  {
247  std::unique_ptr<InputSource::FileOpenSentry> sentry(
248  input ? std::make_unique<InputSource::FileOpenSentry>(*input, lfn_) : nullptr);
250  if (service.isAvailable()) {
251  service->openingFile(lfn(), inputType, -1);
252  }
253  for (std::vector<std::string>::const_iterator it = fNames.begin(); it != fNames.end(); ++it) {
254  try {
255  std::unique_ptr<char[]> name(gSystem->ExpandPathName(it->c_str()));
256  filePtr = std::make_shared<InputFile>(name.get(), " Initiating request to open file ", inputType);
257  usedFallback_ = (it != fNames.begin());
258  break;
259  } catch (cms::Exception const& e) {
260  if (!skipBadFiles && std::next(it) == fNames.end()) {
263  ex.addContext("Calling RootInputFileSequence::initTheFile()");
264  std::ostringstream out;
265  out << "Input file " << (*it) << " could not be opened.";
266  ex.addAdditionalInfo(out.str());
267  //report previous exceptions when use other names to open file
268  for (auto const& s : exInfo)
269  ex.addAdditionalInfo(s);
270  throw ex;
271  } else {
272  exInfo.push_back("Calling RootInputFileSequence::initTheFile(): fail to open the file with name " + (*it));
273  }
274  }
275  }
276  }
277  if (filePtr) {
278  size_t currentIndexIntoFile = fileIter_ - fileIterBegin_;
279  rootFile_ = makeRootFile(filePtr);
280  assert(rootFile_);
281  if (input) {
282  rootFile_->setSignals(&(input->preEventReadFromSourceSignal_), &(input->postEventReadFromSourceSignal_));
283  }
285  setIndexIntoFile(currentIndexIntoFile);
286  rootFile_->reportOpened(inputTypeName);
287  } else {
288  std::string fName = !fNames.empty() ? fNames[0] : "";
289  InputFile::reportSkippedFile(fName, logicalFileName()); //0 cause exception?
290  if (!skipBadFiles) {
291  throw Exception(errors::FileOpenError) << "RootFileSequenceBase::initTheFile(): Input file " << fName
292  << " was not found or could not be opened.\n";
293  }
294  LogWarning("RootInputFileSequence")
295  << "Input file: " << fName << " was not found or could not be opened, and will be skipped.\n";
296  }
297  }
std::vector< FileCatalogItem >::const_iterator fileIter_
std::vector< FileCatalogItem >::const_iterator const fileIterEnd_
std::vector< FileCatalogItem >::const_iterator const fileIterBegin_
std::string const & logicalFileName() const
assert(be >=bs)
std::vector< std::string > const & fileNames() const
static std::string const input
Definition: EdmProvDump.cc:50
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_
std::string const & lfn() const
Log< level::Warning, false > LogWarning

◆ lfn()

std::string const& edm::RootInputFileSequence::lfn ( ) const
inlineprotected

Definition at line 87 of file RootInputFileSequence.h.

References lfn_.

Referenced by closeFile(), edm::RootPrimaryFileSequence::closeFile_(), and initTheFile().

87 { return lfn_; }

◆ lfnHash()

size_t edm::RootInputFileSequence::lfnHash ( ) const
inlineprotected

◆ logicalFileName()

std::string const& edm::RootInputFileSequence::logicalFileName ( ) const
inlineprotected

Definition at line 86 of file RootInputFileSequence.h.

References fileIter_.

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

86 { return fileIter_->logicalFileName(); }
std::vector< FileCatalogItem >::const_iterator fileIter_

◆ makeRootFile()

virtual RootFileSharedPtr edm::RootInputFileSequence::makeRootFile ( std::shared_ptr< InputFile filePtr)
privatepure virtual

◆ nextProcessBlock_()

bool edm::RootInputFileSequence::nextProcessBlock_ ( ProcessBlockPrincipal processBlockPrincipal)

Definition at line 73 of file RootInputFileSequence.cc.

References cms::cuda::assert(), and rootFile().

73  {
74  assert(rootFile());
75  return rootFile()->nextProcessBlock_(processBlockPrincipal);
76  }
assert(be >=bs)
std::shared_ptr< RootFile const > rootFile() const

◆ noFiles()

bool edm::RootInputFileSequence::noFiles ( ) const
inlineprotected

Definition at line 74 of file RootInputFileSequence.h.

References fileIterBegin_, and fileIterEnd_.

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

74 { return fileIterBegin_ == fileIterEnd_; }
std::vector< FileCatalogItem >::const_iterator const fileIterEnd_
std::vector< FileCatalogItem >::const_iterator const fileIterBegin_

◆ noMoreFiles()

bool edm::RootInputFileSequence::noMoreFiles ( ) const
inlineprotected

◆ numberOfFiles()

size_t edm::RootInputFileSequence::numberOfFiles ( ) const
inlineprotected

Definition at line 76 of file RootInputFileSequence.h.

References fileIterBegin_, and fileIterEnd_.

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

76 { return fileIterEnd_ - fileIterBegin_; }
std::vector< FileCatalogItem >::const_iterator const fileIterEnd_
std::vector< FileCatalogItem >::const_iterator const fileIterBegin_

◆ operator=()

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

◆ readEvent()

bool edm::RootInputFileSequence::readEvent ( EventPrincipal cache)

Definition at line 101 of file RootInputFileSequence.cc.

References cms::cuda::assert(), and rootFile().

101  {
102  assert(rootFile());
103  return rootFile()->readEvent(eventPrincipal);
104  }
assert(be >=bs)
std::shared_ptr< RootFile const > rootFile() const

◆ readLuminosityBlock_()

bool edm::RootInputFileSequence::readLuminosityBlock_ ( LuminosityBlockPrincipal lumiPrincipal)

Definition at line 83 of file RootInputFileSequence.cc.

References cms::cuda::assert(), and rootFile().

83  {
84  assert(rootFile());
85  return rootFile()->readLuminosityBlock_(lumiPrincipal);
86  }
assert(be >=bs)
std::shared_ptr< RootFile const > rootFile() const

◆ readLuminosityBlockAuxiliary_()

std::shared_ptr< LuminosityBlockAuxiliary > edm::RootInputFileSequence::readLuminosityBlockAuxiliary_ ( )

Definition at line 58 of file RootInputFileSequence.cc.

References cms::cuda::assert(), and rootFile().

58  {
59  assert(rootFile());
60  return rootFile()->readLuminosityBlockAuxiliary_();
61  }
assert(be >=bs)
std::shared_ptr< RootFile const > rootFile() const

◆ readProcessBlock_()

void edm::RootInputFileSequence::readProcessBlock_ ( ProcessBlockPrincipal processBlockPrincipal)

Definition at line 78 of file RootInputFileSequence.cc.

References cms::cuda::assert(), and rootFile().

78  {
79  assert(rootFile());
80  rootFile()->readProcessBlock_(processBlockPrincipal);
81  }
assert(be >=bs)
std::shared_ptr< RootFile const > rootFile() const

◆ readRun_()

bool edm::RootInputFileSequence::readRun_ ( RunPrincipal runPrincipal)

Definition at line 63 of file RootInputFileSequence.cc.

References cms::cuda::assert(), and rootFile().

63  {
64  assert(rootFile());
65  return rootFile()->readRun_(runPrincipal);
66  }
assert(be >=bs)
std::shared_ptr< RootFile const > rootFile() const

◆ readRunAuxiliary_()

std::shared_ptr< RunAuxiliary > edm::RootInputFileSequence::readRunAuxiliary_ ( )

Definition at line 53 of file RootInputFileSequence.cc.

References cms::cuda::assert(), and rootFile().

53  {
54  assert(rootFile());
55  return rootFile()->readRunAuxiliary_();
56  }
assert(be >=bs)
std::shared_ptr< RootFile const > rootFile() const

◆ rootFile() [1/2]

std::shared_ptr<RootFile const> edm::RootInputFileSequence::rootFile ( ) const
inlineprotected

Definition at line 95 of file RootInputFileSequence.h.

References edm::get_underlying_safe(), and rootFile_.

Referenced by closeFile(), edm::RootSecondaryFileSequence::closeFile_(), edm::RootEmbeddedFileSequence::closeFile_(), edm::RootPrimaryFileSequence::closeFile_(), containedInCurrentFile(), fileBranchIDListHelper(), fileProductRegistry(), fillProcessBlockHelper_(), edm::RootPrimaryFileSequence::forwardState(), edm::RootPrimaryFileSequence::getNextItemType(), edm::RootPrimaryFileSequence::goToEvent(), edm::RootSecondaryFileSequence::initAssociationsFromSecondary(), edm::RootPrimaryFileSequence::nextFile(), nextProcessBlock_(), edm::RootPrimaryFileSequence::previousFile(), readEvent(), edm::RootPrimaryFileSequence::readFile_(), readLuminosityBlock_(), readLuminosityBlockAuxiliary_(), edm::RootEmbeddedFileSequence::readOneRandom(), edm::RootEmbeddedFileSequence::readOneRandomWithID(), edm::RootEmbeddedFileSequence::readOneSequential(), edm::RootEmbeddedFileSequence::readOneSequentialWithID(), edm::RootEmbeddedFileSequence::readOneSpecified(), readProcessBlock_(), 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(), edm::RootPrimaryFileSequence::skipEventsAtBeginning(), skipToItem(), and skipToItemInNewFile().

95 { return get_underlying_safe(rootFile_); }
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< RootFileSharedPtr > rootFile_

◆ rootFile() [2/2]

std::shared_ptr<RootFile>& edm::RootInputFileSequence::rootFile ( )
inlineprotected

Definition at line 96 of file RootInputFileSequence.h.

References edm::get_underlying_safe(), and rootFile_.

96 { return get_underlying_safe(rootFile_); }
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
edm::propagate_const< RootFileSharedPtr > rootFile_

◆ sequenceNumberOfFile()

size_t edm::RootInputFileSequence::sequenceNumberOfFile ( ) const
inlineprotected

◆ setAtFileSequenceNumber()

void edm::RootInputFileSequence::setAtFileSequenceNumber ( size_t  offset)
inlineprotected

◆ setAtFirstFile()

void edm::RootInputFileSequence::setAtFirstFile ( )
inlineprotected

◆ setAtNextFile()

void edm::RootInputFileSequence::setAtNextFile ( )
inlineprotected

◆ setAtPreviousFile()

void edm::RootInputFileSequence::setAtPreviousFile ( )
inlineprotected

Definition at line 82 of file RootInputFileSequence.h.

References fileIter_.

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

82 { --fileIter_; }
std::vector< FileCatalogItem >::const_iterator fileIter_

◆ setIndexIntoFile()

void edm::RootInputFileSequence::setIndexIntoFile ( size_t  index)
protected

Definition at line 307 of file RootInputFileSequence.cc.

References indexesIntoFiles_, and rootFile().

Referenced by initTheFile().

307  {
308  indexesIntoFiles_[index] = rootFile()->indexIntoFileSharedPtr();
309  }
std::shared_ptr< RootFile const > rootFile() const
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_

◆ setNoMoreFiles()

void edm::RootInputFileSequence::setNoMoreFiles ( )
inlineprotected

Definition at line 80 of file RootInputFileSequence.h.

References fileIter_, and fileIterEnd_.

std::vector< FileCatalogItem >::const_iterator const fileIterEnd_
std::vector< FileCatalogItem >::const_iterator fileIter_

◆ skipToItem()

bool edm::RootInputFileSequence::skipToItem ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event,
size_t  fileNameHash = 0U,
bool  currentFileFirst = true 
)

Definition at line 167 of file RootInputFileSequence.cc.

References cms::cuda::assert(), fileIter_, newFWLiteAna::found, indexesIntoFiles_, initFile(), rootFile(), writedatasetfile::run, setAtFileSequenceNumber(), skipToItemInNewFile(), and mitigatedMETSequence_cff::U.

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

168  {
169  // Attempt to find item in currently open input file.
170  bool found = currentFileFirst && rootFile() && rootFile()->setEntryAtItem(run, lumi, event);
171  if (!found) {
172  // If only one input file, give up now, to save time.
173  if (currentFileFirst && rootFile() && indexesIntoFiles_.size() == 1) {
174  return false;
175  }
176  // Look for item (run/lumi/event) in files previously opened without reopening unnecessary files.
177  for (auto it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) {
178  if (*it && (*it)->containsItem(run, lumi, event)) {
179  // We found it. Close the currently open file, and open the correct one.
180  std::vector<FileCatalogItem>::const_iterator currentIter = fileIter_;
182  if (fileIter_ != currentIter) {
183  initFile(false);
184  }
185  // Now get the item from the correct file.
186  assert(rootFile());
187  found = rootFile()->setEntryAtItem(run, lumi, event);
188  assert(found);
189  return true;
190  }
191  }
192  return (fileNameHash != 0U && skipToItemInNewFile(run, lumi, event, fileNameHash)) ||
194  }
195  return true;
196  }
void initFile(bool skipBadFiles)
void setAtFileSequenceNumber(size_t offset)
std::vector< FileCatalogItem >::const_iterator fileIter_
assert(be >=bs)
std::shared_ptr< RootFile const > rootFile() const
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
bool skipToItemInNewFile(RunNumber_t run, LuminosityBlockNumber_t lumi, EventNumber_t event)
Definition: event.py:1

◆ skipToItemInNewFile() [1/2]

bool edm::RootInputFileSequence::skipToItemInNewFile ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event 
)
protected

Definition at line 149 of file RootInputFileSequence.cc.

References cms::cuda::assert(), newFWLiteAna::found, indexesIntoFiles_, initFile_(), rootFile(), writedatasetfile::run, and setAtFileSequenceNumber().

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

149  {
150  // Look for item in files not yet opened. We do not have a valid hash of the logical file name.
151  for (auto it = indexesIntoFiles_.begin(), itEnd = indexesIntoFiles_.end(); it != itEnd; ++it) {
152  if (!*it) {
153  // File not yet opened.
155  initFile_(false);
156  assert(rootFile());
157  bool found = rootFile()->setEntryAtItem(run, lumi, event);
158  if (found) {
159  return true;
160  }
161  }
162  }
163  // Not found
164  return false;
165  }
void setAtFileSequenceNumber(size_t offset)
assert(be >=bs)
virtual void initFile_(bool skipBadFiles)=0
std::shared_ptr< RootFile const > rootFile() const
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
Definition: event.py:1

◆ skipToItemInNewFile() [2/2]

bool edm::RootInputFileSequence::skipToItemInNewFile ( RunNumber_t  run,
LuminosityBlockNumber_t  lumi,
EventNumber_t  event,
size_t  fileNameHash 
)
protected

Definition at line 114 of file RootInputFileSequence.cc.

References cms::cuda::assert(), fileIterBegin_, fileIterEnd_, findFileForSpecifiedID_, newFWLiteAna::found, visDQMUpload::hasher, indexesIntoFiles_, initFile_(), FastTimerService_cff::range, rootFile(), writedatasetfile::run, setAtFileSequenceNumber(), and mitigatedMETSequence_cff::U.

117  {
118  // Look for item in files not yet opened. We have a hash of the logical file name
119  assert(fileNameHash != 0U);
120  // If the lookup table is not yet filled in, fill it.
122  // We use a multimap because there may be hash collisions (Two different LFNs could have the same hash).
123  // We map the hash of the LFN to the index into the list of files.
125  std::make_unique<std::unordered_multimap<size_t, size_t>>(); // propagate_const<T> has no reset() function
126  auto hasher = std::hash<std::string>();
127  for (auto fileIter = fileIterBegin_; fileIter != fileIterEnd_; ++fileIter) {
128  findFileForSpecifiedID_->insert(std::make_pair(hasher(fileIter->logicalFileName()), fileIter - fileIterBegin_));
129  }
130  }
131  // Look up the logical file name in the table
132  auto range = findFileForSpecifiedID_->equal_range(fileNameHash);
133  for (auto iter = range.first; iter != range.second; ++iter) {
134  // Don't look in files previously opened, because those have already been searched.
135  if (!indexesIntoFiles_[iter->second]) {
136  setAtFileSequenceNumber(iter->second);
137  initFile_(false);
138  assert(rootFile());
139  bool found = rootFile()->setEntryAtItem(run, lumi, event);
140  if (found) {
141  return true;
142  }
143  }
144  }
145  // Not found
146  return false;
147  }
void setAtFileSequenceNumber(size_t offset)
std::vector< FileCatalogItem >::const_iterator const fileIterEnd_
std::vector< FileCatalogItem >::const_iterator const fileIterBegin_
assert(be >=bs)
virtual void initFile_(bool skipBadFiles)=0
std::shared_ptr< RootFile const > rootFile() const
std::vector< std::shared_ptr< IndexIntoFile > > indexesIntoFiles_
edm::propagate_const< std::unique_ptr< std::unordered_multimap< size_t, size_t > > > findFileForSpecifiedID_
Definition: event.py:1

◆ usedFallback()

bool edm::RootInputFileSequence::usedFallback ( ) const
inlineprotected

Definition at line 93 of file RootInputFileSequence.h.

References usedFallback_.

Referenced by closeFile().

Member Data Documentation

◆ catalog_

InputFileCatalog const& edm::RootInputFileSequence::catalog_
private

Definition at line 99 of file RootInputFileSequence.h.

Referenced by fileCatalogItems().

◆ fileIter_

std::vector<FileCatalogItem>::const_iterator edm::RootInputFileSequence::fileIter_
private

◆ fileIterBegin_

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

◆ fileIterEnd_

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

◆ fileIterLastOpened_

std::vector<FileCatalogItem>::const_iterator edm::RootInputFileSequence::fileIterLastOpened_
private

Definition at line 107 of file RootInputFileSequence.h.

Referenced by initTheFile().

◆ findFileForSpecifiedID_

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

Definition at line 103 of file RootInputFileSequence.h.

Referenced by skipToItemInNewFile().

◆ indexesIntoFiles_

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

◆ lfn_

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

Definition at line 100 of file RootInputFileSequence.h.

Referenced by initTheFile(), and lfn().

◆ lfnHash_

size_t edm::RootInputFileSequence::lfnHash_
private

Definition at line 101 of file RootInputFileSequence.h.

Referenced by initTheFile(), and lfnHash().

◆ rootFile_

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

Definition at line 108 of file RootInputFileSequence.h.

Referenced by initTheFile(), and rootFile().

◆ usedFallback_

bool edm::RootInputFileSequence::usedFallback_
private

Definition at line 102 of file RootInputFileSequence.h.

Referenced by initTheFile(), and usedFallback().