16#include "Acts/Geometry/TrackingVolume.hpp"
17#include "Acts/Geometry/CuboidVolumeBounds.hpp"
18#include "Acts/Geometry/TrapezoidVolumeBounds.hpp"
19#include "Acts/Surfaces/RectangleBounds.hpp"
20#include "Acts/Surfaces/TrapezoidBounds.hpp"
26 std::unique_ptr<const Acts::Logger> loggerObj):
34 expand(tgContext, *chamber.boundingVolume());
45 std::shared_ptr<Acts::VolumeBounds>
47 Acts::VolumeBoundFactory& boundFactory) {
52 if (std::abs(pars.shortHalfX - pars.longHalfX) < Acts::s_epsilon) {
53 return boundFactory.makeBounds<Acts::CuboidVolumeBounds>(pars.shortHalfX, pars.halfY, pars.halfHeight);
55 return boundFactory.makeBounds<Acts::TrapezoidVolumeBounds>(pars.shortHalfX, pars.longHalfX,
56 pars.halfY, pars.halfHeight);
60 return boundFactory.makeBounds<Acts::CuboidVolumeBounds>(pars.halfWidth, pars.halfLength, pars.halfThickness);
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 );
74 return boundFactory.makeBounds<Acts::TrapezoidVolumeBounds>(pars.halfShortWidth, pars.halfLongWidth,
75 pars.halfHeight, pars.halfThickness );
83 Acts::VolumeBoundFactory& boundFactory) {
92 ACTS_VERBOSE(__func__<<
"() "<<__LINE__<<
" - User defined center system: "
96 for (std::size_t k = 0; k <
m_locMax.size(); ++k) {
102 for (std::size_t k =0 ; k <
m_locMax.size(); ++k) {
115 const Acts::Volume& volume,
116 const std::size_t nSegments) {
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()));
126 return (
a - b).mag2() < Acts::s_onSurfaceTolerance;
128 edges.erase(begin, end);
132 const Acts::Surface& surface,
133 const std::size_t nSegments) {
134 constexpr std::array signs{-1., 1.};
135 std::vector<Amg::Vector3D> vertices{};
137 const Acts::Transform3& transform = surface.localToGlobalTransform(tgContext);
141 switch (surface.bounds().type()) {
142 using enum Acts::SurfaceBounds::BoundsType;
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 *
152 sign*bounds.get(eMaxY), 0.});
153 vertices.push_back(transform *
155 -bounds.get(eMaxY) + stepY * seg, 0.});
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);
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);
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);
184 vertices = surface.polyhedronRepresentation(tgContext, nSegments).vertices;
191 std::string_view volName) {
192 auto volume = std::make_unique<Acts::TrackingVolume>(
toVertexCenter().inverse(),
194 ACTS_DEBUG(__func__<<
"() "<<__LINE__<<
" - Created new volume envelope "
196 <<
" with bounds: "<<volume->volumeBounds());
virtual DetectorType detectorType() const =0
Returns the detector element type.
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.
std::span< const double > maxima() const
Returns the triplet of the maximum coordinates from the ensemble of all seen vertices.
std::array< double, 3 > m_locMin
Minimum value seen by the recenter method.
Acts::Transform3 m_shiftTrf
Extra shift to center all the vertices.
std::span< const double > minima() const
Returns the triplet of the minimum coordinates from the ensemble of all seen vertices.
Acts::Transform3 toVertexCenter() const
Returns the transform from the ATLAS frame to the center of all seen vertices.
BoundsExpander()=default
Default constructor.
Acts::Transform3 m_toVolume
External method to go from ATLAS to the reference frame.
std::array< double, 3 > m_locMax
Maximum value seen by the recenter method.
void expand(const Acts::GeometryContext &tgContext, const MuonGMR4::Chamber &chamber)
Expand the bounds from a chamber.
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.
std::unique_ptr< const Acts::Logger > m_logger
const Acts::Transform3 & boxMidPoint() const
Returns the transform from the nominal volume center to the middle point to all seen vertices.
const Acts::Logger & logger() const
Returns the ACTS logegr object.
void reCenter(std::span< const Amg::Vector3D > vertices)
Update the center point from a list of global vertices.
std::unique_ptr< Acts::TrackingVolume > makeEnvelope(Acts::VolumeBoundFactory &factory, std::string_view volName)
Creates an empty tracking volume.
Chamber represent the volume enclosing a muon station.
Readout element to describe the Monitored Drift Tube (Mdt) chambers Mdt chambers usually comrpise out...
const parameterBook & getParameters() const
Get a const reference to the parameter book.
const parameterBook & getParameters() const
MuonReadoutElement is an abstract class representing the geometry of a muon detector.
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...
const parameterBook & getParameters() const
A spectrometer sector forms the envelope of all chambers that are placed in the same MS sector & laye...
std::shared_ptr< Acts::Volume > boundingVolume() const
Returns the Acts::Volume representation of the sector.
const parameterBook & getParameters() const
@ Mm
Maybe not needed in the migration.
@ Tgc
Resitive Plate Chambers.
@ Rpc
Monitored Drift Tubes.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Amg::Isometry3D getTranslate3D(const double X, const double Y, const double Z)
: Returns a shift transformation along an arbitrary axis
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
The ReadoutGeomCnvAlg converts the Run4 Readout geometry build from the GeoModelXML into the legacy M...
#define THROW_EXCEPTION(MESSAGE)