4     from argparse 
import ArgumentParser
 
    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")
 
   13 if __name__ == 
"__main__":
 
   15     from ROOT 
import PathResolver
 
   16     resolver = PathResolver()
 
   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))
 
   23     stationNameDict = {41:
"T1F", 42:
"T1E", 43:
"T2F", 44:
"T2E", 45:
"T3F", 46:
"T3E", 47:
"T4F", 48:
"T4E"}
 
   25     with open (resolvedInFile, 
'r') 
as 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]
 
   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),
 
   41             logging.debug(deadEntry)
 
   42             deadChambers+=[deadEntry]
 
   44     with open(args.outFile, 
'w') 
as outStream:
 
   45         outStream.write(
"[\n")
 
   46         for num, dead 
in enumerate(deadChambers, 1):
 
   48             if num != len(deadChambers): outStream.write(
",")
 
   50         outStream.write(
"]\n")