CMS 3D CMS Logo

TestAlpakaGlobalProducerNullES.cc
Go to the documentation of this file.
10 
16  public:
18  : esTokenA_(esConsumes(config.getParameter<edm::ESInputTag>("eventSetupSource"))),
19  esTokenC_(esConsumes(config.getParameter<edm::ESInputTag>("eventSetupSource"))),
20  esTokenCNotExist_(esConsumes(edm::ESInputTag("", "doesNotExist"))) {}
21 
22  void produce(edm::StreamID, device::Event& iEvent, device::EventSetup const& iSetup) const override {
23  bool threw = false;
24  try {
25  [[maybe_unused]] auto handleA = iSetup.getHandle(esTokenA_);
26  } catch (cms::Exception& e) {
27  threw = true;
28  }
29  if (not threw) {
30  throw cms::Exception("Assert") << "Getting AlpakaESTestDataADevice ESProduct did not throw";
31  }
32 
33  threw = false;
34  try {
35  [[maybe_unused]] auto const& prodC = iSetup.getData(esTokenC_);
36  } catch (cms::Exception& e) {
37  threw = true;
38  }
39  if (not threw) {
40  throw cms::Exception("Assert") << "Getting AlpakaESTestDataCDevice ESProduct did not throw";
41  }
42 
43  auto handleC = iSetup.getHandle(esTokenCNotExist_);
44  if (handleC.isValid()) {
45  throw cms::Exception("Assert") << "Getting non-existing AlpakaESTestDataCDevice succeeded, should have failed";
46  }
47  threw = false;
48  try {
49  [[maybe_unused]] auto const& prodC = *handleC;
50  } catch (cms::Exception& e) {
51  threw = true;
52  }
53  if (not threw) {
54  throw cms::Exception("Assert")
55  << "De-referencing ESHandle of non-existentAlpakaESTestDataADevice did not throw";
56  }
57  }
58 
59  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
61  desc.add("eventSetupSource", edm::ESInputTag{});
62  descriptions.addWithDefaultLabel(desc);
63  }
64 
65  private:
69  };
70 
71 } // namespace ALPAKA_ACCELERATOR_NAMESPACE
72 
74 DEFINE_FWK_ALPAKA_MODULE(TestAlpakaGlobalProducerNullES);
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
edm::ESHandle< T > getHandle(edm::ESGetToken< T, R > const &iToken) const
Definition: EventSetup.h:49
void produce(edm::StreamID, device::Event &iEvent, device::EventSetup const &iSetup) const override
Definition: config.py:1
const device::ESGetToken< AlpakaESTestDataCDevice, AlpakaESTestRecordA > esTokenCNotExist_
const device::ESGetToken< AlpakaESTestDataCDevice, AlpakaESTestRecordA > esTokenC_
int iEvent
Definition: GenABIO.cc:224
const device::ESGetToken< AlpakaESTestDataADevice, AlpakaESTestRecordA > esTokenA_
T const & getData(edm::ESGetToken< T, R > const &iToken) const
Definition: EventSetup.h:32
HLT enums.
#define DEFINE_FWK_ALPAKA_MODULE(name)
Definition: MakerMacros.h:16