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 
17 protected:
18  bool is_branch_in_cache(const char* name) { return (m_branch_set.find(name) != m_branch_set.end()); }
19 
20  bool start_learning() { if (fIsLearning) return true; fIsLearning = true; return false; }
21  void stop_learning() { fIsLearning = false; }
22 
23  struct LearnGuard
24  {
28 
29  LearnGuard(FWTTreeCache *tc) : f_tc(tc)
30  {
31  f_was_learning = f_tc->start_learning();
32  f_was_silent_ll = f_tc->m_silent_low_level;
33  f_tc->m_silent_low_level = true;
34  }
36  {
37  if ( ! f_was_learning) f_tc->stop_learning();
39  }
40  };
41 
42 public:
43  FWTTreeCache();
44  FWTTreeCache(TTree *tree, Int_t buffersize=0);
45  virtual ~FWTTreeCache();
46 
47  static void LoggingOn();
48  static void LoggingOff();
49  static bool IsLogging();
50  static void SetDefaultCacheSize(int def_size);
51  static int GetDefaultCacheSize();
52 
53  Int_t AddBranchTopLevel (const char* bname);
54  Int_t DropBranchTopLevel(const char* bname);
55 
56  void BranchAccessCallIn(const TBranch *b);
57 
58  // virtuals from TTreeCache, just wrappers for info printouts
59  Int_t AddBranch(TBranch *b, Bool_t subbranches = kFALSE) override;
60  Int_t AddBranch(const char *branch, Bool_t subbranches = kFALSE) override;
61  Int_t DropBranch(TBranch *b, Bool_t subbranches = kFALSE) override;
62  Int_t DropBranch(const char *branch, Bool_t subbranches = kFALSE) override;
63 };
64 
65 #endif
static void LoggingOff()
Definition: FWTTreeCache.cc:26
static bool s_logging
Definition: FWTTreeCache.h:15
Int_t AddBranchTopLevel(const char *bname)
Definition: FWTTreeCache.cc:34
static bool IsLogging()
Definition: FWTTreeCache.cc:27
static int s_default_size
Definition: FWTTreeCache.h:14
LearnGuard(FWTTreeCache *tc)
Definition: FWTTreeCache.h:29
static int GetDefaultCacheSize()
Definition: FWTTreeCache.cc:30
Int_t AddBranch(TBranch *b, Bool_t subbranches=kFALSE) override
Definition: FWTTreeCache.cc:98
Int_t DropBranch(TBranch *b, Bool_t subbranches=kFALSE) override
void stop_learning()
Definition: FWTTreeCache.h:21
void BranchAccessCallIn(const TBranch *b)
Definition: FWTTreeCache.cc:88
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
virtual ~FWTTreeCache()
Definition: FWTTreeCache.cc:17
Definition: tree.py:1
Int_t DropBranchTopLevel(const char *bname)
Definition: FWTTreeCache.cc:63
static void LoggingOn()
Definition: FWTTreeCache.cc:25
bool start_learning()
Definition: FWTTreeCache.h:20
static void SetDefaultCacheSize(int def_size)
Definition: FWTTreeCache.cc:29
bool is_branch_in_cache(const char *name)
Definition: FWTTreeCache.h:18