Skip to content

Commit 7ef9055

Browse files
committed
Extend track::PID list and add PID data member to TrackPar
* PID list extended by derived particles (V0 and cascade candidates), changed to uint8_t base. * TrackPar will have mPID data member
1 parent 907f2be commit 7ef9055

6 files changed

Lines changed: 52 additions & 26 deletions

File tree

Common/Constants/include/CommonConstants/PhysicsConstants.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,20 @@ namespace constants
2222
namespace physics
2323
{
2424
// particles masses
25+
constexpr float MassPhoton = 0.0;
2526
constexpr float MassElectron = 0.000511;
2627
constexpr float MassMuon = 0.105658;
2728
constexpr float MassPionCharged = 0.139570;
2829
constexpr float MassPionNeutral = 0.134976;
2930
constexpr float MassKaonCharged = 0.493677;
3031
constexpr float MassKaonNeutral = 0.497648;
3132
constexpr float MassProton = 0.938272;
33+
constexpr float MassLambda = 1.115683;
3234
constexpr float MassDeuteron = 1.875613;
3335
constexpr float MassTriton = 2.809250;
3436
constexpr float MassHelium3 = 2.809230;
3537
constexpr float MassAlpha = 3.727379;
38+
constexpr float MassHyperTriton = 2.992;
3639

3740
constexpr float LightSpeedCm2S = 299792458.e2; // C in cm/s
3841
constexpr float LightSpeedCm2NS = LightSpeedCm2S * 1e-9; // C in cm/ns

DataFormats/Detectors/ITSMFT/ITS/include/DataFormatsITS/TrackITS.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,6 @@ class TrackITS : public o2::track::TrackParCov
8787
o2::track::TrackParCov& getParamOut() { return mParamOut; }
8888
const o2::track::TrackParCov& getParamOut() const { return mParamOut; }
8989

90-
void setPID(uint8_t p) { mPID = p; }
91-
int getPID() const { return mPID; }
92-
9390
void setPattern(uint8_t p) { mPattern = p; }
9491
int getPattern() const { return mPattern; }
9592
bool hasHitOnLayer(int i) { return mPattern & (0x1 << i); }
@@ -98,7 +95,6 @@ class TrackITS : public o2::track::TrackParCov
9895
o2::track::TrackParCov mParamOut; ///< parameter at largest radius
9996
ClusRefs mClusRef; ///< references on clusters
10097
float mChi2 = 0.; ///< Chi2 for this track
101-
uint8_t mPID = 0; ///< pid info (at the moment not used)
10298
uint8_t mPattern = 0; ///< layers pattern
10399

104100
ClassDefNV(TrackITS, 4);
@@ -137,7 +133,7 @@ class TrackITSExt : public TrackITS
137133

138134
private:
139135
std::array<int, MaxClusters> mIndex = {-1}; ///< Indices of associated clusters
140-
ClassDefNV(TrackITSExt, 1);
136+
ClassDefNV(TrackITSExt, 2);
141137
};
142138
} // namespace its
143139
} // namespace o2

DataFormats/Reconstruction/include/ReconstructionDataFormats/PID.h

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#ifndef ALICEO2_track_PID_H_
1616
#define ALICEO2_track_PID_H_
1717

18-
#include <Rtypes.h>
18+
#include "GPUCommonRtypes.h"
1919
#include "CommonConstants/PhysicsConstants.h"
2020

