]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGPP/pid/AliAnalysisTaskLambdaBayes.cxx
PWGPP-3, ATO-19 - Reduce size of the space points for alignment (Laser calibration...
[u/mrichter/AliRoot.git] / PWGPP / pid / AliAnalysisTaskLambdaBayes.cxx
index d3cced19909153780eb1fdf30a3e95f4dd0dea1c..fb5a7ce6333b8a0dd8c6393b4aa1deeb893626a5 100644 (file)
@@ -69,12 +69,17 @@ AliAnalysisTaskLambdaBayes::AliAnalysisTaskLambdaBayes():
   fPIDCombined(NULL),
   fContPid(NULL),
   fContPid2(NULL),
+  fContUser(NULL),
+  fContUser2(NULL),
   fNLambda(0),
   fNpPos(0),
   fNpNeg(0),
   fHmismTOF(0),
   fHchannelTOFdistr(0),
-  fTypeCol(2)
+  fTypeCol(2),
+  fPIDuserCut(NULL),
+  fToEP(kFALSE),
+  fSpeciesRef(4)
 {
   // Default constructor (should not be used)
   fList->SetName("contLambdaBayes1");
@@ -90,6 +95,31 @@ AliAnalysisTaskLambdaBayes::AliAnalysisTaskLambdaBayes():
 
   TFile *fchDist = new TFile("$ALICE_ROOT/TOF/data/TOFchannelDist.root");
   fHchannelTOFdistr = (TH1D *) fchDist->Get("hTOFchanDist"); 
+
+  for(Int_t i=0;i < nCentrBin;i++){
+    fElTOF[i] = NULL; 
+    fElTPC[i] = NULL; 
+    fPiTOF[i] = NULL; 
+    fPiTPC[i] = NULL; 
+    fKaTOF[i] = NULL; 
+    fKaTPC[i] = NULL; 
+    fPrTOF[i] = NULL; 
+    fPrTPC[i] = NULL; 
+  }
+  for(Int_t i=0;i < 4;i++){
+    hMatching[i] = NULL;
+    hTracking[i] = NULL;
+  }
+
+  for(Int_t i=0;i < 1000;i++){
+    fPhiLambda[i] = 0.0;
+    fPtLambda[i] = 0.0;
+    fIPPos[i] = 0;
+    fIPNeg[i] = 0;
+    fIpP[i] = 0;
+    fIpN[i] = 0;
+    fMassLambda[i] = 0.0;
+  }
 }
 
 //______________________________________________________________________________
@@ -125,12 +155,17 @@ AliAnalysisTaskLambdaBayes::AliAnalysisTaskLambdaBayes(const char *name):
   fPIDCombined(NULL),
   fContPid(NULL),
   fContPid2(NULL),
+  fContUser(NULL),
+  fContUser2(NULL),
   fNLambda(0),
   fNpPos(0),
   fNpNeg(0),
   fHmismTOF(0),
   fHchannelTOFdistr(0),
-  fTypeCol(2)
+  fTypeCol(2),
+  fPIDuserCut(NULL),
+  fToEP(kFALSE),
+  fSpeciesRef(4)
 {
 
   DefineOutput(1, TList::Class());
@@ -152,6 +187,31 @@ AliAnalysisTaskLambdaBayes::AliAnalysisTaskLambdaBayes(const char *name):
 
   TFile *fchDist = new TFile("$ALICE_ROOT/TOF/data/TOFchannelDist.root");
   fHchannelTOFdistr = (TH1D *) fchDist->Get("hTOFchanDist"); 
+
+  for(Int_t i=0;i < nCentrBin;i++){
+    fElTOF[i] = NULL; 
+    fElTPC[i] = NULL; 
+    fPiTOF[i] = NULL; 
+    fPiTPC[i] = NULL; 
+    fKaTOF[i] = NULL; 
+    fKaTPC[i] = NULL; 
+    fPrTOF[i] = NULL; 
+    fPrTPC[i] = NULL; 
+  }
+  for(Int_t i=0;i < 4;i++){
+    hMatching[i] = NULL;
+    hTracking[i] = NULL;
+  }
+
+  for(Int_t i=0;i < 1000;i++){
+    fPhiLambda[i] = 0.0;
+    fPtLambda[i] = 0.0;
+    fIPPos[i] = 0;
+    fIPNeg[i] = 0;
+    fIpP[i] = 0;
+    fIpN[i] = 0;
+    fMassLambda[i] = 0.0;
+  }
 }
 //_____________________________________________________________________________
 AliAnalysisTaskLambdaBayes::~AliAnalysisTaskLambdaBayes()
@@ -172,9 +232,9 @@ void AliAnalysisTaskLambdaBayes::UserCreateOutputObjects()
 
   const Int_t nBinPid = 14;
 
-  Int_t binPid[nBinPid] = {1/*ptLambda*/,8/*EtaPP*/,20/*pt+*/,1/*pt-*/,5/*P+*/,1/*P-*/,2/*TOFmatch+*/,1/*TOFmatch-*/,2/*istrue*/,4/*Nsigma+*/,1/*Nsigma-*/,1/*DeltaPhi+*/,1/*DeltaPhi-*/,1/*Psi*/};
+  Int_t binPid[nBinPid] = {1/*ptKs*/,1+7*(!fToEP)/*EtaPiP*/,20/*pt+*/,1/*pt-*/,5/*P+*/,1/*P-*/,2/*TOFmatch+*/,1/*TOFmatch-*/,2/*istrue*/,4/*Nsigma+*/,1/*Nsigma-*/,1+4*(fToEP)/*DeltaPhi+*/,1/*DeltaPhi-*/,1+4*(fToEP)/*Psi*/};
 
-  Int_t binPid2[nBinPid] = {1/*ptLambda*/,8/*EtaPN*/,1/*pt+*/,20/*pt-*/,1/*P+*/,5/*P-*/,1/*TOFmatch+*/,2/*TOFmatch-*/,2/*istrue*/,1/*Nsigma+*/,4/*Nsigma-*/,1/*DeltaPhi+*/,1/*DeltaPhi-*/,1/*Psi*/};
+  Int_t binPid2[nBinPid] = {1/*ptKs*/,1+7*(!fToEP)/*EtaPiN*/,1/*pt+*/,20/*pt-*/,1/*P+*/,5/*P-*/,1/*TOFmatch+*/,2/*TOFmatch-*/,2/*istrue*/,1/*Nsigma+*/,4/*Nsigma-*/,1/*DeltaPhi+*/,1+4*(fToEP)/*DeltaPhi-*/,1+4*(fToEP)/*Psi*/};
 
   fContPid = new AliPIDperfContainer("contPID",nBinPid,binPid);
   fContPid->SetTitleX("M_{#Lambda}");
@@ -258,6 +318,46 @@ void AliAnalysisTaskLambdaBayes::UserCreateOutputObjects()
   fList->Add(fContPid);
   fList->Add(fContPid2);
 
+  const Int_t nBinUser = 6;
+  Int_t binUser[nBinUser] = {8/*Eta*/,20/*pt*/,2/*istrue*/,4/*whatSelection*/,1/*DeltaPhi*/,1/*Psi*/};
+  fContUser = new AliPIDperfContainer("contUserPID",nBinUser,binUser);
+  fContUser->SetTitleX("M_{#Lambda}");
+  fContUser->SetTitleY("centrality (%)");
+  fContUser->SetVarName(0,"#eta");
+  fContUser->SetVarRange(0,-0.8,0.8);
+  fContUser->SetVarName(1,"p_{T}");
+  fContUser->SetVarRange(1,0.3,4.3);
+  fContUser->SetVarName(2,"isLambdaTrue");
+  fContUser->SetVarRange(2,-0.5,1.5);
+  fContUser->SetVarName(3,"whatSelected"); // 0=no, 1=pi, 2=K, 3=p
+  fContUser->SetVarRange(3,-0.5,3.5);
+  fContUser->SetVarName(4,"#Delta#phi");
+  fContUser->SetVarRange(4,-TMath::Pi(),TMath::Pi());
+  fContUser->SetVarName(5,"#Psi");
+  fContUser->SetVarRange(5,-TMath::Pi()/2,TMath::Pi()/2);
+
+  fContUser2 = new AliPIDperfContainer("contUserPID2",nBinUser,binUser);
+  fContUser2->SetTitleX("M_{#Lambda}");
+  fContUser2->SetTitleY("centrality (%)");
+  fContUser2->SetVarName(0,"#eta");
+  fContUser2->SetVarRange(0,-0.8,0.8);
+  fContUser2->SetVarName(1,"p_{T}");
+  fContUser2->SetVarRange(1,0.3,4.3);
+  fContUser2->SetVarName(2,"isLambdaTrue");
+  fContUser2->SetVarRange(2,-0.5,1.5);
+  fContUser2->SetVarName(3,"whatSelected");
+  fContUser2->SetVarRange(3,-0.5,3.5);
+  fContUser2->SetVarName(4,"#Delta#phi");
+  fContUser2->SetVarRange(4,-TMath::Pi(),TMath::Pi());
+  fContUser2->SetVarName(5,"#Psi");
+ fContUser2->SetVarRange(5,-TMath::Pi()/2,TMath::Pi()/2);
+
+  fContUser->AddSpecies("Lambda",nDETsignal,binDETsignal,nDETsignal2,binDETsignal2);
+  fContUser2->AddSpecies("Lambda2",nDETsignal,binDETsignal,nDETsignal2,binDETsignal2);
+
+  fList->Add(fContUser);
+  fList->Add(fContUser2);
+
   hMatching[0] = new TH2F("hMatchAll","TOF matched (all);p_{T} (GeV/#it{c});centrality (%)",50,0,10,nDETsignal2,0,100);
   hMatching[1] = new TH2F("hMatchPi","TOF matched (#pi);p_{T} (GeV/#it{c});centrality (%)",50,0,10,nDETsignal2,0,100);
   hMatching[2] = new TH2F("hMatchKa","TOF matched (K);p_{T} (GeV/#it{c});centrality (%)",50,0,10,nDETsignal2,0,100);
@@ -372,6 +472,11 @@ void AliAnalysisTaskLambdaBayes::UserExec(Option_t *)
        v0Centr = centrality->GetCentralityPercentile("TRK"); 
       }
 
