Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
art::Source< T > Class Template Reference

#include "/cvmfs/nova.opensciencegrid.org/externals/art/v3_05_01/source/art/Framework/IO/Sources/Source.h"

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

Public Types

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

Public Member Functions

 Source (fhicl::ParameterSet 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
 
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
 
virtual void doBeginJob ()
 
virtual void doEndJob ()
 
virtual void skipEvents (int n)
 
virtual void rewind ()
 
ModuleDescription const & moduleDescription () const
 
ProcessConfiguration const & processConfiguration () const
 

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

ProductRegistryHelper h_ {}
 
UpdateOutputCallbacksoutputCallbacks_
 
ProductTables presentProducts_ {ProductTables::invalid()}
 
SourceHelper sourceHelper_
 
SourceDetail 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<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 159 of file Source.h.

Member Enumeration Documentation

Enumerator
Runs 
RunsAndSubRuns 
RunsSubRunsAndEvents 

Definition at line 67 of file InputSource.h.

Constructor & Destructor Documentation

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

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

272  : InputSource{d.moduleDescription}
273  , outputCallbacks_{d.productRegistry}
274  , sourceHelper_{d.moduleDescription}
276  , fh_{p.get<std::vector<std::string>>("fileNames",
277  std::vector<std::string>())}
278  {
279  // Handle maxSubRuns parameter.
280  int64_t maxSubRuns_par = p.get<int64_t>("maxSubRuns", -1);
281  if (maxSubRuns_par > -1) {
282  remainingSubRuns_ = maxSubRuns_par;
283  haveSRLimit_ = true;
284  }
285  // Handle maxEvents parameter.
286  int64_t maxEvents_par = p.get<int64_t>("maxEvents", -1);
287  if (maxEvents_par > -1) {
288  remainingEvents_ = maxEvents_par;
289  haveEventLimit_ = true;
290  }
291  // Finish product registration.
293  }
InputSource(ModuleDescription const &)
const char * p
Definition: xmltok.h:285
EventNumber_t remainingEvents_
Definition: Source.h:265
SourceDetail detail_
Definition: Source.h:234
SourceHelper sourceHelper_
Definition: Source.h:232
Float_t d
Definition: plot.C:236
void finishProductRegistration_(InputSourceDescription &d)
Definition: Source.h:662
ProductRegistryHelper h_
Definition: Source.h:225
detail::FileNamesHandler< Source_wantFileServices< T >::value > fh_
Definition: Source.h:238
bool haveEventLimit_
Definition: Source.h:267
SubRunNumber_t remainingSubRuns_
Definition: Source.h:261
UpdateOutputCallbacks & outputCallbacks_
Definition: Source.h:227
bool haveSRLimit_
Definition: Source.h:263
template<class T >
art::Source< T >::Source ( Source< T > const &  )
delete
template<class T >
art::Source< T >::Source ( Source< T > &&  )
delete

Member Function Documentation

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

Definition at line 461 of file Source.h.

References art::Source< T >::currentFileName_, art::Source< T >::detail_, art::Source< T >::fh_, art::input::IsFile, art::input::IsStop, and art::Source< T >::state_.

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

462  {
463  state_ = input::IsStop; // Default -- may change below.
466  detail::do_call_hasMoreData<T>,
467  detail::do_not_call_hasMoreData<T>>
468  generatorHasMoreData;
469  if (generatorHasMoreData(detail_)) {
471  }
472  } else {
473  currentFileName_ = fh_.next();
474  if (!currentFileName_.empty()) {
476  }
477  }
478  }
input::ItemType state_
Definition: Source.h:236
const XML_Char int const XML_Char * value
Definition: expat.h:331
static constexpr bool value
Definition: SourceTraits.h:58
SourceDetail detail_
Definition: Source.h:234
detail::FileNamesHandler< Source_wantFileServices< T >::value > fh_
Definition: Source.h:238
std::string currentFileName_
Definition: Source.h:240
template<class T >
void art::Source< T >::closeFile ( )
overridevirtual

Implements art::InputSource.

Definition at line 609 of file Source.h.

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

610  {
611  detail_.closeCurrentFile();
612  // Cached pointers are no longer valid since the PrincipalCache is
613  // cleared after file close.
614  cachedRP_ = nullptr;
615  cachedSRP_ = nullptr;
616  }
cet::exempt_ptr< SubRunPrincipal > cachedSRP_
Definition: Source.h:253
SourceDetail detail_
Definition: Source.h:234
cet::exempt_ptr< RunPrincipal > cachedRP_
Definition: Source.h:251
virtual void art::InputSource::doBeginJob ( )
virtualinherited
virtual void art::InputSource::doEndJob ( )
virtualinherited
template<class T >
void art::Source< T >::finishProductRegistration_ ( InputSourceDescription d)
private

