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
72
73
74
|
#ifndef TTREE_FOREACH_ENTRY_H
#define TTREE_FOREACH_ENTRY_H
#include <cassert>
#include <string>
#include <algorithm>
#include <iomanip>
#include "TTree.h"
#define LEAF(leaf, tree) \
leaf = 0; \
{ \
TBranch* branch = tree->GetBranch(#leaf); \
assert(branch); \
branch->SetAddress(&(leaf)); \
branch->GetEntry(TFE_local_index, 1); \
}
#define PLEAF(leaf, tree) \
leaf; \
{ \
TBranch* branch = tree->GetBranch(#leaf); \
assert(branch); \
void* pt = &(leaf); \
branch->SetAddress(&pt); \
branch->GetEntry(TFE_local_index, 1); \
}
#define RENAMED_LEAF(var, leafname, tree) \
var = 0; \
{ \
std::string n = leafname; \
TBranch* branch = tree->GetBranch(n.c_str()); \
assert(branch); \
branch->SetAddress(&(var)); \
branch->GetEntry(TFE_local_index, 1); \
}
#define RENAMED_PLEAF(var, leafname, tree) \
var; \
{ \
std::string n = leafname; \
TBranch* branch = tree->GetBranch(n.c_str()); \
assert(branch); \
void* pt = &(var); \
branch->SetAddress(&pt); \
branch->GetEntry(TFE_local_index, 1); \
}
#define TTREE_FOREACH_ENTRY(tree) \
for (Long64_t TFE_index = 0, \
TFE_total = tree->GetEntries(), \
TFE_local_index = 0, \
TFE_local_total = 0, \
TFE_freq = TFE_total / 100; \
TFE_index < TFE_total && \
(TFE_local_index < TFE_local_total || (-1 < tree->LoadTree(TFE_index) && -1 < (TFE_local_index = 0) && \
-1 < (TFE_local_total = tree->GetTree()->GetEntries()))); \
TFE_index++, TFE_local_index++)
#define TFE_MAX(max) \
if (TFE_index && max) { \
TFE_total = std::min(Long64_t(max), TFE_total); \
TFE_freq = TFE_total / 100; \
}
#define TFE_PRINTSTATUS \
{ \
if (TFE_freq && !(TFE_index % TFE_freq)) { \
std::cout << "\b\b\b\b\b" << std::setw(3) << std::fixed << (100 * TFE_index) / TFE_total << "% " << std::flush; \
} \
}
#endif
|