38 const std::vector<ReadSpeedRegex> &
regexes)
40 const auto f = std::unique_ptr<TFile>(
TFile::Open(fileName.c_str(),
"READ_WITHOUT_GLOBALREGISTRATION"));
41 if (
f ==
nullptr ||
f->IsZombie())
42 throw std::runtime_error(
"Could not open file '" + fileName +
'\'');
45 throw std::runtime_error(
"Could not retrieve tree '" +
treeName +
"' from file '" + fileName +
'\'');
58 bool match = std::regex_match(
bName, regex.regex);
73 std::cerr <<
"Provided branch regexes didn't match any branches in tree '" +
treeName +
"' from file '" +
78 std::string
errString =
"The following regexes didn't match any branches in tree '" +
treeName +
"' from file '" +
79 fileName +
"', this is probably unintended:\n";
80 for (
const auto ®ex :
regexes) {
96 std::vector<ReadSpeedRegex>
regexes;
98 std::transform(
d.fBranchNames.begin(),
d.fBranchNames.end(), std::back_inserter(
regexes), [](std::string
text) {
99 return ReadSpeedRegex{text, std::regex(text)};
102 for (
const auto &fName :
d.fFileNames) {
111 if (
d.fTreeNames.size() > 1)
135 throw std::runtime_error(
"Could not retrieve tree '" +
treeName +
"' from file '" +
f->GetName() +
'\'');
137 t->SetBranchStatus(
"*", 0);
141 auto *
b = t->GetBranch(
bName.c_str());
143 throw std::runtime_error(
"Could not retrieve branch '" +
bName +
"' from tree '" + t->GetName() +
144 "' in file '" + t->GetCurrentFile()->GetName() +
'\'');
150 const auto nEntries = t->GetEntries();
151 if (
range.fStart == -1ll)
154 throw std::runtime_error(
"Range end (" + std::to_string(
range.fEnd) +
") is beyond the end of tree '" +
155 t->GetName() +
"' in file '" + t->GetCurrentFile()->GetName() +
"' with " +
156 std::to_string(
nEntries) +
" entries.");
178 for (
const auto &fileName :
d.fFileNames) {
179 auto f = std::unique_ptr<TFile>(
TFile::Open(fileName.c_str(),
"READ_WITHOUT_GLOBALREGISTRATION"));
180 if (
f ==
nullptr ||
f->IsZombie())
181 throw std::runtime_error(
"Could not open file '" + fileName +
'\'');
189 if (
d.fTreeNames.size() > 1)
203 const auto nFiles =
d.fFileNames.size();
204 std::vector<std::vector<EntryRange>> ranges(
nFiles);
206 const auto &fileName =
d.fFileNames[
fileIdx];
207 std::unique_ptr<TFile>
f(
TFile::Open(fileName.c_str(),
"READ_WITHOUT_GLOBALREGISTRATION"));
208 if (
f ==
nullptr ||
f->IsZombie())
209 throw std::runtime_error(
"There was a problem opening file '" + fileName +
'\'');
210 const auto &
treeName =
d.fTreeNames.size() > 1 ?
d.fTreeNames[
fileIdx] :
d.fTreeNames[0];
213 throw std::runtime_error(
"There was a problem retrieving TTree '" +
treeName +
"' from file '" + fileName +
216 const auto nEntries = t->GetEntries();
217 auto it = t->GetClusterIterator(0);
220 while ((start = it.Next()) <
nEntries)
230std::vector<std::vector<EntryRange>>
275 std::cerr <<
"Running with " <<
actualThreads <<
" threads even though " <<
nThreads <<
" were requested.\n";
287 std::cout <<
"Total number of tasks: " <<
nranges <<
'\n';
295 auto processFile = [&](
int fileIdx) {
296 const auto &fileName =
d.fFileNames[
fileIdx];
297 const auto &
treeName =
d.fTreeNames.size() > 1 ?
d.fTreeNames[
fileIdx] :
d.fTreeNames[0];
307 file.reset(
TFile::Open(fileName.c_str(),
"READ_WITHOUT_GLOBALREGISTRATION"));
311 if (file ==
nullptr || file->IsZombie())
312 throw std::runtime_error(
"Could not open file '" + fileName +
'\'');
329 return {
sw.RealTime(),
345 if (
d.fTreeNames.empty()) {
346 std::cerr <<
"Please provide at least one tree name\n";
349 if (
d.fFileNames.empty()) {
350 std::cerr <<
"Please provide at least one file name\n";
353 if (
d.fBranchNames.empty()) {
354 std::cerr <<
"Please provide at least one branch name\n";
357 if (
d.fTreeNames.size() != 1 &&
d.fTreeNames.size() !=
d.fFileNames.size()) {
358 std::cerr <<
"Please provide either one tree name or as many as the file names\n";
367 <<
" threads were requested, but ROOT was built without implicit multi-threading (IMT) support.\n";
std::vector< std::vector< std::string > > GetPerFileBranchNames(const Data &d)
ByteData SumBytes(const std::vector< ByteData > &bytesData)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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 text
A thread-safe stack of N indexes (0 to size - 1).
const_iterator begin() const
const_iterator end() const
This class provides a simple interface to execute the same task multiple times in parallel threads,...
static unsigned int GetTasksPerWorkerHint()
Retrieve the current value for the desired number of tasks per worker.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
static TFile * Open(const char *name, Option_t *option="", const char *ftitle="", Int_t compress=ROOT::RCompressionSetting::EDefaults::kUseCompiledDefault, Int_t netopt=0)
Create / open a file.
A TTree represents a columnar dataset.
std::vector< std::string > GetTopLevelBranchNames(TTree &t)
Get all the top-level branches names, including the ones of the friend trees.
UInt_t GetThreadPoolSize()
Returns the size of ROOT's thread pool.
Result EvalThroughputST(const Data &d)
std::vector< std::string > GetMatchingBranchNames(const std::string &fileName, const std::string &treeName, const std::vector< ReadSpeedRegex > ®exes)
std::vector< std::vector< EntryRange > > GetClusters(const Data &d)
Result EvalThroughputMT(const Data &d, unsigned nThreads)
Result EvalThroughput(const Data &d, unsigned nThreads)
std::vector< std::vector< EntryRange > > MergeClusters(std::vector< std::vector< EntryRange > > &&clusters, unsigned int maxTasksPerFile)
ByteData ReadTree(TFile *file, const std::string &treeName, const std::vector< std::string > &branchNames, EntryRange range={-1, -1})
A RAII object to pop and push slot numbers from a RSlotStack object.
static uint64_t sum(uint64_t i)