File indexing completed on 2024-04-06 12:23:22
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021 #include <iostream>
0022 #include <vector>
0023
0024
0025 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0026
0027 #include "FWCore/Framework/interface/MakerMacros.h"
0028
0029 #include "DataFormats/TestObjects/interface/ToyProducts.h"
0030 #include "PhysicsTools/CondLiteIO/test/IntProductRecord.h"
0031
0032 #include "FWCore/Framework/interface/ESHandle.h"
0033 #include "FWCore/Framework/interface/EventSetup.h"
0034 #include "FWCore/Utilities/interface/Exception.h"
0035
0036
0037
0038
0039
0040 namespace edmtest {
0041
0042 class EventSetupIntProductAnalyzer : public edm::one::EDAnalyzer<> {
0043 public:
0044 explicit EventSetupIntProductAnalyzer(const edm::ParameterSet&);
0045 ~EventSetupIntProductAnalyzer();
0046
0047 virtual void analyze(const edm::Event&, const edm::EventSetup&);
0048
0049 private:
0050
0051 std::vector<int> expectedValues_;
0052 unsigned int index_;
0053 edm::ESGetToken<edmtest::IntProduct, IntProductRecord> token_;
0054 };
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067 EventSetupIntProductAnalyzer::EventSetupIntProductAnalyzer(const edm::ParameterSet& iConfig)
0068 : expectedValues_(iConfig.getUntrackedParameter<std::vector<int> >("expectedValues", std::vector<int>())),
0069 index_(0),
0070 token_(esConsumes()) {
0071
0072 }
0073
0074 EventSetupIntProductAnalyzer::~EventSetupIntProductAnalyzer() {
0075
0076
0077 }
0078
0079
0080
0081
0082
0083
0084 void EventSetupIntProductAnalyzer::analyze(const edm::Event& , const edm::EventSetup& iSetup) {
0085 using namespace edm;
0086 auto const& setup = iSetup.getData(token_);
0087
0088 std::cout << "edmtest::IntProduct " << setup.value << std::endl;
0089 if (!expectedValues_.empty()) {
0090 if (expectedValues_.at(index_) != setup.value) {
0091 throw cms::Exception("TestFail") << "expected value " << expectedValues_[index_] << " but was got "
0092 << setup.value;
0093 }
0094 ++index_;
0095 }
0096 }
0097 }
0098 using namespace edmtest;
0099
0100 DEFINE_FWK_MODULE(EventSetupIntProductAnalyzer);