LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
art::SourceHelper Class Reference

#include "SourceHelper.h"

Public Member Functions

 SourceHelper (ModuleDescription const &md)
 
 SourceHelper (SourceHelper const &)=delete
 
 SourceHelper (SourceHelper &&)=delete
 
SourceHelperoperator= (SourceHelper const &)=delete
 
SourceHelperoperator= (SourceHelper &&)=delete
 
template<typename T >
Ptr< T > makePtr (TypeLabel const &t, Principal const &p, typename Ptr< T >::key_type key) const
 
RunPrincipalmakeRunPrincipal (RunAuxiliary runAux) const
 
RunPrincipalmakeRunPrincipal (RunID r, Timestamp const &startTime) const
 
RunPrincipalmakeRunPrincipal (RunNumber_t r, Timestamp const &startTime) const
 
SubRunPrincipalmakeSubRunPrincipal (SubRunAuxiliary subRunAux) const
 
SubRunPrincipalmakeSubRunPrincipal (SubRunID const &sr, Timestamp const &startTime) const
 
SubRunPrincipalmakeSubRunPrincipal (RunNumber_t r, SubRunNumber_t sr, Timestamp const &startTime) const
 
EventPrincipalmakeEventPrincipal (EventAuxiliary eventAux) const
 
EventPrincipalmakeEventPrincipal (EventID const &e, Timestamp const &startTime, bool isRealData=true, EventAuxiliary::ExperimentType eType=EventAuxiliary::Data) const
 
EventPrincipalmakeEventPrincipal (RunNumber_t r, SubRunNumber_t sr, EventNumber_t e, Timestamp const &startTime, bool isRealData=true, EventAuxiliary::ExperimentType eType=EventAuxiliary::Data) const
 
template<typename T >
art::Ptr< T > makePtr (TypeLabel const &tl, Principal const &p, typename Ptr< T >::key_type key) const
 

Private Member Functions

template<typename T >
T * makePrincipal_ (typename T::Auxiliary aux) const
 
void throwIfProductsNotRegistered_ () const
 
ProcessHistoryID updatedProcessHistoryID_ (ProcessHistoryID const &, BranchType, ProcessConfiguration const &) const
 
void setPresentProducts (cet::exempt_ptr< ProductTables const > presentProducts)
 

Private Attributes

cet::exempt_ptr< ProductTables const > presentProducts_ {nullptr}
 
ModuleDescription md_
 

Friends

template<typename T >
class Source
 

Detailed Description

Definition at line 30 of file SourceHelper.h.

Constructor & Destructor Documentation

art::SourceHelper::SourceHelper ( ModuleDescription const &  md)
explicit

Definition at line 15 of file SourceHelper.cc.

15 : md_{md} {}
ModuleDescription md_
Definition: SourceHelper.h:89
art::SourceHelper::SourceHelper ( SourceHelper const &  )
delete
art::SourceHelper::SourceHelper ( SourceHelper &&  )
delete

Member Function Documentation

art::EventPrincipal * art::SourceHelper::makeEventPrincipal ( EventAuxiliary  eventAux) const
art::EventPrincipal * art::SourceHelper::makeEventPrincipal ( EventID const &  e,
Timestamp const &  startTime,
bool  isRealData = true,
EventAuxiliary::ExperimentType  eType = EventAuxiliary::Data 
) const

Definition at line 138 of file SourceHelper.cc.

References e, and makeEventPrincipal().

143 {
144  return makeEventPrincipal(EventAuxiliary{e, startTime, isRealData, eType});
145 }
EventPrincipal * makeEventPrincipal(EventAuxiliary eventAux) const
Float_t e
Definition: plot.C:35
art::EventPrincipal * art::SourceHelper::makeEventPrincipal ( RunNumber_t  r,
SubRunNumber_t  sr,
EventNumber_t  e,
Timestamp const &  startTime,
bool  isRealData = true,
EventAuxiliary::ExperimentType  eType = EventAuxiliary::Data 
) const

Definition at line 148 of file SourceHelper.cc.

References makeEventPrincipal(), and r.

