Skip to content

Commit 43ac34a

Browse files
authored
Merge b5b6da4 into sapling-pr-archive-ktf
2 parents 18133df + b5b6da4 commit 43ac34a

File tree

26 files changed

+1241
-638
lines changed

26 files changed

+1241
-638
lines changed

Common/Constants/include/CommonConstants/PhysicsConstants.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ enum Pdg {
7575
kHyperTriton = 1010010030,
7676
kHyperHydrogen4 = 1010010040,
7777
kHyperHelium4 = 1010020040,
78-
kHyperHelium5 = 1010020050
78+
kHyperHelium5 = 1010020050,
79+
kHyperHelium4Sigma = 1110020040
7980
};
8081

8182
/// \brief Declarations of masses for additional particles
@@ -124,6 +125,7 @@ constexpr double MassHyperTriton = 2.99131;
124125
constexpr double MassHyperHydrogen4 = 3.9226;
125126
constexpr double MassHyperHelium4 = 3.9217;
126127
constexpr double MassHyperHelium5 = 4.841;
128+
constexpr double MassHyperHelium4Sigma = 3.995;
127129

128130
/// \brief Declarations of masses for particles in ROOT PDG_t
129131
constexpr double MassDown = 0.00467;
@@ -194,6 +196,7 @@ constexpr double MassKaonNeutral = MassK0;
194196
constexpr double MassLambda = MassLambda0;
195197
constexpr double MassHyperhydrog4 = MassHyperHydrogen4;
196198
constexpr double MassHyperhelium4 = MassHyperHelium4;
199+
constexpr double MassHyperhelium4sigma = MassHyperHelium4Sigma;
197200

198201
// Light speed
199202
constexpr float LightSpeedCm2S = 299792458.e2; // C in cm/s

Common/Constants/include/CommonConstants/make_pdg_header.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class Pdg(Enum):
131131
kHyperHydrogen4 = 1010010040
132132
kHyperHelium4 = 1010020040
133133
kHyperHelium5 = 1010020050
134+
kHyperHelium4Sigma = 1110020040
134135

135136

136137
dbPdg = ROOT.o2.O2DatabasePDG

Common/MathUtils/include/MathUtils/SMatrixGPU.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,8 @@ class SMatrixGPU
446446
GPUdi() SMatrixGPU(SMatrixNoInit) {}
447447
GPUd() SMatrixGPU(SMatrixIdentity);
448448
GPUd() SMatrixGPU(const SMatrixGPU<T, D1, D2, R>& rhs);
449+
template <class R2>
450+
GPUd() SMatrixGPU(const SMatrixGPU<T, D1, D2, R2>& rhs);
449451
template <class A, class R2>
450452
GPUd() SMatrixGPU(const Expr<A, T, D1, D2, R2>& rhs);
451453
template <class M>
@@ -497,6 +499,11 @@ class SMatrixGPU
497499
GPUd() SMatrixRowGPU operator[](unsigned int i) { return SMatrixRowGPU(*this, i); }
498500
template <class R2>
499501
GPUd() SMatrixGPU<T, D1, D2, R>& operator+=(const SMatrixGPU<T, D1, D2, R2>& rhs);
502+
GPUd() SMatrixGPU<T, D1, D2, R>& operator*=(const T& rhs);
503+
template <class R2>
504+
GPUd() SMatrixGPU<T, D1, D2, R>& operator*=(const SMatrixGPU<T, D1, D2, R2>& rhs);
505+
template <class A, class R2>
506+
GPUd() SMatrixGPU<T, D1, D2, R>& operator*=(const Expr<A, T, D1, D2, R2>& rhs);
500507

501508
GPUd() bool Invert();
502509
GPUd() bool IsInUse(const T* p) const;
@@ -528,6 +535,13 @@ GPUdi() SMatrixGPU<T, D1, D2, R>::SMatrixGPU(const SMatrixGPU<T, D1, D2, R>& rhs
528535
mRep = rhs.mRep;
529536
}
530537

