CMS 3D CMS Logo

HcalHF_PETalgorithm.cc
Go to the documentation of this file.
8 
9 #include <algorithm> // for "max"
10 #include <cmath>
11 #include <iostream>
12 
14  // no params given; revert to old 'algo 1' fixed settings
15  short_R.clear();
16  short_R.push_back(0.995);
17  short_R_29.clear();
18  short_R_29.push_back(0.995);
19  short_Energy_Thresh.clear();
20  short_Energy_Thresh.push_back(50);
21  short_ET_Thresh.clear();
22  short_ET_Thresh.push_back(0);
23 
24  long_R.clear();
25  long_R.push_back(0.995);
26  long_R_29.clear();
27  long_R_29.push_back(0.995);
28  long_Energy_Thresh.clear();
29  long_Energy_Thresh.push_back(50);
30  long_ET_Thresh.clear();
31  long_ET_Thresh.push_back(0);
33 }
34 
35 HcalHF_PETalgorithm::HcalHF_PETalgorithm(const std::vector<double>& shortR,
36  const std::vector<double>& shortEnergyParams,
37  const std::vector<double>& shortETParams,
38  const std::vector<double>& longR,
39  const std::vector<double>& longEnergyParams,
40  const std::vector<double>& longETParams,
42  const std::vector<double>& shortR29,
43  const std::vector<double>& longR29) {
44  // R is parameterized depending on the energy of the cells, so just store the parameters here
45  short_R = shortR;
46  long_R = longR;
47  short_R_29 = shortR29;
48  long_R_29 = longR29;
49 
50  // Energy and ET cuts are ieta-dependent, and only need to be calculated once!
51  short_Energy_Thresh.clear();
52  short_ET_Thresh.clear();
53  long_Energy_Thresh.clear();
54  long_ET_Thresh.clear();
55 
56  //separate short, long cuts provided for each ieta
61 
63 }
64 
66 
68  HFRecHitCollection& rec,
69  const HcalChannelQuality* myqual,
70  const HcalSeverityLevelComputer* mySeverity) {
71  /* Set the HFLongShort flag by comparing the ratio |L-S|/|L+S|. Channels must first pass energy and ET cuts, and channels whose partners are known to be dead are skipped, since those channels can never satisfy the ratio cut. */
72 
73  int ieta = hf.id().ieta(); // get coordinates of rechit being checked
74  int depth = hf.id().depth();
75  int iphi = hf.id().iphi();
76  std::pair<double, double> etas = myqual->topo()->etaRange(HcalForward, abs(ieta));
77  double eta1 = etas.first;
78  double eta2 = etas.second;
79  double fEta = 0.5 * (eta1 + eta2); // calculate eta as average of eta values at ieta boundaries
80  double energy = hf.energy();
81  double ET = energy / fabs(cosh(fEta));
82 
83  // Step 1: Check energy and ET cuts
84  double ETthresh = 0, Energythresh = 0; // set ET, energy thresholds
85 
86  if (depth == 1) // set thresholds for long fibers
87  {
88  Energythresh = long_Energy_Thresh[abs(ieta) - 29];
89  ETthresh = long_ET_Thresh[abs(ieta) - 29];
90  } else if (depth == 2) // short fibers
91  {
92  Energythresh = short_Energy_Thresh[abs(ieta) - 29];
93  ETthresh = short_ET_Thresh[abs(ieta) - 29];
94  }
95 
96  if (energy < Energythresh || ET < ETthresh) {
97  hf.setFlagField(0, HcalCaloFlagLabels::HFLongShort); // shouldn't be necessary, but set bit to 0 just to be sure
98  hf.setFlagField(0, HcalCaloFlagLabels::HFPET);
99  return;
100  }
101 
102  // Step 2: Get partner info, check if partner is excluded from rechits already
103  HcalDetId partner(HcalForward, ieta, iphi, 3 - depth); // if depth=1, 3-depth=2, and vice versa
104  DetId detpartner = DetId(partner);
105  const HcalChannelStatus* partnerstatus = myqual->getValues(detpartner.rawId());
106 
107  // Don't set the bit if the partner has been dropped from the rechit collection ('dead' or 'off')
108  if (mySeverity->dropChannel(partnerstatus->getValue())) {
109  hf.setFlagField(0, HcalCaloFlagLabels::HFLongShort); // shouldn't be necessary, but set bit to 0 just to be sure
110  hf.setFlagField(0, HcalCaloFlagLabels::HFPET);
111  return;
112  }
113 
114  // Step 3: Compute ratio
115  double Ratio = 0;
117  if (part != rec.end()) {
118  HcalDetId neighbor(part->detid().rawId());
119  const uint32_t chanstat = myqual->getValues(neighbor)->getValue();
120  int SeverityLevel = mySeverity->getSeverityLevel(neighbor, part->flags(), chanstat);
121 
123  Ratio = (energy - part->energy()) / (energy + part->energy());
124  }
125 
126  double RatioThresh = 0;
127  // Allow for the ratio cut to be parameterized in terms of energy
128  if (abs(ieta) == 29) {
129  if (depth == 1)
130  RatioThresh = CalcThreshold(energy, long_R_29);
131  else if (depth == 2)
132  RatioThresh = CalcThreshold(energy, short_R_29);
133  } else {
134  if (depth == 1)
135  RatioThresh = CalcThreshold(energy, long_R);
136  else if (depth == 2)
137  RatioThresh = CalcThreshold(energy, short_R);
138  }
139  if (Ratio <= RatioThresh) {
140  hf.setFlagField(0, HcalCaloFlagLabels::HFLongShort); // shouldn't be necessary, but set bit to 0 just to be sure
141  hf.setFlagField(0, HcalCaloFlagLabels::HFPET);
142  return;
143  }
144  // Made it this far -- ratio is > threshold, and cell should be flagged!
145  // 'HFLongShort' is overall topological flag, and 'HFPET' is the flag for this
146  // specific test
147  hf.setFlagField(1, HcalCaloFlagLabels::HFLongShort);
148  hf.setFlagField(1, HcalCaloFlagLabels::HFPET);
149 } //void HcalHF_PETalgorithm::HFSetFlagFromPET
150 
151 double HcalHF_PETalgorithm::CalcThreshold(double abs_x, const std::vector<double>& params) {
152  /* CalcEnergyThreshold calculates the polynomial [0]+[1]*x + [2]*x^2 + ....,
153  where x is an integer provided by the first argument (int double abs_x),
154  and [0],[1],[2] is a vector of doubles provided by the second (std::vector<double> params).
155  The output of the polynomial calculation (threshold) is returned by the function.
156  */
157  double threshold = 0;
158  for (std::vector<double>::size_type i = 0; i < params.size(); ++i) {
159  threshold += params[i] * pow(abs_x, (int)i);
160  }
161  return threshold;
162 } //double HcalHF_PETalgorithm::CalcThreshold(double abs_x,std::vector<double> params)
HLT_2018_cff.HcalAcceptSeverityLevel
HcalAcceptSeverityLevel
Definition: HLT_2018_cff.py:7147
HcalHF_PETalgorithm::short_R
std::vector< double > short_R
Definition: HcalHF_PETalgorithm.h:63
mps_fire.i
i
Definition: mps_fire.py:355
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
MessageLogger.h
HcalHF_PETalgorithm::long_ET_Thresh
std::vector< double > long_ET_Thresh
Definition: HcalHF_PETalgorithm.h:68
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
HLT_2018_cff.longETParams
longETParams
Definition: HLT_2018_cff.py:7142
HLT_2018_cff.eta1
eta1
Definition: HLT_2018_cff.py:8220
HcalHF_PETalgorithm::long_R
std::vector< double > long_R
Definition: HcalHF_PETalgorithm.h:67
edm::SortedCollection
Definition: SortedCollection.h:49
HcalChannelQuality
Definition: HcalChannelQuality.h:17
HcalCondObjectContainer::getValues
const Item * getValues(DetId fId, bool throwOnFail=true) const
Definition: HcalCondObjectContainer.h:159
HcalHF_PETalgorithm::HFSetFlagFromPET
void HFSetFlagFromPET(HFRecHit &hf, HFRecHitCollection &rec, const HcalChannelQuality *myqual, const HcalSeverityLevelComputer *mySeverity)
Definition: HcalHF_PETalgorithm.cc:67
HcalHF_PETalgorithm::long_R_29
std::vector< double > long_R_29
Definition: HcalHF_PETalgorithm.h:72
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
DetId
Definition: DetId.h:17
part
part
Definition: HCALResponse.h:20
photonIsolationHIProducer_cfi.hf
hf
Definition: photonIsolationHIProducer_cfi.py:9
trigger::size_type
uint16_t size_type
Definition: TriggerTypeDefs.h:18
HFRecHit
Definition: HFRecHit.h:11
EnergyCorrector.etas
etas
Definition: EnergyCorrector.py:45
HcalChannelStatus
Definition: HcalChannelStatus.h:13
HcalSeverityLevelComputer
Definition: HcalSeverityLevelComputer.h:24
HLT_2018_cff.shortEnergyParams
shortEnergyParams
Definition: HLT_2018_cff.py:7139
HcalHF_PETalgorithm::short_R_29
std::vector< double > short_R_29
Definition: HcalHF_PETalgorithm.h:71
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
HLT_2018_cff.eta2
eta2
Definition: HLT_2018_cff.py:8221
HcalSeverityLevelComputer::dropChannel
bool dropChannel(const uint32_t &mystatus) const
Definition: HcalSeverityLevelComputer.cc:395
ET
#define ET
Definition: GenericBenchmark.cc:27
HcalSeverityLevelComputerRcd.h
HcalSeverityLevelComputer::getSeverityLevel
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
Definition: HcalSeverityLevelComputer.cc:304
HcalChannelStatus::getValue
uint32_t getValue() const
Definition: HcalChannelStatus.h:60
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
HcalHF_PETalgorithm::short_Energy_Thresh
std::vector< double > short_Energy_Thresh
Definition: HcalHF_PETalgorithm.h:65
HcalCaloFlagLabels.h
HcalHF_PETalgorithm::~HcalHF_PETalgorithm
~HcalHF_PETalgorithm()
Definition: HcalHF_PETalgorithm.cc:65
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
HcalCondObjectContainerBase::topo
const HcalTopology * topo() const
Definition: HcalCondObjectContainer.h:22
HcalDetId
Definition: HcalDetId.h:12
EcalSeverityLevel::SeverityLevel
SeverityLevel
Definition: EcalSeverityLevel.h:18
HcalHF_PETalgorithm::HcalAcceptSeverityLevel_
int HcalAcceptSeverityLevel_
Definition: HcalHF_PETalgorithm.h:70
HcalHF_PETalgorithm::long_Energy_Thresh
std::vector< double > long_Energy_Thresh
Definition: HcalHF_PETalgorithm.h:69
HcalHF_PETalgorithm.h
HcalChannelQuality.h
HcalForward
Definition: HcalAssistant.h:36
HLT_2018_cff.longEnergyParams
longEnergyParams
Definition: HLT_2018_cff.py:7143
edm::SortedCollection::find
iterator find(key_type k)
Definition: SortedCollection.h:240
HcalTopology.h
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
HcalHF_PETalgorithm::CalcThreshold
double CalcThreshold(double abs_energy, const std::vector< double > &params)
Definition: HcalHF_PETalgorithm.cc:151
HcalHF_PETalgorithm::HcalHF_PETalgorithm
HcalHF_PETalgorithm()
Definition: HcalHF_PETalgorithm.cc:13
HcalTopology::etaRange
std::pair< double, double > etaRange(HcalSubdetector subdet, int ieta) const
Definition: HcalTopology.cc:1124
HcalSeverityLevelComputer.h
HcalCaloFlagLabels::HFLongShort
Definition: HcalCaloFlagLabels.h:37
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
HcalHF_PETalgorithm::short_ET_Thresh
std::vector< double > short_ET_Thresh
Definition: HcalHF_PETalgorithm.h:64
remoteMonitoring_LED_IterMethod_cfg.threshold
threshold
Definition: remoteMonitoring_LED_IterMethod_cfg.py:426
HcalCaloFlagLabels::HFPET
Definition: HcalCaloFlagLabels.h:41
HLT_2018_cff.shortETParams
shortETParams
Definition: HLT_2018_cff.py:7140