Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:10:35

0001 /*************************************************************************
0002  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers.               *
0003  * All rights reserved.                                                  *
0004  *                                                                       *
0005  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0006  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0007  *************************************************************************/
0008 
0009 /**
0010  \file ROOT/InternalTreeUtils.hxx
0011  \ingroup tree
0012  \author Enric Tejedor Saavedra
0013  \author Enrico Guiraud
0014  \author Vincenzo Eduardo Padulano
0015  \date 2021-03
0016 */
0017 
0018 #ifndef ROOT_INTERNAL_TREEUTILS_H
0019 #define ROOT_INTERNAL_TREEUTILS_H
0020 
0021 #include "RtypesCore.h"
0022 #include "TTree.h"
0023 #include "TChain.h"
0024 #include "TNotifyLink.h"
0025 #include "TObjArray.h"
0026 #include "ROOT/RFriendInfo.hxx"
0027 
0028 #include <memory>
0029 #include <string>
0030 #include <utility> // std::pair
0031 #include <vector>
0032 
0033 namespace ROOT {
0034 namespace Internal {
0035 /**
0036 \namespace ROOT::Internal::TreeUtils
0037 \ingroup tree
0038 \brief Namespace hosting functions and classes to retrieve tree information for internal use.
0039 */
0040 namespace TreeUtils {
0041 
0042 std::vector<std::string> GetTopLevelBranchNames(TTree &t);
0043 std::vector<std::string> GetFileNamesFromTree(const TTree &tree);
0044 ROOT::TreeUtils::RFriendInfo GetFriendInfo(const TTree &tree, bool retrieveEntries = false);
0045 std::vector<std::string> GetTreeFullPaths(const TTree &tree);
0046 
0047 void ClearMustCleanupBits(TObjArray &arr);
0048 
0049 class RNoCleanupNotifierHelper {
0050    TChain *fChain = nullptr;
0051 
0052 public:
0053    bool Notify()
0054    {
0055       TTree *t = fChain->GetTree();
0056       TObjArray *branches = t->GetListOfBranches();
0057       ClearMustCleanupBits(*branches);
0058       return true;
0059    }
0060 
0061    void RegisterChain(TChain *c) { fChain = c; }
0062 };
0063 
0064 class RNoCleanupNotifier : public TNotifyLink<RNoCleanupNotifierHelper> {
0065    RNoCleanupNotifierHelper fNoCleanupNotifierHelper;
0066 
0067 public:
0068    RNoCleanupNotifier() : TNotifyLink<RNoCleanupNotifierHelper>(&fNoCleanupNotifierHelper) {}
0069 
0070    void RegisterChain(TChain &c)
0071    {
0072       fNoCleanupNotifierHelper.RegisterChain(&c);
0073       this->PrependLink(c);
0074    }
0075 
0076    ClassDefOverride(RNoCleanupNotifier, 0);
0077 };
0078 
0079 std::unique_ptr<TChain> MakeChainForMT(const std::string &name = "", const std::string &title = "");
0080 std::vector<std::unique_ptr<TChain>> MakeFriends(const ROOT::TreeUtils::RFriendInfo &finfo);
0081 
0082 std::vector<std::string> ExpandGlob(const std::string &glob);
0083 
0084 std::pair<std::vector<Long64_t>, Long64_t> GetClustersAndEntries(std::string_view treename, std::string_view path);
0085 
0086 std::pair<bool, std::string> TreeUsesIndexedFriends(const TTree &tree);
0087 
0088 } // namespace TreeUtils
0089 } // namespace Internal
0090 } // namespace ROOT
0091 
0092 #endif // ROOT_INTERNAL_TREEUTILS_H