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){
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, HcalDeterministicFit * hltOOTpuCorr, PedestalSub * hltPedSub /* whatever don't know what to do with the pointer...*/)// 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  //if(cs[4]-calibs.pedestal(capidvec[4])+cs[5]-calibs.pedestal(capidvec[4]) > 5){
367  psFitOOTpuCorr->apply(cs, capidvec, calibs, correctedOutput);
368  if( correctedOutput.back() == 0 && correctedOutput.size() >1 ){
369  time = correctedOutput[1]; ampl = correctedOutput[0];
370  }
371  // } else {time = -999; ampl = 0;}
372  }
373 
374  // S. Brandt - Feb 19th : Adding Section for HLT
375  // Turn on HLT here with puCorrMethod = 3
376  if ( puCorrMethod == 3){
377  std::vector<double> hltCorrOutput;
378  hltPedSub->init(((PedestalSub::Method)1), 0, 2.7, 0.0);
380 
381  CaloSamples cs;
382  coder.adc2fC(digi,cs);
383  std::vector<int> capidvec;
384  for(int ip=0; ip<cs.size(); ip++){
385  const int capid = digi[ip].capid();
386  capidvec.push_back(capid);
387  }
388  // if(cs[4]-calibs.pedestal(capidvec[4])+cs[5]-calibs.pedestal(capidvec[4]) > 5){
389  hltOOTpuCorr->apply(cs, capidvec, calibs, hltCorrOutput);
390  if( hltCorrOutput.size() > 1 ){
391  time = hltCorrOutput[1]; ampl = hltCorrOutput[0];
392  }
393  //} else {time = -999; ampl = 0;}
394  }
395 
396  // Temporary hack to apply energy-dependent corrections to some HB- cells
397  if (runnum > 0) {
398  const HcalDetId& cell = digi.id();
399  if (cell.subdet() == HcalBarrel) {
400  const int ieta = cell.ieta();
401  const int iphi = cell.iphi();
402  ampl *= eCorr(ieta, iphi, ampl, runnum);
403  uncorr_ampl *= eCorr(ieta, iphi, uncorr_ampl, runnum);
404  }
405  }
406 
407  // Correction for a leak to pre-sample
408  if(useLeak && !leakCorrApplied) {
409  ampl *= leakCorr(ampl);
410  uncorr_ampl *= leakCorr(uncorr_ampl);
411  }
412 
413  RecHit rh(digi.id(),ampl,time);
414  setRawEnergy(rh, static_cast<float>(uncorr_ampl));
415  return rh;
416  }
417 }
418 
419 
420 HBHERecHit HcalSimpleRecAlgo::reconstruct(const HBHEDataFrame& digi, int first, int toadd, const HcalCoder& coder, const HcalCalibrations& calibs) const {
421  return HcalSimpleRecAlgoImpl::reco<HBHEDataFrame,HBHERecHit>(digi,coder,calibs,
423  pulseCorr_->get(digi.id(), toadd, phaseNS_),
426  hbhePileupCorr_.get(),
428 }
429 
430 
431 HORecHit HcalSimpleRecAlgo::reconstruct(const HODataFrame& digi, int first, int toadd, const HcalCoder& coder, const HcalCalibrations& calibs) const {
432  return HcalSimpleRecAlgoImpl::reco<HODataFrame,HORecHit>(digi,coder,calibs,
434  pulseCorr_->get(digi.id(), toadd, phaseNS_),
436  runnum_, false, hoPileupCorr_.get(),
438 }
439 
440 
441 HcalCalibRecHit HcalSimpleRecAlgo::reconstruct(const HcalCalibDataFrame& digi, int first, int toadd, const HcalCoder& coder, const HcalCalibrations& calibs) const {
442  return HcalSimpleRecAlgoImpl::reco<HcalCalibDataFrame,HcalCalibRecHit>(digi,coder,calibs,
444  pulseCorr_->get(digi.id(), toadd, phaseNS_),
446  runnum_, false, 0,
448 }
449 
450 
451 HBHERecHit HcalSimpleRecAlgo::reconstructHBHEUpgrade(const HcalUpgradeDataFrame& digi, int first, int toadd, const HcalCoder& coder, const HcalCalibrations& calibs) const {
452  HBHERecHit result = HcalSimpleRecAlgoImpl::reco<HcalUpgradeDataFrame,HBHERecHit>(digi, coder, calibs,
454  pulseCorr_->get(digi.id(), toadd, phaseNS_),
455  HcalTimeSlew::Medium, 0, false,
456  hbhePileupCorr_.get(),
459  tdcReco.reconstruct(digi, result);
460  return result;
461 }
462 
463 
465  const int first,
466  const int toadd,
467  const HcalCoder& coder,
468  const HcalCalibrations& calibs) const
469 {
470  const HcalPulseContainmentCorrection* corr = pulseCorr_->get(digi.id(), toadd, phaseNS_);
471 
472  double amp_fC, ampl, uncorr_ampl, maxA;
473  int nRead, maxI;
474  bool leakCorrApplied;
475  float t0, t2;
476 
477  HcalSimpleRecAlgoImpl::removePileup(digi, coder, calibs, first, toadd,
478  correctForPulse_, corr, hfPileupCorr_.get(),
480  &maxA, &ampl, &uncorr_ampl, &amp_fC, &nRead,
481  &maxI, &leakCorrApplied, &t0, &t2);
482 
483  float time=-9999.f;
484  if (maxI > 0 && maxI < (nRead - 1))
485  time = HcalSimpleRecAlgoImpl::recoHFTime(digi,maxI,amp_fC,correctForTimeslew_,maxA,t0,t2) -
486  calibs.timecorr();
487 
488  HFRecHit rh(digi.id(),ampl,time);
489  setRawEnergy(rh, static_cast<float>(uncorr_ampl));
490  return rh;
491 }
492 
493 
494 // NB: Upgrade HFRecHit method content is just the same as regular HFRecHit
495 // with one exclusion: double time (second is dummy) in constructor
497  const int first,
498  const int toadd,
499  const HcalCoder& coder,
500  const HcalCalibrations& calibs) const
501 {
502  const HcalPulseContainmentCorrection* corr = pulseCorr_->get(digi.id(), toadd, phaseNS_);
503 
504  double amp_fC, ampl, uncorr_ampl, maxA;
505  int nRead, maxI;
506  bool leakCorrApplied;
507  float t0, t2;
508 
509  HcalSimpleRecAlgoImpl::removePileup(digi, coder, calibs, first, toadd,
510  correctForPulse_, corr, hfPileupCorr_.get(),
512  &maxA, &ampl, &uncorr_ampl, &amp_fC, &nRead,
513  &maxI, &leakCorrApplied, &t0, &t2);
514 
515  float time=-9999.f;
516  if (maxI > 0 && maxI < (nRead - 1))
517  time = HcalSimpleRecAlgoImpl::recoHFTime(digi,maxI,amp_fC,correctForTimeslew_,maxA,t0,t2) -
518  calibs.timecorr();
519 
520  HFRecHit rh(digi.id(),ampl,time); // new RecHit gets second time = 0.
521  setRawEnergy(rh, static_cast<float>(uncorr_ampl));
522  return rh;
523 }
524 
525 
527 float eCorr(int ieta, int iphi, double energy, int runnum) {
528 // return energy correction factor for HBM channels
529 // iphi=6 ieta=(-1,-15) and iphi=32 ieta=(-1,-7)
530 // I.Vodopianov 28 Feb. 2011
531  static const float low32[7] = {0.741,0.721,0.730,0.698,0.708,0.751,0.861};
532  static const float high32[7] = {0.973,0.925,0.900,0.897,0.950,0.935,1};
533  static const float low6[15] = {0.635,0.623,0.670,0.633,0.644,0.648,0.600,
534  0.570,0.595,0.554,0.505,0.513,0.515,0.561,0.579};
535  static const float high6[15] = {0.875,0.937,0.942,0.900,0.922,0.925,0.901,
536  0.850,0.852,0.818,0.731,0.717,0.782,0.853,0.778};
537 
538 
539  double slope, mid, en;
540  double corr = 1.0;
541 
542  if (!(iphi==6 && ieta<0 && ieta>-16) && !(iphi==32 && ieta<0 && ieta>-8))
543  return corr;
544 
545  int jeta = -ieta-1;
546  double xeta = (double) ieta;
547  if (energy > 0.) en=energy;
548  else en = 0.;
549 
550  if (iphi == 32) {
551  slope = 0.2272;
552  mid = 17.14 + 0.7147*xeta;
553  if (en > 100.) corr = high32[jeta];
554  else corr = low32[jeta]+(high32[jeta]-low32[jeta])/(1.0+exp(-(en-mid)*slope));
555  }
556  else if (iphi == 6 && runnum < 216091 ) {
557  slope = 0.1956;
558  mid = 15.96 + 0.3075*xeta;
559  if (en > 100.0) corr = high6[jeta];
560  else corr = low6[jeta]+(high6[jeta]-low6[jeta])/(1.0+exp(-(en-mid)*slope));
561  }
562 
563  // std::cout << "HBHE cell: ieta, iphi = " << ieta << " " << iphi
564  // << " -> energy = " << en << " corr = " << corr << std::endl;
565 
566  return corr;
567 }
568 
569 
570 // Actual leakage (to pre-sample) correction
571 float leakCorr(double energy) {
572  double corr = 1.0;
573  return corr;
574 }
575 
576 
577 // timeshift implementation
578 
579 static const float wpksamp0_hbheho = 0.5;
580 static const int num_bins_hbheho = 61;
581 
582 static const float actual_ns_hbheho[num_bins_hbheho] = {
583 -5.44000, // 0.500, 0.000-0.017
584 -4.84250, // 0.517, 0.017-0.033
585 -4.26500, // 0.533, 0.033-0.050
586 -3.71000, // 0.550, 0.050-0.067
587 -3.18000, // 0.567, 0.067-0.083
588 -2.66250, // 0.583, 0.083-0.100
589 -2.17250, // 0.600, 0.100-0.117
590 -1.69000, // 0.617, 0.117-0.133
591 -1.23000, // 0.633, 0.133-0.150
592 -0.78000, // 0.650, 0.150-0.167
593 -0.34250, // 0.667, 0.167-0.183
594  0.08250, // 0.683, 0.183-0.200
595  0.50250, // 0.700, 0.200-0.217
596  0.90500, // 0.717, 0.217-0.233
597  1.30500, // 0.733, 0.233-0.250
598  1.69500, // 0.750, 0.250-0.267
599  2.07750, // 0.767, 0.267-0.283
600  2.45750, // 0.783, 0.283-0.300
601  2.82500, // 0.800, 0.300-0.317
602  3.19250, // 0.817, 0.317-0.333
603  3.55750, // 0.833, 0.333-0.350
604  3.91750, // 0.850, 0.350-0.367
605  4.27500, // 0.867, 0.367-0.383
606  4.63000, // 0.883, 0.383-0.400
607  4.98500, // 0.900, 0.400-0.417
608  5.33750, // 0.917, 0.417-0.433
609  5.69500, // 0.933, 0.433-0.450
610  6.05000, // 0.950, 0.450-0.467
611  6.40500, // 0.967, 0.467-0.483
612  6.77000, // 0.983, 0.483-0.500
613  7.13500, // 1.000, 0.500-0.517
614  7.50000, // 1.017, 0.517-0.533
615  7.88250, // 1.033, 0.533-0.550
616  8.26500, // 1.050, 0.550-0.567
617  8.66000, // 1.067, 0.567-0.583
618  9.07000, // 1.083, 0.583-0.600
619  9.48250, // 1.100, 0.600-0.617
620  9.92750, // 1.117, 0.617-0.633
621 10.37750, // 1.133, 0.633-0.650
622 10.87500, // 1.150, 0.650-0.667
623 11.38000, // 1.167, 0.667-0.683
624 11.95250, // 1.183, 0.683-0.700
625 12.55000, // 1.200, 0.700-0.717
626 13.22750, // 1.217, 0.717-0.733
627 13.98500, // 1.233, 0.733-0.750
628 14.81500, // 1.250, 0.750-0.767
629 15.71500, // 1.267, 0.767-0.783
630 16.63750, // 1.283, 0.783-0.800
631 17.53750, // 1.300, 0.800-0.817
632 18.38500, // 1.317, 0.817-0.833
633 19.16500, // 1.333, 0.833-0.850
634 19.89750, // 1.350, 0.850-0.867
635 20.59250, // 1.367, 0.867-0.883
636 21.24250, // 1.383, 0.883-0.900
637 21.85250, // 1.400, 0.900-0.917
638 22.44500, // 1.417, 0.917-0.933
639 22.99500, // 1.433, 0.933-0.950
640 23.53250, // 1.450, 0.950-0.967
641 24.03750, // 1.467, 0.967-0.983
642 24.53250, // 1.483, 0.983-1.000
643 25.00000 // 1.500, 1.000-1.017 - keep for interpolation
644 };
645 
646 float timeshift_ns_hbheho(float wpksamp) {
647  float flx = (num_bins_hbheho-1)*(wpksamp - wpksamp0_hbheho);
648  int index = (int)flx;
649  float yval;
650 
651  if (index < 0) return actual_ns_hbheho[0];
652  else if (index >= num_bins_hbheho-1) return actual_ns_hbheho[num_bins_hbheho-1];
653 
654  // else interpolate:
655  float y1 = actual_ns_hbheho[index];
656  float y2 = actual_ns_hbheho[index+1];
657 
658  yval = y1 + (y2-y1)*(flx-(float)index);
659 
660  return yval;
661 }
662 
663 static const int num_bins_hf = 101;
664 static const float wpksamp0_hf = 0.5;
665 
666 static const float actual_ns_hf[num_bins_hf] = {
667  0.00250, // 0.000-0.010
668  0.04500, // 0.010-0.020
669  0.08750, // 0.020-0.030
670  0.13000, // 0.030-0.040
671  0.17250, // 0.040-0.050
672  0.21500, // 0.050-0.060
673  0.26000, // 0.060-0.070
674  0.30250, // 0.070-0.080
675  0.34500, // 0.080-0.090
676  0.38750, // 0.090-0.100
677  0.42750, // 0.100-0.110
678  0.46000, // 0.110-0.120
679  0.49250, // 0.120-0.130
680  0.52500, // 0.130-0.140
681  0.55750, // 0.140-0.150
682  0.59000, // 0.150-0.160
683  0.62250, // 0.160-0.170
684  0.65500, // 0.170-0.180
685  0.68750, // 0.180-0.190
686  0.72000, // 0.190-0.200
687  0.75250, // 0.200-0.210
688  0.78500, // 0.210-0.220
689  0.81750, // 0.220-0.230
690  0.85000, // 0.230-0.240
691  0.88250, // 0.240-0.250
692  0.91500, // 0.250-0.260
693  0.95500, // 0.260-0.270
694  0.99250, // 0.270-0.280
695  1.03250, // 0.280-0.290
696  1.07000, // 0.290-0.300
697  1.10750, // 0.300-0.310
698  1.14750, // 0.310-0.320
699  1.18500, // 0.320-0.330
700  1.22500, // 0.330-0.340
701  1.26250, // 0.340-0.350
702  1.30000, // 0.350-0.360
703  1.34000, // 0.360-0.370
704  1.37750, // 0.370-0.380
705  1.41750, // 0.380-0.390
706  1.48750, // 0.390-0.400
707  1.55750, // 0.400-0.410
708  1.62750, // 0.410-0.420
709  1.69750, // 0.420-0.430
710  1.76750, // 0.430-0.440
711  1.83750, // 0.440-0.450
712  1.90750, // 0.450-0.460
713  2.06750, // 0.460-0.470
714  2.23250, // 0.470-0.480
715  2.40000, // 0.480-0.490
716  2.82250, // 0.490-0.500
717  3.81000, // 0.500-0.510
718  6.90500, // 0.510-0.520
719  8.99250, // 0.520-0.530
720 10.50000, // 0.530-0.540
721 11.68250, // 0.540-0.550
722 12.66250, // 0.550-0.560
723 13.50250, // 0.560-0.570
724 14.23750, // 0.570-0.580
725 14.89750, // 0.580-0.590
726 15.49000, // 0.590-0.600
727 16.03250, // 0.600-0.610
728 16.53250, // 0.610-0.620
729 17.00000, // 0.620-0.630
730 17.44000, // 0.630-0.640
731 17.85250, // 0.640-0.650
732 18.24000, // 0.650-0.660
733 18.61000, // 0.660-0.670
734 18.96750, // 0.670-0.680
735 19.30500, // 0.680-0.690
736 19.63000, // 0.690-0.700
737 19.94500, // 0.700-0.710
738 20.24500, // 0.710-0.720
739 20.54000, // 0.720-0.730
740 20.82250, // 0.730-0.740
741 21.09750, // 0.740-0.750
742 21.37000, // 0.750-0.760
743 21.62750, // 0.760-0.770
744 21.88500, // 0.770-0.780
745 22.13000, // 0.780-0.790
746 22.37250, // 0.790-0.800
747 22.60250, // 0.800-0.810
748 22.83000, // 0.810-0.820
749 23.04250, // 0.820-0.830
750 23.24500, // 0.830-0.840
751 23.44250, // 0.840-0.850
752 23.61000, // 0.850-0.860
753 23.77750, // 0.860-0.870
754 23.93500, // 0.870-0.880
755 24.05500, // 0.880-0.890
756 24.17250, // 0.890-0.900
757 24.29000, // 0.900-0.910
758 24.40750, // 0.910-0.920
759 24.48250, // 0.920-0.930
760 24.55500, // 0.930-0.940
761 24.62500, // 0.940-0.950
762 24.69750, // 0.950-0.960
763 24.77000, // 0.960-0.970
764 24.84000, // 0.970-0.980
765 24.91250, // 0.980-0.990
766 24.95500, // 0.990-1.000
767 24.99750, // 1.000-1.010 - keep for interpolation
768 };
769 
770 float timeshift_ns_hf(float wpksamp) {
771  float flx = (num_bins_hf-1)*(wpksamp-wpksamp0_hf);
772  int index = (int)flx;
773  float yval;
774 
775  if (index < 0) return actual_ns_hf[0];
776  else if (index >= num_bins_hf-1) return actual_ns_hf[num_bins_hf-1];
777 
778  // else interpolate:
779  float y1 = actual_ns_hf[index];
780  float y2 = actual_ns_hf[index+1];
781 
782  // float delta_x = 1/(float)num_bins_hf;
783  // yval = y1 + (y2-y1)*(flx-(float)index)/delta_x;
784 
785  yval = y1 + (y2-y1)*(flx-(float)index);
786  return yval;
787 }
#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]
assert(m_qm.get())
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]
void apply(const CaloSamples &cs, const std::vector< int > &capidvec, const HcalCalibrations &calibs, std::vector< double > &HLTOutput) const
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]
void init(HcalTimeSlew::ParaSource tsParam, HcalTimeSlew::BiasSetting bias, NegStrategy nStrat, PedestalSub pedSubFxn_)
static float leakCorr(double energy)
Leak correction.
T min(T a, T b)
Definition: MathUtil.h:58
std::auto_ptr< HcalPulseContainmentManager > pulseCorr_
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
std::auto_ptr< PedestalSub > pedSubFxn_
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
std::auto_ptr< HcalDeterministicFit > hltOOTpuCorr_
void init(Method method, int runCond, float threshold, float quantile)
Definition: PedestalSub.cc:14
volatile std::atomic< bool > shutdown_flag false
const HcalDetId & id() const
Definition: HFDataFrame.h:22
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)
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)