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"
32 #include "AliMathBase.h"
40 AliTPCseed::AliTPCseed():
43 fClusterOwner(kFALSE),
47 fCurrentSigmaY2(1e10),
48 fCurrentSigmaZ2(1e10),
49 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
50 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
51 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
52 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
57 fCurrentClusterIndex1(-1),
72 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
73 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
74 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=0;
75 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0.2;
76 for (Int_t i=0;i<4;i++) {
81 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
82 // for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
83 //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
84 fClusterMap.ResetAllBits(kFALSE);
85 fSharedMap.ResetAllBits(kFALSE);
89 AliTPCseed::AliTPCseed(const AliTPCseed &s, Bool_t clusterOwner):
92 fClusterOwner(clusterOwner),
98 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
99 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
100 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
101 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
104 fCurrentCluster(0x0),
105 fCurrentClusterIndex1(-1),
116 fClusterMap(s.fClusterMap),
117 fSharedMap(s.fSharedMap)
119 //---------------------
120 // dummy copy constructor
121 //-------------------------
122 for (Int_t i=0;i<160;i++) {
123 fClusterPointer[i]=0;
125 if (s.fClusterPointer[i])
126 fClusterPointer[i] = new AliTPCclusterMI(*(s.fClusterPointer[i]));
128 fClusterPointer[i] = s.fClusterPointer[i];
130 fTrackPoints[i] = s.fTrackPoints[i];
132 for (Int_t i=0;i<160;i++) fIndex[i] = s.fIndex[i];
133 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=s.fTPCr[i];
134 for (Int_t i=0;i<4;i++) {
135 fDEDX[i] = s.fDEDX[i];
136 fSDEDX[i] = s.fSDEDX[i];
137 fNCDEDX[i] = s.fNCDEDX[i];
139 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = s.fOverlapLabels[i];
144 AliTPCseed::AliTPCseed(const AliTPCtrack &t):
147 fClusterOwner(kFALSE),
153 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
154 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
155 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
156 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
159 fCurrentCluster(0x0),
160 fCurrentClusterIndex1(-1),
175 // Constructor from AliTPCtrack
178 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
179 for (Int_t i=0;i<160;i++) {
180 fClusterPointer[i] = 0;
181 Int_t index = t.GetClusterIndex(i);
183 SetClusterIndex2(i,index);
186 SetClusterIndex2(i,-3);
189 for (Int_t i=0;i<4;i++) {
194 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
196 //for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
197 //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
198 fClusterMap.ResetAllBits(kFALSE);
199 fSharedMap.ResetAllBits(kFALSE);
203 AliTPCseed::AliTPCseed(Double_t xr, Double_t alpha, const Double_t xx[5],
204 const Double_t cc[15], Int_t index):
205 AliTPCtrack(xr, alpha, xx, cc, index),
207 fClusterOwner(kFALSE),
213 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
214 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
215 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
216 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
219 fCurrentCluster(0x0),
220 fCurrentClusterIndex1(-1),
238 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
239 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
240 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
241 for (Int_t i=0;i<4;i++) {
246 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
249 AliTPCseed::~AliTPCseed(){
254 for (Int_t icluster=0; icluster<160; icluster++){
255 delete fClusterPointer[icluster];
260 //_________________________________________________
261 AliTPCseed & AliTPCseed::operator=(const AliTPCseed ¶m)
264 // assignment operator
267 AliTPCtrack::operator=(param);
269 for(Int_t i = 0;i<160;++i)fClusterPointer[i] = param.fClusterPointer[i]; // this is not allocated by AliTPCSeed
270 fClusterOwner = param.fClusterOwner;
271 // leave out fPoint, they are also not copied in the copy ctor...
272 // but deleted in the dtor... strange...
274 fSector = param.fSector;
275 fRelativeSector = param.fRelativeSector;
276 fCurrentSigmaY2 = param.fCurrentSigmaY2;
277 fCurrentSigmaZ2 = param.fCurrentSigmaZ2;
278 fErrorY2 = param.fErrorY2;
279 fErrorZ2 = param.fErrorZ2;
280 fCurrentCluster = param.fCurrentCluster; // this is not allocated by AliTPCSeed
281 fCurrentClusterIndex1 = param.fCurrentClusterIndex1;
282 fInDead = param.fInDead;
283 fIsSeeding = param.fIsSeeding;
284 fNoCluster = param.fNoCluster;
286 fBSigned = param.fBSigned;
287 for(Int_t i = 0;i<4;++i){
288 fDEDX[i] = param.fDEDX[i];
289 fSDEDX[i] = param.fSDEDX[i];
290 fNCDEDX[i] = param.fNCDEDX[i];
292 for(Int_t i = 0;i<AliPID::kSPECIES;++i)fTPCr[i] = param.fTPCr[i];
294 fSeedType = param.fSeedType;
295 fSeed1 = param.fSeed1;
296 fSeed2 = param.fSeed2;
297 for(Int_t i = 0;i<12;++i)fOverlapLabels[i] = param.fOverlapLabels[i];
298 fMAngular = param.fMAngular;
299 fCircular = param.fCircular;
300 for(int i = 0;i<160;++i)fTrackPoints[i] = param.fTrackPoints[i];
301 fClusterMap = param.fClusterMap;
302 fSharedMap = param.fSharedMap;
306 //____________________________________________________
307 AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
311 return &fTrackPoints[i];
316 Double_t AliTPCseed::GetDensityFirst(Int_t n)
320 // return cluster for n rows bellow first point
321 Int_t nfoundable = 1;
323 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
324 Int_t index = GetClusterIndex2(i);
325 if (index!=-1) nfoundable++;
326 if (index>0) nfound++;
328 if (nfoundable<n) return 0;
329 return Double_t(nfound)/Double_t(nfoundable);
334 void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
336 // get cluster stat. on given region
341 for (Int_t i=first;i<last; i++){
342 Int_t index = GetClusterIndex2(i);
343 if (index!=-1) foundable++;
344 if (index&0x8000) continue;
345 if (fClusterPointer[i]) {
351 if (fClusterPointer[i]->IsUsed(10)) {
355 if (!plus2) continue; //take also neighborhoud
357 if ( (i>0) && fClusterPointer[i-1]){
358 if (fClusterPointer[i-1]->IsUsed(10)) {
363 if ( fClusterPointer[i+1]){
364 if (fClusterPointer[i+1]->IsUsed(10)) {
372 //Error("AliTPCseed::GetClusterStatistic","problem\n");
380 void AliTPCseed::Reset(Bool_t all)
384 SetNumberOfClusters(0);
387 ResetCovariance(10.);
390 for (Int_t i=0;i<8;i++){
391 delete [] fTrackPoints[i];
399 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
400 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
406 void AliTPCseed::Modify(Double_t factor)
409 //------------------------------------------------------------------
410 //This function makes a track forget its history :)
411 //------------------------------------------------------------------
413 ResetCovariance(10.);
416 ResetCovariance(factor);
418 SetNumberOfClusters(0);
422 fCurrentSigmaY2 = 0.000005;
423 fCurrentSigmaZ2 = 0.000005;
432 Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
434 //-----------------------------------------------------------------
435 // This function find proloncation of a track to a reference plane x=xk.
436 // doesn't change internal state of the track
437 //-----------------------------------------------------------------
439 Double_t x1=GetX(), x2=x1+(xk-x1), dx=x2-x1;
441 if (TMath::Abs(GetSnp()+GetC()*dx) >= AliTPCReconstructor::GetMaxSnpTrack()) {
445 // Double_t y1=fP0, z1=fP1;
446 Double_t c1=GetSnp(), r1=sqrt((1.-c1)*(1.+c1));
447 Double_t c2=c1 + GetC()*dx, r2=sqrt((1.-c2)*(1.+c2));
451 //y += dx*(c1+c2)/(r1+r2);
452 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
454 Double_t dy = dx*(c1+c2)/(r1+r2);
457 Double_t delta = GetC()*dx*(c1+c2)/(c1*r2 + c2*r1);
459 if (TMath::Abs(delta)>0.0001){
460 dz = fP3*TMath::ASin(delta)/fP4;
462 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
465 // dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
466 dz = GetTgl()*TMath::ASin(delta)/GetC();
476 //_____________________________________________________________________________
477 Double_t AliTPCseed::GetPredictedChi2(const AliCluster *c) const
479 //-----------------------------------------------------------------
480 // This function calculates a predicted chi2 increment.
481 //-----------------------------------------------------------------
482 Double_t p[2]={c->GetY(), c->GetZ()};
483 Double_t cov[3]={fErrorY2, 0., fErrorZ2};
485 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
486 if (TMath::Abs(dx)>0){
487 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
489 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
493 return AliExternalTrackParam::GetPredictedChi2(p,cov);
496 //_________________________________________________________________________________________
499 Int_t AliTPCseed::Compare(const TObject *o) const {
500 //-----------------------------------------------------------------
501 // This function compares tracks according to the sector - for given sector according z
502 //-----------------------------------------------------------------
503 AliTPCseed *t=(AliTPCseed*)o;
506 if (t->fRelativeSector>fRelativeSector) return -1;
507 if (t->fRelativeSector<fRelativeSector) return 1;
508 Double_t z2 = t->GetZ();
509 Double_t z1 = GetZ();
511 if (z2<z1) return -1;
516 f2 = 1-20*TMath::Sqrt(t->GetSigma1Pt2())/(t->OneOverPt()+0.0066);
517 if (t->fBConstrain) f2=1.2;
520 f1 = 1-20*TMath::Sqrt(GetSigma1Pt2())/(OneOverPt()+0.0066);
522 if (fBConstrain) f1=1.2;
524 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
532 //_____________________________________________________________________________
533 Bool_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, Int_t index)
535 //-----------------------------------------------------------------
536 // This function associates a cluster with this track.
537 //-----------------------------------------------------------------
538 Int_t n=GetNumberOfClusters();
539 Int_t idx=GetClusterIndex(n); // save the current cluster index
541 AliCluster cl(*c); cl.SetSigmaY2(fErrorY2); cl.SetSigmaZ2(fErrorZ2);
542 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
543 if (TMath::Abs(dx)>0){
544 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
546 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
547 cl.SetY(c->GetY()-dy);
548 cl.SetZ(c->GetZ()-dz);
551 if (!AliTPCtrack::Update(&cl,chisq,index)) return kFALSE;
553 if (fCMeanSigmaY2p30<0){
554 fCMeanSigmaY2p30= c->GetSigmaY2(); //! current mean sigma Y2 - mean30%
555 fCMeanSigmaZ2p30= c->GetSigmaZ2(); //! current mean sigma Z2 - mean30%
556 fCMeanSigmaY2p30R = 1; //! current mean sigma Y2 - mean5%
557 fCMeanSigmaZ2p30R = 1; //! current mean sigma Z2 - mean5%
560 fCMeanSigmaY2p30= 0.70*fCMeanSigmaY2p30 +0.30*c->GetSigmaY2();
561 fCMeanSigmaZ2p30= 0.70*fCMeanSigmaZ2p30 +0.30*c->GetSigmaZ2();
562 if (fCurrentSigmaY2>0){
563 fCMeanSigmaY2p30R = 0.7*fCMeanSigmaY2p30R +0.3*c->GetSigmaY2()/fCurrentSigmaY2;
564 fCMeanSigmaZ2p30R = 0.7*fCMeanSigmaZ2p30R +0.3*c->GetSigmaZ2()/fCurrentSigmaZ2;
568 SetClusterIndex(n,idx); // restore the current cluster index
574 //_____________________________________________________________________________
575 Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t /* onlyused */) {
576 //-----------------------------------------------------------------
577 // This funtion calculates dE/dX within the "low" and "up" cuts.
578 //-----------------------------------------------------------------
579 AliTPCParam *param = AliTPCcalibDB::Instance()->GetParameters();
580 Int_t row0 = param->GetNRowLow();
581 Int_t row1 = row0+param->GetNRowUp1();
582 Int_t row2 = row1+param->GetNRowUp2();
586 fDEDX[0] = CookdEdxNorm(low,up,0 ,i1 ,i2, kTRUE,kFALSE,2,0);
587 fDEDX[1] = CookdEdxNorm(low,up,0 ,0 ,row0,kTRUE,kFALSE,2,0);
588 fDEDX[2] = CookdEdxNorm(low,up,0 ,row0,row1,kTRUE,kFALSE,2,0);
589 fDEDX[3] = CookdEdxNorm(low,up,0 ,row1,row2,kTRUE,kFALSE,2,0);
591 fSDEDX[0] = CookdEdxNorm(low,up,0 ,i1 ,i2, kTRUE,kFALSE,2,1);
592 fSDEDX[1] = CookdEdxNorm(low,up,0 ,0 ,row0,kTRUE,kFALSE,2,1);
593 fSDEDX[2] = CookdEdxNorm(low,up,0 ,row0,row1,kTRUE,kFALSE,2,1);
594 fSDEDX[3] = CookdEdxNorm(low,up,0 ,row1,row2,kTRUE,kFALSE,2,1);
596 fNCDEDX[0] = TMath::Nint(CookdEdxNorm(low,up,0 ,i1 ,i2, kTRUE,kFALSE,2,2));
597 fNCDEDX[1] = TMath::Nint(CookdEdxNorm(low,up,0 ,0 ,row0,kTRUE,kFALSE,2,2));
598 fNCDEDX[2] = TMath::Nint(CookdEdxNorm(low,up,0 ,row0,row1,kTRUE,kFALSE,2,2));
599 fNCDEDX[3] = TMath::Nint(CookdEdxNorm(low,up,0 ,row1,row2,kTRUE,kFALSE,2,2));
604 // return CookdEdxNorm(low,up,0,i1,i2,1,0,2);
608 // Float_t angular[200];
609 // Float_t weight[200];
612 // Float_t meanlog = 100.;
614 // Float_t mean[4] = {0,0,0,0};
615 // Float_t sigma[4] = {1000,1000,1000,1000};
616 // Int_t nc[4] = {0,0,0,0};
617 // Float_t norm[4] = {1000,1000,1000,1000};
622 // Float_t gainGG = 1;
623 // if (AliTPCcalibDB::Instance()->GetParameters()){
624 // gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000.; //relative gas gain
628 // for (Int_t of =0; of<4; of++){
629 // for (Int_t i=of+i1;i<i2;i+=4)
631 // Int_t clindex = fIndex[i];
632 // if (clindex<0||clindex&0x8000) continue;
634 // //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
635 // AliTPCTrackerPoint * point = GetTrackPoint(i);
636 // //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
637 // //AliTPCTrackerPoint * pointp = 0;
638 // //if (i<159) pointp = GetTrackPoint(i+1);
640 // if (point==0) continue;
641 // AliTPCclusterMI * cl = fClusterPointer[i];
642 // if (cl==0) continue;
643 // if (onlyused && (!cl->IsUsed(10))) continue;
644 // if (cl->IsUsed(11)) {
648 // Int_t type = cl->GetType();
649 // //if (point->fIsShared){
654 // // if (pointm->fIsShared) continue;
656 // // if (pointp->fIsShared) continue;
658 // if (type<0) continue;
659 // //if (type>10) continue;
660 // //if (point->GetErrY()==0) continue;
661 // //if (point->GetErrZ()==0) continue;
663 // //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
664 // //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
665 // //if ((ddy*ddy+ddz*ddz)>10) continue;
668 // // if (point->GetCPoint().GetMax()<5) continue;
669 // if (cl->GetMax()<5) continue;
670 // Float_t angley = point->GetAngleY();
671 // Float_t anglez = point->GetAngleZ();
673 // Float_t rsigmay2 = point->GetSigmaY();
674 // Float_t rsigmaz2 = point->GetSigmaZ();
678 // rsigmay += pointm->GetTPoint().GetSigmaY();
679 // rsigmaz += pointm->GetTPoint().GetSigmaZ();
683 // rsigmay += pointp->GetTPoint().GetSigmaY();
684 // rsigmaz += pointp->GetTPoint().GetSigmaZ();
691 // Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
693 // Float_t ampc = 0; // normalization to the number of electrons
695 // // ampc = 1.*point->GetCPoint().GetMax();
696 // ampc = 1.*cl->GetMax();
697 // //ampc = 1.*point->GetCPoint().GetQ();
698 // // AliTPCClusterPoint & p = point->GetCPoint();
699 // // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
700 // // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
702 // // TMath::Abs( Int_t(iz) - iz + 0.5);
703 // //ampc *= 1.15*(1-0.3*dy);
704 // //ampc *= 1.15*(1-0.3*dz);
705 // // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
709 // //ampc = 1.0*point->GetCPoint().GetMax();
710 // ampc = 1.0*cl->GetMax();
711 // //ampc = 1.0*point->GetCPoint().GetQ();
712 // //AliTPCClusterPoint & p = point->GetCPoint();
713 // // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
714 // //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
716 // // TMath::Abs( Int_t(iz) - iz + 0.5);
718 // //ampc *= 1.15*(1-0.3*dy);
719 // //ampc *= 1.15*(1-0.3*dz);
720 // // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
724 // ampc *= 2.0; // put mean value to channel 50
725 // //ampc *= 0.58; // put mean value to channel 50
727 // // if (type>0) w = 1./(type/2.-0.5);
728 // // Float_t z = TMath::Abs(cl->GetZ());
731 // //ampc /= (1+0.0008*z);
735 // //ampc /= (1+0.0008*z);
737 // //ampc /= (1+0.0008*z);
740 // if (type<0) { //amp at the border - lower weight
745 // if (rsigma>1.5) ampc/=1.3; // if big backround
746 // amp[nc[of]] = ampc;
747 // amp[nc[of]] /=gainGG;
748 // angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
749 // weight[nc[of]] = w;
753 // TMath::Sort(nc[of],amp,index,kFALSE);
755 // Float_t sumamp2=0;
757 // //meanlog = amp[index[Int_t(nc[of]*0.33)]];
759 // for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
760 // Float_t ampl = amp[index[i]]/angular[index[i]];
761 // ampl = meanlog*TMath::Log(1.+ampl/meanlog);
763 // sumw += weight[index[i]];
764 // sumamp += weight[index[i]]*ampl;
765 // sumamp2 += weight[index[i]]*ampl*ampl;
766 // norm[of] += angular[index[i]]*weight[index[i]];
773 // mean[of] = sumamp/sumw;
774 // sigma[of] = sumamp2/sumw-mean[of]*mean[of];
775 // if (sigma[of]>0.1)
776 // sigma[of] = TMath::Sqrt(sigma[of]);
780 // mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
781 // //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
782 // //mean *=(1-0.1*(norm-1.));
789 // // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
790 // // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
793 // // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
794 // // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
798 // for (Int_t i =0;i<4;i++){
799 // if (nc[i]>2&&nc[i]<1000){
800 // dedx += mean[i] *nc[i];
801 // fSdEdx += sigma[i]*(nc[i]-2);
802 // fMAngular += norm[i] *nc[i];
806 // fDEDX[i] = mean[i];
807 // fSDEDX[i] = sigma[i];
808 // fNCDEDX[i]= nc[i];
820 // // Float_t dedx1 =dedx;
823 // for (Int_t i =0;i<4;i++){
824 // if (nc[i]>2&&nc[i]<1000){
825 // mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
826 // dedx += mean[i] *nc[i];
828 // fDEDX[i] = mean[i];
838 void AliTPCseed::CookPID()
841 // cook PID information according dEdx
843 Double_t fRange = 10.;
847 Int_t ns=AliPID::kSPECIES;
849 for (Int_t j=0; j<ns; j++) {
850 Double_t mass=AliPID::ParticleMass(j);
852 Double_t dedx=fdEdx/fMIP;
853 Double_t bethe=AliMathBase::BetheBlochAleph(mom/mass);
854 Double_t sigma=fRes*bethe;
856 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
857 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
861 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
869 for (Int_t j=0; j<ns; j++) {
870 fTPCr[j]/=sumr; //normalize
874 Double_t AliTPCseed::GetYat(Double_t xk) const {
875 //-----------------------------------------------------------------
876 // This function calculates the Y-coordinate of a track at the plane x=xk.
877 //-----------------------------------------------------------------
878 if (TMath::Abs(GetSnp())>AliTPCReconstructor::GetMaxSnpTrack()) return 0.; //patch 01 jan 06
879 Double_t c1=GetSnp(), r1=TMath::Sqrt((1.-c1)*(1.+c1));
880 Double_t c2=c1+GetC()*(xk-GetX());
881 if (TMath::Abs(c2)>AliTPCReconstructor::GetMaxSnpTrack()) return 0;
882 Double_t r2=TMath::Sqrt((1.-c2)*(1.+c2));
883 return GetY() + (xk-GetX())*(c1+c2)/(r1+r2);
886 void AliTPCseed::SetClusterMapBit(int ibit, Bool_t state)
888 fClusterMap[ibit] = state;
890 Bool_t AliTPCseed::GetClusterMapBit(int ibit)
892 return fClusterMap[ibit];
894 void AliTPCseed::SetSharedMapBit(int ibit, Bool_t state)
896 fSharedMap[ibit] = state;
898 Bool_t AliTPCseed::GetSharedMapBit(int ibit)
900 return fSharedMap[ibit];
907 Float_t AliTPCseed::CookdEdxNorm(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, Bool_t shapeNorm,Int_t posNorm, Int_t padNorm, Int_t returnVal){
910 // calculates dedx using the cluster
911 // low - up specify trunc mean range - default form 0-0.7
912 // type - 1 - max charge or 0- total charge in cluster
913 // //2- max no corr 3- total+ correction
914 // i1-i2 - the pad-row range used for calculation
915 // shapeNorm - kTRUE -taken from OCDB
917 // posNorm - usage of pos normalization
918 // padNorm - pad type normalization
919 // returnVal - 0 return mean
921 // - 2 return number of clusters
923 // normalization parametrization taken from AliTPCClusterParam
925 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
926 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
927 if (!parcl) return 0;
928 if (!param) return 0;
929 Int_t row0 = param->GetNRowLow();
930 Int_t row1 = row0+param->GetNRowUp1();
937 Float_t gainGG = 1; // gas gain factor -always enabled
938 Float_t gainPad = 1; // gain map - used always
939 Float_t corrShape = 1; // correction due angular effect, diffusion and electron attachment
940 Float_t corrPos = 1; // local position correction - if posNorm enabled
941 Float_t corrPadType = 1; // pad type correction - if padNorm enabled
942 Float_t corrNorm = 1; // normalization factor - set Q to channel 50
946 if (AliTPCcalibDB::Instance()->GetParameters()){
947 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
950 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
951 const Float_t kedgey =3.;
954 for (Int_t irow=i1; irow<i2; irow++){
955 AliTPCclusterMI* cluster = GetClusterPointer(irow);
956 if (!cluster) continue;
957 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
958 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
960 if (irow>=row0) ipad=1;
961 if (irow>=row1) ipad=2;
965 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
968 // Get gainPad - pad by pad calibration
971 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
972 if (irow < row0) { // IROC
973 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
975 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
977 if (factor>0.5) gainPad=factor;
980 //do position and angular normalization
985 AliTPCTrackerPoint * point = GetTrackPoint(irow);
986 Float_t ty = TMath::Abs(point->GetAngleY());
987 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
989 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
990 corrShape = parcl->Qnorm(ipad,type,dr,ty,tz);
996 // Do position normalization - relative distance to
997 // center of pad- time bin
999 // corrPos = parcl->QnormPos(ipad,type, cluster->GetPad(),
1000 // cluster->GetTimeBin(), cluster->GetZ(),
1001 // cluster->GetSigmaY2(),cluster->GetSigmaZ2(),
1002 // cluster->GetMax(),cluster->GetQ());
1003 // scaled response function
1004 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
1005 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1008 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1009 Float_t ty = TMath::Abs(point->GetAngleY());
1010 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1012 if (type==1) corrPos =
1013 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1014 cluster->GetTimeBin(),ty,tz,yres0,zres0,0.4);
1015 if (type==0) corrPos =
1016 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1017 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,0.4);
1019 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
1020 Double_t signtgl = (cluster->GetZ()*point->GetAngleZ()>0)? 1:-1;
1021 Double_t p2 = TMath::Abs(TMath::Sin(TMath::ATan(ty)));
1022 Float_t corrHis = parcl->QnormHis(ipad,type,dr,p2,TMath::Abs(point->GetAngleZ())*signtgl);
1023 if (corrHis>0) corrPos*=corrHis;
1030 if (type==0 && parcl->fQpadTnorm) corrPadType = (*parcl->fQpadTnorm)[ipad];
1031 if (type==1 && parcl->fQpadTnorm) corrPadType = (*parcl->fQpadMnorm)[ipad];
1035 corrPadType =param->GetPadPitchLength(cluster->GetDetector(),cluster->GetRow());
1036 //use hardwired - temp fix
1037 if (type==0) corrNorm=3.;
1038 if (type==1) corrNorm=1.;
1044 amp[ncl]/=corrShape;
1045 amp[ncl]/=corrPadType;
1052 if (type>3) return ncl;
1053 TMath::Sort(ncl,amp, indexes, kFALSE);
1055 if (ncl<10) return 0;
1060 Int_t icl0=TMath::Nint(ncl*low);
1061 Int_t icl1=TMath::Nint(ncl*up);
1062 for (Int_t icl=icl0; icl<icl1;icl++){
1063 suma+=amp[indexes[icl]];
1064 suma2+=amp[indexes[icl]]*amp[indexes[icl]];
1067 Float_t mean =suma/sumn;
1068 Float_t rms =TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1069 if (returnVal==1) return rms;
1070 if (returnVal==2) return ncl;
1074 Float_t AliTPCseed::CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, Int_t returnVal){
1077 // calculates dedx using the cluster
1078 // low - up specify trunc mean range - default form 0-0.7
1079 // type - 1 - max charge or 0- total charge in cluster
1080 // //2- max no corr 3- total+ correction
1081 // i1-i2 - the pad-row range used for calculation
1083 // posNorm - usage of pos normalization
1084 // returnVal - 0 return mean
1086 // - 2 return number of clusters
1088 // normalization parametrization taken from AliTPCClusterParam
1090 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
1091 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
1092 if (!parcl) return 0;
1093 if (!param) return 0;
1094 Int_t row0 = param->GetNRowLow();
1095 Int_t row1 = row0+param->GetNRowUp1();
1102 Float_t gainGG = 1; // gas gain factor -always enabled
1103 Float_t gainPad = 1; // gain map - used always
1104 Float_t corrPos = 1; // local position correction - if posNorm enabled
1105 Float_t corrNorm = 1; // normalization factor - set Q to channel 50
1109 if (AliTPCcalibDB::Instance()->GetParameters()){
1110 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
1113 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1114 const Float_t kedgey =3.;
1117 for (Int_t irow=i1; irow<i2; irow++){
1118 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1119 if (!cluster) continue;
1120 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
1121 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
1123 if (irow>=row0) ipad=1;
1124 if (irow>=row1) ipad=2;
1128 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
1131 // Get gainPad - pad by pad calibration
1134 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
1135 if (irow < row0) { // IROC
1136 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
1138 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
1140 if (factor>0.5) gainPad=factor;
1144 // Do position normalization - relative distance to
1145 // center of pad- time bin
1147 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1148 Float_t ty = TMath::Abs(point->GetAngleY());
1149 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1150 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
1151 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1153 yres0 *=parcl->GetQnormCorr(ipad, type,0);
1154 zres0 *=parcl->GetQnormCorr(ipad, type,1);
1155 Float_t effLength=parcl->GetQnormCorr(ipad, type,4)*0.5;
1156 Float_t effDiff =(parcl->GetQnormCorr(ipad, type,2)+parcl->GetQnormCorr(ipad, type,3))*0.5;
1159 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1160 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1161 cluster->GetTimeBin(),ty,tz,yres0,zres0,effLength,effDiff);
1162 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1163 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1164 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1165 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1169 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1170 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1171 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,effLength,effDiff);
1173 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1174 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1175 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1176 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1189 if (type>3) return ncl;
1190 TMath::Sort(ncl,amp, indexes, kFALSE);
1192 if (ncl<10) return 0;
1197 Int_t icl0=TMath::Nint(ncl*low);
1198 Int_t icl1=TMath::Nint(ncl*up);
1199 for (Int_t icl=icl0; icl<icl1;icl++){
1200 suma+=amp[indexes[icl]];
1201 suma2+=amp[indexes[icl]]*amp[indexes[icl]];
1204 Float_t mean =suma/sumn;
1205 Float_t rms =TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1206 if (returnVal==1) return rms;
1207 if (returnVal==2) return ncl;
1214 Float_t AliTPCseed::CookShape(Int_t type){
1218 //-----------------------------------------------------------------
1219 // This funtion calculates dE/dX within the "low" and "up" cuts.
1220 //-----------------------------------------------------------------
1223 for (Int_t i =0; i<160;i++) {
1224 AliTPCTrackerPoint * point = GetTrackPoint(i);
1225 if (point==0) continue;
1227 AliTPCclusterMI * cl = fClusterPointer[i];
1228 if (cl==0) continue;
1230 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1231 Float_t rsigmaz = TMath::Sqrt(point->GetSigmaZ());
1232 Float_t rsigma = (rsigmay+rsigmaz)*0.5;
1233 if (type==0) means+=rsigma;
1234 if (type==1) means+=rsigmay;
1235 if (type==2) means+=rsigmaz;
1238 Float_t mean = (meanc>0)? means/meanc:0;
1244 Int_t AliTPCseed::RefitTrack(AliTPCseed *seed, AliExternalTrackParam * parin, AliExternalTrackParam * parout){
1247 // return value - number of used clusters
1250 const Int_t kMinNcl =10;
1251 AliTPCseed *track=new AliTPCseed(*seed);
1256 for (Int_t i=0;i<15;i++) covar[i]=0;
1259 covar[5]=10.*10./(64.*64.);
1260 covar[9]=10.*10./(64.*64.);
1264 Float_t xmin=1000, xmax=-10000;
1265 Int_t imin=158, imax=0;
1266 for (Int_t i=0;i<160;i++) {
1267 AliTPCclusterMI *c=track->GetClusterPointer(i);
1269 if (sector<0) sector = c->GetDetector();
1270 if (c->GetX()<xmin) xmin=c->GetX();
1271 if (c->GetX()>xmax) xmax=c->GetX();
1275 if(imax-imin<kMinNcl) {
1279 // Not succes to rotate
1280 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1286 // fit from inner to outer row
1288 AliExternalTrackParam paramIn;
1289 AliExternalTrackParam paramOut;
1295 for (Int_t i=imin; i<=imax; i++){
1296 AliTPCclusterMI *c=track->GetClusterPointer(i);
1298 // if (RejectCluster(c,track)) continue;
1299 sector = (c->GetDetector()%18);
1300 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1303 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1304 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1305 if (!track->PropagateTo(r[0])) {
1308 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1310 if (!isOK) { delete track; return 0;}
1311 track->AddCovariance(covar);
1315 for (Int_t i=imax; i>=imin; i--){
1316 AliTPCclusterMI *c=track->GetClusterPointer(i);
1318 //if (RejectCluster(c,track)) continue;
1319 sector = (c->GetDetector()%18);
1320 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1323 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1324 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1325 if (!track->PropagateTo(r[0])) {
1328 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1330 //if (!isOK) { delete track; return 0;}
1332 track->AddCovariance(covar);
1335 for (Int_t i=imin; i<=imax; i++){
1336 AliTPCclusterMI *c=track->GetClusterPointer(i);
1338 sector = (c->GetDetector()%18);
1339 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1343 //if (RejectCluster(c,track)) continue;
1344 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1345 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1346 if (!track->PropagateTo(r[0])) {
1349 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1351 //if (!isOK) { delete track; return 0;}
1356 if (parin) (*parin)=paramIn;
1357 if (parout) (*parout)=paramOut;
1363 Bool_t AliTPCseed::RefitTrack(AliTPCseed* /*seed*/, Bool_t /*out*/){
1375 void AliTPCseed::GetError(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1376 Double_t& erry, Double_t &errz)
1379 // Get cluster error at given position
1381 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1383 Double_t snp1=param->GetSnp();
1384 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1386 Double_t tgl1=param->GetTgl();
1387 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1389 Int_t padSize = 0; // short pads
1390 if (cluster->GetDetector() >= 36) {
1391 padSize = 1; // medium pads
1392 if (cluster->GetRow() > 63) padSize = 2; // long pads
1395 erry = clusterParam->GetError0Par( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany) );
1396 errz = clusterParam->GetError0Par( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) );
1400 void AliTPCseed::GetShape(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1401 Double_t& rmsy, Double_t &rmsz)
1404 // Get cluster error at given position
1406 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1408 Double_t snp1=param->GetSnp();
1409 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1411 Double_t tgl1=param->GetTgl();
1412 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
1414 Int_t padSize = 0; // short pads
1415 if (cluster->GetDetector() >= 36) {
1416 padSize = 1; // medium pads
1417 if (cluster->GetRow() > 63) padSize = 2; // long pads
1420 rmsy = clusterParam->GetRMSQ( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany), TMath::Abs(cluster->GetMax()) );
1421 rmsz = clusterParam->GetRMSQ( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) ,TMath::Abs(cluster->GetMax()));
1426 Double_t AliTPCseed::GetQCorrGeom(Float_t ty, Float_t tz){
1428 //ty - tangent in local y direction
1431 Float_t norm=TMath::Sqrt(1+ty*ty+tz*tz);
1435 Double_t AliTPCseed::GetQCorrShape(Int_t ipad, Int_t type,Float_t z, Float_t ty, Float_t tz, Float_t /*q*/, Float_t /*thr*/){
1439 // return value = Q Normalization factor
1440 // Normalization - 1 - shape factor part for full drift
1441 // 1 - electron attachment for 0 drift
1443 // Input parameters:
1445 // ipad - 0 short pad
1452 //z - z position (-250,250 cm)
1453 //ty - tangent in local y direction
1457 AliTPCClusterParam * paramCl = AliTPCcalibDB::Instance()->GetClusterParam();
1458 AliTPCParam * paramTPC = AliTPCcalibDB::Instance()->GetParameters();
1460 if (!paramCl) return 1;
1462 Double_t dr = 250.-TMath::Abs(z);
1463 Double_t sy = paramCl->GetRMS0( 0,ipad, dr, TMath::Abs(ty));
1464 Double_t sy0= paramCl->GetRMS0(0,ipad, 250, 0);
1465 Double_t sz = paramCl->GetRMS0( 1,ipad, dr, TMath::Abs(tz));
1466 Double_t sz0= paramCl->GetRMS0(1,ipad, 250, 0);
1468 Double_t sfactorMax = TMath::Sqrt(sy0*sz0/(sy*sz));
1471 Double_t dt = 1000000*(dr/paramTPC->GetDriftV()); //time in microsecond
1472 Double_t attProb = TMath::Exp(-paramTPC->GetAttCoef()*paramTPC->GetOxyCont()*dt);
1475 if (type==0) return sfactorMax*attProb;