Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Particle Ancestry Map Fix #38

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions lardataobj/Simulation/ParticleAncestryMap.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,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 @@ -28,7 +28,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