ATLAS Offline Software
Loading...
Searching...
No Matches
GeometryEnvelopeTest.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5
6#include "Acts/Geometry/TrackingVolume.hpp"
7#include "Acts/Geometry/TrackingGeometry.hpp"
8#include "Acts/Geometry/VolumeBounds.hpp"
9#include "Acts/Surfaces/Surface.hpp"
10#include "Acts/Surfaces/RegularSurface.hpp"
11#include "Acts/Surfaces/SurfaceBounds.hpp"
12#include "Acts/Definitions/Units.hpp"
14
15
16using namespace ActsTrk::detail::GeoVolIds;
17using namespace Acts::UnitLiterals;
18namespace ActsTrk{
21 return StatusCode::SUCCESS;
22 }
23
24 StatusCode GeometryEnvelopeTest::execute(const EventContext& ctx) {
25 const Acts::GeometryContext tgContext = m_trackingGeometrySvc->getNominalContext().context();
26
27 const Acts::TrackingGeometry* trkGeo = m_trackingGeometrySvc->trackingGeometry().get();
30 ATH_CHECK(checkVolume(tgContext, *trkGeo->highestTrackingVolume()));
33 auto checkEnevelope = [this](const StringProperty& envName,
34 const SystemEnvelope env) -> StatusCode {
35 if (envName.value().empty()) {
36 ATH_MSG_DEBUG("The envelope "<<envName<<" is undefined");
37 return StatusCode::SUCCESS;
38 }
39 const Acts::TrackingVolume* envelope = m_trackingGeometrySvc->getEnvelope(env);
40 if (!envelope) {
41 ATH_MSG_ERROR("The envelope "<<envName<<"/ "<<env<<" does not exist in the tracking geometry");
42 return StatusCode::FAILURE;
43 }
44 if (envelope->volumeName() != envName) {
45 ATH_MSG_ERROR("The envelope "<<envelope->volumeName()<<" "<<envelope->volumeBounds()<<" "
46 <<" has a different name than expected: "<<envName);
47 return StatusCode::FAILURE;
48 }
49 ATH_MSG_INFO("Envelopes match by name "<<envelope->volumeName()<<" "<<envelope->volumeBounds());
50 return StatusCode::SUCCESS;
51 };
55
56 ATH_MSG_INFO("Test succeeded "<<ctx.eventID());
57 return StatusCode::SUCCESS;
58 }
59 StatusCode GeometryEnvelopeTest::checkVolume(const Acts::GeometryContext& tgContext,
60 const Acts::TrackingVolume& volume) const {
61 ATH_MSG_VERBOSE("Check whether all volumes are within the envelope defined by "
62 <<volume.volumeName()<<", "<<volume.volumeBounds());
63 bool allGood{true};
64 for (const Acts::TrackingVolume& childVolume : volume.volumes()) {
65 for (const Amg::Vector3D& vert : edges(tgContext, childVolume)) {
66 const Amg::Vector3D lVert = volume.globalToLocalTransform(tgContext)* vert;
67
68 if (!volume.volumeBounds().inside(lVert)) {
69 ATH_MSG_ERROR("The vertex "<<Amg::toString(lVert)<<", perp:"<<lVert.perp()
70 <<" is not inside of the volume envelope "<<volume.volumeName()
71 <<" "<<volume.volumeBounds());
72 allGood = false;
73 }
74 }
75 }
76 if (!allGood) {
77 return StatusCode::FAILURE;
78 }
79 for (const Acts::Surface& surface : volume.surfaces()) {
80 for (const Amg::Vector3D& vert : vertices(tgContext, surface)) {
81 const Amg::Vector3D lVert = volume.globalToLocalTransform(tgContext)* vert;
82 if (!volume.volumeBounds().inside(lVert, 0.1_mm)) {
83 ATH_MSG_ERROR("The vertex "<<Amg::toString(lVert)<<", perp:"<<lVert.perp()
84 <<" is not inside of the volume envelope "<<volume.volumeName()
85 <<" "<<volume.volumeBounds());
86 allGood = false;
87 }
88 }
89 }
90 if (!allGood) {
91 return StatusCode::FAILURE;
92 }
93 for (const Acts::TrackingVolume& childVolume : volume.volumes()) {
94 ATH_CHECK(checkVolume(tgContext, childVolume));
95 }
96 return StatusCode::SUCCESS;
97 }
98 std::vector<Amg::Vector3D> GeometryEnvelopeTest::edges(const Acts::GeometryContext& tgContext,
99 const Acts::TrackingVolume& volume) const {
100 std::vector<Amg::Vector3D> result{};
101 for (const auto& oriented : volume.volumeBounds().orientedSurfaces(volume.localToGlobalTransform(tgContext))) {
102 std::vector<Amg::Vector3D> verts = vertices(tgContext,*oriented.surface);
103 result.insert(result.end(),
104 std::make_move_iterator(verts.begin()),
105 std::make_move_iterator(verts.end()));
106 }
107 return result;
108 }
109 std::vector<Amg::Vector3D> GeometryEnvelopeTest::vertices(const Acts::GeometryContext& tgContext,
110 const Acts::Surface& surface) const {
111 Acts::Polyhedron polyhedron = surface.polyhedronRepresentation(tgContext, 10);
112 return polyhedron.vertices;
113 }
114}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(x,...)
ServiceHandle< ActsTrk::ITrackingGeometrySvc > m_trackingGeometrySvc
The handle to the tracking geometry service.
virtual StatusCode execute(const EventContext &ctx) override final
Execute method.
Gaudi::Property< std::string > m_caloExitVolume
std::vector< Amg::Vector3D > vertices(const Acts::GeometryContext &tgContext, const Acts::Surface &surface) const
Extracts the vertices from a surface.
virtual StatusCode initialize() override final
Gaudi::Property< std::string > m_MsExitVolume
StatusCode checkVolume(const Acts::GeometryContext &tgContext, const Acts::TrackingVolume &volume) const
Checks whether all subvolumes are contained in the volume Method recursively called for each subvolum...
std::vector< Amg::Vector3D > edges(const Acts::GeometryContext &tgContext, const Acts::TrackingVolume &volume) const
Extracts the vertices form the TrackingVolume marking its edges.
Gaudi::Property< std::string > m_ITkExitVolume
Define the volume parts of the GeometryIdentifier for each ATLAS subsystem centrally.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
SystemEnvelope
Define an enumeration to retrieve the envelope tracking volume from.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Matrix< double, 3, 1 > Vector3D