Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Estimate parameters on surface also if bottom SP is not on surface #3800

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 68 additions & 14 deletions Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -19,6 +27,7 @@
#include <cmath>
#include <iostream>
#include <iterator>
#include <memory>
#include <optional>

namespace Acts {
Expand Down Expand Up @@ -249,34 +258,79 @@ std::optional<BoundVector> 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<ConstantBField>(bField)),
VoidNavigator(), logger().cloneWithSuffix("Propagator"));
MagneticFieldContext mctx;
auto propagatorOptions =
typename decltype(propagator)::template 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"
Expand Down
Loading