From dfeab665fdd70f06c78174ecba9279ccba94faa6 Mon Sep 17 00:00:00 2001 From: Andre Sailer <andre.philippe.sailer@cern.ch> Date: Tue, 9 Aug 2022 13:59:13 +0200 Subject: [PATCH] DDG4.Gun: set momentumMin to 0 for default, still check None --- DDG4/python/DDSim/Helper/Gun.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/DDG4/python/DDSim/Helper/Gun.py b/DDG4/python/DDSim/Helper/Gun.py index 97b35cdfd..8424e0718 100644 --- a/DDG4/python/DDSim/Helper/Gun.py +++ b/DDG4/python/DDSim/Helper/Gun.py @@ -26,7 +26,7 @@ class Gun(ConfigHelper): self.thetaMin = None self.thetaMax = None self._momentumMin_EXTRA = {'help': "Minimal momentum when using distribution (default = 0.0)"} - self.momentumMin = None + self.momentumMin = 0 * GeV self._momentumMax_EXTRA = {'help': "Maximal momentum when using distribution (default = 0.0)"} self.momentumMax = 10 * GeV self._energy_EXTRA = {'help': "The kinetic energy for the particle gun.\n\n" @@ -137,9 +137,8 @@ class Gun(ConfigHelper): if self.phiMax is not None: ddg4Gun.PhiMax = self.phiMax ddg4Gun.isotrop = True - ddg4Gun.MomentumMin = 0.0 - if self.momentumMin is not None: - ddg4Gun.MomentumMin = self.momentumMin + # this avoids issues if momentumMin is None because of previous default + ddg4Gun.MomentumMin = self.momentumMin if self.momentumMin else 0.0 ddg4Gun.MomentumMax = self.momentumMax except Exception as e: # pylint: disable=W0703 logger.error("parsing gun options:\n%s\nException: %s " % (self, e)) -- GitLab