Skip to content
Snippets Groups Projects
Commit f248ab84 authored by Andre Sailer's avatar Andre Sailer
Browse files

DDSim: Add reading of particle.tbl file, needs DD4hep revision 2058

Adapt to the new way the rangeCut is added
parent 4dad464c
No related branches found
No related tags found
No related merge requests found
"""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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment