Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AntiTrigger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AntiTrigger.cc
1 #include "AntiTrigger.h"
2 
3 /*
4  * Find decay topologies in HepMC
5  * Cameron Dean
6  * 04/06/2021
7  */
8 
10  : SubsysReco("ANTITRIGGER")
11 {
12 }
13 
15  : SubsysReco(name)
16 {
17 }
18 
20 {
21  if (Verbosity() >= VERBOSITY_SOME)
22  {
23  std::cout << "AntiTrigger name: " << Name() << std::endl;
24 
25  int numberOfParticles = m_particleList.size();
26 
27  std::cout << "Particles to reject: ";
28  for (int i = 0; i < numberOfParticles; ++i)
29  {
30  std::cout << m_particleList[i];
31  if (i != numberOfParticles - 1) std::cout << ", ";
32  }
33  std::cout << std::endl;
34  }
35 
36  int canSearchDecay = parseParticleList();
37 
38  return canSearchDecay;
39 }
40 
42 {
43  bool particleFound = findParticle(topNode);
44 
45  if (particleFound)
46  {
47  m_counter += 1;
49  }
50  else
51  {
53  }
54 }
55 
57 {
59 
60  return 0;
61 }
62 
64 {
65  bool listCanBeParsed = true;
66 
67  for (int i = 0; i < m_particleList.size(); ++i)
68  {
70  {
71  m_particleIDs.push_back(TDatabasePDG::Instance()->GetParticle(m_particleList[i].c_str())->PdgCode());
72  }
73  else
74  {
75  listCanBeParsed = false;
76  }
77  }
78 
79  if (listCanBeParsed)
80  {
81  if (Verbosity() >= VERBOSITY_MORE) std::cout << "Your particle list can be parsed" << std::endl;
82  return 0;
83  }
84  else
85  {
86  if (Verbosity() >= VERBOSITY_SOME) std::cout << "Your particle list cannot be parsed, " << Name() << " will not be registered" << std::endl;
88  }
89 }
90 
92 {
93  bool particleWasFound = false;
94 
95  m_geneventmap = findNode::getClass<PHHepMCGenEventMap>(topNode, "PHHepMCGenEventMap");
96  if (!m_geneventmap)
97  {
98  std::cout << "AntiTrigger: Missing node PHHepMCGenEventMap" << std::endl;
99  return 0;
100  }
101 
102  m_genevt = m_geneventmap->get(1);
103  if (!m_genevt)
104  {
105  std::cout << "AntiTrigger: Missing node PHHepMCGenEvent" << std::endl;
106  return 0;
107  }
108 
109  HepMC::GenEvent* theEvent = m_genevt->getEvent();
110 
111  for (HepMC::GenEvent::particle_const_iterator p = theEvent->particles_begin(); p != theEvent->particles_end(); ++p)
112  {
113  if (std::find(m_particleIDs.begin(), m_particleIDs.end(), abs((*p)->pdg_id())) != m_particleIDs.end())
114  {
115  particleWasFound = true;
116  if (Verbosity() >= VERBOSITY_MORE) std::cout << "This event will be rejected due to: " << (*p)->pdg_id() << std::endl;
117  }
118  }
119 
120  return particleWasFound;
121 }
122 
124 {
125  bool particleFound = true;
126  if (!TDatabasePDG::Instance()->GetParticle(particle.c_str()))
127  {
128  if (Verbosity() >= VERBOSITY_SOME)
129  {
130  std::cout << "The particle, " << particle << " is not in the particle list" << std::endl;
131  std::cout << "Check TDatabasePDG for a list of available particles" << std::endl;
132  }
133  particleFound = false;
134  }
135 
136  return particleFound;
137 }
138 
140 {
141  std::cout << "\n---------------AntiTrigger information---------------" << std::endl;
142  std::cout << "AntiTrigger name: " << Name() << std::endl;
143  int numberOfParticles = m_particleList.size();
144  std::cout << "Particles to reject: ";
145  for (int i; i < numberOfParticles; ++i)
146  {
147  std::cout << m_particleList[i];
148  if (i != numberOfParticles - 1) std::cout << ", ";
149  }
150  std::cout << std::endl;
151  std::cout << "Number of events skipped: " << m_counter << std::endl;
152  std::cout << "-----------------------------------------------------\n" << std::endl;
153 }