CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Static Private Attributes
FWTTreeCache Class Reference

#include <FWTTreeCache.h>

Inheritance diagram for FWTTreeCache:

Classes

struct  LearnGuard
 

Public Member Functions

Int_t AddBranch (TBranch *b, Bool_t subbranches=kFALSE) override
 
Int_t AddBranch (const char *branch, Bool_t subbranches=kFALSE) override
 
Int_t AddBranchTopLevel (const char *bname)
 
void BranchAccessCallIn (const TBranch *b)
 
Int_t DropBranch (TBranch *b, Bool_t subbranches=kFALSE) override
 
Int_t DropBranch (const char *branch, Bool_t subbranches=kFALSE) override
 
Int_t DropBranchTopLevel (const char *bname)
 
 FWTTreeCache ()
 
 FWTTreeCache (TTree *tree, Int_t buffersize=0)
 
 ~FWTTreeCache () override
 

Static Public Member Functions

static int GetDefaultCacheSize ()
 
static bool IsLogging ()
 
static void LoggingOff ()
 
static void LoggingOn ()
 
static void SetDefaultCacheSize (int def_size)
 

Protected Member Functions

bool is_branch_in_cache (const char *name)
 
bool start_learning ()
 
void stop_learning ()
 

Private Attributes

std::set< std::string > m_branch_set
 
bool m_silent_low_level = false
 

Static Private Attributes

static int s_default_size = 50 * 1024 * 1024
 
static bool s_logging = false
 

Detailed Description

Definition at line 9 of file FWTTreeCache.h.

Constructor & Destructor Documentation

FWTTreeCache::FWTTreeCache ( )

Definition at line 9 of file FWTTreeCache.cc.

Referenced by FWTTreeCache::LearnGuard::~LearnGuard().

9  :
10  TTreeCache()
11 {}
FWTTreeCache::FWTTreeCache ( TTree *  tree,
Int_t  buffersize = 0 
)

Definition at line 13 of file FWTTreeCache.cc.

13  :
14  TTreeCache(tree, buffersize)
15 {}
Definition: tree.py:1
FWTTreeCache::~FWTTreeCache ( )
override

Definition at line 17 of file FWTTreeCache.cc.

References s_default_size, and s_logging.

Referenced by FWTTreeCache::LearnGuard::~LearnGuard().

18 {}

Member Function Documentation

Int_t FWTTreeCache::AddBranch ( TBranch *  b,
Bool_t  subbranches = kFALSE 
)
override

Definition at line 98 of file FWTTreeCache.cc.

References m_silent_low_level, and s_logging.

Referenced by AddBranchTopLevel(), and FWTTreeCache::LearnGuard::~LearnGuard().

99 {
100  if (s_logging && ! m_silent_low_level)
101  printf("FWTTreeCache::AddBranch by ptr '%s', subbp=%d\n", b->GetName(), subbranches);
102  return TTreeCache::AddBranch(b, subbranches);
103 }
static bool s_logging
Definition: FWTTreeCache.h:15
bool m_silent_low_level
Definition: FWTTreeCache.h:12
double b
Definition: hdecay.h:120
Int_t FWTTreeCache::AddBranch ( const char *  branch,
Bool_t  subbranches = kFALSE 
)
override

Definition at line 105 of file FWTTreeCache.cc.

References m_silent_low_level, and s_logging.

106 {
107  if (s_logging)
108  printf("FWTTreeCache::AddBranch by name '%s', subbp=%d\n", branch, subbranches);
109  if (strcmp(branch,"*") == 0)
110  m_silent_low_level = true;
111  return TTreeCache::AddBranch(branch, subbranches);
112 }
static bool s_logging
Definition: FWTTreeCache.h:15
bool m_silent_low_level
Definition: FWTTreeCache.h:12
Int_t FWTTreeCache::AddBranchTopLevel ( const char *  bname)

Definition at line 34 of file FWTTreeCache.cc.

References AddBranch(), is_branch_in_cache(), m_branch_set, and s_logging.

Referenced by BranchAccessCallIn(), and FWTTreeCache::LearnGuard::~LearnGuard().

35 {
36  if (bname == nullptr || bname[0] == 0)
37  {
38  printf("FWTTreeCache::AddBranchTopLevel Invalid branch name <%s>\n",
39  bname == nullptr ? "nullptr" : "empty string");
40  return -1;
41  }
42 
43  Int_t ret = 0;
44  if ( ! is_branch_in_cache(bname))
45  {
46  if (s_logging)
47  printf("FWTTreeCache::AddBranchTopLevel '%s' -- adding\n", bname);
48  { LearnGuard _lg(this);
49  ret = AddBranch(bname, true);
50  }
51  if (ret == 0)
52  m_branch_set.insert(bname);
53  }
54  else
55  {
56  if (s_logging)
57  printf("FWTTreeCache::AddBranchTopLevel '%s' -- already in cache\n", bname);
58  }
59 
60  return ret;
61 }
static bool s_logging
Definition: FWTTreeCache.h:15
Int_t AddBranch(TBranch *b, Bool_t subbranches=kFALSE) override
Definition: FWTTreeCache.cc:98
std::set< std::string > m_branch_set
Definition: FWTTreeCache.h:11
bool is_branch_in_cache(const char *name)
Definition: FWTTreeCache.h:18
void FWTTreeCache::BranchAccessCallIn ( const TBranch *  b)

Definition at line 88 of file FWTTreeCache.cc.

References AddBranchTopLevel(), and s_logging.

Referenced by FWTTreeCache::LearnGuard::~LearnGuard().

89 {
90  if (s_logging)
91  printf("FWTTreeCache::BranchAccessCallIn '%s'\n", b->GetName());
92 
93  AddBranchTopLevel(b->GetName());
94 }
static bool s_logging
Definition: FWTTreeCache.h:15
Int_t AddBranchTopLevel(const char *bname)
Definition: FWTTreeCache.cc:34
double b
Definition: hdecay.h:120
Int_t FWTTreeCache::DropBranch ( TBranch *  b,
Bool_t  subbranches = kFALSE 
)
override

Definition at line 114 of file FWTTreeCache.cc.

References m_silent_low_level, and s_logging.

Referenced by DropBranchTopLevel(), and FWTTreeCache::LearnGuard::~LearnGuard().

115 {
116  if (s_logging && ! m_silent_low_level)
117  printf("FWTTreeCache::DropBranch by ptr '%s', subbp=%d\n", b->GetName(), subbranches);
118  return TTreeCache::DropBranch(b, subbranches);
119 }
static bool s_logging
Definition: FWTTreeCache.h:15
bool m_silent_low_level
Definition: FWTTreeCache.h:12
double b
Definition: hdecay.h:120
Int_t FWTTreeCache::DropBranch ( const char *  branch,
Bool_t  subbranches = kFALSE 
)
override

Definition at line 121 of file FWTTreeCache.cc.

References m_silent_low_level, and s_logging.

122 {
123  if (s_logging)
124  printf("FWTTreeCache::DropBranch by name '%s', subbp=%d\n", branch, subbranches);
125  Int_t ret = TTreeCache::DropBranch(branch, subbranches);
126  if (strcmp(branch,"*") == 0)
127  m_silent_low_level = false;
128  return ret;
129 }
static bool s_logging
Definition: FWTTreeCache.h:15
bool m_silent_low_level
Definition: FWTTreeCache.h:12
Int_t FWTTreeCache::DropBranchTopLevel ( const char *  bname)

Definition at line 63 of file FWTTreeCache.cc.

References DropBranch(), is_branch_in_cache(), m_branch_set, and s_logging.

Referenced by FWTTreeCache::LearnGuard::~LearnGuard().

