87 switch (bounds.type()) {
88 using enum Acts::SurfaceBounds::BoundsType;
90 using ParEnum_t = Acts::RectangleBounds::BoundValues;
91 const auto& cBounds =
static_cast<const Acts::RectangleBounds&
>(bounds);
92 return std::make_shared<Trk::RectangleBounds>(cBounds.get(ParEnum_t::eMaxX),
93 cBounds.get(ParEnum_t::eMaxY));
95 using ParEnum_t = Acts::TrapezoidBounds::BoundValues;
96 const auto& cBounds =
static_cast<const Acts::TrapezoidBounds&
>(bounds);
97 return std::make_shared<Trk::TrapezoidBounds>(cBounds.get(ParEnum_t::eHalfLengthXnegY),
98 cBounds.get(ParEnum_t::eHalfLengthXposY),
99 cBounds.get(ParEnum_t::eHalfLengthY));
101 using ParEnum_t = Acts::RadialBounds::BoundValues;
102 const auto& cBounds =
static_cast<const Acts::RadialBounds&
>(bounds);
103 return std::make_shared<Trk::DiscBounds>(cBounds.get(ParEnum_t::eMinR),
104 cBounds.get(ParEnum_t::eMaxR),
105 cBounds.get(ParEnum_t::eAveragePhi),
106 cBounds.get(ParEnum_t::eHalfPhiSector));
108 using ParEnum_t = Acts::CylinderBounds::BoundValues;
109 const auto& cBounds =
static_cast<const Acts::CylinderBounds&
>(bounds);
110 return std::make_shared<Trk::CylinderBounds>(cBounds.get(ParEnum_t::eR),
111 cBounds.get(ParEnum_t::eHalfPhiSector),
112 cBounds.get(ParEnum_t::eAveragePhi),
113 cBounds.get(ParEnum_t::eHalfLengthZ));
115 using ParEnum_t = Acts::LineBounds::BoundValues;
116 const auto& cBounds =
static_cast<const Acts::LineBounds&
>(bounds);
117 return std::make_shared<Trk::CylinderBounds>(cBounds.get(ParEnum_t::eR),
118 cBounds.get(ParEnum_t::eHalfLengthZ));
120 using ParEnum_t = Acts::DiamondBounds::BoundValues;
121 const auto& cBounds =
static_cast<const Acts::DiamondBounds&
>(bounds);
122 return std::make_shared<Trk::DiamondBounds>(cBounds.get(ParEnum_t::eHalfLengthXnegY),
123 cBounds.get(ParEnum_t::eHalfLengthXzeroY),
124 cBounds.get(ParEnum_t::eHalfLengthXposY),
125 cBounds.get(ParEnum_t::eHalfLengthYneg),
126 cBounds.get(ParEnum_t::eHalfLengthYpos));
225 std::shared_ptr<const Acts::Surface> actsSurface{};
226 Acts::BoundVector params{};
232 }
catch (
const std::exception &e) {
233 ATH_MSG_ERROR(
"Could not find ACTS detector surface for this TrackParameter:");
239 const auto& atlasParam{atlasParameter.parameters()};
240 if (actsSurface->bounds().type() == Acts::SurfaceBounds::BoundsType::eAnnulus) {
244 auto result = actsSurface->globalToLocal(tgContext, position, atlasParameter.
momentum());
246 params << (*result)[0], (*result)[1], atlasParam[
Trk::phi0],
251 ATH_MSG_WARNING(
"Unable to convert annulus surface - globalToLocal failed");
259 std::optional<Acts::BoundMatrix> cov{};
260 if (atlasParameter.covariance()) {
261 cov = Acts::BoundMatrix::Identity();
262 cov->topLeftCorner(5, 5) = *atlasParameter.covariance();
267 for (
int i = 0; i < cov->rows(); ++i) {
268 (*cov)(i, 4) = (*cov)(i, 4) / 1_MeV;
270 for (
int i = 0; i < cov->cols(); ++i) {
271 (*cov)(4, i) = (*cov)(4, i) / 1_MeV;
274 return Acts::BoundTrackParameters{actsSurface, params, std::move(cov),
279 const Acts::BoundTrackParameters& actsParameter)
const {
283 if (actsParameter.covariance()) {
284 AmgSymMatrix(5) newcov(actsParameter.covariance()->topLeftCorner<5, 5>());
286 for (
int i = 0; i < newcov.rows(); i++) {
287 newcov(i, 4) = newcov(i, 4) * 1_MeV;
289 for (
int i = 0; i < newcov.cols(); i++) {
290 newcov(4, i) = newcov(4, i) * 1_MeV;
295 const Acts::Surface &actsSurface = actsParameter.referenceSurface();
297 switch (actsSurface.type()) {
298 case Acts::Surface::SurfaceType::Cone: {
299 const auto &coneSurface =
static_cast<const Trk::ConeSurface&
>(*trkSurface);
300 return std::make_unique<Trk::AtaCone>(
301 actsParameter.get<Acts::eBoundLoc0>(),
302 actsParameter.get<Acts::eBoundLoc1>(),
303 actsParameter.get<Acts::eBoundPhi>(),
304 actsParameter.get<Acts::eBoundTheta>(),
305 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, coneSurface, cov);
306 }
case Acts::Surface::SurfaceType::Cylinder: {
308 return std::make_unique<Trk::AtaCylinder>(
309 actsParameter.get<Acts::eBoundLoc0>(),
310 actsParameter.get<Acts::eBoundLoc1>(),
311 actsParameter.get<Acts::eBoundPhi>(),
312 actsParameter.get<Acts::eBoundTheta>(),
313 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, cylSurface, cov);
314 }
case Acts::Surface::SurfaceType::Disc: {
317 return std::make_unique<Trk::AtaDisc>(
318 actsParameter.get<Acts::eBoundLoc0>(),
319 actsParameter.get<Acts::eBoundLoc1>(),
320 actsParameter.get<Acts::eBoundPhi>(),
321 actsParameter.get<Acts::eBoundTheta>(),
322 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, discSurface, cov);
327 auto helperSurface = Acts::Surface::makeShared<Acts::PlaneSurface>(planeSurface.transform());
329 auto covpc = actsParameter.covariance().value();
331 Acts::FreeVector freePars = Acts::transformBoundToFreeParameters(actsSurface, tgContext,
332 actsParameter.parameters());
335 Acts::BoundVector targetPars = Acts::transformFreeToBoundParameters(freePars,
336 *helperSurface, tgContext).value();
339 Acts::FreeMatrix freeTransportJacobian{Acts::FreeMatrix::Identity()};
341 Acts::FreeVector freeToPathDerivatives{Acts::FreeVector::Zero()};
342 freeToPathDerivatives.head<3>() = freePars.segment<3>(Acts::eFreeDir0);
344 auto boundToFreeJacobian = actsSurface.boundToFreeJacobian(tgContext,
345 freePars.segment<3>(Acts::eFreePos0),
346 freePars.segment<3>(Acts::eFreeDir0));
348 Acts::BoundMatrix boundToBoundJac =
349 Acts::detail::boundToBoundTransportJacobian(tgContext, freePars,
350 boundToFreeJacobian, freeTransportJacobian,
351 freeToPathDerivatives, *helperSurface);
353 Acts::BoundMatrix targetCov{boundToBoundJac * covpc * boundToBoundJac.transpose()};
355 return std::make_unique<Trk::AtaPlane>(
356 targetPars[Acts::eBoundLoc0], targetPars[Acts::eBoundLoc1],
357 targetPars[Acts::eBoundPhi], targetPars[Acts::eBoundTheta],
358 targetPars[Acts::eBoundQOverP] * 1_MeV, planeSurface,
359 targetCov.topLeftCorner<5, 5>());
361 throw std::domain_error(
"Acts::DiscSurface is not associated with ATLAS disc or plane surface");
364 }
case Acts::Surface::SurfaceType::Perigee: {
366 return std::make_unique<Trk::Perigee>(
367 actsParameter.get<Acts::eBoundLoc0>(),
368 actsParameter.get<Acts::eBoundLoc1>(),
369 actsParameter.get<Acts::eBoundPhi>(),
370 actsParameter.get<Acts::eBoundTheta>(),
371 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, perSurface, cov);
372 }
case Acts::Surface::SurfaceType::Plane: {
374 return std::make_unique<Trk::AtaPlane>(
375 actsParameter.get<Acts::eBoundLoc0>(),
376 actsParameter.get<Acts::eBoundLoc1>(),
377 actsParameter.get<Acts::eBoundPhi>(),
378 actsParameter.get<Acts::eBoundTheta>(),
379 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, plaSurface, cov);
380 }
case Acts::Surface::SurfaceType::Straw: {
382 return std::make_unique<Trk::AtaStraightLine>(
383 actsParameter.get<Acts::eBoundLoc0>(),
384 actsParameter.get<Acts::eBoundLoc1>(),
385 actsParameter.get<Acts::eBoundPhi>(),
386 actsParameter.get<Acts::eBoundTheta>(),
387 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, lineSurface, cov);
388 }
case Acts::Surface::SurfaceType::Curvilinear: {
390 return std::make_unique<Trk::CurvilinearParameters>(
391 actsParameter.position(tgContext), actsParameter.get<Acts::eBoundPhi>(),
392 actsParameter.get<Acts::eBoundTheta>(),
393 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, cov);
394 }
case Acts::Surface::SurfaceType::Other: {
398 throw std::domain_error(
"Surface type not found");