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::operator=(const AliTOFtrackerMI &t)
90 //AliTOFtrackerMI assignment operator
92 this->fHoles=t.fHoles;
93 this->fNseeds=t.fNseeds;
94 this->fNseedsTOF=t.fNseedsTOF;
95 this->fngoodmatch=t.fngoodmatch;
96 this->fnbadmatch=t.fnbadmatch;
97 this->fnunmatch=t.fnunmatch;
98 this->fnmatch=t.fnmatch;
99 this->fGeom = t.fGeom;
100 this->fTOFpid = t.fTOFpid;
102 this->fTOFHeigth=t.fTOFHeigth;
107 this->fSeeds=t.fSeeds;
108 this->fTracks=t.fTracks;
114 //_____________________________________________________________________________
115 AliTOFtrackerMI::~AliTOFtrackerMI(){
119 if (fDebugStreamer) {
120 //fDebugStreamer->Close();
121 delete fDebugStreamer;
126 //_____________________________________________________________________________
128 void AliTOFtrackerMI::Init() {
130 // temporary solution to know about Holes/no Holes, will be implemented as
131 // an AliTOFGeometry getter
133 AliModule* frame=gAlice->GetModule("FRAME");
136 Error("Init","Could Not load FRAME! Assume Frame with Holes \n");
139 if(frame->IsVersion()==1) {fHoles=false;}
144 //_____________________________________________________________________________
145 Int_t AliTOFtrackerMI::PropagateBack(AliESD* event) {
147 // Gets seeds from ESD event and Match with TOF Clusters
151 //Initialise some counters
160 Int_t ntrk=event->GetNumberOfTracks();
162 fSeeds= new TClonesArray("AliESDtrack");
163 TClonesArray &aESDTrack = *fSeeds;
166 //Load ESD tracks into a local Array of ESD Seeds
168 for (Int_t i=0; i<fNseeds; i++) {
169 AliESDtrack *t=event->GetTrack(i);
170 new(aESDTrack[i]) AliESDtrack(*t);
173 //Prepare ESD tracks candidates for TOF Matching
176 //First Step with Strict Matching Criterion
177 //MatchTracks(kFALSE);
179 //Second Step with Looser Matching Criterion
180 //MatchTracks(kTRUE);
181 MatchTracksMI(kFALSE); // assign track to clusters
182 MatchTracksMI(kTRUE); // assign clusters to esd
184 Info("PropagateBack","Number of matched tracks: %d",fnmatch);
185 Info("PropagateBack","Number of good matched tracks: %d",fngoodmatch);
186 Info("PropagateBack","Number of bad matched tracks: %d",fnbadmatch);
188 //Update the matched ESD tracks
190 for (Int_t i=0; i<ntrk; i++) {
191 AliESDtrack *t=event->GetTrack(i);
192 AliESDtrack *seed =(AliESDtrack*)fSeeds->UncheckedAt(i);
193 if(seed->GetTOFsignal()>0){
194 t->SetTOFsignal(seed->GetTOFsignal());
195 t->SetTOFcluster(seed->GetTOFcluster());
197 seed->GetTOFLabel(tlab);
198 t->SetTOFLabel(tlab);
199 AliTOFtrack *track = new AliTOFtrack(*seed);
202 seed->GetTOFInfo(info);
203 seed->GetIntegratedTimes(times);
204 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
205 t->SetIntegratedLength(seed->GetIntegratedLength());
206 t->SetIntegratedTimes(times);
207 t->SetTOFsignalToT(seed->GetTOFsignalToT());
208 t->SetTOFCalChannel(seed->GetTOFCalChannel());
217 fTOFpid->MakePID(event);
232 //_________________________________________________________________________
233 void AliTOFtrackerMI::CollectESD() {
234 //prepare the set of ESD tracks to be matched to clusters in TOF
236 fTracks= new TClonesArray("AliTOFtrack");
237 TClonesArray &aTOFTrack = *fTracks;
240 for (Int_t i=0; i<fNseeds; i++) {
242 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(i);
243 if ((t->GetStatus()&AliESDtrack::kTPCout)==0)continue;
245 // TRD good tracks, already propagated at 371 cm
247 AliTOFtrack *track = new AliTOFtrack(*t); // New
248 Double_t x = track->GetX(); //New
250 if (((t->GetStatus()&AliESDtrack::kTRDout)!=0 ) &&
251 ( x >= fGeom->RinTOF()) ){
252 track->SetSeedIndex(i);
253 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
254 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
260 // Propagate the rest of TPCbp
263 if(track->PropagateToInnerTOF(fHoles)){ // temporary solution
264 // if(track->PropagateToInnerTOF(fGeom->GetHoles())){
265 track->SetSeedIndex(i);
266 t->UpdateTrackParams(track,AliESDtrack::kTOFout);
267 new(aTOFTrack[fNseedsTOF]) AliTOFtrack(*track);
276 printf("TRD\tOn\t%d\tOff\t%d\n",c0,c1);
278 // Sort according uncertainties on track position
291 //_________________________________________________________________________
292 void AliTOFtrackerMI::MatchTracks( Bool_t /*mLastStep*/){
297 //_________________________________________________________________________
298 void AliTOFtrackerMI::MatchTracksMI(Bool_t mLastStep){
300 //Match ESD tracks to clusters in TOF
301 const Float_t kTofOffset = 26; // time offset
302 const Float_t kMinQuality = -6.; // minimal quality
303 const Float_t kMaxQualityD = 1.; // max delta quality if cluster used
304 const Float_t kForbiddenR = 0.1; // minimal PID according TPC
306 static const Double_t kMasses[]={
307 0.000511, 0.105658, 0.139570, 0.493677, 0.938272, 1.875613
310 Int_t nSteps=(Int_t)(fTOFHeigth/0.1);
312 AliTOFcalib *calib = new AliTOFcalib(fGeom);
314 //PH Arrays (moved outside of the loop)
315 Float_t * trackPos[4];
316 for (Int_t ii=0; ii<4; ii++) trackPos[ii] = new Float_t[nSteps];
318 for (Int_t ii=0;ii<6;ii++) clind[ii] = new Int_t[fN];
323 Float_t dist3D[1000][6];
324 Double_t times[1000][6];
325 Float_t mintimedist[1000];
326 Float_t likelihood[1000];
327 Float_t length[1000];
328 AliTOFcluster *clusters[1000];
332 for (Int_t i=0; i<fNseedsTOF; i++) {
334 AliTOFtrack *track =(AliTOFtrack*)fTracks->UncheckedAt(i);
335 AliESDtrack *t =(AliESDtrack*)fSeeds->UncheckedAt(track->GetSeedIndex());
336 Bool_t hasTime = ( (t->GetStatus()& AliESDtrack::kTIME)>0) ? kTRUE:kFALSE; // did we integrate time
337 Float_t trdquality = t->GetTRDQuality();
341 t->GetTPCpid(tpcpid);
343 for (Int_t ipid=0;ipid<5;ipid++){
344 sumpid+=tpcpid[ipid];
346 for (Int_t ipid=0;ipid<5;ipid++){
347 if (sumpid>0) tpcpid[ipid]/=sumpid;
353 if (trdquality<0) continue; // no chance
355 AliTOFtrack *trackTOFin =new AliTOFtrack(*track);
357 //propagat track to the middle of TOF
359 Float_t xs = 378.2; // should be defined in the TOF geometry
360 Double_t ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
362 Double_t ysect=trackTOFin->GetYat(xs,skip);
365 ymax=xs*TMath::Tan(0.5*AliTOFGeometry::GetAlpha());
366 ysect=trackTOFin->GetYat(xs,skip);
369 if (!trackTOFin->Rotate(AliTOFGeometry::GetAlpha())) {
372 } else if (ysect <-ymax) {
373 if (!trackTOFin->Rotate(-AliTOFGeometry::GetAlpha())) {
377 if(!trackTOFin->PropagateTo(xs)) {
381 // Determine a window around the track
384 trackTOFin->GetExternalParameters(x,par);
386 trackTOFin->GetExternalCovariance(cov);
387 Float_t scalefact=3.;
390 ((5*TMath::Sqrt(cov[0]) + 3.*fDy +10.*TMath::Abs(par[2]))/fR);
393 (5*TMath::Sqrt(cov[2]) + 3.*fDz +10.*TMath::Abs(par[3]));
395 Double_t phi=TMath::ATan2(par[0],x) + trackTOFin->GetAlpha();
396 if (phi<-TMath::Pi())phi+=2*TMath::Pi();
397 if (phi>=TMath::Pi())phi-=2*TMath::Pi();
402 // find the clusters in the window of the track
404 for (Int_t k=FindClusterIndex(z-dz); k<fN; k++) {
405 AliTOFcluster *c=fClusters[k];
406 if (c->GetZ() > z+dz) break;
407 // if (c->IsUsed()) continue;
409 Double_t dph=TMath::Abs(c->GetPhi()-phi);
410 if (dph>TMath::Pi()) dph-=2.*TMath::Pi();
411 if (TMath::Abs(dph)>dphi) continue;
413 clind[0][nc] = c->GetDetInd(0);
414 clind[1][nc] = c->GetDetInd(1);
415 clind[2][nc] = c->GetDetInd(2);
416 clind[3][nc] = c->GetDetInd(3);
417 clind[4][nc] = c->GetDetInd(4);
423 // select close clusters
425 Double_t mom=t->GetP();
426 // Bool_t dump = kTRUE;
427 for (Int_t icl=0; icl<nc; icl++){
428 Float_t distances[5];
429 if (nfound>=1000) break;
430 index[nfound]=clind[5][icl];
431 AliTOFcluster *cluster = fClusters[clind[5][icl]];
432 GetLinearDistances(trackTOFin,cluster, distances);
433 dist3D[nfound][0] = distances[4];
434 dist3D[nfound][1] = distances[1];
435 dist3D[nfound][2] = distances[2];
437 if (TMath::Abs(dist3D[nfound][1])>20 || TMath::Abs(dist3D[nfound][2])>20) continue;
439 GetLikelihood(distances[1],distances[2],cov,trackTOFin, dist3D[nfound][3], dist3D[nfound][4]);
442 if (dist3D[nfound][3]*dist3D[nfound][4]<0.00000000000001) continue; // log likelihood
443 if (TMath::Log(dist3D[nfound][3]*dist3D[nfound][4])<-9) continue; // log likelihood
445 clusters[nfound] = cluster;
447 //length and TOF updates
448 trackTOFin->GetIntegratedTimes(times[nfound]);
449 length[nfound] = trackTOFin->GetIntegratedLength();
450 length[nfound]+=distances[4];
451 mintimedist[nfound]=1000;
452 Double_t tof2=AliTOFGeometry::TdcBinWidth()*cluster->GetTDC()+kTofOffset; // in ps
453 // Float_t tgamma = TMath::Sqrt(cluster->GetR()*cluster->GetR()+cluster->GetZ()*cluster->GetZ())/0.03; //time for "primary" gamma
454 //if (trackTOFin->GetPt()<0.7 && TMath::Abs(tgamma-tof2)<350) continue; // gamma conversion candidate - TEMPORARY
455 for(Int_t j=0;j<=5;j++){
456 Double_t mass=kMasses[j];
457 times[nfound][j]+=distances[4]/3e-2*TMath::Sqrt(mom*mom+mass*mass)/mom; // add time distance
458 if ( TMath::Abs(times[nfound][j]-tof2)<mintimedist[nfound] && tpcpid[j]>kForbiddenR){
459 mintimedist[nfound]=TMath::Abs(times[nfound][j]-tof2);
463 Float_t liketime = TMath::Exp(-mintimedist[nfound]/90.)+0.25*TMath::Exp(-mintimedist[nfound]/180.);
464 if (!hasTime) liketime=0.2;
465 likelihood[nfound] = TMath::Log(dist3D[nfound][3]*dist3D[nfound][4]*liketime);
467 if (TMath::Log(dist3D[nfound][3]*dist3D[nfound][4])<-1){
468 if (likelihood[nfound]<-9.) continue;
479 //choose the best cluster
481 Float_t quality[1000];
484 AliTOFcluster * cgold=0;
486 for (Int_t icl=0;icl<nfound;icl++){
487 quality[icl] = dist3D[icl][3]*dist3D[icl][4];
489 TMath::Sort(nfound,quality,index,kTRUE);
491 cgold = clusters[igold];
492 if (nfound>1 &&likelihood[index[1]]>likelihood[index[0]]){
493 if ( quality[index[0]]<quality[index[1]]+0.5){
495 cgold = clusters[igold];
500 Float_t qualityGold = TMath::Log(0.0000001+(quality[igold]*(0.1+TMath::Exp(-mintimedist[igold]/80.))*(0.2+trdquality)));
502 if (cgold->GetQuality()<qualityGold) cgold->SetQuality(qualityGold);
507 //signed better cluster
508 if (cgold->GetQuality()>qualityGold+kMaxQualityD) continue;
509 if (2.*qualityGold-cgold->GetQuality()<kMinQuality) continue;
514 for (Int_t icl=0;icl<nfound;icl++){
516 (clusters[index[icl]]->GetLabel(0)==TMath::Abs(trackTOFin->GetLabel()))
518 (clusters[index[icl]]->GetLabel(1)==TMath::Abs(trackTOFin->GetLabel()))
520 (clusters[index[icl]]->GetLabel(2)==TMath::Abs(trackTOFin->GetLabel()))
527 if (inonfake==0) fngoodmatch++;
533 tlab[0]=cgold->GetLabel(0);
534 tlab[1]=cgold->GetLabel(1);
535 tlab[2]=cgold->GetLabel(2);
536 // Double_t tof2=25.*cgold->GetTDC()-350; // in ps
537 Double_t tof2=AliTOFGeometry::TdcBinWidth()*cgold->GetTDC()+kTofOffset; // in ps
538 Float_t tgamma = TMath::Sqrt(cgold->GetR()*cgold->GetR()+cgold->GetZ()*cgold->GetZ())/0.03;
539 Float_t info[11]={dist3D[igold][0],dist3D[igold][1],dist3D[igold][2],dist3D[igold][3],dist3D[igold][4],mintimedist[igold],
540 -1,tgamma, qualityGold,cgold->GetQuality(),0};
541 // GetLinearDistances(trackTOFin,cgold,&info[6]);
544 // info[7] = mintimedist[index[inonfake]];
547 // Store quantities to be used for TOF Calibration
548 Float_t tToT=cgold->GetToT(); // in ps
549 t->SetTOFsignalToT(tToT);
551 ind[0]=cgold->GetDetInd(0);
552 ind[1]=cgold->GetDetInd(1);
553 ind[2]=cgold->GetDetInd(2);
554 ind[3]=cgold->GetDetInd(3);
555 ind[4]=cgold->GetDetInd(4);
556 Int_t calindex = calib->GetIndex(ind);
557 t->SetTOFCalChannel(calindex);
560 t->SetTOFsignal(tof2);
561 t->SetTOFcluster(cgold->GetIndex());
562 AliTOFtrack *trackTOFout = new AliTOFtrack(*t);
563 trackTOFout->PropagateTo(378.);
564 t->UpdateTrackParams(trackTOFout,AliESDtrack::kTOFout);
565 t->SetIntegratedLength(length[igold]);
566 t->SetIntegratedTimes(times[igold]);
567 t->SetTOFLabel(tlab);
576 for (Int_t ii=0; ii<4; ii++) delete [] trackPos[ii];
577 for (Int_t ii=0;ii<6;ii++) delete [] clind[ii];
584 // //_________________________________________________________________________
585 // Int_t AliTOFtrackerMI::LoadClusters(TTree *dTree) {
586 // //--------------------------------------------------------------------
587 // //This function loads the TOF clusters
588 // //--------------------------------------------------------------------
590 // TBranch *branch=dTree->GetBranch("TOF");
592 // Error("LoadClusters"," can't get the branch with the TOF digits !\n");
596 // TClonesArray dummy("AliTOFdigit",10000), *digits=&dummy;
597 // branch->SetAddress(&digits);
599 // dTree->GetEvent(0);
600 // Int_t nd=digits->GetEntriesFast();
601 // Info("LoadClusters","number of digits: %d",nd);
603 // for (Int_t i=0; i<nd; i++) {
604 // AliTOFdigit *d=(AliTOFdigit*)digits->UncheckedAt(i);
605 // Int_t dig[5]; Float_t g[3];
606 // dig[0]=d->GetSector();
607 // dig[1]=d->GetPlate();
608 // dig[2]=d->GetStrip();
609 // dig[3]=d->GetPadz();
610 // dig[4]=d->GetPadx();
612 // fGeom->GetPos(dig,g);
615 // h[0]=TMath::Sqrt(g[0]*g[0]+g[1]*g[1]);
616 // h[1]=TMath::ATan2(g[1],g[0]); h[2]=g[2];
617 // h[3]=d->GetTdc(); h[4]=d->GetAdc();
619 // AliTOFcluster *cl=new AliTOFcluster(h,d->GetTracks(),dig,i);
620 // InsertCluster(cl);
625 // //_________________________________________________________________________
626 // void AliTOFtrackerMI::UnloadClusters() {
627 // //--------------------------------------------------------------------
628 // //This function unloads TOF clusters
629 // //--------------------------------------------------------------------
630 // for (Int_t i=0; i<fN; i++) delete fClusters[i];
636 //_________________________________________________________________________
637 Int_t AliTOFtrackerMI::LoadClusters(TTree *cTree) {
638 //--------------------------------------------------------------------
639 //This function loads the TOF clusters
640 //--------------------------------------------------------------------
642 TBranch *branch=cTree->GetBranch("TOF");
644 AliError("can't get the branch with the TOF clusters !");
648 TClonesArray dummy("AliTOFcluster",10000), *clusters=&dummy;
649 branch->SetAddress(&clusters);
652 Int_t nc=clusters->GetEntriesFast();
653 AliInfo(Form("Number of clusters: %d",nc));
655 for (Int_t i=0; i<nc; i++) {
656 AliTOFcluster *c=(AliTOFcluster*)clusters->UncheckedAt(i);
658 for (Int_t jj=0; jj<5; jj++) dig[jj]=c->GetDetInd(jj);
668 for (Int_t jj=0; jj<3; jj++) indexDig[jj] = c->GetLabel(jj);
670 AliTOFcluster *cl=new AliTOFcluster(h,c->GetTracks(),dig,i);
673 // fClusters[i]=c; fN++;
674 fClusters[i]=new AliTOFcluster(*c); fN++;
676 //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)));
677 //AliInfo(Form("%i %f",i, fClusters[i]->GetZ()));
680 //AliInfo(Form("Number of clusters: %d",fN));
684 //_________________________________________________________________________
685 void AliTOFtrackerMI::UnloadClusters() {
686 //--------------------------------------------------------------------
687 //This function unloads TOF clusters
688 //--------------------------------------------------------------------
689 for (Int_t i=0; i<fN; i++) {
699 //_________________________________________________________________________
700 Int_t AliTOFtrackerMI::InsertCluster(AliTOFcluster *c) {
701 //--------------------------------------------------------------------
702 //This function adds a cluster to the array of clusters sorted in Z
703 //--------------------------------------------------------------------
704 if (fN==kMaxCluster) {
705 Error("InsertCluster","Too many clusters !\n");
709 if (fN==0) {fClusters[fN++]=c; return 0;}
710 Int_t i=FindClusterIndex(c->GetZ());
711 memmove(fClusters+i+1 ,fClusters+i,(fN-i)*sizeof(AliTOFcluster*));
712 fClusters[i]=c; fN++;
717 //_________________________________________________________________________
718 Int_t AliTOFtrackerMI::FindClusterIndex(Double_t z) const {
719 //--------------------------------------------------------------------
720 // This function returns the index of the nearest cluster
721 //--------------------------------------------------------------------
723 if (z <= fClusters[0]->GetZ()) return 0;
724 if (z > fClusters[fN-1]->GetZ()) return fN;
725 Int_t b=0, e=fN-1, m=(b+e)/2;
726 for (; b<e; m=(b+e)/2) {
727 if (z > fClusters[m]->GetZ()) b=m+1;
735 Float_t AliTOFtrackerMI::GetLinearDistances(AliTOFtrack * track, AliTOFcluster *cluster, Float_t distances[5])
738 // calclates distance between cluster and track
739 // use linear aproximation
741 const Float_t kRaddeg = 180/3.14159265358979312;
743 // Float_t tiltangle = fGeom->GetAngles(cluster->fdetIndex[1],cluster->fdetIndex[2])/kRaddeg; //tiltangle
745 cind[0]= cluster->GetDetInd(0);
746 cind[1]= cluster->GetDetInd(1);
747 cind[2]= cluster->GetDetInd(2);
748 cind[3]= cluster->GetDetInd(3);
749 cind[4]= cluster->GetDetInd(4);
750 Float_t tiltangle = fGeom->GetAngles(cluster->GetDetInd(1),cluster->GetDetInd(2))/kRaddeg; //tiltangle
752 Float_t cpos[3]; //cluster position
753 Float_t cpos0[3]; //cluster position
754 // fGeom->GetPos(cluster->fdetIndex,cpos);
755 //fGeom->GetPos(cluster->fdetIndex,cpos0);
757 fGeom->GetPos(cind,cpos);
758 fGeom->GetPos(cind,cpos0);
760 Float_t phi = TMath::ATan2(cpos[1],cpos[0]);
761 if(phi<0) phi=2.*TMath::Pi()+phi;
762 // Get the local angle in the sector philoc
763 Float_t phiangle = (Int_t (phi*kRaddeg/20.) + 0.5)*20./kRaddeg;
767 track->GetGlobalXYZ(v0[0],v0[1],v0[2]);
768 track->GetPxPyPz(dir[0],dir[1],dir[2]);
769 dir[0]/=track->GetP();
770 dir[1]/=track->GetP();
771 dir[2]/=track->GetP();
775 Float_t sinphi = TMath::Sin(phiangle);
776 Float_t cosphi = TMath::Cos(phiangle);
777 Float_t sinth = TMath::Sin(tiltangle);
778 Float_t costh = TMath::Cos(tiltangle);
781 temp = cpos[0]*cosphi+cpos[1]*sinphi;
782 cpos[1] = -cpos[0]*sinphi+cpos[1]*cosphi;
784 temp = v0[0]*cosphi+v0[1]*sinphi;
785 v0[1] = -v0[0]*sinphi+v0[1]*cosphi;
788 temp = cpos[0]*costh+cpos[2]*sinth;
789 cpos[2] = -cpos[0]*sinth+cpos[2]*costh;
791 temp = v0[0]*costh+v0[2]*sinth;
792 v0[2] = -v0[0]*sinth+v0[2]*costh;
796 //rotate direction vector
798 temp = dir[0]*cosphi+dir[1]*sinphi;
799 dir[1] = -dir[0]*sinphi+dir[1]*cosphi;
802 temp = dir[0]*costh+dir[2]*sinth;
803 dir[2] = -dir[0]*sinth+dir[2]*costh;
807 Float_t k = (cpos[0]-v0[0])/dir[0];
808 v3[0] = v0[0]+k*dir[0];
809 v3[1] = v0[1]+k*dir[1];
810 v3[2] = v0[2]+k*dir[2];
812 distances[0] = v3[0]-cpos[0];
813 distances[1] = v3[1]-cpos[1];
814 distances[2] = v3[2]-cpos[2];
815 distances[3] = TMath::Sqrt( distances[0]*distances[0]+distances[1]*distances[1]+distances[2]*distances[2]); //distance
816 distances[4] = k; //length
819 // Debuging part of the matching
821 if (track->GetLabel()==cluster->GetLabel(0) ||track->GetLabel()==cluster->GetLabel(1) ){
822 TTreeSRedirector& cstream = *fDebugStreamer;
823 Float_t tdc = cluster->GetTDC();
830 "Dist0="<<distances[0]<<
831 "Dist1="<<distances[1]<<
832 "Dist2="<<distances[2]<<
841 void AliTOFtrackerMI::GetLikelihood(Float_t dy, Float_t dz, const Double_t *cov, AliTOFtrack * /*track*/, Float_t & py, Float_t &pz)
844 // get likelihood - track covariance taken
845 // 75 % of gauss with expected sigma
846 // 25 % of gauss with extended sigma
848 Double_t kMaxSigmaY = 0.6; // ~ 90% of TRD tracks
849 Double_t kMaxSigmaZ = 1.2; // ~ 90% of TRD tracks
850 Double_t kMeanSigmaY = 0.25; // mean TRD sigma
851 Double_t kMeanSigmaZ = 0.5; // mean TRD sigma
854 Float_t normwidth, normd, p0,p1;
855 Float_t sigmay = TMath::Max(TMath::Sqrt(cov[0]+kMeanSigmaY*kMeanSigmaY),kMaxSigmaY);
856 Float_t sigmaz = TMath::Max(TMath::Sqrt(cov[2]+kMeanSigmaZ*kMeanSigmaZ),kMaxSigmaZ);
861 // py calculation - 75% admixture of original sigma - 25% tails
863 normwidth = fDy/sigmay;
865 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
866 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
869 normwidth = fDy/(3.*sigmay);
870 normd = dy/(3.*sigmay);
871 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
872 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
875 // pz calculation - 75% admixture of original sigma - 25% tails
877 normwidth = fDz/sigmaz;
879 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
880 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));
883 normwidth = fDz/(3.*sigmaz);
884 normd = dz/(3.*sigmaz);
885 p0 = 0.5*(1+TMath::Erf(normd-normwidth*0.5));
886 p1 = 0.5*(1+TMath::Erf(normd+normwidth*0.5));