From df85d61afd3a792cf8e362da9fb83d7a97ee4895 Mon Sep 17 00:00:00 2001 From: Andre Sailer <andre.philippe.sailer@cern.ch> Date: Tue, 1 Dec 2015 15:55:18 +0000 Subject: [PATCH] Update DDSim documentation strings Move module doc to class doc so we can use it in the automatically created steering file Change docstrings to be more sensible --- DDSim/DD4hepSimulation.py | 3 +++ DDSim/Helper/Action.py | 31 +++++++++++----------- DDSim/Helper/Filter.py | 47 ++++++++++++++++++++++++++------- DDSim/Helper/Gun.py | 2 +- DDSim/Helper/MagneticField.py | 2 +- DDSim/Helper/Output.py | 2 +- DDSim/Helper/ParticleHandler.py | 4 +-- DDSim/Helper/Random.py | 2 +- 8 files changed, 62 insertions(+), 31 deletions(-) diff --git a/DDSim/DD4hepSimulation.py b/DDSim/DD4hepSimulation.py index 03b0117ef..5ba647818 100644 --- a/DDSim/DD4hepSimulation.py +++ b/DDSim/DD4hepSimulation.py @@ -615,6 +615,9 @@ SIM = DD4hepSimulation() continue if isinstance( parameter, ConfigHelper ): steeringFileBase += "\n\n" + steeringFileBase += "################################################################################\n" + steeringFileBase += "## %s \n" % "\n## ".join( parameter.__doc__.splitlines() ) + steeringFileBase += "################################################################################\n" options = parameter.getOptions() for opt,valAndDoc in options.iteritems(): parValue, parDoc = valAndDoc diff --git a/DDSim/Helper/Action.py b/DDSim/Helper/Action.py index 686c794e7..0fadf5efa 100644 --- a/DDSim/Helper/Action.py +++ b/DDSim/Helper/Action.py @@ -1,26 +1,27 @@ """Helper object for SD Actions +""" -The default tracker and calorimeter actions can be set with +from DDSim.Helper.ConfigHelper import ConfigHelper ->>> SIM = DD4hepSimulation() ->>> SIM.action.tracker = "Geant4TrackerAction" ->>> SIM.action.tracker = "Geant4CalorimeterAction" +class Action( ConfigHelper ): + """Action holding sensitive detector actions + The default tracker and calorimeter actions can be set with -for specific subdetectors specific sensitive detectors can be set based on pattern matching + >>> SIM = DD4hepSimulation() + >>> SIM.action.tracker = "Geant4TrackerAction" + >>> SIM.action.tracker = "Geant4CalorimeterAction" ->>> SIM = DD4hepSimulation() ->>> SIM.action.mapActions['tpc'] = "TPCSDAction" + for specific subdetectors specific sensitive detectors can be set based on pattern matching -and additional parameters for the sensitive detectors can be set when the map is given a tuple + >>> SIM = DD4hepSimulation() + >>> SIM.action.mapActions['tpc'] = "TPCSDAction" ->>> SIM = DD4hepSimulation() ->>> SIM.action.mapActions['ecal'] =( "CaloPreShowerSDAction", {"FirstLayerNumber": 1} ) -""" + and additional parameters for the sensitive detectors can be set when the map is given a tuple -from DDSim.Helper.ConfigHelper import ConfigHelper + >>> SIM = DD4hepSimulation() + >>> SIM.action.mapActions['ecal'] =( "CaloPreShowerSDAction", {"FirstLayerNumber": 1} ) -class Action( ConfigHelper ): - """Action holding sensitive detector actions""" + """ def __init__( self ): super(Action, self).__init__() self._tracker = 'Geant4TrackerAction' @@ -47,7 +48,7 @@ class Action( ConfigHelper ): @property def mapActions( self ): """ create a map of patterns and actions to be applied to sensitive detectors - e.g. tpc --> TPCSDAction """ + example: SIM.action.mapActions['tpc'] = "TPCSDAction" """ return self._mapActions @mapActions.setter diff --git a/DDSim/Helper/Filter.py b/DDSim/Helper/Filter.py index 18705b64a..6846fa654 100644 --- a/DDSim/Helper/Filter.py +++ b/DDSim/Helper/Filter.py @@ -1,11 +1,6 @@ """Helper object for Filters ->>> SIM = DD4hepSimulation() ->>> SIM.filter.mapDetFilter['FTD'] = "edep3keV" ->>> SIM.filter.filters['edep3keV'] = dict(name="EnergyDepositMinimumCut/3keV", parameter={"Cut": 3.0*keV} ) - - -Later the paramter dictionary is used to instantiate the filter object +Later the parameter dictionary is used to instantiate the filter object The default filters are a GeantinoRejector and a 1keV minimum energy cut """ @@ -14,15 +9,47 @@ from DDSim.Helper.ConfigHelper import ConfigHelper from SystemOfUnits import keV class Filter( ConfigHelper ): - """Filter for sensitive detector actions""" + """Configuration for sensitive detector filters + + Set the default filter for tracker or caliromter + >>> SIM.filter.tracker = "edep1kev" + >>> SIM.filter.calo = "" + + Assign a filter to a sensitive detector via pattern matching + >>> SIM.filter.mapDetFilter['FTD'] = "edep1kev" + + Or more than one filter: + >>> SIM.filter.mapDetFilter['FTD'] = ["edep1kev", "geantino"] + + Create a custom filter. The dictionary is used to instantiate the filter later on + >>> SIM.filter.filters['edep3kev'] = dict(name="EnergyDepositMinimumCut/3keV", parameter={"Cut": 3.0*keV} ) + + """ def __init__( self ): super(Filter, self).__init__() self._mapDetFilter = {} - self._tracker = "edep" + self._tracker = "edep1kev" self._calo = None self._filters = {} self._createDefaultFilters() + @property + def tracker( self ): + """ default filter for tracking sensitive detectors """ + return self._tracker + @tracker.setter + def tracker( self, val ): + self._tracker = val + + @property + def calo( self ): + """ default filter for calorimeter sensitive detectors """ + return self._calo + @calo.setter + def calo( self, val ): + self._calo = val + + @property def filters( self ): """ list of filter objects: map between name and parameter dictionary """ @@ -32,8 +59,8 @@ class Filter( ConfigHelper ): if isinstance(val, dict): self._filters.update(val) return - ## - raise RuntimeError("Commandline setting of filters is not supported, use a steeringFile:%s " % val ) + ## + raise RuntimeError("Commandline setting of filters is not supported, use a steeringFile: %s " % val ) @property diff --git a/DDSim/Helper/Gun.py b/DDSim/Helper/Gun.py index 5db30c158..8fb4db5ca 100644 --- a/DDSim/Helper/Gun.py +++ b/DDSim/Helper/Gun.py @@ -4,7 +4,7 @@ from DDSim.Helper.ConfigHelper import ConfigHelper from SystemOfUnits import GeV class Gun( ConfigHelper ): - """Gun holding all gun properties""" + """Configuration for the DDG4 ParticleGun""" def __init__( self ): super(Gun, self).__init__() self.energy = 10*GeV diff --git a/DDSim/Helper/MagneticField.py b/DDSim/Helper/MagneticField.py index 73777dfa1..4a92c5170 100644 --- a/DDSim/Helper/MagneticField.py +++ b/DDSim/Helper/MagneticField.py @@ -3,7 +3,7 @@ from SystemOfUnits import mm from DDSim.Helper.ConfigHelper import ConfigHelper class MagneticField( ConfigHelper ): - """MagneticField holding all field properties""" + """Configuration for the magnetic field (stepper)""" def __init__( self ): super(MagneticField, self).__init__() self.stepper = "HelixSimpleRunge" diff --git a/DDSim/Helper/Output.py b/DDSim/Helper/Output.py index f55c799ae..93aed3281 100644 --- a/DDSim/Helper/Output.py +++ b/DDSim/Helper/Output.py @@ -4,7 +4,7 @@ from DDSim.Helper.ConfigHelper import ConfigHelper from DDSim.DD4hepSimulation import outputLevel class Output( ConfigHelper ): - """Output holding all gun properties so we can easily overwrite them via command line magic""" + """Configuration for the output levels of DDG4 components""" def __init__( self ): super(Output, self).__init__() self._kernel = outputLevel('INFO') diff --git a/DDSim/Helper/ParticleHandler.py b/DDSim/Helper/ParticleHandler.py index a2f078286..4f251ddaf 100644 --- a/DDSim/Helper/ParticleHandler.py +++ b/DDSim/Helper/ParticleHandler.py @@ -4,7 +4,7 @@ from SystemOfUnits import MeV from DDSim.Helper.ConfigHelper import ConfigHelper class ParticleHandler( ConfigHelper ): - """Gun holding all gun properties so we can easily overwrite them via command line magic""" + """Configuration for the Particle Handler/ MCTruth treatment""" def __init__( self ): super(ParticleHandler, self).__init__() self._saveProcesses = ['Decay'] @@ -15,7 +15,7 @@ class ParticleHandler( ConfigHelper ): @property def saveProcesses(self): - """List of processes to save, give as whitespace separated string in quotation marks""" + """List of processes to save, on command line give as whitespace separated string in quotation marks""" return self._saveProcesses @saveProcesses.setter def saveProcesses(self, stringVal): diff --git a/DDSim/Helper/Random.py b/DDSim/Helper/Random.py index 6f3102628..7dc49e20a 100644 --- a/DDSim/Helper/Random.py +++ b/DDSim/Helper/Random.py @@ -3,7 +3,7 @@ from DDSim.Helper.ConfigHelper import ConfigHelper class Random (ConfigHelper): - """Properties for random number generator""" + """Properties for the random number generator""" def __init__ (self): super(Random, self).__init__() self.seed = None -- GitLab