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 / nThreads;
{
for (
auto i :
ROOT::TSeqI(
n))
ntuple.Fill(rndm.Gaus());
}
{
TFile ofile(
"mtbb101_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(
"mtbb101_multiCore_%u.root", workerID),
"RECREATE");
TNtuple workerRandomNumbers(
"multiCore",
"Random Numbers",
"r");
fillRandom(workerRandomNumbers, workerRndm, workSize);
workerRandomNumbers.Write();
return 0;
};
return 0;
}
int Int_t
Signed integer 4 bytes (int)
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int)
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
A pseudo container class which is a generator of indices.
This class provides a simple interface to execute the same task multiple times in parallel threads,...
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
A simple TTree restricted to a list of float variables only.
Random number generator class based on M.
- Date
- January 2016
- Author
- Danilo Piparo
Definition in file mtbb_fillNtuples.C.