StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
AliHLTTPCCAParam.cxx
1 // @(#) $Id: AliHLTTPCCAParam.cxx,v 1.2 2016/06/21 03:39:45 smirnovd Exp $
2 // **************************************************************************
3 // This file is property of and copyright by the ALICE HLT Project *
4 // ALICE Experiment at CERN, All rights reserved. *
5 // *
6 // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
7 // Ivan Kisel <kisel@kip.uni-heidelberg.de> *
8 // for The ALICE HLT Project. *
9 // *
10 // Developed by: Igor Kulakov <I.Kulakov@gsi.de> *
11 // Maksym Zyzak <M.Zyzak@gsi.de> *
12 // *
13 // Permission to use, copy, modify and distribute this software and its *
14 // documentation strictly for non-commercial purposes is hereby granted *
15 // without fee, provided that the above copyright notice appears in all *
16 // copies and that both the copyright notice and this permission notice *
17 // appear in the supporting documentation. The authors make no claims *
18 // about the suitability of this software for any purpose. It is *
19 // provided "as is" without express or implied warranty. *
20 // *
21 //***************************************************************************
22 
23 
24 #include "AliHLTTPCCAParam.h"
25 #include "AliHLTTPCCAMath.h"
26 
27 #include <iostream>
28 #include "debug.h"
29 
31  : fISlice( 0 ), fNRows( 0 ), fNInnerRows(0), fAlpha( 0.174533 ), fDAlpha( 0.349066 ),
32  fCosAlpha( 0 ), fSinAlpha( 0 ), fAngleMin( 0 ), fAngleMax( 0 ), fRMin( 83.65 ), fRMax( 133.3 ),
33  fZMin( 0.0529937 ), fZMax( 249.778 ), fErrX( 0 ), fErrY( 0 ), fErrZ( 0.228808 ), fPadPitch( 0.4 ), fBz( -5. ),
34  fHitPickUpFactor( 1. ),
35  fMaxTrackMatchDRow( 4 ), fTrackConnectionFactor( 3.5 ), fTrackChiCut( 3.5 ), fTrackChi2Cut( 10 ) // are rewrited from file. See operator>>()
36  ,fRowX(0), fRecoType(0) //Default is Sti
37 {
38  // constructor
40 /* fParamS0Par[0][0][0] = 0.00047013f;
41  fParamS0Par[0][0][1] = 2.00135e-05f;
42  fParamS0Par[0][0][2] = 0.0106533f;
43  fParamS0Par[0][0][3] = 5.27104e-08f;
44  fParamS0Par[0][0][4] = 0.012829f;
45  fParamS0Par[0][0][5] = 0.000147125f;
46  fParamS0Par[0][0][6] = 4.99432f;
47  fParamS0Par[0][1][0] = 0.000883342f;
48  fParamS0Par[0][1][1] = 1.07011e-05f;
49  fParamS0Par[0][1][2] = 0.0103187f;
50  fParamS0Par[0][1][3] = 4.25141e-08f;
51  fParamS0Par[0][1][4] = 0.0224292f;
52  fParamS0Par[0][1][5] = 8.27274e-05f;
53  fParamS0Par[0][1][6] = 4.17233f;
54  fParamS0Par[0][2][0] = 0.000745399f;
55  fParamS0Par[0][2][1] = 5.62408e-06f;
56  fParamS0Par[0][2][2] = 0.0151562f;
57  fParamS0Par[0][2][3] = 5.08757e-08f;
58  fParamS0Par[0][2][4] = 0.0601004f;
59  fParamS0Par[0][2][5] = 7.97129e-05f;
60  fParamS0Par[0][2][6] = 4.84913f;
61  fParamS0Par[1][0][0] = 0.00215126f;
62  fParamS0Par[1][0][1] = 6.82233e-05f;
63  fParamS0Par[1][0][2] = 0.0221867f;
64  fParamS0Par[1][0][3] = -6.27825e-09f;
65  fParamS0Par[1][0][4] = -0.00745378f;
66  fParamS0Par[1][0][5] = 0.000172629f;
67  fParamS0Par[1][0][6] = 6.24987f;
68  fParamS0Par[1][1][0] = 0.00181667f;
69  fParamS0Par[1][1][1] = -4.17772e-06f;
70  fParamS0Par[1][1][2] = 0.0253429f;
71  fParamS0Par[1][1][3] = 1.3011e-07f;
72  fParamS0Par[1][1][4] = -0.00362827f;
73  fParamS0Par[1][1][5] = 0.00030406f;
74  fParamS0Par[1][1][6] = 17.7775f;
75  fParamS0Par[1][2][0] = 0.00158251f;
76  fParamS0Par[1][2][1] = -3.55911e-06f;
77  fParamS0Par[1][2][2] = 0.0247899f;
78  fParamS0Par[1][2][3] = 7.20604e-08f;
79  fParamS0Par[1][2][4] = 0.0179946f;
80  fParamS0Par[1][2][5] = 0.000425504f;
81  fParamS0Par[1][2][6] = 20.9294f;*/
82 
83  fParamS0Par[0][0][0] = 0.0004f;
84  fParamS0Par[0][0][1] = 0.001720216f;
85  fParamS0Par[0][0][2] = 0.0236289f;
86  fParamS0Par[0][0][3] = 0.001096839f;
87  fParamS0Par[0][0][4] = 0.007570851f;
88  fParamS0Par[0][0][5] = 0.01857614f;
89  fParamS0Par[0][0][6] = 0.0f;
90  fParamS0Par[0][1][0] = 0.001534805f;
91  fParamS0Par[0][1][1] = 0.001422267f;
92  fParamS0Par[0][1][2] = 0.07089186f;
93  fParamS0Par[0][1][3] = 0.002919157f;
94  fParamS0Par[0][1][4] = 0.006362385f;
95  fParamS0Par[0][1][5] = 0.06090711f;
96  fParamS0Par[0][1][6] = 0.0f;
97  fParamS0Par[0][2][0] = 0.0f;
98  fParamS0Par[0][2][1] = 0.0f;
99  fParamS0Par[0][2][2] = 0.0f;
100  fParamS0Par[0][2][3] = 0.0f;
101  fParamS0Par[0][2][4] = 0.0f;
102  fParamS0Par[0][2][5] = 0.0f;
103  fParamS0Par[0][2][6] = 0.0f;
104  fParamS0Par[1][0][0] = 0.0f;
105  fParamS0Par[1][0][1] = 0.0f;
106  fParamS0Par[1][0][2] = 0.0f;
107  fParamS0Par[1][0][3] = 0.0f;
108  fParamS0Par[1][0][4] = 0.0f;
109  fParamS0Par[1][0][5] = 0.0f;
110  fParamS0Par[1][0][6] = 0.0f;
111  fParamS0Par[1][1][0] = 0.0f;
112  fParamS0Par[1][1][1] = 0.0f;
113  fParamS0Par[1][1][2] = 0.0f;
114  fParamS0Par[1][1][3] = 0.0f;
115  fParamS0Par[1][1][4] = 0.0f;
116  fParamS0Par[1][1][5] = 0.0f;
117  fParamS0Par[1][1][6] = 0.0f;
118  fParamS0Par[1][2][0] = 0.0f;
119  fParamS0Par[1][2][1] = 0.0f;
120  fParamS0Par[1][2][2] = 0.0f;
121  fParamS0Par[1][2][3] = 0.0f;
122  fParamS0Par[1][2][4] = 0.0f;
123  fParamS0Par[1][2][5] = 0.0f;
124  fParamS0Par[1][2][6] = 0.0f;
126  const double kCLight = 0.000299792458;
127 
128  fPolinomialFieldBz[0] = kCLight * 4.99643;
129  fPolinomialFieldBz[1] = kCLight * -2.27193e-06;
130  fPolinomialFieldBz[2] = kCLight * 0.000116475;
131  fPolinomialFieldBz[3] = kCLight * -1.49956e-06;
132  fPolinomialFieldBz[4] = kCLight * -1.01721e-07;
133  fPolinomialFieldBz[5] = kCLight * 4.85701e-07;
134 
135  Update();
136 }
137 
138 void AliHLTTPCCAParam::Initialize( int iSlice,
139  int nRows, float rowX[],
140  float alpha, float dAlpha,
141  float rMin, float rMax,
142  float zMin, float zMax,
143  float padPitch, float zSigma,
144  float bz
145  )
146 {
147  // initialization
148  fISlice = iSlice;
149  fAlpha = alpha;
150  fDAlpha = dAlpha;
151  fRMin = rMin;
152  fRMax = rMax;
153  fZMin = zMin;
154  fZMax = zMax;
155  fPadPitch = padPitch;
156  fErrY = 1.; // not in use
157  fErrZ = zSigma;
158  fBz = bz;
159  fNRows = nRows;
160  fRowX.resize(fNRows);
161  for ( int irow = 0; irow < nRows; irow++ ) {
162  fRowX[irow] = rowX[irow];
163  }
164 
165  Update();
166 }
167 
168 void AliHLTTPCCAParam::Update()
169 {
170  // update of calculated values
171  fCosAlpha = CAMath::Cos( fAlpha );
172  fSinAlpha = CAMath::Sin( fAlpha );
173  fAngleMin = fAlpha - fDAlpha / 2.f;
174  fAngleMax = fAlpha + fDAlpha / 2.f;
175  fErrX = fPadPitch / CAMath::Sqrt( 12.f );
176  fTrackChi2Cut = fTrackChiCut * fTrackChiCut;
177 }
178 
179 void AliHLTTPCCAParam::Slice2Global( float x, float y, float z,
180  float *X, float *Y, float *Z ) const
181 {
182  // conversion of coorinates sector->global
183  *X = x * fCosAlpha - y * fSinAlpha;
184  *Y = y * fCosAlpha + x * fSinAlpha;
185  *Z = z;
186 }
187 
188 void AliHLTTPCCAParam::Global2Slice( float X, float Y, float Z,
189  float *x, float *y, float *z ) const
190 {
191  // conversion of coorinates global->sector
192  *x = X * fCosAlpha + Y * fSinAlpha;
193  *y = Y * fCosAlpha - X * fSinAlpha;
194  *z = Z;
195 }
196 
197 float AliHLTTPCCAParam::GetClusterError2( int yz, int type, float z, float angle ) const
198 {
199  //* recalculate the cluster error wih respect to the track slope
200  const float angle2 = angle * angle;
201  const float *c = fParamS0Par[yz][type];
202  const float v = c[0] + z * ( c[1] + c[3] * z ) + angle2 * ( c[2] + angle2 * c[4] + c[5] * z );
203 //std::cout << v << std::endl;
204  return CAMath::Abs( v );
205 }
207 /*
208 void AliHLTTPCCAParam::GetClusterErrors2( int iRow, float z, float sinPhi, float cosPhi, float DzDs, float &Err2Y, float &Err2Z ) const
209 {
210  //
211  // Use calibrated cluster error from OCDB
212  //
213 
214  z = CAMath::Abs( ( 250. - 0.275 ) - CAMath::Abs( z ) );
215  const int type = errorType( iRow );
216  float cosPhiInv = CAMath::Abs( cosPhi ) > 1.e-2 ? 1. / cosPhi : 0;
217  float angleY = sinPhi * cosPhiInv ;
218  float angleZ = DzDs * cosPhiInv ; // SG was bug???
219  Err2Y = GetClusterError2( 0, type, z, angleY );
220  Err2Z = GetClusterError2( 1, type, z, angleZ );
221 }*/
222 void AliHLTTPCCAParam::GetClusterErrors2( int iRow, const AliHLTTPCCATrackParam &t, float &Err2Y, float &Err2Z ) const
223 {
224 enum {kYErr=0,kZErr=1,kWidTrk=2,kThkDet=3,kYDiff=4,kZDiff=5};
225  float z = t.Z();
226  const int type = errorType( iRow );
227  z = (200. - CAMath::Abs(z)) * 0.01;
228  if(z<0.) z=0;
229 
230  float sin2Phi = t.GetSinPhi()*t.GetSinPhi();
231  float cos2Phi = (1.f - sin2Phi);
232  if (cos2Phi<0.0001) cos2Phi=0.0001;
233  float tg2Phi = sin2Phi/cos2Phi;
234 
235  float tg2Lambda = t.DzDs()*t.DzDs();
236 
237  const float *c = fParamS0Par[0][type];
238  switch (fRecoType) {
239  case 0: {/*Sti*/
240  Err2Y = c[0] + c[1]*z/cos2Phi + c[2]*tg2Phi;
241  Err2Z = c[3] + c[4]*z*(1.f+tg2Lambda) + c[5]*tg2Lambda;
242  break;}
243 
244  case 1: {/*Sti*/
245  float cos2lambda = 1/(tg2Lambda+1);
246  float sin2lambda = tg2Lambda*cos2lambda;
247  z = (210. - CAMath::Abs(z)) * 0.01;
248 
249  Err2Y = (c[kThkDet]*sin2Phi + c[kWidTrk])
250  / (cos2Phi) + c[kYErr] + c[kYDiff]*z;
251  Err2Z = (c[kThkDet]*(sin2lambda) + c[kWidTrk]*((sin2Phi)*(sin2lambda)+cos2Phi))
252  / (cos2Phi*cos2lambda) + c[kZErr] + c[kZDiff]*z;
253  break; }
254  default: assert(0);
255  }
256 
257 
258  if(Err2Y<1e-6) Err2Y = 1e-6;
259  if(Err2Z<1e-6) Err2Z = 1e-6;
260 
261  if(Err2Y>1.f) Err2Y = 1.f;
262  if(Err2Z>1.f) Err2Z = 1.f;
263 
264 // std::cout <<Err2Y<<" "<<Err2Z<< std::endl;
265 }
267 
268 std::ostream &operator<<( std::ostream &out, const AliHLTTPCCAParam &p )
269 {
270  // write settings to the file
271  out << p.fISlice << std::endl;
272  out << p.fNRows << std::endl;
273  out << p.fAlpha << std::endl;
274  out << p.fDAlpha << std::endl;
275  out << p.fCosAlpha << std::endl;
276  out << p.fSinAlpha << std::endl;
277  out << p.fAngleMin << std::endl;
278  out << p.fAngleMax << std::endl;
279  out << p.fRMin << std::endl;
280  out << p.fRMax << std::endl;
281  out << p.fZMin << std::endl;
282  out << p.fZMax << std::endl;
283  out << p.fErrX << std::endl;
284  out << p.fErrY << std::endl;
285  out << p.fErrZ << std::endl;
286  out << p.fPadPitch << std::endl;
287  out << p.fBz << std::endl;
288  out << p.fHitPickUpFactor << std::endl;
289  out << p.fMaxTrackMatchDRow << std::endl;
290  out << p.fTrackConnectionFactor << std::endl;
291  out << p.fTrackChiCut << std::endl;
292  out << p.fTrackChi2Cut << std::endl;
293  for ( int iRow = 0; iRow < p.fNRows; iRow++ ) {
294  out << p.fRowX[iRow] << std::endl;
295  }
296  out << std::endl;
297  for ( int i = 0; i < 2; i++ )
298  for ( int j = 0; j < 3; j++ )
299  for ( int k = 0; k < 7; k++ )
300  out << p.fParamS0Par[i][j][k] << std::endl;
301  out << std::endl;
302 
303  return out;
304 }
305 
306 std::istream &operator>>( std::istream &in, AliHLTTPCCAParam &p )
307 {
308  // Read settings from the file
309 
310  in >> p.fISlice;
311  in >> p.fNRows;
312  p.SetNInnerRows( 13 ); // TODO move to input file
313  in >> p.fAlpha;
314  in >> p.fDAlpha;
315  in >> p.fCosAlpha;
316  in >> p.fSinAlpha;
317  in >> p.fAngleMin;
318  in >> p.fAngleMax;
319  in >> p.fRMin;
320  in >> p.fRMax;
321  in >> p.fZMin;
322  in >> p.fZMax;
323  in >> p.fErrX;
324  in >> p.fErrY;
325  in >> p.fErrZ;
326  in >> p.fPadPitch;
327  in >> p.fBz;
328  in >> p.fHitPickUpFactor;
329  in >> p.fMaxTrackMatchDRow;
330  in >> p.fTrackConnectionFactor;
331  in >> p.fTrackChiCut;
332  in >> p.fTrackChi2Cut;
333  p.fRowX.resize(p.fNRows);
334  for ( int iRow = 0; iRow < p.fNRows; iRow++ ) {
335  in >> p.fRowX[iRow];
336  }
337 
338  for ( int i = 0; i < 2; i++ )
339  for ( int j = 0; j < 3; j++ )
340  for ( int k = 0; k < 7; k++ )
341  in >> p.fParamS0Par[i][j][k];
342 
343  return in;
344 }
345 
346 #include "BinaryStoreHelper.h"
347 
348 void AliHLTTPCCAParam::StoreToFile( FILE *f ) const
349 {
350  BinaryStoreWrite( *this, f );
351 }
352 
353 void AliHLTTPCCAParam::RestoreFromFile( FILE *f )
354 {
355  BinaryStoreRead( *this, f );
356 }
357 
void GetClusterErrors2(int iRow, const AliHLTTPCCATrackParam &t, float &Err2Y, float &Err2Z) const
mvz start 20.01.2010