1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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 #include "AliTPCClusterParam.h"
28 #include "AliTPCCalPad.h"
29 #include "AliTPCCalROC.h"
30 #include "AliTPCcalibDB.h"
38 AliTPCseed::AliTPCseed():
41 fClusterOwner(kFALSE),
45 fCurrentSigmaY2(1e10),
46 fCurrentSigmaZ2(1e10),
47 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
48 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
49 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
50 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
55 fCurrentClusterIndex1(-1),
70 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
71 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
72 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=0;
73 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0.2;
74 for (Int_t i=0;i<4;i++) {
79 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
80 // for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
81 //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
82 fClusterMap.ResetAllBits(kFALSE);
83 fSharedMap.ResetAllBits(kFALSE);
87 AliTPCseed::AliTPCseed(const AliTPCseed &s, Bool_t clusterOwner):
90 fClusterOwner(clusterOwner),
96 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
97 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
98 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
99 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
102 fCurrentCluster(0x0),
103 fCurrentClusterIndex1(-1),
114 fClusterMap(s.fClusterMap),
115 fSharedMap(s.fSharedMap)
117 //---------------------
118 // dummy copy constructor
119 //-------------------------
120 for (Int_t i=0;i<160;i++) {
121 fClusterPointer[i]=0;
123 if (s.fClusterPointer[i])
124 fClusterPointer[i] = new AliTPCclusterMI(*(s.fClusterPointer[i]));
126 fClusterPointer[i] = s.fClusterPointer[i];
128 fTrackPoints[i] = s.fTrackPoints[i];
130 for (Int_t i=0;i<160;i++) fIndex[i] = s.fIndex[i];
131 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=s.fTPCr[i];
132 for (Int_t i=0;i<4;i++) {
133 fDEDX[i] = s.fDEDX[i];
134 fSDEDX[i] = s.fSDEDX[i];
135 fNCDEDX[i] = s.fNCDEDX[i];
137 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = s.fOverlapLabels[i];
142 AliTPCseed::AliTPCseed(const AliTPCtrack &t):
145 fClusterOwner(kFALSE),
151 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
152 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
153 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
154 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
157 fCurrentCluster(0x0),
158 fCurrentClusterIndex1(-1),
173 // Constructor from AliTPCtrack
176 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
177 for (Int_t i=0;i<160;i++) {
178 fClusterPointer[i] = 0;
179 Int_t index = t.GetClusterIndex(i);
181 SetClusterIndex2(i,index);
184 SetClusterIndex2(i,-3);
187 for (Int_t i=0;i<4;i++) {
192 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
194 //for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
195 //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
196 fClusterMap.ResetAllBits(kFALSE);
197 fSharedMap.ResetAllBits(kFALSE);
201 AliTPCseed::AliTPCseed(Double_t xr, Double_t alpha, const Double_t xx[5],
202 const Double_t cc[15], Int_t index):
203 AliTPCtrack(xr, alpha, xx, cc, index),
205 fClusterOwner(kFALSE),
211 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
212 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
213 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
214 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
217 fCurrentCluster(0x0),
218 fCurrentClusterIndex1(-1),
236 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
237 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
238 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
239 for (Int_t i=0;i<4;i++) {
244 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
247 AliTPCseed::~AliTPCseed(){
252 for (Int_t icluster=0; icluster<160; icluster++){
253 delete fClusterPointer[icluster];
258 //_________________________________________________
259 AliTPCseed & AliTPCseed::operator=(const AliTPCseed ¶m)
262 // assignment operator
265 AliTPCtrack::operator=(param);
267 for(Int_t i = 0;i<160;++i)fClusterPointer[i] = param.fClusterPointer[i]; // this is not allocated by AliTPCSeed
268 fClusterOwner = param.fClusterOwner;
269 // leave out fPoint, they are also not copied in the copy ctor...
270 // but deleted in the dtor... strange...
272 fSector = param.fSector;
273 fRelativeSector = param.fRelativeSector;
274 fCurrentSigmaY2 = param.fCurrentSigmaY2;
275 fCurrentSigmaZ2 = param.fCurrentSigmaZ2;
276 fErrorY2 = param.fErrorY2;
277 fErrorZ2 = param.fErrorZ2;
278 fCurrentCluster = param.fCurrentCluster; // this is not allocated by AliTPCSeed
279 fCurrentClusterIndex1 = param.fCurrentClusterIndex1;
280 fInDead = param.fInDead;
281 fIsSeeding = param.fIsSeeding;
282 fNoCluster = param.fNoCluster;
284 fBSigned = param.fBSigned;
285 for(Int_t i = 0;i<4;++i){
286 fDEDX[i] = param.fDEDX[i];
287 fSDEDX[i] = param.fSDEDX[i];
288 fNCDEDX[i] = param.fNCDEDX[i];
290 for(Int_t i = 0;i<AliPID::kSPECIES;++i)fTPCr[i] = param.fTPCr[i];
292 fSeedType = param.fSeedType;
293 fSeed1 = param.fSeed1;
294 fSeed2 = param.fSeed2;
295 for(Int_t i = 0;i<12;++i)fOverlapLabels[i] = param.fOverlapLabels[i];
296 fMAngular = param.fMAngular;
297 fCircular = param.fCircular;
298 for(int i = 0;i<160;++i)fTrackPoints[i] = param.fTrackPoints[i];
299 fClusterMap = param.fClusterMap;
300 fSharedMap = param.fSharedMap;
304 //____________________________________________________
305 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
309 return &fTrackPoints[i];
314 Double_t AliTPCseed::GetDensityFirst(Int_t n)
318 // return cluster for n rows bellow first point
319 Int_t nfoundable = 1;
321 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
322 Int_t index = GetClusterIndex2(i);
323 if (index!=-1) nfoundable++;
324 if (index>0) nfound++;
326 if (nfoundable<n) return 0;
327 return Double_t(nfound)/Double_t(nfoundable);
332 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
334 // get cluster stat. on given region
339 for (Int_t i=first;i<last; i++){
340 Int_t index = GetClusterIndex2(i);
341 if (index!=-1) foundable++;
342 if (index&0x8000) continue;
343 if (fClusterPointer[i]) {
349 if (fClusterPointer[i]->IsUsed(10)) {
353 if (!plus2) continue; //take also neighborhoud
355 if ( (i>0) && fClusterPointer[i-1]){
356 if (fClusterPointer[i-1]->IsUsed(10)) {
361 if ( fClusterPointer[i+1]){
362 if (fClusterPointer[i+1]->IsUsed(10)) {
370 //Error("AliTPCseed::GetClusterStatistic","problem\n");
378 void AliTPCseed::Reset(Bool_t all)
382 SetNumberOfClusters(0);
385 ResetCovariance(10.);
388 for (Int_t i=0;i<8;i++){
389 delete [] fTrackPoints[i];
397 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
398 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
404 void AliTPCseed::Modify(Double_t factor)
407 //------------------------------------------------------------------
408 //This function makes a track forget its history :)
409 //------------------------------------------------------------------
411 ResetCovariance(10.);
414 ResetCovariance(factor);
416 SetNumberOfClusters(0);
420 fCurrentSigmaY2 = 0.000005;
421 fCurrentSigmaZ2 = 0.000005;
430 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
432 //-----------------------------------------------------------------
433 // This function find proloncation of a track to a reference plane x=xk.
434 // doesn't change internal state of the track
435 //-----------------------------------------------------------------
437 Double_t x1=GetX(), x2=x1+(xk-x1), dx=x2-x1;
439 if (TMath::Abs(GetSnp()+GetC()*dx) >= AliTPCReconstructor::GetMaxSnpTrack()) {
443 // Double_t y1=fP0, z1=fP1;
444 Double_t c1=GetSnp(), r1=sqrt(1.- c1*c1);
445 Double_t c2=c1 + GetC()*dx, r2=sqrt(1.- c2*c2);
449 //y += dx*(c1+c2)/(r1+r2);
450 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
452 Double_t dy = dx*(c1+c2)/(r1+r2);
455 Double_t delta = GetC()*dx*(c1+c2)/(c1*r2 + c2*r1);
457 if (TMath::Abs(delta)>0.0001){
458 dz = fP3*TMath::ASin(delta)/fP4;
460 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
463 // dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
464 dz = GetTgl()*TMath::ASin(delta)/GetC();
474 //_____________________________________________________________________________
475 Double_t AliTPCseed::GetPredictedChi2(const AliCluster *c) const
477 //-----------------------------------------------------------------
478 // This function calculates a predicted chi2 increment.
479 //-----------------------------------------------------------------
480 Double_t p[2]={c->GetY(), c->GetZ()};
481 Double_t cov[3]={fErrorY2, 0., fErrorZ2};
482 return AliExternalTrackParam::GetPredictedChi2(p,cov);
485 //_________________________________________________________________________________________
488 Int_t AliTPCseed::Compare(const TObject *o) const {
489 //-----------------------------------------------------------------
490 // This function compares tracks according to the sector - for given sector according z
491 //-----------------------------------------------------------------
492 AliTPCseed *t=(AliTPCseed*)o;
495 if (t->fRelativeSector>fRelativeSector) return -1;
496 if (t->fRelativeSector<fRelativeSector) return 1;
497 Double_t z2 = t->GetZ();
498 Double_t z1 = GetZ();
500 if (z2<z1) return -1;
505 f2 = 1-20*TMath::Sqrt(t->GetSigma1Pt2())/(t->OneOverPt()+0.0066);
506 if (t->fBConstrain) f2=1.2;
509 f1 = 1-20*TMath::Sqrt(GetSigma1Pt2())/(OneOverPt()+0.0066);
511 if (fBConstrain) f1=1.2;
513 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
521 //_____________________________________________________________________________
522 Bool_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, Int_t index)
524 //-----------------------------------------------------------------
525 // This function associates a cluster with this track.
526 //-----------------------------------------------------------------
527 Int_t n=GetNumberOfClusters();
528 Int_t idx=GetClusterIndex(n); // save the current cluster index
530 AliCluster cl(*c); cl.SetSigmaY2(fErrorY2); cl.SetSigmaZ2(fErrorZ2);
531 if (!AliTPCtrack::Update(&cl,chisq,index)) return kFALSE;
533 if (fCMeanSigmaY2p30<0){
534 fCMeanSigmaY2p30= c->GetSigmaY2(); //! current mean sigma Y2 - mean30%
535 fCMeanSigmaZ2p30= c->GetSigmaZ2(); //! current mean sigma Z2 - mean30%
536 fCMeanSigmaY2p30R = 1; //! current mean sigma Y2 - mean5%
537 fCMeanSigmaZ2p30R = 1; //! current mean sigma Z2 - mean5%
540 fCMeanSigmaY2p30= 0.70*fCMeanSigmaY2p30 +0.30*c->GetSigmaY2();
541 fCMeanSigmaZ2p30= 0.70*fCMeanSigmaZ2p30 +0.30*c->GetSigmaZ2();
542 if (fCurrentSigmaY2>0){
543 fCMeanSigmaY2p30R = 0.7*fCMeanSigmaY2p30R +0.3*c->GetSigmaY2()/fCurrentSigmaY2;
544 fCMeanSigmaZ2p30R = 0.7*fCMeanSigmaZ2p30R +0.3*c->GetSigmaZ2()/fCurrentSigmaZ2;
548 SetClusterIndex(n,idx); // restore the current cluster index
554 //_____________________________________________________________________________
555 Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
556 //-----------------------------------------------------------------
557 // This funtion calculates dE/dX within the "low" and "up" cuts.
558 //-----------------------------------------------------------------
561 Float_t angular[200];
565 Float_t meanlog = 100.;
567 Float_t mean[4] = {0,0,0,0};
568 Float_t sigma[4] = {1000,1000,1000,1000};
569 Int_t nc[4] = {0,0,0,0};
570 Float_t norm[4] = {1000,1000,1000,1000};
576 if (AliTPCcalibDB::Instance()->GetParameters()){
577 gainGG= 20000./AliTPCcalibDB::Instance()->GetParameters()->GetGasGain(); //relative gas gain
581 for (Int_t of =0; of<4; of++){
582 for (Int_t i=of+i1;i<i2;i+=4)
584 Int_t index = fIndex[i];
585 if (index<0||index&0x8000) continue;
587 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
588 AliTPCTrackerPoint * point = GetTrackPoint(i);
589 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
590 //AliTPCTrackerPoint * pointp = 0;
591 //if (i<159) pointp = GetTrackPoint(i+1);
593 if (point==0) continue;
594 AliTPCclusterMI * cl = fClusterPointer[i];
596 if (onlyused && (!cl->IsUsed(10))) continue;
597 if (cl->IsUsed(11)) {
601 Int_t type = cl->GetType();
602 //if (point->fIsShared){
607 // if (pointm->fIsShared) continue;
609 // if (pointp->fIsShared) continue;
611 if (type<0) continue;
612 //if (type>10) continue;
613 //if (point->GetErrY()==0) continue;
614 //if (point->GetErrZ()==0) continue;
616 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
617 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
618 //if ((ddy*ddy+ddz*ddz)>10) continue;
621 // if (point->GetCPoint().GetMax()<5) continue;
622 if (cl->GetMax()<5) continue;
623 Float_t angley = point->GetAngleY();
624 Float_t anglez = point->GetAngleZ();
626 Float_t rsigmay2 = point->GetSigmaY();
627 Float_t rsigmaz2 = point->GetSigmaZ();
631 rsigmay += pointm->GetTPoint().GetSigmaY();
632 rsigmaz += pointm->GetTPoint().GetSigmaZ();
636 rsigmay += pointp->GetTPoint().GetSigmaY();
637 rsigmaz += pointp->GetTPoint().GetSigmaZ();
644 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
646 Float_t ampc = 0; // normalization to the number of electrons
648 // ampc = 1.*point->GetCPoint().GetMax();
649 ampc = 1.*cl->GetMax();
650 //ampc = 1.*point->GetCPoint().GetQ();
651 // AliTPCClusterPoint & p = point->GetCPoint();
652 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
653 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
655 // TMath::Abs( Int_t(iz) - iz + 0.5);
656 //ampc *= 1.15*(1-0.3*dy);
657 //ampc *= 1.15*(1-0.3*dz);
658 // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
662 //ampc = 1.0*point->GetCPoint().GetMax();
663 ampc = 1.0*cl->GetMax();
664 //ampc = 1.0*point->GetCPoint().GetQ();
665 //AliTPCClusterPoint & p = point->GetCPoint();
666 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
667 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
669 // TMath::Abs( Int_t(iz) - iz + 0.5);
671 //ampc *= 1.15*(1-0.3*dy);
672 //ampc *= 1.15*(1-0.3*dz);
673 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
677 ampc *= 2.0; // put mean value to channel 50
678 //ampc *= 0.58; // put mean value to channel 50
680 // if (type>0) w = 1./(type/2.-0.5);
681 // Float_t z = TMath::Abs(cl->GetZ());
684 //ampc /= (1+0.0008*z);
688 //ampc /= (1+0.0008*z);
690 //ampc /= (1+0.0008*z);
693 if (type<0) { //amp at the border - lower weight
698 if (rsigma>1.5) ampc/=1.3; // if big backround
699 amp[nc[of]] /=gainGG;
701 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
706 TMath::Sort(nc[of],amp,index,kFALSE);
710 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
712 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
713 Float_t ampl = amp[index[i]]/angular[index[i]];
714 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
716 sumw += weight[index[i]];
717 sumamp += weight[index[i]]*ampl;
718 sumamp2 += weight[index[i]]*ampl*ampl;
719 norm[of] += angular[index[i]]*weight[index[i]];
726 mean[of] = sumamp/sumw;
727 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
729 sigma[of] = TMath::Sqrt(sigma[of]);
733 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
734 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
735 //mean *=(1-0.1*(norm-1.));
742 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
743 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
746 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
747 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
751 for (Int_t i =0;i<4;i++){
752 if (nc[i]>2&&nc[i]<1000){
753 dedx += mean[i] *nc[i];
754 fSdEdx += sigma[i]*(nc[i]-2);
755 fMAngular += norm[i] *nc[i];
760 fSDEDX[i] = sigma[i];
773 // Float_t dedx1 =dedx;
776 for (Int_t i =0;i<4;i++){
777 if (nc[i]>2&&nc[i]<1000){
778 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
779 dedx += mean[i] *nc[i];
790 Double_t AliTPCseed::Bethe(Double_t bg){
792 // This is the Bethe-Bloch function normalised to 1 at the minimum
797 bethe=(1.+ bg2)/bg2*(log(5940*bg2) - bg2/(1.+ bg2));
798 else // Density effect ( approximately :)
799 bethe=1.15*(1.+ bg2)/bg2*(log(3.5*5940*bg) - bg2/(1.+ bg2));
803 void AliTPCseed::CookPID()
806 // cook PID information according dEdx
808 Double_t fRange = 10.;
812 Int_t ns=AliPID::kSPECIES;
814 for (Int_t j=0; j<ns; j++) {
815 Double_t mass=AliPID::ParticleMass(j);
817 Double_t dedx=fdEdx/fMIP;
818 Double_t bethe=Bethe(mom/mass);
819 Double_t sigma=fRes*bethe;
821 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
822 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
826 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
834 for (Int_t j=0; j<ns; j++) {
835 fTPCr[j]/=sumr; //normalize
840 void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
841 //-----------------------------------------------------------------
842 // This funtion calculates dE/dX within the "low" and "up" cuts.
843 //-----------------------------------------------------------------
846 Float_t angular[200];
850 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
851 for (Int_t i=0;i<200;i++) amp[i]=10000;
852 for (Int_t i=0;i<200;i++) angular[i]= 1;;
856 Float_t meanlog = 100.;
857 Int_t indexde[4]={0,64,128,160};
864 Float_t mean[4] = {0,0,0,0};
865 Float_t sigma[4] = {1000,1000,1000,1000};
866 Int_t nc[4] = {0,0,0,0};
867 Float_t norm[4] = {1000,1000,1000,1000};
872 // for (Int_t of =0; of<3; of++){
873 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
874 for (Int_t i =0; i<160;i++)
876 AliTPCTrackPoint * point = GetTrackPoint(i);
877 if (point==0) continue;
878 if (point->fIsShared){
882 Int_t type = point->GetCPoint().GetType();
883 if (type<0) continue;
884 if (point->GetCPoint().GetMax()<5) continue;
885 Float_t angley = point->GetTPoint().GetAngleY();
886 Float_t anglez = point->GetTPoint().GetAngleZ();
887 Float_t rsigmay = point->GetCPoint().GetSigmaY();
888 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
889 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
891 Float_t ampc = 0; // normalization to the number of electrons
893 ampc = point->GetCPoint().GetMax();
896 ampc = point->GetCPoint().GetMax();
898 ampc *= 2.0; // put mean value to channel 50
899 // ampc *= 0.565; // put mean value to channel 50
902 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
909 if (type<0) { //amp at the border - lower weight
912 if (rsigma>1.5) ampc/=1.3; // if big backround
913 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
914 amp[i] = ampc/angular[i];
919 TMath::Sort(159,amp,index,kFALSE);
920 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
921 inlimit[index[i]] = kTRUE; // take all clusters
924 // meanlog = amp[index[Int_t(anc*0.3)]];
926 for (Int_t of =0; of<3; of++){
930 for (Int_t i=indexde[of];i<indexde[of+1];i++)
932 if (inlimit[i]==kFALSE) continue;
933 Float_t ampl = amp[i];
935 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
938 sumamp += weight[i]*ampl;
939 sumamp2 += weight[i]*ampl*ampl;
940 norm[of] += angular[i]*weight[i];
948 mean[of] = sumamp/sumw;
949 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
951 sigma[of] = TMath::Sqrt(sigma[of]);
954 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
964 Float_t www[3] = {12.,14.,17.};
965 //Float_t www[3] = {1.,1.,1.};
967 for (Int_t i =0;i<3;i++){
968 if (nc[i]>2&&nc[i]<1000){
969 dedx += mean[i] *nc[i]*www[i]/sigma[i];
970 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
971 fMAngular += norm[i] *nc[i];
972 norm2 += nc[i]*www[i]/sigma[i];
973 norm3 += (nc[i]-2)*www[i]/sigma[i];
976 fSDEDX[i] = sigma[i];
989 // Float_t dedx1 =dedx;
993 for (Int_t i =0;i<3;i++){
994 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
995 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
996 dedx += mean[i] *(nc[i])/(sigma[i]);
997 norm4 += (nc[i])/(sigma[i]);
1001 if (norm4>0) dedx /= norm4;
1011 Double_t AliTPCseed::GetYat(Double_t xk) const {
1012 //-----------------------------------------------------------------
1013 // This function calculates the Y-coordinate of a track at the plane x=xk.
1014 //-----------------------------------------------------------------
1015 if (TMath::Abs(GetSnp())>AliTPCReconstructor::GetMaxSnpTrack()) return 0.; //patch 01 jan 06
1016 Double_t c1=GetSnp(), r1=TMath::Sqrt(1.- c1*c1);
1017 Double_t c2=c1+GetC()*(xk-GetX());
1018 if (TMath::Abs(c2)>AliTPCReconstructor::GetMaxSnpTrack()) return 0;
1019 Double_t r2=TMath::Sqrt(1.- c2*c2);
1020 return GetY() + (xk-GetX())*(c1+c2)/(r1+r2);
1023 void AliTPCseed::SetClusterMapBit(int ibit, Bool_t state)
1025 fClusterMap[ibit] = state;
1027 Bool_t AliTPCseed::GetClusterMapBit(int ibit)
1029 return fClusterMap[ibit];
1031 void AliTPCseed::SetSharedMapBit(int ibit, Bool_t state)
1033 fSharedMap[ibit] = state;
1035 Bool_t AliTPCseed::GetSharedMapBit(int ibit)
1037 return fSharedMap[ibit];
1044 Float_t AliTPCseed::CookdEdxNorm(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, AliTPCCalPad * gainMap, Bool_t posNorm, Bool_t padNorm){
1047 // calculates dedx using the cluster
1048 // low - up specify trunc mean range - default form 0-0.7
1049 // type - 1 - max charge or 0- total charge in cluster
1050 // //2- max no corr 3- total+ correction
1051 // i1-i2 - the pad-row range used for calculation
1053 // normalization parametrization taken from AliTPCClusterParam
1055 AliTPCClusterParam * parcl = AliTPCClusterParam::Instance();
1056 if (!parcl) parcl = AliTPCcalibDB::Instance()->GetClusterParam();
1057 if (!parcl) return 0;
1064 if (AliTPCcalibDB::Instance()->GetParameters()){
1065 gainGG= 20000./AliTPCcalibDB::Instance()->GetParameters()->GetGasGain(); //relative gas gain
1068 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1069 const Float_t kedgey =3.;
1072 for (Int_t irow=i1; irow<i2; irow++){
1073 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1074 if (!cluster) continue;
1075 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
1076 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
1077 if (!gainMap) gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
1080 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
1081 if (irow < 63) { // IROC
1082 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()))*1.55;
1084 factor = roc->GetValue(irow - 63, TMath::Nint(cluster->GetPad()));
1086 if (factor>0.5) charge/=factor;
1092 if (irow>62) ipad=1;
1093 if (irow>127) ipad=2;
1096 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1097 Float_t ty = TMath::Abs(point->GetAngleY());
1098 Float_t tz = TMath::Abs(point->GetAngleZ());
1100 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
1101 corr = parcl->Qnorm(ipad,type,dr,ty,tz);
1103 amp[ncl]=charge/corr;
1109 corr = parcl->QnormPos(ipad,type, cluster->GetPad(),cluster->GetTimeBin(), cluster->GetZ(),
1110 cluster->GetSigmaY2(),cluster->GetSigmaZ2(),cluster->GetMax(),cluster->GetQ());
1115 amp[ncl] *= 2.0; // put mean value to channel 50
1118 if (type==0 && parcl->fQpadTnorm) corr = (*parcl->fQpadTnorm)[ipad];
1119 if (type==1 && parcl->fQpadTnorm) corr = (*parcl->fQpadMnorm)[ipad];
1124 // amp[ncl] /= 0.65; // this we will take form OCDB
1133 if (type>3) return ncl;
1134 TMath::Sort(ncl,amp, indexes, kFALSE);
1136 if (ncl<10) return 0;
1140 Int_t icl0=TMath::Nint(ncl*low);
1141 Int_t icl1=TMath::Nint(ncl*up);
1142 for (Int_t icl=icl0; icl<icl1;icl++){
1143 suma+=amp[indexes[icl]];
1150 Double_t AliTPCseed::BetheMass(Double_t mass){
1152 // return bethe-bloch
1154 Float_t bg= P()/mass;
1155 const Double_t kp1=0.76176e-1;
1156 const Double_t kp2=10.632;
1157 const Double_t kp3=0.13279e-4;
1158 const Double_t kp4=1.8631;
1159 const Double_t kp5=1.9479;
1161 Double_t dbg = (Double_t) bg;
1163 Double_t beta = dbg/TMath::Sqrt(1.+dbg*dbg);
1165 Double_t aa = TMath::Power(beta,kp4);
1166 Double_t bb = TMath::Power(1./dbg,kp5);
1168 bb=TMath::Log(kp3+bb);
1170 return ((Float_t)((kp2-aa-bb)*kp1/aa));
1174 Float_t AliTPCseed::CookShape(Int_t type){
1178 //-----------------------------------------------------------------
1179 // This funtion calculates dE/dX within the "low" and "up" cuts.
1180 //-----------------------------------------------------------------
1183 for (Int_t i =0; i<160;i++) {
1184 AliTPCTrackerPoint * point = GetTrackPoint(i);
1185 if (point==0) continue;
1187 AliTPCclusterMI * cl = fClusterPointer[i];
1188 if (cl==0) continue;
1190 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1191 Float_t rsigmaz = TMath::Sqrt(point->GetSigmaZ());
1192 Float_t rsigma = (rsigmay+rsigmaz)*0.5;
1193 if (type==0) means+=rsigma;
1194 if (type==1) means+=rsigmay;
1195 if (type==2) means+=rsigmaz;
1198 Float_t mean = (meanc>0)? means/meanc:0;