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