ATLAS Offline Software
MatrixBranch.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 #ifndef MUONTESTER_MATRIXBRANCH_H
5 #define MUONTESTER_MATRIXBRANCH_H
7 
8 class TTree;
9 
10 namespace MuonVal {
11 class MuonTesterTree;
12 template <class T> class MatrixBranch : public VectorBranch<std::vector<T>> {
13 public:
15  MatrixBranch(TTree* tree, const std::string& name);
16  MatrixBranch(MuonTesterTree& tree, const std::string& name);
17 
19  MatrixBranch(TTree* tree, const std::string& b_name, const T& def);
20  MatrixBranch(MuonTesterTree& tree, const std::string& b_name, const T& def);
21 
22 
23  virtual ~MatrixBranch() = default;
24 
25 
26 
29  using VectorBranch<std::vector<T>>::operator[];
30 
32  inline T& get(size_t i, size_t j);
33 
36  inline void push_back(size_t i, const T& value);
37 
39  inline size_t nrows() const;
41  inline size_t ncols(size_t row) const;
42 
44  inline const T& getDefault() const;
45  void setDefault(const T& def);
46 
47 private:
48  T m_default{};
49 };
50 }
52 #endif
query_example.row
row
Definition: query_example.py:24
MuonVal::IMuonTesterBranch::tree
virtual TTree * tree()=0
Returns the pointer to the underlying TTree object.
MuonVal::MatrixBranch::MatrixBranch
MatrixBranch(MuonTesterTree &tree, const std::string &name)
athena.value
value
Definition: athena.py:124
MuonVal::MatrixBranch::getDefault
const T & getDefault() const
Get the default value to fill the empty fields in the vector.
MuonVal::VectorBranch
Definition: VectorBranch.h:14
MuonVal::MatrixBranch::MatrixBranch
MatrixBranch(TTree *tree, const std::string &name)
Standard constructor.
VectorBranch.h
MuonVal::MatrixBranch::ncols
size_t ncols(size_t row) const
Size of the i-th inner vector.
MuonVal::MatrixBranch::push_back
void push_back(size_t i, const T &value)
MuonVal::MuonTesterTree
Definition: MuonTesterTree.h:30
lumiFormat.i
int i
Definition: lumiFormat.py:85
MuonVal::MatrixBranch::nrows
size_t nrows() const
Size of the outer vector.
MuonVal::MatrixBranch::MatrixBranch
MatrixBranch(TTree *tree, const std::string &b_name, const T &def)
Constructor with default value extending the array.
MatrixBranch.icc
MuonVal
Class to store array like branches into the n-tuples.
Definition: MuonTPMetaDataAlg.cxx:25
MuonVal::MatrixBranch::MatrixBranch
MatrixBranch(MuonTesterTree &tree, const std::string &b_name, const T &def)
MuonVal::IMuonTesterBranch::name
virtual std::string name() const =0
Returns the name of the branch.
MuonVal::MatrixBranch::~MatrixBranch
virtual ~MatrixBranch()=default
MuonVal::MatrixBranch::m_default
T m_default
Definition: MatrixBranch.h:48
MuonVal::MatrixBranch
Definition: MatrixBranch.h:12
MuonVal::MatrixBranch::setDefault
void setDefault(const T &def)
MuonVal::MatrixBranch::get
T & get(size_t i, size_t j)
Returns the j-th element of the i-th inner vector.