88 switch (bounds.type()) {
89 using enum Acts::SurfaceBounds::BoundsType;
91 using ParEnum_t = Acts::RectangleBounds::BoundValues;
92 const auto& cBounds =
static_cast<const Acts::RectangleBounds&
>(bounds);
93 return std::make_shared<Trk::RectangleBounds>(cBounds.get(ParEnum_t::eMaxX),
94 cBounds.get(ParEnum_t::eMaxY));
96 using ParEnum_t = Acts::TrapezoidBounds::BoundValues;
97 const auto& cBounds =
static_cast<const Acts::TrapezoidBounds&
>(bounds);
98 return std::make_shared<Trk::TrapezoidBounds>(cBounds.get(ParEnum_t::eHalfLengthXnegY),
99 cBounds.get(ParEnum_t::eHalfLengthXposY),
100 cBounds.get(ParEnum_t::eHalfLengthY));
102 using ParEnum_t = Acts::RadialBounds::BoundValues;
103 const auto& cBounds =
static_cast<const Acts::RadialBounds&
>(bounds);
104 return std::make_shared<Trk::DiscBounds>(cBounds.get(ParEnum_t::eMinR),
105 cBounds.get(ParEnum_t::eMaxR),
106 cBounds.get(ParEnum_t::eAveragePhi),
107 cBounds.get(ParEnum_t::eHalfPhiSector));
109 using ParEnum_t = Acts::CylinderBounds::BoundValues;
110 const auto& cBounds =
static_cast<const Acts::CylinderBounds&
>(bounds);
111 return std::make_shared<Trk::CylinderBounds>(cBounds.get(ParEnum_t::eR),
112 cBounds.get(ParEnum_t::eHalfPhiSector),
113 cBounds.get(ParEnum_t::eAveragePhi),
114 cBounds.get(ParEnum_t::eHalfLengthZ));
116 using ParEnum_t = Acts::LineBounds::BoundValues;
117 const auto& cBounds =
static_cast<const Acts::LineBounds&
>(bounds);
118 return std::make_shared<Trk::CylinderBounds>(cBounds.get(ParEnum_t::eR),
119 cBounds.get(ParEnum_t::eHalfLengthZ));
121 using ParEnum_t = Acts::DiamondBounds::BoundValues;
122 const auto& cBounds =
static_cast<const Acts::DiamondBounds&
>(bounds);
123 return std::make_shared<Trk::DiamondBounds>(cBounds.get(ParEnum_t::eHalfLengthXnegY),
124 cBounds.get(ParEnum_t::eHalfLengthXzeroY),
125 cBounds.get(ParEnum_t::eHalfLengthXposY),
126 cBounds.get(ParEnum_t::eHalfLengthYneg),
127 cBounds.get(ParEnum_t::eHalfLengthYpos));
226 std::shared_ptr<const Acts::Surface> actsSurface{};
227 Acts::BoundVector params{};
228 const Acts::GeometryContext tgContext =
m_ctxProvider.getGeometryContext(ctx);
233 }
catch (
const std::exception &e) {
234 ATH_MSG_ERROR(
"Could not find ACTS detector surface for this TrackParameter:");
240 const auto& atlasParam{atlasParameter.parameters()};
241 if (actsSurface->bounds().type() == Acts::SurfaceBounds::BoundsType::eAnnulus) {
245 auto result = actsSurface->globalToLocal(tgContext, position, atlasParameter.
momentum());
247 params << (*result)[0], (*result)[1], atlasParam[
Trk::phi0],
252 ATH_MSG_WARNING(
"Unable to convert annulus surface - globalToLocal failed");
260 std::optional<Acts::BoundMatrix> cov{};
261 if (atlasParameter.covariance()) {
262 cov = Acts::BoundMatrix::Identity();
263 cov->topLeftCorner(5, 5) = *atlasParameter.covariance();
268 for (
int i = 0; i < cov->rows(); ++i) {
269 (*cov)(i, 4) = (*cov)(i, 4) / 1_MeV;
271 for (
int i = 0; i < cov->cols(); ++i) {
272 (*cov)(4, i) = (*cov)(4, i) / 1_MeV;
275 return Acts::BoundTrackParameters{actsSurface, params, std::move(cov),
280 const Acts::BoundTrackParameters& actsParameter)
const {
284 if (actsParameter.covariance()) {
285 AmgSymMatrix(5) newcov(actsParameter.covariance()->topLeftCorner<5, 5>());
287 for (
int i = 0; i < newcov.rows(); i++) {
288 newcov(i, 4) = newcov(i, 4) * 1_MeV;
290 for (
int i = 0; i < newcov.cols(); i++) {
291 newcov(4, i) = newcov(4, i) * 1_MeV;
296 const Acts::Surface &actsSurface = actsParameter.referenceSurface();
298 switch (actsSurface.type()) {
299 case Acts::Surface::SurfaceType::Cone: {
300 const auto &coneSurface =
static_cast<const Trk::ConeSurface&
>(*trkSurface);
301 return std::make_unique<Trk::AtaCone>(
302 actsParameter.get<Acts::eBoundLoc0>(),
303 actsParameter.get<Acts::eBoundLoc1>(),
304 actsParameter.get<Acts::eBoundPhi>(),
305 actsParameter.get<Acts::eBoundTheta>(),
306 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, coneSurface, cov);
307 }
case Acts::Surface::SurfaceType::Cylinder: {
309 return std::make_unique<Trk::AtaCylinder>(
310 actsParameter.get<Acts::eBoundLoc0>(),
311 actsParameter.get<Acts::eBoundLoc1>(),
312 actsParameter.get<Acts::eBoundPhi>(),
313 actsParameter.get<Acts::eBoundTheta>(),
314 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, cylSurface, cov);
315 }
case Acts::Surface::SurfaceType::Disc: {
318 return std::make_unique<Trk::AtaDisc>(
319 actsParameter.get<Acts::eBoundLoc0>(),
320 actsParameter.get<Acts::eBoundLoc1>(),
321 actsParameter.get<Acts::eBoundPhi>(),
322 actsParameter.get<Acts::eBoundTheta>(),
323 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, discSurface, cov);
325 const Acts::GeometryContext tgContext =
m_ctxProvider.getGeometryContext(ctx);
328 auto helperSurface = Acts::Surface::makeShared<Acts::PlaneSurface>(planeSurface.transform());
330 auto covpc = actsParameter.covariance().value();
332 Acts::FreeVector freePars = Acts::transformBoundToFreeParameters(actsSurface, tgContext,
333 actsParameter.parameters());
336 Acts::BoundVector targetPars = Acts::transformFreeToBoundParameters(freePars,
337 *helperSurface, tgContext).value();
340 Acts::FreeMatrix freeTransportJacobian{Acts::FreeMatrix::Identity()};
342 Acts::FreeVector freeToPathDerivatives{Acts::FreeVector::Zero()};
343 freeToPathDerivatives.head<3>() = freePars.segment<3>(Acts::eFreeDir0);
345 auto boundToFreeJacobian = actsSurface.boundToFreeJacobian(tgContext,
346 freePars.segment<3>(Acts::eFreePos0),
347 freePars.segment<3>(Acts::eFreeDir0));
349 Acts::BoundMatrix boundToBoundJac =
350 Acts::detail::boundToBoundTransportJacobian(tgContext, freePars,
351 boundToFreeJacobian, freeTransportJacobian,
352 freeToPathDerivatives, *helperSurface);
354 Acts::BoundMatrix targetCov{boundToBoundJac * covpc * boundToBoundJac.transpose()};
356 return std::make_unique<Trk::AtaPlane>(
357 targetPars[Acts::eBoundLoc0], targetPars[Acts::eBoundLoc1],
358 targetPars[Acts::eBoundPhi], targetPars[Acts::eBoundTheta],
359 targetPars[Acts::eBoundQOverP] * 1_MeV, planeSurface,
360 targetCov.topLeftCorner<5, 5>());
362 throw std::domain_error(
"Acts::DiscSurface is not associated with ATLAS disc or plane surface");
365 }
case Acts::Surface::SurfaceType::Perigee: {
367 return std::make_unique<Trk::Perigee>(
368 actsParameter.get<Acts::eBoundLoc0>(),
369 actsParameter.get<Acts::eBoundLoc1>(),
370 actsParameter.get<Acts::eBoundPhi>(),
371 actsParameter.get<Acts::eBoundTheta>(),
372 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, perSurface, cov);
373 }
case Acts::Surface::SurfaceType::Plane: {
375 return std::make_unique<Trk::AtaPlane>(
376 actsParameter.get<Acts::eBoundLoc0>(),
377 actsParameter.get<Acts::eBoundLoc1>(),
378 actsParameter.get<Acts::eBoundPhi>(),
379 actsParameter.get<Acts::eBoundTheta>(),
380 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, plaSurface, cov);
381 }
case Acts::Surface::SurfaceType::Straw: {
383 return std::make_unique<Trk::AtaStraightLine>(
384 actsParameter.get<Acts::eBoundLoc0>(),
385 actsParameter.get<Acts::eBoundLoc1>(),
386 actsParameter.get<Acts::eBoundPhi>(),
387 actsParameter.get<Acts::eBoundTheta>(),
388 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, lineSurface, cov);
389 }
case Acts::Surface::SurfaceType::Curvilinear: {
390 const Acts::GeometryContext tgContext =
m_ctxProvider.getGeometryContext(ctx);
391 return std::make_unique<Trk::CurvilinearParameters>(
392 actsParameter.position(tgContext), actsParameter.get<Acts::eBoundPhi>(),
393 actsParameter.get<Acts::eBoundTheta>(),
394 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, cov);
395 }
case Acts::Surface::SurfaceType::Point:
396 case Acts::Surface::SurfaceType::Other: {
400 throw std::domain_error(
"Surface type not found");