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