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>
12 
13 #include <iostream>
14 
15 //
16 // Quality test that checks threshold
17 //
19 public:
21 
23  : PFRecHitQTestBase(iConfig), threshold_(iConfig.getParameter<double>("threshold")) {}
24 
25  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {}
26 
27  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
28  return fullReadOut or pass(hit);
29  }
30  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override { return pass(hit); }
31 
32  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override { return pass(hit); }
33  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override { return pass(hit); }
34 
35  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return pass(hit); }
36 
37  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return pass(hit); }
38 
39 protected:
40  double threshold_;
41 
42  bool pass(const reco::PFRecHit& hit) { return hit.energy() > threshold_; }
43 };
44 
45 //
46 // Quality test that checks threshold read from the DB
47 //
49 public:
50  PFRecHitQTestDBThreshold() : eventSetup_(nullptr) {}
51 
53  : PFRecHitQTestBase(iConfig),
54  applySelectionsToAllCrystals_(iConfig.getParameter<bool>("applySelectionsToAllCrystals")),
55  eventSetup_(nullptr) {}
56 
57  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override { eventSetup_ = &iSetup; }
58 
59  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
60  if (applySelectionsToAllCrystals_)
61  return pass(hit);
62  return fullReadOut or pass(hit);
63  }
64  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override { return pass(hit); }
65 
66  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override { return pass(hit); }
67  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override { return pass(hit); }
68 
69  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return pass(hit); }
70 
71  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return pass(hit); }
72 
73 protected:
76 
77  bool pass(const reco::PFRecHit& hit) {
79  (*eventSetup_).get<EcalPFRecHitThresholdsRcd>().get(ths);
80 
81  float threshold = (*ths)[hit.detId()];
82  return hit.energy() > threshold;
83  }
84 };
85 
86 //
87 // Quality test that checks kHCAL Severity
88 //
90 public:
92 
94  thresholds_ = iConfig.getParameter<std::vector<int> >("maxSeverities");
95  cleanThresholds_ = iConfig.getParameter<std::vector<double> >("cleaningThresholds");
96  std::vector<std::string> flags = iConfig.getParameter<std::vector<std::string> >("flags");
97  for (auto& flag : flags) {
98  if (flag == "Standard") {
99  flags_.push_back(-1);
100  depths_.push_back(-1);
101  } else if (flag == "HFInTime") {
102  flags_.push_back(1 << HcalCaloFlagLabels::HFInTimeWindow);
103  depths_.push_back(-1);
104  } else if (flag == "HFDigi") {
105  flags_.push_back(1 << HcalCaloFlagLabels::HFDigiTime);
106  depths_.push_back(-1);
107  } else if (flag == "HFLong") {
108  flags_.push_back(1 << HcalCaloFlagLabels::HFLongShort);
109  depths_.push_back(1);
110  } else if (flag == "HFShort") {
111  flags_.push_back(1 << HcalCaloFlagLabels::HFLongShort);
112  depths_.push_back(2);
113  } else {
114  flags_.push_back(-1);
115  depths_.push_back(-1);
116  }
117  }
118  }
119 
120  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
122  iSetup.get<HcalRecNumberingRecord>().get(topo);
123  theHcalTopology_ = topo.product();
125  iSetup.get<HcalChannelQualityRcd>().get("withTopo", hcalChStatus);
126  theHcalChStatus_ = hcalChStatus.product();
127  edm::ESHandle<HcalSeverityLevelComputer> hcalSevLvlComputerHndl;
128  iSetup.get<HcalSeverityLevelComputerRcd>().get(hcalSevLvlComputerHndl);
129  hcalSevLvlComputer_ = hcalSevLvlComputerHndl.product();
130  }
131 
132  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override { return true; }
133  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override {
134  return test(rh.detid(), rh.energy(), rh.flags(), clean);
135  }
136 
137  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override {
138  return test(rh.detid(), rh.energy(), rh.flags(), clean);
139  }
140  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override {
141  return test(rh.detid(), rh.energy(), rh.flags(), clean);
142  }
143 
144  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return true; }
145 
146  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return true; }
147 
148 protected:
149  std::vector<int> thresholds_;
150  std::vector<double> cleanThresholds_;
151  std::vector<int> flags_;
152  std::vector<int> depths_;
156 
157  bool test(unsigned aDETID, double energy, int flags, bool& clean) {
158  HcalDetId detid = (HcalDetId)aDETID;
159  if (theHcalTopology_->getMergePositionFlag() and detid.subdet() == HcalEndcap) {
160  detid = theHcalTopology_->idFront(detid);
161  }
162 
163  const HcalChannelStatus* theStatus = theHcalChStatus_->getValues(detid);
164  unsigned theStatusValue = theStatus->getValue();
165  // Now get severity of problems for the given detID, based on the rechit flag word and the channel quality status value
166  for (unsigned int i = 0; i < thresholds_.size(); ++i) {
167  int hitSeverity = 0;
168  if (energy < cleanThresholds_[i])
169  continue;
170 
171  if (flags_[i] < 0) {
172  hitSeverity = hcalSevLvlComputer_->getSeverityLevel(detid, flags, theStatusValue);
173  } else {
174  hitSeverity = hcalSevLvlComputer_->getSeverityLevel(detid, flags & flags_[i], theStatusValue);
175  }
176 
177  if (hitSeverity > thresholds_[i] and ((depths_[i] < 0 or (depths_[i] == detid.depth())))) {
178  clean = true;
179  return false;
180  }
181  }
182  return true;
183  }
184 };
185 
186 //
187 // Quality test that applies threshold and timing as a function of depth
188 //
190 public:
192 
194  std::vector<edm::ParameterSet> psets = iConfig.getParameter<std::vector<edm::ParameterSet> >("cuts");
195  for (auto& pset : psets) {
196  depths_.push_back(pset.getParameter<int>("depth"));
197  minTimes_.push_back(pset.getParameter<double>("minTime"));
198  maxTimes_.push_back(pset.getParameter<double>("maxTime"));
199  thresholds_.push_back(pset.getParameter<double>("threshold"));
200  }
201  }
202 
203  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {}
204 
205  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override { return true; }
206  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override {
207  return test(rh.detid(), rh.energy(), rh.time(), clean);
208  }
209 
210  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override {
211  return test(rh.detid(), rh.energy(), rh.time(), clean);
212  }
213  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override {
214  return test(rh.detid(), rh.energy(), rh.time(), clean);
215  }
216 
217  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return true; }
218 
219  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return true; }
220 
221 protected:
222  std::vector<int> depths_;
223  std::vector<double> minTimes_;
224  std::vector<double> maxTimes_;
225  std::vector<double> thresholds_;
226 
227  bool test(unsigned aDETID, double energy, double time, bool& clean) {
228  HcalDetId detid(aDETID);
229  for (unsigned int i = 0; i < depths_.size(); ++i) {
230  if (detid.depth() == depths_[i]) {
231  if ((time < minTimes_[i] or time > maxTimes_[i]) and energy > thresholds_[i]) {
232  clean = true;
233  return false;
234  }
235  break;
236  }
237  }
238  return true;
239  }
240 };
241 
242 //
243 // Quality test that applies threshold as a function of depth
244 //
246 public:
248 
250  std::vector<edm::ParameterSet> psets = iConfig.getParameter<std::vector<edm::ParameterSet> >("cuts");
251  for (auto& pset : psets) {
252  depths_ = pset.getParameter<std::vector<int> >("depth");
253  thresholds_ = pset.getParameter<std::vector<double> >("threshold");
254  detector_ = pset.getParameter<int>("detectorEnum");
255  if (thresholds_.size() != depths_.size()) {
256  throw cms::Exception("InvalidPFRecHitThreshold") << "PFRecHitThreshold mismatch with the numbers of depths";
257  }
258  }
259  }
260 
261  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {}
262 
263  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override { return true; }
264  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override {
265  return test(rh.detid(), rh.energy(), rh.time(), clean);
266  }
267 
268  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override {
269  return test(rh.detid(), rh.energy(), rh.time(), clean);
270  }
271  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override {
272  return test(rh.detid(), rh.energy(), rh.time(), clean);
273  }
274 
275  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return true; }
276 
277  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return true; }
278 
279 protected:
280  std::vector<int> depths_;
281  std::vector<double> thresholds_;
283 
284  bool test(unsigned aDETID, double energy, double time, bool& clean) {
285  HcalDetId detid(aDETID);
286 
287  for (unsigned int i = 0; i < thresholds_.size(); ++i) {
288  if (detid.depth() == depths_[i] && detid.subdet() == detector_) {
289  if (energy < thresholds_[i]) {
290  clean = false;
291  return false;
292  }
293  break;
294  }
295  }
296  return true;
297  }
298 };
299 
300 //
301 // Quality test that checks HO threshold applying different threshold in rings
302 //
304 public:
305  PFRecHitQTestHOThreshold() : threshold0_(0.), threshold12_(0.) {}
306 
308  : PFRecHitQTestBase(iConfig),
309  threshold0_(iConfig.getParameter<double>("threshold_ring0")),
310  threshold12_(iConfig.getParameter<double>("threshold_ring12")) {}
311 
312  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {}
313 
314  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override { return true; }
315 
316  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override { return true; }
317 
318  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override { return true; }
319 
320  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override {
321  HcalDetId detid(rh.detid());
322  if (abs(detid.ieta()) <= 4 and hit.energy() > threshold0_)
323  return true;
324  if (abs(detid.ieta()) > 4 and hit.energy() > threshold12_)
325  return true;
326 
327  return false;
328  }
329 
330  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return true; }
331 
332  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return true; }
333 
334 protected:
335  const double threshold0_;
336  const double threshold12_;
337 };
338 
339 //
340 // Quality test that checks threshold as a function of ECAL eta-ring
341 //
347 public:
349 
351  : PFRecHitQTestBase(iConfig),
352  thresholds_(iConfig.getParameter<std::vector<double> >("thresholds")),
353  applySelectionsToAllCrystals_(iConfig.getParameter<bool>("applySelectionsToAllCrystals")) {
354  if (thresholds_.size() != EcalRingCalibrationTools::N_RING_TOTAL)
355  throw edm::Exception(edm::errors::Configuration, "ValueError")
356  << "thresholds is expected to have " << EcalRingCalibrationTools::N_RING_TOTAL << " elements but has "
357  << thresholds_.size();
358  }
359 
360  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
362  iSetup.get<CaloGeometryRecord>().get(pG);
364  endcapGeometrySet_ = false;
365  if (endcapGeometry) {
367  endcapGeometrySet_ = true;
368  }
369  }
370 
371  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
372  if (applySelectionsToAllCrystals_)
373  return pass(hit);
374  else
375  return fullReadOut or pass(hit);
376  }
377  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override { return true; }
378 
379  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override { return true; }
380  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override { return true; }
381 
382  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return true; }
383 
384  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return true; }
385 
386 protected:
387  const std::vector<double> thresholds_;
389 
390  // apply selections to all crystals
392 
393  bool pass(const reco::PFRecHit& hit) {
394  DetId detId(hit.detId());
395 
396  // this is to skip endcap ZS for Phase2 until there is a defined geometry
397  // apply the loosest ZS threshold, for the first eta-ring in EB
398  if (not endcapGeometrySet_) {
399  // there is only ECAL EB in Phase 2
400  if (detId.subdetId() != EcalBarrel)
401  return true;
402 
403  // 0-169: EB eta-rings
404  // 170-208: EE- eta rings
405  // 209-247: EE+ eta rings
406  int firstEBRing = 0;
407  return (hit.energy() > thresholds_[firstEBRing]);
408  }
409 
410  int iring = EcalRingCalibrationTools::getRingIndex(detId);
411  if (hit.energy() > thresholds_[iring])
412  return true;
413 
414  return false;
415  }
416 };
417 
418 //
419 // Quality test that checks ecal quality cuts
420 //
422 public:
424 
426  : PFRecHitQTestBase(iConfig),
427  thresholdCleaning_(iConfig.getParameter<double>("cleaningThreshold")),
428  timingCleaning_(iConfig.getParameter<bool>("timingCleaning")),
429  topologicalCleaning_(iConfig.getParameter<bool>("topologicalCleaning")),
430  skipTTRecoveredHits_(iConfig.getParameter<bool>("skipTTRecoveredHits")) {}
431 
432  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {}
433 
434  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
435  if (skipTTRecoveredHits_ and rh.checkFlag(EcalRecHit::kTowerRecovered)) {
436  clean = true;
437  return false;
438  }
439  if (timingCleaning_ and rh.energy() > thresholdCleaning_ and rh.checkFlag(EcalRecHit::kOutOfTime)) {
440  clean = true;
441  return false;
442  }
443 
444  if (topologicalCleaning_ and (rh.checkFlag(EcalRecHit::kWeird) or rh.checkFlag(EcalRecHit::kDiWeird))) {
445  clean = true;
446  return false;
447  }
448 
449  return true;
450  }
451 
452  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override { return true; }
453 
454  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override { return true; }
455 
456  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override { return true; }
457 
458  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return true; }
459 
460  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return true; }
461 
462 protected:
467 };
468 
469 //
470 // Quality test that checks ES quality cuts
471 //
473 public:
474  PFRecHitQTestES() : thresholdCleaning_(0.), topologicalCleaning_(false) {}
475 
477  : PFRecHitQTestBase(iConfig),
478  thresholdCleaning_(iConfig.getParameter<double>("cleaningThreshold")),
479  topologicalCleaning_(iConfig.getParameter<bool>("topologicalCleaning")) {}
480 
481  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {}
482 
483  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
484  if (rh.energy() < thresholdCleaning_) {
485  clean = false;
486  return false;
487  }
488 
489  if (topologicalCleaning_ and
494  clean = false;
495  return false;
496  }
497 
498  return true;
499  }
500 
501  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override { return true; }
502 
503  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override { return true; }
504 
505  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override { return true; }
506 
507  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return true; }
508 
509  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return true; }
510 
511 protected:
512  const double thresholdCleaning_;
514 };
515 
516 //
517 // Quality test that calibrates tower 29 of HCAL
518 //
520 public:
521  PFRecHitQTestHCALCalib29() : calibFactor_(0.) {}
522 
524  : PFRecHitQTestBase(iConfig), calibFactor_(iConfig.getParameter<double>("calibFactor")) {}
525 
526  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {}
527 
528  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override { return true; }
529  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override {
530  HcalDetId detId(hit.detId());
531  if (abs(detId.ieta()) == 29)
532  hit.setEnergy(hit.energy() * calibFactor_);
533  return true;
534  }
535 
536  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override { return true; }
537  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override { return true; }
538 
539  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override {
540  CaloTowerDetId detId(hit.detId());
541  if (detId.ietaAbs() == 29)
542  hit.setEnergy(hit.energy() * calibFactor_);
543  return true;
544  }
545 
546  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return true; }
547 
548 protected:
549  const float calibFactor_;
550 };
551 
553 public:
554  PFRecHitQTestThresholdInMIPs() : recHitEnergy_keV_(false), threshold_(0.), mip_(0.), recHitEnergyMultiplier_(0.) {}
555 
557  : PFRecHitQTestBase(iConfig),
558  recHitEnergy_keV_(iConfig.getParameter<bool>("recHitEnergyIs_keV")),
559  threshold_(iConfig.getParameter<double>("thresholdInMIPs")),
560  mip_(iConfig.getParameter<double>("mipValueInkeV")),
561  recHitEnergyMultiplier_(iConfig.getParameter<double>("recHitEnergyMultiplier")) {}
562 
563  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {}
564 
565  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
566  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
567  return false;
568  }
569  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override {
570  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
571  return false;
572  }
573 
574  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override {
575  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
576  return false;
577  }
578  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override {
579  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
580  return false;
581  }
582 
583  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override {
584  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
585  return false;
586  }
587 
588  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override {
589  const double newE =
590  (recHitEnergy_keV_ ? 1.0e-6 * rh.energy() * recHitEnergyMultiplier_ : rh.energy() * recHitEnergyMultiplier_);
591  hit.setEnergy(newE);
592  return pass(hit);
593  }
594 
595 protected:
596  const bool recHitEnergy_keV_;
597  const double threshold_, mip_, recHitEnergyMultiplier_;
598 
599  bool pass(const reco::PFRecHit& hit) {
600  const double hitValueInMIPs = 1e6 * hit.energy() / mip_;
601  return hitValueInMIPs > threshold_;
602  }
603 };
604 
607 public:
609  : geometryInstance_(""), recHitEnergy_keV_(0.), threshold_(0.), mip_(0.), recHitEnergyMultiplier_(0.) {}
610 
612  : PFRecHitQTestBase(iConfig),
613  geometryInstance_(iConfig.getParameter<std::string>("geometryInstance")),
614  recHitEnergy_keV_(iConfig.getParameter<bool>("recHitEnergyIs_keV")),
615  threshold_(iConfig.getParameter<double>("thresholdInMIPs")),
616  mip_(iConfig.getParameter<double>("mipValueInkeV")),
617  recHitEnergyMultiplier_(iConfig.getParameter<double>("recHitEnergyMultiplier")) {}
618 
619  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
621  iSetup.get<IdealGeometryRecord>().get(geometryInstance_, geoHandle);
622  ddd_ = &(geoHandle->topology().dddConstants());
623  }
624 
625  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
626  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
627  return false;
628  }
629  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override {
630  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
631  return false;
632  }
633 
634  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override {
635  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
636  return false;
637  }
638  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override {
639  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
640  return false;
641  }
642 
643  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override {
644  throw cms::Exception("WrongDetector") << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
645  return false;
646  }
647 
648  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override {
649  const double newE =
650  (recHitEnergy_keV_ ? 1.0e-6 * rh.energy() * recHitEnergyMultiplier_ : rh.energy() * recHitEnergyMultiplier_);
651  const int wafer = HGCalDetId(rh.detid()).wafer();
652  const float mult = (float)ddd_->waferTypeL(wafer); // 1 for 100um, 2 for 200um, 3 for 300um
653  hit.setEnergy(newE);
654  return pass(hit, mult);
655  }
656 
657 protected:
659  const bool recHitEnergy_keV_;
660  const double threshold_, mip_, recHitEnergyMultiplier_;
662 
663  bool pass(const reco::PFRecHit& hit, const float mult) {
664  const double hitValueInMIPs = 1e6 * hit.energy() / (mult * mip_);
665  return hitValueInMIPs > threshold_;
666  }
667 };
668 
670 public:
671  PFRecHitQTestHGCalThresholdSNR() : thresholdSNR_(0.) {}
672 
674  : PFRecHitQTestBase(iConfig), thresholdSNR_(iConfig.getParameter<double>("thresholdSNR")) {}
675 
676  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {}
677 
678  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
679  throw cms::Exception("WrongDetector") << "PFRecHitQTestHGCalThresholdSNR only works for HGCAL!";
680  return false;
681  }
682  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override {
683  throw cms::Exception("WrongDetector") << "PFRecHitQTestHGCalThresholdSNR only works for HGCAL!";
684  return false;
685  }
686 
687  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override {
688  throw cms::Exception("WrongDetector") << "PFRecHitQTestHGCalThresholdSNR only works for HGCAL!";
689  return false;
690  }
691  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override {
692  throw cms::Exception("WrongDetector") << "PFRecHitQTestHGCalThresholdSNR only works for HGCAL!";
693  return false;
694  }
695 
696  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override {
697  throw cms::Exception("WrongDetector") << "PFRecHitQTestHGCalThresholdSNR only works for HGCAL!";
698  return false;
699  }
700 
701  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override {
702  return rh.signalOverSigmaNoise() >= thresholdSNR_;
703  }
704 
705 protected:
706  const double thresholdSNR_;
707 };
708 
709 // M.G. Quality test that checks seeding threshold read from the DB
710 //
712 public:
714  : PFRecHitQTestBase(iConfig),
715  applySelectionsToAllCrystals_(iConfig.getParameter<bool>("applySelectionsToAllCrystals")) {}
716 
717  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
718  iSetup.get<EcalPFSeedingThresholdsRcd>().get(ths_);
719  }
720 
721  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
722  if (applySelectionsToAllCrystals_)
723  return pass(hit);
724  return fullReadOut or pass(hit);
725  }
726  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override { return pass(hit); }
727 
728  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override { return pass(hit); }
729  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override { return pass(hit); }
730 
731  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override { return pass(hit); }
732 
733  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override { return pass(hit); }
734 
735 protected:
738 
739  bool pass(const reco::PFRecHit& hit) {
740  float threshold = (*ths_)[hit.detId()];
741  return (hit.energy() > threshold);
742  }
743 };
744 
745 #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
constexpr float energy() const
Definition: CaloRecHit.h:31
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:49
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
const HcalChannelQuality * theHcalChStatus_
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HFRecHit &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
static void setCaloGeometry(const CaloGeometry *geometry)
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:146
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)
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
unsigned detId() const
rechit detId
Definition: PFRecHit.h:93
PFRecHitQTestThreshold(const edm::ParameterSet &iConfig)
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
constexpr const DetId & detid() const
Definition: CaloRecHit.h:35
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
std::vector< int > depths_
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 pass(const reco::PFRecHit &hit, const float mult)
const HcalSeverityLevelComputer * hcalSevLvlComputer_
#define nullptr
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
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
PFRecHitQTestECAL(const edm::ParameterSet &iConfig)
const Item * getValues(DetId fId, bool throwOnFail=true) const
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
PFRecHitQTestHCALChannel(const edm::ParameterSet &iConfig)
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
std::vector< double > cleanThresholds_
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
std::vector< double > thresholds_
bool getMergePositionFlag() const
Definition: HcalTopology.h:171
bool pass(const reco::PFRecHit &hit)
PFRecHitQTestHCALThresholdVsDepth(const edm::ParameterSet &iConfig)
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
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
float signalOverSigmaNoise() const
Definition: HGCRecHit.cc:69
std::vector< double > thresholds_
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
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
int depth() const
get the tower depth
Definition: HcalDetId.h:166
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
bool checkFlag(int flag) const
check if the flag is true
Definition: EcalRecHit.h:187
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
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
const HGCalTopology & topology() const
PFRecHitQTestHCALCalib29(const edm::ParameterSet &iConfig)
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
constexpr float time() const
Definition: CaloRecHit.h:33
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
float energy() const
Definition: EcalRecHit.h:68
void beginEvent(const edm::Event &event, const edm::EventSetup &iSetup) override
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override
PFRecHitQTestDBSeedingThreshold(const edm::ParameterSet &iConfig)
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
float energy() const
rechit energy
Definition: PFRecHit.h:99
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override
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_
bool test(reco::PFRecHit &hit, const HFRecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
PFRecHitQTestHCALTimeVsDepth(const edm::ParameterSet &iConfig)
std::vector< T * > clean
Definition: MVATrainer.cc:154
void beginEvent(const edm::Event &event, const edm::EventSetup &iSetup) override
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
Definition: DetId.h:18
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
PFRecHitQTestHOThreshold(const edm::ParameterSet &iConfig)
const HGCalDDDConstants & dddConstants() const
bool test(reco::PFRecHit &hit, const CaloTower &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
PFRecHitQTestThresholdInThicknessNormalizedMIPs(const edm::ParameterSet &iConfig)
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
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
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
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< int > thresholds_
void setEnergy(float energy)
Definition: PFRecHit.h:69
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
T get() const
Definition: EventSetup.h:71
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
bool pass(const reco::PFRecHit &hit)
const bool topologicalCleaning_
PFRecHitQTestThresholdInMIPs(const edm::ParameterSet &iConfig)
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
HcalDetId idFront(const HcalDetId &id) const
Definition: HcalTopology.h:177
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
bool test(unsigned aDETID, double energy, int flags, bool &clean)
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
const edm::EventSetup * eventSetup_
bool test(reco::PFRecHit &hit, const HBHERecHit &rh, bool &clean) override
uint32_t getValue() const
PFRecHitQTestECALMultiThreshold(const edm::ParameterSet &iConfig)
bool pass(const reco::PFRecHit &hit)
static constexpr short N_RING_TOTAL
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
T const * product() const
Definition: ESHandle.h:86
constexpr uint32_t flags() const
Definition: CaloRecHit.h:36
std::vector< int > flags_
bool test(reco::PFRecHit &hit, const EcalRecHit &rh, bool &clean, bool fullReadOut) override
PFRecHitQTestHGCalThresholdSNR(const edm::ParameterSet &iConfig)
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
Definition: event.py:1
PFRecHitQTestES(const edm::ParameterSet &iConfig)
PFRecHitQTestDBThreshold(const edm::ParameterSet &iConfig)
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