From bf16e6317659facd78be6b0a376d22401ba2614c Mon Sep 17 00:00:00 2001 From: Florian Uhlig <f.uhlig@gsi.de> Date: Thu, 4 Jan 2024 15:55:02 +0100 Subject: [PATCH] Fix a precision problem When comapring real numbers for equality one shouldn't compare the difference of both values with zero. Due to rounding effects the result can be slightly differnt from zero. If the difference of the values is smaller than a a small value ( e.g. 0.00001 ) both values are equal. --- sim/detectors/sts/CbmStsSimSensor.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sim/detectors/sts/CbmStsSimSensor.cxx b/sim/detectors/sts/CbmStsSimSensor.cxx index ee4b13f8d9..ac5f9052da 100644 --- a/sim/detectors/sts/CbmStsSimSensor.cxx +++ b/sim/detectors/sts/CbmStsSimSensor.cxx @@ -92,7 +92,7 @@ Int_t CbmStsSimSensor::ProcessPoint(const CbmStsPoint* point, Double_t eventTime Double_t tXav = 0.; Double_t tYav = 0.; // Int_t tZav = 0; - if (z2 - z1 != 0.) { + if (abs(z2 - z1) > 0.000001) { tXav = (x2 - x1) / (z2 - z1); tYav = (y2 - y1) / (z2 - z1); // tZav = 1; -- GitLab