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

This class provides a simple interface to write Vectors to a root tree The size of the vectors cannot exceed ROWMAX. More...

#include <VectorNtupleBranch.h>

Collaboration diagram for Trk::VectorNtupleBranch:

Public Member Functions

bool initForWrite (TTree &tree, const std::string &varname, int nrow, const std::string &prefix="")
 initialize class for writing More...
 
bool initForRead (TTree &tree, const std::string &varname, int nrow, const std::string &prefix="")
 initialize class for reading More...
 
bool fill (const Amg::VectorX &matrix)
 fill a vector More...
 
bool fill (const CLHEP::HepVector &vec)
 fill a vector More...
 
bool fill (const CLHEP::Hep3Vector &vec)
 fill a vector More...
 
bool fill (const HepGeom::Point3D< double > &vec)
 fill a vector More...
 
bool fill (const HepGeom::Vector3D< double > &vec)
 fill a vector More...
 

Public Attributes

int m_nrows {-1}
 
float m_vector [ROWMAX] {}
 

Static Public Attributes

static const int ROWMAX = 10
 maximum size of the vector More...
 

Detailed Description

This class provides a simple interface to write Vectors to a root tree The size of the vectors cannot exceed ROWMAX.

The class requires all vectors to have the same size

Usage:

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

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

Definition at line 34 of file VectorNtupleBranch.h.

Member Function Documentation

◆ fill() [1/5]

bool Trk::VectorNtupleBranch::fill ( const Amg::VectorX matrix)

fill a vector

Definition at line 34 of file VectorNtupleBranch.cxx.

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

◆ fill() [2/5]

bool Trk::VectorNtupleBranch::fill ( const CLHEP::Hep3Vector &  vec)

fill a vector

Definition at line 62 of file VectorNtupleBranch.cxx.

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

◆ fill() [3/5]

bool Trk::VectorNtupleBranch::fill ( const CLHEP::HepVector &  vec)

fill a vector

Definition at line 45 of file VectorNtupleBranch.cxx.

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

◆ fill() [4/5]

bool Trk::VectorNtupleBranch::fill ( const HepGeom::Point3D< double > &  vec)

fill a vector

Definition at line 55 of file VectorNtupleBranch.cxx.

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

◆ fill() [5/5]

bool Trk::VectorNtupleBranch::fill ( const HepGeom::Vector3D< double > &  vec)

fill a vector

Definition at line 69 of file VectorNtupleBranch.cxx.

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

◆ initForRead()

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

initialize class for reading

Definition at line 22 of file VectorNtupleBranch.cxx.

22  {
23  if( nrow >= ROWMAX ) return false;
24  m_nrows = nrow;
25  for( int i=0;i<nrow;++i ){
26  TString bname = prefix.c_str();
27  bname += varname;
28  bname += i;
29  tree.SetBranchAddress(bname,&m_vector[i]);
30  }
31  return true;
32  }

◆ initForWrite()

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

initialize class for writing

Definition at line 10 of file VectorNtupleBranch.cxx.

10  {
11  if( nrow >= ROWMAX ) return false;
12  m_nrows = nrow;
13  for( int i=0;i<nrow;++i ){
14  TString bname = prefix.c_str();
15  bname += varname;
16  bname += i;
17  tree.Branch(bname,&m_vector[i]);
18  }
19  return true;
20  }

Member Data Documentation

◆ m_nrows

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

Definition at line 59 of file VectorNtupleBranch.h.

◆ m_vector

float Trk::VectorNtupleBranch::m_vector[ROWMAX] {}

Definition at line 60 of file VectorNtupleBranch.h.

◆ ROWMAX

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

maximum size of the vector

Definition at line 58 of file VectorNtupleBranch.h.


The documentation for this struct was generated from the following files:
Trk::VectorNtupleBranch::ROWMAX
static const int ROWMAX
maximum size of the vector
Definition: VectorNtupleBranch.h:58
tree
TChain * tree
Definition: tile_monitor.h:30
Trk::VectorNtupleBranch::m_nrows
int m_nrows
Definition: VectorNtupleBranch.h:59
lumiFormat.i
int i
Definition: lumiFormat.py:85
vector
Definition: MultiHisto.h:13
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
Trk::VectorNtupleBranch::m_vector
float m_vector[ROWMAX]
Definition: VectorNtupleBranch.h:60
LArG4AODNtuplePlotter.varname
def varname(hname)
Definition: LArG4AODNtuplePlotter.py:37