Belle II Software  release-08-01-10
HMatrixV.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 "HMatrixV.h"
21 
22 #include "IO.h"
23 
24 #include <cassert>
25 #include <alloca.h>
26 
27 namespace genfit {
28 
29 
30 // 0, 0, 0, 0, 1
31 
32 const TMatrixD& HMatrixV::getMatrix() const {
33  static const double HMatrixContent[5] = {0, 0, 0, 0, 1};
34 
35  static const TMatrixD HMatrix(1,5, HMatrixContent);
36 
37  return HMatrix;
38 }
39 
40 
41 TVectorD HMatrixV::Hv(const TVectorD& v) const {
42  assert (v.GetNrows() == 5);
43 
44  double* retValArray =(double *)alloca(sizeof(double) * 1);
45 
46  retValArray[0] = v(4); // v
47 
48  return TVectorD(1, retValArray);
49 }
50 
51 
52 TMatrixD HMatrixV::MHt(const TMatrixDSym& M) const {
53  assert (M.GetNcols() == 5);
54 
55  double* retValArray =(double *)alloca(sizeof(double) * 5);
56  const double* MatArray = M.GetMatrixArray();
57 
58  for (unsigned int i=0; i<5; ++i) {
59  retValArray[i] = MatArray[i*5 + 4];
60  }
61 
62  return TMatrixD(5,1, retValArray);
63 }
64 
65 
66 TMatrixD HMatrixV::MHt(const TMatrixD& M) const {
67  assert (M.GetNcols() == 5);
68 
69  double* retValArray =(double *)alloca(sizeof(double) * M.GetNrows());
70  const double* MatArray = M.GetMatrixArray();
71 
72  for (int i = 0; i < M.GetNrows(); ++i) {
73  retValArray[i] = MatArray[i*5 + 4];
74  }
75 
76  return TMatrixD(M.GetNrows(),1, retValArray);
77 }
78 
79 
80 void HMatrixV::HMHt(TMatrixDSym& M) const {
81  assert (M.GetNrows() == 5);
82 
83  M(0,0) = M(4,4);
84 
85  M.ResizeTo(1,1);
86 }
87 
88 
89 void HMatrixV::Print(const Option_t*) const {
90  printOut << "V" << std::endl;
91 }
92 
93 } /* End of namespace genfit */
TMatrixD MHt(const TMatrixDSym &M) const override
M*H^t.
Definition: HMatrixV.cc:52
void HMHt(TMatrixDSym &M) const override
similarity: H*M*H^t
Definition: HMatrixV.cc:80
const TMatrixD & getMatrix() const override
Get the actual matrix representation.
Definition: HMatrixV.cc:32
TVectorD Hv(const TVectorD &v) const override
H*v.
Definition: HMatrixV.cc:41
Defines for I/O streams used for error and debug printing.
std::ostream printOut
Default stream for output of Print calls.