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);
partialHisto->Fill(*randomRV);
}
return partialHisto;
};
auto sumHistogram = workers.Process(inputChain, workItem, "multiCore");
sumHistogram->Fit("gaus", 0);
return 0;
}
- Date
- January 2016
- Author
- Danilo Piparo
Definition in file mp102_readNtuplesFillHistosAndFit.C.