CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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() [1/2]

FWTTreeCache::FWTTreeCache ( )

Definition at line 9 of file FWTTreeCache.cc.

9 : TTreeCache() {}

◆ FWTTreeCache() [2/2]

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::~FWTTreeCache ( )
override

Definition at line 13 of file FWTTreeCache.cc.

13 {}

Member Function Documentation

◆ AddBranch() [1/2]

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

Definition at line 87 of file FWTTreeCache.cc.

References b, m_silent_low_level, and s_logging.

Referenced by AddBranchTopLevel().

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

◆ AddBranch() [2/2]

Int_t FWTTreeCache::AddBranch ( const char *  branch,
Bool_t  subbranches = kFALSE 
)
override

Definition at line 93 of file FWTTreeCache.cc.

References MicroEventContent_cff::branch, 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

◆ AddBranchTopLevel()

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().

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

◆ BranchAccessCallIn()

void FWTTreeCache::BranchAccessCallIn ( const TBranch *  b)

Definition at line 78 of file FWTTreeCache.cc.

References AddBranchTopLevel(), b, and s_logging.

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

◆ DropBranch() [1/2]

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

Definition at line 101 of file FWTTreeCache.cc.

References b, m_silent_low_level, and s_logging.

Referenced by DropBranchTopLevel().

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

◆ DropBranch() [2/2]

Int_t FWTTreeCache::DropBranch ( const char *  branch,
Bool_t  subbranches = kFALSE 
)
override

Definition at line 107 of file FWTTreeCache.cc.

References MicroEventContent_cff::branch, 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

◆ DropBranchTopLevel()

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.

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

◆ GetDefaultCacheSize()

int FWTTreeCache::GetDefaultCacheSize ( )
static

Definition at line 30 of file FWTTreeCache.cc.

References s_default_size.

Referenced by FWFileEntry::openFile().

30 { return s_default_size; }
static int s_default_size
Definition: FWTTreeCache.h:13

◆ is_branch_in_cache()

bool FWTTreeCache::is_branch_in_cache ( const char *  name)
inlineprotected

Definition at line 18 of file FWTTreeCache.h.

References m_branch_set, and Skims_PA_cff::name.

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

◆ IsLogging()

bool FWTTreeCache::IsLogging ( )
static

◆ IsPrefetching()

bool FWTTreeCache::IsPrefetching ( )
static

Definition at line 27 of file FWTTreeCache.cc.

References s_prefetching.

Referenced by FWFileEntry::openFile(), and FWFileEntry::runFilter().

27 { return s_prefetching; }
static bool s_prefetching
Definition: FWTTreeCache.h:15

◆ LoggingOff()

void FWTTreeCache::LoggingOff ( )
static

Definition at line 22 of file FWTTreeCache.cc.

References s_logging.

22 { s_logging = false; }
static bool s_logging
Definition: FWTTreeCache.h:14

◆ LoggingOn()

void FWTTreeCache::LoggingOn ( )
static

Definition at line 21 of file FWTTreeCache.cc.

References s_logging.

Referenced by CmsShowMain::CmsShowMain().

21 { s_logging = true; }
static bool s_logging
Definition: FWTTreeCache.h:14

◆ PrefetchingOff()

void FWTTreeCache::PrefetchingOff ( )
static

Definition at line 26 of file FWTTreeCache.cc.

References s_prefetching.

26 { s_prefetching = false; }
static bool s_prefetching
Definition: FWTTreeCache.h:15

◆ PrefetchingOn()

void FWTTreeCache::PrefetchingOn ( )
static

Definition at line 25 of file FWTTreeCache.cc.

References s_prefetching.

Referenced by CmsShowMain::CmsShowMain().

25 { s_prefetching = true; }
static bool s_prefetching
Definition: FWTTreeCache.h:15

◆ SetDefaultCacheSize()

void FWTTreeCache::SetDefaultCacheSize ( int  def_size)
static

Definition at line 29 of file FWTTreeCache.cc.

References s_default_size.

Referenced by CmsShowMain::CmsShowMain().

29 { s_default_size = def_size; }
static int s_default_size
Definition: FWTTreeCache.h:13

◆ start_learning()

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  }

◆ stop_learning()

void FWTTreeCache::stop_learning ( )
inlineprotected

Definition at line 26 of file FWTTreeCache.h.

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

26 { fIsLearning = false; }

Member Data Documentation

◆ m_branch_set

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

Definition at line 10 of file FWTTreeCache.h.

Referenced by AddBranchTopLevel(), DropBranchTopLevel(), and is_branch_in_cache().

◆ m_silent_low_level

bool FWTTreeCache::m_silent_low_level = false
private

◆ s_default_size

int FWTTreeCache::s_default_size = 50 * 1024 * 1024
staticprivate

Definition at line 13 of file FWTTreeCache.h.

Referenced by GetDefaultCacheSize(), and SetDefaultCacheSize().

◆ s_logging

bool FWTTreeCache::s_logging = false
staticprivate

◆ s_prefetching

bool FWTTreeCache::s_prefetching = false
staticprivate

Definition at line 15 of file FWTTreeCache.h.

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