Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:18:27

0001 /* Copyright 2013, Technische Universitaet Muenchen, Ludwig-Maximilians-Universität München
0002    Authors: Johannes Rauch, Tobias Schlüter
0003 
0004    This file is part of GENFIT.
0005 
0006    GENFIT is free software: you can redistribute it and/or modify
0007    it under the terms of the GNU Lesser General Public License as published
0008    by the Free Software Foundation, either version 3 of the License, or
0009    (at your option) any later version.
0010 
0011    GENFIT is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0014    GNU Lesser General Public License for more details.
0015 
0016    You should have received a copy of the GNU Lesser General Public License
0017    along with GENFIT.  If not, see <http://www.gnu.org/licenses/>.
0018 */
0019 
0020 #include "HMatrixUV.h"
0021 
0022 #include "IO.h"
0023 
0024 #include <cassert>
0025 #include <alloca.h>
0026 
0027 namespace genfit {
0028 
0029 
0030 // 0, 0, 0, 1, 0
0031 // 0, 0, 0, 0, 1
0032 
0033 const TMatrixD& HMatrixUV::getMatrix() const {
0034   static const double HMatrixContent[2*5] = {0, 0, 0, 1, 0,
0035                                              0, 0, 0, 0, 1};
0036 
0037   static const TMatrixD HMatrix(2,5, HMatrixContent);
0038 
0039   return HMatrix;
0040 }
0041 
0042 
0043 TVectorD HMatrixUV::Hv(const TVectorD& v) const {
0044   assert (v.GetNrows() == 5);
0045 
0046   double* retValArray =(double *)alloca(sizeof(double) * 2);
0047   const double* VecArray = v.GetMatrixArray();
0048 
0049   retValArray[0] = VecArray[3]; // u
0050   retValArray[1] = VecArray[4]; // v
0051 
0052   return TVectorD(2, retValArray);
0053 }
0054 
0055 
0056 TMatrixD HMatrixUV::MHt(const TMatrixDSym& M) const {
0057   assert (M.GetNcols() == 5);
0058 
0059   double* retValArray =(double *)alloca(sizeof(double) * 5*2);
0060   const double* MatArray = M.GetMatrixArray();
0061 
0062   for (unsigned int i=0; i<5; ++i) {
0063     retValArray[i*2] = MatArray[i*5 + 3];
0064     retValArray[i*2 + 1] = MatArray[i*5 + 4];
0065   }
0066 
0067   return TMatrixD(5,2, retValArray);
0068 }
0069 
0070 
0071 TMatrixD HMatrixUV::MHt(const TMatrixD& M) const {
0072   assert (M.GetNcols() == 5);
0073 
0074   double* retValArray =(double *)alloca(sizeof(double) * M.GetNrows()*2);
0075   const double* MatArray = M.GetMatrixArray();
0076 
0077   for (int i = 0; i < M.GetNrows(); ++i) {
0078     retValArray[i*2] = MatArray[i*5 + 3];
0079     retValArray[i*2 + 1] = MatArray[i*5 + 4];
0080   }
0081 
0082   return TMatrixD(M.GetNrows(),2, retValArray);
0083 }
0084 
0085 
0086 void HMatrixUV::HMHt(TMatrixDSym& M) const {
0087   assert (M.GetNrows() == 5);
0088   double* MatArray = M.GetMatrixArray();
0089 
0090   //
0091   //  HMH^t = ( M_33  M_34 ) where M_34 == M_43
0092   //          ( M_43  M_44 )
0093   //
0094   double uu = MatArray[3*5 + 3];
0095   double uv = MatArray[3*5 + 4];
0096   double vv = MatArray[4*5 + 4];
0097 
0098   M.ResizeTo(2,2);
0099   MatArray = M.GetMatrixArray();
0100   MatArray[0] = uu; MatArray[1] = uv;
0101   MatArray[2] = uv; MatArray[3] = vv;
0102 }
0103 
0104 
0105 void HMatrixUV::Print(const Option_t*) const {
0106   printOut << "UV" << std::endl;
0107 }
0108 
0109 
0110 } /* End of namespace genfit */