15 Int_t mt102_readNtuplesFillHistosAndFit()
22 TChain inputChain(
"multiCore");
23 inputChain.Add(
"mt101_multiCore_*.root");
24 TH1F outHisto(
"outHisto",
"Random Numbers", 128, -4, 4);
25 inputChain.Draw(
"r >> outHisto");
35 const auto nFiles = inputChain.GetListOfFiles()->GetEntries();
38 std::vector<TH1F> histograms;
40 histograms.reserve(nFiles);
41 for (
auto workerID : workerIDs){
42 histograms.emplace_back(
TH1F(
Form(
"outHisto_%u", workerID),
"Random Numbers", 128, -4, 4));
46 auto workItem = [&histograms](
UInt_t workerID) {
47 TFile f(
Form(
"mt101_multiCore_%u.root", workerID));
49 f.GetObject(
"multiCore", ntuple);
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) worker.join();
72 std::for_each(std::begin(histograms), std::end(histograms),
73 [&sumHistogram](
const TH1F &
h) {
77 sumHistogram.Fit(
"gaus",0);
virtual Long64_t GetEntriesFast() const
THist< 1, float, THistStatContent, THistStatUncertainty > TH1F
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
tomato 1-D histogram with a float per channel (see TH1 documentation)}
A simple TTree restricted to a list of float variables only.
char * Form(const char *fmt,...)
Float_t * GetArgs() const
void EnableThreadSafety()
Enables the global mutex to make ROOT thread safe/aware.
A pseudo container class which is a generator of indices.
A chain is a collection of files containg TTree objects.