64 {
65  if (bname == nullptr || bname[0] == 0)
66  {
67  printf("FWTTreeCache::AddBranchTopLevel Invalid branch name");
68  return -1;
69  }
70 
71  Int_t ret = 0;
72  if (is_branch_in_cache(bname))
73  {
74  if (s_logging)
75  printf("FWTTreeCache::DropBranchTopLevel '%s' -- dropping\n", bname);
76  m_branch_set.erase(bname);
77  LearnGuard _lg(this);
78  ret = DropBranch(bname, true);
79  }
80  else
81  {
82  if (s_logging)
83  printf("FWTTreeCache::DropBranchTopLevel '%s' -- not in cache\n", bname);
84  }
85  return ret;
86 }
static bool s_logging
Definition: FWTTreeCache.h:15
Int_t DropBranch(TBranch *b, Bool_t subbranches=kFALSE) override
std::set< std::string > m_branch_set
Definition: FWTTreeCache.h:11
bool is_branch_in_cache(const char *name)
Definition: FWTTreeCache.h:18
int FWTTreeCache::GetDefaultCacheSize ( )
static

Definition at line 30 of file FWTTreeCache.cc.

References s_default_size.

Referenced by FWFileEntry::openFile(), and FWTTreeCache::LearnGuard::~LearnGuard().

30 { return s_default_size; }
static int s_default_size
Definition: FWTTreeCache.h:14
bool FWTTreeCache::is_branch_in_cache ( const char *  name)
inlineprotected

Definition at line 18 of file FWTTreeCache.h.

Referenced by AddBranchTopLevel(), and DropBranchTopLevel().

18 { return (m_branch_set.find(name) != m_branch_set.end()); }
std::set< std::string > m_branch_set
Definition: FWTTreeCache.h:11
bool FWTTreeCache::IsLogging ( )
static
void FWTTreeCache::LoggingOff ( )
static

Definition at line 26 of file FWTTreeCache.cc.

References s_logging.

Referenced by FWTTreeCache::LearnGuard::~LearnGuard().

26 { s_logging = false; }
static bool s_logging
Definition: FWTTreeCache.h:15
void FWTTreeCache::LoggingOn ( )
static

Definition at line 25 of file FWTTreeCache.cc.

References s_logging.

Referenced by CmsShowMain::CmsShowMain(), and FWTTreeCache::LearnGuard::~LearnGuard().

25 { s_logging = true; }
static bool s_logging
Definition: FWTTreeCache.h:15
void FWTTreeCache::SetDefaultCacheSize ( int  def_size)
static

Definition at line 29 of file FWTTreeCache.cc.

References s_default_size.

Referenced by CmsShowMain::CmsShowMain(), and FWTTreeCache::LearnGuard::~LearnGuard().

29 { s_default_size = def_size; }
static int s_default_size
Definition: FWTTreeCache.h:14
bool FWTTreeCache::start_learning ( )
inlineprotected

Definition at line 20 of file FWTTreeCache.h.

Referenced by FWTTreeCache::LearnGuard::LearnGuard().

20 { if (fIsLearning) return true; fIsLearning = true; return false; }
void FWTTreeCache::stop_learning ( )
inlineprotected

Definition at line 21 of file FWTTreeCache.h.

Referenced by FWTTreeCache::LearnGuard::~LearnGuard().

21 { fIsLearning = false; }

Member Data Documentation

std::set<std::string> FWTTreeCache::m_branch_set
private

Definition at line 11 of file FWTTreeCache.h.

Referenced by AddBranchTopLevel(), and DropBranchTopLevel().

bool FWTTreeCache::m_silent_low_level = false
private
int FWTTreeCache::s_default_size = 50 * 1024 * 1024
staticprivate

Definition at line 14 of file FWTTreeCache.h.

Referenced by GetDefaultCacheSize(), SetDefaultCacheSize(), and ~FWTTreeCache().

bool FWTTreeCache::s_logging = false
staticprivate