CMS 3D CMS Logo

FWTTreeCache.cc
Go to the documentation of this file.
1 #include "FWTTreeCache.h"
2 
3 #include "TChain.h"
4 #include "TTree.h"
5 #include "TEventList.h"
6 
7 #include <climits>
8 
9 FWTTreeCache::FWTTreeCache() : TTreeCache() {}
10 
11 FWTTreeCache::FWTTreeCache(TTree *tree, Int_t buffersize) : TTreeCache(tree, buffersize) {}
12 
14 
15 //==============================================================================
16 
17 bool FWTTreeCache::s_logging = false;
18 bool FWTTreeCache::s_prefetching = false;
19 int FWTTreeCache::s_default_size = 50 * 1024 * 1024;
20 
24 
28 
29 void FWTTreeCache::SetDefaultCacheSize(int def_size) { s_default_size = def_size; }
31 
32 //==============================================================================
33 
34 Int_t FWTTreeCache::AddBranchTopLevel(const char *bname) {
35  if (bname == nullptr || bname[0] == 0) {
36  printf("FWTTreeCache::AddBranchTopLevel Invalid branch name <%s>\n", bname == nullptr ? "nullptr" : "empty string");
37  return -1;
38  }
39 
40  Int_t ret = 0;
41  if (!is_branch_in_cache(bname)) {
42  if (s_logging)
43  printf("FWTTreeCache::AddBranchTopLevel '%s' -- adding\n", bname);
44  {
45  LearnGuard _lg(this);
46  ret = AddBranch(bname, true);
47  }
48  if (ret == 0)
49  m_branch_set.insert(bname);
50  } else {
51  if (s_logging)
52  printf("FWTTreeCache::AddBranchTopLevel '%s' -- already in cache\n", bname);
53  }
54 
55  return ret;
56 }
57 
58 Int_t FWTTreeCache::DropBranchTopLevel(const char *bname) {
59  if (bname == nullptr || bname[0] == 0) {
60  printf("FWTTreeCache::AddBranchTopLevel Invalid branch name");
61  return -1;
62  }
63 
64  Int_t ret = 0;
65  if (is_branch_in_cache(bname)) {
66  if (s_logging)
67  printf("FWTTreeCache::DropBranchTopLevel '%s' -- dropping\n", bname);
68  m_branch_set.erase(bname);
69  LearnGuard _lg(this);
70  ret = DropBranch(bname, true);
71  } else {
72  if (s_logging)
73  printf("FWTTreeCache::DropBranchTopLevel '%s' -- not in cache\n", bname);
74  }
75  return ret;
76 }
77 
78 void FWTTreeCache::BranchAccessCallIn(const TBranch *b) {
79  if (s_logging)
80  printf("FWTTreeCache::BranchAccessCallIn '%s'\n", b->GetName());
81 
82  AddBranchTopLevel(b->GetName());
83 }
84 
85 //==============================================================================
86 
87 Int_t FWTTreeCache::AddBranch(TBranch *b, Bool_t subbranches) {
89  printf("FWTTreeCache::AddBranch by ptr '%s', subbp=%d\n", b->GetName(), subbranches);
90  return TTreeCache::AddBranch(b, subbranches);
91 }
92 
93 Int_t FWTTreeCache::AddBranch(const char *branch, Bool_t subbranches) {
94  if (s_logging)
95  printf("FWTTreeCache::AddBranch by name '%s', subbp=%d\n", branch, subbranches);
96  if (strcmp(branch, "*") == 0)
97  m_silent_low_level = true;
98  return TTreeCache::AddBranch(branch, subbranches);
99 }
100 
101 Int_t FWTTreeCache::DropBranch(TBranch *b, Bool_t subbranches) {
103  printf("FWTTreeCache::DropBranch by ptr '%s', subbp=%d\n", b->GetName(), subbranches);
104  return TTreeCache::DropBranch(b, subbranches);
105 }
106 
107 Int_t FWTTreeCache::DropBranch(const char *branch, Bool_t subbranches) {
108  if (s_logging)
109  printf("FWTTreeCache::DropBranch by name '%s', subbp=%d\n", branch, subbranches);
110  Int_t ret = TTreeCache::DropBranch(branch, subbranches);
111  if (strcmp(branch, "*") == 0)
112  m_silent_low_level = false;
113  return ret;
114 }
static void PrefetchingOn()
Definition: FWTTreeCache.cc:25
static void LoggingOff()
Definition: FWTTreeCache.cc:22
~FWTTreeCache() override
Definition: FWTTreeCache.cc:13
static bool s_logging
Definition: FWTTreeCache.h:14
Int_t AddBranchTopLevel(const char *bname)
Definition: FWTTreeCache.cc:34
ret
prodAgent to be discontinued
static void PrefetchingOff()
Definition: FWTTreeCache.cc:26
static bool IsLogging()
Definition: FWTTreeCache.cc:23
static bool IsPrefetching()
Definition: FWTTreeCache.cc:27
static int s_default_size
Definition: FWTTreeCache.h:13
static int GetDefaultCacheSize()
Definition: FWTTreeCache.cc:30
Int_t AddBranch(TBranch *b, Bool_t subbranches=kFALSE) override
Definition: FWTTreeCache.cc:87
Int_t DropBranch(TBranch *b, Bool_t subbranches=kFALSE) override
void BranchAccessCallIn(const TBranch *b)
Definition: FWTTreeCache.cc:78
static bool s_prefetching
Definition: FWTTreeCache.h:15
bool m_silent_low_level
Definition: FWTTreeCache.h:11
std::set< std::string > m_branch_set
Definition: FWTTreeCache.h:10
double b
Definition: hdecay.h:120
Definition: tree.py:1
Int_t DropBranchTopLevel(const char *bname)
Definition: FWTTreeCache.cc:58
static void LoggingOn()
Definition: FWTTreeCache.cc:21
static void SetDefaultCacheSize(int def_size)
Definition: FWTTreeCache.cc:29
bool is_branch_in_cache(const char *name)
Definition: FWTTreeCache.h:18