ATLAS Offline Software
dumpTgcDigiDeadChambers.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_2016deadChamber.dat")
9  parser.add_argument("--outFile", help="Output JSON file",
10  default="TGC_Digitization_2016deadChamber.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  deadChambers = []
25  with open (resolvedInFile, 'r') as inStream:
26  for line in inStream:
27  comment = line[line.find("#") + 1 : -1]
28  line = line[0 : line.find("#")]
29  tokens = [int(x.strip()) for x in line.split(" ") if len(x.strip())]
30  stationName = stationNameDict[tokens[0]]
31  stationEta = tokens[1]
32  stationPhi = tokens[2]
33  gasGap = tokens[3]
34  deadEntry ="\n".join([ " {",
35  " \"station\" : \"{name}\",".format(name = stationName),
36  " \"eta\" : {eta},".format(eta = stationEta),
37  " \"phi\" : {phi},".format(phi = stationPhi),
38  " \"gasGap\" : {gap},".format(gap = gasGap),
39  " \"comment\" : \"{comment}\"".format(comment = comment),
40  " }"])
41  logging.debug(deadEntry)
42  deadChambers+=[deadEntry]
43 
44  with open(args.outFile, 'w') as outStream:
45  outStream.write("[\n")
46  for num, dead in enumerate(deadChambers, 1):
47  outStream.write(dead)
48  if num != len(deadChambers): outStream.write(",")
49  outStream.write("\n")
50  outStream.write("]\n")
vtune_athena.format
format
Definition: vtune_athena.py:14
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
dumpTgcDigiDeadChambers.setupArgParser
def setupArgParser()
Definition: dumpTgcDigiDeadChambers.py:3
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
Trk::open
@ open
Definition: BinningType.h:40
confTool.parse_args
def parse_args()
Definition: confTool.py:35