Fill n-tuples in distinct workers.
This tutorial illustrates the basics of how it's possible with ROOT to offload heavy operations on multiple processes and how it's possible to write simultaneously multiple files. The operation performed in this case is the creation of random gaussian numbers.
const UInt_t nNumbers = 20000000U;
const auto workSize = nNumbers / nWorkers;
{
}
Int_t mp101_fillNtuples()
{
TFile ofile(
"mp101_singleCore.root",
"RECREATE");
TNtuple randomNumbers(
"singleCore",
"Random Numbers",
"r");
fillRandom(randomNumbers, rndm, nNumbers);
randomNumbers.Write();
ofile.Close();
auto workItem = [](
UInt_t workerID) {
TFile ofile(
Form(
"mp101_multiCore_%u.root", workerID),
"RECREATE");
TNtuple workerRandomNumbers(
"multiCore",
"Random Numbers",
"r");
fillRandom(workerRandomNumbers, workerRndm, workSize);
workerRandomNumbers.Write();
return 0;
};
return 0;
}
char * Form(const char *fmt,...)
This class provides a simple interface to execute the same task multiple times in parallel,...
A pseudo container class which is a generator of indices.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
A simple TTree restricted to a list of float variables only.
virtual Int_t Fill()
Fill a Ntuple with current values in fArgs.
Random number generator class based on M.
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...
- Date
- January 2016
- Author
- Danilo Piparo
Definition in file mp101_fillNtuples.C.