EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HMatrixPhi.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file HMatrixPhi.cc
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 
22 #include "IO.h"
23 
24 #include <TBuffer.h>
25 
26 #include <cassert>
27 #include <alloca.h>
28 #include <math.h>
29 #include <TBuffer.h>
30 
31 namespace genfit {
32 
33 
34 // 0, 0, 0, cos(phi), sin(phi)
35 
36 
38  phi_(phi),
39  cosPhi_(cos(phi)),
40  sinPhi_(sin(phi))
41 {
42  ;
43 }
44 
45 const TMatrixD& HMatrixPhi::getMatrix() const {
46  static const double HMatrixContent[5] = {0, 0, 0, cosPhi_, sinPhi_};
47 
48  static const TMatrixD HMatrix(1,5, HMatrixContent);
49 
50  return HMatrix;
51 }
52 
53 
54 TVectorD HMatrixPhi::Hv(const TVectorD& v) const {
55  assert (v.GetNrows() == 5);
56 
57  double* retValArray =(double *)alloca(sizeof(double) * 1);
58 
59  retValArray[0] = cosPhi_*v(3) + sinPhi_*v(4);
60 
61  return TVectorD(1, retValArray);
62 }
63 
64 
65 TMatrixD HMatrixPhi::MHt(const TMatrixDSym& M) const {
66  assert (M.GetNcols() == 5);
67 
68  double* retValArray =(double *)alloca(sizeof(double) * 5);
69  const double* MatArray = M.GetMatrixArray();
70 
71  for (unsigned int i=0; i<5; ++i) {
72  retValArray[i] = cosPhi_*MatArray[i*5 + 3] + sinPhi_*MatArray[i*5 + 4];
73  }
74 
75  return TMatrixD(5,1, retValArray);
76 }
77 
78 
79 TMatrixD HMatrixPhi::MHt(const TMatrixD& M) const {
80  assert (M.GetNcols() == 5);
81 
82  double* retValArray =(double *)alloca(sizeof(double) * M.GetNrows());
83  const double* MatArray = M.GetMatrixArray();
84 
85  for (int i = 0; i < M.GetNrows(); ++i) {
86  retValArray[i] = cosPhi_*MatArray[i*5 + 3] + sinPhi_*MatArray[i*5 + 4];
87  }
88 
89  return TMatrixD(M.GetNrows(),1, retValArray);
90 }
91 
92 
93 void HMatrixPhi::HMHt(TMatrixDSym& M) const {
94  assert (M.GetNrows() == 5);
95 
96  M(0,0) = cosPhi_ * (cosPhi_*M(3,3) + sinPhi_*M(3,4))
97  + sinPhi_ * (cosPhi_*M(4,3) + sinPhi_*M(4,4));
98 
99  M.ResizeTo(1,1);
100 }
101 
102 
103 bool HMatrixPhi::isEqual(const AbsHMatrix& other) const {
104  if (dynamic_cast<const HMatrixPhi*>(&other) == nullptr)
105  return false;
106 
107  return (phi_ == static_cast<const HMatrixPhi*>(&other)->phi_);
108 }
109 
110 void HMatrixPhi::Print(const Option_t*) const
111 {
112  printOut << "phi = " << phi_ << std::endl;
113 }
114 
115 void HMatrixPhi::Streamer(TBuffer &R__b) {
116  // Stream an object of class genfit::HMatrixPhi.
117 
118  // Modified from auto-generated streamer to set non-persistent members after reading
119 
120  if (R__b.IsReading()) {
121  R__b.ReadClassBuffer(genfit::HMatrixPhi::Class(),this);
122  cosPhi_ = cos(phi_);
123  sinPhi_ = sin(phi_);
124  } else {
125  R__b.WriteClassBuffer(genfit::HMatrixPhi::Class(),this);
126  }
127 }
128 
129 
130 } /* End of namespace genfit */