Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:14:22

0001 """Dummy helper object for particle gun properties"""
0002 
0003 from DDSim.Helper.ConfigHelper import ConfigHelper
0004 
0005 OUTPUT_CHOICES = (1, 2, 3, 4, 5, 6, 7, 'VERBOSE', 'DEBUG',
0006                   'INFO', 'WARNING', 'ERROR', 'FATAL', 'ALWAYS')
0007 
0008 
0009 def outputLevelType(level):
0010   """Return verbosity level as integer if possible.
0011 
0012   Still benefit from argparsers list of possible choices
0013   """
0014   try:
0015     return int(level)
0016   except ValueError:
0017     return str(level)
0018 
0019 
0020 def outputLevel(level):
0021   """return INT for outputlevel"""
0022   if isinstance(level, int):
0023     if level < 1 or 7 < level:
0024       raise KeyError
0025     return level
0026   outputlevels = {"VERBOSE": 1,
0027                   "DEBUG": 2,
0028                   "INFO": 3,
0029                   "WARNING": 4,
0030                   "ERROR": 5,
0031                   "FATAL": 6,
0032                   "ALWAYS": 7}
0033   return outputlevels[level.upper()]
0034 
0035 
0036 class Output(ConfigHelper):
0037   """Configuration for the output levels of DDG4 components"""
0038 
0039   def __init__(self):
0040     super(Output, self).__init__()
0041     self._kernel_EXTRA = {'choices': OUTPUT_CHOICES, 'type': outputLevelType}
0042     self._kernel = outputLevel('INFO')
0043 
0044     self._part_EXTRA = {'choices': OUTPUT_CHOICES, 'type': outputLevelType}
0045     self._part = outputLevel('INFO')
0046 
0047     self._inputStage_EXTRA = {'choices': OUTPUT_CHOICES, 'type': outputLevelType}
0048     self._inputStage = outputLevel('INFO')
0049 
0050     self._random_EXTRA = {'choices': OUTPUT_CHOICES, 'type': outputLevelType}
0051     self._random = outputLevel('FATAL')
0052 
0053     self._geometry_EXTRA = {'choices': OUTPUT_CHOICES, 'type': outputLevelType}
0054     self._geometry = outputLevel('DEBUG')
0055 
0056     self._physics_EXTRA = {'choices': (0, 1, 2), 'type': outputLevelType}
0057     self._physics = outputLevel(1)
0058     self._closeProperties()
0059 
0060   @property
0061   def inputStage(self):
0062     """Output level for input sources"""
0063     return self._inputStage
0064 
0065   @inputStage.setter
0066   def inputStage(self, level):
0067     self._inputStage = outputLevel(level)
0068 
0069   @property
0070   def kernel(self):
0071     """Output level for Geant4 kernel"""
0072     return self._kernel
0073 
0074   @kernel.setter
0075   def kernel(self, level):
0076     self._kernel = outputLevel(level)
0077 
0078   @property
0079   def part(self):
0080     """Output level for ParticleHandler"""
0081     return self._part
0082 
0083   @part.setter
0084   def part(self, level):
0085     self._part = outputLevel(level)
0086 
0087   @property
0088   def random(self):
0089     """Output level for Random Number Generator setup"""
0090     return self._random
0091 
0092   @random.setter
0093   def random(self, level):
0094     self._random = outputLevel(level)
0095 
0096   @property
0097   def geometry(self):
0098     """Output level for geometry."""
0099     return self._geometry
0100 
0101   @geometry.setter
0102   def geometry(self, level):
0103     self._geometry = outputLevel(level)
0104 
0105   @property
0106   def physics(self):
0107     """Output level for physics and physics constructors: 0 (silent), 1, 2"""
0108     return self._physics
0109 
0110   @physics.setter
0111   def physics(self, level):
0112     self._physics = int(level)