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