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(const 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(const AliAODTrack *track,Double_t *p) const
71 // TPC pid using bethe-bloch and gaussian response
74 if ((track->GetStatus()&AliESDtrack::kTPCin )==0) return;
76 AliAODPid *pidObj = track->GetDetPid();
77 Double_t mom = track->P();
79 UShort_t nTPCClus = 0;
81 nTPCClus = pidObj->GetTPCsignalN();
82 dedx = pidObj->GetTPCsignal();
83 mom = pidObj->GetTPCmomentum();
86 Bool_t mismatch=kTRUE;
88 for (Int_t j=0; j<AliPID::kSPECIES; j++) {
89 AliPID::EParticleType type=AliPID::EParticleType(j);
90 Double_t bethe=fTPCResponse.GetExpectedSignal(mom,type);
91 Double_t sigma=fTPCResponse.GetExpectedSigma(mom,nTPCClus,type);
92 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
93 p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
95 p[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
102 for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1./AliPID::kSPECIES;
107 //_________________________________________________________________________
108 void AliAODpidUtil::MakeITSPID(const AliAODTrack *track,Double_t *p) const
112 // 1) Truncated mean method
116 if ((track->GetStatus()&AliESDtrack::kITSin)==0) return;
117 UChar_t clumap=track->GetITSClusterMap();
118 Int_t nPointsForPid=0;
119 for(Int_t i=2; i<6; i++){
120 if(clumap&(1<<i)) ++nPointsForPid;
122 if(nPointsForPid<3) { // track not to be used for combined PID purposes
123 for (Int_t j=0; j<AliPID::kSPECIES; j++)
124 p[j] = 1./AliPID::kSPECIES;
127 Double_t mom=track->P();
128 AliAODPid *pidObj = track->GetDetPid();
132 dedx = pidObj->GetITSsignal();
135 Bool_t mismatch = kTRUE;
137 if(track->GetStatus() & AliESDtrack::kTPCin){
140 mom = pidObj->GetTPCmomentum();
142 for (Int_t j=0; j<AliPID::kSPECIES; j++) {
143 Double_t mass = AliPID::ParticleMass(j);//GeV/c^2
144 Double_t bethe = fITSResponse.Bethe(mom,mass);
145 Double_t sigma = fITSResponse.GetResolution(bethe,nPointsForPid,isSA);
146 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
147 p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
149 p[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
153 // Check for particles heavier than (AliPID::kSPECIES - 1)
158 for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1./AliPID::kSPECIES;
163 //_________________________________________________________________________
164 void AliAODpidUtil::MakeTOFPID(const AliAODTrack *track, Double_t *p) const
167 // TOF PID using gaussian response
169 if ((track->GetStatus()&AliESDtrack::kTOFout )==0) return;
170 if ((track->GetStatus()&AliESDtrack::kTIME )==0) return;
171 if ((track->GetStatus()&AliESDtrack::kTOFpid )==0) return;
173 Double_t time[AliPID::kSPECIESN];
174 Double_t sigma[AliPID::kSPECIESN];
175 AliAODPid *pidObj = track->GetDetPid();
176 pidObj->GetIntegratedTimes(time);
178 for (Int_t iPart = 0; iPart < AliPID::kSPECIES; iPart++) {
179 sigma[iPart] = fTOFResponse.GetExpectedSigma(track->P(),time[iPart],AliPID::ParticleMass(iPart));
182 AliDebugGeneral("AliESDpid::MakeTOFPID",2,
183 Form("Expected TOF signals [ps]: %f %f %f %f %f",
184 time[AliPID::kElectron],
188 time[AliPID::kProton]));
190 AliDebugGeneral("AliESDpid::MakeTOFPID",2,
191 Form("Expected TOF std deviations [ps]: %f %f %f %f %f",
192 sigma[AliPID::kElectron],
193 sigma[AliPID::kMuon],
194 sigma[AliPID::kPion],
195 sigma[AliPID::kKaon],
196 sigma[AliPID::kProton]
199 Double_t tof = pidObj->GetTOFsignal();
201 Bool_t mismatch = kTRUE;
202 for (Int_t j=0; j<AliPID::kSPECIES; j++) {
203 Double_t sig = sigma[j];
204 if (TMath::Abs(tof-time[j]) > fRange*sig) {
205 p[j] = TMath::Exp(-0.5*fRange*fRange)/sig;
207 p[j] = TMath::Exp(-0.5*(tof-time[j])*(tof-time[j])/(sig*sig))/sig;
209 // Check the mismatching
210 Double_t mass = AliPID::ParticleMass(j);
211 Double_t pm = fTOFResponse.GetMismatchProbability(track->P(),mass);
212 if (p[j]>pm) mismatch = kFALSE;
214 // Check for particles heavier than (AliPID::kSPECIES - 1)
219 for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1./AliPID::kSPECIES;
223 //_________________________________________________________________________
224 void AliAODpidUtil::MakeTRDPID(const AliAODTrack *track,Double_t *p) const
226 ComputeTRDProbability(track, AliPID::kSPECIES, p);