]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliTracker.cxx
Added ptHard to the information in the AliAODMCHeader, filled in the AODHandler
[u/mrichter/AliRoot.git] / STEER / AliTracker.cxx
index c755dc82f31cb368641d6c570e3cdd08989e9d68..7678b65c37c17051611fdca9468c114ad3e444bd 100644 (file)
@@ -48,7 +48,8 @@ AliTracker::AliTracker():
   fZ(0),
   fSigmaX(0.005),
   fSigmaY(0.005),
-  fSigmaZ(0.010) 
+  fSigmaZ(0.010),
+  fEventInfo(NULL)
 {
   //--------------------------------------------------------------------
   // The default constructor.
@@ -65,7 +66,8 @@ AliTracker::AliTracker(const AliTracker &atr):
   fZ(atr.fZ),
   fSigmaX(atr.fSigmaX),
   fSigmaY(atr.fSigmaY),
-  fSigmaZ(atr.fSigmaZ)
+  fSigmaZ(atr.fSigmaZ),
+  fEventInfo(atr.fEventInfo)
 {
   //--------------------------------------------------------------------
   // The default constructor.
@@ -94,6 +96,28 @@ Double_t AliTracker::GetBz(const Double_t *r) {
   return  TMath::Sign(0.5*kAlmost0Field,bz) + bz;
 }
 
+//__________________________________________________________________________
+void AliTracker::GetBxByBz(const Double_t r[3], Double_t b[3]) {
+  //------------------------------------------------------------------
+  // Returns Bx, By and Bz (kG) at the point "r" .
+  //------------------------------------------------------------------
+  AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
+  if (!fld) {
+     b[0] = b[1] = 0.;
+     b[2] = 0.5*kAlmost0Field;
+     return;
+  }
+
+  if (fld->IsUniform()) {
+     b[0] = b[1] = 0.;
+     b[2] = fld->SolenoidField();
+  }  else {
+     fld->Field(r,b);
+  }
+  b[2] = (TMath::Sign(0.5*kAlmost0Field,b[2]) + b[2]);
+  return;
+}
+
 //__________________________________________________________________________
 void AliTracker::FillClusterArray(TObjArray* /*array*/) const
 {
@@ -321,7 +345,7 @@ Double_t AliTracker::MeanMaterialBudget(const Double_t *start, const Double_t *e
 
 Bool_t 
 AliTracker::PropagateTrackTo(AliExternalTrackParam *track, Double_t xToGo, 
-Double_t mass, Double_t maxStep, Bool_t rotateTo, Double_t maxSnp){
+                            Double_t mass, Double_t maxStep, Bool_t rotateTo, Double_t maxSnp, Double_t sign){
   //----------------------------------------------------------------
   //
   // Propagates the track to the plane X=xk (cm) using the magnetic field map 
@@ -352,7 +376,62 @@ Double_t mass, Double_t maxStep, Bool_t rotateTo, Double_t maxSnp){
     if (!track->PropagateTo(x,bz))  return kFALSE;
 
     MeanMaterialBudget(xyz0,xyz1,param);       
-    Double_t xrho=param[0]*param[4], xx0=param[1];
+    Double_t xrho=param[0]*param[4]*sign, xx0=param[1];
+
+    if (!track->CorrectForMeanMaterial(xx0,xrho,mass)) return kFALSE;
+    if (rotateTo){
+      if (TMath::Abs(track->GetSnp()) >= maxSnp) return kFALSE;
+      track->GetXYZ(xyz0);   // global position
+      Double_t alphan = TMath::ATan2(xyz0[1], xyz0[0]); 
+      //
+      Double_t ca=TMath::Cos(alphan-track->GetAlpha()), 
+               sa=TMath::Sin(alphan-track->GetAlpha());
+      Double_t sf=track->GetSnp(), cf=TMath::Sqrt((1.-sf)*(1.+sf));
+      Double_t sinNew =  sf*ca - cf*sa;
+      if (TMath::Abs(sinNew) >= maxSnp) return kFALSE;
+      if (!track->Rotate(alphan)) return kFALSE;
+    }
+    xpos = track->GetX();
+  }
+  return kTRUE;
+}
+
+Bool_t 
+AliTracker::PropagateTrackToBxByBz(AliExternalTrackParam *track,
+Double_t xToGo, 
+                                  Double_t mass, Double_t maxStep, Bool_t rotateTo, Double_t maxSnp,Double_t sign){
+  //----------------------------------------------------------------
+  //
+  // Propagates the track to the plane X=xk (cm)
+  // taking into account all the three components of the magnetic field 
+  // and correcting for the crossed material.
+  //
+  // mass     - mass used in propagation - used for energy loss correction
+  // maxStep  - maximal step for propagation
+  //
+  //  Origin: Marian Ivanov,  Marian.Ivanov@cern.ch
+  //
+  //----------------------------------------------------------------
+  const Double_t kEpsilon = 0.00001;
+  Double_t xpos     = track->GetX();
+  Double_t dir      = (xpos<xToGo) ? 1.:-1.;
+  //
+  while ( (xToGo-xpos)*dir > kEpsilon){
+    Double_t step = dir*TMath::Min(TMath::Abs(xToGo-xpos), maxStep);
+    Double_t x    = xpos+step;
+    Double_t xyz0[3],xyz1[3],param[7];
+    track->GetXYZ(xyz0);   //starting global position
+
+    Double_t b[3]; GetBxByBz(xyz0,b); // getting the local Bx, By and Bz
+
+    if (!track->GetXYZAt(x,b[2],xyz1)) return kFALSE;   // no prolongation
+    xyz1[2]+=kEpsilon; // waiting for bug correction in geo
+
+    if (TMath::Abs(track->GetSnpAt(x,b[2])) >= maxSnp) return kFALSE;
+    if (!track->PropagateToBxByBz(x,b))  return kFALSE;
+
+    MeanMaterialBudget(xyz0,xyz1,param);       
+    Double_t xrho=param[0]*param[4]*sign, xx0=param[1];
 
     if (!track->CorrectForMeanMaterial(xx0,xrho,mass)) return kFALSE;
     if (rotateTo){