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 (const char *branch, Bool_t subbranches=kFALSE) override
 
Int_t AddBranch (TBranch *b, Bool_t subbranches=kFALSE) override
 
Int_t AddBranchTopLevel (const char *bname)
 
void BranchAccessCallIn (const TBranch *b)
 
Int_t DropBranch (const char *branch, Bool_t subbranches=kFALSE) override
 
Int_t DropBranch (TBranch *b, 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) {}

◆ ~FWTTreeCache()

FWTTreeCache::~FWTTreeCache ( )
override

Definition at line 13 of file FWTTreeCache.cc.

13 {}

Member Function Documentation

◆ AddBranch() [1/2]

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

Definition at line 93 of file FWTTreeCache.cc.

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 }

References MicroEventContent_cff::branch, m_silent_low_level, and s_logging.

◆ AddBranch() [2/2]

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

Definition at line 87 of file FWTTreeCache.cc.

87  {
89  printf("FWTTreeCache::AddBranch by ptr '%s', subbp=%d\n", b->GetName(), subbranches);
90  return TTreeCache::AddBranch(b, subbranches);
91 }

References b, m_silent_low_level, and s_logging.

Referenced by AddBranchTopLevel().

◆ AddBranchTopLevel()

Int_t FWTTreeCache::AddBranchTopLevel ( const char *  bname)

Definition at line 34 of file FWTTreeCache.cc.

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 }

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

Referenced by BranchAccessCallIn().

◆ BranchAccessCallIn()

void FWTTreeCache::BranchAccessCallIn ( const TBranch *  b)

Definition at line 78 of file FWTTreeCache.cc.

78  {
79  if (s_logging)
80  printf("FWTTreeCache::BranchAccessCallIn '%s'\n", b->GetName());
81 
82  AddBranchTopLevel(b->GetName());
83 }

References AddBranchTopLevel(), b, and s_logging.

◆ DropBranch() [1/2]

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

Definition at line 107 of file FWTTreeCache.cc.

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 }

References MicroEventContent_cff::branch, m_silent_low_level, runTheMatrix::ret, and s_logging.

◆ DropBranch() [2/2]

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

Definition at line 101 of file FWTTreeCache.cc.

101  {
103  printf("FWTTreeCache::DropBranch by ptr '%s', subbp=%d\n", b->GetName(), subbranches);
104  return TTreeCache::DropBranch(b, subbranches);
105 }

References b, m_silent_low_level, and s_logging.

Referenced by DropBranchTopLevel().

◆ DropBranchTopLevel()

Int_t FWTTreeCache::DropBranchTopLevel ( const char *  bname)

Definition at line 58 of file FWTTreeCache.cc.

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 }

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

◆ GetDefaultCacheSize()

int FWTTreeCache::GetDefaultCacheSize ( )
static

Definition at line 30 of file FWTTreeCache.cc.

30 { return s_default_size; }

References s_default_size.

Referenced by FWFileEntry::openFile().

◆ is_branch_in_cache()

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

Definition at line 18 of file FWTTreeCache.h.

18 { return (m_branch_set.find(name) != m_branch_set.end()); }

References m_branch_set, and Skims_PA_cff::name.

Referenced by AddBranchTopLevel(), and DropBranchTopLevel().

◆ IsLogging()

bool FWTTreeCache::IsLogging ( )
static

◆ IsPrefetching()

bool FWTTreeCache::IsPrefetching ( )
static

Definition at line 27 of file FWTTreeCache.cc.

27 { return s_prefetching; }

References s_prefetching.

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

◆ LoggingOff()

void FWTTreeCache::LoggingOff ( )
static

Definition at line 22 of file FWTTreeCache.cc.

22 { s_logging = false; }

References s_logging.

◆ LoggingOn()

void FWTTreeCache::LoggingOn ( )
static

Definition at line 21 of file FWTTreeCache.cc.

21 { s_logging = true; }

References s_logging.

Referenced by CmsShowMain::CmsShowMain().

◆ PrefetchingOff()

void FWTTreeCache::PrefetchingOff ( )
static

Definition at line 26 of file FWTTreeCache.cc.

26 { s_prefetching = false; }

References s_prefetching.

◆ PrefetchingOn()

void FWTTreeCache::PrefetchingOn ( )
static

Definition at line 25 of file FWTTreeCache.cc.

25 { s_prefetching = true; }

References s_prefetching.

Referenced by CmsShowMain::CmsShowMain().

◆ SetDefaultCacheSize()

void FWTTreeCache::SetDefaultCacheSize ( int  def_size)
static

Definition at line 29 of file FWTTreeCache.cc.

29 { s_default_size = def_size; }

References s_default_size.

Referenced by CmsShowMain::CmsShowMain().

◆ start_learning()

bool FWTTreeCache::start_learning ( )
inlineprotected

Definition at line 20 of file FWTTreeCache.h.

20  {
21  if (fIsLearning)
22  return true;
23  fIsLearning = true;
24  return false;
25  }

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

◆ stop_learning()

void FWTTreeCache::stop_learning ( )
inlineprotected

Definition at line 26 of file FWTTreeCache.h.

26 { fIsLearning = false; }

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

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

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
FWTTreeCache::s_prefetching
static bool s_prefetching
Definition: FWTTreeCache.h:15
FWTTreeCache::AddBranch
Int_t AddBranch(TBranch *b, Bool_t subbranches=kFALSE) override
Definition: FWTTreeCache.cc:87
MicroEventContent_cff.branch
branch
Definition: MicroEventContent_cff.py:169
tree
Definition: tree.py:1
FWTTreeCache::m_silent_low_level
bool m_silent_low_level
Definition: FWTTreeCache.h:11
FWTTreeCache::m_branch_set
std::set< std::string > m_branch_set
Definition: FWTTreeCache.h:10
b
double b
Definition: hdecay.h:118
FWTTreeCache::s_default_size
static int s_default_size
Definition: FWTTreeCache.h:13
FWTTreeCache::DropBranch
Int_t DropBranch(TBranch *b, Bool_t subbranches=kFALSE) override
Definition: FWTTreeCache.cc:101
FWTTreeCache::is_branch_in_cache
bool is_branch_in_cache(const char *name)
Definition: FWTTreeCache.h:18
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
FWTTreeCache::s_logging
static bool s_logging
Definition: FWTTreeCache.h:14
FWTTreeCache::AddBranchTopLevel
Int_t AddBranchTopLevel(const char *bname)
Definition: FWTTreeCache.cc:34