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