CMS 3D CMS Logo

FWTTreeCache.h
Go to the documentation of this file.
1 #ifndef Fireworks_Core_FWTTreeCache_h
2 #define Fireworks_Core_FWTTreeCache_h
3 
4 #include "TTreeCache.h"
5 
6 #include <set>
7 #include <string>
8 
9 class FWTTreeCache : public TTreeCache
10 {
11  std::set<std::string> m_branch_set;
12  bool m_silent_low_level = false;
13 
14  static int s_default_size;
15  static bool s_logging;
16  static bool s_prefetching;
17 
18 protected:
19  bool is_branch_in_cache(const char* name) { return (m_branch_set.find(name) != m_branch_set.end()); }
20 
21  bool start_learning() { if (fIsLearning) return true; fIsLearning = true; return false; }
22  void stop_learning() { fIsLearning = false; }
23 
24  struct LearnGuard
25  {
29 
30  LearnGuard(FWTTreeCache *tc) : f_tc(tc)
31  {
32  f_was_learning = f_tc->start_learning();
33  f_was_silent_ll = f_tc->m_silent_low_level;
34  f_tc->m_silent_low_level = true;
35  }
37  {
38  if ( ! f_was_learning) f_tc->stop_learning();
40  }
41  };
42 
43 public:
44  FWTTreeCache();
45  FWTTreeCache(TTree *tree, Int_t buffersize=0);
46  ~FWTTreeCache() override;
47 
48  static void LoggingOn();
49  static void LoggingOff();
50  static bool IsLogging();
51  static void PrefetchingOn();
52  static void PrefetchingOff();
53  static bool IsPrefetching();
54  static void SetDefaultCacheSize(int def_size);
55  static int GetDefaultCacheSize();
56 
57  Int_t AddBranchTopLevel (const char* bname);
58  Int_t DropBranchTopLevel(const char* bname);
59 
60  void BranchAccessCallIn(const TBranch *b);
61 
62  // virtuals from TTreeCache, just wrappers for info printouts
63  Int_t AddBranch(TBranch *b, Bool_t subbranches = kFALSE) override;
64  Int_t AddBranch(const char *branch, Bool_t subbranches = kFALSE) override;
65  Int_t DropBranch(TBranch *b, Bool_t subbranches = kFALSE) override;
66  Int_t DropBranch(const char *branch, Bool_t subbranches = kFALSE) override;
67 };
68 
69 #endif
static void PrefetchingOn()
Definition: FWTTreeCache.cc:30
static void LoggingOff()
Definition: FWTTreeCache.cc:27
~FWTTreeCache() override
Definition: FWTTreeCache.cc:17
static bool s_logging
Definition: FWTTreeCache.h:15
Int_t AddBranchTopLevel(const char *bname)
Definition: FWTTreeCache.cc:39
static void PrefetchingOff()
Definition: FWTTreeCache.cc:31
static bool IsLogging()
Definition: FWTTreeCache.cc:28
static bool IsPrefetching()
Definition: FWTTreeCache.cc:32
static int s_default_size
Definition: FWTTreeCache.h:14
LearnGuard(FWTTreeCache *tc)
Definition: FWTTreeCache.h:30
static int GetDefaultCacheSize()
Definition: FWTTreeCache.cc:35
Int_t AddBranch(TBranch *b, Bool_t subbranches=kFALSE) override
Int_t DropBranch(TBranch *b, Bool_t subbranches=kFALSE) override
void stop_learning()
Definition: FWTTreeCache.h:22
void BranchAccessCallIn(const TBranch *b)
Definition: FWTTreeCache.cc:93
static bool s_prefetching
Definition: FWTTreeCache.h:16
bool m_silent_low_level
Definition: FWTTreeCache.h:12
std::set< std::string > m_branch_set
Definition: FWTTreeCache.h:11
double b
Definition: hdecay.h:120
Definition: tree.py:1
Int_t DropBranchTopLevel(const char *bname)
Definition: FWTTreeCache.cc:68
static void LoggingOn()
Definition: FWTTreeCache.cc:26
bool start_learning()
Definition: FWTTreeCache.h:21
static void SetDefaultCacheSize(int def_size)
Definition: FWTTreeCache.cc:34
bool is_branch_in_cache(const char *name)
Definition: FWTTreeCache.h:19