CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GetLineCovMatrix.cc
Go to the documentation of this file.
1 
3 
5 {
6 
7  PointOne = pointOne;
8  PointTwo = pointTwo;
9 
10  CombinedErrorMatrix = CLHEP::HepMatrix(6, 6, 0);
11 
12  CombinedErrorMatrix[0][0] = ErrorOne.cxx();
13  CombinedErrorMatrix[1][0] = ErrorOne.cyx();
14  CombinedErrorMatrix[0][1] = ErrorOne.cyx();
15  CombinedErrorMatrix[1][1] = ErrorOne.cyy();
16  CombinedErrorMatrix[2][0] = ErrorOne.czx();
17  CombinedErrorMatrix[0][2] = ErrorOne.czx();
18  CombinedErrorMatrix[2][1] = ErrorOne.czy();
19  CombinedErrorMatrix[1][2] = ErrorOne.czy();
20  CombinedErrorMatrix[2][2] = ErrorOne.czz();
21 
22  CombinedErrorMatrix[3][3] = ErrorTwo.cxx();
23  CombinedErrorMatrix[4][3] = ErrorTwo.cyx();
24  CombinedErrorMatrix[3][4] = ErrorTwo.cyx();
25  CombinedErrorMatrix[4][4] = ErrorTwo.cyy();
26  CombinedErrorMatrix[5][3] = ErrorTwo.czx();
27  CombinedErrorMatrix[3][5] = ErrorTwo.czx();
28  CombinedErrorMatrix[5][4] = ErrorTwo.czy();
29  CombinedErrorMatrix[4][5] = ErrorTwo.czy();
30  CombinedErrorMatrix[5][5] = ErrorTwo.czz();
31 
32  B = CLHEP::HepMatrix(3, 6, 0);
33 }
34 
35 
37 {
38  // the linear equation is K = PointOne + (PointTwo-PointOne)*s
39  double s;
40  if( !fabs(PointTwo.x() - PointOne.x()) < 0.00000001 )
41  s = (PointThree.x() - PointOne.x()) / (PointTwo.x() - PointOne.x()) ;
42  else {
43  if( !fabs(PointTwo.y() - PointOne.y()) < 0.00000001 )
44  s = (PointThree.y() - PointOne.y()) / (PointTwo.y() - PointOne.y()) ;
45  else {
46  if( !fabs(PointTwo.z() - PointOne.z()) < 0.00000001 )
47  s = (PointThree.z() - PointOne.z()) / (PointTwo.z() - PointOne.z()) ;
48  else {
49  GlobalError EmptyError(0, 0, 0, 0, 0, 0);
50  return EmptyError;
51  }
52  }
53  }
54 
55  B[0][0] = 1-s;
56  B[0][3] = s;
57  B[1][1] = 1-s;
58  B[1][4] = s;
59  B[2][2] = 1-s;
60  B[2][5] = s;
61 
62  CLHEP::HepMatrix Result = B * CombinedErrorMatrix * B.T();
63 
64  GlobalError TheGlobalError( Result[0][0], Result[1][0], Result[1][1], Result[2][0], Result[2][1], Result[2][2] );
65  return TheGlobalError;
66 }
67 
T y() const
Definition: PV3DBase.h:62
GlobalPoint PointTwo
T z() const
Definition: PV3DBase.h:63
GlobalPoint PointOne
CLHEP::HepMatrix CombinedErrorMatrix
GlobalError GetMatrix(GlobalPoint)
T x() const
Definition: PV3DBase.h:61
GetLineCovMatrix(GlobalPoint, GlobalPoint, GlobalError, GlobalError)