Proper usage of the bayesian approach (Alis Rodriguez Manso)
[u/mrichter/AliRoot.git] / PWGCF / EBYE / BalanceFunctions / AliAnalysisTaskBF.cxx
index 6e75e91..72ef420 100755 (executable)
@@ -70,12 +70,14 @@ AliAnalysisTaskBF::AliAnalysisTaskBF(const char *name)
   fHistBetavsPTOFbeforePID(NULL), \r
   fHistProbTPCvsPtbeforePID(NULL), \r
   fHistProbTOFvsPtbeforePID(NULL), \r
+  fHistProbTPCTOFvsPtbeforePID(NULL),\r
   fHistNSigmaTPCvsPtbeforePID(NULL), \r
   fHistNSigmaTOFvsPtbeforePID(NULL), \r
   fHistdEdxVsPTPCafterPID(NULL),\r
   fHistBetavsPTOFafterPID(NULL), \r
   fHistProbTPCvsPtafterPID(NULL), \r
   fHistProbTOFvsPtafterPID(NULL), \r
+  fHistProbTPCTOFvsPtafterPID(NULL),\r
   fHistNSigmaTPCvsPtafterPID(NULL), \r
   fHistNSigmaTOFvsPtafterPID(NULL),  \r
   fPIDResponse(0x0),\r
@@ -301,11 +303,14 @@ void AliAnalysisTaskBF::UserCreateOutputObjects() {
     fHistBetavsPTOFbeforePID = new TH2D ("BetavsPTOFbefore","BetavsPTOFbefore", 1000, -10.0, 10., 1000, 0, 1.2); \r
     fHistListPIDQA->Add(fHistBetavsPTOFbeforePID); //addition\r
     \r
-    fHistProbTPCvsPtbeforePID = new TH2D ("ProbTPCvsPtbefore","ProbTPCvsPtbefore", 1000, -10.0,10.0, 1000, 0, 100); \r
+    fHistProbTPCvsPtbeforePID = new TH2D ("ProbTPCvsPtbefore","ProbTPCvsPtbefore", 1000, -10.0,10.0, 1000, 0, 2.0); \r
     fHistListPIDQA->Add(fHistProbTPCvsPtbeforePID); //addition \r
     \r
-    fHistProbTOFvsPtbeforePID = new TH2D ("ProbTOFvsPtbefore","ProbTOFvsPtbefore", 1000, -50, 50, 1000, 0, 100); \r
+    fHistProbTOFvsPtbeforePID = new TH2D ("ProbTOFvsPtbefore","ProbTOFvsPtbefore", 1000, -50, 50, 1000, 0, 2.0); \r
     fHistListPIDQA->Add(fHistProbTOFvsPtbeforePID); //addition \r
+\r
+    fHistProbTPCTOFvsPtbeforePID =new TH2D ("ProbTPCTOFvsPtbefore","ProbTPCTOFvsPtbefore", 1000, -50, 50, 1000, 0, 2.0); \r
+    fHistListPIDQA->Add(fHistProbTPCTOFvsPtbeforePID); //addition \r
     \r
     fHistNSigmaTPCvsPtbeforePID = new TH2D ("NSigmaTPCvsPtbefore","NSigmaTPCvsPtbefore", 1000, -10, 10, 1000, 0, 500); \r
     fHistListPIDQA->Add(fHistNSigmaTPCvsPtbeforePID); //addition \r
@@ -325,6 +330,9 @@ void AliAnalysisTaskBF::UserCreateOutputObjects() {
     fHistProbTOFvsPtafterPID = new TH2D ("ProbTOFvsPtafter","ProbTOFvsPtafter", 1000,  -10, 10, 1000, 0, 2); \r
     fHistListPIDQA->Add(fHistProbTOFvsPtafterPID); //addition  \r
     \r
+    fHistProbTPCTOFvsPtafterPID =new TH2D ("ProbTPCTOFvsPtafter","ProbTPCTOFvsPtafter", 1000, -50, 50, 1000, 0, 2.0); \r
+    fHistListPIDQA->Add(fHistProbTPCTOFvsPtafterPID); //addition \r
+\r
     fHistNSigmaTPCvsPtafterPID = new TH2D ("NSigmaTPCvsPtafter","NSigmaTPCvsPtafter", 1000, -10, 10, 1000, 0, 500); \r
     fHistListPIDQA->Add(fHistNSigmaTPCvsPtafterPID); //addition  \r
     \r
@@ -457,26 +465,41 @@ void AliAnalysisTaskBF::UserExec(Option_t *) {
                    //===========================PID===============================//               \r
                    if(fUsePID) {\r
                      Double_t prob[AliPID::kSPECIES]={0.};\r
+                     Double_t probTPC[AliPID::kSPECIES]={0.};\r
+                     Double_t probTOF[AliPID::kSPECIES]={0.};\r
+                     Double_t probTPCTOF[AliPID::kSPECIES]={0.};\r
+\r
                      Double_t nSigma = 0.;\r
+                      UInt_t detUsedTPC = 0;\r
+                     UInt_t detUsedTOF = 0;\r
+                      UInt_t detUsedTPCTOF = 0;\r
+\r
                      //Decide what detector configuration we want to use\r
                      switch(fPidDetectorConfig) {\r
                      case kTPCpid:\r
                        fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC);\r
                        nSigma = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(track,(AliPID::EParticleType)fParticleOfInterest));\r
+                       detUsedTPC = fPIDCombined->ComputeProbabilities(track, fPIDResponse, probTPC);\r
+                       for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++)\r
+                         prob[iSpecies] = probTPC[iSpecies];\r
                        break;\r
                      case kTOFpid:\r
                        fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTOF);\r
                        nSigma = TMath::Abs(fPIDResponse->NumberOfSigmasTOF(track,(AliPID::EParticleType)fParticleOfInterest));\r
+                       detUsedTOF = fPIDCombined->ComputeProbabilities(track, fPIDResponse, probTOF);\r
+                       for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++)\r
+                         prob[iSpecies] = probTOF[iSpecies];\r
                        break;\r
                      case kTPCTOF:\r
                        fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTOF|AliPIDResponse::kDetTPC);\r
