1 /**************************************************************************
2 * Copyright(c) 1998-2006, ALICE Experiment at CERN, All rights reserved. *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
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 * *************************************************************************/
17 //***********************************************************
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 "AliAODTrack.h"
26 #include "AliTPCPIDResponse.h"
27 #include "AliITSPIDResponse.h"
28 #include "AliTOFPIDResponse.h"
29 #include "AliAODpidUtil.h"
30 #include "AliESDtrack.h"
35 //------------------------------
36 AliAODPidHF::AliAODPidHF():
48 // Default constructor
50 fPLimit=new Double_t[fnPLimit];
51 fnSigma=new Double_t[fnNSigma];
52 fPriors=new Double_t[fnPriors];
54 for(Int_t i=0;i<fnNSigma;i++){
57 for(Int_t i=0;i<fnPriors;i++){
60 for(Int_t i=0;i<fnPLimit;i++){
65 //----------------------
66 AliAODPidHF::~AliAODPidHF()
69 // if(fPLimit) delete fPLimit;
70 // if(fnSigma) delete fnSigma;
71 // if(fPriors) delete fPriors;
73 //------------------------
74 AliAODPidHF::AliAODPidHF(const AliAODPidHF& pid) :
76 fnNSigma(pid.fnNSigma),
78 fTOFSigma(pid.fTOFSigma),
79 fnPriors(pid.fnPriors),
81 fnPLimit(pid.fnPLimit),
86 for(Int_t i=0;i<5;i++){
87 fPriors[i]=pid.fPriors[i];
92 //----------------------
93 Int_t AliAODPidHF::RawSignalPID(AliAODTrack *track, TString detector) const{
94 // raw PID for single detectors, returns the particle type with smaller sigma
96 if(detector.Contains("ITS")) return ApplyPidITSRaw(track,specie);
97 if(detector.Contains("TPC")) return ApplyPidTPCRaw(track,specie);
98 if(detector.Contains("TOF")) return ApplyPidTOFRaw(track,specie);
103 //---------------------------
104 Bool_t AliAODPidHF::IsKaonRaw(AliAODTrack *track, TString detector) const{
105 // checks if the track can be a kaon, raw PID applied for single detectors
108 if(detector.Contains("ITS")) specie=ApplyPidITSRaw(track,3);
109 if(detector.Contains("TPC")) specie=ApplyPidTPCRaw(track,3);
110 if(detector.Contains("TOF")) specie=ApplyPidTOFRaw(track,3);
112 if(specie==3) return kTRUE;
115 //---------------------------
116 Bool_t AliAODPidHF::IsPionRaw (AliAODTrack *track, TString detector) const{
117 // checks if the track can be a pion, raw PID applied for single detectors
121 if(detector.Contains("ITS")) specie=ApplyPidITSRaw(track,2);
122 if(detector.Contains("TPC")) specie=ApplyPidTPCRaw(track,2);
123 if(detector.Contains("TOF")) specie=ApplyPidTOFRaw(track,2);
125 if(specie==2) return kTRUE;
128 //---------------------------
129 Bool_t AliAODPidHF::IsProtonRaw (AliAODTrack *track, TString detector) const{
130 // checks if the track can be a proton raw PID applied for single detectors
133 if(detector.Contains("ITS")) specie=ApplyPidITSRaw(track,4);
134 if(detector.Contains("TPC")) specie=ApplyPidTPCRaw(track,4);
135 if(detector.Contains("TOF")) specie=ApplyPidTOFRaw(track,4);
137 if(specie==4) return kTRUE;
141 //--------------------------
142 Bool_t AliAODPidHF::IsElectronRaw(AliAODTrack *track, TString detector) const{
143 // checks if the track can be an electron raw PID applied for single detectors
146 if(detector.Contains("ITS")) specie=ApplyPidITSRaw(track,0);
147 if(detector.Contains("TPC")) specie=ApplyPidTPCRaw(track,0);
148 if(detector.Contains("TOF")) specie=ApplyPidTOFRaw(track,0);
150 if(specie==0) return kTRUE;
154 //--------------------------
155 Int_t AliAODPidHF::ApplyPidTPCRaw(AliAODTrack *track,Int_t specie) const{
156 // n-sigma cut, TPC PID
158 if(!CheckStatus(track,"TPC")) return -1;
159 AliAODPid *pidObj = track->GetDetPid();
161 Double_t dedx=pidObj->GetTPCsignal();
162 Double_t mom = pidObj->GetTPCmomentum();
163 AliTPCPIDResponse tpcResponse;
165 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
166 Double_t nsigmaMax=fnSigma[0];
167 for(Int_t ipart=0;ipart<5;ipart++){
168 AliPID::EParticleType type=AliPID::EParticleType(ipart);
169 Double_t nsigma = TMath::Abs(tpcResponse.GetNumberOfSigmas(mom,dedx,track->GetTPCNcls(),type));
170 if((nsigma<nsigmaMax) && (nsigma<fnSigma[0])) {
175 }else{ // asks only for one particle specie
176 AliPID::EParticleType type=AliPID::EParticleType(specie);
177 Double_t nsigma = TMath::Abs(tpcResponse.GetNumberOfSigmas(mom,dedx,track->GetTPCNcls(),type));
178 if (nsigma>fnSigma[0]) {
188 //----------------------------
189 Int_t AliAODPidHF::ApplyPidITSRaw(AliAODTrack *track,Int_t specie) const{
190 // truncated mean, ITS PID
192 if(!CheckStatus(track,"ITS")) return -1;
194 Double_t mom=track->P();
195 AliAODPid *pidObj = track->GetDetPid();
197 Double_t dedx=pidObj->GetITSsignal();
198 AliITSPIDResponse itsResponse;
200 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
201 Double_t nsigmaMax=fnSigma[4];
202 for(Int_t ipart=0;ipart<5;ipart++){
203 AliPID::EParticleType type=AliPID::EParticleType(ipart);
204 Double_t nsigma = TMath::Abs(itsResponse.GetNumberOfSigmas(mom,dedx,type));
205 if((nsigma<nsigmaMax) && (nsigma<fnSigma[4])) {
210 }else{ // asks only for one particle specie
211 AliPID::EParticleType type=AliPID::EParticleType(specie);
212 Double_t nsigma = TMath::Abs(itsResponse.GetNumberOfSigmas(mom,dedx,type));
213 if (nsigma>fnSigma[4]) {
221 //----------------------------
222 Int_t AliAODPidHF::ApplyPidTOFRaw(AliAODTrack *track,Int_t specie) const{
223 // n-sigma cut, TOF PID
225 if(!CheckStatus(track,"TOF")) return -1;
227 Double_t time[AliPID::kSPECIESN];
228 AliAODPid *pidObj = track->GetDetPid();
229 pidObj->GetIntegratedTimes(time);
230 Double_t sigTOF=pidObj->GetTOFsignal();
231 // AliTOFPIDResponse tofResponse;
234 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
235 Double_t nsigmaMax=fTOFSigma*fnSigma[3];
236 for(Int_t ipart=0;ipart<5;ipart++){
237 //AliPID::EParticleType type=AliPID::EParticleType(ipart);
238 //Double_t nsigma = tofResponse.GetExpectedSigma(track->P(),time[type],AliPID::ParticleMass(type));
239 Double_t nsigma=TMath::Abs(sigTOF-time[ipart]);
240 if((nsigma<nsigmaMax) && (nsigma<fnSigma[3]*fTOFSigma)) {
245 }else{ // asks only for one particle specie
246 //AliPID::EParticleType type=AliPID::EParticleType(specie);
247 //Double_t nsigma = TMath::Abs(tofResponse.GetExpectedSigma(track->P(),time[type],AliPID::ParticleMass(type)));
248 Double_t nsigma=TMath::Abs(sigTOF-time[specie]);
249 if (nsigma>fnSigma[3]*fTOFSigma) {
258 //------------------------------
259 void AliAODPidHF::CombinedProbability(AliAODTrack *track,Bool_t *type) const{
260 // combined PID stored inside the AOD track
262 const Double_t *pid=track->PID();
265 for (Int_t i=0; i<10; i++) {
266 if (pid[i]>max) {k=i; max=pid[i];}
269 if(k==2) type[0]=kTRUE;
270 if(k==3) type[1]=kTRUE;
271 if(k==4) type[2]=kTRUE;
275 //--------------------
276 void AliAODPidHF::BayesianProbability(AliAODTrack *track,TString detectors,Double_t *pid) const{
277 // bayesian PID for single detectors or combined
279 if(detectors.Contains("ITS")) {BayesianProbabilityITS(track,pid);return;}
280 if(detectors.Contains("TPC")) {BayesianProbabilityTPC(track,pid);return;}
281 if(detectors.Contains("TOF")) {BayesianProbabilityTOF(track,pid);return;}
283 if(detectors.Contains("All")) {
284 Double_t probITS[5]={0.,0.,0.,0.,0.};
285 Double_t probTPC[5]={0.,0.,0.,0.,0.};
286 Double_t probTOF[5]={0.,0.,0.,0.,0.};
287 BayesianProbabilityITS(track,probITS);
288 BayesianProbabilityTPC(track,probTPC);
289 BayesianProbabilityTOF(track,probTOF);
290 Double_t probTot[5]={0.,0.,0.,0.,0.};
291 for(Int_t i=0;i<5;i++){
292 probTot[i]=probITS[i]*probTPC[i]*probTOF[i];
294 for(Int_t i2=0;i2<5;i2++){
295 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]);
302 //------------------------------------
303 void AliAODPidHF::BayesianProbabilityITS(AliAODTrack *track,Double_t *prob) const{
305 // bayesian PID for ITS
307 Double_t itspid[AliPID::kSPECIES];
308 pid.MakeITSPID(track,itspid);
309 for(Int_t ind=0;ind<AliPID::kSPECIES;ind++){
310 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]);
315 //------------------------------------
316 void AliAODPidHF::BayesianProbabilityTPC(AliAODTrack *track,Double_t *prob) const{
317 // bayesian PID for TPC
320 Double_t tpcpid[AliPID::kSPECIES];
321 pid.MakeTPCPID(track,tpcpid);
322 for(Int_t ind=0;ind<AliPID::kSPECIES;ind++){
324 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]);
332 //------------------------------------
333 void AliAODPidHF::BayesianProbabilityTOF(AliAODTrack *track,Double_t *prob) const{
334 // bayesian PID for TOF
337 Double_t tofpid[AliPID::kSPECIES];
338 pid.MakeTOFPID(track,tofpid);
339 for(Int_t ind=0;ind<AliPID::kSPECIES;ind++){
340 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]);
345 //---------------------------------
346 void AliAODPidHF::BayesianProbabilityTRD(AliAODTrack *track,Double_t *prob) const{
347 // bayesian PID for TRD
350 Double_t trdpid[AliPID::kSPECIES];
351 pid.MakeTRDPID(track,trdpid);
352 for(Int_t ind=0;ind<AliPID::kSPECIES;ind++){
354 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]);
362 //--------------------------------
363 Bool_t AliAODPidHF::CheckStatus(AliAODTrack *track,TString detectors) const{
365 // Quality cuts on the tracks, detector by detector
367 if(detectors.Contains("ITS")){
368 if ((track->GetStatus()&AliESDtrack::kITSin)==0) return kFALSE;
369 UChar_t clumap=track->GetITSClusterMap();
370 Int_t nPointsForPid=0;
371 for(Int_t i=2; i<6; i++){
372 if(clumap&(1<<i)) ++nPointsForPid;
374 if(nPointsForPid<3) return kFALSE;// track not to be used for PID purposes
377 if(detectors.Contains("TPC")){
378 if ((track->GetStatus()&AliESDtrack::kTPCin )==0) return kFALSE;
379 UShort_t nTPCClus=track->GetTPCClusterMap().CountBits();
380 if (nTPCClus<70) return kFALSE;
383 if(detectors.Contains("TOF")){
384 if ((track->GetStatus()&AliESDtrack::kTOFout )==0) return kFALSE;
385 if ((track->GetStatus()&AliESDtrack::kTIME )==0) return kFALSE;
386 if ((track->GetStatus()&AliESDtrack::kTOFpid )==0) return kFALSE;
390 if(detectors.Contains("TRD")){
391 if ((track->GetStatus()&AliESDtrack::kTRDout )==0) return kFALSE;
392 AliAODPid *pidObj = track->GetDetPid();
393 Float_t *mom=pidObj->GetTRDmomentum();
395 for(Int_t iPl=0;iPl<6;iPl++){
396 if(mom[iPl]>0.) ntracklets++;
398 if(ntracklets<4) return kFALSE;
403 //--------------------------------------------
404 Bool_t AliAODPidHF::TPCRawAsym(AliAODTrack* track,Int_t specie) const{
405 // TPC nsigma cut PID, different sigmas in different p bins
407 if(!CheckStatus(track,"TPC")) return kFALSE;
408 AliAODPid *pidObj = track->GetDetPid();
409 Double_t mom = pidObj->GetTPCmomentum();
410 Double_t dedx=pidObj->GetTPCsignal();
412 AliTPCPIDResponse tpcResponse;
413 AliPID::EParticleType type=AliPID::EParticleType(specie);
414 Double_t nsigma = TMath::Abs(tpcResponse.GetNumberOfSigmas(mom,dedx,track->GetTPCNcls(),type));
416 if(mom<fPLimit[0] && nsigma<fnSigma[0]) return kTRUE;
417 if(mom<fPLimit[1] && mom>fPLimit[0] && nsigma<fnSigma[1]) return kTRUE;
418 if(mom>fPLimit[1] && nsigma<fnSigma[2]) return kTRUE;
423 Int_t AliAODPidHF::MatchTPCTOF(AliAODTrack *track,Int_t mode,Int_t specie,Bool_t compat){
424 // combination of the PID info coming from TPC and TOF
426 //TOF || TPC (a la' Andrea R.)
427 // convention (temporary):
428 // for the single detectors: -1 = kFALSE, 1 = kTRUE, 0 = compatible
429 // the method returns the sum of the response of the 2 detectors
430 if(!CheckStatus(track,"TPC") && !CheckStatus(track,"TOF")) return 0;
433 if(CheckStatus(track,"TPC")) {
435 if(TPCRawAsym(track,specie)) TPCinfo=1;
437 if(specie==2 && IsPionRaw(track,"TPC")) TPCinfo=1;
438 if(specie==3 && IsKaonRaw(track,"TPC")) TPCinfo=1;
439 if(specie==4 && IsProtonRaw(track,"TPC")) TPCinfo=1;
443 if(compat && TPCinfo<0){
444 Double_t sig0tmp=fnSigma[0];
446 if(specie==2 && IsPionRaw(track,"TPC")) TPCinfo=0;
447 if(specie==3 && IsKaonRaw(track,"TPC")) TPCinfo=0;
448 if(specie==4 && IsProtonRaw(track,"TPC")) TPCinfo=0;
454 if(!CheckStatus(track,"TOF")) return TPCinfo;
458 if(specie==2 && IsPionRaw(track,"TOF")) TOFinfo=1;
459 if(specie==3 && IsKaonRaw(track,"TOF")) TOFinfo=1;
460 if(specie==4 && IsProtonRaw(track,"TOF")) TOFinfo=1;
462 if(compat && TOFinfo>0){
463 Double_t ptrack=track->P();
464 if(ptrack>1.5) TOFinfo=0;
467 return TPCinfo+TOFinfo;
470 //TPC & TOF (a la' Yifei)
471 // convention (temporary): -1 = kFALSE, 1 = kTRUE, 0 = not identified
473 if(CheckStatus(track,"TPC")) {
475 if(!TPCRawAsym(track,specie)) TPCinfo=-1;
477 if(specie==2 && !IsPionRaw(track,"TPC")) TPCinfo=-1;
478 if(specie==3 && !IsKaonRaw(track,"TPC")) TPCinfo=-1;
479 if(specie==4 && !IsProtonRaw(track,"TPC")) TPCinfo=-1;
484 if(!CheckStatus(track,"TOF")) return TPCinfo;
486 if(specie==2 && !IsPionRaw(track,"TOF")) TOFinfo=-1;
487 if(specie==3 && !IsKaonRaw(track,"TOF")) TOFinfo=-1;
488 if(specie==4 && !IsProtonRaw(track,"TOF")) TOFinfo=-1;
490 if(TOFinfo==1 && TPCinfo==1) return 1;
496 //TPC for p<fPLimit[0], TOF for p>=fPLimit[0] (a la' Andrea A.)
497 // convention (temporary): -1 = kFALSE, 1 = kTRUE, 0 = not identified
499 if(!CheckStatus(track,"TPC") && !CheckStatus(track,"TOF")) return 0;
501 Double_t ptrack=track->P();
506 if(ptrack<fPLimit[0]) {
507 if(!CheckStatus(track,"TPC")) return 0;
509 if(TPCRawAsym(track,specie)) TPCinfo=1;
511 if(specie==2 && IsPionRaw(track,"TPC")) TPCinfo=1;
512 if(specie==3 && IsKaonRaw(track,"TPC")) TPCinfo=1;
513 if(specie==4 && IsProtonRaw(track,"TPC")) TPCinfo=1;
519 if(ptrack>=fPLimit[0]){
520 if(!CheckStatus(track,"TOF")) return 0;
521 if(specie==2 && IsPionRaw(track,"TOF")) TOFinfo=1;
522 if(specie==3 && IsKaonRaw(track,"TOF")) TOFinfo=1;
523 if(specie==4 && IsProtonRaw(track,"TOF")) TOFinfo=1;