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