ATLAS Offline Software
Loading...
Searching...
No Matches
MuonGMR4::TrapezoidBoundsExpander Class Reference

#include <TrapezoidBoundsExpander.h>

Inheritance diagram for MuonGMR4::TrapezoidBoundsExpander:
Collaboration diagram for MuonGMR4::TrapezoidBoundsExpander:

Classes

struct  TrapezoidPatch
 Helper struct to describe a sub trapezoid that is not aligned with the center of the coordinate system. More...

Public Types

enum class  Side : std::int8_t { left = -1 , right = 1 }
 Enum to select the left / right corners of a trapezoid. More...
enum class  Level : std::int8_t { bottom = -1 , top = 1 }
 Enum to select the top / bottom corners of a trapezoid. More...
using VolumeAligner_t = std::function<Acts::Transform3(const Acts::GeometryContext& tgContext)>
 Abrivation of the transform getter.

Public Member Functions

virtual void expand (const Acts::GeometryContext &tgContext, const Acts::Volume &volume) override final
virtual std::shared_ptr< Acts::VolumeBounds > makeBounds (Acts::VolumeBoundFactory &factory) override final
void setMargin (const double margin)
 Apply an extra margin to all four bound dimensions.
void setMargin (const double marginXlow, const double marginXhigh, const double marginY, const double marginZ)
 Apply an extra margin to each individual bound side.
 BoundsExpander ()=default
 Use the constructor from the base class.
 BoundsExpander (const Acts::Transform3 &toVolume, std::unique_ptr< const Acts::Logger > loggerObj=nullptr)
 Use the constructor from the base class.
void expand (const Acts::GeometryContext &tgContext, const MuonGMR4::Chamber &chamber)
 Use the expand overloads w.r.t.
void expand (const Acts::GeometryContext &tgContext, const MuonGMR4::SpectrometerSector &sector)
 Use the expand overloads w.r.t.
void expand (const Acts::GeometryContext &tgContext, const MuonGMR4::MuonReadoutElement &readoutElement, Acts::VolumeBoundFactory &boundFactory)
 Use the expand overloads w.r.t.
std::unique_ptr< Acts::TrackingVolume > makeEnvelope (Acts::VolumeBoundFactory &factory, std::string_view volName)
 Creates an empty tracking volume.
Acts::Transform3 toVertexCenter () const
 Returns the transform from the ATLAS frame to the center of all seen vertices.
const Acts::Transform3 & boxMidPoint () const
 Returns the transform from the nominal volume center to the middle point to all seen vertices.
void reCenter (std::span< const Amg::Vector3D > vertices)
 Update the center point from a list of global vertices.
std::span< const double > minima () const
 Returns the triplet of the minimum coordinates from the ensemble of all seen vertices.
std::span< const double > maxima () const
 Returns the triplet of the maximum coordinates from the ensemble of all seen vertices.
const Acts::Logger & logger () const
 Returns the ACTS logegr object.

Static Public Member Functions

static Amg::Vector3D makeVertex (const TrapezoidPatch &trapezoid, const Side side, const Level lvl)
 Returns the vertex point from a trapezoid.
static double distanceToTrapezoid (const Amg::Vector3D &vertex, const Amg::Vector3D &edge, const Amg::Vector3D &testMe, const Side side)
 Returns the distance to the inclided trapezoidal side Positive values imply that the test point is outside of the trapezoid edge.
static std::uint8_t toIndex (const Side side, const Level lvl)
 Construct an index from [0;3] from the side and level.
static std::shared_ptr< Acts::VolumeBounds > makeBounds (const MuonGMR4::MuonReadoutElement &readoutElement, Acts::VolumeBoundFactory &boundFactory)
 Use the makeBounds overload for the readout element.
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.
static std::vector< Amg::Vector3D > cornerPoints (const Acts::GeometryContext &tgContext, const Acts::Surface &surface, const std::size_t nSegments=3)
 Returns the vertices from a surface.

Private Member Functions

void findTrapezoidEdge (Amg::Vector3D &botCorner, Amg::Vector3D &topCorner, const Side side, const std::size_t lowPatch, const std::size_t highPatch) const
 Moves the position of the bottom and top corner of a trapezoid side such that all vertices are enclosed.

Private Attributes

std::vector< TrapezoidPatch > m_constituents {}
std::shared_ptr< Acts::VolumeBounds > m_finalBounds {}
std::array< double, 4 > m_margin {Acts::filledArray<double, 4>(0.)}
std::unique_ptr< const Acts::Logger > m_logger
Acts::Transform3 m_toVolume {Acts::Transform3::Identity()}
 External method to go from ATLAS to the reference frame.
Acts::Transform3 m_shiftTrf {Acts::Transform3::Identity()}
 Extra shift to center all the vertices.
std::array< double, 3 > m_locMax {Acts::filledArray<double, 3>(-2.*Acts::UnitConstants::km)}
 Maximum value seen by the recenter method.
std::array< double, 3 > m_locMin {Acts::filledArray<double, 3>(2.*Acts::UnitConstants::km)}
 Minimum value seen by the recenter method.

Friends