155 {
156  return makeEventPrincipal(EventID{r, sr, e}, startTime, isRealData, eType);
157 }
TRandom r
Definition: spectrum.C:23
EventPrincipal * makeEventPrincipal(EventAuxiliary eventAux) const
Float_t e
Definition: plot.C:35
template<typename T >
T * art::SourceHelper::makePrincipal_ ( typename T::Auxiliary  aux) const
private

Definition at line 74 of file SourceHelper.cc.

References md_, presentProducts_, art::ModuleDescription::processConfiguration(), throwIfProductsNotRegistered_(), and updatedProcessHistoryID_().

75 {
77  constexpr auto branch_type = T::branch_type;
78  aux.setProcessHistoryID(updatedProcessHistoryID_(
79  aux.processHistoryID(), branch_type, md_.processConfiguration()));
80  auto principal =
81  new T{aux, md_.processConfiguration(), &presentProducts_->get(branch_type)};
82  if (aux.processHistoryID().isValid()) {
83  principal->markProcessHistoryAsModified();
84  }
85  return principal;
86 }
cet::exempt_ptr< ProductTables const > presentProducts_
Definition: SourceHelper.h:88
ProcessHistoryID updatedProcessHistoryID_(ProcessHistoryID const &, BranchType, ProcessConfiguration const &) const
Definition: SourceHelper.cc:34
ProcessConfiguration const & processConfiguration() const
void throwIfProductsNotRegistered_() const
Definition: SourceHelper.cc:18
ModuleDescription md_
Definition: SourceHelper.h:89
template<typename T >
Ptr<T> art::SourceHelper::makePtr ( TypeLabel const &  t,
Principal const &  p,
typename Ptr< T >::key_type  key 
) const
template<typename T >
art::Ptr<T> art::SourceHelper::makePtr ( TypeLabel const &  tl,
Principal const &  p,
typename Ptr< T >::key_type  key 
) const

Definition at line 94 of file SourceHelper.h.

References art::Principal::branchType(), md_, art::ModuleDescription::moduleLabel(), art::ModuleDescription::parameterSetID(), art::ModuleDescription::processConfiguration(), and art::Principal::productGetter().

97 {
98  BranchDescription const pd{p.branchType(),
99  tl,
100  md_.moduleLabel(),
103  ProductID const pid{pd.productID()};
104  return Ptr<T>{pid, key, p.productGetter(pid)};
105 }
std::string const & moduleLabel() const
ProcessConfiguration const & processConfiguration() const
fhicl::ParameterSetID const & parameterSetID() const
ModuleDescription md_
Definition: SourceHelper.h:89
art::RunPrincipal * art::SourceHelper::makeRunPrincipal ( RunAuxiliary  runAux) const
art::RunPrincipal * art::SourceHelper::makeRunPrincipal ( RunID  r,
Timestamp const &  startTime 
) const

Definition at line 95 of file SourceHelper.cc.

References art::Timestamp::invalidTimestamp(), makeRunPrincipal(), and r.

97 {
98  return makeRunPrincipal(
99  RunAuxiliary{r, startTime, Timestamp::invalidTimestamp()});
100 }
TRandom r
Definition: spectrum.C:23
static constexpr Timestamp invalidTimestamp()
Definition: Timestamp.h:82
RunPrincipal * makeRunPrincipal(RunAuxiliary runAux) const
Definition: SourceHelper.cc:89
art::RunPrincipal * art::SourceHelper::makeRunPrincipal ( RunNumber_t  r,
Timestamp const &  startTime 
) const

Definition at line 103 of file SourceHelper.cc.

References makeRunPrincipal().

105 {
106  return makeRunPrincipal(RunID{r}, startTime);
107 }
TRandom r
Definition: spectrum.C:23
RunPrincipal * makeRunPrincipal(RunAuxiliary runAux) const
Definition: SourceHelper.cc:89
art::SubRunPrincipal * art::SourceHelper::makeSubRunPrincipal ( SubRunAuxiliary  subRunAux) const
art::SubRunPrincipal * art::SourceHelper::makeSubRunPrincipal ( SubRunID const &  sr,
Timestamp const &  startTime 
) const

Definition at line 116 of file SourceHelper.cc.

References art::Timestamp::invalidTimestamp(), and makeSubRunPrincipal().

118 {
119  return makeSubRunPrincipal(
120  SubRunAuxiliary{sr, startTime, Timestamp::invalidTimestamp()});
121 }
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary subRunAux) const
static constexpr Timestamp invalidTimestamp()
Definition: Timestamp.h:82
art::SubRunPrincipal * art::SourceHelper::makeSubRunPrincipal ( RunNumber_t  r,
SubRunNumber_t  sr,
Timestamp const &  startTime 
) const

Definition at line 124 of file SourceHelper.cc.

References makeSubRunPrincipal(), and r.

127 {
128  return makeSubRunPrincipal(SubRunID{r, sr}, startTime);
129 }
TRandom r
Definition: spectrum.C:23
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary subRunAux) const
SourceHelper& art::SourceHelper::operator= ( SourceHelper const &  )
delete
SourceHelper& art::SourceHelper::operator= ( SourceHelper &&  )
delete
void art::SourceHelper::setPresentProducts ( cet::exempt_ptr< ProductTables const >  presentProducts)
private

Definition at line 66 of file SourceHelper.cc.

References presentProducts_.

68 {
69  presentProducts_ = presentProducts;
70 }
cet::exempt_ptr< ProductTables const > presentProducts_
Definition: SourceHelper.h:88
void art::SourceHelper::throwIfProductsNotRegistered_ ( ) const
private

Definition at line 18 of file SourceHelper.cc.

References presentProducts_, and art::errors::ProductRegistrationFailure.

Referenced by makePrincipal_().

19 {
20  if (!presentProducts_) {
21  throw Exception(
23  "Error while attempting to create principal from SourceHelper.\n")
24  << "Principals cannot be created until product registration is "
25  "complete.\n"
26  "This can happen if you are attempting to create a Principal\n"
27  "outside of your 'readNext' function, or if you are using a\n"
28  "different SourceHelper object than the one provided by art.\n"
29  "Please contact artists@fnal.gov for guidance.";
30  }
31 }
cet::exempt_ptr< ProductTables const > presentProducts_
Definition: SourceHelper.h:88
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
art::ProcessHistoryID art::SourceHelper::updatedProcessHistoryID_ ( ProcessHistoryID const &  processHistoryID,
BranchType  bt,
ProcessConfiguration const &  pc 
) const
private

Definition at line 34 of file SourceHelper.cc.

References art::thread_safe_registry_via_id< K, M >::emplace(), art::thread_safe_registry_via_id< K, M >::get(), art::Hash< I >::isValid(), art::errors::LogicError, and presentProducts_.

Referenced by makePrincipal_().

38 {
39  // If no products are present for this branch type, we do not
40  // update the process history.
41  if (presentProducts_->descriptions(bt).empty()) {
42  return processHistoryID;
43  }
44 
45  art::ProcessHistory processHistory{};
46  if (processHistoryID.isValid()) {
47  bool const found =
48  ProcessHistoryRegistry::get(processHistoryID, processHistory);
49  if (!found) {
50  throw Exception(
52  "Error while attempting to create principal from SourceHelper.\n")
53  << "The provided process-history ID\n"
54  << " " << processHistory << '\n'
55  << "does not correspond to a known process history.\n"
56  "Please contact artists@fnal.gov for guidance.";
57  }
58  }
59  processHistory.push_back(pc);
60  auto const phid = processHistory.id();
61  art::ProcessHistoryRegistry::emplace(phid, processHistory);
62  return phid;
63 }
cet::exempt_ptr< ProductTables const > presentProducts_
Definition: SourceHelper.h:88
static collection_type const & get()
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
static auto emplace(value_type const &value)

Friends And Related Function Documentation

template<typename T >
friend class Source
friend

Definition at line 79 of file SourceHelper.h.

Member Data Documentation

ModuleDescription art::SourceHelper::md_
private

Definition at line 89 of file SourceHelper.h.

Referenced by makePrincipal_(), and makePtr().

cet::exempt_ptr<ProductTables const> art::SourceHelper::presentProducts_ {nullptr}
private

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