5"""Configure and initialize ITkPixelCsvWaferIdAlg.
7This script is a lightweight AthenaConfiguration entry point for the CSV-based
8wafer identifier algorithm. It currently validates that the algorithm can be
9configured and executed, and prints the lookup request that would be passed to
10its waferId() implementation.
13from argparse
import ArgumentParser
17from AthenaCommon.Logging
import log
18from AthenaConfiguration.AllConfigFlags
import initConfigFlags
19from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
20from PixelGeoModelXml.ITkPixelGeoModelConfig
import ITkPixelReadoutGeometryCfg
22from ITkPixelByteStreamCnv.ITkPixelByteStreamCnvConfig
import ITkPixelCsvWaferIdAlgCfg
24import csv, json, sys, os
26parser = ArgumentParser(
"RunITkPixelCsvWaferIdAlg.py")
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.",
34 default=
"ITkPixelWaferIds.txt",
35 help=
"Output csv file for one 32-bit waferID identifier per line.",
41 help=
"Print the full Athena configuration and properties.",
43args = parser.parse_args()
47flags = initConfigFlags()
48flags.Input.isMC =
True
53from AthenaConfiguration.TestDefaults
import defaultGeometryTags
54flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN4
55flags.GeoModel.Align.Dynamic =
False
57from AthenaConfiguration.TestDefaults
import defaultConditionsTags
58flags.IOVDb.GlobalTag = defaultConditionsTags.RUN4_MC
62cfg = MainServicesCfg(flags)
63cfg.merge(ITkPixelReadoutGeometryCfg(flags))
64cfg.merge(ITkPixelCsvWaferIdAlgCfg(flags,
65 CsvFile=args.csv_file,
66 OutputFile=args.output_file))
69 cfg.printConfig(withDetails=
True, summariseProps=
True, printDefaults=
True)
74print(
"Configured ITkPixelCsvWaferIdAlg")
75print(f
" Input CSV file: {args.csv_file}")
76print(f
" Output file: {args.output_file}")
77print(
" Note: the algorithm execution writes one front end per line to the output file.")
78print(
" 32-bit waferID+feID, 32-bit waferID+feID, FELIX Card Name, Uplink Pin, DMA buffer, SourceID")
80print(
" Converting csv to json....")
81if os.path.isfile(args.output_file+
".json"):
82 print(f
"File {args.output_file}.json exists, will overwrite it")
84f = open(args.output_file+
".json",
"w")
85with open(args.output_file, newline=
'')
as csvfile:
86 f.write(json.dumps([dict(r)
for r
in csv.DictReader(csvfile)]))
void print(char *figname, TCanvas *c1)