File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed
Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -87,20 +87,34 @@ def read_AO2D_eventcount(file):
8787
8888 # Open the ROOT file
8989 tfile = ROOT .TFile .Open (file )
90-
90+
9191 # Get the list of keys (TKeys) in the ROOT files
9292 keys = tfile .GetListOfKeys ()
9393
9494 # Iterate through the keys "DF_" keys and accumulate
9595 # stored MC collisions
96+ colfound = 0
97+
9698 for key in keys :
9799 key_name = key .GetName ()
98100 if key_name .startswith ("DF_" ):
99101 obj = key .ReadObj ()
100- # the O2mccollision tree contains the simulated collisions
101- coltree = obj .Get ("O2mccollision" )
102- if coltree and isinstance (coltree , ROOT .TTree ):
103- eventcount = eventcount + coltree .GetEntries ()
102+
103+ # get the list of keys of available tables
104+ tablelist = obj .GetListOfKeys ()
105+ for tab in tablelist :
106+ # the O2mccollision_ tree contains the simulated collisions
107+ # but the version number might change so better to loop over keys and do matching
108+ tabname = tab .GetName ()
109+ if tabname .startswith ("O2mccollision_" ):
110+ coltreekey = obj .GetKey (tabname )
111+ coltree = coltreekey .ReadObj ()
112+ if coltree and isinstance (coltree , ROOT .TTree ):
113+ eventcount = eventcount + coltree .GetEntries ()
114+ colfound = colfound + 1
115+
116+ if colfound != 1 :
117+ print ("ERROR in extracting the expected amount of MC collision tables" )
104118
105119 # Close the files
106120 tfile .Close ()
You can’t perform that action at this time.
0 commit comments