LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ParticleAncestryMap.cxx
Go to the documentation of this file.
1 #ifndef PARTICLEANCESTRYMAP_CXX
2 #define PARTICLEANCESTRYMAP_CXX
3 
5 
6 #include <limits>
7 
8 namespace sim {
9 
10  void ParticleAncestryMap::SetMap(const std::map<int, std::set<int>>& map)
11  {
12  fParticleMap = map;
13  }
14 
15  std::map<int, std::set<int>> const& ParticleAncestryMap::GetMap() const
16  {
17  return fParticleMap;
18  }
19 
20  bool ParticleAncestryMap::HasDroppedDescendants(const int trackid) const
21  {
22  return fParticleMap.count(trackid) != 0;
23  }
24 
25  std::set<int> const& ParticleAncestryMap::GetAllDroppedDescendants(const int trackid) const
26  {
27  return fParticleMap.at(trackid);
28  }
29 
30  int ParticleAncestryMap::GetAncestor(const int trackid) const
31  {
32  for (auto const& [ancestor, descendants] : fParticleMap) {
33  if (descendants.count(trackid) != 0) return ancestor;
34  }
35 
36  return -std::numeric_limits<int>::max();
37  }
38 
39  bool ParticleAncestryMap::Exists(const int trackid) const
40  {
41  return trackid != -std::numeric_limits<int>::max();
42  }
43 }
44 
45 #endif
std::set< int > const & GetAllDroppedDescendants(const int trackid) const
bool HasDroppedDescendants(const int trackid) const
std::map< int, std::set< int > > fParticleMap
Monte Carlo Simulation.
int GetAncestor(const int trackid) const
void SetMap(const std::map< int, std::set< int >> &map)
bool Exists(const int trackid) const
std::map< int, std::set< int > > const & GetMap() const