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