39 const std::vector<ReadSpeedRegex> &
regexes)
41 const auto f = std::unique_ptr<TFile>(
TFile::Open(fileName.c_str(),
"READ_WITHOUT_GLOBALREGISTRATION"));
42 if (
f ==
nullptr ||
f->IsZombie())
43 throw std::runtime_error(
"Could not open file '" + fileName +
'\'');
46 throw std::runtime_error(
"Could not retrieve tree '" +
treeName +
"' from file '" + fileName +
'\'');
59 bool match = std::regex_match(
bName, regex.regex);
74 std::cerr <<
"Provided branch regexes didn't match any branches in tree '" +
treeName +
"' from file '" +
79 std::string
errString =
"The following regexes didn't match any branches in tree '" +
treeName +
"' from file '" +
80 fileName +
"', this is probably unintended:\n";
81 for (
const auto ®ex :
regexes) {
97 std::vector<ReadSpeedRegex>
regexes;
99 std::transform(
d.fBranchNames.begin(),
d.fBranchNames.end(), std::back_inserter(
regexes), [](std::string
text) {
100 return ReadSpeedRegex{text, std::regex(text)};
103 for (
const auto &fName :
d.fFileNames) {
112 if (
d.fTreeNames.size() > 1)
136 throw std::runtime_error(
"Could not retrieve tree '" +
treeName +
"' from file '" +
f->GetName() +
'\'');
138 t->SetBranchStatus(
"*", 0);
142 auto *
b = t->GetBranch(
bName.c_str());
144 throw std::runtime_error(
"Could not retrieve branch '" +
bName +
"' from tree '" + t->GetName() +
145 "' in file '" + t->GetCurrentFile()->GetName() +
'\'');
151 const auto nEntries = t->GetEntries();
152 if (
range.fStart == -1ll)
155 throw std::runtime_error(
"Range end (" + std::to_string(
range.fEnd) +
") is beyond the end of tree '" +
156 t->GetName() +
"' in file '" + t->GetCurrentFile()->GetName() +
"' with " +
157 std::to_string(
nEntries) +
" entries.");
179 for (
const auto &fileName :
d.fFileNames) {
180 auto f = std::unique_ptr<TFile>(
TFile::Open(fileName.c_str(),
"READ_WITHOUT_GLOBALREGISTRATION"));
181 if (
f ==
nullptr ||
f->IsZombie())
182 throw std::runtime_error(
"Could not open file '" + fileName +
'\'');
190 if (
d.fTreeNames.size() > 1)
204 const auto nFiles =
d.fFileNames.size();
205 std::vector<std::vector<EntryRange>> ranges(
nFiles);
207 const auto &fileName =
d.fFileNames[
fileIdx];
208 std::unique_ptr<TFile>
f(
TFile::Open(fileName.c_str(),
"READ_WITHOUT_GLOBALREGISTRATION"));
209 if (
f ==
nullptr ||
f->IsZombie())
210 throw std::runtime_error(
"There was a problem opening file '" + fileName +
'\'');
211 const auto &
treeName =
d.fTreeNames.size() > 1 ?
d.fTreeNames[
fileIdx] :
d.fTreeNames[0];
214 throw std::runtime_error(
"There was a problem retrieving TTree '" +
treeName +
"' from file '" + fileName +
217 const auto nEntries = t->GetEntries();
218 auto it = t->GetClusterIterator(0);
221 while ((start = it.Next()) <
nEntries)
231std::vector<std::vector<EntryRange>>
276 std::cerr <<
"Running with " <<
actualThreads <<
" threads even though " <<
nThreads <<
" were requested.\n";
288 std::cout <<
"Total number of tasks: " <<
nranges <<
'\n';
296 auto processFile = [&](
int fileIdx) {
297 const auto &fileName =
d.fFileNames[
fileIdx];
298 const auto &
treeName =
d.fTreeNames.size() > 1 ?
d.fTreeNames[
fileIdx] :
d.fTreeNames[0];
308 file.reset(
TFile::Open(fileName.c_str(),
"READ_WITHOUT_GLOBALREGISTRATION"));
312 if (file ==
nullptr || file->IsZombie())
313 throw std::runtime_error(
"Could not open file '" + fileName +
'\'');
330 return {
sw.RealTime(),
346 if (
d.fTreeNames.empty()) {
347 std::cerr <<
"Please provide at least one tree name\n";
350 if (
d.fFileNames.empty()) {
351 std::cerr <<
"Please provide at least one file name\n";
354 if (
d.fBranchNames.empty()) {
355 std::cerr <<
"Please provide at least one branch name\n";
358 if (
d.fTreeNames.size() != 1 &&
d.fTreeNames.size() !=
d.fFileNames.size()) {
359 std::cerr <<
"Please provide either one tree name or as many as the file names\n";
368 <<
" 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 list 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)