FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairTrackParP.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 // Class for the representation of a track as parabola (SD system)
9 //
10 // Authors: M. Al-Turany, A. Fontana, L. Lavezzi and A. Rotondi
11 //
12 //
13 // GEANE parameters (q/p, v', w', v, w) of Helix track
14 // The Helix can be constructed using the Helix parameter (1/p, v', w', v, w) in SC reference
15 // and the covariance matrix. Or using position and momentum in LAB referance.
16 
17 #include "FairTrackParP.h"
18 #include <TGenericClassInfo.h> // for TGenericClassInfo
19 #include <TMath.h> // for Sqrt
20 #include <TMathBase.h> // for Abs, Sign
21 #include <cmath> // for fabs
22 #include <iomanip> // for operator<<, setprecision
23 #include <iostream> // for operator<<, basic_ostream, endl, cout
24 #include "FairGeaneUtil.h" // for FairGeaneUtil
25 #include "FairTrackParH.h" // for FairTrackParH
26 
27 
28 using std::cout;
29 using std::endl;
30 
32 
34  : FairTrackPar()
35  , fU(0.)
36  , fV(0.)
37  , fW(0.)
38  , fTV(0.)
39  , fTW(0.)
40  , fPx_sd(0.)
41  , fPy_sd(0.)
42  , fPz_sd(0.)
43  , fDU(0.)
44  , fDV(0.)
45  , fDW(0.)
46  , fDTV(0.)
47  , fDTW(0.)
48  , forigin(TVector3(0, 0, 0))
49  , fiver(TVector3(0, 0, 0))
50  , fjver(TVector3(0, 0, 0))
51  , fkver(TVector3(0, 0, 0))
52  , fSPU(0.)
53 {
54  // Reset();
55  for (Int_t i = 0; i < 15; i++) {
56  fCovMatrix[i] = 0;
57  }
58  for (int i = 0; i < 6; i++)
59  for (int j = 0; j < 6; j++) {
60  fCovMatrix66[i][j] = 0;
61  }
62 }
63 
64 // Constructor with track parameters in SD
66  Double_t w,
67  Double_t Tv,
68  Double_t Tw,
69  Double_t qp,
70  Double_t CovMatrix[15],
71  TVector3 o,
72  TVector3 dj,
73  TVector3 dk)
74  : FairTrackPar()
75  , fU(0.)
76  , fV(v)
77  , fW(w)
78  , fTV(Tv)
79  , fTW(Tw)
80  , fPx_sd(0.)
81  , fPy_sd(0.)
82  , fPz_sd(0.)
83  , fDU(0.)
84  , fDV(0.)
85  , fDW(0.)
86  , fDTV(0.)
87  , fDTW(0.)
88  , forigin(TVector3(0, 0, 0))
89  , fiver(TVector3(0, 0, 0))
90  , fjver(TVector3(0, 0, 0))
91  , fkver(TVector3(0, 0, 0))
92  , fSPU(0.)
93 {
94  // Reset();
95  SetPlane(o, dj, dk);
96  // fV = v;
97  // fW = w;
98  // fTV = Tv;
99  // fTW = Tw;
100  fQp = qp;
101 
102  Double_t P = TMath::Abs(1 / fQp);
103  // fq= int (P * fQp);
104  fq = static_cast<int>(TMath::Sign(1.0, fQp));
105  for (Int_t i = 0; i < 15; i++) {
106  fCovMatrix[i] = CovMatrix[i];
107  }
108 
109  fPx_sd = TMath::Sqrt(P * P / (fTV * fTV + fTW * fTW + 1));
110  fPy_sd = fTV * fPx_sd;
111  fPz_sd = fTW * fPx_sd;
112 
113  // fU = 0.;
114 
115  FairGeaneUtil util;
116  TVector3 position = util.FromSDToMARSCoord(TVector3(fU, fV, fW), forigin, fiver, fjver, fkver);
117  fX = position.X();
118  fY = position.Y();
119  fZ = position.Z();
120 
121  fDQp = TMath::Sqrt(fabs(fCovMatrix[0]));
122  fDTV = TMath::Sqrt(fabs(fCovMatrix[5]));
123  fDTW = TMath::Sqrt(fabs(fCovMatrix[9]));
124  fDV = TMath::Sqrt(fabs(fCovMatrix[12]));
125  fDW = TMath::Sqrt(fabs(fCovMatrix[14]));
126 
127  Double_t PD[3], RD[6][6], H[3], PC[3], RC[15], SP1;
128  Int_t CH;
129  PC[0] = fQp;
130  PC[1] = fTV;
131  PC[2] = fTW;
132 
133  for (Int_t i = 0; i < 15; i++) {
134  RC[i] = fCovMatrix[i];
135  }
136 
137  // initialize RD
138  for (Int_t i = 0; i < 6; i++) {
139  for (Int_t k = 0; k < 6; k++) {
140  RD[i][k] = 0;
141  }
142  }
143 
144  // retrieve field
145  Double_t pnt[3];
146  pnt[0] = fX;
147  pnt[1] = fY;
148  pnt[2] = fZ;
149 
150  GetFieldValue(pnt, H);
151 
152  CH = fq;
153 
154  TVector3 momsd = TVector3(fPx_sd, fPy_sd, fPz_sd);
155  SP1 = (momsd.Dot(fjver.Cross(fkver))) / TMath::Abs(momsd.Dot(fjver.Cross(fkver)));
156  fSPU = SP1;
157 
158  util.FromSDToMars(PC, RC, H, CH, SP1, fDJ, fDK, PD, RD);
159 
160  fPx = PD[0];
161  fPy = PD[1];
162  fPz = PD[2];
163 
164  for (int i = 0; i < 6; i++)
165  for (int j = 0; j < 6; j++) {
166  fCovMatrix66[i][j] = RD[i][j];
167  }
168 
169  fDPx = TMath::Sqrt(fabs(RD[0][0]));
170  fDPy = TMath::Sqrt(fabs(RD[1][1]));
171  fDPz = TMath::Sqrt(fabs(RD[2][2]));
172  fDX = TMath::Sqrt(fabs(RD[3][3]));
173  fDY = TMath::Sqrt(fabs(RD[4][4]));
174  fDZ = TMath::Sqrt(fabs(RD[5][5]));
175 }
176 
177 // Constructor with track parameters in SD
179  Double_t w,
180  Double_t Tv,
181  Double_t Tw,
182  Double_t qp,
183  Double_t CovMatrix[15],
184  TVector3 o,
185  TVector3 dj,
186  TVector3 dk,
187  Double_t spu)
188  : FairTrackPar()
189  , fU(0.)
190  , fV(v)
191  , fW(w)
192  , fTV(Tv)
193  , fTW(Tw)
194  , fPx_sd(0.)
195  , fPy_sd(0.)
196  , fPz_sd(0.)
197  , fDU(0.)
198  , fDV(0.)
199  , fDW(0.)
200  , fDTV(0.)
201  , fDTW(0.)
202  , forigin(TVector3(0, 0, 0))
203  , fiver(TVector3(0, 0, 0))
204  , fjver(TVector3(0, 0, 0))
205  , fkver(TVector3(0, 0, 0))
206  , fSPU(spu)
207 
208 {
209  // Reset();
210  SetPlane(o, dj, dk);
211  // fV = v;
212  // fW = w;
213  // fTV = Tv;
214  // fTW = Tw;
215  fQp = qp;
216  // fSPU = spu;
217  Double_t P = 0;
218  if (0 != fQp) {
219  P = TMath::Abs(1 / fQp);
220  fq = static_cast<int>(TMath::Sign(1.0, fQp));
221  // fq= int (P * fQp);
222  } else {
223  fq = 1;
224  }
225  for (Int_t i = 0; i < 15; i++) {
226  fCovMatrix[i] = CovMatrix[i];
227  }
228 
229  fPx_sd = fSPU * TMath::Sqrt(P * P / (fTV * fTV + fTW * fTW + 1));
230  fPy_sd = fTV * fPx_sd;
231  fPz_sd = fTW * fPx_sd;
232 
233  // fU = 0.;
234 
235  FairGeaneUtil util;
236  TVector3 position = util.FromSDToMARSCoord(TVector3(fU, fV, fW), forigin, fiver, fjver, fkver);
237  fX = position.X();
238  fY = position.Y();
239  fZ = position.Z();
240 
241  fDQp = TMath::Sqrt(fabs(fCovMatrix[0]));
242  fDTV = TMath::Sqrt(fabs(fCovMatrix[5]));
243  fDTW = TMath::Sqrt(fabs(fCovMatrix[9]));
244  fDV = TMath::Sqrt(fabs(fCovMatrix[12]));
245  fDW = TMath::Sqrt(fabs(fCovMatrix[14]));
246 
247  Double_t PD[3], RD[6][6], H[3], PC[3], RC[15], SP1;
248  Int_t CH;
249  PC[0] = fQp;
250  PC[1] = fTV;
251  PC[2] = fTW;
252 
253  // initialize RD
254  for (Int_t i = 0; i < 6; i++) {
255  for (Int_t k = 0; k < 6; k++) {
256  RD[i][k] = 0;
257  }
258  }
259 
260  for (Int_t i = 0; i < 15; i++) {
261  RC[i] = fCovMatrix[i];
262  }
263 
264  // retrieve field
265  Double_t pnt[3];
266  pnt[0] = fX;
267  pnt[1] = fY;
268  pnt[2] = fZ;
269 
270  GetFieldValue(pnt, H);
271 
272  CH = fq;
273 
274  TVector3 momsd = TVector3(fPx_sd, fPy_sd, fPz_sd);
275  // SP1 = (momsd.Dot(fjver.Cross(fkver)))/TMath::Abs(momsd.Dot(fjver.Cross(fkver)));
276  SP1 = fSPU; // correct calculation of SP1
277 
278  util.FromSDToMars(PC, RC, H, CH, SP1, fDJ, fDK, PD, RD);
279 
280  fPx = PD[0];
281  fPy = PD[1];
282  fPz = PD[2];
283 
284  for (int i = 0; i < 6; i++)
285  for (int j = 0; j < 6; j++) {
286  fCovMatrix66[i][j] = RD[i][j];
287  }
288 
289  fDPx = TMath::Sqrt(fabs(RD[0][0]));
290  fDPy = TMath::Sqrt(fabs(RD[1][1]));
291  fDPz = TMath::Sqrt(fabs(RD[2][2]));
292  fDX = TMath::Sqrt(fabs(RD[3][3]));
293  fDY = TMath::Sqrt(fabs(RD[4][4]));
294  fDZ = TMath::Sqrt(fabs(RD[5][5]));
295 }
296 
297 // Constructor with track parameters in LAB
299  TVector3 Mom,
300  TVector3 posErr,
301  TVector3 MomErr,
302  Int_t Q,
303  TVector3 o,
304  TVector3 dj,
305  TVector3 dk)
306  : FairTrackPar(pos.x(), pos.y(), pos.z(), Mom.x(), Mom.y(), Mom.z(), Q)
307  , fU(0.)
308  , fV(0)
309  , fW(0)
310  , fTV(0)
311  , fTW(0)
312  , fPx_sd(0.)
313  , fPy_sd(0.)
314  , fPz_sd(0.)
315  , fDU(0.)
316  , fDV(0.)
317  , fDW(0.)
318  , fDTV(0.)
319  , fDTW(0.)
320  , forigin(TVector3(0, 0, 0))
321  , fiver(TVector3(0, 0, 0))
322  , fjver(TVector3(0, 0, 0))
323  , fkver(TVector3(0, 0, 0))
324  , fSPU(0.)
325 {
326  // Reset();
327  SetPlane(o, dj, dk);
328 
329  SetPx(Mom.x());
330  SetPy(Mom.y());
331  SetPz(Mom.z());
332 
333  SetX(pos.x()); // x (lab)
334  SetY(pos.y()); // y (lab)
335  SetZ(pos.z()); // z (lab)
336  Double_t P = TMath::Sqrt(fPx * fPx + fPy * fPy + fPz * fPz);
337  if (Q != 0) {
338  fq = Q / TMath::Abs(Q);
339  }
340 
341  FairGeaneUtil util;
342  TVector3 positionsd = util.FromMARSToSDCoord(TVector3(fX, fY, fZ), forigin, fiver, fjver, fkver);
343  fU = positionsd.X();
344  fV = positionsd.Y();
345  fW = positionsd.Z();
346  fQp = fq / P;
347 
348  fDPx = MomErr.x(); // dpx
349  fDPy = MomErr.y(); // dpy
350  fDPz = MomErr.z(); // dpz
351  fDX = posErr.x(); // dpx
352  fDY = posErr.y(); // dpy
353  fDZ = posErr.z(); // dpz
354 
355  Double_t PD[3], RD[6][6], H[3], SP1, PC[3], RC[15];
356 
357  Int_t CH, IERR;
358 
359  PD[0] = fPx;
360  PD[1] = fPy;
361  PD[2] = fPz;
362 
363  for (int i = 0; i < 6; i++)
364  for (int j = 0; j < 6; j++) {
365  RD[i][j] = 0.;
366  }
367  RD[0][0] = fDPx * fDPx;
368  RD[1][1] = fDPy * fDPy;
369  RD[2][2] = fDPz * fDPz;
370  RD[3][3] = fDX * fDX;
371  RD[4][4] = fDY * fDY;
372  RD[5][5] = fDZ * fDZ;
373 
374  for (int i = 0; i < 6; i++)
375  for (int j = 0; j < 6; j++) {
376  fCovMatrix66[i][j] = RD[i][j];
377  }
378 
379  // retrieve field
380  Double_t pnt[3];
381  pnt[0] = fX;
382  pnt[1] = fY;
383  pnt[2] = fZ;
384 
385  GetFieldValue(pnt, H);
386 
387  CH = fq;
388 
389  util.FromMarsToSD(PD, RD, H, CH, fDJ, fDK, IERR, SP1, PC, RC);
390 
391  for (Int_t i = 0; i < 15; i++) {
392  fCovMatrix[i] = RC[i];
393  }
394 
395  fTV = PC[1];
396  fTW = PC[2];
397 
398  fDQp = TMath::Sqrt(fabs(fCovMatrix[0]));
399  fDTV = TMath::Sqrt(fabs(fCovMatrix[5]));
400  fDTW = TMath::Sqrt(fabs(fCovMatrix[9]));
401  fDV = TMath::Sqrt(fabs(fCovMatrix[12]));
402  fDW = TMath::Sqrt(fabs(fCovMatrix[14]));
403 
404  fSPU = SP1;
405 
406  fPx_sd = fSPU * TMath::Sqrt(P * P / (fTV * fTV + fTW * fTW + 1));
407  fPy_sd = fTV * fPx_sd;
408  fPz_sd = fTW * fPx_sd;
409 }
410 
411 // Constructor with track parameters in LAB (with complete covariance matrix in MARS)
413  TVector3 Mom,
414  Double_t covMARS[6][6],
415  Int_t Q,
416  TVector3 o,
417  TVector3 dj,
418  TVector3 dk)
419  : FairTrackPar(pos.x(), pos.y(), pos.z(), Mom.x(), Mom.y(), Mom.z(), Q)
420  , fU(0.)
421  , fV(0)
422  , fW(0)
423  , fTV(0)
424  , fTW(0)
425  , fPx_sd(0.)
426  , fPy_sd(0.)
427  , fPz_sd(0.)
428  , fDU(0.)
429  , fDV(0.)
430  , fDW(0.)
431  , fDTV(0.)
432  , fDTW(0.)
433  , forigin(TVector3(0, 0, 0))
434  , fiver(TVector3(0, 0, 0))
435  , fjver(TVector3(0, 0, 0))
436  , fkver(TVector3(0, 0, 0))
437  , fSPU(0.)
438 {
439  // Reset();
440  SetPlane(o, dj, dk);
441 
442  SetPx(Mom.x());
443  SetPy(Mom.y());
444  SetPz(Mom.z());
445 
446  SetX(pos.x()); // x (lab)
447  SetY(pos.y()); // y (lab)
448  SetZ(pos.z()); // z (lab)
449  Double_t P = TMath::Sqrt(fPx * fPx + fPy * fPy + fPz * fPz);
450  if (Q != 0) {
451  fq = Q / TMath::Abs(Q);
452  }
453 
454  FairGeaneUtil util;
455  TVector3 positionsd = util.FromMARSToSDCoord(TVector3(fX, fY, fZ), forigin, fiver, fjver, fkver);
456  fU = positionsd.X();
457  fV = positionsd.Y();
458  fW = positionsd.Z();
459  fQp = fq / P;
460 
461  fDPx = TMath::Sqrt(fabs(covMARS[0][0])); // dpx
462  fDPy = TMath::Sqrt(fabs(covMARS[1][1])); // dpy
463  fDPz = TMath::Sqrt(fabs(covMARS[2][2])); // dpz
464  fDX = TMath::Sqrt(fabs(covMARS[3][3])); // dpx
465  fDY = TMath::Sqrt(fabs(covMARS[4][4])); // dpy
466  fDZ = TMath::Sqrt(fabs(covMARS[5][5])); // dpz
467 
468  Double_t PD[3], RD[6][6], H[3], SP1, PC[3], RC[15];
469  Int_t IERR, CH;
470 
471  PD[0] = fPx;
472  PD[1] = fPy;
473  PD[2] = fPz;
474 
475  for (int i = 0; i < 6; i++)
476  for (int j = 0; j < 6; j++) {
477  RD[i][j] = covMARS[i][j];
478  }
479  for (int i = 0; i < 6; i++)
480  for (int j = 0; j < 6; j++) {
481  fCovMatrix66[i][j] = RD[i][j];
482  }
483 
484  // retrieve field
485  Double_t pnt[3];
486  pnt[0] = fX;
487  pnt[1] = fY;
488  pnt[2] = fZ;
489 
490  GetFieldValue(pnt, H);
491 
492  CH = fq;
493 
494  util.FromMarsToSD(PD, RD, H, CH, fDJ, fDK, IERR, SP1, PC, RC);
495 
496  for (Int_t i = 0; i < 15; i++) {
497  fCovMatrix[i] = RC[i];
498  }
499 
500  fTV = PC[1];
501  fTW = PC[2];
502 
503  fDQp = TMath::Sqrt(fabs(fCovMatrix[0]));
504  fDTV = TMath::Sqrt(fabs(fCovMatrix[5]));
505  fDTW = TMath::Sqrt(fabs(fCovMatrix[9]));
506  fDV = TMath::Sqrt(fabs(fCovMatrix[12]));
507  fDW = TMath::Sqrt(fabs(fCovMatrix[14]));
508 
509  fSPU = SP1;
510 
511  fPx_sd = fSPU * TMath::Sqrt(P * P / (fTV * fTV + fTW * fTW + 1));
512  fPy_sd = fTV * fPx_sd;
513  fPz_sd = fTW * fPx_sd;
514 }
515 
516 // ctor from helix to parabola ---------------------------------------------------------------
517 // -- WARNING -- please pay attention to choose a plane which DOES NOT CONTAIN the TRACK, i.e.
518 // the plane normal axis u MUST NOT BE ORTHOGONAL to the particle momentum. If this happens
519 // you will get an error flag:
520 // IERR = 1 [when the particle moves perpendicular to u-axis (i.e. ON the CHOSEN PLANE)
521 // ==> v', w' are not definded.]
522 FairTrackParP::FairTrackParP(FairTrackParH* helix, TVector3 dj, TVector3 dk, Int_t& ierr)
523  : FairTrackPar()
524  , fU(0.)
525  , fV(0)
526  , fW(0)
527  , fTV(0)
528  , fTW(0)
529  , fPx_sd(0.)
530  , fPy_sd(0.)
531  , fPz_sd(0.)
532  , fDU(0.)
533  , fDV(0.)
534  , fDW(0.)
535  , fDTV(0.)
536  , fDTW(0.)
537  , forigin(TVector3(0, 0, 0))
538  , fiver(TVector3(0, 0, 0))
539  , fjver(TVector3(0, 0, 0))
540  , fkver(TVector3(0, 0, 0))
541  , fSPU(0.)
542 {
543 
544  // q/p, lambda, phi --> q/p, v', w'
545  Double_t PC[3] = {helix->GetQp(), helix->GetLambda(), helix->GetPhi()};
546  Double_t RC[15];
547  helix->GetCov(RC);
548  // retrieve field
549  TVector3 xyz(helix->GetX(), helix->GetY(), helix->GetZ());
550  Double_t H[3], pnt[3];
551  pnt[0] = xyz.X();
552  pnt[1] = xyz.Y();
553  pnt[2] = xyz.Z();
554 
555  GetFieldValue(pnt, H);
556 
557  Int_t CH = helix->GetQ();
558 
559  Double_t DJ[3] = {dj.X(), dj.Y(), dj.Z()};
560  Double_t DK[3] = {dk.X(), dk.Y(), dk.Z()};
561 
562  Int_t IERR = 0;
563  Double_t SPU = 0;
564  Double_t PD[3], RD[15];
565 
566  FairGeaneUtil util;
567  util.FromSCToSD(PC, RC, H, CH, DJ, DK, IERR, SPU, PD, RD);
568 
569  ierr = IERR;
570 
571  // MARS coordinates
572  TVector3 o(xyz.X(), xyz.Y(), xyz.Z());
573  TVector3 di = dj.Cross(dk);
574  TVector3 uvm = util.FromMARSToSDCoord(xyz, o, di, dj, dk);
575 
576  if (ierr == 0)
577  SetTrackPar(uvm.Y(), uvm.Z(), PD[1], PD[2], PD[0], RD, o, di, dj, dk, SPU);
578  else {
579  cout << "FairTrackParP(FairTrackParH *) contructor ERROR: CANNOT convert helix to parabola" << endl;
580  }
581 }
582 
583 // define track in LAB
585  Double_t Y,
586  Double_t Z,
587  Double_t Px,
588  Double_t Py,
589  Double_t Pz,
590  Int_t Q,
591  Double_t CovMatrix[15],
592  TVector3 o,
593  TVector3 /*di*/,
594  TVector3 dj,
595  TVector3 dk)
596 {
597  Reset();
598  SetPlane(o, dj, dk);
599 
600  Double_t P = TMath::Sqrt(Px * Px + Py * Py + Pz * Pz);
601 
602  if (Q != 0) {
603  fq = TMath::Abs(Q) / Q;
604  }
605  fQp = fq / P;
606 
607  SetX(X);
608  SetY(Y);
609  SetZ(Z);
610 
611  SetPx(Px);
612  SetPy(Py);
613  SetPz(Pz);
614 
615  for (Int_t i = 0; i < 15; i++) {
616  fCovMatrix[i] = CovMatrix[i];
617  }
618 
619  FairGeaneUtil util;
620 
621  TVector3 positionsd = util.FromMARSToSDCoord(TVector3(fX, fY, fZ), forigin, fiver, fjver, fkver);
622  fU = positionsd.X();
623  fV = positionsd.Y();
624  fW = positionsd.Z();
625  fQp = fq / P;
626 
627  Double_t PD[3], RD[6][6], H[3], SP1, PC[3], RC[15];
628  Int_t IERR, CH;
629  PD[0] = Px;
630  PD[1] = Py;
631  PD[2] = Pz;
632 
633  for (int i = 0; i < 6; i++)
634  for (int j = 0; j < 6; j++) {
635  RD[i][j] = 0.;
636  }
637  // retrieve field
638  Double_t pnt[3];
639  pnt[0] = fX;
640  pnt[1] = fY;
641  pnt[2] = fZ;
642 
643  GetFieldValue(pnt, H);
644 
645  CH = fq;
646  util.FromMarsToSD(PD, RD, H, CH, fDJ, fDK, IERR, SP1, PC, RC);
647  fTV = PC[1];
648  fTW = PC[2];
649 
650  fDQp = TMath::Sqrt(fabs(fCovMatrix[0]));
651  fDTV = TMath::Sqrt(fabs(fCovMatrix[5]));
652  fDTW = TMath::Sqrt(fabs(fCovMatrix[9]));
653  fDV = TMath::Sqrt(fabs(fCovMatrix[12]));
654  fDW = TMath::Sqrt(fabs(fCovMatrix[14]));
655 
656  for (Int_t i = 0; i < 15; i++) {
657  RC[i] = fCovMatrix[i];
658  }
659 
660  util.FromSDToMars(PC, RC, H, CH, SP1, fDJ, fDK, PD, RD);
661 
662  for (int i = 0; i < 6; i++)
663  for (int j = 0; j < 6; j++) {
664  fCovMatrix66[i][j] = RD[i][j];
665  }
666 
667  fDPx = TMath::Sqrt(fabs(RD[0][0]));
668  fDPy = TMath::Sqrt(fabs(RD[1][1]));
669  fDPz = TMath::Sqrt(fabs(RD[2][2]));
670  fDX = TMath::Sqrt(fabs(RD[3][3]));
671  fDY = TMath::Sqrt(fabs(RD[4][4]));
672  fDZ = TMath::Sqrt(fabs(RD[5][5]));
673 
674  fSPU = SP1;
675 }
676 
677 // define track in SD
679  Double_t w,
680  Double_t Tv,
681  Double_t Tw,
682  Double_t qp,
683  Double_t CovMatrix[15],
684  TVector3 o,
685  TVector3 /*di*/,
686  TVector3 dj,
687  TVector3 dk,
688  Double_t spu)
689 {
690  Reset();
691  SetPlane(o, dj, dk);
692  fU = 0;
693  fV = v;
694  fW = w;
695  fTV = Tv;
696  fTW = Tw;
697  fQp = qp;
698  fSPU = spu;
699 
700  Double_t P = TMath::Abs(1 / fQp);
701  // fq= int (P * fQp);
702  fq = static_cast<int>(TMath::Sign(1.0, fQp));
703  for (Int_t i = 0; i < 15; i++) {
704  fCovMatrix[i] = CovMatrix[i];
705  }
706 
707  fPx_sd = fSPU * TMath::Sqrt(P * P / (fTV * fTV + fTW * fTW + 1));
708  fPy_sd = fTV * fPx_sd;
709  fPz_sd = fTW * fPx_sd;
710 
711  FairGeaneUtil util;
712  TVector3 position = util.FromSDToMARSCoord(TVector3(fU, fV, fW), forigin, fiver, fjver, fkver);
713  fX = position.X();
714  fY = position.Y();
715  fZ = position.Z();
716 
717  fDQp = TMath::Sqrt(fabs(fCovMatrix[0]));
718  fDTV = TMath::Sqrt(fabs(fCovMatrix[5]));
719  fDTW = TMath::Sqrt(fabs(fCovMatrix[9]));
720  fDV = TMath::Sqrt(fabs(fCovMatrix[12]));
721  fDW = TMath::Sqrt(fabs(fCovMatrix[14]));
722 
723  Double_t PD[3], RD[6][6], H[3], PC[3], RC[15], SP1;
724  Int_t CH;
725  PC[0] = fQp;
726  PC[1] = fTV;
727  PC[2] = fTW;
728 
729  for (Int_t i = 0; i < 15; i++) {
730  RC[i] = fCovMatrix[i];
731  }
732 
733  // initialize RD
734  for (Int_t i = 0; i < 6; i++) {
735  for (Int_t k = 0; k < 6; k++) {
736  RD[i][k] = 0;
737  }
738  }
739 
740  // retrieve field
741  Double_t pnt[3];
742  pnt[0] = fX;
743  pnt[1] = fY;
744  pnt[2] = fZ;
745 
746  GetFieldValue(pnt, H);
747 
748  CH = fq;
749 
750  TVector3 momsd = TVector3(fPx_sd, fPy_sd, fPz_sd);
751  // SP1 = (momsd.Dot(fjver.Cross(fkver)))/TMath::Abs(momsd.Dot(fjver.Cross(fkver)));
752  SP1 = fSPU;
753 
754  util.FromSDToMars(PC, RC, H, CH, SP1, fDJ, fDK, PD, RD);
755 
756  fPx = PD[0];
757  fPy = PD[1];
758  fPz = PD[2];
759 
760  for (int i = 0; i < 6; i++)
761  for (int j = 0; j < 6; j++) {
762  fCovMatrix66[i][j] = RD[i][j];
763  }
764 
765  fDPx = TMath::Sqrt(fabs(RD[0][0]));
766  fDPy = TMath::Sqrt(fabs(RD[1][1]));
767  fDPz = TMath::Sqrt(fabs(RD[2][2]));
768  fDX = TMath::Sqrt(fabs(RD[3][3]));
769  fDY = TMath::Sqrt(fabs(RD[4][4]));
770  fDZ = TMath::Sqrt(fabs(RD[5][5]));
771 }
772 
773 void FairTrackParP::CalCov()
774 {
775  // not needed
776 }
777 
779 
780 void FairTrackParP::Print(Option_t* /*option*/) const
781 {
782  cout << "Position : (";
783  cout << std::setprecision(2) << fX << ", " << fY << ", " << fZ << ")" << endl;
784  cout << std::setprecision(2) << "Slopes : dx/dz = " << fTV << ", dy/dz = " << fTW << endl;
785  cout << std::setprecision(2) << "q/p = " << fQp << endl;
786 }
787 
788 /*Double_t FairTrackParP::GetDX()
789 { return fDX; }
790 Double_t FairTrackParP::GetDY()
791 { return fDY; }
792 Double_t FairTrackParP::GetDZ()
793 { return fDZ; }
794 */
795 
796 Double_t FairTrackParP::GetV() { return fV; }
797 
798 Double_t FairTrackParP::GetW() { return fW; }
799 
800 Double_t FairTrackParP::GetTV() { return fTV; }
801 
802 Double_t FairTrackParP::GetTW() { return fTW; }
803 
804 Double_t FairTrackParP::GetDV() { return fDV; }
805 
806 Double_t FairTrackParP::GetDW() { return fDW; }
807 
808 Double_t FairTrackParP::GetDTV() { return fDTV; }
809 
810 Double_t FairTrackParP::GetDTW() { return fDTW; }
811 /*
812 Double_t FairTrackParP::GetX()
813 {
814  return fX;
815 }
816 Double_t FairTrackParP::GetY()
817 {
818  return fY;
819 }
820 
821 Double_t FairTrackParP::GetZ()
822 {
823  return fZ;
824 }
825 
826 Double_t FairTrackParP::GetDPx()
827 {
828  return fDPx;
829 }
830 
831 Double_t FairTrackParP::GetDPy()
832 {
833  return fDPy;
834 }
835 
836 Double_t FairTrackParP::GetDPz()
837 {
838  return fDPz;
839 }
840 
841 Double_t FairTrackParP::GetDQp()
842 {
843  return fDQp;
844 }
845 */
846 TVector3 FairTrackParP::GetOrigin() { return forigin; }
847 
848 TVector3 FairTrackParP::GetIVer() { return fiver; }
849 
850 TVector3 FairTrackParP::GetJVer() { return fjver; }
851 
852 TVector3 FairTrackParP::GetKVer() { return fkver; }
853 
855 {
856  fU = 0.;
857  fV = 0.;
858  fW = 0.;
859  fTV = 0.;
860  fTW = 0.;
861  fDV = 0.;
862  fDW = 0.;
863  fDTV = 0.;
864  fDTW = 0.;
865  for (Int_t i = 0; i < 15; i++) {
866  fCovMatrix[i] = 0.;
867  }
868  fPx_sd = 0.;
869  fPy_sd = 0.;
870  fPz_sd = 0.;
871 
872  // base class members
873  fX = fY = fZ = 0.;
874  fDX = fDY = fDZ = 0.;
875  fPx = fPy = fPz = 0.;
876  fDPx = fDPy = fDPz = 0.;
877  fQp = fDQp = fq = 0;
878 }
879 
880 void FairTrackParP::SetPlane(TVector3 o, TVector3 j, TVector3 k)
881 {
882  // origin
883  forigin = TVector3(o.X(), o.Y(), o.Z());
884 
885  // check unity
886  j.SetMag(1.);
887  k.SetMag(1.);
888  // check orthogonality
889  if (j * k != 0) {
890 
891  k = (j.Cross(k)).Cross(j);
892  }
893 
894  // plane
895  // i
896  TVector3 i = j.Cross(k);
897  i.SetMag(1.);
898  fDI[0] = i.X();
899  fDI[1] = i.Y();
900  fDI[2] = i.Z();
901  fiver = TVector3(fDI[0], fDI[1], fDI[2]);
902  // j
903  fDJ[0] = j.X();
904  fDJ[1] = j.Y();
905  fDJ[2] = j.Z();
906  fjver = TVector3(fDJ[0], fDJ[1], fDJ[2]);
907  // k
908  fDK[0] = k.X();
909  fDK[1] = k.Y();
910  fDK[2] = k.Z();
911  fkver = TVector3(fDK[0], fDK[1], fDK[2]);
912 }
913 
914 void FairTrackParP::SetTransportMatrix(Double_t mat[][5])
915 {
916  for (int i = 0; i < 5; i++)
917  for (int j = 0; j < 5; j++) {
918  ftrmat[i][j] = mat[i][j];
919  }
920 }
921 
922 void FairTrackParP::GetTransportMatrix(Double_t mat[][5])
923 {
924  for (int i = 0; i < 5; i++)
925  for (int j = 0; j < 5; j++) {
926  mat[i][j] = ftrmat[i][j];
927  }
928 }
929 
930 void FairTrackParP::GetCovQ(Double_t* CovQ)
931 {
932  // return error matrix in 1/p instead of q/p
933 
934  for (int i = 0; i < 15; i++) {
935  CovQ[i] = fCovMatrix[i];
936  if (fq != 0) {
937  if (i == 0) {
938  CovQ[i] = CovQ[i] / (fq * fq);
939  }
940  if (i > 0 && i < 5) {
941  CovQ[i] = CovQ[i] / fq;
942  }
943  }
944  }
945 }
virtual void Print(Option_t *option="") const
void FromMarsToSD(Double_t PD[3], Double_t RD[6][6], Double_t H[3], Int_t CH, Double_t DJ1[3], Double_t DK1[3], Int_t &IERR, Double_t &SP1, Double_t *PC, Double_t *RC)
void FromSDToMars(Double_t PC[3], Double_t RC[15], Double_t H[3], Int_t CH, Double_t SP1, Double_t DJ1[3], Double_t DK1[3], Double_t *PD, sixMat &RD)
Double_t fQp
Definition: FairTrackPar.h:124
void SetPlane(TVector3 o, TVector3 dj, TVector3 dk)
Double_t GetDTW()
Double_t fPz
Definition: FairTrackPar.h:118
virtual Double_t GetQp() const
Definition: FairTrackPar.h:63
virtual ~FairTrackParP()
Double_t GetDTV()
Double_t GetLambda()
Definition: FairTrackParH.h:64
virtual void GetFieldValue(const Double_t point[3], Double_t *bField)
virtual void SetPy(Double_t py)
Definition: FairTrackPar.h:81
Double_t fY
Definition: FairTrackPar.h:112
Double_t GetY()
Double_t GetW()
Double_t fDPx
Definition: FairTrackPar.h:121
ClassImp(FairEventBuilder)
void SetTrackPar(Double_t X, Double_t Y, Double_t Z, Double_t Px, Double_t Py, Double_t Pz, Int_t Q, Double_t CovMatrix[15], TVector3 o, TVector3 di, TVector3 dj, TVector3 dk)
virtual void SetY(Double_t y)
Definition: FairTrackPar.h:73
Double_t fDPz
Definition: FairTrackPar.h:121
Double_t fZ
Definition: FairTrackPar.h:112
Double_t GetV()
Double_t fX
Definition: FairTrackPar.h:112
Double_t fPx
Definition: FairTrackPar.h:118
Double_t fDX
Definition: FairTrackPar.h:115
Double_t GetTW()
Double_t GetX()
virtual void SetZ(Double_t z)
Definition: FairTrackPar.h:74
TVector3 GetJVer()
Double_t GetZ()
TVector3 FromMARSToSDCoord(TVector3 xyz, TVector3 o, TVector3 di, TVector3 dj, TVector3 dk)
void GetTransportMatrix(Double_t mat[5][5])
TVector3 FromSDToMARSCoord(TVector3 uvw, TVector3 o, TVector3 di, TVector3 dj, TVector3 dk)
virtual void SetPz(Double_t pz)
Definition: FairTrackPar.h:82
virtual void SetPx(Double_t px)
Definition: FairTrackPar.h:80
Double_t GetDV()
void GetCov(Double_t *Cov)
Definition: FairTrackParH.h:69
Int_t GetQ() const
Definition: FairTrackPar.h:52
Double_t fPy
Definition: FairTrackPar.h:118
void FromSCToSD(Double_t PC[3], Double_t RC[15], Double_t H[3], Int_t CH, Double_t DJ[3], Double_t DK[3], Int_t &IERR, Double_t &SPU, Double_t *PD, Double_t *RD)
Double_t GetPhi()
Definition: FairTrackParH.h:65
TVector3 GetIVer()
Double_t fDZ
Definition: FairTrackPar.h:115
virtual void SetX(Double_t x)
Definition: FairTrackPar.h:72
Double_t fDPy
Definition: FairTrackPar.h:121
Double_t GetTV()
void SetTransportMatrix(Double_t mat[5][5])
Double_t GetDW()
Double_t fDY
Definition: FairTrackPar.h:115
TVector3 GetKVer()
Double_t fDQp
Definition: FairTrackPar.h:127
TVector3 GetOrigin()
void GetCovQ(Double_t *CovQ)