Ejemplo n.º 1
0
    def __init__(self, name=PyG4Atlas_name, sim_module=None):
        """
        name                  --> must be 'PyG4AtlasAlg' (non-hive) or 'PyG4AtlasSvc' (hive)
        sim_module            --> name of a Python module which describes the simulation

        NB. If sim_module is an empty string or None, the sim skeleton contained
        in G4AtlasEng.G4Eng.Dict() will be run.
        """
        super(_PyG4AtlasComp, self).__init__(name=name)
        self.doFirstEventG4SeedsCheck = True  #FIXME - remove for G4Hive?
        self.sim_module = sim_module

        ## If the random number service hasn't been set up already, do it now.
        from G4AtlasApps.SimFlags import simFlags
        simFlags.RandomSeedList.useDefaultSeeds()

        ## Set up the appropriate sim skeleton in the G4 engine
        import AtlasG4Eng
        if "ATLAS" in simFlags.SimLayout():
            from SimAtlasKernel import AtlasSimSkeleton
            AtlasG4Eng.G4Eng.log.info('Configuring ATLAS simulations')
            dummy = AtlasSimSkeleton()
        elif "tb_Tile2000_2003" in simFlags.SimLayout():
            from SimCtbKernel import Tile2000_2003
            AtlasG4Eng.G4Eng.log.info(
                'Configuring old standalone Tile test beams')
            dummy = Tile2000_2003()
        elif "tb_LArH6" in simFlags.SimLayout():
            AtlasG4Eng.G4Eng.log.info('Configuring LAr H6 test beam')
            from SimCtbKernel import LArH6_TB
            dummy = LArH6_TB()
        elif "ctbh8" in simFlags.SimLayout():
            from SimCtbKernel import CtbSim
            AtlasG4Eng.G4Eng.log.info('Configuring CTB H8 (2004) test beam')
            dummy = CtbSim()
        elif "simu_skeleton" not in AtlasG4Eng.G4Eng.Dict:
            AtlasG4Eng.G4Eng.log.error(
                'No sim skeleton registered by time of %s construction: STOP!!'
                % self.name())
            raise ValueError('Unknown sim setup: STOP')

        ## Import sim module if requested
        # TODO: is this ever used?
        if self.sim_module:
            AtlasG4Eng.G4Eng.log.info(
                "The kernel simulation Python module which describes the simulation is: %s"
                % self.sim_module)
            try:
                __import__(self.sim_module, globals(), locals())
            except:
                AtlasG4Eng.G4Eng.log.fatal(
                    "The kernel simulation Python module '%s' was not found!" %
                    self.sim_module)
                raise RuntimeError('PyG4Atlas: %s: initialize()' % self.name())

        ## Call the sim skeleton pre-init method
        AtlasG4Eng.G4Eng.Dict['simu_skeleton']._do_PreInit()

        ## Start profiler
        AtlasG4Eng.G4Eng._app_profiler('PyG4AtlasAlg before initialize')
def getSensitiveDetectorMasterTool(name="SensitiveDetectorMasterTool", **kwargs):
    from G4AtlasApps.SimFlags import simFlags
    if "ATLAS" in simFlags.SimLayout():
        kwargs.setdefault("SensitiveDetectors", generateSensitiveDetectorList())
    elif "tb_Tile2000_2003" in simFlags.SimLayout():
        kwargs.setdefault("SensitiveDetectors", generateTestBeamSensitiveDetectorList())
    elif "tb_LArH6" in simFlags.SimLayout():
        pass
    elif "ctbh8" in simFlags.SimLayout():
        kwargs.setdefault("SensitiveDetectors", generateTestBeamSensitiveDetectorList())
    return CfgMgr.SensitiveDetectorMasterTool(name, **kwargs)
