Skip to content

Commit 13fd099

Browse files
committed
fixes
1 parent 1927aeb commit 13fd099

2 files changed

Lines changed: 20 additions & 16 deletions

File tree

ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx

Lines changed: 12 additions & 8 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,9 @@ 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+
}
137144
const float decayRadius = decayer.getDecayRadius();
138145
const float trackVelocity = o2::upgrade::computeParticleVelocity(particle.p(), pdgDB->GetParticle(particle.pdgCode())->Mass());
139146
const int charge = pdgDB->GetParticle(particle.pdgCode())->Charge() / 3;
@@ -151,19 +158,15 @@ struct OnTheFlyDecayer {
151158

152159
const float trackTimeNS = trackLength / trackVelocity * PicoToNano;
153160
particle.setIndicesDaughter(allParticles.size(), allParticles.size() + (decayStack.size() - 1));
154-
for (const o2::upgrade::OTFParticle& daughter : decayStack) {
161+
for (auto& daughter : decayStack) {
155162
daughter.setIndicesMother(i, i);
156163
daughter.setCollisionId(particle.collisionId());
157164
daughter.setBitOn(o2::upgrade::DecayerBits::IsAlive);
158165
daughter.setBitOff(o2::upgrade::DecayerBits::IsPrimary);
159166
daughter.setProductionTime(trackTimeNS);
160167
allParticles.push_back(daughter);
161-
ndau++;
162168
}
163-
}
164-
165-
if (start >= stop) {
166-
return;
169+
ndau += decayStack.size();
167170
}
168171

169172
decayParticles(stop, stop + ndau);
@@ -172,6 +175,7 @@ struct OnTheFlyDecayer {
172175
void process(aod::McCollisions_001From<aod::Hash<"TMP"_h>>::iterator const& collision, aod::McParticles_001From<aod::Hash<"TMP"_h>> const& mcParticles)
173176
{
174177
allParticles.clear();
178+
allParticles.reserve(mcParticles.size() * 2);
175179
if (collision.globalIndex() == 0) {
176180
indexOffset = 0;
177181
}
@@ -190,7 +194,7 @@ struct OnTheFlyDecayer {
190194
decayParticles(0, allParticles.size());
191195

192196
// Fill output table
193-
for (const o2::upgrade::OTFParticle& otfParticle : allParticles) {
197+
for (auto& otfParticle : allParticles) {
194198
otfParticle.setIndexOffset(indexOffset);
195199
if (otfParticle.hasNaN()) {
196200
histos.fill(HIST("hNaNBookkeeping"), 1);
@@ -199,7 +203,7 @@ struct OnTheFlyDecayer {
199203
}
200204

201205
tableOTFDecayerBits(otfParticle.getBitsValue());
202-
tableMcParticles(otfParticle.collisionId(), otfParticle.pdgCode(), otfParticle.statusCode(), otfParticle.flags(),
206+
tableMcParticles(tableMcCollisions.lastIndex(), otfParticle.pdgCode(), otfParticle.statusCode(), otfParticle.flags(),
203207
otfParticle.getMotherSpan(), otfParticle.getDaughters().data(), otfParticle.weight(),
204208
otfParticle.px(), otfParticle.py(), otfParticle.pz(), otfParticle.e(),
205209
otfParticle.vx(), otfParticle.vy(), otfParticle.vz(), otfParticle.vt());

ALICE3/Tasks/alice3DecayerQa.cxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ struct Alice3DecayerQa {
163163
histos.fill(HIST("K0S/hHasDecayed"), 1);
164164
auto daughters = particle.daughtersIds();
165165
if (daughters.size() == NV0Daughters) {
166-
auto dau0 = particles.rawIteratorAt(daughters.front());
167-
auto dau1 = particles.rawIteratorAt(daughters.back());
166+
auto dau0 = particles.rawIteratorAt(daughters.front() - particles.offset());
167+
auto dau1 = particles.rawIteratorAt(daughters.back() - particles.offset());
168168

169169
// K0S -> pi+ pi-
170170
const bool k0sDecay = (dau0.pdgCode() == PDG_t::kPiPlus && dau1.pdgCode() == PDG_t::kPiMinus) ||
@@ -187,8 +187,8 @@ struct Alice3DecayerQa {
187187
histos.fill(HIST("Lambda/hHasDecayed"), 1);
188188
auto daughters = particle.daughtersIds();
189189
if (daughters.size() == NV0Daughters) {
190-
auto dau0 = particles.rawIteratorAt(daughters[0]);
191-
auto dau1 = particles.rawIteratorAt(daughters[1]);
190+
auto dau0 = particles.rawIteratorAt(daughters[0] - particles.offset());
191+
auto dau1 = particles.rawIteratorAt(daughters[1] - particles.offset());
192192

193193
// Lambda -> p pi-
194194
const bool lambdaDecay = (dau0.pdgCode() == PDG_t::kProton && dau1.pdgCode() == PDG_t::kPiMinus) ||
@@ -211,8 +211,8 @@ struct Alice3DecayerQa {
211211
histos.fill(HIST("XiMinus/hHasDecayed"), 1);
212212
auto daughters = particle.daughtersIds();
213213
if (daughters.size() == NCascadeDaughters) {
214-
auto dau0 = particles.rawIteratorAt(daughters.front());
215-
auto dau1 = particles.rawIteratorAt(daughters.back());
214+
auto dau0 = particles.rawIteratorAt(daughters.front() - particles.offset());
215+
auto dau1 = particles.rawIteratorAt(daughters.back() - particles.offset());
216216

217217
// Xi- -> Lambda pi-
218218
const bool xiDecay = (dau0.pdgCode() == PDG_t::kLambda0 && dau1.pdgCode() == PDG_t::kPiMinus) ||
@@ -228,8 +228,8 @@ struct Alice3DecayerQa {
228228
if (v0.has_daughters()) {
229229
auto v0daughters = v0.daughtersIds();
230230
if (v0daughters.size() == NV0Daughters) {
231-
auto v0dau0 = particles.rawIteratorAt(v0daughters.front());
232-
auto v0dau1 = particles.rawIteratorAt(v0daughters.back());
231+
auto v0dau0 = particles.rawIteratorAt(v0daughters.front() - particles.offset());
232+
auto v0dau1 = particles.rawIteratorAt(v0daughters.back() - particles.offset());
233233
const bool lambdaDecay = (v0dau0.pdgCode() == PDG_t::kProton && v0dau1.pdgCode() == PDG_t::kPiMinus) ||
234234
(v0dau0.pdgCode() == PDG_t::kPiMinus && v0dau1.pdgCode() == PDG_t::kProton);
235235
if (lambdaDecay) {

0 commit comments

Comments
 (0)