Logo ROOT  
Reference Guide
mtbb201_parallelHistoFill.C File Reference

Detailed Description

View in nbviewer Open in SWAN Parallel fill of a histogram. This tutorial shows how a histogram can be filled in parallel with a multiprocess approach.

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;
}
Date
January 2016
Author
Danilo Piparo.

Definition in file mtbb201_parallelHistoFill.C.

c
#define c(i)
Definition: RSha256.hxx:119
TRandom::Gaus
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
Definition: TRandom.cxx:263
ROOT::ExecutorUtils::ReduceObjects
Merge collection of TObjects.
Definition: PoolUtils.h:47
ROOT::TThreadExecutor
This class provides a simple interface to execute the same task multiple times in parallel,...
Definition: TThreadExecutor.hxx:41
ROOT::TSeqI
TSeq< int > TSeqI
Definition: TSeq.hxx:194
Int_t
int Int_t
Definition: RtypesCore.h:45
TRandom3
Definition: TRandom3.h:27
h
#define h(i)
Definition: RSha256.hxx:124
TH1::AddDirectory
static void AddDirectory(Bool_t add=kTRUE)
Sets the flag controlling the automatic add of histograms in memory.
Definition: TH1.cxx:1225
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TCanvas
Definition: TCanvas.h:23
TH1F
1-D histogram with a float per channel (see TH1 documentation)}
Definition: TH1.h:572
ROOT::TSeq
A pseudo container class which is a generator of indices.
Definition: TSeq.hxx:66