std::ostream & operator<< (std::ostream &ostr, const Side side)
 Pipe the Side to an ostream.
std::ostream & operator<< (std::ostream &ostr, const Level lvl)
 Pipe the Level to an ostream.

Detailed Description

Definition at line 13 of file TrapezoidBoundsExpander.h.

Member Typedef Documentation

◆ VolumeAligner_t

using MuonGMR4::BoundsExpander::VolumeAligner_t = std::function<Acts::Transform3(const Acts::GeometryContext& tgContext)>
inherited

Abrivation of the transform getter.

Definition at line 62 of file BoundsExpander.h.

Member Enumeration Documentation

◆ Level

enum class MuonGMR4::TrapezoidBoundsExpander::Level : std::int8_t
strong

Enum to select the top / bottom corners of a trapezoid.

Enumerator
bottom 
top 

Definition at line 38 of file TrapezoidBoundsExpander.h.

38: std::int8_t { bottom= -1, top = 1 };

◆ Side

enum class MuonGMR4::TrapezoidBoundsExpander::Side : std::int8_t
strong

Enum to select the left / right corners of a trapezoid.

Enumerator
left 
right 

Definition at line 36 of file TrapezoidBoundsExpander.h.

36: std::int8_t{left = -1, right = 1};

Member Function Documentation

◆ BoundsExpander() [1/2]

Use the constructor from the base class.

◆ BoundsExpander() [2/2]

MuonGMR4::BoundsExpander::BoundsExpander ( const Acts::Transform3 & toVolume,
std::unique_ptr< const Acts::Logger > loggerObj = nullptr )
explicit

Use the constructor from the base class.

Definition at line 69 of file BoundsExpander.cxx.

26 :
27 m_toVolume{toVolume} {
28 if (loggerObj) {
29 m_logger = std::move(loggerObj);
30 }
31 }
Acts::Transform3 m_toVolume
External method to go from ATLAS to the reference frame.
std::unique_ptr< const Acts::Logger > m_logger

◆ boxMidPoint()

const Acts::Transform3 & MuonGMR4::BoundsExpander::boxMidPoint ( ) const
inherited

Returns the transform from the nominal volume center to the middle point to all seen vertices.

Definition at line 42 of file BoundsExpander.cxx.

42 {
43 return m_shiftTrf;
44 }
Acts::Transform3 m_shiftTrf
Extra shift to center all the vertices.

◆ cornerPoints() [1/2]

std::vector< Amg::Vector3D > MuonGMR4::BoundsExpander::cornerPoints ( const Acts::GeometryContext & tgContext,
const Acts::Surface & surface,
const std::size_t nSegments = 3 )
staticinherited

Returns the vertices from a surface.

Parameters
tgContextThe geometry context to align the surface
volumeThe surface from which the vertices shall be retrieved
nSegmentsNumber of segments to be generated

Don't use the polyhedron representation for rectangles and trapezoids as we need the central point on the edge to properly constrain the radius of a surrounding cylinder

Definition at line 131 of file BoundsExpander.cxx.

133 {
134 constexpr std::array signs{-1., 1.};
135 std::vector<Amg::Vector3D> vertices{}; //vertices has size zero
136 //calculate transform once, outside of loops
137 const Acts::Transform3& transform = surface.localToGlobalTransform(tgContext);
141 switch (surface.bounds().type()) {
142 using enum Acts::SurfaceBounds::BoundsType;
143 case eRectangle: {
144 const auto& bounds{static_cast<const Acts::RectangleBounds&>(surface.bounds())};
145 using enum Acts::RectangleBounds::BoundValues;
146 const double stepX = 2.*bounds.get(eMaxX) / nSegments;
147 const double stepY = 2.*bounds.get(eMaxY) / nSegments;
148 for (const double sign : signs) {
149 for (unsigned seg = 0; seg <= nSegments ; ++seg) {
150 vertices.push_back(transform *
151 Amg::Vector3D{-bounds.get(eMaxX) + stepX * seg,
152 sign*bounds.get(eMaxY), 0.});
153 vertices.push_back(transform *
154 Amg::Vector3D{sign*bounds.get(eMaxX),
155 -bounds.get(eMaxY) + stepY * seg, 0.});
156 }
157 }
158 break;
159 } case eTrapezoid: {
160 const auto& bounds{static_cast<const Acts::TrapezoidBounds&>(surface.bounds())};
161 using enum Acts::TrapezoidBounds::BoundValues;
162 const double hY = bounds.get(eHalfLengthY);
163 const double xS = bounds.get(eHalfLengthXnegY);
164 const double xL = bounds.get(eHalfLengthXposY);
165 const double m = (xL - xS) / (2.*hY);
166 Amg::Vector3D locPos{Amg::Vector3D::Zero()};
167 auto pushVertex = [&](const double x, const double y) {
168 locPos.block<2,1>(0,0) = Eigen::Rotation2D{-bounds.get(eRotationAngle)} *
170 vertices.push_back(transform *locPos);
171 };
172 const double stepY = 2.*hY / nSegments;
173 for (const double sign : signs) {
174 const double x = (sign > 0 ? xL : xS);
175 const double stepX = 2.*x / nSegments;
176 for (unsigned seg = 0; seg <= nSegments ; ++seg){
177 pushVertex(-x + stepX*seg, sign*hY);
178 const double y = -hY + stepY*seg;
179 pushVertex(sign*(xS + (y+hY)*m), y);
180 }
181 }
182 break;
183 } default: {
184 vertices = surface.polyhedronRepresentation(tgContext, nSegments).vertices;
185 break;
186 }
187 }
188 return vertices;
189 }
int sign(int a)
#define y
#define x
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D

