Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
garana
garana
Base
TreeReader.cxx
Go to the documentation of this file.
1
2
#include "
garana/Base/TreeReader.h
"
3
4
using namespace
garana
;
5
6
void
TreeReader::SetupRead
(TTree*
tree
=0){
7
8
fTreeIn
=
tree
;
9
fOpt
=
'r'
;
10
11
try
{
12
if
(!
fTreeIn
)
13
throw
fTreeIn
;
14
15
if
(!
SetBranchAddresses
())
16
throw
false
;
17
}
18
catch
(TTree*
t
){
19
std::cerr <<
"TreeReader::SetupRead error: input tree not valid"
<<
std::endl
;
20
}
21
catch
(
bool
set
){
22
std::cerr <<
"TreeReader::SetupRead error: failed to set branch addresses"
<<
std::endl
;
23
}
24
}
25
26
TTree*
TreeReader::GetInputTree
(){
27
return
fTreeIn
;
28
}
29
30
Int_t
TreeReader::Event
()
const
{
31
32
return
fEvent
;
33
}
34
35
size_t
TreeReader::NEntries
()
const
{
36
return
fTreeIn
->GetEntries();
37
}
38
39
void
TreeReader::GetEntry
(
const
UInt_t& ientry=0) {
40
if
(ientry !=
fCurrentEntry
) {
41
fCurrentEntry
= ientry;
42
fTreeIn
->GetEntry(ientry);
43
}
44
return
;
45
}
46
47
const
TObjArray*
TreeReader::GetBranchList
()
const
{
48
return
fTreeIn
->GetListOfBranches();
49
}
50
51
void
TreeReader::Fill
() {
52
if
(
BlockWrite
())
53
return
;
54
55
fTreeIn
->Fill();
56
}
57
58
void
TreeReader::Write
(){
59
if
(
BlockWrite
())
60
return
;
61
62
//fTreeIn->GetCurrentFile()->Write();
63
fTreeIn
->Write();
64
}
65
66
//checks read/write option and sets usable value
67
void
TreeReader::CheckOpt
(
char
opt
) {
68
switch
(opt) {
69
case
(
'W'
) :
70
fOpt
=
'w'
;
71
return
;
72
73
case
(
'R'
) :
74
fOpt
=
'r'
;
75
return
;
76
77
case
(
'w'
) :
78
fOpt
=
'w'
;
79
return
;
80
case
(
'r'
) :
81
fOpt
=
'r'
;
82
return
;
83
84
default
:
85
std::cerr <<
"WARNING(TreeReader): Unknown option specified '"
86
<< opt <<
"'. Option should be 'R'/'r' (read-only)"
87
<<
" or 'W'/'w' (write). Setting option to read-only."
88
<<
std::endl
;
89
fOpt
=
'r'
;
90
}
91
}
92
93
bool
TreeReader::BlockWrite
()
const
{
94
if
(
fOpt
!=
'w'
) {
95
std::cerr <<
"WARNING(TreeReader): Write method invoked for read-only accessor - "
96
<<
" ignoring method call..."
<<
std::endl
;
97
return
true
;
98
}
99
return
false
;
100
}
101
102
garana::TreeReader::fCurrentEntry
UInt_t fCurrentEntry
Definition:
TreeReader.h:52
garana
Definition:
FlatDetTree.h:15
train.opt
opt
Definition:
train.py:196
garana::TreeReader::GetInputTree
TTree * GetInputTree()
Definition:
TreeReader.cxx:26
garana::TreeReader::fTreeIn
TTree * fTreeIn
pointer to the analyzed TTree or TChain
Definition:
TreeReader.h:51
garana::TreeReader::CheckOpt
void CheckOpt(char opt)
Definition:
TreeReader.cxx:67
reco_momentum_tuples.t
t
Definition:
reco_momentum_tuples.py:25
garana::TreeReader::Fill
void Fill()
Definition:
TreeReader.cxx:51
garana::TreeReader::BlockWrite
bool BlockWrite() const
Definition:
TreeReader.cxx:93
garana::TreeReader::fOpt
char fOpt
Definition:
TreeReader.h:50
garana::TreeReader::Event
Int_t Event() const
Definition:
TreeReader.cxx:30
garana::TreeReader::SetupRead
void SetupRead(TTree *tree)
Definition:
TreeReader.cxx:6
garana::TreeReader::GetBranchList
const TObjArray * GetBranchList() const
Definition:
TreeReader.cxx:47
TreeReader.h
garana::TreeReader::Write
void Write()
Definition:
TreeReader.cxx:58
garana::TreeReader::SetBranchAddresses
virtual bool SetBranchAddresses()=0
garana::TreeReader::GetEntry
virtual void GetEntry(const UInt_t &ientry)
Definition:
TreeReader.cxx:39
garana::TreeReader::fEvent
Int_t fEvent
event number for tree entry
Definition:
TreeReader.h:55
make_resolution.tree
tree
Definition:
make_resolution.py:22
garana::TreeReader::NEntries
size_t NEntries() const
Definition:
TreeReader.cxx:35
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
Generated by
1.8.11