Obsolete class (related to V1 tracking)
[u/mrichter/AliRoot.git] / ITS / AliITSTrackerV1.cxx
CommitLineData
b48af428 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
88cb7938 16/* $Id$ */
61ab8ea8 17
af50998a 18// The purpose of this class is to permorm the ITS tracking. The
b48af428 19// constructor has the task to inizialize some private members. The method
20// DoTracking is written to be called by a macro. It gets the event number,
21// the minimum and maximum order number of TPC tracks that are to be tracked
22// trough the ITS, and the file where the recpoints are registered. The
23// method Recursivetracking is a recursive function that performs the
24// tracking trough the ITS The method Intersection found the layer, ladder
25// and detector whre the intersection take place and caluclate the
26// cohordinates of this intersection. It returns an integer that is 0 if the
27// intersection has been found successfully. The two mwthods Kalmanfilter
28// and kalmanfiltervert operate the kalmanfilter without and with the vertex
29// imposition respectively. The authors thank Mariana Bondila to have help
30// them to resolve some problems. July-2000
04b80329 31
4ae5bbc4 32#include <Riostream.h>
33#include <Riostream.h>
13888096 34#include <TMath.h>
13888096 35#include <TBranch.h>
36#include <TVector.h>
13888096 37#include <TFile.h>
38#include <TTree.h>
cbcfa38d 39#include <TStopwatch.h>
40
13888096 41#include "TParticle.h"
42#include "AliRun.h"
88cb7938 43#include "AliLoader.h"
13888096 44#include "AliITS.h"
04b80329 45#include "AliITSsegmentationSSD.h"
13888096 46#include "AliITSgeomSPD.h"
47#include "AliITSgeomSDD.h"
48#include "AliITSgeomSSD.h"
49#include "AliITSgeom.h"
13888096 50#include "AliITSRecPoint.h"
04b80329 51#include "stdlib.h"
13888096 52#include "AliKalmanTrack.h"
53#include "AliMagF.h"
04b80329 54#include "AliITSTrackV1.h"
55#include "AliITSIOTrack.h"
56#include "AliITSRad.h"
13888096 57#include "../TPC/AliTPCtracker.h"
13888096 58#include "AliITSTrackerV1.h"
0983ac5b 59#include "AliITSVertex.h"
def162f4 60#include "AliITSPid.h"
5d12ce38 61#include "AliMC.h"
13888096 62
13888096 63ClassImp(AliITSTrackerV1)
55cd883f 64 //______________________________________________________________________
65AliITSTrackerV1::AliITSTrackerV1() {
66 //Default constructor
67 fITS = 0;
68 fresult = 0;
64ab0d55 69 fPtref=0.;
70 fChi2max=0.;
71 //fepsphi=0.;
72 //fepsz=0.;
55cd883f 73 frecPoints = 0;
74 fvettid = 0;
64ab0d55 75 fflagvert=0;
55cd883f 76 frl = 0;
64ab0d55 77 Int_t ia;
78 for(ia=0; ia<6; ia++) {
79 fNlad[ia]=0;
80 fNdet[ia]=0;
81 fAvrad[ia]=0.;
82 fDetx[ia]=0.;
83 fDetz[ia]=0.;
84 } // end for ia
55cd883f 85 fzmin = 0;
86 fzmax = 0;
87 fphimin = 0;
88 fphimax = 0;
89 fphidet = 0;
64ab0d55 90 fNRecPoints=0;
91 fRecCylR=0;
92 fRecCylPhi=0;
93 fRecCylZ=0;
94 fFieldFactor=0;
55cd883f 95}
b48af428 96//______________________________________________________________________
64ab0d55 97AliITSTrackerV1::AliITSTrackerV1(AliITS* IITTSS, Int_t evnumber, Bool_t flag) {
b48af428 98 //Origin A. Badala' and G.S. Pappalardo:
99 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
100 // Class constructor. It does some initializations.
101
a49bb2c8 102 //PH Initialisation taken from the default constructor
b48af428 103 fITS = IITTSS;
a49bb2c8 104 fresult = 0;
64ab0d55 105 fPtref = 0.;
106 fChi2max =0.;
107 frecPoints = 0;
a49bb2c8 108 fvettid = 0;
64ab0d55 109 fflagvert = flag;
a49bb2c8 110 frl = 0;
111 fzmin = 0;
112 fzmax = 0;
113 fphimin = 0;
114 fphimax = 0;
115 fphidet = 0;
64ab0d55 116
b48af428 117 Int_t imax = 200,jmax = 450;
118 frl = new AliITSRad(imax,jmax);
119
120 ////////// gets information on geometry /////////////////////////////
64ab0d55 121 AliITSgeom *g1 = fITS->GetITSgeom();
b48af428 122 Int_t ll=1, dd=1;
123 TVector det(9);
124
b48af428 125 Int_t ia;
126 for(ia=0; ia<6; ia++) {
127 fNlad[ia]=g1->GetNladders(ia+1);
128 fNdet[ia]=g1->GetNdetectors(ia+1);
129 //cout<<fNlad[i]<<" "<<fNdet[i]<<"\n";
130 } // end for ia
b48af428 131
64ab0d55 132 //cout<<" mean radius = ";
b48af428 133 Int_t ib;
134 for(ib=0; ib<6; ib++) {
135 g1->GetCenterThetaPhi(ib+1,ll,dd,det);
136 Double_t r1=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
137 g1->GetCenterThetaPhi(ib+1,ll,dd+1,det);
138 Double_t r2=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
139 fAvrad[ib]=(r1+r2)/2.;
140 //cout<<fAvrad[ib]<<" ";
141 } // end for ib
142 //cout<<"\n"; getchar();
143
144 fDetx[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDx();
145 fDetz[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDz();
146
147 fDetx[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDx();
148 fDetz[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDz();
149
150 fDetx[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDx();
151 fDetz[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDz();
152
153 fDetx[3] = ((AliITSgeomSDD*)(g1->GetShape(4, ll, dd)))->GetDx();
154 fDetz[3] = ((AliITSgeomSDD*)(g1->GetShape(4, ll, dd)))->GetDz();
155
156 fDetx[4] = ((AliITSgeomSSD*)(g1->GetShape(5, ll, dd)))->GetDx();
157 fDetz[4] = ((AliITSgeomSSD*)(g1->GetShape(5, ll, dd)))->GetDz();
158
159 fDetx[5] = ((AliITSgeomSSD*)(g1->GetShape(6, ll, dd)))->GetDx();
160 fDetz[5] = ((AliITSgeomSSD*)(g1->GetShape(6, ll, dd)))->GetDz();
161 //cout<<" Detx Detz\n";
162 //for(Int_t la=0; la<6; la++) cout<<" "<<fDetx[la]<<" "<<
163 // fDetz[la]<<endl;
164 //getchar();
64ab0d55 165
b48af428 166 // allocate memory and define matrices fzmin, fzmax, fphimin and fphimax //
167 Double_t epsz=1.2;
168 Double_t epszdrift=0.05;
169
170 fzmin = new Double_t*[6]; fzmax = new Double_t*[6];
171 Int_t im1, im2, im2max;
172 for(im1=0; im1<6; im1++) {
173 im2max=fNdet[im1];
174 fzmin[im1] = new Double_t[im2max]; fzmax[im1] = new Double_t[im2max];
175 } // end for im1
176
177 for(im1=0; im1<6; im1++) {
178 im2max=fNdet[im1];
179 for(im2=0; im2<im2max; im2++) {
180 g1->GetCenterThetaPhi(im1+1,1,im2+1,det);
181 if(im2!=0) fzmin[im1][im2]=det(2)-fDetz[im1];
182 else
183 fzmin[im1][im2]=det(2)-(fDetz[im1])*epsz;
184 if(im2!=(im2max-1)) fzmax[im1][im2]=det(2)+fDetz[im1];
185 else
cbcfa38d 186 fzmax[im1][im2]=det(2)+fDetz[im1]*epsz;
b48af428 187 if(im1==2 || im1==3) {
188 fzmin[im1][im2]-=epszdrift;
189 fzmax[im1][im2]+=epszdrift;
190 } // end if im1==2 || im1==3
191 } // end for im2
192 } // end for im1
13888096 193
b48af428 194 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
195 for(im1=0;im1<6;im1++) {
196 im2max=fNlad[im1];
197 fphimin[im1] = new Double_t[im2max];
198 fphimax[im1] = new Double_t[im2max];
199 } // end for im1
200
201 fphidet = new Double_t*[6];
202 for(im1=0; im1<6; im1++) {
203 im2max=fNlad[im1];
204 fphidet[im1] = new Double_t[im2max];
205 } // end for im1
206
def162f4 207 Double_t global[3],local[3];
b48af428 208 Double_t pigre=TMath::Pi();
209 Double_t xmin,ymin,xmax,ymax;
210
211 for(im1=0; im1<6; im1++) {
212 im2max=fNlad[im1];
213 for(im2=0; im2<im2max; im2++) {
214 Int_t idet=2;
215 g1->GetCenterThetaPhi(im1+1,im2+1,idet,det);
216 fphidet[im1][im2] = TMath::ATan2(Double_t(det(1)),
217 Double_t(det(0)));
218 if(fphidet[im1][im2]<0.) fphidet[im1][im2]+=2.*pigre;
219 local[1]=local[2]=0.;
220 local[0]= -(fDetx[im1]);
221 if(im1==0) local[0]= (fDetx[im1]); //to take into account
222 // different reference system
223 g1->LtoG(im1+1,im2+1,idet,local,global);
224 xmax=global[0]; ymax=global[1];
225 local[0]= (fDetx[im1]);
226 if(im1==0) local[0]= -(fDetx[im1]);//take into account different
227 // reference system
228 g1->LtoG(im1+1,im2+1,idet,local,global);
229 xmin=global[0]; ymin=global[1];
230 fphimin[im1][im2]= TMath::ATan2(ymin,xmin);
231 if(fphimin[im1][im2]<0.) fphimin[im1][im2]+=2.*pigre;
232 fphimax[im1][im2]= TMath::ATan2(ymax,xmax);
233 if(fphimax[im1][im2]<0.) fphimax[im1][im2]+=2.*pigre;
234 } // end for im2
235 } // end for im1
64ab0d55 236//////////////////////////////////////////////////////////////////////////////////////////////////////////
237/////////////// allocate memory and define vector fNRecPoints and matrices fRecCylR, fRecCylPhi, fRecCylZ /////////////
238 gAlice->GetEvent(evnumber);
239 Int_t NumOfModules = g1->GetIndexMax();
64ab0d55 240 fRecCylR = new Double_t *[NumOfModules];
64ab0d55 241 fRecCylPhi = new Double_t *[NumOfModules];
64ab0d55 242 fRecCylZ = new Double_t *[NumOfModules];
243 AliITSRecPoint *recp;
244 fNRecPoints = new Int_t[NumOfModules];
245
246 for(Int_t module=0; module<NumOfModules; module++) {
247 fITS->ResetRecPoints();
248 gAlice->TreeR()->GetEvent(module);
249 frecPoints=fITS->RecPoints();
250 Int_t nRecPoints=fNRecPoints[module]=frecPoints->GetEntries();
64ab0d55 251 fRecCylR[module] = new Double_t[nRecPoints];
252 fRecCylPhi[module] = new Double_t[nRecPoints];
253 fRecCylZ[module] = new Double_t[nRecPoints];
254 Int_t ind;
255 for(ind=0; ind<fNRecPoints[module]; ind++) {
256 recp=(AliITSRecPoint*)frecPoints->UncheckedAt(ind);
257 // Float_t global[3], local[3];
258 Double_t global[3], local[3];
259 local[0]=recp->GetX();
260 local[1]=0.;
261 local[2]= recp->GetZ();
262 g1->LtoG(module,local,global);
64ab0d55 263
264 Double_t r = TMath::Sqrt(global[0]*global[0]+global[1]*global[1]); // r hit
265 Double_t phi = TMath::ATan2(global[1],global[0]); if(phi<0.) phi+=2.*TMath::Pi(); // phi hit
def162f4 266 Double_t z = global[2]; // z hit
64ab0d55 267
268 fRecCylR[module][ind]=r;
269 fRecCylPhi[module][ind]=phi;
270 fRecCylZ[module][ind]=z;
271 }
272 }
273 //}
274 //}
275////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
276
b48af428 277
278 ////////// gets magnetic field factor //////////////////////////////
279
280 AliMagF * fieldPointer = gAlice->Field();
af50998a 281 // fFieldFactor = (Double_t)fieldPointer->Factor();
282 fFieldFactor =(Double_t)fieldPointer-> SolenoidField()/10/.2;
283 // cout<< " field factor = "<<fFieldFactor<<"\n"; getchar();
b48af428 284}
285//______________________________________________________________________
d0df5576 286AliITSTrackerV1::AliITSTrackerV1(const AliITSTrackerV1 &cobj) : TObject(cobj) {
b48af428 287 // Origin A. Badala' and G.S. Pappalardo:
288 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
289 // copy constructor
64ab0d55 290
291 *fITS = *cobj.fITS;
b48af428 292 *fresult = *cobj.fresult;
293 fPtref = cobj.fPtref;
294 fChi2max = cobj.fChi2max;
295 **fvettid = **cobj.fvettid;
296 fflagvert = cobj.fflagvert;
297 Int_t imax=200,jmax=450;
298 frl = new AliITSRad(imax,jmax);
299 *frl = *cobj.frl;
300 fFieldFactor = cobj.fFieldFactor;
301 Int_t i,im1,im2,im2max;
302 for(i=0; i<6; i++) {
303 fNlad[i] = cobj.fNlad[i];
304 fNdet[i] = cobj.fNdet[i];
305 fAvrad[i] = cobj.fAvrad[i];
306 fDetx[i] = cobj.fDetx[i];
307 fDetz[i] = cobj.fDetz[i];
308 } // end or i
309 fzmin = new Double_t*[6]; fzmax = new Double_t*[6];
310 for(im1=0; im1<6; im1++) {
311 im2max=fNdet[im1];
312 fzmin[im1] = new Double_t[im2max];
313 fzmax[im1] = new Double_t[im2max];
314 } // end for im1
cbcfa38d 315 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
b48af428 316 for(im1=0;im1<6;im1++) {
317 im2max=fNlad[im1];
318 fphimin[im1] = new Double_t[im2max];
319 fphimax[im1] = new Double_t[im2max];
320 } // end for im1
321
322 fphidet = new Double_t*[6];
323 for(im1=0; im1<6; im1++) {
324 im2max=fNlad[im1];
325 fphidet[im1] = new Double_t[im2max];
326 } // end for im1
327 for(im1=0; im1<6; im1++) {
328 im2max=fNdet[im1];
329 for(im2=0; im2<im2max; im2++) {
330 fzmin[im1][im2]=cobj.fzmin[im1][im2];
331 fzmax[im1][im2]=cobj.fzmax[im1][im2];
332 } // end for im2
333 } // end for im1
334 for(im1=0; im1<6; im1++) {
335 im2max=fNlad[im1];
336 for(im2=0; im2<im2max; im2++) {
337 fphimin[im1][im2]=cobj.fphimin[im1][im2];
338 fphimax[im1][im2]=cobj.fphimax[im1][im2];
339 fphidet[im1][im2]=cobj.fphidet[im1][im2];
340 } // end for im2
341 } // end for im2
64ab0d55 342
343
344 AliITSgeom *g1 = fITS->GetITSgeom();
345 Int_t NumOfModules = g1->GetIndexMax();
346 /*
347 fRecCylR = new Float_t *[NumOfModules];
348 fRecCylPhi = new Float_t *[NumOfModules];
349 fRecCylZ = new Float_t *[NumOfModules];
350 */
351 fRecCylR = new Double_t *[NumOfModules];
352 fRecCylPhi = new Double_t *[NumOfModules];
353 fRecCylZ = new Double_t *[NumOfModules];
354 fNRecPoints = new Int_t[NumOfModules];
355 for(Int_t module=0; module<NumOfModules; module++) {
356 Int_t nRecPoints=fNRecPoints[module]=cobj.fNRecPoints[module];
357 /*
358 fRecCylR[module] = new Float_t[nRecPoints];
359 fRecCylPhi[module] = new Float_t[nRecPoints];
360 fRecCylZ[module] = new Float_t[nRecPoints];
361 */
362 fRecCylR[module] = new Double_t[nRecPoints];
363 fRecCylPhi[module] = new Double_t[nRecPoints];
364 fRecCylZ[module] = new Double_t[nRecPoints];
365 Int_t ind;
366 for(ind=0; ind<nRecPoints; ind++) {
367 fRecCylR[module][ind]=cobj.fRecCylR[module][ind];
368 fRecCylPhi[module][ind]=cobj.fRecCylPhi[module][ind];
369 fRecCylZ[module][ind]=cobj.fRecCylZ[module][ind];
370 }
371 }
372
373}
374void AliITSTrackerV1::DelMatrix(Int_t NumOfModules) {
375 for(Int_t mod=0; mod<NumOfModules; mod++) {
376 delete fRecCylR[mod];
377 delete fRecCylPhi[mod];
378 delete fRecCylZ[mod];
379 }
380 delete fRecCylR;
381 delete fRecCylPhi;
382 delete fRecCylZ;
cbcfa38d 383}
b48af428 384//______________________________________________________________________
cbcfa38d 385AliITSTrackerV1::~AliITSTrackerV1(){
b48af428 386 // Origin A. Badala' and G.S. Pappalardo:
387 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
64ab0d55 388 // class destructor
389 delete frl;
390 delete fNRecPoints;
391 for(Int_t i=0; i<6; i++) {
392 delete fzmin[i];
393 delete fzmax[i];
394 delete fphimin[i];
395 delete fphimax[i];
396 delete fphidet[i];
397 }
398
399 delete fzmin;
400 delete fzmax;
401 delete fphimin;
402 delete fphimax;
403 delete fphidet;
404
13888096 405}
b48af428 406//______________________________________________________________________
04b80329 407AliITSTrackerV1 &AliITSTrackerV1::operator=(AliITSTrackerV1 obj) {
b48af428 408 // Origin A. Badala' and G.S. Pappalardo:
409 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
410 // assignement operator
411
64ab0d55 412 *fITS = *obj.fITS;
b48af428 413 *fresult = *obj.fresult;
414 fPtref = obj.fPtref;
415 fChi2max = obj.fChi2max;
416 **fvettid = **obj.fvettid;
417 fflagvert = obj.fflagvert;
418 Int_t imax=200,jmax=450;
419 frl = new AliITSRad(imax,jmax);
420 *frl = *obj.frl;
421 fFieldFactor = obj.fFieldFactor;
422 Int_t i;
423 for(i=0; i<6; i++) {
424 fNlad[i] = obj.fNlad[i];
425 fNdet[i] = obj.fNdet[i];
426 fAvrad[i] = obj.fAvrad[i];
427 fDetx[i] = obj.fDetx[i];
428 fDetz[i] = obj.fDetz[i];
429 } // end for i
430 fzmin = new Double_t*[6];
431 fzmax = new Double_t*[6];
432 Int_t im1, im2, im2max;
433 for(im1=0; im1<6; im1++) {
434 im2max=fNdet[im1];
435 fzmin[im1] = new Double_t[im2max]; fzmax[im1] = new Double_t[im2max];
436 } // end for im1
cbcfa38d 437 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
b48af428 438 for(im1=0;im1<6;im1++) {
439 im2max=fNlad[im1];
440 fphimin[im1] = new Double_t[im2max];
441 fphimax[im1] = new Double_t[im2max];
442 } // end for im1
443
444 fphidet = new Double_t*[6];
445 for(im1=0; im1<6; im1++) {
446 im2max=fNlad[im1];
447 fphidet[im1] = new Double_t[im2max];
448 } // end for im1
449 for(im1=0; im1<6; im1++) {
450 im2max=fNdet[im1];
451 for(im2=0; im2<im2max; im2++) {
452 fzmin[im1][im2]=obj.fzmin[im1][im2];
453 fzmax[im1][im2]=obj.fzmax[im1][im2];
454 } // end for im2
455 } // end for im1
456 for(im1=0; im1<6; im1++) {
457 im2max=fNlad[im1];
458 for(im2=0; im2<im2max; im2++) {
459 fphimin[im1][im2]=obj.fphimin[im1][im2];
460 fphimax[im1][im2]=obj.fphimax[im1][im2];
461 fphidet[im1][im2]=obj.fphidet[im1][im2];
462 } // end for im2
463 } // end for im1
464
64ab0d55 465 AliITSgeom *g1 = fITS->GetITSgeom();
466 Int_t NumOfModules = g1->GetIndexMax();
64ab0d55 467 fRecCylR = new Double_t *[NumOfModules];
468 fRecCylPhi = new Double_t *[NumOfModules];
469 fRecCylZ = new Double_t *[NumOfModules];
470 fNRecPoints = new Int_t[NumOfModules];
471 for(Int_t module=0; module<NumOfModules; module++) {
472 Int_t nRecPoints=fNRecPoints[module]=obj.fNRecPoints[module];
64ab0d55 473 fRecCylR[module] = new Double_t[nRecPoints];
474 fRecCylPhi[module] = new Double_t[nRecPoints];
475 fRecCylZ[module] = new Double_t[nRecPoints];
476 Int_t ind;
477 for(ind=0; ind<nRecPoints; ind++) {
478 fRecCylR[module][ind]=obj.fRecCylR[module][ind];
479 fRecCylPhi[module][ind]=obj.fRecCylPhi[module][ind];
480 fRecCylZ[module][ind]=obj.fRecCylZ[module][ind];
481 }
482 }
483
484
b48af428 485 return *this;
04b80329 486}
b48af428 487//______________________________________________________________________
488void AliITSTrackerV1::DoTracking(Int_t evNumber,Int_t minTr,Int_t maxTr,
61231d74 489 TFile *file, Bool_t realmass) {
b48af428 490 // Origin A. Badala' and G.S. Pappalardo:
491 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
492 // The method needs the event number, the minimum and maximum order
493 // number of TPC tracks that
494 // are to be tracked trough the ITS, and the file where the recpoints
495 // are registered.
496 // The method can be called by a macro. It preforms the tracking for
497 // all good TPC tracks
498
499 printf("begin DoTracking - file %p\n",file);
500
501 gAlice->GetEvent(evNumber); //modificato per gestire hbt
13888096 502
88b5be23 503 AliKalmanTrack::SetConvConst(1000/0.299792458/gAlice->Field()->SolenoidField());
af50998a 504 // cout<<" field = "<<gAlice->Field()->SolenoidField()<<endl;
505
b48af428 506
507 TFile *cf=TFile::Open("AliTPCclusters.root");
9040b789 508 AliTPCParam *digp= (AliTPCParam*)cf->Get("75x40_100x60_150x60");
b48af428 509 if (!digp) { cerr<<"TPC parameters have not been found !\n"; getchar();}
510
511 cf->cd();
88cb7938 512 TString foldname(fITS->GetLoader()->GetEventFolder()->GetName());
513
c630aafd 514 printf("This method is not converted to the NewIO !\n"); //I.B.
515 return; //I.B.
516 AliTPCtracker *tracker = new AliTPCtracker(digp); //I.B.
88cb7938 517 //PH tracker->SetEventNumber(evNumber); //I.B.
b48af428 518
519 // Load clusters
c630aafd 520 printf("This method is not converted to the NewIO !\n"); //I.B.
521 return; //I.B.
522 tracker->LoadClusters(0); //I.B.
b48af428 523
524 // Load tracks
64ab0d55 525 TFile *tf=TFile::Open("AliTPCtracksSorted.root");
b48af428 526 if (!tf->IsOpen()) {
527 cerr<<"Can't open AliTPCtracksSorted.root !\n";
528 return ;
529 } // end if
530 TObjArray tracks(200000);
531 char tname[100];
532 sprintf(tname,"TreeT_TPC_%d",evNumber);
533
534 TTree *tracktree=(TTree*)tf->Get(tname);
535 if (!tracktree) {cerr<<"Can't get a tree with TPC tracks !\n";}
536 TBranch *tbranch=tracktree->GetBranch("tracks");
537 Int_t nentr=(Int_t)tracktree->GetEntries();
538 Int_t kk;
539
def162f4 540 AliITSRecPoint *recp; // oggi
541 AliTPCtrack *ioTrackTPC=0;
b48af428 542 for (kk=0; kk<nentr; kk++) {
543 ioTrackTPC=new AliTPCtrack;
544 tbranch->SetAddress(&ioTrackTPC);
545 tracktree->GetEvent(kk);
546 tracker->CookLabel(ioTrackTPC,0.1);
547 tracks.AddLast(ioTrackTPC);
548 } // end for kk
549 delete tracker;
550 tf->Close();
551
552 Int_t nt = tracks.GetEntriesFast();
553 cerr<<"Number of found tracks "<<nt<<endl;
554
555 TVector vec(5);
556 TTree *tr=gAlice->TreeR();
557 Int_t nent=(Int_t)tr->GetEntries();
558 frecPoints = fITS->RecPoints();
559
560 Int_t numbpoints;
561 Int_t totalpoints=0;
562 Int_t *np = new Int_t[nent];
563 fvettid = new Int_t* [nent];
564 Int_t mod;
565
566 for (mod=0; mod<nent; mod++) {
567 fvettid[mod]=0;
568 fITS->ResetRecPoints();
569 gAlice->TreeR()->GetEvent(mod);
570 numbpoints = frecPoints->GetEntries();
571 totalpoints+=numbpoints;
572 np[mod] = numbpoints;
573 //cout<<" mod = "<<mod<<" numbpoints = "<<numbpoints<<"\n";getchar();
574 fvettid[mod] = new Int_t[numbpoints];
575 Int_t ii;
576 for (ii=0;ii<numbpoints; ii++) *(fvettid[mod]+ii)=0;
577 } // end for mod
578
579 AliTPCtrack *track=0;
580
581 if(minTr < 0) {minTr = 0; maxTr = nt-1;}
582
583 TVector vgeant(3);
584
585 TTree tracktree1("TreeT","Tree with ITS tracks");
586 AliITSIOTrack *ioTrack=0;
def162f4 587 AliITSPid *pid=new AliITSPid(1000); // oggi
588
b48af428 589 tracktree1.Branch("ITStracks","AliITSIOTrack",&ioTrack,32000,0);
590
def162f4 591 TDatabasePDG * db = new TDatabasePDG;
61231d74 592
b48af428 593 Int_t j;
594 for (j=minTr; j<=maxTr; j++) {
595 track=(AliTPCtrack*)tracks.UncheckedAt(j);
596 if (!track) continue;
61231d74 597
598 /// mass definition ////////////////////////
599 Double_t mass=0.13956995;
600 Int_t pcode=211; // a pion by default
def162f4 601
61231d74 602 if(realmass) {
def162f4 603 if(TMath::Abs(pcode)<20443) mass=db->GetParticle(pcode)->Mass();
61231d74 604 }
def162f4 605 else {
606 mass = track->GetMass();
e286bade 607// cout << "Mass = " << mass << endl;
def162f4 608 }
609
61231d74 610
611
d3ab000e 612 // new propagation to the end of TPC
64ab0d55 613 Double_t xk=80.;
614 // track->PropagateTo(xk,0.,0.); //Ne if it's still there //attenzione funziona solo se modifica in TPC
615 // Double_t xk=77.415;
d3ab000e 616 track->PropagateTo(xk, 28.94, 1.204e-3);
617 xk-=0.005;
618 track->PropagateTo(xk, 44.77,1.71); //Tedlar
619 xk-=0.02;
620 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
621 xk-=2.0;
622 track->PropagateTo(xk, 41.28, 0.029);//Nomex
623 xk-=0.02;
624 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
625 xk-=0.005;
626 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
627
628 xk=61.;
64ab0d55 629 // track->PropagateTo(xk,0.,0.); //C02
630 track->PropagateTo(xk,36.2,1.98e-3); //C02 //attenzione funziona solo se modifica in TPC
d3ab000e 631
632 xk -=0.005;
633 track->PropagateTo(xk, 24.01, 2.7); //Al
634 xk -=0.005;
635 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
636 xk -=0.02;
637 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
638 xk -=0.5;
639 track->PropagateTo(xk, 41.28, 0.029); //Nomex
640 xk -=0.02;
641 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
642 xk -=0.005;
643 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
644 xk -=0.005;
64ab0d55 645 track->PropagateTo(xk, 24.01, 2.7); //Al
af50998a 646
64ab0d55 647 ////////////////////////////////////////////////////////////////////////////////////////////////////////
af50998a 648 //AliITSTrackV1 trackITS(*track);
649 AliITSTrackV1 trackITS(*track, fFieldFactor);
650 //cout<<" fFieldFactor = "<<fFieldFactor<<"\n";
61231d74 651 trackITS.PutMass(mass); //new to add mass to track
b48af428 652 if(fresult){ delete fresult; fresult=0;}
653 fresult = new AliITSTrackV1(trackITS);
654
655 AliITSTrackV1 primaryTrack(trackITS);
656 vgeant=(*fresult).GetVertex();
657
658 // Definition of dv and zv for vertex constraint
659 Double_t sigmaDv=0.0050; Double_t sigmaZv=0.010;
660 //Double_t sigmaDv=0.0015; Double_t sigmaZv=0.0015;
13888096 661 Double_t uniform= gRandom->Uniform();
662 Double_t signdv;
663 if(uniform<=0.5) signdv=-1.;
b48af428 664 else
665 signdv=1.;
666
04b80329 667 Double_t vr=TMath::Sqrt(vgeant(0)*vgeant(0)+ vgeant(1)*vgeant(1));
b48af428 668 Double_t dv=gRandom->Gaus(signdv*vr,(Float_t)sigmaDv);
669 Double_t zv=gRandom->Gaus(vgeant(2),(Float_t)sigmaZv);
670 //cout<<" Dv e Zv = "<<dv<<" "<<zv<<"\n";
671 trackITS.SetDv(dv);
672 trackITS.SetZv(zv);
673 trackITS.SetsigmaDv(sigmaDv);
674 trackITS.SetsigmaZv(sigmaZv);
675 (*fresult).SetDv(dv);
676 (*fresult).SetZv(zv);
677 (*fresult).SetsigmaDv(sigmaDv);
678 (*fresult).SetsigmaZv(sigmaZv);
679 primaryTrack.SetDv(dv);
680 primaryTrack.SetZv(zv);
681 primaryTrack.SetsigmaDv(sigmaDv);
682 primaryTrack.SetsigmaZv(sigmaZv);
088e0b8d 683 primaryTrack.PrimaryTrack();
b48af428 684 TVector d2=primaryTrack.Getd2();
685 TVector tgl2=primaryTrack.Gettgl2();
686 TVector dtgl=primaryTrack.Getdtgl();
687 trackITS.Setd2(d2); trackITS.Settgl2(tgl2);
688 trackITS.Setdtgl(dtgl);
689 (*fresult).Setd2(d2); (*fresult).Settgl2(tgl2);
690 (*fresult).Setdtgl(dtgl);
691 /*
692 trackITS.SetVertex(vertex); trackITS.SetErrorVertex(ervertex);
693 (*result).SetVertex(vertex); (*result).SetErrorVertex(ervertex);
694 */
695 TList *list= new TList();
696
697 list->AddLast(&trackITS);
698
699 fPtref=TMath::Abs( (trackITS).GetPt() );
af50998a 700 //cout<<" fPtref = " <<fPtref<<"\n";
b48af428 701 if(fPtref>1.0) fChi2max=40.;
702 if(fPtref<=1.0) fChi2max=20.;
703 if(fPtref<0.4 ) fChi2max=100.;
704 if(fPtref<0.2 ) fChi2max=40.;
705 // if(fPtref<0.4 ) fChi2max=30.;
706 // if(fPtref<0.2 ) fChi2max=20.;
707 //if(fPtref<0.2 ) fChi2max=10.;
708 //if(fPtref<0.1 ) fChi2max=5.;
c57de405 709 //cout << "\n Pt = " << fPtref <<"\n"; //stampa
b48af428 710 RecursiveTracking(list);
711 list->Delete();
712 delete list;
713
714 Int_t itot=-1;
715 TVector vecTotLabRef(18);
716 Int_t lay, k;
717 for(lay=5; lay>=0; lay--) {
718 TVector vecLabRef(3);
719 vecLabRef=(*fresult).GetLabTrack(lay);
720 Float_t clustZ=(*fresult).GetZclusterTrack( lay);
721 for(k=0; k<3; k++){
04b80329 722 Int_t lpp=(Int_t)vecLabRef(k);
723 if(lpp>=0) {
5d12ce38 724 TParticle *p=(TParticle*) gAlice->GetMCApp()->Particle(lpp);
b48af428 725 Int_t pcode=p->GetPdgCode();
726 if(pcode==11) vecLabRef(k)=p->GetFirstMother();
727 } // end if
728 itot++; vecTotLabRef(itot)=vecLabRef(k);
64ab0d55 729 if(vecLabRef(k)==0. && clustZ == -1.) vecTotLabRef(itot) =-3.;
b48af428 730 } // end for k
731 } // end for lay
732 Long_t labref;
733 Int_t freq;
734 (*fresult).Search(vecTotLabRef, labref, freq);
735
736 //if(freq < 6) labref=-labref; // cinque - sei
737 if(freq < 5) labref=-labref; // cinque - sei
738 (*fresult).SetLabel(labref);
739
740 // cout<<" progressive track number = "<<j<<"\r";
741 // cout<<j<<"\r";
742 Int_t numOfCluster=(*fresult).GetNumClust();
c57de405 743 //cout<<" progressive track number = "<<j<<"\n"; // stampa
b48af428 744 Long_t labITS=(*fresult).GetLabel();
c57de405 745 //cout << " ITS track label = " << labITS << "\n"; // stampa
b48af428 746 Int_t lab=track->GetLabel();
c57de405 747 //cout << " TPC track label = " << lab <<"\n"; // stampa
b48af428 748 //propagation to vertex
749
750 Double_t rbeam=3.;
def162f4 751 if((*fresult).DoNotCross(rbeam)) continue; //no intersection with beampipe
b48af428 752 (*fresult).Propagation(rbeam);
753 Double_t c00,c10,c11,c20,c21,c22,c30,c31,c32,c33,c40,c41,c42,c43,c44;
754 (*fresult).GetCElements(c00,
755 c10,c11,
756 c20,c21,c22,
757 c30,c31,c32,c33,
758 c40,c41,c42,c43,c44);
13888096 759
b48af428 760 Double_t pt=TMath::Abs((*fresult).GetPt());
761 Double_t dr=(*fresult).GetD();
762 Double_t z=(*fresult).GetZ();
763 Double_t tgl=(*fresult).GetTgl();
764 Double_t c=(*fresult).GetC();
765 Double_t cy=c/2.;
766 Double_t dz=z-(tgl/cy)*TMath::ASin((*fresult).Arga(rbeam));
767 dz-=vgeant(2);
768 // cout<<" dr e dz alla fine = "<<dr<<" "<<dz<<"\n"; getchar();
769 Double_t phi=(*fresult).Getphi();
770 Double_t phivertex = phi - TMath::ASin((*fresult).ArgA(rbeam));
771 Double_t duepi=2.*TMath::Pi();
772 if(phivertex>duepi) phivertex-=duepi;
773 if(phivertex<0.) phivertex+=duepi;
774 /////////////////////////////////////////////////////////////
775 Int_t idmodule,idpoint;
776 if(numOfCluster >=5) { // cinque - sei
777 //if(numOfCluster ==6) { // cinque - sei
778 AliITSIOTrack outTrack;
779 ioTrack=&outTrack;
780 ioTrack->SetStatePhi(phi);
781 ioTrack->SetStateZ(z);
782 ioTrack->SetStateD(dr);
783 ioTrack->SetStateTgl(tgl);
784 ioTrack->SetStateC(c);
785 Double_t radius=(*fresult).Getrtrack();
786 ioTrack->SetRadius(radius);
787 Int_t charge;
788 if(c>0.) charge=-1; else charge=1;
789 ioTrack->SetCharge(charge);
def162f4 790 Double_t trackmass=(*fresult).GetMass(); // oggi
791 ioTrack->SetMass(trackmass); // oggi
b48af428 792 ioTrack->SetCovMatrix(c00,
793 c10,c11,
794 c20,c21,c22,
795 c30,c31,c32,c33,
796 c40,c41,c42,c43,c44);
797 Double_t px=pt*TMath::Cos(phivertex);
798 Double_t py=pt*TMath::Sin(phivertex);
799 Double_t pz=pt*tgl;
800 Double_t xtrack=dr*TMath::Sin(phivertex);
801 Double_t ytrack=dr*TMath::Cos(phivertex);
802 Double_t ztrack=dz+vgeant(2);
803 ioTrack->SetPx(px);
804 ioTrack->SetPy(py);
805 ioTrack->SetPz(pz);
806 ioTrack->SetX(xtrack);
807 ioTrack->SetY(ytrack);
808 ioTrack->SetZ(ztrack);
809 ioTrack->SetLabel(labITS);
810 ioTrack->SetTPCLabel(lab);
61231d74 811 ioTrack->SetDz(dz);
b48af428 812 Int_t il;
def162f4 813 /*
814 for(il=0;il<6; il++){
b48af428 815 ioTrack->SetIdPoint(il,(*fresult).GetIdPoint(il));
816 ioTrack->SetIdModule(il,(*fresult).GetIdModule(il));
817 } // end for il
def162f4 818 */
819 //tracktree1.Fill();
820 Float_t q[4]={-1.,-1.,-1.,-1.};
821 Float_t globaldedx=0.;
b48af428 822 for (il=0;il<6;il++) {
823 idpoint=(*fresult).GetIdPoint(il);
824 idmodule=(*fresult).GetIdModule(il);
61231d74 825 if(idmodule>0.) *(fvettid[idmodule]+idpoint)=1;
826
b48af428 827 ioTrack->SetIdPoint(il,idpoint);
828 ioTrack->SetIdModule(il,idmodule);
def162f4 829 //// for q definition
830 if(il>1){
831 if(idmodule>0.){
832 fITS->ResetRecPoints();
833 gAlice->TreeR()->GetEvent(idmodule);
834 recp=(AliITSRecPoint*)frecPoints->UncheckedAt(idpoint);
835 q[il-2]=recp->GetQ()*(*fresult).Getfcor(il-2);
836 }
837 }
838 } // end for il
839 q[0]/=280.; q[1]/=280.;
840 q[2]/=38.; q[3]/=38.;
841
842 // cout<<" q prima = "<<q[0]<<" "<<q[1]<<" "<<q[2]<<" "<<q[3]<<"\n"; getchar();
843
844 Int_t swap;
845 do{
846 swap=0;
847 for (il=0; il<3; il++) {
848 if (q[il]<=q[il+1]) continue;
849 Float_t tmp=q[il];
850 q[il]=q[il+1]; q[il+1]=tmp;
851 swap++;
852 }
853 } while(swap);
854
855
856 // cout<<" q dopo = "<<q[0]<<" "<<q[1]<<" "<<q[2]<<" "<<q[3]<<"\n"; getchar();
857
858 if(q[0]<0.) {
859 q[0]=q[1];
860 q[1]=q[2];
861 q[2]=q[3];
862 q[3]=-1.;
863 }
864
865 // cout<<" q dopo if = "<<q[0]<<" "<<q[1]<<" "<<q[2]<<" "<<q[3]<<"\n"; getchar();
866
867 globaldedx=(q[0]+q[1])/2.;
868
869 // if(q[3]> 0.) globaldedx=(q[0]+q[1]+q[2]+q[3])/4.;
870 // else globaldedx=(q[0]+q[1]+q[2])/3.;
871
872 ioTrack->SetdEdx(globaldedx);
873 ioTrack->SetPid(pid->GetPcode(ioTrack));
874
875 tracktree1.Fill();
b48af428 876 } // end if on numOfCluster
877 //gObjectTable->Print(); // stampa memoria
878 } // end for (int j=minTr; j<=maxTr; j++)
61231d74 879 delete db;
b48af428 880 static Bool_t first=kTRUE;
881 static TFile *tfile;
882 if(first) {
883 tfile=new TFile("itstracks.root","RECREATE");
884 //cout<<"I have opened itstracks.root file "<<endl;
885 } // end if
886 first=kFALSE;
887 tfile->cd();
888 tfile->ls();
889 char hname[30];
890 sprintf(hname,"TreeT%d",evNumber);
def162f4 891 cout << "Number of saved ITS tracks " << tracktree1.GetEntries() << endl;
b48af428 892 tracktree1.Write(hname);
893
894 TTree *fAli=gAlice->TreeK();
895 TFile *fileAli=0;
896 if (fAli) fileAli =fAli->GetCurrentFile();
897 fileAli->cd();
898 ////////////////////////////////////////////////////////////////////
899
900 printf("delete vectors\n");
901 if(np) delete [] np;
902 if(fvettid) delete [] fvettid;
903 if(fresult) {delete fresult; fresult=0;}
04b80329 904}
b48af428 905//______________________________________________________________________
04b80329 906void AliITSTrackerV1::RecursiveTracking(TList *trackITSlist) {
b48af428 907 // This function perform the recursive tracking in ITS detectors
908 // reference is a pointer to the final best track
909 // Origin A. Badala' and G.S. Pappalardo:
910 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
911 // The authors thank Mariana Bondila to have help them to resolve some
912 // problems. July-2000
913
914 //Rlayer[0]=4.; Rlayer[1]=7.; Rlayer[2]=14.9;
915 // Rlayer[3]=23.8; Rlayer[4]=39.1; Rlayer[5]=43.6; //vecchio
916
917 //////////////////////
918 Float_t sigmaphil[6], sigmazl[6];
919 sigmaphil[0]=1.44e-6/(fAvrad[0]*fAvrad[0]);
920 sigmaphil[1]=1.44e-6/(fAvrad[1]*fAvrad[1]);
921 sigmaphil[2]=1.444e-5/(fAvrad[2]*fAvrad[2]);
922 sigmaphil[3]=1.444e-5/(fAvrad[3]*fAvrad[3]);
923 sigmaphil[4]=4e-6/(fAvrad[4]*fAvrad[4]);
924 sigmaphil[5]=4e-6/(fAvrad[5]*fAvrad[5]);
925 sigmazl[0]=1e-2;
926 sigmazl[1]=1e-2;
927 sigmazl[2]=7.84e-4;
928 sigmazl[3]=7.84e-4;
929 sigmazl[4]=0.6889;
930 sigmazl[5]=0.6889;
931 ///////////////////////////////////////////////////////////
932 Int_t index;
933 AliITSgeom *g1 = fITS->GetITSgeom();
934 AliITSRecPoint *recp;
935 for(index =0; index<trackITSlist->GetSize(); index++) {
936 AliITSTrackV1 *trackITS = (AliITSTrackV1 *) trackITSlist->At(index);
937 if((*trackITS).GetLayer()==7) fresult->SetChi2(10.223e140);
938 // cout <<" Layer inizio = "<<(*trackITS).GetLayer()<<"\n";
939 // cout<<"fvtrack =" <<"\n";
940 // cout << (*trackITS)(0) << " "<<(*trackITS)(1)<<" "
941 // <<(*trackITS)(2)<<" "<<(*trackITS)(3)<<" "
942 // <<(*trackITS)(4)<<"\n";
943 // cout<< " rtrack = "<<(*trackITS).Getrtrack()<<"\n";
944 // cout<< " Pt = "<<(*trackITS).GetPt()<<"\n";
945 // getchar();
946 Double_t chi2Now, chi2Ref;
947 Float_t numClustRef = fresult->GetNumClust();
948 if((*trackITS).GetLayer()==1 ) {
949 chi2Now = trackITS->GetChi2();
950 Float_t numClustNow = trackITS->GetNumClust();
951 if(trackITS->GetNumClust())
952 chi2Now /= (Double_t)trackITS->GetNumClust();
953 chi2Ref = fresult->GetChi2();
954 if(fresult->GetNumClust())
955 chi2Ref /= (Double_t)fresult->GetNumClust();
956 //cout<<" chi2Now and chi2Ref = "<<chi2Now<<" "<<chi2Ref<<"\n";
957 if( numClustNow > numClustRef ) {*fresult = *trackITS;}
958 if((numClustNow == numClustRef )&&
959 (chi2Now < chi2Ref)) {
960 *fresult = *trackITS;
961 } // end if
962 continue;
963 } // end if
964
965 if(trackITS->Getfnoclust()>=2) continue;
966 Float_t numClustNow = trackITS->GetNumClust();
967 if(numClustNow) {
968 chi2Now = trackITS->GetChi2();
969
970 if(numClustNow<numClustRef && chi2Now>fresult->GetChi2()) continue;
971 //cout<<" chi2Now = "<<chi2Now<<"\n";
64ab0d55 972
b48af428 973 chi2Now/=numClustNow;
974 if(fPtref > 1.0 && chi2Now > 30.) continue;
975 if((fPtref >= 0.6 && fPtref<=1.0) && chi2Now > 40.) continue;
976 // if((fPtref <= 0.6 && fPtref>0.2)&& chi2Now > 40.) continue;
977 // if(fPtref <= 0.2 && chi2Now > 8.) continue;
978 if((fPtref <= 0.6 && fPtref>0.2)&& chi2Now > 30.) continue;
979 if(fPtref <= 0.2 && chi2Now > 7.) continue;
980 /////////////////////////////
981 } // end if
982
983 Int_t layerInit = (*trackITS).GetLayer();
984 Int_t layernew = layerInit - 2;// -1 for new layer, -1 for matrix index
985 TList listoftrack;
986 Int_t ladp, ladm, detp,detm,ladinters,detinters;
987 Int_t layerfin=layerInit-1;
988 // cout<<"Prima di intersection \n";
b48af428 989 Int_t outinters=Intersection(*trackITS,layerfin,ladinters,detinters);
b48af428 990 // cout<<" outinters = "<<outinters<<"\n";
991 // cout<<" Layer ladder detector intersection ="
992 // <<layerfin<<" "<<ladinters<<" "<<detinters<<"\n";
993 // cout << " phiinters zinters = "<<(*trackITS)(0)
994 // << " "<<(*trackITS)(1)<<"\n"; getchar();
995 if(outinters==-1) continue;
996 Int_t flaghit=0;
def162f4 997 (*trackITS).SetLayer(layerfin); // oggi
998 (*trackITS).Setfcor(); // oggi
b48af428 999 if(outinters==0){
1000 TVector toucLad(9), toucDet(9);
1001 Int_t lycur=layerfin;
1002 ladp=ladinters+1;
1003 ladm=ladinters-1;
1004 if(ladm <= 0) ladm=fNlad[layerfin-1];
1005 if(ladp > fNlad[layerfin-1]) ladp=1;
1006 detp=detinters+1;
1007 detm=detinters-1;
1008 Int_t idetot=1;
1009 /*
1010 toucLad(0)=ladinters; toucLad(1)=ladm; toucLad(2)=ladp;
1011 toucLad(3)=ladinters; toucLad(4)=ladm; toucLad(5)=ladp;
1012 toucLad(6)=ladinters; toucLad(7)=ladm; toucLad(8)=ladp;
1013 toucDet(0)=detinters; toucDet(1)=detinters; toucDet(2)=detinters;
1014 if(detm > 0 && detp <= fNdet[layerfin-1]) {
1015 idetot=9;
1016 toucDet(3)=detm; toucDet(4)=detm; toucDet(5)=detm;
1017 toucDet(6)=detp; toucDet(7)=detp; toucDet(8)=detp;
1018 } // end if
1019 if(detm > 0 && detp > fNdet[layerfin-1]) {
1020 idetot=6;
1021 toucDet(3)=detm; toucDet(4)=detm; toucDet(5)=detm;
1022 } // end if
1023 if(detm <= 0 && detp <= fNdet[layerfin-1]) {
1024 idetot=6;
1025 toucDet(3)=detp; toucDet(4)=detp; toucDet(5)=detp;
1026 } // end if
1027 */
f66ae545 1028 Float_t epsphi=5.0, epsz=5.0;
b48af428 1029 if(fPtref<0.2) {epsphi=3.; epsz=3.;}
64ab0d55 1030 // new definition of idetot e toucLad e toucDet to be
b48af428 1031 // transformed in a method
1032 // these values could be modified
1033 Float_t pigre=TMath::Pi();
1034 Float_t rangephi=5., rangez=5.;
1035 if(layerfin==1 || layerfin ==2){
1036 rangephi=40.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1037 (*trackITS).GetSigmaphi());
1038 rangez = 40.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1039 (*trackITS).GetSigmaZ());
1040 } // end if
1041 if(layerfin==3 || layerfin ==4){
1042 //rangephi=30.*fepsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1043 // (*trackITS).GetSigmaphi());
1044 //rangez = 40.*fepsz*TMath::Sqrt(sigmazl[layerfin-1]+
1045 // (*trackITS).GetSigmaZ());
1046 rangephi=40.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1047 (*trackITS).GetSigmaphi());
1048 rangez = 50.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1049 (*trackITS).GetSigmaZ());
1050 } // end if
1051 if(layerfin==5 || layerfin ==6){
1052 rangephi=20.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1053 (*trackITS).GetSigmaphi());
1054 rangez =5.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1055 (*trackITS).GetSigmaZ());
1056 } // end if
1057 Float_t phinters, zinters;
1058 phinters=(*trackITS).Getphi();
1059 zinters=(*trackITS).GetZ();
1060 Float_t distz = 0.0;
1061 Float_t phicm, phicp, distphim, distphip;
1062 phicm=phinters;
cf411bb5 1063 if(phinters>fphimax[layerfin-1][ladm-1]) phicm=phinters-2*pigre; //corretto il 20-11-2001
1064 distphim=TMath::Abs(phicm-fphimax[layerfin-1][ladm-1]); //corretto il 20-11-2001
b48af428 1065 phicp=phinters;
cf411bb5 1066 //cout<<" fNlad[layerfin-1] e ladp = "<<fNlad[layerfin-1]<<" "<<ladp<<endl;
1067 if(phinters>fphimin[layerfin-1][ladp-1]) phicp=phinters-2.*pigre; //corretto il 20-11-2001
1068 distphip=TMath::Abs(phicp-fphimin[layerfin-1][ladp-1]); //corretto il 20-11-2001
b48af428 1069 Int_t flagzmin=0;
1070 Int_t flagzmax=0;
1071 idetot=1;
1072 toucLad(0)=ladinters; toucDet(0)=detinters;
1073 if(detm>0) distz=TMath::Abs(zinters-fzmax[layerfin-1][detm-1]);
1074 if(detm>0 && rangez>=distz){
1075 flagzmin=1;
1076 idetot++; toucLad(idetot-1)=ladinters; toucDet(idetot-1)=detm;
1077 if(rangephi>=distphim){
1078 idetot++;
1079 toucLad(idetot-1)=ladm;
1080 toucDet(idetot-1)=detinters;
1081 idetot++;
1082 toucLad(idetot-1)=ladm;
1083 toucDet(idetot-1)=detm;
1084 } // end if
1085 if(rangephi>=distphip){
1086 idetot++;
1087 toucLad(idetot-1)=ladp;
1088 toucDet(idetot-1)=detinters;
1089 idetot++;
1090 toucLad(idetot-1)=ladp;
1091 toucDet(idetot-1)=detm;
1092 } // end if
1093 } //end detm>0....
1094 if(detp<=fNdet[layerfin-1])
1095 distz=TMath::Abs(zinters-fzmin[layerfin-1][detp-1]);
1096 if(detp<=fNdet[layerfin-1] && rangez>=distz){
1097 flagzmax=1;
1098 idetot++; toucLad(idetot-1)=ladinters; toucDet(idetot-1)=detp;
1099 if(rangephi>=distphim){
1100 idetot++; toucLad(idetot-1)=ladm; toucDet(idetot-1)=detp;
1101 if(flagzmin == 0) {
1102 idetot++;
1103 toucLad(idetot-1)=ladm;
1104 toucDet(idetot-1)=detinters;
1105 } // end if
1106 } // end if
1107 if(rangephi>=distphip){
1108 idetot++;
1109 toucLad(idetot-1)=ladp;
1110 toucDet(idetot-1)=detp;
1111 if(flagzmin == 0) {
1112 idetot++;
1113 toucLad(idetot-1)=ladp;
1114 toucDet(idetot-1)=detinters;
1115 } // end if
1116 } // end if
1117 } //end detm<fNdet[.......
1118
1119 if(flagzmin == 0 && flagzmax==0){
1120 if(rangephi>=distphim){
1121 idetot++;
1122 toucLad(idetot-1)=ladm;
1123 toucDet(idetot-1)=detinters;
1124 } // end if
1125 if(rangephi>=distphip){
1126 idetot++;
1127 toucLad(idetot-1)=ladp;
1128 toucDet(idetot-1)=detinters;
1129 } // end if
1130 } // end if
1131 ////////////////////////////////////////////////////////////
1132 Int_t iriv;
1133 for (iriv=0; iriv<idetot; iriv++) { //for on detectors
1134 ///////////////////////////////////////////////////////
1135 /*** Rec points sorted by module *****/
1136 /**************************************/
64ab0d55 1137 Int_t indexmod;
b48af428 1138 indexmod = g1->GetModuleIndex(lycur,(Int_t)toucLad(iriv),
64ab0d55 1139 (Int_t)toucDet(iriv));
b48af428 1140 fITS->ResetRecPoints();
1141 gAlice->TreeR()->GetEvent(indexmod);
1142 Int_t npoints=frecPoints->GetEntries();
64ab0d55 1143
b48af428 1144 Int_t indnew;
1145 for(indnew=0; indnew<npoints; indnew++){
1146 if (*(fvettid[indexmod]+indnew)==0)
1147 recp =(AliITSRecPoint*)frecPoints->UncheckedAt(indnew);
1148 else
f66ae545 1149 continue;
b48af428 1150 TVector cluster(3),vecclust(9);
64ab0d55 1151 //vecclust(6)=vecclust(7)=vecclust(8)=-1.;
1152 Double_t sigma[2];
1153 // now vecclust is with cylindrical cohordinates
1154 vecclust(0)=(Float_t)fRecCylR[indexmod][indnew];
1155 vecclust(1)=(Float_t)fRecCylPhi[indexmod][indnew];
1156 vecclust(2)=(Float_t)fRecCylZ[indexmod][indnew];
b48af428 1157 vecclust(3) = (Float_t)recp->fTracks[0];
b48af428 1158 vecclust(4) = (Float_t)indnew;
64ab0d55 1159 vecclust(5) = (Float_t)indexmod;
b48af428 1160 vecclust(6) = (Float_t)recp->fTracks[0];
1161 vecclust(7) = (Float_t)recp->fTracks[1];
1162 vecclust(8) = (Float_t)recp->fTracks[2];
1163 sigma[0] = (Double_t) recp->GetSigmaX2();
1164 sigma[1] = (Double_t) recp->GetSigmaZ2();
64ab0d55 1165
1166 cluster(0)=fRecCylR[indexmod][indnew];
1167 cluster(1)=fRecCylPhi[indexmod][indnew];
1168 cluster(2)=fRecCylZ[indexmod][indnew];
1169
b48af428 1170 // cout<<" layer = "<<play<<"\n";
1171 // cout<<" cluster prima = "<<vecclust(0)<<" "
1172 // <<vecclust(1)<<" "
1173 // <<vecclust(2)<<"\n"; getchar();
1174
1175 Float_t sigmatotphi, sigmatotz;
1176 // Float_t epsphi=5.0, epsz=5.0;
1177 //if(fPtref<0.2) {epsphi=3.; epsz=3.;}
1178 Double_t rTrack=(*trackITS).Getrtrack();
1179 Double_t sigmaphi=sigma[0]/(rTrack*rTrack);
1180 sigmatotphi=epsphi*TMath::Sqrt(sigmaphi +
1181 (*trackITS).GetSigmaphi());
1182 sigmatotz=epsz*TMath::Sqrt(sigma[1] +
1183 (*trackITS).GetSigmaZ());
1184 //cout<<"cluster e sigmatotphi e track = "<<cluster(0)
1185 // <<" "<<cluster(1)<<" "<<sigmatotphi<<" "
1186 // <<vecclust(3)<<"\n";
1187 //if(vecclust(3)==481) getchar();
1188 if(cluster(1)<6. && (*trackITS).Getphi()>6.)
1189 cluster(1)=cluster(1)+(2.*TMath::Pi());
1190 if(cluster(1)>6. && (*trackITS).Getphi()<6.)
1191 cluster(1)=cluster(1)-(2.*TMath::Pi());
1192 if(TMath::Abs(cluster(1)-(*trackITS).Getphi())>sigmatotphi)
1193 continue;
1194 // cout<<" supero sigmaphi \n";
1195 AliITSTrackV1 *newTrack = new AliITSTrackV1((*trackITS));
def162f4 1196 //(*newTrack).SetLayer((*trackITS).GetLayer()-1);
b48af428 1197 if (TMath::Abs(rTrack-cluster(0))/rTrack>1e-6)
1198 (*newTrack).Correct(Double_t(cluster(0)));
1199 //cout<<" cluster(2) e(*newTrack).GetZ()="<<cluster(2)<<" "
1200 // << (*newTrack).GetZ()<<"\n";
1201 if(TMath::Abs(cluster(2)-(*newTrack).GetZ()) > sigmatotz){
1202 delete newTrack;
1203 continue;
1204 } // end if
1205 Double_t sigmanew[2];
1206 sigmanew[0]= sigmaphi;
1207 sigmanew[1]=sigma[1];
1208 Double_t m[2];
1209 m[0]=cluster(1);
1210 m[1]=cluster(2);
1211 // Double_t chi2pred=newTrack->GetPredChi2(m,sigmanew);
1212 // cout<<" chi2pred = "<<chi2pred<<"\n";
1213 // if(chi2pred>fChi2max) continue; //aggiunto il 30-7-2001
1214 if(iriv == 0) flaghit=1;
088e0b8d 1215 (*newTrack).AddMS(); // add the multiple scattering
b48af428 1216 //matrix to the covariance matrix
d0df5576 1217 (*newTrack).AddEL(1.,0);
b48af428 1218
b48af428 1219 if(fflagvert){
1220 KalmanFilterVert(newTrack,cluster,sigmanew);
1221 //KalmanFilterVert(newTrack,cluster,sigmanew,chi2pred);
1222 }else{
1223 KalmanFilter(newTrack,cluster,sigmanew);
1224 } // end if
b48af428 1225 (*newTrack).PutCluster(layernew, vecclust);
1226 newTrack->AddClustInTrack();
1227 listoftrack.AddLast(newTrack);
1228 } // end for indnew
b48af428 1229 } // end of for on detectors (iriv)
1230 }//end if(outinters==0)
1231
1232 if(flaghit==0 || outinters==-2) {
1233 AliITSTrackV1 *newTrack = new AliITSTrackV1(*trackITS);
1234 (*newTrack).Setfnoclust();
def162f4 1235 //(*newTrack).SetLayer((*trackITS).GetLayer()-1);
088e0b8d 1236 (*newTrack).AddMS(); // add the multiple scattering matrix
b48af428 1237 // to the covariance matrix
d0df5576 1238 (*newTrack).AddEL(1.,0);
b48af428 1239 listoftrack.AddLast(newTrack);
1240 } // end if
1241
1242 //gObjectTable->Print(); // stampa memoria
04b80329 1243
b48af428 1244 RecursiveTracking(&listoftrack);
1245 listoftrack.Delete();
1246 } // end of for on tracks (index)
04b80329 1247
b48af428 1248 //gObjectTable->Print(); // stampa memoria
13888096 1249}
b48af428 1250//______________________________________________________________________
1251Int_t AliITSTrackerV1::Intersection(AliITSTrackV1 &track,Int_t layer,
1252 Int_t &ladder,Int_t &detector) {
1253 // Origin A. Badala' and G.S. Pappalardo
1254 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1255 // Found the intersection and the detector
1256
1257 Double_t rk=fAvrad[layer-1];
1258 if(track.DoNotCross(rk)){ /*cout<< " Do not cross \n";*/ return -1;}
1259 track.Propagation(rk);
1260 Double_t zinters=track.GetZ();
1261 Double_t phinters=track.Getphi();
1262 //cout<<"zinters = "<<zinters<<" phinters = "<<phinters<<"\n";
1263
1264 TVector det(9);
1265 TVector listDet(2);
1266 TVector distZCenter(2);
1267
1268 Int_t iz=0;
1269 Int_t iD;
1270 for(iD = 1; iD<= fNdet[layer-1]; iD++) {
1271 if(zinters > fzmin[layer-1][iD-1] && zinters <= fzmax[layer-1][iD-1]) {
1272 if(iz>1) {
1273 cout<< " Errore su iz in Intersection \n";
1274 getchar();
1275 }else {
1276 listDet(iz)= iD; distZCenter(iz)=TMath::Abs(zinters-det(2));
1277 iz++;
1278 } // end if
1279 } // end if
1280 } // end for iD
1281
1282 if(iz==0) {/* cout<< " No detector along Z \n";*/ return -2;}
1283 detector=Int_t (listDet(0));
1284 if(iz>1 && (distZCenter(0)>distZCenter(1))) detector=Int_t (listDet(1));
1285
1286 TVector listLad(2);
1287 TVector distPhiCenter(2);
1288 Int_t ip=0;
1289 Double_t pigre=TMath::Pi();
1290 Int_t iLd;
1291 for(iLd = 1; iLd<= fNlad[layer-1]; iLd++) {
1292 Double_t phimin=fphimin[layer-1][iLd-1];
1293 Double_t phimax=fphimax[layer-1][iLd-1];
1294 Double_t phidet=fphidet[layer-1][iLd-1];
1295 Double_t phiconfr=phinters;
1296 if(phimin>phimax) {
1297 //if(phimin <5.5) {cout<<" Error in Intersection for phi \n";
1298 // getchar();}
1299 phimin-=(2.*pigre);
1300 if(phinters>(1.5*pigre)) phiconfr=phinters-(2.*pigre);
1301 if(phidet>(1.5*pigre)) phidet-=(2.*pigre);
1302 } // end if
1303 if(phiconfr>phimin && phiconfr<= phimax) {
1304 if(ip>1) {
1305 cout<< " Errore su ip in Intersection \n"; getchar();
1306 }else {
1307 listLad(ip)= iLd;
1308 distPhiCenter(ip)=TMath::Abs(phiconfr-phidet); ip++;
1309 } // end if
1310 } // end if
1311 } // end for iLd
1312 if(ip==0) { cout<< " No detector along phi \n"; getchar();}
1313 ladder=Int_t (listLad(0));
1314 if(ip>1 && (distPhiCenter(0)>distPhiCenter(1))) ladder=Int_t (listLad(1));
1315 return 0;
1316}
1317//______________________________________________________________________
1318void AliITSTrackerV1::KalmanFilter(AliITSTrackV1 *newTrack,TVector &cluster,
1319 Double_t sigma[2]){
1320 //Origin A. Badala' and G.S. Pappalardo:
1321 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1322 // Kalman filter without vertex constraint
1323 ////// Evaluation of the measurement vector ////////////////////////
1324 Double_t m[2];
1325 Double_t rk,phik,zk;
1326 rk=cluster(0); phik=cluster(1); zk=cluster(2);
1327 m[0]=phik; m[1]=zk;
1328 //////////////////////// Evaluation of the error matrix V /////////
1329 Double_t v00=sigma[0];
1330 Double_t v11=sigma[1];
1331 ////////////////////////////////////////////////////////////////////
1332 Double_t cin00,cin10,cin20,cin30,cin40,cin11,cin21,cin31,cin41,cin22,
1333 cin32,cin42,cin33,cin43,cin44;
1334
1335 newTrack->GetCElements(cin00,
1336 cin10,cin11,
1337 cin20,cin21,cin22,
1338 cin30,cin31,cin32,cin33,
1339 cin40,cin41,cin42,cin43,cin44); //get C matrix
1340 Double_t rold00=cin00+v00;
1341 Double_t rold10=cin10;
1342 Double_t rold11=cin11+v11;
1343 ////////////////////// R matrix inversion /////////////////////////
1344 Double_t det=rold00*rold11-rold10*rold10;
1345 Double_t r00=rold11/det;
1346 Double_t r10=-rold10/det;
1347 Double_t r11=rold00/det;
1348 ////////////////////////////////////////////////////////////////////
1349 Double_t k00=cin00*r00+cin10*r10;
1350 Double_t k01=cin00*r10+cin10*r11;
1351 Double_t k10=cin10*r00+cin11*r10;
1352 Double_t k11=cin10*r10+cin11*r11;
1353 Double_t k20=cin20*r00+cin21*r10;
1354 Double_t k21=cin20*r10+cin21*r11;
1355 Double_t k30=cin30*r00+cin31*r10;
1356 Double_t k31=cin30*r10+cin31*r11;
1357 Double_t k40=cin40*r00+cin41*r10;
1358 Double_t k41=cin40*r10+cin41*r11;
1359 Double_t x0,x1,x2,x3,x4;
1360 newTrack->GetXElements(x0,x1,x2,x3,x4); // get the state vector
1361 Double_t savex0=x0, savex1=x1;
1362 x0+=k00*(m[0]-savex0)+k01*(m[1]-savex1);
1363 x1+=k10*(m[0]-savex0)+k11*(m[1]-savex1);
1364 x2+=k20*(m[0]-savex0)+k21*(m[1]-savex1);
1365 x3+=k30*(m[0]-savex0)+k31*(m[1]-savex1);
1366 x4+=k40*(m[0]-savex0)+k41*(m[1]-savex1);
1367 Double_t c00,c10,c20,c30,c40,c11,c21,c31,c41,c22,c32,c42,c33,c43,c44;
1368 c00=cin00-k00*cin00-k01*cin10;
1369 c10=cin10-k00*cin10-k01*cin11;
1370 c20=cin20-k00*cin20-k01*cin21;
1371 c30=cin30-k00*cin30-k01*cin31;
1372 c40=cin40-k00*cin40-k01*cin41;
1373 c11=cin11-k10*cin10-k11*cin11;
1374 c21=cin21-k10*cin20-k11*cin21;
1375 c31=cin31-k10*cin30-k11*cin31;
1376 c41=cin41-k10*cin40-k11*cin41;
1377 c22=cin22-k20*cin20-k21*cin21;
1378 c32=cin32-k20*cin30-k21*cin31;
1379 c42=cin42-k20*cin40-k21*cin41;
1380 c33=cin33-k30*cin30-k31*cin31;
1381 c43=cin43-k30*cin40-k31*cin41;
1382 c44=cin44-k40*cin40-k41*cin41;
1383 newTrack->PutXElements(x0,x1,x2,x3,x4); // put the new state vector
1384 newTrack->PutCElements(c00,
1385 c10,c11,
1386 c20,c21,c22,
1387 c30,c31,c32,c33,
1388 c40,c41,c42,c43,c44); // put in track the
1389 // new cov matrix
1390 Double_t vmcold00=v00-c00;
1391 Double_t vmcold10=-c10;
1392 Double_t vmcold11=v11-c11;
1393 ////////////////////// Matrix vmc inversion ///////////////////////
1394 det=vmcold00*vmcold11-vmcold10*vmcold10;
1395 Double_t vmc00=vmcold11/det;
1396 Double_t vmc10=-vmcold10/det;
1397 Double_t vmc11=vmcold00/det;
1398 ////////////////////////////////////////////////////////////////////
1399 Double_t chi2=(m[0]-x0)*( vmc00*(m[0]-x0) + 2.*vmc10*(m[1]-x1) ) +
1400 (m[1]-x1)*vmc11*(m[1]-x1);
04b80329 1401 newTrack->SetChi2(newTrack->GetChi2()+chi2);
b48af428 1402}
1403//----------------------------------------------------------------------
1404//void AliITSTrackerV1::KalmanFilterVert(AliITSTrackV1 *newTrack,
1405// TVector &cluster,Double_t sigma[2]){
1406void AliITSTrackerV1::KalmanFilterVert(AliITSTrackV1 *newTrack,
1407 TVector &cluster,Double_t sigma[2]
1408 /*, Double_t chi2pred*/){
1409 //Origin A. Badala' and G.S. Pappalardo:
1410 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1411 // Kalman filter with vertex constraint
1412 ///////////////////// Evaluation of the measurement vector m ////////
1413 Double_t m[4];
1414 Double_t rk,phik,zk;
1415 rk=cluster(0); phik=cluster(1); zk=cluster(2);
1416 m[0]=phik; m[1]=zk;
1417 Double_t cc=(*newTrack).GetC();
1418 Double_t zv=(*newTrack).GetZv();
1419 Double_t dv=(*newTrack).GetDv();
1420 Double_t cy=cc/2.;
1421 Double_t tgl= (zk-zv)*cy/TMath::ASin(cy*rk);
1422 m[2]=dv; m[3]=tgl;
1423 /////////////////////// Evaluation of the error matrix V //////////
1424 Int_t layer=newTrack->GetLayer();
1425 Double_t v00=sigma[0];
1426 Double_t v11=sigma[1];
1427 Double_t v31=sigma[1]/rk;
1428 Double_t sigmaDv=newTrack->GetsigmaDv();
1429 Double_t v22=sigmaDv*sigmaDv + newTrack->Getd2(layer-1);
1430 Double_t v32=newTrack->Getdtgl(layer-1);
1431 Double_t sigmaZv=newTrack->GetsigmaZv();
1432 Double_t v33=(sigma[1]+sigmaZv*sigmaZv)/(rk*rk)+newTrack->Gettgl2(layer-1);
1433 //////////////////////////////////////////////////////////////////
1434 Double_t cin00,cin10,cin11,cin20,cin21,cin22,
1435 cin30,cin31,cin32,cin33,cin40,cin41,cin42,cin43,cin44;
1436 newTrack->GetCElements(cin00,
1437 cin10,cin11,
1438 cin20,cin21,cin22,
1439 cin30,cin31,cin32,cin33,
1440 cin40,cin41,cin42,cin43,cin44); //get C matrix
1441 Double_t r[4][4];
1442 r[0][0]=cin00+v00;
1443 r[1][0]=cin10;
1444 r[2][0]=cin20;
1445 r[3][0]=cin30;
1446 r[1][1]=cin11+v11;
1447 r[2][1]=cin21;
1448 r[3][1]=cin31+sigma[1]/rk;
1449 r[2][2]=cin22+sigmaDv*sigmaDv+newTrack->Getd2(layer-1);
1450 r[3][2]=cin32+newTrack->Getdtgl(layer-1);
1451 r[3][3]=cin33+(sigma[1]+sigmaZv*sigmaZv)/(rk*rk)+
1452 newTrack->Gettgl2(layer-1);
1453 r[0][1]=r[1][0]; r[0][2]=r[2][0]; r[0][3]=r[3][0];
1454 r[1][2]=r[2][1]; r[1][3]=r[3][1]; r[2][3]=r[3][2];
1455 ///////////////////// Matrix R inversion //////////////////////////
1456 const Int_t kn=4;
1457 Double_t big, hold;
1458 Double_t d=1.;
1459 Int_t ll[kn],mm[kn];
1460 Int_t i,j,k;
1461
1462 for(k=0; k<kn; k++) {
1463 ll[k]=k;
1464 mm[k]=k;
1465 big=r[k][k];
1466 for(j=k; j<kn ; j++) {
1467 for (i=j; i<kn; i++) {
1468 if(TMath::Abs(big) < TMath::Abs(r[i][j]) ) {
1469 big=r[i][j];
1470 ll[k]=i;
1471 mm[k]=j;
1472 } // end if
1473 } // end for i
1474 } // end for j
1475 //
1476 j= ll[k];
1477 if(j > k) {
1478 for(i=0; i<kn; i++) {
1479 hold=-r[k][i];
1480 r[k][i]=r[j][i];
1481 r[j][i]=hold;
1482 } // end for i
1483 }// end if
1484 //
1485 i=mm[k];
1486 if(i > k ) {
1487 for(j=0; j<kn; j++) {
1488 hold=-r[j][k];
1489 r[j][k]=r[j][i];
1490 r[j][i]=hold;
1491 } // end for j
1492 } // end if
1493 //
1494 if(!big) {
1495 d=0.;
1496 cout << "Singular matrix\n";
1497 } // end if
1498 for(i=0; i<kn; i++) {
1499 if(i == k) { continue; }
1500 r[i][k]=r[i][k]/(-big);
1501 } // end for i
1502 //
1503 for(i=0; i<kn; i++) {
1504 hold=r[i][k];
1505 for(j=0; j<kn; j++) {
1506 if(i == k || j == k) continue;
1507 r[i][j]=hold*r[k][j]+r[i][j];
1508 } // end for j
1509 } // end of ri
1510 //
1511 for(j=0; j<kn; j++) {
1512 if(j == k) continue;
1513 r[k][j]=r[k][j]/big;
1514 } // end for j
1515 //
1516 d=d*big;
1517 //
1518 r[k][k]=1./big;
1519 } // end for k
1520 //
1521 for(k=kn-1; k>=0; k--) {
1522 i=ll[k];
1523 if(i > k) {
1524 for (j=0; j<kn; j++) {
1525 hold=r[j][k];
1526 r[j][k]=-r[j][i];
1527 r[j][i]=hold;
1528 } // end for j
1529 } // end if i
1530 j=mm[k];
1531 if(j > k) {
1532 for (i=0; i<kn; i++) {
1533 hold=r[k][i];
1534 r[k][i]=-r[j][i];
1535 r[j][i]=hold;
1536 } // end for i
1537 } // end if
1538 } // end for k
1539 ////////////////////////////////////////////////////////////////////
1540 Double_t k00=cin00*r[0][0]+cin10*r[1][0]+cin20*r[2][0]+cin30*r[3][0];
1541 Double_t k01=cin00*r[1][0]+cin10*r[1][1]+cin20*r[2][1]+cin30*r[3][1];
1542 Double_t k02=cin00*r[2][0]+cin10*r[2][1]+cin20*r[2][2]+cin30*r[3][2];
1543 Double_t k03=cin00*r[3][0]+cin10*r[3][1]+cin20*r[3][2]+cin30*r[3][3];
1544 Double_t k10=cin10*r[0][0]+cin11*r[1][0]+cin21*r[2][0]+cin31*r[3][0];
1545 Double_t k11=cin10*r[1][0]+cin11*r[1][1]+cin21*r[2][1]+cin31*r[3][1];
1546 Double_t k12=cin10*r[2][0]+cin11*r[2][1]+cin21*r[2][2]+cin31*r[3][2];
1547 Double_t k13=cin10*r[3][0]+cin11*r[3][1]+cin21*r[3][2]+cin31*r[3][3];
1548 Double_t k20=cin20*r[0][0]+cin21*r[1][0]+cin22*r[2][0]+cin32*r[3][0];
1549 Double_t k21=cin20*r[1][0]+cin21*r[1][1]+cin22*r[2][1]+cin32*r[3][1];
1550 Double_t k22=cin20*r[2][0]+cin21*r[2][1]+cin22*r[2][2]+cin32*r[3][2];
1551 Double_t k23=cin20*r[3][0]+cin21*r[3][1]+cin22*r[3][2]+cin32*r[3][3];
1552 Double_t k30=cin30*r[0][0]+cin31*r[1][0]+cin32*r[2][0]+cin33*r[3][0];
1553 Double_t k31=cin30*r[1][0]+cin31*r[1][1]+cin32*r[2][1]+cin33*r[3][1];
1554 Double_t k32=cin30*r[2][0]+cin31*r[2][1]+cin32*r[2][2]+cin33*r[3][2];
1555 Double_t k33=cin30*r[3][0]+cin31*r[3][1]+cin32*r[3][2]+cin33*r[3][3];
1556 Double_t k40=cin40*r[0][0]+cin41*r[1][0]+cin42*r[2][0]+cin43*r[3][0];
1557 Double_t k41=cin40*r[1][0]+cin41*r[1][1]+cin42*r[2][1]+cin43*r[3][1];
1558 Double_t k42=cin40*r[2][0]+cin41*r[2][1]+cin42*r[2][2]+cin43*r[3][2];
1559 Double_t k43=cin40*r[3][0]+cin41*r[3][1]+cin42*r[3][2]+cin43*r[3][3];
1560
1561 Double_t x0,x1,x2,x3,x4;
1562 newTrack->GetXElements(x0,x1,x2,x3,x4); // get the state vector
1563 Double_t savex0=x0, savex1=x1, savex2=x2, savex3=x3;
1564 x0+=k00*(m[0]-savex0)+k01*(m[1]-savex1)+k02*(m[2]-savex2)+
1565 k03*(m[3]-savex3);
1566 x1+=k10*(m[0]-savex0)+k11*(m[1]-savex1)+k12*(m[2]-savex2)+
1567 k13*(m[3]-savex3);
1568 x2+=k20*(m[0]-savex0)+k21*(m[1]-savex1)+k22*(m[2]-savex2)+
1569 k23*(m[3]-savex3);
1570 x3+=k30*(m[0]-savex0)+k31*(m[1]-savex1)+k32*(m[2]-savex2)+
1571 k33*(m[3]-savex3);
1572 x4+=k40*(m[0]-savex0)+k41*(m[1]-savex1)+k42*(m[2]-savex2)+
1573 k43*(m[3]-savex3);
1574 Double_t c00,c10,c20,c30,c40,c11,c21,c31,c41,c22,c32,c42,c33,c43,c44;
1575 c00=cin00-k00*cin00-k01*cin10-k02*cin20-k03*cin30;
1576 c10=cin10-k00*cin10-k01*cin11-k02*cin21-k03*cin31;
1577 c20=cin20-k00*cin20-k01*cin21-k02*cin22-k03*cin32;
1578 c30=cin30-k00*cin30-k01*cin31-k02*cin32-k03*cin33;
1579 c40=cin40-k00*cin40-k01*cin41-k02*cin42-k03*cin43;
1580 c11=cin11-k10*cin10-k11*cin11-k12*cin21-k13*cin31;
1581 c21=cin21-k10*cin20-k11*cin21-k12*cin22-k13*cin32;
1582 c31=cin31-k10*cin30-k11*cin31-k12*cin32-k13*cin33;
1583 c41=cin41-k10*cin40-k11*cin41-k12*cin42-k13*cin43;
1584 c22=cin22-k20*cin20-k21*cin21-k22*cin22-k23*cin32;
1585 c32=cin32-k20*cin30-k21*cin31-k22*cin32-k23*cin33;
1586 c42=cin42-k20*cin40-k21*cin41-k22*cin42-k23*cin43;
1587 c33=cin33-k30*cin30-k31*cin31-k32*cin32-k33*cin33;
1588 c43=cin43-k30*cin40-k31*cin41-k32*cin42-k33*cin43;
1589 c44=cin44-k40*cin40-k41*cin41-k42*cin42-k43*cin43;
1590
1591 newTrack->PutXElements(x0,x1,x2,x3,x4); // put the new state vector
1592 newTrack->PutCElements(c00,
1593 c10,c11,
1594 c20,c21,c22,
1595 c30,c31,c32,c33,
1596 c40,c41,c42,c43,c44); // put in track the
1597 // new cov matrix
1598 Double_t vmc[4][4];
1599 vmc[0][0]=v00-c00; vmc[1][0]=-c10; vmc[2][0]=-c20; vmc[3][0]=-c30;
1600 vmc[1][1]=v11-c11; vmc[2][1]=-c21; vmc[3][1]=v31-c31;
1601 vmc[2][2]=v22-c22; vmc[3][2]=v32-c32;
1602 vmc[3][3]=v33-c33;
1603 vmc[0][1]=vmc[1][0]; vmc[0][2]=vmc[2][0]; vmc[0][3]=vmc[3][0];
1604 vmc[1][2]=vmc[2][1]; vmc[1][3]=vmc[3][1];
1605 vmc[2][3]=vmc[3][2];
1606 /////////////////////// vmc matrix inversion ///////////////////////
1607 d=1.;
1608 for(k=0; k<kn; k++) {
1609 ll[k]=k;
1610 mm[k]=k;
1611 big=vmc[k][k];
1612 for(j=k; j<kn ; j++) {
1613 for (i=j; i<kn; i++) {
1614 if(TMath::Abs(big) < TMath::Abs(vmc[i][j]) ) {
1615 big=vmc[i][j];
1616 ll[k]=i;
1617 mm[k]=j;
1618 } // end if
1619 } // end for i
1620 } // end for j
1621 //
1622 j= ll[k];
1623 if(j > k) {
1624 for(i=0; i<kn; i++) {
1625 hold=-vmc[k][i];
1626 vmc[k][i]=vmc[j][i];
1627 vmc[j][i]=hold;
1628 } // end for i
1629 } // end if
1630 //
1631 i=mm[k];
1632 if(i > k ) {
1633 for(j=0; j<kn; j++) {
1634 hold=-vmc[j][k];
1635 vmc[j][k]=vmc[j][i];
1636 vmc[j][i]=hold;
1637 } // end for j
1638 } // end if
1639 //
1640 if(!big) {
1641 d=0.;
1642 cout << "Singular matrix\n";
1643 } // end if
1644 for(i=0; i<kn; i++) {
1645 if(i == k) continue;
1646 vmc[i][k]=vmc[i][k]/(-big);
1647 } // end for i
1648 //
1649 for(i=0; i<kn; i++) {
1650 hold=vmc[i][k];
1651 for(j=0; j<kn; j++) {
1652 if(i == k || j == k) continue;
1653 vmc[i][j]=hold*vmc[k][j]+vmc[i][j];
1654 } // end for j
1655 } // end for i
1656 //
1657 for(j=0; j<kn; j++) {
1658 if(j == k) continue;
1659 vmc[k][j]=vmc[k][j]/big;
1660 } // end for j
1661 //
1662 d=d*big;
1663 //
1664 vmc[k][k]=1./big;
1665 } // end for k
1666 //
1667 for(k=kn-1; k>=0; k--) {
1668 i=ll[k];
1669 if(i > k) {
1670 for (j=0; j<kn; j++) {
1671 hold=vmc[j][k];
1672 vmc[j][k]=-vmc[j][i];
1673 vmc[j][i]=hold;
1674 } // end for j
1675 } // end if i>k
1676 j=mm[k];
1677 if(j > k) {
1678 for (i=0; i<kn; i++) {
1679 hold=vmc[k][i];
1680 vmc[k][i]=-vmc[j][i];
1681 vmc[j][i]=hold;
1682 } // end for i
1683 } // end if j>k
1684 } // end for k
1685 ////////////////////////////////////////////////////////////////////
1686 Double_t chi2=(m[0]-x0)*( vmc[0][0]*(m[0]-x0) + 2.*vmc[1][0]*(m[1]-x1) +
1687 2.*vmc[2][0]*(m[2]-x2)+ 2.*vmc[3][0]*(m[3]-x3) )+
1688 (m[1]-x1)* ( vmc[1][1]*(m[1]-x1) + 2.*vmc[2][1]*(m[2]-x2)+
1689 2.*vmc[3][1]*(m[3]-x3) ) +
1690 (m[2]-x2)* ( vmc[2][2]*(m[2]-x2)+ 2.*vmc[3][2]*(m[3]-x3) ) +
1691 (m[3]-x3)*vmc[3][3]*(m[3]-x3);
1692 //cout<<" chi2 kalman = "<<chi2<<"\n"; getchar();
1693 newTrack->SetChi2(newTrack->GetChi2()+chi2);
1694 // newTrack->SetChi2(newTrack->GetChi2()+chi2pred);
1695}