Skip to content

Commit 7fce8d8

Browse files
authored
ITS: last mod. for deltaROF and perVertex (#14538)
1 parent 6cd3538 commit 7fce8d8

File tree

11 files changed

+583
-364
lines changed

11 files changed

+583
-364
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,14 @@ void clearResizeBoundedArray(std::array<bounded_vector<T>, S>& arr, size_t size,
174174
}
175175
}
176176

177+
template <typename T>
178+
std::vector<T> toSTDVector(const bounded_vector<T>& b)
179+
{
180+
std::vector<T> t(b.size());
181+
std::copy(b.cbegin(), b.cend(), t.begin());
182+
return t;
183+
}
184+
177185
} // namespace o2::its
178186

179187
#endif

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

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@
1515

1616
#ifndef TRACKINGITSU_INCLUDE_CACELL_H_
1717
#define TRACKINGITSU_INCLUDE_CACELL_H_
18-
#ifndef GPUCA_GPUCODE_DEVICE
19-
#include <array>
20-
#include <vector>
21-
#include <iostream>
22-
#endif
2318

19+
#include "ITStracking/Constants.h"
2420
#include "GPUCommonDef.h"
2521

2622
namespace o2::its
@@ -39,12 +35,12 @@ class Cell final
3935
GPUhd() int* getLevelPtr() { return &mLevel; }
4036

4137
private:
42-
int mFirstClusterIndex{0};
43-
int mSecondClusterIndex{0};
44-
int mThirdClusterIndex{0};
45-
int mFirstTrackletIndex{0};
46-
int mSecondTrackletIndex{0};
47-
int mLevel{0};
38+
int mFirstClusterIndex{constants::UnusedIndex};
39+
int mSecondClusterIndex{constants::UnusedIndex};
40+
int mThirdClusterIndex{constants::UnusedIndex};
41+
int mFirstTrackletIndex{constants::UnusedIndex};
42+
int mSecondTrackletIndex{constants::UnusedIndex};
43+
int mLevel{constants::UnusedIndex};
4844
};
4945

5046
class CellSeed final : public o2::track::TrackParCovF
@@ -82,14 +78,14 @@ class CellSeed final : public o2::track::TrackParCovF
8278
GPUhd() int getCluster(int i) const { return mClusters[i]; }
8379
GPUhd() void printCell() const
8480
{
85-
printf("trkl: %d, %d\t lvl: %d\t chi2: %f\n", mTracklets[0], mTracklets[1], mLevel, mChi2);
81+
printf("trkl: %d, %d\t lvl: %d\t chi2: %f\tcls: [%d | %d | %d | %d | %d | %d | %d]\n", mTracklets[0], mTracklets[1], mLevel, mChi2, mClusters[0], mClusters[1], mClusters[2], mClusters[3], mClusters[4], mClusters[5], mClusters[6]);
8682
}
8783

8884
private:
89-
float mChi2 = 0.f;
90-
int mLevel = 0;
91-
int mTracklets[2] = {-1, -1};
92-
int mClusters[7] = {-1, -1, -1, -1, -1, -1, -1};
85+
float mChi2 = -999.f;
86+
int mLevel = constants::UnusedIndex;
87+
int mTracklets[2] = {constants::UnusedIndex, constants::UnusedIndex};
88+
int mClusters[7] = {constants::UnusedIndex, constants::UnusedIndex, constants::UnusedIndex, constants::UnusedIndex, constants::UnusedIndex, constants::UnusedIndex, constants::UnusedIndex};
9389
};
9490

9591
} // namespace o2::its

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ struct Line final {
4242
bool operator!=(const Line&) const;
4343
short getMinROF() const { return rof[0] < rof[1] ? rof[0] : rof[1]; }
4444

45-
float originPoint[3] = {0};
46-
float cosinesDirector[3] = {0};
45+
float originPoint[3] = {0, 0, 0};
46+
float cosinesDirector[3] = {0, 0, 0};
4747
// float weightMatrix[6] = {1., 0., 0., 1., 0., 1.};
4848
// weightMatrix is a symmetric matrix internally stored as
4949
// 0 --> row = 0, col = 0
@@ -52,7 +52,7 @@ struct Line final {
5252
// 3 --> 1,1
5353
// 4 --> 1,2
5454
// 5 --> 2,2
55-
short rof[2] = {-1, -1};
55+
short rof[2] = {constants::UnusedIndex, constants::UnusedIndex};
5656

5757
ClassDefNV(Line, 1);
5858
};
@@ -207,7 +207,7 @@ class ClusterLines final
207207
std::array<float, 6> mRMS2 = {0.f}; // symmetric matrix: diagonal is RMS2
208208
float mAvgDistance2 = 0.f; // substitute for chi2
209209
int mROFWeight = 0; // rof weight for voting
210-
short mROF = -1; // rof
210+
short mROF = constants::UnusedIndex; // rof
211211
};
212212

