LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
art::Source< T > Class Template Reference

#include "Source.h"

Inheritance diagram for art::Source< T >:
art::InputSource

Public Types

using SourceDetail = T
 
enum  ProcessingMode { Runs, RunsAndSubRuns, RunsSubRunsAndEvents }
 

Public Member Functions

 Source (Source< T > const &)=delete
 
Source< T > & operator= (Source< T > const &)=delete
 
 Source (fhicl::ParameterSet const &p, InputSourceDescription &d)
 
input::ItemType nextItemType () override
 
std::unique_ptr< FileBlockreadFile () override
 
void closeFile () override
 
std::unique_ptr< RunPrincipalreadRun () override
 
std::unique_ptr< SubRunPrincipalreadSubRun (cet::exempt_ptr< RunPrincipal const > rp) override
 
std::unique_ptr< EventPrincipalreadEvent (cet::exempt_ptr< SubRunPrincipal const > srp) override
 
std::unique_ptr< art::RangeSetHandlerrunRangeSetHandler () override
 
std::unique_ptr< art::RangeSetHandlersubRunRangeSetHandler () override
 
auto const & moduleDescription () const
 
auto const & processConfiguration () const
 
virtual std::unique_ptr< EventPrincipalreadEvent (EventID const &id)
 
virtual void skipEvents (int n)
 
virtual void rewind ()
 
virtual void doBeginJob ()
 
virtual void doEndJob ()
 

Private Member Functions

void finishProductRegistration_ (InputSourceDescription &d)
 
bool readNext_ ()
 
void checkForNextFile_ ()
 
void readNextAndRequireRun_ ()
 
void readNextAndRefuseEvent_ ()
 
void throwIfInsane_ (bool result, RunPrincipal *newR, SubRunPrincipal *newSR, EventPrincipal *newE) const
 

Static Private Member Functions

static void throwDataCorruption_ (const char *msg)
 

Private Attributes

cet::exempt_ptr< ActivityRegistryact_
 
ProductRegistryHelper h_ {}
 
ProductTables presentProducts_ {ProductTables::invalid()}
 
SourceHelper sourceHelper_
 
SourceDetail detail_
 
input::ItemType state_ {input::IsInvalid}
 
detail::FileNamesHandler< Source_wantFileServices< T >::value > fh_
 
std::string currentFileName_ {}
 
std::unique_ptr< RunPrincipalnewRP_ {nullptr}
 
std::unique_ptr< SubRunPrincipalnewSRP_ {nullptr}
 
std::unique_ptr< EventPrincipalnewE_ {nullptr}
 
cet::exempt_ptr< RunPrincipalcachedRP_ {nullptr}
 
cet::exempt_ptr< SubRunPrincipalcachedSRP_ {nullptr}
 
bool pendingSubRun_ {false}
 
bool pendingEvent_ {false}
 
bool subRunIsNew_ {false}
 
SubRunNumber_t remainingSubRuns_ {1}
 
bool haveSRLimit_ {false}
 
EventNumber_t remainingEvents_ {1}
 
bool haveEventLimit_ {false}
 

Detailed Description

template<class T>
class art::Source< T >

Definition at line 113 of file Source.h.

Member Typedef Documentation

template<class T >
using art::Source< T >::SourceDetail = T

Definition at line 164 of file Source.h.

Member Enumeration Documentation

Enumerator
Runs 
RunsAndSubRuns 
RunsSubRunsAndEvents 

Definition at line 52 of file InputSource.h.

Constructor & Destructor Documentation

template<class T >
art::Source< T >::Source ( Source< T > const &  )
delete
template<class T >
art::Source< T >::Source ( fhicl::ParameterSet const &  p,
InputSourceDescription d 
)
explicit

Definition at line 246 of file Source.h.

References art::Source< T >::act_, d, art::Source< T >::detail_, art::Source< T >::fh_, art::Source< T >::finishProductRegistration_(), art::Source< T >::h_, art::Source< T >::haveEventLimit_, art::Source< T >::haveSRLimit_, art::errors::LogicError, art::InputSourceDescription::moduleDescription, art::Source< T >::remainingEvents_, art::Source< T >::remainingSubRuns_, and art::Source< T >::sourceHelper_.

247  : InputSource{d.moduleDescription}
248  , act_{&d.activityRegistry}
249  , sourceHelper_{d.moduleDescription}
250  , detail_{p, h_, sourceHelper_}
251  , fh_{
252  p.get<std::vector<std::string>>("fileNames", std::vector<std::string>())}
253 {
254  // Handle maxSubRuns parameter.
255  int64_t maxSubRuns_par = p.get<int64_t>("maxSubRuns", -1);
256  if (maxSubRuns_par > -1) {
257  remainingSubRuns_ = maxSubRuns_par;
258  haveSRLimit_ = true;
259  }
260  // Handle maxEvents parameter.
261  int64_t maxEvents_par = p.get<int64_t>("maxEvents", -1);
262  if (maxEvents_par > -1) {
263  remainingEvents_ = maxEvents_par;
264  haveEventLimit_ = true;
265  }
266  // Verify we got a real ActivityRegistry.
267  if (!act_) {
268  throw Exception(errors::LogicError) << "no ActivityRegistry\n";
269  }
270  // Finish product registration.
272 }
EventNumber_t remainingEvents_
Definition: Source.h:211
InputSource(ModuleDescription const &md)
Definition: InputSource.h:54
SourceDetail detail_
Definition: Source.h:189
SourceHelper sourceHelper_
Definition: Source.h:188
cet::exempt_ptr< ActivityRegistry > act_
Definition: Source.h:184
Float_t d
Definition: plot.C:237
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void finishProductRegistration_(InputSourceDescription &d)
Definition: Source.h:645
ProductRegistryHelper h_
Definition: Source.h:186
detail::FileNamesHandler< Source_wantFileServices< T >::value > fh_
Definition: Source.h:192
bool haveEventLimit_
Definition: Source.h:212
SubRunNumber_t remainingSubRuns_
Definition: Source.h:209
bool haveSRLimit_
Definition: Source.h:210

Member Function Documentation

template<class T >
void art::Source< T >::checkForNextFile_ ( )
private

Definition at line 444 of file Source.h.

References art::Source< T >::currentFileName_, art::Source< T >::detail_, art::Source< T >::fh_, art::input::IsFile, art::input::IsStop, art::Source< T >::state_, and fhicl::detail::atom::value().

Referenced by art::Source< T >::nextItemType(), art::Source< T >::readNextAndRefuseEvent_(), and art::Source< T >::readNextAndRequireRun_().

445 {
446  state_ = input::IsStop; // Default -- may change below.
449  detail::do_call_hasMoreData<T>,
450  detail::do_not_call_hasMoreData<T>>
451  generatorHasMoreData;
452  if (generatorHasMoreData(detail_)) {
454  }
455  } else {
456  currentFileName_ = fh_.next();
457  if (!currentFileName_.empty()) {
459  }
460  }
461 }
input::ItemType state_
Definition: Source.h:190
static constexpr bool value
Definition: SourceTraits.h:58
SourceDetail detail_
Definition: Source.h:189
std::string value(boost::any const &)
detail::FileNamesHandler< Source_wantFileServices< T >::value > fh_
Definition: Source.h:192
std::string currentFileName_
Definition: Source.h:193
template<class T >
void art::Source< T >::closeFile ( )
overridevirtual

Implements art::InputSource.

Definition at line 592 of file Source.h.

References art::Source< T >::cachedRP_, art::Source< T >::cachedSRP_, and art::Source< T >::detail_.

593 {
594  detail_.closeCurrentFile();
595  // Cached pointers are no longer valid since the PrincipalCache is
596  // cleared after file close.
597  cachedRP_ = nullptr;
598  cachedSRP_ = nullptr;
599 }
cet::exempt_ptr< SubRunPrincipal > cachedSRP_
Definition: Source.h:202
SourceDetail detail_
Definition: Source.h:189
cet::exempt_ptr< RunPrincipal > cachedRP_
Definition: Source.h:201
void art::InputSource::doBeginJob ( )
virtualinherited

Reimplemented in art::DecrepitRelicInputSourceImplementation.

