Skip to content

Commit 3bb0feb

Browse files
committed
Make O2DatabasePDG::Instance() thread-safe and remove duplicate PDG warnings
1 parent eeaf095 commit 3bb0feb

3 files changed

Lines changed: 7 additions & 14 deletions

File tree

‎DataFormats/simulation/include/SimulationDataFormat/O2DatabasePDG.h‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ class O2DatabasePDG
3434
public:
3535
static TDatabasePDG* Instance()
3636
{
37-
static bool initialized = false; // initialize this --> adds particles to TDatabasePDG;
38-
auto db = TDatabasePDG::Instance();
39-
if (!initialized) {
37+
// adds the ALICE particles to TDatabasePDG on first use.
38+
// Initialisation is done through a local static database to make the Instance() function thread-safe
39+
static TDatabasePDG* db = [] {
40+
auto db = TDatabasePDG::Instance();
4041
addALICEParticles(db);
41-
initialized = true;
42-
}
42+
return db;
43+
}();
4344
return db;
4445
}
4546

‎Detectors/gconfig/data/extra_ions_pdg_table.dat‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,6 @@
706706
1352 W174 1000741740 1 100 Ion 222 1.61992e+02 0.00000e+00 0 0 0 -1 0 0
707707
1353 Hg198 1000801980 1 100 Ion 240 1.84365e+02 0.00000e+00 0 0 0 -1 0 0
708708
1354 Pd115 1000461150 1 100 Ion 138 1.07018e+02 0.00000e+00 0 0 0 -1 0 0
709-
1355 Li4 1000030040 1 100 Ion 9 3.74977e+00 0.00000e+00 0 0 0 -1 0 0
710709
1356 Lu170 1000711700 1 100 Ion 213 1.58261e+02 0.00000e+00 0 0 0 -1 0 0
711710
1357 Ho163 1000671630 1 100 Ion 201 1.51733e+02 0.00000e+00 0 0 0 -1 0 0
712711
1358 Tm153 1000691530 1 100 Ion 207 1.42430e+02 0.00000e+00 0 0 0 -1 0 0

‎Generators/src/GeneratorFactory.cxx‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ namespace eventgen
6060
// using the configured GeneratorExternalParam. This makes the simulation parallelisation automatic
6161
// on Hyperloop.
6262
// To-do: Define the behaviour with ini configuration which are already definining a hybrid gen
63-
//
64-
// Note on GeneratorHybrid.num_workers: expanding to 8 sub-generators does not by itself raise
65-
// the number of TBB workers that actually run them in parallel. This is controlled by
66-
// the parameter GeneratorHybrid.num_workers. On Hyperloop this will be part
67-
// of the standard train configuration
6863
std::string buildHyperloopExternalHybridConfig(GeneratorExternalParam const& extparams)
6964
{
7065
rapidjson::Document doc;
@@ -89,12 +84,10 @@ std::string buildHyperloopExternalHybridConfig(GeneratorExternalParam const& ext
8984
doc.AddMember("generators", generators, alloc);
9085
doc.AddMember("fractions", fractions, alloc);
9186

92-
// The generated config file is deliberatelly left on disk for possible inspection after the process ran.
9387
std::string path = "hyperloop_exttohybrid_" + std::to_string(getpid()) + ".json";
9488
std::ofstream ofs(path);
9589
if (!ofs.is_open()) {
9690
LOG(fatal) << "Failed to open " << path << " for writing the Hyperloop hybrid generator configuration";
97-
exit(1);
9891
}
9992
rapidjson::OStreamWrapper osw(ofs);
10093
rapidjson::Writer<rapidjson::OStreamWrapper> writer(osw);
@@ -140,7 +133,7 @@ void GeneratorFactory::setPrimaryGenerator(o2::conf::SimConfig const& conf, Fair
140133

141134
/** generators **/
142135

143-
o2::O2DatabasePDG::addALICEParticles(TDatabasePDG::Instance());
136+
o2::O2DatabasePDG::Instance(); //--> ALICE particles are added once in this call
144137
auto genconfig = conf.getGenerator();
145138
#if defined(GENERATORS_WITH_PYTHIA8) && defined(GENERATORS_WITH_HEPMC3)
146139
std::string hyperloopExtHybridConfigFile; // set when IS_HYPERLOOP is defined

0 commit comments

Comments
 (0)