File indexing completed on 2024-09-07 04:37:36
0001 #include "RecoLocalCalo/HcalRecAlgos/interface/HcalHFStatusBitFromRecHits.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "Geometry/CaloTopology/interface/HcalTopology.h"
0004
0005 #include <algorithm> // for "max"
0006 #include <cmath>
0007 #include <iostream>
0008
0009 HcalHFStatusBitFromRecHits::HcalHFStatusBitFromRecHits() {
0010
0011 long_HFlongshortratio_ = 0.99;
0012 short_HFlongshortratio_ = 0.99;
0013 long_thresholdET_ = 0.5;
0014 short_thresholdET_ = 0.5;
0015 long_thresholdEnergy_ = 100;
0016 short_thresholdEnergy_ = 100;
0017 }
0018
0019 HcalHFStatusBitFromRecHits::HcalHFStatusBitFromRecHits(
0020 double shortR, double shortET, double shortE, double longR, double longET, double longE) {
0021 long_HFlongshortratio_ = longR;
0022 short_HFlongshortratio_ = shortR;
0023 long_thresholdET_ = longET;
0024 short_thresholdET_ = shortET;
0025 long_thresholdEnergy_ = longE;
0026 short_thresholdEnergy_ = shortE;
0027 }
0028
0029 HcalHFStatusBitFromRecHits::~HcalHFStatusBitFromRecHits() {}
0030
0031 void HcalHFStatusBitFromRecHits::hfSetFlagFromRecHits(HFRecHitCollection& rec,
0032 HcalChannelQuality* myqual,
0033 const HcalSeverityLevelComputer* mySeverity) {
0034
0035 int status;
0036 float en, en2;
0037 int ieta, iphi, depth;
0038 float ratio;
0039 double coshEta;
0040
0041
0042 for (HFRecHitCollection::iterator iHF = rec.begin(); iHF != rec.end(); ++iHF) {
0043
0044
0045
0046 ieta = iHF->id().ieta();
0047
0048 std::pair<double, double> etas = myqual->topo()->etaRange(HcalForward, abs(ieta));
0049 double eta1 = etas.first;
0050 double eta2 = etas.second;
0051 coshEta = fabs(cosh(0.5 * (eta1 + eta2)));
0052
0053 status = 0;
0054
0055 en2 = -999;
0056 depth = iHF->id().depth();
0057 en = iHF->energy();
0058
0059 if (depth == 1)
0060 {
0061 if (en < 1.2)
0062 continue;
0063 if (long_thresholdEnergy_ > 0. && en < long_thresholdEnergy_)
0064 continue;
0065 if (long_thresholdET_ > 0. && en < long_thresholdET_ * coshEta)
0066 continue;
0067 }
0068
0069 else if (depth == 2)
0070 {
0071 if (en < 1.8)
0072 continue;
0073 if (short_thresholdEnergy_ > 0. && en < short_thresholdEnergy_)
0074 continue;
0075 if (short_thresholdET_ > 0. && en < short_thresholdET_ * coshEta)
0076 continue;
0077 }
0078
0079 iphi = iHF->id().iphi();
0080
0081
0082
0083
0084 HcalDetId partner(HcalForward, ieta, iphi, 3 - depth);
0085 DetId detpartner = DetId(partner);
0086 const HcalChannelStatus* partnerstatus = myqual->getValues(detpartner.rawId());
0087 if (mySeverity->dropChannel(partnerstatus->getValue()))
0088 continue;
0089
0090
0091 for (HFRecHitCollection::iterator iHF2 = rec.begin(); iHF2 != rec.end(); ++iHF2) {
0092 if (iHF2->id().ieta() != ieta)
0093 continue;
0094 if (iHF2->id().iphi() != iphi)
0095 continue;
0096 if (iHF2->id().depth() == depth)
0097 continue;
0098
0099 en2 = iHF2->energy();
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111 ratio = (en - en2) / (en + en2);
0112
0113 if (depth == 1 && ratio > long_HFlongshortratio_)
0114 status = 1;
0115 else if (depth == 2 && ratio > short_HFlongshortratio_)
0116 status = 1;
0117 break;
0118 }
0119
0120
0121 if (en2 ==
0122 -999)
0123 status = 1;
0124
0125
0126 if (status == 1)
0127 iHF->setFlagField(status, HcalCaloFlagLabels::HFLongShort, 1);
0128 }
0129 return;
0130 }