◆ cornerPoints() [2/2]

std::vector< Amg::Vector3D > MuonGMR4::BoundsExpander::cornerPoints ( const Acts::GeometryContext & tgContext,
const Acts::Volume & volume,
const std::size_t nSegments = 3 )
staticinherited

Returns the vertices from a volume.

Parameters
tgContextThe geometry context to align the volume
volumeThe volume from which the vertices shall be retrieved
nSegmentsNumber of segments to be generated

Definition at line 114 of file BoundsExpander.cxx.

116 {
117 std::vector<Amg::Vector3D> edges{};
118 const Acts::VolumeBounds& bounds{volume.volumeBounds()};
119 const Acts::Transform3& trf{volume.localToGlobalTransform(tgContext)};
120 for (const Acts::OrientedSurface& boundary : bounds.orientedSurfaces(trf)) {
121 std::vector<Amg::Vector3D> corners = cornerPoints(tgContext, *boundary.surface, nSegments);
122 edges.insert(edges.end(), std::make_move_iterator(corners.begin()),
123 std::make_move_iterator(corners.end()));
124 }
125 auto [begin, end] = std::ranges::unique(edges, [](const Amg::Vector3D& a, const Amg::Vector3D& b) {
126 return (a - b).mag2() < Acts::s_onSurfaceTolerance;
127 });
128 edges.erase(begin, end);
129 return edges;
130 }
static Double_t a
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.

◆ distanceToTrapezoid()

double MuonGMR4::TrapezoidBoundsExpander::distanceToTrapezoid ( const Amg::Vector3D & vertex,
const Amg::Vector3D & edge,
const Amg::Vector3D & testMe,
const Side side )
static

Returns the distance to the inclided trapezoidal side Positive values imply that the test point is outside of the trapezoid edge.

Parameters
vertexThe side vertex of the trapezoid
edgeThe direction vector describing the inclined edge
testMeThe external point to test
sideFlag to toggle whether the edge is on the left or right

Definition at line 62 of file TrapezoidBoundsExpander.cxx.

65 {
66 const Amg::Vector3D closest = intersectPlane(vertex, edge,
67 Amg::Vector3D::UnitY(), testMe).position();
68 return (testMe.x() - closest.x()) *Acts::toUnderlying(side);
69}

◆ expand() [1/4]

void MuonGMR4::TrapezoidBoundsExpander::expand ( const Acts::GeometryContext & tgContext,
const Acts::Volume & volume )
finaloverridevirtual

Implements MuonGMR4::BoundsExpander.

Definition at line 50 of file TrapezoidBoundsExpander.cxx.

51 {
52 ACTS_DEBUG(__func__<<"() "<<__LINE__<<" - Bounds "<<volume.volumeBounds());
53 reCenter(cornerPoints(tgContext, volume));
54 m_constituents.emplace_back(volume.localToGlobalTransform(tgContext),
55 volume.volumeBoundsPtr());
56}
void reCenter(std::span< const Amg::Vector3D > vertices)
Update the center point from a list of global vertices.
std::vector< TrapezoidPatch > m_constituents

◆ expand() [2/4]

void MuonGMR4::BoundsExpander::expand ( const Acts::GeometryContext & tgContext,
const MuonGMR4::Chamber & chamber )

Use the expand overloads w.r.t.

chamber, sector

Definition at line 74 of file BoundsExpander.cxx.

33 {
34 expand(tgContext, *chamber.boundingVolume());
35 }
virtual void expand(const Acts::GeometryContext &tgContext, const Acts::Volume &volume) override final

◆ expand() [3/4]

void MuonGMR4::BoundsExpander::expand ( const Acts::GeometryContext & tgContext,
const MuonGMR4::MuonReadoutElement & readoutElement,
Acts::VolumeBoundFactory & boundFactory )

Use the expand overloads w.r.t.

chamber, sector

Definition at line 86 of file BoundsExpander.cxx.

83 {
84 expand(tgContext, Acts::Volume{readoutElement.localToGlobalTransform(tgContext),
85 makeBounds(readoutElement, boundFactory)});
86 }
const Acts::Transform3 & localToGlobalTransform(const ActsTrk::GeometryContext &ctx) const override final
Returns the transformation from the local coordinate system of the readout element into the global AT...
virtual std::shared_ptr< Acts::VolumeBounds > makeBounds(Acts::VolumeBoundFactory &factory) override final

◆ expand() [4/4]

void MuonGMR4::BoundsExpander::expand ( const Acts::GeometryContext & tgContext,
const MuonGMR4::SpectrometerSector & sector )

Use the expand overloads w.r.t.

chamber, sector

Definition at line 79 of file BoundsExpander.cxx.

