Project
Loading...
Searching...
No Matches
TrackSeed.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 ALICEO2_ITSMFT_TRACKING_TRACKSEED_H_
17#define ALICEO2_ITSMFT_TRACKING_TRACKSEED_H_
18
19#include <array>
20
22#include "GPUCommonDef.h"
28
30{
31
38class TrackSeed final
39{
40 public:
41 static constexpr int MaxSurfaces = static_cast<int>(MaxLayoutSurfaces);
42
43 GPUhdDefault() TrackSeed() = default;
44 GPUhdDefault() TrackSeed(const TrackSeed&) = default;
45 GPUhdDefault() ~TrackSeed() = default;
47 GPUhdDefault() TrackSeed& operator=(const TrackSeed&) = default;
48 GPUhdDefault() TrackSeed& operator=(TrackSeed&&) = default;
49
50 // Triplet's hit mask is positional in the same fixed-capacity domain.
51 GPUhd() TrackSeed(const Triplet& cs, const SurfaceTrackState& state, float chi2)
52 : mState(state), mChi2(chi2), mLevel(cs.getLevel()), mTracklets{cs.getFirstTrackletIndex(), cs.getSecondTrackletIndex()}, mTime(cs.getTimeStamp())
53 {
54 const auto hitMask = cs.getHitLayerMask();
55 int slot = 0;
56 for (int position = 0; position < MaxSurfaces; ++position) {
57 if (hitMask.has(position)) {
58 mClusters[position] = cs.getClusters()[slot++];
59 mHitLayerMask.set(position);
60 }
61 }
62 }
63
64 GPUhd() int getActiveLayerCount() const noexcept { return mHitLayerMask.count(); }
65 GPUhd() int getInnerLayer() const noexcept { return mHitLayerMask.first(); }
66 GPUhd() bool hasCluster(int position) const noexcept
67 {
68 return position >= 0 && position < MaxSurfaces && mHitLayerMask.has(position);
69 }
70
71 // Bounds-checked: an out-of-[0, MaxSurfaces) position safely
72 // returns UnusedIndex instead of indexing out of bounds.
73 GPUhd() int getCluster(int position) const noexcept
74 {
75 return (position >= 0 && position < MaxSurfaces) ? mClusters[position] : o2::its::constants::UnusedIndex;
76 }
77
78 GPUhd() LayerMask getHitLayerMask() const noexcept { return mHitLayerMask; }
80 GPUhd() void setCluster(int position, int clusterIndex) noexcept
81 {
82 if (position >= 0 && position < MaxSurfaces) {
83 mClusters[position] = clusterIndex;
84 }
85 }
86
87 GPUhd() int getFirstClusterIndex() const noexcept { return getClusterBySlot(0); }
88 GPUhd() int getSecondClusterIndex() const noexcept { return getClusterBySlot(1); }
89 GPUhd() int getThirdClusterIndex() const noexcept { return getClusterBySlot(2); }
90
91 GPUhd() auto& getClusters() noexcept { return mClusters; }
92 GPUhd() const auto& getClusters() const noexcept { return mClusters; }
93
94 GPUhd() int getFirstTrackletIndex() const noexcept { return mTracklets[0]; }
95 GPUhd() void setFirstTrackletIndex(int trkl) noexcept { mTracklets[0] = trkl; }
96 GPUhd() int getSecondTrackletIndex() const noexcept { return mTracklets[1]; }
97 GPUhd() void setSecondTrackletIndex(int trkl) noexcept { mTracklets[1] = trkl; }
98
99 GPUhd() float getChi2() const noexcept { return mChi2; }
100 GPUhd() void setChi2(float chi2) noexcept { mChi2 = chi2; }
101 GPUhd() int getLevel() const noexcept { return mLevel; }
102 GPUhd() void setLevel(int level) noexcept { mLevel = level; }
103
104 GPUhd() auto& getTimeStamp() noexcept { return mTime; }
105 GPUhd() const auto& getTimeStamp() const noexcept { return mTime; }
106
107 GPUhd() SurfaceTrackState& state() noexcept { return mState; }
108 GPUhd() const SurfaceTrackState& state() const noexcept { return mState; }
109 // Raw signed q/pT in slot 4 for cylinder and disk states; never squared.
110 GPUhd() float getQOverPt() const noexcept { return mState.parameters[4]; }
111
112 private:
113 GPUhd() int getClusterBySlot(int requestedSlot) const noexcept
114 {
115 int slot = 0;
116 for (int position = 0; position < MaxSurfaces; ++position) {
117 if (hasCluster(position)) {
118 if (slot++ == requestedSlot) {
119 return mClusters[position];
120 }
121 }
122 }
124 }
125
126 SurfaceTrackState mState{};
130 std::array<int, 2> mTracklets = o2::its::constants::helpers::initArray<int, 2, o2::its::constants::UnusedIndex>();
131 std::array<int, MaxSurfaces> mClusters = o2::its::constants::helpers::initArray<int, MaxSurfaces, o2::its::constants::UnusedIndex>();
133};
134
135} // namespace o2::itsmft::tracking
136
137#endif // ALICEO2_ITSMFT_TRACKING_TRACKSEED_H_
CA geometric triplet types with hole-layer support.
std::array< int, MaxSurfaces > mClusters
Definition TrackSeed.h:131
const SurfaceTrackState & state
Definition TrackSeed.h:51
static constexpr int MaxSurfaces
Definition TrackSeed.h:41
const SurfaceTrackState float mTracklets
Definition TrackSeed.h:52
GPUhd() void setHitLayerMask(LayerMask mask) noexcept
Definition TrackSeed.h:79
GPUhd() LayerMask getHitLayerMask() const noexcept
Definition TrackSeed.h:78
GPUhd() int getInnerLayer() const noexcept
Definition TrackSeed.h:65
const SurfaceTrackState float chi2
Definition TrackSeed.h:52
GPUhd() bool hasCluster(int position) const noexcept
Definition TrackSeed.h:66
GPUhd() int getActiveLayerCount() const noexcept
Definition TrackSeed.h:64
GPUhd() int getCluster(int position) const noexcept
Definition TrackSeed.h:73
GPUhd() void setCluster(int position
GPUhdDefault() TrackSeed()=default
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLint level
Definition glcorearb.h:275
GLint GLuint mask
Definition glcorearb.h:291
constexpr int UnusedIndex
Definition Constants.h:32
constexpr float UnsetValue
Definition Constants.h:33
constexpr uint32_t MaxLayoutSurfaces
Definition IdTypes.h:70