def generateFastSimulationList():
    FastSimulationList=[]
    from G4AtlasApps.SimFlags import simFlags
    from AthenaCommon.DetFlags import DetFlags
    if DetFlags.bpipe_on():
        if simFlags.ForwardDetectors.statusOn and simFlags.ForwardDetectors() == 2:
            FastSimulationList += ['ForwardTransportModel']
        if hasattr(simFlags, 'BeamPipeSimMode') and simFlags.BeamPipeSimMode.statusOn and simFlags.BeamPipeSimMode() != "Normal":
            FastSimulationList += [ 'SimpleFastKiller' ]
    if DetFlags.geometry.LAr_on():
        ## Shower parameterization overrides the calibration hit flag
        if simFlags.LArParameterization.statusOn and simFlags.LArParameterization() > 0 \
                and simFlags.CalibrationRun.statusOn and simFlags.CalibrationRun.get_Value() in ['LAr','LAr+Tile','DeadLAr']:
            print 'getFastSimulationMasterTool FATAL :: You requested both calibration hits and frozen showers / parameterization in the LAr.'
            print '  Such a configuration is not allowed, and would give junk calibration hits where the showers are modified.'
            print '  Please try again with a different value of simFlags.LArParameterization or simFlags.CalibrationRun '
            raise RuntimeError('Configuration not allowed')
        if simFlags.LArParameterization() > 0:
            #FIXME If we're only using Frozen Showers in the FCAL do we really need to set up the EMB and EMEC as well?
            FastSimulationList += ['EMBFastShower', 'EMECFastShower', 'FCALFastShower', 'FCAL2FastShower']
            if simFlags.LArParameterization.get_Value() > 1:
                 FastSimulationList += ['DeadMaterialShower']
        elif simFlags.LArParameterization() is None or simFlags.LArParameterization() == 0:
            print "getFastSimulationMasterTool INFO No Frozen Showers"
    if DetFlags.Muon_on():
        if simFlags.CavernBG.statusOn and simFlags.CavernBG.get_Value() != 'Read':
            FastSimulationList += ['NeutronFastSim']
    return FastSimulationList
    def _initPR(self):
        """ Parameterization of the forward region (if fwd detectors on)
            creates the needed regions and applies the relevant fast sim model
        """
        from G4AtlasApps.SimFlags import simFlags

        ## Speed up simulation of forward plugs on the beam pipe
        if simFlags.BeamPipeSimMode.statusOn and simFlags.BeamPipeSimMode(
        ) != "Normal":
            self.atlas_beampipe_PhysReg = PyG4Atlas.PhysicsReg(
                'BeampipeFwdCut')
            self.atlas_beampipe_PhysReg.add_Volumes('BeamPipe::SectionF47')
            self.atlas_beampipe_PhysReg.add_Volumes('BeamPipe::SectionF48')
            self.atlas_beampipe_PhysReg.add_Volumes('BeamPipe::SectionF61')
            if simFlags.BeamPipeSimMode() == "FastSim":
                self.atlas_beampipe_PhysReg.add_Cuts('e-', 10.)
                self.atlas_beampipe_PhysReg.add_Cuts('e+', 10.)
                self.atlas_beampipe_PhysReg.add_Cuts('gamma', 10.)
                self.beampipe.add_PhysicsReg(self.atlas_beampipe_PhysReg)
                ## Add dead material
                #from AthenaCommon.AppMgr import ServiceMgr
                #if not hasattr(ServiceMgr, 'DeadMaterialFastSimSvc' ):
                #    from LArG4FastSimSvc.LArG4FastSimSvcConfig import DeadMaterialFastSimSvc
                #    ServiceMgr += DeadMaterialFastSimSvc()
                AtlasG4Eng.G4Eng.log.info(
                    'Adding fast sim model to the beampipe!')
            else:
                assert simFlags.BeamPipeCut.statusOn
                if simFlags.BeamPipeCut() < 1:
                    msg = "Setting the forward beam pipe range cuts to %e mm " % simFlags.BeamPipeCut(
                    )
                    msg += "-- cut is < 1 mm, I hope you know what you're doing!"
                    AtlasG4Eng.G4Eng.log.info(msg)
                if simFlags.BeamPipeSimMode() == "EGammaRangeCuts":
                    self.atlas_beampipe_PhysReg.add_Cuts(
                        'e-', simFlags.BeamPipeCut())
                    self.atlas_beampipe_PhysReg.add_Cuts(
                        'e+', simFlags.BeamPipeCut())
                    self.atlas_beampipe_PhysReg.add_Cuts(
                        'gamma', simFlags.BeamPipeCut())
                elif simFlags.BeamPipeSimMode() == "EGammaPRangeCuts":
                    self.atlas_beampipe_PhysReg.add_Cuts(
                        'e-', simFlags.BeamPipeCut())
                    self.atlas_beampipe_PhysReg.add_Cuts(
                        'e+', simFlags.BeamPipeCut())
                    self.atlas_beampipe_PhysReg.add_Cuts(
                        'gamma', simFlags.BeamPipeCut())
                    self.atlas_beampipe_PhysReg.add_Cuts(
                        'proton', simFlags.BeamPipeCut())
                self.beampipe.add_PhysicsReg(self.atlas_beampipe_PhysReg)

        ## Set up the forward transport model
        if simFlags.ForwardDetectors.statusOn and simFlags.ForwardDetectors(
        ) == 2:
            self.atlas_bPipe_PhysReg = PyG4Atlas.PhysicsReg('FWDBeamLine')
            self.atlas_bPipe_PhysReg.add_Volumes('BeamPipe::SectionF46')
            self.beampipe.add_PhysicsReg(self.atlas_bPipe_PhysReg)
