1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#ifndef Fireworks_Core_FWTTreeCache_h
#define Fireworks_Core_FWTTreeCache_h
#include "TTreeCache.h"
#include <set>
#include <string>
class FWTTreeCache : public TTreeCache {
std::set<std::string> m_branch_set;
bool m_silent_low_level = false;
static int s_default_size;
static bool s_logging;
static bool s_prefetching;
protected:
bool is_branch_in_cache(const char *name) { return (m_branch_set.find(name) != m_branch_set.end()); }
bool start_learning() {
if (fIsLearning)
return true;
fIsLearning = true;
return false;
}
void stop_learning() { fIsLearning = false; }
struct LearnGuard {
FWTTreeCache *f_tc;
bool f_was_learning;
bool f_was_silent_ll;
LearnGuard(FWTTreeCache *tc) : f_tc(tc) {
f_was_learning = f_tc->start_learning();
f_was_silent_ll = f_tc->m_silent_low_level;
f_tc->m_silent_low_level = true;
}
~LearnGuard() {
if (!f_was_learning)
f_tc->stop_learning();
f_tc->m_silent_low_level = f_was_silent_ll;
}
};
public:
FWTTreeCache();
FWTTreeCache(TTree *tree, Int_t buffersize = 0);
~FWTTreeCache() override;
static void LoggingOn();
static void LoggingOff();
static bool IsLogging();
static void PrefetchingOn();
static void PrefetchingOff();
static bool IsPrefetching();
static void SetDefaultCacheSize(int def_size);
static int GetDefaultCacheSize();
Int_t AddBranchTopLevel(const char *bname);
Int_t DropBranchTopLevel(const char *bname);
void BranchAccessCallIn(const TBranch *b);
// virtuals from TTreeCache, just wrappers for info printouts
Int_t AddBranch(TBranch *b, Bool_t subbranches = kFALSE) override;
Int_t AddBranch(const char *branch, Bool_t subbranches = kFALSE) override;
Int_t DropBranch(TBranch *b, Bool_t subbranches = kFALSE) override;
Int_t DropBranch(const char *branch, Bool_t subbranches = kFALSE) override;
};
#endif
|