@@ -9,13 +9,15 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra
99 const EcalMGPAGainRatio* aGain,
1010 const FullSampleVector& fullpulse,
1111 const float targetTimePrecision,
12- const bool correctForOOT) const {
12+ const bool correctForOOT,
13+ const bool correctForSlew) const {
1314 constexpr unsigned int nsample = EcalDataFrame::MAXSAMPLES;
1415
1516 double maxamplitude = -std::numeric_limits<double >::max ();
1617 float pulsenorm = 0 .;
1718
1819 std::vector<float > pedSubSamples (nsample);
20+ std::vector<float > weights (nsample, 1 .f );
1921 for (unsigned int iSample = 0 ; iSample < nsample; iSample++) {
2022 const EcalMGPASample& sample = dataFrame.sample (iSample);
2123
@@ -45,10 +47,19 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra
4547
4648 pedSubSamples[iSample] = amplitude;
4749
50+ pulsenorm += fullpulse (iSample);
51+
4852 if (amplitude > maxamplitude) {
4953 maxamplitude = amplitude;
5054 }
51- pulsenorm += fullpulse (iSample);
55+
56+ if (iSample > 0 && correctForSlew) {
57+ int GainIdPrev = dataFrame.sample (iSample - 1 ).gainId ();
58+ bool GainIdInRange = GainIdPrev >= 1 && GainIdPrev <= 3 && gainId >= 1 && gainId <= 3 ;
59+ bool GainSlew = GainIdPrev < gainId;
60+ if (GainIdInRange && GainSlew)
61+ weights[iSample - 1 ] = 0 .f ;
62+ }
5263 }
5364
5465 if (correctForOOT) {
@@ -61,7 +72,7 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra
6172
6273 for (unsigned int isample = firstsamplet; isample < nsample; ++isample) {
6374 auto const pulse = fullpulse (isample + offset);
64- pedSubSamples[isample] = std::max ( 0 ., pedSubSamples[isample] - amplit * pulse / pulsenorm);
75+ pedSubSamples[isample] = pedSubSamples[isample] - ( amplit * pulse / pulsenorm);
6576 }
6677 }
6778 }
@@ -74,9 +85,9 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra
7485
7586 int counter = 0 ;
7687
77- float cc1 = computeCC (pedSubSamples, fullpulse, t1);
88+ float cc1 = computeCC (pedSubSamples, weights, fullpulse, t1);
7889 ++counter;
79- float cc2 = computeCC (pedSubSamples, fullpulse, t2);
90+ float cc2 = computeCC (pedSubSamples, weights, fullpulse, t2);
8091 ++counter;
8192
8293 while (std::abs (t3 - t0) > targetTimePrecision && counter < MAX_NUM_OF_ITERATIONS) {
@@ -85,14 +96,14 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra
8596 t1 = t2;
8697 t2 = GOLDEN_RATIO * t2 + ONE_MINUS_GOLDEN_RATIO * t3;
8798 cc1 = cc2;
88- cc2 = computeCC (pedSubSamples, fullpulse, t2);
99+ cc2 = computeCC (pedSubSamples, weights, fullpulse, t2);
89100 ++counter;
90101 } else {
91102 t3 = t2;
92103 t2 = t1;
93104 t1 = GOLDEN_RATIO * t1 + ONE_MINUS_GOLDEN_RATIO * t0;
94105 cc2 = cc1;
95- cc1 = computeCC (pedSubSamples, fullpulse, t1);
106+ cc1 = computeCC (pedSubSamples, weights, fullpulse, t1);
96107 ++counter;
97108 }
98109 }
@@ -144,6 +155,7 @@ FullSampleVector EcalUncalibRecHitTimingCCAlgo::interpolatePulse(const FullSampl
144155}
145156
146157float EcalUncalibRecHitTimingCCAlgo::computeCC (const std::vector<float >& samples,
158+ const std::vector<float >& weights,
147159 const FullSampleVector& signalTemplate,
148160 const float time) const {
149161 constexpr int exclude = 1 ;
@@ -152,9 +164,9 @@ float EcalUncalibRecHitTimingCCAlgo::computeCC(const std::vector<float>& samples
152164 float cc = 0 .;
153165 auto interpolated = interpolatePulse (signalTemplate, time);
154166 for (int i = exclude; i < int (samples.size () - exclude); ++i) {
155- powerSamples += std::pow (samples[i], 2 );
156- powerTemplate += std::pow (interpolated[i], 2 );
157- cc += interpolated[i] * samples[i];
167+ powerSamples += std::pow (samples[i], 2 ) * weights[i] ;
168+ powerTemplate += std::pow (interpolated[i], 2 ) * weights[i] ;
169+ cc += interpolated[i] * samples[i] * weights[i] ;
158170 }
159171
160172 float denominator = std::sqrt (powerTemplate * powerSamples);
0 commit comments