65{
66
67 const unsigned int ntrack = cart_coordList.size();
68
70
71 if (ntrack != 2) {
72 return matrixDeriv2;
73 }
74
75 const double bend_factor = -0.299792458 * b_fieldTesla;
76
77 const double px1 = cart_coordList[0][0];
78 const double py1 = cart_coordList[0][1];
79 const double pz1 = cart_coordList[0][2];
80
81 const double pt1 = sqrt(px1 * px1 + py1 * py1);
82
83 const double px2 = cart_coordList[1][0];
84 const double py2 = cart_coordList[1][1];
85 const double pz2 = cart_coordList[1][2];
86
87 const double pt2 = sqrt(px2 * px2 + py2 * py2);
88
89 const double deltaX1 = refPoint[0] - cart_coordList[0][4];
90 const double deltaY1 = refPoint[1] - cart_coordList[0][5];
91 const double deltaX2 = refPoint[0] - cart_coordList[1][4];
92 const double deltaY2 = refPoint[1] - cart_coordList[1][5];
93
94 const double a1 = charges[0] * bend_factor;
95 const double a2 = charges[1] * bend_factor;
96
97
98 matrixDeriv2(0, 0) = -(px2 - a2 * deltaY2) / (pt1 * pt2) +
99 px1 *
100 ((px1 - a1 * deltaY1) * (px2 - a2 * deltaY2) +
101 (py1 + a1 * deltaX1) * (py2 + a2 * deltaX2)) /
102 (pt1 * pt1 * pt1 * pt2);
103 matrixDeriv2(0, 1) = -(py2 + a2 * deltaX2) / (pt1 * pt2) +
104 py1 *
105 ((px1 - a1 * deltaY1) * (px2 - a2 * deltaY2) +
106 (py1 + a1 * deltaX1) * (py2 + a2 * deltaX2)) /
107 (pt1 * pt1 * pt1 * pt2);
108 matrixDeriv2(0, 2) = 0.;
109 matrixDeriv2(0, 3) = 0.;
110
111 matrixDeriv2(0, 4) = a1 * (py2 + a2 * deltaX2) / (pt1 * pt2);
112 matrixDeriv2(0, 5) = -a1 * (px2 - a2 * deltaY2) / (pt1 * pt2);
113 matrixDeriv2(0, 6) = 0.;
114
115 matrixDeriv2(0, 7) = -(px1 - a1 * deltaY1) / (pt1 * pt2) +
116 px2 *
117 ((px1 - a1 * deltaY1) * (px2 - a2 * deltaY2) +
118 (py1 + a1 * deltaX1) * (py2 + a2 * deltaX2)) /
119 (pt1 * pt2 * pt2 * pt2);
120 matrixDeriv2(0, 8) = -(py1 + a1 * deltaX1) / (pt1 * pt2) +
121 py2 *
122 ((px1 - a1 * deltaY1) * (px2 - a2 * deltaY2) +
123 (py1 + a1 * deltaX1) * (py2 + a2 * deltaX2)) /
124 (pt1 * pt2 * pt2 * pt2);
125 matrixDeriv2(0, 9) = 0.;
126 matrixDeriv2(0, 10) = 0.;
127
128 matrixDeriv2(0, 11) = a2 * (py1 + a1 * deltaX1) / (pt1 * pt2);
129 matrixDeriv2(0, 12) = -a2 * (px1 - a1 * deltaY1) / (pt1 * pt2);
130 matrixDeriv2(0, 13) = 0.;
131
132
133 matrixDeriv2(1, 0) = -(px1 * pz2) / pt1;
134 matrixDeriv2(1, 1) = -(py1 * pz2) / pt1;
135 matrixDeriv2(1, 2) = pt2;
136 matrixDeriv2(1, 3) = 0.;
137
138 matrixDeriv2(1, 4) = 0.;
139 matrixDeriv2(1, 5) = 0.;
140 matrixDeriv2(1, 6) = 0.;
141
142 matrixDeriv2(1, 7) = (px2 * pz1) / pt2;
143 matrixDeriv2(1, 8) = (py2 * pz1) / pt2;
144 matrixDeriv2(1, 9) = -pt1;
145 matrixDeriv2(1, 10) = 0;
146
147 matrixDeriv2(1, 11) = 0.;
148 matrixDeriv2(1, 12) = 0.;
149 matrixDeriv2(1, 13) = 0.;
150
151 return matrixDeriv2;
152}
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.