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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
|
#include "HLTDoubletDZ.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/EgammaCandidates/interface/Electron.h"
#include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoChargedCandidateFwd.h"
#include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
#include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
#include "DataFormats/L1TMuonPhase2/interface/TrackerMuon.h"
#include "DataFormats/L1TParticleFlow/interface/HPSPFTau.h"
#include "DataFormats/L1TParticleFlow/interface/HPSPFTauFwd.h"
#include "DataFormats/L1TParticleFlow/interface/PFTau.h"
#include "DataFormats/Math/interface/deltaR.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include <cmath>
template <typename T1, typename T2>
HLTDoubletDZ<T1, T2>::HLTDoubletDZ(edm::ParameterSet const& iConfig)
: HLTFilter(iConfig),
originTag1_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag1")),
originTag2_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag2")),
inputTag1_(iConfig.getParameter<edm::InputTag>("inputTag1")),
inputTag2_(iConfig.getParameter<edm::InputTag>("inputTag2")),
inputToken1_(consumes(inputTag1_)),
inputToken2_(consumes(inputTag2_)),
electronToken_(edm::EDGetTokenT<reco::ElectronCollection>()),
triggerType1_(iConfig.getParameter<int>("triggerType1")),
triggerType2_(iConfig.getParameter<int>("triggerType2")),
minDR_(iConfig.getParameter<double>("MinDR")),
minDR2_(minDR_ * minDR_),
maxDZ_(iConfig.getParameter<double>("MaxDZ")),
min_N_(iConfig.getParameter<int>("MinN")),
minPixHitsForDZ_(iConfig.getParameter<int>("MinPixHitsForDZ")),
checkSC_(iConfig.getParameter<bool>("checkSC")),
same_(inputTag1_.encode() == inputTag2_.encode()) // same collections to be compared?
{}
template <>
HLTDoubletDZ<l1t::P2GTCandidate, l1t::P2GTCandidate>::HLTDoubletDZ(const edm::ParameterSet& iConfig)
: HLTFilter(iConfig),
originTag1_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag1")),
originTag2_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag2")),
electronToken_(edm::EDGetTokenT<reco::ElectronCollection>()),
l1GTAlgoBlockTag_(iConfig.template getParameter<edm::InputTag>("l1GTAlgoBlockTag")),
algoBlockToken_(consumes<l1t::P2GTAlgoBlockMap>(l1GTAlgoBlockTag_)),
l1GTAlgoName1_(iConfig.template getParameter<std::string>("l1GTAlgoName1")),
l1GTAlgoName2_(iConfig.template getParameter<std::string>("l1GTAlgoName2")),
triggerType1_(iConfig.getParameter<int>("triggerType1")),
triggerType2_(iConfig.getParameter<int>("triggerType2")),
minDR_(iConfig.getParameter<double>("MinDR")),
minDR2_(minDR_ * minDR_),
maxDZ_(iConfig.getParameter<double>("MaxDZ")),
min_N_(iConfig.getParameter<int>("MinN")),
minPixHitsForDZ_(iConfig.getParameter<int>("MinPixHitsForDZ")),
checkSC_(iConfig.getParameter<bool>("checkSC")),
same_(l1GTAlgoName1_ == l1GTAlgoName2_) // same collections to be compared?
{}
template <>
HLTDoubletDZ<reco::RecoEcalCandidate, reco::RecoEcalCandidate>::HLTDoubletDZ(const edm::ParameterSet& iConfig)
: HLTFilter(iConfig),
originTag1_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag1")),
originTag2_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag2")),
inputTag1_(iConfig.getParameter<edm::InputTag>("inputTag1")),
inputTag2_(iConfig.getParameter<edm::InputTag>("inputTag2")),
inputToken1_(consumes(inputTag1_)),
inputToken2_(consumes(inputTag2_)),
electronToken_(consumes(iConfig.getParameter<edm::InputTag>("electronTag"))),
triggerType1_(iConfig.getParameter<int>("triggerType1")),
triggerType2_(iConfig.getParameter<int>("triggerType2")),
minDR_(iConfig.getParameter<double>("MinDR")),
minDR2_(minDR_ * minDR_),
maxDZ_(iConfig.getParameter<double>("MaxDZ")),
min_N_(iConfig.getParameter<int>("MinN")),
minPixHitsForDZ_(iConfig.getParameter<int>("MinPixHitsForDZ")),
checkSC_(iConfig.getParameter<bool>("checkSC")),
same_(inputTag1_.encode() == inputTag2_.encode()) // same collections to be compared?
{}
template <>
HLTDoubletDZ<reco::RecoChargedCandidate, reco::RecoEcalCandidate>::HLTDoubletDZ(const edm::ParameterSet& iConfig)
: HLTFilter(iConfig),
originTag1_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag1")),
originTag2_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag2")),
inputTag1_(iConfig.getParameter<edm::InputTag>("inputTag1")),
inputTag2_(iConfig.getParameter<edm::InputTag>("inputTag2")),
inputToken1_(consumes(inputTag1_)),
inputToken2_(consumes(inputTag2_)),
electronToken_(consumes(iConfig.getParameter<edm::InputTag>("electronTag"))),
triggerType1_(iConfig.getParameter<int>("triggerType1")),
triggerType2_(iConfig.getParameter<int>("triggerType2")),
minDR_(iConfig.getParameter<double>("MinDR")),
minDR2_(minDR_ * minDR_),
maxDZ_(iConfig.getParameter<double>("MaxDZ")),
min_N_(iConfig.getParameter<int>("MinN")),
minPixHitsForDZ_(iConfig.getParameter<int>("MinPixHitsForDZ")),
checkSC_(iConfig.getParameter<bool>("checkSC")),
same_(inputTag1_.encode() == inputTag2_.encode()) // same collections to be compared?
{}
template <>
HLTDoubletDZ<reco::RecoEcalCandidate, reco::RecoChargedCandidate>::HLTDoubletDZ(const edm::ParameterSet& iConfig)
: HLTFilter(iConfig),
originTag1_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag1")),
originTag2_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag2")),
inputTag1_(iConfig.getParameter<edm::InputTag>("inputTag1")),
inputTag2_(iConfig.getParameter<edm::InputTag>("inputTag2")),
inputToken1_(consumes(inputTag1_)),
inputToken2_(consumes(inputTag2_)),
electronToken_(consumes(iConfig.getParameter<edm::InputTag>("electronTag"))),
triggerType1_(iConfig.getParameter<int>("triggerType1")),
triggerType2_(iConfig.getParameter<int>("triggerType2")),
minDR_(iConfig.getParameter<double>("MinDR")),
minDR2_(minDR_ * minDR_),
maxDZ_(iConfig.getParameter<double>("MaxDZ")),
min_N_(iConfig.getParameter<int>("MinN")),
minPixHitsForDZ_(iConfig.getParameter<int>("MinPixHitsForDZ")),
checkSC_(iConfig.getParameter<bool>("checkSC")),
same_(inputTag1_.encode() == inputTag2_.encode()) // same collections to be compared?
{}
template <>
HLTDoubletDZ<l1t::TrackerMuon, l1t::TrackerMuon>::HLTDoubletDZ(const edm::ParameterSet& iConfig)
: HLTFilter(iConfig),
originTag1_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag1")),
originTag2_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag2")),
inputTag1_(iConfig.getParameter<edm::InputTag>("inputTag1")),
inputTag2_(iConfig.getParameter<edm::InputTag>("inputTag2")),
inputToken1_(consumes(inputTag1_)),
inputToken2_(consumes(inputTag2_)),
electronToken_(edm::EDGetTokenT<reco::ElectronCollection>()),
triggerType1_(iConfig.getParameter<int>("triggerType1")),
triggerType2_(iConfig.getParameter<int>("triggerType2")),
minDR_(iConfig.getParameter<double>("MinDR")),
minDR2_(minDR_ * minDR_),
maxDZ_(iConfig.getParameter<double>("MaxDZ")),
min_N_(iConfig.getParameter<int>("MinN")),
minPixHitsForDZ_(0),
checkSC_(false),
same_(inputTag1_.encode() == inputTag2_.encode()) // same collections to be compared?
{}
template <>
HLTDoubletDZ<l1t::PFTau, l1t::PFTau>::HLTDoubletDZ(const edm::ParameterSet& iConfig)
: HLTFilter(iConfig),
originTag1_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag1")),
originTag2_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag2")),
inputTag1_(iConfig.getParameter<edm::InputTag>("inputTag1")),
inputTag2_(iConfig.getParameter<edm::InputTag>("inputTag2")),
inputToken1_(consumes(inputTag1_)),
inputToken2_(consumes(inputTag2_)),
electronToken_(edm::EDGetTokenT<reco::ElectronCollection>()),
triggerType1_(iConfig.getParameter<int>("triggerType1")),
triggerType2_(iConfig.getParameter<int>("triggerType2")),
minDR_(iConfig.getParameter<double>("MinDR")),
minDR2_(minDR_ * minDR_),
maxDZ_(iConfig.getParameter<double>("MaxDZ")),
min_N_(iConfig.getParameter<int>("MinN")),
minPixHitsForDZ_(0),
checkSC_(false),
same_(inputTag1_.encode() == inputTag2_.encode()) // same collections to be compared?
{}
template <>
HLTDoubletDZ<l1t::HPSPFTau, l1t::HPSPFTau>::HLTDoubletDZ(const edm::ParameterSet& iConfig)
: HLTFilter(iConfig),
originTag1_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag1")),
originTag2_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag2")),
inputTag1_(iConfig.getParameter<edm::InputTag>("inputTag1")),
inputTag2_(iConfig.getParameter<edm::InputTag>("inputTag2")),
inputToken1_(consumes(inputTag1_)),
inputToken2_(consumes(inputTag2_)),
electronToken_(edm::EDGetTokenT<reco::ElectronCollection>()),
triggerType1_(iConfig.getParameter<int>("triggerType1")),
triggerType2_(iConfig.getParameter<int>("triggerType2")),
minDR_(iConfig.getParameter<double>("MinDR")),
minDR2_(minDR_ * minDR_),
maxDZ_(iConfig.getParameter<double>("MaxDZ")),
min_N_(iConfig.getParameter<int>("MinN")),
minPixHitsForDZ_(0),
checkSC_(false),
same_(inputTag1_.encode() == inputTag2_.encode()) // same collections to be compared?
{}
template <>
void HLTDoubletDZ<l1t::P2GTCandidate, l1t::P2GTCandidate>::fillDescriptions(
edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
makeHLTFilterDescription(desc);
desc.add<std::vector<edm::InputTag>>("originTag1", {edm::InputTag("hltOriginal1")});
desc.add<std::vector<edm::InputTag>>("originTag2", {edm::InputTag("hltOriginal2")});
desc.add<edm::InputTag>("l1GTAlgoBlockTag", edm::InputTag("l1tGTAlgoBlockProducer"));
desc.add<std::string>("l1GTAlgoName1", "");
desc.add<std::string>("l1GTAlgoName2", "");
desc.add<int>("triggerType1", 0);
desc.add<int>("triggerType2", 0);
desc.add<double>("MinDR", -1.0);
desc.add<double>("MaxDZ", 0.2);
desc.add<int>("MinPixHitsForDZ", 0);
desc.add<bool>("checkSC", false);
desc.add<int>("MinN", 1);
descriptions.addWithDefaultLabel(desc);
}
template <typename T1, typename T2>
void HLTDoubletDZ<T1, T2>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
makeHLTFilterDescription(desc);
desc.add<std::vector<edm::InputTag>>("originTag1", {edm::InputTag("hltOriginal1")});
desc.add<std::vector<edm::InputTag>>("originTag2", {edm::InputTag("hltOriginal2")});
desc.add<edm::InputTag>("inputTag1", edm::InputTag("hltFiltered1"));
desc.add<edm::InputTag>("inputTag2", edm::InputTag("hltFiltered2"));
desc.add<int>("triggerType1", 0);
desc.add<int>("triggerType2", 0);
desc.add<double>("MinDR", -1.0);
desc.add<double>("MaxDZ", 0.2);
desc.add<int>("MinN", 1);
desc.add<int>("MinPixHitsForDZ", 0);
desc.add<bool>("checkSC", false);
descriptions.addWithDefaultLabel(desc);
}
template <>
void HLTDoubletDZ<reco::RecoEcalCandidate, reco::RecoEcalCandidate>::fillDescriptions(
edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
makeHLTFilterDescription(desc);
desc.add<std::vector<edm::InputTag>>("originTag1", {edm::InputTag("hltOriginal1")});
desc.add<std::vector<edm::InputTag>>("originTag2", {edm::InputTag("hltOriginal2")});
desc.add<edm::InputTag>("inputTag1", edm::InputTag("hltFiltered1"));
desc.add<edm::InputTag>("inputTag2", edm::InputTag("hltFiltered2"));
desc.add<edm::InputTag>("electronTag", edm::InputTag("electronTag"));
desc.add<int>("triggerType1", 0);
desc.add<int>("triggerType2", 0);
desc.add<double>("MinDR", -1.0);
desc.add<double>("MaxDZ", 0.2);
desc.add<int>("MinN", 1);
desc.add<int>("MinPixHitsForDZ", 0);
desc.add<bool>("checkSC", false);
descriptions.addWithDefaultLabel(desc);
}
template <>
void HLTDoubletDZ<reco::RecoChargedCandidate, reco::RecoEcalCandidate>::fillDescriptions(
edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
makeHLTFilterDescription(desc);
desc.add<std::vector<edm::InputTag>>("originTag1", {edm::InputTag("hltOriginal1")});
desc.add<std::vector<edm::InputTag>>("originTag2", {edm::InputTag("hltOriginal2")});
desc.add<edm::InputTag>("inputTag1", edm::InputTag("hltFiltered1"));
desc.add<edm::InputTag>("inputTag2", edm::InputTag("hltFiltered2"));
desc.add<edm::InputTag>("electronTag", edm::InputTag("electronTag"));
desc.add<int>("triggerType1", 0);
desc.add<int>("triggerType2", 0);
desc.add<double>("MinDR", -1.0);
desc.add<double>("MaxDZ", 0.2);
desc.add<int>("MinN", 1);
desc.add<int>("MinPixHitsForDZ", 0);
desc.add<bool>("checkSC", false);
descriptions.addWithDefaultLabel(desc);
}
template <>
void HLTDoubletDZ<reco::RecoEcalCandidate, reco::RecoChargedCandidate>::fillDescriptions(
edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
makeHLTFilterDescription(desc);
desc.add<std::vector<edm::InputTag>>("originTag1", {edm::InputTag("hltOriginal1")});
desc.add<std::vector<edm::InputTag>>("originTag2", {edm::InputTag("hltOriginal2")});
desc.add<edm::InputTag>("inputTag1", edm::InputTag("hltFiltered1"));
desc.add<edm::InputTag>("inputTag2", edm::InputTag("hltFiltered2"));
desc.add<edm::InputTag>("electronTag", edm::InputTag("electronTag"));
desc.add<int>("triggerType1", 0);
desc.add<int>("triggerType2", 0);
desc.add<double>("MinDR", -1.0);
desc.add<double>("MaxDZ", 0.2);
desc.add<int>("MinN", 1);
desc.add<int>("MinPixHitsForDZ", 0);
desc.add<bool>("checkSC", false);
descriptions.addWithDefaultLabel(desc);
}
template <>
void HLTDoubletDZ<l1t::TrackerMuon, l1t::TrackerMuon>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
makeHLTFilterDescription(desc);
desc.add<std::vector<edm::InputTag>>("originTag1", {edm::InputTag("hltOriginal1")});
desc.add<std::vector<edm::InputTag>>("originTag2", {edm::InputTag("hltOriginal2")});
desc.add<edm::InputTag>("inputTag1", edm::InputTag("hltFiltered1"));
desc.add<edm::InputTag>("inputTag2", edm::InputTag("hltFiltered2"));
desc.add<int>("triggerType1", 0);
desc.add<int>("triggerType2", 0);
desc.add<double>("MinDR", -1.0);
desc.add<double>("MaxDZ", 0.2);
desc.add<int>("MinN", 1);
descriptions.addWithDefaultLabel(desc);
}
template <>
void HLTDoubletDZ<l1t::PFTau, l1t::PFTau>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
makeHLTFilterDescription(desc);
desc.add<std::vector<edm::InputTag>>("originTag1", {edm::InputTag("hltOriginal1")});
desc.add<std::vector<edm::InputTag>>("originTag2", {edm::InputTag("hltOriginal2")});
desc.add<edm::InputTag>("inputTag1", edm::InputTag("hltFiltered1"));
desc.add<edm::InputTag>("inputTag2", edm::InputTag("hltFiltered2"));
desc.add<int>("triggerType1", 0);
desc.add<int>("triggerType2", 0);
desc.add<double>("MinDR", -1.0);
desc.add<double>("MaxDZ", 0.2);
desc.add<int>("MinN", 1);
descriptions.addWithDefaultLabel(desc);
}
template <>
void HLTDoubletDZ<l1t::HPSPFTau, l1t::HPSPFTau>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
makeHLTFilterDescription(desc);
desc.add<std::vector<edm::InputTag>>("originTag1", {edm::InputTag("hltOriginal1")});
desc.add<std::vector<edm::InputTag>>("originTag2", {edm::InputTag("hltOriginal2")});
desc.add<edm::InputTag>("inputTag1", edm::InputTag("hltFiltered1"));
desc.add<edm::InputTag>("inputTag2", edm::InputTag("hltFiltered2"));
desc.add<int>("triggerType1", 0);
desc.add<int>("triggerType2", 0);
desc.add<double>("MinDR", -1.0);
desc.add<double>("MaxDZ", 0.2);
desc.add<int>("MinN", 1);
descriptions.addWithDefaultLabel(desc);
}
template <typename T1, typename T2>
bool HLTDoubletDZ<T1, T2>::getCollections(edm::Event const& iEvent,
std::vector<T1Ref>& coll1,
std::vector<T2Ref>& coll2,
trigger::TriggerFilterObjectWithRefs& filterproduct) const {
edm::Handle<trigger::TriggerFilterObjectWithRefs> handle1, handle2;
if (iEvent.getByToken(inputToken1_, handle1) and iEvent.getByToken(inputToken2_, handle2)) {
// get hold of pre-filtered object collections
handle1->getObjects(triggerType1_, coll1);
handle2->getObjects(triggerType2_, coll2);
const trigger::size_type n1(coll1.size());
const trigger::size_type n2(coll2.size());
if (saveTags()) {
edm::InputTag tagOld;
for (unsigned int i = 0; i < originTag1_.size(); ++i) {
filterproduct.addCollectionTag(originTag1_[i]);
}
tagOld = edm::InputTag();
for (trigger::size_type i1 = 0; i1 != n1; ++i1) {
const edm::ProductID pid(coll1[i1].id());
const auto& prov = iEvent.getStableProvenance(pid);
const std::string& label(prov.moduleLabel());
const std::string& instance(prov.productInstanceName());
const std::string& process(prov.processName());
edm::InputTag tagNew(edm::InputTag(label, instance, process));
if (tagOld.encode() != tagNew.encode()) {
filterproduct.addCollectionTag(tagNew);
tagOld = tagNew;
}
}
for (unsigned int i = 0; i < originTag2_.size(); ++i) {
filterproduct.addCollectionTag(originTag2_[i]);
}
tagOld = edm::InputTag();
for (trigger::size_type i2 = 0; i2 != n2; ++i2) {
const edm::ProductID pid(coll2[i2].id());
const auto& prov = iEvent.getStableProvenance(pid);
const std::string& label(prov.moduleLabel());
const std::string& instance(prov.productInstanceName());
const std::string& process(prov.processName());
edm::InputTag tagNew(edm::InputTag(label, instance, process));
if (tagOld.encode() != tagNew.encode()) {
filterproduct.addCollectionTag(tagNew);
tagOld = tagNew;
}
}
}
return true;
}
return false;
}
template <>
bool HLTDoubletDZ<l1t::P2GTCandidate, l1t::P2GTCandidate>::getCollections(
edm::Event const& iEvent,
std::vector<l1t::P2GTCandidateRef>& coll1,
std::vector<l1t::P2GTCandidateRef>& coll2,
trigger::TriggerFilterObjectWithRefs& filterproduct) const {
const l1t::P2GTAlgoBlockMap& algos = iEvent.get(algoBlockToken_);
if (!algos.empty()) {
if (algos.count(l1GTAlgoName1_) > 0 && algos.at(l1GTAlgoName1_).decisionBeforeBxMaskAndPrescale()) {
const l1t::P2GTCandidateVectorRef& objects = algos.at(l1GTAlgoName1_).trigObjects();
for (const l1t::P2GTCandidateRef& obj : objects) {
if ((triggerType1_ == trigger::TriggerObjectType::TriggerL1TkMu && obj->isMuon()) ||
(triggerType1_ == trigger::TriggerObjectType::TriggerL1TkEle && obj->isElectron()) ||
(triggerType1_ == trigger::TriggerObjectType::TriggerL1TkEm && obj->isPhoton())) {
coll1.push_back(obj);
}
}
}
if (algos.count(l1GTAlgoName2_) > 0 && algos.at(l1GTAlgoName2_).decisionBeforeBxMaskAndPrescale()) {
const l1t::P2GTCandidateVectorRef& objects = algos.at(l1GTAlgoName2_).trigObjects();
for (const l1t::P2GTCandidateRef& obj : objects) {
if ((triggerType2_ == trigger::TriggerObjectType::TriggerL1TkMu && obj->isMuon()) ||
(triggerType2_ == trigger::TriggerObjectType::TriggerL1TkEle && obj->isElectron()) ||
(triggerType2_ == trigger::TriggerObjectType::TriggerL1TkEm && obj->isPhoton())) {
coll2.push_back(obj);
}
}
}
}
if (!coll1.empty() && !coll2.empty()) {
const trigger::size_type n1(coll1.size());
const trigger::size_type n2(coll2.size());
if (saveTags()) {
edm::InputTag tagOld;
for (unsigned int i = 0; i < originTag1_.size(); ++i) {
filterproduct.addCollectionTag(originTag1_[i]);
}
tagOld = edm::InputTag();
for (trigger::size_type i1 = 0; i1 != n1; ++i1) {
const edm::ProductID pid(coll1[i1].id());
const auto& prov = iEvent.getStableProvenance(pid);
const std::string& label(prov.moduleLabel());
const std::string& instance(prov.productInstanceName());
const std::string& process(prov.processName());
edm::InputTag tagNew(edm::InputTag(label, instance, process));
if (tagOld.encode() != tagNew.encode()) {
filterproduct.addCollectionTag(tagNew);
tagOld = tagNew;
}
}
for (unsigned int i = 0; i < originTag2_.size(); ++i) {
filterproduct.addCollectionTag(originTag2_[i]);
}
tagOld = edm::InputTag();
for (trigger::size_type i2 = 0; i2 != n2; ++i2) {
const edm::ProductID pid(coll2[i2].id());
const auto& prov = iEvent.getStableProvenance(pid);
const std::string& label(prov.moduleLabel());
const std::string& instance(prov.productInstanceName());
const std::string& process(prov.processName());
edm::InputTag tagNew(edm::InputTag(label, instance, process));
if (tagOld.encode() != tagNew.encode()) {
filterproduct.addCollectionTag(tagNew);
tagOld = tagNew;
}
}
}
return true;
} else
return false;
}
template <typename T1, typename T2>
bool HLTDoubletDZ<T1, T2>::haveSameSuperCluster(T1 const& c1, T2 const& c2) const {
return (c1.superCluster().isNonnull() and c2.superCluster().isNonnull() and (c1.superCluster() == c2.superCluster()));
}
template <>
bool HLTDoubletDZ<l1t::TrackerMuon, l1t::TrackerMuon>::haveSameSuperCluster(l1t::TrackerMuon const&,
l1t::TrackerMuon const&) const {
return false;
}
template <>
bool HLTDoubletDZ<l1t::PFTau, l1t::PFTau>::haveSameSuperCluster(l1t::PFTau const&, l1t::PFTau const&) const {
return false;
}
template <>
bool HLTDoubletDZ<l1t::HPSPFTau, l1t::HPSPFTau>::haveSameSuperCluster(l1t::HPSPFTau const&,
l1t::HPSPFTau const&) const {
return false;
}
template <typename C1, typename C2>
bool HLTDoubletDZ<C1, C2>::passCutMinDeltaR(C1 const& c1, C2 const& c2) const {
return (minDR_ < 0 or reco::deltaR2(c1, c2) >= minDR2_);
}
template <>
bool HLTDoubletDZ<l1t::P2GTCandidate, l1t::P2GTCandidate>::passCutMinDeltaR(l1t::P2GTCandidate const& c1,
l1t::P2GTCandidate const& c2) const {
return (minDR_ < 0 or reco::deltaR2(c1, c2) > minDR2_);
}
template <>
bool HLTDoubletDZ<l1t::TrackerMuon, l1t::TrackerMuon>::passCutMinDeltaR(l1t::TrackerMuon const& m1,
l1t::TrackerMuon const& m2) const {
return (minDR_ < 0 or reco::deltaR2(m1.phEta(), m1.phPhi(), m2.phEta(), m2.phPhi()) >= minDR2_);
}
namespace {
double getCandidateVZ(reco::RecoChargedCandidate const& cand, bool& isValidVZ, int const minPixHitsForValidVZ) {
if (minPixHitsForValidVZ > 0) {
auto const track = cand.track();
if (not(track.isNonnull() and track.isAvailable() and
track->hitPattern().numberOfValidPixelHits() >= minPixHitsForValidVZ)) {
isValidVZ = false;
return 0;
}
}
isValidVZ = true;
return cand.vz();
}
double getCandidateVZ(reco::RecoEcalCandidate const& cand,
bool& isValidVZ,
int const minPixHitsForValidVZ,
reco::ElectronCollection const& electrons) {
reco::Electron const* elec_ptr = nullptr;
for (auto const& elec : electrons) {
if (elec.superCluster() == cand.superCluster()) {
elec_ptr = &elec;
}
}
if (elec_ptr == nullptr) {
// IMPROVE, kept for backward compatibility
isValidVZ = true;
return 0; // equivalent to 'reco::Electron e1; return e1.vz();'
}
if (minPixHitsForValidVZ > 0) {
auto const track = elec_ptr->gsfTrack();
if (not(track.isNonnull() and track.isAvailable() and
track->hitPattern().numberOfValidPixelHits() >= minPixHitsForValidVZ)) {
isValidVZ = false;
return 0;
}
}
isValidVZ = true;
return elec_ptr->vz();
}
double getCandidateVZ(l1t::HPSPFTau const& cand, bool& isValidVZ) {
auto const& leadChargedPFCand = cand.leadChargedPFCand();
if (leadChargedPFCand.isNonnull() and leadChargedPFCand.isAvailable()) {
auto const& pfTrack = leadChargedPFCand->pfTrack();
if (pfTrack.isNonnull() and pfTrack.isAvailable()) {
isValidVZ = true;
return pfTrack->vertex().z();
}
}
isValidVZ = false;
return 0;
}
} // namespace
template <typename T1, typename T2>
bool HLTDoubletDZ<T1, T2>::computeDZ(edm::Event const&, T1 const& c1, T2 const& c2) const {
return ((std::abs(c1.vz() - c2.vz()) <= maxDZ_) and passCutMinDeltaR(c1, c2));
}
template <>
bool HLTDoubletDZ<l1t::P2GTCandidate, l1t::P2GTCandidate>::computeDZ(edm::Event const& iEvent,
l1t::P2GTCandidate const& c1,
l1t::P2GTCandidate const& c2) const {
if (maxDZ_ > 0 && std::abs(c1.vz() - c2.vz()) > maxDZ_) {
return false;
}
if (not passCutMinDeltaR(c1, c2)) {
return false;
}
return true;
}
template <>
bool HLTDoubletDZ<reco::RecoEcalCandidate, reco::RecoChargedCandidate>::computeDZ(
edm::Event const& iEvent, reco::RecoEcalCandidate const& c1, reco::RecoChargedCandidate const& c2) const {
if (not passCutMinDeltaR(c1, c2))
return false;
bool hasValidVZ2 = false;
auto const vz2 = getCandidateVZ(c2, hasValidVZ2, minPixHitsForDZ_);
if (not hasValidVZ2)
return true;
bool hasValidVZ1 = false;
auto const& electrons = iEvent.get(electronToken_);
auto const vz1 = getCandidateVZ(c1, hasValidVZ1, minPixHitsForDZ_, electrons);
if (not hasValidVZ1)
return true;
return (std::abs(vz1 - vz2) <= maxDZ_);
}
template <>
bool HLTDoubletDZ<reco::RecoChargedCandidate, reco::RecoEcalCandidate>::computeDZ(
edm::Event const& iEvent, reco::RecoChargedCandidate const& c1, reco::RecoEcalCandidate const& c2) const {
if (not passCutMinDeltaR(c1, c2))
return false;
bool hasValidVZ1 = false;
auto const vz1 = getCandidateVZ(c1, hasValidVZ1, minPixHitsForDZ_);
if (not hasValidVZ1)
return true;
bool hasValidVZ2 = false;
auto const& electrons = iEvent.get(electronToken_);
auto const vz2 = getCandidateVZ(c2, hasValidVZ2, minPixHitsForDZ_, electrons);
if (not hasValidVZ2)
return true;
return (std::abs(vz1 - vz2) <= maxDZ_);
}
template <>
bool HLTDoubletDZ<reco::RecoEcalCandidate, reco::RecoEcalCandidate>::computeDZ(
edm::Event const& iEvent, reco::RecoEcalCandidate const& c1, reco::RecoEcalCandidate const& c2) const {
if (not passCutMinDeltaR(c1, c2))
return false;
auto const& electrons = iEvent.get(electronToken_);
bool hasValidVZ1 = false;
auto const vz1 = getCandidateVZ(c1, hasValidVZ1, minPixHitsForDZ_, electrons);
if (not hasValidVZ1)
return true;
bool hasValidVZ2 = false;
auto const vz2 = getCandidateVZ(c2, hasValidVZ2, minPixHitsForDZ_, electrons);
if (not hasValidVZ2)
return true;
return (std::abs(vz1 - vz2) <= maxDZ_);
}
template <>
bool HLTDoubletDZ<reco::RecoChargedCandidate, reco::RecoChargedCandidate>::computeDZ(
edm::Event const& iEvent, reco::RecoChargedCandidate const& c1, reco::RecoChargedCandidate const& c2) const {
if (not passCutMinDeltaR(c1, c2))
return false;
bool hasValidVZ1 = false;
auto const vz1 = getCandidateVZ(c1, hasValidVZ1, minPixHitsForDZ_);
if (not hasValidVZ1)
return true;
bool hasValidVZ2 = false;
auto const vz2 = getCandidateVZ(c2, hasValidVZ2, minPixHitsForDZ_);
if (not hasValidVZ2)
return true;
return (std::abs(vz1 - vz2) <= maxDZ_);
}
template <>
bool HLTDoubletDZ<l1t::TrackerMuon, l1t::TrackerMuon>::computeDZ(edm::Event const& iEvent,
l1t::TrackerMuon const& c1,
l1t::TrackerMuon const& c2) const {
return ((std::abs(c1.phZ0() - c2.phZ0()) <= maxDZ_) and passCutMinDeltaR(c1, c2));
}
template <>
bool HLTDoubletDZ<l1t::HPSPFTau, l1t::HPSPFTau>::computeDZ(edm::Event const& iEvent,
l1t::HPSPFTau const& c1,
l1t::HPSPFTau const& c2) const {
if (not passCutMinDeltaR(c1, c2))
return false;
bool hasValidVZ1 = false;
auto const vz1 = getCandidateVZ(c1, hasValidVZ1);
if (not hasValidVZ1)
return false;
bool hasValidVZ2 = false;
auto const vz2 = getCandidateVZ(c2, hasValidVZ2);
if (not hasValidVZ2)
return false;
return (std::abs(vz1 - vz2) <= maxDZ_);
}
template <typename T1, typename T2>
bool HLTDoubletDZ<T1, T2>::hltFilter(edm::Event& iEvent,
edm::EventSetup const& iSetup,
trigger::TriggerFilterObjectWithRefs& filterproduct) const {
// All HLT filters must create and fill an HLT filter object,
// recording any reconstructed physics objects satisfying (or not)
// this HLT filter, and place it in the Event.
std::vector<T1Ref> coll1;
std::vector<T2Ref> coll2;
if (getCollections(iEvent, coll1, coll2, filterproduct)) {
int n(0);
T1Ref r1;
T2Ref r2;
for (unsigned int i1 = 0; i1 < coll1.size(); ++i1) {
r1 = coll1[i1];
unsigned int const I = same_ ? i1 + 1 : 0;
for (unsigned int i2 = I; i2 < coll2.size(); ++i2) {
r2 = coll2[i2];
if (checkSC_ and haveSameSuperCluster(*r1, *r2)) {
continue;
}
if (not computeDZ(iEvent, *r1, *r2)) {
continue;
}
n++;
filterproduct.addObject(triggerType1_, r1);
filterproduct.addObject(triggerType2_, r2);
}
}
return (n >= min_N_);
}
return false;
}
template <>
bool HLTDoubletDZ<l1t::P2GTCandidate, l1t::P2GTCandidate>::hltFilter(
edm::Event& iEvent, const edm::EventSetup& iSetup, trigger::TriggerFilterObjectWithRefs& filterproduct) const {
// All HLT filters must create and fill an HLT filter object,
// recording any reconstructed physics objects satisfying (or not)
// this HLT filter, and place it in the Event.
bool accept(false);
std::vector<l1t::P2GTCandidateRef> coll1;
std::vector<l1t::P2GTCandidateRef> coll2;
if (getCollections(iEvent, coll1, coll2, filterproduct)) {
int n(0);
l1t::P2GTCandidateRef r1;
l1t::P2GTCandidateRef r2;
for (unsigned int i1 = 0; i1 != coll1.size(); i1++) {
r1 = coll1[i1];
unsigned int I(0);
if (same_) {
I = i1 + 1;
}
for (unsigned int i2 = I; i2 != coll2.size(); i2++) {
r2 = coll2[i2];
if (!computeDZ(iEvent, *r1, *r2))
continue;
n++;
filterproduct.addObject(triggerType1_, r1);
filterproduct.addObject(triggerType2_, r2);
}
}
accept = accept || (n >= min_N_);
}
return accept;
}
using HLT2ElectronElectronDZ = HLTDoubletDZ<reco::Electron, reco::Electron>;
using HLT2MuonMuonDZ = HLTDoubletDZ<reco::RecoChargedCandidate, reco::RecoChargedCandidate>;
using HLT2ElectronMuonDZ = HLTDoubletDZ<reco::Electron, reco::RecoChargedCandidate>;
using HLT2PhotonPhotonDZ = HLTDoubletDZ<reco::RecoEcalCandidate, reco::RecoEcalCandidate>;
using HLT2MuonPhotonDZ = HLTDoubletDZ<reco::RecoChargedCandidate, reco::RecoEcalCandidate>;
using HLT2PhotonMuonDZ = HLTDoubletDZ<reco::RecoEcalCandidate, reco::RecoChargedCandidate>;
using HLT2L1TkMuonL1TkMuonDZ = HLTDoubletDZ<l1t::TrackerMuon, l1t::TrackerMuon>;
using HLT2L1PFTauL1PFTauDZ = HLTDoubletDZ<l1t::PFTau, l1t::PFTau>;
using HLT2L1HPSPFTauL1HPSPFTauDZ = HLTDoubletDZ<l1t::HPSPFTau, l1t::HPSPFTau>;
using HLT2L1P2GTCandL1P2GTCandDZ = HLTDoubletDZ<l1t::P2GTCandidate, l1t::P2GTCandidate>;
#include "FWCore/Framework/interface/MakerMacros.h"
DEFINE_FWK_MODULE(HLT2ElectronElectronDZ);
DEFINE_FWK_MODULE(HLT2MuonMuonDZ);
DEFINE_FWK_MODULE(HLT2ElectronMuonDZ);
DEFINE_FWK_MODULE(HLT2PhotonPhotonDZ);
DEFINE_FWK_MODULE(HLT2PhotonMuonDZ);
DEFINE_FWK_MODULE(HLT2MuonPhotonDZ);
DEFINE_FWK_MODULE(HLT2L1TkMuonL1TkMuonDZ);
DEFINE_FWK_MODULE(HLT2L1PFTauL1PFTauDZ);
DEFINE_FWK_MODULE(HLT2L1HPSPFTauL1HPSPFTauDZ);
DEFINE_FWK_MODULE(HLT2L1P2GTCandL1P2GTCandDZ);
|