39 {
40 expand(tgContext, *sector.boundingVolume());
41 }
std::shared_ptr< Acts::Volume > boundingVolume() const
Returns the Acts::Volume representation of the sector.

◆ findTrapezoidEdge()

void MuonGMR4::TrapezoidBoundsExpander::findTrapezoidEdge ( Amg::Vector3D & botCorner,
Amg::Vector3D & topCorner,
const Side side,
const std::size_t lowPatch,
const std::size_t highPatch ) const
private

Moves the position of the bottom and top corner of a trapezoid side such that all vertices are enclosed.

The parallel lines are assumed to be at +-halfY. The inclined edge is tilted to enclose all vertices

Parameters
botCornerThe bottom corner to be moved
topCOrnerThe top corner to be moved
sideIs the left or the right side of the trapezoid considered
lowPatchFirst trapezoid patch to consider
highPatchLast trapezoid patch to consider

Update the slope of the tilted trapezoid edge to find the steepest one

If the point is outwards update the outer vertex and the slope

Try to decrease

Definition at line 183 of file TrapezoidBoundsExpander.cxx.

187 {
188 const double halfY = 0.5*(maxima()[Amg::y] - minima()[Amg::y]);
189 botCorner = makeVertex(m_constituents.at(lowPatch), side, Level::bottom);
190 topCorner = makeVertex(m_constituents.at(highPatch), side, Level::top);
191 Amg::Vector3D edge = Amg::projectDirOntoPlane((botCorner - topCorner).unit(),
192 Amg::Vector3D::UnitZ());
193 botCorner = intersectPlane(botCorner, edge, Amg::Vector3D::UnitY(), -halfY).position();
194 topCorner = intersectPlane(topCorner, edge, Amg::Vector3D::UnitY(), halfY).position();
195
196 double steepM{0.};
198 auto updateSlope = [&]( const Amg::Vector3D& v) {
199 if (v.y() <= botCorner.y()) {
200 return;
201 }
202 const double m = (v.x() - botCorner.x()) / (v.y() - botCorner.y());
203 if(std::abs(m)> std::abs(steepM)) {
204 steepM = m;
205 }
206 };
207 updateSlope(topCorner);
208 ACTS_DEBUG(__func__<<"() "<<__LINE__<<" - Identified "<<Amg::toString(botCorner)
209 <<", "<<Amg::toString(topCorner)<<" as vertices. Edge: "<<Amg::toString(edge));
210 Amg::Vector3D farestVtx{botCorner};
211 double area{0.};
212 for (const TrapezoidPatch& patch : m_constituents) {
213 area += patch.area();
214 for (auto lvl : {Level::bottom, Level::top}) {
215 const Amg::Vector3D vtx = makeVertex(patch, side, lvl);
216 const double d = distanceToTrapezoid(botCorner, edge, vtx, side);
217 ACTS_VERBOSE(__func__<<"() "<<__LINE__<<" - Vertex at "<<lvl
218 <<" edge "<<Amg::toString(vtx)<<" distance: "<<d);
220 if (d > 0. && d > distanceToTrapezoid(botCorner, edge, farestVtx, side)) {
221 updateSlope(vtx);
222 farestVtx = vtx;
223 ACTS_VERBOSE(__func__<<"() "<<__LINE__<<" - Shift the trapezoid.");
224 }
225 }
226 }
227 ACTS_VERBOSE(__func__<<"() "<<__LINE__<<" - The farest "<<Amg::toString(farestVtx)<<" with distance "
228 <<distanceToTrapezoid(botCorner, edge, farestVtx, side)<<", steepest m: "<<steepM
229 <<", start M: "<<(topCorner.x() - botCorner.x()) / (topCorner.y() - botCorner.y()));
230
231 edge = Amg::Vector3D{steepM, 1., 0.}.unit();
232 botCorner = intersectPlane(farestVtx, edge, Amg::Vector3D::UnitY(), -halfY).position();
233 topCorner = intersectPlane(farestVtx, edge, Amg::Vector3D::UnitY(), halfY).position();
235 const double envArea = (std::abs(botCorner.x()) + std::abs(topCorner.x()))* 2.*halfY;
236 ACTS_VERBOSE(__func__<<"() "<<__LINE__<<" - Update corners to "<<Amg::toString(botCorner)
237 <<" (bottom) and "<<Amg::toString(topCorner)<<" (top) New area: "<<envArea
238 <<", old area: "<<area<<", diff: "<<(area/ envArea));
239}
double area(double R)
detray::unit< scalar_t > unit
std::span< const double > maxima() const
Returns the triplet of the maximum coordinates from the ensemble of all seen vertices.
std::span< const double > minima() const
Returns the triplet of the minimum coordinates from the ensemble of all seen vertices.
static Amg::Vector3D makeVertex(const TrapezoidPatch &trapezoid, const Side side, const Level lvl)
Returns the vertex point from a trapezoid.
static double distanceToTrapezoid(const Amg::Vector3D &vertex, const Amg::Vector3D &edge, const Amg::Vector3D &testMe, const Side side)
Returns the distance to the inclided trapezoidal side Positive values imply that the test point is ou...
Amg::Vector3D projectDirOntoPlane(const Amg::Vector3D &direction, const Amg::Vector3D &planeNorm)
Project the direction vector onto the plane and renormalize to unity.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
double halfY(const Acts::VolumeBounds &bounds)
Returns the half-Y length for the parsed volume bounds (Trapezoid/ Cuboid).
Helper struct to describe a sub trapezoid that is not aligned with the center of the coordinate syste...

