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
예제 #2
0
def generateSubDetectorList():
    SubDetectorList = []
    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() ):
        if jobproperties.Beam.beamType() == 'cosmics' and hasattr(
                simFlags, "ReadTR"):
            SubDetectorList += ['CosmicShortCut']
    from AthenaCommon.DetFlags import DetFlags
    if DetFlags.Muon_on():
        SubDetectorList += ['MUONQ02']  #FIXME rename to MUON when safe
    if DetFlags.ID_on():
        SubDetectorList += ['IDET']
    if DetFlags.Calo_on():
        SubDetectorList += ['CALO']
    if DetFlags.ID_on():  #HACK
        if DetFlags.bpipe_on():  #HACK
            SubDetectorList += ['BeamPipe']  #HACK
    if DetFlags.geometry.Lucid_on():
        SubDetectorList += ['Lucid']
    if simFlags.ForwardDetectors.statusOn:
        SubDetectorList += ['ForwardRegion']
    #if DetFlags.Muon_on(): #HACK
    #    SubDetectorList += ['MUONQ02'] #FIXME rename to MUON when safe #HACK
    #SubDetectorList += generateFwdSubDetectorList() #FIXME Fwd Detectors not supported yet.
    return SubDetectorList
예제 #3
0
def getATLAS_FieldMgrList():
    fieldMgrList = []
    from G4AtlasApps.SimFlags import simFlags
    if not simFlags.TightMuonStepping.statusOn or\
       not simFlags.TightMuonStepping():
        fieldMgrList += ['ATLASFieldManager']
    else:
        fieldMgrList += ['TightMuonsATLASFieldManager']

    from AthenaCommon.DetFlags import DetFlags
    if DetFlags.bpipe_on():
        fieldMgrList += ['BeamPipeFieldManager']
    if DetFlags.ID_on():
        fieldMgrList += ['InDetFieldManager']
    if DetFlags.Calo_on(
    ) and simFlags.MuonFieldOnlyInCalo.statusOn and simFlags.MuonFieldOnlyInCalo(
    ):
        fieldMgrList += ['MuonsOnlyInCaloFieldManager']
    if DetFlags.Muon_on():
        fieldMgrList += ['MuonFieldManager']
    if simFlags.ForwardDetectors.statusOn:
        if DetFlags.geometry.FwdRegion_on():
            fieldMgrList += [
                'Q1FwdFieldManager', 'Q2FwdFieldManager', 'Q3FwdFieldManager',
                'D1FwdFieldManager', 'D2FwdFieldManager', 'Q4FwdFieldManager',
                'Q5FwdFieldManager', 'Q6FwdFieldManager', 'Q7FwdFieldManager',
                'Q1HKickFwdFieldManager', 'Q1VKickFwdFieldManager',
                'Q2HKickFwdFieldManager', 'Q2VKickFwdFieldManager',
                'Q3HKickFwdFieldManager', 'Q3VKickFwdFieldManager',
                'Q4VKickAFwdFieldManager', 'Q4HKickFwdFieldManager',
                'Q4VKickBFwdFieldManager', 'Q5HKickFwdFieldManager',
                'Q6VKickFwdFieldManager', 'FwdRegionFieldManager'
            ]
    return fieldMgrList
def generateTrackFastSimSensitiveDetectorList():
    SensitiveDetectorList=[]
    from AthenaCommon.DetFlags import DetFlags
    from G4AtlasApps.SimFlags import simFlags
    if (DetFlags.Muon_on() and simFlags.CavernBG.statusOn and simFlags.CavernBG.get_Value() != 'Read' and 'Write' in simFlags.CavernBG.get_Value()) or (hasattr(simFlags, 'StoppedParticleFile') and simFlags.StoppedParticleFile.statusOn):
        SensitiveDetectorList += [ 'TrackFastSimSD' ]
    return SensitiveDetectorList
def getParticlePositionFilterDynamic(name="ISF_ParticlePositionFilterDynamic", **kwargs):
    # automatically choose the best fitting filter region
    if DetFlags.Muon_on():
      return getParticlePositionFilterWorld(name, **kwargs)
    elif DetFlags.Calo_on():
      return getParticlePositionFilterCalo(name, **kwargs)
    elif DetFlags.ID_on():
      return getParticlePositionFilterID(name, **kwargs)
    else:
      return getParticlePositionFilterWorld(name, **kwargs)
예제 #6
0
def getFatrasGeometryBuilder(name="ISF_FatrasGeometryBuilder", **kwargs):
    # the geometry builder alg tool
    # switch on the Detectors
    #kwargs.setdefault("InDetTrackingGeometry"   , DetFlags.ID_on())
    #kwargs.setdefault("CaloTrackingGeometry"    , DetFlags.Calo_on())
    #kwargs.setdefault("MuonTrackingGeometry"    , DetFlags.Muon_on())
    if DetFlags.ID_on():
        kwargs.setdefault("InDetTrackingGeometryBuilder",getPublicTool('ISF_InDetTrackingGeometryBuilder'))
    if DetFlags.Calo_on():
        kwargs.setdefault("CaloTrackingGeometryBuilder" ,getPublicTool('ISF_FatrasCaloTrackingGeometryBuilder'))
    if DetFlags.Muon_on():
        kwargs.setdefault("MuonTrackingGeometryBuilder" ,getPublicTool('ISF_FatrasMuonTrackingGeometryBuilder'))

    from TrkDetDescrTools.TrkDetDescrToolsConf import Trk__GeometryBuilder
    return Trk__GeometryBuilder(name, **kwargs )
예제 #7
0
def setupMuonCalib():
    global topSequence, ToolSvc
    if not rec.doMuon() or not DetFlags.Muon_on():
        logMuon.warning(
            "Not setting up requested Muon Calibration because Muons are off")
        return

    logMuon.info("Setting up Muon Calibration")
    try:
        from MuonCnvExample.MuonCalibFlags import muonCalibFlags
        muonCalibFlags.setDefaults()

        configs = getCalibConfigs()
        #
        # MuonSegmentToCalibSegment
        #
        calibConfig = muonRec.allConfigs()[0].getCalibConfig(
        )  #muonRec.getConfig(muonCalibFlags.EventTag()).getCalibConfig()
        MuonSegmentToCalibSegment = getMuonSegmentToCalibSegment()
        #
        # MuonCalibAlg
        #
        MuonCalibAlg = getMuonCalibAlg(muonCalibFlags.EventTag())

        from MdtCalibTools.MdtCalibToolsConf import MuonCalib__MdtCalibTool
        MuonCalibTool = MuonCalib__MdtCalibTool()
        calibMode = muonCalibFlags.Mode()
        if calibMode == 'regionNtuple':
            from MdtCalibTools.MdtCalibToolsConf import MuonCalib__MdtCalibNtupleMakerTool
            MdtCalibTool = MuonCalib__MdtCalibNtupleMakerTool()
        else:
            raise RuntimeError("Unknown Muon Calibration Mode: %r" % calibMode)

        ToolSvc += MdtCalibTool
        MuonCalibTool.MdtCalibTool = MdtCalibTool

        ToolSvc += MuonCalibTool
        MuonCalibAlg.MuonCalibTool = MuonCalibTool

    except:
        from AthenaCommon.Resilience import treatException
        treatException(
            "Problem in MuonCalib - Muon Calibration configuration probably incomplete"
        )
예제 #8
0
def getCTB_RegionCreatorList():
    regionCreatorList = []
    from G4AtlasApps.SimFlags import simFlags
    from AthenaCommon.DetFlags import DetFlags
    ## FIXME _initPR never called for SCT??
    #if DetFlags.ID_on():
    #    if DetFlags.geometry.SCT_on():
    #        regionCreatorList += ['SCTSiliconPhysicsRegionTool']
    if DetFlags.Calo_on():
        eta = simFlags.Eta.get_Value()
        if eta >= 0 and eta < 1.201:
            if DetFlags.em_on():
                regionCreatorList += ['EMBPhysicsRegionTool']
    if DetFlags.Muon_on():
        regionCreatorList += [
            'DriftWallPhysicsRegionTool', 'DriftWall1PhysicsRegionTool',
            'DriftWall2PhysicsRegionTool'
        ]
    return regionCreatorList
