AliStack.h not needed.
[u/mrichter/AliRoot.git] / STEER / AliTrackReference.cxx
CommitLineData
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"
9ac3aec9 19#include "TParticle.h"
0742d588 20
0742d588 21#include "AliTrackReference.h"
ac3eaff4 22#include "AliExternalTrackParam.h"
23#include "AliKalmanTrack.h"
65b311b3 24#include <Riostream.h>
2d74ba4f 25
26//
27// Track Reference object is created every time particle is
28// crossing detector bounds. The object is created by Step Manager
29//
30// The class stores the following informations:
31// track label,
32// track position: X,Y,X
33// track momentum px, py, pz
34// track length and time of fligth: both in cm
35// status bits from Monte Carlo
36//
37
aab9c8d5 38
39ClassImp(AliTrackReference)
40
e2afb3b6 41//_______________________________________________________________________
42 AliTrackReference::AliTrackReference():
448312df 43 TObject(),
e2afb3b6 44 fTrack(0),
45 fX(0),
46 fY(0),
47 fZ(0),
48 fPx(0),
49 fPy(0),
50 fPz(0),
448312df 51 fLength(0),
3142ebc3 52 fTime(0),
9ac3aec9 53 fUserId(0),
54 fDetectorId(-999)
aab9c8d5 55{
56 //
57 // Default constructor
2d74ba4f 58 // Creates empty object
59
60 for(Int_t i=0; i<16; i++) ResetBit(BIT(i));
61}
62
9ac3aec9 63AliTrackReference::AliTrackReference(const AliTrackReference &tr) :
64 TObject(),
65 fTrack(tr.fTrack),
66 fX(tr.fX),
67 fY(tr.fY),
68 fZ(tr.fZ),
69 fPx(tr.fPx),
70 fPy(tr.fPy),
71 fPz(tr.fPz),
72 fLength(tr.fLength),
73 fTime(tr.fTime),
74 fUserId(tr.fUserId),
75 fDetectorId(tr.fDetectorId)
76{
77 // Copy Constructor
78}
79
2d74ba4f 80//_______________________________________________________________________
9ac3aec9 81AliTrackReference::AliTrackReference(Int_t label, Int_t id) :
90e48c0c 82 TObject(),
83 fTrack(label),
84 fX(0),
85 fY(0),
86 fZ(0),
87 fPx(0),
88 fPy(0),
89 fPz(0),
90 fLength(gMC->TrackLength()),
3142ebc3 91 fTime(gMC->TrackTime()),
9ac3aec9 92 fUserId(0),
93 fDetectorId(id)
448312df 94{
2d74ba4f 95 //
96 // Create Reference object out of label and
97 // data in TVirtualMC object
98 //
99 // Creates an object and fill all parameters
100 // from data in VirtualMC
aab9c8d5 101 //
2d74ba4f 102 // Sylwester Radomski, (S.Radomski@gsi.de)
103 // GSI, Jan 31, 2003
104 //
2cad796f 105
90e48c0c 106 Double_t vec[4];
2d74ba4f 107
90e48c0c 108 gMC->TrackPosition(vec[0],vec[1],vec[2]);
2d74ba4f 109
110 fX = vec[0];
111 fY = vec[1];
112 fZ = vec[2];
113
90e48c0c 114 gMC->TrackMomentum(vec[0],vec[1],vec[2],vec[3]);
2d74ba4f 115
116 fPx = vec[0];
117 fPy = vec[1];
b745fc4c 118 fPz = vec[2];
2d74ba4f 119
120 // Set Up status code
121 // Copy Bits from virtual MC
122
123 for(Int_t i=0; i<16; i++) ResetBit(BIT(i));
124
2cad796f 125 SetBit(BIT(0), gMC->IsNewTrack());
126 SetBit(BIT(1), gMC->IsTrackAlive());
127 SetBit(BIT(2), gMC->IsTrackDisappeared());
128 SetBit(BIT(3), gMC->IsTrackEntering());
129 SetBit(BIT(4), gMC->IsTrackExiting());
130 SetBit(BIT(5), gMC->IsTrackInside());
131 SetBit(BIT(6), gMC->IsTrackOut());
132 SetBit(BIT(7), gMC->IsTrackStop());
9ac3aec9 133 //
134 // This particle has to be kept
135
aab9c8d5 136}
2d74ba4f 137//_______________________________________________________________________
ac3eaff4 138AliExternalTrackParam * AliTrackReference::MakeTrack(const AliTrackReference *ref, Double_t mass)
139{
140 //
141 // Make dummy track from the track reference
142 // negative mass means opposite charge
143 //
144 Double_t xx[5];
145 Double_t cc[15];
146 for (Int_t i=0;i<15;i++) cc[i]=0;
147 Double_t x = ref->X(), y = ref->Y(), z = ref->Z();
148 Double_t alpha = TMath::ATan2(y,x);
149 Double_t xr = TMath::Sqrt(x*x+y*y);
b31d3cd8 150 xx[0] = ref->LocalY();
ac3eaff4 151 xx[1] = z;
152 xx[3] = ref->Pz()/ref->Pt();
c9ec41e8 153 xx[4] = 1./ref->Pt();
ac3eaff4 154 if (mass<0) xx[4]*=-1.; // negative mass - negative direction
155 Double_t alphap = TMath::ATan2(ref->Py(),ref->Px())-alpha;
156 if (alphap> TMath::Pi()) alphap-=TMath::Pi();
157 if (alphap<-TMath::Pi()) alphap+=TMath::Pi();
158 xx[2] = TMath::Sin(alphap);
c9ec41e8 159
ac3eaff4 160 AliExternalTrackParam * track = new AliExternalTrackParam(xr,alpha,xx,cc);
ac3eaff4 161 return track;
162}
163
65b311b3 164//_______________________________________________________________________
165void
9ac3aec9 166AliTrackReference::Print(Option_t* /*opt*/) const
65b311b3 167{
168 cout << Form("Label %d P=%7.2f (X,Y,Z)=(%7.2f,%7.2f,%7.2f) (PX,PY,PZ)=(%7.2f,%7.2f,%7.2f)"
169 " Length=%7.2f Time=%7.2f UserId=%d",
170 Label(),P(),Px(),Py(),Pz(),X(),Y(),Z(),GetLength(),GetTime()) << endl;
171}
ac3eaff4 172