LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
art::RootInputFileSequence Class Reference

#include "RootInputFileSequence.h"

Classes

struct  Config
 

Public Types

using RootInputFileSharedPtr = std::shared_ptr< RootInputFile >
 
using EntryNumber = input::EntryNumber
 

Public Member Functions

 RootInputFileSequence (RootInputFileSequence const &)=delete
 
RootInputFileSequenceoperator= (RootInputFileSequence const &)=delete
 
 RootInputFileSequence (fhicl::TableFragment< Config > const &, InputFileCatalog &, FastCloningInfoProvider const &, InputSource::ProcessingMode, MasterProductRegistry &, ProcessConfiguration const &)
 
void endJob ()
 
std::unique_ptr< FileBlockreadFile_ ()
 
std::unique_ptr< RootInputFileopenSecondaryFile (std::string const &name, cet::exempt_ptr< RootInputFile > primaryFile)
 
void closeFile_ ()
 
void skip (int offset)
 
void rewind_ ()
 
EventID seekToEvent (EventID const &, bool exact=false)
 
EventID seekToEvent (off_t offset, bool exact=false)
 
input::ItemType getNextItemType ()
 
std::unique_ptr< RunPrincipalreadIt (RunID const &)
 
std::unique_ptr< RunPrincipalreadRun_ ()
 
std::unique_ptr< SubRunPrincipalreadIt (SubRunID const &, cet::exempt_ptr< RunPrincipal >)
 
std::unique_ptr< SubRunPrincipalreadSubRun_ (cet::exempt_ptr< RunPrincipal >)
 
std::unique_ptr< EventPrincipalreadIt (EventID const &, bool exact=false)
 
std::unique_ptr< EventPrincipalreadEvent_ ()
 
RootInputFileSharedPtr rootFileForLastReadEvent () const
 
RootInputFileSharedPtr rootFile () const
 
std::unique_ptr< RangeSetHandlerrunRangeSetHandler ()
 
std::unique_ptr< RangeSetHandlersubRunRangeSetHandler ()
 
std::vector< std::vector< std::string > > const & secondaryFileNames () const
 
EventID origEventID () const
 
EventNumber_t eventsToSkip () const
 
FastCloningInfoProvider const & fastCloningInfo () const
 
unsigned int treeCacheSize () const
 
int64_t treeMaxVirtualSize () const
 
int64_t saveMemoryObjectThreshold () const
 
bool delayedReadEventProducts () const
 
bool delayedReadSubRunProducts () const
 
bool delayedReadRunProducts () const
 
InputSource::ProcessingMode const & processingMode ()
 
void finish ()
 

Private Member Functions

void initFile (bool skipBadFiles)
 
bool nextFile ()
 
bool previousFile ()
 
void rewindFile ()
 
std::vector< FileCatalogItem > const & fileCatalogItems () const
 
ProcessConfiguration const & processConfiguration () const
 
bool primary () const
 

Private Attributes

InputFileCatalogcatalog_
 
bool firstFile_ {true}
 
RootInputFileSharedPtr rootFile_ {nullptr}
 
std::vector< std::shared_ptr< FileIndex > > fileIndexes_
 
EventID origEventID_ {}
 
EventNumber_t eventsToSkip_
 
bool const compactSubRunRanges_
 
bool const noEventSort_
 
bool const skipBadFiles_
 
unsigned int const treeCacheSize_
 
int64_t const treeMaxVirtualSize_
 
int64_t const saveMemoryObjectThreshold_
 
bool const delayedReadEventProducts_
 
bool const delayedReadSubRunProducts_
 
bool const delayedReadRunProducts_
 
int forcedRunOffset_ {}
 
RunNumber_t setRun_ {}
 
GroupSelectorRules groupSelectorRules_
 
std::shared_ptr< DuplicateCheckerduplicateChecker_ {nullptr}
 
bool const dropDescendants_
 
bool const readParameterSets_
 
RootInputFileSharedPtr rootFileForLastReadEvent_
 
FastCloningInfoProvider fastCloningInfo_
 
InputSource::ProcessingMode processingMode_
 
ProcessConfiguration const & processConfiguration_
 
std::vector< std::vector< std::string > > secondaryFileNames_ {}
 
MasterProductRegistrympr_
 
bool pendingClose_ {false}
 

Detailed Description

Definition at line 36 of file RootInputFileSequence.h.

Member Typedef Documentation

Constructor & Destructor Documentation

art::RootInputFileSequence::RootInputFileSequence ( RootInputFileSequence const &  )
delete
art::RootInputFileSequence::RootInputFileSequence ( fhicl::TableFragment< Config > const &  config,
InputFileCatalog catalog,
FastCloningInfoProvider const &  fcip,
InputSource::ProcessingMode  pMode,
MasterProductRegistry mpr,
ProcessConfiguration const &  processConfig 
)

Definition at line 30 of file RootInputFileSequence.cc.

References catalog_, compactSubRunRanges_, art::errors::Configuration, delayedReadEventProducts_, delayedReadRunProducts_, delayedReadSubRunProducts_, dropDescendants_, duplicateChecker_, e, eventsToSkip_, fastCloningInfo_, fileCatalogItems(), fileIndexes_, art::InputFileCatalog::fileSources(), art::EventID::firstEvent(), art::RunID::firstRun(), art::SubRunID::firstSubRun(), forcedRunOffset_, art::InputFileCatalog::getNextFile(), groupSelectorRules_, initFile(), art::errors::InvalidNumber, art::errors::LogicError, art::RunID::maxRun(), mpr_, noEventSort_, origEventID_, pendingClose_, primary(), processConfiguration_, processingMode_, readParameterSets_, rootFile_, art::SubRunID::run(), art::RunID::run(), saveMemoryObjectThreshold_, secondaryFileNames(), secondaryFileNames_, setRun_, skipBadFiles_, treeCacheSize_, and treeMaxVirtualSize_.

