ATLAS Offline Software
Loading...
Searching...
No Matches
MuonDetectorDefs.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
5#include <GaudiKernel/SystemOfUnits.h>
6
7#ifndef SIMULATIONBASE
8# include <Acts/Geometry/VolumeBounds.hpp>
9# include <Acts/Geometry/CuboidVolumeBounds.hpp>
10# include <Acts/Geometry/TrapezoidVolumeBounds.hpp>
11# include <Acts/Geometry/DiamondVolumeBounds.hpp>
12# include <Acts/Geometry/TrackingVolume.hpp>
13#endif
14
15namespace MuonGMR4 {
17 using enum ActsTrk::DetectorType;
18 return type == Mdt || type == Rpc || type == Tgc ||
19 type == Mm || type == sTgc;
20 }
21
22 std::unique_ptr<ActsTrk::DetectorAlignStore> copyDeltas(const ActsTrk::DetectorAlignStore& inStore) {
23 auto newStore = std::make_unique<ActsTrk::DetectorAlignStore>(inStore);
24 if(newStore->geoModelAlignment) {
25 if (!inStore.geoModelAlignment->posCacheLocked()) {
26 newStore->geoModelAlignment->clearPosCache();
27 }
28 newStore->trackingAlignment = std::make_unique<ActsTrk::detail::TransformStore>(inStore.detType,
30 }
31 return newStore;
32 }
33 namespace detail{
34 Acts::Transform3 rotationToAMDB(const ActsTrk::DetectorType type) {
35 return type == ActsTrk::DetectorType::sTgc ? Acts::Transform3::Identity()
36 : Amg::getRotateY3D(90. * Gaudi::Units::deg) * Amg::getRotateZ3D(90. * Gaudi::Units::deg);
37 }
38 }
39
40#ifndef SIMULATIONBASE
41 double halfXlowY(const Acts::VolumeBounds& visitBounds) {
42 switch (visitBounds.type()) {
43 case Acts::VolumeBounds::BoundsType::eCuboid: {
44 const auto& bounds = static_cast<const Acts::CuboidVolumeBounds&>(visitBounds);
45 using BoundEnum = Acts::CuboidVolumeBounds::BoundValues;
46 return bounds.get(BoundEnum::eHalfLengthX);
47 }
48 case Acts::VolumeBounds::BoundsType::eTrapezoid: {
49 const auto& bounds = static_cast<const Acts::TrapezoidVolumeBounds&>(visitBounds);
50 using BoundEnum = Acts::TrapezoidVolumeBounds::BoundValues;
51 return bounds.get(BoundEnum::eHalfLengthXnegY);
52 } case Acts::VolumeBounds::BoundsType::eDiamond: {
53 const auto& bounds = static_cast<const Acts::DiamondVolumeBounds&>(visitBounds);
54 using BoundEnum = Acts::DiamondVolumeBounds::BoundValues;
55 return bounds.get(BoundEnum::eHalfLengthX2);
56 } default:
57 THROW_EXCEPTION("Unsupported bound type "<<visitBounds.type());
58 }
59 }
60 double halfXhighY(const Acts::VolumeBounds& visitBounds) {
61 switch (visitBounds.type()) {
62 case Acts::VolumeBounds::BoundsType::eCuboid: {
63 const auto& bounds = static_cast<const Acts::CuboidVolumeBounds&>(visitBounds);
64 using BoundEnum = Acts::CuboidVolumeBounds::BoundValues;
65 return bounds.get(BoundEnum::eHalfLengthX);
66 }
67 case Acts::VolumeBounds::BoundsType::eTrapezoid: {
68 const auto& bounds = static_cast<const Acts::TrapezoidVolumeBounds&>(visitBounds);
69 using BoundEnum = Acts::TrapezoidVolumeBounds::BoundValues;
70 return bounds.get(BoundEnum::eHalfLengthXposY);
71 } case Acts::VolumeBounds::BoundsType::eDiamond: {
72 const auto& bounds = static_cast<const Acts::DiamondVolumeBounds&>(visitBounds);
73 using BoundEnum = Acts::DiamondVolumeBounds::BoundValues;
74 return bounds.get(BoundEnum::eHalfLengthX1);
75 } default:
76 THROW_EXCEPTION("Unsupported bound type "<<visitBounds.type());
77 }
78 }
79 double halfY(const Acts::VolumeBounds& visitBounds) {
80 switch (visitBounds.type()) {
81 case Acts::VolumeBounds::BoundsType::eCuboid: {
82 const auto& bounds = static_cast<const Acts::CuboidVolumeBounds&>(visitBounds);
83 using BoundEnum = Acts::CuboidVolumeBounds::BoundValues;
84 return bounds.get(BoundEnum::eHalfLengthY);
85 } case Acts::VolumeBounds::BoundsType::eTrapezoid: {
86 const auto& bounds = static_cast<const Acts::TrapezoidVolumeBounds&>(visitBounds);
87 using BoundEnum = Acts::TrapezoidVolumeBounds::BoundValues;
88 return bounds.get(BoundEnum::eHalfLengthY);
89 } case Acts::VolumeBounds::BoundsType::eDiamond: {
90 const auto& bounds = static_cast<const Acts::DiamondVolumeBounds&>(visitBounds);
91 using BoundEnum = Acts::DiamondVolumeBounds::BoundValues;
92 return std::max(bounds.get(BoundEnum::eLengthY1),
93 bounds.get(BoundEnum::eLengthY2));
94 } default:
95 THROW_EXCEPTION("Unsupported bound type "<<visitBounds.type());
96 }
97
98 }
99 double halfZ(const Acts::VolumeBounds& visitBounds) {
100 switch (visitBounds.type()) {
101 case Acts::VolumeBounds::BoundsType::eCuboid: {
102 const auto& bounds = static_cast<const Acts::CuboidVolumeBounds&>(visitBounds);
103 using BoundEnum = Acts::CuboidVolumeBounds::BoundValues;
104 return bounds.get(BoundEnum::eHalfLengthZ);
105 } case Acts::VolumeBounds::BoundsType::eTrapezoid: {
106 const auto& bounds = static_cast<const Acts::TrapezoidVolumeBounds&>(visitBounds);
107 using BoundEnum = Acts::TrapezoidVolumeBounds::BoundValues;
108 return bounds.get(BoundEnum::eHalfLengthZ);
109 } case Acts::VolumeBounds::BoundsType::eDiamond: {
110 const auto& bounds = static_cast<const Acts::DiamondVolumeBounds&>(visitBounds);
111 using BoundEnum = Acts::DiamondVolumeBounds::BoundValues;
112 return bounds.get(BoundEnum::eHalfLengthZ);
113 } default:
114 THROW_EXCEPTION("Unsupported bound type "<<visitBounds.type());
115 }
116 }
117 inline const Acts::Surface* volumeLidBounadry(const Acts::TrackingVolume& volume,
118 const bool fetchBottom) {
119 if (!volume.isAlignable()) {
120 THROW_EXCEPTION("The tracking volume must be alignable "<<volume);
121 }
122 std::size_t portalIdx{volume.portals().size()};
123 switch (volume.volumeBounds().type()) {
124 using enum Acts::VolumeBounds::BoundsType;
125 case eCuboid: {
126 if (fetchBottom) {
127 portalIdx = Acts::toUnderlying(Acts::CuboidVolumeBounds::Face::NegativeZFace);
128 } else {
129 portalIdx = Acts::toUnderlying(Acts::CuboidVolumeBounds::Face::PositiveZFace);
130 }
131 break;
132 } case eTrapezoid: {
133 if (fetchBottom) {
134 portalIdx = Acts::toUnderlying(Acts::CuboidVolumeBounds::Face::NegativeZFace);
135 } else {
136 portalIdx = Acts::toUnderlying(Acts::CuboidVolumeBounds::Face::PositiveZFace);
137 }
138 break;
139 } case eDiamond: {
140 if (fetchBottom) {
141 portalIdx = Acts::toUnderlying(Acts::DiamondVolumeBounds::Face::NegativeZFaceXY);
142 } else {
143 portalIdx = Acts::toUnderlying(Acts::DiamondVolumeBounds::Face::PositiveZFaceXY);
144 }
145 break;
146 } default: {
147 THROW_EXCEPTION("Unknown boundary type "<<volume.volumeBounds());
148 }
149 }
150 const Acts::VolumePlacementBase* placement = volume.volumePlacement();
151 assert(portalIdx < placement->nPortalPlacements());
152 const Acts::SurfacePlacementBase* portalPlacement = placement->portalPlacement(portalIdx);
153 const Acts::Surface* surface = (&portalPlacement->surface());
154 if (surface->geometryId().withBoundary(0) != volume.geometryId()) {
155 std::stringstream portalStr{};
156 for (const Acts::Portal& portal : volume.portals()) {
157 portalStr<<"\n --- "<<portal.surface().type()<<" "
158 <<portal.surface().geometryId();
159 }
160 THROW_EXCEPTION("Expected volume and boundary ID to match "
161 <<volume.geometryId()<<" vs. "<<surface->geometryId().withBoundary(0)
162 <<"Portals: "<<portalStr.str());
163 }
164 return surface;
165
166 }
167 const Acts::Surface* bottomBoundary(const Acts::TrackingVolume& volume) {
168 return volumeLidBounadry(volume, true);
169 }
170 const Acts::Surface* topBoundary(const Acts::TrackingVolume& volume) {
171 return volumeLidBounadry(volume, false);
172 }
173 const Acts::TrackingVolume* highestAlignable(const Acts::TrackingVolume* volume) {
174 return !volume || !volume->motherVolume() || !volume->motherVolume()->isAlignable()
175 ? volume : highestAlignable(volume->motherVolume());
176 }
177
178#endif
179}
std::shared_ptr< GeoAlignmentStore > geoModelAlignment
Store containing the aligned GeoModel nodes.
DetectorType detType
The aligned detector element type.
bool posCacheLocked() const
Returns whether the position cache is locked.
DetectorType
Simple enum to Identify the Type of the ACTS sub detector.
@ sTgc
Micromegas (NSW).
Amg::Isometry3D getRotateY3D(double angle)
Rotate the coordinate system by an angle around the z-axis.
Amg::Isometry3D getRotateZ3D(double angle)
Rotate the coordinate system by an angle around the z-axis.
Acts::Transform3 rotationToAMDB(const ActsTrk::DetectorType type)
Returns the rotation matrix from the readout element coordinate system into the AMDB coordinate syste...
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
double halfY(const Acts::VolumeBounds &bounds)
Returns the half-Y length for the parsed volume bounds (Trapezoid/ Cuboid).
const Acts::Surface * bottomBoundary(const Acts::TrackingVolume &volume)
Returns the boundary surface parallel to the x-y plane at negative local z.
const Acts::TrackingVolume * highestAlignable(const Acts::TrackingVolume *volume)
Returns the highest parent volume that is alignable.
const Acts::Surface * topBoundary(const Acts::TrackingVolume &volume)
Returns the boundary surface parallel to the x-y plane at positive local z.
std::unique_ptr< ActsTrk::DetectorAlignStore > copyDeltas(const ActsTrk::DetectorAlignStore &inStore)
Copy the alignment deltas from the inStore to a new alignment store.
bool isMuon(const ActsTrk::DetectorType type)
Returns whether the parsed type is muon.
const Acts::Surface * volumeLidBounadry(const Acts::TrackingVolume &volume, const bool fetchBottom)
double halfZ(const Acts::VolumeBounds &bounds)
Returns the half-Z length for the parsed volume bounds (Trapezoid/ Cuboid).
double halfXhighY(const Acts::VolumeBounds &bounds)
Returns the half-Y length @ posiive Y for the parsed volume bounds (Trapezoid/ Cuboid).
double halfXlowY(const Acts::VolumeBounds &bounds)
Returns the half-X length @ negative Y for the parsed volume bounds (Trapezoid/ Cuboid).
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10