17void df013_InspectAnalysis()
21 const auto nSlots = 0 == poolSize ? 1 : poolSize;
25 const auto nEvents = nSlots * 10000ull;
30 auto heavyWork = [&
r]() {
31 for (
volatile int i = 0; i < 1000000; ++i)
38 auto df =
d.Define(
"x", heavyWork);
43 auto h = df.Histo1D<
double>({
"browserHisto",
"", 100, -2., 2.},
"x");
54 auto dfDirectory =
new TMemFile(
"RDFResults",
"RECREATE");
55 auto browser =
new TBrowser(
"b", dfDirectory);
57 auto browserPad =
gPad;
66 h.OnPartialResult(
h.kOnce, [dfDirectory](
TH1D &h_) { dfDirectory->Add(&h_); });
73 h.OnPartialResult(50, [&browserPad](
TH1D &hist) {
92 std::string progressBar;
95 const auto everyN = nSlots == 8 ? 1000 : 100ull * nSlots;
96 const auto barWidth = nEvents / everyN;
97 h.OnPartialResultSlot(everyN, [&barWidth, &progressBar, &barMutex](
unsigned int ,
TH1D & ) {
98 std::lock_guard<std::mutex>
l(barMutex);
99 progressBar.push_back(
'#');
101 std::cout <<
"\r[" << std::left << std::setw(barWidth) << progressBar <<
']' << std::flush;
110 std::cout <<
"Analysis running..." << std::endl;
112 std::cout <<
"\nDone!" << std::endl;
116 dfDirectory->Clear();
117 auto clone =
static_cast<TH1D *
>(
h->Clone());
119 dfDirectory->Add(clone);
124 browserPad->Update();
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
R__EXTERN TSystem * gSystem
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
Using a TBrowser one can browse all ROOT objects.
1-D histogram with a double per channel (see TH1 documentation)}
virtual void SetDirectory(TDirectory *dir)
By default, when a histogram is created, it is added to the list of histogram objects in the current ...
void Draw(Option_t *option="") override
Draw this histogram with options.
A TMemFile is like a normal TFile except that it reads and writes only from memory.
This is the base class for the ROOT Random number generators.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
void EnableImplicitMT(UInt_t numthreads=0)
Enable ROOT's implicit multi-threading for all objects and methods that provide an internal paralleli...
UInt_t GetThreadPoolSize()
Returns the size of ROOT's thread pool.