◆ logger()

const Acts::Logger & MuonGMR4::BoundsExpander::logger ( ) const
inherited

Returns the ACTS logegr object.

Definition at line 36 of file BoundsExpander.cxx.

36{ return *m_logger; }

◆ makeBounds() [1/2]

std::shared_ptr< Acts::VolumeBounds > MuonGMR4::TrapezoidBoundsExpander::makeBounds ( Acts::VolumeBoundFactory & factory)
finaloverridevirtual

shift first the constituents by the centering transform

Hack to cope with the RPCs which may be rotated by 180 degrees around the x or z-axis in cases, they're upside down.

Find the first envelope which is a trapezoid (Needed to keep the opening angle low in EIL4/5

Implements MuonGMR4::BoundsExpander.

Definition at line 87 of file TrapezoidBoundsExpander.cxx.

87 {
88 if (m_finalBounds) {
89 return m_finalBounds;
90 }
91 const auto boxMin = minima();
92 const auto boxMax = maxima();
93
94 const double halfZ = 0.5*(boxMax[Amg::z] - boxMin[Amg::z]);
95 const double halfY = 0.5*(boxMax[Amg::y] - boxMin[Amg::y]);
96
97 if (std::ranges::all_of(m_constituents, [](const TrapezoidPatch& patch) {
98 return patch.bounds->type() == Acts::VolumeBounds::BoundsType::eCuboid;
99 })) {
100 ACTS_VERBOSE(__func__<<"() "<<__LINE__<<" Only cuboids have been passed. Construct a cuboid");
101 m_finalBounds = factory.makeBounds<Acts::CuboidVolumeBounds>(0.5*(boxMax[Amg::x] - boxMin[Amg::x]+
102 std::max(m_margin[0], m_margin[1])),
103 halfY + 0.5*m_margin[2],
104 halfZ + 0.5* m_margin[3]);
105 m_constituents.clear();
106 return m_finalBounds;
107 }
109 for (TrapezoidPatch &trapezoid : m_constituents) {
110 trapezoid.toCenter = toVertexCenter() * trapezoid.toCenter;
111 ACTS_VERBOSE(__func__<<"() "<<__LINE__<<" - Trapezoid after shift: "<<trapezoid);
114 GeoTrf::CoordEulerAngles rotAngles = GeoTrf::getCoordRotationAngles(trapezoid.toCenter);
115 if (std::abs(rotAngles.gamma - 180._degree)< Acts::s_epsilon) {
116 trapezoid.toCenter = trapezoid.toCenter *Amg::getRotateZ3D(180._degree);
117 ACTS_VERBOSE(__func__<<"() "<<__LINE__<<" - Flip trapezoid around Z: "
118 <<Amg::toString(trapezoid.toCenter));
119 }
120 if (std::abs(rotAngles.alpha - 180._degree)< Acts::s_epsilon) {
121 trapezoid.toCenter = trapezoid.toCenter *Amg::getRotateX3D(180._degree);
122 ACTS_VERBOSE(__func__<<"() "<<__LINE__<<" - Flip trapezoid around X: "
123 <<Amg::toString(trapezoid.toCenter));
124 }
125 }
126
127 std::array<Amg::Vector3D, 4> expandedCorners{Acts::filledArray<Amg::Vector3D, 4>(Amg::Vector3D::Zero())};
128 for (const Side side : {Side::left, Side::right}) {
129 std::ranges::sort(m_constituents, [side](const auto& a, const auto& b){
130 const Amg::Vector3D botA = makeVertex(a, side, Level::bottom);
131 const Amg::Vector3D botB = makeVertex(b, side, Level::bottom);
132 if (std::abs(botA.y() - botB.y()) > Acts::s_onSurfaceTolerance) {
133 return botA.y() < botB.y();
134 }
135 return (botA.x() - botB.x()) * Acts::toUnderlying(side) > 0.;
136 });
137 std::size_t highPatch{0ul};
140 std::optional<std::size_t> lowPatch{};
141 for (std::size_t patch = 0ul; patch < m_constituents.size(); ++ patch) {
142 if (!lowPatch.has_value() && m_constituents.at(patch).bounds->type() == Acts::VolumeBounds::eTrapezoid) {
143 lowPatch = patch;
144 }
145 const Amg::Vector3D botA = makeVertex(m_constituents.at(highPatch),
146 side, Level::bottom);
147 const Amg::Vector3D botB = makeVertex(m_constituents.at(patch),
148 side, Level::bottom);
149 ACTS_VERBOSE(__func__<<"() "<<__LINE__<<" - Test: "<<patch<<" position: "
150 <<Amg::toString(botB)<<" --- best: "<<highPatch<<" position: "
151 <<Amg::toString(botA)<<", distance: "<<(botB.x() - botA.x())<<", side: "<<side);
152 if ((botB.x() - botA.x()) * Acts::toUnderlying(side) > 0.) {
153 highPatch = patch;
154 }
155 }
156 ACTS_DEBUG(__func__<<"() "<<__LINE__<<" - Expand corners at "<<side
157 <<" side. Resorted trapezoids:\n"<<toString(m_constituents)
158 <<"\n ---- Selected upper trapezoid:\n"
159 <<m_constituents.at(highPatch));
160
161 findTrapezoidEdge(expandedCorners[toIndex(side, Level::bottom)],
162 expandedCorners[toIndex(side, Level::top)], side,
163 lowPatch.value_or(0), highPatch);
164 }
165 const double halfXhighY = std::max(std::abs(expandedCorners[toIndex(Side::left, Level::top)].x()),
166 std::abs(expandedCorners[toIndex(Side::right, Level::top)].x()));
167 const double halfXlowY = std::max(std::abs(expandedCorners[toIndex(Side::left, Level::bottom)].x()),
168 std::abs(expandedCorners[toIndex(Side::right, Level::bottom)].x()));
169 if (std::abs(halfXhighY - halfXlowY) > Acts::s_onSurfaceTolerance) {
170 m_finalBounds = factory.makeBounds<Acts::TrapezoidVolumeBounds>(halfXlowY + 0.5*m_margin[0],
171 halfXhighY + 0.5*m_margin[1],
172 halfY + 0.5*m_margin[2],
173 halfZ + 0.5* m_margin[3]);
174 } else {
175 m_finalBounds = factory.makeBounds<Acts::CuboidVolumeBounds>(halfXlowY + 0.5*std::max(m_margin[0], m_margin[1]),
176 halfY + 0.5*m_margin[2],
177 halfZ + 0.5* m_margin[3]);
178 }
179 ACTS_DEBUG(__func__<<"() "<<__LINE__<<" - Created new bounds "<<(*m_finalBounds));
180 m_constituents.clear();
181 return m_finalBounds;
182}
Acts::Transform3 toVertexCenter() const
Returns the transform from the ATLAS frame to the center of all seen vertices.
void findTrapezoidEdge(Amg::Vector3D &botCorner, Amg::Vector3D &topCorner, const Side side, const std::size_t lowPatch, const std::size_t highPatch) const
Moves the position of the bottom and top corner of a trapezoid side such that all vertices are enclos...
std::shared_ptr< Acts::VolumeBounds > m_finalBounds
Side
Enum to select the left / right corners of a trapezoid.
static std::uint8_t toIndex(const Side side, const Level lvl)
Construct an index from [0;3] from the side and level.
Amg::Isometry3D getRotateX3D(double angle)
Rotate the coordinate system by an angle around the x-axis.
Amg::Isometry3D getRotateZ3D(double angle)
Rotate the coordinate system by an angle around the z-axis.
std::string toString(const MuonGMR4::MuonReadoutElement *re)
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).
unsigned long ul

