Project
Loading...
Searching...
No Matches
GlobalTrackID.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.
11
15
16#ifndef O2_GLOBAL_TRACK_ID
17#define O2_GLOBAL_TRACK_ID
18
19#include "GPUCommonBitSet.h"
22#ifndef GPUCA_GPUCODE
23#include <iosfwd>
24#include <string>
25#include <array>
26#include <string_view>
27#include <bitset>
28#endif // GPUCA_GPUCODE_DEVICE
29
30namespace o2
31{
32namespace dataformats
33{
34
35class GlobalTrackID : public AbstractRef<25, 5, 2>
36{
37 public:
39
40 enum Source : uint8_t { // provenance of the
41 ITS, // standalone detectors
45 PHS, // FIXME Not sure PHS ... FDD should be kept here, at the moment
46 CPV, // they are here for completeness
56 ITSTPC, // 2-detector tracks
60 ITSTPCTRD, // 3-detector tracks
64 ITSTPCTRDTOF, // full barrel track
65 ITSAB, // ITS AfterBurner tracklets
67 //
68 MCHMID, // Temporary ordering
69 //
71 };
72
73 using AbstractRef<25, 5, 2>::AbstractRef;
74 static_assert(NSources <= 32, "bitset<32> insufficient");
76
77#ifndef GPUCA_GPUCODE
78 static constexpr std::string_view NONE{"none"};
79 static constexpr std::string_view ALL{"all"};
80#endif
81 static constexpr mask_t MASK_ALL = (1u << NSources) - 1;
82 static constexpr mask_t MASK_NONE = 0;
83
84 // methods for detector level manipulations
85 GPUdi() static constexpr DetID::mask_t getSourceDetectorsMask(int i);
86 GPUdi() static constexpr DetID::mask_t getSourcesDetectorsMask(GlobalTrackID::mask_t srcm);
87 GPUdi() static bool includesDet(DetID id, GlobalTrackID::mask_t srcm);
88 GPUdi() static bool isTrackSource(int s);
89 GPUdi() auto getSourceDetectorsMask() const { return getSourceDetectorsMask(getSource()); }
90 GPUdi() bool includesDet(DetID id) const { return (getSourceDetectorsMask() & DetID::getMask(id)).any(); }
91
92 // methods for source level manipulations
93#ifndef GPUCA_GPUCODE
94 static auto getSourceName(int s)
95 {
96 return s == ITSAB ? std::string{"ITSAB"} : DetID::getNames(getSourceDetectorsMask(s), '-');
97 }
98 static mask_t getSourcesMask(const std::string_view srcList);
99 static std::string getSourcesNames(mask_t srcm);
100 auto getSourceName() const { return getSourceName(getSource()); }
101#endif // GPUCA_GPUCODE
102 GPUd() static constexpr mask_t getSourceMask(int s);
103 GPUdi() mask_t getSourceMask() const { return getSourceMask(getSource()); }
104 GPUdi() static bool includesSource(int s, mask_t srcm) { return srcm[s]; }
105 GPUdi() operator int() const { return int(getIndex()); }
106
107#ifndef GPUCA_GPUCODE
108 std::string asString() const;
109 void print() const;
110#endif // GPUCA_GPUCODE
111
113};
114
115#ifndef GPUCA_GPUCODE
116std::ostream& operator<<(std::ostream& os, const o2::dataformats::GlobalTrackID& v);
117#endif // GPUCA_GPUCODE
118
119namespace globaltrackid_internal
120{
121// static constexpr array class members not possible on the GPU, thus we use this trick.
123GPUconstexpr() DetID::mask_t SourceDetectorsMasks[GlobalTrackID::NSources] = {
139 //
152};
153
154GPUconstexpr() GlobalTrackID::mask_t sMasks[GlobalTrackID::NSources] =
155 {
156 GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::ITS)), GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::TPC)), GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::TRD)), GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::TOF)), GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::PHS)),
157 GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::CPV)), GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::EMC)), GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::HMP)), GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::MFT)), GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::MCH)),
158 GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::MID)), GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::ZDC)), GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::FT0)), GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::FV0)), GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::FDD)),
161 GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::ITSAB)),
162 GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::CTP)),
163 GlobalTrackID::mask_t(math_utils::bit2Mask(GlobalTrackID::MCHMID)) // Temporary ordering
164};
165
166#ifndef __OPENCL__
167GPUconstexpr() GlobalTrackID::mask_t sTrackSources =
168 sMasks[GlobalTrackID::ITS] | sMasks[GlobalTrackID::TPC] | sMasks[GlobalTrackID::MFT] | sMasks[GlobalTrackID::MCH] | sMasks[GlobalTrackID::ITSTPC] | sMasks[GlobalTrackID::TPCTOF] |
169 sMasks[GlobalTrackID::TPCTRD] | sMasks[GlobalTrackID::MFTMCH] | sMasks[GlobalTrackID::ITSTPCTRD] | sMasks[GlobalTrackID::ITSTPCTOF] | sMasks[GlobalTrackID::TPCTRDTOF] |
170 sMasks[GlobalTrackID::MFTMCHMID] | sMasks[GlobalTrackID::ITSTPCTRDTOF] | sMasks[GlobalTrackID::ITSAB] | sMasks[GlobalTrackID::MCHMID];
171#endif
172
173} // namespace globaltrackid_internal
174
175GPUdi() constexpr GlobalTrackID::DetID::mask_t GlobalTrackID::getSourceDetectorsMask(int i) { return globaltrackid_internal::SourceDetectorsMasks[i]; }
176GPUdi() constexpr GlobalTrackID::mask_t GlobalTrackID::getSourceMask(int s) { return globaltrackid_internal::sMasks[s]; }
177
178#ifndef __OPENCL__
179GPUdi() bool GlobalTrackID::isTrackSource(int s)
180{
181 return globaltrackid_internal::sTrackSources[s];
182}
183#endif
184
185GPUdi() bool GlobalTrackID::includesDet(DetID id, GlobalTrackID::mask_t srcm)
186{
187 for (int i = 0; i < NSources; i++) {
188 if (includesSource(i, srcm) && (getSourceDetectorsMask(i) & id.getMask()).any()) {
189 return true;
190 }
191 }
192 return false;
193}
194
195GPUd() constexpr GlobalTrackID::DetID::mask_t GlobalTrackID::getSourcesDetectorsMask(GlobalTrackID::mask_t srcm)
196{
198 for (int i = 0; i < NSources; i++) {
199 if (srcm[i]) {
200 mdet |= getSourceDetectorsMask(i);
201 }
202 }
203 return mdet;
204}
205
206} // namespace dataformats
207} // namespace o2
208
209#ifndef GPUCA_GPUCODE
210namespace std
211{
212// defining std::hash for GlobalTrackIndex to be used with std containers
213template <>
214struct hash<o2::dataformats::GlobalTrackID> {
215 public:
217 {
218 return id.getRawWOFlags();
219 }
220};
221} // namespace std
222#endif // GPUCA_GPUCODE
223
224#endif
Class to refer to object indicating its Indec, Source and status flags.
int32_t i
GPUdi() static const expr DetID GPUdi() static const expr DetID GPUdi() static bool includesDet(DetID id
static mask_t getSourcesMask(const std::string_view srcList)
GPUdi() static const expr DetID GPUdi() static const expr DetID GlobalTrackID::mask_t srcm
GPUdi() static bool includesSource(int s
static std::string getSourcesNames(mask_t srcm)
static constexpr mask_t MASK_ALL
o2::gpu::gpustd::bitset< 32 > mask_t
GPUdi() bool includesDet(DetID id) const
static constexpr std::string_view NONE
keywork for no sources
static constexpr mask_t MASK_NONE
ClassDefNV(GlobalTrackID, 3)
GPUdi() operator int() const
static constexpr std::string_view ALL
keywork for all sources
static auto getSourceName(int s)
GPUd() static const expr mask_t getSourceMask(int s)
Static class with identifiers, bitmasks and names for ALICE detectors.
Definition DetID.h:58
o2::gpu::gpustd::bitset< 32 > mask_t
Definition DetID.h:97
static constexpr ID CTP
Definition DetID.h:79
static constexpr ID FV0
Definition DetID.h:76
static constexpr ID PHS
Definition DetID.h:67
static std::string getNames(mask_t mask, char delimiter=',')
Definition DetID.cxx:74
static constexpr ID MID
Definition DetID.h:73
static constexpr ID ITS
Definition DetID.h:63
static constexpr ID MFT
Definition DetID.h:71
static constexpr ID ZDC
Definition DetID.h:74
static constexpr ID FT0
Definition DetID.h:75
static constexpr ID CPV
Definition DetID.h:68
static constexpr ID TRD
Definition DetID.h:65
static constexpr ID TPC
Definition DetID.h:64
static constexpr ID EMC
Definition DetID.h:69
static mask_t getMask(const std::string_view detList)
detector masks from any non-alpha-num delimiter-separated list (empty if NONE is supplied)
Definition DetID.cxx:42
static constexpr ID FDD
Definition DetID.h:77
static constexpr ID MCH
Definition DetID.h:72
static constexpr ID HMP
Definition DetID.h:70
static constexpr ID TOF
Definition DetID.h:66
const GLdouble * v
Definition glcorearb.h:832
GPUd() const expr GlobalTrackID
std::ostream & operator<<(std::ostream &os, const o2::dataformats::MeanVertexObject &o)
GPUdi() const expr GlobalTrackID
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
size_t operator()(const o2::dataformats::GlobalTrackID &id) const