diff --git a/DDG4/python/DDG4.py b/DDG4/python/DDG4.py index eb0822034..71cfc80c8 100644 --- a/DDG4/python/DDG4.py +++ b/DDG4/python/DDG4.py @@ -670,35 +670,34 @@ def setupDetector(self, name, action, collections=None): return (seq, acts) return (seq, acts[0]) - def setupCalorimeter(self, name, type=None, collections=None): # noqa: A002 + def setupCaloOrTracker(self, name, detType=None, collections=None, isCalo=True): # noqa: A002 + """ + Setup subdetector of type 'calorimeter' and assign the proper sensitive action + """ + self.description.sensitiveDetector(str(name)) + retType = detType + if detType is None: + retType = self.sensitive_types['calorimeter' if isCalo else 'tracker'] + # detType is a tuple when an action with parameters in a dictionary is passed + elif not isinstance(detType, tuple) and detType in self.sensitive_types: + retType = self.sensitive_types[detType] + return self.setupDetector(name, retType, collections) + + def setupCalorimeter(self, name, caloType=None, collections=None): # noqa: A002 """ Setup subdetector of type 'calorimeter' and assign the proper sensitive action \author M.Frank """ - typ = type # noqa: A002 - self.description.sensitiveDetector(str(name)) - # sd.setType('calorimeter') - if typ is None: - typ = self.sensitive_types['calorimeter'] - elif typ is not None and self.sensitive_types.get(typ): - typ = self.sensitive_types[typ] - return self.setupDetector(name, typ, collections) + return self.setupCaloOrTracker(name, caloType, collections, True) - def setupTracker(self, name, type=None, collections=None): # noqa: A002 + def setupTracker(self, name, trackerType=None, collections=None): # noqa: A002 """ Setup subdetector of type 'tracker' and assign the proper sensitive action \author M.Frank """ - typ = type - self.description.sensitiveDetector(str(name)) - # sd.setType('tracker') - if typ is None: - typ = self.sensitive_types['tracker'] - elif typ is not None and self.sensitive_types.get(typ): - typ = self.sensitive_types[typ] - return self.setupDetector(name, typ, collections) + return self.setupCaloOrTracker(name, trackerType, collections, False) def _private_setupField(self, field, stepper, equation, prt): import g4units