]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITStrackerMI.cxx
Bug fix in method RefitAt: the cluster with index 0 was rejected (A. Dainese)
[u/mrichter/AliRoot.git] / ITS / AliITStrackerMI.cxx
index 6ead043a64d75f66948b5b8f925a9ebf18896ef2..0323d1f4ac46e8b043d0bf9415d242fb868beb03 100644 (file)
@@ -33,7 +33,7 @@
 #include "AliV0.h"
 #include "AliHelix.h"
 #include "AliITSRecPoint.h"
-#include "AliITSgeom.h"
+#include "AliITSgeomTGeo.h"
 #include "AliITStrackerMI.h"
 #include "AliTrackPointArray.h"
 #include "AliAlignObj.h"
@@ -61,7 +61,7 @@ fDebugStreamer(0){
 }
 
 
-AliITStrackerMI::AliITStrackerMI(const AliITSgeom *geom) : AliTracker(),
+AliITStrackerMI::AliITStrackerMI(const Char_t *geom) : AliTracker(),
 fI(kMaxLayer),
 fBestTrack(),
 fTrackToFollow(),
@@ -78,25 +78,28 @@ fDebugStreamer(0){
   //--------------------------------------------------------------------
   //This is the AliITStrackerMI constructor
   //--------------------------------------------------------------------
+  if (geom) {
+    AliWarning("\"geom\" is actually a dummy argument !");
+  }
+
   fCoeficients = 0;
   fAfterV0     = kFALSE;
-  AliITSgeom *g=(AliITSgeom*)geom;
-  Float_t x,y,z;
-  Int_t i;
-  for (i=1; i<kMaxLayer+1; i++) {
-    Int_t nlad=g->GetNladders(i);
-    Int_t ndet=g->GetNdetectors(i);
-
-    g->GetTrans(i,1,1,x,y,z); 
-    Double_t r=TMath::Sqrt(x*x + y*y);
+
+  for (Int_t i=1; i<kMaxLayer+1; i++) {
+    Int_t nlad=AliITSgeomTGeo::GetNLadders(i);
+    Int_t ndet=AliITSgeomTGeo::GetNDetectors(i);
+
+    Double_t xyz[3], &x=xyz[0], &y=xyz[1], &z=xyz[2];
+    AliITSgeomTGeo::GetOrigTranslation(i,1,1,xyz); 
     Double_t poff=TMath::ATan2(y,x);
     Double_t zoff=z;
+    Double_t r=TMath::Sqrt(x*x + y*y);
 
-    g->GetTrans(i,1,2,x,y,z);
+    AliITSgeomTGeo::GetOrigTranslation(i,1,2,xyz);
     r += TMath::Sqrt(x*x + y*y);
-    g->GetTrans(i,2,1,x,y,z);
+    AliITSgeomTGeo::GetOrigTranslation(i,2,1,xyz);
     r += TMath::Sqrt(x*x + y*y);
-    g->GetTrans(i,2,2,x,y,z);
+    AliITSgeomTGeo::GetOrigTranslation(i,2,2,xyz);
     r += TMath::Sqrt(x*x + y*y);
     r*=0.25;
 
@@ -104,14 +107,16 @@ fDebugStreamer(0){
 
     for (Int_t j=1; j<nlad+1; j++) {
       for (Int_t k=1; k<ndet+1; k++) { //Fill this layer with detectors
-        Float_t x,y,zshift; g->GetTrans(i,j,k,x,y,zshift); 
-        Double_t rot[9]; g->GetRotMatrix(i,j,k,rot);
+        TGeoHMatrix m; AliITSgeomTGeo::GetOrigMatrix(i,j,k,m);
+        const TGeoHMatrix *tm=AliITSgeomTGeo::GetTracking2LocalMatrix(i,j,k);
+        m.Multiply(tm);
+        Double_t txyz[3]={0.}, xyz[3]={0.};
+        m.LocalToMaster(txyz,xyz);
+        Double_t r=TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
+        Double_t phi=TMath::ATan2(xyz[1],xyz[0]);
 
-        Double_t phi=TMath::ATan2(rot[1],rot[0])+TMath::Pi();
-        phi+=TMath::Pi()/2;
-        if (i==1) phi+=TMath::Pi();
-        Double_t cp=TMath::Cos(phi), sp=TMath::Sin(phi);
-        Double_t r=x*cp+y*sp;
+        if (phi<0) phi+=TMath::TwoPi();
+        else if (phi>=TMath::TwoPi()) phi-=TMath::TwoPi();
 
         AliITSdetector &det=fgLayers[i-1].GetDetector((j-1)*ndet + k-1); 
         new(&det) AliITSdetector(r,phi); 
@@ -204,9 +209,13 @@ Int_t AliITStrackerMI::LoadClusters(TTree *cTree) {
       if (!cTree->GetEvent(j)) continue;
       Int_t ncl=clusters->GetEntriesFast();
       SignDeltas(clusters,GetZ());
       while (ncl--) {
         AliITSRecPoint *c=(AliITSRecPoint*)clusters->UncheckedAt(ncl);
-       detector = c->GetDetectorIndex();
+        detector=c->GetDetectorIndex();
+
+       if (!c->Misalign()) AliWarning("Can't misalign this cluster !");
+
         fgLayers[i].InsertCluster(new AliITSRecPoint(*c));
       }
       clusters->Delete();
@@ -214,7 +223,7 @@ Int_t AliITStrackerMI::LoadClusters(TTree *cTree) {
       if (i<2){
        for (Float_t ydead = 0; ydead < 1.31 ; ydead+=(i+1.)*0.018){     
          Int_t lab[4] = {0,0,0,detector};
-         Int_t info[3] = {0,0,0};
+         Int_t info[3] = {0,0,i};
          Float_t hit[5]={0,0,0.004/12.,0.001/12.,0};
          if (i==0) hit[0] =ydead-0.4;
          if (i==1) hit[0]=ydead-3.75; 
@@ -573,26 +582,18 @@ Bool_t AliITStrackerMI::GetTrackPoint(Int_t index, AliTrackPoint& p) const {
   //
   // Get track space point with index i
   //
+
   Int_t l=(index & 0xf0000000) >> 28;
   Int_t c=(index & 0x0fffffff) >> 00;
   AliITSRecPoint *cl = fgLayers[l].GetCluster(c);
   Int_t idet = cl->GetDetectorIndex();
-  const AliITSdetector &det = fgLayers[l].GetDetector(idet);
-  Float_t phi = det.GetPhi();
-  Float_t r = det.GetR();
-  Float_t cp=TMath::Cos(phi), sp=TMath::Sin(phi);
+
   Float_t xyz[3];
-  xyz[0] = r*cp - cl->GetY()*sp;
-  xyz[1] = r*sp + cl->GetY()*cp;
-  xyz[2] = cl->GetZ();
   Float_t cov[6];
-  cov[0] = sp*sp*cl->GetSigmaY2();
-  cov[1] = -sp*cp*cl->GetSigmaY2();
-  cov[2] = 0.;
-  cov[3] = cp*cp*cl->GetSigmaY2();
-  cov[4] = 0.;
-  cov[5] = cl->GetSigmaZ2();
-  p.SetXYZ(xyz[0],xyz[1],xyz[2],cov);
+  cl->GetGlobalXYZ(xyz);
+  cl->GetGlobalCov(cov);
+  p.SetXYZ(xyz, cov);
+
   AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer; 
   switch (l) {
   case 0:
@@ -641,12 +642,12 @@ void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdin
       AliESDv0 * vertex = fEsd->GetV0(index);
       if (vertex->GetStatus()<0) continue;     // rejected V0
       //
-      if (esd->GetSign()>0) {
-        vertex->SetIndex(0,esdindex);
-      }
-      else{
-        vertex->SetIndex(1,esdindex);
-      }
+            if (esd->GetSign()>0) {
+              vertex->SetIndex(0,esdindex);
+            }
+            else{
+              vertex->SetIndex(1,esdindex);
+            }
     }
   }
   TObjArray *bestarray = (TObjArray*)fBestHypothesys.At(esdindex);
@@ -702,13 +703,10 @@ void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdin
          continue;
        }
       }
-      //
-      //find intersection with layer
-      Double_t x,y,z;  
-      if (!currenttrack1.GetGlobalXYZat(r,x,y,z)) {
-       continue;
-      }
-      Double_t phi=TMath::ATan2(y,x);
+
+      Double_t phi,z;
+      if (!currenttrack1.GetPhiZat(r,phi,z)) continue;
+
       Int_t idet=layer.FindDetectorIndex(phi,z);
       if (idet<0) {
        continue;
@@ -954,7 +952,8 @@ void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdin
        vertex->SetIndex(1,esdindex);
       }
       //find nearest layer with track info
-      Int_t nearestold  = GetNearestLayer(vertex->GetXrp());
+      Double_t xrp[3]; vertex->GetXYZ(xrp[0],xrp[1],xrp[2]);  //I.B.
+      Int_t nearestold  = GetNearestLayer(xrp);               //I.B.
       Int_t nearest     = nearestold; 
       for (Int_t ilayer =nearest;ilayer<8;ilayer++){
        if (ntracks[nearest]==0){
@@ -967,12 +966,12 @@ void AliITStrackerMI::FollowProlongationTree(AliITStrackMI * otrack, Int_t esdin
        Bool_t accept = track.GetNormChi2(nearest)<10; 
        if (accept){
          if (track.GetSign()>0) {
-           vertex->SetP(track);
+           vertex->SetParamP(track);
            vertex->Update(fprimvertex);
            //      vertex->SetIndex(0,track.fESDtrack->GetID()); 
            if (track.GetNumberOfClusters()>2) AddTrackHypothesys(new AliITStrackMI(track), esdindex);
          }else{
-           vertex->SetM(track);
+           vertex->SetParamN(track);
            vertex->Update(fprimvertex);
            //vertex->SetIndex(1,track.fESDtrack->GetID());
            if (track.GetNumberOfClusters()>2) AddTrackHypothesys(new AliITStrackMI(track), esdindex);
@@ -1402,7 +1401,12 @@ FindDetectorIndex(Double_t phi, Double_t z) const {
   //--------------------------------------------------------------------
   //This function finds the detector crossed by the track
   //--------------------------------------------------------------------
-  Double_t dphi=-(phi-fPhiOffset);
+  Double_t dphi;
+  if (fZOffset<0)            // old geometry
+    dphi = -(phi-fPhiOffset);
+  else                       // new geometry
+    dphi = phi-fPhiOffset;
+
   if      (dphi <  0) dphi += 2*TMath::Pi();
   else if (dphi >= 2*TMath::Pi()) dphi -= 2*TMath::Pi();
   Int_t np=Int_t(dphi*fNladders*0.5/TMath::Pi()+0.5);
@@ -1650,15 +1654,14 @@ Bool_t AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *t,
      }
      //
 
-     Double_t x,y,z;
-     if (!t->GetGlobalXYZat(r,x,y,z)) { 
-       return kFALSE;
-     }
-     Double_t phi=TMath::ATan2(y,x);
+     Double_t phi,z;
+     if (!t->GetPhiZat(r,phi,z)) return kFALSE;
+
      Int_t idet=layer.FindDetectorIndex(phi,z);
      if (idet<0) { 
        return kFALSE;
      }
+
      const AliITSdetector &det=layer.GetDetector(idet);
      phi=det.GetPhi();
      if (!t->Propagate(phi,det.GetR())) {
@@ -1670,7 +1673,7 @@ Bool_t AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *t,
      Double_t maxchi2=1000.*kMaxChi2;
 
      Int_t idx=index[i];
-     if (idx>0) {
+     if (idx>=0) {
         const AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(idx); 
        if (c){
          if (idet != c->GetDetectorIndex()) {
@@ -1798,12 +1801,9 @@ AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *t,const Int_t *clindex) {
         t->GetGlobalXYZat(t->GetX(),oldX,oldY,oldZ);
      }
      //
+     Double_t phi,z;
+     if (!t->GetPhiZat(r,phi,z)) return kFALSE;
 
-     Double_t x,y,z;
-     if (!t->GetGlobalXYZat(r,x,y,z)) { 
-       return kFALSE;
-     }
-     Double_t phi=TMath::ATan2(y,x);
      Int_t idet=layer.FindDetectorIndex(phi,z);
      if (idet<0) { 
        return kFALSE;
@@ -1819,7 +1819,7 @@ AliITStrackerMI::RefitAt(Double_t xx,AliITStrackMI *t,const Int_t *clindex) {
      Double_t maxchi2=1000.*kMaxChi2;
 
      Int_t idx=index[i];
-     if (idx>0) {
+     if (idx>=0) {
         const AliITSRecPoint *c=(AliITSRecPoint *)GetCluster(idx); 
        if (c){
          if (idet != c->GetDetectorIndex()) {
@@ -3204,6 +3204,13 @@ Int_t    AliITStrackerMI::UpdateMI(AliITStrackMI* track, const AliITSRecPoint* c
     chi2+= (0.5-track->GetNormQ(layer)/track->GetExpQ())*10.;
     track->SetdEdxMismatch(track->GetdEdxMismatch()+(0.5-track->GetNormQ(layer)/track->GetExpQ())*10.);
   }
+
+  if (cl->GetQ()<=0) return 0;  // ingore the "virtual" clusters
+
+  // Take into account the mis-alignment
+  Double_t x=track->GetX()+cl->GetX();
+  if (!track->PropagateTo(x,0.,0.)) return 0;
+  
   return track->UpdateMI(cl->GetY(),cl->GetZ(),track->GetSigmaY(layer),track->GetSigmaZ(layer),chi2,index);
 }
 
@@ -3538,7 +3545,8 @@ void AliITStrackerMI::UpdateTPCV0(AliESD *event){
     }
     if (vertex->GetStatus()==-100) continue;
     //
-    Int_t clayer = GetNearestLayer(vertex->GetXrp());
+    Double_t xrp[3]; vertex->GetXYZ(xrp[0],xrp[1],xrp[2]);  //I.B.
+    Int_t clayer = GetNearestLayer(xrp);                    //I.B.
     vertex->SetNBefore(clayer);        //
     vertex->SetChi2Before(9*clayer);   //
     vertex->SetNAfter(6-clayer);       //
@@ -3948,20 +3956,20 @@ void  AliITStrackerMI::FindV02(AliESD *event)
       }      
       //
       //
-      pvertex->SetM(*track0);
-      pvertex->SetP(*track1);
+      pvertex->SetParamN(*track0);
+      pvertex->SetParamP(*track1);
       pvertex->Update(primvertex);
       pvertex->SetClusters(track0->ClIndex(),track1->ClIndex());  // register clusters
 
       if (pvertex->GetRr()<kMinR) continue;
       if (pvertex->GetRr()>kMaxR) continue;
-      if (pvertex->GetPointAngle()<kMinPointAngle) continue;
-      if (pvertex->GetDist2()>maxDist) continue;
-      pvertex->SetLab(0,track0->GetLabel());
-      pvertex->SetLab(1,track1->GetLabel());
+      if (pvertex->GetV0CosineOfPointingAngle()<kMinPointAngle) continue;
+//Bo:      if (pvertex->GetDist2()>maxDist) continue;
+      if (pvertex->GetDcaV0Daughters()>maxDist) continue;
+//Bo:        pvertex->SetLab(0,track0->GetLabel());
+//Bo:        pvertex->SetLab(1,track1->GetLabel());
       pvertex->SetIndex(0,track0->GetESDtrack()->GetID());
       pvertex->SetIndex(1,track1->GetESDtrack()->GetID());
-      
       //      
       AliITStrackMI * htrackc0 = trackc0 ? trackc0:dummy;      
       AliITStrackMI * htrackc1 = trackc1 ? trackc1:dummy;
@@ -3984,7 +3992,8 @@ void  AliITStrackerMI::FindV02(AliESD *event)
       Float_t minchi2before1=16;
       Float_t minchi2after0 =16;
       Float_t minchi2after1 =16;
-      Int_t maxLayer = GetNearestLayer(pvertex->GetXrp());
+      Double_t xrp[3]; pvertex->GetXYZ(xrp[0],xrp[1],xrp[2]);  //I.B.
+      Int_t maxLayer = GetNearestLayer(xrp);                   //I.B.
       
       if (array0b) for (Int_t i=0;i<5;i++){
        // best track after vertex
@@ -4091,19 +4100,20 @@ void  AliITStrackerMI::FindV02(AliESD *event)
       }
       //       
       AliV0 vertex2;
-      vertex2.SetM(*track0b);
-      vertex2.SetP(*track1b);
+      vertex2.SetParamN(*track0b);
+      vertex2.SetParamP(*track1b);
       vertex2.Update(primvertex);
-      if (vertex2.GetDist2()<=pvertex->GetDist2()&&(vertex2.GetPointAngle()>=pvertex->GetPointAngle())){
-       pvertex->SetM(*track0b);
-       pvertex->SetP(*track1b);
+      //Bo:      if (vertex2.GetDist2()<=pvertex->GetDist2()&&(vertex2.GetV0CosineOfPointingAngle()>=pvertex->GetV0CosineOfPointingAngle())){
+      if (vertex2.GetDcaV0Daughters()<=pvertex->GetDcaV0Daughters()&&(vertex2.GetV0CosineOfPointingAngle()>=pvertex->GetV0CosineOfPointingAngle())){
+       pvertex->SetParamN(*track0b);
+       pvertex->SetParamP(*track1b);
        pvertex->Update(primvertex);
        pvertex->SetClusters(track0b->ClIndex(),track1b->ClIndex());  // register clusters
        pvertex->SetIndex(0,track0->GetESDtrack()->GetID());
        pvertex->SetIndex(1,track1->GetESDtrack()->GetID());
       }
       pvertex->SetDistSigma(sigmad);
-      pvertex->SetDistNorm(pvertex->GetDist2()/sigmad);       
+      //Bo:      pvertex->SetDistNorm(pvertex->GetDist2()/sigmad);       
       pvertex->SetNormDCAPrim(normdist[itrack0],normdist[itrack1]);
       //
       // define likelihhod and causalities
@@ -4147,7 +4157,7 @@ void  AliITStrackerMI::FindV02(AliESD *event)
       //         
       Bool_t v0OK = kTRUE;
       Float_t p12 = pvertex->GetParamP()->GetParameter()[4]*pvertex->GetParamP()->GetParameter()[4];
-      p12        += pvertex->GetParamM()->GetParameter()[4]*pvertex->GetParamM()->GetParameter()[4];
+      p12        += pvertex->GetParamN()->GetParameter()[4]*pvertex->GetParamN()->GetParameter()[4];
       p12         = TMath::Sqrt(p12);                             // "mean" momenta
       Float_t    sigmap0   = 0.0001+0.001/(0.1+pvertex->GetRr()); 
       Float_t    sigmap    = 0.5*sigmap0*(0.6+0.4*p12);           // "resolution: of point angle - as a function of radius and momenta
@@ -4156,12 +4166,14 @@ void  AliITStrackerMI::FindV02(AliESD *event)
       Float_t causalityB  = TMath::Sqrt(TMath::Min(pvertex->GetCausalityP()[2],Float_t(0.7))*
                                        TMath::Min(pvertex->GetCausalityP()[3],Float_t(0.7)));
       //
-      Float_t likelihood0 = (TMath::Exp(-pvertex->GetDistNorm())+0.1) *(pvertex->GetDist2()<0.5)*(pvertex->GetDistNorm()<5);
-
-      Float_t likelihood1 = TMath::Exp(-(1.0001-pvertex->GetPointAngle())/sigmap)+
-       0.4*TMath::Exp(-(1.0001-pvertex->GetPointAngle())/(4.*sigmap))+
-       0.4*TMath::Exp(-(1.0001-pvertex->GetPointAngle())/(8.*sigmap))+
-       0.1*TMath::Exp(-(1.0001-pvertex->GetPointAngle())/0.01);
+      //Bo:      Float_t likelihood0 = (TMath::Exp(-pvertex->GetDistNorm())+0.1) *(pvertex->GetDist2()<0.5)*(pvertex->GetDistNorm()<5);
+      Float_t lDistNorm = pvertex->GetDcaV0Daughters()/pvertex->GetDistSigma();
+      Float_t likelihood0 = (TMath::Exp(-lDistNorm)+0.1) *(pvertex->GetDcaV0Daughters()<0.5)*(lDistNorm<5);
+
+      Float_t likelihood1 = TMath::Exp(-(1.0001-pvertex->GetV0CosineOfPointingAngle())/sigmap)+
+       0.4*TMath::Exp(-(1.0001-pvertex->GetV0CosineOfPointingAngle())/(4.*sigmap))+
+       0.4*TMath::Exp(-(1.0001-pvertex->GetV0CosineOfPointingAngle())/(8.*sigmap))+
+       0.1*TMath::Exp(-(1.0001-pvertex->GetV0CosineOfPointingAngle())/0.01);
       //
       if (causalityA<kCausality0Cut)                                          v0OK = kFALSE;
       if (TMath::Sqrt(likelihood0*likelihood1)<kLikelihood01Cut)              v0OK = kFALSE;
@@ -4200,8 +4212,10 @@ void  AliITStrackerMI::FindV02(AliESD *event)
       //      if (rejectBase) {
       //       pvertex->SetStatus(-100);
       //}
-      if (pvertex->GetPointAngle()>kMinPointAngle2) {
-         pvertex->SetESDindexes(track0->GetESDtrack()->GetID(),track1->GetESDtrack()->GetID());
+      if (pvertex->GetV0CosineOfPointingAngle()>kMinPointAngle2) {
+       //Bo:     pvertex->SetESDindexes(track0->GetESDtrack()->GetID(),track1->GetESDtrack()->GetID());
+       pvertex->SetIndex(0,track0->GetESDtrack()->GetID());//Bo: consistency 0 for neg
+       pvertex->SetIndex(1,track1->GetESDtrack()->GetID());//Bo: consistency 1 for pos
        if (v0OK){
          //      AliV0vertex vertexjuri(*track0,*track1);
          //      vertexjuri.SetESDindexes(track0->fESDtrack->GetID(),track1->fESDtrack->GetID());
@@ -4209,6 +4223,7 @@ void  AliITStrackerMI::FindV02(AliESD *event)
          pvertex->SetStatus(100);
        }
         pvertex->SetOnFlyStatus(kTRUE);
+        pvertex->ChangeMassHypothesis(kK0Short);
        event->AddV0(pvertex);
       }
     }
@@ -4251,11 +4266,12 @@ void AliITStrackerMI::RefitV02(AliESD *event)
     if (!esd0||!esd1) continue;
     AliITStrackMI tpc0(*esd0);  
     AliITStrackMI tpc1(*esd1);
-    Double_t alpha =TMath::ATan2(v0mi->GetXr(1),v0mi->GetXr(0));
+    Double_t x,y,z; v0mi->GetXYZ(x,y,z); //I.B. 
+    Double_t alpha =TMath::ATan2(y,x);   //I.B.
     if (v0mi->GetRr()>85){
       if (tpc0.Propagate(alpha,v0mi->GetRr())&&tpc1.Propagate(alpha,v0mi->GetRr())){
-       v0temp.SetM(tpc0);
-       v0temp.SetP(tpc1);
+       v0temp.SetParamN(tpc0);
+       v0temp.SetParamP(tpc1);
        v0temp.Update(primvertex);
        if (kFALSE) cstream<<"Refit"<<
          "V0.="<<v0mi<<
@@ -4263,9 +4279,10 @@ void AliITStrackerMI::RefitV02(AliESD *event)
          "Tr0.="<<&tpc0<<
          "Tr1.="<<&tpc1<<
          "\n";
-       if (v0temp.GetDist2()<v0mi->GetDist2() || v0temp.GetPointAngle()>v0mi->GetPointAngle()){
-         v0mi->SetM(tpc0);
-         v0mi->SetP(tpc1);
+       //Bo:   if (v0temp.GetDist2()<v0mi->GetDist2() || v0temp.GetV0CosineOfPointingAngle()>v0mi->GetV0CosineOfPointingAngle()){
+       if (v0temp.GetDcaV0Daughters()<v0mi->GetDcaV0Daughters() || v0temp.GetV0CosineOfPointingAngle()>v0mi->GetV0CosineOfPointingAngle()){
+         v0mi->SetParamN(tpc0);
+         v0mi->SetParamP(tpc1);
          v0mi->Update(primvertex);
        }
       }
@@ -4275,8 +4292,8 @@ void AliITStrackerMI::RefitV02(AliESD *event)
       CorrectForDeadZoneMaterial(&tpc0);
       CorrectForDeadZoneMaterial(&tpc1);
       if (tpc0.Propagate(alpha,v0mi->GetRr())&&tpc1.Propagate(alpha,v0mi->GetRr())){
-       v0temp.SetM(tpc0);
-       v0temp.SetP(tpc1);
+       v0temp.SetParamN(tpc0);
+       v0temp.SetParamP(tpc1);
        v0temp.Update(primvertex);
        if (kFALSE) cstream<<"Refit"<<
          "V0.="<<v0mi<<
@@ -4284,9 +4301,10 @@ void AliITStrackerMI::RefitV02(AliESD *event)
          "Tr0.="<<&tpc0<<
          "Tr1.="<<&tpc1<<
          "\n";
-       if (v0temp.GetDist2()<v0mi->GetDist2() || v0temp.GetPointAngle()>v0mi->GetPointAngle()){
-         v0mi->SetM(tpc0);
-         v0mi->SetP(tpc1);
+       //Bo:   if (v0temp.GetDist2()<v0mi->GetDist2() || v0temp.GetV0CosineOfPointingAngle()>v0mi->GetV0CosineOfPointingAngle()){
+       if (v0temp.GetDcaV0Daughters()<v0mi->GetDcaV0Daughters() || v0temp.GetV0CosineOfPointingAngle()>v0mi->GetV0CosineOfPointingAngle()){
+         v0mi->SetParamN(tpc0);
+         v0mi->SetParamP(tpc1);
          v0mi->Update(primvertex);
        }       
       }
@@ -4296,8 +4314,8 @@ void AliITStrackerMI::RefitV02(AliESD *event)
     CorrectForDeadZoneMaterial(&tpc1);    
     //    if (tpc0.Propagate(alpha,v0mi->GetRr())&&tpc1.Propagate(alpha,v0mi->GetRr())){
     if (RefitAt(v0mi->GetRr(),&tpc0, v0mi->GetClusters(0)) && RefitAt(v0mi->GetRr(),&tpc1, v0mi->GetClusters(1))){
-      v0temp.SetM(tpc0);
-      v0temp.SetP(tpc1);
+      v0temp.SetParamN(tpc0);
+      v0temp.SetParamP(tpc1);
       v0temp.Update(primvertex);
       if (kFALSE) cstream<<"Refit"<<
        "V0.="<<v0mi<<
@@ -4305,9 +4323,10 @@ void AliITStrackerMI::RefitV02(AliESD *event)
        "Tr0.="<<&tpc0<<
        "Tr1.="<<&tpc1<<
        "\n";
-      if (v0temp.GetDist2()<v0mi->GetDist2() || v0temp.GetPointAngle()>v0mi->GetPointAngle()){
-       v0mi->SetM(tpc0);
-       v0mi->SetP(tpc1);
+      //Bo:      if (v0temp.GetDist2()<v0mi->GetDist2() || v0temp.GetV0CosineOfPointingAngle()>v0mi->GetV0CosineOfPointingAngle()){
+      if (v0temp.GetDcaV0Daughters()<v0mi->GetDcaV0Daughters() || v0temp.GetV0CosineOfPointingAngle()>v0mi->GetV0CosineOfPointingAngle()){
+       v0mi->SetParamN(tpc0);
+       v0mi->SetParamP(tpc1);
        v0mi->Update(primvertex);
       }        
     }