13void mt103_fillNtupleFromMultipleThreads()
22 const size_t nEntries = 65535;
25 const size_t nWorkers = 4;
28 const size_t nEventsPerWorker = nEntries / nWorkers;
31 auto fileName =
"mt103_fillNtupleFromMultipleThreads.root";
38 auto work_function = [&](
int seed) {
39 auto f = merger.GetFile();
40 TNtuple ntrand(
"ntrand",
"Random Numbers",
"r");
50 ntrand.Fill(rnd.Gaus());
55 std::vector<std::thread> workers;
58 workers.emplace_back(work_function, i + 1);
61 for (
auto &&worker : workers)
TBufferMerger is a class to facilitate writing data in parallel from multiple threads,...
A pseudo container class which is a generator of indices.
A simple TTree restricted to a list of float variables only.
This is the base class for the ROOT Random number generators.
void EnableThreadSafety()
Enables the global mutex to make ROOT thread safe/aware.