diff --git a/Trigger/EFTracking/FPGATrackSim/FPGATrackSimConfTools/CMakeLists.txt b/Trigger/EFTracking/FPGATrackSim/FPGATrackSimConfTools/CMakeLists.txt index 424e6a29997661c879fe3b3dc377d83829dfe036..e275488f97e1f779d1f6a86657f92e2435a971ba 100755 --- a/Trigger/EFTracking/FPGATrackSim/FPGATrackSimConfTools/CMakeLists.txt +++ b/Trigger/EFTracking/FPGATrackSim/FPGATrackSimConfTools/CMakeLists.txt @@ -1,4 +1,4 @@ - # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration + # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration # Declare the package name: atlas_subdir( FPGATrackSimConfTools ) @@ -35,10 +35,6 @@ atlas_add_test( FPGATrackSimRegionSlices_test INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} LINK_LIBRARIES ${ROOT_LIBRARIES} FPGATrackSimConfToolsLib ) -atlas_add_test( FPGATrackSimEventSelectionSvc_test - SCRIPT python -m FPGATrackSimConfTools.FPGATrackSimConfigCompInit - POST_EXEC_SCRIPT noerror.sh ) - atlas_add_test( FPGATrackSimConfigFlags_test SCRIPT python -m FPGATrackSimConfTools.FPGATrackSimConfigFlags POST_EXEC_SCRIPT noerror.sh ) diff --git a/Trigger/EFTracking/FPGATrackSim/FPGATrackSimConfTools/python/FPGATrackSimConfigCompInit.py b/Trigger/EFTracking/FPGATrackSim/FPGATrackSimConfTools/python/FPGATrackSimConfigCompInit.py deleted file mode 100644 index a88cdecd9fc2b5cf31a8320c87200ae1b166a701..0000000000000000000000000000000000000000 --- a/Trigger/EFTracking/FPGATrackSim/FPGATrackSimConfTools/python/FPGATrackSimConfigCompInit.py +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration -''' -@author Riley Xu - riley.xu@cern.ch -@date Feb 23rd 2021 -@brief This file declares functions to configure FPGATrackSimConfig components -''' - -def getRegionIndex(map_tag): - ''' - Note the region member of the tag is a string - ''' - try: - return int(map_tag['region']) - except ValueError: - return map_tag['regionNames'].index(map_tag['region']) - -def getRegionName(map_tag): - return map_tag['regionNames'][getRegionIndex(map_tag)] - -def getSampleType(map_tag): - return map_tag['sampleType'] - -def getWithPU(map_tag): - return map_tag['withPU'] - -def addEvtSelSvc(map_tag,name=""): - ''' - Creates and returns a FPGATrackSimEventSelectionSvc object, configured with the specified tags. - This function adds the returned map service instance to SvcMgr. - ''' - from AthenaCommon.Constants import INFO - - import FPGATrackSimConfTools.FPGATrackSimConfToolsConf as Config - if name : - ES = Config.FPGATrackSimEventSelectionSvc(name) - else : - ES = Config.FPGATrackSimEventSelectionSvc() - ES.regionID = getRegionIndex(map_tag) - ES.regions = map_tag['slices'] - ES.sampleType = getSampleType(map_tag) - ES.withPU = getWithPU(map_tag) - ES.OutputLevel=INFO - - from AthenaCommon.AppMgr import ServiceMgr - #global ServiceMgr - ServiceMgr += ES - return ES - - -if __name__=='__main__': - from AthenaCommon.Logging import log - from AthenaCommon.Constants import DEBUG - log.setLevel(DEBUG) - - import FPGATrackSimConfTools.FPGATrackSimTagConfig as FPGATrackSimTagConfig - tags = FPGATrackSimTagConfig.getTags(stage='bank') - map_tag = tags['map'] - ES = addEvtSelSvc(map_tag) - ES.sampleType="singleMuons" - - print(ES) - diff --git a/Trigger/EFTracking/FPGATrackSim/FPGATrackSimMaps/python/FPGATrackSimMapConfig.py b/Trigger/EFTracking/FPGATrackSim/FPGATrackSimMaps/python/FPGATrackSimMapConfig.py index fd8836316299556700c23e7df81ec76d706142ab..abd889935836a3a8228aea60329ed8430badb60a 100644 --- a/Trigger/EFTracking/FPGATrackSim/FPGATrackSimMaps/python/FPGATrackSimMapConfig.py +++ b/Trigger/EFTracking/FPGATrackSim/FPGATrackSimMaps/python/FPGATrackSimMapConfig.py @@ -1,103 +1,49 @@ -# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration -''' -@author Riley Xu - rixu@cern.ch -@date March 3rd 2020 -@brief This file declares functions to make and configure the map service. -''' - -import os - -from PyJobTransforms.trfUtils import findFile -from PyJobTransforms.trfLogger import msg - -from FPGATrackSimMaps.FPGATrackSimMapsConf import FPGATrackSimMappingSvc, FPGATrackSimHitFilteringTool -import FPGATrackSimConfTools.FPGATrackSimConfigCompInit as FPGATrackSimConfig - -def findFileWithTest(datapath,filename): - retv = findFile(datapath,filename) - if retv is None: - msg.info(datapath) - raise OSError(2, "Couldn't find file", filename) - return retv - -def addMapSvc(tag): - ''' - Creates and returns a FPGATrackSimMapSvc object, configured with the specified tag. - - This function adds the returned map service instance to SvcMgr, and ALSO ADDS - the EventSelectionSvc, which the map svc depends on - ''' - FPGATrackSimConfig.addEvtSelSvc(tag) - - MyFPGATrackSimMappingSvc = FPGATrackSimMappingSvc() - - filepaths = [ - 'pmap', - 'rmap', - 'modulemap', - 'subrmap', - 'NNmap', - ] - - formats = { - 'region': FPGATrackSimConfig.getRegionIndex(tag), - 'regionName': FPGATrackSimConfig.getRegionName(tag), - } - - for param in filepaths: - if tag['formatted']: - path = tag[param].format(**formats) - else: - path = tag[param] - setattr(MyFPGATrackSimMappingSvc, param, path) - - MyFPGATrackSimMappingSvc.mappingType = tag['mappingType'] - MyFPGATrackSimMappingSvc.layerOverride = tag['layerOverride'] - - from AthenaCommon.AppMgr import ServiceMgr - ServiceMgr += MyFPGATrackSimMappingSvc - - return MyFPGATrackSimMappingSvc - - - -def addHitFilteringTool(tag): - ''' - Creates and adds the hit filtering tool to the tool svc - ''' - - HitFilteringTool = FPGATrackSimHitFilteringTool() - - for param in HitFilteringTool.__slots__: - if param in tag: - setattr(HitFilteringTool, param, tag[param]) - - from AthenaCommon.AppMgr import ToolSvc - ToolSvc += HitFilteringTool - - return HitFilteringTool - - - -def getNSubregions(tag): - formats = { - 'region': FPGATrackSimConfig.getRegionIndex(tag), - 'regionName': FPGATrackSimConfig.getRegionName(tag), - } - - if tag['formatted']: - path = tag['subrmap'].format(**formats) - else: - path = tag['subrmap'] - path = findFile(os.environ['DATAPATH'], path) - - with open(path, 'r') as f: - fields = f.readline().split() - assert(fields[0] == 'towers') - return int(fields[1]) - - -def _applyTag(MyFPGATrackSimMappingSvc, tag): - ''' - Helper function that sets the filepaths of the MapSvc using the supplied tag - ''' +# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration + +from PyJobTransforms.trfUtils import findFile +from PyJobTransforms.trfLogger import msg +import os + + +def findFileWithTest(datapath,filename): + retv = findFile(datapath,filename) + if retv is None: + msg.info(datapath) + raise OSError(2, "Couldn't find file", filename) + return retv + +def getRegionIndex(map_tag): + ''' + Note the region member of the tag is a string + ''' + try: + return int(map_tag['region']) + except ValueError: + return map_tag['regionNames'].index(map_tag['region']) + + +def getRegionName(map_tag): + return map_tag['regionNames'][getRegionIndex(map_tag)] + +def getSampleType(map_tag): + return map_tag['sampleType'] + +def getWithPU(map_tag): + return map_tag['withPU'] + +def getNSubregions(tag): + formats = { + 'region': getRegionIndex(tag), + 'regionName': getRegionName(tag), + } + + if tag['formatted']: + path = tag['subrmap'].format(**formats) + else: + path = tag['subrmap'] + path = findFile(os.environ['DATAPATH'], path) + + with open(path, 'r') as f: + fields = f.readline().split() + assert(fields[0] == 'towers') + return int(fields[1]) \ No newline at end of file