ATLAS Offline Software
AlSymMatBase.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRKALGS_ALSYMMATBASE_H
6 #define TRKALGS_ALSYMMATBASE_H
7 
8 // AlSymMatBase.h - Base implementation of generic matrices for alignment
9 // modified from SiGlobalChi2AlgebrUtils::AlSymMatBase, modified to make
10 // pure virtual
11 
12 #include <exception>
13 #include <map>
14 #include <vector>
15 
16 class StatusCode;
17 template<class Element> class TMatrixTSparse;
18 typedef class TMatrixTSparse<double> TMatrixDSparse;
19 
20 namespace Trk {
21 
22 class AlVec;
23 class AlMat;
24 class AlSpaMat;
25 
26 // definition of custom types used:
27 typedef std::pair<long int, long int> indices;
28 typedef std::map<indices, double> datamap;
30 typedef datamap::const_iterator const_mapiterator;
31 
37 class AlSymMatBase {
40 
41  public:
42  virtual ~AlSymMatBase();
43 
45  public:
46  inline AlSymMatBase_row(AlSymMatBase&,long int);
47  double & operator[](long int);
48  private:
50  long int m_r;
51  };
52 
54  public:
55  inline AlSymMatBase_row_const(const AlSymMatBase&,long int);
56  double operator[](long int) const;
57  private:
58  const AlSymMatBase& m_a;
59  long int m_r;
60  };
61  // helper class to implement m[i][j]
62 
63  inline AlSymMatBase_row operator[] (long int);
64  inline AlSymMatBase_row_const operator[] (long int) const;
65 
66  inline long int nrow() const;
67  inline long int ncol() const;
68  inline long int size() const;
69 
70  inline int matrix_type() const;
71 
72  // pure virtual:
73  virtual void reSize(long int Nnew)=0;
74  virtual double& elemr(long int, long int)=0;
75  virtual double elemc(long int, long int) const=0;
76  virtual int invert() = 0;
77  virtual void RemoveModule(int) = 0;
78  virtual void RemoveAlignPar(int, int) = 0;
79  virtual int RemoveCollsRows(std::vector<int>) = 0;
80  virtual void SetPathBin(const std::string&) = 0;
81  virtual void SetPathTxt(const std::string&) = 0;
82  virtual StatusCode Write(const std::string&, bool, bool, double, float) = 0;
83  virtual StatusCode CheckMatVersion(const std::string&, bool&) = 0;
84  virtual StatusCode Read(const std::string&, int&, bool&, float&) = 0;
85  virtual StatusCode ReadProjected(const std::string&, int&, bool&, float&) = 0;
86  virtual int diagonalize(char jobz, AlVec& w, AlMat& z) = 0;
87  virtual double determinant() = 0;
88 
89  inline const datamap * ptrMap() const;
90 
91  virtual TMatrixDSparse* makeTMatrix() =0;
92 
93 
94  protected:
95  AlSymMatBase(); // ensure only create derived classes
96  AlSymMatBase(long int N);
97  AlSymMatBase(const AlSymMatBase&);
99 
100  int m_matrix_type = 0;
102 
103  long int m_size = 0;
104  long int m_nele = 0;
105 };
106 
107 // inline operators
108 
110  AlSymMatBase_row b(*this,r);
111  return b;
112 }
113 
115  const AlSymMatBase_row_const b(*this,r);
116  return b;
117 }
118 
120  if(m_r<0||m_r>=m_a.nrow() || c<0||c>=m_a.ncol()) {
121  throw std::out_of_range( "Range error in AlSymMatBase::operator[][]" );
122  } else {
123  return m_a.elemr(m_r,c);
124  }
125 }
126 
128  if(m_r<0||m_r>=m_a.nrow() || c<0||c>=m_a.ncol()) {
129  throw std::out_of_range( "Range error in AlSymMatBase::operator[][]" );
130  } else {
131  return m_a.elemc(m_r,c);
132  }
133 }
134 
136  : m_a(a), m_r(r)
137 {}
138 
140 (const AlSymMatBase&a,long int r)
141  : m_a(a), m_r(r)
142 {}
143 
144 
145 inline long int AlSymMatBase::size() const { return m_size; }
146 inline long int AlSymMatBase::nrow() const { return m_size; }
147 inline long int AlSymMatBase::ncol() const { return m_size; }
148 inline int AlSymMatBase::matrix_type() const { return m_matrix_type; }
149 inline const datamap * AlSymMatBase::ptrMap() const { return &m_ptr_map; }
150 
151 } // end namespace Trk
152 
153 #endif // TRKALGS_ALSYMMATBASE_H
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
beamspotman.r
def r
Definition: beamspotman.py:676
Trk::AlSymMatBase::diagonalize
virtual int diagonalize(char jobz, AlVec &w, AlMat &z)=0
Trk::AlSymMatBase::nrow
long int nrow() const
Definition: AlSymMatBase.h:146
Trk::const_mapiterator
datamap::const_iterator const_mapiterator
Definition: AlSymMatBase.h:30
Trk::AlSymMatBase::RemoveAlignPar
virtual void RemoveAlignPar(int, int)=0
Trk::AlSymMatBase::determinant
virtual double determinant()=0
Trk::AlSymMatBase::CheckMatVersion
virtual StatusCode CheckMatVersion(const std::string &, bool &)=0
Trk::z
@ z
global position (cartesian)
Definition: ParamDefs.h:57
Trk::AlVec
Definition: AlVec.h:23
Trk::AlSymMatBase
Definition: AlSymMatBase.h:38
Trk::AlSymMatBase::invert
virtual int invert()=0
Trk::datamap
std::map< indices, double > datamap
Definition: AlSymMatBase.h:28
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
Trk::AlSymMatBase::reSize
virtual void reSize(long int Nnew)=0
Trk::AlSymMatBase::m_ptr_map
datamap m_ptr_map
Definition: AlSymMatBase.h:101
Trk::AlSymMatBase::SetPathTxt
virtual void SetPathTxt(const std::string &)=0
Trk::AlSymMatBase::RemoveCollsRows
virtual int RemoveCollsRows(std::vector< int >)=0
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
Trk::AlSymMatBase::AlSymMatBase
AlSymMatBase()
Definition: AlSymMatBase.cxx:20
Trk::AlSymMatBase::ptrMap
const datamap * ptrMap() const
Definition: AlSymMatBase.h:149
TMatrixDSparse
class TMatrixTSparse< double > TMatrixDSparse
Definition: AlSpaMat.h:14
Trk::AlSymMatBase::elemc
virtual double elemc(long int, long int) const =0
Trk::AlSymMatBase::size
long int size() const
Definition: AlSymMatBase.h:145
Trk::AlSymMatBase::AlSymMatBase_row_const::m_a
const AlSymMatBase & m_a
Definition: AlSymMatBase.h:58
Trk::AlSymMatBase::makeTMatrix
virtual TMatrixDSparse * makeTMatrix()=0
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::AlSymMatBase::operator=
AlSymMatBase & operator=(const AlSymMatBase &)
Definition: AlSymMatBase.cxx:46
Trk::AlMat
Definition: AlMat.h:27
Trk::AlSymMatBase::ReadProjected
virtual StatusCode ReadProjected(const std::string &, int &, bool &, float &)=0
Trk::AlSymMatBase::Write
virtual StatusCode Write(const std::string &, bool, bool, double, float)=0
Trk::AlSymMatBase::m_nele
long int m_nele
Definition: AlSymMatBase.h:104
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
Trk::AlSymMatBase::AlSymMatBase_row::m_r
long int m_r
Definition: AlSymMatBase.h:50
Trk::AlSymMatBase::RemoveModule
virtual void RemoveModule(int)=0
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::AlSymMatBase::AlSymMatBase_row
Definition: AlSymMatBase.h:44
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
Trk::AlSymMatBase::ncol
long int ncol() const
Definition: AlSymMatBase.h:147
Trk::AlSymMatBase::AlSymMatBase_row::AlSymMatBase_row
AlSymMatBase_row(AlSymMatBase &, long int)
Definition: AlSymMatBase.h:135
Trk::AlSymMatBase::operator[]
AlSymMatBase_row operator[](long int)
Definition: AlSymMatBase.h:109
Trk::mapiterator
datamap::iterator mapiterator
Definition: AlSymMatBase.h:29
TMatrixTSparse
Definition: AlSpaMat.h:13
Trk::AlSymMatBase::AlSymMatBase_row_const::operator[]
double operator[](long int) const
Definition: AlSymMatBase.h:127
a
TList * a
Definition: liststreamerinfos.cxx:10
Trk::AlSymMatBase::SetPathBin
virtual void SetPathBin(const std::string &)=0
Trk::AlSymMatBase::AlSymMatBase_row_const::m_r
long int m_r
Definition: AlSymMatBase.h:59
Trk::AlSymMatBase::AlSymMatBase_row_const::AlSymMatBase_row_const
AlSymMatBase_row_const(const AlSymMatBase &, long int)
Definition: AlSymMatBase.h:140
Trk::AlSymMatBase::elemr
virtual double & elemr(long int, long int)=0
Trk::AlSymMatBase::AlSymMatBase_row::m_a
AlSymMatBase & m_a
Definition: AlSymMatBase.h:49
Trk::AlSymMatBase::~AlSymMatBase
virtual ~AlSymMatBase()
Definition: AlSymMatBase.cxx:57
Trk::AlSymMatBase::AlSymMatBase_row_const
Definition: AlSymMatBase.h:53
Trk::AlSymMatBase::m_matrix_type
int m_matrix_type
Definition: AlSymMatBase.h:100
Trk::AlSymMatBase::AlSymMatBase_row::operator[]
double & operator[](long int)
Definition: AlSymMatBase.h:119
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
Trk::AlSymMatBase::m_size
long int m_size
Definition: AlSymMatBase.h:103
python.compressB64.c
def c
Definition: compressB64.py:93
Trk::AlSymMatBase::matrix_type
int matrix_type() const
Definition: AlSymMatBase.h:148
Trk::AlSymMatBase::Read
virtual StatusCode Read(const std::string &, int &, bool &, float &)=0