54 def ProcessEvent(self, evt):
55
56
57 print(
"--> Event "+str(evt))
58 self.tree.GetEntry(evt)
59 EventNumber = self.tree.EventInfo.mcEventNumber()
60
61
62 for container in self.dict_variables_types.keys():
63 dict_lists = {}
64 dict_container = self.dict_variables_types[container]
65 try:
66 tp = getattr(self.tree, container)
67 except Exception:
68 print(
".. Missing ", container)
69 continue
70
71 if tp.size() == 0:
72 print(
".. Empty ", container)
73 continue
74
75 for var,fmt in dict_container.items():
76 try:
77 sp = tp.getConstDataSpan[ fmt ]( var)
78 except Exception:
79
80 print(
"getConstDataSpan failed for variable ",var,fmt, container)
81 sp = [ getattr(element, var)() for element in tp ]
82
83 try:
84
85 list_of_lists = [list(std_vector) for std_vector in sp]
86
87 max_len =
max(len(ll)
for ll
in list_of_lists)
88
89 for ll in list_of_lists:
90 ll.extend([np.nan] * (max_len - len(ll)))
91 except Exception:
92 list_of_lists = sp
93
94
95 sp = np.array(list_of_lists)
96
97 if "ArrayFloat3" in fmt and len(sp) > 0:
98 sp =
array( list(
map(self.ArrayFloat3_to_CppArray, sp) ) )
99
100 if ("unsigned char" in fmt or "uint8" in fmt) and len(sp) > 0:
101 sp = sp.view(np.int32)
102
103 if sp.ndim == 1:
104 dict_lists[var] = sp
105 else:
106
107 for column in range(sp.shape[1]):
108 dict_lists[var+f"_at{column}"] = sp.T[column]
109
110 self.WriteCSV( filename=getCSVFilename(self.outputDir, container, EventNumber), dictionary=dict_lists )
111
112