ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonConditions
MuonCondGeneral
MuonCondDump
python
dumpTgcDigiThreshold.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
import
logging
3
def
setupArgParser
():
4
from
argparse
import
ArgumentParser
5
6
parser = ArgumentParser()
7
parser.add_argument(
"--inFile"
, help=
"Input file to be translated"
,
8
default=
"TGC_Digitization_energyThreshold.dat"
)
9
parser.add_argument(
"--outFile"
, help=
"Output JSON file"
,
10
default=
"TGC_Digitization_energyThreshold.json"
)
11
return
parser
12
13
if
__name__ ==
"__main__"
:
14
args =
setupArgParser
().parse_args()
15
from
ROOT
import
PathResolver
16
resolver =
PathResolver
()
17
18
resolvedInFile = resolver.find_file(args.inFile,
"DATAPATH"
)
19
if
not
resolvedInFile
or
len(resolvedInFile) == 0:
20
logging.error(
"Failed to find file {fileName}"
.format(fileName = args.inFile))
21
exit(1)
22
23
stationNameDict = {41:
"T1F"
, 42:
"T1E"
, 43:
"T2F"
, 44:
"T2E"
, 45:
"T3F"
, 46:
"T3E"
, 47:
"T4F"
, 48:
"T4E"
}
24
threshChambers = []
25
with
open (resolvedInFile,
'r'
)
as
inStream:
26
for
line
in
inStream:
27
line = line[0 : line.find(
"#"
)]
28
tokens = [x.strip()
for
x
in
line.split(
" "
)
if
len(x.strip())]
29
stationName = stationNameDict[int(tokens[0])]
30
stationEta = tokens[1][tokens[1].
find
(
"+"
)+1: ]
31
stationPhi = tokens[2]
32
gasGap = tokens[3]
33
isStrip = tokens[4]
34
threshold = tokens[5]
35
threshEntry =
"\n"
.join([
" {"
,
36
" \"station\" : \"{name}\","
.format(name = stationName),
37
" \"eta\" : {eta},"
.format(eta = stationEta),
38
" \"phi\" : {phi},"
.format(phi = stationPhi),
39
" \"gasGap\" : {gap},"
.format(gap = gasGap),
40
" \"isStrip\" : {strip},"
.format(strip = isStrip),
41
" \"threshold\": {threshold}"
.format(threshold=threshold),
42
" }"
])
43
logging.debug(threshEntry)
44
threshChambers+=[threshEntry]
45
with
open(args.outFile,
'w'
)
as
outStream:
46
outStream.write(
"[\n"
)
47
for
num, thresh
in
enumerate(threshChambers, 1):
48
outStream.write(thresh)
49
if
num != len(threshChambers): outStream.write(
","
)
50
outStream.write(
"\n"
)
51
outStream.write(
"]\n"
)
PathResolver
Definition
PathResolver.h:15
find
std::string find(const std::string &s)
return a remapped string
Definition
hcg.cxx:140
dumpTgcDigiThreshold.setupArgParser
setupArgParser()
Definition
dumpTgcDigiThreshold.py:3
Generated on
for ATLAS Offline Software by
1.17.0