41 std::ifstream white_list;
42 white_list.open( resolvedFilename );
43 if (!white_list.is_open()){
45 return StatusCode::FAILURE;
51 while (!white_list.eof()){
52 getline( white_list , a_line );
53 long int pdg = strtol( a_line.c_str() , &pEnd , 10 );
57 ATH_MSG_DEBUG(
"pdgId " << pdg <<
" already in acceptlist. Will not add it again.");
66 return StatusCode::SUCCESS;
73 ATH_MSG_VERBOSE(
"Checking whether " << particle <<
" passes the filter." );
75 std::vector<int> vertices(500);
76 bool so_far_so_good =
pass( particle , vertices );
79 const int id_of_particle = particle->id();
80 if (so_far_so_good && particle->production_vertex() &&
m_qs){
81 for (
auto& pit: particle->production_vertex()->particles_in()){
83 if ( pit->id() == id_of_particle )
continue;
86 bool parent_all_clear =
pass( pit , vertices );
88 "\nIf true, will not pass the daughter because it should have been picked up through the parent already (to avoid multi-counting)." );
89 so_far_so_good = so_far_so_good && !parent_all_clear;
93 return so_far_so_good;
101 bool passFilter = std::binary_search(
m_pdgId.begin() ,
m_pdgId.end() , particle->pdg_id() ) ||
MC::isNucleus( particle->pdg_id() );
105 if (particle->end_vertex() &&
m_qs && passFilter){
110 passFilter = passFilter && ( (
m_minDecayRadiusQS < particle->end_vertex()->position().
perp()) || (m_minDecayRadiusQS < particle->production_vertex()->position().
perp()) );
113 if ( std::find( used_vertices.begin() , used_vertices.end() , particle->end_vertex()->id() )==used_vertices.end() ){
114 used_vertices.push_back( particle->end_vertex()->id() );
115 for (
auto& pit: particle->end_vertex()->particles_out()){
116 passFilter = passFilter &&
pass( pit , used_vertices );
129 ATH_MSG_ERROR(
"Found a particle with no end vertex that does not appear in the accept list." );
130 ATH_MSG_ERROR(
"This is VERY likely pointing to a problem with either the configuration you ");
131 ATH_MSG_ERROR(
"are using, or a bug in the generator. Either way it should be fixed. The");
132 ATH_MSG_ERROR(
"particle will come next, and then we will throw.");
134 throw std::runtime_error(
"GenParticleSimAcceptList: Particle with no end vertex and not in acceptlist");
144 return StatusCode::SUCCESS;
Scalar perp() const
perp method - perpendicular length
#define ATH_MSG_VERBOSE(x)
ATLAS-specific HepMC functions.
virtual StatusCode finalize() override final
virtual StatusCode initialize() override final
Athena algtool's Hooks.
virtual bool pass(const HepMC::ConstGenParticlePtr &particle) const override
passes through to the private version
BooleanProperty m_qs
Switch for quasi-stable particle simulation.
StringArrayProperty m_acceptLists
The location of the accept lists.
GenParticleSimAcceptList(const std::string &t, const std::string &n, const IInterface *p)
Constructor.
std::vector< long int > m_pdgId
Allowed PDG IDs.
DoubleProperty m_minDecayRadiusQS
Decay radius below which QS particles should be ignored.
BooleanProperty m_useShadowEvent
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
HepMC3::ConstGenParticlePtr ConstGenParticlePtr
bool isDecayed(const T &p)
Identify if the particle decayed.
bool isNucleus(const T &p)
PDG rule 16 Nuclear codes are given as 10-digit numbers ±10LZZZAAAI.
bool isPhysical(const T &p)
Identify if the particle is physical, i.e. is stable or decayed.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.