Fill histograms in parallel and write them on file.
This example expresses the parallelism of the mt001_fillHistos.C tutorial with multiprocessing techniques.
const UInt_t nNumbers = 20000000U;
Int_t mtbb001_fillHistos()
{
auto workItem = [](
UInt_t workerID) {
TFile f(
Form(
"myFile_%u.root", workerID),
"RECREATE");
TH1F h(
Form(
"myHisto_%u", workerID),
"The Histogram", 64, -4, 4);
for (
UInt_t i = 0; i < nNumbers; ++i) {
h.
Fill(workerRndm.Gaus());
}
return 0;
};
ROOT::TThreadExecutor pool(nThreads);
return 0;
}
- Author
- Danilo Piparo
Definition in file mtbb001_fillHistos.C.