ImplicitRSAssignmentProducer_module.cc
Go to the documentation of this file.
8 
9 namespace fhicl {
10  class ParameterSet;
11 }
12 
13 using std::make_unique;
14 
15 namespace {
16 
17  bool
18  insert_failure(art::Exception const& e)
19  {
20  return e.categoryCode() == art::errors::ProductPutFailure;
21  }
22 
23  bool
24  run_fragment_put(std::string const what)
25  {
26  return what.find(
27  " Cannot put a product corresponding to a full Run using\n"
28  " art::runFragment(). This can happen if you attempted to\n"
29  " put a product at beginRun using art::runFragment().\n"
30  " Please use either:\n"
31  " art::fullRun(), or\n"
32  " art::runFragment(art::RangeSet const&)\n"
33  " or contact artists@fnal.gov for assistance.\n") !=
34  std::string::npos;
35  }
36 
37  bool
38  run_fragment_full_run_put(std::string const what)
39  {
40  return what.find(
41  " Cannot put a product corresponding to a full Run using\n"
42  " art::runFragment(art::RangeSet&). Please use:\n"
43  " art::fullRun()\n"
44  " or contact artists@fnal.gov for assistance.\n") !=
45  std::string::npos;
46  }
47 
48  bool
49  subRun_fragment_put(std::string const what)
50  {
51  return what.find(
52  " Cannot put a product corresponding to a full SubRun using\n"
53  " art::subRunFragment(). This can happen if you attempted to\n"
54  " put a product at beginSubRun using art::subRunFragment().\n"
55  " Please use either:\n"
56  " art::fullSubRun(), or\n"
57  " art::subRunFragment(art::RangeSet const&)\n"
58  " or contact artists@fnal.gov for assistance.\n") !=
59  std::string::npos;
60  }
61 
62  bool
63  subRun_fragment_full_subRun_put(std::string const what)
64  {
65  return what.find(
66  " Cannot put a product corresponding to a full SubRun using\n"
67  " art::subRunFragment(art::RangeSet&). Please use:\n"
68  " art::fullSubRun()\n"
69  " or contact artists@fnal.gov for assistance.\n") !=
70  std::string::npos;
71  }
72 
73  struct Config {
74  };
75 
76 } // namespace
77 
78 namespace arttest {
79 
81  public:
83  explicit ImplicitRSAssigmentProducer(Parameters const& ps) : EDProducer{ps}
84  {
85  produces<unsigned, art::InRun>("bgnRunNum");
86  produces<unsigned, art::InRun>("bgnRunDenom");
87  produces<unsigned, art::InRun>("bgnRunGarbage1");
88  produces<unsigned, art::InRun>("bgnRunGarbage2");
89  produces<unsigned, art::InRun>("endRunNum");
90  produces<unsigned, art::InRun>("endRunDenom");
91 
92  produces<unsigned, art::InSubRun>("bgnSubRunNum");
93  produces<unsigned, art::InSubRun>("bgnSubRunDenom");
94  produces<unsigned, art::InSubRun>("bgnSubRunGarbage1");
95  produces<unsigned, art::InSubRun>("bgnSubRunGarbage2");
96  produces<unsigned, art::InSubRun>("endSubRunNum");
97  produces<unsigned, art::InSubRun>("endSubRunDenom");
98  }
99 
100  void
101  beginRun(art::Run& r) override
102  {
103  r.put(make_unique<unsigned>(2), "bgnRunNum");
104  r.put(make_unique<unsigned>(2), "bgnRunDenom", art::fullRun());
105 
106  BOOST_CHECK_EXCEPTION(
107  r.put(make_unique<unsigned>(4), "bgnRunGarbage1", art::runFragment()),
109  [](art::Exception const& e) {
110  return insert_failure(e) && run_fragment_put(e.what());
111  });
112 
113  BOOST_CHECK_EXCEPTION(
114  r.put(make_unique<unsigned>(4),
115  "bgnRunGarbage2",
118  [](art::Exception const& e) {
119  return insert_failure(e) && run_fragment_full_run_put(e.what());
120  });
121  }
122 
123  void
125  {
126  sr.put(make_unique<unsigned>(6), "bgnSubRunNum");
127  sr.put(make_unique<unsigned>(6), "bgnSubRunDenom", art::fullSubRun());
128 
129  BOOST_CHECK_EXCEPTION(
130  sr.put(
131  make_unique<unsigned>(8), "bgnSubRunGarbage1", art::subRunFragment()),
133  [](art::Exception const& e) {
134  return insert_failure(e) && subRun_fragment_put(e.what());
135  });
136 
137  BOOST_CHECK_EXCEPTION(
138  sr.put(make_unique<unsigned>(8),
139  "bgnSubRunGarbage2",
142  [](art::Exception const& e) {
143  return insert_failure(e) && subRun_fragment_full_subRun_put(e.what());
144  });
145  }
146 
147  void
148  produce(art::Event&) override
149  {}
150 
151  void
153  {
154  sr.put(make_unique<unsigned>(1), "endSubRunNum");
155  sr.put(make_unique<unsigned>(1), "endSubRunDenom", art::subRunFragment());
156  }
157 
158  void
159  endRun(art::Run& r) override
160  {
161  r.put(make_unique<unsigned>(3), "endRunNum");
162  r.put(make_unique<unsigned>(3), "endRunDenom", art::runFragment());
163  }
164 
165  }; // ImplicitRSAssigmentProducer
166 
167 } // namespace arttest
168 
RunID id() const
Definition: Run.cc:24
constexpr auto fullRun()
static const double ps
Definition: Units.h:103
std::string string
Definition: nybbler.cc:12
Definition: Run.h:21
constexpr auto runFragment()
static RangeSet forSubRun(SubRunID)
Definition: RangeSet.cc:58
const double e
#define DEFINE_ART_MODULE(klass)
Definition: ModuleMacros.h:68
parameter set interface
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr auto subRunFragment()
SubRunID id() const
Definition: SubRun.cc:21
constexpr auto fullSubRun()
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:692
static const double sr
Definition: Units.h:167
static RangeSet forRun(RunID)
Definition: RangeSet.cc:52