aab9c8d5 |
1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
3 | * * |
4 | * Author: The ALICE Off-line Project. * |
5 | * Contributors are mentioned in the code where appropriate. * |
6 | * * |
7 | * Permission to use, copy, modify and distribute this software and its * |
8 | * documentation strictly for non-commercial purposes is hereby granted * |
9 | * without fee, provided that the above copyright notice appears in all * |
10 | * copies and that both the copyright notice and this permission notice * |
11 | * appear in the supporting documentation. The authors make no claims * |
12 | * about the suitability of this software for any purpose. It is * |
13 | * provided "as is" without express or implied warranty. * |
14 | **************************************************************************/ |
15 | |
0742d588 |
16 | /* $Id$ */ |
116cbefd |
17 | |
2cad796f |
18 | #include "TVirtualMC.h" |
0742d588 |
19 | |
2d74ba4f |
20 | #include "AliRun.h" |
0742d588 |
21 | #include "AliTrackReference.h" |
ac3eaff4 |
22 | #include "AliExternalTrackParam.h" |
23 | #include "AliKalmanTrack.h" |
2d74ba4f |
24 | |
25 | // |
26 | // Track Reference object is created every time particle is |
27 | // crossing detector bounds. The object is created by Step Manager |
28 | // |
29 | // The class stores the following informations: |
30 | // track label, |
31 | // track position: X,Y,X |
32 | // track momentum px, py, pz |
33 | // track length and time of fligth: both in cm |
34 | // status bits from Monte Carlo |
35 | // |
36 | |
aab9c8d5 |
37 | |
38 | ClassImp(AliTrackReference) |
39 | |
e2afb3b6 |
40 | //_______________________________________________________________________ |
41 | AliTrackReference::AliTrackReference(): |
448312df |
42 | TObject(), |
e2afb3b6 |
43 | fTrack(0), |
44 | fX(0), |
45 | fY(0), |
46 | fZ(0), |
47 | fPx(0), |
48 | fPy(0), |
49 | fPz(0), |
448312df |
50 | fLength(0), |
3142ebc3 |
51 | fTime(0), |
52 | fUserId(0) |
aab9c8d5 |
53 | { |
54 | // |
55 | // Default constructor |
2d74ba4f |
56 | // Creates empty object |
57 | |
58 | for(Int_t i=0; i<16; i++) ResetBit(BIT(i)); |
59 | } |
60 | |
61 | //_______________________________________________________________________ |
448312df |
62 | AliTrackReference::AliTrackReference(Int_t label) : |
90e48c0c |
63 | TObject(), |
64 | fTrack(label), |
65 | fX(0), |
66 | fY(0), |
67 | fZ(0), |
68 | fPx(0), |
69 | fPy(0), |
70 | fPz(0), |
71 | fLength(gMC->TrackLength()), |
3142ebc3 |
72 | fTime(gMC->TrackTime()), |
73 | fUserId(0) |
448312df |
74 | { |
2d74ba4f |
75 | // |
76 | // Create Reference object out of label and |
77 | // data in TVirtualMC object |
78 | // |
79 | // Creates an object and fill all parameters |
80 | // from data in VirtualMC |
aab9c8d5 |
81 | // |
2d74ba4f |
82 | // Sylwester Radomski, (S.Radomski@gsi.de) |
83 | // GSI, Jan 31, 2003 |
84 | // |
2cad796f |
85 | |
90e48c0c |
86 | Double_t vec[4]; |
2d74ba4f |
87 | |
90e48c0c |
88 | gMC->TrackPosition(vec[0],vec[1],vec[2]); |
2d74ba4f |
89 | |
90 | fX = vec[0]; |
91 | fY = vec[1]; |
92 | fZ = vec[2]; |
93 | |
90e48c0c |
94 | gMC->TrackMomentum(vec[0],vec[1],vec[2],vec[3]); |
2d74ba4f |
95 | |
96 | fPx = vec[0]; |
97 | fPy = vec[1]; |
b745fc4c |
98 | fPz = vec[2]; |
2d74ba4f |
99 | |
100 | // Set Up status code |
101 | // Copy Bits from virtual MC |
102 | |
103 | for(Int_t i=0; i<16; i++) ResetBit(BIT(i)); |
104 | |
2cad796f |
105 | SetBit(BIT(0), gMC->IsNewTrack()); |
106 | SetBit(BIT(1), gMC->IsTrackAlive()); |
107 | SetBit(BIT(2), gMC->IsTrackDisappeared()); |
108 | SetBit(BIT(3), gMC->IsTrackEntering()); |
109 | SetBit(BIT(4), gMC->IsTrackExiting()); |
110 | SetBit(BIT(5), gMC->IsTrackInside()); |
111 | SetBit(BIT(6), gMC->IsTrackOut()); |
112 | SetBit(BIT(7), gMC->IsTrackStop()); |
aab9c8d5 |
113 | } |
2d74ba4f |
114 | //_______________________________________________________________________ |
ac3eaff4 |
115 | AliExternalTrackParam * AliTrackReference::MakeTrack(const AliTrackReference *ref, Double_t mass) |
116 | { |
117 | // |
118 | // Make dummy track from the track reference |
119 | // negative mass means opposite charge |
120 | // |
121 | Double_t xx[5]; |
122 | Double_t cc[15]; |
123 | for (Int_t i=0;i<15;i++) cc[i]=0; |
124 | Double_t x = ref->X(), y = ref->Y(), z = ref->Z(); |
125 | Double_t alpha = TMath::ATan2(y,x); |
126 | Double_t xr = TMath::Sqrt(x*x+y*y); |
127 | xx[0] = 0; |
128 | xx[1] = z; |
129 | xx[3] = ref->Pz()/ref->Pt(); |
c9ec41e8 |
130 | xx[4] = 1./ref->Pt(); |
ac3eaff4 |
131 | if (mass<0) xx[4]*=-1.; // negative mass - negative direction |
132 | Double_t alphap = TMath::ATan2(ref->Py(),ref->Px())-alpha; |
133 | if (alphap> TMath::Pi()) alphap-=TMath::Pi(); |
134 | if (alphap<-TMath::Pi()) alphap+=TMath::Pi(); |
135 | xx[2] = TMath::Sin(alphap); |
c9ec41e8 |
136 | |
ac3eaff4 |
137 | AliExternalTrackParam * track = new AliExternalTrackParam(xr,alpha,xx,cc); |
ac3eaff4 |
138 | return track; |
139 | } |
140 | |
141 | |