LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
SourceHelper.h
Go to the documentation of this file.
1 #ifndef art_Framework_IO_Sources_SourceHelper_h
2 #define art_Framework_IO_Sources_SourceHelper_h
3 
4 // -----------------------------------------------------------------
5 // SourceHelper provides the means for creation of EventPrincipals,
6 // SubRunPrincipals, and RunPrincipals.
7 //
8 // Note that processing history can only be retained for event
9 // principles, and only if a non-null History object is provided when
10 // calling makeEventPrincipal.
11 // -----------------------------------------------------------------
12 
22 #include "cetlib/exempt_ptr.h"
23 
24 #include <memory>
25 
26 namespace art {
27  class SourceHelper;
28 } // namespace art
29 
31 public:
32  explicit SourceHelper(ModuleDescription const& md);
33 
34  // Copying/moving is disallowed--the helper object that art creates
35  // is intended to be passed to the user by reference for their use.
36  // If the detail class uses a copy of the SourceHelper object
37  // instead of a reference to the art-provided object, then the
38  // 'setPresentProducts' function will not be called on the detail
39  // class's object. This will induce an exception throw when calling
40  // 'make*Principal'.
41  SourceHelper(SourceHelper const&) = delete;
42  SourceHelper(SourceHelper&&) = delete;
43  SourceHelper& operator=(SourceHelper const&) = delete;
44  SourceHelper& operator=(SourceHelper&&) = delete;
45 
46  template <typename T>
47  Ptr<T> makePtr(TypeLabel const& t,
48  Principal const& p,
49  typename Ptr<T>::key_type key) const;
50 
52  RunPrincipal* makeRunPrincipal(RunID r, Timestamp const& startTime) const;
54  Timestamp const& startTime) const;
55 
58  Timestamp const& startTime) const;
60  SubRunNumber_t sr,
61  Timestamp const& startTime) const;
62 
65  EventID const& e,
66  Timestamp const& startTime,
67  bool isRealData = true,
70  RunNumber_t r,
71  SubRunNumber_t sr,
72  EventNumber_t e,
73  Timestamp const& startTime,
74  bool isRealData = true,
76 
77 private:
78  template <typename T>
79  friend class Source;
80 
81  template <typename T>
82  T* makePrincipal_(typename T::Auxiliary aux) const;
83  void throwIfProductsNotRegistered_() const;
85  BranchType,
86  ProcessConfiguration const&) const;
87  void setPresentProducts(cet::exempt_ptr<ProductTables const> presentProducts);
88  cet::exempt_ptr<ProductTables const> presentProducts_{nullptr};
90 };
91 
92 template <typename T>
95  Principal const& p,
96  typename Ptr<T>::key_type key) const
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 }
106 
107 #endif /* art_Framework_IO_Sources_SourceHelper_h */
108 
109 // Local Variables:
110 // mode: c++
111 // End:
TRandom r
Definition: spectrum.C:23
Ptr< T > makePtr(TypeLabel const &t, Principal const &p, typename Ptr< T >::key_type key) const
SubRunPrincipal * makeSubRunPrincipal(SubRunAuxiliary subRunAux) const
cet::exempt_ptr< ProductTables const > presentProducts_
Definition: SourceHelper.h:88
std::string const & moduleLabel() const
void setPresentProducts(cet::exempt_ptr< ProductTables const > presentProducts)
Definition: SourceHelper.cc:66
EventPrincipal * makeEventPrincipal(EventAuxiliary eventAux) const
std::size_t key_type
Definition: Ptr.h:78
EDProductGetter const * productGetter(ProductID id) const
Definition: Principal.cc:177
SourceHelper(ModuleDescription const &md)
Definition: SourceHelper.cc:15
SourceHelper & operator=(SourceHelper const &)=delete
ProcessHistoryID updatedProcessHistoryID_(ProcessHistoryID const &, BranchType, ProcessConfiguration const &) const
Definition: SourceHelper.cc:34
IDNumber_t< Level::SubRun > SubRunNumber_t
Definition: IDNumber.h:119
T * makePrincipal_(typename T::Auxiliary aux) const
Definition: SourceHelper.cc:74
ProcessConfiguration const & processConfiguration() const
void throwIfProductsNotRegistered_() const
Definition: SourceHelper.cc:18
fhicl::ParameterSetID const & parameterSetID() const
RunPrincipal * makeRunPrincipal(RunAuxiliary runAux) const
Definition: SourceHelper.cc:89
IDNumber_t< Level::Event > EventNumber_t
Definition: IDNumber.h:118
ModuleDescription md_
Definition: SourceHelper.h:89
BranchType
Definition: BranchType.h:20
Definition: MVAAlg.h:12
Float_t e
Definition: plot.C:35
Definition: fwd.h:26
BranchType branchType() const
Definition: Principal.cc:807
IDNumber_t< Level::Run > RunNumber_t
Definition: IDNumber.h:120