ATLAS Offline Software
MatrixBranch.icc
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_MUONSMATRIXBRANCH_IXX
5 #define MUONTESTER_MUONSMATRIXBRANCH_IXX
6 
7 namespace MuonVal {
8 
9 
10 template <class T> MatrixBranch<T>::MatrixBranch(TTree* tree, const std::string& name) :
11  VectorBranch<std::vector<T>>(tree, name) {}
12 template <class T> MatrixBranch<T>::MatrixBranch(TTree* tree, const std::string& b_name, const T& def) :
13  MatrixBranch<T>(tree, b_name) {
14  setDefault(def);
15 }
16 template <class T> MatrixBranch<T>::MatrixBranch(MuonTesterTree& parent, const std::string& name) :
17  VectorBranch<std::vector<T>>{parent, name} {}
18 template <class T>
19 MatrixBranch<T>::MatrixBranch(MuonTesterTree& tree, const std::string& b_name, const T& def) :
20  MatrixBranch<T>(tree, b_name) {
21  setDefault(def);
22 }
23 template <class T> void MatrixBranch<T>::push_back(size_t i, const T& value) {
24  get(i).push_back(value); }
25 template <class T> T& MatrixBranch<T>::get(size_t i, size_t j) {
26 
27  if (get(i).size() <= j) {
28  for (size_t k = get(i).size(); k <= j; ++k) { get(i).push_back(getDefault()); }
29  }
30  return get(i)[j];
31 }
32 template <class T> size_t MatrixBranch<T>::nrows() const { return VectorBranch<std::vector<T>>::size(); }
33 template <class T> size_t MatrixBranch<T>::ncols(size_t row) const {
34  if (row >= nrows()) { return 0; }
35  return get(row).size();
36 }
37 template <class T> const T& MatrixBranch<T>::getDefault() const { return m_default; }
38 template <class T> void MatrixBranch<T>::setDefault(const T& def) { m_default = def; }
39 
40 }
41 #endif