Skip to content

Commit 20c398d

Browse files
committed
ITS: simplify constants
1 parent 5532a58 commit 20c398d

File tree

13 files changed

+58
-187
lines changed

13 files changed

+58
-187
lines changed

Detectors/ITSMFT/ITS/tracking/GPU/cuda/TrackingKernels.cu

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ using namespace o2::track;
5353

5454
namespace o2::its
5555
{
56-
using namespace constants::its2;
5756
using Vertex = o2::dataformats::Vertex<o2::dataformats::TimeStamp<int>>;
5857

5958
GPUdii() float Sq(float v)
@@ -392,8 +391,8 @@ GPUg() void computeLayerCellsKernel(
392391
const float cellDeltaTanLambdaSigma,
393392
const float nSigmaCut)
394393
{
395-
constexpr float radl = 9.36f; // Radiation length of Si [cm].
396-
constexpr float rho = 2.33f; // Density of Si [g/cm^3].
394+
constexpr float constants::Radl = 9.36f; // Radiation length of Si [cm].
395+
constexpr float constants::Rho = 2.33f; // Density of Si [g/cm^3].
397396
constexpr float layerxX0[7] = {5.e-3f, 5.e-3f, 5.e-3f, 1.e-2f, 1.e-2f, 1.e-2f, 1.e-2f}; // Hardcoded here for the moment.
398397
for (int iCurrentTrackletIndex = blockIdx.x * blockDim.x + threadIdx.x; iCurrentTrackletIndex < nTrackletsCurrent; iCurrentTrackletIndex += blockDim.x * gridDim.x) {
399398
const Tracklet& currentTracklet = tracklets[layer][iCurrentTrackletIndex];
@@ -432,7 +431,7 @@ GPUg() void computeLayerCellsKernel(
432431
break;
433432
}
434433

435-
if (!track.correctForMaterial(layerxX0[layer + iC], layerxX0[layer] * radl * rho, true)) {
434+
if (!track.correctForMaterial(layerxX0[layer + iC], layerxX0[layer] * constants::Radl * constants::Rho, true)) {
436435
break;
437436
}
438437

@@ -604,8 +603,6 @@ GPUg() void processNeighboursKernel(const int layer,
604603
const o2::base::Propagator* propagator,
605604
const o2::base::PropagatorF::MatCorrType matCorrType)
606605
{
607-
constexpr float radl = 9.36f; // Radiation length of Si [cm].
608-
constexpr float rho = 2.33f; // Density of Si [g/cm^3].
609606
constexpr float layerxX0[7] = {5.e-3f, 5.e-3f, 5.e-3f, 1.e-2f, 1.e-2f, 1.e-2f, 1.e-2f}; // Hardcoded here for the moment.
610607
for (unsigned int iCurrentCell = blockIdx.x * blockDim.x + threadIdx.x; iCurrentCell < nCurrentCells; iCurrentCell += blockDim.x * gridDim.x) {
611608
int foundSeeds{0};
@@ -648,7 +645,7 @@ GPUg() void processNeighboursKernel(const int layer,
648645
}
649646

650647
if (matCorrType == o2::base::PropagatorF::MatCorrType::USEMatCorrNONE) {
651-
if (!seed.correctForMaterial(layerxX0[layer - 1], layerxX0[layer - 1] * radl * rho, true)) {
648+
if (!seed.correctForMaterial(layerxX0[layer - 1], layerxX0[layer - 1] * constants::Radl * constants::Rho, true)) {
652649
continue;
653650
}
654651
}

Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ class Configuration : public Param
5858
};
5959

6060
struct TrackingParameters {
61-
int CellMinimumLevel() { return MinTrackLength - constants::its::ClustersPerCell + 1; }
62-
int CellsPerRoad() const { return NLayers - 2; }
63-
int TrackletsPerRoad() const { return NLayers - 1; }
61+
int CellMinimumLevel() const noexcept { return MinTrackLength - constants::ClustersPerCell + 1; }
62+
int CellsPerRoad() const noexcept { return NLayers - 2; }
63+
int TrackletsPerRoad() const noexcept { return NLayers - 1; }
6464
std::string asString() const;
6565

6666
int NLayers = 7;

Detectors/ITSMFT/ITS/tracking/include/ITStracking/Constants.h

Lines changed: 7 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -17,112 +17,24 @@
1717
#define TRACKINGITSU_INCLUDE_CONSTANTS_H_
1818

1919
#include "ITStracking/Definitions.h"
20-
#include "CommonConstants/MathConstants.h"
2120

22-
#include "GPUCommonMath.h"
23-
#include "GPUCommonDef.h"
24-
25-
#ifndef GPUCA_GPUCODE_DEVICE
26-
#include <climits>
27-
#include <vector>
28-
#include <array>
29-
#endif
30-
31-
namespace o2
32-
{
33-
namespace its
34-
{
35-
36-
namespace constants
21+
namespace o2::its::constants
3722
{
3823
constexpr float MB = 1024.f * 1024.f;
3924
constexpr float GB = 1024.f * 1024.f * 1024.f;
4025
constexpr bool DoTimeBenchmarks = true;
4126
constexpr bool SaveTimeBenchmarks = false;
4227

43-
namespace math
44-
{
45-
constexpr float Pi{3.14159265359f};
46-
constexpr float TwoPi{2.0f * Pi};
47-
constexpr float FloatMinThreshold{1e-20f};
48-
} // namespace math
49-
50-
namespace its
51-
{
52-
constexpr int LayersNumberVertexer{3};
5328
constexpr int ClustersPerCell{3};
5429
constexpr int UnusedIndex{-1};
5530
constexpr float Resolution{0.0005f};
56-
57-
GPUhdi() constexpr std::array<float, 3> VertexerHistogramVolume()
58-
{
59-
return std::array<float, 3>{{1.98, 1.98, 40.f}};
60-
}
61-
} // namespace its
62-
63-
namespace its2
64-
{
65-
constexpr int LayersNumber{7};
66-
constexpr int TrackletsPerRoad{LayersNumber - 1};
67-
constexpr int CellsPerRoad{LayersNumber - 2};
68-
69-
GPUhdi() constexpr std::array<float, LayersNumber> LayersZCoordinate()
70-
{
71-
constexpr double s = 1.; // safety margin
72-
return std::array<float, LayersNumber>{16.333f + s, 16.333f + s, 16.333f + s, 42.140f + s, 42.140f + s, 73.745f + s, 73.745f + s};
73-
}
74-
75-
GPUhdi() constexpr std::array<float, LayersNumber> LayersRCoordinate()
31+
constexpr float Radl = 9.36f; // Radiation length of Si [cm]
32+
constexpr float Rho = 2.33f; // Density of Si [g/cm^3]
33+
namespace its // to be removed
7634
{
77-
return std::array<float, LayersNumber>{{2.33959f, 3.14076f, 3.91924f, 19.6213f, 24.5597f, 34.388f, 39.3329f}};
78-
}
79-
80-
constexpr int ZBins{256};
81-
constexpr int PhiBins{128};
82-
constexpr float InversePhiBinSize{PhiBins / constants::math::TwoPi};
83-
GPUhdi() constexpr std::array<float, LayersNumber> InverseZBinSize()
84-
{
85-
constexpr auto zSize = LayersZCoordinate();
86-
return std::array<float, LayersNumber>{0.5f * ZBins / (zSize[0]), 0.5f * ZBins / (zSize[1]), 0.5f * ZBins / (zSize[2]),
87-
0.5f * ZBins / (zSize[3]), 0.5f * ZBins / (zSize[4]), 0.5f * ZBins / (zSize[5]),
88-
0.5f * ZBins / (zSize[6])};
89-
}
90-
91-
GPUhdi() constexpr float getInverseZCoordinate(const int layerIndex)
92-
{
93-
return 0.5f * ZBins / LayersZCoordinate()[layerIndex];
94-
}
95-
96-
GPUhdi() int getZBinIndex(const int layerIndex, const float zCoordinate)
97-
{
98-
return (zCoordinate + LayersZCoordinate()[layerIndex]) *
99-
InverseZBinSize()[layerIndex];
100-
}
101-
102-
GPUhdi() int getPhiBinIndex(const float currentPhi)
103-
{
104-
return (currentPhi * InversePhiBinSize);
105-
}
106-
107-
GPUhdi() int getBinIndex(const int zIndex, const int phiIndex)
108-
{
109-
return o2::gpu::GPUCommonMath::Min(phiIndex * ZBins + zIndex,
110-
ZBins * PhiBins - 1);
111-
}
112-
113-
GPUhdi() constexpr int4 getEmptyBinsRect() { return int4{0, 0, 0, 0}; }
114-
115-
} // namespace its2
116-
117-
namespace pdgcodes
118-
{
119-
constexpr int PionCode{211};
120-
}
121-
} // namespace constants
122-
#ifndef GPUCA_GPUCODE_DEVICE
123-
typedef std::vector<std::vector<int>> index_table_t;
124-
#endif
35+
constexpr int UnusedIndex{-1};
36+
constexpr float Resolution{0.0005f};
12537
} // namespace its
126-
} // namespace o2
38+
} // namespace o2::its::constants
12739

12840
#endif /* TRACKINGITSU_INCLUDE_CONSTANTS_H_ */

Detectors/ITSMFT/ITS/tracking/include/ITStracking/IndexTableUtils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
#ifndef TRACKINGITSU_INCLUDE_INDEXTABLEUTILS_H_
1717
#define TRACKINGITSU_INCLUDE_INDEXTABLEUTILS_H_
1818

19-
#include "ITStracking/Constants.h"
2019
#include "ITStracking/Configuration.h"
2120
#include "ITStracking/Definitions.h"
21+
#include "CommonConstants/MathConstants.h"
2222
#include "GPUCommonMath.h"
2323
#include "GPUCommonDef.h"
2424

@@ -55,7 +55,7 @@ class IndexTableUtils
5555
template <class T>
5656
inline void IndexTableUtils::setTrackingParameters(const T& params)
5757
{
58-
mInversePhiBinSize = params.PhiBins / constants::math::TwoPi;
58+
mInversePhiBinSize = params.PhiBins / o2::constants::math::TwoPI;
5959
mNzBins = params.ZBins;
6060
mNphiBins = params.PhiBins;
6161
for (int iLayer{0}; iLayer < params.LayerZ.size(); ++iLayer) {

Detectors/ITSMFT/ITS/tracking/include/ITStracking/MathUtils.h

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,61 +16,38 @@
1616
#ifndef TRACKINGITSU_INCLUDE_CAUTILS_H_
1717
#define TRACKINGITSU_INCLUDE_CAUTILS_H_
1818

19-
#ifndef GPUCA_GPUCODE_DEVICE
20-
#include <array>
21-
#include <cmath>
22-
#include <cassert>
23-
#include <iostream>
24-
#endif
25-
19+
#include "CommonConstants/MathConstants.h"
2620
#include "MathUtils/Utils.h"
27-
#include "ITStracking/Constants.h"
2821
#include "GPUCommonMath.h"
2922
#include "GPUCommonDef.h"
3023

31-
namespace o2
32-
{
33-
namespace its
34-
{
35-
36-
namespace math_utils
24+
namespace o2::its::math_utils
3725
{
38-
GPUhdni() float computePhi(const float, const float);
39-
GPUhdni() float hypot(const float, const float);
40-
GPUhdni() constexpr float getNormalizedPhi(const float);
41-
GPUhdni() constexpr float3 crossProduct(const float3&, const float3&);
42-
GPUhdni() float computeCurvature(float x1, float y1, float x2, float y2, float x3, float y3);
43-
GPUhdni() float computeCurvatureCentreX(float x1, float y1, float x2, float y2, float x3, float y3);
44-
GPUhdni() float computeTanDipAngle(float x1, float y1, float x2, float y2, float z1, float z2);
45-
46-
} // namespace math_utils
4726

48-
GPUhdi() float math_utils::computePhi(const float x, const float y)
27+
GPUhdi() float computePhi(const float x, const float y)
4928
{
50-
//return o2::gpu::CAMath::ATan2(-yCoordinate, -xCoordinate) + constants::math::Pi;
51-
return o2::math_utils::fastATan2(-y, -x) + constants::math::Pi;
29+
return o2::math_utils::fastATan2(-y, -x) + o2::constants::math::PI;
5230
}
5331

54-
GPUhdi() float math_utils::hypot(const float x, const float y)
32+
GPUhdi() float hypot(const float x, const float y)
5533
{
5634
return o2::gpu::CAMath::Sqrt(x * x + y * y);
5735
}
5836

59-
GPUhdi() constexpr float math_utils::getNormalizedPhi(const float phi)
37+
GPUhdi() constexpr float getNormalizedPhi(const float phi)
6038
{
61-
return (phi < 0) ? phi + constants::math::TwoPi : (phi > constants::math::TwoPi) ? phi - constants::math::TwoPi
62-
: phi;
39+
return (phi < 0) ? phi + o2::constants::math::TwoPI : (phi > o2::constants::math::TwoPI) ? phi - o2::constants::math::TwoPI
40+
: phi;
6341
}
6442

65-
GPUhdi() constexpr float3 math_utils::crossProduct(const float3& firstVector, const float3& secondVector)
43+
GPUhdi() constexpr float3 crossProduct(const float3& firstVector, const float3& secondVector)
6644
{
67-
6845
return float3{(firstVector.y * secondVector.z) - (firstVector.z * secondVector.y),
6946
(firstVector.z * secondVector.x) - (firstVector.x * secondVector.z),
7047
(firstVector.x * secondVector.y) - (firstVector.y * secondVector.x)};
7148
}
7249

73-
GPUhdi() float math_utils::computeCurvature(float x1, float y1, float x2, float y2, float x3, float y3)
50+
GPUhdi() float computeCurvature(float x1, float y1, float x2, float y2, float x3, float y3)
7451
{
7552
const float d = (x2 - x1) * (y3 - y2) - (x3 - x2) * (y2 - y1);
7653
const float a =
@@ -81,7 +58,7 @@ GPUhdi() float math_utils::computeCurvature(float x1, float y1, float x2, float
8158
return den2 > 0.f ? -1.f * d / o2::gpu::CAMath::Sqrt(den2) : 0.f;
8259
}
8360

84-
GPUhdi() float math_utils::computeCurvatureCentreX(float x1, float y1, float x2, float y2, float x3, float y3)
61+
GPUhdi() float computeCurvatureCentreX(float x1, float y1, float x2, float y2, float x3, float y3)
8562
{
8663
float dx21 = x2 - x1, dx32 = x3 - x2;
8764
if (dx21 == 0.f || dx32 == 0.f) { // add small offset
@@ -93,12 +70,11 @@ GPUhdi() float math_utils::computeCurvatureCentreX(float x1, float y1, float x2,
9370
return (k1 != k2) ? 0.5f * (k1 * k2 * (y1 - y3) + k2 * (x1 + x2) - k1 * (x2 + x3)) / (k2 - k1) : 1e5;
9471
}
9572

96-
GPUhdi() float math_utils::computeTanDipAngle(float x1, float y1, float x2, float y2, float z1, float z2)
73+
GPUhdi() float computeTanDipAngle(float x1, float y1, float x2, float y2, float z1, float z2)
9774
{
9875
return (z1 - z2) / o2::gpu::CAMath::Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
9976
}
10077

101-
} // namespace its
102-
} // namespace o2
78+
} // namespace o2::its::math_utils
10379

10480
#endif /* TRACKINGITSU_INCLUDE_CAUTILS_H_ */

Detectors/ITSMFT/ITS/tracking/include/ITStracking/Road.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,22 @@ class Road final
3838
GPUhd() void resetRoad()
3939
{
4040
for (int i = 0; i < maxRoadSize; i++) {
41-
mCellIds[i] = constants::its::UnusedIndex;
41+
mCellIds[i] = constants::UnusedIndex;
4242
}
4343
mRoadSize = 0;
4444
}
4545

4646
GPUhd() void addCell(int cellLayer, int cellId)
4747
{
48-
if (mCellIds[cellLayer] == constants::its::UnusedIndex) {
48+
if (mCellIds[cellLayer] == constants::UnusedIndex) {
4949
++mRoadSize;
5050
}
5151

5252
mCellIds[cellLayer] = cellId;
5353
}
5454

5555
private:
56-
int mCellIds[maxRoadSize]{constants::its::UnusedIndex};
56+
int mCellIds[maxRoadSize]{constants::UnusedIndex};
5757
// int mLabel;
5858
unsigned char mRoadSize{0};
5959
bool mIsFakeRoad{false};

Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraits.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ template <int nLayers>
113113
inline const int4 TrackerTraits<nLayers>::getBinsRect(const int layerIndex, float phi, float maxdeltaphi, float z1, float z2, float maxdeltaz) const noexcept
114114
{
115115
const float zRangeMin = o2::gpu::GPUCommonMath::Min(z1, z2) - maxdeltaz;
116-
const float phiRangeMin = (maxdeltaphi > constants::math::Pi) ? 0.f : phi - maxdeltaphi;
116+
const float phiRangeMin = (maxdeltaphi > o2::constants::math::PI) ? 0.f : phi - maxdeltaphi;
117117
const float zRangeMax = o2::gpu::GPUCommonMath::Max(z1, z2) + maxdeltaz;
118-
const float phiRangeMax = (maxdeltaphi > constants::math::Pi) ? constants::math::TwoPi : phi + maxdeltaphi;
118+
const float phiRangeMax = (maxdeltaphi > o2::constants::math::PI) ? o2::constants::math::TwoPI : phi + maxdeltaphi;
119119

120120
if (zRangeMax < -mTrkParams[0].LayerZ[layerIndex] ||
121121
zRangeMin > mTrkParams[0].LayerZ[layerIndex] || zRangeMin > zRangeMax) {

Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ class MCCompLabel;
4141

4242
namespace its
4343
{
44-
class ROframe;
45-
using constants::its::LayersNumberVertexer;
4644

4745
enum class TrackletMode {
4846
Layer0Layer1 = 0,

Detectors/ITSMFT/ITS/tracking/src/Smoother.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Smoother<D>::Smoother(TrackITSExt& track, size_t smoothingLayer, const ROframe&
5050
//////////////////////
5151
// Outward propagation
5252
for (size_t iLayer{0}; iLayer < mLayerToSmooth; ++iLayer) {
53-
if (mOutwardsTrack.getClusterIndex(iLayer) == constants::its::UnusedIndex) { // Shorter tracks
53+
if (mOutwardsTrack.getClusterIndex(iLayer) == constants::UnusedIndex) { // Shorter tracks
5454
continue;
5555
}
5656
const TrackingFrameInfo& tF = event.getTrackingFrameInfoOnLayer(iLayer).at(mOutwardsTrack.getClusterIndex(iLayer));
@@ -78,7 +78,7 @@ Smoother<D>::Smoother(TrackITSExt& track, size_t smoothingLayer, const ROframe&
7878
/////////////////////
7979
// Inward propagation
8080
for (size_t iLayer{D - 1}; iLayer > mLayerToSmooth; --iLayer) {
81-
if (mInwardsTrack.getClusterIndex(iLayer) == constants::its::UnusedIndex) { // Shorter tracks
81+
if (mInwardsTrack.getClusterIndex(iLayer) == constants::UnusedIndex) { // Shorter tracks
8282
continue;
8383
}
8484
const TrackingFrameInfo& tF = event.getTrackingFrameInfoOnLayer(iLayer).at(mInwardsTrack.getClusterIndex(iLayer));

Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ void TimeFrame<nLayers>::initialise(const int iteration, const TrackingParameter
375375
const float cosTheta2half = o2::gpu::CAMath::Sqrt(1.f - Sq(0.5f * r2 * oneOverR));
376376
float x = r2 * cosTheta1half - r1 * cosTheta2half;
377377
float delta = o2::gpu::CAMath::Sqrt(1.f / (1.f - 0.25f * Sq(x * oneOverR)) * (Sq(0.25f * r1 * r2 * Sq(oneOverR) / cosTheta2half + cosTheta1half) * Sq(res1) + Sq(0.25f * r1 * r2 * Sq(oneOverR) / cosTheta1half + cosTheta2half) * Sq(res2)));
378-
mPhiCuts[iLayer] = std::min(o2::gpu::CAMath::ASin(0.5f * x * oneOverR) + 2.f * mMSangles[iLayer] + delta, constants::math::Pi * 0.5f);
378+
mPhiCuts[iLayer] = std::min(o2::gpu::CAMath::ASin(0.5f * x * oneOverR) + 2.f * mMSangles[iLayer] + delta, o2::constants::math::PI * 0.5f);
379379
}
380380
}
381381

0 commit comments

Comments
 (0)