Skip to content

Commit 81dcf48

Browse files
sawenzelalcaliva
authored andcommitted
Yet more resilience in o2dpg_determine_eventstat (#1777)
(cherry picked from commit f26dfd2)
1 parent f8aac6f commit 81dcf48

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

MC/bin/o2dpg_determine_eventstat.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ def read_AO2D_eventcount(file):
106106
# the O2mccollision_ tree contains the simulated collisions
107107
# but the version number might change so better to loop over keys and do matching
108108
tabname = tab.GetName()
109-
if tabname.startswith("O2mccollision_"):
109+
if re.match("^O2mccollision(_[0-9]*)?$", tabname):
110110
coltreekey = obj.GetKey(tabname)
111111
coltree = coltreekey.ReadObj()
112112
if coltree and isinstance(coltree, ROOT.TTree):
113113
eventcount = eventcount + coltree.GetEntries()
114114
colfound = colfound + 1
115115

116-
if colfound != 1:
117-
print ("ERROR in extracting the expected amount of MC collision tables")
116+
if colfound == 0:
117+
print ("ERROR: No MC collision table found")
118118

119119
# Close the files
120120
tfile.Close()
@@ -125,4 +125,5 @@ def read_AO2D_eventcount(file):
125125
if AO2D_eventcount != GEANT_eventcount:
126126
print ("WARN: AO2D MC event count and GEANT event count differ")
127127

128-
write_stat_file(AO2D_eventcount)
128+
print ("Found " + str(AO2D_eventcount) + " events in AO2D file")
129+
write_stat_file(AO2D_eventcount)

0 commit comments

Comments
 (0)