Definition at line 662 of file Source.h.

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

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

663  {
664  // These _xERROR_ strings should never appear in branch names; they
665  // are here as tracers to help identify any failures in coding.
666  ProductDescriptions descriptions;
668  descriptions,
669  ModuleDescription{fhicl::ParameterSet{}.id(), // Dummy
670  "_NAMEERROR_",
671  "_LABELERROR_",
673  d.moduleDescription.processConfiguration(),
674  true /*isEmulated*/});
675  presentProducts_ = ProductTables{descriptions};
678  }
void setPresentProducts(cet::exempt_ptr< ProductTables const > presentProducts)
std::vector< BranchDescription > ProductDescriptions
ParameterSetID id() const
void registerProducts(ProductDescriptions &productsToRegister, ModuleDescription const &md)
exempt_ptr< E > make_exempt_ptr(E *) noexcept
SourceHelper sourceHelper_
Definition: Source.h:232
ProductTables presentProducts_
Definition: Source.h:229
Float_t d
Definition: plot.C:236
void invoke(ProductTables const &)
ProductRegistryHelper h_
Definition: Source.h:225
UpdateOutputCallbacks & outputCallbacks_
Definition: Source.h:227
ModuleDescription const& art::InputSource::moduleDescription ( ) const
inherited
template<class T >
input::ItemType art::Source< T >::nextItemType ( )
overridevirtual

Implements art::InputSource.

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

483  {
484  if (remainingEvents_ == 0) {
486  }
487  switch (state_) {
488  case input::IsInvalid:
490  state_ = input::IsFile; // Once.
491  } else {
493  }
494  break;
495  case input::IsFile:
497  break;
498  case input::IsRun:
501  pendingSubRun_ = false;
502  } else if (pendingEvent_)
504  << "Input file '" << currentFileName_ << "' contains an Event "
505  << newE_->eventID() << " that belongs to no SubRun\n";
506  else {
508  }
509  break;
510  case input::IsSubRun:
511  if (pendingEvent_) {
513  pendingEvent_ = false;
514  } else {
516  }
517  break;
518  case input::IsEvent:
519  if (!readNext_()) {
521  }
522  break;
523  case input::IsStop:
524  break;
525  }
526  if ((state_ == input::IsRun || state_ == input::IsSubRun) &&
527  remainingSubRuns_ == 0) {
529  }
530  if (state_ == input::IsStop) {
531  // FIXME: upon the advent of a catalog system which can do something
532  // intelligent with the difference between whole-file success,
533  // partial-file success, partial-file failure and whole-file failure
534  // (such as file-open failure), we will need to communicate that
535  // difference here. The file disposition options as they are now
536  // (and the mapping to any concrete implementation we are are aware
537  // of currently) are not sufficient to the task, so we deliberately
538  // do not distinguish here between partial-file and whole-file
539  // success in particular.
540  fh_.finish();
541  }
542  return state_;
543  }
void checkForNextFile_()
Definition: Source.h:461
bool readNext_()
Definition: Source.h:414
bool pendingSubRun_
Definition: Source.h:255
EventNumber_t remainingEvents_
Definition: Source.h:265
void readNextAndRequireRun_()
Definition: Source.h:547
input::ItemType state_
Definition: Source.h:236
cet::exempt_ptr< SubRunPrincipal > cachedSRP_
Definition: Source.h:253
bool pendingEvent_
Definition: Source.h:257
static constexpr bool value
Definition: SourceTraits.h:58
std::unique_ptr< EventPrincipal > newE_
Definition: Source.h:246
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
detail::FileNamesHandler< Source_wantFileServices< T >::value > fh_
Definition: Source.h:238
SubRunNumber_t remainingSubRuns_
Definition: Source.h:261
void readNextAndRefuseEvent_()
Definition: Source.h:567
std::string currentFileName_
Definition: Source.h:240
template<class T >
Source<T>& art::Source< T >::operator= ( Source< T > const &  )
delete
template<class T >
Source<T>& art::Source< T >::operator= ( Source< T > &&  )
delete
ProcessConfiguration const& art::InputSource::processConfiguration ( ) const
inherited
template<class T >
std::unique_ptr< EventPrincipal > art::Source< T >::readEvent ( cet::exempt_ptr< SubRunPrincipal const >  srp)
overridevirtual

Implements art::InputSource.

Definition at line 652 of file Source.h.

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

653  {
654  if (haveEventLimit_) {
656  }
657  return std::move(newE_);
658  }
EventNumber_t remainingEvents_
Definition: Source.h:265
std::unique_ptr< EventPrincipal > newE_
Definition: Source.h:246
bool haveEventLimit_
Definition: Source.h:267
template<class T >
std::unique_ptr< FileBlock > art::Source< T >::readFile ( )
overridevirtual

Implements art::InputSource.

Definition at line 596 of file Source.h.

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

597  {
598  FileBlock* newF{nullptr};
599  detail_.readFile(currentFileName_, newF);
600  if (!newF) {
602  << "detail_::readFile() failed to return a valid FileBlock object\n";
603  }
604  return std::unique_ptr<FileBlock>(newF);
605  }
SourceDetail detail_
Definition: Source.h:234
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string currentFileName_
Definition: Source.h:240
template<class T >
bool art::Source< T >::readNext_ ( )
private

Definition at line 414 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, nE, art::Source< T >::newE_, art::Source< T >::newRP_, art::Source< T >::newSRP_, art::Source< T >::pendingEvent_, art::Source< T >::pendingSubRun_, fillBadChanDBTables::result, 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_().

415  {
416  std::unique_ptr<RunPrincipal> newR{nullptr};
417  std::unique_ptr<SubRunPrincipal> newSR{nullptr};
418  std::unique_ptr<EventPrincipal> newE{nullptr};
419  bool result{false};
420  {
421  RunPrincipal* nR{nullptr};
422  SubRunPrincipal* nSR{nullptr};
423  EventPrincipal* nE{nullptr};
424  result = detail_.readNext(cachedRP_.get(), cachedSRP_.get(), nR, nSR, nE);
425  newR.reset(nR);
426  newSR.reset(nSR);
427  newE.reset(nE);
428  throwIfInsane_(result, newR.get(), newSR.get(), newE.get());
429  }
430  if (result) {
431  subRunIsNew_ =
432  newSR && ((!cachedSRP_) || newSR->subRunID() != cachedSRP_->subRunID());
433  pendingSubRun_ = newSR.get() != nullptr;
434  pendingEvent_ = newE.get() != nullptr;
435  if (newR) {
436  newRP_ = std::move(newR);
437  }
438  if (newSR) {
439  auto rp = newRP_ ? newRP_.get() : cachedRP_.get();
440  newSR->setRunPrincipal(rp);
441  newSRP_ = std::move(newSR);
442  }
443  if (newE) {
444  auto srp = newSRP_ ? newSRP_.get() : cachedSRP_.get();
445  newE->setSubRunPrincipal(srp);
446  newE_ = std::move(newE);
447  }
448  if (newRP_) {
450  } else if (newSRP_) {
452  } else if (newE_) {
454  }
455  }
456  return result;
457  }
bool pendingSubRun_
Definition: Source.h:255
bool subRunIsNew_
Definition: Source.h:259
input::ItemType state_
Definition: Source.h:236
cet::exempt_ptr< SubRunPrincipal > cachedSRP_
Definition: Source.h:253
bool pendingEvent_
Definition: Source.h:257
SourceDetail detail_
Definition: Source.h:234
std::unique_ptr< SubRunPrincipal > newSRP_
Definition: Source.h:244
cet::exempt_ptr< RunPrincipal > cachedRP_
Definition: Source.h:251
std::unique_ptr< EventPrincipal > newE_
Definition: Source.h:246
void throwIfInsane_(bool result, RunPrincipal *newR, SubRunPrincipal *newSR, EventPrincipal *newE) const
Definition: Source.h:304
std::unique_ptr< RunPrincipal > newRP_
Definition: Source.h:242
int nE
template<class T >
void art::Source< T >::readNextAndRefuseEvent_ ( )
private

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

568  {
569  if (readNext_()) {
570  if (state_ == input::IsEvent) {
572  << "Input file '" << currentFileName_
573  << "' has an Event where a Run or SubRun is expected\n";
574  }
575  } else {
577  }
578  }
void checkForNextFile_()
Definition: Source.h:461
bool readNext_()
Definition: Source.h:414
input::ItemType state_
Definition: Source.h:236
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string currentFileName_
Definition: Source.h:240
template<class T >
void art::Source< T >::readNextAndRequireRun_ ( )
private

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

548  {
549  if (readNext_()) {
550  if (state_ != input::IsRun) {
551  if (cachedRP_) {
552  state_ = input::IsRun; // Regurgitate existing cached run.
553  } else {
555  << "Input file '" << currentFileName_ << "' has a"
556  << (state_ == input::IsSubRun ? " SubRun" : "n Event")
557  << " where a Run is expected\n";
558  }
559  }
560  } else {
562  }
563  }
void checkForNextFile_()
Definition: Source.h:461
bool readNext_()
Definition: Source.h:414
input::ItemType state_
Definition: Source.h:236
cet::exempt_ptr< RunPrincipal > cachedRP_
Definition: Source.h:251
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::string currentFileName_
Definition: Source.h:240
template<class T >
std::unique_ptr< RunPrincipal > art::Source< T >::readRun ( )
overridevirtual

Implements art::InputSource.

Definition at line 620 of file Source.h.

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

621  {
622  if (!newRP_)
624  << "Error in Source<T>\n"
625  << "readRun() called when no RunPrincipal exists\n"
626  << "Please report this to the art developers\n";
627  cachedRP_ = newRP_.get();
628  return std::move(newRP_);
629  }
cet::exempt_ptr< RunPrincipal > cachedRP_
Definition: Source.h:251
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::unique_ptr< RunPrincipal > newRP_
Definition: Source.h:242
template<class T >
std::unique_ptr< SubRunPrincipal > art::Source< T >::readSubRun ( cet::exempt_ptr< RunPrincipal const >  rp)
overridevirtual

Implements art::InputSource.

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

634  {
635  if (!newSRP_)
637  << "Error in Source<T>\n"
638  << "readSubRun() called when no SubRunPrincipal exists\n"
639  << "Please report this to the art developers\n";
640  if (subRunIsNew_) {
641  if (haveSRLimit_) {
643  }
644  subRunIsNew_ = false;
645  }
646  cachedSRP_ = newSRP_.get();
647  return std::move(newSRP_);
648  }
bool subRunIsNew_
Definition: Source.h:259
cet::exempt_ptr< SubRunPrincipal > cachedSRP_
Definition: Source.h:253
std::unique_ptr< SubRunPrincipal > newSRP_
Definition: Source.h:244
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
SubRunNumber_t remainingSubRuns_
Definition: Source.h:261
bool haveSRLimit_
Definition: Source.h:263
virtual void art::InputSource::rewind ( )
virtualinherited
template<class T >
std::unique_ptr< RangeSetHandler > art::Source< T >::runRangeSetHandler ( )
overridevirtual

Implements art::InputSource.

Definition at line 582 of file Source.h.

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

583  {
584  return std::make_unique<OpenRangeSetHandler>(cachedRP_->run());
585  }
cet::exempt_ptr< RunPrincipal > cachedRP_
Definition: Source.h:251
virtual void art::InputSource::skipEvents ( int  n)
virtualinherited
template<class T >
std::unique_ptr< RangeSetHandler > art::Source< T >::subRunRangeSetHandler ( )
overridevirtual

Implements art::InputSource.

Definition at line 589 of file Source.h.

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

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

Definition at line 297 of file Source.h.

References art::errors::DataCorruption, and lem_server::msg.

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

298  {
300  }
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 304 of file Source.h.

References art::Source< T >::cachedRP_, art::Source< T >::cachedSRP_, novadaq::messages::error::rc::errMsg, art::Principal::eventID(), art::SubRunID::isValid(), art::RunID::isValid(), art::EventID::isValid(), art::errors::LogicError, art::SubRunID::runID(), art::Principal::runID(), art::Principal::runPrincipalExemptPtr(), art::EventID::subRunID(), art::Principal::subRunID(), art::Principal::subRunPrincipalPtr(), and art::Source< T >::throwDataCorruption_().

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

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

Member Data Documentation

template<class T >
cet::exempt_ptr<RunPrincipal> art::Source< T >::cachedRP_ {nullptr}
private
template<class T >
cet::exempt_ptr<SubRunPrincipal> art::Source< T >::cachedSRP_ {nullptr}
private
template<class T >
std::string art::Source< T >::currentFileName_ {}
private
template<class T >
SourceDetail art::Source< T >::detail_
private
template<class T >
detail::FileNamesHandler<Source_wantFileServices<T>::value> art::Source< T >::fh_
private
template<class T >
ProductRegistryHelper art::Source< T >::h_ {}
private
template<class T >
bool art::Source< T >::haveEventLimit_ {false}
private

Definition at line 267 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 263 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_ {}
private
template<class T >
std::unique_ptr<RunPrincipal> art::Source< T >::newRP_ {}
private

Definition at line 242 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_ {}
private

Definition at line 244 of file Source.h.

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

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

Definition at line 257 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 255 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 229 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

Definition at line 232 of file Source.h.

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

template<class T >
input::ItemType art::Source< T >::state_ {input::IsInvalid}
private
template<class T >
bool art::Source< T >::subRunIsNew_ {false}
private

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