Skip to content

Commit

Permalink
Merge pull request #26054 from abdoulline/M0_timing_update
Browse files Browse the repository at this point in the history
HCAL M0 timing update/cleanup
  • Loading branch information
cmsbuild committed Mar 11, 2019
2 parents 61be00a + 3bf3d7b commit 0165e04
Showing 1 changed file with 20 additions and 25 deletions.
45 changes: 20 additions & 25 deletions RecoLocalCalo/HcalRecAlgos/src/SimpleHBHEPhase1Algo.cc
Expand Up @@ -207,34 +207,29 @@ float SimpleHBHEPhase1Algo::m0Time(const HBHEChannelInfo& info,
int ibeg = soi + firstSampleShift_;
if (ibeg < 0)
ibeg = 0;
const int iend = ibeg + nSamplesToExamine;
unsigned maxI = info.peakEnergyTS(ibeg, iend);
const int iend = std::min(ibeg + nSamplesToExamine, (int)nSamples - 1); // actual array

unsigned maxI = info.peakEnergyTS((unsigned)ibeg, (unsigned)iend); // requires unsigned params
if (maxI < HBHEChannelInfo::MAXSAMPLES)
{
if (!maxI)
maxI = 1U;
else if (maxI >= nSamples - 1U)
maxI = nSamples - 2U;

// The remaining code in this scope emulates
// the historic algorithm
float t0 = info.tsEnergy(maxI - 1U);
float maxA = info.tsEnergy(maxI);
float t2 = info.tsEnergy(maxI + 1U);

// Handle negative excursions by moving "zero"
float minA = t0;
if (maxA < minA) minA = maxA;
if (t2 < minA) minA=t2;
if (minA < 0.f) { maxA-=minA; t0-=minA; t2-=minA; }
float wpksamp = (t0 + maxA + t2);
if (wpksamp) wpksamp = (maxA + 2.f*t2) / wpksamp;
time = (maxI - soi)*25.f + timeshift_ns_hbheho(wpksamp);

// Legacy QIE8 timing correction

if(maxI >= nSamples) maxI = nSamples - 1U; // just in case

// Simplified evaluation for Phase1
float emax0 = info.tsEnergy(maxI);
float emax1 = 0.;
if(maxI < (nSamples - 1U)) emax1 = info.tsEnergy(maxI + 1U);

// consider soi reference for collisions
int position = (int)maxI;
if(nSamplesToExamine < (int)nSamples) position -= soi;

time = 25.f * (float)position;
if(emax0 > 0.f && emax1 > 0.f && maxI < (nSamples - 1U)) time += 25.f * emax1/(emax0+emax1); // 1st order corr.

// TimeSlew correction
time -= hcalTimeSlew_delay_->delay(std::max(1.0, fc_ampl), HcalTimeSlew::Medium);
// Time calibration
time -= calibs.timecorr();

}
}
return time;
Expand Down

0 comments on commit 0165e04

Please sign in to comment.