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 : TTreeCache() {}
FWTTreeCache::FWTTreeCache ( TTree *  tree,
Int_t  buffersize = 0 
)

Definition at line 11 of file FWTTreeCache.cc.

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

Definition at line 13 of file FWTTreeCache.cc.

References s_default_size, s_logging, and s_prefetching.

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

13 {}

Member Function Documentation

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

Definition at line 87 of file FWTTreeCache.cc.

References m_silent_low_level, and s_logging.

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

87  {
89  printf("FWTTreeCache::AddBranch by ptr '%s', subbp=%d\n", b->GetName(), subbranches);
90  return TTreeCache::AddBranch(b, subbranches);
91 }
static bool s_logging
Definition: FWTTreeCache.h:14
bool m_silent_low_level
Definition: FWTTreeCache.h:11
double b
Definition: hdecay.h:118
Int_t FWTTreeCache::AddBranch ( const char *  branch,
Bool_t  subbranches = kFALSE 
)
override

Definition at line 93 of file FWTTreeCache.cc.

References m_silent_low_level, and s_logging.

93  {
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 }
static bool s_logging
Definition: FWTTreeCache.h:14
bool m_silent_low_level
Definition: FWTTreeCache.h:11
Int_t FWTTreeCache::AddBranchTopLevel ( const char *  bname)

Definition at line 34 of file FWTTreeCache.cc.

References AddBranch(), is_branch_in_cache(), m_branch_set, runTheMatrix::ret, and s_logging.

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

34  {
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 }
static bool s_logging
Definition: FWTTreeCache.h:14
ret
prodAgent to be discontinued
Int_t AddBranch(TBranch *b, Bool_t subbranches=kFALSE) override
Definition: FWTTreeCache.cc:87
std::set< std::string > m_branch_set
Definition: FWTTreeCache.h:10
bool is_branch_in_cache(const char *name)
Definition: FWTTreeCache.h:18
void FWTTreeCache::BranchAccessCallIn ( const TBranch *  b)

Definition at line 78 of file FWTTreeCache.cc.

References AddBranchTopLevel(), and s_logging.

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

78  {
79  if (s_logging)
80  printf("FWTTreeCache::BranchAccessCallIn '%s'\n", b->GetName());
81 
82  AddBranchTopLevel(b->GetName());
83 }
static bool s_logging
Definition: FWTTreeCache.h:14
Int_t AddBranchTopLevel(const char *bname)
Definition: FWTTreeCache.cc:34
double b
Definition: hdecay.h:118
Int_t FWTTreeCache::DropBranch ( TBranch *  b,
Bool_t  subbranches = kFALSE 
)
override

Definition at line 101 of file FWTTreeCache.cc.

References m_silent_low_level, and s_logging.

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

101  {
103  printf("FWTTreeCache::DropBranch by ptr '%s', subbp=%d\n", b->GetName(), subbranches);
104  return TTreeCache::DropBranch(b, subbranches);
105 }
static bool s_logging
Definition: FWTTreeCache.h:14
bool m_silent_low_level
Definition: FWTTreeCache.h:11
double b
Definition: hdecay.h:118
Int_t FWTTreeCache::DropBranch ( const char *  branch,
Bool_t  subbranches = kFALSE 
)
override

Definition at line 107 of file FWTTreeCache.cc.

References m_silent_low_level, runTheMatrix::ret, and s_logging.

107  {
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 bool s_logging
Definition: FWTTreeCache.h:14
ret
prodAgent to be discontinued
bool m_silent_low_level
Definition: FWTTreeCache.h:11
Int_t FWTTreeCache::DropBranchTopLevel ( const char *  bname)

Definition at line 58 of file FWTTreeCache.cc.

References DropBranch(), is_branch_in_cache(), m_branch_set, runTheMatrix::ret, and s_logging.

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

58  {
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 }
static bool s_logging
Definition: FWTTreeCache.h:14
ret
prodAgent to be discontinued
Int_t DropBranch(TBranch *b, Bool_t subbranches=kFALSE) override
std::set< std::string > m_branch_set
Definition: FWTTreeCache.h:10
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:13
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:10
bool FWTTreeCache::IsLogging ( )
static
bool FWTTreeCache::IsPrefetching ( )
static

Definition at line 27 of file FWTTreeCache.cc.

References s_prefetching.

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

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

Definition at line 22 of file FWTTreeCache.cc.

References s_logging.

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

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

Definition at line 21 of file FWTTreeCache.cc.

References s_logging.

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

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

Definition at line 26 of file FWTTreeCache.cc.

References s_prefetching.

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

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

Definition at line 25 of file FWTTreeCache.cc.

References s_prefetching.

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

25 { s_prefetching = true; }
static bool s_prefetching
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:13
bool FWTTreeCache::start_learning ( )
inlineprotected

Definition at line 20 of file FWTTreeCache.h.

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

20  {
21  if (fIsLearning)
22  return true;
23  fIsLearning = true;
24  return false;
25  }
void FWTTreeCache::stop_learning ( )
inlineprotected

Definition at line 26 of file FWTTreeCache.h.

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

26 { fIsLearning = false; }

Member Data Documentation

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

Definition at line 10 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 13 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 15 of file FWTTreeCache.h.

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