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 // The purpose of this class is to permorm the ITS tracking. The
19 // constructor has the task to inizialize some private members. The method
20 // DoTracking is written to be called by a macro. It gets the event number,
21 // the minimum and maximum order number of TPC tracks that are to be tracked
22 // trough the ITS, and the file where the recpoints are registered. The
23 // method Recursivetracking is a recursive function that performs the
24 // tracking trough the ITS The method Intersection found the layer, ladder
25 // and detector whre the intersection take place and caluclate the
26 // cohordinates of this intersection. It returns an integer that is 0 if the
27 // intersection has been found successfully. The two mwthods Kalmanfilter
28 // and kalmanfiltervert operate the kalmanfilter without and with the vertex
29 // imposition respectively. The authors thank Mariana Bondila to have help
30 // them to resolve some problems. July-2000
32 #include <Riostream.h>
33 #include <Riostream.h>
39 #include <TStopwatch.h>
41 #include "TParticle.h"
43 #include "AliLoader.h"
45 #include "AliITSsegmentationSSD.h"
46 #include "AliITSgeomSPD.h"
47 #include "AliITSgeomSDD.h"
48 #include "AliITSgeomSSD.h"
49 #include "AliITSgeom.h"
50 #include "AliITSRecPoint.h"
52 #include "AliKalmanTrack.h"
54 #include "AliITSTrackV1.h"
55 #include "AliITSIOTrack.h"
56 #include "AliITSRad.h"
57 #include "../TPC/AliTPCtracker.h"
58 #include "AliITSTrackerV1.h"
59 #include "AliITSVertex.h"
60 #include "AliITSPid.h"
62 ClassImp(AliITSTrackerV1)
63 //______________________________________________________________________
64 AliITSTrackerV1::AliITSTrackerV1() {
77 for(ia=0; ia<6; ia++) {
95 //______________________________________________________________________
96 AliITSTrackerV1::AliITSTrackerV1(AliITS* IITTSS, Int_t evnumber, Bool_t flag) {
97 //Origin A. Badala' and G.S. Pappalardo:
98 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
99 // Class constructor. It does some initializations.
101 //PH Initialisation taken from the default constructor
116 Int_t imax = 200,jmax = 450;
117 frl = new AliITSRad(imax,jmax);
119 ////////// gets information on geometry /////////////////////////////
120 AliITSgeom *g1 = fITS->GetITSgeom();
125 for(ia=0; ia<6; ia++) {
126 fNlad[ia]=g1->GetNladders(ia+1);
127 fNdet[ia]=g1->GetNdetectors(ia+1);
128 //cout<<fNlad[i]<<" "<<fNdet[i]<<"\n";
131 //cout<<" mean radius = ";
133 for(ib=0; ib<6; ib++) {
134 g1->GetCenterThetaPhi(ib+1,ll,dd,det);
135 Double_t r1=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
136 g1->GetCenterThetaPhi(ib+1,ll,dd+1,det);
137 Double_t r2=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
138 fAvrad[ib]=(r1+r2)/2.;
139 //cout<<fAvrad[ib]<<" ";
141 //cout<<"\n"; getchar();
143 fDetx[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDx();
144 fDetz[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDz();
146 fDetx[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDx();
147 fDetz[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDz();
149 fDetx[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDx();
150 fDetz[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDz();
152 fDetx[3] = ((AliITSgeomSDD*)(g1->GetShape(4, ll, dd)))->GetDx();
153 fDetz[3] = ((AliITSgeomSDD*)(g1->GetShape(4, ll, dd)))->GetDz();
155 fDetx[4] = ((AliITSgeomSSD*)(g1->GetShape(5, ll, dd)))->GetDx();
156 fDetz[4] = ((AliITSgeomSSD*)(g1->GetShape(5, ll, dd)))->GetDz();
158 fDetx[5] = ((AliITSgeomSSD*)(g1->GetShape(6, ll, dd)))->GetDx();
159 fDetz[5] = ((AliITSgeomSSD*)(g1->GetShape(6, ll, dd)))->GetDz();
160 //cout<<" Detx Detz\n";
161 //for(Int_t la=0; la<6; la++) cout<<" "<<fDetx[la]<<" "<<
165 // allocate memory and define matrices fzmin, fzmax, fphimin and fphimax //
167 Double_t epszdrift=0.05;
169 fzmin = new Double_t*[6]; fzmax = new Double_t*[6];
170 Int_t im1, im2, im2max;
171 for(im1=0; im1<6; im1++) {
173 fzmin[im1] = new Double_t[im2max]; fzmax[im1] = new Double_t[im2max];
176 for(im1=0; im1<6; im1++) {
178 for(im2=0; im2<im2max; im2++) {
179 g1->GetCenterThetaPhi(im1+1,1,im2+1,det);
180 if(im2!=0) fzmin[im1][im2]=det(2)-fDetz[im1];
182 fzmin[im1][im2]=det(2)-(fDetz[im1])*epsz;
183 if(im2!=(im2max-1)) fzmax[im1][im2]=det(2)+fDetz[im1];
185 fzmax[im1][im2]=det(2)+fDetz[im1]*epsz;
186 if(im1==2 || im1==3) {
187 fzmin[im1][im2]-=epszdrift;
188 fzmax[im1][im2]+=epszdrift;
189 } // end if im1==2 || im1==3
193 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
194 for(im1=0;im1<6;im1++) {
196 fphimin[im1] = new Double_t[im2max];
197 fphimax[im1] = new Double_t[im2max];
200 fphidet = new Double_t*[6];
201 for(im1=0; im1<6; im1++) {
203 fphidet[im1] = new Double_t[im2max];
206 Double_t global[3],local[3];
207 Double_t pigre=TMath::Pi();
208 Double_t xmin,ymin,xmax,ymax;
210 for(im1=0; im1<6; im1++) {
212 for(im2=0; im2<im2max; im2++) {
214 g1->GetCenterThetaPhi(im1+1,im2+1,idet,det);
215 fphidet[im1][im2] = TMath::ATan2(Double_t(det(1)),
217 if(fphidet[im1][im2]<0.) fphidet[im1][im2]+=2.*pigre;
218 local[1]=local[2]=0.;
219 local[0]= -(fDetx[im1]);
220 if(im1==0) local[0]= (fDetx[im1]); //to take into account
221 // different reference system
222 g1->LtoG(im1+1,im2+1,idet,local,global);
223 xmax=global[0]; ymax=global[1];
224 local[0]= (fDetx[im1]);
225 if(im1==0) local[0]= -(fDetx[im1]);//take into account different
227 g1->LtoG(im1+1,im2+1,idet,local,global);
228 xmin=global[0]; ymin=global[1];
229 fphimin[im1][im2]= TMath::ATan2(ymin,xmin);
230 if(fphimin[im1][im2]<0.) fphimin[im1][im2]+=2.*pigre;
231 fphimax[im1][im2]= TMath::ATan2(ymax,xmax);
232 if(fphimax[im1][im2]<0.) fphimax[im1][im2]+=2.*pigre;
235 //////////////////////////////////////////////////////////////////////////////////////////////////////////
236 /////////////// allocate memory and define vector fNRecPoints and matrices fRecCylR, fRecCylPhi, fRecCylZ /////////////
237 gAlice->GetEvent(evnumber);
238 Int_t NumOfModules = g1->GetIndexMax();
239 fRecCylR = new Double_t *[NumOfModules];
240 fRecCylPhi = new Double_t *[NumOfModules];
241 fRecCylZ = new Double_t *[NumOfModules];
242 AliITSRecPoint *recp;
243 fNRecPoints = new Int_t[NumOfModules];
245 for(Int_t module=0; module<NumOfModules; module++) {
246 fITS->ResetRecPoints();
247 gAlice->TreeR()->GetEvent(module);
248 frecPoints=fITS->RecPoints();
249 Int_t nRecPoints=fNRecPoints[module]=frecPoints->GetEntries();
250 fRecCylR[module] = new Double_t[nRecPoints];
251 fRecCylPhi[module] = new Double_t[nRecPoints];
252 fRecCylZ[module] = new Double_t[nRecPoints];
254 for(ind=0; ind<fNRecPoints[module]; ind++) {
255 recp=(AliITSRecPoint*)frecPoints->UncheckedAt(ind);
256 // Float_t global[3], local[3];
257 Double_t global[3], local[3];
258 local[0]=recp->GetX();
260 local[2]= recp->GetZ();
261 g1->LtoG(module,local,global);
263 Double_t r = TMath::Sqrt(global[0]*global[0]+global[1]*global[1]); // r hit
264 Double_t phi = TMath::ATan2(global[1],global[0]); if(phi<0.) phi+=2.*TMath::Pi(); // phi hit
265 Double_t z = global[2]; // z hit
267 fRecCylR[module][ind]=r;
268 fRecCylPhi[module][ind]=phi;
269 fRecCylZ[module][ind]=z;
274 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
277 ////////// gets magnetic field factor //////////////////////////////
279 AliMagF * fieldPointer = gAlice->Field();
280 // fFieldFactor = (Double_t)fieldPointer->Factor();
281 fFieldFactor =(Double_t)fieldPointer-> SolenoidField()/10/.2;
282 // cout<< " field factor = "<<fFieldFactor<<"\n"; getchar();
284 //______________________________________________________________________
285 AliITSTrackerV1::AliITSTrackerV1(const AliITSTrackerV1 &cobj) {
286 // Origin A. Badala' and G.S. Pappalardo:
287 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
291 *fresult = *cobj.fresult;
292 fPtref = cobj.fPtref;
293 fChi2max = cobj.fChi2max;
294 **fvettid = **cobj.fvettid;
295 fflagvert = cobj.fflagvert;
296 Int_t imax=200,jmax=450;
297 frl = new AliITSRad(imax,jmax);
299 fFieldFactor = cobj.fFieldFactor;
300 Int_t i,im1,im2,im2max;
302 fNlad[i] = cobj.fNlad[i];
303 fNdet[i] = cobj.fNdet[i];
304 fAvrad[i] = cobj.fAvrad[i];
305 fDetx[i] = cobj.fDetx[i];
306 fDetz[i] = cobj.fDetz[i];
308 fzmin = new Double_t*[6]; fzmax = new Double_t*[6];
309 for(im1=0; im1<6; im1++) {
311 fzmin[im1] = new Double_t[im2max];
312 fzmax[im1] = new Double_t[im2max];
314 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
315 for(im1=0;im1<6;im1++) {
317 fphimin[im1] = new Double_t[im2max];
318 fphimax[im1] = new Double_t[im2max];
321 fphidet = new Double_t*[6];
322 for(im1=0; im1<6; im1++) {
324 fphidet[im1] = new Double_t[im2max];
326 for(im1=0; im1<6; im1++) {
328 for(im2=0; im2<im2max; im2++) {
329 fzmin[im1][im2]=cobj.fzmin[im1][im2];
330 fzmax[im1][im2]=cobj.fzmax[im1][im2];
333 for(im1=0; im1<6; im1++) {
335 for(im2=0; im2<im2max; im2++) {
336 fphimin[im1][im2]=cobj.fphimin[im1][im2];
337 fphimax[im1][im2]=cobj.fphimax[im1][im2];
338 fphidet[im1][im2]=cobj.fphidet[im1][im2];
343 AliITSgeom *g1 = fITS->GetITSgeom();
344 Int_t NumOfModules = g1->GetIndexMax();
346 fRecCylR = new Float_t *[NumOfModules];
347 fRecCylPhi = new Float_t *[NumOfModules];
348 fRecCylZ = new Float_t *[NumOfModules];
350 fRecCylR = new Double_t *[NumOfModules];
351 fRecCylPhi = new Double_t *[NumOfModules];
352 fRecCylZ = new Double_t *[NumOfModules];
353 fNRecPoints = new Int_t[NumOfModules];
354 for(Int_t module=0; module<NumOfModules; module++) {
355 Int_t nRecPoints=fNRecPoints[module]=cobj.fNRecPoints[module];
357 fRecCylR[module] = new Float_t[nRecPoints];
358 fRecCylPhi[module] = new Float_t[nRecPoints];
359 fRecCylZ[module] = new Float_t[nRecPoints];
361 fRecCylR[module] = new Double_t[nRecPoints];
362 fRecCylPhi[module] = new Double_t[nRecPoints];
363 fRecCylZ[module] = new Double_t[nRecPoints];
365 for(ind=0; ind<nRecPoints; ind++) {
366 fRecCylR[module][ind]=cobj.fRecCylR[module][ind];
367 fRecCylPhi[module][ind]=cobj.fRecCylPhi[module][ind];
368 fRecCylZ[module][ind]=cobj.fRecCylZ[module][ind];
373 void AliITSTrackerV1::DelMatrix(Int_t NumOfModules) {
374 for(Int_t mod=0; mod<NumOfModules; mod++) {
375 delete fRecCylR[mod];
376 delete fRecCylPhi[mod];
377 delete fRecCylZ[mod];
383 //______________________________________________________________________
384 AliITSTrackerV1::~AliITSTrackerV1(){
385 // Origin A. Badala' and G.S. Pappalardo:
386 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
390 for(Int_t i=0; i<6; i++) {
405 //______________________________________________________________________
406 AliITSTrackerV1 &AliITSTrackerV1::operator=(AliITSTrackerV1 obj) {
407 // Origin A. Badala' and G.S. Pappalardo:
408 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
409 // assignement operator
412 *fresult = *obj.fresult;
414 fChi2max = obj.fChi2max;
415 **fvettid = **obj.fvettid;
416 fflagvert = obj.fflagvert;
417 Int_t imax=200,jmax=450;
418 frl = new AliITSRad(imax,jmax);
420 fFieldFactor = obj.fFieldFactor;
423 fNlad[i] = obj.fNlad[i];
424 fNdet[i] = obj.fNdet[i];
425 fAvrad[i] = obj.fAvrad[i];
426 fDetx[i] = obj.fDetx[i];
427 fDetz[i] = obj.fDetz[i];
429 fzmin = new Double_t*[6];
430 fzmax = new Double_t*[6];
431 Int_t im1, im2, im2max;
432 for(im1=0; im1<6; im1++) {
434 fzmin[im1] = new Double_t[im2max]; fzmax[im1] = new Double_t[im2max];
436 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
437 for(im1=0;im1<6;im1++) {
439 fphimin[im1] = new Double_t[im2max];
440 fphimax[im1] = new Double_t[im2max];
443 fphidet = new Double_t*[6];
444 for(im1=0; im1<6; im1++) {
446 fphidet[im1] = new Double_t[im2max];
448 for(im1=0; im1<6; im1++) {
450 for(im2=0; im2<im2max; im2++) {
451 fzmin[im1][im2]=obj.fzmin[im1][im2];
452 fzmax[im1][im2]=obj.fzmax[im1][im2];
455 for(im1=0; im1<6; im1++) {
457 for(im2=0; im2<im2max; im2++) {
458 fphimin[im1][im2]=obj.fphimin[im1][im2];
459 fphimax[im1][im2]=obj.fphimax[im1][im2];
460 fphidet[im1][im2]=obj.fphidet[im1][im2];
464 AliITSgeom *g1 = fITS->GetITSgeom();
465 Int_t NumOfModules = g1->GetIndexMax();
466 fRecCylR = new Double_t *[NumOfModules];
467 fRecCylPhi = new Double_t *[NumOfModules];
468 fRecCylZ = new Double_t *[NumOfModules];
469 fNRecPoints = new Int_t[NumOfModules];
470 for(Int_t module=0; module<NumOfModules; module++) {
471 Int_t nRecPoints=fNRecPoints[module]=obj.fNRecPoints[module];
472 fRecCylR[module] = new Double_t[nRecPoints];
473 fRecCylPhi[module] = new Double_t[nRecPoints];
474 fRecCylZ[module] = new Double_t[nRecPoints];
476 for(ind=0; ind<nRecPoints; ind++) {
477 fRecCylR[module][ind]=obj.fRecCylR[module][ind];
478 fRecCylPhi[module][ind]=obj.fRecCylPhi[module][ind];
479 fRecCylZ[module][ind]=obj.fRecCylZ[module][ind];
486 //______________________________________________________________________
487 void AliITSTrackerV1::DoTracking(Int_t evNumber,Int_t minTr,Int_t maxTr,
488 TFile *file, Bool_t realmass) {
489 // Origin A. Badala' and G.S. Pappalardo:
490 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
491 // The method needs the event number, the minimum and maximum order
492 // number of TPC tracks that
493 // are to be tracked trough the ITS, and the file where the recpoints
495 // The method can be called by a macro. It preforms the tracking for
496 // all good TPC tracks
498 printf("begin DoTracking - file %p\n",file);
500 gAlice->GetEvent(evNumber); //modificato per gestire hbt
502 AliKalmanTrack::SetConvConst(1000/0.299792458/gAlice->Field()->SolenoidField());
503 // cout<<" field = "<<gAlice->Field()->SolenoidField()<<endl;
506 TFile *cf=TFile::Open("AliTPCclusters.root");
507 AliTPCParam *digp= (AliTPCParam*)cf->Get("75x40_100x60_150x60");
508 if (!digp) { cerr<<"TPC parameters have not been found !\n"; getchar();}
511 TString foldname(fITS->GetLoader()->GetEventFolder()->GetName());
513 AliTPCtracker *tracker = new AliTPCtracker(digp,evNumber,foldname);
514 //PH AliTPCtracker *tracker = new AliTPCtracker(digp); //I.B.
515 //PH tracker->SetEventNumber(evNumber); //I.B.
518 //tracker->LoadInnerSectors(); //I.B.
519 //tracker->LoadOuterSectors(); //I.B.
520 tracker->LoadClusters(); //I.B.
523 TFile *tf=TFile::Open("AliTPCtracksSorted.root");
525 cerr<<"Can't open AliTPCtracksSorted.root !\n";
528 TObjArray tracks(200000);
530 sprintf(tname,"TreeT_TPC_%d",evNumber);
532 TTree *tracktree=(TTree*)tf->Get(tname);
533 if (!tracktree) {cerr<<"Can't get a tree with TPC tracks !\n";}
534 TBranch *tbranch=tracktree->GetBranch("tracks");
535 Int_t nentr=(Int_t)tracktree->GetEntries();
538 AliITSRecPoint *recp; // oggi
539 AliTPCtrack *ioTrackTPC=0;
540 for (kk=0; kk<nentr; kk++) {
541 ioTrackTPC=new AliTPCtrack;
542 tbranch->SetAddress(&ioTrackTPC);
543 tracktree->GetEvent(kk);
544 tracker->CookLabel(ioTrackTPC,0.1);
545 tracks.AddLast(ioTrackTPC);
550 Int_t nt = tracks.GetEntriesFast();
551 cerr<<"Number of found tracks "<<nt<<endl;
554 TTree *tr=gAlice->TreeR();
555 Int_t nent=(Int_t)tr->GetEntries();
556 frecPoints = fITS->RecPoints();
560 Int_t *np = new Int_t[nent];
561 fvettid = new Int_t* [nent];
564 for (mod=0; mod<nent; mod++) {
566 fITS->ResetRecPoints();
567 gAlice->TreeR()->GetEvent(mod);
568 numbpoints = frecPoints->GetEntries();
569 totalpoints+=numbpoints;
570 np[mod] = numbpoints;
571 //cout<<" mod = "<<mod<<" numbpoints = "<<numbpoints<<"\n";getchar();
572 fvettid[mod] = new Int_t[numbpoints];
574 for (ii=0;ii<numbpoints; ii++) *(fvettid[mod]+ii)=0;
577 AliTPCtrack *track=0;
579 if(minTr < 0) {minTr = 0; maxTr = nt-1;}
583 TTree tracktree1("TreeT","Tree with ITS tracks");
584 AliITSIOTrack *ioTrack=0;
585 AliITSPid *pid=new AliITSPid(1000); // oggi
587 tracktree1.Branch("ITStracks","AliITSIOTrack",&ioTrack,32000,0);
589 TDatabasePDG * db = new TDatabasePDG;
592 for (j=minTr; j<=maxTr; j++) {
593 track=(AliTPCtrack*)tracks.UncheckedAt(j);
594 if (!track) continue;
596 /// mass definition ////////////////////////
597 Double_t mass=0.13956995;
598 Int_t pcode=211; // a pion by default
601 if(TMath::Abs(pcode)<20443) mass=db->GetParticle(pcode)->Mass();
604 mass = track->GetMass();
605 // cout << "Mass = " << mass << endl;
610 // new propagation to the end of TPC
612 // track->PropagateTo(xk,0.,0.); //Ne if it's still there //attenzione funziona solo se modifica in TPC
613 // Double_t xk=77.415;
614 track->PropagateTo(xk, 28.94, 1.204e-3);
616 track->PropagateTo(xk, 44.77,1.71); //Tedlar
618 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
620 track->PropagateTo(xk, 41.28, 0.029);//Nomex
622 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
624 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
627 // track->PropagateTo(xk,0.,0.); //C02
628 track->PropagateTo(xk,36.2,1.98e-3); //C02 //attenzione funziona solo se modifica in TPC
631 track->PropagateTo(xk, 24.01, 2.7); //Al
633 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
635 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
637 track->PropagateTo(xk, 41.28, 0.029); //Nomex
639 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
641 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
643 track->PropagateTo(xk, 24.01, 2.7); //Al
645 ////////////////////////////////////////////////////////////////////////////////////////////////////////
646 //AliITSTrackV1 trackITS(*track);
647 AliITSTrackV1 trackITS(*track, fFieldFactor);
648 //cout<<" fFieldFactor = "<<fFieldFactor<<"\n";
649 trackITS.PutMass(mass); //new to add mass to track
650 if(fresult){ delete fresult; fresult=0;}
651 fresult = new AliITSTrackV1(trackITS);
653 AliITSTrackV1 primaryTrack(trackITS);
654 vgeant=(*fresult).GetVertex();
656 // Definition of dv and zv for vertex constraint
657 Double_t sigmaDv=0.0050; Double_t sigmaZv=0.010;
658 //Double_t sigmaDv=0.0015; Double_t sigmaZv=0.0015;
659 Double_t uniform= gRandom->Uniform();
661 if(uniform<=0.5) signdv=-1.;
665 Double_t vr=TMath::Sqrt(vgeant(0)*vgeant(0)+ vgeant(1)*vgeant(1));
666 Double_t dv=gRandom->Gaus(signdv*vr,(Float_t)sigmaDv);
667 Double_t zv=gRandom->Gaus(vgeant(2),(Float_t)sigmaZv);
668 //cout<<" Dv e Zv = "<<dv<<" "<<zv<<"\n";
671 trackITS.SetsigmaDv(sigmaDv);
672 trackITS.SetsigmaZv(sigmaZv);
673 (*fresult).SetDv(dv);
674 (*fresult).SetZv(zv);
675 (*fresult).SetsigmaDv(sigmaDv);
676 (*fresult).SetsigmaZv(sigmaZv);
677 primaryTrack.SetDv(dv);
678 primaryTrack.SetZv(zv);
679 primaryTrack.SetsigmaDv(sigmaDv);
680 primaryTrack.SetsigmaZv(sigmaZv);
681 primaryTrack.PrimaryTrack(frl);
682 TVector d2=primaryTrack.Getd2();
683 TVector tgl2=primaryTrack.Gettgl2();
684 TVector dtgl=primaryTrack.Getdtgl();
685 trackITS.Setd2(d2); trackITS.Settgl2(tgl2);
686 trackITS.Setdtgl(dtgl);
687 (*fresult).Setd2(d2); (*fresult).Settgl2(tgl2);
688 (*fresult).Setdtgl(dtgl);
690 trackITS.SetVertex(vertex); trackITS.SetErrorVertex(ervertex);
691 (*result).SetVertex(vertex); (*result).SetErrorVertex(ervertex);
693 TList *list= new TList();
695 list->AddLast(&trackITS);
697 fPtref=TMath::Abs( (trackITS).GetPt() );
698 //cout<<" fPtref = " <<fPtref<<"\n";
699 if(fPtref>1.0) fChi2max=40.;
700 if(fPtref<=1.0) fChi2max=20.;
701 if(fPtref<0.4 ) fChi2max=100.;
702 if(fPtref<0.2 ) fChi2max=40.;
703 // if(fPtref<0.4 ) fChi2max=30.;
704 // if(fPtref<0.2 ) fChi2max=20.;
705 //if(fPtref<0.2 ) fChi2max=10.;
706 //if(fPtref<0.1 ) fChi2max=5.;
707 //cout << "\n Pt = " << fPtref <<"\n"; //stampa
708 RecursiveTracking(list);
713 TVector vecTotLabRef(18);
715 for(lay=5; lay>=0; lay--) {
716 TVector vecLabRef(3);
717 vecLabRef=(*fresult).GetLabTrack(lay);
718 Float_t clustZ=(*fresult).GetZclusterTrack( lay);
720 Int_t lpp=(Int_t)vecLabRef(k);
722 TParticle *p=(TParticle*) gAlice->Particle(lpp);
723 Int_t pcode=p->GetPdgCode();
724 if(pcode==11) vecLabRef(k)=p->GetFirstMother();
726 itot++; vecTotLabRef(itot)=vecLabRef(k);
727 if(vecLabRef(k)==0. && clustZ == -1.) vecTotLabRef(itot) =-3.;
732 (*fresult).Search(vecTotLabRef, labref, freq);
734 //if(freq < 6) labref=-labref; // cinque - sei
735 if(freq < 5) labref=-labref; // cinque - sei
736 (*fresult).SetLabel(labref);
738 // cout<<" progressive track number = "<<j<<"\r";
740 Int_t numOfCluster=(*fresult).GetNumClust();
741 //cout<<" progressive track number = "<<j<<"\n"; // stampa
742 Long_t labITS=(*fresult).GetLabel();
743 //cout << " ITS track label = " << labITS << "\n"; // stampa
744 Int_t lab=track->GetLabel();
745 //cout << " TPC track label = " << lab <<"\n"; // stampa
746 //propagation to vertex
749 if((*fresult).DoNotCross(rbeam)) continue; //no intersection with beampipe
750 (*fresult).Propagation(rbeam);
751 Double_t c00,c10,c11,c20,c21,c22,c30,c31,c32,c33,c40,c41,c42,c43,c44;
752 (*fresult).GetCElements(c00,
756 c40,c41,c42,c43,c44);
758 Double_t pt=TMath::Abs((*fresult).GetPt());
759 Double_t dr=(*fresult).GetD();
760 Double_t z=(*fresult).GetZ();
761 Double_t tgl=(*fresult).GetTgl();
762 Double_t c=(*fresult).GetC();
764 Double_t dz=z-(tgl/cy)*TMath::ASin((*fresult).Arga(rbeam));
766 // cout<<" dr e dz alla fine = "<<dr<<" "<<dz<<"\n"; getchar();
767 Double_t phi=(*fresult).Getphi();
768 Double_t phivertex = phi - TMath::ASin((*fresult).ArgA(rbeam));
769 Double_t duepi=2.*TMath::Pi();
770 if(phivertex>duepi) phivertex-=duepi;
771 if(phivertex<0.) phivertex+=duepi;
772 /////////////////////////////////////////////////////////////
773 Int_t idmodule,idpoint;
774 if(numOfCluster >=5) { // cinque - sei
775 //if(numOfCluster ==6) { // cinque - sei
776 AliITSIOTrack outTrack;
778 ioTrack->SetStatePhi(phi);
779 ioTrack->SetStateZ(z);
780 ioTrack->SetStateD(dr);
781 ioTrack->SetStateTgl(tgl);
782 ioTrack->SetStateC(c);
783 Double_t radius=(*fresult).Getrtrack();
784 ioTrack->SetRadius(radius);
786 if(c>0.) charge=-1; else charge=1;
787 ioTrack->SetCharge(charge);
788 Double_t trackmass=(*fresult).GetMass(); // oggi
789 ioTrack->SetMass(trackmass); // oggi
790 ioTrack->SetCovMatrix(c00,
794 c40,c41,c42,c43,c44);
795 Double_t px=pt*TMath::Cos(phivertex);
796 Double_t py=pt*TMath::Sin(phivertex);
798 Double_t xtrack=dr*TMath::Sin(phivertex);
799 Double_t ytrack=dr*TMath::Cos(phivertex);
800 Double_t ztrack=dz+vgeant(2);
804 ioTrack->SetX(xtrack);
805 ioTrack->SetY(ytrack);
806 ioTrack->SetZ(ztrack);
807 ioTrack->SetLabel(labITS);
808 ioTrack->SetTPCLabel(lab);
812 for(il=0;il<6; il++){
813 ioTrack->SetIdPoint(il,(*fresult).GetIdPoint(il));
814 ioTrack->SetIdModule(il,(*fresult).GetIdModule(il));
818 Float_t q[4]={-1.,-1.,-1.,-1.};
819 Float_t globaldedx=0.;
820 for (il=0;il<6;il++) {
821 idpoint=(*fresult).GetIdPoint(il);
822 idmodule=(*fresult).GetIdModule(il);
823 if(idmodule>0.) *(fvettid[idmodule]+idpoint)=1;
825 ioTrack->SetIdPoint(il,idpoint);
826 ioTrack->SetIdModule(il,idmodule);
827 //// for q definition
830 fITS->ResetRecPoints();
831 gAlice->TreeR()->GetEvent(idmodule);
832 recp=(AliITSRecPoint*)frecPoints->UncheckedAt(idpoint);
833 q[il-2]=recp->GetQ()*(*fresult).Getfcor(il-2);
837 q[0]/=280.; q[1]/=280.;
838 q[2]/=38.; q[3]/=38.;
840 // cout<<" q prima = "<<q[0]<<" "<<q[1]<<" "<<q[2]<<" "<<q[3]<<"\n"; getchar();
845 for (il=0; il<3; il++) {
846 if (q[il]<=q[il+1]) continue;
848 q[il]=q[il+1]; q[il+1]=tmp;
854 // cout<<" q dopo = "<<q[0]<<" "<<q[1]<<" "<<q[2]<<" "<<q[3]<<"\n"; getchar();
863 // cout<<" q dopo if = "<<q[0]<<" "<<q[1]<<" "<<q[2]<<" "<<q[3]<<"\n"; getchar();
865 globaldedx=(q[0]+q[1])/2.;
867 // if(q[3]> 0.) globaldedx=(q[0]+q[1]+q[2]+q[3])/4.;
868 // else globaldedx=(q[0]+q[1]+q[2])/3.;
870 ioTrack->SetdEdx(globaldedx);
871 ioTrack->SetPid(pid->GetPcode(ioTrack));
874 } // end if on numOfCluster
875 //gObjectTable->Print(); // stampa memoria
876 } // end for (int j=minTr; j<=maxTr; j++)
878 static Bool_t first=kTRUE;
881 tfile=new TFile("itstracks.root","RECREATE");
882 //cout<<"I have opened itstracks.root file "<<endl;
888 sprintf(hname,"TreeT%d",evNumber);
889 cout << "Number of saved ITS tracks " << tracktree1.GetEntries() << endl;
890 tracktree1.Write(hname);
892 TTree *fAli=gAlice->TreeK();
894 if (fAli) fileAli =fAli->GetCurrentFile();
896 ////////////////////////////////////////////////////////////////////
898 printf("delete vectors\n");
900 if(fvettid) delete [] fvettid;
901 if(fresult) {delete fresult; fresult=0;}
903 //______________________________________________________________________
904 void AliITSTrackerV1::RecursiveTracking(TList *trackITSlist) {
905 // This function perform the recursive tracking in ITS detectors
906 // reference is a pointer to the final best track
907 // Origin A. Badala' and G.S. Pappalardo:
908 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
909 // The authors thank Mariana Bondila to have help them to resolve some
910 // problems. July-2000
912 //Rlayer[0]=4.; Rlayer[1]=7.; Rlayer[2]=14.9;
913 // Rlayer[3]=23.8; Rlayer[4]=39.1; Rlayer[5]=43.6; //vecchio
915 //////////////////////
916 Float_t sigmaphil[6], sigmazl[6];
917 sigmaphil[0]=1.44e-6/(fAvrad[0]*fAvrad[0]);
918 sigmaphil[1]=1.44e-6/(fAvrad[1]*fAvrad[1]);
919 sigmaphil[2]=1.444e-5/(fAvrad[2]*fAvrad[2]);
920 sigmaphil[3]=1.444e-5/(fAvrad[3]*fAvrad[3]);
921 sigmaphil[4]=4e-6/(fAvrad[4]*fAvrad[4]);
922 sigmaphil[5]=4e-6/(fAvrad[5]*fAvrad[5]);
929 ///////////////////////////////////////////////////////////
931 AliITSgeom *g1 = fITS->GetITSgeom();
932 AliITSRecPoint *recp;
933 for(index =0; index<trackITSlist->GetSize(); index++) {
934 AliITSTrackV1 *trackITS = (AliITSTrackV1 *) trackITSlist->At(index);
935 if((*trackITS).GetLayer()==7) fresult->SetChi2(10.223e140);
936 // cout <<" Layer inizio = "<<(*trackITS).GetLayer()<<"\n";
937 // cout<<"fvtrack =" <<"\n";
938 // cout << (*trackITS)(0) << " "<<(*trackITS)(1)<<" "
939 // <<(*trackITS)(2)<<" "<<(*trackITS)(3)<<" "
940 // <<(*trackITS)(4)<<"\n";
941 // cout<< " rtrack = "<<(*trackITS).Getrtrack()<<"\n";
942 // cout<< " Pt = "<<(*trackITS).GetPt()<<"\n";
944 Double_t chi2Now, chi2Ref;
945 Float_t numClustRef = fresult->GetNumClust();
946 if((*trackITS).GetLayer()==1 ) {
947 chi2Now = trackITS->GetChi2();
948 Float_t numClustNow = trackITS->GetNumClust();
949 if(trackITS->GetNumClust())
950 chi2Now /= (Double_t)trackITS->GetNumClust();
951 chi2Ref = fresult->GetChi2();
952 if(fresult->GetNumClust())
953 chi2Ref /= (Double_t)fresult->GetNumClust();
954 //cout<<" chi2Now and chi2Ref = "<<chi2Now<<" "<<chi2Ref<<"\n";
955 if( numClustNow > numClustRef ) {*fresult = *trackITS;}
956 if((numClustNow == numClustRef )&&
957 (chi2Now < chi2Ref)) {
958 *fresult = *trackITS;
963 if(trackITS->Getfnoclust()>=2) continue;
964 Float_t numClustNow = trackITS->GetNumClust();
966 chi2Now = trackITS->GetChi2();
968 if(numClustNow<numClustRef && chi2Now>fresult->GetChi2()) continue;
969 //cout<<" chi2Now = "<<chi2Now<<"\n";
971 chi2Now/=numClustNow;
972 if(fPtref > 1.0 && chi2Now > 30.) continue;
973 if((fPtref >= 0.6 && fPtref<=1.0) && chi2Now > 40.) continue;
974 // if((fPtref <= 0.6 && fPtref>0.2)&& chi2Now > 40.) continue;
975 // if(fPtref <= 0.2 && chi2Now > 8.) continue;
976 if((fPtref <= 0.6 && fPtref>0.2)&& chi2Now > 30.) continue;
977 if(fPtref <= 0.2 && chi2Now > 7.) continue;
978 /////////////////////////////
981 Int_t layerInit = (*trackITS).GetLayer();
982 Int_t layernew = layerInit - 2;// -1 for new layer, -1 for matrix index
984 Int_t ladp, ladm, detp,detm,ladinters,detinters;
985 Int_t layerfin=layerInit-1;
986 // cout<<"Prima di intersection \n";
987 Int_t outinters=Intersection(*trackITS,layerfin,ladinters,detinters);
988 // cout<<" outinters = "<<outinters<<"\n";
989 // cout<<" Layer ladder detector intersection ="
990 // <<layerfin<<" "<<ladinters<<" "<<detinters<<"\n";
991 // cout << " phiinters zinters = "<<(*trackITS)(0)
992 // << " "<<(*trackITS)(1)<<"\n"; getchar();
993 if(outinters==-1) continue;
995 (*trackITS).SetLayer(layerfin); // oggi
996 (*trackITS).Setfcor(); // oggi
998 TVector toucLad(9), toucDet(9);
999 Int_t lycur=layerfin;
1002 if(ladm <= 0) ladm=fNlad[layerfin-1];
1003 if(ladp > fNlad[layerfin-1]) ladp=1;
1008 toucLad(0)=ladinters; toucLad(1)=ladm; toucLad(2)=ladp;
1009 toucLad(3)=ladinters; toucLad(4)=ladm; toucLad(5)=ladp;
1010 toucLad(6)=ladinters; toucLad(7)=ladm; toucLad(8)=ladp;
1011 toucDet(0)=detinters; toucDet(1)=detinters; toucDet(2)=detinters;
1012 if(detm > 0 && detp <= fNdet[layerfin-1]) {
1014 toucDet(3)=detm; toucDet(4)=detm; toucDet(5)=detm;
1015 toucDet(6)=detp; toucDet(7)=detp; toucDet(8)=detp;
1017 if(detm > 0 && detp > fNdet[layerfin-1]) {
1019 toucDet(3)=detm; toucDet(4)=detm; toucDet(5)=detm;
1021 if(detm <= 0 && detp <= fNdet[layerfin-1]) {
1023 toucDet(3)=detp; toucDet(4)=detp; toucDet(5)=detp;
1026 Float_t epsphi=5.0, epsz=5.0;
1027 if(fPtref<0.2) {epsphi=3.; epsz=3.;}
1028 // new definition of idetot e toucLad e toucDet to be
1029 // transformed in a method
1030 // these values could be modified
1031 Float_t pigre=TMath::Pi();
1032 Float_t rangephi=5., rangez=5.;
1033 if(layerfin==1 || layerfin ==2){
1034 rangephi=40.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1035 (*trackITS).GetSigmaphi());
1036 rangez = 40.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1037 (*trackITS).GetSigmaZ());
1039 if(layerfin==3 || layerfin ==4){
1040 //rangephi=30.*fepsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1041 // (*trackITS).GetSigmaphi());
1042 //rangez = 40.*fepsz*TMath::Sqrt(sigmazl[layerfin-1]+
1043 // (*trackITS).GetSigmaZ());
1044 rangephi=40.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1045 (*trackITS).GetSigmaphi());
1046 rangez = 50.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1047 (*trackITS).GetSigmaZ());
1049 if(layerfin==5 || layerfin ==6){
1050 rangephi=20.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1051 (*trackITS).GetSigmaphi());
1052 rangez =5.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1053 (*trackITS).GetSigmaZ());
1055 Float_t phinters, zinters;
1056 phinters=(*trackITS).Getphi();
1057 zinters=(*trackITS).GetZ();
1058 Float_t distz = 0.0;
1059 Float_t phicm, phicp, distphim, distphip;
1061 if(phinters>fphimax[layerfin-1][ladm-1]) phicm=phinters-2*pigre; //corretto il 20-11-2001
1062 distphim=TMath::Abs(phicm-fphimax[layerfin-1][ladm-1]); //corretto il 20-11-2001
1064 //cout<<" fNlad[layerfin-1] e ladp = "<<fNlad[layerfin-1]<<" "<<ladp<<endl;
1065 if(phinters>fphimin[layerfin-1][ladp-1]) phicp=phinters-2.*pigre; //corretto il 20-11-2001
1066 distphip=TMath::Abs(phicp-fphimin[layerfin-1][ladp-1]); //corretto il 20-11-2001
1070 toucLad(0)=ladinters; toucDet(0)=detinters;
1071 if(detm>0) distz=TMath::Abs(zinters-fzmax[layerfin-1][detm-1]);
1072 if(detm>0 && rangez>=distz){
1074 idetot++; toucLad(idetot-1)=ladinters; toucDet(idetot-1)=detm;
1075 if(rangephi>=distphim){
1077 toucLad(idetot-1)=ladm;
1078 toucDet(idetot-1)=detinters;
1080 toucLad(idetot-1)=ladm;
1081 toucDet(idetot-1)=detm;
1083 if(rangephi>=distphip){
1085 toucLad(idetot-1)=ladp;
1086 toucDet(idetot-1)=detinters;
1088 toucLad(idetot-1)=ladp;
1089 toucDet(idetot-1)=detm;
1092 if(detp<=fNdet[layerfin-1])
1093 distz=TMath::Abs(zinters-fzmin[layerfin-1][detp-1]);
1094 if(detp<=fNdet[layerfin-1] && rangez>=distz){
1096 idetot++; toucLad(idetot-1)=ladinters; toucDet(idetot-1)=detp;
1097 if(rangephi>=distphim){
1098 idetot++; toucLad(idetot-1)=ladm; toucDet(idetot-1)=detp;
1101 toucLad(idetot-1)=ladm;
1102 toucDet(idetot-1)=detinters;
1105 if(rangephi>=distphip){
1107 toucLad(idetot-1)=ladp;
1108 toucDet(idetot-1)=detp;
1111 toucLad(idetot-1)=ladp;
1112 toucDet(idetot-1)=detinters;
1115 } //end detm<fNdet[.......
1117 if(flagzmin == 0 && flagzmax==0){
1118 if(rangephi>=distphim){
1120 toucLad(idetot-1)=ladm;
1121 toucDet(idetot-1)=detinters;
1123 if(rangephi>=distphip){
1125 toucLad(idetot-1)=ladp;
1126 toucDet(idetot-1)=detinters;
1129 ////////////////////////////////////////////////////////////
1131 for (iriv=0; iriv<idetot; iriv++) { //for on detectors
1132 ///////////////////////////////////////////////////////
1133 /*** Rec points sorted by module *****/
1134 /**************************************/
1136 indexmod = g1->GetModuleIndex(lycur,(Int_t)toucLad(iriv),
1137 (Int_t)toucDet(iriv));
1138 fITS->ResetRecPoints();
1139 gAlice->TreeR()->GetEvent(indexmod);
1140 Int_t npoints=frecPoints->GetEntries();
1143 for(indnew=0; indnew<npoints; indnew++){
1144 if (*(fvettid[indexmod]+indnew)==0)
1145 recp =(AliITSRecPoint*)frecPoints->UncheckedAt(indnew);
1148 TVector cluster(3),vecclust(9);
1149 //vecclust(6)=vecclust(7)=vecclust(8)=-1.;
1151 // now vecclust is with cylindrical cohordinates
1152 vecclust(0)=(Float_t)fRecCylR[indexmod][indnew];
1153 vecclust(1)=(Float_t)fRecCylPhi[indexmod][indnew];
1154 vecclust(2)=(Float_t)fRecCylZ[indexmod][indnew];
1155 vecclust(3) = (Float_t)recp->fTracks[0];
1156 vecclust(4) = (Float_t)indnew;
1157 vecclust(5) = (Float_t)indexmod;
1158 vecclust(6) = (Float_t)recp->fTracks[0];
1159 vecclust(7) = (Float_t)recp->fTracks[1];
1160 vecclust(8) = (Float_t)recp->fTracks[2];
1161 sigma[0] = (Double_t) recp->GetSigmaX2();
1162 sigma[1] = (Double_t) recp->GetSigmaZ2();
1164 cluster(0)=fRecCylR[indexmod][indnew];
1165 cluster(1)=fRecCylPhi[indexmod][indnew];
1166 cluster(2)=fRecCylZ[indexmod][indnew];
1168 // cout<<" layer = "<<play<<"\n";
1169 // cout<<" cluster prima = "<<vecclust(0)<<" "
1170 // <<vecclust(1)<<" "
1171 // <<vecclust(2)<<"\n"; getchar();
1173 Float_t sigmatotphi, sigmatotz;
1174 // Float_t epsphi=5.0, epsz=5.0;
1175 //if(fPtref<0.2) {epsphi=3.; epsz=3.;}
1176 Double_t rTrack=(*trackITS).Getrtrack();
1177 Double_t sigmaphi=sigma[0]/(rTrack*rTrack);
1178 sigmatotphi=epsphi*TMath::Sqrt(sigmaphi +
1179 (*trackITS).GetSigmaphi());
1180 sigmatotz=epsz*TMath::Sqrt(sigma[1] +
1181 (*trackITS).GetSigmaZ());
1182 //cout<<"cluster e sigmatotphi e track = "<<cluster(0)
1183 // <<" "<<cluster(1)<<" "<<sigmatotphi<<" "
1184 // <<vecclust(3)<<"\n";
1185 //if(vecclust(3)==481) getchar();
1186 if(cluster(1)<6. && (*trackITS).Getphi()>6.)
1187 cluster(1)=cluster(1)+(2.*TMath::Pi());
1188 if(cluster(1)>6. && (*trackITS).Getphi()<6.)
1189 cluster(1)=cluster(1)-(2.*TMath::Pi());
1190 if(TMath::Abs(cluster(1)-(*trackITS).Getphi())>sigmatotphi)
1192 // cout<<" supero sigmaphi \n";
1193 AliITSTrackV1 *newTrack = new AliITSTrackV1((*trackITS));
1194 //(*newTrack).SetLayer((*trackITS).GetLayer()-1);
1195 if (TMath::Abs(rTrack-cluster(0))/rTrack>1e-6)
1196 (*newTrack).Correct(Double_t(cluster(0)));
1197 //cout<<" cluster(2) e(*newTrack).GetZ()="<<cluster(2)<<" "
1198 // << (*newTrack).GetZ()<<"\n";
1199 if(TMath::Abs(cluster(2)-(*newTrack).GetZ()) > sigmatotz){
1203 Double_t sigmanew[2];
1204 sigmanew[0]= sigmaphi;
1205 sigmanew[1]=sigma[1];
1209 // Double_t chi2pred=newTrack->GetPredChi2(m,sigmanew);
1210 // cout<<" chi2pred = "<<chi2pred<<"\n";
1211 // if(chi2pred>fChi2max) continue; //aggiunto il 30-7-2001
1212 if(iriv == 0) flaghit=1;
1213 (*newTrack).AddMS(frl); // add the multiple scattering
1214 //matrix to the covariance matrix
1215 (*newTrack).AddEL(frl,1.,0);
1218 KalmanFilterVert(newTrack,cluster,sigmanew);
1219 //KalmanFilterVert(newTrack,cluster,sigmanew,chi2pred);
1221 KalmanFilter(newTrack,cluster,sigmanew);
1223 (*newTrack).PutCluster(layernew, vecclust);
1224 newTrack->AddClustInTrack();
1225 listoftrack.AddLast(newTrack);
1227 } // end of for on detectors (iriv)
1228 }//end if(outinters==0)
1230 if(flaghit==0 || outinters==-2) {
1231 AliITSTrackV1 *newTrack = new AliITSTrackV1(*trackITS);
1232 (*newTrack).Setfnoclust();
1233 //(*newTrack).SetLayer((*trackITS).GetLayer()-1);
1234 (*newTrack).AddMS(frl); // add the multiple scattering matrix
1235 // to the covariance matrix
1236 (*newTrack).AddEL(frl,1.,0);
1237 listoftrack.AddLast(newTrack);
1240 //gObjectTable->Print(); // stampa memoria
1242 RecursiveTracking(&listoftrack);
1243 listoftrack.Delete();
1244 } // end of for on tracks (index)
1246 //gObjectTable->Print(); // stampa memoria
1248 //______________________________________________________________________
1249 Int_t AliITSTrackerV1::Intersection(AliITSTrackV1 &track,Int_t layer,
1250 Int_t &ladder,Int_t &detector) {
1251 // Origin A. Badala' and G.S. Pappalardo
1252 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1253 // Found the intersection and the detector
1255 Double_t rk=fAvrad[layer-1];
1256 if(track.DoNotCross(rk)){ /*cout<< " Do not cross \n";*/ return -1;}
1257 track.Propagation(rk);
1258 Double_t zinters=track.GetZ();
1259 Double_t phinters=track.Getphi();
1260 //cout<<"zinters = "<<zinters<<" phinters = "<<phinters<<"\n";
1264 TVector distZCenter(2);
1268 for(iD = 1; iD<= fNdet[layer-1]; iD++) {
1269 if(zinters > fzmin[layer-1][iD-1] && zinters <= fzmax[layer-1][iD-1]) {
1271 cout<< " Errore su iz in Intersection \n";
1274 listDet(iz)= iD; distZCenter(iz)=TMath::Abs(zinters-det(2));
1280 if(iz==0) {/* cout<< " No detector along Z \n";*/ return -2;}
1281 detector=Int_t (listDet(0));
1282 if(iz>1 && (distZCenter(0)>distZCenter(1))) detector=Int_t (listDet(1));
1285 TVector distPhiCenter(2);
1287 Double_t pigre=TMath::Pi();
1289 for(iLd = 1; iLd<= fNlad[layer-1]; iLd++) {
1290 Double_t phimin=fphimin[layer-1][iLd-1];
1291 Double_t phimax=fphimax[layer-1][iLd-1];
1292 Double_t phidet=fphidet[layer-1][iLd-1];
1293 Double_t phiconfr=phinters;
1295 //if(phimin <5.5) {cout<<" Error in Intersection for phi \n";
1298 if(phinters>(1.5*pigre)) phiconfr=phinters-(2.*pigre);
1299 if(phidet>(1.5*pigre)) phidet-=(2.*pigre);
1301 if(phiconfr>phimin && phiconfr<= phimax) {
1303 cout<< " Errore su ip in Intersection \n"; getchar();
1306 distPhiCenter(ip)=TMath::Abs(phiconfr-phidet); ip++;
1310 if(ip==0) { cout<< " No detector along phi \n"; getchar();}
1311 ladder=Int_t (listLad(0));
1312 if(ip>1 && (distPhiCenter(0)>distPhiCenter(1))) ladder=Int_t (listLad(1));
1315 //______________________________________________________________________
1316 void AliITSTrackerV1::KalmanFilter(AliITSTrackV1 *newTrack,TVector &cluster,
1318 //Origin A. Badala' and G.S. Pappalardo:
1319 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1320 // Kalman filter without vertex constraint
1321 ////// Evaluation of the measurement vector ////////////////////////
1323 Double_t rk,phik,zk;
1324 rk=cluster(0); phik=cluster(1); zk=cluster(2);
1326 //////////////////////// Evaluation of the error matrix V /////////
1327 Double_t v00=sigma[0];
1328 Double_t v11=sigma[1];
1329 ////////////////////////////////////////////////////////////////////
1330 Double_t cin00,cin10,cin20,cin30,cin40,cin11,cin21,cin31,cin41,cin22,
1331 cin32,cin42,cin33,cin43,cin44;
1333 newTrack->GetCElements(cin00,
1336 cin30,cin31,cin32,cin33,
1337 cin40,cin41,cin42,cin43,cin44); //get C matrix
1338 Double_t rold00=cin00+v00;
1339 Double_t rold10=cin10;
1340 Double_t rold11=cin11+v11;
1341 ////////////////////// R matrix inversion /////////////////////////
1342 Double_t det=rold00*rold11-rold10*rold10;
1343 Double_t r00=rold11/det;
1344 Double_t r10=-rold10/det;
1345 Double_t r11=rold00/det;
1346 ////////////////////////////////////////////////////////////////////
1347 Double_t k00=cin00*r00+cin10*r10;
1348 Double_t k01=cin00*r10+cin10*r11;
1349 Double_t k10=cin10*r00+cin11*r10;
1350 Double_t k11=cin10*r10+cin11*r11;
1351 Double_t k20=cin20*r00+cin21*r10;
1352 Double_t k21=cin20*r10+cin21*r11;
1353 Double_t k30=cin30*r00+cin31*r10;
1354 Double_t k31=cin30*r10+cin31*r11;
1355 Double_t k40=cin40*r00+cin41*r10;
1356 Double_t k41=cin40*r10+cin41*r11;
1357 Double_t x0,x1,x2,x3,x4;
1358 newTrack->GetXElements(x0,x1,x2,x3,x4); // get the state vector
1359 Double_t savex0=x0, savex1=x1;
1360 x0+=k00*(m[0]-savex0)+k01*(m[1]-savex1);
1361 x1+=k10*(m[0]-savex0)+k11*(m[1]-savex1);
1362 x2+=k20*(m[0]-savex0)+k21*(m[1]-savex1);
1363 x3+=k30*(m[0]-savex0)+k31*(m[1]-savex1);
1364 x4+=k40*(m[0]-savex0)+k41*(m[1]-savex1);
1365 Double_t c00,c10,c20,c30,c40,c11,c21,c31,c41,c22,c32,c42,c33,c43,c44;
1366 c00=cin00-k00*cin00-k01*cin10;
1367 c10=cin10-k00*cin10-k01*cin11;
1368 c20=cin20-k00*cin20-k01*cin21;
1369 c30=cin30-k00*cin30-k01*cin31;
1370 c40=cin40-k00*cin40-k01*cin41;
1371 c11=cin11-k10*cin10-k11*cin11;
1372 c21=cin21-k10*cin20-k11*cin21;
1373 c31=cin31-k10*cin30-k11*cin31;
1374 c41=cin41-k10*cin40-k11*cin41;
1375 c22=cin22-k20*cin20-k21*cin21;
1376 c32=cin32-k20*cin30-k21*cin31;
1377 c42=cin42-k20*cin40-k21*cin41;
1378 c33=cin33-k30*cin30-k31*cin31;
1379 c43=cin43-k30*cin40-k31*cin41;
1380 c44=cin44-k40*cin40-k41*cin41;
1381 newTrack->PutXElements(x0,x1,x2,x3,x4); // put the new state vector
1382 newTrack->PutCElements(c00,
1386 c40,c41,c42,c43,c44); // put in track the
1388 Double_t vmcold00=v00-c00;
1389 Double_t vmcold10=-c10;
1390 Double_t vmcold11=v11-c11;
1391 ////////////////////// Matrix vmc inversion ///////////////////////
1392 det=vmcold00*vmcold11-vmcold10*vmcold10;
1393 Double_t vmc00=vmcold11/det;
1394 Double_t vmc10=-vmcold10/det;
1395 Double_t vmc11=vmcold00/det;
1396 ////////////////////////////////////////////////////////////////////
1397 Double_t chi2=(m[0]-x0)*( vmc00*(m[0]-x0) + 2.*vmc10*(m[1]-x1) ) +
1398 (m[1]-x1)*vmc11*(m[1]-x1);
1399 newTrack->SetChi2(newTrack->GetChi2()+chi2);
1401 //----------------------------------------------------------------------
1402 //void AliITSTrackerV1::KalmanFilterVert(AliITSTrackV1 *newTrack,
1403 // TVector &cluster,Double_t sigma[2]){
1404 void AliITSTrackerV1::KalmanFilterVert(AliITSTrackV1 *newTrack,
1405 TVector &cluster,Double_t sigma[2]
1406 /*, Double_t chi2pred*/){
1407 //Origin A. Badala' and G.S. Pappalardo:
1408 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1409 // Kalman filter with vertex constraint
1410 ///////////////////// Evaluation of the measurement vector m ////////
1412 Double_t rk,phik,zk;
1413 rk=cluster(0); phik=cluster(1); zk=cluster(2);
1415 Double_t cc=(*newTrack).GetC();
1416 Double_t zv=(*newTrack).GetZv();
1417 Double_t dv=(*newTrack).GetDv();
1419 Double_t tgl= (zk-zv)*cy/TMath::ASin(cy*rk);
1421 /////////////////////// Evaluation of the error matrix V //////////
1422 Int_t layer=newTrack->GetLayer();
1423 Double_t v00=sigma[0];
1424 Double_t v11=sigma[1];
1425 Double_t v31=sigma[1]/rk;
1426 Double_t sigmaDv=newTrack->GetsigmaDv();
1427 Double_t v22=sigmaDv*sigmaDv + newTrack->Getd2(layer-1);
1428 Double_t v32=newTrack->Getdtgl(layer-1);
1429 Double_t sigmaZv=newTrack->GetsigmaZv();
1430 Double_t v33=(sigma[1]+sigmaZv*sigmaZv)/(rk*rk)+newTrack->Gettgl2(layer-1);
1431 //////////////////////////////////////////////////////////////////
1432 Double_t cin00,cin10,cin11,cin20,cin21,cin22,
1433 cin30,cin31,cin32,cin33,cin40,cin41,cin42,cin43,cin44;
1434 newTrack->GetCElements(cin00,
1437 cin30,cin31,cin32,cin33,
1438 cin40,cin41,cin42,cin43,cin44); //get C matrix
1446 r[3][1]=cin31+sigma[1]/rk;
1447 r[2][2]=cin22+sigmaDv*sigmaDv+newTrack->Getd2(layer-1);
1448 r[3][2]=cin32+newTrack->Getdtgl(layer-1);
1449 r[3][3]=cin33+(sigma[1]+sigmaZv*sigmaZv)/(rk*rk)+
1450 newTrack->Gettgl2(layer-1);
1451 r[0][1]=r[1][0]; r[0][2]=r[2][0]; r[0][3]=r[3][0];
1452 r[1][2]=r[2][1]; r[1][3]=r[3][1]; r[2][3]=r[3][2];
1453 ///////////////////// Matrix R inversion //////////////////////////
1457 Int_t ll[kn],mm[kn];
1460 for(k=0; k<kn; k++) {
1464 for(j=k; j<kn ; j++) {
1465 for (i=j; i<kn; i++) {
1466 if(TMath::Abs(big) < TMath::Abs(r[i][j]) ) {
1476 for(i=0; i<kn; i++) {
1485 for(j=0; j<kn; j++) {
1494 cout << "Singular matrix\n";
1496 for(i=0; i<kn; i++) {
1497 if(i == k) { continue; }
1498 r[i][k]=r[i][k]/(-big);
1501 for(i=0; i<kn; i++) {
1503 for(j=0; j<kn; j++) {
1504 if(i == k || j == k) continue;
1505 r[i][j]=hold*r[k][j]+r[i][j];
1509 for(j=0; j<kn; j++) {
1510 if(j == k) continue;
1511 r[k][j]=r[k][j]/big;
1519 for(k=kn-1; k>=0; k--) {
1522 for (j=0; j<kn; j++) {
1530 for (i=0; i<kn; i++) {
1537 ////////////////////////////////////////////////////////////////////
1538 Double_t k00=cin00*r[0][0]+cin10*r[1][0]+cin20*r[2][0]+cin30*r[3][0];
1539 Double_t k01=cin00*r[1][0]+cin10*r[1][1]+cin20*r[2][1]+cin30*r[3][1];
1540 Double_t k02=cin00*r[2][0]+cin10*r[2][1]+cin20*r[2][2]+cin30*r[3][2];
1541 Double_t k03=cin00*r[3][0]+cin10*r[3][1]+cin20*r[3][2]+cin30*r[3][3];
1542 Double_t k10=cin10*r[0][0]+cin11*r[1][0]+cin21*r[2][0]+cin31*r[3][0];
1543 Double_t k11=cin10*r[1][0]+cin11*r[1][1]+cin21*r[2][1]+cin31*r[3][1];
1544 Double_t k12=cin10*r[2][0]+cin11*r[2][1]+cin21*r[2][2]+cin31*r[3][2];
1545 Double_t k13=cin10*r[3][0]+cin11*r[3][1]+cin21*r[3][2]+cin31*r[3][3];
1546 Double_t k20=cin20*r[0][0]+cin21*r[1][0]+cin22*r[2][0]+cin32*r[3][0];
1547 Double_t k21=cin20*r[1][0]+cin21*r[1][1]+cin22*r[2][1]+cin32*r[3][1];
1548 Double_t k22=cin20*r[2][0]+cin21*r[2][1]+cin22*r[2][2]+cin32*r[3][2];
1549 Double_t k23=cin20*r[3][0]+cin21*r[3][1]+cin22*r[3][2]+cin32*r[3][3];
1550 Double_t k30=cin30*r[0][0]+cin31*r[1][0]+cin32*r[2][0]+cin33*r[3][0];
1551 Double_t k31=cin30*r[1][0]+cin31*r[1][1]+cin32*r[2][1]+cin33*r[3][1];
1552 Double_t k32=cin30*r[2][0]+cin31*r[2][1]+cin32*r[2][2]+cin33*r[3][2];
1553 Double_t k33=cin30*r[3][0]+cin31*r[3][1]+cin32*r[3][2]+cin33*r[3][3];
1554 Double_t k40=cin40*r[0][0]+cin41*r[1][0]+cin42*r[2][0]+cin43*r[3][0];
1555 Double_t k41=cin40*r[1][0]+cin41*r[1][1]+cin42*r[2][1]+cin43*r[3][1];
1556 Double_t k42=cin40*r[2][0]+cin41*r[2][1]+cin42*r[2][2]+cin43*r[3][2];
1557 Double_t k43=cin40*r[3][0]+cin41*r[3][1]+cin42*r[3][2]+cin43*r[3][3];
1559 Double_t x0,x1,x2,x3,x4;
1560 newTrack->GetXElements(x0,x1,x2,x3,x4); // get the state vector
1561 Double_t savex0=x0, savex1=x1, savex2=x2, savex3=x3;
1562 x0+=k00*(m[0]-savex0)+k01*(m[1]-savex1)+k02*(m[2]-savex2)+
1564 x1+=k10*(m[0]-savex0)+k11*(m[1]-savex1)+k12*(m[2]-savex2)+
1566 x2+=k20*(m[0]-savex0)+k21*(m[1]-savex1)+k22*(m[2]-savex2)+
1568 x3+=k30*(m[0]-savex0)+k31*(m[1]-savex1)+k32*(m[2]-savex2)+
1570 x4+=k40*(m[0]-savex0)+k41*(m[1]-savex1)+k42*(m[2]-savex2)+
1572 Double_t c00,c10,c20,c30,c40,c11,c21,c31,c41,c22,c32,c42,c33,c43,c44;
1573 c00=cin00-k00*cin00-k01*cin10-k02*cin20-k03*cin30;
1574 c10=cin10-k00*cin10-k01*cin11-k02*cin21-k03*cin31;
1575 c20=cin20-k00*cin20-k01*cin21-k02*cin22-k03*cin32;
1576 c30=cin30-k00*cin30-k01*cin31-k02*cin32-k03*cin33;
1577 c40=cin40-k00*cin40-k01*cin41-k02*cin42-k03*cin43;
1578 c11=cin11-k10*cin10-k11*cin11-k12*cin21-k13*cin31;
1579 c21=cin21-k10*cin20-k11*cin21-k12*cin22-k13*cin32;
1580 c31=cin31-k10*cin30-k11*cin31-k12*cin32-k13*cin33;
1581 c41=cin41-k10*cin40-k11*cin41-k12*cin42-k13*cin43;
1582 c22=cin22-k20*cin20-k21*cin21-k22*cin22-k23*cin32;
1583 c32=cin32-k20*cin30-k21*cin31-k22*cin32-k23*cin33;
1584 c42=cin42-k20*cin40-k21*cin41-k22*cin42-k23*cin43;
1585 c33=cin33-k30*cin30-k31*cin31-k32*cin32-k33*cin33;
1586 c43=cin43-k30*cin40-k31*cin41-k32*cin42-k33*cin43;
1587 c44=cin44-k40*cin40-k41*cin41-k42*cin42-k43*cin43;
1589 newTrack->PutXElements(x0,x1,x2,x3,x4); // put the new state vector
1590 newTrack->PutCElements(c00,
1594 c40,c41,c42,c43,c44); // put in track the
1597 vmc[0][0]=v00-c00; vmc[1][0]=-c10; vmc[2][0]=-c20; vmc[3][0]=-c30;
1598 vmc[1][1]=v11-c11; vmc[2][1]=-c21; vmc[3][1]=v31-c31;
1599 vmc[2][2]=v22-c22; vmc[3][2]=v32-c32;
1601 vmc[0][1]=vmc[1][0]; vmc[0][2]=vmc[2][0]; vmc[0][3]=vmc[3][0];
1602 vmc[1][2]=vmc[2][1]; vmc[1][3]=vmc[3][1];
1603 vmc[2][3]=vmc[3][2];
1604 /////////////////////// vmc matrix inversion ///////////////////////
1606 for(k=0; k<kn; k++) {
1610 for(j=k; j<kn ; j++) {
1611 for (i=j; i<kn; i++) {
1612 if(TMath::Abs(big) < TMath::Abs(vmc[i][j]) ) {
1622 for(i=0; i<kn; i++) {
1624 vmc[k][i]=vmc[j][i];
1631 for(j=0; j<kn; j++) {
1633 vmc[j][k]=vmc[j][i];
1640 cout << "Singular matrix\n";
1642 for(i=0; i<kn; i++) {
1643 if(i == k) continue;
1644 vmc[i][k]=vmc[i][k]/(-big);
1647 for(i=0; i<kn; i++) {
1649 for(j=0; j<kn; j++) {
1650 if(i == k || j == k) continue;
1651 vmc[i][j]=hold*vmc[k][j]+vmc[i][j];
1655 for(j=0; j<kn; j++) {
1656 if(j == k) continue;
1657 vmc[k][j]=vmc[k][j]/big;
1665 for(k=kn-1; k>=0; k--) {
1668 for (j=0; j<kn; j++) {
1670 vmc[j][k]=-vmc[j][i];
1676 for (i=0; i<kn; i++) {
1678 vmc[k][i]=-vmc[j][i];
1683 ////////////////////////////////////////////////////////////////////
1684 Double_t chi2=(m[0]-x0)*( vmc[0][0]*(m[0]-x0) + 2.*vmc[1][0]*(m[1]-x1) +
1685 2.*vmc[2][0]*(m[2]-x2)+ 2.*vmc[3][0]*(m[3]-x3) )+
1686 (m[1]-x1)* ( vmc[1][1]*(m[1]-x1) + 2.*vmc[2][1]*(m[2]-x2)+
1687 2.*vmc[3][1]*(m[3]-x3) ) +
1688 (m[2]-x2)* ( vmc[2][2]*(m[2]-x2)+ 2.*vmc[3][2]*(m[3]-x3) ) +
1689 (m[3]-x3)*vmc[3][3]*(m[3]-x3);
1690 //cout<<" chi2 kalman = "<<chi2<<"\n"; getchar();
1691 newTrack->SetChi2(newTrack->GetChi2()+chi2);
1692 // newTrack->SetChi2(newTrack->GetChi2()+chi2pred);