Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
garana
garana
Accessors
HeaderTree.cxx
Go to the documentation of this file.
1
/*
2
* HeaderTree.cxx
3
*
4
* Created on: Feb 9, 2021
5
* Author: chilgenb
6
*/
7
8
#include "
garana/Accessors/HeaderTree.h
"
9
10
using namespace
garana
;
11
12
HeaderTree::HeaderTree
(){}
13
HeaderTree::HeaderTree
(TTree*
tree
)
14
{
15
SetupRead
(tree);
16
}
17
18
HeaderTree::HeaderTree
(TTree*
tree
,
char
opt
)
19
{
20
CheckOpt
(opt);
//sets TreeReader::fOpt
21
22
if
(
fOpt
==
'r'
){
23
SetupRead
(tree);
24
}
25
else
{
26
fTreeIn
=
tree
;
27
SetBranchAddresses
();
28
}
29
}
//
30
31
32
const
std::string
*
const
HeaderTree::TreeType
()
const
{
33
34
fTreeIn
->GetEntry(0);
35
//std::cout << "trying tree type, " << fTreeType << std::endl;
36
try
{
37
38
if
(
fTreeTypePtr
->compare(
"structured"
)!=0 &&
fTreeTypePtr
->compare(
"flat"
)!=0)
39
throw
fTreeTypePtr
;
40
41
}
42
catch
(
std::string
*
type
){
43
std::cerr <<
"HeaderTree::TreeType: tree type is not set."
<<
'\n'
;
44
}
45
46
return
fTreeTypePtr
;
47
}
48
49
50
Int_t
const
&
HeaderTree::Run
()
const
{
51
fTreeIn
->GetEntry(0);
52
return
fRun
;
53
}
54
55
Int_t
const
&
HeaderTree::SubRun
()
const
{
56
fTreeIn
->GetEntry(0);
57
return
fSubRun
;
58
}
59
60
Int_t
const
&
HeaderTree::POT
()
const
{
61
fTreeIn
->GetEntry(0);
62
return
fPOT
;
63
}
64
65
Int_t
const
&
HeaderTree::NSpills
()
const
{
66
fTreeIn
->GetEntry(0);
67
return
fNSpills
;
68
}
69
70
std::string
const
&
HeaderTree::Geometry
()
const
{
71
fTreeIn
->GetEntry(0);
72
return
fGeometry
;
73
}
74
75
TLorentzVector*
const
&
HeaderTree::TpcCenter
()
const
{
76
fTreeIn
->GetEntry(0);
77
return
fTpcCenter
;
78
}
79
80
bool
HeaderTree::SetBranchAddresses
(){
81
82
if
(
fOpt
==
'r'
){
83
fTreeIn
->SetBranchAddress(
"Run"
, &
fRun
, &
b_Run
);
84
fTreeIn
->SetBranchAddress(
"SubRun"
, &
fSubRun
, &
b_SubRun
);
85
fTreeIn
->SetBranchAddress(
"TreeType"
, &
fTreeTypePtr
, &
b_TreeType
);
86
fTreeIn
->SetBranchAddress(
"POT"
, &
fPOT
, &
b_POT
);
87
fTreeIn
->SetBranchAddress(
"NSpills"
, &
fNSpills
, &
b_NSpills
);
88
fTreeIn
->SetBranchAddress(
"Geometry"
, &
fGeometryPtr
, &
b_Geometry
);
89
fTreeIn
->SetBranchAddress(
"TpcCenter"
, &
fTpcCenter
, &
b_TpcCenter
);
90
}
91
92
if
(
fOpt
==
'w'
){
93
fTreeIn
->Branch(
"Run"
, &
fRun
,
"Run/I"
);
94
fTreeIn
->Branch(
"SubRun"
, &
fSubRun
,
"SubRun/I"
);
95
fTreeIn
->Branch(
"TreeType"
, &
fTreeType
);
96
fTreeIn
->Branch(
"POT"
, &
fPOT
,
"POT/I"
);
97
fTreeIn
->Branch(
"NSpills"
, &
fNSpills
,
"NSpills/I"
);
98
fTreeIn
->Branch(
"Geometry"
, &
fGeometry
);
99
fTreeIn
->Branch(
"TpcCenter"
, &
fTpcCenter
);
100
}
101
102
return
true
;
103
}
104
105
void
HeaderTree::SetRun
(
const
Int_t
run
) {
106
std::cout <<
"SetRun called"
<<
std::endl
;
107
if
(
BlockWrite
())
108
return
;
109
110
fRun
=
run
;
111
std::cout <<
"set run = "
<<
fRun
<<
std::endl
;
112
}
113
114
void
HeaderTree::SetSubRun
(
const
Int_t subrun) {
115
if
(
BlockWrite
())
116
return
;
117
fSubRun
= subrun;
118
}
119
120
void
HeaderTree::SetTreeType
(
std::string
type
) {
121
if
(
BlockWrite
())
122
return
;
123
fTreeType
=
type
;
124
fTreeTypePtr
= &
fTreeType
;
125
}
126
127
//TODO implement other setters
garana::HeaderTree::Geometry
std::string const & Geometry() const
Definition:
HeaderTree.cxx:70
HeaderTree.h
garana::HeaderTree::TpcCenter
TLorentzVector *const & TpcCenter() const
Definition:
HeaderTree.cxx:75
garana::HeaderTree::fNSpills
Int_t fNSpills
Definition:
HeaderTree.h:43
garana::HeaderTree::SubRun
Int_t const & SubRun() const
Definition:
HeaderTree.cxx:55
garana::HeaderTree::b_TreeType
TBranch * b_TreeType
Definition:
HeaderTree.h:53
garana
Definition:
FlatDetTree.h:15
string
std::string string
Definition:
nybbler.cc:12
train.opt
opt
Definition:
train.py:196
garana::HeaderTree::SetSubRun
void SetSubRun(const Int_t subrun)
Definition:
HeaderTree.cxx:114
garana::HeaderTree::fSubRun
Int_t fSubRun
Definition:
HeaderTree.h:41
garana::TreeReader::fTreeIn
TTree * fTreeIn
pointer to the analyzed TTree or TChain
Definition:
TreeReader.h:51
garana::HeaderTree::b_Run
TBranch * b_Run
Definition:
HeaderTree.h:51
garana::HeaderTree::POT
Int_t const & POT() const
Definition:
HeaderTree.cxx:60
garana::HeaderTree::fGeometry
std::string fGeometry
Definition:
HeaderTree.h:45
filelisting.run
int run
Definition:
filelisting.py:13
garana::HeaderTree::SetBranchAddresses
bool SetBranchAddresses() override
Definition:
HeaderTree.cxx:80
garana::TreeReader::CheckOpt
void CheckOpt(char opt)
Definition:
TreeReader.cxx:67
garana::HeaderTree::fTpcCenter
TLorentzVector * fTpcCenter
Definition:
HeaderTree.h:44
garana::HeaderTree::NSpills
Int_t const & NSpills() const
Definition:
HeaderTree.cxx:65
garana::HeaderTree::TreeType
const std::string *const TreeType() const
Definition:
HeaderTree.cxx:32
type
Definition:
ShowerProducedPtrsHolder.hh:36
garana::HeaderTree::b_NSpills
TBranch * b_NSpills
Definition:
HeaderTree.h:56
garana::HeaderTree::b_Geometry
TBranch * b_Geometry
Definition:
HeaderTree.h:57
garana::HeaderTree::HeaderTree
HeaderTree()
Definition:
HeaderTree.cxx:12
garana::HeaderTree::fGeometryPtr
std::string * fGeometryPtr
Definition:
HeaderTree.h:48
garana::HeaderTree::b_POT
TBranch * b_POT
Definition:
HeaderTree.h:55
garana::HeaderTree::fTreeTypePtr
std::string * fTreeTypePtr
Definition:
HeaderTree.h:47
garana::HeaderTree::fRun
Int_t fRun
Definition:
HeaderTree.h:40
garana::HeaderTree::fPOT
Int_t fPOT
Definition:
HeaderTree.h:42
garana::TreeReader::BlockWrite
bool BlockWrite() const
Definition:
TreeReader.cxx:93
garana::HeaderTree::fTreeType
std::string fTreeType
Definition:
HeaderTree.h:46
garana::TreeReader::fOpt
char fOpt
Definition:
TreeReader.h:50
garana::TreeReader::SetupRead
void SetupRead(TTree *tree)
Definition:
TreeReader.cxx:6
garana::HeaderTree::Run
Int_t const & Run() const
Definition:
HeaderTree.cxx:50
type
static QCString type
Definition:
declinfo.cpp:672
garana::HeaderTree::SetRun
void SetRun(const Int_t run)
Definition:
HeaderTree.cxx:105
garana::HeaderTree::SetTreeType
void SetTreeType(std::string type)
Definition:
HeaderTree.cxx:120
garana::HeaderTree::b_SubRun
TBranch * b_SubRun
Definition:
HeaderTree.h:52
garana::HeaderTree::b_TpcCenter
TBranch * b_TpcCenter
Definition:
HeaderTree.h:54
make_resolution.tree
tree
Definition:
make_resolution.py:22
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
Generated by
1.8.11