File indexing completed on 2024-04-06 12:12:38
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
0023
0024 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0025
0026 #include "FWCore/Framework/interface/MakerMacros.h"
0027
0028 #include "WhatsIt.h"
0029 #include "GadgetRcd.h"
0030
0031 #include "FWCore/Framework/interface/ESHandle.h"
0032
0033 #include "FWCore/Framework/interface/ESWatcher.h"
0034
0035
0036
0037
0038
0039 namespace edmtest {
0040
0041 class WhatsItWatcherAnalyzer : public edm::one::EDAnalyzer<> {
0042 public:
0043 explicit WhatsItWatcherAnalyzer(const edm::ParameterSet&);
0044
0045 void analyze(const edm::Event&, const edm::EventSetup&) override;
0046
0047 private:
0048
0049 void watch1(const GadgetRcd&);
0050 void watch2(const GadgetRcd&);
0051
0052 edm::ESWatcher<GadgetRcd> watch1_;
0053 edm::ESWatcher<GadgetRcd> watch2_;
0054 edm::ESWatcher<GadgetRcd> watchBool_;
0055
0056 edm::ESGetToken<edmtest::WhatsIt, GadgetRcd> token_;
0057 };
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 WhatsItWatcherAnalyzer::WhatsItWatcherAnalyzer(const edm::ParameterSet& )
0071 : watch1_(this, &WhatsItWatcherAnalyzer::watch1),
0072 watch2_(std::bind(&WhatsItWatcherAnalyzer::watch2, this, std::placeholders::_1)),
0073 watchBool_(),
0074 token_(esConsumes()) {
0075
0076 }
0077
0078
0079
0080
0081
0082
0083 void WhatsItWatcherAnalyzer::analyze(const edm::Event& , const edm::EventSetup& iSetup) {
0084 bool w1 = watch1_.check(iSetup);
0085 bool w2 = watch2_.check(iSetup);
0086 bool w3 = watchBool_.check(iSetup);
0087 assert(w1 == w2);
0088 assert(w2 == w3);
0089 }
0090
0091 void WhatsItWatcherAnalyzer::watch1(const GadgetRcd& iRcd) {
0092 edm::ESHandle<edmtest::WhatsIt> pSetup = iRcd.getHandle(token_);
0093
0094 std::cout << "watch1: WhatsIt " << pSetup->a << " changed" << std::endl;
0095 }
0096
0097 void WhatsItWatcherAnalyzer::watch2(const GadgetRcd& iRcd) {
0098 edm::ESHandle<WhatsIt> pSetup = iRcd.getHandle(token_);
0099
0100 std::cout << "watch2: WhatsIt " << pSetup->a << " changed" << std::endl;
0101 }
0102
0103 }
0104 using namespace edmtest;
0105
0106 DEFINE_FWK_MODULE(WhatsItWatcherAnalyzer);