]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliTrackReference.cxx
Write all track references into one branch of TreeTR.
[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
9ac3aec9 21#include "AliStack.h"
0742d588 22#include "AliTrackReference.h"
ac3eaff4 23#include "AliExternalTrackParam.h"
24#include "AliKalmanTrack.h"
65b311b3 25#include <Riostream.h>
2d74ba4f 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
aab9c8d5 39
40ClassImp(AliTrackReference)
41
e2afb3b6 42//_______________________________________________________________________
43 AliTrackReference::AliTrackReference():
448312df 44 TObject(),
e2afb3b6 45 fTrack(0),
46 fX(0),
47 fY(0),
48 fZ(0),
49 fPx(0),
50 fPy(0),
51 fPz(0),
448312df 52 fLength(0),
3142ebc3 53 fTime(0),
9ac3aec9 54 fUserId(0),
55 fDetectorId(-999)
aab9c8d5 56{
57 //
58 // Default constructor
2d74ba4f 59 // Creates empty object
60
61 for(Int_t i=0; i<16; i++) ResetBit(BIT(i));
62}
63
9ac3aec9 64AliTrackReference::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
2d74ba4f 81//_______________________________________________________________________
9ac3aec9 82AliTrackReference::AliTrackReference(Int_t label, Int_t id) :
90e48c0c 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()),
3142ebc3 92 fTime(gMC->TrackTime()),
9ac3aec9 93 fUserId(0),
94 fDetectorId(id)
448312df 95{
2d74ba4f 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
aab9c8d5 102 //
2d74ba4f 103 // Sylwester Radomski, (S.Radomski@gsi.de)
104 // GSI, Jan 31, 2003
105 //
2cad796f 106
90e48c0c 107 Double_t vec[4];
2d74ba4f 108
90e48c0c 109 gMC->TrackPosition(vec[0],vec[1],vec[2]);
2d74ba4f 110
111 fX = vec[0];
112 fY = vec[1];
113 fZ = vec[2];
114
90e48c0c 115 gMC->TrackMomentum(vec[0],vec[1],vec[2],vec[3]);
2d74ba4f 116
117 fPx = vec[0];
118 fPy = vec[1];
b745fc4c 119 fPz = vec[2];
2d74ba4f 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
2cad796f 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());
9ac3aec9 134 //
135 // This particle has to be kept
136
aab9c8d5 137}
2d74ba4f 138//_______________________________________________________________________
ac3eaff4 139AliExternalTrackParam * 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);
b31d3cd8 151 xx[0] = ref->LocalY();
ac3eaff4 152 xx[1] = z;
153 xx[3] = ref->Pz()/ref->Pt();
c9ec41e8 154 xx[4] = 1./ref->Pt();
ac3eaff4 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);
c9ec41e8 160
ac3eaff4 161 AliExternalTrackParam * track = new AliExternalTrackParam(xr,alpha,xx,cc);
ac3eaff4 162 return track;
163}
164
65b311b3 165//_______________________________________________________________________
166void
9ac3aec9 167AliTrackReference::Print(Option_t* /*opt*/) const
65b311b3 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}
ac3eaff4 173