16Int_t mt102_readNtuplesFillHistosAndFit()
 
   23   TChain inputChain(
"multiCore");
 
   24   inputChain.Add(
"mt101_multiCore_*.root");
 
   25   TH1F outHisto(
"outHisto", 
"Random Numbers", 128, -4, 4);
 
   26   inputChain.Draw(
"r >> outHisto");
 
   36   const auto nFiles = inputChain.GetListOfFiles()->GetEntries();
 
   39   std::vector<TH1F> histograms;
 
   41   histograms.reserve(nFiles);
 
   42   for (
auto workerID : workerIDs) {
 
   43      histograms.emplace_back(
TH1F(
Form(
"outHisto_%u", workerID), 
"Random Numbers", 128, -4, 4));
 
   47   auto workItem = [&histograms](
UInt_t workerID) {
 
   48      TFile f(
Form(
"mt101_multiCore_%u.root", workerID));
 
   49      auto ntuple = 
f.Get<
TNtuple>(
"multiCore");
 
   50      auto &histo = histograms.at(workerID);
 
   51      for (
auto index : 
ROOT::TSeqL(ntuple->GetEntriesFast())) {
 
   53         histo.
Fill(ntuple->GetArgs()[0]);
 
   57   TH1F sumHistogram(
"SumHisto", 
"Random Numbers", 128, -4, 4);
 
   60   std::vector<std::thread> workers;
 
   64   for (
auto workerID : workerIDs) {
 
   65      workers.emplace_back(workItem, workerID);
 
   69   for (
auto &&worker : workers)
 
   73   std::for_each(std::begin(histograms), std::end(histograms),
 
   74                 [&sumHistogram](
const TH1F &
h) { sumHistogram.Add(&
h); });
 
   76   sumHistogram.Fit(
"gaus", 0);
 
char * Form(const char *fmt,...)
 
A pseudo container class which is a generator of indices.
 
A chain is a collection of files containing TTree objects.
 
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
 
1-D histogram with a float per channel (see TH1 documentation)}
 
A simple TTree restricted to a list of float variables only.
 
virtual Int_t Fill()
Fill a Ntuple with current values in fArgs.
 
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
 
void EnableThreadSafety()
Enables the global mutex to make ROOT thread safe/aware.