37  : catalog_{catalog}
38  , fileIndexes_(fileCatalogItems().size())
39  , eventsToSkip_{config().skipEvents()}
40  , compactSubRunRanges_{config().compactSubRunRanges()}
41  , noEventSort_{config().noEventSort()}
42  , skipBadFiles_{config().skipBadFiles()}
43  , treeCacheSize_{config().cacheSize()}
44  , treeMaxVirtualSize_{config().treeMaxVirtualSize()}
45  , saveMemoryObjectThreshold_{config().saveMemoryObjectThreshold()}
46  , delayedReadEventProducts_{config().delayedReadEventProducts()}
47  , delayedReadSubRunProducts_{config().delayedReadSubRunProducts()}
48  , delayedReadRunProducts_{config().delayedReadRunProducts()}
49  , groupSelectorRules_{config().inputCommands(),
50  "inputCommands",
51  "InputSource"}
52  , dropDescendants_{config().dropDescendantsOfDroppedBranches()}
53  , readParameterSets_{config().readParameterSets()}
54  , fastCloningInfo_{fcip}
55  , processingMode_{pMode}
56  , processConfiguration_{processConfig}
57  , mpr_{mpr}
58  {
59  auto const& primaryFileNames = catalog_.fileSources();
60 
61  map<string const, vector<string> const> secondaryFilesMap;
62 
63  std::vector<Config::SecondaryFile> secondaryFiles;
64  if (config().secondaryFileNames(secondaryFiles)) {
65  for (auto const& val : secondaryFiles) {
66  auto const a = val.a();
67  auto const b = val.b();
68  if (a.empty()) {
70  << "Empty filename found as value of an \"a\" parameter!\n";
71  }
72  for (auto const& name : b) {
73  if (name.empty()) {
75  << "Empty secondary filename found as value of an \"b\" "
76  "parameter!\n";
77  }
78  }
79  secondaryFilesMap.emplace(a, b);
80  }
81  }
82 
84  stk;
85  for (auto const& primaryFileName : primaryFileNames) {
86  vector<string> secondaries;
87  auto SFMI = secondaryFilesMap.find(primaryFileName);
88  if (SFMI == secondaryFilesMap.end()) {
89  // This primary has no secondaries.
90  secondaryFileNames_.push_back(std::move(secondaries));
91  continue;
92  }
93  if (!SFMI->second.size()) {
94  // Has an empty secondary list.
95  secondaryFileNames_.push_back(std::move(secondaries));
96  continue;
97  }
98  stk.emplace_back(SFMI->second.cbegin(), SFMI->second.cend());
99  while (stk.size()) {
100  auto val = stk.back();
101  stk.pop_back();
102  if (val.first == val.second) {
103  // Reached end of this filename list.
104  continue;
105  }
106  auto const& fn = *val.first;
107  ++val.first;
108  secondaries.push_back(fn);
109  auto SI = secondaryFilesMap.find(fn);
110  if (SI == secondaryFilesMap.end()) {
111  // Has no secondary list.
112  if (val.first == val.second) {
113  // Reached end of this filename list.
114  continue;
115  }
116  stk.emplace_back(val.first, val.second);
117  continue;
118  }
119  if (!SI->second.size()) {
120  // Has an empty secondary list.
121  if (val.first == val.second) {
122  // Reached end of this filename list.
123  continue;
124  }
125  stk.emplace_back(val.first, val.second);
126  continue;
127  }
128  stk.emplace_back(val.first, val.second);
129  stk.emplace_back(SI->second.cbegin(), SI->second.cend());
130  }
131  secondaryFileNames_.push_back(std::move(secondaries));
132  }
133  RunNumber_t firstRun{};
134  bool const haveFirstRun{config().hasFirstRun(firstRun)};
135  SubRunNumber_t firstSubRun{};
136  bool const haveFirstSubRun{config().hasFirstSubRun(firstSubRun)};
137  EventNumber_t firstEvent{};
138  bool const haveFirstEvent{config().hasFirstEvent(firstEvent)};
139 
140  RunID const firstRunID{haveFirstRun ? RunID{firstRun} : RunID::firstRun()};
141  SubRunID const firstSubRunID{haveFirstSubRun ?
142  SubRunID{firstRunID.run(), firstSubRun} :
143  SubRunID::firstSubRun(firstRunID)};
144 
145  origEventID_ = haveFirstEvent ? EventID{firstSubRunID, firstEvent} :
146  EventID::firstEvent(firstSubRunID);
147 
148  if (noEventSort_ && haveFirstEvent) {
150  << "Illegal configuration options passed to RootInput\n"
151  << "You cannot request \"noEventSort\" and also set \"firstEvent\".\n";
152  }
153  if (primary()) {
154  duplicateChecker_ = std::make_shared<DuplicateChecker>(config().dc);
155  }
156  if (pendingClose_) {
158  << "RootInputFileSequence looking for next file with a pending close!";
159  }
160  while (catalog_.getNextFile()) {
162  if (rootFile_) {
163  // We found one, good, stop now.
164  break;
165  }
166  }
167  if (!rootFile_) {
168  // We could not open any input files, stop.
169  return;
170  }
171  if (config().setRunNumber(setRun_)) {
172  try {
173  forcedRunOffset_ = rootFile_->setForcedRunOffset(setRun_);
174  }
175  catch (art::Exception& e) {
176  if (e.categoryCode() == errors::InvalidNumber) {
178  << "setRunNumber " << setRun_
179  << " does not correspond to a valid run number in ["
180  << RunID::firstRun().run() << ", " << RunID::maxRun().run()
181  << "]\n";
182  } else {
183  throw; // Rethrow.
184  }
185  }
186  if (forcedRunOffset_ < 0) {
188  << "The value of the 'setRunNumber' parameter must not be\n"
189  << "less than the first run number in the first input file.\n"
190  << "'setRunNumber' was " << setRun_ << ", while the first run was "
191  << setRun_ - forcedRunOffset_ << ".\n";
192  }
193  }
194  if (!readParameterSets_) {
195  mf::LogWarning("PROVENANCE")
196  << "Source parameter readParameterSets was set to false: parameter set "
197  "provenance\n"
198  << "will NOT be available in this or subsequent jobs using output from "
199  "this job.\n"
200  << "Check your experiment's policy on this issue to avoid future "
201  "problems\n"
202  << "with analysis reproducibility.\n";
203  }
204  if (compactSubRunRanges_) {
205  mf::LogWarning("PROVENANCE")
206  << "Source parameter compactEventRanges was set to true: enabling "
207  "compact event ranges\n"
208  << "creates a history that can cause file concatenation problems if a "
209  "given SubRun spans\n"
210  << "multiple input files. Use with care.\n";
211  }
212  }
std::vector< std::shared_ptr< FileIndex > > fileIndexes_
ProcessConfiguration const & processConfiguration_
std::vector< FileCatalogItem > const & fileCatalogItems() const
bool getNextFile(int attempts=5)
std::shared_ptr< DuplicateChecker > duplicateChecker_
RunNumber_t run() const
Definition: RunID.h:63
std::vector< std::vector< std::string > > const & secondaryFileNames() const
intermediate_table::const_iterator const_iterator
GroupSelectorRules groupSelectorRules_
static RunID maxRun()
Definition: RunID.h:109
FastCloningInfoProvider fastCloningInfo_
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:118
RootInputFileSharedPtr rootFile_
static SubRunID firstSubRun()
Definition: SubRunID.h:152
std::vector< std::vector< std::string > > secondaryFileNames_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
InputSource::ProcessingMode processingMode_
MasterProductRegistry & mpr_
void initFile(bool skipBadFiles)
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:117
static RunID firstRun()
Definition: RunID.h:115
std::vector< std::string > const & fileSources() const
Float_t e
Definition: plot.C:34
static EventID firstEvent()
Definition: EventID.h:191
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:119

