Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion ALICE3/Core/OTFParticle.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ class OTFParticle
mPz = pz;
mE = e;
}
void setIndexOffset(const std::size_t offset)
{
static constexpr int NotFound = -1;
mIndicesMother[0] = (mIndicesMother[0] >= 0) ? mIndicesMother[0] + static_cast<int>(offset) : NotFound;
mIndicesMother[1] = (mIndicesMother[1] >= 0) ? mIndicesMother[1] + static_cast<int>(offset) : NotFound;
mIndicesDaughter[0] = (mIndicesDaughter[0] >= 0) ? mIndicesDaughter[0] + static_cast<int>(offset) : NotFound;
mIndicesDaughter[1] = (mIndicesDaughter[1] >= 0) ? mIndicesDaughter[1] + static_cast<int>(offset) : NotFound;
}

// Getters
int pdgCode() const { return mPdgCode; }
Expand Down Expand Up @@ -171,7 +179,7 @@ class OTFParticle

private:
int mPdgCode{}, mGlobalIndex{-1};
int mCollisionId{};
int mCollisionId{-1};
float mVx{}, mVy{}, mVz{}, mVt{};
float mPx{}, mPy{}, mPz{}, mE{};
bool mIsAlive{}, mIsFromMcParticles{false};
Expand Down
29 changes: 15 additions & 14 deletions ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@
{DefaultParameters[0], NumDecays, NumParameters, ParticleNames, ParameterNames},
"Enable option for particle to be decayed: 0 - no, 1 - yes"};

std::size_t indexOffset = 0;
static constexpr float PicoToNano = 1.e-3f;
int mCollisionId{-1};

std::vector<int> mEnabledDecays;
void init(o2::framework::InitContext&)
{
Expand Down Expand Up @@ -152,9 +151,9 @@

const float trackTimeNS = trackLength / trackVelocity * PicoToNano;
particle.setIndicesDaughter(allParticles.size(), allParticles.size() + (decayStack.size() - 1));
for (o2::upgrade::OTFParticle daughter : decayStack) {

Check failure on line 154 in ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
daughter.setIndicesMother(i, i);
daughter.setCollisionId(mCollisionId);
daughter.setCollisionId(particle.collisionId());
daughter.setBitOn(o2::upgrade::DecayerBits::IsAlive);
daughter.setBitOff(o2::upgrade::DecayerBits::IsPrimary);
daughter.setProductionTime(trackTimeNS);
Expand All @@ -173,18 +172,14 @@
void process(aod::McCollisions_001From<aod::Hash<"TMP"_h>>::iterator const& collision, aod::McParticles_001From<aod::Hash<"TMP"_h>> const& mcParticles)
{
allParticles.clear();
if (collision.globalIndex() == 0) {
indexOffset = 0;
}

// Reproduce collision table to have AOD origin
mCollisionId = collision.globalIndex();
tableMcCollisions(collision.bcId(),
collision.generatorsID(),
collision.posX(),
collision.posY(),
collision.posZ(),
collision.t(),
collision.weight(),
collision.impactParameter(),
collision.eventPlaneAngle());
tableMcCollisions(collision.bcId(), collision.generatorsID(),
collision.posX(), collision.posY(), collision.posZ(), collision.t(),
collision.weight(), collision.impactParameter(), collision.eventPlaneAngle());

// First we copy the particles from the table into a vector that is extendable
for (const auto& particle : mcParticles) {
Expand All @@ -195,7 +190,8 @@
decayParticles(0, allParticles.size());

// Fill output table
for (const auto& otfParticle : allParticles) {
for (auto& otfParticle : allParticles) {

Check failure on line 193 in ALICE3/TableProducer/OTF/onTheFlyDecayer.cxx

View workflow job for this annotation

GitHub Actions / O2 linter

[const-ref-in-for-loop]

Use constant references for non-modified iterators in range-based for loops.
otfParticle.setIndexOffset(indexOffset);
if (otfParticle.hasNaN()) {
histos.fill(HIST("hNaNBookkeeping"), 1);
} else {
Expand All @@ -208,6 +204,11 @@
otfParticle.px(), otfParticle.py(), otfParticle.pz(), otfParticle.e(),
otfParticle.vx(), otfParticle.vy(), otfParticle.vz(), otfParticle.vt());
}

// Particles for later collisions in df's needs to have thier mother
// and daughter indices adjusted since their global index will be
// shifted due to the appending of decay products
indexOffset += (allParticles.size() - mcParticles.size());
}
};

Expand Down
Loading