Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions MC/bin/o2dpg_determine_eventstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,34 @@ def read_AO2D_eventcount(file):

# Open the ROOT file
tfile = ROOT.TFile.Open(file)

# Get the list of keys (TKeys) in the ROOT files
keys = tfile.GetListOfKeys()

# Iterate through the keys "DF_" keys and accumulate
# stored MC collisions
colfound = 0

for key in keys:
key_name = key.GetName()
if key_name.startswith("DF_"):
obj = key.ReadObj()
# the O2mccollision tree contains the simulated collisions
coltree = obj.Get("O2mccollision")
if coltree and isinstance(coltree, ROOT.TTree):
eventcount = eventcount + coltree.GetEntries()

# get the list of keys of available tables
tablelist = obj.GetListOfKeys()
for tab in tablelist:
# 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_"):
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")

# Close the files
tfile.Close()
Expand Down