48 def event(self):
49 """
50 List VXD TrueHits, the MCParticles that generated them, related
51 SimHits, and check the reconstruction of the mid-point parameters.
52 """
53
57
58 for truehit in pxd_truehits:
59
60 id = truehit.getSensorID()
61 layer = id.getLayerNumber()
62 ladder = id.getLadderNumber()
63 sensor = id.getSensorNumber()
64 sensor_info = geocache.get(id)
65 thickness = sensor_info.getThickness()
66 base_info = \
67 f'\nPXDTrueHit {truehit.getArrayIndex()}: layer:{layer} ladder:{ladder} sensor:{sensor}'
68
69 into_type = \
70 abs(abs(truehit.getEntryW()) - thickness / 2.0) < 1.0e-6
71 out_type = \
72 abs(abs(truehit.getExitW()) - thickness / 2.0) < 1.0e-6
73 through_type = into_type and out_type
74 truehit_type_text = 'inside'
75 if through_type:
76 truehit_type_text = 'through'
77 elif into_type:
78 truehit_type_text = 'into'
79 elif out_type:
80 truehit_type_text = 'out'
81 base_info = '\n' + 'TrueHit type: ' + truehit_type_text
82
83 mcparticle_relations = truehit.getRelationsFrom('MCParticles')
84 if mcparticle_relations.size() == 0:
85 b2.B2INFO('Found PXDTrueHit w/o relation to MCParticles')
86 continue
87 weight = mcparticle_relations.weight(0)
88 particle = mcparticle_relations[0]
89 particle_type_text = 'secondary'
90 if particle.hasStatus(Belle2.MCParticle.c_PrimaryParticle):
91 particle_type_text = 'primary'
92 mcparticle_message = f"MCParticle {particle.getArrayIndex()}: {particle_type_text + ' '}"
93 self.truehit_stats_pxd[truehit_type_text]['total'] += 1
94 if particle_type_text == 'secondary':
95 self.truehit_stats_pxd[truehit_type_text]['secondary'] += 1
96 if weight < 0:
97 self.truehit_stats_pxd[truehit_type_text]['remapped'] += 1
98 mcparticle_message += 'remapped ' + str(weight)
99 else:
100 continue
101 b2.B2INFO(base_info + '\n' + mcparticle_message)
102
103 simhits = truehit.getRelationsTo('PXDSimHits')
104 b2.B2INFO('SimHits:')
105 for simhit in simhits:
106 particle_type_text = 'secondary'
107 simhit_weight = 0.0
108 particle_index = -1
109
110 simhit_relations = simhit.getRelationsFrom('MCParticles')
111 if simhit_relations.size() == 0:
112 particle_type_text = 'none'
113 else:
114 simhit_weight = simhit_relations.weight(0)
115 particle = simhit_relations[0]
116 particle_index = particle.getArrayIndex()
117 if particle.hasStatus(Belle2.MCParticle.c_PrimaryParticle):
118 particle_type_text = 'primary'
119 simhit_text = \
120 f'{simhit.getArrayIndex()} {particle_type_text} {particle_index} {simhit_weight:9.6f}'
121 simhit_text += \
122 f' {simhit.getPosIn().X():8.4f} {simhit.getPosIn().Y():8.4f} {simhit.getPosIn().Z():8.4f}'
123 simhit_text += \
124 f'{simhit.getGlobalTime():8.5f}'
125 b2.B2INFO(simhit_text)
126
127 midpoint_text = 'TrueHit position:\n'
128 midpoint_text += \
129 f'IN: ({truehit.getEntryU():8.4f},{truehit.getEntryV():8.4f},{truehit.getEntryW():8.4f})\n'
130 midpoint_text += \
131 f'MID: ({truehit.getU():8.4f},{truehit.getV():8.4f},{truehit.getW():8.4f})\n'
132 midpoint_text += \
133 f'OUT: ({truehit.getExitU():8.4f},{truehit.getExitV():8.4f},{truehit.getExitW():8.4f})\n'
134
135 midpoint_text += '\nTrueHit momentum:\n'
136 midpoint_text += \
137 f'IN: ({truehit.getEntryMomentum().X():8.4f},{truehit.getEntryMomentum().Y():8.4f},' + \
138 f'{truehit.getEntryMomentum().Z():8.4f})\n'
139 midpoint_text += \
140 f'MID: ({truehit.getMomentum().X():8.4f},{truehit.getMomentum().Y():8.4f},{truehit.getMomentum().Z():8.4f})\n'
141 midpoint_text += \
142 f'OUT: ({truehit.getExitMomentum().X():8.4f},{truehit.getExitMomentum().Y():8.4f},' + \
143 f'{truehit.getExitMomentum().Z():8.4f})\n'
144
145 midpoint_text += f'Time: {truehit.getGlobalTime():8.5f}\n'
146 b2.B2INFO(midpoint_text)
147
148 for truehit in svd_truehits:
149
150 id = truehit.getSensorID()
151 layer = id.getLayerNumber()
152 ladder = id.getLadderNumber()
153 sensor = id.getSensorNumber()
154 sensor_info = geocache.get(id)
155 thickness = sensor_info.getThickness()
156 base_info = \
157 f'\nSVDTrueHit {truehit.getArrayIndex()}: layer:{layer} ladder:{ladder} sensor:{sensor}'
158
159 into_type = \
160 abs(abs(truehit.getEntryW()) - thickness / 2.0) < 1.0e-6
161 out_type = \
162 abs(abs(truehit.getExitW()) - thickness / 2.0) < 1.0e-6
163 through_type = into_type and out_type
164 truehit_type_text = 'inside'
165 if through_type:
166 truehit_type_text = 'through'
167 elif into_type:
168 truehit_type_text = 'into'
169 elif out_type:
170 truehit_type_text = 'out'
171 base_info += '\n' + 'TrueHit type: ' + truehit_type_text
172
173 mcparticle_relations = truehit.getRelationsFrom('MCParticles')
174 if mcparticle_relations.size() == 0:
175 b2.B2INFO('Found SVDTrueHit w/o relation to MCParticles')
176 continue
177 weight = mcparticle_relations.weight(0)
178 particle = mcparticle_relations[0]
179 particle_type_text = 'secondary'
180 if particle.hasStatus(Belle2.MCParticle.c_PrimaryParticle):
181 particle_type_text = 'primary'
182 mcparticle_message = f"MCParticle {particle.getArrayIndex()}: {particle_type_text + ' '}"
183 self.truehit_stats_svd[truehit_type_text]['total'] += 1
184 if particle_type_text == 'secondary':
185 self.truehit_stats_svd[truehit_type_text]['secondary'] += 1
186 if weight < 0:
187 self.truehit_stats_svd[truehit_type_text]['remapped'] += 1
188 mcparticle_message += 'remapped ' + str(weight)
189 else:
190 continue
191 b2.B2INFO(base_info + '\n' + mcparticle_message)
192
193 simhits = truehit.getRelationsTo('SVDSimHits')
194 b2.B2INFO('SimHits:')
195 for simhit in simhits:
196 particle_type_text = 'secondary'
197 simhit_weight = 0.0
198 particle_index = -1
199
200 simhit_relations = simhit.getRelationsFrom('MCParticles')
201 if simhit_relations.size() == 0:
202 particle_type_text = 'none'
203 else:
204 simhit_weight = simhit_relations.weight(0)
205 particle = simhit_relations[0]
206 particle_index = particle.getArrayIndex()
207 if particle.hasStatus(Belle2.MCParticle.c_PrimaryParticle):
208 particle_type_text = 'primary'
209 simhit_text = \
210 f'{simhit.getArrayIndex()} {particle_type_text} {particle_index} {simhit_weight:9.6f}'
211 simhit_text += \
212 f' {simhit.getPosIn().X():8.4f} {simhit.getPosIn().Y():8.4f} {simhit.getPosIn().Z():8.4f}'
213 simhit_text += \
214 f'{simhit.getGlobalTime():8.5f} '
215 b2.B2INFO(simhit_text)
216
217 midpoint_text = 'TrueHit position:\n'
218 midpoint_text += \
219 f'IN: ({truehit.getEntryU():8.4f},{truehit.getEntryV():8.4f},{truehit.getEntryW():8.4f})\n'
220 midpoint_text += \
221 f'MID: ({truehit.getU():8.4f},{truehit.getV():8.4f},{truehit.getW():8.4f})\n'
222 midpoint_text += \
223 f'OUT: ({truehit.getExitU():8.4f},{truehit.getExitV():8.4f},{truehit.getExitW():8.4f})\n'
224
225 midpoint_text += '\nTrueHit momentum:\n'
226 midpoint_text += \
227 f'IN: ({truehit.getEntryMomentum().X():8.4f},{truehit.getEntryMomentum().Y():8.4f},' + \
228 f'{truehit.getEntryMomentum().Z():8.4f})\n'
229 midpoint_text += \
230 f'MID: ({truehit.getMomentum().X():8.4f},{truehit.getMomentum().Y():8.4f},{truehit.getMomentum().Z():8.4f})\n'
231 midpoint_text += \
232 f'OUT: ({truehit.getExitMomentum().X():8.4f},{truehit.getExitMomentum().Y():8.4f},' + \
233 f'{truehit.getExitMomentum().Z():8.4f})\n'
234
235 midpoint_text += f'Time: {truehit.getGlobalTime():8.5f}\n'
236 b2.B2INFO(midpoint_text)
237
A (simplified) python wrapper for StoreArray.
static GeoCache & getInstance()
Return a reference to the singleton instance.