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 /* $Id: AliAODpidUtil.cxx 38329 2010-01-17 19:17:24Z hristov $ */
18 //-----------------------------------------------------------------
19 // Implementation of the combined PID class
21 // containing information on the particle identification
22 // Origin: Rosa Romita, GSI, r.romita@gsi.de
23 //-----------------------------------------------------------------
27 #include "AliAODpidUtil.h"
28 #include "AliAODEvent.h"
29 #include "AliAODTrack.h"
30 #include "AliAODPid.h"
31 #include "AliTRDPIDResponse.h"
32 #include "AliESDtrack.h"
34 ClassImp(AliAODpidUtil)
36 Int_t AliAODpidUtil::MakePID(AliAODTrack *track,Double_t *p) const {
38 // Calculate probabilities for all detectors, except if TPConly==kTRUE
41 // Option TPConly==kTRUE is used during reconstruction,
42 // because ITS tracking uses TPC pid
43 // HMPID and TRD pid are done in detector reconstructors
47 Float_t TimeZeroTOF = 0;
49 TimeZeroTOF = event->GetT0();
51 Int_t ns=AliPID::kSPECIES;
52 Double_t tpcPid[AliPID::kSPECIES];
53 MakeTPCPID(track,tpcPid);
54 Double_t itsPid[AliPID::kSPECIES];
55 Double_t tofPid[AliPID::kSPECIES];
56 Double_t trdPid[AliPID::kSPECIES];
57 MakeITSPID(track,itsPid);
58 MakeTOFPID(track,tofPid);
59 //MakeHMPIDPID(track);
60 MakeTRDPID(track,trdPid);
61 for (Int_t j=0; j<ns; j++) {
62 p[j]=tpcPid[j]*itsPid[j]*tofPid[j]*trdPid[j];
67 //_________________________________________________________________________
68 void AliAODpidUtil::MakeTPCPID(AliAODTrack *track,Double_t *p) const
71 // TPC pid using bethe-bloch and gaussian response
74 if ((track->GetStatus()&AliESDtrack::kTPCin )==0) return;
75 UShort_t nTPCClus=track->GetTPCNcls();
77 Double_t mom = track->P();
78 AliAODPid *pidObj = track->GetDetPid();
79 if (pidObj) mom = pidObj->GetTPCmomentum();
81 Double_t dedx=pidObj->GetTPCsignal();
82 Bool_t mismatch=kTRUE;
84 for (Int_t j=0; j<AliPID::kSPECIES; j++) {
85 AliPID::EParticleType type=AliPID::EParticleType(j);
86 Double_t bethe=fTPCResponse.GetExpectedSignal(mom,type);
87 Double_t sigma=fTPCResponse.GetExpectedSigma(mom,nTPCClus,type);
88 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
89 p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
91 p[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
98 for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1/AliPID::kSPECIES;
103 //_________________________________________________________________________
104 void AliAODpidUtil::MakeITSPID(AliAODTrack *track,Double_t *p) const
108 // 1) Truncated mean method
112 if ((track->GetStatus()&AliESDtrack::kITSin)==0) return;
113 UChar_t clumap=track->GetITSClusterMap();
114 Int_t nPointsForPid=0;
115 for(Int_t i=2; i<6; i++){
116 if(clumap&(1<<i)) ++nPointsForPid;
118 if(nPointsForPid<3) return;// track not to be used for PID purposes
120 Double_t mom=track->P();
121 AliAODPid *pidObj = track->GetDetPid();
123 Double_t dedx=pidObj->GetITSsignal();
124 Bool_t mismatch=kTRUE;
125 for (Int_t j=0; j<AliPID::kSPECIES; j++) {
126 Double_t mass=AliPID::ParticleMass(j);//GeV/c^2
127 Double_t bethe=fITSResponse.Bethe(mom,mass);
128 Double_t sigma=fITSResponse.GetResolution(bethe);
129 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
130 p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
132 p[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
136 // Check for particles heavier than (AliPID::kSPECIES - 1)
141 for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1./AliPID::kSPECIES;
146 //_________________________________________________________________________
147 void AliAODpidUtil::MakeTOFPID(AliAODTrack *track, Double_t *p) const
150 // TOF PID using gaussian response
152 if ((track->GetStatus()&AliESDtrack::kTOFout )==0) return;
153 if ((track->GetStatus()&AliESDtrack::kTIME )==0) return;
154 if ((track->GetStatus()&AliESDtrack::kTOFpid )==0) return;
156 Double_t time[AliPID::kSPECIESN];
157 Double_t sigma[AliPID::kSPECIESN];
158 AliAODPid *pidObj = track->GetDetPid();
159 pidObj->GetIntegratedTimes(time);
161 for (Int_t iPart = 0; iPart < AliPID::kSPECIES; iPart++) {
162 sigma[iPart] = fTOFResponse.GetExpectedSigma(track->P(),time[iPart],AliPID::ParticleMass(iPart));
165 AliDebugGeneral("AliESDpid::MakeTOFPID",2,
166 Form("Expected TOF signals [ps]: %f %f %f %f %f",
167 time[AliPID::kElectron],
171 time[AliPID::kProton]));
173 AliDebugGeneral("AliESDpid::MakeTOFPID",2,
174 Form("Expected TOF std deviations [ps]: %f %f %f %f %f",
175 sigma[AliPID::kElectron],
176 sigma[AliPID::kMuon],
177 sigma[AliPID::kPion],
178 sigma[AliPID::kKaon],
179 sigma[AliPID::kProton]
182 Double_t tof = pidObj->GetTOFsignal();
184 Bool_t mismatch = kTRUE;
185 for (Int_t j=0; j<AliPID::kSPECIES; j++) {
186 Double_t sig = sigma[j];
187 if (TMath::Abs(tof-time[j]) > fRange*sig) {
188 p[j] = TMath::Exp(-0.5*fRange*fRange)/sig;
190 p[j] = TMath::Exp(-0.5*(tof-time[j])*(tof-time[j])/(sig*sig))/sig;
192 // Check the mismatching
193 Double_t mass = AliPID::ParticleMass(j);
194 Double_t pm = fTOFResponse.GetMismatchProbability(track->P(),mass);
195 if (p[j]>pm) mismatch = kFALSE;
197 // Check for particles heavier than (AliPID::kSPECIES - 1)
202 for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1/AliPID::kSPECIES;
206 //_________________________________________________________________________
207 void AliAODpidUtil::MakeTRDPID(AliAODTrack *track,Double_t *p) const
210 // Method to recalculate the TRD PID probabilities
211 if ((track->GetStatus()&AliESDtrack::kTRDout )==0) return;
213 AliAODPid *pidObj = track->GetDetPid();
214 Float_t *mom=pidObj->GetTRDmomentum();
216 for(Int_t iPl=0;iPl<6;iPl++){
217 if(mom[iPl]>0.) ntracklets++;
219 if(ntracklets<4) return;
221 Double_t* dedx=pidObj->GetTRDsignal();
223 fTRDResponse.GetResponse(pidObj->GetTRDnSlices(),dedx,mom,p,norm);