ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonConditions
MuonCondGeneral
MuonCondDump
python
sTgcDigitEffiDump.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=
"sTGC_Digitization_EffChamber.dat"
)
9
parser.add_argument(
"--outFile"
, help=
"Output JSON file"
,
10
default=
"sTGC_Digitization_EffChamber.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
efficiencies = []
24
with
open (resolvedInFile,
'r'
)
as
inStream:
25
for
i, line
in
enumerate(inStream):
26
27
if
i == 0:
continue
28
tokens = [x.strip()
for
x
in
line.split(
" "
)
if
len(x.strip())]
29
30
stationName =
"STL"
if
tokens[0] == 1
else
"STS"
31
stationEta = tokens[1]
32
33
if
stationEta == 0:
34
continue
35
stationPhi = tokens[2]
36
multiLayer = int(tokens[3]) + 1
37
gasGap = tokens[4]
38
effi = tokens[5]
39
effiEntry =
"\n"
.join([
" {"
,
40
" \"station\" : \"{name}\","
.format(name = stationName),
41
" \"eta\" : {eta},"
.format(eta = stationEta),
42
" \"phi\" : {phi},"
.format(phi = stationPhi),
43
" \"multiLayer\" : {phi},"
.format(phi = multiLayer),
44
" \"gasGap\" : {gap},"
.format(gap = gasGap),
45
" \"efficiency\": {effi}"
.format(effi=effi),
46
" }"
])
47
logging.debug(effiEntry)
48
efficiencies+=[effiEntry]
49
50
with
open(args.outFile,
'w'
)
as
outStream:
51
outStream.write(
"[\n"
)
52
for
num, jitter
in
enumerate(efficiencies, 1):
53
outStream.write(jitter)
54
if
num != len(efficiencies): outStream.write(
","
)
55
outStream.write(
"\n"
)
56
outStream.write(
"]\n"
)
PathResolver
Definition
PathResolver.h:15
sTgcDigitEffiDump.setupArgParser
setupArgParser()
Definition
sTgcDigitEffiDump.py:3
Generated on
for ATLAS Offline Software by
1.17.0