Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
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 const &runAux) const
 
RunPrincipalmakeRunPrincipal (RunID r, Timestamp const &startTime) const
 
RunPrincipalmakeRunPrincipal (RunNumber_t r, Timestamp const &startTime) const
 
SubRunPrincipalmakeSubRunPrincipal (SubRunAuxiliary const &subRunAux) const
 
SubRunPrincipalmakeSubRunPrincipal (SubRunID const &sr, Timestamp const &startTime) const
 
SubRunPrincipalmakeSubRunPrincipal (RunNumber_t r, SubRunNumber_t sr, Timestamp const &startTime) const
 
EventPrincipalmakeEventPrincipal (EventAuxiliary const &eventAux, std::unique_ptr< History > &&history) 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

void throwIfProductsNotRegistered_ () const
 
ProcessHistoryID processHistoryID_ (BranchType, ProcessConfiguration const &) const
 
std::unique_ptr< Historyhistory_ (ProcessConfiguration const &, std::unique_ptr< History > &&) 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 31 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:95
art::SourceHelper::SourceHelper ( SourceHelper const &  )
delete
art::SourceHelper::SourceHelper ( SourceHelper &&  )
delete

Member Function Documentation

std::unique_ptr< art::History > art::SourceHelper::history_ ( ProcessConfiguration const &  pc,
std::unique_ptr< History > &&  history 
) const
private

Definition at line 51 of file SourceHelper.cc.

53 {
54  // If no event products are present, we do not register the process
55  // history, and we return the already-provided history.
56  if (presentProducts_->descriptions(InEvent).empty()) {
57  return std::move(history);
58  }
59 
60  // To append to the processing history, we must first retrieve the
61  // ProcessHistory object corresponding to history's process history
62  // ID, if the ID is valid.
63  art::ProcessHistory processHistory;
64  auto const phid = history->processHistoryID();
65  if (phid.isValid()) {
66  bool const success = ProcessHistoryRegistry::get(phid, processHistory);
67  if (!success) {
68  throw Exception{
70  "Error while attempting to create event principal from SourceHelper.\n"}
71  << "There is no processing history corresponding to the valid id: "
72  << phid << '\n'
73  << "Please contact artists@fnal.gov for guidance.";
74  }
75  }
76 
77  processHistory.push_back(pc);
78  auto const new_phid = processHistory.id();
79  art::ProcessHistoryRegistry::emplace(new_phid, processHistory);
80  history->setProcessHistoryID(new_phid);
81  return std::move(history);
82 }
cet::exempt_ptr< ProductTables const > presentProducts_
Definition: SourceHelper.h:94
ProcessHistoryID id() const
static collection_type const & get()
def move(depos, offset)
Definition: depos.py:107
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void push_back(const_reference t)
static auto emplace(value_type const &value)
art::EventPrincipal * art::SourceHelper::makeEventPrincipal ( EventAuxiliary const &  eventAux,
std::unique_ptr< History > &&  history 
) const

Definition at line 151 of file SourceHelper.cc.

153 {
154  if (history.get() == nullptr) {
155  throw Exception{
157  "Error while attempting to create principal from SourceHelper.\n"}
158  << "The provided 'unique_ptr<History>' object is null, which is not "
159  "allowed\n"
160  "for this makeEventPrincipal function overload. Please choose a "
161  "different\n"
162  "function to use, or provided a non-null History unique pointer. "
163  "Contact\n"
164  "artists@fnal.gov for further guidance.";
165  }
167  auto new_history = history_(md_.processConfiguration(), std::move(history));
168  auto const processHistoryID = new_history->processHistoryID();
169  auto principal = new EventPrincipal{eventAux,
171  &presentProducts_->get(InEvent),
172  std::move(new_history)};
173  if (processHistoryID.isValid()) {
174  principal->markProcessHistoryAsModified();
175  }
176  return principal;
177 }
std::unique_ptr< History > history_(ProcessConfiguration const &, std::unique_ptr< History > &&) const
Definition: SourceHelper.cc:51
cet::exempt_ptr< ProductTables const > presentProducts_
Definition: SourceHelper.h:94
def move(depos, offset)
Definition: depos.py:107
ProcessConfiguration const & processConfiguration() const
void throwIfProductsNotRegistered_() const
Definition: SourceHelper.cc:18
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
ModuleDescription md_
Definition: SourceHelper.h:95
art::EventPrincipal * art::SourceHelper::makeEventPrincipal ( EventID const &  e,
Timestamp const &  startTime,
bool  isRealData = true,
EventAuxiliary::ExperimentType  eType = EventAuxiliary::Data 
) const

Definition at line 180 of file SourceHelper.cc.

185 {
186  EventAuxiliary const eventAux{e, startTime, isRealData, eType};
187  return makeEventPrincipal(eventAux, std::make_unique<History>());
188 }
const double e
EventPrincipal * makeEventPrincipal(EventAuxiliary const &eventAux, std::unique_ptr< History > &&history) const
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 191 of file SourceHelper.cc.

198 {
199  return makeEventPrincipal(EventID{r, sr, e}, startTime, isRealData, eType);
200 }
const double e
EventPrincipal * makeEventPrincipal(EventAuxiliary const &eventAux, std::unique_ptr< History > &&history) const
static constexpr double sr
Definition: Units.h:166
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 100 of file SourceHelper.h.

103 {
104  BranchDescription const pd{p.branchType(),
105  tl,
106  md_.moduleLabel(),
109  ProductID const pid{pd.productID()};
110  return Ptr<T>{pid, key, p.productGetter(pid)};
111 }
std::string const & moduleLabel() const
def key(type, name=None)
Definition: graph.py:13
p
Definition: test.py:223
ProcessConfiguration const & processConfiguration() const
fhicl::ParameterSetID const & parameterSetID() const
ModuleDescription md_
Definition: SourceHelper.h:95
art::RunPrincipal * art::SourceHelper::makeRunPrincipal ( RunAuxiliary const &  runAux) const

Definition at line 92 of file SourceHelper.cc.

93 {
95  runAux.processHistoryID() =
97  auto principal = new RunPrincipal{
99  if (runAux.processHistoryID().isValid()) {
100  principal->markProcessHistoryAsModified();
101  }
102  return principal;
103 }
cet::exempt_ptr< ProductTables const > presentProducts_
Definition: SourceHelper.h:94
ProcessConfiguration const & processConfiguration() const
void throwIfProductsNotRegistered_() const
Definition: SourceHelper.cc:18
ModuleDescription md_
Definition: SourceHelper.h:95
ProcessHistoryID processHistoryID_(BranchType, ProcessConfiguration const &) const
Definition: SourceHelper.cc:34
art::RunPrincipal * art::SourceHelper::makeRunPrincipal ( RunID  r,
Timestamp const &  startTime 
) const

Definition at line 106 of file SourceHelper.cc.

108 {
109  RunAuxiliary const runAux{r, startTime, Timestamp::invalidTimestamp()};
110  return makeRunPrincipal(runAux);
111 }
RunPrincipal * makeRunPrincipal(RunAuxiliary const &runAux) const
Definition: SourceHelper.cc:92
static constexpr Timestamp invalidTimestamp()
Definition: Timestamp.h:82
art::RunPrincipal * art::SourceHelper::makeRunPrincipal ( RunNumber_t  r,
Timestamp const &  startTime 
) const

Definition at line 114 of file SourceHelper.cc.

116 {
117  return makeRunPrincipal(RunID{r}, startTime);
118 }
RunPrincipal * makeRunPrincipal(RunAuxiliary const &runAux) const
Definition: SourceHelper.cc:92
art::SubRunPrincipal * art::SourceHelper::makeSubRunPrincipal ( SubRunAuxiliary const &  subRunAux) const

Definition at line 121 of file SourceHelper.cc.

122 {
125  subRunAux.setProcessHistoryID(phid);
126  auto principal = new SubRunPrincipal{
127  subRunAux, md_.processConfiguration(), &presentProducts_->get(InSubRun)};
128  if (subRunAux.processHistoryID().isValid()) {
129  principal->markProcessHistoryAsModified();
130  }
131  return principal;
132 }
cet::exempt_ptr< ProductTables const > presentProducts_
Definition: SourceHelper.h:94
ProcessConfiguration const & processConfiguration() const
void throwIfProductsNotRegistered_() const
Definition: SourceHelper.cc:18
ModuleDescription md_
Definition: SourceHelper.h:95
ProcessHistoryID processHistoryID_(BranchType, ProcessConfiguration const &) const
Definition: SourceHelper.cc:34
art::SubRunPrincipal * art::SourceHelper::makeSubRunPrincipal ( SubRunID const &  sr,
Timestamp const &  startTime 
) const

Definition at line 135 of file SourceHelper.cc.

137 {
138  SubRunAuxiliary const subRunAux{sr, startTime, Timestamp::invalidTimestamp()};
139  return makeSubRunPrincipal(subRunAux);
140 }
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary const &subRunAux) const
static constexpr Timestamp invalidTimestamp()
Definition: Timestamp.h:82
static constexpr double sr
Definition: Units.h:166
art::SubRunPrincipal * art::SourceHelper::makeSubRunPrincipal ( RunNumber_t  r,
SubRunNumber_t  sr,
Timestamp const &  startTime 
) const

Definition at line 143 of file SourceHelper.cc.

146 {
147  return makeSubRunPrincipal(SubRunID{r, sr}, startTime);
148 }
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary const &subRunAux) const
static constexpr double sr
Definition: Units.h:166
SourceHelper& art::SourceHelper::operator= ( SourceHelper const &  )
delete
SourceHelper& art::SourceHelper::operator= ( SourceHelper &&  )
delete
art::ProcessHistoryID art::SourceHelper::processHistoryID_ ( BranchType  bt,
ProcessConfiguration const &  pc 
) const
private

Definition at line 34 of file SourceHelper.cc.

36 {
37  art::ProcessHistory processHistory{};
38  // If no products are present for this branch type, we do not
39  // register the process history.
40  if (presentProducts_->descriptions(bt).empty()) {
41  return processHistory.id();
42  }
43 
44  processHistory.push_back(pc);
45  auto const phid = processHistory.id();
46  art::ProcessHistoryRegistry::emplace(phid, processHistory);
47  return phid;
48 }
cet::exempt_ptr< ProductTables const > presentProducts_
Definition: SourceHelper.h:94
ProcessHistoryID id() const
bt
Definition: tracks.py:83
static auto emplace(value_type const &value)
void art::SourceHelper::setPresentProducts ( cet::exempt_ptr< ProductTables const >  presentProducts)
private

Definition at line 85 of file SourceHelper.cc.

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

Definition at line 18 of file SourceHelper.cc.

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:94
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66

Friends And Related Function Documentation

template<typename T >
friend class Source
friend

Definition at line 87 of file SourceHelper.h.

Member Data Documentation

ModuleDescription art::SourceHelper::md_
private

Definition at line 95 of file SourceHelper.h.

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

Definition at line 94 of file SourceHelper.h.


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