Skip to content

Commit

Permalink
dont use a float as a for-loop counter
Browse files Browse the repository at this point in the history
replace this with a while loop instead to be more clear about the possibility of rounding errors affecting performance
  • Loading branch information
tomeichlersmith committed Sep 20, 2024
1 parent 6c08a49 commit 05ff7e4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion TrigScint/src/TrigScint/SimQIE.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ std::vector<int> 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
}
Expand Down

0 comments on commit 05ff7e4

Please sign in to comment.