Member Function Documentation

void art::RootInputFileSequence::closeFile_ ( )

Definition at line 291 of file RootInputFileSequence.cc.

References catalog_, duplicateChecker_, eventsToSkip_, art::InputFileCatalog::finish(), art::detail::logFileAction(), pendingClose_, primary(), and rootFile_.

Referenced by endJob(), and initFile().

292  {
293  if (pendingClose_) {
294  catalog_.finish(); // We were expecting this
295  pendingClose_ = false;
296  }
297  if (!rootFile_)
298  return;
299 
300  // Account for events skipped in the file.
301  eventsToSkip_ = rootFile_->eventsToSkip();
302  rootFile_->close(primary());
303  detail::logFileAction("Closed input file ", rootFile_->fileName());
304  rootFile_.reset();
305  if (duplicateChecker_.get() != nullptr) {
306  duplicateChecker_->inputFileClosed();
307  }
308  }
void logFileAction(const char *msg, std::string const &file)
Definition: logFileAction.cc:9
std::shared_ptr< DuplicateChecker > duplicateChecker_
RootInputFileSharedPtr rootFile_
bool art::RootInputFileSequence::delayedReadEventProducts ( ) const
inline

Definition at line 207 of file RootInputFileSequence.h.

References delayedReadEventProducts_.

208  {
210  }
bool art::RootInputFileSequence::delayedReadRunProducts ( ) const
inline

Definition at line 219 of file RootInputFileSequence.h.

References delayedReadRunProducts_.

220  {
222  }
bool art::RootInputFileSequence::delayedReadSubRunProducts ( ) const
inline

Definition at line 213 of file RootInputFileSequence.h.

References delayedReadSubRunProducts_.

214  {
216  }
void art::RootInputFileSequence::endJob ( )

Definition at line 266 of file RootInputFileSequence.cc.

References closeFile_().

267  {
268  closeFile_();
269  }
EventNumber_t art::RootInputFileSequence::eventsToSkip ( ) const
inline

Definition at line 177 of file RootInputFileSequence.h.

References eventsToSkip_.

178  {
179  return eventsToSkip_;
180  }
FastCloningInfoProvider const& art::RootInputFileSequence::fastCloningInfo ( ) const
inline

Definition at line 183 of file RootInputFileSequence.h.

References fastCloningInfo_.

184  {
185  return fastCloningInfo_;
186  }
FastCloningInfoProvider fastCloningInfo_
vector< FileCatalogItem > const & art::RootInputFileSequence::fileCatalogItems ( ) const
private

Definition at line 260 of file RootInputFileSequence.cc.

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

Referenced by processingMode(), and RootInputFileSequence().

261  {
262  return catalog_.fileCatalogItems();
263  }
std::vector< FileCatalogItem > const & fileCatalogItems() const
void art::RootInputFileSequence::finish ( )

Definition at line 311 of file RootInputFileSequence.cc.

References pendingClose_.

Referenced by processingMode().

312  {
313  pendingClose_ = true;
314  }
input::ItemType art::RootInputFileSequence::getNextItemType ( )

Definition at line 642 of file RootInputFileSequence.cc.

References catalog_, firstFile_, art::InputFileCatalog::hasNextFile(), art::input::IsEvent, art::input::IsFile, art::input::IsRun, art::input::IsStop, art::input::IsSubRun, art::FileIndex::kEnd, art::FileIndex::kEvent, art::FileIndex::kRun, art::FileIndex::kSubRun, and rootFile_.

