22#include "RConfigure.h"
38#if defined(_WIN32) || defined(_WIN64)
39#define WIN32_LEAN_AND_MEAN
55#if defined(_WIN32) || defined(_WIN64)
73struct RestoreStreamState {
74 RestoreStreamState(std::ostream &stream) : fStream(stream) { fPreservedState.copyfmt(stream); }
77 std::ostream &fStream;
78 std::ios fPreservedState{
nullptr};
84 std::stringstream str;
85 auto h = std::chrono::duration_cast<std::chrono::hours>(
elapsedSeconds);
86 auto m = std::chrono::duration_cast<std::chrono::minutes>(
elapsedSeconds -
h);
90 str <<
h.count() <<
':' << std::setw(2) << std::right << std::setfill(
'0');
91 str <<
m.count() <<
':' << std::setw(2) << std::right << std::setfill(
'0') << s;
92 str << (
h.count() > 0 ?
'h' :
'm');
104 Warning(
"RunGraphs",
"Got an empty list of handles, now quitting.");
109 const unsigned int nToRun =
112 Warning(
"RunGraphs",
"Got %zu handles from which %zu link to results which are already ready.",
handles.size(),
121 std::vector<RResultHandle>
uniqueLoops(s.begin(), s.end());
140 <<
"Just-in-time compilation phase for RunGraphs (" <<
uniqueLoops.size()
141 <<
" unique computation graphs) completed"
142 << (
sw.RealTime() > 1
e-3 ?
" in " + std::to_string(
sw.RealTime()) +
" seconds." :
" in less than 1ms.");
147 if (
h.fLoopManager) {
149 h.fLoopManager->Run(
false);
165 <<
"Finished RunGraphs run (" <<
uniqueLoops.size() <<
" unique computation graphs, " <<
sw.CpuTime() <<
"s CPU, "
166 <<
sw.RealTime() <<
"s elapsed).";
225 return n > 0 ?
sum /
n : 0.;
242 using namespace std::chrono;
264 std::ostringstream buffer;
288 std::string
bars(std::max(
nBar, 1u),
'=');
292 buffer <<
"\033[33m";
293 buffer <<
'|' << std::setfill(
' ') << std::setw(
barWidth) << std::left <<
bars <<
"| ";
301 buffer <<
"\033[35m";
309 buffer <<
"\033[32m";
313 buffer <<
" / " << std::scientific << std::setprecision(2);
325 buffer << std::scientific << std::setprecision(2) <<
evtpersec <<
" evt/s";
334 buffer <<
"\033[35m";
352 RestoreStreamState
restore(stream);
353 stream << std::left << std::setw(
fNColumns - 1) << buffer.str();
358 auto &stream = std::cout;
359 RestoreStreamState
restore(stream);
361 std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now() -
fBeginTime);
369 stream <<
'\r' << std::string(
fNColumns,
' ') <<
'\r';
372 stream <<
"\033[35m";
377 stream <<
"processed files: " <<
fTotalFiles <<
" ";
381 stream <<
"\033[32m";
399 using namespace std::chrono;
425 std::cout << std::flush;
427 std::cout << std::endl;
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 void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
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()
unsigned int const fTotalFiles
std::size_t ComputeTotalEvents() const
Compute total events in all open files.
void PrintStatsFinal() const
ProgressHelper(std::size_t increment, unsigned int totalFiles, unsigned int printInterval=0, bool useColors=true)
Create a progress helper.
std::pair< std::size_t, std::chrono::seconds > RecordEvtCountAndTime()
Record current event counts and time stamp, populate evts/s statistics array.
void RegisterNewSample(unsigned int, const ROOT::RDF::RSampleInfo &id)
Register a new sample for completion statistics.
unsigned int const fNColumns
unsigned int fEventsPerSecondStatisticsCounter
std::chrono::time_point< std::chrono::system_clock > const fBeginTime
void Update()
Record number of events processed and update progress bar.
std::map< std::string, ULong64_t > fSampleNameToEventEntries
std::size_t fLastProcessedEvents
std::mutex fSampleNameToEventEntriesMutex
std::chrono::seconds const fPrintInterval
double EvtPerSec() const
Compute a running mean of events/s.
std::atomic< std::size_t > fProcessedEvents
std::array< double, 10 > fEventsPerSecondStatistics
std::chrono::time_point< std::chrono::system_clock > fLastPrintTime
std::size_t const fIncrement
bool const fUseShellColours
void PrintProgressAndStats(std::ostream &stream, std::size_t currentEventCount, std::chrono::seconds totalElapsedSeconds) const
Print event and time statistics.
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.
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.
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.
RNode AsRNode(NodeType node)
Cast a RDataFrame node to the common type ROOT::RDF::RNode.
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.
static uint64_t sum(uint64_t i)