Skip to content

Commit

Permalink
fix: Write surface only once in the MaterialMapJsonConverter (#787)
Browse files Browse the repository at this point in the history
With this PR when converting a tracking geometry to a Hierarchy the volume that have already been added to the hierarchy won't be added a second time. This solve the issue that if a volume belong to multiple volumes (as it is the case for the Calorimeter in the Acts ATLAS implementation) the code would result in an error (since hierarchy can only have each identifier appear once)
  • Loading branch information
Corentin-Allaire committed Apr 28, 2021
1 parent ec14282 commit ffd0c8a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Plugins/Json/src/MaterialMapJsonConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <Acts/Surfaces/RadialBounds.hpp>
#include <Acts/Surfaces/SurfaceBounds.hpp>

#include <algorithm>
#include <map>

namespace {
Expand Down Expand Up @@ -256,6 +257,16 @@ void Acts::MaterialMapJsonConverter::convertToHierarchy(
std::vector<std::pair<GeometryIdentifier, Acts::SurfaceAndMaterial>>&
surfaceHierarchy,
const Acts::TrackingVolume* tVolume) {
auto sameId =
[tVolume](
std::pair<GeometryIdentifier, Acts::TrackingVolumeAndMaterial> pair) {
return (tVolume->geometryId() == pair.first);
};
if (std::find_if(volumeHierarchy.begin(), volumeHierarchy.end(), sameId) !=
volumeHierarchy.end()) {
// this volume was already visited
return;
}
if ((tVolume->volumeMaterial() != nullptr ||
m_cfg.processNonMaterial == true) &&
m_cfg.processVolumes == true) {
Expand Down

0 comments on commit ffd0c8a

Please sign in to comment.