From f248ab842abff4ddc979d81f104f1b4e8edb0da6 Mon Sep 17 00:00:00 2001 From: Andre Sailer <andre.philippe.sailer@cern.ch> Date: Thu, 21 Jan 2016 10:30:18 +0000 Subject: [PATCH] DDSim: Add reading of particle.tbl file, needs DD4hep revision 2058 Adapt to the new way the rangeCut is added --- DDSim/Helper/Physics.py | 92 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 83 insertions(+), 9 deletions(-) diff --git a/DDSim/Helper/Physics.py b/DDSim/Helper/Physics.py index 2b1afb833..b1072fa4b 100644 --- a/DDSim/Helper/Physics.py +++ b/DDSim/Helper/Physics.py @@ -1,5 +1,7 @@ """Helper object for physicslist properties""" +import os + from DDSim.Helper.ConfigHelper import ConfigHelper from SystemOfUnits import mm @@ -7,15 +9,87 @@ class Physics( ConfigHelper ): """Configuration for the PhysicsList""" def __init__( self ): super(Physics, self).__init__() - self.rangecut = 0.7*mm + self._rangecut = 0.7*mm self.list ="FTFP_BERT" self.decays = True + self._pdgfile = None + + + @property + def rangecut( self ): + """ The global geant4 rangecut for secondary production + + Default is 0.7 mm as is the case in geant4 10 + + To disable this plugin and be absolutely sure to use the Geant4 default range cut use "None" + + Set printlevel to DEBUG to see a printout of all range cuts, + but this only works if range cut is not "None" + """ + return self._rangecut + @rangecut.setter + def rangecut( self, val ): + if val is None: + self._rangecut = None + return + if isinstance( val, basestring): + if val == "None": + self._rangecut = None + return + self._rangecut = val + + @property + def pdgfile( self ): + """ location of particle.tbl file containing extra particles and their lifetime information + """ + return self._pdgfile + @pdgfile.setter + def pdgfile( self, val ): + if not val: + self._pdgfile = None + return + if not os.path.exists( val ): + raise RuntimeError( "PDGFile: %s not found" % os.path.abspath( val ) ) + self._pdgfile = os.path.abspath( val ) + + + @property + def pdgfile( self ): + """ location of particle.tbl file containing extra particles and their lifetime information + """ + return self._pdgfile + @pdgfile.setter + def pdgfile( self, val ): + if not val: + self._pdgfile = None + return + if not os.path.exists( val ): + raise RuntimeError( "PDGFile: %s not found" % os.path.abspath( val ) ) + self._pdgfile = os.path.abspath( val ) + + def setupPhysics( self, kernel, name=None): + seq = kernel.physicsList() + seq.extends = name if name is not None else self.list + seq.decays = self.decays + seq.enableUI() + seq.dump() + + from DDG4 import PhysicsList + + # Add special particle types from specialized physics constructor + if self.pdgfile: + seq = kernel.physicsList() + part = PhysicsList(kernel, 'Geant4ExtraParticles/ExtraParticles') + part.enableUI() + seq.adopt(part) + part.pdgfile = self.pdgfile + + # Add global range cut + if self.rangecut is not None: + seq = kernel.physicsList() + rg = PhysicsList(kernel,'Geant4DefaultRangeCut/GlobalRangeCut') + rg.enableUI() + seq.adopt(rg) + rg.RangeCut = self.rangecut - def setupPhysics( self, kernel, name=None ): - phys = kernel.physicsList() - phys.extends = name if name is not None else self.list - phys.decays = self.decays - phys.rangecut = self.rangecut - phys.enableUI() - phys.dump() - return phys + return seq -- GitLab