]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCseed.cxx
Bug fix
[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"
81e97e0d 27
28ClassImp(AliTPCseed)
29
30
31
32fab534 32AliTPCseed::AliTPCseed():
33 AliTPCtrack(),
34 fEsd(0x0),
2928bdf0 35 fClusterOwner(kFALSE),
32fab534 36 fPoints(0x0),
37 fEPoints(0x0),
38 fRow(0),
39 fSector(-1),
40 fRelativeSector(-1),
41 fCurrentSigmaY2(1e10),
42 fCurrentSigmaZ2(1e10),
43 fErrorY2(1e10),
44 fErrorZ2(1e10),
45 fCurrentCluster(0x0),
46 fCurrentClusterIndex1(-1),
47 fInDead(kFALSE),
48 fIsSeeding(kFALSE),
49 fNoCluster(0),
50 fSort(0),
51 fBSigned(kFALSE),
52 fSeedType(0),
53 fSeed1(-1),
54 fSeed2(-1),
55 fMAngular(0),
56 fCircular(0)
57{
81e97e0d 58 //
5c09947e 59 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
81e97e0d 60 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
61 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=0;
32fab534 62 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0.2;
63 for (Int_t i=0;i<4;i++) {
64 fDEDX[i] = 0.;
65 fSDEDX[i] = 1e10;
66 fNCDEDX[i] = 0;
67 }
68 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
81e97e0d 69}
32fab534 70
2928bdf0 71AliTPCseed::AliTPCseed(const AliTPCseed &s, Bool_t clusterOwner):
32fab534 72 AliTPCtrack(s),
73 fEsd(0x0),
2928bdf0 74 fClusterOwner(clusterOwner),
32fab534 75 fPoints(0x0),
76 fEPoints(0x0),
77 fRow(0),
78 fSector(-1),
79 fRelativeSector(-1),
80 fCurrentSigmaY2(1e10),
81 fCurrentSigmaZ2(1e10),
82 fErrorY2(1e10),
83 fErrorZ2(1e10),
84 fCurrentCluster(0x0),
85 fCurrentClusterIndex1(-1),
86 fInDead(kFALSE),
87 fIsSeeding(kFALSE),
88 fNoCluster(0),
89 fSort(0),
90 fBSigned(kFALSE),
91 fSeedType(0),
92 fSeed1(-1),
93 fSeed2(-1),
94 fMAngular(0),
95 fCircular(0)
96{
81e97e0d 97 //---------------------
98 // dummy copy constructor
99 //-------------------------
2928bdf0 100 for (Int_t i=0;i<160;i++) {
101 fClusterPointer[i]=0;
102 if (fClusterOwner){
103 if (s.fClusterPointer[i])
104 fClusterPointer[i] = new AliTPCclusterMI(*(s.fClusterPointer[i]));
105 }else{
106 fClusterPointer[i] = s.fClusterPointer[i];
107 }
108 fTrackPoints[i] = s.fTrackPoints[i];
109 }
81e97e0d 110 for (Int_t i=0;i<160;i++) fIndex[i] = s.fIndex[i];
5c09947e 111 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=s.fTPCr[i];
112 for (Int_t i=0;i<4;i++) {
113 fDEDX[i] = s.fDEDX[i];
114 fSDEDX[i] = s.fSDEDX[i];
115 fNCDEDX[i] = s.fNCDEDX[i];
116 }
117 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = s.fOverlapLabels[i];
81e97e0d 118}
5c09947e 119
120
32fab534 121AliTPCseed::AliTPCseed(const AliTPCtrack &t):
122 AliTPCtrack(t),
123 fEsd(0x0),
2928bdf0 124 fClusterOwner(kFALSE),
32fab534 125 fPoints(0x0),
126 fEPoints(0x0),
127 fRow(0),
128 fSector(-1),
129 fRelativeSector(-1),
130 fCurrentSigmaY2(1e10),
131 fCurrentSigmaZ2(1e10),
132 fErrorY2(1e10),
133 fErrorZ2(1e10),
134 fCurrentCluster(0x0),
135 fCurrentClusterIndex1(-1),
136 fInDead(kFALSE),
137 fIsSeeding(kFALSE),
138 fNoCluster(0),
139 fSort(0),
140 fBSigned(kFALSE),
141 fSeedType(0),
142 fSeed1(-1),
143 fSeed2(-1),
144 fMAngular(0),
145 fCircular(0)
146{
81e97e0d 147 //
32fab534 148 // Constructor from AliTPCtrack
149 //
150 fFirstPoint =0;
105b1b81 151 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
81e97e0d 152 for (Int_t i=0;i<160;i++) {
153 fClusterPointer[i] = 0;
154 Int_t index = t.GetClusterIndex(i);
155 if (index>=-1){
156 SetClusterIndex2(i,index);
157 }
158 else{
159 SetClusterIndex2(i,-3);
160 }
161 }
32fab534 162 for (Int_t i=0;i<4;i++) {
163 fDEDX[i] = 0.;
164 fSDEDX[i] = 1e10;
165 fNCDEDX[i] = 0;
166 }
167 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
81e97e0d 168}
169
32fab534 170AliTPCseed::AliTPCseed(UInt_t index, const Double_t xx[5],
171 const Double_t cc[15],
172 Double_t xr, Double_t alpha):
173 AliTPCtrack(index, xx, cc, xr, alpha),
174 fEsd(0x0),
2928bdf0 175 fClusterOwner(kFALSE),
32fab534 176 fPoints(0x0),
177 fEPoints(0x0),
178 fRow(0),
179 fSector(-1),
180 fRelativeSector(-1),
181 fCurrentSigmaY2(1e10),
182 fCurrentSigmaZ2(1e10),
183 fErrorY2(1e10),
184 fErrorZ2(1e10),
185 fCurrentCluster(0x0),
186 fCurrentClusterIndex1(-1),
187 fInDead(kFALSE),
188 fIsSeeding(kFALSE),
189 fNoCluster(0),
190 fSort(0),
191 fBSigned(kFALSE),
192 fSeedType(0),
193 fSeed1(-1),
194 fSeed2(-1),
195 fMAngular(0),
196 fCircular(0)
197{
198 //
199 // Constructor
81e97e0d 200 //
32fab534 201 fFirstPoint =0;
5c09947e 202 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
81e97e0d 203 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
81e97e0d 204 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
32fab534 205 for (Int_t i=0;i<4;i++) {
206 fDEDX[i] = 0.;
207 fSDEDX[i] = 1e10;
208 fNCDEDX[i] = 0;
209 }
210 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
81e97e0d 211}
212
213AliTPCseed::~AliTPCseed(){
214 //
215 // destructor
216 if (fPoints) delete fPoints;
217 fPoints =0;
218 if (fEPoints) delete fEPoints;
219 fEPoints = 0;
220 fNoCluster =0;
2928bdf0 221 if (fClusterOwner){
222 for (Int_t icluster=0; icluster<160; icluster++){
223 delete fClusterPointer[icluster];
224 }
225 }
81e97e0d 226}
227
228AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
229{
230 //
231 //
232 return &fTrackPoints[i];
233}
234
235void AliTPCseed::RebuildSeed()
236{
237 //
238 // rebuild seed to be ready for storing
239 AliTPCclusterMI cldummy;
240 cldummy.SetQ(0);
241 AliTPCTrackPoint pdummy;
242 pdummy.GetTPoint().fIsShared = 10;
243 for (Int_t i=0;i<160;i++){
244 AliTPCclusterMI * cl0 = fClusterPointer[i];
245 AliTPCTrackPoint *trpoint = (AliTPCTrackPoint*)fPoints->UncheckedAt(i);
246 if (cl0){
247 trpoint->GetTPoint() = *(GetTrackPoint(i));
248 trpoint->GetCPoint() = *cl0;
249 trpoint->GetCPoint().SetQ(TMath::Abs(cl0->GetQ()));
250 }
251 else{
252 *trpoint = pdummy;
253 trpoint->GetCPoint()= cldummy;
254 }
255
256 }
257
258}
259
260
261Double_t AliTPCseed::GetDensityFirst(Int_t n)
262{
263 //
264 //
265 // return cluster for n rows bellow first point
266 Int_t nfoundable = 1;
267 Int_t nfound = 1;
268 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
269 Int_t index = GetClusterIndex2(i);
270 if (index!=-1) nfoundable++;
271 if (index>0) nfound++;
272 }
273 if (nfoundable<n) return 0;
274 return Double_t(nfound)/Double_t(nfoundable);
275
276}
277
278
279void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
280{
281 // get cluster stat. on given region
282 //
283 found = 0;
284 foundable = 0;
285 shared =0;
286 for (Int_t i=first;i<last; i++){
287 Int_t index = GetClusterIndex2(i);
288 if (index!=-1) foundable++;
289 if (fClusterPointer[i]) {
290 found++;
291 }
292 else
293 continue;
294
295 if (fClusterPointer[i]->IsUsed(10)) {
296 shared++;
297 continue;
298 }
299 if (!plus2) continue; //take also neighborhoud
300 //
301 if ( (i>0) && fClusterPointer[i-1]){
302 if (fClusterPointer[i-1]->IsUsed(10)) {
303 shared++;
304 continue;
305 }
306 }
307 if ( fClusterPointer[i+1]){
308 if (fClusterPointer[i+1]->IsUsed(10)) {
309 shared++;
310 continue;
311 }
312 }
313
314 }
315 //if (shared>found){
316 //Error("AliTPCseed::GetClusterStatistic","problem\n");
317 //}
318}
319
320
321
322
323
324void AliTPCseed::Reset(Bool_t all)
325{
326 //
327 //
328 SetNumberOfClusters(0);
329 fNFoundable = 0;
330 SetChi2(0);
331 ResetCovariance();
332 /*
333 if (fTrackPoints){
334 for (Int_t i=0;i<8;i++){
335 delete [] fTrackPoints[i];
336 }
337 delete fTrackPoints;
338 fTrackPoints =0;
339 }
340 */
341
342 if (all){
343 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
344 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
345 }
346
347}
348
349
350void AliTPCseed::Modify(Double_t factor)
351{
352
353 //------------------------------------------------------------------
354 //This function makes a track forget its history :)
355 //------------------------------------------------------------------
356 if (factor<=0) {
357 ResetCovariance();
358 return;
359 }
360 fC00*=factor;
361 fC10*=0; fC11*=factor;
362 fC20*=0; fC21*=0; fC22*=factor;
363 fC30*=0; fC31*=0; fC32*=0; fC33*=factor;
364 fC40*=0; fC41*=0; fC42*=0; fC43*=0; fC44*=factor;
365 SetNumberOfClusters(0);
366 fNFoundable =0;
367 SetChi2(0);
368 fRemoval = 0;
369 fCurrentSigmaY2 = 0.000005;
370 fCurrentSigmaZ2 = 0.000005;
371 fNoCluster = 0;
372 //fFirstPoint = 160;
373 //fLastPoint = 0;
374}
375
376
377
378
379Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
380{
381 //-----------------------------------------------------------------
382 // This function find proloncation of a track to a reference plane x=xk.
383 // doesn't change internal state of the track
384 //-----------------------------------------------------------------
385
386 Double_t x1=fX, x2=x1+(xk-x1), dx=x2-x1;
387
3f82c4f2 388 if (TMath::Abs(fP4*xk - fP2) >= AliTPCReconstructor::GetMaxSnpTrack()) {
81e97e0d 389 return 0;
390 }
391
392 // Double_t y1=fP0, z1=fP1;
393 Double_t c1=fP4*x1 - fP2, r1=sqrt(1.- c1*c1);
394 Double_t c2=fP4*x2 - fP2, r2=sqrt(1.- c2*c2);
395
396 y = fP0;
397 z = fP1;
398 //y += dx*(c1+c2)/(r1+r2);
399 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
400
401 Double_t dy = dx*(c1+c2)/(r1+r2);
402 Double_t dz = 0;
403 //
404 Double_t delta = fP4*dx*(c1+c2)/(c1*r2 + c2*r1);
405 /*
406 if (TMath::Abs(delta)>0.0001){
407 dz = fP3*TMath::ASin(delta)/fP4;
408 }else{
409 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
410 }
411 */
412 // dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
413 dz = fP3*TMath::ASin(delta)/fP4;
414 //
415 y+=dy;
416 z+=dz;
417
418
419 return 1;
420}
421
422
423//_____________________________________________________________________________
af32720d 424Double_t AliTPCseed::GetPredictedChi2(const AliCluster *c) const
81e97e0d 425{
426 //-----------------------------------------------------------------
427 // This function calculates a predicted chi2 increment.
428 //-----------------------------------------------------------------
429 //Double_t r00=c->GetSigmaY2(), r01=0., r11=c->GetSigmaZ2();
430 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
431 r00+=fC00; r01+=fC10; r11+=fC11;
432
433 Double_t det=r00*r11 - r01*r01;
434 if (TMath::Abs(det) < 1.e-10) {
435 //Int_t n=GetNumberOfClusters();
436 //if (n>4) cerr<<n<<" AliKalmanTrack warning: Singular matrix !\n";
437 return 1e10;
438 }
439 Double_t tmp=r00; r00=r11; r11=tmp; r01=-r01;
440
441 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
442
443 return (dy*r00*dy + 2*r01*dy*dz + dz*r11*dz)/det;
444}
445
446
447//_________________________________________________________________________________________
448
449
450Int_t AliTPCseed::Compare(const TObject *o) const {
451 //-----------------------------------------------------------------
452 // This function compares tracks according to the sector - for given sector according z
453 //-----------------------------------------------------------------
454 AliTPCseed *t=(AliTPCseed*)o;
455
456 if (fSort == 0){
457 if (t->fRelativeSector>fRelativeSector) return -1;
458 if (t->fRelativeSector<fRelativeSector) return 1;
459 Double_t z2 = t->GetZ();
460 Double_t z1 = GetZ();
461 if (z2>z1) return 1;
462 if (z2<z1) return -1;
463 return 0;
464 }
465 else {
466 Float_t f2 =1;
467 f2 = 1-20*TMath::Sqrt(t->fC44)/(TMath::Abs(t->GetC())+0.0066);
468 if (t->fBConstrain) f2=1.2;
469
470 Float_t f1 =1;
471 f1 = 1-20*TMath::Sqrt(fC44)/(TMath::Abs(GetC())+0.0066);
472
473 if (fBConstrain) f1=1.2;
474
475 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
476 else return +1;
477 }
478}
479
480
481
482
483//_____________________________________________________________________________
af32720d 484Int_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, UInt_t /*index*/) {
81e97e0d 485 //-----------------------------------------------------------------
486 // This function associates a cluster with this track.
487 //-----------------------------------------------------------------
488 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
489
490 r00+=fC00; r01+=fC10; r11+=fC11;
491 Double_t det=r00*r11 - r01*r01;
492 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
493
494 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
495 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
496 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
497 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
498 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
499
500 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
501 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
3f82c4f2 502 if (TMath::Abs(cur*fX-eta) >= AliTPCReconstructor::GetMaxSnpTrack()) {
81e97e0d 503 return 0;
504 }
505
506 fP0 += k00*dy + k01*dz;
507 fP1 += k10*dy + k11*dz;
508 fP2 = eta;
509 fP3 += k30*dy + k31*dz;
510 fP4 = cur;
511
512 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
513 Double_t c12=fC21, c13=fC31, c14=fC41;
514
515 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
516 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
517 fC40-=k00*c04+k01*c14;
518
519 fC11-=k10*c01+k11*fC11;
520 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
521 fC41-=k10*c04+k11*c14;
522
523 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
524 fC42-=k20*c04+k21*c14;
525
526 fC33-=k30*c03+k31*c13;
527 fC43-=k40*c03+k41*c13;
528
529 fC44-=k40*c04+k41*c14;
530
531 Int_t n=GetNumberOfClusters();
532 // fIndex[n]=index;
533 SetNumberOfClusters(n+1);
534 SetChi2(GetChi2()+chisq);
535
536 return 1;
537}
538
539
540
541//_____________________________________________________________________________
105b1b81 542Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
81e97e0d 543 //-----------------------------------------------------------------
544 // This funtion calculates dE/dX within the "low" and "up" cuts.
545 //-----------------------------------------------------------------
546
547 Float_t amp[200];
548 Float_t angular[200];
549 Float_t weight[200];
550 Int_t index[200];
551 //Int_t nc = 0;
552 // TClonesArray & arr = *fPoints;
553 Float_t meanlog = 100.;
554
555 Float_t mean[4] = {0,0,0,0};
556 Float_t sigma[4] = {1000,1000,1000,1000};
557 Int_t nc[4] = {0,0,0,0};
558 Float_t norm[4] = {1000,1000,1000,1000};
559 //
560 //
561 fNShared =0;
562
563 for (Int_t of =0; of<4; of++){
564 for (Int_t i=of+i1;i<i2;i+=4)
565 {
566 Int_t index = fIndex[i];
567 if (index<0||index&0x8000) continue;
568
569 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
570 AliTPCTrackerPoint * point = GetTrackPoint(i);
571 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
572 //AliTPCTrackerPoint * pointp = 0;
573 //if (i<159) pointp = GetTrackPoint(i+1);
574
575 if (point==0) continue;
576 AliTPCclusterMI * cl = fClusterPointer[i];
577 if (cl==0) continue;
578 if (onlyused && (!cl->IsUsed(10))) continue;
579 if (cl->IsUsed(11)) {
580 fNShared++;
581 continue;
582 }
583 Int_t type = cl->GetType();
584 //if (point->fIsShared){
585 // fNShared++;
586 // continue;
587 //}
588 //if (pointm)
589 // if (pointm->fIsShared) continue;
590 //if (pointp)
591 // if (pointp->fIsShared) continue;
592
593 if (type<0) continue;
594 //if (type>10) continue;
595 //if (point->GetErrY()==0) continue;
596 //if (point->GetErrZ()==0) continue;
597
598 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
599 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
600 //if ((ddy*ddy+ddz*ddz)>10) continue;
601
602
603 // if (point->GetCPoint().GetMax()<5) continue;
604 if (cl->GetMax()<5) continue;
605 Float_t angley = point->GetAngleY();
606 Float_t anglez = point->GetAngleZ();
607
608 Float_t rsigmay2 = point->GetSigmaY();
609 Float_t rsigmaz2 = point->GetSigmaZ();
610 /*
611 Float_t ns = 1.;
612 if (pointm){
613 rsigmay += pointm->GetTPoint().GetSigmaY();
614 rsigmaz += pointm->GetTPoint().GetSigmaZ();
615 ns+=1.;
616 }
617 if (pointp){
618 rsigmay += pointp->GetTPoint().GetSigmaY();
619 rsigmaz += pointp->GetTPoint().GetSigmaZ();
620 ns+=1.;
621 }
622 rsigmay/=ns;
623 rsigmaz/=ns;
624 */
625
626 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
627
628 Float_t ampc = 0; // normalization to the number of electrons
629 if (i>64){
630 // ampc = 1.*point->GetCPoint().GetMax();
631 ampc = 1.*cl->GetMax();
632 //ampc = 1.*point->GetCPoint().GetQ();
633 // AliTPCClusterPoint & p = point->GetCPoint();
634 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
635 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
636 //Float_t dz =
637 // TMath::Abs( Int_t(iz) - iz + 0.5);
638 //ampc *= 1.15*(1-0.3*dy);
639 //ampc *= 1.15*(1-0.3*dz);
640 // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
641 //ampc *=zfactor;
642 }
643 else{
644 //ampc = 1.0*point->GetCPoint().GetMax();
645 ampc = 1.0*cl->GetMax();
646 //ampc = 1.0*point->GetCPoint().GetQ();
647 //AliTPCClusterPoint & p = point->GetCPoint();
648 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
649 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
650 //Float_t dz =
651 // TMath::Abs( Int_t(iz) - iz + 0.5);
652
653 //ampc *= 1.15*(1-0.3*dy);
654 //ampc *= 1.15*(1-0.3*dz);
655 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
656 //ampc *=zfactor;
657
658 }
659 ampc *= 2.0; // put mean value to channel 50
660 //ampc *= 0.58; // put mean value to channel 50
661 Float_t w = 1.;
662 // if (type>0) w = 1./(type/2.-0.5);
663 // Float_t z = TMath::Abs(cl->GetZ());
664 if (i<64) {
665 ampc /= 0.6;
666 //ampc /= (1+0.0008*z);
667 } else
668 if (i>128){
669 ampc /=1.5;
670 //ampc /= (1+0.0008*z);
671 }else{
672 //ampc /= (1+0.0008*z);
673 }
674
675 if (type<0) { //amp at the border - lower weight
676 // w*= 2.;
677
678 continue;
679 }
680 if (rsigma>1.5) ampc/=1.3; // if big backround
681 amp[nc[of]] = ampc;
682 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
683 weight[nc[of]] = w;
684 nc[of]++;
685 }
686
687 TMath::Sort(nc[of],amp,index,kFALSE);
688 Float_t sumamp=0;
689 Float_t sumamp2=0;
690 Float_t sumw=0;
691 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
692 meanlog = 50;
693 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
694 Float_t ampl = amp[index[i]]/angular[index[i]];
695 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
696 //
697 sumw += weight[index[i]];
698 sumamp += weight[index[i]]*ampl;
699 sumamp2 += weight[index[i]]*ampl*ampl;
700 norm[of] += angular[index[i]]*weight[index[i]];
701 }
702 if (sumw<1){
703 SetdEdx(0);
704 }
705 else {
706 norm[of] /= sumw;
707 mean[of] = sumamp/sumw;
708 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
709 if (sigma[of]>0.1)
710 sigma[of] = TMath::Sqrt(sigma[of]);
711 else
712 sigma[of] = 1000;
713
714 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
715 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
716 //mean *=(1-0.1*(norm-1.));
717 }
718 }
719
720 Float_t dedx =0;
721 fSdEdx =0;
722 fMAngular =0;
723 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
724 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
725
726
727 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
728 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
729
730 Int_t norm2 = 0;
731 Int_t norm3 = 0;
732 for (Int_t i =0;i<4;i++){
733 if (nc[i]>2&&nc[i]<1000){
734 dedx += mean[i] *nc[i];
735 fSdEdx += sigma[i]*(nc[i]-2);
736 fMAngular += norm[i] *nc[i];
737 norm2 += nc[i];
738 norm3 += nc[i]-2;
739 }
740 fDEDX[i] = mean[i];
741 fSDEDX[i] = sigma[i];
742 fNCDEDX[i]= nc[i];
743 }
744
745 if (norm3>0){
746 dedx /=norm2;
747 fSdEdx /=norm3;
748 fMAngular/=norm2;
749 }
750 else{
751 SetdEdx(0);
105b1b81 752 return 0;
81e97e0d 753 }
754 // Float_t dedx1 =dedx;
755 /*
756 dedx =0;
757 for (Int_t i =0;i<4;i++){
758 if (nc[i]>2&&nc[i]<1000){
759 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
760 dedx += mean[i] *nc[i];
761 }
762 fDEDX[i] = mean[i];
763 }
764 dedx /= norm2;
765 */
766
767
768 SetdEdx(dedx);
a2d457f2 769 return dedx;
81e97e0d 770}
771Double_t AliTPCseed::Bethe(Double_t bg){
772 //
773 // This is the Bethe-Bloch function normalised to 1 at the minimum
774 //
775 Double_t bg2=bg*bg;
776 Double_t bethe;
777 if (bg<3.5e1)
778 bethe=(1.+ bg2)/bg2*(log(5940*bg2) - bg2/(1.+ bg2));
779 else // Density effect ( approximately :)
780 bethe=1.15*(1.+ bg2)/bg2*(log(3.5*5940*bg) - bg2/(1.+ bg2));
781 return bethe/11.091;
782}
783
784void AliTPCseed::CookPID()
785{
786 //
787 // cook PID information according dEdx
788 //
789 Double_t fRange = 10.;
790 Double_t fRes = 0.1;
791 Double_t fMIP = 47.;
792 //
793 Int_t ns=AliPID::kSPECIES;
794 Double_t sumr =0;
795 for (Int_t j=0; j<ns; j++) {
796 Double_t mass=AliPID::ParticleMass(j);
797 Double_t mom=P();
798 Double_t dedx=fdEdx/fMIP;
799 Double_t bethe=Bethe(mom/mass);
800 Double_t sigma=fRes*bethe;
801 if (sigma>0.001){
802 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
803 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
804 sumr+=fTPCr[j];
805 continue;
806 }
807 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
808 sumr+=fTPCr[j];
809 }
810 else{
811 fTPCr[j]=1.;
812 sumr+=fTPCr[j];
813 }
814 }
815 for (Int_t j=0; j<ns; j++) {
816 fTPCr[j]/=sumr; //normalize
817 }
818}
819
820/*
821void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
822 //-----------------------------------------------------------------
823 // This funtion calculates dE/dX within the "low" and "up" cuts.
824 //-----------------------------------------------------------------
825
826 Float_t amp[200];
827 Float_t angular[200];
828 Float_t weight[200];
829 Int_t index[200];
830 Bool_t inlimit[200];
831 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
832 for (Int_t i=0;i<200;i++) amp[i]=10000;
833 for (Int_t i=0;i<200;i++) angular[i]= 1;;
834
835
836 //
837 Float_t meanlog = 100.;
838 Int_t indexde[4]={0,64,128,160};
839
840 Float_t amean =0;
841 Float_t asigma =0;
842 Float_t anc =0;
843 Float_t anorm =0;
844
845 Float_t mean[4] = {0,0,0,0};
846 Float_t sigma[4] = {1000,1000,1000,1000};
847 Int_t nc[4] = {0,0,0,0};
848 Float_t norm[4] = {1000,1000,1000,1000};
849 //
850 //
851 fNShared =0;
852
853 // for (Int_t of =0; of<3; of++){
854 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
855 for (Int_t i =0; i<160;i++)
856 {
857 AliTPCTrackPoint * point = GetTrackPoint(i);
858 if (point==0) continue;
859 if (point->fIsShared){
860 fNShared++;
861 continue;
862 }
863 Int_t type = point->GetCPoint().GetType();
864 if (type<0) continue;
865 if (point->GetCPoint().GetMax()<5) continue;
866 Float_t angley = point->GetTPoint().GetAngleY();
867 Float_t anglez = point->GetTPoint().GetAngleZ();
868 Float_t rsigmay = point->GetCPoint().GetSigmaY();
869 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
870 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
871
872 Float_t ampc = 0; // normalization to the number of electrons
873 if (i>64){
874 ampc = point->GetCPoint().GetMax();
875 }
876 else{
877 ampc = point->GetCPoint().GetMax();
878 }
879 ampc *= 2.0; // put mean value to channel 50
880 // ampc *= 0.565; // put mean value to channel 50
881
882 Float_t w = 1.;
883 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
884 if (i<64) {
885 ampc /= 0.63;
886 } else
887 if (i>128){
888 ampc /=1.51;
889 }
890 if (type<0) { //amp at the border - lower weight
891 continue;
892 }
893 if (rsigma>1.5) ampc/=1.3; // if big backround
894 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
895 amp[i] = ampc/angular[i];
896 weight[i] = w;
897 anc++;
898 }
899
900 TMath::Sort(159,amp,index,kFALSE);
901 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
902 inlimit[index[i]] = kTRUE; // take all clusters
903 }
904
905 // meanlog = amp[index[Int_t(anc*0.3)]];
906 meanlog =10000.;
907 for (Int_t of =0; of<3; of++){
908 Float_t sumamp=0;
909 Float_t sumamp2=0;
910 Float_t sumw=0;
911 for (Int_t i=indexde[of];i<indexde[of+1];i++)
912 {
913 if (inlimit[i]==kFALSE) continue;
914 Float_t ampl = amp[i];
915 ///angular[i];
916 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
917 //
918 sumw += weight[i];
919 sumamp += weight[i]*ampl;
920 sumamp2 += weight[i]*ampl*ampl;
921 norm[of] += angular[i]*weight[i];
922 nc[of]++;
923 }
924 if (sumw<1){
925 SetdEdx(0);
926 }
927 else {
928 norm[of] /= sumw;
929 mean[of] = sumamp/sumw;
930 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
931 if (sigma[of]>0.1)
932 sigma[of] = TMath::Sqrt(sigma[of]);
933 else
934 sigma[of] = 1000;
935 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
936 }
937 }
938
939 Float_t dedx =0;
940 fSdEdx =0;
941 fMAngular =0;
942 //
943 Int_t norm2 = 0;
944 Int_t norm3 = 0;
945 Float_t www[3] = {12.,14.,17.};
946 //Float_t www[3] = {1.,1.,1.};
947
948 for (Int_t i =0;i<3;i++){
949 if (nc[i]>2&&nc[i]<1000){
950 dedx += mean[i] *nc[i]*www[i]/sigma[i];
951 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
952 fMAngular += norm[i] *nc[i];
953 norm2 += nc[i]*www[i]/sigma[i];
954 norm3 += (nc[i]-2)*www[i]/sigma[i];
955 }
956 fDEDX[i] = mean[i];
957 fSDEDX[i] = sigma[i];
958 fNCDEDX[i]= nc[i];
959 }
960
961 if (norm3>0){
962 dedx /=norm2;
963 fSdEdx /=norm3;
964 fMAngular/=norm2;
965 }
966 else{
967 SetdEdx(0);
968 return;
969 }
970 // Float_t dedx1 =dedx;
971
972 dedx =0;
973 Float_t norm4 = 0;
974 for (Int_t i =0;i<3;i++){
975 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
976 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
977 dedx += mean[i] *(nc[i])/(sigma[i]);
978 norm4 += (nc[i])/(sigma[i]);
979 }
980 fDEDX[i] = mean[i];
981 }
982 if (norm4>0) dedx /= norm4;
983
984
985
986 SetdEdx(dedx);
987
988 //mi deDX
989
990}
991*/