Definition at line 31 of file InputSource.cc.

32 {}
void art::InputSource::doEndJob ( )
virtualinherited

Reimplemented in art::DecrepitRelicInputSourceImplementation.

Definition at line 35 of file InputSource.cc.

36 {}
template<class T >
void art::Source< T >::finishProductRegistration_ ( InputSourceDescription d)
private

Definition at line 645 of file Source.h.

References art::Source< T >::h_, art::ModuleDescription::id(), art::ModuleDescription::invalidID(), art::InputSourceDescription::moduleDescription, art::Source< T >::presentProducts_, art::ModuleDescription::processConfiguration(), art::InputSourceDescription::productRegistry, art::ProductRegistryHelper::registerProducts(), art::SourceHelper::setPresentProducts(), and art::Source< T >::sourceHelper_.

Referenced by art::Source< T >::Source().

646 {
647  // These _xERROR_ strings should never appear in branch names; they
648  // are here as tracers to help identify any failures in coding.
649  ProductDescriptions descriptions{};
651  d.productRegistry,
652  descriptions,
653  ModuleDescription{fhicl::ParameterSet{}.id(), // Dummy
654  "_NAMEERROR_",
655  "_LABELERROR_",
656  d.moduleDescription.processConfiguration(),
658  presentProducts_ = ProductTables{descriptions};
659  sourceHelper_.setPresentProducts(cet::make_exempt_ptr(&presentProducts_));
660 }
void registerProducts(MasterProductRegistry &mpr, ProductDescriptions &productsToRegister, ModuleDescription const &md)
static constexpr ModuleDescriptionID invalidID()
void setPresentProducts(cet::exempt_ptr< ProductTables const > presentProducts)
Definition: SourceHelper.cc:29
std::vector< BranchDescription > ProductDescriptions
SourceHelper sourceHelper_
Definition: Source.h:188
ProductTables presentProducts_
Definition: Source.h:187
Float_t d
Definition: plot.C:237
ProductRegistryHelper h_
Definition: Source.h:186
auto const& art::InputSource::moduleDescription ( ) const
inlineinherited

Definition at line 59 of file InputSource.h.

Referenced by art::EmptyEvent::readRun_(), and art::EmptyEvent::readSubRun_().

60  {
61  return moduleDescription_;
62  }
ModuleDescription moduleDescription_
Definition: InputSource.h:100
template<class T >
art::input::ItemType art::Source< T >::nextItemType ( )
overridevirtual

Implements art::InputSource.

Definition at line 465 of file Source.h.

References art::Source< T >::cachedSRP_, art::Source< T >::checkForNextFile_(), art::Source< T >::currentFileName_, art::errors::DataCorruption, art::Source< T >::fh_, art::input::IsEvent, art::input::IsFile, art::input::IsInvalid, art::input::IsRun, art::input::IsStop, art::input::IsSubRun, art::Source< T >::newE_, art::Source< T >::pendingEvent_, art::Source< T >::pendingSubRun_, art::Source< T >::readNext_(), art::Source< T >::readNextAndRefuseEvent_(), art::Source< T >::readNextAndRequireRun_(), art::Source< T >::remainingEvents_, art::Source< T >::remainingSubRuns_, and art::Source< T >::state_.

466 {
467  if (remainingEvents_ == 0) {
469  }
470  switch (state_) {
471  case input::IsInvalid:
473  state_ = input::IsFile; // Once.
474  } else {
476  }
477  break;
478  case input::IsFile:
480  break;
481  case input::IsRun:
484  pendingSubRun_ = false;
485  } else if (pendingEvent_)
487  << "Input file '" << currentFileName_ << "' contains an Event "
488  << newE_->id() << " that belongs to no SubRun\n";
489  else {
491  }
492  break;
493  case input::IsSubRun:
494  if (pendingEvent_) {
496  pendingEvent_ = false;
497  } else {
499  }
500  break;
501  case input::IsEvent:
502  if (!readNext_()) {
504  }
505  break;
506  case input::IsStop:
507  break;
508  }
509  if ((state_ == input::IsRun || state_ == input::IsSubRun) &&
510  remainingSubRuns_ == 0) {
512  }
513  if (state_ == input::IsStop) {
514  // FIXME: upon the advent of a catalog system which can do something
515  // intelligent with the difference between whole-file success,
516  // partial-file success, partial-file failure and whole-file failure
517  // (such as file-open failure), we will need to communicate that
518  // difference here. The file disposition options as they are now
519  // (and the mapping to any concrete implementation we are are aware
520  // of currently) are not sufficient to the task, so we deliberately
521  // do not distinguish here between partial-file and whole-file
522  // success in particular.
523  fh_.finish();
524  }
525  return state_;
526 }
void checkForNextFile_()
Definition: Source.h:444
bool readNext_()
Definition: Source.h:396
bool pendingSubRun_
Definition: Source.h:204
EventNumber_t remainingEvents_
Definition: Source.h:211
void readNextAndRequireRun_()
Definition: Source.h:530
input::ItemType state_
Definition: Source.h:190
cet::exempt_ptr< SubRunPrincipal > cachedSRP_
Definition: Source.h:202
bool pendingEvent_
Definition: Source.h:205
static constexpr bool value
Definition: SourceTraits.h:58
std::unique_ptr< EventPrincipal > newE_
Definition: Source.h:197
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
detail::FileNamesHandler< Source_wantFileServices< T >::value > fh_
Definition: Source.h:192
SubRunNumber_t remainingSubRuns_
Definition: Source.h:209
void readNextAndRefuseEvent_()
Definition: Source.h:550
std::string currentFileName_
Definition: Source.h:193
template<class T >
Source<T>& art::Source< T >::operator= ( Source< T > const &  )
delete
auto const& art::InputSource::processConfiguration ( ) const
inlineinherited

