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"
31 #include "AliTPCParam.h"
39 AliTPCseed::AliTPCseed():
42 fClusterOwner(kFALSE),
46 fCurrentSigmaY2(1e10),
47 fCurrentSigmaZ2(1e10),
48 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
49 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
50 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
51 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
56 fCurrentClusterIndex1(-1),
71 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
72 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
73 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=0;
74 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0.2;
75 for (Int_t i=0;i<4;i++) {
80 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
81 // for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
82 //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
83 fClusterMap.ResetAllBits(kFALSE);
84 fSharedMap.ResetAllBits(kFALSE);
88 AliTPCseed::AliTPCseed(const AliTPCseed &s, Bool_t clusterOwner):
91 fClusterOwner(clusterOwner),
97 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
98 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
99 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
100 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
103 fCurrentCluster(0x0),
104 fCurrentClusterIndex1(-1),
115 fClusterMap(s.fClusterMap),
116 fSharedMap(s.fSharedMap)
118 //---------------------
119 // dummy copy constructor
120 //-------------------------
121 for (Int_t i=0;i<160;i++) {
122 fClusterPointer[i]=0;
124 if (s.fClusterPointer[i])
125 fClusterPointer[i] = new AliTPCclusterMI(*(s.fClusterPointer[i]));
127 fClusterPointer[i] = s.fClusterPointer[i];
129 fTrackPoints[i] = s.fTrackPoints[i];
131 for (Int_t i=0;i<160;i++) fIndex[i] = s.fIndex[i];
132 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=s.fTPCr[i];
133 for (Int_t i=0;i<4;i++) {
134 fDEDX[i] = s.fDEDX[i];
135 fSDEDX[i] = s.fSDEDX[i];
136 fNCDEDX[i] = s.fNCDEDX[i];
138 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = s.fOverlapLabels[i];
143 AliTPCseed::AliTPCseed(const AliTPCtrack &t):
146 fClusterOwner(kFALSE),
152 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
153 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
154 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
155 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
158 fCurrentCluster(0x0),
159 fCurrentClusterIndex1(-1),
174 // Constructor from AliTPCtrack
177 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
178 for (Int_t i=0;i<160;i++) {
179 fClusterPointer[i] = 0;
180 Int_t index = t.GetClusterIndex(i);
182 SetClusterIndex2(i,index);
185 SetClusterIndex2(i,-3);
188 for (Int_t i=0;i<4;i++) {
193 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
195 //for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
196 //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
197 fClusterMap.ResetAllBits(kFALSE);
198 fSharedMap.ResetAllBits(kFALSE);
202 AliTPCseed::AliTPCseed(Double_t xr, Double_t alpha, const Double_t xx[5],
203 const Double_t cc[15], Int_t index):
204 AliTPCtrack(xr, alpha, xx, cc, index),
206 fClusterOwner(kFALSE),
212 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
213 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
214 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
215 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
218 fCurrentCluster(0x0),
219 fCurrentClusterIndex1(-1),
237 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
238 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
239 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
240 for (Int_t i=0;i<4;i++) {
245 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
248 AliTPCseed::~AliTPCseed(){
253 for (Int_t icluster=0; icluster<160; icluster++){
254 delete fClusterPointer[icluster];
259 //_________________________________________________
260 AliTPCseed & AliTPCseed::operator=(const AliTPCseed ¶m)
263 // assignment operator
266 AliTPCtrack::operator=(param);
268 for(Int_t i = 0;i<160;++i)fClusterPointer[i] = param.fClusterPointer[i]; // this is not allocated by AliTPCSeed
269 fClusterOwner = param.fClusterOwner;
270 // leave out fPoint, they are also not copied in the copy ctor...
271 // but deleted in the dtor... strange...
273 fSector = param.fSector;
274 fRelativeSector = param.fRelativeSector;
275 fCurrentSigmaY2 = param.fCurrentSigmaY2;
276 fCurrentSigmaZ2 = param.fCurrentSigmaZ2;
277 fErrorY2 = param.fErrorY2;
278 fErrorZ2 = param.fErrorZ2;
279 fCurrentCluster = param.fCurrentCluster; // this is not allocated by AliTPCSeed
280 fCurrentClusterIndex1 = param.fCurrentClusterIndex1;
281 fInDead = param.fInDead;
282 fIsSeeding = param.fIsSeeding;
283 fNoCluster = param.fNoCluster;
285 fBSigned = param.fBSigned;
286 for(Int_t i = 0;i<4;++i){
287 fDEDX[i] = param.fDEDX[i];
288 fSDEDX[i] = param.fSDEDX[i];
289 fNCDEDX[i] = param.fNCDEDX[i];
291 for(Int_t i = 0;i<AliPID::kSPECIES;++i)fTPCr[i] = param.fTPCr[i];
293 fSeedType = param.fSeedType;
294 fSeed1 = param.fSeed1;
295 fSeed2 = param.fSeed2;
296 for(Int_t i = 0;i<12;++i)fOverlapLabels[i] = param.fOverlapLabels[i];
297 fMAngular = param.fMAngular;
298 fCircular = param.fCircular;
299 for(int i = 0;i<160;++i)fTrackPoints[i] = param.fTrackPoints[i];
300 fClusterMap = param.fClusterMap;
301 fSharedMap = param.fSharedMap;
305 //____________________________________________________
306 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
310 return &fTrackPoints[i];
315 Double_t AliTPCseed::GetDensityFirst(Int_t n)
319 // return cluster for n rows bellow first point
320 Int_t nfoundable = 1;
322 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
323 Int_t index = GetClusterIndex2(i);
324 if (index!=-1) nfoundable++;
325 if (index>0) nfound++;
327 if (nfoundable<n) return 0;
328 return Double_t(nfound)/Double_t(nfoundable);
333 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
335 // get cluster stat. on given region
340 for (Int_t i=first;i<last; i++){
341 Int_t index = GetClusterIndex2(i);
342 if (index!=-1) foundable++;
343 if (index&0x8000) continue;
344 if (fClusterPointer[i]) {
350 if (fClusterPointer[i]->IsUsed(10)) {
354 if (!plus2) continue; //take also neighborhoud
356 if ( (i>0) && fClusterPointer[i-1]){
357 if (fClusterPointer[i-1]->IsUsed(10)) {
362 if ( fClusterPointer[i+1]){
363 if (fClusterPointer[i+1]->IsUsed(10)) {
371 //Error("AliTPCseed::GetClusterStatistic","problem\n");
379 void AliTPCseed::Reset(Bool_t all)
383 SetNumberOfClusters(0);
386 ResetCovariance(10.);
389 for (Int_t i=0;i<8;i++){
390 delete [] fTrackPoints[i];
398 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
399 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
405 void AliTPCseed::Modify(Double_t factor)
408 //------------------------------------------------------------------
409 //This function makes a track forget its history :)
410 //------------------------------------------------------------------
412 ResetCovariance(10.);
415 ResetCovariance(factor);
417 SetNumberOfClusters(0);
421 fCurrentSigmaY2 = 0.000005;
422 fCurrentSigmaZ2 = 0.000005;
431 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
433 //-----------------------------------------------------------------
434 // This function find proloncation of a track to a reference plane x=xk.
435 // doesn't change internal state of the track
436 //-----------------------------------------------------------------
438 Double_t x1=GetX(), x2=x1+(xk-x1), dx=x2-x1;
440 if (TMath::Abs(GetSnp()+GetC()*dx) >= AliTPCReconstructor::GetMaxSnpTrack()) {
444 // Double_t y1=fP0, z1=fP1;
445 Double_t c1=GetSnp(), r1=sqrt(1.- c1*c1);
446 Double_t c2=c1 + GetC()*dx, r2=sqrt(1.- c2*c2);
450 //y += dx*(c1+c2)/(r1+r2);
451 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
453 Double_t dy = dx*(c1+c2)/(r1+r2);
456 Double_t delta = GetC()*dx*(c1+c2)/(c1*r2 + c2*r1);
458 if (TMath::Abs(delta)>0.0001){
459 dz = fP3*TMath::ASin(delta)/fP4;
461 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
464 // dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
465 dz = GetTgl()*TMath::ASin(delta)/GetC();
475 //_____________________________________________________________________________
476 Double_t AliTPCseed::GetPredictedChi2(const AliCluster *c) const
478 //-----------------------------------------------------------------
479 // This function calculates a predicted chi2 increment.
480 //-----------------------------------------------------------------
481 Double_t p[2]={c->GetY(), c->GetZ()};
482 Double_t cov[3]={fErrorY2, 0., fErrorZ2};
483 return AliExternalTrackParam::GetPredictedChi2(p,cov);
486 //_________________________________________________________________________________________
489 Int_t AliTPCseed::Compare(const TObject *o) const {
490 //-----------------------------------------------------------------
491 // This function compares tracks according to the sector - for given sector according z
492 //-----------------------------------------------------------------
493 AliTPCseed *t=(AliTPCseed*)o;
496 if (t->fRelativeSector>fRelativeSector) return -1;
497 if (t->fRelativeSector<fRelativeSector) return 1;
498 Double_t z2 = t->GetZ();
499 Double_t z1 = GetZ();
501 if (z2<z1) return -1;
506 f2 = 1-20*TMath::Sqrt(t->GetSigma1Pt2())/(t->OneOverPt()+0.0066);
507 if (t->fBConstrain) f2=1.2;
510 f1 = 1-20*TMath::Sqrt(GetSigma1Pt2())/(OneOverPt()+0.0066);
512 if (fBConstrain) f1=1.2;
514 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
522 //_____________________________________________________________________________
523 Bool_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, Int_t index)
525 //-----------------------------------------------------------------
526 // This function associates a cluster with this track.
527 //-----------------------------------------------------------------
528 Int_t n=GetNumberOfClusters();
529 Int_t idx=GetClusterIndex(n); // save the current cluster index
531 AliCluster cl(*c); cl.SetSigmaY2(fErrorY2); cl.SetSigmaZ2(fErrorZ2);
532 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
533 if (TMath::Abs(dx)>0){
534 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
536 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
537 cl.SetY(c->GetY()-dy);
538 cl.SetZ(c->GetZ()-dz);
541 if (!AliTPCtrack::Update(&cl,chisq,index)) return kFALSE;
543 if (fCMeanSigmaY2p30<0){
544 fCMeanSigmaY2p30= c->GetSigmaY2(); //! current mean sigma Y2 - mean30%
545 fCMeanSigmaZ2p30= c->GetSigmaZ2(); //! current mean sigma Z2 - mean30%
546 fCMeanSigmaY2p30R = 1; //! current mean sigma Y2 - mean5%
547 fCMeanSigmaZ2p30R = 1; //! current mean sigma Z2 - mean5%
550 fCMeanSigmaY2p30= 0.70*fCMeanSigmaY2p30 +0.30*c->GetSigmaY2();
551 fCMeanSigmaZ2p30= 0.70*fCMeanSigmaZ2p30 +0.30*c->GetSigmaZ2();
552 if (fCurrentSigmaY2>0){
553 fCMeanSigmaY2p30R = 0.7*fCMeanSigmaY2p30R +0.3*c->GetSigmaY2()/fCurrentSigmaY2;
554 fCMeanSigmaZ2p30R = 0.7*fCMeanSigmaZ2p30R +0.3*c->GetSigmaZ2()/fCurrentSigmaZ2;
558 SetClusterIndex(n,idx); // restore the current cluster index
564 //_____________________________________________________________________________
565 Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
566 //-----------------------------------------------------------------
567 // This funtion calculates dE/dX within the "low" and "up" cuts.
568 //-----------------------------------------------------------------
571 Float_t angular[200];
575 Float_t meanlog = 100.;
577 Float_t mean[4] = {0,0,0,0};
578 Float_t sigma[4] = {1000,1000,1000,1000};
579 Int_t nc[4] = {0,0,0,0};
580 Float_t norm[4] = {1000,1000,1000,1000};
586 if (AliTPCcalibDB::Instance()->GetParameters()){
587 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000.; //relative gas gain
591 for (Int_t of =0; of<4; of++){
592 for (Int_t i=of+i1;i<i2;i+=4)
594 Int_t index = fIndex[i];
595 if (index<0||index&0x8000) continue;
597 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
598 AliTPCTrackerPoint * point = GetTrackPoint(i);
599 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
600 //AliTPCTrackerPoint * pointp = 0;
601 //if (i<159) pointp = GetTrackPoint(i+1);
603 if (point==0) continue;
604 AliTPCclusterMI * cl = fClusterPointer[i];
606 if (onlyused && (!cl->IsUsed(10))) continue;
607 if (cl->IsUsed(11)) {
611 Int_t type = cl->GetType();
612 //if (point->fIsShared){
617 // if (pointm->fIsShared) continue;
619 // if (pointp->fIsShared) continue;
621 if (type<0) continue;
622 //if (type>10) continue;
623 //if (point->GetErrY()==0) continue;
624 //if (point->GetErrZ()==0) continue;
626 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
627 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
628 //if ((ddy*ddy+ddz*ddz)>10) continue;
631 // if (point->GetCPoint().GetMax()<5) continue;
632 if (cl->GetMax()<5) continue;
633 Float_t angley = point->GetAngleY();
634 Float_t anglez = point->GetAngleZ();
636 Float_t rsigmay2 = point->GetSigmaY();
637 Float_t rsigmaz2 = point->GetSigmaZ();
641 rsigmay += pointm->GetTPoint().GetSigmaY();
642 rsigmaz += pointm->GetTPoint().GetSigmaZ();
646 rsigmay += pointp->GetTPoint().GetSigmaY();
647 rsigmaz += pointp->GetTPoint().GetSigmaZ();
654 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
656 Float_t ampc = 0; // normalization to the number of electrons
658 // ampc = 1.*point->GetCPoint().GetMax();
659 ampc = 1.*cl->GetMax();
660 //ampc = 1.*point->GetCPoint().GetQ();
661 // AliTPCClusterPoint & p = point->GetCPoint();
662 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
663 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
665 // TMath::Abs( Int_t(iz) - iz + 0.5);
666 //ampc *= 1.15*(1-0.3*dy);
667 //ampc *= 1.15*(1-0.3*dz);
668 // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
672 //ampc = 1.0*point->GetCPoint().GetMax();
673 ampc = 1.0*cl->GetMax();
674 //ampc = 1.0*point->GetCPoint().GetQ();
675 //AliTPCClusterPoint & p = point->GetCPoint();
676 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
677 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
679 // TMath::Abs( Int_t(iz) - iz + 0.5);
681 //ampc *= 1.15*(1-0.3*dy);
682 //ampc *= 1.15*(1-0.3*dz);
683 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
687 ampc *= 2.0; // put mean value to channel 50
688 //ampc *= 0.58; // put mean value to channel 50
690 // if (type>0) w = 1./(type/2.-0.5);
691 // Float_t z = TMath::Abs(cl->GetZ());
694 //ampc /= (1+0.0008*z);
698 //ampc /= (1+0.0008*z);
700 //ampc /= (1+0.0008*z);
703 if (type<0) { //amp at the border - lower weight
708 if (rsigma>1.5) ampc/=1.3; // if big backround
710 amp[nc[of]] /=gainGG;
711 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
716 TMath::Sort(nc[of],amp,index,kFALSE);
720 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
722 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
723 Float_t ampl = amp[index[i]]/angular[index[i]];
724 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
726 sumw += weight[index[i]];
727 sumamp += weight[index[i]]*ampl;
728 sumamp2 += weight[index[i]]*ampl*ampl;
729 norm[of] += angular[index[i]]*weight[index[i]];
736 mean[of] = sumamp/sumw;
737 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
739 sigma[of] = TMath::Sqrt(sigma[of]);
743 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
744 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
745 //mean *=(1-0.1*(norm-1.));
752 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
753 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
756 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
757 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
761 for (Int_t i =0;i<4;i++){
762 if (nc[i]>2&&nc[i]<1000){
763 dedx += mean[i] *nc[i];
764 fSdEdx += sigma[i]*(nc[i]-2);
765 fMAngular += norm[i] *nc[i];
770 fSDEDX[i] = sigma[i];
783 // Float_t dedx1 =dedx;
786 for (Int_t i =0;i<4;i++){
787 if (nc[i]>2&&nc[i]<1000){
788 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
789 dedx += mean[i] *nc[i];
800 Double_t AliTPCseed::Bethe(Double_t bg){
802 // This is the Bethe-Bloch function normalised to 1 at the minimum
807 bethe=(1.+ bg2)/bg2*(log(5940*bg2) - bg2/(1.+ bg2));
808 else // Density effect ( approximately :)
809 bethe=1.15*(1.+ bg2)/bg2*(log(3.5*5940*bg) - bg2/(1.+ bg2));
813 void AliTPCseed::CookPID()
816 // cook PID information according dEdx
818 Double_t fRange = 10.;
822 Int_t ns=AliPID::kSPECIES;
824 for (Int_t j=0; j<ns; j++) {
825 Double_t mass=AliPID::ParticleMass(j);
827 Double_t dedx=fdEdx/fMIP;
828 Double_t bethe=Bethe(mom/mass);
829 Double_t sigma=fRes*bethe;
831 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
832 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
836 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
844 for (Int_t j=0; j<ns; j++) {
845 fTPCr[j]/=sumr; //normalize
850 void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
851 //-----------------------------------------------------------------
852 // This funtion calculates dE/dX within the "low" and "up" cuts.
853 //-----------------------------------------------------------------
856 Float_t angular[200];
860 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
861 for (Int_t i=0;i<200;i++) amp[i]=10000;
862 for (Int_t i=0;i<200;i++) angular[i]= 1;;
866 Float_t meanlog = 100.;
867 Int_t indexde[4]={0,64,128,160};
874 Float_t mean[4] = {0,0,0,0};
875 Float_t sigma[4] = {1000,1000,1000,1000};
876 Int_t nc[4] = {0,0,0,0};
877 Float_t norm[4] = {1000,1000,1000,1000};
882 // for (Int_t of =0; of<3; of++){
883 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
884 for (Int_t i =0; i<160;i++)
886 AliTPCTrackPoint * point = GetTrackPoint(i);
887 if (point==0) continue;
888 if (point->fIsShared){
892 Int_t type = point->GetCPoint().GetType();
893 if (type<0) continue;
894 if (point->GetCPoint().GetMax()<5) continue;
895 Float_t angley = point->GetTPoint().GetAngleY();
896 Float_t anglez = point->GetTPoint().GetAngleZ();
897 Float_t rsigmay = point->GetCPoint().GetSigmaY();
898 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
899 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
901 Float_t ampc = 0; // normalization to the number of electrons
903 ampc = point->GetCPoint().GetMax();
906 ampc = point->GetCPoint().GetMax();
908 ampc *= 2.0; // put mean value to channel 50
909 // ampc *= 0.565; // put mean value to channel 50
912 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
919 if (type<0) { //amp at the border - lower weight
922 if (rsigma>1.5) ampc/=1.3; // if big backround
923 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
924 amp[i] = ampc/angular[i];
929 TMath::Sort(159,amp,index,kFALSE);
930 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
931 inlimit[index[i]] = kTRUE; // take all clusters
934 // meanlog = amp[index[Int_t(anc*0.3)]];
936 for (Int_t of =0; of<3; of++){
940 for (Int_t i=indexde[of];i<indexde[of+1];i++)
942 if (inlimit[i]==kFALSE) continue;
943 Float_t ampl = amp[i];
945 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
948 sumamp += weight[i]*ampl;
949 sumamp2 += weight[i]*ampl*ampl;
950 norm[of] += angular[i]*weight[i];
958 mean[of] = sumamp/sumw;
959 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
961 sigma[of] = TMath::Sqrt(sigma[of]);
964 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
974 Float_t www[3] = {12.,14.,17.};
975 //Float_t www[3] = {1.,1.,1.};
977 for (Int_t i =0;i<3;i++){
978 if (nc[i]>2&&nc[i]<1000){
979 dedx += mean[i] *nc[i]*www[i]/sigma[i];
980 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
981 fMAngular += norm[i] *nc[i];
982 norm2 += nc[i]*www[i]/sigma[i];
983 norm3 += (nc[i]-2)*www[i]/sigma[i];
986 fSDEDX[i] = sigma[i];
999 // Float_t dedx1 =dedx;
1003 for (Int_t i =0;i<3;i++){
1004 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
1005 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
1006 dedx += mean[i] *(nc[i])/(sigma[i]);
1007 norm4 += (nc[i])/(sigma[i]);
1011 if (norm4>0) dedx /= norm4;
1021 Double_t AliTPCseed::GetYat(Double_t xk) const {
1022 //-----------------------------------------------------------------
1023 // This function calculates the Y-coordinate of a track at the plane x=xk.
1024 //-----------------------------------------------------------------
1025 if (TMath::Abs(GetSnp())>AliTPCReconstructor::GetMaxSnpTrack()) return 0.; //patch 01 jan 06
1026 Double_t c1=GetSnp(), r1=TMath::Sqrt(1.- c1*c1);
1027 Double_t c2=c1+GetC()*(xk-GetX());
1028 if (TMath::Abs(c2)>AliTPCReconstructor::GetMaxSnpTrack()) return 0;
1029 Double_t r2=TMath::Sqrt(1.- c2*c2);
1030 return GetY() + (xk-GetX())*(c1+c2)/(r1+r2);
1033 void AliTPCseed::SetClusterMapBit(int ibit, Bool_t state)
1035 fClusterMap[ibit] = state;
1037 Bool_t AliTPCseed::GetClusterMapBit(int ibit)
1039 return fClusterMap[ibit];
1041 void AliTPCseed::SetSharedMapBit(int ibit, Bool_t state)
1043 fSharedMap[ibit] = state;
1045 Bool_t AliTPCseed::GetSharedMapBit(int ibit)
1047 return fSharedMap[ibit];
1054 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){
1057 // calculates dedx using the cluster
1058 // low - up specify trunc mean range - default form 0-0.7
1059 // type - 1 - max charge or 0- total charge in cluster
1060 // //2- max no corr 3- total+ correction
1061 // i1-i2 - the pad-row range used for calculation
1063 // normalization parametrization taken from AliTPCClusterParam
1065 AliTPCClusterParam * parcl = AliTPCClusterParam::Instance();
1066 if (!parcl) parcl = AliTPCcalibDB::Instance()->GetClusterParam();
1067 if (!parcl) return 0;
1074 if (AliTPCcalibDB::Instance()->GetParameters()){
1075 gainGG= 20000./AliTPCcalibDB::Instance()->GetParameters()->GetGasGain(); //relative gas gain
1078 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1079 const Float_t kedgey =3.;
1082 for (Int_t irow=i1; irow<i2; irow++){
1083 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1084 if (!cluster) continue;
1085 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
1086 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
1087 if (!gainMap) gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
1090 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
1091 if (irow < 63) { // IROC
1092 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()))*1.55;
1094 factor = roc->GetValue(irow - 63, TMath::Nint(cluster->GetPad()));
1096 if (factor>0.5) charge/=factor;
1102 if (irow>62) ipad=1;
1103 if (irow>127) ipad=2;
1106 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1107 Float_t ty = TMath::Abs(point->GetAngleY());
1108 Float_t tz = TMath::Abs(point->GetAngleZ());
1110 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
1111 corr = parcl->Qnorm(ipad,type,dr,ty,tz);
1113 amp[ncl]=charge/corr;
1119 corr = parcl->QnormPos(ipad,type, cluster->GetPad(),cluster->GetTimeBin(), cluster->GetZ(),
1120 cluster->GetSigmaY2(),cluster->GetSigmaZ2(),cluster->GetMax(),cluster->GetQ());
1125 amp[ncl] *= 2.0; // put mean value to channel 50
1128 if (type==0 && parcl->fQpadTnorm) corr = (*parcl->fQpadTnorm)[ipad];
1129 if (type==1 && parcl->fQpadTnorm) corr = (*parcl->fQpadMnorm)[ipad];
1134 // amp[ncl] /= 0.65; // this we will take form OCDB
1143 if (type>3) return ncl;
1144 TMath::Sort(ncl,amp, indexes, kFALSE);
1146 if (ncl<10) return 0;
1150 Int_t icl0=TMath::Nint(ncl*low);
1151 Int_t icl1=TMath::Nint(ncl*up);
1152 for (Int_t icl=icl0; icl<icl1;icl++){
1153 suma+=amp[indexes[icl]];
1160 Double_t AliTPCseed::BetheMass(Double_t mass){
1162 // return bethe-bloch
1164 Float_t bg= P()/mass;
1165 const Double_t kp1=0.76176e-1;
1166 const Double_t kp2=10.632;
1167 const Double_t kp3=0.13279e-4;
1168 const Double_t kp4=1.8631;
1169 const Double_t kp5=1.9479;
1171 Double_t dbg = (Double_t) bg;
1173 Double_t beta = dbg/TMath::Sqrt(1.+dbg*dbg);
1175 Double_t aa = TMath::Power(beta,kp4);
1176 Double_t bb = TMath::Power(1./dbg,kp5);
1178 bb=TMath::Log(kp3+bb);
1180 return ((Float_t)((kp2-aa-bb)*kp1/aa));
1184 Float_t AliTPCseed::CookShape(Int_t type){
1188 //-----------------------------------------------------------------
1189 // This funtion calculates dE/dX within the "low" and "up" cuts.
1190 //-----------------------------------------------------------------
1193 for (Int_t i =0; i<160;i++) {
1194 AliTPCTrackerPoint * point = GetTrackPoint(i);
1195 if (point==0) continue;
1197 AliTPCclusterMI * cl = fClusterPointer[i];
1198 if (cl==0) continue;
1200 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1201 Float_t rsigmaz = TMath::Sqrt(point->GetSigmaZ());
1202 Float_t rsigma = (rsigmay+rsigmaz)*0.5;
1203 if (type==0) means+=rsigma;
1204 if (type==1) means+=rsigmay;
1205 if (type==2) means+=rsigmaz;
1208 Float_t mean = (meanc>0)? means/meanc:0;