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