255 def peel(self, segment):
256 """Aggregate the track and MC information for track-segment analysis"""
258 mc_segment_lookup = self.mc_segment_lookup
259 mc_hit_lookup = self.mc_hit_lookup
261 segment_crops = cdc_peelers.peel_segment2d(segment)
263 mc_particle = mc_segment_lookup.getMCParticle(segment)
264 mc_particle_crops = peelers.peel_mc_particle(mc_particle)
266 fit3d_truth = mc_segment_lookup.getTrajectory3D(segment)
267 curvature_truth = fit3d_truth.getCurvatureXY()
269 reconstructed_backward = mc_segment_lookup.isForwardOrBackwardToMCTrack(segment)
270 is_fake = mc_segment_lookup.getMCTrackId(segment) < 0
272 if reconstructed_backward != 1:
273 curvature_truth = -curvature_truth
276 tan_lambda_truth=fit3d_truth.getTanLambda(),
277 curvature_truth=curvature_truth,
278 abs_curvature_truth=abs(curvature_truth),
279 curvature_residual=segment_crops["curvature_estimate"] - curvature_truth,
280 curvature_pull=(segment_crops["curvature_estimate"] - curvature_truth) / segment_crops["curvature_variance"],
281 reconstructed_backward=reconstructed_backward,
287 n_total = segment.size()
288 first_i_incorrect = float("nan")
289 last_i_incorrect = float("nan")
290 first_l_incorrect = 0
295 for i, reco_hit2d in enumerate(segment):
296 rl_info = reco_hit2d.getRLInfo()
297 hit = reco_hit2d.getWireHit().getHit()
298 true_rl_info = mc_hit_lookup.getRLInfo(hit)
300 if rl_info != last_rl_info:
302 last_rl_info = rl_info
304 if true_rl_info == rl_info:
307 if first_i_incorrect != first_i_incorrect:
308 first_i_incorrect = i
309 first_l_incorrect = reco_hit2d.getRefDriftLength()
311 last_l_incorrect = reco_hit2d.getRefDriftLength()
314 elif rl_info == -1 or rl_info == 65535: # <- The root interface mistakes the signed enum value for an unsigned value
317 alias_score = segment.getAliasScore()
322 n_incorrect=n_total - n_correct,
323 rl_purity=n_correct / n_total,
324 first_incorrect_location=first_i_incorrect / (n_total - 1),
325 first_l_incorrect=first_l_incorrect,
326 last_incorrect_location=last_i_incorrect / (n_total - 1),
327 last_l_incorrect=last_l_incorrect,
328 n_rl_switch=n_rl_switch,
329 n_rl_asymmetry=rl_sum / n_total,
330 n_abs_rl_asymmetry=abs(rl_sum) / n_total,
331 may_alias=alias_score == 0,
332 alias_score=alias_score
335 segment_crops.update(truth_crops)
336 segment_crops.update(mc_particle_crops)
337 segment_crops.update(rl_crops)