bug fix in post analysis macro
[u/mrichter/AliRoot.git] / PWGPP / pid / AliPIDmaxProb.cxx
1 #include"AliPIDmaxProb.h"
2 #include"AliPIDResponse.h"
3 #include"AliAnalysisManager.h"
4 #include"AliInputEventHandler.h"
5
6 ClassImp(AliPIDmaxProb);
7
8 AliPIDmaxProb::AliPIDmaxProb(const char *name):
9   AliPIDperfCut(name),
10   fPIDCombined(NULL),
11   fMaskPID(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF),
12   fTPCin(kFALSE),
13   fTOFin(kFALSE)
14 {
15   fPIDCombined=new AliPIDCombined;
16   fPIDCombined->SetDefaultTPCPriors();
17 }
18 //--------------------------------------------------------------------
19 AliPIDmaxProb::AliPIDmaxProb():
20   AliPIDperfCut("AliPIDmaxProb"),
21   fPIDCombined(NULL),
22   fMaskPID(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF),
23   fTPCin(kFALSE),
24   fTOFin(kFALSE)
25 {
26   fPIDCombined=new AliPIDCombined;
27   fPIDCombined->SetDefaultTPCPriors();
28 }
29 //--------------------------------------------------------------------
30 Bool_t AliPIDmaxProb::IsSelected(AliVTrack *track,AliPID::EParticleType type) const{
31   Int_t nspecies = AliPID::kSPECIES;
32   if(type >= nspecies || type < 0) return 0; // type has not a proper value
33
34   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
35   AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
36   AliPIDResponse *PIDResponse=inputHandler->GetPIDResponse();
37
38   fPIDCombined->SetDetectorMask(fMaskPID);
39
40   Double_t prob[10] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
41
42   UInt_t detUsed = fPIDCombined->ComputeProbabilities(track, PIDResponse, prob);
43
44   if(fTPCin && !(detUsed & AliPIDResponse::kDetTPC)) return kFALSE;
45   if(fTOFin && !(detUsed & AliPIDResponse::kDetTOF)) return kFALSE;
46
47   Bool_t status = kTRUE;
48   for(Int_t i=0;i<nspecies;i++){
49     if(i != type && prob[type] <= prob[i]){
50       status = kFALSE;
51       break;
52     }
53   }
54
55   return status;
56 }