Skip to content

Commit

Permalink
Translate Pythia6 status codes to Pythia8-like format
Browse files Browse the repository at this point in the history
  • Loading branch information
nburmaso committed Nov 21, 2024
1 parent 1cc5b19 commit 8aa5eb7
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
4 changes: 2 additions & 2 deletions include/UpcGenerator.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class UpcGenerator

// helper struct for ROOT file output
struct outParticle {
int eventNumber;
long int eventNumber;
int pdgCode;
int particleID;
int statusID;
Expand All @@ -211,7 +211,7 @@ class UpcGenerator
outParticle particle{};
std::vector<TParticle> genParticles;

void writeEvent(int evt,
void writeEvent(long int evt,
const std::vector<int>& pdgs,
const std::vector<int>& statuses,
const std::vector<int>& mothers,
Expand Down
10 changes: 5 additions & 5 deletions src/UpcGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ void UpcGenerator::processInPythia(vector<int>& pdgs,
}
int pdg = part->GetPdgCode();
int status = part->GetStatusCode();
int mother = part->GetFirstMother();
int mother = abs(status) == 23 ? 0 : part->GetFirstMother() + 1;
int fDaughter = part->GetFirstDaughter();
int lDaughter = part->GetLastDaughter();
part->Momentum(tlVector);
Expand Down Expand Up @@ -518,7 +518,7 @@ bool UpcGenerator::checkKinCuts(std::vector<TLorentzVector>& particles)
return pass;
}

void UpcGenerator::writeEvent(int evt,
void UpcGenerator::writeEvent(long int evt,
const vector<int>& pdgs,
const vector<int>& statuses,
const vector<int>& mothers,
Expand All @@ -541,7 +541,7 @@ void UpcGenerator::writeEvent(int evt,

if (useHepMCOut) {
writerHepMC->writeEventInfo(evt, static_cast<int>(particles.size()), 1);
for (int i = 0; i < particles.size(); i++) {
for (int i = 0; i < particles.size(); ++i) {
writerHepMC->writeParticleInfo(i + 1, mothers[i], pdgs[i],
particles[i].Px(), particles[i].Py(), particles[i].Pz(), particles[i].E(), particles[i].M(),
statuses[i]);
Expand Down Expand Up @@ -702,13 +702,13 @@ long int UpcGenerator::generateEvent(vector<int>& pdgs,

// uniform pion decays into photon pairs
if (procID == 111) {
twoPartDecayUniform(pdgs, statuses, mothers, particles, 0, 0., 22);
twoPartDecayUniform(pdgs, statuses, mothers, particles, 1, 0., 22);
twoPartDecayUniform(pdgs, statuses, mothers, particles, 2, 0., 22);
}

// uniform ALP decay into two photons
if (procID == 51) {
twoPartDecayUniform(pdgs, statuses, mothers, particles, 0, 0., 22);
twoPartDecayUniform(pdgs, statuses, mothers, particles, 1, 0., 22);
}

// fill genParticles
Expand Down
19 changes: 18 additions & 1 deletion src/UpcPythia6Helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ void UpcPythia6Helper::process(std::vector<int>& pdgs, std::vector<int>& statuse
}
}

// status codes:
// https://www.pythia.org/download/pythia6/pythia6200.pdf
// https://pythia.org/download/pdf/worksheet8153.pdf
int UpcPythia6Helper::import(TClonesArray* particles)
{
int nParts = 0;
Expand All @@ -53,7 +56,21 @@ int UpcPythia6Helper::import(TClonesArray* particles)
for (int i = 0; i < mPartHolder.size(); i++) {
for (int j = 0; j < mPartHolder[i].GetEntriesFast(); j++) {
auto* part = (TParticle*)mPartHolder[i].At(j);
int mother = part->GetFirstMother() == 0 ? 0 : part->GetFirstMother() + shift;
bool isPrimary = part->GetFirstMother() == 0;
bool isFinal = part->GetFirstDaughter() == 0;
int statusP6 = part->GetStatusCode();
int statusP8 = -1;
if (statusP6 == 11 && isPrimary) { // primary, decayed
statusP8 = -23;
}
if (statusP6 == 11 && !isFinal && !isPrimary) { // secondary, decayed
statusP8 = -91;
}
if (statusP6 == 1 && isFinal && !isPrimary) { // secondary, "final state"
statusP8 = 91;
}
part->SetStatusCode(statusP8);
int mother = part->GetFirstMother() == 0 ? -1 : part->GetFirstMother() + shift - 1;
part->SetFirstMother(mother);
new (clonesParticles[nParts]) TParticle(*part);
nParts++;
Expand Down

0 comments on commit 8aa5eb7

Please sign in to comment.