643  {
644  // marked as the first file but failed to find a valid
645  // root file. we should make it stop.
646  if (firstFile_ && !rootFile_) {
647  return input::IsStop;
648  }
649  if (firstFile_) {
650  return input::IsFile;
651  }
652  if (rootFile_) {
653  FileIndex::EntryType entryType = rootFile_->getNextEntryTypeWanted();
654  if (entryType == FileIndex::kEvent) {
655  return input::IsEvent;
656  } else if (entryType == FileIndex::kSubRun) {
657  return input::IsSubRun;
658  } else if (entryType == FileIndex::kRun) {
659  return input::IsRun;
660  }
661  assert(entryType == FileIndex::kEnd);
662  }
663  // now we are either at the end of a root file
664  // or the current file is not a root file
665  if (!catalog_.hasNextFile()) {
666  return input::IsStop;
667  }
668  return input::IsFile;
669  }
bool hasNextFile(int attempts=5)
RootInputFileSharedPtr rootFile_
void art::RootInputFileSequence::initFile ( bool  skipBadFiles)
private

Definition at line 317 of file RootInputFileSequence.cc.

References catalog_, closeFile_(), compactSubRunRanges_, art::InputFileCatalog::currentFile(), art::InputFileCatalog::currentIndex(), delayedReadEventProducts_, delayedReadRunProducts_, delayedReadSubRunProducts_, dropDescendants_, duplicateChecker_, e, eventsToSkip_, fastCloningInfo_, fileIndexes_, art::FileCatalogItem::fileName(), art::errors::FileOpenError, forcedRunOffset_, groupSelectorRules_, art::InputFileCatalog::indexEnd, art::detail::logFileAction(), art::FileCatalogItem::logicalFileName(), mpr_, noEventSort_, art::Open, origEventID_, processConfiguration(), processingMode_, readParameterSets_, rootFile_, saveMemoryObjectThreshold_, secondaryFileNames_, treeCacheSize_, treeMaxVirtualSize_, and art::FileCatalog::url().

Referenced by nextFile(), previousFile(), processingMode(), readFile_(), readIt(), RootInputFileSequence(), and seekToEvent().

