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

#include "Source.h"

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

Public Types

using Parameters = typename detail::maybe_has_Parameters< T >::Parameters
 
enum  ProcessingMode { Runs, RunsAndSubRuns, RunsSubRunsAndEvents }
 

Public Member Functions

template<typename U = Parameters>
 Source (std::enable_if_t< std::is_same_v< U, fhicl::ParameterSet >, fhicl::ParameterSet > const &p, InputSourceDescription &d)
 
template<typename U = Parameters>
 Source (std::enable_if_t<!std::is_same_v< U, fhicl::ParameterSet >, U > const &p, InputSourceDescription &d)
 
 Source (Source< T > const &)=delete
 
 Source (Source< T > &&)=delete
 
Source< T > & operator= (Source< T > const &)=delete
 
Source< T > & operator= (Source< T > &&)=delete
 
virtual void doBeginJob ()
 
virtual void doEndJob ()
 
virtual void skipEvents (int n)
 
ModuleDescription const & moduleDescription () const
 
ProcessConfiguration const & processConfiguration () const
 

Static Public Member Functions

static ProcessingMode mode (std::string const &modeString)
 

Private Member Functions

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< RangeSetHandlerrunRangeSetHandler () override
 
std::unique_ptr< RangeSetHandlersubRunRangeSetHandler () override
 
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

ProductRegistryHelper h_ {product_creation_mode::reconstitutes}
 
UpdateOutputCallbacksoutputCallbacks_
 
ProductTables presentProducts_ {ProductTables::invalid()}
 
SourceHelper sourceHelper_
 
detail_
 
input::ItemType state_ {input::IsInvalid}
 
detail::FileNamesHandler< Source_wantFileServices< T >::valuefh_
 
std::string currentFileName_ {}
 
std::unique_ptr< RunPrincipalnewRP_ {}
 
std::unique_ptr< SubRunPrincipalnewSRP_ {}
 
std::unique_ptr< EventPrincipalnewE_ {}
 
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<typename T>
class art::Source< T >

Definition at line 118 of file Source.h.

Member Typedef Documentation

template<typename T >
using art::Source< T >::Parameters = typename detail::maybe_has_Parameters<T>::Parameters

Definition at line 202 of file Source.h.

Member Enumeration Documentation

Enumerator
Runs 
RunsAndSubRuns 
RunsSubRunsAndEvents 

Definition at line 61 of file InputSource.h.

Constructor & Destructor Documentation

template<typename T >
template<typename U >
art::Source< T >::Source ( std::enable_if_t< std::is_same_v< U, fhicl::ParameterSet >, fhicl::ParameterSet > const &  p,
InputSourceDescription d 
)
explicit

Definition at line 298 of file Source.h.

References 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::InputSourceDescription::moduleDescription, art::Source< T >::outputCallbacks_, art::Source< T >::remainingEvents_, art::Source< T >::remainingSubRuns_, and art::Source< T >::sourceHelper_.

301  : InputSource{d.moduleDescription}
302  , outputCallbacks_{d.productRegistry}
303  , sourceHelper_{d.moduleDescription}
304  , detail_{p, h_, sourceHelper_}
305  , fh_{p.template get<std::vector<std::string>>("fileNames", {})}
306  {
307  int64_t const maxSubRuns_par = p.template get<int64_t>("maxSubRuns", -1);
308  if (maxSubRuns_par > -1) {
309  remainingSubRuns_ = maxSubRuns_par;
310  haveSRLimit_ = true;
311  }
312  int64_t const maxEvents_par = p.template get<int64_t>("maxEvents", -1);
313  if (maxEvents_par > -1) {
314  remainingEvents_ = maxEvents_par;
315  haveEventLimit_ = true;
316  }
318  }
InputSource(ModuleDescription const &)
Definition: InputSource.cc:27
EventNumber_t remainingEvents_
Definition: Source.h:292
SourceHelper sourceHelper_
Definition: Source.h:272
Float_t d
Definition: plot.C:235
void finishProductRegistration_(InputSourceDescription &d)
Definition: Source.h:703
ProductRegistryHelper h_
Definition: Source.h:267
detail::FileNamesHandler< Source_wantFileServices< T >::value > fh_
Definition: Source.h:275
bool haveEventLimit_
Definition: Source.h:293
SubRunNumber_t remainingSubRuns_
Definition: Source.h:290
UpdateOutputCallbacks & outputCallbacks_
Definition: Source.h:268
bool haveSRLimit_
Definition: Source.h:291
template<typename T >
template<typename U >
art::Source< T >::Source ( std::enable_if_t<!std::is_same_v< U, fhicl::ParameterSet >, U > const &  p,
InputSourceDescription d 
)
explicit

Definition at line 322 of file Source.h.

References 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::InputSourceDescription::moduleDescription, art::Source< T >::outputCallbacks_, art::Source< T >::remainingEvents_, and art::Source< T >::remainingSubRuns_.

325  : InputSource{d.moduleDescription}
326  , outputCallbacks_{d.productRegistry}
327  , sourceHelper_{d.moduleDescription}
328  , detail_{p().userConfig, h_, sourceHelper_}
329  , fh_{p().sourceConfig().fileNames()}
330  {
331  if (int64_t const maxSubRuns_par = p().sourceConfig().maxSubRuns();
332  maxSubRuns_par > -1) {
333  remainingSubRuns_ = maxSubRuns_par;
334  haveSRLimit_ = true;
335  }
336  if (int64_t const maxEvents_par = p().sourceConfig().maxEvents();
337  maxEvents_par > -1) {
338  remainingEvents_ = maxEvents_par;
339  haveEventLimit_ = true;
340  }
342  }
InputSource(ModuleDescription const &)
Definition: InputSource.cc:27
EventNumber_t remainingEvents_
Definition: Source.h:292
SourceHelper sourceHelper_
Definition: Source.h:272
Float_t d
Definition: plot.C:235
void finishProductRegistration_(InputSourceDescription &d)
Definition: Source.h:703
ProductRegistryHelper h_
Definition: Source.h:267
detail::FileNamesHandler< Source_wantFileServices< T >::value > fh_
Definition: Source.h:275
bool haveEventLimit_
Definition: Source.h:293
SubRunNumber_t remainingSubRuns_
Definition: Source.h:290
UpdateOutputCallbacks & outputCallbacks_
Definition: Source.h:268
bool haveSRLimit_
Definition: Source.h:291
template<typename T >
art::Source< T >::Source ( Source< T > const &  )
delete
template<typename T >
art::Source< T >::Source ( Source< T > &&  )
delete

Member Function Documentation

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

Definition at line 502 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 value.

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

503  {
504  state_ = input::IsStop; // Default -- may change below.
507  detail::do_call_hasMoreData<T>,
508  detail::do_not_call_hasMoreData<T>>
509  generatorHasMoreData;
510  if (generatorHasMoreData(detail_)) {
512  }
513  } else {
514  currentFileName_ = fh_.next();
515  if (!currentFileName_.empty()) {
517  }
518  }
519  }
input::ItemType state_
Definition: Source.h:274
static constexpr bool value
Definition: SourceTraits.h:58
double value
Definition: spectrum.C:18
detail::FileNamesHandler< Source_wantFileServices< T >::value > fh_
Definition: Source.h:275
std::string currentFileName_
Definition: Source.h:276
template<typename T >
void art::Source< T >::closeFile ( )
overrideprivatevirtual

Implements art::InputSource.

Definition at line 650 of file Source.h.

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

651  {
652  detail_.closeCurrentFile();
653  // Cached pointers are no longer valid since the PrincipalCache is
654  // cleared after file close.
655  cachedRP_ = nullptr;
656  cachedSRP_ = nullptr;
657  }
cet::exempt_ptr< SubRunPrincipal > cachedSRP_
Definition: Source.h:285
cet::exempt_ptr< RunPrincipal > cachedRP_
Definition: Source.h:284
void art::InputSource::doBeginJob ( )
virtualinherited

Reimplemented in art::EmptyEvent.

Definition at line 54 of file InputSource.cc.

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

Reimplemented in art::EmptyEvent.

Definition at line 58 of file InputSource.cc.

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

Definition at line 703 of file Source.h.

References art::Source< T >::h_, fhicl::ParameterSet::id(), art::UpdateOutputCallbacks::invoke(), art::legacy, art::InputSourceDescription::moduleDescription, art::Source< T >::outputCallbacks_, art::Source< T >::presentProducts_, art::ModuleDescription::processConfiguration(), and art::ProductRegistryHelper::registerProducts().

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

704  {
705  // These _xERROR_ strings should never appear in branch names; they
706  // are here as tracers to help identify any failures in coding.
707  ProductDescriptions descriptions;
709  descriptions,
710  ModuleDescription{fhicl::ParameterSet{}.id(), // Dummy
711  "_NAMEERROR_",
712  "_LABELERROR_",
714  d.moduleDescription.processConfiguration(),
715  true /*isEmulated*/});
716  presentProducts_ = ProductTables{descriptions};
717  sourceHelper_.setPresentProducts(cet::make_exempt_ptr(&presentProducts_));
719  }
void setPresentProducts(cet::exempt_ptr< ProductTables const > presentProducts)
Definition: SourceHelper.cc:66
std::vector< BranchDescription > ProductDescriptions
void registerProducts(ProductDescriptions &productsToRegister, ModuleDescription const &md)
SourceHelper sourceHelper_
Definition: Source.h:272
ProductTables presentProducts_
Definition: Source.h:269
Float_t d
Definition: plot.C:235
void invoke(ProductTables const &)
ParameterSetID id() const
ProductRegistryHelper h_
Definition: Source.h:267
UpdateOutputCallbacks & outputCallbacks_
Definition: Source.h:268
InputSource::ProcessingMode art::InputSource::mode ( std::string const &  modeString)
staticinherited

Definition at line 9 of file InputSource.cc.

References art::errors::Configuration, art::InputSource::Runs, art::InputSource::RunsAndSubRuns, and art::InputSource::RunsSubRunsAndEvents.

Referenced by art::ProcessingLimits::ProcessingLimits().

10  {
11  if (modeString == "Runs") {
12  return Runs;
13  }
14  if (modeString == "RunsAndSubRuns") {
15  return RunsAndSubRuns;
16  }
17  if (modeString == "RunsSubRunsAndEvents") {
18  return RunsSubRunsAndEvents;
19  }
21  << "The 'processingMode' parameter for sources has an illegal value '"
22  << modeString << "'\n"
23  << "Legal values are 'Runs', 'RunsAndSubRuns', or "
24  "'RunsSubRunsAndEvents'.\n";
25  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
ModuleDescription const & art::InputSource::moduleDescription ( ) const
inherited

Definition at line 31 of file InputSource.cc.

References art::InputSource::moduleDescription_.

Referenced by art::EmptyEvent::readRun(), and art::EmptyEvent::readSubRun().

32  {
33  return moduleDescription_;
34  }
ModuleDescription moduleDescription_
Definition: InputSource.h:106
template<typename T >
input::ItemType art::Source< T >::nextItemType ( )
overrideprivatevirtual

Implements art::InputSource.

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

524  {
525  if (remainingEvents_ == 0) {
527  }
528  switch (state_) {
529  case input::IsInvalid:
531  state_ = input::IsFile; // Once.
532  } else {
534  }
535  break;
536  case input::IsFile:
538  break;
539  case input::IsRun:
542  pendingSubRun_ = false;
543  } else if (pendingEvent_)
545  << "Input file '" << currentFileName_ << "' contains an Event "
546  << newE_->eventID() << " that belongs to no SubRun\n";
547  else {
549  }
550  break;
551  case input::IsSubRun:
552  if (pendingEvent_) {
554  pendingEvent_ = false;
555  } else {
557  }
558  break;
559  case input::IsEvent:
560  if (!readNext_()) {
562  }
563  break;
564  case input::IsStop:
565  break;
566  }
567  if ((state_ == input::IsRun || state_ == input::IsSubRun) &&
568  remainingSubRuns_ == 0) {
570  }
571  if (state_ == input::IsStop) {
572  // FIXME: upon the advent of a catalog system which can do something
573  // intelligent with the difference between whole-file success,
574  // partial-file success, partial-file failure and whole-file failure
575  // (such as file-open failure), we will need to communicate that
576  // difference here. The file disposition options as they are now
577  // (and the mapping to any concrete implementation we are are aware
578  // of currently) are not sufficient to the task, so we deliberately
579  // do not distinguish here between partial-file and whole-file
580  // success in particular.
581  fh_.finish();
582  }
583  return state_;
584  }
void checkForNextFile_()
Definition: Source.h:502
bool readNext_()
Definition: Source.h:455
bool pendingSubRun_
Definition: Source.h:287
EventNumber_t remainingEvents_
Definition: Source.h:292
void readNextAndRequireRun_()
Definition: Source.h:588
input::ItemType state_
Definition: Source.h:274
cet::exempt_ptr< SubRunPrincipal > cachedSRP_
Definition: Source.h:285
bool pendingEvent_
Definition: Source.h:288
static constexpr bool value
Definition: SourceTraits.h:58
std::unique_ptr< EventPrincipal > newE_
Definition: Source.h:280
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
detail::FileNamesHandler< Source_wantFileServices< T >::value > fh_
Definition: Source.h:275
SubRunNumber_t remainingSubRuns_
Definition: Source.h:290
void readNextAndRefuseEvent_()
Definition: Source.h:608
std::string currentFileName_
Definition: Source.h:276
template<typename T >
Source<T>& art::Source< T >::operator= ( Source< T > const &  )
delete
template<typename T >
Source<T>& art::Source< T >::operator= ( Source< T > &&  )
delete
ProcessConfiguration const & art::InputSource::processConfiguration ( ) const
inherited
template<typename T >
std::unique_ptr< EventPrincipal > art::Source< T >::readEvent ( cet::exempt_ptr< SubRunPrincipal const >  srp)
overrideprivatevirtual

Implements art::InputSource.

Definition at line 693 of file Source.h.

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

694  {
695  if (haveEventLimit_) {
697  }
698  return std::move(newE_);
699  }
EventNumber_t remainingEvents_
Definition: Source.h:292
std::unique_ptr< EventPrincipal > newE_
Definition: Source.h:280
bool haveEventLimit_
Definition: Source.h:293
template<typename T >
std::unique_ptr< FileBlock > art::Source< T >::readFile ( )
overrideprivatevirtual

Implements art::InputSource.

Definition at line 637 of file Source.h.

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

638  {
639  FileBlock* newF{nullptr};
640  detail_.readFile(currentFileName_, newF);
641  if (!newF) {
643  << "detail_::readFile() failed to return a valid FileBlock object\n";
644  }
645  return std::unique_ptr<FileBlock>(newF);
646  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string currentFileName_
Definition: Source.h:276
template<typename T >
bool art::Source< T >::readNext_ ( )
private

Definition at line 455 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_().

456  {
457  std::unique_ptr<RunPrincipal> newR{nullptr};
458  std::unique_ptr<SubRunPrincipal> newSR{nullptr};
459  std::unique_ptr<EventPrincipal> newE{nullptr};
460  bool result{false};
461  {
462  RunPrincipal* nR{nullptr};
463  SubRunPrincipal* nSR{nullptr};
464  EventPrincipal* nE{nullptr};
465  result = detail_.readNext(cachedRP_.get(), cachedSRP_.get(), nR, nSR, nE);
466  newR.reset(nR);
467  newSR.reset(nSR);
468  newE.reset(nE);
469  throwIfInsane_(result, newR.get(), newSR.get(), newE.get());
470  }
471  if (result) {
472  subRunIsNew_ =
473  newSR && ((!cachedSRP_) || newSR->subRunID() != cachedSRP_->subRunID());
474  pendingSubRun_ = newSR.get() != nullptr;
475  pendingEvent_ = newE.get() != nullptr;
476  if (newR) {
477  newRP_ = std::move(newR);
478  }
479  if (newSR) {
480  auto rp = newRP_ ? newRP_.get() : cachedRP_.get();
481  newSR->setRunPrincipal(rp);
482  newSRP_ = std::move(newSR);
483  }
484  if (newE) {
485  auto srp = newSRP_ ? newSRP_.get() : cachedSRP_.get();
486  newE->setSubRunPrincipal(srp);
487  newE_ = std::move(newE);
488  }
489  if (newRP_) {
491  } else if (newSRP_) {
493  } else if (newE_) {
495  }
496  }
497  return result;
498  }
bool pendingSubRun_
Definition: Source.h:287
bool subRunIsNew_
Definition: Source.h:289
input::ItemType state_
Definition: Source.h:274
cet::exempt_ptr< SubRunPrincipal > cachedSRP_
Definition: Source.h:285
bool pendingEvent_
Definition: Source.h:288
std::unique_ptr< SubRunPrincipal > newSRP_
Definition: Source.h:279
cet::exempt_ptr< RunPrincipal > cachedRP_
Definition: Source.h:284
std::unique_ptr< EventPrincipal > newE_
Definition: Source.h:280
void throwIfInsane_(bool result, RunPrincipal *newR, SubRunPrincipal *newSR, EventPrincipal *newE) const
Definition: Source.h:353
std::unique_ptr< RunPrincipal > newRP_
Definition: Source.h:278
template<typename T >
void art::Source< T >::readNextAndRefuseEvent_ ( )
private

Definition at line 608 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().

609  {
610  if (readNext_()) {
611  if (state_ == input::IsEvent) {
613  << "Input file '" << currentFileName_
614  << "' has an Event where a Run or SubRun is expected\n";
615  }
616  } else {
618  }
619  }
void checkForNextFile_()
Definition: Source.h:502
bool readNext_()
Definition: Source.h:455
input::ItemType state_
Definition: Source.h:274
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string currentFileName_
Definition: Source.h:276
template<typename T >
void art::Source< T >::readNextAndRequireRun_ ( )
private

Definition at line 588 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().

589  {
590  if (readNext_()) {
591  if (state_ != input::IsRun) {
592  if (cachedRP_) {
593  state_ = input::IsRun; // Regurgitate existing cached run.
594  } else {
596  << "Input file '" << currentFileName_ << "' has a"
597  << (state_ == input::IsSubRun ? " SubRun" : "n Event")
598  << " where a Run is expected\n";
599  }
600  }
601  } else {
603  }
604  }
void checkForNextFile_()
Definition: Source.h:502
bool readNext_()
Definition: Source.h:455
input::ItemType state_
Definition: Source.h:274
cet::exempt_ptr< RunPrincipal > cachedRP_
Definition: Source.h:284
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string currentFileName_
Definition: Source.h:276
template<typename T >
std::unique_ptr< RunPrincipal > art::Source< T >::readRun ( )
overrideprivatevirtual

Implements art::InputSource.

Definition at line 661 of file Source.h.

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

662  {
663  if (!newRP_)
665  << "Error in Source<T>\n"
666  << "readRun() called when no RunPrincipal exists\n"
667  << "Please report this to the art developers\n";
668  cachedRP_ = newRP_.get();
669  return std::move(newRP_);
670  }
cet::exempt_ptr< RunPrincipal > cachedRP_
Definition: Source.h:284
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::unique_ptr< RunPrincipal > newRP_
Definition: Source.h:278
template<typename T >
std::unique_ptr< SubRunPrincipal > art::Source< T >::readSubRun ( cet::exempt_ptr< RunPrincipal const >  rp)
overrideprivatevirtual

Implements art::InputSource.

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

675  {
676  if (!newSRP_)
678  << "Error in Source<T>\n"
679  << "readSubRun() called when no SubRunPrincipal exists\n"
680  << "Please report this to the art developers\n";
681  if (subRunIsNew_) {
682  if (haveSRLimit_) {
684  }
685  subRunIsNew_ = false;
686  }
687  cachedSRP_ = newSRP_.get();
688  return std::move(newSRP_);
689  }
bool subRunIsNew_
Definition: Source.h:289
cet::exempt_ptr< SubRunPrincipal > cachedSRP_
Definition: Source.h:285
std::unique_ptr< SubRunPrincipal > newSRP_
Definition: Source.h:279
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
SubRunNumber_t remainingSubRuns_
Definition: Source.h:290
bool haveSRLimit_
Definition: Source.h:291
template<typename T >
std::unique_ptr< RangeSetHandler > art::Source< T >::runRangeSetHandler ( )
overrideprivatevirtual

Implements art::InputSource.

Definition at line 623 of file Source.h.

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

624  {
625  return std::make_unique<OpenRangeSetHandler>(cachedRP_->run());
626  }
cet::exempt_ptr< RunPrincipal > cachedRP_
Definition: Source.h:284
void art::InputSource::skipEvents ( int  n)
virtualinherited

Reimplemented in art::EmptyEvent.

Definition at line 43 of file InputSource.cc.

References art::errors::Configuration.

44  {
46  << "The application has tried to peform random access on an input "
47  "source\n"
48  << "that does not support random access. Please reconfigure the program\n"
49  << "to use an input source that supports random access (e.g. "
50  "RootInput)\n";
51  }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
template<typename T >
std::unique_ptr< RangeSetHandler > art::Source< T >::subRunRangeSetHandler ( )
overrideprivatevirtual

Implements art::InputSource.

Definition at line 630 of file Source.h.

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

631  {
632  return std::make_unique<OpenRangeSetHandler>(cachedSRP_->run());
633  }
cet::exempt_ptr< SubRunPrincipal > cachedSRP_
Definition: Source.h:285
template<typename T >
void art::Source< T >::throwDataCorruption_ ( const char *  msg)
staticprivate

Definition at line 346 of file Source.h.

References art::errors::DataCorruption.

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

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

Definition at line 353 of file Source.h.

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

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

357  {
358  std::ostringstream errMsg;
359  if (result) {
360  if (!newR && !newSR && !newE) {
362  << "readNext returned true but created no new data\n";
363  }
364  if (!cachedRP_ && !newR) {
366  << "readNext returned true but no RunPrincipal has been set, and no "
367  "cached RunPrincipal exists.\n"
368  "This can happen if a new input file has been opened and the "
369  "RunPrincipal has not been appropriately assigned.";
370  }
371  if (!cachedSRP_ && !newSR) {
373  << "readNext returned true but no SubRunPrincipal has been set, and "
374  "no cached SubRunPrincipal exists.\n"
375  "This can happen if a new input file has been opened and the "
376  "SubRunPrincipal has not been appropriately assigned.";
377  }
378  if (cachedRP_ && newR && cachedRP_.get() == newR) {
379  errMsg << "readNext returned a new Run which is the old Run for "
380  << cachedRP_->runID()
381  << ".\nIf you don't have a new run, don't return one!\n";
382  }
383  if (cachedSRP_ && newSR && cachedSRP_.get() == newSR) {
384  errMsg << "readNext returned a new SubRun which is the old SubRun for "
385  << cachedSRP_->subRunID()
386  << ".\nIf you don't have a new subRun, don't return one!\n";
387  }
388  // Either or both of the above cases could be true and we need
389  // to make both of them safe before we throw:
390  if (!errMsg.str().empty())
391  throw Exception(errors::LogicError) << errMsg.str();
392  if (cachedRP_ && cachedSRP_) {
393  if (!newR && newSR && newSR->subRunID() == cachedSRP_->subRunID())
394  throwDataCorruption_("readNext returned a 'new' SubRun "
395  "that was the same as the previous "
396  "SubRun\n");
397  if (newR && newR->runID() == cachedRP_->runID())
398  throwDataCorruption_("readNext returned a 'new' Run "
399  "that was the same as the previous "
400  "Run\n");
401  if (newR && !newSR && newE)
402  throwDataCorruption_("readNext returned a new Run and "
403  "Event without a SubRun\n");
404  if (newR && newSR && newSR->subRunID() == cachedSRP_->subRunID())
405  throwDataCorruption_("readNext returned a new Run with "
406  "a SubRun from the wrong Run\n");
407  }
408  RunID rID;
409  SubRunID srID;
410  EventID eID;
411  if (newR) {
412  rID = newR->runID();
413  if (!rID.isValid()) {
415  "readNext returned a Run with an invalid RunID.\n");
416  }
417  } else if (cachedRP_) {
418  rID = cachedRP_->runID();
419  }
420  if (newSR) {
421  srID = newSR->subRunID();
422  if (rID != srID.runID()) {
423  errMsg << "readNext returned a SubRun " << srID
424  << " which is a mismatch to " << rID << '\n';
425  throwDataCorruption_(errMsg.str().c_str());
426  }
427  if (!srID.isValid()) {
429  "readNext returned a SubRun with an invalid SubRunID.\n");
430  }
431  } else if (cachedSRP_) {
432  srID = cachedSRP_->subRunID();
433  }
434  if (newE) {
435  eID = newE->eventID();
436  if (srID != eID.subRunID()) {
437  errMsg << "readNext returned an Event " << eID
438  << " which is a mismatch to " << srID << '\n';
439  throwDataCorruption_(errMsg.str().c_str());
440  }
441  if (!eID.isValid()) {
443  "readNext returned an Event with an invalid EventID.\n");
444  }
445  }
446  } else {
447  if (newR || newSR || newE)
449  << "readNext returned false but created new data\n";
450  }
451  }
static void throwDataCorruption_(const char *msg)
Definition: Source.h:346
cet::exempt_ptr< SubRunPrincipal > cachedSRP_
Definition: Source.h:285
cet::exempt_ptr< RunPrincipal > cachedRP_
Definition: Source.h:284
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66

Member Data Documentation

template<typename T >
bool art::Source< T >::haveEventLimit_ {false}
private

Definition at line 293 of file Source.h.

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

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

Definition at line 291 of file Source.h.

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

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

Definition at line 278 of file Source.h.

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

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

Definition at line 279 of file Source.h.

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

template<typename T >
UpdateOutputCallbacks& art::Source< T >::outputCallbacks_
private
template<typename T >
bool art::Source< T >::pendingEvent_ {false}
private

Definition at line 288 of file Source.h.

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

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

Definition at line 287 of file Source.h.

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

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

Definition at line 269 of file Source.h.

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

template<typename T >
EventNumber_t art::Source< T >::remainingEvents_ {1}
private
template<typename T >
SubRunNumber_t art::Source< T >::remainingSubRuns_ {1}
private
template<typename T >
SourceHelper art::Source< T >::sourceHelper_
private

Definition at line 272 of file Source.h.

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

template<typename T >
bool art::Source< T >::subRunIsNew_ {false}
private

Definition at line 289 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: