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 "AliTOFcalib.h"
36 #include "AliTOFcluster.h"
37 #include "AliTOFGeometry.h"
38 #include "AliTOFtrackerMI.h"
39 #include "AliTOFtrack.h"
41 extern TGeoManager *gGeoManager;
43 ClassImp(AliTOFtrackerMI)
45 //_____________________________________________________________________________
46 AliTOFtrackerMI::AliTOFtrackerMI(AliTOFGeometry * geom, Double_t parPID[2]):
48 fTOFpid(new AliTOFpidESD(parPID)),
67 //AliTOFtrackerMI main Ctor
70 fDy=AliTOFGeometry::XPad();
71 fDz=AliTOFGeometry::ZPad();
72 fDebugStreamer = new TTreeSRedirector("TOFdebug.root");
73 //Init(); // temporary solution to know about Holes/no Holes
74 fHoles=geom->GetHoles();
76 //_____________________________________________________________________________
77 AliTOFtrackerMI::AliTOFtrackerMI(const AliTOFtrackerMI &t):
99 //AliTOFtrackerMI copy Ctor
103 fNseedsTOF=t.fNseedsTOF;
104 fngoodmatch=t.fngoodmatch;
105 fnbadmatch=t.fnbadmatch;
106 fnunmatch=t.fnunmatch;
111 fTOFHeigth=t.fTOFHeigth;
121 //_________________________________________________________________________________
122 AliTOFtrackerMI& AliTOFtrackerMI::operator=(const AliTOFtrackerMI &t)
124 //AliTOFtrackerMI assignment operator
126 this->fHoles=t.fHoles;
127 this->fNseeds=t.fNseeds;
128 this->fNseedsTOF=t.fNseedsTOF;
129 this->fngoodmatch=t.fngoodmatch;
130 this->fnbadmatch=t.fnbadmatch;
131 this->fnunmatch=t.fnunmatch;
132 this->fnmatch=t.fnmatch;
133 this->fGeom = t.fGeom;
134 this->fTOFpid = t.fTOFpid;
136 this->fTOFHeigth=t.fTOFHeigth;
141 this->fSeeds=t.fSeeds;
142 this->fTracks=t.fTracks;
148 //_____________________________________________________________________________
149 AliTOFtrackerMI::~AliTOFtrackerMI(){
153 if (fDebugStreamer) {
154 //fDebugStreamer->Close();
155 delete fDebugStreamer;
160 //_____________________________________________________________________________
162 void AliTOFtrackerMI::Init() {
164 // temporary solution to know about Holes/no Holes, will be implemented as
165 // an AliTOFGeometry getter
167 AliModule* frame=gAlice->GetModule("FRAME");
170 AliError("Could Not load FRAME! Assume Frame with Holes ");
173 if(frame->IsVersion()==1) {fHoles=false;}
178 //_____________________________________________________________________________
179 Int_t AliTOFtrackerMI::PropagateBack(AliESD* event) {
181 // Gets seeds from ESD event and Match with TOF Clusters
185 //Initialise some counters
194 Int_t ntrk=event->GetNumberOfTracks();
196 fSeeds= new TClonesArray("AliESDtrack");
197 TClonesArray &aESDTrack = *fSeeds;
200 //Load ESD tracks into a local Array of ESD Seeds
202 for (Int_t i=0; i<fNseeds; i++) {
203 AliESDtrack *t=event->GetTrack(i);
204 new(aESDTrack[i]) AliESDtrack(*t);
207 //Prepare ESD tracks candidates for TOF Matching
210 //First Step with Strict Matching Criterion
211 //MatchTracks(kFALSE);
213 //Second Step with Looser Matching Criterion
214 //MatchTracks(kTRUE);
215 MatchTracksMI(kFALSE); // assign track to clusters
216 MatchTracksMI(kTRUE); // assign clusters to esd
218 Info("PropagateBack","Number of matched tracks: %d",fnmatch);
219 Info("PropagateBack","Number of good matched tracks: %d",fngoodmatch);
220 Info("PropagateBack","Number of bad matched tracks: %d",fnbadmatch);
222 //Update the matched ESD tracks
224 for (Int_t i=0; i<ntrk; i++) {
225 AliESDtrack *t=event->GetTrack(i);
226 AliESDtrack *seed =(AliESDtrack*)fSeeds->UncheckedAt(i);
227 if(seed->GetTOFsignal()>0){
228 t->SetTOFsignal(seed->GetTOFsignal());
229 t->SetTOFcluster(seed->GetTOFcluster());
231 seed->GetTOFLabel(tlab);
232 t->SetTOFLabel(tlab);
233 AliTOFtrack *track = new AliTOFtrack(*seed);
236 seed->GetTOFInfo(info);
237 seed->GetIntegratedTimes(times);
238 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
239 t->SetIntegratedLength(seed->GetIntegratedLength());
240 t->SetIntegratedTimes(times);
241 t->SetTOFsignalToT(seed->GetTOFsignalToT());
242 t->SetTOFCalChannel(seed->GetTOFCalChannel());
251 fTOFpid->MakePID(event);
266 //_________________________________________________________________________
267 void AliTOFtrackerMI::CollectESD() {
268 //prepare the set of ESD tracks to be matched to clusters in TOF
270 fTracks= new TClonesArray("AliTOFtrack");
271 TClonesArray &aTOFTrack = *fTracks;
274 for (Int_t i=0; i<fNseeds; i++) {
276 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(i);
277 if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue;
279 // TRD good tracks, already propagated at 371 cm
281 AliTOFtrack *track = new AliTOFtrack(*t); // New
282 Double_t x = track->GetX(); //New
284 if (((t->GetStatus()&AliESDtrack::kTRDout)!=0 ) &&
285 ( x >= fGeom->RinTOF()) ){
286 track->SetSeedIndex(i);
287 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
288 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
294 // Propagate the rest of TPCbp
297 if(track->PropagateToInnerTOF(fHoles)){ // temporary solution
298 // if(track->PropagateToInnerTOF(fGeom->GetHoles())){
299 track->SetSeedIndex(i);
300 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
301 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
310 printf("TRD\tOn\t%d\tOff\t%d\n",c0,c1);
312 // Sort according uncertainties on track position
325 //_________________________________________________________________________
326 void AliTOFtrackerMI::MatchTracks( Bool_t /*mLastStep*/){
331 //_________________________________________________________________________
332 void AliTOFtrackerMI::MatchTracksMI(Bool_t mLastStep){
334 //Match ESD tracks to clusters in TOF
335 const Float_t kTofOffset = 26; // time offset
336 const Float_t kMinQuality = -6.; // minimal quality
337 const Float_t kMaxQualityD = 1.; // max delta quality if cluster used
338 const Float_t kForbiddenR = 0.1; // minimal PID according TPC
340 static const Double_t kMasses[]={
341 0.000511, 0.105658, 0.139570, 0.493677, 0.938272, 1.875613
344 Int_t nSteps=(Int_t)(fTOFHeigth/0.1);
346 AliTOFcalib *calib = new AliTOFcalib(fGeom);
348 //PH Arrays (moved outside of the loop)
349 Float_t * trackPos[4];
350 for (Int_t ii=0; ii<4; ii++) trackPos[ii] = new Float_t[nSteps];
352 for (Int_t ii=0;ii<6;ii++) clind[ii] = new Int_t[fN];
357 Float_t dist3D[1000][6];
358 Double_t times[1000][6];
359 Float_t mintimedist[1000];
360 Float_t likelihood[1000];
361 Float_t length[1000];
362 AliTOFcluster *clusters[1000];
366 for (Int_t i=0; i<fNseedsTOF; i++) {
368 AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(i);
369 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(track->GetSeedIndex());
370 Bool_t hasTime = ( (t->GetStatus()& AliESDtrack::kTIME)>0) ? kTRUE:kFALSE; // did we integrate time
371 Float_t trdquality = t->GetTRDQuality();
375 t->GetTPCpid(tpcpid);
377 for (Int_t ipid=0;ipid<5;ipid++){
378 sumpid+=tpcpid[ipid];
380 for (Int_t ipid=0;ipid<5;ipid++){
381 if (sumpid>0) tpcpid[ipid]/=sumpid;
387 if (trdquality<0) continue; // no chance
389 AliTOFtrack *trackTOFin =new AliTOFtrack(*track);
391 //propagat track to the middle of TOF
393 Float_t xs = 378.2; // should be defined in the TOF geometry
394 Double_t ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
396 Double_t ysect=trackTOFin->GetYat(xs,skip);
399 ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
400 ysect=trackTOFin->GetYat(xs,skip);
403 if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) {
406 } else if (ysect <-ymax) {
407 if (!trackTOFin->Rotate(-AliTOFGeometry::GetAlpha())) {
411 if(!trackTOFin->PropagateTo(xs)) {
415 // Determine a window around the track
418 trackTOFin->GetExternalParameters(x,par);
420 trackTOFin->GetExternalCovariance(cov);
421 Float_t scalefact=3.;
424 ((5*TMath::Sqrt(cov[0]) + 3.*fDy +10.*TMath::Abs(par[2]))/fR);
427 (5*TMath::Sqrt(cov[2]) + 3.*fDz +10.*TMath::Abs(par[3]));
429 Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha();
430 if (phi<-TMath::Pi())phi+=2*TMath::Pi();
431 if (phi>=TMath::Pi())phi-=2*TMath::Pi();
436 // find the clusters in the window of the track
438 for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) {
439 AliTOFcluster *c=fClusters[k];
440 if (c->GetZ() > z+dz) break;
441 // if (c->IsUsed()) continue;
443 Double_t dph=TMath::Abs(c->GetPhi()-phi);
444 if (dph>TMath::Pi()) dph-=2.*TMath::Pi();
445 if (TMath::Abs(dph)>dphi) continue;
447 clind[0][nc] = c->GetDetInd(0);
448 clind[1][nc] = c->GetDetInd(1);
449 clind[2][nc] = c->GetDetInd(2);
450 clind[3][nc] = c->GetDetInd(3);
451 clind[4][nc] = c->GetDetInd(4);
457 // select close clusters
459 Double_t mom=t->GetP();
460 // Bool_t dump = kTRUE;
461 for (Int_t icl=0; icl<nc; icl++){
462 Float_t distances[5];
463 if (nfound>=1000) break;
464 index[nfound]=clind[5][icl];
465 AliTOFcluster *cluster = fClusters[clind[5][icl]];
466 GetLinearDistances(trackTOFin,cluster, distances);
467 dist3D[nfound][0] = distances[4];
468 dist3D[nfound][1] = distances[1];
469 dist3D[nfound][2] = distances[2];
471 if (TMath::Abs(dist3D[nfound][1])>20 || TMath::Abs(dist3D[nfound][2])>20) continue;
473 GetLikelihood(distances[1],distances[2],cov,trackTOFin, dist3D[nfound][3], dist3D[nfound][4]);
476 if (dist3D[nfound][3]*dist3D[nfound][4]<0.00000000000001) continue; // log likelihood
477 if (TMath::Log(dist3D[nfound][3]*dist3D[nfound][4])<-9) continue; // log likelihood
479 clusters[nfound] = cluster;
481 //length and TOF updates
482 trackTOFin->GetIntegratedTimes(times[nfound]);
483 length[nfound] = trackTOFin->GetIntegratedLength();
484 length[nfound]+=distances[4];
485 mintimedist[nfound]=1000;
486 Double_t tof2=AliTOFGeometry::TdcBinWidth()*cluster->GetTDC()+kTofOffset; // in ps
487 // Float_t tgamma = TMath::Sqrt(cluster->GetR()*cluster->GetR()+cluster->GetZ()*cluster->GetZ())/0.03; //time for "primary" gamma
488 //if (trackTOFin->GetPt()<0.7 && TMath::Abs(tgamma-tof2)<350) continue; // gamma conversion candidate - TEMPORARY
489 for(Int_t j=0;j<=5;j++){
490 Double_t mass=kMasses[j];
491 times[nfound][j]+=distances[4]/3e-2*TMath::Sqrt(mom*mom+mass*mass)/mom; // add time distance
492 if ( TMath::Abs(times[nfound][j]-tof2)<mintimedist[nfound] && tpcpid[j]>kForbiddenR){
493 mintimedist[nfound]=TMath::Abs(times[nfound][j]-tof2);
497 Float_t liketime = TMath::Exp(-mintimedist[nfound]/90.)+0.25*TMath::Exp(-mintimedist[nfound]/180.);
498 if (!hasTime) liketime=0.2;
499 likelihood[nfound] = TMath::Log(dist3D[nfound][3]*dist3D[nfound][4]*liketime);
501 if (TMath::Log(dist3D[nfound][3]*dist3D[nfound][4])<-1){
502 if (likelihood[nfound]<-9.) continue;
513 //choose the best cluster
515 Float_t quality[1000];
518 AliTOFcluster * cgold=0;
520 for (Int_t icl=0;icl<nfound;icl++){
521 quality[icl] = dist3D[icl][3]*dist3D[icl][4];
523 TMath::Sort(nfound,quality,index,kTRUE);
525 cgold = clusters[igold];
526 if (nfound>1 &&likelihood[index[1]]>likelihood[index[0]]){
527 if ( quality[index[0]]<quality[index[1]]+0.5){
529 cgold = clusters[igold];
534 Float_t qualityGold = TMath::Log(0.0000001+(quality[igold]*(0.1+TMath::Exp(-mintimedist[igold]/80.))*(0.2+trdquality)));
536 if (cgold->GetQuality()<qualityGold) cgold->SetQuality(qualityGold);
541 //signed better cluster
542 if (cgold->GetQuality()>qualityGold+kMaxQualityD) continue;
543 if (2.*qualityGold-cgold->GetQuality()<kMinQuality) continue;
548 for (Int_t icl=0;icl<nfound;icl++){
550 (clusters[index[icl]]->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel()))
552 (clusters[index[icl]]->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel()))
554 (clusters[index[icl]]->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel()))
561 if (inonfake==0) fngoodmatch++;
567 tlab[0]=cgold->GetLabel(0);
568 tlab[1]=cgold->GetLabel(1);
569 tlab[2]=cgold->GetLabel(2);
570 // Double_t tof2=25.*cgold->GetTDC()-350; // in ps
571 Double_t tof2=AliTOFGeometry::TdcBinWidth()*cgold->GetTDC()+kTofOffset; // in ps
572 Float_t tgamma = TMath::Sqrt(cgold->GetR()*cgold->GetR()+cgold->GetZ()*cgold->GetZ())/0.03;
573 Float_t info[11]={dist3D[igold][0],dist3D[igold][1],dist3D[igold][2],dist3D[igold][3],dist3D[igold][4],mintimedist[igold],
574 -1,tgamma, qualityGold,cgold->GetQuality(),0};
575 // GetLinearDistances(trackTOFin,cgold,&info[6]);
578 // info[7] = mintimedist[index[inonfake]];
581 // Store quantities to be used for TOF Calibration
582 Float_t tToT=cgold->GetToT(); // in ps
583 t->SetTOFsignalToT(tToT);
585 ind[0]=cgold->GetDetInd(0);
586 ind[1]=cgold->GetDetInd(1);
587 ind[2]=cgold->GetDetInd(2);
588 ind[3]=cgold->GetDetInd(3);
589 ind[4]=cgold->GetDetInd(4);
590 Int_t calindex = calib->GetIndex(ind);
591 t->SetTOFCalChannel(calindex);
594 t->SetTOFsignal(tof2);
595 t->SetTOFcluster(cgold->GetIndex());
596 AliTOFtrack *trackTOFout = new AliTOFtrack(*t);
597 trackTOFout->PropagateTo(378.);
598 t->UpdateTrackParams(trackTOFout,AliESDtrack::kTOFout);
599 t->SetIntegratedLength(length[igold]);
600 t->SetIntegratedTimes(times[igold]);
601 t->SetTOFLabel(tlab);
610 for (Int_t ii=0; ii<4; ii++) delete [] trackPos[ii];
611 for (Int_t ii=0;ii<6;ii++) delete [] clind[ii];
618 // //_________________________________________________________________________
619 // Int_t AliTOFtrackerMI::LoadClusters(TTree *dTree) {
620 // //--------------------------------------------------------------------
621 // //This function loads the TOF clusters
622 // //--------------------------------------------------------------------
624 // TBranch *branch=dTree->GetBranch("TOF");
626 // AliError(" can't get the branch with the TOF digits !");
630 // TClonesArray dummy("AliTOFdigit",10000), *digits=&dummy;
631 // branch->SetAddress(&digits);
633 // dTree->GetEvent(0);
634 // Int_t nd=digits->GetEntriesFast();
635 // Info("LoadClusters","number of digits: %d",nd);
637 // for (Int_t i=0; i<nd; i++) {
638 // AliTOFdigit *d=(AliTOFdigit*)digits->UncheckedAt(i);
639 // Int_t dig[5]; Float_t g[3];
640 // dig[0]=d->GetSector();
641 // dig[1]=d->GetPlate();
642 // dig[2]=d->GetStrip();
643 // dig[3]=d->GetPadz();
644 // dig[4]=d->GetPadx();
646 // fGeom->GetPos(dig,g);
649 // h[0]=TMath::Sqrt(g[0]*g[0]+g[1]*g[1]);
650 // h[1]=TMath::ATan2(g[1],g[0]); h[2]=g[2];
651 // h[3]=d->GetTdc(); h[4]=d->GetAdc();
653 // AliTOFcluster *cl=new AliTOFcluster(h,d->GetTracks(),dig,i);
654 // InsertCluster(cl);
659 // //_________________________________________________________________________
660 // void AliTOFtrackerMI::UnloadClusters() {
661 // //--------------------------------------------------------------------
662 // //This function unloads TOF clusters
663 // //--------------------------------------------------------------------
664 // for (Int_t i=0; i<fN; i++) delete fClusters[i];
670 //_________________________________________________________________________
671 Int_t AliTOFtrackerMI::LoadClusters(TTree *cTree) {
672 //--------------------------------------------------------------------
673 //This function loads the TOF clusters
674 //--------------------------------------------------------------------
676 TBranch *branch=cTree->GetBranch("TOF");
678 AliError("can't get the branch with the TOF clusters !");
682 TClonesArray dummy("AliTOFcluster",10000), *clusters=&dummy;
683 branch->SetAddress(&clusters);
686 Int_t nc=clusters->GetEntriesFast();
687 AliInfo(Form("Number of clusters: %d",nc));
689 for (Int_t i=0; i<nc; i++) {
690 AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i);
692 for (Int_t jj=0; jj<5; jj++) dig[jj]=c->GetDetInd(jj);
702 for (Int_t jj=0; jj<3; jj++) indexDig[jj] = c->GetLabel(jj);
704 AliTOFcluster *cl=new AliTOFcluster(h,c->GetTracks(),dig,i);
707 // fClusters[i]=c; fN++;
708 fClusters[i]=new AliTOFcluster(*c); fN++;
710 //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)));
711 //AliInfo(Form("%i %f",i, fClusters[i]->GetZ()));
714 //AliInfo(Form("Number of clusters: %d",fN));
718 //_________________________________________________________________________
719 void AliTOFtrackerMI::UnloadClusters() {
720 //--------------------------------------------------------------------
721 //This function unloads TOF clusters
722 //--------------------------------------------------------------------
723 for (Int_t i=0; i<fN; i++) {
733 //_________________________________________________________________________
734 Int_t AliTOFtrackerMI::InsertCluster(AliTOFcluster *c) {
735 //--------------------------------------------------------------------
736 //This function adds a cluster to the array of clusters sorted in Z
737 //--------------------------------------------------------------------
738 if (fN==kMaxCluster) {
739 AliError("Too many clusters !");
743 if (fN==0) {fClusters[fN++]=c; return 0;}
744 Int_t i=FindClusterIndex(c->GetZ());
745 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTOFcluster*));
746 fClusters[i]=c; fN++;
751 //_________________________________________________________________________
752 Int_t AliTOFtrackerMI::FindClusterIndex(Double_t z) const {
753 //--------------------------------------------------------------------
754 // This function returns the index of the nearest cluster
755 //--------------------------------------------------------------------
757 if (z <= fClusters[0]->GetZ()) return 0;
758 if (z > fClusters[fN-1]->GetZ()) return fN;
759 Int_t b=0, e=fN-1, m=(b+e)/2;
760 for (; b<e; m=(b+e)/2) {
761 if (z > fClusters[m]->GetZ()) b=m+1;
769 Float_t AliTOFtrackerMI::GetLinearDistances(AliTOFtrack * track, AliTOFcluster *cluster, Float_t distances[5])
772 // calclates distance between cluster and track
773 // use linear aproximation
775 const Float_t kRaddeg = 180/3.14159265358979312;
777 // Float_t tiltangle = fGeom->GetAngles(cluster->fdetIndex[1],cluster->fdetIndex[2])/kRaddeg; //tiltangle
779 cind[0]= cluster->GetDetInd(0);
780 cind[1]= cluster->GetDetInd(1);
781 cind[2]= cluster->GetDetInd(2);
782 cind[3]= cluster->GetDetInd(3);
783 cind[4]= cluster->GetDetInd(4);
784 Float_t tiltangle = fGeom->GetAngles(cluster->GetDetInd(1),cluster->GetDetInd(2))/kRaddeg; //tiltangle
786 Float_t cpos[3]; //cluster position
787 Float_t cpos0[3]; //cluster position
788 // fGeom->GetPos(cluster->fdetIndex,cpos);
789 //fGeom->GetPos(cluster->fdetIndex,cpos0);
791 fGeom->GetPos(cind,cpos);
792 fGeom->GetPos(cind,cpos0);
794 Float_t phi = TMath::ATan2(cpos[1],cpos[0]);
795 if(phi<0) phi=2.*TMath::Pi()+phi;
796 // Get the local angle in the sector philoc
797 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
802 track->GetPxPyPz(dir);
803 dir[0]/=track->GetP();
804 dir[1]/=track->GetP();
805 dir[2]/=track->GetP();
809 Float_t sinphi = TMath::Sin(phiangle);
810 Float_t cosphi = TMath::Cos(phiangle);
811 Float_t sinth = TMath::Sin(tiltangle);
812 Float_t costh = TMath::Cos(tiltangle);
815 temp = cpos[0]*cosphi+cpos[1]*sinphi;
816 cpos[1] = -cpos[0]*sinphi+cpos[1]*cosphi;
818 temp = v0[0]*cosphi+v0[1]*sinphi;
819 v0[1] = -v0[0]*sinphi+v0[1]*cosphi;
822 temp = cpos[0]*costh+cpos[2]*sinth;
823 cpos[2] = -cpos[0]*sinth+cpos[2]*costh;
825 temp = v0[0]*costh+v0[2]*sinth;
826 v0[2] = -v0[0]*sinth+v0[2]*costh;
830 //rotate direction vector
832 temp = dir[0]*cosphi+dir[1]*sinphi;
833 dir[1] = -dir[0]*sinphi+dir[1]*cosphi;
836 temp = dir[0]*costh+dir[2]*sinth;
837 dir[2] = -dir[0]*sinth+dir[2]*costh;
841 Float_t k = (cpos[0]-v0[0])/dir[0];
842 v3[0] = v0[0]+k*dir[0];
843 v3[1] = v0[1]+k*dir[1];
844 v3[2] = v0[2]+k*dir[2];
846 distances[0] = v3[0]-cpos[0];
847 distances[1] = v3[1]-cpos[1];
848 distances[2] = v3[2]-cpos[2];
849 distances[3] = TMath::Sqrt( distances[0]*distances[0]+distances[1]*distances[1]+distances[2]*distances[2]); //distance
850 distances[4] = k; //length
853 // Debuging part of the matching
855 if (track->GetLabel()==cluster->GetLabel(0) ||track->GetLabel()==cluster->GetLabel(1) ){
856 TTreeSRedirector& cstream = *fDebugStreamer;
857 Float_t tdc = cluster->GetTDC();
864 "Dist0="<<distances[0]<<
865 "Dist1="<<distances[1]<<
866 "Dist2="<<distances[2]<<
875 void AliTOFtrackerMI::GetLikelihood(Float_t dy, Float_t dz, const Double_t *cov, AliTOFtrack * /*track*/, Float_t & py, Float_t &pz)
878 // get likelihood - track covariance taken
879 // 75 % of gauss with expected sigma
880 // 25 % of gauss with extended sigma
882 Double_t kMaxSigmaY = 0.6; // ~ 90% of TRD tracks
883 Double_t kMaxSigmaZ = 1.2; // ~ 90% of TRD tracks
884 Double_t kMeanSigmaY = 0.25; // mean TRD sigma
885 Double_t kMeanSigmaZ = 0.5; // mean TRD sigma
888 Float_t normwidth, normd, p0,p1;
889 Float_t sigmay = TMath::Max(TMath::Sqrt(cov[0]+kMeanSigmaY*kMeanSigmaY),kMaxSigmaY);
890 Float_t sigmaz = TMath::Max(TMath::Sqrt(cov[2]+kMeanSigmaZ*kMeanSigmaZ),kMaxSigmaZ);
895 // py calculation - 75% admixture of original sigma - 25% tails
897 normwidth = fDy/sigmay;
899 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
900 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
903 normwidth = fDy/(3.*sigmay);
904 normd = dy/(3.*sigmay);
905 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
906 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
909 // pz calculation - 75% admixture of original sigma - 25% tails
911 normwidth = fDz/sigmaz;
913 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
914 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
917 normwidth = fDz/(3.*sigmaz);
918 normd = dz/(3.*sigmaz);
919 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
920 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));