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