]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliExternalTrackParam.cxx
introduction flag to skip the reading of track references (default: on)
[u/mrichter/AliRoot.git] / STEER / AliExternalTrackParam.cxx
index dde326a83bb9fd0c8c094546d6288ba15e8d09d9..6f3906916a0294ff6e2459ccad8a1ee8cb2f8223 100644 (file)
@@ -201,8 +201,8 @@ Double_t AliExternalTrackParam::GetLinearD(Double_t xv,Double_t yv) const {
 }
 
 Bool_t AliExternalTrackParam::CorrectForMeanMaterial
-(Double_t xOverX0,  Double_t xTimesRho, Double_t mass, 
-Double_t (*Bethe)(Double_t)) {
+(Double_t xOverX0,  Double_t xTimesRho, Double_t mass, Bool_t anglecorr, 
+ Double_t (*Bethe)(Double_t)) {
   //------------------------------------------------------------------
   // This function corrects the track parameters for the crossed material.
   // "xOverX0"   - X/X0, the thickness in units of the radiation length.
@@ -218,6 +218,13 @@ Double_t (*Bethe)(Double_t)) {
   Double_t &fC43=fC[13];
   Double_t &fC44=fC[14];
 
+  //Apply angle correction, if requested
+  if(anglecorr) {
+    Double_t angle=TMath::Sqrt((1.+ fP3*fP3)/(1.- fP2*fP2));
+    xOverX0 *=angle;
+    xTimesRho *=angle;
+  } 
+
   Double_t p=GetP();
   Double_t p2=p*p;
   Double_t beta2=p2/(p2 + mass*mass);
@@ -899,54 +906,6 @@ Bool_t AliExternalTrackParam::PropagateToDCA(const AliESDVertex *vtx, Double_t b
 }
 
 
-
-
-Bool_t Local2GlobalMomentum(Double_t p[3],Double_t alpha) {
-  //----------------------------------------------------------------
-  // This function performs local->global transformation of the
-  // track momentum.
-  // When called, the arguments are:
-  //    p[0] = 1/pt of the track;
-  //    p[1] = sine of local azim. angle of the track momentum;
-  //    p[2] = tangent of the track momentum dip angle;
-  //   alpha - rotation angle. 
-  // The result is returned as:
-  //    p[0] = px
-  //    p[1] = py
-  //    p[2] = pz
-  // Results for (nearly) straight tracks are meaningless !
-  //----------------------------------------------------------------
-  if (TMath::Abs(p[0])<=kAlmost0) return kFALSE;
-  if (TMath::Abs(p[1])> kAlmost1) return kFALSE;
-
-  Double_t pt=1./TMath::Abs(p[0]);
-  Double_t cs=TMath::Cos(alpha), sn=TMath::Sin(alpha);
-  Double_t r=TMath::Sqrt(1 - p[1]*p[1]);
-  p[0]=pt*(r*cs - p[1]*sn); p[1]=pt*(p[1]*cs + r*sn); p[2]=pt*p[2];
-
-  return kTRUE;
-}
-
-Bool_t Local2GlobalPosition(Double_t r[3],Double_t alpha) {
-  //----------------------------------------------------------------
-  // This function performs local->global transformation of the
-  // track position.
-  // When called, the arguments are:
-  //    r[0] = local x
-  //    r[1] = local y
-  //    r[2] = local z
-  //   alpha - rotation angle. 
-  // The result is returned as:
-  //    r[0] = global x
-  //    r[1] = global y
-  //    r[2] = global z
-  //----------------------------------------------------------------
-  Double_t cs=TMath::Cos(alpha), sn=TMath::Sin(alpha), x=r[0];
-  r[0]=x*cs - r[1]*sn; r[1]=x*sn + r[1]*cs;
-
-  return kTRUE;
-}
-
 void AliExternalTrackParam::GetDirection(Double_t d[3]) const {
   //----------------------------------------------------------------
   // This function returns a unit vector along the track direction
@@ -961,7 +920,7 @@ void AliExternalTrackParam::GetDirection(Double_t d[3]) const {
   d[2]=fP[3]/norm;
 }
 
-Bool_t AliExternalTrackParam::GetPxPyPz(Double_t *p) const {
+Bool_t AliExternalTrackParam::GetPxPyPz(Double_t p[3]) const {
   //---------------------------------------------------------------------
   // This function returns the global track momentum components
   // Results for (nearly) straight tracks are meaningless !
@@ -971,45 +930,91 @@ Bool_t AliExternalTrackParam::GetPxPyPz(Double_t *p) const {
 }
 
 Double_t AliExternalTrackParam::Px() const {
-  // return x-component of momentum
+  //---------------------------------------------------------------------
+  // Returns x-component of momentum
+  // Result for (nearly) straight tracks is meaningless !
+  //---------------------------------------------------------------------
 
-  Double_t p[3];
+  Double_t p[3]={kVeryBig,kVeryBig,kVeryBig};
   GetPxPyPz(p);
 
   return p[0];
 }
 
 Double_t AliExternalTrackParam::Py() const {
-  // return y-component of momentum
+  //---------------------------------------------------------------------
+  // Returns y-component of momentum
+  // Result for (nearly) straight tracks is meaningless !
+  //---------------------------------------------------------------------
 
-  Double_t p[3];
+  Double_t p[3]={kVeryBig,kVeryBig,kVeryBig};
   GetPxPyPz(p);
 
   return p[1];
 }
 
 Double_t AliExternalTrackParam::Pz() const {
-  // return z-component of momentum
+  //---------------------------------------------------------------------
+  // Returns z-component of momentum
+  // Result for (nearly) straight tracks is meaningless !
+  //---------------------------------------------------------------------
 
-  Double_t p[3];
+  Double_t p[3]={kVeryBig,kVeryBig,kVeryBig};
   GetPxPyPz(p);
 
   return p[2];
 }
 
+Double_t AliExternalTrackParam::Xv() const {
+  //---------------------------------------------------------------------
+  // Returns x-component of first track point
+  //---------------------------------------------------------------------
+
+  Double_t r[3]={0.,0.,0.};
+  GetXYZ(r);
+
+  return r[0];
+}
+
+Double_t AliExternalTrackParam::Yv() const {
+  //---------------------------------------------------------------------
+  // Returns y-component of first track point
+  //---------------------------------------------------------------------
+
+  Double_t r[3]={0.,0.,0.};
+  GetXYZ(r);
+
+  return r[1];
+}
+
+Double_t AliExternalTrackParam::Zv() const {
+  //---------------------------------------------------------------------
+  // Returns z-component of first track point
+  //---------------------------------------------------------------------
+
+  Double_t r[3]={0.,0.,0.};
+  GetXYZ(r);
+
+  return r[2];
+}
+
 Double_t AliExternalTrackParam::Theta() const {
   // return theta angle of momentum
 
-  return TMath::ATan2(Pt(), Pz());
+  return 0.5*TMath::Pi() - TMath::ATan(fP[3]);
 }
 
 Double_t AliExternalTrackParam::Phi() const {
-  // return phi angle of momentum
-
-  Double_t p[3];
-  GetPxPyPz(p);
+  //---------------------------------------------------------------------
+  // Returns the azimuthal angle of momentum
+  // 0 <= phi < 2*pi
+  //---------------------------------------------------------------------
 
-  return TMath::ATan2(p[1], p[0]);
+  Double_t phi=TMath::ASin(fP[2]) + fAlpha;
+  if (phi<0.) phi+=2.*TMath::Pi();
+  else if (phi>=2.*TMath::Pi()) phi-=2.*TMath::Pi();
+  return phi;
 }
 
 Double_t AliExternalTrackParam::M() const {
@@ -1213,3 +1218,43 @@ Double_t AliExternalTrackParam::GetSnpAt(Double_t x,Double_t b) const {
   Double_t res = fP[2]+dx*crv;
   return res;
 }
+
+Bool_t AliExternalTrackParam::GetDistance(AliExternalTrackParam *param2, Double_t x, Double_t dist[3], Double_t bz){
+  //------------------------------------------------------------------------
+  // Get the distance between two tracks at the local position x 
+  // working in the local frame of this track.
+  // Origin :   Marian.Ivanov@cern.ch
+  //-----------------------------------------------------------------------
+  Double_t xyz[3];
+  Double_t xyz2[3];
+  xyz[0]=x;
+  if (!GetYAt(x,bz,xyz[1])) return kFALSE;
+  if (!GetZAt(x,bz,xyz[2])) return kFALSE;
+  //  
+  //
+  if (TMath::Abs(GetAlpha()-param2->GetAlpha())<kAlmost0){
+    xyz2[0]=x;
+    if (!param2->GetYAt(x,bz,xyz2[1])) return kFALSE;
+    if (!param2->GetZAt(x,bz,xyz2[2])) return kFALSE;
+  }else{
+    //
+    Double_t xyz1[3];
+    Double_t dfi = param2->GetAlpha()-GetAlpha();
+    Double_t ca = TMath::Cos(dfi), sa = TMath::Sin(dfi);
+    xyz2[0] =  xyz[0]*ca+xyz[1]*sa;
+    xyz2[1] = -xyz[0]*sa+xyz[1]*ca;
+    //
+    xyz1[0]=xyz2[0];
+    if (!param2->GetYAt(xyz2[0],bz,xyz1[1])) return kFALSE;
+    if (!param2->GetZAt(xyz2[0],bz,xyz1[2])) return kFALSE;
+    //
+    xyz2[0] =  xyz1[0]*ca-xyz1[1]*sa;
+    xyz2[1] = +xyz1[0]*sa+xyz1[1]*ca;
+    xyz2[2] = xyz1[2];
+  }
+  dist[0] = xyz[0]-xyz2[0];
+  dist[1] = xyz[1]-xyz2[1];
+  dist[2] = xyz[2]-xyz2[2];
+
+  return kTRUE;
+}