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():
67 fTracks(new TClonesArray("AliTOFtrack")),
68 fSeeds(new TClonesArray("AliESDtrack")),
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):
102 fTracks(new TClonesArray("AliTOFtrack")),
103 fSeeds(new TClonesArray("AliESDtrack")),
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;
179 //_____________________________________________________________________________
180 Int_t AliTOFtrackerMI::PropagateBack(AliESDEvent* event) {
182 // Gets seeds from ESD event and Match with TOF Clusters
186 //Initialise some counters
195 Int_t ntrk=event->GetNumberOfTracks();
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 fPid->MakePID(event);
258 //_________________________________________________________________________
259 void AliTOFtrackerMI::CollectESD() {
260 //prepare the set of ESD tracks to be matched to clusters in TOF
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 372 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 quality[1000];
348 Float_t dist3D[1000][6];
349 Double_t times[1000][6];
350 Float_t mintimedist[1000];
351 Float_t likelihood[1000];
352 Float_t length[1000];
353 AliTOFcluster *clusters[1000];
357 for (Int_t i=0; i<fNseedsTOF; i++) {
359 AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(i);
360 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(track->GetSeedIndex());
361 Bool_t hasTime = ( (t->GetStatus()& AliESDtrack::kTIME)>0) ? kTRUE:kFALSE; // did we integrate time
362 Float_t trdquality = t->GetTRDQuality();
366 t->GetTPCpid(tpcpid);
368 for (Int_t ipid=0;ipid<5;ipid++){
369 sumpid+=tpcpid[ipid];
371 for (Int_t ipid=0;ipid<5;ipid++){
372 if (sumpid>0) tpcpid[ipid]/=sumpid;
378 if (trdquality<0) continue; // no chance
380 AliTOFtrack *trackTOFin =new AliTOFtrack(*track);
382 //propagat track to the middle of TOF
384 Float_t xs = 379.2; // should be defined in the TOF geometry
385 Double_t ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
387 Double_t ysect=trackTOFin->GetYat(xs,skip);
390 ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
391 ysect=trackTOFin->GetYat(xs,skip);
394 if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) {
397 } else if (ysect <-ymax) {
398 if (!trackTOFin->Rotate(-AliTOFGeometry::GetAlpha())) {
402 if(!trackTOFin->PropagateTo(xs)) {
406 // Determine a window around the track
409 trackTOFin->GetExternalParameters(x,par);
411 trackTOFin->GetExternalCovariance(cov);
412 Float_t scalefact=3.;
415 ((5*TMath::Sqrt(cov[0]) + 3.*fDy +10.*TMath::Abs(par[2]))/fR);
418 (5*TMath::Sqrt(cov[2]) + 3.*fDz +10.*TMath::Abs(par[3]));
420 Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha();
421 if (phi<-TMath::Pi())phi+=2*TMath::Pi();
422 if (phi>=TMath::Pi())phi-=2*TMath::Pi();
427 // find the clusters in the window of the track
429 for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) {
430 AliTOFcluster *c=fClusters[k];
431 if (c->GetZ() > z+dz) break;
432 // if (c->IsUsed()) continue;
434 Double_t dph=TMath::Abs(c->GetPhi()-phi);
435 if (dph>TMath::Pi()) dph-=2.*TMath::Pi();
436 if (TMath::Abs(dph)>dphi) continue;
438 clind[0][nc] = c->GetDetInd(0);
439 clind[1][nc] = c->GetDetInd(1);
440 clind[2][nc] = c->GetDetInd(2);
441 clind[3][nc] = c->GetDetInd(3);
442 clind[4][nc] = c->GetDetInd(4);
448 // select close clusters
450 Double_t mom=t->GetP();
451 // Bool_t dump = kTRUE;
452 for (Int_t icl=0; icl<nc; icl++){
453 Float_t distances[5];
454 if (nfound>=1000) break;
455 index[nfound]=clind[5][icl];
456 AliTOFcluster *cluster = fClusters[clind[5][icl]];
457 GetLinearDistances(trackTOFin,cluster, distances);
458 dist3D[nfound][0] = distances[4];
459 dist3D[nfound][1] = distances[1];
460 dist3D[nfound][2] = distances[2];
462 if (TMath::Abs(dist3D[nfound][1])>20 || TMath::Abs(dist3D[nfound][2])>20) continue;
464 GetLikelihood(distances[1],distances[2],cov,trackTOFin, dist3D[nfound][3], dist3D[nfound][4]);
467 if (dist3D[nfound][3]*dist3D[nfound][4]<0.00000000000001) continue; // log likelihood
468 if (TMath::Log(dist3D[nfound][3]*dist3D[nfound][4])<-9) continue; // log likelihood
470 clusters[nfound] = cluster;
472 //length and TOF updates
473 trackTOFin->GetIntegratedTimes(times[nfound]);
474 length[nfound] = trackTOFin->GetIntegratedLength();
475 length[nfound]+=distances[4];
476 mintimedist[nfound]=1000;
477 Double_t tof2=AliTOFGeometry::TdcBinWidth()*cluster->GetTDC()+kTofOffset; // in ps
478 // Float_t tgamma = TMath::Sqrt(cluster->GetR()*cluster->GetR()+cluster->GetZ()*cluster->GetZ())/0.03; //time for "primary" gamma
479 //if (trackTOFin->GetPt()<0.7 && TMath::Abs(tgamma-tof2)<350) continue; // gamma conversion candidate - TEMPORARY
480 for(Int_t j=0;j<=5;j++){
481 Double_t mass=kMasses[j];
482 times[nfound][j]+=distances[4]/3e-2*TMath::Sqrt(mom*mom+mass*mass)/mom; // add time distance
483 if ( TMath::Abs(times[nfound][j]-tof2)<mintimedist[nfound] && tpcpid[j]>kForbiddenR){
484 mintimedist[nfound]=TMath::Abs(times[nfound][j]-tof2);
488 Float_t liketime = TMath::Exp(-mintimedist[nfound]/90.)+0.25*TMath::Exp(-mintimedist[nfound]/180.);
489 if (!hasTime) liketime=0.2;
490 likelihood[nfound] = TMath::Log(dist3D[nfound][3]*dist3D[nfound][4]*liketime);
492 if (TMath::Log(dist3D[nfound][3]*dist3D[nfound][4])<-1){
493 if (likelihood[nfound]<-9.) continue;
504 //choose the best cluster
506 //Float_t quality[1000];
508 for (Int_t kk=0; kk<1000; kk++) quality[kk]=0;
510 AliTOFcluster * cgold=0;
512 for (Int_t icl=0;icl<nfound;icl++){
513 quality[icl] = dist3D[icl][3]*dist3D[icl][4];
515 TMath::Sort(nfound,quality,index,kTRUE);
517 cgold = clusters[igold];
518 if (nfound>1 &&likelihood[index[1]]>likelihood[index[0]]){
519 if ( quality[index[0]]<quality[index[1]]+0.5){
521 cgold = clusters[igold];
526 Float_t qualityGold = TMath::Log(0.0000001+(quality[igold]*(0.1+TMath::Exp(-mintimedist[igold]/80.))*(0.2+trdquality)));
528 if (cgold->GetQuality()<qualityGold) cgold->SetQuality(qualityGold);
533 //signed better cluster
534 if (cgold->GetQuality()>qualityGold+kMaxQualityD) continue;
535 if (2.*qualityGold-cgold->GetQuality()<kMinQuality) continue;
540 for (Int_t icl=0;icl<nfound;icl++){
542 (clusters[index[icl]]->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel()))
544 (clusters[index[icl]]->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel()))
546 (clusters[index[icl]]->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel()))
553 if (inonfake==0) fngoodmatch++;
559 tlab[0]=cgold->GetLabel(0);
560 tlab[1]=cgold->GetLabel(1);
561 tlab[2]=cgold->GetLabel(2);
562 // Double_t tof2=25.*cgold->GetTDC()-350; // in ps
563 Double_t tof2=AliTOFGeometry::TdcBinWidth()*cgold->GetTDC()+kTofOffset; // in ps
564 Float_t tgamma = TMath::Sqrt(cgold->GetR()*cgold->GetR()+cgold->GetZ()*cgold->GetZ())/0.03;
565 Float_t info[11]={dist3D[igold][0],dist3D[igold][1],dist3D[igold][2],dist3D[igold][3],dist3D[igold][4],mintimedist[igold],
566 -1,tgamma, qualityGold,cgold->GetQuality(),0};
567 // GetLinearDistances(trackTOFin,cgold,&info[6]);
570 // info[7] = mintimedist[index[inonfake]];
573 // Store quantities to be used for TOF Calibration
574 Float_t tToT=cgold->GetToT(); // in ps
575 t->SetTOFsignalToT(tToT);
577 ind[0]=cgold->GetDetInd(0);
578 ind[1]=cgold->GetDetInd(1);
579 ind[2]=cgold->GetDetInd(2);
580 ind[3]=cgold->GetDetInd(3);
581 ind[4]=cgold->GetDetInd(4);
582 Int_t calindex = AliTOFGeometry::GetIndex(ind);
583 t->SetTOFCalChannel(calindex);
586 t->SetTOFsignal(tof2);
587 t->SetTOFcluster(cgold->GetIndex());
588 AliTOFtrack *trackTOFout = new AliTOFtrack(*t);
589 trackTOFout->PropagateTo(379.);
590 t->UpdateTrackParams(trackTOFout,AliESDtrack::kTOFout);
591 t->SetIntegratedLength(length[igold]);
592 t->SetIntegratedTimes(times[igold]);
593 t->SetTOFLabel(tlab);
602 for (Int_t ii=0; ii<4; ii++) delete [] trackPos[ii];
603 for (Int_t ii=0;ii<6;ii++) delete [] clind[ii];
610 // //_________________________________________________________________________
611 // Int_t AliTOFtrackerMI::LoadClusters(TTree *dTree) {
612 // //--------------------------------------------------------------------
613 // //This function loads the TOF clusters
614 // //--------------------------------------------------------------------
616 // TBranch *branch=dTree->GetBranch("TOF");
618 // AliError(" can't get the branch with the TOF digits !");
622 // TClonesArray dummy("AliTOFdigit",10000), *digits=&dummy;
623 // branch->SetAddress(&digits);
625 // dTree->GetEvent(0);
626 // Int_t nd=digits->GetEntriesFast();
627 // Info("LoadClusters","number of digits: %d",nd);
629 // for (Int_t i=0; i<nd; i++) {
630 // AliTOFdigit *d=(AliTOFdigit*)digits->UncheckedAt(i);
631 // Int_t dig[5]; Float_t g[3];
632 // dig[0]=d->GetSector();
633 // dig[1]=d->GetPlate();
634 // dig[2]=d->GetStrip();
635 // dig[3]=d->GetPadz();
636 // dig[4]=d->GetPadx();
638 // fGeom->GetPos(dig,g);
641 // h[0]=TMath::Sqrt(g[0]*g[0]+g[1]*g[1]);
642 // h[1]=TMath::ATan2(g[1],g[0]); h[2]=g[2];
643 // h[3]=d->GetTdc(); h[4]=d->GetAdc();
645 // AliTOFcluster *cl=new AliTOFcluster(h,d->GetTracks(),dig,i);
646 // InsertCluster(cl);
651 // //_________________________________________________________________________
652 // void AliTOFtrackerMI::UnloadClusters() {
653 // //--------------------------------------------------------------------
654 // //This function unloads TOF clusters
655 // //--------------------------------------------------------------------
656 // for (Int_t i=0; i<fN; i++) delete fClusters[i];
662 //_________________________________________________________________________
663 Int_t AliTOFtrackerMI::LoadClusters(TTree *cTree) {
664 //--------------------------------------------------------------------
665 //This function loads the TOF clusters
666 //--------------------------------------------------------------------
668 TBranch *branch=cTree->GetBranch("TOF");
670 AliError("can't get the branch with the TOF clusters !");
674 static TClonesArray dummy("AliTOFcluster",10000);
676 TClonesArray *clusters=&dummy;
677 branch->SetAddress(&clusters);
680 Int_t nc=clusters->GetEntriesFast();
681 AliInfo(Form("Number of clusters: %d",nc));
683 for (Int_t i=0; i<nc; i++) {
684 AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i);
686 for (Int_t jj=0; jj<5; jj++) dig[jj]=c->GetDetInd(jj);
696 for (Int_t jj=0; jj<3; jj++) indexDig[jj] = c->GetLabel(jj);
698 AliTOFcluster *cl=new AliTOFcluster(h,c->GetTracks(),dig,i);
701 // fClusters[i]=c; fN++;
702 fClusters[i]=new AliTOFcluster(*c); fN++;
704 //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)));
705 //AliInfo(Form("%i %f",i, fClusters[i]->GetZ()));
708 //AliInfo(Form("Number of clusters: %d",fN));
712 //_________________________________________________________________________
713 void AliTOFtrackerMI::UnloadClusters() {
714 //--------------------------------------------------------------------
715 //This function unloads TOF clusters
716 //--------------------------------------------------------------------
717 for (Int_t i=0; i<fN; i++) {
727 //_________________________________________________________________________
728 Int_t AliTOFtrackerMI::InsertCluster(AliTOFcluster *c) {
729 //--------------------------------------------------------------------
730 //This function adds a cluster to the array of clusters sorted in Z
731 //--------------------------------------------------------------------
732 if (fN==kMaxCluster) {
733 AliError("Too many clusters !");
737 if (fN==0) {fClusters[fN++]=c; return 0;}
738 Int_t i=FindClusterIndex(c->GetZ());
739 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTOFcluster*));
740 fClusters[i]=c; fN++;
745 //_________________________________________________________________________
746 Int_t AliTOFtrackerMI::FindClusterIndex(Double_t z) const {
747 //--------------------------------------------------------------------
748 // This function returns the index of the nearest cluster
749 //--------------------------------------------------------------------
751 if (z <= fClusters[0]->GetZ()) return 0;
752 if (z > fClusters[fN-1]->GetZ()) return fN;
753 Int_t b=0, e=fN-1, m=(b+e)/2;
754 for (; b<e; m=(b+e)/2) {
755 if (z > fClusters[m]->GetZ()) b=m+1;
763 Float_t AliTOFtrackerMI::GetLinearDistances(AliTOFtrack * track, AliTOFcluster *cluster, Float_t distances[5])
766 // calclates distance between cluster and track
767 // use linear aproximation
769 const Float_t kRaddeg = 180/3.14159265358979312;
771 // Float_t tiltangle = fGeom->GetAngles(cluster->fdetIndex[1],cluster->fdetIndex[2])/kRaddeg; //tiltangle
773 cind[0]= cluster->GetDetInd(0);
774 cind[1]= cluster->GetDetInd(1);
775 cind[2]= cluster->GetDetInd(2);
776 cind[3]= cluster->GetDetInd(3);
777 cind[4]= cluster->GetDetInd(4);
778 Float_t tiltangle = AliTOFGeometry::GetAngles(cluster->GetDetInd(1),cluster->GetDetInd(2))/kRaddeg; //tiltangle
780 Float_t cpos[3]; //cluster position
781 Float_t cpos0[3]; //cluster position
782 // fGeom->GetPos(cluster->fdetIndex,cpos);
783 //fGeom->GetPos(cluster->fdetIndex,cpos0);
785 fGeom->GetPos(cind,cpos);
786 fGeom->GetPos(cind,cpos0);
788 Float_t phi = TMath::ATan2(cpos[1],cpos[0]);
789 if(phi<0) phi=2.*TMath::Pi()+phi;
790 // Get the local angle in the sector philoc
791 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
796 track->GetPxPyPz(dir);
797 dir[0]/=track->GetP();
798 dir[1]/=track->GetP();
799 dir[2]/=track->GetP();
803 Float_t sinphi = TMath::Sin(phiangle);
804 Float_t cosphi = TMath::Cos(phiangle);
805 Float_t sinth = TMath::Sin(tiltangle);
806 Float_t costh = TMath::Cos(tiltangle);
809 temp = cpos[0]*cosphi+cpos[1]*sinphi;
810 cpos[1] = -cpos[0]*sinphi+cpos[1]*cosphi;
812 temp = v0[0]*cosphi+v0[1]*sinphi;
813 v0[1] = -v0[0]*sinphi+v0[1]*cosphi;
816 temp = cpos[0]*costh+cpos[2]*sinth;
817 cpos[2] = -cpos[0]*sinth+cpos[2]*costh;
819 temp = v0[0]*costh+v0[2]*sinth;
820 v0[2] = -v0[0]*sinth+v0[2]*costh;
824 //rotate direction vector
826 temp = dir[0]*cosphi+dir[1]*sinphi;
827 dir[1] = -dir[0]*sinphi+dir[1]*cosphi;
830 temp = dir[0]*costh+dir[2]*sinth;
831 dir[2] = -dir[0]*sinth+dir[2]*costh;
835 Float_t k = (cpos[0]-v0[0])/dir[0];
836 v3[0] = v0[0]+k*dir[0];
837 v3[1] = v0[1]+k*dir[1];
838 v3[2] = v0[2]+k*dir[2];
840 distances[0] = v3[0]-cpos[0];
841 distances[1] = v3[1]-cpos[1];
842 distances[2] = v3[2]-cpos[2];
843 distances[3] = TMath::Sqrt( distances[0]*distances[0]+distances[1]*distances[1]+distances[2]*distances[2]); //distance
844 distances[4] = k; //length
847 // Debuging part of the matching
849 if (track->GetLabel()==cluster->GetLabel(0) ||track->GetLabel()==cluster->GetLabel(1) ){
850 TTreeSRedirector& cstream = *fDebugStreamer;
851 Float_t tdc = cluster->GetTDC();
858 "Dist0="<<distances[0]<<
859 "Dist1="<<distances[1]<<
860 "Dist2="<<distances[2]<<
869 void AliTOFtrackerMI::GetLikelihood(Float_t dy, Float_t dz, const Double_t *cov, AliTOFtrack * /*track*/, Float_t & py, Float_t &pz)
872 // get likelihood - track covariance taken
873 // 75 % of gauss with expected sigma
874 // 25 % of gauss with extended sigma
876 Double_t kMaxSigmaY = 0.6; // ~ 90% of TRD tracks
877 Double_t kMaxSigmaZ = 1.2; // ~ 90% of TRD tracks
878 Double_t kMeanSigmaY = 0.25; // mean TRD sigma
879 Double_t kMeanSigmaZ = 0.5; // mean TRD sigma
882 Float_t normwidth, normd, p0,p1;
883 Float_t sigmay = TMath::Max(TMath::Sqrt(cov[0]+kMeanSigmaY*kMeanSigmaY),kMaxSigmaY);
884 Float_t sigmaz = TMath::Max(TMath::Sqrt(cov[2]+kMeanSigmaZ*kMeanSigmaZ),kMaxSigmaZ);
889 // py calculation - 75% admixture of original sigma - 25% tails
891 normwidth = fDy/sigmay;
893 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
894 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
897 normwidth = fDy/(3.*sigmay);
898 normd = dy/(3.*sigmay);
899 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
900 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
903 // pz calculation - 75% admixture of original sigma - 25% tails
905 normwidth = fDz/sigmaz;
907 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
908 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
911 normwidth = fDz/(3.*sigmaz);
912 normd = dz/(3.*sigmaz);
913 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
914 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));