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<std::vector<l1t::P2GTAlgoBlock>>(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 std::vector<l1t::P2GTAlgoBlock>& algos = iEvent.get(algoBlockToken_);
398 
399  if (!algos.empty()) {
400  for (const l1t::P2GTAlgoBlock& algo : algos) {
401  if (algo.algoName() == l1GTAlgoName1_ && algo.decisionBeforeBxMaskAndPrescale()) {
402  const l1t::P2GTCandidateVectorRef& objects = algo.trigObjects();
403  for (const l1t::P2GTCandidateRef& obj : objects) {
404  if ((triggerType1_ == trigger::TriggerObjectType::TriggerL1TkMu && obj->isMuon()) ||
405  (triggerType1_ == trigger::TriggerObjectType::TriggerL1TkEle && obj->isElectron()) ||
406  (triggerType1_ == trigger::TriggerObjectType::TriggerL1TkEm && obj->isPhoton())) {
407  coll1.push_back(obj);
408  }
409  }
410  }
411  if (algo.algoName() == l1GTAlgoName2_ && algo.decisionBeforeBxMaskAndPrescale()) {
412  const l1t::P2GTCandidateVectorRef& objects = algo.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 
424  if (!coll1.empty() && !coll2.empty()) {
425  const trigger::size_type n1(coll1.size());
426  const trigger::size_type n2(coll2.size());
427 
428  if (saveTags()) {
429  edm::InputTag tagOld;
430  for (unsigned int i = 0; i < originTag1_.size(); ++i) {
431  filterproduct.addCollectionTag(originTag1_[i]);
432  }
433  tagOld = edm::InputTag();
434  for (trigger::size_type i1 = 0; i1 != n1; ++i1) {
435  const edm::ProductID pid(coll1[i1].id());
436  const auto& prov = iEvent.getStableProvenance(pid);
437  const std::string& label(prov.moduleLabel());
438  const std::string& instance(prov.productInstanceName());
439  const std::string& process(prov.processName());
441  if (tagOld.encode() != tagNew.encode()) {
442  filterproduct.addCollectionTag(tagNew);
443  tagOld = tagNew;
444  }
445  }
446  for (unsigned int i = 0; i < originTag2_.size(); ++i) {
447  filterproduct.addCollectionTag(originTag2_[i]);
448  }
449  tagOld = edm::InputTag();
450  for (trigger::size_type i2 = 0; i2 != n2; ++i2) {
451  const edm::ProductID pid(coll2[i2].id());
452  const auto& prov = iEvent.getStableProvenance(pid);
453  const std::string& label(prov.moduleLabel());
454  const std::string& instance(prov.productInstanceName());
455  const std::string& process(prov.processName());
457  if (tagOld.encode() != tagNew.encode()) {
458  filterproduct.addCollectionTag(tagNew);
459  tagOld = tagNew;
460  }
461  }
462  }
463 
464  return true;
465  } else
466  return false;
467 }
468 
469 template <typename T1, typename T2>
470 bool HLTDoubletDZ<T1, T2>::haveSameSuperCluster(T1 const& c1, T2 const& c2) const {
471  return (c1.superCluster().isNonnull() and c2.superCluster().isNonnull() and (c1.superCluster() == c2.superCluster()));
472 }
473 
474 template <>
476  l1t::TrackerMuon const&) const {
477  return false;
478 }
479 
480 template <>
482  return false;
483 }
484 
485 template <>
487  l1t::HPSPFTau const&) const {
488  return false;
489 }
490 
491 template <typename C1, typename C2>
492 bool HLTDoubletDZ<C1, C2>::passCutMinDeltaR(C1 const& c1, C2 const& c2) const {
493  return (minDR_ < 0 or reco::deltaR2(c1, c2) >= minDR2_);
494 }
495 
496 template <>
498  l1t::P2GTCandidate const& c2) const {
499  return (minDR_ < 0 or reco::deltaR2(c1, c2) > minDR2_);
500 }
501 
502 template <>
504  l1t::TrackerMuon const& m2) const {
505  return (minDR_ < 0 or reco::deltaR2(m1.phEta(), m1.phPhi(), m2.phEta(), m2.phPhi()) >= minDR2_);
506 }
507 
508 namespace {
509 
510  double getCandidateVZ(reco::RecoChargedCandidate const& cand, bool& isValidVZ, int const minPixHitsForValidVZ) {
511  if (minPixHitsForValidVZ > 0) {
512  auto const track = cand.track();
513  if (not(track.isNonnull() and track.isAvailable() and
514  track->hitPattern().numberOfValidPixelHits() >= minPixHitsForValidVZ)) {
515  isValidVZ = false;
516  return 0;
517  }
518  }
519 
520  isValidVZ = true;
521  return cand.vz();
522  }
523 
524  double getCandidateVZ(reco::RecoEcalCandidate const& cand,
525  bool& isValidVZ,
526  int const minPixHitsForValidVZ,
528  reco::Electron const* elec_ptr = nullptr;
529  for (auto const& elec : electrons) {
530  if (elec.superCluster() == cand.superCluster()) {
531  elec_ptr = &elec;
532  }
533  }
534 
535  if (elec_ptr == nullptr) {
536  // IMPROVE, kept for backward compatibility
537  isValidVZ = true;
538  return 0; // equivalent to 'reco::Electron e1; return e1.vz();'
539  }
540 
541  if (minPixHitsForValidVZ > 0) {
542  auto const track = elec_ptr->gsfTrack();
543  if (not(track.isNonnull() and track.isAvailable() and
544  track->hitPattern().numberOfValidPixelHits() >= minPixHitsForValidVZ)) {
545  isValidVZ = false;
546  return 0;
547  }
548  }
549 
550  isValidVZ = true;
551  return elec_ptr->vz();
552  }
553 
554  double getCandidateVZ(l1t::HPSPFTau const& cand, bool& isValidVZ) {
555  auto const& leadChargedPFCand = cand.leadChargedPFCand();
556  if (leadChargedPFCand.isNonnull() and leadChargedPFCand.isAvailable()) {
557  auto const& pfTrack = leadChargedPFCand->pfTrack();
558  if (pfTrack.isNonnull() and pfTrack.isAvailable()) {
559  isValidVZ = true;
560  return pfTrack->vertex().z();
561  }
562  }
563 
564  isValidVZ = false;
565  return 0;
566  }
567 
568 } // namespace
569 
570 template <typename T1, typename T2>
571 bool HLTDoubletDZ<T1, T2>::computeDZ(edm::Event const&, T1 const& c1, T2 const& c2) const {
572  return ((std::abs(c1.vz() - c2.vz()) <= maxDZ_) and passCutMinDeltaR(c1, c2));
573 }
574 
575 template <>
577  l1t::P2GTCandidate const& c1,
578  l1t::P2GTCandidate const& c2) const {
579  if (maxDZ_ > 0 && std::abs(c1.vz() - c2.vz()) > maxDZ_) {
580  return false;
581  }
582 
583  if (not passCutMinDeltaR(c1, c2)) {
584  return false;
585  }
586 
587  return true;
588 }
589 
590 template <>
592  edm::Event const& iEvent, reco::RecoEcalCandidate const& c1, reco::RecoChargedCandidate const& c2) const {
593  if (not passCutMinDeltaR(c1, c2))
594  return false;
595 
596  bool hasValidVZ2 = false;
597  auto const vz2 = getCandidateVZ(c2, hasValidVZ2, minPixHitsForDZ_);
598  if (not hasValidVZ2)
599  return true;
600 
601  bool hasValidVZ1 = false;
602  auto const& electrons = iEvent.get(electronToken_);
603  auto const vz1 = getCandidateVZ(c1, hasValidVZ1, minPixHitsForDZ_, electrons);
604  if (not hasValidVZ1)
605  return true;
606 
607  return (std::abs(vz1 - vz2) <= maxDZ_);
608 }
609 
610 template <>
612  edm::Event const& iEvent, reco::RecoChargedCandidate const& c1, reco::RecoEcalCandidate const& c2) const {
613  if (not passCutMinDeltaR(c1, c2))
614  return false;
615 
616  bool hasValidVZ1 = false;
617  auto const vz1 = getCandidateVZ(c1, hasValidVZ1, minPixHitsForDZ_);
618  if (not hasValidVZ1)
619  return true;
620 
621  bool hasValidVZ2 = false;
622  auto const& electrons = iEvent.get(electronToken_);
623  auto const vz2 = getCandidateVZ(c2, hasValidVZ2, minPixHitsForDZ_, electrons);
624  if (not hasValidVZ2)
625  return true;
626 
627  return (std::abs(vz1 - vz2) <= maxDZ_);
628 }
629 
630 template <>
632  edm::Event const& iEvent, reco::RecoEcalCandidate const& c1, reco::RecoEcalCandidate const& c2) const {
633  if (not passCutMinDeltaR(c1, c2))
634  return false;
635 
636  auto const& electrons = iEvent.get(electronToken_);
637 
638  bool hasValidVZ1 = false;
639  auto const vz1 = getCandidateVZ(c1, hasValidVZ1, minPixHitsForDZ_, electrons);
640  if (not hasValidVZ1)
641  return true;
642 
643  bool hasValidVZ2 = false;
644  auto const vz2 = getCandidateVZ(c2, hasValidVZ2, minPixHitsForDZ_, electrons);
645  if (not hasValidVZ2)
646  return true;
647 
648  return (std::abs(vz1 - vz2) <= maxDZ_);
649 }
650 
651 template <>
654  if (not passCutMinDeltaR(c1, c2))
655  return false;
656 
657  bool hasValidVZ1 = false;
658  auto const vz1 = getCandidateVZ(c1, hasValidVZ1, minPixHitsForDZ_);
659  if (not hasValidVZ1)
660  return true;
661 
662  bool hasValidVZ2 = false;
663  auto const vz2 = getCandidateVZ(c2, hasValidVZ2, minPixHitsForDZ_);
664  if (not hasValidVZ2)
665  return true;
666 
667  return (std::abs(vz1 - vz2) <= maxDZ_);
668 }
669 
670 template <>
672  l1t::TrackerMuon const& c1,
673  l1t::TrackerMuon const& c2) const {
674  return ((std::abs(c1.phZ0() - c2.phZ0()) <= maxDZ_) and passCutMinDeltaR(c1, c2));
675 }
676 
677 template <>
679  l1t::HPSPFTau const& c1,
680  l1t::HPSPFTau const& c2) const {
681  if (not passCutMinDeltaR(c1, c2))
682  return false;
683 
684  bool hasValidVZ1 = false;
685  auto const vz1 = getCandidateVZ(c1, hasValidVZ1);
686  if (not hasValidVZ1)
687  return false;
688 
689  bool hasValidVZ2 = false;
690  auto const vz2 = getCandidateVZ(c2, hasValidVZ2);
691  if (not hasValidVZ2)
692  return false;
693 
694  return (std::abs(vz1 - vz2) <= maxDZ_);
695 }
696 
697 template <typename T1, typename T2>
699  edm::EventSetup const& iSetup,
700  trigger::TriggerFilterObjectWithRefs& filterproduct) const {
701  // All HLT filters must create and fill an HLT filter object,
702  // recording any reconstructed physics objects satisfying (or not)
703  // this HLT filter, and place it in the Event.
704  std::vector<T1Ref> coll1;
705  std::vector<T2Ref> coll2;
706 
707  if (getCollections(iEvent, coll1, coll2, filterproduct)) {
708  int n(0);
709  T1Ref r1;
710  T2Ref r2;
711 
712  for (unsigned int i1 = 0; i1 < coll1.size(); ++i1) {
713  r1 = coll1[i1];
714  unsigned int const I = same_ ? i1 + 1 : 0;
715  for (unsigned int i2 = I; i2 < coll2.size(); ++i2) {
716  r2 = coll2[i2];
717 
718  if (checkSC_ and haveSameSuperCluster(*r1, *r2)) {
719  continue;
720  }
721 
722  if (not computeDZ(iEvent, *r1, *r2)) {
723  continue;
724  }
725 
726  n++;
727  filterproduct.addObject(triggerType1_, r1);
728  filterproduct.addObject(triggerType2_, r2);
729  }
730  }
731 
732  return (n >= min_N_);
733  }
734 
735  return false;
736 }
737 
738 template <>
740  edm::Event& iEvent, const edm::EventSetup& iSetup, trigger::TriggerFilterObjectWithRefs& filterproduct) const {
741  // All HLT filters must create and fill an HLT filter object,
742  // recording any reconstructed physics objects satisfying (or not)
743  // this HLT filter, and place it in the Event.
744  bool accept(false);
745 
746  std::vector<l1t::P2GTCandidateRef> coll1;
747  std::vector<l1t::P2GTCandidateRef> coll2;
748 
749  if (getCollections(iEvent, coll1, coll2, filterproduct)) {
750  int n(0);
753 
754  for (unsigned int i1 = 0; i1 != coll1.size(); i1++) {
755  r1 = coll1[i1];
756  unsigned int I(0);
757  if (same_) {
758  I = i1 + 1;
759  }
760  for (unsigned int i2 = I; i2 != coll2.size(); i2++) {
761  r2 = coll2[i2];
762 
763  if (!computeDZ(iEvent, *r1, *r2))
764  continue;
765 
766  n++;
767  filterproduct.addObject(triggerType1_, r1);
768  filterproduct.addObject(triggerType2_, r2);
769  }
770  }
771 
772  accept = accept || (n >= min_N_);
773  }
774  return accept;
775 }
776 
787 
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
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:61