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.27 2002/10/31 10:17:40 hristov
19 Corrected usage of AliKalmanTrack::SetConvConst (Alpha)
21 Revision 1.26 2002/10/25 18:44:33 barbera
22 Unnecessary print-out removed
24 Revision 1.25 2002/10/24 17:12:58 barbera
25 ITS tracking V1 integrated with the last version of ITS PID
27 Revision 1.24 2002/10/23 14:28:38 barbera
28 Fixes added to get into account the new magnetic field conversion factor automatically
30 Revision 1.23 2002/10/22 18:29:34 barbera
31 Tracking V1 ported to the HEAD
33 Revision 1.22 2002/10/22 14:45:36 alibrary
34 Introducing Riostream.h
36 Revision 1.21 2002/02/05 09:12:26 hristov
37 Small mods for gcc 3.02
39 Revision 1.20 2001/11/21 14:47:45 barbera
40 Some unuseful print-out commented out
42 Revision 1.19 2001/11/21 10:49:07 barbera
43 Bug correction suggested by Rene done
45 Revision 1.18 2001/11/20 15:46:17 barbera
46 Point coordinated are calculated in cylindrical reference frame once and for all at the beginning of tracking V1
48 Revision 1.10.2.1 2001/10/24 07:26:04 hristov
49 All the changes from the head are merged with the release
51 Revision 1.14 2001/10/24 07:19:57 hristov
52 Some pointer correctly initialised in one of the constructors
54 Revision 1.13 2001/10/21 19:17:12 hristov
55 Several pointers were set to zero in the default constructors to avoid memory management problems
57 Revision 1.12 2001/10/19 21:32:35 nilsen
58 Minor changes to remove compliation warning on gcc 2.92.2 compiler, and
59 cleanded up a little bit of code.
62 // The purpose of this class is to permorm the ITS tracking. The
63 // constructor has the task to inizialize some private members. The method
64 // DoTracking is written to be called by a macro. It gets the event number,
65 // the minimum and maximum order number of TPC tracks that are to be tracked
66 // trough the ITS, and the file where the recpoints are registered. The
67 // method Recursivetracking is a recursive function that performs the
68 // tracking trough the ITS The method Intersection found the layer, ladder
69 // and detector whre the intersection take place and caluclate the
70 // cohordinates of this intersection. It returns an integer that is 0 if the
71 // intersection has been found successfully. The two mwthods Kalmanfilter
72 // and kalmanfiltervert operate the kalmanfilter without and with the vertex
73 // imposition respectively. The authors thank Mariana Bondila to have help
74 // them to resolve some problems. July-2000
76 #include <Riostream.h>
77 #include <Riostream.h>
83 #include <TStopwatch.h>
85 #include "TParticle.h"
88 #include "AliITSsegmentationSSD.h"
89 #include "AliITSgeomSPD.h"
90 #include "AliITSgeomSDD.h"
91 #include "AliITSgeomSSD.h"
92 #include "AliITSgeom.h"
93 #include "AliITSRecPoint.h"
95 #include "AliKalmanTrack.h"
97 #include "AliITSTrackV1.h"
98 #include "AliITSIOTrack.h"
99 #include "AliITSRad.h"
100 #include "../TPC/AliTPCtracker.h"
101 #include "AliITSTrackerV1.h"
102 #include "AliITSVertex.h"
103 #include "AliITSPid.h"
105 ClassImp(AliITSTrackerV1)
106 //______________________________________________________________________
107 AliITSTrackerV1::AliITSTrackerV1() {
108 //Default constructor
120 for(ia=0; ia<6; ia++) {
138 //______________________________________________________________________
139 AliITSTrackerV1::AliITSTrackerV1(AliITS* IITTSS, Int_t evnumber, Bool_t flag) {
140 //Origin A. Badala' and G.S. Pappalardo:
141 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
142 // Class constructor. It does some initializations.
144 //PH Initialisation taken from the default constructor
159 Int_t imax = 200,jmax = 450;
160 frl = new AliITSRad(imax,jmax);
162 ////////// gets information on geometry /////////////////////////////
163 AliITSgeom *g1 = fITS->GetITSgeom();
168 for(ia=0; ia<6; ia++) {
169 fNlad[ia]=g1->GetNladders(ia+1);
170 fNdet[ia]=g1->GetNdetectors(ia+1);
171 //cout<<fNlad[i]<<" "<<fNdet[i]<<"\n";
174 //cout<<" mean radius = ";
176 for(ib=0; ib<6; ib++) {
177 g1->GetCenterThetaPhi(ib+1,ll,dd,det);
178 Double_t r1=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
179 g1->GetCenterThetaPhi(ib+1,ll,dd+1,det);
180 Double_t r2=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
181 fAvrad[ib]=(r1+r2)/2.;
182 //cout<<fAvrad[ib]<<" ";
184 //cout<<"\n"; getchar();
186 fDetx[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDx();
187 fDetz[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDz();
189 fDetx[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDx();
190 fDetz[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDz();
192 fDetx[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDx();
193 fDetz[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDz();
195 fDetx[3] = ((AliITSgeomSDD*)(g1->GetShape(4, ll, dd)))->GetDx();
196 fDetz[3] = ((AliITSgeomSDD*)(g1->GetShape(4, ll, dd)))->GetDz();
198 fDetx[4] = ((AliITSgeomSSD*)(g1->GetShape(5, ll, dd)))->GetDx();
199 fDetz[4] = ((AliITSgeomSSD*)(g1->GetShape(5, ll, dd)))->GetDz();
201 fDetx[5] = ((AliITSgeomSSD*)(g1->GetShape(6, ll, dd)))->GetDx();
202 fDetz[5] = ((AliITSgeomSSD*)(g1->GetShape(6, ll, dd)))->GetDz();
203 //cout<<" Detx Detz\n";
204 //for(Int_t la=0; la<6; la++) cout<<" "<<fDetx[la]<<" "<<
208 // allocate memory and define matrices fzmin, fzmax, fphimin and fphimax //
210 Double_t epszdrift=0.05;
212 fzmin = new Double_t*[6]; fzmax = new Double_t*[6];
213 Int_t im1, im2, im2max;
214 for(im1=0; im1<6; im1++) {
216 fzmin[im1] = new Double_t[im2max]; fzmax[im1] = new Double_t[im2max];
219 for(im1=0; im1<6; im1++) {
221 for(im2=0; im2<im2max; im2++) {
222 g1->GetCenterThetaPhi(im1+1,1,im2+1,det);
223 if(im2!=0) fzmin[im1][im2]=det(2)-fDetz[im1];
225 fzmin[im1][im2]=det(2)-(fDetz[im1])*epsz;
226 if(im2!=(im2max-1)) fzmax[im1][im2]=det(2)+fDetz[im1];
228 fzmax[im1][im2]=det(2)+fDetz[im1]*epsz;
229 if(im1==2 || im1==3) {
230 fzmin[im1][im2]-=epszdrift;
231 fzmax[im1][im2]+=epszdrift;
232 } // end if im1==2 || im1==3
236 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
237 for(im1=0;im1<6;im1++) {
239 fphimin[im1] = new Double_t[im2max];
240 fphimax[im1] = new Double_t[im2max];
243 fphidet = new Double_t*[6];
244 for(im1=0; im1<6; im1++) {
246 fphidet[im1] = new Double_t[im2max];
249 Double_t global[3],local[3];
250 Double_t pigre=TMath::Pi();
251 Double_t xmin,ymin,xmax,ymax;
253 for(im1=0; im1<6; im1++) {
255 for(im2=0; im2<im2max; im2++) {
257 g1->GetCenterThetaPhi(im1+1,im2+1,idet,det);
258 fphidet[im1][im2] = TMath::ATan2(Double_t(det(1)),
260 if(fphidet[im1][im2]<0.) fphidet[im1][im2]+=2.*pigre;
261 local[1]=local[2]=0.;
262 local[0]= -(fDetx[im1]);
263 if(im1==0) local[0]= (fDetx[im1]); //to take into account
264 // different reference system
265 g1->LtoG(im1+1,im2+1,idet,local,global);
266 xmax=global[0]; ymax=global[1];
267 local[0]= (fDetx[im1]);
268 if(im1==0) local[0]= -(fDetx[im1]);//take into account different
270 g1->LtoG(im1+1,im2+1,idet,local,global);
271 xmin=global[0]; ymin=global[1];
272 fphimin[im1][im2]= TMath::ATan2(ymin,xmin);
273 if(fphimin[im1][im2]<0.) fphimin[im1][im2]+=2.*pigre;
274 fphimax[im1][im2]= TMath::ATan2(ymax,xmax);
275 if(fphimax[im1][im2]<0.) fphimax[im1][im2]+=2.*pigre;
278 //////////////////////////////////////////////////////////////////////////////////////////////////////////
279 /////////////// allocate memory and define vector fNRecPoints and matrices fRecCylR, fRecCylPhi, fRecCylZ /////////////
280 gAlice->GetEvent(evnumber);
281 Int_t NumOfModules = g1->GetIndexMax();
282 fRecCylR = new Double_t *[NumOfModules];
283 fRecCylPhi = new Double_t *[NumOfModules];
284 fRecCylZ = new Double_t *[NumOfModules];
285 AliITSRecPoint *recp;
286 fNRecPoints = new Int_t[NumOfModules];
288 for(Int_t module=0; module<NumOfModules; module++) {
289 fITS->ResetRecPoints();
290 gAlice->TreeR()->GetEvent(module);
291 frecPoints=fITS->RecPoints();
292 Int_t nRecPoints=fNRecPoints[module]=frecPoints->GetEntries();
293 fRecCylR[module] = new Double_t[nRecPoints];
294 fRecCylPhi[module] = new Double_t[nRecPoints];
295 fRecCylZ[module] = new Double_t[nRecPoints];
297 for(ind=0; ind<fNRecPoints[module]; ind++) {
298 recp=(AliITSRecPoint*)frecPoints->UncheckedAt(ind);
299 // Float_t global[3], local[3];
300 Double_t global[3], local[3];
301 local[0]=recp->GetX();
303 local[2]= recp->GetZ();
304 g1->LtoG(module,local,global);
306 Double_t r = TMath::Sqrt(global[0]*global[0]+global[1]*global[1]); // r hit
307 Double_t phi = TMath::ATan2(global[1],global[0]); if(phi<0.) phi+=2.*TMath::Pi(); // phi hit
308 Double_t z = global[2]; // z hit
310 fRecCylR[module][ind]=r;
311 fRecCylPhi[module][ind]=phi;
312 fRecCylZ[module][ind]=z;
317 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
320 ////////// gets magnetic field factor //////////////////////////////
322 AliMagF * fieldPointer = gAlice->Field();
323 // fFieldFactor = (Double_t)fieldPointer->Factor();
324 fFieldFactor =(Double_t)fieldPointer-> SolenoidField()/10/.2;
325 // cout<< " field factor = "<<fFieldFactor<<"\n"; getchar();
327 //______________________________________________________________________
328 AliITSTrackerV1::AliITSTrackerV1(const AliITSTrackerV1 &cobj) {
329 // Origin A. Badala' and G.S. Pappalardo:
330 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
334 *fresult = *cobj.fresult;
335 fPtref = cobj.fPtref;
336 fChi2max = cobj.fChi2max;
337 **fvettid = **cobj.fvettid;
338 fflagvert = cobj.fflagvert;
339 Int_t imax=200,jmax=450;
340 frl = new AliITSRad(imax,jmax);
342 fFieldFactor = cobj.fFieldFactor;
343 Int_t i,im1,im2,im2max;
345 fNlad[i] = cobj.fNlad[i];
346 fNdet[i] = cobj.fNdet[i];
347 fAvrad[i] = cobj.fAvrad[i];
348 fDetx[i] = cobj.fDetx[i];
349 fDetz[i] = cobj.fDetz[i];
351 fzmin = new Double_t*[6]; fzmax = new Double_t*[6];
352 for(im1=0; im1<6; im1++) {
354 fzmin[im1] = new Double_t[im2max];
355 fzmax[im1] = new Double_t[im2max];
357 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
358 for(im1=0;im1<6;im1++) {
360 fphimin[im1] = new Double_t[im2max];
361 fphimax[im1] = new Double_t[im2max];
364 fphidet = new Double_t*[6];
365 for(im1=0; im1<6; im1++) {
367 fphidet[im1] = new Double_t[im2max];
369 for(im1=0; im1<6; im1++) {
371 for(im2=0; im2<im2max; im2++) {
372 fzmin[im1][im2]=cobj.fzmin[im1][im2];
373 fzmax[im1][im2]=cobj.fzmax[im1][im2];
376 for(im1=0; im1<6; im1++) {
378 for(im2=0; im2<im2max; im2++) {
379 fphimin[im1][im2]=cobj.fphimin[im1][im2];
380 fphimax[im1][im2]=cobj.fphimax[im1][im2];
381 fphidet[im1][im2]=cobj.fphidet[im1][im2];
386 AliITSgeom *g1 = fITS->GetITSgeom();
387 Int_t NumOfModules = g1->GetIndexMax();
389 fRecCylR = new Float_t *[NumOfModules];
390 fRecCylPhi = new Float_t *[NumOfModules];
391 fRecCylZ = new Float_t *[NumOfModules];
393 fRecCylR = new Double_t *[NumOfModules];
394 fRecCylPhi = new Double_t *[NumOfModules];
395 fRecCylZ = new Double_t *[NumOfModules];
396 fNRecPoints = new Int_t[NumOfModules];
397 for(Int_t module=0; module<NumOfModules; module++) {
398 Int_t nRecPoints=fNRecPoints[module]=cobj.fNRecPoints[module];
400 fRecCylR[module] = new Float_t[nRecPoints];
401 fRecCylPhi[module] = new Float_t[nRecPoints];
402 fRecCylZ[module] = new Float_t[nRecPoints];
404 fRecCylR[module] = new Double_t[nRecPoints];
405 fRecCylPhi[module] = new Double_t[nRecPoints];
406 fRecCylZ[module] = new Double_t[nRecPoints];
408 for(ind=0; ind<nRecPoints; ind++) {
409 fRecCylR[module][ind]=cobj.fRecCylR[module][ind];
410 fRecCylPhi[module][ind]=cobj.fRecCylPhi[module][ind];
411 fRecCylZ[module][ind]=cobj.fRecCylZ[module][ind];
416 void AliITSTrackerV1::DelMatrix(Int_t NumOfModules) {
417 for(Int_t mod=0; mod<NumOfModules; mod++) {
418 delete fRecCylR[mod];
419 delete fRecCylPhi[mod];
420 delete fRecCylZ[mod];
426 //______________________________________________________________________
427 AliITSTrackerV1::~AliITSTrackerV1(){
428 // Origin A. Badala' and G.S. Pappalardo:
429 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
433 for(Int_t i=0; i<6; i++) {
448 //______________________________________________________________________
449 AliITSTrackerV1 &AliITSTrackerV1::operator=(AliITSTrackerV1 obj) {
450 // Origin A. Badala' and G.S. Pappalardo:
451 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
452 // assignement operator
455 *fresult = *obj.fresult;
457 fChi2max = obj.fChi2max;
458 **fvettid = **obj.fvettid;
459 fflagvert = obj.fflagvert;
460 Int_t imax=200,jmax=450;
461 frl = new AliITSRad(imax,jmax);
463 fFieldFactor = obj.fFieldFactor;
466 fNlad[i] = obj.fNlad[i];
467 fNdet[i] = obj.fNdet[i];
468 fAvrad[i] = obj.fAvrad[i];
469 fDetx[i] = obj.fDetx[i];
470 fDetz[i] = obj.fDetz[i];
472 fzmin = new Double_t*[6];
473 fzmax = new Double_t*[6];
474 Int_t im1, im2, im2max;
475 for(im1=0; im1<6; im1++) {
477 fzmin[im1] = new Double_t[im2max]; fzmax[im1] = new Double_t[im2max];
479 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
480 for(im1=0;im1<6;im1++) {
482 fphimin[im1] = new Double_t[im2max];
483 fphimax[im1] = new Double_t[im2max];
486 fphidet = new Double_t*[6];
487 for(im1=0; im1<6; im1++) {
489 fphidet[im1] = new Double_t[im2max];
491 for(im1=0; im1<6; im1++) {
493 for(im2=0; im2<im2max; im2++) {
494 fzmin[im1][im2]=obj.fzmin[im1][im2];
495 fzmax[im1][im2]=obj.fzmax[im1][im2];
498 for(im1=0; im1<6; im1++) {
500 for(im2=0; im2<im2max; im2++) {
501 fphimin[im1][im2]=obj.fphimin[im1][im2];
502 fphimax[im1][im2]=obj.fphimax[im1][im2];
503 fphidet[im1][im2]=obj.fphidet[im1][im2];
507 AliITSgeom *g1 = fITS->GetITSgeom();
508 Int_t NumOfModules = g1->GetIndexMax();
509 fRecCylR = new Double_t *[NumOfModules];
510 fRecCylPhi = new Double_t *[NumOfModules];
511 fRecCylZ = new Double_t *[NumOfModules];
512 fNRecPoints = new Int_t[NumOfModules];
513 for(Int_t module=0; module<NumOfModules; module++) {
514 Int_t nRecPoints=fNRecPoints[module]=obj.fNRecPoints[module];
515 fRecCylR[module] = new Double_t[nRecPoints];
516 fRecCylPhi[module] = new Double_t[nRecPoints];
517 fRecCylZ[module] = new Double_t[nRecPoints];
519 for(ind=0; ind<nRecPoints; ind++) {
520 fRecCylR[module][ind]=obj.fRecCylR[module][ind];
521 fRecCylPhi[module][ind]=obj.fRecCylPhi[module][ind];
522 fRecCylZ[module][ind]=obj.fRecCylZ[module][ind];
529 //______________________________________________________________________
530 void AliITSTrackerV1::DoTracking(Int_t evNumber,Int_t minTr,Int_t maxTr,
531 TFile *file, Bool_t realmass) {
532 // Origin A. Badala' and G.S. Pappalardo:
533 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
534 // The method needs the event number, the minimum and maximum order
535 // number of TPC tracks that
536 // are to be tracked trough the ITS, and the file where the recpoints
538 // The method can be called by a macro. It preforms the tracking for
539 // all good TPC tracks
541 printf("begin DoTracking - file %p\n",file);
543 gAlice->GetEvent(evNumber); //modificato per gestire hbt
545 AliKalmanTrack::SetConvConst(1000/0.299792458/gAlice->Field()->SolenoidField());
546 // cout<<" field = "<<gAlice->Field()->SolenoidField()<<endl;
549 TFile *cf=TFile::Open("AliTPCclusters.root");
550 AliTPCParam *digp= (AliTPCParam*)cf->Get("75x40_100x60_150x60");
551 if (!digp) { cerr<<"TPC parameters have not been found !\n"; getchar();}
554 //AliTPCtracker *tracker = new AliTPCtracker(digp,evNumber); //I.B.
555 AliTPCtracker *tracker = new AliTPCtracker(digp); //I.B.
556 tracker->SetEventNumber(evNumber); //I.B.
559 //tracker->LoadInnerSectors(); //I.B.
560 //tracker->LoadOuterSectors(); //I.B.
561 tracker->LoadClusters(); //I.B.
564 TFile *tf=TFile::Open("AliTPCtracksSorted.root");
566 cerr<<"Can't open AliTPCtracksSorted.root !\n";
569 TObjArray tracks(200000);
571 sprintf(tname,"TreeT_TPC_%d",evNumber);
573 TTree *tracktree=(TTree*)tf->Get(tname);
574 if (!tracktree) {cerr<<"Can't get a tree with TPC tracks !\n";}
575 TBranch *tbranch=tracktree->GetBranch("tracks");
576 Int_t nentr=(Int_t)tracktree->GetEntries();
579 AliITSRecPoint *recp; // oggi
580 AliTPCtrack *ioTrackTPC=0;
581 for (kk=0; kk<nentr; kk++) {
582 ioTrackTPC=new AliTPCtrack;
583 tbranch->SetAddress(&ioTrackTPC);
584 tracktree->GetEvent(kk);
585 tracker->CookLabel(ioTrackTPC,0.1);
586 tracks.AddLast(ioTrackTPC);
591 Int_t nt = tracks.GetEntriesFast();
592 cerr<<"Number of found tracks "<<nt<<endl;
595 TTree *tr=gAlice->TreeR();
596 Int_t nent=(Int_t)tr->GetEntries();
597 frecPoints = fITS->RecPoints();
601 Int_t *np = new Int_t[nent];
602 fvettid = new Int_t* [nent];
605 for (mod=0; mod<nent; mod++) {
607 fITS->ResetRecPoints();
608 gAlice->TreeR()->GetEvent(mod);
609 numbpoints = frecPoints->GetEntries();
610 totalpoints+=numbpoints;
611 np[mod] = numbpoints;
612 //cout<<" mod = "<<mod<<" numbpoints = "<<numbpoints<<"\n";getchar();
613 fvettid[mod] = new Int_t[numbpoints];
615 for (ii=0;ii<numbpoints; ii++) *(fvettid[mod]+ii)=0;
618 AliTPCtrack *track=0;
620 if(minTr < 0) {minTr = 0; maxTr = nt-1;}
624 TTree tracktree1("TreeT","Tree with ITS tracks");
625 AliITSIOTrack *ioTrack=0;
626 AliITSPid *pid=new AliITSPid(1000); // oggi
628 tracktree1.Branch("ITStracks","AliITSIOTrack",&ioTrack,32000,0);
630 TDatabasePDG * db = new TDatabasePDG;
633 for (j=minTr; j<=maxTr; j++) {
634 track=(AliTPCtrack*)tracks.UncheckedAt(j);
635 if (!track) continue;
637 /// mass definition ////////////////////////
638 Double_t mass=0.13956995;
639 Int_t pcode=211; // a pion by default
642 if(TMath::Abs(pcode)<20443) mass=db->GetParticle(pcode)->Mass();
645 mass = track->GetMass();
646 // cout << "Mass = " << mass << endl;
651 // new propagation to the end of TPC
653 // track->PropagateTo(xk,0.,0.); //Ne if it's still there //attenzione funziona solo se modifica in TPC
654 // Double_t xk=77.415;
655 track->PropagateTo(xk, 28.94, 1.204e-3);
657 track->PropagateTo(xk, 44.77,1.71); //Tedlar
659 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
661 track->PropagateTo(xk, 41.28, 0.029);//Nomex
663 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
665 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
668 // track->PropagateTo(xk,0.,0.); //C02
669 track->PropagateTo(xk,36.2,1.98e-3); //C02 //attenzione funziona solo se modifica in TPC
672 track->PropagateTo(xk, 24.01, 2.7); //Al
674 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
676 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
678 track->PropagateTo(xk, 41.28, 0.029); //Nomex
680 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
682 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
684 track->PropagateTo(xk, 24.01, 2.7); //Al
686 ////////////////////////////////////////////////////////////////////////////////////////////////////////
687 //AliITSTrackV1 trackITS(*track);
688 AliITSTrackV1 trackITS(*track, fFieldFactor);
689 //cout<<" fFieldFactor = "<<fFieldFactor<<"\n";
690 trackITS.PutMass(mass); //new to add mass to track
691 if(fresult){ delete fresult; fresult=0;}
692 fresult = new AliITSTrackV1(trackITS);
694 AliITSTrackV1 primaryTrack(trackITS);
695 vgeant=(*fresult).GetVertex();
697 // Definition of dv and zv for vertex constraint
698 Double_t sigmaDv=0.0050; Double_t sigmaZv=0.010;
699 //Double_t sigmaDv=0.0015; Double_t sigmaZv=0.0015;
700 Double_t uniform= gRandom->Uniform();
702 if(uniform<=0.5) signdv=-1.;
706 Double_t vr=TMath::Sqrt(vgeant(0)*vgeant(0)+ vgeant(1)*vgeant(1));
707 Double_t dv=gRandom->Gaus(signdv*vr,(Float_t)sigmaDv);
708 Double_t zv=gRandom->Gaus(vgeant(2),(Float_t)sigmaZv);
709 //cout<<" Dv e Zv = "<<dv<<" "<<zv<<"\n";
712 trackITS.SetsigmaDv(sigmaDv);
713 trackITS.SetsigmaZv(sigmaZv);
714 (*fresult).SetDv(dv);
715 (*fresult).SetZv(zv);
716 (*fresult).SetsigmaDv(sigmaDv);
717 (*fresult).SetsigmaZv(sigmaZv);
718 primaryTrack.SetDv(dv);
719 primaryTrack.SetZv(zv);
720 primaryTrack.SetsigmaDv(sigmaDv);
721 primaryTrack.SetsigmaZv(sigmaZv);
722 primaryTrack.PrimaryTrack(frl);
723 TVector d2=primaryTrack.Getd2();
724 TVector tgl2=primaryTrack.Gettgl2();
725 TVector dtgl=primaryTrack.Getdtgl();
726 trackITS.Setd2(d2); trackITS.Settgl2(tgl2);
727 trackITS.Setdtgl(dtgl);
728 (*fresult).Setd2(d2); (*fresult).Settgl2(tgl2);
729 (*fresult).Setdtgl(dtgl);
731 trackITS.SetVertex(vertex); trackITS.SetErrorVertex(ervertex);
732 (*result).SetVertex(vertex); (*result).SetErrorVertex(ervertex);
734 TList *list= new TList();
736 list->AddLast(&trackITS);
738 fPtref=TMath::Abs( (trackITS).GetPt() );
739 //cout<<" fPtref = " <<fPtref<<"\n";
740 if(fPtref>1.0) fChi2max=40.;
741 if(fPtref<=1.0) fChi2max=20.;
742 if(fPtref<0.4 ) fChi2max=100.;
743 if(fPtref<0.2 ) fChi2max=40.;
744 // if(fPtref<0.4 ) fChi2max=30.;
745 // if(fPtref<0.2 ) fChi2max=20.;
746 //if(fPtref<0.2 ) fChi2max=10.;
747 //if(fPtref<0.1 ) fChi2max=5.;
748 //cout << "\n Pt = " << fPtref <<"\n"; //stampa
749 RecursiveTracking(list);
754 TVector vecTotLabRef(18);
756 for(lay=5; lay>=0; lay--) {
757 TVector vecLabRef(3);
758 vecLabRef=(*fresult).GetLabTrack(lay);
759 Float_t clustZ=(*fresult).GetZclusterTrack( lay);
761 Int_t lpp=(Int_t)vecLabRef(k);
763 TParticle *p=(TParticle*) gAlice->Particle(lpp);
764 Int_t pcode=p->GetPdgCode();
765 if(pcode==11) vecLabRef(k)=p->GetFirstMother();
767 itot++; vecTotLabRef(itot)=vecLabRef(k);
768 if(vecLabRef(k)==0. && clustZ == -1.) vecTotLabRef(itot) =-3.;
773 (*fresult).Search(vecTotLabRef, labref, freq);
775 //if(freq < 6) labref=-labref; // cinque - sei
776 if(freq < 5) labref=-labref; // cinque - sei
777 (*fresult).SetLabel(labref);
779 // cout<<" progressive track number = "<<j<<"\r";
781 Int_t numOfCluster=(*fresult).GetNumClust();
782 //cout<<" progressive track number = "<<j<<"\n"; // stampa
783 Long_t labITS=(*fresult).GetLabel();
784 //cout << " ITS track label = " << labITS << "\n"; // stampa
785 Int_t lab=track->GetLabel();
786 //cout << " TPC track label = " << lab <<"\n"; // stampa
787 //propagation to vertex
790 if((*fresult).DoNotCross(rbeam)) continue; //no intersection with beampipe
791 (*fresult).Propagation(rbeam);
792 Double_t c00,c10,c11,c20,c21,c22,c30,c31,c32,c33,c40,c41,c42,c43,c44;
793 (*fresult).GetCElements(c00,
797 c40,c41,c42,c43,c44);
799 Double_t pt=TMath::Abs((*fresult).GetPt());
800 Double_t dr=(*fresult).GetD();
801 Double_t z=(*fresult).GetZ();
802 Double_t tgl=(*fresult).GetTgl();
803 Double_t c=(*fresult).GetC();
805 Double_t dz=z-(tgl/cy)*TMath::ASin((*fresult).Arga(rbeam));
807 // cout<<" dr e dz alla fine = "<<dr<<" "<<dz<<"\n"; getchar();
808 Double_t phi=(*fresult).Getphi();
809 Double_t phivertex = phi - TMath::ASin((*fresult).ArgA(rbeam));
810 Double_t duepi=2.*TMath::Pi();
811 if(phivertex>duepi) phivertex-=duepi;
812 if(phivertex<0.) phivertex+=duepi;
813 /////////////////////////////////////////////////////////////
814 Int_t idmodule,idpoint;
815 if(numOfCluster >=5) { // cinque - sei
816 //if(numOfCluster ==6) { // cinque - sei
817 AliITSIOTrack outTrack;
819 ioTrack->SetStatePhi(phi);
820 ioTrack->SetStateZ(z);
821 ioTrack->SetStateD(dr);
822 ioTrack->SetStateTgl(tgl);
823 ioTrack->SetStateC(c);
824 Double_t radius=(*fresult).Getrtrack();
825 ioTrack->SetRadius(radius);
827 if(c>0.) charge=-1; else charge=1;
828 ioTrack->SetCharge(charge);
829 Double_t trackmass=(*fresult).GetMass(); // oggi
830 ioTrack->SetMass(trackmass); // oggi
831 ioTrack->SetCovMatrix(c00,
835 c40,c41,c42,c43,c44);
836 Double_t px=pt*TMath::Cos(phivertex);
837 Double_t py=pt*TMath::Sin(phivertex);
839 Double_t xtrack=dr*TMath::Sin(phivertex);
840 Double_t ytrack=dr*TMath::Cos(phivertex);
841 Double_t ztrack=dz+vgeant(2);
845 ioTrack->SetX(xtrack);
846 ioTrack->SetY(ytrack);
847 ioTrack->SetZ(ztrack);
848 ioTrack->SetLabel(labITS);
849 ioTrack->SetTPCLabel(lab);
853 for(il=0;il<6; il++){
854 ioTrack->SetIdPoint(il,(*fresult).GetIdPoint(il));
855 ioTrack->SetIdModule(il,(*fresult).GetIdModule(il));
859 Float_t q[4]={-1.,-1.,-1.,-1.};
860 Float_t globaldedx=0.;
861 for (il=0;il<6;il++) {
862 idpoint=(*fresult).GetIdPoint(il);
863 idmodule=(*fresult).GetIdModule(il);
864 if(idmodule>0.) *(fvettid[idmodule]+idpoint)=1;
866 ioTrack->SetIdPoint(il,idpoint);
867 ioTrack->SetIdModule(il,idmodule);
868 //// for q definition
871 fITS->ResetRecPoints();
872 gAlice->TreeR()->GetEvent(idmodule);
873 recp=(AliITSRecPoint*)frecPoints->UncheckedAt(idpoint);
874 q[il-2]=recp->GetQ()*(*fresult).Getfcor(il-2);
878 q[0]/=280.; q[1]/=280.;
879 q[2]/=38.; q[3]/=38.;
881 // cout<<" q prima = "<<q[0]<<" "<<q[1]<<" "<<q[2]<<" "<<q[3]<<"\n"; getchar();
886 for (il=0; il<3; il++) {
887 if (q[il]<=q[il+1]) continue;
889 q[il]=q[il+1]; q[il+1]=tmp;
895 // cout<<" q dopo = "<<q[0]<<" "<<q[1]<<" "<<q[2]<<" "<<q[3]<<"\n"; getchar();
904 // cout<<" q dopo if = "<<q[0]<<" "<<q[1]<<" "<<q[2]<<" "<<q[3]<<"\n"; getchar();
906 globaldedx=(q[0]+q[1])/2.;
908 // if(q[3]> 0.) globaldedx=(q[0]+q[1]+q[2]+q[3])/4.;
909 // else globaldedx=(q[0]+q[1]+q[2])/3.;
911 ioTrack->SetdEdx(globaldedx);
912 ioTrack->SetPid(pid->GetPcode(ioTrack));
915 } // end if on numOfCluster
916 //gObjectTable->Print(); // stampa memoria
917 } // end for (int j=minTr; j<=maxTr; j++)
919 static Bool_t first=kTRUE;
922 tfile=new TFile("itstracks.root","RECREATE");
923 //cout<<"I have opened itstracks.root file "<<endl;
929 sprintf(hname,"TreeT%d",evNumber);
930 cout << "Number of saved ITS tracks " << tracktree1.GetEntries() << endl;
931 tracktree1.Write(hname);
933 TTree *fAli=gAlice->TreeK();
935 if (fAli) fileAli =fAli->GetCurrentFile();
937 ////////////////////////////////////////////////////////////////////
939 printf("delete vectors\n");
941 if(fvettid) delete [] fvettid;
942 if(fresult) {delete fresult; fresult=0;}
944 //______________________________________________________________________
945 void AliITSTrackerV1::RecursiveTracking(TList *trackITSlist) {
946 // This function perform the recursive tracking in ITS detectors
947 // reference is a pointer to the final best track
948 // Origin A. Badala' and G.S. Pappalardo:
949 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
950 // The authors thank Mariana Bondila to have help them to resolve some
951 // problems. July-2000
953 //Rlayer[0]=4.; Rlayer[1]=7.; Rlayer[2]=14.9;
954 // Rlayer[3]=23.8; Rlayer[4]=39.1; Rlayer[5]=43.6; //vecchio
956 //////////////////////
957 Float_t sigmaphil[6], sigmazl[6];
958 sigmaphil[0]=1.44e-6/(fAvrad[0]*fAvrad[0]);
959 sigmaphil[1]=1.44e-6/(fAvrad[1]*fAvrad[1]);
960 sigmaphil[2]=1.444e-5/(fAvrad[2]*fAvrad[2]);
961 sigmaphil[3]=1.444e-5/(fAvrad[3]*fAvrad[3]);
962 sigmaphil[4]=4e-6/(fAvrad[4]*fAvrad[4]);
963 sigmaphil[5]=4e-6/(fAvrad[5]*fAvrad[5]);
970 ///////////////////////////////////////////////////////////
972 AliITSgeom *g1 = fITS->GetITSgeom();
973 AliITSRecPoint *recp;
974 for(index =0; index<trackITSlist->GetSize(); index++) {
975 AliITSTrackV1 *trackITS = (AliITSTrackV1 *) trackITSlist->At(index);
976 if((*trackITS).GetLayer()==7) fresult->SetChi2(10.223e140);
977 // cout <<" Layer inizio = "<<(*trackITS).GetLayer()<<"\n";
978 // cout<<"fvtrack =" <<"\n";
979 // cout << (*trackITS)(0) << " "<<(*trackITS)(1)<<" "
980 // <<(*trackITS)(2)<<" "<<(*trackITS)(3)<<" "
981 // <<(*trackITS)(4)<<"\n";
982 // cout<< " rtrack = "<<(*trackITS).Getrtrack()<<"\n";
983 // cout<< " Pt = "<<(*trackITS).GetPt()<<"\n";
985 Double_t chi2Now, chi2Ref;
986 Float_t numClustRef = fresult->GetNumClust();
987 if((*trackITS).GetLayer()==1 ) {
988 chi2Now = trackITS->GetChi2();
989 Float_t numClustNow = trackITS->GetNumClust();
990 if(trackITS->GetNumClust())
991 chi2Now /= (Double_t)trackITS->GetNumClust();
992 chi2Ref = fresult->GetChi2();
993 if(fresult->GetNumClust())
994 chi2Ref /= (Double_t)fresult->GetNumClust();
995 //cout<<" chi2Now and chi2Ref = "<<chi2Now<<" "<<chi2Ref<<"\n";
996 if( numClustNow > numClustRef ) {*fresult = *trackITS;}
997 if((numClustNow == numClustRef )&&
998 (chi2Now < chi2Ref)) {
999 *fresult = *trackITS;
1004 if(trackITS->Getfnoclust()>=2) continue;
1005 Float_t numClustNow = trackITS->GetNumClust();
1007 chi2Now = trackITS->GetChi2();
1009 if(numClustNow<numClustRef && chi2Now>fresult->GetChi2()) continue;
1010 //cout<<" chi2Now = "<<chi2Now<<"\n";
1012 chi2Now/=numClustNow;
1013 if(fPtref > 1.0 && chi2Now > 30.) continue;
1014 if((fPtref >= 0.6 && fPtref<=1.0) && chi2Now > 40.) continue;
1015 // if((fPtref <= 0.6 && fPtref>0.2)&& chi2Now > 40.) continue;
1016 // if(fPtref <= 0.2 && chi2Now > 8.) continue;
1017 if((fPtref <= 0.6 && fPtref>0.2)&& chi2Now > 30.) continue;
1018 if(fPtref <= 0.2 && chi2Now > 7.) continue;
1019 /////////////////////////////
1022 Int_t layerInit = (*trackITS).GetLayer();
1023 Int_t layernew = layerInit - 2;// -1 for new layer, -1 for matrix index
1025 Int_t ladp, ladm, detp,detm,ladinters,detinters;
1026 Int_t layerfin=layerInit-1;
1027 // cout<<"Prima di intersection \n";
1028 Int_t outinters=Intersection(*trackITS,layerfin,ladinters,detinters);
1029 // cout<<" outinters = "<<outinters<<"\n";
1030 // cout<<" Layer ladder detector intersection ="
1031 // <<layerfin<<" "<<ladinters<<" "<<detinters<<"\n";
1032 // cout << " phiinters zinters = "<<(*trackITS)(0)
1033 // << " "<<(*trackITS)(1)<<"\n"; getchar();
1034 if(outinters==-1) continue;
1036 (*trackITS).SetLayer(layerfin); // oggi
1037 (*trackITS).Setfcor(); // oggi
1039 TVector toucLad(9), toucDet(9);
1040 Int_t lycur=layerfin;
1043 if(ladm <= 0) ladm=fNlad[layerfin-1];
1044 if(ladp > fNlad[layerfin-1]) ladp=1;
1049 toucLad(0)=ladinters; toucLad(1)=ladm; toucLad(2)=ladp;
1050 toucLad(3)=ladinters; toucLad(4)=ladm; toucLad(5)=ladp;
1051 toucLad(6)=ladinters; toucLad(7)=ladm; toucLad(8)=ladp;
1052 toucDet(0)=detinters; toucDet(1)=detinters; toucDet(2)=detinters;
1053 if(detm > 0 && detp <= fNdet[layerfin-1]) {
1055 toucDet(3)=detm; toucDet(4)=detm; toucDet(5)=detm;
1056 toucDet(6)=detp; toucDet(7)=detp; toucDet(8)=detp;
1058 if(detm > 0 && detp > fNdet[layerfin-1]) {
1060 toucDet(3)=detm; toucDet(4)=detm; toucDet(5)=detm;
1062 if(detm <= 0 && detp <= fNdet[layerfin-1]) {
1064 toucDet(3)=detp; toucDet(4)=detp; toucDet(5)=detp;
1067 Float_t epsphi=5.0, epsz=5.0;
1068 if(fPtref<0.2) {epsphi=3.; epsz=3.;}
1069 // new definition of idetot e toucLad e toucDet to be
1070 // transformed in a method
1071 // these values could be modified
1072 Float_t pigre=TMath::Pi();
1073 Float_t rangephi=5., rangez=5.;
1074 if(layerfin==1 || layerfin ==2){
1075 rangephi=40.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1076 (*trackITS).GetSigmaphi());
1077 rangez = 40.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1078 (*trackITS).GetSigmaZ());
1080 if(layerfin==3 || layerfin ==4){
1081 //rangephi=30.*fepsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1082 // (*trackITS).GetSigmaphi());
1083 //rangez = 40.*fepsz*TMath::Sqrt(sigmazl[layerfin-1]+
1084 // (*trackITS).GetSigmaZ());
1085 rangephi=40.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1086 (*trackITS).GetSigmaphi());
1087 rangez = 50.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1088 (*trackITS).GetSigmaZ());
1090 if(layerfin==5 || layerfin ==6){
1091 rangephi=20.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1092 (*trackITS).GetSigmaphi());
1093 rangez =5.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1094 (*trackITS).GetSigmaZ());
1096 Float_t phinters, zinters;
1097 phinters=(*trackITS).Getphi();
1098 zinters=(*trackITS).GetZ();
1099 Float_t distz = 0.0;
1100 Float_t phicm, phicp, distphim, distphip;
1102 if(phinters>fphimax[layerfin-1][ladm-1]) phicm=phinters-2*pigre; //corretto il 20-11-2001
1103 distphim=TMath::Abs(phicm-fphimax[layerfin-1][ladm-1]); //corretto il 20-11-2001
1105 //cout<<" fNlad[layerfin-1] e ladp = "<<fNlad[layerfin-1]<<" "<<ladp<<endl;
1106 if(phinters>fphimin[layerfin-1][ladp-1]) phicp=phinters-2.*pigre; //corretto il 20-11-2001
1107 distphip=TMath::Abs(phicp-fphimin[layerfin-1][ladp-1]); //corretto il 20-11-2001
1111 toucLad(0)=ladinters; toucDet(0)=detinters;
1112 if(detm>0) distz=TMath::Abs(zinters-fzmax[layerfin-1][detm-1]);
1113 if(detm>0 && rangez>=distz){
1115 idetot++; toucLad(idetot-1)=ladinters; toucDet(idetot-1)=detm;
1116 if(rangephi>=distphim){
1118 toucLad(idetot-1)=ladm;
1119 toucDet(idetot-1)=detinters;
1121 toucLad(idetot-1)=ladm;
1122 toucDet(idetot-1)=detm;
1124 if(rangephi>=distphip){
1126 toucLad(idetot-1)=ladp;
1127 toucDet(idetot-1)=detinters;
1129 toucLad(idetot-1)=ladp;
1130 toucDet(idetot-1)=detm;
1133 if(detp<=fNdet[layerfin-1])
1134 distz=TMath::Abs(zinters-fzmin[layerfin-1][detp-1]);
1135 if(detp<=fNdet[layerfin-1] && rangez>=distz){
1137 idetot++; toucLad(idetot-1)=ladinters; toucDet(idetot-1)=detp;
1138 if(rangephi>=distphim){
1139 idetot++; toucLad(idetot-1)=ladm; toucDet(idetot-1)=detp;
1142 toucLad(idetot-1)=ladm;
1143 toucDet(idetot-1)=detinters;
1146 if(rangephi>=distphip){
1148 toucLad(idetot-1)=ladp;
1149 toucDet(idetot-1)=detp;
1152 toucLad(idetot-1)=ladp;
1153 toucDet(idetot-1)=detinters;
1156 } //end detm<fNdet[.......
1158 if(flagzmin == 0 && flagzmax==0){
1159 if(rangephi>=distphim){
1161 toucLad(idetot-1)=ladm;
1162 toucDet(idetot-1)=detinters;
1164 if(rangephi>=distphip){
1166 toucLad(idetot-1)=ladp;
1167 toucDet(idetot-1)=detinters;
1170 ////////////////////////////////////////////////////////////
1172 for (iriv=0; iriv<idetot; iriv++) { //for on detectors
1173 ///////////////////////////////////////////////////////
1174 /*** Rec points sorted by module *****/
1175 /**************************************/
1177 indexmod = g1->GetModuleIndex(lycur,(Int_t)toucLad(iriv),
1178 (Int_t)toucDet(iriv));
1179 fITS->ResetRecPoints();
1180 gAlice->TreeR()->GetEvent(indexmod);
1181 Int_t npoints=frecPoints->GetEntries();
1184 for(indnew=0; indnew<npoints; indnew++){
1185 if (*(fvettid[indexmod]+indnew)==0)
1186 recp =(AliITSRecPoint*)frecPoints->UncheckedAt(indnew);
1189 TVector cluster(3),vecclust(9);
1190 //vecclust(6)=vecclust(7)=vecclust(8)=-1.;
1192 // now vecclust is with cylindrical cohordinates
1193 vecclust(0)=(Float_t)fRecCylR[indexmod][indnew];
1194 vecclust(1)=(Float_t)fRecCylPhi[indexmod][indnew];
1195 vecclust(2)=(Float_t)fRecCylZ[indexmod][indnew];
1196 vecclust(3) = (Float_t)recp->fTracks[0];
1197 vecclust(4) = (Float_t)indnew;
1198 vecclust(5) = (Float_t)indexmod;
1199 vecclust(6) = (Float_t)recp->fTracks[0];
1200 vecclust(7) = (Float_t)recp->fTracks[1];
1201 vecclust(8) = (Float_t)recp->fTracks[2];
1202 sigma[0] = (Double_t) recp->GetSigmaX2();
1203 sigma[1] = (Double_t) recp->GetSigmaZ2();
1205 cluster(0)=fRecCylR[indexmod][indnew];
1206 cluster(1)=fRecCylPhi[indexmod][indnew];
1207 cluster(2)=fRecCylZ[indexmod][indnew];
1209 // cout<<" layer = "<<play<<"\n";
1210 // cout<<" cluster prima = "<<vecclust(0)<<" "
1211 // <<vecclust(1)<<" "
1212 // <<vecclust(2)<<"\n"; getchar();
1214 Float_t sigmatotphi, sigmatotz;
1215 // Float_t epsphi=5.0, epsz=5.0;
1216 //if(fPtref<0.2) {epsphi=3.; epsz=3.;}
1217 Double_t rTrack=(*trackITS).Getrtrack();
1218 Double_t sigmaphi=sigma[0]/(rTrack*rTrack);
1219 sigmatotphi=epsphi*TMath::Sqrt(sigmaphi +
1220 (*trackITS).GetSigmaphi());
1221 sigmatotz=epsz*TMath::Sqrt(sigma[1] +
1222 (*trackITS).GetSigmaZ());
1223 //cout<<"cluster e sigmatotphi e track = "<<cluster(0)
1224 // <<" "<<cluster(1)<<" "<<sigmatotphi<<" "
1225 // <<vecclust(3)<<"\n";
1226 //if(vecclust(3)==481) getchar();
1227 if(cluster(1)<6. && (*trackITS).Getphi()>6.)
1228 cluster(1)=cluster(1)+(2.*TMath::Pi());
1229 if(cluster(1)>6. && (*trackITS).Getphi()<6.)
1230 cluster(1)=cluster(1)-(2.*TMath::Pi());
1231 if(TMath::Abs(cluster(1)-(*trackITS).Getphi())>sigmatotphi)
1233 // cout<<" supero sigmaphi \n";
1234 AliITSTrackV1 *newTrack = new AliITSTrackV1((*trackITS));
1235 //(*newTrack).SetLayer((*trackITS).GetLayer()-1);
1236 if (TMath::Abs(rTrack-cluster(0))/rTrack>1e-6)
1237 (*newTrack).Correct(Double_t(cluster(0)));
1238 //cout<<" cluster(2) e(*newTrack).GetZ()="<<cluster(2)<<" "
1239 // << (*newTrack).GetZ()<<"\n";
1240 if(TMath::Abs(cluster(2)-(*newTrack).GetZ()) > sigmatotz){
1244 Double_t sigmanew[2];
1245 sigmanew[0]= sigmaphi;
1246 sigmanew[1]=sigma[1];
1250 // Double_t chi2pred=newTrack->GetPredChi2(m,sigmanew);
1251 // cout<<" chi2pred = "<<chi2pred<<"\n";
1252 // if(chi2pred>fChi2max) continue; //aggiunto il 30-7-2001
1253 if(iriv == 0) flaghit=1;
1254 (*newTrack).AddMS(frl); // add the multiple scattering
1255 //matrix to the covariance matrix
1256 (*newTrack).AddEL(frl,1.,0);
1259 KalmanFilterVert(newTrack,cluster,sigmanew);
1260 //KalmanFilterVert(newTrack,cluster,sigmanew,chi2pred);
1262 KalmanFilter(newTrack,cluster,sigmanew);
1264 (*newTrack).PutCluster(layernew, vecclust);
1265 newTrack->AddClustInTrack();
1266 listoftrack.AddLast(newTrack);
1268 } // end of for on detectors (iriv)
1269 }//end if(outinters==0)
1271 if(flaghit==0 || outinters==-2) {
1272 AliITSTrackV1 *newTrack = new AliITSTrackV1(*trackITS);
1273 (*newTrack).Setfnoclust();
1274 //(*newTrack).SetLayer((*trackITS).GetLayer()-1);
1275 (*newTrack).AddMS(frl); // add the multiple scattering matrix
1276 // to the covariance matrix
1277 (*newTrack).AddEL(frl,1.,0);
1278 listoftrack.AddLast(newTrack);
1281 //gObjectTable->Print(); // stampa memoria
1283 RecursiveTracking(&listoftrack);
1284 listoftrack.Delete();
1285 } // end of for on tracks (index)
1287 //gObjectTable->Print(); // stampa memoria
1289 //______________________________________________________________________
1290 Int_t AliITSTrackerV1::Intersection(AliITSTrackV1 &track,Int_t layer,
1291 Int_t &ladder,Int_t &detector) {
1292 // Origin A. Badala' and G.S. Pappalardo
1293 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1294 // Found the intersection and the detector
1296 Double_t rk=fAvrad[layer-1];
1297 if(track.DoNotCross(rk)){ /*cout<< " Do not cross \n";*/ return -1;}
1298 track.Propagation(rk);
1299 Double_t zinters=track.GetZ();
1300 Double_t phinters=track.Getphi();
1301 //cout<<"zinters = "<<zinters<<" phinters = "<<phinters<<"\n";
1305 TVector distZCenter(2);
1309 for(iD = 1; iD<= fNdet[layer-1]; iD++) {
1310 if(zinters > fzmin[layer-1][iD-1] && zinters <= fzmax[layer-1][iD-1]) {
1312 cout<< " Errore su iz in Intersection \n";
1315 listDet(iz)= iD; distZCenter(iz)=TMath::Abs(zinters-det(2));
1321 if(iz==0) {/* cout<< " No detector along Z \n";*/ return -2;}
1322 detector=Int_t (listDet(0));
1323 if(iz>1 && (distZCenter(0)>distZCenter(1))) detector=Int_t (listDet(1));
1326 TVector distPhiCenter(2);
1328 Double_t pigre=TMath::Pi();
1330 for(iLd = 1; iLd<= fNlad[layer-1]; iLd++) {
1331 Double_t phimin=fphimin[layer-1][iLd-1];
1332 Double_t phimax=fphimax[layer-1][iLd-1];
1333 Double_t phidet=fphidet[layer-1][iLd-1];
1334 Double_t phiconfr=phinters;
1336 //if(phimin <5.5) {cout<<" Error in Intersection for phi \n";
1339 if(phinters>(1.5*pigre)) phiconfr=phinters-(2.*pigre);
1340 if(phidet>(1.5*pigre)) phidet-=(2.*pigre);
1342 if(phiconfr>phimin && phiconfr<= phimax) {
1344 cout<< " Errore su ip in Intersection \n"; getchar();
1347 distPhiCenter(ip)=TMath::Abs(phiconfr-phidet); ip++;
1351 if(ip==0) { cout<< " No detector along phi \n"; getchar();}
1352 ladder=Int_t (listLad(0));
1353 if(ip>1 && (distPhiCenter(0)>distPhiCenter(1))) ladder=Int_t (listLad(1));
1356 //______________________________________________________________________
1357 void AliITSTrackerV1::KalmanFilter(AliITSTrackV1 *newTrack,TVector &cluster,
1359 //Origin A. Badala' and G.S. Pappalardo:
1360 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1361 // Kalman filter without vertex constraint
1362 ////// Evaluation of the measurement vector ////////////////////////
1364 Double_t rk,phik,zk;
1365 rk=cluster(0); phik=cluster(1); zk=cluster(2);
1367 //////////////////////// Evaluation of the error matrix V /////////
1368 Double_t v00=sigma[0];
1369 Double_t v11=sigma[1];
1370 ////////////////////////////////////////////////////////////////////
1371 Double_t cin00,cin10,cin20,cin30,cin40,cin11,cin21,cin31,cin41,cin22,
1372 cin32,cin42,cin33,cin43,cin44;
1374 newTrack->GetCElements(cin00,
1377 cin30,cin31,cin32,cin33,
1378 cin40,cin41,cin42,cin43,cin44); //get C matrix
1379 Double_t rold00=cin00+v00;
1380 Double_t rold10=cin10;
1381 Double_t rold11=cin11+v11;
1382 ////////////////////// R matrix inversion /////////////////////////
1383 Double_t det=rold00*rold11-rold10*rold10;
1384 Double_t r00=rold11/det;
1385 Double_t r10=-rold10/det;
1386 Double_t r11=rold00/det;
1387 ////////////////////////////////////////////////////////////////////
1388 Double_t k00=cin00*r00+cin10*r10;
1389 Double_t k01=cin00*r10+cin10*r11;
1390 Double_t k10=cin10*r00+cin11*r10;
1391 Double_t k11=cin10*r10+cin11*r11;
1392 Double_t k20=cin20*r00+cin21*r10;
1393 Double_t k21=cin20*r10+cin21*r11;
1394 Double_t k30=cin30*r00+cin31*r10;
1395 Double_t k31=cin30*r10+cin31*r11;
1396 Double_t k40=cin40*r00+cin41*r10;
1397 Double_t k41=cin40*r10+cin41*r11;
1398 Double_t x0,x1,x2,x3,x4;
1399 newTrack->GetXElements(x0,x1,x2,x3,x4); // get the state vector
1400 Double_t savex0=x0, savex1=x1;
1401 x0+=k00*(m[0]-savex0)+k01*(m[1]-savex1);
1402 x1+=k10*(m[0]-savex0)+k11*(m[1]-savex1);
1403 x2+=k20*(m[0]-savex0)+k21*(m[1]-savex1);
1404 x3+=k30*(m[0]-savex0)+k31*(m[1]-savex1);
1405 x4+=k40*(m[0]-savex0)+k41*(m[1]-savex1);
1406 Double_t c00,c10,c20,c30,c40,c11,c21,c31,c41,c22,c32,c42,c33,c43,c44;
1407 c00=cin00-k00*cin00-k01*cin10;
1408 c10=cin10-k00*cin10-k01*cin11;
1409 c20=cin20-k00*cin20-k01*cin21;
1410 c30=cin30-k00*cin30-k01*cin31;
1411 c40=cin40-k00*cin40-k01*cin41;
1412 c11=cin11-k10*cin10-k11*cin11;
1413 c21=cin21-k10*cin20-k11*cin21;
1414 c31=cin31-k10*cin30-k11*cin31;
1415 c41=cin41-k10*cin40-k11*cin41;
1416 c22=cin22-k20*cin20-k21*cin21;
1417 c32=cin32-k20*cin30-k21*cin31;
1418 c42=cin42-k20*cin40-k21*cin41;
1419 c33=cin33-k30*cin30-k31*cin31;
1420 c43=cin43-k30*cin40-k31*cin41;
1421 c44=cin44-k40*cin40-k41*cin41;
1422 newTrack->PutXElements(x0,x1,x2,x3,x4); // put the new state vector
1423 newTrack->PutCElements(c00,
1427 c40,c41,c42,c43,c44); // put in track the
1429 Double_t vmcold00=v00-c00;
1430 Double_t vmcold10=-c10;
1431 Double_t vmcold11=v11-c11;
1432 ////////////////////// Matrix vmc inversion ///////////////////////
1433 det=vmcold00*vmcold11-vmcold10*vmcold10;
1434 Double_t vmc00=vmcold11/det;
1435 Double_t vmc10=-vmcold10/det;
1436 Double_t vmc11=vmcold00/det;
1437 ////////////////////////////////////////////////////////////////////
1438 Double_t chi2=(m[0]-x0)*( vmc00*(m[0]-x0) + 2.*vmc10*(m[1]-x1) ) +
1439 (m[1]-x1)*vmc11*(m[1]-x1);
1440 newTrack->SetChi2(newTrack->GetChi2()+chi2);
1442 //----------------------------------------------------------------------
1443 //void AliITSTrackerV1::KalmanFilterVert(AliITSTrackV1 *newTrack,
1444 // TVector &cluster,Double_t sigma[2]){
1445 void AliITSTrackerV1::KalmanFilterVert(AliITSTrackV1 *newTrack,
1446 TVector &cluster,Double_t sigma[2]
1447 /*, Double_t chi2pred*/){
1448 //Origin A. Badala' and G.S. Pappalardo:
1449 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1450 // Kalman filter with vertex constraint
1451 ///////////////////// Evaluation of the measurement vector m ////////
1453 Double_t rk,phik,zk;
1454 rk=cluster(0); phik=cluster(1); zk=cluster(2);
1456 Double_t cc=(*newTrack).GetC();
1457 Double_t zv=(*newTrack).GetZv();
1458 Double_t dv=(*newTrack).GetDv();
1460 Double_t tgl= (zk-zv)*cy/TMath::ASin(cy*rk);
1462 /////////////////////// Evaluation of the error matrix V //////////
1463 Int_t layer=newTrack->GetLayer();
1464 Double_t v00=sigma[0];
1465 Double_t v11=sigma[1];
1466 Double_t v31=sigma[1]/rk;
1467 Double_t sigmaDv=newTrack->GetsigmaDv();
1468 Double_t v22=sigmaDv*sigmaDv + newTrack->Getd2(layer-1);
1469 Double_t v32=newTrack->Getdtgl(layer-1);
1470 Double_t sigmaZv=newTrack->GetsigmaZv();
1471 Double_t v33=(sigma[1]+sigmaZv*sigmaZv)/(rk*rk)+newTrack->Gettgl2(layer-1);
1472 //////////////////////////////////////////////////////////////////
1473 Double_t cin00,cin10,cin11,cin20,cin21,cin22,
1474 cin30,cin31,cin32,cin33,cin40,cin41,cin42,cin43,cin44;
1475 newTrack->GetCElements(cin00,
1478 cin30,cin31,cin32,cin33,
1479 cin40,cin41,cin42,cin43,cin44); //get C matrix
1487 r[3][1]=cin31+sigma[1]/rk;
1488 r[2][2]=cin22+sigmaDv*sigmaDv+newTrack->Getd2(layer-1);
1489 r[3][2]=cin32+newTrack->Getdtgl(layer-1);
1490 r[3][3]=cin33+(sigma[1]+sigmaZv*sigmaZv)/(rk*rk)+
1491 newTrack->Gettgl2(layer-1);
1492 r[0][1]=r[1][0]; r[0][2]=r[2][0]; r[0][3]=r[3][0];
1493 r[1][2]=r[2][1]; r[1][3]=r[3][1]; r[2][3]=r[3][2];
1494 ///////////////////// Matrix R inversion //////////////////////////
1498 Int_t ll[kn],mm[kn];
1501 for(k=0; k<kn; k++) {
1505 for(j=k; j<kn ; j++) {
1506 for (i=j; i<kn; i++) {
1507 if(TMath::Abs(big) < TMath::Abs(r[i][j]) ) {
1517 for(i=0; i<kn; i++) {
1526 for(j=0; j<kn; j++) {
1535 cout << "Singular matrix\n";
1537 for(i=0; i<kn; i++) {
1538 if(i == k) { continue; }
1539 r[i][k]=r[i][k]/(-big);
1542 for(i=0; i<kn; i++) {
1544 for(j=0; j<kn; j++) {
1545 if(i == k || j == k) continue;
1546 r[i][j]=hold*r[k][j]+r[i][j];
1550 for(j=0; j<kn; j++) {
1551 if(j == k) continue;
1552 r[k][j]=r[k][j]/big;
1560 for(k=kn-1; k>=0; k--) {
1563 for (j=0; j<kn; j++) {
1571 for (i=0; i<kn; i++) {
1578 ////////////////////////////////////////////////////////////////////
1579 Double_t k00=cin00*r[0][0]+cin10*r[1][0]+cin20*r[2][0]+cin30*r[3][0];
1580 Double_t k01=cin00*r[1][0]+cin10*r[1][1]+cin20*r[2][1]+cin30*r[3][1];
1581 Double_t k02=cin00*r[2][0]+cin10*r[2][1]+cin20*r[2][2]+cin30*r[3][2];
1582 Double_t k03=cin00*r[3][0]+cin10*r[3][1]+cin20*r[3][2]+cin30*r[3][3];
1583 Double_t k10=cin10*r[0][0]+cin11*r[1][0]+cin21*r[2][0]+cin31*r[3][0];
1584 Double_t k11=cin10*r[1][0]+cin11*r[1][1]+cin21*r[2][1]+cin31*r[3][1];
1585 Double_t k12=cin10*r[2][0]+cin11*r[2][1]+cin21*r[2][2]+cin31*r[3][2];
1586 Double_t k13=cin10*r[3][0]+cin11*r[3][1]+cin21*r[3][2]+cin31*r[3][3];
1587 Double_t k20=cin20*r[0][0]+cin21*r[1][0]+cin22*r[2][0]+cin32*r[3][0];
1588 Double_t k21=cin20*r[1][0]+cin21*r[1][1]+cin22*r[2][1]+cin32*r[3][1];
1589 Double_t k22=cin20*r[2][0]+cin21*r[2][1]+cin22*r[2][2]+cin32*r[3][2];
1590 Double_t k23=cin20*r[3][0]+cin21*r[3][1]+cin22*r[3][2]+cin32*r[3][3];
1591 Double_t k30=cin30*r[0][0]+cin31*r[1][0]+cin32*r[2][0]+cin33*r[3][0];
1592 Double_t k31=cin30*r[1][0]+cin31*r[1][1]+cin32*r[2][1]+cin33*r[3][1];
1593 Double_t k32=cin30*r[2][0]+cin31*r[2][1]+cin32*r[2][2]+cin33*r[3][2];
1594 Double_t k33=cin30*r[3][0]+cin31*r[3][1]+cin32*r[3][2]+cin33*r[3][3];
1595 Double_t k40=cin40*r[0][0]+cin41*r[1][0]+cin42*r[2][0]+cin43*r[3][0];
1596 Double_t k41=cin40*r[1][0]+cin41*r[1][1]+cin42*r[2][1]+cin43*r[3][1];
1597 Double_t k42=cin40*r[2][0]+cin41*r[2][1]+cin42*r[2][2]+cin43*r[3][2];
1598 Double_t k43=cin40*r[3][0]+cin41*r[3][1]+cin42*r[3][2]+cin43*r[3][3];
1600 Double_t x0,x1,x2,x3,x4;
1601 newTrack->GetXElements(x0,x1,x2,x3,x4); // get the state vector
1602 Double_t savex0=x0, savex1=x1, savex2=x2, savex3=x3;
1603 x0+=k00*(m[0]-savex0)+k01*(m[1]-savex1)+k02*(m[2]-savex2)+
1605 x1+=k10*(m[0]-savex0)+k11*(m[1]-savex1)+k12*(m[2]-savex2)+
1607 x2+=k20*(m[0]-savex0)+k21*(m[1]-savex1)+k22*(m[2]-savex2)+
1609 x3+=k30*(m[0]-savex0)+k31*(m[1]-savex1)+k32*(m[2]-savex2)+
1611 x4+=k40*(m[0]-savex0)+k41*(m[1]-savex1)+k42*(m[2]-savex2)+
1613 Double_t c00,c10,c20,c30,c40,c11,c21,c31,c41,c22,c32,c42,c33,c43,c44;
1614 c00=cin00-k00*cin00-k01*cin10-k02*cin20-k03*cin30;
1615 c10=cin10-k00*cin10-k01*cin11-k02*cin21-k03*cin31;
1616 c20=cin20-k00*cin20-k01*cin21-k02*cin22-k03*cin32;
1617 c30=cin30-k00*cin30-k01*cin31-k02*cin32-k03*cin33;
1618 c40=cin40-k00*cin40-k01*cin41-k02*cin42-k03*cin43;
1619 c11=cin11-k10*cin10-k11*cin11-k12*cin21-k13*cin31;
1620 c21=cin21-k10*cin20-k11*cin21-k12*cin22-k13*cin32;
1621 c31=cin31-k10*cin30-k11*cin31-k12*cin32-k13*cin33;
1622 c41=cin41-k10*cin40-k11*cin41-k12*cin42-k13*cin43;
1623 c22=cin22-k20*cin20-k21*cin21-k22*cin22-k23*cin32;
1624 c32=cin32-k20*cin30-k21*cin31-k22*cin32-k23*cin33;
1625 c42=cin42-k20*cin40-k21*cin41-k22*cin42-k23*cin43;
1626 c33=cin33-k30*cin30-k31*cin31-k32*cin32-k33*cin33;
1627 c43=cin43-k30*cin40-k31*cin41-k32*cin42-k33*cin43;
1628 c44=cin44-k40*cin40-k41*cin41-k42*cin42-k43*cin43;
1630 newTrack->PutXElements(x0,x1,x2,x3,x4); // put the new state vector
1631 newTrack->PutCElements(c00,
1635 c40,c41,c42,c43,c44); // put in track the
1638 vmc[0][0]=v00-c00; vmc[1][0]=-c10; vmc[2][0]=-c20; vmc[3][0]=-c30;
1639 vmc[1][1]=v11-c11; vmc[2][1]=-c21; vmc[3][1]=v31-c31;
1640 vmc[2][2]=v22-c22; vmc[3][2]=v32-c32;
1642 vmc[0][1]=vmc[1][0]; vmc[0][2]=vmc[2][0]; vmc[0][3]=vmc[3][0];
1643 vmc[1][2]=vmc[2][1]; vmc[1][3]=vmc[3][1];
1644 vmc[2][3]=vmc[3][2];
1645 /////////////////////// vmc matrix inversion ///////////////////////
1647 for(k=0; k<kn; k++) {
1651 for(j=k; j<kn ; j++) {
1652 for (i=j; i<kn; i++) {
1653 if(TMath::Abs(big) < TMath::Abs(vmc[i][j]) ) {
1663 for(i=0; i<kn; i++) {
1665 vmc[k][i]=vmc[j][i];
1672 for(j=0; j<kn; j++) {
1674 vmc[j][k]=vmc[j][i];
1681 cout << "Singular matrix\n";
1683 for(i=0; i<kn; i++) {
1684 if(i == k) continue;
1685 vmc[i][k]=vmc[i][k]/(-big);
1688 for(i=0; i<kn; i++) {
1690 for(j=0; j<kn; j++) {
1691 if(i == k || j == k) continue;
1692 vmc[i][j]=hold*vmc[k][j]+vmc[i][j];
1696 for(j=0; j<kn; j++) {
1697 if(j == k) continue;
1698 vmc[k][j]=vmc[k][j]/big;
1706 for(k=kn-1; k>=0; k--) {
1709 for (j=0; j<kn; j++) {
1711 vmc[j][k]=-vmc[j][i];
1717 for (i=0; i<kn; i++) {
1719 vmc[k][i]=-vmc[j][i];
1724 ////////////////////////////////////////////////////////////////////
1725 Double_t chi2=(m[0]-x0)*( vmc[0][0]*(m[0]-x0) + 2.*vmc[1][0]*(m[1]-x1) +
1726 2.*vmc[2][0]*(m[2]-x2)+ 2.*vmc[3][0]*(m[3]-x3) )+
1727 (m[1]-x1)* ( vmc[1][1]*(m[1]-x1) + 2.*vmc[2][1]*(m[2]-x2)+
1728 2.*vmc[3][1]*(m[3]-x3) ) +
1729 (m[2]-x2)* ( vmc[2][2]*(m[2]-x2)+ 2.*vmc[3][2]*(m[3]-x3) ) +
1730 (m[3]-x3)*vmc[3][3]*(m[3]-x3);
1731 //cout<<" chi2 kalman = "<<chi2<<"\n"; getchar();
1732 newTrack->SetChi2(newTrack->GetChi2()+chi2);
1733 // newTrack->SetChi2(newTrack->GetChi2()+chi2pred);