18 const UInt_t nNumbers = 20000000U;
21 const UInt_t nThreads = 4U;
24 const auto workSize = nNumbers / nThreads;
27 void fillRandom(TNtuple &ntuple, TRandom3 &rndm, UInt_t n)
29 for (
auto i : ROOT::TSeqI(n))
30 ntuple.Fill(rndm.Gaus());
33 Int_t mtbb101_fillNtuples()
35 ROOT::EnableThreadSafety();
43 TFile ofile(
"mtbb101_singleCore.root",
"RECREATE");
44 TNtuple randomNumbers(
"singleCore",
"Random Numbers",
"r");
45 fillRandom(randomNumbers, rndm, nNumbers);
46 randomNumbers.Write();
52 auto workItem = [](UInt_t workerID) {
54 TRandom3 workerRndm(workerID);
55 TFile ofile(Form(
"mtbb101_multiCore_%u.root", workerID),
"RECREATE");
56 TNtuple workerRandomNumbers(
"multiCore",
"Random Numbers",
"r");
57 fillRandom(workerRandomNumbers, workerRndm, workSize);
58 workerRandomNumbers.Write();
63 ROOT::TThreadExecutor pool(nThreads);
66 pool.Map(workItem, ROOT::TSeqI(nThreads));