diff --git a/DDG4/python/DDSim/DD4hepSimulation.py b/DDG4/python/DDSim/DD4hepSimulation.py index 5f3d72368f6dd84e6e9ce1fd3efd5c8cd6a98e11..46fd5e0c5b0275bfec4d91f99eed710e742d0a7b 100644 --- a/DDG4/python/DDSim/DD4hepSimulation.py +++ b/DDG4/python/DDSim/DD4hepSimulation.py @@ -263,8 +263,7 @@ class DD4hepSimulation(object): self.__printSteeringFile(parser) exit(1) - @staticmethod - def getDetectorLists(detectorDescription): + def getDetectorLists(self, detectorDescription): ''' get lists of trackers and calorimeters that are defined in detectorDescription (the compact xml file)''' import DDG4 trackers, calos = [], [] @@ -274,13 +273,13 @@ class DD4hepSimulation(object): sd = detectorDescription.sensitiveDetector(name) if sd.isValid(): detType = sd.type() - # if len(detectorList) and not(name in detectorList): - # continue - logger.info('getDetectorLists - found active detctor %s type: %s', name, detType) - if detType == "tracker": + logger.info('getDetectorLists - found active detector %s type: %s', name, detType) + if any(pat in detType.lower() for pat in self.action.trackerSDTypes): trackers.append(det.name()) - if detType == "calorimeter": + elif any(pat in detType.lower() for pat in self.action.calorimeterSDTypes): calos.append(det.name()) + else: + logger.warn('Unknown sensitive detector type: %s', detType) return trackers, calos diff --git a/DDG4/python/DDSim/Helper/Action.py b/DDG4/python/DDSim/Helper/Action.py index a9def61568c69c24c772570d241c240450447e8b..21488c8d23720f31c35db9f71428d57592c2f1e7 100644 --- a/DDG4/python/DDSim/Helper/Action.py +++ b/DDG4/python/DDSim/Helper/Action.py @@ -32,6 +32,8 @@ class Action(ConfigHelper): self._tracker = ('Geant4TrackerWeightedAction', {'HitPositionCombination': 2, 'CollectSingleDeposits': False}) self._calo = 'Geant4ScintillatorCalorimeterAction' self._mapActions = dict() + self._trackerSDTypes = ['tracker'] + self._calorimeterSDTypes = ['calorimeter'] @property def tracker(self): @@ -78,3 +80,21 @@ class Action(ConfigHelper): def clearMapActions(self): """empty the mapActions dictionary""" self._mapActions = dict() + + @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)