]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/BASE/util/AliHLTGlobalBarrelTrack.cxx
dd8b8e8468cd01c3d9c5d4e0b63bd6f19091ca3e
[u/mrichter/AliRoot.git] / HLT / BASE / util / AliHLTGlobalBarrelTrack.cxx
1 // $Id$
2
3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project        * 
5 //* ALICE Experiment at CERN, All rights reserved.                         *
6 //*                                                                        *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no>        *
8 //*                  for The ALICE HLT Project.                            *
9 //*                                                                        *
10 //* Permission to use, copy, modify and distribute this software and its   *
11 //* documentation strictly for non-commercial purposes is hereby granted   *
12 //* without fee, provided that the above copyright notice appears in all   *
13 //* copies and that both the copyright notice and this permission notice   *
14 //* appear in the supporting documentation. The authors make no claims     *
15 //* about the suitability of this software for any purpose. It is          *
16 //* provided "as is" without express or implied warranty.                  *
17 //**************************************************************************
18
19 /** @file   AliHLTGlobalBarrelTrack.cxx
20     @author Matthias Richter
21     @date   2009-06-24
22     @brief  An AliKalmanTrack implementation for global HLT barrel tracks.
23 */
24
25 // see header file for class documentation
26 // or
27 // refer to README to build package
28 // or
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
30
31 #include <cassert>
32 #include "AliHLTGlobalBarrelTrack.h"
33
34 /** ROOT macro for the implementation of ROOT specific class methods */
35 ClassImp(AliHLTGlobalBarrelTrack)
36
37 AliHLTGlobalBarrelTrack::AliHLTGlobalBarrelTrack()
38 : AliKalmanTrack()
39   , fPoints()
40   , fLastX(0.0)
41   , fLastY(0.0)
42   , fTrackID(-1)
43 {
44   // see header file for class documentation
45   // or
46   // refer to README to build package
47   // or
48   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
49 }
50
51 AliHLTGlobalBarrelTrack::AliHLTGlobalBarrelTrack(const AliHLTGlobalBarrelTrack& t)
52   : AliKalmanTrack(t)
53   , fPoints()
54   , fLastX(t.GetLastPointX())
55   , fLastY(t.GetLastPointY())
56   , fTrackID(t.TrackID())
57 {
58   // see header file for class documentation
59   fPoints.assign(t.fPoints.begin(), t.fPoints.end());
60 }
61
62 AliHLTGlobalBarrelTrack::AliHLTGlobalBarrelTrack(const AliHLTExternalTrackParam& p )
63   : AliKalmanTrack()
64   , fPoints()
65   , fLastX(p.fLastX)
66   , fLastY(p.fLastY)
67   , fTrackID(p.fTrackID)
68 {
69   // see header file for class documentation
70
71   // the 5 track parameters are named in the AliHLTExternalTrackParam
72   // while AliExternalTrackParam just uses an array[5]
73   // the members have the some order, fY is the first one
74   Set(p.fX, p.fAlpha, &p.fY, p.fC);
75   SetPoints(p.fPointIDs, p.fNPoints);
76   SetNumberOfClusters(p.fNPoints);
77   //SetIntegratedLength(GetPathLengthTo( GetLastPointX(), b);
78 }
79
80 template <class c>
81 AliHLTGlobalBarrelTrack& AliHLTGlobalBarrelTrack::operator=(const c& p)
82 {
83   // see header file for class documentation
84   this->~AliHLTGlobalBarrelTrack();
85   new (this) AliHLTGlobalBarrelTrack(p);
86   return *this;
87 }
88
89 AliHLTGlobalBarrelTrack::~AliHLTGlobalBarrelTrack()
90 {
91   // see header file for class documentation
92 }
93
94
95 Double_t AliHLTGlobalBarrelTrack::GetPathLengthTo( Double_t x, Double_t b ) const
96 {
97   // calculate the trajectory length for dx step
98     
99   Double_t dx = x - GetX();
100   Double_t ey = GetSnp();
101   if( TMath::Abs( ey )>=kAlmost1 ) return 0;
102
103   Double_t ex = TMath::Sqrt(1-ey*ey);
104   Double_t k  = GetC(b);
105
106   Double_t ey1 = k * dx + ey;
107
108   // check for intersection with X=x
109
110   if ( TMath::Abs( ey1 ) >= kAlmost1  ) return 0;
111
112   Double_t ex1 = TMath::Sqrt(1-ey1*ey1);
113
114   Double_t dx2 = dx * dx;
115   Double_t ss = ey + ey1;
116   Double_t cc = ex + ex1;
117
118   if ( TMath::Abs( cc ) < 1.e-4  ) return 0;
119
120   Double_t tg = ss / cc; 
121   Double_t dl = dx * TMath::Sqrt( 1 + tg * tg );
122   Double_t dSin = dl * k / 2;
123   if ( dSin > 1 ) dSin = 1;
124   if ( dSin < -1 ) dSin = -1;
125   Double_t dS = ( TMath::Abs( k ) > 1.e-4 )  ? ( 2 * TMath::ASin( dSin ) / k ) : dl;
126
127   return dS*TMath::Sqrt(1 + GetTgl()*GetTgl() );
128 }
129
130
131
132 int AliHLTGlobalBarrelTrack::ConvertTrackDataArray(const AliHLTTracksData* pTracks, unsigned sizeInByte, vector<AliHLTGlobalBarrelTrack> &tgtArray )
133 {
134   // see header file for class documentation
135   int iResult=0;
136   tgtArray.clear();
137   if (!pTracks || sizeInByte<sizeof(AliHLTTracksData) || pTracks->fCount==0) return 0;
138
139   const AliHLTUInt8_t* pEnd=reinterpret_cast<const AliHLTUInt8_t*>(pTracks);
140   pEnd+=sizeInByte;
141
142   tgtArray.resize(pTracks->fCount);
143   const AliHLTUInt8_t* pCurrent=reinterpret_cast<const AliHLTUInt8_t*>(pTracks->fTracklets);
144   for (unsigned i=0; i<pTracks->fCount; i++) {
145     if (pCurrent+sizeof(AliHLTExternalTrackParam)>pEnd) {
146       iResult=-EINVAL; break;
147     }
148     const AliHLTExternalTrackParam* track=reinterpret_cast<const AliHLTExternalTrackParam*>(pCurrent);
149     if (pCurrent+sizeof(AliHLTExternalTrackParam)+track->fNPoints*sizeof(UInt_t)>pEnd) {
150       iResult=-EINVAL; break;
151     }
152     tgtArray[i]=*track;
153     pCurrent+=sizeof(AliHLTExternalTrackParam)+track->fNPoints*sizeof(UInt_t);
154   }
155   if (iResult<0) tgtArray.clear();
156   else iResult=tgtArray.size();
157   return iResult;
158 }
159
160 UInt_t AliHLTGlobalBarrelTrack::GetNumberOfPoints() const
161 {
162   // see header file for class documentation
163   return fPoints.size();
164 }
165
166 const UInt_t* AliHLTGlobalBarrelTrack::GetPoints() const
167 {
168   // see header file for class documentation
169   if (fPoints.size()==0) return NULL;
170   return &fPoints[0];
171 }
172
173 int AliHLTGlobalBarrelTrack::SetPoints(const UInt_t* pArray, UInt_t arraySize)
174 {
175   // see header file for class documentation
176   if (!pArray || arraySize==0) return 0;
177   fPoints.resize(arraySize);
178   for (unsigned i=0; i<arraySize; i++) fPoints[i]=pArray[i];
179   return fPoints.size();
180 }
181
182 void AliHLTGlobalBarrelTrack::Print(Option_t* option) const
183 {
184   // see header file for class documentation
185   cout << "********* Track Id: " << fTrackID << " *******************" << endl;
186   AliExternalTrackParam::Print(option);
187 //   cout << "  Alpha "     << GetAlpha();
188 //   cout << "  X "         << GetX();
189 //   cout << "  Y "         << GetY();
190 //   cout << "  Z "         << GetZ() << endl;
191 //   cout << "  Snp "       << GetSnp();
192 //   cout << "  Tgl "       << GetTgl();
193 //   cout << "  Signed1Pt " << GetSigned1Pt() << endl;
194 }