+                       detUsedTPCTOF = fPIDCombined->ComputeProbabilities(track, fPIDResponse, probTPCTOF);\r
+                       for(Int_t iSpecies = 0; iSpecies < AliPID::kSPECIES; iSpecies++)\r
+                         prob[iSpecies] = probTPCTOF[iSpecies];\r
                        break;\r
                      default:\r
                        break;\r
                      }//end switch: define detector mask\r
                      \r
-                     UInt_t detUsed = fPIDCombined->ComputeProbabilities(track, fPIDResponse, prob);\r
-                     \r
                      //Filling the PID QA\r
                      Double_t tofTime = -999., length = 999., tof = -999.;\r
                      Double_t c = TMath::C()*1.E-9;// m/ns\r
@@ -503,18 +526,19 @@ void AliAnalysisTaskBF::UserExec(Option_t *) {
                        \r
                        nSigmaTOFForParticleOfInterest = fPIDResponse->NumberOfSigmasTOF(track,(AliPID::EParticleType)fParticleOfInterest);\r
                        fHistBetavsPTOFbeforePID ->Fill(track->P()*track->Charge(),beta);\r
-                       fHistProbTOFvsPtbeforePID ->Fill(track->Pt(),prob[fParticleOfInterest]);\r
+                       fHistProbTOFvsPtbeforePID ->Fill(track->Pt(),probTOF[fParticleOfInterest]);\r
                        fHistNSigmaTOFvsPtbeforePID ->Fill(track->Pt(),nSigmaTOFForParticleOfInterest);\r
                      }//TOF signal \r
                      \r
                      \r
                      Double_t  nSigmaTPCForParticleOfInterest = fPIDResponse->NumberOfSigmasTPC(track,(AliPID::EParticleType)fParticleOfInterest);\r
                      fHistdEdxVsPTPCbeforePID -> Fill(track->P()*track->Charge(),track->GetTPCsignal());\r
-                     fHistProbTPCvsPtbeforePID -> Fill(track->Pt(),prob[fParticleOfInterest]); \r
+                     fHistProbTPCvsPtbeforePID -> Fill(track->Pt(),probTPC[fParticleOfInterest]); \r
                      fHistNSigmaTPCvsPtbeforePID -> Fill(track->Pt(),nSigmaTPCForParticleOfInterest); \r
+                     fHistProbTPCTOFvsPtbeforePID -> Fill(track->Pt(),probTPCTOF[fParticleOfInterest]);\r
                      //end of QA-before pid\r
                      \r
-                     if (detUsed != 0) {\r
+                     if ((detUsedTPC != 0)||(detUsedTOF != 0)||(detUsedTPCTOF != 0)) {\r
                        //Make the decision based on the n-sigma\r
                        if(fUsePIDnSigma) {\r
                          if(nSigma > fPIDNSigma) continue;}\r
@@ -527,11 +551,12 @@ void AliAnalysisTaskBF::UserExec(Option_t *) {
                        \r
                        //Fill QA after the PID\r
                        fHistBetavsPTOFafterPID ->Fill(track->P()*track->Charge(),beta);\r
-                       fHistProbTOFvsPtafterPID ->Fill(track->Pt(),prob[fParticleOfInterest]);\r
+                       fHistProbTOFvsPtafterPID ->Fill(track->Pt(),probTOF[fParticleOfInterest]);\r
                        fHistNSigmaTOFvsPtafterPID ->Fill(track->Pt(),nSigmaTOFForParticleOfInterest);\r
                        \r
                        fHistdEdxVsPTPCafterPID -> Fill(track->P()*track->Charge(),track->GetTPCsignal());\r
-                       fHistProbTPCvsPtafterPID -> Fill(track->Pt(),prob[fParticleOfInterest]); \r
+                       fHistProbTPCvsPtafterPID -> Fill(track->Pt(),probTPC[fParticleOfInterest]); \r
+                       fHistProbTPCTOFvsPtafterPID -> Fill(track->Pt(),probTPCTOF[fParticleOfInterest]);\r
                        fHistNSigmaTPCvsPtafterPID -> Fill(track->Pt(),nSigmaTPCForParticleOfInterest); \r
                      }\r
                      \r