19 from ROOT
import Belle2
20 import matplotlib.cm
as colormap
21 from matplotlib.patches
import Circle
22 import matplotlib.pyplot
as plt
23 from basf2
import Module, Path, process, B2INFO, B2WARNING
24 from simulation
import add_simulation
27 def plot(x, y, col, show=0):
29 Plot a list of x/y values, plus CDC superlayer boundaries.
31 Returns a pyplot.figure that can be saved.
33 fig = plt.figure(figsize=(8, 8))
34 ax = fig.add_subplot(111)
38 for i
in range(len(col)):
39 ax.plot(x[i], y[i], marker=
'.', color=col[i], linestyle=
'None', markersize=1)
41 ax.set_title(
'CDCSimHits')
42 ax.set_xlabel(
'x [cm]')
43 ax.set_ylabel(
'y [cm]')
47 layers = [16.8, 25.7, 36.5, 47.6, 58.4, 69.5, 80.2, 91.3, 102.0, 111.1]
48 Circs = [Circle((0, 0), a, facecolor=
'none', edgecolor=
'lightgrey')
53 ax.set_xlim(-130, 130)
54 ax.set_ylim(-130, 130)
62 """An example python module.
64 It gathers the x/y position off all CDCSimHits and draws them using
65 matplotlib. The result is saved as a PNG.
72 """reimplementation of Module::event().
74 loops over the CDCSimHits in the current event.
84 mcpart = hit.getRelatedFrom(
"MCParticles")
85 if mcpart
not in mcparts:
86 mcparts.append(mcpart)
87 trackhits_x.append([])
88 trackhits_y.append([])
90 idx = mcparts.index(mcpart)
91 hitpos = hit.getPosWire()
92 trackhits_x[idx].append(hitpos.X())
93 trackhits_y[idx].append(hitpos.Y())
98 col = [colormap.jet(1.0 * c / (npart - 1))
for c
in range(npart)]
99 fig =
plot(trackhits_x, trackhits_y, col)
101 filename =
'cdchits_%i.png' % (self.
num_eventsnum_events)
102 if os.path.lexists(filename):
103 B2WARNING(filename +
' exists, overwriting ...')
105 B2INFO(
'creating ' + filename +
' ...')
106 fig.savefig(filename)
111 """reimplementation of Module::terminate()."""
112 B2INFO(
'terminating CDCPlotModule')
119 'pdgCodes': [211, -211],
122 'momentumGeneration':
'uniform',
123 'momentumParams': [0.4, 1.6],
124 'thetaGeneration':
'uniform',
125 'thetaParams': [60., 120.],
126 'phiGeneration':
'uniform',
127 'phiParams': [0, 360],
128 'vertexGeneration':
'uniform',
129 'xVertexParams': [0.0, 0.0],
130 'yVertexParams': [0.0, 0.0],
131 'zVertexParams': [0.0, 0.0],
136 main.add_module(
'EventInfoSetter', evtNumList=[5])
137 main.add_module(
'ParticleGun', **param_pGun)
A (simplified) python wrapper for StoreArray.
int num_events
event counter