Skip to content

Commit

Permalink
Merge pull request #38 from henrylay97/feature/hlay_particle_ancestry…
Browse files Browse the repository at this point in the history
…_map_fix

Particle Ancestry Map Fix
  • Loading branch information
lgarren committed Jun 1, 2023
2 parents 0f1b273 + f8fe9c4 commit b1e837e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions lardataobj/Simulation/ParticleAncestryMap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ namespace sim {

std::map<int, std::set<int>> const& ParticleAncestryMap::GetMap() const { return fParticleMap; }

bool ParticleAncestryMap::HasDroppedDescendants(const int trackid)
bool ParticleAncestryMap::HasDroppedDescendants(const int trackid) const
{
return fParticleMap.count(trackid) != 0;
}

std::set<int> const& ParticleAncestryMap::GetAllDroppedDescendants(const int trackid)
std::set<int> const& ParticleAncestryMap::GetAllDroppedDescendants(const int trackid) const
{
return fParticleMap[trackid];
return fParticleMap.at(trackid);
}

int ParticleAncestryMap::GetAncestor(const int trackid)
int ParticleAncestryMap::GetAncestor(const int trackid) const
{
for (auto const& [ancestor, descendants] : fParticleMap) {
if (descendants.count(trackid) != 0) return ancestor;
Expand All @@ -30,7 +30,7 @@ namespace sim {
return -std::numeric_limits<int>::max();
}

bool ParticleAncestryMap::Exists(const int trackid)
bool ParticleAncestryMap::Exists(const int trackid) const
{
return trackid != -std::numeric_limits<int>::max();
}
Expand Down
8 changes: 4 additions & 4 deletions lardataobj/Simulation/ParticleAncestryMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ namespace sim {
std::map<int, std::set<int>> const& GetMap() const;

// Whether there are any dropped descendants for a given track id
bool HasDroppedDescendants(const int trackid);
bool HasDroppedDescendants(const int trackid) const;

// Return the set of dropped descendants from a given ancestor's track id
std::set<int> const& GetAllDroppedDescendants(const int trackid);
std::set<int> const& GetAllDroppedDescendants(const int trackid) const;

// Get the stored ancestor from a given dropped track id
int GetAncestor(const int trackid);
int GetAncestor(const int trackid) const;

// Whether or not the returned track id from GetAncestor is valid or set to the default value
bool Exists(const int trackid);
bool Exists(const int trackid) const;
};
}
#endif

0 comments on commit b1e837e

Please sign in to comment.