1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.10.2.1 2001/10/24 07:26:04 hristov
19 All the changes from the head are merged with the release
21 Revision 1.14 2001/10/24 07:19:57 hristov
22 Some pointer correctly initialised in one of the constructors
24 Revision 1.13 2001/10/21 19:17:12 hristov
25 Several pointers were set to zero in the default constructors to avoid memory management problems
27 Revision 1.12 2001/10/19 21:32:35 nilsen
28 Minor changes to remove compliation warning on gcc 2.92.2 compiler, and
29 cleanded up a little bit of code.
32 // The purpose of this class is to permorm the ITS tracking. The
33 // constructor has the task to inizialize some private members. The method
34 // DoTracking is written to be called by a macro. It gets the event number,
35 // the minimum and maximum order number of TPC tracks that are to be tracked
36 // trough the ITS, and the file where the recpoints are registered. The
37 // method Recursivetracking is a recursive function that performs the
38 // tracking trough the ITS The method Intersection found the layer, ladder
39 // and detector whre the intersection take place and caluclate the
40 // cohordinates of this intersection. It returns an integer that is 0 if the
41 // intersection has been found successfully. The two mwthods Kalmanfilter
42 // and kalmanfiltervert operate the kalmanfilter without and with the vertex
43 // imposition respectively. The authors thank Mariana Bondila to have help
44 // them to resolve some problems. July-2000
52 #include <TStopwatch.h>
54 #include "TParticle.h"
57 #include "AliITSsegmentationSSD.h"
58 #include "AliITSgeomSPD.h"
59 #include "AliITSgeomSDD.h"
60 #include "AliITSgeomSSD.h"
61 #include "AliITSgeom.h"
62 #include "AliITSRecPoint.h"
64 #include "AliKalmanTrack.h"
66 #include "AliITSTrackV1.h"
67 #include "AliITSIOTrack.h"
68 #include "AliITSRad.h"
69 #include "../TPC/AliTPCtracker.h"
70 #include "AliITSTrackerV1.h"
71 #include "AliITSVertex.h"
73 ClassImp(AliITSTrackerV1)
74 //______________________________________________________________________
75 AliITSTrackerV1::AliITSTrackerV1() {
88 //______________________________________________________________________
89 AliITSTrackerV1::AliITSTrackerV1(AliITS* IITTSS, Bool_t flag) {
90 //Origin A. Badala' and G.S. Pappalardo:
91 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
92 // Class constructor. It does some initializations.
94 //PH Initialisation taken from the default constructor
109 Int_t imax = 200,jmax = 450;
110 frl = new AliITSRad(imax,jmax);
112 ////////// gets information on geometry /////////////////////////////
113 AliITSgeom *g1 = ((AliITS*)gAlice->GetDetector("ITS"))->GetITSgeom();
114 // Why not AliITS *g1 = fITS->GetITSgeom(); // ?? BSN
118 //cout<<" nlad ed ndet \n";
120 for(ia=0; ia<6; ia++) {
121 fNlad[ia]=g1->GetNladders(ia+1);
122 fNdet[ia]=g1->GetNdetectors(ia+1);
123 //cout<<fNlad[i]<<" "<<fNdet[i]<<"\n";
127 //cout<<" raggio medio = ";
129 for(ib=0; ib<6; ib++) {
130 g1->GetCenterThetaPhi(ib+1,ll,dd,det);
131 Double_t r1=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
132 g1->GetCenterThetaPhi(ib+1,ll,dd+1,det);
133 Double_t r2=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
134 fAvrad[ib]=(r1+r2)/2.;
135 //cout<<fAvrad[ib]<<" ";
137 //cout<<"\n"; getchar();
139 fDetx[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDx();
140 fDetz[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDz();
142 fDetx[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDx();
143 fDetz[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDz();
145 fDetx[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDx();
146 fDetz[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDz();
148 fDetx[3] = ((AliITSgeomSDD*)(g1->GetShape(4, ll, dd)))->GetDx();
149 fDetz[3] = ((AliITSgeomSDD*)(g1->GetShape(4, ll, dd)))->GetDz();
151 fDetx[4] = ((AliITSgeomSSD*)(g1->GetShape(5, ll, dd)))->GetDx();
152 fDetz[4] = ((AliITSgeomSSD*)(g1->GetShape(5, ll, dd)))->GetDz();
154 fDetx[5] = ((AliITSgeomSSD*)(g1->GetShape(6, ll, dd)))->GetDx();
155 fDetz[5] = ((AliITSgeomSSD*)(g1->GetShape(6, ll, dd)))->GetDz();
156 //cout<<" Detx Detz\n";
157 //for(Int_t la=0; la<6; la++) cout<<" "<<fDetx[la]<<" "<<
160 // allocate memory and define matrices fzmin, fzmax, fphimin and fphimax //
162 Double_t epszdrift=0.05;
164 fzmin = new Double_t*[6]; fzmax = new Double_t*[6];
165 Int_t im1, im2, im2max;
166 for(im1=0; im1<6; im1++) {
168 fzmin[im1] = new Double_t[im2max]; fzmax[im1] = new Double_t[im2max];
171 for(im1=0; im1<6; im1++) {
173 for(im2=0; im2<im2max; im2++) {
174 g1->GetCenterThetaPhi(im1+1,1,im2+1,det);
175 if(im2!=0) fzmin[im1][im2]=det(2)-fDetz[im1];
177 fzmin[im1][im2]=det(2)-(fDetz[im1])*epsz;
178 if(im2!=(im2max-1)) fzmax[im1][im2]=det(2)+fDetz[im1];
180 fzmax[im1][im2]=det(2)+fDetz[im1]*epsz;
181 if(im1==2 || im1==3) {
182 fzmin[im1][im2]-=epszdrift;
183 fzmax[im1][im2]+=epszdrift;
184 } // end if im1==2 || im1==3
188 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
189 for(im1=0;im1<6;im1++) {
191 fphimin[im1] = new Double_t[im2max];
192 fphimax[im1] = new Double_t[im2max];
195 fphidet = new Double_t*[6];
196 for(im1=0; im1<6; im1++) {
198 fphidet[im1] = new Double_t[im2max];
201 Float_t global[3],local[3];
202 Double_t pigre=TMath::Pi();
203 Double_t xmin,ymin,xmax,ymax;
205 for(im1=0; im1<6; im1++) {
207 for(im2=0; im2<im2max; im2++) {
209 g1->GetCenterThetaPhi(im1+1,im2+1,idet,det);
210 fphidet[im1][im2] = TMath::ATan2(Double_t(det(1)),
212 if(fphidet[im1][im2]<0.) fphidet[im1][im2]+=2.*pigre;
213 local[1]=local[2]=0.;
214 local[0]= -(fDetx[im1]);
215 if(im1==0) local[0]= (fDetx[im1]); //to take into account
216 // different reference system
217 g1->LtoG(im1+1,im2+1,idet,local,global);
218 xmax=global[0]; ymax=global[1];
219 local[0]= (fDetx[im1]);
220 if(im1==0) local[0]= -(fDetx[im1]);//take into account different
222 g1->LtoG(im1+1,im2+1,idet,local,global);
223 xmin=global[0]; ymin=global[1];
224 fphimin[im1][im2]= TMath::ATan2(ymin,xmin);
225 if(fphimin[im1][im2]<0.) fphimin[im1][im2]+=2.*pigre;
226 fphimax[im1][im2]= TMath::ATan2(ymax,xmax);
227 if(fphimax[im1][im2]<0.) fphimax[im1][im2]+=2.*pigre;
231 ////////// gets magnetic field factor //////////////////////////////
233 AliMagF * fieldPointer = gAlice->Field();
234 fFieldFactor = (Double_t)fieldPointer->Factor();
235 //cout<< " field factor = "<<fFieldFactor<<"\n"; getchar();
237 //______________________________________________________________________
238 AliITSTrackerV1::AliITSTrackerV1(const AliITSTrackerV1 &cobj) {
239 // Origin A. Badala' and G.S. Pappalardo:
240 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
244 *fresult = *cobj.fresult;
245 fPtref = cobj.fPtref;
246 fChi2max = cobj.fChi2max;
247 **fvettid = **cobj.fvettid;
248 fflagvert = cobj.fflagvert;
249 Int_t imax=200,jmax=450;
250 frl = new AliITSRad(imax,jmax);
252 fFieldFactor = cobj.fFieldFactor;
253 Int_t i,im1,im2,im2max;
255 fNlad[i] = cobj.fNlad[i];
256 fNdet[i] = cobj.fNdet[i];
257 fAvrad[i] = cobj.fAvrad[i];
258 fDetx[i] = cobj.fDetx[i];
259 fDetz[i] = cobj.fDetz[i];
261 fzmin = new Double_t*[6]; fzmax = new Double_t*[6];
262 for(im1=0; im1<6; im1++) {
264 fzmin[im1] = new Double_t[im2max];
265 fzmax[im1] = new Double_t[im2max];
267 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
268 for(im1=0;im1<6;im1++) {
270 fphimin[im1] = new Double_t[im2max];
271 fphimax[im1] = new Double_t[im2max];
274 fphidet = new Double_t*[6];
275 for(im1=0; im1<6; im1++) {
277 fphidet[im1] = new Double_t[im2max];
279 for(im1=0; im1<6; im1++) {
281 for(im2=0; im2<im2max; im2++) {
282 fzmin[im1][im2]=cobj.fzmin[im1][im2];
283 fzmax[im1][im2]=cobj.fzmax[im1][im2];
286 for(im1=0; im1<6; im1++) {
288 for(im2=0; im2<im2max; im2++) {
289 fphimin[im1][im2]=cobj.fphimin[im1][im2];
290 fphimax[im1][im2]=cobj.fphimax[im1][im2];
291 fphidet[im1][im2]=cobj.fphidet[im1][im2];
295 //______________________________________________________________________
296 AliITSTrackerV1::~AliITSTrackerV1(){
297 // Origin A. Badala' and G.S. Pappalardo:
298 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
301 //delete fTimerKalman;
302 //delete fTimerIntersection;
304 //______________________________________________________________________
305 AliITSTrackerV1 &AliITSTrackerV1::operator=(AliITSTrackerV1 obj) {
306 // Origin A. Badala' and G.S. Pappalardo:
307 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
308 // assignement operator
311 *fresult = *obj.fresult;
313 fChi2max = obj.fChi2max;
314 **fvettid = **obj.fvettid;
315 fflagvert = obj.fflagvert;
316 Int_t imax=200,jmax=450;
317 frl = new AliITSRad(imax,jmax);
319 fFieldFactor = obj.fFieldFactor;
322 fNlad[i] = obj.fNlad[i];
323 fNdet[i] = obj.fNdet[i];
324 fAvrad[i] = obj.fAvrad[i];
325 fDetx[i] = obj.fDetx[i];
326 fDetz[i] = obj.fDetz[i];
328 fzmin = new Double_t*[6];
329 fzmax = new Double_t*[6];
330 Int_t im1, im2, im2max;
331 for(im1=0; im1<6; im1++) {
333 fzmin[im1] = new Double_t[im2max]; fzmax[im1] = new Double_t[im2max];
335 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
336 for(im1=0;im1<6;im1++) {
338 fphimin[im1] = new Double_t[im2max];
339 fphimax[im1] = new Double_t[im2max];
342 fphidet = new Double_t*[6];
343 for(im1=0; im1<6; im1++) {
345 fphidet[im1] = new Double_t[im2max];
347 for(im1=0; im1<6; im1++) {
349 for(im2=0; im2<im2max; im2++) {
350 fzmin[im1][im2]=obj.fzmin[im1][im2];
351 fzmax[im1][im2]=obj.fzmax[im1][im2];
354 for(im1=0; im1<6; im1++) {
356 for(im2=0; im2<im2max; im2++) {
357 fphimin[im1][im2]=obj.fphimin[im1][im2];
358 fphimax[im1][im2]=obj.fphimax[im1][im2];
359 fphidet[im1][im2]=obj.fphidet[im1][im2];
365 //______________________________________________________________________
366 void AliITSTrackerV1::DoTracking(Int_t evNumber,Int_t minTr,Int_t maxTr,
367 TFile *file, Bool_t realmass) {
368 // Origin A. Badala' and G.S. Pappalardo:
369 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
370 // The method needs the event number, the minimum and maximum order
371 // number of TPC tracks that
372 // are to be tracked trough the ITS, and the file where the recpoints
374 // The method can be called by a macro. It preforms the tracking for
375 // all good TPC tracks
377 printf("begin DoTracking - file %p\n",file);
379 gAlice->GetEvent(evNumber); //modificato per gestire hbt
381 AliKalmanTrack *kkprov;
382 kkprov->SetConvConst(100/0.299792458/0.2/fFieldFactor);
384 TFile *cf=TFile::Open("AliTPCclusters.root");
385 AliTPCParam *digp= (AliTPCParam*)cf->Get("75x40_100x60");
386 if (!digp) { cerr<<"TPC parameters have not been found !\n"; getchar();}
389 AliTPCtracker *tracker = new AliTPCtracker(digp,evNumber);
392 tracker->LoadInnerSectors();
393 tracker->LoadOuterSectors();
396 TFile *tf=TFile::Open("AliTPCtracksSorted.root"); //modificato per hbt
398 cerr<<"Can't open AliTPCtracksSorted.root !\n";
401 TObjArray tracks(200000);
403 sprintf(tname,"TreeT_TPC_%d",evNumber);
405 TTree *tracktree=(TTree*)tf->Get(tname);
406 if (!tracktree) {cerr<<"Can't get a tree with TPC tracks !\n";}
407 TBranch *tbranch=tracktree->GetBranch("tracks");
408 Int_t nentr=(Int_t)tracktree->GetEntries();
411 AliTPCtrack *ioTrackTPC=0;
412 for (kk=0; kk<nentr; kk++) {
413 ioTrackTPC=new AliTPCtrack;
414 tbranch->SetAddress(&ioTrackTPC);
415 tracktree->GetEvent(kk);
416 tracker->CookLabel(ioTrackTPC,0.1);
417 tracks.AddLast(ioTrackTPC);
422 Int_t nt = tracks.GetEntriesFast();
423 cerr<<"Number of found tracks "<<nt<<endl;
426 TTree *tr=gAlice->TreeR();
427 Int_t nent=(Int_t)tr->GetEntries();
428 frecPoints = fITS->RecPoints();
432 Int_t *np = new Int_t[nent];
433 fvettid = new Int_t* [nent];
436 for (mod=0; mod<nent; mod++) {
438 fITS->ResetRecPoints();
439 gAlice->TreeR()->GetEvent(mod);
440 numbpoints = frecPoints->GetEntries();
441 totalpoints+=numbpoints;
442 np[mod] = numbpoints;
443 //cout<<" mod = "<<mod<<" numbpoints = "<<numbpoints<<"\n";getchar();
444 fvettid[mod] = new Int_t[numbpoints];
446 for (ii=0;ii<numbpoints; ii++) *(fvettid[mod]+ii)=0;
449 AliTPCtrack *track=0;
451 if(minTr < 0) {minTr = 0; maxTr = nt-1;}
455 TTree tracktree1("TreeT","Tree with ITS tracks");
456 AliITSIOTrack *ioTrack=0;
457 tracktree1.Branch("ITStracks","AliITSIOTrack",&ioTrack,32000,0);
459 TDatabasePDG * db = new TDatabasePDG;
462 for (j=minTr; j<=maxTr; j++) {
463 track=(AliTPCtrack*)tracks.UncheckedAt(j);
464 if (!track) continue;
466 /// mass definition ////////////////////////
467 Double_t mass=0.13956995;
468 Int_t pcode=211; // a pion by default
470 Int_t TPClabel=TMath::Abs( track->GetLabel() );
471 TParticle *p = (TParticle*)gAlice->Particle(TPClabel);
472 pcode=p->GetPdgCode();
473 // Int_t mothercode=p->GetFirstMother();
474 //if(mothercode>0 ) numofsecondaries++; else numofprimaries++;
476 //if(!pcode) pcode=211;
477 if(TMath::Abs(pcode)<20443) mass=db->GetParticle(pcode)->Mass();
480 ///////////////////////////////////////////////
482 ////// propagation to the end of TPC //////////////
484 track->PropagateTo(xk, 28.94, 1.204e-3,mass); //Ne
486 track->PropagateTo(xk, 44.77, 1.71,mass); //Tedlar
488 track->PropagateTo(xk, 44.86, 1.45,mass); //kevlar
490 track->PropagateTo(xk, 41.28, 0.029,mass); //Nomex
492 track->PropagateTo(xk,36.2,1.98e-3,mass); //C02
494 track->PropagateTo(xk, 24.01, 2.7,mass); //Al
496 track->PropagateTo(xk, 44.77, 1.71,mass); //Tedlar
498 track->PropagateTo(xk, 44.86, 1.45,mass); //kevlar
500 track->PropagateTo(xk, 41.28, 0.029,mass); //Nomex
501 ////////////////////////////////////////////////////////////////////
503 // new propagation to the end of TPC
505 //track->PropagateTo(xk,0.,0.); //Ne if it's still there
507 track->PropagateTo(xk, 28.94, 1.204e-3);
509 track->PropagateTo(xk, 44.77,1.71); //Tedlar
511 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
513 track->PropagateTo(xk, 41.28, 0.029);//Nomex
515 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
517 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
520 //track->PropagateTo(xk,0.,0.); //C02
521 track->PropagateTo(xk,36.2,1.98e-3); //C02
524 track->PropagateTo(xk, 24.01, 2.7); //Al
526 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
528 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
530 track->PropagateTo(xk, 41.28, 0.029); //Nomex
532 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
534 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
536 track->PropagateTo(xk, 24.01, 2.7); //Al
539 AliITSTrackV1 trackITS(*track);
540 trackITS.PutMass(mass); //new to add mass to track
541 if(fresult){ delete fresult; fresult=0;}
542 fresult = new AliITSTrackV1(trackITS);
544 AliITSTrackV1 primaryTrack(trackITS);
545 vgeant=(*fresult).GetVertex();
547 // Definition of dv and zv for vertex constraint
548 Double_t sigmaDv=0.0050; Double_t sigmaZv=0.010;
549 //Double_t sigmaDv=0.0015; Double_t sigmaZv=0.0015;
550 Double_t uniform= gRandom->Uniform();
552 if(uniform<=0.5) signdv=-1.;
556 Double_t vr=TMath::Sqrt(vgeant(0)*vgeant(0)+ vgeant(1)*vgeant(1));
557 Double_t dv=gRandom->Gaus(signdv*vr,(Float_t)sigmaDv);
558 Double_t zv=gRandom->Gaus(vgeant(2),(Float_t)sigmaZv);
559 //cout<<" Dv e Zv = "<<dv<<" "<<zv<<"\n";
562 trackITS.SetsigmaDv(sigmaDv);
563 trackITS.SetsigmaZv(sigmaZv);
564 (*fresult).SetDv(dv);
565 (*fresult).SetZv(zv);
566 (*fresult).SetsigmaDv(sigmaDv);
567 (*fresult).SetsigmaZv(sigmaZv);
568 primaryTrack.SetDv(dv);
569 primaryTrack.SetZv(zv);
570 primaryTrack.SetsigmaDv(sigmaDv);
571 primaryTrack.SetsigmaZv(sigmaZv);
572 primaryTrack.PrimaryTrack(frl);
573 TVector d2=primaryTrack.Getd2();
574 TVector tgl2=primaryTrack.Gettgl2();
575 TVector dtgl=primaryTrack.Getdtgl();
576 trackITS.Setd2(d2); trackITS.Settgl2(tgl2);
577 trackITS.Setdtgl(dtgl);
578 (*fresult).Setd2(d2); (*fresult).Settgl2(tgl2);
579 (*fresult).Setdtgl(dtgl);
581 trackITS.SetVertex(vertex); trackITS.SetErrorVertex(ervertex);
582 (*result).SetVertex(vertex); (*result).SetErrorVertex(ervertex);
584 TList *list= new TList();
586 list->AddLast(&trackITS);
588 fPtref=TMath::Abs( (trackITS).GetPt() );
589 if(fPtref>1.0) fChi2max=40.;
590 if(fPtref<=1.0) fChi2max=20.;
591 if(fPtref<0.4 ) fChi2max=100.;
592 if(fPtref<0.2 ) fChi2max=40.;
593 // if(fPtref<0.4 ) fChi2max=30.;
594 // if(fPtref<0.2 ) fChi2max=20.;
595 //if(fPtref<0.2 ) fChi2max=10.;
596 //if(fPtref<0.1 ) fChi2max=5.;
597 //cout << "\n Pt = " << fPtref <<"\n"; //stampa
598 RecursiveTracking(list);
603 TVector vecTotLabRef(18);
605 for(lay=5; lay>=0; lay--) {
606 TVector vecLabRef(3);
607 vecLabRef=(*fresult).GetLabTrack(lay);
608 Float_t clustZ=(*fresult).GetZclusterTrack( lay);
610 Int_t lpp=(Int_t)vecLabRef(k);
612 TParticle *p=(TParticle*) gAlice->Particle(lpp);
613 Int_t pcode=p->GetPdgCode();
614 if(pcode==11) vecLabRef(k)=p->GetFirstMother();
616 itot++; vecTotLabRef(itot)=vecLabRef(k);
617 if(vecLabRef(k)==0. && clustZ == 0.) vecTotLabRef(itot) =-3.;
622 (*fresult).Search(vecTotLabRef, labref, freq);
624 //if(freq < 6) labref=-labref; // cinque - sei
625 if(freq < 5) labref=-labref; // cinque - sei
626 (*fresult).SetLabel(labref);
628 // cout<<" progressive track number = "<<j<<"\r";
630 Int_t numOfCluster=(*fresult).GetNumClust();
631 //cout<<" progressive track number = "<<j<<"\n"; // stampa
632 Long_t labITS=(*fresult).GetLabel();
633 //cout << " ITS track label = " << labITS << "\n"; // stampa
634 Int_t lab=track->GetLabel();
635 //cout << " TPC track label = " << lab <<"\n"; // stampa
636 //propagation to vertex
639 if((*fresult).DoNotCross(rbeam)) continue; //no intersection with beampipe
640 (*fresult).Propagation(rbeam);
641 Double_t c00,c10,c11,c20,c21,c22,c30,c31,c32,c33,c40,c41,c42,c43,c44;
642 (*fresult).GetCElements(c00,
646 c40,c41,c42,c43,c44);
648 Double_t pt=TMath::Abs((*fresult).GetPt());
649 Double_t dr=(*fresult).GetD();
650 Double_t z=(*fresult).GetZ();
651 Double_t tgl=(*fresult).GetTgl();
652 Double_t c=(*fresult).GetC();
654 Double_t dz=z-(tgl/cy)*TMath::ASin((*fresult).Arga(rbeam));
656 // cout<<" dr e dz alla fine = "<<dr<<" "<<dz<<"\n"; getchar();
657 Double_t phi=(*fresult).Getphi();
658 Double_t phivertex = phi - TMath::ASin((*fresult).ArgA(rbeam));
659 Double_t duepi=2.*TMath::Pi();
660 if(phivertex>duepi) phivertex-=duepi;
661 if(phivertex<0.) phivertex+=duepi;
662 /////////////////////////////////////////////////////////////
663 Int_t idmodule,idpoint;
664 if(numOfCluster >=5) { // cinque - sei
665 //if(numOfCluster ==6) { // cinque - sei
666 AliITSIOTrack outTrack;
668 ioTrack->SetStatePhi(phi);
669 ioTrack->SetStateZ(z);
670 ioTrack->SetStateD(dr);
671 ioTrack->SetStateTgl(tgl);
672 ioTrack->SetStateC(c);
673 Double_t radius=(*fresult).Getrtrack();
674 ioTrack->SetRadius(radius);
676 if(c>0.) charge=-1; else charge=1;
677 ioTrack->SetCharge(charge);
678 ioTrack->SetCovMatrix(c00,
682 c40,c41,c42,c43,c44);
683 Double_t px=pt*TMath::Cos(phivertex);
684 Double_t py=pt*TMath::Sin(phivertex);
686 Double_t xtrack=dr*TMath::Sin(phivertex);
687 Double_t ytrack=dr*TMath::Cos(phivertex);
688 Double_t ztrack=dz+vgeant(2);
692 ioTrack->SetX(xtrack);
693 ioTrack->SetY(ytrack);
694 ioTrack->SetZ(ztrack);
695 ioTrack->SetLabel(labITS);
696 ioTrack->SetTPCLabel(lab);
699 for(il=0;il<6; il++){
700 ioTrack->SetIdPoint(il,(*fresult).GetIdPoint(il));
701 ioTrack->SetIdModule(il,(*fresult).GetIdModule(il));
704 for (il=0;il<6;il++) {
705 idpoint=(*fresult).GetIdPoint(il);
706 idmodule=(*fresult).GetIdModule(il);
707 if(idmodule>0.) *(fvettid[idmodule]+idpoint)=1;
709 ioTrack->SetIdPoint(il,idpoint);
710 ioTrack->SetIdModule(il,idmodule);
712 } // end if on numOfCluster
713 //gObjectTable->Print(); // stampa memoria
714 } // end for (int j=minTr; j<=maxTr; j++)
716 static Bool_t first=kTRUE;
719 tfile=new TFile("itstracks.root","RECREATE");
720 //cout<<"I have opened itstracks.root file "<<endl;
726 sprintf(hname,"TreeT%d",evNumber);
727 tracktree1.Write(hname);
729 TTree *fAli=gAlice->TreeK();
731 if (fAli) fileAli =fAli->GetCurrentFile();
733 ////////////////////////////////////////////////////////////////////
735 printf("delete vectors\n");
737 if(fvettid) delete [] fvettid;
738 if(fresult) {delete fresult; fresult=0;}
740 //______________________________________________________________________
741 void AliITSTrackerV1::RecursiveTracking(TList *trackITSlist) {
742 // This function perform the recursive tracking in ITS detectors
743 // reference is a pointer to the final best track
744 // Origin A. Badala' and G.S. Pappalardo:
745 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
746 // The authors thank Mariana Bondila to have help them to resolve some
747 // problems. July-2000
749 //Rlayer[0]=4.; Rlayer[1]=7.; Rlayer[2]=14.9;
750 // Rlayer[3]=23.8; Rlayer[4]=39.1; Rlayer[5]=43.6; //vecchio
752 //////////////////////
753 Float_t sigmaphil[6], sigmazl[6];
754 sigmaphil[0]=1.44e-6/(fAvrad[0]*fAvrad[0]);
755 sigmaphil[1]=1.44e-6/(fAvrad[1]*fAvrad[1]);
756 sigmaphil[2]=1.444e-5/(fAvrad[2]*fAvrad[2]);
757 sigmaphil[3]=1.444e-5/(fAvrad[3]*fAvrad[3]);
758 sigmaphil[4]=4e-6/(fAvrad[4]*fAvrad[4]);
759 sigmaphil[5]=4e-6/(fAvrad[5]*fAvrad[5]);
766 ///////////////////////////////////////////////////////////
768 AliITSgeom *g1 = fITS->GetITSgeom();
769 AliITSRecPoint *recp;
770 for(index =0; index<trackITSlist->GetSize(); index++) {
771 AliITSTrackV1 *trackITS = (AliITSTrackV1 *) trackITSlist->At(index);
772 if((*trackITS).GetLayer()==7) fresult->SetChi2(10.223e140);
773 // cout <<" Layer inizio = "<<(*trackITS).GetLayer()<<"\n";
774 // cout<<"fvtrack =" <<"\n";
775 // cout << (*trackITS)(0) << " "<<(*trackITS)(1)<<" "
776 // <<(*trackITS)(2)<<" "<<(*trackITS)(3)<<" "
777 // <<(*trackITS)(4)<<"\n";
778 // cout<< " rtrack = "<<(*trackITS).Getrtrack()<<"\n";
779 // cout<< " Pt = "<<(*trackITS).GetPt()<<"\n";
781 Double_t chi2Now, chi2Ref;
782 Float_t numClustRef = fresult->GetNumClust();
783 if((*trackITS).GetLayer()==1 ) {
784 chi2Now = trackITS->GetChi2();
785 Float_t numClustNow = trackITS->GetNumClust();
786 if(trackITS->GetNumClust())
787 chi2Now /= (Double_t)trackITS->GetNumClust();
788 chi2Ref = fresult->GetChi2();
789 if(fresult->GetNumClust())
790 chi2Ref /= (Double_t)fresult->GetNumClust();
791 //cout<<" chi2Now and chi2Ref = "<<chi2Now<<" "<<chi2Ref<<"\n";
792 if( numClustNow > numClustRef ) {*fresult = *trackITS;}
793 if((numClustNow == numClustRef )&&
794 (chi2Now < chi2Ref)) {
795 *fresult = *trackITS;
800 if(trackITS->Getfnoclust()>=2) continue;
801 Float_t numClustNow = trackITS->GetNumClust();
803 chi2Now = trackITS->GetChi2();
805 if(numClustNow<numClustRef && chi2Now>fresult->GetChi2()) continue;
806 //cout<<" chi2Now = "<<chi2Now<<"\n";
807 // commentato il 30-7-2001
808 chi2Now/=numClustNow;
809 if(fPtref > 1.0 && chi2Now > 30.) continue;
810 if((fPtref >= 0.6 && fPtref<=1.0) && chi2Now > 40.) continue;
811 // if((fPtref <= 0.6 && fPtref>0.2)&& chi2Now > 40.) continue;
812 // if(fPtref <= 0.2 && chi2Now > 8.) continue;
813 if((fPtref <= 0.6 && fPtref>0.2)&& chi2Now > 30.) continue;
814 if(fPtref <= 0.2 && chi2Now > 7.) continue;
815 /////////////////////////////
818 Int_t layerInit = (*trackITS).GetLayer();
819 Int_t layernew = layerInit - 2;// -1 for new layer, -1 for matrix index
821 Int_t ladp, ladm, detp,detm,ladinters,detinters;
822 Int_t layerfin=layerInit-1;
823 // cout<<"Prima di intersection \n";
824 //if(!fTimerIntersection) fTimerIntersection = new TStopwatch();
826 //fTimerIntersection->Continue();
828 Int_t outinters=Intersection(*trackITS,layerfin,ladinters,detinters);
829 //fTimerIntersection->Stop();
831 // cout<<" outinters = "<<outinters<<"\n";
832 // cout<<" Layer ladder detector intersection ="
833 // <<layerfin<<" "<<ladinters<<" "<<detinters<<"\n";
834 // cout << " phiinters zinters = "<<(*trackITS)(0)
835 // << " "<<(*trackITS)(1)<<"\n"; getchar();
836 if(outinters==-1) continue;
839 TVector toucLad(9), toucDet(9);
840 Int_t lycur=layerfin;
843 if(ladm <= 0) ladm=fNlad[layerfin-1];
844 if(ladp > fNlad[layerfin-1]) ladp=1;
849 toucLad(0)=ladinters; toucLad(1)=ladm; toucLad(2)=ladp;
850 toucLad(3)=ladinters; toucLad(4)=ladm; toucLad(5)=ladp;
851 toucLad(6)=ladinters; toucLad(7)=ladm; toucLad(8)=ladp;
852 toucDet(0)=detinters; toucDet(1)=detinters; toucDet(2)=detinters;
853 if(detm > 0 && detp <= fNdet[layerfin-1]) {
855 toucDet(3)=detm; toucDet(4)=detm; toucDet(5)=detm;
856 toucDet(6)=detp; toucDet(7)=detp; toucDet(8)=detp;
858 if(detm > 0 && detp > fNdet[layerfin-1]) {
860 toucDet(3)=detm; toucDet(4)=detm; toucDet(5)=detm;
862 if(detm <= 0 && detp <= fNdet[layerfin-1]) {
864 toucDet(3)=detp; toucDet(4)=detp; toucDet(5)=detp;
867 Float_t epsphi=5.0, epsz=5.0;
868 if(fPtref<0.2) {epsphi=3.; epsz=3.;}
869 // nuova definizione idetot e toucLad e toucDet to be
870 // transformed in a method
871 // these values could be modified
872 Float_t pigre=TMath::Pi();
873 Float_t rangephi=5., rangez=5.;
874 if(layerfin==1 || layerfin ==2){
875 rangephi=40.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
876 (*trackITS).GetSigmaphi());
877 rangez = 40.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
878 (*trackITS).GetSigmaZ());
880 if(layerfin==3 || layerfin ==4){
881 //rangephi=30.*fepsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
882 // (*trackITS).GetSigmaphi());
883 //rangez = 40.*fepsz*TMath::Sqrt(sigmazl[layerfin-1]+
884 // (*trackITS).GetSigmaZ());
885 rangephi=40.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
886 (*trackITS).GetSigmaphi());
887 rangez = 50.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
888 (*trackITS).GetSigmaZ());
890 if(layerfin==5 || layerfin ==6){
891 rangephi=20.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
892 (*trackITS).GetSigmaphi());
893 rangez =5.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
894 (*trackITS).GetSigmaZ());
896 Float_t phinters, zinters;
897 phinters=(*trackITS).Getphi();
898 zinters=(*trackITS).GetZ();
900 Float_t phicm, phicp, distphim, distphip;
902 if(phinters>fphimax[layerfin-1][ladm]) phicm=phinters-2*pigre;
903 distphim=TMath::Abs(phicm-fphimax[layerfin-1][ladm]);
905 if(phinters>fphimin[layerfin-1][ladp]) phicp=phinters-2.*pigre;
906 distphip=TMath::Abs(phicp-fphimin[layerfin-1][ladp]);
910 toucLad(0)=ladinters; toucDet(0)=detinters;
911 if(detm>0) distz=TMath::Abs(zinters-fzmax[layerfin-1][detm-1]);
912 if(detm>0 && rangez>=distz){
914 idetot++; toucLad(idetot-1)=ladinters; toucDet(idetot-1)=detm;
915 if(rangephi>=distphim){
917 toucLad(idetot-1)=ladm;
918 toucDet(idetot-1)=detinters;
920 toucLad(idetot-1)=ladm;
921 toucDet(idetot-1)=detm;
923 if(rangephi>=distphip){
925 toucLad(idetot-1)=ladp;
926 toucDet(idetot-1)=detinters;
928 toucLad(idetot-1)=ladp;
929 toucDet(idetot-1)=detm;
932 if(detp<=fNdet[layerfin-1])
933 distz=TMath::Abs(zinters-fzmin[layerfin-1][detp-1]);
934 if(detp<=fNdet[layerfin-1] && rangez>=distz){
936 idetot++; toucLad(idetot-1)=ladinters; toucDet(idetot-1)=detp;
937 if(rangephi>=distphim){
938 idetot++; toucLad(idetot-1)=ladm; toucDet(idetot-1)=detp;
941 toucLad(idetot-1)=ladm;
942 toucDet(idetot-1)=detinters;
945 if(rangephi>=distphip){
947 toucLad(idetot-1)=ladp;
948 toucDet(idetot-1)=detp;
951 toucLad(idetot-1)=ladp;
952 toucDet(idetot-1)=detinters;
955 } //end detm<fNdet[.......
957 if(flagzmin == 0 && flagzmax==0){
958 if(rangephi>=distphim){
960 toucLad(idetot-1)=ladm;
961 toucDet(idetot-1)=detinters;
963 if(rangephi>=distphip){
965 toucLad(idetot-1)=ladp;
966 toucDet(idetot-1)=detinters;
969 ////////////////////////////////////////////////////////////
971 for (iriv=0; iriv<idetot; iriv++) { //for on detectors
972 ///////////////////////////////////////////////////////
973 /*** Rec points sorted by module *****/
974 /**************************************/
975 Int_t indexmod; //mod ott
976 // AliITSRecPoint *recp;
977 indexmod = g1->GetModuleIndex(lycur,(Int_t)toucLad(iriv),
978 (Int_t)toucDet(iriv));
980 fITS->ResetRecPoints();
981 gAlice->TreeR()->GetEvent(indexmod);
982 Int_t npoints=frecPoints->GetEntries();
984 Int_t *indlist=new Int_t[npoints+1];
987 for (ind=0; ind<=npoints; ind++) {
989 if (*(fvettid[index]+ind)==0) {
990 indlist[counter]=ind;
997 if(indlist[ind] < 0) recp=0;
999 recp = (AliITSRecPoint*)frecPoints->
1000 UncheckedAt(indlist[ind]);
1004 ///////////////////////// new //////////////////////////
1006 for(indnew=0; indnew<npoints; indnew++){
1007 if (*(fvettid[indexmod]+indnew)==0)
1008 recp =(AliITSRecPoint*)frecPoints->UncheckedAt(indnew);
1011 ////////////////////////////////////////////////////
1012 TVector cluster(3),vecclust(9);
1013 vecclust(6)=vecclust(7)=vecclust(8)=-1.;
1015 // set veclust in global
1016 Float_t global[3], local[3];
1017 local[0]=recp->GetX();
1019 local[2]= recp->GetZ();
1021 Int_t plad = TMath::Nint(toucLad(iriv));
1022 Int_t pdet = TMath::Nint(toucDet(iriv));
1023 g1->LtoG(play,plad,pdet,local,global);
1024 vecclust(0)=global[0];
1025 vecclust(1)=global[1];
1026 vecclust(2)=global[2];
1028 vecclust(3) = (Float_t)recp->fTracks[0];
1029 //vecclust(4) = (Float_t)indlist[ind];
1030 vecclust(4) = (Float_t)indnew;
1031 vecclust(5) = (Float_t)indexmod; //mod ott
1032 vecclust(6) = (Float_t)recp->fTracks[0];
1033 vecclust(7) = (Float_t)recp->fTracks[1];
1034 vecclust(8) = (Float_t)recp->fTracks[2];
1035 sigma[0] = (Double_t) recp->GetSigmaX2();
1036 sigma[1] = (Double_t) recp->GetSigmaZ2();
1037 //now we are in r,phi,z in global
1038 cluster(0) = TMath::Sqrt(vecclust(0)*vecclust(0)+
1039 vecclust(1)*vecclust(1));//r hit
1040 cluster(1) = TMath::ATan2(vecclust(1),vecclust(0));
1041 if(cluster(1)<0.) cluster(1)+=2.*TMath::Pi();
1042 cluster(2) = vecclust(2); // z hit
1043 // cout<<" layer = "<<play<<"\n";
1044 // cout<<" cluster prima = "<<vecclust(0)<<" "
1045 // <<vecclust(1)<<" "
1046 // <<vecclust(2)<<"\n"; getchar();
1048 Float_t sigmatotphi, sigmatotz;
1049 // Float_t epsphi=5.0, epsz=5.0;
1050 //if(fPtref<0.2) {epsphi=3.; epsz=3.;}
1051 Double_t rTrack=(*trackITS).Getrtrack();
1052 Double_t sigmaphi=sigma[0]/(rTrack*rTrack);
1053 sigmatotphi=epsphi*TMath::Sqrt(sigmaphi +
1054 (*trackITS).GetSigmaphi());
1055 sigmatotz=epsz*TMath::Sqrt(sigma[1] +
1056 (*trackITS).GetSigmaZ());
1057 //cout<<"cluster e sigmatotphi e track = "<<cluster(0)
1058 // <<" "<<cluster(1)<<" "<<sigmatotphi<<" "
1059 // <<vecclust(3)<<"\n";
1060 //if(vecclust(3)==481) getchar();
1061 if(cluster(1)<6. && (*trackITS).Getphi()>6.)
1062 cluster(1)=cluster(1)+(2.*TMath::Pi());
1063 if(cluster(1)>6. && (*trackITS).Getphi()<6.)
1064 cluster(1)=cluster(1)-(2.*TMath::Pi());
1065 if(TMath::Abs(cluster(1)-(*trackITS).Getphi())>sigmatotphi)
1067 // cout<<" supero sigmaphi \n";
1068 AliITSTrackV1 *newTrack = new AliITSTrackV1((*trackITS));
1069 (*newTrack).SetLayer((*trackITS).GetLayer()-1);
1070 if (TMath::Abs(rTrack-cluster(0))/rTrack>1e-6)
1071 (*newTrack).Correct(Double_t(cluster(0)));
1072 //cout<<" cluster(2) e(*newTrack).GetZ()="<<cluster(2)<<" "
1073 // << (*newTrack).GetZ()<<"\n";
1074 if(TMath::Abs(cluster(2)-(*newTrack).GetZ()) > sigmatotz){
1078 Double_t sigmanew[2];
1079 sigmanew[0]= sigmaphi;
1080 sigmanew[1]=sigma[1];
1084 // Double_t chi2pred=newTrack->GetPredChi2(m,sigmanew);
1085 // cout<<" chi2pred = "<<chi2pred<<"\n";
1086 // if(chi2pred>fChi2max) continue; //aggiunto il 30-7-2001
1087 if(iriv == 0) flaghit=1;
1088 (*newTrack).AddMS(frl); // add the multiple scattering
1089 //matrix to the covariance matrix
1090 (*newTrack).AddEL(frl,1.,0);
1092 //if(!fTimerKalman) fTimerKalman = new TStopwatch();//timer
1093 //fTimerKalman->Continue(); // timer
1095 KalmanFilterVert(newTrack,cluster,sigmanew);
1096 //KalmanFilterVert(newTrack,cluster,sigmanew,chi2pred);
1098 KalmanFilter(newTrack,cluster,sigmanew);
1100 //fTimerKalman->Stop(); // timer
1101 (*newTrack).PutCluster(layernew, vecclust);
1102 newTrack->AddClustInTrack();
1103 listoftrack.AddLast(newTrack);
1105 // delete [] indlist; //mod ott
1106 } // end of for on detectors (iriv)
1107 }//end if(outinters==0)
1109 if(flaghit==0 || outinters==-2) {
1110 AliITSTrackV1 *newTrack = new AliITSTrackV1(*trackITS);
1111 (*newTrack).Setfnoclust();
1112 (*newTrack).SetLayer((*trackITS).GetLayer()-1);
1113 (*newTrack).AddMS(frl); // add the multiple scattering matrix
1114 // to the covariance matrix
1115 (*newTrack).AddEL(frl,1.,0);
1116 listoftrack.AddLast(newTrack);
1119 //gObjectTable->Print(); // stampa memoria
1121 RecursiveTracking(&listoftrack);
1122 listoftrack.Delete();
1123 } // end of for on tracks (index)
1125 //gObjectTable->Print(); // stampa memoria
1127 //______________________________________________________________________
1128 Int_t AliITSTrackerV1::Intersection(AliITSTrackV1 &track,Int_t layer,
1129 Int_t &ladder,Int_t &detector) {
1130 // Origin A. Badala' and G.S. Pappalardo
1131 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1132 // Found the intersection and the detector
1134 Double_t rk=fAvrad[layer-1];
1135 if(track.DoNotCross(rk)){ /*cout<< " Do not cross \n";*/ return -1;}
1136 track.Propagation(rk);
1137 Double_t zinters=track.GetZ();
1138 Double_t phinters=track.Getphi();
1139 //cout<<"zinters = "<<zinters<<" phinters = "<<phinters<<"\n";
1143 TVector distZCenter(2);
1147 for(iD = 1; iD<= fNdet[layer-1]; iD++) {
1148 if(zinters > fzmin[layer-1][iD-1] && zinters <= fzmax[layer-1][iD-1]) {
1150 cout<< " Errore su iz in Intersection \n";
1153 listDet(iz)= iD; distZCenter(iz)=TMath::Abs(zinters-det(2));
1159 if(iz==0) {/* cout<< " No detector along Z \n";*/ return -2;}
1160 detector=Int_t (listDet(0));
1161 if(iz>1 && (distZCenter(0)>distZCenter(1))) detector=Int_t (listDet(1));
1164 TVector distPhiCenter(2);
1166 Double_t pigre=TMath::Pi();
1168 for(iLd = 1; iLd<= fNlad[layer-1]; iLd++) {
1169 Double_t phimin=fphimin[layer-1][iLd-1];
1170 Double_t phimax=fphimax[layer-1][iLd-1];
1171 Double_t phidet=fphidet[layer-1][iLd-1];
1172 Double_t phiconfr=phinters;
1174 //if(phimin <5.5) {cout<<" Error in Intersection for phi \n";
1177 if(phinters>(1.5*pigre)) phiconfr=phinters-(2.*pigre);
1178 if(phidet>(1.5*pigre)) phidet-=(2.*pigre);
1180 if(phiconfr>phimin && phiconfr<= phimax) {
1182 cout<< " Errore su ip in Intersection \n"; getchar();
1185 distPhiCenter(ip)=TMath::Abs(phiconfr-phidet); ip++;
1189 if(ip==0) { cout<< " No detector along phi \n"; getchar();}
1190 ladder=Int_t (listLad(0));
1191 if(ip>1 && (distPhiCenter(0)>distPhiCenter(1))) ladder=Int_t (listLad(1));
1194 //______________________________________________________________________
1195 void AliITSTrackerV1::KalmanFilter(AliITSTrackV1 *newTrack,TVector &cluster,
1197 //Origin A. Badala' and G.S. Pappalardo:
1198 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1199 // Kalman filter without vertex constraint
1200 ////// Evaluation of the measurement vector ////////////////////////
1202 Double_t rk,phik,zk;
1203 rk=cluster(0); phik=cluster(1); zk=cluster(2);
1205 //////////////////////// Evaluation of the error matrix V /////////
1206 Double_t v00=sigma[0];
1207 Double_t v11=sigma[1];
1208 ////////////////////////////////////////////////////////////////////
1209 Double_t cin00,cin10,cin20,cin30,cin40,cin11,cin21,cin31,cin41,cin22,
1210 cin32,cin42,cin33,cin43,cin44;
1212 newTrack->GetCElements(cin00,
1215 cin30,cin31,cin32,cin33,
1216 cin40,cin41,cin42,cin43,cin44); //get C matrix
1217 Double_t rold00=cin00+v00;
1218 Double_t rold10=cin10;
1219 Double_t rold11=cin11+v11;
1220 ////////////////////// R matrix inversion /////////////////////////
1221 Double_t det=rold00*rold11-rold10*rold10;
1222 Double_t r00=rold11/det;
1223 Double_t r10=-rold10/det;
1224 Double_t r11=rold00/det;
1225 ////////////////////////////////////////////////////////////////////
1226 Double_t k00=cin00*r00+cin10*r10;
1227 Double_t k01=cin00*r10+cin10*r11;
1228 Double_t k10=cin10*r00+cin11*r10;
1229 Double_t k11=cin10*r10+cin11*r11;
1230 Double_t k20=cin20*r00+cin21*r10;
1231 Double_t k21=cin20*r10+cin21*r11;
1232 Double_t k30=cin30*r00+cin31*r10;
1233 Double_t k31=cin30*r10+cin31*r11;
1234 Double_t k40=cin40*r00+cin41*r10;
1235 Double_t k41=cin40*r10+cin41*r11;
1236 Double_t x0,x1,x2,x3,x4;
1237 newTrack->GetXElements(x0,x1,x2,x3,x4); // get the state vector
1238 Double_t savex0=x0, savex1=x1;
1239 x0+=k00*(m[0]-savex0)+k01*(m[1]-savex1);
1240 x1+=k10*(m[0]-savex0)+k11*(m[1]-savex1);
1241 x2+=k20*(m[0]-savex0)+k21*(m[1]-savex1);
1242 x3+=k30*(m[0]-savex0)+k31*(m[1]-savex1);
1243 x4+=k40*(m[0]-savex0)+k41*(m[1]-savex1);
1244 Double_t c00,c10,c20,c30,c40,c11,c21,c31,c41,c22,c32,c42,c33,c43,c44;
1245 c00=cin00-k00*cin00-k01*cin10;
1246 c10=cin10-k00*cin10-k01*cin11;
1247 c20=cin20-k00*cin20-k01*cin21;
1248 c30=cin30-k00*cin30-k01*cin31;
1249 c40=cin40-k00*cin40-k01*cin41;
1250 c11=cin11-k10*cin10-k11*cin11;
1251 c21=cin21-k10*cin20-k11*cin21;
1252 c31=cin31-k10*cin30-k11*cin31;
1253 c41=cin41-k10*cin40-k11*cin41;
1254 c22=cin22-k20*cin20-k21*cin21;
1255 c32=cin32-k20*cin30-k21*cin31;
1256 c42=cin42-k20*cin40-k21*cin41;
1257 c33=cin33-k30*cin30-k31*cin31;
1258 c43=cin43-k30*cin40-k31*cin41;
1259 c44=cin44-k40*cin40-k41*cin41;
1260 newTrack->PutXElements(x0,x1,x2,x3,x4); // put the new state vector
1261 newTrack->PutCElements(c00,
1265 c40,c41,c42,c43,c44); // put in track the
1267 Double_t vmcold00=v00-c00;
1268 Double_t vmcold10=-c10;
1269 Double_t vmcold11=v11-c11;
1270 ////////////////////// Matrix vmc inversion ///////////////////////
1271 det=vmcold00*vmcold11-vmcold10*vmcold10;
1272 Double_t vmc00=vmcold11/det;
1273 Double_t vmc10=-vmcold10/det;
1274 Double_t vmc11=vmcold00/det;
1275 ////////////////////////////////////////////////////////////////////
1276 Double_t chi2=(m[0]-x0)*( vmc00*(m[0]-x0) + 2.*vmc10*(m[1]-x1) ) +
1277 (m[1]-x1)*vmc11*(m[1]-x1);
1278 newTrack->SetChi2(newTrack->GetChi2()+chi2);
1280 //----------------------------------------------------------------------
1281 //void AliITSTrackerV1::KalmanFilterVert(AliITSTrackV1 *newTrack,
1282 // TVector &cluster,Double_t sigma[2]){
1283 void AliITSTrackerV1::KalmanFilterVert(AliITSTrackV1 *newTrack,
1284 TVector &cluster,Double_t sigma[2]
1285 /*, Double_t chi2pred*/){
1286 //Origin A. Badala' and G.S. Pappalardo:
1287 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1288 // Kalman filter with vertex constraint
1289 ///////////////////// Evaluation of the measurement vector m ////////
1291 Double_t rk,phik,zk;
1292 rk=cluster(0); phik=cluster(1); zk=cluster(2);
1294 Double_t cc=(*newTrack).GetC();
1295 Double_t zv=(*newTrack).GetZv();
1296 Double_t dv=(*newTrack).GetDv();
1298 Double_t tgl= (zk-zv)*cy/TMath::ASin(cy*rk);
1300 /////////////////////// Evaluation of the error matrix V //////////
1301 Int_t layer=newTrack->GetLayer();
1302 Double_t v00=sigma[0];
1303 Double_t v11=sigma[1];
1304 Double_t v31=sigma[1]/rk;
1305 Double_t sigmaDv=newTrack->GetsigmaDv();
1306 Double_t v22=sigmaDv*sigmaDv + newTrack->Getd2(layer-1);
1307 Double_t v32=newTrack->Getdtgl(layer-1);
1308 Double_t sigmaZv=newTrack->GetsigmaZv();
1309 Double_t v33=(sigma[1]+sigmaZv*sigmaZv)/(rk*rk)+newTrack->Gettgl2(layer-1);
1310 //////////////////////////////////////////////////////////////////
1311 Double_t cin00,cin10,cin11,cin20,cin21,cin22,
1312 cin30,cin31,cin32,cin33,cin40,cin41,cin42,cin43,cin44;
1313 newTrack->GetCElements(cin00,
1316 cin30,cin31,cin32,cin33,
1317 cin40,cin41,cin42,cin43,cin44); //get C matrix
1325 r[3][1]=cin31+sigma[1]/rk;
1326 r[2][2]=cin22+sigmaDv*sigmaDv+newTrack->Getd2(layer-1);
1327 r[3][2]=cin32+newTrack->Getdtgl(layer-1);
1328 r[3][3]=cin33+(sigma[1]+sigmaZv*sigmaZv)/(rk*rk)+
1329 newTrack->Gettgl2(layer-1);
1330 r[0][1]=r[1][0]; r[0][2]=r[2][0]; r[0][3]=r[3][0];
1331 r[1][2]=r[2][1]; r[1][3]=r[3][1]; r[2][3]=r[3][2];
1332 ///////////////////// Matrix R inversion //////////////////////////
1336 Int_t ll[kn],mm[kn];
1339 for(k=0; k<kn; k++) {
1343 for(j=k; j<kn ; j++) {
1344 for (i=j; i<kn; i++) {
1345 if(TMath::Abs(big) < TMath::Abs(r[i][j]) ) {
1355 for(i=0; i<kn; i++) {
1364 for(j=0; j<kn; j++) {
1373 cout << "Singular matrix\n";
1375 for(i=0; i<kn; i++) {
1376 if(i == k) { continue; }
1377 r[i][k]=r[i][k]/(-big);
1380 for(i=0; i<kn; i++) {
1382 for(j=0; j<kn; j++) {
1383 if(i == k || j == k) continue;
1384 r[i][j]=hold*r[k][j]+r[i][j];
1388 for(j=0; j<kn; j++) {
1389 if(j == k) continue;
1390 r[k][j]=r[k][j]/big;
1398 for(k=kn-1; k>=0; k--) {
1401 for (j=0; j<kn; j++) {
1409 for (i=0; i<kn; i++) {
1416 ////////////////////////////////////////////////////////////////////
1417 Double_t k00=cin00*r[0][0]+cin10*r[1][0]+cin20*r[2][0]+cin30*r[3][0];
1418 Double_t k01=cin00*r[1][0]+cin10*r[1][1]+cin20*r[2][1]+cin30*r[3][1];
1419 Double_t k02=cin00*r[2][0]+cin10*r[2][1]+cin20*r[2][2]+cin30*r[3][2];
1420 Double_t k03=cin00*r[3][0]+cin10*r[3][1]+cin20*r[3][2]+cin30*r[3][3];
1421 Double_t k10=cin10*r[0][0]+cin11*r[1][0]+cin21*r[2][0]+cin31*r[3][0];
1422 Double_t k11=cin10*r[1][0]+cin11*r[1][1]+cin21*r[2][1]+cin31*r[3][1];
1423 Double_t k12=cin10*r[2][0]+cin11*r[2][1]+cin21*r[2][2]+cin31*r[3][2];
1424 Double_t k13=cin10*r[3][0]+cin11*r[3][1]+cin21*r[3][2]+cin31*r[3][3];
1425 Double_t k20=cin20*r[0][0]+cin21*r[1][0]+cin22*r[2][0]+cin32*r[3][0];
1426 Double_t k21=cin20*r[1][0]+cin21*r[1][1]+cin22*r[2][1]+cin32*r[3][1];
1427 Double_t k22=cin20*r[2][0]+cin21*r[2][1]+cin22*r[2][2]+cin32*r[3][2];
1428 Double_t k23=cin20*r[3][0]+cin21*r[3][1]+cin22*r[3][2]+cin32*r[3][3];
1429 Double_t k30=cin30*r[0][0]+cin31*r[1][0]+cin32*r[2][0]+cin33*r[3][0];
1430 Double_t k31=cin30*r[1][0]+cin31*r[1][1]+cin32*r[2][1]+cin33*r[3][1];
1431 Double_t k32=cin30*r[2][0]+cin31*r[2][1]+cin32*r[2][2]+cin33*r[3][2];
1432 Double_t k33=cin30*r[3][0]+cin31*r[3][1]+cin32*r[3][2]+cin33*r[3][3];
1433 Double_t k40=cin40*r[0][0]+cin41*r[1][0]+cin42*r[2][0]+cin43*r[3][0];
1434 Double_t k41=cin40*r[1][0]+cin41*r[1][1]+cin42*r[2][1]+cin43*r[3][1];
1435 Double_t k42=cin40*r[2][0]+cin41*r[2][1]+cin42*r[2][2]+cin43*r[3][2];
1436 Double_t k43=cin40*r[3][0]+cin41*r[3][1]+cin42*r[3][2]+cin43*r[3][3];
1438 Double_t x0,x1,x2,x3,x4;
1439 newTrack->GetXElements(x0,x1,x2,x3,x4); // get the state vector
1440 Double_t savex0=x0, savex1=x1, savex2=x2, savex3=x3;
1441 x0+=k00*(m[0]-savex0)+k01*(m[1]-savex1)+k02*(m[2]-savex2)+
1443 x1+=k10*(m[0]-savex0)+k11*(m[1]-savex1)+k12*(m[2]-savex2)+
1445 x2+=k20*(m[0]-savex0)+k21*(m[1]-savex1)+k22*(m[2]-savex2)+
1447 x3+=k30*(m[0]-savex0)+k31*(m[1]-savex1)+k32*(m[2]-savex2)+
1449 x4+=k40*(m[0]-savex0)+k41*(m[1]-savex1)+k42*(m[2]-savex2)+
1451 Double_t c00,c10,c20,c30,c40,c11,c21,c31,c41,c22,c32,c42,c33,c43,c44;
1452 c00=cin00-k00*cin00-k01*cin10-k02*cin20-k03*cin30;
1453 c10=cin10-k00*cin10-k01*cin11-k02*cin21-k03*cin31;
1454 c20=cin20-k00*cin20-k01*cin21-k02*cin22-k03*cin32;
1455 c30=cin30-k00*cin30-k01*cin31-k02*cin32-k03*cin33;
1456 c40=cin40-k00*cin40-k01*cin41-k02*cin42-k03*cin43;
1457 c11=cin11-k10*cin10-k11*cin11-k12*cin21-k13*cin31;
1458 c21=cin21-k10*cin20-k11*cin21-k12*cin22-k13*cin32;
1459 c31=cin31-k10*cin30-k11*cin31-k12*cin32-k13*cin33;
1460 c41=cin41-k10*cin40-k11*cin41-k12*cin42-k13*cin43;
1461 c22=cin22-k20*cin20-k21*cin21-k22*cin22-k23*cin32;
1462 c32=cin32-k20*cin30-k21*cin31-k22*cin32-k23*cin33;
1463 c42=cin42-k20*cin40-k21*cin41-k22*cin42-k23*cin43;
1464 c33=cin33-k30*cin30-k31*cin31-k32*cin32-k33*cin33;
1465 c43=cin43-k30*cin40-k31*cin41-k32*cin42-k33*cin43;
1466 c44=cin44-k40*cin40-k41*cin41-k42*cin42-k43*cin43;
1468 newTrack->PutXElements(x0,x1,x2,x3,x4); // put the new state vector
1469 newTrack->PutCElements(c00,
1473 c40,c41,c42,c43,c44); // put in track the
1476 vmc[0][0]=v00-c00; vmc[1][0]=-c10; vmc[2][0]=-c20; vmc[3][0]=-c30;
1477 vmc[1][1]=v11-c11; vmc[2][1]=-c21; vmc[3][1]=v31-c31;
1478 vmc[2][2]=v22-c22; vmc[3][2]=v32-c32;
1480 vmc[0][1]=vmc[1][0]; vmc[0][2]=vmc[2][0]; vmc[0][3]=vmc[3][0];
1481 vmc[1][2]=vmc[2][1]; vmc[1][3]=vmc[3][1];
1482 vmc[2][3]=vmc[3][2];
1483 /////////////////////// vmc matrix inversion ///////////////////////
1485 for(k=0; k<kn; k++) {
1489 for(j=k; j<kn ; j++) {
1490 for (i=j; i<kn; i++) {
1491 if(TMath::Abs(big) < TMath::Abs(vmc[i][j]) ) {
1501 for(i=0; i<kn; i++) {
1503 vmc[k][i]=vmc[j][i];
1510 for(j=0; j<kn; j++) {
1512 vmc[j][k]=vmc[j][i];
1519 cout << "Singular matrix\n";
1521 for(i=0; i<kn; i++) {
1522 if(i == k) continue;
1523 vmc[i][k]=vmc[i][k]/(-big);
1526 for(i=0; i<kn; i++) {
1528 for(j=0; j<kn; j++) {
1529 if(i == k || j == k) continue;
1530 vmc[i][j]=hold*vmc[k][j]+vmc[i][j];
1534 for(j=0; j<kn; j++) {
1535 if(j == k) continue;
1536 vmc[k][j]=vmc[k][j]/big;
1544 for(k=kn-1; k>=0; k--) {
1547 for (j=0; j<kn; j++) {
1549 vmc[j][k]=-vmc[j][i];
1555 for (i=0; i<kn; i++) {
1557 vmc[k][i]=-vmc[j][i];
1562 ////////////////////////////////////////////////////////////////////
1563 Double_t chi2=(m[0]-x0)*( vmc[0][0]*(m[0]-x0) + 2.*vmc[1][0]*(m[1]-x1) +
1564 2.*vmc[2][0]*(m[2]-x2)+ 2.*vmc[3][0]*(m[3]-x3) )+
1565 (m[1]-x1)* ( vmc[1][1]*(m[1]-x1) + 2.*vmc[2][1]*(m[2]-x2)+
1566 2.*vmc[3][1]*(m[3]-x3) ) +
1567 (m[2]-x2)* ( vmc[2][2]*(m[2]-x2)+ 2.*vmc[3][2]*(m[3]-x3) ) +
1568 (m[3]-x3)*vmc[3][3]*(m[3]-x3);
1569 //cout<<" chi2 kalman = "<<chi2<<"\n"; getchar();
1570 newTrack->SetChi2(newTrack->GetChi2()+chi2);
1571 // newTrack->SetChi2(newTrack->GetChi2()+chi2pred);