65 const std::vector<Trk::VxTrackAtVertex *> * tracks =
vertex->vxTrackAtVertex();
66 if ( tracks !=
nullptr ) {
71 if (
sc.isFailure() ) {
74 msg() <<
"Zero pointer returned." <<
endmsg;
83 if( genEvent->vertices_empty() ) {
87 auto pv = genEvent->vertices()[0];
93 const auto& pv_pos = pv ->position();
94 double pv_r = pv_pos.perp();
95 double pv_z = pv_pos.z();
99 std::map<int,HepMC::ConstGenVertexPtr> vertex_ids;
100 for (
const auto& vtx: genEvent->vertices()){
101 const auto& lv_pos = vtx->position();
102 if ( std::abs ( lv_pos.perp() - pv_r ) <
m_r_tol && std::abs ( lv_pos.z() - pv_z ) <
m_z_tol ) {vertex_ids[vtx->id()] = vtx;}
109 if (
sc.isFailure() ) {
112 msg() <<
"Zero pointer returned" <<
endmsg;
118 std::vector<Trk::VxTrackAtVertex *>::const_iterator vt = tracks->begin();
119 std::vector<Trk::VxTrackAtVertex *>::const_iterator ve = tracks->end();
120 unsigned int n_failed = 0;
121 std::vector<double> in_weights ( 0 );
122 std::vector<double> out_weights ( 0 );
123 std::vector<double> pu_weights ( 0 );
124 std::vector<double> no_correspondance ( 0 );
127 for ( ;vt!=ve;++vt ) {
130 if ( ( *vt ) !=
nullptr ) {
132 ITrackLink * origLink = ( **vt ).trackOrParticleLink();
134 if ( origLink !=
nullptr ) {
137 if ( tr_part !=
nullptr && tr_part->isValid()) {
140 std::map< Rec::TrackParticleTruthKey, TrackParticleTruth>::const_iterator ttItr = trackParticleTruthCollection->end();
154 if (ttItr != trackParticleTruthCollection->end() ) {
158 const auto *tpEvent = genParticle->parent_event();
159 if(tpEvent==genEvent) {
161 if (genParticle) pVertex = genParticle->production_vertex();
163 int link_pid = genParticle->pdg_id();
164 bool primary_track =
false;
165 bool secondary_track =
false;
169 auto idf_res = vertex_ids.find ( pVertex->id() );
173 if ( idf_res != vertex_ids.end() ) {
175 primary_track =
true;
176 in_weights.push_back ( ( *vt )->weight() );
181 if ( pVertex->particles_in_size() == 1 ) {
183 auto inp = pVertex->particles_in()[0] ;
184 auto tmpVertex_loc = inp ->production_vertex();
185 if ( inp ->pdg_id() == link_pid && tmpVertex_loc) {
188 pVertex = tmpVertex_loc;
190 secondary_track =
true;
191 out_weights.push_back ( ( *vt )->weight() );
197 secondary_track =
true;
198 out_weights.push_back ( ( *vt )->weight() );
201 }
while ( !primary_track && !secondary_track );
207 msg() <<
"A truth particle with no production vertex found."<<
endmsg;
208 msg() <<
"Since it does not come from PV, consider as PileUp"<<
endmsg;
210 pu_weights.push_back ( ( *vt )->weight() );
215 pu_weights.push_back ( ( *vt )->weight() );
221 no_correspondance.push_back ( ( *vt )->weight() );
225 if (
msgLvl(MSG::DEBUG))
msg() <<
"This track at vertex has no valid link to its original trackparticle "<<
endmsg;
229 if (
msgLvl(MSG::DEBUG))
msg() <<
"There is an empty pointer in the vector<VxTrackAtVertex *> for this vertex"<<
endmsg;
244 n_failed, in_weights, out_weights );
248 msg()<<
"Empty vertex pointer received"<<
endmsg;
249 msg()<<
"Empty pointer returned."<<
endmsg;
a link optimized in size for a GenParticle in a McEventCollection
HepMC::ConstGenParticlePtr scptr() const
Dereference/smart pointer.