ATLAS Offline Software
Loading...
Searching...
No Matches
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.
5import json
6import argparse
7
8data = {}
9
10parser = argparse.ArgumentParser(description="Converter from geometry dat file to json")
11parser.add_argument(
12 '--infile',
13 type=str,
14 help="Input .dat file",
15 default="geometry.dat"
16)
17parser.add_argument(
18 "--outfile",
19 help="Output .json file",
20 type=str,
21 default="geometry.json",
22)
23
24args = parser.parse_args()
25
26
27with 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
36with open(args.outfile, "w") as f:
37 json.dump(data, f, indent = 4)