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 **************************************************************************/
16 //-----------------------------------------------------------------//
18 // AliTOFtracker Class //
19 // Task: Perform association of the ESD tracks to TOF Clusters //
20 // and Update ESD track with associated TOF Cluster parameters //
22 //-----------------------------------------------------------------//
26 #include "TClonesArray.h"
27 #include "TGeoManager.h"
29 #include "TTreeStream.h"
33 #include "AliESDtrack.h"
35 #include "AliTOFRecoParam.h"
36 #include "AliTOFcalib.h"
37 #include "AliTOFcluster.h"
38 #include "AliTOFGeometryV5.h"
39 #include "AliTOFtrackerMI.h"
40 #include "AliTOFtrack.h"
42 extern TGeoManager *gGeoManager;
44 ClassImp(AliTOFtrackerMI)
46 //_____________________________________________________________________________
47 AliTOFtrackerMI::AliTOFtrackerMI():
68 //AliTOFtrackerMI main Ctor
70 fRecoParam=new AliTOFRecoParam();
71 fGeom=new AliTOFGeometryV5();
73 parPID[0]=fRecoParam->GetTimeResolution();
74 parPID[1]=fRecoParam->GetTimeNSigma();
75 fPid=new AliTOFpidESD(parPID);
78 fDebugStreamer = new TTreeSRedirector("TOFdebug.root");
80 //_____________________________________________________________________________
81 AliTOFtrackerMI::AliTOFtrackerMI(const AliTOFtrackerMI &t):
103 //AliTOFtrackerMI copy Ctor
106 fNseedsTOF=t.fNseedsTOF;
107 fngoodmatch=t.fngoodmatch;
108 fnbadmatch=t.fnbadmatch;
109 fnunmatch=t.fnunmatch;
111 fRecoParam = t.fRecoParam;
115 fTOFHeigth=t.fTOFHeigth;
125 //_________________________________________________________________________________
126 AliTOFtrackerMI& AliTOFtrackerMI::operator=(const AliTOFtrackerMI &t)
128 //AliTOFtrackerMI assignment operator
130 this->fNseeds=t.fNseeds;
131 this->fNseedsTOF=t.fNseedsTOF;
132 this->fngoodmatch=t.fngoodmatch;
133 this->fnbadmatch=t.fnbadmatch;
134 this->fnunmatch=t.fnunmatch;
135 this->fnmatch=t.fnmatch;
136 this->fRecoParam = t.fRecoParam;
137 this->fGeom = t.fGeom;
140 this->fTOFHeigth=t.fTOFHeigth;
145 this->fSeeds=t.fSeeds;
146 this->fTracks=t.fTracks;
152 //_____________________________________________________________________________
153 AliTOFtrackerMI::~AliTOFtrackerMI(){
157 if (fDebugStreamer) {
158 //fDebugStreamer->Close();
159 delete fDebugStreamer;
166 //_____________________________________________________________________________
167 Int_t AliTOFtrackerMI::PropagateBack(AliESD* event) {
169 // Gets seeds from ESD event and Match with TOF Clusters
173 //Initialise some counters
182 Int_t ntrk=event->GetNumberOfTracks();
184 fSeeds= new TClonesArray("AliESDtrack");
185 TClonesArray &aESDTrack = *fSeeds;
188 //Load ESD tracks into a local Array of ESD Seeds
190 for (Int_t i=0; i<fNseeds; i++) {
191 AliESDtrack *t=event->GetTrack(i);
192 new(aESDTrack[i]) AliESDtrack(*t);
195 //Prepare ESD tracks candidates for TOF Matching
198 //First Step with Strict Matching Criterion
199 //MatchTracks(kFALSE);
201 //Second Step with Looser Matching Criterion
202 //MatchTracks(kTRUE);
203 MatchTracksMI(kFALSE); // assign track to clusters
204 MatchTracksMI(kTRUE); // assign clusters to esd
206 Info("PropagateBack","Number of matched tracks: %d",fnmatch);
207 Info("PropagateBack","Number of good matched tracks: %d",fngoodmatch);
208 Info("PropagateBack","Number of bad matched tracks: %d",fnbadmatch);
210 //Update the matched ESD tracks
212 for (Int_t i=0; i<ntrk; i++) {
213 AliESDtrack *t=event->GetTrack(i);
214 AliESDtrack *seed =(AliESDtrack*)fSeeds->UncheckedAt(i);
215 if(seed->GetTOFsignal()>0){
216 t->SetTOFsignal(seed->GetTOFsignal());
217 t->SetTOFcluster(seed->GetTOFcluster());
219 seed->GetTOFLabel(tlab);
220 t->SetTOFLabel(tlab);
221 AliTOFtrack *track = new AliTOFtrack(*seed);
224 seed->GetTOFInfo(info);
225 seed->GetIntegratedTimes(times);
226 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
227 t->SetIntegratedLength(seed->GetIntegratedLength());
228 t->SetIntegratedTimes(times);
229 t->SetTOFsignalToT(seed->GetTOFsignalToT());
230 t->SetTOFCalChannel(seed->GetTOFCalChannel());
239 fPid->MakePID(event);
254 //_________________________________________________________________________
255 void AliTOFtrackerMI::CollectESD() {
256 //prepare the set of ESD tracks to be matched to clusters in TOF
258 fTracks= new TClonesArray("AliTOFtrack");
259 TClonesArray &aTOFTrack = *fTracks;
262 for (Int_t i=0; i<fNseeds; i++) {
264 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(i);
265 if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue;
267 // TRD good tracks, already propagated at 371 cm
269 AliTOFtrack *track = new AliTOFtrack(*t); // New
270 Double_t x = track->GetX(); //New
272 if (((t->GetStatus()&AliESDtrack::kTRDout)!=0 ) &&
273 ( x >= fGeom->RinTOF()) ){
274 track->SetSeedIndex(i);
275 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
276 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
282 // Propagate the rest of TPCbp
285 if(track->PropagateToInnerTOF()){ // temporary solution
286 track->SetSeedIndex(i);
287 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
288 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
297 printf("TRD\tOn\t%d\tOff\t%d\n",c0,c1);
299 // Sort according uncertainties on track position
312 //_________________________________________________________________________
313 void AliTOFtrackerMI::MatchTracks( Bool_t /*mLastStep*/){
318 //_________________________________________________________________________
319 void AliTOFtrackerMI::MatchTracksMI(Bool_t mLastStep){
321 //Match ESD tracks to clusters in TOF
322 const Float_t kTofOffset = 26; // time offset
323 const Float_t kMinQuality = -6.; // minimal quality
324 const Float_t kMaxQualityD = 1.; // max delta quality if cluster used
325 const Float_t kForbiddenR = 0.1; // minimal PID according TPC
327 static const Double_t kMasses[]={
328 0.000511, 0.105658, 0.139570, 0.493677, 0.938272, 1.875613
331 Int_t nSteps=(Int_t)(fTOFHeigth/0.1);
333 AliTOFcalib *calib = new AliTOFcalib(fGeom);
335 //PH Arrays (moved outside of the loop)
336 Float_t * trackPos[4];
337 for (Int_t ii=0; ii<4; ii++) trackPos[ii] = new Float_t[nSteps];
339 for (Int_t ii=0;ii<6;ii++) clind[ii] = new Int_t[fN];
344 Float_t dist3D[1000][6];
345 Double_t times[1000][6];
346 Float_t mintimedist[1000];
347 Float_t likelihood[1000];
348 Float_t length[1000];
349 AliTOFcluster *clusters[1000];
353 for (Int_t i=0; i<fNseedsTOF; i++) {
355 AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(i);
356 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(track->GetSeedIndex());
357 Bool_t hasTime = ( (t->GetStatus()& AliESDtrack::kTIME)>0) ? kTRUE:kFALSE; // did we integrate time
358 Float_t trdquality = t->GetTRDQuality();
362 t->GetTPCpid(tpcpid);
364 for (Int_t ipid=0;ipid<5;ipid++){
365 sumpid+=tpcpid[ipid];
367 for (Int_t ipid=0;ipid<5;ipid++){
368 if (sumpid>0) tpcpid[ipid]/=sumpid;
374 if (trdquality<0) continue; // no chance
376 AliTOFtrack *trackTOFin =new AliTOFtrack(*track);
378 //propagat track to the middle of TOF
380 Float_t xs = 378.2; // should be defined in the TOF geometry
381 Double_t ymax=xs*TMath::Tan(0.5*fGeom->GetAlpha());
383 Double_t ysect=trackTOFin->GetYat(xs,skip);
386 ymax=xs*TMath::Tan(0.5*fGeom->GetAlpha());
387 ysect=trackTOFin->GetYat(xs,skip);
390 if (!trackTOFin->Rotate(fGeom->GetAlpha())) {
393 } else if (ysect <-ymax) {
394 if (!trackTOFin->Rotate(-fGeom->GetAlpha())) {
398 if(!trackTOFin->PropagateTo(xs)) {
402 // Determine a window around the track
405 trackTOFin->GetExternalParameters(x,par);
407 trackTOFin->GetExternalCovariance(cov);
408 Float_t scalefact=3.;
411 ((5*TMath::Sqrt(cov[0]) + 3.*fDy +10.*TMath::Abs(par[2]))/fR);
414 (5*TMath::Sqrt(cov[2]) + 3.*fDz +10.*TMath::Abs(par[3]));
416 Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha();
417 if (phi<-TMath::Pi())phi+=2*TMath::Pi();
418 if (phi>=TMath::Pi())phi-=2*TMath::Pi();
423 // find the clusters in the window of the track
425 for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) {
426 AliTOFcluster *c=fClusters[k];
427 if (c->GetZ() > z+dz) break;
428 // if (c->IsUsed()) continue;
430 Double_t dph=TMath::Abs(c->GetPhi()-phi);
431 if (dph>TMath::Pi()) dph-=2.*TMath::Pi();
432 if (TMath::Abs(dph)>dphi) continue;
434 clind[0][nc] = c->GetDetInd(0);
435 clind[1][nc] = c->GetDetInd(1);
436 clind[2][nc] = c->GetDetInd(2);
437 clind[3][nc] = c->GetDetInd(3);
438 clind[4][nc] = c->GetDetInd(4);
444 // select close clusters
446 Double_t mom=t->GetP();
447 // Bool_t dump = kTRUE;
448 for (Int_t icl=0; icl<nc; icl++){
449 Float_t distances[5];
450 if (nfound>=1000) break;
451 index[nfound]=clind[5][icl];
452 AliTOFcluster *cluster = fClusters[clind[5][icl]];
453 GetLinearDistances(trackTOFin,cluster, distances);
454 dist3D[nfound][0] = distances[4];
455 dist3D[nfound][1] = distances[1];
456 dist3D[nfound][2] = distances[2];
458 if (TMath::Abs(dist3D[nfound][1])>20 || TMath::Abs(dist3D[nfound][2])>20) continue;
460 GetLikelihood(distances[1],distances[2],cov,trackTOFin, dist3D[nfound][3], dist3D[nfound][4]);
463 if (dist3D[nfound][3]*dist3D[nfound][4]<0.00000000000001) continue; // log likelihood
464 if (TMath::Log(dist3D[nfound][3]*dist3D[nfound][4])<-9) continue; // log likelihood
466 clusters[nfound] = cluster;
468 //length and TOF updates
469 trackTOFin->GetIntegratedTimes(times[nfound]);
470 length[nfound] = trackTOFin->GetIntegratedLength();
471 length[nfound]+=distances[4];
472 mintimedist[nfound]=1000;
473 Double_t tof2=fGeom->TdcBinWidth()*cluster->GetTDC()+kTofOffset; // in ps
474 // Float_t tgamma = TMath::Sqrt(cluster->GetR()*cluster->GetR()+cluster->GetZ()*cluster->GetZ())/0.03; //time for "primary" gamma
475 //if (trackTOFin->GetPt()<0.7 && TMath::Abs(tgamma-tof2)<350) continue; // gamma conversion candidate - TEMPORARY
476 for(Int_t j=0;j<=5;j++){
477 Double_t mass=kMasses[j];
478 times[nfound][j]+=distances[4]/3e-2*TMath::Sqrt(mom*mom+mass*mass)/mom; // add time distance
479 if ( TMath::Abs(times[nfound][j]-tof2)<mintimedist[nfound] && tpcpid[j]>kForbiddenR){
480 mintimedist[nfound]=TMath::Abs(times[nfound][j]-tof2);
484 Float_t liketime = TMath::Exp(-mintimedist[nfound]/90.)+0.25*TMath::Exp(-mintimedist[nfound]/180.);
485 if (!hasTime) liketime=0.2;
486 likelihood[nfound] = TMath::Log(dist3D[nfound][3]*dist3D[nfound][4]*liketime);
488 if (TMath::Log(dist3D[nfound][3]*dist3D[nfound][4])<-1){
489 if (likelihood[nfound]<-9.) continue;
500 //choose the best cluster
502 Float_t quality[1000];
505 AliTOFcluster * cgold=0;
507 for (Int_t icl=0;icl<nfound;icl++){
508 quality[icl] = dist3D[icl][3]*dist3D[icl][4];
510 TMath::Sort(nfound,quality,index,kTRUE);
512 cgold = clusters[igold];
513 if (nfound>1 &&likelihood[index[1]]>likelihood[index[0]]){
514 if ( quality[index[0]]<quality[index[1]]+0.5){
516 cgold = clusters[igold];
521 Float_t qualityGold = TMath::Log(0.0000001+(quality[igold]*(0.1+TMath::Exp(-mintimedist[igold]/80.))*(0.2+trdquality)));
523 if (cgold->GetQuality()<qualityGold) cgold->SetQuality(qualityGold);
528 //signed better cluster
529 if (cgold->GetQuality()>qualityGold+kMaxQualityD) continue;
530 if (2.*qualityGold-cgold->GetQuality()<kMinQuality) continue;
535 for (Int_t icl=0;icl<nfound;icl++){
537 (clusters[index[icl]]->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel()))
539 (clusters[index[icl]]->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel()))
541 (clusters[index[icl]]->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel()))
548 if (inonfake==0) fngoodmatch++;
554 tlab[0]=cgold->GetLabel(0);
555 tlab[1]=cgold->GetLabel(1);
556 tlab[2]=cgold->GetLabel(2);
557 // Double_t tof2=25.*cgold->GetTDC()-350; // in ps
558 Double_t tof2=fGeom->TdcBinWidth()*cgold->GetTDC()+kTofOffset; // in ps
559 Float_t tgamma = TMath::Sqrt(cgold->GetR()*cgold->GetR()+cgold->GetZ()*cgold->GetZ())/0.03;
560 Float_t info[11]={dist3D[igold][0],dist3D[igold][1],dist3D[igold][2],dist3D[igold][3],dist3D[igold][4],mintimedist[igold],
561 -1,tgamma, qualityGold,cgold->GetQuality(),0};
562 // GetLinearDistances(trackTOFin,cgold,&info[6]);
565 // info[7] = mintimedist[index[inonfake]];
568 // Store quantities to be used for TOF Calibration
569 Float_t tToT=cgold->GetToT(); // in ps
570 t->SetTOFsignalToT(tToT);
572 ind[0]=cgold->GetDetInd(0);
573 ind[1]=cgold->GetDetInd(1);
574 ind[2]=cgold->GetDetInd(2);
575 ind[3]=cgold->GetDetInd(3);
576 ind[4]=cgold->GetDetInd(4);
577 Int_t calindex = calib->GetIndex(ind);
578 t->SetTOFCalChannel(calindex);
581 t->SetTOFsignal(tof2);
582 t->SetTOFcluster(cgold->GetIndex());
583 AliTOFtrack *trackTOFout = new AliTOFtrack(*t);
584 trackTOFout->PropagateTo(378.);
585 t->UpdateTrackParams(trackTOFout,AliESDtrack::kTOFout);
586 t->SetIntegratedLength(length[igold]);
587 t->SetIntegratedTimes(times[igold]);
588 t->SetTOFLabel(tlab);
597 for (Int_t ii=0; ii<4; ii++) delete [] trackPos[ii];
598 for (Int_t ii=0;ii<6;ii++) delete [] clind[ii];
605 // //_________________________________________________________________________
606 // Int_t AliTOFtrackerMI::LoadClusters(TTree *dTree) {
607 // //--------------------------------------------------------------------
608 // //This function loads the TOF clusters
609 // //--------------------------------------------------------------------
611 // TBranch *branch=dTree->GetBranch("TOF");
613 // AliError(" can't get the branch with the TOF digits !");
617 // TClonesArray dummy("AliTOFdigit",10000), *digits=&dummy;
618 // branch->SetAddress(&digits);
620 // dTree->GetEvent(0);
621 // Int_t nd=digits->GetEntriesFast();
622 // Info("LoadClusters","number of digits: %d",nd);
624 // for (Int_t i=0; i<nd; i++) {
625 // AliTOFdigit *d=(AliTOFdigit*)digits->UncheckedAt(i);
626 // Int_t dig[5]; Float_t g[3];
627 // dig[0]=d->GetSector();
628 // dig[1]=d->GetPlate();
629 // dig[2]=d->GetStrip();
630 // dig[3]=d->GetPadz();
631 // dig[4]=d->GetPadx();
633 // fGeom->GetPos(dig,g);
636 // h[0]=TMath::Sqrt(g[0]*g[0]+g[1]*g[1]);
637 // h[1]=TMath::ATan2(g[1],g[0]); h[2]=g[2];
638 // h[3]=d->GetTdc(); h[4]=d->GetAdc();
640 // AliTOFcluster *cl=new AliTOFcluster(h,d->GetTracks(),dig,i);
641 // InsertCluster(cl);
646 // //_________________________________________________________________________
647 // void AliTOFtrackerMI::UnloadClusters() {
648 // //--------------------------------------------------------------------
649 // //This function unloads TOF clusters
650 // //--------------------------------------------------------------------
651 // for (Int_t i=0; i<fN; i++) delete fClusters[i];
657 //_________________________________________________________________________
658 Int_t AliTOFtrackerMI::LoadClusters(TTree *cTree) {
659 //--------------------------------------------------------------------
660 //This function loads the TOF clusters
661 //--------------------------------------------------------------------
663 TBranch *branch=cTree->GetBranch("TOF");
665 AliError("can't get the branch with the TOF clusters !");
669 TClonesArray dummy("AliTOFcluster",10000), *clusters=&dummy;
670 branch->SetAddress(&clusters);
673 Int_t nc=clusters->GetEntriesFast();
674 AliInfo(Form("Number of clusters: %d",nc));
676 for (Int_t i=0; i<nc; i++) {
677 AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i);
679 for (Int_t jj=0; jj<5; jj++) dig[jj]=c->GetDetInd(jj);
689 for (Int_t jj=0; jj<3; jj++) indexDig[jj] = c->GetLabel(jj);
691 AliTOFcluster *cl=new AliTOFcluster(h,c->GetTracks(),dig,i);
694 // fClusters[i]=c; fN++;
695 fClusters[i]=new AliTOFcluster(*c); fN++;
697 //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)));
698 //AliInfo(Form("%i %f",i, fClusters[i]->GetZ()));
701 //AliInfo(Form("Number of clusters: %d",fN));
705 //_________________________________________________________________________
706 void AliTOFtrackerMI::UnloadClusters() {
707 //--------------------------------------------------------------------
708 //This function unloads TOF clusters
709 //--------------------------------------------------------------------
710 for (Int_t i=0; i<fN; i++) {
720 //_________________________________________________________________________
721 Int_t AliTOFtrackerMI::InsertCluster(AliTOFcluster *c) {
722 //--------------------------------------------------------------------
723 //This function adds a cluster to the array of clusters sorted in Z
724 //--------------------------------------------------------------------
725 if (fN==kMaxCluster) {
726 AliError("Too many clusters !");
730 if (fN==0) {fClusters[fN++]=c; return 0;}
731 Int_t i=FindClusterIndex(c->GetZ());
732 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTOFcluster*));
733 fClusters[i]=c; fN++;
738 //_________________________________________________________________________
739 Int_t AliTOFtrackerMI::FindClusterIndex(Double_t z) const {
740 //--------------------------------------------------------------------
741 // This function returns the index of the nearest cluster
742 //--------------------------------------------------------------------
744 if (z <= fClusters[0]->GetZ()) return 0;
745 if (z > fClusters[fN-1]->GetZ()) return fN;
746 Int_t b=0, e=fN-1, m=(b+e)/2;
747 for (; b<e; m=(b+e)/2) {
748 if (z > fClusters[m]->GetZ()) b=m+1;
756 Float_t AliTOFtrackerMI::GetLinearDistances(AliTOFtrack * track, AliTOFcluster *cluster, Float_t distances[5])
759 // calclates distance between cluster and track
760 // use linear aproximation
762 const Float_t kRaddeg = 180/3.14159265358979312;
764 // Float_t tiltangle = fGeom->GetAngles(cluster->fdetIndex[1],cluster->fdetIndex[2])/kRaddeg; //tiltangle
766 cind[0]= cluster->GetDetInd(0);
767 cind[1]= cluster->GetDetInd(1);
768 cind[2]= cluster->GetDetInd(2);
769 cind[3]= cluster->GetDetInd(3);
770 cind[4]= cluster->GetDetInd(4);
771 Float_t tiltangle = fGeom->GetAngles(cluster->GetDetInd(1),cluster->GetDetInd(2))/kRaddeg; //tiltangle
773 Float_t cpos[3]; //cluster position
774 Float_t cpos0[3]; //cluster position
775 // fGeom->GetPos(cluster->fdetIndex,cpos);
776 //fGeom->GetPos(cluster->fdetIndex,cpos0);
778 fGeom->GetPos(cind,cpos);
779 fGeom->GetPos(cind,cpos0);
781 Float_t phi = TMath::ATan2(cpos[1],cpos[0]);
782 if(phi<0) phi=2.*TMath::Pi()+phi;
783 // Get the local angle in the sector philoc
784 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
789 track->GetPxPyPz(dir);
790 dir[0]/=track->GetP();
791 dir[1]/=track->GetP();
792 dir[2]/=track->GetP();
796 Float_t sinphi = TMath::Sin(phiangle);
797 Float_t cosphi = TMath::Cos(phiangle);
798 Float_t sinth = TMath::Sin(tiltangle);
799 Float_t costh = TMath::Cos(tiltangle);
802 temp = cpos[0]*cosphi+cpos[1]*sinphi;
803 cpos[1] = -cpos[0]*sinphi+cpos[1]*cosphi;
805 temp = v0[0]*cosphi+v0[1]*sinphi;
806 v0[1] = -v0[0]*sinphi+v0[1]*cosphi;
809 temp = cpos[0]*costh+cpos[2]*sinth;
810 cpos[2] = -cpos[0]*sinth+cpos[2]*costh;
812 temp = v0[0]*costh+v0[2]*sinth;
813 v0[2] = -v0[0]*sinth+v0[2]*costh;
817 //rotate direction vector
819 temp = dir[0]*cosphi+dir[1]*sinphi;
820 dir[1] = -dir[0]*sinphi+dir[1]*cosphi;
823 temp = dir[0]*costh+dir[2]*sinth;
824 dir[2] = -dir[0]*sinth+dir[2]*costh;
828 Float_t k = (cpos[0]-v0[0])/dir[0];
829 v3[0] = v0[0]+k*dir[0];
830 v3[1] = v0[1]+k*dir[1];
831 v3[2] = v0[2]+k*dir[2];
833 distances[0] = v3[0]-cpos[0];
834 distances[1] = v3[1]-cpos[1];
835 distances[2] = v3[2]-cpos[2];
836 distances[3] = TMath::Sqrt( distances[0]*distances[0]+distances[1]*distances[1]+distances[2]*distances[2]); //distance
837 distances[4] = k; //length
840 // Debuging part of the matching
842 if (track->GetLabel()==cluster->GetLabel(0) ||track->GetLabel()==cluster->GetLabel(1) ){
843 TTreeSRedirector& cstream = *fDebugStreamer;
844 Float_t tdc = cluster->GetTDC();
851 "Dist0="<<distances[0]<<
852 "Dist1="<<distances[1]<<
853 "Dist2="<<distances[2]<<
862 void AliTOFtrackerMI::GetLikelihood(Float_t dy, Float_t dz, const Double_t *cov, AliTOFtrack * /*track*/, Float_t & py, Float_t &pz)
865 // get likelihood - track covariance taken
866 // 75 % of gauss with expected sigma
867 // 25 % of gauss with extended sigma
869 Double_t kMaxSigmaY = 0.6; // ~ 90% of TRD tracks
870 Double_t kMaxSigmaZ = 1.2; // ~ 90% of TRD tracks
871 Double_t kMeanSigmaY = 0.25; // mean TRD sigma
872 Double_t kMeanSigmaZ = 0.5; // mean TRD sigma
875 Float_t normwidth, normd, p0,p1;
876 Float_t sigmay = TMath::Max(TMath::Sqrt(cov[0]+kMeanSigmaY*kMeanSigmaY),kMaxSigmaY);
877 Float_t sigmaz = TMath::Max(TMath::Sqrt(cov[2]+kMeanSigmaZ*kMeanSigmaZ),kMaxSigmaZ);
882 // py calculation - 75% admixture of original sigma - 25% tails
884 normwidth = fDy/sigmay;
886 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
887 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
890 normwidth = fDy/(3.*sigmay);
891 normd = dy/(3.*sigmay);
892 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
893 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
896 // pz calculation - 75% admixture of original sigma - 25% tails
898 normwidth = fDz/sigmaz;
900 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
901 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
904 normwidth = fDz/(3.*sigmaz);
905 normd = dz/(3.*sigmaz);
906 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
907 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));