5 from ROOT
import Belle2
7 logging.log_level = LogLevel.WARNING
13 Lists TrueHits with MCParticles and SimHits that generated them.
17 """Initialize the module"""
19 super(CheckTrueHits, self).
__init__()
22 'through': {
'total': 0,
'secondary': 0,
'remapped': 0},
23 'into': {
'total': 0,
'secondary': 0,
'remapped': 0},
24 'out': {
'total': 0,
'secondary': 0,
'remapped': 0},
25 'inside': {
'total': 0,
'secondary': 0,
'remapped': 0}
29 'through': {
'total': 0,
'secondary': 0,
'remapped': 0},
30 'into': {
'total': 0,
'secondary': 0,
'remapped': 0},
31 'out': {
'total': 0,
'secondary': 0,
'remapped': 0},
32 'inside': {
'total': 0,
'secondary': 0,
'remapped': 0}
43 List VXD TrueHits, the MCParticles that generated them, related
44 SimHits, and check the reconstruction of the mid-point parameters.
51 for truehit
in pxd_truehits:
53 id = truehit.getSensorID()
54 layer = id.getLayerNumber()
55 ladder = id.getLadderNumber()
56 sensor = id.getSensorNumber()
57 sensor_info = geocache.get(id)
58 thickness = sensor_info.getThickness()
60 '\nPXDTrueHit {index}: layer:{ly} ladder:{ld} sensor:{sr}'\
61 .format(index=truehit.getArrayIndex(),
62 ly=layer, ld=ladder, sr=sensor)
65 abs(abs(truehit.getEntryW()) - thickness / 2.0) < 1.0e-6
67 abs(abs(truehit.getExitW()) - thickness / 2.0) < 1.0e-6
68 through_type = into_type
and out_type
69 truehit_type_text =
'inside'
71 truehit_type_text =
'through'
73 truehit_type_text =
'into'
75 truehit_type_text =
'out'
76 base_info =
'\n' +
'TrueHit type: ' + truehit_type_text
78 mcparticle_relations = truehit.getRelationsFrom(
'MCParticles')
79 weight = mcparticle_relations.weight(0)
80 particle = mcparticle_relations[0]
81 particle_type_text =
'secondary'
82 if particle.hasStatus(Belle2.MCParticle.c_PrimaryParticle):
83 particle_type_text =
'primary'
84 mcparticle_message =
'MCParticle {index}: {text}'.format(
85 index=particle.getArrayIndex(),
86 text=particle_type_text +
' ')
87 self.truehit_stats_pxd[truehit_type_text][
'total'] += 1
88 if particle_type_text ==
'secondary':
89 self.truehit_stats_pxd[truehit_type_text][
'secondary'] += 1
91 self.truehit_stats_pxd[truehit_type_text][
'remapped'] += 1
92 mcparticle_message +=
'remapped ' + str(weight)
95 B2INFO(base_info +
'\n' + mcparticle_message)
97 simhits = truehit.getRelationsTo(
'PXDSimHits')
99 for simhit
in simhits:
100 particle_type_text =
'secondary'
104 simhit_relations = simhit.getRelationsFrom(
'MCParticles')
105 if simhit_relations.size() == 0:
106 particle_type_text =
'none'
108 simhit_weight = simhit_relations.weight(0)
109 particle = simhit_relations[0]
110 particle_index = particle.getArrayIndex()
111 if particle.hasStatus(Belle2.MCParticle.c_PrimaryParticle):
112 particle_type_text =
'primary'
114 '{index} {ptext} {pindex} {wt:9.6f}'.format(
115 index=simhit.getArrayIndex(),
116 ptext=particle_type_text,
117 pindex=particle_index,
120 ' {u_in:8.4f} {v_in:8.4f} {w_in:8.4f}'.format(
121 u_in=simhit.getPosIn().X(),
122 v_in=simhit.getPosIn().Y(),
123 w_in=simhit.getPosIn().Z())
125 '{time:8.5f}'.format(time=simhit.getGlobalTime())
128 midpoint_text =
'TrueHit position:\n'
130 'IN: ({u_in:8.4f},{v_in:8.4f},{w_in:8.4f})\n'.format(
131 u_in=truehit.getEntryU(),
132 v_in=truehit.getEntryV(),
133 w_in=truehit.getEntryW())
135 'MID: ({u_mid:8.4f},{v_mid:8.4f},{w_mid:8.4f})\n'.format(
136 u_mid=truehit.getU(),
137 v_mid=truehit.getV(),
138 w_mid=truehit.getW())
140 'OUT: ({u_out:8.4f},{v_out:8.4f},{w_out:8.4f})\n'.format(
141 u_out=truehit.getExitU(),
142 v_out=truehit.getExitV(),
143 w_out=truehit.getExitW())
145 midpoint_text +=
'\nTrueHit momentum:\n'
147 'IN: ({pu_in:8.4f},{pv_in:8.4f},{pw_in:8.4f})\n'.format(
148 pu_in=truehit.getEntryMomentum().X(),
149 pv_in=truehit.getEntryMomentum().Y(),
150 pw_in=truehit.getEntryMomentum().Z())
152 'MID: ({pu_mid:8.4f},{pv_mid:8.4f},{pw_mid:8.4f})\n'.format(
153 pu_mid=truehit.getMomentum().X(),
154 pv_mid=truehit.getMomentum().Y(),
155 pw_mid=truehit.getMomentum().Z())
157 'OUT: ({pu_out:8.4f},{pv_out:8.4f},{pw_out:8.4f})\n'.format(
158 pu_out=truehit.getExitMomentum().X(),
159 pv_out=truehit.getExitMomentum().Y(),
160 pw_out=truehit.getExitMomentum().Z())
162 midpoint_text +=
'Time: {t:8.5f}\n'.format(
163 t=truehit.getGlobalTime())
164 B2INFO(midpoint_text)
166 for truehit
in svd_truehits:
168 id = truehit.getSensorID()
169 layer = id.getLayerNumber()
170 ladder = id.getLadderNumber()
171 sensor = id.getSensorNumber()
172 sensor_info = geocache.get(id)
173 thickness = sensor_info.getThickness()
175 '\nSVDTrueHit {index}: layer:{ly} ladder:{ld} sensor:{sr}'\
176 .format(index=truehit.getArrayIndex(),
177 ly=layer, ld=ladder, sr=sensor)
180 abs(abs(truehit.getEntryW()) - thickness / 2.0) < 1.0e-6
182 abs(abs(truehit.getExitW()) - thickness / 2.0) < 1.0e-6
183 through_type = into_type
and out_type
184 truehit_type_text =
'inside'
186 truehit_type_text =
'through'
188 truehit_type_text =
'into'
190 truehit_type_text =
'out'
191 base_info +=
'\n' +
'TrueHit type: ' + truehit_type_text
193 mcparticle_relations = truehit.getRelationsFrom(
'MCParticles')
194 weight = mcparticle_relations.weight(0)
195 particle = mcparticle_relations[0]
196 particle_type_text =
'secondary'
197 if particle.hasStatus(Belle2.MCParticle.c_PrimaryParticle):
198 particle_type_text =
'primary'
199 mcparticle_message =
'MCParticle {index}: {text}'.format(
200 index=particle.getArrayIndex(),
201 text=particle_type_text +
' ')
202 self.truehit_stats_svd[truehit_type_text][
'total'] += 1
203 if particle_type_text ==
'secondary':
204 self.truehit_stats_svd[truehit_type_text][
'secondary'] += 1
206 self.truehit_stats_svd[truehit_type_text][
'remapped'] += 1
207 mcparticle_message +=
'remapped ' + str(weight)
210 B2INFO(base_info +
'\n' + mcparticle_message)
212 simhits = truehit.getRelationsTo(
'SVDSimHits')
214 for simhit
in simhits:
215 particle_type_text =
'secondary'
219 simhit_relations = simhit.getRelationsFrom(
'MCParticles')
220 if simhit_relations.size() == 0:
221 particle_type_text =
'none'
223 simhit_weight = simhit_relations.weight(0)
224 particle = simhit_relations[0]
225 particle_index = particle.getArrayIndex()
226 if particle.hasStatus(Belle2.MCParticle.c_PrimaryParticle):
227 particle_type_text =
'primary'
229 '{index} {ptext} {pindex} {wt:9.6f}'.format(
230 index=simhit.getArrayIndex(),
231 ptext=particle_type_text,
232 pindex=particle_index,
235 ' {u_in:8.4f} {v_in:8.4f} {w_in:8.4f}'.format(
236 u_in=simhit.getPosIn().X(),
237 v_in=simhit.getPosIn().Y(),
238 w_in=simhit.getPosIn().Z())
240 '{time:8.5f} '.format(time=simhit.getGlobalTime())
243 midpoint_text =
'TrueHit position:\n'
245 'IN: ({u_in:8.4f},{v_in:8.4f},{w_in:8.4f})\n'.format(
246 u_in=truehit.getEntryU(),
247 v_in=truehit.getEntryV(),
248 w_in=truehit.getEntryW())
250 'MID: ({u_mid:8.4f},{v_mid:8.4f},{w_mid:8.4f})\n'.format(
251 u_mid=truehit.getU(),
252 v_mid=truehit.getV(),
253 w_mid=truehit.getW())
255 'OUT: ({u_out:8.4f},{v_out:8.4f},{w_out:8.4f})\n'.format(
256 u_out=truehit.getExitU(),
257 v_out=truehit.getExitV(),
258 w_out=truehit.getExitW())
260 midpoint_text +=
'\nTrueHit momentum:\n'
262 'IN: ({pu_in:8.4f},{pv_in:8.4f},{pw_in:8.4f})\n'.format(
263 pu_in=truehit.getEntryMomentum().X(),
264 pv_in=truehit.getEntryMomentum().Y(),
265 pw_in=truehit.getEntryMomentum().Z())
267 'MID: ({pu_mid:8.4f},{pv_mid:8.4f},{pw_mid:8.4f})\n'.format(
268 pu_mid=truehit.getMomentum().X(),
269 pv_mid=truehit.getMomentum().Y(),
270 pw_mid=truehit.getMomentum().Z())
272 'OUT: ({pu_out:8.4f},{pv_out:8.4f},{pw_out:8.4f})\n'.format(
273 pu_out=truehit.getExitMomentum().X(),
274 pv_out=truehit.getExitMomentum().Y(),
275 pw_out=truehit.getExitMomentum().Z())
277 midpoint_text +=
'Time: {t:8.5f}\n'.format(
278 t=truehit.getGlobalTime())
279 B2INFO(midpoint_text)
282 """ Write results """
284 '\nStatistics for PXD: {pxd};\nStatistics for SVD: {svd}\n'.format(
291 particlegun = register_module(
'ParticleGun')
293 eventinfosetter = register_module(
'EventInfoSetter')
295 progress = register_module(
'Progress')
297 gearbox = register_module(
'Gearbox')
299 geometry = register_module(
'Geometry')
301 simulation = register_module(
'FullSim')
305 printParticles.set_log_level(LogLevel.INFO)
308 eventinfosetter.param({
'evtNumList': [200],
'runList': [1]})
314 'pdgCodes': [211, -211, 11, -11],
315 'momentumGeneration':
'normalPt',
316 'momentumParams': [2, 1],
317 'phiGeneration':
'normal',
318 'phiParams': [0, 360],
319 'thetaGeneration':
'uniformCos',
320 'thetaParams': [17, 150],
321 'vertexGeneration':
'normal',
322 'xVertexParams': [0, 1],
323 'yVertexParams': [0, 1],
324 'zVertexParams': [0, 1],
325 'independentVertices':
False,
329 geometry.param(
'components', [
'MagneticField',
'PXD',
'SVD'])
333 main.add_module(eventinfosetter)
334 main.add_module(progress)
335 main.add_module(particlegun)
336 main.add_module(gearbox)
337 main.add_module(geometry)
338 main.add_module(simulation)
339 main.add_module(printParticles)