◆ makeBounds() [2/2]

std::shared_ptr< Acts::VolumeBounds > MuonGMR4::BoundsExpander::makeBounds ( const MuonGMR4::MuonReadoutElement & readoutElement,
Acts::VolumeBoundFactory & boundFactory )
static

Use the makeBounds overload for the readout element.

Definition at line 59 of file BoundsExpander.cxx.

47 {
48 switch(readoutElement.detectorType()) {
50 const auto& techEle = static_cast<const MdtReadoutElement&>(readoutElement);
51 const auto& pars = techEle.getParameters();
52 if (std::abs(pars.shortHalfX - pars.longHalfX) < Acts::s_epsilon) {
53 return boundFactory.makeBounds<Acts::CuboidVolumeBounds>(pars.shortHalfX, pars.halfY, pars.halfHeight);
54 }
55 return boundFactory.makeBounds<Acts::TrapezoidVolumeBounds>(pars.shortHalfX, pars.longHalfX,
56 pars.halfY, pars.halfHeight);
58 const auto& techEle = static_cast<const RpcReadoutElement&>(readoutElement);
59 const auto& pars = techEle.getParameters();
60 return boundFactory.makeBounds<Acts::CuboidVolumeBounds>(pars.halfWidth, pars.halfLength, pars.halfThickness);
62 const auto& techEle = static_cast<const TgcReadoutElement&>(readoutElement);
63 const auto& pars = techEle.getParameters();
64 return boundFactory.makeBounds<Acts::TrapezoidVolumeBounds>(pars.halfWidthShort, pars.halfWidthLong,
65 pars.halfHeight, pars.halfThickness );
67 const auto& techEle = static_cast<const sTgcReadoutElement&>(readoutElement);
68 const auto& pars = techEle.getParameters();
69 return boundFactory.makeBounds<Acts::TrapezoidVolumeBounds>(pars.sHalfChamberLength, pars.lHalfChamberLength,
70 pars.halfChamberHeight, pars.halfChamberTck );
72 const auto& techEle = static_cast<const MmReadoutElement&>(readoutElement);
73 const auto& pars = techEle.getParameters();
74 return boundFactory.makeBounds<Acts::TrapezoidVolumeBounds>(pars.halfShortWidth, pars.halfLongWidth,
75 pars.halfHeight, pars.halfThickness );
76 } default:
77 THROW_EXCEPTION("Unsupported detector type "<<readoutElement.detectorType());
78 }
79 return nullptr;
80 }
virtual DetectorType detectorType() const =0
Returns the detector element type.
@ Mm
Maybe not needed in the migration.
@ Tgc
Resitive Plate Chambers.
@ sTgc
Micromegas (NSW).
@ Rpc
Monitored Drift Tubes.
@ Mdt
MuonSpectrometer.
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10

