Skip to content

Commit

Permalink
More consistently apply external ion pdg table
Browse files Browse the repository at this point in the history
It appears that sometimes the external ion table
was not loaded (only when users got hold of the singleton instance).
This should now be fixed.
  • Loading branch information
sawenzel committed Jun 18, 2024
1 parent 594e3ed commit 93a3d19
Showing 1 changed file with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,14 @@ class O2DatabasePDG
auto db = TDatabasePDG::Instance();
if (!initialized) {
addALICEParticles(db);
if (const char* o2Root = std::getenv("O2_ROOT")) {
auto inputExtraPDGs = std::string(o2Root) + "/share/Detectors/gconfig/data/extra_ions_pdg_table.dat";
db->ReadPDGTable(inputExtraPDGs.c_str());
}
initialized = true;
}
return db;
}

// adds ALICE particles to a given TDatabasePDG instance
static void addALICEParticles(TDatabasePDG* db = TDatabasePDG::Instance());
static void addParticlesFromExternalFile(TDatabasePDG* db);

// get particle's (if any) mass
static Double_t MassImpl(TParticlePDG* particle, bool& success)
Expand Down Expand Up @@ -655,6 +652,26 @@ inline void O2DatabasePDG::addALICEParticles(TDatabasePDG* db)
if (!db->GetParticle(-ionCode)) {
db->AddParticle("AntiSexaquark", "AntiSexaquark", 2.0, kTRUE, 0.0, 0, "Special", -ionCode);
}

// lastly, add particle from the the extra text file
addParticlesFromExternalFile(db);
}

inline void O2DatabasePDG::addParticlesFromExternalFile(TDatabasePDG* db)
{
static bool initialized = false;
if (!initialized) {
// allow user to specify custom file
if (const char* custom = std::getenv("O2_SIM_CUSTOM_PDG")) {
// TODO: make sure this is a file
db->ReadPDGTable(custom);
} else if (const char* o2Root = std::getenv("O2_ROOT")) {
// take the maintained file from O2
auto inputExtraPDGs = std::string(o2Root) + "/share/Detectors/gconfig/data/extra_ions_pdg_table.dat";
db->ReadPDGTable(inputExtraPDGs.c_str());
}
initialized = true;
}
}

} // namespace o2
Expand Down

0 comments on commit 93a3d19

Please sign in to comment.