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"
13
16
17
18using namespace ActsTrk::detail::GeoVolIds;
19using namespace Acts::UnitLiterals;
20namespace ActsTrk{
23 return StatusCode::SUCCESS;
24 }
25
26 StatusCode GeometryEnvelopeTest::execute(const EventContext& ctx) {
27 const Acts::GeometryContext tgContext = m_trackingGeometrySvc->getNominalContext().context();
28
29 const Acts::TrackingGeometry* trkGeo = m_trackingGeometrySvc->trackingGeometry().get();
32 ATH_CHECK(checkVolume(tgContext, *trkGeo->highestTrackingVolume()));
35 auto checkEnevelope = [this](const StringProperty& envName,
36 const SystemEnvelope env) -> StatusCode {
37 if (envName.value().empty()) {
38 ATH_MSG_DEBUG("The envelope "<<envName<<" is undefined");
39 return StatusCode::SUCCESS;
40 }
41 const Acts::TrackingVolume* envelope = m_trackingGeometrySvc->getEnvelope(env);
42 if (!envelope) {
43 ATH_MSG_ERROR("The envelope "<<envName<<"/ "<<env<<" does not exist in the tracking geometry");
44 return StatusCode::FAILURE;
45 }
46 if (envelope->volumeName() != envName) {
47 ATH_MSG_ERROR("The envelope "<<envelope->volumeName()<<" "<<envelope->volumeBounds()<<" "
48 <<" has a different name than expected: "<<envName);
49 return StatusCode::FAILURE;
50 }
51 ATH_MSG_INFO("Envelopes match by name "<<envelope->volumeName()<<" "<<envelope->volumeBounds());
52 return StatusCode::SUCCESS;
53 };
57
58 ATH_MSG_INFO("Test succeeded "<<ctx.eventID());
59 return StatusCode::SUCCESS;
60 }
61 StatusCode GeometryEnvelopeTest::checkVolume(const Acts::GeometryContext& tgContext,
62 const Acts::TrackingVolume& volume) const {
63 ATH_MSG_VERBOSE("Check whether all volumes are within the envelope defined by "
64 <<volume.volumeName()<<", "<<volume.volumeBounds());
65 bool allGood{true};
66 std::vector<Amg::Vector3D> allSurfVertices{};
67
68 for (const Acts::Surface& surface : volume.surfaces()) {
69 ATH_MSG_INFO("Check surface "<<surface.geometryId()<<", "<<surface.bounds()<<", "
70 <<Amg::toString(surface.center(tgContext)));
71 std::vector<Amg::Vector3D> surfaceVertices = MuonGMR4::BoundsExpander::cornerPoints(tgContext, surface, m_nVertices);
72 for (const Amg::Vector3D& vert : surfaceVertices) {
73 const Amg::Vector3D lVert = volume.globalToLocalTransform(tgContext)* vert;
74 if (!volume.volumeBounds().inside(lVert, 0.1_mm)) {
75 ATH_MSG_ERROR("The vertex "<<Amg::toString(lVert)<<", perp:"<<lVert.perp()
76 <<" is not inside of the volume envelope "<<volume.volumeName()
77 <<" "<<volume.volumeBounds());
78 allGood = false;
79 }
80 }
81 allSurfVertices.insert(allSurfVertices.end(),
82 std::make_move_iterator(surfaceVertices.begin()),
83 std::make_move_iterator(surfaceVertices.end()));
84 }
85
86 for (const Acts::TrackingVolume& childVolume : volume.volumes()) {
88 for (const Amg::Vector3D& vert : MuonGMR4::BoundsExpander::cornerPoints(tgContext, childVolume,
89 m_nVertices)) {
90 const Amg::Vector3D lVert = volume.globalToLocalTransform(tgContext)* vert;
91 if (!volume.volumeBounds().inside(lVert)) {
92 ATH_MSG_ERROR("The vertex "<<Amg::toString(lVert)<<", perp:"<<lVert.perp()
93 <<" is not inside of the volume envelope "<<volume.volumeName()
94 <<" "<<volume.volumeBounds());
95 allGood = false;
96 }
97 }
98 for (const Amg::Vector3D& vert : allSurfVertices) {
99 const Amg::Vector3D lVert = childVolume.globalToLocalTransform(tgContext)* vert;
100 if (childVolume.volumeBounds().inside(lVert)) {
101 ATH_MSG_ERROR("The vertex "<<Amg::toString(lVert)<<", perp: "<<lVert.perp()
102 <<" is inside of the volume envelope "<<childVolume.volumeName()
103 <<" "<<childVolume.volumeBounds());
104 allGood = false;
105 }
106 }
107 }
108 if (!allGood) {
109 return StatusCode::FAILURE;
110 }
111 for (const Acts::TrackingVolume& childVolume : volume.volumes()) {
112 ATH_CHECK(checkVolume(tgContext, childVolume));
113 }
114 return StatusCode::SUCCESS;
115 }
116}
#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< unsigned > m_nVertices
Gaudi::Property< std::string > m_caloExitVolume
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...
Gaudi::Property< std::string > m_ITkExitVolume
static std::vector< Amg::Vector3D > cornerPoints(const Acts::GeometryContext &tgContext, const Acts::Volume &volume, const std::size_t nSegments=3)
Returns the vertices from a volume.
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