358 def peel(self, track_fit_result):
359 """Aggregate the track-fit information associated with a TrackFitResult"""
360 mc_track_cand = track_fit_result.getRelationsFrom("TrackCands")[0]
361 mc_particle = self.data_store.getRelated(mc_track_cand, "MCParticles")
362
363 fit_momentum = track_fit_result.getMomentum()
364 true_momentum = mc_particle.getMomentum()
365
366 related_reco_track = track_fit_result.getRelated("GF2Tracks")
367 cardinal_rep = related_reco_track.getCardinalRep()
368 kalman_fit_state = related_reco_track.getKalmanFitStatus()
369
370 number_of_measurements_in_total = 0
371 number_of_measurements_with_smaller_weight = 0
372
373 number_of_momentum_measurements_in_total = 0
374 number_of_momentum_measurements_with_smaller_weight = 0
375
376 for track_point_ID in range(related_reco_track.getNumPointsWithMeasurement()):
377 track_point = related_reco_track.getPointWithMeasurement(track_point_ID)
378
379 is_momentum_measurement = track_point.getRawMeasurement().__class__.__name__ == "genfit::PlanarMomentumMeasurement"
380
381 if is_momentum_measurement:
382 number_of_momentum_measurements_in_total += 1
383
384 if track_point.hasFitterInfo(cardinal_rep):
385 fitter_info = track_point.getFitterInfo(cardinal_rep)
386 num_measurements = fitter_info.getNumMeasurements()
387
388 for measurement_id in range(num_measurements):
389 number_of_measurements_in_total += 1
390 weight = fitter_info.getMeasurementOnPlane(measurement_id).getWeight()
391 if weight != 1:
392 number_of_measurements_with_smaller_weight += 1
393
394 if is_momentum_measurement:
395 number_of_momentum_measurements_with_smaller_weight += 1
396
397 return dict(fit_momentum_x=fit_momentum.X(),
398 fit_momentum_y=fit_momentum.Y(),
399 fit_momentum_z=fit_momentum.Z(),
400 p_value=kalman_fit_state.getForwardPVal(),
401 backward_p_value=kalman_fit_state.getBackwardPVal(),
402 true_momentum_x=true_momentum.X(),
403 true_momentum_y=true_momentum.Y(),
404 true_momentum_z=true_momentum.Z(),
405 number_of_measurements_in_total=number_of_measurements_in_total,
406 number_of_measurements_with_smaller_weight=number_of_measurements_with_smaller_weight,
407 number_of_momentum_measurements_in_total=number_of_momentum_measurements_in_total,
408 number_of_momentum_measurements_with_smaller_weight=number_of_momentum_measurements_with_smaller_weight)
409