1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 #include "TVirtualMC.h"
19 #include "TParticle.h"
22 #include "AliTrackReference.h"
23 #include "AliExternalTrackParam.h"
24 #include "AliKalmanTrack.h"
25 #include <Riostream.h>
28 // Track Reference object is created every time particle is
29 // crossing detector bounds. The object is created by Step Manager
31 // The class stores the following informations:
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
40 ClassImp(AliTrackReference)
42 //_______________________________________________________________________
43 AliTrackReference::AliTrackReference():
58 // Default constructor
59 // Creates empty object
61 for(Int_t i=0; i<16; i++) ResetBit(BIT(i));
64 AliTrackReference::AliTrackReference(const AliTrackReference &tr) :
76 fDetectorId(tr.fDetectorId)
81 //_______________________________________________________________________
82 AliTrackReference::AliTrackReference(Int_t label, Int_t id) :
91 fLength(gMC->TrackLength()),
92 fTime(gMC->TrackTime()),
97 // Create Reference object out of label and
98 // data in TVirtualMC object
100 // Creates an object and fill all parameters
101 // from data in VirtualMC
103 // Sylwester Radomski, (S.Radomski@gsi.de)
109 gMC->TrackPosition(vec[0],vec[1],vec[2]);
115 gMC->TrackMomentum(vec[0],vec[1],vec[2],vec[3]);
121 // Set Up status code
122 // Copy Bits from virtual MC
124 for(Int_t i=0; i<16; i++) ResetBit(BIT(i));
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());
135 // This particle has to be kept
138 //_______________________________________________________________________
139 AliExternalTrackParam * AliTrackReference::MakeTrack(const AliTrackReference *ref, Double_t mass)
142 // Make dummy track from the track reference
143 // negative mass means opposite charge
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();
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);
161 AliExternalTrackParam * track = new AliExternalTrackParam(xr,alpha,xx,cc);
165 //_______________________________________________________________________
167 AliTrackReference::Print(Option_t* /*opt*/) const
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;