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