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 constexpr 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] =
49
50GPUconstexpr() const float sMasses2[NIDsTot] =
70
71GPUconstexpr() const float sMasses2Z[NIDsTot] =
76 o2cp::MassAlpha / 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 constexpr ID Electron = 0;
95 static constexpr ID Muon = 1;
96 static constexpr ID Pion = 2;
97 static constexpr ID Kaon = 3;
98 static constexpr ID Proton = 4;
99 static constexpr ID Deuteron = 5;
100 static constexpr ID Triton = 6;
101 static constexpr ID Helium3 = 7;
102 static constexpr ID Alpha = 8;
103
104 static constexpr ID First = Electron;
105 static constexpr ID Last = Alpha;
106 static constexpr ID NIDs = Last + 1;
107
108 // PID for derived particles
109 static constexpr ID PI0 = 9;
110 static constexpr ID Photon = 10;
111 static constexpr ID K0 = 11;
112 static constexpr ID Lambda = 12;
113 static constexpr ID HyperTriton = 13;
114 static constexpr ID Hyperhydrog4 = 14;
115 static constexpr ID XiMinus = 15;
116 static constexpr ID OmegaMinus = 16;
117 static constexpr ID HyperHelium4 = 17;
118 static constexpr ID HyperHelium5 = 18;
119 static constexpr ID FirstExt = PI0;
120 static constexpr ID LastExt = HyperHelium5;
121 static constexpr 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 : nameToID(name, id + 1);
163 }
164#endif
165
166 ClassDefNV(PID, 2);
167};
168} // namespace track
169} // namespace o2
170
171#endif
std::string getName(const TDataMember *dm, int index, int size)
#define GPUhdDefault()
Header to collect physics constants.
GPUd() static float getMass(ID id)
Definition PID.h:138
static constexpr ID HyperHelium4
Definition PID.h:117
static constexpr ID Electron
Definition PID.h:94
static constexpr ID HyperTriton
Definition PID.h:113
static constexpr ID LastExt
Definition PID.h:120
static constexpr ID NIDs
number of defined IDs
Definition PID.h:106
static constexpr ID Last
if extra IDs added, update this !!!
Definition PID.h:105
static constexpr ID FirstExt
Definition PID.h:119
GPUdDefault() PID()=default
GPUd() operator ID() const
Definition PID.h:131
static constexpr ID Lambda
Definition PID.h:112
GPUd() static float getMass2(ID id)
Definition PID.h:139
static constexpr ID PI0
Definition PID.h:109
static constexpr ID Helium3
Definition PID.h:101
GPUd() float getMass() const
Definition PID.h:133
static constexpr ID Muon
Definition PID.h:95
static constexpr ID Kaon
Definition PID.h:97
GPUd() PID(const char *name)
pid_constants::ID ID
Definition PID.h:92
GPUd() static const char *getName(ID id)
Definition PID.h:147
static constexpr ID Pion
Definition PID.h:96
GPUd() static int getCharge(ID id)
Definition PID.h:141
static constexpr ID NIDsTot
total number of defined IDs
Definition PID.h:121
static constexpr ID HyperHelium5
Definition PID.h:118
static constexpr ID Deuteron
Definition PID.h:99
static constexpr ID K0
Definition PID.h:111
static constexpr ID OmegaMinus
Definition PID.h:116
static constexpr ID Photon
Definition PID.h:110
static constexpr ID Proton
Definition PID.h:98
static constexpr ID First
Definition PID.h:104
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
static constexpr ID Triton
Definition PID.h:100
GPUd() int getCharge() const
Definition PID.h:136
static constexpr ID XiMinus
Definition PID.h:115
static constexpr ID Hyperhydrog4
Definition PID.h:114
GPUd() float getMass2Z() const
Definition PID.h:135
GPUd() static float getMass2Z(ID id)
Definition PID.h:140
static constexpr ID Alpha
Definition PID.h:102
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum src
Definition glcorearb.h:1767
GLuint const GLchar * name
Definition glcorearb.h:781
GLuint id
Definition glcorearb.h:650
constexpr double MassPhoton
constexpr double MassLambda
constexpr double MassHyperhydrog4
constexpr double MassHelium3
constexpr double MassPionNeutral
constexpr double MassHyperHelium4
constexpr double MassHyperHelium5
constexpr double MassTriton
constexpr double MassMuon
constexpr double MassKaonCharged
constexpr double MassOmegaMinus
constexpr double MassXiMinus
constexpr double MassKaonNeutral
constexpr double MassDeuteron
constexpr double MassHyperTriton
constexpr double MassAlpha
constexpr double MassElectron
constexpr double MassProton
constexpr double MassPionCharged
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 ...