DCA calculation moved to the AliKalmanTrack (Yu.Belikov)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 13 Mar 2003 14:39:52 +0000 (14:39 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 13 Mar 2003 14:39:52 +0000 (14:39 +0000)
ITS/AliV0vertexer.cxx
STEER/AliKalmanTrack.cxx
STEER/AliKalmanTrack.h

index 207648f6853498310975a02b4157658966284b14..0ba5a7656303a0f7172410b6781f81aae124184e 100644 (file)
@@ -147,148 +147,12 @@ Int_t AliV0vertexer::Tracks2V0vertices(const TFile *inp, TFile *out) {
    return 0;
 }
 
-
-static void External2Helix(const AliITStrackV2 *t, Double_t helix[6]) { 
-  //--------------------------------------------------------------------
-  // External track parameters -> helix parameters 
-  //--------------------------------------------------------------------
-  Double_t alpha,x,cs,sn;
-  t->GetExternalParameters(x,helix); alpha=t->GetAlpha();
-
-  cs=TMath::Cos(alpha); sn=TMath::Sin(alpha);
-  helix[5]=x*cs - helix[0]*sn;            // x0
-  helix[0]=x*sn + helix[0]*cs;            // y0
-//helix[1]=                               // z0
-  helix[2]=TMath::ASin(helix[2]) + alpha; // phi0
-//helix[3]=                               // tgl
-  helix[4]=helix[4]/t->GetConvConst();    // C
-}
-
-static void Evaluate(const Double_t *h, Double_t t,
-                     Double_t r[3],  //radius vector
-                     Double_t g[3],  //first defivatives
-                     Double_t gg[3]) //second derivatives
-{
-  //--------------------------------------------------------------------
-  // Calculate position of a point on a track and some derivatives
-  //--------------------------------------------------------------------
-  Double_t phase=h[4]*t+h[2];
-  Double_t sn=TMath::Sin(phase), cs=TMath::Cos(phase);
-
-  r[0] = h[5] + (sn - h[6])/h[4];
-  r[1] = h[0] - (cs - h[7])/h[4];  
-  r[2] = h[1] + h[3]*t;
-
-  g[0] = cs; g[1]=sn; g[2]=h[3];
-  
-  gg[0]=-h[4]*sn; gg[1]=h[4]*cs; gg[2]=0.;
-}
-
 Double_t AliV0vertexer::PropagateToDCA(AliITStrackV2 *n, AliITStrackV2 *p) {
   //--------------------------------------------------------------------
   // This function returns the DCA between two tracks
   // The tracks will be moved to the point of DCA ! 
   //--------------------------------------------------------------------
-  Double_t dy2=n->GetSigmaY2() + p->GetSigmaY2();
-  Double_t dz2=n->GetSigmaZ2() + p->GetSigmaZ2();
-  Double_t dx2=dy2; 
-
-  //dx2=dy2=dz2=1.;
-
-  Double_t p1[8]; External2Helix(n,p1);
-  p1[6]=TMath::Sin(p1[2]); p1[7]=TMath::Cos(p1[2]);
-  Double_t p2[8]; External2Helix(p,p2);
-  p2[6]=TMath::Sin(p2[2]); p2[7]=TMath::Cos(p2[2]);
-
-
-  Double_t r1[3],g1[3],gg1[3]; Double_t t1=0.;
-  Evaluate(p1,t1,r1,g1,gg1);
-  Double_t r2[3],g2[3],gg2[3]; Double_t t2=0.;
-  Evaluate(p2,t2,r2,g2,gg2);
-
-  Double_t dx=r2[0]-r1[0], dy=r2[1]-r1[1], dz=r2[2]-r1[2];
-  Double_t dm=dx*dx/dx2 + dy*dy/dy2 + dz*dz/dz2;
-
-  Int_t max=27;
-  while (max--) {
-     Double_t gt1=-(dx*g1[0]/dx2 + dy*g1[1]/dy2 + dz*g1[2]/dz2);
-     Double_t gt2=+(dx*g2[0]/dx2 + dy*g2[1]/dy2 + dz*g2[2]/dz2);
-     Double_t h11=(g1[0]*g1[0] - dx*gg1[0])/dx2 + 
-                  (g1[1]*g1[1] - dy*gg1[1])/dy2 +
-                  (g1[2]*g1[2] - dz*gg1[2])/dz2;
-     Double_t h22=(g2[0]*g2[0] + dx*gg2[0])/dx2 + 
-                  (g2[1]*g2[1] + dy*gg2[1])/dy2 +
-                  (g2[2]*g2[2] + dz*gg2[2])/dz2;
-     Double_t h12=-(g1[0]*g2[0]/dx2 + g1[1]*g2[1]/dy2 + g1[2]*g2[2]/dz2);
-
-     Double_t det=h11*h22-h12*h12;
-
-     Double_t dt1,dt2;
-     if (TMath::Abs(det)<1.e-33) {
-        //(quasi)singular Hessian
-        dt1=-gt1; dt2=-gt2;
-     } else {
-        dt1=-(gt1*h22 - gt2*h12)/det; 
-        dt2=-(h11*gt2 - h12*gt1)/det;
-     }
-
-     if ((dt1*gt1+dt2*gt2)>0) {dt1=-dt1; dt2=-dt2;}
-
-     //check delta(phase1) ?
-     //check delta(phase2) ?
-
-     if (TMath::Abs(dt1)/(TMath::Abs(t1)+1.e-3) < 1.e-4)
-     if (TMath::Abs(dt2)/(TMath::Abs(t2)+1.e-3) < 1.e-4) {
-        if ((gt1*gt1+gt2*gt2) > 1.e-4/dy2/dy2) 
-          cerr<<"AliV0vertexer::PropagateToDCA:"
-                 " stopped at not a stationary point !\n";
-        Double_t lmb=h11+h22; lmb=lmb-TMath::Sqrt(lmb*lmb-4*det);
-        if (lmb < 0.) 
-          cerr<<"AliV0vertexer::PropagateToDCA:"
-                 " stopped at not a minimum !\n";
-        break;
-     }
-
-     Double_t dd=dm;
-     for (Int_t div=1 ; ; div*=2) {
-        Evaluate(p1,t1+dt1,r1,g1,gg1);
-        Evaluate(p2,t2+dt2,r2,g2,gg2);
-        dx=r2[0]-r1[0]; dy=r2[1]-r1[1]; dz=r2[2]-r1[2];
-        dd=dx*dx/dx2 + dy*dy/dy2 + dz*dz/dz2;
-       if (dd<dm) break;
-        dt1*=0.5; dt2*=0.5;
-        if (div>512) {
-           cerr<<"AliV0vertexer::PropagateToDCA: overshoot !\n"; break;
-        }   
-     }
-     dm=dd;
-
-     t1+=dt1;
-     t2+=dt2;
-
-  }
-
-  if (max<=0) cerr<<"AliV0vertexer::PropagateToDCA: too many iterations !\n";  
-  
-  //propagate tracks to the points of DCA
-  Double_t cs=TMath::Cos(n->GetAlpha());
-  Double_t sn=TMath::Sin(n->GetAlpha());
-  Double_t x=r1[0]*cs + r1[1]*sn;
-  if (!n->PropagateTo(x,0.,0.)) {
-    //cerr<<"AliV0vertexer::PropagateToDCA: propagation failed !\n";
-    return 1.e+33;
-  }  
-
-  cs=TMath::Cos(p->GetAlpha());
-  sn=TMath::Sin(p->GetAlpha());
-  x=r2[0]*cs + r2[1]*sn;
-  if (!p->PropagateTo(x,0.,0.)) {
-    //cerr<<"AliV0vertexer::PropagateToDCA: propagation failed !\n";
-    return 1.e+33;
-  }  
-
-  return TMath::Sqrt(dm*TMath::Sqrt(dy2*dz2));
-  //return TMath::Sqrt(dx*dx + dy*dy + dz*dz);
+  return n->PropagateToDCA(p);
 }
 
 
index 5b1a85f0a2a776354e75ccfd9d5164c957d921fe..4e64e082d01ea400590f8aa9191cceee457a914d 100644 (file)
@@ -72,6 +72,8 @@ AliKalmanTrack::AliKalmanTrack(const AliKalmanTrack &t):
 //_______________________________________________________________________
 void AliKalmanTrack::StartTimeIntegral() 
 {
+  // Sylwester Radomski, GSI
+  // S.Radomski@gsi.de
   //
   // Start time integration
   // To be called at Vertex by ITS tracker
@@ -144,6 +146,8 @@ void AliKalmanTrack:: AddTimeStep(Double_t length)
 
 Double_t AliKalmanTrack::GetIntegratedTime(Int_t pdg) const 
 {
+  // Sylwester Radomski, GSI
+  // S.Radomski@gsi.de
   //
   // Return integrated time hypothesis for a given particle
   // type assumption.
@@ -170,6 +174,9 @@ Double_t AliKalmanTrack::GetIntegratedTime(Int_t pdg) const
 
 void AliKalmanTrack::PrintTime() const
 {
+  // Sylwester Radomski, GSI
+  // S.Radomski@gsi.de
+  //
   // For testing
   // Prints time for all hypothesis
   //
@@ -181,5 +188,159 @@ void AliKalmanTrack::PrintTime() const
   printf("\n");  
 }
 
-//_______________________________________________________________________
+static void External2Helix(const AliKalmanTrack *t, Double_t helix[6]) { 
+  //--------------------------------------------------------------------
+  // External track parameters -> helix parameters 
+  //--------------------------------------------------------------------
+  Double_t alpha,x,cs,sn;
+  t->GetExternalParameters(x,helix); alpha=t->GetAlpha();
+
+  cs=TMath::Cos(alpha); sn=TMath::Sin(alpha);
+  helix[5]=x*cs - helix[0]*sn;            // x0
+  helix[0]=x*sn + helix[0]*cs;            // y0
+//helix[1]=                               // z0
+  helix[2]=TMath::ASin(helix[2]) + alpha; // phi0
+//helix[3]=                               // tgl
+  helix[4]=helix[4]/t->GetConvConst();    // C
+}
+
+static void Evaluate(const Double_t *h, Double_t t,
+                     Double_t r[3],  //radius vector
+                     Double_t g[3],  //first defivatives
+                     Double_t gg[3]) //second derivatives
+{
+  //--------------------------------------------------------------------
+  // Calculate position of a point on a track and some derivatives
+  //--------------------------------------------------------------------
+  Double_t phase=h[4]*t+h[2];
+  Double_t sn=TMath::Sin(phase), cs=TMath::Cos(phase);
+
+  r[0] = h[5] + (sn - h[6])/h[4];
+  r[1] = h[0] - (cs - h[7])/h[4];  
+  r[2] = h[1] + h[3]*t;
+
+  g[0] = cs; g[1]=sn; g[2]=h[3];
+  
+  gg[0]=-h[4]*sn; gg[1]=h[4]*cs; gg[2]=0.;
+}
+
+Double_t AliKalmanTrack::
+GetDCA(const AliKalmanTrack *p, Double_t &xthis, Double_t &xp) const {
+  //------------------------------------------------------------
+  // Returns the (weighed !) distance of closest approach between 
+  // this track and the track passed as the argument.
+  // Other returned values:
+  //   xthis, xt - coordinates of tracks' reference planes at the DCA 
+  //-----------------------------------------------------------
+  Double_t dy2=GetSigmaY2() + p->GetSigmaY2();
+  Double_t dz2=GetSigmaZ2() + p->GetSigmaZ2();
+  Double_t dx2=dy2; 
+
+  //dx2=dy2=dz2=1.;
+
+  Double_t p1[8]; External2Helix(this,p1);
+  p1[6]=TMath::Sin(p1[2]); p1[7]=TMath::Cos(p1[2]);
+  Double_t p2[8]; External2Helix(p,p2);
+  p2[6]=TMath::Sin(p2[2]); p2[7]=TMath::Cos(p2[2]);
+
+
+  Double_t r1[3],g1[3],gg1[3]; Double_t t1=0.;
+  Evaluate(p1,t1,r1,g1,gg1);
+  Double_t r2[3],g2[3],gg2[3]; Double_t t2=0.;
+  Evaluate(p2,t2,r2,g2,gg2);
 
+  Double_t dx=r2[0]-r1[0], dy=r2[1]-r1[1], dz=r2[2]-r1[2];
+  Double_t dm=dx*dx/dx2 + dy*dy/dy2 + dz*dz/dz2;
+
+  Int_t max=27;
+  while (max--) {
+     Double_t gt1=-(dx*g1[0]/dx2 + dy*g1[1]/dy2 + dz*g1[2]/dz2);
+     Double_t gt2=+(dx*g2[0]/dx2 + dy*g2[1]/dy2 + dz*g2[2]/dz2);
+     Double_t h11=(g1[0]*g1[0] - dx*gg1[0])/dx2 + 
+                  (g1[1]*g1[1] - dy*gg1[1])/dy2 +
+                  (g1[2]*g1[2] - dz*gg1[2])/dz2;
+     Double_t h22=(g2[0]*g2[0] + dx*gg2[0])/dx2 + 
+                  (g2[1]*g2[1] + dy*gg2[1])/dy2 +
+                  (g2[2]*g2[2] + dz*gg2[2])/dz2;
+     Double_t h12=-(g1[0]*g2[0]/dx2 + g1[1]*g2[1]/dy2 + g1[2]*g2[2]/dz2);
+
+     Double_t det=h11*h22-h12*h12;
+
+     Double_t dt1,dt2;
+     if (TMath::Abs(det)<1.e-33) {
+        //(quasi)singular Hessian
+        dt1=-gt1; dt2=-gt2;
+     } else {
+        dt1=-(gt1*h22 - gt2*h12)/det; 
+        dt2=-(h11*gt2 - h12*gt1)/det;
+     }
+
+     if ((dt1*gt1+dt2*gt2)>0) {dt1=-dt1; dt2=-dt2;}
+
+     //check delta(phase1) ?
+     //check delta(phase2) ?
+
+     if (TMath::Abs(dt1)/(TMath::Abs(t1)+1.e-3) < 1.e-4)
+     if (TMath::Abs(dt2)/(TMath::Abs(t2)+1.e-3) < 1.e-4) {
+        if ((gt1*gt1+gt2*gt2) > 1.e-4/dy2/dy2) 
+         Warning("GetDCA"," stopped at not a stationary point !\n");
+        Double_t lmb=h11+h22; lmb=lmb-TMath::Sqrt(lmb*lmb-4*det);
+        if (lmb < 0.) 
+         Warning("GetDCA"," stopped at not a minimum !\n");
+        break;
+     }
+
+     Double_t dd=dm;
+     for (Int_t div=1 ; ; div*=2) {
+        Evaluate(p1,t1+dt1,r1,g1,gg1);
+        Evaluate(p2,t2+dt2,r2,g2,gg2);
+        dx=r2[0]-r1[0]; dy=r2[1]-r1[1]; dz=r2[2]-r1[2];
+        dd=dx*dx/dx2 + dy*dy/dy2 + dz*dz/dz2;
+       if (dd<dm) break;
+        dt1*=0.5; dt2*=0.5;
+        if (div>512) {
+           Warning("GetDCA"," overshoot !\n"); break;
+        }   
+     }
+     dm=dd;
+
+     t1+=dt1;
+     t2+=dt2;
+
+  }
+
+  if (max<=0) Warning("GetDCA"," too many iterations !\n");  
+
+  Double_t cs=TMath::Cos(GetAlpha());
+  Double_t sn=TMath::Sin(GetAlpha());
+  xthis=r1[0]*cs + r1[1]*sn;
+
+  cs=TMath::Cos(p->GetAlpha());
+  sn=TMath::Sin(p->GetAlpha());
+  xp=r2[0]*cs + r2[1]*sn;
+
+  return TMath::Sqrt(dm*TMath::Sqrt(dy2*dz2));
+}
+
+Double_t AliKalmanTrack::
+PropagateToDCA(AliKalmanTrack *p, Double_t d, Double_t x0) {
+  //--------------------------------------------------------------
+  // Propagates this track and the argument track to the position of the
+  // distance of closest approach. 
+  // Returns the (weighed !) distance of closest approach.
+  //--------------------------------------------------------------
+  Double_t xthis,xp;
+  Double_t dca=GetDCA(p,xthis,xp);
+
+  if (!PropagateTo(xthis,d,x0)) {
+    //Warning("PropagateToDCA"," propagation failed !\n");
+    return 1e+33;
+  }  
+
+  if (!p->PropagateTo(xp,d,x0)) {
+    //Warning("PropagateToDCA"," propagation failed !\n";
+    return 1e+33;
+  }  
+
+  return dca;
+}
index 875d496629644d4932163f9caa58224174fe178b..27ff9bb2631bd85fc1c787a8b4312b3cbc84c469 100644 (file)
@@ -34,6 +34,22 @@ public:
     return 0;
   } 
 
+  virtual Double_t GetDCA(const AliKalmanTrack *,Double_t &,Double_t &) const; 
+  virtual 
+  Double_t PropagateToDCA(AliKalmanTrack *, Double_t d=0., Double_t x0=0.); 
+  virtual Double_t GetAlpha() const {
+    Warning("GetAlpha()","Method must be overloaded !\n");
+    return 0.;
+  }
+  virtual Double_t GetSigmaY2() const {
+    Warning("GetSigmaY2()","Method must be overloaded !\n");
+    return 0.;
+  }
+  virtual Double_t GetSigmaZ2() const {
+    Warning("GetSigmaZ2()","Method must be overloaded !\n");
+    return 0.;
+  }
+
   virtual Int_t Compare(const TObject *) const {return 0;} 
 
   virtual void GetExternalParameters(Double_t &/*xr*/, Double_t /*x*/[5]) const {}
@@ -52,7 +68,7 @@ public:
   }
   Double_t GetMagneticField() const {return 100/0.299792458/fgConvConst;}
 
-  // Time integration
+  // Time integration (S.Radomski@gsi.de)
   void   StartTimeIntegral();
   Bool_t IsStartedTimeIntegral() const {return fStartTimeIntegral;}
   void     AddTimeStep(Double_t length);
@@ -74,7 +90,7 @@ private:
 
   static Double_t fgConvConst; //conversion constant cm -> GeV/c
 
-  // variables for time integration
+  // variables for time integration (S.Radomski@gsi.de)
   static const Int_t fgkTypes = 5;  // Number of track types (e,mu,pi,k,p)
   Bool_t  fStartTimeIntegral;       // indicator wether integrate time
   Float_t fIntegratedTime[5];       // intgrated time