ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ISF::GenParticleSimAcceptList Class Reference

#include <GenParticleSimAcceptList.h>

Inheritance diagram for ISF::GenParticleSimAcceptList:
Collaboration diagram for ISF::GenParticleSimAcceptList:

Public Member Functions

 GenParticleSimAcceptList (const std::string &t, const std::string &n, const IInterface *p)
 Constructor. More...
 
 ~GenParticleSimAcceptList ()
 Destructor. More...
 
virtual StatusCode initialize () override final
 Athena algtool's Hooks. More...
 
virtual StatusCode finalize () override final
 
virtual bool pass (const HepMC::GenParticle &particle) const override
 passes through to the private version More...
 

Private Member Functions

bool pass (const HepMC::GenParticle &particle, std::vector< int > &used_vertices) const
 returns true if the the particle and all daughters are on the accept list More...
 

Private Attributes

StringArrayProperty m_acceptLists {this, "AcceptLists", {"G4particle_acceptlist.txt"} }
 The location of the accept lists. More...
 
std::vector< long int > m_pdgId
 Allowed PDG IDs. More...
 
BooleanProperty m_qs {this, "QuasiStableSim", true}
 Switch for quasi-stable particle simulation. More...
 
BooleanProperty m_useShadowEvent {this, "UseShadowEvent", false, "New approach to selecting particles for simulation" }
 
DoubleProperty m_minDecayRadiusQS {this, "MinimumDecayRadiusQS", 30.19*Gaudi::Units::mm}
 Decay radius below which QS particles should be ignored. More...
 

Detailed Description

Stable/Interacting particle filter for HepMC particles to be used in the stack filling process. Checks this particle and all daughters.

Author
ZLMarshall -at- lbl.gov

Definition at line 31 of file GenParticleSimAcceptList.h.

Constructor & Destructor Documentation

◆ GenParticleSimAcceptList()

ISF::GenParticleSimAcceptList::GenParticleSimAcceptList ( const std::string &  t,
const std::string &  n,
const IInterface *  p 
)

Constructor.

Definition at line 23 of file GenParticleSimAcceptList.cxx.

26  : base_class(t,n,p)
27 {
28 }

◆ ~GenParticleSimAcceptList()

ISF::GenParticleSimAcceptList::~GenParticleSimAcceptList ( )
inline

Destructor.

Definition at line 38 of file GenParticleSimAcceptList.h.

38 {}

Member Function Documentation

◆ finalize()

StatusCode ISF::GenParticleSimAcceptList::finalize ( )
finaloverridevirtual

Definition at line 212 of file GenParticleSimAcceptList.cxx.

213 {
214  ATH_MSG_VERBOSE("Finalizing ...");
215  return StatusCode::SUCCESS;
216 }

◆ initialize()

StatusCode ISF::GenParticleSimAcceptList::initialize ( )
finaloverridevirtual

Athena algtool's Hooks.

Definition at line 31 of file GenParticleSimAcceptList.cxx.

32 {
33  ATH_MSG_VERBOSE("Initializing ...");
34 
35  // Initialize the list
36  m_pdgId.clear();
37 
38  for (auto &acceptList : m_acceptLists) {
39  // Get the appropriate file handle
40  std::string resolvedFilename = PathResolver::find_file( acceptList , "DATAPATH" );
41  std::ifstream white_list;
42  white_list.open( resolvedFilename );
43  if (!white_list.is_open()){
44  ATH_MSG_ERROR("Could not find accept list " << acceptList);
45  return StatusCode::FAILURE;
46  }
47 
48  // Parse the list into the vector
49  std::string a_line;
50  char * pEnd;
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);
56  } else {
57  ATH_MSG_DEBUG("pdgId " << pdg << " already in acceptlist. Will not add it again.");
58  }
59  }
60 
61  // Sort the list for use later
62  std::sort( m_pdgId.begin() , m_pdgId.end() );
63  }
64 
65  // All done!
66  return StatusCode::SUCCESS;
67 }

◆ pass() [1/2]

bool ISF::GenParticleSimAcceptList::pass ( const HepMC::GenParticle particle) const
overridevirtual

passes through to the private version

passes through to the private version of the filter

Definition at line 97 of file GenParticleSimAcceptList.cxx.

98 {
99 
100  ATH_MSG_VERBOSE( "Checking whether " << particle << " passes the filter." );
101 
102  std::vector<int> vertices(500);
103  bool so_far_so_good = pass( particle , vertices );
104 
105  // Test all parent particles
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);
108  it != particle.production_vertex()->particles_end(HepMC::parents); ++it){
109  // Loop breaker
110  if ( HepMC::uniqueID(*it) == HepMC::uniqueID(particle) ) continue;
111  // Check this particle
112  vertices.clear();
113  bool parent_all_clear = pass( **it , vertices );
114  ATH_MSG_VERBOSE( "Parent all clear: " << parent_all_clear <<
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;
117  } // Loop over parents
118  } // particle had parents
119 
120  return so_far_so_good;
121 }

◆ pass() [2/2]

bool ISF::GenParticleSimAcceptList::pass ( const HepMC::GenParticle particle,
std::vector< int > &  used_vertices 
) const
private

returns true if the the particle and all daughters are on the accept list

Definition at line 168 of file GenParticleSimAcceptList.cxx.

169 {
170  // See if the particle is in the accept list
171  bool passFilter = std::binary_search( m_pdgId.begin() , m_pdgId.end() , particle.pdg_id() ) || MC::isNucleus( particle.pdg_id() );
172  // Remove documentation particles
174  // Test all daughter particles
175  if (particle.end_vertex() && m_qs && passFilter){
176  // Primarily interested in passing particles decaying outside
177  // m_minDecayRadiusQS (nomimally the inner radius of the
178  // beampipe). However, it is also interesting to pass particles
179  // which start outside m_minDecayRadiusQS, but decay inside it.
180  passFilter = passFilter && ( (m_minDecayRadiusQS < particle.end_vertex()->position().perp()) || (m_minDecayRadiusQS < particle.production_vertex()->position().perp()) );
181  if (passFilter) {
182  // Break loops
183  if ( std::find( used_vertices.begin() , used_vertices.end() , HepMC::uniqueID(particle.end_vertex()) )==used_vertices.end() ){
184  used_vertices.push_back( HepMC::uniqueID(particle.end_vertex()) );
185  for (HepMC::GenVertex::particle_iterator it = particle.end_vertex()->particles_begin(HepMC::children);
186  it != particle.end_vertex()->particles_end(HepMC::children); ++it){
187  passFilter = passFilter && pass( **it , used_vertices );
188  if (!passFilter) {
189  ATH_MSG_VERBOSE( "Daughter particle " << **it << " does not pass." );
190  break;
191  }
192  } // Loop over daughters
193  } // Break loops
194  } // particle decayed before the min radius to be considered for simulation
195  else {
196  ATH_MSG_VERBOSE( "Particle " << particle << " was produced and decayed within a radius of " << m_minDecayRadiusQS << " mm.");
197  }
198  } // particle had daughters
199  if (!m_useShadowEvent && !particle.end_vertex() && MC::isDecayed(&particle)) { // no daughters... No end vertex... Check if this isn't trouble
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");
206  }
207 
208  return passFilter;
209 }

Member Data Documentation

◆ m_acceptLists

StringArrayProperty ISF::GenParticleSimAcceptList::m_acceptLists {this, "AcceptLists", {"G4particle_acceptlist.txt"} }
private

The location of the accept lists.

Definition at line 58 of file GenParticleSimAcceptList.h.

◆ m_minDecayRadiusQS

DoubleProperty ISF::GenParticleSimAcceptList::m_minDecayRadiusQS {this, "MinimumDecayRadiusQS", 30.19*Gaudi::Units::mm}
private

Decay radius below which QS particles should be ignored.

Definition at line 62 of file GenParticleSimAcceptList.h.

◆ m_pdgId

std::vector<long int> ISF::GenParticleSimAcceptList::m_pdgId
private

Allowed PDG IDs.

Definition at line 59 of file GenParticleSimAcceptList.h.

◆ m_qs

BooleanProperty ISF::GenParticleSimAcceptList::m_qs {this, "QuasiStableSim", true}
private

Switch for quasi-stable particle simulation.

Definition at line 60 of file GenParticleSimAcceptList.h.

◆ m_useShadowEvent

BooleanProperty ISF::GenParticleSimAcceptList::m_useShadowEvent {this, "UseShadowEvent", false, "New approach to selecting particles for simulation" }
private

Definition at line 61 of file GenParticleSimAcceptList.h.


The documentation for this class was generated from the following files:
ISF::GenParticleSimAcceptList::m_minDecayRadiusQS
DoubleProperty m_minDecayRadiusQS
Decay radius below which QS particles should be ignored.
Definition: GenParticleSimAcceptList.h:62
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
isNucleus
bool isNucleus(const T &p)
Definition: AtlasPID.h:212
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
PathResolver::find_file
static std::string find_file(const std::string &logical_file_name, const std::string &search_path, SearchType search_type=LocalSearch)
Definition: PathResolver.cxx:251
python.DecayParser.parents
parents
print ("==> buf:",buf)
Definition: DecayParser.py:31
ISF::GenParticleSimAcceptList::m_pdgId
std::vector< long int > m_pdgId
Allowed PDG IDs.
Definition: GenParticleSimAcceptList.h:59
skel.it
it
Definition: skel.GENtoEVGEN.py:423
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
covarianceTool.passFilter
bool passFilter
Definition: covarianceTool.py:604
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
ISF::GenParticleSimAcceptList::m_useShadowEvent
BooleanProperty m_useShadowEvent
Definition: GenParticleSimAcceptList.h:61
ISF::GenParticleSimAcceptList::pass
virtual bool pass(const HepMC::GenParticle &particle) const override
passes through to the private version
Definition: GenParticleSimAcceptList.cxx:97
ISF::GenParticleSimAcceptList::m_qs
BooleanProperty m_qs
Switch for quasi-stable particle simulation.
Definition: GenParticleSimAcceptList.h:60
MC::isPhysical
bool isPhysical(const T &p)
Definition: HepMCHelpers.h:32
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
beamspotman.n
n
Definition: beamspotman.py:731
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
HepMC::uniqueID
int uniqueID(const T &p)
Definition: MagicNumbers.h:113
ISF::GenParticleSimAcceptList::m_acceptLists
StringArrayProperty m_acceptLists
The location of the accept lists.
Definition: GenParticleSimAcceptList.h:58
std::sort
void sort(typename std::reverse_iterator< DataModel_detail::iterator< DVL > > beg, typename std::reverse_iterator< DataModel_detail::iterator< DVL > > end, const Compare &comp)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:623
MC::isDecayed
bool isDecayed(const T &p)
Definition: HepMCHelpers.h:29
python.DecayParser.children
children
Definition: DecayParser.py:32