Changed to new naming scheme for histograms, added functionality to the analysis...
[u/mrichter/AliRoot.git] / PWG4 / GammaConv / AliV0Reader.cxx
index b5ecfba..970e4e6 100644 (file)
@@ -26,6 +26,7 @@
 #include "AliV0Reader.h"\r
 #include "AliAnalysisManager.h"\r
 #include "AliESDInputHandler.h"\r
+#include "AliESDtrack.h"\r
 #include "AliMCEvent.h"\r
 #include "AliKFVertex.h"\r
 \r
@@ -43,53 +44,55 @@ ClassImp(AliV0Reader)
 \r
 \r
 \r
-  AliV0Reader::AliV0Reader() :\r
-    TObject(),\r
-    fMCStack(NULL),\r
-    fMCTruth(NULL),\r
-    fChain(NULL),\r
-    fESDHandler(NULL),\r
-    fESDEvent(NULL),\r
-    fHistograms(NULL),\r
-    fCurrentV0IndexNumber(0),\r
-    fCurrentV0(NULL),\r
-    fCurrentNegativeKFParticle(NULL),\r
-    fCurrentPositiveKFParticle(NULL),\r
-    fCurrentMotherKFCandidate(NULL),\r
-    fCurrentNegativeESDTrack(NULL),\r
-    fCurrentPositiveESDTrack(NULL),\r
-    fNegativeTrackLorentzVector(NULL),\r
-    fPositiveTrackLorentzVector(NULL),\r
-    fMotherCandidateLorentzVector(NULL),\r
-    fCurrentXValue(0),\r
-    fCurrentYValue(0),\r
-    fCurrentZValue(0),\r
-    fPositiveTrackPID(0),\r
-    fNegativeTrackPID(0),\r
-    fNegativeMCParticle(NULL),\r
-    fPositiveMCParticle(NULL),\r
-    fMotherMCParticle(NULL),\r
-    fMotherCandidateKFMass(0),\r
-    fMotherCandidateKFWidth(0),\r
-    fUseKFParticle(kTRUE),\r
-    fUseESDTrack(kFALSE),\r
-    fDoMC(kFALSE),\r
-    fMaxR(10000),// 100 meter(outside of ALICE)\r
-    fEtaCut(0.),\r
-    fPtCut(0.),\r
-    fChi2CutConversion(0.),\r
-    fChi2CutMeson(0.),\r
-    fPIDProbabilityCutNegativeParticle(0),\r
-    fPIDProbabilityCutPositiveParticle(0),\r
-    fXVertexCut(0.),\r
-    fYVertexCut(0.),\r
-    fZVertexCut(0.),\r
-    fNSigmaMass(0.),\r
-    fUseImprovedVertex(kFALSE),\r
-    fCurrentEventGoodV0s(),\r
-    fPreviousEventGoodV0s()\r
+AliV0Reader::AliV0Reader() :\r
+TObject(),\r
+  fMCStack(NULL),\r
+  fMCTruth(NULL),\r
+  fChain(NULL),\r
+  fESDHandler(NULL),\r
+  fESDEvent(NULL),\r
+  fHistograms(NULL),\r
+  fCurrentV0IndexNumber(0),\r
+  fCurrentV0(NULL),\r
+  fCurrentNegativeKFParticle(NULL),\r
+  fCurrentPositiveKFParticle(NULL),\r
+  fCurrentMotherKFCandidate(NULL),\r
+  fCurrentNegativeESDTrack(NULL),\r
+  fCurrentPositiveESDTrack(NULL),\r
+  fNegativeTrackLorentzVector(NULL),\r
+  fPositiveTrackLorentzVector(NULL),\r
+  fMotherCandidateLorentzVector(NULL),\r
+  fCurrentXValue(0),\r
+  fCurrentYValue(0),\r
+  fCurrentZValue(0),\r
+  fPositiveTrackPID(0),\r
+  fNegativeTrackPID(0),\r
+  fNegativeMCParticle(NULL),\r
+  fPositiveMCParticle(NULL),\r
+  fMotherMCParticle(NULL),\r
+  fMotherCandidateKFMass(0),\r
+  fMotherCandidateKFWidth(0),\r
+  fUseKFParticle(kTRUE),\r
+  fUseESDTrack(kFALSE),\r
+  fDoMC(kFALSE),\r
+  fMaxR(10000),// 100 meter(outside of ALICE)\r
+  fEtaCut(0.),\r
+  fPtCut(0.),\r
+  fLineCutZRSlope(0.),\r
+  fLineCutZValue(0.),\r
+  fChi2CutConversion(0.),\r
+  fChi2CutMeson(0.),\r
+  fPIDProbabilityCutNegativeParticle(0),\r
+  fPIDProbabilityCutPositiveParticle(0),\r
+  fXVertexCut(0.),\r
+  fYVertexCut(0.),\r
+  fZVertexCut(0.),\r
+  fNSigmaMass(0.),\r
+  fUseImprovedVertex(kFALSE),\r
+  fCurrentEventGoodV0s(),\r
+  fPreviousEventGoodV0s()\r
 {\r
-\r
+       \r
 }\r
 \r
 \r
