1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
// -*- C++ -*-
//
// Package: WhatsItWatcherAnalyzer
// Class: WhatsItWatcherAnalyzer
//
/**\class WhatsItWatcherAnalyzer WhatsItWatcherAnalyzer.cc test/WhatsItWatcherAnalyzer/src/WhatsItWatcherAnalyzer.cc
Description: <one line class summary>
Implementation:
<Notes on implementation>
*/
//
// Original Author: Chris Jones
// Created: Fri Jun 24 19:13:25 EDT 2005
//
//
// system include files
#include <memory>
#include <iostream>
// user include files
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "WhatsIt.h"
#include "GadgetRcd.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ESWatcher.h"
//
// class decleration
//
namespace edmtest {
class WhatsItWatcherAnalyzer : public edm::one::EDAnalyzer<> {
public:
explicit WhatsItWatcherAnalyzer(const edm::ParameterSet&);
void analyze(const edm::Event&, const edm::EventSetup&) override;
private:
// ----------member data ---------------------------
void watch1(const GadgetRcd&);
void watch2(const GadgetRcd&);
edm::ESWatcher<GadgetRcd> watch1_;
edm::ESWatcher<GadgetRcd> watch2_;
edm::ESWatcher<GadgetRcd> watchBool_;
edm::ESGetToken<edmtest::WhatsIt, GadgetRcd> token_;
};
//
// constants, enums and typedefs
//
//
// static data member definitions
//
//
// constructors and destructor
//
WhatsItWatcherAnalyzer::WhatsItWatcherAnalyzer(const edm::ParameterSet& /*iConfig*/)
: watch1_(this, &WhatsItWatcherAnalyzer::watch1),
watch2_(std::bind(&WhatsItWatcherAnalyzer::watch2, this, std::placeholders::_1)),
watchBool_(),
token_(esConsumes()) {
//now do what ever initialization is needed
}
//
// member functions
//
// ------------ method called to produce the data ------------
void WhatsItWatcherAnalyzer::analyze(const edm::Event& /*iEvent*/, const edm::EventSetup& iSetup) {
bool w1 = watch1_.check(iSetup);
bool w2 = watch2_.check(iSetup);
bool w3 = watchBool_.check(iSetup);
assert(w1 == w2);
assert(w2 == w3);
}
void WhatsItWatcherAnalyzer::watch1(const GadgetRcd& iRcd) {
edm::ESHandle<edmtest::WhatsIt> pSetup = iRcd.getHandle(token_);
std::cout << "watch1: WhatsIt " << pSetup->a << " changed" << std::endl;
}
void WhatsItWatcherAnalyzer::watch2(const GadgetRcd& iRcd) {
edm::ESHandle<WhatsIt> pSetup = iRcd.getHandle(token_);
std::cout << "watch2: WhatsIt " << pSetup->a << " changed" << std::endl;
}
} // namespace edmtest
using namespace edmtest;
//define this as a plug-in
DEFINE_FWK_MODULE(WhatsItWatcherAnalyzer);
|