42 {
45 const ActsTrk::GeometryContext* gctx{nullptr};
47 const auto tgContext = gctx->
context();
48
50 const MuonR4::SpacePoint&
sp) {
54 Amg::Vector3D::Zero(),
55 Amg::Vector3D::Zero());
56
58 trf.linear() *
sp.sensorDirection(),
59 start.position(tgContext),
64
65 const auto* detEl =
static_cast<const ActsTrk::IDetectorElementBase*
>(
target.associatedDetectorElement());
69 <<
" geoId: "<<
target.geometryId()<<
", "<<( lambda.value_or(0.) > 0 ?
"forward" :
"backward"));
70
72 ? Acts::Direction::Forward()
73 : Acts::Direction::Backward(), 100._m);
74
75 };
79
82
83 const MuonGMR4::SpectrometerSector* sector =
m_detMgr->getSectorEnvelope(segment->chamberIndex(),
84 segment->sector(),
85 segment->etaIndex());
87
88 Acts::ObjVisualization3D visualHelper{};
92 Acts::ViewConfig{.color = {220, 0, 0}});
94 }
95
96 if (
msgLvl(MSG::VERBOSE)) {
97
98 std::stringstream sstr{};
101 <<segment->chiSquared() / segment->numberDoF()<<", nDoF: "<<segment->numberDoF()<<", "
102 <<segment->nPrecisionHits()<<", "<<segment->nPhiLayers()<<std::endl;
104 sstr<<" **** "<<(*meas)<<", chi2: "<<SeedingAux::chi2Term(locPos, locDir, *meas)
105 <<", sign: "<<(meas->isStraw() ?
106 (SeedingAux::strawSign(locPos,locDir, *meas) == 1 ? "R" : "L") : "-")
109 : Acts::GeometryIdentifier{})
110 <<std::endl;
111 }
113 }
114
116 if (!meas->spacePoint() ||
117 meas->fitState() != MuonR4::CalibratedSpacePoint::State::Valid) {
118 continue;
119 }
120 const auto sp = meas->spacePoint();
122
123 const auto& bounds = targetSurf.bounds();
125 const auto trf = targetSurf.transform(tgContext).inverse() *
126 sector->
surface().transform(tgContext);
127 if (targetSurf.type() == Acts::Surface::SurfaceType::Plane) {
128 lPos = (
trf * SeedingAux::extrapolateToPlane(locPos, locDir, *meas)).block<2,1>(0,0);
129 if (!bounds.inside(lPos, Acts::BoundaryTolerance::AbsoluteEuclidean(-2._mm))){
131 <<" is outside the trapezoid "<<bounds
133 continue;
134 }
135 } else if (targetSurf.type() == Acts::Surface::SurfaceType::Straw) {
136 const auto cIsect = lineIntersect<3>(meas->localPosition(),
137 meas->sensorDirection(),
138 locPos, locDir);
139 const auto cIsectPos = cIsect.position();
140 const auto cPos =
trf * cIsectPos;
141 lPos[0] = cPos.perp() * SeedingAux::strawSign(locPos, locDir, *meas);
142 lPos[1] = cPos.z();
143 const auto& lBounds = static_cast<const Acts::LineBounds&>(bounds);
144 if (std::abs(cPos.z()) > lBounds.get(Acts::LineBounds::eHalfLengthZ) - 2._cm ||
145 cPos.perp() >lBounds.get(Acts::LineBounds::eR) - 0.2_mm) {
149 continue;
150 }
151 }
153 if (!extpPars) {
156 <<
", expected: "<<
Amg::toString(lPos)<<
", "<<targetSurf.bounds());
157 retCode = StatusCode::FAILURE;
158 continue;
159 }
163 Acts::ViewConfig{.color = {0, 0, 220}}, 6._cm);
164 }
165
166 if (targetSurf.type() == Acts::Surface::SurfaceType::Plane) {
170 const Amg::Vector2D dPos = (*extpPars).localPosition() - lPos;
171 if (dPos.mag() > 0.1_mm) {
174 retCode = StatusCode::FAILURE;
175 }
176 } else if (targetSurf.type() == Acts::Surface::SurfaceType::Straw) {
177 const double dist = lPos[0];
178 const double extDist = (*extpPars).parameters()[Acts::eBoundLoc0];
179 const double extLocZ = (*extpPars).parameters()[Acts::eBoundLoc1];
180 const double cov = meas->covariance()[Acts::toUnderlying(AxisDefs::etaCov)];
182 <<" straight: "<<dist<<", extrapolated: "<<extDist
183 <<"--> "<<(extDist - dist ) / std::sqrt(cov)
184 <<", along the tube: "<<lPos[1]<<", extrapolated: "<<extLocZ);
185 if (std::abs(dist - extDist) / std::sqrt(cov) > 0.05 ||
186 std::abs(lPos[1] - extLocZ) > 0.1_mm) {
188 <<
", "<<
Amg::toString(lPos)<<
" vs. ("<<extDist<<
", "<<extLocZ<<
")"
189 <<", deviate R: "<<(std::abs(dist -extDist) / std::sqrt(cov))
190 <<", deviate Z: "<<std::abs(lPos[1] - extLocZ));
191 retCode = StatusCode::FAILURE;
192 }
193 }
194 }
196 visualHelper.write(std::format("ExtTpTest_{:}_{:}_{:}.obj",
197 ctx.eventID().event_number(), segment->index(),
199 }
200 }
201
202 return retCode;
203 }
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Acts::GeometryContext context() const
bool msgLvl(const MSG::Level lvl) const
std::string identString() const
Returns a string encoding the chamber index & the sector of the MS sector.
const Acts::PlaneSurface & surface() const
Returns the associated surface.
const MeasVec & measurements() const
Returns the associated measurements.
SG::ReadHandleKey< ActsTrk::GeometryContext > m_geoCtxKey
Dependency on the geometry alignment.
Gaudi::Property< bool > m_drawEvent
Option to draw every extrapolation asan obj file.
const MuonGMR4::MuonDetectorManager * m_detMgr
Detector manager to fetch the sector surfaces.
ToolHandle< ActsTrk::IExtrapolationTool > m_extrapolationTool
Track extrapolation tool.
SG::ReadHandleKey< xAOD::MuonSegmentContainer > m_readKey
Declare the data dependency on the standard Mdt+Rpc+Tgc segment container.
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
IdHelperSvc to decode the Identifiers.
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the point B' along the line B that's closest to a second line A.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
::StatusCode StatusCode
StatusCode definition for legacy code.
float extrapolate(const MuonLayerHough::Maximum &ref, const MuonLayerHough::Maximum &ex, bool doparabolic=false)
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::BoundTrackParameters boundSegmentPars(const MuonGMR4::MuonDetectorManager &detMgr, const xAOD::MuonSegment &segment, std::optional< Acts::BoundMatrix > cov=std::nullopt, Acts::ParticleHypothesis hypot=Acts::ParticleHypothesis::muon())
Returns the segment parameters as boundTrackParameters.
std::string printID(const xAOD::MuonSegment &seg)
Print the chamber ID of a segment, e.g.
const Segment * detailedSegment(const xAOD::MuonSegment &seg)
Helper function to navigate from the xAOD::MuonSegment to the MuonR4::Segment.
void drawBoundParameters(const ActsTrk::GeometryContext &gctx, const Acts::BoundTrackParameters &pars, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewLine, const double standardLength=3.*Gaudi::Units::cm)
Draw a line representing the bound track parameters.
void drawSegmentMeasurements(const ActsTrk::GeometryContext &gctx, const xAOD::MuonSegment &segment, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewSensitive)
Draw all uncalibrated measurements associated to the segment.
void drawSegmentLine(const ActsTrk::GeometryContext &gctx, const xAOD::MuonSegment &segment, Acts::ObjVisualization3D &visualHelper, const Acts::ViewConfig &viewConfig=Acts::s_viewLine, const double standardLength=1.*Gaudi::Units::m)
Draw a segment line inside the obj file.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
dot(G, fn, nodesToHighlight=[])
MuonSegmentContainer_v1 MuonSegmentContainer
Definition of the current "MuonSegment container version".
const Acts::Surface & muonSurface(const UncalibratedMeasurement *meas)
Returns the associated Acts surface to the measurement.
MuonSegment_v1 MuonSegment
Reference the current persistent version: