From 39043de9e55f0e21d4d280fc7910719dbad38266 Mon Sep 17 00:00:00 2001 From: jesgum Date: Wed, 1 Jul 2026 11:00:58 +0200 Subject: [PATCH 1/3] Don't copy trackparcov when computing tracklengths --- ALICE3/Core/TrackUtilities.cxx | 4 ++-- ALICE3/Core/TrackUtilities.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ALICE3/Core/TrackUtilities.cxx b/ALICE3/Core/TrackUtilities.cxx index 86b41e6245c..79405c4e0ee 100644 --- a/ALICE3/Core/TrackUtilities.cxx +++ b/ALICE3/Core/TrackUtilities.cxx @@ -48,14 +48,14 @@ void o2::upgrade::convertTLorentzVectorToO2Track(const int charge, new (&o2track)(o2::track::TrackParCov)(x, particle.Phi(), params, covm); } -float o2::upgrade::computeParticleVelocity(float momentum, float mass) +float o2::upgrade::computeParticleVelocity(const float momentum, const float mass) { const float a = momentum / mass; // uses light speed in cm/ps so output is in those units return o2::constants::physics::LightSpeedCm2PS * a / std::sqrt((1.f + a * a)); } -float o2::upgrade::computeTrackLength(o2::track::TrackParCov track, float radius, float magneticField) +float o2::upgrade::computeTrackLength(const o2::track::TrackParCov& track, const float radius, const float magneticField) { // don't make use of the track parametrization float length = -100; diff --git a/ALICE3/Core/TrackUtilities.h b/ALICE3/Core/TrackUtilities.h index 0cdcc5da92b..4c2e288d883 100644 --- a/ALICE3/Core/TrackUtilities.h +++ b/ALICE3/Core/TrackUtilities.h @@ -105,13 +105,13 @@ o2::track::TrackParCov convertMCParticleToO2Track(McParticleType& particle, /// returns velocity in centimeters per picoseconds /// \param momentum the momentum of the track /// \param mass the mass of the particle -float computeParticleVelocity(float momentum, float mass); +float computeParticleVelocity(const float momentum, const float mass); /// function to calculate track length of this track up to a certain radius /// \param track the input track (TrackParCov) /// \param radius the radius of the layer you're calculating the length to /// \param magneticField the magnetic field to use when propagating -float computeTrackLength(o2::track::TrackParCov track, float radius, float magneticField); +float computeTrackLength(const o2::track::TrackParCov& track, const float radius, const float magneticField); } // namespace o2::upgrade From a4f205702636809eabb1ed83d0b5e7c76a6bdb20 Mon Sep 17 00:00:00 2001 From: jesgum Date: Wed, 1 Jul 2026 11:26:32 +0200 Subject: [PATCH 2/3] More const --- ALICE3/Core/TrackUtilities.cxx | 4 ++-- ALICE3/Core/TrackUtilities.h | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ALICE3/Core/TrackUtilities.cxx b/ALICE3/Core/TrackUtilities.cxx index 79405c4e0ee..3e52e4367af 100644 --- a/ALICE3/Core/TrackUtilities.cxx +++ b/ALICE3/Core/TrackUtilities.cxx @@ -29,8 +29,8 @@ #include void o2::upgrade::convertTLorentzVectorToO2Track(const int charge, - const TLorentzVector particle, - const std::vector productionVertex, + const TLorentzVector& particle, + const std::vector& productionVertex, o2::track::TrackParCov& o2track) { std::array params; diff --git a/ALICE3/Core/TrackUtilities.h b/ALICE3/Core/TrackUtilities.h index 4c2e288d883..f591cd05d0f 100644 --- a/ALICE3/Core/TrackUtilities.h +++ b/ALICE3/Core/TrackUtilities.h @@ -36,8 +36,8 @@ namespace o2::upgrade /// \param productionVertex where the particle was produced /// \param o2track the address of the resulting TrackParCov void convertTLorentzVectorToO2Track(const int charge, - const TLorentzVector particle, - const std::vector productionVertex, + const TLorentzVector& particle, + const std::vector& productionVertex, o2::track::TrackParCov& o2track); /// Function to convert a TLorentzVector into a perfect Track @@ -47,9 +47,9 @@ void convertTLorentzVectorToO2Track(const int charge, /// \param o2track the address of the resulting TrackParCov /// \param pdg the pdg service template -void convertTLorentzVectorToO2Track(int pdgCode, - TLorentzVector particle, - std::vector productionVertex, +void convertTLorentzVectorToO2Track(const int pdgCode, + const TLorentzVector& particle, + const std::vector& productionVertex, o2::track::TrackParCov& o2track, const PdgService& pdg) { @@ -80,7 +80,7 @@ void convertOTFParticleToO2Track(const OTFParticle& particle, /// \param o2track the address of the resulting TrackParCov /// \param pdg the pdg service template -void convertMCParticleToO2Track(McParticleType& particle, +void convertMCParticleToO2Track(const McParticleType& particle, o2::track::TrackParCov& o2track, const PdgService& pdg) { @@ -94,7 +94,7 @@ void convertMCParticleToO2Track(McParticleType& particle, /// \param o2track the address of the resulting TrackParCov /// \param pdg the pdg service template -o2::track::TrackParCov convertMCParticleToO2Track(McParticleType& particle, +o2::track::TrackParCov convertMCParticleToO2Track(const McParticleType& particle, const PdgService& pdg) { o2::track::TrackParCov o2track; From ef72ddbecb7b7501bc654cfa5e5abcc8aff46e23 Mon Sep 17 00:00:00 2001 From: jesgum Date: Mon, 6 Jul 2026 15:18:37 +0200 Subject: [PATCH 3/3] Code checker fixes --- ALICE3/Core/TrackUtilities.cxx | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ALICE3/Core/TrackUtilities.cxx b/ALICE3/Core/TrackUtilities.cxx index 3e52e4367af..0b4d1dc08f7 100644 --- a/ALICE3/Core/TrackUtilities.cxx +++ b/ALICE3/Core/TrackUtilities.cxx @@ -33,9 +33,9 @@ void o2::upgrade::convertTLorentzVectorToO2Track(const int charge, const std::vector& productionVertex, o2::track::TrackParCov& o2track) { - std::array params; + std::array params = {0.}; std::array covm = {0.}; - float s, c, x; + float s{}, c{}, x{}; o2::math_utils::sincos(static_cast(particle.Phi()), s, c); o2::math_utils::rotateZInv(static_cast(productionVertex[0]), static_cast(productionVertex[1]), x, params[0], s, c); params[1] = static_cast(productionVertex[2]); @@ -61,7 +61,7 @@ float o2::upgrade::computeTrackLength(const o2::track::TrackParCov& track, const float length = -100; o2::math_utils::CircleXYf_t trcCircle; - float sna, csa; + float sna{}, csa{}; track.getCircleParams(magneticField, trcCircle, sna, csa); // distance between circle centers (one circle is at origin -> easy) @@ -69,8 +69,6 @@ float o2::upgrade::computeTrackLength(const o2::track::TrackParCov& track, const // condition of circles touching - if not satisfied returned length will be -100 if (centerDistance < trcCircle.rC + radius && centerDistance > std::fabs(trcCircle.rC - radius)) { - length = 0.0f; - // base radical direction const float ux = trcCircle.xC / centerDistance; const float uy = trcCircle.yC / centerDistance; @@ -87,17 +85,17 @@ float o2::upgrade::computeTrackLength(const o2::track::TrackParCov& track, const (centerDistance + trcCircle.rC + radius)); // possible intercept points of track and TOF layer in 2D plane - const float point1[2] = {radical * ux + displace * vx, radical * uy + displace * vy}; - const float point2[2] = {radical * ux - displace * vx, radical * uy - displace * vy}; + const std::array point1 = {radical * ux + displace * vx, radical * uy + displace * vy}; + const std::array point2 = {radical * ux - displace * vx, radical * uy - displace * vy}; // decide on correct intercept point - std::array mom; + std::array mom{}; track.getPxPyPzGlo(mom); const float scalarProduct1 = point1[0] * mom[0] + point1[1] * mom[1]; const float scalarProduct2 = point2[0] * mom[0] + point2[1] * mom[1]; // get start point - std::array startPoint; + std::array startPoint{}; track.getXYZGlo(startPoint); float cosAngle = -1000, modulus = -1000;