Skip to content

Commit c490e90

Browse files
committed
anton's fixes
1 parent 2d572a0 commit c490e90

3 files changed

Lines changed: 25 additions & 20 deletions

File tree

ALICE3/Core/OTFParticle.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ class OTFParticle
155155
std::span<const int> getMotherSpan() const { return hasMothers() ? std::span<const int>(mIndicesMother.data(), 2) : std::span<const int>(); }
156156

157157
// Checks
158-
bool hasDaughters() const { return (mIndicesDaughter[0] > 0); }
159-
bool hasMothers() const { return (mIndicesMother[0] > 0); }
158+
bool hasDaughters() const { return (mIndicesDaughter[0] >= 0); }
159+
bool hasMothers() const { return (mIndicesMother[0] >= 0); }
160160
bool hasNaN() const
161161
{
162162
return std::isnan(mPx) || std::isnan(mPy) || std::isnan(mPz) || std::isnan(mE) ||

ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ struct OnTheFlyDecayer {
120120
std::vector<o2::upgrade::OTFParticle> allParticles;
121121
void decayParticles(const int start, const int stop)
122122
{
123+
if (start >= stop) {
124+
return;
125+
}
126+
123127
int ndau = 0;
124128
for (int i = start; i < stop; ++i) {
125129
o2::upgrade::OTFParticle& particle = allParticles[i];
@@ -134,6 +138,10 @@ struct OnTheFlyDecayer {
134138

135139
particle.setBitOff(o2::upgrade::DecayerBits::IsAlive);
136140
std::vector<o2::upgrade::OTFParticle> decayStack = decayer.decayParticle(pdgDB, particle);
141+
if (decayStack.empty()) {
142+
continue;
143+
}
144+
137145
const float decayRadius = decayer.getDecayRadius();
138146
const float trackVelocity = o2::upgrade::computeParticleVelocity(particle.p(), pdgDB->GetParticle(particle.pdgCode())->Mass());
139147
const int charge = pdgDB->GetParticle(particle.pdgCode())->Charge() / 3;
@@ -151,19 +159,15 @@ struct OnTheFlyDecayer {
151159

152160
const float trackTimeNS = trackLength / trackVelocity * PicoToNano;
153161
particle.setIndicesDaughter(allParticles.size(), allParticles.size() + (decayStack.size() - 1));
154-
for (const o2::upgrade::OTFParticle& daughter : decayStack) {
162+
for (auto& daughter : decayStack) {
155163
daughter.setIndicesMother(i, i);
156164
daughter.setCollisionId(particle.collisionId());
157165
daughter.setBitOn(o2::upgrade::DecayerBits::IsAlive);
158166
daughter.setBitOff(o2::upgrade::DecayerBits::IsPrimary);
159167
daughter.setProductionTime(trackTimeNS);
160168
allParticles.push_back(daughter);
161-
ndau++;
162169
}
163-
}
164-
165-
if (start >= stop) {
166-
return;
170+
ndau += decayStack.size();
167171
}
168172

169173
decayParticles(stop, stop + ndau);
@@ -172,6 +176,7 @@ struct OnTheFlyDecayer {
172176
void process(aod::McCollisions_001From<aod::Hash<"TMP"_h>>::iterator const& collision, aod::McParticles_001From<aod::Hash<"TMP"_h>> const& mcParticles)
173177
{
174178
allParticles.clear();
179+
allParticles.reserve(mcParticles.size() * 2);
175180
if (collision.globalIndex() == 0) {
176181
indexOffset = 0;
177182
}
@@ -190,7 +195,8 @@ struct OnTheFlyDecayer {
190195
decayParticles(0, allParticles.size());
191196

192197
// Fill output table
193-
for (const o2::upgrade::OTFParticle& otfParticle : allParticles) {
198+
int id = indexOffset;
199+
for (auto& otfParticle : allParticles) {
194200
otfParticle.setIndexOffset(indexOffset);
195201
if (otfParticle.hasNaN()) {
196202
histos.fill(HIST("hNaNBookkeeping"), 1);
@@ -199,7 +205,7 @@ struct OnTheFlyDecayer {
199205
}
200206

201207
tableOTFDecayerBits(otfParticle.getBitsValue());
202-
tableMcParticles(otfParticle.collisionId(), otfParticle.pdgCode(), otfParticle.statusCode(), otfParticle.flags(),
208+
tableMcParticles(tableMcCollisions.lastIndex(), otfParticle.pdgCode(), otfParticle.statusCode(), otfParticle.flags(),
203209
otfParticle.getMotherSpan(), otfParticle.getDaughters().data(), otfParticle.weight(),
204210
otfParticle.px(), otfParticle.py(), otfParticle.pz(), otfParticle.e(),
205211
otfParticle.vx(), otfParticle.vy(), otfParticle.vz(), otfParticle.vt());
@@ -208,7 +214,7 @@ struct OnTheFlyDecayer {
208214
// Particles for later collisions in df's needs to have thier mother
209215
// and daughter indices adjusted since their global index will be
210216
// shifted due to the appending of decay products
211-
indexOffset += (allParticles.size() - mcParticles.size());
217+
indexOffset += allParticles.size();
212218
}
213219
};
214220

ALICE3/Tasks/alice3DecayerQa.cxx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ struct Alice3DecayerQa {
132132

133133
void process(const aod::McCollision& collision, const aod::McParticles& particles)
134134
{
135-
LOG(info) << particles.size();
136135
// Group with collision
137136
auto trueElectronsGrouped = trueElectrons->sliceByCached(aod::mcparticle::mcCollisionId, collision.globalIndex(), cache);
138137
auto trueMuonsGrouped = trueMuons->sliceByCached(aod::mcparticle::mcCollisionId, collision.globalIndex(), cache);
@@ -164,8 +163,8 @@ struct Alice3DecayerQa {
164163
histos.fill(HIST("K0S/hHasDecayed"), 1);
165164
auto daughters = particle.daughtersIds();
166165
if (daughters.size() == NV0Daughters) {
167-
auto dau0 = particles.rawIteratorAt(daughters.front());
168-
auto dau1 = particles.rawIteratorAt(daughters.back());
166+
auto dau0 = particles.rawIteratorAt(daughters.front() - particles.offset());
167+
auto dau1 = particles.rawIteratorAt(daughters.back() - particles.offset());
169168

170169
// K0S -> pi+ pi-
171170
const bool k0sDecay = (dau0.pdgCode() == PDG_t::kPiPlus && dau1.pdgCode() == PDG_t::kPiMinus) ||
@@ -188,8 +187,8 @@ struct Alice3DecayerQa {
188187
histos.fill(HIST("Lambda/hHasDecayed"), 1);
189188
auto daughters = particle.daughtersIds();
190189
if (daughters.size() == NV0Daughters) {
191-
auto dau0 = particles.rawIteratorAt(daughters[0]);
192-
auto dau1 = particles.rawIteratorAt(daughters[1]);
190+
auto dau0 = particles.rawIteratorAt(daughters[0] - particles.offset());
191+
auto dau1 = particles.rawIteratorAt(daughters[1] - particles.offset());
193192

194193
// Lambda -> p pi-
195194
const bool lambdaDecay = (dau0.pdgCode() == PDG_t::kProton && dau1.pdgCode() == PDG_t::kPiMinus) ||
@@ -212,8 +211,8 @@ struct Alice3DecayerQa {
212211
histos.fill(HIST("XiMinus/hHasDecayed"), 1);
213212
auto daughters = particle.daughtersIds();
214213
if (daughters.size() == NCascadeDaughters) {
215-
auto dau0 = particles.rawIteratorAt(daughters.front());
216-
auto dau1 = particles.rawIteratorAt(daughters.back());
214+
auto dau0 = particles.rawIteratorAt(daughters.front() - particles.offset());
215+
auto dau1 = particles.rawIteratorAt(daughters.back() - particles.offset());
217216

218217
// Xi- -> Lambda pi-
219218
const bool xiDecay = (dau0.pdgCode() == PDG_t::kLambda0 && dau1.pdgCode() == PDG_t::kPiMinus) ||
@@ -229,8 +228,8 @@ struct Alice3DecayerQa {
229228
if (v0.has_daughters()) {
230229
auto v0daughters = v0.daughtersIds();
231230
if (v0daughters.size() == NV0Daughters) {
232-
auto v0dau0 = particles.rawIteratorAt(v0daughters.front());
233-
auto v0dau1 = particles.rawIteratorAt(v0daughters.back());
231+
auto v0dau0 = particles.rawIteratorAt(v0daughters.front() - particles.offset());
232+
auto v0dau1 = particles.rawIteratorAt(v0daughters.back() - particles.offset());
234233
const bool lambdaDecay = (v0dau0.pdgCode() == PDG_t::kProton && v0dau1.pdgCode() == PDG_t::kPiMinus) ||
235234
(v0dau0.pdgCode() == PDG_t::kPiMinus && v0dau1.pdgCode() == PDG_t::kProton);
236235
if (lambdaDecay) {

0 commit comments

Comments
 (0)