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.24 2002/10/23 14:28:38 barbera
19 Fixes added to get into account the new magnetic field conversion factor automatically
21 Revision 1.23 2002/10/22 18:29:34 barbera
22 Tracking V1 ported to the HEAD
24 Revision 1.22 2002/10/22 14:45:36 alibrary
25 Introducing Riostream.h
27 Revision 1.21 2002/02/05 09:12:26 hristov
28 Small mods for gcc 3.02
30 Revision 1.20 2001/11/21 14:47:45 barbera
31 Some unuseful print-out commented out
33 Revision 1.19 2001/11/21 10:49:07 barbera
34 Bug correction suggested by Rene done
36 Revision 1.18 2001/11/20 15:46:17 barbera
37 Point coordinated are calculated in cylindrical reference frame once and for all at the beginning of tracking V1
39 Revision 1.10.2.1 2001/10/24 07:26:04 hristov
40 All the changes from the head are merged with the release
42 Revision 1.14 2001/10/24 07:19:57 hristov
43 Some pointer correctly initialised in one of the constructors
45 Revision 1.13 2001/10/21 19:17:12 hristov
46 Several pointers were set to zero in the default constructors to avoid memory management problems
48 Revision 1.12 2001/10/19 21:32:35 nilsen
49 Minor changes to remove compliation warning on gcc 2.92.2 compiler, and
50 cleanded up a little bit of code.
53 // The purpose of this class is to permorm the ITS tracking. The
54 // constructor has the task to inizialize some private members. The method
55 // DoTracking is written to be called by a macro. It gets the event number,
56 // the minimum and maximum order number of TPC tracks that are to be tracked
57 // trough the ITS, and the file where the recpoints are registered. The
58 // method Recursivetracking is a recursive function that performs the
59 // tracking trough the ITS The method Intersection found the layer, ladder
60 // and detector whre the intersection take place and caluclate the
61 // cohordinates of this intersection. It returns an integer that is 0 if the
62 // intersection has been found successfully. The two mwthods Kalmanfilter
63 // and kalmanfiltervert operate the kalmanfilter without and with the vertex
64 // imposition respectively. The authors thank Mariana Bondila to have help
65 // them to resolve some problems. July-2000
67 #include <Riostream.h>
68 #include <Riostream.h>
74 #include <TStopwatch.h>
76 #include "TParticle.h"
79 #include "AliITSsegmentationSSD.h"
80 #include "AliITSgeomSPD.h"
81 #include "AliITSgeomSDD.h"
82 #include "AliITSgeomSSD.h"
83 #include "AliITSgeom.h"
84 #include "AliITSRecPoint.h"
86 #include "AliKalmanTrack.h"
88 #include "AliITSTrackV1.h"
89 #include "AliITSIOTrack.h"
90 #include "AliITSRad.h"
91 #include "../TPC/AliTPCtracker.h"
92 #include "AliITSTrackerV1.h"
93 #include "AliITSVertex.h"
94 #include "AliITSPid.h"
96 ClassImp(AliITSTrackerV1)
97 //______________________________________________________________________
98 AliITSTrackerV1::AliITSTrackerV1() {
111 for(ia=0; ia<6; ia++) {
129 //______________________________________________________________________
130 AliITSTrackerV1::AliITSTrackerV1(AliITS* IITTSS, Int_t evnumber, Bool_t flag) {
131 //Origin A. Badala' and G.S. Pappalardo:
132 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
133 // Class constructor. It does some initializations.
135 //PH Initialisation taken from the default constructor
150 Int_t imax = 200,jmax = 450;
151 frl = new AliITSRad(imax,jmax);
153 ////////// gets information on geometry /////////////////////////////
154 AliITSgeom *g1 = fITS->GetITSgeom();
159 for(ia=0; ia<6; ia++) {
160 fNlad[ia]=g1->GetNladders(ia+1);
161 fNdet[ia]=g1->GetNdetectors(ia+1);
162 //cout<<fNlad[i]<<" "<<fNdet[i]<<"\n";
165 //cout<<" mean radius = ";
167 for(ib=0; ib<6; ib++) {
168 g1->GetCenterThetaPhi(ib+1,ll,dd,det);
169 Double_t r1=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
170 g1->GetCenterThetaPhi(ib+1,ll,dd+1,det);
171 Double_t r2=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
172 fAvrad[ib]=(r1+r2)/2.;
173 //cout<<fAvrad[ib]<<" ";
175 //cout<<"\n"; getchar();
177 fDetx[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDx();
178 fDetz[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDz();
180 fDetx[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDx();
181 fDetz[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDz();
183 fDetx[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDx();
184 fDetz[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDz();
186 fDetx[3] = ((AliITSgeomSDD*)(g1->GetShape(4, ll, dd)))->GetDx();
187 fDetz[3] = ((AliITSgeomSDD*)(g1->GetShape(4, ll, dd)))->GetDz();
189 fDetx[4] = ((AliITSgeomSSD*)(g1->GetShape(5, ll, dd)))->GetDx();
190 fDetz[4] = ((AliITSgeomSSD*)(g1->GetShape(5, ll, dd)))->GetDz();
192 fDetx[5] = ((AliITSgeomSSD*)(g1->GetShape(6, ll, dd)))->GetDx();
193 fDetz[5] = ((AliITSgeomSSD*)(g1->GetShape(6, ll, dd)))->GetDz();
194 //cout<<" Detx Detz\n";
195 //for(Int_t la=0; la<6; la++) cout<<" "<<fDetx[la]<<" "<<
199 // allocate memory and define matrices fzmin, fzmax, fphimin and fphimax //
201 Double_t epszdrift=0.05;
203 fzmin = new Double_t*[6]; fzmax = new Double_t*[6];
204 Int_t im1, im2, im2max;
205 for(im1=0; im1<6; im1++) {
207 fzmin[im1] = new Double_t[im2max]; fzmax[im1] = new Double_t[im2max];
210 for(im1=0; im1<6; im1++) {
212 for(im2=0; im2<im2max; im2++) {
213 g1->GetCenterThetaPhi(im1+1,1,im2+1,det);
214 if(im2!=0) fzmin[im1][im2]=det(2)-fDetz[im1];
216 fzmin[im1][im2]=det(2)-(fDetz[im1])*epsz;
217 if(im2!=(im2max-1)) fzmax[im1][im2]=det(2)+fDetz[im1];
219 fzmax[im1][im2]=det(2)+fDetz[im1]*epsz;
220 if(im1==2 || im1==3) {
221 fzmin[im1][im2]-=epszdrift;
222 fzmax[im1][im2]+=epszdrift;
223 } // end if im1==2 || im1==3
227 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
228 for(im1=0;im1<6;im1++) {
230 fphimin[im1] = new Double_t[im2max];
231 fphimax[im1] = new Double_t[im2max];
234 fphidet = new Double_t*[6];
235 for(im1=0; im1<6; im1++) {
237 fphidet[im1] = new Double_t[im2max];
240 Double_t global[3],local[3];
241 Double_t pigre=TMath::Pi();
242 Double_t xmin,ymin,xmax,ymax;
244 for(im1=0; im1<6; im1++) {
246 for(im2=0; im2<im2max; im2++) {
248 g1->GetCenterThetaPhi(im1+1,im2+1,idet,det);
249 fphidet[im1][im2] = TMath::ATan2(Double_t(det(1)),
251 if(fphidet[im1][im2]<0.) fphidet[im1][im2]+=2.*pigre;
252 local[1]=local[2]=0.;
253 local[0]= -(fDetx[im1]);
254 if(im1==0) local[0]= (fDetx[im1]); //to take into account
255 // different reference system
256 g1->LtoG(im1+1,im2+1,idet,local,global);
257 xmax=global[0]; ymax=global[1];
258 local[0]= (fDetx[im1]);
259 if(im1==0) local[0]= -(fDetx[im1]);//take into account different
261 g1->LtoG(im1+1,im2+1,idet,local,global);
262 xmin=global[0]; ymin=global[1];
263 fphimin[im1][im2]= TMath::ATan2(ymin,xmin);
264 if(fphimin[im1][im2]<0.) fphimin[im1][im2]+=2.*pigre;
265 fphimax[im1][im2]= TMath::ATan2(ymax,xmax);
266 if(fphimax[im1][im2]<0.) fphimax[im1][im2]+=2.*pigre;
269 //////////////////////////////////////////////////////////////////////////////////////////////////////////
270 /////////////// allocate memory and define vector fNRecPoints and matrices fRecCylR, fRecCylPhi, fRecCylZ /////////////
271 gAlice->GetEvent(evnumber);
272 Int_t NumOfModules = g1->GetIndexMax();
273 fRecCylR = new Double_t *[NumOfModules];
274 fRecCylPhi = new Double_t *[NumOfModules];
275 fRecCylZ = new Double_t *[NumOfModules];
276 AliITSRecPoint *recp;
277 fNRecPoints = new Int_t[NumOfModules];
279 for(Int_t module=0; module<NumOfModules; module++) {
280 fITS->ResetRecPoints();
281 gAlice->TreeR()->GetEvent(module);
282 frecPoints=fITS->RecPoints();
283 Int_t nRecPoints=fNRecPoints[module]=frecPoints->GetEntries();
284 fRecCylR[module] = new Double_t[nRecPoints];
285 fRecCylPhi[module] = new Double_t[nRecPoints];
286 fRecCylZ[module] = new Double_t[nRecPoints];
288 for(ind=0; ind<fNRecPoints[module]; ind++) {
289 recp=(AliITSRecPoint*)frecPoints->UncheckedAt(ind);
290 // Float_t global[3], local[3];
291 Double_t global[3], local[3];
292 local[0]=recp->GetX();
294 local[2]= recp->GetZ();
295 g1->LtoG(module,local,global);
297 Double_t r = TMath::Sqrt(global[0]*global[0]+global[1]*global[1]); // r hit
298 Double_t phi = TMath::ATan2(global[1],global[0]); if(phi<0.) phi+=2.*TMath::Pi(); // phi hit
299 Double_t z = global[2]; // z hit
301 fRecCylR[module][ind]=r;
302 fRecCylPhi[module][ind]=phi;
303 fRecCylZ[module][ind]=z;
308 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
311 ////////// gets magnetic field factor //////////////////////////////
313 AliMagF * fieldPointer = gAlice->Field();
314 // fFieldFactor = (Double_t)fieldPointer->Factor();
315 fFieldFactor =(Double_t)fieldPointer-> SolenoidField()/10/.2;
316 // cout<< " field factor = "<<fFieldFactor<<"\n"; getchar();
318 //______________________________________________________________________
319 AliITSTrackerV1::AliITSTrackerV1(const AliITSTrackerV1 &cobj) {
320 // Origin A. Badala' and G.S. Pappalardo:
321 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
325 *fresult = *cobj.fresult;
326 fPtref = cobj.fPtref;
327 fChi2max = cobj.fChi2max;
328 **fvettid = **cobj.fvettid;
329 fflagvert = cobj.fflagvert;
330 Int_t imax=200,jmax=450;
331 frl = new AliITSRad(imax,jmax);
333 fFieldFactor = cobj.fFieldFactor;
334 Int_t i,im1,im2,im2max;
336 fNlad[i] = cobj.fNlad[i];
337 fNdet[i] = cobj.fNdet[i];
338 fAvrad[i] = cobj.fAvrad[i];
339 fDetx[i] = cobj.fDetx[i];
340 fDetz[i] = cobj.fDetz[i];
342 fzmin = new Double_t*[6]; fzmax = new Double_t*[6];
343 for(im1=0; im1<6; im1++) {
345 fzmin[im1] = new Double_t[im2max];
346 fzmax[im1] = new Double_t[im2max];
348 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
349 for(im1=0;im1<6;im1++) {
351 fphimin[im1] = new Double_t[im2max];
352 fphimax[im1] = new Double_t[im2max];
355 fphidet = new Double_t*[6];
356 for(im1=0; im1<6; im1++) {
358 fphidet[im1] = new Double_t[im2max];
360 for(im1=0; im1<6; im1++) {
362 for(im2=0; im2<im2max; im2++) {
363 fzmin[im1][im2]=cobj.fzmin[im1][im2];
364 fzmax[im1][im2]=cobj.fzmax[im1][im2];
367 for(im1=0; im1<6; im1++) {
369 for(im2=0; im2<im2max; im2++) {
370 fphimin[im1][im2]=cobj.fphimin[im1][im2];
371 fphimax[im1][im2]=cobj.fphimax[im1][im2];
372 fphidet[im1][im2]=cobj.fphidet[im1][im2];
377 AliITSgeom *g1 = fITS->GetITSgeom();
378 Int_t NumOfModules = g1->GetIndexMax();
380 fRecCylR = new Float_t *[NumOfModules];
381 fRecCylPhi = new Float_t *[NumOfModules];
382 fRecCylZ = new Float_t *[NumOfModules];
384 fRecCylR = new Double_t *[NumOfModules];
385 fRecCylPhi = new Double_t *[NumOfModules];
386 fRecCylZ = new Double_t *[NumOfModules];
387 fNRecPoints = new Int_t[NumOfModules];
388 for(Int_t module=0; module<NumOfModules; module++) {
389 Int_t nRecPoints=fNRecPoints[module]=cobj.fNRecPoints[module];
391 fRecCylR[module] = new Float_t[nRecPoints];
392 fRecCylPhi[module] = new Float_t[nRecPoints];
393 fRecCylZ[module] = new Float_t[nRecPoints];
395 fRecCylR[module] = new Double_t[nRecPoints];
396 fRecCylPhi[module] = new Double_t[nRecPoints];
397 fRecCylZ[module] = new Double_t[nRecPoints];
399 for(ind=0; ind<nRecPoints; ind++) {
400 fRecCylR[module][ind]=cobj.fRecCylR[module][ind];
401 fRecCylPhi[module][ind]=cobj.fRecCylPhi[module][ind];
402 fRecCylZ[module][ind]=cobj.fRecCylZ[module][ind];
407 void AliITSTrackerV1::DelMatrix(Int_t NumOfModules) {
408 for(Int_t mod=0; mod<NumOfModules; mod++) {
409 delete fRecCylR[mod];
410 delete fRecCylPhi[mod];
411 delete fRecCylZ[mod];
417 //______________________________________________________________________
418 AliITSTrackerV1::~AliITSTrackerV1(){
419 // Origin A. Badala' and G.S. Pappalardo:
420 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
424 for(Int_t i=0; i<6; i++) {
439 //______________________________________________________________________
440 AliITSTrackerV1 &AliITSTrackerV1::operator=(AliITSTrackerV1 obj) {
441 // Origin A. Badala' and G.S. Pappalardo:
442 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
443 // assignement operator
446 *fresult = *obj.fresult;
448 fChi2max = obj.fChi2max;
449 **fvettid = **obj.fvettid;
450 fflagvert = obj.fflagvert;
451 Int_t imax=200,jmax=450;
452 frl = new AliITSRad(imax,jmax);
454 fFieldFactor = obj.fFieldFactor;
457 fNlad[i] = obj.fNlad[i];
458 fNdet[i] = obj.fNdet[i];
459 fAvrad[i] = obj.fAvrad[i];
460 fDetx[i] = obj.fDetx[i];
461 fDetz[i] = obj.fDetz[i];
463 fzmin = new Double_t*[6];
464 fzmax = new Double_t*[6];
465 Int_t im1, im2, im2max;
466 for(im1=0; im1<6; im1++) {
468 fzmin[im1] = new Double_t[im2max]; fzmax[im1] = new Double_t[im2max];
470 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
471 for(im1=0;im1<6;im1++) {
473 fphimin[im1] = new Double_t[im2max];
474 fphimax[im1] = new Double_t[im2max];
477 fphidet = new Double_t*[6];
478 for(im1=0; im1<6; im1++) {
480 fphidet[im1] = new Double_t[im2max];
482 for(im1=0; im1<6; im1++) {
484 for(im2=0; im2<im2max; im2++) {
485 fzmin[im1][im2]=obj.fzmin[im1][im2];
486 fzmax[im1][im2]=obj.fzmax[im1][im2];
489 for(im1=0; im1<6; im1++) {
491 for(im2=0; im2<im2max; im2++) {
492 fphimin[im1][im2]=obj.fphimin[im1][im2];
493 fphimax[im1][im2]=obj.fphimax[im1][im2];
494 fphidet[im1][im2]=obj.fphidet[im1][im2];
498 AliITSgeom *g1 = fITS->GetITSgeom();
499 Int_t NumOfModules = g1->GetIndexMax();
500 fRecCylR = new Double_t *[NumOfModules];
501 fRecCylPhi = new Double_t *[NumOfModules];
502 fRecCylZ = new Double_t *[NumOfModules];
503 fNRecPoints = new Int_t[NumOfModules];
504 for(Int_t module=0; module<NumOfModules; module++) {
505 Int_t nRecPoints=fNRecPoints[module]=obj.fNRecPoints[module];
506 fRecCylR[module] = new Double_t[nRecPoints];
507 fRecCylPhi[module] = new Double_t[nRecPoints];
508 fRecCylZ[module] = new Double_t[nRecPoints];
510 for(ind=0; ind<nRecPoints; ind++) {
511 fRecCylR[module][ind]=obj.fRecCylR[module][ind];
512 fRecCylPhi[module][ind]=obj.fRecCylPhi[module][ind];
513 fRecCylZ[module][ind]=obj.fRecCylZ[module][ind];
520 //______________________________________________________________________
521 void AliITSTrackerV1::DoTracking(Int_t evNumber,Int_t minTr,Int_t maxTr,
522 TFile *file, Bool_t realmass) {
523 // Origin A. Badala' and G.S. Pappalardo:
524 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
525 // The method needs the event number, the minimum and maximum order
526 // number of TPC tracks that
527 // are to be tracked trough the ITS, and the file where the recpoints
529 // The method can be called by a macro. It preforms the tracking for
530 // all good TPC tracks
532 printf("begin DoTracking - file %p\n",file);
534 gAlice->GetEvent(evNumber); //modificato per gestire hbt
536 AliKalmanTrack *kkprov;
537 //kkprov->SetConvConst(100/0.299792458/0.2/fFieldFactor);
538 kkprov->SetConvConst(1000/0.299792458/gAlice->Field()->SolenoidField());
539 // cout<<" field = "<<gAlice->Field()->SolenoidField()<<endl;
542 TFile *cf=TFile::Open("AliTPCclusters.root");
543 AliTPCParam *digp= (AliTPCParam*)cf->Get("75x40_100x60_150x60");
544 if (!digp) { cerr<<"TPC parameters have not been found !\n"; getchar();}
547 AliTPCtracker *tracker = new AliTPCtracker(digp,evNumber);
550 tracker->LoadInnerSectors();
551 tracker->LoadOuterSectors();
554 TFile *tf=TFile::Open("AliTPCtracksSorted.root");
556 cerr<<"Can't open AliTPCtracksSorted.root !\n";
559 TObjArray tracks(200000);
561 sprintf(tname,"TreeT_TPC_%d",evNumber);
563 TTree *tracktree=(TTree*)tf->Get(tname);
564 if (!tracktree) {cerr<<"Can't get a tree with TPC tracks !\n";}
565 TBranch *tbranch=tracktree->GetBranch("tracks");
566 Int_t nentr=(Int_t)tracktree->GetEntries();
569 AliITSRecPoint *recp; // oggi
570 AliTPCtrack *ioTrackTPC=0;
571 for (kk=0; kk<nentr; kk++) {
572 ioTrackTPC=new AliTPCtrack;
573 tbranch->SetAddress(&ioTrackTPC);
574 tracktree->GetEvent(kk);
575 tracker->CookLabel(ioTrackTPC,0.1);
576 tracks.AddLast(ioTrackTPC);
581 Int_t nt = tracks.GetEntriesFast();
582 cerr<<"Number of found tracks "<<nt<<endl;
585 TTree *tr=gAlice->TreeR();
586 Int_t nent=(Int_t)tr->GetEntries();
587 frecPoints = fITS->RecPoints();
591 Int_t *np = new Int_t[nent];
592 fvettid = new Int_t* [nent];
595 for (mod=0; mod<nent; mod++) {
597 fITS->ResetRecPoints();
598 gAlice->TreeR()->GetEvent(mod);
599 numbpoints = frecPoints->GetEntries();
600 totalpoints+=numbpoints;
601 np[mod] = numbpoints;
602 //cout<<" mod = "<<mod<<" numbpoints = "<<numbpoints<<"\n";getchar();
603 fvettid[mod] = new Int_t[numbpoints];
605 for (ii=0;ii<numbpoints; ii++) *(fvettid[mod]+ii)=0;
608 AliTPCtrack *track=0;
610 if(minTr < 0) {minTr = 0; maxTr = nt-1;}
614 TTree tracktree1("TreeT","Tree with ITS tracks");
615 AliITSIOTrack *ioTrack=0;
616 AliITSPid *pid=new AliITSPid(1000); // oggi
618 tracktree1.Branch("ITStracks","AliITSIOTrack",&ioTrack,32000,0);
620 TDatabasePDG * db = new TDatabasePDG;
623 for (j=minTr; j<=maxTr; j++) {
624 track=(AliTPCtrack*)tracks.UncheckedAt(j);
625 if (!track) continue;
627 /// mass definition ////////////////////////
628 Double_t mass=0.13956995;
629 Int_t pcode=211; // a pion by default
632 if(TMath::Abs(pcode)<20443) mass=db->GetParticle(pcode)->Mass();
635 mass = track->GetMass();
636 cout << "Mass = " << mass << endl;
641 // new propagation to the end of TPC
643 // track->PropagateTo(xk,0.,0.); //Ne if it's still there //attenzione funziona solo se modifica in TPC
644 // Double_t xk=77.415;
645 track->PropagateTo(xk, 28.94, 1.204e-3);
647 track->PropagateTo(xk, 44.77,1.71); //Tedlar
649 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
651 track->PropagateTo(xk, 41.28, 0.029);//Nomex
653 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
655 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
658 // track->PropagateTo(xk,0.,0.); //C02
659 track->PropagateTo(xk,36.2,1.98e-3); //C02 //attenzione funziona solo se modifica in TPC
662 track->PropagateTo(xk, 24.01, 2.7); //Al
664 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
666 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
668 track->PropagateTo(xk, 41.28, 0.029); //Nomex
670 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
672 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
674 track->PropagateTo(xk, 24.01, 2.7); //Al
676 ////////////////////////////////////////////////////////////////////////////////////////////////////////
677 //AliITSTrackV1 trackITS(*track);
678 AliITSTrackV1 trackITS(*track, fFieldFactor);
679 //cout<<" fFieldFactor = "<<fFieldFactor<<"\n";
680 trackITS.PutMass(mass); //new to add mass to track
681 if(fresult){ delete fresult; fresult=0;}
682 fresult = new AliITSTrackV1(trackITS);
684 AliITSTrackV1 primaryTrack(trackITS);
685 vgeant=(*fresult).GetVertex();
687 // Definition of dv and zv for vertex constraint
688 Double_t sigmaDv=0.0050; Double_t sigmaZv=0.010;
689 //Double_t sigmaDv=0.0015; Double_t sigmaZv=0.0015;
690 Double_t uniform= gRandom->Uniform();
692 if(uniform<=0.5) signdv=-1.;
696 Double_t vr=TMath::Sqrt(vgeant(0)*vgeant(0)+ vgeant(1)*vgeant(1));
697 Double_t dv=gRandom->Gaus(signdv*vr,(Float_t)sigmaDv);
698 Double_t zv=gRandom->Gaus(vgeant(2),(Float_t)sigmaZv);
699 //cout<<" Dv e Zv = "<<dv<<" "<<zv<<"\n";
702 trackITS.SetsigmaDv(sigmaDv);
703 trackITS.SetsigmaZv(sigmaZv);
704 (*fresult).SetDv(dv);
705 (*fresult).SetZv(zv);
706 (*fresult).SetsigmaDv(sigmaDv);
707 (*fresult).SetsigmaZv(sigmaZv);
708 primaryTrack.SetDv(dv);
709 primaryTrack.SetZv(zv);
710 primaryTrack.SetsigmaDv(sigmaDv);
711 primaryTrack.SetsigmaZv(sigmaZv);
712 primaryTrack.PrimaryTrack(frl);
713 TVector d2=primaryTrack.Getd2();
714 TVector tgl2=primaryTrack.Gettgl2();
715 TVector dtgl=primaryTrack.Getdtgl();
716 trackITS.Setd2(d2); trackITS.Settgl2(tgl2);
717 trackITS.Setdtgl(dtgl);
718 (*fresult).Setd2(d2); (*fresult).Settgl2(tgl2);
719 (*fresult).Setdtgl(dtgl);
721 trackITS.SetVertex(vertex); trackITS.SetErrorVertex(ervertex);
722 (*result).SetVertex(vertex); (*result).SetErrorVertex(ervertex);
724 TList *list= new TList();
726 list->AddLast(&trackITS);
728 fPtref=TMath::Abs( (trackITS).GetPt() );
729 //cout<<" fPtref = " <<fPtref<<"\n";
730 if(fPtref>1.0) fChi2max=40.;
731 if(fPtref<=1.0) fChi2max=20.;
732 if(fPtref<0.4 ) fChi2max=100.;
733 if(fPtref<0.2 ) fChi2max=40.;
734 // if(fPtref<0.4 ) fChi2max=30.;
735 // if(fPtref<0.2 ) fChi2max=20.;
736 //if(fPtref<0.2 ) fChi2max=10.;
737 //if(fPtref<0.1 ) fChi2max=5.;
738 //cout << "\n Pt = " << fPtref <<"\n"; //stampa
739 RecursiveTracking(list);
744 TVector vecTotLabRef(18);
746 for(lay=5; lay>=0; lay--) {
747 TVector vecLabRef(3);
748 vecLabRef=(*fresult).GetLabTrack(lay);
749 Float_t clustZ=(*fresult).GetZclusterTrack( lay);
751 Int_t lpp=(Int_t)vecLabRef(k);
753 TParticle *p=(TParticle*) gAlice->Particle(lpp);
754 Int_t pcode=p->GetPdgCode();
755 if(pcode==11) vecLabRef(k)=p->GetFirstMother();
757 itot++; vecTotLabRef(itot)=vecLabRef(k);
758 if(vecLabRef(k)==0. && clustZ == -1.) vecTotLabRef(itot) =-3.;
763 (*fresult).Search(vecTotLabRef, labref, freq);
765 //if(freq < 6) labref=-labref; // cinque - sei
766 if(freq < 5) labref=-labref; // cinque - sei
767 (*fresult).SetLabel(labref);
769 // cout<<" progressive track number = "<<j<<"\r";
771 Int_t numOfCluster=(*fresult).GetNumClust();
772 //cout<<" progressive track number = "<<j<<"\n"; // stampa
773 Long_t labITS=(*fresult).GetLabel();
774 //cout << " ITS track label = " << labITS << "\n"; // stampa
775 Int_t lab=track->GetLabel();
776 //cout << " TPC track label = " << lab <<"\n"; // stampa
777 //propagation to vertex
780 if((*fresult).DoNotCross(rbeam)) continue; //no intersection with beampipe
781 (*fresult).Propagation(rbeam);
782 Double_t c00,c10,c11,c20,c21,c22,c30,c31,c32,c33,c40,c41,c42,c43,c44;
783 (*fresult).GetCElements(c00,
787 c40,c41,c42,c43,c44);
789 Double_t pt=TMath::Abs((*fresult).GetPt());
790 Double_t dr=(*fresult).GetD();
791 Double_t z=(*fresult).GetZ();
792 Double_t tgl=(*fresult).GetTgl();
793 Double_t c=(*fresult).GetC();
795 Double_t dz=z-(tgl/cy)*TMath::ASin((*fresult).Arga(rbeam));
797 // cout<<" dr e dz alla fine = "<<dr<<" "<<dz<<"\n"; getchar();
798 Double_t phi=(*fresult).Getphi();
799 Double_t phivertex = phi - TMath::ASin((*fresult).ArgA(rbeam));
800 Double_t duepi=2.*TMath::Pi();
801 if(phivertex>duepi) phivertex-=duepi;
802 if(phivertex<0.) phivertex+=duepi;
803 /////////////////////////////////////////////////////////////
804 Int_t idmodule,idpoint;
805 if(numOfCluster >=5) { // cinque - sei
806 //if(numOfCluster ==6) { // cinque - sei
807 AliITSIOTrack outTrack;
809 ioTrack->SetStatePhi(phi);
810 ioTrack->SetStateZ(z);
811 ioTrack->SetStateD(dr);
812 ioTrack->SetStateTgl(tgl);
813 ioTrack->SetStateC(c);
814 Double_t radius=(*fresult).Getrtrack();
815 ioTrack->SetRadius(radius);
817 if(c>0.) charge=-1; else charge=1;
818 ioTrack->SetCharge(charge);
819 Double_t trackmass=(*fresult).GetMass(); // oggi
820 ioTrack->SetMass(trackmass); // oggi
821 ioTrack->SetCovMatrix(c00,
825 c40,c41,c42,c43,c44);
826 Double_t px=pt*TMath::Cos(phivertex);
827 Double_t py=pt*TMath::Sin(phivertex);
829 Double_t xtrack=dr*TMath::Sin(phivertex);
830 Double_t ytrack=dr*TMath::Cos(phivertex);
831 Double_t ztrack=dz+vgeant(2);
835 ioTrack->SetX(xtrack);
836 ioTrack->SetY(ytrack);
837 ioTrack->SetZ(ztrack);
838 ioTrack->SetLabel(labITS);
839 ioTrack->SetTPCLabel(lab);
843 for(il=0;il<6; il++){
844 ioTrack->SetIdPoint(il,(*fresult).GetIdPoint(il));
845 ioTrack->SetIdModule(il,(*fresult).GetIdModule(il));
849 Float_t q[4]={-1.,-1.,-1.,-1.};
850 Float_t globaldedx=0.;
851 for (il=0;il<6;il++) {
852 idpoint=(*fresult).GetIdPoint(il);
853 idmodule=(*fresult).GetIdModule(il);
854 if(idmodule>0.) *(fvettid[idmodule]+idpoint)=1;
856 ioTrack->SetIdPoint(il,idpoint);
857 ioTrack->SetIdModule(il,idmodule);
858 //// for q definition
861 fITS->ResetRecPoints();
862 gAlice->TreeR()->GetEvent(idmodule);
863 recp=(AliITSRecPoint*)frecPoints->UncheckedAt(idpoint);
864 q[il-2]=recp->GetQ()*(*fresult).Getfcor(il-2);
868 q[0]/=280.; q[1]/=280.;
869 q[2]/=38.; q[3]/=38.;
871 // cout<<" q prima = "<<q[0]<<" "<<q[1]<<" "<<q[2]<<" "<<q[3]<<"\n"; getchar();
876 for (il=0; il<3; il++) {
877 if (q[il]<=q[il+1]) continue;
879 q[il]=q[il+1]; q[il+1]=tmp;
885 // cout<<" q dopo = "<<q[0]<<" "<<q[1]<<" "<<q[2]<<" "<<q[3]<<"\n"; getchar();
894 // cout<<" q dopo if = "<<q[0]<<" "<<q[1]<<" "<<q[2]<<" "<<q[3]<<"\n"; getchar();
896 globaldedx=(q[0]+q[1])/2.;
898 // if(q[3]> 0.) globaldedx=(q[0]+q[1]+q[2]+q[3])/4.;
899 // else globaldedx=(q[0]+q[1]+q[2])/3.;
901 ioTrack->SetdEdx(globaldedx);
902 ioTrack->SetPid(pid->GetPcode(ioTrack));
905 } // end if on numOfCluster
906 //gObjectTable->Print(); // stampa memoria
907 } // end for (int j=minTr; j<=maxTr; j++)
909 static Bool_t first=kTRUE;
912 tfile=new TFile("itstracks.root","RECREATE");
913 //cout<<"I have opened itstracks.root file "<<endl;
919 sprintf(hname,"TreeT%d",evNumber);
920 cout << "Number of saved ITS tracks " << tracktree1.GetEntries() << endl;
921 tracktree1.Write(hname);
923 TTree *fAli=gAlice->TreeK();
925 if (fAli) fileAli =fAli->GetCurrentFile();
927 ////////////////////////////////////////////////////////////////////
929 printf("delete vectors\n");
931 if(fvettid) delete [] fvettid;
932 if(fresult) {delete fresult; fresult=0;}
934 //______________________________________________________________________
935 void AliITSTrackerV1::RecursiveTracking(TList *trackITSlist) {
936 // This function perform the recursive tracking in ITS detectors
937 // reference is a pointer to the final best track
938 // Origin A. Badala' and G.S. Pappalardo:
939 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
940 // The authors thank Mariana Bondila to have help them to resolve some
941 // problems. July-2000
943 //Rlayer[0]=4.; Rlayer[1]=7.; Rlayer[2]=14.9;
944 // Rlayer[3]=23.8; Rlayer[4]=39.1; Rlayer[5]=43.6; //vecchio
946 //////////////////////
947 Float_t sigmaphil[6], sigmazl[6];
948 sigmaphil[0]=1.44e-6/(fAvrad[0]*fAvrad[0]);
949 sigmaphil[1]=1.44e-6/(fAvrad[1]*fAvrad[1]);
950 sigmaphil[2]=1.444e-5/(fAvrad[2]*fAvrad[2]);
951 sigmaphil[3]=1.444e-5/(fAvrad[3]*fAvrad[3]);
952 sigmaphil[4]=4e-6/(fAvrad[4]*fAvrad[4]);
953 sigmaphil[5]=4e-6/(fAvrad[5]*fAvrad[5]);
960 ///////////////////////////////////////////////////////////
962 AliITSgeom *g1 = fITS->GetITSgeom();
963 AliITSRecPoint *recp;
964 for(index =0; index<trackITSlist->GetSize(); index++) {
965 AliITSTrackV1 *trackITS = (AliITSTrackV1 *) trackITSlist->At(index);
966 if((*trackITS).GetLayer()==7) fresult->SetChi2(10.223e140);
967 // cout <<" Layer inizio = "<<(*trackITS).GetLayer()<<"\n";
968 // cout<<"fvtrack =" <<"\n";
969 // cout << (*trackITS)(0) << " "<<(*trackITS)(1)<<" "
970 // <<(*trackITS)(2)<<" "<<(*trackITS)(3)<<" "
971 // <<(*trackITS)(4)<<"\n";
972 // cout<< " rtrack = "<<(*trackITS).Getrtrack()<<"\n";
973 // cout<< " Pt = "<<(*trackITS).GetPt()<<"\n";
975 Double_t chi2Now, chi2Ref;
976 Float_t numClustRef = fresult->GetNumClust();
977 if((*trackITS).GetLayer()==1 ) {
978 chi2Now = trackITS->GetChi2();
979 Float_t numClustNow = trackITS->GetNumClust();
980 if(trackITS->GetNumClust())
981 chi2Now /= (Double_t)trackITS->GetNumClust();
982 chi2Ref = fresult->GetChi2();
983 if(fresult->GetNumClust())
984 chi2Ref /= (Double_t)fresult->GetNumClust();
985 //cout<<" chi2Now and chi2Ref = "<<chi2Now<<" "<<chi2Ref<<"\n";
986 if( numClustNow > numClustRef ) {*fresult = *trackITS;}
987 if((numClustNow == numClustRef )&&
988 (chi2Now < chi2Ref)) {
989 *fresult = *trackITS;
994 if(trackITS->Getfnoclust()>=2) continue;
995 Float_t numClustNow = trackITS->GetNumClust();
997 chi2Now = trackITS->GetChi2();
999 if(numClustNow<numClustRef && chi2Now>fresult->GetChi2()) continue;
1000 //cout<<" chi2Now = "<<chi2Now<<"\n";
1002 chi2Now/=numClustNow;
1003 if(fPtref > 1.0 && chi2Now > 30.) continue;
1004 if((fPtref >= 0.6 && fPtref<=1.0) && chi2Now > 40.) continue;
1005 // if((fPtref <= 0.6 && fPtref>0.2)&& chi2Now > 40.) continue;
1006 // if(fPtref <= 0.2 && chi2Now > 8.) continue;
1007 if((fPtref <= 0.6 && fPtref>0.2)&& chi2Now > 30.) continue;
1008 if(fPtref <= 0.2 && chi2Now > 7.) continue;
1009 /////////////////////////////
1012 Int_t layerInit = (*trackITS).GetLayer();
1013 Int_t layernew = layerInit - 2;// -1 for new layer, -1 for matrix index
1015 Int_t ladp, ladm, detp,detm,ladinters,detinters;
1016 Int_t layerfin=layerInit-1;
1017 // cout<<"Prima di intersection \n";
1018 Int_t outinters=Intersection(*trackITS,layerfin,ladinters,detinters);
1019 // cout<<" outinters = "<<outinters<<"\n";
1020 // cout<<" Layer ladder detector intersection ="
1021 // <<layerfin<<" "<<ladinters<<" "<<detinters<<"\n";
1022 // cout << " phiinters zinters = "<<(*trackITS)(0)
1023 // << " "<<(*trackITS)(1)<<"\n"; getchar();
1024 if(outinters==-1) continue;
1026 (*trackITS).SetLayer(layerfin); // oggi
1027 (*trackITS).Setfcor(); // oggi
1029 TVector toucLad(9), toucDet(9);
1030 Int_t lycur=layerfin;
1033 if(ladm <= 0) ladm=fNlad[layerfin-1];
1034 if(ladp > fNlad[layerfin-1]) ladp=1;
1039 toucLad(0)=ladinters; toucLad(1)=ladm; toucLad(2)=ladp;
1040 toucLad(3)=ladinters; toucLad(4)=ladm; toucLad(5)=ladp;
1041 toucLad(6)=ladinters; toucLad(7)=ladm; toucLad(8)=ladp;
1042 toucDet(0)=detinters; toucDet(1)=detinters; toucDet(2)=detinters;
1043 if(detm > 0 && detp <= fNdet[layerfin-1]) {
1045 toucDet(3)=detm; toucDet(4)=detm; toucDet(5)=detm;
1046 toucDet(6)=detp; toucDet(7)=detp; toucDet(8)=detp;
1048 if(detm > 0 && detp > fNdet[layerfin-1]) {
1050 toucDet(3)=detm; toucDet(4)=detm; toucDet(5)=detm;
1052 if(detm <= 0 && detp <= fNdet[layerfin-1]) {
1054 toucDet(3)=detp; toucDet(4)=detp; toucDet(5)=detp;
1057 Float_t epsphi=5.0, epsz=5.0;
1058 if(fPtref<0.2) {epsphi=3.; epsz=3.;}
1059 // new definition of idetot e toucLad e toucDet to be
1060 // transformed in a method
1061 // these values could be modified
1062 Float_t pigre=TMath::Pi();
1063 Float_t rangephi=5., rangez=5.;
1064 if(layerfin==1 || layerfin ==2){
1065 rangephi=40.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1066 (*trackITS).GetSigmaphi());
1067 rangez = 40.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1068 (*trackITS).GetSigmaZ());
1070 if(layerfin==3 || layerfin ==4){
1071 //rangephi=30.*fepsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1072 // (*trackITS).GetSigmaphi());
1073 //rangez = 40.*fepsz*TMath::Sqrt(sigmazl[layerfin-1]+
1074 // (*trackITS).GetSigmaZ());
1075 rangephi=40.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1076 (*trackITS).GetSigmaphi());
1077 rangez = 50.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1078 (*trackITS).GetSigmaZ());
1080 if(layerfin==5 || layerfin ==6){
1081 rangephi=20.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1082 (*trackITS).GetSigmaphi());
1083 rangez =5.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1084 (*trackITS).GetSigmaZ());
1086 Float_t phinters, zinters;
1087 phinters=(*trackITS).Getphi();
1088 zinters=(*trackITS).GetZ();
1089 Float_t distz = 0.0;
1090 Float_t phicm, phicp, distphim, distphip;
1092 if(phinters>fphimax[layerfin-1][ladm-1]) phicm=phinters-2*pigre; //corretto il 20-11-2001
1093 distphim=TMath::Abs(phicm-fphimax[layerfin-1][ladm-1]); //corretto il 20-11-2001
1095 //cout<<" fNlad[layerfin-1] e ladp = "<<fNlad[layerfin-1]<<" "<<ladp<<endl;
1096 if(phinters>fphimin[layerfin-1][ladp-1]) phicp=phinters-2.*pigre; //corretto il 20-11-2001
1097 distphip=TMath::Abs(phicp-fphimin[layerfin-1][ladp-1]); //corretto il 20-11-2001
1101 toucLad(0)=ladinters; toucDet(0)=detinters;
1102 if(detm>0) distz=TMath::Abs(zinters-fzmax[layerfin-1][detm-1]);
1103 if(detm>0 && rangez>=distz){
1105 idetot++; toucLad(idetot-1)=ladinters; toucDet(idetot-1)=detm;
1106 if(rangephi>=distphim){
1108 toucLad(idetot-1)=ladm;
1109 toucDet(idetot-1)=detinters;
1111 toucLad(idetot-1)=ladm;
1112 toucDet(idetot-1)=detm;
1114 if(rangephi>=distphip){
1116 toucLad(idetot-1)=ladp;
1117 toucDet(idetot-1)=detinters;
1119 toucLad(idetot-1)=ladp;
1120 toucDet(idetot-1)=detm;
1123 if(detp<=fNdet[layerfin-1])
1124 distz=TMath::Abs(zinters-fzmin[layerfin-1][detp-1]);
1125 if(detp<=fNdet[layerfin-1] && rangez>=distz){
1127 idetot++; toucLad(idetot-1)=ladinters; toucDet(idetot-1)=detp;
1128 if(rangephi>=distphim){
1129 idetot++; toucLad(idetot-1)=ladm; toucDet(idetot-1)=detp;
1132 toucLad(idetot-1)=ladm;
1133 toucDet(idetot-1)=detinters;
1136 if(rangephi>=distphip){
1138 toucLad(idetot-1)=ladp;
1139 toucDet(idetot-1)=detp;
1142 toucLad(idetot-1)=ladp;
1143 toucDet(idetot-1)=detinters;
1146 } //end detm<fNdet[.......
1148 if(flagzmin == 0 && flagzmax==0){
1149 if(rangephi>=distphim){
1151 toucLad(idetot-1)=ladm;
1152 toucDet(idetot-1)=detinters;
1154 if(rangephi>=distphip){
1156 toucLad(idetot-1)=ladp;
1157 toucDet(idetot-1)=detinters;
1160 ////////////////////////////////////////////////////////////
1162 for (iriv=0; iriv<idetot; iriv++) { //for on detectors
1163 ///////////////////////////////////////////////////////
1164 /*** Rec points sorted by module *****/
1165 /**************************************/
1167 indexmod = g1->GetModuleIndex(lycur,(Int_t)toucLad(iriv),
1168 (Int_t)toucDet(iriv));
1169 fITS->ResetRecPoints();
1170 gAlice->TreeR()->GetEvent(indexmod);
1171 Int_t npoints=frecPoints->GetEntries();
1174 for(indnew=0; indnew<npoints; indnew++){
1175 if (*(fvettid[indexmod]+indnew)==0)
1176 recp =(AliITSRecPoint*)frecPoints->UncheckedAt(indnew);
1179 TVector cluster(3),vecclust(9);
1180 //vecclust(6)=vecclust(7)=vecclust(8)=-1.;
1182 // now vecclust is with cylindrical cohordinates
1183 vecclust(0)=(Float_t)fRecCylR[indexmod][indnew];
1184 vecclust(1)=(Float_t)fRecCylPhi[indexmod][indnew];
1185 vecclust(2)=(Float_t)fRecCylZ[indexmod][indnew];
1186 vecclust(3) = (Float_t)recp->fTracks[0];
1187 vecclust(4) = (Float_t)indnew;
1188 vecclust(5) = (Float_t)indexmod;
1189 vecclust(6) = (Float_t)recp->fTracks[0];
1190 vecclust(7) = (Float_t)recp->fTracks[1];
1191 vecclust(8) = (Float_t)recp->fTracks[2];
1192 sigma[0] = (Double_t) recp->GetSigmaX2();
1193 sigma[1] = (Double_t) recp->GetSigmaZ2();
1195 cluster(0)=fRecCylR[indexmod][indnew];
1196 cluster(1)=fRecCylPhi[indexmod][indnew];
1197 cluster(2)=fRecCylZ[indexmod][indnew];
1199 // cout<<" layer = "<<play<<"\n";
1200 // cout<<" cluster prima = "<<vecclust(0)<<" "
1201 // <<vecclust(1)<<" "
1202 // <<vecclust(2)<<"\n"; getchar();
1204 Float_t sigmatotphi, sigmatotz;
1205 // Float_t epsphi=5.0, epsz=5.0;
1206 //if(fPtref<0.2) {epsphi=3.; epsz=3.;}
1207 Double_t rTrack=(*trackITS).Getrtrack();
1208 Double_t sigmaphi=sigma[0]/(rTrack*rTrack);
1209 sigmatotphi=epsphi*TMath::Sqrt(sigmaphi +
1210 (*trackITS).GetSigmaphi());
1211 sigmatotz=epsz*TMath::Sqrt(sigma[1] +
1212 (*trackITS).GetSigmaZ());
1213 //cout<<"cluster e sigmatotphi e track = "<<cluster(0)
1214 // <<" "<<cluster(1)<<" "<<sigmatotphi<<" "
1215 // <<vecclust(3)<<"\n";
1216 //if(vecclust(3)==481) getchar();
1217 if(cluster(1)<6. && (*trackITS).Getphi()>6.)
1218 cluster(1)=cluster(1)+(2.*TMath::Pi());
1219 if(cluster(1)>6. && (*trackITS).Getphi()<6.)
1220 cluster(1)=cluster(1)-(2.*TMath::Pi());
1221 if(TMath::Abs(cluster(1)-(*trackITS).Getphi())>sigmatotphi)
1223 // cout<<" supero sigmaphi \n";
1224 AliITSTrackV1 *newTrack = new AliITSTrackV1((*trackITS));
1225 //(*newTrack).SetLayer((*trackITS).GetLayer()-1);
1226 if (TMath::Abs(rTrack-cluster(0))/rTrack>1e-6)
1227 (*newTrack).Correct(Double_t(cluster(0)));
1228 //cout<<" cluster(2) e(*newTrack).GetZ()="<<cluster(2)<<" "
1229 // << (*newTrack).GetZ()<<"\n";
1230 if(TMath::Abs(cluster(2)-(*newTrack).GetZ()) > sigmatotz){
1234 Double_t sigmanew[2];
1235 sigmanew[0]= sigmaphi;
1236 sigmanew[1]=sigma[1];
1240 // Double_t chi2pred=newTrack->GetPredChi2(m,sigmanew);
1241 // cout<<" chi2pred = "<<chi2pred<<"\n";
1242 // if(chi2pred>fChi2max) continue; //aggiunto il 30-7-2001
1243 if(iriv == 0) flaghit=1;
1244 (*newTrack).AddMS(frl); // add the multiple scattering
1245 //matrix to the covariance matrix
1246 (*newTrack).AddEL(frl,1.,0);
1249 KalmanFilterVert(newTrack,cluster,sigmanew);
1250 //KalmanFilterVert(newTrack,cluster,sigmanew,chi2pred);
1252 KalmanFilter(newTrack,cluster,sigmanew);
1254 (*newTrack).PutCluster(layernew, vecclust);
1255 newTrack->AddClustInTrack();
1256 listoftrack.AddLast(newTrack);
1258 } // end of for on detectors (iriv)
1259 }//end if(outinters==0)
1261 if(flaghit==0 || outinters==-2) {
1262 AliITSTrackV1 *newTrack = new AliITSTrackV1(*trackITS);
1263 (*newTrack).Setfnoclust();
1264 //(*newTrack).SetLayer((*trackITS).GetLayer()-1);
1265 (*newTrack).AddMS(frl); // add the multiple scattering matrix
1266 // to the covariance matrix
1267 (*newTrack).AddEL(frl,1.,0);
1268 listoftrack.AddLast(newTrack);
1271 //gObjectTable->Print(); // stampa memoria
1273 RecursiveTracking(&listoftrack);
1274 listoftrack.Delete();
1275 } // end of for on tracks (index)
1277 //gObjectTable->Print(); // stampa memoria
1279 //______________________________________________________________________
1280 Int_t AliITSTrackerV1::Intersection(AliITSTrackV1 &track,Int_t layer,
1281 Int_t &ladder,Int_t &detector) {
1282 // Origin A. Badala' and G.S. Pappalardo
1283 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1284 // Found the intersection and the detector
1286 Double_t rk=fAvrad[layer-1];
1287 if(track.DoNotCross(rk)){ /*cout<< " Do not cross \n";*/ return -1;}
1288 track.Propagation(rk);
1289 Double_t zinters=track.GetZ();
1290 Double_t phinters=track.Getphi();
1291 //cout<<"zinters = "<<zinters<<" phinters = "<<phinters<<"\n";
1295 TVector distZCenter(2);
1299 for(iD = 1; iD<= fNdet[layer-1]; iD++) {
1300 if(zinters > fzmin[layer-1][iD-1] && zinters <= fzmax[layer-1][iD-1]) {
1302 cout<< " Errore su iz in Intersection \n";
1305 listDet(iz)= iD; distZCenter(iz)=TMath::Abs(zinters-det(2));
1311 if(iz==0) {/* cout<< " No detector along Z \n";*/ return -2;}
1312 detector=Int_t (listDet(0));
1313 if(iz>1 && (distZCenter(0)>distZCenter(1))) detector=Int_t (listDet(1));
1316 TVector distPhiCenter(2);
1318 Double_t pigre=TMath::Pi();
1320 for(iLd = 1; iLd<= fNlad[layer-1]; iLd++) {
1321 Double_t phimin=fphimin[layer-1][iLd-1];
1322 Double_t phimax=fphimax[layer-1][iLd-1];
1323 Double_t phidet=fphidet[layer-1][iLd-1];
1324 Double_t phiconfr=phinters;
1326 //if(phimin <5.5) {cout<<" Error in Intersection for phi \n";
1329 if(phinters>(1.5*pigre)) phiconfr=phinters-(2.*pigre);
1330 if(phidet>(1.5*pigre)) phidet-=(2.*pigre);
1332 if(phiconfr>phimin && phiconfr<= phimax) {
1334 cout<< " Errore su ip in Intersection \n"; getchar();
1337 distPhiCenter(ip)=TMath::Abs(phiconfr-phidet); ip++;
1341 if(ip==0) { cout<< " No detector along phi \n"; getchar();}
1342 ladder=Int_t (listLad(0));
1343 if(ip>1 && (distPhiCenter(0)>distPhiCenter(1))) ladder=Int_t (listLad(1));
1346 //______________________________________________________________________
1347 void AliITSTrackerV1::KalmanFilter(AliITSTrackV1 *newTrack,TVector &cluster,
1349 //Origin A. Badala' and G.S. Pappalardo:
1350 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1351 // Kalman filter without vertex constraint
1352 ////// Evaluation of the measurement vector ////////////////////////
1354 Double_t rk,phik,zk;
1355 rk=cluster(0); phik=cluster(1); zk=cluster(2);
1357 //////////////////////// Evaluation of the error matrix V /////////
1358 Double_t v00=sigma[0];
1359 Double_t v11=sigma[1];
1360 ////////////////////////////////////////////////////////////////////
1361 Double_t cin00,cin10,cin20,cin30,cin40,cin11,cin21,cin31,cin41,cin22,
1362 cin32,cin42,cin33,cin43,cin44;
1364 newTrack->GetCElements(cin00,
1367 cin30,cin31,cin32,cin33,
1368 cin40,cin41,cin42,cin43,cin44); //get C matrix
1369 Double_t rold00=cin00+v00;
1370 Double_t rold10=cin10;
1371 Double_t rold11=cin11+v11;
1372 ////////////////////// R matrix inversion /////////////////////////
1373 Double_t det=rold00*rold11-rold10*rold10;
1374 Double_t r00=rold11/det;
1375 Double_t r10=-rold10/det;
1376 Double_t r11=rold00/det;
1377 ////////////////////////////////////////////////////////////////////
1378 Double_t k00=cin00*r00+cin10*r10;
1379 Double_t k01=cin00*r10+cin10*r11;
1380 Double_t k10=cin10*r00+cin11*r10;
1381 Double_t k11=cin10*r10+cin11*r11;
1382 Double_t k20=cin20*r00+cin21*r10;
1383 Double_t k21=cin20*r10+cin21*r11;
1384 Double_t k30=cin30*r00+cin31*r10;
1385 Double_t k31=cin30*r10+cin31*r11;
1386 Double_t k40=cin40*r00+cin41*r10;
1387 Double_t k41=cin40*r10+cin41*r11;
1388 Double_t x0,x1,x2,x3,x4;
1389 newTrack->GetXElements(x0,x1,x2,x3,x4); // get the state vector
1390 Double_t savex0=x0, savex1=x1;
1391 x0+=k00*(m[0]-savex0)+k01*(m[1]-savex1);
1392 x1+=k10*(m[0]-savex0)+k11*(m[1]-savex1);
1393 x2+=k20*(m[0]-savex0)+k21*(m[1]-savex1);
1394 x3+=k30*(m[0]-savex0)+k31*(m[1]-savex1);
1395 x4+=k40*(m[0]-savex0)+k41*(m[1]-savex1);
1396 Double_t c00,c10,c20,c30,c40,c11,c21,c31,c41,c22,c32,c42,c33,c43,c44;
1397 c00=cin00-k00*cin00-k01*cin10;
1398 c10=cin10-k00*cin10-k01*cin11;
1399 c20=cin20-k00*cin20-k01*cin21;
1400 c30=cin30-k00*cin30-k01*cin31;
1401 c40=cin40-k00*cin40-k01*cin41;
1402 c11=cin11-k10*cin10-k11*cin11;
1403 c21=cin21-k10*cin20-k11*cin21;
1404 c31=cin31-k10*cin30-k11*cin31;
1405 c41=cin41-k10*cin40-k11*cin41;
1406 c22=cin22-k20*cin20-k21*cin21;
1407 c32=cin32-k20*cin30-k21*cin31;
1408 c42=cin42-k20*cin40-k21*cin41;
1409 c33=cin33-k30*cin30-k31*cin31;
1410 c43=cin43-k30*cin40-k31*cin41;
1411 c44=cin44-k40*cin40-k41*cin41;
1412 newTrack->PutXElements(x0,x1,x2,x3,x4); // put the new state vector
1413 newTrack->PutCElements(c00,
1417 c40,c41,c42,c43,c44); // put in track the
1419 Double_t vmcold00=v00-c00;
1420 Double_t vmcold10=-c10;
1421 Double_t vmcold11=v11-c11;
1422 ////////////////////// Matrix vmc inversion ///////////////////////
1423 det=vmcold00*vmcold11-vmcold10*vmcold10;
1424 Double_t vmc00=vmcold11/det;
1425 Double_t vmc10=-vmcold10/det;
1426 Double_t vmc11=vmcold00/det;
1427 ////////////////////////////////////////////////////////////////////
1428 Double_t chi2=(m[0]-x0)*( vmc00*(m[0]-x0) + 2.*vmc10*(m[1]-x1) ) +
1429 (m[1]-x1)*vmc11*(m[1]-x1);
1430 newTrack->SetChi2(newTrack->GetChi2()+chi2);
1432 //----------------------------------------------------------------------
1433 //void AliITSTrackerV1::KalmanFilterVert(AliITSTrackV1 *newTrack,
1434 // TVector &cluster,Double_t sigma[2]){
1435 void AliITSTrackerV1::KalmanFilterVert(AliITSTrackV1 *newTrack,
1436 TVector &cluster,Double_t sigma[2]
1437 /*, Double_t chi2pred*/){
1438 //Origin A. Badala' and G.S. Pappalardo:
1439 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1440 // Kalman filter with vertex constraint
1441 ///////////////////// Evaluation of the measurement vector m ////////
1443 Double_t rk,phik,zk;
1444 rk=cluster(0); phik=cluster(1); zk=cluster(2);
1446 Double_t cc=(*newTrack).GetC();
1447 Double_t zv=(*newTrack).GetZv();
1448 Double_t dv=(*newTrack).GetDv();
1450 Double_t tgl= (zk-zv)*cy/TMath::ASin(cy*rk);
1452 /////////////////////// Evaluation of the error matrix V //////////
1453 Int_t layer=newTrack->GetLayer();
1454 Double_t v00=sigma[0];
1455 Double_t v11=sigma[1];
1456 Double_t v31=sigma[1]/rk;
1457 Double_t sigmaDv=newTrack->GetsigmaDv();
1458 Double_t v22=sigmaDv*sigmaDv + newTrack->Getd2(layer-1);
1459 Double_t v32=newTrack->Getdtgl(layer-1);
1460 Double_t sigmaZv=newTrack->GetsigmaZv();
1461 Double_t v33=(sigma[1]+sigmaZv*sigmaZv)/(rk*rk)+newTrack->Gettgl2(layer-1);
1462 //////////////////////////////////////////////////////////////////
1463 Double_t cin00,cin10,cin11,cin20,cin21,cin22,
1464 cin30,cin31,cin32,cin33,cin40,cin41,cin42,cin43,cin44;
1465 newTrack->GetCElements(cin00,
1468 cin30,cin31,cin32,cin33,
1469 cin40,cin41,cin42,cin43,cin44); //get C matrix
1477 r[3][1]=cin31+sigma[1]/rk;
1478 r[2][2]=cin22+sigmaDv*sigmaDv+newTrack->Getd2(layer-1);
1479 r[3][2]=cin32+newTrack->Getdtgl(layer-1);
1480 r[3][3]=cin33+(sigma[1]+sigmaZv*sigmaZv)/(rk*rk)+
1481 newTrack->Gettgl2(layer-1);
1482 r[0][1]=r[1][0]; r[0][2]=r[2][0]; r[0][3]=r[3][0];
1483 r[1][2]=r[2][1]; r[1][3]=r[3][1]; r[2][3]=r[3][2];
1484 ///////////////////// Matrix R inversion //////////////////////////
1488 Int_t ll[kn],mm[kn];
1491 for(k=0; k<kn; k++) {
1495 for(j=k; j<kn ; j++) {
1496 for (i=j; i<kn; i++) {
1497 if(TMath::Abs(big) < TMath::Abs(r[i][j]) ) {
1507 for(i=0; i<kn; i++) {
1516 for(j=0; j<kn; j++) {
1525 cout << "Singular matrix\n";
1527 for(i=0; i<kn; i++) {
1528 if(i == k) { continue; }
1529 r[i][k]=r[i][k]/(-big);
1532 for(i=0; i<kn; i++) {
1534 for(j=0; j<kn; j++) {
1535 if(i == k || j == k) continue;
1536 r[i][j]=hold*r[k][j]+r[i][j];
1540 for(j=0; j<kn; j++) {
1541 if(j == k) continue;
1542 r[k][j]=r[k][j]/big;
1550 for(k=kn-1; k>=0; k--) {
1553 for (j=0; j<kn; j++) {
1561 for (i=0; i<kn; i++) {
1568 ////////////////////////////////////////////////////////////////////
1569 Double_t k00=cin00*r[0][0]+cin10*r[1][0]+cin20*r[2][0]+cin30*r[3][0];
1570 Double_t k01=cin00*r[1][0]+cin10*r[1][1]+cin20*r[2][1]+cin30*r[3][1];
1571 Double_t k02=cin00*r[2][0]+cin10*r[2][1]+cin20*r[2][2]+cin30*r[3][2];
1572 Double_t k03=cin00*r[3][0]+cin10*r[3][1]+cin20*r[3][2]+cin30*r[3][3];
1573 Double_t k10=cin10*r[0][0]+cin11*r[1][0]+cin21*r[2][0]+cin31*r[3][0];
1574 Double_t k11=cin10*r[1][0]+cin11*r[1][1]+cin21*r[2][1]+cin31*r[3][1];
1575 Double_t k12=cin10*r[2][0]+cin11*r[2][1]+cin21*r[2][2]+cin31*r[3][2];
1576 Double_t k13=cin10*r[3][0]+cin11*r[3][1]+cin21*r[3][2]+cin31*r[3][3];
1577 Double_t k20=cin20*r[0][0]+cin21*r[1][0]+cin22*r[2][0]+cin32*r[3][0];
1578 Double_t k21=cin20*r[1][0]+cin21*r[1][1]+cin22*r[2][1]+cin32*r[3][1];
1579 Double_t k22=cin20*r[2][0]+cin21*r[2][1]+cin22*r[2][2]+cin32*r[3][2];
1580 Double_t k23=cin20*r[3][0]+cin21*r[3][1]+cin22*r[3][2]+cin32*r[3][3];
1581 Double_t k30=cin30*r[0][0]+cin31*r[1][0]+cin32*r[2][0]+cin33*r[3][0];
1582 Double_t k31=cin30*r[1][0]+cin31*r[1][1]+cin32*r[2][1]+cin33*r[3][1];
1583 Double_t k32=cin30*r[2][0]+cin31*r[2][1]+cin32*r[2][2]+cin33*r[3][2];
1584 Double_t k33=cin30*r[3][0]+cin31*r[3][1]+cin32*r[3][2]+cin33*r[3][3];
1585 Double_t k40=cin40*r[0][0]+cin41*r[1][0]+cin42*r[2][0]+cin43*r[3][0];
1586 Double_t k41=cin40*r[1][0]+cin41*r[1][1]+cin42*r[2][1]+cin43*r[3][1];
1587 Double_t k42=cin40*r[2][0]+cin41*r[2][1]+cin42*r[2][2]+cin43*r[3][2];
1588 Double_t k43=cin40*r[3][0]+cin41*r[3][1]+cin42*r[3][2]+cin43*r[3][3];
1590 Double_t x0,x1,x2,x3,x4;
1591 newTrack->GetXElements(x0,x1,x2,x3,x4); // get the state vector
1592 Double_t savex0=x0, savex1=x1, savex2=x2, savex3=x3;
1593 x0+=k00*(m[0]-savex0)+k01*(m[1]-savex1)+k02*(m[2]-savex2)+
1595 x1+=k10*(m[0]-savex0)+k11*(m[1]-savex1)+k12*(m[2]-savex2)+
1597 x2+=k20*(m[0]-savex0)+k21*(m[1]-savex1)+k22*(m[2]-savex2)+
1599 x3+=k30*(m[0]-savex0)+k31*(m[1]-savex1)+k32*(m[2]-savex2)+
1601 x4+=k40*(m[0]-savex0)+k41*(m[1]-savex1)+k42*(m[2]-savex2)+
1603 Double_t c00,c10,c20,c30,c40,c11,c21,c31,c41,c22,c32,c42,c33,c43,c44;
1604 c00=cin00-k00*cin00-k01*cin10-k02*cin20-k03*cin30;
1605 c10=cin10-k00*cin10-k01*cin11-k02*cin21-k03*cin31;
1606 c20=cin20-k00*cin20-k01*cin21-k02*cin22-k03*cin32;
1607 c30=cin30-k00*cin30-k01*cin31-k02*cin32-k03*cin33;
1608 c40=cin40-k00*cin40-k01*cin41-k02*cin42-k03*cin43;
1609 c11=cin11-k10*cin10-k11*cin11-k12*cin21-k13*cin31;
1610 c21=cin21-k10*cin20-k11*cin21-k12*cin22-k13*cin32;
1611 c31=cin31-k10*cin30-k11*cin31-k12*cin32-k13*cin33;
1612 c41=cin41-k10*cin40-k11*cin41-k12*cin42-k13*cin43;
1613 c22=cin22-k20*cin20-k21*cin21-k22*cin22-k23*cin32;
1614 c32=cin32-k20*cin30-k21*cin31-k22*cin32-k23*cin33;
1615 c42=cin42-k20*cin40-k21*cin41-k22*cin42-k23*cin43;
1616 c33=cin33-k30*cin30-k31*cin31-k32*cin32-k33*cin33;
1617 c43=cin43-k30*cin40-k31*cin41-k32*cin42-k33*cin43;
1618 c44=cin44-k40*cin40-k41*cin41-k42*cin42-k43*cin43;
1620 newTrack->PutXElements(x0,x1,x2,x3,x4); // put the new state vector
1621 newTrack->PutCElements(c00,
1625 c40,c41,c42,c43,c44); // put in track the
1628 vmc[0][0]=v00-c00; vmc[1][0]=-c10; vmc[2][0]=-c20; vmc[3][0]=-c30;
1629 vmc[1][1]=v11-c11; vmc[2][1]=-c21; vmc[3][1]=v31-c31;
1630 vmc[2][2]=v22-c22; vmc[3][2]=v32-c32;
1632 vmc[0][1]=vmc[1][0]; vmc[0][2]=vmc[2][0]; vmc[0][3]=vmc[3][0];
1633 vmc[1][2]=vmc[2][1]; vmc[1][3]=vmc[3][1];
1634 vmc[2][3]=vmc[3][2];
1635 /////////////////////// vmc matrix inversion ///////////////////////
1637 for(k=0; k<kn; k++) {
1641 for(j=k; j<kn ; j++) {
1642 for (i=j; i<kn; i++) {
1643 if(TMath::Abs(big) < TMath::Abs(vmc[i][j]) ) {
1653 for(i=0; i<kn; i++) {
1655 vmc[k][i]=vmc[j][i];
1662 for(j=0; j<kn; j++) {
1664 vmc[j][k]=vmc[j][i];
1671 cout << "Singular matrix\n";
1673 for(i=0; i<kn; i++) {
1674 if(i == k) continue;
1675 vmc[i][k]=vmc[i][k]/(-big);
1678 for(i=0; i<kn; i++) {
1680 for(j=0; j<kn; j++) {
1681 if(i == k || j == k) continue;
1682 vmc[i][j]=hold*vmc[k][j]+vmc[i][j];
1686 for(j=0; j<kn; j++) {
1687 if(j == k) continue;
1688 vmc[k][j]=vmc[k][j]/big;
1696 for(k=kn-1; k>=0; k--) {
1699 for (j=0; j<kn; j++) {
1701 vmc[j][k]=-vmc[j][i];
1707 for (i=0; i<kn; i++) {
1709 vmc[k][i]=-vmc[j][i];
1714 ////////////////////////////////////////////////////////////////////
1715 Double_t chi2=(m[0]-x0)*( vmc[0][0]*(m[0]-x0) + 2.*vmc[1][0]*(m[1]-x1) +
1716 2.*vmc[2][0]*(m[2]-x2)+ 2.*vmc[3][0]*(m[3]-x3) )+
1717 (m[1]-x1)* ( vmc[1][1]*(m[1]-x1) + 2.*vmc[2][1]*(m[2]-x2)+
1718 2.*vmc[3][1]*(m[3]-x3) ) +
1719 (m[2]-x2)* ( vmc[2][2]*(m[2]-x2)+ 2.*vmc[3][2]*(m[3]-x3) ) +
1720 (m[3]-x3)*vmc[3][3]*(m[3]-x3);
1721 //cout<<" chi2 kalman = "<<chi2<<"\n"; getchar();
1722 newTrack->SetChi2(newTrack->GetChi2()+chi2);
1723 // newTrack->SetChi2(newTrack->GetChi2()+chi2pred);