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"
32 #include "AliESDEvent.h"
33 #include "AliESDtrack.h"
35 #include "AliTOFRecoParam.h"
36 #include "AliTOFcalib.h"
37 #include "AliTOFcluster.h"
38 #include "AliTOFGeometry.h"
39 #include "AliTOFtrackerMI.h"
40 #include "AliTOFtrack.h"
41 #include "AliTOFpidESD.h"
45 extern TGeoManager *gGeoManager;
47 ClassImp(AliTOFtrackerMI)
49 //_____________________________________________________________________________
50 AliTOFtrackerMI::AliTOFtrackerMI():
71 //AliTOFtrackerMI main Ctor
73 fRecoParam=new AliTOFRecoParam();
74 fGeom=new AliTOFGeometry();
76 parPID[0]=fRecoParam->GetTimeResolution();
77 parPID[1]=fRecoParam->GetTimeNSigma();
78 fPid=new AliTOFpidESD(parPID);
79 fDy=AliTOFGeometry::XPad();
80 fDz=AliTOFGeometry::ZPad();
81 fDebugStreamer = new TTreeSRedirector("TOFdebug.root");
83 //_____________________________________________________________________________
84 AliTOFtrackerMI::AliTOFtrackerMI(const AliTOFtrackerMI &t):
106 //AliTOFtrackerMI copy Ctor
109 fNseedsTOF=t.fNseedsTOF;
110 fngoodmatch=t.fngoodmatch;
111 fnbadmatch=t.fnbadmatch;
112 fnunmatch=t.fnunmatch;
114 fRecoParam = t.fRecoParam;
118 fTOFHeigth=t.fTOFHeigth;
128 //_________________________________________________________________________________
129 AliTOFtrackerMI& AliTOFtrackerMI::operator=(const AliTOFtrackerMI &t)
131 //AliTOFtrackerMI assignment operator
133 this->fNseeds=t.fNseeds;
134 this->fNseedsTOF=t.fNseedsTOF;
135 this->fngoodmatch=t.fngoodmatch;
136 this->fnbadmatch=t.fnbadmatch;
137 this->fnunmatch=t.fnunmatch;
138 this->fnmatch=t.fnmatch;
139 this->fRecoParam = t.fRecoParam;
140 this->fGeom = t.fGeom;
143 this->fTOFHeigth=t.fTOFHeigth;
148 this->fSeeds=t.fSeeds;
149 this->fTracks=t.fTracks;
155 //_____________________________________________________________________________
156 AliTOFtrackerMI::~AliTOFtrackerMI(){
160 if (fDebugStreamer) {
161 //fDebugStreamer->Close();
162 delete fDebugStreamer;
169 //_____________________________________________________________________________
170 Int_t AliTOFtrackerMI::PropagateBack(AliESDEvent* event) {
172 // Gets seeds from ESD event and Match with TOF Clusters
176 //Initialise some counters
185 Int_t ntrk=event->GetNumberOfTracks();
187 fSeeds= new TClonesArray("AliESDtrack");
188 TClonesArray &aESDTrack = *fSeeds;
191 //Load ESD tracks into a local Array of ESD Seeds
193 for (Int_t i=0; i<fNseeds; i++) {
194 AliESDtrack *t=event->GetTrack(i);
195 new(aESDTrack[i]) AliESDtrack(*t);
198 //Prepare ESD tracks candidates for TOF Matching
201 //First Step with Strict Matching Criterion
202 //MatchTracks(kFALSE);
204 //Second Step with Looser Matching Criterion
205 //MatchTracks(kTRUE);
206 MatchTracksMI(kFALSE); // assign track to clusters
207 MatchTracksMI(kTRUE); // assign clusters to esd
209 Info("PropagateBack","Number of matched tracks: %d",fnmatch);
210 Info("PropagateBack","Number of good matched tracks: %d",fngoodmatch);
211 Info("PropagateBack","Number of bad matched tracks: %d",fnbadmatch);
213 //Update the matched ESD tracks
215 for (Int_t i=0; i<ntrk; i++) {
216 AliESDtrack *t=event->GetTrack(i);
217 AliESDtrack *seed =(AliESDtrack*)fSeeds->UncheckedAt(i);
218 if(seed->GetTOFsignal()>0){
219 t->SetTOFsignal(seed->GetTOFsignal());
220 t->SetTOFcluster(seed->GetTOFcluster());
222 seed->GetTOFLabel(tlab);
223 t->SetTOFLabel(tlab);
224 AliTOFtrack *track = new AliTOFtrack(*seed);
227 seed->GetTOFInfo(info);
228 seed->GetIntegratedTimes(times);
229 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
230 t->SetIntegratedLength(seed->GetIntegratedLength());
231 t->SetIntegratedTimes(times);
232 t->SetTOFsignalToT(seed->GetTOFsignalToT());
233 t->SetTOFCalChannel(seed->GetTOFCalChannel());
242 fPid->MakePID(event);
257 //_________________________________________________________________________
258 void AliTOFtrackerMI::CollectESD() {
259 //prepare the set of ESD tracks to be matched to clusters in TOF
261 fTracks= new TClonesArray("AliTOFtrack");
262 TClonesArray &aTOFTrack = *fTracks;
265 for (Int_t i=0; i<fNseeds; i++) {
267 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(i);
268 if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue;
270 // TRD good tracks, already propagated at 371 cm
272 AliTOFtrack *track = new AliTOFtrack(*t); // New
273 Double_t x = track->GetX(); //New
275 if (((t->GetStatus()&AliESDtrack::kTRDout)!=0 ) &&
276 ( x >= AliTOFGeometry::RinTOF()) ){
277 track->SetSeedIndex(i);
278 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
279 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
285 // Propagate the rest of TPCbp
288 if(track->PropagateToInnerTOF()){ // temporary solution
289 track->SetSeedIndex(i);
290 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
291 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
300 printf("TRD\tOn\t%d\tOff\t%d\n",c0,c1);
302 // Sort according uncertainties on track position
315 //_________________________________________________________________________
316 void AliTOFtrackerMI::MatchTracks( Bool_t /*mLastStep*/){
321 //_________________________________________________________________________
322 void AliTOFtrackerMI::MatchTracksMI(Bool_t mLastStep){
324 //Match ESD tracks to clusters in TOF
325 const Float_t kTofOffset = 26; // time offset
326 const Float_t kMinQuality = -6.; // minimal quality
327 const Float_t kMaxQualityD = 1.; // max delta quality if cluster used
328 const Float_t kForbiddenR = 0.1; // minimal PID according TPC
330 static const Double_t kMasses[]={
331 0.000511, 0.105658, 0.139570, 0.493677, 0.938272, 1.875613
334 Int_t nSteps=(Int_t)(fTOFHeigth/0.1);
336 AliTOFcalib *calib = new AliTOFcalib();
338 //PH Arrays (moved outside of the loop)
339 Float_t * trackPos[4];
340 for (Int_t ii=0; ii<4; ii++) trackPos[ii] = new Float_t[nSteps];
342 for (Int_t ii=0;ii<6;ii++) clind[ii] = new Int_t[fN];
347 Float_t dist3D[1000][6];
348 Double_t times[1000][6];
349 Float_t mintimedist[1000];
350 Float_t likelihood[1000];
351 Float_t length[1000];
352 AliTOFcluster *clusters[1000];
356 for (Int_t i=0; i<fNseedsTOF; i++) {
358 AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(i);
359 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(track->GetSeedIndex());
360 Bool_t hasTime = ( (t->GetStatus()& AliESDtrack::kTIME)>0) ? kTRUE:kFALSE; // did we integrate time
361 Float_t trdquality = t->GetTRDQuality();
365 t->GetTPCpid(tpcpid);
367 for (Int_t ipid=0;ipid<5;ipid++){
368 sumpid+=tpcpid[ipid];
370 for (Int_t ipid=0;ipid<5;ipid++){
371 if (sumpid>0) tpcpid[ipid]/=sumpid;
377 if (trdquality<0) continue; // no chance
379 AliTOFtrack *trackTOFin =new AliTOFtrack(*track);
381 //propagat track to the middle of TOF
383 Float_t xs = 378.2; // should be defined in the TOF geometry
384 Double_t ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
386 Double_t ysect=trackTOFin->GetYat(xs,skip);
389 ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
390 ysect=trackTOFin->GetYat(xs,skip);
393 if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) {
396 } else if (ysect <-ymax) {
397 if (!trackTOFin->Rotate(-AliTOFGeometry::GetAlpha())) {
401 if(!trackTOFin->PropagateTo(xs)) {
405 // Determine a window around the track
408 trackTOFin->GetExternalParameters(x,par);
410 trackTOFin->GetExternalCovariance(cov);
411 Float_t scalefact=3.;
414 ((5*TMath::Sqrt(cov[0]) + 3.*fDy +10.*TMath::Abs(par[2]))/fR);
417 (5*TMath::Sqrt(cov[2]) + 3.*fDz +10.*TMath::Abs(par[3]));
419 Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha();
420 if (phi<-TMath::Pi())phi+=2*TMath::Pi();
421 if (phi>=TMath::Pi())phi-=2*TMath::Pi();
426 // find the clusters in the window of the track
428 for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) {
429 AliTOFcluster *c=fClusters[k];
430 if (c->GetZ() > z+dz) break;
431 // if (c->IsUsed()) continue;
433 Double_t dph=TMath::Abs(c->GetPhi()-phi);
434 if (dph>TMath::Pi()) dph-=2.*TMath::Pi();
435 if (TMath::Abs(dph)>dphi) continue;
437 clind[0][nc] = c->GetDetInd(0);
438 clind[1][nc] = c->GetDetInd(1);
439 clind[2][nc] = c->GetDetInd(2);
440 clind[3][nc] = c->GetDetInd(3);
441 clind[4][nc] = c->GetDetInd(4);
447 // select close clusters
449 Double_t mom=t->GetP();
450 // Bool_t dump = kTRUE;
451 for (Int_t icl=0; icl<nc; icl++){
452 Float_t distances[5];
453 if (nfound>=1000) break;
454 index[nfound]=clind[5][icl];
455 AliTOFcluster *cluster = fClusters[clind[5][icl]];
456 GetLinearDistances(trackTOFin,cluster, distances);
457 dist3D[nfound][0] = distances[4];
458 dist3D[nfound][1] = distances[1];
459 dist3D[nfound][2] = distances[2];
461 if (TMath::Abs(dist3D[nfound][1])>20 || TMath::Abs(dist3D[nfound][2])>20) continue;
463 GetLikelihood(distances[1],distances[2],cov,trackTOFin, dist3D[nfound][3], dist3D[nfound][4]);
466 if (dist3D[nfound][3]*dist3D[nfound][4]<0.00000000000001) continue; // log likelihood
467 if (TMath::Log(dist3D[nfound][3]*dist3D[nfound][4])<-9) continue; // log likelihood
469 clusters[nfound] = cluster;
471 //length and TOF updates
472 trackTOFin->GetIntegratedTimes(times[nfound]);
473 length[nfound] = trackTOFin->GetIntegratedLength();
474 length[nfound]+=distances[4];
475 mintimedist[nfound]=1000;
476 Double_t tof2=AliTOFGeometry::TdcBinWidth()*cluster->GetTDC()+kTofOffset; // in ps
477 // Float_t tgamma = TMath::Sqrt(cluster->GetR()*cluster->GetR()+cluster->GetZ()*cluster->GetZ())/0.03; //time for "primary" gamma
478 //if (trackTOFin->GetPt()<0.7 && TMath::Abs(tgamma-tof2)<350) continue; // gamma conversion candidate - TEMPORARY
479 for(Int_t j=0;j<=5;j++){
480 Double_t mass=kMasses[j];
481 times[nfound][j]+=distances[4]/3e-2*TMath::Sqrt(mom*mom+mass*mass)/mom; // add time distance
482 if ( TMath::Abs(times[nfound][j]-tof2)<mintimedist[nfound] && tpcpid[j]>kForbiddenR){
483 mintimedist[nfound]=TMath::Abs(times[nfound][j]-tof2);
487 Float_t liketime = TMath::Exp(-mintimedist[nfound]/90.)+0.25*TMath::Exp(-mintimedist[nfound]/180.);
488 if (!hasTime) liketime=0.2;
489 likelihood[nfound] = TMath::Log(dist3D[nfound][3]*dist3D[nfound][4]*liketime);
491 if (TMath::Log(dist3D[nfound][3]*dist3D[nfound][4])<-1){
492 if (likelihood[nfound]<-9.) continue;
503 //choose the best cluster
505 Float_t quality[1000];
508 AliTOFcluster * cgold=0;
510 for (Int_t icl=0;icl<nfound;icl++){
511 quality[icl] = dist3D[icl][3]*dist3D[icl][4];
513 TMath::Sort(nfound,quality,index,kTRUE);
515 cgold = clusters[igold];
516 if (nfound>1 &&likelihood[index[1]]>likelihood[index[0]]){
517 if ( quality[index[0]]<quality[index[1]]+0.5){
519 cgold = clusters[igold];
524 Float_t qualityGold = TMath::Log(0.0000001+(quality[igold]*(0.1+TMath::Exp(-mintimedist[igold]/80.))*(0.2+trdquality)));
526 if (cgold->GetQuality()<qualityGold) cgold->SetQuality(qualityGold);
531 //signed better cluster
532 if (cgold->GetQuality()>qualityGold+kMaxQualityD) continue;
533 if (2.*qualityGold-cgold->GetQuality()<kMinQuality) continue;
538 for (Int_t icl=0;icl<nfound;icl++){
540 (clusters[index[icl]]->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel()))
542 (clusters[index[icl]]->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel()))
544 (clusters[index[icl]]->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel()))
551 if (inonfake==0) fngoodmatch++;
557 tlab[0]=cgold->GetLabel(0);
558 tlab[1]=cgold->GetLabel(1);
559 tlab[2]=cgold->GetLabel(2);
560 // Double_t tof2=25.*cgold->GetTDC()-350; // in ps
561 Double_t tof2=AliTOFGeometry::TdcBinWidth()*cgold->GetTDC()+kTofOffset; // in ps
562 Float_t tgamma = TMath::Sqrt(cgold->GetR()*cgold->GetR()+cgold->GetZ()*cgold->GetZ())/0.03;
563 Float_t info[11]={dist3D[igold][0],dist3D[igold][1],dist3D[igold][2],dist3D[igold][3],dist3D[igold][4],mintimedist[igold],
564 -1,tgamma, qualityGold,cgold->GetQuality(),0};
565 // GetLinearDistances(trackTOFin,cgold,&info[6]);
568 // info[7] = mintimedist[index[inonfake]];
571 // Store quantities to be used for TOF Calibration
572 Float_t tToT=cgold->GetToT(); // in ps
573 t->SetTOFsignalToT(tToT);
575 ind[0]=cgold->GetDetInd(0);
576 ind[1]=cgold->GetDetInd(1);
577 ind[2]=cgold->GetDetInd(2);
578 ind[3]=cgold->GetDetInd(3);
579 ind[4]=cgold->GetDetInd(4);
580 Int_t calindex = AliTOFGeometry::GetIndex(ind);
581 t->SetTOFCalChannel(calindex);
584 t->SetTOFsignal(tof2);
585 t->SetTOFcluster(cgold->GetIndex());
586 AliTOFtrack *trackTOFout = new AliTOFtrack(*t);
587 trackTOFout->PropagateTo(378.);
588 t->UpdateTrackParams(trackTOFout,AliESDtrack::kTOFout);
589 t->SetIntegratedLength(length[igold]);
590 t->SetIntegratedTimes(times[igold]);
591 t->SetTOFLabel(tlab);
600 for (Int_t ii=0; ii<4; ii++) delete [] trackPos[ii];
601 for (Int_t ii=0;ii<6;ii++) delete [] clind[ii];
608 // //_________________________________________________________________________
609 // Int_t AliTOFtrackerMI::LoadClusters(TTree *dTree) {
610 // //--------------------------------------------------------------------
611 // //This function loads the TOF clusters
612 // //--------------------------------------------------------------------
614 // TBranch *branch=dTree->GetBranch("TOF");
616 // AliError(" can't get the branch with the TOF digits !");
620 // TClonesArray dummy("AliTOFdigit",10000), *digits=&dummy;
621 // branch->SetAddress(&digits);
623 // dTree->GetEvent(0);
624 // Int_t nd=digits->GetEntriesFast();
625 // Info("LoadClusters","number of digits: %d",nd);
627 // for (Int_t i=0; i<nd; i++) {
628 // AliTOFdigit *d=(AliTOFdigit*)digits->UncheckedAt(i);
629 // Int_t dig[5]; Float_t g[3];
630 // dig[0]=d->GetSector();
631 // dig[1]=d->GetPlate();
632 // dig[2]=d->GetStrip();
633 // dig[3]=d->GetPadz();
634 // dig[4]=d->GetPadx();
636 // fGeom->GetPos(dig,g);
639 // h[0]=TMath::Sqrt(g[0]*g[0]+g[1]*g[1]);
640 // h[1]=TMath::ATan2(g[1],g[0]); h[2]=g[2];
641 // h[3]=d->GetTdc(); h[4]=d->GetAdc();
643 // AliTOFcluster *cl=new AliTOFcluster(h,d->GetTracks(),dig,i);
644 // InsertCluster(cl);
649 // //_________________________________________________________________________
650 // void AliTOFtrackerMI::UnloadClusters() {
651 // //--------------------------------------------------------------------
652 // //This function unloads TOF clusters
653 // //--------------------------------------------------------------------
654 // for (Int_t i=0; i<fN; i++) delete fClusters[i];
660 //_________________________________________________________________________
661 Int_t AliTOFtrackerMI::LoadClusters(TTree *cTree) {
662 //--------------------------------------------------------------------
663 //This function loads the TOF clusters
664 //--------------------------------------------------------------------
666 TBranch *branch=cTree->GetBranch("TOF");
668 AliError("can't get the branch with the TOF clusters !");
672 TClonesArray dummy("AliTOFcluster",10000), *clusters=&dummy;
673 branch->SetAddress(&clusters);
676 Int_t nc=clusters->GetEntriesFast();
677 AliInfo(Form("Number of clusters: %d",nc));
679 for (Int_t i=0; i<nc; i++) {
680 AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i);
682 for (Int_t jj=0; jj<5; jj++) dig[jj]=c->GetDetInd(jj);
692 for (Int_t jj=0; jj<3; jj++) indexDig[jj] = c->GetLabel(jj);
694 AliTOFcluster *cl=new AliTOFcluster(h,c->GetTracks(),dig,i);
697 // fClusters[i]=c; fN++;
698 fClusters[i]=new AliTOFcluster(*c); fN++;
700 //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)));
701 //AliInfo(Form("%i %f",i, fClusters[i]->GetZ()));
704 //AliInfo(Form("Number of clusters: %d",fN));
708 //_________________________________________________________________________
709 void AliTOFtrackerMI::UnloadClusters() {
710 //--------------------------------------------------------------------
711 //This function unloads TOF clusters
712 //--------------------------------------------------------------------
713 for (Int_t i=0; i<fN; i++) {
723 //_________________________________________________________________________
724 Int_t AliTOFtrackerMI::InsertCluster(AliTOFcluster *c) {
725 //--------------------------------------------------------------------
726 //This function adds a cluster to the array of clusters sorted in Z
727 //--------------------------------------------------------------------
728 if (fN==kMaxCluster) {
729 AliError("Too many clusters !");
733 if (fN==0) {fClusters[fN++]=c; return 0;}
734 Int_t i=FindClusterIndex(c->GetZ());
735 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTOFcluster*));
736 fClusters[i]=c; fN++;
741 //_________________________________________________________________________
742 Int_t AliTOFtrackerMI::FindClusterIndex(Double_t z) const {
743 //--------------------------------------------------------------------
744 // This function returns the index of the nearest cluster
745 //--------------------------------------------------------------------
747 if (z <= fClusters[0]->GetZ()) return 0;
748 if (z > fClusters[fN-1]->GetZ()) return fN;
749 Int_t b=0, e=fN-1, m=(b+e)/2;
750 for (; b<e; m=(b+e)/2) {
751 if (z > fClusters[m]->GetZ()) b=m+1;
759 Float_t AliTOFtrackerMI::GetLinearDistances(AliTOFtrack * track, AliTOFcluster *cluster, Float_t distances[5])
762 // calclates distance between cluster and track
763 // use linear aproximation
765 const Float_t kRaddeg = 180/3.14159265358979312;
767 // Float_t tiltangle = fGeom->GetAngles(cluster->fdetIndex[1],cluster->fdetIndex[2])/kRaddeg; //tiltangle
769 cind[0]= cluster->GetDetInd(0);
770 cind[1]= cluster->GetDetInd(1);
771 cind[2]= cluster->GetDetInd(2);
772 cind[3]= cluster->GetDetInd(3);
773 cind[4]= cluster->GetDetInd(4);
774 Float_t tiltangle = AliTOFGeometry::GetAngles(cluster->GetDetInd(1),cluster->GetDetInd(2))/kRaddeg; //tiltangle
776 Float_t cpos[3]; //cluster position
777 Float_t cpos0[3]; //cluster position
778 // fGeom->GetPos(cluster->fdetIndex,cpos);
779 //fGeom->GetPos(cluster->fdetIndex,cpos0);
781 fGeom->GetPos(cind,cpos);
782 fGeom->GetPos(cind,cpos0);
784 Float_t phi = TMath::ATan2(cpos[1],cpos[0]);
785 if(phi<0) phi=2.*TMath::Pi()+phi;
786 // Get the local angle in the sector philoc
787 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
792 track->GetPxPyPz(dir);
793 dir[0]/=track->GetP();
794 dir[1]/=track->GetP();
795 dir[2]/=track->GetP();
799 Float_t sinphi = TMath::Sin(phiangle);
800 Float_t cosphi = TMath::Cos(phiangle);
801 Float_t sinth = TMath::Sin(tiltangle);
802 Float_t costh = TMath::Cos(tiltangle);
805 temp = cpos[0]*cosphi+cpos[1]*sinphi;
806 cpos[1] = -cpos[0]*sinphi+cpos[1]*cosphi;
808 temp = v0[0]*cosphi+v0[1]*sinphi;
809 v0[1] = -v0[0]*sinphi+v0[1]*cosphi;
812 temp = cpos[0]*costh+cpos[2]*sinth;
813 cpos[2] = -cpos[0]*sinth+cpos[2]*costh;
815 temp = v0[0]*costh+v0[2]*sinth;
816 v0[2] = -v0[0]*sinth+v0[2]*costh;
820 //rotate direction vector
822 temp = dir[0]*cosphi+dir[1]*sinphi;
823 dir[1] = -dir[0]*sinphi+dir[1]*cosphi;
826 temp = dir[0]*costh+dir[2]*sinth;
827 dir[2] = -dir[0]*sinth+dir[2]*costh;
831 Float_t k = (cpos[0]-v0[0])/dir[0];
832 v3[0] = v0[0]+k*dir[0];
833 v3[1] = v0[1]+k*dir[1];
834 v3[2] = v0[2]+k*dir[2];
836 distances[0] = v3[0]-cpos[0];
837 distances[1] = v3[1]-cpos[1];
838 distances[2] = v3[2]-cpos[2];
839 distances[3] = TMath::Sqrt( distances[0]*distances[0]+distances[1]*distances[1]+distances[2]*distances[2]); //distance
840 distances[4] = k; //length
843 // Debuging part of the matching
845 if (track->GetLabel()==cluster->GetLabel(0) ||track->GetLabel()==cluster->GetLabel(1) ){
846 TTreeSRedirector& cstream = *fDebugStreamer;
847 Float_t tdc = cluster->GetTDC();
854 "Dist0="<<distances[0]<<
855 "Dist1="<<distances[1]<<
856 "Dist2="<<distances[2]<<
865 void AliTOFtrackerMI::GetLikelihood(Float_t dy, Float_t dz, const Double_t *cov, AliTOFtrack * /*track*/, Float_t & py, Float_t &pz)
868 // get likelihood - track covariance taken
869 // 75 % of gauss with expected sigma
870 // 25 % of gauss with extended sigma
872 Double_t kMaxSigmaY = 0.6; // ~ 90% of TRD tracks
873 Double_t kMaxSigmaZ = 1.2; // ~ 90% of TRD tracks
874 Double_t kMeanSigmaY = 0.25; // mean TRD sigma
875 Double_t kMeanSigmaZ = 0.5; // mean TRD sigma
878 Float_t normwidth, normd, p0,p1;
879 Float_t sigmay = TMath::Max(TMath::Sqrt(cov[0]+kMeanSigmaY*kMeanSigmaY),kMaxSigmaY);
880 Float_t sigmaz = TMath::Max(TMath::Sqrt(cov[2]+kMeanSigmaZ*kMeanSigmaZ),kMaxSigmaZ);
885 // py calculation - 75% admixture of original sigma - 25% tails
887 normwidth = fDy/sigmay;
889 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
890 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
893 normwidth = fDy/(3.*sigmay);
894 normd = dy/(3.*sigmay);
895 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
896 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
899 // pz calculation - 75% admixture of original sigma - 25% tails
901 normwidth = fDz/sigmaz;
903 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
904 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
907 normwidth = fDz/(3.*sigmaz);
908 normd = dz/(3.*sigmaz);
909 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
910 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));