]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliKalmanTrack.cxx
Correct overloading of virtual functions in the derived classes (icc)
[u/mrichter/AliRoot.git] / STEER / AliKalmanTrack.cxx
index 0e52d2ce4faa4038629279f2bec39a164ad22f73..3cfe6a639f34d1325e4a9c6a914de2f4fad6e8f5 100644 (file)
 //-------------------------------------------------------------------------
 
 #include "AliKalmanTrack.h"
-#include "AliLog.h"
+#include "TGeoManager.h"
 
 ClassImp(AliKalmanTrack)
 
-Double_t AliKalmanTrack::fgConvConst;
+const AliMagF *AliKalmanTrack::fgkFieldMap=0;
+Double_t AliKalmanTrack::fgConvConst=0.;
 
 //_______________________________________________________________________
 AliKalmanTrack::AliKalmanTrack():
@@ -34,18 +35,19 @@ AliKalmanTrack::AliKalmanTrack():
   fFakeRatio(0),
   fChi2(0),
   fMass(AliPID::ParticleMass(AliPID::kPion)),
-  fN(0)
+  fN(0),
+  fLocalConvConst(0),
+  fStartTimeIntegral(kFALSE),
+  fIntegratedLength(0)
 {
   //
   // Default constructor
   //
-    if (fgConvConst==0) {
+    if (fgkFieldMap==0) {
       AliFatal("The magnetic field has not been set!");
     }
-    
-    fStartTimeIntegral = kFALSE;
-    fIntegratedLength = 0;
-    for(Int_t i=0; i<5; i++) fIntegratedTime[i] = 0;
+
+    for(Int_t i=0; i<AliPID::kSPECIES; i++) fIntegratedTime[i] = 0;
 }
 
 //_______________________________________________________________________
@@ -55,20 +57,20 @@ AliKalmanTrack::AliKalmanTrack(const AliKalmanTrack &t):
   fFakeRatio(t.fFakeRatio),
   fChi2(t.fChi2),
   fMass(t.fMass),
-  fN(t.fN)
+  fN(t.fN),
+  fLocalConvConst(t.fLocalConvConst),
+  fStartTimeIntegral(t.fStartTimeIntegral),
+  fIntegratedLength(t.fIntegratedLength)
 {
   //
   // Copy constructor
   //
-  if (fgConvConst==0) {
+  if (fgkFieldMap==0) {
     AliFatal("The magnetic field has not been set!");
   }
-
-  fStartTimeIntegral = t.fStartTimeIntegral;
-  fIntegratedLength = t.fIntegratedLength;
   
-  for (Int_t i=0; i<5; i++) 
-    fIntegratedTime[i] = t.fIntegratedTime[i];
+  for (Int_t i=0; i<AliPID::kSPECIES; i++)
+      fIntegratedTime[i] = t.fIntegratedTime[i];
 }
 
 //_______________________________________________________________________
@@ -189,12 +191,12 @@ void AliKalmanTrack::PrintTime() const
   printf("\n");  
 }
 
-static void External2Helix(const AliKalmanTrack *t, Double_t helix[6]) { 
+void AliKalmanTrack::External2Helix(Double_t helix[6]) const { 
   //--------------------------------------------------------------------
   // External track parameters -> helix parameters 
   //--------------------------------------------------------------------
   Double_t alpha,x,cs,sn;
-  t->GetExternalParameters(x,helix); alpha=t->GetAlpha();
+  GetExternalParameters(x,helix); alpha=GetAlpha();
 
   cs=TMath::Cos(alpha); sn=TMath::Sin(alpha);
   helix[5]=x*cs - helix[0]*sn;            // x0
@@ -202,7 +204,7 @@ static void External2Helix(const AliKalmanTrack *t, Double_t helix[6]) {
 //helix[1]=                               // z0
   helix[2]=TMath::ASin(helix[2]) + alpha; // phi0
 //helix[3]=                               // tgl
-  helix[4]=helix[4]/t->GetConvConst();    // C
+  helix[4]=helix[4]/GetLocalConvConst();  // C
 }
 
 static void Evaluate(const Double_t *h, Double_t t,
@@ -239,9 +241,9 @@ GetDCA(const AliKalmanTrack *p, Double_t &xthis, Double_t &xp) const {
 
   //dx2=dy2=dz2=1.;
 
-  Double_t p1[8]; External2Helix(this,p1);
+  Double_t p1[8]; External2Helix(p1);
   p1[6]=TMath::Sin(p1[2]); p1[7]=TMath::Cos(p1[2]);
-  Double_t p2[8]; External2Helix(p,p2);
+  Double_t p2[8]; p->External2Helix(p2);
   p2[6]=TMath::Sin(p2[2]); p2[7]=TMath::Cos(p2[2]);
 
 
@@ -345,3 +347,141 @@ PropagateToDCA(AliKalmanTrack *p, Double_t d, Double_t x0) {
 
   return dca;
 }
+
+
+
+
+
+Double_t AliKalmanTrack::MeanMaterialBudget(Double_t *start, Double_t *end, Double_t *mparam)
+{
+  //
+  // calculate mean material budget and material properties beween point start and end
+  // mparam - returns parameters used for dEdx and multiple scatering
+  //
+  // mparam[0] - density mean 
+  // mparam[1] - rad length
+  // mparam[2] - A mean
+  // mparam[3] - Z mean
+  // mparam[4] - length
+  // mparam[5] - Z/A mean
+  // mparam[6] - number of boundary crosses
+  //
+    mparam[0]=0; mparam[1]=1; mparam[2] =0; mparam[3] =0, mparam[4]=0, mparam[5]=0; mparam[6]=0; 
+  //
+  Double_t bparam[6], lparam[6];          // bparam - total param - lparam - local parameters
+  for (Int_t i=0;i<6;i++) bparam[i]=0;    // 
+
+  if (!gGeoManager) {
+    printf("ERROR: no TGeo\n");
+    return 0.;
+  }
+  //
+  Double_t length;
+  Double_t dir[3];
+  length = TMath::Sqrt((end[0]-start[0])*(end[0]-start[0])+
+                      (end[1]-start[1])*(end[1]-start[1])+
+                      (end[2]-start[2])*(end[2]-start[2]));
+  mparam[4]=length;
+  if (length<TGeoShape::Tolerance()) return 0.0;
+  Double_t invlen = 1./length;
+  dir[0] = (end[0]-start[0])*invlen;
+  dir[1] = (end[1]-start[1])*invlen;
+  dir[2] = (end[2]-start[2])*invlen;
+  // Initialize start point and direction
+  TGeoNode *currentnode = 0;
+  TGeoNode *startnode = gGeoManager->InitTrack(start, dir);
+  //  printf("%s length=%f\n",gGeoManager->GetPath(),length);
+  if (!startnode) {
+    printf("ERROR: start point out of geometry\n");
+    return 0.0;
+  }
+  TGeoMaterial *material = startnode->GetVolume()->GetMedium()->GetMaterial();
+  lparam[0] = material->GetDensity();
+  lparam[1]   = material->GetRadLen();
+  lparam[2]   = material->GetA();
+  lparam[3]   = material->GetZ();
+  lparam[5]   = lparam[3]/lparam[2];
+  if (material->IsMixture()) {
+    lparam[1]*=lparam[0];  // different normalization in the modeler for mixture
+    TGeoMixture * mixture = (TGeoMixture*)material;
+    lparam[5] =0;
+    Double_t sum =0;
+    for (Int_t iel=0;iel<mixture->GetNelements();iel++){
+      sum  += mixture->GetWmixt()[iel];
+      lparam[5]+= mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel];
+    }
+    lparam[5]/=sum;
+  }
+  gGeoManager->FindNextBoundary(length);
+  Double_t snext = gGeoManager->GetStep();
+  Double_t step = 0.0;
+  // If no boundary within proposed length, return current density
+  if (snext>=length) {
+    for (Int_t ip=0;ip<5;ip++) mparam[ip] = lparam[ip];  
+    return lparam[0];
+  }
+  // Try to cross the boundary and see what is next
+  while (length>TGeoShape::Tolerance()) {
+    mparam[6]+=1.;
+    currentnode = gGeoManager->Step();
+    step += snext+1.E-6;
+    bparam[1]    += snext*lparam[1];
+    bparam[2]    += snext*lparam[2];
+    bparam[3]    += snext*lparam[3];
+    bparam[5]    += snext*lparam[5];    
+    bparam[0]    += snext*lparam[0];
+
+    if (snext>=length) break;
+    //    printf("%s snext=%f  density=%f bparam[0]=%f\n", gGeoManager->GetPath(),snext,density,bparam[0]);
+    if (!gGeoManager->IsEntering()) {
+      gGeoManager->SetStep(1.E-3);
+      currentnode = gGeoManager->Step();
+      if (!gGeoManager->IsEntering() || !currentnode) {
+       //      printf("ERROR: cannot cross boundary\n"); 
+       mparam[0] = bparam[0]/step;
+       mparam[1] = bparam[1]/step;
+       mparam[2] = bparam[2]/step;
+       mparam[3] = bparam[3]/step;     
+       mparam[5] = bparam[5]/step;     
+       mparam[4] = step;
+       mparam[0] = 0.;             // if crash of navigation take mean density 0 
+       mparam[1] = 1000000;        // and infinite rad length
+        return bparam[0]/step;
+      }
+      step += 1.E-3;
+      snext += 1.E-3;
+      bparam[0] += lparam[0]*1.E-3;
+      bparam[1]    += lparam[1]*1.E-3;
+      bparam[2]    += lparam[2]*1.E-3;
+      bparam[3]    += lparam[3]*1.E-3;
+      bparam[5]    += lparam[5]*1.E-3;
+    }
+    length -= snext;
+    material = currentnode->GetVolume()->GetMedium()->GetMaterial();
+    lparam[0] = material->GetDensity();
+    lparam[1]  = material->GetRadLen();
+    lparam[2]  = material->GetA();
+    lparam[3]  = material->GetZ();
+    lparam[5]   = lparam[3]/lparam[2];
+    if (material->IsMixture()) {
+      lparam[1]*=lparam[0];
+      TGeoMixture * mixture = (TGeoMixture*)material;
+      lparam[5]=0; 
+      Double_t sum =0;
+      for (Int_t iel=0;iel<mixture->GetNelements();iel++){
+       sum+= mixture->GetWmixt()[iel];
+       lparam[5]+= mixture->GetZmixt()[iel]*mixture->GetWmixt()[iel]/mixture->GetAmixt()[iel];
+      }
+      lparam[5]/=sum;
+    }
+    gGeoManager->FindNextBoundary(length);
+    snext = gGeoManager->GetStep();
+  }   
+  mparam[0] = bparam[0]/step;
+  mparam[1] = bparam[1]/step;
+  mparam[2] = bparam[2]/step;
+  mparam[3] = bparam[3]/step;  
+  mparam[5] = bparam[5]/step;  
+  return bparam[0]/step;   
+  
+}