13#ifndef TRACKINGITSU_INCLUDE_TIMEFRAME_H_
14#define TRACKINGITSU_INCLUDE_TIMEFRAME_H_
54class TopologyDictionary;
67template <
int nLayers = 7>
82 void addPrimaryVertices(
const gsl::span<const Vertex>& vertices,
const int rofId,
const int iteration);
90 gsl::span<const itsmft::CompClusterExt>
clusters,
91 gsl::span<const unsigned char>::iterator& pattIt,
103 void setBeamPosition(
const float x,
const float y,
const float s2,
const float base = 50.f,
const float systematic = 0.f)
105 isBeamPositionOverridden =
true;
106 resetBeamXY(
x,
y, s2 / o2::gpu::CAMath::Sqrt(base * base + systematic));
152 mTotVertPerIteration.resize(1);
186 void setMemoryPool(std::shared_ptr<BoundedMemoryResource>& pool);
201 auto&
getLines(
int rofId) {
return mLines[rofId]; }
204 return std::accumulate(mLines.begin(), mLines.end(), 0, [](
int sum,
const auto& l) { return sum + l.size(); });
221 const unsigned long long&
getRoadLabel(
int i)
const {
return mRoadLabels[
i].first; }
225 void setROFMask(
const std::vector<uint8_t>& rofMask) { mROFMask = rofMask; }
228 int hasBogusClusters()
const {
return std::accumulate(mBogusClusters.begin(), mBogusClusters.end(), 0); }
236 template <
typename... T>
238 template <
typename... T>
283 LOGP(
debug,
"Setting timeFrame allocator to external");
287 LOGP(fatal,
"External allocator is currently only supported for GPU");
295 std::vector<bounded_vector<CellSeed>>
mCells;
296 std::vector<bounded_vector<o2::track::TrackParCovF>>
mCellSeeds;
299 std::vector<bounded_vector<TrackITSExt>>
mTracks;
311 unsigned int mNTotalLowPtVertices = 0;
312 int mBeamPosWeight = 0;
313 std::array<float, 2> mBeamPos = {0.f, 0.f};
314 bool isBeamPositionOverridden =
false;
315 std::array<float, nLayers> mMinR;
316 std::array<float, nLayers> mMaxR;
322 std::vector<uint8_t> mROFMask;
324 std::vector<bounded_vector<MCCompLabel>> mTrackletLabels;
325 std::vector<bounded_vector<MCCompLabel>> mCellLabels;
326 std::vector<bounded_vector<int>> mCellsNeighboursLUT;
327 std::vector<bounded_vector<MCCompLabel>> mTracksLabel;
335 std::vector<bounded_vector<int>> mNTrackletsPerROF;
336 std::vector<bounded_vector<Line>> mLines;
337 std::vector<bounded_vector<ClusterLines>> mTrackletClusters;
338 std::array<bounded_vector<int>, 2> mTrackletsIndexROF;
339 std::vector<bounded_vector<MCCompLabel>> mLinesLabels;
340 std::vector<std::pair<MCCompLabel, float>> mVerticesMCRecInfo;
341 std::array<uint32_t, 2> mTotalTracklets = {0, 0};
342 unsigned int mNoVertexROF = 0;
343 bounded_vector<int> mTotVertPerIteration;
346 std::shared_ptr<BoundedMemoryResource> mMemoryPool;
349template <
int nLayers>
352 if (mPrimaryVertices.empty()) {
355 const int start = mROFramesPV[rofId];
356 const int stop_idx = rofId >= mNrof - 1 ? mNrof : rofId + 1;
357 int delta = mMultiplicityCutMask[rofId] ? mROFramesPV[stop_idx] -
start : 0;
358 return {&mPrimaryVertices[
start],
static_cast<gsl::span<const Vertex>::size_type
>(delta)};
361template <
int nLayers>
364 const int start = mROFramesPV[rofId];
365 const int stop_idx = rofId >= mNrof - 1 ? mNrof : rofId + 1;
366 int delta = mMultiplicityCutMask[rofId] ? mROFramesPV[stop_idx] -
start : 0;
367 return {&(mVerticesMCRecInfo[
start]),
static_cast<gsl::span<const std::pair<MCCompLabel, float>
>::size_type>(delta)};
370template <
int nLayers>
373 if (mPrimaryVertices.empty()) {
376 return {&mPrimaryVertices[mROFramesPV[romin]],
static_cast<gsl::span<const Vertex>::size_type
>(mROFramesPV[romax + 1] - mROFramesPV[romin])};
379template <
int nLayers>
382 const int start = mROFramesPV[rofId];
383 const int stop_idx = rofId >= mNrof - 1 ? mNrof : rofId + 1;
384 int delta = mMultiplicityCutMask[rofId] ? mROFramesPV[stop_idx] -
start : 0;
385 return {&(mPValphaX[
start]),
static_cast<gsl::span<const std::array<float, 2>
>::size_type>(delta)};
388template <
int nLayers>
391 return rofId < 0 ? mPrimaryVertices.size() : mROFramesPV[rofId + 1] - mROFramesPV[rofId];
394template <
int nLayers>
402template <
int nLayers>
405 return {&mROFramesClusters[layerId][0],
static_cast<gsl::span<const int>::size_type
>(mROFramesClusters[layerId].size())};
408template <
int nLayers>
411 if (rofId < 0 || rofId >= mNrof) {
414 int startIdx{mROFramesClusters[layerId][rofId]};
415 return {&mClusters[layerId][startIdx],
static_cast<gsl::span<Cluster>::size_type
>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
418template <
int nLayers>
421 if (rofId < 0 || rofId >= mNrof) {
424 int startIdx{mROFramesClusters[layerId][rofId]};
425 return {&mClusters[layerId][startIdx],
static_cast<gsl::span<const Cluster>::size_type
>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
428template <
int nLayers>
431 if (rofId < 0 || rofId >= mNrof) {
434 int startIdx{mROFramesClusters[layerId][rofId]};
435 return {&mUsedClusters[layerId][startIdx],
static_cast<gsl::span<uint8_t>::size_type
>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
438template <
int nLayers>
441 if (rofId < 0 || rofId >= mNrof) {
444 int startIdx{mROFramesClusters[layerId][rofId]};
445 return {&mUsedClusters[layerId][startIdx],
static_cast<gsl::span<const uint8_t>::size_type
>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
448template <
int nLayers>
451 if (rofMin < 0 || rofMin >= mNrof) {
454 int startIdx{mROFramesClusters[layerId][rofMin]};
455 int endIdx{mROFramesClusters[layerId][o2::gpu::CAMath::Min(rofMin +
range, mNrof)]};
456 return {&mClusters[layerId][startIdx],
static_cast<gsl::span<Cluster>::size_type
>(endIdx - startIdx)};
459template <
int nLayers>
462 int chkdRange{o2::gpu::CAMath::Min(
range, mNrof - rofMin)};
463 return {&mROFramesClusters[layerId][rofMin],
static_cast<gsl::span<int>::size_type
>(chkdRange)};
466template <
int nLayers>
469 int chkdRange{o2::gpu::CAMath::Min(
range, mNrof - rofMin)};
470 return {&mNClustersPerROF[layerId][rofMin],
static_cast<gsl::span<int>::size_type
>(chkdRange)};
473template <
int nLayers>
476 int startIdx{rofMin};
477 int endIdx{o2::gpu::CAMath::Min(rofMin +
range, mNrof)};
478 return mROFramesClusters[layerId][endIdx] - mROFramesClusters[layerId][startIdx];
481template <
int nLayers>
484 const int iTableSize{mIndexTableUtils.getNphiBins() * mIndexTableUtils.getNzBins() + 1};
485 int chkdRange{o2::gpu::CAMath::Min(
range, mNrof - rofMin)};
486 return {&mIndexTables[layerId][rofMin * iTableSize],
static_cast<gsl::span<int>::size_type
>(chkdRange * iTableSize)};
489template <
int nLayers>
492 return std::lower_bound(mROFramesClusters[iLayer].begin(), mROFramesClusters[iLayer].
end(), iCluster + 1) - mROFramesClusters[iLayer].begin() - 1;
495template <
int nLayers>
498 if (rofId < 0 || rofId >= mNrof) {
501 int startIdx{mROFramesClusters[layerId][rofId]};
502 return {&mUnsortedClusters[layerId][startIdx],
static_cast<gsl::span<Cluster>::size_type
>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
505template <
int nLayers>
508 if (rofId < 0 || rofId >= mNrof) {
511 return {&mIndexTables[
layer][rofId * (mIndexTableUtils.getNphiBins() * mIndexTableUtils.getNzBins() + 1)],
512 static_cast<gsl::span<int>::size_type
>(mIndexTableUtils.getNphiBins() * mIndexTableUtils.getNzBins() + 1)};
515template <
int nLayers>
516template <
typename... T>
519 mUnsortedClusters[
layer].emplace_back(std::forward<T>(
values)...);
522template <
int nLayers>
523template <
typename... T>
526 mTrackingFrameInfo[
layer].emplace_back(std::forward<T>(
values)...);
529template <
int nLayers>
532 return {&mUsedClusters[
layer][0],
static_cast<gsl::span<uint8_t>::size_type
>(mUsedClusters[
layer].size())};
535template <
int nLayers>
539 mRoadLabels.resize(mRoads.size());
542template <
int nLayers>
545 mRoadLabels[
i].first = lab;
546 mRoadLabels[
i].second = fake;
549template <
int nLayers>
552 if (rofId < 0 || rofId >= mNrof) {
555 auto startIdx{mROFramesClusters[1][rofId]};
556 return {&mNTrackletsPerCluster[combId][startIdx],
static_cast<gsl::span<int>::size_type
>(mROFramesClusters[1][rofId + 1] - startIdx)};
559template <
int nLayers>
562 if (rofId < 0 || rofId >= mNrof) {
565 auto clusStartIdx{mROFramesClusters[1][rofId]};
567 return {&mNTrackletsPerClusterSum[combId][clusStartIdx],
static_cast<gsl::span<int>::size_type
>(mROFramesClusters[1][rofId + 1] - clusStartIdx)};
570template <
int nLayers>
573 if (rofId < 0 || rofId >= mNrof) {
576 auto startIdx{mNTrackletsPerROF[combId][rofId]};
577 return {&mTracklets[combId][startIdx],
static_cast<gsl::span<Tracklet>::size_type
>(mNTrackletsPerROF[combId][rofId + 1] - startIdx)};
580template <
int nLayers>
583 if (rofId < 0 || rofId >= mNrof) {
586 auto startIdx{mNTrackletsPerROF[combId][rofId]};
587 return {&mTracklets[combId][startIdx],
static_cast<gsl::span<Tracklet>::size_type
>(mNTrackletsPerROF[combId][rofId + 1] - startIdx)};
590template <
int nLayers>
593 if (rofId < 0 || rofId >= mNrof || !hasMCinformation()) {
596 auto startIdx{mNTrackletsPerROF[combId][rofId]};
597 return {&mTrackletLabels[combId][startIdx],
static_cast<gsl::span<Tracklet>::size_type
>(mNTrackletsPerROF[combId][rofId + 1] - startIdx)};
600template <
int nLayers>
603 size_t totalClusters{0};
604 for (
const auto&
clusters : mUnsortedClusters) {
607 return int(totalClusters);
610template <
int nLayers>
614 for (
const auto&
layer : mClusters) {
620template <
int nLayers>
624 for (
const auto&
layer : mCells) {
625 nCells +=
layer.size();
630template <
int nLayers>
634 for (
const auto&
layer : mTracklets) {
635 nTracklets +=
layer.size();
640template <
int nLayers>
644 for (
const auto& l : mCellsNeighbours) {
650template <
int nLayers>
654 for (
const auto& t : mTracks) {
660template <
int nLayers>
664 for (
const auto&
layer : mUsedClusters) {
670template <
int nLayers>
673 int rofId =
vertex.getTimeStamp().getTimeStamp();
674 mPrimaryVertices.insert(mPrimaryVertices.begin() + mROFramesPV[rofId],
vertex);
675 for (
int i = rofId + 1;
i < mROFramesPV.size(); ++
i) {
678 mTotVertPerIteration[iteration]++;
Definition of a container to keep Monte Carlo truth external to simulation objects.
Definition of the ITS track.
HMPID cluster implementation.
float sum(float s, o2::dcs::DataPointValue v)
GLenum GLsizei GLsizei GLint * values
GLenum GLuint GLint GLint layer
GLubyte GLubyte GLubyte GLubyte w
void deepVectorClear(std::vector< T > &vec)
std::pmr::vector< T > bounded_vector
o2::dataformats::Vertex< o2::dataformats::TimeStamp< int > > Vertex
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
auto & getPositionResolutions()
void addTrackingFrameInfoToLayer(int layer, T &&... args)
void setClusterSize(const bounded_vector< uint8_t > &v)
IndexTableUtils mIndexTableUtils
void checkTrackletLUTs()
Debug and printing.
gsl::span< const Tracklet > getFoundTracklets(int rofId, int combId) const
bool checkMemory(unsigned long max)
int getClusterROF(int iLayer, int iCluster)
auto & getCellsLabel(int layer)
void printTrackletLUTonLayer(int i)
bool isClusterUsed(int layer, int clusterId) const
std::vector< bounded_vector< float > > mCellSeedsChi2
void initialise(const int iteration, const TrackingParameters &trkParam, const int maxLayers=7, bool resetVertices=true)
float getMSangle(int layer) const
std::vector< bounded_vector< int > > mCellsLookupTable
bool hasMCinformation() const
auto & getIndexTableWhole(int layerId)
std::array< bounded_vector< int >, 2 > mNTrackletsPerClusterSum
gsl::span< const MCCompLabel > getClusterLabels(int layerId, const int clId) const
auto & getTracks(int rofId)
size_t getNumberOfTracks() const
unsigned int & getNoVertexROF()
ExternalAllocator * mAllocator
int getTotalClustersPerROFrange(int rofMin, int range, int layerId) const
int getNumberOfTracklets() const
auto & getTrackletsLabel(int layer)
std::vector< bounded_vector< Tracklet > > mTracklets
gsl::span< const std::pair< MCCompLabel, float > > getPrimaryVerticesMCRecInfo(const int rofId) const
void computeTracletsPerClusterScans()
gsl::span< uint8_t > getUsedClustersROF(int rofId, int layerId)
const TrackingFrameInfo & getClusterTrackingFrameInfo(int layerId, const Cluster &cl) const
int getClusterExternalIndex(int layerId, const int clId) const
std::vector< bounded_vector< o2::track::TrackParCovF > > mCellSeeds
void resetBeamXY(const float x, const float y, const float w=0)
void addPrimaryVerticesInROF(const bounded_vector< Vertex > &vertices, const int rofId, const int iteration)
gsl::span< const int > getIndexTablePerROFrange(int rofMin, int range, int layerId) const
gsl::span< const Cluster > getClustersOnLayer(int rofId, int layerId) const
bounded_vector< int > mROFramesPV
std::array< float, 2 > & getBeamXY()
std::array< bounded_vector< int >, nLayers > mClusterExternalIndices
bool getExtAllocator() const
bool isRoadFake(int i) const
gsl::span< const Vertex > getPrimaryVertices(int romin, int romax) const
void printSliceInfo(const int, const int)
int getNLinesTotal() const
auto & getTrackletsLookupTable()
bounded_vector< Vertex > mPrimaryVertices
int getROFCutAllMult() const
int getROFCutVertexMult() const
std::array< bounded_vector< int >, nLayers > mROFramesClusters
std::vector< uint8_t > mMultiplicityCutMask
float getPhiCut(int layer) const
int getTotalClusters() const
gsl::span< int > getExclusiveNTrackletsCluster(int rofId, int combId)
void setMultiplicityCutMask(const std::vector< uint8_t > &cutMask)
auto & getTrackletClusters(int rofId)
std::vector< bounded_vector< int > > mTrackletsLookupTable
int mNExtendedUsedClusters
gsl::span< const Cluster > getUnsortedClustersOnLayer(int rofId, int layerId) const
const o2::base::PropagatorImpl< float > * getDevicePropagator() const
void computeTrackletsPerROFScans()
gsl::span< const std::array< float, 2 > > getPrimaryVerticesXAlpha(int rofId) const
void setExtAllocator(bool ext)
size_t getNumberOfUsedClusters() const
gsl::span< int > getIndexTable(int rofId, int layerId)
void addPrimaryVerticesLabelsInROF(const bounded_vector< std::pair< MCCompLabel, float > > &labels, const int rofId)
auto & getCellsLookupTable()
void setBeamPosition(const float x, const float y, const float s2, const float base=50.f, const float systematic=0.f)
bounded_vector< Road< nLayers - 2 > > mRoads
std::array< bounded_vector< int >, nLayers > mIndexTables
const auto & getTrackingFrameInfoOnLayer(int layerId) const
auto & getTotVertIteration()
float getMaxR(int layer) const
auto & getVerticesMCRecInfo()
void insertPastVertex(const Vertex &vertex, const int refROFId)
gsl::span< const int > getROFramesClustersPerROFrange(int rofMin, int range, int layerId) const
float getPositionResolution(int layer) const
std::vector< bounded_vector< TrackITSExt > > mTracks
int getPrimaryVerticesNum(int rofId=-1) const
void setROFMask(const std::vector< uint8_t > &rofMask)
gsl::span< unsigned char > getUsedClusters(const int layer)
void addClusterExternalIndexToLayer(int layer, const int idx)
void addPrimaryVerticesLabels(bounded_vector< std::pair< MCCompLabel, float > > &labels)
gsl::span< const MCCompLabel > getLabelsFoundTracklets(int rofId, int combId) const
int loadROFrameData(const o2::itsmft::ROFRecord &rof, gsl::span< const itsmft::Cluster > clusters, const dataformats::MCTruthContainer< MCCompLabel > *mcLabels=nullptr)
std::array< bounded_vector< int >, 2 > mNTrackletsPerCluster
int getNumberOfCells() const
void setExternalAllocator(ExternalAllocator *allocator)
gsl::span< const Cluster > getClustersPerROFrange(int rofMin, int range, int layerId) const
gsl::span< const Vertex > getPrimaryVertices(int rofId) const
void fillPrimaryVerticesXandAlpha()
const dataformats::MCTruthContainer< MCCompLabel > * mClusterLabels
void initialiseRoadLabels()
auto getNumberOfUsedExtendedClusters() const
void setMemoryPool(std::shared_ptr< BoundedMemoryResource > &pool)
memory management
gsl::span< Cluster > getClustersOnLayer(int rofId, int layerId)
auto & getLinesLabel(const int rofId)
int getSortedStartIndex(const int rofId, const int layer) const
gsl::span< const MCCompLabel > getClusterLabels(int layerId, const Cluster &cl) const
const Vertex & getPrimaryVertex(const int ivtx) const
virtual void setDevicePropagator(const o2::base::PropagatorImpl< float > *)
std::vector< bounded_vector< int > > mCellsNeighbours
std::vector< bounded_vector< CellSeed > > mCells
gsl::span< Tracklet > getFoundTracklets(int rofId, int combId)
std::array< bounded_vector< Cluster >, nLayers > mUnsortedClusters
void addClusterToLayer(int layer, T &&... args)
unsigned long getArtefactsMemory() const
float getMinR(int layer) const
std::array< bounded_vector< uint8_t >, nLayers > mUsedClusters
gsl::span< const int > getROFrameClusters(int layerId) const
void removePrimaryVerticesInROf(const int rofId)
const o2::base::PropagatorImpl< float > * mPropagatorDevice
void printCellLUTonLayer(int i)
int getNumberOfNeighbours() const
void printArtefactsMemory() const
auto & getTracksLabel(const int rofId)
std::array< bounded_vector< int >, nLayers > mNClustersPerROF
int getROFCutClusterMult() const
ROF cuts.
std::array< bounded_vector< TrackingFrameInfo >, nLayers > mTrackingFrameInfo
gsl::span< int > getNTrackletsCluster(int rofId, int combId)
auto & getCellsNeighbours()
void markUsedCluster(int layer, int clusterId)
std::array< bounded_vector< Cluster >, nLayers > mClusters
uint32_t getTotalTrackletsTF(const int iLayer)
auto getNumberOfExtendedTracks() const
int hasBogusClusters() const
auto & getUnsortedClusters()
auto & getCellsNeighboursLUT()
int & getNTrackletsROF(int rofId, int combId)
int getNumberOfClusters() const
void setRoadLabel(int i, const unsigned long long &lab, bool fake)
auto & getMemoryPool() const noexcept
auto & getLines(int rofId)
int getClusterSize(int clusterId) const
void addPrimaryVertices(const bounded_vector< Vertex > &vertices)
gsl::span< const uint8_t > getUsedClustersROF(int rofId, int layerId) const
gsl::span< const int > getNClustersROFrange(int rofMin, int range, int layerId) const
int getSortedIndex(int rofId, int layer, int idx) const
const unsigned long long & getRoadLabel(int i) const
std::vector< Cluster > clusters