Definition at line 64 of file InputSource.h.

References n.

Referenced by art::EmptyEvent::readRun_(), art::EmptyEvent::readSubRun_(), art::EmptyEvent::reallyReadEvent(), and art::RootInput::RootInput().

65  {
67  }
ModuleDescription moduleDescription_
Definition: InputSource.h:100
ProcessConfiguration const & processConfiguration() const
std::unique_ptr< art::EventPrincipal > art::InputSource::readEvent ( art::EventID const &  id)
virtualinherited

Reimplemented in art::DecrepitRelicInputSourceImplementation.

Definition at line 4 of file InputSource.cc.

References art::errors::Configuration.

5 {
7  << "The application has tried to peform random access on an input source\n"
8  << "that does not support random access. Please reconfigure the program\n"
9  << "to use an input source that supports random access (e.g. RootInput)\n";
10 }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
template<class T >
std::unique_ptr< art::EventPrincipal > art::Source< T >::readEvent ( cet::exempt_ptr< SubRunPrincipal const >  srp)
overridevirtual

Implements art::InputSource.

Definition at line 635 of file Source.h.

References art::Source< T >::haveEventLimit_, art::Source< T >::newE_, and art::Source< T >::remainingEvents_.

636 {
637  if (haveEventLimit_) {
639  }
640  return std::move(newE_);
641 }
EventNumber_t remainingEvents_
Definition: Source.h:211
std::unique_ptr< EventPrincipal > newE_
Definition: Source.h:197
bool haveEventLimit_
Definition: Source.h:212
template<class T >
std::unique_ptr< art::FileBlock > art::Source< T >::readFile ( )
overridevirtual

Implements art::InputSource.

Definition at line 579 of file Source.h.

References art::Source< T >::currentFileName_, art::Source< T >::detail_, and art::errors::LogicError.

580 {
581  FileBlock* newF{nullptr};
582  detail_.readFile(currentFileName_, newF);
583  if (!newF) {
585  << "detail_::readFile() failed to return a valid FileBlock object\n";
586  }
587  return std::unique_ptr<FileBlock>(newF);
588 }
SourceDetail detail_
Definition: Source.h:189
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string currentFileName_
Definition: Source.h:193
template<class T >
bool art::Source< T >::readNext_ ( )
private

Definition at line 396 of file Source.h.

