SND@LHC Software
Loading...
Searching...
No Matches
HMatrixUV.cc
Go to the documentation of this file.
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#include <cassert>
22#include <alloca.h>
23
24namespace genfit {
25
26
27// 0, 0, 0, 1, 0
28// 0, 0, 0, 0, 1
29
30const TMatrixD& HMatrixUV::getMatrix() const {
31 static const double HMatrixContent[2*5] = {0, 0, 0, 1, 0,
32 0, 0, 0, 0, 1};
33
34 static const TMatrixD HMatrix(2,5, HMatrixContent);
35
36 return HMatrix;
37}
38
39
40TVectorD HMatrixUV::Hv(const TVectorD& v) const {
41 assert (v.GetNrows() == 5);
42
43 double* retValArray =(double *)alloca(sizeof(double) * 2);
44 const double* VecArray = v.GetMatrixArray();
45
46 retValArray[0] = VecArray[3]; // u
47 retValArray[1] = VecArray[4]; // v
48
49 return TVectorD(2, retValArray);
50}
51
52
53TMatrixD HMatrixUV::MHt(const TMatrixDSym& M) const {
54 assert (M.GetNcols() == 5);
55
56 double* retValArray =(double *)alloca(sizeof(double) * 5*2);
57 const double* MatArray = M.GetMatrixArray();
58
59 for (unsigned int i=0; i<5; ++i) {
60 retValArray[i*2] = MatArray[i*5 + 3];
61 retValArray[i*2 + 1] = MatArray[i*5 + 4];
62 }
63
64 return TMatrixD(5,2, retValArray);
65}
66
67
68TMatrixD HMatrixUV::MHt(const TMatrixD& M) const {
69 assert (M.GetNcols() == 5);
70
71 double* retValArray =(double *)alloca(sizeof(double) * M.GetNrows()*2);
72 const double* MatArray = M.GetMatrixArray();
73
74 for (int i = 0; i < M.GetNrows(); ++i) {
75 retValArray[i*2] = MatArray[i*5 + 3];
76 retValArray[i*2 + 1] = MatArray[i*5 + 4];
77 }
78
79 return TMatrixD(M.GetNrows(),2, retValArray);
80}
81
82
83void HMatrixUV::HMHt(TMatrixDSym& M) const {
84 assert (M.GetNrows() == 5);
85 double* MatArray = M.GetMatrixArray();
86
87 //
88 // HMH^t = ( M_33 M_34 ) where M_34 == M_43
89 // ( M_43 M_44 )
90 //
91 double uu = MatArray[3*5 + 3];
92 double uv = MatArray[3*5 + 4];
93 double vv = MatArray[4*5 + 4];
94
95 M.ResizeTo(2,2);
96 MatArray = M.GetMatrixArray();
97 MatArray[0] = uu; MatArray[1] = uv;
98 MatArray[2] = uv; MatArray[3] = vv;
99}
100
101
102} /* End of namespace genfit */
TVectorD Hv(const TVectorD &v) const
H*v.
Definition HMatrixUV.cc:40
TMatrixD MHt(const TMatrixDSym &M) const
M*H^t.
Definition HMatrixUV.cc:53
const TMatrixD & getMatrix() const
Get the actual matrix representation.
Definition HMatrixUV.cc:30
void HMHt(TMatrixDSym &M) const
similarity: H*M*H^t
Definition HMatrixUV.cc:83
Matrix inversion tools.
Definition AbsBField.h:29