ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkUtilityPackages
TrkValidationUtils
src
VectorNtupleBranch.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TrkValidationUtils/VectorNtupleBranch.h
"
6
#include <TTree.h>
7
#include <TString.h>
8
9
namespace
Trk
{
10
bool
VectorNtupleBranch::initForWrite
(TTree&
tree
, std::string_view varname,
int
nrow, std::string_view prefix ) {
11
if
( nrow >=
ROWMAX
)
return
false
;
12
m_nrows
= nrow;
13
for
(
int
i=0;i<nrow;++i ){
14
TString bname{prefix.data(),
static_cast<
Ssiz_t
>
(prefix.size())};
15
bname.Append(varname.data(),
static_cast<
Ssiz_t
>
(varname.size()));
16
bname += i;
17
tree
.Branch(bname,&
m_vector
[i]);
18
}
19
return
true
;
20
}
21
22
bool
VectorNtupleBranch::initForRead
(TTree&
tree
, std::string_view varname,
int
nrow, std::string_view prefix ) {
23
if
( nrow >=
ROWMAX
)
return
false
;
24
m_nrows
= nrow;
25
for
(
int
i=0;i<nrow;++i ){
26
TString bname{prefix.data(),
static_cast<
Ssiz_t
>
(prefix.size())};
27
bname.Append(varname.data(),
static_cast<
Ssiz_t
>
(varname.size()));
28
bname += i;
29
tree
.SetBranchAddress(bname,&
m_vector
[i]);
30
}
31
return
true
;
32
}
33
34
bool
VectorNtupleBranch::fill
(
const
Amg::VectorX
&
vector
) {
35
if
(
m_nrows
== -1 )
return
false
;
36
if
(
vector
.rows() >
m_nrows
)
return
false
;
37
38
for
(
int
i=0;i<
m_nrows
;++i ){
39
if
( i <
vector
.rows() )
m_vector
[i] =
vector
[i];
40
else
m_vector
[i] = 0.;
41
}
42
return
true
;
43
}
44
45
bool
VectorNtupleBranch::fill
(
const
CLHEP::HepVector&
vector
) {
46
if
(
m_nrows
== -1 )
return
false
;
47
if
(
vector
.num_row() >
m_nrows
)
return
false
;
48
for
(
int
i=0;i<
m_nrows
;++i ){
49
if
( i <
vector
.num_row() )
m_vector
[i] =
vector
[i];
50
else
m_vector
[i] = 0.;
51
}
52
return
true
;
53
}
54
55
bool
VectorNtupleBranch::fill
(
const
HepGeom::Point3D<double>&
vector
) {
56
if
(
m_nrows
== -1 )
return
false
;
57
if
(
m_nrows
!= 3 )
return
false
;
58
for
(
int
i=0;i<
m_nrows
;++i )
m_vector
[i] =
vector
[i];
59
return
true
;
60
}
61
62
bool
VectorNtupleBranch::fill
(
const
CLHEP::Hep3Vector&
vector
) {
63
if
(
m_nrows
== -1 )
return
false
;
64
if
(
m_nrows
!= 3 )
return
false
;
65
for
(
int
i=0;i<
m_nrows
;++i )
m_vector
[i] =
vector
[i];
66
return
true
;
67
}
68
69
bool
VectorNtupleBranch::fill
(
const
HepGeom::Vector3D<double>&
vector
) {
70
if
(
m_nrows
== -1 )
return
false
;
71
if
(
m_nrows
!= 3 )
return
false
;
72
for
(
int
i=0;i<
m_nrows
;++i )
m_vector
[i] =
vector
[i];
73
return
true
;
74
}
75
76
}
VectorNtupleBranch.h
vector
Definition
MultiHisto.h:13
Amg::VectorX
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
Definition
EventPrimitives.h:30
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition
FakeTrackBuilder.h:9
Trk::VectorNtupleBranch::m_vector
float m_vector[ROWMAX]
Definition
VectorNtupleBranch.h:60
Trk::VectorNtupleBranch::ROWMAX
static const int ROWMAX
maximum size of the vector
Definition
VectorNtupleBranch.h:58
Trk::VectorNtupleBranch::initForRead
bool initForRead(TTree &tree, std::string_view varname, int nrow, std::string_view prefix="")
initialize class for reading
Definition
VectorNtupleBranch.cxx:22
Trk::VectorNtupleBranch::initForWrite
bool initForWrite(TTree &tree, std::string_view varname, int nrow, std::string_view prefix="")
initialize class for writing
Definition
VectorNtupleBranch.cxx:10
Trk::VectorNtupleBranch::fill
bool fill(const Amg::VectorX &matrix)
fill a vector
Definition
VectorNtupleBranch.cxx:34
Trk::VectorNtupleBranch::m_nrows
int m_nrows
Definition
VectorNtupleBranch.h:59
tree
TChain * tree
Definition
tile_monitor.h:30
Generated on
for ATLAS Offline Software by
1.17.0