ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkUtilityPackages
TrkValidationUtils
src
MatrixNtupleBranch.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/MatrixNtupleBranch.h
"
6
#include <TTree.h>
7
#include <TString.h>
8
9
namespace
Trk
{
10
bool
MatrixNtupleBranch::initForWrite
(TTree&
tree
,
const
std::string_view varname,
int
ncol,
int
nrow, std::string_view prefix ) {
11
if
( ncol >=
COLMAX
)
return
false
;
12
if
( nrow >=
ROWMAX
)
return
false
;
13
m_ncols
= ncol;
14
m_nrows
= nrow;
15
for
(
int
i=0;i<nrow;++i ){
16
for
(
int
j=0;j<ncol;++j ){
17
TString bname{prefix.data(),
static_cast<
Ssiz_t
>
(prefix.size())};
18
bname.Append(varname.data(),
static_cast<
Ssiz_t
>
(varname.size()));
19
bname += i;
20
bname += j;
21
tree
.Branch(bname,&
m_matrix
[i][j]);
22
}
23
}
24
return
true
;
25
}
26
27
bool
MatrixNtupleBranch::initForRead
(TTree&
tree
, std::string_view varname,
int
ncol,
int
nrow, std::string_view prefix ) {
28
if
( ncol >=
COLMAX
)
return
false
;
29
if
( nrow >=
ROWMAX
)
return
false
;
30
m_ncols
= ncol;
31
m_nrows
= nrow;
32
for
(
int
i=0;i<nrow;++i ){
33
for
(
int
j=0;j<ncol;++j ){
34
TString bname{prefix.data(),
static_cast<
Ssiz_t
>
(prefix.size())};
35
bname.Append(varname.data(),
static_cast<
Ssiz_t
>
(varname.size()));
36
bname += i;
37
bname += j;
38
tree
.SetBranchAddress(bname,&
m_matrix
[i][j]);
39
}
40
}
41
return
true
;
42
}
43
44
bool
MatrixNtupleBranch::fill
(
const
Amg::MatrixX
& matrix ) {
45
if
(
m_ncols
== -1 )
return
false
;
46
if
( matrix.rows() >
m_nrows
&& matrix.cols() >
m_ncols
)
return
false
;
47
48
for
(
int
i=0;i<
m_nrows
;++i ){
49
for
(
int
j=0;j<
m_ncols
;++j ){
50
if
( i < matrix.rows() && j < matrix.cols() )
m_matrix
[i][j] = matrix(i,j);
51
else
m_matrix
[i][j] = 0.;
52
}
53
}
54
return
true
;
55
}
56
57
bool
MatrixNtupleBranch::fill
(
const
HepGeom::Rotate3D& matrix ) {
58
if
(
m_ncols
== -1 )
return
false
;
59
if
(
m_nrows
!= 3 &&
m_ncols
!= 3 )
return
false
;
60
61
for
(
int
i=0;i<
m_nrows
;++i ){
62
for
(
int
j=0;j<
m_ncols
;++j ){
63
if
( i < 3 && j < 3 )
m_matrix
[i][j] = matrix(i,j);
64
else
m_matrix
[i][j] = 0.;
65
}
66
}
67
return
true
;
68
}
69
70
}
MatrixNtupleBranch.h
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition
EventPrimitives.h:27
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition
FakeTrackBuilder.h:9
Trk::MatrixNtupleBranch::ROWMAX
static const int ROWMAX
Definition
MatrixNtupleBranch.h:49
Trk::MatrixNtupleBranch::initForRead
bool initForRead(TTree &tree, std::string_view varname, int ncol, int nrow, std::string_view prefix="")
initialize class for reading
Definition
MatrixNtupleBranch.cxx:27
Trk::MatrixNtupleBranch::fill
bool fill(const Amg::MatrixX &matrix)
fill a vector
Definition
MatrixNtupleBranch.cxx:44
Trk::MatrixNtupleBranch::COLMAX
static const int COLMAX
data
Definition
MatrixNtupleBranch.h:48
Trk::MatrixNtupleBranch::initForWrite
bool initForWrite(TTree &tree, std::string_view varname, int ncol, int nrow, std::string_view prefix="")
initialize class for writing
Definition
MatrixNtupleBranch.cxx:10
Trk::MatrixNtupleBranch::m_ncols
int m_ncols
Definition
MatrixNtupleBranch.h:51
Trk::MatrixNtupleBranch::m_nrows
int m_nrows
Definition
MatrixNtupleBranch.h:50
Trk::MatrixNtupleBranch::m_matrix
float m_matrix[COLMAX][ROWMAX]
Definition
MatrixNtupleBranch.h:52
tree
TChain * tree
Definition
tile_monitor.h:30
Generated on
for ATLAS Offline Software by
1.17.0