Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:11:43

0001 #ifndef Fireworks_Core_FWTTreeCache_h
0002 #define Fireworks_Core_FWTTreeCache_h
0003 
0004 #include "TTreeCache.h"
0005 
0006 #include <set>
0007 #include <string>
0008 
0009 class FWTTreeCache : public TTreeCache {
0010   std::set<std::string> m_branch_set;
0011   bool m_silent_low_level = false;
0012 
0013   static int s_default_size;
0014   static bool s_logging;
0015   static bool s_prefetching;
0016 
0017 protected:
0018   bool is_branch_in_cache(const char *name) { return (m_branch_set.find(name) != m_branch_set.end()); }
0019 
0020   bool start_learning() {
0021     if (fIsLearning)
0022       return true;
0023     fIsLearning = true;
0024     return false;
0025   }
0026   void stop_learning() { fIsLearning = false; }
0027 
0028   struct LearnGuard {
0029     FWTTreeCache *f_tc;
0030     bool f_was_learning;
0031     bool f_was_silent_ll;
0032 
0033     LearnGuard(FWTTreeCache *tc) : f_tc(tc) {
0034       f_was_learning = f_tc->start_learning();
0035       f_was_silent_ll = f_tc->m_silent_low_level;
0036       f_tc->m_silent_low_level = true;
0037     }
0038     ~LearnGuard() {
0039       if (!f_was_learning)
0040         f_tc->stop_learning();
0041       f_tc->m_silent_low_level = f_was_silent_ll;
0042     }
0043   };
0044 
0045 public:
0046   FWTTreeCache();
0047   FWTTreeCache(TTree *tree, Int_t buffersize = 0);
0048   ~FWTTreeCache() override;
0049 
0050   static void LoggingOn();
0051   static void LoggingOff();
0052   static bool IsLogging();
0053   static void PrefetchingOn();
0054   static void PrefetchingOff();
0055   static bool IsPrefetching();
0056   static void SetDefaultCacheSize(int def_size);
0057   static int GetDefaultCacheSize();
0058 
0059   Int_t AddBranchTopLevel(const char *bname);
0060   Int_t DropBranchTopLevel(const char *bname);
0061 
0062   void BranchAccessCallIn(const TBranch *b);
0063 
0064   // virtuals from TTreeCache, just wrappers for info printouts
0065   Int_t AddBranch(TBranch *b, Bool_t subbranches = kFALSE) override;
0066   Int_t AddBranch(const char *branch, Bool_t subbranches = kFALSE) override;
0067   Int_t DropBranch(TBranch *b, Bool_t subbranches = kFALSE) override;
0068   Int_t DropBranch(const char *branch, Bool_t subbranches = kFALSE) override;
0069 };
0070 
0071 #endif