Fill histograms in parallel with automatic binning.
Illustrates use of power-of-two autobin algorithm
{
auto workItem = [&](
UInt_t workerID) {
auto wh1d = h1d.Get();
auto wh1dr = h1dr.Get();
for (
UInt_t i = 0; i < nNumbers; ++i) {
x = workerRndm.Gaus(3.);
wh1d->Fill(x);
wh1dr->Fill(x);
}
};
std::vector<std::thread> workers;
workers.emplace_back(workItem, workerID);
}
for (auto &&worker : workers)
worker.join();
auto fh1d = h1d.Merge();
auto fh1dr = h1dr.Merge();
auto c =
new TCanvas(
"c",
"c", 800, 800);
c->Divide(1, 2);
c->cd(1);
fh1d->DrawCopy();
c->cd(2);
fh1dr->DrawCopy();
c->Update();
return 0;
}
- Author
- Gerardo Ganis
Definition in file mt304_fillHistos.C.