@@ -127,6 +130,8 @@ AliV0Reader::AliV0Reader(const AliV0Reader & original) :
   fMaxR(original.fMaxR),\r
   fEtaCut(original.fEtaCut),\r
   fPtCut(original.fPtCut),\r
+  fLineCutZRSlope(original.fLineCutZRSlope),\r
+  fLineCutZValue(original.fLineCutZValue),\r
   fChi2CutConversion(original.fChi2CutConversion),\r
   fChi2CutMeson(original.fChi2CutMeson),\r
   fPIDProbabilityCutNegativeParticle(original.fPIDProbabilityCutNegativeParticle),\r
@@ -139,7 +144,7 @@ AliV0Reader::AliV0Reader(const AliV0Reader & original) :
   fCurrentEventGoodV0s(original.fCurrentEventGoodV0s),\r
   fPreviousEventGoodV0s(original.fPreviousEventGoodV0s)\r
 {\r
-\r
+       \r
 }\r
 \r
 \r
@@ -151,171 +156,252 @@ AliV0Reader & AliV0Reader::operator = (const AliV0Reader & /*source*/)
 \r
 void AliV0Reader::Initialize(){\r
   //see header file for documentation\r
-\r
+       \r
   // Get the input handler from the manager\r
   fESDHandler = (AliESDInputHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());\r
   if(fESDHandler == NULL){\r
     //print warning here\r
   }\r
-  \r
+       \r
   // Get pointer to esd event from input handler\r
   fESDEvent = fESDHandler->GetEvent();\r
   if(fESDEvent == NULL){\r
     //print warning here\r
   }\r
-\r
+       \r
   //Get pointer to MCTruth\r
   fMCTruth = (AliMCEventHandler*)((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());\r
   if(fMCTruth == NULL){\r
     //print warning here\r
   }\r
-\r
+       \r
   //Get pointer to the mc stack\r
   fMCStack = fMCTruth->MCEvent()->Stack();\r
   if(fMCStack == NULL){\r
     //print warning here\r
   }\r
-\r
+       \r
   AliKFParticle::SetField(fESDEvent->GetMagneticField());\r
-\r
+       \r
 }\r
 \r
 AliESDv0* AliV0Reader::GetV0(Int_t index){\r
   //see header file for documentation\r
-\r
+       \r
   fCurrentV0 = fESDEvent->GetV0(index);\r
   UpdateV0Information();\r
   return fCurrentV0;\r
 }\r
+\r
 Bool_t AliV0Reader::CheckForPrimaryVertex(){\r
   return fESDEvent->GetPrimaryVertex()->GetNContributors()>0;\r
 }\r
 \r
+\r
+\r
 Bool_t AliV0Reader::NextV0(){\r
   //see header file for documentation\r
-\r
+       \r
   Bool_t iResult=kFALSE;\r
   while(fCurrentV0IndexNumber<fESDEvent->GetNumberOfV0s()){\r
     fCurrentV0 = fESDEvent->GetV0(fCurrentV0IndexNumber);\r
-    \r
+               \r
     //checks if on the fly mode is set\r
     if ( !fCurrentV0->GetOnFlyStatus() ){\r
-      fCurrentV0IndexNumber++;\r
       if(fHistograms != NULL){\r
-       fHistograms->FillHistogram("V0MassDebugCut1",GetMotherCandidateMass());\r
+       fHistograms->FillHistogram("ESD_CutGetOnFly_InvMass",GetMotherCandidateMass());\r
       }\r
+      fCurrentV0IndexNumber++;\r
       continue;\r
     }\r
-\r
-    if(fESDEvent->GetPrimaryVertex()->GetNContributors()<=0) {//checks if we have a vertex\r
-      fCurrentV0IndexNumber++;\r
+    \r
+    //checks if we have a prim vertex\r
+    if(fESDEvent->GetPrimaryVertex()->GetNContributors()<=0) { \r
       if(fHistograms != NULL){\r
-       fHistograms->FillHistogram("V0MassDebugCut2",GetMotherCandidateMass());\r
+       fHistograms->FillHistogram("ESD_CutNContributors_InvMass",GetMotherCandidateMass());\r
       }\r
+      fCurrentV0IndexNumber++;\r
       continue;\r
     }\r
-\r
+               \r
+    //Check the pid probability\r
     if(CheckPIDProbability(fPIDProbabilityCutNegativeParticle,fPIDProbabilityCutPositiveParticle)==kFALSE){\r
-      fCurrentV0IndexNumber++;\r
       if(fHistograms != NULL){\r
-       fHistograms->FillHistogram("V0MassDebugCut3",GetMotherCandidateMass());\r
+       fHistograms->FillHistogram("ESD_CutPIDProb_InvMass",GetMotherCandidateMass());\r
       }\r
+      fCurrentV0IndexNumber++;\r
       continue;\r
     }\r
-\r
+               \r
+               \r
     fCurrentV0->GetXYZ(fCurrentXValue,fCurrentYValue,fCurrentZValue);\r
\r
+               \r
+               \r
     if(GetXYRadius()>fMaxR){ // cuts on distance from collision point\r
+      if(fHistograms != NULL){\r
+       fHistograms->FillHistogram("ESD_CutR_InvMass",GetMotherCandidateMass());\r
+      }\r
       fCurrentV0IndexNumber++;\r
+      continue;\r
+    }          \r
+               \r
+               \r
+    if((TMath::Abs(fCurrentZValue)*fLineCutZRSlope)-fLineCutZValue > GetXYRadius() ){ // cuts out regions where we do not reconstruct\r
       if(fHistograms != NULL){\r
-       fHistograms->FillHistogram("V0MassDebugCut4",GetMotherCandidateMass());\r
+       fHistograms->FillHistogram("ESD_CutLine_InvMass",GetMotherCandidateMass());\r
       }\r
+      fCurrentV0IndexNumber++;\r
+      continue;\r
+    }          \r
+               \r
+               \r
+    if(UpdateV0Information() == kFALSE){\r
+      fCurrentV0IndexNumber++;\r
       continue;\r
     }\r
-\r
-    UpdateV0Information();\r
-        \r
+               \r
     if(fUseKFParticle){\r
       if(fCurrentMotherKFCandidate->GetNDF()<=0){\r
-       fCurrentV0IndexNumber++;\r
        if(fHistograms != NULL){\r
-         fHistograms->FillHistogram("V0MassDebugCut5",GetMotherCandidateMass());\r
+         fHistograms->FillHistogram("ESD_CutNDF_InvMass",GetMotherCandidateMass());\r
        }\r
+       fCurrentV0IndexNumber++;\r
        continue;\r
       }\r
+                       \r
+                       \r
       Double_t chi2V0 = fCurrentMotherKFCandidate->GetChi2()/fCurrentMotherKFCandidate->GetNDF();\r
       if(chi2V0 > fChi2CutConversion || chi2V0 <=0){\r
-       fCurrentV0IndexNumber++;\r
        if(fHistograms != NULL){\r
-         fHistograms->FillHistogram("V0MassDebugCut6",GetMotherCandidateMass());\r
+         fHistograms->FillHistogram("ESD_CutChi2_InvMass",GetMotherCandidateMass());\r
        }\r
-       continue;\r
+       fCurrentV0IndexNumber++;\r
+       continue;\r
       }\r
-      \r
+                       \r
+                       \r
       if(TMath::Abs(fMotherCandidateLorentzVector->Eta())> fEtaCut){\r
-       fCurrentV0IndexNumber++;\r
        if(fHistograms != NULL){\r
-         fHistograms->FillHistogram("V0MassDebugCut7",GetMotherCandidateMass());\r
+         fHistograms->FillHistogram("ESD_CutEta_InvMass",GetMotherCandidateMass());\r
        }\r
+       fCurrentV0IndexNumber++;\r
        continue;\r
       }\r
-      \r
+                       \r
+                       \r
       if(fMotherCandidateLorentzVector->Pt()<fPtCut){\r
-       fCurrentV0IndexNumber++;\r
        if(fHistograms != NULL){\r
-         fHistograms->FillHistogram("V0MassDebugCut8",GetMotherCandidateMass());\r
+         fHistograms->FillHistogram("ESD_CutPt_InvMass",GetMotherCandidateMass());\r
        }\r
+       fCurrentV0IndexNumber++;\r
        continue;\r
       }\r
+                       \r
+                       \r
     }\r
     else if(fUseESDTrack){\r
       //TODO\r
     }\r
 \r
-    iResult=kTRUE;//means we have a v0 who survived all the cuts applied\r
+    fCurrentEventGoodV0s.push_back(*fCurrentMotherKFCandidate);\r
 \r
+    iResult=kTRUE;//means we have a v0 who survived all the cuts applied\r
+               \r
     fCurrentV0IndexNumber++;\r
-    \r
+               \r
     break;\r
   }\r
   return iResult; \r
 }\r
 \r
-void AliV0Reader::UpdateV0Information(){\r
+Bool_t AliV0Reader::UpdateV0Information(){\r
   //see header file for documentation\r
-  \r
+\r
+  Bool_t iResult=kTRUE;                                                // for taking out not refitted, kinks and like sign tracks \r
+\r
+  Bool_t switchTracks = kFALSE;\r
+       \r
+  fCurrentNegativeESDTrack = fESDEvent->GetTrack(fCurrentV0->GetNindex());\r
+  fCurrentPositiveESDTrack = fESDEvent->GetTrack(fCurrentV0->GetPindex());\r
+       \r
+  if(fCurrentNegativeESDTrack->GetSign() == fCurrentPositiveESDTrack->GetSign()){             // avoid like sign\r
+    iResult=kFALSE;\r
+    if(fHistograms != NULL){\r
+      fHistograms->FillHistogram("ESD_CutLikeSign_InvMass",GetMotherCandidateMass());\r
+    }\r
+  }\r
+       \r
+  if(fCurrentPositiveESDTrack->GetSign() == -1 && fCurrentNegativeESDTrack->GetSign() == 1){  // switch wrong signed tracks\r
+    fCurrentNegativeESDTrack = fESDEvent->GetTrack(fCurrentV0->GetPindex());\r
+    fCurrentPositiveESDTrack = fESDEvent->GetTrack(fCurrentV0->GetNindex());\r
+    switchTracks = kTRUE;\r
+  }\r
+\r
+  if( !(fCurrentNegativeESDTrack->GetStatus() & AliESDtrack::kTPCrefit) || \r
+      !(fCurrentPositiveESDTrack->GetStatus() & AliESDtrack::kTPCrefit) ){\r
+    //  if( !(fCurrentNegativeESDTrack->GetStatus() & AliESDtrack::kITSrefit) || \r
+    //      !(fCurrentPositiveESDTrack->GetStatus() & AliESDtrack::kITSrefit) ){\r
+         \r
+    iResult=kFALSE;\r
+    if(fHistograms != NULL){\r
+      fHistograms->FillHistogram("ESD_CutRefit_InvMass",GetMotherCandidateMass());\r
+    }\r
+  }\r
+       \r
+       \r
+  if( fCurrentNegativeESDTrack->GetKinkIndex(0) > 0 || \r
+      fCurrentPositiveESDTrack->GetKinkIndex(0) > 0) {                 \r
+               \r
+    iResult=kFALSE;\r
+    if(fHistograms != NULL){\r
+      fHistograms->FillHistogram("ESD_CutKink_InvMass",GetMotherCandidateMass());\r
+    }\r
+  }\r
+\r
+\r
+       \r
   if(fCurrentNegativeKFParticle != NULL){\r
     delete fCurrentNegativeKFParticle;\r
   }\r
-  fCurrentNegativeKFParticle = new AliKFParticle(*(fCurrentV0->GetParamN()),fNegativeTrackPID);\r
-  \r
+  if(switchTracks == kFALSE){\r
+    fCurrentNegativeKFParticle = new AliKFParticle(*(fCurrentV0->GetParamN()),fNegativeTrackPID);\r
+  }\r
+  else{\r
+    fCurrentNegativeKFParticle = new AliKFParticle(*(fCurrentV0->GetParamP()),fNegativeTrackPID);\r
+  }\r
+\r
   if(fCurrentPositiveKFParticle != NULL){\r
     delete fCurrentPositiveKFParticle;\r
   }\r
-  fCurrentPositiveKFParticle = new AliKFParticle(*(fCurrentV0->GetParamP()),fPositiveTrackPID);\r
+  if(switchTracks == kFALSE){\r
+    fCurrentPositiveKFParticle = new AliKFParticle(*(fCurrentV0->GetParamP()),fPositiveTrackPID);\r
+  }\r
+  else{\r
+    fCurrentPositiveKFParticle = new AliKFParticle(*(fCurrentV0->GetParamN()),fPositiveTrackPID);\r
+  }\r
     \r
   if(fCurrentMotherKFCandidate != NULL){\r
     delete fCurrentMotherKFCandidate;\r
   }\r
   fCurrentMotherKFCandidate = new AliKFParticle(*fCurrentNegativeKFParticle,*fCurrentPositiveKFParticle);\r
 \r
-  fCurrentNegativeESDTrack = fESDEvent->GetTrack(fCurrentV0->GetNindex());\r
-\r
-  fCurrentPositiveESDTrack = fESDEvent->GetTrack(fCurrentV0->GetPindex());\r
 \r
   if(fPositiveTrackPID==-11 && fNegativeTrackPID==11){\r
     fCurrentMotherKFCandidate->SetMassConstraint(0,fNSigmaMass);\r
   }\r
-\r
+       \r
+       \r
+       \r
+       \r
   if(fUseImprovedVertex == kTRUE){\r
     AliKFVertex primaryVertexImproved(*GetPrimaryVertex());\r
     primaryVertexImproved+=*fCurrentMotherKFCandidate;\r
     fCurrentMotherKFCandidate->SetProductionVertex(primaryVertexImproved);\r
   }\r
-\r
+       \r
   fCurrentMotherKFCandidate->GetMass(fMotherCandidateKFMass,fMotherCandidateKFWidth);\r
-\r
-\r
+       \r
+       \r
   if(fNegativeTrackLorentzVector != NULL){\r
     delete fNegativeTrackLorentzVector;\r
   }\r
@@ -325,7 +411,7 @@ void AliV0Reader::UpdateV0Information(){
   else if(fUseESDTrack){\r
     fNegativeTrackLorentzVector = new TLorentzVector(fCurrentNegativeESDTrack->Px(),fCurrentNegativeESDTrack->Py(),fCurrentNegativeESDTrack->Pz());\r
   }\r
-\r
+       \r
   if(fPositiveTrackLorentzVector != NULL){\r
     delete fPositiveTrackLorentzVector;\r
   }\r
@@ -335,7 +421,7 @@ void AliV0Reader::UpdateV0Information(){
   else if(fUseESDTrack){\r
     fPositiveTrackLorentzVector = new TLorentzVector(fCurrentPositiveESDTrack->Px(),fCurrentPositiveESDTrack->Py(),fCurrentPositiveESDTrack->Pz());\r
   }\r
-\r
+       \r
   if(fMotherCandidateLorentzVector != NULL){\r
     delete fMotherCandidateLorentzVector;\r
   }\r
@@ -345,11 +431,12 @@ void AliV0Reader::UpdateV0Information(){
   else if(fUseESDTrack){\r
     fMotherCandidateLorentzVector = new TLorentzVector(*fNegativeTrackLorentzVector + *fPositiveTrackLorentzVector);\r
   }\r
-\r
+       \r
   if(fPositiveTrackPID==-11 && fNegativeTrackPID==11){\r
     fMotherCandidateLorentzVector->SetXYZM(fMotherCandidateLorentzVector->Px() ,fMotherCandidateLorentzVector->Py(),fMotherCandidateLorentzVector->Pz(),0.); \r
   }\r
     \r
+       \r
   if(fDoMC == kTRUE){\r
     fMotherMCParticle= NULL;\r
     fNegativeMCParticle = fMCStack->Particle(TMath::Abs(fESDEvent->GetTrack(fCurrentV0->GetNindex())->GetLabel()));\r
@@ -358,12 +445,19 @@ void AliV0Reader::UpdateV0Information(){
       fMotherMCParticle = fMCStack->Particle(fPositiveMCParticle->GetMother(0));\r
     }\r
   }\r
-  fCurrentEventGoodV0s.push_back(*fCurrentMotherKFCandidate);\r
+               \r
+  //  if(iResult==kTRUE){\r
+  //   fCurrentEventGoodV0s.push_back(*fCurrentMotherKFCandidate); // moved it to NextV0() after all the cuts are applied\r
+  //  }\r
+\r
+  return iResult;\r
 }\r
 \r
+\r
+\r
 Bool_t AliV0Reader::HasSameMCMother(){\r
   //see header file for documentation\r
-\r
+       \r
   Bool_t iResult = kFALSE;\r
   if(fDoMC == kTRUE){\r
     if(fNegativeMCParticle != NULL && fPositiveMCParticle != NULL){\r
@@ -378,17 +472,17 @@ Bool_t AliV0Reader::HasSameMCMother(){
 \r
 Bool_t AliV0Reader::CheckPIDProbability(Double_t negProbCut, Double_t posProbCut){\r
   //see header file for documentation\r
-\r
+       \r
   Bool_t iResult=kFALSE;\r
-\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
+       \r
   negTrack->GetTPCpid(negProbArray);\r
   posTrack->GetTPCpid(posProbArray);\r
-\r
+       \r
   if(negProbArray!=NULL && posProbArray!=NULL){\r
     if(negProbArray[GetSpeciesIndex(-1)]>=negProbCut && posProbArray[GetSpeciesIndex(1)]>=posProbCut){\r
       iResult=kTRUE;\r
@@ -400,15 +494,15 @@ Bool_t AliV0Reader::CheckPIDProbability(Double_t negProbCut, Double_t posProbCut
 }\r
 \r
 void AliV0Reader::GetPIDProbability(Double_t &negPIDProb,Double_t & posPIDProb){\r
-\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
+       \r
   negTrack->GetTPCpid(negProbArray);\r
   posTrack->GetTPCpid(posProbArray);\r
-\r
+       \r
   if(negProbArray!=NULL && posProbArray!=NULL){\r
     negPIDProb = negProbArray[GetSpeciesIndex(-1)];\r
     posPIDProb = posProbArray[GetSpeciesIndex(1)];\r
@@ -419,19 +513,37 @@ void AliV0Reader::GetPIDProbability(Double_t &negPIDProb,Double_t & posPIDProb){
 \r
 void AliV0Reader::UpdateEventByEventData(){\r
   //see header file for documentation\r
-\r
+       \r
   if(fCurrentEventGoodV0s.size() >0 ){\r
-    fPreviousEventGoodV0s.clear();\r
-    fPreviousEventGoodV0s = fCurrentEventGoodV0s;\r
+    //    fPreviousEventGoodV0s.clear();\r
+    //    fPreviousEventGoodV0s = fCurrentEventGoodV0s;\r
+    if(fPreviousEventGoodV0s.size()>19){\r
+      for(UInt_t nCurrent=0;nCurrent<fCurrentEventGoodV0s.size();nCurrent++){\r
+       fPreviousEventGoodV0s.erase(fPreviousEventGoodV0s.begin());\r
+       fPreviousEventGoodV0s.push_back(fCurrentEventGoodV0s.at(nCurrent));\r
+      }\r
+    }\r
+    else{\r
+      for(UInt_t nCurrent=0;nCurrent<fCurrentEventGoodV0s.size();nCurrent++){\r
+       if(fPreviousEventGoodV0s.size()<20){\r
+         fPreviousEventGoodV0s.push_back(fCurrentEventGoodV0s.at(nCurrent));\r
+       }\r
+       else{\r
+         fPreviousEventGoodV0s.erase(fPreviousEventGoodV0s.begin());\r
+         fPreviousEventGoodV0s.push_back(fCurrentEventGoodV0s.at(nCurrent));\r
+       }\r
+      }\r
+    }\r
   }\r
   fCurrentEventGoodV0s.clear();\r
-  \r
+       \r
   fCurrentV0IndexNumber=0;\r
 }\r
 \r
+\r
 Double_t AliV0Reader::GetNegativeTrackPhi() const{\r
   //see header file for documentation\r
-\r
+       \r
   Double_t offset=0;\r
   if(fNegativeTrackLorentzVector->Phi()> TMath::Pi()){\r
     offset = -2*TMath::Pi();\r
@@ -441,7 +553,7 @@ Double_t AliV0Reader::GetNegativeTrackPhi() const{
 \r
 Double_t AliV0Reader::GetPositiveTrackPhi() const{\r
   //see header file for documentation\r
-\r
+       \r
   Double_t offset=0;\r
   if(fPositiveTrackLorentzVector->Phi()> TMath::Pi()){\r
     offset = -2*TMath::Pi();\r
@@ -451,7 +563,7 @@ Double_t AliV0Reader::GetPositiveTrackPhi() const{
 \r
 Double_t AliV0Reader::GetMotherCandidatePhi() const{\r
   //see header file for documentation\r
-\r
+       \r
   Double_t offset=0;\r
   if(fMotherCandidateLorentzVector->Phi()> TMath::Pi()){\r
     offset = -2*TMath::Pi();\r
@@ -459,11 +571,26 @@ Double_t AliV0Reader::GetMotherCandidatePhi() const{
   return fMotherCandidateLorentzVector->Phi()+offset;\r
 }\r
 \r
-Int_t AliV0Reader::GetSpeciesIndex(Int_t chargeOfTrack){\r
+\r
+Double_t AliV0Reader::GetMotherCandidateRapidity() const{\r
   //see header file for documentation\r
+       \r
+  Double_t rapidity=0;\r
+  if(fMotherCandidateLorentzVector->Energy() - fMotherCandidateLorentzVector->Pz() == 0 || fMotherCandidateLorentzVector->Energy() + fMotherCandidateLorentzVector->Pz() == 0) rapidity=0;\r
+  else rapidity = 0.5*(TMath::Log((fMotherCandidateLorentzVector->Energy() + fMotherCandidateLorentzVector->Pz()) / (fMotherCandidateLorentzVector->Energy()-fMotherCandidateLorentzVector->Pz())));\r
+  return rapidity;\r
+       \r
+}\r
+\r
 \r
-  Int_t iResult = 10; // Unknown particle\r
 \r
+\r
+\r
+Int_t AliV0Reader::GetSpeciesIndex(Int_t chargeOfTrack){\r
+  //see header file for documentation\r
+       \r
+  Int_t iResult = 10; // Unknown particle\r
+       \r
   if(chargeOfTrack==-1){ //negative track\r
     switch(abs(fNegativeTrackPID)){\r
     case 11:       //electron\r
@@ -493,7 +620,7 @@ Int_t AliV0Reader::GetSpeciesIndex(Int_t chargeOfTrack){
     case 311:      //K0\r
       iResult = 8;\r
       break;\r
-      \r
+                               \r
       //Put in here for kSPECIES::kEleCon  ????\r
     }\r
   }\r
@@ -526,7 +653,7 @@ Int_t AliV0Reader::GetSpeciesIndex(Int_t chargeOfTrack){
     case 311:      //K0\r
       iResult = 8;\r
       break;\r
-\r
+                               \r
       //Put in here for kSPECIES::kEleCon  ????\r
     }\r
   }\r