예제 #9
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
예제 #10
0
#    and different Tag is used
# 
#################################################################################
# import the DetFlags for the setting
from AthenaCommon.DetFlags import DetFlags

CoolDataBaseFolder = '/Indet/TrackingGeo/LayerMaterial'
AtlasMaterialTag   = 'InDetLayerMat_v5_'

# set the CaloTrkGeo if not set --- Calorimeter in Beta Test
if not 'CaloTrkGeo' in dir():
   CaloTrkGeo=DetFlags.Calo_on()

# set the MuonTrkGeo if not set --- Muon System in Prototype state
if not 'MuonTrkGeo' in dir():
   MuonTrkGeo = DetFlags.Muon_on()

# the steering for the CaloEnergyLoss tool
if not 'doCaloTrkEloss' in dir():
  doCaloTrkEloss = False
  
if CaloTrkGeo:
   CoolDataBaseFolder = '/GLOBAL/TrackingGeo/LayerMaterial'
   AtlasMaterialTag   = 'AtlasLayerMat_v5_'

# load the right folders (preparation for calo inclusion)
from IOVDbSvc.CondDB import conddb
if DetFlags.ID_on() and not CaloTrkGeo:
   conddb.addFolder('INDET',CoolDataBaseFolder +'<tag>TagInfo/'+AtlasMaterialTag+'/GeoAtlas</tag>')
if CaloTrkGeo :
   conddb.addFolder('GLOBAL',CoolDataBaseFolder +'<tag>TagInfo/'+AtlasMaterialTag+'/GeoAtlas</tag>')
예제 #11
0
  def __init__(self):
    from AthenaCommon.Include import include
    from AthenaCommon.AppMgr import ToolSvc

    ##################################################################################
    # The FatrasTrackingGeometry Svc fragment
    #
    # usage: 
    #   include('TrkDetDescrSvc/FatrasTrackingGeometrySvc.py')
    #
    #    + for the navigator, set the TrackingGeometryName to:
    #      FatrasTrackingGeometrySvc.trackingGeometryName()
    #
    ##################################################################################
    # import the DetFlags for the setting
    from AthenaCommon.DetFlags import DetFlags

    #################################################################################
    # Material for the Geometry
    #
    # if only ID is switched on different COOLDB Folders
    #    and different Tag is used
    # 
    #################################################################################

    from TrkDetDescrSvc.TrkDetDescrJobProperties import TrkDetFlags
    
    if TrkDetFlags.ConfigurationOutputLevel() < 3 :
      print '[ Configuration : start ] *** FatrasTrackingGeometry ********************************'
      print '[ TrackingGeometrySvc ]'

    # check whether the material retrieval is ment to be from COOL
    if TrkDetFlags.MaterialFromCool() :
        # the tag names
        CoolDataBaseFolder = TrkDetFlags.MaterialStoreGateKey()
        AtlasMaterialTag = TrkDetFlags.MaterialTagBase()+str(TrkDetFlags.MaterialVersion())+'_'

        if TrkDetFlags.ConfigurationOutputLevel() < 3 :
           print '[ TrackingGeometrySvc ] Associating DB folder : ',CoolDataBaseFolder
           print '[ TrackingGeometrySvc ]     base material tag : ',AtlasMaterialTag

        # we need the conditions interface
        from IOVDbSvc.CondDB import conddb
        # use a local database
        if TrkDetFlags.MaterialDatabaseLocal():
            # specify the local database
            DataBasePath  = TrkDetFlags.MaterialDatabaseLocalPath() 
            DataBaseName  = TrkDetFlags.MaterialDatabaseLocalName()
            MagicTag      = TrkDetFlags.MaterialMagicTag()
            DataBaseConnection = '<dbConnection>sqlite://X;schema='+DataBasePath+DataBaseName+';dbname=OFLP200</dbConnection>'
            conddb.blockFolder('/GLOBAL/TrackingGeo/LayerMaterial')
            conddb.addFolderWithTag('',DataBaseConnection+CoolDataBaseFolder,AtlasMaterialTag+MagicTag,force=True)
            if TrkDetFlags.ConfigurationOutputLevel() < 3 :
                print '[ TrackingGeometrySvc ] Using Local Database: '+DataBaseConnection        
            # make sure that the pool files are in the catalog
            #from PoolSvc.PoolSvcConf import PoolSvc
            #PoolSvc.ReadCatalog += [ DataBasePath+'PoolFileCatalog.xml' ]                
        elif TrkDetFlags.SLHC_Geometry() :
            # set the folder to the SLHC location
            CoolDataBaseFolder = '/GLOBAL/TrackingGeo/SLHC_LayerMaterial'
            ctag = AtlasMaterialTag+TrkDetFlags.MaterialMagicTag()
            cfoldertag = CoolDataBaseFolder+' <tag>'+ctag+'</tag>'
            conddb.addFolderSplitMC('GLOBAL',cfoldertag,cfoldertag)
        else :
            # load the right folders (preparation for calo inclusion)
            cfolder = CoolDataBaseFolder +'<tag>TagInfoMajor/'+AtlasMaterialTag+'/GeoAtlas</tag>'
            conddb.addFolderSplitMC('GLOBAL',cfolder,cfolder)

    #################################################################################
    # The Geometry Builder
    #################################################################################

    # the name to register the Geometry
    FatrasTrackingGeometryName = 'FatrasTrackingGeometry'

    # the geometry builder alg tool
    from TrkDetDescrTools.TrkDetDescrToolsConf import Trk__GeometryBuilder
    FatrasGeometryBuilder = Trk__GeometryBuilder(name = 'FatrasGeometryBuilder')
    # switch on the Detectors
    FatrasGeometryBuilder.InDetTrackingGeometry  = DetFlags.ID_on()
    FatrasGeometryBuilder.CaloTrackingGeometry   = DetFlags.Calo_on()
    FatrasGeometryBuilder.MuonTrackingGeometry   = DetFlags.Muon_on() # avoid double building of MTG
    # register it to tool svc
    ToolSvc += FatrasGeometryBuilder

    # (ID) 
    if DetFlags.ID_on() :
      # get hand on the ID Tracking Geometry Builder
      if not TrkDetFlags.SLHC_Geometry() :
        from InDetTrackingGeometry.ConfiguredInDetTrackingGeometryBuilder import ConfiguredInDetTrackingGeometryBuilder as IDGeometryBuilder
      else :
        from InDetTrackingGeometry.ConfiguredSLHC_InDetTrackingGeometryBuilder import ConfiguredSLHC_InDetTrackingGeometryBuilder as IDGeometryBuilder
      if not TrkDetFlags.SLHC_Geometry() :   
        self.__InDetTrackingGeometryBuilder__ = IDGeometryBuilder(name ='InDetTrackingGeometryBuilder',
                                                         namePrefix = 'Fatras',
                                                         setLayerAssociation = False,
                                                         buildTrtStrawLayers = True)
        self.__InDetTrackingGeometryBuilder__.VolumeEnclosureOuterR = 1148.
      else :   
        self.__InDetTrackingGeometryBuilder__ = IDGeometryBuilder(name ='InDetTrackingGeometryBuilder',
                                                         namePrefix = 'Fatras',
                                                         setLayerAssociation = False)
        self.__InDetTrackingGeometryBuilder__.VolumeEnclosureOuterR = 1148.

      # make a public tool out of it
      ToolSvc += self.__InDetTrackingGeometryBuilder__
      # and give it to the Geometry Builder
      FatrasGeometryBuilder.InDetTrackingGeometryBuilder = self.__InDetTrackingGeometryBuilder__
      # 
    # (Calo)
    if DetFlags.Calo_on():
       from CaloTrackingGeometry.ConfiguredCaloTrackingGeometryBuilder import ConfiguredCaloTrackingGeometryBuilder as ConfiguredCaloGeo
       CaloTrackingGeometryBuilder = ConfiguredCaloGeo(name = 'FatrasCaloTrackingGeometryBuilder')
       CaloTrackingGeometryBuilder.RecordLayerIndexCaloSampleMap = True
       # make a publid tool
       ToolSvc += CaloTrackingGeometryBuilder
       # and give it to the Geometry Builder
       FatrasGeometryBuilder.CaloTrackingGeometryBuilder = CaloTrackingGeometryBuilder

    # (Muon)  
    if DetFlags.Muon_on():
       from MuonTrackingGeometry.ConfiguredMuonTrackingGeometry import MuonTrackingGeometryBuilder
       FatrasMuonTrackingGeometryBuilder = MuonTrackingGeometryBuilder(name = 'FatrasMuonTrackingGeometryBuilder')
       FatrasMuonTrackingGeometryBuilder.BarrelZ = 6783.  
       FatrasMuonTrackingGeometryBuilder.InnerBarrelRadius = 4255.  
       ToolSvc += FatrasMuonTrackingGeometryBuilder
       # and give it to the Geometry Builder
       FatrasGeometryBuilder.MuonTrackingGeometryBuilder = FatrasMuonTrackingGeometryBuilder      
  

    # then get the tuning parameters
    from FatrasExample.FatrasTuning import FatrasTuningFlags
    if FatrasTuningFlags.MaterialDistortionsX0.statusOn and \
       FatrasTuningFlags.MaterialDistortionsRho.statusOn :
      from TrkDetDescrSvc.TrkDetDescrSvcConf import CalibrationTrackingGeometrySvc as GeometrySvc
    else :  
      from TrkDetDescrSvc.TrkDetDescrSvcConf import TrackingGeometrySvc as GeometrySvc
    FatrasTrackingGeometrySvc = GeometrySvc(name = 'FatrasTrackingGeometrySvc')

    # register the Builder 
    FatrasTrackingGeometrySvc.GeometryBuilder = FatrasGeometryBuilder
    # and register the name under which the geometry is registered
    FatrasTrackingGeometrySvc.TrackingGeometryName = FatrasTrackingGeometryName
    # global scaling of the material if necessary
    FatrasTrackingGeometrySvc.GlobalScaleFactor = FatrasTuningFlags.MaterialScalor()
    # some flags - only works when ID is on
    FatrasTrackingGeometrySvc.AssignMaterialFromCOOL   = True
    FatrasTrackingGeometrySvc.BuildGeometryFromTagInfo = True
    # Material scaling & distortion
    if FatrasTuningFlags.MaterialDistortionsX0.statusOn and \
       FatrasTuningFlags.MaterialDistortionsRho.statusOn :
       FatrasTrackingGeometrySvc.RandomDistortions          = True
       FatrasTrackingGeometrySvc.DistortionsRadiationLength = FatrasTuningFlags.MaterialDistortionsX0() 
       FatrasTrackingGeometrySvc.DistortionsDensity         = FatrasTuningFlags.MaterialDistortionsRho()
       from FatrasExample.FatrasValidation import FatrasValidationFlags
       FatrasTrackingGeometrySvc.RecordDistortions          = FatrasValidationFlags.MaterialDistortions()
       FatrasTrackingGeometrySvc.DistortionOutputFolder     = '/'+FatrasValidationFlags.ValidationStream()+'/MaterialDistortions'
    # switch to the rigth CoolDB folder 
    FatrasTrackingGeometrySvc.InputLayerMaterialSetName = CoolDataBaseFolder

    from AthenaCommon.AppMgr import ServiceMgr as svcMgr
    svcMgr += FatrasTrackingGeometrySvc

    print '* [ Configuration : start ] *** FatrasTrackingGeometry ********************************'
    print '* [ FatrasTrackingGeometrySvc   ]'
    print FatrasTrackingGeometrySvc
    print '* [ GeometryBuilder       ]'
    print FatrasGeometryBuilder
    print '* [ Configuration : end   ] *** FatrasTrackingGeometry ********************************'

    ##################################################################################    

    self.__geoSvc__ = FatrasTrackingGeometrySvc
