29 constexpr
const char* NAME =
"truthParticleLink";
31 if( !
acc.isAvailable( *trkPart ) ) {
34 const Link_t& link =
acc( *trkPart );
35 if( ! link.isValid() ) {
47 enum vertexCatogory_tracks {
53 enum vertexCategory_vertex {
55 multipleTruthVertices,
61 multiset<const xAOD::TruthVertex*> truth_vertices;
64 set<const xAOD::TruthVertex*> truth_vertices_types;
66 vector<const xAOD::TrackParticle*> reco_tracks;
67 vector<const xAOD::TrackParticle*> orphan_tracks;
68 vector<const xAOD::TrackParticle*> fake_tracks;
72 for(
size_t itrk=0; itrk<
vertex->nTrackParticles(); itrk++ ) {
73 const auto *trk =
vertex->trackParticle( itrk );
75 ATH_MSG_VERBOSE(
"categorizeVertexTruthTopology(): track loop itrk = " << itrk );
78 const truthLink& link = truthParticleLinkAcc(*trk);
81 fake_tracks.emplace_back( trk );
87 orphan_tracks.emplace_back( trk );
91 reco_tracks.emplace_back( trk );
93 truth_vertices_types .insert( truth->
prodVtx() );
94 truth_vertices .insert( truth->
prodVtx() );
100 ATH_MSG_VERBOSE(
"categorizeVertexTruthTopology(): Add truth track pattern to the reco vertex" );
102 if( reco_tracks.size() ==
vertex->nTrackParticles() ) {
103 trkpatAcc( *
vertex ) = allTruthAssociated;
104 }
else if( fake_tracks.size() ==
vertex->nTrackParticles() ) {
105 trkpatAcc( *
vertex ) = allFakeTracks;
107 trkpatAcc( *
vertex ) = hasFakeTracks;
112 ATH_MSG_VERBOSE(
"categorizeVertexTruthTopology(): Histogramming - counting the number of appearing truth vertices connected" );
113 vector< tuple<const xAOD::TruthVertex*, size_t> > truth_vertex_histogram;
114 for(
const auto *
v : truth_vertices_types ) {
115 size_t count = truth_vertices.count(
v );
116 truth_vertex_histogram.emplace_back(
v,
count );
120 ATH_MSG_VERBOSE(
"categorizeVertexTruthTopology(): Determine the truth vertex associated to this vertex by majority decision" );
121 tuple<const xAOD::TruthVertex*, size_t> tmp_tuple(
nullptr, 0 );
122 for(
const auto&
t : truth_vertex_histogram ) {
123 const size_t& size_tmp = get<1>( tmp_tuple );
124 const size_t& size_this = get<1>(
t );
125 if( size_tmp < size_this ) tmp_tuple =
t;
129 ATH_MSG_VERBOSE(
"categorizeVertexTruthTopology(): Add truth track pattern to the reco vertex" );
130 char truth_vtx_pattern = 0;
131 if( truth_vertices_types.empty() ) {
132 truth_vtx_pattern = noTruthVertex;
133 }
else if( truth_vertices_types.size() == 1 ) {
134 truth_vtx_pattern = uniqueTruthVertex;
136 truth_vtx_pattern = multipleTruthVertices;
139 vtxpatAcc(*
vertex) = truth_vtx_pattern;
143 if( noTruthVertex != truth_vtx_pattern ) {
146 ATH_MSG_VERBOSE(
"categorizeVertexTruthTopology(): Retrieve the truth vertex container for element link" );
151 ATH_MSG_VERBOSE(
"categorizeVertexTruthTopology(): create the element link" );
152 const auto *theVertex = get<0>( tmp_tuple );
156 ATH_MSG_VERBOSE(
"categorizeVertexTruthTopology(): Add the truth vertex element link to the reco vertex" );
162 linkAcc(
"truth_vtx_link" );
163 linkAcc(*
vertex) = vtx_link;
165 return StatusCode::SUCCESS;