CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
HcalHF_S9S1algorithm Class Reference

#include <HcalHF_S9S1algorithm.h>

Public Member Functions

double bit ()
 
double CalcEnergyThreshold (double abs_energy, const std::vector< double > &params)
 
double CalcSlope (int abs_ieta, const std::vector< double > &params)
 
 HcalHF_S9S1algorithm ()
 
 HcalHF_S9S1algorithm (const std::vector< double > &short_optimumSlope, const std::vector< double > &short_Energy, const std::vector< double > &short_ET, const std::vector< double > &long_optimumSlope, const std::vector< double > &long_Energy, const std::vector< double > &long_ET, int HcalAcceptSeverityLevel, bool isS8S1)
 
void HFSetFlagFromS9S1 (HFRecHit &hf, HFRecHitCollection &rec, const HcalChannelQuality *myqual, const HcalSeverityLevelComputer *mySeverity)
 
 ~HcalHF_S9S1algorithm ()
 

Private Attributes

int HcalAcceptSeverityLevel_
 
bool isS8S1_
 
std::vector< double > long_Energy_
 
std::vector< double > long_ET_
 
std::vector< double > LongEnergyThreshold
 
std::vector< double > LongETThreshold
 
std::vector< double > LongSlopes
 
std::vector< double > short_Energy_
 
std::vector< double > short_ET_
 
std::vector< double > ShortEnergyThreshold
 
std::vector< double > ShortETThreshold
 
std::vector< double > ShortSlopes
 

Detailed Description

Class evaluates the ratio |(L-S)/(L+S)| for a given cell, and flags the cell if the threshold exceeds a given maximum value R(Energy). Each cell must also pass ieta-dependent energy and ET cuts to be considered for flagging.

Author
J. Temple and D. Ferencek

Definition at line 21 of file HcalHF_S9S1algorithm.h.

Constructor & Destructor Documentation

◆ HcalHF_S9S1algorithm() [1/2]

HcalHF_S9S1algorithm::HcalHF_S9S1algorithm ( )

Constructors

Definition at line 13 of file HcalHF_S9S1algorithm.cc.

References HcalAcceptSeverityLevel_, mps_fire::i, isS8S1_, LongEnergyThreshold, LongETThreshold, LongSlopes, ShortEnergyThreshold, ShortETThreshold, and ShortSlopes.

13  {
14  // Default settings: Energy > 50 GeV, slope = 0, ET = 0
15  std::vector<double> blank;
16  blank.clear();
17  blank.push_back(0);
18  std::vector<double> EnergyDefault;
19  EnergyDefault.clear();
20  EnergyDefault.push_back(50);
21 
22  // Thresholds only need to be computed once, not every event!
23  LongSlopes.clear();
24  ShortSlopes.clear();
25  for (int i = 29; i <= 41; ++i) {
26  LongSlopes.push_back(0);
27  ShortSlopes.push_back(0);
28  }
29  LongEnergyThreshold.clear();
30  LongETThreshold.clear();
31  ShortEnergyThreshold.clear();
32  ShortETThreshold.clear();
33  for (int i = 29; i <= 41; ++i) {
34  LongEnergyThreshold.push_back(EnergyDefault[0]);
35  LongETThreshold.push_back(blank[0]);
36  ShortEnergyThreshold.push_back(EnergyDefault[0]);
37  ShortETThreshold.push_back(blank[0]);
38  }
40  isS8S1_ = false; // S8S1 is almost the same as S9S1
41 }
std::vector< double > LongSlopes
std::vector< double > LongEnergyThreshold
std::vector< double > LongETThreshold
std::vector< double > ShortSlopes
std::vector< double > ShortETThreshold
std::vector< double > ShortEnergyThreshold

◆ HcalHF_S9S1algorithm() [2/2]

HcalHF_S9S1algorithm::HcalHF_S9S1algorithm ( const std::vector< double > &  short_optimumSlope,
const std::vector< double > &  short_Energy,
const std::vector< double > &  short_ET,
const std::vector< double > &  long_optimumSlope,
const std::vector< double > &  long_Energy,
const std::vector< double > &  long_ET,
int  HcalAcceptSeverityLevel,
bool  isS8S1 
)

