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;
76 Double_t mom = track->P();
77 AliAODPid *pidObj = track->GetDetPid();
78 if (pidObj) mom = pidObj->GetTPCmomentum();
79 UShort_t nTPCClus=pidObj->GetTPCsignalN();
82 if (pidObj) dedx = pidObj->GetTPCsignal();
83 Bool_t mismatch=kTRUE;
85 for (Int_t j=0; j<AliPID::kSPECIES; j++) {
86 AliPID::EParticleType type=AliPID::EParticleType(j);
87 Double_t bethe=fTPCResponse.GetExpectedSignal(mom,type);
88 Double_t sigma=fTPCResponse.GetExpectedSigma(mom,nTPCClus,type);
89 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
90 p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
92 p[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
99 for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1/AliPID::kSPECIES;
104 //_________________________________________________________________________
105 void AliAODpidUtil::MakeITSPID(AliAODTrack *track,Double_t *p) const
109 // 1) Truncated mean method
113 if ((track->GetStatus()&AliESDtrack::kITSin)==0) return;
114 UChar_t clumap=track->GetITSClusterMap();
115 Int_t nPointsForPid=0;
116 for(Int_t i=2; i<6; i++){
117 if(clumap&(1<<i)) ++nPointsForPid;
119 if(nPointsForPid<3) { // track not to be used for combined PID purposes
120 for (Int_t j=0; j<AliPID::kSPECIES; j++)
121 p[j] = 1./AliPID::kSPECIES;
124 Double_t mom=track->P();
125 AliAODPid *pidObj = track->GetDetPid();
129 dedx = pidObj->GetITSsignal();
132 Bool_t mismatch = kTRUE;
134 if(track->GetStatus() & AliESDtrack::kTPCin){
137 mom = pidObj->GetTPCmomentum();
139 for (Int_t j=0; j<AliPID::kSPECIES; j++) {
140 Double_t mass = AliPID::ParticleMass(j);//GeV/c^2
141 Double_t bethe = fITSResponse.Bethe(mom,mass);
142 Double_t sigma = fITSResponse.GetResolution(bethe,nPointsForPid,isSA);
143 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
144 p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
146 p[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
150 // Check for particles heavier than (AliPID::kSPECIES - 1)
155 for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1./AliPID::kSPECIES;
160 //_________________________________________________________________________
161 void AliAODpidUtil::MakeTOFPID(AliAODTrack *track, Double_t *p) const
164 // TOF PID using gaussian response
166 if ((track->GetStatus()&AliESDtrack::kTOFout )==0) return;
167 if ((track->GetStatus()&AliESDtrack::kTIME )==0) return;
168 if ((track->GetStatus()&AliESDtrack::kTOFpid )==0) return;
170 Double_t time[AliPID::kSPECIESN];
171 Double_t sigma[AliPID::kSPECIESN];
172 AliAODPid *pidObj = track->GetDetPid();
173 pidObj->GetIntegratedTimes(time);
175 for (Int_t iPart = 0; iPart < AliPID::kSPECIES; iPart++) {
176 sigma[iPart] = fTOFResponse.GetExpectedSigma(track->P(),time[iPart],AliPID::ParticleMass(iPart));
179 AliDebugGeneral("AliESDpid::MakeTOFPID",2,
180 Form("Expected TOF signals [ps]: %f %f %f %f %f",
181 time[AliPID::kElectron],
185 time[AliPID::kProton]));
187 AliDebugGeneral("AliESDpid::MakeTOFPID",2,
188 Form("Expected TOF std deviations [ps]: %f %f %f %f %f",
189 sigma[AliPID::kElectron],
190 sigma[AliPID::kMuon],
191 sigma[AliPID::kPion],
192 sigma[AliPID::kKaon],
193 sigma[AliPID::kProton]
196 Double_t tof = pidObj->GetTOFsignal();
198 Bool_t mismatch = kTRUE;
199 for (Int_t j=0; j<AliPID::kSPECIES; j++) {
200 Double_t sig = sigma[j];
201 if (TMath::Abs(tof-time[j]) > fRange*sig) {
202 p[j] = TMath::Exp(-0.5*fRange*fRange)/sig;
204 p[j] = TMath::Exp(-0.5*(tof-time[j])*(tof-time[j])/(sig*sig))/sig;
206 // Check the mismatching
207 Double_t mass = AliPID::ParticleMass(j);
208 Double_t pm = fTOFResponse.GetMismatchProbability(track->P(),mass);
209 if (p[j]>pm) mismatch = kFALSE;
211 // Check for particles heavier than (AliPID::kSPECIES - 1)
216 for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1/AliPID::kSPECIES;
220 //_________________________________________________________________________
221 void AliAODpidUtil::MakeTRDPID(AliAODTrack *track,Double_t *p) const
224 // Method to recalculate the TRD PID probabilities
225 if ((track->GetStatus()&AliESDtrack::kTRDout )==0) return;
227 AliAODPid *pidObj = track->GetDetPid();
228 Float_t *mom=pidObj->GetTRDmomentum();
230 for(Int_t iPl=0;iPl<6;iPl++){
231 if(mom[iPl]>0.) ntracklets++;
233 if(ntracklets<4) return;
235 Double_t* dedx=pidObj->GetTRDsignal();
237 fTRDResponse.GetResponse(pidObj->GetTRDnSlices(),dedx,mom,p,norm);