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 **************************************************************************/
15 // AliTOFtracker Class
16 // Task: Perform association of the ESD tracks to TOF Clusters
17 // and Update ESD track with associated TOF Cluster parameters
19 //--------------------------------------------------------------------
22 #include "AliTOFtrackerMI.h"
23 #include "AliTOFtrack.h"
24 #include "TClonesArray.h"
26 #include "AliTOFdigit.h"
27 #include "AliTOFGeometry.h"
30 #include "AliModule.h"
31 #include "TTreeStream.h"
32 #include "AliTOFcluster.h"
33 #include "AliTOFcalib.h"
35 ClassImp(AliTOFtrackerMI)
37 //_____________________________________________________________________________
38 AliTOFtrackerMI::AliTOFtrackerMI(AliTOFGeometry * geom, Double_t parPID[2]) {
39 //AliTOFtrackerMI main Ctor
49 fTOFpid = new AliTOFpidESD(parPID);
53 fDy=AliTOFGeometry::XPad();
54 fDz=AliTOFGeometry::ZPad();
59 fDebugStreamer = new TTreeSRedirector("TOFdebug.root");
60 //Init(); // temporary solution to know about Holes/no Holes
61 fHoles=geom->GetHoles();
63 //_____________________________________________________________________________
64 AliTOFtrackerMI::AliTOFtrackerMI(const AliTOFtrackerMI &t):AliTracker() {
65 //AliTOFtrackerMI copy Ctor
69 fNseedsTOF=t.fNseedsTOF;
70 fngoodmatch=t.fngoodmatch;
71 fnbadmatch=t.fnbadmatch;
72 fnunmatch=t.fnunmatch;
77 fTOFHeigth=t.fTOFHeigth;
87 //_________________________________________________________________________________
88 AliTOFtrackerMI::~AliTOFtrackerMI(){
93 //fDebugStreamer->Close();
94 delete fDebugStreamer;
99 //_____________________________________________________________________________
101 void AliTOFtrackerMI::Init() {
103 // temporary solution to know about Holes/no Holes, will be implemented as
104 // an AliTOFGeometry getter
106 AliModule* frame=gAlice->GetModule("FRAME");
109 Error("Init","Could Not load FRAME! Assume Frame with Holes \n");
112 if(frame->IsVersion()==1) {fHoles=false;}
117 //_____________________________________________________________________________
118 Int_t AliTOFtrackerMI::PropagateBack(AliESD* event) {
120 // Gets seeds from ESD event and Match with TOF Clusters
124 //Initialise some counters
133 Int_t ntrk=event->GetNumberOfTracks();
135 fSeeds= new TClonesArray("AliESDtrack");
136 TClonesArray &aESDTrack = *fSeeds;
139 //Load ESD tracks into a local Array of ESD Seeds
141 for (Int_t i=0; i<fNseeds; i++) {
142 AliESDtrack *t=event->GetTrack(i);
143 new(aESDTrack[i]) AliESDtrack(*t);
146 //Prepare ESD tracks candidates for TOF Matching
149 //First Step with Strict Matching Criterion
150 //MatchTracks(kFALSE);
152 //Second Step with Looser Matching Criterion
153 //MatchTracks(kTRUE);
154 MatchTracksMI(kFALSE); // assign track to clusters
155 MatchTracksMI(kTRUE); // assign clusters to esd
157 Info("PropagateBack","Number of matched tracks: %d",fnmatch);
158 Info("PropagateBack","Number of good matched tracks: %d",fngoodmatch);
159 Info("PropagateBack","Number of bad matched tracks: %d",fnbadmatch);
161 //Update the matched ESD tracks
163 for (Int_t i=0; i<ntrk; i++) {
164 AliESDtrack *t=event->GetTrack(i);
165 AliESDtrack *seed =(AliESDtrack*)fSeeds->UncheckedAt(i);
166 if(seed->GetTOFsignal()>0){
167 t->SetTOFsignal(seed->GetTOFsignal());
168 t->SetTOFcluster(seed->GetTOFcluster());
170 seed->GetTOFLabel(tlab);
171 t->SetTOFLabel(tlab);
172 AliTOFtrack *track = new AliTOFtrack(*seed);
175 seed->GetTOFInfo(info);
176 seed->GetIntegratedTimes(times);
177 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
178 t->SetIntegratedLength(seed->GetIntegratedLength());
179 t->SetIntegratedTimes(times);
180 t->SetTOFsignalToT(seed->GetTOFsignalToT());
181 t->SetTOFCalChannel(seed->GetTOFCalChannel());
190 fTOFpid->MakePID(event);
205 //_________________________________________________________________________
206 void AliTOFtrackerMI::CollectESD() {
207 //prepare the set of ESD tracks to be matched to clusters in TOF
209 fTracks= new TClonesArray("AliTOFtrack");
210 TClonesArray &aTOFTrack = *fTracks;
213 for (Int_t i=0; i<fNseeds; i++) {
215 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(i);
216 if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue;
218 // TRD good tracks, already propagated at 371 cm
220 AliTOFtrack *track = new AliTOFtrack(*t); // New
221 Double_t x = track->GetX(); //New
223 if (((t->GetStatus()&AliESDtrack::kTRDout)!=0 ) &&
224 ( x >= fGeom->RinTOF()) ){
225 track->SetSeedIndex(i);
226 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
227 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
233 // Propagate the rest of TPCbp
236 if(track->PropagateToInnerTOF(fHoles)){ // temporary solution
237 // if(track->PropagateToInnerTOF(fGeom->GetHoles())){
238 track->SetSeedIndex(i);
239 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
240 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
249 printf("TRD\tOn\t%d\tOff\t%d\n",c0,c1);
251 // Sort according uncertainties on track position
264 //_________________________________________________________________________
265 void AliTOFtrackerMI::MatchTracks( Bool_t /*mLastStep*/){
270 //_________________________________________________________________________
271 void AliTOFtrackerMI::MatchTracksMI(Bool_t mLastStep){
273 //Match ESD tracks to clusters in TOF
274 const Float_t kTofOffset = 26; // time offset
275 const Float_t kMinQuality = -6.; // minimal quality
276 const Float_t kMaxQualityD = 1.; // max delta quality if cluster used
277 const Float_t kForbiddenR = 0.1; // minimal PID according TPC
279 static const Double_t kMasses[]={
280 0.000511, 0.105658, 0.139570, 0.493677, 0.938272, 1.875613
283 Int_t nSteps=(Int_t)(fTOFHeigth/0.1);
285 AliTOFcalib *calib = new AliTOFcalib(fGeom);
287 //PH Arrays (moved outside of the loop)
288 Float_t * trackPos[4];
289 for (Int_t ii=0; ii<4; ii++) trackPos[ii] = new Float_t[nSteps];
291 for (Int_t ii=0;ii<6;ii++) clind[ii] = new Int_t[fN];
296 Float_t dist3D[1000][6];
297 Double_t times[1000][6];
298 Float_t mintimedist[1000];
299 Float_t likelihood[1000];
300 Float_t length[1000];
301 AliTOFcluster *clusters[1000];
305 for (Int_t i=0; i<fNseedsTOF; i++) {
307 AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(i);
308 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(track->GetSeedIndex());
309 Bool_t hasTime = ( (t->GetStatus()& AliESDtrack::kTIME)>0) ? kTRUE:kFALSE; // did we integrate time
310 Float_t trdquality = t->GetTRDQuality();
314 t->GetTPCpid(tpcpid);
316 for (Int_t ipid=0;ipid<5;ipid++){
317 sumpid+=tpcpid[ipid];
319 for (Int_t ipid=0;ipid<5;ipid++){
320 if (sumpid>0) tpcpid[ipid]/=sumpid;
326 if (trdquality<0) continue; // no chance
328 AliTOFtrack *trackTOFin =new AliTOFtrack(*track);
330 //propagat track to the middle of TOF
332 Float_t xs = 378.2; // should be defined in the TOF geometry
333 Double_t ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
335 Double_t ysect=trackTOFin->GetYat(xs,skip);
338 ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
339 ysect=trackTOFin->GetYat(xs,skip);
342 if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) {
345 } else if (ysect <-ymax) {
346 if (!trackTOFin->Rotate(-AliTOFGeometry::GetAlpha())) {
350 if(!trackTOFin->PropagateTo(xs)) {
354 // Determine a window around the track
357 trackTOFin->GetExternalParameters(x,par);
359 trackTOFin->GetExternalCovariance(cov);
360 Float_t scalefact=3.;
363 ((5*TMath::Sqrt(cov[0]) + 3.*fDy +10.*TMath::Abs(par[2]))/fR);
366 (5*TMath::Sqrt(cov[2]) + 3.*fDz +10.*TMath::Abs(par[3]));
368 Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha();
369 if (phi<-TMath::Pi())phi+=2*TMath::Pi();
370 if (phi>=TMath::Pi())phi-=2*TMath::Pi();
375 // find the clusters in the window of the track
377 for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) {
378 AliTOFcluster *c=fClusters[k];
379 if (c->GetZ() > z+dz) break;
380 // if (c->IsUsed()) continue;
382 Double_t dph=TMath::Abs(c->GetPhi()-phi);
383 if (dph>TMath::Pi()) dph-=2.*TMath::Pi();
384 if (TMath::Abs(dph)>dphi) continue;
386 clind[0][nc] = c->GetDetInd(0);
387 clind[1][nc] = c->GetDetInd(1);
388 clind[2][nc] = c->GetDetInd(2);
389 clind[3][nc] = c->GetDetInd(3);
390 clind[4][nc] = c->GetDetInd(4);
396 // select close clusters
398 Double_t mom=t->GetP();
399 // Bool_t dump = kTRUE;
400 for (Int_t icl=0; icl<nc; icl++){
401 Float_t distances[5];
402 if (nfound>=1000) break;
403 index[nfound]=clind[5][icl];
404 AliTOFcluster *cluster = fClusters[clind[5][icl]];
405 GetLinearDistances(trackTOFin,cluster, distances);
406 dist3D[nfound][0] = distances[4];
407 dist3D[nfound][1] = distances[1];
408 dist3D[nfound][2] = distances[2];
410 if (TMath::Abs(dist3D[nfound][1])>20 || TMath::Abs(dist3D[nfound][2])>20) continue;
412 GetLikelihood(distances[1],distances[2],cov,trackTOFin, dist3D[nfound][3], dist3D[nfound][4]);
415 if (dist3D[nfound][3]*dist3D[nfound][4]<0.00000000000001) continue; // log likelihood
416 if (TMath::Log(dist3D[nfound][3]*dist3D[nfound][4])<-9) continue; // log likelihood
418 clusters[nfound] = cluster;
420 //length and TOF updates
421 trackTOFin->GetIntegratedTimes(times[nfound]);
422 length[nfound] = trackTOFin->GetIntegratedLength();
423 length[nfound]+=distances[4];
424 mintimedist[nfound]=1000;
425 Double_t tof2=AliTOFGeometry::TdcBinWidth()*cluster->GetTDC()+kTofOffset; // in ps
426 // Float_t tgamma = TMath::Sqrt(cluster->GetR()*cluster->GetR()+cluster->GetZ()*cluster->GetZ())/0.03; //time for "primary" gamma
427 //if (trackTOFin->GetPt()<0.7 && TMath::Abs(tgamma-tof2)<350) continue; // gamma conversion candidate - TEMPORARY
428 for(Int_t j=0;j<=5;j++){
429 Double_t mass=kMasses[j];
430 times[nfound][j]+=distances[4]/3e-2*TMath::Sqrt(mom*mom+mass*mass)/mom; // add time distance
431 if ( TMath::Abs(times[nfound][j]-tof2)<mintimedist[nfound] && tpcpid[j]>kForbiddenR){
432 mintimedist[nfound]=TMath::Abs(times[nfound][j]-tof2);
436 Float_t liketime = TMath::Exp(-mintimedist[nfound]/90.)+0.25*TMath::Exp(-mintimedist[nfound]/180.);
437 if (!hasTime) liketime=0.2;
438 likelihood[nfound] = TMath::Log(dist3D[nfound][3]*dist3D[nfound][4]*liketime);
440 if (TMath::Log(dist3D[nfound][3]*dist3D[nfound][4])<-1){
441 if (likelihood[nfound]<-9.) continue;
452 //choose the best cluster
454 Float_t quality[1000];
457 AliTOFcluster * cgold=0;
459 for (Int_t icl=0;icl<nfound;icl++){
460 quality[icl] = dist3D[icl][3]*dist3D[icl][4];
462 TMath::Sort(nfound,quality,index,kTRUE);
464 cgold = clusters[igold];
465 if (nfound>1 &&likelihood[index[1]]>likelihood[index[0]]){
466 if ( quality[index[0]]<quality[index[1]]+0.5){
468 cgold = clusters[igold];
473 Float_t qualityGold = TMath::Log(0.0000001+(quality[igold]*(0.1+TMath::Exp(-mintimedist[igold]/80.))*(0.2+trdquality)));
475 if (cgold->GetQuality()<qualityGold) cgold->SetQuality(qualityGold);
480 //signed better cluster
481 if (cgold->GetQuality()>qualityGold+kMaxQualityD) continue;
482 if (2.*qualityGold-cgold->GetQuality()<kMinQuality) continue;
487 for (Int_t icl=0;icl<nfound;icl++){
489 (clusters[index[icl]]->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel()))
491 (clusters[index[icl]]->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel()))
493 (clusters[index[icl]]->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel()))
500 if (inonfake==0) fngoodmatch++;
506 tlab[0]=cgold->GetLabel(0);
507 tlab[1]=cgold->GetLabel(1);
508 tlab[2]=cgold->GetLabel(2);
509 // Double_t tof2=25.*cgold->GetTDC()-350; // in ps
510 Double_t tof2=AliTOFGeometry::TdcBinWidth()*cgold->GetTDC()+kTofOffset; // in ps
511 Float_t tgamma = TMath::Sqrt(cgold->GetR()*cgold->GetR()+cgold->GetZ()*cgold->GetZ())/0.03;
512 Float_t info[11]={dist3D[igold][0],dist3D[igold][1],dist3D[igold][2],dist3D[igold][3],dist3D[igold][4],mintimedist[igold],
513 -1,tgamma, qualityGold,cgold->GetQuality(),0};
514 // GetLinearDistances(trackTOFin,cgold,&info[6]);
517 // info[7] = mintimedist[index[inonfake]];
520 // Store quantities to be used for TOF Calibration
521 Float_t ToT=cgold->GetToT(); // in ps
522 t->SetTOFsignalToT(ToT);
524 ind[0]=cgold->GetDetInd(0);
525 ind[1]=cgold->GetDetInd(1);
526 ind[2]=cgold->GetDetInd(2);
527 ind[3]=cgold->GetDetInd(3);
528 ind[4]=cgold->GetDetInd(4);
529 Int_t calindex = calib->GetIndex(ind);
530 t->SetTOFCalChannel(calindex);
533 t->SetTOFsignal(tof2);
534 t->SetTOFcluster(cgold->GetIndex());
535 AliTOFtrack *trackTOFout = new AliTOFtrack(*t);
536 trackTOFout->PropagateTo(378.);
537 t->UpdateTrackParams(trackTOFout,AliESDtrack::kTOFout);
538 t->SetIntegratedLength(length[igold]);
539 t->SetIntegratedTimes(times[igold]);
540 t->SetTOFLabel(tlab);
549 for (Int_t ii=0; ii<4; ii++) delete [] trackPos[ii];
550 for (Int_t ii=0;ii<6;ii++) delete [] clind[ii];
557 // //_________________________________________________________________________
558 // Int_t AliTOFtrackerMI::LoadClusters(TTree *dTree) {
559 // //--------------------------------------------------------------------
560 // //This function loads the TOF clusters
561 // //--------------------------------------------------------------------
563 // TBranch *branch=dTree->GetBranch("TOF");
565 // Error("LoadClusters"," can't get the branch with the TOF digits !\n");
569 // TClonesArray dummy("AliTOFdigit",10000), *digits=&dummy;
570 // branch->SetAddress(&digits);
572 // dTree->GetEvent(0);
573 // Int_t nd=digits->GetEntriesFast();
574 // Info("LoadClusters","number of digits: %d",nd);
576 // for (Int_t i=0; i<nd; i++) {
577 // AliTOFdigit *d=(AliTOFdigit*)digits->UncheckedAt(i);
578 // Int_t dig[5]; Float_t g[3];
579 // dig[0]=d->GetSector();
580 // dig[1]=d->GetPlate();
581 // dig[2]=d->GetStrip();
582 // dig[3]=d->GetPadz();
583 // dig[4]=d->GetPadx();
585 // fGeom->GetPos(dig,g);
588 // h[0]=TMath::Sqrt(g[0]*g[0]+g[1]*g[1]);
589 // h[1]=TMath::ATan2(g[1],g[0]); h[2]=g[2];
590 // h[3]=d->GetTdc(); h[4]=d->GetAdc();
592 // AliTOFcluster *cl=new AliTOFcluster(h,d->GetTracks(),dig,i);
593 // InsertCluster(cl);
598 // //_________________________________________________________________________
599 // void AliTOFtrackerMI::UnloadClusters() {
600 // //--------------------------------------------------------------------
601 // //This function unloads TOF clusters
602 // //--------------------------------------------------------------------
603 // for (Int_t i=0; i<fN; i++) delete fClusters[i];
609 //_________________________________________________________________________
610 Int_t AliTOFtrackerMI::LoadClusters(TTree *cTree) {
611 //--------------------------------------------------------------------
612 //This function loads the TOF clusters
613 //--------------------------------------------------------------------
615 TBranch *branch=cTree->GetBranch("TOF");
617 AliError("can't get the branch with the TOF clusters !");
621 TClonesArray dummy("AliTOFcluster",10000), *clusters=&dummy;
622 branch->SetAddress(&clusters);
625 Int_t nc=clusters->GetEntriesFast();
626 AliInfo(Form("Number of clusters: %d",nc));
628 for (Int_t i=0; i<nc; i++) {
629 AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i);
631 for (Int_t jj=0; jj<5; jj++) dig[jj]=c->GetDetInd(jj);
641 for (Int_t jj=0; jj<3; jj++) indexDig[jj] = c->GetLabel(jj);
643 AliTOFcluster *cl=new AliTOFcluster(h,c->GetTracks(),dig,i);
646 // fClusters[i]=c; fN++;
647 fClusters[i]=new AliTOFcluster(*c); fN++;
649 //AliInfo(Form("%4i %4i %f %f %f %f %f %2i %1i %2i %1i %2i",i, fClusters[i]->GetIndex(),fClusters[i]->GetZ(),fClusters[i]->GetR(),fClusters[i]->GetPhi(), fClusters[i]->GetTDC(),fClusters[i]->GetADC(),fClusters[i]->GetDetInd(0),fClusters[i]->GetDetInd(1),fClusters[i]->GetDetInd(2),fClusters[i]->GetDetInd(3),fClusters[i]->GetDetInd(4)));
650 //AliInfo(Form("%i %f",i, fClusters[i]->GetZ()));
653 //AliInfo(Form("Number of clusters: %d",fN));
657 //_________________________________________________________________________
658 void AliTOFtrackerMI::UnloadClusters() {
659 //--------------------------------------------------------------------
660 //This function unloads TOF clusters
661 //--------------------------------------------------------------------
662 for (Int_t i=0; i<fN; i++) {
672 //_________________________________________________________________________
673 Int_t AliTOFtrackerMI::InsertCluster(AliTOFcluster *c) {
674 //--------------------------------------------------------------------
675 //This function adds a cluster to the array of clusters sorted in Z
676 //--------------------------------------------------------------------
677 if (fN==kMaxCluster) {
678 Error("InsertCluster","Too many clusters !\n");
682 if (fN==0) {fClusters[fN++]=c; return 0;}
683 Int_t i=FindClusterIndex(c->GetZ());
684 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTOFcluster*));
685 fClusters[i]=c; fN++;
690 //_________________________________________________________________________
691 Int_t AliTOFtrackerMI::FindClusterIndex(Double_t z) const {
692 //--------------------------------------------------------------------
693 // This function returns the index of the nearest cluster
694 //--------------------------------------------------------------------
696 if (z <= fClusters[0]->GetZ()) return 0;
697 if (z > fClusters[fN-1]->GetZ()) return fN;
698 Int_t b=0, e=fN-1, m=(b+e)/2;
699 for (; b<e; m=(b+e)/2) {
700 if (z > fClusters[m]->GetZ()) b=m+1;
708 Float_t AliTOFtrackerMI::GetLinearDistances(AliTOFtrack * track, AliTOFcluster *cluster, Float_t distances[5])
711 // calclates distance between cluster and track
712 // use linear aproximation
714 const Float_t kRaddeg = 180/3.14159265358979312;
716 // Float_t tiltangle = fGeom->GetAngles(cluster->fdetIndex[1],cluster->fdetIndex[2])/kRaddeg; //tiltangle
718 cind[0]= cluster->GetDetInd(0);
719 cind[1]= cluster->GetDetInd(1);
720 cind[2]= cluster->GetDetInd(2);
721 cind[3]= cluster->GetDetInd(3);
722 cind[4]= cluster->GetDetInd(4);
723 Float_t tiltangle = fGeom->GetAngles(cluster->GetDetInd(1),cluster->GetDetInd(2))/kRaddeg; //tiltangle
725 Float_t cpos[3]; //cluster position
726 Float_t cpos0[3]; //cluster position
727 // fGeom->GetPos(cluster->fdetIndex,cpos);
728 //fGeom->GetPos(cluster->fdetIndex,cpos0);
730 fGeom->GetPos(cind,cpos);
731 fGeom->GetPos(cind,cpos0);
733 Float_t phi = TMath::ATan2(cpos[1],cpos[0]);
734 if(phi<0) phi=2.*TMath::Pi()+phi;
735 // Get the local angle in the sector philoc
736 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
740 track->GetGlobalXYZ(v0[0],v0[1],v0[2]);
741 track->GetPxPyPz(dir[0],dir[1],dir[2]);
742 dir[0]/=track->GetP();
743 dir[1]/=track->GetP();
744 dir[2]/=track->GetP();
748 Float_t sinphi = TMath::Sin(phiangle);
749 Float_t cosphi = TMath::Cos(phiangle);
750 Float_t sinth = TMath::Sin(tiltangle);
751 Float_t costh = TMath::Cos(tiltangle);
754 temp = cpos[0]*cosphi+cpos[1]*sinphi;
755 cpos[1] = -cpos[0]*sinphi+cpos[1]*cosphi;
757 temp = v0[0]*cosphi+v0[1]*sinphi;
758 v0[1] = -v0[0]*sinphi+v0[1]*cosphi;
761 temp = cpos[0]*costh+cpos[2]*sinth;
762 cpos[2] = -cpos[0]*sinth+cpos[2]*costh;
764 temp = v0[0]*costh+v0[2]*sinth;
765 v0[2] = -v0[0]*sinth+v0[2]*costh;
769 //rotate direction vector
771 temp = dir[0]*cosphi+dir[1]*sinphi;
772 dir[1] = -dir[0]*sinphi+dir[1]*cosphi;
775 temp = dir[0]*costh+dir[2]*sinth;
776 dir[2] = -dir[0]*sinth+dir[2]*costh;
780 Float_t k = (cpos[0]-v0[0])/dir[0];
781 v3[0] = v0[0]+k*dir[0];
782 v3[1] = v0[1]+k*dir[1];
783 v3[2] = v0[2]+k*dir[2];
785 distances[0] = v3[0]-cpos[0];
786 distances[1] = v3[1]-cpos[1];
787 distances[2] = v3[2]-cpos[2];
788 distances[3] = TMath::Sqrt( distances[0]*distances[0]+distances[1]*distances[1]+distances[2]*distances[2]); //distance
789 distances[4] = k; //length
792 // Debuging part of the matching
794 if (track->GetLabel()==cluster->GetLabel(0) ||track->GetLabel()==cluster->GetLabel(1) ){
795 TTreeSRedirector& cstream = *fDebugStreamer;
796 Float_t tdc = cluster->GetTDC();
803 "Dist0="<<distances[0]<<
804 "Dist1="<<distances[1]<<
805 "Dist2="<<distances[2]<<
814 void AliTOFtrackerMI::GetLikelihood(Float_t dy, Float_t dz, const Double_t *cov, AliTOFtrack * /*track*/, Float_t & py, Float_t &pz)
817 // get likelihood - track covariance taken
818 // 75 % of gauss with expected sigma
819 // 25 % of gauss with extended sigma
821 Double_t kMaxSigmaY = 0.6; // ~ 90% of TRD tracks
822 Double_t kMaxSigmaZ = 1.2; // ~ 90% of TRD tracks
823 Double_t kMeanSigmaY = 0.25; // mean TRD sigma
824 Double_t kMeanSigmaZ = 0.5; // mean TRD sigma
827 Float_t normwidth, normd, p0,p1;
828 Float_t sigmay = TMath::Max(TMath::Sqrt(cov[0]+kMeanSigmaY*kMeanSigmaY),kMaxSigmaY);
829 Float_t sigmaz = TMath::Max(TMath::Sqrt(cov[2]+kMeanSigmaZ*kMeanSigmaZ),kMaxSigmaZ);
834 // py calculation - 75% admixture of original sigma - 25% tails
836 normwidth = fDy/sigmay;
838 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
839 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
842 normwidth = fDy/(3.*sigmay);
843 normd = dy/(3.*sigmay);
844 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
845 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
848 // pz calculation - 75% admixture of original sigma - 25% tails
850 normwidth = fDz/sigmaz;
852 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
853 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
856 normwidth = fDz/(3.*sigmaz);
857 normd = dz/(3.*sigmaz);
858 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
859 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));