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"
21 #include "AliTrackReference.h"
22 #include <Riostream.h>
25 // Track Reference object is created every time particle is
26 // crossing detector bounds. The object is created by Step Manager
28 // The class stores the following informations:
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
39 ClassImp(AliTrackReference)
41 //_______________________________________________________________________
42 AliTrackReference::AliTrackReference():
57 // Default constructor
58 // Creates empty object
60 for(Int_t i=0; i<16; i++) ResetBit(BIT(i));
63 AliTrackReference::AliTrackReference(const AliTrackReference &tr) :
75 fDetectorId(tr.fDetectorId)
80 //_______________________________________________________________________
81 AliTrackReference::AliTrackReference(Int_t label, Int_t id) :
90 fLength(gMC->TrackLength()),
91 fTime(gMC->TrackTime()),
96 // Create Reference object out of label and
97 // data in TVirtualMC object
99 // Creates an object and fill all parameters
100 // from data in VirtualMC
102 // Sylwester Radomski, (S.Radomski@gsi.de)
108 gMC->TrackPosition(vec[0],vec[1],vec[2]);
114 gMC->TrackMomentum(vec[0],vec[1],vec[2],vec[3]);
120 // Set Up status code
121 // Copy Bits from virtual MC
123 for(Int_t i=14; i<22; i++) ResetBit(BIT(i));
125 SetBit(BIT(14), gMC->IsNewTrack());
126 SetBit(BIT(15), gMC->IsTrackAlive());
127 SetBit(BIT(16), gMC->IsTrackDisappeared());
128 SetBit(BIT(17), gMC->IsTrackEntering());
129 SetBit(BIT(18), gMC->IsTrackExiting());
130 SetBit(BIT(19), gMC->IsTrackInside());
131 SetBit(BIT(20), gMC->IsTrackOut());
132 SetBit(BIT(21), gMC->IsTrackStop());
134 // This particle has to be kept
138 AliExternalTrackParam * AliTrackReference::MakeTrack(const AliTrackReference *ref, Double_t mass)
141 // Make dummy track from the track reference
142 // negative mass means opposite charge
146 for (Int_t i=0;i<15;i++) cc[i]=0;
147 Double_t x = ref->X(), y = ref->Y(), z = ref->Z();
148 Double_t alpha = TMath::ATan2(y,x);
149 Double_t xr = TMath::Sqrt(x*x+y*y);
150 xx[0] = ref->LocalY();
152 xx[3] = ref->Pz()/ref->Pt();
153 xx[4] = 1./ref->Pt();
154 if (mass<0) xx[4]*=-1.; // negative mass - negative direction
155 Double_t alphap = TMath::ATan2(ref->Py(),ref->Px())-alpha;
156 if (alphap> TMath::Pi()) alphap-=TMath::Pi();
157 if (alphap<-TMath::Pi()) alphap+=TMath::Pi();
158 xx[2] = TMath::Sin(alphap);
160 AliExternalTrackParam * track = new AliExternalTrackParam(xr,alpha,xx,cc);
164 //_______________________________________________________________________
166 AliTrackReference::Print(Option_t* /*opt*/) const
168 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)"
169 " Length=%7.2f Time=%7.2f UserId=%d",
170 Label(),P(),Px(),Py(),Pz(),X(),Y(),Z(),GetLength(),GetTime(),UserId()) << endl;