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