예제 #12
0
    def _do_external(self):
        """Place to handle the external services: GeoModel, IOVDb,
           frozen showers, etc
        """
        AtlasG4Eng.G4Eng.log.verbose(
            'AtlasSimSkeleton._do_external :: starting')
        from AthenaCommon.AppMgr import ToolSvc, ServiceMgr
        from Geo2G4.Geo2G4Conf import Geo2G4Svc
        geo2G4Svc = Geo2G4Svc()
        theApp.CreateSvc += ["Geo2G4Svc"]
        ServiceMgr += geo2G4Svc
        ## Enable top transforms for the ATLAS geometry
        geo2G4Svc.GetTopTransform = True

        ## Configure access to the BeamCondSvc if necessary.  Assuming
        ## it should be on always as BeamEffectTransformation is
        ## currently always switched on, else something like this will
        ## be required here.
        from G4AtlasApps.SimFlags import simFlags
        include("InDetBeamSpotService/BeamCondSvc.py")

        ## GeoModel stuff
        ## TODO: Tidy imports etc.
        from GeoModelSvc.GeoModelSvcConf import GeoModelSvc
        from AthenaCommon.GlobalFlags import jobproperties
        from AtlasGeoModel import SetGeometryVersion

        ## Forward Region Twiss files - needed before geometry setup!
        if simFlags.ForwardDetectors.statusOn:
            if DetFlags.geometry.FwdRegion_on():
                from AthenaCommon.CfgGetter import getPublicTool
                from AthenaCommon.AppMgr import ToolSvc
                ToolSvc += getPublicTool("ForwardRegionProperties")

        from AtlasGeoModel import GeoModelInit
        from AtlasGeoModel import SimEnvelopes
        from GeoModelSvc.GeoModelSvcConf import GeoModelSvc
        gms = GeoModelSvc()
        ## Cosmics GeoModel tweaks
        if jobproperties.Beam.beamType() == 'cosmics' or \
           (simFlags.CavernBG.statusOn and not 'Signal' in simFlags.CavernBG.get_Value() ):
            from CavernInfraGeoModel.CavernInfraGeoModelConf import CavernInfraDetectorTool
            gms.DetectorTools += [CavernInfraDetectorTool()]
        ## Protects GeoModelSvc in the simulation from the AlignCallbacks
        gms.AlignCallbacks = False
        ## Muon GeoModel tweaks
        if DetFlags.Muon_on():
            ## Turn off caching in the muon system
            from MuonGeoModel.MuonGeoModelConf import MuonDetectorTool
            MuonDetectorTool = MuonDetectorTool()
            MuonDetectorTool.FillCacheInitTime = 0  # default is 1

            ## Additional material in the muon system
            from AGDD2GeoSvc.AGDD2GeoSvcConf import AGDDtoGeoSvc
            AGDD2Geo = AGDDtoGeoSvc()
            from AthenaCommon import CfgGetter
            if not "MuonAGDDTool/MuonSpectrometer" in AGDD2Geo.Builders:
                ToolSvc += CfgGetter.getPublicTool("MuonSpectrometer",
                                                   checkType=True)
                AGDD2Geo.Builders += ["MuonAGDDTool/MuonSpectrometer"]
            from AtlasGeoModel.MuonGMJobProperties import MuonGeometryFlags
            if (MuonGeometryFlags.hasSTGC() and MuonGeometryFlags.hasMM()):
                if not "NSWAGDDTool/NewSmallWheel" in AGDD2Geo.Builders:
                    ToolSvc += CfgGetter.getPublicTool("NewSmallWheel",
                                                       checkType=True)
                    AGDD2Geo.Builders += ["NSWAGDDTool/NewSmallWheel"]
            theApp.CreateSvc += ["AGDDtoGeoSvc"]
            ServiceMgr += AGDD2Geo

        ## Add configured GeoModelSvc to service manager
        ServiceMgr += gms

        ## Run the geometry envelope setup earlier than GeoSD
        self._do_GeoEnv()  #TODO remove
        AtlasG4Eng.G4Eng.log.verbose('AtlasSimSkeleton._do_external :: done')
