Project
Loading...
Searching...
No Matches
VertexerTraits.h
Go to the documentation of this file.
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.
15
16#ifndef O2_ITS_TRACKING_VERTEXER_TRAITS_H_
17#define O2_ITS_TRACKING_VERTEXER_TRAITS_H_
18
19#include <array>
20#include <memory>
21#include <string>
22#include <vector>
23
25#include "ITStracking/Cluster.h"
33
34#include "GPUCommonDef.h"
35#include "GPUCommonMath.h"
36
37#include <oneapi/tbb/task_arena.h>
38
39namespace o2
40{
41class MCCompLabel;
42
43namespace its
44{
45
46template <int NLayers>
48{
51
52 public:
53 VertexerTraits() = default;
54 virtual ~VertexerTraits() = default;
55
56 // virtual vertexer interface
57 virtual void initialise(const TrackingParameters& trackingParams);
58 virtual void computeTracklets(const int iteration);
59 virtual void computeTrackletMatching(const int iteration);
60 virtual void computeVertices(const int iteration);
61 virtual void adoptTimeFrame(TimeFrameN* tf) noexcept { mTimeFrame = tf; }
62 virtual void updateVertexingParameters(const std::vector<VertexingParameters>& vrtPar);
63
64 // truth tracking
66
67 // utils
69 auto getVertexingParameters() const { return mVrtParams; }
70 void setVertexingParameters(std::vector<VertexingParameters>& vertParams) { mVrtParams = vertParams; }
71 void setNThreads(int n, std::shared_ptr<tbb::task_arena>& arena);
72 int getNThreads() { return mTaskArena->max_concurrency(); }
73 virtual bool isGPU() const noexcept { return false; }
74 virtual const char* getName() const noexcept { return "CPU"; }
75 virtual bool usesMemoryPool() const noexcept { return true; }
76 void setMemoryPool(std::shared_ptr<BoundedMemoryResource> pool) { mMemoryPool = pool; }
77
79 {
80 // we only care about the source&event of the tracks, not the trackId
81 auto composeVtxLabel = [](const o2::MCCompLabel& lbl) -> o2::MCCompLabel {
82 return {o2::MCCompLabel::maxTrackID(), lbl.getEventID(), lbl.getSourceID(), lbl.isFake()};
83 };
84 std::unordered_map<o2::MCCompLabel, size_t> frequency;
85 for (const auto& element : elements) {
86 ++frequency[composeVtxLabel(element)];
87 }
88 o2::MCCompLabel elem{};
89 size_t maxCount = 0;
90 for (const auto& [key, count] : frequency) {
91 if (count > maxCount) {
93 elem = key;
94 }
95 }
96 if (maxCount <= 1) { // need >50%
97 elem.setFakeFlag();
98 }
99 return std::make_pair(elem, static_cast<float>(maxCount) / static_cast<float>(elements.size()));
100 }
101
102 protected:
103 std::vector<VertexingParameters> mVrtParams;
105
106 // Frame related quantities
107 TimeFrameN* mTimeFrame = nullptr; // observer ptr
108 private:
109 bool skipROF(int iteration, int rof) const;
110
111 std::shared_ptr<BoundedMemoryResource> mMemoryPool;
112 std::shared_ptr<tbb::task_arena> mTaskArena;
113};
114
115} // namespace its
116} // namespace o2
117#endif
atype::type element
StringRef key
static constexpr int maxTrackID()
void setNThreads(int n, std::shared_ptr< tbb::task_arena > &arena)
auto getVertexingParameters() const
virtual void computeVertices(const int iteration)
virtual ~VertexerTraits()=default
IndexTableUtilsN mIndexTableUtils
static VertexLabel computeMain(const bounded_vector< o2::MCCompLabel > &elements)
virtual void initialise(const TrackingParameters &trackingParams)
std::vector< VertexingParameters > mVrtParams
void setVertexingParameters(std::vector< VertexingParameters > &vertParams)
virtual void updateVertexingParameters(const std::vector< VertexingParameters > &vrtPar)
virtual void computeTrackletMatching(const int iteration)
virtual bool usesMemoryPool() const noexcept
virtual void computeTracklets(const int iteration)
virtual bool isGPU() const noexcept
virtual const char * getName() const noexcept
void setMemoryPool(std::shared_ptr< BoundedMemoryResource > pool)
virtual void adoptTimeFrame(TimeFrameN *tf) noexcept
GLdouble n
Definition glcorearb.h:1982
GLint GLsizei count
Definition glcorearb.h:399
std::pmr::vector< T > bounded_vector
std::pair< o2::MCCompLabel, float > VertexLabel
Definition Vertex.h:27
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::unique_ptr< GPUReconstructionTimeframe > tf