StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
AliHLTTPCCAParam.h
1 //-*- Mode: C++ -*-
2 // @(#) $Id: AliHLTTPCCAParam.h,v 1.1 2016/02/05 23:27:28 fisyak Exp $
3 // ************************************************************************
4 // This file is property of and copyright by the ALICE HLT Project *
5 // ALICE Experiment at CERN, All rights reserved. *
6 // See cxx source for full Copyright notice *
7 // *
8 //*************************************************************************
9 
10 #ifndef ALIHLTTPCCAPARAM_H
11 #define ALIHLTTPCCAPARAM_H
12 
13 #include "AliHLTTPCCADef.h"
14 #include "AliHLTTPCCAMath.h"
15 #include "AliHLTTPCCATrackParam.h"
16 #include "AliHLTTPCCAParameters.h"
17 #include <cstdio>
18 #include <vector>
19 using std::vector;
20 #if 0
21 namespace std
22 {
23  template<typename T> struct char_traits;
24  template<typename _CharT, typename _Traits> class basic_istream;
25  typedef basic_istream<char, char_traits<char> > istream;
26  template<typename _CharT, typename _Traits> class basic_ostream;
27  typedef basic_ostream<char, char_traits<char> > ostream;
28 } // namespace std
29 #endif
30 
39 {
40  friend std::istream &operator>>( std::istream &, AliHLTTPCCAParam & );
41  friend std::ostream &operator<<( std::ostream &, const AliHLTTPCCAParam & );
42  public:
43 
45 
46  void Initialize( int iSlice, int nRows, float rowX[],
47  float alpha, float dAlpha,
48  float rMin, float rMax, float zMin, float zMax,
49  float padPitch, float zSigma, float bz );
50  void Update();
51 
52  void Slice2Global( float x, float y, float z,
53  float *X, float *Y, float *Z ) const;
54 
55  void Global2Slice( float x, float y, float z,
56  float *X, float *Y, float *Z ) const;
57 
58 
59  int ISlice() const { return fISlice;}
60  int NRows() const { return fNRows; }
61  int NRows8() const { return fNRows + sfloat_v::Size - (fNRows-1)%sfloat_v::Size - 1;} // NRows8 % sfloat_v::Size == 0 && NRows + sfloat_v::Size > NRows8 >= NRows
62 //
63  int NInnerRows() const { return fNInnerRows; }
64 
65  const float *RowX() const { return &(fRowX[0]); }
66  float RowX( int iRow ) const { return fRowX[iRow]; }
67 
68  float Alpha() const { return fAlpha;}
69  float Alpha( int iSlice ) const { return 0.0 + DAlpha()*iSlice;} // TODO: From file!
70  float DAlpha() const { return fDAlpha;}
71  float CosAlpha() const { return fCosAlpha;}
72  float SinAlpha() const { return fSinAlpha;}
73  float AngleMin() const { return fAngleMin;}
74  float AngleMax() const { return fAngleMax;}
75  float RMin() const { return fRMin;}
76  float RMax() const { return fRMax;}
77  float ZMin() const { return fZMin;}
78  float ZMax() const { return fZMax;}
79  float ErrZ() const { return fErrZ;}
80  float ErrX() const { return fErrX;}
81  float ErrY() const { return fErrY;}
82  float Bz() const { return fBz;}
83  float cBz() const { return fBz*0.000299792458;}
84 
85  float TrackConnectionFactor() const { return fTrackConnectionFactor; }
86  float TrackChiCut() const { return fTrackChiCut; }
87  float TrackChi2Cut() const { return fTrackChi2Cut; }
88  int MaxTrackMatchDRow() const { return fMaxTrackMatchDRow; }
89  float HitPickUpFactor() const { return fHitPickUpFactor; }
90 
91 
92 
93  void SetISlice( int v ) { fISlice = v;}
94  void SetNRows( int v ) { fNRows = v; fRowX.resize(fNRows);}
95  void SetNInnerRows( int v ) { fNInnerRows = v;}
96  void SetRowX( int iRow, float v ) { fRowX[iRow] = v; }
97  void SetAlpha( float v ) { fAlpha = v;}
98  void SetDAlpha( float v ) { fDAlpha = v;}
99  void SetCosAlpha( float v ) { fCosAlpha = v;}
100  void SetSinAlpha( float v ) { fSinAlpha = v;}
101  void SetAngleMin( float v ) { fAngleMin = v;}
102  void SetAngleMax( float v ) { fAngleMax = v;}
103  void SetRMin( float v ) { fRMin = v;}
104  void SetRMax( float v ) { fRMax = v;}
105  void SetZMin( float v ) { fZMin = v;}
106  void SetZMax( float v ) { fZMax = v;}
107  void SetErrZ( float v ) { fErrZ = v;}
108  void SetErrX( float v ) { fErrX = v;}
109  void SetErrY( float v ) { fErrY = v;}
110  void SetBz( float v ) { fBz = v;}
111  void SetTrackConnectionFactor( float v ) { fTrackConnectionFactor = v;}
112  void SetTrackChiCut( float v ) { fTrackChiCut = v; }
113  void SetTrackChi2Cut( float v ) { fTrackChi2Cut = v; }
114  void SetMaxTrackMatchDRow( int v ) { fMaxTrackMatchDRow = v; }
115  void SetHitPickUpFactor( float v ) { fHitPickUpFactor = v; }
116  void SetRecoType( int reco) { fRecoType = reco; }
117 
119 /* void GetClusterErrors2( int iRow, float z, float sinPhi, float cosPhi, float DzDs, float &Err2Y, float &Err2Z ) const;
120 
121  void GetClusterErrors2( int iRow, sfloat_v z, sfloat_v sinPhi, sfloat_v DzDs, sfloat_v &Err2Y, sfloat_v &Err2Z ) const;
122  void GetClusterErrors2( ushort_v rowIndexes, sfloat_v z, sfloat_v sinPhi, sfloat_v DzDs, sfloat_v &Err2Y, sfloat_v &Err2Z ) const;*/
123 
124  void GetClusterErrors2( int iRow, const AliHLTTPCCATrackParam &t, float &Err2Y, float &Err2Z ) const;
125  void GetClusterErrors2( ushort_v rowIndexes, const sfloat_v &X, const sfloat_v &Y, sfloat_v &Z, sfloat_v &Err2Y, sfloat_v &Err2Z ) const;
127 
128  void GetClusterErrors2( int iRow, const TrackParamVector &t, sfloat_v *Err2Y, sfloat_v *Err2Z ) const;
129  void GetClusterErrors2( ushort_v rowIndexes, const TrackParamVector &t, sfloat_v *Err2Y, sfloat_v *Err2Z ) const;
130 
131  void SetParamS0Par( int i, int j, int k, float val ) {
132  fParamS0Par[i][j][k] = val;
133  }
134 
135  float GetBz() const { return fBz;}
136  float GetBz( float x, float y, float z ) const;
137  sfloat_v GetBz( sfloat_v x, sfloat_v y, sfloat_v z ) const;
138  float GetBz( const AliHLTTPCCATrackParam &t ) const;
139  sfloat_v GetBz( const AliHLTTPCCATrackParamVector &t ) const;
140 
141  void StoreToFile( FILE *f ) const;
142  void RestoreFromFile( FILE *f );
143 
144  protected:
145  float GetClusterError2( int yz, int type, float z, float angle ) const;
146  sfloat_v GetClusterError2( int yz, int type, sfloat_v z, sfloat_v angle ) const;
147 
148  int fISlice; // slice number
149  int fNRows; // number of rows
150  int fNInnerRows; // number of inner rows
151 
152  float fAlpha, fDAlpha; // slice angle and angular size
153  float fCosAlpha, fSinAlpha;// sign and cosine of the slice angle
154  float fAngleMin, fAngleMax; // minimal and maximal angle
155  float fRMin, fRMax;// slice R range
156  float fZMin, fZMax;// slice Z range
157  float fErrX, fErrY, fErrZ;// default cluster errors
158  float fPadPitch; // pad pitch
159  float fBz; // magnetic field value (only constant field can be used)
160 
161  float fHitPickUpFactor;// multiplier for the chi2 window for hit pick up procedure
162 
163  int fMaxTrackMatchDRow;// maximal jump in TPC row for connecting track segments
164  float fTrackConnectionFactor; // allowed distance in Chi^2/3.5 for neighbouring tracks
165  float fTrackChiCut; // cut for track Sqrt(Chi2/NDF);
166  float fTrackChi2Cut;// cut for track Chi^2/NDF
167 
168  vector<float> fRowX;// X-coordinate of rows
169  int fRecoType; // 0=Sti error parametrization; 1=Stv
170  float fParamS0Par[2][3][7]; // cluster error parameterization coeficients
171  float fPolinomialFieldBz[6]; // field coefficients
172 
173  private:
175 /*
176  inline int errorType( int row ) const {
177  int type = 0;
178 // const int numberOfRows = AliHLTTPCCAParameters::NumberOfRows;
179  if ( ISLIKELY( row >= fInnerRows ) ) {
180  type = ( row > 126 ? 1 : 2 );
181  }
182  return type;
183  }
184  inline ushort_v errorType( short_v row ) const {
185  ushort_v type( 14 );
186  type.makeZero( row < fInnerRows );
187  type( row > 126 ) = 7;
188  return type;
189  }
190 */
191  inline int errorType( int row ) const {
192  int type = 0;
193  type = ( row < fNInnerRows ? 0 : 1 );
194  return type;
195  }
196  inline ushort_v errorType( short_v row ) const {
197  ushort_v type( 7 );
198  type.setZero( row < fNInnerRows );
199  //type( row > 126 ) = 7;
200  return type;
201  }
203 };
204 
205 
206 std::istream &operator>>( std::istream &, AliHLTTPCCAParam & );
207 std::ostream &operator<<( std::ostream &, const AliHLTTPCCAParam & );
208 
209 inline float AliHLTTPCCAParam::GetBz( float x, float y, float z ) const
210 {
211  float r2 = x * x + y * y;
212  float r = CAMath::Sqrt( r2 );
213  const float *c = fPolinomialFieldBz;
214  return ( c[0] + c[1]*z + c[2]*r + c[3]*z*z + c[4]*z*r + c[5]*r2 );
215 }
216 
217 inline sfloat_v AliHLTTPCCAParam::GetBz( sfloat_v x, sfloat_v y, sfloat_v z ) const
218 {
219  sfloat_v r2 = x * x + y * y;
220  sfloat_v r = CAMath::Sqrt( r2 );
221  const float *c = fPolinomialFieldBz;
222  return ( c[0] + c[1]*z + c[2]*r + c[3]*z*z + c[4]*z*r + c[5]*r2 );
223 }
224 
225 inline float AliHLTTPCCAParam::GetBz( const AliHLTTPCCATrackParam &t ) const
226 {
227  return GetBz( t.X(), t.Y(), t.Z() );
228 }
229 
230 inline sfloat_v AliHLTTPCCAParam::GetBz( const AliHLTTPCCATrackParamVector &t ) const
231 {
232  return GetBz( t.X(), t.Y(), t.Z() );
233 }
234 
236 /*
237 inline sfloat_v AliHLTTPCCAParam::GetClusterError2( int yz, int type, sfloat_v z, sfloat_v angle ) const
238 {
239  // recalculate the cluster error wih respect to the track slope
240  const sfloat_v angle2 = angle * angle;
241  const float *c = fParamS0Par[yz][type];
242  const sfloat_v v = c[0] + z * ( c[1] + c[3] * z ) + angle2 * ( c[2] + angle2 * c[4] + c[5] * z );
243  return CAMath::Abs( v );
244 }
245 
246 inline void AliHLTTPCCAParam::GetClusterErrors2( int iRow, const TrackParamVector &t, sfloat_v *Err2Y, sfloat_v *Err2Z ) const
247 {
248  //
249  // Use calibrated cluster error from OCDB
250  //
251 
252  const sfloat_v &z = CAMath::Abs( ( 250.f - 0.275f ) - CAMath::Abs( t.Z() ) );
253  const int type = errorType( iRow );
254  const sfloat_v &sinPhi = t.SinPhi();
255  const sfloat_v &cosPhiInv = t.SignCosPhi() / CAMath::Sqrt( sfloat_v( Vc::One ) - sinPhi * sinPhi ); // RSqrt
256  const sfloat_v &angleY = sinPhi * cosPhiInv;
257  const sfloat_v &angleZ = t.DzDs() * cosPhiInv; // SG was bug???
258 
259  debugF() << "GetClusterErrors2 y,z angles: " << angleY << angleZ << std::endl;
260 
261  *Err2Y = GetClusterError2( 0, type, z, angleY );
262  *Err2Z = GetClusterError2( 1, type, z, angleZ );
263 }
264 
265 inline void AliHLTTPCCAParam::GetClusterErrors2( int iRow, sfloat_v z, sfloat_v sinPhi, sfloat_v DzDs, sfloat_v &Err2Y, sfloat_v &Err2Z ) const
266 {
267  //
268  // Use calibrated cluster error from OCDB
269  //
270 
271  z = CAMath::Abs( ( 250.f - 0.275f ) - CAMath::Abs( z ) );
272  const int type = errorType( iRow );
273  const sfloat_v cosPhiInv = sfloat_v( Vc::One ) / CAMath::Sqrt( sfloat_v( Vc::One ) - sinPhi * sinPhi ); // RSqrt
274  sfloat_v angleY = sinPhi * cosPhiInv;
275  sfloat_v angleZ = DzDs * cosPhiInv; // SG was bug???
276 
277  debugF() << "GetClusterErrors2 y,z angles: " << angleY << angleZ << std::endl;
278 
279  Err2Y = GetClusterError2( 0, type, z, angleY );
280  Err2Z = GetClusterError2( 1, type, z, angleZ );
281 }
282 
283 inline void AliHLTTPCCAParam::GetClusterErrors2( ushort_v rowIndexes, const TrackParamVector &t, sfloat_v *Err2Y, sfloat_v *Err2Z ) const
284 {
285  const sfloat_v &z = CAMath::Abs( ( 250.f - 0.275f ) - CAMath::Abs( t.Z() ) );
286  const ushort_v type = errorType( static_cast<short_v>( rowIndexes ) );
287  const sfloat_v &sinPhi = t.SinPhi();
288  const sfloat_v &cosPhiInv = t.SignCosPhi() / CAMath::Sqrt( sfloat_v( Vc::One ) - sinPhi * sinPhi ); // RSqrt
289  const sfloat_v &angleY = sinPhi * cosPhiInv;
290  const sfloat_v &angleZ = t.DzDs() * cosPhiInv; // SG was bug???
291 
292  const sfloat_v angleY2 = angleY * angleY;
293  const float *c = &fParamS0Par[0][0][0];
294  sfloat_v v( c, type );
295  v += z * ( sfloat_v( c + 1, type ) + sfloat_v( c + 3, type ) * z );
296  v += angleY2 * ( sfloat_v( c + 2, type ) + angleY2 * sfloat_v( c + 4, type ) + sfloat_v( c + 5, type ) * z );
297  *Err2Y = CAMath::Abs( v );
298 
299  const sfloat_v angleZ2 = angleZ * angleZ;
300  c = &fParamS0Par[1][0][0];
301  v.gather( c, type );
302  v += z * ( sfloat_v( c + 1, type ) + sfloat_v( c + 3, type ) * z );
303  v += angleZ2 * ( sfloat_v( c + 2, type ) + angleZ2 * sfloat_v( c + 4, type ) + sfloat_v( c + 5, type ) * z );
304  *Err2Z = CAMath::Abs( v );
305 }
306 
307 inline void AliHLTTPCCAParam::GetClusterErrors2( ushort_v rowIndexes, sfloat_v z, sfloat_v sinPhi, sfloat_v DzDs, sfloat_v &Err2Y, sfloat_v &Err2Z ) const
308 {
309  z = CAMath::Abs( ( 250.f - 0.275f ) - CAMath::Abs( z ) );
310  const ushort_v type = errorType( static_cast<short_v>( rowIndexes ) );
311  const sfloat_v cosPhiInv = sfloat_v( Vc::One ) / CAMath::Sqrt( sfloat_v( Vc::One ) - sinPhi * sinPhi ); // RSqrt
312  sfloat_v angleY = sinPhi * cosPhiInv;
313  sfloat_v angleZ = DzDs * cosPhiInv; // SG was bug???
314 
315  const sfloat_v angleY2 = angleY * angleY;
316  const float *c = &fParamS0Par[0][0][0];
317  sfloat_v v( c, type );
318  v += z * ( sfloat_v( c + 1, type ) + sfloat_v( c + 3, type ) * z );
319  v += angleY2 * ( sfloat_v( c + 2, type ) + angleY2 * sfloat_v( c + 4, type ) + sfloat_v( c + 5, type ) * z );
320  Err2Y = CAMath::Abs( v );
321 
322  const sfloat_v angleZ2 = angleZ * angleZ;
323  c = &fParamS0Par[1][0][0];
324  v.gather( c, type );
325  v += z * ( sfloat_v( c + 1, type ) + sfloat_v( c + 3, type ) * z );
326  v += angleZ2 * ( sfloat_v( c + 2, type ) + angleZ2 * sfloat_v( c + 4, type ) + sfloat_v( c + 5, type ) * z );
327  Err2Z = CAMath::Abs( v );
328 }
329 */
330 inline void AliHLTTPCCAParam::GetClusterErrors2( int iRow, const TrackParamVector &t, sfloat_v *Err2Y, sfloat_v *Err2Z ) const
331 {
332  const sfloat_v one = sfloat_v(Vc::One);
333  const sfloat_v zero = sfloat_v(Vc::Zero);
334  sfloat_v z = t.Z();
335  const int type = errorType( iRow );
336  z = (200.f - CAMath::Abs(z)) * 0.01f;
337  z(z < zero) = zero;
338 
339  sfloat_v sin2Phi = t.GetSinPhi()*t.GetSinPhi();
340  sfloat_v cos2Phi = (one - sin2Phi);
341  cos2Phi(cos2Phi < 0.0001f) = 0.0001f;
342  sfloat_v tg2Phi = sin2Phi/cos2Phi;
343 
344  sfloat_v tg2Lambda = t.DzDs()*t.DzDs();
345 
346  const float *c = fParamS0Par[0][type];
347  sfloat_v v = c[0] + c[1]*z/cos2Phi + c[2]*tg2Phi;
348  sfloat_v w = c[3] + c[4]*z*(one + tg2Lambda) + c[5]*tg2Lambda;
349  v(v>one) = one;
350  w(w>one) = one;
351 
352  const sfloat_v errmin=1e-6f;
353  v(v<errmin) = errmin;
354  w(w<errmin) = errmin;
355 
356  *Err2Y = CAMath::Abs( v );
357  *Err2Z = CAMath::Abs( w );
358 }
359 
360 inline void AliHLTTPCCAParam::GetClusterErrors2( ushort_v rowIndexes, const TrackParamVector &t, sfloat_v *Err2Y, sfloat_v *Err2Z ) const
361 {
362  const sfloat_v one = sfloat_v(Vc::One);
363  const sfloat_v zero = sfloat_v(Vc::Zero);
364  sfloat_v z = t.Z();
365  z = (200.f - CAMath::Abs(z)) * 0.01f;
366  z(z < zero) = zero;
367 
368  const ushort_v type = errorType( static_cast<short_v>( rowIndexes ) );
369 
370  sfloat_v sin2Phi = t.GetSinPhi()*t.GetSinPhi();
371  sfloat_v cos2Phi = (one - sin2Phi);
372  cos2Phi(cos2Phi < 0.0001f) = 0.0001f;
373  sfloat_v tg2Phi = sin2Phi/cos2Phi;
374 
375  sfloat_v tg2Lambda = t.DzDs()*t.DzDs();
376 
377  const float *c = &fParamS0Par[0][0][0];
378  const sfloat_v errmin=1e-6f;
379  sfloat_v v( c, type );
380  v += z * sfloat_v( c + 1, type )/cos2Phi + sfloat_v( c + 2, type ) *tg2Phi;
381  v(v>one) = one;
382  v(v<errmin) = errmin;
383  *Err2Y = CAMath::Abs( v );
384 
385  v.gather( c+3, type );
386  v += z * sfloat_v( c + 4, type )*(one + tg2Lambda) + sfloat_v( c + 5, type )*tg2Lambda;
387  v(v>one) = one;
388  v(v<errmin) = errmin;
389  *Err2Z = CAMath::Abs( v );
390 }
391 
392 // inline void AliHLTTPCCAParam::GetClusterErrors2( ushort_v rowIndexes, const sfloat_v &X, const sfloat_v &Y, sfloat_v &Z, sfloat_v &Err2Y, sfloat_v &Err2Z ) const
393 // {
394 // const sfloat_v one = sfloat_v(Vc::One);
395 // const sfloat_v zero = sfloat_v(Vc::Zero);
396 // sfloat_v z = Z;
397 // z = (200.f - CAMath::Abs(z)) * 0.01f;
398 // z(z < zero) = zero;
399 
400 // const ushort_v type = errorType( static_cast<short_v>( rowIndexes ) );
401 
402 // sfloat_v tg2Phi = Y/X;
403 // tg2Phi = tg2Phi*tg2Phi;
404 // sfloat_v cos2Phi = one / (one + tg2Phi);
405 // if (cos2Phi<0.0001f) cos2Phi=0.0001f;
406 
407 // sfloat_v s2 = X*X+Y*Y;
408 // sfloat_v tg2Lambda = s2/(Z*Z);
409 // // sfloat_v tg2Lambda = one/t.DzDs();
410 
411 // const float *c = &fParamS0Par[0][0][0];
412 // const sfloat_v errmin=1e-6f;
413 // sfloat_v v( c, type );
414 // v += z * sfloat_v( c + 1, type )/cos2Phi + sfloat_v( c + 2, type ) *tg2Phi;
415 // v(v>one) = one;
416 // v(v<errmin) = errmin;
417 // Err2Y = CAMath::Abs( v );
418 
419 // v.gather( c+3, type );
420 // v += z * sfloat_v( c + 4, type )*(one + tg2Lambda) + sfloat_v( c + 5, type )*tg2Lambda;
421 // v(v>one) = one;
422 // v(v<errmin) = errmin;
423 // Err2Z = CAMath::Abs( v );
424 // }
425 
427 
428 #endif
void GetClusterErrors2(int iRow, const AliHLTTPCCATrackParam &t, float &Err2Y, float &Err2Z) const
mvz start 20.01.2010
friend std::ostream & operator<<(std::ostream &, const AliHLTTPCCAParam &)
mvz end 20.01.2010