From 81dcf4872b682fb350eec62fddb57e979639da28 Mon Sep 17 00:00:00 2001 From: Sandro Wenzel Date: Tue, 29 Oct 2024 16:31:10 +0100 Subject: [PATCH] Yet more resilience in o2dpg_determine_eventstat (#1777) (cherry picked from commit f26dfd23f877214d3d8052ad8d431a9f4100d453) --- MC/bin/o2dpg_determine_eventstat.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/MC/bin/o2dpg_determine_eventstat.py b/MC/bin/o2dpg_determine_eventstat.py index 012d274e7..9e91a24c8 100755 --- a/MC/bin/o2dpg_determine_eventstat.py +++ b/MC/bin/o2dpg_determine_eventstat.py @@ -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() @@ -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) \ No newline at end of file +print ("Found " + str(AO2D_eventcount) + " events in AO2D file") +write_stat_file(AO2D_eventcount)