2121
namespace o2
@@ -26,7 +26,7 @@ class PID
2626
{
2727
public:
2828
// particle identifiers, continuos starting from 0
29-
typedef std::int32_t ID;
29+
typedef uint8_t ID;
3030

3131
static constexpr ID Electron = 0;
3232
static constexpr ID Muon = 1;
@@ -40,7 +40,17 @@ class PID
4040

4141
static constexpr ID First = Electron;
4242
static constexpr ID Last = Alpha; ///< if extra IDs added, update this !!!
43-
static constexpr int NIDs = Last + 1; ///< number of defined IDs
43+
static constexpr ID NIDs = Last + 1; ///< number of defined IDs
44+
45+
// PID for derived particles
46+
static constexpr ID PI0 = 9;
47+
static constexpr ID Photon = 10;
48+
static constexpr ID K0 = 11;
49+
static constexpr ID Lambda = 12;
50+
static constexpr ID HyperTriton = 13;
51+
static constexpr ID FirstExt = PI0;
52+
static constexpr ID LastExt = HyperTriton;
53+
static constexpr ID NIDsTot = LastExt + 1; ///< total number of defined IDs
4454

4555
PID() = default;
4656
PID(ID id) : mID(id) {}
@@ -49,6 +59,7 @@ class PID
4959
PID& operator=(const PID& src) = default;
5060

5161
ID getID() const { return mID; }
62+
operator ID() const { return getID(); }
5263

5364
float getMass() const { return getMass(mID); }
5465
float getMass2Z() const { return getMass2Z(mID); }
@@ -69,32 +80,39 @@ class PID
6980
return !*x && !*y ? true : /* default */ (*x == *y && sameStr(x + 1, y + 1));
7081
}
7182

72-
inline static constexpr int nameToID(char const* name, int id)
83+
inline static constexpr ID nameToID(char const* name, ID id)
7384
{
74-
return id > Last ? id : sameStr(name, sNames[id]) ? id : nameToID(name, id + 1);
85+
return id > LastExt ? id : sameStr(name, sNames[id]) ? id : nameToID(name, id + 1);
7586
}
7687

77-
static constexpr const char* sNames[NIDs + 1] = ///< defined particle names
78-
{"Electron", "Muon", "Pion", "Kaon", "Proton", "Deuteron", "Triton", "He3", "Alpha", nullptr};
88+
static constexpr const char* sNames[NIDsTot + 1] = ///< defined particle names
89+
{"Electron", "Muon", "Pion", "Kaon", "Proton", "Deuteron", "Triton", "He3", "Alpha",
90+
"Pion0", "Photon", "K0", "Lambda", "HyperTriton",
91+
nullptr};
7992

80-
static constexpr const float sMasses[NIDs] = ///< defined particle masses
93+
static constexpr const float sMasses[NIDsTot] = ///< defined particle masses
8194
{o2::constants::physics::MassElectron, o2::constants::physics::MassMuon,
8295
o2::constants::physics::MassPionCharged, o2::constants::physics::MassKaonCharged,
8396
o2::constants::physics::MassProton, o2::constants::physics::MassDeuteron,
8497
o2::constants::physics::MassTriton, o2::constants::physics::MassHelium3,
85-
o2::constants::physics::MassAlpha};
98+
o2::constants::physics::MassAlpha,
99+
o2::constants::physics::MassPionNeutral, o2::constants::physics::MassPhoton,
100+
o2::constants::physics::MassKaonNeutral, o2::constants::physics::MassLambda,
101+
o2::constants::physics::MassHyperTriton};
86102

87-
static constexpr const float sMasses2Z[NIDs] = ///< defined particle masses / Z
103+
static constexpr const float sMasses2Z[NIDsTot] = ///< defined particle masses / Z
88104
{o2::constants::physics::MassElectron, o2::constants::physics::MassMuon,
89105
o2::constants::physics::MassPionCharged, o2::constants::physics::MassKaonCharged,
90106
o2::constants::physics::MassProton, o2::constants::physics::MassDeuteron,
91107
o2::constants::physics::MassTriton, o2::constants::physics::MassHelium3 / 2.,
92-
o2::constants::physics::MassAlpha / 2.};
108+
o2::constants::physics::MassAlpha / 2.,
109+
0, 0, 0, 0, o2::constants::physics::MassHyperTriton};
93110

94-
static constexpr const int sCharges[NIDs] = ///< defined particle charges
95-
{1, 1, 1, 1, 1, 1, 1, 2, 2};
111+
static constexpr const int sCharges[NIDsTot] = ///< defined particle charges
112+
{1, 1, 1, 1, 1, 1, 1, 2, 2,
113+
0, 0, 0, 0, 1};
96114

97-
ClassDefNV(PID, 1);
115+
ClassDefNV(PID, 2);
98116
};
99117
} // namespace track
100118
} // namespace o2

