CMS 3D CMS Logo

HcalSimpleRecAlgo.cc
Go to the documentation of this file.
11 
12 #include <algorithm>
13 #include <cmath>
14 
15 //--- temporary for printouts
16 // #include<iostream>
17 
18 constexpr double MaximumFractionalError = 0.002; // 0.2% error allowed from this source
19 
21  bool correctForPulse,
22  float phaseNS,
24  : correctForTimeslew_(correctForTimeslew),
25  correctForPulse_(correctForPulse),
26  phaseNS_(phaseNS),
27  delayToken_(iC.esConsumes<edm::Transition::BeginRun>(edm::ESInputTag("", "HBHE"))),
28  runnum_(0),
29  setLeakCorrection_(false),
30  puCorrMethod_(0) {
31  hcalTimeSlew_delay_ = nullptr;
32  pulseCorr_ = std::make_unique<HcalPulseContainmentManager>(MaximumFractionalError, iC);
33 }
34 
37 
38  pulseCorr_->beginRun(es);
39 }
40 
42 
44 
46  bool correctForTimeslew, bool correctForPulse, bool setLeakCorrection, int pileupCleaningID, float phaseNS) {
48  correctForPulse_ = correctForPulse;
49  phaseNS_ = phaseNS;
51  pileupCleaningID_ = pileupCleaningID;
52 }
53 
55 
56 void HcalSimpleRecAlgo::setHFPileupCorrection(std::shared_ptr<AbsOOTPileupCorrection> corr) { hfPileupCorr_ = corr; }
57 
58 void HcalSimpleRecAlgo::setHOPileupCorrection(std::shared_ptr<AbsOOTPileupCorrection> corr) { hoPileupCorr_ = corr; }
59 
60 void HcalSimpleRecAlgo::setBXInfo(const BunchXParameter* info, const unsigned lenInfo) {
62  lenBunchCrossingInfo_ = lenInfo;
63 }
64 
66 static float timeshift_ns_hf(float wpksamp);
67 
69 static float leakCorr(double energy);
70 
72  template <class Digi>
73  inline float recoHFTime(
74  const Digi& digi, const int maxI, const double amp_fC, const bool slewCorrect, double maxA, float t0, float t2) {
75  // Handle negative excursions by moving "zero":
76  float zerocorr = std::min(t0, t2);
77  if (zerocorr < 0.f) {
78  t0 -= zerocorr;
79  t2 -= zerocorr;
80  maxA -= zerocorr;
81  }
82 
83  // pair the peak with the larger of the two neighboring time samples
84  float wpksamp = 0.f;
85  if (t0 > t2) {
86  wpksamp = t0 + maxA;
87  if (wpksamp != 0.f)
88  wpksamp = maxA / wpksamp;
89  } else {
90  wpksamp = maxA + t2;
91  if (wpksamp != 0.f)
92  wpksamp = 1. + (t2 / wpksamp);
93  }
94 
95  float time = (maxI - digi.presamples()) * 25.0 + timeshift_ns_hf(wpksamp);
96 
97  if (slewCorrect && amp_fC > 0.0) {
98  // -5.12327 - put in calibs.timecorr()
99  double tslew = exp(0.337681 - 5.94689e-4 * amp_fC) + exp(2.44628 - 1.34888e-2 * amp_fC);
100  time -= (float)tslew;
101  }
102 
103  return time;
104  }
105 
106  template <class Digi>
107  inline void removePileup(const Digi& digi,
108  const HcalCoder& coder,
109  const HcalCalibrations& calibs,
110  const int ifirst,
111  const int n,
112  const bool pulseCorrect,
114  const AbsOOTPileupCorrection* pileupCorrection,
115  const BunchXParameter* bxInfo,
116  const unsigned lenInfo,
117  double* p_maxA,
118  double* p_ampl,
119  double* p_uncorr_ampl,
120  double* p_fc_ampl,
121  int* p_nRead,
122  int* p_maxI,
123  bool* leakCorrApplied,
124  float* p_t0,
125  float* p_t2) {
126  CaloSamples cs;
127  coder.adc2fC(digi, cs);
128  const int nRead = cs.size();
129  const int iStop = std::min(nRead, n + ifirst);
130 
131  // Signal energy will be calculated both with
132  // and without OOT pileup corrections. Try to
133  // arrange the calculations so that we do not
134  // repeat them.
135  double uncorrectedEnergy[CaloSamples::MAXSAMPLES]{}, buf[CaloSamples::MAXSAMPLES]{};
136  double* correctedEnergy = nullptr;
137  double fc_ampl = 0.0, corr_fc_ampl = 0.0;
138  bool pulseShapeCorrApplied = false, readjustTiming = false;
139  *leakCorrApplied = false;
140 
141  if (pileupCorrection) {
142  correctedEnergy = &buf[0];
143 
144  double correctionInput[CaloSamples::MAXSAMPLES]{};
145  double gains[CaloSamples::MAXSAMPLES]{};
146 
147  for (int i = 0; i < nRead; ++i) {
148  const int capid = digi[i].capid();
149  correctionInput[i] = cs[i] - calibs.pedestal(capid);
150  gains[i] = calibs.respcorrgain(capid);
151  }
152 
153  for (int i = ifirst; i < iStop; ++i)
154  fc_ampl += correctionInput[i];
155 
156  const bool useGain = pileupCorrection->inputIsEnergy();
157  for (int i = 0; i < nRead; ++i) {
158  uncorrectedEnergy[i] = correctionInput[i] * gains[i];
159  if (useGain)
160  correctionInput[i] = uncorrectedEnergy[i];
161  }
162 
163  pileupCorrection->apply(digi.id(),
164  correctionInput,
165  nRead,
166  bxInfo,
167  lenInfo,
168  ifirst,
169  n,
170  correctedEnergy,
172  &pulseShapeCorrApplied,
173  leakCorrApplied,
174  &readjustTiming);
175  if (useGain) {
176  // Gain factors have been already applied.
177  // Divide by them for accumulating corr_fc_ampl.
178  for (int i = ifirst; i < iStop; ++i)
179  if (gains[i])
180  corr_fc_ampl += correctedEnergy[i] / gains[i];
181  } else {
182  for (int i = ifirst; i < iStop; ++i)
183  corr_fc_ampl += correctedEnergy[i];
184  for (int i = 0; i < nRead; ++i)
185  correctedEnergy[i] *= gains[i];
186  }
187  } else {
188  correctedEnergy = &uncorrectedEnergy[0];
189 
190  // In this situation, we do not need to process all time slices
191  const int istart = std::max(ifirst - 1, 0);
192  const int iend = std::min(n + ifirst + 1, nRead);
193  for (int i = istart; i < iend; ++i) {
194  const int capid = digi[i].capid();
195  float ta = cs[i] - calibs.pedestal(capid);
196  if (i >= ifirst && i < iStop)
197  fc_ampl += ta;
198  ta *= calibs.respcorrgain(capid);
199  uncorrectedEnergy[i] = ta;
200  }
201  corr_fc_ampl = fc_ampl;
202  }
203 
204  // Uncorrected and corrected energies
205  double ampl = 0.0, corr_ampl = 0.0;
206  for (int i = ifirst; i < iStop; ++i) {
207  ampl += uncorrectedEnergy[i];
208  corr_ampl += correctedEnergy[i];
209  }
210 
211  // Apply phase-based amplitude correction:
212  if (corr && pulseCorrect) {
213  ampl *= corr->getCorrection(fc_ampl);
214  if (pileupCorrection) {
215  if (!pulseShapeCorrApplied)
216  corr_ampl *= corr->getCorrection(corr_fc_ampl);
217  } else
218  corr_ampl = ampl;
219  }
220 
221  // Which energies we want to use for timing?
222  const double* etime = readjustTiming ? &correctedEnergy[0] : &uncorrectedEnergy[0];
223  int maxI = -1;
224  double maxA = -1.e300;
225  for (int i = ifirst; i < iStop; ++i)
226  if (etime[i] > maxA) {
227  maxA = etime[i];
228  maxI = i;
229  }
230 
231  // Fill out the output
232  *p_maxA = maxA;
233  *p_ampl = corr_ampl;
234  *p_uncorr_ampl = ampl;
235  *p_fc_ampl = readjustTiming ? corr_fc_ampl : fc_ampl;
236  *p_nRead = nRead;
237  *p_maxI = maxI;
238 
239  if (maxI <= 0 || maxI >= (nRead - 1)) {
240  LogDebug("HCAL Pulse") << "HcalSimpleRecAlgoImpl::removePileup :"
241  << " Invalid max amplitude position, "
242  << " max Amplitude: " << maxI << " first: " << ifirst << " last: " << ifirst + n
243  << std::endl;
244  *p_t0 = 0.f;
245  *p_t2 = 0.f;
246  } else {
247  *p_t0 = etime[maxI - 1];
248  *p_t2 = etime[maxI + 1];
249  }
250  }
251 
252  template <class Digi, class RecHit>
253  inline RecHit reco(const Digi& digi,
254  const HcalCoder& coder,
255  const HcalCalibrations& calibs,
256  const int ifirst,
257  const int n,
258  const bool slewCorrect,
259  const bool pulseCorrect,
261  const HcalTimeSlew::BiasSetting slewFlavor,
262  const int runnum,
263  const bool useLeak,
264  const AbsOOTPileupCorrection* pileupCorrection,
265  const BunchXParameter* bxInfo,
266  const unsigned lenInfo,
267  const int puCorrMethod,
268  const HcalTimeSlew* hcalTimeSlew_delay_) {
269  double fc_ampl = 0, ampl = 0, uncorr_ampl = 0, m3_ampl = 0, maxA = -1.e300;
270  int nRead = 0, maxI = -1;
271  bool leakCorrApplied = false;
272  float t0 = 0, t2 = 0;
273  float time = -9999;
274 
275  // Disable method 1 inside the removePileup function this way!
276  // Some code in removePileup does NOT do pileup correction & to make sure maximum share of code
277  const AbsOOTPileupCorrection* inputAbsOOTpuCorr = (puCorrMethod == 1 ? pileupCorrection : nullptr);
278 
279  removePileup(digi,
280  coder,
281  calibs,
282  ifirst,
283  n,
284  pulseCorrect,
285  corr,
286  inputAbsOOTpuCorr,
287  bxInfo,
288  lenInfo,
289  &maxA,
290  &ampl,
291  &uncorr_ampl,
292  &fc_ampl,
293  &nRead,
294  &maxI,
295  &leakCorrApplied,
296  &t0,
297  &t2);
298 
299  if (maxI > 0 && maxI < (nRead - 1)) {
300  // Handle negative excursions by moving "zero":
301  float minA = t0;
302  if (maxA < minA)
303  minA = maxA;
304  if (t2 < minA)
305  minA = t2;
306  if (minA < 0) {
307  maxA -= minA;
308  t0 -= minA;
309  t2 -= minA;
310  } // positivizes all samples
311 
312  float wpksamp = (t0 + maxA + t2);
313  if (wpksamp != 0)
314  wpksamp = (maxA + 2.0 * t2) / wpksamp;
315  time = (maxI - digi.presamples()) * 25.0 + timeshift_ns_hbheho(wpksamp);
316 
317  if (slewCorrect)
318  time -= hcalTimeSlew_delay_->delay(std::max(1.0, fc_ampl), slewFlavor);
319 
320  time = time - calibs.timecorr(); // time calibration
321  }
322 
323  // Correction for a leak to pre-sample
324  if (useLeak && !leakCorrApplied) {
325  uncorr_ampl *= leakCorr(uncorr_ampl);
326  if (puCorrMethod < 2)
327  ampl *= leakCorr(ampl);
328  }
329 
330  RecHit rh(digi.id(), ampl, time);
331  setRawEnergy(rh, static_cast<float>(uncorr_ampl));
332  setAuxEnergy(rh, static_cast<float>(m3_ampl));
333  return rh;
334  }
335 } // namespace HcalSimpleRecAlgoImpl
336 
338  const HODataFrame& digi, int first, int toadd, const HcalCoder& coder, const HcalCalibrations& calibs) const {
339  return HcalSimpleRecAlgoImpl::reco<HODataFrame, HORecHit>(digi,
340  coder,
341  calibs,
342  first,
343  toadd,
346  pulseCorr_->get(digi.id(), toadd, phaseNS_),
348  runnum_,
349  false,
350  hoPileupCorr_.get(),
355 }
356 
358  int first,
359  int toadd,
360  const HcalCoder& coder,
361  const HcalCalibrations& calibs) const {
362  return HcalSimpleRecAlgoImpl::reco<HcalCalibDataFrame, HcalCalibRecHit>(digi,
363  coder,
364  calibs,
365  first,
366  toadd,
369  pulseCorr_->get(digi.id(), toadd, phaseNS_),
371  runnum_,
372  false,
373  nullptr,
378 }
379 
381  const int first,
382  const int toadd,
383  const HcalCoder& coder,
384  const HcalCalibrations& calibs) const {
385  const HcalPulseContainmentCorrection* corr = pulseCorr_->get(digi.id(), toadd, phaseNS_);
386 
387  double amp_fC, ampl, uncorr_ampl, maxA;
388  int nRead, maxI;
389  bool leakCorrApplied;
390  float t0, t2;
391 
393  coder,
394  calibs,
395  first,
396  toadd,
398  corr,
399  hfPileupCorr_.get(),
402  &maxA,
403  &ampl,
404  &uncorr_ampl,
405  &amp_fC,
406  &nRead,
407  &maxI,
408  &leakCorrApplied,
409  &t0,
410  &t2);
411 
412  float time = -9999.f;
413  if (maxI > 0 && maxI < (nRead - 1))
414  time = HcalSimpleRecAlgoImpl::recoHFTime(digi, maxI, amp_fC, correctForTimeslew_, maxA, t0, t2) - calibs.timecorr();
415 
416  HFRecHit rh(digi.id(), ampl, time);
417  setRawEnergy(rh, static_cast<float>(uncorr_ampl));
418  return rh;
419 }
420 
422  const int first,
423  const int toadd,
424  const HcalCoder& coder,
425  const HcalCalibrations& calibs) const {
426  const HcalPulseContainmentCorrection* corr = pulseCorr_->get(digi.id(), toadd, phaseNS_);
427 
428  double amp_fC, ampl, uncorr_ampl, maxA;
429  int nRead, maxI;
430  bool leakCorrApplied;
431  float t0, t2;
432 
434  coder,
435  calibs,
436  first,
437  toadd,
439  corr,
440  hfPileupCorr_.get(),
443  &maxA,
444  &ampl,
445  &uncorr_ampl,
446  &amp_fC,
447  &nRead,
448  &maxI,
449  &leakCorrApplied,
450  &t0,
451  &t2);
452 
453  float time = -9999.f;
454  if (maxI > 0 && maxI < (nRead - 1))
455  time = HcalSimpleRecAlgoImpl::recoHFTime(digi, maxI, amp_fC, correctForTimeslew_, maxA, t0, t2) - calibs.timecorr();
456 
457  HFRecHit rh(digi.id(), ampl, time);
458  setRawEnergy(rh, static_cast<float>(uncorr_ampl));
459  return rh;
460 }
461 
463 float hbminus_special_ecorr(int ieta, int iphi, double energy, int runnum) {
464  // return energy correction factor for HBM channels
465  // iphi=6 ieta=(-1,-15) and iphi=32 ieta=(-1,-7)
466  // I.Vodopianov 28 Feb. 2011
467  static const float low32[7] = {0.741, 0.721, 0.730, 0.698, 0.708, 0.751, 0.861};
468  static const float high32[7] = {0.973, 0.925, 0.900, 0.897, 0.950, 0.935, 1};
469  static const float low6[15] = {
470  0.635, 0.623, 0.670, 0.633, 0.644, 0.648, 0.600, 0.570, 0.595, 0.554, 0.505, 0.513, 0.515, 0.561, 0.579};
471  static const float high6[15] = {
472  0.875, 0.937, 0.942, 0.900, 0.922, 0.925, 0.901, 0.850, 0.852, 0.818, 0.731, 0.717, 0.782, 0.853, 0.778};
473 
474  double slope, mid, en;
475  double corr = 1.0;
476 
477  if (!(iphi == 6 && ieta < 0 && ieta > -16) && !(iphi == 32 && ieta < 0 && ieta > -8))
478  return corr;
479 
480  int jeta = -ieta - 1;
481  double xeta = (double)ieta;
482  if (energy > 0.)
483  en = energy;
484  else
485  en = 0.;
486 
487  if (iphi == 32) {
488  slope = 0.2272;
489  mid = 17.14 + 0.7147 * xeta;
490  if (en > 100.)
491  corr = high32[jeta];
492  else
493  corr = low32[jeta] + (high32[jeta] - low32[jeta]) / (1.0 + exp(-(en - mid) * slope));
494  } else if (iphi == 6 && runnum < 216091) {
495  slope = 0.1956;
496  mid = 15.96 + 0.3075 * xeta;
497  if (en > 100.0)
498  corr = high6[jeta];
499  else
500  corr = low6[jeta] + (high6[jeta] - low6[jeta]) / (1.0 + exp(-(en - mid) * slope));
501  }
502 
503  // std::cout << "HBHE cell: ieta, iphi = " << ieta << " " << iphi
504  // << " -> energy = " << en << " corr = " << corr << std::endl;
505 
506  return corr;
507 }
508 
509 // Actual leakage (to pre-sample) correction
510 float leakCorr(double energy) {
511  double corr = 1.0;
512  return corr;
513 }
514 
515 // timeshift implementation
516 
517 static const float wpksamp0_hbheho = 0.5;
518 static const int num_bins_hbheho = 61;
519 
520 static const float actual_ns_hbheho[num_bins_hbheho] = {
521  -5.44000, // 0.500, 0.000-0.017
522  -4.84250, // 0.517, 0.017-0.033
523  -4.26500, // 0.533, 0.033-0.050
524  -3.71000, // 0.550, 0.050-0.067
525  -3.18000, // 0.567, 0.067-0.083
526  -2.66250, // 0.583, 0.083-0.100
527  -2.17250, // 0.600, 0.100-0.117
528  -1.69000, // 0.617, 0.117-0.133
529  -1.23000, // 0.633, 0.133-0.150
530  -0.78000, // 0.650, 0.150-0.167
531  -0.34250, // 0.667, 0.167-0.183
532  0.08250, // 0.683, 0.183-0.200
533  0.50250, // 0.700, 0.200-0.217
534  0.90500, // 0.717, 0.217-0.233
535  1.30500, // 0.733, 0.233-0.250
536  1.69500, // 0.750, 0.250-0.267
537  2.07750, // 0.767, 0.267-0.283
538  2.45750, // 0.783, 0.283-0.300
539  2.82500, // 0.800, 0.300-0.317
540  3.19250, // 0.817, 0.317-0.333
541  3.55750, // 0.833, 0.333-0.350
542  3.91750, // 0.850, 0.350-0.367
543  4.27500, // 0.867, 0.367-0.383
544  4.63000, // 0.883, 0.383-0.400
545  4.98500, // 0.900, 0.400-0.417
546  5.33750, // 0.917, 0.417-0.433
547  5.69500, // 0.933, 0.433-0.450
548  6.05000, // 0.950, 0.450-0.467
549  6.40500, // 0.967, 0.467-0.483
550  6.77000, // 0.983, 0.483-0.500
551  7.13500, // 1.000, 0.500-0.517
552  7.50000, // 1.017, 0.517-0.533
553  7.88250, // 1.033, 0.533-0.550
554  8.26500, // 1.050, 0.550-0.567
555  8.66000, // 1.067, 0.567-0.583
556  9.07000, // 1.083, 0.583-0.600
557  9.48250, // 1.100, 0.600-0.617
558  9.92750, // 1.117, 0.617-0.633
559  10.37750, // 1.133, 0.633-0.650
560  10.87500, // 1.150, 0.650-0.667
561  11.38000, // 1.167, 0.667-0.683
562  11.95250, // 1.183, 0.683-0.700
563  12.55000, // 1.200, 0.700-0.717
564  13.22750, // 1.217, 0.717-0.733
565  13.98500, // 1.233, 0.733-0.750
566  14.81500, // 1.250, 0.750-0.767
567  15.71500, // 1.267, 0.767-0.783
568  16.63750, // 1.283, 0.783-0.800
569  17.53750, // 1.300, 0.800-0.817
570  18.38500, // 1.317, 0.817-0.833
571  19.16500, // 1.333, 0.833-0.850
572  19.89750, // 1.350, 0.850-0.867
573  20.59250, // 1.367, 0.867-0.883
574  21.24250, // 1.383, 0.883-0.900
575  21.85250, // 1.400, 0.900-0.917
576  22.44500, // 1.417, 0.917-0.933
577  22.99500, // 1.433, 0.933-0.950
578  23.53250, // 1.450, 0.950-0.967
579  24.03750, // 1.467, 0.967-0.983
580  24.53250, // 1.483, 0.983-1.000
581  25.00000 // 1.500, 1.000-1.017 - keep for interpolation
582 };
583 
584 float timeshift_ns_hbheho(float wpksamp) {
585  float flx = (num_bins_hbheho - 1) * (wpksamp - wpksamp0_hbheho);
586  int index = (int)flx;
587  float yval;
588 
589  if (index < 0)
590  return actual_ns_hbheho[0];
591  else if (index >= num_bins_hbheho - 1)
592  return actual_ns_hbheho[num_bins_hbheho - 1];
593 
594  // else interpolate:
595  float y1 = actual_ns_hbheho[index];
596  float y2 = actual_ns_hbheho[index + 1];
597 
598  yval = y1 + (y2 - y1) * (flx - (float)index);
599 
600  return yval;
601 }
602 
603 static const int num_bins_hf = 101;
604 static const float wpksamp0_hf = 0.5;
605 
606 static const float actual_ns_hf[num_bins_hf] = {
607  0.00250, // 0.000-0.010
608  0.04500, // 0.010-0.020
609  0.08750, // 0.020-0.030
610  0.13000, // 0.030-0.040
611  0.17250, // 0.040-0.050
612  0.21500, // 0.050-0.060
613  0.26000, // 0.060-0.070
614  0.30250, // 0.070-0.080
615  0.34500, // 0.080-0.090
616  0.38750, // 0.090-0.100
617  0.42750, // 0.100-0.110
618  0.46000, // 0.110-0.120
619  0.49250, // 0.120-0.130
620  0.52500, // 0.130-0.140
621  0.55750, // 0.140-0.150
622  0.59000, // 0.150-0.160
623  0.62250, // 0.160-0.170
624  0.65500, // 0.170-0.180
625  0.68750, // 0.180-0.190
626  0.72000, // 0.190-0.200
627  0.75250, // 0.200-0.210
628  0.78500, // 0.210-0.220
629  0.81750, // 0.220-0.230
630  0.85000, // 0.230-0.240
631  0.88250, // 0.240-0.250
632  0.91500, // 0.250-0.260
633  0.95500, // 0.260-0.270
634  0.99250, // 0.270-0.280
635  1.03250, // 0.280-0.290
636  1.07000, // 0.290-0.300
637  1.10750, // 0.300-0.310
638  1.14750, // 0.310-0.320
639  1.18500, // 0.320-0.330
640  1.22500, // 0.330-0.340
641  1.26250, // 0.340-0.350
642  1.30000, // 0.350-0.360
643  1.34000, // 0.360-0.370
644  1.37750, // 0.370-0.380
645  1.41750, // 0.380-0.390
646  1.48750, // 0.390-0.400
647  1.55750, // 0.400-0.410
648  1.62750, // 0.410-0.420
649  1.69750, // 0.420-0.430
650  1.76750, // 0.430-0.440
651  1.83750, // 0.440-0.450
652  1.90750, // 0.450-0.460
653  2.06750, // 0.460-0.470
654  2.23250, // 0.470-0.480
655  2.40000, // 0.480-0.490
656  2.82250, // 0.490-0.500
657  3.81000, // 0.500-0.510
658  6.90500, // 0.510-0.520
659  8.99250, // 0.520-0.530
660  10.50000, // 0.530-0.540
661  11.68250, // 0.540-0.550
662  12.66250, // 0.550-0.560
663  13.50250, // 0.560-0.570
664  14.23750, // 0.570-0.580
665  14.89750, // 0.580-0.590
666  15.49000, // 0.590-0.600
667  16.03250, // 0.600-0.610
668  16.53250, // 0.610-0.620
669  17.00000, // 0.620-0.630
670  17.44000, // 0.630-0.640
671  17.85250, // 0.640-0.650
672  18.24000, // 0.650-0.660
673  18.61000, // 0.660-0.670
674  18.96750, // 0.670-0.680
675  19.30500, // 0.680-0.690
676  19.63000, // 0.690-0.700
677  19.94500, // 0.700-0.710
678  20.24500, // 0.710-0.720
679  20.54000, // 0.720-0.730
680  20.82250, // 0.730-0.740
681  21.09750, // 0.740-0.750
682  21.37000, // 0.750-0.760
683  21.62750, // 0.760-0.770
684  21.88500, // 0.770-0.780
685  22.13000, // 0.780-0.790
686  22.37250, // 0.790-0.800
687  22.60250, // 0.800-0.810
688  22.83000, // 0.810-0.820
689  23.04250, // 0.820-0.830
690  23.24500, // 0.830-0.840
691  23.44250, // 0.840-0.850
692  23.61000, // 0.850-0.860
693  23.77750, // 0.860-0.870
694  23.93500, // 0.870-0.880
695  24.05500, // 0.880-0.890
696  24.17250, // 0.890-0.900
697  24.29000, // 0.900-0.910
698  24.40750, // 0.910-0.920
699  24.48250, // 0.920-0.930
700  24.55500, // 0.930-0.940
701  24.62500, // 0.940-0.950
702  24.69750, // 0.950-0.960
703  24.77000, // 0.960-0.970
704  24.84000, // 0.970-0.980
705  24.91250, // 0.980-0.990
706  24.95500, // 0.990-1.000
707  24.99750, // 1.000-1.010 - keep for interpolation
708 };
709 
710 float timeshift_ns_hf(float wpksamp) {
711  float flx = (num_bins_hf - 1) * (wpksamp - wpksamp0_hf);
712  int index = (int)flx;
713  float yval;
714 
715  if (index < 0)
716  return actual_ns_hf[0];
717  else if (index >= num_bins_hf - 1)
718  return actual_ns_hf[num_bins_hf - 1];
719 
720  // else interpolate:
721  float y1 = actual_ns_hf[index];
722  float y2 = actual_ns_hf[index + 1];
723 
724  // float delta_x = 1/(float)num_bins_hf;
725  // yval = y1 + (y2-y1)*(flx-(float)index)/delta_x;
726 
727  yval = y1 + (y2 - y1) * (flx - (float)index);
728  return yval;
729 }
HcalSimpleRecAlgo::delayToken_
const edm::ESGetToken< HcalTimeSlew, HcalTimeSlewRecord > delayToken_
Definition: HcalSimpleRecAlgo.h:76
setAuxEnergy
void setAuxEnergy(HcalRecHit &h, float e)
Definition: rawEnergy.h:234
RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
HcalSimpleRecAlgo::runnum_
int runnum_
Definition: HcalSimpleRecAlgo.h:78
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
funct::false
false
Definition: Factorize.h:29
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
ESInputTag
HcalCoder::adc2fC
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0
HFDataFrame::id
constexpr HcalDetId const & id() const
Definition: HFDataFrame.h:23
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
fwrapper::cs
unique_ptr< ClusterSequence > cs
Definition: fastjetfortran_madfks.cc:47
min
T min(T a, T b)
Definition: MathUtil.h:58
HORecHit
Definition: HORecHit.h:11
edm
HLT enums.
Definition: AlignableModifier.h:19
METSignificanceParams_cfi.jeta
jeta
Definition: METSignificanceParams_cfi.py:12
TrendClient_cfi.Digi
Digi
Definition: TrendClient_cfi.py:7
wpksamp0_hbheho
static const float wpksamp0_hbheho
Definition: HcalSimpleRecAlgo.cc:517
HcalSimpleRecAlgoImpl::removePileup
void removePileup(const Digi &digi, const HcalCoder &coder, const HcalCalibrations &calibs, const int ifirst, const int n, const bool pulseCorrect, const HcalPulseContainmentCorrection *corr, const AbsOOTPileupCorrection *pileupCorrection, const BunchXParameter *bxInfo, const unsigned lenInfo, double *p_maxA, double *p_ampl, double *p_uncorr_ampl, double *p_fc_ampl, int *p_nRead, int *p_maxI, bool *leakCorrApplied, float *p_t0, float *p_t2)
Definition: HcalSimpleRecAlgo.cc:107
HcalSimpleRecAlgo::setBXInfo
void setBXInfo(const BunchXParameter *info, unsigned lenInfo)
Definition: HcalSimpleRecAlgo.cc:60
HcalSimpleRecAlgo::setHFPileupCorrection
void setHFPileupCorrection(std::shared_ptr< AbsOOTPileupCorrection > corr)
Definition: HcalSimpleRecAlgo.cc:56
rawEnergy.h
protons_cff.time
time
Definition: protons_cff.py:39
HcalTimeSlew.h
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:153
HcalSimpleRecAlgo::beginRun
void beginRun(edm::EventSetup const &es)
Definition: HcalSimpleRecAlgo.cc:35
findQualityFiles.maxI
int maxI
Definition: findQualityFiles.py:182
timeshift_ns_hf
static float timeshift_ns_hf(float wpksamp)
Timeshift correction for the HF PMTs.
Definition: HcalSimpleRecAlgo.cc:710
HcalSimpleRecAlgoImpl::recoHFTime
float recoHFTime(const Digi &digi, const int maxI, const double amp_fC, const bool slewCorrect, double maxA, float t0, float t2)
Definition: HcalSimpleRecAlgo.cc:73
AbsOOTPileupCorrection
Definition: AbsOOTPileupCorrection.h:26
HcalPulseContainmentCorrection
Definition: HcalPulseContainmentCorrection.h:15
CaloSamples::MAXSAMPLES
static const int MAXSAMPLES
Definition: CaloSamples.h:86
HcalTimeSlew::BiasSetting
BiasSetting
Definition: HcalTimeSlew.h:71
HcalTimeSlew
Definition: HcalTimeSlew.h:19
HcalTimeSlew::delay
float delay(float fC, BiasSetting bias=Medium) const
Returns the amount (ns) by which a pulse of the given number of fC will be delayed by the timeslew ef...
Definition: HcalTimeSlew.cc:20
LEDCalibrationChannels.iphi
iphi
Definition: LEDCalibrationChannels.py:64
MaximumFractionalError
constexpr double MaximumFractionalError
Definition: HcalSimpleRecAlgo.cc:18
testProducerWithPsetDescEmpty_cfi.y1
y1
Definition: testProducerWithPsetDescEmpty_cfi.py:29
HcalSimpleRecAlgo::phaseNS_
float phaseNS_
Definition: HcalSimpleRecAlgo.h:75
HFRecHit
Definition: HFRecHit.h:11
HcalSimpleRecAlgo::pulseCorr_
std::unique_ptr< HcalPulseContainmentManager > pulseCorr_
Definition: HcalSimpleRecAlgo.h:77
HcalSimpleRecAlgo::puCorrMethod_
int puCorrMethod_
Definition: HcalSimpleRecAlgo.h:89
HcalSimpleRecAlgo::setLeakCorrection_
bool setLeakCorrection_
Definition: HcalSimpleRecAlgo.h:79
leakCorr
static float leakCorr(double energy)
Leak correction.
Definition: HcalSimpleRecAlgo.cc:510
FrontierCondition_GT_autoExpress_cfi.t0
t0
Definition: FrontierCondition_GT_autoExpress_cfi.py:149
alignCSCRings.corr
dictionary corr
Definition: alignCSCRings.py:124
HcalTDCReco.h
HcalSimpleRecAlgo::lenBunchCrossingInfo_
unsigned lenBunchCrossingInfo_
Definition: HcalSimpleRecAlgo.h:82
wpksamp0_hf
static const float wpksamp0_hf
Definition: HcalSimpleRecAlgo.cc:604
HcalCorrectionFunctions.h
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
HcalSimpleRecAlgo::bunchCrossingInfo_
const BunchXParameter * bunchCrossingInfo_
Definition: HcalSimpleRecAlgo.h:81
HcalTimeSlew::Slow
Definition: HcalTimeSlew.h:71
HcalCalibrations
Definition: HcalCalibrations.h:9
first
auto first
Definition: CAHitNtupletGeneratorKernelsImpl.h:112
actual_ns_hbheho
static const float actual_ns_hbheho[num_bins_hbheho]
Definition: HcalSimpleRecAlgo.cc:520
HcalCalibrations::respcorrgain
constexpr double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
Definition: HcalCalibrations.h:42
HcalSimpleRecAlgo::correctForTimeslew_
bool correctForTimeslew_
Definition: HcalSimpleRecAlgo.h:73
HcalCalibDataFrame
Definition: HcalCalibDataFrame.h:15
testProducerWithPsetDescEmpty_cfi.y2
y2
Definition: testProducerWithPsetDescEmpty_cfi.py:30
HcalCalibrations::timecorr
constexpr double timecorr() const
get time correction factor
Definition: HcalCalibrations.h:52
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
HcalCalibRecHit
Definition: HcalCalibRecHit.h:10
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::Transition
Transition
Definition: Transition.h:12
HcalCaloFlagLabels.h
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
num_bins_hf
static const int num_bins_hf
Definition: HcalSimpleRecAlgo.cc:603
HcalSimpleRecAlgo::initPulseCorr
void initPulseCorr(int toadd)
Definition: HcalSimpleRecAlgo.cc:43
num_bins_hbheho
static const int num_bins_hbheho
Definition: HcalSimpleRecAlgo.cc:518
HcalSimpleRecAlgo.h
AbsOOTPileupCorrection::inputIsEnergy
virtual bool inputIsEnergy() const =0
HcalSimpleRecAlgo::reconstructQIE10
HFRecHit reconstructQIE10(const QIE10DataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
Definition: HcalSimpleRecAlgo.cc:421
createfilelist.int
int
Definition: createfilelist.py:10
HFDataFrame
Definition: HFDataFrame.h:14
HcalSimpleRecAlgoImpl::reco
RecHit reco(const Digi &digi, const HcalCoder &coder, const HcalCalibrations &calibs, const int ifirst, const int n, const bool slewCorrect, const bool pulseCorrect, const HcalPulseContainmentCorrection *corr, const HcalTimeSlew::BiasSetting slewFlavor, const int runnum, const bool useLeak, const AbsOOTPileupCorrection *pileupCorrection, const BunchXParameter *bxInfo, const unsigned lenInfo, const int puCorrMethod, const HcalTimeSlew *hcalTimeSlew_delay_)
Definition: HcalSimpleRecAlgo.cc:253
HcalSimpleRecAlgo::setRecoParams
void setRecoParams(bool correctForTimeslew, bool correctForPulse, bool setLeakCorrection, int pileupCleaningID, float phaseNS)
Definition: HcalSimpleRecAlgo.cc:45
edm::EventSetup
Definition: EventSetup.h:58
CaloSamples
Definition: CaloSamples.h:14
HcalSimpleRecAlgo::setLeakCorrection
void setLeakCorrection()
Definition: HcalSimpleRecAlgo.cc:54
visDQMUpload.buf
buf
Definition: visDQMUpload.py:154
timeshift_ns_hbheho
float timeshift_ns_hbheho(float wpksamp)
Definition: HcalSimpleRecAlgo.cc:584
edm::EventSetup::getData
bool getData(T &iHolder) const
Definition: EventSetup.h:127
HcalCalibrations::pedestal
constexpr double pedestal(int fCapId) const
get pedestal for capid=0..3
Definition: HcalCalibrations.h:46
castor_dqm_sourceclient-live_cfg.correctForTimeslew
correctForTimeslew
Definition: castor_dqm_sourceclient-live_cfg.py:66
QIE10DataFrame
Definition: QIE10DataFrame.h:11
HODataFrame
Definition: HODataFrame.h:14
HcalSimpleRecAlgo::setHOPileupCorrection
void setHOPileupCorrection(std::shared_ptr< AbsOOTPileupCorrection > corr)
Definition: HcalSimpleRecAlgo.cc:58
HcalCoder
Definition: HcalCoder.h:19
setRawEnergy
void setRawEnergy(HcalRecHit &h, float e)
Definition: rawEnergy.h:217
EventSetup.h
HcalSimpleRecAlgo::hoPileupCorr_
std::shared_ptr< AbsOOTPileupCorrection > hoPileupCorr_
Definition: HcalSimpleRecAlgo.h:85
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
HcalSimpleRecAlgo::pileupCleaningID_
int pileupCleaningID_
Definition: HcalSimpleRecAlgo.h:80
HcalSimpleRecAlgo::endRun
void endRun()
Definition: HcalSimpleRecAlgo.cc:41
ConsumesCollector.h
HcalSimpleRecAlgoImpl
Definition: HcalSimpleRecAlgo.cc:71
HcalSimpleRecAlgo::hcalTimeSlew_delay_
const HcalTimeSlew * hcalTimeSlew_delay_
Definition: HcalSimpleRecAlgo.h:91
HcalTimeSlewRecord.h
actual_ns_hf
static const float actual_ns_hf[num_bins_hf]
Definition: HcalSimpleRecAlgo.cc:606
HcalSimpleRecAlgo::HcalSimpleRecAlgo
HcalSimpleRecAlgo(bool correctForTimeslew, bool correctForContainment, float fixedPhaseNs, edm::ConsumesCollector iC)
Definition: HcalSimpleRecAlgo.cc:20
HcalSimpleRecAlgo::correctForPulse_
bool correctForPulse_
Definition: HcalSimpleRecAlgo.h:74
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
HcalSimpleRecAlgo::hfPileupCorr_
std::shared_ptr< AbsOOTPileupCorrection > hfPileupCorr_
Definition: HcalSimpleRecAlgo.h:84
slope
static const double slope[3]
Definition: CastorTimeSlew.cc:6
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
HODataFrame::id
constexpr HcalDetId const & id() const
Definition: HODataFrame.h:23
QIE10DataFrame::id
constexpr edm::DataFrame::id_type id() const
Definition: QIE10DataFrame.h:77
HcalSimpleRecAlgo::reconstruct
HFRecHit reconstruct(const HFDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
Definition: HcalSimpleRecAlgo.cc:380
HcalCalibDataFrame::id
const HcalCalibDetId & id() const
Definition: HcalCalibDataFrame.h:22
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
AbsOOTPileupCorrection::apply
virtual void apply(const HcalDetId &id, const double *inputCharge, unsigned lenInputCharge, const BunchXParameter *bcParams, unsigned lenBcParams, unsigned firstTimeSlice, unsigned nTimeSlices, double *correctedCharge, unsigned lenCorrectedCharge, bool *pulseShapeCorrApplied, bool *leakCorrApplied, bool *readjustTiming) const =0
hbminus_special_ecorr
float hbminus_special_ecorr(int ieta, int iphi, double energy, int runnum)
Ugly hack to apply energy corrections to some HB- cells.
Definition: HcalSimpleRecAlgo.cc:463
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
HcalTimeSlew::Fast
Definition: HcalTimeSlew.h:71