From 430542a0764b3cc35fb2ef221e7cf3240e1f9e09 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Thu, 31 Oct 2024 11:42:45 +0100 Subject: [PATCH 1/3] feat: Estimate parameters on surface also if bottom SP is not on surface --- .../Seeding/EstimateTrackParamsFromSeed.hpp | 81 +++++++++++++++---- 1 file changed, 67 insertions(+), 14 deletions(-) diff --git a/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp b/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp index f3850e102ce..9a2dd06530a 100644 --- a/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp +++ b/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp @@ -10,7 +10,15 @@ #include "Acts/Definitions/TrackParametrization.hpp" #include "Acts/Definitions/Units.hpp" +#include "Acts/EventData/ParticleHypothesis.hpp" +#include "Acts/EventData/TrackParameters.hpp" #include "Acts/Geometry/GeometryContext.hpp" +#include "Acts/MagneticField/ConstantBField.hpp" +#include "Acts/MagneticField/MagneticFieldContext.hpp" +#include "Acts/Propagator/ActorList.hpp" +#include "Acts/Propagator/EigenStepper.hpp" +#include "Acts/Propagator/Propagator.hpp" +#include "Acts/Propagator/VoidNavigator.hpp" #include "Acts/Surfaces/Surface.hpp" #include "Acts/Utilities/Logger.hpp" #include "Acts/Utilities/MathHelpers.hpp" @@ -19,6 +27,7 @@ #include #include #include +#include #include namespace Acts { @@ -249,34 +258,78 @@ std::optional estimateTrackParamsFromSeed( // Transform it back to the original frame Vector3 direction = rotation * transDirection.normalized(); - // Initialize the bound parameters vector - BoundVector params = BoundVector::Zero(); + // The estimated q/pt in [GeV/c]^-1 (note that the pt is the projection of + // momentum on the transverse plane of the new frame) + ActsScalar qOverPt = sign * (UnitConstants::m) / (0.3 * bFieldInTesla * R); - // The estimated phi and theta - params[eBoundPhi] = VectorHelpers::phi(direction); - params[eBoundTheta] = VectorHelpers::theta(direction); + Vector4 parameterOrigin(spGlobalPositions[0].x(), spGlobalPositions[0].y(), + spGlobalPositions[0].z(), + spGlobalTimes[0].value_or(0.)); // Transform the bottom space point to local coordinates of the provided // surface - auto lpResult = surface.globalToLocal(gctx, spGlobalPositions[0], direction); + auto lpResult = + surface.globalToLocal(gctx, parameterOrigin.head<3>(), direction); if (!lpResult.ok()) { - ACTS_ERROR( - "Global to local transformation did not succeed. Please make sure the " - "bottom space point lies on the provided surface."); - return std::nullopt; + // no cov transport matrix is needed here + // particle hypothesis does not matter here + CurvilinearTrackParameters estimatedParams(parameterOrigin, direction, + qOverPt, std::nullopt, + ParticleHypothesis::pion()); + + auto surfaceIntersection = + surface.intersect(gctx, parameterOrigin.head<3>(), direction).closest(); + + if (!surfaceIntersection.isValid()) { + ACTS_INFO( + "The surface does not intersect with the origin and estimated " + "direction."); + return std::nullopt; + } + + Direction propagatorDirection = + Direction::fromScalarZeroAsPositive(surfaceIntersection.pathLength()); + + Propagator propagator( + EigenStepper<>(std::make_shared(bField)), + VoidNavigator(), logger().cloneWithSuffix("Propagator")); + MagneticFieldContext mctx; + auto propagatorOptions = decltype(propagator)::Options<>(gctx, mctx); + propagatorOptions.direction = propagatorDirection; + + auto result = + propagator.propagate(estimatedParams, surface, propagatorOptions); + + if (!result.ok()) { + ACTS_INFO("The propagation failed."); + return std::nullopt; + } + if (!result.value().endParameters.has_value()) { + ACTS_INFO("The propagation did not reach the surface."); + return std::nullopt; + } + + return result.value().endParameters.value().parameters(); } + Vector2 bottomLocalPos = lpResult.value(); + + // Initialize the bound parameters vector + BoundVector params = BoundVector::Zero(); + // The estimated loc0 and loc1 params[eBoundLoc0] = bottomLocalPos.x(); params[eBoundLoc1] = bottomLocalPos.y(); - params[eBoundTime] = spGlobalTimes[0].value_or(0.); - // The estimated q/pt in [GeV/c]^-1 (note that the pt is the projection of - // momentum on the transverse plane of the new frame) - ActsScalar qOverPt = sign * (UnitConstants::m) / (0.3 * bFieldInTesla * R); + // The estimated phi and theta + params[eBoundPhi] = VectorHelpers::phi(direction); + params[eBoundTheta] = VectorHelpers::theta(direction); + // The estimated q/p in [GeV/c]^-1 params[eBoundQOverP] = qOverPt / fastHypot(1., invTanTheta); + params[eBoundTime] = spGlobalTimes[0].value_or(0.); + if (params.hasNaN()) { ACTS_ERROR( "The NaN value exists at the estimated track parameters from seed with" From cf1dcf2603fa171443edc0d0b3280cbd8bea197e Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Thu, 31 Oct 2024 11:52:44 +0100 Subject: [PATCH 2/3] fix --- Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp b/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp index 9a2dd06530a..7e82839061b 100644 --- a/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp +++ b/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp @@ -294,7 +294,8 @@ std::optional estimateTrackParamsFromSeed( EigenStepper<>(std::make_shared(bField)), VoidNavigator(), logger().cloneWithSuffix("Propagator")); MagneticFieldContext mctx; - auto propagatorOptions = decltype(propagator)::Options<>(gctx, mctx); + auto propagatorOptions = + decltype(propagator)::template Options<>(gctx, mctx); propagatorOptions.direction = propagatorDirection; auto result = From 5a9eb62c0f0690746355cf144b73fb5089ef3969 Mon Sep 17 00:00:00 2001 From: Andreas Stefl Date: Thu, 31 Oct 2024 14:53:50 +0100 Subject: [PATCH 3/3] fix? --- Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp b/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp index 7e82839061b..1ea07eda8c8 100644 --- a/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp +++ b/Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp @@ -295,7 +295,7 @@ std::optional estimateTrackParamsFromSeed( VoidNavigator(), logger().cloneWithSuffix("Propagator")); MagneticFieldContext mctx; auto propagatorOptions = - decltype(propagator)::template Options<>(gctx, mctx); + typename decltype(propagator)::template Options<>(gctx, mctx); propagatorOptions.direction = propagatorDirection; auto result =