538+
template <class T, unsigned int D1, unsigned int D2, class R>
539+
template <class R2>
540+
GPUd() SMatrixGPU<T, D1, D2, R>::SMatrixGPU(const SMatrixGPU<T, D1, D2, R2>& rhs)
541+
{
542+
operator=(rhs);
543+
}
544+
531545
template <class T, unsigned int D1, unsigned int D2, class R>
532546
GPUdi() T* SMatrixGPU<T, D1, D2, R>::begin()
533547
{
@@ -1387,6 +1401,29 @@ GPUdi() SMatrixGPU<T, D1, D2, R>& SMatrixGPU<T, D1, D2, R>::operator+=(const SMa
13871401
return *this;
13881402
}
13891403

1404+
template <class T, unsigned int D1, unsigned int D2, class R>
1405+
GPUdi() SMatrixGPU<T, D1, D2, R>& SMatrixGPU<T, D1, D2, R>::operator*=(const T & rhs)
1406+
{
1407+
for (unsigned int i = 0; i < R::kSize; ++i) {
1408+
mRep.Array()[i] *= rhs;
1409+
}
1410+
return *this;
1411+
}
1412+
1413+
template <class T, unsigned int D1, unsigned int D2, class R>
1414+
template <class R2>
1415+
GPUdi() SMatrixGPU<T, D1, D2, R>& SMatrixGPU<T, D1, D2, R>::operator*=(const SMatrixGPU<T, D1, D2, R2>& rhs)
1416+
{
1417+
return operator=(*this* rhs);
1418+
}
1419+
1420+
template <class T, unsigned int D1, unsigned int D2, class R>
1421+
template <class A, class R2>
1422+
GPUdi() SMatrixGPU<T, D1, D2, R>& SMatrixGPU<T, D1, D2, R>::operator*=(const Expr<A, T, D1, D2, R2>& rhs)
1423+
{
1424+
return operator=(*this* rhs);
1425+
}
1426+
13901427
template <class T, unsigned int D1, unsigned int D2, class R>
13911428
struct TranspPolicyGPU {
13921429
enum {

DataFormats/Reconstruction/include/ReconstructionDataFormats/TrackParametrizationWithError.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define INCLUDE_RECONSTRUCTIONDATAFORMATS_TRACKPARAMETRIZATIONWITHERROR_H_
1919

2020
#include "ReconstructionDataFormats/TrackParametrization.h"
21+
#include <MathUtils/Cartesian.h>
2122

2223
namespace o2
2324
{
@@ -38,8 +39,8 @@ class TrackParametrizationWithError : public TrackParametrization<value_T>
3839
#endif
3940

4041
using covMat_t = gpu::gpustd::array<value_t, kCovMatSize>;
41-
using MatrixDSym5 = ROOT::Math::SMatrix<double, kNParams, kNParams, ROOT::Math::MatRepSym<double, kNParams>>;
42-
using MatrixD5 = ROOT::Math::SMatrix<double, kNParams, kNParams, ROOT::Math::MatRepStd<double, kNParams, kNParams>>;
42+
using MatrixDSym5 = o2::math_utils::SMatrix<double, kNParams, kNParams, o2::math_utils::MatRepSym<double, kNParams>>;
43+
using MatrixD5 = o2::math_utils::SMatrix<double, kNParams, kNParams, o2::math_utils::MatRepStd<double, kNParams, kNParams>>;
4344

4445
GPUd() TrackParametrizationWithError();
4546
GPUd() TrackParametrizationWithError(value_t x, value_t alpha, const params_t& par, const covMat_t& cov, int charge = 1, const PID pid = PID::Pion);
@@ -100,12 +101,12 @@ class TrackParametrizationWithError : public TrackParametrization<value_T>
100101
template <typename T>
101102
GPUd() value_t getPredictedChi2(const BaseCluster<T>& p) const;
102103

103-
void buildCombinedCovMatrix(const TrackParametrizationWithError& rhs, MatrixDSym5& cov) const;
104-
value_t getPredictedChi2(const TrackParametrizationWithError& rhs, MatrixDSym5& covToSet) const;
104+
GPUd() void buildCombinedCovMatrix(const TrackParametrizationWithError& rhs, MatrixDSym5& cov) const;
105+
GPUd() value_t getPredictedChi2(const TrackParametrizationWithError& rhs, MatrixDSym5& covToSet) const;
105106
GPUd() value_t getPredictedChi2(const TrackParametrizationWithError& rhs) const;
106107
GPUd() value_t getPredictedChi2Quiet(const TrackParametrizationWithError& rhs) const;
107-
bool update(const TrackParametrizationWithError& rhs, const MatrixDSym5& covInv);
108-
bool update(const TrackParametrizationWithError& rhs);
108+
GPUd() bool update(const TrackParametrizationWithError& rhs, const MatrixDSym5& covInv);
109+
GPUd() bool update(const TrackParametrizationWithError& rhs);
109110

110111
GPUd() bool update(const dim2_t& p, const dim3_t& cov);
111112
GPUd() bool update(const value_t* p, const value_t* cov);

DataFormats/Reconstruction/src/TrackParametrizationWithError.cxx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
#include "ReconstructionDataFormats/DCA.h"
1515
#include <GPUCommonLogger.h>
1616

17+
#ifndef __OPENCL__
18+
#include <cfloat>
19+
#else
20+
#include <float.h>
21+
#endif
22+
1723
#ifndef GPUCA_GPUCODE_DEVICE
1824
#include <iostream>
19-
#ifndef GPUCA_STANDALONE
20-
#include "Math/SMatrix.h"
21-
#endif
2225
#endif
2326

2427
#ifndef GPUCA_ALIGPUCODE
@@ -754,11 +757,17 @@ GPUd() auto TrackParametrizationWithError<value_T>::getPredictedChi2Quiet(const
754757
return (d * (szz * d - sdz * z) + z * (sdd * z - d * sdz)) / det;
755758
}
756759

757-
#if !defined(GPUCA_GPUCODE) && !defined(GPUCA_STANDALONE) // Disable function relying on ROOT SMatrix on GPU
760+
//______________________________________________
761+
template <typename value_T>
762+
GPUd() auto TrackParametrizationWithError<value_T>::getPredictedChi2(const TrackParametrizationWithError<value_T>& rhs) const -> value_t
763+
{
764+
MatrixDSym5 cov; // perform matrix operations in double!
765+
return getPredictedChi2(rhs, cov);
766+
}
758767

759768
//______________________________________________
760769
template <typename value_T>
761-
void TrackParametrizationWithError<value_T>::buildCombinedCovMatrix(const TrackParametrizationWithError<value_T>& rhs, MatrixDSym5& cov) const
770+
GPUd() void TrackParametrizationWithError<value_T>::buildCombinedCovMatrix(const TrackParametrizationWithError<value_T>& rhs, MatrixDSym5& cov) const
762771
{
763772
// fill combined cov.matrix (NOT inverted)
764773
cov(kY, kY) = static_cast<double>(getSigmaY2()) + static_cast<double>(rhs.getSigmaY2());
@@ -778,14 +787,6 @@ void TrackParametrizationWithError<value_T>::buildCombinedCovMatrix(const TrackP
778787
cov(kQ2Pt, kQ2Pt) = static_cast<double>(getSigma1Pt2()) + static_cast<double>(rhs.getSigma1Pt2());
779788
}
780789

781-
//______________________________________________
782-
template <typename value_T>
783-
GPUd() auto TrackParametrizationWithError<value_T>::getPredictedChi2(const TrackParametrizationWithError<value_T>& rhs) const -> value_t
784-
{
785-
MatrixDSym5 cov; // perform matrix operations in double!
786-
return getPredictedChi2(rhs, cov);
787-
}
788-
789790
//______________________________________________
790791
template <typename value_T>
791792
GPUd() auto TrackParametrizationWithError<value_T>::getPredictedChi2(const TrackParametrizationWithError<value_T>& rhs, MatrixDSym5& covToSet) const -> value_t
@@ -867,7 +868,7 @@ GPUd() bool TrackParametrizationWithError<value_T>::update(const TrackParametriz
867868
}
868869

869870
// updated covariance: Cov0 = Cov0 - K*Cov0
870-
matK *= ROOT::Math::SMatrix<double, kNParams, kNParams, ROOT::Math::MatRepStd<double, kNParams>>(matC0);
871+
matK *= o2::math_utils::SMatrix<double, kNParams, kNParams, o2::math_utils::MatRepStd<double, kNParams>>(matC0);
871872
mC[kSigY2] -= matK(kY, kY);
872873
mC[kSigZY] -= matK(kZ, kY);
873874
mC[kSigZ2] -= matK(kZ, kZ);
@@ -901,8 +902,6 @@ GPUd() bool TrackParametrizationWithError<value_T>::update(const TrackParametriz
901902
return update(rhs, covI);
902903
}
903904

904-
#endif
905-
906905
//______________________________________________
907906
template <typename value_T>
908907
GPUd() bool TrackParametrizationWithError<value_T>::update(const value_t* p, const value_t* cov)

DataFormats/simulation/include/SimulationDataFormat/O2DatabasePDG.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,19 @@ inline void O2DatabasePDG::addALICEParticles(TDatabasePDG* db)
331331
2.5e-15, 6, "Ion", ionCode);
332332
}
333333

334+
// hyper helium 4 sigma
335+
ionCode = 1110020040;
336+
if (!db->GetParticle(ionCode)) {
337+
db->AddParticle("Hyperhelium4sigma", "Hyperhelium4sigma", 3.995, kFALSE,
338+
2.5e-15, 6, "Ion", ionCode);
339+
}
340+
// anti-hyper helium 4 sigma
341+
ionCode = -1110020040;
342+
if (!db->GetParticle(ionCode)) {
343+
db->AddParticle("AntiHyperhelium4sigma", "AntiHyperhelium4sigma", 3.995, kFALSE,
344+
2.5e-15, 6, "Ion", ionCode);
345+
}
346+
334347
ionCode = 1010000020;
335348
if (!db->GetParticle(ionCode)) {
336349
db->AddParticle("LambdaNeutron", "LambdaNeutron", 2.054, kFALSE,
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
///
12+
13+
#ifndef TRACKINGITSGPU_INCLUDE_TIMEFRAMECHUNKGPU_H
14+
#define TRACKINGITSGPU_INCLUDE_TIMEFRAMECHUNKGPU_H
15+
16+
#include "ITStracking/Configuration.h"
17+
#include "ITStracking/TimeFrame.h"
18+
19+
#include "ITStrackingGPU/ClusterLinesGPU.h"
20+
#include "ITStrackingGPU/Array.h"
21+
#include "ITStrackingGPU/Vector.h"
22+
#include "ITStrackingGPU/Stream.h"
23+
24+
#include <gsl/gsl>
25+
26+
namespace o2::its::gpu
27+
{
28+
template <int nLayers>
29+
struct StaticTrackingParameters {
30+
StaticTrackingParameters<nLayers>& operator=(const StaticTrackingParameters<nLayers>& t) = default;
31+
void set(const TrackingParameters& pars)
32+
{
33+
ClusterSharing = pars.ClusterSharing;
34+
MinTrackLength = pars.MinTrackLength;
35+
NSigmaCut = pars.NSigmaCut;
36+
PVres = pars.PVres;
37+
DeltaROF = pars.DeltaROF;
38+
ZBins = pars.ZBins;
39+
PhiBins = pars.PhiBins;
40+
CellDeltaTanLambdaSigma = pars.CellDeltaTanLambdaSigma;
41+
}
42+
43+
/// General parameters
44+
int ClusterSharing = 0;
45+
int MinTrackLength = nLayers;
46+
float NSigmaCut = 5;
47+
float PVres = 1.e-2f;
48+
int DeltaROF = 0;
49+
int ZBins{256};
50+
int PhiBins{128};
51+
52+
/// Cell finding cuts
53+
float CellDeltaTanLambdaSigma = 0.007f;
54+
};
55+
56+
template <int nLayers>
57+
class GpuTimeFrameChunk
58+
{
59+
public:
60+
static size_t computeScalingSizeBytes(const int, const TimeFrameGPUParameters&);
61+
static size_t computeFixedSizeBytes(const TimeFrameGPUParameters&);
62+
static size_t computeRofPerChunk(const TimeFrameGPUParameters&, const size_t);
63+
64+
GpuTimeFrameChunk() = delete;
65+
GpuTimeFrameChunk(o2::its::TimeFrame* tf, TimeFrameGPUParameters& conf)
66+
{
67+
mTimeFramePtr = tf;
68+
mTFGPUParams = &conf;
69+
}
70+
~GpuTimeFrameChunk();
71+
72+
/// Most relevant operations
73+
void allocate(const size_t, Stream&);
74+
void reset(const Task, Stream&);
75+
size_t loadDataOnDevice(const size_t, const size_t, const int, Stream&);
76+
77+
/// Interface
78+
Cluster* getDeviceClusters(const int);
79+
int* getDeviceClusterExternalIndices(const int);
80+
int* getDeviceIndexTables(const int);
81+
Tracklet* getDeviceTracklets(const int);
82+
int* getDeviceTrackletsLookupTables(const int);
83+
CellSeed* getDeviceCells(const int);
84+
int* getDeviceCellsLookupTables(const int);
85+
int* getDeviceRoadsLookupTables(const int);
86+
TimeFrameGPUParameters* getTimeFrameGPUParameters() const { return mTFGPUParams; }
87+
88+
int* getDeviceCUBTmpBuffer() { return mCUBTmpBufferDevice; }
89+
int* getDeviceFoundTracklets() { return mFoundTrackletsDevice; }
90+
int* getDeviceNFoundCells() { return mNFoundCellsDevice; }
91+
int* getDeviceCellNeigboursLookupTables(const int);
92+
int* getDeviceCellNeighbours(const int);
93+
CellSeed** getDeviceArrayCells() const { return mCellsDeviceArray; }
94+
int** getDeviceArrayNeighboursCell() const { return mNeighboursCellDeviceArray; }
95+
int** getDeviceArrayNeighboursCellLUT() const { return mNeighboursCellLookupTablesDeviceArray; }
96+
97+
/// Vertexer only
98+
int* getDeviceNTrackletCluster(const int combid) { return mNTrackletsPerClusterDevice[combid]; }
99+
Line* getDeviceLines() { return mLinesDevice; };
100+
int* getDeviceNFoundLines() { return mNFoundLinesDevice; }
101+
int* getDeviceNExclusiveFoundLines() { return mNExclusiveFoundLinesDevice; }
102+
unsigned char* getDeviceUsedTracklets() { return mUsedTrackletsDevice; }
103+
int* getDeviceClusteredLines() { return mClusteredLinesDevice; }
104+
size_t getNPopulatedRof() const { return mNPopulatedRof; }
105+
106+
private:
107+
/// Host
108+
std::array<gsl::span<const Cluster>, nLayers> mHostClusters;
109+
std::array<gsl::span<const int>, nLayers> mHostIndexTables;
110+
111+
/// Device
112+
std::array<Cluster*, nLayers> mClustersDevice;
113+
std::array<int*, nLayers> mClusterExternalIndicesDevice;
114+
std::array<int*, nLayers> mIndexTablesDevice;
115+
std::array<Tracklet*, nLayers - 1> mTrackletsDevice;
116+
std::array<int*, nLayers - 1> mTrackletsLookupTablesDevice;
117+
std::array<CellSeed*, nLayers - 2> mCellsDevice;
118+
// Road<nLayers - 2>* mRoadsDevice;
119+
std::array<int*, nLayers - 2> mCellsLookupTablesDevice;
120+
std::array<int*, nLayers - 3> mNeighboursCellDevice;
121+
std::array<int*, nLayers - 3> mNeighboursCellLookupTablesDevice;
122+
std::array<int*, nLayers - 2> mRoadsLookupTablesDevice;
123+
124+
// These are to make them accessible using layer index
125+
CellSeed** mCellsDeviceArray;
126+
int** mNeighboursCellDeviceArray;
127+
int** mNeighboursCellLookupTablesDeviceArray;
128+
129+
// Small accessory buffers
130+
int* mCUBTmpBufferDevice;
131+
int* mFoundTrackletsDevice;
132+
int* mNFoundCellsDevice;
133+
134+
/// Vertexer only
135+
Line* mLinesDevice;
136+
int* mNFoundLinesDevice;
137+
int* mNExclusiveFoundLinesDevice;
138+
unsigned char* mUsedTrackletsDevice;
139+
std::array<int*, 2> mNTrackletsPerClusterDevice;
140+
int* mClusteredLinesDevice;
141+
142+
/// State and configuration
143+
bool mAllocated = false;
144+
size_t mNRof = 0;
145+
size_t mNPopulatedRof = 0;
146+
o2::its::TimeFrame* mTimeFramePtr = nullptr;
147+
TimeFrameGPUParameters* mTFGPUParams = nullptr;
148+
};
149+
} // namespace o2::its::gpu
150+
#endif

0 commit comments

Comments
 (0)