Skip to content

Commit 3b0667b

Browse files
authored
Merge pull request #45386 from jking79/pr_master_cc_slew_correction
Updated EcalUncalibRecHitTimingCCAlgo to correct for bias at high energies
2 parents 58f6467 + 15b297b commit 3b0667b

File tree

3 files changed

+50
-20
lines changed

3 files changed

+50
-20
lines changed

RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitTimingCCAlgo.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class EcalUncalibRecHitTimingCCAlgo {
2424
const EcalMGPAGainRatio* aGain,
2525
const FullSampleVector& fullpulse,
2626
const float targetTimePrecision,
27-
const bool correctForOOT = true) const;
27+
const bool correctForOOT = true,
28+
const bool correctForSlew = true) const;
2829

2930
private:
3031
const float startTime_;
@@ -38,7 +39,10 @@ class EcalUncalibRecHitTimingCCAlgo {
3839
static constexpr float ONE_MINUS_GOLDEN_RATIO = 1.0 - GOLDEN_RATIO;
3940

4041
FullSampleVector interpolatePulse(const FullSampleVector& fullpulse, const float t = 0) const;
41-
float computeCC(const std::vector<float>& samples, const FullSampleVector& sigmalTemplate, const float t) const;
42+
float computeCC(const std::vector<float>& samples,
43+
const std::vector<float>& weights,
44+
const FullSampleVector& sigmalTemplate,
45+
const float t) const;
4246
};
4347

4448
#endif

RecoLocalCalo/EcalRecAlgos/src/EcalUncalibRecHitTimingCCAlgo.cc

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

146157
float 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);

RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ class EcalUncalibRecHitWorkerMultiFit final : public EcalUncalibRecHitWorkerBase
169169
double CCTimeShiftWrtRations_;
170170
double CCtargetTimePrecision_;
171171
double CCtargetTimePrecisionForDelayedPulses_;
172+
bool crossCorrelationUseSlewCorrectionEB_;
173+
bool crossCorrelationUseSlewCorrectionEE_;
172174
};
173175

174176
EcalUncalibRecHitWorkerMultiFit::EcalUncalibRecHitWorkerMultiFit(const edm::ParameterSet& ps, edm::ConsumesCollector& c)
@@ -238,11 +240,13 @@ EcalUncalibRecHitWorkerMultiFit::EcalUncalibRecHitWorkerMultiFit(const edm::Para
238240
CCminTimeToBeLateMin_ = ps.getParameter<double>("crossCorrelationMinTimeToBeLateMin") / ecalcctiming::clockToNS;
239241
CCminTimeToBeLateMax_ = ps.getParameter<double>("crossCorrelationMinTimeToBeLateMax") / ecalcctiming::clockToNS;
240242
CCTimeShiftWrtRations_ = ps.getParameter<double>("crossCorrelationTimeShiftWrtRations");
243+
crossCorrelationUseSlewCorrectionEB_ = ps.getParameter<bool>("crossCorrelationUseSlewCorrectionEB");
244+
crossCorrelationUseSlewCorrectionEE_ = ps.getParameter<bool>("crossCorrelationUseSlewCorrectionEE");
241245
computeCC_ = std::make_unique<EcalUncalibRecHitTimingCCAlgo>(startTime, stopTime);
242246
} else if (timeAlgoName != "None")
243247
edm::LogError("EcalUncalibRecHitError") << "No time estimation algorithm defined";
244248

245-
// ratio method parameters
249+
// time reco parameters
246250
EBtimeFitParameters_ = ps.getParameter<std::vector<double>>("EBtimeFitParameters");
247251
EEtimeFitParameters_ = ps.getParameter<std::vector<double>>("EEtimeFitParameters");
248252
EBamplitudeFitParameters_ = ps.getParameter<std::vector<double>>("EBamplitudeFitParameters");
@@ -640,13 +644,21 @@ void EcalUncalibRecHitWorkerMultiFit::run(const edm::Event& evt,
640644
for (unsigned int ibx = 0; ibx < activeBX.size(); ++ibx)
641645
amplitudes[ibx] = uncalibRecHit.outOfTimeAmplitude(ibx);
642646

643-
float jitter =
644-
computeCC_->computeTimeCC(*itdg, amplitudes, aped, aGain, fullpulse, CCtargetTimePrecision_, true) +
645-
CCTimeShiftWrtRations_ / ecalcctiming::clockToNS;
646-
float noCorrectedJitter =
647-
computeCC_->computeTimeCC(
648-
*itdg, amplitudes, aped, aGain, fullpulse, CCtargetTimePrecisionForDelayedPulses_, false) +
649-
CCTimeShiftWrtRations_ / ecalcctiming::clockToNS;
647+
bool const doSlewCorrection =
648+
barrel ? crossCorrelationUseSlewCorrectionEB_ : crossCorrelationUseSlewCorrectionEE_;
649+
650+
float jitter = computeCC_->computeTimeCC(
651+
*itdg, amplitudes, aped, aGain, fullpulse, CCtargetTimePrecision_, true, doSlewCorrection) +
652+
CCTimeShiftWrtRations_ / ecalcctiming::clockToNS;
653+
float noCorrectedJitter = computeCC_->computeTimeCC(*itdg,
654+
amplitudes,
655+
aped,
656+
aGain,
657+
fullpulse,
658+
CCtargetTimePrecisionForDelayedPulses_,
659+
false,
660+
doSlewCorrection) +
661+
CCTimeShiftWrtRations_ / ecalcctiming::clockToNS;
650662

651663
uncalibRecHit.setJitter(jitter);
652664
uncalibRecHit.setNonCorrectedTime(jitter, noCorrectedJitter);
@@ -783,6 +795,8 @@ edm::ParameterSetDescription EcalUncalibRecHitWorkerMultiFit::getAlgoDescription
783795
edm::ParameterDescription<double>("outOfTimeThresholdGain61mEE", 1000, true) and
784796
edm::ParameterDescription<double>("amplitudeThresholdEB", 10, true) and
785797
edm::ParameterDescription<double>("amplitudeThresholdEE", 10, true) and
798+
edm::ParameterDescription<bool>("crossCorrelationUseSlewCorrectionEB", true, true) and
799+
edm::ParameterDescription<bool>("crossCorrelationUseSlewCorrectionEE", false, true) and
786800
edm::ParameterDescription<double>("crossCorrelationStartTime", -25.0, true) and
787801
edm::ParameterDescription<double>("crossCorrelationStopTime", 25.0, true) and
788802
edm::ParameterDescription<double>("crossCorrelationTargetTimePrecision", 0.01, true) and

0 commit comments

Comments
 (0)