References art::Source< T >::cachedRP_, art::Source< T >::cachedSRP_, art::Source< T >::detail_, art::input::IsEvent, art::input::IsRun, art::input::IsSubRun, art::Source< T >::newE_, art::Source< T >::newRP_, art::Source< T >::newSRP_, art::Source< T >::pendingEvent_, art::Source< T >::pendingSubRun_, art::Source< T >::state_, art::Source< T >::subRunIsNew_, and art::Source< T >::throwIfInsane_().

Referenced by art::Source< T >::nextItemType(), art::Source< T >::readNextAndRefuseEvent_(), and art::Source< T >::readNextAndRequireRun_().

397 {
398  std::unique_ptr<RunPrincipal> newR{nullptr};
399  std::unique_ptr<SubRunPrincipal> newSR{nullptr};
400  std::unique_ptr<EventPrincipal> newE{nullptr};
401 
402  bool result{false};
403  {
404  RunPrincipal* nR{nullptr};
405  SubRunPrincipal* nSR{nullptr};
406  EventPrincipal* nE{nullptr};
407  result = detail_.readNext(cachedRP_.get(), cachedSRP_.get(), nR, nSR, nE);
408  newR.reset(nR);
409  newSR.reset(nSR);
410  newE.reset(nE);
411  throwIfInsane_(result, newR.get(), newSR.get(), newE.get());
412  }
413 
414  if (result) {
415  subRunIsNew_ = newSR && ((!cachedSRP_) || newSR->id() != cachedSRP_->id());
416  pendingSubRun_ = newSR.get() != nullptr;
417  pendingEvent_ = newE.get() != nullptr;
418  if (newR) {
419  newRP_ = std::move(newR);
420  }
421  if (newSR) {
422  auto rp = newRP_ ? newRP_.get() : cachedRP_.get();
423  newSR->setRunPrincipal(rp);
424  newSRP_ = std::move(newSR);
425  }
426  if (newE) {
427  auto srp = newSRP_ ? newSRP_.get() : cachedSRP_.get();
428  newE->setSubRunPrincipal(srp);
429  newE_ = std::move(newE);
430  }
431  if (newRP_) {
433  } else if (newSRP_) {
435  } else if (newE_) {
437  }
438  }
439  return result;
440 }
bool pendingSubRun_
Definition: Source.h:204
bool subRunIsNew_
Definition: Source.h:207
input::ItemType state_
Definition: Source.h:190
cet::exempt_ptr< SubRunPrincipal > cachedSRP_
Definition: Source.h:202
bool pendingEvent_
Definition: Source.h:205
SourceDetail detail_
Definition: Source.h:189
std::unique_ptr< SubRunPrincipal > newSRP_
Definition: Source.h:196
cet::exempt_ptr< RunPrincipal > cachedRP_
Definition: Source.h:201
std::unique_ptr< EventPrincipal > newE_
Definition: Source.h:197
void throwIfInsane_(bool result, RunPrincipal *newR, SubRunPrincipal *newSR, EventPrincipal *newE) const
Definition: Source.h:283
std::unique_ptr< RunPrincipal > newRP_
Definition: Source.h:195
template<class T >
void art::Source< T >::readNextAndRefuseEvent_ ( )
private

Definition at line 550 of file Source.h.

References art::Source< T >::checkForNextFile_(), art::Source< T >::currentFileName_, art::errors::DataCorruption, art::input::IsEvent, art::Source< T >::readNext_(), and art::Source< T >::state_.

Referenced by art::Source< T >::nextItemType().

551 {
552  if (readNext_()) {
553  if (state_ == input::IsEvent) {
555  << "Input file '" << currentFileName_
556  << "' has an Event where a Run or SubRun is expected\n";
557  }
558  } else {
560  }
561 }
void checkForNextFile_()
Definition: Source.h:444
bool readNext_()
Definition: Source.h:396
input::ItemType state_
Definition: Source.h:190
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string currentFileName_
Definition: Source.h:193
template<class T >
void art::Source< T >::readNextAndRequireRun_ ( )
private

Definition at line 530 of file Source.h.

