File indexing completed on 2025-02-26 04:25:19
0001 #include "FWCore/Framework/interface/Event.h"
0002 #include "FWCore/Framework/interface/global/EDAnalyzer.h"
0003 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0006 #include "FWCore/Utilities/interface/EDGetToken.h"
0007 #include "FWCore/Utilities/interface/Exception.h"
0008 #include "FWCore/Utilities/interface/InputTag.h"
0009
0010 namespace edmtest {
0011
0012 class GlobalIntAnalyzer : public edm::global::EDAnalyzer<> {
0013 public:
0014 explicit GlobalIntAnalyzer(edm::ParameterSet const& ps);
0015
0016 void analyze(edm::StreamID sid, edm::Event const& event, edm::EventSetup const& es) const override;
0017
0018 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0019
0020 private:
0021 edm::EDGetTokenT<int> token_;
0022 int expected_;
0023 };
0024
0025 GlobalIntAnalyzer::GlobalIntAnalyzer(edm::ParameterSet const& config)
0026 : token_(consumes(config.getParameter<edm::InputTag>("source"))),
0027 expected_(config.getParameter<int>("expected")) {}
0028
0029 void GlobalIntAnalyzer::analyze(edm::StreamID sid, edm::Event const& event, edm::EventSetup const& es) const {
0030 int value = event.get(token_);
0031 if (value != expected_) {
0032 throw cms::Exception("LogicError") << "expected value \"" << expected_ << "\"\nreceived value \"" << value << '"';
0033 }
0034 }
0035
0036 void GlobalIntAnalyzer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0037 edm::ParameterSetDescription desc;
0038 desc.add<edm::InputTag>("source");
0039 desc.add<int>("expected", 0);
0040 descriptions.addDefault(desc);
0041 }
0042
0043 }
0044
0045 #include "FWCore/Framework/interface/MakerMacros.h"
0046 DEFINE_FWK_MODULE(edmtest::GlobalIntAnalyzer);