47 const auto tgContext = gctx->
context();
49 auto extrapolate = [&](
const Acts::BoundTrackParameters& start,
54 Amg::Vector3D::Zero(),
55 Amg::Vector3D::Zero());
58 trf.linear() *
sp.sensorDirection(),
59 start.position(tgContext),
63 n.dot(target.center(tgContext)));
67 <<
Amg::toString(start.direction())<<
" onto surface: "<<target.toString(tgContext)
69 <<
" geoId: "<<target.geometryId()<<
", "<<( lambda.value_or(0.) > 0 ?
"forward" :
"backward"));
72 ? Acts::Direction::Forward()
73 : Acts::Direction::Backward(), 100._m);
76 StatusCode retCode = StatusCode::SUCCESS;
81 const auto [locPos, locDir] =
makeLine(segPars);
88 Acts::ObjVisualization3D visualHelper{};
92 Acts::ViewConfig{.color = {220, 0, 0}});
96 if (
msgLvl(MSG::VERBOSE)) {
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{})
116 if (!meas->spacePoint() ||
117 meas->fitState() != MuonR4::CalibratedSpacePoint::State::Valid) {
120 const auto sp = meas->spacePoint();
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
135 }
else if (targetSurf.type() == Acts::Surface::SurfaceType::Straw) {
136 const auto cIsect = lineIntersect<3>(meas->localPosition(),
137 meas->sensorDirection(),
139 const auto cIsectPos = cIsect.position();
140 const auto cPos = trf * cIsectPos;
141 lPos[0] = cPos.perp() * SeedingAux::strawSign(locPos, locDir, *meas);
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) {
152 auto extpPars = extrapolate(startPars, *
sp);
156 <<
", expected: "<<
Amg::toString(lPos)<<
", "<<targetSurf.bounds());
157 retCode = StatusCode::FAILURE;
163 Acts::ViewConfig{.color = {0, 0, 220}}, 6._cm);
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;
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;
196 visualHelper.write(std::format(
"ExtTpTest_{:}_{:}_{:}.obj",
197 ctx.eventID().event_number(), segment->index(),
SG::ReadHandleKey< ActsTrk::GeometryContext > m_geoCtxKey
Dependency on the geometry alignment.
Gaudi::Property< bool > m_drawEvent
Option to draw every extrapolation asan obj file.
virtual StatusCode execute(const EventContext &ctx) const override final
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.