References art::Source< T >::cachedRP_, art::Source< T >::checkForNextFile_(), art::Source< T >::currentFileName_, art::errors::DataCorruption, art::input::IsRun, art::input::IsSubRun, art::Source< T >::readNext_(), and art::Source< T >::state_.

Referenced by art::Source< T >::nextItemType().

531 {
532  if (readNext_()) {
533  if (state_ != input::IsRun) {
534  if (cachedRP_) {
535  state_ = input::IsRun; // Regurgitate existing cached run.
536  } else {
538  << "Input file '" << currentFileName_ << "' has a"
539  << (state_ == input::IsSubRun ? " SubRun" : "n Event")
540  << " where a Run is expected\n";
541  }
542  }
543  } else {
545  }
546 }
void checkForNextFile_()
Definition: Source.h:444
bool readNext_()
Definition: Source.h:396
input::ItemType state_
Definition: Source.h:190
cet::exempt_ptr< RunPrincipal > cachedRP_
Definition: Source.h:201
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string currentFileName_
Definition: Source.h:193
template<class T >
std::unique_ptr< art::RunPrincipal > art::Source< T >::readRun ( )
overridevirtual

Implements art::InputSource.

Definition at line 603 of file Source.h.

References art::Source< T >::cachedRP_, art::errors::LogicError, and art::Source< T >::newRP_.

604 {
605  if (!newRP_)
607  << "Error in Source<T>\n"
608  << "readRun() called when no RunPrincipal exists\n"
609  << "Please report this to the art developers\n";
610  cachedRP_ = newRP_.get();
611  return std::move(newRP_);
612 }
cet::exempt_ptr< RunPrincipal > cachedRP_
Definition: Source.h:201
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::unique_ptr< RunPrincipal > newRP_
Definition: Source.h:195
template<class T >
std::unique_ptr< art::SubRunPrincipal > art::Source< T >::readSubRun ( cet::exempt_ptr< RunPrincipal const >  rp)
overridevirtual

Implements art::InputSource.

Definition at line 616 of file Source.h.

References art::Source< T >::cachedSRP_, art::Source< T >::haveSRLimit_, art::errors::LogicError, art::Source< T >::newSRP_, art::Source< T >::remainingSubRuns_, and art::Source< T >::subRunIsNew_.

617 {
618  if (!newSRP_)
620  << "Error in Source<T>\n"
621  << "readSubRun() called when no SubRunPrincipal exists\n"
622  << "Please report this to the art developers\n";
623  if (subRunIsNew_) {
624  if (haveSRLimit_) {
626  }
627  subRunIsNew_ = false;
628  }
629  cachedSRP_ = newSRP_.get();
630  return std::move(newSRP_);
631 }
bool subRunIsNew_
Definition: Source.h:207
cet::exempt_ptr< SubRunPrincipal > cachedSRP_
Definition: Source.h:202
std::unique_ptr< SubRunPrincipal > newSRP_
Definition: Source.h:196
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
SubRunNumber_t remainingSubRuns_
Definition: Source.h:209
bool haveSRLimit_
Definition: Source.h:210
void art::InputSource::rewind ( )
virtualinherited

Reimplemented in art::DecrepitRelicInputSourceImplementation.

Definition at line 22 of file InputSource.cc.

References art::errors::Configuration.

23 {
25  << "The application has tried to rewind an input source\n"
26  << "that does not support rewinding. Please reconfigure the program\n"
27  << "to use an input source that supports random access (e.g. RootInput)\n";
28 }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
template<class T >
std::unique_ptr< art::RangeSetHandler > art::Source< T >::runRangeSetHandler ( )
overridevirtual

Implements art::InputSource.

Definition at line 565 of file Source.h.

References art::Source< T >::cachedRP_.

566 {
567  return std::make_unique<OpenRangeSetHandler>(cachedRP_->run());
568 }
cet::exempt_ptr< RunPrincipal > cachedRP_
Definition: Source.h:201
void art::InputSource::skipEvents ( int  n)
virtualinherited

Reimplemented in art::DecrepitRelicInputSourceImplementation.

Definition at line 13 of file InputSource.cc.

References art::errors::Configuration.

14 {
16  << "The application has tried to peform random access on an input source\n"
17  << "that does not support random access. Please reconfigure the program\n"
18  << "to use an input source that supports random access (e.g. RootInput)\n";
19 }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
template<class T >
std::unique_ptr< art::RangeSetHandler > art::Source< T >::subRunRangeSetHandler ( )
overridevirtual

Implements art::InputSource.

Definition at line 572 of file Source.h.

References art::Source< T >::cachedSRP_.

573 {
574  return std::make_unique<OpenRangeSetHandler>(cachedSRP_->run());
575 }
cet::exempt_ptr< SubRunPrincipal > cachedSRP_
Definition: Source.h:202
template<class T >
void art::Source< T >::throwDataCorruption_ ( const char *  msg)
staticprivate

Definition at line 276 of file Source.h.

References art::errors::DataCorruption.

Referenced by art::Source< T >::throwIfInsane_().

277 {
278  throw Exception(errors::DataCorruption) << msg;
279 }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
template<class T >
void art::Source< T >::throwIfInsane_ ( bool  result,
RunPrincipal newR,
SubRunPrincipal newSR,
EventPrincipal newE 
) const
private

Definition at line 283 of file Source.h.

References art::Source< T >::cachedRP_, art::Source< T >::cachedSRP_, art::RunPrincipal::id(), art::SubRunPrincipal::id(), art::EventPrincipal::id(), art::SubRunID::isValid(), art::RunID::isValid(), art::EventID::isValid(), art::errors::LogicError, art::SubRunID::runID(), art::SubRunPrincipal::runPrincipalExemptPtr(), art::EventID::subRunID(), art::EventPrincipal::subRunPrincipalExemptPtr(), and art::Source< T >::throwDataCorruption_().

Referenced by art::Source< T >::readNext_().

287 {
288  std::ostringstream errMsg;
289  if (result) {
290  if (!newR && !newSR && !newE) {
292  << "readNext returned true but created no new data\n";
293  }
294 
295  if (!cachedRP_ && !newR) {
297  << "readNext returned true but no RunPrincipal has been set, and no "
298  "cached RunPrincipal exists.\n"
299  "This can happen if a new input file has been opened and the "
300  "RunPrincipal has not been appropriately assigned.";
301  }
302 
303  if (!cachedSRP_ && !newSR) {
305  << "readNext returned true but no SubRunPrincipal has been set, and no "
306  "cached SubRunPrincipal exists.\n"
307  "This can happen if a new input file has been opened and the "
308  "SubRunPrincipal has not been appropriately assigned.";
309  }
310 
311  if (cachedRP_ && newR && cachedRP_.get() == newR) {
312  errMsg << "readNext returned a new Run which is the old Run for "
313  << cachedRP_->id()
314  << ".\nIf you don't have a new run, don't return one!\n";
315  }
316  if (cachedSRP_ && newSR && cachedSRP_.get() == newSR) {
317  errMsg << "readNext returned a new SubRun which is the old SubRun for "
318  << cachedSRP_->id()
319  << ".\nIf you don't have a new subRun, don't return one!\n";
320  }
321  // Either or both of the above cases could be true and we need
322  // to make both of them safe before we throw:
323  if (!errMsg.str().empty())
324  throw Exception(errors::LogicError) << errMsg.str();
325  if (cachedRP_ && cachedSRP_) {
326  if (!newR && newSR && newSR->id() == cachedSRP_->id())
327  throwDataCorruption_("readNext returned a 'new' SubRun "
328  "that was the same as the previous "
329  "SubRun\n");
330  if (newR && newR->id() == cachedRP_->id())
331  throwDataCorruption_("readNext returned a 'new' Run "
332  "that was the same as the previous "
333  "Run\n");
334  if (newR && !newSR && newE)
335  throwDataCorruption_("readNext returned a new Run and "
336  "Event without a SubRun\n");
337  if (newR && newSR && newSR->id() == cachedSRP_->id())
338  throwDataCorruption_("readNext returned a new Run with "
339  "a SubRun from the wrong Run\n");
340  }
341  RunID rID;
342  SubRunID srID;
343  EventID eID;
344  if (newR) {
345  rID = newR->id();
346  if (!rID.isValid()) {
348  "readNext returned a Run with an invalid RunID.\n");
349  }
350  } else if (cachedRP_) {
351  rID = cachedRP_->id();
352  }
353  if (newSR) {
354  srID = newSR->id();
355  if (rID != srID.runID()) {
356  errMsg << "readNext returned a SubRun " << srID
357  << " which is a mismatch to " << rID << "\n";
358  throwDataCorruption_(errMsg.str().c_str());
359  }
360  if (!srID.isValid()) {
362  "readNext returned a SubRun with an invalid SubRunID.\n");
363  }
364  if (newSR->runPrincipalExemptPtr()) {
366  "readNext returned a SubRun with a non-null embedded Run.\n");
367  }
368  } else if (cachedSRP_) {
369  srID = cachedSRP_->id();
370  }
371  if (newE) {
372  eID = newE->id();
373  if (srID != eID.subRunID()) {
374  errMsg << "readNext returned an Event " << eID
375  << " which is a mismatch to " << srID << "\n";
376  throwDataCorruption_(errMsg.str().c_str());
377  }
378  if (!eID.isValid()) {
380  "readNext returned an Event with an invalid EventID.\n");
381  }
382  if (newE->subRunPrincipalExemptPtr()) {
384  "readNext returned an Event with a non-null embedded SubRun.\n");
385  }
386  }
387  } else {
388  if (newR || newSR || newE)
390  << "readNext returned false but created new data\n";
391  }
392 }
static void throwDataCorruption_(const char *msg)
Definition: Source.h:276
cet::exempt_ptr< SubRunPrincipal > cachedSRP_
Definition: Source.h:202
cet::exempt_ptr< RunPrincipal > cachedRP_
Definition: Source.h:201
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66