Definition at line 43 of file HcalHF_S9S1algorithm.cc.

References HLT_2022v12_cff::HcalAcceptSeverityLevel, HcalAcceptSeverityLevel_, HLT_2022v12_cff::isS8S1, isS8S1_, HLT_2022v12_cff::long_optimumSlope, LongEnergyThreshold, LongETThreshold, LongSlopes, HLT_2022v12_cff::short_optimumSlope, ShortEnergyThreshold, ShortETThreshold, and ShortSlopes.

52 {
53  // Constructor in the case where all parameters are provided by the user
54 
55  // Thresholds only need to be computed once, not every event!
56 
59 
60  while (LongSlopes.size() < 13)
61  LongSlopes.push_back(0); // should be unnecessary, but include this protection to avoid crashes
62  while (ShortSlopes.size() < 13)
63  ShortSlopes.push_back(0);
64 
65  // Get long, short energy thresholds (different threshold for each |ieta|)
66  LongEnergyThreshold.clear();
67  LongETThreshold.clear();
68  ShortEnergyThreshold.clear();
69  ShortETThreshold.clear();
70  LongEnergyThreshold = long_Energy;
71  LongETThreshold = long_ET;
72  ShortEnergyThreshold = short_Energy;
73  ShortETThreshold = short_ET;
74 
76  isS8S1_ = isS8S1;
77 } // HcalHF_S9S1algorithm constructor with parameters
std::vector< double > LongSlopes
std::vector< double > LongEnergyThreshold
std::vector< double > LongETThreshold
std::vector< double > ShortSlopes
std::vector< double > ShortETThreshold
std::vector< double > ShortEnergyThreshold

◆ ~HcalHF_S9S1algorithm()

HcalHF_S9S1algorithm::~HcalHF_S9S1algorithm ( )

Definition at line 79 of file HcalHF_S9S1algorithm.cc.

79 {}

Member Function Documentation

◆ bit()

double HcalHF_S9S1algorithm::bit ( )
inline

◆ CalcEnergyThreshold()

double HcalHF_S9S1algorithm::CalcEnergyThreshold ( double  abs_energy,
const std::vector< double > &  params 
)

Definition at line 244 of file HcalHF_S9S1algorithm.cc.

References mps_fire::i, submitPVValidationJobs::params, funct::pow(), and remoteMonitoring_LASER_era2018_cfg::threshold.

244  {
245  /* CalcEnergyThreshold calculates the polynomial [0]+[1]*x + [2]*x^2 + ....,
246  where x is an integer provided by the first argument (int abs_ieta),
247  and [0],[1],[2] is a vector of doubles provided by the second (std::vector<double> params).
248  The output of the polynomial calculation (threshold) is returned by the function.
249  */
250  double threshold = 0;
251  for (std::vector<double>::size_type i = 0; i < params.size(); ++i) {
252  threshold += params[i] * pow(abs_energy, (int)i);
253  }
254  return threshold;
255 } //double HcalHF_S9S1algorithm::CalcEnergyThreshold(double abs_energy,std::vector<double> params)
uint16_t size_type
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ CalcSlope()

double HcalHF_S9S1algorithm::CalcSlope ( int  abs_ieta,
const std::vector< double > &  params 
)

Definition at line 230 of file HcalHF_S9S1algorithm.cc.

References mps_fire::i, submitPVValidationJobs::params, funct::pow(), and remoteMonitoring_LASER_era2018_cfg::threshold.

230  {
231  /* CalcSlope calculates the polynomial [0]+[1]*x + [2]*x^2 + ....,
232  where x is an integer provided by the first argument (int abs_ieta),
233  and [0],[1],[2] is a vector of doubles provided by the second (std::vector<double> params).
234  The output of the polynomial calculation (threshold) is returned by the function.
235  This function should no longer be needed, since we pass slopes for all ietas into the function via the parameter set.
236  */
237  double threshold = 0;
238  for (std::vector<double>::size_type i = 0; i < params.size(); ++i) {
239  threshold += params[i] * pow(static_cast<double>(abs_ieta), (int)i);
240  }
241  return threshold;
242 } // HcalHF_S9S1algorithm::CalcRThreshold(int abs_ieta, std::vector<double> params)
uint16_t size_type
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ HFSetFlagFromS9S1()

