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