Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DecayFinderContainer_v1.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DecayFinderContainer_v1.cc
1 /*****************/
2 /* Cameron Dean */
3 /* LANL 2021 */
4 /* cdean@bnl.gov */
5 /*****************/
6 
8 
9 #include <map> // for _Rb_tree_const_iterator, _Rb_tree_iterator
10 #include <ostream> // for operator<<, endl, ostream, basic_ostream, bas...
11 #include <utility> // for pair, make_pair
12 #include <vector> // for vector
13 
15  : m_decaymap()
16 {
17 }
18 
20  : m_decaymap()
21 {
22  for (const auto& iter : decaymap)
23  {
24  Decay decay = iter.second;
25  m_decaymap.insert(std::make_pair(iter.first, decay));
26  }
27 }
28 
30 {
31  Reset();
32  for (const auto& iter : decaymap)
33  {
34  Decay decay = iter.second;
35  m_decaymap.insert(std::make_pair(iter.first, decay));
36  }
37  return *this;
38 }
39 
41 {
42  Reset();
43 }
44 
46 {
47  m_decaymap.clear();
48 }
49 
50 void DecayFinderContainer_v1::identify(std::ostream& os) const
51 {
52  os << "DecayFinderContainer_v1: size = " << m_decaymap.size() << std::endl;
53  return;
54 }
55 
57 {
58  std::pair<int, int> dummyPair = {0, 0};
59  Decay dummyDecay = {{dummyPair, 0}};
60  ConstIter iter = m_decaymap.find(id);
61  if (iter == m_decaymap.end())
62  {
63  return dummyDecay;
64  }
65  return iter->second;
66 }
67 
69 {
70  std::pair<int, int> dummyPair = {0, 0};
71  Decay dummyDecay = {{dummyPair, 0}};
72  Iter iter = m_decaymap.find(id);
73  if (iter == m_decaymap.end())
74  {
75  return dummyDecay;
76  }
77  return iter->second;
78 }
79 
81 {
82  unsigned int index = 0;
83  if (!m_decaymap.empty())
84  {
85  index = m_decaymap.rbegin()->first + 1;
86  }
87  m_decaymap.insert(std::make_pair(index, decay));
88  return m_decaymap[index];
89 }
90 
92 {
93  Map requiredDecays;
94 
95  for (auto& iter : m_decaymap)
96  {
97  for (auto& [particleNumber, particleType] : iter.second)
98  {
99  if (particleType == PDGid)
100  {
101  requiredDecays.insert(std::make_pair(iter.first, iter.second));
102  }
103  }
104  }
105 
106  return requiredDecays;
107 }
108 
109 size_t DecayFinderContainer_v1::erase(unsigned int key)
110 {
111  return m_decaymap.erase(key);
112 }