CMS 3D CMS Logo

HLTDoubletDZ.cc
Go to the documentation of this file.
1 #include "HLTDoubletDZ.h"
2 
19 
20 #include <cmath>
21 
22 template <typename T1, typename T2>
24  : HLTFilter(iConfig),
25  originTag1_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag1")),
26  originTag2_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag2")),
27  inputTag1_(iConfig.getParameter<edm::InputTag>("inputTag1")),
28  inputTag2_(iConfig.getParameter<edm::InputTag>("inputTag2")),
29  inputToken1_(consumes(inputTag1_)),
30  inputToken2_(consumes(inputTag2_)),
31  electronToken_(edm::EDGetTokenT<reco::ElectronCollection>()),
32  triggerType1_(iConfig.getParameter<int>("triggerType1")),
33  triggerType2_(iConfig.getParameter<int>("triggerType2")),
34  minDR_(iConfig.getParameter<double>("MinDR")),
35  minDR2_(minDR_ * minDR_),
36  maxDZ_(iConfig.getParameter<double>("MaxDZ")),
37  min_N_(iConfig.getParameter<int>("MinN")),
38  minPixHitsForDZ_(iConfig.getParameter<int>("MinPixHitsForDZ")),
39  checkSC_(iConfig.getParameter<bool>("checkSC")),
40  same_(inputTag1_.encode() == inputTag2_.encode()) // same collections to be compared?
41 {}
42 
43 template <>
45  : HLTFilter(iConfig),
46  originTag1_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag1")),
47  originTag2_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag2")),
48  electronToken_(edm::EDGetTokenT<reco::ElectronCollection>()),
49  l1GTAlgoBlockTag_(iConfig.template getParameter<edm::InputTag>("l1GTAlgoBlockTag")),
50  algoBlockToken_(consumes<l1t::P2GTAlgoBlockMap>(l1GTAlgoBlockTag_)),
51  l1GTAlgoName1_(iConfig.template getParameter<std::string>("l1GTAlgoName1")),
52  l1GTAlgoName2_(iConfig.template getParameter<std::string>("l1GTAlgoName2")),
53  triggerType1_(iConfig.getParameter<int>("triggerType1")),
54  triggerType2_(iConfig.getParameter<int>("triggerType2")),
55  minDR_(iConfig.getParameter<double>("MinDR")),
56  minDR2_(minDR_ * minDR_),
57  maxDZ_(iConfig.getParameter<double>("MaxDZ")),
58  min_N_(iConfig.getParameter<int>("MinN")),
59  minPixHitsForDZ_(iConfig.getParameter<int>("MinPixHitsForDZ")),
60  checkSC_(iConfig.getParameter<bool>("checkSC")),
61  same_(l1GTAlgoName1_ == l1GTAlgoName2_) // same collections to be compared?
62 {}
63 
64 template <>
66  : HLTFilter(iConfig),
67  originTag1_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag1")),
68  originTag2_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag2")),
69  inputTag1_(iConfig.getParameter<edm::InputTag>("inputTag1")),
70  inputTag2_(iConfig.getParameter<edm::InputTag>("inputTag2")),
71  inputToken1_(consumes(inputTag1_)),
72  inputToken2_(consumes(inputTag2_)),
73  electronToken_(consumes(iConfig.getParameter<edm::InputTag>("electronTag"))),
74  triggerType1_(iConfig.getParameter<int>("triggerType1")),
75  triggerType2_(iConfig.getParameter<int>("triggerType2")),
76  minDR_(iConfig.getParameter<double>("MinDR")),
77  minDR2_(minDR_ * minDR_),
78  maxDZ_(iConfig.getParameter<double>("MaxDZ")),
79  min_N_(iConfig.getParameter<int>("MinN")),
80  minPixHitsForDZ_(iConfig.getParameter<int>("MinPixHitsForDZ")),
81  checkSC_(iConfig.getParameter<bool>("checkSC")),
82  same_(inputTag1_.encode() == inputTag2_.encode()) // same collections to be compared?
83 {}
84 
85 template <>
87  : HLTFilter(iConfig),
88  originTag1_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag1")),
89  originTag2_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag2")),
90  inputTag1_(iConfig.getParameter<edm::InputTag>("inputTag1")),
91  inputTag2_(iConfig.getParameter<edm::InputTag>("inputTag2")),
92  inputToken1_(consumes(inputTag1_)),
93  inputToken2_(consumes(inputTag2_)),
94  electronToken_(consumes(iConfig.getParameter<edm::InputTag>("electronTag"))),
95  triggerType1_(iConfig.getParameter<int>("triggerType1")),
96  triggerType2_(iConfig.getParameter<int>("triggerType2")),
97  minDR_(iConfig.getParameter<double>("MinDR")),
98  minDR2_(minDR_ * minDR_),
99  maxDZ_(iConfig.getParameter<double>("MaxDZ")),
100  min_N_(iConfig.getParameter<int>("MinN")),
101  minPixHitsForDZ_(iConfig.getParameter<int>("MinPixHitsForDZ")),
102  checkSC_(iConfig.getParameter<bool>("checkSC")),
103  same_(inputTag1_.encode() == inputTag2_.encode()) // same collections to be compared?
104 {}
105 
106 template <>
108  : HLTFilter(iConfig),
109  originTag1_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag1")),
110  originTag2_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag2")),
111  inputTag1_(iConfig.getParameter<edm::InputTag>("inputTag1")),
112  inputTag2_(iConfig.getParameter<edm::InputTag>("inputTag2")),
113  inputToken1_(consumes(inputTag1_)),
114  inputToken2_(consumes(inputTag2_)),
115  electronToken_(consumes(iConfig.getParameter<edm::InputTag>("electronTag"))),
116  triggerType1_(iConfig.getParameter<int>("triggerType1")),
117  triggerType2_(iConfig.getParameter<int>("triggerType2")),
118  minDR_(iConfig.getParameter<double>("MinDR")),
119  minDR2_(minDR_ * minDR_),
120  maxDZ_(iConfig.getParameter<double>("MaxDZ")),
121  min_N_(iConfig.getParameter<int>("MinN")),
122  minPixHitsForDZ_(iConfig.getParameter<int>("MinPixHitsForDZ")),
123  checkSC_(iConfig.getParameter<bool>("checkSC")),
124  same_(inputTag1_.encode() == inputTag2_.encode()) // same collections to be compared?
125 {}
126 
127 template <>
129  : HLTFilter(iConfig),
130  originTag1_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag1")),
131  originTag2_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag2")),
132  inputTag1_(iConfig.getParameter<edm::InputTag>("inputTag1")),
133  inputTag2_(iConfig.getParameter<edm::InputTag>("inputTag2")),
134  inputToken1_(consumes(inputTag1_)),
135  inputToken2_(consumes(inputTag2_)),
136  electronToken_(edm::EDGetTokenT<reco::ElectronCollection>()),
137  triggerType1_(iConfig.getParameter<int>("triggerType1")),
138  triggerType2_(iConfig.getParameter<int>("triggerType2")),
139  minDR_(iConfig.getParameter<double>("MinDR")),
140  minDR2_(minDR_ * minDR_),
141  maxDZ_(iConfig.getParameter<double>("MaxDZ")),
142  min_N_(iConfig.getParameter<int>("MinN")),
143  minPixHitsForDZ_(0),
144  checkSC_(false),
145  same_(inputTag1_.encode() == inputTag2_.encode()) // same collections to be compared?
146 {}
147 
148 template <>
150  : HLTFilter(iConfig),
151  originTag1_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag1")),
152  originTag2_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag2")),
153  inputTag1_(iConfig.getParameter<edm::InputTag>("inputTag1")),
154  inputTag2_(iConfig.getParameter<edm::InputTag>("inputTag2")),
155  inputToken1_(consumes(inputTag1_)),
156  inputToken2_(consumes(inputTag2_)),
157  electronToken_(edm::EDGetTokenT<reco::ElectronCollection>()),
158  triggerType1_(iConfig.getParameter<int>("triggerType1")),
159  triggerType2_(iConfig.getParameter<int>("triggerType2")),
160  minDR_(iConfig.getParameter<double>("MinDR")),
161  minDR2_(minDR_ * minDR_),
162  maxDZ_(iConfig.getParameter<double>("MaxDZ")),
163  min_N_(iConfig.getParameter<int>("MinN")),
164  minPixHitsForDZ_(0),
165  checkSC_(false),
166  same_(inputTag1_.encode() == inputTag2_.encode()) // same collections to be compared?
167 {}
168 
169 template <>
171  : HLTFilter(iConfig),
172  originTag1_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag1")),
173  originTag2_(iConfig.getParameter<std::vector<edm::InputTag>>("originTag2")),
174  inputTag1_(iConfig.getParameter<edm::InputTag>("inputTag1")),
175  inputTag2_(iConfig.getParameter<edm::InputTag>("inputTag2")),
176  inputToken1_(consumes(inputTag1_)),
177  inputToken2_(consumes(inputTag2_)),
178  electronToken_(edm::EDGetTokenT<reco::ElectronCollection>()),
179  triggerType1_(iConfig.getParameter<int>("triggerType1")),
180  triggerType2_(iConfig.getParameter<int>("triggerType2")),
181  minDR_(iConfig.getParameter<double>("MinDR")),
182  minDR2_(minDR_ * minDR_),
183  maxDZ_(iConfig.getParameter<double>("MaxDZ")),
184  min_N_(iConfig.getParameter<int>("MinN")),
185  minPixHitsForDZ_(0),
186  checkSC_(false),
187  same_(inputTag1_.encode() == inputTag2_.encode()) // same collections to be compared?
188 {}
189 
190 template <>
192  edm::ConfigurationDescriptions& descriptions) {
194  makeHLTFilterDescription(desc);
195  desc.add<std::vector<edm::InputTag>>("originTag1", {edm::InputTag("hltOriginal1")});
196  desc.add<std::vector<edm::InputTag>>("originTag2", {edm::InputTag("hltOriginal2")});
197  desc.add<edm::InputTag>("l1GTAlgoBlockTag", edm::InputTag("l1tGTAlgoBlockProducer"));
198  desc.add<std::string>("l1GTAlgoName1", "");
199  desc.add<std::string>("l1GTAlgoName2", "");
200  desc.add<int>("triggerType1", 0);
201  desc.add<int>("triggerType2", 0);
202  desc.add<double>("MinDR", -1.0);
203  desc.add<double>("MaxDZ", 0.2);
204  desc.add<int>("MinPixHitsForDZ", 0);
205  desc.add<bool>("checkSC", false);
206  desc.add<int>("MinN", 1);
207  descriptions.addWithDefaultLabel(desc);
208 }
209 
210 template <typename T1, typename T2>
213  makeHLTFilterDescription(desc);
214  desc.add<std::vector<edm::InputTag>>("originTag1", {edm::InputTag("hltOriginal1")});
215  desc.add<std::vector<edm::InputTag>>("originTag2", {edm::InputTag("hltOriginal2")});
216  desc.add<edm::InputTag>("inputTag1", edm::InputTag("hltFiltered1"));
217  desc.add<edm::InputTag>("inputTag2", edm::InputTag("hltFiltered2"));
218  desc.add<int>("triggerType1", 0);
219  desc.add<int>("triggerType2", 0);
220  desc.add<double>("MinDR", -1.0);
221  desc.add<double>("MaxDZ", 0.2);
222  desc.add<int>("MinN", 1);
223  desc.add<int>("MinPixHitsForDZ", 0);
224  desc.add<bool>("checkSC", false);
225  descriptions.addWithDefaultLabel(desc);
226 }
227 
228 template <>
230  edm::ConfigurationDescriptions& descriptions) {
232  makeHLTFilterDescription(desc);
233  desc.add<std::vector<edm::InputTag>>("originTag1", {edm::InputTag("hltOriginal1")});
234  desc.add<std::vector<edm::InputTag>>("originTag2", {edm::InputTag("hltOriginal2")});
235  desc.add<edm::InputTag>("inputTag1", edm::InputTag("hltFiltered1"));
236  desc.add<edm::InputTag>("inputTag2", edm::InputTag("hltFiltered2"));
237  desc.add<edm::InputTag>("electronTag", edm::InputTag("electronTag"));
238  desc.add<int>("triggerType1", 0);
239  desc.add<int>("triggerType2", 0);
240  desc.add<double>("MinDR", -1.0);
241  desc.add<double>("MaxDZ", 0.2);
242  desc.add<int>("MinN", 1);
243  desc.add<int>("MinPixHitsForDZ", 0);
244  desc.add<bool>("checkSC", false);
245  descriptions.addWithDefaultLabel(desc);
246 }
247 
248 template <>
250  edm::ConfigurationDescriptions& descriptions) {
252  makeHLTFilterDescription(desc);
253  desc.add<std::vector<edm::InputTag>>("originTag1", {edm::InputTag("hltOriginal1")});
254  desc.add<std::vector<edm::InputTag>>("originTag2", {edm::InputTag("hltOriginal2")});
255  desc.add<edm::InputTag>("inputTag1", edm::InputTag("hltFiltered1"));
256  desc.add<edm::InputTag>("inputTag2", edm::InputTag("hltFiltered2"));
257  desc.add<edm::InputTag>("electronTag", edm::InputTag("electronTag"));
258  desc.add<int>("triggerType1", 0);
259  desc.add<int>("triggerType2", 0);
260  desc.add<double>("MinDR", -1.0);
261  desc.add<double>("MaxDZ", 0.2);
262  desc.add<int>("MinN", 1);
263  desc.add<int>("MinPixHitsForDZ", 0);
264  desc.add<bool>("checkSC", false);
265  descriptions.addWithDefaultLabel(desc);
266 }
267 
268 template <>
270  edm::ConfigurationDescriptions& descriptions) {
272  makeHLTFilterDescription(desc);
273  desc.add<std::vector<edm::InputTag>>("originTag1", {edm::InputTag("hltOriginal1")});
274  desc.add<std::vector<edm::InputTag>>("originTag2", {edm::InputTag("hltOriginal2")});
275  desc.add<edm::InputTag>("inputTag1", edm::InputTag("hltFiltered1"));
276  desc.add<edm::InputTag>("inputTag2", edm::InputTag("hltFiltered2"));
277  desc.add<edm::InputTag>("electronTag", edm::InputTag("electronTag"));
278  desc.add<int>("triggerType1", 0);
279  desc.add<int>("triggerType2", 0);
280  desc.add<double>("MinDR", -1.0);
281  desc.add<double>("MaxDZ", 0.2);
282  desc.add<int>("MinN", 1);
283  desc.add<int>("MinPixHitsForDZ", 0);
284  desc.add<bool>("checkSC", false);
285  descriptions.addWithDefaultLabel(desc);
286 }
287 
288 template <>
291  makeHLTFilterDescription(desc);
292  desc.add<std::vector<edm::InputTag>>("originTag1", {edm::InputTag("hltOriginal1")});
293  desc.add<std::vector<edm::InputTag>>("originTag2", {edm::InputTag("hltOriginal2")});
294  desc.add<edm::InputTag>("inputTag1", edm::InputTag("hltFiltered1"));
295  desc.add<edm::InputTag>("inputTag2", edm::InputTag("hltFiltered2"));
296  desc.add<int>("triggerType1", 0);
297  desc.add<int>("triggerType2", 0);
298  desc.add<double>("MinDR", -1.0);
299  desc.add<double>("MaxDZ", 0.2);
300  desc.add<int>("MinN", 1);
301  descriptions.addWithDefaultLabel(desc);
302 }
303 
304 template <>
307  makeHLTFilterDescription(desc);
308  desc.add<std::vector<edm::InputTag>>("originTag1", {edm::InputTag("hltOriginal1")});
309  desc.add<std::vector<edm::InputTag>>("originTag2", {edm::InputTag("hltOriginal2")});
310  desc.add<edm::InputTag>("inputTag1", edm::InputTag("hltFiltered1"));
311  desc.add<edm::InputTag>("inputTag2", edm::InputTag("hltFiltered2"));
312  desc.add<int>("triggerType1", 0);
313  desc.add<int>("triggerType2", 0);
314  desc.add<double>("MinDR", -1.0);
315  desc.add<double>("MaxDZ", 0.2);
316  desc.add<int>("MinN", 1);
317  descriptions.addWithDefaultLabel(desc);
318 }
319 
320 template <>
323  makeHLTFilterDescription(desc);
324  desc.add<std::vector<edm::InputTag>>("originTag1", {edm::InputTag("hltOriginal1")});
325  desc.add<std::vector<edm::InputTag>>("originTag2", {edm::InputTag("hltOriginal2")});
326  desc.add<edm::InputTag>("inputTag1", edm::InputTag("hltFiltered1"));
327  desc.add<edm::InputTag>("inputTag2", edm::InputTag("hltFiltered2"));
328  desc.add<int>("triggerType1", 0);
329  desc.add<int>("triggerType2", 0);
330  desc.add<double>("MinDR", -1.0);
331  desc.add<double>("MaxDZ", 0.2);
332  desc.add<int>("MinN", 1);
333  descriptions.addWithDefaultLabel(desc);
334 }
335 
336 template <typename T1, typename T2>
338  std::vector<T1Ref>& coll1,
339  std::vector<T2Ref>& coll2,
340  trigger::TriggerFilterObjectWithRefs& filterproduct) const {
342  if (iEvent.getByToken(inputToken1_, handle1) and iEvent.getByToken(inputToken2_, handle2)) {
343  // get hold of pre-filtered object collections
344  handle1->getObjects(triggerType1_, coll1);
345  handle2->getObjects(triggerType2_, coll2);
346  const trigger::size_type n1(coll1.size());
347  const trigger::size_type n2(coll2.size());
348 
349  if (saveTags()) {
350  edm::InputTag tagOld;
351  for (unsigned int i = 0; i < originTag1_.size(); ++i) {
352  filterproduct.addCollectionTag(originTag1_[i]);
353  }
354  tagOld = edm::InputTag();
355  for (trigger::size_type i1 = 0; i1 != n1; ++i1) {
356  const edm::ProductID pid(coll1[i1].id());
357  const auto& prov = iEvent.getStableProvenance(pid);
358  const std::string& label(prov.moduleLabel());
359  const std::string& instance(prov.productInstanceName());
360  const std::string& process(prov.processName());
362  if (tagOld.encode() != tagNew.encode()) {
363  filterproduct.addCollectionTag(tagNew);
364  tagOld = tagNew;
365  }
366  }
367  for (unsigned int i = 0; i < originTag2_.size(); ++i) {
368  filterproduct.addCollectionTag(originTag2_[i]);
369  }
370  tagOld = edm::InputTag();
371  for (trigger::size_type i2 = 0; i2 != n2; ++i2) {
372  const edm::ProductID pid(coll2[i2].id());
373  const auto& prov = iEvent.getStableProvenance(pid);
374  const std::string& label(prov.moduleLabel());
375  const std::string& instance(prov.productInstanceName());
376  const std::string& process(prov.processName());
378  if (tagOld.encode() != tagNew.encode()) {
379  filterproduct.addCollectionTag(tagNew);
380  tagOld = tagNew;
381  }
382  }
383  }
384 
385  return true;
386  }
387 
388  return false;
389 }
390 
391 template <>
393  edm::Event const& iEvent,
394  std::vector<l1t::P2GTCandidateRef>& coll1,
395  std::vector<l1t::P2GTCandidateRef>& coll2,
396  trigger::TriggerFilterObjectWithRefs& filterproduct) const {
397  const l1t::P2GTAlgoBlockMap& algos = iEvent.get(algoBlockToken_);
398 
399  if (!algos.empty()) {
400  if (algos.count(l1GTAlgoName1_) > 0 && algos.at(l1GTAlgoName1_).decisionBeforeBxMaskAndPrescale()) {
401  const l1t::P2GTCandidateVectorRef& objects = algos.at(l1GTAlgoName1_).trigObjects();
402  for (const l1t::P2GTCandidateRef& obj : objects) {
403  if ((triggerType1_ == trigger::TriggerObjectType::TriggerL1TkMu && obj->isMuon()) ||
404  (triggerType1_ == trigger::TriggerObjectType::TriggerL1TkEle && obj->isElectron()) ||
405  (triggerType1_ == trigger::TriggerObjectType::TriggerL1TkEm && obj->isPhoton())) {
406  coll1.push_back(obj);
407  }
408  }
409  }
410 
411  if (algos.count(l1GTAlgoName2_) > 0 && algos.at(l1GTAlgoName2_).decisionBeforeBxMaskAndPrescale()) {
412  const l1t::P2GTCandidateVectorRef& objects = algos.at(l1GTAlgoName2_).trigObjects();
413  for (const l1t::P2GTCandidateRef& obj : objects) {
414  if ((triggerType2_ == trigger::TriggerObjectType::TriggerL1TkMu && obj->isMuon()) ||
415  (triggerType2_ == trigger::TriggerObjectType::TriggerL1TkEle && obj->isElectron()) ||
416  (triggerType2_ == trigger::TriggerObjectType::TriggerL1TkEm && obj->isPhoton())) {
417  coll2.push_back(obj);
418  }
419  }
420  }
421  }
422 
423  if (!coll1.empty() && !coll2.empty()) {
424  const trigger::size_type n1(coll1.size());
425  const trigger::size_type n2(coll2.size());
426 
427  if (saveTags()) {
428  edm::InputTag tagOld;
429  for (unsigned int i = 0; i < originTag1_.size(); ++i) {
430  filterproduct.addCollectionTag(originTag1_[i]);
431  }
432  tagOld = edm::InputTag();
433  for (trigger::size_type i1 = 0; i1 != n1; ++i1) {
434  const edm::ProductID pid(coll1[i1].id());
435  const auto& prov = iEvent.getStableProvenance(pid);
436  const std::string& label(prov.moduleLabel());
437  const std::string& instance(prov.productInstanceName());
438  const std::string& process(prov.processName());
440  if (tagOld.encode() != tagNew.encode()) {
441  filterproduct.addCollectionTag(tagNew);
442  tagOld = tagNew;
443  }
444  }
445  for (unsigned int i = 0; i < originTag2_.size(); ++i) {
446  filterproduct.addCollectionTag(originTag2_[i]);
447  }
448  tagOld = edm::InputTag();
449  for (trigger::size_type i2 = 0; i2 != n2; ++i2) {
450  const edm::ProductID pid(coll2[i2].id());
451  const auto& prov = iEvent.getStableProvenance(pid);
452  const std::string& label(prov.moduleLabel());
453  const std::string& instance(prov.productInstanceName());
454  const std::string& process(prov.processName());
456  if (tagOld.encode() != tagNew.encode()) {
457  filterproduct.addCollectionTag(tagNew);
458  tagOld = tagNew;
459  }
460  }
461  }
462 
463  return true;
464  } else
465  return false;
466 }
467 
468 template <typename T1, typename T2>
469 bool HLTDoubletDZ<T1, T2>::haveSameSuperCluster(T1 const& c1, T2 const& c2) const {
470  return (c1.superCluster().isNonnull() and c2.superCluster().isNonnull() and (c1.superCluster() == c2.superCluster()));
471 }
472 
473 template <>
475  l1t::TrackerMuon const&) const {
476  return false;
477 }
478 
479 template <>
481  return false;
482 }
483 
484 template <>
486  l1t::HPSPFTau const&) const {
487  return false;
488 }
489 
490 template <typename C1, typename C2>
491 bool HLTDoubletDZ<C1, C2>::passCutMinDeltaR(C1 const& c1, C2 const& c2) const {
492  return (minDR_ < 0 or reco::deltaR2(c1, c2) >= minDR2_);
493 }
494 
495 template <>
497  l1t::P2GTCandidate const& c2) const {
498  return (minDR_ < 0 or reco::deltaR2(c1, c2) > minDR2_);
499 }
500 
501 template <>
503  l1t::TrackerMuon const& m2) const {
504  return (minDR_ < 0 or reco::deltaR2(m1.phEta(), m1.phPhi(), m2.phEta(), m2.phPhi()) >= minDR2_);
505 }
506 
507 namespace {
508 
509  double getCandidateVZ(reco::RecoChargedCandidate const& cand, bool& isValidVZ, int const minPixHitsForValidVZ) {
510  if (minPixHitsForValidVZ > 0) {
511  auto const track = cand.track();
512  if (not(track.isNonnull() and track.isAvailable() and
513  track->hitPattern().numberOfValidPixelHits() >= minPixHitsForValidVZ)) {
514  isValidVZ = false;
515  return 0;
516  }
517  }
518 
519  isValidVZ = true;
520  return cand.vz();
521  }
522 
523  double getCandidateVZ(reco::RecoEcalCandidate const& cand,
524  bool& isValidVZ,
525  int const minPixHitsForValidVZ,
527  reco::Electron const* elec_ptr = nullptr;
528  for (auto const& elec : electrons) {
529  if (elec.superCluster() == cand.superCluster()) {
530  elec_ptr = &elec;
531  }
532  }
533 
534  if (elec_ptr == nullptr) {
535  // IMPROVE, kept for backward compatibility
536  isValidVZ = true;
537  return 0; // equivalent to 'reco::Electron e1; return e1.vz();'
538  }
539 
540  if (minPixHitsForValidVZ > 0) {
541  auto const track = elec_ptr->gsfTrack();
542  if (not(track.isNonnull() and track.isAvailable() and
543  track->hitPattern().numberOfValidPixelHits() >= minPixHitsForValidVZ)) {
544  isValidVZ = false;
545  return 0;
546  }
547  }
548 
549  isValidVZ = true;
550  return elec_ptr->vz();
551  }
552 
553  double getCandidateVZ(l1t::HPSPFTau const& cand, bool& isValidVZ) {
554  auto const& leadChargedPFCand = cand.leadChargedPFCand();
555  if (leadChargedPFCand.isNonnull() and leadChargedPFCand.isAvailable()) {
556  auto const& pfTrack = leadChargedPFCand->pfTrack();
557  if (pfTrack.isNonnull() and pfTrack.isAvailable()) {
558  isValidVZ = true;
559  return pfTrack->vertex().z();
560  }
561  }
562 
563  isValidVZ = false;
564  return 0;
565  }
566 
567 } // namespace
568 
569 template <typename T1, typename T2>
570 bool HLTDoubletDZ<T1, T2>::computeDZ(edm::Event const&, T1 const& c1, T2 const& c2) const {
571  return ((std::abs(c1.vz() - c2.vz()) <= maxDZ_) and passCutMinDeltaR(c1, c2));
572 }
573 
574 template <>
576  l1t::P2GTCandidate const& c1,
577  l1t::P2GTCandidate const& c2) const {
578  if (maxDZ_ > 0 && std::abs(c1.vz() - c2.vz()) > maxDZ_) {
579  return false;
580  }
581 
582  if (not passCutMinDeltaR(c1, c2)) {
583  return false;
584  }
585 
586  return true;
587 }
588 
589 template <>
591  edm::Event const& iEvent, reco::RecoEcalCandidate const& c1, reco::RecoChargedCandidate const& c2) const {
592  if (not passCutMinDeltaR(c1, c2))
593  return false;
594 
595  bool hasValidVZ2 = false;
596  auto const vz2 = getCandidateVZ(c2, hasValidVZ2, minPixHitsForDZ_);
597  if (not hasValidVZ2)
598  return true;
599 
600  bool hasValidVZ1 = false;
601  auto const& electrons = iEvent.get(electronToken_);
602  auto const vz1 = getCandidateVZ(c1, hasValidVZ1, minPixHitsForDZ_, electrons);
603  if (not hasValidVZ1)
604  return true;
605 
606  return (std::abs(vz1 - vz2) <= maxDZ_);
607 }
608 
609 template <>
611  edm::Event const& iEvent, reco::RecoChargedCandidate const& c1, reco::RecoEcalCandidate const& c2) const {
612  if (not passCutMinDeltaR(c1, c2))
613  return false;
614 
615  bool hasValidVZ1 = false;
616  auto const vz1 = getCandidateVZ(c1, hasValidVZ1, minPixHitsForDZ_);
617  if (not hasValidVZ1)
618  return true;
619 
620  bool hasValidVZ2 = false;
621  auto const& electrons = iEvent.get(electronToken_);
622  auto const vz2 = getCandidateVZ(c2, hasValidVZ2, minPixHitsForDZ_, electrons);
623  if (not hasValidVZ2)
624  return true;
625 
626  return (std::abs(vz1 - vz2) <= maxDZ_);
627 }
628 
629 template <>
631  edm::Event const& iEvent, reco::RecoEcalCandidate const& c1, reco::RecoEcalCandidate const& c2) const {
632  if (not passCutMinDeltaR(c1, c2))
633  return false;
634 
635  auto const& electrons = iEvent.get(electronToken_);
636 
637  bool hasValidVZ1 = false;
638  auto const vz1 = getCandidateVZ(c1, hasValidVZ1, minPixHitsForDZ_, electrons);
639  if (not hasValidVZ1)
640  return true;
641 
642  bool hasValidVZ2 = false;
643  auto const vz2 = getCandidateVZ(c2, hasValidVZ2, minPixHitsForDZ_, electrons);
644  if (not hasValidVZ2)
645  return true;
646 
647  return (std::abs(vz1 - vz2) <= maxDZ_);
648 }
649 
650 template <>
653  if (not passCutMinDeltaR(c1, c2))
654  return false;
655 
656  bool hasValidVZ1 = false;
657  auto const vz1 = getCandidateVZ(c1, hasValidVZ1, minPixHitsForDZ_);
658  if (not hasValidVZ1)
659  return true;
660 
661  bool hasValidVZ2 = false;
662  auto const vz2 = getCandidateVZ(c2, hasValidVZ2, minPixHitsForDZ_);
663  if (not hasValidVZ2)
664  return true;
665 
666  return (std::abs(vz1 - vz2) <= maxDZ_);
667 }
668 
669 template <>
671  l1t::TrackerMuon const& c1,
672  l1t::TrackerMuon const& c2) const {
673  return ((std::abs(c1.phZ0() - c2.phZ0()) <= maxDZ_) and passCutMinDeltaR(c1, c2));
674 }
675 
676 template <>
678  l1t::HPSPFTau const& c1,
679  l1t::HPSPFTau const& c2) const {
680  if (not passCutMinDeltaR(c1, c2))
681  return false;
682 
683  bool hasValidVZ1 = false;
684  auto const vz1 = getCandidateVZ(c1, hasValidVZ1);
685  if (not hasValidVZ1)
686  return false;
687 
688  bool hasValidVZ2 = false;
689  auto const vz2 = getCandidateVZ(c2, hasValidVZ2);
690  if (not hasValidVZ2)
691  return false;
692 
693  return (std::abs(vz1 - vz2) <= maxDZ_);
694 }
695 
696 template <typename T1, typename T2>
698  edm::EventSetup const& iSetup,
699  trigger::TriggerFilterObjectWithRefs& filterproduct) const {
700  // All HLT filters must create and fill an HLT filter object,
701  // recording any reconstructed physics objects satisfying (or not)
702  // this HLT filter, and place it in the Event.
703  std::vector<T1Ref> coll1;
704  std::vector<T2Ref> coll2;
705 
706  if (getCollections(iEvent, coll1, coll2, filterproduct)) {
707  int n(0);
708  T1Ref r1;
709  T2Ref r2;
710 
711  for (unsigned int i1 = 0; i1 < coll1.size(); ++i1) {
712  r1 = coll1[i1];
713  unsigned int const I = same_ ? i1 + 1 : 0;
714  for (unsigned int i2 = I; i2 < coll2.size(); ++i2) {
715  r2 = coll2[i2];
716 
717  if (checkSC_ and haveSameSuperCluster(*r1, *r2)) {
718  continue;
719  }
720 
721  if (not computeDZ(iEvent, *r1, *r2)) {
722  continue;
723  }
724 
725  n++;
726  filterproduct.addObject(triggerType1_, r1);
727  filterproduct.addObject(triggerType2_, r2);
728  }
729  }
730 
731  return (n >= min_N_);
732  }
733 
734  return false;
735 }
736 
737 template <>
739  edm::Event& iEvent, const edm::EventSetup& iSetup, trigger::TriggerFilterObjectWithRefs& filterproduct) const {
740  // All HLT filters must create and fill an HLT filter object,
741  // recording any reconstructed physics objects satisfying (or not)
742  // this HLT filter, and place it in the Event.
743  bool accept(false);
744 
745  std::vector<l1t::P2GTCandidateRef> coll1;
746  std::vector<l1t::P2GTCandidateRef> coll2;
747 
748  if (getCollections(iEvent, coll1, coll2, filterproduct)) {
749  int n(0);
752 
753  for (unsigned int i1 = 0; i1 != coll1.size(); i1++) {
754  r1 = coll1[i1];
755  unsigned int I(0);
756  if (same_) {
757  I = i1 + 1;
758  }
759  for (unsigned int i2 = I; i2 != coll2.size(); i2++) {
760  r2 = coll2[i2];
761 
762  if (!computeDZ(iEvent, *r1, *r2))
763  continue;
764 
765  n++;
766  filterproduct.addObject(triggerType1_, r1);
767  filterproduct.addObject(triggerType2_, r2);
768  }
769  }
770 
771  accept = accept || (n >= min_N_);
772  }
773  return accept;
774 }
775 
786 
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool computeDZ(edm::Event const &iEvent, T1 const &c1, T2 const &c2) const
double vz() const override
z coordinate of vertex position
static PFTauRenderPlugin instance
std::string encode() const
Definition: InputTag.cc:159
std::map< std::string, P2GTAlgoBlock > P2GTAlgoBlockMap
Definition: P2GTAlgoBlock.h:11
delete x;
Definition: CaloConfig.h:22
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
uint16_t size_type
bool passCutMinDeltaR(T1 const &c1, T2 const &c2) const
void addObject(int id, const reco::RecoEcalCandidateRef &ref)
setters for L3 collections: (id=physics type, and Ref<C>)
char const * label
int iEvent
Definition: GenABIO.cc:224
bool getCollections(edm::Event const &iEvent, std::vector< T1Ref > &coll1, std::vector< T2Ref > &coll2, trigger::TriggerFilterObjectWithRefs &filterproduct) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
reco::GsfTrackRef gsfTrack() const override
reference to a GsfTrack
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::complex< double > I
Definition: I.h:8
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
bool haveSameSuperCluster(T1 const &c1, T2 const &c2) const
std::vector< Electron > ElectronCollection
collectin of Electron objects
Definition: ElectronFwd.h:9
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
void addCollectionTag(const edm::InputTag &collectionTag)
collectionTags
def encode(args, files)
std::vector< P2GTCandidateRef > P2GTCandidateVectorRef
Definition: P2GTCandidate.h:20
fixed size matrix
HLT enums.
bool hltFilter(edm::Event &iEvent, edm::EventSetup const &iSetup, trigger::TriggerFilterObjectWithRefs &filterproduct) const override
HLTDoubletDZ(edm::ParameterSet const &)
Definition: HLTDoubletDZ.cc:23
const double phZ0() const
Definition: TrackerMuon.h:62