]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/ITS/AliL3ITStrack.cxx
Added GetPxPyPz
[u/mrichter/AliRoot.git] / HLT / ITS / AliL3ITStrack.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 //-------------------------------------------------------------------------
17 //                Implementation of the HLT ITS track class
18 //
19 //          Origin: Cvetan Cheshkov, CERN, Cvetan.Cheshkov@cern.ch
20 //-------------------------------------------------------------------------
21
22 #include <TMath.h>
23
24 #include "AliL3StandardIncludes.h"
25
26 #include "AliESDHLTtrack.h"
27 #include "AliL3ITStrack.h"
28
29 ClassImp(AliL3ITStrack)
30
31 //____________________________________________________________________________
32 AliL3ITStrack::AliL3ITStrack()
33               :AliITStrackV2(),fESDHLTtrack(0)
34 {
35   //------------------------------------------------------------------
36   //Constructor
37   //------------------------------------------------------------------
38 }
39
40 //____________________________________________________________________________
41 AliL3ITStrack::AliL3ITStrack(const AliL3ITStrack& t) 
42               : AliITStrackV2(t), fESDHLTtrack(0)
43 {
44   //------------------------------------------------------------------
45   //Copy constructor
46   //------------------------------------------------------------------
47   fESDHLTtrack=t.fESDHLTtrack;
48 }
49
50 //____________________________________________________________________________
51 AliL3ITStrack::AliL3ITStrack(AliESDHLTtrack& t, Double_t zvertex) throw (const Char_t *) 
52               : AliITStrackV2(), fESDHLTtrack(0) 
53 {
54   // The method constructs an AliL3ITStrack object from an ESD HLT track
55  
56   fESDHLTtrack=&t;
57   Set(t,zvertex);
58 }
59
60 //____________________________________________________________________________
61 AliL3ITStrack::AliL3ITStrack(const AliESDHLTtrack& t, Double_t zvertex) throw (const Char_t *) 
62               : AliITStrackV2(), fESDHLTtrack(0) 
63 {
64   // The method constructs an AliL3ITStrack object from an ESD HLT track
65   Set(t,zvertex);
66 }
67
68 //____________________________________________________________________________
69 void AliL3ITStrack::Set(const AliESDHLTtrack& t, Double_t zvertex) throw (const Char_t *) {
70   // The method constructs an AliL3ITStrack object from an ESD HLT track
71  
72   SetChi2(0.);
73   if(t.GetNHits()==1)
74     SetNumberOfClusters(0);
75   else
76     SetNumberOfClusters(t.GetNHits());
77   SetLabel(t.GetMCid());
78   SetMass(0.13957);
79
80   fdEdx=0;
81   fAlpha = fmod((t.GetSector()+0.5)*(2*TMath::Pi()/18),2*TMath::Pi());
82   if      (fAlpha < -TMath::Pi()) fAlpha += 2*TMath::Pi();
83   else if (fAlpha >= TMath::Pi()) fAlpha -= 2*TMath::Pi();
84
85   //First the emiision angle
86   Double_t psi = t.GetPsi()-(t.GetSector()+0.5)*(2*TMath::Pi()/18);
87
88   //Then local x,y coordinates
89   Double_t radius = t.GetPt()*GetConvConst();
90   Double_t xhit = 82.97; //Position at first TPC padrow
91   Double_t trackphi0 = psi + (-t.GetCharge())*TMath::Pi()/2;
92   Double_t x0 = t.GetFirstPointX()*TMath::Cos(fAlpha) + t.GetFirstPointY()*TMath::Sin(fAlpha);
93   Double_t y0 = t.GetFirstPointY()*TMath::Cos(fAlpha) - t.GetFirstPointX()*TMath::Sin(fAlpha);
94   Double_t centerx = radius *  cos(trackphi0) + x0;
95   Double_t centery = radius *  sin(trackphi0) + y0;
96   Double_t aa = (xhit - centerx)*(xhit - centerx);
97   Double_t r2 = radius*radius;
98   if(aa > r2) throw "AliITStrackV2: conversion failed !\n";
99   Double_t aa2 = sqrt(r2 - aa);
100   Double_t y1 = centery + aa2;
101   Double_t y2 = centery - aa2;
102   Double_t yhit = y1;
103   if(fabs(y2) < fabs(y1)) yhit = y2;
104
105   //Local z coordinate
106   Double_t angle1 = atan2((yhit - centery),(xhit - centerx));
107   if(angle1 < 0) angle1 += 2.*TMath::Pi();
108   Double_t angle2 = atan2((x0-centery),(y0-centerx));
109   if(angle2 < 0) angle2 += 2.*TMath::Pi();
110   Double_t diffangle = angle1 - angle2;
111   diffangle = fmod(diffangle,2.*TMath::Pi());
112   if(((-t.GetCharge())*diffangle) < 0) diffangle = diffangle - (-t.GetCharge())*2.*TMath::Pi();
113   Double_t stot = fabs(diffangle)*radius;
114   Double_t zhit;
115   if(t.GetNHits()==1)
116     zhit = zvertex + stot*t.GetTgl();
117   else
118     zhit = t.GetFirstPointZ() + stot*t.GetTgl();
119
120   //Local sine of track azimuthal angle
121   if((-t.GetCharge())<0)
122     radius = -radius;
123   Double_t sinbeta = -1.*(centerx - xhit)/radius;
124
125   //Filling of the track paramaters
126   fX=xhit;
127   fP0=yhit;
128   fP1=zhit;
129   fP2=sinbeta;
130   fP3=t.GetTgl();
131   fP4=1./radius;
132
133   //and covariance matrix
134   fC22=0.005*0.005;
135   fC33=0.005*0.005;
136   fC00=fC22*82.97*82.97;
137   fC11=fC33*82.97*82.97;
138   //  fC44=(0.005+0.025*t.GetPt())*(0.005+0.025*t.GetPt())*fP4*fP4;
139   //  fC44=(0.01+0.01*t.GetPt())*(0.01+0.01*t.GetPt())*fP4*fP4;
140   fC44=0.01*0.01*fP4*fP4;
141
142   fC10=0;
143   fC20=0;   fC21=0;
144   fC30=0;   fC31=0;   fC32=0;
145   fC40=0;   fC41=0;   fC42=0;   fC43=0;
146
147   fESDtrack=0;
148
149   SetFakeRatio(0.);
150 }
151
152 //_____________________________________________________________________________
153 Int_t AliL3ITStrack::Compare(const TObject *o) const {
154   //-----------------------------------------------------------------
155   // This function compares tracks according to the their curvature
156   //-----------------------------------------------------------------
157   AliL3ITStrack *t=(AliL3ITStrack*)o;
158   Double_t co=TMath::Abs(t->Get1Pt());
159   Double_t c =TMath::Abs(Get1Pt());
160   //  Double_t co=t->GetSigmaY2()*t->GetSigmaZ2();
161   //  Double_t c =GetSigmaY2()*GetSigmaZ2();
162   if (c>co) return 1;
163   else if (c<co) return -1;
164   return 0;
165 }
166
167 Bool_t AliL3ITStrack::GetPxPyPzAt(Double_t x,Double_t *p) const {
168   //---------------------------------------------------------------------
169   // This function returns the global track momentum components
170   // at the position "x" using the helix track approximation
171   //---------------------------------------------------------------------
172   p[0]=fP4;
173   p[1]=fP2+(x-fX)*fP4/AliKalmanTrack::GetConvConst(); 
174   p[2]=fP3;
175
176   if (TMath::Abs(p[0])<=0)        return kFALSE;
177   if (TMath::Abs(p[1])> 0.999999) return kFALSE;
178
179   Double_t pt=1./TMath::Abs(p[0]);
180   Double_t cs=TMath::Cos(fAlpha), sn=TMath::Sin(fAlpha);
181   Double_t r=TMath::Sqrt(1 - p[1]*p[1]);
182   p[0]=pt*(r*cs - p[1]*sn); p[1]=pt*(p[1]*cs + r*sn); p[2]=pt*p[2];
183
184   return kTRUE;
185 }