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.19 2001/11/21 10:49:07 barbera
19 Bug correction suggested by Rene done
21 Revision 1.18 2001/11/20 15:46:17 barbera
22 Point coordinated are calculated in cylindrical reference frame once and for all at the beginning of tracking V1
24 Revision 1.10.2.1 2001/10/24 07:26:04 hristov
25 All the changes from the head are merged with the release
27 Revision 1.14 2001/10/24 07:19:57 hristov
28 Some pointer correctly initialised in one of the constructors
30 Revision 1.13 2001/10/21 19:17:12 hristov
31 Several pointers were set to zero in the default constructors to avoid memory management problems
33 Revision 1.12 2001/10/19 21:32:35 nilsen
34 Minor changes to remove compliation warning on gcc 2.92.2 compiler, and
35 cleanded up a little bit of code.
38 // The purpose of this class is to permorm the ITS tracking. The
39 // constructor has the task to inizialize some private members. The method
40 // DoTracking is written to be called by a macro. It gets the event number,
41 // the minimum and maximum order number of TPC tracks that are to be tracked
42 // trough the ITS, and the file where the recpoints are registered. The
43 // method Recursivetracking is a recursive function that performs the
44 // tracking trough the ITS The method Intersection found the layer, ladder
45 // and detector whre the intersection take place and caluclate the
46 // cohordinates of this intersection. It returns an integer that is 0 if the
47 // intersection has been found successfully. The two mwthods Kalmanfilter
48 // and kalmanfiltervert operate the kalmanfilter without and with the vertex
49 // imposition respectively. The authors thank Mariana Bondila to have help
50 // them to resolve some problems. July-2000
58 #include <TStopwatch.h>
60 #include "TParticle.h"
63 #include "AliITSsegmentationSSD.h"
64 #include "AliITSgeomSPD.h"
65 #include "AliITSgeomSDD.h"
66 #include "AliITSgeomSSD.h"
67 #include "AliITSgeom.h"
68 #include "AliITSRecPoint.h"
70 #include "AliKalmanTrack.h"
72 #include "AliITSTrackV1.h"
73 #include "AliITSIOTrack.h"
74 #include "AliITSRad.h"
75 #include "../TPC/AliTPCtracker.h"
76 #include "AliITSTrackerV1.h"
77 #include "AliITSVertex.h"
79 ClassImp(AliITSTrackerV1)
80 //______________________________________________________________________
81 AliITSTrackerV1::AliITSTrackerV1() {
94 for(ia=0; ia<6; ia++) {
112 //______________________________________________________________________
113 AliITSTrackerV1::AliITSTrackerV1(AliITS* IITTSS, Int_t evnumber, Bool_t flag) {
114 //Origin A. Badala' and G.S. Pappalardo:
115 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
116 // Class constructor. It does some initializations.
118 //PH Initialisation taken from the default constructor
133 Int_t imax = 200,jmax = 450;
134 frl = new AliITSRad(imax,jmax);
136 ////////// gets information on geometry /////////////////////////////
137 AliITSgeom *g1 = fITS->GetITSgeom();
142 for(ia=0; ia<6; ia++) {
143 fNlad[ia]=g1->GetNladders(ia+1);
144 fNdet[ia]=g1->GetNdetectors(ia+1);
145 //cout<<fNlad[i]<<" "<<fNdet[i]<<"\n";
148 //cout<<" mean radius = ";
150 for(ib=0; ib<6; ib++) {
151 g1->GetCenterThetaPhi(ib+1,ll,dd,det);
152 Double_t r1=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
153 g1->GetCenterThetaPhi(ib+1,ll,dd+1,det);
154 Double_t r2=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
155 fAvrad[ib]=(r1+r2)/2.;
156 //cout<<fAvrad[ib]<<" ";
158 //cout<<"\n"; getchar();
160 fDetx[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDx();
161 fDetz[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDz();
163 fDetx[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDx();
164 fDetz[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDz();
166 fDetx[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDx();
167 fDetz[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDz();
169 fDetx[3] = ((AliITSgeomSDD*)(g1->GetShape(4, ll, dd)))->GetDx();
170 fDetz[3] = ((AliITSgeomSDD*)(g1->GetShape(4, ll, dd)))->GetDz();
172 fDetx[4] = ((AliITSgeomSSD*)(g1->GetShape(5, ll, dd)))->GetDx();
173 fDetz[4] = ((AliITSgeomSSD*)(g1->GetShape(5, ll, dd)))->GetDz();
175 fDetx[5] = ((AliITSgeomSSD*)(g1->GetShape(6, ll, dd)))->GetDx();
176 fDetz[5] = ((AliITSgeomSSD*)(g1->GetShape(6, ll, dd)))->GetDz();
177 //cout<<" Detx Detz\n";
178 //for(Int_t la=0; la<6; la++) cout<<" "<<fDetx[la]<<" "<<
182 // allocate memory and define matrices fzmin, fzmax, fphimin and fphimax //
184 Double_t epszdrift=0.05;
186 fzmin = new Double_t*[6]; fzmax = new Double_t*[6];
187 Int_t im1, im2, im2max;
188 for(im1=0; im1<6; im1++) {
190 fzmin[im1] = new Double_t[im2max]; fzmax[im1] = new Double_t[im2max];
193 for(im1=0; im1<6; im1++) {
195 for(im2=0; im2<im2max; im2++) {
196 g1->GetCenterThetaPhi(im1+1,1,im2+1,det);
197 if(im2!=0) fzmin[im1][im2]=det(2)-fDetz[im1];
199 fzmin[im1][im2]=det(2)-(fDetz[im1])*epsz;
200 if(im2!=(im2max-1)) fzmax[im1][im2]=det(2)+fDetz[im1];
202 fzmax[im1][im2]=det(2)+fDetz[im1]*epsz;
203 if(im1==2 || im1==3) {
204 fzmin[im1][im2]-=epszdrift;
205 fzmax[im1][im2]+=epszdrift;
206 } // end if im1==2 || im1==3
210 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
211 for(im1=0;im1<6;im1++) {
213 fphimin[im1] = new Double_t[im2max];
214 fphimax[im1] = new Double_t[im2max];
217 fphidet = new Double_t*[6];
218 for(im1=0; im1<6; im1++) {
220 fphidet[im1] = new Double_t[im2max];
223 //Float_t global[3],local[3];
224 Double_t global[3],local[3];
225 Double_t pigre=TMath::Pi();
226 Double_t xmin,ymin,xmax,ymax;
228 for(im1=0; im1<6; im1++) {
230 for(im2=0; im2<im2max; im2++) {
232 g1->GetCenterThetaPhi(im1+1,im2+1,idet,det);
233 fphidet[im1][im2] = TMath::ATan2(Double_t(det(1)),
235 if(fphidet[im1][im2]<0.) fphidet[im1][im2]+=2.*pigre;
236 local[1]=local[2]=0.;
237 local[0]= -(fDetx[im1]);
238 if(im1==0) local[0]= (fDetx[im1]); //to take into account
239 // different reference system
240 g1->LtoG(im1+1,im2+1,idet,local,global);
241 xmax=global[0]; ymax=global[1];
242 local[0]= (fDetx[im1]);
243 if(im1==0) local[0]= -(fDetx[im1]);//take into account different
245 g1->LtoG(im1+1,im2+1,idet,local,global);
246 xmin=global[0]; ymin=global[1];
247 fphimin[im1][im2]= TMath::ATan2(ymin,xmin);
248 if(fphimin[im1][im2]<0.) fphimin[im1][im2]+=2.*pigre;
249 fphimax[im1][im2]= TMath::ATan2(ymax,xmax);
250 if(fphimax[im1][im2]<0.) fphimax[im1][im2]+=2.*pigre;
253 //////////////////////////////////////////////////////////////////////////////////////////////////////////
254 /////////////// allocate memory and define vector fNRecPoints and matrices fRecCylR, fRecCylPhi, fRecCylZ /////////////
255 gAlice->GetEvent(evnumber);
256 Int_t NumOfModules = g1->GetIndexMax();
257 //fRecCylR = new Float_t *[NumOfModules];
258 fRecCylR = new Double_t *[NumOfModules];
259 //fRecCylPhi = new Float_t *[NumOfModules];
260 fRecCylPhi = new Double_t *[NumOfModules];
261 //fRecCylZ = new Float_t *[NumOfModules];
262 fRecCylZ = new Double_t *[NumOfModules];
263 AliITSRecPoint *recp;
264 fNRecPoints = new Int_t[NumOfModules];
266 for(Int_t module=0; module<NumOfModules; module++) {
267 fITS->ResetRecPoints();
268 gAlice->TreeR()->GetEvent(module);
269 frecPoints=fITS->RecPoints();
270 Int_t nRecPoints=fNRecPoints[module]=frecPoints->GetEntries();
272 fRecCylR[module] = new Float_t[nRecPoints];
273 fRecCylPhi[module] = new Float_t[nRecPoints];
274 fRecCylZ[module] = new Float_t[nRecPoints];
276 fRecCylR[module] = new Double_t[nRecPoints];
277 fRecCylPhi[module] = new Double_t[nRecPoints];
278 fRecCylZ[module] = new Double_t[nRecPoints];
280 for(ind=0; ind<fNRecPoints[module]; ind++) {
281 recp=(AliITSRecPoint*)frecPoints->UncheckedAt(ind);
282 // Float_t global[3], local[3];
283 Double_t global[3], local[3];
284 local[0]=recp->GetX();
286 local[2]= recp->GetZ();
287 g1->LtoG(module,local,global);
289 Float_t r = TMath::Sqrt(global[0]*global[0]+global[1]*global[1]); // r hit
290 Float_t phi = TMath::ATan2(global[1],global[0]); if(phi<0.) phi+=2.*TMath::Pi(); // phi hit
291 Float_t z = global[2]; // z hit
294 Double_t r = TMath::Sqrt(global[0]*global[0]+global[1]*global[1]); // r hit
295 Double_t phi = TMath::ATan2(global[1],global[0]); if(phi<0.) phi+=2.*TMath::Pi(); // phi hit
296 Double_t z = global[2]; // z hit
298 fRecCylR[module][ind]=r;
299 fRecCylPhi[module][ind]=phi;
300 fRecCylZ[module][ind]=z;
305 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
308 ////////// gets magnetic field factor //////////////////////////////
310 AliMagF * fieldPointer = gAlice->Field();
311 fFieldFactor = (Double_t)fieldPointer->Factor();
312 //cout<< " field factor = "<<fFieldFactor<<"\n"; getchar();
314 //______________________________________________________________________
315 AliITSTrackerV1::AliITSTrackerV1(const AliITSTrackerV1 &cobj) {
316 // Origin A. Badala' and G.S. Pappalardo:
317 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
321 *fresult = *cobj.fresult;
322 fPtref = cobj.fPtref;
323 fChi2max = cobj.fChi2max;
324 **fvettid = **cobj.fvettid;
325 fflagvert = cobj.fflagvert;
326 Int_t imax=200,jmax=450;
327 frl = new AliITSRad(imax,jmax);
329 fFieldFactor = cobj.fFieldFactor;
330 Int_t i,im1,im2,im2max;
332 fNlad[i] = cobj.fNlad[i];
333 fNdet[i] = cobj.fNdet[i];
334 fAvrad[i] = cobj.fAvrad[i];
335 fDetx[i] = cobj.fDetx[i];
336 fDetz[i] = cobj.fDetz[i];
338 fzmin = new Double_t*[6]; fzmax = new Double_t*[6];
339 for(im1=0; im1<6; im1++) {
341 fzmin[im1] = new Double_t[im2max];
342 fzmax[im1] = new Double_t[im2max];
344 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
345 for(im1=0;im1<6;im1++) {
347 fphimin[im1] = new Double_t[im2max];
348 fphimax[im1] = new Double_t[im2max];
351 fphidet = new Double_t*[6];
352 for(im1=0; im1<6; im1++) {
354 fphidet[im1] = new Double_t[im2max];
356 for(im1=0; im1<6; im1++) {
358 for(im2=0; im2<im2max; im2++) {
359 fzmin[im1][im2]=cobj.fzmin[im1][im2];
360 fzmax[im1][im2]=cobj.fzmax[im1][im2];
363 for(im1=0; im1<6; im1++) {
365 for(im2=0; im2<im2max; im2++) {
366 fphimin[im1][im2]=cobj.fphimin[im1][im2];
367 fphimax[im1][im2]=cobj.fphimax[im1][im2];
368 fphidet[im1][im2]=cobj.fphidet[im1][im2];
373 AliITSgeom *g1 = fITS->GetITSgeom();
374 Int_t NumOfModules = g1->GetIndexMax();
376 fRecCylR = new Float_t *[NumOfModules];
377 fRecCylPhi = new Float_t *[NumOfModules];
378 fRecCylZ = new Float_t *[NumOfModules];
380 fRecCylR = new Double_t *[NumOfModules];
381 fRecCylPhi = new Double_t *[NumOfModules];
382 fRecCylZ = new Double_t *[NumOfModules];
383 fNRecPoints = new Int_t[NumOfModules];
384 for(Int_t module=0; module<NumOfModules; module++) {
385 Int_t nRecPoints=fNRecPoints[module]=cobj.fNRecPoints[module];
387 fRecCylR[module] = new Float_t[nRecPoints];
388 fRecCylPhi[module] = new Float_t[nRecPoints];
389 fRecCylZ[module] = new Float_t[nRecPoints];
391 fRecCylR[module] = new Double_t[nRecPoints];
392 fRecCylPhi[module] = new Double_t[nRecPoints];
393 fRecCylZ[module] = new Double_t[nRecPoints];
395 for(ind=0; ind<nRecPoints; ind++) {
396 fRecCylR[module][ind]=cobj.fRecCylR[module][ind];
397 fRecCylPhi[module][ind]=cobj.fRecCylPhi[module][ind];
398 fRecCylZ[module][ind]=cobj.fRecCylZ[module][ind];
403 void AliITSTrackerV1::DelMatrix(Int_t NumOfModules) {
404 for(Int_t mod=0; mod<NumOfModules; mod++) {
405 delete fRecCylR[mod];
406 delete fRecCylPhi[mod];
407 delete fRecCylZ[mod];
413 //______________________________________________________________________
414 AliITSTrackerV1::~AliITSTrackerV1(){
415 // Origin A. Badala' and G.S. Pappalardo:
416 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
420 for(Int_t i=0; i<6; i++) {
435 //______________________________________________________________________
436 AliITSTrackerV1 &AliITSTrackerV1::operator=(AliITSTrackerV1 obj) {
437 // Origin A. Badala' and G.S. Pappalardo:
438 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
439 // assignement operator
442 *fresult = *obj.fresult;
444 fChi2max = obj.fChi2max;
445 **fvettid = **obj.fvettid;
446 fflagvert = obj.fflagvert;
447 Int_t imax=200,jmax=450;
448 frl = new AliITSRad(imax,jmax);
450 fFieldFactor = obj.fFieldFactor;
453 fNlad[i] = obj.fNlad[i];
454 fNdet[i] = obj.fNdet[i];
455 fAvrad[i] = obj.fAvrad[i];
456 fDetx[i] = obj.fDetx[i];
457 fDetz[i] = obj.fDetz[i];
459 fzmin = new Double_t*[6];
460 fzmax = new Double_t*[6];
461 Int_t im1, im2, im2max;
462 for(im1=0; im1<6; im1++) {
464 fzmin[im1] = new Double_t[im2max]; fzmax[im1] = new Double_t[im2max];
466 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
467 for(im1=0;im1<6;im1++) {
469 fphimin[im1] = new Double_t[im2max];
470 fphimax[im1] = new Double_t[im2max];
473 fphidet = new Double_t*[6];
474 for(im1=0; im1<6; im1++) {
476 fphidet[im1] = new Double_t[im2max];
478 for(im1=0; im1<6; im1++) {
480 for(im2=0; im2<im2max; im2++) {
481 fzmin[im1][im2]=obj.fzmin[im1][im2];
482 fzmax[im1][im2]=obj.fzmax[im1][im2];
485 for(im1=0; im1<6; im1++) {
487 for(im2=0; im2<im2max; im2++) {
488 fphimin[im1][im2]=obj.fphimin[im1][im2];
489 fphimax[im1][im2]=obj.fphimax[im1][im2];
490 fphidet[im1][im2]=obj.fphidet[im1][im2];
494 AliITSgeom *g1 = fITS->GetITSgeom();
495 Int_t NumOfModules = g1->GetIndexMax();
497 fRecCylR = new Float_t *[NumOfModules];
498 fRecCylPhi = new Float_t *[NumOfModules];
499 fRecCylZ = new Float_t *[NumOfModules];
501 fRecCylR = new Double_t *[NumOfModules];
502 fRecCylPhi = new Double_t *[NumOfModules];
503 fRecCylZ = new Double_t *[NumOfModules];
504 fNRecPoints = new Int_t[NumOfModules];
505 for(Int_t module=0; module<NumOfModules; module++) {
506 Int_t nRecPoints=fNRecPoints[module]=obj.fNRecPoints[module];
508 fRecCylR[module] = new Float_t[nRecPoints];
509 fRecCylPhi[module] = new Float_t[nRecPoints];
510 fRecCylZ[module] = new Float_t[nRecPoints];
512 fRecCylR[module] = new Double_t[nRecPoints];
513 fRecCylPhi[module] = new Double_t[nRecPoints];
514 fRecCylZ[module] = new Double_t[nRecPoints];
516 for(ind=0; ind<nRecPoints; ind++) {
517 fRecCylR[module][ind]=obj.fRecCylR[module][ind];
518 fRecCylPhi[module][ind]=obj.fRecCylPhi[module][ind];
519 fRecCylZ[module][ind]=obj.fRecCylZ[module][ind];
526 //______________________________________________________________________
527 void AliITSTrackerV1::DoTracking(Int_t evNumber,Int_t minTr,Int_t maxTr,
528 TFile *file, Bool_t realmass) {
529 // Origin A. Badala' and G.S. Pappalardo:
530 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
531 // The method needs the event number, the minimum and maximum order
532 // number of TPC tracks that
533 // are to be tracked trough the ITS, and the file where the recpoints
535 // The method can be called by a macro. It preforms the tracking for
536 // all good TPC tracks
538 printf("begin DoTracking - file %p\n",file);
540 gAlice->GetEvent(evNumber); //modificato per gestire hbt
542 AliKalmanTrack *kkprov;
543 kkprov->SetConvConst(100/0.299792458/0.2/fFieldFactor);
545 TFile *cf=TFile::Open("AliTPCclusters.root");
546 AliTPCParam *digp= (AliTPCParam*)cf->Get("75x40_100x60");
547 if (!digp) { cerr<<"TPC parameters have not been found !\n"; getchar();}
550 AliTPCtracker *tracker = new AliTPCtracker(digp,evNumber);
553 tracker->LoadInnerSectors();
554 tracker->LoadOuterSectors();
557 TFile *tf=TFile::Open("AliTPCtracksSorted.root");
559 cerr<<"Can't open AliTPCtracksSorted.root !\n";
562 TObjArray tracks(200000);
564 sprintf(tname,"TreeT_TPC_%d",evNumber);
566 TTree *tracktree=(TTree*)tf->Get(tname);
567 if (!tracktree) {cerr<<"Can't get a tree with TPC tracks !\n";}
568 TBranch *tbranch=tracktree->GetBranch("tracks");
569 Int_t nentr=(Int_t)tracktree->GetEntries();
572 AliTPCtrack *ioTrackTPC=0;
573 for (kk=0; kk<nentr; kk++) {
574 ioTrackTPC=new AliTPCtrack;
575 tbranch->SetAddress(&ioTrackTPC);
576 tracktree->GetEvent(kk);
577 tracker->CookLabel(ioTrackTPC,0.1);
578 tracks.AddLast(ioTrackTPC);
583 Int_t nt = tracks.GetEntriesFast();
584 cerr<<"Number of found tracks "<<nt<<endl;
587 TTree *tr=gAlice->TreeR();
588 Int_t nent=(Int_t)tr->GetEntries();
589 frecPoints = fITS->RecPoints();
593 Int_t *np = new Int_t[nent];
594 fvettid = new Int_t* [nent];
597 for (mod=0; mod<nent; mod++) {
599 fITS->ResetRecPoints();
600 gAlice->TreeR()->GetEvent(mod);
601 numbpoints = frecPoints->GetEntries();
602 totalpoints+=numbpoints;
603 np[mod] = numbpoints;
604 //cout<<" mod = "<<mod<<" numbpoints = "<<numbpoints<<"\n";getchar();
605 fvettid[mod] = new Int_t[numbpoints];
607 for (ii=0;ii<numbpoints; ii++) *(fvettid[mod]+ii)=0;
610 AliTPCtrack *track=0;
612 if(minTr < 0) {minTr = 0; maxTr = nt-1;}
616 TTree tracktree1("TreeT","Tree with ITS tracks");
617 AliITSIOTrack *ioTrack=0;
618 tracktree1.Branch("ITStracks","AliITSIOTrack",&ioTrack,32000,0);
620 TDatabasePDG * db = new TDatabasePDG;
623 for (j=minTr; j<=maxTr; j++) {
624 track=(AliTPCtrack*)tracks.UncheckedAt(j);
625 if (!track) continue;
627 /// mass definition ////////////////////////
628 Double_t mass=0.13956995;
629 Int_t pcode=211; // a pion by default
631 Int_t TPClabel=TMath::Abs( track->GetLabel() );
632 TParticle *p = (TParticle*)gAlice->Particle(TPClabel);
633 pcode=p->GetPdgCode();
634 // Int_t mothercode=p->GetFirstMother();
635 //if(mothercode>0 ) numofsecondaries++; else numofprimaries++;
637 //if(!pcode) pcode=211;
638 if(TMath::Abs(pcode)<20443) mass=db->GetParticle(pcode)->Mass();
641 ///////////////////////////////////////////////
643 ////// propagation to the end of TPC //////////////
645 track->PropagateTo(xk, 28.94, 1.204e-3,mass); //Ne
647 track->PropagateTo(xk, 44.77, 1.71,mass); //Tedlar
649 track->PropagateTo(xk, 44.86, 1.45,mass); //kevlar
651 track->PropagateTo(xk, 41.28, 0.029,mass); //Nomex
653 track->PropagateTo(xk,36.2,1.98e-3,mass); //C02
655 track->PropagateTo(xk, 24.01, 2.7,mass); //Al
657 track->PropagateTo(xk, 44.77, 1.71,mass); //Tedlar
659 track->PropagateTo(xk, 44.86, 1.45,mass); //kevlar
661 track->PropagateTo(xk, 41.28, 0.029,mass); //Nomex
662 ////////////////////////////////////////////////////////////////////
664 // new propagation to the end of TPC
666 // track->PropagateTo(xk,0.,0.); //Ne if it's still there //attenzione funziona solo se modifica in TPC
667 // Double_t xk=77.415;
668 track->PropagateTo(xk, 28.94, 1.204e-3);
670 track->PropagateTo(xk, 44.77,1.71); //Tedlar
672 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
674 track->PropagateTo(xk, 41.28, 0.029);//Nomex
676 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
678 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
681 // track->PropagateTo(xk,0.,0.); //C02
682 track->PropagateTo(xk,36.2,1.98e-3); //C02 //attenzione funziona solo se modifica in TPC
685 track->PropagateTo(xk, 24.01, 2.7); //Al
687 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
689 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
691 track->PropagateTo(xk, 41.28, 0.029); //Nomex
693 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
695 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
697 track->PropagateTo(xk, 24.01, 2.7); //Al
698 ////////////////////////////////////////////////////////////////////////////////////////////////////////
699 AliITSTrackV1 trackITS(*track);
700 trackITS.PutMass(mass); //new to add mass to track
701 if(fresult){ delete fresult; fresult=0;}
702 fresult = new AliITSTrackV1(trackITS);
704 AliITSTrackV1 primaryTrack(trackITS);
705 vgeant=(*fresult).GetVertex();
707 // Definition of dv and zv for vertex constraint
708 Double_t sigmaDv=0.0050; Double_t sigmaZv=0.010;
709 //Double_t sigmaDv=0.0015; Double_t sigmaZv=0.0015;
710 Double_t uniform= gRandom->Uniform();
712 if(uniform<=0.5) signdv=-1.;
716 Double_t vr=TMath::Sqrt(vgeant(0)*vgeant(0)+ vgeant(1)*vgeant(1));
717 Double_t dv=gRandom->Gaus(signdv*vr,(Float_t)sigmaDv);
718 Double_t zv=gRandom->Gaus(vgeant(2),(Float_t)sigmaZv);
719 //cout<<" Dv e Zv = "<<dv<<" "<<zv<<"\n";
722 trackITS.SetsigmaDv(sigmaDv);
723 trackITS.SetsigmaZv(sigmaZv);
724 (*fresult).SetDv(dv);
725 (*fresult).SetZv(zv);
726 (*fresult).SetsigmaDv(sigmaDv);
727 (*fresult).SetsigmaZv(sigmaZv);
728 primaryTrack.SetDv(dv);
729 primaryTrack.SetZv(zv);
730 primaryTrack.SetsigmaDv(sigmaDv);
731 primaryTrack.SetsigmaZv(sigmaZv);
732 primaryTrack.PrimaryTrack(frl);
733 TVector d2=primaryTrack.Getd2();
734 TVector tgl2=primaryTrack.Gettgl2();
735 TVector dtgl=primaryTrack.Getdtgl();
736 trackITS.Setd2(d2); trackITS.Settgl2(tgl2);
737 trackITS.Setdtgl(dtgl);
738 (*fresult).Setd2(d2); (*fresult).Settgl2(tgl2);
739 (*fresult).Setdtgl(dtgl);
741 trackITS.SetVertex(vertex); trackITS.SetErrorVertex(ervertex);
742 (*result).SetVertex(vertex); (*result).SetErrorVertex(ervertex);
744 TList *list= new TList();
746 list->AddLast(&trackITS);
748 fPtref=TMath::Abs( (trackITS).GetPt() );
749 if(fPtref>1.0) fChi2max=40.;
750 if(fPtref<=1.0) fChi2max=20.;
751 if(fPtref<0.4 ) fChi2max=100.;
752 if(fPtref<0.2 ) fChi2max=40.;
753 // if(fPtref<0.4 ) fChi2max=30.;
754 // if(fPtref<0.2 ) fChi2max=20.;
755 //if(fPtref<0.2 ) fChi2max=10.;
756 //if(fPtref<0.1 ) fChi2max=5.;
757 //cout << "\n Pt = " << fPtref <<"\n"; //stampa
758 RecursiveTracking(list);
763 TVector vecTotLabRef(18);
765 for(lay=5; lay>=0; lay--) {
766 TVector vecLabRef(3);
767 vecLabRef=(*fresult).GetLabTrack(lay);
768 Float_t clustZ=(*fresult).GetZclusterTrack( lay);
770 Int_t lpp=(Int_t)vecLabRef(k);
772 TParticle *p=(TParticle*) gAlice->Particle(lpp);
773 Int_t pcode=p->GetPdgCode();
774 if(pcode==11) vecLabRef(k)=p->GetFirstMother();
776 itot++; vecTotLabRef(itot)=vecLabRef(k);
777 if(vecLabRef(k)==0. && clustZ == -1.) vecTotLabRef(itot) =-3.;
782 (*fresult).Search(vecTotLabRef, labref, freq);
784 //if(freq < 6) labref=-labref; // cinque - sei
785 if(freq < 5) labref=-labref; // cinque - sei
786 (*fresult).SetLabel(labref);
788 // cout<<" progressive track number = "<<j<<"\r";
790 Int_t numOfCluster=(*fresult).GetNumClust();
791 //cout<<" progressive track number = "<<j<<"\n"; // stampa
792 Long_t labITS=(*fresult).GetLabel();
793 //cout << " ITS track label = " << labITS << "\n"; // stampa
794 Int_t lab=track->GetLabel();
795 //cout << " TPC track label = " << lab <<"\n"; // stampa
796 //propagation to vertex
799 if((*fresult).DoNotCross(rbeam)) continue; //no intersection with beampipe
800 (*fresult).Propagation(rbeam);
801 Double_t c00,c10,c11,c20,c21,c22,c30,c31,c32,c33,c40,c41,c42,c43,c44;
802 (*fresult).GetCElements(c00,
806 c40,c41,c42,c43,c44);
808 Double_t pt=TMath::Abs((*fresult).GetPt());
809 Double_t dr=(*fresult).GetD();
810 Double_t z=(*fresult).GetZ();
811 Double_t tgl=(*fresult).GetTgl();
812 Double_t c=(*fresult).GetC();
814 Double_t dz=z-(tgl/cy)*TMath::ASin((*fresult).Arga(rbeam));
816 // cout<<" dr e dz alla fine = "<<dr<<" "<<dz<<"\n"; getchar();
817 Double_t phi=(*fresult).Getphi();
818 Double_t phivertex = phi - TMath::ASin((*fresult).ArgA(rbeam));
819 Double_t duepi=2.*TMath::Pi();
820 if(phivertex>duepi) phivertex-=duepi;
821 if(phivertex<0.) phivertex+=duepi;
822 /////////////////////////////////////////////////////////////
823 Int_t idmodule,idpoint;
824 if(numOfCluster >=5) { // cinque - sei
825 //if(numOfCluster ==6) { // cinque - sei
826 AliITSIOTrack outTrack;
828 ioTrack->SetStatePhi(phi);
829 ioTrack->SetStateZ(z);
830 ioTrack->SetStateD(dr);
831 ioTrack->SetStateTgl(tgl);
832 ioTrack->SetStateC(c);
833 Double_t radius=(*fresult).Getrtrack();
834 ioTrack->SetRadius(radius);
836 if(c>0.) charge=-1; else charge=1;
837 ioTrack->SetCharge(charge);
838 ioTrack->SetCovMatrix(c00,
842 c40,c41,c42,c43,c44);
843 Double_t px=pt*TMath::Cos(phivertex);
844 Double_t py=pt*TMath::Sin(phivertex);
846 Double_t xtrack=dr*TMath::Sin(phivertex);
847 Double_t ytrack=dr*TMath::Cos(phivertex);
848 Double_t ztrack=dz+vgeant(2);
852 ioTrack->SetX(xtrack);
853 ioTrack->SetY(ytrack);
854 ioTrack->SetZ(ztrack);
855 ioTrack->SetLabel(labITS);
856 ioTrack->SetTPCLabel(lab);
859 for(il=0;il<6; il++){
860 ioTrack->SetIdPoint(il,(*fresult).GetIdPoint(il));
861 ioTrack->SetIdModule(il,(*fresult).GetIdModule(il));
864 for (il=0;il<6;il++) {
865 idpoint=(*fresult).GetIdPoint(il);
866 idmodule=(*fresult).GetIdModule(il);
867 if(idmodule>0.) *(fvettid[idmodule]+idpoint)=1;
869 ioTrack->SetIdPoint(il,idpoint);
870 ioTrack->SetIdModule(il,idmodule);
872 } // end if on numOfCluster
873 //gObjectTable->Print(); // stampa memoria
874 } // end for (int j=minTr; j<=maxTr; j++)
876 static Bool_t first=kTRUE;
879 tfile=new TFile("itstracks.root","RECREATE");
880 //cout<<"I have opened itstracks.root file "<<endl;
886 sprintf(hname,"TreeT%d",evNumber);
887 tracktree1.Write(hname);
889 TTree *fAli=gAlice->TreeK();
891 if (fAli) fileAli =fAli->GetCurrentFile();
893 ////////////////////////////////////////////////////////////////////
895 printf("delete vectors\n");
897 if(fvettid) delete [] fvettid;
898 if(fresult) {delete fresult; fresult=0;}
900 //______________________________________________________________________
901 void AliITSTrackerV1::RecursiveTracking(TList *trackITSlist) {
902 // This function perform the recursive tracking in ITS detectors
903 // reference is a pointer to the final best track
904 // Origin A. Badala' and G.S. Pappalardo:
905 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
906 // The authors thank Mariana Bondila to have help them to resolve some
907 // problems. July-2000
909 //Rlayer[0]=4.; Rlayer[1]=7.; Rlayer[2]=14.9;
910 // Rlayer[3]=23.8; Rlayer[4]=39.1; Rlayer[5]=43.6; //vecchio
912 //////////////////////
913 Float_t sigmaphil[6], sigmazl[6];
914 sigmaphil[0]=1.44e-6/(fAvrad[0]*fAvrad[0]);
915 sigmaphil[1]=1.44e-6/(fAvrad[1]*fAvrad[1]);
916 sigmaphil[2]=1.444e-5/(fAvrad[2]*fAvrad[2]);
917 sigmaphil[3]=1.444e-5/(fAvrad[3]*fAvrad[3]);
918 sigmaphil[4]=4e-6/(fAvrad[4]*fAvrad[4]);
919 sigmaphil[5]=4e-6/(fAvrad[5]*fAvrad[5]);
926 ///////////////////////////////////////////////////////////
928 AliITSgeom *g1 = fITS->GetITSgeom();
929 AliITSRecPoint *recp;
930 for(index =0; index<trackITSlist->GetSize(); index++) {
931 AliITSTrackV1 *trackITS = (AliITSTrackV1 *) trackITSlist->At(index);
932 if((*trackITS).GetLayer()==7) fresult->SetChi2(10.223e140);
933 // cout <<" Layer inizio = "<<(*trackITS).GetLayer()<<"\n";
934 // cout<<"fvtrack =" <<"\n";
935 // cout << (*trackITS)(0) << " "<<(*trackITS)(1)<<" "
936 // <<(*trackITS)(2)<<" "<<(*trackITS)(3)<<" "
937 // <<(*trackITS)(4)<<"\n";
938 // cout<< " rtrack = "<<(*trackITS).Getrtrack()<<"\n";
939 // cout<< " Pt = "<<(*trackITS).GetPt()<<"\n";
941 Double_t chi2Now, chi2Ref;
942 Float_t numClustRef = fresult->GetNumClust();
943 if((*trackITS).GetLayer()==1 ) {
944 chi2Now = trackITS->GetChi2();
945 Float_t numClustNow = trackITS->GetNumClust();
946 if(trackITS->GetNumClust())
947 chi2Now /= (Double_t)trackITS->GetNumClust();
948 chi2Ref = fresult->GetChi2();
949 if(fresult->GetNumClust())
950 chi2Ref /= (Double_t)fresult->GetNumClust();
951 //cout<<" chi2Now and chi2Ref = "<<chi2Now<<" "<<chi2Ref<<"\n";
952 if( numClustNow > numClustRef ) {*fresult = *trackITS;}
953 if((numClustNow == numClustRef )&&
954 (chi2Now < chi2Ref)) {
955 *fresult = *trackITS;
960 if(trackITS->Getfnoclust()>=2) continue;
961 Float_t numClustNow = trackITS->GetNumClust();
963 chi2Now = trackITS->GetChi2();
965 if(numClustNow<numClustRef && chi2Now>fresult->GetChi2()) continue;
966 //cout<<" chi2Now = "<<chi2Now<<"\n";
968 chi2Now/=numClustNow;
969 if(fPtref > 1.0 && chi2Now > 30.) continue;
970 if((fPtref >= 0.6 && fPtref<=1.0) && chi2Now > 40.) continue;
971 // if((fPtref <= 0.6 && fPtref>0.2)&& chi2Now > 40.) continue;
972 // if(fPtref <= 0.2 && chi2Now > 8.) continue;
973 if((fPtref <= 0.6 && fPtref>0.2)&& chi2Now > 30.) continue;
974 if(fPtref <= 0.2 && chi2Now > 7.) continue;
975 /////////////////////////////
978 Int_t layerInit = (*trackITS).GetLayer();
979 Int_t layernew = layerInit - 2;// -1 for new layer, -1 for matrix index
981 Int_t ladp, ladm, detp,detm,ladinters,detinters;
982 Int_t layerfin=layerInit-1;
983 // cout<<"Prima di intersection \n";
984 Int_t outinters=Intersection(*trackITS,layerfin,ladinters,detinters);
985 // cout<<" outinters = "<<outinters<<"\n";
986 // cout<<" Layer ladder detector intersection ="
987 // <<layerfin<<" "<<ladinters<<" "<<detinters<<"\n";
988 // cout << " phiinters zinters = "<<(*trackITS)(0)
989 // << " "<<(*trackITS)(1)<<"\n"; getchar();
990 if(outinters==-1) continue;
993 TVector toucLad(9), toucDet(9);
994 Int_t lycur=layerfin;
997 if(ladm <= 0) ladm=fNlad[layerfin-1];
998 if(ladp > fNlad[layerfin-1]) ladp=1;
1003 toucLad(0)=ladinters; toucLad(1)=ladm; toucLad(2)=ladp;
1004 toucLad(3)=ladinters; toucLad(4)=ladm; toucLad(5)=ladp;
1005 toucLad(6)=ladinters; toucLad(7)=ladm; toucLad(8)=ladp;
1006 toucDet(0)=detinters; toucDet(1)=detinters; toucDet(2)=detinters;
1007 if(detm > 0 && detp <= fNdet[layerfin-1]) {
1009 toucDet(3)=detm; toucDet(4)=detm; toucDet(5)=detm;
1010 toucDet(6)=detp; toucDet(7)=detp; toucDet(8)=detp;
1012 if(detm > 0 && detp > fNdet[layerfin-1]) {
1014 toucDet(3)=detm; toucDet(4)=detm; toucDet(5)=detm;
1016 if(detm <= 0 && detp <= fNdet[layerfin-1]) {
1018 toucDet(3)=detp; toucDet(4)=detp; toucDet(5)=detp;
1021 Float_t epsphi=5.0, epsz=5.0;
1022 if(fPtref<0.2) {epsphi=3.; epsz=3.;}
1023 // new definition of idetot e toucLad e toucDet to be
1024 // transformed in a method
1025 // these values could be modified
1026 Float_t pigre=TMath::Pi();
1027 Float_t rangephi=5., rangez=5.;
1028 if(layerfin==1 || layerfin ==2){
1029 rangephi=40.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1030 (*trackITS).GetSigmaphi());
1031 rangez = 40.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1032 (*trackITS).GetSigmaZ());
1034 if(layerfin==3 || layerfin ==4){
1035 //rangephi=30.*fepsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1036 // (*trackITS).GetSigmaphi());
1037 //rangez = 40.*fepsz*TMath::Sqrt(sigmazl[layerfin-1]+
1038 // (*trackITS).GetSigmaZ());
1039 rangephi=40.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1040 (*trackITS).GetSigmaphi());
1041 rangez = 50.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1042 (*trackITS).GetSigmaZ());
1044 if(layerfin==5 || layerfin ==6){
1045 rangephi=20.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1046 (*trackITS).GetSigmaphi());
1047 rangez =5.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1048 (*trackITS).GetSigmaZ());
1050 Float_t phinters, zinters;
1051 phinters=(*trackITS).Getphi();
1052 zinters=(*trackITS).GetZ();
1053 Float_t distz = 0.0;
1054 Float_t phicm, phicp, distphim, distphip;
1056 if(phinters>fphimax[layerfin-1][ladm-1]) phicm=phinters-2*pigre; //corretto il 20-11-2001
1057 distphim=TMath::Abs(phicm-fphimax[layerfin-1][ladm-1]); //corretto il 20-11-2001
1059 //cout<<" fNlad[layerfin-1] e ladp = "<<fNlad[layerfin-1]<<" "<<ladp<<endl;
1060 if(phinters>fphimin[layerfin-1][ladp-1]) phicp=phinters-2.*pigre; //corretto il 20-11-2001
1061 distphip=TMath::Abs(phicp-fphimin[layerfin-1][ladp-1]); //corretto il 20-11-2001
1065 toucLad(0)=ladinters; toucDet(0)=detinters;
1066 if(detm>0) distz=TMath::Abs(zinters-fzmax[layerfin-1][detm-1]);
1067 if(detm>0 && rangez>=distz){
1069 idetot++; toucLad(idetot-1)=ladinters; toucDet(idetot-1)=detm;
1070 if(rangephi>=distphim){
1072 toucLad(idetot-1)=ladm;
1073 toucDet(idetot-1)=detinters;
1075 toucLad(idetot-1)=ladm;
1076 toucDet(idetot-1)=detm;
1078 if(rangephi>=distphip){
1080 toucLad(idetot-1)=ladp;
1081 toucDet(idetot-1)=detinters;
1083 toucLad(idetot-1)=ladp;
1084 toucDet(idetot-1)=detm;
1087 if(detp<=fNdet[layerfin-1])
1088 distz=TMath::Abs(zinters-fzmin[layerfin-1][detp-1]);
1089 if(detp<=fNdet[layerfin-1] && rangez>=distz){
1091 idetot++; toucLad(idetot-1)=ladinters; toucDet(idetot-1)=detp;
1092 if(rangephi>=distphim){
1093 idetot++; toucLad(idetot-1)=ladm; toucDet(idetot-1)=detp;
1096 toucLad(idetot-1)=ladm;
1097 toucDet(idetot-1)=detinters;
1100 if(rangephi>=distphip){
1102 toucLad(idetot-1)=ladp;
1103 toucDet(idetot-1)=detp;
1106 toucLad(idetot-1)=ladp;
1107 toucDet(idetot-1)=detinters;
1110 } //end detm<fNdet[.......
1112 if(flagzmin == 0 && flagzmax==0){
1113 if(rangephi>=distphim){
1115 toucLad(idetot-1)=ladm;
1116 toucDet(idetot-1)=detinters;
1118 if(rangephi>=distphip){
1120 toucLad(idetot-1)=ladp;
1121 toucDet(idetot-1)=detinters;
1124 ////////////////////////////////////////////////////////////
1126 for (iriv=0; iriv<idetot; iriv++) { //for on detectors
1127 ///////////////////////////////////////////////////////
1128 /*** Rec points sorted by module *****/
1129 /**************************************/
1131 indexmod = g1->GetModuleIndex(lycur,(Int_t)toucLad(iriv),
1132 (Int_t)toucDet(iriv));
1133 fITS->ResetRecPoints();
1134 gAlice->TreeR()->GetEvent(indexmod);
1135 Int_t npoints=frecPoints->GetEntries();
1138 for(indnew=0; indnew<npoints; indnew++){
1139 if (*(fvettid[indexmod]+indnew)==0)
1140 recp =(AliITSRecPoint*)frecPoints->UncheckedAt(indnew);
1143 TVector cluster(3),vecclust(9);
1144 //vecclust(6)=vecclust(7)=vecclust(8)=-1.;
1146 // now vecclust is with cylindrical cohordinates
1147 vecclust(0)=(Float_t)fRecCylR[indexmod][indnew];
1148 vecclust(1)=(Float_t)fRecCylPhi[indexmod][indnew];
1149 vecclust(2)=(Float_t)fRecCylZ[indexmod][indnew];
1150 vecclust(3) = (Float_t)recp->fTracks[0];
1151 vecclust(4) = (Float_t)indnew;
1152 vecclust(5) = (Float_t)indexmod;
1153 vecclust(6) = (Float_t)recp->fTracks[0];
1154 vecclust(7) = (Float_t)recp->fTracks[1];
1155 vecclust(8) = (Float_t)recp->fTracks[2];
1156 sigma[0] = (Double_t) recp->GetSigmaX2();
1157 sigma[1] = (Double_t) recp->GetSigmaZ2();
1159 cluster(0)=fRecCylR[indexmod][indnew];
1160 cluster(1)=fRecCylPhi[indexmod][indnew];
1161 cluster(2)=fRecCylZ[indexmod][indnew];
1163 // cout<<" layer = "<<play<<"\n";
1164 // cout<<" cluster prima = "<<vecclust(0)<<" "
1165 // <<vecclust(1)<<" "
1166 // <<vecclust(2)<<"\n"; getchar();
1168 Float_t sigmatotphi, sigmatotz;
1169 // Float_t epsphi=5.0, epsz=5.0;
1170 //if(fPtref<0.2) {epsphi=3.; epsz=3.;}
1171 Double_t rTrack=(*trackITS).Getrtrack();
1172 Double_t sigmaphi=sigma[0]/(rTrack*rTrack);
1173 sigmatotphi=epsphi*TMath::Sqrt(sigmaphi +
1174 (*trackITS).GetSigmaphi());
1175 sigmatotz=epsz*TMath::Sqrt(sigma[1] +
1176 (*trackITS).GetSigmaZ());
1177 //cout<<"cluster e sigmatotphi e track = "<<cluster(0)
1178 // <<" "<<cluster(1)<<" "<<sigmatotphi<<" "
1179 // <<vecclust(3)<<"\n";
1180 //if(vecclust(3)==481) getchar();
1181 if(cluster(1)<6. && (*trackITS).Getphi()>6.)
1182 cluster(1)=cluster(1)+(2.*TMath::Pi());
1183 if(cluster(1)>6. && (*trackITS).Getphi()<6.)
1184 cluster(1)=cluster(1)-(2.*TMath::Pi());
1185 if(TMath::Abs(cluster(1)-(*trackITS).Getphi())>sigmatotphi)
1187 // cout<<" supero sigmaphi \n";
1188 AliITSTrackV1 *newTrack = new AliITSTrackV1((*trackITS));
1189 (*newTrack).SetLayer((*trackITS).GetLayer()-1);
1190 if (TMath::Abs(rTrack-cluster(0))/rTrack>1e-6)
1191 (*newTrack).Correct(Double_t(cluster(0)));
1192 //cout<<" cluster(2) e(*newTrack).GetZ()="<<cluster(2)<<" "
1193 // << (*newTrack).GetZ()<<"\n";
1194 if(TMath::Abs(cluster(2)-(*newTrack).GetZ()) > sigmatotz){
1198 Double_t sigmanew[2];
1199 sigmanew[0]= sigmaphi;
1200 sigmanew[1]=sigma[1];
1204 // Double_t chi2pred=newTrack->GetPredChi2(m,sigmanew);
1205 // cout<<" chi2pred = "<<chi2pred<<"\n";
1206 // if(chi2pred>fChi2max) continue; //aggiunto il 30-7-2001
1207 if(iriv == 0) flaghit=1;
1208 (*newTrack).AddMS(frl); // add the multiple scattering
1209 //matrix to the covariance matrix
1210 (*newTrack).AddEL(frl,1.,0);
1213 KalmanFilterVert(newTrack,cluster,sigmanew);
1214 //KalmanFilterVert(newTrack,cluster,sigmanew,chi2pred);
1216 KalmanFilter(newTrack,cluster,sigmanew);
1218 (*newTrack).PutCluster(layernew, vecclust);
1219 newTrack->AddClustInTrack();
1220 listoftrack.AddLast(newTrack);
1222 } // end of for on detectors (iriv)
1223 }//end if(outinters==0)
1225 if(flaghit==0 || outinters==-2) {
1226 AliITSTrackV1 *newTrack = new AliITSTrackV1(*trackITS);
1227 (*newTrack).Setfnoclust();
1228 (*newTrack).SetLayer((*trackITS).GetLayer()-1);
1229 (*newTrack).AddMS(frl); // add the multiple scattering matrix
1230 // to the covariance matrix
1231 (*newTrack).AddEL(frl,1.,0);
1232 listoftrack.AddLast(newTrack);
1235 //gObjectTable->Print(); // stampa memoria
1237 RecursiveTracking(&listoftrack);
1238 listoftrack.Delete();
1239 } // end of for on tracks (index)
1241 //gObjectTable->Print(); // stampa memoria
1243 //______________________________________________________________________
1244 Int_t AliITSTrackerV1::Intersection(AliITSTrackV1 &track,Int_t layer,
1245 Int_t &ladder,Int_t &detector) {
1246 // Origin A. Badala' and G.S. Pappalardo
1247 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1248 // Found the intersection and the detector
1250 Double_t rk=fAvrad[layer-1];
1251 if(track.DoNotCross(rk)){ /*cout<< " Do not cross \n";*/ return -1;}
1252 track.Propagation(rk);
1253 Double_t zinters=track.GetZ();
1254 Double_t phinters=track.Getphi();
1255 //cout<<"zinters = "<<zinters<<" phinters = "<<phinters<<"\n";
1259 TVector distZCenter(2);
1263 for(iD = 1; iD<= fNdet[layer-1]; iD++) {
1264 if(zinters > fzmin[layer-1][iD-1] && zinters <= fzmax[layer-1][iD-1]) {
1266 cout<< " Errore su iz in Intersection \n";
1269 listDet(iz)= iD; distZCenter(iz)=TMath::Abs(zinters-det(2));
1275 if(iz==0) {/* cout<< " No detector along Z \n";*/ return -2;}
1276 detector=Int_t (listDet(0));
1277 if(iz>1 && (distZCenter(0)>distZCenter(1))) detector=Int_t (listDet(1));
1280 TVector distPhiCenter(2);
1282 Double_t pigre=TMath::Pi();
1284 for(iLd = 1; iLd<= fNlad[layer-1]; iLd++) {
1285 Double_t phimin=fphimin[layer-1][iLd-1];
1286 Double_t phimax=fphimax[layer-1][iLd-1];
1287 Double_t phidet=fphidet[layer-1][iLd-1];
1288 Double_t phiconfr=phinters;
1290 //if(phimin <5.5) {cout<<" Error in Intersection for phi \n";
1293 if(phinters>(1.5*pigre)) phiconfr=phinters-(2.*pigre);
1294 if(phidet>(1.5*pigre)) phidet-=(2.*pigre);
1296 if(phiconfr>phimin && phiconfr<= phimax) {
1298 cout<< " Errore su ip in Intersection \n"; getchar();
1301 distPhiCenter(ip)=TMath::Abs(phiconfr-phidet); ip++;
1305 if(ip==0) { cout<< " No detector along phi \n"; getchar();}
1306 ladder=Int_t (listLad(0));
1307 if(ip>1 && (distPhiCenter(0)>distPhiCenter(1))) ladder=Int_t (listLad(1));
1310 //______________________________________________________________________
1311 void AliITSTrackerV1::KalmanFilter(AliITSTrackV1 *newTrack,TVector &cluster,
1313 //Origin A. Badala' and G.S. Pappalardo:
1314 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1315 // Kalman filter without vertex constraint
1316 ////// Evaluation of the measurement vector ////////////////////////
1318 Double_t rk,phik,zk;
1319 rk=cluster(0); phik=cluster(1); zk=cluster(2);
1321 //////////////////////// Evaluation of the error matrix V /////////
1322 Double_t v00=sigma[0];
1323 Double_t v11=sigma[1];
1324 ////////////////////////////////////////////////////////////////////
1325 Double_t cin00,cin10,cin20,cin30,cin40,cin11,cin21,cin31,cin41,cin22,
1326 cin32,cin42,cin33,cin43,cin44;
1328 newTrack->GetCElements(cin00,
1331 cin30,cin31,cin32,cin33,
1332 cin40,cin41,cin42,cin43,cin44); //get C matrix
1333 Double_t rold00=cin00+v00;
1334 Double_t rold10=cin10;
1335 Double_t rold11=cin11+v11;
1336 ////////////////////// R matrix inversion /////////////////////////
1337 Double_t det=rold00*rold11-rold10*rold10;
1338 Double_t r00=rold11/det;
1339 Double_t r10=-rold10/det;
1340 Double_t r11=rold00/det;
1341 ////////////////////////////////////////////////////////////////////
1342 Double_t k00=cin00*r00+cin10*r10;
1343 Double_t k01=cin00*r10+cin10*r11;
1344 Double_t k10=cin10*r00+cin11*r10;
1345 Double_t k11=cin10*r10+cin11*r11;
1346 Double_t k20=cin20*r00+cin21*r10;
1347 Double_t k21=cin20*r10+cin21*r11;
1348 Double_t k30=cin30*r00+cin31*r10;
1349 Double_t k31=cin30*r10+cin31*r11;
1350 Double_t k40=cin40*r00+cin41*r10;
1351 Double_t k41=cin40*r10+cin41*r11;
1352 Double_t x0,x1,x2,x3,x4;
1353 newTrack->GetXElements(x0,x1,x2,x3,x4); // get the state vector
1354 Double_t savex0=x0, savex1=x1;
1355 x0+=k00*(m[0]-savex0)+k01*(m[1]-savex1);
1356 x1+=k10*(m[0]-savex0)+k11*(m[1]-savex1);
1357 x2+=k20*(m[0]-savex0)+k21*(m[1]-savex1);
1358 x3+=k30*(m[0]-savex0)+k31*(m[1]-savex1);
1359 x4+=k40*(m[0]-savex0)+k41*(m[1]-savex1);
1360 Double_t c00,c10,c20,c30,c40,c11,c21,c31,c41,c22,c32,c42,c33,c43,c44;
1361 c00=cin00-k00*cin00-k01*cin10;
1362 c10=cin10-k00*cin10-k01*cin11;
1363 c20=cin20-k00*cin20-k01*cin21;
1364 c30=cin30-k00*cin30-k01*cin31;
1365 c40=cin40-k00*cin40-k01*cin41;
1366 c11=cin11-k10*cin10-k11*cin11;
1367 c21=cin21-k10*cin20-k11*cin21;
1368 c31=cin31-k10*cin30-k11*cin31;
1369 c41=cin41-k10*cin40-k11*cin41;
1370 c22=cin22-k20*cin20-k21*cin21;
1371 c32=cin32-k20*cin30-k21*cin31;
1372 c42=cin42-k20*cin40-k21*cin41;
1373 c33=cin33-k30*cin30-k31*cin31;
1374 c43=cin43-k30*cin40-k31*cin41;
1375 c44=cin44-k40*cin40-k41*cin41;
1376 newTrack->PutXElements(x0,x1,x2,x3,x4); // put the new state vector
1377 newTrack->PutCElements(c00,
1381 c40,c41,c42,c43,c44); // put in track the
1383 Double_t vmcold00=v00-c00;
1384 Double_t vmcold10=-c10;
1385 Double_t vmcold11=v11-c11;
1386 ////////////////////// Matrix vmc inversion ///////////////////////
1387 det=vmcold00*vmcold11-vmcold10*vmcold10;
1388 Double_t vmc00=vmcold11/det;
1389 Double_t vmc10=-vmcold10/det;
1390 Double_t vmc11=vmcold00/det;
1391 ////////////////////////////////////////////////////////////////////
1392 Double_t chi2=(m[0]-x0)*( vmc00*(m[0]-x0) + 2.*vmc10*(m[1]-x1) ) +
1393 (m[1]-x1)*vmc11*(m[1]-x1);
1394 newTrack->SetChi2(newTrack->GetChi2()+chi2);
1396 //----------------------------------------------------------------------
1397 //void AliITSTrackerV1::KalmanFilterVert(AliITSTrackV1 *newTrack,
1398 // TVector &cluster,Double_t sigma[2]){
1399 void AliITSTrackerV1::KalmanFilterVert(AliITSTrackV1 *newTrack,
1400 TVector &cluster,Double_t sigma[2]
1401 /*, Double_t chi2pred*/){
1402 //Origin A. Badala' and G.S. Pappalardo:
1403 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1404 // Kalman filter with vertex constraint
1405 ///////////////////// Evaluation of the measurement vector m ////////
1407 Double_t rk,phik,zk;
1408 rk=cluster(0); phik=cluster(1); zk=cluster(2);
1410 Double_t cc=(*newTrack).GetC();
1411 Double_t zv=(*newTrack).GetZv();
1412 Double_t dv=(*newTrack).GetDv();
1414 Double_t tgl= (zk-zv)*cy/TMath::ASin(cy*rk);
1416 /////////////////////// Evaluation of the error matrix V //////////
1417 Int_t layer=newTrack->GetLayer();
1418 Double_t v00=sigma[0];
1419 Double_t v11=sigma[1];
1420 Double_t v31=sigma[1]/rk;
1421 Double_t sigmaDv=newTrack->GetsigmaDv();
1422 Double_t v22=sigmaDv*sigmaDv + newTrack->Getd2(layer-1);
1423 Double_t v32=newTrack->Getdtgl(layer-1);
1424 Double_t sigmaZv=newTrack->GetsigmaZv();
1425 Double_t v33=(sigma[1]+sigmaZv*sigmaZv)/(rk*rk)+newTrack->Gettgl2(layer-1);
1426 //////////////////////////////////////////////////////////////////
1427 Double_t cin00,cin10,cin11,cin20,cin21,cin22,
1428 cin30,cin31,cin32,cin33,cin40,cin41,cin42,cin43,cin44;
1429 newTrack->GetCElements(cin00,
1432 cin30,cin31,cin32,cin33,
1433 cin40,cin41,cin42,cin43,cin44); //get C matrix
1441 r[3][1]=cin31+sigma[1]/rk;
1442 r[2][2]=cin22+sigmaDv*sigmaDv+newTrack->Getd2(layer-1);
1443 r[3][2]=cin32+newTrack->Getdtgl(layer-1);
1444 r[3][3]=cin33+(sigma[1]+sigmaZv*sigmaZv)/(rk*rk)+
1445 newTrack->Gettgl2(layer-1);
1446 r[0][1]=r[1][0]; r[0][2]=r[2][0]; r[0][3]=r[3][0];
1447 r[1][2]=r[2][1]; r[1][3]=r[3][1]; r[2][3]=r[3][2];
1448 ///////////////////// Matrix R inversion //////////////////////////
1452 Int_t ll[kn],mm[kn];
1455 for(k=0; k<kn; k++) {
1459 for(j=k; j<kn ; j++) {
1460 for (i=j; i<kn; i++) {
1461 if(TMath::Abs(big) < TMath::Abs(r[i][j]) ) {
1471 for(i=0; i<kn; i++) {
1480 for(j=0; j<kn; j++) {
1489 cout << "Singular matrix\n";
1491 for(i=0; i<kn; i++) {
1492 if(i == k) { continue; }
1493 r[i][k]=r[i][k]/(-big);
1496 for(i=0; i<kn; i++) {
1498 for(j=0; j<kn; j++) {
1499 if(i == k || j == k) continue;
1500 r[i][j]=hold*r[k][j]+r[i][j];
1504 for(j=0; j<kn; j++) {
1505 if(j == k) continue;
1506 r[k][j]=r[k][j]/big;
1514 for(k=kn-1; k>=0; k--) {
1517 for (j=0; j<kn; j++) {
1525 for (i=0; i<kn; i++) {
1532 ////////////////////////////////////////////////////////////////////
1533 Double_t k00=cin00*r[0][0]+cin10*r[1][0]+cin20*r[2][0]+cin30*r[3][0];
1534 Double_t k01=cin00*r[1][0]+cin10*r[1][1]+cin20*r[2][1]+cin30*r[3][1];
1535 Double_t k02=cin00*r[2][0]+cin10*r[2][1]+cin20*r[2][2]+cin30*r[3][2];
1536 Double_t k03=cin00*r[3][0]+cin10*r[3][1]+cin20*r[3][2]+cin30*r[3][3];
1537 Double_t k10=cin10*r[0][0]+cin11*r[1][0]+cin21*r[2][0]+cin31*r[3][0];
1538 Double_t k11=cin10*r[1][0]+cin11*r[1][1]+cin21*r[2][1]+cin31*r[3][1];
1539 Double_t k12=cin10*r[2][0]+cin11*r[2][1]+cin21*r[2][2]+cin31*r[3][2];
1540 Double_t k13=cin10*r[3][0]+cin11*r[3][1]+cin21*r[3][2]+cin31*r[3][3];
1541 Double_t k20=cin20*r[0][0]+cin21*r[1][0]+cin22*r[2][0]+cin32*r[3][0];
1542 Double_t k21=cin20*r[1][0]+cin21*r[1][1]+cin22*r[2][1]+cin32*r[3][1];
1543 Double_t k22=cin20*r[2][0]+cin21*r[2][1]+cin22*r[2][2]+cin32*r[3][2];
1544 Double_t k23=cin20*r[3][0]+cin21*r[3][1]+cin22*r[3][2]+cin32*r[3][3];
1545 Double_t k30=cin30*r[0][0]+cin31*r[1][0]+cin32*r[2][0]+cin33*r[3][0];
1546 Double_t k31=cin30*r[1][0]+cin31*r[1][1]+cin32*r[2][1]+cin33*r[3][1];
1547 Double_t k32=cin30*r[2][0]+cin31*r[2][1]+cin32*r[2][2]+cin33*r[3][2];
1548 Double_t k33=cin30*r[3][0]+cin31*r[3][1]+cin32*r[3][2]+cin33*r[3][3];
1549 Double_t k40=cin40*r[0][0]+cin41*r[1][0]+cin42*r[2][0]+cin43*r[3][0];
1550 Double_t k41=cin40*r[1][0]+cin41*r[1][1]+cin42*r[2][1]+cin43*r[3][1];
1551 Double_t k42=cin40*r[2][0]+cin41*r[2][1]+cin42*r[2][2]+cin43*r[3][2];
1552 Double_t k43=cin40*r[3][0]+cin41*r[3][1]+cin42*r[3][2]+cin43*r[3][3];
1554 Double_t x0,x1,x2,x3,x4;
1555 newTrack->GetXElements(x0,x1,x2,x3,x4); // get the state vector
1556 Double_t savex0=x0, savex1=x1, savex2=x2, savex3=x3;
1557 x0+=k00*(m[0]-savex0)+k01*(m[1]-savex1)+k02*(m[2]-savex2)+
1559 x1+=k10*(m[0]-savex0)+k11*(m[1]-savex1)+k12*(m[2]-savex2)+
1561 x2+=k20*(m[0]-savex0)+k21*(m[1]-savex1)+k22*(m[2]-savex2)+
1563 x3+=k30*(m[0]-savex0)+k31*(m[1]-savex1)+k32*(m[2]-savex2)+
1565 x4+=k40*(m[0]-savex0)+k41*(m[1]-savex1)+k42*(m[2]-savex2)+
1567 Double_t c00,c10,c20,c30,c40,c11,c21,c31,c41,c22,c32,c42,c33,c43,c44;
1568 c00=cin00-k00*cin00-k01*cin10-k02*cin20-k03*cin30;
1569 c10=cin10-k00*cin10-k01*cin11-k02*cin21-k03*cin31;
1570 c20=cin20-k00*cin20-k01*cin21-k02*cin22-k03*cin32;
1571 c30=cin30-k00*cin30-k01*cin31-k02*cin32-k03*cin33;
1572 c40=cin40-k00*cin40-k01*cin41-k02*cin42-k03*cin43;
1573 c11=cin11-k10*cin10-k11*cin11-k12*cin21-k13*cin31;
1574 c21=cin21-k10*cin20-k11*cin21-k12*cin22-k13*cin32;
1575 c31=cin31-k10*cin30-k11*cin31-k12*cin32-k13*cin33;
1576 c41=cin41-k10*cin40-k11*cin41-k12*cin42-k13*cin43;
1577 c22=cin22-k20*cin20-k21*cin21-k22*cin22-k23*cin32;
1578 c32=cin32-k20*cin30-k21*cin31-k22*cin32-k23*cin33;
1579 c42=cin42-k20*cin40-k21*cin41-k22*cin42-k23*cin43;
1580 c33=cin33-k30*cin30-k31*cin31-k32*cin32-k33*cin33;
1581 c43=cin43-k30*cin40-k31*cin41-k32*cin42-k33*cin43;
1582 c44=cin44-k40*cin40-k41*cin41-k42*cin42-k43*cin43;
1584 newTrack->PutXElements(x0,x1,x2,x3,x4); // put the new state vector
1585 newTrack->PutCElements(c00,
1589 c40,c41,c42,c43,c44); // put in track the
1592 vmc[0][0]=v00-c00; vmc[1][0]=-c10; vmc[2][0]=-c20; vmc[3][0]=-c30;
1593 vmc[1][1]=v11-c11; vmc[2][1]=-c21; vmc[3][1]=v31-c31;
1594 vmc[2][2]=v22-c22; vmc[3][2]=v32-c32;
1596 vmc[0][1]=vmc[1][0]; vmc[0][2]=vmc[2][0]; vmc[0][3]=vmc[3][0];
1597 vmc[1][2]=vmc[2][1]; vmc[1][3]=vmc[3][1];
1598 vmc[2][3]=vmc[3][2];
1599 /////////////////////// vmc matrix inversion ///////////////////////
1601 for(k=0; k<kn; k++) {
1605 for(j=k; j<kn ; j++) {
1606 for (i=j; i<kn; i++) {
1607 if(TMath::Abs(big) < TMath::Abs(vmc[i][j]) ) {
1617 for(i=0; i<kn; i++) {
1619 vmc[k][i]=vmc[j][i];
1626 for(j=0; j<kn; j++) {
1628 vmc[j][k]=vmc[j][i];
1635 cout << "Singular matrix\n";
1637 for(i=0; i<kn; i++) {
1638 if(i == k) continue;
1639 vmc[i][k]=vmc[i][k]/(-big);
1642 for(i=0; i<kn; i++) {
1644 for(j=0; j<kn; j++) {
1645 if(i == k || j == k) continue;
1646 vmc[i][j]=hold*vmc[k][j]+vmc[i][j];
1650 for(j=0; j<kn; j++) {
1651 if(j == k) continue;
1652 vmc[k][j]=vmc[k][j]/big;
1660 for(k=kn-1; k>=0; k--) {
1663 for (j=0; j<kn; j++) {
1665 vmc[j][k]=-vmc[j][i];
1671 for (i=0; i<kn; i++) {
1673 vmc[k][i]=-vmc[j][i];
1678 ////////////////////////////////////////////////////////////////////
1679 Double_t chi2=(m[0]-x0)*( vmc[0][0]*(m[0]-x0) + 2.*vmc[1][0]*(m[1]-x1) +
1680 2.*vmc[2][0]*(m[2]-x2)+ 2.*vmc[3][0]*(m[3]-x3) )+
1681 (m[1]-x1)* ( vmc[1][1]*(m[1]-x1) + 2.*vmc[2][1]*(m[2]-x2)+
1682 2.*vmc[3][1]*(m[3]-x3) ) +
1683 (m[2]-x2)* ( vmc[2][2]*(m[2]-x2)+ 2.*vmc[3][2]*(m[3]-x3) ) +
1684 (m[3]-x3)*vmc[3][3]*(m[3]-x3);
1685 //cout<<" chi2 kalman = "<<chi2<<"\n"; getchar();
1686 newTrack->SetChi2(newTrack->GetChi2()+chi2);
1687 // newTrack->SetChi2(newTrack->GetChi2()+chi2pred);