Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "Pythia8/Pythia.h"
#include "TRandom.h"
#include <fairlogger/Logger.h>
#include <algorithm>
#include <string>
#include <vector>

Expand Down Expand Up @@ -119,18 +120,45 @@ class GeneratorPythia8HFHadToNuclei : public o2::eventgen::GeneratorPythia8
int id = std::abs(event[iPart].id());
float rap = event[iPart].y();
if (id == mHadronPdg && rap > mHadRapidityMin && rap < mHadRapidityMax) {

int d1 = event[iPart].daughter1();
int d2 = event[iPart].daughter2();

// Protection for invalid index of daughter 1
if (d1 < 0 || d1 >= event.size()) {
LOG(info) << "Invalid daughter index 1! d1 = " << d1;
continue;
}

// Protection for invalid index of daughter 2
if (d2 < 0 || d2 >= event.size()) {
LOG(info) << "Invalid daughter index 2! d2 = " << d2;
continue;
}

// Swap order
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @alcaliva ! Thanks for the update! I don't have any major comment. Just for my understanding though, does it really happens to have unsorted daughter indices? If I am not mistaken, the first and last daughter indices correspond to the first and last daughter index in the decay tree

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @stefanopolitano,
honestly, I don't know. I've seen this kind of protection in other codes so I decided to include it also here.
If it doesn't happen, it should be harmless.

if (d1 > d2) {
std::swap(d1, d2);
}

// No daughters
if (d1 == 0 && d2 == 0) {
LOG(info) << "No daughters (0,0). Skipping.";
continue;
}

LOG(debug) << "-----------------------------------------------------";
LOG(debug) << "Found hadron " << event[iPart].id() << " with rapidity " << rap << " and daughters " << event[iPart].daughter1() << " " << event[iPart].daughter2();
LOG(debug) << "Found hadron " << event[iPart].id() << " with rapidity " << rap << " and daughters " << d1 << " " << d2;
// print pdg code of daughters
LOG(debug) << "Daughters: ";
for (int iDau = event[iPart].daughter1(); iDau <= event[iPart].daughter2(); ++iDau) {
for (int iDau = d1; iDau <= d2; ++iDau) {
LOG(debug) << "Daughter " << iDau << ": " << event[iDau].id();
}
bool isCoalDone = CoalescencePythia8(event, mNucleiPdgList, mTrivialCoal, mCoalMomentum, event[iPart].daughter1(), event[iPart].daughter2());
bool isCoalDone = CoalescencePythia8(event, mNucleiPdgList, mTrivialCoal, mCoalMomentum, d1, d2);
if (isCoalDone) {
LOG(debug) << "Coalescence process found for hadron " << event[iPart].id() << " with daughters " << event[iPart].daughter1() << " " << event[iPart].daughter2();
LOG(debug) << "Coalescence process found for hadron " << event[iPart].id() << " with daughters " << d1 << " " << d2;
LOG(debug) << "Check updated daughters: ";
for (int iDau = event[iPart].daughter1(); iDau <= event[iPart].daughter2(); ++iDau) {
for (int iDau = d1; iDau <= d2; ++iDau) {
LOG(debug) << "Daughter " << iDau << ": " << event[iDau].id();
}
return true;
Expand Down Expand Up @@ -171,4 +199,4 @@ FairGenerator *generateHFHadToNuclei(int input_trigger_ratio = 5, std::vector<in
myGen->readString("Random:setSeed on");
myGen->readString("Random:seed " + std::to_string(seed));
return myGen;
}
}