Fill histograms in parallel with automatic binning.
Illustrates use of power-of-two autobin algorithm
#include <thread>
#include <iostream>
{
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();
fh1d->DrawCopy();
fh1dr->DrawCopy();
return 0;
}
- Author
- Gerardo Ganis
Definition in file mt304_fillHistos.C.