]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliKalmanTrack.cxx
Adding PHOS to EINCLUDE (Solaris x86)
[u/mrichter/AliRoot.git] / STEER / AliKalmanTrack.cxx
index 7fb0e857abeebdd380f8f9dbbcdef1fc9db15264..a3d09ffe168ea699e88ede8f3061a230a477e0c2 100644 (file)
 
 //-------------------------------------------------------------------------
 //                Implementation of the AliKalmanTrack class
-//
+//   that is the base for AliTPCtrack, AliITStrackV2 and AliTRDtrack
 //        Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
 //-------------------------------------------------------------------------
-
+#include <TGeoManager.h>
 #include "AliKalmanTrack.h"
-#include "AliPDG.h"
-#include "TPDGCode.h"
-#include "TDatabasePDG.h"
 
 ClassImp(AliKalmanTrack)
 
-Double_t AliKalmanTrack::fgConvConst;
-
 //_______________________________________________________________________
-AliKalmanTrack::AliKalmanTrack():
+  AliKalmanTrack::AliKalmanTrack():AliExternalTrackParam(),
   fLab(-3141593),
+  fFakeRatio(0),
   fChi2(0),
-  fMass(0.13957),
-  fN(0)
+  fMass(AliPID::ParticleMass(AliPID::kPion)),
+  fN(0),
+  fStartTimeIntegral(kFALSE),
+  fIntegratedLength(0)
 {
   //
   // Default constructor
   //
-    if (fgConvConst==0) 
-      Fatal("AliKalmanTrack()","The magnetic field has not been set !\n"); 
-    
-    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;
 }
 
 //_______________________________________________________________________
 AliKalmanTrack::AliKalmanTrack(const AliKalmanTrack &t):
-  TObject(t),
+  AliExternalTrackParam(t),
   fLab(t.fLab),
+  fFakeRatio(t.fFakeRatio),
   fChi2(t.fChi2),
   fMass(t.fMass),
-  fN(t.fN)
+  fN(t.fN),
+  fStartTimeIntegral(t.fStartTimeIntegral),
+  fIntegratedLength(t.fIntegratedLength)
 {
   //
   // Copy constructor
   //
-  if (fgConvConst==0) 
-    Fatal("AliKalmanTrack(const AliKalmanTrack&)",
-          "The magnetic field has not been set !\n"); 
-
-  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];
 }
+
 //_______________________________________________________________________
 void AliKalmanTrack::StartTimeIntegral() 
 {
+  // Sylwester Radomski, GSI
+  // S.Radomski@gsi.de
   //
   // Start time integration
   // To be called at Vertex by ITS tracker
   //
   
   //if (fStartTimeIntegral) 
-  //  Warning("StartTimeIntegral", "Reseting Recorded Time.");
+  //  AliWarning("Reseting Recorded Time.");
 
   fStartTimeIntegral = kTRUE;
-  for(Int_t i=0; i<fTypes; i++) fIntegratedTime[i] = 0;  
+  for(Int_t i=0; i<AliPID::kSPECIES; i++) fIntegratedTime[i] = 0;  
   fIntegratedLength = 0;
 }
+
 //_______________________________________________________________________
 void AliKalmanTrack:: AddTimeStep(Double_t length) 
 {
@@ -107,15 +102,12 @@ void AliKalmanTrack:: AddTimeStep(Double_t length)
   // S.Radomski@gsi.de
   // 
   
-  static const Double_t cc = 2.99792458e-2;
+  static const Double_t kcc = 2.99792458e-2;
 
   if (!fStartTimeIntegral) return;
   
   fIntegratedLength += length;
 
-  static Int_t pdgCode[fTypes]  = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton};
-  TDatabasePDG *db = TDatabasePDG::Instance();
-
   Double_t xr, param[5];
   Double_t pt, tgl;
   
@@ -127,23 +119,21 @@ void AliKalmanTrack:: AddTimeStep(Double_t length)
 
   if (length > 100) return;
 
-  for (Int_t i=0; i<fTypes; i++) {
+  for (Int_t i=0; i<AliPID::kSPECIES; i++) {
     
-    Double_t mass = db->GetParticle(pdgCode[i])->Mass();
+    Double_t mass = AliPID::ParticleMass(i);
     Double_t correction = TMath::Sqrt( pt*pt * (1 + tgl*tgl) + mass * mass ) / p;
-    Double_t time = length * correction / cc;
-
-    //cout << mass << "\t" << pt << "\t" << p << "\t" 
-    //     << correction << endl;
+    Double_t time = length * correction / kcc;
 
     fIntegratedTime[i] += time;
   }
 }
 
 //_______________________________________________________________________
-
 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.
@@ -154,32 +144,158 @@ Double_t AliKalmanTrack::GetIntegratedTime(Int_t pdg) const
 
 
   if (!fStartTimeIntegral) {
-    Warning("GetIntegratedTime","Time integration not started");
+    AliWarning("Time integration not started");
     return 0.;
   }
 
-  static Int_t pdgCode[fTypes] = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton};
-
-  for (Int_t i=0; i<fTypes; i++)
-    if (pdgCode[i] == TMath::Abs(pdg)) return fIntegratedTime[i];
+  for (Int_t i=0; i<AliPID::kSPECIES; i++)
+    if (AliPID::ParticleCode(i) == TMath::Abs(pdg)) return fIntegratedTime[i];
 
-  Warning(":GetIntegratedTime","Particle type [%d] not found", pdg);
+  AliWarning(Form("Particle type [%d] not found", pdg));
   return 0;
 }
-//_______________________________________________________________________
 
-void AliKalmanTrack::PrintTime() const
+void AliKalmanTrack::GetIntegratedTimes(Double_t *times) const {
+  for (Int_t i=0; i<AliPID::kSPECIES; i++) times[i]=fIntegratedTime[i];
+}
+
+void AliKalmanTrack::SetIntegratedTimes(const Double_t *times) {
+  for (Int_t i=0; i<AliPID::kSPECIES; i++) fIntegratedTime[i]=times[i];
+}
+
+Double_t AliKalmanTrack::MeanMaterialBudget(Double_t *start, Double_t *end, Double_t *mparam)
 {
-  // For testing
-  // Prints time for all hypothesis
+  // 
+  // 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[4]   = length;
+  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];
 
-  static Int_t pdgCode[fTypes] = {kElectron, kMuonMinus, kPiPlus, kKPlus, kProton};
+    if (snext>=length) break;
+    if (!currentnode) 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;
 
-  for (Int_t i=0; i<fTypes; i++)
-    printf("%d: %.2f  ", pdgCode[i], fIntegratedTime[i]);
-  printf("\n");  
 }
 
-//_______________________________________________________________________
-