CMS 3D CMS Logo

PFRecHitQTests.h
Go to the documentation of this file.
1 #ifndef RecoParticleFlow_PFClusterProducer_PFEcalRecHitQTests_h
2 #define RecoParticleFlow_PFClusterProducer_PFEcalRecHitQTests_h
3 
4 #include <memory>
15 
16 #include <iostream>
17 
18 //
19 // Quality test that checks threshold
20 //
22 public:
24 
26  : PFRecHitQTestBase(iConfig, cc), threshold_(iConfig.getParameter<double>("threshold")) {}
27 
28  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {}
29 
30  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
31  return fullReadOut or pass(hit);
32  }
33  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override { return pass(hit); }
34 
35  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override { return pass(hit); }
36  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override { return pass(hit); }
37 
38  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return pass(hit); }
39 
40  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return pass(hit); }
41 
42 protected:
43  double threshold_;
44 
45  bool pass(const reco::PFRecHit& hit) { return hit.energy() > threshold_; }
46 };
47 
48 //
49 // Quality test that checks threshold read from the DB
50 //
52 public:
54 
56  : PFRecHitQTestBase(iConfig, cc),
57  applySelectionsToAllCrystals_(iConfig.getParameter<bool>("applySelectionsToAllCrystals")),
59 
60  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
61  ths_ = iSetup.getHandle(threshToken_);
62  }
63 
64  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
66  return pass(hit);
67  return fullReadOut or pass(hit);
68  }
69  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override { return pass(hit); }
70 
71  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override { return pass(hit); }
72  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override { return pass(hit); }
73 
74  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return pass(hit); }
75 
76  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return pass(hit); }
77 
78 protected:
81 
82  bool pass(const reco::PFRecHit& hit) {
83  float threshold = (*ths_)[hit.detId()];
84  return hit.energy() > threshold;
85  }
86 
87 private:
89 };
90 
91 //
92 // Quality test that checks kHCAL Severity
93 //
95 public:
97 
99  : PFRecHitQTestBase(iConfig, cc),
100  flagStr_(iConfig.getParameter<std::vector<std::string>>("flags")),
101  thresholds_(iConfig.getParameter<std::vector<int>>("maxSeverities")),
102  cleanThresholds_(iConfig.getParameter<std::vector<double>>("cleaningThresholds")),
104  qualityToken_(cc.esConsumes(edm::ESInputTag("", "withTopo"))),
106  for (auto& flag : flagStr_) {
107  if (flag == "Standard") {
108  flags_.push_back(-1);
109  depths_.push_back(-1);
110  } else if (flag == "HFInTime") {
112  depths_.push_back(-1);
113  } else if (flag == "HFDigi") {
114  flags_.push_back(1 << HcalCaloFlagLabels::HFDigiTime);
115  depths_.push_back(-1);
116  } else if (flag == "HFLong") {
117  flags_.push_back(1 << HcalCaloFlagLabels::HFLongShort);
118  depths_.push_back(1);
119  } else if (flag == "HFShort") {
120  flags_.push_back(1 << HcalCaloFlagLabels::HFLongShort);
121  depths_.push_back(2);
122  } else if (flag == "HFSignalAsymmetry") {
124  depths_.push_back(-1);
125  } else {
126  flags_.push_back(-1);
127  depths_.push_back(-1);
128  }
129  }
130  }
131 
132  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
136  }
137 
138  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override { return true; }
139  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override {
140  return test(rh.detid(), rh.energy(), rh.flags(), clean);
141  }
142 
143  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override {
144  return test(rh.detid(), rh.energy(), rh.flags(), clean);
145  }
146  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override {
147  return test(rh.detid(), rh.energy(), rh.flags(), clean);
148  }
149 
150  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return true; }
151 
152  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return true; }
153 
154 protected:
155  std::vector<std::string> flagStr_;
156  std::vector<int> thresholds_;
157  std::vector<double> cleanThresholds_;
158  std::vector<int> flags_;
159  std::vector<int> depths_;
163 
164  bool test(unsigned aDETID, double energy, int flags, bool& clean) {
165  HcalDetId detid = (HcalDetId)aDETID;
166  if (theHcalTopology_->getMergePositionFlag() and detid.subdet() == HcalEndcap) {
167  detid = theHcalTopology_->idFront(detid);
168  }
169 
170  const HcalChannelStatus* theStatus = theHcalChStatus_->getValues(detid);
171  unsigned theStatusValue = theStatus->getValue();
172  // Now get severity of problems for the given detID, based on the rechit flag word and the channel quality status value
173  for (unsigned int i = 0; i < thresholds_.size(); ++i) {
174  int hitSeverity = 0;
175  if (energy < cleanThresholds_[i])
176  continue;
177 
178  if (flags_[i] < 0) {
179  hitSeverity = hcalSevLvlComputer_->getSeverityLevel(detid, flags, theStatusValue);
180  } else {
181  hitSeverity = hcalSevLvlComputer_->getSeverityLevel(detid, flags & flags_[i], theStatusValue);
182  }
183 
184  if (hitSeverity > thresholds_[i] and ((depths_[i] < 0 or (depths_[i] == detid.depth())))) {
185  clean = true;
186  return false;
187  }
188  }
189  return true;
190  }
191 
192 private:
196 };
197 
198 //
199 // Quality test that applies threshold and timing as a function of depth
200 //
202 public:
204 
206  : PFRecHitQTestBase(iConfig, cc), psets_(iConfig.getParameter<std::vector<edm::ParameterSet>>("cuts")) {
207  for (auto& pset : psets_) {
208  depths_.push_back(pset.getParameter<int>("depth"));
209  minTimes_.push_back(pset.getParameter<double>("minTime"));
210  maxTimes_.push_back(pset.getParameter<double>("maxTime"));
211  thresholds_.push_back(pset.getParameter<double>("threshold"));
212  }
213  }
214 
215  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {}
216 
217  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override { return true; }
218  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override {
219  return test(rh.detid(), rh.energy(), rh.time(), clean);
220  }
221 
222  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override {
223  return test(rh.detid(), rh.energy(), rh.time(), clean);
224  }
225  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override {
226  return test(rh.detid(), rh.energy(), rh.time(), clean);
227  }
228 
229  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return true; }
230 
231  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return true; }
232 
233 protected:
234  std::vector<edm::ParameterSet> psets_;
235  std::vector<int> depths_;
236  std::vector<double> minTimes_;
237  std::vector<double> maxTimes_;
238  std::vector<double> thresholds_;
239 
240  bool test(unsigned aDETID, double energy, double time, bool& clean) {
241  HcalDetId detid(aDETID);
242  for (unsigned int i = 0; i < depths_.size(); ++i) {
243  if (detid.depth() == depths_[i]) {
244  if ((time < minTimes_[i] or time > maxTimes_[i]) and energy > thresholds_[i]) {
245  clean = true;
246  return false;
247  }
248  break;
249  }
250  }
251  return true;
252  }
253 };
254 
255 //
256 // Quality test that applies threshold as a function of depth
257 //
259 public:
261 
263  : PFRecHitQTestBase(iConfig, cc),
264  psets_(iConfig.getParameter<std::vector<edm::ParameterSet>>("cuts")),
265  cutsFromDB(iConfig.getParameter<bool>("usePFThresholdsFromDB")) {
266  if (cutsFromDB) {
267  hcalCutsToken_ = cc.esConsumes<HcalPFCuts, HcalPFCutsRcd>(edm::ESInputTag("", "withTopo"));
268  }
269  for (auto& pset : psets_) {
270  depths_.push_back(pset.getParameter<std::vector<int>>("depth"));
271  thresholds_.push_back(pset.getParameter<std::vector<double>>("threshold"));
272  detector_.push_back(pset.getParameter<int>("detectorEnum"));
273  if (thresholds_[thresholds_.size() - 1].size() != depths_[depths_.size() - 1].size()) {
274  throw cms::Exception("InvalidPFRecHitThreshold") << "PFRecHitThreshold mismatch with the numbers of depths";
275  }
276  }
277  }
278 
279  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
280  if (cutsFromDB) {
281  paramPF = &iSetup.getData(hcalCutsToken_);
282  }
283  }
284 
285  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override { return true; }
286  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override {
287  return test(rh.detid(), rh.energy(), rh.time(), clean);
288  }
289 
290  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override {
291  return test(rh.detid(), rh.energy(), rh.time(), clean);
292  }
293  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override {
294  return test(rh.detid(), rh.energy(), rh.time(), clean);
295  }
296 
297  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return true; }
298 
299  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return true; }
300 
301 protected:
302  std::vector<edm::ParameterSet> psets_;
303  std::vector<std::vector<int>> depths_;
304  std::vector<std::vector<double>> thresholds_;
305  std::vector<int> detector_;
306  HcalPFCuts const* paramPF = nullptr;
307 
308  bool test(unsigned aDETID, double energy, double time, bool& clean) {
309  HcalDetId detid(aDETID);
310  const HcalPFCut* item = nullptr;
311  if (cutsFromDB) {
312  item = paramPF->getValues(detid.rawId());
313  }
314 
315  for (unsigned int d = 0; d < detector_.size(); ++d) {
316  if (detid.subdet() != detector_[d])
317  continue;
318  for (unsigned int i = 0; i < thresholds_[d].size(); ++i) {
319  if (detid.depth() == depths_[d][i]) {
320  float thres = cutsFromDB ? item->noiseThreshold() : thresholds_[d][i];
321  if (energy < thres) {
322  clean = false;
323  return false;
324  }
325  break;
326  }
327  }
328  }
329  return true;
330  }
331 
332 private:
336 };
337 
338 //
339 // Quality test that checks HO threshold applying different threshold in rings
340 //
342 public:
344 
346  : PFRecHitQTestBase(iConfig, cc),
347  threshold0_(iConfig.getParameter<double>("threshold_ring0")),
348  threshold12_(iConfig.getParameter<double>("threshold_ring12")) {}
349 
350  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {}
351 
352  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override { return true; }
353 
354  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override { return true; }
355 
356  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override { return true; }
357 
358  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override {
359  HcalDetId detid(rh.detid());
360  if (abs(detid.ieta()) <= 4 and hit.energy() > threshold0_)
361  return true;
362  if (abs(detid.ieta()) > 4 and hit.energy() > threshold12_)
363  return true;
364 
365  return false;
366  }
367 
368  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return true; }
369 
370  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return true; }
371 
372 protected:
373  const double threshold0_;
374  const double threshold12_;
375 };
376 
377 //
378 // Quality test that checks threshold as a function of ECAL eta-ring
379 //
385 public:
387 
389  : PFRecHitQTestBase(iConfig, cc),
390  thresholds_(iConfig.getParameter<std::vector<double>>("thresholds")),
391  applySelectionsToAllCrystals_(iConfig.getParameter<bool>("applySelectionsToAllCrystals")),
394  throw edm::Exception(edm::errors::Configuration, "ValueError")
395  << "thresholds is expected to have " << EcalRingCalibrationTools::N_RING_TOTAL << " elements but has "
396  << thresholds_.size();
397  }
398 
399  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
402  endcapGeometrySet_ = false;
403  if (endcapGeometry) {
405  endcapGeometrySet_ = true;
406  }
407  }
408 
409  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
411  return pass(hit);
412  else
413  return fullReadOut or pass(hit);
414  }
415  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override { return true; }
416 
417  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override { return true; }
418  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override { return true; }
419 
420  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return true; }
421 
422  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return true; }
423 
424 protected:
425  const std::vector<double> thresholds_;
427 
428  // apply selections to all crystals
430 
431  bool pass(const reco::PFRecHit& hit) {
432  DetId detId(hit.detId());
433 
434  // this is to skip endcap ZS for Phase2 until there is a defined geometry
435  // apply the loosest ZS threshold, for the first eta-ring in EB
436  if (not endcapGeometrySet_) {
437  // there is only ECAL EB in Phase 2
438  if (detId.subdetId() != EcalBarrel)
439  return true;
440 
441  // 0-169: EB eta-rings
442  // 170-208: EE- eta rings
443  // 209-247: EE+ eta rings
444  int firstEBRing = 0;
445  return (hit.energy() > thresholds_[firstEBRing]);
446  }
447 
449  if (hit.energy() > thresholds_[iring])
450  return true;
451 
452  return false;
453  }
454 
455 private:
457 };
458 
459 //
460 // Quality test that checks ecal quality cuts
461 //
463 public:
465 
467  : PFRecHitQTestBase(iConfig, cc),
468  thresholdCleaning_(iConfig.getParameter<double>("cleaningThreshold")),
469  timingCleaning_(iConfig.getParameter<bool>("timingCleaning")),
470  topologicalCleaning_(iConfig.getParameter<bool>("topologicalCleaning")),
471  skipTTRecoveredHits_(iConfig.getParameter<bool>("skipTTRecoveredHits")) {}
472 
473  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {}
474 
475  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
477  clean = true;
478  return false;
479  }
481  clean = true;
482  return false;
483  }
484 
486  clean = true;
487  return false;
488  }
489 
490  return true;
491  }
492 
493  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override { return true; }
494 
495  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override { return true; }
496 
497  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override { return true; }
498 
499  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return true; }
500 
501  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return true; }
502 
503 protected:
508 };
509 
510 //
511 // Quality test that checks ES quality cuts
512 //
514 public:
516 
518  : PFRecHitQTestBase(iConfig, cc),
519  thresholdCleaning_(iConfig.getParameter<double>("cleaningThreshold")),
520  topologicalCleaning_(iConfig.getParameter<bool>("topologicalCleaning")) {}
521 
522  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {}
523 
524  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
525  if (rh.energy() < thresholdCleaning_) {
526  clean = false;
527  return false;
528  }
529 
530  if (topologicalCleaning_ and
535  clean = false;
536  return false;
537  }
538 
539  return true;
540  }
541 
542  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override { return true; }
543 
544  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override { return true; }
545 
546  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override { return true; }
547 
548  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return true; }
549 
550  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return true; }
551 
552 protected:
553  const double thresholdCleaning_;
555 };
556 
557 //
558 // Quality test that calibrates tower 29 of HCAL
559 //
561 public:
563 
565  : PFRecHitQTestBase(iConfig, cc), calibFactor_(iConfig.getParameter<double>("calibFactor")) {}
566 
567  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {}
568 
569  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override { return true; }
570  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override {
571  HcalDetId detId(hit.detId());
572  if (abs(detId.ieta()) == 29)
573  hit.setEnergy(hit.energy() * calibFactor_);
574  return true;
575  }
576 
577  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override { return true; }
578  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override { return true; }
579 
580  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override {
581  CaloTowerDetId detId(hit.detId());
582  if (detId.ietaAbs() == 29)
583  hit.setEnergy(hit.energy() * calibFactor_);
584  return true;
585  }
586 
587  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return true; }
588 
589 protected:
590  const float calibFactor_;
591 };
592 
594 public:
596 
598  : PFRecHitQTestBase(iConfig, cc),
599  recHitEnergy_keV_(iConfig.getParameter<bool>("recHitEnergyIs_keV")),
600  threshold_(iConfig.getParameter<double>("thresholdInMIPs")),
601  mip_(iConfig.getParameter<double>("mipValueInkeV")),
602  recHitEnergyMultiplier_(iConfig.getParameter<double>("recHitEnergyMultiplier")) {}
603 
604  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {}
605 
606  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
607  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
608  return false;
609  }
610  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override {
611  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
612  return false;
613  }
614 
615  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override {
616  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
617  return false;
618  }
619  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override {
620  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
621  return false;
622  }
623 
624  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override {
625  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
626  return false;
627  }
628 
629  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override {
630  const double newE =
632  hit.setEnergy(newE);
633  return pass(hit);
634  }
635 
636 protected:
637  const bool recHitEnergy_keV_;
639 
640  bool pass(const reco::PFRecHit& hit) {
641  const double hitValueInMIPs = 1e6 * hit.energy() / mip_;
642  return hitValueInMIPs > threshold_;
643  }
644 };
645 
648 public:
651 
653  : PFRecHitQTestBase(iConfig, cc),
654  geometryInstance_(iConfig.getParameter<std::string>("geometryInstance")),
655  recHitEnergy_keV_(iConfig.getParameter<bool>("recHitEnergyIs_keV")),
656  threshold_(iConfig.getParameter<double>("thresholdInMIPs")),
657  mip_(iConfig.getParameter<double>("mipValueInkeV")),
658  recHitEnergyMultiplier_(iConfig.getParameter<double>("recHitEnergyMultiplier")),
659  geomToken_(cc.esConsumes()) {}
660 
661  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
663  ddd_ = &(geoHandle->topology().dddConstants());
664  }
665 
666  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
667  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
668  return false;
669  }
670  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override {
671  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
672  return false;
673  }
674 
675  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override {
676  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
677  return false;
678  }
679  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override {
680  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
681  return false;
682  }
683 
684  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override {
685  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
686  return false;
687  }
688 
689  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override {
690  const double newE =
692  const int wafer = HGCalDetId(rh.detid()).wafer();
693  const float mult = (float)ddd_->waferTypeL(wafer); // 1 for 100um, 2 for 200um, 3 for 300um
694  hit.setEnergy(newE);
695  return pass(hit, mult);
696  }
697 
698 protected:
700  const bool recHitEnergy_keV_;
703 
704  bool pass(const reco::PFRecHit& hit, const float mult) {
705  const double hitValueInMIPs = 1e6 * hit.energy() / (mult * mip_);
706  return hitValueInMIPs > threshold_;
707  }
708 
709 private:
711 };
712 
714 public:
716 
718  : PFRecHitQTestBase(iConfig, cc), thresholdSNR_(iConfig.getParameter<double>("thresholdSNR")) {}
719 
720  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {}
721 
722  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
723  throw cms::Exception("WrongDetector") << "PFRecHitQTestHGCalThresholdSNR only works for HGCAL!";
724  return false;
725  }
726  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override {
727  throw cms::Exception("WrongDetector") << "PFRecHitQTestHGCalThresholdSNR only works for HGCAL!";
728  return false;
729  }
730 
731  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override {
732  throw cms::Exception("WrongDetector") << "PFRecHitQTestHGCalThresholdSNR only works for HGCAL!";
733  return false;
734  }
735  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override {
736  throw cms::Exception("WrongDetector") << "PFRecHitQTestHGCalThresholdSNR only works for HGCAL!";
737  return false;
738  }
739 
740  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override {
741  throw cms::Exception("WrongDetector") << "PFRecHitQTestHGCalThresholdSNR only works for HGCAL!";
742  return false;
743  }
744 
745  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override {
746  return rh.signalOverSigmaNoise() >= thresholdSNR_;
747  }
748 
749 protected:
750  const double thresholdSNR_;
751 };
752 
753 // M.G. Quality test that checks seeding threshold read from the DB
754 //
756 public:
758  : PFRecHitQTestBase(iConfig, cc),
759  applySelectionsToAllCrystals_(iConfig.getParameter<bool>("applySelectionsToAllCrystals")),
761 
762  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
763  ths_ = iSetup.getHandle(threshToken_);
764  }
765 
766  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
768  return pass(hit);
769  return fullReadOut or pass(hit);
770  }
771  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override { return pass(hit); }
772 
773  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override { return pass(hit); }
774  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override { return pass(hit); }
775 
776  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return pass(hit); }
777 
778  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return pass(hit); }
779 
780 protected:
783 
784  bool pass(const reco::PFRecHit& hit) {
785  float threshold = (*ths_)[hit.detId()];
786  return (hit.energy() > threshold);
787  }
788 
789 private:
791 };
792 
793 #endif
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override
void beginEvent(const edm::Event &event, const edm::EventSetup &iSetup) override
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > geomToken_
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override
bool getMergePositionFlag() const
Definition: HcalTopology.h:167
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
const HcalChannelQuality * theHcalChStatus_
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
PFRecHitQTestDBSeedingThreshold(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
void beginEvent(const edm::Event &event, const edm::EventSetup &iSetup) override
PFRecHitQTestES(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
edm::ESGetToken< HcalSeverityLevelComputer, HcalSeverityLevelComputerRcd > severityToken_
constexpr const DetId & detid() const
Definition: CaloRecHit.h:33
void beginEvent(const edm::Event &event, const edm::EventSetup &iSetup) override
static void setCaloGeometry(const CaloGeometry *geometry)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
std::vector< double > minTimes_
bool pass(const reco::PFRecHit &hit)
edm::ESGetToken< EcalPFSeedingThresholds, EcalPFSeedingThresholdsRcd > threshToken_
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
PFRecHitQTestHCALCalib29(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
std::vector< int > depths_
PFRecHitQTestECALMultiThreshold(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
float signalOverSigmaNoise() const
Definition: HGCRecHit.cc:72
bool pass(const reco::PFRecHit &hit, const float mult)
const HcalSeverityLevelComputer * hcalSevLvlComputer_
PFRecHitQTestDBThreshold(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
std::vector< double > maxTimes_
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > topoToken_
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
bool test(unsigned aDETID, double energy, double time, bool &clean)
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override
static short getRingIndex(DetId aDetId)
Retrieve the phi-ring index corresponding to a DetId.
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
std::vector< double > cleanThresholds_
PFRecHitQTestHCALChannel(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
std::vector< double > thresholds_
bool pass(const reco::PFRecHit &hit)
const HcalTopology * theHcalTopology_
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override
void beginEvent(const edm::Event &event, const edm::EventSetup &iSetup) override
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
const Item * getValues(DetId fId, bool throwOnFail=true) const
constexpr float energy() const
Definition: CaloRecHit.h:29
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
static void clean(char *s)
bool test(unsigned aDETID, double energy, double time, bool &clean)
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
void beginEvent(const edm::Event &event, const edm::EventSetup &iSetup) override
void beginEvent(const edm::Event &event, const edm::EventSetup &iSetup) override
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:31
constexpr uint32_t flags() const
Definition: CaloRecHit.h:34
HcalDetId idFront(const HcalDetId &id) const
Definition: HcalTopology.h:170
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
PFRecHitQTestThreshold(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
PFRecHitQTestHCALTimeVsDepth(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
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
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
bool pass(const reco::PFRecHit &hit)
void beginEvent(const edm::Event &event, const edm::EventSetup &iSetup) override
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void beginEvent(const edm::Event &event, const edm::EventSetup &iSetup) override
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override
edm::ESGetToken< HcalChannelQuality, HcalChannelQualityRcd > qualityToken_
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
const std::vector< double > thresholds_
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
const HGCalTopology & topology() const
d
Definition: ztail.py:151
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
uint32_t getValue() const
PFRecHitQTestThresholdInThicknessNormalizedMIPs(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
PFRecHitQTestHCALThresholdVsDepth(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
void beginEvent(const edm::Event &event, const edm::EventSetup &iSetup) override
edm::ESGetToken< HcalPFCuts, HcalPFCutsRcd > hcalCutsToken_
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override
void beginEvent(const edm::Event &event, const edm::EventSetup &iSetup) override
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override
PFRecHitQTestECAL(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
Definition: DetId.h:17
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
static constexpr short N_RING_TOTAL
edm::ESGetToken< HcalTopology, HcalRecNumberingRecord > htopoToken_
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
std::vector< edm::ParameterSet > psets_
PFRecHitQTestHGCalThresholdSNR(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
void beginEvent(const edm::Event &event, const edm::EventSetup &iSetup) override
std::vector< int > depths_
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
std::vector< std::vector< double > > thresholds_
edm::ESHandle< EcalPFRecHitThresholds > ths_
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
PFRecHitQTestThresholdInMIPs(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
edm::ESGetToken< EcalPFRecHitThresholds, EcalPFRecHitThresholdsRcd > threshToken_
constexpr float time() const
Definition: CaloRecHit.h:31
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
void beginEvent(const edm::Event &event, const edm::EventSetup &iSetup) override
void beginEvent(const edm::Event &event, const edm::EventSetup &iSetup) override
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
std::vector< std::string > flagStr_
HLT enums.
std::vector< int > thresholds_
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
int waferTypeL(int wafer) const
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
edm::ESHandle< EcalPFSeedingThresholds > ths_
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
bool pass(const reco::PFRecHit &hit)
const bool topologicalCleaning_
edm::ESGetToken< HGCalGeometry, IdealGeometryRecord > geomToken_
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
bool test(unsigned aDETID, double energy, int flags, bool &clean)
std::vector< edm::ParameterSet > psets_
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
void beginEvent(const edm::Event &event, const edm::EventSetup &iSetup) override
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
float energy() const
Definition: EcalRecHit.h:69
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
bool pass(const reco::PFRecHit &hit)
const double thresholdCleaning_
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:34
std::vector< int > flags_
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
PFRecHitQTestHOThreshold(const edm::ParameterSet &iConfig, edm::ConsumesCollector &cc)
const HGCalDDDConstants & dddConstants() const
Definition: HGCalTopology.h:98
bool checkFlag(int flag) const
check if the flag is true
Definition: EcalRecHit.h:188
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
Definition: event.py:1
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override
std::vector< std::vector< int > > depths_
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164