Newer
Older
Andre Sailer
committed
"""Helper object for SD Actions
from __future__ import absolute_import, unicode_literals
from DDSim.Helper.ConfigHelper import ConfigHelper
from ddsix.moves import range
import ddsix as six
Andre Sailer
committed
"""Action holding sensitive detector actions
The default tracker and calorimeter actions can be set with
Andre Sailer
committed
>>> SIM.action.tracker=('Geant4TrackerWeightedAction', {'HitPositionCombination': 2, 'CollectSingleDeposits': False})
>>> SIM.action.calo = "Geant4CalorimeterAction"
Andre Sailer
committed
for specific subdetectors specific sensitive detectors can be set based on pattern matching
>>> SIM = DD4hepSimulation()
>>> SIM.action.mapActions['tpc'] = "TPCSDAction"
Andre Sailer
committed
and additional parameters for the sensitive detectors can be set when the map is given a tuple
Andre Sailer
committed
>>> SIM = DD4hepSimulation()
>>> SIM.action.mapActions['ecal'] =( "CaloPreShowerSDAction", {"FirstLayerNumber": 1} )
super(Action, self).__init__()
self._tracker = ('Geant4TrackerWeightedAction', {'HitPositionCombination': 2, 'CollectSingleDeposits': False})
self._calo = 'Geant4ScintillatorCalorimeterAction'
self._mapActions = dict()
Andre Sailer
committed
self._trackerSDTypes = ['tracker']
self._calorimeterSDTypes = ['calorimeter']
""" set the default tracker action """
return self._tracker
self._tracker = val
@property
""" set the default calorimeter action """
return self._calo
self._calo = val
@property
""" create a map of patterns and actions to be applied to sensitive detectors
example: SIM.action.mapActions['tpc'] = "TPCSDAction" """
return self._mapActions
@mapActions.setter
"""check if the argument is a dict, then we just update mapActions
Andre Sailer
committed
if it is a string or list, we use pairs as patterns --> Action
"""
if isinstance(val, dict):
self._mapActions.update(val)
return
if isinstance(val, six.string_types):
raise RuntimeError("Not enough parameters for mapActions")
for index in range(0, len(vals), 2):
self._mapActions[vals[index]] = vals[index + 1]
Andre Sailer
committed
"""empty the mapActions dictionary"""
self._mapActions = dict()
Andre Sailer
committed
@property
def trackerSDTypes(self):
"""List of patterns matching sensitive detectors of type Tracker."""
return self._trackerSDTypes
@trackerSDTypes.setter
def trackerSDTypes(self, val):
self._trackerSDTypes = ConfigHelper.makeList(val)
@property
def calorimeterSDTypes(self):
"""List of patterns matching sensitive detectors of type Calorimeter."""
return self._calorimeterSDTypes
@calorimeterSDTypes.setter
def calorimeterSDTypes(self, val):
self._calorimeterSDTypes = ConfigHelper.makeList(val)