From ace65b25c0d5e8ed782eb19f556ba0374091695b Mon Sep 17 00:00:00 2001
From: Volker Friese <v.friese@gsi.de>
Date: Fri, 21 Jan 2022 16:13:35 +0000
Subject: [PATCH] Protect STS digitizers against unphysical MCPoint times

---
 sim/detectors/sts/CbmStsDigitize.cxx | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/sim/detectors/sts/CbmStsDigitize.cxx b/sim/detectors/sts/CbmStsDigitize.cxx
index 8509a08e1c..f918b05609 100644
--- a/sim/detectors/sts/CbmStsDigitize.cxx
+++ b/sim/detectors/sts/CbmStsDigitize.cxx
@@ -628,6 +628,17 @@ void CbmStsDigitize::ProcessMCEvent()
       }  //? MC track present
     }    //? discard secondaries
 
+    // --- Ignore points with unphysical time
+    // Such instances were observed using Geant4 in the fairsoft jun19 version.
+    // The cut at 1 ms from the event start is somehow arbitrary, but should suit the purpose.
+    // If not cut here, the time range for the StsDigi (2^31 ns) might be exceeded in
+    // flexible time slices or in event-by-event simulation.
+    if (point->GetTime() > 1.e6) {
+      fNofPointsIgno++;
+      continue;
+    }
+
+    // --- Process the StsPoint
     ProcessPoint(point, fCurrentEventTime, link);
     fNofPointsProc++;
     delete link;
-- 
GitLab