22#include "RConfigure.h"
37#if (!defined(_WIN32)) && (!defined(_WIN64))
41#if defined(_WIN32) || defined(_WIN64)
42#define WIN32_LEAN_AND_MEAN
55#if defined(_WIN32) || defined(_WIN64)
77 Warning(
"RunGraphs",
"Got an empty list of handles, now quitting.");
82 const unsigned int nToRun =
85 Warning(
"RunGraphs",
"Got %zu handles from which %zu link to results which are already ready.",
handles.size(),
94 std::vector<RResultHandle>
uniqueLoops(s.begin(), s.end());
113 <<
"Just-in-time compilation phase for RunGraphs (" <<
uniqueLoops.size()
114 <<
" unique computation graphs) completed"
115 << (
sw.RealTime() > 1
e-3 ?
" in " + std::to_string(
sw.RealTime()) +
" seconds." :
" in less than 1ms.");
120 if (
h.fLoopManager) {
122 h.fLoopManager->Run(
false);
138 <<
"Finished RunGraphs run (" <<
uniqueLoops.size() <<
" unique computation graphs, " <<
sw.CpuTime() <<
"s CPU, "
139 <<
sw.RealTime() <<
"s elapsed).";
146 throw std::logic_error(
"Varying a Snapshot result is not implemented yet.");
152namespace Experimental {
190 using namespace std::chrono;
209struct RestoreStreamState {
210 RestoreStreamState(std::ostream &stream) :
fStream(stream),
fFlags(stream.flags()),
fFillChar(stream.fill()) {}
225 RestoreStreamState
restore(stream);
226 auto h = std::chrono::duration_cast<std::chrono::hours>(
elapsedSeconds);
227 auto m = std::chrono::duration_cast<std::chrono::minutes>(
elapsedSeconds -
h);
231 stream <<
h.count() <<
':' << std::setw(2) << std::right << std::setfill(
'0');
232 stream <<
m.count() <<
':' << std::setw(2) << std::right << std::setfill(
'0') << s;
233 return stream << (
h.count() > 0 ?
'h' :
'm');
242 RestoreStreamState
restore(stream);
249 stream <<
"\033[35m";
258 stream <<
"\033[32m";
270 stream << std::scientific << std::setprecision(2) <<
evtpersec <<
" evt/s";
275 stream <<
"\033[35m";
279 <<
" remaining time (per file being processed)";
289 RestoreStreamState
restore(stream);
294 stream <<
"\033[35m";
303 stream <<
"\033[32m";
307 stream <<
" / " << std::scientific << std::setprecision(2) <<
totalEvents;
323 RestoreStreamState
restore(stream);
328 std::string
bars(std::max(
nBar, 1u),
'=');
332 stream <<
"\033[33m";
333 stream <<
'|' << std::setfill(
' ') << std::setw(
fBarWidth) << std::left <<
bars <<
"| ";
359 std::mutex fPrintMutex;
360 if (!fPrintMutex.try_lock())
362 std::lock_guard<std::mutex>
lockGuard(fPrintMutex, std::adopt_lock);
369 std::cout <<
'\r' << std::string(
get_tty_size(),
' ') <<
'\r';
381 this->fHelper->registerNewSample(
slot,
id);
382 return this->fHelper->ComputeNEventsSoFar();
390 auto progress = std::make_shared<ProgressHelper>(1000,
total_files);
393 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()
unsigned int & NThreadPerTH3()
Obtain or set the number of threads that will share a clone of a thread-safe 3D histogram.
RLogChannel & GetChannelOrManager()
void ThreadsPerTH3(unsigned int nThread=1)
Set the number of threads sharing one TH3 in RDataFrame.
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)
Run the event loops 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.
Namespace for new ROOT classes and functions.
Bool_t IsImplicitMTEnabled()
Returns true if the implicit multi-threading in ROOT is enabled.
UInt_t GetThreadPoolSize()
Returns the size of ROOT's thread pool.
@ kDebug
Debug information; only useful for developers; can have added verbosity up to 255-kDebug.