LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
SubRun.cc
Go to the documentation of this file.
5 
6 namespace art {
7 
8  namespace {
9  Run*
10  newRun(SubRunPrincipal const& srp,
11  ModuleDescription const& md,
12  cet::exempt_ptr<Consumer> consumer)
13  {
14  return srp.runPrincipalExemptPtr() ?
15  new Run{srp.runPrincipal(), md, consumer} :
16  nullptr;
17  }
18  }
19 
21  ModuleDescription const& md,
22  cet::exempt_ptr<Consumer> consumer,
23  RangeSet const& rs)
24  : DataViewImpl{srp, md, InSubRun, false, consumer}
25  , principal_{srp}
26  , aux_{srp.aux()}
27  , run_{newRun(srp, md, consumer)}
28  , productRangeSet_{rs}
29  {}
30 
31  Run const&
33  {
34  if (!run_) {
36  << "Tried to obtain a NULL run.\n";
37  }
38  return *run_;
39  }
40 
41  EDProductGetter const*
43  {
44  return principal_.productGetter(pid);
45  }
46 
47  void
49  bool const checkProducts,
50  std::set<TypeLabel> const& expectedProducts)
51  {
52  // Check addresses only since type of 'srp' will hopefully change to
53  // Principal&.
54  assert(&srp == &principal_);
55  checkPutProducts(checkProducts, expectedProducts, putProducts());
56  commit(srp);
57  }
58 
59  void
61  {
62  for (auto& elem : putProducts()) {
63  auto const& pd = elem.second.pd;
64  auto productProvenancePtr = std::make_unique<ProductProvenance const>(
65  pd.productID(), productstatus::present());
66 
67  srp.put(std::move(elem.second.prod),
68  pd,
69  std::move(productProvenancePtr),
70  std::move(elem.second.rs));
71  }
72 
73  // the cleanup is all or none
74  putProducts().clear();
75  }
76 }
void put(std::unique_ptr< EDProduct > &&, BranchDescription const &, std::unique_ptr< ProductProvenance const > &&, RangeSet &&)
std::unique_ptr< Run const > const run_
Definition: SubRun.h:138
Definition: Run.h:30
Principal const & principal_
Definition: SubRun.h:136
SubRun(SubRunPrincipal const &srp, ModuleDescription const &md, cet::exempt_ptr< Consumer > consumer, RangeSet const &rsForPuttingProducts=RangeSet::invalid())
Definition: SubRun.cc:20
RangeSet productRangeSet_
Definition: SubRun.h:139
Run const & getRun() const
Definition: SubRun.cc:32
SubRunAuxiliary const & aux_
Definition: SubRun.h:137
EDProductGetter const * productGetter(ProductID const pid) const
Definition: SubRun.cc:42
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void commit(SubRunPrincipal &srp, bool const checkProducts, std::set< TypeLabel > const &expectedProducts)
Definition: SubRun.cc:48
EDProductGetter const * productGetter(ProductID const pid) const
Definition: Principal.cc:532
TypeLabelMap & putProducts()
Definition: DataViewImpl.h:183
HLT enums.
void checkPutProducts(bool checkProducts, std::set< TypeLabel > const &expectedProducts, TypeLabelMap const &putProducts)
ProductStatus present()
Definition: ProductStatus.h:16