Effective C++ warnings
[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;
c2765847 455 const Double_t kfC44mean = 0.0001;
81e97e0d 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 {
c2765847 466 if (t->fC44<0){
467 AliError("Non positive covariance");
468 t->Dump();
469 return -1;
470 }
471 if (fC44<0){
472 AliError("Non positive covariance");
473 Dump();
474 return 1;
475 }
476 //
81e97e0d 477 Float_t f2 =1;
c2765847 478 f2 = 1./(kfC44mean+TMath::Sqrt(TMath::Abs(t->fC44)));
81e97e0d 479 if (t->fBConstrain) f2=1.2;
480
481 Float_t f1 =1;
c2765847 482 f1 = 1./(kfC44mean+TMath::Sqrt(TMath::Abs(fC44)));
81e97e0d 483
484 if (fBConstrain) f1=1.2;
485
486 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
487 else return +1;
488 }
489}
490
491
492
493
494//_____________________________________________________________________________
af32720d 495Int_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, UInt_t /*index*/) {
81e97e0d 496 //-----------------------------------------------------------------
497 // This function associates a cluster with this track.
498 //-----------------------------------------------------------------
499 Double_t r00=fErrorY2, r01=0., r11=fErrorZ2;
500
501 r00+=fC00; r01+=fC10; r11+=fC11;
502 Double_t det=r00*r11 - r01*r01;
503 Double_t tmp=r00; r00=r11/det; r11=tmp/det; r01=-r01/det;
504
505 Double_t k00=fC00*r00+fC10*r01, k01=fC00*r01+fC10*r11;
506 Double_t k10=fC10*r00+fC11*r01, k11=fC10*r01+fC11*r11;
507 Double_t k20=fC20*r00+fC21*r01, k21=fC20*r01+fC21*r11;
508 Double_t k30=fC30*r00+fC31*r01, k31=fC30*r01+fC31*r11;
509 Double_t k40=fC40*r00+fC41*r01, k41=fC40*r01+fC41*r11;
510
511 Double_t dy=c->GetY() - fP0, dz=c->GetZ() - fP1;
512 Double_t cur=fP4 + k40*dy + k41*dz, eta=fP2 + k20*dy + k21*dz;
3f82c4f2 513 if (TMath::Abs(cur*fX-eta) >= AliTPCReconstructor::GetMaxSnpTrack()) {
81e97e0d 514 return 0;
515 }
516
517 fP0 += k00*dy + k01*dz;
518 fP1 += k10*dy + k11*dz;
519 fP2 = eta;
520 fP3 += k30*dy + k31*dz;
521 fP4 = cur;
522
523 Double_t c01=fC10, c02=fC20, c03=fC30, c04=fC40;
524 Double_t c12=fC21, c13=fC31, c14=fC41;
525
526 fC00-=k00*fC00+k01*fC10; fC10-=k00*c01+k01*fC11;
527 fC20-=k00*c02+k01*c12; fC30-=k00*c03+k01*c13;
528 fC40-=k00*c04+k01*c14;
529
530 fC11-=k10*c01+k11*fC11;
531 fC21-=k10*c02+k11*c12; fC31-=k10*c03+k11*c13;
532 fC41-=k10*c04+k11*c14;
533
534 fC22-=k20*c02+k21*c12; fC32-=k20*c03+k21*c13;
535 fC42-=k20*c04+k21*c14;
536
537 fC33-=k30*c03+k31*c13;
538 fC43-=k40*c03+k41*c13;
539
540 fC44-=k40*c04+k41*c14;
541
542 Int_t n=GetNumberOfClusters();
543 // fIndex[n]=index;
544 SetNumberOfClusters(n+1);
545 SetChi2(GetChi2()+chisq);
546
547 return 1;
548}
549
550
551
552//_____________________________________________________________________________
105b1b81 553Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
81e97e0d 554 //-----------------------------------------------------------------
555 // This funtion calculates dE/dX within the "low" and "up" cuts.
556 //-----------------------------------------------------------------
557
558 Float_t amp[200];
559 Float_t angular[200];
560 Float_t weight[200];
561 Int_t index[200];
562 //Int_t nc = 0;
563 // TClonesArray & arr = *fPoints;
564 Float_t meanlog = 100.;
565
566 Float_t mean[4] = {0,0,0,0};
567 Float_t sigma[4] = {1000,1000,1000,1000};
568 Int_t nc[4] = {0,0,0,0};
569 Float_t norm[4] = {1000,1000,1000,1000};
570 //
571 //
572 fNShared =0;
573
574 for (Int_t of =0; of<4; of++){
575 for (Int_t i=of+i1;i<i2;i+=4)
576 {
577 Int_t index = fIndex[i];
578 if (index<0||index&0x8000) continue;
579
580 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
581 AliTPCTrackerPoint * point = GetTrackPoint(i);
582 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
583 //AliTPCTrackerPoint * pointp = 0;
584 //if (i<159) pointp = GetTrackPoint(i+1);
585
586 if (point==0) continue;
587 AliTPCclusterMI * cl = fClusterPointer[i];
588 if (cl==0) continue;
589 if (onlyused && (!cl->IsUsed(10))) continue;
590 if (cl->IsUsed(11)) {
591 fNShared++;
592 continue;
593 }
594 Int_t type = cl->GetType();
595 //if (point->fIsShared){
596 // fNShared++;
597 // continue;
598 //}
599 //if (pointm)
600 // if (pointm->fIsShared) continue;
601 //if (pointp)
602 // if (pointp->fIsShared) continue;
603
604 if (type<0) continue;
605 //if (type>10) continue;
606 //if (point->GetErrY()==0) continue;
607 //if (point->GetErrZ()==0) continue;
608
609 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
610 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
611 //if ((ddy*ddy+ddz*ddz)>10) continue;
612
613
614 // if (point->GetCPoint().GetMax()<5) continue;
615 if (cl->GetMax()<5) continue;
616 Float_t angley = point->GetAngleY();
617 Float_t anglez = point->GetAngleZ();
618
619 Float_t rsigmay2 = point->GetSigmaY();
620 Float_t rsigmaz2 = point->GetSigmaZ();
621 /*
622 Float_t ns = 1.;
623 if (pointm){
624 rsigmay += pointm->GetTPoint().GetSigmaY();
625 rsigmaz += pointm->GetTPoint().GetSigmaZ();
626 ns+=1.;
627 }
628 if (pointp){
629 rsigmay += pointp->GetTPoint().GetSigmaY();
630 rsigmaz += pointp->GetTPoint().GetSigmaZ();
631 ns+=1.;
632 }
633 rsigmay/=ns;
634 rsigmaz/=ns;
635 */
636
637 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
638
639 Float_t ampc = 0; // normalization to the number of electrons
640 if (i>64){
641 // ampc = 1.*point->GetCPoint().GetMax();
642 ampc = 1.*cl->GetMax();
643 //ampc = 1.*point->GetCPoint().GetQ();
644 // AliTPCClusterPoint & p = point->GetCPoint();
645 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
646 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
647 //Float_t dz =
648 // TMath::Abs( Int_t(iz) - iz + 0.5);
649 //ampc *= 1.15*(1-0.3*dy);
650 //ampc *= 1.15*(1-0.3*dz);
651 // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
652 //ampc *=zfactor;
653 }
654 else{
655 //ampc = 1.0*point->GetCPoint().GetMax();
656 ampc = 1.0*cl->GetMax();
657 //ampc = 1.0*point->GetCPoint().GetQ();
658 //AliTPCClusterPoint & p = point->GetCPoint();
659 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
660 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
661 //Float_t dz =
662 // TMath::Abs( Int_t(iz) - iz + 0.5);
663
664 //ampc *= 1.15*(1-0.3*dy);
665 //ampc *= 1.15*(1-0.3*dz);
666 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
667 //ampc *=zfactor;
668
669 }
670 ampc *= 2.0; // put mean value to channel 50
671 //ampc *= 0.58; // put mean value to channel 50
672 Float_t w = 1.;
673 // if (type>0) w = 1./(type/2.-0.5);
674 // Float_t z = TMath::Abs(cl->GetZ());
675 if (i<64) {
676 ampc /= 0.6;
677 //ampc /= (1+0.0008*z);
678 } else
679 if (i>128){
680 ampc /=1.5;
681 //ampc /= (1+0.0008*z);
682 }else{
683 //ampc /= (1+0.0008*z);
684 }
685
686 if (type<0) { //amp at the border - lower weight
687 // w*= 2.;
688
689 continue;
690 }
691 if (rsigma>1.5) ampc/=1.3; // if big backround
692 amp[nc[of]] = ampc;
693 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
694 weight[nc[of]] = w;
695 nc[of]++;
696 }
697
698 TMath::Sort(nc[of],amp,index,kFALSE);
699 Float_t sumamp=0;
700 Float_t sumamp2=0;
701 Float_t sumw=0;
702 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
703 meanlog = 50;
704 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
705 Float_t ampl = amp[index[i]]/angular[index[i]];
706 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
707 //
708 sumw += weight[index[i]];
709 sumamp += weight[index[i]]*ampl;
710 sumamp2 += weight[index[i]]*ampl*ampl;
711 norm[of] += angular[index[i]]*weight[index[i]];
712 }
713 if (sumw<1){
714 SetdEdx(0);
715 }
716 else {
717 norm[of] /= sumw;
718 mean[of] = sumamp/sumw;
719 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
720 if (sigma[of]>0.1)
721 sigma[of] = TMath::Sqrt(sigma[of]);
722 else
723 sigma[of] = 1000;
724
725 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
726 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
727 //mean *=(1-0.1*(norm-1.));
728 }
729 }
730
731 Float_t dedx =0;
732 fSdEdx =0;
733 fMAngular =0;
734 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
735 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
736
737
738 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
739 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
740
741 Int_t norm2 = 0;
742 Int_t norm3 = 0;
743 for (Int_t i =0;i<4;i++){
744 if (nc[i]>2&&nc[i]<1000){
745 dedx += mean[i] *nc[i];
746 fSdEdx += sigma[i]*(nc[i]-2);
747 fMAngular += norm[i] *nc[i];
748 norm2 += nc[i];
749 norm3 += nc[i]-2;
750 }
751 fDEDX[i] = mean[i];
752 fSDEDX[i] = sigma[i];
753 fNCDEDX[i]= nc[i];
754 }
755
756 if (norm3>0){
757 dedx /=norm2;
758 fSdEdx /=norm3;
759 fMAngular/=norm2;
760 }
761 else{
762 SetdEdx(0);
105b1b81 763 return 0;
81e97e0d 764 }
765 // Float_t dedx1 =dedx;
766 /*
767 dedx =0;
768 for (Int_t i =0;i<4;i++){
769 if (nc[i]>2&&nc[i]<1000){
770 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
771 dedx += mean[i] *nc[i];
772 }
773 fDEDX[i] = mean[i];
774 }
775 dedx /= norm2;
776 */
777
778
779 SetdEdx(dedx);
a2d457f2 780 return dedx;
81e97e0d 781}
782Double_t AliTPCseed::Bethe(Double_t bg){
783 //
784 // This is the Bethe-Bloch function normalised to 1 at the minimum
785 //
786 Double_t bg2=bg*bg;
787 Double_t bethe;
788 if (bg<3.5e1)
789 bethe=(1.+ bg2)/bg2*(log(5940*bg2) - bg2/(1.+ bg2));
790 else // Density effect ( approximately :)
791 bethe=1.15*(1.+ bg2)/bg2*(log(3.5*5940*bg) - bg2/(1.+ bg2));
792 return bethe/11.091;
793}
794
795void AliTPCseed::CookPID()
796{
797 //
798 // cook PID information according dEdx
799 //
800 Double_t fRange = 10.;
801 Double_t fRes = 0.1;
802 Double_t fMIP = 47.;
803 //
804 Int_t ns=AliPID::kSPECIES;
805 Double_t sumr =0;
806 for (Int_t j=0; j<ns; j++) {
807 Double_t mass=AliPID::ParticleMass(j);
808 Double_t mom=P();
809 Double_t dedx=fdEdx/fMIP;
810 Double_t bethe=Bethe(mom/mass);
811 Double_t sigma=fRes*bethe;
812 if (sigma>0.001){
813 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
814 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
815 sumr+=fTPCr[j];
816 continue;
817 }
818 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
819 sumr+=fTPCr[j];
820 }
821 else{
822 fTPCr[j]=1.;
823 sumr+=fTPCr[j];
824 }
825 }
826 for (Int_t j=0; j<ns; j++) {
827 fTPCr[j]/=sumr; //normalize
828 }
829}
830
831/*
832void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
833 //-----------------------------------------------------------------
834 // This funtion calculates dE/dX within the "low" and "up" cuts.
835 //-----------------------------------------------------------------
836
837 Float_t amp[200];
838 Float_t angular[200];
839 Float_t weight[200];
840 Int_t index[200];
841 Bool_t inlimit[200];
842 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
843 for (Int_t i=0;i<200;i++) amp[i]=10000;
844 for (Int_t i=0;i<200;i++) angular[i]= 1;;
845
846
847 //
848 Float_t meanlog = 100.;
849 Int_t indexde[4]={0,64,128,160};
850
851 Float_t amean =0;
852 Float_t asigma =0;
853 Float_t anc =0;
854 Float_t anorm =0;
855
856 Float_t mean[4] = {0,0,0,0};
857 Float_t sigma[4] = {1000,1000,1000,1000};
858 Int_t nc[4] = {0,0,0,0};
859 Float_t norm[4] = {1000,1000,1000,1000};
860 //
861 //
862 fNShared =0;
863
864 // for (Int_t of =0; of<3; of++){
865 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
866 for (Int_t i =0; i<160;i++)
867 {
868 AliTPCTrackPoint * point = GetTrackPoint(i);
869 if (point==0) continue;
870 if (point->fIsShared){
871 fNShared++;
872 continue;
873 }
874 Int_t type = point->GetCPoint().GetType();
875 if (type<0) continue;
876 if (point->GetCPoint().GetMax()<5) continue;
877 Float_t angley = point->GetTPoint().GetAngleY();
878 Float_t anglez = point->GetTPoint().GetAngleZ();
879 Float_t rsigmay = point->GetCPoint().GetSigmaY();
880 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
881 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
882
883 Float_t ampc = 0; // normalization to the number of electrons
884 if (i>64){
885 ampc = point->GetCPoint().GetMax();
886 }
887 else{
888 ampc = point->GetCPoint().GetMax();
889 }
890 ampc *= 2.0; // put mean value to channel 50
891 // ampc *= 0.565; // put mean value to channel 50
892
893 Float_t w = 1.;
894 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
895 if (i<64) {
896 ampc /= 0.63;
897 } else
898 if (i>128){
899 ampc /=1.51;
900 }
901 if (type<0) { //amp at the border - lower weight
902 continue;
903 }
904 if (rsigma>1.5) ampc/=1.3; // if big backround
905 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
906 amp[i] = ampc/angular[i];
907 weight[i] = w;
908 anc++;
909 }
910
911 TMath::Sort(159,amp,index,kFALSE);
912 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
913 inlimit[index[i]] = kTRUE; // take all clusters
914 }
915
916 // meanlog = amp[index[Int_t(anc*0.3)]];
917 meanlog =10000.;
918 for (Int_t of =0; of<3; of++){
919 Float_t sumamp=0;
920 Float_t sumamp2=0;
921 Float_t sumw=0;
922 for (Int_t i=indexde[of];i<indexde[of+1];i++)
923 {
924 if (inlimit[i]==kFALSE) continue;
925 Float_t ampl = amp[i];
926 ///angular[i];
927 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
928 //
929 sumw += weight[i];
930 sumamp += weight[i]*ampl;
931 sumamp2 += weight[i]*ampl*ampl;
932 norm[of] += angular[i]*weight[i];
933 nc[of]++;
934 }
935 if (sumw<1){
936 SetdEdx(0);
937 }
938 else {
939 norm[of] /= sumw;
940 mean[of] = sumamp/sumw;
941 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
942 if (sigma[of]>0.1)
943 sigma[of] = TMath::Sqrt(sigma[of]);
944 else
945 sigma[of] = 1000;
946 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
947 }
948 }
949
950 Float_t dedx =0;
951 fSdEdx =0;
952 fMAngular =0;
953 //
954 Int_t norm2 = 0;
955 Int_t norm3 = 0;
956 Float_t www[3] = {12.,14.,17.};
957 //Float_t www[3] = {1.,1.,1.};
958
959 for (Int_t i =0;i<3;i++){
960 if (nc[i]>2&&nc[i]<1000){
961 dedx += mean[i] *nc[i]*www[i]/sigma[i];
962 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
963 fMAngular += norm[i] *nc[i];
964 norm2 += nc[i]*www[i]/sigma[i];
965 norm3 += (nc[i]-2)*www[i]/sigma[i];
966 }
967 fDEDX[i] = mean[i];
968 fSDEDX[i] = sigma[i];
969 fNCDEDX[i]= nc[i];
970 }
971
972 if (norm3>0){
973 dedx /=norm2;
974 fSdEdx /=norm3;
975 fMAngular/=norm2;
976 }
977 else{
978 SetdEdx(0);
979 return;
980 }
981 // Float_t dedx1 =dedx;
982
983 dedx =0;
984 Float_t norm4 = 0;
985 for (Int_t i =0;i<3;i++){
986 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
987 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
988 dedx += mean[i] *(nc[i])/(sigma[i]);
989 norm4 += (nc[i])/(sigma[i]);
990 }
991 fDEDX[i] = mean[i];
992 }
993 if (norm4>0) dedx /= norm4;
994
995
996
997 SetdEdx(dedx);
998
999 //mi deDX
1000
1001}
1002*/