Skip to content

Commit 6013796

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

4 files changed

Lines changed: 9 additions & 9 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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void GeneratorFactory::setPrimaryGenerator(o2::conf::SimConfig const& conf, Fair
140140

141141
/** generators **/
142142

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

‎macro/o2sim.C‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ FairRunSim* o2sim_init(bool asservice, bool evalmat = false)
177177
// run init
178178
run->Init();
179179

180-
// add ALICE particles to TDatabasePDG singleton
181-
o2::O2DatabasePDG::addALICEParticles(TDatabasePDG::Instance());
180+
// ensure ALICE particles are in the TDatabasePDG singleton (added once, thread-safely)
181+
o2::O2DatabasePDG::Instance();
182182

183183
long runStart = timestamp;
184184
{

0 commit comments

Comments
 (0)