10#include <GaudiKernel/PhysicalConstants.h>
12#include "Acts/Surfaces/PlaneSurface.hpp"
13#include "Acts/Definitions/Units.hpp"
14#include "Acts/Utilities/UnitVectors.hpp"
20using namespace Acts::UnitLiterals;
23 constexpr double straightQoverP = 1. / 20._TeV;
24 constexpr double inDeg(
const double rad) {
return rad / 1._degree; }
29 constexpr double eps = std::numeric_limits<float>::epsilon();
30 return v.y() / ( std::abs(v.z()) > eps ? v.z() : eps);
33 constexpr double eps = std::numeric_limits<float>::epsilon();
34 return v.x() / ( std::abs(v.z()) > eps ? v.z() : eps);
36 namespace SegmentFit {
37 constexpr std::size_t
N = Acts::toUnderlying(ParamDefs::nPars);
39 inline std::optional<Acts::BoundMatrix>
41 std::optional<Covariance>&& localCov,
46 const SeedingAux::Line_t line{locSegPars};
48 Acts::Matrix<3,2> basisTrf{};
49 basisTrf.block<3,1>(0,1) = line.gradient(SeedingAux::Line_t::ParIndex::theta);
50 basisTrf.block<3,1>(0,0) = line.gradient(SeedingAux::Line_t::ParIndex::phi);
52 BoundMatrix jacobian{BoundMatrix::Identity()};
53 jacobian.block<2,2>(Acts::eBoundPhi, Acts::eBoundPhi) = basisTrf.transpose() *
54 localToGlobal.linear() *
56 BoundMatrix cov{BoundMatrix::Identity()};
57 cov.block<
N,
N>(0,0) = std::move(*localCov);
58 BoundMatrix translator{BoundMatrix::Zero()};
59 translator( Acts::toUnderlying(ParamDefs::x0), Acts::eBoundLoc0) =
60 translator( Acts::toUnderlying(ParamDefs::y0), Acts::eBoundLoc1) =
61 translator( Acts::toUnderlying(ParamDefs::theta), Acts::eBoundTheta) =
62 translator( Acts::toUnderlying(ParamDefs::phi), Acts::eBoundPhi) =
63 translator( Acts::toUnderlying(ParamDefs::t0), Acts::eBoundTime) =
64 translator( Acts::toUnderlying(ParamDefs::nPars), Acts::eBoundQOverP) = 1.;
65 translator = jacobian * translator;
66 return translator.transpose() * cov * translator;
71 return std::make_pair(
Amg::Vector3D{pars[Acts::toUnderlying(x0)],
72 pars[Acts::toUnderlying(y0)],0.},
73 Acts::makeDirectionFromPhiTheta(pars[Acts::toUnderlying(
phi)],
74 pars[Acts::toUnderlying(
theta)]));
79 for (std::size_t p =0 ; p <
N; ++p) {
80 segPars[p] = acc(seg)[p];
86 if (!acc.isAvailable(seg)) {
90 const auto& covVec{acc(seg)};
91 for (std::size_t i = 0 ; i < covVec.size(); ++i) {
92 const auto [p, p1] = Acts::symMatIndices<N>(i);
93 cov(p,p1) = cov(p1,p) = covVec[i];
109 pars[Acts::toUnderlying(ParamDefs::x0)] = locPos.x();
110 pars[Acts::toUnderlying(ParamDefs::y0)] = locPos.y();
111 pars[Acts::toUnderlying(ParamDefs::theta)] = locDir.theta();
112 pars[Acts::toUnderlying(ParamDefs::phi)] = locDir.phi();
113 pars[Acts::toUnderlying(ParamDefs::t0)] = segment.
segementT0();
118 std::stringstream sstr{};
119 sstr<<std::format(
"x_{{0}}={:.2f}", pars[Acts::toUnderlying(ParamDefs::x0)])<<
", ";
120 sstr<<std::format(
"y_{{0}}={:.2f}", pars[Acts::toUnderlying(ParamDefs::y0)])<<
", ";
121 sstr<<std::format(
"#theta={:.2f}^{{#circ}}",
inDeg(pars[Acts::toUnderlying(ParamDefs::theta)]))<<
", ";
122 sstr<<std::format(
"#phi={:.2f}^{{#circ}}",
inDeg(pars[Acts::toUnderlying(ParamDefs::phi)]))<<
", ";
123 sstr<<std::format(
"t_{{0}}={:.1f}", pars[Acts::toUnderlying(ParamDefs::t0)]);
127 std::stringstream sstr{};
128 sstr<< std::format(
"{}={:.2f}, ",
toString(ParamDefs::x0), pars[Acts::toUnderlying(ParamDefs::x0)]);
129 sstr<< std::format(
"{}={:.2f}, ",
toString(ParamDefs::y0), pars[Acts::toUnderlying(ParamDefs::y0)]);
130 sstr<< std::format(
"{}={:.2f}, ",
toString(ParamDefs::theta),
inDeg(pars[Acts::toUnderlying(ParamDefs::theta)]));
131 sstr<< std::format(
"{}={:.2f}, ",
toString(ParamDefs::phi),
inDeg(pars[Acts::toUnderlying(ParamDefs::phi)]));
132 sstr<< std::format(
"{}={:.2f}",
toString(ParamDefs::t0), pars[Acts::toUnderlying(ParamDefs::t0)]);
136 return SeedingAux::parName(
a);
142 const Acts::ParticleHypothesis hypot) {
144 detMgr, segment, hypot);
149 const Acts::ParticleHypothesis hypot) {
158 Acts::BoundVector boundPars{};
159 boundPars[Acts::eBoundLoc0] = locSegPars[Acts::toUnderlying(ParamDefs::x0)];
160 boundPars[Acts::eBoundLoc1] = locSegPars[Acts::toUnderlying(ParamDefs::y0)];
161 boundPars[Acts::eBoundPhi] = globDir.phi();
162 boundPars[Acts::eBoundTheta] = globDir.theta();
163 boundPars[Acts::eBoundQOverP] = straightQoverP;
167 return Acts::BoundTrackParameters{msSector->surface().getSharedPtr(),
168 std::move(boundPars),
170 msSector->localToGlobalTransform(gctx)), hypot};
174 const Acts::ParticleHypothesis hypot) {
177 Acts::BoundVector boundPars{};
178 boundPars[Acts::eBoundLoc0] = locPos.x();
179 boundPars[Acts::eBoundLoc1] = locPos.y();
180 boundPars[Acts::eBoundPhi] = segment.
direction().phi();
181 boundPars[Acts::eBoundTheta] = segment.
direction().theta();
182 boundPars[Acts::eBoundQOverP] = straightQoverP;
186 return Acts::BoundTrackParameters{segment.
msSector()->
surface().getSharedPtr(),
187 std::move(boundPars),
Scalar phi() const
phi method
Scalar theta() const
theta method
constexpr float inDeg(const float rad)
const SpectrometerSector * getSectorEnvelope(const Identifier &channelId) const
Retrieves the spectrometer envelope enclosing the channel's readout element.
const Amg::Transform3D & localToGlobalTransform(const ActsTrk::GeometryContext &gctx) const
Returns the local -> global tarnsformation from the sector.
Amg::Transform3D globalToLocalTransform(const ActsTrk::GeometryContext &gctx) const
Returns the global -> local transformation from the ATLAS global.
const Acts::PlaneSurface & surface() const
Returns the associated surface.
Placeholder for what will later be the muon segment EDM representation.
double segementT0() const
Returns the fitted segment time, if there's any.
const SegmentFit::Covariance & covariance() const
Returns the uncertainties of the defining parameters.
const MuonGMR4::SpectrometerSector * msSector() const
Returns the associated MS sector.
const Amg::Vector3D & position() const
Returns the global segment position.
const Amg::Vector3D & direction() const
Returns the global segment direction.
Amg::Vector3D direction() const
Returns the direction as Amg::Vector.
::Muon::MuonStationIndex::ChIndex chamberIndex() const
Returns the chamber index.
Amg::Vector3D position() const
Returns the position as Amg::Vector.
int etaIndex() const
Returns the eta index, which corresponds to stationEta in the offline identifiers (and the ).
constexpr auto timeToActs(T athenaT)
Converts a time unit from Athena to Acts units.
This class is not to needed in AthSimulation.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Acts::Experimental::CompositeSpacePointLineFitter::CovMat_t Covariance
std::optional< Covariance > localSegmentCov(const xAOD::MuonSegment &seg)
Returns the localCovariance decoration from a xAOD::MuonSegment.
Acts::BoundTrackParameters boundSegmentPars(const ActsTrk::GeometryContext &gctx, const MuonGMR4::MuonDetectorManager &detMgr, const xAOD::MuonSegment &segment, const Acts::ParticleHypothesis hypot=Acts::ParticleHypothesis::muon())
Returns the segment parameters as boundTrackParameters.
SeedingAux::FitParIndex ParamDefs
Use the same parameter indices as used by the CompSpacePointAuxiliaries.
Parameters localSegmentPars(const xAOD::MuonSegment &seg)
Returns the localSegPars decoration from a xAODMuon::Segment.
std::pair< Amg::Vector3D, Amg::Vector3D > makeLine(const Parameters &pars)
Returns the parsed parameters into an Eigen line parametrization.
Acts::Experimental::CompositeSpacePointLineFitter::ParamVec_t Parameters
std::optional< Acts::BoundMatrix > translateCovariance(const Parameters &locSegPars, std::optional< Covariance > &&localCov, const Amg::Transform3D &localToGlobal)
std::string makeLabel(const Parameters &pars)
Dumps the parameters into a string in the form of TLatex.
std::string toString(const Parameters &pars)
Dumps the parameters into a string with labels in front of each number.
This header ties the generic definitions in this package.
double houghTanBeta(const Amg::Vector3D &v)
Returns the hough tanBeta [y] / [z].
double houghTanAlpha(const Amg::Vector3D &v)
: Returns the hough tanAlpha [x] / [z]
constexpr float inDeg(const float rad)
SG::AuxElement::Accessor< std::array< float, N > > PosAccessor
xAOD Accessor to the position
MuonSegment_v1 MuonSegment
Reference the current persistent version: