Fix in impact parameter units
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliAODPidHF.cxx
CommitLineData
7ce8802c 1/**************************************************************************
2 * Copyright(c) 1998-2006, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
7 *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 * *************************************************************************/
16
27de2dfb 17/* $Id$ */
18
7ce8802c 19//***********************************************************
20// Class AliAODPidHF
21// class for PID with AliAODRecoDecayHF
b257e565 22// Authors: D. Caffarri caffarri@pd.infn.it, A.Dainese andrea.dainese@pd.infn.it, S. Dash dash@to.infn.it, F. Prino prino@to.infn.it, R. Romita r.romita@gsi.de, Y. Wang yifei@pi0.physi.uni-heidelberg.de P. Antonioli pietro.antonioli@bo.infn.it
7ce8802c 23//***********************************************************
24#include "AliAODPidHF.h"
25#include "AliAODPid.h"
7ce8802c 26#include "AliPID.h"
b79bfc3e 27#include "AliPIDResponse.h"
7ce8802c 28#include "AliAODpidUtil.h"
f9e3cf8e 29#include "AliESDtrack.h"
7ce8802c 30
31
32ClassImp(AliAODPidHF)
33
34//------------------------------
35AliAODPidHF::AliAODPidHF():
228f3aba 36 AliAODPid(),
37 fnNSigma(5),
38 fnSigma(),
39 fTOFSigma(160.),
40 fnPriors(5),
41 fPriors(),
42 fnPLimit(2),
43 fPLimit(),
cdac45d3 44 fAsym(kFALSE),
45 fTPC(kFALSE),
46 fTOF(kFALSE),
47 fITS(kFALSE),
48 fTRD(kFALSE),
79f3c225 49 fMatch(0),
913d1957 50 fCompat(kFALSE),
ad42e35b 51 fPCompatTOF(1.5),
02baac36 52 fnNSigmaCompat(2),
ad42e35b 53 fnSigmaCompat(),
12141139 54 fMC(kFALSE),
17c4a8d5 55 fOnePad(kFALSE),
5821ea5b 56 fMCLowEn2011(kFALSE),
439d61b7 57 fPbPb(kFALSE),
b79bfc3e 58 fTOFdecide(kFALSE),
2c9eefd4 59 fOldPid(kTRUE),
60 fPtThresholdTPC(999999.),
11690a06 61 fPidResponse(0),
62 fPidCombined(new AliPIDCombined())
7ce8802c 63{
64 //
65 // Default constructor
66 //
228f3aba 67 fPLimit=new Double_t[fnPLimit];
68 fnSigma=new Double_t[fnNSigma];
69 fPriors=new Double_t[fnPriors];
02baac36 70 fnSigmaCompat=new Double_t[fnNSigmaCompat];
228f3aba 71
72 for(Int_t i=0;i<fnNSigma;i++){
73 fnSigma[i]=0.;
74 }
75 for(Int_t i=0;i<fnPriors;i++){
76 fPriors[i]=0.;
77 }
78 for(Int_t i=0;i<fnPLimit;i++){
79 fPLimit[i]=0.;
80 }
02baac36 81 for(Int_t i=0;i<fnNSigmaCompat;i++){
ad42e35b 82 fnSigmaCompat[i]=3.;
83 }
7ce8802c 84
85}
86//----------------------
87AliAODPidHF::~AliAODPidHF()
88{
89 // destructor
228f3aba 90 // if(fPLimit) delete fPLimit;
91 // if(fnSigma) delete fnSigma;
92 // if(fPriors) delete fPriors;
7ce8802c 93}
94//------------------------
95AliAODPidHF::AliAODPidHF(const AliAODPidHF& pid) :
96 AliAODPid(pid),
228f3aba 97 fnNSigma(pid.fnNSigma),
98 fnSigma(pid.fnSigma),
99 fTOFSigma(pid.fTOFSigma),
100 fnPriors(pid.fnPriors),
101 fPriors(pid.fPriors),
102 fnPLimit(pid.fnPLimit),
103 fPLimit(pid.fPLimit),
cdac45d3 104 fAsym(pid.fAsym),
105 fTPC(pid.fTPC),
106 fTOF(pid.fTOF),
107 fITS(pid.fITS),
108 fTRD(pid.fTRD),
109 fMatch(pid.fMatch),
913d1957 110 fCompat(pid.fCompat),
ad42e35b 111 fPCompatTOF(pid.fPCompatTOF),
02baac36 112 fnNSigmaCompat(pid.fnNSigmaCompat),
ad42e35b 113 fnSigmaCompat(pid.fnSigmaCompat),
12141139 114 fMC(pid.fMC),
17c4a8d5 115 fOnePad(pid.fOnePad),
5821ea5b 116 fMCLowEn2011(pid.fMCLowEn2011),
439d61b7 117 fPbPb(pid.fPbPb),
b79bfc3e 118 fTOFdecide(pid.fTOFdecide),
119 fOldPid(pid.fOldPid),
2c9eefd4 120 fPtThresholdTPC(pid.fPtThresholdTPC),
11690a06 121 fPidResponse(pid.fPidResponse),
122 fPidCombined(pid.fPidCombined)
7ce8802c 123 {
124
125 for(Int_t i=0;i<5;i++){
126 fPriors[i]=pid.fPriors[i];
127 }
128
129 }
130
131//----------------------
228f3aba 132Int_t AliAODPidHF::RawSignalPID(AliAODTrack *track, TString detector) const{
133// raw PID for single detectors, returns the particle type with smaller sigma
f9e3cf8e 134 Int_t specie=-1;
135 if(detector.Contains("ITS")) return ApplyPidITSRaw(track,specie);
136 if(detector.Contains("TPC")) return ApplyPidTPCRaw(track,specie);
137 if(detector.Contains("TOF")) return ApplyPidTOFRaw(track,specie);
7ce8802c 138
f9e3cf8e 139 return specie;
7ce8802c 140
141}
142//---------------------------
228f3aba 143Bool_t AliAODPidHF::IsKaonRaw(AliAODTrack *track, TString detector) const{
144// checks if the track can be a kaon, raw PID applied for single detectors
7ce8802c 145 Int_t specie=0;
146
147 if(detector.Contains("ITS")) specie=ApplyPidITSRaw(track,3);
148 if(detector.Contains("TPC")) specie=ApplyPidTPCRaw(track,3);
149 if(detector.Contains("TOF")) specie=ApplyPidTOFRaw(track,3);
150
151 if(specie==3) return kTRUE;
152 return kFALSE;
153}
154//---------------------------
228f3aba 155Bool_t AliAODPidHF::IsPionRaw (AliAODTrack *track, TString detector) const{
156// checks if the track can be a pion, raw PID applied for single detectors
7ce8802c 157
158 Int_t specie=0;
159
160 if(detector.Contains("ITS")) specie=ApplyPidITSRaw(track,2);
161 if(detector.Contains("TPC")) specie=ApplyPidTPCRaw(track,2);
162 if(detector.Contains("TOF")) specie=ApplyPidTOFRaw(track,2);
163
164 if(specie==2) return kTRUE;
165 return kFALSE;
166}
167//---------------------------
228f3aba 168Bool_t AliAODPidHF::IsProtonRaw (AliAODTrack *track, TString detector) const{
169// checks if the track can be a proton raw PID applied for single detectors
7ce8802c 170
171 Int_t specie=0;
172 if(detector.Contains("ITS")) specie=ApplyPidITSRaw(track,4);
173 if(detector.Contains("TPC")) specie=ApplyPidTPCRaw(track,4);
174 if(detector.Contains("TOF")) specie=ApplyPidTOFRaw(track,4);
175
176 if(specie==4) return kTRUE;
177
178 return kFALSE;
179}
f9e3cf8e 180//--------------------------
228f3aba 181Bool_t AliAODPidHF::IsElectronRaw(AliAODTrack *track, TString detector) const{
182// checks if the track can be an electron raw PID applied for single detectors
f9e3cf8e 183
184 Int_t specie=-1;
185 if(detector.Contains("ITS")) specie=ApplyPidITSRaw(track,0);
186 if(detector.Contains("TPC")) specie=ApplyPidTPCRaw(track,0);
187 if(detector.Contains("TOF")) specie=ApplyPidTOFRaw(track,0);
188
189 if(specie==0) return kTRUE;
190
191 return kFALSE;
192}
193//--------------------------
228f3aba 194Int_t AliAODPidHF::ApplyPidTPCRaw(AliAODTrack *track,Int_t specie) const{
195// n-sigma cut, TPC PID
7ce8802c 196
cdac45d3 197 if(!CheckStatus(track,"TPC")) return 0;
b79bfc3e 198 Int_t pid=-1;
199 if(fOldPid){
7ce8802c 200 AliAODPid *pidObj = track->GetDetPid();
201
202 Double_t dedx=pidObj->GetTPCsignal();
203 Double_t mom = pidObj->GetTPCmomentum();
2c9eefd4 204 if(mom>fPtThresholdTPC) return 0;
7ce8802c 205 AliTPCPIDResponse tpcResponse;
12141139 206 SetBetheBloch(tpcResponse);
0aba57ed 207 UShort_t nTPCClus=pidObj->GetTPCsignalN();
208 if(nTPCClus==0) {nTPCClus=track->GetTPCNcls();}
12141139 209
f9e3cf8e 210 if(specie<0){ // from RawSignalPID : should return the particle specie to wich the de/dx is closer to the bethe-block curve -> performance to be checked
228f3aba 211 Double_t nsigmaMax=fnSigma[0];
f9e3cf8e 212 for(Int_t ipart=0;ipart<5;ipart++){
7ce8802c 213 AliPID::EParticleType type=AliPID::EParticleType(ipart);
0aba57ed 214 Double_t nsigma = TMath::Abs(tpcResponse.GetNumberOfSigmas(mom,dedx,nTPCClus,type));
228f3aba 215 if((nsigma<nsigmaMax) && (nsigma<fnSigma[0])) {
7ce8802c 216 pid=ipart;
217 nsigmaMax=nsigma;
218 }
219 }
220 }else{ // asks only for one particle specie
221 AliPID::EParticleType type=AliPID::EParticleType(specie);
0aba57ed 222 Double_t nsigma = TMath::Abs(tpcResponse.GetNumberOfSigmas(mom,dedx,nTPCClus,type));
228f3aba 223 if (nsigma>fnSigma[0]) {
f9e3cf8e 224 pid=-1;
7ce8802c 225 }else{
79f3c225 226 pid=specie;
7ce8802c 227 }
228 }
b79bfc3e 229 }else{ //old pid
230 if(specie<0){ // from RawSignalPID : should return the particle specie to wich the de/dx is closer to the bethe-block curve -> performance to be checked
231 Double_t nsigmaMax=fnSigma[0];
232 for(Int_t ipart=0;ipart<5;ipart++){
233 AliPID::EParticleType type=AliPID::EParticleType(ipart);
234 Double_t nsigma = TMath::Abs(fPidResponse->NumberOfSigmasTPC(track,type));
235 if((nsigma<nsigmaMax) && (nsigma<fnSigma[0])) {
236 pid=ipart;
237 nsigmaMax=nsigma;
238 }
239 }
240 }else{ // asks only for one particle specie
241 AliPID::EParticleType type=AliPID::EParticleType(specie);
242 Double_t nsigma = TMath::Abs(fPidResponse->NumberOfSigmasTPC(track,type));
243 if (nsigma>fnSigma[0]) {
244 pid=-1;
245 }else{
246 pid=specie;
247 }
248 }
249
250 } //new pid
7ce8802c 251
252 return pid;
253
254}
255//----------------------------
228f3aba 256Int_t AliAODPidHF::ApplyPidITSRaw(AliAODTrack *track,Int_t specie) const{
257// truncated mean, ITS PID
f9e3cf8e 258
cdac45d3 259 if(!CheckStatus(track,"ITS")) return 0;
b79bfc3e 260 Int_t pid=-1;
f9e3cf8e 261
b79bfc3e 262 if(fOldPid){
7ce8802c 263 Double_t mom=track->P();
264 AliAODPid *pidObj = track->GetDetPid();
265
266 Double_t dedx=pidObj->GetITSsignal();
913d1957 267 UChar_t clumap=track->GetITSClusterMap();
268 Int_t nPointsForPid=0;
269 for(Int_t i=2; i<6; i++){
270 if(clumap&(1<<i)) ++nPointsForPid;
271 }
272
273 Bool_t isSA=kTRUE;
274 if(track->GetStatus() & AliESDtrack::kTPCin) isSA = kFALSE;
275
7ce8802c 276 AliITSPIDResponse itsResponse;
f9e3cf8e 277 if(specie<0){ // from RawSignalPID : should return the particle specie to wich the de/dx is closer to the bethe-block curve -> performance to be checked
228f3aba 278 Double_t nsigmaMax=fnSigma[4];
f9e3cf8e 279 for(Int_t ipart=0;ipart<5;ipart++){
7ce8802c 280 AliPID::EParticleType type=AliPID::EParticleType(ipart);
913d1957 281 Double_t nsigma = TMath::Abs(itsResponse.GetNumberOfSigmas(mom,dedx,type,nPointsForPid,isSA));
228f3aba 282 if((nsigma<nsigmaMax) && (nsigma<fnSigma[4])) {
7ce8802c 283 pid=ipart;
284 nsigmaMax=nsigma;
285 }
286 }
287 }else{ // asks only for one particle specie
288 AliPID::EParticleType type=AliPID::EParticleType(specie);
289 Double_t nsigma = TMath::Abs(itsResponse.GetNumberOfSigmas(mom,dedx,type));
228f3aba 290 if (nsigma>fnSigma[4]) {
f9e3cf8e 291 pid=-1;
7ce8802c 292 }else{
79f3c225 293 pid=specie;
7ce8802c 294 }
295 }
b79bfc3e 296 }else{ // old pid
297
298 if(specie<0){ // from RawSignalPID : should return the particle specie to wich the de/dx is closer to the bethe-block curve -> performance to be checked
299 Double_t nsigmaMax=fnSigma[4];
300 for(Int_t ipart=0;ipart<5;ipart++){
301 AliPID::EParticleType type=AliPID::EParticleType(ipart);
302 Double_t nsigma = TMath::Abs(fPidResponse->NumberOfSigmasITS(track,type));
303 if((nsigma<nsigmaMax) && (nsigma<fnSigma[4])) {
304 pid=ipart;
305 nsigmaMax=nsigma;
306 }
307 }
308 }else{ // asks only for one particle specie
309 AliPID::EParticleType type=AliPID::EParticleType(specie);
310 Double_t nsigma = TMath::Abs(fPidResponse->NumberOfSigmasITS(track,type));
311 if (nsigma>fnSigma[4]) {
312 pid=-1;
313 }else{
314 pid=specie;
315 }
316 }
317 } //new pid
318
7ce8802c 319 return pid;
320}
321//----------------------------
228f3aba 322Int_t AliAODPidHF::ApplyPidTOFRaw(AliAODTrack *track,Int_t specie) const{
323// n-sigma cut, TOF PID
f9e3cf8e 324
cdac45d3 325 if(!CheckStatus(track,"TOF")) return 0;
f9e3cf8e 326
7ce8802c 327 Double_t time[AliPID::kSPECIESN];
b257e565 328 Double_t sigmaTOFPid[AliPID::kSPECIES];
7ce8802c 329 AliAODPid *pidObj = track->GetDetPid();
330 pidObj->GetIntegratedTimes(time);
228f3aba 331 Double_t sigTOF=pidObj->GetTOFsignal();
b257e565 332 pidObj->GetTOFpidResolution(sigmaTOFPid);
333
f9e3cf8e 334 Int_t pid=-1;
7ce8802c 335
b257e565 336 if(specie<0){
337 Double_t sigmaTOFtrack;
338 if (sigmaTOFPid[4]>0) sigmaTOFtrack=sigmaTOFPid[4];
339 else sigmaTOFtrack=fTOFSigma;
340 Double_t nsigmaMax=sigmaTOFtrack*fnSigma[3];
f9e3cf8e 341 for(Int_t ipart=0;ipart<5;ipart++){
228f3aba 342 Double_t nsigma=TMath::Abs(sigTOF-time[ipart]);
b257e565 343 if (sigmaTOFPid[ipart]>0) sigmaTOFtrack=sigmaTOFPid[ipart];
344 else sigmaTOFtrack=fTOFSigma; // backward compatibility for old AODs
345 if((nsigma<nsigmaMax) && (nsigma<fnSigma[3]*sigmaTOFtrack)) {
7ce8802c 346 pid=ipart;
347 nsigmaMax=nsigma;
348 }
349 }
350 }else{ // asks only for one particle specie
228f3aba 351 Double_t nsigma=TMath::Abs(sigTOF-time[specie]);
b257e565 352 Double_t sigmaTOFtrack;
353 if (sigmaTOFPid[specie]>0) sigmaTOFtrack=sigmaTOFPid[specie];
354 else sigmaTOFtrack=fTOFSigma; // backward compatibility for old AODs
355 if (nsigma>fnSigma[3]*sigmaTOFtrack) {
356 pid=-1;
357 }else{
358 pid=specie;
359 }
7ce8802c 360 }
361 return pid;
362
363}
364//------------------------------
228f3aba 365void AliAODPidHF::CombinedProbability(AliAODTrack *track,Bool_t *type) const{
366// combined PID stored inside the AOD track
7ce8802c 367
368 const Double_t *pid=track->PID();
369 Float_t max=0.;
370 Int_t k=-1;
371 for (Int_t i=0; i<10; i++) {
372 if (pid[i]>max) {k=i; max=pid[i];}
373 }
374
375 if(k==2) type[0]=kTRUE;
376 if(k==3) type[1]=kTRUE;
377 if(k==4) type[2]=kTRUE;
378
379 return;
380}
381//--------------------
cdac45d3 382void AliAODPidHF::BayesianProbability(AliAODTrack *track,Double_t *pid) const{
228f3aba 383// bayesian PID for single detectors or combined
7ce8802c 384
cdac45d3 385 if(fITS && !fTPC && !fTOF) {BayesianProbabilityITS(track,pid);return;}
386 if(fTPC && !fITS && !fTOF) {BayesianProbabilityTPC(track,pid);return;}
387 if(fTOF && !fITS && !fTPC) {BayesianProbabilityTOF(track,pid);return;}
388
389 Double_t probITS[5]={1.,1.,1.,1.,1.};
390 Double_t probTPC[5]={1.,1.,1.,1.,1.};
391 Double_t probTOF[5]={1.,1.,1.,1.,1.};
392 if(fITS) BayesianProbabilityITS(track,probITS);
393 if(fTPC) BayesianProbabilityTPC(track,probTPC);
394 if(fTOF) BayesianProbabilityTOF(track,probTOF);
7ce8802c 395 Double_t probTot[5]={0.,0.,0.,0.,0.};
396 for(Int_t i=0;i<5;i++){
397 probTot[i]=probITS[i]*probTPC[i]*probTOF[i];
398 }
399 for(Int_t i2=0;i2<5;i2++){
400 pid[i2]=probTot[i2]*fPriors[i2]/(probTot[0]*fPriors[0]+probTot[1]*fPriors[1]+probTot[2]*fPriors[2]+probTot[3]*fPriors[3]+probTot[4]*fPriors[4]);
401 }
7ce8802c 402
403 return;
404
405}
406//------------------------------------
228f3aba 407void AliAODPidHF::BayesianProbabilityITS(AliAODTrack *track,Double_t *prob) const{
7ce8802c 408
228f3aba 409// bayesian PID for ITS
7ce8802c 410 AliAODpidUtil pid;
411 Double_t itspid[AliPID::kSPECIES];
412 pid.MakeITSPID(track,itspid);
413 for(Int_t ind=0;ind<AliPID::kSPECIES;ind++){
369ad90e 414 if(fTOF || fTPC || fTRD){
415 prob[ind]=itspid[ind];
416 }else{
417 prob[ind]=itspid[ind]*fPriors[ind]/(itspid[0]*fPriors[0]+itspid[1]*fPriors[1]+itspid[2]*fPriors[2]+itspid[3]*fPriors[3]+itspid[4]*fPriors[4]);
418 }
7ce8802c 419 }
420 return;
421
422}
423//------------------------------------
228f3aba 424void AliAODPidHF::BayesianProbabilityTPC(AliAODTrack *track,Double_t *prob) const{
425// bayesian PID for TPC
7ce8802c 426
427 AliAODpidUtil pid;
428 Double_t tpcpid[AliPID::kSPECIES];
429 pid.MakeTPCPID(track,tpcpid);
430 for(Int_t ind=0;ind<AliPID::kSPECIES;ind++){
369ad90e 431 if(fTOF || fITS || fTRD){
432 prob[ind]=tpcpid[ind];
7ce8802c 433 }else{
369ad90e 434 prob[ind]=tpcpid[ind]*fPriors[ind]/(tpcpid[0]*fPriors[0]+tpcpid[1]*fPriors[1]+tpcpid[2]*fPriors[2]+tpcpid[3]*fPriors[3]+tpcpid[4]*fPriors[4]);
7ce8802c 435 }
369ad90e 436}
7ce8802c 437 return;
438
439}
440//------------------------------------
228f3aba 441void AliAODPidHF::BayesianProbabilityTOF(AliAODTrack *track,Double_t *prob) const{
442// bayesian PID for TOF
7ce8802c 443
444 AliAODpidUtil pid;
445 Double_t tofpid[AliPID::kSPECIES];
228f3aba 446 pid.MakeTOFPID(track,tofpid);
7ce8802c 447 for(Int_t ind=0;ind<AliPID::kSPECIES;ind++){
369ad90e 448 if(fTPC || fITS || fTRD){
449 prob[ind]=tofpid[ind];
450 }else{
7ce8802c 451 prob[ind]=tofpid[ind]*fPriors[ind]/(tofpid[0]*fPriors[0]+tofpid[1]*fPriors[1]+tofpid[2]*fPriors[2]+tofpid[3]*fPriors[3]+tofpid[4]*fPriors[4]);
452 }
369ad90e 453}
7ce8802c 454 return;
455
456}
f9e3cf8e 457//---------------------------------
228f3aba 458void AliAODPidHF::BayesianProbabilityTRD(AliAODTrack *track,Double_t *prob) const{
459// bayesian PID for TRD
f9e3cf8e 460
461 AliAODpidUtil pid;
462 Double_t trdpid[AliPID::kSPECIES];
463 pid.MakeTRDPID(track,trdpid);
464 for(Int_t ind=0;ind<AliPID::kSPECIES;ind++){
369ad90e 465 if(fTPC || fITS || fTOF){
466 prob[ind]=trdpid[ind];
f9e3cf8e 467 }else{
369ad90e 468 prob[ind]=trdpid[ind]*fPriors[ind]/(trdpid[0]*fPriors[0]+trdpid[1]*fPriors[1]+trdpid[2]*fPriors[2]+trdpid[3]*fPriors[3]+trdpid[4]*fPriors[4]);
f9e3cf8e 469 }
369ad90e 470}
f9e3cf8e 471 return;
472
473 }
474//--------------------------------
228f3aba 475Bool_t AliAODPidHF::CheckStatus(AliAODTrack *track,TString detectors) const{
f9e3cf8e 476
228f3aba 477// Quality cuts on the tracks, detector by detector
f9e3cf8e 478
479 if(detectors.Contains("ITS")){
480 if ((track->GetStatus()&AliESDtrack::kITSin)==0) return kFALSE;
481 UChar_t clumap=track->GetITSClusterMap();
482 Int_t nPointsForPid=0;
483 for(Int_t i=2; i<6; i++){
484 if(clumap&(1<<i)) ++nPointsForPid;
485 }
913d1957 486 if(nPointsForPid<3) return kFALSE;
f9e3cf8e 487 }
488
489 if(detectors.Contains("TPC")){
490 if ((track->GetStatus()&AliESDtrack::kTPCin )==0) return kFALSE;
491 UShort_t nTPCClus=track->GetTPCClusterMap().CountBits();
492 if (nTPCClus<70) return kFALSE;
493 }
494
495 if(detectors.Contains("TOF")){
496 if ((track->GetStatus()&AliESDtrack::kTOFout )==0) return kFALSE;
497 if ((track->GetStatus()&AliESDtrack::kTIME )==0) return kFALSE;
498 if ((track->GetStatus()&AliESDtrack::kTOFpid )==0) return kFALSE;
b257e565 499 if (!(track->GetStatus()&AliESDtrack::kTOFmismatch)==0) return kFALSE;
f9e3cf8e 500 }
501
502
503 if(detectors.Contains("TRD")){
504 if ((track->GetStatus()&AliESDtrack::kTRDout )==0) return kFALSE;
505 AliAODPid *pidObj = track->GetDetPid();
506 Float_t *mom=pidObj->GetTRDmomentum();
507 Int_t ntracklets=0;
508 for(Int_t iPl=0;iPl<6;iPl++){
509 if(mom[iPl]>0.) ntracklets++;
510 }
511 if(ntracklets<4) return kFALSE;
512 }
513
514 return kTRUE;
515}
228f3aba 516//--------------------------------------------
517Bool_t AliAODPidHF::TPCRawAsym(AliAODTrack* track,Int_t specie) const{
518// TPC nsigma cut PID, different sigmas in different p bins
519
520 if(!CheckStatus(track,"TPC")) return kFALSE;
521 AliAODPid *pidObj = track->GetDetPid();
522 Double_t mom = pidObj->GetTPCmomentum();
2c9eefd4 523 if(mom>fPtThresholdTPC) return 0;
b79bfc3e 524 Double_t nsigma=999.;
525 if(fOldPid){
228f3aba 526 Double_t dedx=pidObj->GetTPCsignal();
0aba57ed 527 UShort_t nTPCClus=pidObj->GetTPCsignalN();
528 if(nTPCClus==0) {nTPCClus=track->GetTPCNcls();}
228f3aba 529
530 AliTPCPIDResponse tpcResponse;
12141139 531 SetBetheBloch(tpcResponse);
228f3aba 532 AliPID::EParticleType type=AliPID::EParticleType(specie);
b79bfc3e 533 nsigma = TMath::Abs(tpcResponse.GetNumberOfSigmas(mom,dedx,nTPCClus,type));
534
535 }else{ //old pid
536 AliPID::EParticleType type=AliPID::EParticleType(specie);
537 nsigma = TMath::Abs(fPidResponse->NumberOfSigmasTPC(track,type));
538 } //new pid
228f3aba 539
540 if(mom<fPLimit[0] && nsigma<fnSigma[0]) return kTRUE;
541 if(mom<fPLimit[1] && mom>fPLimit[0] && nsigma<fnSigma[1]) return kTRUE;
542 if(mom>fPLimit[1] && nsigma<fnSigma[2]) return kTRUE;
543
544 return kFALSE;
545}
546//------------------
547Int_t AliAODPidHF::MatchTPCTOF(AliAODTrack *track,Int_t mode,Int_t specie,Bool_t compat){
548// combination of the PID info coming from TPC and TOF
549 if(mode==1){
550 //TOF || TPC (a la' Andrea R.)
cdac45d3 551 // convention:
228f3aba 552 // for the single detectors: -1 = kFALSE, 1 = kTRUE, 0 = compatible
553 // the method returns the sum of the response of the 2 detectors
79f3c225 554 if(fTPC && fTOF) {if(!CheckStatus(track,"TPC") && !CheckStatus(track,"TOF")) return 0;}
228f3aba 555
cdac45d3 556
1cb0f658 557 Int_t tTPCinfo=0;
cdac45d3 558 if(fTPC){
228f3aba 559 if(CheckStatus(track,"TPC")) {
560 if(fAsym) {
3779f50a 561 if(TPCRawAsym(track,specie)) {
1cb0f658 562 tTPCinfo=1;
3779f50a 563 }else{
1cb0f658 564 tTPCinfo=-1;
3779f50a 565 }
228f3aba 566 }else{
3779f50a 567 if(specie==2 && IsPionRaw(track,"TPC")) {
1cb0f658 568 tTPCinfo=1;
3779f50a 569 }else{
1cb0f658 570 tTPCinfo=-1;
3779f50a 571 }
572 if(specie==3 && IsKaonRaw(track,"TPC")) {
1cb0f658 573 tTPCinfo=1;
3779f50a 574 }else{
1cb0f658 575 tTPCinfo=-1;
3779f50a 576 }
577 if(specie==4 && IsProtonRaw(track,"TPC")) {
1cb0f658 578 tTPCinfo=1;
3779f50a 579 }else{
1cb0f658 580 tTPCinfo=-1;
3779f50a 581 }
582
228f3aba 583 }
584
585
1cb0f658 586 if(compat && tTPCinfo<0){
cdac45d3 587 Double_t sig0tmp=fnSigma[0];
ad42e35b 588 SetSigma(0,fnSigmaCompat[0]);
1cb0f658 589 if(specie==2 && IsPionRaw(track,"TPC")) tTPCinfo=0;
590 if(specie==3 && IsKaonRaw(track,"TPC")) tTPCinfo=0;
591 if(specie==4 && IsProtonRaw(track,"TPC")) tTPCinfo=0;
cdac45d3 592 SetSigma(0,sig0tmp);
593 }
228f3aba 594
cdac45d3 595 }
228f3aba 596 }
597
1cb0f658 598 Int_t tTOFinfo=0;
cdac45d3 599 if(fTOF){
1cb0f658 600 if(!CheckStatus(track,"TOF") && fTPC) return tTPCinfo;
228f3aba 601
1cb0f658 602 tTOFinfo=-1;
228f3aba 603
1cb0f658 604 if(specie==2 && IsPionRaw(track,"TOF")) tTOFinfo=1;
605 if(specie==3 && IsKaonRaw(track,"TOF")) tTOFinfo=1;
606 if(specie==4 && IsProtonRaw(track,"TOF")) tTOFinfo=1;
228f3aba 607
1cb0f658 608 if(compat && tTOFinfo>0){
cdac45d3 609 Double_t ptrack=track->P();
ad42e35b 610 if(ptrack>fPCompatTOF) {
611 Double_t sig0tmp=fnSigma[3];
612 SetSigma(3,fnSigmaCompat[1]);
613 if(specie==2 && IsPionRaw(track,"TOF")) tTOFinfo=0;
614 if(specie==3 && IsKaonRaw(track,"TOF")) tTOFinfo=0;
615 if(specie==4 && IsProtonRaw(track,"TOF")) tTOFinfo=0;
616 SetSigma(3,sig0tmp);
617 }
cdac45d3 618 }
79f3c225 619 }
913d1957 620
439d61b7 621
622 if(tTPCinfo+tTOFinfo==0 && fTOFdecide){
623 if(!CheckStatus(track,"TOF")) return tTPCinfo;
624 return tTOFinfo;
625 }
626
913d1957 627 if(tTPCinfo+tTOFinfo==0 && fITS){
628 if(!CheckStatus(track,"ITS")) return tTPCinfo+tTOFinfo;
629 Int_t tITSinfo = -1;
2a5813a1 630 if(specie==2 && IsPionRaw(track,"ITS")) tITSinfo=1;
631 if(specie==3 && IsKaonRaw(track,"ITS")) tITSinfo=1;
632 if(specie==4 && IsProtonRaw(track,"ITS")) tITSinfo=1;
913d1957 633 return tITSinfo;
634 }
635
1cb0f658 636 return tTPCinfo+tTOFinfo;
cdac45d3 637}
228f3aba 638 if(mode==2){
639 //TPC & TOF (a la' Yifei)
cdac45d3 640 // convention: -1 = kFALSE, 1 = kTRUE, 0 = not identified
1cb0f658 641 Int_t tTPCinfo=0;
cdac45d3 642
643 if(fTPC && CheckStatus(track,"TPC")) {
1cb0f658 644 tTPCinfo=1;
228f3aba 645 if(fAsym){
1cb0f658 646 if(!TPCRawAsym(track,specie)) tTPCinfo=-1;
228f3aba 647 }else{
1cb0f658 648 if(specie==2 && !IsPionRaw(track,"TPC")) tTPCinfo=-1;
649 if(specie==3 && !IsKaonRaw(track,"TPC")) tTPCinfo=-1;
650 if(specie==4 && !IsProtonRaw(track,"TPC")) tTPCinfo=-1;
228f3aba 651 }
652 }
653
1cb0f658 654 Int_t tTOFinfo=1;
cdac45d3 655 if(fTOF){
1cb0f658 656 if(fTPC && !CheckStatus(track,"TOF")) return tTPCinfo;
228f3aba 657
1cb0f658 658 if(specie==2 && !IsPionRaw(track,"TOF")) tTOFinfo=-1;
659 if(specie==3 && !IsKaonRaw(track,"TOF")) tTOFinfo=-1;
660 if(specie==4 && !IsProtonRaw(track,"TOF")) tTOFinfo=-1;
cdac45d3 661 }
913d1957 662
663 if(tTOFinfo==1 && tTPCinfo==1) return 1;
664
665 if(tTPCinfo+tTOFinfo==0 && fITS){
666 if(!CheckStatus(track,"ITS")) return tTPCinfo+tTOFinfo;
667 Int_t tITSinfo = -1;
2a5813a1 668 if(specie==2 && IsPionRaw(track,"ITS")) tITSinfo=1;
669 if(specie==3 && IsKaonRaw(track,"ITS")) tITSinfo=1;
670 if(specie==4 && IsProtonRaw(track,"ITS")) tITSinfo=1;
913d1957 671 return tITSinfo;
672 }
228f3aba 673
228f3aba 674 return -1;
675
cdac45d3 676}
228f3aba 677
678 if(mode==3){
679 //TPC for p<fPLimit[0], TOF for p>=fPLimit[0] (a la' Andrea A.)
680 // convention (temporary): -1 = kFALSE, 1 = kTRUE, 0 = not identified
681
cdac45d3 682 if(fTPC && fTOF) if(!CheckStatus(track,"TPC") && !CheckStatus(track,"TOF")) return 0;
228f3aba 683
684 Double_t ptrack=track->P();
685
686
1cb0f658 687 Int_t tTPCinfo=-1;
228f3aba 688
913d1957 689 if(ptrack>=fPLimit[0] && ptrack<fPLimit[1] && fTPC) {
228f3aba 690 if(!CheckStatus(track,"TPC")) return 0;
691 if(fAsym) {
1cb0f658 692 if(TPCRawAsym(track,specie)) tTPCinfo=1;
228f3aba 693 }else{
1cb0f658 694 if(specie==2 && IsPionRaw(track,"TPC")) tTPCinfo=1;
695 if(specie==3 && IsKaonRaw(track,"TPC")) tTPCinfo=1;
696 if(specie==4 && IsProtonRaw(track,"TPC")) tTPCinfo=1;
228f3aba 697 }
1cb0f658 698 return tTPCinfo;
228f3aba 699 }
700
1cb0f658 701 Int_t tTOFinfo=-1;
913d1957 702 if(ptrack>=fPLimit[1] && fTOF){
228f3aba 703 if(!CheckStatus(track,"TOF")) return 0;
1cb0f658 704 if(specie==2 && IsPionRaw(track,"TOF")) tTOFinfo=1;
705 if(specie==3 && IsKaonRaw(track,"TOF")) tTOFinfo=1;
706 if(specie==4 && IsProtonRaw(track,"TOF")) tTOFinfo=1;
707 return tTOFinfo;
228f3aba 708 }
709
913d1957 710 Int_t tITSinfo=-1;
711 if(ptrack<fPLimit[0] && fITS){
712 if(!CheckStatus(track,"ITS")) return 0;
713 if(specie==2 && IsPionRaw(track,"ITS")) tITSinfo=1;
714 if(specie==3 && IsKaonRaw(track,"ITS")) tITSinfo=1;
715 if(specie==4 && IsProtonRaw(track,"ITS")) tITSinfo=1;
716 return tITSinfo;
717 }
718
228f3aba 719 }
720
721 return -1;
cdac45d3 722
723}
724//----------------------------------
725Int_t AliAODPidHF::MakeRawPid(AliAODTrack *track, Int_t specie){
1cb0f658 726// general method to compute PID
cdac45d3 727 if(fMatch>0){
1cb0f658 728 return MatchTPCTOF(track,fMatch,specie,fCompat);
cdac45d3 729 }else{
730 if(fTPC && !fTOF && !fITS) {
ad42e35b 731 Int_t tTPCres=0;
732 if(!fAsym){
733 tTPCres=ApplyPidTPCRaw(track,specie);
734 }else{
735 if(TPCRawAsym(track,specie)) {
736 tTPCres=1;
737 }else{
738 tTPCres=-1;
739 }
740 }
1cb0f658 741 if(tTPCres==specie){return 1;}else{return tTPCres;};
cdac45d3 742 }else{
743 AliError("You should enable just one detector if you don't want to match");
744 return 0;
745 }
746 if(fTOF && !fTPC && !fITS) {
1cb0f658 747 Int_t tTOFres=ApplyPidTOFRaw(track,specie);
748 if(tTOFres==specie){return 1;}else{return tTOFres;};
cdac45d3 749 }else{
750 AliError("You should enable just one detector if you don't want to match");
751 return 0;
752 }
753
754 if(fITS && !fTPC && !fTOF) {
1cb0f658 755 Int_t tITSres=ApplyPidITSRaw(track,specie);
756 if(tITSres==specie){return 1;}else{return tITSres;};
cdac45d3 757 }else{
758 AliError("You should enable just one detector if you don't want to match");
759 return 0;
760 }
761 }
762
228f3aba 763}
12141139 764//--------------------------------------------
bad87dce 765void AliAODPidHF::SetBetheBloch(AliTPCPIDResponse &tpcResp) const{
12141139 766
767 Double_t alephParameters[5];
98db0ef2 768
32a978c2 769 if(fMC) { // MC
12141139 770
32a978c2 771 if(fPbPb) { // PbPb MC
772
9ea811e0 773 alephParameters[0] = 1.44405/50.;
32a978c2 774 alephParameters[1] = 2.35409e+01;
775 alephParameters[2] = TMath::Exp(-2.90330e+01);
776 alephParameters[3] = 2.10681e+00;
777 alephParameters[4] = 4.62254e+00;
12141139 778
32a978c2 779 } else { // pp MC
5821ea5b 780 if(fMCLowEn2011){
781 alephParameters[0]=0.0207667;
782 alephParameters[1]=29.9936;
783 alephParameters[2]=3.87866e-11;
784 alephParameters[3]=2.17291;
785 alephParameters[4]=7.1623;
3d4afb8c 786 }else if(fOnePad){
787 alephParameters[0]=0.029021;
788 alephParameters[1]=25.4181;
789 alephParameters[2]=4.66596e-08;
790 alephParameters[3]=1.90008;
791 alephParameters[4]=4.63783;
5821ea5b 792 }else{
793 alephParameters[0] = 2.15898/50.;
794 alephParameters[1] = 1.75295e+01;
795 alephParameters[2] = 3.40030e-09;
796 alephParameters[3] = 1.96178e+00;
797 alephParameters[4] = 3.91720e+00;
798 }
32a978c2 799 }
12141139 800
32a978c2 801 } else { // Real Data
802
803 if(fOnePad) { // pp 1-pad (since LHC10d)
804
805 alephParameters[0] =1.34490e+00/50.;
98db0ef2 806 alephParameters[1] = 2.69455e+01;
8a292370 807 alephParameters[2] = TMath::Exp(-2.97552e+01);
98db0ef2 808 alephParameters[3] = 2.35339e+00;
809 alephParameters[4] = 5.98079e+00;
810
32a978c2 811 } else if(fPbPb) { // PbPb
98db0ef2 812
813 // alephParameters[0] = 1.25202/50.;
814 // alephParameters[1] = 2.74992e+01;
815 // alephParameters[2] = TMath::Exp(-3.31517e+01);
816 // alephParameters[3] = 2.46246;
817 // alephParameters[4] = 6.78938;
818
819 alephParameters[0] = 5.10207e+00/50.;
820 alephParameters[1] = 7.94982e+00;
821 alephParameters[2] = TMath::Exp(-9.07942e+00);
822 alephParameters[3] = 2.38808e+00;
823 alephParameters[4] = 1.68165e+00;
824
32a978c2 825 } else { // pp no 1-pad (LHC10bc)
826
12141139 827 alephParameters[0] = 0.0283086/0.97;
828 alephParameters[1] = 2.63394e+01;
829 alephParameters[2] = 5.04114e-11;
830 alephParameters[3] = 2.12543e+00;
831 alephParameters[4] = 4.88663e+00;
98db0ef2 832
12141139 833 }
98db0ef2 834
12141139 835 }
836
837 tpcResp.SetBetheBlochParameters(alephParameters[0],alephParameters[1],alephParameters[2],alephParameters[3],alephParameters[4]);
838
839
840 return;
841
842}
d50b25df 843//-----------------------
844Bool_t AliAODPidHF::IsTOFPiKexcluded(AliAODTrack *track,Double_t nsigmaK){
845
846
847 if(!CheckStatus(track,"TOF")) return 0;
848
849 Double_t time[AliPID::kSPECIESN];
850 Double_t sigmaTOFPid[AliPID::kSPECIES];
851 AliAODPid *pidObj = track->GetDetPid();
852 pidObj->GetIntegratedTimes(time);
853 Double_t sigTOF=pidObj->GetTOFsignal();
854 pidObj->GetTOFpidResolution(sigmaTOFPid);
855 Double_t sigmaTOFtrack;
856 if (sigmaTOFPid[3]>0) sigmaTOFtrack=sigmaTOFPid[3];
857 else sigmaTOFtrack=fTOFSigma; // backward compatibility for old AODs
858
859 if((sigTOF-time[3])>nsigmaK*sigmaTOFtrack)return kTRUE;// K, Pi excluded (->LIKELY A PROTON)
860
861 return kFALSE;
862
863}
864