ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
AsgAnalysisAlgorithms
share
testOutputContent.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
"""
4
Test to check output content of CPRun.py
5
"""
6
7
import
argparse
8
import
ROOT
9
import
sys
10
11
def
main
():
12
parser = argparse.ArgumentParser(description=
"Check for branches in a ROOT TTree."
)
13
parser.add_argument(
"--input_file"
, required=
True
, help=
"Path to the ROOT file"
)
14
parser.add_argument(
"--tree_name"
, required=
True
, help=
"Name of the TTree inside the file"
)
15
parser.add_argument(
"--branches"
, nargs=
"*"
, default=[], help=
"Branch names to check that should be present in tree"
)
16
parser.add_argument(
"--forbidden-branches"
, nargs=
"*"
, default=[], help=
"Branch names to check that should not be present in tree"
)
17
18
args = parser.parse_args()
19
20
# Open ROOT file
21
f = ROOT.TFile.Open(args.input_file)
22
if
not
f
or
f.IsZombie():
23
print
(f
"Error: Could not open file '{args.input_file}'"
)
24
sys.exit(1)
25
26
# Get tree
27
tree = f.Get(args.tree_name)
28
if
not
tree:
29
print
(f
"Error: Could not find tree '{args.tree_name}' in file '{args.input_file}'"
)
30
sys.exit(1)
31
32
# Available branches
33
available = {b.GetName()
for
b
in
tree.GetListOfBranches()}
34
35
36
missing =
False
37
forbidden_found =
False
38
39
# Check required branches
40
if
args.branches:
41
print
()
42
print
(f
"Checking required branches in tree '{args.tree_name}':"
)
43
for
br
in
args.branches:
44
if
br
in
available:
45
print
(f
"[ OK ] {br}"
)
46
else
:
47
print
(f
"[ MISSING ] {br}"
)
48
missing =
True
49
50
# Check forbidden branches
51
if
args.forbidden_branches:
52
print
()
53
print
(
"Checking forbidden branches:"
)
54
for
br
in
args.forbidden_branches:
55
if
br
in
available:
56
print
(f
"[ FORBIDDEN ] {br}"
)
57
forbidden_found =
True
58
else
:
59
print
(f
"[ OK (not present) ] {br}"
)
60
61
f.Close()
62
63
# Exit non-zero if any issue found
64
if
missing
or
forbidden_found:
65
sys.exit(2)
66
67
if
__name__ ==
"__main__"
:
68
main
()
print
void print(char *figname, TCanvas *c1)
Definition
TRTCalib_StrawStatusPlots.cxx:26
testOutputContent.main
main()
Definition
testOutputContent.py:11
Generated on
for ATLAS Offline Software by
1.17.0