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>
40 #include "TParticle.h"
42 #include "AliITSDetTypeRec.h"
43 #include "AliITSgeomSPD.h"
44 #include "AliITSgeomSDD.h"
45 #include "AliITSgeomSSD.h"
46 #include "AliITSgeom.h"
47 #include "AliITSRecPoint.h"
48 #include "AliKalmanTrack.h"
50 #include "AliITSTrackV1.h"
51 #include "AliITSIOTrack.h"
52 #include "AliITSRad.h"
53 #include "AliTPCtracker.h"
54 #include "AliITSTrackerV1.h"
55 #include "AliITSPid.h"
58 ClassImp(AliITSTrackerV1)
59 //______________________________________________________________________
60 AliITSTrackerV1::AliITSTrackerV1() {
73 for(ia=0; ia<6; ia++) {
92 //______________________________________________________________________
93 AliITSTrackerV1::AliITSTrackerV1(Int_t evnumber, Bool_t flag) {
94 //Origin A. Badala' and G.S. Pappalardo:
95 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
96 // Class constructor. It does some initializations.
98 //PH Initialisation taken from the default constructor
113 Int_t imax = 200,jmax = 450;
114 frl = new AliITSRad(imax,jmax);
116 ////////// gets information on geometry /////////////////////////////
117 AliRunLoader* rl = AliRunLoader::Open("galice.root");
118 AliITSLoader* loader = (AliITSLoader*)runLoader->GetLoader("ITSLoader");
120 Error("AliITSTrackerV1", "ITS loader not found");
123 fDetTypeRec = new AliITSDetTypeRec(loader);
124 AliITSgeom* g1 = loader->GetITSgeom();
130 for(ia=0; ia<6; ia++) {
131 fNlad[ia]=g1->GetNladders(ia+1);
132 fNdet[ia]=g1->GetNdetectors(ia+1);
133 //cout<<fNlad[i]<<" "<<fNdet[i]<<"\n";
136 //cout<<" mean radius = ";
138 for(ib=0; ib<6; ib++) {
139 g1->GetCenterThetaPhi(ib+1,ll,dd,det);
140 Double_t r1=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
141 g1->GetCenterThetaPhi(ib+1,ll,dd+1,det);
142 Double_t r2=TMath::Sqrt(det(0)*det(0)+det(1)*det(1));
143 fAvrad[ib]=(r1+r2)/2.;
144 //cout<<fAvrad[ib]<<" ";
146 //cout<<"\n"; getchar();
148 fDetx[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDx();
149 fDetz[0] = ((AliITSgeomSPD*)(g1->GetShape(1, ll, dd)))->GetDz();
151 fDetx[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDx();
152 fDetz[1] = ((AliITSgeomSPD*)(g1->GetShape(2, ll, dd)))->GetDz();
154 fDetx[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDx();
155 fDetz[2] = ((AliITSgeomSDD*)(g1->GetShape(3, ll, dd)))->GetDz();
157 fDetx[3] = ((AliITSgeomSDD*)(g1->GetShape(4, ll, dd)))->GetDx();
158 fDetz[3] = ((AliITSgeomSDD*)(g1->GetShape(4, ll, dd)))->GetDz();
160 fDetx[4] = ((AliITSgeomSSD*)(g1->GetShape(5, ll, dd)))->GetDx();
161 fDetz[4] = ((AliITSgeomSSD*)(g1->GetShape(5, ll, dd)))->GetDz();
163 fDetx[5] = ((AliITSgeomSSD*)(g1->GetShape(6, ll, dd)))->GetDx();
164 fDetz[5] = ((AliITSgeomSSD*)(g1->GetShape(6, ll, dd)))->GetDz();
165 //cout<<" Detx Detz\n";
166 //for(Int_t la=0; la<6; la++) cout<<" "<<fDetx[la]<<" "<<
170 // allocate memory and define matrices fzmin, fzmax, fphimin and fphimax //
172 Double_t epszdrift=0.05;
174 fzmin = new Double_t*[6]; fzmax = new Double_t*[6];
175 Int_t im1, im2, im2max;
176 for(im1=0; im1<6; im1++) {
178 fzmin[im1] = new Double_t[im2max]; fzmax[im1] = new Double_t[im2max];
181 for(im1=0; im1<6; im1++) {
183 for(im2=0; im2<im2max; im2++) {
184 g1->GetCenterThetaPhi(im1+1,1,im2+1,det);
185 if(im2!=0) fzmin[im1][im2]=det(2)-fDetz[im1];
187 fzmin[im1][im2]=det(2)-(fDetz[im1])*epsz;
188 if(im2!=(im2max-1)) fzmax[im1][im2]=det(2)+fDetz[im1];
190 fzmax[im1][im2]=det(2)+fDetz[im1]*epsz;
191 if(im1==2 || im1==3) {
192 fzmin[im1][im2]-=epszdrift;
193 fzmax[im1][im2]+=epszdrift;
194 } // end if im1==2 || im1==3
198 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
199 for(im1=0;im1<6;im1++) {
201 fphimin[im1] = new Double_t[im2max];
202 fphimax[im1] = new Double_t[im2max];
205 fphidet = new Double_t*[6];
206 for(im1=0; im1<6; im1++) {
208 fphidet[im1] = new Double_t[im2max];
211 Double_t global[3],local[3];
212 Double_t pigre=TMath::Pi();
213 Double_t xmin,ymin,xmax,ymax;
215 for(im1=0; im1<6; im1++) {
217 for(im2=0; im2<im2max; im2++) {
219 g1->GetCenterThetaPhi(im1+1,im2+1,idet,det);
220 fphidet[im1][im2] = TMath::ATan2(Double_t(det(1)),
222 if(fphidet[im1][im2]<0.) fphidet[im1][im2]+=2.*pigre;
223 local[1]=local[2]=0.;
224 local[0]= -(fDetx[im1]);
225 if(im1==0) local[0]= (fDetx[im1]); //to take into account
226 // different reference system
227 g1->LtoG(im1+1,im2+1,idet,local,global);
228 xmax=global[0]; ymax=global[1];
229 local[0]= (fDetx[im1]);
230 if(im1==0) local[0]= -(fDetx[im1]);//take into account different
232 g1->LtoG(im1+1,im2+1,idet,local,global);
233 xmin=global[0]; ymin=global[1];
234 fphimin[im1][im2]= TMath::ATan2(ymin,xmin);
235 if(fphimin[im1][im2]<0.) fphimin[im1][im2]+=2.*pigre;
236 fphimax[im1][im2]= TMath::ATan2(ymax,xmax);
237 if(fphimax[im1][im2]<0.) fphimax[im1][im2]+=2.*pigre;
240 //////////////////////////////////////////////////////////////////////////////////////////////////////////
241 /////////////// allocate memory and define vector fNRecPoints and matrices fRecCylR, fRecCylPhi, fRecCylZ /////////////
242 gAlice->GetEvent(evnumber);
243 Int_t numOfModules = g1->GetIndexMax();
244 fRecCylR = new Double_t *[numOfModules];
245 fRecCylPhi = new Double_t *[numOfModules];
246 fRecCylZ = new Double_t *[numOfModules];
247 AliITSRecPoint *recp;
248 fNRecPoints = new Int_t[numOfModules];
250 for(Int_t module=0; module<numOfModules; module++) {
251 fDetTypeRec->ResetRecPoints();
252 gAlice->TreeR()->GetEvent(module);
253 frecPoints=fDetTypeRec->RecPoints();
254 Int_t nRecPoints=fNRecPoints[module]=frecPoints->GetEntries();
255 fRecCylR[module] = new Double_t[nRecPoints];
256 fRecCylPhi[module] = new Double_t[nRecPoints];
257 fRecCylZ[module] = new Double_t[nRecPoints];
259 for(ind=0; ind<fNRecPoints[module]; ind++) {
260 recp=(AliITSRecPoint*)frecPoints->UncheckedAt(ind);
261 // Float_t global[3], local[3];
262 Double_t global[3], local[3];
263 local[0]=recp->GetX();
265 local[2]= recp->GetZ();
266 g1->LtoG(module,local,global);
268 Double_t r = TMath::Sqrt(global[0]*global[0]+global[1]*global[1]); // r hit
269 Double_t phi = TMath::ATan2(global[1],global[0]); if(phi<0.) phi+=2.*TMath::Pi(); // phi hit
270 Double_t z = global[2]; // z hit
272 fRecCylR[module][ind]=r;
273 fRecCylPhi[module][ind]=phi;
274 fRecCylZ[module][ind]=z;
279 ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
282 ////////// gets magnetic field factor //////////////////////////////
283 AliMagF * fieldPointer = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
284 fFieldFactor = fieldPointer ? fieldPointer->SolenoidField()/10/.2 : 0;
285 // cout<< " field factor = "<<fFieldFactor<<"\n"; getchar();
289 //______________________________________________________________________
290 AliITSTrackerV1::AliITSTrackerV1(const AliITSTrackerV1 &cobj) : TObject(cobj) {
291 // Origin A. Badala' and G.S. Pappalardo:
292 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
295 // *fITS = *cobj.fITS;
296 *fresult = *cobj.fresult;
297 fPtref = cobj.fPtref;
298 fChi2max = cobj.fChi2max;
299 **fvettid = **cobj.fvettid;
300 fflagvert = cobj.fflagvert;
301 Int_t imax=200,jmax=450;
302 frl = new AliITSRad(imax,jmax);
304 fFieldFactor = cobj.fFieldFactor;
305 Int_t i,im1,im2,im2max;
307 fNlad[i] = cobj.fNlad[i];
308 fNdet[i] = cobj.fNdet[i];
309 fAvrad[i] = cobj.fAvrad[i];
310 fDetx[i] = cobj.fDetx[i];
311 fDetz[i] = cobj.fDetz[i];
313 fzmin = new Double_t*[6]; fzmax = new Double_t*[6];
314 for(im1=0; im1<6; im1++) {
316 fzmin[im1] = new Double_t[im2max];
317 fzmax[im1] = new Double_t[im2max];
319 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
320 for(im1=0;im1<6;im1++) {
322 fphimin[im1] = new Double_t[im2max];
323 fphimax[im1] = new Double_t[im2max];
326 fphidet = new Double_t*[6];
327 for(im1=0; im1<6; im1++) {
329 fphidet[im1] = new Double_t[im2max];
331 for(im1=0; im1<6; im1++) {
333 for(im2=0; im2<im2max; im2++) {
334 fzmin[im1][im2]=cobj.fzmin[im1][im2];
335 fzmax[im1][im2]=cobj.fzmax[im1][im2];
338 for(im1=0; im1<6; im1++) {
340 for(im2=0; im2<im2max; im2++) {
341 fphimin[im1][im2]=cobj.fphimin[im1][im2];
342 fphimax[im1][im2]=cobj.fphimax[im1][im2];
343 fphidet[im1][im2]=cobj.fphidet[im1][im2];
348 AliRunLoader* rl = AliRunLoader::Open("galice.root");
350 AliITSgeom* g1 = (AliITSgeom*)gDirectory->Get("AliITSgeom");
352 Int_t numOfModules = g1->GetIndexMax();
354 fRecCylR = new Float_t *[numOfModules];
355 fRecCylPhi = new Float_t *[numOfModules];
356 fRecCylZ = new Float_t *[numOfModules];
358 fRecCylR = new Double_t *[numOfModules];
359 fRecCylPhi = new Double_t *[numOfModules];
360 fRecCylZ = new Double_t *[numOfModules];
361 fNRecPoints = new Int_t[numOfModules];
362 for(Int_t module=0; module<numOfModules; module++) {
363 Int_t nRecPoints=fNRecPoints[module]=cobj.fNRecPoints[module];
365 fRecCylR[module] = new Float_t[nRecPoints];
366 fRecCylPhi[module] = new Float_t[nRecPoints];
367 fRecCylZ[module] = new Float_t[nRecPoints];
369 fRecCylR[module] = new Double_t[nRecPoints];
370 fRecCylPhi[module] = new Double_t[nRecPoints];
371 fRecCylZ[module] = new Double_t[nRecPoints];
373 for(ind=0; ind<nRecPoints; ind++) {
374 fRecCylR[module][ind]=cobj.fRecCylR[module][ind];
375 fRecCylPhi[module][ind]=cobj.fRecCylPhi[module][ind];
376 fRecCylZ[module][ind]=cobj.fRecCylZ[module][ind];
383 //______________________________________________________________________
384 void AliITSTrackerV1::DelMatrix(Int_t numOfModules) {
385 // cleanup of some data members
386 for(Int_t mod=0; mod<numOfModules; mod++) {
387 delete fRecCylR[mod];
388 delete fRecCylPhi[mod];
389 delete fRecCylZ[mod];
396 //______________________________________________________________________
397 AliITSTrackerV1::~AliITSTrackerV1(){
398 // Origin A. Badala' and G.S. Pappalardo:
399 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
403 for(Int_t i=0; i<6; i++) {
418 //______________________________________________________________________
419 AliITSTrackerV1 &AliITSTrackerV1::operator=(const AliITSTrackerV1 &obj) {
420 // Origin A. Badala' and G.S. Pappalardo:
421 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
422 // assignement operator
424 // *fITS = *obj.fITS;
425 *fresult = *obj.fresult;
427 fChi2max = obj.fChi2max;
428 **fvettid = **obj.fvettid;
429 fflagvert = obj.fflagvert;
430 Int_t imax=200,jmax=450;
431 frl = new AliITSRad(imax,jmax);
433 fFieldFactor = obj.fFieldFactor;
436 fNlad[i] = obj.fNlad[i];
437 fNdet[i] = obj.fNdet[i];
438 fAvrad[i] = obj.fAvrad[i];
439 fDetx[i] = obj.fDetx[i];
440 fDetz[i] = obj.fDetz[i];
442 fzmin = new Double_t*[6];
443 fzmax = new Double_t*[6];
444 Int_t im1, im2, im2max;
445 for(im1=0; im1<6; im1++) {
447 fzmin[im1] = new Double_t[im2max]; fzmax[im1] = new Double_t[im2max];
449 fphimin = new Double_t*[6]; fphimax = new Double_t*[6];
450 for(im1=0;im1<6;im1++) {
452 fphimin[im1] = new Double_t[im2max];
453 fphimax[im1] = new Double_t[im2max];
456 fphidet = new Double_t*[6];
457 for(im1=0; im1<6; im1++) {
459 fphidet[im1] = new Double_t[im2max];
461 for(im1=0; im1<6; im1++) {
463 for(im2=0; im2<im2max; im2++) {
464 fzmin[im1][im2]=obj.fzmin[im1][im2];
465 fzmax[im1][im2]=obj.fzmax[im1][im2];
468 for(im1=0; im1<6; im1++) {
470 for(im2=0; im2<im2max; im2++) {
471 fphimin[im1][im2]=obj.fphimin[im1][im2];
472 fphimax[im1][im2]=obj.fphimax[im1][im2];
473 fphidet[im1][im2]=obj.fphidet[im1][im2];
477 AliRunLoader* rl = AliRunLoader::Open("galice.root");
479 AliITSgeom* g1 = (AliITSgeom*)gDirectory->Get("AliITSgeom");
480 // AliITSgeom *g1 = fITS->GetITSgeom();
481 Int_t numOfModules = g1->GetIndexMax();
482 fRecCylR = new Double_t *[numOfModules];
483 fRecCylPhi = new Double_t *[numOfModules];
484 fRecCylZ = new Double_t *[numOfModules];
485 fNRecPoints = new Int_t[numOfModules];
486 for(Int_t module=0; module<numOfModules; module++) {
487 Int_t nRecPoints=fNRecPoints[module]=obj.fNRecPoints[module];
488 fRecCylR[module] = new Double_t[nRecPoints];
489 fRecCylPhi[module] = new Double_t[nRecPoints];
490 fRecCylZ[module] = new Double_t[nRecPoints];
492 for(ind=0; ind<nRecPoints; ind++) {
493 fRecCylR[module][ind]=obj.fRecCylR[module][ind];
494 fRecCylPhi[module][ind]=obj.fRecCylPhi[module][ind];
495 fRecCylZ[module][ind]=obj.fRecCylZ[module][ind];
503 //______________________________________________________________________
504 void AliITSTrackerV1::DoTracking(Int_t evNumber,Int_t minTr,Int_t maxTr,
505 TFile *file, Bool_t realmass) {
506 // Origin A. Badala' and G.S. Pappalardo:
507 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
508 // The method needs the event number, the minimum and maximum order
509 // number of TPC tracks that
510 // are to be tracked trough the ITS, and the file where the recpoints
512 // The method can be called by a macro. It preforms the tracking for
513 // all good TPC tracks
515 printf("begin DoTracking - file %p\n",(void*)file);
517 gAlice->GetEvent(evNumber); //modificato per gestire hbt
519 TFile *cf=TFile::Open("AliTPCclusters.root");
520 AliTPCParam *digp= (AliTPCParam*)cf->Get("75x40_100x60_150x60");
521 if (!digp) { cerr<<"TPC parameters have not been found !\n"; getchar();}
524 AliRunLoader* rl = AliRunLoader::Open("galice.root");
525 AliITSLoader* itsl = (AliITSLoader*)rl->GetLoader("ITSLoader");
526 TString foldname(itsl->GetEventFolder()->GetName());
527 //TString foldname(fITS->GetLoader()->GetEventFolder()->GetName());
529 printf("This method is not converted to the NewIO !\n"); //I.B.
531 AliTPCtracker *tracker = new AliTPCtracker(digp); //I.B.
532 //PH tracker->SetEventNumber(evNumber); //I.B.
535 printf("This method is not converted to the NewIO !\n"); //I.B.
537 tracker->LoadClusters(0); //I.B.
540 TFile *tf=TFile::Open("AliTPCtracksSorted.root");
542 cerr<<"Can't open AliTPCtracksSorted.root !\n";
545 TObjArray tracks(200000);
547 sprintf(tname,"TreeT_TPC_%d",evNumber);
549 TTree *tracktree=(TTree*)tf->Get(tname);
550 if (!tracktree) {cerr<<"Can't get a tree with TPC tracks !\n";}
551 TBranch *tbranch=tracktree->GetBranch("tracks");
552 Int_t nentr=(Int_t)tracktree->GetEntries();
555 AliITSRecPoint *recp; // oggi
556 AliTPCtrack *ioTrackTPC=0;
557 for (kk=0; kk<nentr; kk++) {
558 ioTrackTPC=new AliTPCtrack;
559 tbranch->SetAddress(&ioTrackTPC);
560 tracktree->GetEvent(kk);
561 tracker->CookLabel(ioTrackTPC,0.1);
562 tracks.AddLast(ioTrackTPC);
567 Int_t nt = tracks.GetEntriesFast();
568 cerr<<"Number of found tracks "<<nt<<endl;
571 TTree *tr=gAlice->TreeR();
572 Int_t nent=(Int_t)tr->GetEntries();
573 frecPoints = fDetTypeRec->RecPoints();
577 Int_t *np = new Int_t[nent];
578 fvettid = new Int_t* [nent];
581 for (mod=0; mod<nent; mod++) {
583 fDetTypeRec->ResetRecPoints();
584 gAlice->TreeR()->GetEvent(mod);
585 numbpoints = frecPoints->GetEntries();
586 totalpoints+=numbpoints;
587 np[mod] = numbpoints;
588 //cout<<" mod = "<<mod<<" numbpoints = "<<numbpoints<<"\n";getchar();
589 fvettid[mod] = new Int_t[numbpoints];
591 for (ii=0;ii<numbpoints; ii++) *(fvettid[mod]+ii)=0;
594 AliTPCtrack *track=0;
596 if(minTr < 0) {minTr = 0; maxTr = nt-1;}
600 TTree tracktree1("TreeT","Tree with ITS tracks");
601 AliITSIOTrack *ioTrack=0;
602 AliITSPid *pid=new AliITSPid(1000); // oggi
604 tracktree1.Branch("ITStracks","AliITSIOTrack",&ioTrack,32000,0);
606 TDatabasePDG * db = new TDatabasePDG;
609 for (j=minTr; j<=maxTr; j++) {
610 track=(AliTPCtrack*)tracks.UncheckedAt(j);
611 if (!track) continue;
613 /// mass definition ////////////////////////
614 Double_t mass=0.13956995;
615 Int_t pcode=211; // a pion by default
618 if(TMath::Abs(pcode)<20443) mass=db->GetParticle(pcode)->Mass();
621 mass = track->GetMass();
622 // cout << "Mass = " << mass << endl;
627 // new propagation to the end of TPC
629 // track->PropagateTo(xk,0.,0.); //Ne if it's still there //attenzione funziona solo se modifica in TPC
630 // Double_t xk=77.415;
631 track->PropagateTo(xk, 28.94, 1.204e-3);
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
644 // track->PropagateTo(xk,0.,0.); //C02
645 track->PropagateTo(xk,36.2,1.98e-3); //C02 //attenzione funziona solo se modifica in TPC
648 track->PropagateTo(xk, 24.01, 2.7); //Al
650 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
652 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
654 track->PropagateTo(xk, 41.28, 0.029); //Nomex
656 track->PropagateTo(xk, 44.86, 1.45); //Kevlar
658 track->PropagateTo(xk, 44.77, 1.71); //Tedlar
660 track->PropagateTo(xk, 24.01, 2.7); //Al
662 ////////////////////////////////////////////////////////////////////////////////////////////////////////
663 //AliITSTrackV1 trackITS(*track);
664 AliITSTrackV1 trackITS(*track, fFieldFactor);
665 //cout<<" fFieldFactor = "<<fFieldFactor<<"\n";
666 trackITS.PutMass(mass); //new to add mass to track
667 if(fresult){ delete fresult; fresult=0;}
668 fresult = new AliITSTrackV1(trackITS);
670 AliITSTrackV1 primaryTrack(trackITS);
671 vgeant=(*fresult).GetVertex();
673 // Definition of dv and zv for vertex constraint
674 Double_t sigmaDv=0.0050; Double_t sigmaZv=0.010;
675 //Double_t sigmaDv=0.0015; Double_t sigmaZv=0.0015;
676 Double_t uniform= gRandom->Uniform();
678 if(uniform<=0.5) signdv=-1.;
682 Double_t vr=TMath::Sqrt(vgeant(0)*vgeant(0)+ vgeant(1)*vgeant(1));
683 Double_t dv=gRandom->Gaus(signdv*vr,(Float_t)sigmaDv);
684 Double_t zv=gRandom->Gaus(vgeant(2),(Float_t)sigmaZv);
685 //cout<<" Dv e Zv = "<<dv<<" "<<zv<<"\n";
688 trackITS.SetsigmaDv(sigmaDv);
689 trackITS.SetsigmaZv(sigmaZv);
690 (*fresult).SetDv(dv);
691 (*fresult).SetZv(zv);
692 (*fresult).SetsigmaDv(sigmaDv);
693 (*fresult).SetsigmaZv(sigmaZv);
694 primaryTrack.SetDv(dv);
695 primaryTrack.SetZv(zv);
696 primaryTrack.SetsigmaDv(sigmaDv);
697 primaryTrack.SetsigmaZv(sigmaZv);
698 primaryTrack.PrimaryTrack();
699 TVector d2=primaryTrack.Getd2();
700 TVector tgl2=primaryTrack.Gettgl2();
701 TVector dtgl=primaryTrack.Getdtgl();
702 trackITS.Setd2(d2); trackITS.Settgl2(tgl2);
703 trackITS.Setdtgl(dtgl);
704 (*fresult).Setd2(d2); (*fresult).Settgl2(tgl2);
705 (*fresult).Setdtgl(dtgl);
707 trackITS.SetVertex(vertex); trackITS.SetErrorVertex(ervertex);
708 (*result).SetVertex(vertex); (*result).SetErrorVertex(ervertex);
710 TList *list= new TList();
712 list->AddLast(&trackITS);
714 fPtref=TMath::Abs( (trackITS).GetPt() );
715 //cout<<" fPtref = " <<fPtref<<"\n";
716 if(fPtref>1.0) fChi2max=40.;
717 if(fPtref<=1.0) fChi2max=20.;
718 if(fPtref<0.4 ) fChi2max=100.;
719 if(fPtref<0.2 ) fChi2max=40.;
720 // if(fPtref<0.4 ) fChi2max=30.;
721 // if(fPtref<0.2 ) fChi2max=20.;
722 //if(fPtref<0.2 ) fChi2max=10.;
723 //if(fPtref<0.1 ) fChi2max=5.;
724 //cout << "\n Pt = " << fPtref <<"\n"; //stampa
725 RecursiveTracking(list);
730 TVector vecTotLabRef(18);
732 for(lay=5; lay>=0; lay--) {
733 TVector vecLabRef(3);
734 vecLabRef=(*fresult).GetLabTrack(lay);
735 Float_t clustZ=(*fresult).GetZclusterTrack( lay);
737 Int_t lpp=(Int_t)vecLabRef(k);
739 TParticle *p=(TParticle*) gAlice->GetMCApp()->Particle(lpp);
740 Int_t pcode=p->GetPdgCode();
741 if(pcode==11) vecLabRef(k)=p->GetFirstMother();
743 itot++; vecTotLabRef(itot)=vecLabRef(k);
744 if(vecLabRef(k)==0. && clustZ == -1.) vecTotLabRef(itot) =-3.;
749 (*fresult).Search(vecTotLabRef, labref, freq);
751 //if(freq < 6) labref=-labref; // cinque - sei
752 if(freq < 5) labref=-labref; // cinque - sei
753 (*fresult).SetLabel(labref);
755 // cout<<" progressive track number = "<<j<<"\r";
757 Int_t numOfCluster=(*fresult).GetNumClust();
758 //cout<<" progressive track number = "<<j<<"\n"; // stampa
759 Long_t labITS=(*fresult).GetLabel();
760 //cout << " ITS track label = " << labITS << "\n"; // stampa
761 Int_t lab=track->GetLabel();
762 //cout << " TPC track label = " << lab <<"\n"; // stampa
763 //propagation to vertex
766 if((*fresult).DoNotCross(rbeam)) continue; //no intersection with beampipe
767 (*fresult).Propagation(rbeam);
768 Double_t c00,c10,c11,c20,c21,c22,c30,c31,c32,c33,c40,c41,c42,c43,c44;
769 (*fresult).GetCElements(c00,
773 c40,c41,c42,c43,c44);
775 Double_t pt=TMath::Abs((*fresult).GetPt());
776 Double_t dr=(*fresult).GetD();
777 Double_t z=(*fresult).GetZ();
778 Double_t tgl=(*fresult).GetTgl();
779 Double_t c=(*fresult).GetC();
781 Double_t dz=z-(tgl/cy)*TMath::ASin((*fresult).Arga(rbeam));
783 // cout<<" dr e dz alla fine = "<<dr<<" "<<dz<<"\n"; getchar();
784 Double_t phi=(*fresult).Getphi();
785 Double_t phivertex = phi - TMath::ASin((*fresult).ArgA(rbeam));
786 Double_t duepi=2.*TMath::Pi();
787 if(phivertex>duepi) phivertex-=duepi;
788 if(phivertex<0.) phivertex+=duepi;
789 /////////////////////////////////////////////////////////////
790 Int_t idmodule,idpoint;
791 if(numOfCluster >=5) { // cinque - sei
792 //if(numOfCluster ==6) { // cinque - sei
793 AliITSIOTrack outTrack;
795 ioTrack->SetStatePhi(phi);
796 ioTrack->SetStateZ(z);
797 ioTrack->SetStateD(dr);
798 ioTrack->SetStateTgl(tgl);
799 ioTrack->SetStateC(c);
800 Double_t radius=(*fresult).Getrtrack();
801 ioTrack->SetRadius(radius);
803 if(c>0.) charge=-1; else charge=1;
804 ioTrack->SetCharge(charge);
805 Double_t trackmass=(*fresult).GetMass(); // oggi
806 ioTrack->SetMass(trackmass); // oggi
807 ioTrack->SetCovMatrix(c00,
811 c40,c41,c42,c43,c44);
812 Double_t px=pt*TMath::Cos(phivertex);
813 Double_t py=pt*TMath::Sin(phivertex);
815 Double_t xtrack=dr*TMath::Sin(phivertex);
816 Double_t ytrack=dr*TMath::Cos(phivertex);
817 Double_t ztrack=dz+vgeant(2);
821 ioTrack->SetX(xtrack);
822 ioTrack->SetY(ytrack);
823 ioTrack->SetZ(ztrack);
824 ioTrack->SetLabel(labITS);
825 ioTrack->SetTPCLabel(lab);
829 for(il=0;il<6; il++){
830 ioTrack->SetIdPoint(il,(*fresult).GetIdPoint(il));
831 ioTrack->SetIdModule(il,(*fresult).GetIdModule(il));
835 Float_t q[4]={-1.,-1.,-1.,-1.};
836 Float_t globaldedx=0.;
837 for (il=0;il<6;il++) {
838 idpoint=(*fresult).GetIdPoint(il);
839 idmodule=(*fresult).GetIdModule(il);
840 if(idmodule>0.) *(fvettid[idmodule]+idpoint)=1;
842 ioTrack->SetIdPoint(il,idpoint);
843 ioTrack->SetIdModule(il,idmodule);
844 //// for q definition
847 fDetTypeRec->ResetRecPoints();
848 gAlice->TreeR()->GetEvent(idmodule);
849 recp=(AliITSRecPoint*)frecPoints->UncheckedAt(idpoint);
850 q[il-2]=recp->GetQ()*(*fresult).Getfcor(il-2);
854 q[0]/=280.; q[1]/=280.;
855 q[2]/=38.; q[3]/=38.;
857 // cout<<" q prima = "<<q[0]<<" "<<q[1]<<" "<<q[2]<<" "<<q[3]<<"\n"; getchar();
862 for (il=0; il<3; il++) {
863 if (q[il]<=q[il+1]) continue;
865 q[il]=q[il+1]; q[il+1]=tmp;
871 // cout<<" q dopo = "<<q[0]<<" "<<q[1]<<" "<<q[2]<<" "<<q[3]<<"\n"; getchar();
880 // cout<<" q dopo if = "<<q[0]<<" "<<q[1]<<" "<<q[2]<<" "<<q[3]<<"\n"; getchar();
882 globaldedx=(q[0]+q[1])/2.;
884 // if(q[3]> 0.) globaldedx=(q[0]+q[1]+q[2]+q[3])/4.;
885 // else globaldedx=(q[0]+q[1]+q[2])/3.;
887 ioTrack->SetdEdx(globaldedx);
888 ioTrack->SetPid(pid->GetPcode(ioTrack));
891 } // end if on numOfCluster
892 //gObjectTable->Print(); // stampa memoria
893 } // end for (int j=minTr; j<=maxTr; j++)
895 static Bool_t first=kTRUE;
898 tfile=new TFile("itstracks.root","RECREATE");
899 //cout<<"I have opened itstracks.root file "<<endl;
905 sprintf(hname,"TreeT%d",evNumber);
906 cout << "Number of saved ITS tracks " << tracktree1.GetEntries() << endl;
907 tracktree1.Write(hname);
909 TTree *fAli=gAlice->TreeK();
911 if (fAli) fileAli =fAli->GetCurrentFile();
913 ////////////////////////////////////////////////////////////////////
915 printf("delete vectors\n");
917 if(fvettid) delete [] fvettid;
918 if(fresult) {delete fresult; fresult=0;}
920 //______________________________________________________________________
921 void AliITSTrackerV1::RecursiveTracking(TList *trackITSlist) {
922 // This function perform the recursive tracking in ITS detectors
923 // reference is a pointer to the final best track
924 // Origin A. Badala' and G.S. Pappalardo:
925 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
926 // The authors thank Mariana Bondila to have help them to resolve some
927 // problems. July-2000
929 //Rlayer[0]=4.; Rlayer[1]=7.; Rlayer[2]=14.9;
930 // Rlayer[3]=23.8; Rlayer[4]=39.1; Rlayer[5]=43.6; //vecchio
932 //////////////////////
933 Float_t sigmaphil[6], sigmazl[6];
934 sigmaphil[0]=1.44e-6/(fAvrad[0]*fAvrad[0]);
935 sigmaphil[1]=1.44e-6/(fAvrad[1]*fAvrad[1]);
936 sigmaphil[2]=1.444e-5/(fAvrad[2]*fAvrad[2]);
937 sigmaphil[3]=1.444e-5/(fAvrad[3]*fAvrad[3]);
938 sigmaphil[4]=4e-6/(fAvrad[4]*fAvrad[4]);
939 sigmaphil[5]=4e-6/(fAvrad[5]*fAvrad[5]);
946 ///////////////////////////////////////////////////////////
948 AliRunLoader* rl = AliRunLoader::Open("galice.root");
950 AliITSgeom* g1 = (AliITSgeom*)gDirectory->Get("AliITSgeom");
952 AliITSRecPoint *recp;
953 for(index =0; index<trackITSlist->GetSize(); index++) {
954 AliITSTrackV1 *trackITS = (AliITSTrackV1 *) trackITSlist->At(index);
955 if((*trackITS).GetLayer()==7) fresult->SetChi2(10.223e140);
956 // cout <<" Layer inizio = "<<(*trackITS).GetLayer()<<"\n";
957 // cout<<"fvtrack =" <<"\n";
958 // cout << (*trackITS)(0) << " "<<(*trackITS)(1)<<" "
959 // <<(*trackITS)(2)<<" "<<(*trackITS)(3)<<" "
960 // <<(*trackITS)(4)<<"\n";
961 // cout<< " rtrack = "<<(*trackITS).Getrtrack()<<"\n";
962 // cout<< " Pt = "<<(*trackITS).GetPt()<<"\n";
964 Double_t chi2Now, chi2Ref;
965 Float_t numClustRef = fresult->GetNumClust();
966 if((*trackITS).GetLayer()==1 ) {
967 chi2Now = trackITS->GetChi2();
968 Float_t numClustNow = trackITS->GetNumClust();
969 if(trackITS->GetNumClust())
970 chi2Now /= (Double_t)trackITS->GetNumClust();
971 chi2Ref = fresult->GetChi2();
972 if(fresult->GetNumClust())
973 chi2Ref /= (Double_t)fresult->GetNumClust();
974 //cout<<" chi2Now and chi2Ref = "<<chi2Now<<" "<<chi2Ref<<"\n";
975 if( numClustNow > numClustRef ) {*fresult = *trackITS;}
976 if((numClustNow == numClustRef )&&
977 (chi2Now < chi2Ref)) {
978 *fresult = *trackITS;
983 if(trackITS->Getfnoclust()>=2) continue;
984 Float_t numClustNow = trackITS->GetNumClust();
986 chi2Now = trackITS->GetChi2();
988 if(numClustNow<numClustRef && chi2Now>fresult->GetChi2()) continue;
989 //cout<<" chi2Now = "<<chi2Now<<"\n";
991 chi2Now/=numClustNow;
992 if(fPtref > 1.0 && chi2Now > 30.) continue;
993 if((fPtref >= 0.6 && fPtref<=1.0) && chi2Now > 40.) continue;
994 // if((fPtref <= 0.6 && fPtref>0.2)&& chi2Now > 40.) continue;
995 // if(fPtref <= 0.2 && chi2Now > 8.) continue;
996 if((fPtref <= 0.6 && fPtref>0.2)&& chi2Now > 30.) continue;
997 if(fPtref <= 0.2 && chi2Now > 7.) continue;
998 /////////////////////////////
1001 Int_t layerInit = (*trackITS).GetLayer();
1002 Int_t layernew = layerInit - 2;// -1 for new layer, -1 for matrix index
1004 Int_t ladp, ladm, detp,detm,ladinters,detinters;
1005 Int_t layerfin=layerInit-1;
1006 // cout<<"Prima di intersection \n";
1007 Int_t outinters=Intersection(*trackITS,layerfin,ladinters,detinters);
1008 // cout<<" outinters = "<<outinters<<"\n";
1009 // cout<<" Layer ladder detector intersection ="
1010 // <<layerfin<<" "<<ladinters<<" "<<detinters<<"\n";
1011 // cout << " phiinters zinters = "<<(*trackITS)(0)
1012 // << " "<<(*trackITS)(1)<<"\n"; getchar();
1013 if(outinters==-1) continue;
1015 (*trackITS).SetLayer(layerfin); // oggi
1016 (*trackITS).Setfcor(); // oggi
1018 TVector toucLad(9), toucDet(9);
1019 Int_t lycur=layerfin;
1022 if(ladm <= 0) ladm=fNlad[layerfin-1];
1023 if(ladp > fNlad[layerfin-1]) ladp=1;
1028 toucLad(0)=ladinters; toucLad(1)=ladm; toucLad(2)=ladp;
1029 toucLad(3)=ladinters; toucLad(4)=ladm; toucLad(5)=ladp;
1030 toucLad(6)=ladinters; toucLad(7)=ladm; toucLad(8)=ladp;
1031 toucDet(0)=detinters; toucDet(1)=detinters; toucDet(2)=detinters;
1032 if(detm > 0 && detp <= fNdet[layerfin-1]) {
1034 toucDet(3)=detm; toucDet(4)=detm; toucDet(5)=detm;
1035 toucDet(6)=detp; toucDet(7)=detp; toucDet(8)=detp;
1037 if(detm > 0 && detp > fNdet[layerfin-1]) {
1039 toucDet(3)=detm; toucDet(4)=detm; toucDet(5)=detm;
1041 if(detm <= 0 && detp <= fNdet[layerfin-1]) {
1043 toucDet(3)=detp; toucDet(4)=detp; toucDet(5)=detp;
1046 Float_t epsphi=5.0, epsz=5.0;
1047 if(fPtref<0.2) {epsphi=3.; epsz=3.;}
1048 // new definition of idetot e toucLad e toucDet to be
1049 // transformed in a method
1050 // these values could be modified
1051 Float_t pigre=TMath::Pi();
1052 Float_t rangephi=5., rangez=5.;
1053 if(layerfin==1 || layerfin ==2){
1054 rangephi=40.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1055 (*trackITS).GetSigmaphi());
1056 rangez = 40.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1057 (*trackITS).GetSigmaZ());
1059 if(layerfin==3 || layerfin ==4){
1060 //rangephi=30.*fepsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1061 // (*trackITS).GetSigmaphi());
1062 //rangez = 40.*fepsz*TMath::Sqrt(sigmazl[layerfin-1]+
1063 // (*trackITS).GetSigmaZ());
1064 rangephi=40.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1065 (*trackITS).GetSigmaphi());
1066 rangez = 50.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1067 (*trackITS).GetSigmaZ());
1069 if(layerfin==5 || layerfin ==6){
1070 rangephi=20.*epsphi*TMath::Sqrt(sigmaphil[layerfin-1]+
1071 (*trackITS).GetSigmaphi());
1072 rangez =5.*epsz*TMath::Sqrt(sigmazl[layerfin-1]+
1073 (*trackITS).GetSigmaZ());
1075 Float_t phinters, zinters;
1076 phinters=(*trackITS).Getphi();
1077 zinters=(*trackITS).GetZ();
1078 Float_t distz = 0.0;
1079 Float_t phicm, phicp, distphim, distphip;
1081 if(phinters>fphimax[layerfin-1][ladm-1]) phicm=phinters-2*pigre; //corretto il 20-11-2001
1082 distphim=TMath::Abs(phicm-fphimax[layerfin-1][ladm-1]); //corretto il 20-11-2001
1084 //cout<<" fNlad[layerfin-1] e ladp = "<<fNlad[layerfin-1]<<" "<<ladp<<endl;
1085 if(phinters>fphimin[layerfin-1][ladp-1]) phicp=phinters-2.*pigre; //corretto il 20-11-2001
1086 distphip=TMath::Abs(phicp-fphimin[layerfin-1][ladp-1]); //corretto il 20-11-2001
1090 toucLad(0)=ladinters; toucDet(0)=detinters;
1091 if(detm>0) distz=TMath::Abs(zinters-fzmax[layerfin-1][detm-1]);
1092 if(detm>0 && rangez>=distz){
1094 idetot++; toucLad(idetot-1)=ladinters; toucDet(idetot-1)=detm;
1095 if(rangephi>=distphim){
1097 toucLad(idetot-1)=ladm;
1098 toucDet(idetot-1)=detinters;
1100 toucLad(idetot-1)=ladm;
1101 toucDet(idetot-1)=detm;
1103 if(rangephi>=distphip){
1105 toucLad(idetot-1)=ladp;
1106 toucDet(idetot-1)=detinters;
1108 toucLad(idetot-1)=ladp;
1109 toucDet(idetot-1)=detm;
1112 if(detp<=fNdet[layerfin-1])
1113 distz=TMath::Abs(zinters-fzmin[layerfin-1][detp-1]);
1114 if(detp<=fNdet[layerfin-1] && rangez>=distz){
1116 idetot++; toucLad(idetot-1)=ladinters; toucDet(idetot-1)=detp;
1117 if(rangephi>=distphim){
1118 idetot++; toucLad(idetot-1)=ladm; toucDet(idetot-1)=detp;
1121 toucLad(idetot-1)=ladm;
1122 toucDet(idetot-1)=detinters;
1125 if(rangephi>=distphip){
1127 toucLad(idetot-1)=ladp;
1128 toucDet(idetot-1)=detp;
1131 toucLad(idetot-1)=ladp;
1132 toucDet(idetot-1)=detinters;
1135 } //end detm<fNdet[.......
1137 if(flagzmin == 0 && flagzmax==0){
1138 if(rangephi>=distphim){
1140 toucLad(idetot-1)=ladm;
1141 toucDet(idetot-1)=detinters;
1143 if(rangephi>=distphip){
1145 toucLad(idetot-1)=ladp;
1146 toucDet(idetot-1)=detinters;
1149 ////////////////////////////////////////////////////////////
1151 for (iriv=0; iriv<idetot; iriv++) { //for on detectors
1152 ///////////////////////////////////////////////////////
1153 /*** Rec points sorted by module *****/
1154 /**************************************/
1156 indexmod = g1->GetModuleIndex(lycur,(Int_t)toucLad(iriv),
1157 (Int_t)toucDet(iriv));
1158 fDetTypeRec->ResetRecPoints();
1159 gAlice->TreeR()->GetEvent(indexmod);
1160 Int_t npoints=frecPoints->GetEntries();
1163 for(indnew=0; indnew<npoints; indnew++){
1164 if (*(fvettid[indexmod]+indnew)==0)
1165 recp =(AliITSRecPoint*)frecPoints->UncheckedAt(indnew);
1168 TVector cluster(3),vecclust(9);
1169 //vecclust(6)=vecclust(7)=vecclust(8)=-1.;
1171 // now vecclust is with cylindrical cohordinates
1172 vecclust(0)=(Float_t)fRecCylR[indexmod][indnew];
1173 vecclust(1)=(Float_t)fRecCylPhi[indexmod][indnew];
1174 vecclust(2)=(Float_t)fRecCylZ[indexmod][indnew];
1175 vecclust(3) = (Float_t)recp->fTracks[0];
1176 vecclust(4) = (Float_t)indnew;
1177 vecclust(5) = (Float_t)indexmod;
1178 vecclust(6) = (Float_t)recp->fTracks[0];
1179 vecclust(7) = (Float_t)recp->fTracks[1];
1180 vecclust(8) = (Float_t)recp->fTracks[2];
1181 sigma[0] = (Double_t) recp->GetSigmaX2();
1182 sigma[1] = (Double_t) recp->GetSigmaZ2();
1184 cluster(0)=fRecCylR[indexmod][indnew];
1185 cluster(1)=fRecCylPhi[indexmod][indnew];
1186 cluster(2)=fRecCylZ[indexmod][indnew];
1188 // cout<<" layer = "<<play<<"\n";
1189 // cout<<" cluster prima = "<<vecclust(0)<<" "
1190 // <<vecclust(1)<<" "
1191 // <<vecclust(2)<<"\n"; getchar();
1193 Float_t sigmatotphi, sigmatotz;
1194 // Float_t epsphi=5.0, epsz=5.0;
1195 //if(fPtref<0.2) {epsphi=3.; epsz=3.;}
1196 Double_t rTrack=(*trackITS).Getrtrack();
1197 Double_t sigmaphi=sigma[0]/(rTrack*rTrack);
1198 sigmatotphi=epsphi*TMath::Sqrt(sigmaphi +
1199 (*trackITS).GetSigmaphi());
1200 sigmatotz=epsz*TMath::Sqrt(sigma[1] +
1201 (*trackITS).GetSigmaZ());
1202 //cout<<"cluster e sigmatotphi e track = "<<cluster(0)
1203 // <<" "<<cluster(1)<<" "<<sigmatotphi<<" "
1204 // <<vecclust(3)<<"\n";
1205 //if(vecclust(3)==481) getchar();
1206 if(cluster(1)<6. && (*trackITS).Getphi()>6.)
1207 cluster(1)=cluster(1)+(2.*TMath::Pi());
1208 if(cluster(1)>6. && (*trackITS).Getphi()<6.)
1209 cluster(1)=cluster(1)-(2.*TMath::Pi());
1210 if(TMath::Abs(cluster(1)-(*trackITS).Getphi())>sigmatotphi)
1212 // cout<<" supero sigmaphi \n";
1213 AliITSTrackV1 *newTrack = new AliITSTrackV1((*trackITS));
1214 //(*newTrack).SetLayer((*trackITS).GetLayer()-1);
1215 if (TMath::Abs(rTrack-cluster(0))/rTrack>1e-6)
1216 (*newTrack).Correct(Double_t(cluster(0)));
1217 //cout<<" cluster(2) e(*newTrack).GetZ()="<<cluster(2)<<" "
1218 // << (*newTrack).GetZ()<<"\n";
1219 if(TMath::Abs(cluster(2)-(*newTrack).GetZ()) > sigmatotz){
1223 Double_t sigmanew[2];
1224 sigmanew[0]= sigmaphi;
1225 sigmanew[1]=sigma[1];
1229 // Double_t chi2pred=newTrack->GetPredChi2(m,sigmanew);
1230 // cout<<" chi2pred = "<<chi2pred<<"\n";
1231 // if(chi2pred>fChi2max) continue; //aggiunto il 30-7-2001
1232 if(iriv == 0) flaghit=1;
1233 (*newTrack).AddMS(); // add the multiple scattering
1234 //matrix to the covariance matrix
1235 (*newTrack).AddEL(1.,0);
1238 KalmanFilterVert(newTrack,cluster,sigmanew);
1239 //KalmanFilterVert(newTrack,cluster,sigmanew,chi2pred);
1241 KalmanFilter(newTrack,cluster,sigmanew);
1243 (*newTrack).PutCluster(layernew, vecclust);
1244 newTrack->AddClustInTrack();
1245 listoftrack.AddLast(newTrack);
1247 } // end of for on detectors (iriv)
1248 }//end if(outinters==0)
1250 if(flaghit==0 || outinters==-2) {
1251 AliITSTrackV1 *newTrack = new AliITSTrackV1(*trackITS);
1252 (*newTrack).Setfnoclust();
1253 //(*newTrack).SetLayer((*trackITS).GetLayer()-1);
1254 (*newTrack).AddMS(); // add the multiple scattering matrix
1255 // to the covariance matrix
1256 (*newTrack).AddEL(1.,0);
1257 listoftrack.AddLast(newTrack);
1260 //gObjectTable->Print(); // stampa memoria
1262 RecursiveTracking(&listoftrack);
1263 listoftrack.Delete();
1264 } // end of for on tracks (index)
1266 //gObjectTable->Print(); // stampa memoria
1270 //______________________________________________________________________
1271 Int_t AliITSTrackerV1::Intersection(AliITSTrackV1 &track,Int_t layer,
1272 Int_t &ladder,Int_t &detector) {
1273 // Origin A. Badala' and G.S. Pappalardo
1274 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1275 // Found the intersection and the detector
1277 Double_t rk=fAvrad[layer-1];
1278 if(track.DoNotCross(rk)){ /*cout<< " Do not cross \n";*/ return -1;}
1279 track.Propagation(rk);
1280 Double_t zinters=track.GetZ();
1281 Double_t phinters=track.Getphi();
1282 //cout<<"zinters = "<<zinters<<" phinters = "<<phinters<<"\n";
1286 TVector distZCenter(2);
1290 for(iD = 1; iD<= fNdet[layer-1]; iD++) {
1291 if(zinters > fzmin[layer-1][iD-1] && zinters <= fzmax[layer-1][iD-1]) {
1293 cout<< " Errore su iz in Intersection \n";
1296 listDet(iz)= iD; distZCenter(iz)=TMath::Abs(zinters-det(2));
1302 if(iz==0) {/* cout<< " No detector along Z \n";*/ return -2;}
1303 detector=Int_t (listDet(0));
1304 if(iz>1 && (distZCenter(0)>distZCenter(1))) detector=Int_t (listDet(1));
1307 TVector distPhiCenter(2);
1309 Double_t pigre=TMath::Pi();
1311 for(iLd = 1; iLd<= fNlad[layer-1]; iLd++) {
1312 Double_t phimin=fphimin[layer-1][iLd-1];
1313 Double_t phimax=fphimax[layer-1][iLd-1];
1314 Double_t phidet=fphidet[layer-1][iLd-1];
1315 Double_t phiconfr=phinters;
1317 //if(phimin <5.5) {cout<<" Error in Intersection for phi \n";
1320 if(phinters>(1.5*pigre)) phiconfr=phinters-(2.*pigre);
1321 if(phidet>(1.5*pigre)) phidet-=(2.*pigre);
1323 if(phiconfr>phimin && phiconfr<= phimax) {
1325 cout<< " Errore su ip in Intersection \n"; getchar();
1328 distPhiCenter(ip)=TMath::Abs(phiconfr-phidet); ip++;
1332 if(ip==0) { cout<< " No detector along phi \n"; getchar();}
1333 ladder=Int_t (listLad(0));
1334 if(ip>1 && (distPhiCenter(0)>distPhiCenter(1))) ladder=Int_t (listLad(1));
1337 //______________________________________________________________________
1338 void AliITSTrackerV1::KalmanFilter(AliITSTrackV1 *newTrack,TVector &cluster,
1340 //Origin A. Badala' and G.S. Pappalardo:
1341 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1342 // Kalman filter without vertex constraint
1343 ////// Evaluation of the measurement vector ////////////////////////
1345 Double_t rk,phik,zk;
1346 rk=cluster(0); phik=cluster(1); zk=cluster(2);
1348 //////////////////////// Evaluation of the error matrix V /////////
1349 Double_t v00=sigma[0];
1350 Double_t v11=sigma[1];
1351 ////////////////////////////////////////////////////////////////////
1352 Double_t cin00,cin10,cin20,cin30,cin40,cin11,cin21,cin31,cin41,cin22,
1353 cin32,cin42,cin33,cin43,cin44;
1355 newTrack->GetCElements(cin00,
1358 cin30,cin31,cin32,cin33,
1359 cin40,cin41,cin42,cin43,cin44); //get C matrix
1360 Double_t rold00=cin00+v00;
1361 Double_t rold10=cin10;
1362 Double_t rold11=cin11+v11;
1363 ////////////////////// R matrix inversion /////////////////////////
1364 Double_t det=rold00*rold11-rold10*rold10;
1365 Double_t r00=rold11/det;
1366 Double_t r10=-rold10/det;
1367 Double_t r11=rold00/det;
1368 ////////////////////////////////////////////////////////////////////
1369 Double_t k00=cin00*r00+cin10*r10;
1370 Double_t k01=cin00*r10+cin10*r11;
1371 Double_t k10=cin10*r00+cin11*r10;
1372 Double_t k11=cin10*r10+cin11*r11;
1373 Double_t k20=cin20*r00+cin21*r10;
1374 Double_t k21=cin20*r10+cin21*r11;
1375 Double_t k30=cin30*r00+cin31*r10;
1376 Double_t k31=cin30*r10+cin31*r11;
1377 Double_t k40=cin40*r00+cin41*r10;
1378 Double_t k41=cin40*r10+cin41*r11;
1379 Double_t x0,x1,x2,x3,x4;
1380 newTrack->GetXElements(x0,x1,x2,x3,x4); // get the state vector
1381 Double_t savex0=x0, savex1=x1;
1382 x0+=k00*(m[0]-savex0)+k01*(m[1]-savex1);
1383 x1+=k10*(m[0]-savex0)+k11*(m[1]-savex1);
1384 x2+=k20*(m[0]-savex0)+k21*(m[1]-savex1);
1385 x3+=k30*(m[0]-savex0)+k31*(m[1]-savex1);
1386 x4+=k40*(m[0]-savex0)+k41*(m[1]-savex1);
1387 Double_t c00,c10,c20,c30,c40,c11,c21,c31,c41,c22,c32,c42,c33,c43,c44;
1388 c00=cin00-k00*cin00-k01*cin10;
1389 c10=cin10-k00*cin10-k01*cin11;
1390 c20=cin20-k00*cin20-k01*cin21;
1391 c30=cin30-k00*cin30-k01*cin31;
1392 c40=cin40-k00*cin40-k01*cin41;
1393 c11=cin11-k10*cin10-k11*cin11;
1394 c21=cin21-k10*cin20-k11*cin21;
1395 c31=cin31-k10*cin30-k11*cin31;
1396 c41=cin41-k10*cin40-k11*cin41;
1397 c22=cin22-k20*cin20-k21*cin21;
1398 c32=cin32-k20*cin30-k21*cin31;
1399 c42=cin42-k20*cin40-k21*cin41;
1400 c33=cin33-k30*cin30-k31*cin31;
1401 c43=cin43-k30*cin40-k31*cin41;
1402 c44=cin44-k40*cin40-k41*cin41;
1403 newTrack->PutXElements(x0,x1,x2,x3,x4); // put the new state vector
1404 newTrack->PutCElements(c00,
1408 c40,c41,c42,c43,c44); // put in track the
1410 Double_t vmcold00=v00-c00;
1411 Double_t vmcold10=-c10;
1412 Double_t vmcold11=v11-c11;
1413 ////////////////////// Matrix vmc inversion ///////////////////////
1414 det=vmcold00*vmcold11-vmcold10*vmcold10;
1415 Double_t vmc00=vmcold11/det;
1416 Double_t vmc10=-vmcold10/det;
1417 Double_t vmc11=vmcold00/det;
1418 ////////////////////////////////////////////////////////////////////
1419 Double_t chi2=(m[0]-x0)*( vmc00*(m[0]-x0) + 2.*vmc10*(m[1]-x1) ) +
1420 (m[1]-x1)*vmc11*(m[1]-x1);
1421 newTrack->SetChi2(newTrack->GetChi2()+chi2);
1423 //----------------------------------------------------------------------
1424 //void AliITSTrackerV1::KalmanFilterVert(AliITSTrackV1 *newTrack,
1425 // TVector &cluster,Double_t sigma[2]){
1426 void AliITSTrackerV1::KalmanFilterVert(AliITSTrackV1 *newTrack,
1427 TVector &cluster,Double_t sigma[2]
1428 /*, Double_t chi2pred*/){
1429 //Origin A. Badala' and G.S. Pappalardo:
1430 // e-mail Angela.Badala@ct.infn.it, Giuseppe.S.Pappalardo@ct.infn.it
1431 // Kalman filter with vertex constraint
1432 ///////////////////// Evaluation of the measurement vector m ////////
1434 Double_t rk,phik,zk;
1435 rk=cluster(0); phik=cluster(1); zk=cluster(2);
1437 Double_t cc=(*newTrack).GetC();
1438 Double_t zv=(*newTrack).GetZv();
1439 Double_t dv=(*newTrack).GetDv();
1441 Double_t tgl= (zk-zv)*cy/TMath::ASin(cy*rk);
1443 /////////////////////// Evaluation of the error matrix V //////////
1444 Int_t layer=newTrack->GetLayer();
1445 Double_t v00=sigma[0];
1446 Double_t v11=sigma[1];
1447 Double_t v31=sigma[1]/rk;
1448 Double_t sigmaDv=newTrack->GetsigmaDv();
1449 Double_t v22=sigmaDv*sigmaDv + newTrack->Getd2(layer-1);
1450 Double_t v32=newTrack->Getdtgl(layer-1);
1451 Double_t sigmaZv=newTrack->GetsigmaZv();
1452 Double_t v33=(sigma[1]+sigmaZv*sigmaZv)/(rk*rk)+newTrack->Gettgl2(layer-1);
1453 //////////////////////////////////////////////////////////////////
1454 Double_t cin00,cin10,cin11,cin20,cin21,cin22,
1455 cin30,cin31,cin32,cin33,cin40,cin41,cin42,cin43,cin44;
1456 newTrack->GetCElements(cin00,
1459 cin30,cin31,cin32,cin33,
1460 cin40,cin41,cin42,cin43,cin44); //get C matrix
1468 r[3][1]=cin31+sigma[1]/rk;
1469 r[2][2]=cin22+sigmaDv*sigmaDv+newTrack->Getd2(layer-1);
1470 r[3][2]=cin32+newTrack->Getdtgl(layer-1);
1471 r[3][3]=cin33+(sigma[1]+sigmaZv*sigmaZv)/(rk*rk)+
1472 newTrack->Gettgl2(layer-1);
1473 r[0][1]=r[1][0]; r[0][2]=r[2][0]; r[0][3]=r[3][0];
1474 r[1][2]=r[2][1]; r[1][3]=r[3][1]; r[2][3]=r[3][2];
1475 ///////////////////// Matrix R inversion //////////////////////////
1479 Int_t ll[kn],mm[kn];
1482 for(k=0; k<kn; k++) {
1486 for(j=k; j<kn ; j++) {
1487 for (i=j; i<kn; i++) {
1488 if(TMath::Abs(big) < TMath::Abs(r[i][j]) ) {
1498 for(i=0; i<kn; i++) {
1507 for(j=0; j<kn; j++) {
1516 cout << "Singular matrix\n";
1518 for(i=0; i<kn; i++) {
1519 if(i == k) { continue; }
1520 r[i][k]=r[i][k]/(-big);
1523 for(i=0; i<kn; i++) {
1525 for(j=0; j<kn; j++) {
1526 if(i == k || j == k) continue;
1527 r[i][j]=hold*r[k][j]+r[i][j];
1531 for(j=0; j<kn; j++) {
1532 if(j == k) continue;
1533 r[k][j]=r[k][j]/big;
1541 for(k=kn-1; k>=0; k--) {
1544 for (j=0; j<kn; j++) {
1552 for (i=0; i<kn; i++) {
1559 ////////////////////////////////////////////////////////////////////
1560 Double_t k00=cin00*r[0][0]+cin10*r[1][0]+cin20*r[2][0]+cin30*r[3][0];
1561 Double_t k01=cin00*r[1][0]+cin10*r[1][1]+cin20*r[2][1]+cin30*r[3][1];
1562 Double_t k02=cin00*r[2][0]+cin10*r[2][1]+cin20*r[2][2]+cin30*r[3][2];
1563 Double_t k03=cin00*r[3][0]+cin10*r[3][1]+cin20*r[3][2]+cin30*r[3][3];
1564 Double_t k10=cin10*r[0][0]+cin11*r[1][0]+cin21*r[2][0]+cin31*r[3][0];
1565 Double_t k11=cin10*r[1][0]+cin11*r[1][1]+cin21*r[2][1]+cin31*r[3][1];
1566 Double_t k12=cin10*r[2][0]+cin11*r[2][1]+cin21*r[2][2]+cin31*r[3][2];
1567 Double_t k13=cin10*r[3][0]+cin11*r[3][1]+cin21*r[3][2]+cin31*r[3][3];
1568 Double_t k20=cin20*r[0][0]+cin21*r[1][0]+cin22*r[2][0]+cin32*r[3][0];
1569 Double_t k21=cin20*r[1][0]+cin21*r[1][1]+cin22*r[2][1]+cin32*r[3][1];
1570 Double_t k22=cin20*r[2][0]+cin21*r[2][1]+cin22*r[2][2]+cin32*r[3][2];
1571 Double_t k23=cin20*r[3][0]+cin21*r[3][1]+cin22*r[3][2]+cin32*r[3][3];
1572 Double_t k30=cin30*r[0][0]+cin31*r[1][0]+cin32*r[2][0]+cin33*r[3][0];
1573 Double_t k31=cin30*r[1][0]+cin31*r[1][1]+cin32*r[2][1]+cin33*r[3][1];
1574 Double_t k32=cin30*r[2][0]+cin31*r[2][1]+cin32*r[2][2]+cin33*r[3][2];
1575 Double_t k33=cin30*r[3][0]+cin31*r[3][1]+cin32*r[3][2]+cin33*r[3][3];
1576 Double_t k40=cin40*r[0][0]+cin41*r[1][0]+cin42*r[2][0]+cin43*r[3][0];
1577 Double_t k41=cin40*r[1][0]+cin41*r[1][1]+cin42*r[2][1]+cin43*r[3][1];
1578 Double_t k42=cin40*r[2][0]+cin41*r[2][1]+cin42*r[2][2]+cin43*r[3][2];
1579 Double_t k43=cin40*r[3][0]+cin41*r[3][1]+cin42*r[3][2]+cin43*r[3][3];
1581 Double_t x0,x1,x2,x3,x4;
1582 newTrack->GetXElements(x0,x1,x2,x3,x4); // get the state vector
1583 Double_t savex0=x0, savex1=x1, savex2=x2, savex3=x3;
1584 x0+=k00*(m[0]-savex0)+k01*(m[1]-savex1)+k02*(m[2]-savex2)+
1586 x1+=k10*(m[0]-savex0)+k11*(m[1]-savex1)+k12*(m[2]-savex2)+
1588 x2+=k20*(m[0]-savex0)+k21*(m[1]-savex1)+k22*(m[2]-savex2)+
1590 x3+=k30*(m[0]-savex0)+k31*(m[1]-savex1)+k32*(m[2]-savex2)+
1592 x4+=k40*(m[0]-savex0)+k41*(m[1]-savex1)+k42*(m[2]-savex2)+
1594 Double_t c00,c10,c20,c30,c40,c11,c21,c31,c41,c22,c32,c42,c33,c43,c44;
1595 c00=cin00-k00*cin00-k01*cin10-k02*cin20-k03*cin30;
1596 c10=cin10-k00*cin10-k01*cin11-k02*cin21-k03*cin31;
1597 c20=cin20-k00*cin20-k01*cin21-k02*cin22-k03*cin32;
1598 c30=cin30-k00*cin30-k01*cin31-k02*cin32-k03*cin33;
1599 c40=cin40-k00*cin40-k01*cin41-k02*cin42-k03*cin43;
1600 c11=cin11-k10*cin10-k11*cin11-k12*cin21-k13*cin31;
1601 c21=cin21-k10*cin20-k11*cin21-k12*cin22-k13*cin32;
1602 c31=cin31-k10*cin30-k11*cin31-k12*cin32-k13*cin33;
1603 c41=cin41-k10*cin40-k11*cin41-k12*cin42-k13*cin43;
1604 c22=cin22-k20*cin20-k21*cin21-k22*cin22-k23*cin32;
1605 c32=cin32-k20*cin30-k21*cin31-k22*cin32-k23*cin33;
1606 c42=cin42-k20*cin40-k21*cin41-k22*cin42-k23*cin43;
1607 c33=cin33-k30*cin30-k31*cin31-k32*cin32-k33*cin33;
1608 c43=cin43-k30*cin40-k31*cin41-k32*cin42-k33*cin43;
1609 c44=cin44-k40*cin40-k41*cin41-k42*cin42-k43*cin43;
1611 newTrack->PutXElements(x0,x1,x2,x3,x4); // put the new state vector
1612 newTrack->PutCElements(c00,
1616 c40,c41,c42,c43,c44); // put in track the
1619 vmc[0][0]=v00-c00; vmc[1][0]=-c10; vmc[2][0]=-c20; vmc[3][0]=-c30;
1620 vmc[1][1]=v11-c11; vmc[2][1]=-c21; vmc[3][1]=v31-c31;
1621 vmc[2][2]=v22-c22; vmc[3][2]=v32-c32;
1623 vmc[0][1]=vmc[1][0]; vmc[0][2]=vmc[2][0]; vmc[0][3]=vmc[3][0];
1624 vmc[1][2]=vmc[2][1]; vmc[1][3]=vmc[3][1];
1625 vmc[2][3]=vmc[3][2];
1626 /////////////////////// vmc matrix inversion ///////////////////////
1628 for(k=0; k<kn; k++) {
1632 for(j=k; j<kn ; j++) {
1633 for (i=j; i<kn; i++) {
1634 if(TMath::Abs(big) < TMath::Abs(vmc[i][j]) ) {
1644 for(i=0; i<kn; i++) {
1646 vmc[k][i]=vmc[j][i];
1653 for(j=0; j<kn; j++) {
1655 vmc[j][k]=vmc[j][i];
1662 cout << "Singular matrix\n";
1664 for(i=0; i<kn; i++) {
1665 if(i == k) continue;
1666 vmc[i][k]=vmc[i][k]/(-big);
1669 for(i=0; i<kn; i++) {
1671 for(j=0; j<kn; j++) {
1672 if(i == k || j == k) continue;
1673 vmc[i][j]=hold*vmc[k][j]+vmc[i][j];
1677 for(j=0; j<kn; j++) {
1678 if(j == k) continue;
1679 vmc[k][j]=vmc[k][j]/big;
1687 for(k=kn-1; k>=0; k--) {
1690 for (j=0; j<kn; j++) {
1692 vmc[j][k]=-vmc[j][i];
1698 for (i=0; i<kn; i++) {
1700 vmc[k][i]=-vmc[j][i];
1705 ////////////////////////////////////////////////////////////////////
1706 Double_t chi2=(m[0]-x0)*( vmc[0][0]*(m[0]-x0) + 2.*vmc[1][0]*(m[1]-x1) +
1707 2.*vmc[2][0]*(m[2]-x2)+ 2.*vmc[3][0]*(m[3]-x3) )+
1708 (m[1]-x1)* ( vmc[1][1]*(m[1]-x1) + 2.*vmc[2][1]*(m[2]-x2)+
1709 2.*vmc[3][1]*(m[3]-x3) ) +
1710 (m[2]-x2)* ( vmc[2][2]*(m[2]-x2)+ 2.*vmc[3][2]*(m[3]-x3) ) +
1711 (m[3]-x3)*vmc[3][3]*(m[3]-x3);
1712 //cout<<" chi2 kalman = "<<chi2<<"\n"; getchar();
1713 newTrack->SetChi2(newTrack->GetChi2()+chi2);
1714 // newTrack->SetChi2(newTrack->GetChi2()+chi2pred);