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