示例#3
0
def getATLAS_RegionCreatorList():
    regionCreatorList = []
    from AtlasGeoModel.CommonGMJobProperties import CommonGeometryFlags as commonGeoFlags
    from AtlasGeoModel.InDetGMJobProperties import InDetGeometryFlags as geoFlags
    isUpgrade = commonGeoFlags.Run() == "RUN4" or (
        commonGeoFlags.Run() == "UNDEFINED" and geoFlags.isSLHC())
    isRUN2 = (commonGeoFlags.Run() in [
        "RUN2", "RUN3"
    ]) or (commonGeoFlags.Run() == "UNDEFINED" and geoFlags.isIBL())

    from G4AtlasApps.SimFlags import simFlags
    from AthenaCommon.DetFlags import DetFlags
    if simFlags.SimulateCavern.get_Value():
        regionCreatorList += [
            'SX1PhysicsRegionTool', 'BedrockPhysicsRegionTool',
            'CavernShaftsConcretePhysicsRegionTool'
        ]
        #regionCreatorList += ['CavernShaftsAirPhysicsRegionTool'] # Not used currently
    if DetFlags.ID_on():
        if DetFlags.pixel_on():
            regionCreatorList += ['PixelPhysicsRegionTool']
        if DetFlags.SCT_on():
            regionCreatorList += ['SCTPhysicsRegionTool']
        if DetFlags.TRT_on() and not isUpgrade:
            regionCreatorList += ['TRTPhysicsRegionTool']
            if isRUN2:
                regionCreatorList += ['TRT_ArPhysicsRegionTool'
                                      ]  #'TRT_KrPhysicsRegionTool'
        # FIXME dislike the ordering here, but try to maintain the same ordering as in the old configuration.
        if DetFlags.bpipe_on():
            if simFlags.BeamPipeSimMode.statusOn and simFlags.BeamPipeSimMode(
            ) != "Normal":
                regionCreatorList += ['BeampipeFwdCutPhysicsRegionTool']
            if simFlags.ForwardDetectors.statusOn and simFlags.ForwardDetectors(
            ) == 2:
                regionCreatorList += ['FWDBeamLinePhysicsRegionTool']
    if DetFlags.Calo_on():
        if DetFlags.geometry.LAr_on():
            ## Shower parameterization overrides the calibration hit flag
            if simFlags.LArParameterization.statusOn and simFlags.LArParameterization() > 0 \
                    and simFlags.CalibrationRun.statusOn and simFlags.CalibrationRun.get_Value() in ['LAr','LAr+Tile','DeadLAr']:
                print(
                    'You requested both calibration hits and frozen showers / parameterization in the LAr.'
                )
                print(
                    '  Such a configuration is not allowed, and would give junk calibration hits where the showers are modified.'
                )
                print(
                    '  Please try again with a different value of either simFlags.LArParameterization ('
                    + str(simFlags.LArParameterization()) +
                    ') or simFlags.CalibrationRun (' +
                    str(simFlags.CalibrationRun.get_Value()) + ')')
                raise RuntimeError('Configuration not allowed')
            if simFlags.LArParameterization() > 0:
                regionCreatorList += [
                    'EMBPhysicsRegionTool', 'EMECPhysicsRegionTool',
                    'HECPhysicsRegionTool', 'FCALPhysicsRegionTool'
                ]
                # FIXME 'EMBPhysicsRegionTool' used for parametrization also - do we need a second instance??
                regionCreatorList += [
                    'EMECParaPhysicsRegionTool', 'FCALParaPhysicsRegionTool',
                    'FCAL2ParaPhysicsRegionTool'
                ]
                if simFlags.LArParameterization.get_Value() > 1:
                    regionCreatorList += [
                        'PreSampLArPhysicsRegionTool',
                        'DeadMaterialPhysicsRegionTool'
                    ]
            elif simFlags.LArParameterization(
            ) is None or simFlags.LArParameterization() == 0:
                regionCreatorList += [
                    'EMBPhysicsRegionTool', 'EMECPhysicsRegionTool',
                    'HECPhysicsRegionTool', 'FCALPhysicsRegionTool'
                ]
    ## FIXME _initPR never called for FwdRegion??
    #if simFlags.ForwardDetectors.statusOn:
    #    if DetFlags.geometry.FwdRegion_on():
    #        regionCreatorList += ['FwdRegionPhysicsRegionTool']
    if DetFlags.Muon_on():
        regionCreatorList += [
            'DriftWallPhysicsRegionTool', 'DriftWall1PhysicsRegionTool',
            'DriftWall2PhysicsRegionTool'
        ]
        if simFlags.CavernBG.statusOn and simFlags.CavernBG.get_Value(
        ) != 'Read' and not (simFlags.RecordFlux.statusOn
                             and simFlags.RecordFlux()):
            regionCreatorList += ['MuonSystemFastPhysicsRegionTool']
    return regionCreatorList