Skip to content

Commit

Permalink
Moved to isometries in GeoModel Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
pbutti committed Feb 4, 2025
1 parent 098e751 commit 361ca5d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
10 changes: 6 additions & 4 deletions Plugins/GeoModel/src/GeoModelDetectorObjectFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ void Acts::GeoModelDetectorObjectFactory::convertFpv(
std::vector<GeoModelSensitiveSurface> sensitives;

for (const auto &surface : surfaces) {
//Ths assumes that surface.transform returns an isometry as it doesn't check for it
const Transform3 &transform =
fpv->getAbsoluteTransform() * Eigen::Isometry3d(surface.transform);
Eigen::Isometry3d(fpv->getAbsoluteTransform().matrix()) * Eigen::Isometry3d(surface.transform.matrix());
convertSensitive(surface.volume, transform, sensitives);
}
cache.sensitiveSurfaces.insert(cache.sensitiveSurfaces.end(),
Expand All @@ -172,7 +173,8 @@ void Acts::GeoModelDetectorObjectFactory::convertFpv(
const GeoLogVol *logVol =
physVol->getLogVol(); // get logVol for the shape of the volume
const GeoShape *shape = logVol->getShape(); // get shape
const Acts::Transform3 &fpvtransform = fpv->getAbsoluteTransform(nullptr);
// Assuming that the return is an isometry without checking for it
const Acts::Transform3 &fpvtransform = Eigen::Isometry3d((fpv->getAbsoluteTransform(nullptr)).matrix());

// convert bounding boxes with surfaces inside
std::shared_ptr<Experimental::DetectorVolume> box =
Expand All @@ -182,8 +184,8 @@ void Acts::GeoModelDetectorObjectFactory::convertFpv(
}
// If fpv has no subs and should not be converted to volume convert to surface
else if (subvolumes.empty()) {
// convert fpvs to surfaces
const Transform3 &transform = fpv->getAbsoluteTransform();
// convert fpvs to surfaces assuming the transforms are isometries
const Transform3 &transform = Eigen::Isometry3d((fpv->getAbsoluteTransform()).matrix());
convertSensitive(fpv, transform, cache.sensitiveSurfaces);
}

Expand Down
9 changes: 6 additions & 3 deletions Plugins/GeoModel/src/GeoModelToDetectorVolume.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,14 @@ Volume convertVolume(const Transform3& trf, const GeoShape& shape) {
dynamic_cast<const GeoShapeShift*>(&shape);
const GeoShape* shapeOp = shiftShape->getOp();
newTrf = trf * shiftShape->getX();
return convertVolume(Eigen::Isometry3d(newTrf), *shapeOp);
//This assumes, without checking, that newTrf is an isometry
return convertVolume(Eigen::Isometry3d(newTrf.matrix()), *shapeOp);
} else {
throw std::runtime_error("FATAL: Unsupported GeoModel shape: " +
shape.type());
}
return Volume(newTrf, bounds);
// This assumes newTrk is an isometry
return Volume(Eigen::Isometry3d(newTrf.matrix()), bounds);
}

std::shared_ptr<Experimental::DetectorVolume> convertDetectorVolume(
Expand All @@ -146,7 +148,8 @@ std::shared_ptr<Experimental::DetectorVolume> convertDetectorVolume(
return std::get<1>(t);
});
auto portalGenerator = Experimental::defaultPortalAndSubPortalGenerator();
Volume vol = convertVolume(transform, shape);
// This directly assumes that the transform is an isometry and doesn't check for it
Volume vol = convertVolume(Eigen::Isometry3d(transform.matrix()), shape);
return Experimental::DetectorVolumeFactory::construct(
portalGenerator, context, name, vol.transform(), vol.volumeBoundsPtr(),
sensSurfaces,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ Acts::detail::GeoIntersectionAnnulusConverter::operator()(
// Get the shift
const GeoShapeShift* shapeShift = dynamic_cast<const GeoShapeShift*>(opB);
if (shapeShift != nullptr) {
const Transform3& shift = shapeShift->getX();
// This assumes that shapeShift->getX() is an isometry as it doesn't check for it
const Transform3& shift = Eigen::Isometry3d(shapeShift->getX().matrix());
const GeoGenericTrap* trap =
dynamic_cast<const GeoGenericTrap*>(shapeShift->getOp());
if (trap != nullptr) {
Expand Down
2 changes: 1 addition & 1 deletion Plugins/GeoModel/src/detail/GeoPolygonConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Acts::detail::GeoPolygonConverter::operator()(
// Create the surface transform
Transform3 transform = Transform3::Identity();
transform.translation() = unitLength * absTransform.translation();
auto rotation = absTransform.rotation();
RotationMatrix3 rotation = absTransform.linear();
// Get the half lengths
int nVertices = polygon.getNVertices();
std::vector<std::vector<double>> vertices;
Expand Down
3 changes: 2 additions & 1 deletion Plugins/GeoModel/src/detail/GeoShiftConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ Result<GeoModelSensitiveSurface> impl(PVConstLink geoPV,
;
}

const Transform3& shift = geoShift.getX();
// Warning: This doesn't check if geoShift.getX() is really an isometry.
const Transform3& shift = Eigen::Isometry3d(geoShift.getX().matrix());

const auto& conversionRes =
Converter{}(geoPV, *trd, absTransform * shift, sensitive);
Expand Down

0 comments on commit 361ca5d

Please sign in to comment.