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

refactor!: Remove bFieldMin from estimateTrackParamsFromSeed #3863

Merged
merged 6 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
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
19 changes: 2 additions & 17 deletions Core/include/Acts/Seeding/EstimateTrackParamsFromSeed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

#include <array>
#include <cmath>
#include <iostream>
#include <iterator>
#include <optional>
#include <stdexcept>
Expand Down Expand Up @@ -126,36 +125,21 @@ FreeVector estimateTrackParamsFromSeed(spacepoint_range_t spRange,
/// @param surface is the surface of the bottom space point. The estimated bound
/// track parameters will be represented also at this surface
/// @param bField is the magnetic field vector
/// @param bFieldMin is the minimum magnetic field required to trigger the
/// estimation of q/pt
/// @param logger A logger instance
///
/// @return optional bound parameters
template <typename spacepoint_iterator_t>
std::optional<BoundVector> estimateTrackParamsFromSeed(
const GeometryContext& gctx, spacepoint_iterator_t spBegin,
spacepoint_iterator_t spEnd, const Surface& surface, const Vector3& bField,
ActsScalar bFieldMin, const Acts::Logger& logger = getDummyLogger()) {
const Acts::Logger& logger = getDummyLogger()) {
// Check the number of provided space points
std::size_t numSP = std::distance(spBegin, spEnd);
if (numSP != 3) {
ACTS_ERROR("There should be exactly three space points provided.");
return std::nullopt;
}

// Convert bField to Tesla
ActsScalar bFieldStrength = bField.norm();
// Check if magnetic field is too small
if (bFieldStrength < bFieldMin) {
// @todo shall we use straight-line estimation and use default q/pt in such
// case?
ACTS_WARNING(
"The magnetic field at the bottom space point: B = "
<< bFieldStrength / UnitConstants::T << " T is smaller than |B|_min = "
<< bFieldMin / UnitConstants::T << " T. Estimation is not performed.");
return std::nullopt;
}

// The global positions of the bottom, middle and space points
std::array<Vector3, 3> spGlobalPositions = {Vector3::Zero(), Vector3::Zero(),
Vector3::Zero()};
Expand Down Expand Up @@ -252,6 +236,7 @@ std::optional<BoundVector> estimateTrackParamsFromSeed(
params[eBoundLoc1] = bottomLocalPos.y();
params[eBoundTime] = spGlobalTimes[0].value_or(0.);

ActsScalar bFieldStrength = bField.norm();
// 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 / (bFieldStrength * R);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,16 @@ ProcessCode TrackParamsEstimationAlgorithm::execute(
}
Acts::Vector3 field = *fieldRes;

if (field.norm() < m_cfg.bFieldMin) {
ACTS_WARNING("Magnetic field at seed " << iseed << " is too small "
<< field.norm());
continue;
}

// Estimate the track parameters from seed
auto optParams = Acts::estimateTrackParamsFromSeed(
ctx.geoContext, seed.sp().begin(), seed.sp().end(), *surface, field,
m_cfg.bFieldMin, logger());
logger());
if (!optParams.has_value()) {
ACTS_WARNING("Estimation of track parameters for seed " << iseed
<< " failed.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,21 @@ ProcessCode PrototracksToParameters::execute(
.geometryId();
const auto &surface = *m_cfg.geometry->findSurface(geoId);

auto field = m_cfg.magneticField->getField(
auto fieldRes = m_cfg.magneticField->getField(
{bottomSP->x(), bottomSP->y(), bottomSP->z()}, bCache);
if (!field.ok()) {
ACTS_ERROR("Field lookup error: " << field.error());
if (!fieldRes.ok()) {
ACTS_ERROR("Field lookup error: " << fieldRes.error());
return ProcessCode::ABORT;
}
Acts::Vector3 field = *fieldRes;

if (field.norm() < m_cfg.bFieldMin) {
ACTS_WARNING("Magnetic field at seed is too small " << field.norm());
continue;
}

auto pars = Acts::estimateTrackParamsFromSeed(
ctx.geoContext, seed.sp().begin(), seed.sp().end(), surface, *field,
m_cfg.bFieldMin);
ctx.geoContext, seed.sp().begin(), seed.sp().end(), surface, field);

if (not pars) {
ACTS_WARNING("Skip track because of bad params");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,15 @@

#include "Acts/Definitions/Algebra.hpp"
#include "Acts/Definitions/TrackParametrization.hpp"
#include "Acts/EventData/ParticleHypothesis.hpp"
#include "Acts/Seeding/EstimateTrackParamsFromSeed.hpp"
#include "Acts/Surfaces/PerigeeSurface.hpp"
#include "Acts/Surfaces/Surface.hpp"
#include "Acts/Utilities/Helpers.hpp"
#include "Acts/Utilities/detail/periodic.hpp"
#include "ActsExamples/EventData/SimParticle.hpp"
#include "ActsExamples/EventData/Track.hpp"
#include "ActsExamples/Framework/AlgorithmContext.hpp"
#include "ActsExamples/Framework/RandomNumbers.hpp"
#include "ActsExamples/Utilities/GroupBy.hpp"
#include "ActsExamples/Utilities/Range.hpp"
#include "ActsFatras/EventData/Particle.hpp"

#include <algorithm>
#include <cmath>
#include <ostream>
#include <random>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ BOOST_AUTO_TEST_CASE(trackparameters_estimation_test) {
// Test the bound track parameters estimator
auto fullParamsOpt = estimateTrackParamsFromSeed(
geoCtx, spacePointPtrs.begin(), spacePointPtrs.end(),
*bottomSurface, bField, 0.1_T, *logger);
*bottomSurface, bField, *logger);
BOOST_REQUIRE(fullParamsOpt.has_value());
const auto& estFullParams = fullParamsOpt.value();
BOOST_TEST_INFO(
Expand Down
Loading