From 05ff7e4fd18fb14625aca50d550fb267e2438cd6 Mon Sep 17 00:00:00 2001 From: Tom Eichlersmith <31970302+tomeichlersmith@users.noreply.github.com> Date: Fri, 20 Sep 2024 08:56:26 -0500 Subject: [PATCH] dont use a float as a for-loop counter replace this with a while loop instead to be more clear about the possibility of rounding errors affecting performance --- TrigScint/src/TrigScint/SimQIE.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/TrigScint/src/TrigScint/SimQIE.cxx b/TrigScint/src/TrigScint/SimQIE.cxx index d6179ca75..ab21920e5 100644 --- a/TrigScint/src/TrigScint/SimQIE.cxx +++ b/TrigScint/src/TrigScint/SimQIE.cxx @@ -100,8 +100,10 @@ std::vector SimQIE::Out_ADC(QIEInputPulse* pp) { int SimQIE::TDC(QIEInputPulse* pp, float T0 = 0) { float thr2 = tdc_thr_ / gain_; if (pp->Eval(T0) > thr2) return 62; // when pulse starts high - for (float tt = T0; tt < T0 + tau_; tt += 0.1) { + float tt = T0; + while (tt < T0 + tau_) { if (pp->Eval(tt) >= thr2) return ((int)(2 * (tt - T0))); + tt += 0.1; } return 63; // when pulse remains low all along }