]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliTracker.cxx
Record changes.
[u/mrichter/AliRoot.git] / STEER / AliTracker.cxx
index 280155dd2b48d6d6acbd556af7bdac02e5fcd4d0..e0262c5125fa01f54e600624bc7c7b7ee81cc40d 100644 (file)
 
 //-------------------------------------------------------------------------
 //               Implementation of the AliTracker class
-//                             Origin
-//               Iouri Belikov, CERN, Jouri.Belikov@cern.ch
+//  that is the base for AliTPCtracker, AliITStrackerV2 and AliTRDtracker    
+//        Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
 //-------------------------------------------------------------------------
-
+#include <TClass.h>
 #include <TMath.h>
 
+#include "AliMagF.h"
 #include "AliTracker.h"
 #include "AliCluster.h"
 #include "AliKalmanTrack.h"
-#include "AliRun.h"
-#include "AliMagF.h"
 
-#include "TFile.h"
-#include "Riostream.h"
+Bool_t AliTracker::fgUniformField=kTRUE;
+Double_t AliTracker::fgBz=kAlmost0Field;
+const AliMagF *AliTracker::fgkFieldMap=0;
 
+ClassImp(AliTracker)
+
+AliTracker::AliTracker():
+  TObject(),
+  fX(0),
+  fY(0),
+  fZ(0),
+  fSigmaX(0.005),
+  fSigmaY(0.005),
+  fSigmaZ(0.010)
+{
+  //--------------------------------------------------------------------
+  // The default constructor.
+  //--------------------------------------------------------------------
+  if (!fgkFieldMap) AliWarning("Field map is not set. Call AliTracker::SetFieldMap before creating a tracker!");
+}
 
-extern AliRun* gAlice;
+//__________________________________________________________________________
+AliTracker::AliTracker(const AliTracker &atr):
+  TObject(atr),
+  fX(atr.fX),
+  fY(atr.fY),
+  fZ(atr.fZ),
+  fSigmaX(atr.fSigmaX),
+  fSigmaY(atr.fSigmaY),
+  fSigmaZ(atr.fSigmaZ)
+{
+  //--------------------------------------------------------------------
+  // The default constructor.
+  //--------------------------------------------------------------------
+  if (!fgkFieldMap) AliWarning("Field map is not set. Call AliTracker::SetFieldMap before creating a tracker!");
+}
 
-ClassImp(AliTracker)
+//__________________________________________________________________________
+void AliTracker::SetFieldMap(const AliMagF* map, Bool_t uni) {
+  //--------------------------------------------------------------------
+  //This passes the field map to the reconstruction.
+  //--------------------------------------------------------------------
+  if (map==0) AliFatalClass("Can't access the field map !");
+
+  if (fgkFieldMap) {
+     AliWarningClass("The magnetic field map has been already set !");
+     return;
+  }
+
+  fgUniformField=uni;
+  fgkFieldMap=map;
+
+  //Float_t r[3]={0.,0.,0.},b[3]; map->Field(r,b);
+  //Double_t bz=-b[2];
+  Double_t bz=-map->SolenoidField();
+  fgBz=TMath::Sign(kAlmost0Field,bz) + bz;
+
+}
 
 //__________________________________________________________________________
 void AliTracker::CookLabel(AliKalmanTrack *t, Float_t wrong) const {
@@ -69,11 +120,15 @@ void AliTracker::CookLabel(AliKalmanTrack *t, Float_t wrong) const {
     
   for (i=0; i<noc; i++) {
     AliCluster *c=clusters[i];
-    if (TMath::Abs(c->GetLabel(1)) == lab ||
-        TMath::Abs(c->GetLabel(2)) == lab ) max++;
+    //if (TMath::Abs(c->GetLabel(1)) == lab ||
+    //    TMath::Abs(c->GetLabel(2)) == lab ) max++;
+    if (TMath::Abs(c->GetLabel(0)!=lab))
+       if (TMath::Abs(c->GetLabel(1)) == lab ||
+           TMath::Abs(c->GetLabel(2)) == lab ) max++;
   }
 
   if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
+  t->SetFakeRatio((1.- Float_t(max)/noc));
   t->SetLabel(lab);
 
   delete[] lb;
@@ -94,44 +149,11 @@ void AliTracker::UseClusters(const AliKalmanTrack *t, Int_t from) const {
   }
 }
 
-////////////////////////////////////////////////////////////////////////
-Int_t AliTracker::SetFieldFactor() {
-//
-// Utility class to set the value of the magnetic field in the barrel
-// It supposes that the correct object gAlice is in the memory
-//
-   AliKalmanTrack::SetConvConst(1000/0.299792458/gAlice->Field()->SolenoidField());
-   cout<<"Magnetic field in kGauss: "<<gAlice->Field()->SolenoidField()<<endl;
-   return 0;
-}
-////////////////////////////////////////////////////////////////////////
-Int_t AliTracker::SetFieldFactor(TFile *file, Bool_t deletegAlice) {
-//
-// Utility class to set the value of the magnetic field in the barrel
-// gAlice object is read from the file, and optionally deleted
-// 
-  if (!(gAlice=(AliRun*)file->Get("gAlice"))) {
-    cerr<<"gAlice has not been found in file "<<file->GetName();
-    return 1;
-  }   
-  Int_t rc = SetFieldFactor();
-  if (deletegAlice) {
-    delete gAlice;  
-    gAlice = 0;
-  }
-  return rc;
-}
-////////////////////////////////////////////////////////////////////////
-Int_t AliTracker::SetFieldFactor(Char_t* fileName, Bool_t closeFile) {
-//
-// Utility class to set the value of the magnetic field in the barrel
-// gAlice object is read from the file, the file is optionally closed
-// 
-   TFile *file=TFile::Open(fileName);
-   if (!file->IsOpen()) {cerr<<"Cannnot open "<<fileName<<" !\n"; return 1;}
-   Int_t rc = SetFieldFactor(file, closeFile) ;
-   if (closeFile) file->Close();
-   return rc;
+Double_t AliTracker::GetBz(Float_t *r) {
+  //------------------------------------------------------------------
+  // Returns Bz (kG) at the point "r" .
+  //------------------------------------------------------------------
+    Float_t b[3]; fgkFieldMap->Field(r,b);
+    Double_t bz=-Double_t(b[2]);
+    return  (TMath::Sign(kAlmost0Field,bz) + bz);
 }
-////////////////////////////////////////////////////////////////////////
-