Example #1
0
def initialiseCoolDataBaseFolder():
    if TrkDetFlags.ConfigurationOutputLevel() < 3 :
      print ('[ Configuration : start ] *** FatrasTrackingGeometry ********************************')
      print ('[ TrackingGeometrySvc ]')

    # check whether the material retrieval is ment to be from COOL
    if TrkDetFlags.MaterialSource() == 'COOL' :
        # 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)

    #HACK: CoolDataBaseFolder may not be set at this point! Is this right? -KG
    return CoolDataBaseFolder
Example #2
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 +
                  '********************************')
Example #3
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