]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG3/vertexingHF/AliAODPidHF.cxx
switch to Jochens new raw reader (Markus)
[u/mrichter/AliRoot.git] / PWG3 / vertexingHF / AliAODPidHF.cxx
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
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
21 //***********************************************************
22 #include "AliAODPidHF.h"
23 #include "AliAODPid.h"
24 #include "AliPID.h"
25 #include "AliTPCPIDResponse.h"
26 #include "AliITSPIDResponse.h"
27 #include "AliTOFPIDResponse.h"
28 #include "AliAODpidUtil.h"
29 #include "AliESDtrack.h"
30
31
32 ClassImp(AliAODPidHF)
33
34 //------------------------------
35 AliAODPidHF::AliAODPidHF():
36   AliAODPid(),
37   fnNSigma(5),
38   fnSigma(),
39   fTOFSigma(160.),
40   fnPriors(5),
41   fPriors(),
42   fnPLimit(2),
43   fPLimit(),
44   fAsym(kFALSE),
45   fTPC(kFALSE),
46   fTOF(kFALSE),
47   fITS(kFALSE),
48   fTRD(kFALSE),
49   fMatch(0),
50   fCompat(kFALSE),
51   fMC(kFALSE)
52 {
53  //
54  // Default constructor
55  //
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  }
69
70 }
71 //----------------------
72 AliAODPidHF::~AliAODPidHF()
73 {
74       // destructor
75  //   if(fPLimit) delete fPLimit;
76  //   if(fnSigma)  delete fnSigma;
77  //   if(fPriors)  delete fPriors;
78 }
79 //------------------------
80 AliAODPidHF::AliAODPidHF(const AliAODPidHF& pid) :
81   AliAODPid(pid),
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),
89   fAsym(pid.fAsym),
90   fTPC(pid.fTPC),
91   fTOF(pid.fTOF),
92   fITS(pid.fITS),
93   fTRD(pid.fTRD),
94   fMatch(pid.fMatch),
95   fCompat(pid.fCompat),
96   fMC(kFALSE)
97   {
98   
99   for(Int_t i=0;i<5;i++){
100     fPriors[i]=pid.fPriors[i];
101   }
102   
103   }
104
105 //----------------------
106 Int_t AliAODPidHF::RawSignalPID(AliAODTrack *track, TString detector) const{
107 // raw PID for single detectors, returns the particle type with smaller sigma
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);
112
113   return specie;
114
115 }
116 //---------------------------
117 Bool_t AliAODPidHF::IsKaonRaw(AliAODTrack *track, TString detector) const{
118 // checks if the track can be a kaon, raw PID applied for single detectors
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 //---------------------------
129 Bool_t AliAODPidHF::IsPionRaw (AliAODTrack *track, TString detector) const{
130 // checks if the track can be a pion, raw PID applied for single detectors
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 //---------------------------
142 Bool_t AliAODPidHF::IsProtonRaw (AliAODTrack *track, TString detector) const{
143 // checks if the track can be a proton raw PID applied for single detectors
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 }
154 //--------------------------
155 Bool_t AliAODPidHF::IsElectronRaw(AliAODTrack *track, TString detector) const{
156 // checks if the track can be an electron raw PID applied for single detectors
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 //--------------------------
168 Int_t AliAODPidHF::ApplyPidTPCRaw(AliAODTrack *track,Int_t specie) const{
169 // n-sigma cut, TPC PID
170
171   if(!CheckStatus(track,"TPC")) return 0;
172   AliAODPid *pidObj = track->GetDetPid();
173   
174   Double_t dedx=pidObj->GetTPCsignal();
175   Double_t mom = pidObj->GetTPCmomentum();
176   AliTPCPIDResponse tpcResponse;
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
179    Double_t nsigmaMax=fnSigma[0];
180    for(Int_t ipart=0;ipart<5;ipart++){
181     AliPID::EParticleType type=AliPID::EParticleType(ipart);
182     Double_t nsigma = TMath::Abs(tpcResponse.GetNumberOfSigmas(mom,dedx,track->GetTPCNcls(),type));
183     if((nsigma<nsigmaMax) && (nsigma<fnSigma[0])) {
184      pid=ipart;
185      nsigmaMax=nsigma;
186     }
187    }
188   }else{ // asks only for one particle specie
189    AliPID::EParticleType type=AliPID::EParticleType(specie);
190     Double_t nsigma = TMath::Abs(tpcResponse.GetNumberOfSigmas(mom,dedx,track->GetTPCNcls(),type));
191    if (nsigma>fnSigma[0]) {
192     pid=-1; 
193    }else{
194     pid=specie;
195    }
196   }
197
198  return pid;
199
200 }
201 //----------------------------
202 Int_t AliAODPidHF::ApplyPidITSRaw(AliAODTrack *track,Int_t specie) const{
203 // truncated mean, ITS PID
204
205   if(!CheckStatus(track,"ITS")) return 0;
206
207   Double_t mom=track->P();
208   AliAODPid *pidObj = track->GetDetPid();
209
210   Double_t dedx=pidObj->GetITSsignal();
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
220   AliITSPIDResponse itsResponse;
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
223    Double_t nsigmaMax=fnSigma[4];
224    for(Int_t ipart=0;ipart<5;ipart++){
225     AliPID::EParticleType type=AliPID::EParticleType(ipart);
226     Double_t nsigma = TMath::Abs(itsResponse.GetNumberOfSigmas(mom,dedx,type,nPointsForPid,isSA));
227     if((nsigma<nsigmaMax) && (nsigma<fnSigma[4])) {
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));
235    if (nsigma>fnSigma[4]) {
236     pid=-1; 
237    }else{
238     pid=specie;
239    }
240   }
241  return pid; 
242 }
243 //----------------------------
244 Int_t AliAODPidHF::ApplyPidTOFRaw(AliAODTrack *track,Int_t specie) const{
245 // n-sigma cut, TOF PID
246
247  if(!CheckStatus(track,"TOF")) return 0;
248
249  Double_t time[AliPID::kSPECIESN];
250  AliAODPid *pidObj = track->GetDetPid();
251  pidObj->GetIntegratedTimes(time);
252  Double_t sigTOF=pidObj->GetTOFsignal();
253 // AliTOFPIDResponse tofResponse;
254  Int_t pid=-1;
255
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
257    Double_t nsigmaMax=fTOFSigma*fnSigma[3];
258    for(Int_t ipart=0;ipart<5;ipart++){
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)) {
263      pid=ipart;
264      nsigmaMax=nsigma;
265     }
266    }
267   }else{ // asks only for one particle specie
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) {
272     pid=-1; 
273    }else{
274     pid=specie;
275    }
276   }
277  return pid; 
278
279 }
280 //------------------------------
281 void AliAODPidHF::CombinedProbability(AliAODTrack *track,Bool_t *type) const{
282 // combined PID stored inside the AOD track
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 //--------------------
298 void AliAODPidHF::BayesianProbability(AliAODTrack *track,Double_t *pid) const{
299 // bayesian PID for single detectors or combined
300
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);
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     }
318
319  return;
320
321 }
322 //------------------------------------
323 void AliAODPidHF::BayesianProbabilityITS(AliAODTrack *track,Double_t *prob) const{
324
325 // bayesian PID for ITS
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 //------------------------------------
336 void AliAODPidHF::BayesianProbabilityTPC(AliAODTrack *track,Double_t *prob) const{
337 // bayesian PID for TPC
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 //------------------------------------
353 void AliAODPidHF::BayesianProbabilityTOF(AliAODTrack *track,Double_t *prob) const{
354 // bayesian PID for TOF
355
356  AliAODpidUtil pid;
357  Double_t tofpid[AliPID::kSPECIES];
358  pid.MakeTOFPID(track,tofpid);
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 }
365 //---------------------------------
366 void AliAODPidHF::BayesianProbabilityTRD(AliAODTrack *track,Double_t *prob) const{
367 // bayesian PID for TRD
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 //--------------------------------
383 Bool_t AliAODPidHF::CheckStatus(AliAODTrack *track,TString detectors) const{
384
385 // Quality cuts on the tracks, detector by detector
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   }
394   if(nPointsForPid<3) return kFALSE;
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 }
423 //--------------------------------------------
424 Bool_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 //------------------
443 Int_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.)
447  // convention: 
448  // for the single detectors: -1 = kFALSE, 1 = kTRUE, 0 = compatible
449  // the method returns the sum of the response of the 2 detectors
450   if(fTPC && fTOF) {if(!CheckStatus(track,"TPC") && !CheckStatus(track,"TOF")) return 0;}
451
452   
453   Int_t tTPCinfo=0;
454   if(fTPC){
455   if(CheckStatus(track,"TPC")) {
456    if(fAsym) {
457     if(TPCRawAsym(track,specie)) {
458       tTPCinfo=1;
459      }else{
460       tTPCinfo=-1;
461      }
462    }else{
463     if(specie==2 && IsPionRaw(track,"TPC")) {
464      tTPCinfo=1;
465     }else{
466      tTPCinfo=-1;
467     }
468     if(specie==3 && IsKaonRaw(track,"TPC")) {
469      tTPCinfo=1;
470     }else{
471      tTPCinfo=-1;
472     }
473     if(specie==4 && IsProtonRaw(track,"TPC")) {
474      tTPCinfo=1;
475     }else{
476      tTPCinfo=-1;
477     }
478
479    }
480
481
482    if(compat && tTPCinfo<0){
483     Double_t sig0tmp=fnSigma[0];
484     SetSigma(0,3.);
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;
488     SetSigma(0,sig0tmp);
489    }
490
491   }
492  }
493
494  Int_t tTOFinfo=0;
495  if(fTOF){
496   if(!CheckStatus(track,"TOF") && fTPC) return tTPCinfo;
497
498   tTOFinfo=-1;
499  
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;
503
504   if(compat && tTOFinfo>0){
505    Double_t ptrack=track->P();
506    if(ptrack>1.5) tTOFinfo=0;
507   }
508  }
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
519  return tTPCinfo+tTOFinfo;
520 }
521  if(mode==2){
522   //TPC & TOF (a la' Yifei)
523  // convention: -1 = kFALSE, 1 = kTRUE, 0 = not identified
524   Int_t tTPCinfo=0; 
525   
526   if(fTPC && CheckStatus(track,"TPC")) {
527    tTPCinfo=1;
528    if(fAsym){
529     if(!TPCRawAsym(track,specie)) tTPCinfo=-1;
530    }else{
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;
534    }
535   }
536
537   Int_t tTOFinfo=1;
538   if(fTOF){
539    if(fTPC && !CheckStatus(track,"TOF")) return tTPCinfo;
540
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;
544   }
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  }
556
557    return -1;
558
559 }
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   
565   if(fTPC && fTOF) if(!CheckStatus(track,"TPC") && !CheckStatus(track,"TOF")) return 0;
566
567   Double_t ptrack=track->P();
568   
569
570   Int_t tTPCinfo=-1;
571
572    if(ptrack>=fPLimit[0] && ptrack<fPLimit[1] && fTPC) {  
573     if(!CheckStatus(track,"TPC")) return 0;
574     if(fAsym) {
575      if(TPCRawAsym(track,specie)) tTPCinfo=1;
576     }else{
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;
580     } 
581     return tTPCinfo;
582    }
583
584    Int_t tTOFinfo=-1;
585    if(ptrack>=fPLimit[1] && fTOF){
586     if(!CheckStatus(track,"TOF")) return 0;
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;
591    }
592
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
602  }
603
604  return -1;
605
606 }
607 //----------------------------------   
608 Int_t AliAODPidHF::MakeRawPid(AliAODTrack *track, Int_t specie){
609 // general method to compute PID
610  if(fMatch>0){
611   return MatchTPCTOF(track,fMatch,specie,fCompat); 
612  }else{
613   if(fTPC && !fTOF && !fITS) {
614    Int_t tTPCres=ApplyPidTPCRaw(track,specie);
615    if(tTPCres==specie){return 1;}else{return tTPCres;};
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) {
621    Int_t tTOFres=ApplyPidTOFRaw(track,specie); 
622    if(tTOFres==specie){return 1;}else{return tTOFres;};
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) {
629    Int_t tITSres=ApplyPidITSRaw(track,specie);
630    if(tITSres==specie){return 1;}else{return tITSres;};
631   }else{
632    AliError("You should enable just one detector if you don't want to match");
633    return 0;
634   }
635  } 
636   
637 }