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