Skip to content

Commit

Permalink
Issue warning if surface not planar in draw surfaces (#1274)
Browse files Browse the repository at this point in the history
### Briefly, what does this PR introduce?
Issue warning if surface not planar in draw surfaces

### What kind of change does this PR introduce?
- [x] Bug fix (issue #1273)
- [ ] New feature (issue #__)
- [ ] Documentation update
- [ ] Other: __

### Please check if this PR fulfills the following:
- [ ] Tests for the changes have been added
- [ ] Documentation has been added / updated
- [ ] Changes have been communicated to collaborators

### Does this PR introduce breaking changes? What changes might users
need to make to their code?

### Does this PR change default behavior?

---------

Co-authored-by: Wouter Deconinck <[email protected]>
  • Loading branch information
rahmans1 and wdconinc authored Feb 9, 2024
1 parent e96cfd7 commit 8d28402
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/algorithms/tracking/ActsGeometryProvider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct fmt::formatter<
> : fmt::ostream_formatter {};
#endif // FMT_VERSION >= 90000

void draw_surfaces(std::shared_ptr<const Acts::TrackingGeometry> trk_geo, const Acts::GeometryContext geo_ctx,
void draw_surfaces(std::shared_ptr<const Acts::TrackingGeometry> trk_geo, const Acts::GeometryContext geo_ctx, std::shared_ptr<spdlog::logger> init_log,
const std::string &fname) {
using namespace Acts;
std::vector<const Surface *> surfaces;
Expand All @@ -68,6 +68,10 @@ void draw_surfaces(std::shared_ptr<const Acts::TrackingGeometry> trk_geo, const
size_t nVtx = 0;
for (const auto &srfx: surfaces) {
const auto *srf = dynamic_cast<const PlaneSurface *>(srfx);
if (srf==nullptr){
init_log->error("Warning: Attempting cast a {} to Acts::PlaneSurface returns nullptr. This surface will not be added to the .obj output.", srfx->name());
continue;
}
const auto *bounds = dynamic_cast<const PlanarBounds *>(&srf->bounds());
for (const auto &vtxloc: bounds->vertices()) {
Vector3 vtx = srf->transform(geo_ctx) * Vector3(vtxloc.x(), vtxloc.y(), 0);
Expand Down Expand Up @@ -187,7 +191,7 @@ void ActsGeometryProvider::initialize(const dd4hep::Detector* dd4hep_geo,
// Visit surfaces
m_init_log->info("Checking surfaces...");
if (m_trackingGeo) {
draw_surfaces(m_trackingGeo, m_trackingGeoCtx, "tracking_geometry.obj");
draw_surfaces(m_trackingGeo, m_trackingGeoCtx, m_init_log, "tracking_geometry.obj");

m_init_log->debug("visiting all the surfaces ");
m_trackingGeo->visitSurfaces([this](const Acts::Surface *surface) {
Expand Down
2 changes: 1 addition & 1 deletion src/algorithms/tracking/ActsGeometryProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace dd4hep::rec {
* This is useful for debugging the ACTS geometry. The obj file can
* be loaded into various tools, such as FreeCAD, for inspection.
*/
void draw_surfaces(std::shared_ptr<const Acts::TrackingGeometry> trk_geo, const std::string &fname);
void draw_surfaces(std::shared_ptr<const Acts::TrackingGeometry> trk_geo, std::shared_ptr<spdlog::logger> init_log, const std::string &fname);

class ActsGeometryProvider {
public:
Expand Down

0 comments on commit 8d28402

Please sign in to comment.