File indexing completed on 2024-12-12 03:12:19
0001 #include "DataFormats/TestObjects/interface/ToyProducts.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/Utilities/interface/EDGetToken.h"
0006 #include "FWCore/Utilities/interface/Exception.h"
0007 #include "FWCore/Utilities/interface/InputTag.h"
0008
0009 namespace edmtest {
0010
0011 class MaybeUninitializedIntAnalyzer : public edm::global::EDAnalyzer<> {
0012 public:
0013 MaybeUninitializedIntAnalyzer(edm::ParameterSet const& config)
0014 : value_{config.getParameter<int32_t>("value")},
0015 token_{consumes(config.getParameter<edm::InputTag>("source"))} {}
0016
0017 void analyze(edm::StreamID, edm::Event const& event, edm::EventSetup const&) const final {
0018 MaybeUninitializedIntProduct const& product = event.get(token_);
0019 if (product.value != value_) {
0020 throw cms::Exception("Inconsistent Data", "MaybeUninitializedIntAnalyzer::analyze")
0021 << "Found value " << product.value << " while expecting value " << value_;
0022 }
0023 }
0024
0025 private:
0026 const cms_int32_t value_;
0027 const edm::EDGetTokenT<MaybeUninitializedIntProduct> token_;
0028 };
0029
0030 }
0031
0032 #include "FWCore/Framework/interface/MakerMacros.h"
0033 DEFINE_FWK_MODULE(edmtest::MaybeUninitializedIntAnalyzer);