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