Skip to content

Commit de703e3

Browse files
committed
refactor decayer and fix indices for cascade decays
1 parent 7a16bc4 commit de703e3

2 files changed

Lines changed: 26 additions & 20 deletions

File tree

ALICE3/Core/TrackUtilities.h

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222

2323
#include <TLorentzVector.h>
2424

25+
#include <array>
26+
#include <span>
2527
#include <vector>
2628

2729
namespace o2::upgrade
2830
{
2931

30-
31-
3232
class OTFParticle
3333
{
3434
public:
@@ -48,6 +48,9 @@ class OTFParticle
4848
mVy = particle.vy();
4949
mVz = particle.vz();
5050
mIsFromMcParticles = true;
51+
if (particle.hasMothers()) {
52+
mIndicesMother = {particle.mothersIds().front(), particle.mothersIds().back()};
53+
}
5154
}
5255

5356
// Setters
@@ -78,21 +81,25 @@ class OTFParticle
7881
bool isAlive() const { return mIsAlive; }
7982
bool isPrimary() const { return mIsPrimary; }
8083
bool isFromMcParticles() const { return mIsFromMcParticles; }
81-
float weight() const {
84+
float weight() const
85+
{
8286
static constexpr float Weight = 1.f;
83-
return Weight;
87+
return Weight;
8488
}
85-
uint8_t flags() const {
89+
uint8_t flags() const
90+
{
8691
static constexpr uint8_t Flags = 1;
87-
return Flags;
92+
return Flags;
8893
}
89-
float vt()const {
94+
float vt() const
95+
{
9096
static constexpr float Vt = 1.f;
91-
return Vt;
97+
return Vt;
9298
}
93-
int statusCode()const {
94-
static constexpr int StatusCode = 1;
95-
return StatusCode;
99+
int statusCode() const
100+
{
101+
static constexpr int StatusCode = 1;
102+
return StatusCode;
96103
}
97104
float vx() const { return mVx; }
98105
float vy() const { return mVy; }
@@ -113,7 +120,7 @@ class OTFParticle
113120
if ((p() - mPz) < Tolerance) {
114121
return (mPz < 0.0f) ? -100.0f : 100.0f;
115122
} else {
116-
return 0.5f * std::log((p() + mPz) / (p() - mPz));
123+
return 0.5f * std::log((p() + mPz) / (p() - mPz));
117124
}
118125
}
119126

@@ -129,13 +136,14 @@ class OTFParticle
129136
}
130137

131138
bool hasDaughters() const { return (mIndicesDaughter[0] > 0); }
139+
bool hasMothers() const { return (mIndicesMother[0] > 0); }
132140
int getMotherIndexStart() const { return mIndicesMother[0]; }
133141
int getMotherIndexStop() const { return mIndicesMother[1]; }
134142
int getDaughterIndexStart() const { return mIndicesDaughter[0]; }
135143
int getDaughterIndexStop() const { return mIndicesDaughter[1]; }
136144
std::array<int, 2> getMothers() const { return mIndicesMother; }
137-
std::span<const int> getMotherSpan() const { return std::span<const int>(mIndicesMother.data(), 2); }
138145
std::array<int, 2> getDaughters() const { return mIndicesDaughter; }
146+
std::span<const int> getMotherSpan() const { return hasMothers() ? std::span<const int>(mIndicesMother.data(), 2) : std::span<const int>(); }
139147

140148
bool hasNaN() const
141149
{
@@ -148,7 +156,6 @@ class OTFParticle
148156
return (mGlobalIndex != -1);
149157
}
150158

151-
152159
private:
153160
int mPdgCode{}, mGlobalIndex{-1};
154161
int mCollisionId{};
@@ -158,10 +165,9 @@ class OTFParticle
158165
bool mIsAlive{}, mIsFromMcParticles{false};
159166
bool mIsPrimary{};
160167

161-
std::array<int, 2> mIndicesMother{}, mIndicesDaughter{-1, -1};
168+
std::array<int, 2> mIndicesMother{-1, -1}, mIndicesDaughter{-1, -1};
162169
};
163170

164-
165171
/// Function to convert a TLorentzVector into a perfect Track
166172
/// \param charge particle charge (integer)
167173
/// \param particle the particle to convert (TLorentzVector)

ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
#include <sys/types.h>
4040

4141
#include <algorithm>
42+
#include <array>
4243
#include <cmath>
4344
#include <cstdlib>
44-
#include <gsl/span>
4545
#include <map>
4646
#include <ostream>
4747
#include <span>
@@ -97,7 +97,7 @@ struct OnTheFlyDecayer {
9797
decayer.setBField(magneticField);
9898
for (int i = 0; i < NumDecays; ++i) {
9999
if (enabledDecays->get(ParticleNames[i].c_str(), "enable")) {
100-
LOG(info) << " --- Decay enabled: " << ParticleNames[i].c_str();
100+
LOG(info) << " --- Decay enabled: " << pdgCodes[i];
101101
mEnabledDecays.push_back(pdgCodes[i]);
102102
}
103103
}
@@ -122,11 +122,11 @@ struct OnTheFlyDecayer {
122122
int ndau = 0;
123123
for (int i = start; i < stop; i++) {
124124
o2::upgrade::OTFParticle& particle = allParticles[i];
125-
if (particle.hasIndex()) {
125+
if (particle.isFromMcParticles()) {
126126
particle.setIsPrimary(true);
127127
particle.setIsAlive(true);
128128
}
129-
129+
130130
if (!canDecay(particle)) {
131131
continue;
132132
}

0 commit comments

Comments
 (0)