]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliTracker.cxx
Additional comment
[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 "AliRun.h"
30 #include "AliMagF.h"
31
32 #include "TFile.h"
33 #include "Riostream.h"
34
35
36 extern AliRun* gAlice;
37
38 ClassImp(AliTracker)
39
40 //__________________________________________________________________________
41 void AliTracker::CookLabel(AliKalmanTrack *t, Float_t wrong) const {
42   //--------------------------------------------------------------------
43   //This function "cooks" a track label. If label<0, this track is fake.
44   //--------------------------------------------------------------------
45   Int_t noc=t->GetNumberOfClusters();
46   Int_t *lb=new Int_t[noc];
47   Int_t *mx=new Int_t[noc];
48   AliCluster **clusters=new AliCluster*[noc];
49
50   Int_t i;
51   for (i=0; i<noc; i++) {
52      lb[i]=mx[i]=0;
53      Int_t index=t->GetClusterIndex(i);
54      clusters[i]=GetCluster(index);
55   }
56
57   Int_t lab=123456789;
58   for (i=0; i<noc; i++) {
59     AliCluster *c=clusters[i];
60     lab=TMath::Abs(c->GetLabel(0));
61     Int_t j;
62     for (j=0; j<noc; j++) if (lb[j]==lab || mx[j]==0) break;
63     lb[j]=lab;
64     (mx[j])++;
65   }
66
67   Int_t max=0;
68   for (i=0; i<noc; i++) if (mx[i]>max) {max=mx[i]; lab=lb[i];}
69     
70   for (i=0; i<noc; i++) {
71     AliCluster *c=clusters[i];
72     if (TMath::Abs(c->GetLabel(1)) == lab ||
73         TMath::Abs(c->GetLabel(2)) == lab ) max++;
74   }
75
76   if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
77   t->SetLabel(lab);
78
79   delete[] lb;
80   delete[] mx;
81   delete[] clusters;
82 }
83
84 //____________________________________________________________________________
85 void AliTracker::UseClusters(const AliKalmanTrack *t, Int_t from) const {
86   //------------------------------------------------------------------
87   //This function marks clusters associated with the track.
88   //------------------------------------------------------------------
89   Int_t noc=t->GetNumberOfClusters();
90   for (Int_t i=from; i<noc; i++) {
91      Int_t index=t->GetClusterIndex(i);
92      AliCluster *c=GetCluster(index); 
93      c->Use();   
94   }
95 }
96
97 ////////////////////////////////////////////////////////////////////////
98 Int_t AliTracker::SetFieldFactor() {
99 //
100 // Utility class to set the value of the magnetic field in the barrel
101 // It supposes that the correct object gAlice is in the memory
102 //
103    AliKalmanTrack::SetConvConst(1000/0.299792458/gAlice->Field()->SolenoidField());
104    cout<<"Magnetic field in kGauss: "<<gAlice->Field()->SolenoidField()<<endl;
105    return 0;
106 }
107 ////////////////////////////////////////////////////////////////////////
108 Int_t AliTracker::SetFieldFactor(TFile *file, Bool_t deletegAlice) {
109 //
110 // Utility class to set the value of the magnetic field in the barrel
111 // gAlice object is read from the file, and optionally deleted
112 // 
113   if (!(gAlice=(AliRun*)file->Get("gAlice"))) {
114     cerr<<"gAlice has not been found in file "<<file->GetName();
115     return 1;
116   }   
117   Int_t rc = SetFieldFactor();
118   if (deletegAlice) {
119     delete gAlice;  
120     gAlice = 0;
121   }
122   return rc;
123 }
124 ////////////////////////////////////////////////////////////////////////
125 Int_t AliTracker::SetFieldFactor(Char_t* fileName, Bool_t closeFile) {
126 //
127 // Utility class to set the value of the magnetic field in the barrel
128 // gAlice object is read from the file, the file is optionally closed
129 // 
130    TFile *file=TFile::Open(fileName);
131    if (!file->IsOpen()) {cerr<<"Cannnot open "<<fileName<<" !\n"; return 1;}
132    Int_t rc = SetFieldFactor(file, closeFile) ;
133    if (closeFile) file->Close();
134    return rc;
135 }
136 ////////////////////////////////////////////////////////////////////////
137