File indexing completed on 2024-04-06 12:15:42
0001 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0004 #include "FWCore/Utilities/interface/InputTag.h"
0005 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/global/EDProducer.h"
0006 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/ESGetToken.h"
0007 #include "HeterogeneousCore/AlpakaInterface/interface/config.h"
0008 #include "HeterogeneousCore/AlpakaTest/interface/AlpakaESTestRecords.h"
0009 #include "HeterogeneousCore/AlpakaTest/interface/alpaka/AlpakaESTestData.h"
0010
0011 namespace ALPAKA_ACCELERATOR_NAMESPACE {
0012
0013
0014
0015 class TestAlpakaGlobalProducerNullES : public global::EDProducer<> {
0016 public:
0017 TestAlpakaGlobalProducerNullES(edm::ParameterSet const& config)
0018 : esTokenA_(esConsumes(config.getParameter<edm::ESInputTag>("eventSetupSource"))),
0019 esTokenC_(esConsumes(config.getParameter<edm::ESInputTag>("eventSetupSource"))),
0020 esTokenCNotExist_(esConsumes(edm::ESInputTag("", "doesNotExist"))) {}
0021
0022 void produce(edm::StreamID, device::Event& iEvent, device::EventSetup const& iSetup) const override {
0023 bool threw = false;
0024 try {
0025 [[maybe_unused]] auto handleA = iSetup.getHandle(esTokenA_);
0026 } catch (cms::Exception& e) {
0027 threw = true;
0028 }
0029 if (not threw) {
0030 throw cms::Exception("Assert") << "Getting AlpakaESTestDataADevice ESProduct did not throw";
0031 }
0032
0033 threw = false;
0034 try {
0035 [[maybe_unused]] auto const& prodC = iSetup.getData(esTokenC_);
0036 } catch (cms::Exception& e) {
0037 threw = true;
0038 }
0039 if (not threw) {
0040 throw cms::Exception("Assert") << "Getting AlpakaESTestDataCDevice ESProduct did not throw";
0041 }
0042
0043 auto handleC = iSetup.getHandle(esTokenCNotExist_);
0044 if (handleC.isValid()) {
0045 throw cms::Exception("Assert") << "Getting non-existing AlpakaESTestDataCDevice succeeded, should have failed";
0046 }
0047 threw = false;
0048 try {
0049 [[maybe_unused]] auto const& prodC = *handleC;
0050 } catch (cms::Exception& e) {
0051 threw = true;
0052 }
0053 if (not threw) {
0054 throw cms::Exception("Assert")
0055 << "De-referencing ESHandle of non-existentAlpakaESTestDataADevice did not throw";
0056 }
0057 }
0058
0059 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0060 edm::ParameterSetDescription desc;
0061 desc.add("eventSetupSource", edm::ESInputTag{});
0062 descriptions.addWithDefaultLabel(desc);
0063 }
0064
0065 private:
0066 const device::ESGetToken<AlpakaESTestDataADevice, AlpakaESTestRecordA> esTokenA_;
0067 const device::ESGetToken<AlpakaESTestDataCDevice, AlpakaESTestRecordA> esTokenC_;
0068 const device::ESGetToken<AlpakaESTestDataCDevice, AlpakaESTestRecordA> esTokenCNotExist_;
0069 };
0070
0071 }
0072
0073 #include "HeterogeneousCore/AlpakaCore/interface/alpaka/MakerMacros.h"
0074 DEFINE_FWK_ALPAKA_MODULE(TestAlpakaGlobalProducerNullES);