Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ void clearResizeBoundedArray(std::array<bounded_vector<T>, S>& arr, size_t size,
}
}

template <typename T>
std::vector<T> toSTDVector(const bounded_vector<T>& b)
{
std::vector<T> t(b.size());
std::copy(b.cbegin(), b.cend(), t.begin());
return t;
}

} // namespace o2::its

#endif
28 changes: 12 additions & 16 deletions Detectors/ITSMFT/ITS/tracking/include/ITStracking/Cell.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@

#ifndef TRACKINGITSU_INCLUDE_CACELL_H_
#define TRACKINGITSU_INCLUDE_CACELL_H_
#ifndef GPUCA_GPUCODE_DEVICE
#include <array>
#include <vector>
#include <iostream>
#endif

#include "ITStracking/Constants.h"
#include "GPUCommonDef.h"

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

private:
int mFirstClusterIndex{0};
int mSecondClusterIndex{0};
int mThirdClusterIndex{0};
int mFirstTrackletIndex{0};
int mSecondTrackletIndex{0};
int mLevel{0};
int mFirstClusterIndex{constants::UnusedIndex};
int mSecondClusterIndex{constants::UnusedIndex};
int mThirdClusterIndex{constants::UnusedIndex};
int mFirstTrackletIndex{constants::UnusedIndex};
int mSecondTrackletIndex{constants::UnusedIndex};
int mLevel{constants::UnusedIndex};
};

class CellSeed final : public o2::track::TrackParCovF
Expand Down Expand Up @@ -82,14 +78,14 @@ class CellSeed final : public o2::track::TrackParCovF
GPUhd() int getCluster(int i) const { return mClusters[i]; }
GPUhd() void printCell() const
{
printf("trkl: %d, %d\t lvl: %d\t chi2: %f\n", mTracklets[0], mTracklets[1], mLevel, mChi2);
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]);
}

