]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCseed.cxx
Eff C++ - shadow parameeter index (Marian)
[u/mrichter/AliRoot.git] / TPC / AliTPCseed.cxx
CommitLineData
81e97e0d 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
18
19//-----------------------------------------------------------------
20// Implementation of the TPC seed class
21// This class is used by the AliTPCtrackerMI class
22// Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch
23//-----------------------------------------------------------------
24#include "TClonesArray.h"
25#include "AliTPCseed.h"
3f82c4f2 26#include "AliTPCReconstructor.h"
0a65832b 27#include "AliTPCClusterParam.h"
7cd8ac3f 28#include "AliTPCCalPad.h"
29#include "AliTPCCalROC.h"
37540068 30#include "AliTPCcalibDB.h"
d080e4a4 31#include "AliTPCParam.h"
7cd8ac3f 32
33
81e97e0d 34
35ClassImp(AliTPCseed)
36
37
38
32fab534 39AliTPCseed::AliTPCseed():
40 AliTPCtrack(),
41 fEsd(0x0),
2928bdf0 42 fClusterOwner(kFALSE),
32fab534 43 fRow(0),
44 fSector(-1),
45 fRelativeSector(-1),
46 fCurrentSigmaY2(1e10),
47 fCurrentSigmaZ2(1e10),
e0e13b88 48 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
49 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 50 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
51 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
e0e13b88 52 //
32fab534 53 fErrorY2(1e10),
54 fErrorZ2(1e10),
55 fCurrentCluster(0x0),
56 fCurrentClusterIndex1(-1),
57 fInDead(kFALSE),
58 fIsSeeding(kFALSE),
59 fNoCluster(0),
60 fSort(0),
61 fBSigned(kFALSE),
62 fSeedType(0),
63 fSeed1(-1),
64 fSeed2(-1),
65 fMAngular(0),
19b00333 66 fCircular(0),
67 fClusterMap(159),
68 fSharedMap(159)
32fab534 69{
81e97e0d 70 //
5c09947e 71 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
81e97e0d 72 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
73 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=0;
32fab534 74 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0.2;
75 for (Int_t i=0;i<4;i++) {
76 fDEDX[i] = 0.;
77 fSDEDX[i] = 1e10;
78 fNCDEDX[i] = 0;
79 }
80 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
bfb57b6c 81 // for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
82 //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
83 fClusterMap.ResetAllBits(kFALSE);
84 fSharedMap.ResetAllBits(kFALSE);
85
81e97e0d 86}
32fab534 87
2928bdf0 88AliTPCseed::AliTPCseed(const AliTPCseed &s, Bool_t clusterOwner):
32fab534 89 AliTPCtrack(s),
90 fEsd(0x0),
2928bdf0 91 fClusterOwner(clusterOwner),
32fab534 92 fRow(0),
93 fSector(-1),
94 fRelativeSector(-1),
c07cb486 95 fCurrentSigmaY2(-1),
96 fCurrentSigmaZ2(-1),
e0e13b88 97 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
98 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 99 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
100 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 101 fErrorY2(1e10),
102 fErrorZ2(1e10),
103 fCurrentCluster(0x0),
104 fCurrentClusterIndex1(-1),
105 fInDead(kFALSE),
106 fIsSeeding(kFALSE),
107 fNoCluster(0),
108 fSort(0),
109 fBSigned(kFALSE),
110 fSeedType(0),
111 fSeed1(-1),
112 fSeed2(-1),
113 fMAngular(0),
19b00333 114 fCircular(0),
115 fClusterMap(s.fClusterMap),
116 fSharedMap(s.fSharedMap)
32fab534 117{
81e97e0d 118 //---------------------
119 // dummy copy constructor
120 //-------------------------
2928bdf0 121 for (Int_t i=0;i<160;i++) {
122 fClusterPointer[i]=0;
123 if (fClusterOwner){
124 if (s.fClusterPointer[i])
125 fClusterPointer[i] = new AliTPCclusterMI(*(s.fClusterPointer[i]));
126 }else{
127 fClusterPointer[i] = s.fClusterPointer[i];
128 }
129 fTrackPoints[i] = s.fTrackPoints[i];
130 }
81e97e0d 131 for (Int_t i=0;i<160;i++) fIndex[i] = s.fIndex[i];
5c09947e 132 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=s.fTPCr[i];
133 for (Int_t i=0;i<4;i++) {
134 fDEDX[i] = s.fDEDX[i];
135 fSDEDX[i] = s.fSDEDX[i];
136 fNCDEDX[i] = s.fNCDEDX[i];
137 }
138 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = s.fOverlapLabels[i];
19b00333 139
81e97e0d 140}
5c09947e 141
142
32fab534 143AliTPCseed::AliTPCseed(const AliTPCtrack &t):
144 AliTPCtrack(t),
145 fEsd(0x0),
2928bdf0 146 fClusterOwner(kFALSE),
32fab534 147 fRow(0),
148 fSector(-1),
149 fRelativeSector(-1),
c07cb486 150 fCurrentSigmaY2(-1),
151 fCurrentSigmaZ2(-1),
e0e13b88 152 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
153 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 154 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
155 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 156 fErrorY2(1e10),
157 fErrorZ2(1e10),
158 fCurrentCluster(0x0),
159 fCurrentClusterIndex1(-1),
160 fInDead(kFALSE),
161 fIsSeeding(kFALSE),
162 fNoCluster(0),
163 fSort(0),
164 fBSigned(kFALSE),
165 fSeedType(0),
166 fSeed1(-1),
167 fSeed2(-1),
168 fMAngular(0),
19b00333 169 fCircular(0),
170 fClusterMap(159),
171 fSharedMap(159)
32fab534 172{
81e97e0d 173 //
32fab534 174 // Constructor from AliTPCtrack
175 //
176 fFirstPoint =0;
105b1b81 177 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
81e97e0d 178 for (Int_t i=0;i<160;i++) {
179 fClusterPointer[i] = 0;
180 Int_t index = t.GetClusterIndex(i);
181 if (index>=-1){
182 SetClusterIndex2(i,index);
183 }
184 else{
185 SetClusterIndex2(i,-3);
186 }
187 }
32fab534 188 for (Int_t i=0;i<4;i++) {
189 fDEDX[i] = 0.;
190 fSDEDX[i] = 1e10;
191 fNCDEDX[i] = 0;
192 }
193 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
bfb57b6c 194
195 //for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
196 //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
197 fClusterMap.ResetAllBits(kFALSE);
198 fSharedMap.ResetAllBits(kFALSE);
199
81e97e0d 200}
201
6c94f330 202AliTPCseed::AliTPCseed(Double_t xr, Double_t alpha, const Double_t xx[5],
203 const Double_t cc[15], Int_t index):
204 AliTPCtrack(xr, alpha, xx, cc, index),
32fab534 205 fEsd(0x0),
2928bdf0 206 fClusterOwner(kFALSE),
32fab534 207 fRow(0),
208 fSector(-1),
209 fRelativeSector(-1),
c07cb486 210 fCurrentSigmaY2(-1),
211 fCurrentSigmaZ2(-1),
e0e13b88 212 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
213 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 214 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
215 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 216 fErrorY2(1e10),
217 fErrorZ2(1e10),
218 fCurrentCluster(0x0),
219 fCurrentClusterIndex1(-1),
220 fInDead(kFALSE),
221 fIsSeeding(kFALSE),
222 fNoCluster(0),
223 fSort(0),
224 fBSigned(kFALSE),
225 fSeedType(0),
226 fSeed1(-1),
227 fSeed2(-1),
228 fMAngular(0),
19b00333 229 fCircular(0),
230 fClusterMap(159),
231 fSharedMap(159)
32fab534 232{
233 //
234 // Constructor
81e97e0d 235 //
32fab534 236 fFirstPoint =0;
5c09947e 237 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
81e97e0d 238 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
81e97e0d 239 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
32fab534 240 for (Int_t i=0;i<4;i++) {
241 fDEDX[i] = 0.;
242 fSDEDX[i] = 1e10;
243 fNCDEDX[i] = 0;
244 }
245 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
81e97e0d 246}
247
248AliTPCseed::~AliTPCseed(){
249 //
250 // destructor
81e97e0d 251 fNoCluster =0;
2928bdf0 252 if (fClusterOwner){
253 for (Int_t icluster=0; icluster<160; icluster++){
254 delete fClusterPointer[icluster];
255 }
256 }
bfb57b6c 257
81e97e0d 258}
179c6296 259//_________________________________________________
316c6cd9 260AliTPCseed & AliTPCseed::operator=(const AliTPCseed &param)
179c6296 261{
262 //
316c6cd9 263 // assignment operator
179c6296 264 //
316c6cd9 265 if(this!=&param){
266 AliTPCtrack::operator=(param);
267 fEsd =param.fEsd;
268 for(Int_t i = 0;i<160;++i)fClusterPointer[i] = param.fClusterPointer[i]; // this is not allocated by AliTPCSeed
269 fClusterOwner = param.fClusterOwner;
270 // leave out fPoint, they are also not copied in the copy ctor...
271 // but deleted in the dtor... strange...
316c6cd9 272 fRow = param.fRow;
273 fSector = param.fSector;
274 fRelativeSector = param.fRelativeSector;
275 fCurrentSigmaY2 = param.fCurrentSigmaY2;
276 fCurrentSigmaZ2 = param.fCurrentSigmaZ2;
277 fErrorY2 = param.fErrorY2;
278 fErrorZ2 = param.fErrorZ2;
279 fCurrentCluster = param.fCurrentCluster; // this is not allocated by AliTPCSeed
280 fCurrentClusterIndex1 = param.fCurrentClusterIndex1;
281 fInDead = param.fInDead;
282 fIsSeeding = param.fIsSeeding;
283 fNoCluster = param.fNoCluster;
284 fSort = param.fSort;
285 fBSigned = param.fBSigned;
286 for(Int_t i = 0;i<4;++i){
287 fDEDX[i] = param.fDEDX[i];
288 fSDEDX[i] = param.fSDEDX[i];
289 fNCDEDX[i] = param.fNCDEDX[i];
290 }
291 for(Int_t i = 0;i<AliPID::kSPECIES;++i)fTPCr[i] = param.fTPCr[i];
292
293 fSeedType = param.fSeedType;
294 fSeed1 = param.fSeed1;
295 fSeed2 = param.fSeed2;
296 for(Int_t i = 0;i<12;++i)fOverlapLabels[i] = param.fOverlapLabels[i];
297 fMAngular = param.fMAngular;
298 fCircular = param.fCircular;
299 for(int i = 0;i<160;++i)fTrackPoints[i] = param.fTrackPoints[i];
300 fClusterMap = param.fClusterMap;
301 fSharedMap = param.fSharedMap;
302 }
179c6296 303 return (*this);
304}
305//____________________________________________________
81e97e0d 306AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
307{
308 //
309 //
310 return &fTrackPoints[i];
311}
312
81e97e0d 313
314
315Double_t AliTPCseed::GetDensityFirst(Int_t n)
316{
317 //
318 //
319 // return cluster for n rows bellow first point
320 Int_t nfoundable = 1;
321 Int_t nfound = 1;
322 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
323 Int_t index = GetClusterIndex2(i);
324 if (index!=-1) nfoundable++;
325 if (index>0) nfound++;
326 }
327 if (nfoundable<n) return 0;
328 return Double_t(nfound)/Double_t(nfoundable);
329
330}
331
332
333void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
334{
335 // get cluster stat. on given region
336 //
337 found = 0;
338 foundable = 0;
339 shared =0;
340 for (Int_t i=first;i<last; i++){
341 Int_t index = GetClusterIndex2(i);
342 if (index!=-1) foundable++;
6d493ea0 343 if (index&0x8000) continue;
81e97e0d 344 if (fClusterPointer[i]) {
345 found++;
346 }
347 else
348 continue;
349
350 if (fClusterPointer[i]->IsUsed(10)) {
351 shared++;
352 continue;
353 }
354 if (!plus2) continue; //take also neighborhoud
355 //
356 if ( (i>0) && fClusterPointer[i-1]){
357 if (fClusterPointer[i-1]->IsUsed(10)) {
358 shared++;
359 continue;
360 }
361 }
362 if ( fClusterPointer[i+1]){
363 if (fClusterPointer[i+1]->IsUsed(10)) {
364 shared++;
365 continue;
366 }
367 }
368
369 }
370 //if (shared>found){
371 //Error("AliTPCseed::GetClusterStatistic","problem\n");
372 //}
373}
374
375
376
377
378
379void AliTPCseed::Reset(Bool_t all)
380{
381 //
382 //
383 SetNumberOfClusters(0);
384 fNFoundable = 0;
385 SetChi2(0);
6c94f330 386 ResetCovariance(10.);
81e97e0d 387 /*
388 if (fTrackPoints){
389 for (Int_t i=0;i<8;i++){
390 delete [] fTrackPoints[i];
391 }
392 delete fTrackPoints;
393 fTrackPoints =0;
394 }
395 */
396
397 if (all){
398 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
399 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
400 }
401
402}
403
404
405void AliTPCseed::Modify(Double_t factor)
406{
407
408 //------------------------------------------------------------------
409 //This function makes a track forget its history :)
410 //------------------------------------------------------------------
411 if (factor<=0) {
6c94f330 412 ResetCovariance(10.);
81e97e0d 413 return;
414 }
6c94f330 415 ResetCovariance(factor);
416
81e97e0d 417 SetNumberOfClusters(0);
418 fNFoundable =0;
419 SetChi2(0);
420 fRemoval = 0;
421 fCurrentSigmaY2 = 0.000005;
422 fCurrentSigmaZ2 = 0.000005;
423 fNoCluster = 0;
424 //fFirstPoint = 160;
425 //fLastPoint = 0;
426}
427
428
429
430
431Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
432{
433 //-----------------------------------------------------------------
434 // This function find proloncation of a track to a reference plane x=xk.
435 // doesn't change internal state of the track
436 //-----------------------------------------------------------------
437
6c94f330 438 Double_t x1=GetX(), x2=x1+(xk-x1), dx=x2-x1;
81e97e0d 439
6c94f330 440 if (TMath::Abs(GetSnp()+GetC()*dx) >= AliTPCReconstructor::GetMaxSnpTrack()) {
81e97e0d 441 return 0;
442 }
443
444 // Double_t y1=fP0, z1=fP1;
6c94f330 445 Double_t c1=GetSnp(), r1=sqrt(1.- c1*c1);
446 Double_t c2=c1 + GetC()*dx, r2=sqrt(1.- c2*c2);
81e97e0d 447
6c94f330 448 y = GetY();
449 z = GetZ();
81e97e0d 450 //y += dx*(c1+c2)/(r1+r2);
451 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
452
453 Double_t dy = dx*(c1+c2)/(r1+r2);
454 Double_t dz = 0;
455 //
6c94f330 456 Double_t delta = GetC()*dx*(c1+c2)/(c1*r2 + c2*r1);
81e97e0d 457 /*
458 if (TMath::Abs(delta)>0.0001){
459 dz = fP3*TMath::ASin(delta)/fP4;
460 }else{
461 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
462 }
463 */
464 // dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
6c94f330 465 dz = GetTgl()*TMath::ASin(delta)/GetC();
81e97e0d 466 //
467 y+=dy;
468 z+=dz;
469
470
471 return 1;
472}
473
474
475//_____________________________________________________________________________
af32720d 476Double_t AliTPCseed::GetPredictedChi2(const AliCluster *c) const
81e97e0d 477{
478 //-----------------------------------------------------------------
479 // This function calculates a predicted chi2 increment.
480 //-----------------------------------------------------------------
6c94f330 481 Double_t p[2]={c->GetY(), c->GetZ()};
482 Double_t cov[3]={fErrorY2, 0., fErrorZ2};
483 return AliExternalTrackParam::GetPredictedChi2(p,cov);
81e97e0d 484}
485
81e97e0d 486//_________________________________________________________________________________________
487
488
489Int_t AliTPCseed::Compare(const TObject *o) const {
490 //-----------------------------------------------------------------
491 // This function compares tracks according to the sector - for given sector according z
492 //-----------------------------------------------------------------
493 AliTPCseed *t=(AliTPCseed*)o;
6c94f330 494
81e97e0d 495 if (fSort == 0){
496 if (t->fRelativeSector>fRelativeSector) return -1;
497 if (t->fRelativeSector<fRelativeSector) return 1;
498 Double_t z2 = t->GetZ();
499 Double_t z1 = GetZ();
500 if (z2>z1) return 1;
501 if (z2<z1) return -1;
502 return 0;
503 }
504 else {
505 Float_t f2 =1;
6c23ffed 506 f2 = 1-20*TMath::Sqrt(t->GetSigma1Pt2())/(t->OneOverPt()+0.0066);
81e97e0d 507 if (t->fBConstrain) f2=1.2;
508
509 Float_t f1 =1;
6c23ffed 510 f1 = 1-20*TMath::Sqrt(GetSigma1Pt2())/(OneOverPt()+0.0066);
81e97e0d 511
512 if (fBConstrain) f1=1.2;
513
514 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
515 else return +1;
516 }
517}
518
519
520
521
522//_____________________________________________________________________________
70e20dcf 523Bool_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, Int_t index)
6c94f330 524{
81e97e0d 525 //-----------------------------------------------------------------
526 // This function associates a cluster with this track.
527 //-----------------------------------------------------------------
81e97e0d 528 Int_t n=GetNumberOfClusters();
70e20dcf 529 Int_t idx=GetClusterIndex(n); // save the current cluster index
530
531 AliCluster cl(*c); cl.SetSigmaY2(fErrorY2); cl.SetSigmaZ2(fErrorZ2);
ca521f6c 532 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
533 if (TMath::Abs(dx)>0){
534 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
535 Float_t dy = dx*ty;
536 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
537 cl.SetY(c->GetY()-dy);
538 cl.SetZ(c->GetZ()-dz);
539 }
540
70e20dcf 541 if (!AliTPCtrack::Update(&cl,chisq,index)) return kFALSE;
e0e13b88 542
543 if (fCMeanSigmaY2p30<0){
544 fCMeanSigmaY2p30= c->GetSigmaY2(); //! current mean sigma Y2 - mean30%
c07cb486 545 fCMeanSigmaZ2p30= c->GetSigmaZ2(); //! current mean sigma Z2 - mean30%
546 fCMeanSigmaY2p30R = 1; //! current mean sigma Y2 - mean5%
547 fCMeanSigmaZ2p30R = 1; //! current mean sigma Z2 - mean5%
e0e13b88 548 }
549 //
550 fCMeanSigmaY2p30= 0.70*fCMeanSigmaY2p30 +0.30*c->GetSigmaY2();
c07cb486 551 fCMeanSigmaZ2p30= 0.70*fCMeanSigmaZ2p30 +0.30*c->GetSigmaZ2();
552 if (fCurrentSigmaY2>0){
553 fCMeanSigmaY2p30R = 0.7*fCMeanSigmaY2p30R +0.3*c->GetSigmaY2()/fCurrentSigmaY2;
554 fCMeanSigmaZ2p30R = 0.7*fCMeanSigmaZ2p30R +0.3*c->GetSigmaZ2()/fCurrentSigmaZ2;
555 }
e0e13b88 556
81e97e0d 557
70e20dcf 558 SetClusterIndex(n,idx); // restore the current cluster index
6c94f330 559 return kTRUE;
81e97e0d 560}
561
562
563
564//_____________________________________________________________________________
105b1b81 565Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
81e97e0d 566 //-----------------------------------------------------------------
567 // This funtion calculates dE/dX within the "low" and "up" cuts.
568 //-----------------------------------------------------------------
569
570 Float_t amp[200];
571 Float_t angular[200];
572 Float_t weight[200];
573 Int_t index[200];
574 //Int_t nc = 0;
81e97e0d 575 Float_t meanlog = 100.;
576
577 Float_t mean[4] = {0,0,0,0};
578 Float_t sigma[4] = {1000,1000,1000,1000};
579 Int_t nc[4] = {0,0,0,0};
580 Float_t norm[4] = {1000,1000,1000,1000};
581 //
582 //
583 fNShared =0;
584
4cc7ba77 585 Float_t gainGG = 1;
586 if (AliTPCcalibDB::Instance()->GetParameters()){
c0169053 587 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000.; //relative gas gain
4cc7ba77 588 }
589
590
81e97e0d 591 for (Int_t of =0; of<4; of++){
592 for (Int_t i=of+i1;i<i2;i+=4)
593 {
fef5baad 594 Int_t clindex = fIndex[i];
595 if (clindex<0||clindex&0x8000) continue;
81e97e0d 596
597 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
598 AliTPCTrackerPoint * point = GetTrackPoint(i);
599 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
600 //AliTPCTrackerPoint * pointp = 0;
601 //if (i<159) pointp = GetTrackPoint(i+1);
602
603 if (point==0) continue;
604 AliTPCclusterMI * cl = fClusterPointer[i];
605 if (cl==0) continue;
606 if (onlyused && (!cl->IsUsed(10))) continue;
607 if (cl->IsUsed(11)) {
608 fNShared++;
609 continue;
610 }
611 Int_t type = cl->GetType();
612 //if (point->fIsShared){
613 // fNShared++;
614 // continue;
615 //}
616 //if (pointm)
617 // if (pointm->fIsShared) continue;
618 //if (pointp)
619 // if (pointp->fIsShared) continue;
620
621 if (type<0) continue;
622 //if (type>10) continue;
623 //if (point->GetErrY()==0) continue;
624 //if (point->GetErrZ()==0) continue;
625
626 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
627 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
628 //if ((ddy*ddy+ddz*ddz)>10) continue;
629
630
631 // if (point->GetCPoint().GetMax()<5) continue;
632 if (cl->GetMax()<5) continue;
633 Float_t angley = point->GetAngleY();
634 Float_t anglez = point->GetAngleZ();
635
636 Float_t rsigmay2 = point->GetSigmaY();
637 Float_t rsigmaz2 = point->GetSigmaZ();
638 /*
639 Float_t ns = 1.;
640 if (pointm){
641 rsigmay += pointm->GetTPoint().GetSigmaY();
642 rsigmaz += pointm->GetTPoint().GetSigmaZ();
643 ns+=1.;
644 }
645 if (pointp){
646 rsigmay += pointp->GetTPoint().GetSigmaY();
647 rsigmaz += pointp->GetTPoint().GetSigmaZ();
648 ns+=1.;
649 }
650 rsigmay/=ns;
651 rsigmaz/=ns;
652 */
653
654 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
655
656 Float_t ampc = 0; // normalization to the number of electrons
657 if (i>64){
658 // ampc = 1.*point->GetCPoint().GetMax();
659 ampc = 1.*cl->GetMax();
660 //ampc = 1.*point->GetCPoint().GetQ();
661 // AliTPCClusterPoint & p = point->GetCPoint();
662 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
663 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
664 //Float_t dz =
665 // TMath::Abs( Int_t(iz) - iz + 0.5);
666 //ampc *= 1.15*(1-0.3*dy);
667 //ampc *= 1.15*(1-0.3*dz);
668 // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
669 //ampc *=zfactor;
670 }
671 else{
672 //ampc = 1.0*point->GetCPoint().GetMax();
673 ampc = 1.0*cl->GetMax();
674 //ampc = 1.0*point->GetCPoint().GetQ();
675 //AliTPCClusterPoint & p = point->GetCPoint();
676 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
677 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
678 //Float_t dz =
679 // TMath::Abs( Int_t(iz) - iz + 0.5);
680
681 //ampc *= 1.15*(1-0.3*dy);
682 //ampc *= 1.15*(1-0.3*dz);
683 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
684 //ampc *=zfactor;
685
686 }
687 ampc *= 2.0; // put mean value to channel 50
688 //ampc *= 0.58; // put mean value to channel 50
689 Float_t w = 1.;
690 // if (type>0) w = 1./(type/2.-0.5);
691 // Float_t z = TMath::Abs(cl->GetZ());
692 if (i<64) {
693 ampc /= 0.6;
694 //ampc /= (1+0.0008*z);
695 } else
696 if (i>128){
697 ampc /=1.5;
698 //ampc /= (1+0.0008*z);
699 }else{
700 //ampc /= (1+0.0008*z);
701 }
702
703 if (type<0) { //amp at the border - lower weight
704 // w*= 2.;
705
706 continue;
707 }
708 if (rsigma>1.5) ampc/=1.3; // if big backround
709 amp[nc[of]] = ampc;
c0169053 710 amp[nc[of]] /=gainGG;
81e97e0d 711 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
712 weight[nc[of]] = w;
713 nc[of]++;
714 }
715
716 TMath::Sort(nc[of],amp,index,kFALSE);
717 Float_t sumamp=0;
718 Float_t sumamp2=0;
719 Float_t sumw=0;
720 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
721 meanlog = 50;
722 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
723 Float_t ampl = amp[index[i]]/angular[index[i]];
724 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
725 //
726 sumw += weight[index[i]];
727 sumamp += weight[index[i]]*ampl;
728 sumamp2 += weight[index[i]]*ampl*ampl;
729 norm[of] += angular[index[i]]*weight[index[i]];
730 }
731 if (sumw<1){
732 SetdEdx(0);
733 }
734 else {
735 norm[of] /= sumw;
736 mean[of] = sumamp/sumw;
737 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
738 if (sigma[of]>0.1)
739 sigma[of] = TMath::Sqrt(sigma[of]);
740 else
741 sigma[of] = 1000;
742
743 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
744 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
745 //mean *=(1-0.1*(norm-1.));
746 }
747 }
748
749 Float_t dedx =0;
750 fSdEdx =0;
751 fMAngular =0;
752 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
753 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
754
755
756 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
757 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
758
759 Int_t norm2 = 0;
760 Int_t norm3 = 0;
761 for (Int_t i =0;i<4;i++){
762 if (nc[i]>2&&nc[i]<1000){
763 dedx += mean[i] *nc[i];
764 fSdEdx += sigma[i]*(nc[i]-2);
765 fMAngular += norm[i] *nc[i];
766 norm2 += nc[i];
767 norm3 += nc[i]-2;
768 }
769 fDEDX[i] = mean[i];
770 fSDEDX[i] = sigma[i];
771 fNCDEDX[i]= nc[i];
772 }
773
774 if (norm3>0){
775 dedx /=norm2;
776 fSdEdx /=norm3;
777 fMAngular/=norm2;
778 }
779 else{
780 SetdEdx(0);
105b1b81 781 return 0;
81e97e0d 782 }
783 // Float_t dedx1 =dedx;
784 /*
785 dedx =0;
786 for (Int_t i =0;i<4;i++){
787 if (nc[i]>2&&nc[i]<1000){
788 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
789 dedx += mean[i] *nc[i];
790 }
791 fDEDX[i] = mean[i];
792 }
793 dedx /= norm2;
794 */
795
796
797 SetdEdx(dedx);
a2d457f2 798 return dedx;
81e97e0d 799}
800Double_t AliTPCseed::Bethe(Double_t bg){
801 //
802 // This is the Bethe-Bloch function normalised to 1 at the minimum
803 //
804 Double_t bg2=bg*bg;
805 Double_t bethe;
806 if (bg<3.5e1)
807 bethe=(1.+ bg2)/bg2*(log(5940*bg2) - bg2/(1.+ bg2));
808 else // Density effect ( approximately :)
809 bethe=1.15*(1.+ bg2)/bg2*(log(3.5*5940*bg) - bg2/(1.+ bg2));
810 return bethe/11.091;
811}
812
813void AliTPCseed::CookPID()
814{
815 //
816 // cook PID information according dEdx
817 //
818 Double_t fRange = 10.;
819 Double_t fRes = 0.1;
820 Double_t fMIP = 47.;
821 //
822 Int_t ns=AliPID::kSPECIES;
823 Double_t sumr =0;
824 for (Int_t j=0; j<ns; j++) {
825 Double_t mass=AliPID::ParticleMass(j);
6c94f330 826 Double_t mom=GetP();
81e97e0d 827 Double_t dedx=fdEdx/fMIP;
828 Double_t bethe=Bethe(mom/mass);
829 Double_t sigma=fRes*bethe;
830 if (sigma>0.001){
831 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
832 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
833 sumr+=fTPCr[j];
834 continue;
835 }
836 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
837 sumr+=fTPCr[j];
838 }
839 else{
840 fTPCr[j]=1.;
841 sumr+=fTPCr[j];
842 }
843 }
844 for (Int_t j=0; j<ns; j++) {
845 fTPCr[j]/=sumr; //normalize
846 }
847}
848
849/*
850void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
851 //-----------------------------------------------------------------
852 // This funtion calculates dE/dX within the "low" and "up" cuts.
853 //-----------------------------------------------------------------
854
855 Float_t amp[200];
856 Float_t angular[200];
857 Float_t weight[200];
858 Int_t index[200];
859 Bool_t inlimit[200];
860 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
861 for (Int_t i=0;i<200;i++) amp[i]=10000;
862 for (Int_t i=0;i<200;i++) angular[i]= 1;;
863
864
865 //
866 Float_t meanlog = 100.;
867 Int_t indexde[4]={0,64,128,160};
868
869 Float_t amean =0;
870 Float_t asigma =0;
871 Float_t anc =0;
872 Float_t anorm =0;
873
874 Float_t mean[4] = {0,0,0,0};
875 Float_t sigma[4] = {1000,1000,1000,1000};
876 Int_t nc[4] = {0,0,0,0};
877 Float_t norm[4] = {1000,1000,1000,1000};
878 //
879 //
880 fNShared =0;
881
882 // for (Int_t of =0; of<3; of++){
883 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
884 for (Int_t i =0; i<160;i++)
885 {
886 AliTPCTrackPoint * point = GetTrackPoint(i);
887 if (point==0) continue;
888 if (point->fIsShared){
889 fNShared++;
890 continue;
891 }
892 Int_t type = point->GetCPoint().GetType();
893 if (type<0) continue;
894 if (point->GetCPoint().GetMax()<5) continue;
895 Float_t angley = point->GetTPoint().GetAngleY();
896 Float_t anglez = point->GetTPoint().GetAngleZ();
897 Float_t rsigmay = point->GetCPoint().GetSigmaY();
898 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
899 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
900
901 Float_t ampc = 0; // normalization to the number of electrons
902 if (i>64){
903 ampc = point->GetCPoint().GetMax();
904 }
905 else{
906 ampc = point->GetCPoint().GetMax();
907 }
908 ampc *= 2.0; // put mean value to channel 50
909 // ampc *= 0.565; // put mean value to channel 50
910
911 Float_t w = 1.;
912 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
913 if (i<64) {
914 ampc /= 0.63;
915 } else
916 if (i>128){
917 ampc /=1.51;
918 }
919 if (type<0) { //amp at the border - lower weight
920 continue;
921 }
922 if (rsigma>1.5) ampc/=1.3; // if big backround
923 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
924 amp[i] = ampc/angular[i];
925 weight[i] = w;
926 anc++;
927 }
928
929 TMath::Sort(159,amp,index,kFALSE);
930 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
931 inlimit[index[i]] = kTRUE; // take all clusters
932 }
933
934 // meanlog = amp[index[Int_t(anc*0.3)]];
935 meanlog =10000.;
936 for (Int_t of =0; of<3; of++){
937 Float_t sumamp=0;
938 Float_t sumamp2=0;
939 Float_t sumw=0;
940 for (Int_t i=indexde[of];i<indexde[of+1];i++)
941 {
942 if (inlimit[i]==kFALSE) continue;
943 Float_t ampl = amp[i];
944 ///angular[i];
945 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
946 //
947 sumw += weight[i];
948 sumamp += weight[i]*ampl;
949 sumamp2 += weight[i]*ampl*ampl;
950 norm[of] += angular[i]*weight[i];
951 nc[of]++;
952 }
953 if (sumw<1){
954 SetdEdx(0);
955 }
956 else {
957 norm[of] /= sumw;
958 mean[of] = sumamp/sumw;
959 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
960 if (sigma[of]>0.1)
961 sigma[of] = TMath::Sqrt(sigma[of]);
962 else
963 sigma[of] = 1000;
964 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
965 }
966 }
967
968 Float_t dedx =0;
969 fSdEdx =0;
970 fMAngular =0;
971 //
972 Int_t norm2 = 0;
973 Int_t norm3 = 0;
974 Float_t www[3] = {12.,14.,17.};
975 //Float_t www[3] = {1.,1.,1.};
976
977 for (Int_t i =0;i<3;i++){
978 if (nc[i]>2&&nc[i]<1000){
979 dedx += mean[i] *nc[i]*www[i]/sigma[i];
980 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
981 fMAngular += norm[i] *nc[i];
982 norm2 += nc[i]*www[i]/sigma[i];
983 norm3 += (nc[i]-2)*www[i]/sigma[i];
984 }
985 fDEDX[i] = mean[i];
986 fSDEDX[i] = sigma[i];
987 fNCDEDX[i]= nc[i];
988 }
989
990 if (norm3>0){
991 dedx /=norm2;
992 fSdEdx /=norm3;
993 fMAngular/=norm2;
994 }
995 else{
996 SetdEdx(0);
997 return;
998 }
999 // Float_t dedx1 =dedx;
1000
1001 dedx =0;
1002 Float_t norm4 = 0;
1003 for (Int_t i =0;i<3;i++){
1004 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
1005 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
1006 dedx += mean[i] *(nc[i])/(sigma[i]);
1007 norm4 += (nc[i])/(sigma[i]);
1008 }
1009 fDEDX[i] = mean[i];
1010 }
1011 if (norm4>0) dedx /= norm4;
1012
1013
1014
1015 SetdEdx(dedx);
1016
1017 //mi deDX
1018
1019}
1020*/
6c94f330 1021Double_t AliTPCseed::GetYat(Double_t xk) const {
1022//-----------------------------------------------------------------
1023// This function calculates the Y-coordinate of a track at the plane x=xk.
1024//-----------------------------------------------------------------
1025 if (TMath::Abs(GetSnp())>AliTPCReconstructor::GetMaxSnpTrack()) return 0.; //patch 01 jan 06
1026 Double_t c1=GetSnp(), r1=TMath::Sqrt(1.- c1*c1);
1027 Double_t c2=c1+GetC()*(xk-GetX());
1028 if (TMath::Abs(c2)>AliTPCReconstructor::GetMaxSnpTrack()) return 0;
1029 Double_t r2=TMath::Sqrt(1.- c2*c2);
1030 return GetY() + (xk-GetX())*(c1+c2)/(r1+r2);
1031}
1032
19b00333 1033void AliTPCseed::SetClusterMapBit(int ibit, Bool_t state)
1034{
1035 fClusterMap[ibit] = state;
1036}
1037Bool_t AliTPCseed::GetClusterMapBit(int ibit)
1038{
1039 return fClusterMap[ibit];
1040}
1041void AliTPCseed::SetSharedMapBit(int ibit, Bool_t state)
1042{
1043 fSharedMap[ibit] = state;
1044}
1045Bool_t AliTPCseed::GetSharedMapBit(int ibit)
1046{
1047 return fSharedMap[ibit];
1048}
eb02f63a 1049
1050
0a65832b 1051
1052
1053
2fc9608f 1054Float_t AliTPCseed::CookdEdxNorm(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, AliTPCCalPad * gainMap, Bool_t posNorm, Bool_t padNorm){
0a65832b 1055
1056 //
1057 // calculates dedx using the cluster
1058 // low - up specify trunc mean range - default form 0-0.7
8076baa0 1059 // type - 1 - max charge or 0- total charge in cluster
1060 // //2- max no corr 3- total+ correction
0a65832b 1061 // i1-i2 - the pad-row range used for calculation
1062 //
1063 // normalization parametrization taken from AliTPCClusterParam
1064 //
1065 AliTPCClusterParam * parcl = AliTPCClusterParam::Instance();
8e1dcdda 1066 if (!parcl) parcl = AliTPCcalibDB::Instance()->GetClusterParam();
0a65832b 1067 if (!parcl) return 0;
1068 Float_t amp[160];
1069 Int_t indexes[160];
1070 Int_t ncl=0;
1071 //
1072 //
4cc7ba77 1073 Float_t gainGG = 1;
1074 if (AliTPCcalibDB::Instance()->GetParameters()){
1075 gainGG= 20000./AliTPCcalibDB::Instance()->GetParameters()->GetGasGain(); //relative gas gain
1076 }
1077
0a65832b 1078 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
4cc7ba77 1079 const Float_t kedgey =3.;
0a65832b 1080 //
7cd8ac3f 1081 //
0a65832b 1082 for (Int_t irow=i1; irow<i2; irow++){
1083 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1084 if (!cluster) continue;
1085 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
8076baa0 1086 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
37540068 1087 if (!gainMap) gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
d6920632 1088 if (gainMap) {
1089 Float_t factor = 1;
1090 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
1091 if (irow < 63) { // IROC
1092 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()))*1.55;
1093 } else { // OROC
1094 factor = roc->GetValue(irow - 63, TMath::Nint(cluster->GetPad()));
1095 }
1096 if (factor>0.5) charge/=factor;
7cd8ac3f 1097 }
d6920632 1098
0a65832b 1099 //do normalization
1100 Float_t corr=1;
8076baa0 1101 Int_t ipad= 0;
1102 if (irow>62) ipad=1;
1103 if (irow>127) ipad=2;
0a65832b 1104 if (type<=1){
0a65832b 1105 //
1106 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1107 Float_t ty = TMath::Abs(point->GetAngleY());
1108 Float_t tz = TMath::Abs(point->GetAngleZ());
1109
1110 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
1111 corr = parcl->Qnorm(ipad,type,dr,ty,tz);
1112 }
1113 amp[ncl]=charge/corr;
d080e4a4 1114 amp[ncl]/=gainGG;
8e1dcdda 1115 if (posNorm){
1116 //
1117 //
1118 //
1119 corr = parcl->QnormPos(ipad,type, cluster->GetPad(),cluster->GetTimeBin(), cluster->GetZ(),
1120 cluster->GetSigmaY2(),cluster->GetSigmaZ2(),cluster->GetMax(),cluster->GetQ());
1121 amp[ncl]/=corr;
1122 }
1123
1124
8076baa0 1125 amp[ncl] *= 2.0; // put mean value to channel 50
2fc9608f 1126 if (padNorm){
1127 corr=1;
1128 if (type==0 && parcl->fQpadTnorm) corr = (*parcl->fQpadTnorm)[ipad];
1129 if (type==1 && parcl->fQpadTnorm) corr = (*parcl->fQpadMnorm)[ipad];
1130 amp[ncl]/=corr;
1131 }
1132
1133 // if (ipad==0) {
1134// amp[ncl] /= 0.65; // this we will take form OCDB
1135// } else
1136// if (ipad==2){
1137// amp[ncl] /=1.57;
1138// }else{
1139// }
0a65832b 1140 ncl++;
1141 }
8076baa0 1142
0a65832b 1143 if (type>3) return ncl;
1144 TMath::Sort(ncl,amp, indexes, kFALSE);
1145
8076baa0 1146 if (ncl<10) return 0;
0a65832b 1147
1148 Float_t suma=0;
1149 Float_t sumn=0;
1150 Int_t icl0=TMath::Nint(ncl*low);
1151 Int_t icl1=TMath::Nint(ncl*up);
1152 for (Int_t icl=icl0; icl<icl1;icl++){
1153 suma+=amp[indexes[icl]];
1154 sumn++;
1155 }
1156 return suma/sumn;
1157
1158}
1159
1160Double_t AliTPCseed::BetheMass(Double_t mass){
1161 //
1162 // return bethe-bloch
1163 //
1164 Float_t bg= P()/mass;
1165 const Double_t kp1=0.76176e-1;
1166 const Double_t kp2=10.632;
1167 const Double_t kp3=0.13279e-4;
1168 const Double_t kp4=1.8631;
1169 const Double_t kp5=1.9479;
1170
1171 Double_t dbg = (Double_t) bg;
1172
1173 Double_t beta = dbg/TMath::Sqrt(1.+dbg*dbg);
1174
1175 Double_t aa = TMath::Power(beta,kp4);
1176 Double_t bb = TMath::Power(1./dbg,kp5);
1177
1178 bb=TMath::Log(kp3+bb);
1179
1180 return ((Float_t)((kp2-aa-bb)*kp1/aa));
1181}
1182
1183
eb02f63a 1184Float_t AliTPCseed::CookShape(Int_t type){
1185 //
1186 //
1187 //
1188 //-----------------------------------------------------------------
1189 // This funtion calculates dE/dX within the "low" and "up" cuts.
1190 //-----------------------------------------------------------------
1191 Float_t means=0;
1192 Float_t meanc=0;
1193 for (Int_t i =0; i<160;i++) {
1194 AliTPCTrackerPoint * point = GetTrackPoint(i);
1195 if (point==0) continue;
1196
1197 AliTPCclusterMI * cl = fClusterPointer[i];
1198 if (cl==0) continue;
1199
1200 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1201 Float_t rsigmaz = TMath::Sqrt(point->GetSigmaZ());
1202 Float_t rsigma = (rsigmay+rsigmaz)*0.5;
1203 if (type==0) means+=rsigma;
1204 if (type==1) means+=rsigmay;
1205 if (type==2) means+=rsigmaz;
1206 meanc++;
1207 }
1208 Float_t mean = (meanc>0)? means/meanc:0;
1209 return mean;
1210}
87e92a27 1211
1212
1213
1214Int_t AliTPCseed::RefitTrack(AliTPCseed *seed, AliExternalTrackParam * parin, AliExternalTrackParam * parout){
1215 //
1216 // Refit the track
1217 // return value - number of used clusters
1218 //
1219 //
1220 const Int_t kMinNcl =10;
1221 AliTPCseed *track=new AliTPCseed(*seed);
1222 Int_t sector=-1;
1223 // reset covariance
1224 //
1225 Double_t covar[15];
1226 for (Int_t i=0;i<15;i++) covar[i]=0;
1227 covar[0]=10.*10.;
1228 covar[2]=10.*10.;
1229 covar[5]=10.*10./(64.*64.);
1230 covar[9]=10.*10./(64.*64.);
1231 covar[14]=1*1;
1232 //
1233
1234 Float_t xmin=1000, xmax=-10000;
1235 Int_t imin=158, imax=0;
1236 for (Int_t i=0;i<160;i++) {
1237 AliTPCclusterMI *c=track->GetClusterPointer(i);
1238 if (!c) continue;
1239 if (sector<0) sector = c->GetDetector();
1240 if (c->GetX()<xmin) xmin=c->GetX();
1241 if (c->GetX()>xmax) xmax=c->GetX();
1242 if (i<imin) imin=i;
1243 if (i>imax) imax=i;
1244 }
1245 if(imax-imin<kMinNcl) {
1246 delete track;
1247 return 0 ;
1248 }
1249 // Not succes to rotate
1250 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1251 delete track;
1252 return 0;
1253 }
1254 //
1255 //
1256 // fit from inner to outer row
1257 //
1258 AliExternalTrackParam paramIn;
1259 AliExternalTrackParam paramOut;
1260 Bool_t isOK=kTRUE;
be34cb88 1261 Int_t ncl=0;
87e92a27 1262 //
1263 //
1264 //
1265 for (Int_t i=imin; i<=imax; i++){
1266 AliTPCclusterMI *c=track->GetClusterPointer(i);
1267 if (!c) continue;
1268 // if (RejectCluster(c,track)) continue;
be34cb88 1269 sector = (c->GetDetector()%18);
1270 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1271 //continue;
1272 }
87e92a27 1273 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1274 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1275 if (!track->PropagateTo(r[0])) {
1276 isOK=kFALSE;
87e92a27 1277 }
1278 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1279 }
1280 if (!isOK) { delete track; return 0;}
1281 track->AddCovariance(covar);
1282 //
1283 //
1284 //
1285 for (Int_t i=imax; i>=imin; i--){
1286 AliTPCclusterMI *c=track->GetClusterPointer(i);
1287 if (!c) continue;
1288 //if (RejectCluster(c,track)) continue;
be34cb88 1289 sector = (c->GetDetector()%18);
1290 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1291 //continue;
1292 }
87e92a27 1293 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1294 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1295 if (!track->PropagateTo(r[0])) {
1296 isOK=kFALSE;
87e92a27 1297 }
1298 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1299 }
be34cb88 1300 //if (!isOK) { delete track; return 0;}
87e92a27 1301 paramIn = *track;
1302 track->AddCovariance(covar);
1303 //
1304 //
1305 for (Int_t i=imin; i<=imax; i++){
1306 AliTPCclusterMI *c=track->GetClusterPointer(i);
1307 if (!c) continue;
be34cb88 1308 sector = (c->GetDetector()%18);
1309 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1310 //continue;
1311 }
1312 ncl++;
87e92a27 1313 //if (RejectCluster(c,track)) continue;
1314 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1315 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1316 if (!track->PropagateTo(r[0])) {
1317 isOK=kFALSE;
87e92a27 1318 }
1319 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1320 }
be34cb88 1321 //if (!isOK) { delete track; return 0;}
87e92a27 1322 paramOut=*track;
87e92a27 1323 //
1324 //
1325 //
1326 if (parin) (*parin)=paramIn;
1327 if (parout) (*parout)=paramOut;
be34cb88 1328 return ncl;
87e92a27 1329}
1330
1331
1332
1333Bool_t AliTPCseed::RefitTrack(AliTPCseed* /*seed*/, Bool_t /*out*/){
1334 //
1335 //
1336 //
1337 return kFALSE;
1338}