20 const UInt_t nNumbers = 20000000U;
23 const UInt_t nWorkers = 4U;
26 const auto workSize = nNumbers / nWorkers;
29 void fillRandom(TNtuple &ntuple, TRandom3 &rndm, UInt_t n)
31 for (
auto i : ROOT::TSeqI(n))
32 ntuple.Fill(rndm.Gaus());
35 Int_t mt101_fillNtuples()
45 TFile ofile(
"mp101_singleCore.root",
"RECREATE");
46 TNtuple randomNumbers(
"singleCore",
"Random Numbers",
"r");
47 fillRandom(randomNumbers, rndm, nNumbers);
48 randomNumbers.Write();
55 ROOT::EnableThreadSafety();
58 auto workItem = [](UInt_t workerID) {
60 TRandom3 workerRndm(workerID);
61 TFile ofile(Form(
"mt101_multiCore_%u.root", workerID),
"RECREATE");
62 TNtuple workerRandomNumbers(
"multiCore",
"Random Numbers",
"r");
63 fillRandom(workerRandomNumbers, workerRndm, workSize);
64 workerRandomNumbers.Write();
69 std::vector<std::thread> workers;
72 for (
auto workerID : ROOT::TSeqI(nWorkers)) {
73 workers.emplace_back(workItem, workerID);
77 for (
auto &&worker : workers)