Skip to content

Commit

Permalink
Yet more resilience in o2dpg_determine_eventstat (#1777)
Browse files Browse the repository at this point in the history
(cherry picked from commit f26dfd2)
  • Loading branch information
sawenzel authored and alcaliva committed Nov 2, 2024
1 parent f8aac6f commit 81dcf48
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions MC/bin/o2dpg_determine_eventstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ def read_AO2D_eventcount(file):
# the O2mccollision_ tree contains the simulated collisions
# but the version number might change so better to loop over keys and do matching
tabname = tab.GetName()
if tabname.startswith("O2mccollision_"):
if re.match("^O2mccollision(_[0-9]*)?$", tabname):
coltreekey = obj.GetKey(tabname)
coltree = coltreekey.ReadObj()
if coltree and isinstance(coltree, ROOT.TTree):
eventcount = eventcount + coltree.GetEntries()
colfound = colfound + 1

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

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

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

0 comments on commit 81dcf48

Please sign in to comment.