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 bool IsPrefetching ()
 
static void LoggingOff ()
 
static void LoggingOn ()
 
static void PrefetchingOff ()
 
static void PrefetchingOn ()
 
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
 
static bool s_prefetching = 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, s_logging, and s_prefetching.

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

18 {}

Member Function Documentation

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

Definition at line 103 of file FWTTreeCache.cc.

References m_silent_low_level, and s_logging.

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

104 {
105  if (s_logging && ! m_silent_low_level)
106  printf("FWTTreeCache::AddBranch by ptr '%s', subbp=%d\n", b->GetName(), subbranches);
107  return TTreeCache::AddBranch(b, subbranches);
108 }
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 110 of file FWTTreeCache.cc.

References m_silent_low_level, and s_logging.

111 {
112  if (s_logging)
113  printf("FWTTreeCache::AddBranch by name '%s', subbp=%d\n", branch, subbranches);
114  if (strcmp(branch,"*") == 0)
115  m_silent_low_level = true;
116  return TTreeCache::AddBranch(branch, subbranches);
117 }
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 39 of file FWTTreeCache.cc.

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

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

40 {
41  if (bname == nullptr || bname[0] == 0)
42  {
43  printf("FWTTreeCache::AddBranchTopLevel Invalid branch name <%s>\n",
44  bname == nullptr ? "nullptr" : "empty string");
45  return -1;
46  }
47 
48  Int_t ret = 0;
49  if ( ! is_branch_in_cache(bname))
50  {
51  if (s_logging)
52  printf("FWTTreeCache::AddBranchTopLevel '%s' -- adding\n", bname);
53  { LearnGuard _lg(this);
54  ret = AddBranch(bname, true);
55  }
56  if (ret == 0)
57  m_branch_set.insert(bname);
58  }
59  else
60  {
61  if (s_logging)
62  printf("FWTTreeCache::AddBranchTopLevel '%s' -- already in cache\n", bname);
63  }
64 
65  return ret;
66 }
static bool s_logging
Definition: FWTTreeCache.h:15
Int_t AddBranch(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:19
void FWTTreeCache::BranchAccessCallIn ( const TBranch *  b)

Definition at line 93 of file FWTTreeCache.cc.

References AddBranchTopLevel(), and s_logging.

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

94 {
95  if (s_logging)
96  printf("FWTTreeCache::BranchAccessCallIn '%s'\n", b->GetName());
97 
98  AddBranchTopLevel(b->GetName());
99 }
static bool s_logging
Definition: FWTTreeCache.h:15
Int_t AddBranchTopLevel(const char *bname)
Definition: FWTTreeCache.cc:39
double b
Definition: hdecay.h:120
Int_t FWTTreeCache::DropBranch ( TBranch *  b,
Bool_t  subbranches = kFALSE 
)
override

Definition at line 119 of file FWTTreeCache.cc.

References m_silent_low_level, and s_logging.

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

120 {
121  if (s_logging && ! m_silent_low_level)
122  printf("FWTTreeCache::DropBranch by ptr '%s', subbp=%d\n", b->GetName(), subbranches);
123  return TTreeCache::DropBranch(b, subbranches);
124 }
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 126 of file FWTTreeCache.cc.

References m_silent_low_level, and s_logging.

127 {
128  if (s_logging)
129  printf("FWTTreeCache::DropBranch by name '%s', subbp=%d\n", branch, subbranches);
130  Int_t ret = TTreeCache::DropBranch(branch, subbranches);
131  if (strcmp(branch,"*") == 0)
132  m_silent_low_level = false;
133  return ret;
134 }
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 68 of file FWTTreeCache.cc.

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

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

69 {
70  if (bname == nullptr || bname[0] == 0)
71  {
72  printf("FWTTreeCache::AddBranchTopLevel Invalid branch name");
73  return -1;
74  }
75 
76  Int_t ret = 0;
77  if (is_branch_in_cache(bname))
78  {
79  if (s_logging)
80  printf("FWTTreeCache::DropBranchTopLevel '%s' -- dropping\n", bname);
81  m_branch_set.erase(bname);
82  LearnGuard _lg(this);
83  ret = DropBranch(bname, true);
84  }
85  else
86  {
87  if (s_logging)
88  printf("FWTTreeCache::DropBranchTopLevel '%s' -- not in cache\n", bname);
89  }
90  return ret;
91 }
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:19
int FWTTreeCache::GetDefaultCacheSize ( )
static

Definition at line 35 of file FWTTreeCache.cc.

References s_default_size.

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

35 { 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 19 of file FWTTreeCache.h.

Referenced by AddBranchTopLevel(), and DropBranchTopLevel().

19 { 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
bool FWTTreeCache::IsPrefetching ( )
static

Definition at line 32 of file FWTTreeCache.cc.

References s_prefetching.

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

32 { return s_prefetching; }
static bool s_prefetching
Definition: FWTTreeCache.h:16
void FWTTreeCache::LoggingOff ( )
static

Definition at line 27 of file FWTTreeCache.cc.

References s_logging.

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

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

Definition at line 26 of file FWTTreeCache.cc.

References s_logging.

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

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

Definition at line 31 of file FWTTreeCache.cc.

References s_prefetching.

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

31 { s_prefetching = false; }
static bool s_prefetching
Definition: FWTTreeCache.h:16
void FWTTreeCache::PrefetchingOn ( )
static

Definition at line 30 of file FWTTreeCache.cc.

References s_prefetching.

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

30 { s_prefetching = true; }
static bool s_prefetching
Definition: FWTTreeCache.h:16
void FWTTreeCache::SetDefaultCacheSize ( int  def_size)
static

Definition at line 34 of file FWTTreeCache.cc.

References s_default_size.

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

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

Definition at line 21 of file FWTTreeCache.h.

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

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

Definition at line 22 of file FWTTreeCache.h.

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

22 { 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
bool FWTTreeCache::s_prefetching = false
staticprivate

Definition at line 16 of file FWTTreeCache.h.

Referenced by IsPrefetching(), PrefetchingOff(), PrefetchingOn(), and ~FWTTreeCache().