14 #include "CLHEP/Units/SystemOfUnits.h"
15 #include "HepPDT/ParticleData.hh"
16 #include "GaudiKernel/IPartPropSvc.h"
24 m_particleDataTable{},
27 m_selectPrimariesOnly(
false),
34 declareInterface<IGenParticleSelector>(
this);
38 declareProperty(
"SelectPrimariesOnly",m_selectPrimariesOnly,
"flag to restrict to primaries or not");
39 declareProperty(
"MaxRStartPrimary", m_maxRStartPrimary,
"production vtx r for primaries");
40 declareProperty(
"MaxZStartPrimary", m_maxZStartPrimary,
"production vtx z for primaries");
41 declareProperty(
"MaxRStartAll", m_maxRStartAll,
"production vtx r for all");
42 declareProperty(
"MaxZStartAll", m_maxZStartAll,
"production vtx z for all");
51 IPartPropSvc* partPropSvc =
nullptr;
52 StatusCode sc = service(
"PartPropSvc", partPropSvc,
true);
54 ATH_MSG_FATAL (
" Could not initialize Particle Properties Service");
55 return StatusCode::FAILURE;
57 m_particleDataTable = partPropSvc->PDT();
60 return StatusCode::SUCCESS;
65 return StatusCode::SUCCESS;
68 std::vector<HepMC::ConstGenParticlePtr>*
71 if (! SimTracks)
return nullptr;
73 std::vector<HepMC::ConstGenParticlePtr>* genSignal =
74 new std::vector<HepMC::ConstGenParticlePtr>;
79 for( ; itCollision != SimTracks->
end(); ++itCollision ) {
80 const HepMC::GenEvent* genEvent = *itCollision;
82 for (
const auto&
particle: *genEvent) {
88 if(
particle->production_vertex() ==
nullptr) {
89 ATH_MSG_WARNING (
"GenParticle without production vertex - simulation corrupt? ");
95 if ( std::abs(
particle->production_vertex()->position().perp()) > m_maxRStartAll ||
96 std::abs(
particle->production_vertex()->position().z()) > m_maxZStartAll )
continue;
99 if ( m_selectPrimariesOnly &&
100 ( std::abs(
particle->production_vertex()->position().perp()) > m_maxRStartPrimary ||
101 std::abs(
particle->production_vertex()->position().z()) > m_maxZStartPrimary ) )
continue;
105 const HepPDT::ParticleData* pd = m_particleDataTable->particle(std::abs(pdgCode));
111 float charge = pd->charge();
112 if (std::abs(
charge)<0.5)
continue;
114 if (std::abs(
particle->momentum().perp()) > m_minPt && std::abs(
particle->momentum().pseudoRapidity()) < m_maxEta ) {