Ejemplo n.º 3
0
def getAthenaStackingActionTool(name='G4UA::AthenaStackingActionTool',
                                **kwargs):
    from G4AtlasApps.SimFlags import simFlags
    ## Killing neutrinos
    if "ATLAS" in simFlags.SimLayout():
        kwargs.setdefault('KillAllNeutrinos', True)
    ## Neutron Russian Roulette
    if hasattr(simFlags, 'ApplyNRR') and simFlags.ApplyNRR.statusOn and \
       hasattr(simFlags, 'NRRThreshold') and simFlags.NRRThreshold.statusOn and \
       hasattr(simFlags, 'NRRWeight') and simFlags.NRRWeight.statusOn:
        if simFlags.CalibrationRun.statusOn:
            raise NotImplementedError(
                "Neutron Russian Roulette should not be used in Calibration Runs."
            )
        kwargs.setdefault('ApplyNRR', simFlags.ApplyNRR.get_Value())
        kwargs.setdefault('NRRThreshold', simFlags.NRRThreshold.get_Value())
        kwargs.setdefault('NRRWeight', simFlags.NRRWeight.get_Value())
    ## Photon Russian Roulette
    if hasattr(simFlags, 'ApplyPRR') and simFlags.ApplyPRR.statusOn and \
       hasattr(simFlags, 'PRRThreshold') and simFlags.PRRThreshold.statusOn and \
       hasattr(simFlags, 'PRRWeight') and simFlags.PRRWeight.statusOn:
        if simFlags.CalibrationRun.statusOn:
            raise NotImplementedError(
                "Photon Russian Roulette should not be used in Calibration Runs."
            )
        kwargs.setdefault('ApplyPRR', simFlags.ApplyPRR.get_Value())
        kwargs.setdefault('PRRThreshold', simFlags.PRRThreshold.get_Value())
        kwargs.setdefault('PRRWeight', simFlags.PRRWeight.get_Value())
    kwargs.setdefault('IsISFJob', simFlags.ISFRun())
    kwargs.setdefault('UseDebugAction',
                      simFlags.DebugStackingAction.get_Value())
    return CfgMgr.G4UA__AthenaStackingActionTool(name, **kwargs)
Ejemplo n.º 4
0
def getAthenaStackingActionTool(name='G4UA::AthenaStackingActionTool',
                                **kwargs):
    from G4AtlasApps.SimFlags import simFlags
    if "ATLAS" in simFlags.SimLayout():
        kwargs.setdefault('KillAllNeutrinos', True)
    kwargs.setdefault('IsISFJob', simFlags.ISFRun())
    return CfgMgr.G4UA__AthenaStackingActionTool(name, **kwargs)
Ejemplo n.º 5
0
def getAthenaTrackingActionTool(name='G4UA::AthenaTrackingActionTool',
                                **kwargs):
    kwargs.setdefault('SecondarySavingLevel', 2)
    subDetLevel = 1
    from AthenaCommon.BeamFlags import jobproperties
    from G4AtlasApps.SimFlags import simFlags
    if "ATLAS" in simFlags.SimLayout() and \
    (jobproperties.Beam.beamType() == 'cosmics' or \
     (simFlags.CavernBG.statusOn and not 'Signal' in simFlags.CavernBG.get_Value() ) ):
        subDetLevel = 2
    kwargs.setdefault('SubDetVolumeLevel', subDetLevel)
    return CfgMgr.G4UA__AthenaTrackingActionTool(name, **kwargs)
Ejemplo n.º 6
0
def getGenParticleFilters():
    genParticleFilterList = []
    genParticleFilterList = ['ISF_ParticleFinalStateFilter'] # not used for Quasi-stable particle simulation
    from G4AtlasApps.SimFlags import simFlags
    if "ATLAS" in simFlags.SimLayout():
        from AthenaCommon.BeamFlags import jobproperties
        if jobproperties.Beam.beamType() != "cosmics":
            genParticleFilterList += ['ISF_ParticlePositionFilterDynamic']
            if (not simFlags.CavernBG.statusOn or simFlags.CavernBG.get_Value() == 'Signal') and\
               not (simFlags.SimulateCavern.statusOn and simFlags.SimulateCavern.get_Value()):
                genParticleFilterList += ['ISF_EtaPhiFilter']
    genParticleFilterList += ['ISF_GenParticleInteractingFilter']
    return genParticleFilterList
