Read n-tuples in distinct workers, fill histograms, merge them and fit.
We express parallelism with multiprocessing as it is done with multithreading in mt102_readNtuplesFillHistosAndFit.
Int_t mp102_readNtuplesFillHistosAndFit()
{
TChain inputChain(
"multiCore");
inputChain.Add("mp101_multiCore_*.root");
if (inputChain.GetNtrees() <= 0) {
Printf(
" No files in the TChain: did you run mp101_fillNtuples.C before?");
return 1;
}
TH1F outHisto(
"outHisto",
"Random Numbers", 128, -4, 4);
inputChain.Draw("r >> outHisto");
outHisto.Fit("gaus");
const auto nFiles = inputChain.GetListOfFiles()->GetEntries();
auto partialHisto =
new TH1F(
"outHistoMP",
"Random Numbers", 128, -4, 4);
while (reader.Next()) {
partialHisto->Fill(*randomRV);
}
return partialHisto;
};
auto sumHistogram = workers.Process(inputChain, workItem, "multiCore");
sumHistogram->Fit("gaus", 0);
return 0;
}
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
This class provides an interface to process a TTree dataset in parallel with multi-process technology...
A chain is a collection of files containing TTree objects.
1-D histogram with a float per channel (see TH1 documentation)
An interface for reading values stored in ROOT columnar datasets.
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
- Date
- January 2016
- Author
- Danilo Piparo
Definition in file mp102_readNtuplesFillHistosAndFit.C.