213213
} // namespace o2::its

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,9 @@ struct TimeFrame {
7777
gsl::span<const std::array<float, 2>> getPrimaryVerticesXAlpha(int rofId) const;
7878
void fillPrimaryVerticesXandAlpha();
7979
int getPrimaryVerticesNum(int rofId = -1) const;
80-
void addPrimaryVertices(const bounded_vector<Vertex>& vertices);
8180
void addPrimaryVerticesLabels(bounded_vector<std::pair<MCCompLabel, float>>& labels);
8281
void addPrimaryVerticesContributorLabels(bounded_vector<MCCompLabel>& labels);
83-
void addPrimaryVertices(const bounded_vector<Vertex>& vertices, const int rofId, const int iteration);
84-
void addPrimaryVertices(const gsl::span<const Vertex>& vertices, const int rofId, const int iteration);
82+
void addPrimaryVertices(const bounded_vector<Vertex>& vertices, const int iteration);
8583
void addPrimaryVerticesInROF(const bounded_vector<Vertex>& vertices, const int rofId, const int iteration);
8684
void addPrimaryVerticesLabelsInROF(const bounded_vector<std::pair<MCCompLabel, float>>& labels, const int rofId);
8785
void addPrimaryVerticesContributorLabelsInROF(const bounded_vector<MCCompLabel>& labels, const int rofId);
@@ -397,7 +395,8 @@ inline gsl::span<const Vertex> TimeFrame<nLayers>::getPrimaryVertices(int romin,
397395
if (mPrimaryVertices.empty()) {
398396
return {};
399397
}
400-
return {&mPrimaryVertices[mROFramesPV[romin]], static_cast<gsl::span<const Vertex>::size_type>(mROFramesPV[romax + 1] - mROFramesPV[romin])};
398+
const int stop_idx = romax >= mNrof - 1 ? mNrof : romax + 1;
399+
return {&mPrimaryVertices[mROFramesPV[romin]], static_cast<gsl::span<const Vertex>::size_type>(mROFramesPV[stop_idx] - mROFramesPV[romin])};
401400
}
402401

403402
template <int nLayers>
@@ -594,7 +593,7 @@ inline gsl::span<int> TimeFrame<nLayers>::getExclusiveNTrackletsCluster(int rofI
594593
template <int nLayers>
595594
inline gsl::span<Tracklet> TimeFrame<nLayers>::getFoundTracklets(int rofId, int combId)
596595
{
597-
if (rofId < 0 || rofId >= mNrof) {
596+
if (rofId < 0 || rofId >= mNrof || mTracklets[combId].empty()) {
598597
return {};
599598
}
600599
auto startIdx{mNTrackletsPerROF[combId][rofId]};

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

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#ifndef TRACKINGITS_INCLUDE_TRACKLET_H_
1717
#define TRACKINGITS_INCLUDE_TRACKLET_H_
1818

19+
#include "ITStracking/Constants.h"
1920
#include "ITStracking/Cluster.h"
2021
#include "GPUCommonRtypes.h"
2122
#include "GPUCommonMath.h"
@@ -41,9 +42,10 @@ struct Tracklet final {
4142
{
4243
return firstClusterIndex < 0 || secondClusterIndex < 0;
4344
}
45+
GPUhdi() auto getMinRof() const noexcept { return o2::gpu::CAMath::Min(rof[0], rof[1]); }
46+
GPUhdi() auto getMaxRof() const noexcept { return o2::gpu::CAMath::Max(rof[0], rof[1]); }
4447
GPUhdi() auto getDeltaRof() const { return rof[1] - rof[0]; }
45-
GPUhdi() void dump() const;
46-
GPUhdi() void dump(const int, const int) const;
48+
GPUhdi() auto getSpanRof(const Tracklet& o) const noexcept { return o2::gpu::CAMath::Max(getMaxRof(), o.getMaxRof()) - o2::gpu::CAMath::Min(getMinRof(), o.getMinRof()); }
4749
GPUhdi() unsigned char operator<(const Tracklet&) const;
4850
#if !defined(GPUCA_NO_FMT) && !defined(GPUCA_GPUCODE_DEVICE)
4951
std::string asString() const
@@ -53,11 +55,11 @@ struct Tracklet final {
5355
void print() const { LOG(info) << asString(); }
5456
#endif
5557

56-
int firstClusterIndex{-1};
57-
int secondClusterIndex{-1};
58+
int firstClusterIndex{constants::UnusedIndex};
59+
int secondClusterIndex{constants::UnusedIndex};
5860
float tanLambda{-999};
5961
float phi{-999};
60-
short rof[2] = {-1, -1};
62+
short rof[2] = {constants::UnusedIndex, constants::UnusedIndex};
6163

6264
ClassDefNV(Tracklet, 1);
6365
};
@@ -93,16 +95,6 @@ GPUhdi() unsigned char Tracklet::operator<(const Tracklet& t) const
9395
return true;
9496
}
9597

96-
GPUhdi() void Tracklet::dump(const int offsetFirst, const int offsetSecond) const
97-
{
98-
printf("fClIdx: %d sClIdx: %d rof1: %hu rof2: %hu\n", firstClusterIndex + offsetFirst, secondClusterIndex + offsetSecond, rof[0], rof[1]);
99-
}
100-
101-
GPUhdi() void Tracklet::dump() const
102-
{
103-
printf("fClIdx: %d sClIdx: %d rof1: %hu rof2: %hu\n", firstClusterIndex, secondClusterIndex, rof[0], rof[1]);
104-
}
105-
10698
} // namespace o2::its
10799

108100
#endif /* TRACKINGITS_INCLUDE_TRACKLET_H_ */

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ class VertexerTraits
119119
private:
120120
std::shared_ptr<BoundedMemoryResource> mMemoryPool;
121121
std::shared_ptr<tbb::task_arena> mTaskArena;
122+
123+
// debug output
124+
void debugComputeTracklets(int iteration);
125+
void debugComputeTrackletMatching(int iteration);
126+
void debugComputeVertices(int iteration);
122127
};
123128

124129
inline void VertexerTraits::initialise(const TrackingParameters& trackingParams, const int iteration)

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

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -59,24 +59,19 @@ TimeFrame<nLayers>::~TimeFrame()
5959
}
6060

6161
template <int nLayers>
62-
void TimeFrame<nLayers>::addPrimaryVertices(const bounded_vector<Vertex>& vertices)
62+
void TimeFrame<nLayers>::addPrimaryVertices(const bounded_vector<Vertex>& vertices, const int iteration)
6363
{
6464
for (const auto& vertex : vertices) {
65-
mPrimaryVertices.emplace_back(vertex);
66-
if (!isBeamPositionOverridden) {
65+
mPrimaryVertices.emplace_back(vertex); // put a copy in the present
66+
mTotVertPerIteration[iteration]++;
67+
if (!isBeamPositionOverridden) { // beam position is updated only at first occurrence of the vertex. A bit sketchy if we have past/future vertices, it should not impact too much.
6768
const float w = vertex.getNContributors();
6869
mBeamPos[0] = (mBeamPos[0] * mBeamPosWeight + vertex.getX() * w) / (mBeamPosWeight + w);
6970
mBeamPos[1] = (mBeamPos[1] * mBeamPosWeight + vertex.getY() * w) / (mBeamPosWeight + w);
7071
mBeamPosWeight += w;
7172
}
7273
}
73-
mROFramesPV.push_back(mPrimaryVertices.size());
74-
}
75-
76-
template <int nLayers>
77-
void TimeFrame<nLayers>::addPrimaryVertices(const bounded_vector<Vertex>& vertices, const int rofId, const int iteration)
78-
{
79-
addPrimaryVertices(gsl::span<const Vertex>(vertices), rofId, iteration);
74+
mROFramesPV.push_back(mPrimaryVertices.size()); // current rof must have number of vertices up to present
8075
}
8176

8277
template <int nLayers>
@@ -119,34 +114,6 @@ void TimeFrame<nLayers>::addPrimaryVerticesContributorLabelsInROF(const bounded_
119114
mVerticesContributorLabels.insert(mVerticesContributorLabels.begin() + n, labels.begin(), labels.end());
120115
}
121116

122-
template <int nLayers>
123-
void TimeFrame<nLayers>::addPrimaryVertices(const gsl::span<const Vertex>& vertices, const int rofId, const int iteration)
124-
{
125-
bounded_vector<Vertex> futureVertices(mMemoryPool.get());
126-
for (const auto& vertex : vertices) {
127-
if (vertex.getTimeStamp().getTimeStamp() < rofId) { // put a copy in the past
128-
insertPastVertex(vertex, iteration);
129-
} else {
130-
if (vertex.getTimeStamp().getTimeStamp() > rofId) { // or put a copy in the future
131-
futureVertices.emplace_back(vertex);
132-
}
133-
}
134-
mPrimaryVertices.emplace_back(vertex); // put a copy in the present
135-
mTotVertPerIteration[iteration]++;
136-
if (!isBeamPositionOverridden) { // beam position is updated only at first occurrence of the vertex. A bit sketchy if we have past/future vertices, it should not impact too much.
137-
const float w = vertex.getNContributors();
138-
mBeamPos[0] = (mBeamPos[0] * mBeamPosWeight + vertex.getX() * w) / (mBeamPosWeight + w);
139-
mBeamPos[1] = (mBeamPos[1] * mBeamPosWeight + vertex.getY() * w) / (mBeamPosWeight + w);
140-
mBeamPosWeight += w;
141-
}
142-
}
143-
mROFramesPV.push_back(mPrimaryVertices.size()); // current rof must have number of vertices up to present
144-
for (auto& vertex : futureVertices) {
145-
mPrimaryVertices.emplace_back(vertex);
146-
mTotVertPerIteration[iteration]++;
147-
}
148-
}
149-
150117
template <int nLayers>
151118
int TimeFrame<nLayers>::loadROFrameData(gsl::span<o2::itsmft::ROFRecord> rofs,
152119
gsl::span<const itsmft::CompClusterExt> clusters,
@@ -395,7 +362,7 @@ void TimeFrame<nLayers>::initialise(const int iteration, const TrackingParameter
395362
if (iLayer < (int)mCells.size()) {
396363
deepVectorClear(mCells[iLayer]);
397364
deepVectorClear(mTrackletsLookupTable[iLayer]);
398-
mTrackletsLookupTable[iLayer].resize(mClusters[iLayer + 1].size(), 0);
365+
mTrackletsLookupTable[iLayer].resize(mClusters[iLayer + 1].size() + 1, 0);
399366
deepVectorClear(mCellLabels[iLayer]);
400367
}
401368

@@ -686,8 +653,8 @@ void TimeFrame<nLayers>::wipe()
686653
deepVectorClear(mCellsLookupTable);
687654
deepVectorClear(mTotVertPerIteration);
688655
deepVectorClear(mPrimaryVertices);
689-
deepVectorClear(mROFramesPV);
690656
deepVectorClear(mClusters);
657+
deepVectorClear(mTrackletsLookupTable);
691658
deepVectorClear(mTrackingFrameInfo);
692659
deepVectorClear(mClusterExternalIndices);
693660
deepVectorClear(mROFramesClusters);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ void Tracker::clustersToTracks(const LogFunc& logger, const LogFunc& error)
5252
int maxNvertices{-1};
5353
if (mTrkParams[0].PerPrimaryVertexProcessing) {
5454
for (int iROF{0}; iROF < mTimeFrame->getNrof(); ++iROF) {
55-
maxNvertices = std::max(maxNvertices, (int)mTimeFrame->getPrimaryVertices(iROF).size());
55+
int minRof = o2::gpu::CAMath::Max(0, iROF - mTrkParams[0].DeltaROF);
56+
int maxRof = o2::gpu::CAMath::Min(mTimeFrame->getNrof(), iROF + mTrkParams[0].DeltaROF);
57+
maxNvertices = std::max(maxNvertices, (int)mTimeFrame->getPrimaryVertices(minRof, maxRof).size());
5658
}
5759
}
5860

0 commit comments

Comments
 (0)