ATLAS Offline Software
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
Trk::MatrixNtupleBranch Struct Reference

This class provides a simple interface to write Matricis to a root tree The size of the Matrix cannot exceed COLMAX x ROWMAX. More...

#include <MatrixNtupleBranch.h>

Collaboration diagram for Trk::MatrixNtupleBranch:

Public Member Functions

bool initForWrite (TTree &tree, const std::string &varname, int ncol, int nrow, const std::string &prefix="")
 initialize class for writing More...
 
bool initForRead (TTree &tree, const std::string &varname, int ncol, int nrow, const std::string &prefix="")
 initialize class for reading More...
 
bool fill (const Amg::MatrixX &matrix)
 fill a vector More...
 
bool fill (const HepGeom::Rotate3D &matrix)
 fill a vector More...
 

Public Attributes

int m_nrows {-1}
 
int m_ncols {-1}
 
float m_matrix [COLMAX][ROWMAX] {}
 

Static Public Attributes

static const int COLMAX = 10
 data More...
 
static const int ROWMAX = 10
 

Detailed Description

This class provides a simple interface to write Matricis to a root tree The size of the Matrix cannot exceed COLMAX x ROWMAX.

The class requires all matrices to have the same size

Usage:

TTree* myTree = new TTree("data","data"); MatrixNtupleBranch branch; branch.initForWrite(*myTree,"vec",3,"");

for(int i=0;i<n;++i){ branch.fill( ); myTree->Fill(); }

Definition at line 33 of file MatrixNtupleBranch.h.

Member Function Documentation

◆ fill() [1/2]

bool Trk::MatrixNtupleBranch::fill ( const Amg::MatrixX matrix)

fill a vector

Definition at line 44 of file MatrixNtupleBranch.cxx.

44  {
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  }

◆ fill() [2/2]

bool Trk::MatrixNtupleBranch::fill ( const HepGeom::Rotate3D &  matrix)

fill a vector

Definition at line 57 of file MatrixNtupleBranch.cxx.

57  {
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  }

◆ initForRead()

bool Trk::MatrixNtupleBranch::initForRead ( TTree &  tree,
const std::string &  varname,
int  ncol,
int  nrow,
const std::string &  prefix = "" 
)

initialize class for reading

Definition at line 27 of file MatrixNtupleBranch.cxx.

27  {
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.c_str();
35  bname += varname;
36  bname += i;
37  bname += j;
38  tree.SetBranchAddress(bname,&m_matrix[i][j]);
39  }
40  }
41  return true;
42  }

◆ initForWrite()

bool Trk::MatrixNtupleBranch::initForWrite ( TTree &  tree,
const std::string &  varname,
int  ncol,
int  nrow,
const std::string &  prefix = "" 
)

initialize class for writing

Definition at line 10 of file MatrixNtupleBranch.cxx.

10  {
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.c_str();
18  bname += varname;
19  bname += i;
20  bname += j;
21  tree.Branch(bname,&m_matrix[i][j]);
22  }
23  }
24  return true;
25  }

Member Data Documentation

◆ COLMAX

const int Trk::MatrixNtupleBranch::COLMAX = 10
static

data

Definition at line 48 of file MatrixNtupleBranch.h.

◆ m_matrix

float Trk::MatrixNtupleBranch::m_matrix[COLMAX][ROWMAX] {}

Definition at line 52 of file MatrixNtupleBranch.h.

◆ m_ncols

int Trk::MatrixNtupleBranch::m_ncols {-1}

Definition at line 51 of file MatrixNtupleBranch.h.

◆ m_nrows

int Trk::MatrixNtupleBranch::m_nrows {-1}

Definition at line 50 of file MatrixNtupleBranch.h.

◆ ROWMAX

const int Trk::MatrixNtupleBranch::ROWMAX = 10
static

Definition at line 49 of file MatrixNtupleBranch.h.


The documentation for this struct was generated from the following files:
Trk::MatrixNtupleBranch::COLMAX
static const int COLMAX
data
Definition: MatrixNtupleBranch.h:48
tree
TChain * tree
Definition: tile_monitor.h:30
Trk::MatrixNtupleBranch::m_ncols
int m_ncols
Definition: MatrixNtupleBranch.h:51
Trk::MatrixNtupleBranch::ROWMAX
static const int ROWMAX
Definition: MatrixNtupleBranch.h:49
Trk::MatrixNtupleBranch::m_matrix
float m_matrix[COLMAX][ROWMAX]
Definition: MatrixNtupleBranch.h:52
lumiFormat.i
int i
Definition: lumiFormat.py:92
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
python.testIfMatch.matrix
matrix
Definition: testIfMatch.py:66
LArG4AODNtuplePlotter.varname
def varname(hname)
Definition: LArG4AODNtuplePlotter.py:37
Trk::MatrixNtupleBranch::m_nrows
int m_nrows
Definition: MatrixNtupleBranch.h:50