]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliTracker.cxx
Additional protection in case of zero magnetic field (Yu.Belikov)
[u/mrichter/AliRoot.git] / STEER / AliTracker.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //-------------------------------------------------------------------------
19 //               Implementation of the AliTracker class
20 //  that is the base for AliTPCtracker, AliITStrackerV2 and AliTRDtracker    
21 //        Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
22 //-------------------------------------------------------------------------
23
24 #include <TMath.h>
25
26 #include "AliTracker.h"
27 #include "AliCluster.h"
28 #include "AliKalmanTrack.h"
29 #include "AliLog.h"
30 #include "AliRun.h"
31 #include "AliMagF.h"
32
33 extern AliRun* gAlice;
34
35 const AliMagF *AliTracker::fgkFieldMap=0;
36
37 ClassImp(AliTracker)
38
39 AliTracker::AliTracker():
40   fEventN(0),
41   fStoreBarrel(1),
42   fX(0),
43   fY(0),
44   fZ(0),
45   fSigmaX(0.005),
46   fSigmaY(0.005),
47   fSigmaZ(0.010)
48 {
49   //--------------------------------------------------------------------
50   // The default constructor.
51   //--------------------------------------------------------------------
52  AliMagF *field=gAlice->Field();
53  if (field==0) AliFatal("Can't access the field map !");
54  SetFieldMap(field);
55 }
56
57 void AliTracker::SetFieldMap(const AliMagF* map) {
58   //--------------------------------------------------------------------
59   //This passes the field map to the reconstruction.
60   //--------------------------------------------------------------------
61   if (map==0) AliFatalClass("Can't access the field map !");
62   AliKalmanTrack::SetConvConst(1000/0.299792458/(map->SolenoidField()+1e-13));
63   fgkFieldMap=map;
64 }
65
66 //__________________________________________________________________________
67 void AliTracker::CookLabel(AliKalmanTrack *t, Float_t wrong) const {
68   //--------------------------------------------------------------------
69   //This function "cooks" a track label. If label<0, this track is fake.
70   //--------------------------------------------------------------------
71   Int_t noc=t->GetNumberOfClusters();
72   Int_t *lb=new Int_t[noc];
73   Int_t *mx=new Int_t[noc];
74   AliCluster **clusters=new AliCluster*[noc];
75
76   Int_t i;
77   for (i=0; i<noc; i++) {
78      lb[i]=mx[i]=0;
79      Int_t index=t->GetClusterIndex(i);
80      clusters[i]=GetCluster(index);
81   }
82
83   Int_t lab=123456789;
84   for (i=0; i<noc; i++) {
85     AliCluster *c=clusters[i];
86     lab=TMath::Abs(c->GetLabel(0));
87     Int_t j;
88     for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
89     lb[j]=lab;
90     (mx[j])++;
91   }
92
93   Int_t max=0;
94   for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
95     
96   for (i=0; i<noc; i++) {
97     AliCluster *c=clusters[i];
98     //if (TMath::Abs(c->GetLabel(1)) == lab ||
99     //    TMath::Abs(c->GetLabel(2)) == lab ) max++;
100     if (TMath::Abs(c->GetLabel(0)!=lab))
101         if (TMath::Abs(c->GetLabel(1)) == lab ||
102             TMath::Abs(c->GetLabel(2)) == lab ) max++;
103   }
104
105   if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
106   t->SetFakeRatio((1.- Float_t(max)/noc));
107   t->SetLabel(lab);
108
109   delete[] lb;
110   delete[] mx;
111   delete[] clusters;
112 }
113
114 //____________________________________________________________________________
115 void AliTracker::UseClusters(const AliKalmanTrack *t, Int_t from) const {
116   //------------------------------------------------------------------
117   //This function marks clusters associated with the track.
118   //------------------------------------------------------------------
119   Int_t noc=t->GetNumberOfClusters();
120   for (Int_t i=from; i<noc; i++) {
121      Int_t index=t->GetClusterIndex(i);
122      AliCluster *c=GetCluster(index); 
123      c->Use();   
124   }
125 }