9 #include <unordered_map>
23 float_decor_names[
kHitPurity]=
"truthHitPurity";
27 std::vector<std::string> link_decor_names;
28 link_decor_names.push_back(
"truthParticleLink");
44 std::unordered_map<const ActsTrk::TrackContainerBase *, const ActsTrk::TrackToTruthParticleAssociation *> truth_association_map;
48 if (!track_to_truth_handle.
isValid()) {
49 ATH_MSG_ERROR(
"No track to truth particle association for key " << truth_association_key.key() );
50 return StatusCode::FAILURE;
52 truth_association_map.insert(std::make_pair( track_to_truth_handle->sourceContainer(), track_to_truth_handle.
cptr() ));
56 if (!track_particle_handle.
isValid()) {
57 ATH_MSG_ERROR(
"No track particle container for key " << track_particle_handle.
key() );
58 return StatusCode::FAILURE;
60 std::vector< SG::WriteDecorHandle<xAOD::TrackParticleContainer,float > >
61 float_decor( createDecorators<xAOD::TrackParticleContainer, float >(
m_floatDecor, ctx) );
68 track_particle_handle->
size());
72 std::pair<const ActsTrk::TrackContainerBase *, const ActsTrk::TrackToTruthParticleAssociation *>
73 the_track_truth_association{
nullptr,
nullptr};
78 std::optional<ActsTrk::TrackContainer::ConstTrackProxy> >::
value);
82 std::optional<ActsTrk::TrackContainer::ConstTrackProxy> optional_track = *link_to_track;
83 if (optional_track.has_value()) {
85 if (track_container != the_track_truth_association.first && track_container ) {
86 std::unordered_map<const ActsTrk::TrackContainerBase *, const ActsTrk::TrackToTruthParticleAssociation *>::const_iterator
87 truth_association_map_iter = truth_association_map.find( track_container );
88 if (truth_association_map_iter != truth_association_map.end()) {
89 the_track_truth_association = *truth_association_map_iter;
92 if (the_track_truth_association.second) {
94 (*the_track_truth_association.second).at(optional_track.value().index()),
100 if (truth_particle) {
101 if (!ref_truth_link.
isValid()) {
104 if (!truth_particle_container) {
105 ATH_MSG_ERROR(
"Valid truth particle not part of a xAOD::TruthParticleContainer");
121 float_decor[
kHitPurity](*track_particle) = truth_match.m_hitPurity;
122 float_decor[
kHitEfficiency](*track_particle) = truth_match.m_hitEfficiency;
125 track_particle_handle->size(),
127 return StatusCode::SUCCESS;