Logo ROOT   6.10/09
Reference Guide
mtbb201_parallelHistoFill.C File Reference

Detailed Description

Parallel fill of a histogram.

This tutorial shows how a histogram can be filled in parallel with a multiprocess approach.

pict1_mtbb201_parallelHistoFill.C.png
/// \date January 2016
const UInt_t poolSize = 4U;
Int_t mtbb201_parallelHistoFill()
{
ROOT::TThreadExecutor pool(poolSize);
auto fillRandomHisto = [](int seed = 0) {
TRandom3 rndm(seed);
auto h = new TH1F("myHist", "Filled in parallel", 128, -8, 8);
for (auto i : ROOT::TSeqI(1000000)) {
h->Fill(rndm.Gaus(0,1));
}
return h;
};
auto seeds = ROOT::TSeqI(23);
auto sumRandomHisto = pool.MapReduce(fillRandomHisto, seeds, redfunc);
auto c = new TCanvas();
sumRandomHisto->Draw();
return 0;
}
Author
Danilo Piparo.

Definition in file mtbb201_parallelHistoFill.C.