318  {
319  // close the currently open file, any, and delete the RootInputFile object.
320  closeFile_();
321  std::unique_ptr<TFile> filePtr;
322  try {
323  detail::logFileAction("Initiating request to open input file ",
325  filePtr.reset(TFile::Open(catalog_.currentFile().fileName().c_str()));
326  }
327  catch (cet::exception e) {
328  if (!skipBadFiles) {
330  << e.explain_self()
331  << "\nRootInputFileSequence::initFile(): Input file "
333  << " was not found or could not be opened.\n";
334  }
335  }
336  if (!filePtr || filePtr->IsZombie()) {
337  if (!skipBadFiles) {
339  << "RootInputFileSequence::initFile(): Input file "
341  << " was not found or could not be opened.\n";
342  }
343  mf::LogWarning("")
344  << "Input file: " << catalog_.currentFile().fileName()
345  << " was not found or could not be opened, and will be skipped.\n";
346  return;
347  }
348  detail::logFileAction("Opened input file ",
350  vector<string> empty_vs;
351  rootFile_ = make_shared<RootInputFile>(
353  catalog_.url(),
356  std::move(filePtr),
357  origEventID_,
369  noEventSort_,
374  /*primaryFile*/ exempt_ptr<RootInputFile>{nullptr},
375  secondaryFileNames_.empty() ?
376  empty_vs :
378  this,
379  mpr_);
380 
382  if (catalog_.currentIndex() + 1 > fileIndexes_.size()) {
383  fileIndexes_.resize(catalog_.currentIndex() + 1);
384  }
385  fileIndexes_[catalog_.currentIndex()] = rootFile_->fileIndexSharedPtr();
386  }
size_t currentIndex() const
std::vector< std::shared_ptr< FileIndex > > fileIndexes_
static constexpr size_t indexEnd
void logFileAction(const char *msg, std::string const &file)
Definition: logFileAction.cc:9
std::string & url()
Definition: FileCatalog.h:98
std::string const & logicalFileName() const
Definition: FileCatalog.h:30
ProcessConfiguration const & processConfiguration() const
std::shared_ptr< DuplicateChecker > duplicateChecker_
FileCatalogItem const & currentFile() const
GroupSelectorRules groupSelectorRules_
FastCloningInfoProvider fastCloningInfo_
RootInputFileSharedPtr rootFile_
std::vector< std::vector< std::string > > secondaryFileNames_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
InputSource::ProcessingMode processingMode_
MasterProductRegistry & mpr_
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
Float_t e
Definition: plot.C:34
std::string const & fileName() const
Definition: FileCatalog.h:25
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool art::RootInputFileSequence::nextFile ( )
private

Definition at line 440 of file RootInputFileSequence.cc.

References catalog_, art::InputFileCatalog::getNextFile(), initFile(), and skipBadFiles_.

Referenced by processingMode(), readFile_(), and skip().

441  {
442  if (!catalog_.getNextFile()) {
443  // no more files
444  return false;
445  }
447  return true;
448  }
bool getNextFile(int attempts=5)
void initFile(bool skipBadFiles)
std::unique_ptr< RootInputFile > art::RootInputFileSequence::openSecondaryFile ( std::string const &  name,
cet::exempt_ptr< RootInputFile primaryFile 
)

Definition at line 389 of file RootInputFileSequence.cc.

References compactSubRunRanges_, delayedReadEventProducts_, delayedReadRunProducts_, delayedReadSubRunProducts_, dropDescendants_, e, eventsToSkip_, fastCloningInfo_, art::errors::FileOpenError, forcedRunOffset_, groupSelectorRules_, art::detail::logFileAction(), mpr_, noEventSort_, art::Open, origEventID_, processConfiguration(), processingMode_, readParameterSets_, saveMemoryObjectThreshold_, treeCacheSize_, and treeMaxVirtualSize_.

392  {
393  std::unique_ptr<TFile> filePtr;
394  try {
395  detail::logFileAction("Attempting to open secondary input file ", name);
396  filePtr.reset(TFile::Open(name.c_str()));
397  }
398  catch (cet::exception e) {
400  << e.explain_self()
401  << "\nRootInputFileSequence::openSecondaryFile(): Input file " << name
402  << " was not found or could not be opened.\n";
403  }
404  if (!filePtr || filePtr->IsZombie()) {
406  << "RootInputFileSequence::openSecondaryFile(): Input file " << name
407  << " was not found or could not be opened.\n";
408  }
409  detail::logFileAction("Opened secondary input file ", name);
410  vector<string> empty_secondary_filenames;
411  return std::make_unique<RootInputFile>(name,
412  /*url*/ "",
414  /*logicalFileName*/ "",
415  std::move(filePtr),
416  origEventID_,
428  noEventSort_,
430  /*duplicateChecker_*/ nullptr,
433  primaryFile,
434  empty_secondary_filenames,
435  this,
436  mpr_);
437  }
void logFileAction(const char *msg, std::string const &file)
Definition: logFileAction.cc:9
ProcessConfiguration const & processConfiguration() const
GroupSelectorRules groupSelectorRules_
FastCloningInfoProvider fastCloningInfo_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
InputSource::ProcessingMode processingMode_
MasterProductRegistry & mpr_
Float_t e
Definition: plot.C:34
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
RootInputFileSequence& art::RootInputFileSequence::operator= ( RootInputFileSequence const &  )
delete
EventID art::RootInputFileSequence::origEventID ( ) const
inline

Definition at line 171 of file RootInputFileSequence.h.

References origEventID_.

172  {
173  return origEventID_;
174  }
bool art::RootInputFileSequence::previousFile ( )
private

Definition at line 451 of file RootInputFileSequence.cc.

References catalog_, art::InputFileCatalog::currentIndex(), art::InputFileCatalog::indexEnd, initFile(), art::InputFileCatalog::isSearchable(), art::InputFileCatalog::rewindTo(), and rootFile_.

Referenced by processingMode(), and skip().

452  {
453  // no going back for non-persistent files
454  if (!catalog_.isSearchable()) {
455  return false;
456  }
457  // no file in the catalog
459  return false;
460  }
461  // first file in the catalog, move to the last file in the list
462  if (catalog_.currentIndex() == 0) {
463  return false;
464  } else {
466  }
467  initFile(/*skipBadFiles=*/false);
468  if (rootFile_) {
469  rootFile_->setToLastEntry();
470  }
471  return true;
472  }
size_t currentIndex() const
static constexpr size_t indexEnd
RootInputFileSharedPtr rootFile_
void rewindTo(size_t index)
void initFile(bool skipBadFiles)
bool art::RootInputFileSequence::primary ( ) const
private

Definition at line 711 of file RootInputFileSequence.cc.

Referenced by closeFile_(), processingMode(), and RootInputFileSequence().

712  {
713  return true;
714  }
ProcessConfiguration const & art::RootInputFileSequence::processConfiguration ( ) const
private

Definition at line 717 of file RootInputFileSequence.cc.

References processConfiguration_.

Referenced by initFile(), openSecondaryFile(), and processingMode().

718  {
719  return processConfiguration_;
720  }
ProcessConfiguration const & processConfiguration_
InputSource::ProcessingMode const& art::RootInputFileSequence::processingMode ( )
inline
unique_ptr< EventPrincipal > art::RootInputFileSequence::readEvent_ ( )

Definition at line 519 of file RootInputFileSequence.cc.

References rootFile_, and rootFileForLastReadEvent_.

Referenced by readIt().

520  {
521  // Create and setup the EventPrincipal.
522  //
523  // 1. create an EventPrincipal with a unique EventID
524  // 2. For each entry in the provenance, put in one Group,
525  // holding the Provenance for the corresponding EDProduct.
526  // 3. set up the caches in the EventPrincipal to know about this
527  // Group.
528  //
529  // We do *not* create the EDProduct instance (the equivalent of reading
530  // the branch containing this EDProduct. That will be done by the
531  // Delayed Reader when it is asked to do so.
532  //
534  return rootFile_->readEvent();
535  }
RootInputFileSharedPtr rootFile_
RootInputFileSharedPtr rootFileForLastReadEvent_
std::unique_ptr< FileBlock > art::RootInputFileSequence::readFile_ ( )

Definition at line 272 of file RootInputFileSequence.cc.

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

273  {
274  if (firstFile_) {
275  // We are at the first file in the sequence of files.
276  firstFile_ = false;
277  if (!rootFile_) {
279  }
280  } else if (!nextFile()) {
281  // FIXME: Turn this into a throw!
282  assert(false);
283  }
284  if (!rootFile_) {
285  return std::make_unique<RootFileBlock>();
286  }
287  return rootFile_->createFileBlock();
288  }
RootInputFileSharedPtr rootFile_
void initFile(bool skipBadFiles)
std::unique_ptr< RunPrincipal > art::RootInputFileSequence::readIt ( RunID const &  id)

Definition at line 597 of file RootInputFileSequence.cc.

References B, catalog_, E, fileIndexes_, art::InputFileCatalog::getNextFile(), initFile(), art::InRun, art::InputFileCatalog::isSearchable(), readRun_(), art::InputFileCatalog::rewindTo(), and rootFile_.

598  {
599  // Attempt to find run in current file.
600  bool found = rootFile_->setEntry<InRun>(id);
601  if (found) {
602  // Got it, read the run.
603  return readRun_();
604  }
605  if (!catalog_.isSearchable()) {
606  // Cannot random access files, give up.
607  return std::unique_ptr<RunPrincipal>{nullptr};
608  }
609  // Look for the run in the opened files.
610  for (auto B = fileIndexes_.cbegin(), E = fileIndexes_.cend(), I = B; I != E;
611  ++I) {
612  if (*I && (*I)->contains(id, true)) {
613  // We found it, open the file.
614  catalog_.rewindTo(std::distance(B, I));
615  initFile(/*skipBadFiles=*/false);
616  // Now read the run.
617  found = rootFile_->setEntry<InRun>(id);
618  assert(found);
619  return readRun_();
620  }
621  }
622  // Look for run in files not yet opened.
623  while (catalog_.getNextFile()) {
624  initFile(/*skipBadFiles=*/false);
625  found = rootFile_->setEntry<InRun>(id);
626  if (found) {
627  // Got it, read the run.
628  return readRun_();
629  }
630  }
631  // Not found.
632  return std::unique_ptr<RunPrincipal>{nullptr};
633  }
std::vector< std::shared_ptr< FileIndex > > fileIndexes_
Float_t E
Definition: plot.C:23
Int_t B
Definition: plot.C:25
bool getNextFile(int attempts=5)
std::unique_ptr< RunPrincipal > readRun_()
RootInputFileSharedPtr rootFile_
void rewindTo(size_t index)
void initFile(bool skipBadFiles)
std::unique_ptr< SubRunPrincipal > art::RootInputFileSequence::readIt ( SubRunID const &  id,
cet::exempt_ptr< RunPrincipal rp 
)

Definition at line 550 of file RootInputFileSequence.cc.

References catalog_, fileIndexes_, art::InputFileCatalog::getNextFile(), initFile(), art::InSubRun, art::InputFileCatalog::isSearchable(), readSubRun_(), art::InputFileCatalog::rewindTo(), and rootFile_.

552  {
553  // Attempt to find subRun in currently open input file.
554  bool found = rootFile_->setEntry<InSubRun>(id);
555  if (found) {
556  return readSubRun_(rp);
557  }
558  if (!catalog_.isSearchable()) {
559  return std::unique_ptr<SubRunPrincipal>{nullptr};
560  }
561  // Look for event in cached files
562  typedef vector<std::shared_ptr<FileIndex>>::const_iterator Iter;
563  for (Iter itBegin = fileIndexes_.begin(),
564  itEnd = fileIndexes_.end(),
565  it = itBegin;
566  it != itEnd;
567  ++it) {
568  if (*it && (*it)->contains(id, true)) {
569  // We found it. Close the currently open file, and open the correct one.
570  catalog_.rewindTo(std::distance(itBegin, it));
571  initFile(/*skipBadFiles=*/false);
572  // Now get the subRun from the correct file.
573  found = rootFile_->setEntry<InSubRun>(id);
574  assert(found);
575  return readSubRun_(rp);
576  }
577  }
578  // Look for subRun in files not yet opened.
579  while (catalog_.getNextFile()) {
580  initFile(/*skipBadFiles=*/false);
581  found = rootFile_->setEntry<InSubRun>(id);
582  if (found) {
583  return readSubRun_(rp);
584  }
585  }
586  // not found
587  return std::unique_ptr<SubRunPrincipal>{nullptr};
588  }
std::vector< std::shared_ptr< FileIndex > > fileIndexes_
bool getNextFile(int attempts=5)
RootInputFileSharedPtr rootFile_
void rewindTo(size_t index)
void initFile(bool skipBadFiles)
std::unique_ptr< SubRunPrincipal > readSubRun_(cet::exempt_ptr< RunPrincipal >)
unique_ptr< EventPrincipal > art::RootInputFileSequence::readIt ( EventID const &  id,
bool  exact = false 
)

Definition at line 475 of file RootInputFileSequence.cc.

References catalog_, fileIndexes_, art::InputFileCatalog::getNextFile(), art::InEvent, initFile(), art::InputFileCatalog::isSearchable(), readEvent_(), art::InputFileCatalog::rewindTo(), rootFile_, and rootFileForLastReadEvent_.

476  {
477  // Attempt to find event in currently open input file.
478  bool found = rootFile_->setEntry<InEvent>(id, exact);
479  if (found) {
481  unique_ptr<EventPrincipal> eptr(readEvent_());
482  return eptr;
483  }
484  if (!catalog_.isSearchable()) {
485  // return unique_ptr<EventPrincipal>();
486  return 0;
487  }
488  // Look for event in cached files
489  for (auto IB = fileIndexes_.cbegin(), IE = fileIndexes_.cend(), I = IB;
490  I != IE;
491  ++I) {
492  if (*I && (*I)->contains(id, exact)) {
493  // We found it. Close the currently open file, and open the correct one.
494  catalog_.rewindTo(std::distance(IB, I));
495  initFile(/*skipBadFiles=*/false);
496  // Now get the event from the correct file.
497  found = rootFile_->setEntry<InEvent>(id, exact);
498  assert(found);
500  unique_ptr<EventPrincipal> ep(readEvent_());
501  return ep;
502  }
503  }
504  // Look for event in files not yet opened.
505  while (catalog_.getNextFile()) {
506  initFile(/*skipBadFiles=*/false);
507  found = rootFile_->setEntry<InEvent>(id, exact);
508  if (found) {
510  unique_ptr<EventPrincipal> ep(readEvent_());
511  return ep;
512  }
513  }
514  // Not found
515  return 0;
516  }
std::vector< std::shared_ptr< FileIndex > > fileIndexes_
bool getNextFile(int attempts=5)
RootInputFileSharedPtr rootFile_
void rewindTo(size_t index)
std::unique_ptr< EventPrincipal > readEvent_()
void initFile(bool skipBadFiles)
RootInputFileSharedPtr rootFileForLastReadEvent_
std::unique_ptr< RunPrincipal > art::RootInputFileSequence::readRun_ ( )

Definition at line 636 of file RootInputFileSequence.cc.

References rootFile_.

Referenced by readIt().

637  {
638  return rootFile_->readRun();
639  }
RootInputFileSharedPtr rootFile_
std::unique_ptr< SubRunPrincipal > art::RootInputFileSequence::readSubRun_ ( cet::exempt_ptr< RunPrincipal rp)

Definition at line 591 of file RootInputFileSequence.cc.

References rootFile_.

Referenced by readIt().

592  {
593  return rootFile_->readSubRun(rp);
594  }
RootInputFileSharedPtr rootFile_
void art::RootInputFileSequence::rewind_ ( )

Definition at line 673 of file RootInputFileSequence.cc.

References catalog_, duplicateChecker_, art::errors::FileOpenError, firstFile_, art::InputFileCatalog::isSearchable(), and art::InputFileCatalog::rewind().

674  {
675  if (!catalog_.isSearchable()) {
677  << "RootInputFileSequence::rewind_() "
678  << "cannot rollback on non-searchable file catalogs.";
679  }
680  firstFile_ = true;
681  catalog_.rewind();
682  if (duplicateChecker_.get() != nullptr) {
683  duplicateChecker_->rewind();
684  }
685  }
std::shared_ptr< DuplicateChecker > duplicateChecker_
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void art::RootInputFileSequence::rewindFile ( )
private

Definition at line 689 of file RootInputFileSequence.cc.

References rootFile_.

Referenced by processingMode().

690  {
691  rootFile_->rewind();
692  }
RootInputFileSharedPtr rootFile_
RootInputFileSharedPtr art::RootInputFileSequence::rootFile ( ) const
inline

Definition at line 156 of file RootInputFileSequence.h.

References rootFile_, runRangeSetHandler(), and subRunRangeSetHandler().

157  {
158  return rootFile_;
159  }
RootInputFileSharedPtr rootFile_
RootInputFileSharedPtr art::RootInputFileSequence::rootFileForLastReadEvent ( ) const
inline

Definition at line 150 of file RootInputFileSequence.h.

References rootFileForLastReadEvent_.

151  {
153  }
RootInputFileSharedPtr rootFileForLastReadEvent_
std::unique_ptr< RangeSetHandler > art::RootInputFileSequence::runRangeSetHandler ( )

Definition at line 538 of file RootInputFileSequence.cc.

References rootFile_.

Referenced by rootFile().

539  {
540  return rootFile_->runRangeSetHandler();
541  }
RootInputFileSharedPtr rootFile_
int64_t art::RootInputFileSequence::saveMemoryObjectThreshold ( ) const
inline

Definition at line 201 of file RootInputFileSequence.h.

References saveMemoryObjectThreshold_.

202  {
204  };
std::vector<std::vector<std::string> > const& art::RootInputFileSequence::secondaryFileNames ( ) const
inline

Definition at line 165 of file RootInputFileSequence.h.

References secondaryFileNames_.

Referenced by RootInputFileSequence().

166  {
167  return secondaryFileNames_;
168  }
std::vector< std::vector< std::string > > secondaryFileNames_
EventID art::RootInputFileSequence::seekToEvent ( EventID const &  eID,
bool  exact = false 
)

Definition at line 215 of file RootInputFileSequence.cc.

References catalog_, fileIndexes_, art::InputFileCatalog::getNextFile(), art::InEvent, initFile(), art::InputFileCatalog::isSearchable(), art::InputFileCatalog::rewindTo(), and rootFile_.

216  {
217  // Attempt to find event in currently open input file.
218  bool found = rootFile_->setEntry<InEvent>(eID, true);
219  // found in the current file
220  if (found) {
221  return rootFile_->eventIDForFileIndexPosition();
222  }
223  // fail if not searchable
224  if (!catalog_.isSearchable()) {
225  return EventID();
226  }
227  // Look for event in files previously opened without reopening unnecessary
228  // files.
229  for (auto itBegin = fileIndexes_.cbegin(),
230  itEnd = fileIndexes_.cend(),
231  it = itBegin;
232  (!found) && it != itEnd;
233  ++it) {
234  if (*it && (*it)->contains(eID, exact)) {
235  // We found it. Close the currently open file, and open the correct one.
236  catalog_.rewindTo(std::distance(itBegin, it));
237  initFile(/*skipBadFiles=*/false);
238  // Now get the event from the correct file.
239  found = rootFile_->setEntry<InEvent>(eID, exact);
240  assert(found);
241  return rootFile_->eventIDForFileIndexPosition();
242  }
243  }
244  // Look for event in files not yet opened.
245  while (catalog_.getNextFile()) {
246  initFile(/*skipBadFiles=*/false);
247  found = rootFile_->setEntry<InEvent>(eID, exact);
248  }
249  return (found) ? rootFile_->eventIDForFileIndexPosition() : EventID();
250  }
std::vector< std::shared_ptr< FileIndex > > fileIndexes_
bool getNextFile(int attempts=5)
RootInputFileSharedPtr rootFile_
void rewindTo(size_t index)
void initFile(bool skipBadFiles)
EventID art::RootInputFileSequence::seekToEvent ( off_t  offset,
bool  exact = false 
)

Definition at line 253 of file RootInputFileSequence.cc.

References rootFile_, and skip().

254  {
255  skip(offset);
256  return rootFile_->eventIDForFileIndexPosition();
257  }
RootInputFileSharedPtr rootFile_
void art::RootInputFileSequence::skip ( int  offset)

Definition at line 696 of file RootInputFileSequence.cc.

References nextFile(), previousFile(), and rootFile_.

Referenced by seekToEvent().

697  {
698  while (offset != 0) {
699  offset = rootFile_->skipEvents(offset);
700  if (offset > 0 && !nextFile()) {
701  return;
702  }
703  if (offset < 0 && !previousFile()) {
704  return;
705  }
706  }
707  rootFile_->skipEvents(0);
708  }
RootInputFileSharedPtr rootFile_
std::unique_ptr< RangeSetHandler > art::RootInputFileSequence::subRunRangeSetHandler ( )

Definition at line 544 of file RootInputFileSequence.cc.

References rootFile_.

Referenced by rootFile().

545  {
546  return rootFile_->subRunRangeSetHandler();
547  }
RootInputFileSharedPtr rootFile_
unsigned int art::RootInputFileSequence::treeCacheSize ( ) const
inline

Definition at line 189 of file RootInputFileSequence.h.

References treeCacheSize_.

190  {
191  return treeCacheSize_;
192  }
int64_t art::RootInputFileSequence::treeMaxVirtualSize ( ) const
inline

Definition at line 195 of file RootInputFileSequence.h.

References treeMaxVirtualSize_.

196  {
197  return treeMaxVirtualSize_;
198  }

Member Data Documentation

bool const art::RootInputFileSequence::compactSubRunRanges_
private

Definition at line 254 of file RootInputFileSequence.h.

Referenced by initFile(), openSecondaryFile(), and RootInputFileSequence().

bool const art::RootInputFileSequence::delayedReadEventProducts_
private
bool const art::RootInputFileSequence::delayedReadRunProducts_
private
bool const art::RootInputFileSequence::delayedReadSubRunProducts_
private
bool const art::RootInputFileSequence::dropDescendants_
private

Definition at line 267 of file RootInputFileSequence.h.

Referenced by initFile(), openSecondaryFile(), and RootInputFileSequence().

std::shared_ptr<DuplicateChecker> art::RootInputFileSequence::duplicateChecker_ {nullptr}
private

Definition at line 266 of file RootInputFileSequence.h.

Referenced by closeFile_(), initFile(), rewind_(), and RootInputFileSequence().

EventNumber_t art::RootInputFileSequence::eventsToSkip_
private
FastCloningInfoProvider art::RootInputFileSequence::fastCloningInfo_
private
std::vector<std::shared_ptr<FileIndex> > art::RootInputFileSequence::fileIndexes_
private

Definition at line 251 of file RootInputFileSequence.h.

Referenced by initFile(), readIt(), RootInputFileSequence(), and seekToEvent().

bool art::RootInputFileSequence::firstFile_ {true}
private

Definition at line 249 of file RootInputFileSequence.h.

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

int art::RootInputFileSequence::forcedRunOffset_ {}
private

Definition at line 263 of file RootInputFileSequence.h.

Referenced by initFile(), openSecondaryFile(), and RootInputFileSequence().

GroupSelectorRules art::RootInputFileSequence::groupSelectorRules_
private

Definition at line 265 of file RootInputFileSequence.h.

Referenced by initFile(), openSecondaryFile(), and RootInputFileSequence().

MasterProductRegistry& art::RootInputFileSequence::mpr_
private

Definition at line 274 of file RootInputFileSequence.h.

Referenced by initFile(), openSecondaryFile(), and RootInputFileSequence().

bool const art::RootInputFileSequence::noEventSort_
private

Definition at line 255 of file RootInputFileSequence.h.

Referenced by initFile(), openSecondaryFile(), and RootInputFileSequence().

EventID art::RootInputFileSequence::origEventID_ {}
private
bool art::RootInputFileSequence::pendingClose_ {false}
private

Definition at line 275 of file RootInputFileSequence.h.

Referenced by closeFile_(), finish(), and RootInputFileSequence().

ProcessConfiguration const& art::RootInputFileSequence::processConfiguration_
private

Definition at line 272 of file RootInputFileSequence.h.

Referenced by processConfiguration(), and RootInputFileSequence().

InputSource::ProcessingMode art::RootInputFileSequence::processingMode_
private
bool const art::RootInputFileSequence::readParameterSets_
private

Definition at line 268 of file RootInputFileSequence.h.

Referenced by initFile(), openSecondaryFile(), and RootInputFileSequence().

RootInputFileSharedPtr art::RootInputFileSequence::rootFileForLastReadEvent_
private

Definition at line 269 of file RootInputFileSequence.h.

Referenced by readEvent_(), readIt(), and rootFileForLastReadEvent().

int64_t const art::RootInputFileSequence::saveMemoryObjectThreshold_
private
std::vector<std::vector<std::string> > art::RootInputFileSequence::secondaryFileNames_ {}
private

Definition at line 273 of file RootInputFileSequence.h.

Referenced by initFile(), RootInputFileSequence(), and secondaryFileNames().

RunNumber_t art::RootInputFileSequence::setRun_ {}
private

Definition at line 264 of file RootInputFileSequence.h.

Referenced by RootInputFileSequence().

bool const art::RootInputFileSequence::skipBadFiles_
private

Definition at line 256 of file RootInputFileSequence.h.

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

unsigned int const art::RootInputFileSequence::treeCacheSize_
private
int64_t const art::RootInputFileSequence::treeMaxVirtualSize_
private

The documentation for this class was generated from the following files: