Skip to content

Commit

Permalink
More fixes for newer Pythia
Browse files Browse the repository at this point in the history
In newer (>= 8.310) the `SubCollision` objects may not be stored with
the `HIInfo` object.  Thus, we cannot rely on those to be present when
calculating $N_{\mathrm{coll}}$, $N_{\mathrm{part}}$, and so on.

Instead, we must use the quantities stored directly in the `HIInfo`
object.

This PR fixes that issue by protecting on the Pythia version and falling
back to the information stored in `HIInfo`.

See also JIRA [issue](https://its.cern.ch/jira/browse/O2-4699).
  • Loading branch information
cholmcc authored and sawenzel committed Mar 13, 2024
1 parent 7b6518b commit 0129938
Showing 1 changed file with 28 additions and 6 deletions.
34 changes: 28 additions & 6 deletions Generators/src/GeneratorPythia8.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -752,14 +752,21 @@ void GeneratorPythia8::getNcoll(const Pythia8::Info& info, int& nColl)
#else
auto hiinfo = info.hiInfo;
#endif
nColl = 0;
if (!hiinfo) {
LOG(warn) << "No heavy-ion information from Pythia";
return;
}

// This is how the Pythia authors define Ncoll
nColl = (hiinfo->nAbsProj() + hiinfo->nDiffProj() +
hiinfo->nAbsTarg() + hiinfo->nDiffTarg() -
hiinfo->nCollND() - hiinfo->nCollDD());
nColl = 0;

if (!hiinfo) {
if (not hiinfo->subCollisionsPtr()) {
#if PYTHIA_VERSION_INTEGER < 8310
LOG(fatal) << "No sub-collision pointer from Pythia";
#endif
return;
}

Expand All @@ -785,15 +792,21 @@ void GeneratorPythia8::getNpart(const Pythia8::Info& info, int& nPart)

/** compute number of participants as the sum of all participants nucleons **/

// This is how the Pythia authors calculate Npart
#if PYTHIA_VERSION_INTEGER < 8300
auto hiinfo = info.hiinfo;
#else
auto hiinfo = info.hiInfo;
#endif
if (hiinfo) {
nPart = (hiinfo->nAbsProj() + hiinfo->nDiffProj() +
hiinfo->nAbsTarg() + hiinfo->nDiffTarg());
nPart = 0;
if (not hiinfo) {
return;
}

// This is how the Pythia authors calculate Npart
nPart = (hiinfo->nAbsProj() + hiinfo->nDiffProj() +
hiinfo->nAbsTarg() + hiinfo->nDiffTarg());
if (not hiinfo->subCollisionsPtr()) {
return;
}

int nProtonProj, nNeutronProj, nProtonTarg, nNeutronTarg;
Expand All @@ -819,6 +832,15 @@ void GeneratorPythia8::getNpart(const Pythia8::Info& info, int& nProtonProj, int
return;
}

nProtonProj = hiinfo->nAbsProj() + hiinfo->nDiffProj();
nProtonTarg = hiinfo->nAbsTarg() + hiinfo->nDiffTarg();
if (not hiinfo->subCollisionsPtr()) {
#if PYTHIA_VERSION_INTEGER < 8310
LOG(fatal) << "No sub-collision pointer from Pythia";
#endif
return;
}

// keep track of wounded nucleons
std::vector<Pythia8::Nucleon*> projW;
std::vector<Pythia8::Nucleon*> targW;
Expand Down

0 comments on commit 0129938

Please sign in to comment.