Project
Loading...
Searching...
No Matches
PID.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 ALICEO2_track_PID_H_
17#define ALICEO2_track_PID_H_
18
19#ifndef GPUCA_GPUCODE_DEVICE
20#include <cstdint>
21#endif
22
23#include "GPUCommonDef.h"
24#include "GPUCommonRtypes.h"
26
27namespace o2
28{
29namespace track
30{
32
33namespace pid_constants // GPUs currently cannot have static constexpr array members
34{
35typedef uint8_t ID;
36static GPUglobalconstexpr() ID NIDsTot = 19;
37
38#if !defined(GPUCA_GPUCODE_DEVICE) || defined(GPUCA_GPU_DEBUG_PRINT)
39GPUconstexpr() const char* sNames[NIDsTot + 1] =
40 {"Electron", "Muon", "Pion", "Kaon", "Proton", "Deuteron", "Triton", "He3", "Alpha",
41 "Pion0", "Photon", "K0", "Lambda", "HyperTriton", "Hyperhydrog4", "XiMinus", "OmegaMinus", "HyperHelium4", "HyperHelium5", nullptr};
42#endif
43
44GPUconstexpr() const float sMasses[NIDsTot] =
45 {o2cp::MassElectron, o2cp::MassMuon, o2cp::MassPionCharged, o2cp::MassKaonCharged,
46 o2cp::MassProton, o2cp::MassDeuteron, o2cp::MassTriton, o2cp::MassHelium3,
47 o2cp::MassAlpha, o2cp::MassPionNeutral, o2cp::MassPhoton,
48 o2cp::MassKaonNeutral, o2cp::MassLambda, o2cp::MassHyperTriton, o2cp::MassHyperhydrog4, o2cp::MassXiMinus, o2cp::MassOmegaMinus, o2cp::MassHyperHelium4, o2cp::MassHyperHelium5};
49
50GPUconstexpr() const float sMasses2[NIDsTot] =
51 {o2cp::MassElectron * o2cp::MassElectron,
52 o2cp::MassMuon* o2cp::MassMuon,
53 o2cp::MassPionCharged* o2cp::MassPionCharged,
54 o2cp::MassKaonCharged* o2cp::MassKaonCharged,
55 o2cp::MassProton* o2cp::MassProton,
56 o2cp::MassDeuteron* o2cp::MassDeuteron,
57 o2cp::MassTriton* o2cp::MassTriton,
58 o2cp::MassHelium3* o2cp::MassHelium3,
59 o2cp::MassAlpha* o2cp::MassAlpha,
60 o2cp::MassPionNeutral* o2cp::MassPionNeutral,
61 o2cp::MassPhoton* o2cp::MassPhoton,
62 o2cp::MassKaonNeutral* o2cp::MassKaonNeutral,
63 o2cp::MassLambda* o2cp::MassLambda,
64 o2cp::MassHyperTriton* o2cp::MassHyperTriton,
65 o2cp::MassHyperhydrog4* o2cp::MassHyperhydrog4,
66 o2cp::MassXiMinus* o2cp::MassXiMinus,
67 o2cp::MassOmegaMinus* o2cp::MassOmegaMinus,
68 o2cp::MassHyperHelium4* o2cp::MassHyperHelium4,
69 o2cp::MassHyperHelium5* o2cp::MassHyperHelium5};
70
71GPUconstexpr() const float sMasses2Z[NIDsTot] =
72 {o2cp::MassElectron, o2cp::MassMuon,
73 o2cp::MassPionCharged, o2cp::MassKaonCharged,
74 o2cp::MassProton, o2cp::MassDeuteron,
75 o2cp::MassTriton, o2cp::MassHelium3 / 2.,
76 o2cp::MassAlpha / 2.,
77 0, 0, 0, 0, o2cp::MassHyperTriton, o2cp::MassHyperhydrog4,
78 o2cp::MassXiMinus, o2cp::MassOmegaMinus,
79 o2cp::MassHyperHelium4 / 2., o2cp::MassHyperHelium5 / 2.};
80
81GPUconstexpr() const int sCharges[NIDsTot] =
82 {1, 1, 1, 1, 1, 1, 1, 2, 2,
83 0, 0, 0, 0, 1, 1,
84 1, 1,
85 2, 2};
86} // namespace pid_constants
87
88class PID
89{
90 public:
91 // particle identifiers, continuos starting from 0
93
94 static GPUglobalconstexpr() ID Electron = 0;
95 static GPUglobalconstexpr() ID Muon = 1;
96 static GPUglobalconstexpr() ID Pion = 2;
97 static GPUglobalconstexpr() ID Kaon = 3;
98 static GPUglobalconstexpr() ID Proton = 4;
99 static GPUglobalconstexpr() ID Deuteron = 5;
100 static GPUglobalconstexpr() ID Triton = 6;
101 static GPUglobalconstexpr() ID Helium3 = 7;
102 static GPUglobalconstexpr() ID Alpha = 8;
103
104 static GPUglobalconstexpr() ID First = Electron;
105 static GPUglobalconstexpr() ID Last = Alpha;
106 static GPUglobalconstexpr() ID NIDs = Last + 1;
107
108 // PID for derived particles
109 static GPUglobalconstexpr() ID PI0 = 9;
110 static GPUglobalconstexpr() ID Photon = 10;
111 static GPUglobalconstexpr() ID K0 = 11;
112 static GPUglobalconstexpr() ID Lambda = 12;
113 static GPUglobalconstexpr() ID HyperTriton = 13;
114 static GPUglobalconstexpr() ID Hyperhydrog4 = 14;
115 static GPUglobalconstexpr() ID XiMinus = 15;
116 static GPUglobalconstexpr() ID OmegaMinus = 16;
117 static GPUglobalconstexpr() ID HyperHelium4 = 17;
118 static GPUglobalconstexpr() ID HyperHelium5 = 18;
119 static GPUglobalconstexpr() ID FirstExt = PI0;
120 static GPUglobalconstexpr() ID LastExt = HyperHelium5;
121 static GPUglobalconstexpr() ID NIDsTot = pid_constants::NIDsTot;
122 static_assert(NIDsTot == LastExt + 1, "Incorrect NIDsTot, please update!");
123
124 GPUdDefault() PID() = default;
125 GPUd() PID(ID id) : mID(id) {}
126 GPUd() PID(const char* name);
127 GPUdDefault() PID(const PID& src) = default;
128 GPUhdDefault() PID& operator=(const PID& src) = default;
129
130 GPUd() ID getID() const { return mID; }
131 GPUd() operator ID() const { return getID(); }
132
133 GPUd() float getMass() const { return getMass(mID); }
134 GPUd() float getMass2() const { return getMass2(mID); }
135 GPUd() float getMass2Z() const { return getMass2Z(mID); }
136 GPUd() int getCharge() const { return getCharge(mID); }
137
138 GPUd() static float getMass(ID id) { return pid_constants::sMasses[id]; }
139 GPUd() static float getMass2(ID id) { return pid_constants::sMasses2[id]; }
140 GPUd() static float getMass2Z(ID id) { return pid_constants::sMasses2Z[id]; }
141 GPUd() static int getCharge(ID id) { return pid_constants::sCharges[id]; }
142#if !defined(GPUCA_GPUCODE_DEVICE) || defined(GPUCA_GPU_DEBUG_PRINT)
143 GPUd() const char* getName() const
144 {
145 return getName(mID);
146 }
147 GPUd() static const char* getName(ID id) { return pid_constants::sNames[id]; }
148#endif
149
150 private:
151 ID mID = Pion;
152
153#if !defined(GPUCA_GPUCODE_DEVICE) || defined(GPUCA_GPU_DEBUG_PRINT)
154 // are 2 strings equal ? (trick from Giulio)
155 GPUdi() static constexpr bool sameStr(char const* x, char const* y)
156 {
157 return !*x && !*y ? true : /* default */ (*x == *y && sameStr(x + 1, y + 1));
158 }
159
160 GPUdi() static constexpr ID nameToID(char const* name, ID id)
161 {
162 return id > LastExt ? id : sameStr(name, pid_constants::sNames[id]) ? id
163 : nameToID(name, id + 1);
164 }
165#endif
166
167 ClassDefNV(PID, 2);
168};
169} // namespace track
170} // namespace o2
171
172#endif
std::string getName(const TDataMember *dm, int index, int size)
#define GPUglobalconstexpr()
#define GPUhdDefault()
Header to collect physics constants.
GPUd() static float getMass(ID id)
Definition PID.h:138
GPUdDefault() PID()=default
GPUd() operator ID() const
Definition PID.h:131
GPUd() static float getMass2(ID id)
Definition PID.h:139
GPUd() float getMass() const
Definition PID.h:133
GPUd() PID(const char *name)
pid_constants::ID ID
Definition PID.h:92
GPUd() static const char *getName(ID id)
Definition PID.h:147
GPUd() static int getCharge(ID id)
Definition PID.h:141
static GPUglobalconstexpr() ID Electron=0
GPUd() const char *getName() const
Definition PID.h:143
GPUd() float getMass2() const
Definition PID.h:134
GPUd() PID(ID id)
Definition PID.h:125
GPUd() int getCharge() const
Definition PID.h:136
GPUd() float getMass2Z() const
Definition PID.h:135
GPUd() static float getMass2Z(ID id)
Definition PID.h:140
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum src
Definition glcorearb.h:1767
GLuint const GLchar * name
Definition glcorearb.h:781
GLint y
Definition glcorearb.h:270
GLuint id
Definition glcorearb.h:650
const bool const int TrackITSInternal< NLayers > & track
GPUconstexpr() const char *sNames[NIDsTot+1]
defined particle names
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...