Member Data Documentation

template<class T >
cet::exempt_ptr<ActivityRegistry> art::Source< T >::act_
private

Definition at line 184 of file Source.h.

Referenced by art::Source< T >::Source().

template<class T >
ProductRegistryHelper art::Source< T >::h_ {}
private
template<class T >
bool art::Source< T >::haveEventLimit_ {false}
private

Definition at line 212 of file Source.h.

Referenced by art::Source< T >::readEvent(), and art::Source< T >::Source().

template<class T >
bool art::Source< T >::haveSRLimit_ {false}
private

Definition at line 210 of file Source.h.

Referenced by art::Source< T >::readSubRun(), and art::Source< T >::Source().

template<class T >
std::unique_ptr<EventPrincipal> art::Source< T >::newE_ {nullptr}
private
template<class T >
std::unique_ptr<RunPrincipal> art::Source< T >::newRP_ {nullptr}
private

Definition at line 195 of file Source.h.

Referenced by art::Source< T >::readNext_(), and art::Source< T >::readRun().

template<class T >
std::unique_ptr<SubRunPrincipal> art::Source< T >::newSRP_ {nullptr}
private

Definition at line 196 of file Source.h.

Referenced by art::Source< T >::readNext_(), and art::Source< T >::readSubRun().

template<class T >
bool art::Source< T >::pendingEvent_ {false}
private

Definition at line 205 of file Source.h.

Referenced by art::Source< T >::nextItemType(), and art::Source< T >::readNext_().

template<class T >
bool art::Source< T >::pendingSubRun_ {false}
private

Definition at line 204 of file Source.h.

Referenced by art::Source< T >::nextItemType(), and art::Source< T >::readNext_().

template<class T >
ProductTables art::Source< T >::presentProducts_ {ProductTables::invalid()}
private

Definition at line 187 of file Source.h.

Referenced by art::Source< T >::finishProductRegistration_().

template<class T >
EventNumber_t art::Source< T >::remainingEvents_ {1}
private
template<class T >
SubRunNumber_t art::Source< T >::remainingSubRuns_ {1}
private
template<class T >
SourceHelper art::Source< T >::sourceHelper_
private
template<class T >
bool art::Source< T >::subRunIsNew_ {false}
private

Definition at line 207 of file Source.h.

Referenced by art::Source< T >::readNext_(), and art::Source< T >::readSubRun().


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