ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimMapConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3from PyJobTransforms.trfUtils import findFile
4from PyJobTransforms.trfLogger import msg
5import os
6
7
8def 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
15def 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
25def getRegionName(map_tag):
26 return map_tag['regionNames'][getRegionIndex(map_tag)]
27
28def getSampleType(map_tag):
29 return map_tag['sampleType']
30
31def getWithPU(map_tag):
32 return map_tag['withPU']
33
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])
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
findFileWithTest(datapath, filename)
Logging configuration for ATLAS job transforms.
Transform utility functions.
Definition index.py:1