void HcalHF_S9S1algorithm::HFSetFlagFromS9S1 ( HFRecHit hf,
HFRecHitCollection rec,
const HcalChannelQuality myqual,
const HcalSeverityLevelComputer mySeverity 
)

Definition at line 81 of file HcalHF_S9S1algorithm.cc.

References funct::abs(), ztail::d, LEDCalibrationChannels::depth, edm::SortedCollection< T, SORT >::end(), HCALHighEnergyHPDFilter_cfi::energy, ET, HLT_2022v12_cff::eta1, HLT_2022v12_cff::eta2, HcalTopology::etaRange(), EnergyCorrector::etas, edm::SortedCollection< T, SORT >::find(), HcalSeverityLevelComputer::getSeverityLevel(), HcalChannelStatus::getValue(), HcalCondObjectContainer< Item >::getValues(), HcalAcceptSeverityLevel_, HcalForward, photonIsolationHIProducer_cfi::hf, HcalCaloFlagLabels::HFLongShort, HcalCaloFlagLabels::HFS8S1Ratio, mps_fire::i, LEDCalibrationChannels::ieta, LEDCalibrationChannels::iphi, isS8S1_, dqm-mbProfile::log, LongEnergyThreshold, LongETThreshold, LongSlopes, ShortEnergyThreshold, ShortETThreshold, ShortSlopes, slope, and HcalCondObjectContainerBase::topo().

Referenced by HcalHitReconstructor::produce().

