3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 //* for The ALICE HLT Project. *
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 //**************************************************************************
19 /** @file AliHLTGlobalBarrelTrack.cxx
20 @author Matthias Richter
22 @brief An AliKalmanTrack implementation for global HLT barrel tracks.
25 // see header file for class documentation
27 // refer to README to build package
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
32 #include "AliHLTGlobalBarrelTrack.h"
34 /** ROOT macro for the implementation of ROOT specific class methods */
35 ClassImp(AliHLTGlobalBarrelTrack)
37 AliHLTGlobalBarrelTrack::AliHLTGlobalBarrelTrack()
44 // see header file for class documentation
46 // refer to README to build package
48 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
51 AliHLTGlobalBarrelTrack::AliHLTGlobalBarrelTrack(const AliHLTGlobalBarrelTrack& t)
54 , fLastX(t.GetLastPointX())
55 , fLastY(t.GetLastPointY())
56 , fTrackID(t.TrackID())
58 // see header file for class documentation
59 fPoints.assign(t.fPoints.begin(), t.fPoints.end());
62 AliHLTGlobalBarrelTrack::AliHLTGlobalBarrelTrack(const AliHLTExternalTrackParam& p )
67 , fTrackID(p.fTrackID)
69 // see header file for class documentation
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);
81 AliHLTGlobalBarrelTrack& AliHLTGlobalBarrelTrack::operator=(const c& p)
83 // see header file for class documentation
84 this->~AliHLTGlobalBarrelTrack();
85 new (this) AliHLTGlobalBarrelTrack(p);
89 AliHLTGlobalBarrelTrack::~AliHLTGlobalBarrelTrack()
91 // see header file for class documentation
95 Double_t AliHLTGlobalBarrelTrack::GetPathLengthTo( Double_t x, Double_t b ) const
97 // calculate the trajectory length for dx step
99 Double_t dx = x - GetX();
100 Double_t ey = GetSnp();
101 if( TMath::Abs( ey )>=kAlmost1 ) return 0;
103 Double_t ex = TMath::Sqrt(1-ey*ey);
104 Double_t k = GetC(b);
106 Double_t ey1 = k * dx + ey;
108 // check for intersection with X=x
110 if ( TMath::Abs( ey1 ) >= kAlmost1 ) return 0;
112 Double_t ex1 = TMath::Sqrt(1-ey1*ey1);
114 Double_t dx2 = dx * dx;
115 Double_t ss = ey + ey1;
116 Double_t cc = ex + ex1;
118 if ( TMath::Abs( cc ) < 1.e-4 ) return 0;
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;
127 return dS*TMath::Sqrt(1 + GetTgl()*GetTgl() );
132 int AliHLTGlobalBarrelTrack::ConvertTrackDataArray(const AliHLTTracksData* pTracks, unsigned sizeInByte, vector<AliHLTGlobalBarrelTrack> &tgtArray )
134 // see header file for class documentation
137 if (!pTracks || sizeInByte<sizeof(AliHLTTracksData) || pTracks->fCount==0) return 0;
139 const AliHLTUInt8_t* pEnd=reinterpret_cast<const AliHLTUInt8_t*>(pTracks);
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;
148 const AliHLTExternalTrackParam* track=reinterpret_cast<const AliHLTExternalTrackParam*>(pCurrent);
149 if (pCurrent+sizeof(AliHLTExternalTrackParam)+track->fNPoints*sizeof(UInt_t)>pEnd) {
150 iResult=-EINVAL; break;
153 pCurrent+=sizeof(AliHLTExternalTrackParam)+track->fNPoints*sizeof(UInt_t);
155 if (iResult<0) tgtArray.clear();
156 else iResult=tgtArray.size();
160 UInt_t AliHLTGlobalBarrelTrack::GetNumberOfPoints() const
162 // see header file for class documentation
163 return fPoints.size();
166 const UInt_t* AliHLTGlobalBarrelTrack::GetPoints() const
168 // see header file for class documentation
169 if (fPoints.size()==0) return NULL;
173 int AliHLTGlobalBarrelTrack::SetPoints(const UInt_t* pArray, UInt_t arraySize)
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();
182 void AliHLTGlobalBarrelTrack::Print(Option_t* option) const
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;