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