Correction.
[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//-----------------------------------------------------------------
28273e26 20//
81e97e0d 21// Implementation of the TPC seed class
22// This class is used by the AliTPCtrackerMI class
23// Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch
24//-----------------------------------------------------------------
25#include "TClonesArray.h"
2efc897f 26#include "TGraphErrors.h"
81e97e0d 27#include "AliTPCseed.h"
3f82c4f2 28#include "AliTPCReconstructor.h"
0a65832b 29#include "AliTPCClusterParam.h"
7cd8ac3f 30#include "AliTPCCalPad.h"
31#include "AliTPCCalROC.h"
37540068 32#include "AliTPCcalibDB.h"
d080e4a4 33#include "AliTPCParam.h"
5731b051 34#include "AliMathBase.h"
3af3fbc4 35#include "AliTPCTransform.h"
36#include "AliSplineFit.h"
37#include "AliCDBManager.h"
108a67db 38#include "AliTPCcalibDButil.h"
7cd8ac3f 39
81e97e0d 40
41ClassImp(AliTPCseed)
42
43
44
32fab534 45AliTPCseed::AliTPCseed():
46 AliTPCtrack(),
47 fEsd(0x0),
2928bdf0 48 fClusterOwner(kFALSE),
32fab534 49 fRow(0),
50 fSector(-1),
51 fRelativeSector(-1),
52 fCurrentSigmaY2(1e10),
53 fCurrentSigmaZ2(1e10),
e0e13b88 54 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
55 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 56 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
57 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
e0e13b88 58 //
32fab534 59 fErrorY2(1e10),
60 fErrorZ2(1e10),
61 fCurrentCluster(0x0),
62 fCurrentClusterIndex1(-1),
63 fInDead(kFALSE),
64 fIsSeeding(kFALSE),
65 fNoCluster(0),
66 fSort(0),
67 fBSigned(kFALSE),
68 fSeedType(0),
69 fSeed1(-1),
70 fSeed2(-1),
71 fMAngular(0),
ddfbc51a 72 fCircular(0),
73 fPoolID(-1)
32fab534 74{
81e97e0d 75 //
5c09947e 76 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
81e97e0d 77 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
78 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=0;
32fab534 79 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0.2;
80 for (Int_t i=0;i<4;i++) {
81 fDEDX[i] = 0.;
82 fSDEDX[i] = 1e10;
83 fNCDEDX[i] = 0;
9c0db267 84 fNCDEDXInclThres[i] = 0;
32fab534 85 }
9c0db267 86 fDEDX[4] = 0;
32fab534 87 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
81e97e0d 88}
32fab534 89
2928bdf0 90AliTPCseed::AliTPCseed(const AliTPCseed &s, Bool_t clusterOwner):
32fab534 91 AliTPCtrack(s),
92 fEsd(0x0),
2928bdf0 93 fClusterOwner(clusterOwner),
32fab534 94 fRow(0),
95 fSector(-1),
96 fRelativeSector(-1),
c07cb486 97 fCurrentSigmaY2(-1),
98 fCurrentSigmaZ2(-1),
e0e13b88 99 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
100 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 101 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
102 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 103 fErrorY2(1e10),
104 fErrorZ2(1e10),
105 fCurrentCluster(0x0),
106 fCurrentClusterIndex1(-1),
107 fInDead(kFALSE),
108 fIsSeeding(kFALSE),
109 fNoCluster(0),
110 fSort(0),
111 fBSigned(kFALSE),
112 fSeedType(0),
113 fSeed1(-1),
114 fSeed2(-1),
115 fMAngular(0),
ddfbc51a 116 fCircular(0),
117 fPoolID(-1)
32fab534 118{
81e97e0d 119 //---------------------
120 // dummy copy constructor
121 //-------------------------
2928bdf0 122 for (Int_t i=0;i<160;i++) {
123 fClusterPointer[i]=0;
124 if (fClusterOwner){
125 if (s.fClusterPointer[i])
126 fClusterPointer[i] = new AliTPCclusterMI(*(s.fClusterPointer[i]));
127 }else{
128 fClusterPointer[i] = s.fClusterPointer[i];
129 }
130 fTrackPoints[i] = s.fTrackPoints[i];
131 }
81e97e0d 132 for (Int_t i=0;i<160;i++) fIndex[i] = s.fIndex[i];
5c09947e 133 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=s.fTPCr[i];
134 for (Int_t i=0;i<4;i++) {
135 fDEDX[i] = s.fDEDX[i];
136 fSDEDX[i] = s.fSDEDX[i];
137 fNCDEDX[i] = s.fNCDEDX[i];
9c0db267 138 fNCDEDXInclThres[i] = s.fNCDEDXInclThres[i];
5c09947e 139 }
9c0db267 140 fDEDX[4] = s.fDEDX[4];
5c09947e 141 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = s.fOverlapLabels[i];
19b00333 142
81e97e0d 143}
5c09947e 144
145
32fab534 146AliTPCseed::AliTPCseed(const AliTPCtrack &t):
147 AliTPCtrack(t),
148 fEsd(0x0),
2928bdf0 149 fClusterOwner(kFALSE),
32fab534 150 fRow(0),
151 fSector(-1),
152 fRelativeSector(-1),
c07cb486 153 fCurrentSigmaY2(-1),
154 fCurrentSigmaZ2(-1),
e0e13b88 155 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
156 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 157 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
158 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 159 fErrorY2(1e10),
160 fErrorZ2(1e10),
161 fCurrentCluster(0x0),
162 fCurrentClusterIndex1(-1),
163 fInDead(kFALSE),
164 fIsSeeding(kFALSE),
165 fNoCluster(0),
166 fSort(0),
167 fBSigned(kFALSE),
168 fSeedType(0),
169 fSeed1(-1),
170 fSeed2(-1),
171 fMAngular(0),
ddfbc51a 172 fCircular(0),
173 fPoolID(-1)
32fab534 174{
81e97e0d 175 //
32fab534 176 // Constructor from AliTPCtrack
177 //
178 fFirstPoint =0;
105b1b81 179 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
81e97e0d 180 for (Int_t i=0;i<160;i++) {
181 fClusterPointer[i] = 0;
182 Int_t index = t.GetClusterIndex(i);
183 if (index>=-1){
184 SetClusterIndex2(i,index);
185 }
186 else{
187 SetClusterIndex2(i,-3);
188 }
189 }
32fab534 190 for (Int_t i=0;i<4;i++) {
191 fDEDX[i] = 0.;
192 fSDEDX[i] = 1e10;
193 fNCDEDX[i] = 0;
9c0db267 194 fNCDEDXInclThres[i] = 0;
32fab534 195 }
9c0db267 196 fDEDX[4] = 0;
32fab534 197 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
81e97e0d 198}
199
6c94f330 200AliTPCseed::AliTPCseed(Double_t xr, Double_t alpha, const Double_t xx[5],
201 const Double_t cc[15], Int_t index):
202 AliTPCtrack(xr, alpha, xx, cc, index),
32fab534 203 fEsd(0x0),
2928bdf0 204 fClusterOwner(kFALSE),
32fab534 205 fRow(0),
206 fSector(-1),
207 fRelativeSector(-1),
c07cb486 208 fCurrentSigmaY2(-1),
209 fCurrentSigmaZ2(-1),
e0e13b88 210 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
211 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 212 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
213 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 214 fErrorY2(1e10),
215 fErrorZ2(1e10),
216 fCurrentCluster(0x0),
217 fCurrentClusterIndex1(-1),
218 fInDead(kFALSE),
219 fIsSeeding(kFALSE),
220 fNoCluster(0),
221 fSort(0),
222 fBSigned(kFALSE),
223 fSeedType(0),
224 fSeed1(-1),
225 fSeed2(-1),
226 fMAngular(0),
ddfbc51a 227 fCircular(0),
228 fPoolID(-1)
32fab534 229{
230 //
231 // Constructor
81e97e0d 232 //
32fab534 233 fFirstPoint =0;
5c09947e 234 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
81e97e0d 235 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
81e97e0d 236 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
32fab534 237 for (Int_t i=0;i<4;i++) {
238 fDEDX[i] = 0.;
239 fSDEDX[i] = 1e10;
240 fNCDEDX[i] = 0;
9c0db267 241 fNCDEDXInclThres[i] = 0;
32fab534 242 }
9c0db267 243 fDEDX[4] = 0;
32fab534 244 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
81e97e0d 245}
246
247AliTPCseed::~AliTPCseed(){
248 //
249 // destructor
81e97e0d 250 fNoCluster =0;
2928bdf0 251 if (fClusterOwner){
252 for (Int_t icluster=0; icluster<160; icluster++){
253 delete fClusterPointer[icluster];
254 }
255 }
bfb57b6c 256
81e97e0d 257}
179c6296 258//_________________________________________________
316c6cd9 259AliTPCseed & AliTPCseed::operator=(const AliTPCseed &param)
179c6296 260{
261 //
316c6cd9 262 // assignment operator
ddfbc51a 263 // don't touch pool ID
179c6296 264 //
316c6cd9 265 if(this!=&param){
266 AliTPCtrack::operator=(param);
267 fEsd =param.fEsd;
316c6cd9 268 fClusterOwner = param.fClusterOwner;
f06a1ff6 269 if (!fClusterOwner) for(Int_t i = 0;i<160;++i)fClusterPointer[i] = param.fClusterPointer[i];
270 else for(Int_t i = 0;i<160;++i)fClusterPointer[i] = new AliTPCclusterMI(*(param.fClusterPointer[i]));
316c6cd9 271 // leave out fPoint, they are also not copied in the copy ctor...
272 // but deleted in the dtor... strange...
316c6cd9 273 fRow = param.fRow;
274 fSector = param.fSector;
275 fRelativeSector = param.fRelativeSector;
276 fCurrentSigmaY2 = param.fCurrentSigmaY2;
277 fCurrentSigmaZ2 = param.fCurrentSigmaZ2;
278 fErrorY2 = param.fErrorY2;
279 fErrorZ2 = param.fErrorZ2;
280 fCurrentCluster = param.fCurrentCluster; // this is not allocated by AliTPCSeed
281 fCurrentClusterIndex1 = param.fCurrentClusterIndex1;
282 fInDead = param.fInDead;
283 fIsSeeding = param.fIsSeeding;
284 fNoCluster = param.fNoCluster;
285 fSort = param.fSort;
286 fBSigned = param.fBSigned;
287 for(Int_t i = 0;i<4;++i){
288 fDEDX[i] = param.fDEDX[i];
289 fSDEDX[i] = param.fSDEDX[i];
290 fNCDEDX[i] = param.fNCDEDX[i];
9c0db267 291 fNCDEDXInclThres[i] = param.fNCDEDXInclThres[i];
316c6cd9 292 }
9c0db267 293 fDEDX[4] = param.fDEDX[4];
316c6cd9 294 for(Int_t i = 0;i<AliPID::kSPECIES;++i)fTPCr[i] = param.fTPCr[i];
295
296 fSeedType = param.fSeedType;
297 fSeed1 = param.fSeed1;
298 fSeed2 = param.fSeed2;
299 for(Int_t i = 0;i<12;++i)fOverlapLabels[i] = param.fOverlapLabels[i];
300 fMAngular = param.fMAngular;
301 fCircular = param.fCircular;
302 for(int i = 0;i<160;++i)fTrackPoints[i] = param.fTrackPoints[i];
316c6cd9 303 }
179c6296 304 return (*this);
305}
306//____________________________________________________
81e97e0d 307AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
308{
309 //
310 //
311 return &fTrackPoints[i];
312}
313
81e97e0d 314
315
316Double_t AliTPCseed::GetDensityFirst(Int_t n)
317{
318 //
319 //
320 // return cluster for n rows bellow first point
321 Int_t nfoundable = 1;
322 Int_t nfound = 1;
323 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
324 Int_t index = GetClusterIndex2(i);
325 if (index!=-1) nfoundable++;
326 if (index>0) nfound++;
327 }
328 if (nfoundable<n) return 0;
329 return Double_t(nfound)/Double_t(nfoundable);
330
331}
332
333
334void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
335{
336 // get cluster stat. on given region
337 //
338 found = 0;
339 foundable = 0;
340 shared =0;
341 for (Int_t i=first;i<last; i++){
342 Int_t index = GetClusterIndex2(i);
343 if (index!=-1) foundable++;
6d493ea0 344 if (index&0x8000) continue;
81e97e0d 345 if (fClusterPointer[i]) {
346 found++;
347 }
348 else
349 continue;
350
351 if (fClusterPointer[i]->IsUsed(10)) {
352 shared++;
353 continue;
354 }
355 if (!plus2) continue; //take also neighborhoud
356 //
357 if ( (i>0) && fClusterPointer[i-1]){
358 if (fClusterPointer[i-1]->IsUsed(10)) {
359 shared++;
360 continue;
361 }
362 }
363 if ( fClusterPointer[i+1]){
364 if (fClusterPointer[i+1]->IsUsed(10)) {
365 shared++;
366 continue;
367 }
368 }
369
370 }
371 //if (shared>found){
372 //Error("AliTPCseed::GetClusterStatistic","problem\n");
373 //}
374}
375
376
377
378
379
380void AliTPCseed::Reset(Bool_t all)
381{
382 //
383 //
384 SetNumberOfClusters(0);
385 fNFoundable = 0;
386 SetChi2(0);
6c94f330 387 ResetCovariance(10.);
81e97e0d 388 /*
389 if (fTrackPoints){
390 for (Int_t i=0;i<8;i++){
391 delete [] fTrackPoints[i];
392 }
393 delete fTrackPoints;
394 fTrackPoints =0;
395 }
396 */
397
398 if (all){
f06a1ff6 399 for (Int_t i=200;i--;) SetClusterIndex2(i,-3);
400 if (!fClusterOwner) for (Int_t i=160;i--;) fClusterPointer[i]=0;
401 else for (Int_t i=160;i--;) {delete fClusterPointer[i]; fClusterPointer[i]=0;}
81e97e0d 402 }
403
404}
405
406
407void AliTPCseed::Modify(Double_t factor)
408{
409
410 //------------------------------------------------------------------
411 //This function makes a track forget its history :)
412 //------------------------------------------------------------------
413 if (factor<=0) {
6c94f330 414 ResetCovariance(10.);
81e97e0d 415 return;
416 }
6c94f330 417 ResetCovariance(factor);
418
81e97e0d 419 SetNumberOfClusters(0);
420 fNFoundable =0;
421 SetChi2(0);
422 fRemoval = 0;
423 fCurrentSigmaY2 = 0.000005;
424 fCurrentSigmaZ2 = 0.000005;
425 fNoCluster = 0;
426 //fFirstPoint = 160;
427 //fLastPoint = 0;
428}
429
430
431
432
433Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
434{
435 //-----------------------------------------------------------------
436 // This function find proloncation of a track to a reference plane x=xk.
437 // doesn't change internal state of the track
438 //-----------------------------------------------------------------
439
6c94f330 440 Double_t x1=GetX(), x2=x1+(xk-x1), dx=x2-x1;
81e97e0d 441
6c94f330 442 if (TMath::Abs(GetSnp()+GetC()*dx) >= AliTPCReconstructor::GetMaxSnpTrack()) {
81e97e0d 443 return 0;
444 }
445
446 // Double_t y1=fP0, z1=fP1;
60e55aee 447 Double_t c1=GetSnp(), r1=sqrt((1.-c1)*(1.+c1));
448 Double_t c2=c1 + GetC()*dx, r2=sqrt((1.-c2)*(1.+c2));
81e97e0d 449
6c94f330 450 y = GetY();
451 z = GetZ();
81e97e0d 452 //y += dx*(c1+c2)/(r1+r2);
453 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
454
455 Double_t dy = dx*(c1+c2)/(r1+r2);
456 Double_t dz = 0;
457 //
6c94f330 458 Double_t delta = GetC()*dx*(c1+c2)/(c1*r2 + c2*r1);
81e97e0d 459 /*
460 if (TMath::Abs(delta)>0.0001){
461 dz = fP3*TMath::ASin(delta)/fP4;
462 }else{
463 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
464 }
465 */
466 // dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
6c94f330 467 dz = GetTgl()*TMath::ASin(delta)/GetC();
81e97e0d 468 //
469 y+=dy;
470 z+=dz;
471
472
473 return 1;
474}
475
476
477//_____________________________________________________________________________
af32720d 478Double_t AliTPCseed::GetPredictedChi2(const AliCluster *c) const
81e97e0d 479{
480 //-----------------------------------------------------------------
481 // This function calculates a predicted chi2 increment.
482 //-----------------------------------------------------------------
6c94f330 483 Double_t p[2]={c->GetY(), c->GetZ()};
484 Double_t cov[3]={fErrorY2, 0., fErrorZ2};
9c7b8249 485
486 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
487 if (TMath::Abs(dx)>0){
488 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
489 Float_t dy = dx*ty;
490 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
491 p[0] = c->GetY()-dy;
492 p[1] = c->GetZ()-dz;
493 }
6c94f330 494 return AliExternalTrackParam::GetPredictedChi2(p,cov);
81e97e0d 495}
496
81e97e0d 497//_________________________________________________________________________________________
498
499
500Int_t AliTPCseed::Compare(const TObject *o) const {
501 //-----------------------------------------------------------------
502 // This function compares tracks according to the sector - for given sector according z
503 //-----------------------------------------------------------------
504 AliTPCseed *t=(AliTPCseed*)o;
6c94f330 505
81e97e0d 506 if (fSort == 0){
507 if (t->fRelativeSector>fRelativeSector) return -1;
508 if (t->fRelativeSector<fRelativeSector) return 1;
509 Double_t z2 = t->GetZ();
510 Double_t z1 = GetZ();
511 if (z2>z1) return 1;
512 if (z2<z1) return -1;
513 return 0;
514 }
515 else {
516 Float_t f2 =1;
6c23ffed 517 f2 = 1-20*TMath::Sqrt(t->GetSigma1Pt2())/(t->OneOverPt()+0.0066);
81e97e0d 518 if (t->fBConstrain) f2=1.2;
519
520 Float_t f1 =1;
6c23ffed 521 f1 = 1-20*TMath::Sqrt(GetSigma1Pt2())/(OneOverPt()+0.0066);
81e97e0d 522
523 if (fBConstrain) f1=1.2;
524
525 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
526 else return +1;
527 }
528}
529
530
531
532
533//_____________________________________________________________________________
70e20dcf 534Bool_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, Int_t index)
6c94f330 535{
81e97e0d 536 //-----------------------------------------------------------------
537 // This function associates a cluster with this track.
538 //-----------------------------------------------------------------
81e97e0d 539 Int_t n=GetNumberOfClusters();
70e20dcf 540 Int_t idx=GetClusterIndex(n); // save the current cluster index
541
542 AliCluster cl(*c); cl.SetSigmaY2(fErrorY2); cl.SetSigmaZ2(fErrorZ2);
ca521f6c 543 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
544 if (TMath::Abs(dx)>0){
545 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
546 Float_t dy = dx*ty;
547 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
548 cl.SetY(c->GetY()-dy);
549 cl.SetZ(c->GetZ()-dz);
550 }
551
70e20dcf 552 if (!AliTPCtrack::Update(&cl,chisq,index)) return kFALSE;
e0e13b88 553
554 if (fCMeanSigmaY2p30<0){
555 fCMeanSigmaY2p30= c->GetSigmaY2(); //! current mean sigma Y2 - mean30%
c07cb486 556 fCMeanSigmaZ2p30= c->GetSigmaZ2(); //! current mean sigma Z2 - mean30%
557 fCMeanSigmaY2p30R = 1; //! current mean sigma Y2 - mean5%
558 fCMeanSigmaZ2p30R = 1; //! current mean sigma Z2 - mean5%
e0e13b88 559 }
560 //
561 fCMeanSigmaY2p30= 0.70*fCMeanSigmaY2p30 +0.30*c->GetSigmaY2();
c07cb486 562 fCMeanSigmaZ2p30= 0.70*fCMeanSigmaZ2p30 +0.30*c->GetSigmaZ2();
563 if (fCurrentSigmaY2>0){
564 fCMeanSigmaY2p30R = 0.7*fCMeanSigmaY2p30R +0.3*c->GetSigmaY2()/fCurrentSigmaY2;
565 fCMeanSigmaZ2p30R = 0.7*fCMeanSigmaZ2p30R +0.3*c->GetSigmaZ2()/fCurrentSigmaZ2;
566 }
e0e13b88 567
81e97e0d 568
70e20dcf 569 SetClusterIndex(n,idx); // restore the current cluster index
6c94f330 570 return kTRUE;
81e97e0d 571}
572
573
574
575//_____________________________________________________________________________
dc5cd41c 576Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t /* onlyused */) {
81e97e0d 577 //-----------------------------------------------------------------
578 // This funtion calculates dE/dX within the "low" and "up" cuts.
579 //-----------------------------------------------------------------
2cadb5d1 580 // CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, Int_t returnVal)
83afd539 581 AliTPCParam *param = AliTPCcalibDB::Instance()->GetParameters();
44a6a09e 582
83afd539 583 Int_t row0 = param->GetNRowLow();
584 Int_t row1 = row0+param->GetNRowUp1();
585 Int_t row2 = row1+param->GetNRowUp2();
44a6a09e 586 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
587 Int_t useTot = 0;
588 if (recoParam) useTot = (recoParam->GetUseTotCharge())? 0:1;
83afd539 589 //
590 //
591 //
2cadb5d1 592 fDEDX[0] = CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 0);
593 fDEDX[1] = CookdEdxAnalytical(low,up,useTot ,0 ,row0, 0);
594 fDEDX[2] = CookdEdxAnalytical(low,up,useTot ,row0,row1, 0);
595 fDEDX[3] = CookdEdxAnalytical(low,up,useTot ,row1,row2, 0);
64bf5ca0 596 fDEDX[4] = CookdEdxAnalytical(low,up,useTot ,row0,row2, 0); // full OROC truncated mean
83afd539 597 //
2cadb5d1 598 fSDEDX[0] = CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 1);
599 fSDEDX[1] = CookdEdxAnalytical(low,up,useTot ,0 ,row0, 1);
600 fSDEDX[2] = CookdEdxAnalytical(low,up,useTot ,row0,row1, 1);
601 fSDEDX[3] = CookdEdxAnalytical(low,up,useTot ,row1,row2, 1);
83afd539 602 //
64bf5ca0 603 fNCDEDX[0] = TMath::Nint(GetTPCClustInfo(2, 1, i1 , i2));
604 fNCDEDX[1] = TMath::Nint(GetTPCClustInfo(2, 1, 0 , row0));
605 fNCDEDX[2] = TMath::Nint(GetTPCClustInfo(2, 1, row0, row1));
606 fNCDEDX[3] = TMath::Nint(GetTPCClustInfo(2, 1, row1, row2));
607 //
608 fNCDEDXInclThres[0] = TMath::Nint(GetTPCClustInfo(2, 2, i1 , i2));
609 fNCDEDXInclThres[1] = TMath::Nint(GetTPCClustInfo(2, 2, 0 , row0));
610 fNCDEDXInclThres[2] = TMath::Nint(GetTPCClustInfo(2, 2, row0, row1));
611 fNCDEDXInclThres[3] = TMath::Nint(GetTPCClustInfo(2, 2, row1, row2));
612 //
83afd539 613 SetdEdx(fDEDX[0]);
614 return fDEDX[0];
81e97e0d 615
ba5e52fb 616// return CookdEdxNorm(low,up,0,i1,i2,1,0,2);
4cc7ba77 617
618
ba5e52fb 619// Float_t amp[200];
620// Float_t angular[200];
621// Float_t weight[200];
622// Int_t index[200];
623// //Int_t nc = 0;
624// Float_t meanlog = 100.;
625
626// Float_t mean[4] = {0,0,0,0};
627// Float_t sigma[4] = {1000,1000,1000,1000};
628// Int_t nc[4] = {0,0,0,0};
629// Float_t norm[4] = {1000,1000,1000,1000};
630// //
631// //
632// fNShared =0;
633
634// Float_t gainGG = 1;
635// if (AliTPCcalibDB::Instance()->GetParameters()){
636// gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000.; //relative gas gain
637// }
638
639
640// for (Int_t of =0; of<4; of++){
641// for (Int_t i=of+i1;i<i2;i+=4)
642// {
643// Int_t clindex = fIndex[i];
644// if (clindex<0||clindex&0x8000) continue;
645
646// //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
647// AliTPCTrackerPoint * point = GetTrackPoint(i);
648// //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
649// //AliTPCTrackerPoint * pointp = 0;
650// //if (i<159) pointp = GetTrackPoint(i+1);
651
652// if (point==0) continue;
653// AliTPCclusterMI * cl = fClusterPointer[i];
654// if (cl==0) continue;
655// if (onlyused && (!cl->IsUsed(10))) continue;
656// if (cl->IsUsed(11)) {
657// fNShared++;
658// continue;
659// }
660// Int_t type = cl->GetType();
661// //if (point->fIsShared){
662// // fNShared++;
663// // continue;
664// //}
665// //if (pointm)
666// // if (pointm->fIsShared) continue;
667// //if (pointp)
668// // if (pointp->fIsShared) continue;
669
670// if (type<0) continue;
671// //if (type>10) continue;
672// //if (point->GetErrY()==0) continue;
673// //if (point->GetErrZ()==0) continue;
674
675// //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
676// //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
677// //if ((ddy*ddy+ddz*ddz)>10) continue;
678
679
680// // if (point->GetCPoint().GetMax()<5) continue;
681// if (cl->GetMax()<5) continue;
682// Float_t angley = point->GetAngleY();
683// Float_t anglez = point->GetAngleZ();
684
685// Float_t rsigmay2 = point->GetSigmaY();
686// Float_t rsigmaz2 = point->GetSigmaZ();
687// /*
688// Float_t ns = 1.;
689// if (pointm){
690// rsigmay += pointm->GetTPoint().GetSigmaY();
691// rsigmaz += pointm->GetTPoint().GetSigmaZ();
692// ns+=1.;
693// }
694// if (pointp){
695// rsigmay += pointp->GetTPoint().GetSigmaY();
696// rsigmaz += pointp->GetTPoint().GetSigmaZ();
697// ns+=1.;
698// }
699// rsigmay/=ns;
700// rsigmaz/=ns;
701// */
702
703// Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
704
705// Float_t ampc = 0; // normalization to the number of electrons
706// if (i>64){
707// // ampc = 1.*point->GetCPoint().GetMax();
708// ampc = 1.*cl->GetMax();
709// //ampc = 1.*point->GetCPoint().GetQ();
710// // AliTPCClusterPoint & p = point->GetCPoint();
711// // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
712// // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
713// //Float_t dz =
714// // TMath::Abs( Int_t(iz) - iz + 0.5);
715// //ampc *= 1.15*(1-0.3*dy);
716// //ampc *= 1.15*(1-0.3*dz);
717// // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
718// //ampc *=zfactor;
719// }
720// else{
721// //ampc = 1.0*point->GetCPoint().GetMax();
722// ampc = 1.0*cl->GetMax();
723// //ampc = 1.0*point->GetCPoint().GetQ();
724// //AliTPCClusterPoint & p = point->GetCPoint();
725// // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
726// //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
727// //Float_t dz =
728// // TMath::Abs( Int_t(iz) - iz + 0.5);
729
730// //ampc *= 1.15*(1-0.3*dy);
731// //ampc *= 1.15*(1-0.3*dz);
732// // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
733// //ampc *=zfactor;
734
735// }
736// ampc *= 2.0; // put mean value to channel 50
737// //ampc *= 0.58; // put mean value to channel 50
738// Float_t w = 1.;
739// // if (type>0) w = 1./(type/2.-0.5);
740// // Float_t z = TMath::Abs(cl->GetZ());
741// if (i<64) {
742// ampc /= 0.6;
743// //ampc /= (1+0.0008*z);
744// } else
745// if (i>128){
746// ampc /=1.5;
747// //ampc /= (1+0.0008*z);
748// }else{
749// //ampc /= (1+0.0008*z);
750// }
81e97e0d 751
ba5e52fb 752// if (type<0) { //amp at the border - lower weight
753// // w*= 2.;
81e97e0d 754
ba5e52fb 755// continue;
756// }
757// if (rsigma>1.5) ampc/=1.3; // if big backround
758// amp[nc[of]] = ampc;
759// amp[nc[of]] /=gainGG;
760// angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
761// weight[nc[of]] = w;
762// nc[of]++;
763// }
81e97e0d 764
ba5e52fb 765// TMath::Sort(nc[of],amp,index,kFALSE);
766// Float_t sumamp=0;
767// Float_t sumamp2=0;
768// Float_t sumw=0;
769// //meanlog = amp[index[Int_t(nc[of]*0.33)]];
770// meanlog = 50;
771// for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
772// Float_t ampl = amp[index[i]]/angular[index[i]];
773// ampl = meanlog*TMath::Log(1.+ampl/meanlog);
774// //
775// sumw += weight[index[i]];
776// sumamp += weight[index[i]]*ampl;
777// sumamp2 += weight[index[i]]*ampl*ampl;
778// norm[of] += angular[index[i]]*weight[index[i]];
779// }
780// if (sumw<1){
781// SetdEdx(0);
782// }
783// else {
784// norm[of] /= sumw;
785// mean[of] = sumamp/sumw;
786// sigma[of] = sumamp2/sumw-mean[of]*mean[of];
787// if (sigma[of]>0.1)
788// sigma[of] = TMath::Sqrt(sigma[of]);
789// else
790// sigma[of] = 1000;
81e97e0d 791
ba5e52fb 792// mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
793// //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
794// //mean *=(1-0.1*(norm-1.));
795// }
796// }
797
798// Float_t dedx =0;
799// fSdEdx =0;
800// fMAngular =0;
801// // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
802// // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
81e97e0d 803
804
ba5e52fb 805// // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
806// // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
807
808// Int_t norm2 = 0;
809// Int_t norm3 = 0;
810// for (Int_t i =0;i<4;i++){
811// if (nc[i]>2&&nc[i]<1000){
812// dedx += mean[i] *nc[i];
813// fSdEdx += sigma[i]*(nc[i]-2);
814// fMAngular += norm[i] *nc[i];
815// norm2 += nc[i];
816// norm3 += nc[i]-2;
817// }
818// fDEDX[i] = mean[i];
819// fSDEDX[i] = sigma[i];
820// fNCDEDX[i]= nc[i];
821// }
822
823// if (norm3>0){
824// dedx /=norm2;
825// fSdEdx /=norm3;
826// fMAngular/=norm2;
827// }
828// else{
829// SetdEdx(0);
830// return 0;
831// }
832// // Float_t dedx1 =dedx;
833// /*
834// dedx =0;
835// for (Int_t i =0;i<4;i++){
836// if (nc[i]>2&&nc[i]<1000){
837// mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
838// dedx += mean[i] *nc[i];
839// }
840// fDEDX[i] = mean[i];
841// }
842// dedx /= norm2;
843// */
81e97e0d 844
845
ba5e52fb 846// SetdEdx(dedx);
847// return dedx;
81e97e0d 848}
81e97e0d 849
850void AliTPCseed::CookPID()
851{
852 //
853 // cook PID information according dEdx
854 //
855 Double_t fRange = 10.;
856 Double_t fRes = 0.1;
857 Double_t fMIP = 47.;
858 //
859 Int_t ns=AliPID::kSPECIES;
860 Double_t sumr =0;
861 for (Int_t j=0; j<ns; j++) {
862 Double_t mass=AliPID::ParticleMass(j);
6c94f330 863 Double_t mom=GetP();
81e97e0d 864 Double_t dedx=fdEdx/fMIP;
5731b051 865 Double_t bethe=AliMathBase::BetheBlochAleph(mom/mass);
81e97e0d 866 Double_t sigma=fRes*bethe;
867 if (sigma>0.001){
868 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
869 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
870 sumr+=fTPCr[j];
871 continue;
872 }
873 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
874 sumr+=fTPCr[j];
875 }
876 else{
877 fTPCr[j]=1.;
878 sumr+=fTPCr[j];
879 }
880 }
881 for (Int_t j=0; j<ns; j++) {
882 fTPCr[j]/=sumr; //normalize
883 }
884}
885
6c94f330 886Double_t AliTPCseed::GetYat(Double_t xk) const {
887//-----------------------------------------------------------------
888// This function calculates the Y-coordinate of a track at the plane x=xk.
889//-----------------------------------------------------------------
890 if (TMath::Abs(GetSnp())>AliTPCReconstructor::GetMaxSnpTrack()) return 0.; //patch 01 jan 06
60e55aee 891 Double_t c1=GetSnp(), r1=TMath::Sqrt((1.-c1)*(1.+c1));
6c94f330 892 Double_t c2=c1+GetC()*(xk-GetX());
893 if (TMath::Abs(c2)>AliTPCReconstructor::GetMaxSnpTrack()) return 0;
60e55aee 894 Double_t r2=TMath::Sqrt((1.-c2)*(1.+c2));
6c94f330 895 return GetY() + (xk-GetX())*(c1+c2)/(r1+r2);
896}
897
0a65832b 898
899
8a92e133 900Float_t AliTPCseed::CookdEdxNorm(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, Bool_t shapeNorm,Int_t posNorm, Int_t padNorm, Int_t returnVal){
0a65832b 901
902 //
903 // calculates dedx using the cluster
904 // low - up specify trunc mean range - default form 0-0.7
8076baa0 905 // type - 1 - max charge or 0- total charge in cluster
906 // //2- max no corr 3- total+ correction
0a65832b 907 // i1-i2 - the pad-row range used for calculation
ba5e52fb 908 // shapeNorm - kTRUE -taken from OCDB
909 //
910 // posNorm - usage of pos normalization
83afd539 911 // padNorm - pad type normalization
912 // returnVal - 0 return mean
913 // - 1 return RMS
914 // - 2 return number of clusters
915 //
0a65832b 916 // normalization parametrization taken from AliTPCClusterParam
917 //
ba5e52fb 918 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
919 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
920 if (!parcl) return 0;
921 if (!param) return 0;
83afd539 922 Int_t row0 = param->GetNRowLow();
923 Int_t row1 = row0+param->GetNRowUp1();
924
0a65832b 925 Float_t amp[160];
926 Int_t indexes[160];
927 Int_t ncl=0;
928 //
929 //
ba5e52fb 930 Float_t gainGG = 1; // gas gain factor -always enabled
931 Float_t gainPad = 1; // gain map - used always
83afd539 932 Float_t corrShape = 1; // correction due angular effect, diffusion and electron attachment
ba5e52fb 933 Float_t corrPos = 1; // local position correction - if posNorm enabled
934 Float_t corrPadType = 1; // pad type correction - if padNorm enabled
935 Float_t corrNorm = 1; // normalization factor - set Q to channel 50
936 //
937 //
938 //
4cc7ba77 939 if (AliTPCcalibDB::Instance()->GetParameters()){
ba5e52fb 940 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
4cc7ba77 941 }
942
0a65832b 943 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
4cc7ba77 944 const Float_t kedgey =3.;
0a65832b 945 //
7cd8ac3f 946 //
0a65832b 947 for (Int_t irow=i1; irow<i2; irow++){
948 AliTPCclusterMI* cluster = GetClusterPointer(irow);
949 if (!cluster) continue;
950 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
8076baa0 951 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
ba5e52fb 952 Int_t ipad= 0;
83afd539 953 if (irow>=row0) ipad=1;
954 if (irow>=row1) ipad=2;
ba5e52fb 955 //
956 //
957 //
958 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
959 if (gainMap) {
960 //
961 // Get gainPad - pad by pad calibration
962 //
d6920632 963 Float_t factor = 1;
964 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
83afd539 965 if (irow < row0) { // IROC
ba5e52fb 966 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
d6920632 967 } else { // OROC
83afd539 968 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
d6920632 969 }
ba5e52fb 970 if (factor>0.5) gainPad=factor;
7cd8ac3f 971 }
ba5e52fb 972 //
973 //do position and angular normalization
974 //
975 if (shapeNorm){
976 if (type<=1){
977 //
978 AliTPCTrackerPoint * point = GetTrackPoint(irow);
979 Float_t ty = TMath::Abs(point->GetAngleY());
83afd539 980 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
ba5e52fb 981
982 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
983 corrShape = parcl->Qnorm(ipad,type,dr,ty,tz);
984 }
0a65832b 985 }
ba5e52fb 986
8a92e133 987 if (posNorm>0){
8e1dcdda 988 //
ba5e52fb 989 // Do position normalization - relative distance to
990 // center of pad- time bin
991 // Work in progress
022a2383 992 // corrPos = parcl->QnormPos(ipad,type, cluster->GetPad(),
993 // cluster->GetTimeBin(), cluster->GetZ(),
994 // cluster->GetSigmaY2(),cluster->GetSigmaZ2(),
995 // cluster->GetMax(),cluster->GetQ());
8a92e133 996 // scaled response function
997 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
998 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
999 //
1000
022a2383 1001 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1002 Float_t ty = TMath::Abs(point->GetAngleY());
1003 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1004
1005 if (type==1) corrPos =
1006 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
8a92e133 1007 cluster->GetTimeBin(),ty,tz,yres0,zres0,0.4);
022a2383 1008 if (type==0) corrPos =
1009 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
8a92e133 1010 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,0.4);
1011 if (posNorm==3){
1012 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
1013 Double_t signtgl = (cluster->GetZ()*point->GetAngleZ()>0)? 1:-1;
1014 Double_t p2 = TMath::Abs(TMath::Sin(TMath::ATan(ty)));
1015 Float_t corrHis = parcl->QnormHis(ipad,type,dr,p2,TMath::Abs(point->GetAngleZ())*signtgl);
1016 if (corrHis>0) corrPos*=corrHis;
1017 }
1018
8e1dcdda 1019 }
1020
ba5e52fb 1021 if (padNorm==1){
1022 //taken from OCDB
798017c7 1023 if (type==0 && parcl->QpadTnorm()) corrPadType = (*parcl->QpadTnorm())[ipad];
1024 if (type==1 && parcl->QpadMnorm()) corrPadType = (*parcl->QpadMnorm())[ipad];
022a2383 1025
2fc9608f 1026 }
ba5e52fb 1027 if (padNorm==2){
1028 corrPadType =param->GetPadPitchLength(cluster->GetDetector(),cluster->GetRow());
1029 //use hardwired - temp fix
1030 if (type==0) corrNorm=3.;
1031 if (type==1) corrNorm=1.;
1032 }
1033 //
1034 amp[ncl]=charge;
1035 amp[ncl]/=gainGG;
1036 amp[ncl]/=gainPad;
1037 amp[ncl]/=corrShape;
1038 amp[ncl]/=corrPadType;
1039 amp[ncl]/=corrPos;
1040 amp[ncl]/=corrNorm;
1041 //
0a65832b 1042 ncl++;
1043 }
8076baa0 1044
0a65832b 1045 if (type>3) return ncl;
1046 TMath::Sort(ncl,amp, indexes, kFALSE);
1047
8076baa0 1048 if (ncl<10) return 0;
0a65832b 1049
1050 Float_t suma=0;
83afd539 1051 Float_t suma2=0;
0a65832b 1052 Float_t sumn=0;
1053 Int_t icl0=TMath::Nint(ncl*low);
1054 Int_t icl1=TMath::Nint(ncl*up);
1055 for (Int_t icl=icl0; icl<icl1;icl++){
1056 suma+=amp[indexes[icl]];
83afd539 1057 suma2+=amp[indexes[icl]]*amp[indexes[icl]];
0a65832b 1058 sumn++;
1059 }
83afd539 1060 Float_t mean =suma/sumn;
1061 Float_t rms =TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
3af3fbc4 1062 //
1063 // do time-dependent correction for pressure and temperature variations
1064 UInt_t runNumber = 1;
1065 Float_t corrTimeGain = 1;
1066 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
e5e80ff9 1067 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
1068 if (trans && recoParam->GetUseGainCorrectionTime()>0) {
3af3fbc4 1069 runNumber = trans->GetCurrentRunNumber();
e5e80ff9 1070 //AliTPCcalibDB::Instance()->SetRun(runNumber);
a2c3785e 1071 TObjArray * timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
3af3fbc4 1072 if (timeGainSplines) {
1073 UInt_t time = trans->GetCurrentTimeStamp();
1074 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1075 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1076 if (fitMIP) {
108a67db 1077 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time);/*fitMIP->Eval(time);*/
3af3fbc4 1078 } else {
108a67db 1079 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time);/*fitFPcosmic->Eval(time);*/
3af3fbc4 1080 }
1081 }
1082 }
1083 mean /= corrTimeGain;
1084 rms /= corrTimeGain;
1085 //
83afd539 1086 if (returnVal==1) return rms;
8a92e133 1087 if (returnVal==2) return ncl;
1088 return mean;
1089}
1090
6feb400f 1091Float_t AliTPCseed::CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, Int_t returnVal, Int_t rowThres, Int_t mode){
8a92e133 1092
1093 //
1094 // calculates dedx using the cluster
1095 // low - up specify trunc mean range - default form 0-0.7
1096 // type - 1 - max charge or 0- total charge in cluster
1097 // //2- max no corr 3- total+ correction
1098 // i1-i2 - the pad-row range used for calculation
1099 //
1100 // posNorm - usage of pos normalization
6feb400f 1101 // returnVal - 0 return mean
1102 // - 1 return RMS
1103 // - 2 return number of clusters
1104 // - 3 ratio
1105 // - 4 mean upper half
1106 // - 5 mean - lower half
1107 // - 6 third moment
1108 // mode - 0 - linear
1109 // - 1 - logatithmic
2efc897f 1110 // rowThres - number of rows before and after given pad row to check for clusters below threshold
8a92e133 1111 //
1112 // normalization parametrization taken from AliTPCClusterParam
1113 //
1114 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
1115 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
1116 if (!parcl) return 0;
1117 if (!param) return 0;
1118 Int_t row0 = param->GetNRowLow();
1119 Int_t row1 = row0+param->GetNRowUp1();
1120
1121 Float_t amp[160];
1122 Int_t indexes[160];
1123 Int_t ncl=0;
2efc897f 1124 Int_t nclBelowThr = 0; // counts number of clusters below threshold
8a92e133 1125 //
1126 //
1127 Float_t gainGG = 1; // gas gain factor -always enabled
1128 Float_t gainPad = 1; // gain map - used always
1129 Float_t corrPos = 1; // local position correction - if posNorm enabled
8a92e133 1130 //
1131 //
1132 //
1133 if (AliTPCcalibDB::Instance()->GetParameters()){
1134 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
1135 }
649fcc43 1136 //
1137 // extract time-dependent correction for pressure and temperature variations
1138 //
1139 UInt_t runNumber = 1;
1140 Float_t corrTimeGain = 1;
1141 TObjArray * timeGainSplines = 0x0;
1142 TGraphErrors * grPadEqual = 0x0;
1143 //
1144 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
1145 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
6d64657a 1146 //
1147 if (recoParam->GetNeighborRowsDedx() == 0) rowThres = 0;
1148 //
649fcc43 1149 if (trans) {
2efc897f 1150 runNumber = trans->GetCurrentRunNumber();
1151 //AliTPCcalibDB::Instance()->SetRun(runNumber);
1152 timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
1153 if (timeGainSplines && recoParam->GetUseGainCorrectionTime()>0) {
1154 UInt_t time = trans->GetCurrentTimeStamp();
1155 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1156 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1157 if (fitMIP) {
1158 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time); /*fitMIP->Eval(time);*/
649fcc43 1159 } else {
2efc897f 1160 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time); /*fitFPcosmic->Eval(time); */
1161 }
649fcc43 1162 //
1163 if (type==1) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQMAX_PADREGIONGAIN_BEAM_ALL");
1164 if (type==0) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQTOT_PADREGIONGAIN_BEAM_ALL");
2efc897f 1165 }
649fcc43 1166 }
2efc897f 1167
1168 const Float_t kClusterShapeCut = 1.5; // IMPPRTANT TO DO: move value to AliTPCRecoParam
8a92e133 1169 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1170 const Float_t kedgey =3.;
1171 //
1172 //
1173 for (Int_t irow=i1; irow<i2; irow++){
1174 AliTPCclusterMI* cluster = GetClusterPointer(irow);
736a5826 1175 if (!cluster && irow > 1 && irow < 157) {
2efc897f 1176 Bool_t isClBefore = kFALSE;
1177 Bool_t isClAfter = kFALSE;
1178 for(Int_t ithres = 1; ithres <= rowThres; ithres++) {
1179 AliTPCclusterMI * clusterBefore = GetClusterPointer(irow - ithres);
1180 if (clusterBefore) isClBefore = kTRUE;
1181 AliTPCclusterMI * clusterAfter = GetClusterPointer(irow + ithres);
1182 if (clusterAfter) isClAfter = kTRUE;
1183 }
1184 if (isClBefore && isClAfter) nclBelowThr++;
2efc897f 1185 }
736a5826 1186 if (!cluster) continue;
2efc897f 1187 //
1188 //
8a92e133 1189 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
2efc897f 1190 //
1191 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1192 if (point==0) continue;
1193 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1194 if (rsigmay > kClusterShapeCut) continue;
1195 //
1196 if (cluster->IsUsed(11)) continue; // remove shared clusters for PbPb
1197 //
8a92e133 1198 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
1199 Int_t ipad= 0;
1200 if (irow>=row0) ipad=1;
1201 if (irow>=row1) ipad=2;
1202 //
1203 //
1204 //
1205 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
1206 if (gainMap) {
1207 //
1208 // Get gainPad - pad by pad calibration
1209 //
1210 Float_t factor = 1;
1211 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
1212 if (irow < row0) { // IROC
1213 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
1214 } else { // OROC
1215 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
1216 }
2efc897f 1217 if (factor>0.3) gainPad=factor;
8a92e133 1218 }
8a92e133 1219 //
1220 // Do position normalization - relative distance to
1221 // center of pad- time bin
1222
8a92e133 1223 Float_t ty = TMath::Abs(point->GetAngleY());
1224 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1225 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
1226 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1227
1228 yres0 *=parcl->GetQnormCorr(ipad, type,0);
1229 zres0 *=parcl->GetQnormCorr(ipad, type,1);
1230 Float_t effLength=parcl->GetQnormCorr(ipad, type,4)*0.5;
1231 Float_t effDiff =(parcl->GetQnormCorr(ipad, type,2)+parcl->GetQnormCorr(ipad, type,3))*0.5;
1232 //
1233 if (type==1) {
1234 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1235 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1236 cluster->GetTimeBin(),ty,tz,yres0,zres0,effLength,effDiff);
1237 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1238 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1239 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1240 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1241 //
1242 }
1243 if (type==0) {
1244 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1245 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1246 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,effLength,effDiff);
1247
1248 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1249 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1250 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1251 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1252 //
1253 }
2efc897f 1254 //
1255 // pad region equalization outside of cluster param
1256 //
1257 Float_t gainEqualPadRegion = 1;
649fcc43 1258 if (grPadEqual) gainEqualPadRegion = grPadEqual->Eval(ipad);
8a92e133 1259 //
1260 amp[ncl]=charge;
1261 amp[ncl]/=gainGG;
1262 amp[ncl]/=gainPad;
1263 amp[ncl]/=corrPos;
2efc897f 1264 amp[ncl]/=gainEqualPadRegion;
8a92e133 1265 //
1266 ncl++;
1267 }
1268
6feb400f 1269 if (type==2) return ncl;
8a92e133 1270 TMath::Sort(ncl,amp, indexes, kFALSE);
2efc897f 1271 //
8a92e133 1272 if (ncl<10) return 0;
2efc897f 1273 //
1274 Double_t * ampWithBelow = new Double_t[ncl + nclBelowThr];
1275 for(Int_t iCl = 0; iCl < ncl + nclBelowThr; iCl++) {
1276 if (iCl < nclBelowThr) {
1277 ampWithBelow[iCl] = amp[indexes[0]];
1278 } else {
1279 ampWithBelow[iCl] = amp[indexes[iCl - nclBelowThr]];
1280 }
1281 }
1282 //printf("DEBUG: %i shit %f", nclBelowThr, amp[indexes[0]]);
1283 //
8a92e133 1284 Float_t suma=0;
1285 Float_t suma2=0;
6feb400f 1286 Float_t suma3=0;
1287 Float_t sumaS=0;
8a92e133 1288 Float_t sumn=0;
6feb400f 1289 // upper,and lower part statistic
1290 Float_t sumL=0, sumL2=0, sumLN=0;
1291 Float_t sumD=0, sumD2=0, sumDN=0;
1292
2efc897f 1293 Int_t icl0=TMath::Nint((ncl + nclBelowThr)*low);
1294 Int_t icl1=TMath::Nint((ncl + nclBelowThr)*up);
6feb400f 1295 Int_t iclm=TMath::Nint((ncl + nclBelowThr)*(low +(up+low)*0.5));
1296 //
8a92e133 1297 for (Int_t icl=icl0; icl<icl1;icl++){
6feb400f 1298 if (ampWithBelow[icl]<0.1) continue;
504dd8df 1299 Double_t camp=ampWithBelow[icl]/corrTimeGain;
1300 if (mode==1) camp= TMath::Log(camp);
6feb400f 1301 if (icl<icl1){
504dd8df 1302 suma+=camp;
1303 suma2+=camp*camp;
1304 suma3+=camp*camp*camp;
1305 sumaS+=TMath::Power(TMath::Abs(camp),1./3.);
6feb400f 1306 sumn++;
1307 }
1308 if (icl>iclm){
504dd8df 1309 sumL+=camp;
1310 sumL2+=camp*camp;
6feb400f 1311 sumLN++;
1312 }
1313 if (icl<=iclm){
504dd8df 1314 sumD+=camp;
1315 sumD2+=camp*camp;
6feb400f 1316 sumDN++;
1317 }
8a92e133 1318 }
0f7547f1 1319 //
1320 Float_t mean = 0;
1321 Float_t meanL = 0;
1322 Float_t meanD = 0; // lower half mean
1323 if (sumn > 1e-30) mean =suma/sumn;
1324 if (sumLN > 1e-30) meanL =sumL/sumLN;
1325 if (sumDN > 1e-30) meanD =(sumD/sumDN);
1326 /*
8a92e133 1327 Float_t mean =suma/sumn;
6feb400f 1328 Float_t meanL = sumL/sumLN;
1329 Float_t meanD =(sumD/sumDN); // lower half mean
0f7547f1 1330 */
28273e26 1331
1332 Float_t rms = 0;
1333 Float_t mean2=0;
1334 Float_t mean3=0;
1335 Float_t meanS=0;
1336
1337 if(sumn>0){
1338 rms = TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1339 mean2=suma2/sumn;
1340 mean3=suma3/sumn;
1341 meanS=sumaS/sumn;
1342 }
1343
6feb400f 1344 if (mean2>0) mean2=TMath::Power(TMath::Abs(mean2),1./2.);
1345 if (mean3>0) mean3=TMath::Power(TMath::Abs(mean3),1./3.);
1346 if (meanS>0) meanS=TMath::Power(TMath::Abs(meanS),3.);
3af3fbc4 1347 //
6feb400f 1348 if (mode==1) mean=TMath::Exp(mean);
1349 if (mode==1) meanL=TMath::Exp(meanL); // upper truncation
1350 if (mode==1) meanD=TMath::Exp(meanD); // lower truncation
1351 //
1352 delete [] ampWithBelow;
1353
1354
3af3fbc4 1355 //
8a92e133 1356 if (returnVal==1) return rms;
83afd539 1357 if (returnVal==2) return ncl;
6feb400f 1358 if (returnVal==3) return Double_t(nclBelowThr)/Double_t(nclBelowThr+ncl);
1359 if (returnVal==4) return meanL;
1360 if (returnVal==5) return meanD;
1361 if (returnVal==6) return mean2;
1362 if (returnVal==7) return mean3;
1363 if (returnVal==8) return meanS;
83afd539 1364 return mean;
0a65832b 1365}
1366
83afd539 1367
0a65832b 1368
1369
eb02f63a 1370Float_t AliTPCseed::CookShape(Int_t type){
1371 //
1372 //
1373 //
1374 //-----------------------------------------------------------------
1375 // This funtion calculates dE/dX within the "low" and "up" cuts.
1376 //-----------------------------------------------------------------
1377 Float_t means=0;
1378 Float_t meanc=0;
1379 for (Int_t i =0; i<160;i++) {
1380 AliTPCTrackerPoint * point = GetTrackPoint(i);
1381 if (point==0) continue;
1382
1383 AliTPCclusterMI * cl = fClusterPointer[i];
1384 if (cl==0) continue;
1385
1386 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1387 Float_t rsigmaz = TMath::Sqrt(point->GetSigmaZ());
1388 Float_t rsigma = (rsigmay+rsigmaz)*0.5;
1389 if (type==0) means+=rsigma;
1390 if (type==1) means+=rsigmay;
1391 if (type==2) means+=rsigmaz;
1392 meanc++;
1393 }
1394 Float_t mean = (meanc>0)? means/meanc:0;
1395 return mean;
1396}
87e92a27 1397
1398
1399
1400Int_t AliTPCseed::RefitTrack(AliTPCseed *seed, AliExternalTrackParam * parin, AliExternalTrackParam * parout){
1401 //
1402 // Refit the track
1403 // return value - number of used clusters
1404 //
1405 //
1406 const Int_t kMinNcl =10;
1407 AliTPCseed *track=new AliTPCseed(*seed);
1408 Int_t sector=-1;
1409 // reset covariance
1410 //
1411 Double_t covar[15];
1412 for (Int_t i=0;i<15;i++) covar[i]=0;
1413 covar[0]=10.*10.;
1414 covar[2]=10.*10.;
1415 covar[5]=10.*10./(64.*64.);
1416 covar[9]=10.*10./(64.*64.);
1417 covar[14]=1*1;
1418 //
1419
1420 Float_t xmin=1000, xmax=-10000;
1421 Int_t imin=158, imax=0;
1422 for (Int_t i=0;i<160;i++) {
1423 AliTPCclusterMI *c=track->GetClusterPointer(i);
1424 if (!c) continue;
1425 if (sector<0) sector = c->GetDetector();
1426 if (c->GetX()<xmin) xmin=c->GetX();
1427 if (c->GetX()>xmax) xmax=c->GetX();
1428 if (i<imin) imin=i;
1429 if (i>imax) imax=i;
1430 }
1431 if(imax-imin<kMinNcl) {
1432 delete track;
1433 return 0 ;
1434 }
1435 // Not succes to rotate
1436 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1437 delete track;
1438 return 0;
1439 }
1440 //
1441 //
1442 // fit from inner to outer row
1443 //
1444 AliExternalTrackParam paramIn;
1445 AliExternalTrackParam paramOut;
1446 Bool_t isOK=kTRUE;
be34cb88 1447 Int_t ncl=0;
87e92a27 1448 //
1449 //
1450 //
1451 for (Int_t i=imin; i<=imax; i++){
1452 AliTPCclusterMI *c=track->GetClusterPointer(i);
1453 if (!c) continue;
1454 // if (RejectCluster(c,track)) continue;
be34cb88 1455 sector = (c->GetDetector()%18);
1456 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1457 //continue;
1458 }
87e92a27 1459 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1460 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1461 if (!track->PropagateTo(r[0])) {
1462 isOK=kFALSE;
87e92a27 1463 }
1464 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1465 }
1466 if (!isOK) { delete track; return 0;}
1467 track->AddCovariance(covar);
1468 //
1469 //
1470 //
1471 for (Int_t i=imax; i>=imin; i--){
1472 AliTPCclusterMI *c=track->GetClusterPointer(i);
1473 if (!c) continue;
1474 //if (RejectCluster(c,track)) continue;
be34cb88 1475 sector = (c->GetDetector()%18);
1476 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1477 //continue;
1478 }
87e92a27 1479 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1480 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1481 if (!track->PropagateTo(r[0])) {
1482 isOK=kFALSE;
87e92a27 1483 }
1484 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1485 }
be34cb88 1486 //if (!isOK) { delete track; return 0;}
87e92a27 1487 paramIn = *track;
1488 track->AddCovariance(covar);
1489 //
1490 //
1491 for (Int_t i=imin; i<=imax; i++){
1492 AliTPCclusterMI *c=track->GetClusterPointer(i);
1493 if (!c) continue;
be34cb88 1494 sector = (c->GetDetector()%18);
1495 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1496 //continue;
1497 }
1498 ncl++;
87e92a27 1499 //if (RejectCluster(c,track)) continue;
1500 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1501 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1502 if (!track->PropagateTo(r[0])) {
1503 isOK=kFALSE;
87e92a27 1504 }
1505 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1506 }
be34cb88 1507 //if (!isOK) { delete track; return 0;}
87e92a27 1508 paramOut=*track;
87e92a27 1509 //
1510 //
1511 //
1512 if (parin) (*parin)=paramIn;
1513 if (parout) (*parout)=paramOut;
6e23caff 1514 delete track;
be34cb88 1515 return ncl;
87e92a27 1516}
1517
1518
1519
1520Bool_t AliTPCseed::RefitTrack(AliTPCseed* /*seed*/, Bool_t /*out*/){
1521 //
1522 //
1523 //
1524 return kFALSE;
1525}
3247d397 1526
1527
1528
1529
1530
1531
1532void AliTPCseed::GetError(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1533 Double_t& erry, Double_t &errz)
1534{
1535 //
1536 // Get cluster error at given position
1537 //
1538 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1539 Double_t tany,tanz;
1540 Double_t snp1=param->GetSnp();
60e55aee 1541 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
3247d397 1542 //
1543 Double_t tgl1=param->GetTgl();
60e55aee 1544 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
3247d397 1545 //
1546 Int_t padSize = 0; // short pads
1547 if (cluster->GetDetector() >= 36) {
1548 padSize = 1; // medium pads
1549 if (cluster->GetRow() > 63) padSize = 2; // long pads
1550 }
1551
1552 erry = clusterParam->GetError0Par( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany) );
1553 errz = clusterParam->GetError0Par( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) );
1554}
1555
1556
1557void AliTPCseed::GetShape(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1558 Double_t& rmsy, Double_t &rmsz)
1559{
1560 //
1561 // Get cluster error at given position
1562 //
1563 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1564 Double_t tany,tanz;
1565 Double_t snp1=param->GetSnp();
60e55aee 1566 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
3247d397 1567 //
1568 Double_t tgl1=param->GetTgl();
60e55aee 1569 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
3247d397 1570 //
1571 Int_t padSize = 0; // short pads
1572 if (cluster->GetDetector() >= 36) {
1573 padSize = 1; // medium pads
1574 if (cluster->GetRow() > 63) padSize = 2; // long pads
1575 }
1576
1577 rmsy = clusterParam->GetRMSQ( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany), TMath::Abs(cluster->GetMax()) );
1578 rmsz = clusterParam->GetRMSQ( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) ,TMath::Abs(cluster->GetMax()));
1579}
ba5e52fb 1580
1581
1582
1583Double_t AliTPCseed::GetQCorrGeom(Float_t ty, Float_t tz){
1584 //Geoetrical
1585 //ty - tangent in local y direction
1586 //tz - tangent
1587 //
1588 Float_t norm=TMath::Sqrt(1+ty*ty+tz*tz);
1589 return norm;
1590}
1591
83afd539 1592Double_t AliTPCseed::GetQCorrShape(Int_t ipad, Int_t type,Float_t z, Float_t ty, Float_t tz, Float_t /*q*/, Float_t /*thr*/){
ba5e52fb 1593 //
1594 // Q normalization
1595 //
1596 // return value = Q Normalization factor
1597 // Normalization - 1 - shape factor part for full drift
1598 // 1 - electron attachment for 0 drift
1599
1600 // Input parameters:
1601 //
1602 // ipad - 0 short pad
1603 // 1 medium pad
1604 // 2 long pad
1605 //
1606 // type - 0 qmax
1607 // - 1 qtot
1608 //
1609 //z - z position (-250,250 cm)
1610 //ty - tangent in local y direction
1611 //tz - tangent
1612 //
1613
1614 AliTPCClusterParam * paramCl = AliTPCcalibDB::Instance()->GetClusterParam();
1615 AliTPCParam * paramTPC = AliTPCcalibDB::Instance()->GetParameters();
1616
1617 if (!paramCl) return 1;
1618 //
1619 Double_t dr = 250.-TMath::Abs(z);
1620 Double_t sy = paramCl->GetRMS0( 0,ipad, dr, TMath::Abs(ty));
1621 Double_t sy0= paramCl->GetRMS0(0,ipad, 250, 0);
1622 Double_t sz = paramCl->GetRMS0( 1,ipad, dr, TMath::Abs(tz));
1623 Double_t sz0= paramCl->GetRMS0(1,ipad, 250, 0);
1624
1625 Double_t sfactorMax = TMath::Sqrt(sy0*sz0/(sy*sz));
1626
1627
1628 Double_t dt = 1000000*(dr/paramTPC->GetDriftV()); //time in microsecond
1629 Double_t attProb = TMath::Exp(-paramTPC->GetAttCoef()*paramTPC->GetOxyCont()*dt);
1630 //
1631 //
1632 if (type==0) return sfactorMax*attProb;
1633
1634 return attProb;
1635
1636
1637}
1638
64bf5ca0 1639
1640//_______________________________________________________________________
1641Float_t AliTPCseed::GetTPCClustInfo(Int_t nNeighbours, Int_t type, Int_t row0, Int_t row1)
1642{
1643 //
1644 // TPC cluster information
1645 // type 0: get fraction of found/findable clusters with neighbourhood definition
1646 // 1: found clusters
1647 // 2: findable (number of clusters above and below threshold)
1648 //
1649 // definition of findable clusters:
1650 // a cluster is defined as findable if there is another cluster
1651 // within +- nNeighbours pad rows. The idea is to overcome threshold
1652 // effects with a very simple algorithm.
1653 //
1654
1655 const Float_t kClusterShapeCut = 1.5; // IMPPRTANT TO DO: move value to AliTPCRecoParam
1656 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1657 const Float_t kedgey =3.;
1658
1659 Float_t ncl = 0;
1660 Float_t nclBelowThr = 0; // counts number of clusters below threshold
1661
1662 for (Int_t irow=row0; irow<row1; irow++){
1663 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1664
1665 if (!cluster && irow > 1 && irow < 157) {
1666 Bool_t isClBefore = kFALSE;
1667 Bool_t isClAfter = kFALSE;
1668 for(Int_t ithres = 1; ithres <= nNeighbours; ithres++) {
1669 AliTPCclusterMI * clusterBefore = GetClusterPointer(irow - ithres);
1670 if (clusterBefore) isClBefore = kTRUE;
1671 AliTPCclusterMI * clusterAfter = GetClusterPointer(irow + ithres);
1672 if (clusterAfter) isClAfter = kTRUE;
1673 }
1674 if (isClBefore && isClAfter) nclBelowThr++;
1675 }
1676 if (!cluster) continue;
1677 //
1678 //
1679 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
1680 //
1681 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1682 if (point==0) continue;
1683 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1684 if (rsigmay > kClusterShapeCut) continue;
1685 //
1686 if (cluster->IsUsed(11)) continue; // remove shared clusters for PbPb
1687 ncl++;
1688 }
1689
1690 if(ncl<10)
1691 return 0;
1692 if(type==0)
1693 if(nclBelowThr+ncl>0)
1694 return ncl/(nclBelowThr+ncl);
1695 if(type==1)
1696 return ncl;
1697 if(type==2)
1698 return ncl+nclBelowThr;
1699 return 0;
1700}
f06a1ff6 1701
1702//_______________________________________________________________________
1703void AliTPCseed::Clear(Option_t*)
1704{
1705 // formally seed may allocate memory for clusters (althought this should not happen for
1706 // the seeds in the pool). Hence we need this method for fwd. compatibility
1707 if (fClusterOwner) for (int i=160;i--;) {delete fClusterPointer[i]; fClusterPointer[i] = 0;}
1708}