]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliTracker.cxx
- adding total umber of events to the HLTGlobalTriggerDecision counters
[u/mrichter/AliRoot.git] / STEER / AliTracker.cxx
index f465f40b6acd17564447f14a7fd0bee28d6a7b00..269f15ff08f9350e28af8ac4b6a1b497557cd1ca 100644 (file)
@@ -31,6 +31,7 @@
 #include "AliGeomManager.h"
 #include "AliCluster.h"
 #include "AliKalmanTrack.h"
+#include "AliGlobalQADataMaker.h"
 
 extern TGeoManager *gGeoManager;
 
@@ -47,7 +48,8 @@ AliTracker::AliTracker():
   fZ(0),
   fSigmaX(0.005),
   fSigmaY(0.005),
-  fSigmaZ(0.010) 
+  fSigmaZ(0.010),
+  fEventInfo(NULL)
 {
   //--------------------------------------------------------------------
   // The default constructor.
@@ -64,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.
@@ -93,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
 {
@@ -371,6 +396,61 @@ Double_t mass, Double_t maxStep, Bool_t rotateTo, Double_t maxSnp){
   return kTRUE;
 }
 
+Bool_t 
+AliTracker::PropagateTrackToBxByBz(AliExternalTrackParam *track,
+Double_t xToGo, 
+Double_t mass, Double_t maxStep, Bool_t rotateTo, Double_t maxSnp){
+  //----------------------------------------------------------------
+  //
+  // 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], 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;
+}
+
 void AliTracker::FillResiduals(const AliExternalTrackParam *t,
                              Double_t *p, Double_t *cov, 
                               UShort_t id, Bool_t updated) {
@@ -386,28 +466,29 @@ void AliTracker::FillResiduals(const AliExternalTrackParam *t,
   if (!residuals) return;
 
   TH1F *h=0;
+  Int_t esIndex = AliRecoParam::AConvert(fEventSpecie) ; 
   AliGeomManager::ELayerID layer=AliGeomManager::VolUIDToLayer(id);
-  h=(TH1F*)fResiduals[fEventSpecie]->At(2*layer-2);
+  h=(TH1F*)fResiduals[esIndex]->At(2*layer-2);
   h->Fill(residuals[0]);
-  h=(TH1F*)fResiduals[fEventSpecie]->At(2*layer-1);
+  h=(TH1F*)fResiduals[esIndex]->At(2*layer-1);
   h->Fill(residuals[1]);
 
   if (layer==5) {
     if (p[1]<0) {  // SSD1 absolute residuals
-       ((TH1F*)fResiduals[fEventSpecie]->At(40))->Fill(t->GetY()-p[0]); //C side
-       ((TH1F*)fResiduals[fEventSpecie]->At(41))->Fill(t->GetZ()-p[1]);
+       ((TH1F*)fResiduals[esIndex]->At(40))->Fill(t->GetY()-p[0]); //C side
+       ((TH1F*)fResiduals[esIndex]->At(41))->Fill(t->GetZ()-p[1]);
     } else {             
-       ((TH1F*)fResiduals[fEventSpecie]->At(42))->Fill(t->GetY()-p[0]); //A side
-       ((TH1F*)fResiduals[fEventSpecie]->At(43))->Fill(t->GetZ()-p[1]);
+       ((TH1F*)fResiduals[esIndex]->At(42))->Fill(t->GetY()-p[0]); //A side
+       ((TH1F*)fResiduals[esIndex]->At(43))->Fill(t->GetZ()-p[1]);
     }           
   }
   if (layer==6) {  // SSD2 absolute residuals
     if (p[1]<0) {
-       ((TH1F*)fResiduals[fEventSpecie]->At(44))->Fill(t->GetY()-p[0]); //C side
-       ((TH1F*)fResiduals[fEventSpecie]->At(45))->Fill(t->GetZ()-p[1]);
+       ((TH1F*)fResiduals[esIndex]->At(44))->Fill(t->GetY()-p[0]); //C side
+       ((TH1F*)fResiduals[esIndex]->At(45))->Fill(t->GetZ()-p[1]);
     } else {
-       ((TH1F*)fResiduals[fEventSpecie]->At(46))->Fill(t->GetY()-p[0]); //A side
-       ((TH1F*)fResiduals[fEventSpecie]->At(47))->Fill(t->GetZ()-p[1]);
+       ((TH1F*)fResiduals[esIndex]->At(46))->Fill(t->GetY()-p[0]); //A side
+       ((TH1F*)fResiduals[esIndex]->At(47))->Fill(t->GetZ()-p[1]);
     }
   }
 
@@ -445,10 +526,11 @@ void AliTracker::FillResiduals(const AliExternalTrackParam *t,
   Double_t residuals[2]={trkLoc[0]-clsLoc[0], trkLoc[2]-clsLoc[2]};
 
   TH1F *h=0;
+  Int_t esIndex = AliRecoParam::AConvert(fEventSpecie) ; 
   AliGeomManager::ELayerID layer=AliGeomManager::VolUIDToLayer(id);
-  h=(TH1F*)fResiduals[fEventSpecie]->At(2*layer-2);
+  h=(TH1F*)fResiduals[esIndex]->At(2*layer-2);
   h->Fill(residuals[0]);
-  h=(TH1F*)fResiduals[fEventSpecie]->At(2*layer-1);
+  h=(TH1F*)fResiduals[esIndex]->At(2*layer-1);
   h->Fill(residuals[1]);
 
 }