Skip to content

Commit 33d951d

Browse files
authored
[ALICE3] Pass trackparcov as reference instead of copy in a3 track utilities (#16886)
1 parent 82863ee commit 33d951d

2 files changed

Lines changed: 20 additions & 22 deletions

File tree

ALICE3/Core/TrackUtilities.cxx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
#include <vector>
3030

3131
void o2::upgrade::convertTLorentzVectorToO2Track(const int charge,
32-
const TLorentzVector particle,
33-
const std::vector<double> productionVertex,
32+
const TLorentzVector& particle,
33+
const std::vector<double>& productionVertex,
3434
o2::track::TrackParCov& o2track)
3535
{
36-
std::array<float, 5> params;
36+
std::array<float, 5> params = {0.};
3737
std::array<float, 15> covm = {0.};
38-
float s, c, x;
38+
float s{}, c{}, x{};
3939
o2::math_utils::sincos(static_cast<float>(particle.Phi()), s, c);
4040
o2::math_utils::rotateZInv(static_cast<float>(productionVertex[0]), static_cast<float>(productionVertex[1]), x, params[0], s, c);
4141
params[1] = static_cast<float>(productionVertex[2]);
@@ -48,29 +48,27 @@ void o2::upgrade::convertTLorentzVectorToO2Track(const int charge,
4848
new (&o2track)(o2::track::TrackParCov)(x, particle.Phi(), params, covm);
4949
}
5050

51-
float o2::upgrade::computeParticleVelocity(float momentum, float mass)
51+
float o2::upgrade::computeParticleVelocity(const float momentum, const float mass)
5252
{
5353
const float a = momentum / mass;
5454
// uses light speed in cm/ps so output is in those units
5555
return o2::constants::physics::LightSpeedCm2PS * a / std::sqrt((1.f + a * a));
5656
}
5757

58-
float o2::upgrade::computeTrackLength(o2::track::TrackParCov track, float radius, float magneticField)
58+
float o2::upgrade::computeTrackLength(const o2::track::TrackParCov& track, const float radius, const float magneticField)
5959
{
6060
// don't make use of the track parametrization
6161
float length = -100;
6262

6363
o2::math_utils::CircleXYf_t trcCircle;
64-
float sna, csa;
64+
float sna{}, csa{};
6565
track.getCircleParams(magneticField, trcCircle, sna, csa);
6666

6767
// distance between circle centers (one circle is at origin -> easy)
6868
const float centerDistance = std::hypot(trcCircle.xC, trcCircle.yC);
6969

7070
// condition of circles touching - if not satisfied returned length will be -100
7171
if (centerDistance < trcCircle.rC + radius && centerDistance > std::fabs(trcCircle.rC - radius)) {
72-
length = 0.0f;
73-
7472
// base radical direction
7573
const float ux = trcCircle.xC / centerDistance;
7674
const float uy = trcCircle.yC / centerDistance;
@@ -87,17 +85,17 @@ float o2::upgrade::computeTrackLength(o2::track::TrackParCov track, float radius
8785
(centerDistance + trcCircle.rC + radius));
8886

8987
// possible intercept points of track and TOF layer in 2D plane
90-
const float point1[2] = {radical * ux + displace * vx, radical * uy + displace * vy};
91-
const float point2[2] = {radical * ux - displace * vx, radical * uy - displace * vy};
88+
const std::array<float, 2> point1 = {radical * ux + displace * vx, radical * uy + displace * vy};
89+
const std::array<float, 2> point2 = {radical * ux - displace * vx, radical * uy - displace * vy};
9290

9391
// decide on correct intercept point
94-
std::array<float, 3> mom;
92+
std::array<float, 3> mom{};
9593
track.getPxPyPzGlo(mom);
9694
const float scalarProduct1 = point1[0] * mom[0] + point1[1] * mom[1];
9795
const float scalarProduct2 = point2[0] * mom[0] + point2[1] * mom[1];
9896

9997
// get start point
100-
std::array<float, 3> startPoint;
98+
std::array<float, 3> startPoint{};
10199
track.getXYZGlo(startPoint);
102100

103101
float cosAngle = -1000, modulus = -1000;

ALICE3/Core/TrackUtilities.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ namespace o2::upgrade
3636
/// \param productionVertex where the particle was produced
3737
/// \param o2track the address of the resulting TrackParCov
3838
void convertTLorentzVectorToO2Track(const int charge,
39-
const TLorentzVector particle,
40-
const std::vector<double> productionVertex,
39+
const TLorentzVector& particle,
40+
const std::vector<double>& productionVertex,
4141
o2::track::TrackParCov& o2track);
4242

4343
/// Function to convert a TLorentzVector into a perfect Track
@@ -47,9 +47,9 @@ void convertTLorentzVectorToO2Track(const int charge,
4747
/// \param o2track the address of the resulting TrackParCov
4848
/// \param pdg the pdg service
4949
template <typename PdgService>
50-
void convertTLorentzVectorToO2Track(int pdgCode,
51-
TLorentzVector particle,
52-
std::vector<double> productionVertex,
50+
void convertTLorentzVectorToO2Track(const int pdgCode,
51+
const TLorentzVector& particle,
52+
const std::vector<double>& productionVertex,
5353
o2::track::TrackParCov& o2track,
5454
const PdgService& pdg)
5555
{
@@ -80,7 +80,7 @@ void convertOTFParticleToO2Track(const OTFParticle& particle,
8080
/// \param o2track the address of the resulting TrackParCov
8181
/// \param pdg the pdg service
8282
template <typename McParticleType, typename PdgService>
83-
void convertMCParticleToO2Track(McParticleType& particle,
83+
void convertMCParticleToO2Track(const McParticleType& particle,
8484
o2::track::TrackParCov& o2track,
8585
const PdgService& pdg)
8686
{
@@ -94,7 +94,7 @@ void convertMCParticleToO2Track(McParticleType& particle,
9494
/// \param o2track the address of the resulting TrackParCov
9595
/// \param pdg the pdg service
9696
template <typename McParticleType, typename PdgService>
97-
o2::track::TrackParCov convertMCParticleToO2Track(McParticleType& particle,
97+
o2::track::TrackParCov convertMCParticleToO2Track(const McParticleType& particle,
9898
const PdgService& pdg)
9999
{
100100
o2::track::TrackParCov o2track;
@@ -105,13 +105,13 @@ o2::track::TrackParCov convertMCParticleToO2Track(McParticleType& particle,
105105
/// returns velocity in centimeters per picoseconds
106106
/// \param momentum the momentum of the track
107107
/// \param mass the mass of the particle
108-
float computeParticleVelocity(float momentum, float mass);
108+
float computeParticleVelocity(const float momentum, const float mass);
109109

110110
/// function to calculate track length of this track up to a certain radius
111111
/// \param track the input track (TrackParCov)
112112
/// \param radius the radius of the layer you're calculating the length to
113113
/// \param magneticField the magnetic field to use when propagating
114-
float computeTrackLength(o2::track::TrackParCov track, float radius, float magneticField);
114+
float computeTrackLength(const o2::track::TrackParCov& track, const float radius, const float magneticField);
115115

116116
} // namespace o2::upgrade
117117

0 commit comments

Comments
 (0)