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