38 for (
auto &acceptList : m_acceptLists) {
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 );
54 if (
std::find(m_pdgId.begin(), m_pdgId.end(), pdg) == m_pdgId.end()) {
55 m_pdgId.push_back(pdg);
57 ATH_MSG_DEBUG(
"pdgId " << pdg <<
" already in acceptlist. Will not add it again.");
62 std::sort( m_pdgId.begin() , m_pdgId.end() );
66 return StatusCode::SUCCESS;
74 ATH_MSG_VERBOSE(
"Checking whether " << particle <<
" passes the filter." );
76 std::vector<int> vertices(500);
77 bool so_far_so_good = pass( particle , vertices );
80 const int id_of_particle = particle->id();
81 if (so_far_so_good && particle->production_vertex() && m_qs){
82 for (
auto& pit: particle->production_vertex()->particles_in()){
84 if ( pit->id() == id_of_particle )
continue;
87 bool parent_all_clear = pass( pit , vertices );
89 "\nIf true, will not pass the daughter because it should have been picked up through the parent already (to avoid multi-counting)." );
90 so_far_so_good = so_far_so_good && !parent_all_clear;
94 return so_far_so_good;
100 ATH_MSG_VERBOSE(
"Checking whether " << particle <<
" passes the filter." );
102 std::vector<int> vertices(500);
103 bool so_far_so_good = pass( particle , vertices );
106 if (so_far_so_good && particle.production_vertex() && m_qs){
107 for (HepMC::GenVertex::particle_iterator
it = particle.production_vertex()->particles_begin(
HepMC::parents);
113 bool parent_all_clear = pass( **
it , vertices );
115 "\nIf true, will not pass the daughter because it should have been picked up through the parent already (to avoid multi-counting)." );
116 so_far_so_good = so_far_so_good && !parent_all_clear;
120 return so_far_so_good;
129 bool passFilter = std::binary_search( m_pdgId.begin() , m_pdgId.end() , particle->pdg_id() ) ||
MC::isNucleus( particle->pdg_id() );
133 if (particle->end_vertex() && m_qs &&
passFilter){
138 passFilter =
passFilter && ( (m_minDecayRadiusQS < particle->end_vertex()->position().perp()) || (m_minDecayRadiusQS < particle->production_vertex()->position().perp()) );
141 if (
std::find( used_vertices.begin() , used_vertices.end() , particle->end_vertex()->id() )==used_vertices.end() ){
142 used_vertices.push_back( particle->end_vertex()->id() );
143 for (
auto& pit: particle->end_vertex()->particles_out()){
153 ATH_MSG_VERBOSE(
"Particle " << particle <<
" was produced and decayed within a radius of " << m_minDecayRadiusQS <<
" mm.");
157 ATH_MSG_ERROR(
"Found a particle with no end vertex that does not appear in the accept list." );
158 ATH_MSG_ERROR(
"This is VERY likely pointing to a problem with either the configuration you ");
159 ATH_MSG_ERROR(
"are using, or a bug in the generator. Either way it should be fixed. The");
160 ATH_MSG_ERROR(
"particle will come next, and then we will throw.");
162 throw std::runtime_error(
"GenParticleSimAcceptList: Particle with no end vertex and not in acceptlist");
171 bool passFilter = std::binary_search( m_pdgId.begin() , m_pdgId.end() , particle.pdg_id() ) ||
MC::isNucleus( particle.pdg_id() );
175 if (particle.end_vertex() && m_qs &&
passFilter){
180 passFilter =
passFilter && ( (m_minDecayRadiusQS < particle.end_vertex()->position().perp()) || (m_minDecayRadiusQS < particle.production_vertex()->position().perp()) );
183 if (
std::find( used_vertices.begin() , used_vertices.end() ,
HepMC::uniqueID(particle.end_vertex()) )==used_vertices.end() ){
185 for (HepMC::GenVertex::particle_iterator
it = particle.end_vertex()->particles_begin(
HepMC::children);
196 ATH_MSG_VERBOSE(
"Particle " << particle <<
" was produced and decayed within a radius of " << m_minDecayRadiusQS <<
" mm.");
199 if (!m_useShadowEvent && !particle.end_vertex() &&
MC::isDecayed(&particle)) {
200 ATH_MSG_ERROR(
"Found a particle with no end vertex that does not appear in the accept list." );
201 ATH_MSG_ERROR(
"This is VERY likely pointing to a problem with either the configuration you ");
202 ATH_MSG_ERROR(
"are using, or a bug in the generator. Either way it should be fixed. The");
203 ATH_MSG_ERROR(
"particle will come next, and then we will throw.");
205 throw std::runtime_error(
"GenParticleSimAcceptList: Particle with no end vertex and not in acceptlist");
215 return StatusCode::SUCCESS;