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);
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);
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
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.
Int_t Fill() override
Fill a Ntuple with current values in fArgs.
virtual Int_t GetEntry(Long64_t entry, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
void EnableThreadSafety()
Enable support for multi-threading within the ROOT code in particular, enables the global mutex to ma...