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 **************************************************************************/
18 //-----------------------------------------------------------------
19 // Implementation of the combined PID class
20 // For the Event Summary Data Class
21 // produced by the reconstruction process
22 // and containing information on the particle identification
23 // Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
24 //-----------------------------------------------------------------
28 #include "AliESDpid.h"
29 #include "AliESDEvent.h"
30 #include "AliESDtrack.h"
34 Int_t AliESDpid::MakePID(AliESDEvent *event, Bool_t TPConly, Float_t TimeZeroTOF) const {
36 // Calculate probabilities for all detectors, except if TPConly==kTRUE
39 // Option TPConly==kTRUE is used during reconstruction,
40 // because ITS tracking uses TPC pid
41 // HMPID and TRD pid are done in detector reconstructors
45 Float_t TimeZeroTOF = 0;
47 TimeZeroTOF = event->GetT0();
49 Int_t nTrk=event->GetNumberOfTracks();
50 for (Int_t iTrk=0; iTrk<nTrk; iTrk++) {
51 AliESDtrack *track=event->GetTrack(iTrk);
55 MakeTOFPID(track, TimeZeroTOF);
56 //MakeHMPIDPID(track);
63 //_________________________________________________________________________
64 void AliESDpid::MakeTPCPID(AliESDtrack *track) const
67 // TPC pid using bethe-bloch and gaussian response
69 if ((track->GetStatus()&AliESDtrack::kTPCin )==0)
70 if ((track->GetStatus()&AliESDtrack::kTPCout)==0) return;
72 Double_t mom = track->GetP();
73 const AliExternalTrackParam *in=track->GetInnerParam();
74 if (in) mom = in->GetP();
76 Double_t p[AliPID::kSPECIES];
77 Double_t dedx=track->GetTPCsignal();
78 Bool_t mismatch=kTRUE, heavy=kTRUE;
80 for (Int_t j=0; j<AliPID::kSPECIES; j++) {
81 AliPID::EParticleType type=AliPID::EParticleType(j);
82 Double_t bethe=fTPCResponse.GetExpectedSignal(mom,type);
83 Double_t sigma=fTPCResponse.GetExpectedSigma(mom,track->GetTPCsignalN(),type);
84 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
85 p[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
87 p[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
91 // Check for particles heavier than (AliPID::kSPECIES - 1)
92 if (dedx < (bethe + fRange*sigma)) heavy=kFALSE;
97 for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1/AliPID::kSPECIES;
101 if (heavy) track->ResetStatus(AliESDtrack::kTPCpid);
104 //_________________________________________________________________________
105 void AliESDpid::MakeITSPID(AliESDtrack *track) const
109 // Two options, depending on fITSPIDmethod:
110 // 1) Truncated mean method
111 // 2) Likelihood, using charges measured in all 4 layers and
112 // Landau+gaus response functions
115 if ((track->GetStatus()&AliESDtrack::kITSin)==0 &&
116 (track->GetStatus()&AliESDtrack::kITSout)==0) return;
118 Double_t mom=track->GetP();
119 if (fITSPIDmethod == kITSTruncMean) {
120 Double_t dedx=track->GetITSsignal();
123 ULong_t trStatus=track->GetStatus();
124 if(trStatus&AliESDtrack::kTPCin) isSA=kFALSE;
125 UChar_t clumap=track->GetITSClusterMap();
126 Int_t nPointsForPid=0;
127 for(Int_t i=2; i<6; i++){
128 if(clumap&(1<<i)) ++nPointsForPid;
131 if(nPointsForPid<3) { // track not to be used for combined PID purposes
132 track->ResetStatus(AliESDtrack::kITSpid);
138 Bool_t mismatch=kTRUE, heavy=kTRUE;
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(momITS,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)
151 if (dedx < (bethe + fRange*sigma)) heavy=kFALSE;
156 for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1./AliPID::kSPECIES;
160 if (heavy) track->ResetStatus(AliESDtrack::kITSpid);
162 else { // Likelihood method
163 Double_t condprobfun[AliPID::kSPECIES];
165 track->GetITSdEdxSamples(qclu);
166 fITSResponse.GetITSProbabilities(mom,qclu,condprobfun);
167 track->SetITSpid(condprobfun);
171 //_________________________________________________________________________
172 void AliESDpid::MakeTOFPID(AliESDtrack *track, Float_t TimeZeroTOF) const
175 // TOF PID using gaussian response
177 if ((track->GetStatus()&AliESDtrack::kTOFout)==0) return;
178 if ((track->GetStatus()&AliESDtrack::kTIME)==0) return;
180 Double_t time[AliPID::kSPECIESN];
181 track->GetIntegratedTimes(time);
183 Double_t sigma[AliPID::kSPECIES];
184 for (Int_t iPart = 0; iPart < AliPID::kSPECIES; iPart++) {
185 sigma[iPart] = fTOFResponse.GetExpectedSigma(track->GetP(),time[iPart],AliPID::ParticleMass(iPart));
188 AliDebugGeneral("AliESDpid::MakeTOFPID",2,
189 Form("Expected TOF signals [ps]: %f %f %f %f %f",
190 time[AliPID::kElectron],
194 time[AliPID::kProton]));
196 AliDebugGeneral("AliESDpid::MakeTOFPID",2,
197 Form("Expected TOF std deviations [ps]: %f %f %f %f %f",
198 sigma[AliPID::kElectron],
199 sigma[AliPID::kMuon],
200 sigma[AliPID::kPion],
201 sigma[AliPID::kKaon],
202 sigma[AliPID::kProton]
205 Double_t tof = track->GetTOFsignal() - TimeZeroTOF;
207 Double_t p[AliPID::kSPECIES];
208 Bool_t mismatch = kTRUE, heavy = kTRUE;
209 for (Int_t j=0; j<AliPID::kSPECIES; j++) {
210 Double_t sig = sigma[j];
211 if (TMath::Abs(tof-time[j]) > fRange*sig) {
212 p[j] = TMath::Exp(-0.5*fRange*fRange)/sig;
214 p[j] = TMath::Exp(-0.5*(tof-time[j])*(tof-time[j])/(sig*sig))/sig;
216 // Check the mismatching
217 Double_t mass = AliPID::ParticleMass(j);
218 Double_t pm = fTOFResponse.GetMismatchProbability(track->GetP(),mass);
219 if (p[j]>pm) mismatch = kFALSE;
221 // Check for particles heavier than (AliPID::kSPECIES - 1)
222 if (tof < (time[j] + fRange*sig)) heavy=kFALSE;
227 for (Int_t j=0; j<AliPID::kSPECIES; j++) p[j]=1/AliPID::kSPECIES;
231 if (heavy) track->ResetStatus(AliESDtrack::kTOFpid);
233 //_________________________________________________________________________
234 void AliESDpid::MakeTRDPID(AliESDtrack *track) const
237 // Method to recalculate the TRD PID probabilities
239 if((track->GetStatus()&AliESDtrack::kTRDout)==0) return;
240 Double_t prob[AliPID::kSPECIES]; Float_t mom[6];
241 Double_t dedx[48]; // Allocate space for the maximum number of TRD slices
242 for(Int_t ilayer = 0; ilayer < 6; ilayer++){
243 mom[ilayer] = track->GetTRDmomentum(ilayer);
244 for(Int_t islice = 0; islice < track->GetNumberOfTRDslices(); islice++){
245 dedx[ilayer*track->GetNumberOfTRDslices()+islice] = track->GetTRDslice(ilayer, islice);
248 fTRDResponse.GetResponse(track->GetNumberOfTRDslices(), dedx, mom, prob);
249 track->SetTRDpid(prob);
251 //_________________________________________________________________________
252 void AliESDpid::CombinePID(AliESDtrack *track) const
255 // Combine the information of various detectors
256 // to determine the Particle Identification
258 Int_t ns=AliPID::kSPECIES;
259 Double_t p[10]={1.,1.,1.,1.,1.,1.,1.,1.,1.,1.};
261 if (track->IsOn(AliESDtrack::kITSpid)) {
264 for (Int_t j=0; j<ns; j++) p[j]*=d[j];
267 if (track->IsOn(AliESDtrack::kTPCpid)) {
270 for (Int_t j=0; j<ns; j++) p[j]*=d[j];
273 if (track->IsOn(AliESDtrack::kTRDpid)) {
276 for (Int_t j=0; j<ns; j++) p[j]*=d[j];
279 if (track->IsOn(AliESDtrack::kTOFpid)) {
282 for (Int_t j=0; j<ns; j++) p[j]*=d[j];
285 if (track->IsOn(AliESDtrack::kHMPIDpid)) {
287 track->GetHMPIDpid(d);
288 for (Int_t j=0; j<ns; j++) p[j]*=d[j];