ATLAS Offline Software
Loading...
Searching...
No Matches
VKalTransform.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Header include
6#include "CLHEP/Matrix/Matrix.h"
7#include "CLHEP/Matrix/Vector.h"
9#include <cmath>
10#include <iostream>
11//-------------------------------------------------
12/* Coversion from ATLAS to VKalVrt parameters
13 Output:
14 VTrkPar[5] - track parameters for VKalVrt
15 VTrkCov[15] - track parameters error matrix
16 Charge - track charge
17
18 Convertion is always done for PERIGEE parameters .
19 Only Z component of magnetic field is used for momentum calculation
20 Magnetic field should be taken at point of conversion ( (0,0,0) usually)
21*/
22//--------------------------------------------------------------------
23
24namespace Trk{
25
26 bool TrkVKalVrtFitter::convertAmg5SymMtx(const AmgSymMatrix(5)* AmgMtx, double stdSymMtx[15]) const
27 {
28 if(!AmgMtx) return false;
29 //----- Check perigee covarince matrix for safety
30 double DET=AmgMtx->determinant();
31 if( DET!=DET ) {
32 if(msgLvl(MSG::DEBUG))msg(MSG::DEBUG)<<" NaN in Perigee covariance is detected! Stop fit."<<endmsg;
33 return false;
34 }
35 if( fabs(DET) < 1000.*std::numeric_limits<double>::min()) {
36 if(msgLvl(MSG::DEBUG))msg(MSG::DEBUG)<<"Zero Perigee covariance DET is detected! Stop fit."<<endmsg;
37 return false;
38 }
39//std::cout.setf(std::ios::scientific); std::cout<<"VKMINNUMB="<<std::numeric_limits<double>::min()<<", "<<DET<<'\n';
40 //---------------------------------------------------------
41 stdSymMtx[ 0] =(*AmgMtx)(0,0);
42 stdSymMtx[ 1] =(*AmgMtx)(1,0);
43 stdSymMtx[ 2] =(*AmgMtx)(1,1);
44 stdSymMtx[ 3] =(*AmgMtx)(2,0);
45 stdSymMtx[ 4] =(*AmgMtx)(2,1);
46 stdSymMtx[ 5] =(*AmgMtx)(2,2);
47 stdSymMtx[ 6] =(*AmgMtx)(3,0);
48 stdSymMtx[ 7] =(*AmgMtx)(3,1);
49 stdSymMtx[ 8] =(*AmgMtx)(3,2);
50 stdSymMtx[ 9] =(*AmgMtx)(3,3);
51 stdSymMtx[10] =(*AmgMtx)(4,0);
52 stdSymMtx[11] =(*AmgMtx)(4,1);
53 stdSymMtx[12] =(*AmgMtx)(4,2);
54 stdSymMtx[13] =(*AmgMtx)(4,3);
55 stdSymMtx[14] =(*AmgMtx)(4,4);
56 return true;
57 }
58
59 void TrkVKalVrtFitter::VKalTransform(double effectiveBMAG,
60 double A0V,double ZV,double PhiV,double ThetaV,double PInv,const double CovTrk[15],
61 long int & Charge, double VTrkPar[5], double VTrkCov[15]) const
62 {
63 int i,j,ii,jj;
64 double CnvCst=m_CNVMAG*effectiveBMAG;
65 double sinT = sin(ThetaV);
66 double cosT = cos(ThetaV);
67
68 VTrkPar[0] = - A0V ;
69 VTrkPar[1] = ZV ;
70 VTrkPar[2] = ThetaV;
71 VTrkPar[3] = PhiV;
72 VTrkPar[4] = -PInv*CnvCst/sinT ;
73 Charge = PInv > 0 ? -1 : 1;
74//
75//
76 double CovI[5][5];
77 double Deriv[5][5] ={{0.,0.,0.,0.,0.},{0.,0.,0.,0.,0.},{0.,0.,0.,0.,0.},
78 {0.,0.,0.,0.,0.},{0.,0.,0.,0.,0.}};
79
80 CovI[0][0] = CovTrk[0];
81
82 CovI[1][0] = CovTrk[1];
83 CovI[0][1] = CovTrk[1];
84 CovI[1][1] = CovTrk[2];
85
86 CovI[0][2] = CovTrk[3];
87 CovI[2][0] = CovTrk[3];
88 CovI[1][2] = CovTrk[4];
89 CovI[2][1] = CovTrk[4];
90 CovI[2][2] = CovTrk[5];
91
92 CovI[0][3] = CovTrk[6];
93 CovI[3][0] = CovTrk[6];
94 CovI[1][3] = CovTrk[7];
95 CovI[3][1] = CovTrk[7];
96 CovI[2][3] = CovTrk[8];
97 CovI[3][2] = CovTrk[8];
98 CovI[3][3] = CovTrk[9];
99
100 CovI[0][4] = CovTrk[10] ;
101 CovI[4][0] = CovTrk[10] ;
102 CovI[1][4] = CovTrk[11] ;
103 CovI[4][1] = CovTrk[11] ;
104 CovI[2][4] = CovTrk[12] ;
105 CovI[4][2] = CovTrk[12] ;
106 CovI[3][4] = CovTrk[13] ;
107 CovI[4][3] = CovTrk[13] ;
108 CovI[4][4] = CovTrk[14] ;
109
110
111 Deriv[0][0] = -1.;
112 Deriv[1][1] = 1.;
113 Deriv[2][3] = 1.;
114 Deriv[3][2] = 1.;
115 Deriv[4][3] = PInv*CnvCst *(cosT/sinT/sinT) ;
116 Deriv[4][4] = -CnvCst/sinT;
117
118 double ct;
119 int ipnt=0;
120 for(i=0;i<5;i++){ for(j=0;j<=i;j++){
121 ct=0.;
122 for(ii=4;ii>=0;ii--){
123 if(Deriv[i][ii] == 0.) continue;
124 for(jj=4;jj>=0;jj--){
125 if(Deriv[j][jj] == 0.) continue;
126 ct += CovI[ii][jj]*Deriv[i][ii]*Deriv[j][jj];};};
127 VTrkCov[ipnt++]=ct;
128 };}
129
130}
131} // end of namespace
#define endmsg
#define AmgSymMatrix(dim)
bool convertAmg5SymMtx(const AmgSymMatrix(5) *, double[15]) const
void VKalTransform(double MAG, double A0V, double ZV, double PhiV, double ThetaV, double PInv, const double[15], long int &Charge, double[5], double[15]) const
Ensure that the ATLAS eigen extensions are properly loaded.
MsgStream & msg
Definition testRead.cxx:32