ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimValidateAODOutput.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
4import ROOT
5import sys
6import argparse
7import numpy as np
8
9def main():
10 parser = argparse.ArgumentParser(
11 description="Validate AOD Output from FPGATrackSim."
12 )
13 parser.add_argument(
14 "input_root_file",
15 help="Path to the input ROOT file"
16 )
17 args = parser.parse_args()
18
19 input_root_file = args.input_root_file
20 rootFile = ROOT.TFile.Open(input_root_file)
21 if not rootFile or rootFile.IsZombie():
22 print(f"Error: Could not open file {input_root_file}")
23 sys.exit(1)
24
25 clustersToCheck = [
26 'xAODPixelClustersFromFPGACluster',
27 'xAODStripClustersFromFPGACluster'
28 ]
29 tree = rootFile.Get("CollectionTree")
30
31 # Work around for ATEAM-1000
32 import cppyy.ll
33 cppyy.ll.cast["xAOD::PixelClusterContainer_v1"](0)
34
35 for branch in clustersToCheck:
36 averageClustersPerEvent = np.mean([getattr(evt, branch).size() for evt in tree])
37 if np.isclose(averageClustersPerEvent, 0):
38 raise ValueError(f"no recorded clusters in {branch}")
39 else:
40 print(f"there are on average {averageClustersPerEvent} clusters per event in {branch}")
41
42 averageNumberOfTracksPerEvent = np.mean([evt.FPGATrackParticles.size() for evt in tree])
43 if np.isclose(averageNumberOfTracksPerEvent, 0):
44 raise ValueError("no recorded tracks in FPGATrackparticles")
45 else:
46 print(f"there are on average {averageNumberOfTracksPerEvent} tracks per event in FPGATrackparticles")
47
48if __name__ == "__main__":
49 main()
void print(char *figname, TCanvas *c1)