ECCE @ EIC 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 (ConstIter iter = decaymap.begin(); iter != decaymap.end(); ++iter)
23  {
24  Decay decay = iter->second;
25  m_decaymap.insert(std::make_pair(iter->first, decay));
26  }
27 }
28 
30 {
31  Reset();
32  for (ConstIter iter = decaymap.begin(); iter != decaymap.end(); ++iter)
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  Decay dummyDecay = {{0, 0}};
59  ConstIter iter = m_decaymap.find(id);
60  if (iter == m_decaymap.end()) return dummyDecay;
61  return iter->second;
62 }
63 
65 {
66  Decay dummyDecay = {{0, 0}};
67  Iter iter = m_decaymap.find(id);
68  if (iter == m_decaymap.end()) return dummyDecay;
69  return iter->second;
70 }
71 
73 {
74  unsigned int index = 0;
75  if (!m_decaymap.empty()) index = m_decaymap.rbegin()->first + 1;
76  m_decaymap.insert(std::make_pair(index, decay));
77  return m_decaymap[index];
78 }
79 
81 {
82  Map requiredDecays;
83 
84  for (Iter iter = m_decaymap.begin(); iter != m_decaymap.end(); ++iter)
85  for (auto& [particleNumber, particleType] : iter->second)
86  if (particleType == PDGid)
87  requiredDecays.insert(std::make_pair(iter->first, iter->second));
88 
89  return requiredDecays;
90 }
91 
92 size_t DecayFinderContainer_v1::erase(unsigned int key)
93 {
94  return m_decaymap.erase(key);
95 }