From 696d06e53c31885384f0de158edef3f8329ff846 Mon Sep 17 00:00:00 2001 From: BrieucF Date: Thu, 30 Apr 2026 16:19:06 +0200 Subject: [PATCH] [TrackFit] Generalization for any Bz field direction --- Tracking/components/GenfitTrackFitter.cpp | 10 +++++----- Tracking/src/utils.cpp | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Tracking/components/GenfitTrackFitter.cpp b/Tracking/components/GenfitTrackFitter.cpp index 7482d2cc..7c9cc034 100644 --- a/Tracking/components/GenfitTrackFitter.cpp +++ b/Tracking/components/GenfitTrackFitter.cpp @@ -554,7 +554,7 @@ struct GenfitTrackFitter final this, "RunCalorimeterExtrapolation", true, "If true, the track is extrapolated to the calorimeter surfaces (barrel and endcap)" "and the corresponding track states are stored in the output track." - "This is applied only if a non-zero magnetic field (Bz > 0) is found at the last hit position."}; + "This is applied only if a non-zero magnetic field (|Bz| > 0) is found at the last hit position."}; // ====================== Track Classification ====================== Gaudi::Property m_RadialThresholdPromptTrack{ @@ -598,7 +598,7 @@ struct GenfitTrackFitter final * @return true if the track fit was successful, false otherwise * * @note If the fit fails, the function exits early and no track is added to the output collections. - * @note Calorimeter extrapolation is applied only if a non-zero magnetic field (Bz > 0) is found + * @note Calorimeter extrapolation is applied only if a non-zero magnetic field (|Bz| > 0) is found * at the last hit position. */ bool ProcessTrack(const edm4hep::Track& track, bool LimitHits, int particleHypothesis, @@ -662,7 +662,7 @@ struct GenfitTrackFitter final } } - if (runCalorimeterExtrapolation && Bz > 0) { + if (runCalorimeterExtrapolation && std::abs(Bz) > 0) { FillTrackWithCalorimeterExtrapolation(edm4hep_track, Bz, track_interface.GetCharge(), m_eCalBarrelInnerR, m_eCalBarrelMaxZ, m_eCalEndCapInnerR, m_eCalEndCapOuterR, @@ -697,7 +697,7 @@ struct GenfitTrackFitter final auto edm4hep_track_with_fit = track_interface.GetTrackWithFit_edm4hep(); - if (runCalorimeterExtrapolation && Bz > 0) { + if (runCalorimeterExtrapolation && std::abs(Bz) > 0) { FillTrackWithCalorimeterExtrapolation(edm4hep_track_with_fit, Bz, track_interface.GetCharge(), m_eCalBarrelInnerR, m_eCalBarrelMaxZ, m_eCalEndCapInnerR, @@ -797,4 +797,4 @@ struct GenfitTrackFitter final } }; -DECLARE_COMPONENT(GenfitTrackFitter) \ No newline at end of file +DECLARE_COMPONENT(GenfitTrackFitter) diff --git a/Tracking/src/utils.cpp b/Tracking/src/utils.cpp index bc1254cb..2d77b864 100644 --- a/Tracking/src/utils.cpp +++ b/Tracking/src/utils.cpp @@ -85,7 +85,7 @@ void FillTrackWithCalorimeterExtrapolation(edm4hep::MutableTrack& edm4hep_track, auto trackStateLastHit = edm4hep_track.getTrackStates()[2]; double omega_lastHit = trackStateLastHit.omega; - double pt_lasthit = ConversionUnits::a_lcio * Bz / abs(omega_lastHit); + double pt_lasthit = std::abs(ConversionUnits::a_lcio * Bz / omega_lastHit); double phi_lasthit = trackStateLastHit.phi; double pz_lasthit = trackStateLastHit.tanLambda * pt_lasthit; double px_lasthit = pt_lasthit * std::cos(phi_lasthit); @@ -229,4 +229,4 @@ bool isPositiveSemiDefinite(const TMatrixDSym& M, double tol) { return false; } return true; -} \ No newline at end of file +}