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