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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
|
#include "DataFormats/L1Scouting/interface/L1ScoutingBMTFStub.h"
#include "DataFormats/L1Scouting/interface/L1ScoutingMuon.h"
#include "DataFormats/L1Scouting/interface/L1ScoutingCalo.h"
#include "DataFormats/L1Scouting/interface/OrbitCollection.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/global/EDAnalyzer.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/StreamID.h"
#include <memory>
#include <utility>
#include <vector>
namespace edmtest {
using namespace l1ScoutingRun3;
class TestReadL1Scouting : public edm::global::EDAnalyzer<> {
public:
TestReadL1Scouting(edm::ParameterSet const&);
void analyze(edm::StreamID, edm::Event const&, edm::EventSetup const&) const override;
static void fillDescriptions(edm::ConfigurationDescriptions&);
private:
void analyzeMuons(edm::Event const& iEvent) const;
void analyzeJets(edm::Event const& iEvent) const;
void analyzeEGammas(edm::Event const& iEvent) const;
void analyzeTaus(edm::Event const& iEvent) const;
void analyzeBxSums(edm::Event const& iEvent) const;
void analyzeBmtfStubs(edm::Event const& iEvent) const;
void throwWithMessageFromConstructor(const char*) const;
void throwWithMessage(const char*) const;
const std::vector<unsigned int> bxValues_;
const std::vector<int> expectedMuonValues_;
const edm::EDGetTokenT<OrbitCollection<l1ScoutingRun3::Muon>> muonsToken_;
const std::vector<int> expectedJetValues_;
const edm::EDGetTokenT<OrbitCollection<l1ScoutingRun3::Jet>> jetsToken_;
const std::vector<int> expectedEGammaValues_;
const edm::EDGetTokenT<OrbitCollection<l1ScoutingRun3::EGamma>> eGammasToken_;
const std::vector<int> expectedTauValues_;
const edm::EDGetTokenT<OrbitCollection<l1ScoutingRun3::Tau>> tausToken_;
const std::vector<int> expectedBxSumsValues_;
const edm::EDGetTokenT<OrbitCollection<l1ScoutingRun3::BxSums>> bxSumsToken_;
const int bmtfStubClassVersion_;
const std::vector<int> expectedBmtfStubValues_;
const edm::EDGetTokenT<OrbitCollection<l1ScoutingRun3::BMTFStub>> bmtfStubToken_;
};
TestReadL1Scouting::TestReadL1Scouting(edm::ParameterSet const& iPSet)
: bxValues_(iPSet.getParameter<std::vector<unsigned>>("bxValues")),
expectedMuonValues_(iPSet.getParameter<std::vector<int>>("expectedMuonValues")),
muonsToken_(consumes(iPSet.getParameter<edm::InputTag>("muonsTag"))),
expectedJetValues_(iPSet.getParameter<std::vector<int>>("expectedJetValues")),
jetsToken_(consumes(iPSet.getParameter<edm::InputTag>("jetsTag"))),
expectedEGammaValues_(iPSet.getParameter<std::vector<int>>("expectedEGammaValues")),
eGammasToken_(consumes(iPSet.getParameter<edm::InputTag>("eGammasTag"))),
expectedTauValues_(iPSet.getParameter<std::vector<int>>("expectedTauValues")),
tausToken_(consumes(iPSet.getParameter<edm::InputTag>("tausTag"))),
expectedBxSumsValues_(iPSet.getParameter<std::vector<int>>("expectedBxSumsValues")),
bxSumsToken_(consumes(iPSet.getParameter<edm::InputTag>("bxSumsTag"))),
bmtfStubClassVersion_(iPSet.getParameter<int>("bmtfStubClassVersion")),
expectedBmtfStubValues_(iPSet.getParameter<std::vector<int>>("expectedBmtfStubValues")),
bmtfStubToken_(consumes(iPSet.getParameter<edm::InputTag>("bmtfStubTag"))) {
if (bxValues_.size() != 2) {
throwWithMessageFromConstructor("bxValues must have 2 elements and it does not");
}
if (expectedMuonValues_.size() != 3) {
throwWithMessageFromConstructor("muonValues must have 3 elements and it does not");
}
if (expectedJetValues_.size() != 4) {
throwWithMessageFromConstructor("jetValues must have 4 elements and it does not");
}
if (expectedEGammaValues_.size() != 3) {
throwWithMessageFromConstructor("eGammaValues must have 3 elements and it does not");
}
if (expectedTauValues_.size() != 2) {
throwWithMessageFromConstructor("tauValues must have 2 elements and it does not");
}
if (expectedBxSumsValues_.size() != 1) {
throwWithMessageFromConstructor("bxSumsValues_ must have 1 elements and it does not");
}
if (expectedBmtfStubValues_.size() != 2) {
throwWithMessageFromConstructor("bmtfStubValues_ must have 2 elements and it does not");
}
}
void TestReadL1Scouting::analyze(edm::StreamID, edm::Event const& iEvent, edm::EventSetup const&) const {
analyzeMuons(iEvent);
analyzeJets(iEvent);
analyzeEGammas(iEvent);
analyzeTaus(iEvent);
analyzeBxSums(iEvent);
analyzeBmtfStubs(iEvent);
}
void TestReadL1Scouting::analyzeMuons(edm::Event const& iEvent) const {
auto const& muonsCollection = iEvent.get(muonsToken_);
for (const unsigned& bx : bxValues_) {
unsigned nMuons = muonsCollection.getBxSize(bx);
if (nMuons != expectedMuonValues_.size()) {
throwWithMessage("analyzeMuons, muons do not have the expected bx size");
}
const auto& muons = muonsCollection.bxIterator(bx);
for (unsigned i = 0; i < nMuons; i++) {
if (muons[i].hwPt() != expectedMuonValues_[i]) {
throwWithMessage("analyzeMuons, hwPt does not match the expected value");
}
if (muons[i].hwEta() != expectedMuonValues_[i]) {
throwWithMessage("analyzeMuons, hwEta does not match the expected value");
}
if (muons[i].hwPhi() != expectedMuonValues_[i]) {
throwWithMessage("analyzeMuons, hwPhi does not match the expected value");
}
if (muons[i].hwQual() != expectedMuonValues_[i]) {
throwWithMessage("analyzeMuons, hwQual does not match the expected value");
}
if (muons[i].hwCharge() != expectedMuonValues_[i]) {
throwWithMessage("analyzeMuons, hwCharge does not match the expected value");
}
if (muons[i].hwChargeValid() != expectedMuonValues_[i]) {
throwWithMessage("analyzeMuons, hwChargeValid does not match the expected value");
}
if (muons[i].hwIso() != expectedMuonValues_[i]) {
throwWithMessage("analyzeMuons, hwIso does not match the expected value");
}
if (muons[i].hwIndex() != expectedMuonValues_[i]) {
throwWithMessage("analyzeMuons, hwIndex does not match the expected value");
}
if (muons[i].hwEtaAtVtx() != expectedMuonValues_[i]) {
throwWithMessage("analyzeMuons, hwEtaAtVtx does not match the expected value");
}
if (muons[i].hwPhiAtVtx() != expectedMuonValues_[i]) {
throwWithMessage("analyzeMuons, hwPhiAtVtx does not match the expected value");
}
if (muons[i].hwPtUnconstrained() != expectedMuonValues_[i]) {
throwWithMessage("analyzeMuons, hwPtUnconstrained does not match the expected value");
}
if (muons[i].hwDXY() != expectedMuonValues_[i]) {
throwWithMessage("analyzeMuons, hwDXY does not match the expected value");
}
if (muons[i].tfMuonIndex() != expectedMuonValues_[i]) {
throwWithMessage("analyzeMuons, tfMuonIndex does not match the expected value");
}
}
}
}
void TestReadL1Scouting::analyzeJets(edm::Event const& iEvent) const {
auto const& jetsCollection = iEvent.get(jetsToken_);
for (const unsigned& bx : bxValues_) {
unsigned nJets = jetsCollection.getBxSize(bx);
if (nJets != expectedJetValues_.size()) {
throwWithMessage("analyzeJets, jets do not have the expected bx size");
}
const auto& jets = jetsCollection.bxIterator(bx);
for (unsigned i = 0; i < nJets; i++) {
if (jets[i].hwEt() != expectedJetValues_[i]) {
throwWithMessage("analyzeJets, hwEt does not match the expected value");
}
if (jets[i].hwEta() != expectedJetValues_[i]) {
throwWithMessage("analyzeJets, hwEta does not match the expected value");
}
if (jets[i].hwPhi() != expectedJetValues_[i]) {
throwWithMessage("analyzeJets, hwPhi does not match the expected value");
}
if (jets[i].hwIso() != expectedJetValues_[i]) {
throwWithMessage("analyzeJets, hwIso does not match the expected value");
}
}
}
}
void TestReadL1Scouting::analyzeEGammas(edm::Event const& iEvent) const {
auto const& eGammasCollection = iEvent.get(eGammasToken_);
for (const unsigned& bx : bxValues_) {
unsigned nEGammas = eGammasCollection.getBxSize(bx);
if (nEGammas != expectedEGammaValues_.size()) {
throwWithMessage("analyzeEGammas, egammas do not have the expected bx size");
}
const auto& eGammas = eGammasCollection.bxIterator(bx);
for (unsigned i = 0; i < nEGammas; i++) {
if (eGammas[i].hwEt() != expectedEGammaValues_[i]) {
throwWithMessage("analyzeEGammas, hwEt does not match the expected value");
}
if (eGammas[i].hwEta() != expectedEGammaValues_[i]) {
throwWithMessage("analyzeEGammas, hwEta does not match the expected value");
}
if (eGammas[i].hwPhi() != expectedEGammaValues_[i]) {
throwWithMessage("analyzeEGammas, hwPhi does not match the expected value");
}
if (eGammas[i].hwIso() != expectedEGammaValues_[i]) {
throwWithMessage("analyzeEGammas, hwIso does not match the expected value");
}
}
}
}
void TestReadL1Scouting::analyzeTaus(edm::Event const& iEvent) const {
auto const& tausCollection = iEvent.get(tausToken_);
for (const unsigned& bx : bxValues_) {
unsigned nTaus = tausCollection.getBxSize(bx);
if (nTaus != expectedTauValues_.size()) {
throwWithMessage("analyzeTaus, taus do not have the expected bx size");
}
const auto& taus = tausCollection.bxIterator(bx);
for (unsigned i = 0; i < nTaus; i++) {
if (taus[i].hwEt() != expectedTauValues_[i]) {
throwWithMessage("analyzeTaus, hwEt does not match the expected value");
}
if (taus[i].hwEta() != expectedTauValues_[i]) {
throwWithMessage("analyzeTaus, hwEta does not match the expected value");
}
if (taus[i].hwPhi() != expectedTauValues_[i]) {
throwWithMessage("analyzeTaus, hwPhi does not match the expected value");
}
if (taus[i].hwIso() != expectedTauValues_[i]) {
throwWithMessage("analyzeTaus, hwIso does not match the expected value");
}
}
}
}
void TestReadL1Scouting::analyzeBxSums(edm::Event const& iEvent) const {
auto const& bxSumsCollection = iEvent.get(bxSumsToken_);
for (const unsigned& bx : bxValues_) {
unsigned nSums = bxSumsCollection.getBxSize(bx);
if (nSums != expectedBxSumsValues_.size()) {
throwWithMessage("analyzeBxSums, sums do not have the expected bx size");
}
const auto& sums = bxSumsCollection.bxIterator(bx);
for (unsigned i = 0; i < nSums; i++) {
if (sums[i].hwTotalEt() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, hwTotalEt does not match the expected value");
}
if (sums[i].hwTotalEtEm() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, hwTotalEtEm does not match the expected value");
}
if (sums[i].hwTotalHt() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, hwTotalHt does not match the expected value");
}
if (sums[i].hwMissEt() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, hwMissEt does not match the expected value");
}
if (sums[i].hwMissEtPhi() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, hwMissEtPhi does not match the expected value");
}
if (sums[i].hwMissHt() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, hwMissHt does not match the expected value");
}
if (sums[i].hwMissHtPhi() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, hwMissHtPhi does not match the expected value");
}
if (sums[i].hwMissEtHF() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, hwMissEtHF does not match the expected value");
}
if (sums[i].hwMissEtHFPhi() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, hwMissEtHFPhi does not match the expected value");
}
if (sums[i].hwMissHtHF() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, hwMissHtHFPhi does not match the expected value");
}
if (sums[i].hwAsymEt() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, hwAsymEt does not match the expected value");
}
if (sums[i].hwAsymHt() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, hwAsymHt does not match the expected value");
}
if (sums[i].hwAsymEtHF() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, hwAsymEtHF does not match the expected value");
}
if (sums[i].hwAsymHtHF() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, hwAsymHtHF does not match the expected value");
}
if (sums[i].minBiasHFP0() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, minBiasHFP0 does not match the expected value");
}
if (sums[i].minBiasHFM0() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, minBiasHFM0 does not match the expected value");
}
if (sums[i].minBiasHFP1() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, minBiasHFP1 does not match the expected value");
}
if (sums[i].minBiasHFM1() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, minBiasHFM1 does not match the expected value");
}
if (sums[i].towerCount() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, towerCount does not match the expected value");
}
if (sums[i].centrality() != expectedBxSumsValues_[i]) {
throwWithMessage("analyzeBxSums, centrality does not match the expected value");
}
}
}
}
void TestReadL1Scouting::analyzeBmtfStubs(edm::Event const& iEvent) const {
if (bmtfStubClassVersion_ < 3) {
return;
}
auto const& stubsCollection = iEvent.get(bmtfStubToken_);
for (const unsigned& bx : bxValues_) {
unsigned nStubs = stubsCollection.getBxSize(bx);
if (nStubs != expectedBmtfStubValues_.size()) {
throwWithMessage("analyzeBmtfStubs, stubs do not have the expected bx size");
}
const auto& stubs = stubsCollection.bxIterator(bx);
for (unsigned i = 0; i < nStubs; i++) {
if (stubs[i].hwPhi() != (expectedBmtfStubValues_[i] + 8)) {
throwWithMessage("analyzeBmtfStubs, hwPhi does not match the expected value");
}
if (stubs[i].hwPhiB() != (expectedBmtfStubValues_[i] + 7)) {
throwWithMessage("analyzeBmtfStubs, hwPhiB does not match the expected value");
}
if (stubs[i].hwQual() != (expectedBmtfStubValues_[i] + 6)) {
throwWithMessage("analyzeBmtfStubs, hwQual does not match the expected value");
}
if (stubs[i].hwEta() != (expectedBmtfStubValues_[i] + 5)) {
throwWithMessage("analyzeBmtfStubs, hwEta does not match the expected value");
}
if (stubs[i].hwQEta() != (expectedBmtfStubValues_[i] + 4)) {
throwWithMessage("analyzeBmtfStubs, hwQEta does not match the expected value");
}
if (stubs[i].station() != (expectedBmtfStubValues_[i] + 3)) {
throwWithMessage("analyzeBmtfStubs, station does not match the expected value");
}
if (stubs[i].wheel() != (expectedBmtfStubValues_[i] + 2)) {
throwWithMessage("analyzeBmtfStubs, wheel does not match the expected value");
}
if (stubs[i].sector() != (expectedBmtfStubValues_[i] + 1)) {
throwWithMessage("analyzeBmtfStubs, sector does not match the expected value");
}
if (stubs[i].tag() != (expectedBmtfStubValues_[i])) {
throwWithMessage("analyzeBmtfStubs, tag does not match the expected value");
}
}
}
}
void TestReadL1Scouting::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<std::vector<unsigned int>>("bxValues");
desc.add<std::vector<int>>("expectedMuonValues");
desc.add<edm::InputTag>("muonsTag");
desc.add<std::vector<int>>("expectedJetValues");
desc.add<edm::InputTag>("jetsTag");
desc.add<std::vector<int>>("expectedEGammaValues");
desc.add<edm::InputTag>("eGammasTag");
desc.add<std::vector<int>>("expectedTauValues");
desc.add<edm::InputTag>("tausTag");
desc.add<std::vector<int>>("expectedBxSumsValues");
desc.add<edm::InputTag>("bxSumsTag");
desc.add<int>("bmtfStubClassVersion");
desc.add<std::vector<int>>("expectedBmtfStubValues");
desc.add<edm::InputTag>("bmtfStubTag");
descriptions.addDefault(desc);
}
void TestReadL1Scouting::throwWithMessageFromConstructor(const char* msg) const {
throw cms::Exception("TestFailure") << "TestReadL1Scouting constructor, test configuration error, " << msg;
}
void TestReadL1Scouting::throwWithMessage(const char* msg) const {
throw cms::Exception("TestFailure") << "TestReadL1Scouting analyzer, " << msg;
}
} // namespace edmtest
using edmtest::TestReadL1Scouting;
DEFINE_FWK_MODULE(TestReadL1Scouting);
|