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