private:
float mChi2 = 0.f;
int mLevel = 0;
int mTracklets[2] = {-1, -1};
int mClusters[7] = {-1, -1, -1, -1, -1, -1, -1};
float mChi2 = -999.f;
int mLevel = constants::UnusedIndex;
int mTracklets[2] = {constants::UnusedIndex, constants::UnusedIndex};
int mClusters[7] = {constants::UnusedIndex, constants::UnusedIndex, constants::UnusedIndex, constants::UnusedIndex, constants::UnusedIndex, constants::UnusedIndex, constants::UnusedIndex};
};

} // namespace o2::its
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ struct Line final {
bool operator!=(const Line&) const;
short getMinROF() const { return rof[0] < rof[1] ? rof[0] : rof[1]; }

float originPoint[3] = {0};
float cosinesDirector[3] = {0};
float originPoint[3] = {0, 0, 0};
float cosinesDirector[3] = {0, 0, 0};
// float weightMatrix[6] = {1., 0., 0., 1., 0., 1.};
// weightMatrix is a symmetric matrix internally stored as
// 0 --> row = 0, col = 0
Expand All @@ -52,7 +52,7 @@ struct Line final {
// 3 --> 1,1
// 4 --> 1,2
// 5 --> 2,2
short rof[2] = {-1, -1};
short rof[2] = {constants::UnusedIndex, constants::UnusedIndex};

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

} // namespace o2::its
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,9 @@ struct TimeFrame {
gsl::span<const std::array<float, 2>> getPrimaryVerticesXAlpha(int rofId) const;
void fillPrimaryVerticesXandAlpha();
int getPrimaryVerticesNum(int rofId = -1) const;
void addPrimaryVertices(const bounded_vector<Vertex>& vertices);
void addPrimaryVerticesLabels(bounded_vector<std::pair<MCCompLabel, float>>& labels);
void addPrimaryVerticesContributorLabels(bounded_vector<MCCompLabel>& labels);
void addPrimaryVertices(const bounded_vector<Vertex>& vertices, const int rofId, const int iteration);
void addPrimaryVertices(const gsl::span<const Vertex>& vertices, const int rofId, const int iteration);
void addPrimaryVertices(const bounded_vector<Vertex>& vertices, const int iteration);
void addPrimaryVerticesInROF(const bounded_vector<Vertex>& vertices, const int rofId, const int iteration);
void addPrimaryVerticesLabelsInROF(const bounded_vector<std::pair<MCCompLabel, float>>& labels, const int rofId);
void addPrimaryVerticesContributorLabelsInROF(const bounded_vector<MCCompLabel>& labels, const int rofId);
Expand Down Expand Up @@ -397,7 +395,8 @@ inline gsl::span<const Vertex> TimeFrame<nLayers>::getPrimaryVertices(int romin,
if (mPrimaryVertices.empty()) {
return {};
}
return {&mPrimaryVertices[mROFramesPV[romin]], static_cast<gsl::span<const Vertex>::size_type>(mROFramesPV[romax + 1] - mROFramesPV[romin])};
const int stop_idx = romax >= mNrof - 1 ? mNrof : romax + 1;
return {&mPrimaryVertices[mROFramesPV[romin]], static_cast<gsl::span<const Vertex>::size_type>(mROFramesPV[stop_idx] - mROFramesPV[romin])};
}

template <int nLayers>
Expand Down Expand Up @@ -594,7 +593,7 @@ inline gsl::span<int> TimeFrame<nLayers>::getExclusiveNTrackletsCluster(int rofI
template <int nLayers>
inline gsl::span<Tracklet> TimeFrame<nLayers>::getFoundTracklets(int rofId, int combId)
{
if (rofId < 0 || rofId >= mNrof) {
if (rofId < 0 || rofId >= mNrof || mTracklets[combId].empty()) {
return {};
}
auto startIdx{mNTrackletsPerROF[combId][rofId]};
Expand Down
22 changes: 7 additions & 15 deletions Detectors/ITSMFT/ITS/tracking/include/ITStracking/Tracklet.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#ifndef TRACKINGITS_INCLUDE_TRACKLET_H_
#define TRACKINGITS_INCLUDE_TRACKLET_H_

#include "ITStracking/Constants.h"
#include "ITStracking/Cluster.h"
#include "GPUCommonRtypes.h"
#include "GPUCommonMath.h"
Expand All @@ -41,9 +42,10 @@ struct Tracklet final {
{
return firstClusterIndex < 0 || secondClusterIndex < 0;
}
GPUhdi() auto getMinRof() const noexcept { return o2::gpu::CAMath::Min(rof[0], rof[1]); }
GPUhdi() auto getMaxRof() const noexcept { return o2::gpu::CAMath::Max(rof[0], rof[1]); }
GPUhdi() auto getDeltaRof() const { return rof[1] - rof[0]; }
GPUhdi() void dump() const;
GPUhdi() void dump(const int, const int) const;
GPUhdi() auto getSpanRof(const Tracklet& o) const noexcept { return o2::gpu::CAMath::Max(getMaxRof(), o.getMaxRof()) - o2::gpu::CAMath::Min(getMinRof(), o.getMinRof()); }
GPUhdi() unsigned char operator<(const Tracklet&) const;
#if !defined(GPUCA_NO_FMT) && !defined(GPUCA_GPUCODE_DEVICE)
std::string asString() const
Expand All @@ -53,11 +55,11 @@ struct Tracklet final {
void print() const { LOG(info) << asString(); }
#endif

int firstClusterIndex{-1};
int secondClusterIndex{-1};
int firstClusterIndex{constants::UnusedIndex};
int secondClusterIndex{constants::UnusedIndex};
float tanLambda{-999};
float phi{-999};
short rof[2] = {-1, -1};
short rof[2] = {constants::UnusedIndex, constants::UnusedIndex};

ClassDefNV(Tracklet, 1);
};
Expand Down Expand Up @@ -93,16 +95,6 @@ GPUhdi() unsigned char Tracklet::operator<(const Tracklet& t) const
return true;
}

GPUhdi() void Tracklet::dump(const int offsetFirst, const int offsetSecond) const
{
printf("fClIdx: %d sClIdx: %d rof1: %hu rof2: %hu\n", firstClusterIndex + offsetFirst, secondClusterIndex + offsetSecond, rof[0], rof[1]);
}

GPUhdi() void Tracklet::dump() const
{
printf("fClIdx: %d sClIdx: %d rof1: %hu rof2: %hu\n", firstClusterIndex, secondClusterIndex, rof[0], rof[1]);
}

} // namespace o2::its

#endif /* TRACKINGITS_INCLUDE_TRACKLET_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ class VertexerTraits
private:
std::shared_ptr<BoundedMemoryResource> mMemoryPool;
std::shared_ptr<tbb::task_arena> mTaskArena;

// debug output
void debugComputeTracklets(int iteration);
void debugComputeTrackletMatching(int iteration);
void debugComputeVertices(int iteration);
};

inline void VertexerTraits::initialise(const TrackingParameters& trackingParams, const int iteration)
Expand Down
47 changes: 7 additions & 40 deletions Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,19 @@ TimeFrame<nLayers>::~TimeFrame()
}

template <int nLayers>
void TimeFrame<nLayers>::addPrimaryVertices(const bounded_vector<Vertex>& vertices)
void TimeFrame<nLayers>::addPrimaryVertices(const bounded_vector<Vertex>& vertices, const int iteration)
{
for (const auto& vertex : vertices) {
mPrimaryVertices.emplace_back(vertex);
if (!isBeamPositionOverridden) {
mPrimaryVertices.emplace_back(vertex); // put a copy in the present
mTotVertPerIteration[iteration]++;
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.
const float w = vertex.getNContributors();
mBeamPos[0] = (mBeamPos[0] * mBeamPosWeight + vertex.getX() * w) / (mBeamPosWeight + w);
mBeamPos[1] = (mBeamPos[1] * mBeamPosWeight + vertex.getY() * w) / (mBeamPosWeight + w);
mBeamPosWeight += w;
}
}
mROFramesPV.push_back(mPrimaryVertices.size());
}

template <int nLayers>
void TimeFrame<nLayers>::addPrimaryVertices(const bounded_vector<Vertex>& vertices, const int rofId, const int iteration)
{
addPrimaryVertices(gsl::span<const Vertex>(vertices), rofId, iteration);
mROFramesPV.push_back(mPrimaryVertices.size()); // current rof must have number of vertices up to present
}

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

template <int nLayers>
void TimeFrame<nLayers>::addPrimaryVertices(const gsl::span<const Vertex>& vertices, const int rofId, const int iteration)
{
bounded_vector<Vertex> futureVertices(mMemoryPool.get());
for (const auto& vertex : vertices) {
if (vertex.getTimeStamp().getTimeStamp() < rofId) { // put a copy in the past
insertPastVertex(vertex, iteration);
} else {
if (vertex.getTimeStamp().getTimeStamp() > rofId) { // or put a copy in the future
futureVertices.emplace_back(vertex);
}
}
mPrimaryVertices.emplace_back(vertex); // put a copy in the present
mTotVertPerIteration[iteration]++;
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.
const float w = vertex.getNContributors();
mBeamPos[0] = (mBeamPos[0] * mBeamPosWeight + vertex.getX() * w) / (mBeamPosWeight + w);
mBeamPos[1] = (mBeamPos[1] * mBeamPosWeight + vertex.getY() * w) / (mBeamPosWeight + w);
mBeamPosWeight += w;
}
}
mROFramesPV.push_back(mPrimaryVertices.size()); // current rof must have number of vertices up to present
for (auto& vertex : futureVertices) {
mPrimaryVertices.emplace_back(vertex);
mTotVertPerIteration[iteration]++;
}
}

template <int nLayers>
int TimeFrame<nLayers>::loadROFrameData(gsl::span<o2::itsmft::ROFRecord> rofs,
gsl::span<const itsmft::CompClusterExt> clusters,
Expand Down Expand Up @@ -395,7 +362,7 @@ void TimeFrame<nLayers>::initialise(const int iteration, const TrackingParameter
if (iLayer < (int)mCells.size()) {
deepVectorClear(mCells[iLayer]);
deepVectorClear(mTrackletsLookupTable[iLayer]);
mTrackletsLookupTable[iLayer].resize(mClusters[iLayer + 1].size(), 0);
mTrackletsLookupTable[iLayer].resize(mClusters[iLayer + 1].size() + 1, 0);
deepVectorClear(mCellLabels[iLayer]);
}

Expand Down Expand Up @@ -686,8 +653,8 @@ void TimeFrame<nLayers>::wipe()
deepVectorClear(mCellsLookupTable);
deepVectorClear(mTotVertPerIteration);
deepVectorClear(mPrimaryVertices);
deepVectorClear(mROFramesPV);
deepVectorClear(mClusters);
deepVectorClear(mTrackletsLookupTable);
deepVectorClear(mTrackingFrameInfo);
deepVectorClear(mClusterExternalIndices);
deepVectorClear(mROFramesClusters);
Expand Down
4 changes: 3 additions & 1 deletion Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ void Tracker::clustersToTracks(const LogFunc& logger, const LogFunc& error)
int maxNvertices{-1};
if (mTrkParams[0].PerPrimaryVertexProcessing) {
for (int iROF{0}; iROF < mTimeFrame->getNrof(); ++iROF) {
maxNvertices = std::max(maxNvertices, (int)mTimeFrame->getPrimaryVertices(iROF).size());
int minRof = o2::gpu::CAMath::Max(0, iROF - mTrkParams[0].DeltaROF);
int maxRof = o2::gpu::CAMath::Min(mTimeFrame->getNrof(), iROF + mTrkParams[0].DeltaROF);
maxNvertices = std::max(maxNvertices, (int)mTimeFrame->getPrimaryVertices(minRof, maxRof).size());
}
}

Expand Down
Loading