15#include "RConfigure.h"
31#if (!defined(_WIN32)) && (!defined(_WIN64))
35#if defined(_WIN32) || defined(_WIN64)
36#define WIN32_LEAN_AND_MEAN
47#if defined(_WIN32) || defined(_WIN64)
69 Warning(
"RunGraphs",
"Got an empty list of handles, now quitting.");
74 const unsigned int nToRun =
77 Warning(
"RunGraphs",
"Got %zu handles from which %zu link to results which are already ready.",
handles.size(),
86 std::vector<RResultHandle>
uniqueLoops(s.begin(), s.end());
105 <<
"Just-in-time compilation phase for RunGraphs (" <<
uniqueLoops.size()
106 <<
" unique computation graphs) completed"
107 << (
sw.RealTime() > 1
e-3 ?
" in " + std::to_string(
sw.RealTime()) +
" seconds." :
" in less than 1ms.");
112 h.fLoopManager->Run(
false);
127 <<
"Finished RunGraphs run (" <<
uniqueLoops.size() <<
" unique computation graphs, " <<
sw.CpuTime() <<
"s CPU, "
128 <<
sw.RealTime() <<
"s elapsed).";
135 throw std::logic_error(
"Varying a Snapshot result is not implemented yet.");
141namespace Experimental {
174 using namespace std::chrono;
193struct RestoreStreamState {
194 RestoreStreamState(std::ostream &stream) :
fStream(stream),
fFlags(stream.flags()),
fFillChar(stream.fill()) {}
209 RestoreStreamState
restore(stream);
210 auto h = std::chrono::duration_cast<std::chrono::hours>(
elapsedSeconds);
211 auto m = std::chrono::duration_cast<std::chrono::minutes>(
elapsedSeconds -
h);
215 stream <<
h.count() <<
':' << std::setw(2) << std::right << std::setfill(
'0');
216 stream <<
m.count() <<
':' << std::setw(2) << std::right << std::setfill(
'0') << s;
217 return stream << (
h.count() > 0 ?
'h' :
'm');
226 RestoreStreamState
restore(stream);
233 stream <<
"\033[35m";
242 stream <<
"\033[32m";
254 stream << std::scientific << std::setprecision(2) <<
evtpersec <<
" evt/s";
259 stream <<
"\033[35m";
263 <<
" remaining time (per file being processed)";
273 RestoreStreamState
restore(stream);
278 stream <<
"\033[35m";
287 stream <<
"\033[32m";
291 stream <<
" / " << std::scientific << std::setprecision(2) <<
totalEvents;
307 RestoreStreamState
restore(stream);
312 std::string
bars(std::max(
nBar, 1u),
'=');
316 stream <<
"\033[33m";
317 stream <<
'|' << std::setfill(
' ') << std::setw(
fBarWidth) << std::left <<
bars <<
"| ";
343 std::mutex fPrintMutex;
344 if (!fPrintMutex.try_lock())
346 std::lock_guard<std::mutex>
lockGuard(fPrintMutex, std::adopt_lock);
353 std::cout <<
'\r' << std::string(
get_tty_size(),
' ') <<
'\r';
365 this->fHelper->registerNewSample(
slot,
id);
366 return this->fHelper->ComputeNEventsSoFar();
374 auto progress = std::make_shared<ProgressHelper>(1000,
total_files);
377 r.OnPartialResultSlot(1000, [progress](
unsigned int slot,
auto &&arg) { (*progress)(
slot, arg); });
std::ostream::char_type fFillChar
std::ios_base::fmtflags fFlags
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
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
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Base class for action helpers, see RInterface::Book() for more information.
ROOT::RDF::SampleCallback_t GetSampleCallback() final
Override this method to register a callback that is executed before the processing a new data sample ...
std::shared_ptr< ProgressHelper > fHelper
int & PartialUpdate(unsigned int)
ProgressBarAction(std::shared_ptr< ProgressHelper > r)
void InitTask(TTreeReader *, unsigned int)
std::shared_ptr< int > fDummyResult
std::shared_ptr< Result_t > GetResultPtr() const
std::string GetActionName()
std::pair< std::size_t, std::chrono::seconds > RecordEvtCountAndTime()
Record current event counts and time stamp, populate evts/s statistics array.
void PrintProgressBar(std::ostream &stream, std::size_t currentEventCount) const
Print a progress bar of width ProgressHelper::fBarWidth if fGetNEventsOfCurrentFile is known.
void PrintStats(std::ostream &stream, std::size_t currentEventCount, std::chrono::seconds totalElapsedSeconds) const
Print event and time statistics.
std::size_t fLastProcessedEvents
std::array< double, 20 > fEventsPerSecondStatistics
double EvtPerSec() const
Compute a running mean of events/s.
std::atomic< std::size_t > fProcessedEvents
unsigned int ComputeCurrentFileIdx() const
ProgressHelper(std::size_t increment, unsigned int totalFiles=1, unsigned int progressBarWidth=40, unsigned int printInterval=1, bool useColors=true)
Create a progress helper.
std::chrono::time_point< std::chrono::system_clock > fLastPrintTime
std::chrono::time_point< std::chrono::system_clock > fBeginTime
void PrintStatsFinal(std::ostream &stream, std::chrono::seconds totalElapsedSeconds) const
std::size_t fEventsPerSecondStatisticsIndex
std::size_t ComputeNEventsSoFar() const
The public interface to the RDataFrame federation of classes.
RResultPtr< typename std::decay_t< Helper >::Result_t > Book(Helper &&helper, const ColumnNames_t &columns={})
Book execution of a custom action using a user-defined helper object.
A type-erased version of RResultPtr and RResultMap.
Smart pointer for the return type of actions.
This type represents a sample identifier, to be used in conjunction with RDataFrame features such as ...
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
ELogLevel GetEffectiveVerbosity(const RLogManager &mgr) const
static RLogManager & Get()
Change the verbosity level (global or specific to the RLogChannel passed to the constructor) for the ...
const_iterator begin() const
const_iterator end() const
This class provides a simple interface to execute the same task multiple times in parallel threads,...
void Foreach(F func, unsigned nTimes, unsigned nChunks=0)
Execute a function without arguments several times in parallel, dividing the execution in nChunks.
A simple, robust and fast interface to read values from ROOT columnar datasets such as TTree,...
ROOT::RLogChannel & RDFLogChannel()
RLogChannel & GetChannelOrManager()
RResultMap< T > VariationsFor(RResultPtr< T > resPtr)
Produce all required systematic variations for the given result.
void AddProgressBar(ROOT::RDF::RNode df)
Add ProgressBar to a ROOT::RDF::RNode.
std::function< void(unsigned int, const ROOT::RDF::RSampleInfo &)> SampleCallback_t
The type of a data-block callback, registered with an RDataFrame computation graph via e....
unsigned int RunGraphs(std::vector< RResultHandle > handles)
Trigger the event loop of multiple RDataFrames concurrently.
std::ostream & operator<<(std::ostream &os, const RDFDescription &description)
RNode AsRNode(NodeType node)
Cast a RDataFrame node to the common type ROOT::RDF::RNode.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
@ kDebug
Debug information; only useful for developers; can have added verbosity up to 255-kDebug.