CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalSimpleRecAlgo.cc
Go to the documentation of this file.
5 #include <algorithm> // for "max"
6 #include <math.h>
7 //--- temporary for printouts
8 #include<iostream>
9 
10 constexpr double MaximumFractionalError = 0.002; // 0.2% error allowed from this source
11 
12 HcalSimpleRecAlgo::HcalSimpleRecAlgo(bool correctForTimeslew, bool correctForPulse, float phaseNS) :
13  correctForTimeslew_(correctForTimeslew),
14  correctForPulse_(correctForPulse),
15  phaseNS_(phaseNS), setForData_(false), setLeakCorrection_(false)
16 {
17 
18  pulseCorr_ = std::auto_ptr<HcalPulseContainmentManager>(
20  );
21 }
22 
23 
25  correctForTimeslew_(false), setForData_(false) { }
26 
27 
29 {
30  pulseCorr_->beginRun(es);
31 }
32 
33 
35 {
36  pulseCorr_->endRun();
37 }
38 
39 
41 }
42 
43 void HcalSimpleRecAlgo::setRecoParams(bool correctForTimeslew, bool correctForPulse, bool setLeakCorrection, int pileupCleaningID, float phaseNS){
44  correctForTimeslew_=correctForTimeslew;
45  correctForPulse_=correctForPulse;
46  phaseNS_=phaseNS;
48  pileupCleaningID_=pileupCleaningID;
49 }
50 
52 
54 
60 static float timeshift_ns_hbheho(float wpksamp);
61 
63 static float timeshift_ns_hf(float wpksamp);
64 
66 static float eCorr(int ieta, int iphi, double ampl);
67 
69 static float leakCorr(double energy);
70 
71 namespace HcalSimpleRecAlgoImpl {
72  template<class Digi, class RecHit>
73  inline RecHit reco(const Digi& digi, const HcalCoder& coder, const HcalCalibrations& calibs,
74  int ifirst, int n, bool slewCorrect, bool pulseCorrect, const HcalPulseContainmentCorrection* corr,
75  HcalTimeSlew::BiasSetting slewFlavor, bool forData, bool useLeak) {
76  CaloSamples tool;
77  coder.adc2fC(digi,tool);
78 
79  double ampl=0; int maxI = -1; double maxA = -1e10; float ta=0;
80  double fc_ampl=0;
81  for (int i=ifirst; i<tool.size() && i<n+ifirst; i++) {
82  int capid=digi[i].capid();
83  ta = (tool[i]-calibs.pedestal(capid)); // pedestal subtraction
84  fc_ampl+=ta;
85  ta*= calibs.respcorrgain(capid) ; // fC --> GeV
86  ampl+=ta;
87  if(ta>maxA){
88  maxA=ta;
89  maxI=i;
90  }
91  }
92 
93  float time = -9999;
95  if(maxI==0 || maxI==(tool.size()-1)) {
96  LogDebug("HCAL Pulse") << "HcalSimpleRecAlgo::reconstruct :"
97  << " Invalid max amplitude position, "
98  << " max Amplitude: "<< maxI
99  << " first: "<<ifirst
100  << " last: "<<(tool.size()-1)
101  << std::endl;
102  } else {
103  int capid=digi[maxI-1].capid();
104  float t0 = ((tool[maxI-1]-calibs.pedestal(capid))*calibs.respcorrgain(capid) );
105  capid=digi[maxI+1].capid();
106  float t2 = ((tool[maxI+1]-calibs.pedestal(capid))*calibs.respcorrgain(capid) );
107 
108  // Handle negative excursions by moving "zero":
109  float minA=t0;
110  if (maxA<minA) minA=maxA;
111  if (t2<minA) minA=t2;
112  if (minA<0) { maxA-=minA; t0-=minA; t2-=minA; } // positivizes all samples
113 
114  float wpksamp = (t0 + maxA + t2);
115  if (wpksamp!=0) wpksamp=(maxA + 2.0*t2) / wpksamp;
116  time = (maxI - digi.presamples())*25.0 + timeshift_ns_hbheho(wpksamp);
117  if (corr!=0 && pulseCorrect ) {
118  // Apply phase-based amplitude correction:
119 
120  /*
121  HcalDetId cell(digi.id());
122  int ieta = cell.ieta();
123  int iphi = cell.iphi();
124  int depth = cell.depth();
125  std::cout << "HcalSimpleRecAlgo::reco cell: ieta, iphi, depth = "
126  << ieta << ", " << iphi
127  << ", " << depth
128  << " first, toadd = " << ifirst << ", " << n << std::endl
129  << " ampl, corr, ampl_after_corr = "
130  << ampl << ", " << corr->getCorrection(fc_ampl)
131  << ", "
132  << ampl * corr->getCorrection(fc_ampl) << std::endl;
133  */
134 
135  ampl *= corr->getCorrection(fc_ampl);
136 
137  }
138  if (slewCorrect) time-=HcalTimeSlew::delay(std::max(1.0,fc_ampl),slewFlavor);
139 
140  time=time-calibs.timecorr(); // time calibration
141  }
142 
143 
144  // Temoprary hack to apply energy-dependent corrections to some HB- cells
145  if(forData) {
146  HcalDetId cell(digi.id());
147  int ieta = cell.ieta();
148  int iphi = cell.iphi();
149  ampl *= eCorr(ieta,iphi,ampl);
150  }
151 
152  // Correction for a leak to pre-sample
153  if(useLeak) {
154  ampl *= leakCorr(ampl);
155  }
156 
157 
158  return RecHit(digi.id(),ampl,time);
159  }
160 }
161 
162 HBHERecHit HcalSimpleRecAlgo::reconstruct(const HBHEDataFrame& digi, int first, int toadd, const HcalCoder& coder, const HcalCalibrations& calibs) const {
163  return HcalSimpleRecAlgoImpl::reco<HBHEDataFrame,HBHERecHit>(digi,coder,calibs,
165  pulseCorr_->get(digi.id(), toadd, phaseNS_),
168 }
169 
170 HORecHit HcalSimpleRecAlgo::reconstruct(const HODataFrame& digi, int first, int toadd, const HcalCoder& coder, const HcalCalibrations& calibs) const {
171  return HcalSimpleRecAlgoImpl::reco<HODataFrame,HORecHit>(digi,coder,calibs,
173  pulseCorr_->get(digi.id(), toadd, phaseNS_),
175  setForData_, false);
176 }
177 
178 HcalCalibRecHit HcalSimpleRecAlgo::reconstruct(const HcalCalibDataFrame& digi, int first, int toadd, const HcalCoder& coder, const HcalCalibrations& calibs) const {
179  return HcalSimpleRecAlgoImpl::reco<HcalCalibDataFrame,HcalCalibRecHit>(digi,coder,calibs,
181  pulseCorr_->get(digi.id(), toadd, phaseNS_),
183  setForData_, false );
184 }
185 
186 /*
187 HBHERecHit HcalSimpleRecAlgo::reconstruct(const HBHEDataFrame& digi, int first, int toadd, const HcalCoder& coder, const HcalCalibrations& calibs) const {
188  return HcalSimpleRecAlgoImpl::reco<HBHEDataFrame,HBHERecHit>(digi,coder,calibs,
189  first,toadd,correctForTimeslew_, correctForPulse_,
190  pulseCorr_->get(digi.id(), toadd, phaseNS_),
191  HcalTimeSlew::Medium,
192  setForData_, setLeakCorrection_);
193 }
194 */
195 
196 
197 HBHERecHit HcalSimpleRecAlgo::reconstructHBHEUpgrade(const HcalUpgradeDataFrame& digi, int first, int toadd, const HcalCoder& coder, const HcalCalibrations& calibs) const {
198  HBHERecHit result = HcalSimpleRecAlgoImpl::reco<HcalUpgradeDataFrame,HBHERecHit>( digi, coder, calibs, first, toadd, correctForTimeslew_, correctForPulse_, pulseCorr_->get(digi.id(), toadd, phaseNS_), HcalTimeSlew::Medium, false, false);
200  tdcReco.reconstruct(digi, result);
201  return result;
202 }
203 
204 
205 HFRecHit HcalSimpleRecAlgo::reconstruct(const HFDataFrame& digi, int first, int toadd, const HcalCoder& coder, const HcalCalibrations& calibs) const {
206 
207  const HcalPulseContainmentCorrection* corr = pulseCorr_->get(digi.id(), toadd, phaseNS_);
208 
209  CaloSamples tool;
210  coder.adc2fC(digi,tool);
211 
212  double ampl=0; int maxI = -1; double maxA = -1e10; float ta=0; float amp_fC=0;
213  for (int i=first; i<tool.size() && i<first+toadd; i++) {
214  int capid=digi[i].capid();
215  ta = (tool[i]-calibs.pedestal(capid))*calibs.respcorrgain(capid);
216  ampl+=ta;
217  amp_fC += tool[i]-calibs.pedestal(capid);
218  if(ta>maxA){
219  maxA=ta;
220  maxI=i;
221  }
222  }
223 
224  float time=-9999.0;
226  if(maxI==0 || maxI==(tool.size()-1)) {
227  LogDebug("HCAL Pulse") << "HcalSimpleRecAlgo::reconstruct :"
228  << " Invalid max amplitude position, "
229  << " max Amplitude: "<< maxI
230  << " first: "<< first
231  << " last: "<<(tool.size()-1)
232  << std::endl;
233  } else {
234  int capid=digi[maxI-1].capid();
235  float t0 = (tool[maxI-1]-calibs.pedestal(capid))*calibs.respcorrgain(capid);
236  capid=digi[maxI+1].capid();
237  float t2 = (tool[maxI+1]-calibs.pedestal(capid))*calibs.respcorrgain(capid);
238 
239  // Handle negative excursions by moving "zero":
240  float zerocorr=std::min(t0,t2);
241  if (zerocorr<0.f) {
242  t0 -= zerocorr;
243  t2 -= zerocorr;
244  maxA -= zerocorr;
245  }
246 
247  // pair the peak with the larger of the two neighboring time samples
248  float wpksamp=0.f;
249  if (t0>t2) {
250  wpksamp = t0+maxA;
251  if (wpksamp != 0.f) wpksamp = maxA/wpksamp;
252  } else {
253  wpksamp = maxA+t2;
254  if (wpksamp != 0.f) wpksamp = 1.+(t2/wpksamp);
255  }
256 
257  time = (maxI - digi.presamples())*25.0 + timeshift_ns_hf(wpksamp);
258 
259  if (corr!=0 && correctForPulse_) {
260 
261  // Apply phase-based amplitude correction:
262 
263  /*
264  HcalDetId cell(digi.id());
265  int ieta = cell.ieta();
266  int iphi = cell.iphi();
267  int depth = cell.depth();
268  std::cout << "*** ieta, iphi, depth = " << ieta << ", " << iphi
269  << ", " << depth
270  << " first, toadd = " << ifirst << ", " << n << std::endl
271  << " ampl, corr, ampl_after_corr = "
272  << ampl << ", " << corr->getCorrection(fc_ampl)
273  << ", "
274  << ampl * corr->getCorrection(fc_ampl) << std::endl;
275  */
276 
277  ampl *= corr->getCorrection(amp_fC);
278  }
279 
280  if (correctForTimeslew_ && (amp_fC>0)) {
281  // -5.12327 - put in calibs.timecorr()
282  double tslew=exp(0.337681-5.94689e-4*amp_fC)+exp(2.44628-1.34888e-2*amp_fC);
283  time -= (float)tslew;
284  }
285 
286  time=time-calibs.timecorr();
287  }
288 
289  return HFRecHit(digi.id(),ampl,time);
290 }
291 
292 // NB: Upgrade HFRecHit method content is just the same as regular HFRecHit
293 // with one exclusion: double time (second is dummy) in constructor
294 HFRecHit HcalSimpleRecAlgo::reconstructHFUpgrade(const HcalUpgradeDataFrame& digi, int first, int toadd, const HcalCoder& coder, const HcalCalibrations& calibs) const {
295 
296  const HcalPulseContainmentCorrection* corr = pulseCorr_->get(digi.id(), toadd, phaseNS_);
297 
298  CaloSamples tool;
299  coder.adc2fC(digi,tool);
300 
301  double ampl=0; int maxI = -1; double maxA = -1e10; float ta=0; float amp_fC=0;
302  for (int i=first; i<tool.size() && i<first+toadd; i++) {
303  int capid=digi[i].capid();
304  ta = (tool[i]-calibs.pedestal(capid))*calibs.respcorrgain(capid);
305  ampl+=ta;
306  amp_fC += tool[i]-calibs.pedestal(capid);
307  if(ta>maxA){
308  maxA=ta;
309  maxI=i;
310  }
311  }
312 
313  float time=-9999.0;
315  if(maxI==0 || maxI==(tool.size()-1)) {
316  LogDebug("HCAL Pulse") << "HcalSimpleRecAlgo::reconstruct :"
317  << " Invalid max amplitude position, "
318  << " max Amplitude: "<< maxI
319  << " first: "<< first
320  << " last: "<<(tool.size()-1)
321  << std::endl;
322  } else {
323  int capid=digi[maxI-1].capid();
324  float t0 = (tool[maxI-1]-calibs.pedestal(capid))*calibs.respcorrgain(capid);
325  capid=digi[maxI+1].capid();
326  float t2 = (tool[maxI+1]-calibs.pedestal(capid))*calibs.respcorrgain(capid);
327 
328  // Handle negative excursions by moving "zero":
329  float zerocorr=std::min(t0,t2);
330  if (zerocorr<0.f) {
331  t0 -= zerocorr;
332  t2 -= zerocorr;
333  maxA -= zerocorr;
334  }
335 
336  // pair the peak with the larger of the two neighboring time samples
337  float wpksamp=0.f;
338  if (t0>t2) {
339  wpksamp = t0+maxA;
340  if (wpksamp != 0.f) wpksamp = maxA/wpksamp;
341  } else {
342  wpksamp = maxA+t2;
343  if (wpksamp != 0.f) wpksamp = 1.+(t2/wpksamp);
344  }
345 
346  time = (maxI - digi.presamples())*25.0 + timeshift_ns_hf(wpksamp);
347 
348  if (corr!=0 && correctForPulse_) {
349 
350  // Apply phase-based amplitude correction:
351 
352  /*
353  HcalDetId cell(digi.id());
354  int ieta = cell.ieta();
355  int iphi = cell.iphi();
356  int depth = cell.depth();
357  std::cout << "*** ieta, iphi, depth = " << ieta << ", " << iphi
358  << ", " << depth
359  << " first, toadd = " << ifirst << ", " << n << std::endl
360  << " ampl, corr, ampl_after_corr = "
361  << ampl << ", " << corr->getCorrection(fc_ampl)
362  << ", "
363  << ampl * corr->getCorrection(fc_ampl) << std::endl;
364  */
365 
366  ampl *= corr->getCorrection(amp_fC);
367  }
368 
369  if (correctForTimeslew_ && (amp_fC>0)) {
370  // -5.12327 - put in calibs.timecorr()
371  double tslew=exp(0.337681-5.94689e-4*amp_fC)+exp(2.44628-1.34888e-2*amp_fC);
372  time -= (float)tslew;
373  }
374 
375  time=time-calibs.timecorr();
376  }
377 
378  return HFRecHit(digi.id(),ampl,time); // new RecHit gets second time = 0.
379 
380 }
381 
382 
384 float eCorr(int ieta, int iphi, double energy) {
385 // return energy correction factor for HBM channels
386 // iphi=6 ieta=(-1,-15) and iphi=32 ieta=(-1,-7)
387 // I.Vodopianov 28 Feb. 2011
388  static const float low32[7] = {0.741,0.721,0.730,0.698,0.708,0.751,0.861};
389  static const float high32[7] = {0.973,0.925,0.900,0.897,0.950,0.935,1};
390  static const float low6[15] = {0.635,0.623,0.670,0.633,0.644,0.648,0.600,
391  0.570,0.595,0.554,0.505,0.513,0.515,0.561,0.579};
392  static const float high6[15] = {0.875,0.937,0.942,0.900,0.922,0.925,0.901,
393  0.850,0.852,0.818,0.731,0.717,0.782,0.853,0.778};
394 
395 
396  double slope, mid, en;
397  double corr = 1.0;
398 
399  if (!(iphi==6 && ieta<0 && ieta>-16) && !(iphi==32 && ieta<0 && ieta>-8))
400  return corr;
401 
402  int jeta = -ieta-1;
403  double xeta = (double) ieta;
404  if (energy > 0.) en=energy;
405  else en = 0.;
406 
407  if (iphi == 32) {
408  slope = 0.2272;
409  mid = 17.14 + 0.7147*xeta;
410  if (en > 100.) corr = high32[jeta];
411  else corr = low32[jeta]+(high32[jeta]-low32[jeta])/(1.0+exp(-(en-mid)*slope));
412  }
413  else if (iphi == 6) {
414  slope = 0.1956;
415  mid = 15.96 + 0.3075*xeta;
416  if (en > 100.0) corr = high6[jeta];
417  else corr = low6[jeta]+(high6[jeta]-low6[jeta])/(1.0+exp(-(en-mid)*slope));
418  }
419 
420  // std::cout << "HBHE cell: ieta, iphi = " << ieta << " " << iphi
421  // << " -> energy = " << en << " corr = " << corr << std::endl;
422 
423  return corr;
424 }
425 
426 
427 // Actual leakage (to pre-sample) correction
428 float leakCorr(double energy) {
429  double corr = 1.0;
430  return corr;
431 }
432 
433 
434 // timeshift implementation
435 
436 static const float wpksamp0_hbheho = 0.5;
437 static const int num_bins_hbheho = 61;
438 
439 static const float actual_ns_hbheho[num_bins_hbheho] = {
440 -5.44000, // 0.500, 0.000-0.017
441 -4.84250, // 0.517, 0.017-0.033
442 -4.26500, // 0.533, 0.033-0.050
443 -3.71000, // 0.550, 0.050-0.067
444 -3.18000, // 0.567, 0.067-0.083
445 -2.66250, // 0.583, 0.083-0.100
446 -2.17250, // 0.600, 0.100-0.117
447 -1.69000, // 0.617, 0.117-0.133
448 -1.23000, // 0.633, 0.133-0.150
449 -0.78000, // 0.650, 0.150-0.167
450 -0.34250, // 0.667, 0.167-0.183
451  0.08250, // 0.683, 0.183-0.200
452  0.50250, // 0.700, 0.200-0.217
453  0.90500, // 0.717, 0.217-0.233
454  1.30500, // 0.733, 0.233-0.250
455  1.69500, // 0.750, 0.250-0.267
456  2.07750, // 0.767, 0.267-0.283
457  2.45750, // 0.783, 0.283-0.300
458  2.82500, // 0.800, 0.300-0.317
459  3.19250, // 0.817, 0.317-0.333
460  3.55750, // 0.833, 0.333-0.350
461  3.91750, // 0.850, 0.350-0.367
462  4.27500, // 0.867, 0.367-0.383
463  4.63000, // 0.883, 0.383-0.400
464  4.98500, // 0.900, 0.400-0.417
465  5.33750, // 0.917, 0.417-0.433
466  5.69500, // 0.933, 0.433-0.450
467  6.05000, // 0.950, 0.450-0.467
468  6.40500, // 0.967, 0.467-0.483
469  6.77000, // 0.983, 0.483-0.500
470  7.13500, // 1.000, 0.500-0.517
471  7.50000, // 1.017, 0.517-0.533
472  7.88250, // 1.033, 0.533-0.550
473  8.26500, // 1.050, 0.550-0.567
474  8.66000, // 1.067, 0.567-0.583
475  9.07000, // 1.083, 0.583-0.600
476  9.48250, // 1.100, 0.600-0.617
477  9.92750, // 1.117, 0.617-0.633
478 10.37750, // 1.133, 0.633-0.650
479 10.87500, // 1.150, 0.650-0.667
480 11.38000, // 1.167, 0.667-0.683
481 11.95250, // 1.183, 0.683-0.700
482 12.55000, // 1.200, 0.700-0.717
483 13.22750, // 1.217, 0.717-0.733
484 13.98500, // 1.233, 0.733-0.750
485 14.81500, // 1.250, 0.750-0.767
486 15.71500, // 1.267, 0.767-0.783
487 16.63750, // 1.283, 0.783-0.800
488 17.53750, // 1.300, 0.800-0.817
489 18.38500, // 1.317, 0.817-0.833
490 19.16500, // 1.333, 0.833-0.850
491 19.89750, // 1.350, 0.850-0.867
492 20.59250, // 1.367, 0.867-0.883
493 21.24250, // 1.383, 0.883-0.900
494 21.85250, // 1.400, 0.900-0.917
495 22.44500, // 1.417, 0.917-0.933
496 22.99500, // 1.433, 0.933-0.950
497 23.53250, // 1.450, 0.950-0.967
498 24.03750, // 1.467, 0.967-0.983
499 24.53250, // 1.483, 0.983-1.000
500 25.00000 // 1.500, 1.000-1.017 - keep for interpolation
501 };
502 
503 float timeshift_ns_hbheho(float wpksamp) {
504  float flx = (num_bins_hbheho-1)*(wpksamp - wpksamp0_hbheho);
505  int index = (int)flx;
506  float yval;
507 
508  if (index < 0) return actual_ns_hbheho[0];
509  else if (index >= num_bins_hbheho-1) return actual_ns_hbheho[num_bins_hbheho-1];
510 
511  // else interpolate:
512  float y1 = actual_ns_hbheho[index];
513  float y2 = actual_ns_hbheho[index+1];
514 
515  yval = y1 + (y2-y1)*(flx-(float)index);
516 
517  return yval;
518 }
519 
520 static const int num_bins_hf = 101;
521 static const float wpksamp0_hf = 0.5;
522 
523 static const float actual_ns_hf[num_bins_hf] = {
524  0.00250, // 0.000-0.010
525  0.04500, // 0.010-0.020
526  0.08750, // 0.020-0.030
527  0.13000, // 0.030-0.040
528  0.17250, // 0.040-0.050
529  0.21500, // 0.050-0.060
530  0.26000, // 0.060-0.070
531  0.30250, // 0.070-0.080
532  0.34500, // 0.080-0.090
533  0.38750, // 0.090-0.100
534  0.42750, // 0.100-0.110
535  0.46000, // 0.110-0.120
536  0.49250, // 0.120-0.130
537  0.52500, // 0.130-0.140
538  0.55750, // 0.140-0.150
539  0.59000, // 0.150-0.160
540  0.62250, // 0.160-0.170
541  0.65500, // 0.170-0.180
542  0.68750, // 0.180-0.190
543  0.72000, // 0.190-0.200
544  0.75250, // 0.200-0.210
545  0.78500, // 0.210-0.220
546  0.81750, // 0.220-0.230
547  0.85000, // 0.230-0.240
548  0.88250, // 0.240-0.250
549  0.91500, // 0.250-0.260
550  0.95500, // 0.260-0.270
551  0.99250, // 0.270-0.280
552  1.03250, // 0.280-0.290
553  1.07000, // 0.290-0.300
554  1.10750, // 0.300-0.310
555  1.14750, // 0.310-0.320
556  1.18500, // 0.320-0.330
557  1.22500, // 0.330-0.340
558  1.26250, // 0.340-0.350
559  1.30000, // 0.350-0.360
560  1.34000, // 0.360-0.370
561  1.37750, // 0.370-0.380
562  1.41750, // 0.380-0.390
563  1.48750, // 0.390-0.400
564  1.55750, // 0.400-0.410
565  1.62750, // 0.410-0.420
566  1.69750, // 0.420-0.430
567  1.76750, // 0.430-0.440
568  1.83750, // 0.440-0.450
569  1.90750, // 0.450-0.460
570  2.06750, // 0.460-0.470
571  2.23250, // 0.470-0.480
572  2.40000, // 0.480-0.490
573  2.82250, // 0.490-0.500
574  3.81000, // 0.500-0.510
575  6.90500, // 0.510-0.520
576  8.99250, // 0.520-0.530
577 10.50000, // 0.530-0.540
578 11.68250, // 0.540-0.550
579 12.66250, // 0.550-0.560
580 13.50250, // 0.560-0.570
581 14.23750, // 0.570-0.580
582 14.89750, // 0.580-0.590
583 15.49000, // 0.590-0.600
584 16.03250, // 0.600-0.610
585 16.53250, // 0.610-0.620
586 17.00000, // 0.620-0.630
587 17.44000, // 0.630-0.640
588 17.85250, // 0.640-0.650
589 18.24000, // 0.650-0.660
590 18.61000, // 0.660-0.670
591 18.96750, // 0.670-0.680
592 19.30500, // 0.680-0.690
593 19.63000, // 0.690-0.700
594 19.94500, // 0.700-0.710
595 20.24500, // 0.710-0.720
596 20.54000, // 0.720-0.730
597 20.82250, // 0.730-0.740
598 21.09750, // 0.740-0.750
599 21.37000, // 0.750-0.760
600 21.62750, // 0.760-0.770
601 21.88500, // 0.770-0.780
602 22.13000, // 0.780-0.790
603 22.37250, // 0.790-0.800
604 22.60250, // 0.800-0.810
605 22.83000, // 0.810-0.820
606 23.04250, // 0.820-0.830
607 23.24500, // 0.830-0.840
608 23.44250, // 0.840-0.850
609 23.61000, // 0.850-0.860
610 23.77750, // 0.860-0.870
611 23.93500, // 0.870-0.880
612 24.05500, // 0.880-0.890
613 24.17250, // 0.890-0.900
614 24.29000, // 0.900-0.910
615 24.40750, // 0.910-0.920
616 24.48250, // 0.920-0.930
617 24.55500, // 0.930-0.940
618 24.62500, // 0.940-0.950
619 24.69750, // 0.950-0.960
620 24.77000, // 0.960-0.970
621 24.84000, // 0.970-0.980
622 24.91250, // 0.980-0.990
623 24.95500, // 0.990-1.000
624 24.99750, // 1.000-1.010 - keep for interpolation
625 };
626 
627 float timeshift_ns_hf(float wpksamp) {
628  float flx = (num_bins_hf-1)*(wpksamp-wpksamp0_hf);
629  int index = (int)flx;
630  float yval;
631 
632  if (index < 0) return actual_ns_hf[0];
633  else if (index >= num_bins_hf-1) return actual_ns_hf[num_bins_hf-1];
634 
635  // else interpolate:
636  float y1 = actual_ns_hf[index];
637  float y2 = actual_ns_hf[index+1];
638 
639  // float delta_x = 1/(float)num_bins_hf;
640  // yval = y1 + (y2-y1)*(flx-(float)index)/delta_x;
641 
642  yval = y1 + (y2-y1)*(flx-(float)index);
643  return yval;
644 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
static const float actual_ns_hf[num_bins_hf]
HBHERecHit reconstruct(const HBHEDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
double respcorrgain(int fCapId) const
get response corrected gain for capid=0..3
static float timeshift_ns_hf(float wpksamp)
Same as above, but for the HF PMTs.
double getCorrection(double fc_ampl) const
void beginRun(edm::EventSetup const &es)
static const double slope[3]
#define min(a, b)
Definition: mlp_lapack.h:161
double pedestal(int fCapId) const
get pedestal for capid=0..3
static const float wpksamp0_hbheho
static const float wpksamp0_hf
static const float actual_ns_hbheho[num_bins_hbheho]
const T & max(const T &a, const T &b)
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:18
HFRecHit reconstructHFUpgrade(const HcalUpgradeDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
tuple result
Definition: query.py:137
int ieta() const
get the cell ieta
Definition: HcalDetId.h:38
void initPulseCorr(int toadd)
double f[11][100]
static float leakCorr(double energy)
Leak correction.
std::auto_ptr< HcalPulseContainmentManager > pulseCorr_
bool first
Definition: L1TdeRCT.cc:94
JetCorrectorParameters corr
Definition: classes.h:11
static float timeshift_ns_hbheho(float wpksamp)
static float eCorr(int ieta, int iphi, double ampl)
Ugly hack to apply energy corrections to some HB- cells.
void setRecoParams(bool correctForTimeslew, bool correctForPulse, bool setLeakCorrection, int pileupCleaningID, float phaseNS)
constexpr double MaximumFractionalError
int size() const
get the size
Definition: CaloSamples.h:26
double timecorr() const
get time correction factor
HBHERecHit reconstructHBHEUpgrade(const HcalUpgradeDataFrame &digi, int first, int toadd, const HcalCoder &coder, const HcalCalibrations &calibs) const
static const int num_bins_hf
const HcalDetId & id() const
static const int num_bins_hbheho
void reconstruct(const HcalUpgradeDataFrame &digi, HBHERecHit &recHit) const
Definition: HcalTDCReco.cc:8
virtual void adc2fC(const HBHEDataFrame &df, CaloSamples &lf) const =0
int presamples() const
number of samples before the sample from the triggered beam crossing (according to the hardware) ...
Definition: HFDataFrame.h:28
const HcalDetId & id() const
Definition: HFDataFrame.h:22
RecHit reco(const Digi &digi, const HcalCoder &coder, const HcalCalibrations &calibs, int ifirst, int n, bool slewCorrect, bool pulseCorrect, const HcalPulseContainmentCorrection *corr, HcalTimeSlew::BiasSetting slewFlavor, bool forData, bool useLeak)
#define constexpr
static double delay(double fC, BiasSetting bias=Medium)
Returns the amount (ns) by which a pulse of the given number of fC will be delayed by the timeslew ef...
Definition: HcalTimeSlew.cc:8