]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliExternalTrackParam.cxx
Replaced AliInfo with AliDebug
[u/mrichter/AliRoot.git] / STEER / AliExternalTrackParam.cxx
index e6d2caf2f7bfcb390cf2021e2627447100fbc827..b7f4ce90f3ede87255449c0b2c2e298f8fb7e2ae 100644 (file)
@@ -28,6 +28,7 @@
 #include <TMatrixDSym.h>
 #include <TPolyMarker3D.h>
 #include <TVector3.h>
+#include <TMatrixD.h>
 
 #include "AliExternalTrackParam.h"
 #include "AliVVertex.h"
@@ -868,8 +869,60 @@ GetPredictedChi2(Double_t p[3],Double_t covyz[3],Double_t covxyz[3]) const {
     for (Int_t j = 0; j < 3; j++) chi2 += res[i]*res[j]*v(i,j);
 
   return chi2;  
+}
+
+Double_t AliExternalTrackParam::
+GetPredictedChi2(const AliExternalTrackParam *t) const {
+  //----------------------------------------------------------------
+  // Estimate the chi2 (5 dof) of this track with respect to the track
+  // given by the argument.
+  // The two tracks must be in the same reference system 
+  // and estimated at the same reference plane.
+  //----------------------------------------------------------------
 
+  if (TMath::Abs(1. - t->GetAlpha()/GetAlpha()) > FLT_EPSILON) {
+      AliError("The reference systems of the tracks differ !");
+      return kVeryBig;
+  }
+  if (TMath::Abs(1. - t->GetX()/GetX()) > FLT_EPSILON) {
+      AliError("The reference of the tracks planes differ !");
+      return kVeryBig;
+  }
+
+  TMatrixDSym c(5);
+    c(0,0)=GetSigmaY2(); 
+    c(1,0)=GetSigmaZY();   c(1,1)=GetSigmaZ2();
+    c(2,0)=GetSigmaSnpY(); c(2,1)=GetSigmaSnpZ(); c(2,2)=GetSigmaSnp2();
+    c(3,0)=GetSigmaTglY(); c(3,1)=GetSigmaTglZ(); c(3,2)=GetSigmaTglSnp(); c(3,3)=GetSigmaTgl2();
+    c(4,0)=GetSigma1PtY(); c(4,1)=GetSigma1PtZ(); c(4,2)=GetSigma1PtSnp(); c(4,3)=GetSigma1PtTgl(); c(4,4)=GetSigma1Pt2();
+
+    c(0,0)+=t->GetSigmaY2(); 
+    c(1,0)+=t->GetSigmaZY();  c(1,1)+=t->GetSigmaZ2();
+    c(2,0)+=t->GetSigmaSnpY();c(2,1)+=t->GetSigmaSnpZ();c(2,2)+=t->GetSigmaSnp2();
+    c(3,0)+=t->GetSigmaTglY();c(3,1)+=t->GetSigmaTglZ();c(3,2)+=t->GetSigmaTglSnp();c(3,3)+=t->GetSigmaTgl2();
+    c(4,0)+=t->GetSigma1PtY();c(4,1)+=t->GetSigma1PtZ();c(4,2)+=t->GetSigma1PtSnp();c(4,3)+=t->GetSigma1PtTgl();c(4,4)+=t->GetSigma1Pt2();
+    c(0,1)=c(1,0);
+    c(0,2)=c(2,0); c(1,2)=c(2,1);
+    c(0,3)=c(3,0); c(1,3)=c(3,1); c(2,3)=c(3,2);
+    c(0,4)=c(4,0); c(1,4)=c(4,1); c(2,4)=c(4,2); c(3,4)=c(4,3);
+
+  c.Invert();
+  if (!c.IsValid()) return kVeryBig;
+
+
+  Double_t res[5] = {
+    GetY()   - t->GetY(),
+    GetZ()   - t->GetZ(),
+    GetSnp() - t->GetSnp(),
+    GetTgl() - t->GetTgl(),
+    GetSigned1Pt() - t->GetSigned1Pt()
+  };
 
+  Double_t chi2=0.;
+  for (Int_t i = 0; i < 5; i++)
+    for (Int_t j = 0; j < 5; j++) chi2 += res[i]*res[j]*c(i,j);
+
+  return chi2;  
 }
 
 Bool_t AliExternalTrackParam::
