13#ifndef TRACKINGITSU_INCLUDE_TIMEFRAME_H_
14#define TRACKINGITSU_INCLUDE_TIMEFRAME_H_
52class TopologyDictionary;
88 gsl::span<const itsmft::CompClusterExt>
clusters,
89 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)
106 resetBeamXY(
x,
y, s2 / o2::gpu::CAMath::Sqrt((base * base) + systematic));
186 void initTrackerTopologies(gsl::span<const TrackingParameters> trkParams,
const int maxLayers = NLayers);
217 void setMemoryPool(std::shared_ptr<BoundedMemoryResource> pool);
260 template <
typename... T>
262 template <
typename... T>
270 std::array<const dataformats::MCTruthContainer<MCCompLabel>*, NLayers>
mClusterLabels{
nullptr};
280 std::vector<bounded_vector<CellSeed>>
mCells;
292 virtual bool isGPU() const noexcept {
return false; }
293 virtual const char*
getName() const noexcept {
return "CPU"; }
319 std::vector<bounded_vector<Line>>
mLines;
347template <
int NLayers>
350 if (rofId < 0 || rofId >= getNrof(
layer)) {
353 const auto&
entry = mROFVertexLookupTableView.getVertices(
layer, rofId);
354 return {&mPrimaryVertices[
entry.getFirstEntry()],
static_cast<gsl::span<const Vertex>::size_type
>(
entry.getEntries())};
357template <
int NLayers>
365template <
int NLayers>
368 return {&mROFramesClusters[layerId][0],
static_cast<gsl::span<const int>::size_type
>(mROFramesClusters[layerId].size())};
371template <
int NLayers>
374 if (rofId < 0 || rofId >= getNrof(layerId)) {
377 int startIdx{mROFramesClusters[layerId][rofId]};
378 return {&mClusters[layerId][startIdx],
static_cast<gsl::span<Cluster>::size_type
>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
381template <
int NLayers>
384 if (rofId < 0 || rofId >= getNrof(layerId)) {
387 int startIdx{mROFramesClusters[layerId][rofId]};
388 return {&mClusters[layerId][startIdx],
static_cast<gsl::span<const Cluster>::size_type
>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
391template <
int NLayers>
394 if (rofId < 0 || rofId >= getNrof(layerId)) {
397 int startIdx{mROFramesClusters[layerId][rofId]};
398 return {&mUsedClusters[layerId][startIdx],
static_cast<gsl::span<uint8_t>::size_type
>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
401template <
int NLayers>
404 if (rofId < 0 || rofId >= getNrof(layerId)) {
407 int startIdx{mROFramesClusters[layerId][rofId]};
408 return {&mUsedClusters[layerId][startIdx],
static_cast<gsl::span<const uint8_t>::size_type
>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
411template <
int NLayers>
414 if (rofMin < 0 || rofMin >= getNrof(layerId)) {
417 int startIdx{mROFramesClusters[layerId][rofMin]};
418 int endIdx{mROFramesClusters[layerId][o2::gpu::CAMath::Min(rofMin +
range, getNrof(layerId))]};
419 return {&mClusters[layerId][startIdx],
static_cast<gsl::span<Cluster>::size_type
>(endIdx - startIdx)};
422template <
int NLayers>
425 int chkdRange{o2::gpu::CAMath::Min(
range, getNrof(layerId) - rofMin)};
426 return {&mROFramesClusters[layerId][rofMin],
static_cast<gsl::span<int>::size_type
>(chkdRange)};
429template <
int NLayers>
432 int chkdRange{o2::gpu::CAMath::Min(
range, getNrof(layerId) - rofMin)};
433 return {&mNClustersPerROF[layerId][rofMin],
static_cast<gsl::span<int>::size_type
>(chkdRange)};
436template <
int NLayers>
439 int startIdx{rofMin};
440 int endIdx{o2::gpu::CAMath::Min(rofMin +
range, getNrof(layerId))};
441 return mROFramesClusters[layerId][endIdx] - mROFramesClusters[layerId][startIdx];
444template <
int NLayers>
447 return std::lower_bound(mROFramesClusters[iLayer].begin(), mROFramesClusters[iLayer].
end(), iCluster + 1) - mROFramesClusters[iLayer].begin() - 1;
450template <
int NLayers>
453 if (rofId < 0 || rofId >= getNrof(layerId)) {
456 int startIdx{mROFramesClusters[layerId][rofId]};
457 return {&mUnsortedClusters[layerId][startIdx],
static_cast<gsl::span<Cluster>::size_type
>(mROFramesClusters[layerId][rofId + 1] - startIdx)};
460template <
int NLayers>
463 if (rofId < 0 || rofId >= getNrof(
layer)) {
466 const int tableSize = mIndexTableUtils.getNphiBins() * mIndexTableUtils.getNzBins() + 1;
467 return {&mIndexTables[
layer][rofId * tableSize],
static_cast<gsl::span<int>::size_type
>(tableSize)};
470template <
int NLayers>
471template <
typename... T>
474 mUnsortedClusters[
layer].emplace_back(std::forward<T>(
values)...);
477template <
int NLayers>
478template <
typename... T>
481 mTrackingFrameInfo[
layer].emplace_back(std::forward<T>(
values)...);
484template <
int NLayers>
487 return {&mUsedClusters[
layer][0],
static_cast<gsl::span<uint8_t>::size_type
>(mUsedClusters[
layer].size())};
490template <
int NLayers>
493 if (rofId < 0 || rofId >= getNrof(1)) {
496 auto startIdx{mROFramesClusters[1][rofId]};
497 return {&mNTrackletsPerCluster[combId][startIdx],
static_cast<gsl::span<int>::size_type
>(mROFramesClusters[1][rofId + 1] - startIdx)};
500template <
int NLayers>
503 if (rofId < 0 || rofId >= getNrof(1)) {
506 auto clusStartIdx{mROFramesClusters[1][rofId]};
508 return {&mNTrackletsPerClusterSum[combId][clusStartIdx],
static_cast<gsl::span<int>::size_type
>(mROFramesClusters[1][rofId + 1] - clusStartIdx)};
511template <
int NLayers>
514 if (rofId < 0 || rofId >= getNrof(1) || mTracklets[combId].
empty()) {
517 auto startIdx{mNTrackletsPerROF[combId][rofId]};
518 return {&mTracklets[combId][startIdx],
static_cast<gsl::span<Tracklet>::size_type
>(mNTrackletsPerROF[combId][rofId + 1] - startIdx)};
521template <
int NLayers>
524 if (rofId < 0 || rofId >= getNrof(1)) {
527 auto startIdx{mNTrackletsPerROF[combId][rofId]};
528 return {&mTracklets[combId][startIdx],
static_cast<gsl::span<Tracklet>::size_type
>(mNTrackletsPerROF[combId][rofId + 1] - startIdx)};
531template <
int NLayers>
534 if (rofId < 0 || rofId >= getNrof(1) || !hasMCinformation()) {
537 auto startIdx{mNTrackletsPerROF[combId][rofId]};
538 return {&mTrackletLabels[combId][startIdx],
static_cast<gsl::span<Tracklet>::size_type
>(mNTrackletsPerROF[combId][rofId + 1] - startIdx)};
541template <
int NLayers>
544 size_t totalClusters{0};
545 for (
const auto&
clusters : mUnsortedClusters) {
548 return int(totalClusters);
551template <
int NLayers>
555 for (
const auto&
layer : mClusters) {
561template <
int NLayers>
565 for (
const auto&
layer : mCells) {
566 nCells +=
layer.size();
571template <
int NLayers>
574 size_t nTracklets{0};
575 for (
const auto&
layer : mTracklets) {
576 nTracklets +=
layer.size();
581template <
int NLayers>
585 for (
const auto& l : mCellsNeighbours) {
591template <
int NLayers>
594 return mTracks.size();
597template <
int NLayers>
601 for (
const auto&
layer : mUsedClusters) {
Definition of a container to keep Monte Carlo truth external to simulation objects.
Definition of the ITS track.
HMPID cluster implementation.
GLboolean GLboolean GLboolean b
GLenum GLsizei GLsizei GLint * values
GLuint GLsizei const GLchar * label
GLenum GLuint GLint GLint layer
GLboolean GLboolean GLboolean GLboolean a
GLubyte GLubyte GLubyte GLubyte w
constexpr int UnusedIndex
std::pmr::vector< T > bounded_vector
std::pair< o2::MCCompLabel, float > VertexLabel
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
ROFVertexLookupTable< NLayers > ROFVertexLookupTableN
virtual size_t getNumberOfCells() const
void prepareClusters(const TrackingParameters &trkParam, const int maxLayers=NLayers)
std::vector< TrackingTopologyN > mTrackerTopologies
std::vector< bounded_vector< Line > > mLines
std::vector< bounded_vector< int > > mTrackletsLookupTable
bounded_vector< int > mBogusClusters
std::array< float, NLayers > mMaxR
const TrackingFrameInfo & getClusterTrackingFrameInfo(int layerId, const Cluster &cl) const
virtual void setDevicePropagator(const o2::base::PropagatorImpl< float > *)
const auto & getROFVertexLookupTableView() const
size_t getNumberOfUsedClusters() const
std::array< bounded_vector< int >, NLayers > mIndexTables
ROFMaskTableN mUPCCutMask
gsl::span< const Cluster > getUnsortedClustersOnLayer(int rofId, int layerId) const
std::array< bounded_vector< int >, 2 > mNTrackletsPerClusterSum
size_t getNumberOfClusters() const
gsl::span< const Cluster > getClustersOnLayer(int rofId, int layerId) const
void initDefaultTrackingTopology(const TrackingParameters &trkParam, const int maxLayers=NLayers)
auto & getPositionResolutions()
bounded_vector< MCCompLabel > mTracksLabel
void useMultiplictyMask() noexcept
bool checkMemory(unsigned long max)
const auto & getTrackingFrameInfoOnLayer(int layerId) const
std::array< uint32_t, 2 > mTotalTracklets
void setMemoryPool(std::shared_ptr< BoundedMemoryResource > pool)
memory management
size_t getNumberOfTracks() const
void resetBeamXY(const float x, const float y, const float w=0)
void computeTracletsPerClusterScans()
auto & getTrackletsLabel(int layer)
ROFOverlapTableN mROFOverlapTable
std::shared_ptr< BoundedMemoryResource > mExtMemoryPool
bounded_vector< TrackITSExt > mTracks
auto getFrameworkAllocator()
virtual size_t getNumberOfNeighbours() const
ROFVertexLookupTableN::View mROFVertexLookupTableView
gsl::span< Tracklet > getFoundTracklets(int rofId, int combId)
void initVertexingTopology(const TrackingParameters &trkParam)
gsl::span< uint8_t > getUsedClustersROF(int rofId, int layerId)
std::array< const dataformats::MCTruthContainer< MCCompLabel > *, NLayers > mClusterLabels
std::vector< bounded_vector< CellSeed > > mCells
gsl::span< const MCCompLabel > getLabelsFoundTracklets(int rofId, int combId) const
void printArtefactsMemory() const
void useUPCMask() noexcept
ROFOverlapTableN::View mROFOverlapTableView
gsl::span< const Tracklet > getFoundTracklets(int rofId, int combId) const
const Vertex & getPrimaryVertex(const int ivtx) const
virtual const char * getName() const noexcept
auto & getTransitionPhiCuts()
const o2::base::PropagatorImpl< float > * getDevicePropagator() const
gsl::span< const Cluster > getClustersPerROFrange(int rofMin, int range, int layerId) const
int getClusterSize(int layer, int clusterId) const
void updateROFVertexLookupTable()
void setFrameworkAllocator(ExternalAllocator *ext)
auto & getCellsNeighboursTopology()
void setClusterSize(int layer, bounded_vector< uint8_t > &v)
void initialise(const TrackingParameters &trkParam, const int maxLayers=NLayers, const int iteration=constants::UnusedIndex)
const auto & getIndexTableUtils() const
void addPrimaryVertexLabel(const VertexLabel &label)
bool hasFrameworkAllocator() const noexcept
gsl::span< const int > getNClustersROFrange(int rofMin, int range, int layerId) const
int getSortedStartIndex(const int rofId, const int layer) const
auto & getUnsortedClusters()
const auto & getROFMaskView() const
void prepareROFrameData(gsl::span< const itsmft::CompClusterExt > clusters, int layer)
gsl::span< unsigned char > getUsedClusters(const int layer)
TrackingTopologyN mDefaultTrackingTopology
auto & getLines(int rofId)
void addClusterExternalIndexToLayer(int layer, const int idx)
virtual bool isGPU() const noexcept
auto & getTransitionMSAngles()
const auto & getPrimaryVertices() const
void markUsedCluster(int layer, int clusterId)
gsl::span< int > getIndexTable(int rofId, int layerId)
void computeTrackletsPerROFScans()
const o2::base::PropagatorImpl< float > * mPropagatorDevice
std::vector< bounded_vector< MCCompLabel > > mLinesLabels
std::array< bounded_vector< TrackingFrameInfo >, NLayers > mTrackingFrameInfo
void addPrimaryVertex(const Vertex &vertex)
int getNrof(int layer) const
int hasBogusClusters() const
std::array< bounded_vector< uint8_t >, NLayers > mUsedClusters
void loadROFrameData(gsl::span< const o2::itsmft::ROFRecord > rofs, gsl::span< const itsmft::CompClusterExt > clusters, gsl::span< const unsigned char >::iterator &pattIt, const itsmft::TopologyDictionary *dict, int layer, const dataformats::MCTruthContainer< MCCompLabel > *mcLabels=nullptr)
std::vector< bounded_vector< int > > mCellsNeighbours
float getTransitionMSAngle(int transitionId) const
std::array< float, 2 > & getBeamXY()
auto & getCellsNeighbours()
void addTrackingFrameInfoToLayer(int layer, T &&... args)
bounded_vector< float > mTransitionMSAngles
std::vector< bounded_vector< MCCompLabel > > mTrackletLabels
PV x and alpha for track propagation.
ROFMaskTableN::View mROFMaskView
void resetROFrameData(int iLayer)
void initTrackerTopologies(gsl::span< const TrackingParameters > trkParams, const int maxLayers=NLayers)
bounded_vector< float > mTransitionPhiCuts
TrackingTopologyN mVertexingTopology
int getSortedIndex(int rofId, int layer, int idx) const
auto & getCellsLookupTable()
const auto & getTrackerTopologies() const
std::array< float, 2 > mBeamPos
std::vector< bounded_vector< int > > mCellsNeighboursTopology
void setUPCCutMask(ROFMaskTableN cutMask)
void setROFVertexLookupTable(ROFVertexLookupTableN table)
unsigned int mNTotalLowPtVertices
int getTotalClusters() const
virtual ~TimeFrame()=default
TrackingTopologyN::View mTrackingTopologyView
uint32_t getTotalTrackletsTF(const int iLayer)
float getTransitionPhiCut(int transitionId) const
std::vector< bounded_vector< int > > mNTrackletsPerROF
auto & getMemoryPool() const noexcept
gsl::span< const int > getROFramesClustersPerROFrange(int rofMin, int range, int layerId) const
ExternalAllocator * mExternalAllocator
State if memory will be externally managed by the GPU framework.
std::array< bounded_vector< int >, NLayers > mNClustersPerROF
int getClusterROF(int iLayer, int iCluster)
int getTotalClustersPerROFrange(int rofMin, int range, int layerId) const
auto getPrimaryVerticesNum()
std::array< bounded_vector< int >, 2 > mTrackletsIndexROF
bounded_vector< float > mPositionResolution
std::array< bounded_vector< Cluster >, NLayers > mUnsortedClusters
std::vector< bounded_vector< Tracklet > > mTracklets
std::vector< bounded_vector< MCCompLabel > > mCellLabels
const auto & getTrackingTopologyView() const
auto & getLinesLabel(const int rofId)
void setBeamPosition(const float x, const float y, const float s2, const float base=50.f, const float systematic=0.f)
std::vector< bounded_vector< ClusterLines > > mTrackletClusters
ROFMaskTableN mMultiplicityCutMask
auto & getPrimaryVertices()
std::vector< bounded_vector< int > > mCellsNeighboursLUT
gsl::span< const MCCompLabel > getClusterLabels(int layerId, const int clId) const
bounded_vector< VertexLabel > mPrimaryVerticesLabels
gsl::span< const uint8_t > getUsedClustersROF(int rofId, int layerId) const
virtual size_t getNumberOfTracklets() const
bool hasMCinformation() const
TrackingTopology< NLayers > TrackingTopologyN
float getPositionResolution(int layer) const
std::array< bounded_vector< uint8_t >, NLayers > mClusterSize
gsl::span< const int > getROFrameClusters(int layerId) const
std::pmr::memory_resource * getMaybeFrameworkHostResource(bool forceHost=false)
std::array< bounded_vector< int >, NLayers > mClusterExternalIndices
auto & getCellsLabel(int layer)
std::shared_ptr< BoundedMemoryResource > mMemoryPool
float getMinR(int layer) const
const auto & getROFOverlapTableView() const
gsl::span< Cluster > getClustersOnLayer(int rofId, int layerId)
IndexTableUtilsN mIndexTableUtils
std::array< bounded_vector< int >, NLayers > mROFramesClusters
const auto & getROFVertexLookupTable() const
void setNLinesTotal(uint32_t a) noexcept
void addClusterToLayer(int layer, T &&... args)
unsigned long getArtefactsMemory() const
ROFOverlapTable< NLayers > ROFOverlapTableN
float getMaxR(int layer) const
gsl::span< const MCCompLabel > getClusterLabels(int layerId, const Cluster &cl) const
std::array< bounded_vector< Cluster >, NLayers > mClusters
std::vector< bounded_vector< int > > mCellsLookupTable
bool isBeamPositionOverridden
auto & getPrimaryVerticesLabels()
gsl::span< const Vertex > getPrimaryVertices(int layer, int rofId) const
void setIsStaggered(bool b) noexcept
staggering
int getNLinesTotal() const noexcept
auto & getTrackletClusters(int rofId)
bool isClusterUsed(int layer, int clusterId) const
bounded_vector< Vertex > mPrimaryVertices
keep track of clusters with wild coordinates
void setROFOverlapTable(ROFOverlapTableN table)
gsl::span< int > getExclusiveNTrackletsCluster(int rofId, int combId)
void setMultiplicityCutMask(ROFMaskTableN cutMask)
bounded_vector< std::array< float, 2 > > mPValphaX
auto & getTrackletsLookupTable()
ROFVertexLookupTableN mROFVertexLookupTable
ROFMaskTable< NLayers > ROFMaskTableN
int getClusterExternalIndex(int layerId, const int clId) const
std::array< float, NLayers > mMinR
const auto & getROFOverlapTable() const
int & getNTrackletsROF(int rofId, int combId)
gsl::span< int > getNTrackletsCluster(int rofId, int combId)
auto & getCellsNeighboursLUT()
std::array< bounded_vector< int >, 2 > mNTrackletsPerCluster
std::vector< Cluster > clusters