ATLAS Offline Software
Loading...
Searching...
No Matches
checkIndexRefs Namespace Reference

Functions

 main (infile, intree="CollectionTree")

Variables

 infile

Function Documentation

◆ main()

checkIndexRefs.main ( infile,
intree = "CollectionTree" )
    This script simply takes a ROOT file as input,
    reads the index_ref for all events in the file
    and makes sure each event has a unique value.
    Otherwise, it raises an error...

Definition at line 9 of file checkIndexRefs.py.

9def 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
int main()
Definition hello.cxx:18

Variable Documentation

◆ infile

checkIndexRefs.infile

Definition at line 67 of file checkIndexRefs.py.