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