"Simulation/git@code.ihep.ac.cn:dhb112358/CEPCSW.git" did not exist on "a06eb3911689f9e0935766d179c0d612990e6837"
Newer
Older
"""Configuration Helper for ParticleHandler"""
from __future__ import absolute_import, unicode_literals
from g4units import MeV, mm
Marko Petric
committed
import logging
logger = logging.getLogger(__name__)
"""Configuration for the Particle Handler/ MCTruth treatment"""
super(ParticleHandler, self).__init__()
self._saveProcesses = ['Decay']
self._keepAllParticles = False
self._printEndTracking = False
self._printStartTracking = False
self._enableDetailedHitsAndParticleInfo = False
self._userParticleHandler = "Geant4TCUserParticleHandler"
@property
def enableDetailedHitsAndParticleInfo(self):
"""Enable lots of printout on simulated hits and MC-truth information"""
return self._enableDetailedHitsAndParticleInfo
@enableDetailedHitsAndParticleInfo.setter
self._enableDetailedHitsAndParticleInfo = val
"""Optionally enable an extended Particle Handler"""
return self._userParticleHandler
@userParticleHandler.setter
self._userParticleHandler = val
Andre Sailer
committed
@property
Andre Sailer
committed
"""Minimal distance between particle vertex and endpoint of parent after
which the vertexIsNotEndpointOfParent flag is set
"""
return self._minDistToParentVertex
Andre Sailer
committed
@minDistToParentVertex.setter
Andre Sailer
committed
self._minDistToParentVertex = val
@property
def saveProcesses(self):
"""List of processes to save, on command line give as whitespace separated string in quotation marks"""
@saveProcesses.setter
def saveProcesses(self, stringVal):
self._saveProcesses = ConfigHelper.makeList(stringVal)
@property
def minimalKineticEnergy(self):
"""MinimalKineticEnergy to store particles created in the tracking region"""
return self._minimalKineticEnergy
self._minimalKineticEnergy = val
@property
""" Keep all created particles """
return self._keepAllParticles
self._keepAllParticles = val
@property
""" Printout at Start of Tracking """
return self._printStartTracking
self._printEndTracking = val
@property
""" Printout at End of Tracking """
return self._printEndTracking
# ---- debug code from Markus for detailed dumps of hits and MC-truth assignement ------
# Add the particle dumper to associate the MC truth
evt = DDG4.EventAction(kernel, "Geant4ParticleDumpAction/ParticleDump")
kernel.eventAction().adopt(evt)
evt.enableUI()
# Add the hit dumper BEFORE any hit truth is fixed
evt = DDG4.EventAction(kernel, "Geant4HitDumpAction/RawDump")
kernel.eventAction().adopt(evt)
evt.enableUI()
# Add the hit dumper to the event action sequence
evt = DDG4.EventAction(kernel, "Geant4HitTruthHandler/HitTruth")
kernel.eventAction().adopt(evt)
evt.enableUI()
# Add the hit dumper AFTER any hit truth is fixed. We should see the reduced track references
evt = DDG4.EventAction(kernel, "Geant4HitDumpAction/HitDump")
kernel.eventAction().adopt(evt)
evt.enableUI()
def setupUserParticleHandler(self, part, kernel, DDG4):
"""Create the UserParticleHandler and configure it.
FIXME: this is not extensible at the moment
"""
if not self.userParticleHandler:
return
if self.userParticleHandler not in ["Geant4TCUserParticleHandler"]:
Marko Petric
committed
logger.error("unknown UserParticleHandler: %r" % self.userParticleHandler)
exit(1)
if self.userParticleHandler == "Geant4TCUserParticleHandler":
user = DDG4.Action(kernel, "%s/UserParticleHandler" % self.userParticleHandler)
try:
user.TrackingVolume_Zmax = DDG4.tracker_region_zmax
user.TrackingVolume_Rmax = DDG4.tracker_region_rmax
except AttributeError as e:
Marko Petric
committed
logger.error("Attribute of tracker region missing in detector model %s", e)
logger.error(" make sure to specify the global constants tracker_region_zmax and tracker_region_rmax ")
logger.error(" this is needed for the MC-truth link of created sim-hits ! ")
logger.error(" Or Disable the User Particle Handler with --part.userParticleHandler=''")
try:
user.TrackingVolume_Zmin = DDG4.tracker_region_zmin
except AttributeError as e:
logger.debug("Attribute tracker_region_zmin for asymmetric tracker region missing %s", e)
logger.debug(" will use symmetric region defined by tracker_region_zmax")
user.TrackingVolume_Zmin = str(-float(user.TrackingVolume_Zmax))
logger.info(" *** definition of tracker region *** ")
logger.info(" tracker_region_zmin = %s", user.TrackingVolume_Zmin)
logger.info(" tracker_region_zmax = %s", user.TrackingVolume_Zmax)
logger.info(" tracker_region_rmax = %s", user.TrackingVolume_Rmax)
logger.info(" ************************************ ")
part.adopt(user)