86 {
87  int ieta = hf.id().ieta(); // get coordinates of rechit being checked
88  int depth = hf.id().depth();
89  int iphi = hf.id().iphi();
90  std::pair<double, double> etas = myqual->topo()->etaRange(HcalForward, abs(ieta));
91  double eta1 = etas.first;
92  double eta2 = etas.second;
93  double fEta = 0.5 * (eta1 + eta2); // calculate eta as average of eta values at ieta boundaries
94  double energy = hf.energy();
95  double ET = energy / fabs(cosh(fEta));
96 
97  // Step 1: Check eta-dependent energy and ET thresholds -- same as PET algorithm
98  double ETthresh = 0, Energythresh = 0; // set ET, energy thresholds
99  if (depth == 1) // set thresholds for long fibers
100  {
101  Energythresh = LongEnergyThreshold[abs(ieta) - 29];
102  ETthresh = LongETThreshold[abs(ieta) - 29];
103  } else if (depth == 2) // short fibers
104  {
105  Energythresh = ShortEnergyThreshold[abs(ieta) - 29];
106  ETthresh = ShortETThreshold[abs(ieta) - 29];
107  }
108  if (energy < Energythresh || ET < ETthresh)
109  return;
110 
111  // Step 1A:
112  // Check that EL<ES when evaluating short fibers (S8S1 check only)
113  if (depth == 2 && abs(ieta) > 29 && isS8S1_) {
114  double EL = 0;
115  // look for long partner
116  HcalDetId neighbor(HcalForward, ieta, iphi, 1);
117  HFRecHitCollection::const_iterator neigh = rec.find(neighbor);
118  if (neigh != rec.end())
119  EL = neigh->energy();
120 
121  if (EL >= energy)
122  return;
123  }
124 
125  // Step 2: Find all neighbors, and calculate S9/S1
126  double S9S1 = 0;
127  int testphi = -99;
128 
129  // Part A: Check fixed iphi, and vary ieta
130  for (int d = 1; d <= 2; ++d) // depth loop
131  {
132  for (int i = ieta - 1; i <= ieta + 1; ++i) // ieta loop
133  {
134  testphi = iphi;
135  // Special case when ieta=39, since ieta=40 only has phi values at 3,7,11,...
136  // phi=3 covers 3,4,5,6
137  if (abs(ieta) == 39 && abs(i) > 39 && testphi % 4 == 1)
138  testphi -= 2;
139  while (testphi < 0)
140  testphi += 72;
141  if (i == ieta)
142  if (d == depth || isS8S1_ == true)
143  continue; // don't add the cell itself; don't count neighbor in same ieta-phi if S8S1 test enabled
144 
145  // Look to see if neighbor is in rechit collection
146  HcalDetId neighbor(HcalForward, i, testphi, d);
147  HFRecHitCollection::const_iterator neigh = rec.find(neighbor);
148  // require that neighbor exists, and that it doesn't have a prior flag already set
149  if (neigh != rec.end()) {
150  const uint32_t chanstat = myqual->getValues(neighbor)->getValue();
151  int SeverityLevel = mySeverity->getSeverityLevel(neighbor, neigh->flags(), chanstat);
153  S9S1 += neigh->energy();
154  }
155  }
156  }
157 
158  // Part B: Fix ieta, and loop over iphi. A bit more tricky, because of iphi wraparound and different segmentation at 40, 41
159 
160  int phiseg = 2; // 10 degree segmentation for most of HF (1 iphi unit = 5 degrees)
161  if (abs(ieta) > 39)
162  phiseg = 4; // 20 degree segmentation for |ieta|>39
163  for (int d = 1; d <= 2; ++d) {
164  for (int i = iphi - phiseg; i <= iphi + phiseg; i += phiseg) {
165  if (i == iphi)
166  continue; // don't add the cell itself, or its depthwise partner (which is already counted above)
167  testphi = i;
168  // Our own modular function, since default produces results -1%72 = -1
169  while (testphi < 0)
170  testphi += 72;
171  while (testphi > 72)
172  testphi -= 72;
173  // Look to see if neighbor is in rechit collection
174  HcalDetId neighbor(HcalForward, ieta, testphi, d);
175  HFRecHitCollection::const_iterator neigh = rec.find(neighbor);
176  if (neigh != rec.end()) {
177  const uint32_t chanstat = myqual->getValues(neighbor)->getValue();
178  int SeverityLevel = mySeverity->getSeverityLevel(neighbor, neigh->flags(), chanstat);
180  S9S1 += neigh->energy();
181  }
182  }
183  }
184 
185  if (abs(ieta) == 40) // add extra cells for 39/40 boundary due to increased phi size at ieta=40.
186  {
187  for (int d = 1; d <= 2; ++d) // add cells from both depths!
188  {
189  HcalDetId neighbor(HcalForward, 39 * abs(ieta) / ieta, (iphi + 2) % 72, d);
190  HFRecHitCollection::const_iterator neigh = rec.find(neighbor);
191  if (neigh != rec.end()) {
192  const uint32_t chanstat = myqual->getValues(neighbor)->getValue();
193  int SeverityLevel = mySeverity->getSeverityLevel(neighbor, neigh->flags(), chanstat);
195  S9S1 += neigh->energy();
196  }
197  }
198  }
199 
200  // So far, S9S1 is the sum of the neighbors; divide to form ratio
201  S9S1 /= energy;
202 
203  // Now compare to threshold
204  double slope = 0;
205  if (depth == 1)
206  slope = LongSlopes[abs(ieta) - 29];
207  else if (depth == 2)
208  slope = ShortSlopes[abs(ieta) - 29];
209  double intercept = 0;
210  if (depth == 1)
211  intercept = LongEnergyThreshold[abs(ieta) - 29];
212  else if (depth == 2)
213  intercept = ShortEnergyThreshold[abs(ieta) - 29];
214 
215  // S9S1 cut has the form [0] + [1]*log[E]; S9S1 value should be above this line
216  double S9S1cut = 0;
217  // Protection in case intercept or energy are ever less than 0. Do we have some other default value of S9S1cut we'd like touse in this case?
218  if (intercept > 0 && energy > 0)
219  S9S1cut = -1. * slope * log(intercept) + slope * log(energy);
220  if (S9S1 < S9S1cut) {
221  // Only set HFS8S1Ratio if S8/S1 ratio test fails
222  if (isS8S1_ == true)
223  hf.setFlagField(1, HcalCaloFlagLabels::HFS8S1Ratio);
224  // *Always* set the HFLongShort bit if either S8S1 or S9S1 fail
225  hf.setFlagField(1, HcalCaloFlagLabels::HFLongShort);
226  }
227  return;
228 } // void HcalHF_S9S1algorithm::HFSetFlagFromS9S1
std::vector< double > LongSlopes
static const double slope[3]
std::vector< T >::const_iterator const_iterator
std::vector< double > LongEnergyThreshold
std::vector< double > LongETThreshold
const Item * getValues(DetId fId, bool throwOnFail=true) const
const HcalTopology * topo() const
std::vector< double > ShortSlopes
std::pair< double, double > etaRange(HcalSubdetector subdet, int ieta) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
d
Definition: ztail.py:151
uint32_t getValue() const
const_iterator end() const
iterator find(key_type k)
std::vector< double > ShortETThreshold
int getSeverityLevel(const DetId &myid, const uint32_t &myflag, const uint32_t &mystatus) const
#define ET
std::vector< double > ShortEnergyThreshold

