ATLAS Offline Software
Loading...
Searching...
No Matches
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
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.
11"""
12
13from argparse import ArgumentParser
14
15from AthenaCommon.Constants import INFO
16from AthenaCommon.Constants import DEBUG
17from AthenaCommon.Logging import log
18from AthenaConfiguration.AllConfigFlags import initConfigFlags
19from AthenaConfiguration.MainServicesConfig import MainServicesCfg
20from PixelGeoModelXml.ITkPixelGeoModelConfig import ITkPixelReadoutGeometryCfg
21
22from ITkPixelByteStreamCnv.ITkPixelByteStreamCnvConfig import ITkPixelCsvWaferIdAlgCfg
23
24import csv, json, sys, os
25
26parser = ArgumentParser("RunITkPixelCsvWaferIdAlg.py")
27parser.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)
32parser.add_argument(
33 "--output-file",
34 default="ITkPixelWaferIds.txt",
35 help="Output csv file for one 32-bit waferID identifier per line.",
36)
37
38parser.add_argument(
39 "--verbose",
40 action="store_true",
41 help="Print the full Athena configuration and properties.",
42)
43args = parser.parse_args()
44
45log.setLevel(INFO)
46
47flags = initConfigFlags()
48flags.Input.isMC = True
49flags.Input.Files = [] # No input files needed for this test
50
51#flags.Exec.OutputLevel=DEBUG
52
53from AthenaConfiguration.TestDefaults import defaultGeometryTags
54flags.GeoModel.AtlasVersion = defaultGeometryTags.RUN4
55flags.GeoModel.Align.Dynamic = False
56
57from AthenaConfiguration.TestDefaults import defaultConditionsTags
58flags.IOVDb.GlobalTag = defaultConditionsTags.RUN4_MC
59
60flags.lock()
61
62cfg = MainServicesCfg(flags)
63cfg.merge(ITkPixelReadoutGeometryCfg(flags))
64cfg.merge(ITkPixelCsvWaferIdAlgCfg(flags,
65 CsvFile=args.csv_file,
66 OutputFile=args.output_file))
67
68if args.verbose:
69 cfg.printConfig(withDetails=True, summariseProps=True, printDefaults=True)
70
71# Run the application to initialize and execute
72cfg.run(1)
73
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")
79
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")
83
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)]))
87f.close()
88
89
90print(" Done !!")
void print(char *figname, TCanvas *c1)