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 **************************************************************************/
16 //-------------------------------------------------------------------------
17 // Implementation of the ITS track class
19 // Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch
20 // dEdx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch
21 //-------------------------------------------------------------------------
23 /* $Id: AliHLTITSTrack.cxx 30856 2009-02-02 11:12:50Z fca $ */
29 #include "AliCluster.h"
30 #include "AliESDtrack.h"
31 #include "AliITSgeomTGeo.h"
32 #include "AliHLTITSTrack.h"
33 #include "AliTracker.h"
36 #include "AliCluster.h"
37 #include "AliESDtrack.h"
38 #include "AliESDVertex.h"
39 #include "AliITSReconstructor.h"
40 #include "AliITStrackV2.h"
41 #include "AliTracker.h"
44 ClassImp(AliHLTITSTrack)
46 //____________________________________________________________________________
47 AliHLTITSTrack::AliHLTITSTrack() :
52 for(Int_t i=0; i<2*AliITSgeomTGeo::kNLayers; i++) {fIndex[i]=-1; }
55 //____________________________________________________________________________
56 AliHLTITSTrack::AliHLTITSTrack(const AliHLTITSTrack& t) :
59 fTPCtrackId( t.fTPCtrackId)
61 //------------------------------------------------------------------
63 //------------------------------------------------------------------
65 for (i=0; i<2*AliITSgeomTGeo::GetNLayers(); i++) {
66 fIndex[i]=t.fIndex[i];
69 fFakeRatio = t.fFakeRatio;
72 //____________________________________________________________________________
73 AliHLTITSTrack &AliHLTITSTrack::operator=(const AliHLTITSTrack& t)
75 //------------------------------------------------------------------
77 //------------------------------------------------------------------
78 *(AliKalmanTrack*)this = t;
80 fTPCtrackId = t.fTPCtrackId;
82 for (i=0; i<2*AliITSgeomTGeo::GetNLayers(); i++) {
83 fIndex[i]=t.fIndex[i];
86 fFakeRatio = t.fFakeRatio;
91 //____________________________________________________________________________
92 AliHLTITSTrack::AliHLTITSTrack(AliESDtrack& t,Bool_t c) throw (const Char_t *) :
97 //------------------------------------------------------------------
98 // Conversion ESD track -> ITS track.
99 // If c==kTRUE, create the ITS track out of the constrained params.
100 //------------------------------------------------------------------
101 const AliExternalTrackParam *par=&t;
103 par=t.GetConstrainedParam();
104 if (!par) throw "AliHLTITSTrack: conversion failed !\n";
106 Set(par->GetX(),par->GetAlpha(),par->GetParameter(),par->GetCovariance());
108 SetLabel(t.GetLabel());
109 //SetMass(t.GetMass());
110 SetNumberOfClusters(t.GetITSclusters(fIndex));
113 //____________________________________________________________________________
114 AliHLTITSTrack::AliHLTITSTrack(AliExternalTrackParam& t ) throw (const Char_t *) :
119 //------------------------------------------------------------------
120 // Conversion ESD track -> ITS track.
121 // If c==kTRUE, create the ITS track out of the constrained params.
122 //------------------------------------------------------------------
123 const AliExternalTrackParam *par=&t;
124 Set(par->GetX(),par->GetAlpha(),par->GetParameter(),par->GetCovariance());
125 SetLabel(t.GetLabel());
126 //SetMass(t.GetMass());
127 SetNumberOfClusters(0);
131 Double_t AliHLTITSTrack::GetPredictedChi2(const AliCluster* c) const
133 return GetPredictedChi2(c->GetY(), c->GetZ(), c->GetSigmaY2(), c->GetSigmaZ2() );
136 Double_t AliHLTITSTrack::GetPredictedChi2(Double_t cy, Double_t cz, Double_t cerr2Y, Double_t cerr2Z) const
138 //-----------------------------------------------------------------
139 // This function calculates a predicted chi2 increment.
140 //-----------------------------------------------------------------
141 Double_t p[2]={cy, cz};
142 Double_t cov[3]={cerr2Y, 0., cerr2Z};
143 return AliExternalTrackParam::GetPredictedChi2(p,cov);
149 Int_t AliHLTITSTrack::GetProlongationFast(Double_t alp, Double_t xk,Double_t &y, Double_t &z)
151 //-----------------------------------------------------------------------------
152 //get fast prolongation
153 //-----------------------------------------------------------------------------
154 Double_t ca=TMath::Cos(alp-GetAlpha()), sa=TMath::Sin(alp-GetAlpha());
155 Double_t cf=TMath::Sqrt((1.-GetSnp())*(1.+GetSnp()));
156 // **** rotation **********************
157 y= -GetX()*sa + GetY()*ca;
158 // **** translation ******************
159 Double_t dx = xk- GetX()*ca - GetY()*sa;
160 Double_t f1=GetSnp()*ca - cf*sa, f2=f1 + GetC()*dx;
161 if (TMath::Abs(f2) >= 0.9999) {
164 Double_t r1=TMath::Sqrt((1.-f1)*(1.+f1)), r2=TMath::Sqrt((1.-f2)*(1.+f2));
165 y += dx*(f1+f2)/(r1+r2);
166 z = GetZ()+dx*(f1+f2)/(f1*r2 + f2*r1)*GetTgl();
172 //____________________________________________________________________________
173 void AliHLTITSTrack::ResetClusters() {
174 //------------------------------------------------------------------
175 // Reset the array of attached clusters.
176 //------------------------------------------------------------------
177 for (Int_t i=0; i<2*AliITSgeomTGeo::kNLayers; i++) fIndex[i]=-1;
179 SetNumberOfClusters(0);
185 //____________________________________________________________________________
188 //____________________________________________________________________________
189 Bool_t AliHLTITSTrack::
190 GetGlobalXYZat(Double_t xloc, Double_t &x, Double_t &y, Double_t &z) const {
191 //------------------------------------------------------------------
192 //This function returns a track position in the global system
193 //------------------------------------------------------------------
195 Bool_t rc=GetXYZAt(xloc, GetBz(), r);
196 x=r[0]; y=r[1]; z=r[2];
201 //____________________________________________________________________________
202 Bool_t AliHLTITSTrack::PropagateTo(Double_t xk, Double_t d, Double_t x0) {
203 //------------------------------------------------------------------
204 //This function propagates a track
205 //------------------------------------------------------------------
207 Double_t oldX=GetX(), oldY=GetY(), oldZ=GetZ();
210 if (!AliExternalTrackParam::PropagateTo(xk,bz)) return kFALSE;
211 Double_t xOverX0,xTimesRho;
212 xOverX0 = d; xTimesRho = d*x0;
213 if (!CorrectForMeanMaterial(xOverX0,xTimesRho,kTRUE)) return kFALSE;
215 Double_t x=GetX(), y=GetY(), z=GetZ();
216 if (IsStartedTimeIntegral() && x>oldX) {
217 Double_t l2 = (x-oldX)*(x-oldX) + (y-oldY)*(y-oldY) + (z-oldZ)*(z-oldZ);
218 AddTimeStep(TMath::Sqrt(l2));
224 //____________________________________________________________________________
225 Bool_t AliHLTITSTrack::PropagateToTGeo(Double_t xToGo, Int_t nstep, Double_t &xOverX0, Double_t &xTimesRho, Bool_t addTime) {
226 //-------------------------------------------------------------------
227 // Propagates the track to a reference plane x=xToGo in n steps.
228 // These n steps are only used to take into account the curvature.
229 // The material is calculated with TGeo. (L.Gaudichet)
230 //-------------------------------------------------------------------
232 Double_t startx = GetX(), starty = GetY(), startz = GetZ();
233 Double_t sign = (startx<xToGo) ? -1.:1.;
234 Double_t step = (xToGo-startx)/TMath::Abs(nstep);
236 Double_t start[3], end[3], mparam[7], bz = GetBz();
239 for (Int_t i=0; i<nstep; i++) {
241 GetXYZ(start); //starting global position
243 if (!GetXYZAt(x, bz, end)) return kFALSE;
244 if (!AliExternalTrackParam::PropagateTo(x, bz)) return kFALSE;
245 AliTracker::MeanMaterialBudget(start, end, mparam);
246 xTimesRho = sign*mparam[4]*mparam[0];
248 if (mparam[1]<900000) {
249 if (!AliExternalTrackParam::CorrectForMeanMaterial(xOverX0,
250 xTimesRho,GetMass())) return kFALSE;
251 } else { // this happens when MeanMaterialBudget cannot cross a boundary
256 if (addTime && IsStartedTimeIntegral() && GetX()>startx) {
257 Double_t l2 = ( (GetX()-startx)*(GetX()-startx) +
258 (GetY()-starty)*(GetY()-starty) +
259 (GetZ()-startz)*(GetZ()-startz) );
260 AddTimeStep(TMath::Sqrt(l2));
266 //____________________________________________________________________________
267 Bool_t AliHLTITSTrack::Update(const AliCluster* c, Double_t chi2, Int_t index)
269 //------------------------------------------------------------------
270 //This function updates track parameters
271 //------------------------------------------------------------------
272 Double_t p[2]={c->GetY(), c->GetZ()};
273 Double_t cov[3]={c->GetSigmaY2(), 0., c->GetSigmaZ2()};
275 if (!AliExternalTrackParam::Update(p,cov)) return kFALSE;
277 Int_t n=GetNumberOfClusters();
279 if (chi2<0) return kTRUE;
282 SetNumberOfClusters(n+1);
283 SetChi2(GetChi2()+chi2);
290 //____________________________________________________________________________
291 Bool_t AliHLTITSTrack::Propagate(Double_t alp,Double_t xk) {
292 //------------------------------------------------------------------
293 //This function propagates a track
294 //------------------------------------------------------------------
296 if (!AliExternalTrackParam::Propagate(alp,xk,bz)) return kFALSE;
305 //____________________________________________________________________________
306 Bool_t AliHLTITSTrack::
307 GetPhiZat(Double_t r, Double_t &phi, Double_t &z) const {
308 //------------------------------------------------------------------
309 // This function returns the global cylindrical (phi,z) of the track
310 // position estimated at the radius r.
311 // The track curvature is neglected.
312 //------------------------------------------------------------------
313 Double_t d=GetD(0.,0.);
314 if (TMath::Abs(d) > r) {
315 if (r>1e-1) return kFALSE;
319 Double_t rcurr=TMath::Sqrt(GetX()*GetX() + GetY()*GetY());
320 if (TMath::Abs(d) > rcurr) return kFALSE;
321 Double_t globXYZcurr[3]; GetXYZ(globXYZcurr);
322 Double_t phicurr=TMath::ATan2(globXYZcurr[1],globXYZcurr[0]);
325 phi=phicurr+TMath::ASin(d/r)-TMath::ASin(d/rcurr);
327 phi=phicurr+TMath::ASin(d/r)+TMath::ASin(d/rcurr)-TMath::Pi();
330 // return a phi in [0,2pi[
331 if (phi<0.) phi+=2.*TMath::Pi();
332 else if (phi>=2.*TMath::Pi()) phi-=2.*TMath::Pi();
333 z=GetZ()+GetTgl()*(TMath::Sqrt((r-d)*(r+d))-TMath::Sqrt((rcurr-d)*(rcurr+d)));
337 //____________________________________________________________________________
338 Bool_t AliHLTITSTrack::
339 GetLocalXat(Double_t r,Double_t &xloc) const {
340 //------------------------------------------------------------------
341 // This function returns the local x of the track
342 // position estimated at the radius r.
343 // The track curvature is neglected.
344 //------------------------------------------------------------------
345 Double_t d=GetD(0.,0.);
346 if (TMath::Abs(d) > r) {
347 if (r>1e-1) return kFALSE;
351 Double_t rcurr=TMath::Sqrt(GetX()*GetX() + GetY()*GetY());
352 Double_t globXYZcurr[3]; GetXYZ(globXYZcurr);
353 Double_t phicurr=TMath::ATan2(globXYZcurr[1],globXYZcurr[0]);
356 phi=phicurr+TMath::ASin(d/r)-TMath::ASin(d/rcurr);
358 phi=phicurr+TMath::ASin(d/r)+TMath::ASin(d/rcurr)-TMath::Pi();
361 xloc=r*(TMath::Cos(phi)*TMath::Cos(GetAlpha())
362 +TMath::Sin(phi)*TMath::Sin(GetAlpha()));