Member Data Documentation

◆ HcalAcceptSeverityLevel_

int HcalHF_S9S1algorithm::HcalAcceptSeverityLevel_
private

Definition at line 59 of file HcalHF_S9S1algorithm.h.

Referenced by HcalHF_S9S1algorithm(), and HFSetFlagFromS9S1().

◆ isS8S1_

bool HcalHF_S9S1algorithm::isS8S1_
private

Definition at line 60 of file HcalHF_S9S1algorithm.h.

Referenced by HcalHF_S9S1algorithm(), and HFSetFlagFromS9S1().

◆ long_Energy_

std::vector<double> HcalHF_S9S1algorithm::long_Energy_
private

Definition at line 51 of file HcalHF_S9S1algorithm.h.

◆ long_ET_

std::vector<double> HcalHF_S9S1algorithm::long_ET_
private

Definition at line 50 of file HcalHF_S9S1algorithm.h.

◆ LongEnergyThreshold

std::vector<double> HcalHF_S9S1algorithm::LongEnergyThreshold
private

Definition at line 55 of file HcalHF_S9S1algorithm.h.

Referenced by HcalHF_S9S1algorithm(), and HFSetFlagFromS9S1().

◆ LongETThreshold

std::vector<double> HcalHF_S9S1algorithm::LongETThreshold
private

Definition at line 57 of file HcalHF_S9S1algorithm.h.

Referenced by HcalHF_S9S1algorithm(), and HFSetFlagFromS9S1().

◆ LongSlopes

std::vector<double> HcalHF_S9S1algorithm::LongSlopes
private

Definition at line 53 of file HcalHF_S9S1algorithm.h.

Referenced by HcalHF_S9S1algorithm(), and HFSetFlagFromS9S1().

◆ short_Energy_

std::vector<double> HcalHF_S9S1algorithm::short_Energy_
private

Definition at line 49 of file HcalHF_S9S1algorithm.h.

◆ short_ET_

std::vector<double> HcalHF_S9S1algorithm::short_ET_
private

Definition at line 48 of file HcalHF_S9S1algorithm.h.

◆ ShortEnergyThreshold

std::vector<double> HcalHF_S9S1algorithm::ShortEnergyThreshold
private

Definition at line 56 of file HcalHF_S9S1algorithm.h.

Referenced by HcalHF_S9S1algorithm(), and HFSetFlagFromS9S1().

◆ ShortETThreshold

std::vector<double> HcalHF_S9S1algorithm::ShortETThreshold
private

Definition at line 58 of file HcalHF_S9S1algorithm.h.

Referenced by HcalHF_S9S1algorithm(), and HFSetFlagFromS9S1().

◆ ShortSlopes

std::vector<double> HcalHF_S9S1algorithm::ShortSlopes
private

Definition at line 54 of file HcalHF_S9S1algorithm.h.

Referenced by HcalHF_S9S1algorithm(), and HFSetFlagFromS9S1().