]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliTrackReference.cxx
Coding conventions (Alberto)
[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    fUserId(0)
53 {
54   //
55   // Default constructor
56   // Creates empty object
57
58   for(Int_t i=0; i<16; i++) ResetBit(BIT(i));
59 }
60
61 //_______________________________________________________________________
62 AliTrackReference::AliTrackReference(Int_t label) :
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()),
72   fTime(gMC->TrackTime()),
73   fUserId(0)
74 {
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
81   //
82   // Sylwester Radomski, (S.Radomski@gsi.de)
83   // GSI, Jan 31, 2003
84   //
85     
86   Double_t vec[4];
87   
88   gMC->TrackPosition(vec[0],vec[1],vec[2]);
89
90   fX = vec[0];
91   fY = vec[1];
92   fZ = vec[2];
93   
94   gMC->TrackMomentum(vec[0],vec[1],vec[2],vec[3]);
95   
96   fPx = vec[0];
97   fPy = vec[1];
98   fPz = vec[2];
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
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()); 
113 }
114 //_______________________________________________________________________
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();
130   xx[4] = 1./ref->Pt(); 
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);
136
137   AliExternalTrackParam * track = new  AliExternalTrackParam(xr,alpha,xx,cc);
138   return track;
139 }
140
141