Skip to content

Commit

Permalink
DDSim: better logging of which sensitive detector is used when defaul…
Browse files Browse the repository at this point in the history
…ts are used
  • Loading branch information
andresailer committed Dec 14, 2023
1 parent 1a1aff3 commit fd78aa3
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions DDG4/python/DDSim/DD4hepSimulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,13 @@ def getDetectorLists(self, detectorDescription):
detType = sd.type()
logger.info('getDetectorLists - found active detector %s type: %s', name, detType)
if any(pat.lower() in detType.lower() for pat in self.action.trackerSDTypes):
logger.info('getDetectorLists - Identified %s as a tracker', name)
trackers.append(det.name())
elif any(pat.lower() in detType.lower() for pat in self.action.calorimeterSDTypes):
logger.info('getDetectorLists - Identified %s as a calorimeter', name)
calos.append(det.name())
else:
logger.warning('Unknown sensitive detector type: %s', detType)
logger.warning('getDetectorLists - Unknown sensitive detector type: %s', detType)
unknown.append(det.name())

return trackers, calos, unknown
Expand Down Expand Up @@ -464,13 +466,13 @@ def run(self):
# get lists of trackers and calorimeters in detectorDescription

trk, cal, unk = self.getDetectorLists(detectorDescription)

for detectors, function, defFilter, abort in [(trk, geant4.setupTracker, self.filter.tracker, False),
(cal, geant4.setupCalorimeter, self.filter.calo, False),
(unk, geant4.setupDetector, None, True),
]:
for detectors, function, defFilter, defAction, abort in \
[(trk, geant4.setupTracker, self.filter.tracker, self.action.tracker, False),
(cal, geant4.setupCalorimeter, self.filter.calo, self.action.calo, False),
(unk, geant4.setupDetector, None, "No Default", True),
]:
try:
self.__setupSensitiveDetectors(detectors, function, defFilter, abort)
self.__setupSensitiveDetectors(detectors, function, defFilter, defAction, abort)
except Exception as e:
logger.error("Failed setting up sensitive detector %s", e)
raise
Expand Down Expand Up @@ -580,7 +582,7 @@ def __checkOutputLevel(self, level):
return -1

def __setupSensitiveDetectors(self, detectors, setupFunction, defaultFilter=None,
abortForMissingAction=False,
defaultAction=None, abortForMissingAction=False,
):
"""Attach sensitive detector actions for all subdetectors.
Expand All @@ -592,7 +594,7 @@ def __setupSensitiveDetectors(self, detectors, setupFunction, defaultFilter=None
:param abortForMissingAction: if true end program if there is no action found
"""
for det in detectors:
logger.info('Setting up SD for %s', det)
logger.info('Setting up SD for %s with %s', det, defaultAction)
action = None
for pattern in self.action.mapActions:
if pattern.lower() in det.lower():
Expand Down

0 comments on commit fd78aa3

Please sign in to comment.