+      if(!fTypeCol){
+        v0Centr=100./(fOutputAOD->GetNumberOfTracks()/12.+1);
+        trkCentr=v0Centr;
+      }
+
       if((TMath::Abs(v0Centr - trkCentr) < 5.0 || (fTypeCol!=2)) && v0Centr>0){ // consistency cut on centrality selection
         fCentrality = v0Centr;
        Analyze(fOutputAOD); // Do analysis!!!!
@@ -411,11 +516,10 @@ void AliAnalysisTaskLambdaBayes::Analyze(AliAODEvent* aodEvent)
   else if(fCentrality < 80) icentr = 7;
 
   Float_t addMismatchForMC = 0.005;
-  if(fCentrality < 50) addMismatchForMC += 0.01;
+  if(fCentrality < 50) addMismatchForMC += 0.005;
   if(fCentrality < 20) addMismatchForMC += 0.02;
 
-  if(fTypeCol == 0) addMismatchForMC = 0.005;
-  else if(fTypeCol == 1) addMismatchForMC *= 0.5;
+  if(fTypeCol == 0 || fTypeCol == 1) addMismatchForMC = 0.005;
 
   fPsi = 0;
   /* Compute TPC EP */
@@ -454,16 +558,18 @@ void AliAnalysisTaskLambdaBayes::Analyze(AliAODEvent* aodEvent)
   AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
   AliPIDResponse *PIDResponse=inputHandler->GetPIDResponse();
 
-  PIDResponse->GetTOFResponse().SetTrackParameter(0,0.);
-  PIDResponse->GetTOFResponse().SetTrackParameter(1,0.);
-  PIDResponse->GetTOFResponse().SetTrackParameter(2,0.018);
-  PIDResponse->GetTOFResponse().SetTrackParameter(3,50.0);
+//   PIDResponse->GetTOFResponse().SetTrackParameter(0,0.);
+//   PIDResponse->GetTOFResponse().SetTrackParameter(1,0.);
+//   PIDResponse->GetTOFResponse().SetTrackParameter(2,0.018);
+//   PIDResponse->GetTOFResponse().SetTrackParameter(3,50.0);
 
   fPIDCombined->SetDetectorMask(AliPIDResponse::kDetTPC|AliPIDResponse::kDetTOF);
 
-  Double_t probP[10],probN[10];
-  Double_t nSigmaTPC,nSigmaTOF=6,nSigmaTPC2,nSigmaTOF2=6,nSigmaComb,nSigmaComb2;
 
+  Double_t probP[10] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
+  Double_t probN[10] = {0.,0.,0.,0.,0.,0.,0.,0.,0.,0.};
+  Double_t nSigmaTPC,nSigmaTOF=6,nSigmaTPC2,nSigmaTOF2=6,nSigmaComb,nSigmaComb2;
+  Double_t nSigmaTPCRef,nSigmaTOFRef=6,nSigmaCombRef;
   
   AliAODMCHeader *mcHeader = dynamic_cast<AliAODMCHeader*>(aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName()));
   TClonesArray *mcArray = NULL;
@@ -551,6 +657,9 @@ void AliAnalysisTaskLambdaBayes::Analyze(AliAODEvent* aodEvent)
     Bool_t isLambda = (KpTrack->Charge() > 0);
 
     nSigmaComb=5;
+    nSigmaCombRef=5;
+    nSigmaTOF=5;
+    nSigmaTOFRef=5;
     fPtKp=KpTrack->Pt(),fPhiKp=KpTrack->Phi(),fEtaKp=KpTrack->Eta();
     fPidKp=0;
 
@@ -560,14 +669,8 @@ void AliAnalysisTaskLambdaBayes::Analyze(AliAODEvent* aodEvent)
     fPIDCombined->GetPriors(KpTrack, oldpP, PIDResponse, detUsedP);
 
     
-    nSigmaTPC = PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kKaon);
-    if(isLambda)fKaTPC[icentr]->Fill(fPtKp,nSigmaTPC);
-    nSigmaTPC = PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kElectron);
-    if(isLambda) fElTPC[icentr]->Fill(fPtKp,nSigmaTPC);
-    nSigmaTPC = PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kPion);
-    if(isLambda)fPiTPC[icentr]->Fill(fPtKp,nSigmaTPC);
     nSigmaTPC = PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kProton);
-    if(isLambda) fPrTPC[icentr]->Fill(fPtKp,nSigmaTPC);
+    nSigmaTPCRef = PIDResponse->NumberOfSigmasTPC(KpTrack,(AliPID::EParticleType) fSpeciesRef);
 
     if(! (TMath::Abs(nSigmaTPC) < 5)) continue;
 
@@ -594,16 +697,23 @@ void AliAnalysisTaskLambdaBayes::Analyze(AliAODEvent* aodEvent)
       else{
        if(probP[4] > probP[3] && probP[4] > probP[2] && probP[4] > probP[0]) fPidKp += 128; // max prob
        
-       nSigmaTOF = PIDResponse->NumberOfSigmasTOF(KpTrack,AliPID::kElectron);
-       if(isLambda) fElTOF[icentr]->Fill(fPtKp,nSigmaTOF);
-       nSigmaTOF = PIDResponse->NumberOfSigmasTOF(KpTrack,AliPID::kKaon);
-       if(isLambda) fKaTOF[icentr]->Fill(fPtKp,nSigmaTOF);
-       nSigmaTOF = PIDResponse->NumberOfSigmasTOF(KpTrack,AliPID::kPion);
-       if(isLambda) fPiTOF[icentr]->Fill(fPtKp,nSigmaTOF);
+       if(isLambda){
+         nSigmaTOF = PIDResponse->NumberOfSigmasTOF(KpTrack,AliPID::kElectron);
+         if(TMath::Abs(PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kElectron))<1) fElTOF[icentr]->Fill(fPtKp,nSigmaTOF);
+         if(TMath::Abs(nSigmaTOF)<1) fElTPC[icentr]->Fill(fPtKp,PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kElectron));
+         nSigmaTOF = PIDResponse->NumberOfSigmasTOF(KpTrack,AliPID::kPion);
+         if(TMath::Abs(PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kPion))<1) fPiTOF[icentr]->Fill(fPtKp,nSigmaTOF);
+         if(TMath::Abs(nSigmaTOF)<1) fPiTPC[icentr]->Fill(fPtKp,PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kPion));
+         nSigmaTOF = PIDResponse->NumberOfSigmasTOF(KpTrack,AliPID::kKaon);
+         if(TMath::Abs(PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kKaon))<1) fKaTOF[icentr]->Fill(fPtKp,nSigmaTOF);
+         if(TMath::Abs(nSigmaTOF)<1) fKaTPC[icentr]->Fill(fPtKp,PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kKaon));
+       }
        nSigmaTOF = PIDResponse->NumberOfSigmasTOF(KpTrack,AliPID::kProton);
-       if(isLambda) fPrTOF[icentr]->Fill(fPtKp,nSigmaTOF);
-       
-       nSigmaTOF = TMath::Abs(nSigmaTOF);
+       nSigmaTOFRef = PIDResponse->NumberOfSigmasTOF(KpTrack,(AliPID::EParticleType) fSpeciesRef);
+       if(isLambda){
+         if(TMath::Abs(PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kProton))<1) fPrTOF[icentr]->Fill(fPtKp,nSigmaTOF);
+         if(TMath::Abs(nSigmaTOF)<1) fPrTPC[icentr]->Fill(fPtKp,PIDResponse->NumberOfSigmasTPC(KpTrack,AliPID::kProton));
+       }
        
        if(fIsMC){
          Float_t mismAdd = addMismatchForMC;
@@ -616,14 +726,16 @@ void AliAnalysisTaskLambdaBayes::Analyze(AliAODEvent* aodEvent)
            Float_t distIP = fHchannelTOFdistr->GetBinContent(channel);
            
            // generate random time
-           Float_t timeRandom = fHmismTOF->GetRandom() + distIP*3.35655419905265973e+00;
-           Double_t times[10];
-           KpTrack->GetIntegratedTimes(times);
-           nSigmaTOF = TMath::Abs(timeRandom - times[4])/PIDResponse->GetTOFResponse().GetExpectedSigma(KpTrack->P(), times[3], AliPID::kProton);
+           Float_t timeRandom = fHmismTOF->GetRandom() + distIP*3.35655419905265973e+01;
+           Double_t times[AliPID::kSPECIESC];
+           KpTrack->GetIntegratedTimes(times,AliPID::kSPECIESC);
+           nSigmaTOF = TMath::Abs(timeRandom - times[4])/PIDResponse->GetTOFResponse().GetExpectedSigma(KpTrack->P(), times[4], AliPID::kProton);
+           nSigmaTOFRef = TMath::Abs(timeRandom - times[fSpeciesRef])/PIDResponse->GetTOFResponse().GetExpectedSigma(KpTrack->P(), times[fSpeciesRef], (AliPID::EParticleType) fSpeciesRef);
          }
        }
 
        if(fCentrality < 20 && KpTrack->Pt() < 1.3 && KpTrack->Pt() > 1.2)fTOFTPCsignal->Fill(nSigmaTOF,nSigmaTPC);
+        nSigmaTOF = TMath::Abs(nSigmaTOF);
 
        if(nSigmaTOF < 2) fPidKp += 256;
        else if(nSigmaTOF < 3) fPidKp += 512;
@@ -632,21 +744,33 @@ void AliAnalysisTaskLambdaBayes::Analyze(AliAODEvent* aodEvent)
     
     if(tofMatch1){
       nSigmaComb = TMath::Sqrt(nSigmaTOF*nSigmaTOF + nSigmaTPC*nSigmaTPC);
+      nSigmaCombRef = TMath::Sqrt(nSigmaTOFRef*nSigmaTOFRef + nSigmaTPCRef*nSigmaTPCRef);
       if(nSigmaTOF < 5 && fCentrality < 20 && KpTrack->Pt() < 1.3 && KpTrack->Pt() > 1.2){
        fCombsignal->Fill(nSigmaComb);
       }
     } else {
       nSigmaComb = TMath::Abs(nSigmaTPC);
+      nSigmaCombRef = TMath::Abs(nSigmaTPCRef);
     }
 
     // use sigmaTOF instead of sigmaComb
-    //nSigmaComb = nSigmaTOF;
+    nSigmaTOFRef = TMath::Abs(nSigmaTOFRef);
+
+    if(tofMatch1){
+      nSigmaComb = nSigmaTOF;
+      nSigmaCombRef = nSigmaTOFRef;
+    }
 
     if(nSigmaComb < 2) nSigmaComb = 2;
     else if(nSigmaComb < 3) nSigmaComb = 3;
     else if(nSigmaComb < 5) nSigmaComb = 4.99;
     else nSigmaComb = 6;
 
+    if(nSigmaCombRef < 2) nSigmaCombRef = 2;
+    else if(nSigmaCombRef < 3) nSigmaCombRef = 3;
+    else if(nSigmaCombRef < 5) nSigmaCombRef = 4.99;
+    else nSigmaCombRef = 6;
+
     Int_t iks=-1;
     for(Int_t k=0;k < fNLambda;k++){ // find the Lambda which contains the positive track
       if(i == fIpP[k]) iks = k;
@@ -663,6 +787,9 @@ void AliAnalysisTaskLambdaBayes::Analyze(AliAODEvent* aodEvent)
        continue;
       }
 
+      nSigmaComb2 = 5;
+      nSigmaTOF2 = 5;
+
       if(!(KnTrack->Pt() > 0.3 && TMath::Abs(KnTrack->Eta()) < 0.8)) continue;
 
       fPtKn=KnTrack->Pt(),fPhiKn=KnTrack->Phi(),fEtaKn=KnTrack->Eta();
@@ -673,11 +800,9 @@ void AliAnalysisTaskLambdaBayes::Analyze(AliAODEvent* aodEvent)
       fPIDCombined->GetPriors(KnTrack, oldpN, PIDResponse, detUsedN);
 
       nSigmaTPC2 = PIDResponse->NumberOfSigmasTPC(KnTrack,AliPID::kPion);
-      
+   
       if(! (TMath::Abs(nSigmaTPC2) < 5)) continue;
       
-      nSigmaComb2=5;
-
       Int_t tofMatch2 = (KnTrack->GetStatus() & AliVTrack::kTOFout) && (KnTrack->GetStatus() & AliVTrack::kTIME);
       /*
       if(mcArray){
@@ -694,6 +819,26 @@ void AliAnalysisTaskLambdaBayes::Analyze(AliAODEvent* aodEvent)
 
        nSigmaTOF2 = PIDResponse->NumberOfSigmasTOF(KnTrack,AliPID::kPion);
 
+       if(fIsMC){
+         Float_t mismAdd = addMismatchForMC;
+         if(KnTrack->Pt() < 1) mismAdd = addMismatchForMC/KnTrack->Pt();
+         
+         if(gRandom->Rndm() < mismAdd){
+           Float_t etaAbs = TMath::Abs(KnTrack->Eta());
+           Int_t channel = Int_t(4334.09 - 4758.36 * etaAbs -1989.71 * etaAbs*etaAbs + 1957.62*etaAbs*etaAbs*etaAbs);
+           channel = channel % 8736;
+           Float_t distIP = fHchannelTOFdistr->GetBinContent(channel);
+           
+           // generate random time
+           Float_t timeRandom = fHmismTOF->GetRandom() + distIP*3.35655419905265973e+01;
+           Double_t times[AliPID::kSPECIESC];
+           KnTrack->GetIntegratedTimes(times,AliPID::kSPECIESC);
+           nSigmaTOF2 = TMath::Abs(timeRandom - times[4])/PIDResponse->GetTOFResponse().GetExpectedSigma(KnTrack->P(), times[4], AliPID::kProton);
+         }
+       }
+
+
+
        nSigmaTOF2 = TMath::Abs(nSigmaTOF2);
 
        if(nSigmaTOF2 < 2) fPidKn += 256;
@@ -723,7 +868,7 @@ void AliAnalysisTaskLambdaBayes::Analyze(AliAODEvent* aodEvent)
       }
 
       // use sigmaTOF instead of sigmaComb
-      //nSigmaComb2 = nSigmaTOF2;
+      if(tofMatch2) nSigmaComb2 = nSigmaTOF2;
 
       if(nSigmaComb2 < 2) nSigmaComb2 = 2;
       else if(nSigmaComb2 < 3) nSigmaComb2 = 3;
@@ -754,6 +899,11 @@ void AliAnalysisTaskLambdaBayes::Analyze(AliAODEvent* aodEvent)
       Double_t deltaphi1 = KpTrack->Phi() - fPsi;
       Double_t deltaphi2 = KnTrack->Phi() - fPsi;
 
+      if(gRandom->Rndm() < 0.5){
+       deltaphi1 += TMath::Pi();
+       deltaphi2 += TMath::Pi();
+      }
+
       while(deltaphi1 > TMath::Pi()) deltaphi1 -= TMath::Pi()*2;
       while(deltaphi1 < -TMath::Pi()) deltaphi1 += TMath::Pi()*2;
       while(deltaphi2 > TMath::Pi()) deltaphi2 -= TMath::Pi()*2;
@@ -761,8 +911,8 @@ void AliAnalysisTaskLambdaBayes::Analyze(AliAODEvent* aodEvent)
 
       if(fPtKn > 4.299) fPtKn = 4.299;
 
-      Float_t xTOfill[] = {fPtLambdaC,KpTrack->Eta(),fPtKp,fPtKn,(fPidKp%128)*0.01,(fPidKn%128)*0.01,tofMatch1,tofMatch2,isTrue,nSigmaComb,nSigmaComb2,deltaphi1,deltaphi2,fPsi};
-      Float_t xTOfill2[] = {fPtLambdaC,KpTrack->Eta(),fPtKn,fPtKp,(fPidKn%128)*0.01,(fPidKp%128)*0.01,tofMatch2,tofMatch1,isTrue,nSigmaComb2,nSigmaComb,deltaphi2,deltaphi1,fPsi};
+      Float_t xTOfill[] = {static_cast<Float_t>(fPtLambdaC),static_cast<Float_t>(KpTrack->Eta()),static_cast<Float_t>(fPtKp),static_cast<Float_t>(fPtKn,(fPidKp%128)*0.01),static_cast<Float_t>((fPidKn%128)*0.01),static_cast<Float_t>(tofMatch1),static_cast<Float_t>(tofMatch2),static_cast<Float_t>(isTrue),static_cast<Float_t>(nSigmaComb),static_cast<Float_t>(nSigmaComb2),static_cast<Float_t>(deltaphi1),static_cast<Float_t>(deltaphi2),static_cast<Float_t>(fPsi)};
+      Float_t xTOfill2[] = {static_cast<Float_t>(fPtLambdaC),static_cast<Float_t>(KpTrack->Eta()),static_cast<Float_t>(fPtKn),static_cast<Float_t>(fPtKp),static_cast<Float_t>((fPidKn%128)*0.01),static_cast<Float_t>((fPidKp%128)*0.01),static_cast<Float_t>(tofMatch2),static_cast<Float_t>(tofMatch1),static_cast<Float_t>(isTrue),static_cast<Float_t>(nSigmaComb2),static_cast<Float_t>(nSigmaComb),static_cast<Float_t>(deltaphi2),static_cast<Float_t>(deltaphi1),static_cast<Float_t>(fPsi)};
       
 
       Int_t ipt = 0;
@@ -773,8 +923,34 @@ void AliAnalysisTaskLambdaBayes::Analyze(AliAODEvent* aodEvent)
       if(ipt < 0) ipt = 0; // just to be sure
 
       if(TMath::Abs(fEtaLambda) < 0.8 && fPtKp > 0.3 && fPtKn > 0.3){
+       if(fSpeciesRef != 4){
+         xTOfill[4] = probP[fSpeciesRef];
+         xTOfill2[5] = probP[fSpeciesRef];
+
+         xTOfill[9] = nSigmaCombRef;
+         xTOfill2[10] = nSigmaCombRef;
+
+       }
+
        if(isLambda) fContPid->Fill(0,fMassV0,fCentrality,xTOfill);
        else fContPid2->Fill(0,fMassV0,fCentrality,xTOfill2);
+
+
+
+       if(fPIDuserCut){
+         Float_t xUser[] = {static_cast<Float_t>(KpTrack->Eta()),static_cast<Float_t>(fPtKp),static_cast<Float_t>(isTrue),0,static_cast<Float_t>(deltaphi1),static_cast<Float_t>(fPsi)};
+         
+         if(fPIDuserCut->IsSelected(KpTrack,AliPID::kPion)){ // to be filled
+           xUser[3] = 1;
+         } else if(fPIDuserCut->IsSelected(KpTrack,AliPID::kKaon)){
+           xUser[3] = 2;
+         } else if(fPIDuserCut->IsSelected(KpTrack,AliPID::kProton)){
+           xUser[3] = 3;
+         }
+         
+        if(isLambda) fContUser->Fill(0,fMassV0,fCentrality,xUser);
+         else fContUser2->Fill(0,fMassV0,fCentrality,xUser);
+       }
       }
 
 
@@ -820,7 +996,9 @@ void AliAnalysisTaskLambdaBayes::SelectLambda(){
       if(pass==1) dMASS = myV0->MassLambda();
       else dMASS = myV0->MassAntiLambda();
 
-      if(TMath::Abs(dMASS-1.115)/0.005 < 8){
+      Float_t massKs = myV0->MassK0Short();
+
+      if(TMath::Abs(dMASS-1.115)/0.005 < 8 && TMath::Abs(massKs - 0.497)/0.005 > 8){
        AliAODTrack *iT=(AliAODTrack*) myV0->GetDaughter(0); // positive
        AliAODTrack *jT=(AliAODTrack*) myV0->GetDaughter(1); // negative
        if(iT->Charge()<0){