LCOV - code coverage report
Current view: top level - HLT/ITS/tracking - AliHLTITSTrack.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 189 0.5 %
Date: 2016-06-14 17:26:59 Functions: 1 23 4.3 %

          Line data    Source code
       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 ITS track class
      18             : //
      19             : //          Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch
      20             : //     dEdx analysis by: Boris Batyunya, JINR, Boris.Batiounia@cern.ch
      21             : //-------------------------------------------------------------------------
      22             : 
      23             : /* $Id: AliHLTITSTrack.cxx 30856 2009-02-02 11:12:50Z fca $ */
      24             : 
      25             : #include <TMatrixD.h>
      26             : 
      27             : #include <TMath.h>
      28             : 
      29             : #include "AliCluster.h"
      30             : #include "AliESDtrack.h"
      31             : #include "AliITSgeomTGeo.h"
      32             : #include "AliHLTITSTrack.h"
      33             : #include "AliTracker.h"
      34             : #include <TMath.h>
      35             : 
      36             : #include "AliCluster.h"
      37             : #include "AliESDtrack.h"
      38             : #include "AliESDVertex.h"
      39             : #include "AliITSReconstructor.h"
      40             : #include "AliITStrackV2.h"
      41             : #include "AliTracker.h"
      42             : 
      43             : 
      44           6 : ClassImp(AliHLTITSTrack)
      45             : 
      46             : //____________________________________________________________________________
      47             : AliHLTITSTrack::AliHLTITSTrack() : 
      48           0 :   AliKalmanTrack(),  
      49           0 :   fExpQ(40),
      50           0 :   fTPCtrackId(0)
      51           0 : {
      52           0 :   for(Int_t i=0; i<2*AliITSgeomTGeo::kNLayers; i++) {fIndex[i]=-1; }
      53           0 : }
      54             : 
      55             : //____________________________________________________________________________
      56             : AliHLTITSTrack::AliHLTITSTrack(const AliHLTITSTrack& t) : 
      57           0 :   AliKalmanTrack(t),  
      58           0 :   fExpQ(t.fExpQ),
      59           0 :   fTPCtrackId( t.fTPCtrackId)
      60           0 : {
      61             :   //------------------------------------------------------------------
      62             :   //Copy constructor
      63             :   //------------------------------------------------------------------
      64             :   Int_t i;
      65           0 :   for (i=0; i<2*AliITSgeomTGeo::GetNLayers(); i++) {
      66           0 :     fIndex[i]=t.fIndex[i];
      67             :   }
      68           0 :   fLab = t.fLab;
      69           0 :   fFakeRatio = t.fFakeRatio;
      70           0 : }
      71             : 
      72             : //____________________________________________________________________________
      73             : AliHLTITSTrack &AliHLTITSTrack::operator=(const AliHLTITSTrack& t)
      74             : {
      75             :   //------------------------------------------------------------------
      76             :   //Copy constructor
      77             :   //------------------------------------------------------------------
      78           0 :   if( &t==this ) return *this;
      79           0 :   *(AliKalmanTrack*)this = t;  
      80           0 :   fExpQ = t.fExpQ;
      81           0 :   fTPCtrackId = t.fTPCtrackId;
      82             :   Int_t i;
      83           0 :   for (i=0; i<2*AliITSgeomTGeo::GetNLayers(); i++) {
      84           0 :     fIndex[i]=t.fIndex[i];
      85             :   }
      86           0 :   fLab = t.fLab;
      87           0 :   fFakeRatio = t.fFakeRatio;
      88             :   return *this;
      89           0 : }
      90             : 
      91             : 
      92             : //____________________________________________________________________________
      93             : AliHLTITSTrack::AliHLTITSTrack(AliESDtrack& t,Bool_t c) throw (const Char_t *) :
      94           0 :   AliKalmanTrack(),
      95           0 :   fExpQ(40),
      96           0 :   fTPCtrackId( 0 )
      97           0 : {
      98             :   //------------------------------------------------------------------
      99             :   // Conversion ESD track -> ITS track.
     100             :   // If c==kTRUE, create the ITS track out of the constrained params.
     101             :   //------------------------------------------------------------------
     102           0 :   for(Int_t i=0; i<2*AliITSgeomTGeo::kNLayers; i++) {fIndex[i]=-1; }
     103             : 
     104           0 :   const AliExternalTrackParam *par=&t;
     105           0 :   if (c) {
     106           0 :     par=t.GetConstrainedParam();
     107           0 :     if (!par) throw "AliHLTITSTrack: conversion failed !\n";
     108             :   }
     109           0 :   Set(par->GetX(),par->GetAlpha(),par->GetParameter(),par->GetCovariance());
     110             : 
     111           0 :   SetLabel(t.GetLabel());
     112             :   //SetMass(t.GetMass());
     113           0 :   SetNumberOfClusters(t.GetITSclusters(fIndex));
     114           0 : }
     115             : 
     116             : //____________________________________________________________________________
     117             : AliHLTITSTrack::AliHLTITSTrack(AliExternalTrackParam& t ) throw (const Char_t *) :
     118           0 :   AliKalmanTrack(),  
     119           0 :   fExpQ(40),
     120           0 :   fTPCtrackId( 0 )
     121           0 : {
     122             :   //------------------------------------------------------------------
     123             :   // Conversion ESD track -> ITS track.
     124             :   // If c==kTRUE, create the ITS track out of the constrained params.
     125             :   //------------------------------------------------------------------
     126             :   const AliExternalTrackParam *par=&t;
     127           0 :   Set(par->GetX(),par->GetAlpha(),par->GetParameter(),par->GetCovariance());
     128           0 :   SetLabel(t.GetLabel());
     129             :   //SetMass(t.GetMass());
     130           0 :   SetNumberOfClusters(0); 
     131           0 :   for( int i=0; i<2*AliITSgeomTGeo::kNLayers; i++ ) fIndex[i] = 0;
     132           0 : }
     133             : 
     134             : 
     135             : Double_t AliHLTITSTrack::GetPredictedChi2(const AliCluster* c) const
     136             : {
     137           0 :   return GetPredictedChi2(c->GetY(), c->GetZ(), c->GetSigmaY2(), c->GetSigmaZ2() );
     138             : }
     139             : 
     140             : Double_t AliHLTITSTrack::GetPredictedChi2(Double_t cy, Double_t cz, Double_t cerr2Y, Double_t cerr2Z) const
     141             : {
     142             :   //-----------------------------------------------------------------
     143             :   // This function calculates a predicted chi2 increment.
     144             :   //-----------------------------------------------------------------
     145           0 :   Double_t p[2]={cy, cz};
     146           0 :   Double_t cov[3]={cerr2Y, 0., cerr2Z};
     147           0 :   return AliExternalTrackParam::GetPredictedChi2(p,cov);
     148           0 : }
     149             : 
     150             : 
     151             : 
     152             : 
     153             : Int_t AliHLTITSTrack::GetProlongationFast(Double_t alp, Double_t xk,Double_t &y, Double_t &z)
     154             : {
     155             :   //-----------------------------------------------------------------------------
     156             :   //get fast prolongation 
     157             :   //-----------------------------------------------------------------------------
     158           0 :   Double_t ca=TMath::Cos(alp-GetAlpha()), sa=TMath::Sin(alp-GetAlpha());
     159           0 :   Double_t cf=TMath::Sqrt((1.-GetSnp())*(1.+GetSnp()));  
     160             :   // **** rotation **********************  
     161           0 :   y= -GetX()*sa + GetY()*ca;
     162             :   // **** translation ******************  
     163           0 :   Double_t dx = xk- GetX()*ca - GetY()*sa;
     164           0 :   Double_t f1=GetSnp()*ca - cf*sa, f2=f1 + GetC()*dx;
     165           0 :   if (TMath::Abs(f2) >= 0.9999) {
     166           0 :     return 0;
     167             :   }
     168           0 :   Double_t r1=TMath::Sqrt((1.-f1)*(1.+f1)), r2=TMath::Sqrt((1.-f2)*(1.+f2));  
     169           0 :   y += dx*(f1+f2)/(r1+r2);
     170           0 :   z  = GetZ()+dx*(f1+f2)/(f1*r2 + f2*r1)*GetTgl();  
     171             :   return 1;
     172           0 : }
     173             : 
     174             : 
     175             : 
     176             : //____________________________________________________________________________
     177             : void AliHLTITSTrack::ResetClusters() {
     178             :   //------------------------------------------------------------------
     179             :   // Reset the array of attached clusters.
     180             :   //------------------------------------------------------------------
     181           0 :   for (Int_t i=0; i<2*AliITSgeomTGeo::kNLayers; i++) fIndex[i]=-1;
     182           0 :   SetChi2(0.); 
     183           0 :   SetNumberOfClusters(0);
     184           0 : } 
     185             : 
     186             : 
     187             : 
     188             : 
     189             : //____________________________________________________________________________
     190             : 
     191             : 
     192             : //____________________________________________________________________________
     193             : Bool_t AliHLTITSTrack::
     194             : GetGlobalXYZat(Double_t xloc, Double_t &x, Double_t &y, Double_t &z) const {
     195             :   //------------------------------------------------------------------
     196             :   //This function returns a track position in the global system
     197             :   //------------------------------------------------------------------
     198           0 :   Double_t r[3];
     199           0 :   Bool_t rc=GetXYZAt(xloc, GetBz(), r);
     200           0 :   x=r[0]; y=r[1]; z=r[2]; 
     201           0 :   return rc;
     202           0 : }
     203             : 
     204             : Bool_t AliHLTITSTrack::GetLocalYZat(Double_t xloc, Double_t &y, Double_t &z) const 
     205             : {
     206             :   // local YZ at x
     207           0 :   Double_t dx=xloc - GetX();
     208           0 :   Double_t f1=GetSnp(), f2=f1 + dx*GetC( GetBz() );
     209           0 :   if (TMath::Abs(f1) >= kAlmost1) return kFALSE;
     210           0 :   if (TMath::Abs(f2) >= kAlmost1) return kFALSE;  
     211           0 :   Double_t r1=TMath::Sqrt((1.-f1)*(1.+f1)), r2=TMath::Sqrt((1.-f2)*(1.+f2));
     212           0 :   y = GetY() + dx*(f1+f2)/(r1+r2);
     213           0 :   z = GetZ() + dx*(r2 + f2*(f1+f2)/(r1+r2))*GetTgl();
     214             :   return 1;
     215           0 : }
     216             : 
     217             : //____________________________________________________________________________
     218             : Bool_t AliHLTITSTrack::PropagateTo(Double_t xk, Double_t d, Double_t x0) {
     219             :   //------------------------------------------------------------------
     220             :   //This function propagates a track
     221             :   //------------------------------------------------------------------
     222             : 
     223           0 :   Double_t oldX=GetX(), oldY=GetY(), oldZ=GetZ();
     224             :   
     225           0 :   Double_t bz=GetBz();
     226           0 :   if (!AliExternalTrackParam::PropagateTo(xk,bz)) return kFALSE;
     227             :   Double_t xOverX0,xTimesRho; 
     228           0 :   xOverX0 = d; xTimesRho = d*x0;
     229           0 :   if (!CorrectForMeanMaterial(xOverX0,xTimesRho,kTRUE)) return kFALSE;
     230             : 
     231           0 :   Double_t x=GetX(), y=GetY(), z=GetZ();
     232           0 :   if (IsStartedTimeIntegral() && x>oldX) {
     233           0 :     Double_t l2 = (x-oldX)*(x-oldX) + (y-oldY)*(y-oldY) + (z-oldZ)*(z-oldZ);
     234           0 :     AddTimeStep(TMath::Sqrt(l2));
     235           0 :   }
     236             : 
     237             :   return kTRUE;
     238           0 : }
     239             : 
     240             : //____________________________________________________________________________
     241             : Bool_t AliHLTITSTrack::PropagateToTGeo(Double_t xToGo, Int_t nstep, Double_t &xOverX0, Double_t &xTimesRho, Bool_t addTime) {
     242             :   //-------------------------------------------------------------------
     243             :   //  Propagates the track to a reference plane x=xToGo in n steps.
     244             :   //  These n steps are only used to take into account the curvature.
     245             :   //  The material is calculated with TGeo. (L.Gaudichet)
     246             :   //-------------------------------------------------------------------
     247             : 
     248           0 :   Double_t startx = GetX(), starty = GetY(), startz = GetZ();
     249           0 :   Double_t sign = (startx<xToGo) ? -1.:1.;
     250           0 :   Double_t step = (xToGo-startx)/TMath::Abs(nstep);
     251             : 
     252           0 :   Double_t start[3], end[3], mparam[7], bz = GetBz();
     253             :   Double_t x = startx;
     254             :   
     255           0 :   for (Int_t i=0; i<nstep; i++) {
     256             :     
     257           0 :     GetXYZ(start);   //starting global position
     258           0 :     x += step;
     259           0 :     if (!GetXYZAt(x, bz, end)) return kFALSE;
     260           0 :     if (!AliExternalTrackParam::PropagateTo(x, bz)) return kFALSE;
     261           0 :     AliTracker::MeanMaterialBudget(start, end, mparam);
     262           0 :     xTimesRho = sign*mparam[4]*mparam[0];
     263           0 :     xOverX0   = mparam[1];
     264           0 :     if (mparam[1]<900000) {
     265           0 :       if (!AliExternalTrackParam::CorrectForMeanMaterial(xOverX0,
     266           0 :                                                          xTimesRho,GetMass())) return kFALSE;
     267             :     } else { // this happens when MeanMaterialBudget cannot cross a boundary
     268           0 :       return kFALSE;
     269             :     }
     270             :   }
     271             : 
     272           0 :   if (addTime && IsStartedTimeIntegral() && GetX()>startx) {
     273           0 :     Double_t l2 = ( (GetX()-startx)*(GetX()-startx) +
     274           0 :                     (GetY()-starty)*(GetY()-starty) +
     275           0 :                     (GetZ()-startz)*(GetZ()-startz) );
     276           0 :     AddTimeStep(TMath::Sqrt(l2));
     277           0 :   }
     278             : 
     279           0 :   return kTRUE;
     280           0 : }
     281             : 
     282             : //____________________________________________________________________________
     283             : Bool_t AliHLTITSTrack::Update(const AliCluster* c, Double_t chi2, Int_t index) 
     284             : {
     285             :   //------------------------------------------------------------------
     286             :   //This function updates track parameters
     287             :   //------------------------------------------------------------------
     288           0 :   Double_t p[2]={c->GetY(), c->GetZ()};
     289           0 :   Double_t cov[3]={c->GetSigmaY2(), 0., c->GetSigmaZ2()};
     290             : 
     291           0 :   if (!AliExternalTrackParam::Update(p,cov)) return kFALSE;
     292             : 
     293           0 :   Int_t n=GetNumberOfClusters();
     294             : 
     295           0 :   if (chi2<0) return kTRUE;
     296             : 
     297           0 :   fIndex[n]=index;
     298           0 :   SetNumberOfClusters(n+1);
     299           0 :   SetChi2(GetChi2()+chi2);
     300             : 
     301           0 :   return kTRUE;
     302           0 : }
     303             : 
     304             : 
     305             : 
     306             : //____________________________________________________________________________
     307             : Bool_t AliHLTITSTrack::Propagate(Double_t alp,Double_t xk) {
     308             :   //------------------------------------------------------------------
     309             :   //This function propagates a track
     310             :   //------------------------------------------------------------------
     311           0 :   Double_t bz=GetBz();
     312           0 :   if (!AliExternalTrackParam::Propagate(alp,xk,bz)) return kFALSE;
     313             : 
     314           0 :   return kTRUE;
     315           0 : }
     316             : 
     317             : 
     318             : 
     319             : 
     320             : 
     321             : //____________________________________________________________________________
     322             : Bool_t AliHLTITSTrack::
     323             : GetPhiZat(Double_t r, Double_t &phi, Double_t &z) const {
     324             :   //------------------------------------------------------------------
     325             :   // This function returns the global cylindrical (phi,z) of the track 
     326             :   // position estimated at the radius r. 
     327             :   // The track curvature is neglected.
     328             :   //------------------------------------------------------------------
     329           0 :   Double_t d=GetD(0.,0.);
     330           0 :   if (TMath::Abs(d) > r) {
     331           0 :     if (r>1e-1) return kFALSE;
     332           0 :     r = TMath::Abs(d);
     333           0 :   }
     334             : 
     335           0 :   Double_t rcurr=TMath::Sqrt(GetX()*GetX() + GetY()*GetY());
     336           0 :   if (TMath::Abs(d) > rcurr) return kFALSE;
     337           0 :   Double_t globXYZcurr[3]; GetXYZ(globXYZcurr); 
     338           0 :   Double_t phicurr=TMath::ATan2(globXYZcurr[1],globXYZcurr[0]);
     339             : 
     340           0 :   if (GetX()>=0.) {
     341           0 :     phi=phicurr+TMath::ASin(d/r)-TMath::ASin(d/rcurr);
     342           0 :   } else {
     343           0 :     phi=phicurr+TMath::ASin(d/r)+TMath::ASin(d/rcurr)-TMath::Pi();
     344             :   }
     345             : 
     346             :   // return a phi in [0,2pi[ 
     347           0 :   if (phi<0.) phi+=2.*TMath::Pi();
     348           0 :   else if (phi>=2.*TMath::Pi()) phi-=2.*TMath::Pi();
     349           0 :   z=GetZ()+GetTgl()*(TMath::Sqrt((r-d)*(r+d))-TMath::Sqrt((rcurr-d)*(rcurr+d)));
     350             :   return kTRUE;
     351           0 : }
     352             : 
     353             : //____________________________________________________________________________
     354             : Bool_t AliHLTITSTrack::
     355             : GetLocalXPhiZat(Double_t r,Double_t &xloc, double &phi, double &z ) const 
     356             : {
     357             :   // This function returns the local x of the track position estimated at the radius r. 
     358             : 
     359           0 :   double s = GetSnp();
     360           0 :   double c = 1-s*s;
     361           0 :   if( c<kAlmost0 ) return 0;
     362           0 :   c = TMath::Sqrt(c);
     363           0 :   double k = GetC( GetBz() );
     364             : 
     365           0 :   double xc = GetX()*k - s; // center of the circle * curvature
     366           0 :   double yc = GetY()*k + c;
     367           0 :   double l2 = xc*xc + yc*yc;
     368             : 
     369           0 :   if( l2<kAlmost0 ) return 0; // the track is curved and the center is close to (0,0)
     370             :   
     371             :   // a = (r^2+ l2/k^2 -1/k^2)/2 * k
     372           0 :   double r2 = r*r;
     373           0 :   double a = k*(r2 + GetX()*GetX() + GetY()*GetY())/2 + GetY()*c - GetX()*s;
     374           0 :   double d = r2*l2-a*a;
     375           0 :   if( d<kAlmost0 ) return 0; // no intersection
     376             : 
     377           0 :   xloc = ( a*xc + yc*TMath::Sqrt(d) )/l2;
     378             : 
     379             :   // transport to xloc
     380             : 
     381           0 :   Double_t dx = xloc - GetX();
     382             : 
     383           0 :   Double_t f1=s, f2= s + k*dx;
     384           0 :   if (TMath::Abs(f2) >= kAlmost1) return kFALSE;
     385             : 
     386           0 :   Double_t c2=TMath::Sqrt((1.-f2)*(1.+f2));
     387             :   
     388           0 :   double yloc = GetY() + dx*(f1+f2)/(c+c2);
     389           0 :   double zloc = GetZ() + dx*(c2 + f2*(f1+f2)/(c+c2))*GetTgl();
     390             : 
     391           0 :   phi = GetAlpha() + TMath::ATan2(yloc, xloc);
     392             :   
     393             :   // return the phi in [0,2pi]
     394           0 :   phi -= ( (int) (phi/TMath::TwoPi()) )*TMath::TwoPi();
     395           0 :   z = zloc;
     396             : 
     397             :   return 1;
     398           0 : }
     399             : 
     400             : 
     401             : Bool_t AliHLTITSTrack::GetYZAtPhiX( double phi, double x,
     402             :                                     double &y, double&z, double &snp, double cov[3] ) const
     403             : {
     404           0 :   double bz = GetBz();
     405           0 :   AliExternalTrackParam t(*this);
     406             : 
     407             :   // check for the angle to suppress call of AliError() in AliExternalTrackParam::Rotate()
     408             :   {
     409           0 :     double da = phi - GetAlpha();
     410           0 :     Double_t ca=TMath::Cos(da), sa=TMath::Sin(da);
     411           0 :     Double_t sf=GetSnp(), cf=TMath::Sqrt((1.-sf)*(1.+sf));
     412           0 :     Double_t tmp=sf*ca - cf*sa;
     413           0 :     if (TMath::Abs(tmp) >= kAlmost1) return 0;
     414           0 :   }
     415             : 
     416           0 :   if (!t.Rotate(phi)) return 0;
     417           0 :   if (!t.PropagateTo(x,bz)) return 0;  
     418             : 
     419           0 :   y = t.GetY();
     420           0 :   z = t.GetZ();
     421           0 :   snp = t.GetSnp();
     422           0 :   if( t.GetSigmaY2()<0 || t.GetSigmaZ2()<=0 ) return 0;
     423             : 
     424           0 :   cov[0] = t.GetCovariance()[0];
     425           0 :   cov[1] = t.GetCovariance()[1];
     426           0 :   cov[2] = t.GetCovariance()[2];
     427           0 :   return 1;
     428           0 : }

Generated by: LCOV version 1.11