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