14#include "GaudiKernel/IInterface.h"
41#include "Acts/Surfaces/StrawSurface.hpp"
42#include "Acts/Surfaces/PerigeeSurface.hpp"
43#include "Acts/Surfaces/PlaneSurface.hpp"
45#include "Acts/Surfaces/RectangleBounds.hpp"
46#include "Acts/Surfaces/TrapezoidBounds.hpp"
47#include "Acts/Surfaces/CylinderBounds.hpp"
48#include "Acts/Surfaces/DiscBounds.hpp"
49#include "Acts/Surfaces/LineBounds.hpp"
50#include "Acts/Surfaces/RadialBounds.hpp"
52#include "Acts/Definitions/Units.hpp"
53#include "Acts/EventData/BoundTrackParameters.hpp"
54#include "Acts/EventData/VectorTrackContainer.hpp"
55#include "Acts/EventData/TransformationHelpers.hpp"
56#include "Acts/Geometry/TrackingGeometry.hpp"
57#include "Acts/Propagator/detail/JacobianEngine.hpp"
58#include "Acts/Surfaces/detail/PlanarHelper.hpp"
61#include "Acts/EventData/TrackStatePropMask.hpp"
62#include "Acts/EventData/SourceLink.hpp"
83using namespace Acts::UnitLiterals;
89#pragma GCC diagnostic push
90#pragma GCC diagnostic ignored "-Wunused-function"
93 const Acts::Surface &surface,
94 const Acts::BoundVector &loc);
95#pragma GCC diagnostic pop
98 const Acts::BoundTrackParameters &actsParameter,
99 const Acts::GeometryContext &gctx,
const Acts::BoundMatrix &covpc,
100 const Acts::BoundVector &targetPars,
const Acts::BoundMatrix &targetCov,
108 using namespace Acts::PlanarHelper;
110 const auto isect = intersectPlane(pos, mom.normalized(), target.normal(), target.center());
112 if (inPars.covariance()) {
114 rot.block<2,2>(0,0) =
AmgSymMatrix(2){Eigen::Rotation2D{90._degree}};
115 cov = rot.transpose() * (*inPars.covariance()) * rot;
117 return target.createUniqueTrackParameters(isect.position(), mom,
118 std::copysign(1., inPars.parameters()[
Trk::qOverP]),
134 surface->surfacePlacement());
144 auto [it, ok] =
m_actsSurfaceMap.insert(std::make_pair(actsElement->identify(), surface->getSharedPtr()));
147 <<
" has two ACTS surfaces: "
148 << it->second->geometryId() <<
" and "
149 << surface->geometryId());
168 ATH_CHECK(detStore()->retrieve(muonMgr));
171 std::vector<std::shared_ptr<Acts::Surface>> reSurfaces = readoutElement->getSurfaces();
172 for (
const auto& surf : reSurfaces) {
179 return StatusCode::SUCCESS;
185 switch (surface.type()) {
186 using enum Acts::Surface::SurfaceType;
191 std::dynamic_pointer_cast<Trk::CylinderBounds>(
translateBounds(surface.bounds())))};
196 std::dynamic_pointer_cast<Trk::DiscBounds>(
translateBounds(surface.bounds())))};
198 auto bounds = std::dynamic_pointer_cast<Trk::CylinderBounds>(
translateBounds(surface.bounds()));
204 THROW_EXCEPTION(
"ActsToTrkConverterTool() - Surface cannot be translated "
205 <<surface.toString(gctx.
context()));
211 const Acts::Surface &actsSurface)
const {
213 const auto *detEleBase=
dynamic_cast<const IDetectorElementBase*
>(actsSurface.surfacePlacement());
217 switch (detEleBase->detectorType()) {
248std::shared_ptr<const Acts::Surface>
257 switch (atlasSurface.
type()){
260 return Acts::Surface::makeShared<Acts::PlaneSurface>(trf);
262 return Acts::Surface::makeShared<Acts::PerigeeSurface>(trf);
264 return Acts::Surface::makeShared<Acts::StrawSurface>(trf);
270 std::stringstream surfStr{};
271 atlasSurface.
dump(surfStr);
272 throw std::domain_error(std::format(
"Failed to translate surface {:}", surfStr.str()));
275std::vector<Acts::SourceLink>
277 std::vector<Acts::SourceLink> sourceLinks{};
278 sourceLinks.reserve(track.measurementsOnTrack()->size() +
279 track.outliersOnTrack()->size());
280 toSourceLinks(track.measurementsOnTrack()->stdcont(), sourceLinks);
281 toSourceLinks(track.outliersOnTrack()->stdcont(), sourceLinks);
287 std::vector<Acts::SourceLink>& sourceLinks)
const{
288 if (sourceLinks.capacity() < sourceLinks.size() + measSet.size()) {
289 sourceLinks.reserve(sourceLinks.size() + measSet.size());
291 std::ranges::transform(measSet, std::back_inserter(sourceLinks), [](
const Trk::MeasurementBase* meas) {
296 std::vector<Acts::SourceLink>& links)
const {
297 if (links.capacity() < links.size() + prdSet.size()) {
298 links.reserve(links.size() + prdSet.size());
300 std::ranges::transform(prdSet, std::back_inserter(links), [](
const Trk::PrepRawData* prd) {
305const Acts::BoundTrackParameters
307 const Acts::GeometryContext & gctx,
310 std::shared_ptr<const Acts::Surface> actsSurface{};
311 Acts::BoundVector params;
316 }
catch (
const std::exception &e) {
317 ATH_MSG_ERROR(
"Could not find ACTS detector surface for this TrackParameter:");
323 const auto& atlasParam{atlasParameter.parameters()};
324 if (actsSurface->bounds().type() == Acts::SurfaceBounds::BoundsType::eAnnulus) {
328 auto result = actsSurface->globalToLocal(gctx, position, atlasParameter.
momentum());
330 params << (*result)[0], (*result)[1], atlasParam[
Trk::phi0],
335 ATH_MSG_WARNING(
"Unable to convert annulus surface - globalToLocal failed");
343 Acts::BoundMatrix cov = Acts::BoundMatrix::Identity();
344 if (atlasParameter.covariance()) {
345 cov.topLeftCorner(5, 5) = *atlasParameter.covariance();
350 for (
int i = 0; i < cov.rows(); i++) {
351 cov(i, 4) = cov(i, 4) / 1_MeV;
353 for (
int i = 0; i < cov.cols(); i++) {
354 cov(4, i) = cov(4, i) / 1_MeV;
358 return Acts::BoundTrackParameters(actsSurface, params,cov,
362std::unique_ptr<Trk::TrackParameters>
364 const EventContext& ctx,
365 const Acts::BoundTrackParameters &actsParameter,
366 const Acts::GeometryContext &gctx)
const {
369 if (actsParameter.covariance()) {
370 AmgSymMatrix(5) newcov(actsParameter.covariance()->topLeftCorner<5, 5>());
372 for (
int i = 0; i < newcov.rows(); i++) {
373 newcov(i, 4) = newcov(i, 4) * 1_MeV;
375 for (
int i = 0; i < newcov.cols(); i++) {
376 newcov(4, i) = newcov(4, i) * 1_MeV;
381 const Acts::Surface &actsSurface = actsParameter.referenceSurface();
383 switch (actsSurface.type()) {
384 case Acts::Surface::SurfaceType::Cone: {
385 const auto &coneSurface =
static_cast<const Trk::ConeSurface&
>(*trkSurface);
386 return std::make_unique<Trk::AtaCone>(
387 actsParameter.get<Acts::eBoundLoc0>(),
388 actsParameter.get<Acts::eBoundLoc1>(),
389 actsParameter.get<Acts::eBoundPhi>(),
390 actsParameter.get<Acts::eBoundTheta>(),
391 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, coneSurface, cov);
392 }
case Acts::Surface::SurfaceType::Cylinder: {
394 return std::make_unique<Trk::AtaCylinder>(
395 actsParameter.get<Acts::eBoundLoc0>(),
396 actsParameter.get<Acts::eBoundLoc1>(),
397 actsParameter.get<Acts::eBoundPhi>(),
398 actsParameter.get<Acts::eBoundTheta>(),
399 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, cylSurface, cov);
400 }
case Acts::Surface::SurfaceType::Disc: {
403 return std::make_unique<Trk::AtaDisc>(
404 actsParameter.get<Acts::eBoundLoc0>(),
405 actsParameter.get<Acts::eBoundLoc1>(),
406 actsParameter.get<Acts::eBoundPhi>(),
407 actsParameter.get<Acts::eBoundTheta>(),
408 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, discSurface, cov);
412 auto helperSurface = Acts::Surface::makeShared<Acts::PlaneSurface>(planeSurface.transform());
414 auto covpc = actsParameter.covariance().value();
416 Acts::FreeVector freePars = Acts::transformBoundToFreeParameters(actsSurface, gctx,
417 actsParameter.parameters());
420 Acts::BoundVector targetPars = Acts::transformFreeToBoundParameters(freePars,
421 *helperSurface, gctx).value();
423 Acts::FreeMatrix freeTransportJacobian{Acts::FreeMatrix::Identity()};
425 Acts::FreeVector freeToPathDerivatives{Acts::FreeVector::Zero()};
426 freeToPathDerivatives.head<3>() = freePars.segment<3>(Acts::eFreeDir0);
428 auto boundToFreeJacobian = actsSurface.boundToFreeJacobian(gctx, freePars.segment<3>(Acts::eFreePos0),
429 freePars.segment<3>(Acts::eFreeDir0));
431 Acts::BoundMatrix boundToBoundJac = Acts::detail::boundToBoundTransportJacobian(gctx, freePars,
432 boundToFreeJacobian, freeTransportJacobian, freeToPathDerivatives, *helperSurface);
434 Acts::BoundMatrix targetCov{boundToBoundJac * covpc * boundToBoundJac.transpose()};
436 auto pars = std::make_unique<Trk::AtaPlane>(
437 targetPars[Acts::eBoundLoc0], targetPars[Acts::eBoundLoc1],
438 targetPars[Acts::eBoundPhi], targetPars[Acts::eBoundTheta],
439 targetPars[Acts::eBoundQOverP] * 1_MeV, planeSurface,
440 targetCov.topLeftCorner<5, 5>());
444 targetCov, &planeSurface);
449 throw std::domain_error(
"Acts::DiscSurface is not associated with ATLAS disc or plane surface");
452 }
case Acts::Surface::SurfaceType::Perigee: {
454 return std::make_unique<Trk::Perigee>(
455 actsParameter.get<Acts::eBoundLoc0>(),
456 actsParameter.get<Acts::eBoundLoc1>(),
457 actsParameter.get<Acts::eBoundPhi>(),
458 actsParameter.get<Acts::eBoundTheta>(),
459 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, perSurface, cov);
460 }
case Acts::Surface::SurfaceType::Plane: {
462 return std::make_unique<Trk::AtaPlane>(
463 actsParameter.get<Acts::eBoundLoc0>(),
464 actsParameter.get<Acts::eBoundLoc1>(),
465 actsParameter.get<Acts::eBoundPhi>(),
466 actsParameter.get<Acts::eBoundTheta>(),
467 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, plaSurface, cov);
468 }
case Acts::Surface::SurfaceType::Straw: {
470 return std::make_unique<Trk::AtaStraightLine>(
471 actsParameter.get<Acts::eBoundLoc0>(),
472 actsParameter.get<Acts::eBoundLoc1>(),
473 actsParameter.get<Acts::eBoundPhi>(),
474 actsParameter.get<Acts::eBoundTheta>(),
475 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, lineSurface, cov);
476 }
case Acts::Surface::SurfaceType::Curvilinear: {
477 return std::make_unique<Trk::CurvilinearParameters>(
478 actsParameter.position(gctx), actsParameter.get<Acts::eBoundPhi>(),
479 actsParameter.get<Acts::eBoundTheta>(),
480 actsParameter.get<Acts::eBoundQOverP>() * 1_MeV, cov);
481 }
case Acts::Surface::SurfaceType::Other: {
485 throw std::domain_error(
"Surface type not found");
490 const Acts::GeometryContext & gctx)
const {
492 << trackColl.
size() <<
" tracks.");
493 unsigned int trkCount = 0;
494 std::vector<Identifier> failedIds;
499 auto actsTrack =
tc.getTrack(
tc.addTrack());
500 auto& trackStateContainer =
tc.trackStateContainer();
503 <<
" track states on surfaces.");
505 actsTrack.chi2() = trk->fitQuality()->chiSquared();
506 actsTrack.nDoF() = trk->fitQuality()->numberDoF();
510 bool first_tsos =
true;
511 int measurementsCount = 0;
515 Acts::TrackStatePropMask mask = Acts::TrackStatePropMask::None;
516 if (tsos->measurementOnTrack()) {
517 mask |= Acts::TrackStatePropMask::Calibrated;
519 if (tsos->trackParameters()) {
520 mask |= Acts::TrackStatePropMask::Smoothed;
524 auto index = Acts::kTrackIndexInvalid;
526 index = actsTrack.tipIndex();
528 auto actsTSOS = trackStateContainer.getTrackState(trackStateContainer.addTrackState(mask,
index));
529 ATH_MSG_VERBOSE(
"TipIndex: " << actsTrack.tipIndex() <<
" TSOS index within trajectory: "<< actsTSOS.index());
530 actsTrack.tipIndex() = actsTSOS.index();
532 if (tsos->trackParameters()) {
537 const Acts::BoundTrackParameters parameters =
542 failedIds.push_back(tsos->trackParameters()->associatedSurface().associatedDetectorElementIdentifier());
548 actsTrack.parameters() = parameters.parameters();
549 actsTrack.covariance() = *parameters.covariance();
550 actsTrack.setReferenceSurface(parameters.referenceSurface().getSharedPtr());
553 actsTSOS.setReferenceSurface(parameters.referenceSurface().getSharedPtr());
555 actsTSOS.smoothed() = parameters.parameters();
556 actsTSOS.smoothedCovariance() = *parameters.covariance();
559 if (!(actsTSOS.hasSmoothed() && actsTSOS.hasReferenceSurface())) {
561 << actsTSOS.hasSmoothed()
562 <<
"] or reference surface ["
563 << actsTSOS.hasReferenceSurface() <<
"].");
565 ATH_MSG_VERBOSE(
"TrackState has smoothed state and reference surface.");
568 }
catch (
const std::exception& e){
569 ATH_MSG_ERROR(
"Unable to convert TrackParameter with exception ["<<e.what()<<
"]. Will be missing from ACTS track."
570 <<(*tsos->trackParameters()));
573 if (tsos->measurementOnTrack()) {
574 auto &measurement = *(tsos->measurementOnTrack());
582 int dim = measurement.localParameters().dimension();
583 actsTSOS.allocateCalibrated(dim);
585 actsTSOS.calibrated<1>() = measurement.localParameters();
586 actsTSOS.calibratedCovariance<1>() = measurement.localCovariance();
587 }
else if (dim == 2) {
588 actsTSOS.calibrated<2>() = measurement.localParameters();
589 actsTSOS.calibratedCovariance<2>() = measurement.localCovariance();
591 throw std::domain_error(
"Cannot handle measurement dim>2");
597 actsTrack.nMeasurements() = measurementsCount;
599 <<
" track states on surfaces.");
603 if (!failedIds.empty()){
604 ATH_MSG_WARNING(
"Failed to convert "<<failedIds.size()<<
" track parameters.");
605 for (
auto id : failedIds){
612std::shared_ptr<Trk::SurfaceBounds>
614 switch (bounds.type()) {
615 using enum Acts::SurfaceBounds::BoundsType;
617 using ParEnum_t = Acts::RectangleBounds::BoundValues;
618 const auto& cBounds =
static_cast<const Acts::RectangleBounds&
>(bounds);
619 return std::make_shared<Trk::RectangleBounds>(cBounds.get(ParEnum_t::eMaxX),
620 cBounds.get(ParEnum_t::eMaxY));
622 using ParEnum_t = Acts::TrapezoidBounds::BoundValues;
623 const auto& cBounds =
static_cast<const Acts::TrapezoidBounds&
>(bounds);
624 return std::make_shared<Trk::TrapezoidBounds>(cBounds.get(ParEnum_t::eHalfLengthXnegY),
625 cBounds.get(ParEnum_t::eHalfLengthXposY),
626 cBounds.get(ParEnum_t::eHalfLengthY));
629 using ParEnum_t = Acts::RadialBounds::BoundValues;
630 const auto& cBounds =
static_cast<const Acts::RadialBounds&
>(bounds);
631 return std::make_shared<Trk::DiscBounds>(cBounds.get(ParEnum_t::eMinR),
632 cBounds.get(ParEnum_t::eMaxR),
633 cBounds.get(ParEnum_t::eAveragePhi),
634 cBounds.get(ParEnum_t::eHalfPhiSector));
637 using ParEnum_t = Acts::CylinderBounds::BoundValues;
638 const auto& cBounds =
static_cast<const Acts::CylinderBounds&
>(bounds);
639 return std::make_shared<Trk::CylinderBounds>(cBounds.get(ParEnum_t::eR),
640 cBounds.get(ParEnum_t::eHalfPhiSector),
641 cBounds.get(ParEnum_t::eAveragePhi),
642 cBounds.get(ParEnum_t::eHalfLengthZ));
644 using ParEnum_t = Acts::LineBounds::BoundValues;
645 const auto& cBounds =
static_cast<const Acts::LineBounds&
>(bounds);
646 return std::make_shared<Trk::CylinderBounds>(cBounds.get(ParEnum_t::eR),
647 cBounds.get(ParEnum_t::eHalfLengthZ));
658 const Acts::BoundTrackParameters ¶meters,
660 const Acts::GeometryContext &gctx)
const {
661 auto actsPos = parameters.position(gctx);
668 if ( (actsPos - trkparameters.
position()).mag() > 0.1) {
670 << actsPos <<
" vs Trk \n"
683#pragma GCC diagnostic push
684#pragma GCC diagnostic ignored "-Wunused-function"
687 const Acts::Surface &surface,
const Acts::BoundVector &loc) {
694 if (bounds ==
nullptr) {
695 throw std::runtime_error{
"Annulus but not XY"};
704 if (
auto res = surface.globalToLocal(gctx, global, Acts::Vector3{});
708 throw std::runtime_error{
"Global position not on target surface"};
714 Acts::Surface::makeShared<Acts::PlaneSurface>(surf.
transform());
715 Acts::BoundVector locxypar;
716 locxypar.head<2>() = locxy;
718 locxypar[3] = M_PI_2;
721 Acts::FreeVector globalxypar = Acts::transformBoundToFreeParameters(
722 *planeSurface, gctx, locxypar);
723 auto boundToFree = planeSurface->boundToFreeJacobian(
724 gctx, globalxypar.segment<3>(Acts::eFreePos0),
725 globalxypar.segment<3>(Acts::eFreeDir0));
726 Acts::SquareMatrix<2> xyToXyzJac = boundToFree.topLeftCorner<2, 2>();
728 Acts::BoundVector locpcpar;
729 locpcpar.head<2>() = locpc;
731 locpcpar[3] = M_PI_2;
734 Acts::FreeVector globalpcpar = Acts::transformBoundToFreeParameters(
735 surface, gctx, locpcpar);
737 boundToFree = surface.boundToFreeJacobian(
738 gctx, globalpcpar.segment<3>(Acts::eFreePos0),
739 globalpcpar.segment<3>(Acts::eFreeDir0));
740 Acts::SquareMatrix<2> pcToXyzJac = boundToFree.topLeftCorner<2, 2>();
741 Acts::SquareMatrix<2> xyzToPcJac = pcToXyzJac.inverse();
744 Acts::SquareMatrix<2> covpc = covxy;
745 covpc = xyToXyzJac * covpc * xyToXyzJac.transpose();
746 covpc = xyzToPcJac * covpc * xyzToPcJac.transpose();
748 std::mt19937 gen{42 + surface.geometryId().value()};
749 std::normal_distribution<double> normal{0, 1};
750 std::uniform_real_distribution<double> uniform{-1, 1};
752 Acts::SquareMatrix<2> lltxy = covxy.llt().matrixL();
753 Acts::SquareMatrix<2> lltpc = covpc.llt().matrixL();
755 for (
size_t i = 0; i < 1e4; i++) {
756 std::cout <<
"ANNULUS COV: ";
757 std::cout << surface.geometryId();
765 std::cout <<
"," << xy.x() <<
"," << xy.y();
766 std::cout <<
"," <<
xyz.x() <<
"," <<
xyz.y() <<
"," <<
xyz.z();
776 std::cout <<
"," << rt.x() <<
"," << rt.y();
777 std::cout <<
"," <<
xyz.x() <<
"," <<
xyz.y() <<
"," <<
xyz.z();
780 std::cout << std::endl;
783#pragma GCC diagnostic pop
786 const Acts::BoundTrackParameters &actsParameter,
787 const Acts::GeometryContext &gctx,
const Acts::BoundMatrix &covpc,
788 const Acts::BoundVector &targetPars,
const Acts::BoundMatrix &targetCov,
791 std::cout <<
"ANNULUS PAR COV: ";
792 std::cout << actsParameter.referenceSurface().geometryId();
793 for (
unsigned int i = 0; i < 5; i++) {
794 for (
unsigned int j = 0; j < 5; j++) {
795 std::cout <<
"," << covpc(i, j);
798 for (
unsigned int i = 0; i < 5; i++) {
799 for (
unsigned int j = 0; j < 5; j++) {
800 std::cout <<
"," << targetCov(i, j);
803 std::cout << std::endl;
805 std::mt19937 gen{4242 +
806 actsParameter.referenceSurface().geometryId().value()};
807 std::normal_distribution<double> normal{0, 1};
809 Acts::SquareMatrix<2> lltxy =
810 targetCov.topLeftCorner<2, 2>().llt().matrixL();
811 Acts::SquareMatrix<2> lltpc = covpc.topLeftCorner<2, 2>().llt().matrixL();
813 for (
size_t i = 0; i < 1e4; i++) {
814 std::cout <<
"ANNULUS PAR: ";
815 std::cout << actsParameter.referenceSurface().geometryId();
818 rnd << normal(gen), normal(gen);
823 lltxy.topLeftCorner<2, 2>() *
rnd + targetPars.head<2>();
827 for (
unsigned int i = 0; i < 2; i++) {
828 std::cout <<
"," << xy[i];
830 std::cout <<
"," <<
xyz.x() <<
"," <<
xyz.y() <<
"," <<
xyz.z();
834 Acts::Vector<2> rt = lltpc.topLeftCorner<2, 2>() *
rnd +
835 actsParameter.parameters().head<2>();
837 gctx, Acts::Vector2{rt.head<2>()}, Acts::Vector3{});
839 for (
unsigned int i = 0; i < 2; i++) {
840 std::cout <<
"," << rt[i];
842 std::cout <<
"," <<
xyz.x() <<
"," <<
xyz.y() <<
"," <<
xyz.z();
845 std::cout << std::endl;
850 TrackFitResult_t& fitResult,
854 if (not fitResult.ok()) {
861template <
typename Proxy_t>
862 std::unique_ptr<Trk::Track>
864 const Proxy_t& acts_track,
872 auto finalTrajectory = std::make_unique<Trk::TrackStates>();
878 acts_track.container().trackStateContainer().visitBackwards(acts_track.tipIndex(),
879 [&] (
const auto &state) ->
void {
880 if (!state.hasReferenceSurface()) {
889 state.referenceSurface().surfacePlacement());
890 associatedDetEl !=
nullptr) {
891 ATH_MSG_VERBOSE(
"Associated det: "<<associatedDetEl->detectorType());
894 auto flag = state.typeFlags();
899 acts_track.createParametersFromState(state), gctx);
900 std::unique_ptr<Trk::MeasurementBase> trkMeasurement{};
904 if (!m_convertHoles) { return; }
906 }
if (flag.isOutlier()) {
907 if (!m_convertOutliers) { return; }
909 }
if (flag.hasMeasurement()) {
910 typePattern.set(Trk::TrackStateOnSurface::Measurement);
911 nDoF = state.calibratedSize();
914 using enum detail::SourceLinkType;
916 trkMeasurement = m_measCalib.unpack(state.getUncalibratedSourceLink())->uniqueClone();
919 trkMeasurement = m_prdCalib.createROT(gctx, cctx, state.getUncalibratedSourceLink(), state);
921 case xAODUnCalibMeas:
922 appendMeasTSOS(ctx, detail::xAODUncalibMeasCalibrator::unpack(state.getUncalibratedSourceLink()),
923 typePattern, Trk::FitQualityOnSurface{chi2, nDoF},
924 std::move(trkPars), *finalTrajectory);
927 THROW_EXCEPTION(
"Invalid "<<slType<<
" type parsed.");
931 std::move(trkMeasurement),
932 std::move(trkPars),
nullptr, typePattern);
934 ATH_MSG_VERBOSE(
"State succesfully created, adding it to the trajectory");
935 finalTrajectory->insert(finalTrajectory->begin(), std::move(perState));
938 std::unique_ptr<Trk::TrackParameters> per = actsTrackParametersToTrkParameters(ctx, acts_track.createParametersAtReference(), gctx);
939 TrkTSOSMask typePattern;
941 finalTrajectory->insert(finalTrajectory->begin(),
942 std::make_unique<Trk::TrackStateOnSurface>(
nullptr, std::move(per),
nullptr, typePattern));
945 Trk::TrackInfo newInfo{fitAuthor, ParticleHypothesis::convertTrk(acts_track.particleHypothesis())};
946 auto newtrack = std::make_unique<Trk::Track>(newInfo, std::move(finalTrajectory),
nullptr);
947 constexpr bool suppressHoleSearch =
false;
948 m_trkSummaryTool->updateTrackSummary(ctx, *newtrack, suppressHoleSearch);
952 std::unique_ptr<TrackCollection>
955 auto outColl = std::make_unique<TrackCollection>();
956 for (
const ActsTrk::TrackContainer::ConstTrackProxy& trk : trackCont) {
965 std::unique_ptr<Trk::TrackParameters> trkPars,
967 std::unique_ptr<Trk::MeasurementBase> rot{};
968 switch (meas->
type()) {
970 case PixelClusterType: {
971 static const SG::AuxElement::ConstAccessor<ElementLink<InDet::PixelClusterCollection>> acc_pixelLink(
"pixelClusterLink");
972 if (acc_pixelLink.isAvailable(*meas) && acc_pixelLink(*meas).isValid()) {
973 rot.reset(
m_ROTcreator->correct(**acc_pixelLink(*meas), *trkPars, ctx));
976 }
case StripClusterType: {
977 static const SG::AuxElement::ConstAccessor<ElementLink<InDet::SCT_ClusterCollection>> acc_stripLink(
"sctClusterLink");
978 if (acc_stripLink.isAvailable(*meas) && acc_stripLink(*meas).isValid()) {
979 rot.reset(
m_ROTcreator->correct(**acc_stripLink(*meas), *trkPars, ctx));
982 }
case MdtDriftCircleType:
983 case MMClusterType: {
988 assert(prd !=
nullptr);
993 case sTgcStripType: {
1001 if (meas->
type() == RpcStripType) {
1003 prd1 =
fetchPrd(ctx,
m_keyRpc, muonMeas->secondaryStrip()->identify(), modHash);
1004 }
else if (meas->
type() == TgcStripType) {
1006 prd1 =
fetchPrd(ctx,
m_keyTgc, muonMeas->secondaryStrip()->identify(), modHash);
1009 prd1 =
fetchPrd(ctx,
m_keyStgc, muonMeas->secondaryStrip()->identify(), modHash);
1011 assert(prd !=
nullptr);
1012 assert(prd1 !=
nullptr);
1015 const Trk::Surface& phiSurface = prd1->detectorElement()->surface(prd1->identify());
1017 assert(phiPars !=
nullptr);
1018 std::unique_ptr<Trk::MeasurementBase> phiRot{};
1019 if (meas->
type() != sTgcStripType) {
1023 phiRot.reset(
m_ROTcreator->correct(*prd1, *phiPars, ctx));
1026 assert(phiRot !=
nullptr);
1027 states.insert(states.begin(),
1028 std::make_unique<Trk::TrackStateOnSurface>(quality,
1030 std::move(phiPars),
nullptr, typePattern));
1036 assert(prd !=
nullptr);
1052 assert(rot !=
nullptr);
1053 assert(trkPars !=
nullptr);
1054 states.insert(states.begin(),
1055 std::make_unique<Trk::TrackStateOnSurface>(std::move(quality), std::move(rot),
1056 std::move(trkPars),
nullptr, typePattern));
1059 template <
typename PrdType_t>
1064 const PrdType_t* container{
nullptr};
1065 if (key.empty() || !
SG::get(container, key, ctx).isSuccess()) {
1068 const auto* coll = container->indexFindPtr(hash);
1069 if (coll ==
nullptr){
1070 ATH_MSG_WARNING(
"fetchPrd() - Failed to find a valid collection for "<<prdId.
getString()<<
", key: "<<key.fullKey());
1074 if (prd->identify() == prdId) {
Scalar mag() const
mag method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define AmgSymMatrix(dim)
std::pair< std::vector< unsigned int >, bool > res
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
Acts::GeometryContext context() const
base class interface providing the bare minimal interface extension.
: Helper class to connect the aligned transformations of each active sensor(layer) with the Acts::Sur...
Identifier identify() const override final
Returns the identifier of the Surface.
static Acts::SourceLink pack(const Trk::MeasurementBase *meas)
Packs the pointer to the track measurement into an Acts::SouceLink.
Class to calibrate the Acts track states with uncalibrated Trk::PrepRaw data objects.
static Acts::SourceLink pack(const SourceLink_t prd)
Pack the PrepRaw data measurement into a source link.
size_type size() const noexcept
Returns the number of elements in the collection.
This is a "hash" representation of an Identifier.
std::string getString() const
Provide a string form of the identifier - hexadecimal.
std::vector< const MuonReadoutElement * > getAllReadoutElements(const ActsTrk::DetectorType type=ActsTrk::DetectorType::UnDefined) const
Returns all readout elements.
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const MuonReadoutElement * getReadoutElement(const Identifier &id) const
Get any read out element.
Property holding a SG store/key/clid from which a ReadHandle is made.
Bounds for a annulus-like, planar Surface.
Class for a conical surface in the ATLAS detector.
Class for a CylinderSurface in the ATLAS detector.
Class for a DiscSurface in the ATLAS detector.
This class is the pure abstract base class for all fittable tracking measurements.
virtual const Surface & associatedSurface() const =0
Interface method to get the associated Surface.
const Amg::MatrixX & localCovariance() const
Interface method to get the localError.
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
double charge() const
Returns the charge.
virtual const Surface & associatedSurface() const override=0
Access to the Surface associated to the Parameters.
Class describing the Line to which the Perigee refers to.
Class for a planaer rectangular or trapezoidal surface in the ATLAS detector.
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const override final
Specified for PlaneSurface: LocalToGlobal method without dynamic memory allocation.
virtual const TrkDetElementBase * detectorElement() const =0
return the detector element corresponding to this PRD The pointer will be zero if the det el is not d...
Class for a StraightLineSurface in the ATLAS detector to describe dirft tube and straw like detectors...
virtual BoundsType type() const =0
Return the bounds type - for persistency optimization.
Abstract Base Class for tracking surfaces.
virtual MsgStream & dump(MsgStream &sl) const
Output Method for MsgStream, to be overloaded by child classes.
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
Identifier associatedDetectorElementIdentifier() const
return Identifier of the associated Detector Element
virtual constexpr SurfaceType type() const =0
Returns the Surface type to avoid dynamic casts.
virtual const SurfaceBounds & bounds() const =0
Surface Bounds method.
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const =0
Specified by each surface type: LocalToGlobal method without dynamic memory allocation.
Contains information about the 'fitter' of this track.
TrackFitter
enums to identify who created this track and what propertis does it have.
represents the track state (measurement, material, fit parameters and quality) at a surface.
@ Perigee
This represents a perigee, and so will contain a Perigee object only.
@ Outlier
This TSoS contains an outlier, that is, it contains a MeasurementBase/RIO_OnTrack which was not used ...
@ Hole
A hole on the track - this is defined in the following way.
virtual Identifier identify() const =0
Identifier.
virtual const Surface & surface() const =0
Return surface associated with this detector element.
virtual unsigned int numDimensions() const =0
Returns the number of dimensions of the measurement.
virtual xAOD::UncalibMeasType type() const =0
Returns the type of the measurement type as a simple enumeration.
double chi2(TH1 *h0, TH1 *h1)
xAOD::ParticleHypothesis convert(Acts::ParticleHypothesis h)
SourceLinkType
Enumeration to distinguish between the ATLAS EDM -> Acts::SourceLink variants.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
ActsToTrkConverterTool::SurfacePtr_t SurfacePtr_t
DetectorType
Simple enum to Identify the Type of the ACTS sub detector.
@ Mm
Maybe not needed in the migration.
@ Tgc
Resitive Plate Chambers.
@ Rpc
Monitored Drift Tubes.
@ Trt
Maybe the Sct / Pixel for Itk become seperate entries?
Acts::TrackContainer< MutableTrackBackend, MutableTrackStateBackend, Acts::detail::ValueHolder > MutableTrackContainer
Acts::CalibrationContext getCalibrationContext(const EventContext &ctx)
The Acts::Calibration context is piped through the Acts fitters to (re)calibrate the Acts::SourceLink...
static void ActsTrackParameterCheck(const Acts::BoundTrackParameters &actsParameter, const Acts::GeometryContext &gctx, const Acts::BoundMatrix &covpc, const Acts::BoundVector &targetPars, const Acts::BoundMatrix &targetCov, const Trk::PlaneSurface *planeSurface)
static void ActsMeasurementCheck(const Acts::GeometryContext &gctx, const Trk::MeasurementBase &measurement, const Acts::Surface &surface, const Acts::BoundVector &loc)
std::unique_ptr< Trk::TrackParameters > rotateParams(const Trk::TrackParameters &inPars, const Trk::Surface &target)
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
SurfaceType
This enumerator simplifies the persistency & calculations,.
DataVector< const Trk::TrackStateOnSurface > TrackStates
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
ParametersBase< TrackParametersDim, Charged > TrackParameters
MuonMeasurement_v1 MuonMeasurement
UncalibMeasType
Define the type of the uncalibrated measurement.
CombinedMuonStrip_v1 CombinedMuonStrip
UncalibratedMeasurement_v1 UncalibratedMeasurement
Define the version of the uncalibrated measurement class.
#define THROW_EXCEPTION(MESSAGE)