Belle II Software  release-08-01-10
HMatrixUV.cc
1 /* Copyright 2013, Technische Universitaet Muenchen, Ludwig-Maximilians-Universität München
2  Authors: Johannes Rauch, Tobias Schlüter
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #include "HMatrixUV.h"
21 
22 #include "IO.h"
23 
24 #include <cassert>
25 #include <alloca.h>
26 
27 namespace genfit {
28 
29 
30 // 0, 0, 0, 1, 0
31 // 0, 0, 0, 0, 1
32 
33 const TMatrixD& HMatrixUV::getMatrix() const {
34  static const double HMatrixContent[2*5] = {0, 0, 0, 1, 0,
35  0, 0, 0, 0, 1};
36 
37  static const TMatrixD HMatrix(2,5, HMatrixContent);
38 
39  return HMatrix;
40 }
41 
42 
43 TVectorD HMatrixUV::Hv(const TVectorD& v) const {
44  assert (v.GetNrows() == 5);
45 
46  double* retValArray =(double *)alloca(sizeof(double) * 2);
47  const double* VecArray = v.GetMatrixArray();
48 
49  retValArray[0] = VecArray[3]; // u
50  retValArray[1] = VecArray[4]; // v
51 
52  return TVectorD(2, retValArray);
53 }
54 
55 
56 TMatrixD HMatrixUV::MHt(const TMatrixDSym& M) const {
57  assert (M.GetNcols() == 5);
58 
59  double* retValArray =(double *)alloca(sizeof(double) * 5*2);
60  const double* MatArray = M.GetMatrixArray();
61 
62  for (unsigned int i=0; i<5; ++i) {
63  retValArray[i*2] = MatArray[i*5 + 3];
64  retValArray[i*2 + 1] = MatArray[i*5 + 4];
65  }
66 
67  return TMatrixD(5,2, retValArray);
68 }
69 
70 
71 TMatrixD HMatrixUV::MHt(const TMatrixD& M) const {
72  assert (M.GetNcols() == 5);
73 
74  double* retValArray =(double *)alloca(sizeof(double) * M.GetNrows()*2);
75  const double* MatArray = M.GetMatrixArray();
76 
77  for (int i = 0; i < M.GetNrows(); ++i) {
78  retValArray[i*2] = MatArray[i*5 + 3];
79  retValArray[i*2 + 1] = MatArray[i*5 + 4];
80  }
81 
82  return TMatrixD(M.GetNrows(),2, retValArray);
83 }
84 
85 
86 void HMatrixUV::HMHt(TMatrixDSym& M) const {
87  assert (M.GetNrows() == 5);
88  double* MatArray = M.GetMatrixArray();
89 
90  //
91  // HMH^t = ( M_33 M_34 ) where M_34 == M_43
92  // ( M_43 M_44 )
93  //
94  double uu = MatArray[3*5 + 3];
95  double uv = MatArray[3*5 + 4];
96  double vv = MatArray[4*5 + 4];
97 
98  M.ResizeTo(2,2);
99  MatArray = M.GetMatrixArray();
100  MatArray[0] = uu; MatArray[1] = uv;
101  MatArray[2] = uv; MatArray[3] = vv;
102 }
103 
104 
105 void HMatrixUV::Print(const Option_t*) const {
106  printOut << "UV" << std::endl;
107 }
108 
109 
110 } /* End of namespace genfit */
TMatrixD MHt(const TMatrixDSym &M) const override
M*H^t.
Definition: HMatrixUV.cc:56
void HMHt(TMatrixDSym &M) const override
similarity: H*M*H^t
Definition: HMatrixUV.cc:86
const TMatrixD & getMatrix() const override
Get the actual matrix representation.
Definition: HMatrixUV.cc:33
TVectorD Hv(const TVectorD &v) const override
H*v.
Definition: HMatrixUV.cc:43
Defines for I/O streams used for error and debug printing.
std::ostream printOut
Default stream for output of Print calls.