diff --git a/Simulation/G4Atlas/G4AtlasApps/python/PyG4Atlas.py b/Simulation/G4Atlas/G4AtlasApps/python/PyG4Atlas.py index 9b6bc2fa987688c818a40c228b0ebcb69c9b07e9..c94e8f4c6afb977d1e79c9e82ba268fcecaec3a6 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/PyG4Atlas.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/PyG4Atlas.py @@ -25,6 +25,7 @@ if concurrencyProps.ConcurrencyFlags.NumThreads() > 0: else: is_hive = False + # TODO: Rename to AppProfiler, to avoid class/variable confusion class _app_profiler(object): """\ @@ -87,13 +88,8 @@ class G4AtlasEngine: G4AtlasEngine.Dict = dict() G4AtlasEngine.Dict_DetConfig = dict() G4AtlasEngine.Dict_Materials = dict() - #G4AtlasEngine.Dict_Colors = dict() G4AtlasEngine.Dict_MCTruthStrg = dict() G4AtlasEngine.Dict_MCTruthStrg['SecondarySavingPolicy'] = 'All' - G4AtlasEngine.Dict_Fields = dict() - G4AtlasEngine.Dict_UserAction = dict() - G4AtlasEngine.Dict_RecEnvelope = dict() - G4AtlasEngine.Dict_FieldIntegrationParameters = dict() G4AtlasEngine.Dict_SpecialConfiguration = dict() ## Web doc links @@ -114,11 +110,6 @@ class G4AtlasEngine: ## Logging service G4AtlasEngine.log = Logging.logging.getLogger('G4AtlasApps') - ## Configure the logger to automatically prepend the method it's called from - #if not G4AtlasEngine.log.handlers: - # G4AtlasEngine.log.addHandler(Logging.logging.StreamHandler()) - #fmt = Logging.logging.Formatter('%(name) %(module)s %(funcName)s: %(message)s') - #G4AtlasEngine.log.handlers[0].setFormatter(fmt) from AthenaCommon.AppMgr import ServiceMgr as svcMgr G4AtlasEngine.log.setLevel(10*(svcMgr.MessageSvc.OutputLevel - 1)) @@ -130,9 +121,6 @@ class G4AtlasEngine: self.load_Dict('G4AtlasControlDict') G4AtlasEngine.gbl = cppyy.makeNamespace("") G4AtlasEngine._ctrl = G4AtlasEngine.gbl.SimControl() - #self.load_Lib("G4DetectorEnvelopes") #FIXME remove? - #self.load_Lib("GeoDetectorPlugIns") #FIXME remove? - #self.load_Lib("G4StepLimitation") #FIXME still needed? self.init_status = 0 self.useISF = useISF @@ -145,7 +133,6 @@ class G4AtlasEngine: G4AtlasEngine.log.info('setting useISF to %s' % useISF) self.useISF = useISF - def _init_G4(self): """ Inits G4 @@ -156,7 +143,7 @@ class G4AtlasEngine: if G4AtlasEngine.log.level <= 30: g4Command = G4AtlasEngine.gbl.G4Commands() g4Command.run.verbose(2) # FIXME make configurable based on Athena message level? - G4AtlasEngine._ctrl.initializeG4() + G4AtlasEngine._ctrl.initializeG4(is_hive) self._InitList.append('init_G4') G4AtlasEngine._app_profiler('_init_G4: ') else: @@ -182,54 +169,6 @@ class G4AtlasEngine: G4AtlasEngine._ctrl.mctruthMenu.listStrategies() - def _init_RecEnvelope(self): - """ Inits the recording within the envelopes - - (for internal use) - """ - if 'init_RecEnvelope' not in self._InitList: - G4AtlasEngine.log.debug('G4AtlasEngine: _init_RecEnvelope: init RecEnvelope ') - if G4AtlasEngine.Dict_RecEnvelope.keys(): - G4AtlasEngine._ctrl.mctruthMenu.enableEnvelopeRecording() - for i in G4AtlasEngine.Dict_RecEnvelope.keys(): - G4AtlasEngine.Dict_RecEnvelope.get(i)._construct() - self._InitList.append('init_RecEnvelope') - G4AtlasEngine._app_profiler('_init_RecEnvelope: ') - else: - G4AtlasEngine.log.warning('G4AtlasEngine: init_RecEnvelope is already done') - - - def _init_Fields(self): - """ Inits all the fields defined. - (for internal use) - """ - if 'init_Fields' not in self._InitList: - G4AtlasEngine.log.debug(' G4AtlasEngine: _init_Fields: init magnetic fields ') - for mfd in sorted(G4AtlasEngine.Dict_Fields.keys()): - mfd_obj = G4AtlasEngine.Dict_Fields.get(mfd) - mfd_obj._build() - self._InitList.append('init_Fields') - G4AtlasEngine._app_profiler('_init_Fields: ') - else: - G4AtlasEngine.log.warning('G4AtlasEngine: init_Fields is already done') - - - def _init_FieldIntegrationParameters(self): - """ Inits all the field integration parameter objects defined. - - (for internal use) - """ - if 'init_FieldIntegrationParameters' in self._InitList: - G4AtlasEngine.log.warning('G4AtlasEngine: init_FieldIntegrationParameters is already done') - return - - G4AtlasEngine.log.debug('G4AtlasEngine: _init_FieldIntegrationParameters: init field integration parameters') - for fip in G4AtlasEngine.Dict_FieldIntegrationParameters.values(): - fip._build() - self._InitList.append('init_FieldIntegrationParameters') - G4AtlasEngine._app_profiler('_init_FieldIntegrationParameters: ') - - def _init_Graphics(self): """ Inits the G4 visualization stuff. @@ -259,17 +198,15 @@ class G4AtlasEngine: pre/postInitG4 - called before/after the init_G4 method pre/postInitMCTruth - called before/after the init_MCTruth method pre/postInitFields - called before/after the init_Fields method - pre/postInitFieldIntegrationParameters - called before/after the init_FieldIntegrationParameters method - pre/postInitRecEnvelope - called before/after the init_RecEnvelope method pre/postInitGraphics - called before/after the init_Graphics method postInit - called after all sim engine initialisation methods The current init level is stored in G4AtlasEngine.init_status, and its name corresponds to the active hook at that point. """ + from G4AtlasApps.SimFlags import simFlags def _run_init_callbacks(init_level): - from G4AtlasApps.SimFlags import simFlags if simFlags.InitFunctions.statusOn and init_level in simFlags.InitFunctions.get_Value(): #print simFlags.InitFunctions.get_Value() for callback_fn in simFlags.InitFunctions.get_Value()[init_level]: @@ -295,18 +232,6 @@ class G4AtlasEngine: else: G4AtlasEngine.log.debug('not initializing MCTruth in G4AtlasEngine because useISF=True') - _run_init_stage("Fields") - _run_init_stage("FieldIntegrationParameters") - - # Doesn't work with hive - if not is_hive: - if not self.useISF: - _run_init_stage("RecEnvelope") - else: - G4AtlasEngine.log.debug('not initializing RecEnvelope in G4AtlasEngine because useISF=True') - else: - G4AtlasEngine.log.debug('not initializing RecEnvelope in G4AtlasEngine because this is a G4Hive job.') - _run_init_stage("Graphics") self.init_status = "postInit" @@ -314,7 +239,6 @@ class G4AtlasEngine: _run_init_callbacks(self.init_status) ## Check that all the callbacks were indeed called, and warn otherwise - from G4AtlasApps.SimFlags import simFlags num_reg_callbacks = sum(len(cblist) for cblist in simFlags.InitFunctions.get_Value().values()) if G4AtlasEngine._callback_counter != num_reg_callbacks: G4AtlasEngine.log.warning("G4AtlasEngine: mismatch in num of callbacks regd/called = %d/%d" % @@ -381,80 +305,6 @@ class G4AtlasEngine: - class menu_Field: - """ Menu for the magnetic fields. - """ - - @classmethod - def list_Fields(cls): - """ Lists the existing magnetic fields. - - The libray must be loaded in advance. For example - the G4Field can be loaded. - """ - G4AtlasEngine._ctrl.fldMenu.list() - - @classmethod - def set_EquationOfMotion(cls, eq_name): - """ Set the equation of motion by name - """ - G4AtlasEngine._ctrl.fldMenu.SetEquationOfMotion(eq_name) - - - @classmethod - def add_Field(cls, mag_obj): - """ Adds a magnetic field to the simulation. - - - mag_object must be a Python object of type MagneticField. - """ - if isinstance(mag_obj,MagneticField): - if mag_obj.Name not in G4AtlasEngine.Dict_Fields: - G4AtlasEngine.Dict_Fields[mag_obj.Name] = mag_obj - G4AtlasEngine.log.debug(' G4AtlasEngine: menu_Field: add_Field: added ' + mag_obj.Name) - else: - G4AtlasEngine.log.error(' G4AtlasEngine: menu_Field: add_Field: This is not a MagneticField object!!!') - - - - class menu_FieldIntegrationParameters: - """ Menu for the field integration parameters. - - """ - - @classmethod - def list_Parameters(cls): - """ Lists the existing field integration parameters. - """ - G4AtlasEngine._ctrl.fldIntMenu.list() - - @classmethod - def show_PythonParameters(cls): - """ Prints the parameters for all field integration parameters - defined in the python layer - """ - for par in G4AtlasEngine.Dict_FieldIntegrationParameters.keys() : - G4AtlasEngine.Dict_FieldIntegrationParameters[par].show_Parameters() - - - @classmethod - def add_FieldIntegrationParameters(cls, fip_obj): - """ Adds a field integration parameters instance to the simulation. - - fip_obj must be a Python object of type FieldIntegrationParameters. - """ - if isinstance(fip_obj, FieldIntegrationParameters): - if fip_obj.Name not in G4AtlasEngine.Dict_FieldIntegrationParameters: - G4AtlasEngine.Dict_FieldIntegrationParameters[fip_obj.Name] = fip_obj - G4AtlasEngine.log.debug('G4AtlasEngine:' + - ' menu_FieldIntegrationParameters: add_FieldIntegrationParameters: added '+fip_obj.Name) - else: - G4AtlasEngine.log.error(' G4AtlasEngine:'+ - ' menu_FieldIntegrationParameters: add_FieldIntegrationParameters: '+ - ' This is not a FieldIntegrationParameters object!!!') - - - class menu_MCTruth: """ MC truth strategies can be added using this menu. @@ -522,70 +372,6 @@ class G4AtlasEngine: - class menu_RecordEnvelope: - """ Handles the volumes in which the track record will - be applied - - .add_RecEnvelope(RecEnvelope_obj) - """ - - - def add_RecEnvelope(self,obj): - """ Adds a RecEnvelope object to the simulation - engine. - """ - if isinstance(obj,RecEnvelope): - G4AtlasEngine.Dict_RecEnvelope[obj.Name]=obj - G4AtlasEngine.log.debug(' G4AtlasEngine:'+\ - 'menu_RecordEnvelope:add_RecEnvelope: '+\ - 'added '+obj.Name) - else: - G4AtlasEngine.log.error(' G4AtlasEngine:'+\ - 'menu_RecordEnvelope:add_RecEnvelope:'+\ - ' This is not a RecEnvelope object!!!') - - - def _init(self): - """ Done at the init time automatically. """ - G4AtlasEngine._ctrl.mctruthMenu.enableEnvelopeRecording() - - - -# class menu_UserActions: -# """ -# User actions can be added using this menu. -# """ -# -# @classmethod -# def add_UserAction(cls, action_obj): -# """Adds a UserAction object to the simulation.""" -# if isinstance(action_obj,UserAction): -# G4AtlasEngine.log.debug('G4AtlasEngine: menu_UserActions:add_UserAction: ' + -# action_obj.Name) -# G4AtlasEngine.Dict_UserAction[action_obj.Name] = action_obj -# action_obj._construct() -# else: -# G4AtlasEngine.log.error('G4AtlasEngine: menu_UserActions:add_UserAction: '+ -# 'This is not a UserAction object!!!') -# -# @classmethod -# def list_Actions(cls): -# """ -# Lists the possible actions. -# -# The list is extracted from the user-action libraries already loaded. -# """ -# G4AtlasEngine._ctrl.actMenu.actionList() -# -# -# @classmethod -# def load_Lib(cls, Library): -# """Loads the library with the user-actions.""" -# G4AtlasEngine.load_Lib(Library) -# G4AtlasEngine._ctrl.actMenu.actionList() -# - - class menu_EventFilter(object): """ Access to the event filters @@ -606,18 +392,8 @@ class G4AtlasEngine: self.VertexRangeChecker.SetZ( simFlags.WorldZRange.get_Value() ) if hasattr(simFlags, 'WorldRRange') and simFlags.WorldRRange.statusOn: self.VertexRangeChecker.SetRmax( simFlags.WorldRRange.get_Value() ) - - self.VertexPositioner = G4AtlasEngine.gbl.VertexPositioner('VertexPositioner') - - self.PrimaryEventRotations = G4AtlasEngine.gbl.PrimaryEventRotations('PrimaryEventRotations') - - self.BeamEffectTransformation = G4AtlasEngine.gbl.BeamEffectTransformation('BeamEffectTransformation') - self.FilterStatusOn = { 'EtaPhiFilters' : False, - 'PrimaryEventRotations' : False, - 'BeamEffectTransformation' : False, - 'VertexPositioner' : False, 'VertexRangeChecker' : False } @@ -646,10 +422,7 @@ class G4AtlasEngine: The filters can be customized from here. Available filters are: - EtaPhiFilters - - PrimaryEventRotations - - VertexPositioner - VertexRangeChecker - - BeamEffectTransformation """ f = getattr(self, name_filter) if f is None: @@ -858,7 +631,6 @@ class G4AtlasEngine: G4command.vis.viewer.flush() - class DetConfigurator: """ DetConfigurator is a hook for the specific sub-detector configuration. @@ -911,261 +683,6 @@ class DetConfigurator: -class MagneticField: - """ Magnetic field. - - The Python object "MagneticField". It can be 'Constant' or - magnetic field map 'MapField' type (by default 'Constant'), - unless the last argument will be set to 'MapField'. - """ - - # TODO: change signature so that lib can have a default value (i.e. swap the order of lib & name) - # TODO: reinstate stepper="StepperDispatcher"): - def __init__(self, lib, name, volume="", typefield="Constant", stepper=None): - """\ - lib = library (normally 'G4Field') - name = name of the field map - volume = Geant4 volume with the syntax: 'name::name' For the Mapfield is not needed and it MUST be an empty string. - typefield = Constant | MapField - """ - self._Built = False - self.List_Volumes = list() - if volume: - self.add_Volume(volume) - self.Name = name - self.Library = lib - self.Type = typefield - if typefield == 'Constant': - self.Bx = 0.0 - self.By = 0.0 - self.Bz = 0.0 - elif typefield == 'MapField': - self.DeltaIntersection = dict() - self.DeltaOneStep = dict() - self.MaximumEpsilonStep = dict() - self.MinimumEpsilonStep = dict() - else: - raise ValueError(' PyG4Atlas.MagneticField not allowed field type: '+str(typefield)) - - self.FieldStepper = stepper - - - def add_Volume(self, vol): - """\ - Adds more volumes to the List_Volumes in which the - MagneticField will be applied.The syntax for the - volume names is: 'name::name'. - """ - self.List_Volumes.append(vol) - - - def set_FieldMapFileName(self, fieldmapfilename): - """\ - Sets the name of the file that contains the field map. - """ - if self.Type == 'MapField': - self.MapFieldFileName = fieldmapfilename - - - def set_G4FieldTrackParameters(self, param_name, volume, value): - """\ - The possible parameters are: - - DeltaIntersection - - DeltaOneStep - - MaximumEpsilonStep - - MinimumEpsilonStep - """ - if volume in self.List_Volumes: - if param_name == 'DeltaIntersection': - self.DeltaIntersection[volume] = value - elif param_name == 'DeltaOneStep': - self.DeltaOneStep[volume] = value - elif param_name == 'MaximumEpsilonStep': - self.MaximumEpsilonStep[volume] = value - elif param_name == 'MinimumEpsilonStep': - self.MinimumEpsilonStep[volume] = value - else: - raise ValueError(' PyG4Atlas.MagneticField.set_G4FieldTrackParameters: invalid parameter') - else: - G4AtlasEngine.log.debug('PyG4Atlas.MagneticField.set_G4FieldTrackParameters: ' + - 'the volume is not in the list of the MagneticField volumes') - - - def _build(self): - if self.Library not in G4AtlasEngine.List_LoadedLib: - G4AtlasEngine.load_Lib(self.Library) - if self.Type == 'Constant': - if self.Library+'Dict' not in G4AtlasEngine.List_LoadedDict: - G4AtlasEngine.load_Dict(self.Library+'Dict') - CtFieldHandler = G4AtlasEngine.gbl.ConstantFieldHandler() - for volname in self.List_Volumes: - G4AtlasEngine._ctrl.fldMenu.assign('ConstantField', self.Name, volname) - G4AtlasEngine.log.debug(' MagneticField:_build: Constant field ' + self.Name + - ' with components (%f, %f, %f)' % (self.Bx, self.By, self.Bz) + - ' applied to volume ' + volname) - CtFieldHandler.setFieldValues(self.Name, self.Bx, self.By, self.Bz) - self._Built = True - elif self.Type == 'MapField': - # Check if this is the main detector field or not - from G4AtlasApps.SimFlags import simFlags - main_field = hasattr(simFlags, 'MagneticField') and (not simFlags.MagneticField.statusOn or simFlags.MagneticField() in self.Name) - - if main_field: G4AtlasEngine._ctrl.fldMenu.select(self.Name) - if main_field: G4AtlasEngine._ctrl.fldMenu.fieldmap(self.MapFieldFileName) - for volname in self.List_Volumes: - G4AtlasEngine._ctrl.fldMenu.assign(self.Name, self.Name, volname) - for volname in self.DeltaIntersection.keys(): - G4AtlasEngine._ctrl.fldMenu.setDeltaIntersection(volname, self.DeltaIntersection.get(volname)) - for volname in self.DeltaOneStep.keys(): - G4AtlasEngine._ctrl.fldMenu.setDeltaOneStep(volname, self.DeltaOneStep.get(volname)) - for volname in self.MaximumEpsilonStep.keys(): - G4AtlasEngine._ctrl.fldMenu.setMaximumEpsilonStep(volname, self.MaximumEpsilonStep.get(volname)) - for volname in self.MinimumEpsilonStep.keys(): - G4AtlasEngine._ctrl.fldMenu.setMinimumEpsilonStep(volname, self.MinimumEpsilonStep.get(volname)) - G4AtlasEngine.log.debug(' MagneticField::set_G4FieldTrackParameters: set values') - if main_field: G4AtlasEngine._ctrl.fldMenu.initialize() - G4AtlasEngine.log.debug(' MagneticField:_build: MapField ' + self.Name) - - ## Enable default stepper - stepper = self.FieldStepper - if stepper is None: stepper=G4AtlasEngine._ctrl.fldMenu.GetDefaultStepper() - G4AtlasEngine.log.debug(' MagneticField:_build: Setting stepper = %s' % stepper) - G4AtlasEngine._ctrl.fldMenu.UseStepper(stepper) - - self._Built = True - G4AtlasEngine._app_profiler(' _build: MagneticField ' + self.Name) - - - -class FieldIntegrationParameters: - """ Field integration parameters. - - The Python object "FieldIntegrationParameters". - """ - def __init__(self,region): - """ - name = name of the field integration parameters object - based on the region from which it is constructed - """ - self._Built = False - self.List_Regions = [] - if region: - self.List_Regions.append(region) - # TODO: Calc name dynamically by catting sorted regions list - self.Name = '%s_Parameters' % region - self.KineticEnergyThreshold = -1 - self.MaxLengthForConstField = dict() - self.MissDistance = dict() - self.TypicalLongStep = dict() - self.TolerableBiasError = dict() - self.TolerableIntegrationError = dict() - self.ExpectedNumBoundaries = dict() - self.ExpectedTrackLength = dict() - - def add_Region(self, reg): - """ Adds more regions to the List_Regions in which the - FieldIntegrationParameters will be applied. - """ - if reg: - self.List_Regions.append(reg) - - def set_KineticEnergyThreshold(self,val): - """ Sets kinetic energy threshold for the region. Below this threshold - electrons and positrons will be treated differently - """ - self.KineticEnergyThreshold = val - - def show_Parameters(self): - """ Shows the current values for the parameters of the object - """ - print 'FieldIntegrationParameters with name '+self.Name+' parameters:' - if self.KineticEnergyThreshold >= 0: - print 'KineticEnergyThreshold : %f MeV' % self.KineticEnergyThreshold - else : print 'KineticEnergyThreshold : default' - print 'For the following parameters:' - print ' idx=0 for e+/e- track below E-threshold' - print ' idx=1 for e+/e- track above E-threshold and all other charged track except mu+/mu- of any kinetic energy' - print ' idx=2 for mu+/mu- track of any kinetic energy' - print 'Any items or entries not listed will take the default values' - if len(self.MaxLengthForConstField)>0 : print 'MaxLengthForConstField :',self.MaxLengthForConstField - if len(self.MissDistance)>0 : print 'MissDistance :',self.MissDistance - if len(self.TypicalLongStep)>0 : print 'TypicalLongStep :',self.TypicalLongStep - if len(self.TolerableBiasError)>0 : print 'TolerableBiasError :',self.TolerableBiasError - if len(self.TolerableIntegrationError)>0 : print 'TolerableIntegrationError :',self.TolerableIntegrationError - if len(self.ExpectedNumBoundaries)>0 : print 'ExpectedNumBoundaries :',self.ExpectedNumBoundaries - if len(self.ExpectedTrackLength)>0 : print 'ExpectedTrackLength :',self.ExpectedTrackLength - print '\n\n' - - def set_Parameter(self,param_name,index,val): - """ Set the value of one of the field integration parameters. The - possible parameter names are: - - MaxLengthForConstField : maximum length of a step for which - the magnetic field will be considered to be constant - - MissDistance : Allowable distance for missing a volume - - TypicalLongStep : Length of a long step in the region - - TolerableBiasError : The allowable bias that can accumulate - during stepping - - TolerableIntegrationError : The allowable error on integration - during stepping - - ExpectedNumBoundaries : The expected number of boundaries that - will be crossed by a track traversing the region - - ExpectedTrackLength : The expected track length for a track - traversing the region - - Index should be 0, 1, or 2 : - - idx=0 for e+/e- track below E-threshold - - idx=1 for e+/e- track above E-threshold - and all other charged track except mu+/mu- - of any kinetic energy - - idx=2 for mu+/mu- track of any kinetic energy - """ - if (int(index) == 0 or int(index) == 1 or int(index) == 2): - if(param_name=='MaxLengthForConstField'): - self.MaxLengthForConstField[int(index)]=val - elif(param_name=='MissDistance'): - self.MissDistance[int(index)]=val - elif(param_name=='TypicalLongStep'): - self.TypicalLongStep[int(index)]=val - elif(param_name=='TolerableBiasError'): - self.TolerableBiasError[int(index)]=val - elif(param_name=='TolerableIntegrationError'): - self.TolerableIntegrationError[int(index)]=val - elif(param_name=='ExpectedNumBoundaries'): - self.ExpectedNumBoundaries[int(index)]=val - elif(param_name=='ExpectedTrackLength'): - self.ExpectedTrackLength[int(index)]=val - else: - raise ValueError,(' PyG4Atlas.FieldIntegrationParameters::'+\ - 'set_Parameter: invalid parameter '+param_name) - else: - G4AtlasEngine.log.debug(' FieldIntegrationParameters::'+\ - 'set_Parameter the index is not one of 0, 1, or 2 - '+index) - - def _build(self): - if not self._Built: - for reg in self.List_Regions : - if self.KineticEnergyThreshold >= 0: - G4AtlasEngine._ctrl.fldIntMenu.Set_kineticEnergyThreshold( reg , self.KineticEnergyThreshold ) - for idx in self.MaxLengthForConstField.keys() : - G4AtlasEngine._ctrl.fldIntMenu.Set_maxLengthForConstField( reg , idx , self.MaxLengthForConstField[idx] ) - for idx in self.MissDistance.keys() : - G4AtlasEngine._ctrl.fldIntMenu.Set_missDistance( reg , idx , self.MissDistance[idx] ) - for idx in self.TypicalLongStep.keys() : - G4AtlasEngine._ctrl.fldIntMenu.Set_typicalLongStep( reg , idx , self.TypicalLongStep[idx] ) - for idx in self.TolerableBiasError.keys() : - G4AtlasEngine._ctrl.fldIntMenu.Set_tolerableBiasError( reg , idx , self.TolerableBiasError[idx] ) - for idx in self.TolerableIntegrationError.keys() : - G4AtlasEngine._ctrl.fldIntMenu.Set_tolerableIntegrationError( reg , idx , self.TolerableIntegrationError[idx] ) - for idx in self.ExpectedNumBoundaries.keys() : - G4AtlasEngine._ctrl.fldIntMenu.Set_expectedNumBoundaries( reg , idx , self.ExpectedNumBoundaries[idx] ) - for idx in self.ExpectedTrackLength.keys() : - G4AtlasEngine._ctrl.fldIntMenu.Set_expectedTrackLength( reg , idx , self.ExpectedTrackLength[idx] ) - G4AtlasEngine.log.debug(' FieldIntegrationParameters:_build: FieldIntegrationParameters '+self.Name) - self._Built = True - G4AtlasEngine._app_profiler(' _build: FieldIntegrationParameters '+self.Name) - - - class MCTruthStrg: """ MCTruth strategy. @@ -1212,30 +729,6 @@ class MCTruthStrg: -class RecEnvelope: - """ Recording envelope. - - - """ - - def __init__(self, name, volume_name, volume_level,allowMods=False): - self._Built = False - self.Name = name - self.Dict_Volumes = dict() - self.Dict_Volumes[volume_name] = volume_level - self._AllowMods=allowMods - - def _construct(self): - if not self._Built: - for i in self.Dict_Volumes.keys(): - G4AtlasEngine._ctrl.mctruthMenu.addRecordingEnvelope(i, self.Dict_Volumes.get(i), self.Name) - G4AtlasEngine.log.debug(' RecEnvelope:'+ - '_construct: '+self.Name+' and store at the exit of volume '+i) - self._Built = True - G4AtlasEngine._app_profiler(' _build RecEnvelope: '+self.Name) - - - class SimSkeleton(object): """ Skeleton for a simulation entity. @@ -1307,14 +800,8 @@ class SimSkeleton(object): stream1.ItemList += ["McEventCollection#GEN_EVENT"] from PyJobTransforms.trfUtils import releaseIsOlderThan - if releaseIsOlderThan(20,0): - #Hack to maintain compatibility of G4AtlasApps trunk with - #19.2.X.Y after EDM changes in release 20.0.0. - stream1.ItemList += ["xAOD::JetContainer_v1#*", - "xAOD::JetAuxContainer_v1#*"] - else: - stream1.ItemList += ["xAOD::JetContainer#*", - "xAOD::JetAuxContainer#*"] + stream1.ItemList += ["xAOD::JetContainer#*", + "xAOD::JetAuxContainer#*"] ## Make stream aware of aborted events stream1.AcceptAlgs = ["G4AtlasAlg"] @@ -1348,10 +835,8 @@ class SimSkeleton(object): stream1.ItemList += ["LUCID_SimHitCollection#*"] ## FwdRegion - checkFwdRegion = getattr(DetFlags, 'FwdRegion_on', None) #back-compatibility - if checkFwdRegion is not None: #back-compatibility - if checkFwdRegion(): - stream1.ItemList += ["SimulationHitCollection#*"] + if DetFlags.FwdRegion_on(): + stream1.ItemList += ["SimulationHitCollection#*"] ## ZDC if DetFlags.ZDC_on(): @@ -1359,15 +844,15 @@ class SimSkeleton(object): "ZDC_SimStripHit_Collection#*"] ## ALFA if DetFlags.ALFA_on(): - stream1.ItemList += ["ALFA_HitCollection#*","ALFA_ODHitCollection#*"] + stream1.ItemList += ["ALFA_HitCollection#*", + "ALFA_ODHitCollection#*"] ## AFP - checkAFP = getattr(DetFlags, 'AFP_on', None) #back-compatibility - if checkAFP is not None: #back-compatibility - if checkAFP(): - stream1.ItemList += ["AFP_TDSimHitCollection#*","AFP_SIDSimHitCollection#*"] + if DetFlags.AFP_on(): + stream1.ItemList += ["AFP_TDSimHitCollection#*", + "AFP_SIDSimHitCollection#*"] - ## Ancillary scintillators + ### Ancillary scintillators #stream1.ItemList += ["ScintillatorHitCollection#*"] ## TimingAlg @@ -1616,56 +1101,9 @@ class SimSkeleton(object): G4AtlasEngine.log.verbose('SimSkeleton._doG4AtlasAlg :: starting') from AthenaCommon.AlgSequence import AlgSequence job = AlgSequence() - from G4AtlasAlg.G4AtlasAlgConf import G4AtlasAlg - job += G4AtlasAlg() - - ## Killing neutrinos - from G4AtlasApps.SimFlags import simFlags - sLayout = simFlags.SimLayout() - if "ATLAS" in sLayout: + if not hasattr(job, 'G4AtlasAlg'): from AthenaCommon import CfgGetter - #FIXME move to CfgGetter method - CfgGetter.getPublicTool('AthenaStackingAction',tryDefaultConfigurable=True).KillAllNeutrinos = True - - if hasattr(simFlags, 'ReleaseGeoModel') and simFlags.ReleaseGeoModel.statusOn: - ## Save the fast simulation - job.G4AtlasAlg.ReleaseGeoModel = simFlags.ReleaseGeoModel.get_Value() - - if hasattr(simFlags, 'RecordFlux') and simFlags.RecordFlux.statusOn: - ## Record the particle flux during the simulation - job.G4AtlasAlg.RecordFlux = simFlags.RecordFlux.get_Value() - - if hasattr(simFlags, 'IncludeParentsInG4Event') and simFlags.IncludeParentsInG4Event.statusOn: - ## Propagate quasi-stable particles - job.G4AtlasAlg.IncludeParentsInG4Event = simFlags.IncludeParentsInG4Event.get_Value() - - if hasattr(simFlags, 'KillAbortedEvents') and simFlags.KillAbortedEvents.statusOn: - ## default true - job.G4AtlasAlg.KillAbortedEvents = simFlags.KillAbortedEvents.get_Value() - - if hasattr(simFlags, 'FlagAbortedEvents') and simFlags.FlagAbortedEvents.statusOn: - ## default false - job.G4AtlasAlg.FlagAbortedEvents = simFlags.FlagAbortedEvents.get_Value() - if simFlags.FlagAbortedEvents.get_Value() and simFlags.KillAbortedEvents.get_Value(): - G4AtlasEngine.log.warning('When G4AtlasAlg.FlagAbortedEvents is True G4AtlasAlg.KillAbortedEvents should be False!!! Setting G4AtlasAlg.KillAbortedEvents = False now!') - job.G4AtlasAlg.KillAbortedEvents = False - - if hasattr(simFlags, 'RandomSvc') and simFlags.RandomSvc.statusOn: - ## default true - job.G4AtlasAlg.AtRndmGenSvc = simFlags.RandomSvc.get_Value() - - ## G4AtlasAlg verbosities (available domains = Navigator, Propagator, Tracking, Stepping, Stacking, Event) - ## Set stepper verbose = 1 if the Athena logging level is <= DEBUG - # TODO: Why does it complain that G4AtlasAlgConf.G4AtlasAlg has no "Verbosities" object? Fix. - #from AthenaCommon.AppMgr import ServiceMgr - #if ServiceMgr.MessageSvc.OutputLevel <= 2: - # print dir(job.G4AtlasAlg) - # print job.G4AtlasAlg.Verbosities - # print job.G4AtlasAlg.Verbosities["Tracking"] - # job.G4AtlasAlg.Verbosities["Tracking"] = 1 - - # TODO: Add physics list setting from simFlags to the alg here? - + job += CfgGetter.getAlgorithm("G4AtlasAlg",tryDefaultConfigurable=True) G4AtlasEngine.log.verbose('SimSkeleton._doG4AtlasAlg :: done') @@ -1676,18 +1114,6 @@ class SimSkeleton(object): G4AtlasEngine.log.info('SimSkeleton.do_GeoSD :: nothing done') - @classmethod - def _do_MagField(cls): - """ Place to define the existing magnetic fields. - """ - G4AtlasEngine.log.info('SimSkeleton.do_MagField :: nothing done') - - @classmethod - def _do_FieldIntegrationParameters(cls): - """ Place to define the settings for default field integration parameters. - """ - G4AtlasEngine.log.info('SimSkeleton.do_FieldIntegrationParameters :: nothing done') - @classmethod def do_MCtruth(cls): """ Place to define the MCTruth strategies. @@ -1715,21 +1141,6 @@ class SimSkeleton(object): G4AtlasEngine.log.info('SimSkeleton._do_metadata :: nothing done') - @classmethod - def __checks(cls): - """ - Internals. - - Do not re-write this method. Here it is checked if the - user has defined a world volume and a physics list. If - this is not the case a default world_volume is created - and the QGSP_BERT is selected. - """ - import AtlasG4Eng - G4AtlasEngine.log.verbose('SimSkeleton.__checks :: starting') - G4AtlasEngine.log.verbose('SimSkeleton.__checks :: done') - - @classmethod def _do_PreInit(cls): """ @@ -1743,11 +1154,11 @@ class SimSkeleton(object): from G4AtlasApps.SimFlags import simFlags if simFlags.ISFRun: known_methods = ['_do_jobproperties', '_do_external', '_do_metadata', - '_do_MagField', '_do_FieldIntegrationParameters','do_UserActions'] + 'do_UserActions'] else: known_methods = ['_do_jobproperties', '_do_external', '_do_metadata', - '_do_readevgen', '_do_persistency', '_do_G4AtlasAlg','do_UserActions', - '_do_MagField', '_do_FieldIntegrationParameters'] + '_do_readevgen', '_do_persistency', '_do_G4AtlasAlg', + 'do_UserActions'] ## Execute the known methods from the known_methods in pre_init for k in known_methods: @@ -1769,14 +1180,8 @@ class SimSkeleton(object): from AthenaCommon.CfgGetter import getPublicTool fastSimulationTool = getPublicTool("FastSimulationMasterTool") - # Add User actions - if not hasattr(ServiceMgr, "UserActionSvc"): - from AthenaCommon.CfgGetter import getService - userActionSvc = getService("UserActionSvc") - ## Run pre-init callbacks G4AtlasEngine.log.debug("G4AtlasEngine:init stage " + "preInit") - from G4AtlasApps.SimFlags import simFlags if simFlags.InitFunctions.statusOn and "preInit" in simFlags.InitFunctions.get_Value(): for callback_fn in simFlags.InitFunctions.get_Value()["preInit"]: callback_fn.__call__() @@ -1815,7 +1220,6 @@ class SimSkeleton(object): import traceback, sys traceback.print_exc(file=sys.stdout) raise RuntimeError('SimSkeleton: found problems with the method %s' % i) - cls.__checks() G4AtlasEngine.log.verbose('SimSkeleton._do_All :: done') @@ -1919,7 +1323,6 @@ class _PyG4AtlasComp(PyG4Atlas_base): theApp.EvtMax = athenaCommonFlags.EvtMax() return True - def finalize(self): import AtlasG4Eng AtlasG4Eng.G4Eng._app_profiler('%s at finalize ' % self.name()) diff --git a/Simulation/G4Atlas/G4AtlasApps/python/SimAtlasKernel.py b/Simulation/G4Atlas/G4AtlasApps/python/SimAtlasKernel.py index 9fe22fe6d42e9f71ea37cf522b20cb8d1a665d4e..cb276cf3d37fcf2762c7c023c0ea815d5487de45 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/SimAtlasKernel.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/SimAtlasKernel.py @@ -87,12 +87,9 @@ class AtlasSimSkeleton(SimSkeleton): if simFlags.EventFilter.statusOn and simFlags.EventFilter.get_Value()['EtaPhiFilters']: AtlasG4Eng.G4Eng.log.info('AtlasSimSkeleton._do_jobproperties :: Running Cavern BG simulation - turning off EtaPhi Filter!') simFlags.EventFilter.switchFilterOff('EtaPhiFilters') - if simFlags.CavernBG.get_Value()=='Read' and \ - simFlags.EventFilter.statusOn and simFlags.EventFilter.get_Value()['VertexPositioner']: - AtlasG4Eng.G4Eng.log.info('AtlasSimSkeleton._do_jobproperties :: Reading Cavern BG events - turning off Vertex Positioner (and VertexFromCondDB and VertexTimeOffset)!') - simFlags.EventFilter.switchFilterOff('VertexPositioner') - simFlags.VertexFromCondDB.set_Off() - simFlags.VertexTimeOffset.set_Off() + if simFlags.CavernBG.get_Value()=='Read': + simFlags.VertexFromCondDB.set_Off() + simFlags.VertexTimeOffset.set_Off() # Switch off GeoModel Release in the case of parameterization if simFlags.LArParameterization.get_Value()>0 and simFlags.ReleaseGeoModel(): @@ -254,89 +251,40 @@ class AtlasSimSkeleton(SimSkeleton): AtlasG4Eng.G4Eng.log.verbose('AtlasSimSkeleton._do_GeoEnv :: starting') AtlasG4Eng.G4Eng.log.verbose('AtlasSimSkeleton._do_GeoEnv :: done') + @classmethod def do_UserActions(self): """ - User actions: TrackProcessor + User actions: with the migration ot MT UA, this method is no longer needed. """ - # this line to make sure that the default UAs are added to the list - from G4AtlasServices.G4AtlasUserActionConfig import UAStore + return - # only setup those user actions if running within ISF - from G4AtlasApps.SimFlags import simFlags - if simFlags.ISFRun: - - from AthenaCommon.AppMgr import ToolSvc,ServiceMgr - ##hack to allow for different named Configurations of the UserActions - def UserActionPath(basename): - actionString='' - for t in ToolSvc.getAllChildren(): - if basename in t.getName(): - actionString = t.getName() - break - from G4AtlasApps import AtlasG4Eng - if ''==actionString: - AtlasG4Eng.G4Eng.log.error('ISF_AtlasSimSkeleton::do_UserActions: Could not find ' + basename + ' instance in ToolSvc!') - raise SystemExit('ISF_AtlasSimSkeleton::do_UserActions: Could not find ' + basename + ' instance in ToolSvc!') - else: - AtlasG4Eng.G4Eng.log.info('ISF_AtlasSimSkeleton::do_UserActions: Found a ' + basename + ' instance called ' + actionString) - return actionString - from AthenaCommon.CfgGetter import getPublicTool - UAStore.addAction( getPublicTool(UserActionPath('TrackProcessorUserAction')),['Step','BeginOfTracking','BeginOfEvent','EndOfTracking','EndOfEvent']) - UAStore.addAction( getPublicTool(UserActionPath('MCTruthUserAction')),['BeginOfTracking','EndOfTracking']) - from ISF_Config.ISF_jobProperties import ISF_Flags - if ISF_Flags.ValidationMode.get_Value(): - UAStore.addAction( getPublicTool(UserActionPath('PhysicsValidationUserAction')),['BeginOfRun','EndOfEvent','Step','BeginOfTracking','BeginOfEvent']) @classmethod def do_GeoSD(self): """ Configure the geometry and SD """ AtlasG4Eng.G4Eng.log.verbose('AtlasSimSkeleton._do_GeoSD :: starting') - ## Different geometry-levels for rec envelopes depending into simFlags.SimLayout - recenv_level = 2 - from G4AtlasApps.SimFlags import simFlags - from AthenaCommon.BeamFlags import jobproperties - if jobproperties.Beam.beamType() == 'cosmics' or \ - (simFlags.CavernBG.statusOn and not 'Signal' in simFlags.CavernBG.get_Value() ): - recenv_level = 3 - - # if this is an ISF run, allow the collections on store gate to be modified - # by other algorithms (i.e. set them non-const) - allowSGMods = True if simFlags.ISFRun else False - - ## Get a handle to the RecEnv menu - if not simFlags.ISFRun: - menuRecordEnvelopes = AtlasG4Eng.G4Eng.menu_RecordEnvelope() - from atlas_mctruth import RecordingEnvelopes ## Inner detector if DetFlags.ID_on(): - if not simFlags.ISFRun: - rc = RecordingEnvelopes.AtlasCaloEntryLayer(recenv_level, allowSGMods) - menuRecordEnvelopes.add_RecEnvelope(rc.recenv) if DetFlags.geometry.TRT_on(): AtlasG4Eng.G4Eng.read_XML("TRgeomodelgeometry.xml") # FIXME need to find a better way to do this ## Calorimeters if DetFlags.Calo_on(): - if not simFlags.ISFRun: - rc = RecordingEnvelopes.AtlasMuonEntryLayer(recenv_level, allowSGMods) - menuRecordEnvelopes.add_RecEnvelope(rc.recenv) - ## LAr if DetFlags.geometry.LAr_on(): + from G4AtlasApps.SimFlags import simFlags + # if this is an ISF run, allow the collections on store gate to be modified + # by other algorithms (i.e. set them non-const) + allowSGMods = True if simFlags.ISFRun else False from atlas_calo import PyLArG4RunControler lArG4RunControl = PyLArG4RunControler('PyLArG4RunControl', 'LArG4RunControlDict', allowMods=allowSGMods) - ## Muon system - if DetFlags.geometry.Muon_on(): - if not simFlags.ISFRun: - rc = RecordingEnvelopes.AtlasMuonExitLayer(recenv_level, allowSGMods) - menuRecordEnvelopes.add_RecEnvelope(rc.recenv) - AtlasG4Eng.G4Eng.log.verbose('AtlasSimSkeleton._do_GeoSD :: done') + @classmethod def do_MCtruth(self): """ Configure the MCTruth strategies. @@ -388,107 +336,6 @@ class AtlasSimSkeleton(SimSkeleton): AtlasG4Eng.G4Eng.log.verbose('AtlasSimSkeleton._do_MCTruth :: done') - @classmethod - def _do_MagField(self): - """ Configure the magnetic field - """ - AtlasG4Eng.G4Eng.log.verbose('AtlasSimSkeleton._do_MagField :: starting') - from G4AtlasApps.SimFlags import simFlags - if simFlags.MagneticField.statusOn: - if simFlags.MagneticField() == 'AtlasFieldSvc': - from AthenaCommon.AppMgr import ServiceMgr as svcMgr - import MagFieldServices.SetupField - # TODO: would be useful if the AthenaSvc name can be handed over to the PyG4Atlas.MagneticField somehow - # currently G4AtlasFieldSvc.cxx retrieves a field service with the default name 'AtlasFieldSvc' - atlasfield = PyG4Atlas.MagneticField('G4Field', 'G4AtlasFieldSvc', typefield='MapField') - else: - raise Exception('IllegalFieldServiceSpecification') - - atlasfield.set_FieldMapFileName(simFlags.MagneticField.get_Value()) - - if DetFlags.bpipe_on(): - # BeamPipe volume is not added to DetFacility until - # later on in the simulation set-up (during the - # do_GeoSD method), so have to rely on the DetFlag - # check here. - AtlasG4Eng.G4Eng.log.debug('AtlasSimSkeleton._do_MagField :: Increasing BeamPipe Tracking Precision') - atlasfield.add_Volume('BeamPipe::BeamPipe') - atlasfield.set_G4FieldTrackParameters('DeltaIntersection', 'BeamPipe::BeamPipe', 0.00001) - atlasfield.set_G4FieldTrackParameters('DeltaOneStep', 'BeamPipe::BeamPipe', 0.0001) - atlasfield.set_G4FieldTrackParameters('MaximumEpsilonStep', 'BeamPipe::BeamPipe', 0.001) - atlasfield.set_G4FieldTrackParameters('MinimumEpsilonStep', 'BeamPipe::BeamPipe', 0.00001) - if DetFlags.ID_on(): - AtlasG4Eng.G4Eng.log.debug('AtlasSimSkeleton._do_MagField :: Increasing IDET Tracking Precision') - atlasfield.add_Volume('IDET::IDET') - atlasfield.set_G4FieldTrackParameters('DeltaIntersection', 'IDET::IDET', 0.00001) - atlasfield.set_G4FieldTrackParameters('DeltaOneStep', 'IDET::IDET', 0.0001) - atlasfield.set_G4FieldTrackParameters('MaximumEpsilonStep', 'IDET::IDET', 0.001) - atlasfield.set_G4FieldTrackParameters('MinimumEpsilonStep', 'IDET::IDET', 0.00001) - if DetFlags.Muon_on(): - AtlasG4Eng.G4Eng.log.debug('AtlasSimSkeleton._do_MagField :: Increasing MUONQ02 Tracking Precision') - atlasfield.add_Volume('MUONQ02::MUONQ02') - atlasfield.set_G4FieldTrackParameters('DeltaIntersection', 'MUONQ02::MUONQ02', 0.00000002) - atlasfield.set_G4FieldTrackParameters('DeltaOneStep', 'MUONQ02::MUONQ02', 0.000001) - atlasfield.set_G4FieldTrackParameters('MaximumEpsilonStep', 'MUONQ02::MUONQ02', 0.0000009) - atlasfield.set_G4FieldTrackParameters('MinimumEpsilonStep', 'MUONQ02::MUONQ02', 0.000001) - AtlasG4Eng.G4Eng.menu_Field.add_Field(atlasfield) - if simFlags.EquationOfMotion.statusOn: - AtlasG4Eng.G4Eng.menu_Field.set_EquationOfMotion( simFlags.EquationOfMotion.get_Value() ) - ## Forward Region - if simFlags.ForwardDetectors.statusOn: - if DetFlags.geometry.FwdRegion_on(): - # Set up the field - step_limitation = None - if simFlags.FwdStepLimitation.statusOn: - step_limitation = simFlags.FwdStepLimitation() - fieldVolumes = [] - fieldVolumes += [ ['Q1', ['FwdRegion::LQXAA.1R1MagQ1'] ] ] - fieldVolumes += [ ['Q2', ['FwdRegion::LQXBA.2R1MagQ2a', 'FwdRegion::LQXBA.2R1MagQ2b'] ] ] - fieldVolumes += [ ['Q3', ['FwdRegion::LQXAG.3R1MagQ3'] ] ] - fieldVolumes += [ ['D1', [ 'FwdRegion::MBXW.A4R1MagD1a', 'FwdRegion::MBXW.B4R1MagD1b', 'FwdRegion::MBXW.C4R1MagD1c',\ - 'FwdRegion::MBXW.D4R1MagD1d', 'FwdRegion::MBXW.E4R1MagD1e', 'FwdRegion::MBXW.F4R1MagD1f'] ] ] - fieldVolumes += [ ['D2', ['FwdRegion::LBRCD.4R1MagD2'] ] ] - fieldVolumes += [ ['Q4', ['FwdRegion::LQYCH.4R1MagQ4'] ] ] - fieldVolumes += [ ['Q5', ['FwdRegion::LQNDC.5R1MagQ5'] ] ] - fieldVolumes += [ ['Q6', ['FwdRegion::LQNDD.6R1MagQ6'] ] ] - fieldVolumes += [ ['Q7', ['FwdRegion::LQNFD.7R1MagQ7a', 'FwdRegion::LQNFD.7R1MagQ7b'] ] ] - fieldVolumes += [ ['Q1HKick', ['FwdRegion::LQXAA.1R1MagQ1HKick'] ] ] - fieldVolumes += [ ['Q1VKick', ['FwdRegion::LQXAA.1R1MagQ1VKick'] ] ] - fieldVolumes += [ ['Q2HKick', ['FwdRegion::LQXBA.2R1MagQ2HKick'] ] ] - fieldVolumes += [ ['Q2VKick', ['FwdRegion::LQXBA.2R1MagQ2VKick'] ] ] - fieldVolumes += [ ['Q3HKick', ['FwdRegion::LQXAG.3R1MagQ3HKick'] ] ] - fieldVolumes += [ ['Q3VKick', ['FwdRegion::LQXAG.3R1MagQ3VKick'] ] ] - fieldVolumes += [ ['Q4VKickA', ['FwdRegion::LQYCH.4R1MagQ4VKickA'] ] ] - fieldVolumes += [ ['Q4HKick', ['FwdRegion::LQYCH.4R1MagQ4HKick'] ] ] - fieldVolumes += [ ['Q4VKickB', ['FwdRegion::LQYCH.4R1MagQ4VKickB'] ] ] - fieldVolumes += [ ['Q5HKick', ['FwdRegion::LQNDC.5R1MagQ5HKick'] ] ] - fieldVolumes += [ ['Q6VKick', ['FwdRegion::LQNDD.6R1MagQ6VKick'] ] ] - - epsMin = 1e-9 - epsMax = 1e-8 - deltaIntersection = 1e-9 - deltaOneStep = 1e-8 - - for i in fieldVolumes: - a_field = PyG4Atlas.MagneticField('ForwardRegionMgField',i[0],typefield='MapField') - for v in i[1]: - a_field.add_Volume(v) - a_field.set_G4FieldTrackParameters('DeltaIntersection', v, deltaIntersection) - a_field.set_G4FieldTrackParameters('DeltaOneStep', v, deltaOneStep) - a_field.set_G4FieldTrackParameters('MaximumEpsilonStep', v, epsMax) - a_field.set_G4FieldTrackParameters('MinimumEpsilonStep', v, epsMin) - - # limit step length - if step_limitation is not None: - AtlasG4Eng.G4Eng._ctrl.geometryMenu.SetMaxStep(v, step_limitation) - - a_field.set_FieldMapFileName(i[0]) - AtlasG4Eng.G4Eng.menu_Field.add_Field(a_field) - - if step_limitation is not None: - AtlasG4Eng.G4Eng._ctrl.geometryMenu.SetMaxStep('FwdRegion::ForwardRegionGeoModel', step_limitation) - AtlasG4Eng.G4Eng.log.verbose('AtlasSimSkeleton._do_MagField :: done') - @classmethod def _do_metadata(self): """ @@ -646,19 +493,7 @@ class AtlasSimSkeleton(SimSkeleton): stat = menu_EventFilter.getFilterStatus() ## TODO: Always switch off the EtaPhiFilters if ALFA/ZDC/AFP are being simulated? stat['EtaPhiFilters'] = simFlags.EventFilter.get_Value()['EtaPhiFilters'] - stat['VertexPositioner'] = simFlags.EventFilter.get_Value()['VertexPositioner'] - if not stat['VertexPositioner']: - if simFlags.VertexFromCondDB.statusOn and simFlags.VertexFromCondDB(): - AtlasG4Eng.G4Eng.log.error('AtlasSimSkeleton._do_EventFilter :: simFlags.EventFilter[VertexPositioner] has been switched off, but simFlags.VertexFromCondDB is switched on.') - AtlasG4Eng.G4Eng.log.warning('Please check your configuration.') - if simFlags.VertexTimeOffset.statusOn and simFlags.VertexTimeOffset.get_Value() != 0: - AtlasG4Eng.G4Eng.log.error('AtlasSimSkeleton._do_EventFilter :: simFlags.EventFilter[VertexPositioner] has been switched off, but simFlags.VertexTimeOffset is set to True.') - AtlasG4Eng.G4Eng.log.warning('Please check your configuration.') - elif not simFlags.VertexFromCondDB.statusOn: - AtlasG4Eng.G4Eng.log.info('AtlasSimSkeleton._do_EventFilter :: simFlags.EventFilter[VertexPositioner] is on, but simFlags.VertexFromCondDB is switched off. Assuming that you have set up the BeamCondSvc yourself.') stat['VertexRangeChecker'] = simFlags.EventFilter.get_Value()['VertexRangeChecker'] - stat['BeamEffectTransformation'] = simFlags.EventFilter.get_Value()['BeamEffectTransformation'] - stat['PrimaryEventRotations'] = simFlags.EventFilter.get_Value()['PrimaryEventRotations'] menu_EventFilter._build() if stat['EtaPhiFilters']: @@ -667,24 +502,4 @@ class AtlasSimSkeleton(SimSkeleton): etarange = 7.0 if DetFlags.geometry.Lucid_on() else 6.0 etaFilter.AddEtaInterval(-etarange, etarange) - # Additional options for beam effect transport - if stat['BeamEffectTransformation']: - beFilter = menu_EventFilter.getFilter('BeamEffectTransformation') - if simFlags.BeamEffectOptions.statusOn: - for opt in simFlags.BeamEffectOptions.get_Value().keys(): - exec( 'beFilter.Set_'+opt+'(float('+str(simFlags.BeamEffectOptions.get_Value()[opt])+'))' ) - exec( 'new_value = beFilter.Get_'+opt+'()' ) - AtlasG4Eng.G4Eng.log.info('Set BeamEffectTransformation option '+opt+' to '+str( new_value ) ) - - if simFlags.VertexTimeOffset.statusOn and simFlags.VertexTimeOffset.get_Value() != 0: - raise RuntimeError( 'Vertex time offset should not be used!' ) - - if hasattr(simFlags, 'RandomSvc') and simFlags.RandomSvc.statusOn: - AtlasG4Eng.G4Eng._ctrl.physicsMenu.SetRandomNumberService( simFlags.RandomSvc() ) - if simFlags.VertexOverrideFile.statusOn: - AtlasG4Eng.G4Eng.log.verbose('AtlasSimSkeleton._do_EventFilter :: Setting vertex override file '+str(simFlags.VertexOverrideFile())) - AtlasG4Eng.G4Eng._ctrl.physicsMenu.SetVertexOverrideFile( simFlags.VertexOverrideFile() ) - if simFlags.VertexOverrideEventFile.statusOn: - AtlasG4Eng.G4Eng.log.verbose('AtlasSimSkeleton._do_EventFilter :: Setting vertex override event file '+str(simFlags.VertexOverrideEventFile())) - AtlasG4Eng.G4Eng._ctrl.physicsMenu.SetVertexOverrideEventFile( simFlags.VertexOverrideEventFile() ) AtlasG4Eng.G4Eng.log.verbose('AtlasSimSkeleton._do_EventFilter :: done') diff --git a/Simulation/G4Atlas/G4AtlasApps/python/SimCtbKernel.py b/Simulation/G4Atlas/G4AtlasApps/python/SimCtbKernel.py index 798c25bf6f535b0d5a0b10a7fac197421d19b06f..38b19231fc965365e6f60323fa486cc4bd17d774 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/SimCtbKernel.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/SimCtbKernel.py @@ -120,12 +120,10 @@ class TBSimSkeleton(SimSkeleton): dbFiller.addSimParam('EtaPhiStatus', str(simFlags.EventFilter.get_Value()['EtaPhiFilters'])) dbFiller.addSimParam('VertexStatus', str(simFlags.EventFilter.get_Value()['VertexPositioner'])) dbFiller.addSimParam('VRangeStatus', str(simFlags.EventFilter.get_Value()['VertexRangeChecker'])) - #dbFiller.addSimParam('PrimaryEventRotations', str(simFlags.EventFilter.get_Value()['PrimaryEventRotations'])) else : dbFiller.addSimParam('EtaPhiStatus', 'default') dbFiller.addSimParam('VertexStatus', 'default') dbFiller.addSimParam('VRangeStatus', 'default') - #dbFiller.addSimParam('PrimaryEventRotations', 'default') dbFiller.addSimParam('G4Version', str(os.environ['G4VERS'])) dbFiller.addSimParam('beamType',jobproperties.Beam.beamType.get_Value()) @@ -344,8 +342,8 @@ class CtbSim(TBSimSkeleton): ctb_top_volumes() # recording envelope added to IDET volume - rc=CTBRecordingEnvelopes.CtbCaloEntryLayer() - MenuRecordEnvelopes.add_RecEnvelope(rc.recenv) + ## rc=CTBRecordingEnvelopes.CtbCaloEntryLayer() + ## MenuRecordEnvelopes.add_RecEnvelope(rc.recenv) from G4AtlasApps.SimFlags import simFlags if (simFlags.SimLayout.get_Value()=='ctbh8_photon'): @@ -365,11 +363,11 @@ class CtbSim(TBSimSkeleton): if not(simFlags.BeamConditions.statusOn and simFlags.BeamConditions.get_Value()): larupmaterial=LArFarUpstreamMaterial(0) - rc1=CTBRecordingEnvelopes.LArFarUpstreamMaterialExitLayer(0) + ## rc1=CTBRecordingEnvelopes.LArFarUpstreamMaterialExitLayer(0) else: larupmaterial=LArFarUpstreamMaterial(1) - rc1=CTBRecordingEnvelopes.LArFarUpstreamMaterialExitLayer(1) - MenuRecordEnvelopes.add_RecEnvelope(rc1.recenv) + ## rc1=CTBRecordingEnvelopes.LArFarUpstreamMaterialExitLayer(1) + ## MenuRecordEnvelopes.add_RecEnvelope(rc1.recenv) # -- Inner detector if(DetFlags.ID_on()): @@ -558,71 +556,71 @@ class CtbSim(TBSimSkeleton): if(simFlags.LeadUpstreamAbs.statusOn): from ctb_common import leadfoil - @classmethod - def do_MagField(self): - """ Defines the magnetic field configurations. - - (constant and magnetic field map supported) - """ - # - Magnetic fields - # - Magnetic Field Map only in the IDET volume - from G4AtlasApps.SimFlags import simFlags - if simFlags.MagFieldMap.statusOn: - if(AtlasG4Eng.G4Eng.Dict_DetFacility.has_key('MBPSID') and - AtlasG4Eng.G4Eng.Dict_DetFacility.has_key('IDET')): - from ctb_field import CTBFieldMap - ctbfieldmap=CTBFieldMap(simFlags.MagFieldMap.get_Value(),\ - simFlags.MagFieldMapCalculation.get_Value()) - else: - AtlasG4Eng.G4Eng.log.warning('CtbSim: magnetic fields: \ - No MBPSID or IDET volumes') - # - Constant Fields - if(simFlags.MagnetMBPSIDBz.statusOn and - not(simFlags.MagFieldMap.statusOn)) : - if AtlasG4Eng.G4Eng.Dict_DetFacility.has_key('MBPSID'): - from ctb_field import CTBConstantField - B_MBPSID=CTBConstantField('MBPSID') - B_MBPSID.field.Bz=simFlags.MagnetMBPSIDBz.get_Value() - AtlasG4Eng.G4Eng.menu_Field.add_Field(B_MBPSID.field) - else: - AtlasG4Eng.G4Eng.log.warning('CtbSim: magnetic fields: \ - No MBPSID volume') - if simFlags.MagnetMBPLBy.statusOn: - if AtlasG4Eng.G4Eng.Dict_DetFacility.has_key('MBPL'): - from ctb_field import CTBConstantField - B_MBPL=CTBConstantField('MBPL') - B_MBPL.field.By=simFlags.MagnetMBPLBy.get_Value() - AtlasG4Eng.G4Eng.menu_Field.add_Field(B_MBPL.field) - else: - AtlasG4Eng.G4Eng.log.warning('CtbSim: magnetic fields: \ - No MBPL volume') - if simFlags.MagnetMBPS2By.statusOn: - if AtlasG4Eng.G4Eng.Dict_DetFacility.has_key('MBPS2'): - from ctb_field import CTBConstantField - B_MBPS2=CTBConstantField('MBPS2') - B_MBPS2.field.By=simFlags.MagnetMBPS2By.get_Value() - AtlasG4Eng.G4Eng.menu_Field.add_Field(B_MBPS2.field) - else: - AtlasG4Eng.G4Eng.log.warning('CtbSim: magnetic fields: \ - No MBPS2 volume') - if simFlags.MagnetMBPL12Bz.statusOn: - if AtlasG4Eng.G4Eng.Dict_DetFacility.has_key('MBPL12'): - from ctb_field import CTBConstantField - B_MBPL12=CTBConstantField('MBPL12') - B_MBPL12.field.Bz=simFlags.MagnetMBPL12Bz.get_Value() - AtlasG4Eng.G4Eng.menu_Field.add_Field(B_MBPL12.field) - else: - AtlasG4Eng.G4Eng.log.warning('CtbSim: magnetic fields: \ - No MBPL12 volume') - if simFlags.MagnetMBPL13By.statusOn: - if AtlasG4Eng.G4Eng.Dict_DetFacility.has_key('MBPL13'): - from ctb_field import CTBConstantField - B_MBPL13=CTBConstantField('MBPL13') - B_MBPL13.field.By=simFlags.MagnetMBPL13By.get_Value() - AtlasG4Eng.G4Eng.menu_Field.add_Field(B_MBPL13.field) - else: - AtlasG4Eng.G4Eng.log.warning('CtbSim: magnetic fields: \ - No MBPL13 volume') + ## @classmethod + ## def do_MagField(self): + ## """ Defines the magnetic field configurations. + ## + ## (constant and magnetic field map supported) + ## """ + ## # - Magnetic fields + ## # - Magnetic Field Map only in the IDET volume + ## from G4AtlasApps.SimFlags import simFlags + ## if simFlags.MagFieldMap.statusOn: + ## if(AtlasG4Eng.G4Eng.Dict_DetFacility.has_key('MBPSID') and + ## AtlasG4Eng.G4Eng.Dict_DetFacility.has_key('IDET')): + ## from ctb_field import CTBFieldMap + ## ctbfieldmap=CTBFieldMap(simFlags.MagFieldMap.get_Value(),\ + ## simFlags.MagFieldMapCalculation.get_Value()) + ## else: + ## AtlasG4Eng.G4Eng.log.warning('CtbSim: magnetic fields: \ + ## No MBPSID or IDET volumes') + ## # - Constant Fields + ## if(simFlags.MagnetMBPSIDBz.statusOn and + ## not(simFlags.MagFieldMap.statusOn)) : + ## if AtlasG4Eng.G4Eng.Dict_DetFacility.has_key('MBPSID'): + ## from ctb_field import CTBConstantField + ## B_MBPSID=CTBConstantField('MBPSID') + ## B_MBPSID.field.Bz=simFlags.MagnetMBPSIDBz.get_Value() + ## AtlasG4Eng.G4Eng.menu_Field.add_Field(B_MBPSID.field) + ## else: + ## AtlasG4Eng.G4Eng.log.warning('CtbSim: magnetic fields: \ + ## No MBPSID volume') + ## if simFlags.MagnetMBPLBy.statusOn: + ## if AtlasG4Eng.G4Eng.Dict_DetFacility.has_key('MBPL'): + ## from ctb_field import CTBConstantField + ## B_MBPL=CTBConstantField('MBPL') + ## B_MBPL.field.By=simFlags.MagnetMBPLBy.get_Value() + ## AtlasG4Eng.G4Eng.menu_Field.add_Field(B_MBPL.field) + ## else: + ## AtlasG4Eng.G4Eng.log.warning('CtbSim: magnetic fields: \ + ## No MBPL volume') + ## if simFlags.MagnetMBPS2By.statusOn: + ## if AtlasG4Eng.G4Eng.Dict_DetFacility.has_key('MBPS2'): + ## from ctb_field import CTBConstantField + ## B_MBPS2=CTBConstantField('MBPS2') + ## B_MBPS2.field.By=simFlags.MagnetMBPS2By.get_Value() + ## AtlasG4Eng.G4Eng.menu_Field.add_Field(B_MBPS2.field) + ## else: + ## AtlasG4Eng.G4Eng.log.warning('CtbSim: magnetic fields: \ + ## No MBPS2 volume') + ## if simFlags.MagnetMBPL12Bz.statusOn: + ## if AtlasG4Eng.G4Eng.Dict_DetFacility.has_key('MBPL12'): + ## from ctb_field import CTBConstantField + ## B_MBPL12=CTBConstantField('MBPL12') + ## B_MBPL12.field.Bz=simFlags.MagnetMBPL12Bz.get_Value() + ## AtlasG4Eng.G4Eng.menu_Field.add_Field(B_MBPL12.field) + ## else: + ## AtlasG4Eng.G4Eng.log.warning('CtbSim: magnetic fields: \ + ## No MBPL12 volume') + ## if simFlags.MagnetMBPL13By.statusOn: + ## if AtlasG4Eng.G4Eng.Dict_DetFacility.has_key('MBPL13'): + ## from ctb_field import CTBConstantField + ## B_MBPL13=CTBConstantField('MBPL13') + ## B_MBPL13.field.By=simFlags.MagnetMBPL13By.get_Value() + ## AtlasG4Eng.G4Eng.menu_Field.add_Field(B_MBPL13.field) + ## else: + ## AtlasG4Eng.G4Eng.log.warning('CtbSim: magnetic fields: \ + ## No MBPL13 volume') #--- Tile TB 2000-2003 ------------------------------------------------ @@ -902,8 +900,8 @@ class LArH6_TB(TBSimSkeleton): # - switch off tasks DetFlags.pileup.all_setOff() DetFlags.simulateLVL1.all_setOff() - DetFlags.digitize.all_setOff() DetFlags.overlay.all_setOff() + DetFlags.digitize.all_setOff() DetFlags.readRDOPool.all_setOff() DetFlags.makeRIO.all_setOff() DetFlags.writeBS.all_setOff() @@ -1027,13 +1025,16 @@ class LArH6_TB(TBSimSkeleton): @classmethod def do_UserActions(self): - from G4AtlasServices.G4AtlasUserActionConfig import UAStore - from G4AtlasApps.SimFlags import simFlags - if (simFlags.SimLayout.get_Value()=='tb_LArH6_2004'): - # ADS FIXME is it ok to add this system action here? - UAStore.addSystemAction('LArHitsH6EventAction',['EndOfEvent']) - UAStore.addAction('LArGeoH62004EventAction',['EndOfEvent']) - if simFlags.LArTB_H6Step.statusOn: - if simFlags.LArTB_H6Step.get_Value(): - UAStore.addAction('LArGeoH62004SteppingAction',['Step']) - UAStore.addAction('RadLenNtuple',['BeginOfEvent','EndOfEvent','Step']) + # ADS: this is not needed anymore with the migration to the new MT UAs + #from G4AtlasServices.G4AtlasUserActionConfig import UAStore + #from G4AtlasApps.SimFlags import simFlags + #if (simFlags.SimLayout.get_Value()=='tb_LArH6_2004'): + # # ADS FIXME is it ok to add this system action here? + # UAStore.addSystemAction('LArHitsH6EventAction',['EndOfEvent']) + # UAStore.addAction('LArGeoH62004EventAction',['EndOfEvent']) + # if simFlags.LArTB_H6Step.statusOn: + # if simFlags.LArTB_H6Step.get_Value(): + # UAStore.addAction('LArGeoH62004SteppingAction',['Step']) + # UAStore.addAction('RadLenNtuple',['BeginOfEvent','EndOfEvent','Step']) + + return diff --git a/Simulation/G4Atlas/G4AtlasApps/python/SimFlags.py b/Simulation/G4Atlas/G4AtlasApps/python/SimFlags.py index 3085b895c1b3a1d8ee936d2db02f9d8e445834e3..b484745b6a3d20f9cb24395910146ff0d3796847 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/SimFlags.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/SimFlags.py @@ -183,13 +183,13 @@ class PhysicsList(JobProperty): details. - _Msc95 - Uses Urban95 for e-/e+ multiple scattering. + Uses Urban95 for e-/e+ multiple scattering. - _Conv95 - Uses improved gamma conversion model. + Uses improved gamma conversion model. - _Brem95 - Uses relativistic Brem95 above threshold for e-/e+. + Uses relativistic Brem95 above threshold for e-/e+. - _95 Uses *all* 95 options, Msc95, Brem, and Conv. @@ -200,6 +200,7 @@ class PhysicsList(JobProperty): statusOn = True allowedTypes = ["str"] allowedValues = ["FTFP_BERT", + "FTFP_BERT_ATL", "QGSP_BERT", "QGSP_BERT_HP", "QGSP_BIC", @@ -250,86 +251,21 @@ class SimLayout(JobProperty): Full ATLAS layouts ------------------ - ATLAS-GEO-06-00-00 --> LUCID included, and muon envelope shifted accordingly - ATLAS-GEO-06-01-00 --> ATLAS-GEO-06-00-00 with misalignments and distorted material in the LAr - ATLAS-GEO-06-02-00 --> ATLAS-GEO-06-00-00 with 0.1 X0 of material in front of the LAr - ATLAS-GEO-06-03-00 --> ATLAS-GEO-06-00-00 with 0.2 X0 of material in front of the LAr - ATLAS-GEO-06-04-00 --> ? - ATLAS-GEO-06-22-00 --> ATLAS-GEO-06-00-00 with additional material in the inner detector - ATLAS-GEO-07-00-00 --> For cosmics, updated ID since ATLAS-GEO-03 - ATLAS-GEONSF-07-00-00 --> Same as ATLAS-GEO-07-00-00 but with solenoid off - ATLAS-GEONTF-07-00-00 --> Same as ATLAS-GEO-07-00-00 but with toroid off - ATLAS-GEONF-07-00-00 --> Same as ATLAS-GEO-07-00-00 but with no field - ATLAS-GEO-08-00-00 --> Layout for MC09 (bug in tile and muon envelopes) - ATLAS-GEO-08-00-01 --> Layout for MC09 with fixed tile and muon envelopes - ATLAS-GEO-08-00-02 --> ATLAS-GEO-08-00-01 with fwd det identifiers and TGC T4F position fix - ATLAS-GEONSF-08-00-00 --> Same as ATLAS-GEO-08-00-00 but with solenoid off - ATLAS-GEONTF-08-00-00 --> Same as ATLAS-GEO-08-00-00 but with toroid off - ATLAS-GEONF-08-00-00 --> Same as ATLAS-GEO-08-00-00 but with no field - ATLAS-GEONF-08-00-02 --> Same as ATLAS-GEO-08-00-02 but with no field - ATLAS-GEOHF-08-00-02 --> Same as ATLAS-GEO-08-00-02, but with half toroid field - ATLAS-GEONSF-08-00-02 --> Same as ATLAS-GEO-08-00-02, but with no solenoid field - ATLAS-GEOHNSF-08-00-02 --> Same as ATLAS-GEO-08-00-02 but with half toroid field and no solenoid field - ATLAS-GEONTF-08-00-02 --> Same as ATLAS-GEO-08-00-02 but with toroid off - ATLAS-GEO-08-01-00 --> CSC-like material distortion - ATLAS-GEO-08-02-00 --> ID scaled by 10% - ATLAS-GEO-08-03-00 --> ID scaled by 20% - ATLAS-GEO-08-04-00 --> ID scaled by 10% cf. ATLAS-GEO-08-02-00, plus the CSC distortions in the LAr from ATLAS-GEO-06-01-00 - ATLAS-GEO-08-05-00 --> ATLAS-GEO-08-00-02 with corrected dead material in the pixels at high eta - ATLAS-GEO-09-00-00 --> ATLAS-GEO-08-05-00 with correct associated tracking geometry - ATLAS-GEO-10-00-00 --> ATLAS-GEO-09-00-00 with updates to muon layout and LAr EMEC support geometry - ATLAS-GEO-10-00-01 --> ATLAS-GEO-10-00-00 with fix to wrong staggering of the tube layers in the muon BEE chambers - ATLAS-GEO-10-00-02 --> Based on ATLAS-GEO-10-00-01. Muon updates: Fix for staggering of BIS8 on top of R.03.13 - ATLAS-GEONTF-10-00-01 --> Based on ATLAS-GEO-10-00-01. Magnetic field configuration with Toroids OFF. - ATLAS-GEO-10-01-00 --> ATLAS-GEO-10-00-00 with ~20% extra X0 in LAr - ATLAS-GEO-10-02-00 --> 5% increase of whole ID - ATLAS-GEO-10-03-00 --> 10% increase of whole ID - ATLAS-GEO-10-04-00 --> 20% increase of pixel services - ATLAS-GEO-10-05-00 --> 20% increase of SCT services - ATLAS-GEO-10-06-00 --> Extra 15% X0 at end of SCT/TRT endcaps. - ATLAS-GEO-10-07-00 --> Extra 15% X0 at ID endplate. - ATLAS-GEO-10-08-00 --> +10% whole ID, +20% Pixel services, +20% SCT services, +15% X0 at end of SCT/TRT endcap, - +15% X0 at ID endplate. 0.1 X0 before the presampler in LAr. - ATLAS-GEO-10-09-00 --> Based on ATLAS-GEO-10-00-01. Testing bmagatlas_08_full45Sym20400.data.bz2 magnetic field map. - ATLAS-GEO-10-10-00 --> Based on ATLAS-GEO-10-00-01. Testing bmagatlas_08_fullAsym20400.data.bz2 magnetic field map. - ATLAS-GEO-10-11-00 --> Based on ATLAS-GEO-10-00-01. Testing bmagatlas_08_full45SymOld.data.bz2 magnetic field map. - ATLAS-GEO-10-12-00 --> Based on ATLAS-GEO-10-00-00. Geometry for extra material studies. - Config H. Extra 15% X0 at ID endplate. 0.1 X0 before the presampler in LAr. - ATLAS-GEO-10-13-00 --> Based on ATLAS-GEO-10-00-00. Geometry for extra material studies. - Config I (=B+C+D+E): +10% whole ID, +20% Pixel services, +20% SCT services, +15% X0 at end of SCT/TRT endcap. - ATLAS-GEO-11-00-00 --> Based on ATLAS-GEO-10-00-01. Overlap fixes in the LAr EMEC, corrected tile girder length in special EB - modules, fixed description of special D4 cells. Muon: layout R.04.01. Forward detectors: Fix for ZDC identifiers. - ATLAS-GEO-11-00-01 --> Based on ATLAS-GEO-11-00-00, with downgrade of Muon version to R.03.13. - ATLAS-GEO-11-01-00 --> Based on ATLAS-GEO-11-00-00. Only instrumented part of tile modules considered for calculation of cell dimensions. - ATLAS-GEO-11-01-01 --> Based on ATLAS-GEO-11-01-00, with downgrade of Muon version to R.03.13. - ATLAS-GEO-11-02-00 --> Based on ATLAS-GEO-11-00-00. Testing bmagatlas_08_full45Sym20400.data.bz2 magnetic field map. - ATLAS-GEO-11-02-01 --> Based on ATLAS-GEO-11-02-00, with downgrade of Muon version to R.03.13. - ATLAS-GEO-11-03-00 --> Based on ATLAS-GEO-11-00-00. Testing bmagatlas_08_fullAsym20400.data.bz2 magnetic field map. - ATLAS-GEO-11-03-01 --> Based on ATLAS-GEO-11-03-00, with downgrade of Muon version to R.03.13. - ATLAS-GEO-11-04-00 --> Based on ATLAS-GEO-11-00-00. Testing bmagatlas_08_full45SymOld.data.bz2 magnetic field map. - ATLAS-GEO-11-04-01 --> Based on ATLAS-GEO-11-04-00, with downgrade of Muon version to R.03.13. - ATLAS-GEO-12-00-00 --> Based on ATLAS-GEO-11-01-01. InDet modifications: Update to Pixel Global frame and PST. - Muon modifications: Fix bug in the staggering of the mdt tubes in BIS8 chambers. 29/07/2010 - ATLAS-GEO-13-00-00 --> Based on ATLAS-GEO-12-00-00, added detailed description of the ID rail. 30/07/2010 - ATLAS-GEO-13-00-01 --> Clone of ATLAS-GEO-14-00-01 with updated InDet component: Revert to old PP0 but keep new pixel frame and PST. - ATLAS-GEO-13-01-00 --> ATLAS-GEO-13-00-00 + the new symmetric magnetic field map (bmagatlas_08_full45Sym20400.data.bz2). 04/08/2010 - ATLAS-GEO-14-00-00 --> Unsupported: for info only. - Based on ATLAS-GEO-13-00-00: InDet updates: Add new PP0 to PP1 description in pixel, fixes to PST. - ATLAS-GEO-14-00-01 --> Based on ATLAS-GEO-14-00-00. Switching to Muon R.04.05 layout: fixes for RailAssembly and EMS1, EMS3 cutout position and dimension. - ATLAS-GEO-14-01-01 --> Based on ATLAS-GEO-14-00-01. bmagatlas_08_full45Sym20400.data.bz2 magnetic field map. - ATLAS-GEO-14-02-01 --> Based on ATLAS-GEO-14-00-01. bmagatlas_08_fullAsym20400.data.bz2 magnetic field map - ATLAS-GEO-16-00-00 --> Based on ATLAS-GEO-14-00-01. Updated InDet component: Bug fix in PP0 and split one of the Inner PP0 volumes into two volumes. - ATLAS-GEONSF-16-00-00 --> Based on ATLAS-GEO-16-00-00. Toroid ON, Solenoid OFF - ATLAS-GEO-16-01-00 --> Based on ATLAS-GEO-16-00-00. LAr Detailed absorber flag is ON - ATLAS-GEO-18-01-00 --> Based on ATLAS-GEO-18-00-00. Calorimeters: New calo neighbor table and updated FCAL2 electrode map. Drop the Magnetic Field component. - ATLAS-GEO-18-01-03 --> Based of ATLAS-GEO-18-01-00. Muon version changed to R.05.03. AGDD patch. + ATLAS-R1-2010-02-00-00 --> 2010 ATLAS layout for MC14a + ATLAS-R1-2011-02-00-00 --> 2011 ATLAS layout for MC14a + ATLAS-R1-2012-02-00-00 --> 2012 ATLAS layout for MC14a + ATLAS-R2-2015-01-01-00 --> 2015 ATLAS layout for MC14a + ATLAS-R1-2012-03-00-00 --> 2012 ATLAS layout for MC15a + ATLAS-R2-2015-02-00-00 --> 2015 ATLAS layout for MC15a + ATLAS-R2-2015-02-01-00 --> 2015 ATLAS layout for MC15a + ATLAS-R2-2015-03-00-00 --> 2015 ATLAS layout for MC15a + ATLAS-R2-2015-03-01-00 --> 2015 ATLAS layout for MC15a + ATLAS-R2-2016-00-00-00 --> 2016 ATLAS test layout for MC16 ATLAS upgrade layouts --------------------- - ATLAS-IBL-00-00-00 --> ATLAS with an insertable B-layer - ATLAS-IBL-01-00-00 --> ATLAS-GEO-10-00-01 geometry with IBL in pixel and IBL beampipe - ATLAS-SLHC-00-00-00 --> ATLAS layout for the LHC luminosity upgrade + ATLAS-P2-ITK-03-00-00 --> Phase 2 Upgrade ATLAS layout Combined Test Beam (2004) simulations @@ -366,14 +302,6 @@ class SimLayout(JobProperty): allowedTypes = ['str'] StoredValue = 'ATLAS-R2-2015-03-01-00' allowedValues = [ - 'ATLAS-GEO-16-00-00', # Default for MC10 - 'ATLAS-GEO-18-01-00', # Used in MC11a, MC11b, MC11c - 'ATLAS-GEO-18-01-01', # Used in MC11a, MC11b, MC11c - 'ATLAS-GEO-18-01-03', # Used in MC11a, MC11b, MC11c - 'ATLAS-GEO-20-00-01', # Default for MC12a, MC12b - 'ATLAS-GEO-21-02-02', # Used in MC11d, MC12c - 'ATLAS-IBL-03-00-00', # Used in MC12 Upgrade - 'ATLAS-SLHC-02-00-00', # Used in MC12 Upgrade 'ATLAS-R1-2010-02-00-00', # Used in MC14a 'ATLAS-R1-2011-02-00-00', # Used in MC14a 'ATLAS-R1-2012-02-00-00', # Used in MC14a @@ -383,6 +311,8 @@ class SimLayout(JobProperty): 'ATLAS-R2-2015-02-01-00', # Used in MC15a 'ATLAS-R2-2015-03-00-00', # Used in MC15a 'ATLAS-R2-2015-03-01-00', # Used in MC15a + 'ATLAS-R2-2016-00-00-00', # Testing for MC16 + 'ATLAS-P2-ITK-03-00-00', # Phase 2 upgrade testing 'ctbh8_combined', 'ctbh8_photon', 'ctbh8_lar-material', @@ -501,9 +431,6 @@ class RandomSeedList(JobProperty): if hasattr( jobproperties.SimFlags, 'VertexFromCondDB') and jobproperties.SimFlags.VertexFromCondDB(): if not self.checkForExistingSeed('VERTEX'): self.addSeed( "VERTEX", 2040160768, 443921183 ) - if hasattr( jobproperties.SimFlags, 'EventFilter') and jobproperties.SimFlags.EventFilter.statusOn and jobproperties.SimFlags.EventFilter.get_Value()['BeamEffectTransformation']: - if not self.checkForExistingSeed('BEAM'): - self.addSeed( "BEAM", 3499598793, 7345291 ) if hasattr( jobproperties.SimFlags, 'LArParameterization') and jobproperties.SimFlags.LArParameterization()!=0: self.addSeed("FROZENSHOWERS", 56546123, 47694674 ) if jobproperties.Beam.beamType.get_Value() == 'cosmics': @@ -623,7 +550,7 @@ class RunDict(JobProperty): _sflog = logging.getLogger('SimFlags') if len(self.get_Value())==0: _sflog.warning ('No run dictionary - giving back run number -1') - return -1 + return -1 else: total=0 for a in self.get_Value(): total += int(self.get_Value()[a]) @@ -656,6 +583,14 @@ class EquationOfMotion(JobProperty): allowedTypes = ['str'] StoredValue = 'Default' +class G4Stepper(JobProperty): + """ + The Stepper to be used in Geant4 by default. + """ + statusOn = True + allowedTypes = ['str'] + StoredValue = 'AtlasRK4' + class SimulationFlavour(JobProperty): """A short name to describe the configuration used during simulation - can be used by future steps to determine @@ -703,6 +638,56 @@ class RecordFlux(JobProperty): allowedTypes = ['bool'] StoredValue = False +class UseV2UserActions(JobProperty): + """ + Migration version of the user actions. This should only be used by experts! + - V1 corresponds to JIRA ATLASSIM-1752 + - V2 corresponds to JIRA ATLASSIM-2226 + """ + statusOn = True + allowedTypes = ['bool'] + StoredValue = True + +class OptionalUserActionList(JobProperty): + """Configuration for Optional UserActions + The name of the action must be a name retrievable through the ConfigurableFactory""" + + statusOn = True + allowedTypes = ['dict'] + # not allowing stacking actions to be modified this way + StoredValue = {'BeginOfRun':[], 'BeginOfEvent':[], 'PreTracking':[], 'Step':['G4UA::LooperKillerTool'], 'PostTracking':[], 'EndOfRun':[], 'EndOfEvent':[]} + def addAction(self,actionTool,roles=[]): + #Add the action to the end of the list of actions for each role. + for role in roles: + try: + self.StoredValue[role]+=[actionTool] + except KeyError: + print "WARNING Attempt to assign to action",actionTool,"a role ",role,"which is not allowed" + + def removeAction(self,actionTool,roles=['BeginOfRun','BeginOfEvent', 'PreTracking', 'Step', 'PostTracking', 'EndOfRun', 'EndOfEvent']): + #Remove the action from the lists of actions for each role (remove from all by default) - no error if it isn't in the list. + for role in roles: + try: + self.StoredValue[role].remove(actionTool) + except KeyError: + print "WARNING Attempt to remove action",actionTool," from role ",role,"which is not allowed" + except ValueError: + print "WARNING Attempt to remove unkown action",actionTool,"from role ",role + +class UserActionConfig(JobProperty): + """Configuration for UserActions + The name of the action must be a name retrievable through the ConfigurableFactory """ + statusOn = True + allowedTypes = ['dict'] + StoredValue = {} + def addConfig(self,actionTool,prop,value): + if actionTool in self.StoredValue.keys(): + # this overrides the previous configuration, if any + self.StoredValue[actionTool][prop]=value + else: + self.StoredValue[actionTool]={prop:value} + + ## Definition and registration of the simulation flag container class SimFlags(JobPropertyContainer): diff --git a/Simulation/G4Atlas/G4AtlasApps/python/atlas_flags.py b/Simulation/G4Atlas/G4AtlasApps/python/atlas_flags.py index 60ed9a7d5977134f6b2cc0fb2c3fc2702932fb1d..093788ae5ad955f9007e381b1b7e08c591eb5250 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/atlas_flags.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/atlas_flags.py @@ -21,26 +21,13 @@ class EventFilter(JobProperty): The available filters for the full ATLAS simulation are: - EtaPhiFilters: (Filters G4PrimaryParticle objects outside of configurable Eta and Phi ranges. Not suitable for use with ALFA and ZDC.) - - VertexPositioner: (Randomly offsets events so that the primary - vertex spread is distributed according to the luminous - region. This should be used for those generators which set the - vertex position at (0,0,0) by default, but not for Single - ParticleGenerator.) - VertexRangeChecker: (Filters G4PrimaryVertex objects outside of configurable R and Z ranges.) - - BeamEffectTransformation: (Boosts primary event particles to - account for beam effects. This class applies a Lorentz - transformation to the momentum vectors of a primary event to - account for effect of the incoming beams, such as crossing angle, - beam divergence, and beam energy smearing.) """ statusOn = True allowedTypes = ['dict'] StoredValue = { 'EtaPhiFilters': True, - 'VertexPositioner': True, - 'VertexRangeChecker': True, - 'PrimaryEventRotations' : False, - 'BeamEffectTransformation': False } + 'VertexRangeChecker': True } def switchFilterOff(self, filter): """Switch the specified filter off""" @@ -50,7 +37,7 @@ class EventFilter(JobProperty): from AthenaCommon.Logging import logging _sflog = logging.getLogger('SimFlags') _sflog.warning ( "Tried to switch off non-existent EventFilter: " + filter ) - + def switchFilterOn(self, filter): """Switch the specified filter on""" if filter in self.get_Value().keys(): @@ -64,7 +51,7 @@ class EventFilter(JobProperty): """Switch the specified filter off""" for filter in self.get_Value().keys(): self.get_Value()[filter] = False - + def switchAllFiltersOn(self): """Switch the specified filter on""" for filter in self.get_Value().keys(): @@ -127,6 +114,15 @@ class MagneticField(JobProperty): StoredValue = 'AtlasFieldSvc' +class TightMuonStepping(JobProperty): + """ + Switch to enable tight muon stepping parameters + """ + statusOn = True + allowedTypes = ['bool'] + StoredValue = False + + class ForwardDetectors(JobProperty): """ Decide whether simulation must be run for forward detectors. @@ -177,38 +173,13 @@ class VertexTimeOffset(JobProperty): StoredValue = False -class GMSBIndex(JobProperty): - """ - Index number of GMSB point. - - Used exclusively in SimuJobTransforms/postOptions.GMSB.py - """ - statusOn = False - allowedTypes = ['int'] - StoredValue = None - - -class AMSBIndex(JobProperty): +class PhysicsOptions(JobProperty): """ - Index (non-number) of AMSB point. - - Used exclusively in SimuJobTransforms/postOptions.AMSB.py + PhysicsOptionTools to be used in this job """ - statusOn = False - allowedTypes = ['str'] - StoredValue = None - - -class PionIndex(JobProperty): - """ - Index for pion decayer configuration. - - Used exclusively in SimuJobTransforms/postOptions.PionDecayer.py - """ - statusOn = False - allowedTypes = ['str'] - StoredValue = None - + statusOn = True + allowedTypes = ['list'] + StoredValue = [] class CavernBG(JobProperty): @@ -291,7 +262,7 @@ class WriteTR(JobProperty): class StoppedParticleFile(JobProperty): """ Enable a fast simulation which kills anything other than SUSY particles - meant to stop in the calorimeter, watches those SUSY particles, and + meant to stop in the calorimeter, watches those SUSY particles, and writes them out when they drop below the magical energy threshold. The value assigned is the name of the file to be written out. @@ -309,26 +280,26 @@ class IncludeParentsInG4Event(JobProperty): allowedTypes = ['bool'] StoredValue = False -class KillAbortedEvents(JobProperty): - """ - If an event is aborted by Geant4 then it should not be written out - to the HITS file. - """ - statusOn = True - allowedTypes = ['bool'] - StoredValue = True - -class FlagAbortedEvents(JobProperty): - """ - If an event is aborted by Geant4 then it should still be written - out to the HITS file, but with the Error flag set in - EventInfo. When this flag is True, KillAbortedEvents should be - False for it to have any effect. - """ - statusOn = True - allowedTypes = ['bool'] +class KillAbortedEvents(JobProperty): + """ + If an event is aborted by Geant4 then it should not be written out + to the HITS file. + """ + statusOn = True + allowedTypes = ['bool'] + StoredValue = True + +class FlagAbortedEvents(JobProperty): + """ + If an event is aborted by Geant4 then it should still be written + out to the HITS file, but with the Error flag set in + EventInfo. When this flag is True, KillAbortedEvents should be + False for it to have any effect. + """ + statusOn = True + allowedTypes = ['bool'] StoredValue = False - + class VertexOverrideFile(JobProperty): """ File name (path) for the file that will perform the vertex override in overlay sim @@ -429,4 +400,3 @@ class TRTRangeCut(JobProperty): allowedTypes = ['float'] allowedValues = [0.05,30.0] StoredValue = 0.05 - diff --git a/Simulation/G4Atlas/G4AtlasApps/python/atlas_mctruth.py b/Simulation/G4Atlas/G4AtlasApps/python/atlas_mctruth.py index c519578710bb9cc9f2969a3f95bb4c0649d9de63..fbf120475ef4de40b78c88f6df1c95c35d334379 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/atlas_mctruth.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/atlas_mctruth.py @@ -147,38 +147,3 @@ class MCTruthStrategies(object): def __init__(self,level=1): self.strg=PyG4Atlas.MCTruthStrg('G4TruthStrategies', 'DMuonCatchAll','MUONQ02::MUONQ02',level) - -class RecordingEnvelopes(object): - """ - Defines the recording envelopes in use in the full ATLAS simulations - - The hits are recorded with the TrackRecorderSD in the - TrackRecordCollection collection. - """ - - class AtlasCaloEntryLayer: - """ Defines the recording envelope AtlasCaloEntryLayer - - Hits in TrackRecordCollection#CaloEntryLayer - (by default it will be applied to level 2 but this is optional) - """ - def __init__(self,level=2,allowMods=False): - self.recenv=PyG4Atlas.RecEnvelope('CaloEntryLayer','IDET::IDET',level,allowMods) - - class AtlasMuonEntryLayer: - """ Defines the recording envelope MuonEntryLayer - - Hits in TrackRecordCollection#MuonEntryLayer - (by default it will be applied to level 2 but this is optional) - """ - def __init__(self,level=2,allowMods=False): - self.recenv=PyG4Atlas.RecEnvelope('MuonEntryLayer','CALO::CALO',level,allowMods) - - class AtlasMuonExitLayer: - """ Defines the recording envelope MuonExitLayer - - Hits in TrackRecordCollection#MuonExitLayer - (by default it will be applied to level 2 but this is optional) - """ - def __init__(self,level=2,allowMods=False): - self.recenv=PyG4Atlas.RecEnvelope('MuonExitLayer','MUONQ02::MUONQ02',level,allowMods) diff --git a/Simulation/G4Atlas/G4AtlasApps/python/ctb_common.py b/Simulation/G4Atlas/G4AtlasApps/python/ctb_common.py index 0d82b5bcbc0602c674466d8fd8e266aa19988bcc..9f5b6363fc3d0c2ce96789ce24ea1a72d46772e2 100644 --- a/Simulation/G4Atlas/G4AtlasApps/python/ctb_common.py +++ b/Simulation/G4Atlas/G4AtlasApps/python/ctb_common.py @@ -965,32 +965,32 @@ larmaterial.df.SetMaterial("Aluminum") #larmaterial_position=AtlasG4Eng.G4Eng.gbl.CLHEP.Hep3Vector(0.,0.,0.) #======================================================================= -class CTBRecordingEnvelopes(object): - """ Defines the recording envelopes in use in the CTB simulations - - The hits are recorded with the TrackRecorderSD in the - TrackRecordCollection collection. - - """ - class CtbCaloEntryLayer: - """ Defines the recording envelope CtbCaloEntryLayer - - Hits in TrackRecordCollection#CaloEntryLayer - """ - def __init__(self): - self.recenv=PyG4Atlas.RecEnvelope('CaloEntryLayer','IDET::IDET',2) - - class LArFarUpstreamMaterialExitLayer: - """ Defines the recording envelope LArFarUpstreamMaterialExitLayer - - Hits in TrackRecordCollection#LArFarUpstreamMaterialExitLayer - """ - def __init__(self,option): - if(option==0): - self.recenv=PyG4Atlas.RecEnvelope('LArFarUpstreamMaterialExitLayer', - 'LARFARUPSTREAMMATERIAL::LARFARUPSTREAMMATERIAL',2) - elif(option==1): - self.recenv=PyG4Atlas.RecEnvelope('LArFarUpstreamMaterialExitLayer', - 'LARFARUPSTREAMMATERIAL::LARFARUPSTREAMMATERIAL',3) - -#======================================================================= +## class CTBRecordingEnvelopes(object): +## """ Defines the recording envelopes in use in the CTB simulations +## +## The hits are recorded with the TrackRecorderSD in the +## TrackRecordCollection collection. +## +## """ +## class CtbCaloEntryLayer: +## """ Defines the recording envelope CtbCaloEntryLayer +## +## Hits in TrackRecordCollection#CaloEntryLayer +## """ +## def __init__(self): +## self.recenv=PyG4Atlas.RecEnvelope('CaloEntryLayer','IDET::IDET',2) +## +## class LArFarUpstreamMaterialExitLayer: +## """ Defines the recording envelope LArFarUpstreamMaterialExitLayer +## +## Hits in TrackRecordCollection#LArFarUpstreamMaterialExitLayer +## """ +## def __init__(self,option): +## if(option==0): +## self.recenv=PyG4Atlas.RecEnvelope('LArFarUpstreamMaterialExitLayer', +## 'LARFARUPSTREAMMATERIAL::LARFARUPSTREAMMATERIAL',2) +## elif(option==1): +## self.recenv=PyG4Atlas.RecEnvelope('LArFarUpstreamMaterialExitLayer', +## 'LARFARUPSTREAMMATERIAL::LARFARUPSTREAMMATERIAL',3) +## +## #======================================================================= diff --git a/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Atlas.py b/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Atlas.py index a4667ab1a611b25cee3805ef3340d5f9d3db1442..74768f899e43f9b832727442948187ae6bc5a447 100644 --- a/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Atlas.py +++ b/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Atlas.py @@ -83,6 +83,9 @@ include('G4AtlasApps/fragment.SimCopyWeights.py') #from TruthExamples.TruthExamplesConf import DumpMC #topSeq += DumpMC() +from AthenaCommon.CfgGetter import getAlgorithm +topSeq += getAlgorithm("BeamEffectsAlg", tryDefaultConfigurable=True) + ## Add the G4 sim to the alg sequence after the generator from G4AtlasApps.PyG4Atlas import PyG4AtlasAlg topSeq += PyG4AtlasAlg() diff --git a/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Atlas_ReadEvgen.py b/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Atlas_ReadEvgen.py index 9d2aab03ec8a94465f40043875a6cc774fcb970d..d6ac16a821df98c8a90622ad7ee108a6f5cdd017 100644 --- a/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Atlas_ReadEvgen.py +++ b/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Atlas_ReadEvgen.py @@ -63,6 +63,9 @@ simFlags.EventFilter.set_On() #simFlags.InitFunctions.add_function("postInit", callbacks.use_simplerunge_stepper) #simFlags.InitFunctions.add_function("postInit", callbacks.use_verbose_tracking) +from AthenaCommon.CfgGetter import getAlgorithm +topSeq += getAlgorithm("BeamEffectsAlg", tryDefaultConfigurable=True) + ## Add the G4 sim to the alg sequence from G4AtlasApps.PyG4Atlas import PyG4AtlasAlg topSeq += PyG4AtlasAlg() diff --git a/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Cosmic.py b/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Cosmic.py index 41ca2d74ca301cd865384fa1fbb0827792d8f8ab..1d0de0ff9d1c7590e13ad63838e4cae8dd61a21a 100644 --- a/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Cosmic.py +++ b/Simulation/G4Atlas/G4AtlasApps/share/jobOptions.G4Cosmic.py @@ -61,6 +61,9 @@ if hasattr(topSeq, 'CosmicGenerator'): ## No magnetic field #simFlags.MagneticField.set_Off() +from AthenaCommon.CfgGetter import getAlgorithm +topSeq += getAlgorithm("BeamEffectsAlg", tryDefaultConfigurable=True) + ## Add alg to alg sequence from G4AtlasApps.PyG4Atlas import PyG4AtlasAlg topSeq += PyG4AtlasAlg()