]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliTracker.cxx
New class for raw data processing (T.Kuhr)
[u/mrichter/AliRoot.git] / STEER / AliTracker.cxx
CommitLineData
be9c5115 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
acd84897 16/* $Id$ */
fb17acd4 17
be9c5115 18//-------------------------------------------------------------------------
19// Implementation of the AliTracker class
9b83b8cc 20// that is the base for AliTPCtracker, AliITStrackerV2 and AliTRDtracker
21// Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
be9c5115 22//-------------------------------------------------------------------------
116cbefd 23
be9c5115 24#include <TMath.h>
25
26#include "AliTracker.h"
27#include "AliCluster.h"
28#include "AliKalmanTrack.h"
41377c29 29#include "AliRun.h"
30#include "AliMagF.h"
31
32#include "TFile.h"
1d5fc4ea 33#include "TError.h"
41377c29 34
35
36extern AliRun* gAlice;
be9c5115 37
38ClassImp(AliTracker)
39
40//__________________________________________________________________________
41void 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
bb9d1614 70 max=0;
be9c5115 71 for (i=0; i<noc; i++) {
72 AliCluster *c=clusters[i];
bb9d1614 73 if (TMath::Abs(c->GetLabel(0)) == lab ||
74 TMath::Abs(c->GetLabel(1)) == lab ||
be9c5115 75 TMath::Abs(c->GetLabel(2)) == lab ) max++;
76 }
77
78 if ((1.- Float_t(max)/noc) > wrong) lab=-lab;
79 t->SetLabel(lab);
80
81 delete[] lb;
82 delete[] mx;
83 delete[] clusters;
84}
85
86//____________________________________________________________________________
87void AliTracker::UseClusters(const AliKalmanTrack *t, Int_t from) const {
88 //------------------------------------------------------------------
89 //This function marks clusters associated with the track.
90 //------------------------------------------------------------------
91 Int_t noc=t->GetNumberOfClusters();
92 for (Int_t i=from; i<noc; i++) {
93 Int_t index=t->GetClusterIndex(i);
94 AliCluster *c=GetCluster(index);
95 c->Use();
96 }
97}
98
41377c29 99////////////////////////////////////////////////////////////////////////
100Int_t AliTracker::SetFieldFactor() {
101//
102// Utility class to set the value of the magnetic field in the barrel
103// It supposes that the correct object gAlice is in the memory
104//
1d5fc4ea 105 AliKalmanTrack::
106 SetConvConst(1000/0.299792458/gAlice->Field()->SolenoidField());
107 Double_t field=gAlice->Field()->SolenoidField();
108 ::Info("SetFieldFactor","Magnetic field in kGauss: %f\n",field);
41377c29 109 return 0;
110}
111////////////////////////////////////////////////////////////////////////
112Int_t AliTracker::SetFieldFactor(TFile *file, Bool_t deletegAlice) {
113//
114// Utility class to set the value of the magnetic field in the barrel
115// gAlice object is read from the file, and optionally deleted
116//
117 if (!(gAlice=(AliRun*)file->Get("gAlice"))) {
1d5fc4ea 118 ::Warning
119 ("SetFieldFactor","gAlice has not been found in file %s\n",file->GetName());
41377c29 120 return 1;
121 }
122 Int_t rc = SetFieldFactor();
123 if (deletegAlice) {
124 delete gAlice;
125 gAlice = 0;
126 }
127 return rc;
128}
129////////////////////////////////////////////////////////////////////////
e24ea474 130Int_t AliTracker::SetFieldFactor(const char* fileName, Bool_t closeFile) {
41377c29 131//
132// Utility class to set the value of the magnetic field in the barrel
133// gAlice object is read from the file, the file is optionally closed
134//
135 TFile *file=TFile::Open(fileName);
1d5fc4ea 136 if (!file->IsOpen()) {
137 ::Warning("AliTracker::SetFieldFactor","Cannnot open %s !\n",fileName);
138 return 1;
139 }
41377c29 140 Int_t rc = SetFieldFactor(file, closeFile) ;
141 if (closeFile) file->Close();
142 return rc;
143}
144////////////////////////////////////////////////////////////////////////
be9c5115 145