32auto myCanvas = std::make_unique<TCanvas>(
"myCanvas",
"myCanvas", 1000, 500);
34void df042_ThreadSafeRNG()
36 myCanvas->Divide(3, 1);
38 unsigned int nEntries{10000000};
42 auto h1 = df1.Histo1D({
"h1",
"Single thread (no MT)", 1000, -4, 4}, {
"x"});
50 unsigned int nSlots{std::max(2u, std::thread::hardware_concurrency() / 4u)};
56 auto h2 = df2.
Histo1D({
"h2",
"Thread-safe (MT, non-deterministic)", 1000, -4, 4}, {
"x"});
72 auto h3 = df3.
Histo1D({
"h3",
"Thread-safe (MT, deterministic)", 1000, -4, 4}, {
"x"});
76 std::cout << std::fixed << std::setprecision(3) <<
"Final distributions : " <<
"Mean " <<
" +- "
77 <<
"StdDev" << std::endl;
78 std::cout << std::fixed << std::setprecision(3) <<
"Theoretical : " <<
"0.000" <<
" +- "
79 <<
"1.000" << std::endl;
80 std::cout << std::fixed << std::setprecision(3) <<
"Single thread (no MT) : " <<
h1->
GetMean() <<
" +- "
82 std::cout << std::fixed << std::setprecision(3) <<
"Thread-safe (MT, non-deterministic): " << h2->GetMean() <<
" +- "
83 << h2->GetStdDev() << std::endl;
84 std::cout << std::fixed << std::setprecision(3) <<
"Thread-safe (MT, deterministic) : " << h3->GetMean() <<
" +- "
85 << h3->GetStdDev() << std::endl;
RResultPtr<::TH1D > Histo1D(const TH1DModel &model={"", "", 128u, 0., 0.}, std::string_view vName="")
Fill and return a one-dimensional histogram with the values of a column (lazy action).
RInterface< Proxied > DefineSlotEntry(std::string_view name, F expression, const ColumnNames_t &columns={})
Define a new column with a value dependent on the processing slot and the current entry.
RInterface< Proxied > DefineSlot(std::string_view name, F expression, const ColumnNames_t &columns={})
Define a new column with a value dependent on the processing slot.
RInterface< Proxied > Define(std::string_view name, F expression, const ColumnNames_t &columns={})
Define a new column.
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
virtual Double_t GetStdDev(Int_t axis=1) const
Returns the Standard Deviation (Sigma).
virtual Double_t GetMean(Int_t axis=1) const
For axis = 1,2 or 3 returns the mean value of the histogram along X,Y or Z axis.
void Draw(Option_t *option="") override
Draw this histogram with options.
double GetNormallyDistributedNumberPerSlotGeneratorForEntry(unsigned int slot, unsigned long long entry)
double GetNormallyDistributedNumberFromGlobalGenerator()
void ReinitializeGenerators(unsigned int nSlots)
double GetNormallyDistributedNumberPerSlotGenerator(unsigned int slot)
void EnableImplicitMT(UInt_t numthreads=0)
Enable ROOT's implicit multi-threading for all objects and methods that provide an internal paralleli...