71 def event(self):
72 """reimplementation of Module::event().
73
74 loops over the CDCSimHits in the current event.
75 """
77
78
79 trackhits_x = []
80 trackhits_y = []
81
82 mcparts = []
83 for hit in simhits:
84 mcpart = hit.getRelatedFrom("MCParticles")
85 if mcpart not in mcparts:
86 mcparts.append(mcpart)
87 trackhits_x.append([])
88 trackhits_y.append([])
89
90 idx = mcparts.index(mcpart)
91 hitpos = hit.getPosWire()
92 trackhits_x[idx].append(hitpos.X())
93 trackhits_y[idx].append(hitpos.Y())
94
95 npart = len(mcparts)
96 if npart > 0:
97
98 col = [colormap.jet(1.0 * c / (npart - 1)) for c in range(npart)]
99 fig =
plot(trackhits_x, trackhits_y, col)
100
101 filename = f'cdchits_{self.num_events}.png'
102 if os.path.lexists(filename):
103 B2WARNING(filename + ' exists, overwriting ...')
104 else:
105 B2INFO('creating ' + filename + ' ...')
106 fig.savefig(filename)
107
108 self.num_events += 1
109
A (simplified) python wrapper for StoreArray.