Adding two detailed lookup tables which are used to speed up the calculation of
[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),
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);
182
f9e3cf8e 183 Int_t pid=-1;
184 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 185 Double_t nsigmaMax=fnSigma[0];
f9e3cf8e 186 for(Int_t ipart=0;ipart<5;ipart++){
7ce8802c 187 AliPID::EParticleType type=AliPID::EParticleType(ipart);
f9e3cf8e 188 Double_t nsigma = TMath::Abs(tpcResponse.GetNumberOfSigmas(mom,dedx,track->GetTPCNcls(),type));
228f3aba 189 if((nsigma<nsigmaMax) && (nsigma<fnSigma[0])) {
7ce8802c 190 pid=ipart;
191 nsigmaMax=nsigma;
192 }
193 }
194 }else{ // asks only for one particle specie
195 AliPID::EParticleType type=AliPID::EParticleType(specie);
f9e3cf8e 196 Double_t nsigma = TMath::Abs(tpcResponse.GetNumberOfSigmas(mom,dedx,track->GetTPCNcls(),type));
228f3aba 197 if (nsigma>fnSigma[0]) {
f9e3cf8e 198 pid=-1;
7ce8802c 199 }else{
79f3c225 200 pid=specie;
7ce8802c 201 }
202 }
203
204 return pid;
205
206}
207//----------------------------
228f3aba 208Int_t AliAODPidHF::ApplyPidITSRaw(AliAODTrack *track,Int_t specie) const{
209// truncated mean, ITS PID
f9e3cf8e 210
cdac45d3 211 if(!CheckStatus(track,"ITS")) return 0;
f9e3cf8e 212
7ce8802c 213 Double_t mom=track->P();
214 AliAODPid *pidObj = track->GetDetPid();
215
216 Double_t dedx=pidObj->GetITSsignal();
913d1957 217 UChar_t clumap=track->GetITSClusterMap();
218 Int_t nPointsForPid=0;
219 for(Int_t i=2; i<6; i++){
220 if(clumap&(1<<i)) ++nPointsForPid;
221 }
222
223 Bool_t isSA=kTRUE;
224 if(track->GetStatus() & AliESDtrack::kTPCin) isSA = kFALSE;
225
7ce8802c 226 AliITSPIDResponse itsResponse;
f9e3cf8e 227 Int_t pid=-1;
228 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 229 Double_t nsigmaMax=fnSigma[4];
f9e3cf8e 230 for(Int_t ipart=0;ipart<5;ipart++){
7ce8802c 231 AliPID::EParticleType type=AliPID::EParticleType(ipart);
913d1957 232 Double_t nsigma = TMath::Abs(itsResponse.GetNumberOfSigmas(mom,dedx,type,nPointsForPid,isSA));
228f3aba 233 if((nsigma<nsigmaMax) && (nsigma<fnSigma[4])) {
7ce8802c 234 pid=ipart;
235 nsigmaMax=nsigma;
236 }
237 }
238 }else{ // asks only for one particle specie
239 AliPID::EParticleType type=AliPID::EParticleType(specie);
240 Double_t nsigma = TMath::Abs(itsResponse.GetNumberOfSigmas(mom,dedx,type));
228f3aba 241 if (nsigma>fnSigma[4]) {
f9e3cf8e 242 pid=-1;
7ce8802c 243 }else{
79f3c225 244 pid=specie;
7ce8802c 245 }
246 }
247 return pid;
248}
249//----------------------------
228f3aba 250Int_t AliAODPidHF::ApplyPidTOFRaw(AliAODTrack *track,Int_t specie) const{
251// n-sigma cut, TOF PID
f9e3cf8e 252
cdac45d3 253 if(!CheckStatus(track,"TOF")) return 0;
f9e3cf8e 254
7ce8802c 255 Double_t time[AliPID::kSPECIESN];
256 AliAODPid *pidObj = track->GetDetPid();
257 pidObj->GetIntegratedTimes(time);
228f3aba 258 Double_t sigTOF=pidObj->GetTOFsignal();
259// AliTOFPIDResponse tofResponse;
f9e3cf8e 260 Int_t pid=-1;
7ce8802c 261
f9e3cf8e 262 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 263 Double_t nsigmaMax=fTOFSigma*fnSigma[3];
f9e3cf8e 264 for(Int_t ipart=0;ipart<5;ipart++){
228f3aba 265 //AliPID::EParticleType type=AliPID::EParticleType(ipart);
266 //Double_t nsigma = tofResponse.GetExpectedSigma(track->P(),time[type],AliPID::ParticleMass(type));
267 Double_t nsigma=TMath::Abs(sigTOF-time[ipart]);
268 if((nsigma<nsigmaMax) && (nsigma<fnSigma[3]*fTOFSigma)) {
7ce8802c 269 pid=ipart;
270 nsigmaMax=nsigma;
271 }
272 }
273 }else{ // asks only for one particle specie
228f3aba 274 //AliPID::EParticleType type=AliPID::EParticleType(specie);
275 //Double_t nsigma = TMath::Abs(tofResponse.GetExpectedSigma(track->P(),time[type],AliPID::ParticleMass(type)));
276 Double_t nsigma=TMath::Abs(sigTOF-time[specie]);
277 if (nsigma>fnSigma[3]*fTOFSigma) {
f9e3cf8e 278 pid=-1;
7ce8802c 279 }else{
79f3c225 280 pid=specie;
7ce8802c 281 }
282 }
283 return pid;
284
285}
286//------------------------------
228f3aba 287void AliAODPidHF::CombinedProbability(AliAODTrack *track,Bool_t *type) const{
288// combined PID stored inside the AOD track
7ce8802c 289
290 const Double_t *pid=track->PID();
291 Float_t max=0.;
292 Int_t k=-1;
293 for (Int_t i=0; i<10; i++) {
294 if (pid[i]>max) {k=i; max=pid[i];}
295 }
296
297 if(k==2) type[0]=kTRUE;
298 if(k==3) type[1]=kTRUE;
299 if(k==4) type[2]=kTRUE;
300
301 return;
302}
303//--------------------
cdac45d3 304void AliAODPidHF::BayesianProbability(AliAODTrack *track,Double_t *pid) const{
228f3aba 305// bayesian PID for single detectors or combined
7ce8802c 306
cdac45d3 307 if(fITS && !fTPC && !fTOF) {BayesianProbabilityITS(track,pid);return;}
308 if(fTPC && !fITS && !fTOF) {BayesianProbabilityTPC(track,pid);return;}
309 if(fTOF && !fITS && !fTPC) {BayesianProbabilityTOF(track,pid);return;}
310
311 Double_t probITS[5]={1.,1.,1.,1.,1.};
312 Double_t probTPC[5]={1.,1.,1.,1.,1.};
313 Double_t probTOF[5]={1.,1.,1.,1.,1.};
314 if(fITS) BayesianProbabilityITS(track,probITS);
315 if(fTPC) BayesianProbabilityTPC(track,probTPC);
316 if(fTOF) BayesianProbabilityTOF(track,probTOF);
7ce8802c 317 Double_t probTot[5]={0.,0.,0.,0.,0.};
318 for(Int_t i=0;i<5;i++){
319 probTot[i]=probITS[i]*probTPC[i]*probTOF[i];
320 }
321 for(Int_t i2=0;i2<5;i2++){
322 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]);
323 }
7ce8802c 324
325 return;
326
327}
328//------------------------------------
228f3aba 329void AliAODPidHF::BayesianProbabilityITS(AliAODTrack *track,Double_t *prob) const{
7ce8802c 330
228f3aba 331// bayesian PID for ITS
7ce8802c 332 AliAODpidUtil pid;
333 Double_t itspid[AliPID::kSPECIES];
334 pid.MakeITSPID(track,itspid);
335 for(Int_t ind=0;ind<AliPID::kSPECIES;ind++){
369ad90e 336 if(fTOF || fTPC || fTRD){
337 prob[ind]=itspid[ind];
338 }else{
339 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]);
340 }
7ce8802c 341 }
342 return;
343
344}
345//------------------------------------
228f3aba 346void AliAODPidHF::BayesianProbabilityTPC(AliAODTrack *track,Double_t *prob) const{
347// bayesian PID for TPC
7ce8802c 348
349 AliAODpidUtil pid;
350 Double_t tpcpid[AliPID::kSPECIES];
351 pid.MakeTPCPID(track,tpcpid);
352 for(Int_t ind=0;ind<AliPID::kSPECIES;ind++){
369ad90e 353 if(fTOF || fITS || fTRD){
354 prob[ind]=tpcpid[ind];
7ce8802c 355 }else{
369ad90e 356 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 357 }
369ad90e 358}
7ce8802c 359 return;
360
361}
362//------------------------------------
228f3aba 363void AliAODPidHF::BayesianProbabilityTOF(AliAODTrack *track,Double_t *prob) const{
364// bayesian PID for TOF
7ce8802c 365
366 AliAODpidUtil pid;
367 Double_t tofpid[AliPID::kSPECIES];
228f3aba 368 pid.MakeTOFPID(track,tofpid);
7ce8802c 369 for(Int_t ind=0;ind<AliPID::kSPECIES;ind++){
369ad90e 370 if(fTPC || fITS || fTRD){
371 prob[ind]=tofpid[ind];
372 }else{
7ce8802c 373 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]);
374 }
369ad90e 375}
7ce8802c 376 return;
377
378}
f9e3cf8e 379//---------------------------------
228f3aba 380void AliAODPidHF::BayesianProbabilityTRD(AliAODTrack *track,Double_t *prob) const{
381// bayesian PID for TRD
f9e3cf8e 382
383 AliAODpidUtil pid;
384 Double_t trdpid[AliPID::kSPECIES];
385 pid.MakeTRDPID(track,trdpid);
386 for(Int_t ind=0;ind<AliPID::kSPECIES;ind++){
369ad90e 387 if(fTPC || fITS || fTOF){
388 prob[ind]=trdpid[ind];
f9e3cf8e 389 }else{
369ad90e 390 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 391 }
369ad90e 392}
f9e3cf8e 393 return;
394
395 }
396//--------------------------------
228f3aba 397Bool_t AliAODPidHF::CheckStatus(AliAODTrack *track,TString detectors) const{
f9e3cf8e 398
228f3aba 399// Quality cuts on the tracks, detector by detector
f9e3cf8e 400
401 if(detectors.Contains("ITS")){
402 if ((track->GetStatus()&AliESDtrack::kITSin)==0) return kFALSE;
403 UChar_t clumap=track->GetITSClusterMap();
404 Int_t nPointsForPid=0;
405 for(Int_t i=2; i<6; i++){
406 if(clumap&(1<<i)) ++nPointsForPid;
407 }
913d1957 408 if(nPointsForPid<3) return kFALSE;
f9e3cf8e 409 }
410
411 if(detectors.Contains("TPC")){
412 if ((track->GetStatus()&AliESDtrack::kTPCin )==0) return kFALSE;
413 UShort_t nTPCClus=track->GetTPCClusterMap().CountBits();
414 if (nTPCClus<70) return kFALSE;
415 }
416
417 if(detectors.Contains("TOF")){
418 if ((track->GetStatus()&AliESDtrack::kTOFout )==0) return kFALSE;
419 if ((track->GetStatus()&AliESDtrack::kTIME )==0) return kFALSE;
420 if ((track->GetStatus()&AliESDtrack::kTOFpid )==0) return kFALSE;
421 }
422
423
424 if(detectors.Contains("TRD")){
425 if ((track->GetStatus()&AliESDtrack::kTRDout )==0) return kFALSE;
426 AliAODPid *pidObj = track->GetDetPid();
427 Float_t *mom=pidObj->GetTRDmomentum();
428 Int_t ntracklets=0;
429 for(Int_t iPl=0;iPl<6;iPl++){
430 if(mom[iPl]>0.) ntracklets++;
431 }
432 if(ntracklets<4) return kFALSE;
433 }
434
435 return kTRUE;
436}
228f3aba 437//--------------------------------------------
438Bool_t AliAODPidHF::TPCRawAsym(AliAODTrack* track,Int_t specie) const{
439// TPC nsigma cut PID, different sigmas in different p bins
440
441 if(!CheckStatus(track,"TPC")) return kFALSE;
442 AliAODPid *pidObj = track->GetDetPid();
443 Double_t mom = pidObj->GetTPCmomentum();
444 Double_t dedx=pidObj->GetTPCsignal();
445
446 AliTPCPIDResponse tpcResponse;
12141139 447 SetBetheBloch(tpcResponse);
228f3aba 448 AliPID::EParticleType type=AliPID::EParticleType(specie);
449 Double_t nsigma = TMath::Abs(tpcResponse.GetNumberOfSigmas(mom,dedx,track->GetTPCNcls(),type));
450
451 if(mom<fPLimit[0] && nsigma<fnSigma[0]) return kTRUE;
452 if(mom<fPLimit[1] && mom>fPLimit[0] && nsigma<fnSigma[1]) return kTRUE;
453 if(mom>fPLimit[1] && nsigma<fnSigma[2]) return kTRUE;
454
455 return kFALSE;
456}
457//------------------
458Int_t AliAODPidHF::MatchTPCTOF(AliAODTrack *track,Int_t mode,Int_t specie,Bool_t compat){
459// combination of the PID info coming from TPC and TOF
460 if(mode==1){
461 //TOF || TPC (a la' Andrea R.)
cdac45d3 462 // convention:
228f3aba 463 // for the single detectors: -1 = kFALSE, 1 = kTRUE, 0 = compatible
464 // the method returns the sum of the response of the 2 detectors
79f3c225 465 if(fTPC && fTOF) {if(!CheckStatus(track,"TPC") && !CheckStatus(track,"TOF")) return 0;}
228f3aba 466
cdac45d3 467
1cb0f658 468 Int_t tTPCinfo=0;
cdac45d3 469 if(fTPC){
228f3aba 470 if(CheckStatus(track,"TPC")) {
471 if(fAsym) {
3779f50a 472 if(TPCRawAsym(track,specie)) {
1cb0f658 473 tTPCinfo=1;
3779f50a 474 }else{
1cb0f658 475 tTPCinfo=-1;
3779f50a 476 }
228f3aba 477 }else{
3779f50a 478 if(specie==2 && IsPionRaw(track,"TPC")) {
1cb0f658 479 tTPCinfo=1;
3779f50a 480 }else{
1cb0f658 481 tTPCinfo=-1;
3779f50a 482 }
483 if(specie==3 && IsKaonRaw(track,"TPC")) {
1cb0f658 484 tTPCinfo=1;
3779f50a 485 }else{
1cb0f658 486 tTPCinfo=-1;
3779f50a 487 }
488 if(specie==4 && IsProtonRaw(track,"TPC")) {
1cb0f658 489 tTPCinfo=1;
3779f50a 490 }else{
1cb0f658 491 tTPCinfo=-1;
3779f50a 492 }
493
228f3aba 494 }
495
496
1cb0f658 497 if(compat && tTPCinfo<0){
cdac45d3 498 Double_t sig0tmp=fnSigma[0];
499 SetSigma(0,3.);
1cb0f658 500 if(specie==2 && IsPionRaw(track,"TPC")) tTPCinfo=0;
501 if(specie==3 && IsKaonRaw(track,"TPC")) tTPCinfo=0;
502 if(specie==4 && IsProtonRaw(track,"TPC")) tTPCinfo=0;
cdac45d3 503 SetSigma(0,sig0tmp);
504 }
228f3aba 505
cdac45d3 506 }
228f3aba 507 }
508
1cb0f658 509 Int_t tTOFinfo=0;
cdac45d3 510 if(fTOF){
1cb0f658 511 if(!CheckStatus(track,"TOF") && fTPC) return tTPCinfo;
228f3aba 512
1cb0f658 513 tTOFinfo=-1;
228f3aba 514
1cb0f658 515 if(specie==2 && IsPionRaw(track,"TOF")) tTOFinfo=1;
516 if(specie==3 && IsKaonRaw(track,"TOF")) tTOFinfo=1;
517 if(specie==4 && IsProtonRaw(track,"TOF")) tTOFinfo=1;
228f3aba 518
1cb0f658 519 if(compat && tTOFinfo>0){
cdac45d3 520 Double_t ptrack=track->P();
1cb0f658 521 if(ptrack>1.5) tTOFinfo=0;
cdac45d3 522 }
79f3c225 523 }
913d1957 524
525 if(tTPCinfo+tTOFinfo==0 && fITS){
526 if(!CheckStatus(track,"ITS")) return tTPCinfo+tTOFinfo;
527 Int_t tITSinfo = -1;
528 if(specie==2 && IsPionRaw(track,"TOF")) tITSinfo=1;
529 if(specie==3 && IsKaonRaw(track,"TOF")) tITSinfo=1;
530 if(specie==4 && IsProtonRaw(track,"TOF")) tITSinfo=1;
531 return tITSinfo;
532 }
533
1cb0f658 534 return tTPCinfo+tTOFinfo;
cdac45d3 535}
228f3aba 536 if(mode==2){
537 //TPC & TOF (a la' Yifei)
cdac45d3 538 // convention: -1 = kFALSE, 1 = kTRUE, 0 = not identified
1cb0f658 539 Int_t tTPCinfo=0;
cdac45d3 540
541 if(fTPC && CheckStatus(track,"TPC")) {
1cb0f658 542 tTPCinfo=1;
228f3aba 543 if(fAsym){
1cb0f658 544 if(!TPCRawAsym(track,specie)) tTPCinfo=-1;
228f3aba 545 }else{
1cb0f658 546 if(specie==2 && !IsPionRaw(track,"TPC")) tTPCinfo=-1;
547 if(specie==3 && !IsKaonRaw(track,"TPC")) tTPCinfo=-1;
548 if(specie==4 && !IsProtonRaw(track,"TPC")) tTPCinfo=-1;
228f3aba 549 }
550 }
551
1cb0f658 552 Int_t tTOFinfo=1;
cdac45d3 553 if(fTOF){
1cb0f658 554 if(fTPC && !CheckStatus(track,"TOF")) return tTPCinfo;
228f3aba 555
1cb0f658 556 if(specie==2 && !IsPionRaw(track,"TOF")) tTOFinfo=-1;
557 if(specie==3 && !IsKaonRaw(track,"TOF")) tTOFinfo=-1;
558 if(specie==4 && !IsProtonRaw(track,"TOF")) tTOFinfo=-1;
cdac45d3 559 }
913d1957 560
561 if(tTOFinfo==1 && tTPCinfo==1) return 1;
562
563 if(tTPCinfo+tTOFinfo==0 && fITS){
564 if(!CheckStatus(track,"ITS")) return tTPCinfo+tTOFinfo;
565 Int_t tITSinfo = -1;
566 if(specie==2 && IsPionRaw(track,"TOF")) tITSinfo=1;
567 if(specie==3 && IsKaonRaw(track,"TOF")) tITSinfo=1;
568 if(specie==4 && IsProtonRaw(track,"TOF")) tITSinfo=1;
569 return tITSinfo;
570 }
228f3aba 571
228f3aba 572 return -1;
573
cdac45d3 574}
228f3aba 575
576 if(mode==3){
577 //TPC for p<fPLimit[0], TOF for p>=fPLimit[0] (a la' Andrea A.)
578 // convention (temporary): -1 = kFALSE, 1 = kTRUE, 0 = not identified
579
cdac45d3 580 if(fTPC && fTOF) if(!CheckStatus(track,"TPC") && !CheckStatus(track,"TOF")) return 0;
228f3aba 581
582 Double_t ptrack=track->P();
583
584
1cb0f658 585 Int_t tTPCinfo=-1;
228f3aba 586
913d1957 587 if(ptrack>=fPLimit[0] && ptrack<fPLimit[1] && fTPC) {
228f3aba 588 if(!CheckStatus(track,"TPC")) return 0;
589 if(fAsym) {
1cb0f658 590 if(TPCRawAsym(track,specie)) tTPCinfo=1;
228f3aba 591 }else{
1cb0f658 592 if(specie==2 && IsPionRaw(track,"TPC")) tTPCinfo=1;
593 if(specie==3 && IsKaonRaw(track,"TPC")) tTPCinfo=1;
594 if(specie==4 && IsProtonRaw(track,"TPC")) tTPCinfo=1;
228f3aba 595 }
1cb0f658 596 return tTPCinfo;
228f3aba 597 }
598
1cb0f658 599 Int_t tTOFinfo=-1;
913d1957 600 if(ptrack>=fPLimit[1] && fTOF){
228f3aba 601 if(!CheckStatus(track,"TOF")) return 0;
1cb0f658 602 if(specie==2 && IsPionRaw(track,"TOF")) tTOFinfo=1;
603 if(specie==3 && IsKaonRaw(track,"TOF")) tTOFinfo=1;
604 if(specie==4 && IsProtonRaw(track,"TOF")) tTOFinfo=1;
605 return tTOFinfo;
228f3aba 606 }
607
913d1957 608 Int_t tITSinfo=-1;
609 if(ptrack<fPLimit[0] && fITS){
610 if(!CheckStatus(track,"ITS")) return 0;
611 if(specie==2 && IsPionRaw(track,"ITS")) tITSinfo=1;
612 if(specie==3 && IsKaonRaw(track,"ITS")) tITSinfo=1;
613 if(specie==4 && IsProtonRaw(track,"ITS")) tITSinfo=1;
614 return tITSinfo;
615 }
616
228f3aba 617 }
618
619 return -1;
cdac45d3 620
621}
622//----------------------------------
623Int_t AliAODPidHF::MakeRawPid(AliAODTrack *track, Int_t specie){
1cb0f658 624// general method to compute PID
cdac45d3 625 if(fMatch>0){
1cb0f658 626 return MatchTPCTOF(track,fMatch,specie,fCompat);
cdac45d3 627 }else{
628 if(fTPC && !fTOF && !fITS) {
1cb0f658 629 Int_t tTPCres=ApplyPidTPCRaw(track,specie);
630 if(tTPCres==specie){return 1;}else{return tTPCres;};
cdac45d3 631 }else{
632 AliError("You should enable just one detector if you don't want to match");
633 return 0;
634 }
635 if(fTOF && !fTPC && !fITS) {
1cb0f658 636 Int_t tTOFres=ApplyPidTOFRaw(track,specie);
637 if(tTOFres==specie){return 1;}else{return tTOFres;};
cdac45d3 638 }else{
639 AliError("You should enable just one detector if you don't want to match");
640 return 0;
641 }
642
643 if(fITS && !fTPC && !fTOF) {
1cb0f658 644 Int_t tITSres=ApplyPidITSRaw(track,specie);
645 if(tITSres==specie){return 1;}else{return tITSres;};
cdac45d3 646 }else{
647 AliError("You should enable just one detector if you don't want to match");
648 return 0;
649 }
650 }
651
228f3aba 652}
12141139 653//--------------------------------------------
654void AliAODPidHF::SetBetheBloch(AliTPCPIDResponse tpcResp) const{
655
656 Double_t alephParameters[5];
657 if(fMC){
658 alephParameters[0] = 2.15898e+00/50.;
659 alephParameters[1] = 1.75295e+01;
660 alephParameters[2] = 3.40030e-09;
661 alephParameters[3] = 1.96178e+00;
662 alephParameters[4] = 3.91720e+00;
663
664 }else{
665
17c4a8d5 666 if(fOnePad) {
667
6fbe5a9b 668 alephParameters[0] =1.34490e+00/50;
669 alephParameters[1] = 2.69455e+01;
670 alephParameters[2] = TMath::Exp(-2.97552+01);
671 alephParameters[3] = 2.35339e+00;
672 alephParameters[4] = 5.98079e+00;
12141139 673
17c4a8d5 674 } else if(fPbPb) {
675
676 alephParameters[0] = 1.25202/50.;
677 alephParameters[1] = 2.74992e+01;
678 alephParameters[2] = TMath::Exp(-3.31517e+01);
679 alephParameters[3] = 2.46246;
680 alephParameters[4] = 6.78938;
681
682 } else {
12141139 683 alephParameters[0] = 0.0283086/0.97;
684 alephParameters[1] = 2.63394e+01;
685 alephParameters[2] = 5.04114e-11;
686 alephParameters[3] = 2.12543e+00;
687 alephParameters[4] = 4.88663e+00;
688
689 }
690
691 }
692
693 tpcResp.SetBetheBlochParameters(alephParameters[0],alephParameters[1],alephParameters[2],alephParameters[3],alephParameters[4]);
694
695
696 return;
697
698}