DataFormats/Reconstruction/include/ReconstructionDataFormats/Track.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include "CommonConstants/MathConstants.h"
4444
#include "MathUtils/Utils.h"
4545
#include "MathUtils/Primitive2D.h"
46+
#include "ReconstructionDataFormats/PID.h"
4647

4748
//Forward declarations, since we cannot include the headers if we eventually want to use track.h on GPU
4849
namespace ROOT
@@ -153,6 +154,13 @@ class TrackPar
153154
float getTgl() const { return mP[kTgl]; }
154155
float getQ2Pt() const { return mP[kQ2Pt]; }
155156
float getCharge2Pt() const { return mAbsCharge ? mP[kQ2Pt] : 0.; }
157+
int getAbsCharge() const { return mAbsCharge; }
158+
PID getPID() const { return mPID; }
159+
void setPID(const PID pid)
160+
{
161+
mPID = pid;
162+
setAbsCharge(pid.getCharge());
163+
}
156164

157165
/// calculate cos^2 and cos of track direction in rphi-tracking
158166
float getCsp2() const
@@ -178,7 +186,6 @@ class TrackPar
178186
void getCircleParams(float bz, o2::utils::CircleXY& circle, float& sna, float& csa) const;
179187
void getLineParams(o2::utils::IntervalXY& line, float& sna, float& csa) const;
180188
float getCurvature(float b) const { return mAbsCharge ? mP[kQ2Pt] * b * o2::constants::math::B2C : 0.; }
181-
int getAbsCharge() const { return mAbsCharge; }
182189
int getCharge() const { return getSign() > 0 ? mAbsCharge : -mAbsCharge; }
183190
int getSign() const { return mAbsCharge ? (mP[kQ2Pt] > 0.f ? 1 : -1) : 0; }
184191
float getPhi() const;
@@ -239,6 +246,7 @@ class TrackPar
239246
float mAlpha = 0.f; /// track frame angle
240247
float mP[kNParams] = {0.f}; /// 5 parameters: Y,Z,sin(phi),tg(lambda),q/pT
241248
char mAbsCharge = 1; /// Extra info about the abs charge, to be taken into account only if not 1
249+
PID mPID{}; /// 8 bit PID
242250

243251
ClassDefNV(TrackPar, 2);
244252
};

DataFormats/Reconstruction/src/PID.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818

1919
using namespace o2::track;
2020

21-
constexpr const char* PID::sNames[NIDs + 1];
22-
constexpr const float PID::sMasses[NIDs];
23-
constexpr const float PID::sMasses2Z[NIDs];
24-
constexpr const int PID::sCharges[NIDs];
21+
constexpr const char* PID::sNames[NIDsTot + 1];
22+
constexpr const float PID::sMasses[NIDsTot];
23+
constexpr const float PID::sMasses2Z[NIDsTot];
24+
constexpr const int PID::sCharges[NIDsTot];
2525

2626
//_______________________________
2727
PID::PID(const char* name) : mID(nameToID(name, First))
2828
{
2929
// construct from the name
30-
assert(mID < NIDs);
30+
assert(mID < NIDsTot);
3131
}

DataFormats/Reconstruction/src/Track.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,8 @@ float TrackPar::getYAt(float xk, float b) const
458458
std::string TrackPar::asString() const
459459
{
460460
// print parameters as string
461-
return fmt::format("X:{:+.4e} Alp:{:+.3e} Par: {:+.4e} {:+.4e} {:+.4e} {:+.4e} {:+.4e} |Q|:{:d}", getX(), getAlpha(), getY(), getZ(), getSnp(), getTgl(), getQ2Pt(), getAbsCharge());
461+
return fmt::format("X:{:+.4e} Alp:{:+.3e} Par: {:+.4e} {:+.4e} {:+.4e} {:+.4e} {:+.4e} |Q|:{:d} {:s}",
462+
getX(), getAlpha(), getY(), getZ(), getSnp(), getTgl(), getQ2Pt(), getAbsCharge(), getPID().getName());
462463
}
463464

464465
//______________________________________________________________

0 commit comments

Comments
 (0)