From bb21a09721cf8ff0253ae9afdd8889735be6948f Mon Sep 17 00:00:00 2001 From: Jack King Date: Fri, 5 Jul 2024 04:53:52 -0500 Subject: [PATCH 1/5] Slew Correction fo CC + parameters to use this correction in EB &/or EE --- .../interface/EcalUncalibRecHitTimingCCAlgo.h | 5 ++- .../src/EcalUncalibRecHitTimingCCAlgo.cc | 43 ++++++++++++------- .../EcalUncalibRecHitWorkerMultiFit.cc | 21 ++++++--- .../python/ecalMultiFitUncalibRecHit_cfi.py | 2 + 4 files changed, 48 insertions(+), 23 deletions(-) diff --git a/RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitTimingCCAlgo.h b/RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitTimingCCAlgo.h index 6ea638dc9e32a..5e606d6953260 100644 --- a/RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitTimingCCAlgo.h +++ b/RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitTimingCCAlgo.h @@ -24,7 +24,8 @@ class EcalUncalibRecHitTimingCCAlgo { const EcalMGPAGainRatio* aGain, const FullSampleVector& fullpulse, const float targetTimePrecision, - const bool correctForOOT = true) const; + const bool correctForOOT = true, + const bool correctForSlew = true ) const; private: const float startTime_; @@ -38,7 +39,7 @@ class EcalUncalibRecHitTimingCCAlgo { static constexpr float ONE_MINUS_GOLDEN_RATIO = 1.0 - GOLDEN_RATIO; FullSampleVector interpolatePulse(const FullSampleVector& fullpulse, const float t = 0) const; - float computeCC(const std::vector& samples, const FullSampleVector& sigmalTemplate, const float t) const; + float computeCC(const std::vector& samples, const std::vector& weights, const FullSampleVector& sigmalTemplate, const float t) const; }; #endif diff --git a/RecoLocalCalo/EcalRecAlgos/src/EcalUncalibRecHitTimingCCAlgo.cc b/RecoLocalCalo/EcalRecAlgos/src/EcalUncalibRecHitTimingCCAlgo.cc index 9b8d8e500fe76..0bd1ebafc5cc8 100644 --- a/RecoLocalCalo/EcalRecAlgos/src/EcalUncalibRecHitTimingCCAlgo.cc +++ b/RecoLocalCalo/EcalRecAlgos/src/EcalUncalibRecHitTimingCCAlgo.cc @@ -9,13 +9,19 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra const EcalMGPAGainRatio* aGain, const FullSampleVector& fullpulse, const float targetTimePrecision, - const bool correctForOOT) const { + const bool correctForOOT, + const bool correctForSlew ) const { + constexpr unsigned int nsample = EcalDataFrame::MAXSAMPLES; double maxamplitude = -std::numeric_limits::max(); float pulsenorm = 0.; + bool doOOTAmpCorrection(correctForOOT); std::vector pedSubSamples(nsample); + std::vector weights(nsample,1.f); + float minADC = (dataFrame.sample(0)).adc(); + for (unsigned int iSample = 1; iSample < nsample; iSample++) { if( (dataFrame.sample(iSample)).adc() < minADC ) minADC = (dataFrame.sample(iSample)).adc(); } for (unsigned int iSample = 0; iSample < nsample; iSample++) { const EcalMGPASample& sample = dataFrame.sample(iSample); @@ -48,10 +54,17 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra if (amplitude > maxamplitude) { maxamplitude = amplitude; } - pulsenorm += fullpulse(iSample); + + if( iSample > 0 && correctForSlew ){ + int GainIdPrev = dataFrame.sample(iSample - 1).gainId(); + bool GainIdInRange = GainIdPrev >= 1 && GainIdPrev <= 3 && gainId >= 1 && gainId <= 3; + bool GainSlew = GainIdPrev < gainId; + if( GainIdInRange && GainSlew ) weights[iSample - 1] = 0.f; + } + } - if (correctForOOT) { + if( doOOTAmpCorrection ){ int ipulse = -1; for (auto const& amplit : amplitudes) { ipulse++; @@ -61,7 +74,7 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra for (unsigned int isample = firstsamplet; isample < nsample; ++isample) { auto const pulse = fullpulse(isample + offset); - pedSubSamples[isample] = std::max(0., pedSubSamples[isample] - amplit * pulse / pulsenorm); + pedSubSamples[isample] = pedSubSamples[isample] - ( amplit * pulse / pulsenorm ); } } } @@ -74,9 +87,9 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra int counter = 0; - float cc1 = computeCC(pedSubSamples, fullpulse, t1); + float cc1 = computeCC(pedSubSamples, weights, fullpulse, t1); ++counter; - float cc2 = computeCC(pedSubSamples, fullpulse, t2); + float cc2 = computeCC(pedSubSamples, weights, fullpulse, t2); ++counter; while (std::abs(t3 - t0) > targetTimePrecision && counter < MAX_NUM_OF_ITERATIONS) { @@ -85,23 +98,22 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra t1 = t2; t2 = GOLDEN_RATIO * t2 + ONE_MINUS_GOLDEN_RATIO * t3; cc1 = cc2; - cc2 = computeCC(pedSubSamples, fullpulse, t2); + cc2 = computeCC(pedSubSamples, weights, fullpulse, t2); ++counter; } else { t3 = t2; t2 = t1; t1 = GOLDEN_RATIO * t1 + ONE_MINUS_GOLDEN_RATIO * t0; cc2 = cc1; - cc1 = computeCC(pedSubSamples, fullpulse, t1); + cc1 = computeCC(pedSubSamples, weights, fullpulse, t1); ++counter; } } float tM = (t3 + t0) / 2 - GLOBAL_TIME_SHIFT; - if (counter < MIN_NUM_OF_ITERATIONS || counter > MAX_NUM_OF_ITERATIONS - 1) { - tM = TIME_WHEN_NOT_CONVERGING * ecalPh1::Samp_Period; - } - return -tM / ecalPh1::Samp_Period; + if (counter < MIN_NUM_OF_ITERATIONS || counter > MAX_NUM_OF_ITERATIONS - 1) { tM = TIME_WHEN_NOT_CONVERGING * ecalPh1::Samp_Period; } + float cct = -tM / ecalPh1::Samp_Period; + return cct; } FullSampleVector EcalUncalibRecHitTimingCCAlgo::interpolatePulse(const FullSampleVector& fullpulse, @@ -144,6 +156,7 @@ FullSampleVector EcalUncalibRecHitTimingCCAlgo::interpolatePulse(const FullSampl } float EcalUncalibRecHitTimingCCAlgo::computeCC(const std::vector& samples, + const std::vector& weights, const FullSampleVector& signalTemplate, const float time) const { constexpr int exclude = 1; @@ -152,9 +165,9 @@ float EcalUncalibRecHitTimingCCAlgo::computeCC(const std::vector& samples float cc = 0.; auto interpolated = interpolatePulse(signalTemplate, time); for (int i = exclude; i < int(samples.size() - exclude); ++i) { - powerSamples += std::pow(samples[i], 2); - powerTemplate += std::pow(interpolated[i], 2); - cc += interpolated[i] * samples[i]; + powerSamples += std::pow(samples[i], 2) * weights[i]; + powerTemplate += std::pow(interpolated[i], 2) * weights[i]; + cc += interpolated[i] * samples[i] * weights[i]; } float denominator = std::sqrt(powerTemplate * powerSamples); diff --git a/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc b/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc index 39753547ee7ca..5640fec8b1a0b 100644 --- a/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc +++ b/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc @@ -169,6 +169,8 @@ class EcalUncalibRecHitWorkerMultiFit final : public EcalUncalibRecHitWorkerBase double CCTimeShiftWrtRations_; double CCtargetTimePrecision_; double CCtargetTimePrecisionForDelayedPulses_; + bool useSlewCorrectionEB_; + bool useSlewCorrectionEE_; }; EcalUncalibRecHitWorkerMultiFit::EcalUncalibRecHitWorkerMultiFit(const edm::ParameterSet& ps, edm::ConsumesCollector& c) @@ -238,11 +240,13 @@ EcalUncalibRecHitWorkerMultiFit::EcalUncalibRecHitWorkerMultiFit(const edm::Para CCminTimeToBeLateMin_ = ps.getParameter("crossCorrelationMinTimeToBeLateMin") / ecalcctiming::clockToNS; CCminTimeToBeLateMax_ = ps.getParameter("crossCorrelationMinTimeToBeLateMax") / ecalcctiming::clockToNS; CCTimeShiftWrtRations_ = ps.getParameter("crossCorrelationTimeShiftWrtRations"); + useSlewCorrectionEB_ = ps.getParameter("useSlewCorrectionEB"); + useSlewCorrectionEE_ = ps.getParameter("useSlewCorrectionEE"); computeCC_ = std::make_unique(startTime, stopTime); } else if (timeAlgoName != "None") edm::LogError("EcalUncalibRecHitError") << "No time estimation algorithm defined"; - // ratio method parameters + // time reco parameters EBtimeFitParameters_ = ps.getParameter>("EBtimeFitParameters"); EEtimeFitParameters_ = ps.getParameter>("EEtimeFitParameters"); EBamplitudeFitParameters_ = ps.getParameter>("EBamplitudeFitParameters"); @@ -518,6 +522,7 @@ void EcalUncalibRecHitWorkerMultiFit::run(const edm::Event& evt, // === time computation === if (timealgo_ == ratioMethod) { // ratio method + //std::cout << " Using Ratio method !!!!!!!!!!! " << std::endl; constexpr float clockToNsConstant = 25.; constexpr float invClockToNs = 1. / clockToNsConstant; if (not barrel) { @@ -636,16 +641,18 @@ void EcalUncalibRecHitWorkerMultiFit::run(const edm::Event& evt, uncalibRecHit.setJitterError(0.); // not computed with weights } else if (timealgo_ == crossCorrelationMethod) { + std::vector amplitudes(activeBX.size()); for (unsigned int ibx = 0; ibx < activeBX.size(); ++ibx) amplitudes[ibx] = uncalibRecHit.outOfTimeAmplitude(ibx); + bool const doSlewCorrection = barrel ? useSlewCorrectionEB_ : useSlewCorrectionEE_; + float jitter = - computeCC_->computeTimeCC(*itdg, amplitudes, aped, aGain, fullpulse, CCtargetTimePrecision_, true) + + computeCC_->computeTimeCC(*itdg, amplitudes, aped, aGain, fullpulse, CCtargetTimePrecision_, true, doSlewCorrection ) + CCTimeShiftWrtRations_ / ecalcctiming::clockToNS; float noCorrectedJitter = - computeCC_->computeTimeCC( - *itdg, amplitudes, aped, aGain, fullpulse, CCtargetTimePrecisionForDelayedPulses_, false) + + computeCC_->computeTimeCC(*itdg, amplitudes, aped, aGain, fullpulse, CCtargetTimePrecisionForDelayedPulses_, false, doSlewCorrection ) + CCTimeShiftWrtRations_ / ecalcctiming::clockToNS; uncalibRecHit.setJitter(jitter); @@ -763,8 +770,8 @@ edm::ParameterSetDescription EcalUncalibRecHitWorkerMultiFit::getAlgoDescription true) and edm::ParameterDescription>("EBamplitudeFitParameters", {1.138, 1.652}, true) and edm::ParameterDescription>("EEamplitudeFitParameters", {1.890, 1.400}, true) and - edm::ParameterDescription("timeCalibTag", edm::ESInputTag(), true) and - edm::ParameterDescription("timeOffsetTag", edm::ESInputTag(), true) and + edm::ParameterDescription("timeCalibTag", edm::ESInputTag(":CC"), true) and + edm::ParameterDescription("timeOffsetTag", edm::ESInputTag(":CC"), true) and edm::ParameterDescription("EBtimeFitLimits_Lower", 0.2, true) and edm::ParameterDescription("EBtimeFitLimits_Upper", 1.4, true) and edm::ParameterDescription("EEtimeFitLimits_Lower", 0.2, true) and @@ -783,6 +790,8 @@ edm::ParameterSetDescription EcalUncalibRecHitWorkerMultiFit::getAlgoDescription edm::ParameterDescription("outOfTimeThresholdGain61mEE", 1000, true) and edm::ParameterDescription("amplitudeThresholdEB", 10, true) and edm::ParameterDescription("amplitudeThresholdEE", 10, true) and + edm::ParameterDescription("useSlewCorrectionEB", true, true) and + edm::ParameterDescription("useSlewCorrectionEE", false, true) and edm::ParameterDescription("crossCorrelationStartTime", -25.0, true) and edm::ParameterDescription("crossCorrelationStopTime", 25.0, true) and edm::ParameterDescription("crossCorrelationTargetTimePrecision", 0.01, true) and diff --git a/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_cfi.py b/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_cfi.py index 2cacce93ce879..cb33201fb7c0f 100644 --- a/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_cfi.py +++ b/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_cfi.py @@ -14,6 +14,8 @@ outOfTimeThresholdGain12mEB = 3.0, outOfTimeThresholdGain61pEB = 3.0, outOfTimeThresholdGain61mEB = 3.0, + useSlewCorrectionEB = True, + useSlewCorrectionEE = False, timeCalibTag = ':CC', timeOffsetTag = ':CC' ) From 173f02cf920a489bee6e101468192dbdaeed7bb8 Mon Sep 17 00:00:00 2001 From: Jack King Date: Fri, 5 Jul 2024 05:28:20 -0500 Subject: [PATCH 2/5] Slew Correction fo CC + parameters to use this correction in EB &/or EE v2 --- .../EcalRecAlgos/src/EcalUncalibRecHitTimingCCAlgo.cc | 10 ++++------ .../plugins/EcalUncalibRecHitWorkerMultiFit.cc | 5 ++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/RecoLocalCalo/EcalRecAlgos/src/EcalUncalibRecHitTimingCCAlgo.cc b/RecoLocalCalo/EcalRecAlgos/src/EcalUncalibRecHitTimingCCAlgo.cc index 0bd1ebafc5cc8..922cce5e5a6d5 100644 --- a/RecoLocalCalo/EcalRecAlgos/src/EcalUncalibRecHitTimingCCAlgo.cc +++ b/RecoLocalCalo/EcalRecAlgos/src/EcalUncalibRecHitTimingCCAlgo.cc @@ -17,11 +17,8 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra double maxamplitude = -std::numeric_limits::max(); float pulsenorm = 0.; - bool doOOTAmpCorrection(correctForOOT); std::vector pedSubSamples(nsample); std::vector weights(nsample,1.f); - float minADC = (dataFrame.sample(0)).adc(); - for (unsigned int iSample = 1; iSample < nsample; iSample++) { if( (dataFrame.sample(iSample)).adc() < minADC ) minADC = (dataFrame.sample(iSample)).adc(); } for (unsigned int iSample = 0; iSample < nsample; iSample++) { const EcalMGPASample& sample = dataFrame.sample(iSample); @@ -51,6 +48,8 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra pedSubSamples[iSample] = amplitude; + pulsenorm += fullpulse(iSample); + if (amplitude > maxamplitude) { maxamplitude = amplitude; } @@ -64,7 +63,7 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra } - if( doOOTAmpCorrection ){ + if( correctForOOT ){ int ipulse = -1; for (auto const& amplit : amplitudes) { ipulse++; @@ -112,8 +111,7 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra float tM = (t3 + t0) / 2 - GLOBAL_TIME_SHIFT; if (counter < MIN_NUM_OF_ITERATIONS || counter > MAX_NUM_OF_ITERATIONS - 1) { tM = TIME_WHEN_NOT_CONVERGING * ecalPh1::Samp_Period; } - float cct = -tM / ecalPh1::Samp_Period; - return cct; + return -tM / ecalPh1::Samp_Period; } FullSampleVector EcalUncalibRecHitTimingCCAlgo::interpolatePulse(const FullSampleVector& fullpulse, diff --git a/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc b/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc index 5640fec8b1a0b..a2cefe6c755b4 100644 --- a/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc +++ b/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc @@ -522,7 +522,6 @@ void EcalUncalibRecHitWorkerMultiFit::run(const edm::Event& evt, // === time computation === if (timealgo_ == ratioMethod) { // ratio method - //std::cout << " Using Ratio method !!!!!!!!!!! " << std::endl; constexpr float clockToNsConstant = 25.; constexpr float invClockToNs = 1. / clockToNsConstant; if (not barrel) { @@ -770,8 +769,8 @@ edm::ParameterSetDescription EcalUncalibRecHitWorkerMultiFit::getAlgoDescription true) and edm::ParameterDescription>("EBamplitudeFitParameters", {1.138, 1.652}, true) and edm::ParameterDescription>("EEamplitudeFitParameters", {1.890, 1.400}, true) and - edm::ParameterDescription("timeCalibTag", edm::ESInputTag(":CC"), true) and - edm::ParameterDescription("timeOffsetTag", edm::ESInputTag(":CC"), true) and + edm::ParameterDescription("timeCalibTag", edm::ESInputTag(), true) and + edm::ParameterDescription("timeOffsetTag", edm::ESInputTag(), true) and edm::ParameterDescription("EBtimeFitLimits_Lower", 0.2, true) and edm::ParameterDescription("EBtimeFitLimits_Upper", 1.4, true) and edm::ParameterDescription("EEtimeFitLimits_Lower", 0.2, true) and From 22924d4097151317f948d19925591fc6e0de13ad Mon Sep 17 00:00:00 2001 From: Jack King Date: Fri, 5 Jul 2024 05:44:20 -0500 Subject: [PATCH 3/5] Applied code style and quality patch https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-45386/40835/code-format.patch --- .../interface/EcalUncalibRecHitTimingCCAlgo.h | 7 +++-- .../src/EcalUncalibRecHitTimingCCAlgo.cc | 29 ++++++++++--------- .../EcalUncalibRecHitWorkerMultiFit.cc | 23 +++++++++------ 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitTimingCCAlgo.h b/RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitTimingCCAlgo.h index 5e606d6953260..b31cb866280ad 100644 --- a/RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitTimingCCAlgo.h +++ b/RecoLocalCalo/EcalRecAlgos/interface/EcalUncalibRecHitTimingCCAlgo.h @@ -25,7 +25,7 @@ class EcalUncalibRecHitTimingCCAlgo { const FullSampleVector& fullpulse, const float targetTimePrecision, const bool correctForOOT = true, - const bool correctForSlew = true ) const; + const bool correctForSlew = true) const; private: const float startTime_; @@ -39,7 +39,10 @@ class EcalUncalibRecHitTimingCCAlgo { static constexpr float ONE_MINUS_GOLDEN_RATIO = 1.0 - GOLDEN_RATIO; FullSampleVector interpolatePulse(const FullSampleVector& fullpulse, const float t = 0) const; - float computeCC(const std::vector& samples, const std::vector& weights, const FullSampleVector& sigmalTemplate, const float t) const; + float computeCC(const std::vector& samples, + const std::vector& weights, + const FullSampleVector& sigmalTemplate, + const float t) const; }; #endif diff --git a/RecoLocalCalo/EcalRecAlgos/src/EcalUncalibRecHitTimingCCAlgo.cc b/RecoLocalCalo/EcalRecAlgos/src/EcalUncalibRecHitTimingCCAlgo.cc index 922cce5e5a6d5..aa489ce64e56d 100644 --- a/RecoLocalCalo/EcalRecAlgos/src/EcalUncalibRecHitTimingCCAlgo.cc +++ b/RecoLocalCalo/EcalRecAlgos/src/EcalUncalibRecHitTimingCCAlgo.cc @@ -10,15 +10,14 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra const FullSampleVector& fullpulse, const float targetTimePrecision, const bool correctForOOT, - const bool correctForSlew ) const { - + const bool correctForSlew) const { constexpr unsigned int nsample = EcalDataFrame::MAXSAMPLES; double maxamplitude = -std::numeric_limits::max(); float pulsenorm = 0.; std::vector pedSubSamples(nsample); - std::vector weights(nsample,1.f); + std::vector weights(nsample, 1.f); for (unsigned int iSample = 0; iSample < nsample; iSample++) { const EcalMGPASample& sample = dataFrame.sample(iSample); @@ -54,16 +53,16 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra maxamplitude = amplitude; } - if( iSample > 0 && correctForSlew ){ - int GainIdPrev = dataFrame.sample(iSample - 1).gainId(); - bool GainIdInRange = GainIdPrev >= 1 && GainIdPrev <= 3 && gainId >= 1 && gainId <= 3; - bool GainSlew = GainIdPrev < gainId; - if( GainIdInRange && GainSlew ) weights[iSample - 1] = 0.f; - } - + if (iSample > 0 && correctForSlew) { + int GainIdPrev = dataFrame.sample(iSample - 1).gainId(); + bool GainIdInRange = GainIdPrev >= 1 && GainIdPrev <= 3 && gainId >= 1 && gainId <= 3; + bool GainSlew = GainIdPrev < gainId; + if (GainIdInRange && GainSlew) + weights[iSample - 1] = 0.f; + } } - if( correctForOOT ){ + if (correctForOOT) { int ipulse = -1; for (auto const& amplit : amplitudes) { ipulse++; @@ -73,7 +72,7 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra for (unsigned int isample = firstsamplet; isample < nsample; ++isample) { auto const pulse = fullpulse(isample + offset); - pedSubSamples[isample] = pedSubSamples[isample] - ( amplit * pulse / pulsenorm ); + pedSubSamples[isample] = pedSubSamples[isample] - (amplit * pulse / pulsenorm); } } } @@ -110,7 +109,9 @@ double EcalUncalibRecHitTimingCCAlgo::computeTimeCC(const EcalDataFrame& dataFra } float tM = (t3 + t0) / 2 - GLOBAL_TIME_SHIFT; - if (counter < MIN_NUM_OF_ITERATIONS || counter > MAX_NUM_OF_ITERATIONS - 1) { tM = TIME_WHEN_NOT_CONVERGING * ecalPh1::Samp_Period; } + if (counter < MIN_NUM_OF_ITERATIONS || counter > MAX_NUM_OF_ITERATIONS - 1) { + tM = TIME_WHEN_NOT_CONVERGING * ecalPh1::Samp_Period; + } return -tM / ecalPh1::Samp_Period; } @@ -154,7 +155,7 @@ FullSampleVector EcalUncalibRecHitTimingCCAlgo::interpolatePulse(const FullSampl } float EcalUncalibRecHitTimingCCAlgo::computeCC(const std::vector& samples, - const std::vector& weights, + const std::vector& weights, const FullSampleVector& signalTemplate, const float time) const { constexpr int exclude = 1; diff --git a/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc b/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc index a2cefe6c755b4..6e91bcdbd2279 100644 --- a/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc +++ b/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc @@ -640,19 +640,24 @@ void EcalUncalibRecHitWorkerMultiFit::run(const edm::Event& evt, uncalibRecHit.setJitterError(0.); // not computed with weights } else if (timealgo_ == crossCorrelationMethod) { - std::vector amplitudes(activeBX.size()); for (unsigned int ibx = 0; ibx < activeBX.size(); ++ibx) amplitudes[ibx] = uncalibRecHit.outOfTimeAmplitude(ibx); - bool const doSlewCorrection = barrel ? useSlewCorrectionEB_ : useSlewCorrectionEE_; - - float jitter = - computeCC_->computeTimeCC(*itdg, amplitudes, aped, aGain, fullpulse, CCtargetTimePrecision_, true, doSlewCorrection ) + - CCTimeShiftWrtRations_ / ecalcctiming::clockToNS; - float noCorrectedJitter = - computeCC_->computeTimeCC(*itdg, amplitudes, aped, aGain, fullpulse, CCtargetTimePrecisionForDelayedPulses_, false, doSlewCorrection ) + - CCTimeShiftWrtRations_ / ecalcctiming::clockToNS; + bool const doSlewCorrection = barrel ? useSlewCorrectionEB_ : useSlewCorrectionEE_; + + float jitter = computeCC_->computeTimeCC( + *itdg, amplitudes, aped, aGain, fullpulse, CCtargetTimePrecision_, true, doSlewCorrection) + + CCTimeShiftWrtRations_ / ecalcctiming::clockToNS; + float noCorrectedJitter = computeCC_->computeTimeCC(*itdg, + amplitudes, + aped, + aGain, + fullpulse, + CCtargetTimePrecisionForDelayedPulses_, + false, + doSlewCorrection) + + CCTimeShiftWrtRations_ / ecalcctiming::clockToNS; uncalibRecHit.setJitter(jitter); uncalibRecHit.setNonCorrectedTime(jitter, noCorrectedJitter); From 134859375abb8d472d7861ee4bde46c3db3ab584 Mon Sep 17 00:00:00 2001 From: Jack King Date: Fri, 5 Jul 2024 07:39:45 -0500 Subject: [PATCH 4/5] Removed useSlewCorrection parameters from ecalMultiFitUncalibRecHit_cfi.py, Changed name of slew correction paramters in EcalUncalibRecHitWorkerMultiFit.cc --- .../plugins/EcalUncalibRecHitWorkerMultiFit.cc | 14 +++++++------- .../python/ecalMultiFitUncalibRecHit_cfi.py | 2 -- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc b/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc index 6e91bcdbd2279..35a49fe30c016 100644 --- a/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc +++ b/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc @@ -169,8 +169,8 @@ class EcalUncalibRecHitWorkerMultiFit final : public EcalUncalibRecHitWorkerBase double CCTimeShiftWrtRations_; double CCtargetTimePrecision_; double CCtargetTimePrecisionForDelayedPulses_; - bool useSlewCorrectionEB_; - bool useSlewCorrectionEE_; + bool crossCorrelationUseSlewCorrectionEB_; + bool crossCorrelationUseSlewCorrectionEE_; }; EcalUncalibRecHitWorkerMultiFit::EcalUncalibRecHitWorkerMultiFit(const edm::ParameterSet& ps, edm::ConsumesCollector& c) @@ -240,8 +240,8 @@ EcalUncalibRecHitWorkerMultiFit::EcalUncalibRecHitWorkerMultiFit(const edm::Para CCminTimeToBeLateMin_ = ps.getParameter("crossCorrelationMinTimeToBeLateMin") / ecalcctiming::clockToNS; CCminTimeToBeLateMax_ = ps.getParameter("crossCorrelationMinTimeToBeLateMax") / ecalcctiming::clockToNS; CCTimeShiftWrtRations_ = ps.getParameter("crossCorrelationTimeShiftWrtRations"); - useSlewCorrectionEB_ = ps.getParameter("useSlewCorrectionEB"); - useSlewCorrectionEE_ = ps.getParameter("useSlewCorrectionEE"); + crossCorrelationUseSlewCorrectionEB_ = ps.getParameter("crossCorrelationUseSlewCorrectionEB"); + crossCorrelationUseSlewCorrectionEE_ = ps.getParameter("crossCorrelationUseSlewCorrectionEE"); computeCC_ = std::make_unique(startTime, stopTime); } else if (timeAlgoName != "None") edm::LogError("EcalUncalibRecHitError") << "No time estimation algorithm defined"; @@ -644,7 +644,7 @@ void EcalUncalibRecHitWorkerMultiFit::run(const edm::Event& evt, for (unsigned int ibx = 0; ibx < activeBX.size(); ++ibx) amplitudes[ibx] = uncalibRecHit.outOfTimeAmplitude(ibx); - bool const doSlewCorrection = barrel ? useSlewCorrectionEB_ : useSlewCorrectionEE_; + bool const doSlewCorrection = barrel ? crossCorrelationUseSlewCorrectionEB_ : crossCorrelationUseSlewCorrectionEE_; float jitter = computeCC_->computeTimeCC( *itdg, amplitudes, aped, aGain, fullpulse, CCtargetTimePrecision_, true, doSlewCorrection) + @@ -794,8 +794,8 @@ edm::ParameterSetDescription EcalUncalibRecHitWorkerMultiFit::getAlgoDescription edm::ParameterDescription("outOfTimeThresholdGain61mEE", 1000, true) and edm::ParameterDescription("amplitudeThresholdEB", 10, true) and edm::ParameterDescription("amplitudeThresholdEE", 10, true) and - edm::ParameterDescription("useSlewCorrectionEB", true, true) and - edm::ParameterDescription("useSlewCorrectionEE", false, true) and + edm::ParameterDescription("crossCorrelationUseSlewCorrectionEB", true, true) and + edm::ParameterDescription("crossCorrelationUseSlewCorrectionEE", false, true) and edm::ParameterDescription("crossCorrelationStartTime", -25.0, true) and edm::ParameterDescription("crossCorrelationStopTime", 25.0, true) and edm::ParameterDescription("crossCorrelationTargetTimePrecision", 0.01, true) and diff --git a/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_cfi.py b/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_cfi.py index cb33201fb7c0f..2cacce93ce879 100644 --- a/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_cfi.py +++ b/RecoLocalCalo/EcalRecProducers/python/ecalMultiFitUncalibRecHit_cfi.py @@ -14,8 +14,6 @@ outOfTimeThresholdGain12mEB = 3.0, outOfTimeThresholdGain61pEB = 3.0, outOfTimeThresholdGain61mEB = 3.0, - useSlewCorrectionEB = True, - useSlewCorrectionEE = False, timeCalibTag = ':CC', timeOffsetTag = ':CC' ) From 15b297b1c6f47c4bc321710d9ca71fecf9898ec2 Mon Sep 17 00:00:00 2001 From: Jack King Date: Fri, 5 Jul 2024 07:54:37 -0500 Subject: [PATCH 5/5] Applied https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-45386/40838/code-format.patch --- .../plugins/EcalUncalibRecHitWorkerMultiFit.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc b/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc index 35a49fe30c016..3bf2f1cd3789e 100644 --- a/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc +++ b/RecoLocalCalo/EcalRecProducers/plugins/EcalUncalibRecHitWorkerMultiFit.cc @@ -644,7 +644,8 @@ void EcalUncalibRecHitWorkerMultiFit::run(const edm::Event& evt, for (unsigned int ibx = 0; ibx < activeBX.size(); ++ibx) amplitudes[ibx] = uncalibRecHit.outOfTimeAmplitude(ibx); - bool const doSlewCorrection = barrel ? crossCorrelationUseSlewCorrectionEB_ : crossCorrelationUseSlewCorrectionEE_; + bool const doSlewCorrection = + barrel ? crossCorrelationUseSlewCorrectionEB_ : crossCorrelationUseSlewCorrectionEE_; float jitter = computeCC_->computeTimeCC( *itdg, amplitudes, aped, aGain, fullpulse, CCtargetTimePrecision_, true, doSlewCorrection) +