ATLAS Offline Software
FPGATrackSimMapConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 from PyJobTransforms.trfUtils import findFile
4 from PyJobTransforms.trfLogger import msg
5 import os
6 
7 
8 def findFileWithTest(datapath,filename):
9  retv = findFile(datapath,filename)
10  if retv is None:
11  msg.info(datapath)
12  raise OSError(2, "Couldn't find file", filename)
13  return retv
14 
15 def getRegionIndex(map_tag):
16  '''
17  Note the region member of the tag is a string
18  '''
19  try:
20  return int(map_tag['region'])
21  except ValueError:
22  return map_tag['regionNames'].index(map_tag['region'])
23 
24 
25 def getRegionName(map_tag):
26  return map_tag['regionNames'][getRegionIndex(map_tag)]
27 
28 def getSampleType(map_tag):
29  return map_tag['sampleType']
30 
31 def getWithPU(map_tag):
32  return map_tag['withPU']
33 
34 def getNSubregions(tag):
35  formats = {
36  'region': getRegionIndex(tag),
37  'regionName': getRegionName(tag),
38  }
39 
40  if tag['formatted']:
41  path = tag['subrmap'].format(**formats)
42  else:
43  path = tag['subrmap']
44  path = findFile(os.environ['DATAPATH'], path)
45 
46  with open(path, 'r') as f:
47  fields = f.readline().split()
48  assert(fields[0] == 'towers')
49  return int(fields[1])
vtune_athena.format
format
Definition: vtune_athena.py:14
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
index
Definition: index.py:1
FPGATrackSimMapConfig.getSampleType
def getSampleType(map_tag)
Definition: FPGATrackSimMapConfig.py:28
FPGATrackSimMapConfig.getRegionName
def getRegionName(map_tag)
Definition: FPGATrackSimMapConfig.py:25
FPGATrackSimMapConfig.getRegionIndex
def getRegionIndex(map_tag)
Definition: FPGATrackSimMapConfig.py:15
FPGATrackSimMapConfig.findFileWithTest
def findFileWithTest(datapath, filename)
Definition: FPGATrackSimMapConfig.py:8
python.trfUtils.findFile
def findFile(pathvar, fname)
Find a named file along a colon separated PATH type variable.
Definition: trfUtils.py:37
Trk::open
@ open
Definition: BinningType.h:40
PyJobTransforms.trfUtils
Transform utility functions.
PyJobTransforms.trfLogger
Logging configuration for ATLAS job transforms.
FPGATrackSimMapConfig.getWithPU
def getWithPU(map_tag)
Definition: FPGATrackSimMapConfig.py:31
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
FPGATrackSimMapConfig.getNSubregions
def getNSubregions(tag)
Definition: FPGATrackSimMapConfig.py:34