CMS 3D CMS Logo

ExceptionThrowingProducer.cc
Go to the documentation of this file.
11 
12 #include <memory>
13 
14 namespace edmtest {
15 
16  namespace {
17  struct Cache {};
18  } // namespace
19 
21  : public edm::global::EDProducer<edm::StreamCache<Cache>, edm::RunCache<Cache>, edm::LuminosityBlockCache<Cache>> {
22  public:
24 
25  ~ExceptionThrowingProducer() override;
26 
27  void produce(edm::StreamID, edm::Event&, edm::EventSetup const&) const override;
28 
29  std::shared_ptr<Cache> globalBeginRun(edm::Run const&, edm::EventSetup const&) const override;
30  void globalEndRun(edm::Run const&, edm::EventSetup const&) const override;
31  std::shared_ptr<Cache> globalBeginLuminosityBlock(edm::LuminosityBlock const&,
32  edm::EventSetup const&) const override;
33  void globalEndLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&) const override;
34 
35  std::unique_ptr<Cache> beginStream(edm::StreamID) const override;
36  void streamBeginRun(edm::StreamID, edm::Run const&, edm::EventSetup const&) const override;
39  void streamEndRun(edm::StreamID, edm::Run const&, edm::EventSetup const&) const override;
40 
42 
43  private:
53  };
54 
56  : eventIDThrowOnEvent_(pset.getUntrackedParameter<edm::EventID>("eventIDThrowOnEvent")),
57  eventIDThrowOnGlobalBeginRun_(pset.getUntrackedParameter<edm::EventID>("eventIDThrowOnGlobalBeginRun")),
58  eventIDThrowOnGlobalBeginLumi_(pset.getUntrackedParameter<edm::EventID>("eventIDThrowOnGlobalBeginLumi")),
59  eventIDThrowOnGlobalEndRun_(pset.getUntrackedParameter<edm::EventID>("eventIDThrowOnGlobalEndRun")),
60  eventIDThrowOnGlobalEndLumi_(pset.getUntrackedParameter<edm::EventID>("eventIDThrowOnGlobalEndLumi")),
61  eventIDThrowOnStreamBeginRun_(pset.getUntrackedParameter<edm::EventID>("eventIDThrowOnStreamBeginRun")),
62  eventIDThrowOnStreamBeginLumi_(pset.getUntrackedParameter<edm::EventID>("eventIDThrowOnStreamBeginLumi")),
63  eventIDThrowOnStreamEndRun_(pset.getUntrackedParameter<edm::EventID>("eventIDThrowOnStreamEndRun")),
64  eventIDThrowOnStreamEndLumi_(pset.getUntrackedParameter<edm::EventID>("eventIDThrowOnStreamEndLumi")) {}
65 
67 
69  if (event.id() == eventIDThrowOnEvent_) {
70  throw cms::Exception("IntentionalTestException")
71  << "ExceptionThrowingProducer::produce, module configured to throw on: " << eventIDThrowOnEvent_;
72  }
73  }
74 
75  std::shared_ptr<Cache> ExceptionThrowingProducer::globalBeginRun(edm::Run const& run, edm::EventSetup const&) const {
78  throw cms::Exception("IntentionalTestException")
79  << "ExceptionThrowingProducer::globalBeginRun, module configured to throw on: "
81  }
82  return std::make_shared<Cache>();
83  }
84 
88  throw cms::Exception("IntentionalTestException")
89  << "ExceptionThrowingProducer::globalEndRun, module configured to throw on: " << eventIDThrowOnGlobalEndRun_;
90  }
91  }
92 
94  edm::EventSetup const&) const {
95  if (edm::EventID(lumi.id().run(), lumi.id().luminosityBlock(), edm::invalidEventNumber) ==
97  throw cms::Exception("IntentionalTestException")
98  << "ExceptionThrowingProducer::globalBeginLuminosityBlock, module configured to throw on: "
100  }
101  return std::make_shared<Cache>();
102  }
103 
105  edm::EventSetup const&) const {
106  if (edm::EventID(lumi.id().run(), lumi.id().luminosityBlock(), edm::invalidEventNumber) ==
108  throw cms::Exception("IntentionalTestException")
109  << "ExceptionThrowingProducer::globalEndLuminosityBlock, module configured to throw on: "
111  }
112  }
113 
115  return std::make_unique<Cache>();
116  }
117 
119  edm::Run const& run,
120  edm::EventSetup const&) const {
121  if (iStream.value() == 0 &&
124  throw cms::Exception("IntentionalTestException")
125  << "ExceptionThrowingProducer::streamBeginRun, module configured to throw on: "
127  }
128  }
129 
131  edm::LuminosityBlock const& lumi,
132  edm::EventSetup const&) const {
133  if (iStream.value() == 0 && edm::EventID(lumi.run(), lumi.id().luminosityBlock(), edm::invalidEventNumber) ==
135  throw cms::Exception("IntentionalTestException")
136  << "ExceptionThrowingProducer::streamBeginLuminosityBlock, module configured to throw on: "
138  }
139  }
140 
142  edm::LuminosityBlock const& lumi,
143  edm::EventSetup const&) const {
144  if (iStream.value() == 0 && edm::EventID(lumi.run(), lumi.id().luminosityBlock(), edm::invalidEventNumber) ==
146  throw cms::Exception("IntentionalTestException")
147  << "ExceptionThrowingProducer::streamEndLuminosityBlock, module configured to throw on: "
149  }
150  }
151 
153  edm::Run const& run,
154  edm::EventSetup const&) const {
155  if (iStream.value() == 0 &&
158  throw cms::Exception("IntentionalTestException")
159  << "ExceptionThrowingProducer::streamEndRun, module configured to throw on: " << eventIDThrowOnStreamEndRun_;
160  }
161  }
162 
165  edm::EventID invalidEventID;
166  desc.addUntracked<edm::EventID>("eventIDThrowOnEvent", invalidEventID);
167  desc.addUntracked<edm::EventID>("eventIDThrowOnGlobalBeginRun", invalidEventID);
168  desc.addUntracked<edm::EventID>("eventIDThrowOnGlobalBeginLumi", invalidEventID);
169  desc.addUntracked<edm::EventID>("eventIDThrowOnGlobalEndRun", invalidEventID);
170  desc.addUntracked<edm::EventID>("eventIDThrowOnGlobalEndLumi", invalidEventID);
171  desc.addUntracked<edm::EventID>("eventIDThrowOnStreamBeginRun", invalidEventID);
172  desc.addUntracked<edm::EventID>("eventIDThrowOnStreamBeginLumi", invalidEventID);
173  desc.addUntracked<edm::EventID>("eventIDThrowOnStreamEndRun", invalidEventID);
174  desc.addUntracked<edm::EventID>("eventIDThrowOnStreamEndLumi", invalidEventID);
175  descriptions.addDefault(desc);
176  }
177 
178 } // namespace edmtest
std::shared_ptr< Cache > globalBeginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) const override
std::unique_ptr< Cache > beginStream(edm::StreamID) const override
static void fillDescriptions(edm::ConfigurationDescriptions &)
void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override
EventNumber_t const invalidEventNumber
void addDefault(ParameterSetDescription const &psetDescription)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void streamBeginLuminosityBlock(edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &) const override
void streamBeginRun(edm::StreamID, edm::Run const &, edm::EventSetup const &) const override
LuminosityBlockNumber_t const invalidLuminosityBlockNumber
void globalEndLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) const override
std::shared_ptr< Cache > globalBeginRun(edm::Run const &, edm::EventSetup const &) const override
ExceptionThrowingProducer(edm::ParameterSet const &)
void streamEndRun(edm::StreamID, edm::Run const &, edm::EventSetup const &) const override
void streamEndLuminosityBlock(edm::StreamID, edm::LuminosityBlock const &, edm::EventSetup const &) const override
HLT enums.
void globalEndRun(edm::Run const &, edm::EventSetup const &) const override
unsigned int value() const
Definition: StreamID.h:43
Definition: event.py:1
Definition: Run.h:45