CbmRoot
L1Extrapolation.h
Go to the documentation of this file.
1 #ifndef L1Extrapolation_h
2 #define L1Extrapolation_h
3 
4 #include "CbmL1Def.h"
5 #include "L1Field.h"
6 #include "L1TrackPar.h"
7 
8 
9 //#define cnst static const fvec
10 #define cnst const fvec
11 
12 // #define ANALYTICEXTRAPOLATION
13 #ifdef ANALYTICEXTRAPOLATION
14 inline void L1Extrapolate(
15  L1TrackPar& T, // input track parameters (x,y,tx,ty,Q/p) and cov.matrix
16  fvec z_out, // extrapolate to this z position
17  fvec qp0, // use Q/p linearisation at this value
18  L1FieldRegion& F,
19  fvec* w = 0) {
20  //cout<<"Extrapolation..."<<endl;
21  //
22  // Part of the analytic extrapolation formula with error (c_light*B*dz)^4/4!
23  //
24 
25  cnst ZERO = 0.0, ONE = 1.;
26  cnst c_light = 0.000299792458, c_light_i = 1. / c_light;
27 
28  cnst c1 = 1., c2 = 2., c3 = 3., c4 = 4., c6 = 6., c9 = 9., c15 = 15.,
29  c18 = 18., c45 = 45., c2i = 1. / 2., c3i = 1. / 3., c6i = 1. / 6.,
30  c12i = 1. / 12.;
31 
32  const fvec qp = T.qp;
33  const fvec dz = (z_out - T.z);
34  const fvec dz2 = dz * dz;
35  const fvec dz3 = dz2 * dz;
36 
37  // construct coefficients
38 
39  const fvec x = T.tx;
40  const fvec y = T.ty;
41  const fvec xx = x * x;
42  const fvec xy = x * y;
43  const fvec yy = y * y;
44  const fvec y2 = y * c2;
45  const fvec x2 = x * c2;
46  const fvec x4 = x * c4;
47  const fvec xx31 = xx * c3 + c1;
48  const fvec xx159 = xx * c15 + c9;
49 
50  const fvec Ay = -xx - c1;
51  const fvec Ayy = x * (xx * c3 + c3);
52  const fvec Ayz = -c2 * xy;
53  const fvec Ayyy = -(c15 * xx * xx + c18 * xx + c3);
54 
55  const fvec Ayy_x = c3 * xx31;
56  const fvec Ayyy_x = -x4 * xx159;
57 
58  const fvec Bx = yy + c1;
59  const fvec Byy = y * xx31;
60  const fvec Byz = c2 * xx + c1;
61  const fvec Byyy = -xy * xx159;
62 
63  const fvec Byy_x = c6 * xy;
64  const fvec Byyy_x = -y * (c45 * xx + c9);
65  const fvec Byyy_y = -x * xx159;
66 
67  // end of coefficients calculation
68 
69  const fvec t2 = c1 + xx + yy;
70  const fvec t = sqrt(t2);
71  const fvec h = qp0 * c_light;
72  const fvec ht = h * t;
73 
74  // get field integrals
75  const fvec ddz = T.z - F.z0;
76  const fvec Fx0 = F.cx0 + F.cx1 * ddz + F.cx2 * ddz * ddz;
77  const fvec Fx1 = (F.cx1 + c2 * F.cx2 * ddz) * dz;
78  const fvec Fx2 = F.cx2 * dz2;
79  const fvec Fy0 = F.cy0 + F.cy1 * ddz + F.cy2 * ddz * ddz;
80  const fvec Fy1 = (F.cy1 + c2 * F.cy2 * ddz) * dz;
81  const fvec Fy2 = F.cy2 * dz2;
82  const fvec Fz0 = F.cz0 + F.cz1 * ddz + F.cz2 * ddz * ddz;
83  const fvec Fz1 = (F.cz1 + c2 * F.cz2 * ddz) * dz;
84  const fvec Fz2 = F.cz2 * dz2;
85 
86  //
87 
88  const fvec sx = (Fx0 + Fx1 * c2i + Fx2 * c3i);
89  const fvec sy = (Fy0 + Fy1 * c2i + Fy2 * c3i);
90  const fvec sz = (Fz0 + Fz1 * c2i + Fz2 * c3i);
91 
92  const fvec Sx = (Fx0 * c2i + Fx1 * c6i + Fx2 * c12i);
93  const fvec Sy = (Fy0 * c2i + Fy1 * c6i + Fy2 * c12i);
94  const fvec Sz = (Fz0 * c2i + Fz1 * c6i + Fz2 * c12i);
95 
96  fvec syz;
97  {
98  cnst d = 1. / 360., c00 = 30. * 6. * d, c01 = 30. * 2. * d, c02 = 30. * d,
99  c10 = 3. * 40. * d, c11 = 3. * 15. * d, c12 = 3. * 8. * d,
100  c20 = 2. * 45. * d, c21 = 2. * 2. * 9. * d, c22 = 2. * 2. * 5. * d;
101  syz = Fy0 * (c00 * Fz0 + c01 * Fz1 + c02 * Fz2)
102  + Fy1 * (c10 * Fz0 + c11 * Fz1 + c12 * Fz2)
103  + Fy2 * (c20 * Fz0 + c21 * Fz1 + c22 * Fz2);
104  }
105 
106  fvec Syz;
107  {
108  cnst d = 1. / 2520., c00 = 21. * 20. * d, c01 = 21. * 5. * d,
109  c02 = 21. * 2. * d, c10 = 7. * 30. * d, c11 = 7. * 9. * d,
110  c12 = 7. * 4. * d, c20 = 2. * 63. * d, c21 = 2. * 21. * d,
111  c22 = 2. * 10. * d;
112  Syz = Fy0 * (c00 * Fz0 + c01 * Fz1 + c02 * Fz2)
113  + Fy1 * (c10 * Fz0 + c11 * Fz1 + c12 * Fz2)
114  + Fy2 * (c20 * Fz0 + c21 * Fz1 + c22 * Fz2);
115  }
116 
117  const fvec syy = sy * sy * c2i;
118  const fvec syyy = syy * sy * c3i;
119 
120  fvec Syy;
121  {
122  cnst d = 1. / 2520., c00 = 420. * d, c01 = 21. * 15. * d,
123  c02 = 21. * 8. * d, c03 = 63. * d, c04 = 70. * d, c05 = 20. * d;
124  Syy = Fy0 * (c00 * Fy0 + c01 * Fy1 + c02 * Fy2)
125  + Fy1 * (c03 * Fy1 + c04 * Fy2) + c05 * Fy2 * Fy2;
126  }
127 
128  fvec Syyy;
129  {
130  cnst d = 1. / 181440., c000 = 7560 * d, c001 = 9 * 1008 * d,
131  c002 = 5 * 1008 * d, c011 = 21 * 180 * d, c012 = 24 * 180 * d,
132  c022 = 7 * 180 * d, c111 = 540 * d, c112 = 945 * d, c122 = 560 * d,
133  c222 = 112 * d;
134  const fvec Fy22 = Fy2 * Fy2;
135  Syyy = Fy0
136  * (Fy0 * (c000 * Fy0 + c001 * Fy1 + c002 * Fy2)
137  + Fy1 * (c011 * Fy1 + c012 * Fy2) + c022 * Fy22)
138  + Fy1 * (Fy1 * (c111 * Fy1 + c112 * Fy2) + c122 * Fy22)
139  + c222 * Fy22 * Fy2;
140  }
141 
142 
143  const fvec sA1 = sx * xy + sy * Ay + sz * y;
144  const fvec sA1_x = sx * y - sy * x2;
145  const fvec sA1_y = sx * x + sz;
146 
147  const fvec sB1 = sx * Bx - sy * xy - sz * x;
148  const fvec sB1_x = -sy * y - sz;
149  const fvec sB1_y = sx * y2 - sy * x;
150 
151  const fvec SA1 = Sx * xy + Sy * Ay + Sz * y;
152  const fvec SA1_x = Sx * y - Sy * x2;
153  const fvec SA1_y = Sx * x + Sz;
154 
155  const fvec SB1 = Sx * Bx - Sy * xy - Sz * x;
156  const fvec SB1_x = -Sy * y - Sz;
157  const fvec SB1_y = Sx * y2 - Sy * x;
158 
159 
160  const fvec sA2 = syy * Ayy + syz * Ayz;
161  const fvec sA2_x = syy * Ayy_x - syz * y2;
162  const fvec sA2_y = -syz * x2;
163  const fvec sB2 = syy * Byy + syz * Byz;
164  const fvec sB2_x = syy * Byy_x + syz * x4;
165  const fvec sB2_y = syy * xx31;
166 
167  const fvec SA2 = Syy * Ayy + Syz * Ayz;
168  const fvec SA2_x = Syy * Ayy_x - Syz * y2;
169  const fvec SA2_y = -Syz * x2;
170  const fvec SB2 = Syy * Byy + Syz * Byz;
171  const fvec SB2_x = Syy * Byy_x + Syz * x4;
172  const fvec SB2_y = Syy * xx31;
173 
174  const fvec sA3 = syyy * Ayyy;
175  const fvec sA3_x = syyy * Ayyy_x;
176  const fvec sB3 = syyy * Byyy;
177  const fvec sB3_x = syyy * Byyy_x;
178  const fvec sB3_y = syyy * Byyy_y;
179 
180 
181  const fvec SA3 = Syyy * Ayyy;
182  const fvec SA3_x = Syyy * Ayyy_x;
183  const fvec SB3 = Syyy * Byyy;
184  const fvec SB3_x = Syyy * Byyy_x;
185  const fvec SB3_y = Syyy * Byyy_y;
186 
187  const fvec ht1 = ht * dz;
188  const fvec ht2 = ht * ht * dz2;
189  const fvec ht3 = ht * ht * ht * dz3;
190  const fvec ht1sA1 = ht1 * sA1;
191  const fvec ht1sB1 = ht1 * sB1;
192  const fvec ht1SA1 = ht1 * SA1;
193  const fvec ht1SB1 = ht1 * SB1;
194  const fvec ht2sA2 = ht2 * sA2;
195  const fvec ht2SA2 = ht2 * SA2;
196  const fvec ht2sB2 = ht2 * sB2;
197  const fvec ht2SB2 = ht2 * SB2;
198  const fvec ht3sA3 = ht3 * sA3;
199  const fvec ht3sB3 = ht3 * sB3;
200  const fvec ht3SA3 = ht3 * SA3;
201  const fvec ht3SB3 = ht3 * SB3;
202 
203  fvec initialised = ZERO;
204  if (w) //TODO use operator {?:}
205  {
206  const fvec zero = ZERO;
207  initialised = fvec(zero < *w);
208  } else {
209  const fvec one = ONE;
210  const fvec zero = ZERO;
211  initialised = fvec(zero < one);
212  }
213 
214  T.x += (((x + ht1SA1 + ht2SA2 + ht3SA3) * dz) & initialised);
215  T.y += (((y + ht1SB1 + ht2SB2 + ht3SB3) * dz) & initialised);
216  T.tx += ((ht1sA1 + ht2sA2 + ht3sA3) & initialised);
217  T.ty += ((ht1sB1 + ht2sB2 + ht3sB3) & initialised);
218  T.z += ((dz) &initialised);
219 
220  const fvec ctdz = c_light * t * dz;
221  const fvec ctdz2 = c_light * t * dz2;
222 
223  const fvec dqp = qp - qp0;
224  const fvec t2i = c1 * rcp(t2); // /t2;
225  const fvec xt2i = x * t2i;
226  const fvec yt2i = y * t2i;
227  const fvec tmp0 = ht1SA1 + c2 * ht2SA2 + c3 * ht3SA3;
228  const fvec tmp1 = ht1SB1 + c2 * ht2SB2 + c3 * ht3SB3;
229  const fvec tmp2 = ht1sA1 + c2 * ht2sA2 + c3 * ht3sA3;
230  const fvec tmp3 = ht1sB1 + c2 * ht2sB2 + c3 * ht3sB3;
231 
232  const fvec j02 =
233  dz * (c1 + xt2i * tmp0 + ht1 * SA1_x + ht2 * SA2_x + ht3 * SA3_x);
234  const fvec j12 = dz * (xt2i * tmp1 + ht1 * SB1_x + ht2 * SB2_x + ht3 * SB3_x);
235  const fvec j22 = c1 + xt2i * tmp2 + ht1 * sA1_x + ht2 * sA2_x + ht3 * sA3_x;
236  const fvec j32 = xt2i * tmp3 + ht1 * sB1_x + ht2 * sB2_x + ht3 * sB3_x;
237 
238  const fvec j03 = dz * (yt2i * tmp0 + ht1 * SA1_y + ht2 * SA2_y);
239  const fvec j13 =
240  dz * (c1 + yt2i * tmp1 + ht1 * SB1_y + ht2 * SB2_y + ht3 * SB3_y);
241  const fvec j23 = yt2i * tmp2 + ht1 * sA1_y + ht2 * sA2_y;
242  const fvec j33 = c1 + yt2i * tmp3 + ht1 * sB1_y + ht2 * sB2_y + ht3 * sB3_y;
243 
244  const fvec j04 = ctdz2 * (SA1 + c2 * ht1 * SA2 + c3 * ht2 * SA3);
245  const fvec j14 = ctdz2 * (SB1 + c2 * ht1 * SB2 + c3 * ht2 * SB3);
246  const fvec j24 = ctdz * (sA1 + c2 * ht1 * sA2 + c3 * ht2 * sA3);
247  const fvec j34 = ctdz * (sB1 + c2 * ht1 * sB2 + c3 * ht2 * sB3);
248 
249 
250  // extrapolate inverse momentum
251 
252  T.x += ((j04 * dqp) & initialised);
253  T.y += ((j14 * dqp) & initialised);
254  T.tx += ((j24 * dqp) & initialised);
255  T.ty += ((j34 * dqp) & initialised);
256 
257  // covariance matrix transport
258 
259  const fvec c42 = T.C42, c43 = T.C43;
260 
261  const fvec cj00 = T.C00 + T.C20 * j02 + T.C30 * j03 + T.C40 * j04;
262  // const fvec cj10 = T.C10 + T.C21*j02 + T.C31*j03 + T.C41*j04;
263  const fvec cj20 = T.C20 + T.C22 * j02 + T.C32 * j03 + c42 * j04;
264  const fvec cj30 = T.C30 + T.C32 * j02 + T.C33 * j03 + c43 * j04;
265 
266  const fvec cj01 = T.C10 + T.C20 * j12 + T.C30 * j13 + T.C40 * j14;
267  const fvec cj11 = T.C11 + T.C21 * j12 + T.C31 * j13 + T.C41 * j14;
268  const fvec cj21 = T.C21 + T.C22 * j12 + T.C32 * j13 + c42 * j14;
269  const fvec cj31 = T.C31 + T.C32 * j12 + T.C33 * j13 + c43 * j14;
270 
271  // const fvec cj02 = T.C20*j22 + T.C30*j23 + T.C40*j24;
272  // const fvec cj12 = T.C21*j22 + T.C31*j23 + T.C41*j24;
273  const fvec cj22 = T.C22 * j22 + T.C32 * j23 + c42 * j24;
274  const fvec cj32 = T.C32 * j22 + T.C33 * j23 + c43 * j24;
275 
276  // const fvec cj03 = T.C20*j32 + T.C30*j33 + T.C40*j34;
277  // const fvec cj13 = T.C21*j32 + T.C31*j33 + T.C41*j34;
278  const fvec cj23 = T.C22 * j32 + T.C32 * j33 + c42 * j34;
279  const fvec cj33 = T.C32 * j32 + T.C33 * j33 + c43 * j34;
280 
281  T.C40 += ((c42 * j02 + c43 * j03 + T.C44 * j04) & initialised); // cj40
282  T.C41 += ((c42 * j12 + c43 * j13 + T.C44 * j14) & initialised); // cj41
283  T.C42 = ((c42 * j22 + c43 * j23 + T.C44 * j24) & initialised)
284  + (T.C42 & (!initialised)); // cj42
285  T.C43 = ((c42 * j32 + c43 * j33 + T.C44 * j34) & initialised)
286  + (T.C43 & (!initialised)); // cj43
287 
288  T.C00 = ((cj00 + j02 * cj20 + j03 * cj30 + j04 * T.C40) & initialised)
289  + (T.C00 & (!initialised));
290  T.C10 = ((cj01 + j02 * cj21 + j03 * cj31 + j04 * T.C41) & initialised)
291  + (T.C10 & (!initialised));
292  T.C11 = ((cj11 + j12 * cj21 + j13 * cj31 + j14 * T.C41) & initialised)
293  + (T.C11 & (!initialised));
294 
295  T.C20 = ((j22 * cj20 + j23 * cj30 + j24 * T.C40) & initialised)
296  + (T.C20 & (!initialised));
297  T.C30 = ((j32 * cj20 + j33 * cj30 + j34 * T.C40) & initialised)
298  + (T.C30 & (!initialised));
299  T.C21 = ((j22 * cj21 + j23 * cj31 + j24 * T.C41) & initialised)
300  + (T.C21 & (!initialised));
301  T.C31 = ((j32 * cj21 + j33 * cj31 + j34 * T.C41) & initialised)
302  + (T.C31 & (!initialised));
303  T.C22 = ((j22 * cj22 + j23 * cj32 + j24 * T.C42) & initialised)
304  + (T.C22 & (!initialised));
305  T.C32 = ((j32 * cj22 + j33 * cj32 + j34 * T.C42) & initialised)
306  + (T.C32 & (!initialised));
307  T.C33 = ((j32 * cj23 + j33 * cj33 + j34 * T.C43) & initialised)
308  + (T.C33 & (!initialised));
309  //cout<<"Extrapolation ok"<<endl;
310 }
311 #else
312 inline void
313  L1Extrapolate // extrapolates track parameters and returns jacobian for extrapolation of CovMatrix
314  (L1TrackPar& T, // input track parameters (x,y,tx,ty,Q/p) and cov.matrix
315  fvec z_out, // extrapolate to this z position
316  fvec qp0, // use Q/p linearisation at this value
317  const L1FieldRegion& F,
318  fvec* w = 0) {
319  //
320  // Forth-order Runge-Kutta method for solution of the equation
321  // of motion of a particle with parameter qp = Q /P
322  // in the magnetic field B()
323  //
324  // | x | tx
325  // | y | ty
326  // d/dz = | tx| = ft * ( ty * ( B(3)+tx*b(1) ) - (1+tx**2)*B(2) )
327  // | ty| ft * (-tx * ( B(3)+ty+b(2) - (1+ty**2)*B(1) ) ,
328  //
329  // where ft = c_light*qp*sqrt ( 1 + tx**2 + ty**2 ) .
330  //
331  // In the following for RK step :
332  //
333  // x=x[0], y=x[1], tx=x[3], ty=x[4].
334  //
335  //========================================================================
336  //
337  // NIM A395 (1997) 169-184; NIM A426 (1999) 268-282.
338  //
339  // the routine is based on LHC(b) utility code
340  //
341  //========================================================================
342 
343 
344  cnst ZERO = 0.0, ONE = 1.;
345  cnst c_light = 0.000299792458;
346 
347  const fvec a[4] = {0.0f, 0.5f, 0.5f, 1.0f};
348  const fvec c[4] = {1.0f / 6.0f, 1.0f / 3.0f, 1.0f / 3.0f, 1.0f / 6.0f};
349  const fvec b[4] = {0.0f, 0.5f, 0.5f, 1.0f};
350 
351  int step4;
352  fvec k[16], x0[4], x[4], k1[16];
353  fvec Ax[4], Ay[4], Ax_tx[4], Ay_tx[4], Ax_ty[4], Ay_ty[4];
354 
355  //----------------------------------------------------------------
356 
357  fvec qp_in = T.qp;
358  const fvec z_in = T.z;
359  const fvec h = (z_out - T.z);
360  fvec hC = h * c_light;
361  x0[0] = T.x;
362  x0[1] = T.y;
363  x0[2] = T.tx;
364  x0[3] = T.ty;
365  //
366  // Runge-Kutta step
367  //
368 
369  int step;
370  int i;
371 
372  fvec B[4][3];
373  for (step = 0; step < 4; ++step) {
374  F.Get(z_in + a[step] * h, B[step]);
375  }
376 
377  for (step = 0; step < 4; ++step) {
378  for (i = 0; i < 4; ++i) {
379  if (step == 0) {
380  x[i] = x0[i];
381  } else {
382  x[i] = x0[i] + b[step] * k[step * 4 - 4 + i];
383  }
384  }
385 
386  fvec tx = x[2];
387  fvec ty = x[3];
388  fvec tx2 = tx * tx;
389  fvec ty2 = ty * ty;
390  fvec txty = tx * ty;
391  fvec tx2ty21 = 1.f + tx2 + ty2;
392  // if( tx2ty21 > 1.e4 ) return 1;
393  fvec I_tx2ty21 = 1.f / tx2ty21 * qp0;
394  fvec tx2ty2 = sqrt(tx2ty21);
395  // fvec I_tx2ty2 = qp0 * hC / tx2ty2 ; unsused ???
396  tx2ty2 *= hC;
397  fvec tx2ty2qp = tx2ty2 * qp0;
398  Ax[step] =
399  (txty * B[step][0] + ty * B[step][2] - (1.f + tx2) * B[step][1]) * tx2ty2;
400  Ay[step] = (-txty * B[step][1] - tx * B[step][2] + (1.f + ty2) * B[step][0])
401  * tx2ty2;
402 
403  Ax_tx[step] = Ax[step] * tx * I_tx2ty21
404  + (ty * B[step][0] - 2.f * tx * B[step][1]) * tx2ty2qp;
405  Ax_ty[step] =
406  Ax[step] * ty * I_tx2ty21 + (tx * B[step][0] + B[step][2]) * tx2ty2qp;
407  Ay_tx[step] =
408  Ay[step] * tx * I_tx2ty21 + (-ty * B[step][1] - B[step][2]) * tx2ty2qp;
409  Ay_ty[step] = Ay[step] * ty * I_tx2ty21
410  + (-tx * B[step][1] + 2.f * ty * B[step][0]) * tx2ty2qp;
411 
412  step4 = step * 4;
413  k[step4] = tx * h;
414  k[step4 + 1] = ty * h;
415  k[step4 + 2] = Ax[step] * qp0;
416  k[step4 + 3] = Ay[step] * qp0;
417 
418  } // end of Runge-Kutta steps
419 
420  fvec initialised = ZERO;
421  if (w) //TODO use operator {?:}
422  {
423  const fvec zero = ZERO;
424  initialised = fvec(zero < *w);
425  } else {
426  const fvec one = ONE;
427  const fvec zero = ZERO;
428  initialised = fvec(zero < one);
429  }
430 
431  {
432  T.x = ((x0[0] + c[0] * k[0] + c[1] * k[4 + 0] + c[2] * k[8 + 0]
433  + c[3] * k[12 + 0])
434  & initialised)
435  + ((!initialised) & T.x);
436  T.y = ((x0[1] + c[0] * k[1] + c[1] * k[4 + 1] + c[2] * k[8 + 1]
437  + c[3] * k[12 + 1])
438  & initialised)
439  + ((!initialised) & T.y);
440  T.tx = ((x0[2] + c[0] * k[2] + c[1] * k[4 + 2] + c[2] * k[8 + 2]
441  + c[3] * k[12 + 2])
442  & initialised)
443  + ((!initialised) & T.tx);
444  T.ty = ((x0[3] + c[0] * k[3] + c[1] * k[4 + 3] + c[2] * k[8 + 3]
445  + c[3] * k[12 + 3])
446  & initialised)
447  + ((!initialised) & T.ty);
448  T.z = (z_out & initialised) + ((!initialised) & T.z);
449  }
450 
451  //
452  // Derivatives dx/dqp
453  //
454 
455  x0[0] = 0.f;
456  x0[1] = 0.f;
457  x0[2] = 0.f;
458  x0[3] = 0.f;
459 
460  //
461  // Runge-Kutta step for derivatives dx/dqp
462 
463  for (step = 0; step < 4; ++step) {
464  for (i = 0; i < 4; ++i) {
465  if (step == 0) {
466  x[i] = x0[i];
467  } else {
468  x[i] = x0[i] + b[step] * k1[step * 4 - 4 + i];
469  }
470  }
471  step4 = step * 4;
472  k1[step4] = x[2] * h;
473  k1[step4 + 1] = x[3] * h;
474  k1[step4 + 2] = Ax[step] + Ax_tx[step] * x[2] + Ax_ty[step] * x[3];
475  k1[step4 + 3] = Ay[step] + Ay_tx[step] * x[2] + Ay_ty[step] * x[3];
476 
477  } // end of Runge-Kutta steps for derivatives dx/dqp
478 
479  fvec J[25];
480 
481  for (i = 0; i < 4; ++i) {
482  J[20 + i] = x0[i] + c[0] * k1[i] + c[1] * k1[4 + i] + c[2] * k1[8 + i]
483  + c[3] * k1[12 + i];
484  }
485  J[24] = 1.;
486  //
487  // end of derivatives dx/dqp
488  //
489 
490  // Derivatives dx/tx
491  //
492 
493  x0[0] = 0.f;
494  x0[1] = 0.f;
495  x0[2] = 1.f;
496  x0[3] = 0.f;
497 
498  //
499  // Runge-Kutta step for derivatives dx/dtx
500  //
501 
502  for (step = 0; step < 4; ++step) {
503  for (i = 0; i < 4; ++i) {
504  if (step == 0) {
505  x[i] = x0[i];
506  } else if (i != 2) {
507  x[i] = x0[i] + b[step] * k1[step * 4 - 4 + i];
508  }
509  }
510  step4 = step * 4;
511  k1[step4] = x[2] * h;
512  k1[step4 + 1] = x[3] * h;
513  // k1[step4+2] = Ax_tx[step] * x[2] + Ax_ty[step] * x[3];
514  k1[step4 + 3] = Ay_tx[step] * x[2] + Ay_ty[step] * x[3];
515 
516  } // end of Runge-Kutta steps for derivatives dx/dtx
517 
518  for (i = 0; i < 4; ++i) {
519  if (i != 2) {
520  J[10 + i] = x0[i] + c[0] * k1[i] + c[1] * k1[4 + i] + c[2] * k1[8 + i]
521  + c[3] * k1[12 + i];
522  }
523  }
524  // end of derivatives dx/dtx
525  J[12] = 1.f;
526  J[14] = 0.f;
527 
528  // Derivatives dx/ty
529  //
530 
531  x0[0] = 0.f;
532  x0[1] = 0.f;
533  x0[2] = 0.f;
534  x0[3] = 1.f;
535 
536  //
537  // Runge-Kutta step for derivatives dx/dty
538  //
539 
540  for (step = 0; step < 4; ++step) {
541  for (i = 0; i < 4; ++i) {
542  if (step == 0) {
543  x[i] = x0[i]; // ty fixed
544  } else if (i != 3) {
545  x[i] = x0[i] + b[step] * k1[step * 4 - 4 + i];
546  }
547  }
548  step4 = step * 4;
549  k1[step4] = x[2] * h;
550  k1[step4 + 1] = x[3] * h;
551  k1[step4 + 2] = Ax_tx[step] * x[2] + Ax_ty[step] * x[3];
552  // k1[step4+3] = Ay_tx[step] * x[2] + Ay_ty[step] * x[3];
553 
554  } // end of Runge-Kutta steps for derivatives dx/dty
555 
556  for (i = 0; i < 3; ++i) {
557  J[15 + i] = x0[i] + c[0] * k1[i] + c[1] * k1[4 + i] + c[2] * k1[8 + i]
558  + c[3] * k1[12 + i];
559  }
560  // end of derivatives dx/dty
561  J[18] = 1.;
562  J[19] = 0.;
563 
564  //
565  // derivatives dx/dx and dx/dy
566 
567  for (i = 0; i < 10; ++i) {
568  J[i] = 0.;
569  }
570  J[0] = 1.;
571  J[6] = 1.;
572 
573  fvec dqp = qp_in - qp0;
574 
575  { // update parameters
576  T.x += ((J[5 * 4 + 0] * dqp) & initialised);
577  T.y += ((J[5 * 4 + 1] * dqp) & initialised);
578  T.tx += ((J[5 * 4 + 2] * dqp) & initialised);
579  T.ty += ((J[5 * 4 + 3] * dqp) & initialised);
580  }
581 
582  // covariance matrix transport
583 
584  // // if ( C_in&&C_out ) CbmKFMath::multQtSQ( 5, J, C_in, C_out); // TODO
585  // j(0,2) = J[5*2 + 0];
586  // j(1,2) = J[5*2 + 1];
587  // j(2,2) = J[5*2 + 2];
588  // j(3,2) = J[5*2 + 3];
589  //
590  // j(0,3) = J[5*3 + 0];
591  // j(1,3) = J[5*3 + 1];
592  // j(2,3) = J[5*3 + 2];
593  // j(3,3) = J[5*3 + 3];
594  //
595  // j(0,4) = J[5*4 + 0];
596  // j(1,4) = J[5*4 + 1];
597  // j(2,4) = J[5*4 + 2];
598  // j(3,4) = J[5*4 + 3];
599 
600  const fvec c42 = T.C42, c43 = T.C43;
601 
602  const fvec cj00 =
603  T.C00 + T.C20 * J[5 * 2 + 0] + T.C30 * J[5 * 3 + 0] + T.C40 * J[5 * 4 + 0];
604  // const fvec cj10 = T.C10 + T.C21*J[5*2 + 0] + T.C31*J[5*3 + 0] + T.C41*J[5*4 + 0];
605  const fvec cj20 =
606  T.C20 + T.C22 * J[5 * 2 + 0] + T.C32 * J[5 * 3 + 0] + c42 * J[5 * 4 + 0];
607  const fvec cj30 =
608  T.C30 + T.C32 * J[5 * 2 + 0] + T.C33 * J[5 * 3 + 0] + c43 * J[5 * 4 + 0];
609 
610  const fvec cj01 =
611  T.C10 + T.C20 * J[5 * 2 + 1] + T.C30 * J[5 * 3 + 1] + T.C40 * J[5 * 4 + 1];
612  const fvec cj11 =
613  T.C11 + T.C21 * J[5 * 2 + 1] + T.C31 * J[5 * 3 + 1] + T.C41 * J[5 * 4 + 1];
614  const fvec cj21 =
615  T.C21 + T.C22 * J[5 * 2 + 1] + T.C32 * J[5 * 3 + 1] + c42 * J[5 * 4 + 1];
616  const fvec cj31 =
617  T.C31 + T.C32 * J[5 * 2 + 1] + T.C33 * J[5 * 3 + 1] + c43 * J[5 * 4 + 1];
618 
619  // const fvec cj02 = T.C20*J[5*2 + 2] + T.C30*J[5*3 + 2] + T.C40*J[5*4 + 2];
620  // const fvec cj12 = T.C21*J[5*2 + 2] + T.C31*J[5*3 + 2] + T.C41*J[5*4 + 2];
621  const fvec cj22 =
622  T.C22 * J[5 * 2 + 2] + T.C32 * J[5 * 3 + 2] + c42 * J[5 * 4 + 2];
623  const fvec cj32 =
624  T.C32 * J[5 * 2 + 2] + T.C33 * J[5 * 3 + 2] + c43 * J[5 * 4 + 2];
625 
626  // const fvec cj03 = T.C20*J[5*2 + 3] + T.C30*J[5*3 + 3] + T.C40*J[5*4 + 3];
627  // const fvec cj13 = T.C21*J[5*2 + 3] + T.C31*J[5*3 + 3] + T.C41*J[5*4 + 3];
628  const fvec cj23 =
629  T.C22 * J[5 * 2 + 3] + T.C32 * J[5 * 3 + 3] + c42 * J[5 * 4 + 3];
630  const fvec cj33 =
631  T.C32 * J[5 * 2 + 3] + T.C33 * J[5 * 3 + 3] + c43 * J[5 * 4 + 3];
632 
633  T.C40 += ((c42 * J[5 * 2 + 0] + c43 * J[5 * 3 + 0] + T.C44 * J[5 * 4 + 0])
634  & initialised); // cj40
635  T.C41 += ((c42 * J[5 * 2 + 1] + c43 * J[5 * 3 + 1] + T.C44 * J[5 * 4 + 1])
636  & initialised); // cj41
637  T.C42 = ((c42 * J[5 * 2 + 2] + c43 * J[5 * 3 + 2] + T.C44 * J[5 * 4 + 2])
638  & initialised)
639  + ((!initialised) & T.C42);
640  T.C43 = ((c42 * J[5 * 2 + 3] + c43 * J[5 * 3 + 3] + T.C44 * J[5 * 4 + 3])
641  & initialised)
642  + ((!initialised) & T.C43);
643 
644  T.C00 =
645  ((cj00 + J[5 * 2 + 0] * cj20 + J[5 * 3 + 0] * cj30 + J[5 * 4 + 0] * T.C40)
646  & initialised)
647  + ((!initialised) & T.C00);
648  T.C10 =
649  ((cj01 + J[5 * 2 + 0] * cj21 + J[5 * 3 + 0] * cj31 + J[5 * 4 + 0] * T.C41)
650  & initialised)
651  + ((!initialised) & T.C10);
652  T.C11 =
653  ((cj11 + J[5 * 2 + 1] * cj21 + J[5 * 3 + 1] * cj31 + J[5 * 4 + 1] * T.C41)
654  & initialised)
655  + ((!initialised) & T.C11);
656 
657  T.C20 = ((J[5 * 2 + 2] * cj20 + J[5 * 3 + 2] * cj30 + J[5 * 4 + 2] * T.C40)
658  & initialised)
659  + ((!initialised) & T.C20);
660  T.C30 = ((J[5 * 2 + 3] * cj20 + J[5 * 3 + 3] * cj30 + J[5 * 4 + 3] * T.C40)
661  & initialised)
662  + ((!initialised) & T.C30);
663  T.C21 = ((J[5 * 2 + 2] * cj21 + J[5 * 3 + 2] * cj31 + J[5 * 4 + 2] * T.C41)
664  & initialised)
665  + ((!initialised) & T.C21);
666  T.C31 = ((J[5 * 2 + 3] * cj21 + J[5 * 3 + 3] * cj31 + J[5 * 4 + 3] * T.C41)
667  & initialised)
668  + ((!initialised) & T.C31);
669  T.C22 = ((J[5 * 2 + 2] * cj22 + J[5 * 3 + 2] * cj32 + J[5 * 4 + 2] * T.C42)
670  & initialised)
671  + ((!initialised) & T.C22);
672  T.C32 = ((J[5 * 2 + 3] * cj22 + J[5 * 3 + 3] * cj32 + J[5 * 4 + 3] * T.C42)
673  & initialised)
674  + ((!initialised) & T.C32);
675  T.C33 = ((J[5 * 2 + 3] * cj23 + J[5 * 3 + 3] * cj33 + J[5 * 4 + 3] * T.C43)
676  & initialised)
677  + ((!initialised) & T.C33);
678 }
679 #endif //ANALYTICEXTRAPOLATION
680 
681 inline void L1Extrapolate0(
682  L1TrackPar& T, // input track parameters (x,y,tx,ty,Q/p) and cov.matrix
683  fvec z_out, // extrapolate to this z position
684  L1FieldRegion& F) {
685  //
686  // Part of the analytic extrapolation formula with error (c_light*B*dz)^4/4!
687  //
688 
689  cnst c_light = 0.000299792458;
690 
691  cnst c1 = 1., c2i = 1. / 2., c3i = 1. / 3., c6i = 1. / 6., c12i = 1. / 12.;
692 
693  const fvec qp = T.qp;
694 
695 
696  const fvec dz = (z_out - T.z);
697  const fvec dz2 = dz * dz;
698 
699  // construct coefficients
700 
701  const fvec x = T.tx;
702  const fvec y = T.ty;
703  // const fvec z = T.z;
704  const fvec xx = x * x;
705  const fvec xy = x * y;
706  const fvec yy = y * y;
707  const fvec Ay = -xx - c1;
708  const fvec Bx = yy + c1;
709  const fvec ct = c_light * sqrt(c1 + xx + yy);
710 
711  const fvec dzc2i = dz * c2i;
712  const fvec dz2c3i = dz2 * c3i;
713  const fvec dzc6i = dz * c6i;
714  const fvec dz2c12i = dz2 * c12i;
715 
716  const fvec sx = (F.cx0 + F.cx1 * dzc2i + F.cx2 * dz2c3i);
717  const fvec sy = (F.cy0 + F.cy1 * dzc2i + F.cy2 * dz2c3i);
718  const fvec sz = (F.cz0 + F.cz1 * dzc2i + F.cz2 * dz2c3i);
719 
720  const fvec Sx = (F.cx0 * c2i + F.cx1 * dzc6i + F.cx2 * dz2c12i);
721  const fvec Sy = (F.cy0 * c2i + F.cy1 * dzc6i + F.cy2 * dz2c12i);
722  const fvec Sz = (F.cz0 * c2i + F.cz1 * dzc6i + F.cz2 * dz2c12i);
723 
724 
725  const fvec ctdz = ct * dz;
726  const fvec ctdz2 = ct * dz2;
727 
728  const fvec j04 = ctdz2 * (Sx * xy + Sy * Ay + Sz * y);
729  const fvec j14 = ctdz2 * (Sx * Bx - Sy * xy - Sz * x);
730  const fvec j24 = ctdz * (sx * xy + sy * Ay + sz * y);
731  const fvec j34 = ctdz * (sx * Bx - sy * xy - sz * x);
732 
733  T.x += x * dz + j04 * qp;
734  T.y += y * dz + j14 * qp;
735  T.tx += j24 * qp;
736  T.ty += j34 * qp;
737  T.z += dz;
738  //T.t += sqrt((x-T.x)*(x-T.x)+(y-T.y)*(y-T.y)+dz*dz)/29.9792458f;
739 
740  // covariance matrix transport
741 
742  const fvec cj00 = T.C00 + T.C20 * dz + T.C40 * j04;
743  // const fvec cj10 = T.C10 + T.C21*dz + T.C41*j04;
744  const fvec cj20 = T.C20 + T.C22 * dz + T.C42 * j04;
745  const fvec cj30 = T.C30 + T.C32 * dz + T.C43 * j04;
746 
747  const fvec cj01 = T.C10 + T.C30 * dz + T.C40 * j14;
748  const fvec cj11 = T.C11 + T.C31 * dz + T.C41 * j14;
749  const fvec cj21 = T.C21 + T.C32 * dz + T.C42 * j14;
750  const fvec cj31 = T.C31 + T.C33 * dz + T.C43 * j14;
751 
752  // const fvec cj02 = T.C20 + T.C40*j24;
753  // const fvec cj12 = T.C21 + T.C41*j24;
754  const fvec cj22 = T.C22 + T.C42 * j24;
755  const fvec cj32 = T.C32 + T.C43 * j24;
756 
757  // const fvec cj03 = T.C30 + T.C40*j34;
758  // const fvec cj13 = T.C31 + T.C41*j34;
759  // const fvec cj23 = T.C32 + T.C42*j34;
760  const fvec cj33 = T.C33 + T.C43 * j34;
761 
762  T.C40 += T.C42 * dz + T.C44 * j04; // cj40
763  T.C41 += T.C43 * dz + T.C44 * j14; // cj41
764  T.C42 += T.C44 * j24; // cj42
765  T.C43 += T.C44 * j34; // cj43
766 
767  T.C00 = cj00 + dz * cj20 + j04 * T.C40;
768  T.C10 = cj01 + dz * cj21 + j04 * T.C41;
769  T.C11 = cj11 + dz * cj31 + j14 * T.C41;
770 
771  T.C20 = cj20 + j24 * T.C40;
772  T.C30 = cj30 + j34 * T.C40;
773  T.C21 = cj21 + j24 * T.C41;
774  T.C31 = cj31 + j34 * T.C41;
775  T.C22 = cj22 + j24 * T.C42;
776  T.C32 = cj32 + j34 * T.C42;
777  T.C33 = cj33 + j34 * T.C43;
778 }
779 
780 
781 inline void L1ExtrapolateTime(
782  L1TrackPar& T, // input track parameters (x,y,tx,ty,Q/p) and cov.matrix
783  fvec dz // extrapolate to this z position
784 ) {
785 
786  cnst c_light = 29.9792458;
787 
788  T.t += sqrt((T.tx * T.tx) + (T.ty * T.ty) + 1) * dz / c_light;
789 
790  const fvec k1 =
791  T.tx * dz / (c_light * sqrt((T.tx * T.tx) + (T.ty * T.ty) + 1));
792  const fvec k2 =
793  T.ty * dz / (c_light * sqrt((T.tx * T.tx) + (T.ty * T.ty) + 1));
794 
795  fvec c52 = T.C52;
796  fvec c53 = T.C53;
797 
798  // cout<<k1<<" k1 "<<k2<<" k2 "<<endl;
799 
800  // fvec ha = T.C53;
801  // fvec ha2 = T.C54;
802 
803  T.C50 += k1 * T.C20 + k2 * T.C30;
804  T.C51 += k1 * T.C21 + k2 * T.C31;
805  T.C52 += k1 * T.C22 + k2 * T.C32;
806  T.C53 += k1 * T.C32 + k2 * T.C33;
807  T.C54 += k1 * T.C42 + k2 * T.C43;
808  T.C55 += k1 * (T.C52 + c52) + k2 * (T.C53 + c53);
809 
810  // cout<<ha<<" c53 "<<T.C53<<endl;
811  // cout<<ha2<<" c54 "<<T.C54<<endl;
812 }
813 
814 inline void L1ExtrapolateLine(L1TrackPar& T, fvec z_out) {
815  fvec dz = (z_out - T.z);
816 
817  T.x += T.tx * dz;
818  T.y += T.ty * dz;
819  T.z += dz;
820 
821  const fvec dzC32_in = dz * T.C32;
822 
823  T.C21 += dzC32_in;
824  T.C10 += dz * (T.C21 + T.C30);
825 
826  const fvec C20_in = T.C20;
827 
828  T.C20 += dz * T.C22;
829  T.C00 += dz * (T.C20 + C20_in);
830 
831  const fvec C31_in = T.C31;
832 
833  T.C31 += dz * T.C33;
834  T.C11 += dz * (T.C31 + C31_in);
835  T.C30 += dzC32_in;
836 
837  T.C40 += dz * T.C42;
838  T.C41 += dz * T.C43;
839 }
840 
841 inline void
842 L1ExtrapolateXC00Line(const L1TrackPar& T, fvec z_out, fvec& x, fvec& C00) {
843  const fvec dz = (z_out - T.z);
844  x = T.x + T.tx * dz;
845  C00 = T.C00 + dz * (2 * T.C20 + dz * T.C22);
846 }
847 
848 inline void
849 L1ExtrapolateYC11Line(const L1TrackPar& T, fvec z_out, fvec& y, fvec& C11) {
850  const fvec dz = (z_out - T.z);
851  y = T.y + T.ty * dz;
852  C11 = T.C11 + dz * (2 * T.C31 + dz * T.C33);
853 }
854 
855 inline void L1ExtrapolateC10Line(const L1TrackPar& T, fvec z_out, fvec& C10) {
856  const fvec dz = (z_out - T.z);
857  C10 = T.C10 + dz * (T.C21 + T.C30 + dz * T.C32);
858 }
859 
860 inline void L1ExtrapolateJXY // is not used currently
861  (fvec& tx,
862  fvec& ty,
863  fvec& qp, // input track parameters
864  fvec dz, // extrapolate to this dz
865  L1FieldRegion& F,
866  fvec& extrDx,
867  fvec& extrDy,
868  fvec extrJ[]) {
869  //
870  // Part of the analytic extrapolation formula with error (c_light*B*dz)^4/4!
871  //
872 
873  // cnst ZERO = 0.0, ONE = 1.;
874  cnst c_light = 0.000299792458;
875 
876  cnst c1 = 1., c2 = 2., c3 = 3., c4 = 4., c6 = 6., c9 = 9., c15 = 15.,
877  c18 = 18., c45 = 45., c2i = 1. / 2., c6i = 1. / 6., c12i = 1. / 12.;
878 
879  fvec dz2 = dz * dz;
880  fvec dz3 = dz2 * dz;
881 
882  // construct coefficients
883 
884  fvec x = tx;
885  fvec y = ty;
886  fvec xx = x * x;
887  fvec xy = x * y;
888  fvec yy = y * y;
889  fvec y2 = y * c2;
890  fvec x2 = x * c2;
891  fvec x4 = x * c4;
892  fvec xx31 = xx * c3 + c1;
893  fvec xx159 = xx * c15 + c9;
894 
895  fvec Ay = -xx - c1;
896  fvec Ayy = x * (xx * c3 + c3);
897  fvec Ayz = -c2 * xy;
898  fvec Ayyy = -(c15 * xx * xx + c18 * xx + c3);
899 
900  fvec Ayy_x = c3 * xx31;
901  fvec Ayyy_x = -x4 * xx159;
902 
903  fvec Bx = yy + c1;
904  fvec Byy = y * xx31;
905  fvec Byz = c2 * xx + c1;
906  fvec Byyy = -xy * xx159;
907 
908  fvec Byy_x = c6 * xy;
909  fvec Byyy_x = -y * (c45 * xx + c9);
910  fvec Byyy_y = -x * xx159;
911 
912  // end of coefficients calculation
913 
914  fvec t2 = c1 + xx + yy;
915  fvec t = sqrt(t2);
916  fvec h = qp * c_light;
917  fvec ht = h * t;
918 
919  // get field integrals
920  fvec Fx0 = F.cx0;
921  fvec Fx1 = F.cx1 * dz;
922  fvec Fx2 = F.cx2 * dz2;
923  fvec Fy0 = F.cy0;
924  fvec Fy1 = F.cy1 * dz;
925  fvec Fy2 = F.cy2 * dz2;
926  fvec Fz0 = F.cz0;
927  fvec Fz1 = F.cz1 * dz;
928  fvec Fz2 = F.cz2 * dz2;
929 
930  //
931 
932  fvec Sx = (Fx0 * c2i + Fx1 * c6i + Fx2 * c12i);
933  fvec Sy = (Fy0 * c2i + Fy1 * c6i + Fy2 * c12i);
934  fvec Sz = (Fz0 * c2i + Fz1 * c6i + Fz2 * c12i);
935 
936  fvec Syz;
937  {
938  cnst d = 1. / 2520., c00 = 21. * 20. * d, c01 = 21. * 5. * d,
939  c02 = 21. * 2. * d, c10 = 7. * 30. * d, c11 = 7. * 9. * d,
940  c12 = 7. * 4. * d, c20 = 2. * 63. * d, c21 = 2. * 21. * d,
941  c22 = 2. * 10. * d;
942  Syz = Fy0 * (c00 * Fz0 + c01 * Fz1 + c02 * Fz2)
943  + Fy1 * (c10 * Fz0 + c11 * Fz1 + c12 * Fz2)
944  + Fy2 * (c20 * Fz0 + c21 * Fz1 + c22 * Fz2);
945  }
946 
947  fvec Syy;
948  {
949  cnst d = 1. / 2520., c00 = 420. * d, c01 = 21. * 15. * d,
950  c02 = 21. * 8. * d, c03 = 63. * d, c04 = 70. * d, c05 = 20. * d;
951  Syy = Fy0 * (c00 * Fy0 + c01 * Fy1 + c02 * Fy2)
952  + Fy1 * (c03 * Fy1 + c04 * Fy2) + c05 * Fy2 * Fy2;
953  }
954 
955  fvec Syyy;
956  {
957  cnst d = 1. / 181440., c000 = 7560 * d, c001 = 9 * 1008 * d,
958  c002 = 5 * 1008 * d, c011 = 21 * 180 * d, c012 = 24 * 180 * d,
959  c022 = 7 * 180 * d, c111 = 540 * d, c112 = 945 * d, c122 = 560 * d,
960  c222 = 112 * d;
961  fvec Fy22 = Fy2 * Fy2;
962  Syyy = Fy0
963  * (Fy0 * (c000 * Fy0 + c001 * Fy1 + c002 * Fy2)
964  + Fy1 * (c011 * Fy1 + c012 * Fy2) + c022 * Fy22)
965  + Fy1 * (Fy1 * (c111 * Fy1 + c112 * Fy2) + c122 * Fy22)
966  + c222 * Fy22 * Fy2;
967  }
968 
969  fvec SA1 = Sx * xy + Sy * Ay + Sz * y;
970  fvec SA1_x = Sx * y - Sy * x2;
971  fvec SA1_y = Sx * x + Sz;
972 
973  fvec SB1 = Sx * Bx - Sy * xy - Sz * x;
974  fvec SB1_x = -Sy * y - Sz;
975  fvec SB1_y = Sx * y2 - Sy * x;
976 
977  fvec SA2 = Syy * Ayy + Syz * Ayz;
978  fvec SA2_x = Syy * Ayy_x - Syz * y2;
979  fvec SA2_y = -Syz * x2;
980  fvec SB2 = Syy * Byy + Syz * Byz;
981  fvec SB2_x = Syy * Byy_x + Syz * x4;
982  fvec SB2_y = Syy * xx31;
983 
984  fvec SA3 = Syyy * Ayyy;
985  fvec SA3_x = Syyy * Ayyy_x;
986  fvec SB3 = Syyy * Byyy;
987  fvec SB3_x = Syyy * Byyy_x;
988  fvec SB3_y = Syyy * Byyy_y;
989 
990  fvec ht1 = ht * dz;
991  fvec ht2 = ht * ht * dz2;
992  fvec ht3 = ht * ht * ht * dz3;
993  fvec ht1SA1 = ht1 * SA1;
994  fvec ht1SB1 = ht1 * SB1;
995  fvec ht2SA2 = ht2 * SA2;
996  fvec ht2SB2 = ht2 * SB2;
997  fvec ht3SA3 = ht3 * SA3;
998  fvec ht3SB3 = ht3 * SB3;
999 
1000  extrDx = (x + ht1SA1 + ht2SA2 + ht3SA3) * dz;
1001  extrDy = (y + ht1SB1 + ht2SB2 + ht3SB3) * dz;
1002 
1003  fvec ctdz2 = c_light * t * dz2;
1004 
1005  fvec t2i = c1 * rcp(t2); // /t2;
1006  fvec xt2i = x * t2i;
1007  fvec yt2i = y * t2i;
1008  fvec tmp0 = ht1SA1 + c2 * ht2SA2 + c3 * ht3SA3;
1009  fvec tmp1 = ht1SB1 + c2 * ht2SB2 + c3 * ht3SB3;
1010 
1011  extrJ[0] =
1012  dz * (c1 + xt2i * tmp0 + ht1 * SA1_x + ht2 * SA2_x + ht3 * SA3_x); // j02
1013  extrJ[1] = dz * (yt2i * tmp0 + ht1 * SA1_y + ht2 * SA2_y); // j03
1014  extrJ[2] = ctdz2 * (SA1 + c2 * ht1 * SA2 + c3 * ht2 * SA3); // j04
1015  extrJ[3] =
1016  dz * (xt2i * tmp1 + ht1 * SB1_x + ht2 * SB2_x + ht3 * SB3_x); // j12
1017  extrJ[4] =
1018  dz * (c1 + yt2i * tmp1 + ht1 * SB1_y + ht2 * SB2_y + ht3 * SB3_y); // j13
1019  extrJ[5] = ctdz2 * (SB1 + c2 * ht1 * SB2 + c3 * ht2 * SB3); // j14
1020 }
1021 
1022 inline void L1ExtrapolateJXY0(fvec& tx,
1023  fvec& ty, // input track slopes
1024  fvec dz, // extrapolate to this dz position
1025  L1FieldRegion& F,
1026  fvec& extrDx,
1027  fvec& extrDy,
1028  fvec& J04,
1029  fvec& J14) {
1030  cnst c_light = 0.000299792458, c1 = 1., c2i = 0.5, c6i = 1. / 6.,
1031  c12i = 1. / 12.;
1032 
1033  fvec dz2 = dz * dz;
1034  fvec dzc6i = dz * c6i;
1035  fvec dz2c12i = dz2 * c12i;
1036 
1037  fvec xx = tx * tx;
1038  fvec yy = ty * ty;
1039  fvec xy = tx * ty;
1040 
1041  fvec Ay = -xx - c1;
1042  fvec Bx = yy + c1;
1043 
1044  fvec ctdz2 = c_light * sqrt(c1 + xx + yy) * dz2;
1045 
1046  fvec Sx = F.cx0 * c2i + F.cx1 * dzc6i + F.cx2 * dz2c12i;
1047  fvec Sy = F.cy0 * c2i + F.cy1 * dzc6i + F.cy2 * dz2c12i;
1048  fvec Sz = F.cz0 * c2i + F.cz1 * dzc6i + F.cz2 * dz2c12i;
1049 
1050  extrDx = (tx) *dz;
1051  extrDy = (ty) *dz;
1052  J04 = ctdz2 * (Sx * xy + Sy * Ay + Sz * ty);
1053  J14 = ctdz2 * (Sx * Bx - Sy * xy - Sz * tx);
1054 }
1055 
1056 #undef cnst
1057 
1058 #endif
L1ExtrapolateLine
void L1ExtrapolateLine(L1TrackPar &T, fvec z_out)
Definition: L1Extrapolation.h:814
L1TrackPar::C54
fvec C54
Definition: L1TrackPar.h:10
L1FieldRegion::cx1
fvec cx1
Definition: L1Field.h:112
L1ExtrapolateJXY0
void L1ExtrapolateJXY0(fvec &tx, fvec &ty, fvec dz, L1FieldRegion &F, fvec &extrDx, fvec &extrDy, fvec &J04, fvec &J14)
Definition: L1Extrapolation.h:1022
L1TrackPar::C10
fvec C10
Definition: L1TrackPar.h:9
L1TrackPar::qp
fvec qp
Definition: L1TrackPar.h:9
h
Generates beam ions for transport simulation.
Definition: CbmBeamGenerator.h:17
L1TrackPar::t
fvec t
Definition: L1TrackPar.h:9
L1TrackPar::C20
fvec C20
Definition: L1TrackPar.h:9
F32vec4
Definition: L1/vectors/P4_F32vec4.h:47
L1TrackPar::C41
fvec C41
Definition: L1TrackPar.h:10
L1TrackPar::C51
fvec C51
Definition: L1TrackPar.h:10
L1Field.h
sqrt
friend F32vec4 sqrt(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:41
L1TrackPar::C30
fvec C30
Definition: L1TrackPar.h:9
L1TrackPar::C31
fvec C31
Definition: L1TrackPar.h:9
L1TrackPar::C53
fvec C53
Definition: L1TrackPar.h:10
fvec
F32vec4 fvec
Definition: L1/vectors/P4_F32vec4.h:249
L1Extrapolate
void L1Extrapolate(L1TrackPar &T, fvec z_out, fvec qp0, const L1FieldRegion &F, fvec *w=0)
Definition: L1Extrapolation.h:314
rcp
friend F32vec4 rcp(const F32vec4 &a)
Definition: L1/vectors/P4_F32vec4.h:52
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
L1TrackPar::C42
fvec C42
Definition: L1TrackPar.h:10
L1FieldRegion::cz0
fvec cz0
Definition: L1Field.h:114
L1ExtrapolateC10Line
void L1ExtrapolateC10Line(const L1TrackPar &T, fvec z_out, fvec &C10)
Definition: L1Extrapolation.h:855
L1TrackPar::z
fvec z
Definition: L1TrackPar.h:9
L1TrackPar::ty
fvec ty
Definition: L1TrackPar.h:9
L1TrackPar::C32
fvec C32
Definition: L1TrackPar.h:9
L1TrackPar::y
fvec y
Definition: L1TrackPar.h:9
CbmL1Def.h
L1ExtrapolateTime
void L1ExtrapolateTime(L1TrackPar &T, fvec dz)
Definition: L1Extrapolation.h:781
L1TrackPar::C44
fvec C44
Definition: L1TrackPar.h:10
L1FieldRegion
Definition: L1Field.h:85
L1FieldRegion::cx2
fvec cx2
Definition: L1Field.h:112
L1ExtrapolateXC00Line
void L1ExtrapolateXC00Line(const L1TrackPar &T, fvec z_out, fvec &x, fvec &C00)
Definition: L1Extrapolation.h:842
L1FieldRegion::cz2
fvec cz2
Definition: L1Field.h:114
d
double d
Definition: P4_F64vec2.h:24
L1FieldRegion::cy0
fvec cy0
Definition: L1Field.h:113
L1ExtrapolateYC11Line
void L1ExtrapolateYC11Line(const L1TrackPar &T, fvec z_out, fvec &y, fvec &C11)
Definition: L1Extrapolation.h:849
L1TrackPar::tx
fvec tx
Definition: L1TrackPar.h:9
L1FieldRegion::cy2
fvec cy2
Definition: L1Field.h:113
L1TrackPar.h
NS_L1TrackFitter::c_light_i
const fvec c_light_i
Definition: L1TrackFitter.cxx:31
L1TrackPar::C50
fvec C50
Definition: L1TrackPar.h:10
L1TrackPar::C21
fvec C21
Definition: L1TrackPar.h:9
cnst
#define cnst
Definition: L1Extrapolation.h:10
L1TrackPar::x
fvec x
Definition: L1TrackPar.h:9
L1TrackPar::C00
fvec C00
Definition: L1TrackPar.h:9
L1TrackPar::C33
fvec C33
Definition: L1TrackPar.h:9
L1TrackPar::C52
fvec C52
Definition: L1TrackPar.h:10
L1FieldRegion::z0
fvec z0
Definition: L1Field.h:115
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
L1FieldRegion::cy1
fvec cy1
Definition: L1Field.h:113
L1TrackPar
Definition: L1TrackPar.h:6
L1TrackPar::C55
fvec C55
Definition: L1TrackPar.h:10
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
L1TrackPar::C40
fvec C40
Definition: L1TrackPar.h:10
L1TrackPar::C11
fvec C11
Definition: L1TrackPar.h:9
L1FieldRegion::cx0
fvec cx0
Definition: L1Field.h:112
L1FieldRegion::cz1
fvec cz1
Definition: L1Field.h:114
L1Extrapolate0
void L1Extrapolate0(L1TrackPar &T, fvec z_out, L1FieldRegion &F)
Definition: L1Extrapolation.h:681
L1TrackPar::C43
fvec C43
Definition: L1TrackPar.h:10
NS_L1TrackFitter::ZERO
const fvec ZERO
Definition: L1TrackFitter.cxx:32
L1ExtrapolateJXY
void L1ExtrapolateJXY(fvec &tx, fvec &ty, fvec &qp, fvec dz, L1FieldRegion &F, fvec &extrDx, fvec &extrDy, fvec extrJ[])
Definition: L1Extrapolation.h:861
NS_L1TrackFitter::ONE
const fvec ONE
Definition: L1TrackFitter.cxx:33
L1TrackPar::C22
fvec C22
Definition: L1TrackPar.h:9
NS_L1TrackFitter::c_light
const fvec c_light
Definition: L1TrackFitter.cxx:31