Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
InternalTreeUtils.cxx
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers. *
3 * All rights reserved. *
4 * *
5 * For the licensing terms see $ROOTSYS/LICENSE. *
6 * For the list of contributors see $ROOTSYS/README/CREDITS. *
7 *************************************************************************/
8
10#include "ROOT/RRangeCast.hxx" // RRangeStaticCast
11#include "TBranch.h" // Usage of TBranch in ClearMustCleanupBits
12#include "TChain.h"
13#include "TCollection.h" // TRangeStaticCast
14#include "TFile.h"
15#include "TFriendElement.h"
16#include "TObjString.h"
17#include "TRegexp.h"
18#include "TString.h"
19#include "TSystem.h"
20#include "TTree.h"
21#include "TVirtualIndex.h"
22
23#include <cstdint> // std::uint64_t
24#include <limits>
25#include <utility> // std::pair
26#include <vector>
27#include <stdexcept> // std::runtime_error
28#include <string>
29
30// Recursively get the top level branches from the specified tree and all of its attached friends.
31static void GetTopLevelBranchNamesImpl(TTree &t, std::unordered_set<std::string> &bNamesReg, std::vector<std::string> &bNames,
32 std::unordered_set<TTree *> &analysedTrees, const std::string friendName = "")
33{
34 if (!analysedTrees.insert(&t).second) {
35 return;
36 }
37
38 auto branches = t.GetListOfBranches();
39 if (branches) {
40 for (auto branchObj : *branches) {
41 const auto name = branchObj->GetName();
42 if (bNamesReg.insert(name).second) {
43 bNames.emplace_back(name);
44 } else if (!friendName.empty()) {
45 // If this is a friend and the branch name has already been inserted, it might be because the friend
46 // has a branch with the same name as a branch in the main tree. Let's add it as <friendname>.<branchname>.
47 const auto longName = friendName + "." + name;
48 if (bNamesReg.insert(longName).second)
49 bNames.emplace_back(longName);
50 }
51 }
52 }
53
54 auto friendTrees = t.GetListOfFriends();
55
56 if (!friendTrees)
57 return;
58
59 for (auto friendTreeObj : *friendTrees) {
60 auto friendElement = static_cast<TFriendElement *>(friendTreeObj);
61 auto friendTree = friendElement->GetTree();
62 const std::string frName(friendElement->GetName()); // this gets us the TTree name or the friend alias if any
63 GetTopLevelBranchNamesImpl(*friendTree, bNamesReg, bNames, analysedTrees, frName);
64 }
65}
66
67namespace ROOT {
68namespace Internal {
69namespace TreeUtils {
70
71///////////////////////////////////////////////////////////////////////////////
72/// Get all the top-level branches names, including the ones of the friend trees
73std::vector<std::string> GetTopLevelBranchNames(TTree &t)
74{
75 std::unordered_set<std::string> bNamesSet;
76 std::vector<std::string> bNames;
77 std::unordered_set<TTree *> analysedTrees;
78 GetTopLevelBranchNamesImpl(t, bNamesSet, bNames, analysedTrees);
79 return bNames;
80}
81
82////////////////////////////////////////////////////////////////////////////////
83/// \fn std::vector<std::string> GetFileNamesFromTree(const TTree &tree)
84/// \ingroup tree
85/// \brief Get and store the file names associated with the input tree.
86/// \param[in] tree The tree from which friends information will be gathered.
87/// \throws std::runtime_error If no files could be associated with the input tree.
88std::vector<std::string> GetFileNamesFromTree(const TTree &tree)
89{
90 std::vector<std::string> filenames;
91
92 // If the input tree is a TChain, traverse its list of associated files.
93 if (auto chain = dynamic_cast<const TChain *>(&tree)) {
94 const auto *chainFiles = chain->GetListOfFiles();
95 if (!chainFiles) {
96 throw std::runtime_error("Could not retrieve a list of files from the input TChain.");
97 }
98 // Store this in a variable so it can be later used in `filenames.reserve`
99 // if it passes the check.
100 const auto nfiles = chainFiles->GetEntries();
101 if (nfiles == 0) {
102 throw std::runtime_error("The list of files associated with the input TChain is empty.");
103 }
104 filenames.reserve(nfiles);
105 for (const auto *f : *chainFiles)
106 filenames.emplace_back(f->GetTitle());
107 } else {
108 const TFile *f = tree.GetCurrentFile();
109 if (!f) {
110 throw std::runtime_error("The input TTree is not linked to any file, "
111 "in-memory-only trees are not supported.");
112 }
113
114 filenames.emplace_back(f->GetName());
115 }
116
117 return filenames;
118}
119
120////////////////////////////////////////////////////////////////////////////////
121/// \fn RFriendInfo GetFriendInfo(const TTree &tree)
122/// \ingroup tree
123/// \brief Get and store the names, aliases and file names of the direct friends of the tree.
124/// \param[in] tree The tree from which friends information will be gathered.
125/// \param[in] retrieveEntries Whether to also retrieve the number of entries in
126/// each tree of each friend: one if the friend is a TTree, more if
127/// the friend is a TChain. In the latter case, this function
128/// triggers the opening of all files in the chain.
129/// \throws std::runtime_error If the input tree has a list of friends, but any
130/// of them could not be associated with any file.
131///
132/// Calls TTree::GetListOfFriends and parses its result for the names, aliases
133/// and file names, with different methodologies depending on whether the
134/// parameter is a TTree or a TChain.
135///
136/// \note This function only retrieves information about <b>direct friends</b>
137/// of the input tree. It will not recurse through friends of friends and
138/// does not take into account circular references in the list of friends
139/// of the input tree.
140///
141/// \returns An RFriendInfo struct, containing the information parsed from the
142/// list of friends. The struct will contain four vectors, which elements at
143/// position `i` represent the `i`-th friend of the input tree. If this friend
144/// is a TTree, the `i`-th element of each of the three vectors will contain
145/// respectively:
146///
147/// - A pair with the name and alias of the tree (the alias might not be
148/// present, in which case it will be just an empty string).
149/// - A vector with a single string representing the path to current file where
150/// the tree is stored.
151/// - An empty vector.
152/// - A vector with a single element, the number of entries in the tree.
153///
154/// If the `i`-th friend is a TChain instead, the `i`-th element of each of the
155/// three vectors will contain respectively:
156/// - A pair with the name and alias of the chain (if present, both might be
157/// empty strings).
158/// - A vector with all the paths to the files contained in the chain.
159/// - A vector with all the names of the trees making up the chain,
160/// associated with the file names of the previous vector.
161/// - A vector with the number of entries of each tree in the previous vector or
162/// an empty vector, depending on whether \p retrieveEntries is true.
164{
165 // Typically, the correct way to call GetListOfFriends would be `tree.GetTree()->GetListOfFriends()`
166 // (see e.g. the discussion at https://github.com/root-project/root/issues/6741).
167 // However, in this case, in case we are dealing with a TChain we really only care about the TChain's
168 // list of friends (which will need to be rebuilt in each processing task) while friends of the TChain's
169 // internal TTree, if any, will be automatically loaded in each task just like they would be automatically
170 // loaded here if we used tree.GetTree()->GetListOfFriends().
171 const auto *friends = tree.GetListOfFriends();
172 if (!friends || friends->GetEntries() == 0)
174
175 std::vector<std::pair<std::string, std::string>> friendNames;
176 std::vector<std::vector<std::string>> friendFileNames;
177 std::vector<std::vector<std::string>> friendChainSubNames;
178 std::vector<std::vector<std::int64_t>> nEntriesPerTreePerFriend;
179 std::vector<std::unique_ptr<TVirtualIndex>> treeIndexes;
180
181 // Reserve space for all friends
182 auto nFriends = friends->GetEntries();
183 friendNames.reserve(nFriends);
184 friendFileNames.reserve(nFriends);
185 friendChainSubNames.reserve(nFriends);
186 nEntriesPerTreePerFriend.reserve(nFriends);
187
188 for (auto fr : *friends) {
189 // Can't pass fr as const TObject* because TFriendElement::GetTree is not const.
190 // Also, we can't retrieve frTree as const TTree* because of TTree::GetFriendAlias(TTree *) a few lines later
191 auto frTree = static_cast<TFriendElement *>(fr)->GetTree();
192
193 // The vector of (name,alias) pairs of the current friend
194 friendFileNames.emplace_back();
195 auto &fileNames = friendFileNames.back();
196
197 // The vector of names of sub trees of the current friend, if it is a TChain.
198 // Otherwise, just an empty vector.
199 friendChainSubNames.emplace_back();
200 auto &chainSubNames = friendChainSubNames.back();
201
202 // The vector of entries in each tree of the current friend.
203 nEntriesPerTreePerFriend.emplace_back();
204 auto &nEntriesInThisFriend = nEntriesPerTreePerFriend.back();
205
206 // Check if friend tree/chain has an alias
207 const auto *alias_c = tree.GetFriendAlias(frTree);
208 const std::string alias = alias_c != nullptr ? alias_c : "";
209
210 auto *treeIndex = frTree->GetTreeIndex();
211 treeIndexes.emplace_back(static_cast<TVirtualIndex *>(treeIndex ? treeIndex->Clone() : nullptr));
212
213 // If the current tree is a TChain
214 if (auto frChain = dynamic_cast<const TChain *>(frTree)) {
215 // Note that each TChainElement returned by TChain::GetListOfFiles has a name
216 // equal to the tree name of this TChain and a title equal to the filename.
217 // Accessing the information like this ensures that we get the correct
218 // filenames and treenames if the treename is given as part of the filename
219 // via chain.AddFile(file.root/myTree) and as well if the tree name is given
220 // in the constructor via TChain(myTree) and a file is added later by chain.AddFile(file.root).
221 // Caveat: The chain may be made of sub-trees with different names. All
222 // tree names need to be retrieved separately, see below.
223
224 // Get filelist of the current chain
225 const auto *chainFiles = frChain->GetListOfFiles();
226 if (!chainFiles || chainFiles->GetEntries() == 0) {
227 throw std::runtime_error("A TChain in the list of friends does not contain any file. "
228 "Friends with no associated files are not supported.");
229 }
230
231 // Reserve space for this friend
232 auto nFiles = chainFiles->GetEntries();
233 fileNames.reserve(nFiles);
234 chainSubNames.reserve(nFiles);
235 nEntriesInThisFriend.reserve(nFiles);
236
237 // Retrieve the name of the chain and add a (name, alias) pair
238 friendNames.emplace_back(std::make_pair(frChain->GetName(), alias));
239 // Each file in the chain can contain a TTree with a different name wrt
240 // the main TChain. Retrieve the name of the file through `GetTitle`
241 // and the name of the tree through `GetName`
242 for (const auto *f : *chainFiles) {
243
244 auto thisTreeName = f->GetName();
245 auto thisFileName = f->GetTitle();
246
247 chainSubNames.emplace_back(thisTreeName);
248 fileNames.emplace_back(thisFileName);
249
250 if (retrieveEntries) {
251 std::unique_ptr<TFile> thisFile{TFile::Open(thisFileName, "READ_WITHOUT_GLOBALREGISTRATION")};
252 if (!thisFile || thisFile->IsZombie())
253 throw std::runtime_error(std::string("GetFriendInfo: Could not open file \"") + thisFileName + "\"");
254 TTree *thisTree = thisFile->Get<TTree>(thisTreeName);
255 if (!thisTree)
256 throw std::runtime_error(std::string("GetFriendInfo: Could not retrieve TTree \"") + thisTreeName +
257 "\" from file \"" + thisFileName + "\"");
258 nEntriesInThisFriend.emplace_back(thisTree->GetEntries());
259 } else {
260 // Avoid odr-using TTree::kMaxEntries which would require a
261 // definition in C++14. In C++17, all constexpr static data
262 // members are implicitly inline.
263 static constexpr auto maxEntries = TTree::kMaxEntries;
264 nEntriesInThisFriend.emplace_back(maxEntries);
265 }
266 }
267 } else {
268 // Get name of the tree
269 const auto realName = GetTreeFullPaths(*frTree)[0];
270 friendNames.emplace_back(std::make_pair(realName, alias));
271
272 // Get filename
273 const auto *f = frTree->GetCurrentFile();
274 if (!f)
275 throw std::runtime_error("A TTree in the list of friends is not linked to any file. "
276 "Friends with no associated files are not supported.");
277 fileNames.emplace_back(f->GetName());
278 // We already have a pointer to the file and the tree, we can get the
279 // entries without triggering a re-open
280 nEntriesInThisFriend.emplace_back(frTree->GetEntries());
281 }
282 }
283
284 return ROOT::TreeUtils::RFriendInfo(std::move(friendNames), std::move(friendFileNames),
285 std::move(friendChainSubNames), std::move(nEntriesPerTreePerFriend),
286 std::move(treeIndexes));
287}
288
289////////////////////////////////////////////////////////////////////////////////
290/// \fn std::vector<std::string> GetTreeFullPaths(const TTree &tree)
291/// \ingroup tree
292/// \brief Retrieve the full path(s) to a TTree or the trees in a TChain.
293/// \param[in] tree The tree or chain from which the paths will be retrieved.
294/// \throws std::runtime_error If the input tree is a TChain but no files could
295/// be found associated with it.
296/// \return If the input argument is a TChain, returns a vector of strings with
297/// the name of the tree of each file in the chain. If the input
298/// argument is a TTree, returns a vector with a single element that is
299/// the full path of the tree in the file (e.g. the name of the tree
300/// itself or the path with the directories inside the file). Finally,
301/// the function returns a vector with just the name of the tree if it
302/// couldn't do any better.
303std::vector<std::string> GetTreeFullPaths(const TTree &tree)
304{
305 // Case 1: this is a TChain. For each file it contains, GetName returns the name of the tree in that file
306 if (auto chain = dynamic_cast<const TChain *>(&tree)) {
307 const auto *chainFiles = chain->GetListOfFiles();
308 if (!chainFiles || chainFiles->GetEntries() == 0) {
309 throw std::runtime_error("The input TChain does not contain any file.");
310 }
311 std::vector<std::string> treeNames;
312 for (const auto *f : *chainFiles)
313 treeNames.emplace_back(f->GetName());
314
315 return treeNames;
316 }
317
318 // Case 2: this is a TTree: we get the full path of it
319 if (const auto *treeDir = tree.GetDirectory()) {
320 // We have 2 subcases (ROOT-9948):
321 // - 1. treeDir is a TFile: return the name of the tree.
322 // - 2. treeDir is a directory: reconstruct the path to the tree in the directory.
323 // Use dynamic_cast to check whether the directory is a TFile
324 if (dynamic_cast<const TFile *>(treeDir)) {
325 return {tree.GetName()};
326 }
327 std::string fullPath = treeDir->GetPath(); // e.g. "file.root:/dir"
328 fullPath = fullPath.substr(fullPath.rfind(":/") + 1); // e.g. "/dir"
329 fullPath += "/";
330 fullPath += tree.GetName(); // e.g. "/dir/tree"
331 return {fullPath};
332 }
333
334 // We do our best and return the name of the tree
335 return {tree.GetName()};
336}
337
338/// Reset the kMustCleanup bit of a TObjArray of TBranch objects (e.g. returned by TTree::GetListOfBranches).
339///
340/// In some rare cases, all branches in a TTree can have their kMustCleanup bit set, which causes a large amount
341/// of contention at teardown due to concurrent calls to RecursiveRemove (which needs to take the global lock).
342/// This helper function checks the first branch of the array and if it has the kMustCleanup bit set, it resets
343/// it for all branches in the array, recursively going through sub-branches and leaves.
345{
346 if (branches.GetEntries() == 0 || branches.At(0)->TestBit(kMustCleanup) == false)
347 return; // we assume either no branches have the bit set, or all do. we never encountered an hybrid case
348
349 for (auto *branch : ROOT::Detail::TRangeStaticCast<TBranch>(branches)) {
350 branch->ResetBit(kMustCleanup);
351 TObjArray *subBranches = branch->GetListOfBranches();
352 ClearMustCleanupBits(*subBranches);
353 TObjArray *leaves = branch->GetListOfLeaves();
354 if (leaves->GetEntries() > 0 && leaves->At(0)->TestBit(kMustCleanup) == true) {
355 for (TObject *leaf : *leaves)
356 leaf->ResetBit(kMustCleanup);
357 }
358 }
359}
360
361/// \brief Create a TChain object with options that avoid common causes of thread contention.
362///
363/// In particular, set its kWithoutGlobalRegistration mode and reset its kMustCleanup bit.
364std::unique_ptr<TChain> MakeChainForMT(const std::string &name, const std::string &title)
365{
366 auto c = std::make_unique<TChain>(name.c_str(), title.c_str(), TChain::kWithoutGlobalRegistration);
367 c->ResetBit(TObject::kMustCleanup);
368 return c;
369}
370
371////////////////////////////////////////////////////////////////////////////////
372/// \brief Create friends from the main TTree.
373std::vector<std::unique_ptr<TChain>> MakeFriends(const ROOT::TreeUtils::RFriendInfo &finfo)
374{
375 std::vector<std::unique_ptr<TChain>> friends;
376 const auto nFriends = finfo.fFriendNames.size();
377 friends.reserve(nFriends);
378
379 for (std::size_t i = 0u; i < nFriends; ++i) {
380 const auto &thisFriendName = finfo.fFriendNames[i].first;
381 const auto &thisFriendFileNames = finfo.fFriendFileNames[i];
382 const auto &thisFriendChainSubNames = finfo.fFriendChainSubNames[i];
383 const auto &thisFriendEntries = finfo.fNEntriesPerTreePerFriend[i];
384
385 // Build a friend chain
386 auto frChain = ROOT::Internal::TreeUtils::MakeChainForMT(thisFriendName);
387 if (thisFriendChainSubNames.empty()) {
388 // The friend is a TTree. It's safe to add to the chain the filename directly.
389 frChain->Add(thisFriendFileNames[0].c_str(), thisFriendEntries[0]);
390 } else {
391 // Otherwise, the new friend chain needs to be built using the nomenclature
392 // "filename?#treename" as argument to `TChain::Add`
393 for (std::size_t j = 0u; j < thisFriendFileNames.size(); ++j) {
394 frChain->Add((thisFriendFileNames[j] + "?#" + thisFriendChainSubNames[j]).c_str(), thisFriendEntries[j]);
395 }
396 }
397
398 auto &treeIndex = finfo.fTreeIndexInfos[i];
399 if (treeIndex) {
400 auto *copyOfIndex = static_cast<TVirtualIndex *>(treeIndex->Clone());
401 copyOfIndex->SetTree(frChain.get());
402 frChain->SetTreeIndex(copyOfIndex);
403 }
404
405 friends.emplace_back(std::move(frChain));
406 }
407
408 return friends;
409}
410
411////////////////////////////////////////////////////////////////////////////////
412/// \brief Expands input glob into a collection of full paths to files.
413/// \param[in] glob The glob to expand.
414/// \throws std::runtime_error If the directory part of the glob refers to a
415/// path that cannot be opened.
416/// \return A vector of strings, the fully expanded paths to the files referred
417/// to by the glob.
418///
419/// The two parts of the glob (directory, fileglob) are separated. The directory
420/// is first expanded via TSystem::ExpandPathName then opened via
421/// TSystem::OpenDirectory. If the directory can be opened, then the remaining
422/// fileglob is used as regex expression (via TRegexp) and the function stores
423/// those files in the directory that match the regex.
424std::vector<std::string> ExpandGlob(const std::string &glob)
425{
426 // TODO: Also implement this pattern in some other free function
427 // This is practically Python's os.path.split
428 std::string dirname;
429 std::string basename;
430
431 const auto slashpos = glob.rfind('/');
432
433 if (slashpos != std::string::npos) {
434 // Separate the glob into its two components
435 dirname = glob.substr(0, slashpos);
436 basename = glob.substr(slashpos + 1);
437 } else {
438 // There is no directory component in the glob, use the CWD
440 basename = glob;
441 }
442
443 // Attempt opening of directory contained in the glob
444 const char *epath = gSystem->ExpandPathName(dirname.c_str());
445 void *dir = gSystem->OpenDirectory(epath);
446 delete[] epath;
447
448 if (dir) {
449 // Create a TList to store the file names (not yet sorted)
450 TList l;
451 l.SetOwner(); // Make sure the TList will delete its objects
452 TRegexp re(basename.c_str(), true);
453 const char *file;
454 TString fname;
455 while ((file = gSystem->GetDirEntry(dir))) {
456 if (!strcmp(file, ".") || !strcmp(file, ".."))
457 continue;
458 fname = file;
459 if ((basename != file) && fname.Index(re) == kNPOS)
460 continue;
461 // Using '/' as separator here as it was done in TChain::Add
462 // In principle this should be using the appropriate platform separator
463 l.Add(new TObjString((dirname + '/' + file).c_str()));
464 }
466 // Sort the files in alphanumeric order
467 l.Sort();
468
469 // Convert TList<TObjString> to std::vector<std::string>
470 std::vector<std::string> ret;
471 ret.reserve(l.GetEntries());
472 for (const auto *tobjstr : ROOT::RangeStaticCast<const TObjString *>(l)) {
473 ret.push_back(tobjstr->GetName());
474 }
475 return ret;
476 } else {
477 throw std::runtime_error("ExpandGlob: could not open directory '" + dirname + "'.");
478 }
479}
480
481} // namespace TreeUtils
482} // namespace Internal
483} // namespace ROOT
static void GetTopLevelBranchNamesImpl(TTree &t, std::unordered_set< std::string > &bNamesReg, std::vector< std::string > &bNames, std::unordered_set< TTree * > &analysedTrees, const std::string friendName="")
#define f(i)
Definition RSha256.hxx:104
#define c(i)
Definition RSha256.hxx:101
constexpr Ssiz_t kNPOS
Definition RtypesCore.h:124
char name[80]
Definition TGX11.cxx:110
@ kMustCleanup
Definition TObject.h:368
R__EXTERN TSystem * gSystem
Definition TSystem.h:560
A chain is a collection of files containing TTree objects.
Definition TChain.h:33
@ kWithoutGlobalRegistration
Definition TChain.h:71
const char * GetName() const override
Return name of this collection.
A ROOT file is composed of a header, followed by consecutive data records (TKey instances) with a wel...
Definition TFile.h:53
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.
Definition TFile.cxx:4075
A TFriendElement TF describes a TTree object TF in a file.
virtual TTree * GetTree()
Return pointer to friend TTree.
A doubly linked list.
Definition TList.h:38
An array of TObjects.
Definition TObjArray.h:31
Int_t GetEntries() const override
Return the number of objects in array (i.e.
TObject * At(Int_t idx) const override
Definition TObjArray.h:164
Collectable string class.
Definition TObjString.h:28
Mother of all ROOT objects.
Definition TObject.h:41
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition TObject.h:199
void ResetBit(UInt_t f)
Definition TObject.h:198
@ kMustCleanup
if object destructor must call RecursiveRemove()
Definition TObject.h:64
Regular expression class.
Definition TRegexp.h:31
Basic string class.
Definition TString.h:139
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition TString.h:651
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1261
virtual void FreeDirectory(void *dirp)
Free a directory.
Definition TSystem.cxx:832
virtual void * OpenDirectory(const char *name)
Open a directory. Returns 0 if directory does not exist.
Definition TSystem.cxx:823
virtual const char * GetDirEntry(void *dirp)
Get a directory entry. Returns 0 if no more entries.
Definition TSystem.cxx:840
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1050
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:858
A TTree represents a columnar dataset.
Definition TTree.h:79
virtual Long64_t GetEntries() const
Definition TTree.h:463
virtual TObjArray * GetListOfBranches()
Definition TTree.h:488
virtual TList * GetListOfFriends() const
Definition TTree.h:490
static constexpr Long64_t kMaxEntries
Definition TTree.h:229
Abstract interface for Tree Index.
virtual void SetTree(TTree *T)=0
Different standalone functions to work with trees and tuples, not reqiuired to be a member of any cla...
std::vector< std::string > GetTreeFullPaths(const TTree &tree)
std::vector< std::string > GetTopLevelBranchNames(TTree &t)
Get all the top-level branches names, including the ones of the friend trees.
std::unique_ptr< TChain > MakeChainForMT(const std::string &name="", const std::string &title="")
Create a TChain object with options that avoid common causes of thread contention.
std::vector< std::unique_ptr< TChain > > MakeFriends(const ROOT::TreeUtils::RFriendInfo &finfo)
Create friends from the main TTree.
ROOT::TreeUtils::RFriendInfo GetFriendInfo(const TTree &tree, bool retrieveEntries=false)
std::vector< std::string > ExpandGlob(const std::string &glob)
Expands input glob into a collection of full paths to files.
void ClearMustCleanupBits(TObjArray &arr)
Reset the kMustCleanup bit of a TObjArray of TBranch objects (e.g.
std::vector< std::string > GetFileNamesFromTree(const TTree &tree)
This file contains a specialised ROOT message handler to test for diagnostic in unit tests.
Definition file.py:1
Definition tree.py:1
Information about friend trees of a certain TTree or TChain object.
std::vector< std::pair< std::string, std::string > > fFriendNames
Pairs of names and aliases of each friend tree/chain.
std::vector< std::vector< std::int64_t > > fNEntriesPerTreePerFriend
Number of entries contained in each tree of each friend.
std::vector< std::vector< std::string > > fFriendChainSubNames
Names of the subtrees of a friend TChain.
std::vector< std::unique_ptr< TVirtualIndex > > fTreeIndexInfos
Information on the friend's TTreeIndexes.
std::vector< std::vector< std::string > > fFriendFileNames
Names of the files where each friend is stored.
TLine l
Definition textangle.C:4