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