예제 #13
0
def getHITSStreamItemList():
    hitsItemList=[]
    ## EventInfo & TruthEvent always written by default
    hitsItemList = ["EventInfo#*",
                    "McEventCollection#TruthEvent",
                    "JetCollection#*"]
    from G4AtlasApps.SimFlags import simFlags
    if simFlags.SimulationFlavour() is not None and 'ongLived' in simFlags.SimulationFlavour(): # to catch LongLived and longLived
        hitsItemList += ["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.
        hitsItemList += ["xAOD::JetContainer_v1#*",
                         "xAOD::JetAuxContainer_v1#*"]
    else:
        hitsItemList += ["xAOD::JetContainer#*",
                           "xAOD::JetAuxContainer#*"]
    ## Detectors
    from AthenaCommon.DetFlags import DetFlags
    ## Inner Detector
    if DetFlags.ID_on():
        hitsItemList += ["SiHitCollection#*",
                         "TRTUncompressedHitCollection#*",
                         "TrackRecordCollection#CaloEntryLayer"]
    ## Calo
    if DetFlags.Calo_on():
        hitsItemList += ["CaloCalibrationHitContainer#*",
                         "LArHitContainer#*",
                         "TileHitVector#*",
                         #"SimpleScintillatorHitCollection#*",
                         "TrackRecordCollection#MuonEntryLayer"]
    ## Muon
    if DetFlags.Muon_on():
        hitsItemList += ["RPCSimHitCollection#*",
                         "TGCSimHitCollection#*",
                         "CSCSimHitCollection#*",
                         "MDTSimHitCollection#*",
                         "TrackRecordCollection#MuonExitLayer"]
    ## FwdRegion
    if DetFlags.FwdRegion_on():
        hitsItemList += ["SimulationHitCollection#*"]

    ## Lucid
    if DetFlags.Lucid_on():
        hitsItemList += ["LUCID_SimHitCollection#*"]

    ## ZDC
    if DetFlags.ZDC_on():
        hitsItemList += ["ZDC_SimPixelHit_Collection#*",
                             "ZDC_SimStripHit_Collection#*"]
    ## ALFA
    if DetFlags.ALFA_on():
        hitsItemList += ["ALFA_HitCollection#*","ALFA_ODHitCollection#*"]

    ## AFP
    if DetFlags.AFP_on():
        hitsItemList += ["AFP_TDSimHitCollection#*","AFP_SIDSimHitCollection#*"]

    ## Ancillary scintillators
    #hitsItemList += ["ScintillatorHitCollection#*"]

    ## TimingAlg
    hitsItemList +=["RecoTimingObj#EVNTtoHITS_timings"]

    if simFlags.RecordStepInfo.get_Value():
        hitsItemList +=["ISF_FCS_Parametrization::FCS_StepInfoCollection#MergedEventSteps"]

    ## add xAOD::TrackParticles output collection Parametric Simulation
    if simFlags.SimulationFlavour == "ParametricSimulation":
        hitsItemList +=["xAOD::TrackParticleContainer#*",
                            "xAOD::TrackParticleAuxContainer#*"]
    ## Add cosmics and test beam configuration hit persistency if required cf. geom tag
    layout = simFlags.SimLayout.get_Value()
    if "tb" not in layout:
        from AthenaCommon.BeamFlags import jobproperties
        if jobproperties.Beam.beamType() == 'cosmics' or \
                (hasattr(simFlags, "WriteTR") and simFlags.WriteTR.statusOn) or \
                (hasattr(simFlags, "ReadTR") and simFlags.ReadTR.statusOn):
            hitsItemList += ["TrackRecordCollection#CosmicRecord", "TrackRecordCollection#CosmicPerigee"]
    else:
        ## CTB-specific
        if layout.startswith("ctb"):
            if simFlags.LArFarUpstreamMaterial.statusOn and simFlags.LArFarUpstreamMaterial.get_Value():
                hitsItemList.append("TrackRecordCollection#LArFarUpstreamMaterialExitLayer")
        ## Persistency of test-beam layout
        if layout.startswith('ctb') or layout.startswith('tb_Tile2000_'):
            hitsItemList += ["TBElementContainer#*"]
    return hitsItemList
예제 #14
0
    def sync_DetFlags(self,technologies="MDT,RPC,CSC,TGC,sTGC,Micromegas"):
        self.setDefaults()
        global rec
        from AthenaCommon.DetFlags import DetFlags
        # if Muons off, then do nothing
        if not DetFlags.Muon_on() or not rec.doMuon(): return

        flagsOn = []
        flagsOff = [ 'readRIOBS' ] # we don't store RIO (=PRD) on bytestream ???
        # Reading RDO
        if rec.readRDO():
            if muonRecFlags.makePRDs():
                flagsOn.append( 'makeRIO' )
            else:
                flagsOff.append( 'makeRIO' )
            if globalflags.InputFormat == 'pool'      :
                flagsOn.append( 'readRDOPool' )
                flagsOff.append( 'readRDOBS' )
            elif globalflags.InputFormat == 'bytestream':
                flagsOn.append( 'readRDOBS'   )
                flagsOff.append( 'readRDOPool' )
        else: # not reading RDO

            flagsOff.append( 'makeRIO' )

        # Reading ESD
        if rec.readESD():
            flagsOn.append( 'readRIOPool' )
        else:
            flagsOff.append( 'readRIOPool' )

        # Writing RDO Pool
        if rec.doWriteRDO():
            flagsOn.append( 'writeRDOPool' )
        else:
            flagsOff.append( 'writeRDOPool' )

        # Writing RDO bystream
        if rec.doWriteBS() :
            flagsOn.append( 'writeBS' )
        else:
            flagsOff.append( 'writeBS' )

        # Writing ESD
        if rec.doWriteESD():
            flagsOn.append( 'writeRIOPool' )
        else:
            flagsOff.append( 'writeRIOPool' )

        # Digitization on-the-fly
        if self.doDigitization():
            flagsOn.append( 'digitize' )
            try:
                flagsOn.remove( 'readRDOPool' )
            except ValueError: # not in list
                pass
            try:
                flagsOn.remove( 'readRDOBS' )
            except ValueError: # not in list
                pass
            flagsOff.append( 'readRDOPool' )
            flagsOff.append( 'readRDOBS'   )
            # very special case for normal Rome production (inspired by RecExCommon_DetFlags.py)
            if 'readRIOPool' not in flagsOn:
                flagsOn.append( 'readRIOPool' )
                try:
                    flagsOff.remove( 'readRIOPool' )
                except ValueError: # not in list
                    pass
            if not rec.doWriteRDO() and 'makeRIO' not in flagsOn:
                flagsOn.append( 'makeRIO' )
                try:
                    flagsOff.remove( 'makeRIO' )
                except ValueError: #not in list
                    pass
                    
        else:
            flagsOff.append( 'digitize')


        # do sync per technology for selected flags
        MDT_on = self.doMDTs()
        RPC_on = self.doRPCs()
        CSC_on = self.doCSCs()
        TGC_on = self.doTGCs()
        sTGC_on = self.dosTGCs()
        Micromegas_on = self.doMicromegas()
        techList = technologies.split(',')
        for f in flagsOn:
            for tech in techList:
                setOn = eval(tech+'_on')
                isOn = eval("DetFlags.%s.%s_on()" % (f,tech))
                if setOn:
                    if not isOn:
                        cmd = "DetFlags.%s.%s_setOn()" % (f,tech)
                        logMuon.info(cmd)
                        exec(cmd)
                else: # set off
                    if isOn:
                        cmd = "DetFlags.%s.%s_setOff()" % (f,tech)
                        logMuon.info(cmd)
                        exec(cmd)

        # Turn off Muon flags (row in DetFlags printout)
        for f in flagsOff:
            isOn = eval("DetFlags.%s.Muon_on()" % f)
            if isOn:
                cmd = "DetFlags.%s.Muon_setOff()" % f
                logMuon.info(cmd)
                exec(cmd)
예제 #15
0
        ToolSvc += getPublicTool("ForwardRegionProperties")

from AtlasGeoModel import GeoModelInit
from AtlasGeoModel import SimEnvelopes
from GeoModelSvc.GeoModelSvcConf import GeoModelSvc

gms = GeoModelSvc()
## Cosmics GeoModel tweaks
if jobproperties.Beam.beamType() == 'cosmics' or \
   (simFlags.CavernBG.statusOn and not 'Signal' in simFlags.CavernBG.get_Value() ):
    from CavernInfraGeoModel.CavernInfraGeoModelConf import CavernInfraDetectorTool
    gms.DetectorTools += [CavernInfraDetectorTool()]
## Protects GeoModelSvc in the simulation from the AlignCallbacks
gms.AlignCallbacks = False
## Muon GeoModel tweaks
if DetFlags.Muon_on():
    ## Turn off caching in the muon system
    from MuonGeoModel.MuonGeoModelConf import MuonDetectorTool
    MuonDetectorTool = MuonDetectorTool()
    MuonDetectorTool.FillCacheInitTime = 0  # default is 1
    if hasattr(simFlags, 'SimulateNewSmallWheel'):
        if simFlags.SimulateNewSmallWheel():
            MuonDetectorTool.StationSelection = 2
            MuonDetectorTool.SelectedStations = ["EIL1"]
            MuonDetectorTool.SelectedStations += ["EIL2"]
            MuonDetectorTool.SelectedStations += ["EIL6"]
            MuonDetectorTool.SelectedStations += ["EIL7"]
            MuonDetectorTool.SelectedStations += ["EIS*"]
            MuonDetectorTool.SelectedStations += ["EIL10"]
            MuonDetectorTool.SelectedStations += ["EIL11"]
            MuonDetectorTool.SelectedStations += ["EIL12"]
예제 #16
0
def setupMuonCalibNtuple():
    global topSequence, muonRecFlags, beamFlags, ToolSvc, rec, DetFlags
    if not rec.doMuon() or not DetFlags.Muon_on():
        logMuon.warning(
            "Not setting up requested Muon Calibration Ntuple because Muons are off"
        )
        return

    logMuon.info("Setting up Muon Calibration Ntuple")
    try:
        configs = getCalibConfigs()
        # MuonSegmentToCalibSegment is only needed if we want segments
        if muonRecFlags.calibNtupleSegments and muonRecFlags.calibMuonStandalone:
            MuonSegmentToCalibSegment = getMuonSegmentToCalibSegment()

        # MuonCalibAlg is always needed
        eventTag = "UNKNOWN"
        if (muonRecFlags.calibNtupleSegments or muonRecFlags.calibNtupleTracks
            ) and muonRecFlags.calibMuonStandalone:
            if len(configs) >= 1:
                eventTag = configs[0]["eventTag"]
        elif muonRecFlags.calibNtupleTrigger:
            eventTag = "TRIG"
        else:
            eventTag = "HITS"

        MuonCalibAlg = getMuonCalibAlg(eventTag)
        # configure for writing ntuple
        from MuonCalibTools.MuonCalibToolsConf import MuonCalib__PatternNtupleMaker
        MuonCalibTool = MuonCalib__PatternNtupleMaker(
            "MuonCalibPatternNtupleMaker")
        MuonCalibTool.FillTruth = rec.doTruth()
        MuonCalibTool.DoRawTGC = (muonRecFlags.doTGCs()
                                  and muonRecFlags.calibNtupleRawTGC())
        ToolSvc += MuonCalibTool
        MuonCalibAlg.MuonCalibTool = MuonCalibTool

        # MuonCalibExtraTree only if we want to write tracks
        if muonRecFlags.calibNtupleTracks:
            MuonCalibTool.DelayFinish = True
            from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__MuonCalibExtraTreeAlg
            MuonCalibExtraTreeAlg = MuonCalib__MuonCalibExtraTreeAlg(
                "MuonCalibExtraTreeAlg",
                NtupleName="PatternNtupleMaker",
            )
            segmentOnTrackSelector = None
            if hasattr(topSequence, "MuonSegmentToCalibSegment"):
                from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__SegmentOnTrackSelector
                segmentOnTrackSelector = MuonCalib__SegmentOnTrackSelector()
                segmentOnTrackSelector.PattternLocation = "PatternsForCalibration"
                ToolSvc += segmentOnTrackSelector
                MuonCalibExtraTreeAlg.SegmentOnTrackSelector = segmentOnTrackSelector
            if not rec.doMuonCombined():
                tool_nr = 0
                from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__ExtraTreeTrackFillerTool
                resPullCalc = getPublicTool("ResidualPullCalculator")
                for config in configs:
                    trackDumpTool = MuonCalib__ExtraTreeTrackFillerTool(
                        "ExtraTreeTrackFillerTool" + str(tool_nr))
                    trackDumpTool.TrackCollectionKey = config['tracksKey']
                    trackDumpTool.SegmentAuthors = [config['segmentAuthor']]
                    trackDumpTool.TrackAuthor = config['trackAuthor']
                    trackDumpTool.PullCalculator = resPullCalc
                    ToolSvc += trackDumpTool
                    MuonCalibExtraTreeAlg.TrackFillerTools.append(
                        trackDumpTool)
                    tool_nr += 1
            # configure needed tools

            # add to topSequence
            topSequence += MuonCalibExtraTreeAlg

        # MuonCalibExtraTreeTriggerAlg only if trigger is available
        if muonRecFlags.calibNtupleTrigger:  # and DetFlags.detdescr.LVL1_on() and DetFlags.haveRDO.LVL1_on():
            # protect against running without AtlasTrigger project
            doMuCTPI = True
            if doMuCTPI:
                try:
                    from TrigT1RPCRecRoiSvc import TrigT1RPCRecRoiConfig
                    from TrigT1TGCRecRoiSvc import TrigT1TGCRecRoiConfig
                except ImportError:
                    logMuon.warning(
                        "MuonCalibExtraTreeTriggerAlg.doMuCTPI = False because AtlasTrigger is not available"
                    )
                    doMuCTPI = False

            # delay writing of MuonCalibAlg
            MuonCalibTool.DelayFinish = True
            # also delay MuonCalibExtraTreeAlg if it is running
            try:
                topSequence.MuonCalibExtraTreeAlg.DelayFinish = True
            except AttributeError:
                pass

            from MuonCalibExtraTreeAlg.MuonCalibExtraTreeAlgConf import MuonCalib__MuonCalibExtraTreeTriggerAlg
            topSequence += MuonCalib__MuonCalibExtraTreeTriggerAlg(
                'MuonCalibExtraTreeTriggerAlg',
                doMuCTPI=doMuCTPI,
                doLVL1Calo=rec.doTile() or rec.doLArg()
                or DetFlags.haveRDO.Calo_on(),
                doMBTS=rec.doTile() or DetFlags.haveRDO.Tile_on())

    except:
        from AthenaCommon.Resilience import treatException
        treatException(
            "Problem in MuonCalib - Muon Calibration Ntuple configuration probably incomplete"
        )
예제 #17
0
def getATLAS(name="Atlas", **kwargs):
    kwargs.setdefault("DetectorName", "Atlas")
    kwargs.setdefault("NSurfaces", 18)
    from G4AtlasApps.SimFlags import simFlags
    from AthenaCommon.BeamFlags import jobproperties
    from AthenaCommon.DetFlags import DetFlags
    ## InnerRadii
    innerRadii = [0.0] * 18
    kwargs.setdefault("InnerRadii", innerRadii)

    ## Shrink the global ATLAS envelope to the activated detectors,
    ## except when running on special setups.

    ## OuterRadii
    AtlasForwardOuterR = 2751.
    AtlasOuterR1 = 14201.
    AtlasOuterR2 = 14201.
    AtlasOuterR3 = 1501.
    if jobproperties.Beam.beamType() != 'cosmics' and not DetFlags.Muon_on() and not \
       (simFlags.CavernBG.statusOn and not 'Signal' in simFlags.CavernBG.get_Value() ):
        AtlasOuterR1 = 4251.
        AtlasOuterR2 = 4251.
        if not DetFlags.Calo_on():
            AtlasOuterR1 = 1150.
            AtlasOuterR2 = 1150.

    outerRadii = [0.0] * 18
    for i in (0, 1, 16, 17):
        outerRadii[i] = 1501.
    for i in (2, 3, 14, 15):
        outerRadii[i] = AtlasForwardOuterR
    for i in (4, 5, 12, 13):
        outerRadii[i] = AtlasOuterR2
    for i in xrange(6, 12):
        outerRadii[i] = AtlasOuterR1

    ## World R range
    if simFlags.WorldRRange.statusOn:
        if simFlags.WorldRRange.get_Value() > max(AtlasOuterR1, AtlasOuterR2):
            routValue = simFlags.WorldRRange.get_Value()
            for i in xrange(4, 14):
                outerRadii[i] = routValue
        else:
            raise RuntimeError(
                'getATLASEnvelope: ERROR simFlags.WorldRRange must be > %f. Current value %f'
                % max(AtlasOuterR1, AtlasOuterR2), routValue)
    kwargs.setdefault("OuterRadii", outerRadii)

    ## ZSurfaces
    zSurfaces = [
        -26046., -23001., -23001., -22031., -22031., -12899., -12899., -6741.,
        -6741., 6741., 6741., 12899., 12899., 22031., 22031., 23001., 23001.,
        26046.
    ]  # FIXME units mm??

    if simFlags.ForwardDetectors.statusOn:
        zSurfaces[0] = -400000.
        zSurfaces[17] = 400000.

    if simFlags.WorldZRange.statusOn:
        if simFlags.WorldZRange.get_Value() < 26046.:
            AtlasG4Eng.G4Eng.log.error('')
            raise RuntimeError(
                'getATLASEnvelope: ERROR simFlags.WorldZRange must be > 26046. Current value: %f'
                % simFlags.WorldZRange.get_Value())
        zSurfaces[17] = simFlags.WorldZRange.get_Value() + 100.
        zSurfaces[16] = simFlags.WorldZRange.get_Value() + 50.
        zSurfaces[15] = simFlags.WorldZRange.get_Value() + 50.
        zSurfaces[14] = simFlags.WorldZRange.get_Value()
        zSurfaces[13] = simFlags.WorldZRange.get_Value()
        zSurfaces[0] = -simFlags.WorldZRange.get_Value() - 100.
        zSurfaces[1] = -simFlags.WorldZRange.get_Value() - 50.
        zSurfaces[2] = -simFlags.WorldZRange.get_Value() - 50.
        zSurfaces[3] = -simFlags.WorldZRange.get_Value()
        zSurfaces[4] = -simFlags.WorldZRange.get_Value()
    kwargs.setdefault("ZSurfaces", zSurfaces)
    kwargs.setdefault("SubDetectors", generateSubDetectorList())
    return CfgMgr.PolyconicalEnvelope(name, **kwargs)
예제 #18
0
    def __init__(self, name='AtlasTrackingGeometrySvc'):

        if TrkDetFlags.ConfigurationOutputLevel() < 3:
            print('[ Configuration : start ] *** ' + name +
                  ' ********************************')
            print('[ TrackingGeometrySvc ]')

        from AthenaCommon.AppMgr import ToolSvc

        #################################################################################
        # The Geometry Builder
        #################################################################################

        # the name to register the Geometry
        AtlasTrackingGeometryName = 'AtlasTrackingGeometry'

        # the geometry builder alg tool
        from TrkDetDescrTools.TrkDetDescrToolsConf import Trk__GeometryBuilder
        AtlasGeometryBuilder = Trk__GeometryBuilder(
            name='AtlasGeometryBuilder')
        # switch the building outputlevel on
        AtlasGeometryBuilder.OutputLevel = TrkDetFlags.ConfigurationOutputLevel(
        )

        # the envelope definition service
        from AthenaCommon.CfgGetter import getPrivateTool,getPrivateToolClone,getPublicTool,getPublicToolClone,\
           getService,getServiceClone,getAlgorithm,getAlgorithmClone
        AtlasEnvelopeSvc = getService('AtlasGeometry_EnvelopeDefSvc')

        # (ID)
        if DetFlags.ID_on():
            # get hand on the ID Tracking Geometry Builder
            if TrkDetFlags.ISF_FatrasCustomGeometry():
                if hasattr(ToolSvc,
                           TrkDetFlags.ISF_FatrasCustomGeometryBuilderName()):
                    InDetTrackingGeometryBuilder = getattr(
                        ToolSvc,
                        TrkDetFlags.ISF_FatrasCustomGeometryBuilderName())
            elif TrkDetFlags.XMLFastCustomGeometry():
                if hasattr(ToolSvc,
                           TrkDetFlags.InDetTrackingGeometryBuilderName()):
                    InDetTrackingGeometryBuilder = getattr(
                        ToolSvc,
                        TrkDetFlags.InDetTrackingGeometryBuilderName())
            else:
                if not TrkDetFlags.SLHC_Geometry(
                ) and not TrkDetFlags.InDetStagedGeometryBuilder():
                    from InDetTrackingGeometry.ConfiguredInDetTrackingGeometryBuilder import ConfiguredInDetTrackingGeometryBuilder as IDGeometryBuilder
                elif not TrkDetFlags.SLHC_Geometry():
                    from InDetTrackingGeometry.ConfiguredStagedTrackingGeometryBuilder import ConfiguredStagedTrackingGeometryBuilder as IDGeometryBuilder
                else:
                    from InDetTrackingGeometry.ConfiguredSLHC_InDetTrackingGeometryBuilder import ConfiguredSLHC_InDetTrackingGeometryBuilder as IDGeometryBuilder
                InDetTrackingGeometryBuilder = IDGeometryBuilder(
                    name='InDetTrackingGeometryBuilder')

            InDetTrackingGeometryBuilder.EnvelopeDefinitionSvc = AtlasEnvelopeSvc
            InDetTrackingGeometryBuilder.OutputLevel = TrkDetFlags.InDetBuildingOutputLevel(
            )
            # and give it to the Geometry Builder
            AtlasGeometryBuilder.InDetTrackingGeometryBuilder = InDetTrackingGeometryBuilder
            #
        # (Calo)
        if DetFlags.Calo_on():
            from TrkDetDescrTools.TrkDetDescrToolsConf import Trk__CylinderVolumeCreator
            CaloVolumeCreator = Trk__CylinderVolumeCreator("CaloVolumeCreator")
            CaloVolumeCreator.OutputLevel = TrkDetFlags.CaloBuildingOutputLevel(
            )
            ToolSvc += CaloVolumeCreator

            from CaloTrackingGeometry.ConfiguredCaloTrackingGeometryBuilder import ConfiguredCaloTrackingGeometryBuilder as ConfiguredCaloGeo
            CaloTrackingGeometryBuilder = ConfiguredCaloGeo(
                name='CaloTrackingGeometryBuilder')
            CaloTrackingGeometryBuilder.TrackingVolumeCreator = CaloVolumeCreator
            CaloTrackingGeometryBuilder.EnvelopeDefinitionSvc = AtlasEnvelopeSvc
            CaloTrackingGeometryBuilder.OutputLevel = TrkDetFlags.CaloBuildingOutputLevel(
            )
            CaloTrackingGeometryBuilder.GeometryName = 'Calo'
            # and give it to the Geometry Builder
            AtlasGeometryBuilder.CaloTrackingGeometryBuilder = CaloTrackingGeometryBuilder

        # (Muon)
        if DetFlags.Muon_on():
            from MuonTrackingGeometry.ConfiguredMuonTrackingGeometry import MuonTrackingGeometryBuilder
            MuonTrackingGeometryBuilder.EnvelopeDefinitionSvc = AtlasEnvelopeSvc
            # and give it to the Geometry Builder
            AtlasGeometryBuilder.MuonTrackingGeometryBuilder = MuonTrackingGeometryBuilder

        # processors
        AtlasGeometryProcessors = []

        # check whether the material retrieval is ment to be from COOL
        if TrkDetFlags.MaterialSource() is 'COOL':
            # the material provider
            from TrkDetDescrTools.TrkDetDescrToolsConf import Trk__LayerMaterialProvider as LayerMaterialProvider
            AtlasMaterialProvider = LayerMaterialProvider(
                'AtlasMaterialProvider')
            AtlasMaterialProvider.OutputLevel = TrkDetFlags.ConfigurationOutputLevel(
            )
            AtlasMaterialProvider.LayerMaterialMapName = TrkDetFlags.MaterialStoreGateKey(
            )

            AtlasGeometryProcessors += [AtlasMaterialProvider]

            # the tag names
            CoolDataBaseFolder = TrkDetFlags.MaterialStoreGateKey()
            AtlasMaterialTag = TrkDetFlags.MaterialTagBase() + str(
                TrkDetFlags.MaterialVersion(
                )) + TrkDetFlags.MaterialSubVersion() + '_'

            if TrkDetFlags.ConfigurationOutputLevel() < 3:
                print('[ TrackingGeometrySvc ] Associating DB folder : ',
                      CoolDataBaseFolder)

            # we need the conditions interface
            from IOVDbSvc.CondDB import conddb
            # use a local database
            if TrkDetFlags.MaterialDatabaseLocal():
                # specify the local database
                DataBasePath = TrkDetFlags.MaterialDatabaseLocalPath()
                DataBaseName = TrkDetFlags.MaterialDatabaseLocalName()
                MagicTag = TrkDetFlags.MaterialMagicTag()
                DataBaseConnection = '<dbConnection>sqlite://X;schema=' + DataBasePath + DataBaseName + ';dbname=OFLP200</dbConnection>'
                conddb.blockFolder('/GLOBAL/TrackingGeo/LayerMaterialV2')
                conddb.addFolderWithTag('',
                                        DataBaseConnection +
                                        CoolDataBaseFolder,
                                        AtlasMaterialTag + MagicTag,
                                        force=True)
                if TrkDetFlags.ConfigurationOutputLevel() < 3:
                    print('[ TrackingGeometrySvc ] Using Local Database: ' +
                          DataBaseConnection)
                # make sure that the pool files are in the catalog
            elif TrkDetFlags.SLHC_Geometry():
                # set the folder to the SLHC location
                CoolDataBaseFolder = '/GLOBAL/TrackingGeo/LayerMaterialITK'
                ctag = AtlasMaterialTag + TrkDetFlags.MaterialMagicTag()
                cfoldertag = CoolDataBaseFolder + ' <tag>' + ctag + '</tag>'
                conddb.addFolderSplitMC('GLOBAL', cfoldertag, cfoldertag)
            else:
                print('[ TrackingGeometrySvc ]     base material tag : ',
                      AtlasMaterialTag)
                cfolder = CoolDataBaseFolder + '<tag>TagInfoMajor/' + AtlasMaterialTag + '/GeoAtlas</tag>'
                print('[ TrackingGeometrySvc ]     translated to COOL: ',
                      cfolder)
                # load the right folders (preparation for calo inclusion)
                conddb.addFolderSplitMC('GLOBAL', cfolder, cfolder)

        elif TrkDetFlags.MaterialSource() is 'Input':
            # the material provider
            from TrkDetDescrTools.TrkDetDescrToolsConf import Trk__InputLayerMaterialProvider
            AtlasMaterialProvider = Trk__InputLayerMaterialProvider(
                'AtlasMaterialProvider')
            AtlasMaterialProvider.OutputLevel = TrkDetFlags.ConfigurationOutputLevel(
            )
            AtlasGeometryProcessors += [AtlasMaterialProvider]

        # material validation
        if TrkDetFlags.MaterialValidation():
            # load the material inspector
            from TrkDetDescrTestTools.TrkDetDescrTestToolsConf import Trk__LayerMaterialInspector
            AtlasLayerMaterialInspector = Trk__LayerMaterialInspector(
                'AtlasLayerMaterialInspector')
            AtlasLayerMaterialInspector.OutputLevel = TrkDetFlags.ConfigurationOutputLevel(
            )

            AtlasGeometryProcessors += [AtlasLayerMaterialInspector]

        # call the base class constructor : sets the tools
        Trk__TrackingGeometrySvc.__init__(self,name,\
                                          GeometryBuilder = AtlasGeometryBuilder,\
                                          TrackingGeometryName = AtlasTrackingGeometryName,\
                                          GeometryProcessors = AtlasGeometryProcessors, \
                                          BuildGeometryFromTagInfo = True,\
                                          OutputLevel = TrkDetFlags.ConfigurationOutputLevel())

        # screen output of the configuration
        if TrkDetFlags.ConfigurationOutputLevel() < 3:
            print(self)
            print('* [ GeometryBuilder       ]')
            print(AtlasGeometryBuilder)
            print('* [ Configuration : end   ] ***' + name +
                  '********************************')
예제 #19
0
from AthenaCommon.DetFlags import DetFlags
DetFlags.ID_setOn()
# --- no TRT for SLHC
DetFlags.TRT_setOff()
DetFlags.detdescr.TRT_setOff()
DetFlags.makeRIO.TRT_setOff()
# Calo and Muon off for SLHC
DetFlags.Calo_setOff()
DetFlags.Muon_setOff()

#from GeoModelSvc.GeoModelSvcConf import GeoModelSvc
#GeoModelSvc.InDetVersionOverride="InnerDetector-SLHC-00"

from FastSimulationConfig.FastSimulationFlags import jobproperties
jobproperties.FastSimulation.doFatrasID   = DetFlags.ID_on()
jobproperties.FastSimulation.doFatrasMuon = DetFlags.Muon_on()

# run additional fast calo sim
FatrasFlags.FastCaloSim = False

#--------------------------------------------------------------
# load Global Flags and set defaults (import the new jobProperty globalflags)
#--------------------------------------------------------------

from AthenaCommon.GlobalFlags import globalflags
# --- default is atlas geometry
globalflags.DetGeo = 'atlas'
# --- set defaults
globalflags.DataSource = 'geant4'
# --- input is pool for SLHC 
globalflags.InputFormat = 'pool'
예제 #20
0
    def hits_persistency():
        """ HITS POOL file persistency
        """
        from G4AtlasApps.SimFlags import simFlags
        from AthenaCommon.DetFlags import DetFlags
        from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
        from AthenaPoolCnvSvc.WriteAthenaPool import AthenaPoolOutputStream

        ## Not yet understood, but need to treat StreamHITS as alg in Hive.
        ## Seems to also work fine outside of Hive, but to be extra safe I'm
        ## only changing it in Hive.
        from AthenaCommon.ConcurrencyFlags import jobproperties as concurrencyProps
        if concurrencyProps.ConcurrencyFlags.NumThreads() > 0:
            as_alg = True
        else:
            as_alg = False
        ## NB. Two-arg constructor is needed, since otherwise metadata writing fails!
        stream1 = AthenaPoolOutputStream("StreamHITS",
                                         athenaCommonFlags.PoolHitsOutput(),
                                         asAlg=as_alg)

        ## Write geometry tag info - move to main method
        #import EventInfoMgt.EventInfoMgtInit

        ## EventInfo & TruthEvent always written by default
        stream1.ForceRead = True
        stream1.ItemList = [
            "EventInfo#*", "McEventCollection#TruthEvent", "JetCollection#*"
        ]

        ## If we are running quasi-stable particle simulation, include the original event record
        if hasattr(
                simFlags, 'IncludeParentsInG4Event'
        ) and simFlags.IncludeParentsInG4Event.statusOn and simFlags.IncludeParentsInG4Event(
        ):
            stream1.ItemList += ["McEventCollection#GEN_EVENT"]

        stream1.ItemList += ["xAOD::JetContainer#*", "xAOD::JetAuxContainer#*"]

        ## Make stream aware of aborted events
        stream1.AcceptAlgs = ["G4AtlasAlg"]

        ## Detectors

        ## Inner Detector
        if DetFlags.ID_on():
            stream1.ItemList += [
                "SiHitCollection#*", "TRTUncompressedHitCollection#*",
                "TrackRecordCollection#CaloEntryLayer"
            ]
        ## Calo
        if DetFlags.Calo_on():
            stream1.ItemList += [
                "CaloCalibrationHitContainer#*",
                "LArHitContainer#*",
                "TileHitVector#*",
                #"SimpleScintillatorHitCollection#*",
                "TrackRecordCollection#MuonEntryLayer"
            ]
        ## Muon
        if DetFlags.Muon_on():
            stream1.ItemList += [
                "RPCSimHitCollection#*", "TGCSimHitCollection#*",
                "CSCSimHitCollection#*", "MDTSimHitCollection#*",
                "TrackRecordCollection#MuonExitLayer"
            ]
            if hasattr(simFlags, 'SimulateNewSmallWheel'):
                if simFlags.SimulateNewSmallWheel():
                    stream1.ItemList += ["GenericMuonSimHitCollection#*"]
        ## Lucid
        if DetFlags.Lucid_on():
            stream1.ItemList += ["LUCID_SimHitCollection#*"]

        ## FwdRegion
        if DetFlags.FwdRegion_on():
            stream1.ItemList += ["SimulationHitCollection#*"]

        ## ZDC
        if DetFlags.ZDC_on():
            stream1.ItemList += [
                "ZDC_SimPixelHit_Collection#*", "ZDC_SimStripHit_Collection#*"
            ]
        ## ALFA
        if DetFlags.ALFA_on():
            stream1.ItemList += [
                "ALFA_HitCollection#*", "ALFA_ODHitCollection#*"
            ]

        ## AFP
        if DetFlags.AFP_on():
            stream1.ItemList += [
                "AFP_TDSimHitCollection#*", "AFP_SIDSimHitCollection#*"
            ]

        ### Ancillary scintillators
        #stream1.ItemList += ["ScintillatorHitCollection#*"]

        ## TimingAlg
        stream1.ItemList += ["RecoTimingObj#EVNTtoHITS_timings"]

        ## Add cosmics and test beam configuration hit persistency if required cf. geom tag
        layout = simFlags.SimLayout.get_Value()
        if "tb" not in layout:
            from AthenaCommon.BeamFlags import jobproperties
            if jobproperties.Beam.beamType() == 'cosmics' or \
                    (hasattr(simFlags, "WriteTR") and simFlags.WriteTR.statusOn) or \
                    (hasattr(simFlags, "ReadTR") and simFlags.ReadTR.statusOn):
                stream1.ItemList += [
                    "TrackRecordCollection#CosmicRecord",
                    "TrackRecordCollection#CosmicPerigee"
                ]
        else:
            ## CTB-specific
            if layout.startswith("ctb"):
                if simFlags.LArFarUpstreamMaterial.statusOn and simFlags.LArFarUpstreamMaterial.get_Value(
                ):
                    stream1.ItemList.append(
                        "TrackRecordCollection#LArFarUpstreamMaterialExitLayer"
                    )
            ## Persistency of test-beam layout
            if layout.startswith('ctb') or layout.startswith('tb_Tile2000_'):
                stream1.ItemList += ["TBElementContainer#*"]
예제 #21
0
    def __init__(self, layout):
        """
        Describes the geometry.
        """

        self.AtlasForwardOuterR = 2751.
        self.AtlasOuterR1 = 13911.
        self.AtlasOuterR2 = 13911.
        self.AtlasOuterR3 = 1501.
        from G4AtlasApps.SimFlags import simFlags
        from AthenaCommon.BeamFlags import jobproperties
        from AthenaCommon.DetFlags import DetFlags
        ## Shrink the global ATLAS envelope to the activated detectors, except when running on special setups.
        if jobproperties.Beam.beamType() != 'cosmics' and not DetFlags.Muon_on() and not \
           (simFlags.CavernBG.statusOn and not 'Signal' in simFlags.CavernBG.get_Value() ):
            self.AtlasOuterR1 = 4251.
            self.AtlasOuterR2 = 4251.
            if not DetFlags.Calo_on():
                self.AtlasOuterR1 = 1150.
                self.AtlasOuterR2 = 1150.
        AtlasG4Eng.G4Eng.log.debug(
            'Creating Atlas envelope with outer radii %d, %d' %
            (self.AtlasOuterR1, self.AtlasOuterR2))

        self.atlas = PyG4Atlas.DetFacility("GenericPCON", "Atlas")
        self.atlas.df.SetPhiMin(math.radians(0))
        self.atlas.df.SetDeltaPhi(math.radians(360))
        self.atlas.df.SetNSurfaces(18)
        self.atlas.df.SetZSurface(0, -26046.)
        self.atlas.df.SetZSurface(1, -23001.)
        self.atlas.df.SetZSurface(2, -23001.)
        self.atlas.df.SetZSurface(3, -22031.)
        self.atlas.df.SetZSurface(4, -22031.)
        self.atlas.df.SetZSurface(5, -12899.)
        self.atlas.df.SetZSurface(6, -12899.)
        self.atlas.df.SetZSurface(7, -6741.)
        self.atlas.df.SetZSurface(8, -6741.)
        self.atlas.df.SetZSurface(9, 6741.)
        self.atlas.df.SetZSurface(10, 6741.)
        self.atlas.df.SetZSurface(11, 12899.)
        self.atlas.df.SetZSurface(12, 12899.)
        self.atlas.df.SetZSurface(13, 22031.)
        self.atlas.df.SetZSurface(14, 22031.)
        self.atlas.df.SetZSurface(15, 23001.)
        self.atlas.df.SetZSurface(16, 23001.)
        self.atlas.df.SetZSurface(17, 26046.)

        if simFlags.ForwardDetectors.statusOn:
            self.atlas.df.SetZSurface(0, -400000.)
            self.atlas.df.SetZSurface(17, 400000.)

        if simFlags.WorldZRange.statusOn:
            if simFlags.WorldZRange.get_Value() < 26046.:
                AtlasG4Eng.G4Eng.log.error('WorldZRange must be > 26046.')
                raise RuntimeError(
                    'atlas_common: found problems with the Z World volume range: %f'
                    % simFlags.WorldZRange.get_Value())
            self.atlas.df.SetZSurface(17,
                                      simFlags.WorldZRange.get_Value() + 100.)
            self.atlas.df.SetZSurface(16,
                                      simFlags.WorldZRange.get_Value() + 50.)
            self.atlas.df.SetZSurface(15,
                                      simFlags.WorldZRange.get_Value() + 50.)
            self.atlas.df.SetZSurface(14, simFlags.WorldZRange.get_Value())
            self.atlas.df.SetZSurface(13, simFlags.WorldZRange.get_Value())
            self.atlas.df.SetZSurface(0,
                                      -simFlags.WorldZRange.get_Value() - 100.)
            self.atlas.df.SetZSurface(1,
                                      -simFlags.WorldZRange.get_Value() - 50.)
            self.atlas.df.SetZSurface(2,
                                      -simFlags.WorldZRange.get_Value() - 50.)
            self.atlas.df.SetZSurface(3, -simFlags.WorldZRange.get_Value())
            self.atlas.df.SetZSurface(4, -simFlags.WorldZRange.get_Value())
            AtlasG4Eng.G4Eng.log.debug(
                'Increasing the Z World ATLAS envelope to %f' %
                simFlags.WorldZRange.get_Value())

        ## Set inner (all zero) and outer radii
        for i in xrange(0, 18):
            self.atlas.df.SetRinSurface(i, 0.0)
        for i in (0, 1, 16, 17):
            self.atlas.df.SetRouSurface(i, 1501.)
        for i in (2, 3, 14, 15):
            self.atlas.df.SetRouSurface(i, self.AtlasForwardOuterR)
        for i in (4, 5, 12, 13):
            self.atlas.df.SetRouSurface(i, self.AtlasOuterR2)
        for i in xrange(6, 12):
            self.atlas.df.SetRouSurface(i, self.AtlasOuterR1)

        ## World R range
        if simFlags.WorldRRange.statusOn:
            if simFlags.WorldRRange.get_Value() > max(self.AtlasOuterR1,
                                                      self.AtlasOuterR2):
                routValue = simFlags.WorldRRange.get_Value()
                for i in xrange(4, 14):
                    self.atlas.df.SetRouSurface(i, routValue)
                AtlasG4Eng.G4Eng.log.debug(
                    'Increasing the ATLAS World envelope R value to %f' %
                    routValue)
            else:
                AtlasG4Eng.G4Eng.log.error(
                    'WorldRRange must be > %f' %
                    max(self.AtlasOuterR1, self.AtlasOuterR2))
                raise RuntimeError(
                    'atlas_common: found problems with the R World volume range %f'
                    % routValue)