ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetEventCnv
ITkPixelByteStreamCnv
scripts
RunITkPixelCsvWaferIdTool.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
3
# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4
5
"""Configure and initialize ITkPixelCsvWaferIdAlg.
6
7
This script is a lightweight AthenaConfiguration entry point for the CSV-based
8
wafer identifier algorithm. It currently validates that the algorithm can be
9
configured and executed, and prints the lookup request that would be passed to
10
its waferId() implementation.
11
"""
12
13
from
argparse
import
ArgumentParser
14
15
from
AthenaCommon.Constants
import
INFO
16
from
AthenaCommon.Constants
import
DEBUG
17
from
AthenaCommon.Logging
import
log
18
from
AthenaConfiguration.AllConfigFlags
import
initConfigFlags
19
from
AthenaConfiguration.MainServicesConfig
import
MainServicesCfg
20
from
PixelGeoModelXml.ITkPixelGeoModelConfig
import
ITkPixelReadoutGeometryCfg
21
22
from
ITkPixelByteStreamCnv.ITkPixelByteStreamCnvConfig
import
ITkPixelCsvWaferIdAlgCfg
23
24
import
csv, json, sys, os
25
26
parser = ArgumentParser(
"RunITkPixelCsvWaferIdAlg.py"
)
27
parser.add_argument(
28
"--csv-file"
,
29
default=
"/eos/atlas/atlascerngroupdisk/det-itk/general/pixels/identifiers/AT2-IP-ES-0016_v1.41_INCOMPLETE-ModuleA_slim.csv"
,
30
help=
"CSV file to load. The default is resolved through DATAPATH."
,
31
)
32
parser.add_argument(
33
"--output-file"
,
34
default=
"ITkPixelWaferIds.txt"
,
35
help=
"Output csv file for one 32-bit waferID identifier per line."
,
36
)
37
38
parser.add_argument(
39
"--verbose"
,
40
action=
"store_true"
,
41
help=
"Print the full Athena configuration and properties."
,
42
)
43
args = parser.parse_args()
44
45
log.setLevel(INFO)
46
47
flags = initConfigFlags()
48
flags.Input.isMC =
True
49
flags.Input.Files = []
# No input files needed for this test
50
51
#flags.Exec.OutputLevel=DEBUG
52
53
from
AthenaConfiguration.TestDefaults
import
defaultGeometryTags
54
flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN4
55
flags.GeoModel.Align.Dynamic =
False
56
57
from
AthenaConfiguration.TestDefaults
import
defaultConditionsTags
58
flags.IOVDb.GlobalTag = defaultConditionsTags.RUN4_MC
59
60
flags.lock()
61
62
cfg = MainServicesCfg(flags)
63
cfg.merge(ITkPixelReadoutGeometryCfg(flags))
64
cfg.merge(ITkPixelCsvWaferIdAlgCfg(flags,
65
CsvFile=args.csv_file,
66
OutputFile=args.output_file))
67
68
if
args.verbose:
69
cfg.printConfig(withDetails=
True
, summariseProps=
True
, printDefaults=
True
)
70
71
# Run the application to initialize and execute
72
cfg.run(1)
73
74
print
(
"Configured ITkPixelCsvWaferIdAlg"
)
75
print
(f
" Input CSV file: {args.csv_file}"
)
76
print
(f
" Output file: {args.output_file}"
)
77
print
(
" Note: the algorithm execution writes one front end per line to the output file."
)
78
print
(
" 32-bit waferID+feID, 32-bit waferID+feID, FELIX Card Name, Uplink Pin, DMA buffer, SourceID"
)
79
80
print
(
" Converting csv to json...."
)
81
if
os.path.isfile(args.output_file+
".json"
):
82
print
(f
"File {args.output_file}.json exists, will overwrite it"
)
83
84
f = open(args.output_file+
".json"
,
"w"
)
85
with
open(args.output_file, newline=
''
)
as
csvfile:
86
f.write(json.dumps([dict(r)
for
r
in
csv.DictReader(csvfile)]))
87
f.close()
88
89
90
print
(
" Done !!"
)
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
Constants
Generated on
for ATLAS Offline Software by
1.17.0