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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
|
//
// Puts some simple test objects in the event, run, and lumi
// principals. The values put into these objects are just
// arbitrary and meaningless. Later we check that what get
// out when reading the file after merging is what is expected.
//
// Original Author: David Dagenhart, Fermilab, February 2008
#include "ThingWithMergeProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/LuminosityBlock.h"
#include "FWCore/Framework/interface/Run.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "DataFormats/TestObjects/interface/Thing.h"
#include "DataFormats/TestObjects/interface/ThingWithMerge.h"
#include "DataFormats/TestObjects/interface/ThingWithIsEqual.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
namespace edmtest {
ThingWithMergeProducer::ThingWithMergeProducer(edm::ParameterSet const& pset)
: changeIsEqualValue_(pset.getUntrackedParameter<bool>("changeIsEqualValue", false)),
labelsToGet_(pset.getUntrackedParameter<std::vector<std::string>>("labelsToGet", std::vector<std::string>())),
noPut_(pset.getUntrackedParameter<bool>("noPut", false)) {
produces<Thing>("event");
produces<Thing, edm::Transition::BeginLuminosityBlock>("beginLumi");
produces<Thing, edm::Transition::EndLuminosityBlock>("endLumi");
produces<Thing, edm::Transition::BeginRun>("beginRun");
produces<Thing, edm::Transition::EndRun>("endRun");
produces<ThingWithMerge>("event");
produces<ThingWithMerge, edm::Transition::BeginLuminosityBlock>("beginLumi");
produces<ThingWithMerge, edm::Transition::EndLuminosityBlock>("endLumi");
produces<ThingWithMerge, edm::Transition::BeginRun>("beginRun");
produces<ThingWithMerge, edm::Transition::EndRun>("endRun");
produces<ThingWithIsEqual>("event");
produces<ThingWithIsEqual, edm::Transition::BeginLuminosityBlock>("beginLumi");
produces<ThingWithIsEqual, edm::Transition::EndLuminosityBlock>("endLumi");
produces<ThingWithIsEqual, edm::Transition::BeginRun>("beginRun");
produces<ThingWithIsEqual, edm::Transition::EndRun>("endRun");
const std::string s_prod("PROD");
for (auto const& label : labelsToGet_) {
consumes<Thing>(edm::InputTag(label, "event", s_prod));
consumes<Thing, edm::InLumi>(edm::InputTag(label, "beginLumi", s_prod));
consumes<Thing, edm::InLumi>(edm::InputTag(label, "endLumi", s_prod));
consumes<Thing, edm::InRun>(edm::InputTag(label, "beginRun", s_prod));
consumes<Thing, edm::InRun>(edm::InputTag(label, "endRun", s_prod));
}
}
ThingWithMergeProducer::~ThingWithMergeProducer() {}
void ThingWithMergeProducer::produce(edm::Event& e, edm::EventSetup const&) {
// The purpose of this first getByLabel call is to cause the products
// that are "put" below to have a parent so we can do tests with the
// parentage provenance.
for (Iter iter = labelsToGet_.begin(), ie = labelsToGet_.end(); iter != ie; ++iter) {
edm::Handle<Thing> h;
edm::InputTag tag(*iter, "event", "PROD");
e.getByLabel(tag, h);
}
auto result = std::make_unique<Thing>();
result->a = 11;
if (!noPut_)
e.put(std::move(result), std::string("event"));
auto result2 = std::make_unique<ThingWithMerge>();
result2->a = 12;
if (!noPut_)
e.put(std::move(result2), std::string("event"));
auto result3 = std::make_unique<ThingWithIsEqual>();
result3->a = 13;
if (changeIsEqualValue_)
result3->a = 14;
if (!noPut_)
e.put(std::move(result3), std::string("event"));
}
void ThingWithMergeProducer::beginLuminosityBlockProduce(edm::LuminosityBlock& lb, edm::EventSetup const&) {
auto result = std::make_unique<Thing>();
result->a = 101;
if (!noPut_)
lb.put(std::move(result), "beginLumi");
auto result2 = std::make_unique<ThingWithMerge>();
result2->a = 102;
if (!noPut_)
lb.put(std::move(result2), "beginLumi");
auto result3 = std::make_unique<ThingWithIsEqual>();
result3->a = 103;
if (changeIsEqualValue_)
result3->a = 104;
if (!noPut_)
lb.put(std::move(result3), "beginLumi");
}
void ThingWithMergeProducer::endLuminosityBlockProduce(edm::LuminosityBlock& lb, edm::EventSetup const&) {
auto result = std::make_unique<Thing>();
result->a = 1001;
if (!noPut_)
lb.put(std::move(result), "endLumi");
auto result2 = std::make_unique<ThingWithMerge>();
result2->a = 1002;
if (!noPut_)
lb.put(std::move(result2), "endLumi");
auto result3 = std::make_unique<ThingWithIsEqual>();
result3->a = 1003;
if (changeIsEqualValue_)
result3->a = 1004;
if (!noPut_)
lb.put(std::move(result3), "endLumi");
}
// Functions that gets called by framework every run
void ThingWithMergeProducer::beginRunProduce(edm::Run& r, edm::EventSetup const&) {
auto result = std::make_unique<Thing>();
result->a = 10001;
if (!noPut_)
r.put(std::move(result), "beginRun");
auto result2 = std::make_unique<ThingWithMerge>();
result2->a = 10002;
if (!noPut_)
r.put(std::move(result2), "beginRun");
auto result3 = std::make_unique<ThingWithIsEqual>();
result3->a = 10003;
if (changeIsEqualValue_)
result3->a = 10004;
if (!noPut_)
r.put(std::move(result3), "beginRun");
}
void ThingWithMergeProducer::endRunProduce(edm::Run& r, edm::EventSetup const&) {
auto result = std::make_unique<Thing>();
result->a = 100001;
if (!noPut_)
r.put(std::move(result), "endRun");
auto result2 = std::make_unique<ThingWithMerge>();
result2->a = 100002;
if (!noPut_)
r.put(std::move(result2), "endRun");
auto result3 = std::make_unique<ThingWithIsEqual>();
result3->a = 100003;
if (changeIsEqualValue_)
result3->a = 100004;
if (!noPut_)
r.put(std::move(result3), "endRun");
}
void ThingWithMergeProducer::beginLuminosityBlock(edm::LuminosityBlock const& lb, edm::EventSetup const&) {
for (Iter iter = labelsToGet_.begin(), ie = labelsToGet_.end(); iter != ie; ++iter) {
edm::Handle<Thing> h;
edm::InputTag tag(*iter, "beginLumi", "PROD");
lb.getByLabel(tag, h);
}
}
void ThingWithMergeProducer::endLuminosityBlock(edm::LuminosityBlock const& lb, edm::EventSetup const&) {
for (Iter iter = labelsToGet_.begin(), ie = labelsToGet_.end(); iter != ie; ++iter) {
edm::Handle<Thing> h;
edm::InputTag tag(*iter, "endLumi", "PROD");
lb.getByLabel(tag, h);
}
}
// Functions that gets called by framework every run
void ThingWithMergeProducer::beginRun(edm::Run const& r, edm::EventSetup const&) {
for (Iter iter = labelsToGet_.begin(), ie = labelsToGet_.end(); iter != ie; ++iter) {
edm::Handle<Thing> h;
edm::InputTag tag(*iter, "beginRun", "PROD");
r.getByLabel(tag, h);
}
}
void ThingWithMergeProducer::endRun(edm::Run const& r, edm::EventSetup const&) {
for (Iter iter = labelsToGet_.begin(), ie = labelsToGet_.end(); iter != ie; ++iter) {
edm::Handle<Thing> h;
edm::InputTag tag(*iter, "endRun", "PROD");
r.getByLabel(tag, h);
}
}
void ThingWithMergeProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.addUntracked<bool>("changeIsEqualValue", false);
desc.addUntracked<std::vector<std::string>>("labelsToGet", std::vector<std::string>());
desc.addUntracked<bool>("noPut", false);
descriptions.add("thingWithMergeProducer", desc);
}
} // namespace edmtest
using edmtest::ThingWithMergeProducer;
DEFINE_FWK_MODULE(ThingWithMergeProducer);
|