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::DetectorAlignStore::TrackingAlignStore>(inStore.detType);
29 }
30 return newStore;
31 }
32 namespace detail{
34 return type == ActsTrk::DetectorType::sTgc ? Amg::Transform3D::Identity()
35 : Amg::getRotateY3D(90. * Gaudi::Units::deg) * Amg::getRotateZ3D(90. * Gaudi::Units::deg);
36 }
37 }
38
39#ifndef SIMULATIONBASE
40 double halfXlowY(const Acts::VolumeBounds& visitBounds) {
41 switch (visitBounds.type()) {
42 case Acts::VolumeBounds::BoundsType::eCuboid: {
43 const auto& bounds = static_cast<const Acts::CuboidVolumeBounds&>(visitBounds);
44 using BoundEnum = Acts::CuboidVolumeBounds::BoundValues;
45 return bounds.get(BoundEnum::eHalfLengthX);
46 }
47 case Acts::VolumeBounds::BoundsType::eTrapezoid: {
48 const auto& bounds = static_cast<const Acts::TrapezoidVolumeBounds&>(visitBounds);
49 using BoundEnum = Acts::TrapezoidVolumeBounds::BoundValues;
50 return bounds.get(BoundEnum::eHalfLengthXnegY);
51 } case Acts::VolumeBounds::BoundsType::eDiamond: {
52 const auto& bounds = static_cast<const Acts::DiamondVolumeBounds&>(visitBounds);
53 using BoundEnum = Acts::DiamondVolumeBounds::BoundValues;
54 return bounds.get(BoundEnum::eHalfLengthX2);
55 } default:
56 THROW_EXCEPTION("Unsupported bound type "<<visitBounds.type());
57 }
58 return 0.;
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 return 0.;
79 }
80 double halfY(const Acts::VolumeBounds& visitBounds) {
81 switch (visitBounds.type()) {
82 case Acts::VolumeBounds::BoundsType::eCuboid: {
83 const auto& bounds = static_cast<const Acts::CuboidVolumeBounds&>(visitBounds);
84 using BoundEnum = Acts::CuboidVolumeBounds::BoundValues;
85 return bounds.get(BoundEnum::eHalfLengthY);
86 } case Acts::VolumeBounds::BoundsType::eTrapezoid: {
87 const auto& bounds = static_cast<const Acts::TrapezoidVolumeBounds&>(visitBounds);
88 using BoundEnum = Acts::TrapezoidVolumeBounds::BoundValues;
89 return bounds.get(BoundEnum::eHalfLengthY);
90 } case Acts::VolumeBounds::BoundsType::eDiamond: {
91 const auto& bounds = static_cast<const Acts::DiamondVolumeBounds&>(visitBounds);
92 using BoundEnum = Acts::DiamondVolumeBounds::BoundValues;
93 return std::max(bounds.get(BoundEnum::eLengthY1),
94 bounds.get(BoundEnum::eLengthY2));
95 } default:
96 THROW_EXCEPTION("Unsupported bound type "<<visitBounds.type());
97 }
98 return 0.;
99
100 }
101 double halfZ(const Acts::VolumeBounds& visitBounds) {
102 switch (visitBounds.type()) {
103 case Acts::VolumeBounds::BoundsType::eCuboid: {
104 const auto& bounds = static_cast<const Acts::CuboidVolumeBounds&>(visitBounds);
105 using BoundEnum = Acts::CuboidVolumeBounds::BoundValues;
106 return bounds.get(BoundEnum::eHalfLengthZ);
107 } case Acts::VolumeBounds::BoundsType::eTrapezoid: {
108 const auto& bounds = static_cast<const Acts::TrapezoidVolumeBounds&>(visitBounds);
109 using BoundEnum = Acts::TrapezoidVolumeBounds::BoundValues;
110 return bounds.get(BoundEnum::eHalfLengthZ);
111 } case Acts::VolumeBounds::BoundsType::eDiamond: {
112 const auto& bounds = static_cast<const Acts::DiamondVolumeBounds&>(visitBounds);
113 using BoundEnum = Acts::DiamondVolumeBounds::BoundValues;
114 return bounds.get(BoundEnum::eHalfLengthZ);
115 } default:
116 THROW_EXCEPTION("Unsupported bound type "<<visitBounds.type());
117 }
118 return 0.;
119 }
120 inline const Acts::Surface* volumeLidBounadry(const Acts::TrackingVolume& volume,
121 const bool fetchBottom) {
122 if (!volume.isAlignable()) {
123 THROW_EXCEPTION("The tracking volume must be alignable "<<volume);
124 }
125 std::size_t portalIdx{volume.portals().size()};
126 switch (volume.volumeBounds().type()) {
127 using enum Acts::VolumeBounds::BoundsType;
128 case eCuboid: {
129 if (fetchBottom) {
130 portalIdx = Acts::toUnderlying(Acts::CuboidVolumeBounds::Face::NegativeZFace);
131 } else {
132 portalIdx = Acts::toUnderlying(Acts::CuboidVolumeBounds::Face::PositiveZFace);
133 }
134 break;
135 } case eTrapezoid: {
136 if (fetchBottom) {
137 portalIdx = Acts::toUnderlying(Acts::CuboidVolumeBounds::Face::NegativeZFace);
138 } else {
139 portalIdx = Acts::toUnderlying(Acts::CuboidVolumeBounds::Face::PositiveZFace);
140 }
141 break;
142 } case eDiamond: {
143 if (fetchBottom) {
144 portalIdx = Acts::toUnderlying(Acts::DiamondVolumeBounds::Face::NegativeZFaceXY);
145 } else {
146 portalIdx = Acts::toUnderlying(Acts::DiamondVolumeBounds::Face::PositiveZFaceXY);
147 }
148 break;
149 } default: {
150 THROW_EXCEPTION("Unknown boundary type "<<volume.volumeBounds());
151 }
152 }
153 const Acts::VolumePlacementBase* placement = volume.volumePlacement();
154 assert(portalIdx < placement->nPortalPlacements());
155 const Acts::SurfacePlacementBase* portalPlacement = placement->portalPlacement(portalIdx);
156 const Acts::Surface* surface = (&portalPlacement->surface());
157 if (surface->geometryId().withBoundary(0) != volume.geometryId()) {
158 std::stringstream portalStr{};
159 for (const Acts::Portal& portal : volume.portals()) {
160 portalStr<<"\n --- "<<portal.surface().type()<<" "
161 <<portal.surface().geometryId();
162 }
163 THROW_EXCEPTION("Expected volume and boundary ID to match "
164 <<volume.geometryId()<<" vs. "<<surface->geometryId().withBoundary(0)
165 <<"Portals: "<<portalStr.str());
166 }
167 return surface;
168
169 }
170 const Acts::Surface* bottomBoundary(const Acts::TrackingVolume& volume) {
171 return volumeLidBounadry(volume, true);
172 }
173 const Acts::Surface* topBoundary(const Acts::TrackingVolume& volume) {
174 return volumeLidBounadry(volume, false);
175 }
176
177#endif
178}
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::Transform3D getRotateZ3D(double angle)
get a rotation transformation around Z-axis
Eigen::Affine3d Transform3D
Amg::Transform3D getRotateY3D(double angle)
get a rotation transformation around Y-axis
Amg::Transform3D 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::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