ATLAS Offline Software
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
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__":
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")
vtune_athena.format
format
Definition: vtune_athena.py:14
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
calibdata.exit
exit
Definition: calibdata.py:236
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
dumpTgcDigiThreshold.setupArgParser
def setupArgParser()
Definition: dumpTgcDigiThreshold.py:3
Trk::open
@ open
Definition: BinningType.h:40
confTool.parse_args
def parse_args()
Definition: confTool.py:35