ATLAS Offline Software
Loading...
Searching...
No Matches
MuonGMR4::BoundsExpander Class Referenceabstract

#include <BoundsExpander.h>

Inheritance diagram for MuonGMR4::BoundsExpander:
Collaboration diagram for MuonGMR4::BoundsExpander:

Public Types

using VolumeAligner_t = std::function<Acts::Transform3(const Acts::GeometryContext& tgContext)>
 Abrivation of the transform getter.

Public Member Functions

 BoundsExpander ()=default
 Default constructor.
 BoundsExpander (const Acts::Transform3 &toVolume, std::unique_ptr< const Acts::Logger > loggerObj=nullptr)
 Constructor with a transform from the global -> local frame of the volume.
void expand (const Acts::GeometryContext &tgContext, const MuonGMR4::Chamber &chamber)
 Expand the bounds from a chamber.
void expand (const Acts::GeometryContext &tgContext, const MuonGMR4::SpectrometerSector &sector)
 Expand the bounds from a sector.
void expand (const Acts::GeometryContext &tgContext, const MuonGMR4::MuonReadoutElement &readoutElement, Acts::VolumeBoundFactory &boundFactory)
 Expand the bounds from a readout element.
virtual void expand (const Acts::GeometryContext &tgContext, const Acts::Volume &volume)=0
 Expand the bound definition from a generic volume.
virtual std::shared_ptr< Acts::VolumeBounds > makeBounds (Acts::VolumeBoundFactory &boundFactory)=0
 Make the final bounds after all volumes are passed via the expand method.
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 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.
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.

Private Attributes

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.

Detailed Description

Definition at line 38 of file BoundsExpander.h.

Member Typedef Documentation

◆ VolumeAligner_t

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

Abrivation of the transform getter.

Definition at line 62 of file BoundsExpander.h.

Constructor & Destructor Documentation

◆ BoundsExpander() [1/2]

MuonGMR4::BoundsExpander::BoundsExpander ( )
explicitdefault

Default constructor.

◆ BoundsExpander() [2/2]

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

Constructor with a transform from the global -> local frame of the volume.

Parameters
toVolumeThe Transform to the volume
loggerObjThe logger instance

Definition at line 25 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

Member Function Documentation

◆ boxMidPoint()

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

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 )
static

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 )
static

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.

◆ expand() [1/4]

virtual void MuonGMR4::BoundsExpander::expand ( const Acts::GeometryContext & tgContext,
const Acts::Volume & volume )
pure virtual

Expand the bound definition from a generic volume.

Parameters
tgContextThe geometry context to align the volume in space
volumeThe volume of interest

Implemented in MuonGMR4::CylinderBoundsExpander, and MuonGMR4::TrapezoidBoundsExpander.

◆ expand() [2/4]

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

Expand the bounds from a chamber.

Parameters
tgContextThe goemetry contex to position the chamber in space
chamberReference to the chamber from which the vertices are extracted

Definition at line 32 of file BoundsExpander.cxx.

33 {
34 expand(tgContext, *chamber.boundingVolume());
35 }
void expand(const Acts::GeometryContext &tgContext, const MuonGMR4::Chamber &chamber)
Expand the bounds from a chamber.

◆ expand() [3/4]

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

Expand the bounds from a readout element.

Parameters
tgContextThe geometry context to align the readout element in space
readoutElementThe readout element of interest
boundFactoryTo create the temporary volume bounds enclosing the readout element

Definition at line 81 of file BoundsExpander.cxx.

83 {
84 expand(tgContext, Acts::Volume{readoutElement.localToGlobalTransform(tgContext),
85 makeBounds(readoutElement, boundFactory)});
86 }
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.
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...

◆ expand() [4/4]

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

Expand the bounds from a sector.

Parameters
tgContextThe goemetry contex to position the sector in space
sectorReference to the sector from which the vertices are extracted

Definition at line 38 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.

◆ logger()

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

Returns the ACTS logegr object.

Definition at line 36 of file BoundsExpander.cxx.

36{ return *m_logger; }

◆ makeBounds() [1/2]

virtual std::shared_ptr< Acts::VolumeBounds > MuonGMR4::BoundsExpander::makeBounds ( Acts::VolumeBoundFactory & boundFactory)
pure virtual

Make the final bounds after all volumes are passed via the expand method.

Parameters
boundFactoryThe factory object used to create the final bounds

Implemented in MuonGMR4::CylinderBoundsExpander, and MuonGMR4::TrapezoidBoundsExpander.

◆ makeBounds() [2/2]

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

Crate volume bounds that enclose the readout element from the central localToGlobalTransform.

Parameters
readoutElementThe readout element of interest
boundFactoryThe factory used to create the bounds

Definition at line 46 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 )

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 }
Acts::Transform3 toVertexCenter() const
Returns the transform from the ATLAS frame to the center of all seen vertices.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.

◆ maxima()

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

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

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)

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

◆ toVertexCenter()

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

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 }

Member Data Documentation

◆ m_locMax

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

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)}
private

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
private
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_shiftTrf

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

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()}
private

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: