LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
Event.cc
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // Event - This is the primary interface for accessing EDProducts from a
4 // single collision and inserting new derived products.
5 //
6 // ======================================================================
7 
9 
16 
17 using namespace std;
18 using namespace fhicl;
19 
20 namespace art {
21 
22  namespace {
23  // It only makes sense to track parents when putting a product
24  // onto the event. That requires a non-const Event object.
25  constexpr bool
26  record_parents(Event*)
27  {
28  return true;
29  }
30  [[gnu::unused]] constexpr bool
31  record_parents(Event const*)
32  {
33  return false;
34  }
35 
36  SubRun*
37  newSubRun(EventPrincipal const& ep,
38  ModuleDescription const& md,
39  cet::exempt_ptr<Consumer> consumer)
40  {
41  return ep.subRunPrincipalExemptPtr() ?
42  new SubRun{ep.subRunPrincipal(), md, consumer} :
43  nullptr;
44  }
45  }
46 
47  Event::Event(EventPrincipal const& ep,
48  ModuleDescription const& md,
49  cet::exempt_ptr<Consumer> consumer,
50  RangeSet const&)
51  : Event{ep, md, consumer}
52  {}
53 
55  ModuleDescription const& md,
56  cet::exempt_ptr<Consumer> consumer)
57  : DataViewImpl{ep, md, InEvent, record_parents(this), consumer}
58  , aux_{ep.aux()}
59  , subRun_{newSubRun(ep, md, consumer)}
60  , eventPrincipal_{ep}
61  {}
62 
63  EDProductGetter const*
65  {
66  return eventPrincipal_.productGetter(pid);
67  }
68 
69  SubRun const&
71  {
72  if (!subRun_) {
74  << "Tried to obtain a NULL subRun.\n";
75  }
76  return *subRun_;
77  }
78 
79  Run const&
80  Event::getRun() const
81  {
82  return getSubRun().getRun();
83  }
84 
85  History const&
87  {
88  return eventPrincipal_.history();
89  }
90 
91  ProcessHistoryID const&
93  {
95  }
96 
97  bool
98  Event::getProcessParameterSet(string const& processName,
99  ParameterSet& ps) const
100  {
101  // Get the ProcessHistory for this event.
102  ProcessHistory ph;
105  << "ProcessHistoryID " << processHistoryID()
106  << " is claimed to describe " << id()
107  << "\nbut is not found in the ProcessHistoryRegistry.\n"
108  "This file is malformed.\n";
109  }
110 
111  ProcessConfiguration config;
112  bool const process_found{
113  ph.getConfigurationForProcess(processName, config)};
114  if (process_found) {
115  ParameterSetRegistry::get(config.parameterSetID(), ps);
116  }
117  return process_found;
118  }
119 
120  void
122  bool const checkProducts,
123  std::set<TypeLabel> const& expectedProducts)
124  {
125  // Check addresses only since type of 'ep' will hopefully change to
126  // Principal&.
127  assert(&ep == &eventPrincipal_);
128  checkPutProducts(checkProducts, expectedProducts, putProducts());
129 
130  auto const& parents = retrievedProductIDs();
131  for (auto& elem : putProducts()) {
132  auto const& pd = elem.second.pd;
133  auto productProvenancePtr = make_unique<ProductProvenance const>(
134  pd.productID(), productstatus::present(), parents);
135  ep.put(std::move(elem.second.prod), pd, std::move(productProvenancePtr));
136  };
137 
138  // the cleanup is all or none
139  putProducts().clear();
140  }
141 
142 } // art
bool getProcessParameterSet(std::string const &processName, fhicl::ParameterSet &ps) const
Definition: Event.cc:98
void put(std::unique_ptr< EDProduct > &&edp, BranchDescription const &pd, std::unique_ptr< ProductProvenance const > &&productProvenance)
History const & history() const
Definition: Event.cc:86
ProcessHistoryID const & processHistoryID() const
Definition: History.h:42
bool getConfigurationForProcess(std::string const &name, ProcessConfiguration &config) const
STL namespace.
EDProductGetter const * productGetter(ProductID const) const
Definition: Event.cc:64
History const & history() const
Definition: Run.h:30
static collection_type const & get()
Run const & getRun() const
Definition: SubRun.cc:32
EventPrincipal const & eventPrincipal_
Definition: Event.h:153
EventAuxiliary const & aux_
Definition: Event.h:151
parameter set interface
Run const & getRun() const
Definition: Event.cc:80
std::unique_ptr< SubRun const > const subRun_
Definition: Event.h:152
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
EDProductGetter const * productGetter(ProductID const pid) const
Definition: Principal.cc:532
TypeLabelMap & putProducts()
Definition: DataViewImpl.h:183
HLT enums.
RetrievedProductIDs retrievedProductIDs() const
void commit(EventPrincipal &, bool checkPutProducts, std::set< TypeLabel > const &expectedProducts)
Definition: Event.cc:121
ProcessHistoryID const & processHistoryID() const
Definition: Event.cc:92
void checkPutProducts(bool checkProducts, std::set< TypeLabel > const &expectedProducts, TypeLabelMap const &putProducts)
SubRun const & getSubRun() const
Definition: Event.cc:70
ProductStatus present()
Definition: ProductStatus.h:16
Event(EventPrincipal const &ep, ModuleDescription const &md, cet::exempt_ptr< Consumer > consumer, RangeSet const &rs)
Definition: Event.cc:47
EventID id() const
Definition: Event.h:56
fhicl::ParameterSetID const & parameterSetID() const