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  }
20 
22  PFRecHitQTestBase(iConfig),
23  threshold_(iConfig.getParameter<double>("threshold"))
24  {
25  }
26 
27  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
28  }
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{
34  return pass(hit);
35  }
36 
37  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override{
38  return pass(hit);
39  }
40  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override{
41  return pass(hit);
42  }
43 
44  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override{
45  return pass(hit);
46  }
47 
48  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override{
49  return pass(hit);
50  }
51 
52 protected:
53  double threshold_;
54 
55  bool pass(const reco::PFRecHit& hit){
56  if (hit.energy()>threshold_) return true;
57 
58  return false;
59  }
60 };
61 
62 
63 
64 //
65 // Quality test that checks threshold read from the DB
66 //
68 public:
70  }
71 
73  PFRecHitQTestBase(iConfig),
74  applySelectionsToAllCrystals_(iConfig.getParameter<bool>("applySelectionsToAllCrystals")),
75  eventSetup_(nullptr){
76  }
77 
78  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
79  eventSetup_=&iSetup;
80  }
81 
82  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override{
83  if (applySelectionsToAllCrystals_) return pass(hit);
84  return fullReadOut or pass(hit);
85  }
86  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override{
87  return pass(hit);
88  }
89 
90  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override{
91  return pass(hit);
92  }
93  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override{
94  return pass(hit);
95  }
96 
97  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override{
98  return pass(hit);
99  }
100 
101  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override{
102  return pass(hit);
103  }
104 
105 protected:
106 
109 
110 
111  bool pass(const reco::PFRecHit& hit){
112 
114  (*eventSetup_).get<EcalPFRecHitThresholdsRcd>().get(ths);
115 
116  float threshold = (*ths)[hit.detId()];
117  if (hit.energy()>threshold) return true;
118 
119  return false;
120  }
121 };
122 
123 
124 
125 
126 //
127 // Quality test that checks kHCAL Severity
128 //
130 public:
132  }
133 
135  PFRecHitQTestBase(iConfig)
136  {
137  thresholds_ = iConfig.getParameter<std::vector<int> >("maxSeverities");
138  cleanThresholds_ = iConfig.getParameter<std::vector<double> >("cleaningThresholds");
139  std::vector<std::string> flags = iConfig.getParameter<std::vector<std::string> >("flags");
140  for (auto & flag : flags) {
141  if (flag =="Standard") {
142  flags_.push_back(-1);
143  depths_.push_back(-1);
144  }
145  else if (flag =="HFInTime") {
146  flags_.push_back(1<<HcalCaloFlagLabels::HFInTimeWindow);
147  depths_.push_back(-1);
148  }
149  else if (flag =="HFDigi") {
150  flags_.push_back(1<<HcalCaloFlagLabels::HFDigiTime);
151  depths_.push_back(-1);
152  }
153  else if (flag =="HFLong") {
154  flags_.push_back(1<<HcalCaloFlagLabels::HFLongShort);
155  depths_.push_back(1);
156  }
157  else if (flag =="HFShort") {
158  flags_.push_back(1<<HcalCaloFlagLabels::HFLongShort);
159  depths_.push_back(2);
160  }
161  else {
162  flags_.push_back(-1);
163  depths_.push_back(-1);
164  }
165  }
166  }
167 
168  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
170  iSetup.get<HcalRecNumberingRecord>().get(topo);
171  theHcalTopology_ = topo.product();
173  iSetup.get<HcalChannelQualityRcd>().get( "withTopo", hcalChStatus );
174  theHcalChStatus_ = hcalChStatus.product();
175  edm::ESHandle<HcalSeverityLevelComputer> hcalSevLvlComputerHndl;
176  iSetup.get<HcalSeverityLevelComputerRcd>().get(hcalSevLvlComputerHndl);
177  hcalSevLvlComputer_ = hcalSevLvlComputerHndl.product();
178  }
179 
180  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override{
181  return true;
182  }
183  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override{
184  return test(rh.detid(), rh.energy(), rh.flags(), clean);
185  }
186 
187  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override{
188  return test(rh.detid(), rh.energy(), rh.flags(), clean);
189  }
190  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override{
191  return test(rh.detid(), rh.energy(), rh.flags(), clean);
192  }
193 
194  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override{
195  return true;
196  }
197 
198  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override{
199  return true;
200  }
201 
202 protected:
203  std::vector<int> thresholds_;
204  std::vector<double> cleanThresholds_;
205  std::vector<int> flags_;
206  std::vector<int> depths_;
210 
211  bool test(unsigned aDETID, double energy, int flags, bool& clean){
212  HcalDetId detid = (HcalDetId)aDETID;
213  if (theHcalTopology_->getMergePositionFlag() and detid.subdet() == HcalEndcap){
214  detid = theHcalTopology_->idFront(detid);
215  }
216 
217  const HcalChannelStatus* theStatus = theHcalChStatus_->getValues(detid);
218  unsigned theStatusValue = theStatus->getValue();
219  // Now get severity of problems for the given detID, based on the rechit flag word and the channel quality status value
220  for (unsigned int i=0;i<thresholds_.size();++i) {
221  int hitSeverity =0;
222  if (energy < cleanThresholds_[i])
223  continue;
224 
225  if(flags_[i]<0) {
226  hitSeverity=hcalSevLvlComputer_->getSeverityLevel(detid, flags, theStatusValue);
227  }
228  else {
229  hitSeverity=hcalSevLvlComputer_->getSeverityLevel(detid, flags & flags_[i], theStatusValue);
230  }
231 
232  if (hitSeverity>thresholds_[i] and ((depths_[i]<0 or (depths_[i]==detid.depth())))) {
233  clean=true;
234  return false;
235  }
236  }
237  return true;
238  }
239 
240 };
241 
242 //
243 // Quality test that applies threshold and timing as a function of depth
244 //
246 public:
248  }
249 
251  PFRecHitQTestBase(iConfig)
252  {
253  std::vector<edm::ParameterSet> psets = iConfig.getParameter<std::vector<edm::ParameterSet> >("cuts");
254  for (auto & pset : psets) {
255  depths_.push_back(pset.getParameter<int>("depth"));
256  minTimes_.push_back(pset.getParameter<double>("minTime"));
257  maxTimes_.push_back(pset.getParameter<double>("maxTime"));
258  thresholds_.push_back(pset.getParameter<double>("threshold"));
259  }
260  }
261 
262  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
263  }
264 
265  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override{
266  return true;
267  }
268  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override{
269  return test(rh.detid(), rh.energy(), rh.time(), clean);
270  }
271 
272  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override{
273  return test(rh.detid(), rh.energy(), rh.time(), clean);
274  }
275  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override {
276  return test(rh.detid(), rh.energy(), rh.time(), clean);
277  }
278 
279  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override{
280  return true;
281  }
282 
283  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override{
284  return true;
285  }
286 
287 protected:
288  std::vector<int> depths_;
289  std::vector<double> minTimes_;
290  std::vector<double> maxTimes_;
291  std::vector<double> thresholds_;
292 
293  bool test(unsigned aDETID, double energy, double time, bool& clean){
294  HcalDetId detid(aDETID);
295  for (unsigned int i=0;i<depths_.size();++i) {
296  if (detid.depth() == depths_[i]) {
297  if ((time <minTimes_[i] or time >maxTimes_[i] ) and energy>thresholds_[i])
298  {
299  clean=true;
300  return false;
301  }
302  break;
303  }
304  }
305  return true;
306  }
307 };
308 
309 
310 
311 
312 //
313 // Quality test that applies threshold as a function of depth
314 //
316 public:
318  }
319 
321  PFRecHitQTestBase(iConfig)
322  {
323  std::vector<edm::ParameterSet> psets = iConfig.getParameter<std::vector<edm::ParameterSet> >("cuts");
324  for (auto & pset : psets) {
325  depths_=pset.getParameter<std::vector<int> >("depth");
326  thresholds_=pset.getParameter<std::vector<double> >("threshold");
327  detector_=pset.getParameter<int>("detectorEnum");
328  if(thresholds_.size()!=depths_.size()) {
329  throw cms::Exception("InvalidPFRecHitThreshold")
330  << "PFRecHitThreshold mismatch with the numbers of depths";
331  }
332  }
333  }
334 
335  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
336  }
337 
338  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override{
339  return true;
340  }
341  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override{
342  return test(rh.detid(), rh.energy(), rh.time(), clean);
343  }
344 
345  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override{
346  return test(rh.detid(), rh.energy(), rh.time(), clean);
347  }
348  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override{
349  return test(rh.detid(), rh.energy(), rh.time(), clean);
350  }
351 
352  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override{
353  return true;
354  }
355 
356  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override{
357  return true;
358  }
359 
360 protected:
361  std::vector<int> depths_;
362  std::vector<double> thresholds_;
364 
365  bool test(unsigned aDETID, double energy, double time, bool& clean){
366  HcalDetId detid(aDETID);
367 
368  for (unsigned int i=0;i<thresholds_.size();++i) {
369  if (detid.depth() == depths_[i] && detid.subdet() == detector_ ) {
370  if ( energy<thresholds_[i])
371  {
372  clean=false;
373  return false;
374  }
375  break;
376  }
377  }
378  return true;
379  }
380 };
381 
382 
383 
384 
385 
386 //
387 // Quality test that checks HO threshold applying different threshold in rings
388 //
390 public:
392  threshold0_(0.),
393  threshold12_(0.)
394  {
395  }
396 
398  PFRecHitQTestBase(iConfig),
399  threshold0_(iConfig.getParameter<double>("threshold_ring0")),
400  threshold12_(iConfig.getParameter<double>("threshold_ring12"))
401  {
402  }
403 
404  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
405  }
406 
407  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override{
408  return true;
409  }
410 
411  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override{
412  return true;
413  }
414 
415  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override{
416  return true;
417  }
418 
419  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override{
420  HcalDetId detid(rh.detid());
421  if (abs(detid.ieta())<=4 and hit.energy()>threshold0_)
422  return true;
423  if (abs(detid.ieta())>4 and hit.energy()>threshold12_)
424  return true;
425 
426  return false;
427  }
428 
429  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override{
430  return true;
431  }
432 
433  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override{
434  return true;
435  }
436 
437 protected:
438  const double threshold0_;
439  const double threshold12_;
440 
441 };
442 
443 //
444 // Quality test that checks threshold as a function of ECAL eta-ring
445 //
451 public:
453  }
454 
456  PFRecHitQTestBase(iConfig),
457  thresholds_(iConfig.getParameter<std::vector<double> >("thresholds")),
458  applySelectionsToAllCrystals_(iConfig.getParameter<bool>("applySelectionsToAllCrystals"))
459  {
460  if (thresholds_.size() != EcalRingCalibrationTools::N_RING_TOTAL)
461  throw edm::Exception(edm::errors::Configuration, "ValueError")
462  << "thresholds is expected to have " << EcalRingCalibrationTools::N_RING_TOTAL << " elements but has " << thresholds_.size();
463  }
464 
465  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
467  iSetup.get<CaloGeometryRecord>().get(pG);
469  endcapGeometrySet_=false;
470  if (endcapGeometry) {
472  endcapGeometrySet_=true;
473  }
474  }
475 
476  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override{
477  if (applySelectionsToAllCrystals_) return pass(hit);
478  else return fullReadOut or pass(hit);
479  }
480  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override{
481  return true;
482  }
483 
484  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override{
485  return true;
486  }
487  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override{
488  return true;
489  }
490 
491  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override{
492  return true;
493  }
494 
495  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override{
496  return true;
497  }
498 
499 protected:
500  const std::vector<double> thresholds_;
502 
503  // apply selections to all crystals
505 
506 
507  bool pass(const reco::PFRecHit& hit){
508 
509  DetId detId(hit.detId());
510 
511  // this is to skip endcap ZS for Phase2 until there is a defined geometry
512  // apply the loosest ZS threshold, for the first eta-ring in EB
513  if (not endcapGeometrySet_) {
514 
515  // there is only ECAL EB in Phase 2
516  if(detId.subdetId() != EcalBarrel) return true;
517 
518  // 0-169: EB eta-rings
519  // 170-208: EE- eta rings
520  // 209-247: EE+ eta rings
521  int firstEBRing = 0;
522  return (hit.energy() > thresholds_[firstEBRing]);
523  }
524 
525  int iring = EcalRingCalibrationTools::getRingIndex(detId);
526  if (hit.energy() > thresholds_[iring]) return true;
527 
528  return false;
529  }
530 };
531 
532 
533 //
534 // Quality test that checks ecal quality cuts
535 //
537  public:
539  }
540 
542  PFRecHitQTestBase(iConfig),
543  thresholdCleaning_(iConfig.getParameter<double>("cleaningThreshold")),
544  timingCleaning_(iConfig.getParameter<bool>("timingCleaning")),
545  topologicalCleaning_(iConfig.getParameter<bool>("topologicalCleaning")),
546  skipTTRecoveredHits_(iConfig.getParameter<bool>("skipTTRecoveredHits"))
547  {
548  }
549 
550  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
551  }
552 
553  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override{
554  if (skipTTRecoveredHits_ and rh.checkFlag(EcalRecHit::kTowerRecovered))
555  {
556  clean=true;
557  return false;
558  }
559  if (timingCleaning_ and rh.energy() > thresholdCleaning_ and
561  {
562  clean=true;
563  return false;
564  }
565 
566  if (topologicalCleaning_ and (
569  {
570  clean=true;
571  return false;
572  }
573 
574  return true;
575  }
576 
577  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override{
578  return true;
579  }
580 
581  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override{
582  return true;
583  }
584 
585  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override{
586  return true;
587  }
588 
589  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override{
590  return true;
591  }
592 
593  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override{
594  return true;
595  }
596 
597 protected:
602 
603 };
604 
605 //
606 // Quality test that checks ES quality cuts
607 //
609 public:
611  thresholdCleaning_(0.),
612  topologicalCleaning_(false)
613  {
614  }
615 
617  PFRecHitQTestBase(iConfig),
618  thresholdCleaning_(iConfig.getParameter<double>("cleaningThreshold")),
619  topologicalCleaning_(iConfig.getParameter<bool>("topologicalCleaning"))
620  {
621  }
622 
623  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
624  }
625 
626  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
627 
628  if ( rh.energy() < thresholdCleaning_ ) {
629  clean=false;
630  return false;
631  }
632 
633  if ( topologicalCleaning_ and
642  )) {
643  clean=false;
644  return false;
645  }
646 
647  return true;
648  }
649 
650  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override{
651  return true;
652  }
653 
654  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override{
655  return true;
656  }
657 
658  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override{
659  return true;
660  }
661 
662  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override{
663  return true;
664  }
665 
666  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override{
667  return true;
668  }
669 
670 protected:
671  const double thresholdCleaning_;
673 
674 };
675 
676 //
677 // Quality test that calibrates tower 29 of HCAL
678 //
680 public:
682  calibFactor_(0.)
683  {
684  }
685 
687  PFRecHitQTestBase(iConfig),
688  calibFactor_(iConfig.getParameter<double>("calibFactor"))
689  {
690  }
691 
692  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
693  }
694 
695  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override{
696  return true;
697  }
698  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override{
699  HcalDetId detId(hit.detId());
700  if (abs(detId.ieta())==29)
701  hit.setEnergy(hit.energy()*calibFactor_);
702  return true;
703  }
704 
705  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override{
706  return true;
707  }
708  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override{
709  return true;
710  }
711 
712  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override{
713  CaloTowerDetId detId(hit.detId());
714  if (detId.ietaAbs()==29)
715  hit.setEnergy(hit.energy()*calibFactor_);
716  return true;
717  }
718 
719  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override{
720  return true;
721  }
722 
723 protected:
724  const float calibFactor_;
725 };
726 
728 public:
730  recHitEnergy_keV_(false),
731  threshold_(0.),
732  mip_(0.),
733  recHitEnergyMultiplier_(0.)
734  {
735  }
736 
738  PFRecHitQTestBase(iConfig),
739  recHitEnergy_keV_(iConfig.getParameter<bool>("recHitEnergyIs_keV")),
740  threshold_(iConfig.getParameter<double>("thresholdInMIPs")),
741  mip_(iConfig.getParameter<double>("mipValueInkeV")),
742  recHitEnergyMultiplier_(iConfig.getParameter<double>("recHitEnergyMultiplier"))
743  {
744  }
745 
746  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
747  }
748 
749  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
750  throw cms::Exception("WrongDetector")
751  << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
752  return false;
753  }
754  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override {
755  throw cms::Exception("WrongDetector")
756  << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
757  return false;
758  }
759 
760  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override {
761  throw cms::Exception("WrongDetector")
762  << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
763  return false;
764  }
765  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override {
766  throw cms::Exception("WrongDetector")
767  << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
768  return false;
769  }
770 
771  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override {
772  throw cms::Exception("WrongDetector")
773  << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
774  return false;
775  }
776 
777  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override {
778  const double newE = ( recHitEnergy_keV_ ?
779  1.0e-6*rh.energy()*recHitEnergyMultiplier_ :
780  rh.energy()*recHitEnergyMultiplier_ );
781  hit.setEnergy(newE);
782  return pass(hit);
783  }
784 
785 protected:
786  const bool recHitEnergy_keV_;
787  const double threshold_, mip_, recHitEnergyMultiplier_;
788 
789  bool pass(const reco::PFRecHit& hit) {
790  const double hitValueInMIPs = 1e6*hit.energy()/mip_;
791  return hitValueInMIPs > threshold_;
792  }
793 };
794 
797  public:
799  geometryInstance_(""),
800  recHitEnergy_keV_(0.),
801  threshold_(0.),
802  mip_(0.),
803  recHitEnergyMultiplier_(0.) {
804  }
805 
807  PFRecHitQTestBase(iConfig),
808  geometryInstance_(iConfig.getParameter<std::string>("geometryInstance")),
809  recHitEnergy_keV_(iConfig.getParameter<bool>("recHitEnergyIs_keV")),
810  threshold_(iConfig.getParameter<double>("thresholdInMIPs")),
811  mip_(iConfig.getParameter<double>("mipValueInkeV")),
812  recHitEnergyMultiplier_(iConfig.getParameter<double>("recHitEnergyMultiplier")) {
813  }
814 
815  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override {
817  iSetup.get<IdealGeometryRecord>().get(geometryInstance_, geoHandle);
818  ddd_ = &(geoHandle->topology().dddConstants());
819  }
820 
821  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override {
822  throw cms::Exception("WrongDetector")
823  << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
824  return false;
825  }
826  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override {
827  throw cms::Exception("WrongDetector")
828  << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
829  return false;
830  }
831 
832  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override {
833  throw cms::Exception("WrongDetector")
834  << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
835  return false;
836  }
837  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override {
838  throw cms::Exception("WrongDetector")
839  << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
840  return false;
841  }
842 
843  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override {
844  throw cms::Exception("WrongDetector")
845  << "PFRecHitQTestThresholdInMIPs only works for HGCAL!";
846  return false;
847  }
848 
849  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override {
850  const double newE = ( recHitEnergy_keV_ ?
851  1.0e-6*rh.energy()*recHitEnergyMultiplier_ :
852  rh.energy()*recHitEnergyMultiplier_ );
853  const int wafer = HGCalDetId(rh.detid()).wafer();
854  const float mult = (float) ddd_->waferTypeL(wafer); // 1 for 100um, 2 for 200um, 3 for 300um
855  hit.setEnergy(newE);
856  return pass(hit, mult);
857  }
858 
859  protected:
861  const bool recHitEnergy_keV_;
862  const double threshold_, mip_, recHitEnergyMultiplier_;
864 
865  bool pass(const reco::PFRecHit& hit, const float mult) {
866  const double hitValueInMIPs = 1e6*hit.energy()/(mult*mip_);
867  return hitValueInMIPs > threshold_;
868  }
869 };
870 
871 
873 {
874  public:
876  thresholdSNR_(0.)
877  {
878  }
879 
881  PFRecHitQTestBase(iConfig), thresholdSNR_(iConfig.getParameter<double>("thresholdSNR"))
882  {
883  }
884 
885  void beginEvent(const edm::Event& event, const edm::EventSetup& iSetup) override
886  {
887  }
888 
889  bool test(reco::PFRecHit& hit, const EcalRecHit& rh, bool& clean, bool fullReadOut) override
890  {
891  throw cms::Exception("WrongDetector")
892  << "PFRecHitQTestHGCalThresholdSNR only works for HGCAL!";
893  return false;
894  }
895  bool test(reco::PFRecHit& hit, const HBHERecHit& rh, bool& clean) override
896  {
897  throw cms::Exception("WrongDetector")
898  << "PFRecHitQTestHGCalThresholdSNR only works for HGCAL!";
899  return false;
900  }
901 
902  bool test(reco::PFRecHit& hit, const HFRecHit& rh, bool& clean) override
903  {
904  throw cms::Exception("WrongDetector")
905  << "PFRecHitQTestHGCalThresholdSNR only works for HGCAL!";
906  return false;
907  }
908  bool test(reco::PFRecHit& hit, const HORecHit& rh, bool& clean) override
909  {
910  throw cms::Exception("WrongDetector")
911  << "PFRecHitQTestHGCalThresholdSNR only works for HGCAL!";
912  return false;
913  }
914 
915  bool test(reco::PFRecHit& hit, const CaloTower& rh, bool& clean) override
916  {
917  throw cms::Exception("WrongDetector")
918  << "PFRecHitQTestHGCalThresholdSNR only works for HGCAL!";
919  return false;
920  }
921 
922  bool test(reco::PFRecHit& hit, const HGCRecHit& rh, bool& clean) override
923  {
924  return rh.signalOverSigmaNoise() >= thresholdSNR_;
925  }
926 
927  protected:
928  const double thresholdSNR_;
929 };
930 
931 #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 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:142
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:108
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_
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
#define nullptr
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:170
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: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:162
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:32
bool checkFlag(int flag) const
check if the flag is true
Definition: EcalRecHit.h:189
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
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:114
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:156
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 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:74
bool test(reco::PFRecHit &hit, const HORecHit &rh, bool &clean) override
T get() const
Definition: EventSetup.h:63
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:176
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 HORecHit &rh, bool &clean) override
bool test(reco::PFRecHit &hit, const HGCRecHit &rh, bool &clean) override