ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EICPIDParticleContainer.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EICPIDParticleContainer.cc
2 
3 #include <phool/phool.h>
4 
5 #include <TSystem.h>
6 
7 #include <cstdlib>
8 #include "EICPIDParticle.h"
9 #include "EICPIDParticlev1.h"
10 
11 using namespace std;
12 
14 {
15 }
16 
18 {
19  while (m_particleMap.begin() != m_particleMap.end())
20  {
21  delete m_particleMap.begin()->second;
22  m_particleMap.erase(m_particleMap.begin());
23  }
24  return;
25 }
26 
27 void EICPIDParticleContainer::identify(ostream& os) const
28 {
29  ConstIterator iter;
30  os << "Number of PIDParticles: " << size() << endl;
31  for (iter = m_particleMap.begin(); iter != m_particleMap.end(); ++iter)
32  {
33  os << "PIDParticles ID " << iter->first << ": ";
34  (iter->second)->identify();
35  }
36  return;
37 }
38 
41 {
42  EICPIDDefs::keytype key = newhit->get_id();
43  if (m_particleMap.find(key) != m_particleMap.end())
44  {
45  cout << "hit with id " << key << " exists already" << endl;
46  return m_particleMap.find(key);
47  }
48  return m_particleMap.insert(std::make_pair(key, newhit)).first;
49 }
50 
52 {
53  return std::make_pair(m_particleMap.begin(), m_particleMap.end());
54 }
55 
57 {
58  EICPIDParticleContainer::Iterator it = m_particleMap.find(key);
59  if (it == m_particleMap.end())
60  {
61  m_particleMap[key] = new EICPIDParticlev1();
62  it = m_particleMap.find(key);
63  EICPIDParticle* mhit = it->second;
64  mhit->set_id(key);
65  }
66  return it;
67 }
68 
70 {
71  EICPIDParticleContainer::ConstIterator it = m_particleMap.find(key);
72  if (it != m_particleMap.end())
73  {
74  return it->second;
75  }
76 
77  return nullptr;
78 }