Skip to content
Snippets Groups Projects
Commit dba903e6 authored by Adam Edward Barton's avatar Adam Edward Barton
Browse files

Merge branch 'FPGATrackSim_revert' into 'main'

Restore legacy FPGATrackSim legacy configs still in use

See merge request !70708
parents 3a9954dd 8f7b505b
No related branches found
No related tags found
No related merge requests found
# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
'''
@author Riley Xu - rixu@cern.ch
@date Feb 6th 2020
@brief This file declares functions to make and configure the bank service.
'''
from FPGATrackSimBanks.FPGATrackSimBanksConf import FPGATrackSimBankSvc
from FPGATrackSimConfTools import FPGATrackSimConfigCompInit
import os
def addBankSvc(mapTag, bankTag):
'''
Creates and returns a FPGATrackSimBankSvc object, configured with the supplied tag.
This function adds the returned bank service
instance to SvcMgr.
'''
from AthenaCommon.AppMgr import ServiceMgr
MyFPGATrackSimBankSvc = FPGATrackSimBankSvc()
_applyTag(MyFPGATrackSimBankSvc, mapTag, bankTag)
if "EOS_MGM_URL_FPGATrackSim" in os.environ: # Set by the gitlab yaml
_applyGitlabOverrides(MyFPGATrackSimBankSvc)
ServiceMgr += MyFPGATrackSimBankSvc
return MyFPGATrackSimBankSvc
def _applyTag(MyFPGATrackSimBankSvc, mapTag, bankTag):
'''
Helper function that sets the filepaths of the BankSvc using the supplied tag.
'''
bankDir = bankTag['bankDir']
filepaths = [
'constants_1st',
'constants_2nd',
'sectorBank_1st',
'sectorBank_2nd',
'sectorSlices'
]
filelists = [
'constantsNoGuess_1st',
'constantsNoGuess_2nd',
]
formats = {
'region': FPGATrackSimConfigCompInit.getRegionIndex(mapTag),
'regionName': mapTag['regionNames'][FPGATrackSimConfigCompInit.getRegionIndex(mapTag)],
}
for param in filepaths:
if bankTag['formatted']:
value = (bankDir + bankTag[param]).format(**formats)
else:
value = bankDir + bankTag[param]
setattr(MyFPGATrackSimBankSvc, param, value)
for param in filelists:
if bankTag['formatted']:
value = [(bankDir + path).format(**formats) for path in bankTag[param]]
else:
value = [bankDir + path for path in bankTag[param]]
setattr(MyFPGATrackSimBankSvc, param, value)
def _applyGitlabOverrides(MyFPGATrackSimBankSvc):
'''
Alters the filepaths for running on Gitlab CI
'''
# The non-root files need to be copied to the pwd
for param in ['sectorBank_1st', 'sectorBank_2nd', 'constants_1st', 'constants_2nd']:
filepath = getattr(MyFPGATrackSimBankSvc, param)
newpath = os.path.basename(filepath)
# This doesn't work for some reason, gets a file not found
#import subprocess
#subprocess.call(['xrdcp', '-f', "'" + os.environ["EOS_MGM_URL_FPGATrackSim"] + filepath + "'", "'" + newpath + "'"])
setattr(MyFPGATrackSimBankSvc, param, newpath)
for param in ['sectorSlices']:
setattr(MyFPGATrackSimBankSvc, param, os.environ["EOS_MGM_URL_FPGATrackSim"] + getattr(MyFPGATrackSimBankSvc, param))
# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
__author__ = "Jahred Adelman, FPGATrackSim team"
......@@ -35,6 +35,10 @@ 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 )
......
# 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)
......@@ -16,6 +16,7 @@ python -m FPGATrackSimConfTools.FPGATrackSimAnalysisConfig \
--evtMax=${RDO_EVT} \
Trigger.FPGATrackSim.mapsDir=${MAPS} \
Trigger.FPGATrackSim.tracking=True \
Trigger.FPGATrackSim.sampleType='skipTruth' \
Trigger.FPGATrackSim.bankDir=${BANKS}
ls -l
echo "... analysis on RDO, this part is done ..."
......@@ -23,6 +23,9 @@ atlas_add_component(
LINK_LIBRARIES FPGATrackSimMapsLib FPGATrackSimConfToolsLib
)
# Install files from the package:
atlas_install_python_modules( python/*.py )
# Tests in the package:
atlas_add_test( FPGATrackSimPlaneMap
SOURCES test/FPGATrackSimPlaneMap_test.cxx
......
# 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
'''
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment