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