SND@LHC Software
Loading...
Searching...
No Matches
HMatrixPhi.cc
Go to the documentation of this file.
1/* Copyright 2013, Technische Universitaet Muenchen,
2 Authors: Johannes Rauch
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 "HMatrixPhi.h"
21#include <cassert>
22#include <alloca.h>
23#include <math.h>
24#include <TBuffer.h>
25
26
27namespace genfit {
28
29
30// 0, 0, 0, cos(phi), sin(phi)
31
32
34 phi_(phi),
35 cosPhi_(cos(phi)),
36 sinPhi_(sin(phi))
37{
38 ;
39}
40
41const TMatrixD& HMatrixPhi::getMatrix() const {
42 static const double HMatrixContent[5] = {0, 0, 0, cosPhi_, sinPhi_};
43
44 static const TMatrixD HMatrix(1,5, HMatrixContent);
45
46 return HMatrix;
47}
48
49
50TVectorD HMatrixPhi::Hv(const TVectorD& v) const {
51 assert (v.GetNrows() == 5);
52
53 double* retValArray =(double *)alloca(sizeof(double) * 1);
54
55 retValArray[0] = cosPhi_*v(3) + sinPhi_*v(4);
56
57 return TVectorD(1, retValArray);
58}
59
60
61TMatrixD HMatrixPhi::MHt(const TMatrixDSym& M) const {
62 assert (M.GetNcols() == 5);
63
64 double* retValArray =(double *)alloca(sizeof(double) * 5);
65 const double* MatArray = M.GetMatrixArray();
66
67 for (unsigned int i=0; i<5; ++i) {
68 retValArray[i] = cosPhi_*MatArray[i*5 + 3] + sinPhi_*MatArray[i*5 + 4];
69 }
70
71 return TMatrixD(5,1, retValArray);
72}
73
74
75TMatrixD HMatrixPhi::MHt(const TMatrixD& M) const {
76 assert (M.GetNcols() == 5);
77
78 double* retValArray =(double *)alloca(sizeof(double) * M.GetNrows());
79 const double* MatArray = M.GetMatrixArray();
80
81 for (int i = 0; i < M.GetNrows(); ++i) {
82 retValArray[i] = cosPhi_*MatArray[i*5 + 3] + sinPhi_*MatArray[i*5 + 4];
83 }
84
85 return TMatrixD(M.GetNrows(),1, retValArray);
86}
87
88
89void HMatrixPhi::HMHt(TMatrixDSym& M) const {
90 assert (M.GetNrows() == 5);
91
92 M(0,0) = cosPhi_ * (cosPhi_*M(3,3) + sinPhi_*M(3,4))
93 + sinPhi_ * (cosPhi_*M(4,3) + sinPhi_*M(4,4));
94
95 M.ResizeTo(1,1);
96}
97
98
99bool HMatrixPhi::isEqual(const AbsHMatrix& other) const {
100 if (dynamic_cast<const HMatrixPhi*>(&other) == NULL)
101 return false;
102
103 return (phi_ == static_cast<const HMatrixPhi*>(&other)->phi_);
104}
105
106
107void HMatrixPhi::Streamer(TBuffer &R__b) {
108 // Stream an object of class genfit::HMatrixPhi.
109
110 // Modified from auto-generated streamer to set non-persistent members after reading
111
112 if (R__b.IsReading()) {
113 R__b.ReadClassBuffer(genfit::HMatrixPhi::Class(),this);
114 cosPhi_ = cos(phi_);
115 sinPhi_ = sin(phi_);
116 } else {
117 R__b.WriteClassBuffer(genfit::HMatrixPhi::Class(),this);
118 }
119}
120
121
122} /* End of namespace genfit */
HMatrix for projecting from AbsTrackRep parameters to measured parameters in a DetPlane.
Definition AbsHMatrix.h:37
AbsHMatrix implementation for one-dimensional MeasurementOnPlane and RKTrackRep parameterization.
Definition HMatrixPhi.h:37
TVectorD Hv(const TVectorD &v) const
H*v.
Definition HMatrixPhi.cc:50
HMatrixPhi(double phi=0)
Definition HMatrixPhi.cc:33
ClassDef(HMatrixPhi, 1) private double cosPhi_
Definition HMatrixPhi.h:56
const TMatrixD & getMatrix() const
Get the actual matrix representation.
Definition HMatrixPhi.cc:41
virtual bool isEqual(const AbsHMatrix &other) const
Definition HMatrixPhi.cc:99
TMatrixD MHt(const TMatrixDSym &M) const
M*H^t.
Definition HMatrixPhi.cc:61
void HMHt(TMatrixDSym &M) const
similarity: H*M*H^t
Definition HMatrixPhi.cc:89
Matrix inversion tools.
Definition AbsBField.h:29