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