ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Database
APR
RootStorageSvc
scripts
checkIndexRefs.py
Go to the documentation of this file.
1
#!/usr/bin/env python3
2
3
# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4
5
import
ROOT
6
import
sys
7
from
AthenaCommon.Logging
import
logging
8
9
def
main
(infile, intree="CollectionTree"):
10
"""
11
This script simply takes a ROOT file as input,
12
reads the index_ref for all events in the file
13
and makes sure each event has a unique value.
14
Otherwise, it raises an error...
15
"""
16
17
logging.info(f
"== Using input file {infile} =="
)
18
19
f = ROOT.TFile(infile)
20
t = f.Get(intree)
21
t.SetBranchStatus(
"*"
, 0)
22
t.SetBranchStatus(
"index_ref"
, 1)
23
24
indices = {}
25
nentries = t.GetEntries()
26
27
# Read index_ref for all the events and build a dictionary that
28
# holds index_ref => # of instances
29
for
idx
in
range(nentries):
30
t.GetEntry(idx)
31
if
hasattr(t,
'index_ref'
):
32
iref = t.index_ref
33
if
iref
not
in
indices:
34
indices[iref] = 1
35
else
:
36
indices[iref] += 1
37
else
:
38
logging.error(
"Cannot read index_ref!"
)
39
return
sys.exit(1)
40
41
nindices = len(indices)
42
43
# The number of unique indices should equal the number of events
44
if
nindices == nentries:
45
logging.info(f
"== Total number of keys is {nindices} vs"
46
f
" total number of events is {nentries} =="
)
47
logging.info(
"All good!"
)
48
return
sys.exit(0)
49
else
:
50
# Print some additional information
51
for
key
in
indices:
52
pid = key >> 32
53
offset = key - ( pid << 32 )
54
logging.warning(f
" >> {key} (pid : {pid}, offset : {offset})"
55
f
" is repeated {indices[key]} times..."
)
56
logging.error(f
"== Total number of keys is {nindices} vs"
57
f
" total number of events is {nentries} =="
)
58
logging.error(
"The test FAILED!"
)
59
return
sys.exit(1)
60
61
if
__name__ ==
'__main__'
:
62
# Check user input
63
if
len(sys.argv) != 2:
64
logging.info(
"Help: Use as checkIndexRefs.py DAOD.pool.root"
)
65
sys.exit(1)
66
# Run the test
67
main
(infile=sys.argv[1])
main
int main()
Definition
hello.cxx:18
Generated on
for ATLAS Offline Software by
1.17.0