ATLAS Offline Software
geometry_dat_to_json.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 # This script converts the geometry.dat file output obtained from the run of RunPrintSiDetElements.py into a JSON file.
4 import json
5 import argparse
6 
7 data = {}
8 
9 parser = argparse.ArgumentParser(description="Converter from geometry dat file to json")
10 parser.add_argument(
11  '--infile',
12  type=str,
13  help="Input .dat file",
14  default="geometry.dat"
15 )
16 parser.add_argument(
17  "--outfile",
18  help="Output .json file",
19  type=str,
20  default="geometry.json",
21 )
22 
23 args = parser.parse_args()
24 
25 
26 with open(args.infile) as f:
27  for l in f:
28 
29  if l.startswith('#'):
30  continue
31 
32  bec, ld, phi, eta, side, ID = l.split()[2:8]
33  data[ID] = {"BEC" : bec, "LayerDisk" : ld, "PhiModule" : phi, "EtaModule" : eta, "Side" : side }
34 
35 with open(args.outfile, "w") as f:
36  json.dump(data, f, indent = 4)
Trk::open
@ open
Definition: BinningType.h:40