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