]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliTrackReference.cxx
START AlignObj added
[u/mrichter/AliRoot.git] / STEER / AliTrackReference.cxx
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
16 /* $Id$ */
17
18 #include "TVirtualMC.h"
19
20 #include "AliRun.h"
21 #include "AliTrackReference.h"
22 #include "AliExternalTrackParam.h"
23 #include "AliKalmanTrack.h"
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
37
38 ClassImp(AliTrackReference)
39
40 //_______________________________________________________________________
41  AliTrackReference::AliTrackReference():
42    TObject(),
43    fTrack(0),
44    fX(0),
45    fY(0),
46    fZ(0),
47    fPx(0),
48    fPy(0),
49    fPz(0),
50    fLength(0),
51    fTime(0)
52 {
53   //
54   // Default constructor
55   // Creates empty object
56
57   for(Int_t i=0; i<16; i++) ResetBit(BIT(i));
58 }
59
60 //_______________________________________________________________________
61 AliTrackReference::AliTrackReference(Int_t label) :
62   TObject(),
63   fTrack(label),
64   fX(0),
65   fY(0),
66   fZ(0),
67   fPx(0),
68   fPy(0),
69   fPz(0),
70   fLength(gMC->TrackLength()),
71   fTime(gMC->TrackTime())
72 {
73   //
74   // Create Reference object out of label and
75   // data in TVirtualMC object
76   //
77   // Creates an object and fill all parameters 
78   // from data in VirtualMC
79   //
80   // Sylwester Radomski, (S.Radomski@gsi.de)
81   // GSI, Jan 31, 2003
82   //
83     
84   Double_t vec[4];
85   
86   gMC->TrackPosition(vec[0],vec[1],vec[2]);
87
88   fX = vec[0];
89   fY = vec[1];
90   fZ = vec[2];
91   
92   gMC->TrackMomentum(vec[0],vec[1],vec[2],vec[3]);
93   
94   fPx = vec[0];
95   fPy = vec[1];
96   fPz = vec[2];
97
98   // Set Up status code 
99   // Copy Bits from virtual MC
100
101   for(Int_t i=0; i<16; i++) ResetBit(BIT(i));
102
103   SetBit(BIT(0), gMC->IsNewTrack());
104   SetBit(BIT(1), gMC->IsTrackAlive());
105   SetBit(BIT(2), gMC->IsTrackDisappeared());
106   SetBit(BIT(3), gMC->IsTrackEntering());
107   SetBit(BIT(4), gMC->IsTrackExiting());
108   SetBit(BIT(5), gMC->IsTrackInside());
109   SetBit(BIT(6), gMC->IsTrackOut());
110   SetBit(BIT(7), gMC->IsTrackStop()); 
111 }
112 //_______________________________________________________________________
113 AliExternalTrackParam * AliTrackReference::MakeTrack(const AliTrackReference *ref, Double_t mass)
114 {
115   //
116   // Make dummy track from the track reference 
117   // negative mass means opposite charge 
118   //
119   Double_t xx[5];
120   Double_t cc[15];
121   for (Int_t i=0;i<15;i++) cc[i]=0;
122   Double_t x = ref->X(), y = ref->Y(), z = ref->Z();
123   Double_t alpha = TMath::ATan2(y,x);
124   Double_t xr = TMath::Sqrt(x*x+y*y);
125   xx[0] = 0;
126   xx[1] = z;
127   xx[3] = ref->Pz()/ref->Pt();
128   xx[4] = 1./ref->Pt(); 
129   if (mass<0) xx[4]*=-1.;  // negative mass - negative direction
130   Double_t alphap = TMath::ATan2(ref->Py(),ref->Px())-alpha;
131   if (alphap> TMath::Pi()) alphap-=TMath::Pi();
132   if (alphap<-TMath::Pi()) alphap+=TMath::Pi();
133   xx[2] = TMath::Sin(alphap);
134
135   AliExternalTrackParam * track = new  AliExternalTrackParam(xr,alpha,xx,cc);
136   return track;
137 }
138
139