]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtrackV1.cxx
Updated tracking code by Alexandru und Markus
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackV1.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 //                                                                           //
20 //  TRD track                                                                //
21 //                                                                           //
22 //  Authors:                                                                 //
23 //    Alex Bercuci <A.Bercuci@gsi.de>                                        //
24 //    Markus Fasel <M.Fasel@gsi.de>                                          //
25 //                                                                           //
26 ///////////////////////////////////////////////////////////////////////////////
27
28 #include "AliTRDtrackV1.h"
29 #include "AliTRDcluster.h"
30 #include "AliTRDcalibDB.h"
31 #include "AliTRDrecoParam.h"
32
33 #include "AliESDtrack.h"
34
35 ClassImp(AliTRDtrackV1)
36
37
38 //_______________________________________________________________
39 AliTRDtrackV1::AliTRDtrackV1() :
40         AliTRDtrack()
41         ,fRecoParam(0x0)
42 {       
43   //
44   // Default constructor
45   //
46
47         for(int ip=0; ip<6; ip++){
48                 fTrackletIndex[ip] = -1;
49                 fTracklet[ip].Reset();
50         }
51 }
52
53 //_______________________________________________________________
54 AliTRDtrackV1::AliTRDtrackV1(const AliESDtrack &t) :
55         AliTRDtrack(t)
56         ,fRecoParam(0x0)
57 {
58   //
59   // Standard constructor
60   //
61
62         //AliInfo(Form("alpha %f", GetAlpha()));
63         t.GetTRDtracklets(&fTrackletIndex[0]);
64         for(int ip=0; ip<6; ip++) fTracklet[ip].Reset();
65 }
66
67 //_______________________________________________________________
68 AliTRDtrackV1::AliTRDtrackV1(const AliTRDtrackV1 &t) :
69         AliTRDtrack(t)
70         ,fRecoParam(0x0)
71 {
72   //
73   // Copy constructor
74   //
75
76 }
77
78 //_______________________________________________________________
79 // AliTRDtrackV1::~AliTRDtrackV1()
80 // {
81 //      
82 // }
83
84         
85 //_______________________________________________________________
86 AliTRDtrackV1::AliTRDtrackV1(AliTRDseedV1 *trklts, const Double_t p[5], const Double_t cov[15], Double_t x, Double_t alpha) :
87         AliTRDtrack()
88         ,fRecoParam(0x0)
89 {
90 // The stand alone tracking constructor
91 // TEMPORARY !!!!!!!!!!!
92 // to check :
93 // 1. covariance matrix
94 // 2. dQdl calculation
95
96
97         Double_t cnv   = 1.0 / (GetBz() * kB2C);
98
99   Double_t pp[5] = { p[0]    
100                    , p[1]
101                    , x*p[4] - p[2]
102                    , p[3]
103                    , p[4]*cnv      };
104
105   Double_t c22 = x*x*cov[14] - 2*x*cov[12] + cov[ 5];
106   Double_t c32 =   x*cov[13] -     cov[ 8];
107   Double_t c20 =   x*cov[10] -     cov[ 3];
108   Double_t c21 =   x*cov[11] -     cov[ 4];
109   Double_t c42 =   x*cov[14] -     cov[12];
110
111   Double_t cc[15] = { cov[ 0]
112                     , cov[ 1],     cov[ 2]
113                     , c20,         c21,         c22
114                     , cov[ 6],     cov[ 7],     c32,     cov[ 9]
115                     , cov[10]*cnv, cov[11]*cnv, c42*cnv, cov[13]*cnv, cov[14]*cnv*cnv };
116   
117         Set(x,alpha,pp,cc);
118   Double_t s = GetSnp();
119   Double_t t = GetTgl();
120
121         Int_t ncl = 0, nclPlane; AliTRDcluster *c = 0x0;
122         for(int iplane=0; iplane<6; iplane++){
123                 fTrackletIndex[iplane] = -1;
124                 fTracklet[iplane] = trklts[iplane];
125                 nclPlane = 0;
126                 for(int ic = 0; ic<AliTRDseed::knTimebins; ic++){
127                         if(!fTracklet[iplane].IsUsable(ic)) continue;
128                         if(!(c = fTracklet[iplane].GetClusters(ic))) continue;
129                         
130                         fIndex[ncl]      = fTracklet[iplane].GetIndexes(ic);
131                         Double_t q = TMath::Abs(c->GetQ());
132                         fClusters[ncl]   = c;
133                         // temporary !!!
134                         // This is not correctly. Has to be updated in the AliTRDtrackerV1::FollowBackProlonagation()
135                         fdQdl[ncl]       = q * (s*s < 1.) ? TMath::Sqrt((1-s*s)/(1+t*t)) : 1.;
136                         ncl++;
137                         nclPlane++;
138                 }
139                 //printf("%d N clusters plane %d [%d %d].\n", iplane, nclPlane, fTracklet[iplane].GetN2(), trklts[iplane].GetN());
140         }
141         //printf("N clusters in AliTRDtrackV1 %d.\n", ncl);
142         SetNumberOfClusters(ncl);
143 }
144
145 //_______________________________________________________________
146 Bool_t AliTRDtrackV1::CookPID()
147 {
148 // CookdEdx();  // truncated mean ... do we still need it ?
149
150 // CookdEdxTimBin(seed->GetID());
151         for(int itrklt=0; itrklt<6; itrklt++){
152     for (Int_t iSlice = 0; iSlice < AliESDtrack::kNSlice; iSlice++) fdEdxPlane[itrklt][iSlice] = -1.;
153
154                 if(fTrackletIndex[itrklt]<0) continue;
155                 fTracklet[itrklt].CookdEdx(fdEdxPlane[itrklt]);
156         }
157
158         // retrive calibration db
159   AliTRDcalibDB *calibration = AliTRDcalibDB::Instance();
160   if (!calibration) {
161     AliError("No access to calibration data");
162     return kFALSE;
163   }
164
165   // Retrieve the CDB container class with the parametric detector response
166   const AliTRDCalPID *pd = calibration->GetPIDObject(0/*fRecoParam->GetPIDMethod()*/);
167   if (!pd) {
168     AliError("No access to AliTRDCalPID object");
169     return kFALSE;
170   }
171
172 // CookPID(pidQ);
173
174
175 }
176
177
178 //_______________________________________________________________
179 Double_t AliTRDtrackV1::GetPredictedChi2(const AliTRDseedV1 *trklt) const
180 {
181   //
182   // Returns the predicted chi2
183   //
184
185   Double_t x      = trklt->GetX0();
186   Double_t p[2]   = { trklt->GetYat(x)
187                     , trklt->GetZat(x) };
188   Double_t cov[3];
189         trklt->GetCovAt(x, cov);
190
191   return AliExternalTrackParam::GetPredictedChi2(p, cov);
192
193 }
194
195 //_______________________________________________________________
196 void AliTRDtrackV1::SetTracklet(AliTRDseedV1 *trklt, Int_t plane, Int_t index)
197 {
198   //
199   // Sets the tracklets
200   //
201
202         if(plane < 0 || plane >=6) return;
203         fTracklet[plane]      = (*trklt);
204         fTrackletIndex[plane] = index;
205 }
206
207 //_______________________________________________________________
208 Bool_t  AliTRDtrackV1::Update(const  AliTRDseedV1 *trklt, Double_t chisq)
209 {
210   //
211   // Update the track
212   //
213
214         Double_t x      = trklt->GetX0();
215   Double_t p[2]   = { trklt->GetYat(x)
216                     , trklt->GetZat(x) };
217   Double_t cov[3];
218         trklt->GetCovAt(x, cov);
219         
220 //      Print();
221 //      AliInfo(Form("cov[%f %f %f]", cov[0], cov[1], cov[2]));
222
223   if(!AliExternalTrackParam::Update(p, cov)) return kFALSE;
224         //Print();
225
226   // Register info to track
227 //   Int_t n      = GetNumberOfClusters();
228 //   fIndex[n]    = index;
229 //   fClusters[n] = c;
230   SetNumberOfClusters(GetNumberOfClusters()+trklt->GetN());
231   SetChi2(GetChi2() + chisq);
232
233         return kTRUE;
234 }
235
236 //_______________________________________________________________
237 void AliTRDtrackV1::UpdateESDdEdx(AliESDtrack *track)
238 {
239   //
240   // Update the dedx info
241   //
242
243         for (Int_t i = 0; i < AliESDtrack::kNPlane; i++) {
244                 for (Int_t j = 0; j < AliESDtrack::kNSlice; j++) {
245                         track->SetTRDsignals(fdEdxPlane[i][j], i, j);
246                 }
247                 track->SetTRDTimBin(fTimBinPlane[i], i);
248         }
249 }