14 const UInt_t nWorkers = 8U;
17 const Double_t xmiref = -1.;
18 const Double_t xmaref = 7.;
20 Int_t mt304_fillHistos(UInt_t nNumbers = 1001)
25 ROOT::EnableThreadSafety();
28 ROOT::TThreadedObject<TH1D> h1d(
"h1d",
"1D test histogram", 64, 0., -1.);
29 ROOT::TThreadedObject<TH1D> h1dr(
"h1dr",
"1D test histogram w/ ref boundaries", 64, xmiref, xmaref);
32 auto workItem = [&](UInt_t workerID) {
34 TRandom3 workerRndm(workerID);
36 auto wh1d = h1d.Get();
37 wh1d->SetBit(TH1::kAutoBinPTwo);
38 auto wh1dr = h1dr.Get();
41 for (UInt_t i = 0; i < nNumbers; ++i) {
42 x = workerRndm.Gaus(3.);
49 std::vector<std::thread> workers;
52 for (
auto workerID : ROOT::TSeqI(nWorkers)) {
53 workers.emplace_back(workItem, workerID);
57 for (
auto &&worker : workers)
61 auto fh1d = h1d.Merge();
62 auto fh1dr = h1dr.Merge();
65 auto c =
new TCanvas(
"c",
"c", 800, 800);
68 gStyle->SetOptStat(111110);