def generateTestBeamSensitiveDetectorList():
    SensitiveDetectorList = []
    from G4AtlasApps.SimFlags import simFlags
    from AthenaCommon.DetFlags import DetFlags
    if "tb_Tile2000_2003" in simFlags.SimLayout():
        if DetFlags.simulate.Tile_on():
            from G4AtlasApps.SimFlags import simFlags
            if simFlags.CalibrationRun.statusOn and (
                    simFlags.CalibrationRun.get_Value()
                    in ['Tile', 'LAr+Tile']):
                SensitiveDetectorList += [
                    'TileCTBGeoG4CalibSD'
                ]  # mode 1 : With CaloCalibrationHits
            else:
                SensitiveDetectorList += ['TileCTBGeoG4SD'
                                          ]  # mode 0 : No CaloCalibrationHits
        if DetFlags.simulate.Calo_on():
            SensitiveDetectorList += ['MuonWallSD']
        return SensitiveDetectorList

    if (hasattr(simFlags, "LArFarUpstreamMaterial")
            and simFlags.LArFarUpstreamMaterial.statusOn
            and simFlags.LArFarUpstreamMaterial.get_Value()):
        SensitiveDetectorList += ['LArFarUpstreamMaterialExitLayer']
    from AthenaCommon.DetFlags import DetFlags
    if DetFlags.simulate.pixel_on():
        SensitiveDetectorList += ['PixelSensor_CTB']
    if DetFlags.simulate.SCT_on():
        SensitiveDetectorList += ['SctSensor_CTB']
    if DetFlags.simulate.TRT_on():
        SensitiveDetectorList += ['TRTSensitiveDetector_CTB']
    if DetFlags.simulate.LAr_on():
        SensitiveDetectorList += ['LArEMBSensitiveDetector']
        if simFlags.CalibrationRun.statusOn and (
                'LAr' in simFlags.CalibrationRun.get_Value()):
            SensitiveDetectorList += ['LArH8CalibSensitiveDetector'
                                      ]  # mode 1 : With CaloCalibrationHits
    if DetFlags.simulate.Tile_on():
        from G4AtlasApps.SimFlags import simFlags
        if simFlags.CalibrationRun.statusOn and (
                simFlags.CalibrationRun.get_Value() in ['Tile', 'LAr+Tile']):
            SensitiveDetectorList += ['TileCTBGeoG4CalibSD'
                                      ]  # mode 1 : With CaloCalibrationHits
        else:
            SensitiveDetectorList += ['TileCTBGeoG4SD'
                                      ]  # mode 0 : No CaloCalibrationHits
    if DetFlags.geometry.Muon_on():
        SensitiveDetectorList += ['MuonEntryRecord']
    SensitiveDetectorList += generateMuonSensitiveDetectorList()
    return SensitiveDetectorList
Ejemplo n.º 8
0
def getGeant4SetupCheckerTool(name="G4UA::Geant4SetupCheckerTool", **kwargs):
    # Set reference based on geometry
    from G4AtlasApps.SimFlags import simFlags
    default_file = '/afs/cern.ch/atlas/groups/Simulation/G4config_reference_files/default_reference.txt'
    test_file = '/afs/cern.ch/atlas/groups/Simulation/G4config_reference_files/'
    test_file+=simFlags.SimLayout().replace('_VALIDATION','')+'_reference.txt'
    import os
    if os.access(test_file,os.R_OK): default_file = test_file
    kwargs.setdefault('ReferenceFile',default_file)
    # Grab the properties that were already set
    if name in simFlags.UserActionConfig.get_Value().keys():
        for prop,value in simFlags.UserActionConfig.get_Value()[name].iteritems():
            kwargs.setdefault(prop,value)
    # Set up the user action
    return CfgMgr.G4UA__Geant4SetupCheckerTool(name, **kwargs)