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