◆ makeEnvelope()

std::unique_ptr< Acts::TrackingVolume > MuonGMR4::BoundsExpander::makeEnvelope ( Acts::VolumeBoundFactory & factory,
std::string_view volName )
inherited

Creates an empty tracking volume.

The volume will be positioned at the vertex center

Parameters
factoryThe bound factory to create the bounds
volNameThe name of the tracking volume

Definition at line 190 of file BoundsExpander.cxx.

191 {
192 auto volume = std::make_unique<Acts::TrackingVolume>(toVertexCenter().inverse(),
193 makeBounds(factory), std::string{volName});
194 ACTS_DEBUG(__func__<<"() "<<__LINE__<<" - Created new volume envelope "
195 <<volName<<" located at @"<<Amg::toString(toVertexCenter().inverse())
196 <<" with bounds: "<<volume->volumeBounds());
197 return volume;
198 }
static std::shared_ptr< Acts::VolumeBounds > makeBounds(const MuonGMR4::MuonReadoutElement &readoutElement, Acts::VolumeBoundFactory &boundFactory)
Crate volume bounds that enclose the readout element from the central localToGlobalTransform.

◆ makeVertex()

Amg::Vector3D MuonGMR4::TrapezoidBoundsExpander::makeVertex ( const TrapezoidPatch & trapezoid,
const Side side,
const Level lvl )
static

Returns the vertex point from a trapezoid.

Parameters
trapezoidReference to the trapezoid of interest
sideIs the vertex on the left [-x] or positive side of the trapezoid
lvlIs the vertex on the upper or the bottom edge of the trapezoid

Definition at line 42 of file TrapezoidBoundsExpander.cxx.

43 {
44 const double halfX = lvl == Level::top ? MuonGMR4::halfXhighY(*trapezoid.bounds)
45 : MuonGMR4::halfXlowY(*trapezoid.bounds);
46 return trapezoid.toCenter * Amg::Vector3D{Acts::copySign(halfX, side),
47 Acts::copySign(MuonGMR4::halfY(*trapezoid.bounds), lvl), 0.};
48}

◆ maxima()

std::span< const double > MuonGMR4::BoundsExpander::maxima ( ) const
inherited

Returns the triplet of the maximum coordinates from the ensemble of all seen vertices.

Definition at line 111 of file BoundsExpander.cxx.

111 {
112 return m_locMax;
113 }
std::array< double, 3 > m_locMax
Maximum value seen by the recenter method.

◆ minima()

std::span< const double > MuonGMR4::BoundsExpander::minima ( ) const
inherited

Returns the triplet of the minimum coordinates from the ensemble of all seen vertices.

Definition at line 108 of file BoundsExpander.cxx.

108 {
109 return m_locMin;
110 }
std::array< double, 3 > m_locMin
Minimum value seen by the recenter method.

◆ reCenter()

void MuonGMR4::BoundsExpander::reCenter ( std::span< const Amg::Vector3D > vertices)
inherited

Update the center point from a list of global vertices.

Parameters
verticesList of vertices expressed in th ATLAS frame

Definition at line 91 of file BoundsExpander.cxx.

91 {
92 ACTS_VERBOSE(__func__<<"() "<<__LINE__<<" - User defined center system: "
94 for (const Amg::Vector3D& vert : vertices) {
95 const Amg::Vector3D locVert = m_toVolume* vert;
96 for (std::size_t k = 0; k < m_locMax.size(); ++k) {
97 m_locMax[k] = std::max(m_locMax[k], locVert[k]);
98 m_locMin[k] = std::min(m_locMin[k], locVert[k]);
99 }
100 }
101 Amg::Vector3D shiftVec{Amg::Vector3D::Zero()};
102 for (std::size_t k =0 ; k < m_locMax.size(); ++k) {
103 shiftVec[k] = 0.5*(m_locMax[k] + m_locMin[k]);
104 }
106 ACTS_VERBOSE(__func__<<"() "<<__LINE__<<" - New transform: "<<Amg::toString(m_shiftTrf));
107 }
Amg::Isometry3D getTranslate3D(const double X, const double Y, const double Z)
: Returns a shift transformation along an arbitrary axis

◆ setMargin() [1/2]

void MuonGMR4::TrapezoidBoundsExpander::setMargin ( const double margin)

Apply an extra margin to all four bound dimensions.

Parameters
marginThe extra margin to apply to the bounds

Definition at line 71 of file TrapezoidBoundsExpander.cxx.

71 {
72 ACTS_DEBUG(__func__<<"() "<<__LINE__<<" - Assign "<<margin<<" to all vertices");
73 m_margin.fill(margin);
74}

◆ setMargin() [2/2]

void MuonGMR4::TrapezoidBoundsExpander::setMargin ( const double marginXlow,
const double marginXhigh,
const double marginY,
const double marginZ )

Apply an extra margin to each individual bound side.

Parameters
marginXLowThe extra margin to apply to the halfX at low Y
marginXhighThe extra margin to aplpy to the halfX at high Y
marginYThe extra margin to apply to the halfY
marginZThe extgra margin to apply to the halfZ

Definition at line 76 of file TrapezoidBoundsExpander.cxx.

77 {
78 m_margin[0] = marginXlow;
79 m_margin[1] = marginXhigh;
80 m_margin[2] = marginY;
81 m_margin[3] = marginZ;
82 ACTS_DEBUG(__func__<<"() "<<__LINE__<<" - Assign "<<marginXlow<<"/"<<marginXhigh
83 <<" to x-edges , "<<marginY<<" to the y-edge, "<<marginZ<<" to the z-edge as extra margin");
84}

◆ toIndex()

std::uint8_t MuonGMR4::TrapezoidBoundsExpander::toIndex ( const Side side,
const Level lvl )
static

Construct an index from [0;3] from the side and level.

Definition at line 58 of file TrapezoidBoundsExpander.cxx.

58 {
59 return (side == Side::left) + 2*(lvl == Level::top);
60}

◆ toVertexCenter()

Acts::Transform3 MuonGMR4::BoundsExpander::toVertexCenter ( ) const
inherited

Returns the transform from the ATLAS frame to the center of all seen vertices.

Definition at line 88 of file BoundsExpander.cxx.

88 {
89 return m_shiftTrf.inverse() * m_toVolume;
90 }

◆ operator<< [1/2]

std::ostream & operator<< ( std::ostream & ostr,
const Level lvl )
friend

Pipe the Level to an ostream.

Definition at line 48 of file TrapezoidBoundsExpander.h.

48 {
49 switch (lvl) {
50 case Level::bottom: return ostr<<"bottom";
51 case Level::top: return ostr<<"top";
52 }
53 return ostr;
54 }

◆ operator<< [2/2]

std::ostream & operator<< ( std::ostream & ostr,
const Side side )
friend

Pipe the Side to an ostream.

Definition at line 40 of file TrapezoidBoundsExpander.h.

40 {
41 switch (side) {
42 case Side::left: return ostr<<"left";
43 case Side::right: return ostr<<"right";
44 }
45 return ostr;
46 }

Member Data Documentation

◆ m_constituents

std::vector<TrapezoidPatch> MuonGMR4::TrapezoidBoundsExpander::m_constituents {}
private

Definition at line 115 of file TrapezoidBoundsExpander.h.

115{};

◆ m_finalBounds

std::shared_ptr<Acts::VolumeBounds> MuonGMR4::TrapezoidBoundsExpander::m_finalBounds {}
private

Definition at line 116 of file TrapezoidBoundsExpander.h.

116{};

◆ m_locMax

std::array<double, 3> MuonGMR4::BoundsExpander::m_locMax {Acts::filledArray<double, 3>(-2.*Acts::UnitConstants::km)}
privateinherited

Maximum value seen by the recenter method.

Definition at line 132 of file BoundsExpander.h.

132{Acts::filledArray<double, 3>(-2.*Acts::UnitConstants::km)};

◆ m_locMin

std::array<double, 3> MuonGMR4::BoundsExpander::m_locMin {Acts::filledArray<double, 3>(2.*Acts::UnitConstants::km)}
privateinherited

Minimum value seen by the recenter method.

Definition at line 134 of file BoundsExpander.h.

134{Acts::filledArray<double, 3>(2.*Acts::UnitConstants::km)};

◆ m_logger

std::unique_ptr<const Acts::Logger> MuonGMR4::BoundsExpander::m_logger
privateinherited
Initial value:
{Acts::getDefaultLogger("BoundsExpander",
Acts::Logging::Level::INFO)}

Definition at line 125 of file BoundsExpander.h.

125 {Acts::getDefaultLogger("BoundsExpander",
126 Acts::Logging::Level::INFO)};

◆ m_margin

std::array<double, 4> MuonGMR4::TrapezoidBoundsExpander::m_margin {Acts::filledArray<double, 4>(0.)}
private

Definition at line 117 of file TrapezoidBoundsExpander.h.

117{Acts::filledArray<double, 4>(0.)};

◆ m_shiftTrf

Acts::Transform3 MuonGMR4::BoundsExpander::m_shiftTrf {Acts::Transform3::Identity()}
privateinherited

Extra shift to center all the vertices.

Definition at line 130 of file BoundsExpander.h.

130{Acts::Transform3::Identity()};

◆ m_toVolume

Acts::Transform3 MuonGMR4::BoundsExpander::m_toVolume {Acts::Transform3::Identity()}
privateinherited

External method to go from ATLAS to the reference frame.

Definition at line 128 of file BoundsExpander.h.

128{Acts::Transform3::Identity()};

The documentation for this class was generated from the following files: