Cleaning up files, added documentation. Added ntuple for v0s.
[u/mrichter/AliRoot.git] / PWG4 / GammaConv / AliV0Reader.cxx
index 7e39f1f..b5ecfba 100644 (file)
@@ -187,7 +187,9 @@ AliESDv0* AliV0Reader::GetV0(Int_t index){
   UpdateV0Information();\r
   return fCurrentV0;\r
 }\r
-\r
+Bool_t AliV0Reader::CheckForPrimaryVertex(){\r
+  return fESDEvent->GetPrimaryVertex()->GetNContributors()>0;\r
+}\r
 \r
 Bool_t AliV0Reader::NextV0(){\r
   //see header file for documentation\r
@@ -199,28 +201,35 @@ Bool_t AliV0Reader::NextV0(){
     //checks if on the fly mode is set\r
     if ( !fCurrentV0->GetOnFlyStatus() ){\r
       fCurrentV0IndexNumber++;\r
-      fHistograms->FillHistogram("V0MassDebugCut1",GetMotherCandidateMass());\r
+      if(fHistograms != NULL){\r
+       fHistograms->FillHistogram("V0MassDebugCut1",GetMotherCandidateMass());\r
+      }\r
       continue;\r
     }\r
 \r
     if(fESDEvent->GetPrimaryVertex()->GetNContributors()<=0) {//checks if we have a vertex\r
       fCurrentV0IndexNumber++;\r
-      fHistograms->FillHistogram("V0MassDebugCut2",GetMotherCandidateMass());\r
+      if(fHistograms != NULL){\r
+       fHistograms->FillHistogram("V0MassDebugCut2",GetMotherCandidateMass());\r
+      }\r
       continue;\r
     }\r
 \r
     if(CheckPIDProbability(fPIDProbabilityCutNegativeParticle,fPIDProbabilityCutPositiveParticle)==kFALSE){\r
       fCurrentV0IndexNumber++;\r
-      fHistograms->FillHistogram("V0MassDebugCut3",GetMotherCandidateMass());\r
+      if(fHistograms != NULL){\r
+       fHistograms->FillHistogram("V0MassDebugCut3",GetMotherCandidateMass());\r
+      }\r
       continue;\r
     }\r
 \r
-\r
     fCurrentV0->GetXYZ(fCurrentXValue,fCurrentYValue,fCurrentZValue);\r
  \r
     if(GetXYRadius()>fMaxR){ // cuts on distance from collision point\r
       fCurrentV0IndexNumber++;\r
-      fHistograms->FillHistogram("V0MassDebugCut4",GetMotherCandidateMass());\r
+      if(fHistograms != NULL){\r
+       fHistograms->FillHistogram("V0MassDebugCut4",GetMotherCandidateMass());\r
+      }\r
       continue;\r
     }\r
 \r
@@ -229,28 +238,35 @@ Bool_t AliV0Reader::NextV0(){
     if(fUseKFParticle){\r
       if(fCurrentMotherKFCandidate->GetNDF()<=0){\r
        fCurrentV0IndexNumber++;\r
-       fHistograms->FillHistogram("V0MassDebugCut5",GetMotherCandidateMass());\r
+       if(fHistograms != NULL){\r
+         fHistograms->FillHistogram("V0MassDebugCut5",GetMotherCandidateMass());\r
+       }\r
        continue;\r
       }\r
       Double_t chi2V0 = fCurrentMotherKFCandidate->GetChi2()/fCurrentMotherKFCandidate->GetNDF();\r
       if(chi2V0 > fChi2CutConversion || chi2V0 <=0){\r
        fCurrentV0IndexNumber++;\r
-       fHistograms->FillHistogram("V0MassDebugCut6",GetMotherCandidateMass());\r
+       if(fHistograms != NULL){\r
+         fHistograms->FillHistogram("V0MassDebugCut6",GetMotherCandidateMass());\r
+       }\r
        continue;\r
       }\r
       \r
       if(TMath::Abs(fMotherCandidateLorentzVector->Eta())> fEtaCut){\r
        fCurrentV0IndexNumber++;\r
-       fHistograms->FillHistogram("V0MassDebugCut7",GetMotherCandidateMass());\r
+       if(fHistograms != NULL){\r
+         fHistograms->FillHistogram("V0MassDebugCut7",GetMotherCandidateMass());\r
+       }\r
        continue;\r
       }\r
       \r
       if(fMotherCandidateLorentzVector->Pt()<fPtCut){\r
        fCurrentV0IndexNumber++;\r
-       fHistograms->FillHistogram("V0MassDebugCut8",GetMotherCandidateMass());\r
+       if(fHistograms != NULL){\r
+         fHistograms->FillHistogram("V0MassDebugCut8",GetMotherCandidateMass());\r
+       }\r
        continue;\r
       }\r
-      \r
     }\r
     else if(fUseESDTrack){\r
       //TODO\r
@@ -335,8 +351,12 @@ void AliV0Reader::UpdateV0Information(){
   }\r
     \r
   if(fDoMC == kTRUE){\r
+    fMotherMCParticle= NULL;\r
     fNegativeMCParticle = fMCStack->Particle(TMath::Abs(fESDEvent->GetTrack(fCurrentV0->GetNindex())->GetLabel()));\r
     fPositiveMCParticle = fMCStack->Particle(TMath::Abs(fESDEvent->GetTrack(fCurrentV0->GetPindex())->GetLabel()));\r
+    if(fPositiveMCParticle->GetMother(0)>-1){\r
+      fMotherMCParticle = fMCStack->Particle(fPositiveMCParticle->GetMother(0));\r
+    }\r
   }\r
   fCurrentEventGoodV0s.push_back(*fCurrentMotherKFCandidate);\r
 }\r
@@ -348,8 +368,9 @@ Bool_t AliV0Reader::HasSameMCMother(){
   if(fDoMC == kTRUE){\r
     if(fNegativeMCParticle != NULL && fPositiveMCParticle != NULL){\r
       if(fNegativeMCParticle->GetMother(0) == fPositiveMCParticle->GetMother(0))\r
-       fMotherMCParticle = fMCStack->Particle(fPositiveMCParticle->GetMother(0));\r
-      iResult = kTRUE;\r
+       if(fMotherMCParticle){\r
+         iResult = kTRUE;\r
+       }\r
     }\r
   }\r
   return iResult;\r
@@ -378,6 +399,24 @@ Bool_t AliV0Reader::CheckPIDProbability(Double_t negProbCut, Double_t posProbCut
   return iResult;\r
 }\r
 \r
+void AliV0Reader::GetPIDProbability(Double_t &negPIDProb,Double_t & posPIDProb){\r
+\r
+  Double_t *posProbArray = new Double_t[10];\r
+  Double_t *negProbArray = new Double_t[10];\r
+  AliESDtrack* negTrack  = fESDEvent->GetTrack(fCurrentV0->GetNindex());\r
+  AliESDtrack* posTrack  = fESDEvent->GetTrack(fCurrentV0->GetPindex());\r
+  \r
+  negTrack->GetTPCpid(negProbArray);\r
+  posTrack->GetTPCpid(posProbArray);\r
+\r
+  if(negProbArray!=NULL && posProbArray!=NULL){\r
+    negPIDProb = negProbArray[GetSpeciesIndex(-1)];\r
+    posPIDProb = posProbArray[GetSpeciesIndex(1)];\r
+  }\r
+  delete [] posProbArray;\r
+  delete [] negProbArray;\r
+}\r
+\r
 void AliV0Reader::UpdateEventByEventData(){\r
   //see header file for documentation\r
 \r