@@ -1857,3 +1910,82 @@ Bool_t AliExternalTrackParam::PropagateToBxByBz(Double_t xk, const Double_t b[3]
   return kTRUE;
 }
 
+Bool_t AliExternalTrackParam::Translate(Double_t *vTrasl,Double_t *covV){
+  //
+  //Translation: in the event mixing, the tracks can be shifted 
+  //of the difference among primary vertices (vTrasl) and 
+  //the covariance matrix is changed accordingly 
+  //(covV = covariance of the primary vertex).
+  //Origin: "Romita, Rossella" <R.Romita@gsi.de>
+  // 
+  TVector3 translation;
+  // vTrasl coordinates in the local system
+  translation.SetXYZ(vTrasl[0],vTrasl[1],vTrasl[2]);
+  translation.RotateZ(-fAlpha);
+  translation.GetXYZ(vTrasl);
+
+ //compute the new x,y,z of the track
+  Double_t newX=fX-vTrasl[0];
+  Double_t newY=fP[0]-vTrasl[1];
+  Double_t newZ=fP[1]-vTrasl[2];
+  
+  //define the new parameters
+  Double_t newParam[5];
+  newParam[0]=newY;
+  newParam[1]=newZ;
+  newParam[2]=fP[2];
+  newParam[3]=fP[3];
+  newParam[4]=fP[4];
+
+  // recompute the covariance matrix:
+  // 1. covV in the local system
+  Double_t cosRot=TMath::Cos(fAlpha), sinRot=TMath::Sin(fAlpha);
+  TMatrixD qQi(3,3);
+  qQi(0,0) = cosRot;
+  qQi(0,1) = sinRot;
+  qQi(0,2) = 0.;
+  qQi(1,0) = -sinRot;
+  qQi(1,1) = cosRot;
+  qQi(1,2) = 0.;
+  qQi(2,0) = 0.;
+  qQi(2,1) = 0.;
+  qQi(2,2) = 1.;
+  TMatrixD uUi(3,3);
+  uUi(0,0) = covV[0];
+  uUi(0,0) = covV[0];
+  uUi(1,0) = covV[1];
+  uUi(0,1) = covV[1];
+  uUi(2,0) = covV[3];
+  uUi(0,2) = covV[3];
+  uUi(1,1) = covV[2];
+  uUi(2,2) = covV[5];
+  uUi(1,2) = covV[4];
+  if(uUi.Determinant() <= 0.) {return kFALSE;}
+  TMatrixD uUiQi(uUi,TMatrixD::kMult,qQi);
+  TMatrixD m(qQi,TMatrixD::kTransposeMult,uUiQi);
+
+  //2. compute the new covariance matrix of the track
+  Double_t sigmaXX=m(0,0);
+  Double_t sigmaXZ=m(2,0);
+  Double_t sigmaXY=m(1,0);
+  Double_t sigmaYY=GetSigmaY2()+m(1,1);
+  Double_t sigmaYZ=fC[1]+m(1,2);
+  Double_t sigmaZZ=fC[2]+m(2,2);
+  Double_t covarianceYY=sigmaYY + (-1.)*((sigmaXY*sigmaXY)/sigmaXX);
+  Double_t covarianceYZ=sigmaYZ-(sigmaXZ*sigmaXY/sigmaXX);
+  Double_t covarianceZZ=sigmaZZ-((sigmaXZ*sigmaXZ)/sigmaXX);
+
+  Double_t newCov[15];
+  newCov[0]=covarianceYY;
+  newCov[1]=covarianceYZ;
+  newCov[2]=covarianceZZ;
+  for(Int_t i=3;i<15;i++){
+    newCov[i]=fC[i];
+   }
+
+  // set the new parameters
+
+  Set(newX,fAlpha,newParam,newCov);
+
+  return kTRUE;
+ }