Added the possibility to the user to manage own PID
[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 {
13   fPIDCombined=new AliPIDCombined;
14   fPIDCombined->SetDefaultTPCPriors();
15 }
16 //--------------------------------------------------------------------
17 AliPIDmaxProb::AliPIDmaxProb():
18   AliPIDperfCut("AliPIDmaxProb"),
19   fPIDCombined(NULL),
20   fMaskPID(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF)
21 {
22   fPIDCombined=new AliPIDCombined;
23   fPIDCombined->SetDefaultTPCPriors();
24 }
25 //--------------------------------------------------------------------
26 Bool_t AliPIDmaxProb::IsSelected(AliVTrack *track,AliPID::EParticleType type) const{
27   Int_t nspecies = AliPID::kSPECIES;
28   if(type >= nspecies || type < 0) return 0; // type has not a proper value
29
30   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
31   AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
32   AliPIDResponse *PIDResponse=inputHandler->GetPIDResponse();
33
34   fPIDCombined->SetDetectorMask(fMaskPID);
35
36   Double_t prob[10] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
37
38   /* UInt_t detUsed = */fPIDCombined->ComputeProbabilities(track, PIDResponse, prob);
39
40   Bool_t status = kTRUE;
41   for(Int_t i=0;i<nspecies;i++){
42     if(i != type && prob[type] <= prob[i]){
43       status = kFALSE;
44       break;
45     }
46   }
47
48   return status;
49 }