]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
updates from gsi trunk
authorslindal <slindal@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 18 Jan 2012 13:54:07 +0000 (13:54 +0000)
committerslindal <slindal@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 18 Jan 2012 13:54:07 +0000 (13:54 +0000)
24 files changed:
PWG4/CMakelibPWG4GammaConv.pkg
PWG4/GammaConv/AliAODConversionMother.cxx
PWG4/GammaConv/AliAODConversionParticle.cxx
PWG4/GammaConv/AliAODConversionPhoton.cxx
PWG4/GammaConv/AliAODConversionPhoton.h
PWG4/GammaConv/AliAnalysisTaskGammaConversion.cxx
PWG4/GammaConv/AliAnalysisTaskGammaConversion.h
PWG4/GammaConv/AliAnalysisTaskdPhi.cxx [new file with mode: 0644]
PWG4/GammaConv/AliAnalysisTaskdPhi.h [new file with mode: 0644]
PWG4/GammaConv/AliConversionCuts.cxx [new file with mode: 0644]
PWG4/GammaConv/AliConversionCuts.h [new file with mode: 0644]
PWG4/GammaConv/AliConversionPhotonBase.cxx
PWG4/GammaConv/AliConversionPhotonBase.h
PWG4/GammaConv/AliGammaConversionHistograms.cxx
PWG4/GammaConv/AliGammaConversionHistograms.h
PWG4/GammaConv/AliKFConversionPhoton.h
PWG4/GammaConv/AliV0Reader.cxx
PWG4/GammaConv/AliV0Reader.h
PWG4/GammaConv/ConvCorrelations/AliAnaConvCorrBase.cxx
PWG4/GammaConv/ConvCorrelations/AliAnaConvCorrBase.h
PWG4/GammaConv/ConvCorrelations/AliAnaConvCorrPhoton.cxx
PWG4/GammaConv/ConvCorrelations/AliAnaConvCorrPhoton.h
PWG4/GammaConv/ConvCorrelations/AliAnaConvCorrPion.cxx
PWG4/PWG4GammaConvLinkDef.h

index 69dfa74cc5aa8f920e3beba8b2e17a6217726fb5..d0e602a8a0570106b1d651e1d318b8b567f72987 100644 (file)
@@ -44,8 +44,10 @@ set ( SRCS  GammaConv/AliV0Reader.cxx
     GammaConv/ConvCorrelations/AliAnaConvCorrPion.cxx 
     GammaConv/ConvCorrelations/AliAnaConvCorrPhoton.cxx 
     GammaConv/ConvCorrelations/AliAnaConvCorrPhotonJet.cxx
-    GammaConv/ConvCorrelations/AliAnaConvCorrPionJet.cxx)
-
+    GammaConv/ConvCorrelations/AliAnaConvCorrPionJet.cxx
+       GammaConv/AliAnalysisTaskdPhi.cxx
+       GammaConv/AliConversionCuts.cxx
+       )
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
 
 set ( DHDR  PWG4GammaConvLinkDef.h)
index de34a567578c4de33956a347067c78bbdb2b785b..59bfd9e6f064831f54d957aa5519733d696ff940 100644 (file)
@@ -56,7 +56,7 @@ fWeight(1)
     }
 
     // Set Chi2 to the mean chi2 of gammas
-    fChi2=0.5*(y1->GetChi2perNDF()+y2->GetChi2perNDF());
//   fChi2=0.5*(y1->GetChi2perNDF()+y2->GetChi2perNDF());
 
     //Set Decay Photon Labels
     fLabel[0]=-1;
index 8f3d187fcbe6fd087ab8a852704dd96053379c62..bb8561be1bbd65d5e66882d25dc457f64d6e42aa 100644 (file)
@@ -11,10 +11,8 @@ TLorentzVector()
 }
 
 AliAODConversionParticle::AliAODConversionParticle(AliKFParticle *kfparticle) :
-TLorentzVector()
+  TLorentzVector(kfparticle->Px(), kfparticle->Py(), kfparticle->Pz(), kfparticle->E())
 {
-    SetVect(TVector3(kfparticle->Px(),kfparticle->Py(),kfparticle->Pz()));
-    SetE(P());
 
 }
 
index 0b8188073e538c02567f822bd9b7caa73b5bbdf0..a199667530d70c89a5d96573a3af94a5c69079d9 100644 (file)
@@ -9,26 +9,26 @@ AliAODConversionPhoton::AliAODConversionPhoton() :
 AliAODConversionParticle(),
 AliConversionPhotonBase()
 {
+  //Standard constructor
 }
 
 AliAODConversionPhoton::AliAODConversionPhoton(AliKFConversionPhoton *kfphoton) :
-AliAODConversionParticle(),
+AliAODConversionParticle(kfphoton),
 AliConversionPhotonBase(*((AliConversionPhotonBase*)kfphoton))
 {
-    // Set 4 momentum
-    SetVect(TVector3(kfphoton->Px(),kfphoton->Py(),kfphoton->Pz()));
-    SetE(P());
+  //Constructor from kfphoton
 }
 
 AliAODConversionPhoton::AliAODConversionPhoton(const AliAODConversionPhoton & original) :
 AliAODConversionParticle(original),
 AliConversionPhotonBase(original)
 {
+  //Copy constructor
 }
 
-AliAODConversionPhoton::~AliAODConversionPhoton(){
-// empty standard destructor
-
+AliAODConversionPhoton::~AliAODConversionPhoton()
+{
+  // empty standard destructor
 }
 
 AliAODConversionPhoton & AliAODConversionPhoton::operator = (const AliAODConversionPhoton & /*source*/)
index e088fd196a155bd67a2b54790c5a2ac6b34e6f88..ff9d00f4a3b2b98a080605e9f3f04ddeb4992a73 100644 (file)
@@ -31,6 +31,10 @@ class AliAODConversionPhoton : public AliAODConversionParticle, public AliConver
   virtual Double_t GetPhotonP() const {return AliAODConversionParticle::P();}
   virtual Double_t GetPhotonEta() const {return AliAODConversionParticle::Eta();}
   virtual Double_t GetPhotonPhi() const {return AliAODConversionParticle::Phi();}
+  virtual Double_t GetPx() const { return AliAODConversionParticle::Px();}
+  virtual Double_t GetPy() const { return AliAODConversionParticle::Py();}
+  virtual Double_t GetPz() const { return AliAODConversionParticle::Pz();}
+  void SetMassToZero() { SetE(P()); }
 
   ClassDef(AliAODConversionPhoton,1)
 };
index f96f72faa662015658e4bde2c4b4bb4ade079fa4..aad815d030174c51a74b22d2bd8be0706cd3bd4c 100644 (file)
@@ -26,6 +26,7 @@
 #include "AliAnalysisTaskGammaConversion.h"
 #include "AliStack.h"
 #include "AliLog.h"
+#include "TTree.h"
 #include "AliESDtrackCuts.h"
 #include "TNtuple.h"
 //#include "AliCFManager.h"    // for CF
@@ -39,7 +40,7 @@
 #include "AliESDCaloCluster.h" // for combining PHOS and GammaConv
 #include "AliKFVertex.h"
 #include "AliGenPythiaEventHeader.h"
-#include "AliGenDPMjetEventHeader.h"
+#include "AliGenDPMjetEventHeader.h"   
 #include "AliGenEventHeader.h"
 #include <AliMCEventHandler.h>
 #include "TRandom3.h"
@@ -49,6 +50,8 @@
 #include "AliAODHandler.h"
 #include "AliKFConversionPhoton.h"
 #include "AliKFConversionMother.h"
+#include "AliESDVertex.h"
+#include "AliESDTZERO.h"
 
 class AliESDTrackCuts;
 class AliCFContainer;
@@ -72,6 +75,7 @@ ClassImp(AliAnalysisTaskGammaConversion)
 
 AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion():
 AliAnalysisTaskSE(),
+        fpcstream(0x0),
        fV0Reader(NULL),
        fStack(NULL),
        fMCTruth(NULL),         // for CF
@@ -86,6 +90,7 @@ AliAnalysisTaskSE(),
        fDoOmegaMeson(kFALSE),
        fDoJet(kFALSE),
        fDoChic(kFALSE),
+       fDoHadInt(kFALSE),
        fRecalculateV0ForGamma(kFALSE),
        fKFReconstructedGammasTClone(NULL),
        fKFReconstructedPi0sTClone(NULL),
@@ -128,6 +133,7 @@ AliAnalysisTaskSE(),
        //fAODOmega(NULL),
        fAODBranchName("GammaConv"),
        fKFCreateAOD(kTRUE),
+       fKFExchangeAOD(kFALSE),
        fKFForceAOD(kFALSE),
        fKFDeltaAODFileName(""),
        fDoNeutralMesonV0MCCheck(kFALSE),
@@ -148,7 +154,10 @@ AliAnalysisTaskSE(),
        fUseHBTMultiplicityBin(0),
        fUseCentrality(0), 
        fUseCentralityBin(0),
-       fRandom(0)
+       fRandom(0),
+       fMaxChi2HadInt(100.),           
+       fMaxErr2DHadInt(10.),
+       fPtMinHadInt(0.3)
 {
        // Default constructor
 
@@ -167,6 +176,7 @@ AliAnalysisTaskSE(),
 
 AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name):
        AliAnalysisTaskSE(name),
+        fpcstream(0x0),
        fV0Reader(NULL),
        fStack(NULL),
        fMCTruth(NULL),         // for CF
@@ -181,6 +191,7 @@ AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name)
        fDoOmegaMeson(kFALSE),
        fDoJet(kFALSE),
        fDoChic(kFALSE),
+       fDoHadInt(kFALSE),
        fRecalculateV0ForGamma(kFALSE),
        fKFReconstructedGammasTClone(NULL),
        fKFReconstructedPi0sTClone(NULL),
@@ -223,6 +234,7 @@ AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name)
        //fAODOmega(NULL),
        fAODBranchName("GammaConv"),
        fKFCreateAOD(kTRUE),
+       fKFExchangeAOD(kFALSE),
        fKFForceAOD(kFALSE),
        fKFDeltaAODFileName(""),
        fDoNeutralMesonV0MCCheck(kFALSE),
@@ -243,7 +255,10 @@ AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name)
        fUseHBTMultiplicityBin(0),
        fUseCentrality(0), 
        fUseCentralityBin(0),
-       fRandom(0)
+       fRandom(0),
+       fMaxChi2HadInt(100.),           
+       fMaxErr2DHadInt(10.),
+       fPtMinHadInt(0.3)
 {
        // Common I/O in slot 0, don't define when inheriting from AnalysisTaskSE
        // DefineInput (0, TChain::Class());    
@@ -252,7 +267,7 @@ AliAnalysisTaskGammaConversion::AliAnalysisTaskGammaConversion(const char* name)
        // Your private output
        DefineOutput(1, TList::Class());
        DefineOutput(2, AliCFContainer::Class());       // for CF
-       
+       DefineOutput(3, TClonesArray::Class());
        
        // Define standard ESD track cuts for Gamma-hadron correlation 
        SetESDtrackCuts();
@@ -305,8 +320,9 @@ AliAnalysisTaskGammaConversion::~AliAnalysisTaskGammaConversion()
        if(fTriggerAnalysis) {
                delete fTriggerAnalysis;
        }
-
-
+       if (fpcstream)
+               delete fpcstream;
+       fpcstream = NULL;
 }
 
 
@@ -409,14 +425,8 @@ void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
                }
        } 
 
-       if(fAODGamma) fAODGamma->Delete();
-       // if(fAODPi0) fAODPi0->Delete();
-       // if(fAODOmega) fAODOmega->Delete();
-
-
-       //      if(fV0Reader == NULL){ // coverty does not permit this test
-       // Write warning here cuts and so on are default if this ever happens
-       //      }
+       if(fAODGamma) fAODGamma->Clear();
+       
 
        if (fMCEvent ) {
                // To avoid crashes due to unzip errors. Sometimes the trees are not there.
@@ -427,27 +437,34 @@ void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
 
                        eventQuality=0;
                        fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-                       return; 
                }
                if (!mcHandler->InitOk() ){
                        eventQuality=0;
                        fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-                       return;
                }
                if (!mcHandler->TreeK() ){
                        eventQuality=0;
                        fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-                       return;
                }
                if (!mcHandler->TreeTR() ) {
                        eventQuality=0;
                        fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-                       return;
+               }
+
+               if (eventQuality > -1) {
+                 PostAODEvent();
+                 return;
                }
        }
+       
 
        fV0Reader->SetInputAndMCEvent(InputEvent(), MCEvent());
 
+       //Process hadronic interactions
+       if(fDoHadInt == kTRUE){
+               ProcessHadronicInteraction(fESDEvent);
+       }
+
        fV0Reader->Initialize();
        fDoMCTruth = fV0Reader->GetDoMCTruth();
 
@@ -506,6 +523,102 @@ void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
        //Clear the data in the v0Reader
        //      fV0Reader->UpdateEventByEventData();
 
+
+       // Process the MC information
+       if(fDoMCTruth){
+               ProcessMCData();
+       }
+
+
+       if(!DoEventSelection()) {
+         PostAODEvent();
+         return;
+       }
+
+       
+       //Process the v0 information with no cuts
+       ProcessV0sNoCut();
+
+       // Process the v0 information
+       ProcessV0s();
+       
+
+       //Fill Gamma AOD
+       if(fKFCreateAOD) {
+         FillAODWithConversionGammas() ; 
+       }
+
+
+       // Process reconstructed gammas
+       if(fDoNeutralMeson == kTRUE){
+               ProcessGammasForNeutralMesonAnalysis();
+
+       }
+       
+       if(fDoMCTruth == kTRUE){
+               CheckV0Efficiency();
+       }
+       //Process reconstructed gammas electrons for Chi_c Analysis
+       if(fDoChic == kTRUE){
+               ProcessGammaElectronsForChicAnalysis();
+       }
+       // Process reconstructed gammas for gamma Jet/hadron correlations
+       if(fDoJet == kTRUE){
+               ProcessGammasForGammaJetAnalysis();
+       }
+       
+       //calculate background if flag is set
+       if(fCalculateBackground){
+               CalculateBackground();
+       }
+
+       if(fDoNeutralMeson == kTRUE){
+               //               ProcessConvPHOSGammasForNeutralMesonAnalysis();
+               if(fDoOmegaMeson == kTRUE){
+                       ProcessGammasForOmegaMesonAnalysis();
+               }
+       }
+
+
+       //Must set fForceAOD to true for the AOD to get filled. (Unless called by other task)
+       if(fKFForceAOD) {
+               if (!AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()) { 
+                       AliFatal("Cannot run ESD filter without an output event handler");
+        
+               } else {
+                       if(fAODGamma && fAODGamma->GetEntriesFast() > 0) {
+       AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
+       AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillExtension(kTRUE);      
+                       }
+               }
+       
+       }
+
+       ///Make sure delta aod is filled if standard aod is filled (for synchronization when reading aod with standard aod)
+       if(fKFCreateAOD && !fKFExchangeAOD) {
+               AliAODHandler * aodhandler = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
+               if (aodhandler && aodhandler->GetFillAOD()) {
+                       AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillExtension(kTRUE);      
+               }
+       }
+
+
+       //Clear the data in the v0Reader
+       fV0Reader->UpdateEventByEventData();
+       //if(fRecalculateV0ForGamma==kTRUE){
+       //      RecalculateV0ForGamma();
+       // }
+       PostAODEvent();
+       PostData(1, fOutputContainer);
+       PostData(2, fCFManager->GetParticleContainer());        // for CF
+}
+
+
+Bool_t AliAnalysisTaskGammaConversion::DoEventSelection() {
+
+
+  Int_t eventQuality = -1;
+
        //Take Only events with proper trigger
        /*
                if(fTriggerCINT1B){
@@ -525,7 +638,7 @@ void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
                        }
                }
 
-               return;
+               return kFALSE;
        }
 
        if(fV0Reader->CheckForPrimaryVertex() == kFALSE){
@@ -537,7 +650,7 @@ void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
                                CheckMesonProcessTypeEventQuality(eventQuality);
                        }
                }
-               return; // aborts if the primary vertex does not have contributors.
+               return kFALSE; // aborts if the primary vertex does not have contributors.
        }
 
         
@@ -550,7 +663,7 @@ void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
                                CheckMesonProcessTypeEventQuality(eventQuality);
                        }
                }
-               return;
+               return kFALSE;
        }
 
 
@@ -565,7 +678,7 @@ void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
        if(fRemovePileUp && fV0Reader->GetESDEvent()->IsPileupFromSPD()) {
                eventQuality=4;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;
+               return kFALSE;
        }
        
 
@@ -589,14 +702,14 @@ void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
        if(fUseMultiplicity!=0 && CalculateMultiplicityBin()!=fUseMultiplicityBin ){
                eventQuality=6;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;
+               return kFALSE;
        }
 
        
        if(fUseHBTMultiplicity!=0 && CalculateMultiplicityBin()!=fUseHBTMultiplicityBin ){
                eventQuality=6;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;
+               return kFALSE;
        }
 
 
@@ -610,7 +723,7 @@ void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
        if( centralityC != fUseCentralityBin ){
                eventQuality=7;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;
+               return kFALSE;
        }
                        }
 
@@ -619,7 +732,7 @@ void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
        if( centralityC != fUseCentralityBin ){
                eventQuality=7;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;
+               return kFALSE;
        }
                        }
 
@@ -629,47 +742,47 @@ void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
        if( (fUseCentralityBin == 0) && (centralityC!=0) ){ // 0-10%
                eventQuality=7;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;         
+               return kFALSE;          
        }
        if( (fUseCentralityBin == 1) && (centralityC!=1) ){ // 10-20%
                eventQuality=7;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;
+               return kFALSE;
        }
        if( (fUseCentralityBin == 2) && (centralityC!=2) && (centralityC!=3) ){ // 20-40%
                eventQuality=7;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;
+               return kFALSE;
        }
        if( (fUseCentralityBin == 3) && (centralityC!=0) && (centralityC!=1) ){ // 0-20%
                eventQuality=7;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;
+               return kFALSE;
        }
        if( (fUseCentralityBin == 4) && (centralityC!=4) && (centralityC!=5) ){ // 40-60%
                eventQuality=7;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;
+               return kFALSE;
        }
        if( (fUseCentralityBin == 6) && (centralityC!=6) && (centralityC!=7) && (centralityC!=8) ){ // 60-90%
                eventQuality=7;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;
+               return kFALSE;
        }
        if( (fUseCentralityBin == 7) && (centralityC!=6) && (centralityC!=7) ){ // 60-80%
                eventQuality=7;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;
+               return kFALSE;
        }
        if( (fUseCentralityBin == 8) && (centralityC>=8) ){ // 0-80%
                eventQuality=7;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;
+               return kFALSE;
        }
        if( (fUseCentralityBin == 9) && (centralityC>=9) ){ // 0-90%
                eventQuality=7;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;
+               return kFALSE;
        }
                        }
 
@@ -678,31 +791,31 @@ void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
        if( (fUseCentralityBin == 0) && (centralityC!=0) ){ // 0-10%
                eventQuality=7;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;         
+               return kFALSE;          
        }
        if( (fUseCentralityBin == 1) && (centralityC!=1) ){ // 10-20%
                eventQuality=7;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;
+               return kFALSE;
        }
        if( (fUseCentralityBin == 2) && (centralityC!=2) && (centralityC!=3) ){ // 20-40%
                eventQuality=7;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;
+               return kFALSE;
        }
        if( (fUseCentralityBin == 4) && (centralityC!=4) && (centralityC!=5) ){ // 40-60%
                eventQuality=7;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;
+               return kFALSE;
        }
        if( (fUseCentralityBin == 6) && (centralityC!=6) && (centralityC!=7) && (centralityC!=8) ){ // 60-90%
                eventQuality=7;
                fHistograms->FillHistogram("ESD_EventQuality",eventQuality);
-               return;
+               return kFALSE;
        }
                        }
                        ////////////////////////////////////// RRnew end ///////////////////////////////////////////////////////
-
+                       
                }
        }
 
@@ -719,88 +832,22 @@ void AliAnalysisTaskGammaConversion::UserExec(Option_t */*option*/)
        } 
 
 
-       // Process the MC information
-       if(fDoMCTruth){
-               ProcessMCData();
-       }
-
-
-       
-       //Process the v0 information with no cuts
-       ProcessV0sNoCut();
-
-       // Process the v0 information
-       ProcessV0s();
-       
-
-       //Fill Gamma AOD
-       if(fKFCreateAOD) {
-               FillAODWithConversionGammas() ; 
-       }
-
 
-       // Process reconstructed gammas
-       if(fDoNeutralMeson == kTRUE){
-               ProcessGammasForNeutralMesonAnalysis();
+       return kTRUE;
 
-       }
-       
-       if(fDoMCTruth == kTRUE){
-               CheckV0Efficiency();
-       }
-       //Process reconstructed gammas electrons for Chi_c Analysis
-       if(fDoChic == kTRUE){
-               ProcessGammaElectronsForChicAnalysis();
-       }
-       // Process reconstructed gammas for gamma Jet/hadron correlations
-       if(fDoJet == kTRUE){
-               ProcessGammasForGammaJetAnalysis();
-       }
-       
-       //calculate background if flag is set
-       if(fCalculateBackground){
-               CalculateBackground();
-       }
-
-       if(fDoNeutralMeson == kTRUE){
-               //               ProcessConvPHOSGammasForNeutralMesonAnalysis();
-               if(fDoOmegaMeson == kTRUE){
-                       ProcessGammasForOmegaMesonAnalysis();
-               }
-       }
+}
 
 
-       //Must set fForceAOD to true for the AOD to get filled. (Unless called by other task)
-       if(fKFForceAOD) {
-               if (!AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()) { 
-                       AliFatal("Cannot run ESD filter without an output event handler");
-        
-               } else {
-                       if(fAODGamma && fAODGamma->GetEntriesFast() > 0) {
-       AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
-       AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillExtension(kTRUE);      
-                       }
-               }
-       
+///_______________________________________________________________
+void AliAnalysisTaskGammaConversion::PostAODEvent() {
+  ///Post AOD array to correct output slot
+  if(fKFCreateAOD) {
+       if(!fKFExchangeAOD) {
+         PostData(0, fAODGamma);
+       }  else {
+         PostData(3, fAODGamma); 
        }
-
-       ///Make sure delta aod is filled if standard aod is filled (for synchronization when reading aod with standard aod)
-       if(fKFCreateAOD) {
-               AliAODHandler * aodhandler = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
-               if (aodhandler && aodhandler->GetFillAOD()) {
-                       AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillExtension(kTRUE);      
-               }
-       }
-
-
-       //Clear the data in the v0Reader
-       fV0Reader->UpdateEventByEventData();
-       //if(fRecalculateV0ForGamma==kTRUE){
-       //      RecalculateV0ForGamma();
-       // }
-       PostData(1, fOutputContainer);
-       PostData(2, fCFManager->GetParticleContainer());        // for CF
-       
+  }
 }
 
 // void AliAnalysisTaskGammaConversion::ConnectInputData(Option_t *option){
@@ -1324,8 +1371,9 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
                                Int_t zBin              = fHistograms->GetZBin(ePos->Vz());
                                Int_t phiBin    = fHistograms->GetPhiBin(particle->Phi());
                                Double_t rFMD=30;
-                               Double_t rITSTPCMin=50;
-                               Double_t rITSTPCMax=80;
+                               Double_t rITSTPCMin=40;
+                               Double_t rITSTPCInt=55;
+                               Double_t rITSTPCMax=72.5;
                                
                                TVector3 vtxPos(ePos->Vx(),ePos->Vy(),ePos->Vz());      
                                
@@ -1365,12 +1413,18 @@ void AliAnalysisTaskGammaConversion::ProcessMCData(){
                                        fHistograms->FillHistogram(nameMCMappingFMDPhiInZ, vtxPos.Phi());
                                }
                        
-                               if(ePos->R()>rITSTPCMin && ePos->R()<rITSTPCMax){
+                               if(ePos->R()>rITSTPCMin && ePos->R()<rITSTPCInt){
                                        TString nameMCMappingITSTPCPhiInZ="";
                                        nameMCMappingITSTPCPhiInZ.Form("MC_Conversion_Mapping_ITSTPC_Phi_in_Z_%02d",zBin);
                                        fHistograms->FillHistogram(nameMCMappingITSTPCPhiInZ, vtxPos.Phi());
                                }
                        
+                               if(ePos->R()>rITSTPCInt && ePos->R()<rITSTPCMax){
+                                       TString nameMCMappingITSTPC2PhiInZ="";
+                                       nameMCMappingITSTPC2PhiInZ.Form("MC_Conversion_Mapping_ITSTPC2_Phi_in_Z_%02d",zBin);
+                                       fHistograms->FillHistogram(nameMCMappingITSTPC2PhiInZ, vtxPos.Phi());
+                               }
+
                                TString nameMCMappingRInZ="";
                                nameMCMappingRInZ.Form("MC_Conversion_Mapping_R_in_Z_%02d",zBin);
                                fHistograms->FillHistogram(nameMCMappingRInZ,ePos->R() );
@@ -1741,11 +1795,12 @@ void AliAnalysisTaskGammaConversion::ProcessV0sNoCut(){
                }
 
                //              if( !fV0Reader->GetV0(i)->GetOnFlyStatus()){
-               if( !fV0Reader->CheckV0FinderStatus(i)){
+               if( !fV0Reader->CheckV0FinderStatus(fV0Reader->GetV0(i))){
                        continue;
                }
 
 
+
                if( !((fV0Reader->GetNegativeESDTrack())->GetStatus() & AliESDtrack::kTPCrefit) || 
                                !((fV0Reader->GetPositiveESDTrack())->GetStatus() & AliESDtrack::kTPCrefit) ){
                        continue;
@@ -1820,6 +1875,9 @@ void AliAnalysisTaskGammaConversion::ProcessV0sNoCut(){
                        
                        if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22){                               
                                fHistograms->FillHistogram("ESD_NoCutConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
+                                if(negativeMC->GetMother(0) <= fStack->GetNprimary()){
+                                   fHistograms->FillHistogram("ESD_NoCutConvPrimaryGamma_Pt", fV0Reader->GetMotherCandidatePt());
+                                }
                                fHistograms->FillHistogram("ESD_NoCutConvGamma_Energy", fV0Reader->GetMotherCandidateEnergy());
                                fHistograms->FillHistogram("ESD_NoCutConvGamma_Eta", fV0Reader->GetMotherCandidateEta());                               
                                fHistograms->FillHistogram("ESD_NoCutConvGamma_Phi", fV0Reader->GetMotherCandidatePhi());
@@ -1835,6 +1893,7 @@ void AliAnalysisTaskGammaConversion::ProcessV0sNoCut(){
                                                        
                                fHistograms->FillHistogram("ESD_NoCutConversion_XY", fV0Reader->GetX(),fV0Reader->GetY());
                                fHistograms->FillHistogram("ESD_NoCutConversion_R", fV0Reader->GetXYRadius());
+                               fHistograms->FillHistogram("ESD_NoCutConversion_MCR",fV0Reader->GetNegativeMCParticle()->R());
                                fHistograms->FillHistogram("ESD_NoCutConversion_ZR", fV0Reader->GetZ(),fV0Reader->GetXYRadius());
                                fHistograms->FillHistogram("ESD_NoCutConversion_OpeningAngle", fV0Reader->GetOpeningAngle());
                                fHistograms->FillHistogram("ESD_NoCutConvGamma_CosPointingAngle", fV0Reader->GetCosPointingAngle());
@@ -1970,6 +2029,9 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
                fHistograms->FillHistogram("ESD_ConvGamma_Eta_Chi2", fV0Reader->GetMotherCandidateEta(), fV0Reader->GetMotherCandidateChi2());
                
                fHistograms->FillHistogram("ESD_ConvGamma_CosPointingAngle", fV0Reader->GetCosPointingAngle());
+               fHistograms->FillHistogram("ESD_ConvGamma_CosPoint_RecCosPoint",fV0Reader->GetCosPointingAngle(),fV0Reader->GetV0CosineOfPointingAngle(fV0Reader->GetX(),fV0Reader->GetY(),fV0Reader->GetZ()));
+               fHistograms->FillHistogram("ESD_ConvGamma_PsiPair", fV0Reader->GetPsiPair(fV0Reader->GetCurrentV0()));
+               
                fHistograms->FillHistogram("ESD_ConvGamma_DcaDaughters", fV0Reader->GetDcaDaughters());
                fHistograms->FillHistogram("ESD_ConvGamma_NormDcaDistDaughters", fV0Reader->GetNormDcaDistDaughters());
                fHistograms->FillHistogram("ESD_ConvGamma_LikelihoodAP", fV0Reader->GetLikelihoodAP());
@@ -2023,14 +2085,25 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
                fHistograms->FillHistogram("ESD_ConvGamma_E_mupiProbP",fV0Reader->GetNegativeTrackP(),negPIDmupi);
                fHistograms->FillHistogram("ESD_ConvGamma_P_mupiProbP",fV0Reader->GetPositiveTrackP(),posPIDmupi);
 
-               Double_t armenterosQtAlfa[2];
-               fV0Reader->GetArmenterosQtAlfa(fV0Reader-> GetNegativeKFParticle(), 
-                                        fV0Reader-> GetPositiveKFParticle(), 
-                                        fV0Reader->GetMotherCandidateKFCombination(),
-                                        armenterosQtAlfa);
-        
-               fHistograms->FillHistogram("ESD_ConvGamma_alfa_qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
-               fHistograms->FillHistogram("ESD_ConvGamma_Pt_Qt",fV0Reader->GetMotherCandidatePt(),armenterosQtAlfa[0]);
+               Double_t armenterosQtAlpha[2] = {0,0};
+               if(fV0Reader->GetUseESDQtCut() == 0){
+                  fV0Reader->GetArmenterosQtAlpha(fV0Reader->GetNegativeKFParticle(),
+                                                   fV0Reader->GetPositiveKFParticle(),
+                                                   fV0Reader->GetMotherCandidateKFCombination(),
+                                                   armenterosQtAlpha);
+               }
+               else if(fV0Reader->GetUseESDQtCut() == 1){
+                  fV0Reader->GetArmenterosQtAlpha(fV0Reader->GetCurrentV0(), armenterosQtAlpha);
+               }
+               else if(fV0Reader->GetUseESDQtCut() == 2 || fV0Reader->GetUseESDQtCut() == 3){
+                  fV0Reader->GetArmenterosQtAlpha(fV0Reader->GetNegativeKFParticle(),
+                                                   fV0Reader->GetPositiveKFParticle(),
+                                                   armenterosQtAlpha,
+                                                   fV0Reader->GetUseESDQtCut());
+               }
+                
+               fHistograms->FillHistogram("ESD_ConvGamma_alfa_qt",armenterosQtAlpha[1],armenterosQtAlpha[0]);
+               fHistograms->FillHistogram("ESD_ConvGamma_Pt_Qt",fV0Reader->GetMotherCandidatePt(),armenterosQtAlpha[0]);
        
                if(!fV0Reader->GetIsHeavyIon()){
                        fHistograms->FillHistogram("3DPlots_Conversion_XYZ", fV0Reader->GetX(),fV0Reader->GetY(),fV0Reader->GetZ());            
@@ -2041,8 +2114,9 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
                        Int_t zBin              = fHistograms->GetZBin(fV0Reader->GetZ());
                        Int_t phiBin    = fHistograms->GetPhiBin(fV0Reader->GetNegativeTrackPhi());
                        Double_t rFMD=25;
-                       Double_t rITSTPCMin=45;
-                       Double_t rITSTPCMax=80;
+                       Double_t rITSTPCMin=40;
+                       Double_t rITSTPCInt=55;
+                       Double_t rITSTPCMax=72.5;
                        
                        //              Double_t motherCandidateEta= fV0Reader->GetMotherCandidateEta();
                        
@@ -2082,13 +2156,20 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
                                fHistograms->FillHistogram("ESD_ConversionMapping_FMD2_ZPhi",fV0Reader->GetZ() ,vtxConv.Phi());
                        }
 
-                       if(fV0Reader->GetXYRadius()>rITSTPCMin && fV0Reader->GetXYRadius()<rITSTPCMax){
+                       if(fV0Reader->GetXYRadius()>rITSTPCMin && fV0Reader->GetXYRadius()<rITSTPCInt){
                                TString nameESDMappingITSTPCPhiInZ="";
                                nameESDMappingITSTPCPhiInZ.Form("ESD_Conversion_Mapping_ITSTPC_Phi_in_Z_%02d",zBin);
                                fHistograms->FillHistogram(nameESDMappingITSTPCPhiInZ, vtxConv.Phi());
                                fHistograms->FillHistogram("ESD_ConversionMapping_ITSTPC_ZPhi",fV0Reader->GetZ() ,vtxConv.Phi());
                        }
                        
+                       if(fV0Reader->GetXYRadius()>rITSTPCInt && fV0Reader->GetXYRadius()<rITSTPCMax){
+                               TString nameESDMappingITSTPC2PhiInZ="";
+                               nameESDMappingITSTPC2PhiInZ.Form("ESD_Conversion_Mapping_ITSTPC2_Phi_in_Z_%02d",zBin);
+                               fHistograms->FillHistogram(nameESDMappingITSTPC2PhiInZ, vtxConv.Phi());
+                               fHistograms->FillHistogram("ESD_ConversionMapping_ITSTPC2_ZPhi",fV0Reader->GetZ() ,vtxConv.Phi());
+                       }
+
                        TString nameESDMappingRInZ="";
                        nameESDMappingRInZ.Form("ESD_Conversion_Mapping_R_in_Z_%02d",zBin);
                        fHistograms->FillHistogram(nameESDMappingRInZ, fV0Reader->GetXYRadius());
@@ -2127,13 +2208,14 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
                        TParticle * negativeMC = (TParticle*)fV0Reader->GetNegativeMCParticle();
                        TParticle * positiveMC = (TParticle*)fV0Reader->GetPositiveMCParticle();
                        Double_t rFMD=25;
-                       Double_t rITSTPCMin=45;
-                       Double_t rITSTPCMax=80;
+                       Double_t rITSTPCMin=40;
+                       Double_t rITSTPCInt=55;
+                       Double_t rITSTPCMax=72.5;
  
                        if(fV0Reader->HasSameMCMother() == kFALSE){
                                fHistograms->FillHistogram("ESD_TrueConvCombinatorial_R", fV0Reader->GetXYRadius());
                                fHistograms->FillHistogram("ESD_TrueConvCombinatorial_Z", fV0Reader->GetZ());
-                               fHistograms->FillHistogram("ESD_TrueConvCombSelected_Alpha_Qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
+                               fHistograms->FillHistogram("ESD_TrueConvCombSelected_Alpha_Qt",armenterosQtAlpha[1],armenterosQtAlpha[0]);
                                if ( fV0Reader->GetMotherCandidatePt() > 2. ) {
                                        fHistograms->FillHistogram("ESD_TrueConvCombinatorialMinPt_R", fV0Reader->GetXYRadius());
                                        fHistograms->FillHistogram("ESD_TrueConvCombinatorialMinPt_Z", fV0Reader->GetZ());                      
@@ -2268,12 +2350,14 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
                                }
                                                                // RRnewTOF end /////////////////////////////////////////////////
                                if (fV0Reader->HasSameMCMother() == kTRUE){
-                                       fHistograms->FillHistogram("ESD_TrueConvGammaSelected_Alpha_Qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
-                                       fHistograms->FillHistogram("ESD_TrueConvGammaSelected_Pt_Qt",fV0Reader->GetMotherCandidatePt(),armenterosQtAlfa[0]);    
+                                       fHistograms->FillHistogram("ESD_TrueConvGammaSelected_Alpha_Qt",armenterosQtAlpha[1],armenterosQtAlpha[0]);
+                                       fHistograms->FillHistogram("ESD_TrueConvGammaSelected_Pt_Qt",fV0Reader->GetMotherCandidatePt(),armenterosQtAlpha[0]);   
                                }
                                // RRnewTOF end /////////////////////////////////////////////////
 
                                fHistograms->FillHistogram("ESD_TrueConvGamma_Pt", fV0Reader->GetMotherCandidatePt());
+                               fHistograms->FillHistogram("ESD_TrueConvGamma_CosPoint_RecCosPoint",fV0Reader->GetCosPointingAngle(),fV0Reader->GetV0CosineOfPointingAngle(fV0Reader->GetX(),fV0Reader->GetY(),fV0Reader->GetZ()));
+                               fHistograms->FillHistogram("ESD_TrueConvGamma_PsiPair", fV0Reader->GetPsiPair(fV0Reader->GetCurrentV0()));
                                if(negativeMC->GetMother(0) <= fStack->GetNprimary()){ // Count just primary MC Gammas as true --> For Ratio esdtruegamma / mcconvgamma
                                        fHistograms->FillHistogram("ESD_TrueConvPrimaryGamma_Pt", fV0Reader->GetMotherCandidatePt());
                                        fHistograms->FillHistogram("ESD_TrueConvPrimaryGamma_R", fV0Reader->GetXYRadius());
@@ -2283,6 +2367,18 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
                                                fHistograms->FillHistogram("ESD_TrueConvPrimaryGammaMinPt_Z", fV0Reader->GetZ());                               
                                        }
                                }
+                                else{
+                                   fHistograms->FillHistogram("ESD_TrueConvSecondaryGamma_Pt", fV0Reader->GetMotherCandidatePt());
+                                   if(fV0Reader->GetMotherMCParticle()->GetMother(0) > -1){
+                                      if(fStack->Particle(fV0Reader->GetMotherMCParticle()->GetMother(0))->GetPdgCode() == 310){
+                                         fHistograms->FillHistogram("ESD_TrueConvSecondaryGammaFromK0s_Pt", fV0Reader->GetMotherCandidatePt());                                         
+                                      }
+                                      if(fStack->Particle(fV0Reader->GetMotherMCParticle()->GetMother(0))->GetMother(0) > -1 && 
+                                         fStack->Particle(fStack->Particle(fV0Reader->GetMotherMCParticle()->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
+                                         fHistograms->FillHistogram("ESD_TrueConvSecondaryGammaFromXFromK0s_Pt", fV0Reader->GetMotherCandidatePt());                                         
+                                      }
+                                   }
+                                }
                                if(fV0Reader->GetMotherMCParticle()->GetMother(0) > -1){
                                        if(fStack->Particle(fV0Reader->GetMotherMCParticle()->GetMother(0))->GetPdgCode() == 221){ // Use just gamma from eta for ratio esdtruegamma / mcconvgamma
                                                fHistograms->FillHistogram("ESD_TrueConvEtaGamma_Pt", fV0Reader->GetMotherCandidatePt());
@@ -2325,9 +2421,13 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
                                if(fV0Reader->GetXYRadius()>rFMD && fV0Reader->GetXYRadius()<rITSTPCMin){
                                        fHistograms->FillHistogram("ESD_TrueConversionMapping_FMD2_ZPhi",fV0Reader->GetZ() ,vtxConv.Phi());
                                }
-                               if(fV0Reader->GetXYRadius()>rITSTPCMin && fV0Reader->GetXYRadius()<rITSTPCMax){
+                               if(fV0Reader->GetXYRadius()>rITSTPCMin && fV0Reader->GetXYRadius()<rITSTPCInt){
                                        fHistograms->FillHistogram("ESD_TrueConversionMapping_ITSTPC_ZPhi",fV0Reader->GetZ() ,vtxConv.Phi());
                                }
+                               if(fV0Reader->GetXYRadius()>rITSTPCInt && fV0Reader->GetXYRadius()<rITSTPCMax){
+                                       fHistograms->FillHistogram("ESD_TrueConversionMapping_ITSTPC2_ZPhi",fV0Reader->GetZ() ,vtxConv.Phi());
+                               }
+
                                fHistograms->FillHistogram("ESD_TrueConversion_OpeningAngle", fV0Reader->GetOpeningAngle());
 
                                //----Histos for HFE-------------------------------------- 
@@ -2365,7 +2465,143 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
                                fHistograms->FillHistogram("ESD_TrueConversion_MC_ZR", negativeMC->Vz(),negativeMC->R());
                                fHistograms->FillHistogram("ESD_TrueConversion_MC_XY", negativeMC->Vx(),negativeMC->Vy());
                                
-                               //resolution
+                               
+                               //___________________________________________Resolution______________________________________________________
+                               // Different Ways of Producing a Gamma                          
+                               // Standard V0 Information                              
+                               Double_t mcPt   = fV0Reader->GetMotherMCParticle()->Pt();
+                               Double_t mcR = fV0Reader->GetNegativeMCParticle()->R();
+                               Double_t mcZ = fV0Reader->GetNegativeMCParticle()->Vz();
+                               Double_t resPt = 0.;
+                               Double_t resR = 0;
+                               Double_t resZ = 0;
+
+                               AliKFParticle AliKFPosParticle(*(fV0Reader->GetExternalTrackParamP(fV0Reader->GetCurrentV0())),-11);
+                               AliKFParticle AliKFNegParticle(*(fV0Reader->GetExternalTrackParamN(fV0Reader->GetCurrentV0())),11);
+
+                               // Resolution Normal V0 unchanged from the On-fly/Offline
+                               Double_t xyz[3] = {0,0,0};
+                               fV0Reader->GetCurrentV0()->GetXYZ(xyz[0],xyz[1],xyz[2]);
+                               resPt = mcPt-fV0Reader->GetCurrentV0()->Pt();
+                               resR = mcR-TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
+                               resZ = mcZ-xyz[2];
+                               fHistograms->FillHistogram("Resolution_Gamma_AbsdPt_Pt", mcPt, resPt);
+                                fHistograms->FillHistogram("Resolution_Gamma_AbsdR_R", mcR,resR);
+                               fHistograms->FillHistogram("Resolution_Gamma_AbsdZ_Z", mcZ,resZ);
+                               
+                               // Resolution Recalculated V0
+                               resR = mcR-fV0Reader->GetXYRadius();
+                               resZ = mcZ-fV0Reader->GetZ();
+                               // No pt, because we not recalculate v0 pt
+                               fHistograms->FillHistogram("Resolution_GammaRecalcPos_AbsdR_R", mcR,resR);
+                               fHistograms->FillHistogram("Resolution_GammaRecalcPos_AbsdZ_Z", mcZ,resZ);
+
+                               // Resolution ConstructGamma
+                               AliKFParticle constructGammaKF;
+                               constructGammaKF.ConstructGamma(AliKFNegParticle,AliKFPosParticle);
+                               resPt = mcPt-constructGammaKF.GetPt();
+                               resR = mcR-constructGammaKF.GetR();
+                               resZ = mcZ-constructGammaKF.GetZ();
+                               fHistograms->FillHistogram("Resolution_GammaConstr_AbsdPt_Pt", mcPt, resPt);
+                                fHistograms->FillHistogram("Resolution_GammaConstr_AbsdR_R", mcR,resR);
+                               fHistograms->FillHistogram("Resolution_GammaConstr_AbsdZ_Z", mcZ,resZ);
+                               if(constructGammaKF.GetNDF() !=0)
+                                  fHistograms->FillHistogram("Resolution_GammaConstr_Chi2NDF", constructGammaKF.GetChi2()/constructGammaKF.GetNDF());
+                               
+
+                               // Construct Gamma + Mass Constrained
+                               constructGammaKF.SetMassConstraint(0,0.0001);
+                               resPt = mcPt-constructGammaKF.GetPt();
+                               resR = mcR-constructGammaKF.GetR();
+                               resZ = mcZ-constructGammaKF.GetZ();
+                               fHistograms->FillHistogram("Resolution_GammaConstrMass_AbsdPt_Pt", mcPt, resPt);
+                                fHistograms->FillHistogram("Resolution_GammaConstrMass_AbsdR_R", mcR,resR);
+                               fHistograms->FillHistogram("Resolution_GammaConstrMass_AbsdZ_Z", mcZ,resZ);
+                               if(constructGammaKF.GetNDF() !=0)
+                                  fHistograms->FillHistogram("Resolution_GammaConstrMass_Chi2NDF", constructGammaKF.GetChi2()/constructGammaKF.GetNDF());
+
+                               // Construct Gamma + ProductionVertex
+                               constructGammaKF.ConstructGamma(AliKFNegParticle,AliKFPosParticle);
+                               AliKFVertex primaryVertexImprovedConstruct(*(fV0Reader->GetESDEvent()->GetPrimaryVertex()));
+                               primaryVertexImprovedConstruct+=constructGammaKF;
+                               constructGammaKF.SetProductionVertex(primaryVertexImprovedConstruct);
+                               resPt = mcPt-constructGammaKF.GetPt();
+                               resR = mcR-constructGammaKF.GetR();
+                               resZ = mcZ-constructGammaKF.GetZ();
+                               fHistograms->FillHistogram("Resolution_GammaConstrVtx_AbsdPt_Pt", mcPt, resPt);
+                                fHistograms->FillHistogram("Resolution_GammaConstrVtx_AbsdR_R", mcR,resR);
+                               fHistograms->FillHistogram("Resolution_GammaConstrVtx_AbsdZ_Z", mcZ,resZ);
+                               if(constructGammaKF.GetNDF() !=0)
+                                  fHistograms->FillHistogram("Resolution_GammaConstrVtx_Chi2NDF", constructGammaKF.GetChi2()/constructGammaKF.GetNDF());
+
+                               // Construct Gamma + Mass Constrained + Production Vtx
+                               constructGammaKF.ConstructGamma(AliKFNegParticle,AliKFPosParticle);
+                               constructGammaKF.SetMassConstraint(0,0.0001);
+                               AliKFVertex primaryVertexImprovedConstructC(*(fV0Reader->GetESDEvent()->GetPrimaryVertex()));
+                               primaryVertexImprovedConstructC+=constructGammaKF;
+                               constructGammaKF.SetProductionVertex(primaryVertexImprovedConstructC);
+                               resPt = mcPt-constructGammaKF.GetPt();
+                               resR = mcR-constructGammaKF.GetR();
+                               resZ = mcZ-constructGammaKF.GetZ();
+                               fHistograms->FillHistogram("Resolution_GammaConstrMassVtx_AbsdPt_Pt", mcPt, resPt);
+                                fHistograms->FillHistogram("Resolution_GammaConstrMassVtx_AbsdR_R", mcR,resR);
+                               fHistograms->FillHistogram("Resolution_GammaConstrMassVtx_AbsdZ_Z", mcZ,resZ);
+                               if(constructGammaKF.GetNDF() !=0)
+                                  fHistograms->FillHistogram("Resolution_GammaConstrMassVtx_Chi2NDF", constructGammaKF.GetChi2()/constructGammaKF.GetNDF());
+
+                               // Resolution Normal Gamma
+                               AliKFParticle normalGammaKF(AliKFNegParticle,AliKFPosParticle);
+                               resPt = mcPt-normalGammaKF.GetPt();
+                               resR = mcR-normalGammaKF.GetR();
+                               resZ = mcZ-normalGammaKF.GetZ();
+                               fHistograms->FillHistogram("Resolution_GammaNormal_AbsdPt_Pt", mcPt, resPt);
+                                fHistograms->FillHistogram("Resolution_GammaNormal_AbsdR_R", mcR,resR);
+                               fHistograms->FillHistogram("Resolution_GammaNormal_AbsdZ_Z", mcZ,resZ);
+                               if(normalGammaKF.GetNDF() !=0)
+                                  fHistograms->FillHistogram("Resolution_GammaNormal_Chi2NDF", normalGammaKF.GetChi2()/normalGammaKF.GetNDF());
+
+                               // Normal Gamma + Mass Constrained
+                               normalGammaKF.SetMassConstraint(0,0.0001);
+                               resPt = mcPt-normalGammaKF.GetPt();
+                               resR = mcR-normalGammaKF.GetR();
+                               resZ = mcZ-normalGammaKF.GetZ();
+                               fHistograms->FillHistogram("Resolution_GammaNormalMass_AbsdPt_Pt", mcPt, resPt);
+                                fHistograms->FillHistogram("Resolution_GammaNormalMass_AbsdR_R", mcR,resR);
+                               fHistograms->FillHistogram("Resolution_GammaNormalMass_AbsdZ_Z", mcZ,resZ);
+                               if(normalGammaKF.GetNDF() !=0)
+                                  fHistograms->FillHistogram("Resolution_GammaNormalMass_Chi2NDF", normalGammaKF.GetChi2()/normalGammaKF.GetNDF());
+                               
+                               // Normal Gamma + ProductionVertex
+                               AliKFParticle normalGammaKFVtx(AliKFNegParticle,AliKFPosParticle);
+                               AliKFVertex primaryVertexImprovedNormal(*(fV0Reader->GetESDEvent()->GetPrimaryVertex()));
+                               primaryVertexImprovedNormal+=normalGammaKFVtx;
+                               normalGammaKFVtx.SetProductionVertex(primaryVertexImprovedNormal);
+                               resPt = mcPt-normalGammaKFVtx.GetPt();
+                               resR = mcR-normalGammaKFVtx.GetR();
+                               resZ = mcZ-normalGammaKFVtx.GetZ();
+                               fHistograms->FillHistogram("Resolution_GammaNormalVtx_AbsdPt_Pt", mcPt, resPt);
+                                fHistograms->FillHistogram("Resolution_GammaNormalVtx_AbsdR_R", mcR,resR);
+                               fHistograms->FillHistogram("Resolution_GammaNormalVtx_AbsdZ_Z", mcZ,resZ);
+                               if(normalGammaKFVtx.GetNDF() !=0)
+                                  fHistograms->FillHistogram("Resolution_GammaNormalVtx_Chi2NDF", normalGammaKFVtx.GetChi2()/normalGammaKFVtx.GetNDF());
+                               
+                               // Normal Gamma + Mass Constrained + Production Vtx
+                               AliKFParticle normalGammaKFMassVtx(AliKFNegParticle,AliKFPosParticle);
+                               normalGammaKFMassVtx.SetMassConstraint(0,0.0001);
+                               AliKFVertex primaryVertexImprovedNormalMassVtx(*(fV0Reader->GetESDEvent()->GetPrimaryVertex()));
+                               primaryVertexImprovedNormalMassVtx+=normalGammaKFMassVtx;
+                               normalGammaKFMassVtx.SetProductionVertex(primaryVertexImprovedNormalMassVtx);
+                               resPt = mcPt-normalGammaKFMassVtx.GetPt();
+                               resR = mcR-normalGammaKFMassVtx.GetR();
+                               resZ = mcZ-normalGammaKFMassVtx.GetZ();
+                               fHistograms->FillHistogram("Resolution_GammaNormalMassVtx_AbsdPt_Pt", mcPt, resPt);
+                                fHistograms->FillHistogram("Resolution_GammaNormalMassVtx_AbsdR_R", mcR,resR);
+                               fHistograms->FillHistogram("Resolution_GammaNormalMassVtx_AbsdZ_Z", mcZ,resZ);
+                               if(normalGammaKFMassVtx.GetNDF() !=0)
+                                  fHistograms->FillHistogram("Resolution_GammaNormalMassVtx_Chi2NDF", normalGammaKFMassVtx.GetChi2()/normalGammaKFMassVtx.GetNDF());
+
+
+                               // ---------- End new Resolution ------------------
                                Double_t mcpt    = fV0Reader->GetMotherMCParticle()->Pt();
                                Double_t esdpt  = fV0Reader->GetMotherCandidatePt();
                                Double_t resdPt = 0.;
@@ -2374,12 +2610,14 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
                                } else if(mcpt < 0){
                                        cout<<"Pt of MC particle is negative, this will cause wrong calculation of resPt"<<endl; 
                                }
-                                                       
+                               
+                               TVector3 vtxConvRes(fV0Reader->GetX(),fV0Reader->GetY(), fV0Reader->GetZ());
+                               
                                fHistograms->FillHistogram("Resolution_Gamma_dPt_Pt", mcpt, resdPt);
                                fHistograms->FillHistogram("Resolution_MCPt_ESDPt", mcpt,esdpt);
-                               fHistograms->FillHistogram("Resolution_Gamma_dPt_Phi", fV0Reader->GetMotherCandidatePhi(), resdPt);
+                               fHistograms->FillHistogram("Resolution_Gamma_dPt_Phi", vtxConvRes.Phi(), resdPt);
                                if (esdpt> 0.150){
-                                       fHistograms->FillHistogram("Resolution_Gamma_minPt_dPt_Phi", fV0Reader->GetMotherCandidatePhi(), resdPt);
+                                       fHistograms->FillHistogram("Resolution_Gamma_minPt_dPt_Phi", vtxConvRes.Phi(), resdPt);
                                }
                                                
                                Double_t resdZ = 0.;
@@ -2391,6 +2629,7 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
 
                                fHistograms->FillHistogram("Resolution_dZAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdZAbs);
                                fHistograms->FillHistogram("Resolution_dZAbs_VS_Z", fV0Reader->GetNegativeMCParticle()->Vz(), resdZAbs);
+                               fHistograms->FillHistogram("Resolution_dZAbs_VS_Phi", vtxConvRes.Phi(), resdZAbs);
                                fHistograms->FillHistogram("Resolution_dZ", fV0Reader->GetNegativeMCParticle()->Vz(), resdZ);
                                fHistograms->FillHistogram("Resolution_MCZ_ESDZ", fV0Reader->GetNegativeMCParticle()->Vz(),fV0Reader->GetZ());
                                        
@@ -2438,9 +2677,9 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
                                }
                                //Filling histograms with respect to Electron resolution
                                fHistograms->FillHistogram("Resolution_E_dPt_Pt", mcEpt, resEdPt);
-                               fHistograms->FillHistogram("Resolution_E_dPt_Phi", fV0Reader->GetNegativeTrackPhi(), resEdPt);
+                               fHistograms->FillHistogram("Resolution_E_dPt_Phi", vtxConvRes.Phi(), resEdPt);
                                if (fV0Reader->GetNegativeTrackPt()> 0.150){
-                                       fHistograms->FillHistogram("Resolution_E_minPt_dPt_Phi", fV0Reader->GetNegativeTrackPhi(), resEdPt);
+                                       fHistograms->FillHistogram("Resolution_E_minPt_dPt_Phi", vtxConvRes.Phi(), resEdPt);
                                }
 
                                if(kTRDoutN){
@@ -2494,9 +2733,9 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
                                }
                                //Filling histograms with respect to Positron resolution
                                fHistograms->FillHistogram("Resolution_P_dPt_Pt", mcPpt, resPdPt);
-                               fHistograms->FillHistogram("Resolution_P_dPt_Phi", fV0Reader->GetPositiveTrackPhi(), resPdPt);
+                               fHistograms->FillHistogram("Resolution_P_dPt_Phi", vtxConvRes.Phi(), resPdPt);
                                if (fV0Reader->GetPositiveTrackPt()> 0.150){
-                                       fHistograms->FillHistogram("Resolution_P_minPt_dPt_Phi", fV0Reader->GetPositiveTrackPhi(), resPdPt);
+                                       fHistograms->FillHistogram("Resolution_P_minPt_dPt_Phi", vtxConvRes.Phi(), resPdPt);
                                }
 
                                if(kTRDoutP){
@@ -2516,6 +2755,8 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
                                resdRAbs = (fV0Reader->GetXYRadius() - fV0Reader->GetNegativeMCParticle()->R());
 
                                fHistograms->FillHistogram("Resolution_dRAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdRAbs);
+                               fHistograms->FillHistogram("Resolution_dRAbs_VS_Z", fV0Reader->GetNegativeMCParticle()->Vz(), resdRAbs);
+                               fHistograms->FillHistogram("Resolution_dRAbs_VS_Phi",  vtxConvRes.Phi(), resdRAbs);
                                fHistograms->FillHistogram("Resolution_dR", fV0Reader->GetNegativeMCParticle()->R(), resdR);
                                fHistograms->FillHistogram("Resolution_MCR_ESDR", fV0Reader->GetNegativeMCParticle()->R(),fV0Reader->GetXYRadius());
                                fHistograms->FillHistogram("Resolution_R_dPt", fV0Reader->GetNegativeMCParticle()->R(), resdPt);
@@ -2525,10 +2766,11 @@ void AliAnalysisTaskGammaConversion::ProcessV0s(){
 
                                Double_t resdPhiAbs=0.;
                                resdPhiAbs=0.;
-                               resdPhiAbs= (fV0Reader->GetMotherCandidatePhi()-fV0Reader->GetNegativeMCParticle()->Phi());
-                               fHistograms->FillHistogram("Resolution_MCPhi_ESDPhi", fV0Reader->GetNegativeMCParticle()->Phi(),fV0Reader->GetMotherCandidatePhi());
+                               resdPhiAbs= (vtxConvRes.Phi()-fV0Reader->GetNegativeMCParticle()->Phi());
+                               fHistograms->FillHistogram("Resolution_MCPhi_ESDPhi", fV0Reader->GetNegativeMCParticle()->Phi(),vtxConvRes.Phi());
                                fHistograms->FillHistogram("Resolution_dPhiAbs_VS_R", fV0Reader->GetNegativeMCParticle()->R(), resdPhiAbs);
-                               fHistograms->FillHistogram("Resolution_dPhiAbs_VS_Phi", fV0Reader->GetNegativeMCParticle()->Phi(), resdPhiAbs);
+                               fHistograms->FillHistogram("Resolution_dPhiAbs_VS_Z", fV0Reader->GetNegativeMCParticle()->Vz(), resdPhiAbs);
+                               fHistograms->FillHistogram("Resolution_dPhiAbs_VS_Phi",  vtxConvRes.Phi(), resdPhiAbs);
                        }//if(fV0Reader->GetMotherMCParticle()->GetPdgCode() == 22)
                }//if(fDoMCTruth)
        }//while(fV0Reader->NextV0)
@@ -3209,46 +3451,10 @@ void AliAnalysisTaskGammaConversion::AddGammaToAOD(AliKFConversionPhoton * kfPar
     TClonesArray *branch=fAODGamma;
     if(branch){
                new((*branch)[branch->GetEntriesFast()])  AliAODConversionPhoton(kfParticle);
-    } else {
+               static_cast<AliAODConversionPhoton*>(branch->Last())->SetMass(kfParticle->M());
+    }
+    else {
                return;
-       }
-
-    //Add PID information with ESD tender (AOD implementation is not complete)
-
-    AliAODConversionPhoton *gamma=static_cast<AliAODConversionPhoton*>(fAODGamma->At(fAODGamma->GetEntriesFast()-1));
-
-    AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
-    AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
-    AliPIDResponse *fPIDResponse = (AliPIDResponse*)inputHandler->GetPIDResponse();
-
-    fESDEvent = fV0Reader->GetESDEvent();
-
-    if(fESDEvent){
-       Int_t labelp=((AliESDv0*)fESDEvent->GetV0(kfParticle->GetV0Index()))->GetPindex();
-       Int_t labeln=((AliESDv0*)fESDEvent->GetV0(kfParticle->GetV0Index()))->GetNindex();
-
-       AliESDtrack *trackpos=fESDEvent->GetTrack(labelp);
-       AliESDtrack *trackneg=fESDEvent->GetTrack(labeln);
-
-       if(trackpos&&trackneg&&fPIDResponse){
-
-           Float_t fNSigmadEdxPositive[5];
-           Float_t fNSigmadEdxNegative[5];
-
-           fNSigmadEdxPositive[0]=fPIDResponse->NumberOfSigmasTPC(trackpos,AliPID::kElectron);
-           fNSigmadEdxPositive[1]=fPIDResponse->NumberOfSigmasTPC(trackpos,AliPID::kMuon);
-           fNSigmadEdxPositive[2]=fPIDResponse->NumberOfSigmasTPC(trackpos,AliPID::kPion);
-           fNSigmadEdxPositive[3]=fPIDResponse->NumberOfSigmasTPC(trackpos,AliPID::kKaon);
-           fNSigmadEdxPositive[4]=fPIDResponse->NumberOfSigmasTPC(trackpos,AliPID::kProton);
-
-           fNSigmadEdxNegative[0]=fPIDResponse->NumberOfSigmasTPC(trackneg,AliPID::kElectron);
-           fNSigmadEdxNegative[1]=fPIDResponse->NumberOfSigmasTPC(trackneg,AliPID::kMuon);
-           fNSigmadEdxNegative[2]=fPIDResponse->NumberOfSigmasTPC(trackneg,AliPID::kPion);
-           fNSigmadEdxNegative[3]=fPIDResponse->NumberOfSigmasTPC(trackneg,AliPID::kKaon);
-           fNSigmadEdxNegative[4]=fPIDResponse->NumberOfSigmasTPC(trackneg,AliPID::kProton);
-
-           gamma->SetNSigmadEdx(fNSigmadEdxPositive,fNSigmadEdxNegative);
-       }
     }
 }
 
@@ -3991,234 +4197,6 @@ void AliAnalysisTaskGammaConversion::CreateListOfChargedParticles(){
        //       } 
 }
 
-/*void AliAnalysisTaskGammaConversion::RecalculateV0ForGamma(){
-       //recalculates v0 for gamma
-
-       Double_t massE=0.00051099892;
-       TLorentzVector curElecPos;
-       TLorentzVector curElecNeg;
-       TLorentzVector curGamma;
-
-       TLorentzVector curGammaAt;
-       TLorentzVector curElecPosAt;
-       TLorentzVector curElecNegAt;
-       AliKFVertex primVtxGamma(*(fESDEvent->GetPrimaryVertex()));
-       AliKFVertex primVtxImprovedGamma = primVtxGamma;
-
-       const AliESDVertex *vtxT3D=fESDEvent->GetPrimaryVertex();
-
-       Double_t xPrimaryVertex=vtxT3D->GetXv();
-       Double_t yPrimaryVertex=vtxT3D->GetYv();
-       Double_t zPrimaryVertex=vtxT3D->GetZv();
-       // Float_t primvertex[3]={xPrimaryVertex,yPrimaryVertex,zPrimaryVertex};
-
-       Float_t nsigmaTPCtrackPos;
-       Float_t nsigmaTPCtrackNeg;
-       Float_t nsigmaTPCtrackPosToPion;
-       Float_t nsigmaTPCtrackNegToPion;
-       AliKFParticle* negKF=NULL;
-       AliKFParticle* posKF=NULL;
-
-       for(Int_t iTracks = 0; iTracks < fESDEvent->GetNumberOfTracks(); iTracks++){
-               AliESDtrack* posTrack = fESDEvent->GetTrack(iTracks);
-               if(!posTrack){
-                       continue;
-               }
-               if (posKF) delete posKF; posKF=NULL;
-               if(posTrack->GetSign()<0) continue;
-               if(!(posTrack->GetStatus() & AliESDtrack::kTPCrefit))continue;
-               if(posTrack->GetKinkIndex(0)>0 ) continue;
-               if(posTrack->GetNcls(1)<50)continue;
-               Double_t momPos[3];
-               //              posTrack->GetConstrainedPxPyPz(momPos);
-               posTrack->GetPxPyPz(momPos);
-               AliESDtrack *ptrk=fESDEvent->GetTrack(iTracks);
-               curElecPos.SetXYZM(momPos[0],momPos[1],momPos[2],massE);
-               if(TMath::Abs(curElecPos.Eta())<0.9) continue;
-               posKF = new AliKFParticle( *(posTrack),-11);
-
-               nsigmaTPCtrackPos = fV0Reader->GetESDpid()->NumberOfSigmasTPC(posTrack,AliPID::kElectron);
-               nsigmaTPCtrackPosToPion = fV0Reader->GetESDpid()->NumberOfSigmasTPC(posTrack,AliPID::kPion);
-
-               if ( nsigmaTPCtrackPos>5.|| nsigmaTPCtrackPos<-2.){
-                       continue;
-               }
-       
-               if(pow((momPos[0]*momPos[0]+momPos[1]*momPos[1]+momPos[2]*momPos[2]),0.5)>0.5 && nsigmaTPCtrackPosToPion<1){
-                       continue;
-               }
-
-
-
-               for(Int_t jTracks = 0; jTracks < fESDEvent->GetNumberOfTracks(); jTracks++){
-                       AliESDtrack* negTrack = fESDEvent->GetTrack(jTracks);
-                       if(!negTrack){
-                               continue;
-                       }
-                       if (negKF) delete negKF; negKF=NULL;
-                       if(negTrack->GetSign()>0) continue;
-                       if(!(negTrack->GetStatus() & AliESDtrack::kTPCrefit))continue;
-                       if(negTrack->GetKinkIndex(0)>0 ) continue;
-                       if(negTrack->GetNcls(1)<50)continue;
-                       Double_t momNeg[3];
-                       //              negTrack->GetConstrainedPxPyPz(momNeg);
-                       negTrack->GetPxPyPz(momNeg);
-
-                       nsigmaTPCtrackNeg = fV0Reader->GetESDpid()->NumberOfSigmasTPC(negTrack,AliPID::kElectron);               
-                       nsigmaTPCtrackNegToPion = fV0Reader->GetESDpid()->NumberOfSigmasTPC(negTrack,AliPID::kPion);
-                       if ( nsigmaTPCtrackNeg>5. || nsigmaTPCtrackNeg<-2.){
-                               continue;
-                       }
-                       if(pow((momNeg[0]*momNeg[0]+momNeg[1]*momNeg[1]+momNeg[2]*momNeg[2]),0.5)>0.5 && nsigmaTPCtrackNegToPion<1){
-                               continue;
-                       }
-                       AliESDtrack *ntrk=fESDEvent->GetTrack(jTracks);
-                       curElecNeg.SetXYZM(momNeg[0],momNeg[1],momNeg[2],massE);
-                       if(TMath::Abs(curElecNeg.Eta())<0.9) continue;
-                       negKF = new AliKFParticle( *(negTrack) ,11);
-
-                       Double_t b=fESDEvent->GetMagneticField();
-                       Double_t xn, xp, dca=ntrk->GetDCA(ptrk,b,xn,xp);
-                       AliExternalTrackParam nt(*ntrk), pt(*ptrk);
-                       nt.PropagateTo(xn,b); pt.PropagateTo(xp,b);
-
-
-                       //--- Like in ITSV0Finder
-                       AliExternalTrackParam ntAt0(*ntrk), ptAt0(*ptrk);
-                       Double_t xxP,yyP,alphaP;
-                       Double_t rP[3];
-
-                       //               if (!ptAt0.GetGlobalXYZat(ptAt0->GetX(),xxP,yyP,zzP)) continue;
-                       if (!ptAt0.GetXYZAt(ptAt0.GetX(),b,rP)) continue;
-                       xxP=rP[0];
-                       yyP=rP[1];
-                       alphaP = TMath::ATan2(yyP,xxP);
-
-
-                       ptAt0.Propagate(alphaP,0,b);
-                       Float_t ptfacP  = (1.+100.*TMath::Abs(ptAt0.GetC(b)));
-
-                       //               Double_t distP                 = ptAt0.GetY();
-                       Double_t normP                  = ptfacP*TMath::Sqrt(ptAt0.GetSigmaY2());
-                       Double_t normdist0P = TMath::Abs(ptAt0.GetY()/normP);
-                       Double_t normdist1P = TMath::Abs((ptAt0.GetZ()-zPrimaryVertex)/(ptfacP*TMath::Sqrt(ptAt0.GetSigmaZ2())));
-                       Double_t normdistP      = TMath::Sqrt(normdist0P*normdist0P+normdist1P*normdist1P);
-       
-
-                       Double_t xxN,yyN,alphaN;
-                       Double_t rN[3];
-                       //               if (!ntAt0.GetGlobalXYZat(ntAt0->GetX(),xxN,yyN,zzN)) continue;
-                       if (!ntAt0.GetXYZAt(ntAt0.GetX(),b,rN)) continue;
-                       xxN=rN[0];
-                       yyN=rN[1];
-                       alphaN = TMath::ATan2(yyN,xxN);
-
-                       ntAt0.Propagate(alphaN,0,b);
-
-                       Float_t ptfacN  = (1.+100.*TMath::Abs(ntAt0.GetC(b)));
-                       //               Double_t distN                 = ntAt0.GetY();
-                       Double_t normN                  = ptfacN*TMath::Sqrt(ntAt0.GetSigmaY2());
-                       Double_t normdist0N = TMath::Abs(ntAt0.GetY()/normN);
-                       Double_t normdist1N = TMath::Abs((ntAt0.GetZ()-zPrimaryVertex)/(ptfacN*TMath::Sqrt(ntAt0.GetSigmaZ2())));
-                       Double_t normdistN      = TMath::Sqrt(normdist0N*normdist0N+normdist1N*normdist1N);
-       
-                       //-----------------------------
-
-                       Double_t momNegAt[3];
-                       nt.GetPxPyPz(momNegAt);
-                       curElecNegAt.SetXYZM(momNegAt[0],momNegAt[1],momNegAt[2],massE);
-
-                       Double_t momPosAt[3];
-                       pt.GetPxPyPz(momPosAt);
-                       curElecPosAt.SetXYZM(momPosAt[0],momPosAt[1],momPosAt[2],massE);
-                       if(dca>1){
-                               continue;
-                       }
-
-                       //               Double_t dneg= negTrack->GetD(xPrimaryVertex,yPrimaryVertex,b);
-                       //               Double_t dpos= posTrack->GetD(xPrimaryVertex,yPrimaryVertex,b);
-                       AliESDv0 vertex(nt,jTracks,pt,iTracks);
-               
-
-                       Float_t cpa=vertex.GetV0CosineOfPointingAngle(xPrimaryVertex,yPrimaryVertex,zPrimaryVertex);
-
-
-                       //      cout<< "v0Rr::"<< v0Rr<<endl;
-                       // if (pvertex.GetRr()<0.5){
-                       // continue;
-                       //}
-                       //               cout<<"vertex.GetChi2V0()"<<vertex.GetChi2V0()<<endl;
-                       if(cpa<0.9)continue;
-                       //               if (vertex.GetChi2V0() > 30) continue;
-                       //               cout<<"xp+xn::"<<xp<<" "<<xn<<endl;
-                       if ((xn+xp) < 0.4) continue;
-                       if (TMath::Abs(ntrk->GetD(xPrimaryVertex,yPrimaryVertex,b))<0.05)
-                       if (TMath::Abs(ptrk->GetD(xPrimaryVertex,yPrimaryVertex,b))<0.05) continue;
-
-                       //cout<<"pass"<<endl;
-
-                       AliKFParticle v0GammaC;
-                       v0GammaC+=(*negKF);
-                       v0GammaC+=(*posKF);
-                       v0GammaC.SetMassConstraint(0,0.001);
-                       primVtxImprovedGamma+=v0GammaC;
-                       v0GammaC.SetProductionVertex(primVtxImprovedGamma);
-
-
-                       curGamma=curElecNeg+curElecPos;
-                       curGammaAt=curElecNegAt+curElecPosAt;
-                
-                       // invariant mass versus pt of K0short
-                
-                       Double_t chi2V0GammaC=100000.;
-                       if( v0GammaC.GetNDF() != 0) {
-                               chi2V0GammaC = v0GammaC.GetChi2()/v0GammaC.GetNDF();
-                       }else{
-                               cout<< "ERROR::v0K0C.GetNDF()" << endl;
-                       }
-
-                       if(chi2V0GammaC<200 &&chi2V0GammaC>0 ){
-                               if(fHistograms != NULL){
-                                       fHistograms->FillHistogram("ESD_RecalculateV0_InvMass",v0GammaC.GetMass());
-                                       fHistograms->FillHistogram("ESD_RecalculateV0_Pt",v0GammaC.GetPt());
-                                       fHistograms->FillHistogram("ESD_RecalculateV0_E_dEdxP",curElecNegAt.P(),negTrack->GetTPCsignal());
-                                       fHistograms->FillHistogram("ESD_RecalculateV0_P_dEdxP",curElecPosAt.P(),posTrack->GetTPCsignal());
-                                       fHistograms->FillHistogram("ESD_RecalculateV0_cpa",cpa);
-                                       fHistograms->FillHistogram("ESD_RecalculateV0_dca",dca);
-                                       fHistograms->FillHistogram("ESD_RecalculateV0_normdistP",normdistP);
-                                       fHistograms->FillHistogram("ESD_RecalculateV0_normdistN",normdistN);
-
-                                       new((*fKFRecalculatedGammasTClone)[fKFRecalculatedGammasTClone->GetEntriesFast()])      AliKFParticle(v0GammaC);
-                                       fElectronRecalculatedv1.push_back(iTracks);
-                                       fElectronRecalculatedv2.push_back(jTracks);
-                               }
-                       }
-               }
-       }
-       for(Int_t firstGammaIndex=0;firstGammaIndex<fKFRecalculatedGammasTClone->GetEntriesFast();firstGammaIndex++){
-               for(Int_t secondGammaIndex=firstGammaIndex+1;secondGammaIndex<fKFRecalculatedGammasTClone->GetEntriesFast();secondGammaIndex++){
-                       AliKFParticle * twoGammaDecayCandidateDaughter0 = (AliKFParticle *)fKFRecalculatedGammasTClone->At(firstGammaIndex);
-                       AliKFParticle * twoGammaDecayCandidateDaughter1 = (AliKFParticle *)fKFRecalculatedGammasTClone->At(secondGammaIndex);
-                       
-                       if(fElectronRecalculatedv1[firstGammaIndex]==fElectronRecalculatedv1[secondGammaIndex]){
-                               continue;
-                       }
-                       if( fElectronRecalculatedv2[firstGammaIndex]==fElectronRecalculatedv2[secondGammaIndex]){
-                               continue;
-                       }
-                       
-                       AliKFParticle twoGammaCandidate(*twoGammaDecayCandidateDaughter0,*twoGammaDecayCandidateDaughter1);
-                       if(fHistograms != NULL){
-                               fHistograms->FillHistogram("ESD_RecalculateGG_InvMass",twoGammaCandidate.GetMass());            
-                               fHistograms->FillHistogram("ESD_RecalculateGG_InvMass_vs_Pt",twoGammaCandidate.GetMass(),twoGammaCandidate.GetPt());            
-                       }
-               }
-       }
-}
-        */
 void AliAnalysisTaskGammaConversion::CalculateJetCone(Int_t gammaIndex){
        // CaculateJetCone
        
@@ -4386,26 +4364,14 @@ void AliAnalysisTaskGammaConversion::UserCreateOutputObjects()
                //AOD
                if(!fAODGamma) fAODGamma = new TClonesArray("AliAODConversionPhoton", 0);
                else fAODGamma->Delete();
+               fAODGamma->SetOwner(kTRUE);
                fAODGamma->SetName(Form("%s_gamma", fAODBranchName.Data()));
                
-              /* if(!fAODPi0) fAODPi0 = new TClonesArray("AliAODConversionPhoton", 0);
-               else fAODPi0->Delete();
-               fAODPi0->SetName(Form("%s_Pi0", fAODBranchName.Data()));
-               
-               if(!fAODOmega) fAODOmega = new TClonesArray("AliAODConversionPhoton", 0);
-               else fAODOmega->Delete();
-               fAODOmega->SetName(Form("%s_Omega", fAODBranchName.Data()));
-              */
-               //If delta AOD file name set, add in separate file. Else add in standard aod file. 
                if(GetDeltaAODFileName().Length() > 0) {
                        AddAODBranch("TClonesArray", &fAODGamma, GetDeltaAODFileName().Data());
-                     //  AddAODBranch("TClonesArray", &fAODPi0, GetDeltaAODFileName().Data());
-                     //  AddAODBranch("TClonesArray", &fAODOmega, GetDeltaAODFileName().Data());
                        AliAnalysisManager::GetAnalysisManager()->RegisterExtraFile(GetDeltaAODFileName().Data());
                } else  {
                        AddAODBranch("TClonesArray", &fAODGamma);
-                     //  AddAODBranch("TClonesArray", &fAODPi0);
-                     //  AddAODBranch("TClonesArray", &fAODOmega);
                }
        }
 
@@ -4439,9 +4405,10 @@ void AliAnalysisTaskGammaConversion::UserCreateOutputObjects()
        
        fOutputContainer->SetName(GetName());
 
+       PostData(0, fAODGamma);
        PostData(1, fOutputContainer);
        PostData(2, fCFManager->GetParticleContainer());        // for CF
-
+       PostData(3, fAODGamma); 
 }
 
 Double_t AliAnalysisTaskGammaConversion::GetMCOpeningAngle(const TParticle* const daughter0, const TParticle* const daughter1) const{
@@ -4523,6 +4490,732 @@ void AliAnalysisTaskGammaConversion::CheckV0Efficiency(){
        }
 }
 
+//_____________________________________________________________________
+void  AliAnalysisTaskGammaConversion::ProcessHadronicInteraction(AliESDEvent *event){
+       //
+       // Process pairs of tracks to get a material budget map
+       //
+       //
+       if (!event) return;
+       if (event) AliKFParticle::SetField(event->GetMagneticField());  // set mean magnetic field for KF particles
+//     TTreeSRedirector *fpcstream = new TTreeSRedirector("eventInfoHadInt.root");
+       // 1. Calculate total dEdx for all TPC tracks
+       //
+       const Int_t kMinCl=50;
+       const Double_t kEpsilon=0.000001;
+       const Float_t kMinRatio=0.7;
+       const Float_t kMinDist=1.5;
+       const Float_t kMinDistChi2=8.;        // 
+       const Float_t kMaxDistZ=300.;        // max distanceZ
+       const Float_t kMaxDistR=250.;          // max distanceR
+       const Double_t kMaxChi2   =36.;     // maximal chi2 to define the vertex
+       const Double_t kMaxDistVertexSec=2.;     // maximal distance to secondary vertex
+       const Double_t kMinPtHadTrack = fPtMinHadInt;
+       Float_t         arrayRBins[6] =                 {5.75,9.5,21.,35.,42.,55.};
+       
+       Double_t szz=1.;      // number to be taken from the OCDB - now it can be hack
+       Double_t stt = 0.006667; // 
+
+       if (!event) return;
+               AliESDVertex *vertexSPD =  (AliESDVertex *)event->GetPrimaryVertexSPD();
+//     AliESDVertex * spdVertex   = (AliESDVertex *)event->GetPrimaryVertexSPD();
+//     AliESDVertex * trackVertex = (AliESDVertex *)event->GetPrimaryVertexTracks();
+//     AliESDVertex * tpcVertex   = (AliESDVertex *)event->GetPrimaryVertexTPC();
+//     AliESDTZERO  * tzero       = (AliESDTZERO  *)event->GetESDTZERO() ;
+       //
+       Double_t tpcSignalTotPrim=0; 
+       Double_t tpcSignalTotSec=0; 
+       Int_t ntracksTPC=0;
+       Int_t nTPCPrim=0; 
+       Int_t nTPCSec=0;  
+       Int_t ntracks=event->GetNumberOfTracks();
+       if ( ntracks<=2 ) return;
+       
+       //
+       Float_t dca[2]={0};
+       Float_t cov[3]={0};
+       Float_t dca0[2]={0};
+       Float_t dca1[2]={0};
+       //
+       //1. Calculate total dEdx for primary and secondary tracks
+       //   and count primaries and secondaries
+       Int_t *rejectTrack = new Int_t[ntracks];
+       Float_t *trackUsedInVtx = new Float_t[ntracks];
+       
+       for (Int_t ii=0; ii<ntracks; ii++){
+               trackUsedInVtx[ii] = 0.;
+       }
+       Int_t nTracksCont = 0;
+       
+       for (Int_t itrack=0; itrack<ntracks; itrack++){
+               AliESDtrack *track=event->GetTrack(itrack);
+               rejectTrack[itrack]=0;
+               if (!track) continue;
+               if ((track->Pt())<kMinPtHadTrack){ rejectTrack[itrack]+=32; continue;}
+               if (track->GetTPCNcls()<=kMinCl) {rejectTrack[itrack]+=64; continue;}  // skip short tracks
+               ntracksTPC++;
+               if ((1.+track->GetTPCNcls())/(1.+track->GetTPCNclsF())<=kMinRatio){rejectTrack[itrack]+=128; continue;}
+               if (!track->GetInnerParam()) continue;  // skip not TPC tracks
+               if (track->GetKinkIndex(0)!=0)  {rejectTrack[itrack]+=16;continue;} // skip kinks
+               track->GetImpactParameters(dca,cov);
+               if (TMath::Abs(dca[0])>kMaxDistR && TMath::Abs(dca[1])>kMaxDistZ){rejectTrack[itrack]+=256; continue;}
+               // remove too dip secondaries
+               if (TMath::Abs(dca[0])<kMinDist && TMath::Abs(dca[1])<kMinDist){
+                       tpcSignalTotPrim+=track->GetTPCsignal();
+                       nTPCPrim++;
+                       rejectTrack[itrack]+=256;
+               }else{
+                       tpcSignalTotSec+=track->GetTPCsignal();
+                       nTPCSec++;
+               };
+               if (cov[0]>kEpsilon &&TMath::Abs(dca[0])>kEpsilon &&TMath::Sqrt(dca[0]*dca[0]/(TMath::Abs(cov[0])))<kMinDistChi2) rejectTrack[itrack]+=1;  // primary
+               if (cov[0]>kEpsilon &&TMath::Abs(dca[0])>kEpsilon &&TMath::Abs(dca[0])<kMinDist)  rejectTrack[itrack]+=1;  // primary
+               if (track->GetTPCsignal()<40) rejectTrack[itrack]+=16;
+               //
+               if (CheckLooper(itrack, event))   rejectTrack[itrack]+=2;   // looper
+               if (CheckV0(itrack,event))       rejectTrack[itrack]+=4; //indentified V0 rejection (K0s, Lambda, gamma conv)
+
+//             UInt_t status = track->GetStatus();
+               if (!track->IsOn(AliVTrack::kITSrefit) && !fDoMCTruth){ 
+                       
+                       Double_t *covar = (Double_t*)track->GetInnerParam()->GetCovariance();
+                       //
+                       //remove -systematic error estimate
+                       //
+                       Double_t sigmazz  = covar[track->GetIndex(1,1)];
+                       Double_t dr = TMath::Abs(TMath::Sqrt((track->GetX()*track->GetX()+track->GetY()*track->GetY())) - TMath::Sqrt((track->GetInnerParam()->GetX()*track->GetInnerParam()->GetX()+track->GetInnerParam()->GetY()*track->GetInnerParam()->GetY()))) ;
+                       
+                       Double_t sigmazz0 = sigmazz -szz*szz - stt*stt*dr*dr;
+//                     cout << "old sigma z: "<<sigmazz << " new sigma z: " << sigmazz0 << endl;
+                       if (sigmazz0<0) sigmazz0=0.1;  // should not happen - the code should be protected
+                       covar[track->GetIndex(1,1)]=sigmazz0;
+                       //
+                       // + rescale the correlation terms
+                       //
+                       Double_t ratio = TMath::Sqrt(sigmazz0/sigmazz);
+                       for (Int_t index=0; index<5; index++){
+                               Int_t jindex = track->GetIndex(index,1);
+                               covar[jindex]*=ratio;
+                       }
+               }
+       } 
+       
+       
+       //
+       // 2. Find secondary vertices - double loop
+       //    
+       
+       AliKFVertex vertexStored[15];
+       Int_t kVertexArr[15][7];
+       for (Int_t ii = 0; ii < 15; ii++){
+               for (Int_t bb = 0; bb < 7; bb++){
+                               kVertexArr[ii][bb] = 0;
+               }               
+       }
+       Int_t kTrackArr[500][7];
+       for (Int_t ii = 0; ii < 500; ii++){
+               for (Int_t bb = 0; bb < 7; bb++){
+                               kTrackArr[ii][bb] = 0;
+               }               
+       }
+       
+       Int_t nVertices = 0;
+       Int_t nVerticesPassed = 0;
+       
+       for (Int_t itrack0=0; itrack0<ntracks; itrack0++){
+               if (rejectTrack[itrack0]) continue;   // skip
+               AliESDtrack *track0=event->GetTrack(itrack0);
+               if (!track0) continue;
+               
+               track0->GetImpactParameters(dca[0],dca[1]);
+               track0->GetImpactParameters(dca0[0],dca0[1]);
+
+               AliKFParticle part0;
+               if (!track0->IsOn(AliVTrack::kITSrefit)){ 
+                       part0=AliKFParticle(*track0->GetInnerParam(),211);  //assuming pion mass
+               } else {
+                       part0=AliKFParticle(*track0,211);  //assuming pion mass
+               }
+               if (track0->Charge()*part0.Q()<0) part0.Q()*=-1;  // change sign if opposite
+               //
+               for (Int_t itrack1=itrack0+1; itrack1<ntracks; itrack1++){
+                       if (rejectTrack[itrack1]) continue;   // skip
+                       AliESDtrack *track1=event->GetTrack(itrack1);
+                       if (!track1) continue;
+                       track1->GetImpactParameters(dca1[0],dca1[1]);
+                       track1->GetImpactParameters(dca[0],dca[1]);
+                       AliKFParticle part1; // assuming pion mass
+                       if (!track1->IsOn(AliVTrack::kITSrefit)){ 
+                               part1=AliKFParticle(*track1->GetInnerParam(),211);  //assuming pion mass
+                       } else {
+                               part1=AliKFParticle(*track1,211);  //assuming pion mass
+                       }
+                       if (track1->Charge()*part1.Q()<0) part1.Q()*=-1;  // change sign if opposite
+
+                       //
+                       //
+                       AliKFVertex vertex;
+                       vertex+=part0;
+                       vertex+=part1;
+                       if ((vertex.GetChi2()/vertex.GetNDF())> kMaxChi2) continue;
+                       if (TMath::Abs(vertex.GetX())>kMaxDistR) continue;
+                       if (TMath::Abs(vertex.GetY())>kMaxDistR) continue;
+                       if (TMath::Abs(vertex.GetZ())>kMaxDistZ) continue;
+                       Double_t errX2=vertex.GetErrX();
+                       Double_t errY2=vertex.GetErrY();
+                       Double_t errZ2=vertex.GetErrZ();
+                       //
+                       Double_t err3D=TMath::Sqrt(errX2*errX2+errY2*errY2+errZ2*errZ2/10.);  
+                       if (err3D>kMaxDistVertexSec) continue;
+                       if (err3D*TMath::Sqrt(vertex.GetChi2()+0.00001)>kMaxDistVertexSec) continue;
+
+                       Double_t dvertex=0;
+                       dvertex += (vertexSPD->GetX()-vertex.GetX())*(vertexSPD->GetX()-vertex.GetX());
+                       dvertex += (vertexSPD->GetY()-vertex.GetY())*(vertexSPD->GetY()-vertex.GetY());
+                       dvertex += (vertexSPD->GetZ()-vertex.GetZ())*(vertexSPD->GetZ()-vertex.GetZ());
+                       dvertex=TMath::Sqrt(dvertex+0.00000001);
+                       if (err3D>0.2*dvertex) continue;    
+                       if (err3D*TMath::Sqrt(vertex.GetChi2()+0.000001)>0.1*dvertex) continue;
+                       Double_t radius = TMath::Sqrt((vertex.GetX()*vertex.GetX()+vertex.GetY()*vertex.GetY()));
+                       
+                       for (Int_t bb= 0; bb < 6; bb++){
+                               if (radius > arrayRBins[bb]) {
+                                       if (track0->HasPointOnITSLayer(bb) ||  track1->HasPointOnITSLayer(bb) ) continue; 
+                               }
+                       }
+                       AliKFVertex vertex2;
+                       vertex2+=part0;
+                       vertex2+=part1;
+                       //
+
+//                     if(fDoMCTruth){
+//                             
+//                     }
+                               
+                       trackUsedInVtx[itrack0] +=1.; 
+                       trackUsedInVtx[itrack1] +=1.; 
+                       
+                       nTracksCont= 2;
+                       kTrackArr[itrack0][0]+= 1;
+                       kTrackArr[itrack1][0]+= 1;
+                       kVertexArr[nVertices][0] = 2;
+                       kVertexArr[nVertices][1] = 1;
+                       kVertexArr[nVertices][2] = itrack0;
+                       kVertexArr[nVertices][3] = itrack1;
+                       
+                       for (Int_t itrack2=0; itrack2<ntracks; itrack2++){  
+                               if (rejectTrack[itrack2]) continue;   // skip
+                               if (itrack2==itrack0) continue;
+                               if (itrack2==itrack1) continue;
+                               AliESDtrack *track2=event->GetTrack(itrack2);
+                               if (!track2) continue;
+                               track2->GetImpactParameters(dca[0],dca[1]);
+                               if (TMath::Abs(track2->GetD(vertex.GetX(), vertex.GetY(),event->GetMagneticField()))>kMaxDistVertexSec) continue;
+                               Double_t vtxx[3]={vertex2.GetX(),vertex2.GetY(),vertex2.GetZ()};
+                               Double_t svtxx[3]={vertex.GetErrX(),vertex.GetErrY(),vertex.GetErrZ()};
+                               AliESDVertex vtx(vtxx,svtxx);
+                               
+                               AliExternalTrackParam param;
+                               if (!track2->IsOn(AliVTrack::kITSrefit)){ 
+                                       param= *track2->GetInnerParam();  //assuming pion mass
+                               } else {
+                                       param=*track2;
+                               }
+                               Double_t delta[2]={0,0};
+                               if (!param.PropagateToDCA(&vtx,event->GetMagneticField(),kMaxDistVertexSec,delta)) continue;    
+                               if (TMath::Abs(delta[0])>kMaxDistVertexSec) continue;
+                               if (TMath::Abs(delta[1])>kMaxDistVertexSec) continue;      
+                               if (TMath::Abs(delta[0])>6.*TMath::Sqrt(param.GetSigmaY2()+vertex2.GetErrY()*vertex2.GetErrY())+0.1) continue; 
+                               if (TMath::Abs(delta[1])>6.*TMath::Sqrt(param.GetSigmaZ2()+vertex2.GetErrZ()*vertex2.GetErrZ())+0.5) continue; 
+                               //
+                               AliKFParticle part2(param,211); // assuming pion mass
+                               if (track2->Charge()*part2.Q()<0) part2.Q()*=-1;  // change sign if opposite
+
+                               for (Int_t cc= 0; cc < 6; cc++){
+                                       if (radius > arrayRBins[cc]){
+                                               if (track2->HasPointOnITSLayer(cc)  ) continue; 
+                                       }
+                               }
+                       
+
+                               vertex2+=part2;
+//                             rejectTrack[itrack0]+=10;  // do noit reuse the track
+//                             rejectTrack[itrack1]+=10;  // do not reuse the track      
+//                             rejectTrack[itrack2]+=10;
+                               trackUsedInVtx[itrack2] +=1.;           
+//                             cout << "track number " << itrack2 << " used times " <<  trackUsedInVtx[itrack2] << endl;
+                               nTracksCont++ ;
+                               kTrackArr[itrack2][0]+= 1;
+                               kVertexArr[nVertices][0] = nTracksCont;
+                               kVertexArr[nVertices][1] = 1;
+                               kVertexArr[nVertices][nTracksCont+1] = itrack2;
+                       
+                       }
+//                     if (nVertices == 0){            
+//                             cout << "new Event" << endl;
+//                     }
+//                     cout << "Vertex " << nVertices << " nTracks " << kVertexArr[nVertices][0] << endl;
+//                     for (Int_t ii = 2  ; ii < kVertexArr[nVertices][0]+2; ii++){
+//                             cout << "\t Track " << kVertexArr[nVertices][ii] << endl;
+//                     }
+                       vertexStored[nVertices]= vertex2;
+                       nVertices++;
+//                     Double_t errX=vertex2.GetErrX();
+//                     Double_t errY=vertex2.GetErrY();
+//                     Double_t errZ=vertex2.GetErrZ();
+//                     Double_t vx = vertex2.GetX();
+//                     Double_t vy = vertex2.GetY();
+//                     Double_t vz = vertex2.GetZ();
+//                     Double_t vr = sqrt((Double_t)(vx*vx + vy*vy));
+//                     Double_t vphi = vertex2.GetPhi(); 
+//                     Double_t vphi2 = TMath::ATan2(vy, vx);
+//                     cout << "\t Quality \t errX: " <<errX << "\t errY: " << errY << "\t errZ: " << errZ << "\t Chi2/ndf: " << vertex2.GetChi2()/vertex2.GetNDF() << endl;
+//                     cout << "\t Position \t x: " <<  vx << "\t y: " << vy << "\t z: " << vz <<"\t r: " << vr  << "\t phi: " << vphi << "\t phi dir calc: " << vphi2 << endl;
+//                     Double_t vNDCA = vertex2.GetDcaV0Daughters()/vertex2.GetDistSigma() 
+//                     if (fpcstream){
+//                             (*fpcstream)<<"ntracks="<<ntracks<<
+//                             "ntracksTPC="<<ntracksTPC<<
+//                             "nPrim="<<nTPCPrim<<              // number of primaries
+//                             "nSec="<<nTPCSec<<                // number of secondaries
+//                             "sigPrim="<<tpcSignalTotPrim<<    // total dEdx in primaries
+//                             "sigSec="<<tpcSignalTotSec<<      // total dEdx in secondaries
+//                             "v.="<<&vertex<<                  // KF vertex
+//                             "v2.="<<&vertex2<<                // KF vertex all tracks
+//                             "z0="<<dca0[1]<<
+//                             "z1="<<dca1[1]<<
+//                             "rphi0="<<dca0[0]<<
+//                             "rphi1="<<dca1[0]<<
+//                             "radius="<<radius<<
+//                             "vx="<<vx<<
+//                             "vy="<<vy<<
+//                             "vz="<<vz<<
+//                             "errX="<<errX<<
+//                             "errY="<<errY<<
+//                             "errZ="<<errZ<<
+//                             "err2D="<<err2D<<
+//                             "err3D="<<err3D<<         
+//                             "dvertex="<<dvertex<< 
+//                             "\n";
+//                     }
+//             
+                       fHistograms->FillHistogram("ESD_HadIntQual_nTracks", ntracks);
+                       fHistograms->FillHistogram("ESD_HadIntQual_ntracksTPC", ntracksTPC);
+               }
+       }
+
+       Int_t verticesRejectedInLoop = 0;
+       for (Int_t ll = 0; ll < nVertices; ll++){
+               if (kVertexArr[ll][1] == 0) continue;
+               for (Int_t kk = 0; kk < nVertices; kk++){
+                       Int_t trackUsedTwice = 0;
+                       Int_t numberOfTracksUsedTwice = 0;
+                       Int_t trackNumberTrackUsedTwice[10];
+                       if (ll == kk) continue;
+                       if (kVertexArr[kk][1] == 0 || kVertexArr[ll][1] == 0 ) continue;
+//                     cout << "Vertex " << ll << " nTracks " << kVertexArr[ll][0] << endl;
+                       for (Int_t ii = 2  ; ii < kVertexArr[ll][0]+2; ii++){
+//                             cout << "\t Track " << kVertexArr[ll][ii] << endl;
+//                             cout << "\t Vertex " << kk << " nTracks " << kVertexArr[kk][0] << endl;
+                               for (Int_t jj = 2 ; jj < kVertexArr[kk][0]+2; jj++){
+//                                     cout << "\t\t Track " << kVertexArr[kk][jj] << endl;
+                                       if (kVertexArr[ll][ii] == kVertexArr[kk][jj]){
+//                                             cout << "\t\t track used twice" << endl;
+                                               trackUsedTwice = 1;
+                                               trackNumberTrackUsedTwice[numberOfTracksUsedTwice] = kVertexArr[kk][jj];
+                                               numberOfTracksUsedTwice++;
+                                               
+                                       }
+                               }
+                       }
+                       if (trackUsedTwice){
+                               if (vertexStored[ll].GetChi2()/vertexStored[ll].GetNDF() < vertexStored[kk].GetChi2()/vertexStored[kk].GetNDF()){
+//                                     cout << "\t Vertex " <<  kk <<"\t track used twice: " << numberOfTracksUsedTwice << "\t tracks left for vertex: " << kVertexArr[kk][0]-numberOfTracksUsedTwice <<  endl;
+                                       if ( kVertexArr[kk][0]-numberOfTracksUsedTwice < 2){
+                                               kVertexArr[kk][1] = 0;
+                                       } else {
+                                               for (Int_t count = 0; count < numberOfTracksUsedTwice; count++){
+                                                       for (Int_t hh = 2; hh < kVertexArr[kk][0]+2; hh++){
+                                                               if (kVertexArr[kk][hh] == trackNumberTrackUsedTwice[count]){
+//                                                                     cout << "\t track to be removed " << trackNumberTrackUsedTwice[count] << " from position "<< hh <<endl;
+                                                                       for (Int_t ii = kVertexArr[kk][0]+2-hh; ii > 1; ii--){
+                                                                               Int_t pos = kVertexArr[kk][0]+2-ii;
+                                                                               kVertexArr[kk][pos] = kVertexArr[kk][pos+1];
+                                                                       }
+                                                                       kVertexArr[kk][0] -=1;
+                                                               }
+                                                       }
+                                                       
+                                                       AliESDtrack *track0=event->GetTrack(kVertexArr[kk][2]);
+                                                       AliKFParticle part0;
+                                                       if (!track0->IsOn(AliVTrack::kITSrefit)){ 
+                                                               part0=AliKFParticle(*track0->GetInnerParam(),211);  //assuming pion mass
+                                                       } else {
+                                                               part0=AliKFParticle(*track0,211);  //assuming pion mass
+                                                       }
+                                               
+                                                       if (track0->Charge()*part0.Q()<0) part0.Q()*=-1;  // change sign if opposite
+
+                                                       AliKFVertex vertex;                                             
+                                                       vertex+=part0;
+                                                       
+//                                                     cout << "\t Vertex " << kk << " nTracks " << kVertexArr[kk][0] << endl;
+                                                       for (Int_t ii = 2  ; ii < kVertexArr[kk][0]+2; ii++){
+//                                                             cout << "\t \t Track " << kVertexArr[kk][ii] << endl;
+                                                               if (ii > 2){
+                                                                       AliESDtrack *track1=event->GetTrack(kVertexArr[kk][ii]);
+                                                                       AliKFParticle part1;
+                                                                       if (!track1->IsOn(AliVTrack::kITSrefit)){ 
+                                                                               part1=AliKFParticle(*track1->GetInnerParam(),211);  //assuming pion mass
+                                                                       } else {
+                                                                               part1=AliKFParticle(*track1,211);  //assuming pion mass
+                                                                       }
+                                                               
+                                                                       if (track1->Charge()*part1.Q()<0) part1.Q()*=-1;  // change sign if opposite
+                                                                       vertex+=part1;
+                                                               }
+                                                       }
+                                                       vertexStored[kk]=vertex;
+//                                                     cout << "\t removing tracks from vtx " << kk << "new chi2/ndf: " << vertexStored[kk].GetChi2()/vertexStored[kk].GetNDF() <<endl;
+//                                                     cout << "Vertex " << kk << " nTracks " << kVertexArr[kk][0] << endl;
+//                                                             for (Int_t ii = 2  ; ii < kVertexArr[kk][0]+2; ii++){
+//                                                             cout << "\t Track " << kVertexArr[kk][ii] << endl;
+//                                                     }
+//                                                     Double_t errX=vertex.GetErrX();
+//                                                     Double_t errY=vertex.GetErrY();
+//                                                     Double_t errZ=vertex.GetErrZ();
+//                                                     Double_t vx = vertex.GetX();
+//                                                     Double_t vy = vertex.GetY();
+//                                                     Double_t vz = vertex.GetZ();
+//                                                     Double_t vr = sqrt((Double_t)(vx*vx + vy*vy));
+//                                                     Double_t vphi = TMath::ATan2(vy, vx);
+//                                                     cout << "\t Quality \t errX: " <<errX << "\t errY: " << errY << "\t errZ: " << errZ << "\t Chi2/ndf: " << vertex.GetChi2()/vertex.GetNDF() << endl;
+//                                                     cout << "\t Position \t x: " <<  vx << "\t y: " << vy << "\t z: " << vz <<"\t r: " << vr  << "\t phi: " << vphi << endl; 
+                                               }
+                                               kVertexArr[kk][1] = 1;
+                                               verticesRejectedInLoop--;
+                                       }
+                                       
+//                                     cout << "\t rejected vertex " << kk << endl;
+                               } else {
+                                       kVertexArr[ll][1] = 0;
+//                                     cout << "\t Vertex " <<  ll  << "\t track used twice: " << numberOfTracksUsedTwice << "\t tracks left for vertex: " << kVertexArr[ll][0]-numberOfTracksUsedTwice <<  endl;
+                                       if ( kVertexArr[ll][0]-numberOfTracksUsedTwice < 2){
+                                               kVertexArr[ll][1] = 0;
+                                       } else {
+                                               for (Int_t count = 0; count < numberOfTracksUsedTwice; count++){
+                                                       for (Int_t hh = 2; hh < kVertexArr[ll][0]+2; hh++){
+                                                               if (kVertexArr[ll][hh] == trackNumberTrackUsedTwice[count]){
+//                                                                     cout << "\t track to be removed " << trackNumberTrackUsedTwice[count] << " from position "<< hh <<endl;
+                                                                       for (Int_t ii = kVertexArr[ll][0]+2-hh; ii > 1; ii--){
+                                                                               Int_t pos = kVertexArr[ll][0]+2-ii;
+                                                                               kVertexArr[ll][pos] = kVertexArr[ll][pos+1];
+                                                                       }
+                                                                       kVertexArr[ll][0] -=1;
+                                                               }
+                                                       }
+                                                       AliESDtrack *track0=event->GetTrack(kVertexArr[ll][2]);
+                                                       AliKFParticle part0(*track0,211);  //assuming pion mass
+                                                       if (track0->Charge()*part0.Q()<0) part0.Q()*=-1;  // change sign if opposite
+
+                                                       AliKFVertex vertex;                                             
+                                                       vertex+=part0;
+                                                       
+//                                                     cout << "\t Vertex " << ll << " nTracks " << kVertexArr[ll][0] << endl;
+                                                       for (Int_t ii = 2  ; ii < kVertexArr[ll][0]+2; ii++){
+//                                                             cout << "\t \t Track " << kVertexArr[ll][ii] << endl;
+                                                               if (ii > 2){
+                                                                       AliESDtrack *track1=event->GetTrack(kVertexArr[ll][ii]);
+                                                                       AliKFParticle part1(*track1,211); // assuming pion mass
+                                                                       if (track1->Charge()*part1.Q()<0) part1.Q()*=-1;  // change sign if opposite
+                                                                       vertex+=part1;
+                                                               }
+                                                       }
+                                                       vertexStored[ll]=vertex;
+//                                                     cout << "\t removing tracks from vtx " << ll << "new chi2/ndf: " << vertexStored[ll].GetChi2()/vertexStored[ll].GetNDF() <<endl;
+//                                                     cout << "Vertex " << ll << " nTracks " << kVertexArr[ll][0] << endl;
+//                                                             for (Int_t ii = 2  ; ii < kVertexArr[ll][0]+2; ii++){
+//                                                             cout << "\t Track " << kVertexArr[ll][ii] << endl;
+//                                                     }
+//                                                     Double_t errX=vertex.GetErrX();
+//                                                     Double_t errY=vertex.GetErrY();
+//                                                     Double_t errZ=vertex.GetErrZ();
+//                                                     Double_t vx = vertex.GetX();
+//                                                     Double_t vy = vertex.GetY();
+//                                                     Double_t vz = vertex.GetZ();
+//                                                     Double_t vr = sqrt((Double_t)(vx*vx + vy*vy));
+//                                                     Double_t vphi = TMath::ATan2(vy, vx);
+//                                                     cout << "\t Quality \t errX: " <<errX << "\t errY: " << errY << "\t errZ: " << errZ << "\t Chi2/ndf: " << vertex.GetChi2()/vertex.GetNDF() << endl;
+//                                                     cout << "\t Position \t x: " <<  vx << "\t y: " << vy << "\t z: " << vz <<"\t r: " << vr  << "\t phi: " << vphi << endl; 
+                                               }
+                                               kVertexArr[ll][1] = 1;
+                                               verticesRejectedInLoop--;
+                                       }
+                               }
+                               verticesRejectedInLoop++;
+                       }
+               }
+       }
+//     if (nVertices > 0){
+//             cout << "Selected Vertices___________________________________" << endl;
+//     }
+       for (Int_t fin = 0; fin < nVertices; fin++){
+               if (kVertexArr[fin][1] == 0) continue;
+               Double_t errX=vertexStored[fin].GetErrX();
+               Double_t errY=vertexStored[fin].GetErrY();
+               Double_t errZ=vertexStored[fin].GetErrZ();
+               Double_t err3D=TMath::Sqrt(errX*errX+errY*errY+errZ*errZ/10.);  
+               Double_t err2D=TMath::Sqrt(errX*errX+errY*errY);  
+               Double_t vx = vertexStored[fin].GetX();
+               Double_t vy = vertexStored[fin].GetY();
+               Double_t vz = vertexStored[fin].GetZ();
+               Double_t vr = sqrt((Double_t)(vx*vx + vy*vy));
+               Double_t vphi = TMath::ATan2(vy, vx);
+//             cout << "Vertex " << fin << " nTracks " << kVertexArr[fin][0] << endl;
+               for (Int_t ii = 2  ; ii < kVertexArr[fin][0]+2; ii++){
+//                     cout << "\t Track " << kVertexArr[fin][ii] << endl;
+               }
+//             cout << "\t Quality \t errX: " <<errX << "\t errY: " << errY << "\t errZ: " << errZ << "\t Chi2/ndf: " << vertexStored[fin].GetChi2()/vertexStored[fin].GetNDF() << endl;
+//             cout << "\t Position \t x: " <<  vx << "\t y: " << vy << "\t z: " << vz <<"\t r: " << vr  << "\t phi:" << vphi << endl;
+
+               fHistograms->FillHistogram("ESD_HadIntQual_nTracksSecVtx", kVertexArr[fin][0]);
+               fHistograms->FillHistogram("ESD_HadIntQual_ErrX", errX);
+//                     fHistograms->FillHistogram("ESD_HadIntQual_NormDCA", vNDCA);
+               fHistograms->FillHistogram("ESD_HadIntQual_ErrY", errY);
+               fHistograms->FillHistogram("ESD_HadIntQual_ErrZ", errZ);
+               fHistograms->FillHistogram("ESD_HadIntQual_Err2D", err2D);
+               fHistograms->FillHistogram("ESD_HadIntQual_Err3D", err3D);
+               fHistograms->FillHistogram("ESD_HadIntQual_Chi2PerDOF", vertexStored[fin].GetChi2()/vertexStored[fin].GetNDF());
+               Double_t chi2PerDOF = vertexStored[fin].GetChi2()/vertexStored[fin].GetNDF();
+               if ( chi2PerDOF< fMaxChi2HadInt  && err2D < fMaxErr2DHadInt ){
+                       fHistograms->FillHistogram("ESD_HadIntMap_ZR", vz,vr);
+                       fHistograms->FillHistogram("ESD_HadIntMap_XY", vx,vy);
+                       
+                       fHistograms->FillHistogram("ESD_HadIntMap_ZPhi", vz,vphi);
+                       fHistograms->FillHistogram("ESD_HadIntMap_RPhi", vr,vphi);
+                       Double_t rFMD=25;
+                       Double_t rITSTPCMin=45;
+                       Double_t rITSTPCMax=80;
+               
+                       if(vr<rFMD){
+                               fHistograms->FillHistogram("ESD_HadIntMap_FMD_ZPhi", vz,vphi);
+                       }
+                       if(vr>rFMD && vr<rITSTPCMin){
+                               fHistograms->FillHistogram("ESD_HadIntMap_FMD2_ZPhi", vz,vphi);
+                       }
+
+                       if(vr>rITSTPCMin && vr<rITSTPCMax){
+                               fHistograms->FillHistogram("ESD_HadIntMap_ITSTPC_ZPhi", vz,vphi);
+                       }
+                       Double_t rHotZoneMin = 5.7;
+                       Double_t rHotZoneMax = 50.;
+                       Double_t zHotZoneMin = 45.;
+                       Double_t zHotZoneMax = 75.;
+                       
+                       if (vr>rHotZoneMin && vr < rHotZoneMax){
+                               fHistograms->FillHistogram("ESD_HadIntMap_HotZone_ZPhi", vz,vphi);
+                               if (vz < zHotZoneMax && vz > zHotZoneMin){
+                                       fHistograms->FillHistogram("ESD_HadIntMap_HotZone_XY", vx,vy);
+                               }
+                       }
+                       
+                       Double_t zBeamPipeInner = 30.;
+                       Double_t zOuterParts = 90.;
+                       if (vz < zBeamPipeInner && vz > - zBeamPipeInner) {
+                               fHistograms->FillHistogram("ESD_HadIntMapInnerBeampipe_XY", vx,vy);
+                               fHistograms->FillHistogram("ESD_HadIntMapInnerParts_XY", vx,vy);
+                               if (vr < rFMD ){
+                                       fHistograms->FillHistogram("ESD_HadIntQualAftCutsSmallR_ErrX", errX);
+                                       fHistograms->FillHistogram("ESD_HadIntQualAftCutsSmallR_ErrY", errY);
+                                       fHistograms->FillHistogram("ESD_HadIntQualAftCutsSmallR_ErrZ", errZ);
+                                       fHistograms->FillHistogram("ESD_HadIntQualAftCutsSmallR_Err2D", err2D);
+                                       fHistograms->FillHistogram("ESD_HadIntQualAftCutsSmallR_Err3D", err3D);
+                                       fHistograms->FillHistogram("ESD_HadIntQualAftCutsSmallR_Chi2PerDOF", vertexStored[fin].GetChi2()/vertexStored[fin].GetNDF());
+                               }
+                       }
+                       
+                       if (vz > zOuterParts )  fHistograms->FillHistogram("ESD_HadIntMapPosZOuterParts_XY", vx,vy);
+                       if (vz > zBeamPipeInner && vz < zOuterParts ) {
+                               fHistograms->FillHistogram("ESD_HadIntMapPosZFMD_XY", vx,vy);
+                               if (vr < rFMD ){
+                                       fHistograms->FillHistogram("ESD_HadIntQualAftCutsSmallROut_ErrX", errX);
+                                       fHistograms->FillHistogram("ESD_HadIntQualAftCutsSmallROut_ErrY", errY);
+                                       fHistograms->FillHistogram("ESD_HadIntQualAftCutsSmallROut_ErrZ", errZ);
+                                       fHistograms->FillHistogram("ESD_HadIntQualAftCutsSmallROut_Err2D", err2D);
+                                       fHistograms->FillHistogram("ESD_HadIntQualAftCutsSmallROut_Err3D", err3D);
+                                       fHistograms->FillHistogram("ESD_HadIntQualAftCutsSmallROut_Chi2PerDOF", vertexStored[fin].GetChi2()/vertexStored[fin].GetNDF());
+                               }
+                       }
+                       if (vz < -zBeamPipeInner && vz > -zOuterParts )         fHistograms->FillHistogram("ESD_HadIntMapNegZFMD_XY", vx,vy);
+                       
+                       fHistograms->FillHistogram("ESD_HadIntQualAftCuts_ErrX", errX);
+                       fHistograms->FillHistogram("ESD_HadIntQualAftCuts_ErrY", errY);
+                       fHistograms->FillHistogram("ESD_HadIntQualAftCuts_ErrZ", errZ);
+                       fHistograms->FillHistogram("ESD_HadIntQualAftCuts_Err2D", err2D);
+                       fHistograms->FillHistogram("ESD_HadIntQualAftCuts_Err3D", err3D);
+                       fHistograms->FillHistogram("ESD_HadIntQualAftCuts_Chi2PerDOF", vertexStored[fin].GetChi2()/vertexStored[fin].GetNDF());
+
+                       if (kVertexArr[fin][0]>2 ){
+                               fHistograms->FillHistogram("ESD_HadIntMap3_ZR", vz,vr);
+                               fHistograms->FillHistogram("ESD_HadIntMap3_XY", vx,vy);
+                       
+                               fHistograms->FillHistogram("ESD_HadIntMap3_ZPhi", vz,vphi);
+                               fHistograms->FillHistogram("ESD_HadIntMap3_RPhi", vr,vphi);
+                       
+                               if(vr<rFMD){
+                                       fHistograms->FillHistogram("ESD_HadIntMap3_FMD_ZPhi", vz,vphi);
+                               }
+                               if(vr>rFMD && vr<rITSTPCMin){
+                                       fHistograms->FillHistogram("ESD_HadIntMap3_FMD2_ZPhi", vz,vphi);
+                               }
+
+                               if (vr>rITSTPCMin && vr<rITSTPCMax){
+                                       fHistograms->FillHistogram("ESD_HadIntMap3_ITSTPC_ZPhi", vz,vphi);
+                               }
+                               if (vz < zBeamPipeInner && vz > - zBeamPipeInner) {
+                                       fHistograms->FillHistogram("ESD_HadIntMap3InnerBeampipe_XY", vx,vy);
+                                       fHistograms->FillHistogram("ESD_HadIntMap3InnerParts_XY", vx,vy);
+                               }
+                               if (vz > zOuterParts )  fHistograms->FillHistogram("ESD_HadIntMap3PosZOuterParts_XY", vx,vy);
+                               if (vz > zBeamPipeInner && vz < zOuterParts ) {
+                                       fHistograms->FillHistogram("ESD_HadIntMap3PosZFMD_XY", vx,vy);
+                               }
+                               if (vz < -zBeamPipeInner && vz > -zOuterParts )         fHistograms->FillHistogram("ESD_HadIntMap3NegZFMD_XY", vx,vy);
+                       
+                               if (vr>rHotZoneMin && vr < rHotZoneMax){
+                                       fHistograms->FillHistogram("ESD_HadIntMap3_HotZone_ZPhi", vz,vphi);
+                                       if (vz < zHotZoneMax && vz > zHotZoneMin){
+                                               fHistograms->FillHistogram("ESD_HadIntMap3_HotZone_XY", vx,vy);
+                                       }
+                               }       
+                               fHistograms->FillHistogram("ESD_HadIntQual3AftCuts_ErrX", errX);
+                               fHistograms->FillHistogram("ESD_HadIntQual3AftCuts_ErrY", errY);
+                               fHistograms->FillHistogram("ESD_HadIntQual3AftCuts_ErrZ", errZ);
+                               fHistograms->FillHistogram("ESD_HadIntQual3AftCuts_Err2D", err2D);
+                               fHistograms->FillHistogram("ESD_HadIntQual3AftCuts_Err3D", err3D);
+                               fHistograms->FillHistogram("ESD_HadIntQual3AftCuts_Chi2PerDOF", vertexStored[fin].GetChi2()/vertexStored[fin].GetNDF());
+                       }
+                       nVerticesPassed++;
+               }
+       }
+       
+//     if (nVertices > 0){
+//             cout << "number of total vertices: "<< nVertices << endl;
+//             cout << "number of total vertices passing selection: "<< nVerticesPassed << endl;
+//             cout << "vertices rejected in loop: " << verticesRejectedInLoop << endl;
+//     }
+       delete [] rejectTrack;
+}
+
+
+Bool_t AliAnalysisTaskGammaConversion::CheckLooper(Int_t index, AliESDEvent *event){
+  //
+  // check if given track is looper candidate
+  // if looper return kTRUE
+  // 
+  Int_t ntracks=event->GetNumberOfTracks();
+  Int_t index1=-1;
+  const Double_t ktglCut=0.03;
+  const Double_t kalphaCut=0.4;
+  //
+  AliESDtrack * track0 = event->GetTrack(index);
+  AliESDtrack * track1P = 0;
+  for (Int_t itrack1=0; itrack1<ntracks; itrack1++){
+    if (itrack1==index) continue;
+    AliESDtrack *track1=event->GetTrack(itrack1);
+    if (!track1) continue;
+    if (TMath::Abs(TMath::Abs(track1->GetTgl())-TMath::Abs(track0->GetTgl()))>ktglCut) continue;
+    if (TMath::Abs(TMath::Abs(track1->GetAlpha())-TMath::Abs(track0->GetAlpha()))>kalphaCut) continue;
+    index1=index;
+    track1P=track1;
+  }
+  if (index1>=0){
+    return kTRUE;
+  }
+  return kFALSE;
+}
+
+Bool_t AliAnalysisTaskGammaConversion::CheckV0(Int_t index, AliESDEvent *event){
+       //
+       // check if given track is V0 candidata
+       // if looper return kTRUE
+       // 
+       return kFALSE;
+       Int_t ntracks=event->GetNumberOfTracks();
+       Int_t index1=-1;
+       const Double_t kSigmaMass=0.001;
+       const Int_t kChi2Cut=10;
+       //
+       AliESDtrack * track0 = event->GetTrack(index);
+       AliExternalTrackParam pL(*track0);
+       AliKFParticle part0El(*track0, 11);  //assuming  mass e
+       AliKFParticle part0Pi(*track0, 211);  //assuming  mass pion
+       AliKFParticle part0P(*track0, 2212);  //assuming  mass proton
+       if (track0->Charge()*part0El.Q()<0) {
+               part0El.Q()*=-1;  // change sign if opposite
+               part0Pi.Q()*=-1;  // change sign if opposite
+               part0P.Q()*=-1;   // change sign if opposite
+       }
+       Bool_t isGamma=0;
+       Bool_t isK0=0;
+       Bool_t isLambda=0;
+       Bool_t isLambdaBar=0;
+       
+       for (Int_t itrack1=0; itrack1<ntracks; itrack1++){
+               if (itrack1==index) continue;
+               AliESDtrack *track1=event->GetTrack(itrack1);
+               if (!track1) continue;
+               if (track1->Charge()*track0->Charge()>0) continue;
+               AliKFParticle part1El(*track1, 11);  //assuming  mass e
+               AliKFParticle part1Pi(*track1, 211);  //assuming  mass pion
+               AliKFParticle part1P(*track1, 2212);  //assuming  mass proton
+               if (track1->Charge()*part1El.Q()<0) {
+                       part1El.Q()*=-1;  // change sign if opposite
+                       part1Pi.Q()*=-1;  // change sign if opposite
+                       part1P.Q()*=-1;   // change sign if opposite
+               }
+               //
+               AliKFVertex vertexG;  // gamma conversion candidate
+               vertexG+=part0El;
+               vertexG+=part1El;
+               AliKFVertex vertexGC;  // gamma conversion candidate
+               vertexGC+=part0El;
+               vertexGC+=part1El;
+               vertexGC.SetMassConstraint(0,kSigmaMass);
+               AliKFVertex vertexK0;  // K0s candidate
+               vertexK0+=part0Pi;
+               vertexK0+=part1Pi;
+               AliKFVertex vertexK0C;  // K0s candidate
+               vertexK0C+=part0Pi;
+               vertexK0C+=part1Pi;
+               vertexK0C.SetMassConstraint(0.497614,kSigmaMass);
+               AliKFVertex vertexLambda;  // Lambda candidate
+               vertexLambda+=part0Pi;
+               vertexLambda+=part1P;
+               AliKFVertex vertexLambdaC;  // Lambda candidate
+               vertexLambdaC+=part0Pi;
+               vertexLambdaC+=part1Pi;
+               vertexLambdaC.SetMassConstraint(1.115683,kSigmaMass);
+               AliKFVertex vertexLambdaB;  // Lambda candidate
+               vertexLambdaB+=part0Pi;
+               vertexLambdaB+=part1P;
+               AliKFVertex vertexLambdaBC;  // LambdaBar candidate
+               vertexLambdaBC+=part0Pi;
+               vertexLambdaBC+=part1Pi;
+               vertexLambdaBC.SetMassConstraint(1.115683,kSigmaMass);
+               
+               if (vertexGC.GetChi2()<kChi2Cut && vertexG.GetMass()<0.06)      isGamma=kTRUE;
+               if (vertexK0C.GetChi2()<kChi2Cut&&TMath::Abs(vertexK0.GetMass()-0.5)<0.06)  isK0=kTRUE;
+               if (vertexLambdaC.GetChi2()<kChi2Cut&&TMath::Abs(vertexLambda.GetMass()-1.1)<0.06)  isLambda=kTRUE;
+               if (vertexLambdaBC.GetChi2()<kChi2Cut&&TMath::Abs(vertexLambdaB.GetMass()-1.1)<0.06)  isLambdaBar=kTRUE;
+               if (isGamma||isK0||isLambda||isLambdaBar) {
+                       index1=index;
+                       break;
+               }
+       }
+       if (index1>0) return kTRUE;
+       return kFALSE;
+}
+
 
 void AliAnalysisTaskGammaConversion::ProcessGammaElectronsForChicAnalysis(){
        // see header file for documantation
index 4921bed76f77c72889d67559741f3c52040881ab..ccfc7a0599e550fd4d5a543fd3407f0137f0f991 100644 (file)
@@ -16,6 +16,7 @@
 #include "AliGammaConversionBGHandler.h"
 #include "TRandom3.h"
 #include "TF1.h"
+#include "TTreeStream.h"
 #include "AliMultiplicity.h"
 //#include "AliCFManager.h"  // for CF
 //#include "AliCFContainer.h"   // for CF
@@ -49,278 +50,296 @@ class TF1;
 class AliAnalysisTaskGammaConversion : public AliAnalysisTaskSE
 {
        
- public:
-  typedef enum { kProcSD, kProcDD, kProcND, kProcUnknown, kNProcs } ProcType_t; 
-  AliAnalysisTaskGammaConversion();
-  AliAnalysisTaskGammaConversion(const char* name);
-  virtual ~AliAnalysisTaskGammaConversion() ;// virtual destructor
-               
-  // Implementation of interface methods
-  virtual void UserCreateOutputObjects();
-  virtual void Init();
-  virtual void LocalInit() {Init();}
-  virtual void UserExec(Option_t *option);
-  virtual void Terminate(Option_t *option);
-  //virtual void ConnectInputData(Option_t * option);
-  void CheckMesonProcessTypeEventQuality(Int_t evtQ);
-  Int_t GetProcessType(const AliMCEvent * mcEvt) ;
-  void ProcessMCData();
-  void ProcessV0sNoCut();
-  void ProcessV0s();
-  void ProcessGammasForNeutralMesonAnalysis();
-  void ProcessGammasForOmegaMesonAnalysis();
+public:
+       typedef enum { kProcSD, kProcDD, kProcND, kProcUnknown, kNProcs } ProcType_t; 
+       AliAnalysisTaskGammaConversion();
+       AliAnalysisTaskGammaConversion(const char* name);
+       virtual ~AliAnalysisTaskGammaConversion() ;// virtual destructor
+                       
+       // Implementation of interface methods
+       virtual void UserCreateOutputObjects();
+       virtual void Init();
+       virtual void LocalInit() {Init();}
+       virtual void UserExec(Option_t *option);
+       virtual void Terminate(Option_t *option);
+       //virtual void ConnectInputData(Option_t * option);
+       void CheckMesonProcessTypeEventQuality(Int_t evtQ);
+       Int_t GetProcessType(const AliMCEvent * mcEvt) ;
+       void ProcessMCData();
+       void ProcessV0sNoCut();
+       void ProcessV0s();
+       void ProcessGammasForNeutralMesonAnalysis();
+       void ProcessGammasForOmegaMesonAnalysis();
+    Bool_t DoEventSelection();
   //  void ProcessConvPHOSGammasForNeutralMesonAnalysis();
-//  void RecalculateV0ForGamma();
-  // for CF
-  void SetCFManager(AliCFManager * const io) {fCFManager = io;};
-  AliCFManager *GetCFManager() const {return fCFManager;}
-               
-               
-  // AOD
-  TString GetAODBranchName() const {return  fAODBranchName;}
-  void SetAODBranchName(TString name)  {fAODBranchName = name ;}       
-  void SetForceAOD(Bool_t forceAOD ) { fKFForceAOD = forceAOD; }
-  void FillAODWithConversionGammas();
-  void AddGammaToAOD(AliKFConversionPhoton * kfParticle);
- // void AddPionToAOD(AliKFConversionMother * kfParticle);
- // void AddOmegaToAOD(AliKFParticle * kfParticle, Int_t daughter1, Int_t daughter2);
-  void TagDaughter(Int_t gammaIndex);
-
-  // end AOD
-               
-  static Bool_t IsGoodImpPar(const AliESDtrack *const track);
-       
-  // for GammaJetAnalysis
-  void ProcessGammasForGammaJetAnalysis();
-  void CreateListOfChargedParticles();
-  Double_t GetMinimumDistanceToCharge(Int_t indexHighestPtGamma);
-  void CalculateJetCone(Int_t gammaIndex);
-  Int_t GetIndexHighestPtGamma();
-  void SetESDtrackCuts();
-  // end of Gamma Jet
+       //  void RecalculateV0ForGamma();
+       // for CF
+       void SetCFManager(AliCFManager * const io) {fCFManager = io;};
+       AliCFManager *GetCFManager() const {return fCFManager;}
+                       
+                       
+       // AOD
+       TString GetAODBranchName() const {return  fAODBranchName;}
+       void SetAODBranchName(TString name)  {fAODBranchName = name ;}  
+       void SetForceAOD(Bool_t forceAOD ) { fKFForceAOD = forceAOD; }
+       void FillAODWithConversionGammas();
+       void AddGammaToAOD(AliKFConversionPhoton * kfParticle);
+    void PostAODEvent();
+       // void AddPionToAOD(AliKFConversionMother * kfParticle);
+       // void AddOmegaToAOD(AliKFParticle * kfParticle, Int_t daughter1, Int_t daughter2);
+       void TagDaughter(Int_t gammaIndex);
+
+       // end AOD
+                       
+       static Bool_t IsGoodImpPar(const AliESDtrack *const track);
                
-  void SetMinPtForGammaJet(Double_t minPtForGammaJet){fMinPtForGammaJet=minPtForGammaJet;}
-  void SetMinIsoConeSize(Double_t minIsoConeSize){fMinIsoConeSize=minIsoConeSize;}
-  void SetMinPtIsoCone(Double_t minPtIsoCone){fMinPtIsoCone=minPtIsoCone;}
-  void SetMinPtGamChargedCorr(Double_t minPtGamChargedCorr){fMinPtGamChargedCorr=minPtGamChargedCorr;}
-  void SetMinPtJetCone(Double_t minPtJetCone){fMinPtJetCone=minPtJetCone;}
+       // for GammaJetAnalysis
+       void ProcessGammasForGammaJetAnalysis();
+       void CreateListOfChargedParticles();
+       Double_t GetMinimumDistanceToCharge(Int_t indexHighestPtGamma);
+       void CalculateJetCone(Int_t gammaIndex);
+       Int_t GetIndexHighestPtGamma();
+       void SetESDtrackCuts();
+       // end of Gamma Jet
+                       
+       void SetMinPtForGammaJet(Double_t minPtForGammaJet){fMinPtForGammaJet=minPtForGammaJet;}
+       void SetMinIsoConeSize(Double_t minIsoConeSize){fMinIsoConeSize=minIsoConeSize;}
+       void SetMinPtIsoCone(Double_t minPtIsoCone){fMinPtIsoCone=minPtIsoCone;}
+       void SetMinPtGamChargedCorr(Double_t minPtGamChargedCorr){fMinPtGamChargedCorr=minPtGamChargedCorr;}
+       void SetMinPtJetCone(Double_t minPtJetCone){fMinPtJetCone=minPtJetCone;}
 
-  void SetLowPtMapping(Double_t lowPtMapping){fLowPtMapping=lowPtMapping;}
-  void SetHighPtMapping(Double_t highPtMapping){fHighPtMapping=highPtMapping;}
+       void SetLowPtMapping(Double_t lowPtMapping){fLowPtMapping=lowPtMapping;}
+       void SetHighPtMapping(Double_t highPtMapping){fHighPtMapping=highPtMapping;}
 
-               
-  void SetHistograms(AliGammaConversionHistograms *const histograms){fHistograms=histograms;}
-  void SetTriggerCINT1B(Bool_t flag){fTriggerCINT1B=flag;}
-  void SetDoMCTruth(Bool_t flag){fDoMCTruth=flag;}
-  void SetDoNeutralMeson(Bool_t flag){fDoNeutralMeson=flag;}
-  void SetDoOmegaMeson(Bool_t flag){fDoOmegaMeson=flag;}
-  void SetDoNeutralMesonV0MCCheck(Bool_t flag){fDoNeutralMesonV0MCCheck=flag;}
-  void SetDoJet(Bool_t flag){fDoJet=flag;}
-  void SetDoChic(Bool_t flag){fDoChic=flag;}
-  void SetRecalculateV0ForGamma(Bool_t flag){fRecalculateV0ForGamma=flag;}             
+                       
+       void SetHistograms(AliGammaConversionHistograms *const histograms){fHistograms=histograms;}
+       void SetTriggerCINT1B(Bool_t flag){fTriggerCINT1B=flag;}
+       void SetDoMCTruth(Bool_t flag){fDoMCTruth=flag;}
+       void SetDoNeutralMeson(Bool_t flag){fDoNeutralMeson=flag;}
+       void SetDoOmegaMeson(Bool_t flag){fDoOmegaMeson=flag;}
+       void SetDoNeutralMesonV0MCCheck(Bool_t flag){fDoNeutralMesonV0MCCheck=flag;}
+       void SetDoJet(Bool_t flag){fDoJet=flag;}
+       void SetDoChic(Bool_t flag){fDoChic=flag;}
+       void SetDoHadInt(Bool_t flag){fDoHadInt=flag;}
+       void SetRecalculateV0ForGamma(Bool_t flag){fRecalculateV0ForGamma=flag;}                
 
-  void SetElectronMass(Double_t electronMass){fElectronMass = electronMass;}
-  void SetGammaMass(Double_t gammaMass){fGammaMass = gammaMass;}
-  void SetGammaWidth(Double_t gammaWidth){fGammaWidth = gammaWidth;}
-  void SetPi0Mass(Double_t pi0Mass){fPi0Mass = pi0Mass;}
-  void SetPi0Width(Double_t pi0Width){fPi0Width = pi0Width;}
-  void SetEtaMass(Double_t etaMass){fEtaMass = etaMass;}
-  void SetEtaWidth(Double_t etaWidth){fEtaWidth = etaWidth;}
-  void SetMinOpeningAngleGhostCut(Double_t ghostCut){fMinOpeningAngleGhostCut = ghostCut;}
-  void SetV0Reader(AliV0Reader* const reader){fV0Reader=reader; fV0Reader->SetESDtrackCuts(fEsdTrackCuts);}
-  void SetCalculateBackground(Bool_t bg){fCalculateBackground=bg;}
-  void CalculateBackground();
-  void SetWriteNtuple(Bool_t writeNtuple){fWriteNtuple = writeNtuple;}
-  void FillNtuple();
-  Double_t GetMCOpeningAngle(const TParticle* const daughter0,const TParticle* const daughter1) const;
-  void CheckV0Efficiency();
-  void SetDeltaAODFileName(TString fn) { fKFDeltaAODFileName = fn; };
-  void SetCreateAOD(Bool_t doAod) { fKFCreateAOD = doAod; };
-  TString GetDeltaAODFileName() const { return fKFDeltaAODFileName; };
-  //////////////////Chi_c Analysis////////////////////////////
-  void GetPID(const AliESDtrack *track, Stat_t &pid, Stat_t &weight);  
-  double GetSigmaToVertex(const AliESDtrack* t);
-  void ElectronBackground(TString hBg, TClonesArray e);
-  void FillAngle(TString histoName,TClonesArray const tlVeNeg, TClonesArray const tlVePos);
-  void FillElectronInvMass(TString histoName, TClonesArray const negativeElectron, TClonesArray const positiveElectron);
-  void FillGammaElectronInvMass(TString histoMass,TString histoDiff, TClonesArray const fKFGammas, TClonesArray const tlVeNeg,TClonesArray const tlVePos);
-  void CleanWithAngleCuts(TClonesArray const negativeElectrons, TClonesArray const positiveElectrons, TClonesArray const gammas);
-  TClonesArray GetTLorentzVector(TClonesArray* esdTrack);      
-  void ProcessGammaElectronsForChicAnalysis();
-  ///////////////////////////////////////////////////////////////
+       void SetElectronMass(Double_t electronMass){fElectronMass = electronMass;}
+       void SetGammaMass(Double_t gammaMass){fGammaMass = gammaMass;}
+       void SetGammaWidth(Double_t gammaWidth){fGammaWidth = gammaWidth;}
+       void SetPi0Mass(Double_t pi0Mass){fPi0Mass = pi0Mass;}
+       void SetPi0Width(Double_t pi0Width){fPi0Width = pi0Width;}
+       void SetEtaMass(Double_t etaMass){fEtaMass = etaMass;}
+       void SetEtaWidth(Double_t etaWidth){fEtaWidth = etaWidth;}
+       void SetMinOpeningAngleGhostCut(Double_t ghostCut){fMinOpeningAngleGhostCut = ghostCut;}
+       void SetV0Reader(AliV0Reader* const reader){fV0Reader=reader; fV0Reader->SetESDtrackCuts(fEsdTrackCuts);}
+       void SetCalculateBackground(Bool_t bg){fCalculateBackground=bg;}
+       void CalculateBackground();
+       void SetWriteNtuple(Bool_t writeNtuple){fWriteNtuple = writeNtuple;}
+       void FillNtuple();
+       Double_t GetMCOpeningAngle(const TParticle* const daughter0,const TParticle* const daughter1) const;
+       void CheckV0Efficiency();
+       void SetDeltaAODFileName(TString fn) { fKFDeltaAODFileName = fn; };
+    void SetCreateAOD(Bool_t doAod) { fKFCreateAOD = doAod; };
+    void SetExchangeAOD(Bool_t xchAOD) { fKFExchangeAOD = xchAOD; };
+       TString GetDeltaAODFileName() const { return fKFDeltaAODFileName; };
+       //////////////////Chi_c Analysis////////////////////////////
+       void GetPID(const AliESDtrack *track, Stat_t &pid, Stat_t &weight);     
+       double GetSigmaToVertex(const AliESDtrack* t);
+       void ElectronBackground(TString hBg, TClonesArray e);
+       void FillAngle(TString histoName,TClonesArray const tlVeNeg, TClonesArray const tlVePos);
+       void FillElectronInvMass(TString histoName, TClonesArray const negativeElectron, TClonesArray const positiveElectron);
+       void FillGammaElectronInvMass(TString histoMass,TString histoDiff, TClonesArray const fKFGammas, TClonesArray const tlVeNeg,TClonesArray const tlVePos);
+       void CleanWithAngleCuts(TClonesArray const negativeElectrons, TClonesArray const positiveElectrons, TClonesArray const gammas);
+       TClonesArray GetTLorentzVector(TClonesArray* esdTrack); 
+       void ProcessGammaElectronsForChicAnalysis();
+       void ProcessHadronicInteraction(AliESDEvent *event);
+       Bool_t CheckLooper(Int_t index, AliESDEvent *event);
+       Bool_t CheckV0(Int_t index, AliESDEvent *event);
+       ///////////////////////////////////////////////////////////////
 
-  void SetDoCF(Bool_t flag){fDoCF = flag;}
+       void SetDoCF(Bool_t flag){fDoCF = flag;}
 
-  void SetUseChargedTracksMultiplicityForBG(Bool_t flag){fUseTrackMultiplicityForBG = flag;}           
+       void SetUseChargedTracksMultiplicityForBG(Bool_t flag){fUseTrackMultiplicityForBG = flag;}              
 
-  void SetMoveParticleAccordingToVertex(Bool_t flag){fMoveParticleAccordingToVertex = flag;}
+       void SetMoveParticleAccordingToVertex(Bool_t flag){fMoveParticleAccordingToVertex = flag;}
 
-  void MoveParticleAccordingToVertex(AliKFParticle * particle,const AliGammaConversionBGHandler::GammaConversionVertex *vertex);
+       void MoveParticleAccordingToVertex(AliKFParticle * particle,const AliGammaConversionBGHandler::GammaConversionVertex *vertex);
 
-  void SetApplyChi2Cut(Bool_t flag){fApplyChi2Cut = flag;}
+       void SetApplyChi2Cut(Bool_t flag){fApplyChi2Cut = flag;}
 
-  void SetDoRotation(Bool_t flag){fDoRotation = flag;}
+       void SetDoRotation(Bool_t flag){fDoRotation = flag;}
 
-  void SetPMDegreesBG(Int_t deg){fNDegreesPMBackground=deg;}
+       void SetPMDegreesBG(Int_t deg){fNDegreesPMBackground=deg;}
 
-  void SetNumberOfRotationsBG(Int_t nRot){fNRandomEventsForBG=nRot;}
+       void SetNumberOfRotationsBG(Int_t nRot){fNRandomEventsForBG=nRot;}
 
-  void RotateKFParticle(AliKFParticle * kfParticle,Double_t angle);
+       void RotateKFParticle(AliKFParticle * kfParticle,Double_t angle);
 
-  void SetCheckBGProbability(Bool_t flag){fCheckBGProbability = flag;}
+       void SetCheckBGProbability(Bool_t flag){fCheckBGProbability = flag;}
 
-  void SetRemovePileUp(Bool_t removePileUp) { fRemovePileUp = removePileUp; }
+       void SetRemovePileUp(Bool_t removePileUp) { fRemovePileUp = removePileUp; }
 
-  void SetSelectV0AND(Bool_t selectV0AND) { fSelectV0AND = selectV0AND; }
-  void SetUseMultiplicity(Int_t useMultiplicity) {fUseMultiplicity=useMultiplicity;}
-  void SetUseMultiplicityBin(Int_t useMultiplicityBin) {fUseMultiplicityBin=useMultiplicityBin;}
-  void SetUseHBTMultiplicity(Int_t useHBTMultiplicity) {fUseHBTMultiplicity=useHBTMultiplicity;}
-  void SetUseHBTMultiplicityBin(Int_t useHBTMultiplicityBin) {fUseHBTMultiplicityBin=useHBTMultiplicityBin;}
+       void SetSelectV0AND(Bool_t selectV0AND) { fSelectV0AND = selectV0AND; }
+       void SetUseMultiplicity(Int_t useMultiplicity) {fUseMultiplicity=useMultiplicity;}
+       void SetUseMultiplicityBin(Int_t useMultiplicityBin) {fUseMultiplicityBin=useMultiplicityBin;}
+       void SetUseHBTMultiplicity(Int_t useHBTMultiplicity) {fUseHBTMultiplicity=useHBTMultiplicity;}
+       void SetUseHBTMultiplicityBin(Int_t useHBTMultiplicityBin) {fUseHBTMultiplicityBin=useHBTMultiplicityBin;}
 
-  Int_t CalculateMultiplicityBin();
-  void SetUseCentrality(Int_t useCentrality) {fUseCentrality=useCentrality;}
-  void SetUseCentralityBin(Int_t useCentralityBin) {fUseCentralityBin=useCentralityBin;}
+       Int_t CalculateMultiplicityBin();
+       void SetUseCentrality(Int_t useCentrality) {fUseCentrality=useCentrality;}
+       void SetUseCentralityBin(Int_t useCentralityBin) {fUseCentralityBin=useCentralityBin;}
 
+       void SetMaxChi2HadIntCut(Float_t chi2HadInt){fMaxChi2HadInt = chi2HadInt; }
+       void SetMaxErr2DHadIntCut(Float_t err2DHadInt){fMaxErr2DHadInt =err2DHadInt ;}
+       void SetMinPtHadIntCut(Float_t ptMinHadInt){fPtMinHadInt =ptMinHadInt ;}
+       
 
 
 
  private:
-  AliAnalysisTaskGammaConversion(const AliAnalysisTaskGammaConversion&); // Not implemented
-  AliAnalysisTaskGammaConversion& operator=(const AliAnalysisTaskGammaConversion&); // Not implemented
+       AliAnalysisTaskGammaConversion(const AliAnalysisTaskGammaConversion&); // Not implemented
+       AliAnalysisTaskGammaConversion& operator=(const AliAnalysisTaskGammaConversion&); // Not implemented
   
-               
+       TTreeSRedirector *fpcstream;
+                               
   // for CF
 enum{
-    kStepGenerated = 0,
-    kStepReconstructable = 1, 
-    kStepGetOnFly = 2,
-    kStepLikeSign = 3,
-    kStepTPCRefit = 4,
-    kStepKinks = 5,
-    kStepdEdxElectronSelection = 6,
-    kStepdEdxPpionRejection = 7,
-    kStepNContributors = 8,
-    kStepTPCPID = 9,
-    kStepR = 10,
-    kStepLine = 11,
-    kStepZ = 12,
-    kStepMinClsTPC = 13,
-    kStepSinglePt = 14,
-    kStepNDF = 15,
-    kStepChi2 = 16,
-    kStepEta = 17,
-    kStepPt = 18,
-    kStepTrueGamma = 19
-  };
-  
-  AliV0Reader* fV0Reader; // The V0 reader object 
-               
-  AliStack * fStack; // pointer to the MC particle stack
-  AliMCEventHandler *fMCTruth; // for CF   pointer to MCTruth
-  AliMCEvent *fGCMCEvent;  // for CF    pointer to the MC Event
-  AliESDEvent* fESDEvent; //pointer to the ESDEvent
-  TList * fOutputContainer; // Histogram container
-  AliCFManager *fCFManager;  // for CF
-  //  AliCFContainer *container;   // for CF
+ enum{
+               kStepGenerated = 0,
+               kStepReconstructable = 1, 
+               kStepGetOnFly = 2,
+               kStepLikeSign = 3,
+               kStepTPCRefit = 4,
+               kStepKinks = 5,
+               kStepdEdxElectronSelection = 6,
+               kStepdEdxPpionRejection = 7,
+               kStepNContributors = 8,
+               kStepTPCPID = 9,
+               kStepR = 10,
+               kStepLine = 11,
+               kStepZ = 12,
+               kStepMinClsTPC = 13,
+               kStepSinglePt = 14,
+               kStepNDF = 15,
+               kStepChi2 = 16,
+               kStepEta = 17,
+               kStepPt = 18,
+               kStepTrueGamma = 19
+       };
+       
+       AliV0Reader* fV0Reader; // The V0 reader object 
+                       
+       AliStack * fStack; // pointer to the MC particle stack
+       AliMCEventHandler *fMCTruth; // for CF   pointer to MCTruth
+       AliMCEvent *fGCMCEvent;  // for CF    pointer to the MC Event
+       AliESDEvent* fESDEvent; //pointer to the ESDEvent
+       TList * fOutputContainer; // Histogram container
+       AliCFManager *fCFManager;  // for CF
+       //  AliCFContainer *container;   // for CF
 
+                       
+                       
+       AliGammaConversionHistograms *fHistograms; // Pointer to the histogram handling class
+       Bool_t fTriggerCINT1B; //Flag to select trigger CINT1B
+       Bool_t fDoMCTruth; // Flag to switch on/off MC truth 
+       Bool_t fDoNeutralMeson; // flag
+       Bool_t fDoOmegaMeson; // flag
+       Bool_t fDoJet; // flag
+       Bool_t fDoChic; // flag
+       Bool_t fDoHadInt; // flag
                
-               
-  AliGammaConversionHistograms *fHistograms; // Pointer to the histogram handling class
-  Bool_t fTriggerCINT1B; //Flag to select trigger CINT1B
-  Bool_t fDoMCTruth; // Flag to switch on/off MC truth 
-  Bool_t fDoNeutralMeson; // flag
-  Bool_t fDoOmegaMeson; // flag
-  Bool_t fDoJet; // flag
-  Bool_t fDoChic; // flag
-  Bool_t fRecalculateV0ForGamma;//flag
-               
-  TClonesArray * fKFReconstructedGammasTClone; //! transient
-  TClonesArray * fKFReconstructedPi0sTClone; //! transient
-  TClonesArray * fKFRecalculatedGammasTClone; //! transient
-  TClonesArray * fCurrentEventPosElectronTClone; //! transient
-  TClonesArray * fCurrentEventNegElectronTClone; //! transient
-  TClonesArray * fKFReconstructedGammasCutTClone; //! transient
-  TClonesArray * fPreviousEventTLVNegElectronTClone; //! transient
-  TClonesArray * fPreviousEventTLVPosElectronTClone; //! transient
-               
-  //  vector<AliKFParticle> fKFReconstructedGammas; // vector containing all reconstructed gammas
-               
-  //  AliESDpid * fESDpid; // esd pid
+       Bool_t fRecalculateV0ForGamma;//flag
+                       
+       TClonesArray * fKFReconstructedGammasTClone; //! transient
+       TClonesArray * fKFReconstructedPi0sTClone; //! transient
+       TClonesArray * fKFRecalculatedGammasTClone; //! transient
+       TClonesArray * fCurrentEventPosElectronTClone; //! transient
+       TClonesArray * fCurrentEventNegElectronTClone; //! transient
+       TClonesArray * fKFReconstructedGammasCutTClone; //! transient
+       TClonesArray * fPreviousEventTLVNegElectronTClone; //! transient
+       TClonesArray * fPreviousEventTLVPosElectronTClone; //! transient
+                       
+       //  vector<AliKFParticle> fKFReconstructedGammas; // vector containing all reconstructed gammas
+                       
+       //  AliESDpid * fESDpid; // esd pid
 
 
-  ///////Chi_c Analysis///////////////////////////
-  //  vector<AliESDtrack*> fCurrentEventPosElectron;       // comment here
-  //  vector<AliESDtrack*> fCurrentEventNegElectron;       // comment here
-  //  vector<AliKFParticle> fKFReconstructedGammasCut;     // comment here
-  //  vector<TLorentzVector> fPreviousEventTLVNegElectron; // comment here
-  //  vector<TLorentzVector> fPreviousEventTLVPosElectron; // comment here
-  //////////////////////////////////////////////////   
-               
-  //mass defines
-  Double_t fElectronMass; //electron mass
-  Double_t fGammaMass;    //gamma mass
-  Double_t fPi0Mass;      //pi0mass
-  Double_t fEtaMass;      //eta mass
-               
-  // width defines
-  Double_t fGammaWidth; //gamma width cut
-  Double_t fPi0Width;   // pi0 width cut
-  Double_t fEtaWidth;   // eta width cut
-               
-  Double_t fMinOpeningAngleGhostCut; // minimum angle cut
-               
-  AliESDtrackCuts* fEsdTrackCuts;           // Object containing the parameters of the esd track cuts
-               
-  Bool_t fCalculateBackground; //flag to set backgrount calculation on/off
-  Bool_t fWriteNtuple;         // flag to set if writing to ntuple on/off
-  TNtuple *fGammaNtuple;       // Ntuple for gamma values
-  TNtuple *fNeutralMesonNtuple;// NTuple for mesons
-               
-  Int_t fTotalNumberOfAddedNtupleEntries; // number of added ntuple entries
-               
-  TClonesArray* fChargedParticles;  //! transient
-  vector<Int_t> fChargedParticlesId;  //! transient
-               
-  Double_t fGammaPtHighest;  //! transient
-  Double_t fMinPtForGammaJet;  //! transient
-  Double_t fMinIsoConeSize; //! transient
-  Double_t fMinPtIsoCone; //! transient
-  Double_t fMinPtGamChargedCorr; //! transient
-  Double_t fMinPtJetCone; //! transient
-  Int_t    fLeadingChargedIndex; //! transient
-  Double_t fLowPtMapping; //! transient
-  Double_t fHighPtMapping; //! transient
-  Bool_t fDoCF; //! transient
-               
-  TClonesArray * fAODGamma; //TClonesArray for gammas to put in AOD
-  //TClonesArray * fAODPi0; //TTClonesArray for Pi0s to put in AOD
-  //TClonesArray * fAODOmega; //TTClonesArray for omegas to put in AOD
-  TString fAODBranchName; // New AOD branch name
-  Bool_t fKFCreateAOD; //Create the AOD tclones? (regardless if storing or not)
-  
-  Bool_t fKFForceAOD;  //Set the Analysis Manager FillAOD variable to true every event
-  TString fKFDeltaAODFileName; //! File name for delta AOD (if any)
-  Bool_t fDoNeutralMesonV0MCCheck; //flag
-  Bool_t fUseTrackMultiplicityForBG; //flag
-  Bool_t fMoveParticleAccordingToVertex; //flag
-  Bool_t fApplyChi2Cut; //flag
-  Int_t fNRandomEventsForBG; //number of random events to use in rotation method
-  Int_t fNDegreesPMBackground; // number of degree window to rotate particles for rotation method
-  Bool_t fDoRotation; //flag
-  Bool_t fCheckBGProbability; //flag
-//  vector<Int_t>fKFReconstructedGammasV0Index; // index of the reconstructed v0s
-  Bool_t fRemovePileUp;                 // Remove Pile Up
-  Bool_t fSelectV0AND;                 // Select V0AND
-  AliTriggerAnalysis *fTriggerAnalysis; //! Trigger Analysis for Normalisation
-  Int_t fMultiplicity;
-  Int_t fUseMultiplicity;
-  Int_t fUseMultiplicityBin;
-  Int_t fUseHBTMultiplicity;
-  Int_t fUseHBTMultiplicityBin;
-  Int_t fUseCentrality;
-  Int_t fUseCentralityBin;
-  TRandom3 fRandom;
-  ClassDef(AliAnalysisTaskGammaConversion, 20); // Analysis task for gamma conversions
+       ///////Chi_c Analysis///////////////////////////
+       //  vector<AliESDtrack*> fCurrentEventPosElectron;       // comment here
+       //  vector<AliESDtrack*> fCurrentEventNegElectron;       // comment here
+       //  vector<AliKFParticle> fKFReconstructedGammasCut;     // comment here
+       //  vector<TLorentzVector> fPreviousEventTLVNegElectron; // comment here
+       //  vector<TLorentzVector> fPreviousEventTLVPosElectron; // comment here
+       //////////////////////////////////////////////////      
+                       
+       //mass defines
+       Double_t fElectronMass; //electron mass
+       Double_t fGammaMass;    //gamma mass
+       Double_t fPi0Mass;      //pi0mass
+       Double_t fEtaMass;      //eta mass
+                       
+       // width defines
+       Double_t fGammaWidth; //gamma width cut
+       Double_t fPi0Width;   // pi0 width cut
+       Double_t fEtaWidth;   // eta width cut
+                       
+       Double_t fMinOpeningAngleGhostCut; // minimum angle cut
+                       
+       AliESDtrackCuts* fEsdTrackCuts;           // Object containing the parameters of the esd track cuts
+                       
+       Bool_t fCalculateBackground; //flag to set backgrount calculation on/off
+       Bool_t fWriteNtuple;         // flag to set if writing to ntuple on/off
+       TNtuple *fGammaNtuple;       // Ntuple for gamma values
+       TNtuple *fNeutralMesonNtuple;// NTuple for mesons
+                       
+       Int_t fTotalNumberOfAddedNtupleEntries; // number of added ntuple entries
+                       
+       TClonesArray* fChargedParticles;  //! transient
+       vector<Int_t> fChargedParticlesId;  //! transient
+                       
+       Double_t fGammaPtHighest;  //! transient
+       Double_t fMinPtForGammaJet;  //! transient
+       Double_t fMinIsoConeSize; //! transient
+       Double_t fMinPtIsoCone; //! transient
+       Double_t fMinPtGamChargedCorr; //! transient
+       Double_t fMinPtJetCone; //! transient
+       Int_t    fLeadingChargedIndex; //! transient
+       Double_t fLowPtMapping; //! transient
+       Double_t fHighPtMapping; //! transient
+       Bool_t fDoCF; //! transient
+                       
+       TClonesArray * fAODGamma; //TClonesArray for gammas to put in AOD
+       //TClonesArray * fAODPi0; //TTClonesArray for Pi0s to put in AOD
+       //TClonesArray * fAODOmega; //TTClonesArray for omegas to put in AOD
+       TString fAODBranchName; // New AOD branch name
+       Bool_t fKFCreateAOD; //Create the AOD tclones? (regardless if storing or not)
+       Bool_t fKFExchangeAOD; //Create the AOD tclones? (regardless if storing or not)
+       Bool_t fKFForceAOD;  //Set the Analysis Manager FillAOD variable to true every event
+       TString fKFDeltaAODFileName; //! File name for delta AOD (if any)
+       Bool_t fDoNeutralMesonV0MCCheck; //flag
+       Bool_t fUseTrackMultiplicityForBG; //flag
+       Bool_t fMoveParticleAccordingToVertex; //flag
+       Bool_t fApplyChi2Cut; //flag
+       Int_t fNRandomEventsForBG; //number of random events to use in rotation method
+       Int_t fNDegreesPMBackground; // number of degree window to rotate particles for rotation method
+       Bool_t fDoRotation; //flag
+       Bool_t fCheckBGProbability; //flag
+       //  vector<Int_t>fKFReconstructedGammasV0Index; // index of the reconstructed v0s
+       Bool_t fRemovePileUp;                 // Remove Pile Up
+       Bool_t fSelectV0AND;                 // Select V0AND
+       AliTriggerAnalysis *fTriggerAnalysis; //! Trigger Analysis for Normalisation
+       Int_t fMultiplicity;
+       Int_t fUseMultiplicity;
+       Int_t fUseMultiplicityBin;
+       Int_t fUseHBTMultiplicity;
+       Int_t fUseHBTMultiplicityBin;
+       Int_t fUseCentrality;
+       Int_t fUseCentralityBin;
+       TRandom3 fRandom;
+       Float_t fMaxChi2HadInt;         
+       Float_t fMaxErr2DHadInt;                
+       Float_t fPtMinHadInt;
+
+       ClassDef(AliAnalysisTaskGammaConversion, 22); // Analysis task for gamma conversions
 };
 
 #endif //ALIANALYSISTASKGAMMA_H
diff --git a/PWG4/GammaConv/AliAnalysisTaskdPhi.cxx b/PWG4/GammaConv/AliAnalysisTaskdPhi.cxx
new file mode 100644 (file)
index 0000000..eda48bb
--- /dev/null
@@ -0,0 +1,601 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                                                                                       *
+ * Authors: Svein Lindal                                                  *
+ * Version 1.0                                                                   *
+ *                                                                                                                                       *
+ *                                                                                                                                       *
+ * Permission to use, copy, modify and distribute this software and its          *
+ * documentation strictly for non-commercial purposes is hereby granted          *
+ * without fee, provided that the above copyright notice appears in all          *
+ * copies and that both the copyright notice and this permission notice          *
+ * appear in the supporting documentation. The authors make no claims    *
+ * about the suitability of this software for any purpose. It is                 *
+ * provided "as is" without express or implied warranty.                                 *
+ **************************************************************************/
+
+////////////////////////////////////////////////
+//--------------------------------------------- 
+// Class doing conversion gamma dPhi correlations
+// Gamma Conversion analysis
+//---------------------------------------------
+////////////////////////////////////////////////
+
+#include "AliAnalysisTaskdPhi.h"
+
+#include <TH2I.h>
+#include <TList.h>
+#include <TChain.h>
+
+#include <AliAnalysisManager.h>
+#include <AliInputEventHandler.h>
+#include <AliESDInputHandler.h>
+#include <AliAODInputHandler.h>
+#include <AliAnalysisFilter.h>
+
+#include "AliConversionCuts.h"
+#include "AliAODConversionPhoton.h"
+#include "AliAODConversionMother.h"
+#include "AliAnaConvCorrPhoton.h"
+#include "AliAnaConvCorrPion.h"
+#include "AliAnaConvIsolation.h"
+// Author Svein Lindal <slindal@fys.uio.no>
+using namespace std;
+
+ClassImp(AliAnalysisTaskdPhi)
+
+
+//________________________________________________________________________
+AliAnalysisTaskdPhi::AliAnalysisTaskdPhi(const char *name) : AliAnalysisTaskSE(name),
+  fHistograms(NULL),
+  fHistoGamma(NULL),
+  fHistoPion(NULL),
+  fDielV0TrackFilter(NULL), 
+  fDielV0Filter(NULL),
+  fDielPi0Filter(NULL),
+  fDielTrackFilter(NULL),
+  fV0Filter(NULL),
+  fGammas(NULL),
+  fPions(NULL),
+  hMETracks(NULL), 
+  hMEPhotons(NULL), 
+  hMEPions(NULL),
+  hMEvents(NULL),
+  fPhotonCorr(NULL),
+  fPionCorr(NULL), 
+  fIsoAna(NULL),
+  fL1(-1),
+  fL2(-1),
+  fDeltaAODBranchName("AliAODGammaConversion_gamma"), 
+  fAxisPt(),
+  fAxisEta(),
+  fAxisPhi(),
+  fAxisCent(),
+  fAxisZ(), 
+  fAxisPiM()
+{
+  //constructor
+
+
+  fAxisPt.SetNameTitle("PtAxis", "Pt");
+  fAxisPt.Set(20, 0, 100);
+  fAxisEta.SetNameTitle("EtaAxis", "Eta");
+  fAxisEta.Set(160, -0.8, 0.8);
+  fAxisPhi.SetNameTitle("PhiAxis", "Phi");
+  fAxisPhi.Set(128, 0, TMath::TwoPi());
+  fAxisZ.SetNameTitle("ZAxis", "Z");
+  fAxisZ.Set(4, -10, 10);
+  fAxisCent.SetNameTitle("CentAxis", "Cent");
+
+  Double_t centbins[5] = {0, 10, 30, 60, 100.1};
+  fAxisCent.Set(4, centbins);
+
+
+  Double_t mbins[7] = {0.1, 0.11, 0.12, 0.15, 0.16, 0.18, 0.2};
+  fAxisPiM.SetNameTitle("InvMassPi0", "Invariant mass");
+  fAxisPiM.Set(6, mbins);
+
+  fGammas = new TObjArray();
+  fGammas->SetOwner(kFALSE);
+
+  fPions = new TObjArray();
+  fPions->SetOwner(kFALSE);
+  
+  // Define input and output slots here
+  DefineInput(0, TChain::Class());
+  DefineInput(1, TClonesArray::Class());
+  DefineOutput(1, TList::Class());
+  DefineOutput(2, TList::Class());
+  DefineOutput(3, TList::Class());
+}
+
+
+
+//________________________________________________________________________
+AliAnalysisTaskdPhi::~AliAnalysisTaskdPhi(){
+  //destructor
+  if(fPions)
+       delete fPions;
+  fPions = NULL;
+
+  if(fGammas)
+       delete fGammas;
+  fGammas = NULL;
+  
+  if(fIsoAna)
+       delete fIsoAna;
+  fIsoAna = NULL;
+
+  if(fV0Filter)
+       delete fV0Filter;
+  fV0Filter = NULL;
+
+  if(fHistograms)
+       delete fHistograms;
+  fHistograms = NULL;
+
+if(fHistoPion)
+       delete fHistoPion;
+  fHistoPion = NULL;
+
+  if(fHistoGamma)
+       delete fHistoGamma;
+  fHistoGamma = NULL;
+
+}
+
+///________________________________________________________________________
+void AliAnalysisTaskdPhi::SetUpCorrObjects() {
+  ///Creat corr obj
+  fIsoAna = new AliAnaConvIsolation();
+
+
+  fPhotonCorr = new TObjArray();
+  fPionCorr = new TObjArray();
+  
+  TList * hPhoton = new TList();
+  hPhoton->SetName("hPhotonCorr");
+  hPhoton->SetOwner(kTRUE);
+  fHistoGamma->Add(hPhoton);
+
+  TList * hPion = new TList();
+  hPion->SetName("hPionCorr");
+  hPion->SetOwner(kTRUE);
+  fHistoPion->Add(hPion);
+
+
+  for(Int_t iz = 0; iz < fAxisZ.GetNbins(); iz++) {
+       TObjArray * photonArray = new TObjArray();
+       photonArray->SetOwner(kTRUE);
+       fPhotonCorr->AddAt(photonArray, iz);
+
+       TObjArray * pionArray = new TObjArray();
+       pionArray->SetOwner(kTRUE);
+       fPionCorr->AddAt(pionArray, iz);
+
+       TList * photonList = new TList();
+       photonList->SetName(Form("photon_%d", iz));
+       photonList->SetOwner(kTRUE);
+       hPhoton->AddAt(photonList, iz);
+
+       TList * pionList = new TList();
+       pionList->SetName(Form("pion_%d", iz));
+       pionList->SetOwner(kTRUE);
+       hPion->AddAt(pionList, iz);
+       
+       for(Int_t ic = 0; ic < fAxisCent.GetNbins(); ic++) {
+         
+         TString nameString = Form("%d_%d", iz, ic);
+         TString titleString = Form("%f < Z < %f ... %f cent %f", 
+                                                                fAxisZ.GetBinLowEdge(iz+1), fAxisZ.GetBinUpEdge(iz+1), 
+                                                                fAxisCent.GetBinLowEdge(ic+1), fAxisCent.GetBinUpEdge(ic+1));
+
+
+
+         AliAnaConvCorrPhoton * photonCorr = new AliAnaConvCorrPhoton(Form("PhotonCorr_%s", nameString.Data()), Form("photon %s", titleString.Data()));
+         photonArray->AddAt(photonCorr, ic);
+         photonCorr->GetAxistPt().Set(fAxisPt.GetNbins(), fAxisPt.GetXbins()->GetArray());
+         photonCorr->GetAxiscPt().Set(fAxisPt.GetNbins(), fAxisPt.GetXbins()->GetArray());
+         photonCorr->CreateHistograms();
+         photonList->Add(photonCorr->GetHistograms());
+
+         AliAnaConvCorrPion * pionCorr = new AliAnaConvCorrPion(Form("PionCorr_%s", nameString.Data()), Form("pion %s", titleString.Data()));
+         pionArray->AddAt(pionCorr, ic);
+         pionCorr->GetAxistPt().Set(fAxisPt.GetNbins(), fAxisPt.GetXbins()->GetArray());
+         pionCorr->GetAxiscPt().Set(fAxisPt.GetNbins(), fAxisPt.GetXbins()->GetArray());
+         pionCorr->GetAxisM().Set(fAxisPiM.GetNbins(), fAxisPiM.GetXbins()->GetArray());
+         pionCorr->CreateHistograms();
+         pionList->Add(pionCorr->GetHistograms());
+       }
+  }
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskdPhi::UserCreateOutputObjects() {
+  // Create histograms
+  
+  fHistograms = new TList();
+  fHistograms->SetName("dPhi_histograms");
+  fHistograms->SetOwner(kTRUE);
+
+  fHistoGamma = new TList();
+  fHistoGamma->SetName("Gamma_histo");
+  fHistoGamma->SetOwner(kTRUE);
+
+  fHistoPion = new TList();
+  fHistoPion->SetName("Pion_histo");
+  fHistoPion->SetOwner(kTRUE);
+
+  
+  if(fV0Filter) {
+       fV0Filter->InitCutHistograms();
+       fHistograms->Add(fV0Filter->GetCutHistograms());
+  }
+  
+
+  SetUpCorrObjects();
+
+
+  ///Set up ME histograms
+  TList * MEHistograms = new TList();
+  MEHistograms->SetName("MEHistograms");
+  MEHistograms->SetOwner(kTRUE);
+  fHistograms->Add(MEHistograms);
+
+  hMETracks = new TObjArray();
+  hMETracks->SetName("TrackArray");
+  hMETracks->SetOwner(kTRUE);
+  hMEPhotons = new TObjArray();
+  hMEPhotons->SetName("PhotonArray");
+  hMEPhotons->SetOwner(kTRUE);
+  hMEPions = new TObjArray();
+  hMEPions->SetName("PionArray");
+  hMEPions->SetOwner(kTRUE);
+
+  MEHistograms->Add(hMETracks);
+  MEHistograms->Add(hMEPions);
+  MEHistograms->Add(hMEPhotons);
+
+  hMEvents = new TH2I("hMEvents", "Nevents vs centrality vertexz",
+                                         fAxisZ.GetNbins(), fAxisZ.GetBinLowEdge(1), fAxisZ.GetBinUpEdge(fAxisZ.GetNbins()),
+                                         fAxisCent.GetNbins(), fAxisCent.GetBinLowEdge(1), fAxisCent.GetBinUpEdge(fAxisCent.GetNbins()));
+  hMEvents->GetYaxis()->Set(fAxisCent.GetNbins(), fAxisCent.GetXbins()->GetArray());
+  MEHistograms->Add(hMEvents);
+
+
+  TList axesList;
+  axesList.AddAt(&GetAxisEta(), 0);
+  axesList.AddAt(&GetAxisPhi(), 1);
+  axesList.AddAt(&GetAxisPt(), 2);
+  axesList.SetOwner(kFALSE);
+  
+  TList piAxesList;
+  piAxesList.AddAt(&GetAxisEta(), 0);
+  piAxesList.AddAt(&GetAxisPhi(), 1);
+  piAxesList.AddAt(&GetAxisPt(), 2);
+  piAxesList.AddAt(&GetAxisPiMass(), 3);
+  piAxesList.SetOwner(kFALSE);
+
+
+  TList * outAxesList = new TList();
+  outAxesList->Add(&fAxisCent);
+  outAxesList->Add(&fAxisZ);
+
+  for(Int_t iz = 0; iz < fAxisZ.GetNbins(); iz++) {
+       TObjArray * trackArray = new TObjArray();
+       trackArray->SetName(Form("METracks_%d", iz));
+       trackArray->SetOwner(kTRUE);
+       TObjArray * photonArray = new TObjArray();
+       photonArray->SetName(Form("MEPhotons_%d", iz));
+       photonArray->SetOwner(kTRUE);
+       TObjArray * pionArray = new TObjArray();
+       pionArray->SetName(Form("MEPions_%d", iz));
+       pionArray->SetOwner(kTRUE);
+
+
+       hMEPions->AddAt(pionArray, iz);
+       hMETracks->AddAt(trackArray, iz);
+       hMEPhotons->AddAt(photonArray, iz);
+
+       for(Int_t ic = 0; ic < fAxisCent.GetNbins(); ic++) {
+
+         TString nameString = Form("%d_%d", iz, ic);
+         TString titleString = Form("%f < Z < %f ... %f cent %f", 
+                                                                fAxisZ.GetBinLowEdge(iz+1), fAxisZ.GetBinUpEdge(iz+1), 
+                                                                fAxisCent.GetBinLowEdge(ic+1), fAxisCent.GetBinUpEdge(ic+1));
+
+
+         THnSparseF * trackHistogram = CreateSparse(Form("tracks_%s", nameString.Data()), 
+                                                                                                Form("tracks %s", titleString.Data()), &axesList );
+         trackArray->AddAt(trackHistogram, ic);
+
+         THnSparseF * photonHistogram = CreateSparse(Form("photons_%s", nameString.Data()), 
+                                                                                                Form("photons %s", titleString.Data()), &axesList );
+         photonArray->AddAt(photonHistogram, ic);
+
+         THnSparseF * pionHistogram = CreateSparse(Form("pions_%s", nameString.Data()), 
+                                                                                                Form("pions %s", titleString.Data()), &piAxesList );
+         pionArray->AddAt(pionHistogram, ic);
+       }
+  }
+
+  PostData(1, fHistograms);
+  PostData(2, fHistoGamma);
+  PostData(3, fHistoPion);
+
+}
+
+///________________________________________________________________________
+THnSparseF * AliAnalysisTaskdPhi::CreateSparse(TString nameString, TString titleString, TList * axesList) {
+  ///Creat sparse
+  const Int_t dim = axesList->GetSize();
+
+  TAxis * axes[dim];
+  Int_t bins[dim];
+  Double_t min[dim];
+  Double_t max[dim];
+
+  for(Int_t i = 0; i<dim; i++) {
+       TAxis * axis = dynamic_cast<TAxis*>(axesList->At(i));
+       if(axis) {
+         axes[i] = axis;
+       } else {
+         cout << "AliAnalysisTaskdPhi::CreateSparse: Error error, all the axes are not present in axis list" << endl;
+         return NULL;
+       }
+  }
+
+  for(Int_t i = 0; i<dim; i++) {
+       bins[i] = axes[i]->GetNbins(); 
+       min[i] = axes[i]->GetBinLowEdge(1);
+       max[i] = axes[i]->GetBinUpEdge(axes[i]->GetNbins());
+  }
+
+  THnSparseF * sparse = new THnSparseF(Form("METracks_%s", nameString.Data()), 
+                                                                                          Form("tracks %s", titleString.Data()), 
+                                                                                          dim, bins, min, max);
+  
+  for(Int_t i = 0; i<dim; i++) {
+       sparse->GetAxis(i)->SetNameTitle(axes[i]->GetName(), axes[i]->GetTitle() );
+       if(axes[i]->GetXbins()->GetSize() > 0) {
+         sparse->SetBinEdges(i, axes[i]->GetXbins()->GetArray() );
+       }
+  }
+
+  return sparse;
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskdPhi::UserExec(Option_t *) {
+  ///User exec. 
+
+  //if(! fV0Filter->EventIsSelected(fInputEvent)) return;
+
+
+  AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
+  Bool_t isAOD=man->GetInputEventHandler()->IsA()==AliAODInputHandler::Class();
+  
+  AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
+  if (!inputHandler) {
+       cout << "cout no input event handler"<<endl;
+       return;
+  }
+
+  
+  if ( fV0Filter && !fV0Filter->GetPIDResponse() ) {
+       if ( inputHandler->GetPIDResponse() ){
+         fV0Filter->SetPIDResponse( inputHandler->GetPIDResponse() );
+       } else {
+         
+         //AOD case
+         if (isAOD){
+               if (!fV0Filter->GetPIDResponse()){
+                 fV0Filter->InitAODpidUtil(1);
+               }
+         }
+       }
+  }
+
+  Double_t centrality = 0.0;
+  Double_t eventPlane = 0.0;
+  Double_t vertexz = fInputEvent->GetPrimaryVertex()->GetZ();
+  if(isAOD) {
+    AliAODHeader * header = static_cast<AliAODHeader*>(fInputEvent->GetHeader());
+       centrality = header->GetCentrality();
+       eventPlane = header->GetEventplane();
+  } else {
+       centrality = static_cast<AliESDEvent*>(fInputEvent)->GetCentrality()->GetCentralityPercentile("kV0M");
+       eventPlane = fInputEvent->GetEventplane()->GetEventplane("Q");
+  }
+
+  if(DebugLevel () > 15) {
+       cout << "centrality: " << centrality <<  " " << GetBin(fAxisCent, centrality) << endl;
+       cout << "vertexz: " << vertexz <<  " " << GetBin(fAxisZ, vertexz) << endl;
+       cout << "eventPlane: " << eventPlane <<  " " << endl;
+  }
+
+  const Int_t centBin = GetBin(fAxisCent, centrality);
+  const Int_t vertexBin = GetBin(fAxisZ, vertexz);
+
+  if(centBin < 0 || vertexBin < 0) {
+       AliError("bin out of range");
+       return;
+  }
+
+  fGammas->Clear();
+  fPions->Clear();
+
+  TClonesArray * aodGammas = GetConversionGammas(isAOD);
+  if(!aodGammas) {
+       AliError("no aod gammas found!");
+       return;
+  }
+
+  if(aodGammas->GetEntriesFast() > 0) {
+       if( static_cast<AliAODConversionParticle*>(aodGammas->At(0))->GetLabel(0) == fL1 && 
+               static_cast<AliAODConversionParticle*>(aodGammas->At(0))->GetLabel(1) == fL2 
+               ) {
+         return;
+       }
+       fL1 = static_cast<AliAODConversionParticle*>(aodGammas->At(0))->GetLabel(0);
+       fL2 = static_cast<AliAODConversionParticle*>(aodGammas->At(0))->GetLabel(1);
+       //cout << aodGammas->GetEntriesFast() << " " << fInputEvent->GetNumberOfTracks() << "c" << endl;
+  }
+
+  if(DebugLevel() > 1) printf("Number of conversion gammas %d \n", aodGammas->GetEntriesFast());
+  for(Int_t ig = 0; ig < aodGammas->GetEntriesFast(); ig++) {
+    AliAODConversionPhoton * photon = dynamic_cast<AliAODConversionPhoton*>(aodGammas->At(ig));
+    
+    if(!photon) continue;
+    if(!fV0Filter || fV0Filter->PhotonIsSelected(static_cast<AliConversionPhotonBase*>(photon), fInputEvent)) {
+      fGammas->Add(static_cast<TObject*>(photon));
+    }
+  }
+  
+  if(DebugLevel() > 4) printf("Number of accepted gammas %d \n", fGammas->GetEntriesFast());
+
+  THnSparseF * trackMehist = GetMEHistogram(vertexBin, centBin, hMETracks); 
+  hMEvents->Fill(vertexz, centrality);
+  
+  ///Add tracks to array
+  TObjArray tracks;
+  for(Int_t iTrack = 0; iTrack < fInputEvent->GetNumberOfTracks(); iTrack++) {
+
+       AliVTrack * track = static_cast<AliVTrack*>(fInputEvent->GetTrack(iTrack));
+       if(track->Pt() < 0.5) continue;
+       if(TMath::Abs(track->Eta()) > 0.8) continue;
+       tracks.Add(track);
+
+       Double_t hValues[3] = { track->Eta(), track->Phi(), track->Pt() };
+       if(trackMehist) trackMehist->Fill(hValues);
+  }
+  
+  Process(fGammas, &tracks, vertexBin, centBin);
+
+  PostData(1, fHistograms);
+  PostData(2, fHistoGamma);
+  PostData(3, fHistoPion);
+  
+}
+
+
+//________________________________________________________________________
+void AliAnalysisTaskdPhi::Process(TObjArray * gammas, TObjArray * tracks, Int_t vertexBin, Int_t centBin) {
+  ///Process stuff
+
+  if(DebugLevel() > 4) printf("Number of accepted tracks %d \n", tracks->GetEntriesFast());
+  THnSparseF * gHisto = GetMEHistogram(vertexBin, centBin, hMEPhotons);
+  THnSparseF * piHisto = GetMEHistogram(vertexBin, centBin, hMEPions);
+
+  AliAnaConvCorrBase * gCorr = GetCorrObject(vertexBin, centBin, fPhotonCorr);
+  AliAnaConvCorrBase * piCorr = GetCorrObject(vertexBin, centBin, fPionCorr);
+  
+  if(!gCorr || !piCorr) {
+       AliError("corr object missing");
+       return;
+  }
+
+
+
+  for(Int_t i1 = 0; i1 < gammas->GetEntriesFast(); i1++) {
+       AliAODConversionPhoton * ph1 = static_cast<AliAODConversionPhoton*>(gammas->UncheckedAt(i1));
+       Int_t tIDs[4] = {ph1->GetLabel(0), ph1->GetLabel(1), -1, -1};
+
+       // AliESDv0 * v0 = ((AliESDEvent*) (fInputEvent))->GetV0(ph1->GetV0Index());
+       // if(v0) {
+       //   cout << v0->GetNindex() << " " << v0->GetPindex() << endl;
+       //   cout << tIDs[1] << " " << tIDs[0] << endl;
+       // }
+
+       
+       Bool_t leading = fIsoAna->IsLeading(static_cast<AliAODConversionParticle*>(ph1), tracks, tIDs);
+
+       if(leading) {
+         gCorr->CorrelateWithTracks( static_cast<AliAODConversionParticle*>(ph1), tracks, tIDs, kFALSE);
+         Double_t phval[3] = {ph1->Eta(), ph1->Phi(), ph1->Pt()};
+         gHisto->Fill(phval);
+       }
+
+       for(Int_t i2 = 0; i2 < i1; i2++) {
+         AliAODConversionPhoton * ph2 = static_cast<AliAODConversionPhoton*>(gammas->UncheckedAt(i2));
+
+         if( ph2->GetTrackLabelPositive()==ph1->GetTrackLabelPositive() 
+                 || ph2->GetTrackLabelNegative()==ph1->GetTrackLabelNegative()
+                 || ph2->GetTrackLabelNegative()==ph1->GetTrackLabelPositive()
+                 || ph2->GetTrackLabelPositive()==ph1->GetTrackLabelNegative()) {
+               continue;
+         }
+
+         AliAODConversionMother * pion = new AliAODConversionMother(ph1, ph2);
+         pion->SetLabels(i1, i2);
+
+         if(!fV0Filter || fV0Filter->MesonIsSelected(pion, kTRUE) ) {
+               
+               Bool_t leadingpi = fIsoAna->IsLeading(static_cast<AliAODConversionParticle*>(pion), tracks, tIDs);
+       
+               if(leadingpi) {
+                 //piCorr->FillTriggerCounters(pion);
+
+                 Double_t pival[4] = { pion->Eta(), pion->Phi(), pion->Pt(), pion->M() };
+                 piHisto->Fill(pival);
+               
+                 if(pion->M() > fAxisPiM.GetXmin() && pion->M() < fAxisPiM.GetXmax()) {
+                       tIDs[2] = ph2->GetLabel(0);
+                       tIDs[3] = ph2->GetLabel(1);
+                       piCorr->CorrelateWithTracks(pion, tracks, tIDs, kFALSE);
+                 }
+               } 
+         }
+       }
+  }
+}
+
+
+//________________________________________________________________________
+void AliAnalysisTaskdPhi::Terminate(Option_t *) {
+  // Draw result to the screen
+  // Called once at the end of the query
+}
+
+//________________________________________________________________________
+TClonesArray * AliAnalysisTaskdPhi::GetConversionGammas(Bool_t isAOD) {
+  
+
+  if(isAOD) {
+
+       TClonesArray * gammas = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(fDeltaAODBranchName.Data()));
+       if(gammas) {
+         return gammas;
+       }
+       //If not found try to locate branch
+       FindDeltaAODBranchName(AODEvent());
+  //gammas = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(fDeltaAODBranchName.Data()));
+  //return gammas;
+       
+       gammas = dynamic_cast<TClonesArray*>(AODEvent()->FindListObject(fDeltaAODBranchName.Data()));
+       return gammas;
+
+  } else {
+       TClonesArray * gammas = dynamic_cast<TClonesArray*>(GetInputData(1));
+       return gammas;
+  }
+
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskdPhi::FindDeltaAODBranchName(AliAODEvent * event){
+  ///Find aod branch
+  TList *list=event->GetList();
+  for(Int_t ii=0;ii<list->GetEntries();ii++){
+       TString name((list->At(ii))->GetName());
+       if(name.BeginsWith("GammaConv")&&name.EndsWith("gamma")){
+         fDeltaAODBranchName=name;
+         AliInfo(Form("Set DeltaAOD BranchName to: %s",fDeltaAODBranchName.Data()));
+         return;
+       }
+  }
+}
+  
+
diff --git a/PWG4/GammaConv/AliAnalysisTaskdPhi.h b/PWG4/GammaConv/AliAnalysisTaskdPhi.h
new file mode 100644 (file)
index 0000000..4c320ad
--- /dev/null
@@ -0,0 +1,158 @@
+////////////////////////////////////////////////
+//--------------------------------------------- 
+// Class doing conversion gamma dPhi correlations
+// Gamma Conversion analysis
+//---------------------------------------------
+////////////////////////////////////////////////
+
+#ifndef AliAnalysisTaskdPhi_cxx
+#define AliAnalysisTaskdPhi_cxx
+
+#include "AliAnalysisTaskSE.h"
+
+#include <TAxis.h>
+#include <TH3I.h>
+#include <THnSparse.h>
+#include <AliAnalysisFilter.h>
+#include <iostream>
+#include <AliAnaConvCorrBase.h>
+#include <AliLog.h>
+class AliAnaConvIsolation;
+//class AliConversionPi0Filter;
+class AliConversionCuts;
+class TList;
+class TH2I;
+//class THnSparseF;
+
+using namespace std;
+
+class AliAnalysisTaskdPhi : public AliAnalysisTaskSE {
+
+public:
+  AliAnalysisTaskdPhi(const char *name);
+  virtual ~AliAnalysisTaskdPhi();
+
+  virtual void   UserCreateOutputObjects();
+  virtual void   SetUpCorrObjects();
+  virtual void   UserExec(Option_t *option);
+  virtual void   Terminate(Option_t *);
+
+  AliAnalysisFilter& GetDielV0Filter()      { return fDielV0Filter;      }
+  AliAnalysisFilter& GetDielV0TrackFilter() { return fDielV0TrackFilter; }
+  AliAnalysisFilter& GetDielTrackFilter()   { return fDielTrackFilter;   }
+  AliAnalysisFilter& GetDielPi0Filter()     { return fDielPi0Filter;     }
+
+  TAxis& GetAxisPt()   { return fAxisPt;   }
+  TAxis& GetAxisEta()  { return fAxisEta;  }
+  TAxis& GetAxisPhi()  { return fAxisPhi;  }
+  TAxis& GetAxisZ()    { return fAxisZ;    }
+  TAxis& GetAxisCent() { return fAxisCent; }
+  TAxis& GetAxisPiMass() { return fAxisPiM; }
+
+  // void SetDielV0Filter(AliAnalysisFilter * filter) { fVDielV0Filter = filter; }
+  // void SetDielPi0Filter(AliAnalysisFilter * filter) { fDielPi0Filter = filter; }
+  // void SetDielV0TrackFilter(AliAnalysisFilter * filter) { fVDielV0TrackFilter = filter; }
+  // void SetDielTrackFilter(AliAnalysisFilter * filter) { fTDielrackFilter = filter; }
+
+  void SetV0Filter(AliConversionCuts * filter) { fV0Filter = filter; }
+  //void SetPi0Filter(AliConversionPi0Filter * filter) { fPionFilter = filter; }
+  
+  
+  //enum kAxes { kVertexZ, kCentrality, kEta, kPhi, kPt };
+  
+protected:
+  
+  TClonesArray * GetConversionGammas(Bool_t isAOD);
+
+private:
+  
+  THnSparseF * CreateSparse(TString nameString, TString titleString, TList * axesList);
+  Int_t GetBin(TAxis &axis, Double_t value);
+  THnSparseF * GetMEHistogram(Int_t binz, Int_t binc, TObjArray * array);
+  AliAnaConvCorrBase * GetCorrObject(Int_t binz, Int_t binc, TObjArray * array);
+  void Process(TObjArray * gammas, TObjArray * tracks, Int_t vertexBin, Int_t centBin);
+  void FindDeltaAODBranchName(AliAODEvent * event);
+  
+  TList * fHistograms; //histograms
+  TList * fHistoGamma; //gamma histo
+  TList * fHistoPion; //pion histo
+
+  AliAnalysisFilter  fDielV0TrackFilter; //Track filter
+  AliAnalysisFilter  fDielV0Filter; //v0 filter
+  AliAnalysisFilter  fDielPi0Filter; //pion filter
+  AliAnalysisFilter  fDielTrackFilter; //track filter
+
+  AliConversionCuts * fV0Filter; //v0 filter
+  //AliConversionPi0Filter * fPionFilter;
+
+  TObjArray * fGammas; //gammas
+  TObjArray * fPions; //poins
+
+  TObjArray * hMETracks; //mixed event tracks
+  TObjArray * hMEPhotons; //photons
+  TObjArray * hMEPions; //pions
+  TH2I * hMEvents; //event histrogam
+
+  TObjArray * fPhotonCorr; //photon
+  TObjArray * fPionCorr; //poin
+  AliAnaConvIsolation * fIsoAna; //comment
+
+  Int_t fL1; //comment
+  Int_t fL2; //comment
+
+  TString fDeltaAODBranchName; //comment
+
+  TAxis fAxisPt; //comment
+  TAxis fAxisEta; //comment
+  TAxis fAxisPhi; //comment
+  TAxis fAxisCent; //comment
+  TAxis fAxisZ; //comment
+  TAxis fAxisPiM; //comment
+  
+  AliAnalysisTaskdPhi(const AliAnalysisTaskdPhi&); // not implemented
+  AliAnalysisTaskdPhi& operator=(const AliAnalysisTaskdPhi&); // not implemented
+  
+  ClassDef(AliAnalysisTaskdPhi, 2); // example of analysis
+};
+
+inline THnSparseF * AliAnalysisTaskdPhi::GetMEHistogram(Int_t binz, Int_t binc, TObjArray * array) {
+  ///Get Mixed Event histogram
+  if(binz < 0 || binz > fAxisZ.GetNbins()) {
+       cout << "error out of z axis range: " << binz << endl; 
+       return NULL;
+  }  
+  if(binc < 0 || binc >= fAxisCent.GetNbins()) {
+       cout << "error out of centraliy axis range: " << binc << endl; 
+       return NULL;
+  }  
+  
+  TObjArray * arrayc = static_cast<TObjArray*>(array->At(binz));
+  THnSparseF * histogram = static_cast<THnSparseF*>(arrayc->At(binc));
+  return histogram;
+}
+
+
+inline AliAnaConvCorrBase * AliAnalysisTaskdPhi::GetCorrObject(Int_t binz, Int_t binc, TObjArray * array) {
+  ///Get correlation object
+  if(binc < 0 || binz < 0) {
+         AliError("We have a bad bin!!!");
+         return NULL;
+       }
+
+  TObjArray * arrayc = static_cast<TObjArray*>(array->At(binz));
+  AliAnaConvCorrBase * corrmaker = static_cast<AliAnaConvCorrBase*>(arrayc->At(binc));
+  return corrmaker;
+
+}
+
+inline Int_t AliAnalysisTaskdPhi::GetBin(TAxis & axis, Double_t value) {
+  //Return bin - 1 if within range, else return -1
+  Int_t bin = axis.FindFixBin(value);
+  
+
+  bin = (bin > 0 && bin <= axis.GetNbins()) ? bin -1 : -1;
+  return bin;
+}
+
+#endif
+
diff --git a/PWG4/GammaConv/AliConversionCuts.cxx b/PWG4/GammaConv/AliConversionCuts.cxx
new file mode 100644 (file)
index 0000000..6b243f7
--- /dev/null
@@ -0,0 +1,2913 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                                                                                                                                                                                                                                             *
+ * Authors: Svein Lindal, Daniel Lohner                                                                                                *
+ * Version 1.0                                                                                                                                                                                                                                         *
+ *                                                                                                                                                                                                                                                                                             *
+ * Permission to use, copy, modify and distribute this software and its         *
+ * documentation strictly for non-commercial purposes is hereby granted         *
+ * without fee, provided that the above copyright notice appears in all         *
+ * copies and that both the copyright notice and this permission notice         *
+ * appear in the supporting documentation. The authors make no claims           *
+ * about the suitability of this software for any purpose. It is                                       *
+ * provided "as is" without express or implied warranty.                                                                       *
+ **************************************************************************/
+
+////////////////////////////////////////////////
+//--------------------------------------------- 
+// Class handling all kinds of selection cuts for
+// Gamma Conversion analysis
+//---------------------------------------------
+////////////////////////////////////////////////
+
+#include "AliConversionCuts.h"
+
+#include "AliKFVertex.h"
+#include "AliAODTrack.h"
+#include "AliESDtrack.h"
+#include "AliAnalysisManager.h"
+#include "AliInputEventHandler.h"
+#include "AliAODHandler.h"
+#include "AliPIDResponse.h"
+#include "TH1.h"
+#include "TH2.h"
+#include "AliStack.h"
+#include "AliAODConversionMother.h"
+#include "TObjString.h"
+#include "AliAODEvent.h"
+#include "AliESDEvent.h"
+#include "AliCentrality.h"
+#include "TList.h"
+class iostream;
+
+using namespace std;
+
+ClassImp(AliConversionCuts)
+
+
+const char* AliConversionCuts::fgkCutNames[AliConversionCuts::kNCuts] = {
+"GoodId",
+"V0FinderType",
+"eProbCut",
+"ededxSigmaCut",
+"pidedxSigmaCut",
+"piMomdedxSigmaCut",
+"Chi2GammaCut",
+"SinglePtCut",
+"ClsTPCCut",
+"EtaCut",
+"Chi2MesonCut",
+"LowPRejectionSigmaCut",
+"QtMaxCut",
+"piMaxMomdedxSigmaCut",
+"AlphaMesonCut",
+"MinRCut",
+"RapidityMesonCut",
+"BackgroundScheme",
+"DegreesForRotationMethod",
+"NumberOfRotations",
+"RemovePileUp",
+"SelectV0AND",
+"MultiplicityBin",
+"HeavyIon",
+"UseCentrality",
+"CentralityBin",
+"TOFelectronPID",
+"UseMCPSmearing",
+"DoPhotonAsymmetryCut",
+"PsiPair",
+"CosinePointingAngle",
+};
+
+
+//________________________________________________________________________
+AliConversionCuts::AliConversionCuts(const char *name,const char *title) : AliAnalysisCuts(name,title),
+    fHistograms(NULL),
+    fPIDResponse(NULL),
+    fMaxR(200),
+    fMinR(0),
+    fEtaCut(0.9),
+    fEtaCutMin(-0.1),
+    fPtCut(0),
+    fSinglePtCut(0),
+    fMaxZ(1000),
+    fMinClsTPC(0.),
+    fMinClsTPCToF(0.),
+    fLineCutZRSlope(0.),
+    fLineCutZValue(0),
+    fLineCutZRSlopeMin(0.),
+    fLineCutZValueMin(0),
+    fChi2CutConversion(1000),
+    fChi2CutMeson(1000),
+    fPIDProbabilityCutNegativeParticle(0),
+    fPIDProbabilityCutPositiveParticle(0),
+    fDodEdxSigmaCut(kTRUE),
+    fDoTOFsigmaCut(kFALSE), // RRnewTOF
+    fPIDTRDEfficiency(1),
+    fDoTRDPID(kFALSE),
+    fPIDnSigmaAboveElectronLine(100),
+    fPIDnSigmaBelowElectronLine(-100),
+    fTofPIDnSigmaAboveElectronLine(100), // RRnewTOF
+    fTofPIDnSigmaBelowElectronLine(-100), // RRnewTOF
+    fPIDnSigmaAbovePionLine(0),
+    fPIDnSigmaAbovePionLineHighPt(-100),
+    fPIDMinPnSigmaAbovePionLine(0),
+    fPIDMaxPnSigmaAbovePionLine(0),
+    fDoKaonRejectionLowP(kFALSE),
+    fDoProtonRejectionLowP(kFALSE),
+    fDoPionRejectionLowP(kFALSE),
+    fPIDnSigmaAtLowPAroundKaonLine(0),
+    fPIDnSigmaAtLowPAroundProtonLine(0),
+    fPIDnSigmaAtLowPAroundPionLine(0),
+    fPIDMinPKaonRejectionLowP(0),
+    fPIDMinPProtonRejectionLowP(0),
+    fPIDMinPPionRejectionLowP(0),
+    fDoQtGammaSelection(kTRUE),
+    fDoHighPtQtGammaSelection(kFALSE), // RRnew
+    fQtMax(100),
+    fHighPtQtMax(0.), // RRnew
+    fPtBorderForQt(0), // RRnew
+    fXVertexCut(0.),
+    fYVertexCut(0.),
+    fZVertexCut(0.),
+    fNSigmaMass(0.),
+    fUseEtaMinCut(kFALSE),
+    fUseOnFlyV0Finder(kTRUE),
+    fDoPhotonAsymmetryCut(kTRUE),
+    fMinPPhotonAsymmetryCut(100.),
+    fMinPhotonAsymmetry(0.),
+    fIsHeavyIon(kFALSE),
+    fMaxVertexZ(10),
+    fUseCentrality(kFALSE),
+    fUseCentralityBin(kFALSE),
+    fUseCorrectedTPCClsInfo(kFALSE),
+    fUseTOFpid(kFALSE),
+    fAlphaMinCutMeson(0),
+    fAlphaCutMeson(1),
+    fRapidityCutMeson(1),
+    fUseRotationMethodInBG(kFALSE),
+    fdoBGProbability(kFALSE),
+    fUseTrackMultiplicityForBG(kFALSE),
+    fnDegreeRotationPMForBG(0),
+    fnumberOfRotationEventsForBG(0),
+    fUseMCPSmearing(kFALSE),
+    fPBremSmearing(0),
+    fPSigSmearing(0),
+    fPSigSmearingCte(0),
+    fUseMultiplicity(kFALSE),
+    fUseMultiplicityBin(0),
+    fSelectV0AND(kFALSE),
+    fRemovePileUp(kFALSE),
+    fOpeningAngle(0.005),
+    fPsiPairCut(10000),
+    fCosPAngleCut(10000),
+    fCutString(NULL),
+    hdEdxCuts(NULL),
+    hTPCdEdxbefore(NULL),
+    hTPCdEdxafter(NULL),
+    hTrackCuts(NULL),
+    hPhotonCuts(NULL),
+    hInvMassbefore(NULL),
+    hArmenterosbefore(NULL),
+    hInvMassafter(NULL),
+    hArmenterosafter(NULL),
+    hAcceptanceCuts(NULL),
+    hCutIndex(NULL),
+    hV0EventCuts(NULL),
+    hCentrality(NULL),
+    hVertexZ(NULL),
+    hMesonCuts(NULL),
+    hMesonBGCuts(NULL)
+{
+    InitPIDResponse();
+    for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=0;}
+    fCutString=new TObjString((GetCutNumber()).Data());
+
+}
+
+//________________________________________________________________________
+AliConversionCuts::~AliConversionCuts() {
+    // Destructor
+  //Deleting fHistograms leads to seg fault it it's added to output collection of a task
+  // if(fHistograms)
+  //   delete fHistograms;
+  // fHistograms = NULL;
+}
+
+//________________________________________________________________________
+void AliConversionCuts::InitCutHistograms(){
+
+    // Initialize Cut Histograms for QA (only initialized and filled if function is called)
+
+    fHistograms=new TList();
+    fHistograms->SetName("ConversionCuts");
+    fHistograms->SetOwner(kTRUE);
+
+    // Cut Number
+    fHistograms->Add(fCutString);
+
+    // IsPhotonSelected
+
+    hCutIndex=new TH1F("IsPhotonSelected","IsPhotonSelected",10,-0.5,9.5);
+    hCutIndex->GetXaxis()->SetBinLabel(1,"in");
+    hCutIndex->GetXaxis()->SetBinLabel(2,"no tracks");
+    hCutIndex->GetXaxis()->SetBinLabel(3,"dEdx");
+    hCutIndex->GetXaxis()->SetBinLabel(4,"Track cuts");
+    hCutIndex->GetXaxis()->SetBinLabel(5,"PhotonCuts");
+    hCutIndex->GetXaxis()->SetBinLabel(6,"out");
+    fHistograms->Add(hCutIndex);
+
+    // Track Cuts
+    hTrackCuts=new TH1F("TrackCuts","TrackCuts",10,-0.5,9.5);
+    hTrackCuts->GetXaxis()->SetBinLabel(1,"in");
+    hTrackCuts->GetXaxis()->SetBinLabel(2,"likesign");
+    hTrackCuts->GetXaxis()->SetBinLabel(3,"ntpccl");
+    hTrackCuts->GetXaxis()->SetBinLabel(4,"acceptance");
+    hTrackCuts->GetXaxis()->SetBinLabel(5,"singlept");
+    hTrackCuts->GetXaxis()->SetBinLabel(6,"TPCrefit");
+    hTrackCuts->GetXaxis()->SetBinLabel(7,"kink");
+    hTrackCuts->GetXaxis()->SetBinLabel(8,"out");
+    fHistograms->Add(hTrackCuts);
+
+    // Photon Cuts
+
+    hPhotonCuts=new TH1F("PhotonCuts","PhotonCuts",12,-0.5,11.5);
+    hPhotonCuts->GetXaxis()->SetBinLabel(1,"in");
+    hPhotonCuts->GetXaxis()->SetBinLabel(2,"qtcut");
+    hPhotonCuts->GetXaxis()->SetBinLabel(3,"chi2");
+    hPhotonCuts->GetXaxis()->SetBinLabel(4,"acceptance");
+    hPhotonCuts->GetXaxis()->SetBinLabel(5,"asymmetry");
+    hPhotonCuts->GetXaxis()->SetBinLabel(6,"pidprob");
+    hPhotonCuts->GetXaxis()->SetBinLabel(7,"cortpcclinfo");
+    hPhotonCuts->GetXaxis()->SetBinLabel(8,"PsiPair");
+    hPhotonCuts->GetXaxis()->SetBinLabel(9,"CosPAngle");
+    hPhotonCuts->GetXaxis()->SetBinLabel(10,"out");
+    fHistograms->Add(hPhotonCuts);
+
+    hInvMassbefore=new TH1F("InvMass_before","InvMass_before",100,0,0.3);
+    fHistograms->Add(hInvMassbefore);
+    hArmenterosbefore=new TH2F("Armenteros_before","Armenteros_before",200,-1,1,250,0,0.25);
+    fHistograms->Add(hArmenterosbefore);
+    hInvMassafter=new TH1F("InvMass_after","InvMass_after",100,0,0.3);
+    fHistograms->Add(hInvMassafter);
+    hArmenterosafter=new TH2F("Armenteros_after","Armenteros_after",200,-1,1,250,0,0.25);
+    fHistograms->Add(hArmenterosafter);
+
+    hAcceptanceCuts=new TH1F("PhotonAcceptanceCuts","PhotonAcceptanceCuts",10,-0.5,9.5);
+    hAcceptanceCuts->GetXaxis()->SetBinLabel(1,"in");
+    hAcceptanceCuts->GetXaxis()->SetBinLabel(2,"maxR");
+    hAcceptanceCuts->GetXaxis()->SetBinLabel(3,"minR");
+    hAcceptanceCuts->GetXaxis()->SetBinLabel(4,"line");
+    hAcceptanceCuts->GetXaxis()->SetBinLabel(5,"maxZ");
+    hAcceptanceCuts->GetXaxis()->SetBinLabel(6,"eta");
+    hAcceptanceCuts->GetXaxis()->SetBinLabel(7,"minpt");
+    hAcceptanceCuts->GetXaxis()->SetBinLabel(8,"out");
+    fHistograms->Add(hAcceptanceCuts);
+
+    // dEdx Cuts
+
+    hdEdxCuts=new TH1F("dEdxCuts","dEdxCuts",10,-0.5,9.5);
+    hdEdxCuts->GetXaxis()->SetBinLabel(1,"in");
+    hdEdxCuts->GetXaxis()->SetBinLabel(2,"TPCelectron");
+    hdEdxCuts->GetXaxis()->SetBinLabel(3,"TPCpion");
+    hdEdxCuts->GetXaxis()->SetBinLabel(4,"TPCpionhighp");
+    hdEdxCuts->GetXaxis()->SetBinLabel(5,"TPCkaonlowprej");
+    hdEdxCuts->GetXaxis()->SetBinLabel(6,"TPCprotonlowprej");
+    hdEdxCuts->GetXaxis()->SetBinLabel(7,"TPCpionlowprej");
+    hdEdxCuts->GetXaxis()->SetBinLabel(8,"TOFelectron");
+    hdEdxCuts->GetXaxis()->SetBinLabel(9,"TRDelectron");
+    hdEdxCuts->GetXaxis()->SetBinLabel(10,"out");
+    
+    fHistograms->Add(hdEdxCuts);
+
+    hTPCdEdxbefore=new TH2F("Gamma_dEdx_before","dEdx Gamma before" ,100,0,25,400, 0,200);
+    fHistograms->Add(hTPCdEdxbefore);
+    hTPCdEdxafter=new TH2F("Gamma_dEdx_after","dEdx Gamma after" ,100,0,25,400, 0,200);
+    fHistograms->Add(hTPCdEdxafter);
+
+    // Event Cuts and Info
+
+    hV0EventCuts=new TH1F("ESD_EventCuts","Event Cuts",10,-0.5,9.5);
+    hV0EventCuts->GetXaxis()->SetBinLabel(1,"in");
+    hV0EventCuts->GetXaxis()->SetBinLabel(2,"VertexZ");
+    hV0EventCuts->GetXaxis()->SetBinLabel(3,"nvtxcontr");
+    hV0EventCuts->GetXaxis()->SetBinLabel(4,"centrsel");
+    hV0EventCuts->GetXaxis()->SetBinLabel(5,"out"); 
+    fHistograms->Add(hV0EventCuts);
+
+    hCentrality=new TH1F("Centrality","Centrality",100,0,100);
+    fHistograms->Add(hCentrality);
+    hVertexZ=new TH1F("VertexZ","VertexZ",1000,-50,50);
+    fHistograms->Add(hVertexZ);
+
+    // Meson Cuts
+
+    hMesonCuts=new TH1F("MesonCuts","MesonCuts",10,-0.5,9.5);
+    hMesonCuts->GetXaxis()->SetBinLabel(1,"in");
+    hMesonCuts->GetXaxis()->SetBinLabel(2,"undef rapidity");
+    hMesonCuts->GetXaxis()->SetBinLabel(3,"rapidity cut");
+    hMesonCuts->GetXaxis()->SetBinLabel(4,"opening angle");
+    hMesonCuts->GetXaxis()->SetBinLabel(5,"alpha max");
+    hMesonCuts->GetXaxis()->SetBinLabel(6,"alpha min");
+    hMesonCuts->GetXaxis()->SetBinLabel(7,"out");
+    fHistograms->Add(hMesonCuts);
+
+    hMesonBGCuts=new TH1F("MesonBGCuts","MesonBGCuts",10,-0.5,9.5);
+    hMesonBGCuts->GetXaxis()->SetBinLabel(1,"in");
+    hMesonBGCuts->GetXaxis()->SetBinLabel(2,"undef rapidity");
+    hMesonBGCuts->GetXaxis()->SetBinLabel(3,"rapidity cut");
+    hMesonBGCuts->GetXaxis()->SetBinLabel(4,"opening angle");
+    hMesonBGCuts->GetXaxis()->SetBinLabel(5,"alpha max");
+    hMesonBGCuts->GetXaxis()->SetBinLabel(6,"alpha min");
+    hMesonBGCuts->GetXaxis()->SetBinLabel(7,"out");
+    fHistograms->Add(hMesonBGCuts);
+}
+
+//________________________________________________________________________
+Bool_t AliConversionCuts::InitPIDResponse(){
+    // Set Pointer to AliPIDResponse
+
+  AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
+  if(man) { 
+       AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
+    fPIDResponse = (AliPIDResponse*)inputHandler->GetPIDResponse();
+    if(fPIDResponse)return kTRUE;
+    
+  }
+  
+  return kFALSE;
+}
+///________________________________________________________________________
+Bool_t AliConversionCuts::EventIsSelected(AliVEvent *fInputEvent){
+    // Process Event Selection
+
+    Int_t cutindex=0;
+    if(hV0EventCuts)hV0EventCuts->Fill(cutindex);
+    cutindex++;
+
+    // Z Vertex Position Cut
+    if(!VertexZCut(fInputEvent)){
+       if(hV0EventCuts)hV0EventCuts->Fill(cutindex);
+        return kFALSE;
+    }
+    cutindex++;
+
+    // Number of Contributors Cut
+    if(GetNumberOfContributorsVtx(fInputEvent)<=0) {
+       if(hV0EventCuts)hV0EventCuts->Fill(cutindex);
+       return kFALSE;
+    }
+    cutindex++;
+
+    // Centrality Selection
+    if(!IsCentralitySelected(fInputEvent)){
+       if(hV0EventCuts)hV0EventCuts->Fill(cutindex);
+       return kFALSE;
+    }
+    cutindex++;
+
+    // Fill Event Histograms
+    if(hV0EventCuts)hV0EventCuts->Fill(cutindex);
+    if(hVertexZ)hVertexZ->Fill(fInputEvent->GetPrimaryVertex()->GetZ());
+    if(hCentrality)hCentrality->Fill(GetCentrality(fInputEvent));
+
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::PhotonIsSelectedMC(TParticle *particle,AliStack *fMCStack){
+    // MonteCarlo Photon Selection
+
+    if(!fMCStack)return kFALSE;
+
+    if (particle->GetPdgCode() == 22){
+       if(TMath::Abs(particle->Eta())> fEtaCut || TMath::Abs(particle->Eta())< fEtaCutMin)     return kFALSE;
+
+       if(particle->GetMother(0) >-1 && fMCStack->Particle(particle->GetMother(0))->GetPdgCode() == 22){
+           return kFALSE; // no photon as mothers!
+       }
+
+       if(particle->GetMother(0) >= fMCStack->GetNprimary()){
+           return kFALSE; // the gamma has a mother, and it is not a primary particle
+       }
+
+       // looking for conversion (electron + positron from pairbuilding (= 5) )
+       TParticle* ePos = NULL;
+       TParticle* eNeg = NULL;
+
+       if(particle->GetNDaughters() >= 2){
+           for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){
+               TParticle *tmpDaughter = fMCStack->Particle(daughterIndex);
+               if(tmpDaughter->GetUniqueID() == 5){
+                   if(tmpDaughter->GetPdgCode() == 11){
+                       eNeg = tmpDaughter;
+                   } else if(tmpDaughter->GetPdgCode() == -11){
+                       ePos = tmpDaughter;
+                   }
+               }
+           }
+       }
+
+       if(ePos == NULL || eNeg == NULL){ // means we do not have two daughters from pair production
+           return kFALSE;
+       }
+
+       if(AcceptanceCut(particle,ePos,eNeg))return kTRUE;
+    }
+    return kFALSE;
+}
+
+//________________________________________________________________________
+Bool_t AliConversionCuts::MesonIsSelectedMC(TParticle *fMCMother,AliStack *fMCStack,Bool_t bMCDaughtersInAcceptance){
+    // Returns true for all pions within acceptance cuts for decay into 2 photons
+    // If bMCDaughtersInAcceptance is selected, it requires in addition that both daughter photons are within acceptance cuts
+
+    if(!fMCStack)return kFALSE;
+
+    if(fMCMother->GetPdgCode()==111){
+
+       // PseudoRapidity Cut
+       if(TMath::Abs(fMCMother->Eta())>fRapidityCutMeson)return kFALSE;
+
+       // Select only -> 2y decay channel
+       if(fMCMother->GetNDaughters()!=2)return kFALSE;
+
+       for(Int_t i=0;i<2;i++){
+           TParticle *MDaughter=fMCStack->Particle(fMCMother->GetDaughter(i));
+
+           // Is Daughter a Photon?
+           if(MDaughter->GetPdgCode()!=22)return kFALSE;
+            // Is Photon in Acceptance?
+           if(bMCDaughtersInAcceptance){
+               if(!PhotonIsSelectedMC(MDaughter,fMCStack)){return kFALSE;}
+           }
+       }
+       return kTRUE;
+    }
+    return kFALSE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::PhotonCuts(AliConversionPhotonBase *photon,AliVEvent *event)
+{   // Specific Photon Cuts
+
+    Int_t cutIndex = 0;
+    if(hPhotonCuts)hPhotonCuts->Fill(cutIndex);
+    cutIndex++;
+
+    // Gamma selection based on QT from Armenteros
+    if(fDoQtGammaSelection == kTRUE){
+       if(!ArmenterosQtCut(photon)){
+           if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //1
+           return kFALSE;
+       }
+    }
+    cutIndex++; //2
+
+    // Chi Cut
+    if(photon->GetChi2perNDF() > fChi2CutConversion || photon->GetChi2perNDF() <=0){
+       {
+           if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //2
+           return kFALSE;
+       }
+    }
+    cutIndex++;//3
+
+    // Reconstruction Acceptance Cuts
+    if(!AcceptanceCuts(photon)){
+       if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //3
+       return kFALSE;
+    }
+
+    cutIndex++; //4
+    // Asymmetry Cut
+    if(fDoPhotonAsymmetryCut == kTRUE){
+       if(!AsymmetryCut(photon,event)){
+           if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //4
+           return kFALSE;
+       }
+    }
+
+    //Check the pid probability
+    cutIndex++; //5
+    if(!PIDProbabilityCut(photon, event)) {
+       if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //5
+       return kFALSE;
+    }
+
+    cutIndex++; //6
+    if(!CorrectedTPCClusterCut(photon, event)) {
+       if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //6
+       return kFALSE;
+    }
+
+
+    cutIndex++; //7
+    if(!PsiPairCut(photon, event)) {
+         if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //7
+         return kFALSE;
+    }
+
+    cutIndex++; //8
+    if(!CosinePAngleCut(photon, event)) {
+         if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //8
+         return kFALSE;
+    }
+
+    cutIndex++; //9
+    if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //9
+    return kTRUE;
+
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::CorrectedTPCClusterCut(AliConversionPhotonBase *photon, AliVEvent * event)
+{   //Cut on corrected TPC Cluster Info
+
+    AliVTrack * negTrack = GetTrack(event, photon->GetTrackLabelNegative());
+    AliVTrack * posTrack = GetTrack(event, photon->GetTrackLabelPositive());
+
+    if(!negTrack||!posTrack)return kFALSE;
+
+    Double_t negclsToF=0;
+
+    if (!fUseCorrectedTPCClsInfo ){
+       if(negTrack->GetTPCNclsF()!=0){
+           negclsToF = (Double_t)negTrack->GetNcls(1)/(Double_t)negTrack->GetTPCNclsF();}// Ncluster/Nfindablecluster
+    }
+    else {
+       negclsToF = negTrack->GetTPCClusterInfo(2,0,GetFirstTPCRow(photon->GetConversionRadius()));
+    }
+
+    Double_t posclsToF = 0.;
+    if (!fUseCorrectedTPCClsInfo ){
+       if(posTrack->GetTPCNclsF()!=0   ){
+           posclsToF = (Double_t)posTrack->GetNcls(1)/(Double_t)posTrack->GetTPCNclsF();
+       }
+    }else{
+       posclsToF = posTrack->GetTPCClusterInfo(2,0,GetFirstTPCRow(photon->GetConversionRadius()));
+    }
+
+    if( negclsToF < fMinClsTPCToF ||   posclsToF < fMinClsTPCToF ){
+    return kFALSE;
+    }
+
+    return kTRUE;
+}
+
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::PhotonIsSelected(AliConversionPhotonBase *photon, AliVEvent * event,Bool_t DoOnlyPhotonCuts) {
+    //Selection of Reconstructed Photons
+
+   Int_t cutIndex=0;
+   if(hCutIndex)hCutIndex->Fill(cutIndex);
+   cutIndex++;
+
+   // Fill Histos before Cuts
+  if(hInvMassbefore)hInvMassbefore->Fill(photon->GetPhotonMass());
+  if(hArmenterosbefore)hArmenterosbefore->Fill(photon->GetArmenterosAlpha(),photon->GetArmenterosQt());
+
+  //Track cuts, if
+  if(!DoOnlyPhotonCuts){
+      // Get Tracks
+      AliVTrack * negTrack = GetTrack(event, photon->GetTrackLabelNegative());
+      AliVTrack * posTrack = GetTrack(event, photon->GetTrackLabelPositive());
+
+      if(!negTrack || !posTrack) {
+         if(hCutIndex)hCutIndex->Fill(cutIndex);
+         return kFALSE;
+      }
+      cutIndex++; //1
+
+      // dEdx Cuts
+      if(!dEdxCuts(negTrack) || !dEdxCuts(posTrack)) {
+         if(hCutIndex)hCutIndex->Fill(cutIndex);
+         return kFALSE;
+      }
+      cutIndex++;
+
+      // Track Cuts
+      if(!TracksAreSelected(negTrack, posTrack)){
+         if(hCutIndex)hCutIndex->Fill(cutIndex);//4
+         return kFALSE;
+      }
+      cutIndex++;
+  }
+  else{cutIndex+=3;}
+
+  // Photon Cuts
+  if(!PhotonCuts(photon,event)){
+      if(hCutIndex)hCutIndex->Fill(cutIndex);
+      return kFALSE;
+  }
+  cutIndex++;
+
+
+  // Photon passed cuts
+  if(hCutIndex)hCutIndex->Fill(cutIndex);
+  if(hInvMassafter)hInvMassafter->Fill(photon->GetPhotonMass());
+  if(hArmenterosafter)hArmenterosafter->Fill(photon->GetArmenterosAlpha(),photon->GetArmenterosQt());
+
+  return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::MesonIsSelected(AliAODConversionMother *pi0,Bool_t IsSignal)
+{
+    // Selection of reconstructed Meson candidates
+    // Use flag IsSignal in order to fill Fill different
+    // histograms for Signal and Background
+    TH1 *hist=0x0;
+
+    if(IsSignal){hist=hMesonCuts;
+    }
+    else{hist=hMesonBGCuts;}
+
+    Int_t cutIndex=0;
+    if(hist)hist->Fill(cutIndex);
+    cutIndex++;
+
+    // Undefined Rapidity -> Floating Point exception
+    if((pi0->E()+pi0->Pz())/(pi0->E()-pi0->Pz())<=0){
+        if(hist)hist->Fill(cutIndex);
+       cutIndex++;
+       return kFALSE;
+    }
+    else{
+       // PseudoRapidity Cut
+        cutIndex++;
+       if(TMath::Abs(pi0->PseudoRapidity())>fRapidityCutMeson){
+           if(hist)hist->Fill(cutIndex);
+           return kFALSE;
+       }
+    }
+    cutIndex++;
+
+    // Opening Angle Cut
+    fOpeningAngle=2*TMath::ATan(0.134/pi0->P());// physical minimum opening angle
+    if(pi0->GetOpeningAngle()<fOpeningAngle){
+       if(hist)hist->Fill(cutIndex);
+       return kFALSE;
+    }
+    cutIndex++;
+
+    // Alpha Max Cut
+    if(pi0->GetAlpha()>fAlphaCutMeson){
+       if(hist)hist->Fill(cutIndex);
+       return kFALSE;
+    }
+    cutIndex++;
+
+    // Alpha Min Cut
+    if(pi0->GetAlpha()<fAlphaMinCutMeson){
+       if(hist)hist->Fill(cutIndex);
+       return kFALSE;
+    }
+    cutIndex++;
+
+    if(hist)hist->Fill(cutIndex);
+    return kTRUE;
+}
+
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::ArmenterosQtCut(AliConversionPhotonBase *photon)
+{   // Armenteros Qt Cut
+
+  if(fDoHighPtQtGammaSelection){
+       if(photon->GetPhotonPt() < fPtBorderForQt){
+         if(photon->GetArmenterosQt()>fQtMax){
+               return kFALSE;
+         }
+       } else {
+         if(photon->GetArmenterosQt()>fHighPtQtMax){
+               return kFALSE;
+         }
+       }
+  } else {
+
+       if(photon->GetArmenterosQt()>fQtMax){
+         return kFALSE;
+       }
+  }
+  return kTRUE;
+}
+
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::AcceptanceCuts(AliConversionPhotonBase *photon) {
+    // Exclude certain areas for photon reconstruction
+
+    Int_t cutIndex=0;
+    if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
+    cutIndex++;
+
+    if(photon->GetConversionRadius()>fMaxR){ // cuts on distance from collision point
+       if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
+       return kFALSE;
+    }
+    cutIndex++;
+
+    if(photon->GetConversionRadius()<fMinR){ // cuts on distance from collision point
+       if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
+       return kFALSE;
+    }
+    cutIndex++;
+
+    if(photon->GetConversionRadius() <= ((TMath::Abs(photon->GetConversionZ())*fLineCutZRSlope)-fLineCutZValue)){
+      if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
+      return kFALSE;
+    }
+    else if (fUseEtaMinCut &&  photon->GetConversionRadius() >= ((TMath::Abs(photon->GetConversionZ())*fLineCutZRSlopeMin)-fLineCutZValueMin )){
+       if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
+       return kFALSE;
+    }
+    cutIndex++;
+
+  if(TMath::Abs(photon->GetConversionZ()) > fMaxZ ){ // cuts out regions where we do not reconstruct
+      if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
+      return kFALSE;
+  }
+    cutIndex++;
+
+
+  if(TMath::Abs(photon->GetPhotonEta())> fEtaCut || TMath::Abs(photon->GetPhotonEta())< fEtaCutMin){
+      if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
+      return kFALSE;
+  }
+    cutIndex++;
+
+
+  if(photon->GetPhotonPt()<fPtCut){
+      if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
+      return kFALSE;
+  }
+    cutIndex++;
+
+  if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
+  return kTRUE;
+}
+
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SpecificTrackCuts(AliAODTrack * negTrack, AliAODTrack * posTrack,Int_t &cutIndex) {
+    // Track Cuts which require AOD/ESD specific implementation
+
+  if( !negTrack->IsOn(AliESDtrack::kTPCrefit)  || !negTrack->IsOn(AliESDtrack::kTPCrefit)   )  {
+      if(hTrackCuts)hTrackCuts->Fill(cutIndex);
+      return kFALSE;
+  }
+  cutIndex++;
+
+  AliAODVertex * NegVtxType=negTrack->GetProdVertex();
+  AliAODVertex * PosVtxType=posTrack->GetProdVertex();
+  if((NegVtxType->GetType())==AliAODVertex::kKink  || (PosVtxType->GetType())==AliAODVertex::kKink) {
+      if(hTrackCuts)hTrackCuts->Fill(cutIndex);
+      return kFALSE;
+  }
+  return kTRUE;
+
+}
+
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SpecificTrackCuts(AliESDtrack * negTrack, AliESDtrack * posTrack,Int_t &cutIndex) {
+    // Track Cuts which require AOD/ESD specific implementation
+
+  if( !negTrack->IsOn(AliESDtrack::kTPCrefit)  || !negTrack->IsOn(AliESDtrack::kTPCrefit)   )  {
+      if(hTrackCuts)hTrackCuts->Fill(cutIndex);
+      return kFALSE;
+  }
+  cutIndex++;
+
+  if(negTrack->GetKinkIndex(0) > 0  || posTrack->GetKinkIndex(0) > 0 ) {
+      if(hTrackCuts)hTrackCuts->Fill(cutIndex);
+      return kFALSE;
+  }
+  return kTRUE;
+}
+
+
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::TracksAreSelected(AliVTrack * negTrack, AliVTrack * posTrack) {
+    // Track Selection for Photon Reconstruction
+
+    Int_t cutIndex=0;
+    if(hTrackCuts)hTrackCuts->Fill(cutIndex);
+    cutIndex++;
+
+  // avoid like sign
+  if(negTrack->Charge() == posTrack->Charge()) {
+       if(hTrackCuts)hTrackCuts->Fill(cutIndex);
+        return kFALSE;
+  }
+  cutIndex++;
+
+  // Number of TPC Clusters
+  if( negTrack->GetNcls(1) < fMinClsTPC || posTrack->GetNcls(1) < fMinClsTPC ) {
+      if(hTrackCuts)hTrackCuts->Fill(cutIndex);
+        return kFALSE;
+  }
+  cutIndex++;
+
+  // Acceptance
+
+  if(TMath::Abs(negTrack->Eta()) > fEtaCut || TMath::Abs(negTrack->Eta()) < fEtaCutMin ||
+     TMath::Abs(posTrack->Eta())> fEtaCut || TMath::Abs(posTrack->Eta())< fEtaCutMin) {
+       if(hTrackCuts)hTrackCuts->Fill(cutIndex);
+      return kFALSE;
+  }
+  cutIndex++;
+
+  // Single Pt Cut
+  if( negTrack->Pt()< fSinglePtCut ||  posTrack->Pt()< fSinglePtCut){
+      if(hTrackCuts)hTrackCuts->Fill(cutIndex);
+      return kFALSE;
+  }
+  cutIndex++;
+
+  // AOD ESD specific cuts
+  Bool_t passCuts = kTRUE;
+
+  if(negTrack->IsA()==AliAODTrack::Class()) {
+       passCuts = passCuts * SpecificTrackCuts(static_cast<AliAODTrack*>(negTrack), static_cast<AliAODTrack*>(posTrack),cutIndex);
+  } else { 
+       passCuts = passCuts * SpecificTrackCuts(static_cast<AliESDtrack*>(negTrack), static_cast<AliESDtrack*>(posTrack),cutIndex);
+  }    
+
+  if(!passCuts){
+      if(hTrackCuts)hTrackCuts->Fill(cutIndex);
+      return kFALSE;
+  }
+  cutIndex++;
+
+  if(hTrackCuts)hTrackCuts->Fill(cutIndex);
+
+  return kTRUE;
+                   
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::dEdxCuts(AliVTrack *fCurrentTrack){
+    // Electron Identification Cuts for Photon reconstruction
+
+    if(!fPIDResponse){InitPIDResponse();}// Try to reinitialize PID Response
+    if(!fPIDResponse){AliError("No PID Response"); return kTRUE;}// if still missing fatal error
+
+    Int_t cutIndex=0;
+    if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
+    if(hTPCdEdxbefore)hTPCdEdxbefore->Fill(fCurrentTrack->P(),fCurrentTrack->GetTPCsignal());
+    cutIndex++;
+    
+
+  if(fDodEdxSigmaCut == kTRUE){
+      // TPC Electron Line
+      if( fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)<fPIDnSigmaBelowElectronLine ||
+               fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaAboveElectronLine){
+
+         if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
+         return kFALSE;
+      }
+      cutIndex++;
+
+      // TPC Pion Line
+       if( fCurrentTrack->P()>fPIDMinPnSigmaAbovePionLine && fCurrentTrack->P()<fPIDMaxPnSigmaAbovePionLine ){
+         if(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLine &&
+                fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLine&&
+                fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)<fPIDnSigmaAbovePionLine){
+
+             if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
+             return kFALSE;
+         }
+       }
+       cutIndex++;
+   
+       // High Pt Pion rej
+       if( fCurrentTrack->P()>fPIDMaxPnSigmaAbovePionLine ){
+         if(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLine &&
+                fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLine&&
+                fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)<fPIDnSigmaAbovePionLineHighPt){
+
+                if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
+               return kFALSE;
+         }
+       }
+       cutIndex++;
+  }
+  else{cutIndex+=3;}
+
+  if(fDoKaonRejectionLowP == kTRUE){
+       if(fCurrentTrack->P()<fPIDMinPKaonRejectionLowP ){
+         if( TMath::Abs(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kKaon))<fPIDnSigmaAtLowPAroundKaonLine){
+
+             if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
+             return kFALSE;
+         }
+       }
+  }
+  cutIndex++;
+   
+  if(fDoProtonRejectionLowP == kTRUE){
+       if( fCurrentTrack->P()<fPIDMinPProtonRejectionLowP ){
+         if( TMath::Abs(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kProton))<fPIDnSigmaAtLowPAroundProtonLine){
+
+             if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
+             return kFALSE;
+         }
+       }
+  }
+   cutIndex++;
+   
+  if(fDoPionRejectionLowP == kTRUE){
+       if( fCurrentTrack->P()<fPIDMinPPionRejectionLowP ){
+         if( TMath::Abs(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion))<fPIDnSigmaAtLowPAroundPionLine){
+
+             if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
+               return kFALSE;
+         }
+       }
+  }
+  cutIndex++;
+   
+
+  if( fDoTOFsigmaCut == kTRUE ){ // RRnewTOF start /////////////////////////////////////////////////////////////////////////////
+
+       if((fPIDResponse->NumberOfSigmasTOF(fCurrentTrack,AliPID::kElectron)>fTofPIDnSigmaAboveElectronLine) || (fPIDResponse->NumberOfSigmasTOF(fCurrentTrack,AliPID::kElectron)<fTofPIDnSigmaBelowElectronLine)){
+
+           if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
+           return kFALSE;
+       }
+  } /////////////////////////////// RRnewTOF end ///////////////////////////////////////////////////////////////////////////////
+  cutIndex++;
+   
+    // Apply TRD PID
+  if(fDoTRDPID){
+       if(!fPIDResponse->IdentifiedAsElectronTRD(fCurrentTrack,fPIDTRDEfficiency)){
+
+           if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
+           return kFALSE;
+       }
+  }
+  cutIndex++;
+
+  if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
+  if(hTPCdEdxafter)hTPCdEdxafter->Fill(fCurrentTrack->P(),fCurrentTrack->GetTPCsignal());
+
+  return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::AsymmetryCut(AliConversionPhotonBase * photon,AliVEvent *event) {
+    // Cut on Energy Assymetry
+
+    for(Int_t ii=0;ii<2;ii++){
+
+        AliVTrack *track=GetTrack(event,photon->GetTrackLabel(ii));
+
+       if( track->P() > fMinPPhotonAsymmetryCut ){
+           Double_t trackNegAsy=0;
+           if (photon->GetPhotonP()!=0.){
+               trackNegAsy= track->P()/photon->GetPhotonP();
+           }
+
+           if( trackNegAsy<fMinPhotonAsymmetry ||trackNegAsy>(1.- fMinPhotonAsymmetry)){
+               return kFALSE;
+           }
+       }
+
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+AliVTrack *AliConversionCuts::GetTrack(AliVEvent * event, Int_t label) const{
+    //Returns pointer to the track with given ESD label
+    //(Important for AOD implementation, since Track array in AOD data is different
+    //from ESD array, but ESD tracklabels are stored in AOD Tracks)
+
+  AliESDEvent * esdEvent = dynamic_cast<AliESDEvent*>(event);
+  if(esdEvent) {
+       if(label > event->GetNumberOfTracks() ) return NULL;
+       AliESDtrack * track = esdEvent->GetTrack(label);
+       return track;
+       
+  } else { 
+       for(Int_t ii=0; ii<event->GetNumberOfTracks(); ii++) {
+         AliVTrack * track = dynamic_cast<AliVTrack*>(event->GetTrack(ii));
+         
+         if(track) { 
+               if(track->GetID() == label) {
+                 return track;
+               }
+         }
+       }
+  }
+  
+  cout << "track not found " << label << " " << event->GetNumberOfTracks() << endl;
+  return NULL;
+}
+
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::PIDProbabilityCut(AliConversionPhotonBase *photon, AliVEvent * event){
+    // Cut on Electron Probability for Photon Reconstruction
+
+  AliESDEvent * esdEvent = dynamic_cast<AliESDEvent*>(event);
+
+  if(esdEvent){
+       
+       Bool_t iResult=kFALSE;
+       
+       Double_t *posProbArray = new Double_t[AliPID::kSPECIES];
+       Double_t *negProbArray = new Double_t[AliPID::kSPECIES];
+       
+       AliESDtrack* negTrack   = esdEvent->GetTrack(photon->GetTrackLabelNegative());
+       AliESDtrack* posTrack   = esdEvent->GetTrack(photon->GetTrackLabelPositive());
+       
+       if(negProbArray && posProbArray){
+         
+         negTrack->GetTPCpid(negProbArray);
+         posTrack->GetTPCpid(posProbArray);
+
+         if(negProbArray[AliPID::kElectron]>=fPIDProbabilityCutNegativeParticle && posProbArray[AliPID::kElectron]>=fPIDProbabilityCutPositiveParticle){
+               iResult=kTRUE;
+         }
+       }
+       
+       delete [] posProbArray;
+       delete [] negProbArray;
+       return iResult;
+
+  } else {
+      ///Not possible for AODs
+      return kTRUE;
+  }
+
+
+
+  
+}
+
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::AcceptanceCut(TParticle *particle, TParticle * ePos,TParticle* eNeg){
+    // MC Acceptance Cuts
+    //(Certain areas were excluded for photon reconstruction)
+
+  if(particle->R()>fMaxR){
+       return kFALSE;}
+
+  if(ePos->R()>fMaxR){
+       return kFALSE;
+  }
+
+  if(ePos->R()<fMinR){
+       return kFALSE;
+  }
+
+  if( ePos->R() <= ((TMath::Abs(ePos->Vz())*fLineCutZRSlope)-fLineCutZValue)){
+       return kFALSE;
+  }
+  else if (fUseEtaMinCut &&  ePos->R() >= ((TMath::Abs(ePos->Vz())*fLineCutZRSlopeMin)-fLineCutZValueMin )){
+      return kFALSE;
+  }
+
+  if(TMath::Abs(eNeg->Vz()) > fMaxZ ){ // cuts out regions where we do not reconstruct
+       return kFALSE;
+  }
+
+  if(eNeg->Vz()!=ePos->Vz()||eNeg->R()!=ePos->R()){
+       return kFALSE;
+  }
+
+  if(TMath::Abs(ePos->Vz()) > fMaxZ ){ // cuts out regions where we do not reconstruct
+       return kFALSE;
+  }
+
+  if(TMath::Abs(particle->Eta())> fEtaCut || TMath::Abs(particle->Eta())< fEtaCutMin){
+       return kFALSE;
+  }
+
+  if(TMath::Abs(ePos->Eta())> fEtaCut || TMath::Abs(ePos->Eta())< fEtaCutMin){
+       return kFALSE;
+  }
+
+  if(TMath::Abs(eNeg->Eta())> fEtaCut || TMath::Abs(eNeg->Eta())< fEtaCutMin){
+       return kFALSE;
+  }
+
+  if( ePos->Pt()< fSinglePtCut ||  eNeg->Pt()< fSinglePtCut){
+       return kFALSE;
+  }
+
+  if(particle->Pt()<fPtCut){
+       return kFALSE;
+  }
+
+  return kTRUE;
+}
+///________________________________________________________________________
+Bool_t AliConversionCuts::UpdateCutString(cutIds cutID, Int_t value) {
+///Update the cut string (if it has been created yet)
+
+  if(fCutString && fCutString->GetString().Length() == kNCuts) {
+       cout << "Updating cut id in spot number " << cutID << " to " << value << endl; 
+       fCutString->SetString(GetCutNumber());
+  } else {
+       cout << "fCutString not yet initialized, will not be updated" << endl;
+       return kFALSE;
+  }
+  cout << fCutString->GetString().Data() << endl;
+  return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::InitializeCutsFromCutString(const TString analysisCutSelection ) {
+   // Initialize Cuts from a given Cut string
+
+  cout<<"Set Cut Number: "<<analysisCutSelection.Data()<<endl;
+  if(analysisCutSelection.Length()!=kNCuts) {
+       AliError(Form("Cut selection has the wrong length! size is %d, number of cuts is %d", analysisCutSelection.Length(), kNCuts));
+       return kFALSE;
+  }
+  if(!analysisCutSelection.IsDigit()){
+       AliError("Cut selection contains characters");
+       return kFALSE;
+  }
+  
+  const char *cutSelection = analysisCutSelection.Data();
+  #define ASSIGNARRAY(i)       fCuts[i] = cutSelection[i] - '0'
+  for(Int_t ii=0;ii<kNCuts;ii++){
+      ASSIGNARRAY(ii);
+  }
+
+  // TestFlag
+  if(fCuts[0] !=9){
+    AliError("Analysis Cut Selection does not start with 9");
+       PrintCuts();
+    return kFALSE;
+  }
+
+  // Set Individual Cuts
+  for(Int_t ii=0;ii<kNCuts;ii++){
+      if(!SetCut(cutIds(ii),fCuts[ii]))return kFALSE;
+  }
+
+  PrintCuts();
+
+  return kTRUE;
+}
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetCut(cutIds cutID, const Int_t value) {
+  ///Set individual cut ID
+
+  cout << "Updating cut  " << fgkCutNames[cutID] << " (" << cutID << ") to " << value << endl;
+
+  if(cutID >= kNCuts) {
+       cout << "Error:: Cut id "<<  cutID << " outside range of kNCuts " << kNCuts << endl;
+       return kFALSE;
+  }
+
+
+
+  switch (cutID) {
+  case kgoodId:
+       fCuts[kgoodId] = value;
+       if(value != 9) {
+         cout << "Error:: First value of cut string is wrong, aborting!!" << endl;
+         return kFALSE;
+       } else {
+         return kTRUE;
+       }
+
+  case kv0FinderType:
+       cout << 1 << endl;
+       if( SetV0Finder(value)) {
+         fCuts[kv0FinderType] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case keProbCut:
+       if( SetElectronProbCut(value)) {
+         fCuts[keProbCut] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kededxSigmaCut:
+       if( SetTPCdEdxCutElectronLine(value)) {
+         fCuts[kededxSigmaCut] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kpidedxSigmaCut:
+       if( SetTPCdEdxCutPionLine(value)) {
+         fCuts[kpidedxSigmaCut] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kpiMomdedxSigmaCut:
+       if( SetMinMomPiondEdxCut(value)) {
+         fCuts[kpiMomdedxSigmaCut] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kchi2GammaCut:
+       if( SetChi2GammaCut(value)) {
+         fCuts[kchi2GammaCut] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case ksinglePtCut:
+       if( SetSinglePtCut(value)) {
+         fCuts[ksinglePtCut] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kclsTPCCut:
+       if( SetTPCClusterCut(value)) {
+         fCuts[kclsTPCCut] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case ketaCut:
+       if( SetEtaCut(value)) {
+         fCuts[ketaCut] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kchi2MesonCut:
+       if( SetChi2MesonCut(value)) {
+         fCuts[kchi2MesonCut] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kLowPRejectionSigmaCut:
+       if( SetLowPRejectionCuts(value)) {
+         fCuts[kLowPRejectionSigmaCut] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kQtMaxCut:
+       if( SetQtMaxCut(value)) {
+         fCuts[kQtMaxCut] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kpiMaxMomdedxSigmaCut:
+       if( SetMaxMomPiondEdxCut(value)) {
+         fCuts[kpiMaxMomdedxSigmaCut] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kalphaMesonCut:
+       if( SetAlphaMesonCut(value)) {
+         fCuts[kalphaMesonCut] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kminRCut:
+       if( SetRCut(value)) {
+         fCuts[kminRCut] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kRapidityMesonCut:
+       if( SetRapidityMesonCut(value)) {
+         fCuts[kRapidityMesonCut] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kBackgroundScheme:
+       if( SetBackgroundScheme(value)) {
+         fCuts[kBackgroundScheme] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kDegreesForRotationMethod:
+       if( SetNDegreesForRotationMethod(value)) {
+         fCuts[kDegreesForRotationMethod] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kNumberOfRotations:
+       if( SetNumberOfRotations(value)) {
+         fCuts[kNumberOfRotations] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kremovePileUp:
+       if( SetRemovePileUp(value)) {
+         fCuts[kremovePileUp] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kselectV0AND:
+       if( SetSelectV0AND(value)) {
+         fCuts[kselectV0AND] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kmultiplicityBin:
+       if( SetMultiplicityBin(value)) {
+         fCuts[kmultiplicityBin] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kisHeavyIon:
+       if( SetIsHeavyIon(value)) {
+         fCuts[kisHeavyIon] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kuseCentrality:
+       if( SetUseCentrality(value)) {
+         fCuts[kuseCentrality] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kcentralityBin:
+       if( SetCentralityBin(value)) {
+         fCuts[kcentralityBin] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kTOFelectronPID:
+       if( SetTOFElectronPIDCut(value)) {
+         fCuts[kTOFelectronPID] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kuseMCPSmearing:
+       if( SetMCPSmearing(value)) {
+         fCuts[kuseMCPSmearing] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kdoPhotonAsymmetryCut:
+       if( SetPhotonAsymmetryCut(value)) {
+         fCuts[kdoPhotonAsymmetryCut] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kPsiPair:
+       if( SetPsiPairCut(value)) {
+         fCuts[kPsiPair] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kCosPAngle:
+       if( SetCosPAngleCut(value)) {
+         fCuts[kCosPAngle] = value;
+         UpdateCutString(cutID, value);
+         return kTRUE;
+       } else return kFALSE;
+
+  case kNCuts:
+       cout << "Error:: Cut id out of range"<< endl;
+       return kFALSE;
+  }
+
+  return kFALSE;
+
+
+
+
+
+
+
+  // case kv0FinderType:
+  //   fCuts[kv0FinderType] = value;
+  //   if(!SetV0Finder(fCuts[kv0FinderType]))return kFALSE;
+  //   else return kTRUE;
+  // case keProbCut:
+  //   fCuts[keProbCut] = value;
+  //   if(!SetElectronProbCut(fCuts[keProbCut]))return kFALSE;
+  //   else return kTRUE;
+  // case kededxSigmaCut:
+  //   fCuts[kededxSigmaCut] = value;
+  //   if(!SetTPCdEdxCutElectronLine(fCuts[kededxSigmaCut]))return kFALSE;
+  //   else return kTRUE;
+  // case kpidedxSigmaCut:
+  //   fCuts[kpidedxSigmaCut] = value;
+  //   if(!SetTPCdEdxCutPionLine(fCuts[kpidedxSigmaCut]))return kFALSE;
+  //   else return kTRUE;
+  // case kpiMomdedxSigmaCut:
+  //   fCuts[kpiMomdedxSigmaCut] = value;
+  //   if(!SetMinMomPiondEdxCut(fCuts[kpiMomdedxSigmaCut]))return kFALSE;
+  //   else return kTRUE;
+  // case kchi2GammaCut:
+  //   fCuts[kchi2GammaCut] = value;
+  //   if(!SetChi2GammaCut(fCuts[kchi2GammaCut]))return kFALSE;
+  //   else return kTRUE;
+  // case ksinglePtCut:
+  //   fCuts[ksinglePtCut] = value;
+  //   if(!SetSinglePtCut(fCuts[ksinglePtCut]))return kFALSE;
+  //   else return kTRUE;
+  // case kclsTPCCut:
+  //   fCuts[kclsTPCCut] = value;
+  //   if(!SetTPCClusterCut(fCuts[kclsTPCCut]))return kFALSE;
+  //   else return kTRUE;
+  // case ketaCut:
+  //   fCuts[ketaCut] = value;
+  //   if(!SetEtaCut(fCuts[ketaCut]))return kFALSE;
+  //   else return kTRUE;
+  // case kchi2MesonCut:
+  //   fCuts[kchi2MesonCut] = value;
+  //   if(!SetChi2MesonCut(fCuts[kchi2MesonCut]))return kFALSE;
+  //   else return kTRUE;
+  // case kLowPRejectionSigmaCut:
+  //   fCuts[kLowPRejectionSigmaCut] = value;
+  //   if(!SetLowPRejectionCuts(fCuts[kLowPRejectionSigmaCut]))return kFALSE;
+  //   else return kTRUE;
+  // case kQtMaxCut:
+  //   fCuts[kQtMaxCut] = value;
+  //   if(!SetQtMaxCut(fCuts[kQtMaxCut]))return kFALSE;
+  //   else return kTRUE;
+  // case kpiMaxMomdedxSigmaCut:
+  //   fCuts[kpiMaxMomdedxSigmaCut] = value;
+  //   if(!SetMaxMomPiondEdxCut(fCuts[kpiMaxMomdedxSigmaCut]))return kFALSE;
+  //   else return kTRUE;
+  // case kalphaMesonCut:
+  //   fCuts[kalphaMesonCut] = value;
+  //   if(!SetAlphaMesonCut(fCuts[kalphaMesonCut]))return kFALSE;
+  //   else return kTRUE;
+  // case kminRCut:
+  //   fCuts[kminRCut] = value;
+  //   if(!SetRCut(fCuts[kminRCut]))return kFALSE;
+  //   else return kTRUE;
+  // case kRapidityMesonCut:
+  //   fCuts[kRapidityMesonCut] = value;
+  //   if(!SetRapidityMesonCut(fCuts[kRapidityMesonCut]))return kFALSE;
+  //   else return kTRUE;
+  // case kBackgroundScheme:
+  //   fCuts[kBackgroundScheme] = value;
+  //   if(!SetBackgroundScheme(fCuts[kBackgroundScheme]))return kFALSE;
+  //   else return kTRUE;
+  // case kDegreesForRotationMethod:
+  //   fCuts[kDegreesForRotationMethod] = value;
+  //   if(!SetNDegreesForRotationMethod(fCuts[kDegreesForRotationMethod]))return kFALSE;
+  //   else return kTRUE;
+  // case kNumberOfRotations:
+  //   fCuts[kNumberOfRotations] = value;
+  //   if(!SetNumberOfRotations(fCuts[kNumberOfRotations]))return kFALSE;
+  //   else return kTRUE;
+  // case kremovePileUp:
+  //   fCuts[kremovePileUp] = value;
+  //   if(!SetRemovePileUp(fCuts[kremovePileUp]))return kFALSE;
+  //   else return kTRUE;
+  // case kselectV0AND:
+  //   fCuts[kselectV0AND] = value;
+  //   if(!SetSelectV0AND(fCuts[kselectV0AND]))return kFALSE;
+  //   else return kTRUE;
+  // case kmultiplicityBin:
+  //   fCuts[kmultiplicityBin] = value;
+  //   if(!SetMultiplicityBin(fCuts[kmultiplicityBin]))return kFALSE;
+  //   else return kTRUE;
+  // case kisHeavyIon:
+  //   fCuts[kisHeavyIon] = value;
+  //   if(!SetIsHeavyIon(fCuts[kisHeavyIon]))return kFALSE;
+  //   else return kTRUE;
+  // case kuseCentrality:
+  //   fCuts[kuseCentrality] = value;
+  //   if(!SetUseCentrality(fCuts[kuseCentrality]))return kFALSE;
+  //   else return kTRUE;
+  // case kcentralityBin:
+  //   fCuts[kcentralityBin] = value;
+  //   if(!SetCentralityBin(fCuts[kcentralityBin]))return kFALSE;
+  //   else return kTRUE;
+  // case kTOFelectronPID:
+  //   fCuts[kTOFelectronPID] = value;
+  //   if(!SetTOFElectronPIDCut(fCuts[kTOFelectronPID]))return kFALSE;
+  //   else return kTRUE;
+  // case kuseMCPSmearing:
+  //   fCuts[kuseMCPSmearing] = value;
+  //   if(!SetMCPSmearing(fCuts[kuseMCPSmearing]))return kFALSE;
+  //   else return kTRUE;
+  // case kdoPhotonAsymmetryCut:
+  //   fCuts[kdoPhotonAsymmetryCut] = value;
+  //   if(!SetPhotonAsymmetryCut(fCuts[kdoPhotonAsymmetryCut]))return kFALSE;
+  //   else return kTRUE;
+  // case kPsiPair:
+  //   fCuts[kPsiPair] = value;
+  //   if(!SetPhotonAsymmetryCut(fCuts[kdoPhotonAsymmetryCut]))return kFALSE;
+  //   else return kTRUE;
+  // case kCosPAngle:
+  //   fCuts[kCosPAngle] = value;
+  //   if(!SetPhotonAsymmetryCut(fCuts[kdoPhotonAsymmetryCut]))return kFALSE;
+  //   else return kTRUE;
+  // case kNCuts:
+  //   cout << "Error:: Cut id out of range"<< endl;
+  //   return kFALSE;
+  // }
+
+  //PrintCuts();
+  
+}
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetRemovePileUp(Int_t removePileUp)
+{// Set Cut
+    switch(removePileUp){
+    case 0:
+       fRemovePileUp=kFALSE;
+       break;
+    case 1:
+       fRemovePileUp=kTRUE;
+       break;
+    default:
+       cout<<"Warning: RemovePileUpCut not defined"<<removePileUp<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetSelectV0AND(Int_t selectV0AND)
+{// Set Cut
+  switch(selectV0AND){
+  case 0:
+      fSelectV0AND=kFALSE;
+      break;
+  case 1:
+      fSelectV0AND=kTRUE;
+      break;
+  default:
+      cout<<"Warning: V0ANDCut not defined"<<selectV0AND<<endl;
+      return kFALSE;
+  }
+  return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetMultiplicityBin(Int_t multiplicityBin)
+{// Set Cut
+    switch(multiplicityBin){
+    case 0:
+       fUseMultiplicity=kFALSE;
+       fUseMultiplicityBin=0;
+       break;
+    case 1:
+       fUseMultiplicity=kTRUE;
+       fUseMultiplicityBin=1;
+       break;
+    case 2:
+       fUseMultiplicity=kTRUE;
+       fUseMultiplicityBin=2;
+       break;
+    case 3:
+       fUseMultiplicity=kTRUE;
+       fUseMultiplicityBin=3;
+       break;
+    case 4:
+       fUseMultiplicity=kTRUE;
+       fUseMultiplicityBin=4;
+       break;
+    case 5:
+       fUseMultiplicity=kTRUE;
+       fUseMultiplicityBin=5;
+       break;
+    default:
+       cout<<"Warning: MultiplicityBinCut not defined"<<multiplicityBin<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetMCPSmearing(Int_t useMCPSmearing)
+{// Set Cut
+    switch(useMCPSmearing){
+    case 0:
+       fUseMCPSmearing=0;
+       fPBremSmearing=1.;
+       fPSigSmearing=0.;
+       fPSigSmearingCte=0.;
+       break;
+    case 1:
+       fUseMCPSmearing=1;
+       fPBremSmearing=1.0e-14;
+       fPSigSmearing=0.;
+       fPSigSmearingCte=0.;
+       break;
+    case 2:
+       fUseMCPSmearing=1;
+       fPBremSmearing=1.0e-15;
+       fPSigSmearing=0.0;
+       fPSigSmearingCte=0.;
+       break;
+    case 3:
+       fUseMCPSmearing=1;
+       fPBremSmearing=1.;
+       fPSigSmearing=0.003;
+       fPSigSmearingCte=0.002;
+       break;
+    case 4:
+       fUseMCPSmearing=1;
+       fPBremSmearing=1.;
+       fPSigSmearing=0.003;
+       fPSigSmearingCte=0.007;
+       break;
+    case 5:
+       fUseMCPSmearing=1;
+       fPBremSmearing=1.;
+       fPSigSmearing=0.003;
+       fPSigSmearingCte=0.016;
+       break;
+    case 6:
+       fUseMCPSmearing=1;
+       fPBremSmearing=1.;
+       fPSigSmearing=0.007;
+       fPSigSmearingCte=0.016;
+       break;
+    case 7:
+       fUseMCPSmearing=1;
+       fPBremSmearing=1.0e-16;
+       fPSigSmearing=0.0;
+       fPSigSmearingCte=0.;
+       break;
+    case 8:
+       fUseMCPSmearing=1;
+       fPBremSmearing=1.;
+       fPSigSmearing=0.007;
+       fPSigSmearingCte=0.014;
+       break;
+    case 9:
+       fUseMCPSmearing=1;
+       fPBremSmearing=1.;
+       fPSigSmearing=0.007;
+       fPSigSmearingCte=0.011;
+       break;
+
+    default:
+       cout<<"Warning: UseMCPSmearing not defined"<<useMCPSmearing<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+void AliConversionCuts::PrintCuts() {
+    // Print out current Cut Selection
+  for(Int_t ic = 0; ic < kNCuts; ic++) {
+       printf("%-30s : %d \n", fgkCutNames[ic], fCuts[ic]);
+  }
+
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetRCut(Int_t RCut){
+    // Set Cut
+    switch(RCut){
+    case 0:
+       fMinR=0;
+       fMaxR = 180.;
+       break;
+    case 1:
+       fMinR=2.8;
+       fMaxR = 180.;
+       break;
+    case 2:
+       fMinR=5.;
+       fMaxR = 180.;
+       break;
+    case 3:
+       fMaxR = 70.;
+       fMinR = 10.;
+       break;
+    case 4:
+       fMaxR = 70.;
+       fMinR = 5.;
+       break;
+    case 5:
+       fMaxR = 180.;
+       fMinR = 10.;
+       break;
+    // High purity cuts for PbPb
+    case 9:
+       fMaxR = 180.;
+       fMinR = 60.;
+       break;
+
+    default:
+       cout<<"Warning: RCut not defined"<<RCut<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetTPCdEdxCutElectronLine(Int_t ededxSigmaCut)
+{   // Set Cut
+    switch(ededxSigmaCut){
+    case 0: // -10,10
+       fPIDnSigmaBelowElectronLine=-10;
+       fPIDnSigmaAboveElectronLine=10;
+       break;
+    case 1: // -5,5
+       fPIDnSigmaBelowElectronLine=-5;
+       fPIDnSigmaAboveElectronLine=5;
+       break;
+    case 2: // -3,5
+       fPIDnSigmaBelowElectronLine=-3;
+       fPIDnSigmaAboveElectronLine=5;
+       break;
+    case 3: // -4,5
+       fPIDnSigmaBelowElectronLine=-4;
+       fPIDnSigmaAboveElectronLine=5;
+       break;
+    default:
+       cout<<"Warning: TPCdEdxCutElectronLine not defined"<<ededxSigmaCut<<endl;
+       return kFALSE;
+        
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetTPCdEdxCutPionLine(Int_t pidedxSigmaCut)
+{   // Set Cut
+
+    switch(pidedxSigmaCut){
+    case 0:  // -10
+       fPIDnSigmaAbovePionLine=-10;
+       fPIDnSigmaAbovePionLineHighPt=-10;
+       break;
+    case 1:   // 0
+       fPIDnSigmaAbovePionLine=0;
+       fPIDnSigmaAbovePionLineHighPt=-10;
+       break;
+    case 2:  // 1
+       fPIDnSigmaAbovePionLine=1;
+       fPIDnSigmaAbovePionLineHighPt=-10;
+       break;
+    case 3:  // 1
+       fPIDnSigmaAbovePionLine=-1;
+       fPIDnSigmaAbovePionLineHighPt=-10;
+       break;
+    case 4:  // 1
+       fPIDnSigmaAbovePionLine=-1.5;
+       fPIDnSigmaAbovePionLineHighPt=-10;
+       break;
+    case 5:  // 1
+       fPIDnSigmaAbovePionLine=2.;
+       fPIDnSigmaAbovePionLineHighPt=-10;
+       break;
+    case 6:  // 1
+       fPIDnSigmaAbovePionLine=2.;
+       fPIDnSigmaAbovePionLineHighPt=0.5;
+       break;
+    case 7:  // 1
+       fPIDnSigmaAbovePionLine=3.5;
+       fPIDnSigmaAbovePionLineHighPt=-10;
+       break;
+    case 8:  // 1
+       fPIDnSigmaAbovePionLine=2.;
+       fPIDnSigmaAbovePionLineHighPt=1.;
+       break;
+    case 9:
+       fPIDnSigmaAbovePionLine=3.0; // We need a bit less tight cut on dE/dx
+       fPIDnSigmaAbovePionLineHighPt=-10;
+       break;
+    default:
+       cout<<"Warning: pidedxSigmaCut not defined "<<pidedxSigmaCut<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetChi2GammaCut(Int_t chi2GammaCut)
+{   // Set Cut
+
+    switch(chi2GammaCut){
+    case 0: // 100
+       fChi2CutConversion = 100.;
+       break;
+    case 1:  // 50
+       fChi2CutConversion = 50.;
+       break;
+    case 2:  // 30
+       fChi2CutConversion = 30.;
+       break;
+    case 3:
+       fChi2CutConversion = 200.;
+       break;
+    case 4:
+       fChi2CutConversion = 500.;
+       break;
+    case 5:
+       fChi2CutConversion = 1000.;
+       break;
+    case 6:
+       fChi2CutConversion = 5.;
+       break;
+    case 7:
+       fChi2CutConversion = 10.;
+       break;
+    case 8:
+       fChi2CutConversion = 20.;
+       break;
+    case 9:
+       fChi2CutConversion = 15.;
+       break;
+    default:
+        cout<<"Warning: Chi2GammaCut not defined "<<chi2GammaCut<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetV0Finder(Int_t v0FinderType)
+{   // Set Cut
+    switch (v0FinderType){
+    case 0:  // on fly V0 finder
+       fUseOnFlyV0Finder=kTRUE;
+       break;
+    case 1:  // offline V0 finder
+       fUseOnFlyV0Finder=kFALSE;
+       break;
+    default:
+        cout<<"Warning: v0FinderType not defined "<<v0FinderType<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetElectronProbCut(Int_t eProbCut)
+{   // Set Cut
+
+    switch(eProbCut){
+    case 0:
+       fPIDProbabilityCutNegativeParticle=0;
+       fPIDProbabilityCutPositiveParticle=0;
+       break;
+    case 1:
+       fPIDProbabilityCutNegativeParticle=0.1;
+       fPIDProbabilityCutPositiveParticle=0.1;
+       break;
+    case 2:
+       fPIDProbabilityCutNegativeParticle=0.5;
+       fPIDProbabilityCutPositiveParticle=0.5;
+       break;
+    case 3:
+       fPIDProbabilityCutNegativeParticle=0.7;
+       fPIDProbabilityCutPositiveParticle=0.7;
+       break;
+    default:
+       cout<<"Warning: eProbCut not defined "<<eProbCut<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetSinglePtCut(Int_t singlePtCut)
+{   // Set Cut
+    switch(singlePtCut){
+    case 0: // 0.050 GeV
+       fSinglePtCut = 0.050;
+       break;
+    case 1:  // 0.100 GeV
+       fSinglePtCut = 0.100;
+       break;
+    case 2:  // 0.150 GeV
+       fSinglePtCut = 0.150;
+       break;
+    case 3:  // 0.200 GeV
+       fSinglePtCut = 0.200;
+       break;
+    case 4:  // 0.075 GeV
+       fSinglePtCut = 0.075;
+       break;
+    case 5:  // 0.125 GeV
+       fSinglePtCut = 0.125;
+       break;
+    default:
+       cout<<"Warning: singlePtCut not defined "<<singlePtCut<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetTPCClusterCut(Int_t clsTPCCut)
+{   // Set Cut
+    switch(clsTPCCut){
+    case 0: // 0
+       fMinClsTPC= 0.;
+       break;
+    case 1:  // 70
+       fMinClsTPC= 70.;
+       break;
+    case 2:  // 80
+       fMinClsTPC= 80.;
+       break;
+    case 3:  // 100
+       fMinClsTPC= 100.;
+       break;
+    case 4:  // 60% of findable clusters
+       fMinClsTPCToF= 0.6;
+       fUseCorrectedTPCClsInfo=0;
+       break;
+    case 5:  // 0% of findable clusters
+       fMinClsTPCToF= 0.0;
+       fUseCorrectedTPCClsInfo=1;
+       break;
+    case 6:  // 0% of findable clusters
+       fMinClsTPCToF= 0.7;
+       fUseCorrectedTPCClsInfo=0;
+       break;
+    case 7:  // 0% of findable clusters
+       fMinClsTPCToF= 0.35;
+       fUseCorrectedTPCClsInfo=0;
+       break;
+    case 8:
+       fMinClsTPCToF= 0.35;
+       fUseCorrectedTPCClsInfo=1;
+       break;
+    case 9:
+       fMinClsTPCToF= 0.6;
+       fUseCorrectedTPCClsInfo=1;
+       break;
+    default:
+       cout<<"Warning: clsTPCCut not defined "<<clsTPCCut<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetEtaCut(Int_t etaCut)
+{   // Set Cut
+    switch(etaCut){
+    case 0: // 0.9
+       fEtaCut         = 0.9;
+       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
+       fEtaCutMin              = -0.1;
+       fLineCutZRSlopeMin = 0.;
+       break;
+    case 1:    // 1.2
+       fEtaCut         = 1.2;
+       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
+       fEtaCutMin              = -0.1;
+       fLineCutZRSlopeMin = 0.;
+       break;
+    case 2:    // 1.4
+       fEtaCut         = 1.4;
+       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
+       fEtaCutMin              = -0.1;
+       fLineCutZRSlopeMin = tan(2*atan(exp(-fEtaCut)));
+       break;
+    case 3: // 0.8
+       fEtaCut         = 0.8;
+       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
+       fEtaCutMin              = -0.1;
+       fLineCutZRSlopeMin = 0.;
+       break;
+    case 4: // 0.75
+       fEtaCut         = 0.75;
+       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
+       fEtaCutMin              = -0.1;
+       fLineCutZRSlopeMin = 0.;
+       break;
+    case 5: // 0.9 - 1.4
+       fEtaCut         = 1.4;
+       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
+       fEtaCutMin              = 0.9;
+       fLineCutZRSlopeMin = tan(2*atan(exp(-fEtaCutMin)));
+       break;
+    case 6: // 0.9 - 1.2
+       fEtaCut         = 1.2;
+       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
+       fEtaCutMin              = 0.9;
+       fLineCutZRSlopeMin = tan(2*atan(exp(-fEtaCutMin)));
+       break;
+    case 7: // 0.1 - 0.8
+       fEtaCut         = 0.8;
+       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
+       fEtaCutMin              = 0.1;
+       fLineCutZRSlopeMin = tan(2*atan(exp(-fEtaCutMin)));
+       break;
+    case 8: // 0.1 - 0.8
+       fEtaCut         = 0.9;
+       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
+       fEtaCutMin              = 0.1;
+       fLineCutZRSlopeMin = tan(2*atan(exp(-fEtaCutMin)));
+        break;
+    default:
+       cout<<"Warning: EtaCut not defined "<<etaCut<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetChi2MesonCut(Int_t chi2MesonCut)
+{   // Set Cut
+    switch(chi2MesonCut){
+    case 0:  // 100.
+       fChi2CutMeson = 100.;
+       break;
+    case 1:  // 50.
+       fChi2CutMeson = 50.;
+       break;
+    case 2:  // 30.
+       fChi2CutMeson = 30.;
+       break;
+    case 3:
+       fChi2CutMeson = 200.;
+       break;
+    case 4:
+       fChi2CutMeson = 500.;
+       break;
+    case 5:
+       fChi2CutMeson = 1000.;
+       break;
+    default:
+       cout<<"Warning: Chi2MesonCut not defined "<<chi2MesonCut<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetMinMomPiondEdxCut(Int_t piMomdedxSigmaCut)
+{   // Set Cut
+    switch(piMomdedxSigmaCut){
+    case 0:  // 0.5 GeV
+       fPIDMinPnSigmaAbovePionLine=0.5;
+       break;
+    case 1:  // 1. GeV
+       fPIDMinPnSigmaAbovePionLine=1.;
+       break;
+    case 2:  // 1.5 GeV
+       fPIDMinPnSigmaAbovePionLine=1.5;
+       break;
+    case 3:  // 20.0 GeV
+       fPIDMinPnSigmaAbovePionLine=20.;
+       break;
+    case 4:  // 50.0 GeV
+       fPIDMinPnSigmaAbovePionLine=50.;
+       break;
+    case 5:  // 0.3 GeV
+       fPIDMinPnSigmaAbovePionLine=0.3;
+       break;
+    case 6:  // 0.25 GeV     // RRnew label was wrong in comment
+       fPIDMinPnSigmaAbovePionLine=0.25;
+       break;
+    case 7:  // 0.4 GeV
+       fPIDMinPnSigmaAbovePionLine=0.4;
+       break;
+    default:
+       cout<<"Warning: piMomdedxSigmaCut not defined "<<piMomdedxSigmaCut<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetMaxMomPiondEdxCut(Int_t piMaxMomdedxSigmaCut)
+{   // Set Cut
+    switch(piMaxMomdedxSigmaCut){
+    case 0:  // 100. GeV
+       fPIDMaxPnSigmaAbovePionLine=100.;
+       break;
+    case 1:  // 5. GeV
+       fPIDMaxPnSigmaAbovePionLine=5.;
+       break;
+    case 2:  // 4. GeV
+       fPIDMaxPnSigmaAbovePionLine=4.;
+       break;
+    case 3:  // 3.5 GeV
+       fPIDMaxPnSigmaAbovePionLine=3.5;
+       break;
+    case 4:  // 3. GeV
+       fPIDMaxPnSigmaAbovePionLine=3.;
+       break;
+    default:
+       cout<<"Warning: piMaxMomdedxSigmaCut not defined "<<piMaxMomdedxSigmaCut<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetIsHeavyIon(Int_t isHeavyIon)
+{   // Set Cut
+    switch(isHeavyIon){
+    case 0:
+       fIsHeavyIon=0;
+       break;
+    case 1:
+       fIsHeavyIon=1;
+       break;
+    default:
+       cout<<"Warning: SetHeavyIon not defined "<<isHeavyIon<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetAlphaMesonCut(Int_t alphaMesonCut)
+{   // Set Cut
+    switch(alphaMesonCut){
+    case 0:    // 0- 0.7
+       fAlphaMinCutMeson        = 0.0;
+       fAlphaCutMeson   = 0.7;
+       break;
+    case 1:    // 0-0.5
+       fAlphaMinCutMeson        = 0.0;
+       fAlphaCutMeson   = 0.5;
+       break;
+    case 2:    // 0.5-1
+       fAlphaMinCutMeson        = 0.5;
+       fAlphaCutMeson   = 1.;
+       break;
+    case 3:    // 0.0-1
+       fAlphaMinCutMeson        = 0.0;
+       fAlphaCutMeson   = 1.;
+       break;
+    case 4:    // 0-0.65
+       fAlphaMinCutMeson        = 0.0;
+       fAlphaCutMeson   = 0.65;
+       break;
+    case 5:    // 0-0.75
+       fAlphaMinCutMeson        = 0.0;
+       fAlphaCutMeson   = 0.75;
+       break;
+    case 6:    // 0-0.8
+       fAlphaMinCutMeson        = 0.0;
+       fAlphaCutMeson   = 0.8;
+       break;
+    case 7:    // 0.0-0.85
+       fAlphaMinCutMeson        = 0.0;
+       fAlphaCutMeson   = 0.85;
+       break;
+    case 8:    // 0.0-0.6
+       fAlphaMinCutMeson        = 0.0;
+       fAlphaCutMeson   = 0.6;
+       break;
+    default:
+        cout<<"Warning: AlphaMesonCut not defined "<<alphaMesonCut<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetRapidityMesonCut(Int_t RapidityMesonCut)
+{   // Set Cut
+    switch(RapidityMesonCut){
+    case 0:  //
+       fRapidityCutMeson   = 0.9;
+       break;
+    case 1:  //
+       fRapidityCutMeson   = 0.8;
+       break;
+    case 2:  //
+       fRapidityCutMeson   = 0.7;
+       break;
+
+    default:
+        cout<<"Warning: RapidityMesonCut not defined "<<RapidityMesonCut<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetLowPRejectionCuts(Int_t LowPRejectionSigmaCut)
+{   // Set Cut
+    switch(LowPRejectionSigmaCut){
+       case 0:  //
+       fPIDnSigmaAtLowPAroundKaonLine=0;
+       fPIDnSigmaAtLowPAroundProtonLine=0;
+       fPIDnSigmaAtLowPAroundPionLine=0;
+       break;
+    case 1:  //
+       fPIDnSigmaAtLowPAroundKaonLine=0.5;
+       fPIDnSigmaAtLowPAroundProtonLine=0.5;
+       fPIDnSigmaAtLowPAroundPionLine=0.5;
+       break;
+    case 2:  //
+       fPIDnSigmaAtLowPAroundKaonLine=1;
+       fPIDnSigmaAtLowPAroundProtonLine=1;
+       fPIDnSigmaAtLowPAroundPionLine=1;
+       break;
+    case 3:  //
+       fPIDnSigmaAtLowPAroundKaonLine=2.;
+       fPIDnSigmaAtLowPAroundProtonLine=2.;
+       fPIDnSigmaAtLowPAroundPionLine=2.;
+       break;
+    case 4:  //
+       fPIDnSigmaAtLowPAroundKaonLine=0.;
+       fPIDnSigmaAtLowPAroundProtonLine=0.;
+       fPIDnSigmaAtLowPAroundPionLine=1;
+       break;
+    case 5:  //
+       fPIDnSigmaAtLowPAroundKaonLine=0.;
+       fPIDnSigmaAtLowPAroundProtonLine=0.;
+       fPIDnSigmaAtLowPAroundPionLine=1.5;
+       break;
+    case 6:  //
+       fPIDnSigmaAtLowPAroundKaonLine=0.;
+       fPIDnSigmaAtLowPAroundProtonLine=0.;
+       fPIDnSigmaAtLowPAroundPionLine=2.;
+       break;
+    default:
+        cout<<"Warning: LowPRejectionSigmaCut not defined "<<LowPRejectionSigmaCut<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetTOFElectronPIDCut(Int_t TOFelectronPID){
+    // Set Cut
+    switch(TOFelectronPID){ // RRnewTOF start //////////////////////////////////////////////////////////////////////////
+    case 0: // no cut
+       fUseTOFpid = kFALSE;
+       fTofPIDnSigmaBelowElectronLine=-100;
+       fTofPIDnSigmaAboveElectronLine=100;
+       break;
+    case 1: // -7,7
+       fUseTOFpid = kTRUE;
+       fTofPIDnSigmaBelowElectronLine=-7;
+       fTofPIDnSigmaAboveElectronLine=7;
+       break;
+    case 2: // -5,5
+       fUseTOFpid = kTRUE;
+       fTofPIDnSigmaBelowElectronLine=-5;
+       fTofPIDnSigmaAboveElectronLine=5;
+       break;
+    case 3: // -3,5
+       fUseTOFpid = kTRUE;
+       fTofPIDnSigmaBelowElectronLine=-3;
+       fTofPIDnSigmaAboveElectronLine=5;
+       break;
+    case 4: // -2,3
+       fUseTOFpid = kTRUE;
+       fTofPIDnSigmaBelowElectronLine=-2;
+       fTofPIDnSigmaAboveElectronLine=3;
+       break;
+    default:
+        cout<<"Warning: TOFElectronCut not defined "<<TOFelectronPID<<endl;
+       return kFALSE;
+    } //////////////////////// RRnewTOF end //////////////////////////////////////////////////////////////////////////
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetTRDElectronCut(Int_t TRDElectronCut)
+{   // Set Cut
+    switch(TRDElectronCut){
+    case 0:
+       fDoTRDPID=kFALSE;
+    case 1:
+       fDoTRDPID=kTRUE;
+       fPIDTRDEfficiency=0.1;
+    case 8:
+       fDoTRDPID=kTRUE;
+       fPIDTRDEfficiency=0.8;
+    case 9:
+       fDoTRDPID=kTRUE;
+       fPIDTRDEfficiency=0.9;
+    default:
+        cout<<"Warning: TRDElectronCut not defined "<<TRDElectronCut<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetQtMaxCut(Int_t QtMaxCut)
+{   // Set Cut
+    switch(QtMaxCut){
+    case 0: //
+       fQtMax=1.;
+       fDoQtGammaSelection=kFALSE;      //No Qt selection (true by default)
+       fDoHighPtQtGammaSelection=kFALSE; // RRnew
+       fHighPtQtMax=100.;              // RRnew
+       fPtBorderForQt=100.;            // RRnew
+       break;
+    case 1:
+       fQtMax=0.1;
+       fDoHighPtQtGammaSelection=kFALSE; // RRnew
+       fHighPtQtMax=100.;              // RRnew
+       fPtBorderForQt=100.;            // RRnew
+       break;
+    case 2:
+       fQtMax=0.07;
+       fDoHighPtQtGammaSelection=kFALSE; // RRnew
+       fHighPtQtMax=100.;              // RRnew
+       fPtBorderForQt=100.;            // RRnew
+       break;
+    case 3:
+       fQtMax=0.05;
+       fDoHighPtQtGammaSelection=kFALSE; // RRnew
+       fHighPtQtMax=100.;              // RRnew
+       fPtBorderForQt=100.;            // RRnew
+       break;
+    case 4:
+       fQtMax=0.03;
+       fDoHighPtQtGammaSelection=kFALSE; // RRnew
+       fHighPtQtMax=100.;              // RRnew
+       fPtBorderForQt=100.;            // RRnew
+       break;
+    case 5: // RR try to improve (get rid of) low InvMass peak in PbPb
+       fQtMax=0.02;
+       fDoHighPtQtGammaSelection=kFALSE; // RRnew
+       fHighPtQtMax=100.;              // RRnew
+       fPtBorderForQt=100.;            // RRnew
+       break; // end RR ///////////////////////////////////////////////
+    case 6:  // RRnew start: pT dependent qT cut
+       fQtMax=0.02;
+       fDoHighPtQtGammaSelection=kTRUE;
+       fHighPtQtMax=0.06;
+       fPtBorderForQt=2.5;
+       break; // RRnew end ////////////////////////////////////////////
+    case 7:
+       fQtMax=0.15;
+       fDoHighPtQtGammaSelection=kFALSE; // RRnew
+       fHighPtQtMax=100.;              // RRnew
+       fPtBorderForQt=100.;            // RRnew
+       break;
+    default:
+        cout<<"Warning: QtMaxCut not defined "<<QtMaxCut<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+//-------------------------------------------------------------
+Double_t AliConversionCuts::GetCentrality(AliVEvent *event)
+{   // Get Event Centrality
+    AliESDEvent *esdEvent=dynamic_cast<AliESDEvent*>(event);
+    if(esdEvent){
+       AliCentrality *fESDCentrality=(AliCentrality*)esdEvent->GetCentrality();
+
+       if(fUseCentrality==0){
+           return fESDCentrality->GetCentralityPercentile("V0M"); // default
+       }
+
+       if(fUseCentrality==1||fUseCentrality==3){
+           return fESDCentrality->GetCentralityPercentile("V0M");
+       }
+
+       if(fUseCentrality==2||fUseCentrality==4){
+           return fESDCentrality->GetCentralityPercentile("CL1");
+       }
+    }
+    AliAODEvent *aodEvent=dynamic_cast<AliAODEvent*>(event);
+    if(aodEvent){
+       if(aodEvent->GetHeader()){return aodEvent->GetHeader()->GetCentrality();}
+    }
+    return -1;
+}
+
+//-------------------------------------------------------------
+Bool_t AliConversionCuts::IsCentralitySelected(AliVEvent *event)
+{   // Centrality Selection
+    if(!fIsHeavyIon)return kTRUE;
+
+    Double_t centrality=GetCentrality(event);
+
+    if(centrality<0)return kFALSE;
+
+    Int_t centralityC=Int_t(centrality/10);
+
+    // No CentralitySelection
+    if(fUseCentrality==0)return kTRUE; 
+
+    // Use Percentiles10
+    if(fUseCentrality==1||fUseCentrality==2){
+        if(fUseCentralityBin==centralityC)return kTRUE;
+    }
+
+    // Use User Defined Centrality Selection
+    if(fUseCentrality==3||fUseCentrality==4){
+
+       //0-10%
+       if( (fUseCentralityBin == 0) && (centralityC!=0) ){
+           return kTRUE;
+       }
+        // 10-20%
+       if( (fUseCentralityBin == 1) && (centralityC!=1) ){ 
+           return kTRUE;
+       }
+        // 20-40%
+       if( (fUseCentralityBin == 2) && (centralityC!=2) && (centralityC!=3) ){ 
+           return kTRUE;
+       }
+       // 0-20%
+       if( (fUseCentralityBin == 3) && (centralityC!=0) && (centralityC!=1) ){ 
+           return kTRUE;
+       }
+       // 40-60%
+       if( (fUseCentralityBin == 4) && (centralityC!=4) && (centralityC!=5) ){ 
+           return kTRUE;
+       }
+       // 60-90%
+       if( (fUseCentralityBin == 6) && (centralityC!=6) && (centralityC!=7) && (centralityC!=8) ){ 
+           return kTRUE;
+       }
+        // 60-80%
+       if( (fUseCentralityBin == 7) && (centralityC!=6) && (centralityC!=7) ){ 
+           return kTRUE;
+       }
+       // 0-80%
+       if( (fUseCentralityBin == 8) && (centralityC>=8) ){ 
+           return kTRUE;
+       }
+       // 0-90%
+       if( (fUseCentralityBin == 9) && (centralityC>=9) ){
+             return kTRUE;
+       }
+    }
+    return kFALSE;
+}
+
+//-------------------------------------------------------------
+Bool_t AliConversionCuts::SetUseCentrality(Int_t useCentrality)
+{
+    // Set Cut
+    switch(useCentrality){
+    case 0:
+       fUseCentrality=0; // No Centrality Selection
+       break;
+    case 1:
+       fUseCentrality=1;//    GetCentralityClass10("V0M")
+       break;
+    case 2:
+       fUseCentrality=2; //    GetCentralityClass10("CL1")
+       break;
+    case 3://////////////// RRnew start //////////////////////////////////////////////////////////////////////////////////////////////////////
+       fUseCentrality=3;//    GetCentralityClass10("V0M") but with merged bins
+       break;
+    case 4:
+       fUseCentrality=4;//    GetCentralityClass10("CL1") but with merged bins
+       break;/////////////// RRnew end ////////////////////////////////////////////////////////////////////////////////////////////////////////
+    default:
+        cout<<"Warning: UseCentrality not defined "<<useCentrality<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+//-------------------------------------------------------------
+Bool_t AliConversionCuts::SetCentralityBin(Int_t centralityBin)
+{
+    // Set Cut
+    if(centralityBin<0||centralityBin>9){
+       cout<<"Warning: CentralityBin not defined "<<centralityBin<<endl;
+       return kFALSE;
+    }
+
+    fUseCentralityBin=centralityBin;
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetPhotonAsymmetryCut(Int_t doPhotonAsymmetryCut){
+    // Set Cut
+    switch(doPhotonAsymmetryCut){
+    case 0:
+       fDoPhotonAsymmetryCut=0;
+       fMinPPhotonAsymmetryCut=100.;
+       fMinPhotonAsymmetry=0.;
+       break;
+    case 1:
+       fDoPhotonAsymmetryCut=1;
+       fMinPPhotonAsymmetryCut=3.5;
+       fMinPhotonAsymmetry=0.04;
+       break;
+    case 2:
+       fDoPhotonAsymmetryCut=1;
+       fMinPPhotonAsymmetryCut=3.5;
+       fMinPhotonAsymmetry=0.06;
+       break;
+    default:
+        cout<<"Warning: PhotonAsymmetryCut not defined "<<doPhotonAsymmetryCut<<endl;
+       return kFALSE;
+    }
+    fCuts[kdoPhotonAsymmetryCut]=doPhotonAsymmetryCut;
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetBackgroundScheme(Int_t BackgroundScheme){
+    // Set Cut
+    switch(BackgroundScheme){
+    case 0: //Rotation
+       fUseRotationMethodInBG=kTRUE;
+       fdoBGProbability=kFALSE;
+       break;
+    case 1: // mixed event with track multiplicity
+       fUseRotationMethodInBG=kFALSE;
+       fUseTrackMultiplicityForBG=kFALSE;
+       fdoBGProbability=kFALSE;
+       break;
+    case 2: // mixed event with V0 multiplicity
+       fUseRotationMethodInBG=kFALSE;
+       fUseTrackMultiplicityForBG=kTRUE;
+       fdoBGProbability=kFALSE;
+       break;
+    case 3: //Rotation
+       fUseRotationMethodInBG=kTRUE;
+       fdoBGProbability=kTRUE;
+       break;
+    default:
+        cout<<"Warning: BackgroundScheme not defined "<<BackgroundScheme<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetNDegreesForRotationMethod(Int_t DegreesForRotationMethod){
+    // Set Cut
+    switch(DegreesForRotationMethod){
+    case 0:
+       fnDegreeRotationPMForBG = 5;
+       break;
+    case 1:
+       fnDegreeRotationPMForBG = 10;
+       break;
+    case 2:
+       fnDegreeRotationPMForBG = 15;
+       break;
+    case 3:
+       fnDegreeRotationPMForBG = 20;
+       break;
+    default:
+        cout<<"Warning: DegreesForRotationMethod not defined "<<DegreesForRotationMethod<<endl;
+       return kFALSE;
+    }
+    fCuts[kDegreesForRotationMethod]=DegreesForRotationMethod;
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetNumberOfRotations(Int_t NumberOfRotations)
+{   // Set Cut
+    switch(NumberOfRotations){
+    case 0:
+       fnumberOfRotationEventsForBG = 5;
+       break;
+    case 1:
+       fnumberOfRotationEventsForBG = 10;
+       break;
+    case 2:
+       fnumberOfRotationEventsForBG = 15;
+       break;
+    case 3:
+       fnumberOfRotationEventsForBG = 20;
+       break;
+    case 4:
+       fnumberOfRotationEventsForBG = 2;
+       break;
+    case 5:
+       fnumberOfRotationEventsForBG = 50;
+       break;
+    case 6:
+       fnumberOfRotationEventsForBG = 80;
+       break;
+    case 7:
+       fnumberOfRotationEventsForBG = 100;
+       break;
+    default:
+        cout<<"Warning: NumberOfRotations not defined "<<NumberOfRotations<<endl;
+       return kFALSE;
+    }
+    return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetPsiPairCut(Int_t psiCut) {
+  
+
+  switch(psiCut) {
+  case 0:
+       fPsiPairCut = 10000; // 
+       break;
+  case 1:
+       fPsiPairCut = 0.1; // 
+       break;
+  case 2:
+       fPsiPairCut = 0.05; // Standard
+       break;
+  case 3:
+       fPsiPairCut = 0.035; // 
+       break;
+  case 4:
+       fPsiPairCut = 0.15; // 
+       break;
+  case 5:
+       fPsiPairCut = 0.2; // 
+       break;
+  case 6:
+       fPsiPairCut = 0.03; // 
+       break;
+  case 7:
+       fPsiPairCut = 0.025; // 
+       break;
+  case 8:
+       fPsiPairCut = 0.01; // 
+       break;
+  default:
+      cout<<"Warning: PsiPairCut not defined "<<fPsiPairCut<<endl;
+      return kFALSE;
+  }
+
+  return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetCosPAngleCut(Int_t cosCut) {
+
+    switch(cosCut){
+    case 0:
+       fCosPAngleCut = 10000; //
+       break;
+    case 1:
+       fCosPAngleCut = 0.1; //
+       break;
+    case 2:
+       fCosPAngleCut = 0.05; //
+       break;
+    case 3:
+       fCosPAngleCut = 0.025; // Standard
+       break;
+    case 4:
+       fCosPAngleCut = 0.01; //
+       break;
+    default:
+       cout<<"Warning: Cosine Pointing Angle cut not defined "<<fCosPAngleCut<<endl;
+       return kFALSE;
+    }
+       
+    return kTRUE;
+}
+
+
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::VertexZCut(AliVEvent *event){
+    // Cut on z position of primary vertex
+     Double_t fVertexZ=event->GetPrimaryVertex()->GetZ();
+
+     if(TMath::Abs(fVertexZ)>fMaxVertexZ)return kFALSE;
+     return kTRUE;
+}
+
+
+
+
+///________________________________________________________________________
+
+Int_t AliConversionCuts::GetNumberOfContributorsVtx(AliVEvent *event){
+    // returns number of contributors to the vertex
+    
+    AliESDEvent *fESDEvent=dynamic_cast<AliESDEvent*>(event);
+    if(fESDEvent){
+       if(fESDEvent->GetPrimaryVertexTracks()->GetNContributors()>0) {
+           return fESDEvent->GetPrimaryVertexTracks()->GetNContributors();
+       }
+     
+       if(fESDEvent->GetPrimaryVertexTracks()->GetNContributors()<1) {
+           //          return 0;
+           //-AM test pi0s without SPD only vertex
+           if(fESDEvent->GetPrimaryVertexSPD()->GetNContributors()>0) {
+               return fESDEvent->GetPrimaryVertexSPD()->GetNContributors();
+
+           }
+           if(fESDEvent->GetPrimaryVertexSPD()->GetNContributors()<1) {
+               return 0;
+           }
+       }
+    }
+
+    AliAODEvent *fAODEvent=dynamic_cast<AliAODEvent*>(event);
+    if(fAODEvent){
+       if(fAODEvent->GetPrimaryVertex()->GetNContributors()>0) {
+           return fAODEvent->GetPrimaryVertex()->GetNContributors();
+       }
+       if(fAODEvent->GetPrimaryVertex()->GetNContributors()<1) {
+           if(fAODEvent->GetPrimaryVertexSPD()->GetNContributors()>0) {
+               return fAODEvent->GetPrimaryVertexSPD()->GetNContributors();
+           }
+           if(fAODEvent->GetPrimaryVertexSPD()->GetNContributors()<1) {
+               AliWarning(Form("Number of contributors from bad vertex type:: %s",fAODEvent->GetPrimaryVertex()->GetName()));
+               return 0;
+           }
+       }
+    }
+
+
+  return 0;
+}
+
+/*Bool_t IsTriggerSelected()
+{
+
+AliVEvent::IsTriggerClassFired ???
+
+    if(fTriggerAnalysis== NULL){
+               fTriggerAnalysis = new AliTriggerAnalysis;
+       }
+
+       //Take Only events with proper trigger
+
+       //      if(fTriggerCINT1B){
+        //       if(!fV0Reader->GetESDEvent()->IsTriggerClassFired("CINT1B-ABCE-NOPF-ALL")) return;
+        //       }
+
+       Bool_t v0A                       = fTriggerAnalysis->IsOfflineTriggerFired(fV0Reader->GetESDEvent(), AliTriggerAnalysis::kV0A);
+       Bool_t v0C                       = fTriggerAnalysis->IsOfflineTriggerFired(fV0Reader->GetESDEvent(), AliTriggerAnalysis::kV0C);
+       Bool_t v0AND = v0A && v0C;
+
+       if(fSelectV0AND && !v0AND){
+           return kTRUE;
+       }
+       
+       return kFALSE;
+} */
+
+///________________________________________________________________________
+Int_t AliConversionCuts::GetFirstTPCRow(Double_t radius){
+    // Get first TPC row
+       Int_t firstTPCRow=0;
+       Double_t radiusI        =       84.8;
+       Double_t radiusO        = 134.6;
+       Double_t radiusOB = 198.;
+       Double_t rSizeI  = 0.75;
+       Double_t rSizeO  = 1.;
+       Double_t rSizeOB        = 1.5;
+       Int_t nClsI=63;
+       Int_t nClsIO=127;
+
+       if(radius <= radiusI){
+               return firstTPCRow;
+       }
+       if(radius>radiusI && radius<=radiusO){
+               firstTPCRow = (Int_t)((radius-radiusI)/rSizeI);
+       }
+       if(radius>radiusO && radius<=radiusOB){
+               firstTPCRow = (Int_t)(nClsI+(radius-radiusO)/rSizeO);
+       }
+
+       if(radius>radiusOB){
+               firstTPCRow =(Int_t)(nClsIO+(radius-radiusOB)/rSizeOB);
+       }
+
+       return firstTPCRow;
+}
+
+Bool_t AliConversionCuts::CosinePAngleCut(const AliConversionPhotonBase * photon, const AliVEvent * event) const {
+  ///Check if passes cosine of pointing angle cut
+  //cout << "cpa " << GetCosineOfPointingAngle(photon, event) <<  " " << 1 - fCosPAngleCut << endl;
+  if(GetCosineOfPointingAngle(photon, event) < ( 1- fCosPAngleCut)) return kFALSE;
+  return kTRUE;
+}
+
+
+
+Double_t AliConversionCuts::GetCosineOfPointingAngle( const AliConversionPhotonBase * photon, const AliVEvent * event) const{
+   // calculates the pointing angle of the recalculated V0 
+
+  Double_t momV0[3] = { photon->GetPx(), photon->GetPy(), photon->GetPz() }; //momentum of the V0
+  Double_t PosV0[3] = { photon->GetConversionX() - event->GetPrimaryVertex()->GetX(), 
+                                               photon->GetConversionY() - event->GetPrimaryVertex()->GetY(), 
+                                               photon->GetConversionZ() - event->GetPrimaryVertex()->GetZ() }; //Recalculated V0 Position vector
+
+   Double_t momV02 = momV0[0]*momV0[0] + momV0[1]*momV0[1] + momV0[2]*momV0[2];
+   Double_t PosV02 = PosV0[0]*PosV0[0] + PosV0[1]*PosV0[1] + PosV0[2]*PosV0[2];
+
+   Double_t cosinePointingAngle = (PosV0[0]*momV0[0] +  PosV0[1]*momV0[1] + PosV0[2]*momV0[2] ) / TMath::Sqrt(momV02 * PosV02);
+  
+   return cosinePointingAngle;
+}
+
+
+Bool_t AliConversionCuts::PsiPairCut(const AliConversionPhotonBase * photon, const AliVEvent * event) const {
+  ///Cehck if passes psi pair cut, works for ESDs only
+  const AliESDEvent * esdEvent = dynamic_cast<const AliESDEvent*>(event);
+  if(!esdEvent) return kTRUE;
+  AliESDv0 * v0 = esdEvent->GetV0(photon->GetV0Index());
+  AliESDtrack * negTrack = esdEvent->GetTrack(photon->GetTrackLabel(0));
+  AliESDtrack * posTrack = esdEvent->GetTrack(photon->GetTrackLabel(0));
+  
+  if(v0 && negTrack && posTrack) {
+      if( GetPsiPair(v0, esdEvent) > fPsiPairCut)
+         return kFALSE;
+       else 
+         return kTRUE;
+  } else {
+       return kFALSE;
+  }
+}
+
+
+Double_t AliConversionCuts::GetPsiPair(const AliESDv0* v0, const AliESDEvent * event) const {
+    //
+    // Angle between daughter momentum plane and plane
+    //
+
+   Float_t magField = event->GetMagneticField();
+
+   Double_t xyz[3] = {0.,0.,0.};
+   v0->GetXYZ(xyz[0],xyz[1],xyz[2]);
+     
+   Double_t mn[3] = {0,0,0};
+   Double_t mp[3] = {0,0,0};
+  
+   v0->GetNPxPyPz(mn[0],mn[1],mn[2]);//reconstructed cartesian momentum components of negative daughter;
+   v0->GetPPxPyPz(mp[0],mp[1],mp[2]);//reconstructed cartesian momentum components of positive daughter; 
+
+   Double_t deltat = 1.;
+   deltat = TMath::ATan(mp[2]/(TMath::Sqrt(mp[0]*mp[0] + mp[1]*mp[1])+1.e-13)) -  TMath::ATan(mn[2]/(TMath::Sqrt(mn[0]*mn[0] + mn[1]*mn[1])+1.e-13));//difference of angles of the two daughter tracks with z-axis
+   Double_t radiussum = TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]) + 50;//radius to which tracks shall be propagated 
+   Double_t momPosProp[3] = {0,0,0};
+   Double_t momNegProp[3] = {0,0,0};
+    
+   AliExternalTrackParam nt = *(v0->GetParamN());
+   AliExternalTrackParam pt = *(v0->GetParamP());
+
+   Double_t psiPair = 4.;
+   if(nt.PropagateTo(radiussum,magField) == 0) return psiPair; //propagate tracks to the outside -> Better Purity and Efficiency
+   
+   if(pt.PropagateTo(radiussum,magField) == 0) return psiPair; //propagate tracks to the outside -> Better Purity and Efficiency
+  
+   pt.GetPxPyPz(momPosProp);//Get momentum vectors of tracks after propagation
+   nt.GetPxPyPz(momNegProp);
+
+   Double_t pEle =
+       TMath::Sqrt(momNegProp[0]*momNegProp[0]+momNegProp[1]*momNegProp[1]+momNegProp[2]*momNegProp[2]);//absolute momentum value of negative daughter
+
+   Double_t pPos =
+       TMath::Sqrt(momPosProp[0]*momPosProp[0]+momPosProp[1]*momPosProp[1]+momPosProp[2]*momPosProp[2]);//absolute momentum value of positive daughter
+
+   Double_t scalarproduct =
+       momPosProp[0]*momNegProp[0]+momPosProp[1]*momNegProp[1]+momPosProp[2]*momNegProp[2];//scalar product of propagated positive and negative daughters' momenta
+
+   Double_t chipair = TMath::ACos(scalarproduct/(pEle*pPos));//Angle between propagated daughter tracks
+
+   psiPair =  TMath::Abs(TMath::ASin(deltat/chipair));
+
+   return psiPair;
+}
+
+///________________________________________________________________________
+TString AliConversionCuts::GetCutNumber(){
+    // returns TString with current cut number
+  TString a(kNCuts);
+  for(Int_t ii=0;ii<kNCuts;ii++){
+       a.Append(Form("%d",fCuts[ii]));
+  }
+  return a;
+}
+
+
+
+///________________________________________________________________________
+AliConversionCuts* AliConversionCuts::GetStandardCuts2010PbPb(){
+    //Create and return standard 2010 PbPb cuts
+    AliConversionCuts *cuts=new AliConversionCuts("StandardCuts2010PbPb","StandardCuts2010PbPb");
+    if(!cuts->InitializeCutsFromCutString("9003972054506132212400010020000")){
+       cout<<"Warning: Initialization of Standardcuts2010PbPB failed"<<endl;}
+    return cuts;
+}
diff --git a/PWG4/GammaConv/AliConversionCuts.h b/PWG4/GammaConv/AliConversionCuts.h
new file mode 100644 (file)
index 0000000..9c71826
--- /dev/null
@@ -0,0 +1,332 @@
+#ifndef ALICONVERSIONCUTS_H
+#define ALICONVERSIONCUTS_H
+
+// Class handling all kinds of selection cuts for Gamma Conversion analysis
+// Authors: Svein Lindal, Daniel Lohner                                                                                                *
+
+#include "AliAODpidUtil.h"
+#include "AliConversionPhotonBase.h"
+#include "AliAODConversionMother.h"
+#include "AliAODTrack.h"
+#include "AliESDtrack.h"
+#include "AliVTrack.h"
+#include "AliAODTrack.h"
+#include "AliStack.h"
+#include "AliAnalysisCuts.h"
+
+class AliESDEvent;
+class AliAODEvent;
+class AliConversionPhotonBase;
+class AliKFVertex;
+class TH1F;
+class TH2F;
+class AliPIDResponse;
+class AliAnalysisCuts;
+class iostream;
+class TList;
+class AliAnalysisManager;
+
+
+using namespace std;
+
+class AliConversionCuts : public AliAnalysisCuts {
+       
+ public: 
+
+
+  enum cutIds {
+       kgoodId=0, 
+       kv0FinderType,                
+       keProbCut,                    
+       kededxSigmaCut,               
+       kpidedxSigmaCut,              
+       kpiMomdedxSigmaCut,           
+       kchi2GammaCut,                
+       ksinglePtCut,                 
+       kclsTPCCut,                   
+       ketaCut,                      
+       kchi2MesonCut,                
+       kLowPRejectionSigmaCut,       
+       kQtMaxCut,                    
+       kpiMaxMomdedxSigmaCut,        
+       kalphaMesonCut,               
+       kminRCut,                     
+       kRapidityMesonCut,            
+       kBackgroundScheme,            
+       kDegreesForRotationMethod,    
+       kNumberOfRotations,           
+       kremovePileUp,                
+       kselectV0AND,                 
+       kmultiplicityBin,             
+       kisHeavyIon,                  
+       kuseCentrality,               
+       kcentralityBin,               
+       kTOFelectronPID,              
+       kuseMCPSmearing,              
+       kdoPhotonAsymmetryCut,
+       kPsiPair, 
+       kCosPAngle,
+     //   kHBTmultiplicityBin,
+     //   kprimaryCutNumber,
+     //   kuseBayesPID,
+     //   kdalitzelectronsPID,
+     //   kpsiCutNumber,
+     //   kdalitzBackgroundType,
+     //   keleclsTPCCut,
+       kNCuts
+  };
+
+  Bool_t SetCutIds(TString cutString); 
+  Int_t fCuts[kNCuts];
+  Bool_t SetCut(cutIds cutID, Int_t cut);
+  Bool_t UpdateCutString(cutIds cutID, Int_t value);
+
+
+  static const char * fgkCutNames[kNCuts];
+
+  Double_t GetPsiPair(const AliESDv0* v0, const AliESDEvent * event) const;
+  Double_t GetCosineOfPointingAngle(const AliConversionPhotonBase * photon, const AliVEvent * event) const; 
+
+
+  Bool_t InitializeCutsFromCutString(const TString analysisCutSelection);
+
+  AliConversionCuts(const char *name="V0Cuts", const char * title="V0 Cuts");
+  virtual ~AliConversionCuts();                            //virtual destructor
+
+  virtual Bool_t IsSelected(TObject* /*obj*/){return kTRUE;}
+  virtual Bool_t IsSelected(TList* /*list*/) {return kTRUE;}
+
+  TString GetCutNumber();
+
+  // Cut Selection
+  Bool_t EventIsSelected(AliVEvent *fInputEvent);
+  Bool_t PhotonIsSelected(AliConversionPhotonBase * photon, AliVEvent  * event,Bool_t DoOnlyPhotonCuts=kFALSE);
+  Bool_t PhotonIsSelectedMC(TParticle *particle,AliStack *fMCStack);
+  Bool_t TracksAreSelected(AliVTrack * negTrack, AliVTrack * posTrack);
+  Bool_t MesonIsSelected(AliAODConversionMother *pi0,Bool_t IsSignal=kTRUE);
+  Bool_t MesonIsSelectedMC(TParticle *fMCMother,AliStack *fMCStack,Bool_t bMCDaughtersInAcceptance=kFALSE);
+
+  void InitAODpidUtil(Int_t type);
+  static AliConversionCuts * GetStandardCuts2010PbPb();
+  Bool_t InitPIDResponse();
+  
+  void SetPIDResponse(AliPIDResponse * pidResponse) {fPIDResponse = pidResponse;}
+  AliPIDResponse * GetPIDResponse() { return fPIDResponse;}
+  
+  void PrintCuts();
+
+  void InitCutHistograms();
+  void SetFillCutHistograms(){if(!fHistograms){InitCutHistograms();};}
+  TList *GetCutHistograms(){return fHistograms;}
+
+  AliVTrack * GetTrack(AliVEvent * event, Int_t label) const;
+
+  ///Cut functions
+  Bool_t SpecificTrackCuts(AliAODTrack * negTrack, AliAODTrack * posTrack,Int_t &cutIndex);
+  Bool_t SpecificTrackCuts(AliESDtrack * negTrack, AliESDtrack * posTrack,Int_t &cutIndex);
+  Bool_t AcceptanceCuts(AliConversionPhotonBase *photon);
+  Bool_t AcceptanceCut(TParticle *particle, TParticle * ePos,TParticle* eNeg);
+  Bool_t dEdxCuts(AliVTrack * track);
+  Bool_t ArmenterosQtCut(AliConversionPhotonBase *photon);
+  Bool_t AsymmetryCut(AliConversionPhotonBase *photon,AliVEvent *event);
+  Bool_t PIDProbabilityCut(AliConversionPhotonBase *photon, AliVEvent * event);
+  Bool_t SelectV0Finder(Bool_t onfly){return onfly&&fUseOnFlyV0Finder;}
+  Bool_t PhotonCuts(AliConversionPhotonBase *photon,AliVEvent *event);
+  Bool_t CorrectedTPCClusterCut(AliConversionPhotonBase *photon, AliVEvent * event);
+  Bool_t PsiPairCut(const AliConversionPhotonBase * photon, const AliVEvent * event) const;
+  Bool_t CosinePAngleCut(const AliConversionPhotonBase * photon, const AliVEvent * event) const;
+  // Event Cuts
+  Bool_t IsCentralitySelected(AliVEvent *fInputEvent);
+  Double_t GetCentrality(AliVEvent *event);
+  Int_t GetNumberOfContributorsVtx(AliVEvent *event);
+  Bool_t VertexZCut(AliVEvent *fInputEvent);
+
+  // Set Individual Cuts
+  Bool_t SetRCut(Int_t RCut);
+  Bool_t SetV0Finder(Int_t v0FinderType);
+  Bool_t SetElectronProbCut(Int_t eProbCut);
+  Bool_t SetChi2GammaCut(Int_t chi2GammaCut);
+  Bool_t SetTPCdEdxCutPionLine(Int_t pidedxSigmaCut);
+  Bool_t SetTPCdEdxCutElectronLine(Int_t ededxSigmaCut);
+  Bool_t SetSinglePtCut(Int_t singlePtCut);
+  Bool_t SetTPCClusterCut(Int_t clsTPCCut);
+  Bool_t SetEtaCut(Int_t etaCut);
+  Bool_t SetChi2MesonCut(Int_t chi2MesonCut);
+  Bool_t SetMinMomPiondEdxCut(Int_t piMinMomdedxSigmaCut);
+  Bool_t SetMaxMomPiondEdxCut(Int_t piMaxMomdedxSigmaCut);
+  Bool_t SetLowPRejectionCuts(Int_t LowPRejectionSigmaCut);
+  Bool_t SetQtMaxCut(Int_t QtMaxCut);
+  Bool_t SetAlphaMesonCut(Int_t alphaMesonCut);
+  Bool_t SetTOFElectronPIDCut(Int_t TOFelectronPID);
+  Bool_t SetTRDElectronCut(Int_t TRDElectronCut);
+  Bool_t SetRapidityMesonCut(Int_t RapidityMesonCut);
+  Bool_t SetUseCentrality(Int_t useCentrality);
+  Bool_t SetIsHeavyIon(Int_t isHeavyIon);
+  Bool_t SetCentralityBin(Int_t centralityBin);
+  Bool_t SetPhotonAsymmetryCut(Int_t doPhotonAsymmetryCut);
+  Bool_t SetRemovePileUp(Int_t removePileUp);
+  Bool_t SetBackgroundScheme(Int_t BackgroundScheme);
+  Bool_t SetNDegreesForRotationMethod(Int_t DegreesForRotationMethod);
+  Bool_t SetNumberOfRotations(Int_t NumberOfRotations);
+  Bool_t SetMCPSmearing(Int_t useMCPSmearing);
+  Bool_t SetMultiplicityBin(Int_t multiplicityBin);
+  Bool_t SetSelectV0AND(Int_t selectV0AND);
+  Bool_t SetCosPAngleCut(Int_t cosCut);
+  Bool_t SetPsiPairCut(Int_t psiCut);
+
+  // Request Flags
+
+  Bool_t UseRotationMethod(){return fUseRotationMethodInBG;}
+  Int_t NumberOfRotationEvents(){return fnumberOfRotationEventsForBG;}
+  Int_t NDegreesRotation(){return fnDegreeRotationPMForBG;}
+  Bool_t IsHeavyIon(){return fIsHeavyIon;}
+  Bool_t UseTrackMultiplicity(){return fUseTrackMultiplicityForBG;}
+
+
+  Int_t GetFirstTPCRow(Double_t radius);
+  
+
+  protected:
+  TList *fHistograms;
+  AliPIDResponse *fPIDResponse;
+
+  //cuts
+  Double_t fMaxR; //r cut
+  Double_t fMinR; //r cut
+  Double_t fEtaCut; //eta cut
+  Double_t fEtaCutMin; //eta cut
+  Double_t fPtCut; // pt cut
+  Double_t fSinglePtCut; // pt cut for electron/positron
+  Double_t fMaxZ; //z cut
+  Double_t fMinClsTPC; // minimum clusters in the TPC
+  Double_t fMinClsTPCToF; // minimum clusters to findable clusters
+  Double_t fLineCutZRSlope; //linecut
+  Double_t fLineCutZValue; //linecut
+  Double_t fLineCutZRSlopeMin; //linecut
+  Double_t fLineCutZValueMin; //linecut
+  Double_t fChi2CutConversion; //chi2cut
+  Double_t fChi2CutMeson; //chicut meson
+  Double_t fPIDProbabilityCutNegativeParticle;
+  Double_t fPIDProbabilityCutPositiveParticle;
+  Bool_t   fDodEdxSigmaCut; // flag to use the dEdxCut based on sigmas
+  Bool_t   fDoTOFsigmaCut; // flag to use TOF pid cut RRnewTOF
+  Double_t fPIDTRDEfficiency; // required electron efficiency for TRD PID
+  Bool_t   fDoTRDPID; // flag to use TRD pid
+  Double_t fPIDnSigmaAboveElectronLine; // sigma cut
+  Double_t fPIDnSigmaBelowElectronLine; // sigma cut
+  Double_t fTofPIDnSigmaAboveElectronLine; // sigma cut RRnewTOF
+  Double_t fTofPIDnSigmaBelowElectronLine; // sigma cut RRnewTOF 
+  Double_t fPIDnSigmaAbovePionLine;     // sigma cut
+  Double_t fPIDnSigmaAbovePionLineHighPt;     // sigma cut
+  Double_t fPIDMinPnSigmaAbovePionLine; // sigma cut
+  Double_t fPIDMaxPnSigmaAbovePionLine; // sigma cut
+  Double_t fDoKaonRejectionLowP;   // Kaon rejection at low p
+  Double_t fDoProtonRejectionLowP; // Proton rejection at low p
+  Double_t fDoPionRejectionLowP;   // Pion rejection at low p
+  Double_t fPIDnSigmaAtLowPAroundKaonLine; // sigma cut
+  Double_t fPIDnSigmaAtLowPAroundProtonLine; // sigma cut
+  Double_t fPIDnSigmaAtLowPAroundPionLine; // sigma cut
+  Double_t fPIDMinPKaonRejectionLowP; // Momentum limit to apply kaon rejection
+  Double_t fPIDMinPProtonRejectionLowP; // Momentum limit to apply proton rejection
+  Double_t fPIDMinPPionRejectionLowP; // Momentum limit to apply proton rejection
+  Bool_t   fDoQtGammaSelection; // Select gammas using qtMax
+  Bool_t   fDoHighPtQtGammaSelection; // RRnew Select gammas using qtMax for high pT
+  Double_t fQtMax; // Maximum Qt from Armenteros to select Gammas
+  Double_t fHighPtQtMax; // RRnew Maximum Qt for High pT from Armenteros to select Gammas
+  Double_t fPtBorderForQt; // RRnew 
+  Double_t fXVertexCut; //vertex cut
+  Double_t fYVertexCut; //vertex cut
+  Double_t fZVertexCut; // vertexcut
+  Double_t fNSigmaMass; //nsigma cut
+  Bool_t fUseEtaMinCut; //flag
+  Bool_t fUseOnFlyV0Finder; //flag
+  Bool_t   fDoPhotonAsymmetryCut; // flag to use the PhotonAsymetryCut
+  Double_t fMinPPhotonAsymmetryCut; // Min Momentum for Asymmetry Cut
+  Double_t fMinPhotonAsymmetry;  // Asymmetry Cut
+  Bool_t fIsHeavyIon;               // flag for heavy ion
+  Double_t fMaxVertexZ;    // max z offset of vertex
+  Bool_t fUseCentrality;  // centrality selection
+  Bool_t fUseCentralityBin; // centrality selection with individual bins
+  Bool_t fUseCorrectedTPCClsInfo; // flag to use corrected tpc cl info
+  Bool_t fUseTOFpid; // flag to use tof pid
+  Double_t fAlphaMinCutMeson; // min value for meson alpha cut
+  Double_t fAlphaCutMeson; // max value for meson alpha cut
+  Double_t fRapidityCutMeson; // max value for meson rapidity
+  Bool_t fUseRotationMethodInBG; // flag to apply rotation method for meson bg estimation
+  Bool_t fdoBGProbability; // flag to use probability method for meson bg estimation
+  Bool_t fUseTrackMultiplicityForBG; // flag to use track multiplicity for meson bg estimation (else V0 mult)
+  Int_t fnDegreeRotationPMForBG; //
+  Int_t fnumberOfRotationEventsForBG; //
+  Bool_t fUseMCPSmearing; // flag
+  Double_t fPBremSmearing;//
+  Double_t fPSigSmearing; //
+  Double_t fPSigSmearingCte; //
+  Bool_t fUseMultiplicity; // flag
+  Int_t fUseMultiplicityBin; // selected multiplicity bin
+  Bool_t fSelectV0AND; // flag
+  Bool_t fRemovePileUp; //flag
+  Float_t fOpeningAngle; // min opening angle for meson
+  Float_t fPsiPairCut;
+  Float_t fCosPAngleCut;
+
+  // Histograms
+  TObjString *fCutString; // cut number used for analysis
+  TH1F *hdEdxCuts;  // bookkeeping for dEdx cuts
+  TH2F *hTPCdEdxbefore; // TPC dEdx before cuts
+  TH2F *hTPCdEdxafter; // TPC dEdx after cuts
+  TH1F *hTrackCuts; // bookkeeping for track cuts
+  TH1F *hPhotonCuts; // bookkeeping for photon specific cuts
+  TH1F *hInvMassbefore; // e+e- inv mass distribution before cuts
+  TH2F *hArmenterosbefore; // armenteros podolanski plot before cuts
+  TH1F *hInvMassafter; // e+e- inv mass distribution after cuts
+  TH2F *hArmenterosafter;  // armenteros podolanski plot after cuts
+  TH1F *hAcceptanceCuts; // bookkeeping for acceptance cuts
+  TH1F *hCutIndex; // bookkeeping for cuts
+  TH1F *hV0EventCuts; // bookkeeping for event selection cuts
+  TH1F *hCentrality; // centrality distribution for selected events
+  TH1F *hVertexZ; // vertex z distribution for selected events
+  TH1F *hMesonCuts; // bookkeeping for meson cuts
+  TH1F *hMesonBGCuts; // bookkeeping for meson bg cuts
+
+
+private:
+
+  AliConversionCuts(const AliConversionCuts&); // not implemented
+  AliConversionCuts& operator=(const AliConversionCuts&); // not implemented
+
+
+  ClassDef(AliConversionCuts,2)
+};
+
+
+inline void AliConversionCuts::InitAODpidUtil(Int_t type) {
+  if (!fPIDResponse) fPIDResponse = new AliAODpidUtil();
+  Double_t alephParameters[5];
+  // simulation
+  alephParameters[0] = 2.15898e+00/50.;
+  alephParameters[1] = 1.75295e+01;
+  alephParameters[2] = 3.40030e-09;
+  alephParameters[3] = 1.96178e+00;
+  alephParameters[4] = 3.91720e+00;
+  fPIDResponse->GetTOFResponse().SetTimeResolution(80.);
+  
+  // data
+  if (type==1){
+    alephParameters[0] = 0.0283086/0.97;
+    alephParameters[1] = 2.63394e+01;
+    alephParameters[2] = 5.04114e-11;
+    alephParameters[3] = 2.12543e+00;
+    alephParameters[4] = 4.88663e+00;
+    fPIDResponse->GetTOFResponse().SetTimeResolution(130.);
+    fPIDResponse->GetTPCResponse().SetMip(50.);
+  }
+  
+  fPIDResponse->GetTPCResponse().SetBetheBlochParameters(
+    alephParameters[0],alephParameters[1],alephParameters[2],
+    alephParameters[3],alephParameters[4]);
+  
+  fPIDResponse->GetTPCResponse().SetSigma(3.79301e-03, 2.21280e+04);
+}
+
+
+#endif
index 0cdd372e63c08f9d2b0ce101fbbff6b5aa3e3ee3..84b9dec4d3a423bbd75e986ef956da77fd50848e 100644 (file)
@@ -6,10 +6,10 @@ using namespace std;
 ClassImp(AliConversionPhotonBase)
 
 AliConversionPhotonBase::AliConversionPhotonBase() :
-    fV0Index(-1),
-    fChi2perNDF(-1),
-    fTagged(kFALSE)
-
+fV0Index(-1),
+  fChi2perNDF(-1),
+  fTagged(kFALSE),
+  fIMass(-999)
 {
   //Default constructor
   fLabel[0] = -1;
@@ -25,19 +25,14 @@ AliConversionPhotonBase::AliConversionPhotonBase() :
   fConversionPoint[0]=-999;
   fConversionPoint[1]=-999;
   fConversionPoint[2]=-999;
-
-  for(Int_t i=0;i<5;i++){
-      fNSigmadEdxPositive[i]=-999;
-      fNSigmadEdxNegative[i]=-999;
-  }
 }
 
 
 AliConversionPhotonBase::AliConversionPhotonBase(const AliConversionPhotonBase & original) :
 fV0Index(original.fV0Index),
 fChi2perNDF(original.fChi2perNDF),
-fTagged(original.fTagged)
-
+fTagged(original.fTagged),
+  fIMass(original.fIMass)
   {
   //Copy constructor
   fLabel[0] = original.fLabel[0];
@@ -53,8 +48,6 @@ fTagged(original.fTagged)
   fConversionPoint[1]=original.fConversionPoint[1];
   fConversionPoint[2]=original.fConversionPoint[2];
 
-  for(Int_t i=0;i<5;i++){fNSigmadEdxNegative[i]=original.fNSigmadEdxNegative[i];}
-  for(Int_t i=0;i<5;i++){fNSigmadEdxPositive[i]=original.fNSigmadEdxPositive[i];}
   }
 
 AliConversionPhotonBase::~AliConversionPhotonBase() {
@@ -91,9 +84,10 @@ Int_t AliConversionPhotonBase::GetMCParticleLabel(AliStack *fMCStack){
 
     if(fPositiveMCParticle->GetMother(0)>-1&&(fNegativeMCParticle->GetMother(0) == fPositiveMCParticle->GetMother(0))){
 
-        return fPositiveMCParticle->GetMother(0);
+           return fPositiveMCParticle->GetMother(0);
     }
- return -1;
+
+    return -1;
 }
 
 
index a7b19849584c0816aa80e1c0e58929b8c8fe21a8..af880338d7c231c07afa8f85c593554440099f6e 100644 (file)
@@ -39,6 +39,9 @@ class AliConversionPhotonBase {
   Int_t GetTrackLabelPositive() const{return fLabel[0];}
   Int_t GetTrackLabelNegative() const {return fLabel[1];}
   Int_t GetTrackLabel(Int_t i) const {return fLabel[i];}
+  virtual Int_t GetLabel(Int_t i) const { return GetTrackLabel(i); };
+  virtual Int_t GetLabel1() const { return GetTrackLabelPositive(); };
+  virtual Int_t GetLabel2() const { return GetTrackLabelNegative(); };
 
   // MC Label
 
@@ -58,28 +61,21 @@ class AliConversionPhotonBase {
   TParticle *GetMCDaughter(AliStack *fMCStack,Int_t label);
 
   // V0Index
-  Int_t GetV0Index(){return fV0Index;}
-  void SetV0Index(Int_t index){fV0Index=index;}
+  Int_t GetV0Index() const {return fV0Index;}
+  void SetV0Index(Int_t index) {fV0Index=index;}
 
   // Conversion Point
    void SetConversionPoint(Double_t convpoint[3]){fConversionPoint[0]=convpoint[0];fConversionPoint[1]=convpoint[1];fConversionPoint[2]=convpoint[2];}
   void GetConversionPoint(Double_t convpoint[3]){convpoint[0]=fConversionPoint[0];convpoint[1]=fConversionPoint[1];convpoint[2]=fConversionPoint[2];}
-  Double_t GetConversionRadius(){return TMath::Sqrt(fConversionPoint[0]*fConversionPoint[0]+fConversionPoint[1]*fConversionPoint[1]);}
-  Double_t GetConversionX(){return fConversionPoint[0];}
-  Double_t GetConversionY(){return fConversionPoint[1];}
-  Double_t GetConversionZ(){return fConversionPoint[2];}
+  Double_t GetConversionRadius() const {return TMath::Sqrt(fConversionPoint[0]*fConversionPoint[0]+fConversionPoint[1]*fConversionPoint[1]);}
+  Double_t GetConversionX() const {return fConversionPoint[0];}
+  Double_t GetConversionY() const {return fConversionPoint[1];}
+  Double_t GetConversionZ() const {return fConversionPoint[2];}
 
   // Armenteros Qt Alpha
   void GetArmenterosQtAlpha(Double_t qtalpha[2]){qtalpha[0]=fArmenteros[0];qtalpha[1]=fArmenteros[1];}
-  Double_t GetArmenterosQt(){return fArmenteros[0];}
-  Double_t GetArmenterosAlpha(){return fArmenteros[1];}
-
-  // dEdx
-  void SetNSigmadEdx(Float_t positive[5],Float_t negative[5]){for(Int_t jj=0;jj<5;jj++){fNSigmadEdxPositive[jj]=positive[jj];fNSigmadEdxNegative[jj]=negative[jj];}}
-  void GetNSigmadEdx(Float_t positive[5],Float_t negative[5]){for(Int_t jj=0;jj<5;jj++){positive[jj]=fNSigmadEdxPositive[jj];negative[jj]=fNSigmadEdxNegative[jj];}}
-  Float_t GetNSigmadEdxPositive(Int_t species){return fNSigmadEdxPositive[species];}
-  Float_t GetNSigmadEdxNegative(Int_t species){return fNSigmadEdxNegative[species];}
-  Float_t GetNSigmadEdx(Int_t label,Int_t species){if(label==0){return fNSigmadEdxPositive[species];}if(label==1){return fNSigmadEdxNegative[species];}printf("label not defined");;return 1000;}
+  Double_t GetArmenterosQt() const {return fArmenteros[0];}
+  Double_t GetArmenterosAlpha() const {return fArmenteros[1];}
 
   // virtual functions to be implemented in KF/AOD classes
 
@@ -88,6 +84,13 @@ class AliConversionPhotonBase {
   virtual Double_t GetPhotonP() const = 0;
   virtual Double_t GetPhotonEta() const = 0;
   virtual Double_t GetPhotonPhi() const =0;
+  virtual Double_t GetPx() const = 0;
+  virtual Double_t GetPy() const = 0;
+  virtual Double_t GetPz() const = 0;
+
+
+  Float_t GetMass() const { return fIMass; }
+  void SetMass( Float_t mass) { fIMass = mass; }
 
 
  protected:
@@ -97,12 +100,12 @@ class AliConversionPhotonBase {
   Int_t fMCLabel[2]; // Electron/Positron MC Label
   Float_t fChi2perNDF; // Chi2perNDF
   Double_t fArmenteros[2]; // Armenteros Paramters
-  Float_t fNSigmadEdxPositive[5]; // N Sigma to lines
-  Float_t fNSigmadEdxNegative[5]; // N Sigma to lines
   Double_t fConversionPoint[3]; // Conversion Point
   Bool_t fTagged; // Is it tagged as decay pion (only for gammas)
+  Float_t fIMass;
+
 
-  ClassDef(AliConversionPhotonBase,1)
+  ClassDef(AliConversionPhotonBase,2);
 };
 
 
index 6f62e2fabb04cfe6c31cdfc39b92de3db1bdadac..89b499ed4a5f94f428425ad012cd0bdcbb2edcbd 100644 (file)
@@ -35,28 +35,29 @@ ClassImp(AliGammaConversionHistograms)
 
 
 AliGammaConversionHistograms::AliGammaConversionHistograms() :
-  fHistogramMap(new TMap()),
-  fNPhiIndex(0),
-  fNRIndex(0),
-  fNZIndex(0),
-//  fRBinLimits(0),
-//  fZBinLimits(0),
-  fMinRadius(0.),
-  fMaxRadius(0.),
-  fDeltaR(0.),
-  fMinPhi(0.),
-  fMaxPhi(0.),
-  fDeltaPhi(0.),
-  fMappingContainer(NULL),
-  fBackgroundContainer(NULL),
-  fDebugContainer(NULL),
-  fResolutionContainer(NULL),
-  fMatchContainer(NULL),
-  fESDContainer(NULL),
-  fMCContainer(NULL),
-  fTableContainer(NULL),       
-  fOtherContainer(NULL),
-  f3DContainer(NULL)
+       fHistogramMap(new TMap()),
+       fNPhiIndex(0),
+       fNRIndex(0),
+       fNZIndex(0),
+       //  fRBinLimits(0),
+       //  fZBinLimits(0),
+       fMinRadius(0.),
+       fMaxRadius(0.),
+       fDeltaR(0.),
+       fMinPhi(0.),
+       fMaxPhi(0.),
+       fDeltaPhi(0.),
+       fMappingContainer(NULL),
+       fBackgroundContainer(NULL),
+       fDebugContainer(NULL),
+       fResolutionContainer(NULL),
+       fMatchContainer(NULL),
+       fESDContainer(NULL),
+       fMCContainer(NULL),
+       fTableContainer(NULL),  
+       fOtherContainer(NULL),
+       f3DContainer(NULL),
+       fHadContainer(NULL)
 {
   // see header file for documenation
   for(Int_t i=0;i<14;i++){
@@ -69,36 +70,37 @@ AliGammaConversionHistograms::AliGammaConversionHistograms() :
 
 
 AliGammaConversionHistograms::AliGammaConversionHistograms(const AliGammaConversionHistograms & original) :
-  fHistogramMap(original.fHistogramMap),
-  fNPhiIndex(original.fNPhiIndex),
-  fNRIndex(original.fNRIndex),
-  fNZIndex(original.fNZIndex),
-  //  fRBinLimits(original.fRBinLimits),
-  //  fZBinLimits(original.fZBinLimits),
-  fMinRadius(original.fMinRadius),
-  fMaxRadius(original.fMaxRadius),
-  fDeltaR(original.fDeltaR),
-  fMinPhi(original.fMinPhi),
-  fMaxPhi(original.fMaxPhi),
-  fDeltaPhi(original.fDeltaPhi),
-  fMappingContainer(original.fMappingContainer),
-  fBackgroundContainer(original.fBackgroundContainer),
-  fDebugContainer(original.fDebugContainer),
-  fResolutionContainer(original.fResolutionContainer),
-  fMatchContainer(original.fMatchContainer),
-  fESDContainer(original.fESDContainer),
-  fMCContainer(original.fMCContainer),
-  fTableContainer(original.fTableContainer), 
-  fOtherContainer(original.fOtherContainer),
-  f3DContainer(original.f3DContainer)
-{    
-  //see header file for documentation
-  for(Int_t i=0;i<14;i++){
-    fRBinLimits[i]= original.fRBinLimits[i];
-  }
-  for(Int_t i=0;i<12;i++){
-    fZBinLimits[i]=original.fZBinLimits[i];
-  }
+       fHistogramMap(original.fHistogramMap),
+       fNPhiIndex(original.fNPhiIndex),
+       fNRIndex(original.fNRIndex),
+       fNZIndex(original.fNZIndex),
+       //  fRBinLimits(original.fRBinLimits),
+       //  fZBinLimits(original.fZBinLimits),
+       fMinRadius(original.fMinRadius),
+       fMaxRadius(original.fMaxRadius),
+       fDeltaR(original.fDeltaR),
+       fMinPhi(original.fMinPhi),
+       fMaxPhi(original.fMaxPhi),
+       fDeltaPhi(original.fDeltaPhi),
+       fMappingContainer(original.fMappingContainer),
+       fBackgroundContainer(original.fBackgroundContainer),
+       fDebugContainer(original.fDebugContainer),
+       fResolutionContainer(original.fResolutionContainer),
+       fMatchContainer(original.fMatchContainer),
+       fESDContainer(original.fESDContainer),
+       fMCContainer(original.fMCContainer),
+       fTableContainer(original.fTableContainer), 
+       fOtherContainer(original.fOtherContainer),
+       f3DContainer(original.f3DContainer),
+       fHadContainer(original.fHadContainer)
+       {    
+       //see header file for documentation
+       for(Int_t i=0;i<14;i++){
+               fRBinLimits[i]= original.fRBinLimits[i];
+       }
+       for(Int_t i=0;i<12;i++){
+               fZBinLimits[i]=original.fZBinLimits[i];
+       }
 }
 
 
@@ -313,6 +315,16 @@ void AliGammaConversionHistograms::FillHistogram(TString histogramName, Double_t
   }
 }
 
+void AliGammaConversionHistograms::FillHistogram(TString histogramName, Float_t* xValue, Int_t nPoints) const{
+       //see header file for documentation
+       TH1 *tmp = (TH1*)fHistogramMap->GetValue(histogramName.Data());
+       if(tmp){
+               for( Int_t ii = 1; ii < nPoints+1; ii++){                 
+                       tmp->SetBinContent(ii,xValue[ii]);
+               }
+       }
+}
+
 void AliGammaConversionHistograms::FillHistogram(TString histogramName, Double_t xValue, Double_t yValue) const{
   //see header file for documentation
   TH1 *tmp = (TH1*)fHistogramMap->GetValue(histogramName.Data());
@@ -339,130 +351,138 @@ TObject* AliGammaConversionHistograms::GetValue(const TString& name)
 void AliGammaConversionHistograms::GetOutputContainer(TList *fOutputContainer){
   //checking if the container is alrerady created
        
-  if(fOutputContainer == NULL){
-    cout<<"WARNING: GetOutputContainer: output container object is NULL"<<endl;
-    return;
-  }
-
-  if(fHistogramMap != NULL){
-    TIter iter(fHistogramMap);
-    TObjString *histogramName;
-    while ((histogramName = (TObjString*) iter.Next())) {
-      TString histogramString = histogramName->GetString();
-      if(histogramString.Contains("Mapping")){// means it should be put in the mapping folder
-       if(fMappingContainer == NULL){
-         fMappingContainer = new TList();
-         fMappingContainer->SetOwner(kTRUE);
-         fMappingContainer->SetName("Mapping histograms");
-       }
-       fMappingContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
-      }
-      else if(histogramString.Contains("Background")){// means it should be put in the background folder
-       if(fBackgroundContainer == NULL){
-         fBackgroundContainer = new TList();
-         fBackgroundContainer->SetOwner(kTRUE);
-         fBackgroundContainer->SetName("Background histograms");
+       if(fOutputContainer == NULL){
+               cout<<"WARNING: GetOutputContainer: output container object is NULL"<<endl;
+               return;
        }
-       fBackgroundContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
-      }
-      else if(histogramString.Contains("Debug")){// means it should be put in the debug folder
-       if(fDebugContainer == NULL){
-         fDebugContainer = new TList();
-         fDebugContainer->SetOwner(kTRUE);
-         fDebugContainer->SetName("Debug histograms");
-       }
-       fDebugContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
-      }
-      else if(histogramString.Contains("Resolution")){// means it should be put in the resolution folder
-       if(fResolutionContainer == NULL){
-         fResolutionContainer = new TList();
-         fResolutionContainer->SetOwner(kTRUE);
-         fResolutionContainer->SetName("Resolution histograms");
-       }
-       fResolutionContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
-      }
-      else if(histogramString.Contains("TrueConv")){// means it should be put in the true conv folder
-       if(fMatchContainer == NULL){
-         fMatchContainer = new TList();
-         fMatchContainer->SetOwner(kTRUE);
-         fMatchContainer->SetName("True conversion histograms");
-       }
-       fMatchContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
-      }
-      else if(histogramString.Contains("ESD")){// means it should be put in the ESD folder
-       if(fESDContainer == NULL){
-         fESDContainer = new TList();
-         fESDContainer->SetOwner(kTRUE);
-         fESDContainer->SetName("ESD histograms");
-       }
-       fESDContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
-      }
-      else if(histogramString.Contains("MC")){// means it should be put in the MC folder
-       if(fMCContainer == NULL){
-         fMCContainer = new TList();
-         fMCContainer->SetOwner(kTRUE);
-         fMCContainer->SetName("MC histograms");
-       }
-       fMCContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
-      }
-      else if(histogramString.Contains("Table")){// means it should be put in the Table Folder
-       if(fTableContainer == NULL){
-          fTableContainer = new TList();
-          fTableContainer->SetOwner(kTRUE);
-          fTableContainer->SetName("Tables");
-       }
-       fTableContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
-      }
-       else if(histogramString.Contains("3DPlots")){// means it should be put in the Table Folder
-               if(f3DContainer == NULL){
-                       f3DContainer = new TList();
-                       f3DContainer->SetOwner(kTRUE);
-                       f3DContainer->SetName("3D histograms");
+
+       if(fHistogramMap != NULL){
+               TIter iter(fHistogramMap);
+               TObjString *histogramName;
+               while ((histogramName = (TObjString*) iter.Next())) {
+                       TString histogramString = histogramName->GetString();
+                       if(histogramString.Contains("Mapping")){// means it should be put in the mapping folder
+                               if(fMappingContainer == NULL){
+                                       fMappingContainer = new TList();
+                                       fMappingContainer->SetOwner(kTRUE);
+                                       fMappingContainer->SetName("Mapping histograms");
+                               }
+                               fMappingContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+                       } else if(histogramString.Contains("HadInt")){// means it should be put in the Table Folder
+                               if(fHadContainer == NULL){
+                                       fHadContainer = new TList();
+                                       fHadContainer->SetOwner(kTRUE);
+                                       fHadContainer->SetName("Hadronic Interactions histograms");
+                               }
+                               fHadContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));      
+                       } else if(histogramString.Contains("Background")){// means it should be put in the background folder
+                               if(fBackgroundContainer == NULL){
+                                       fBackgroundContainer = new TList();
+                                       fBackgroundContainer->SetOwner(kTRUE);
+                                       fBackgroundContainer->SetName("Background histograms");
+                               }
+                               fBackgroundContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+                       } else if(histogramString.Contains("Debug")){// means it should be put in the debug folder
+                               if(fDebugContainer == NULL){
+                                       fDebugContainer = new TList();
+                                       fDebugContainer->SetOwner(kTRUE);
+                                       fDebugContainer->SetName("Debug histograms");
+                               }
+                               fDebugContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+                       } else if(histogramString.Contains("Resolution")){// means it should be put in the resolution folder
+                               if(fResolutionContainer == NULL){
+                                       fResolutionContainer = new TList();
+                                       fResolutionContainer->SetOwner(kTRUE);
+                                       fResolutionContainer->SetName("Resolution histograms");
+                               }
+                               fResolutionContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+                       } else if(histogramString.Contains("TrueConv")){// means it should be put in the true conv folder
+                               if(fMatchContainer == NULL){
+                                       fMatchContainer = new TList();
+                                       fMatchContainer->SetOwner(kTRUE);
+                                       fMatchContainer->SetName("True conversion histograms");
+                               }
+                               fMatchContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+                       } else if(histogramString.Contains("ESD")){// means it should be put in the ESD folder
+                               if(fESDContainer == NULL){
+                                       fESDContainer = new TList();
+                                       fESDContainer->SetOwner(kTRUE);
+                                       fESDContainer->SetName("ESD histograms");
+                               }
+                               fESDContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+                       } else if(histogramString.Contains("MC")){// means it should be put in the MC folder
+                               if(fMCContainer == NULL){
+                                       fMCContainer = new TList();
+                                       fMCContainer->SetOwner(kTRUE);
+                                       fMCContainer->SetName("MC histograms");
+                               }
+                               fMCContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+                       } else if(histogramString.Contains("Table")){// means it should be put in the Table Folder
+                               if(fTableContainer == NULL){
+                                       fTableContainer = new TList();
+                                       fTableContainer->SetOwner(kTRUE);
+                                       fTableContainer->SetName("Tables");
+                               }
+                               fTableContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+                       } else if(histogramString.Contains("3DPlots")){// means it should be put in the Table Folder
+                               if(f3DContainer == NULL){
+                                       f3DContainer = new TList();
+                                       f3DContainer->SetOwner(kTRUE);
+                                       f3DContainer->SetName("3D histograms");
+                               }
+                               f3DContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+                       } else if(histogramString.Contains("HadInt")){// means it should be put in the Table Folder
+                               if(fHadContainer == NULL){
+                                       fHadContainer = new TList();
+                                       fHadContainer->SetOwner(kTRUE);
+                                       fHadContainer->SetName("Hadronic Interactions histograms");
+                               }
+                               fHadContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+                       } else{
+                               if(fOtherContainer == NULL){
+                                       fOtherContainer = new TList();
+                                       fOtherContainer->SetOwner(kTRUE);
+                                       fOtherContainer->SetName("Other histograms");
+                               }
+                               fOtherContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
+                       }
+                       histogramName = NULL;
+               } // end while
+
+               if(fMappingContainer != NULL){
+                       fOutputContainer->Add(fMappingContainer);
+               }
+               if(fBackgroundContainer != NULL){
+                       fOutputContainer->Add(fBackgroundContainer);
+               }
+               if(fDebugContainer != NULL){
+                       fOutputContainer->Add(fDebugContainer);
+               }
+               if(fResolutionContainer != NULL){
+                       fOutputContainer->Add(fResolutionContainer);
+               }
+               if(fMatchContainer != NULL){
+                       fOutputContainer->Add(fMatchContainer);
+               }
+               if(fESDContainer != NULL){
+                       fOutputContainer->Add(fESDContainer);
+               }
+               if(fMCContainer != NULL){
+                       fOutputContainer->Add(fMCContainer);
+               }
+               if(fTableContainer !=  NULL){
+                       fOutputContainer->Add(fTableContainer); 
+               }
+               if(f3DContainer !=  NULL){
+                       fOutputContainer->Add(f3DContainer);    
+               }
+               if(fHadContainer !=  NULL){
+                       fOutputContainer->Add(fHadContainer);   
+               }
+               if(fOtherContainer != NULL){
+                       fOutputContainer->Add(fOtherContainer);
                }
-               f3DContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
-      }
-      else{
-       if(fOtherContainer == NULL){
-         fOtherContainer = new TList();
-         fOtherContainer->SetOwner(kTRUE);
-         fOtherContainer->SetName("Other histograms");
        }
-       fOtherContainer->Add((TH1*)fHistogramMap->GetValue(histogramString.Data()));
-      }
-      histogramName = NULL;
-    } // end while
-
-    if(fMappingContainer != NULL){
-      fOutputContainer->Add(fMappingContainer);
-    }
-    if(fBackgroundContainer != NULL){
-      fOutputContainer->Add(fBackgroundContainer);
-    }
-    if(fDebugContainer != NULL){
-      fOutputContainer->Add(fDebugContainer);
-    }
-    if(fResolutionContainer != NULL){
-      fOutputContainer->Add(fResolutionContainer);
-    }
-    if(fMatchContainer != NULL){
-      fOutputContainer->Add(fMatchContainer);
-    }
-    if(fESDContainer != NULL){
-      fOutputContainer->Add(fESDContainer);
-    }
-    if(fMCContainer != NULL){
-      fOutputContainer->Add(fMCContainer);
-    }
-    if(fTableContainer !=  NULL){
-       fOutputContainer->Add(fTableContainer); 
-    }
-       if(f3DContainer !=  NULL){
-       fOutputContainer->Add(f3DContainer);    
-    }
-    if(fOtherContainer != NULL){
-      fOutputContainer->Add(fOtherContainer);
-    }
-  }
 }
 
 Int_t AliGammaConversionHistograms::GetRBin(Double_t radius) const{
@@ -785,6 +805,14 @@ void AliGammaConversionHistograms::AddMappingHistograms(Int_t nPhiIndex, Int_t n
     //    AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
     AddHistogram(nameMCITSTPCPhiInZ, titleMCITSTPCPhiInZ, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);
 
+    //Mapping Phi in Z for ITSTPC2 
+    TString nameMCITSTPC2PhiInZ="";
+    nameMCITSTPC2PhiInZ.Form("MC_Conversion_Mapping_ITSTPC2_Phi_in_Z_%02d",z);
+    TString titleMCITSTPC2PhiInZ="";
+    titleMCITSTPC2PhiInZ.Form("MC Mapping ITSTPC2 of Phi in Z%02d",z);
+    //    AddHistogram(nameMCPhiInR, titleMCPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);
+    AddHistogram(nameMCITSTPC2PhiInZ, titleMCITSTPC2PhiInZ, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);
+
 
     //Mapping R in Z
     TString nameMCRInZ="";
@@ -848,6 +876,14 @@ void AliGammaConversionHistograms::AddMappingHistograms(Int_t nPhiIndex, Int_t n
     //    AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);    
     AddHistogram(nameESDITSTPCPhiInZ, titleESDITSTPCPhiInZ, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);    
 
+   //Mapping Phi in Z for ITSTPC2
+    TString nameESDITSTPC2PhiInZ="";
+    nameESDITSTPC2PhiInZ.Form("ESD_Conversion_Mapping_ITSTPC2_Phi_in_Z_%02d",z);
+    TString titleESDITSTPC2PhiInZ="";
+    titleESDITSTPC2PhiInZ.Form("ESD Mapping ITSTPC2 of Phi in Z%02d",z);
+    //    AddHistogram(nameESDPhiInR, titleESDPhiInR, nXBins, firstX, lastX, xAxisTitle, yAxisTitle);    
+    AddHistogram(nameESDITSTPC2PhiInZ, titleESDITSTPC2PhiInZ, nXBins, -TMath::Pi(), TMath::Pi(), xAxisTitle, yAxisTitle);    
+
 
    //Mapping R in Z
     TString nameESDRInZ="";
index ecc33b847102b35ac461793ca698ed60b1444f9a..2242fb93d9b15282c8b71156a245d3bd88b2d5f3 100644 (file)
@@ -94,6 +94,12 @@ class AliGammaConversionHistograms{
    */
   void FillHistogram(TString histogramName, Double_t xValue, Double_t yValue, Double_t zValue) const;
 
+  /*
+   * Fills a TH1F histogram with the given name with the given integer array 
+   */
+  
+  void FillHistogram(TString histogramName, Float_t* xValue, Int_t nPoints) const;
+  
   /*
    * Fills a TH1F table with the given name with the given value
    */                  
@@ -143,8 +149,9 @@ class AliGammaConversionHistograms{
   TList * fTableContainer; // table container
   TList * fOtherContainer; // other container
   TList * f3DContainer; // 3D container
+  TList * fHadContainer; // Hadronic Interactions container
  
-  ClassDef(AliGammaConversionHistograms,3)
+  ClassDef(AliGammaConversionHistograms,4)
 };
 
 
index f0b3917760325bb32fe91c4bfedbb3f368419581..bc770e6155cdca983044a1d90c0f7ad7962d1240 100644 (file)
@@ -59,6 +59,9 @@ class AliKFConversionPhoton : public AliKFParticle, public AliConversionPhotonBa
   virtual Double_t GetPhotonP() const {return P();}
   virtual Double_t GetPhotonEta() const {return Eta();}
   virtual Double_t GetPhotonPhi() const {return Phi();} 
+  virtual Double_t GetPx() const { return AliKFParticle::GetPx();}
+  virtual Double_t GetPy() const { return AliKFParticle::GetPy();}
+  virtual Double_t GetPz() const { return AliKFParticle::GetPz();}
 
   ClassDef(AliKFConversionPhoton,1)
 };
index 895206f5bcc5e734add5a1d7a1b1070f5ab0eb95..6f29648528e0f8c2492959617fd66283b4038180 100644 (file)
 #include "AliESDtrack.h"
 #include "AliMCEvent.h"
 #include "AliKFVertex.h"
-
+#include "AliKFParticle.h"
 #include "AliStack.h"
 #include "AliMCEventHandler.h"
 #include "AliESDpid.h"
 #include "AliGammaConversionBGHandler.h"
 #include "AliESDtrackCuts.h"
 #include "TRandom3.h"
+#include "AliGenCocktailEventHeader.h"
+#include "TList.h"
 
 class iostream;
 class AliESDv0;
@@ -132,6 +134,8 @@ AliV0Reader::AliV0Reader() :
        fXVertexCut(0.),
        fYVertexCut(0.),
        fZVertexCut(0.),
+       fPsiPairCut(0.),
+       fCosinePointCut(0.),
        fNSigmaMass(0.),
        fUseImprovedVertex(kFALSE),
        fUseOwnXYZCalculation(kFALSE),
@@ -161,8 +165,11 @@ AliV0Reader::AliV0Reader() :
        fRandom(0),
        fBrem(NULL),
        fDoPhotonAsymmetryCut(0),
+       fdoESDQtCut(0),
        fMinPPhotonAsymmetryCut(100.),
-       fMinPhotonAsymmetry(0.)
+       fMinPhotonAsymmetry(0.),
+        fExcludeBackgroundEventForGammaCorrection(0.),
+        fNumberOfPrimerisFromHijingAndPythia(0)
 {
        //fESDpid = new AliESDpid;      
 }
@@ -250,6 +257,8 @@ AliV0Reader::AliV0Reader(const AliV0Reader & original) :
        fXVertexCut(original.fXVertexCut),
        fYVertexCut(original.fYVertexCut),
        fZVertexCut(original.fZVertexCut),
+       fPsiPairCut(original.fPsiPairCut),
+       fCosinePointCut(original.fCosinePointCut),
        fNSigmaMass(original.fNSigmaMass),
        fUseImprovedVertex(original.fUseImprovedVertex),
        fUseOwnXYZCalculation(original.fUseOwnXYZCalculation),
@@ -279,8 +288,11 @@ AliV0Reader::AliV0Reader(const AliV0Reader & original) :
        fRandom(original.fRandom),
        fBrem(original.fBrem),
        fDoPhotonAsymmetryCut(original.fDoPhotonAsymmetryCut),
+       fdoESDQtCut(original.fdoESDQtCut),
        fMinPPhotonAsymmetryCut(original.fMinPPhotonAsymmetryCut),
-       fMinPhotonAsymmetry(original.fMinPhotonAsymmetry)
+       fMinPhotonAsymmetry(original.fMinPhotonAsymmetry),
+        fExcludeBackgroundEventForGammaCorrection(original.fExcludeBackgroundEventForGammaCorrection),
+        fNumberOfPrimerisFromHijingAndPythia(original.fNumberOfPrimerisFromHijingAndPythia)
 {
        
 }
@@ -411,8 +423,7 @@ void AliV0Reader::Initialize(){
        if(fCalculateBackground == kTRUE){
                if(fBGEventInitialized == kFALSE){
 
-                       
-                       Double_t *zBinLimitsArray = new Double_t[9];
+                       Double_t zBinLimitsArray[9];
                        zBinLimitsArray[0] = -50.00;
                        zBinLimitsArray[1] = -3.375;
                        zBinLimitsArray[2] = -1.605;
@@ -423,7 +434,7 @@ void AliV0Reader::Initialize(){
                        zBinLimitsArray[7] = 50.00;
                        zBinLimitsArray[8] = 1000.00;
                        
-                       Double_t *multiplicityBinLimitsArray= new Double_t[6];
+                  Double_t multiplicityBinLimitsArray[6];
                        if(fUseChargedTrackMultiplicityForBG == kTRUE){
                                multiplicityBinLimitsArray[0] = 0;
                                multiplicityBinLimitsArray[1] = 8.5;
@@ -473,6 +484,10 @@ void AliV0Reader::Initialize(){
                        fBGEventInitialized = kTRUE;
                }
        }
+        
+        if(fDoMC && fExcludeBackgroundEventForGammaCorrection){
+           fNumberOfPrimerisFromHijingAndPythia = GetNumberOfHijingPlusPythiaPrimeries();
+        }
 }
 
 AliESDv0* AliV0Reader::GetV0(Int_t index){
@@ -535,15 +550,16 @@ Bool_t AliV0Reader::CheckForPrimaryVertexZ(){
        return kTRUE;
 }
 
-Bool_t AliV0Reader::CheckV0FinderStatus(Int_t index){
+
+Bool_t AliV0Reader::CheckV0FinderStatus(AliESDv0 *v0){
        // see headerfile for documentation
        if(fUseOnFlyV0Finder){
-               if(!GetV0(index)->GetOnFlyStatus()){
+               if(!v0->GetOnFlyStatus()){
                        return kFALSE;
                }
        }
        if(!fUseOnFlyV0Finder){
-               if(GetV0(index)->GetOnFlyStatus()){
+               if(v0->GetOnFlyStatus()){
                        return kFALSE;
                }
        }
@@ -552,6 +568,7 @@ Bool_t AliV0Reader::CheckV0FinderStatus(Int_t index){
 
 
 
+
 Bool_t AliV0Reader::NextV0(){
        //see header file for documentation
        Bool_t iResult=kFALSE;
@@ -559,9 +576,10 @@ Bool_t AliV0Reader::NextV0(){
                fCurrentV0 = fESDEvent->GetV0(fCurrentV0IndexNumber);
 
                fUpdateV0AlreadyCalled=kFALSE;
-
+             
                if(fHistograms != NULL){
                        fHistograms->FillHistogram("ESD_AllV0s_InvMass",GetMotherCandidateMass());
+                       fHistograms->FillHistogram("ESD_AllV0s_Pt",GetMotherCandidatePt());
                }
                
                // moved it up here so that the correction framework can access pt and eta information
@@ -570,6 +588,27 @@ Bool_t AliV0Reader::NextV0(){
                        continue;
                }
  
+                
+                if(fDoMC && fExcludeBackgroundEventForGammaCorrection){ // Remove all V0s from BGEvent
+                   Bool_t isFromBGEvent = kFALSE;
+                   isFromBGEvent = IsParticleFromBGEvent(TMath::Abs(fESDEvent->GetTrack(fCurrentV0->GetNindex())->GetLabel()));
+                   if(isFromBGEvent){
+                      fHistograms->FillHistogram("ESD_CutMCBgEvent_InvMass",GetMotherCandidateMass());
+                      fHistograms->FillHistogram("ESD_CutMCBgEvent_Pt",GetMotherCandidatePt());
+                      fCurrentV0IndexNumber++;
+                      continue;
+                   }
+                   isFromBGEvent = IsParticleFromBGEvent(TMath::Abs(fESDEvent->GetTrack(fCurrentV0->GetPindex())->GetLabel()));
+                   if(isFromBGEvent){
+                      fHistograms->FillHistogram("ESD_CutMCBgEvent_InvMass",GetMotherCandidateMass());
+                      fHistograms->FillHistogram("ESD_CutMCBgEvent_Pt",GetMotherCandidatePt());
+                      fCurrentV0IndexNumber++;
+                      continue;
+                   }
+                }
+                
+
+
                Double_t containerInput[3];
                if(fDoCF){
                        containerInput[0] = GetMotherCandidatePt();
@@ -589,9 +628,11 @@ Bool_t AliV0Reader::NextV0(){
                */
 
                //checks if on the fly mode is set
-               if ( !CheckV0FinderStatus(fCurrentV0IndexNumber) ){
+               if ( !CheckV0FinderStatus(fCurrentV0) ){
+                       
                        if(fHistograms != NULL){
                                fHistograms->FillHistogram("ESD_CutGetOnFly_InvMass",GetMotherCandidateMass());
+                                fHistograms->FillHistogram("ESD_CutGetOnFly_Pt",GetMotherCandidatePt());
                        }
                        fCurrentV0IndexNumber++;
                        continue;
@@ -602,23 +643,48 @@ Bool_t AliV0Reader::NextV0(){
 
                if(fHistograms != NULL){
                        fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_InvMass",GetMotherCandidateMass());
+                        fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt",GetMotherCandidatePt());
                }
  
-               Double_t armenterosQtAlfa[2];
-               Double_t armenterosQtAlphaESDMC[2];
-               Double_t armenterosQtAlphaMC[2];
-               GetArmenterosQtAlfa(GetNegativeKFParticle(), 
-                       GetPositiveKFParticle(), 
-                       GetMotherCandidateKFCombination(),
-                       armenterosQtAlfa);
-        
-               fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_alfa_qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
-        
+               Double_t armenterosQtAlpha[2] = {0,0};
+               Double_t armenterosQtAlphaKF[2] = {0,0};
+               Double_t armenterosQtAlphaESD[2] = {0,0};
+               Double_t armenterosQtAlphaKFNew[2] = {0,0};
+               Double_t armenterosQtAlphaESDMC[2] = {0,0};
+               Double_t armenterosQtAlphaMC[2] = {0,0};
+
+               GetArmenterosQtAlpha(GetNegativeKFParticle(), // old KF way calculating Qt Alpha
+                                   GetPositiveKFParticle(), 
+                                   GetMotherCandidateKFCombination(),
+                                   armenterosQtAlphaKF);
+               GetArmenterosQtAlpha(fCurrentV0,armenterosQtAlphaESD); // ESD way calculating Qt Alpha
+               GetArmenterosQtAlpha(GetNegativeKFParticle(), // new KF way calculating Qt Alpha
+                                   GetPositiveKFParticle(), 
+                                   armenterosQtAlphaKFNew,fdoESDQtCut);
+
+               fHistograms->FillHistogram("ESD_AllV0sCurrentFinderKF_alfa_qt",armenterosQtAlphaKF[1],armenterosQtAlphaKF[0]);
+               fHistograms->FillHistogram("ESD_AllV0sCurrentFinderESD_alfa_qt",armenterosQtAlphaESD[1],armenterosQtAlphaESD[0]);
+               fHistograms->FillHistogram("ESD_AllV0sCurrentFinderKFNew_alfa_qt",armenterosQtAlphaKFNew[1],armenterosQtAlphaKFNew[0]);
+
+               if(fdoESDQtCut == 0){
+                  armenterosQtAlpha[0] = armenterosQtAlphaKF[0];
+                  armenterosQtAlpha[1] = armenterosQtAlphaKF[1];
+               }
+               else if(fdoESDQtCut == 1){
+                  armenterosQtAlpha[0] = armenterosQtAlphaESD[0];
+                  armenterosQtAlpha[1] = armenterosQtAlphaESD[1];
+               }
+
+               else if(fdoESDQtCut == 2 || fdoESDQtCut == 3){
+                   armenterosQtAlpha[0] = armenterosQtAlphaKFNew[0];
+                  armenterosQtAlpha[1] = armenterosQtAlphaKFNew[1];
+               }
+              
                if(fCurrentNegativeESDTrack->Charge() == fCurrentPositiveESDTrack->Charge()){                                            // avoid like sign
                        //      iResult=kFALSE;
                        if(fHistograms != NULL ){
                                fHistograms->FillHistogram("ESD_CutLikeSign_InvMass",GetMotherCandidateMass());
+                                fHistograms->FillHistogram("ESD_CutLikeSign_Pt",GetMotherCandidatePt());
                                // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
                                // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
                                //      fUpdateV0AlreadyCalled = kTRUE;
@@ -637,6 +703,7 @@ Bool_t AliV0Reader::NextV0(){
                        //      iResult=kFALSE;
                        if(fHistograms != NULL){
                                fHistograms->FillHistogram("ESD_CutRefit_InvMass",GetMotherCandidateMass());
+                                fHistograms->FillHistogram("ESD_CutRefit_Pt",GetMotherCandidatePt());
                                // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
                                // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
                                //fUpdateV0AlreadyCalled = kTRUE;
@@ -655,6 +722,7 @@ Bool_t AliV0Reader::NextV0(){
                        //iResult=kFALSE;
                        if(fHistograms != NULL ){
                                fHistograms->FillHistogram("ESD_CutKink_InvMass",GetMotherCandidateMass());
+                               fHistograms->FillHistogram("ESD_CutKink_Pt",GetMotherCandidatePt());
                                // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
                                // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
                                //fUpdateV0AlreadyCalled = kTRUE;
@@ -670,6 +738,7 @@ Bool_t AliV0Reader::NextV0(){
                if(GetXYRadius()>fMaxR){ // cuts on distance from collision point
                        if(fHistograms != NULL){
                                fHistograms->FillHistogram("ESD_CutR_InvMass",GetMotherCandidateMass());
+                               fHistograms->FillHistogram("ESD_CutR_Pt",GetMotherCandidatePt());
                        }
                        fCurrentV0IndexNumber++;
                        continue;
@@ -680,6 +749,7 @@ Bool_t AliV0Reader::NextV0(){
                if(GetXYRadius()<fMinR){ // cuts on distance from collision point
                        if(fHistograms != NULL){
                                fHistograms->FillHistogram("ESD_CutMinR_InvMass",GetMotherCandidateMass());
+                               fHistograms->FillHistogram("ESD_CutMinR_Pt",GetMotherCandidatePt());
                        }
                        fCurrentV0IndexNumber++;
                        continue;
@@ -689,12 +759,14 @@ Bool_t AliV0Reader::NextV0(){
                if( GetXYRadius() <= ((TMath::Abs(fCurrentZValue)*fLineCutZRSlope)-fLineCutZValue)){
                        if(fHistograms != NULL){
                                fHistograms->FillHistogram("ESD_CutLine_InvMass",GetMotherCandidateMass());
+                               fHistograms->FillHistogram("ESD_CutLine_Pt",GetMotherCandidatePt());
                        }
                        fCurrentV0IndexNumber++;
                        continue;
                } else if (fUseEtaMinCut &&  GetXYRadius() >= ((TMath::Abs(fCurrentZValue)*fLineCutZRSlopeMin)-fLineCutZValueMin )){ 
                        if(fHistograms != NULL){
                                fHistograms->FillHistogram("ESD_CutLine_InvMass",GetMotherCandidateMass());
+                               fHistograms->FillHistogram("ESD_CutLine_Pt",GetMotherCandidatePt());
                        }
                        fCurrentV0IndexNumber++;
                        continue;
@@ -707,6 +779,7 @@ Bool_t AliV0Reader::NextV0(){
                if(TMath::Abs(fCurrentZValue) > fMaxZ ){ // cuts out regions where we do not reconstruct
                        if(fHistograms != NULL){
                                fHistograms->FillHistogram("ESD_CutZ_InvMass",GetMotherCandidateMass());
+                               fHistograms->FillHistogram("ESD_CutZ_Pt",GetMotherCandidatePt());
                        }
                        fCurrentV0IndexNumber++;
                        continue;
@@ -719,6 +792,7 @@ Bool_t AliV0Reader::NextV0(){
                        if(TMath::Abs(fMotherCandidateLorentzVector->Eta())> fEtaCut || TMath::Abs(fMotherCandidateLorentzVector->Eta())< fEtaCutMin){
                                if(fHistograms != NULL){
                                        fHistograms->FillHistogram("ESD_CutEta_InvMass",GetMotherCandidateMass());
+                                       fHistograms->FillHistogram("ESD_CutEta_Pt",GetMotherCandidatePt());
                                }
                                fCurrentV0IndexNumber++;
                                continue;
@@ -727,6 +801,7 @@ Bool_t AliV0Reader::NextV0(){
                        if(TMath::Abs(fCurrentNegativeKFParticle->GetEta())> fEtaCut || TMath::Abs(fCurrentNegativeKFParticle->GetEta())< fEtaCutMin){
                                if(fHistograms != NULL){
                                        fHistograms->FillHistogram("ESD_CutEta_InvMass",GetMotherCandidateMass());
+                                       fHistograms->FillHistogram("ESD_CutEta_Pt",GetMotherCandidatePt());
                                }
                                fCurrentV0IndexNumber++;
                                continue;
@@ -735,29 +810,31 @@ Bool_t AliV0Reader::NextV0(){
                        if(TMath::Abs(fCurrentPositiveKFParticle->GetEta())> fEtaCut || TMath::Abs(fCurrentPositiveKFParticle->GetEta())< fEtaCutMin){
                                if(fHistograms != NULL){
                                        fHistograms->FillHistogram("ESD_CutEta_InvMass",GetMotherCandidateMass());
+                                       fHistograms->FillHistogram("ESD_CutEta_Pt",GetMotherCandidatePt());
                                }
                                fCurrentV0IndexNumber++;
                                continue;
                        }
                }
 
-fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(),armenterosQtAlfa[0]);
+               fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(),armenterosQtAlpha[0]);
 
                if(fDoMC){
                        if ( HasSameMCMother() == kTRUE){ 
-                               GetArmenterosQtAlfa(fNegativeMCParticle, 
+                               GetArmenterosQtAlpha(fNegativeMCParticle, 
                                        fPositiveMCParticle, 
                                        fMotherMCParticle,
                                        armenterosQtAlphaMC);
                        }
-                       GetArmenterosQtAlfa(fNegativeMCParticle, 
+                       GetArmenterosQtAlpha(fNegativeMCParticle, 
                                fPositiveMCParticle, 
                                GetMotherCandidateKFCombination(),
                                armenterosQtAlphaESDMC );
                }
-               fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_goodtracks_alfa_qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
+
+                fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_goodtracks_alfa_qt",armenterosQtAlpha[1],armenterosQtAlpha[0]);
                if( fCurrentNegativeKFParticle->GetPt()> 0.150 &&       fCurrentPositiveKFParticle->GetPt()> 0.150){
-                       fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_minPt_GT_Alpha_Qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
+                       fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_minPt_GT_Alpha_Qt",armenterosQtAlpha[1],armenterosQtAlpha[0]);
                }
                if(fDoMC){
                        fHistograms->FillHistogram("ESD_TrueConvAllV0s_ESDMother_Alpha_Qt",armenterosQtAlphaESDMC[1],armenterosQtAlphaESDMC[0]);
@@ -765,29 +842,29 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                                fHistograms->FillHistogram("ESD_TrueConvSameMother_ESDMother_Alpha_Qt",armenterosQtAlphaESDMC[1],armenterosQtAlphaESDMC[0]);
                                fHistograms->FillHistogram("ESD_TrueConvSameMother_MCMother_Alpha_Qt",armenterosQtAlphaMC[1],armenterosQtAlphaMC[0]);
                                if (fMotherMCParticle->GetPdgCode() == 22 ){
-                                       fHistograms->FillHistogram("ESD_TrueConvGamma_Alpha_Qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
-                                       fHistograms->FillHistogram("ESD_TrueConvGamma_Pt_Qt",GetMotherCandidatePt(),armenterosQtAlfa[0]);       
+                                       fHistograms->FillHistogram("ESD_TrueConvGamma_Alpha_Qt",armenterosQtAlpha[1],armenterosQtAlpha[0]);
+                                       fHistograms->FillHistogram("ESD_TrueConvGamma_Pt_Qt",GetMotherCandidatePt(),armenterosQtAlpha[0]);      
                                } else if ( fMotherMCParticle->GetPdgCode() == 310 ){
-                                       fHistograms->FillHistogram("ESD_TrueConvK0s_Alpha_Qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
+                                       fHistograms->FillHistogram("ESD_TrueConvK0s_Alpha_Qt",armenterosQtAlpha[1],armenterosQtAlpha[0]);
                                } else if ( fMotherMCParticle->GetPdgCode() == 113 ){
-                                       fHistograms->FillHistogram("ESD_TrueConvRho0_Alpha_Qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
+                                       fHistograms->FillHistogram("ESD_TrueConvRho0_Alpha_Qt",armenterosQtAlpha[1],armenterosQtAlpha[0]);
                                } else if ( fMotherMCParticle->GetPdgCode() == 333 ){
-                                       fHistograms->FillHistogram("ESD_TrueConvPhi_Alpha_Qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
+                                       fHistograms->FillHistogram("ESD_TrueConvPhi_Alpha_Qt",armenterosQtAlpha[1],armenterosQtAlpha[0]);
                                } else if ( (fMotherMCParticle->GetPdgCode() == 3122 || fMotherMCParticle->GetPdgCode() == -3122) ){
-                                       fHistograms->FillHistogram("ESD_TrueConvLambda_Alpha_Qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
+                                       fHistograms->FillHistogram("ESD_TrueConvLambda_Alpha_Qt",armenterosQtAlpha[1],armenterosQtAlpha[0]);
                                } else if ( (fMotherMCParticle->GetPdgCode() == 2114 || fMotherMCParticle->GetPdgCode() == -2114) ){
-                                       fHistograms->FillHistogram("ESD_TrueConvDelta_Alpha_Qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
+                                       fHistograms->FillHistogram("ESD_TrueConvDelta_Alpha_Qt",armenterosQtAlpha[1],armenterosQtAlpha[0]);
                                } else if ( (fMotherMCParticle->GetPdgCode() == 313 || 
                                                                fMotherMCParticle->GetPdgCode() == 323 || 
                                                                fMotherMCParticle->GetPdgCode() == -323 ) ){
-                                       fHistograms->FillHistogram("ESD_TrueConvKStar_Alpha_Qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
+                                       fHistograms->FillHistogram("ESD_TrueConvKStar_Alpha_Qt",armenterosQtAlpha[1],armenterosQtAlpha[0]);
                                } else {
-                                       fHistograms->FillHistogram("ESD_TrueConvUnknown_Alpha_Qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
+                                       fHistograms->FillHistogram("ESD_TrueConvUnknown_Alpha_Qt",armenterosQtAlpha[1],armenterosQtAlpha[0]);
                                        fHistograms->FillHistogram("ESD_TrueConvUnknown_Qt_PDG",fMotherMCParticle->GetPdgCode());
                                //      cout << "unidentfied mother: pdg-C mother " << fMotherMCParticle->GetPdgCode() << " daughters " << fNegativeMCParticle->GetPdgCode() << "\t" << fPositiveMCParticle->GetPdgCode() << endl;
                                }
                        }       else {
-                               fHistograms->FillHistogram("ESD_TrueConvComb_Alpha_Qt",armenterosQtAlfa[1],armenterosQtAlfa[0]);
+                               fHistograms->FillHistogram("ESD_TrueConvComb_Alpha_Qt",armenterosQtAlpha[1],armenterosQtAlpha[0]);
                        }
                }
 
@@ -812,6 +889,7 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                                //iResult=kFALSE;
                                if(fHistograms != NULL ){
                                        fHistograms->FillHistogram("ESD_CutdEdxSigmaElectronLine_InvMass",GetMotherCandidateMass());
+                                        fHistograms->FillHistogram("ESD_CutdEdxSigmaElectronLine_Pt",GetMotherCandidatePt());
                                        // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
                                        // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
                                        //fUpdateV0AlreadyCalled = kTRUE;
@@ -836,6 +914,7 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                                        //              iResult=kFALSE;
                                        if(fHistograms != NULL){
                                                fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_InvMass",GetMotherCandidateMass());
+                                                fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_Pt",GetMotherCandidatePt());
                                                // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
                                                // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
                                                //fUpdateV0AlreadyCalled = kTRUE;
@@ -852,6 +931,7 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                                        //              iResult=kFALSE;
                                        if(fHistograms != NULL){
                                                fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_InvMass",GetMotherCandidateMass());
+                                                fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_Pt",GetMotherCandidatePt());
                                                // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
                                                // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
                                                //fUpdateV0AlreadyCalled = kTRUE;
@@ -869,6 +949,7 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                                        //              iResult=kFALSE;
                                        if(fHistograms != NULL){
                                                fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_InvMass",GetMotherCandidateMass());
+                                                fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_Pt",GetMotherCandidatePt());
                                                // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
                                                // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
                                                //fUpdateV0AlreadyCalled = kTRUE;
@@ -885,6 +966,7 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                        //              iResult=kFALSE;
                                        if(fHistograms != NULL){
                                                fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_InvMass",GetMotherCandidateMass());
+                                                fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_Pt",GetMotherCandidatePt());
                                                // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
                                                // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
                                                //fUpdateV0AlreadyCalled = kTRUE;
@@ -989,6 +1071,38 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                }
 
 
+               Double_t psiPair  = -1;
+               psiPair = GetPsiPair(fCurrentV0);
+               
+                if(psiPair > fPsiPairCut){
+                   if(fHistograms != NULL ){
+                      fHistograms->FillHistogram("ESD_CutPsiPair_InvMass",GetMotherCandidateMass());
+                      fHistograms->FillHistogram("ESD_CutPsiPair_Pt",GetMotherCandidatePt());
+                      // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
+                      // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
+                      //       fUpdateV0AlreadyCalled = kTRUE;
+                   }
+                   
+                   fCurrentV0IndexNumber++;
+                   continue;
+                }
+               
+
+               Double_t cosineOfPointingAngle  = -1;
+                cosineOfPointingAngle = GetV0CosineOfPointingAngle(fCurrentXValue,fCurrentYValue,fCurrentZValue);
+                if(cosineOfPointingAngle < fCosinePointCut){
+                   if(fHistograms != NULL ){
+                       fHistograms->FillHistogram("ESD_CutCosinePoint_InvMass",GetMotherCandidateMass());
+                        fHistograms->FillHistogram("ESD_CutCosinePoint_Pt",GetMotherCandidatePt());
+                       // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
+                       // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
+                       //      fUpdateV0AlreadyCalled = kTRUE;
+                       }
+                       fCurrentV0IndexNumber++;
+                       continue;
+               }
+
+
                if( fDoTOFsigmaCut == kTRUE ){ // RRnewTOF start ///////////////////////////////////////////////////////////////////////////// 
                        Bool_t PosTrackNotTOFelec = kFALSE;
                        Bool_t NegTrackNotTOFelec = kFALSE;
@@ -1005,6 +1119,7 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                        if( (PosTrackNotTOFelec==kTRUE) || (NegTrackNotTOFelec==kTRUE) ){
                                if(fHistograms != NULL){
                                        fHistograms->FillHistogram("ESD_CutTOFsigmaElec_InvMass",GetMotherCandidateMass());
+                                        fHistograms->FillHistogram("ESD_CutTOFsigmaElec_Pt",GetMotherCandidatePt());
                                }
                                fCurrentV0IndexNumber++;
                                continue;
@@ -1016,26 +1131,29 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                if(fDoQtGammaSelection == kTRUE){ // RRnew start : apply different qT-cut above/below
                        if(fDoHighPtQtGammaSelection){
                                if(GetMotherCandidatePt() < fPtBorderForQt){
-                                       if(armenterosQtAlfa[0]>fQtMax){
+                                       if(armenterosQtAlpha[0]>fQtMax){
                                                if(fHistograms != NULL){
                                                        fHistograms->FillHistogram("ESD_CutQt_InvMass",GetMotherCandidateMass());
+                                                       fHistograms->FillHistogram("ESD_CutQt_Pt",GetMotherCandidatePt());
                                                }
                                                fCurrentV0IndexNumber++;
                                                continue;
                                        }
                                } else {
-                                       if(armenterosQtAlfa[0]>fHighPtQtMax)    {
+                                       if(armenterosQtAlpha[0]>fHighPtQtMax)   {
                                                if(fHistograms != NULL){
                                                        fHistograms->FillHistogram("ESD_CutQt_InvMass",GetMotherCandidateMass());
+                                                        fHistograms->FillHistogram("ESD_CutQt_Pt",GetMotherCandidatePt());
                                                }
                                                fCurrentV0IndexNumber++;
                                                continue;
                                        }
                                }
                        } else {
-                               if(armenterosQtAlfa[0]>fQtMax){
+                               if(armenterosQtAlpha[0]>fQtMax){
                                        if(fHistograms != NULL){
                                                fHistograms->FillHistogram("ESD_CutQt_InvMass",GetMotherCandidateMass());
+                                                fHistograms->FillHistogram("ESD_CutQt_Pt",GetMotherCandidatePt());
                                        }
                                        fCurrentV0IndexNumber++;
                                        continue;
@@ -1052,6 +1170,7 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                                if( trackNegAsy<fMinPhotonAsymmetry ||trackNegAsy>(1.- fMinPhotonAsymmetry)){
                                        if(fHistograms != NULL){
                                                fHistograms->FillHistogram("ESD_CutPhotonAsymmetry_InvMass",GetMotherCandidateMass());
+                                                fHistograms->FillHistogram("ESD_CutPhotonAsymmetry_Pt",GetMotherCandidatePt());
                                                // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
                                                // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
                                                //fUpdateV0AlreadyCalled = kTRUE;
@@ -1069,6 +1188,7 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                                if( trackPosAsy<fMinPhotonAsymmetry ||trackPosAsy>(1.- fMinPhotonAsymmetry)){
                                        if(fHistograms != NULL){
                                                fHistograms->FillHistogram("ESD_CutPhotonAsymmetry_InvMass",GetMotherCandidateMass());
+                                                fHistograms->FillHistogram("ESD_CutPhotonAsymmetry_Pt",GetMotherCandidatePt());
                                                // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
                                                // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
                                                //fUpdateV0AlreadyCalled = kTRUE;
@@ -1083,6 +1203,7 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                if(GetNumberOfContributorsVtx()<=0) { 
                        if(fHistograms != NULL){
                                fHistograms->FillHistogram("ESD_CutNContributors_InvMass",GetMotherCandidateMass());
+                               fHistograms->FillHistogram("ESD_CutNContributors_Pt",GetMotherCandidatePt());
                        }
                        fCurrentV0IndexNumber++;
                        continue;
@@ -1095,6 +1216,7 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                if(CheckPIDProbability(fPIDProbabilityCutNegativeParticle,fPIDProbabilityCutPositiveParticle)==kFALSE){
                        if(fHistograms != NULL){
                                fHistograms->FillHistogram("ESD_CutPIDProb_InvMass",GetMotherCandidateMass());
+                               fHistograms->FillHistogram("ESD_CutPIDProb_Pt",GetMotherCandidatePt());
                        }
                        fCurrentV0IndexNumber++;
                        continue;
@@ -1113,6 +1235,7 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                if(fCurrentNegativeESDTrack->GetNcls(1) < fMinClsTPC || fCurrentPositiveESDTrack->GetNcls(1) < fMinClsTPC ){
                        if(fHistograms != NULL){
                                fHistograms->FillHistogram("ESD_CutMinNClsTPC_InvMass",GetMotherCandidateMass());
+                               fHistograms->FillHistogram("ESD_CutMinNClsTPC_Pt",GetMotherCandidatePt());
                        }
                        fCurrentV0IndexNumber++;
                        continue;
@@ -1141,6 +1264,7 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                if( negclsToF < fMinClsTPCToF ||        posclsToF < fMinClsTPCToF ){
                        if(fHistograms != NULL){
                                fHistograms->FillHistogram("ESD_CutMinNClsTPCToF_InvMass",GetMotherCandidateMass());
+                               fHistograms->FillHistogram("ESD_CutMinNClsTPCToF_Pt",GetMotherCandidatePt());
                        }
                        fCurrentV0IndexNumber++;
                        continue;
@@ -1155,6 +1279,7 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                        if( fCurrentNegativeKFParticle->GetPt()< fSinglePtCut ||        fCurrentPositiveKFParticle->GetPt()< fSinglePtCut){
                                if(fHistograms != NULL){
                                        fHistograms->FillHistogram("ESD_CutSinglePt_InvMass",GetMotherCandidateMass());
+                                       fHistograms->FillHistogram("ESD_CutSinglePt_Pt",GetMotherCandidatePt());
                                }
                                fCurrentV0IndexNumber++;
                                continue;
@@ -1167,6 +1292,7 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                        if(fCurrentMotherKFCandidate->GetNDF()<=0){
                                if(fHistograms != NULL){
                                        fHistograms->FillHistogram("ESD_CutNDF_InvMass",GetMotherCandidateMass());
+                                       fHistograms->FillHistogram("ESD_CutNDF_Pt",GetMotherCandidatePt());
                                }
                                fCurrentV0IndexNumber++;
                                continue;
@@ -1179,6 +1305,7 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                        if(chi2V0 > fChi2CutConversion || chi2V0 <=0){
                                if(fHistograms != NULL){
                                        fHistograms->FillHistogram("ESD_CutChi2_InvMass",GetMotherCandidateMass());
+                                       fHistograms->FillHistogram("ESD_CutChi2_Pt",GetMotherCandidatePt());
                                }
                                fCurrentV0IndexNumber++;
                                continue;
@@ -1194,6 +1321,7 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
                        if(fMotherCandidateLorentzVector->Pt()<fPtCut){
                                if(fHistograms != NULL){
                                        fHistograms->FillHistogram("ESD_CutPt_InvMass",GetMotherCandidateMass());
+                                       fHistograms->FillHistogram("ESD_CutPt_Pt",GetMotherCandidatePt());
                                }
                                fCurrentV0IndexNumber++;
                                continue;
@@ -1240,6 +1368,9 @@ fHistograms->FillHistogram("ESD_AllV0sCurrentFinder_Pt_Qt",GetMotherCandidatePt(
 Bool_t AliV0Reader::UpdateV0Information(){
        //see header file for documentation
        
+       const AliExternalTrackParam *fCurrentExternalTrackParamPositive=GetExternalTrackParamP(fCurrentV0);
+   const AliExternalTrackParam *fCurrentExternalTrackParamNegative=GetExternalTrackParamN(fCurrentV0);
+
        Bool_t iResult=kTRUE;                                           // for taking out not refitted, kinks and like sign tracks 
        
        Bool_t switchTracks = kFALSE;
@@ -1369,103 +1500,20 @@ Bool_t AliV0Reader::UpdateV0Information(){
                }
        }
        else{
-               Double_t convpos[2]; //Double_t convpos[3];
-               convpos[0]=0;
-               convpos[1]=0;
-//     convpos[2]=0;
-
-               GetConvPosXY(GetPositiveESDTrack(),GetNegativeESDTrack(),GetMagneticField(),convpos);
-               
-               /*if(switchTracks == kFALSE){
-                       GetConversionPoint((fCurrentV0->GetParamP()),(fCurrentV0->GetParamN()),convpos);
-               }else{
-                       GetConversionPoint((fCurrentV0->GetParamN()),(fCurrentV0->GetParamP()),convpos);
-               }*/
-               
+               Double_t convpos[3]={0,0,0};
+               GetConversionPoint(fCurrentExternalTrackParamPositive,fCurrentExternalTrackParamNegative,convpos);
+//             fCurrentMotherKF->SetConversionPoint(convpos);
+
+//             Double_t convpos[2];
+//             convpos[0]=0;
+//             convpos[1]=0;
+// 
+//             GetConvPosXY(GetPositiveESDTrack(),GetNegativeESDTrack(),GetMagneticField(),convpos);
+//             
                fCurrentXValue = convpos[0];
                fCurrentYValue = convpos[1];
-//             fCurrentZValue = convpos[2];
-               fCurrentZValue = GetConvPosZ(GetPositiveESDTrack(),GetNegativeESDTrack(),GetMagneticField());
-       }
-       /*
-       if(fCurrentNegativeESDTrack->GetSign() == fCurrentPositiveESDTrack->GetSign()){                                          // avoid like sign
-               iResult=kFALSE;
-               if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE && doFillHistos == kTRUE){
-                       fHistograms->FillHistogram("ESD_CutLikeSign_InvMass",GetMotherCandidateMass());
-                       // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
-                       // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
-                       fUpdateV0AlreadyCalled = kTRUE;
-               }
-       }
-       
-       if( !(fCurrentNegativeESDTrack->GetStatus() & AliESDtrack::kTPCrefit) || 
-                       !(fCurrentPositiveESDTrack->GetStatus() & AliESDtrack::kTPCrefit) ){
-               //      if( !(fCurrentNegativeESDTrack->GetStatus() & AliESDtrack::kITSrefit) || 
-               //                      !(fCurrentPositiveESDTrack->GetStatus() & AliESDtrack::kITSrefit) ){
-               iResult=kFALSE;
-               if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE      && doFillHistos == kTRUE){
-                       fHistograms->FillHistogram("ESD_CutRefit_InvMass",GetMotherCandidateMass());
-                       // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
-                       // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
-                       fUpdateV0AlreadyCalled = kTRUE;
-               }
+               fCurrentZValue = convpos[2];
        }
-       
-       if( fCurrentNegativeESDTrack->GetKinkIndex(0) > 0 || 
-                       fCurrentPositiveESDTrack->GetKinkIndex(0) > 0) {                        
-               
-               iResult=kFALSE;
-               if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE && doFillHistos == kTRUE ){
-                       fHistograms->FillHistogram("ESD_CutKink_InvMass",GetMotherCandidateMass());
-                       // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
-                       // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
-                       fUpdateV0AlreadyCalled = kTRUE;
-               }
-       }
-
-       if(fDodEdxSigmaCut == kTRUE){
-
-               if( fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)<fPIDnSigmaBelowElectronLine ||
-       fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)>fPIDnSigmaAboveElectronLine ||
-       fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)<fPIDnSigmaBelowElectronLine ||
-       fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)>fPIDnSigmaAboveElectronLine ){
-                       iResult=kFALSE;
-                       if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE      && doFillHistos == kTRUE){
-       fHistograms->FillHistogram("ESD_CutdEdxSigmaElectronLine_InvMass",GetMotherCandidateMass());
-       // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
-       // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
-       fUpdateV0AlreadyCalled = kTRUE;
-                       }
-               }
-               if( fCurrentPositiveESDTrack->P()>fPIDMinPnSigmaAbovePionLine){
-                       if(fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLine &&
-        fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLine&&
-        fESDpid->NumberOfSigmasTPC(fCurrentPositiveESDTrack,AliPID::kPion)<fPIDnSigmaAbovePionLine){
-       iResult=kFALSE;
-       if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE      && doFillHistos == kTRUE){
-               fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_InvMass",GetMotherCandidateMass());
-               // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
-               // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
-               fUpdateV0AlreadyCalled = kTRUE;
-       }
-                       }
-               }
-
-               if( fCurrentNegativeESDTrack->P()>fPIDMinPnSigmaAbovePionLine){
-                       if(fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)>fPIDnSigmaBelowElectronLine &&
-        fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kElectron)<fPIDnSigmaAboveElectronLine&&
-        fESDpid->NumberOfSigmasTPC(fCurrentNegativeESDTrack,AliPID::kPion)<fPIDnSigmaAbovePionLine){
-       iResult=kFALSE;
-       if(fHistograms != NULL && fUpdateV0AlreadyCalled == kFALSE && doFillHistos == kTRUE ){
-               fHistograms->FillHistogram("ESD_CutdEdxSigmaPionLine_InvMass",GetMotherCandidateMass());
-               // to avoid filling the other cut histograms. So in this case fUpdateV0AlreadyCalled also serves as a flag for the histogram filling
-               // it will anyway be set to true at the end of the UpdateV0Information function, and there are no return until the end
-               fUpdateV0AlreadyCalled = kTRUE;
-       }
-                       }
-               }
-       }
-       */
        fUpdateV0AlreadyCalled = kTRUE;
 
        return iResult;
@@ -1730,11 +1778,9 @@ Int_t AliV0Reader::GetSpeciesIndex(Int_t chargeOfTrack){
        return iResult;
 }
 
-Bool_t AliV0Reader::GetHelixCenter(AliESDtrack* track, Double_t b,Int_t charge, Double_t center[2]){ 
-// Bool_t AliV0Reader::GetHelixCenter(const AliExternalTrackParam *track, Double_t b,Int_t charge, Double_t center[2]){
+//_____________________________________________________________________________________________________________________
+Bool_t AliV0Reader::GetHelixCenter(const AliExternalTrackParam *track, Double_t b,Int_t charge, Double_t center[2]){
        // see header file for documentation
-               
-       Double_t pi = 3.14159265358979323846;
        
        Double_t        helix[6];
        track->GetHelixParameters(helix,b);
@@ -1745,104 +1791,161 @@ Bool_t AliV0Reader::GetHelixCenter(AliESDtrack* track, Double_t b,Int_t charge,
        Double_t phi = helix[2];
 
        if(phi < 0){
-               phi = phi + 2*pi;
+               phi = phi + 2*TMath::Pi();
        }
 
-       phi -= pi/2.;
+       phi -= TMath::Pi()/2.;
        Double_t xpoint =       radius * TMath::Cos(phi);
        Double_t ypoint =       radius * TMath::Sin(phi);
 
        if(b<0){
-         if(charge > 0){
-               xpoint = - xpoint;
-               ypoint = - ypoint;
-         }
-       
-       } else if(b>0){
-         if(charge < 0){
-               xpoint = - xpoint;
-               ypoint = - ypoint;
-         }
+               if(charge > 0){
+                       xpoint = - xpoint;
+                       ypoint = - ypoint;
+               }
+
+               if(charge < 0){
+                       xpoint =        xpoint;
+                       ypoint =        ypoint;
+               }
        }
+       if(b>0){
+               if(charge > 0){
+                       xpoint =        xpoint;
+                       ypoint =        ypoint;
+               }
 
+               if(charge < 0){
+                       xpoint = - xpoint;
+                       ypoint = - ypoint;
+               }
+       }
        center[0] =     xpos + xpoint;
        center[1] =     ypos + ypoint;
 
        return 1;
 }
 
-/*void AliV0Reader::GetConversionPoint(const AliExternalTrackParam *pparam,const AliExternalTrackParam *nparam,Double_t convpos[3]){
+//_________________________________________________________________________________________________________
+// Bool_t AliV0Reader::GetHelixCenter(AliESDtrack* track, Double_t b,Int_t charge, Double_t center[2]){ 
+// // Bool_t AliV0Reader::GetHelixCenter(const AliExternalTrackParam *track, Double_t b,Int_t charge, Double_t center[2]){
+//     // see header file for documentation
+//             
+//     Double_t pi = 3.14159265358979323846;
+//     
+//     Double_t        helix[6];
+//     track->GetHelixParameters(helix,b);
+//     
+//     Double_t xpos = helix[5];
+//     Double_t ypos = helix[0];
+//     Double_t radius = TMath::Abs(1./helix[4]);
+//     Double_t phi = helix[2];
+// 
+//     if(phi < 0){
+//             phi = phi + 2*pi;
+//     }
+// 
+//     phi -= pi/2.;
+//     Double_t xpoint =       radius * TMath::Cos(phi);
+//     Double_t ypoint =       radius * TMath::Sin(phi);
+// 
+//     if(b<0){
+//             if(charge > 0){
+//                     xpoint = - xpoint;
+//                     ypoint = - ypoint;
+//             }
+// 
+//             if(charge < 0){
+//                     xpoint =        xpoint;
+//                     ypoint =        ypoint;
+//             }
+//     }
+//     if(b>0){
+//             if(charge > 0){
+//                     xpoint =        xpoint;
+//                     ypoint =        ypoint;
+//             }
+// 
+//             if(charge < 0){
+//                     xpoint = - xpoint;
+//                     ypoint = - ypoint;
+//             }
+//     }
+//     center[0] =     xpos + xpoint;
+//     center[1] =     ypos + ypoint;
+// 
+//     return 1;
+// }
+
+//____________________________________________________________________________________________________________________________
+Bool_t AliV0Reader::GetConversionPoint(const AliExternalTrackParam *pparam,const AliExternalTrackParam *nparam,Double_t convpos[3]){
+
+    if(!pparam||!nparam)return kFALSE;
 
        Double_t helixcenterpos[2];
        GetHelixCenter(pparam,GetMagneticField(),pparam->Charge(),helixcenterpos);
-       
+
        Double_t helixcenterneg[2];
        GetHelixCenter(nparam,GetMagneticField(),nparam->Charge(),helixcenterneg);
-       
+
        Double_t helixpos[6];
        pparam->GetHelixParameters(helixpos,GetMagneticField());
        Double_t posradius = TMath::Abs(1./helixpos[4]);
-       
+
        Double_t helixneg[6];
        nparam->GetHelixParameters(helixneg,GetMagneticField());
        Double_t negradius = TMath::Abs(1./helixneg[4]);
-       
-       // Calculate xy-position
-       
+
+        // Calculate xy-position
+
        Double_t xpos = helixcenterpos[0];
        Double_t ypos = helixcenterpos[1];
        Double_t xneg = helixcenterneg[0];
        Double_t yneg = helixcenterneg[1];
-       
+
        convpos[0] = (xpos*negradius + xneg*posradius)/(negradius+posradius);
-       convpos[1] = (ypos*negradius + yneg*posradius)/(negradius+posradius);
-       
-       
+       convpos[1] = (ypos*negradius+ yneg*posradius)/(negradius+posradius);
+
+
        // Calculate z-position
-       
-       Double_t deltaXPos = convpos[0] -       xpos;
-       Double_t deltaYPos = convpos[1] -      ypos;
-       
-       Double_t deltaXNeg = convpos[0] -      xneg;
-       Double_t deltaYNeg = convpos[1] -      yneg;
-       
-       Double_t alphaPos =    TMath::Pi() + TMath::ATan2(-deltaYPos,-deltaXPos);
-       Double_t alphaNeg =    TMath::Pi() + TMath::ATan2(-deltaYNeg,-deltaXNeg);
-       Double_t vertexXNeg =  xneg +  TMath::Abs(negradius)*TMath::Cos(alphaNeg);
-       Double_t vertexYNeg =  yneg +  TMath::Abs(negradius)*TMath::Sin(alphaNeg);
-       
-       Double_t vertexXPos =  xpos +  TMath::Abs(posradius)*TMath::Cos(alphaPos);
-       Double_t vertexYPos =  ypos +  TMath::Abs(posradius)*TMath::Sin(alphaPos);
-       
-       Double_t x0neg =        helixneg[5];
-       Double_t y0neg =        helixneg[0];
-       
-       Double_t x0pos =        helixpos[5];
-       Double_t y0pos =        helixpos[0];
-       
-       Double_t dNeg = TMath::Sqrt((vertexXNeg - x0neg)*(vertexXNeg - x0neg)+(vertexYNeg - y0neg)*(vertexYNeg - y0neg));
-       
-       Double_t dPos = TMath::Sqrt((vertexXPos - x0pos)*(vertexXPos - x0pos)+(vertexYPos - y0pos)*(vertexYPos - y0pos));
-       
-       Double_t rNeg = TMath::Sqrt(negradius*negradius - dNeg*dNeg/4.);
 
-       Double_t rPos = TMath::Sqrt(posradius*posradius - dPos*dPos/4.);
-       
-       Double_t deltabetaNeg = 2*(TMath::Pi() + TMath::ATan2(-dNeg/2.,-rNeg));
-       Double_t deltabetaPos = 2*(TMath::Pi() + TMath::ATan2(-dPos/2.,-rPos));
-       
-       Double_t deltaUNeg = negradius*deltabetaNeg;
-       Double_t deltaUPos = posradius*deltabetaPos;
+       Double_t deltaXPos = convpos[0] -       xpos;
+       Double_t deltaYPos = convpos[1] -       ypos;
 
-       Double_t zphaseNeg = nparam->GetZ() +  deltaUNeg * nparam->GetTgl();
-       Double_t zphasePos = pparam->GetZ() +  deltaUPos * pparam->GetTgl();
+       Double_t deltaXNeg = convpos[0] -       xneg;
+       Double_t deltaYNeg = convpos[1] -       yneg;
 
-       convpos[2] = (zphasePos*negradius+zphaseNeg*posradius)/(negradius+posradius);
+       Double_t alphaPos =     TMath::Pi() + TMath::ATan2(-deltaYPos,-deltaXPos);
+       Double_t alphaNeg =     TMath::Pi() + TMath::ATan2(-deltaYNeg,-deltaXNeg);
 
-  
+       Double_t vertexXNeg =   xneg +  TMath::Abs(negradius)*TMath::Cos(alphaNeg);
+       Double_t vertexYNeg =   yneg +  TMath::Abs(negradius)*TMath::Sin(alphaNeg);
+
+       Double_t vertexXPos =   xpos +  TMath::Abs(posradius)*TMath::Cos(alphaPos);
+       Double_t vertexYPos =   ypos +  TMath::Abs(posradius)*TMath::Sin(alphaPos);
+
+       Double_t b = fESDEvent->GetMagneticField();
+
+       AliExternalTrackParam p(*pparam);
+       AliExternalTrackParam n(*nparam);
+
+       TVector2 vertexPos(vertexXPos,vertexYPos);
+        TVector2 vertexNeg(vertexXNeg,vertexYNeg);
+
+       // Convert to local coordinate system
+       vertexPos=vertexPos.Rotate(-p.GetAlpha());
+        vertexNeg=vertexNeg.Rotate(-p.GetAlpha());
+
+        // Propagate Track Params to Vertex
+        p.PropagateTo(vertexPos.X(),b);
+        n.PropagateTo(vertexNeg.X(),b);
 
-}*/
+       convpos[2] = (p.GetZ()*negradius+n.GetZ()*posradius)/(negradius+posradius);
 
+       return kTRUE;
+}
+// 
+// //__________________________________________________________________________________________________________
 Bool_t AliV0Reader::GetConvPosXY(AliESDtrack* ptrack, AliESDtrack* ntrack, Double_t b, Double_t convpos[2]){
        //see header file for documentation
 
@@ -1870,9 +1973,9 @@ Bool_t AliV0Reader::GetConvPosXY(AliESDtrack* ptrack, AliESDtrack* ntrack, Doubl
 
        return 1;
 }
-
-
-
+// 
+// 
+// 
 Double_t AliV0Reader::GetConvPosZ(AliESDtrack* ptrack,AliESDtrack* ntrack, Double_t b){
        //see header file for documentation
 
@@ -1954,7 +2057,7 @@ Double_t AliV0Reader::GetConvPosZ(AliESDtrack* ptrack,AliESDtrack* ntrack, Doubl
 
         return convposz;
 }
-
+// 
 AliGammaConversionKFVector* AliV0Reader::GetBGGoodV0s(Int_t /*event*/) const{
        /*
        if(fUseChargedTrackMultiplicityForBG == kTRUE){
@@ -2005,7 +2108,33 @@ Bool_t AliV0Reader::CheckIfEtaIsMother(Int_t label){
 }
 
 
-Bool_t AliV0Reader::GetArmenterosQtAlfa(const AliKFParticle* negativeKFParticle, const AliKFParticle * positiveKFParticle, const AliKFParticle * gammaKFCandidate, Double_t armenterosQtAlfa[2] ){
+
+
+Bool_t AliV0Reader::GetArmenterosQtAlpha(const AliKFParticle* negativeKFParticle, const AliKFParticle * positiveKFParticle, Double_t armenterosQtAlpha[2], Int_t kfProductionMethod){
+   
+   AliKFParticle PosParticle = *positiveKFParticle;
+   AliKFParticle NegParticle = *negativeKFParticle;
+   AliKFParticle Gamma;
+   if(kfProductionMethod < 3)
+      Gamma.ConstructGamma(PosParticle, NegParticle);
+   else if(kfProductionMethod == 3){
+      Gamma += PosParticle;
+      Gamma += NegParticle;
+   }
+   
+   Double_t VertexGamma[3] = {Gamma.GetX(), Gamma.GetY(), Gamma.GetZ()};
+   PosParticle.TransportToPoint(VertexGamma);
+   NegParticle.TransportToPoint(VertexGamma);
+   
+   AliKFParticle::GetArmenterosPodolanski(PosParticle, NegParticle, armenterosQtAlpha);
+   
+   return 1;
+}
+
+
+
+
+Bool_t AliV0Reader::GetArmenterosQtAlpha(const AliKFParticle* negativeKFParticle, const AliKFParticle * positiveKFParticle, const AliKFParticle * gammaKFCandidate, Double_t armenterosQtAlpha[2] ){
        //see header file for documentation
 
        TVector3 momentumVectorPositiveKF(positiveKFParticle->GetPx(),positiveKFParticle->GetPy(),positiveKFParticle->GetPz());
@@ -2021,14 +2150,75 @@ Bool_t AliV0Reader::GetArmenterosQtAlfa(const AliKFParticle* negativeKFParticle,
 
        Float_t qt = momentumVectorPositiveKF.Mag()*TMath::Sin(thetaV0pos);
                        
-       armenterosQtAlfa[0]=qt;
-       armenterosQtAlfa[1]=alfa;
+       armenterosQtAlpha[0]=qt;
+       armenterosQtAlpha[1]=alfa;
 
        return 1;
 
 }
 
-Bool_t AliV0Reader::GetArmenterosQtAlfa(const TParticle* negativeParticle, const TParticle * positiveParticle, const AliKFParticle * gammaKFCandidate, Double_t armenterosQtAlfa[2] ){
+Bool_t AliV0Reader::GetArmenterosQtAlpha(const AliESDv0* v0, Double_t armenterosQtAlpha[2])
+{      //see header file for documentation
+
+   Double_t mn[3] = {0,0,0};
+   Double_t mp[3] = {0,0,0};  
+   Double_t mm[3] = {0,0,0};  
+
+
+   Int_t pIndex = 0, nIndex = 0;
+   pIndex = v0->GetPindex();
+   nIndex = v0->GetNindex();
+
+   AliESDtrack* d[2];
+   d[0] = dynamic_cast<AliESDtrack*>(fESDEvent->GetTrack(pIndex));
+   d[1] = dynamic_cast<AliESDtrack*>(fESDEvent->GetTrack(nIndex));
+
+   Int_t sign[2];
+   sign[0] = (int)d[0]->GetSign();
+   sign[1] = (int)d[1]->GetSign();
+  
+   Bool_t correct = kFALSE;
+
+
+   if(-1 == sign[0] && 1 == sign[1]){
+      correct = kFALSE;
+   }
+   else{
+      correct = kTRUE;
+   }
+
+
+   if(correct){
+      v0->GetNPxPyPz(mn[0],mn[1],mn[2]); //reconstructed cartesian momentum components of negative daughter
+      v0->GetPPxPyPz(mp[0],mp[1],mp[2]); //reconstructed cartesian momentum components of positive daughter
+   }
+   else{
+      v0->GetPPxPyPz(mn[0],mn[1],mn[2]); //reconstructed cartesian momentum components of negative daughter
+      v0->GetNPxPyPz(mp[0],mp[1],mp[2]); //reconstructed cartesian momentum components of positive daughter
+   }
+   v0->GetPxPyPz(mm[0],mm[1],mm[2]); //reconstructed cartesian momentum components of mother
+
+   TVector3 vecN(mn[0],mn[1],mn[2]);
+   TVector3 vecP(mp[0],mp[1],mp[2]);
+   TVector3 vecM(mm[0],mm[1],mm[2]);
+  
+   Double_t thetaP = acos((vecP * vecM)/(vecP.Mag() * vecM.Mag()));
+   Double_t thetaN = acos((vecN * vecM)/(vecN.Mag() * vecM.Mag()));
+  
+   Double_t alfa = ((vecP.Mag())*cos(thetaP)-(vecN.Mag())*cos(thetaN))/
+      ((vecP.Mag())*cos(thetaP)+(vecN.Mag())*cos(thetaN)) ;
+   Double_t qt = vecP.Mag()*sin(thetaP);
+
+   armenterosQtAlpha[0]=qt;
+   armenterosQtAlpha[1]=alfa;
+   
+   return 1;
+
+}
+
+
+
+Bool_t AliV0Reader::GetArmenterosQtAlpha(const TParticle* negativeParticle, const TParticle * positiveParticle, const AliKFParticle * gammaKFCandidate, Double_t armenterosQtAlpha[2] ){
        //see header file for documentation
 
        TVector3 momentumVectorPositiveKF(positiveParticle->Px(),positiveParticle->Py(),positiveParticle->Pz());
@@ -2058,13 +2248,13 @@ Bool_t AliV0Reader::GetArmenterosQtAlfa(const TParticle* negativeParticle, const
                qt = momentumVectorPositiveKF.Mag()*TMath::Sin(thetaV0pos);
        }
                
-       armenterosQtAlfa[0]=qt;
-       armenterosQtAlfa[1]=alfa;
+       armenterosQtAlpha[0]=qt;
+       armenterosQtAlpha[1]=alfa;
        return 1;
 
 }
 
-Bool_t AliV0Reader::GetArmenterosQtAlfa(const TParticle* negativeParticle, const TParticle * positiveParticle, const TParticle * gammaCandidate, Double_t armenterosQtAlfa[2] ){
+Bool_t AliV0Reader::GetArmenterosQtAlpha(const TParticle* negativeParticle, const TParticle * positiveParticle, const TParticle * gammaCandidate, Double_t armenterosQtAlpha[2] ){
        //see header file for documentation
 
        TVector3 momentumVectorPositiveKF(positiveParticle->Px(),positiveParticle->Py(),positiveParticle->Pz());
@@ -2094,8 +2284,8 @@ Bool_t AliV0Reader::GetArmenterosQtAlfa(const TParticle* negativeParticle, const
                qt = momentumVectorPositiveKF.Mag()*TMath::Sin(thetaV0pos);
        }
                        
-       armenterosQtAlfa[0]=qt;
-       armenterosQtAlfa[1]=alfa;
+       armenterosQtAlpha[0]=qt;
+       armenterosQtAlpha[1]=alfa;
        return 1;
 
 }
@@ -2161,3 +2351,156 @@ void AliV0Reader::SmearKFParticle(AliKFParticle * kfParticle)
        kfParticle->Pz() = facPBrem* (1+facPSig)* P*cos(theta) ;
        kfParticle->E() = kfParticle->GetP();
 }
+
+///________________________________________________________________________
+const AliExternalTrackParam *AliV0Reader::GetExternalTrackParam(AliESDv0 *v0,Int_t charge){
+
+    if(!(charge==1||charge==-1)){AliError("Charge not defined");return 0x0;}
+
+    Int_t label;
+    if(charge>0)label=0;
+    else label=1;
+    // Check for sign flip
+
+    if(v0){
+       if(!v0->GetParamN()||!v0->GetParamP())return 0x0;
+       if(!GetTrack(v0->GetNindex())||!fESDEvent->GetTrack(v0->GetPindex()))return 0x0;
+       if((GetTrack(v0->GetPindex()))->Charge()==charge){
+//         fCurrentTrackLabels[label]=v0->GetPindex();
+           return v0->GetParamP();}
+       if((GetTrack(v0->GetNindex()))->Charge()==charge){
+//         fCurrentTrackLabels[label]=v0->GetNindex();
+           return v0->GetParamN();}
+    }
+    return 0x0;
+}
+
+///________________________________________________________________________
+AliVTrack *AliV0Reader::GetTrack(Int_t label){
+    if(fESDEvent){
+               return (AliESDtrack*)fESDEvent->GetTrack(label);
+    }
+//     if(fAODEvent)return (AliAODTrack*)GetAODTrack(label);
+       return 0x0;
+}
+
+Double_t AliV0Reader::GetV0CosineOfPointingAngle(Double_t V0PointX, Double_t V0PointY, Double_t V0PointZ){
+   // calculates the pointing angle of the recalculated V0 
+
+   Double_t momV0[3]; //momentum of the V0
+   fCurrentV0->GetPxPyPz(momV0[0],momV0[1],momV0[2]);
+
+   Double_t PosV0[3]; //Recalculated V0 Position vector
+  
+   PosV0[0] = V0PointX - fESDEvent->GetPrimaryVertex()->GetX();
+   PosV0[1] = V0PointY - fESDEvent->GetPrimaryVertex()->GetY();
+   PosV0[2] = V0PointZ - fESDEvent->GetPrimaryVertex()->GetZ();
+
+   Double_t momV02 = momV0[0]*momV0[0] + momV0[1]*momV0[1] + momV0[2]*momV0[2];
+   Double_t PosV02 = PosV0[0]*PosV0[0] + PosV0[1]*PosV0[1] + PosV0[2]*PosV0[2];
+
+   Double_t cosinePointingAngle = (PosV0[0]*momV0[0] +  PosV0[1]*momV0[1] + PosV0[2]*momV0[2] ) / TMath::Sqrt(momV02 * PosV02);
+   return cosinePointingAngle;
+}
+
+
+Double_t AliV0Reader::GetPsiPair(AliESDv0* v0)
+{
+   //
+   // Angle between daughter momentum plane and plane 
+   // 
+   Float_t magField = fESDEvent->GetMagneticField();
+
+   Double_t xyz[3] = {0.,0.,0.};
+   v0->GetXYZ(xyz[0],xyz[1],xyz[2]);
+     
+   Double_t mn[3] = {0,0,0};
+   Double_t mp[3] = {0,0,0};
+  
+   v0->GetNPxPyPz(mn[0],mn[1],mn[2]);//reconstructed cartesian momentum components of negative daughter;
+   v0->GetPPxPyPz(mp[0],mp[1],mp[2]);//reconstructed cartesian momentum components of positive daughter; 
+
+   Double_t deltat = 1.;
+   deltat = TMath::ATan(mp[2]/(TMath::Sqrt(mp[0]*mp[0] + mp[1]*mp[1])+1.e-13)) -  TMath::ATan(mn[2]/(TMath::Sqrt(mn[0]*mn[0] + mn[1]*mn[1])+1.e-13));//difference of angles of the two daughter tracks with z-axis
+   Double_t radiussum = TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]) + 50;//radius to which tracks shall be propagated 
+   Double_t momPosProp[3] = {0,0,0};
+   Double_t momNegProp[3] = {0,0,0};
+    
+   AliExternalTrackParam nt = *(v0->GetParamN());
+   AliExternalTrackParam pt = *(v0->GetParamP());
+
+   Double_t psiPair = 4.;
+   if(nt.PropagateTo(radiussum,magField) == 0) return psiPair; //propagate tracks to the outside -> Better Purity and Efficiency
+   
+   if(pt.PropagateTo(radiussum,magField) == 0) return psiPair; //propagate tracks to the outside -> Better Purity and Efficiency
+  
+   pt.GetPxPyPz(momPosProp);//Get momentum vectors of tracks after propagation
+   nt.GetPxPyPz(momNegProp);
+
+  Double_t pEle =
+     TMath::Sqrt(momNegProp[0]*momNegProp[0]+momNegProp[1]*momNegProp[1]+momNegProp[2]*momNegProp[2]);//absolute momentum value of negative daughter
+
+  Double_t pPos =
+     TMath::Sqrt(momPosProp[0]*momPosProp[0]+momPosProp[1]*momPosProp[1]+momPosProp[2]*momPosProp[2]);//absolute momentum value of positive daughter
+    
+  Double_t scalarproduct =
+     momPosProp[0]*momNegProp[0]+momPosProp[1]*momNegProp[1]+momPosProp[2]*momNegProp[2];//scalar product of propagated positive and negative daughters' momenta
+    
+  Double_t chipair = TMath::ACos(scalarproduct/(pEle*pPos));//Angle between propagated daughter tracks
+
+  psiPair =  TMath::Abs(TMath::ASin(deltat/chipair));  
+
+  return psiPair; 
+}
+
+Int_t AliV0Reader::GetNumberOfHijingPlusPythiaPrimeries(){
+   
+   // Calculate NPrimaries for LHC11a10b_*
+
+   Int_t nproduced = 0;
+   AliGenCocktailEventHeader *cHeader = dynamic_cast<AliGenCocktailEventHeader*>(fMCEvent->GenEventHeader());
+   if(cHeader){
+      TList *genHeaders = cHeader->GetHeaders();
+      AliGenEventHeader* gh = 0;
+      for(Int_t i = 0; i<genHeaders->GetEntries();i++){
+         gh = (AliGenEventHeader*)genHeaders->At(i);
+         TString GeneratorName = gh->GetName();
+         //  cout<<i<<"   "<<GeneratorName<<"   "<<gh->NProduced()<<endl;
+         if(GeneratorName.CompareTo("Hijing") == 0){
+            nproduced = nproduced + gh->NProduced();
+         }
+         else if(GeneratorName.CompareTo("Pythia") == 0){
+            nproduced = nproduced + gh->NProduced();
+         }
+      }
+   }
+   if(!cHeader){
+      nproduced = fMCStack->GetNprimary();
+   }
+   
+   //  cout<<fMCStack->GetNprimary()-nproduced<<endl;
+
+   return nproduced;
+}
+
+
+Bool_t AliV0Reader::IsParticleFromBGEvent(Int_t index){
+
+   Bool_t particleFromBG = kFALSE;
+  
+   if(index == -1) return kFALSE;
+   if(index > fNumberOfPrimerisFromHijingAndPythia && index < fMCStack->GetNprimary()){
+      // cout<<index<<"   "<<fNumberOfPrimerisFromHijingAndPythia<<endl;
+      return kTRUE;
+   }
+   //  else cout<<"Passt Noch "<<index<<"   "<<fNumberOfPrimerisFromHijingAndPythia<<endl;
+   // cout<<fMCEvent->IsFromBGEvent(index)<<endl;
+   TParticle *BGParticle = fMCStack->Particle(index);
+   if(BGParticle->GetMother(0) > -1)  return kFALSE;
+   Int_t indexMother = fMCStack->Particle(index)->GetMother(0);
+   particleFromBG = IsParticleFromBGEvent(indexMother);
+   
+   return kFALSE;
+}
index 33799933e04836fbd3443b794d57dacb8609e727..d67348d6ca96a530efad8c4436b99392d4844d82 100644 (file)
@@ -49,998 +49,1044 @@ class TRandom3;
 
 class AliV0Reader : public TObject {
        
- public: 
-       
-       
-  // for CF
-  enum{
-    kStepGenerated = 0,
-    kStepReconstructable = 1, 
-    kStepGetOnFly = 2,
-    kStepLikeSign = 3,
-    kStepTPCRefit = 4,
-    kStepKinks = 5,
-    kStepdEdxElectronselection = 6,
-    kStepdEdxPionrejection = 7,
-    kStepNContributors = 8,
-    kStepTPCPID = 9,
-    kStepR = 10,
-    kStepLine = 11,
-    kStepZ = 12,
-    kStepMinClsTPC = 13,
-    kStepSinglePt= 14,  
-    kStepNDF = 15,
-    kStepChi2 = 16,
-    kStepEta = 17,
-    kStepPt = 18,
-    kStepTrueGamma = 19
-  };
-       
-  AliV0Reader();                                        //constructor
-  AliV0Reader(const AliV0Reader & g);                   //copy constructor
-  AliV0Reader & operator = (const AliV0Reader & g);     //assignment operator
-  //  virtual ~AliV0Reader() {;}                            //virtual destructor
-  virtual ~AliV0Reader();                            //virtual destructor
-  /*
-   *Initialize the reader
-   */
-  void Initialize();
-  void SetInputAndMCEvent(AliVEvent* esd, AliMCEvent* mc) ;
-
+       public: 
+       
+       
+       // for CF
+       enum{
+               kStepGenerated = 0,
+               kStepReconstructable = 1, 
+               kStepGetOnFly = 2,
+               kStepLikeSign = 3,
+               kStepTPCRefit = 4,
+               kStepKinks = 5,
+               kStepdEdxElectronselection = 6,
+               kStepdEdxPionrejection = 7,
+               kStepNContributors = 8,
+               kStepTPCPID = 9,
+               kStepR = 10,
+               kStepLine = 11,
+               kStepZ = 12,
+               kStepMinClsTPC = 13,
+               kStepSinglePt= 14,  
+               kStepNDF = 15,
+               kStepChi2 = 16,
+               kStepEta = 17,
+               kStepPt = 18,
+               kStepTrueGamma = 19
+       };
+       
+       AliV0Reader();                                        //constructor
+       AliV0Reader(const AliV0Reader & g);                   //copy constructor
+       AliV0Reader & operator = (const AliV0Reader & g);     //assignment operator
+       //  virtual ~AliV0Reader() {;}                            //virtual destructor
+       virtual ~AliV0Reader();                            //virtual destructor
+       /*
+               *Initialize the reader
+               */
+       void Initialize();
+       void SetInputAndMCEvent(AliVEvent* esd, AliMCEvent* mc) ;
+
+
+       virtual void SetInputEvent(AliVEvent* const input)  {fESDEvent  = dynamic_cast<AliESDEvent*>(input);}
+       virtual void SetMC(AliMCEvent* const mc)            {fMCEvent = mc;}
 
-  virtual void SetInputEvent(AliVEvent* const input)  {fESDEvent  = dynamic_cast<AliESDEvent*>(input);}
-  virtual void SetMC(AliMCEvent* const mc)            {fMCEvent = mc;}
+               
+       // for CF
+       void SetCFManager(AliCFManager * const io){fCFManager = io;};
+       AliCFManager *GetCFManager() const {return fCFManager;}
+               
+               
+               
+               
+       /*
+               * Returns  AliESDEvent
+               */                      
+       AliESDEvent* GetESDEvent() const{return fESDEvent;}     
+               
+       /*
+               *Returns the number of v0s in the event, no cuts applied.
+               */
+       Int_t GetNumberOfV0s() const{return fESDEvent->GetNumberOfV0s();}
+               
+       /*
+               *Returns the number of contributors to the vertex
+               */
+       //  Int_t GetNumberOfContributorsVtx() const{return fESDEvent->GetPrimaryVertex()->GetNContributors();}
+       Int_t GetNumberOfContributorsVtx();
+       
+       /*
+               * Check if there are any more good v0s left in the v0 stack
+               * if so, fCurrent v0 is set to this v0 and can be retrieved
+               * by GetCurrentV0 function.
+               * returns kFALSE if there is no more good v0s in the v0 stack
+               */
+       Bool_t NextV0();
+               
+       /*
+               * Returns the v0 at the given index, no checks are done on the v0. 
+               */
+       AliESDv0* GetV0(Int_t index);
+               
+       /*
+               * Returns the current v0
+               */
+       AliESDv0* GetCurrentV0() const{return fCurrentV0;}
+               
+       /*
+               * Returns the negative ESD track which belongs to fCurrentV0
+               */
+       //  AliESDtrack* GetNegativeESDTrack(){return fESDEvent->GetTrack(fCurrentV0->GetNindex());}
+       AliESDtrack* GetNegativeESDTrack(){return fCurrentNegativeESDTrack;}
+               
+       /*
+               * Returns the positive ESD track which belongs to fCurrentV0
+               */
+       //  AliESDtrack* GetPositiveESDTrack(){return fESDEvent->GetTrack(fCurrentV0->GetPindex());}
+       AliESDtrack* GetPositiveESDTrack(){return fCurrentPositiveESDTrack;}
+               
+       /*
+               * Returns the negative KF particle which belongs to fCurrentV0
+               */
+       AliKFParticle* GetNegativeKFParticle() const{return fCurrentNegativeKFParticle;}
+               
+       /*
+               * Returns the positive KF particle which belongs to fCurrentV0
+               */
+       AliKFParticle* GetPositiveKFParticle() const{return fCurrentPositiveKFParticle;}
+               
+       /*
+               * Returns the KFParticle object of the 2 tracks.
+               */
+       AliKFParticle* GetMotherCandidateKFCombination() const{return fCurrentMotherKFCandidate;}
+               
+       /*
+               * Checks the probablity that the PID of the particle is what we want it to be.
+               */
+       Bool_t CheckPIDProbability(Double_t negProbCut, Double_t posProbCut);
+               
+       /*
+               * Checks if the PID of the two particles are within our cuts.
+               */
+       void GetPIDProbability(Double_t &negPIDProb, Double_t &posPIDProb);
+
+       /*
+               * Checks if the PID of the two particles are within our cuts.
+               */
+       void GetPIDProbabilityMuonPion(Double_t &negPIDProb, Double_t &posPIDProb);
+               
+       /*
+               *Get the negative MC TParticle from the stack 
+               */
+       TParticle * GetNegativeMCParticle() const{return fNegativeMCParticle;}
+               
+       /*
+               *Get the positive MC TParticle from the stack 
+               */
+       TParticle * GetPositiveMCParticle() const{return fPositiveMCParticle;}
+               
+       /*
+               *Get the mother MC TParticle from the stack 
+               */
+       TParticle * GetMotherMCParticle() const{return fMotherMCParticle;}
+               
+       /*
+               * Flag to see if the v0 particles share the same mother
+               */
+       Bool_t HasSameMCMother();
+               
+               
+       /*
+               *Get the PID of the MC mother particle
+               */
+       Int_t GetMotherMCParticlePDGCode() const{return fMotherMCParticle->GetPdgCode();}
+               
+       /*
+               *Get the MC stack 
+               */
+       AliStack* GetMCStack() const{return fMCStack;}
+               
+               
+       /*
+               * Setup  AliMCEventHandler
+               */                      
+       //  AliMCEventHandler* GetMCTruth() const{return fMCTruth;}     // for CF
+               
+               
+       /*
+               *Get the MC stack 
+               */
+       AliMCEvent* GetMCEvent() const{return fMCEvent;}   // for CF
+               
+               
+       /*
+               *Get the magnetic field from the ESD event 
+               */
+       Double_t GetMagneticField() const{return fESDEvent->GetMagneticField();}
+               
+       /*
+               *Get the primary vertex from the esd event
+               */
+       const AliESDVertex *GetPrimaryVertex() const {return fESDEvent->GetPrimaryVertex();}
+
+       /*
+               Calculate cos Pointing angle with new coords
+        */
+       Double_t GetV0CosineOfPointingAngle(Double_t V0PointX, Double_t V0PointY, Double_t V0PointZ);
+
+       /*
+               * Set the PID of the negative track
+               */
+       void SetNegativeTrackPID(Int_t negTrackPID){fNegativeTrackPID=negTrackPID;}
+               
+       /*
+               * Set the PID of the positive track
+               */
+       void SetPositiveTrackPID(Int_t posTrackPID){fPositiveTrackPID=posTrackPID;}
+               
+       /*
+               * Set the flag to use the kfparticle class. Will also disable the use of esd tracks
+               */
+       void UseKFParticle(){fUseKFParticle = kTRUE; fUseESDTrack = kFALSE;}
+               
+       /*
+               *  Set the flag to use the esd track class. Will also disable the use of kf particles
+               */
+       void UseESDTrack(){fUseESDTrack = kTRUE; fUseKFParticle = kFALSE;}
+               
+       /*
+               *  Set the flag to use improved vertex or not
+               */
+       void SetUseImprovedVertex(Bool_t useImprovedVertex){fUseImprovedVertex=useImprovedVertex;}
+               
+       /*
+               * Return the number in the species array belonging to the negative or positive track pid.
+               */
+       Int_t GetSpeciesIndex(Int_t chargeOfTrack);
+               
+       /*
+               * Return the x coordinate of the v0
+               */
+       Double_t GetX() const{return fCurrentXValue;}
+               
+       /*
+               * Return the y coordinate of the v0
+               */
+       Double_t GetY() const{return fCurrentYValue;}
+               
+       /*
+               * Return the Z coordinate of the v0
+               */
+       Double_t GetZ() const{return fCurrentZValue;}
+               
+       /*
+               * Return the radius of the v0
+               */
+       Double_t GetXYRadius() const{return sqrt((Double_t)(fCurrentXValue*fCurrentXValue + fCurrentYValue*fCurrentYValue));}
+               
+       /*
+               * Get the opening angle between the two tracks
+               */
+       Double_t GetOpeningAngle(){return fNegativeTrackLorentzVector->Angle(fPositiveTrackLorentzVector->Vect());}
+
+       /*
+               * Get the Cos Pointing angle between the two tracks
+               */
+       Double_t GetCosPointingAngle(){return fCurrentV0->GetV0CosineOfPointingAngle();}
+
+       /*
+        * Get the PsiPair angle between the two tracks
+        */
+       Double_t GetPsiPair(AliESDv0* v0);
+        /*
+         * Check If Particle is from BG Event
+         */
+        Bool_t IsParticleFromBGEvent(Int_t index);
+        /*
+         * GetNumberOfPrimariesFromHijingAndPythia
+         */
+        Int_t GetNumberOfHijingPlusPythiaPrimeries();
+        Int_t GetPrimeriesFromHijingAndPythia(){return fNumberOfPrimerisFromHijingAndPythia;}
+       /*
+         * Get the DCA between the two tracks
+         */
+       Double_t GetDcaDaughters(){return fCurrentV0->GetDcaV0Daughters();}
+
+       /*
+               * Get the Normalized DCA between the two tracks
+               */
+       Double_t GetNormDcaDistDaughters(){return fCurrentV0->GetDcaV0Daughters()/fCurrentV0->GetDistSigma();}
+
+       /*
+               * Get the Likelihood for a Conversion
+               */
+       Double_t GetLikelihoodAP(){return fCurrentV0->GetLikelihoodAP(0,0);}
+                       
+       /*
+               * Gets the Energy of the negative track.
+               */
+       Double_t GetNegativeTrackEnergy() const{return fCurrentNegativeKFParticle->E();}
+               
+       /*
+               * Gets the Energy of the positive track.
+               */
+       Double_t GetPositiveTrackEnergy() const{return fCurrentPositiveKFParticle->E();}
+               
+       /*
+               * Gets the Energy of the mother candidate.
+               */
+       Double_t GetMotherCandidateEnergy() const{return fCurrentMotherKFCandidate->E();}
+               
+       /*
+               * Gets the Pt of the negative track.
+               */
+       Double_t GetNegativeTrackPt() const{return fNegativeTrackLorentzVector->Pt();}
+               
+       /*
+               * Gets the Pt of the positive track.
+               */
+       Double_t GetPositiveTrackPt() const{return fPositiveTrackLorentzVector->Pt();}
+               
 
-       
-  // for CF
-  void SetCFManager(AliCFManager * const io){fCFManager = io;};
-  AliCFManager *GetCFManager() const {return fCFManager;}
-       
-       
-       
-       
-  /*
-   * Returns  AliESDEvent
-   */                  
-  AliESDEvent* GetESDEvent() const{return fESDEvent;}  
-       
-  /*
-   *Returns the number of v0s in the event, no cuts applied.
-   */
-  Int_t GetNumberOfV0s() const{return fESDEvent->GetNumberOfV0s();}
-       
-  /*
-   *Returns the number of contributors to the vertex
-   */
-  //  Int_t GetNumberOfContributorsVtx() const{return fESDEvent->GetPrimaryVertex()->GetNContributors();}
-  Int_t GetNumberOfContributorsVtx();
-  
-  /*
-   * Check if there are any more good v0s left in the v0 stack
-   * if so, fCurrent v0 is set to this v0 and can be retrieved
-   * by GetCurrentV0 function.
-   * returns kFALSE if there is no more good v0s in the v0 stack
-   */
-  Bool_t NextV0();
-       
-  /*
-   * Returns the v0 at the given index, no checks are done on the v0. 
-   */
-  AliESDv0* GetV0(Int_t index);
-       
-  /*
-   * Returns the current v0
-   */
-  AliESDv0* GetCurrentV0() const{return fCurrentV0;}
-       
-  /*
-   * Returns the negative ESD track which belongs to fCurrentV0
-   */
-  //  AliESDtrack* GetNegativeESDTrack(){return fESDEvent->GetTrack(fCurrentV0->GetNindex());}
-  AliESDtrack* GetNegativeESDTrack(){return fCurrentNegativeESDTrack;}
-       
-  /*
-   * Returns the positive ESD track which belongs to fCurrentV0
-   */
-  //  AliESDtrack* GetPositiveESDTrack(){return fESDEvent->GetTrack(fCurrentV0->GetPindex());}
-  AliESDtrack* GetPositiveESDTrack(){return fCurrentPositiveESDTrack;}
-       
-  /*
-   * Returns the negative KF particle which belongs to fCurrentV0
-   */
-  AliKFParticle* GetNegativeKFParticle() const{return fCurrentNegativeKFParticle;}
-       
-  /*
-   * Returns the positive KF particle which belongs to fCurrentV0
-   */
-  AliKFParticle* GetPositiveKFParticle() const{return fCurrentPositiveKFParticle;}
-       
-  /*
-   * Returns the KFParticle object of the 2 tracks.
-   */
-  AliKFParticle* GetMotherCandidateKFCombination() const{return fCurrentMotherKFCandidate;}
-       
-  /*
-   * Checks the probablity that the PID of the particle is what we want it to be.
-   */
-  Bool_t CheckPIDProbability(Double_t negProbCut, Double_t posProbCut);
-       
-  /*
-   * Checks if the PID of the two particles are within our cuts.
-   */
-  void GetPIDProbability(Double_t &negPIDProb, Double_t &posPIDProb);
-
-  /*
-   * Checks if the PID of the two particles are within our cuts.
-   */
-  void GetPIDProbabilityMuonPion(Double_t &negPIDProb, Double_t &posPIDProb);
-       
-  /*
-   *Get the negative MC TParticle from the stack 
-   */
-  TParticle * GetNegativeMCParticle() const{return fNegativeMCParticle;}
-       
-  /*
-   *Get the positive MC TParticle from the stack 
-   */
-  TParticle * GetPositiveMCParticle() const{return fPositiveMCParticle;}
-       
-  /*
-   *Get the mother MC TParticle from the stack 
-   */
-  TParticle * GetMotherMCParticle() const{return fMotherMCParticle;}
-       
-  /*
-   * Flag to see if the v0 particles share the same mother
-   */
-  Bool_t HasSameMCMother();
-       
-       
-  /*
-   *Get the PID of the MC mother particle
-   */
-  Int_t GetMotherMCParticlePDGCode() const{return fMotherMCParticle->GetPdgCode();}
-       
-  /*
-   *Get the MC stack 
-   */
-  AliStack* GetMCStack() const{return fMCStack;}
-       
-       
-  /*
-   * Setup  AliMCEventHandler
-   */                  
-  //  AliMCEventHandler* GetMCTruth() const{return fMCTruth;}  // for CF
-       
-       
-  /*
-   *Get the MC stack 
-   */
-  AliMCEvent* GetMCEvent() const{return fMCEvent;}   // for CF
-       
-       
-  /*
-   *Get the magnetic field from the ESD event 
-   */
-  Double_t GetMagneticField() const{return fESDEvent->GetMagneticField();}
-       
-  /*
-   *Get the primary vertex from the esd event
-   */
-  const AliESDVertex *GetPrimaryVertex() const {return fESDEvent->GetPrimaryVertex();}
-       
-  /*
-   * Set the PID of the negative track
-   */
-  void SetNegativeTrackPID(Int_t negTrackPID){fNegativeTrackPID=negTrackPID;}
-       
-  /*
-   * Set the PID of the positive track
-   */
-  void SetPositiveTrackPID(Int_t posTrackPID){fPositiveTrackPID=posTrackPID;}
-       
-  /*
-   * Set the flag to use the kfparticle class. Will also disable the use of esd tracks
-   */
-  void UseKFParticle(){fUseKFParticle = kTRUE; fUseESDTrack = kFALSE;}
-       
-  /*
-   *  Set the flag to use the esd track class. Will also disable the use of kf particles
-   */
-  void UseESDTrack(){fUseESDTrack = kTRUE; fUseKFParticle = kFALSE;}
-       
-  /*
-   *  Set the flag to use improved vertex or not
-   */
-  void SetUseImprovedVertex(Bool_t useImprovedVertex){fUseImprovedVertex=useImprovedVertex;}
-       
-  /*
-   * Return the number in the species array belonging to the negative or positive track pid.
-   */
-  Int_t GetSpeciesIndex(Int_t chargeOfTrack);
-       
-  /*
-   * Return the x coordinate of the v0
-   */
-  Double_t GetX() const{return fCurrentXValue;}
-       
-  /*
-   * Return the y coordinate of the v0
-   */
-  Double_t GetY() const{return fCurrentYValue;}
-       
-  /*
-   * Return the Z coordinate of the v0
-   */
-  Double_t GetZ() const{return fCurrentZValue;}
-       
-  /*
-   * Return the radius of the v0
-   */
-  Double_t GetXYRadius() const{return sqrt((Double_t)(fCurrentXValue*fCurrentXValue + fCurrentYValue*fCurrentYValue));}
-       
-  /*
-   * Get the opening angle between the two tracks
-   */
-  Double_t GetOpeningAngle(){return fNegativeTrackLorentzVector->Angle(fPositiveTrackLorentzVector->Vect());}
-
-  /*
-   * Get the Cos Pointing angle between the two tracks
-   */
-  Double_t GetCosPointingAngle(){return fCurrentV0->GetV0CosineOfPointingAngle();}
-
-  /*
-   * Get the DCA between the two tracks
-   */
-  Double_t GetDcaDaughters(){return fCurrentV0->GetDcaV0Daughters();}
-
-  /*
-   * Get the Normalized DCA between the two tracks
-   */
-  Double_t GetNormDcaDistDaughters(){return fCurrentV0->GetDcaV0Daughters()/fCurrentV0->GetDistSigma();}
-
-  /*
-   * Get the Likelihood for a Conversion
-   */
-  Double_t GetLikelihoodAP(){return fCurrentV0->GetLikelihoodAP(0,0);}
-      
-  /*
-   * Gets the Energy of the negative track.
-   */
-  Double_t GetNegativeTrackEnergy() const{return fCurrentNegativeKFParticle->E();}
-       
-  /*
-   * Gets the Energy of the positive track.
-   */
-  Double_t GetPositiveTrackEnergy() const{return fCurrentPositiveKFParticle->E();}
-       
-  /*
-   * Gets the Energy of the mother candidate.
-   */
-  Double_t GetMotherCandidateEnergy() const{return fCurrentMotherKFCandidate->E();}
-       
-  /*
-   * Gets the Pt of the negative track.
-   */
-  Double_t GetNegativeTrackPt() const{return fNegativeTrackLorentzVector->Pt();}
-       
-  /*
-   * Gets the Pt of the positive track.
-   */
-  Double_t GetPositiveTrackPt() const{return fPositiveTrackLorentzVector->Pt();}
-       
+       /*
+               * Gets the Pt of the mother candidate.
+               */
+       Double_t GetMotherCandidatePt() const{return fMotherCandidateLorentzVector->Pt();}
 
-  /*
-   * Gets the Pt of the mother candidate.
-   */
-  Double_t GetMotherCandidatePt() const{return fMotherCandidateLorentzVector->Pt();}
 
+       /*
+               * Gets the P of the mother candidate.
+               */
+       Double_t GetMotherCandidateP() const{return fMotherCandidateLorentzVector->P();}
+               
 
-  /*
-   * Gets the P of the mother candidate.
-   */
-  Double_t GetMotherCandidateP() const{return fMotherCandidateLorentzVector->P();}
-       
+       /*
+               * Gets the Eta of the negative track.
+               */
+       Double_t GetNegativeTrackEta() const{return fNegativeTrackLorentzVector->Eta();}
+       /*
+               * Gets the Eta of the positive track.
+               */
+       Double_t GetPositiveTrackEta() const{return fPositiveTrackLorentzVector->Eta();}
+       /*
+               * Gets the Eta of the mother candidate.
+               */
+       Double_t GetMotherCandidateEta() const{return fMotherCandidateLorentzVector->Eta();}
+               
+       /*
+               * Gets the NDF of the mother candidate.
+               */
+       Double_t GetMotherCandidateNDF() const{return fCurrentMotherKFCandidate->GetNDF();}
+               
+       /*
+               * Gets the Chi2 of the mother candidate.
+               */
+       Double_t GetMotherCandidateChi2() const{return fCurrentMotherKFCandidate->GetChi2();}
+               
+       /*
+               * Gets the Mass of the mother candidate.
+               */
+       Double_t GetMotherCandidateMass() const{return fMotherCandidateKFMass;}
+               
+       /*
+               * Gets the Width of the mother candidate.
+               */
+       Double_t GetMotherCandidateWidth() const{return fMotherCandidateKFWidth;}
+               
+       /*
+               * Gets the Phi of the negative track.
+               */
+       Double_t GetNegativeTrackPhi() const;
+               
+       /*
+               * Gets the Phi of the positive track.
+               */
+       Double_t GetPositiveTrackPhi() const;
+               
+       /*
+               * Gets the Phi of the mother candidate.
+               */
+       Double_t GetMotherCandidatePhi() const;
+               
+       /*
+               * Gets the Rapidity of the mother candidate.
+               */
+       Double_t GetMotherCandidateRapidity() const;
+               
 
-  /*
-   * Gets the Eta of the negative track.
-   */
-  Double_t GetNegativeTrackEta() const{return fNegativeTrackLorentzVector->Eta();}
-  /*
-   * Gets the Eta of the positive track.
-   */
-  Double_t GetPositiveTrackEta() const{return fPositiveTrackLorentzVector->Eta();}
-  /*
-   * Gets the Eta of the mother candidate.
-   */
-  Double_t GetMotherCandidateEta() const{return fMotherCandidateLorentzVector->Eta();}
-       
-  /*
-   * Gets the NDF of the mother candidate.
-   */
-  Double_t GetMotherCandidateNDF() const{return fCurrentMotherKFCandidate->GetNDF();}
-       
-  /*
-   * Gets the Chi2 of the mother candidate.
-   */
-  Double_t GetMotherCandidateChi2() const{return fCurrentMotherKFCandidate->GetChi2();}
-       
-  /*
-   * Gets the Mass of the mother candidate.
-   */
-  Double_t GetMotherCandidateMass() const{return fMotherCandidateKFMass;}
-       
-  /*
-   * Gets the Width of the mother candidate.
-   */
-  Double_t GetMotherCandidateWidth() const{return fMotherCandidateKFWidth;}
-       
-  /*
-   * Gets the Phi of the negative track.
-   */
-  Double_t GetNegativeTrackPhi() const;
-       
-  /*
-   * Gets the Phi of the positive track.
-   */
-  Double_t GetPositiveTrackPhi() const;
-       
-  /*
-   * Gets the Phi of the mother candidate.
-   */
-  Double_t GetMotherCandidatePhi() const;
-       
-  /*
-   * Gets the Rapidity of the mother candidate.
-   */
-  Double_t GetMotherCandidateRapidity() const;
-       
+       /*
+               * Gets the P of the negative track.
+               */
+       Double_t GetNegativeTrackP() const{return fNegativeTrackLorentzVector->P();}
+               
+       /*
+               * Gets the P of the positive track.
+               */
+       Double_t GetPositiveTrackP() const{return fPositiveTrackLorentzVector->P();}
+
+       /*
+               * Gets the dE/dx in the TPC of the negative track.
+               */
+       Double_t GetNegativeTrackTPCdEdx() const{return fCurrentNegativeESDTrack->GetTPCsignal();}
+               
+       /*
+               * Gets the dE/dx in the TPC of the positive track.
+               */
+       Double_t GetPositiveTrackTPCdEdx() const{return fCurrentPositiveESDTrack->GetTPCsignal();}
+
+       /*
+               * Gets the Number of the TPC clusters of the negative track.
+               */
+       Int_t GetNegativeTracknTPCClusters() const{return fCurrentNegativeESDTrack->GetNcls(1);}
+
+       /*
+               * Gets the Number of the TPC clusters of the positive track.
+               */
+       Int_t GetPositiveTracknTPCClusters() const{return fCurrentPositiveESDTrack->GetNcls(1);}
+
+       /*
+               * Get the TOFsignal for negative/positive track. RRnewTOF
+               */
+       Double_t GetNegativeTrackTOFsignal() const{return fCurrentNegativeESDTrack->GetTOFsignal();}
+       Double_t GetPositiveTrackTOFsignal() const{return fCurrentPositiveESDTrack->GetTOFsignal();}    
+
+       /*
+               * Gets the Number of the TPC findable clusters of the negative track.
+               */
+       Int_t GetNegativeTracknTPCFClusters() const{return fCurrentNegativeESDTrack->GetTPCNclsF();}
+
+       /*
+               * Gets the Number of the TPC findable clusters of the positive track.
+               */
+       Int_t GetPositiveTracknTPCFClusters() const{return fCurrentPositiveESDTrack->GetTPCNclsF();}
+
+       /*
+               * Gets the Number of the ITS clusters of the negative track.
+               */
+       Int_t GetNegativeTracknITSClusters() const{return fCurrentNegativeESDTrack->GetNcls(0);}
+
+       /*
+               * Gets the Number of the ITS clusters of the positive track.
+               */
+       Int_t GetPositiveTracknITSClusters() const{return fCurrentPositiveESDTrack->GetNcls(0);}
+
+       /*
+               * Gets the chi2 of the TPC  negative track.
+               */
+       Double_t GetNegativeTrackTPCchi2() const{return fCurrentNegativeESDTrack->GetTPCchi2();}
+
+       /*
+               * Gets the chi2 of the TPC  the positive track.
+               */
+       Double_t GetPositiveTrackTPCchi2() const{return fCurrentPositiveESDTrack->GetTPCchi2();}
+               
+       /*
+               * Update data which need to be updated every event.
+               */
+       void UpdateEventByEventData();
+
+       /*
+               * Gets the MaxRCut value.
+               */
+       Double_t GetMaxVertexZ() const{return fMaxVertexZ;}
+               
+       /*
+               * Gets the MaxRCut value.
+               */
+       Double_t GetMaxRCut() const{return fMaxR;}
+
+               /*
+               * Gets the MinRCut value.
+               */
+               Double_t GetMinRCut() const{return fMinR;}
+               
+       /*
+               * Gets the Eta cut value.
+               */
+       Double_t GetEtaCut() const{return fEtaCut;}
+
+       /*
+               * Gets the Eta cut value.
+               */
+       Double_t GetEtaCutMin() const{return fEtaCutMin;}
+
+       /*
+               * Gets the Rapidity Meson cut value.
+               */
+       Double_t GetRapidityMesonCut() const{return fRapidityMesonCut;}
+               
+       /*
+               * Gets the Pt cut value.
+               */
+       Double_t GetPtCut() const{return fPtCut;}
+       Double_t GetSinglePtCut() const{return fSinglePtCut;}   
+               
+       /*
+               * Gets the MaxZCut value.
+               */
+       Double_t GetMaxZCut() const{return fMaxZ;}
+               
+               
+       /*
+               * Gets the MinClsTPC value.
+               */
+       Double_t GetMinClsTPCCut() const{return fMinClsTPC;}
+               
+       /*
+               * Gets the MinClsTPC value.
+               */
+       Double_t GetMinClsTPCCutToF() const{return fMinClsTPCToF;}
+       
+       const AliExternalTrackParam *GetExternalTrackParam(AliESDv0 *v0,Int_t charge);
+       const AliExternalTrackParam *GetExternalTrackParamP(AliESDv0 *v0){return GetExternalTrackParam(v0,1);};
+       const AliExternalTrackParam *GetExternalTrackParamN(AliESDv0 *v0){return GetExternalTrackParam(v0,-1);};
+       
+       AliVTrack *GetTrack(Int_t label);
+
+       /*
+               * Gets the line cut values.
+               */
+       Double_t GetLineCutZRSlope() const{return fLineCutZRSlope;}
+       Double_t GetLineCutZRSlopeMin() const{return fLineCutZRSlopeMin;}
+       Double_t GetLineCutZValue() const{return fLineCutZValue;}
+       Double_t GetLineCutZValueMin() const{return fLineCutZValueMin;} 
+       /*
+               * Gets the Chi2 cut value for the conversions.
+               */
+       Double_t GetChi2CutConversion() const{return fChi2CutConversion;}
+               
+       /*
+               * Gets the Chi2 cut value for the mesons.
+               */
+       Double_t GetChi2CutMeson() const{return fChi2CutMeson;}
+               
+       /*
+               * Gets the alpha cut value for the mesons.
+               */
+       Double_t GetAlphaCutMeson() const{return fAlphaCutMeson;}
+
+       /*
+               * Gets the Minimum alpha cut value for the mesons.
+               */
+       Double_t GetAlphaMinCutMeson() const{return fAlphaMinCutMeson;}
+
+       Double_t GetPositiveTrackLength() const{return fCurrentPositiveESDTrack->GetIntegratedLength();}
+       Double_t GetNegativeTrackLength() const{return fCurrentNegativeESDTrack->GetIntegratedLength();}
+               
+       Double_t GetPositiveNTPCClusters() const{return fCurrentPositiveESDTrack->GetTPCNcls();}
+       Double_t GetNegativeNTPCClusters() const{return fCurrentNegativeESDTrack->GetTPCNcls();}
+               
+       /*
+         * Sets the MaxVertexZ value.
+         */
+       void SetMaxVertexZ(Double_t maxVertexZ){fMaxVertexZ=maxVertexZ;}
+
+       /*
+         * Sets the MaxRCut value.
+         */
+       void SetMaxRCut(Double_t maxR){fMaxR=maxR;}
+       /*      
+         * Sets the MinRCut value.
+         */
+       void SetMinRCut(Double_t minR){fMinR=minR;}
+
+       /*
+         * Sets the EtaCut value.
+         */
+       void SetEtaCut(Double_t etaCut){fEtaCut=etaCut;}
+
+       /*
+         * Sets the EtaCutMin value.
+         */
+       void SetEtaCutMin(Double_t etaCutMin){fEtaCutMin=etaCutMin;}
+
+
+       /*
+         * Sets the Rapidity Meson Cut value.
+         */
+       void SetRapidityMesonCut(Double_t RapidityMesonCut){fRapidityMesonCut=RapidityMesonCut;}
+               
+       /*
+         * Sets the PtCut value.
+         */
+       void SetPtCut(Double_t ptCut){fPtCut=ptCut;}
+               
+       /*
+         * Sets the PtCut value.
+         */
+       void SetSinglePtCut(Double_t singleptCut){fSinglePtCut=singleptCut;}
+               
+               
+       /*
+         * Sets the MaxZCut value.
+         */
+       void SetMaxZCut(Double_t maxZ){fMaxZ=maxZ;}
+               
+       /*
+         * Sets the MinClsTPC value.
+         */
+       void SetMinClsTPCCut(Double_t minClsTPC){fMinClsTPC=minClsTPC;}
+
+       /*
+         * Sets the MinClsTPC value.
+         */
+       void SetMinClsTPCCutToF(Double_t minClsTPCToF){fMinClsTPCToF=minClsTPCToF;}
+               
 
-  /*
-   * Gets the P of the negative track.
-   */
-  Double_t GetNegativeTrackP() const{return fNegativeTrackLorentzVector->P();}
-       
-  /*
-   * Gets the P of the positive track.
-   */
-  Double_t GetPositiveTrackP() const{return fPositiveTrackLorentzVector->P();}
-
-  /*
-   * Gets the dE/dx in the TPC of the negative track.
-   */
-  Double_t GetNegativeTrackTPCdEdx() const{return fCurrentNegativeESDTrack->GetTPCsignal();}
-       
-  /*
-   * Gets the dE/dx in the TPC of the positive track.
-   */
-  Double_t GetPositiveTrackTPCdEdx() const{return fCurrentPositiveESDTrack->GetTPCsignal();}
-
-  /*
-   * Gets the Number of the TPC clusters of the negative track.
-   */
-  Int_t GetNegativeTracknTPCClusters() const{return fCurrentNegativeESDTrack->GetNcls(1);}
-
-  /*
-   * Gets the Number of the TPC clusters of the positive track.
-   */
-  Int_t GetPositiveTracknTPCClusters() const{return fCurrentPositiveESDTrack->GetNcls(1);}
-
-  /*
-   * Get the TOFsignal for negative/positive track. RRnewTOF
-   */
-  Double_t GetNegativeTrackTOFsignal() const{return fCurrentNegativeESDTrack->GetTOFsignal();}
-  Double_t GetPositiveTrackTOFsignal() const{return fCurrentPositiveESDTrack->GetTOFsignal();} 
-
-  /*
-   * Gets the Number of the TPC findable clusters of the negative track.
-   */
-  Int_t GetNegativeTracknTPCFClusters() const{return fCurrentNegativeESDTrack->GetTPCNclsF();}
-
-  /*
-   * Gets the Number of the TPC findable clusters of the positive track.
-   */
-  Int_t GetPositiveTracknTPCFClusters() const{return fCurrentPositiveESDTrack->GetTPCNclsF();}
-
-  /*
-   * Gets the Number of the ITS clusters of the negative track.
-   */
-  Int_t GetNegativeTracknITSClusters() const{return fCurrentNegativeESDTrack->GetNcls(0);}
-
-  /*
-   * Gets the Number of the ITS clusters of the positive track.
-   */
-  Int_t GetPositiveTracknITSClusters() const{return fCurrentPositiveESDTrack->GetNcls(0);}
-
-  /*
-   * Gets the chi2 of the TPC  negative track.
-   */
-  Double_t GetNegativeTrackTPCchi2() const{return fCurrentNegativeESDTrack->GetTPCchi2();}
-
-  /*
-   * Gets the chi2 of the TPC  the positive track.
-   */
-  Double_t GetPositiveTrackTPCchi2() const{return fCurrentPositiveESDTrack->GetTPCchi2();}
-       
-  /*
-   * Update data which need to be updated every event.
-   */
-  void UpdateEventByEventData();
-
-  /*
-   * Gets the MaxRCut value.
-   */
-  Double_t GetMaxVertexZ() const{return fMaxVertexZ;}
-       
-  /*
-   * Gets the MaxRCut value.
-   */
-  Double_t GetMaxRCut() const{return fMaxR;}
-
-   /*
-    * Gets the MinRCut value.
-    */
-   Double_t GetMinRCut() const{return fMinR;}
-       
-  /*
-   * Gets the Eta cut value.
-   */
-  Double_t GetEtaCut() const{return fEtaCut;}
-
-  /*
-   * Gets the Eta cut value.
-   */
-  Double_t GetEtaCutMin() const{return fEtaCutMin;}
-
-  /*
-   * Gets the Rapidity Meson cut value.
-   */
-  Double_t GetRapidityMesonCut() const{return fRapidityMesonCut;}
-       
-  /*
-   * Gets the Pt cut value.
-   */
-  Double_t GetPtCut() const{return fPtCut;}
-  Double_t GetSinglePtCut() const{return fSinglePtCut;}        
-       
-  /*
-   * Gets the MaxZCut value.
-   */
-  Double_t GetMaxZCut() const{return fMaxZ;}
-       
-       
-  /*
-   * Gets the MinClsTPC value.
-   */
-  Double_t GetMinClsTPCCut() const{return fMinClsTPC;}
-       
-  /*
-   * Gets the MinClsTPC value.
-   */
-  Double_t GetMinClsTPCCutToF() const{return fMinClsTPCToF;}
-       
+       /*
+         * Sets the LineCut values.
+         */
+       void SetLineCutZRSlope(Double_t LineCutZRSlope){fLineCutZRSlope=LineCutZRSlope;}
+       void SetLineCutZValue(Double_t LineCutZValue){fLineCutZValue=LineCutZValue;}
+               
+       void SetLineCutZRSlopeMin(Double_t LineCutZRSlopeMin){fLineCutZRSlopeMin=LineCutZRSlopeMin;}
+       void SetLineCutZValueMin(Double_t LineCutZValueMin){fLineCutZValueMin=LineCutZValueMin;}
+                       
+       /*
+         * Sets the Chi2Cut value for conversions.
+         */
+       void SetChi2CutConversion(Double_t chi2){fChi2CutConversion=chi2;}
+               
+       /*
+         * Sets the Chi2Cut for the mesons.
+         */
+       void SetChi2CutMeson(Double_t chi2){fChi2CutMeson=chi2;}
+               
+       /*
+         * Sets the AlphaCut for the mesons.
+         */
+       void SetAlphaCutMeson(Double_t alpha){fAlphaCutMeson=alpha;}
+               
 
+       /*
+         * Sets the AlphaCut for the mesons.
+         */
+       void SetAlphaMinCutMeson(Double_t alpha){fAlphaMinCutMeson=alpha;}
 
-  /*
-   * Gets the line cut values.
-   */
-  Double_t GetLineCutZRSlope() const{return fLineCutZRSlope;}
-  Double_t GetLineCutZRSlopeMin() const{return fLineCutZRSlopeMin;}
-  Double_t GetLineCutZValue() const{return fLineCutZValue;}
-  Double_t GetLineCutZValueMin() const{return fLineCutZValueMin;}      
-  /*
-   * Gets the Chi2 cut value for the conversions.
-   */
-  Double_t GetChi2CutConversion() const{return fChi2CutConversion;}
-       
-  /*
-   * Gets the Chi2 cut value for the mesons.
-   */
-  Double_t GetChi2CutMeson() const{return fChi2CutMeson;}
-       
-  /*
-   * Gets the alpha cut value for the mesons.
-   */
-  Double_t GetAlphaCutMeson() const{return fAlphaCutMeson;}
-
-  /*
-   * Gets the Minimum alpha cut value for the mesons.
-   */
-  Double_t GetAlphaMinCutMeson() const{return fAlphaMinCutMeson;}
-
-  Double_t GetPositiveTrackLength() const{return fCurrentPositiveESDTrack->GetIntegratedLength();}
-  Double_t GetNegativeTrackLength() const{return fCurrentNegativeESDTrack->GetIntegratedLength();}
-       
-  Double_t GetPositiveNTPCClusters() const{return fCurrentPositiveESDTrack->GetTPCNcls();}
-  Double_t GetNegativeNTPCClusters() const{return fCurrentNegativeESDTrack->GetTPCNcls();}
-       
-  /*
-   * Sets the MaxVertexZ value.
-   */
-  void SetMaxVertexZ(Double_t maxVertexZ){fMaxVertexZ=maxVertexZ;}
-
-  /*
-   * Sets the MaxRCut value.
-   */
-  void SetMaxRCut(Double_t maxR){fMaxR=maxR;}
-  /*   
-   * Sets the MinRCut value.
-   */
-  void SetMinRCut(Double_t minR){fMinR=minR;}
-
-  /*
-   * Sets the EtaCut value.
-   */
-  void SetEtaCut(Double_t etaCut){fEtaCut=etaCut;}
-
-  /*
-   * Sets the EtaCutMin value.
-   */
-  void SetEtaCutMin(Double_t etaCutMin){fEtaCutMin=etaCutMin;}
-
-
-  /*
-   * Sets the Rapidity Meson Cut value.
-   */
-  void SetRapidityMesonCut(Double_t RapidityMesonCut){fRapidityMesonCut=RapidityMesonCut;}
-       
-  /*
-   * Sets the PtCut value.
-   */
-  void SetPtCut(Double_t ptCut){fPtCut=ptCut;}
-       
-  /*
-   * Sets the PtCut value.
-   */
-  void SetSinglePtCut(Double_t singleptCut){fSinglePtCut=singleptCut;}
-       
-    
-  /*
-   * Sets the MaxZCut value.
-   */
-  void SetMaxZCut(Double_t maxZ){fMaxZ=maxZ;}
-       
-  /*
-   * Sets the MinClsTPC value.
-   */
-  void SetMinClsTPCCut(Double_t minClsTPC){fMinClsTPC=minClsTPC;}
-
-  /*
-   * Sets the MinClsTPC value.
-   */
-  void SetMinClsTPCCutToF(Double_t minClsTPCToF){fMinClsTPCToF=minClsTPCToF;}
-       
 
-  /*
-   * Sets the LineCut values.
-   */
-  void SetLineCutZRSlope(Double_t LineCutZRSlope){fLineCutZRSlope=LineCutZRSlope;}
-  void SetLineCutZValue(Double_t LineCutZValue){fLineCutZValue=LineCutZValue;}
-       
-  void SetLineCutZRSlopeMin(Double_t LineCutZRSlopeMin){fLineCutZRSlopeMin=LineCutZRSlopeMin;}
-  void SetLineCutZValueMin(Double_t LineCutZValueMin){fLineCutZValueMin=LineCutZValueMin;}
+       /*
+         * Sets the XVertexCut value.
+         */
+       void SetXVertexCut(Double_t xVtx){fCurrentXValue=xVtx;}
                
-  /*
-   * Sets the Chi2Cut value for conversions.
-   */
-  void SetChi2CutConversion(Double_t chi2){fChi2CutConversion=chi2;}
-       
-  /*
-   * Sets the Chi2Cut for the mesons.
-   */
-  void SetChi2CutMeson(Double_t chi2){fChi2CutMeson=chi2;}
-       
-  /*
-   * Sets the AlphaCut for the mesons.
-   */
-  void SetAlphaCutMeson(Double_t alpha){fAlphaCutMeson=alpha;}
+       /*
+         * Sets the YVertexCut value.
+         */
+       void SetYVertexCut(Double_t yVtx){fCurrentYValue=yVtx;}
+               
+       /*
+         * Sets the ZVertexCut value.
+         */
+       void SetZVertexCut(Double_t zVtx){fCurrentZValue=zVtx;}
+               
+       /*
+         * Sets the PIDProbabilityCut value for track particles.
+         */
+       void SetPIDProbability(Double_t pidProb){fPIDProbabilityCutPositiveParticle=pidProb; fPIDProbabilityCutNegativeParticle=pidProb;}
+               
+       /*
+         * Sets the PIDProbability cut value for the negative track.
+         */
+       void SetPIDProbabilityNegativeParticle(Double_t pidProb){fPIDProbabilityCutNegativeParticle=pidProb;}
+               
+       /*
+         * Sets the PIDProbability cut value for the positive track.
+         */
+       void SetPIDProbabilityPositiveParticle(Double_t pidProb){fPIDProbabilityCutPositiveParticle=pidProb;}
+
+       /*
+         * Sets the PIDnSigmaAboveElectron cut value for the tracks.
+         */
+       void SetPIDnSigmaAboveElectronLine(Double_t nSigmaAbove){fPIDnSigmaAboveElectronLine=nSigmaAbove;}
+       void SetTofPIDnSigmaAboveElectronLine(Double_t nTofSigmaAbove){fTofPIDnSigmaAboveElectronLine=nTofSigmaAbove;} // RRnewTOF
+               
+       /*
+         * Sets the PIDnSigmaBelowElectron cut value for the tracks.
+         */
+       void SetPIDnSigmaBelowElectronLine(Double_t nSigmaBelow){fPIDnSigmaBelowElectronLine=nSigmaBelow;}
+       void SetTofPIDnSigmaBelowElectronLine(Double_t nTofSigmaBelow){fTofPIDnSigmaBelowElectronLine=nTofSigmaBelow;} // RRnewTOF
+               
+       /*
+         * Sets the PIDnSigmaAbovePion cut value for the tracks.
+         */
+       void SetPIDnSigmaAbovePionLine(Double_t nSigmaAbovePion){fPIDnSigmaAbovePionLine=nSigmaAbovePion;}
+
+       /*
+         * Sets the PIDnSigmaAbovePion cut value for the tracks.
+         */
+       void SetPIDnSigmaAbovePionLineHighPt(Double_t nSigmaAbovePionHighPt){fPIDnSigmaAbovePionLineHighPt=nSigmaAbovePionHighPt;}
+
+       /*
+         * Sets the PIDMinPnSigmaAbovePion cut value for the tracks.
+         */
+       void SetPIDMinPnSigmaAbovePionLine(Double_t MinPnSigmaAbovePion){fPIDMinPnSigmaAbovePionLine=MinPnSigmaAbovePion;}
+
+       /*
+         * Sets the PIDMinPnSigmaAbovePion cut value for the tracks.
+         */
+       void SetPIDMaxPnSigmaAbovePionLine(Double_t MaxPnSigmaAbovePion){fPIDMaxPnSigmaAbovePionLine=MaxPnSigmaAbovePion;}
+
+       /*
+         * Sets the SigmaMassCut value.
+         */
+       void SetSigmaMass(Double_t sigmaMass){fNSigmaMass=sigmaMass;}
+               
+       /*
+         * Sets the flag to enable/disable the usage of MC information. 
+         */
+       void SetDoMCTruth(Bool_t doMC){fDoMC = doMC;}
+
+       /*
+         * Sets the flag to enable/disable the usage of MC information. 
+         */
+       Bool_t GetDoMCTruth() const {return fDoMC;}
+               
+       /*
+         * Sets the flag to enable/disable the cut dedx N sigma 
+         */
+
+       void SetDodEdxSigmaCut( Bool_t dodEdxSigmaCut){fDodEdxSigmaCut=dodEdxSigmaCut;}
+       void SetDoTOFsigmaCut( Bool_t doTOFsigmaCut){fDoTOFsigmaCut=doTOFsigmaCut;} //RRnewTOF
+       void SetDoPhotonAsymmetryCut( Bool_t doPhotonAsymmetryCut){fDoPhotonAsymmetryCut=doPhotonAsymmetryCut;}
+       void SetUseESDQtCut(Int_t doESDQtCut){fdoESDQtCut=doESDQtCut;}
+
+       void SetMinPPhotonAsymmetryCut(Double_t minPPhotonAsymmetryCut){fMinPPhotonAsymmetryCut=minPPhotonAsymmetryCut;}
+       void SetMinPhotonAsymmetry(Double_t minPhotonAsymmetry){fMinPhotonAsymmetry=minPhotonAsymmetry;}
+       /*
+         * Sets the flag to enable/disable the cut dedx N sigma for Kaon Rejection at low p 
+         */
+       void SetDoKaonRejectionLowP( Bool_t doKaonRejectionLowP){fDoKaonRejectionLowP=doKaonRejectionLowP;}
+       /*
+         * Sets the flag to enable/disable the cut dedx N sigma for Proton Rejection at low p 
+         */
+       void SetDoProtonRejectionLowP( Bool_t doProtonRejectionLowP){fDoProtonRejectionLowP=doProtonRejectionLowP;}
+
+       /*
+         * Sets the flag to enable/disable the cut dedx N sigma for Pion Rejection at low p 
+         */
+       void SetDoPionRejectionLowP( Bool_t doPionRejectionLowP){fDoPionRejectionLowP=doPionRejectionLowP;}
+
+       /*
+         * Sets the PIDMinPnSigmaAroundKaon cut value for the tracks.
+         */
+       void SetPIDnSigmaAtLowPAroundKaonLine(Double_t nSigmaAtLowPAroundKaon){fPIDnSigmaAtLowPAroundKaonLine =nSigmaAtLowPAroundKaon;}
+
+       /*
+         * Sets the PIDMinPnSigmaAroundProton cut value for the tracks.
+         */
+       void SetPIDnSigmaAtLowPAroundProtonLine(Double_t nSigmaAtLowPAroundProton){fPIDnSigmaAtLowPAroundProtonLine =nSigmaAtLowPAroundProton;}
+
+       /*
+         * Sets the PIDMinPnSigmaAroundPion cut value for the tracks.
+         */
+       void SetPIDnSigmaAtLowPAroundPionLine(Double_t nSigmaAtLowPAroundPion){fPIDnSigmaAtLowPAroundPionLine =nSigmaAtLowPAroundPion;}
+
+       /*
+         * Sets the PIDMinPnSigmaAbovePion cut value for the tracks.
+         */
+       void SetPIDMinPKaonRejectionLowP(Double_t PIDMinPKaonRejectionLowP ){fPIDMinPKaonRejectionLowP=PIDMinPKaonRejectionLowP;}
+
+       /*
+         * Sets the PIDMinPnSigmaAbovePion cut value for the tracks.
+         */
+       void SetPIDMinPProtonRejectionLowP(Double_t PIDMinPProtonRejectionLowP ){fPIDMinPProtonRejectionLowP=PIDMinPProtonRejectionLowP;}
+       /*
+         * Sets the PIDMinPnSigmaAbovePion cut value for the tracks.
+         */
+       void SetPIDMinPPionRejectionLowP(Double_t PIDMinPPionRejectionLowP ){fPIDMinPPionRejectionLowP=PIDMinPPionRejectionLowP;}
+
+       /*
+         *Set if we want to use Gamma Selection based on Qt from Armenteros
+         */
+       void SetDoQtGammaSelection(Bool_t doQtGammaSelection){fDoQtGammaSelection=doQtGammaSelection;}
+       void SetDoHighPtQtGammaSelection(Bool_t doHighPtQtGammaSelection){fDoHighPtQtGammaSelection=doHighPtQtGammaSelection;} // RRnew
+       /*
+         * Sets the MaxQtCut value.
+         */
+       void SetQtMax(Double_t qtMax){fQtMax=qtMax;}
+       void SetHighPtQtMax(Double_t qtMaxHighPt){fHighPtQtMax=qtMaxHighPt;} // RRnew
+       void SetPtBorderForQt(Double_t ptBorderForQt){fPtBorderForQt=ptBorderForQt;} // RRnew
+
+       /*
+         * Updates the V0 information of the current V0.
+         */
+       Bool_t UpdateV0Information();
+               
+       /*
+         * Resets the V0 index.
+         */
+       void ResetV0IndexNumber(){fCurrentV0IndexNumber=0;}
        
 
-  /*
-   * Sets the AlphaCut for the mesons.
-   */
-  void SetAlphaMinCutMeson(Double_t alpha){fAlphaMinCutMeson=alpha;}
-
+       /*
+         * Returns number of good v0s in the event
+         */
+       Int_t GetNGoodV0s() const {return fNumberOfGoodV0s;}
 
-  /*
-   * Sets the XVertexCut value.
-   */
-  void SetXVertexCut(Double_t xVtx){fCurrentXValue=xVtx;}
-       
-  /*
-   * Sets the YVertexCut value.
-   */
-  void SetYVertexCut(Double_t yVtx){fCurrentYValue=yVtx;}
-       
-  /*
-   * Sets the ZVertexCut value.
-   */
-  void SetZVertexCut(Double_t zVtx){fCurrentZValue=zVtx;}
-       
-  /*
-   * Sets the PIDProbabilityCut value for track particles.
-   */
-  void SetPIDProbability(Double_t pidProb){fPIDProbabilityCutPositiveParticle=pidProb; fPIDProbabilityCutNegativeParticle=pidProb;}
-       
-  /*
-   * Sets the PIDProbability cut value for the negative track.
-   */
-  void SetPIDProbabilityNegativeParticle(Double_t pidProb){fPIDProbabilityCutNegativeParticle=pidProb;}
-       
-  /*
-   * Sets the PIDProbability cut value for the positive track.
-   */
-  void SetPIDProbabilityPositiveParticle(Double_t pidProb){fPIDProbabilityCutPositiveParticle=pidProb;}
-
-  /*
-   * Sets the PIDnSigmaAboveElectron cut value for the tracks.
-   */
-  void SetPIDnSigmaAboveElectronLine(Double_t nSigmaAbove){fPIDnSigmaAboveElectronLine=nSigmaAbove;}
-  void SetTofPIDnSigmaAboveElectronLine(Double_t nTofSigmaAbove){fTofPIDnSigmaAboveElectronLine=nTofSigmaAbove;} // RRnewTOF
-       
-  /*
-   * Sets the PIDnSigmaBelowElectron cut value for the tracks.
-   */
-  void SetPIDnSigmaBelowElectronLine(Double_t nSigmaBelow){fPIDnSigmaBelowElectronLine=nSigmaBelow;}
-  void SetTofPIDnSigmaBelowElectronLine(Double_t nTofSigmaBelow){fTofPIDnSigmaBelowElectronLine=nTofSigmaBelow;} // RRnewTOF
-       
-  /*
-   * Sets the PIDnSigmaAbovePion cut value for the tracks.
-   */
-  void SetPIDnSigmaAbovePionLine(Double_t nSigmaAbovePion){fPIDnSigmaAbovePionLine=nSigmaAbovePion;}
-
-  /*
-   * Sets the PIDnSigmaAbovePion cut value for the tracks.
-   */
-  void SetPIDnSigmaAbovePionLineHighPt(Double_t nSigmaAbovePionHighPt){fPIDnSigmaAbovePionLineHighPt=nSigmaAbovePionHighPt;}
-
-  /*
-   * Sets the PIDMinPnSigmaAbovePion cut value for the tracks.
-   */
-  void SetPIDMinPnSigmaAbovePionLine(Double_t MinPnSigmaAbovePion){fPIDMinPnSigmaAbovePionLine=MinPnSigmaAbovePion;}
-
- /*
-   * Sets the PIDMinPnSigmaAbovePion cut value for the tracks.
-   */
-  void SetPIDMaxPnSigmaAbovePionLine(Double_t MaxPnSigmaAbovePion){fPIDMaxPnSigmaAbovePionLine=MaxPnSigmaAbovePion;}
-
-  /*
-   * Sets the SigmaMassCut value.
-   */
-  void SetSigmaMass(Double_t sigmaMass){fNSigmaMass=sigmaMass;}
-       
-  /*
-   * Sets the flag to enable/disable the usage of MC information. 
-   */
-  void SetDoMCTruth(Bool_t doMC){fDoMC = doMC;}
-
-  /*
-   * Sets the flag to enable/disable the usage of MC information. 
-   */
-  Bool_t GetDoMCTruth() const {return fDoMC;}
-       
-  /*
-   * Sets the flag to enable/disable the cut dedx N sigma 
-   */
-
-  void SetDodEdxSigmaCut( Bool_t dodEdxSigmaCut){fDodEdxSigmaCut=dodEdxSigmaCut;}
-  void SetDoTOFsigmaCut( Bool_t doTOFsigmaCut){fDoTOFsigmaCut=doTOFsigmaCut;} //RRnewTOF
-  void SetDoPhotonAsymmetryCut( Bool_t doPhotonAsymmetryCut){fDoPhotonAsymmetryCut=doPhotonAsymmetryCut;}
-
-  void SetMinPPhotonAsymmetryCut(Double_t minPPhotonAsymmetryCut){fMinPPhotonAsymmetryCut=minPPhotonAsymmetryCut;}
-  void SetMinPhotonAsymmetry(Double_t minPhotonAsymmetry){fMinPhotonAsymmetry=minPhotonAsymmetry;}
-  /*
-   * Sets the flag to enable/disable the cut dedx N sigma for Kaon Rejection at low p 
-   */
-  void SetDoKaonRejectionLowP( Bool_t doKaonRejectionLowP){fDoKaonRejectionLowP=doKaonRejectionLowP;}
-  /*
-   * Sets the flag to enable/disable the cut dedx N sigma for Proton Rejection at low p 
-   */
-  void SetDoProtonRejectionLowP( Bool_t doProtonRejectionLowP){fDoProtonRejectionLowP=doProtonRejectionLowP;}
-
-  /*
-   * Sets the flag to enable/disable the cut dedx N sigma for Pion Rejection at low p 
-   */
-  void SetDoPionRejectionLowP( Bool_t doPionRejectionLowP){fDoPionRejectionLowP=doPionRejectionLowP;}
-
-  /*
-   * Sets the PIDMinPnSigmaAroundKaon cut value for the tracks.
-   */
-  void SetPIDnSigmaAtLowPAroundKaonLine(Double_t nSigmaAtLowPAroundKaon){fPIDnSigmaAtLowPAroundKaonLine =nSigmaAtLowPAroundKaon;}
-
-  /*
-   * Sets the PIDMinPnSigmaAroundProton cut value for the tracks.
-   */
-  void SetPIDnSigmaAtLowPAroundProtonLine(Double_t nSigmaAtLowPAroundProton){fPIDnSigmaAtLowPAroundProtonLine =nSigmaAtLowPAroundProton;}
-
-  /*
-   * Sets the PIDMinPnSigmaAroundPion cut value for the tracks.
-   */
-  void SetPIDnSigmaAtLowPAroundPionLine(Double_t nSigmaAtLowPAroundPion){fPIDnSigmaAtLowPAroundPionLine =nSigmaAtLowPAroundPion;}
-
-  /*
-   * Sets the PIDMinPnSigmaAbovePion cut value for the tracks.
-   */
-  void SetPIDMinPKaonRejectionLowP(Double_t PIDMinPKaonRejectionLowP ){fPIDMinPKaonRejectionLowP=PIDMinPKaonRejectionLowP;}
-
-  /*
-   * Sets the PIDMinPnSigmaAbovePion cut value for the tracks.
-   */
-  void SetPIDMinPProtonRejectionLowP(Double_t PIDMinPProtonRejectionLowP ){fPIDMinPProtonRejectionLowP=PIDMinPProtonRejectionLowP;}
-  /*
-   * Sets the PIDMinPnSigmaAbovePion cut value for the tracks.
-   */
-  void SetPIDMinPPionRejectionLowP(Double_t PIDMinPPionRejectionLowP ){fPIDMinPPionRejectionLowP=PIDMinPPionRejectionLowP;}
-
-  /*
-   *Set if we want to use Gamma Selection based on Qt from Armenteros
-   */
-  void SetDoQtGammaSelection(Bool_t doQtGammaSelection){fDoQtGammaSelection=doQtGammaSelection;}
-  void SetDoHighPtQtGammaSelection(Bool_t doHighPtQtGammaSelection){fDoHighPtQtGammaSelection=doHighPtQtGammaSelection;} // RRnew
-  /*
-   * Sets the MaxQtCut value.
-   */
-  void SetQtMax(Double_t qtMax){fQtMax=qtMax;}
-  void SetHighPtQtMax(Double_t qtMaxHighPt){fHighPtQtMax=qtMaxHighPt;} // RRnew
-  void SetPtBorderForQt(Double_t ptBorderForQt){fPtBorderForQt=ptBorderForQt;} // RRnew
-
-  /*
-   * Updates the V0 information of the current V0.
-   */
-  Bool_t UpdateV0Information();
-       
-  /*
-   * Resets the V0 index.
-   */
-  void ResetV0IndexNumber(){fCurrentV0IndexNumber=0;}
-  
+       /*
+         * Sets the histograms.
+         */
+       void SetHistograms(AliGammaConversionHistograms * const histograms){fHistograms=histograms;}
+               
+       /*
+         * Check for primary vertex.
+         */
+       Bool_t CheckForPrimaryVertex();
+               
+       /*
+         * Check for primary vertex Z.
+         */
+       Bool_t CheckForPrimaryVertexZ();
+
+       /*
+         * Gets a vector of good v0s.
+         */
+       TClonesArray* GetCurrentEventGoodV0s() const{return fCurrentEventGoodV0s;}
+               
+       /*
+         * Gets the vector of previous events v0s (for bacground analysis)
+         */
+       AliGammaConversionKFVector* GetBGGoodV0s(Int_t event) const;
+       //  vector<AliKFParticle> GetPreviousEventGoodV0s() const{return fPreviousEventGoodV0s;}
 
-  /*
-   * Returns number of good v0s in the event
-   */
-  Int_t GetNGoodV0s() const {return fNumberOfGoodV0s;}
+       void SetUseOwnXYZCalculation(Bool_t flag){fUseOwnXYZCalculation=flag;}
 
-  /*
-   * Sets the histograms.
-   */
-  void SetHistograms(AliGammaConversionHistograms * const histograms){fHistograms=histograms;}
-       
-  /*
-   * Check for primary vertex.
-   */
-  Bool_t CheckForPrimaryVertex();
-       
-  /*
-   * Check for primary vertex Z.
-   */
-  Bool_t CheckForPrimaryVertexZ();
-
-  /*
-   * Gets a vector of good v0s.
-   */
-  TClonesArray* GetCurrentEventGoodV0s() const{return fCurrentEventGoodV0s;}
-       
-  /*
-   * Gets the vector of previous events v0s (for bacground analysis)
-   */
-  AliGammaConversionKFVector* GetBGGoodV0s(Int_t event) const;
-  //  vector<AliKFParticle> GetPreviousEventGoodV0s() const{return fPreviousEventGoodV0s;}
+       void SetUseConstructGamma(Bool_t flag){fUseConstructGamma=flag;}
 
-  void SetUseOwnXYZCalculation(Bool_t flag){fUseOwnXYZCalculation=flag;}
+       /*
+         * Excludes BG Events in HI Simulations e.g. in LHC10b_bis
+         */
+       void SetExcludeBackgroundEventForGammaCorrection(Bool_t flag){fExcludeBackgroundEventForGammaCorrection=flag;}
+       /*
+         * Excludes BG Events in HI Simulations e.g. in LHC10b_bis
+         */
+       Bool_t GetExcludeBackgroundEventForGammaCorrection(){return fExcludeBackgroundEventForGammaCorrection;}
 
-  void SetUseConstructGamma(Bool_t flag){fUseConstructGamma=flag;}
 
-  //   Bool_t GetHelixCenter(const AliExternalTrackParam *track, Double_t b,Int_t charge, Double_t center[2]);
-  Bool_t GetHelixCenter(AliESDtrack* track, Double_t b,Int_t charge, Double_t center[2]); 
+//     Bool_t GetHelixCenter(AliESDtrack* track, Double_t b,Int_t charge, Double_t center[2]); 
 
-  Bool_t GetConvPosXY(AliESDtrack* ptrack,AliESDtrack* ntrack, Double_t b, Double_t convpos[2]);
+       Bool_t GetHelixCenter(const AliExternalTrackParam *track, Double_t b,Int_t charge, Double_t center[2]);
+       Bool_t GetConvPosXY(AliESDtrack* ptrack,AliESDtrack* ntrack, Double_t b, Double_t convpos[2]);
+       Double_t GetConvPosZ(AliESDtrack* ptrack,AliESDtrack* ntrack, Double_t b);
+       Bool_t GetConversionPoint(const AliExternalTrackParam *pparam,const AliExternalTrackParam *nparam,Double_t convpos[3]);
        
-  Double_t GetConvPosZ(AliESDtrack* ptrack,AliESDtrack* ntrack, Double_t b);
+       Bool_t GetArmenterosQtAlpha(const AliKFParticle * posKFparticle, const AliKFParticle * negKFparticle, const AliKFParticle * gamKFparticle,Double_t armenterosQtAlpha[2]);
+       Bool_t GetArmenterosQtAlpha(const TParticle * posKFparticle, const TParticle * negKFparticle, const AliKFParticle * gamKFparticle,Double_t armenterosQtAlpha[2]);
+       Bool_t GetArmenterosQtAlpha(const TParticle * posKFparticle, const TParticle * negKFparticle, const TParticle * gamKFparticle,Double_t armenterosQtAlpha[2]);
+       Bool_t GetArmenterosQtAlpha(const AliESDv0 * v0, Double_t armenterosQtAlpha[2]);
+       Int_t GetUseESDQtCut(){ return fdoESDQtCut;}
+        Bool_t GetArmenterosQtAlpha(const AliKFParticle * posKFparticle, const AliKFParticle * negKFparticle, Double_t armenterosQtAlpha[2], Int_t kfProductionMethod);
+       void SetDoCF(Bool_t flag){fDoCF = flag;}
 
-       void GetConversionPoint(const AliExternalTrackParam *pparam,const AliExternalTrackParam *nparam,Double_t convpos[3]);
+       Bool_t CheckV0FinderStatus(AliESDv0 *v0);
 
-       Bool_t GetArmenterosQtAlfa(const AliKFParticle * posKFparticle, const AliKFParticle * negKFparticle, const AliKFParticle * gamKFparticle,Double_t armenterosQtAlfa[2]);
-       Bool_t GetArmenterosQtAlfa(const TParticle * posKFparticle, const TParticle * negKFparticle, const AliKFParticle * gamKFparticle,Double_t armenterosQtAlfa[2]);
-       Bool_t GetArmenterosQtAlfa(const TParticle * posKFparticle, const TParticle * negKFparticle, const TParticle * gamKFparticle,Double_t armenterosQtAlfa[2]);
-  
-  void SetDoCF(Bool_t flag){fDoCF = flag;}
 
-  Bool_t CheckV0FinderStatus(Int_t index);
+       void SetOnFlyFlag(Bool_t flag){fUseOnFlyV0Finder = flag;}
 
-  void SetOnFlyFlag(Bool_t flag){fUseOnFlyV0Finder = flag;}
-  
-  Int_t GetNBGEvents(){return fBGEventHandler->GetNBGEvents();}
+       void SetPsiPairCut(Double_t flag){fPsiPairCut = flag;}
+       Double_t GetPsiPairCut(){return fPsiPairCut;}
+       
+       void SetCosinePointCut(Double_t flag){fCosinePointCut = TMath::Cos(flag);}
+       Double_t GetCosinePointCut(){return fCosinePointCut;}
+       
+       Int_t GetNBGEvents(){return fBGEventHandler->GetNBGEvents();}
 
-  void SetCalculateBackground(Bool_t flag){fCalculateBackground=flag;}
+       void SetCalculateBackground(Bool_t flag){fCalculateBackground=flag;}
 
-  AliGammaConversionBGHandler* GetBGHandler() const {return fBGEventHandler;}
+       AliGammaConversionBGHandler* GetBGHandler() const {return fBGEventHandler;}
 
-  Double_t GetVertexZ(){return fESDEvent->GetPrimaryVertex()->GetZ();}
+       Double_t GetVertexZ(){return fESDEvent->GetPrimaryVertex()->GetZ();}
 
-  Int_t GetMultiplicity(){return CountESDTracks();}
+       Int_t GetMultiplicity(){return CountESDTracks();}
 
-  void SetESDtrackCuts(AliESDtrackCuts * const trackCuts){fEsdTrackCuts = trackCuts;}
+       void SetESDtrackCuts(AliESDtrackCuts * const trackCuts){fEsdTrackCuts = trackCuts;}
 
-  void SetNEventsForBG(Int_t nev){fNEventsForBGCalculation = nev;}
+       void SetNEventsForBG(Int_t nev){fNEventsForBGCalculation = nev;}
 
-  Int_t CountESDTracks();
+       Int_t CountESDTracks();
 
-  Int_t GetCurrentV0IndexNumber() const {return fCurrentV0IndexNumber;}
+       Int_t GetCurrentV0IndexNumber() const {return fCurrentV0IndexNumber;}
 
-  Bool_t CheckIfPi0IsMother(Int_t label);
-  Bool_t CheckIfEtaIsMother(Int_t label);
+       Bool_t CheckIfPi0IsMother(Int_t label);
+       Bool_t CheckIfEtaIsMother(Int_t label);
 
-  static void InitESDpid(Int_t type=0);
-  static void SetESDpid(AliESDpid * const pid) {fgESDpid=pid;}
-  static AliESDpid* GetESDpid() {return fgESDpid;}
+       static void InitESDpid(Int_t type=0);
+       static void SetESDpid(AliESDpid * const pid) {fgESDpid=pid;}
+       static AliESDpid* GetESDpid() {return fgESDpid;}
 
-  void SetUseChargedTracksMultiplicityForBG(Bool_t flag){fUseChargedTrackMultiplicityForBG = flag;}
-  void SetIsHeavyIon(Int_t isHeavyIon) {fIsHeavyIon=isHeavyIon;}
-  Int_t GetIsHeavyIon() const { return fIsHeavyIon;}
-  Int_t GetPindex(Int_t i) {return fV0Pindex.at(i);}
-  Int_t GetNindex(Int_t i) {return fV0Nindex.at(i);}
+       void SetUseChargedTracksMultiplicityForBG(Bool_t flag){fUseChargedTrackMultiplicityForBG = flag;}
+       void SetIsHeavyIon(Int_t isHeavyIon) {fIsHeavyIon=isHeavyIon;}
+       Int_t GetIsHeavyIon() const { return fIsHeavyIon;}
+       
+       Int_t GetPindex(Int_t i) {return fV0Pindex.at(i);}
+       Int_t GetNindex(Int_t i) {return fV0Nindex.at(i);}
 
-  void ResetNGoodV0s(){fNumberOfGoodV0s=0;}
-  Int_t GetFirstTPCRow(Double_t radius);
+       void ResetNGoodV0s(){fNumberOfGoodV0s=0;}
+       Int_t GetFirstTPCRow(Double_t radius);
 
-  void SetUseCorrectedTPCClsInfo(Bool_t flag){fUseCorrectedTPCClsInfo = flag;}
-  Bool_t GetUseCorrectedTPCClsInfo() const {return fUseCorrectedTPCClsInfo;}
+       void SetUseCorrectedTPCClsInfo(Bool_t flag){fUseCorrectedTPCClsInfo = flag;}
+       Bool_t GetUseCorrectedTPCClsInfo() const {return fUseCorrectedTPCClsInfo;}
 
-  void SetUseMCPSmearing(Int_t useMCPSmearing) {fUseMCPSmearing=useMCPSmearing;}
-  void SetPBremSmearing(Double_t pBremSmearing){fPBremSmearing=pBremSmearing;}
-  void SetPSigSmearing(Double_t pSigSmearing){fPSigSmearing=pSigSmearing;}
-  void SetPSigSmearingCte(Double_t pSigSmearingCte){fPSigSmearingCte=pSigSmearingCte;}
-  void SmearKFParticle(AliKFParticle * kfParticle);
+       void SetUseMCPSmearing(Int_t useMCPSmearing) {fUseMCPSmearing=useMCPSmearing;}
+       void SetPBremSmearing(Double_t pBremSmearing){fPBremSmearing=pBremSmearing;}
+       void SetPSigSmearing(Double_t pSigSmearing){fPSigSmearing=pSigSmearing;}
+       void SetPSigSmearingCte(Double_t pSigSmearingCte){fPSigSmearingCte=pSigSmearingCte;}
+       void SmearKFParticle(AliKFParticle * kfParticle);
+  
+       private:
+               AliStack * fMCStack;           // pointer to MonteCarlo particle stack 
+               //  AliMCEventHandler* fMCTruth;   // for CF    pointer to the MC object
+               AliMCEvent *fMCEvent;                   //  for CF      pointer to MC event
+               TChain * fChain;               // pointer to the TChain
+                       
+               //  AliESDInputHandler* fESDHandler;      //! pointer to esd object
+               AliESDEvent *fESDEvent;               //! pointer to esd object
+                       
+                       
+               // for CF
+               AliCFManager *fCFManager; // pointer to the cf manager
+               //  AliCFContainer *container;
+                       
+               // for dEdx cut based on nSigma to a particle line
+               //AliESDpid * fESDpid; // esd pid
+                       
+               AliGammaConversionHistograms *fHistograms; // pointer to histogram handling class
+                       
+               Int_t fCurrentV0IndexNumber;  // the current v0 index number
+               AliESDv0 * fCurrentV0;                //! pointer to the current v0
+               AliKFParticle * fCurrentNegativeKFParticle;  //! pointer to the negative KF particle
+               AliKFParticle * fCurrentPositiveKFParticle;  //! pointer to the positive KF particle
+               AliKFParticle * fCurrentMotherKFCandidate;   //! pointer to the positive KF particle
+                       
+               AliESDtrack * fCurrentNegativeESDTrack;      //! pointer to the negative ESD track
+               AliESDtrack * fCurrentPositiveESDTrack;      //! pointer to the positive ESD track
+                       
+               TLorentzVector * fNegativeTrackLorentzVector; //! pointer to the negative Track Lorentz Vector
+               TLorentzVector * fPositiveTrackLorentzVector; //! pointer to the positive Track Lorentz Vector
+               TLorentzVector * fMotherCandidateLorentzVector;   //! pointer to the mother candidate Track Lorentz Vector
+                       
+               Double_t fCurrentXValue;   // current x value
+               Double_t fCurrentYValue;   // current y value
+               Double_t fCurrentZValue;   // current z value
+                       
+               Int_t fPositiveTrackPID;   // positive track pid
+               Int_t fNegativeTrackPID;   // negative track pid
+                       
+               TParticle *fNegativeMCParticle;      //!
+               TParticle *fPositiveMCParticle;      //!
+               TParticle *fMotherMCParticle;        //!
+                       
+               Double_t fMotherCandidateKFMass;   // mass of mother candidate KF particle
+               Double_t fMotherCandidateKFWidth;  // width of mother candidate KF particle
+                       
+               Bool_t fUseKFParticle;   // flag 
+               Bool_t fUseESDTrack;     // flag 
+               Bool_t fDoMC;            // flag 
+
+               //Event Cuts
+               Double_t fMaxVertexZ; // max z vertex cut
+               //cuts
+               Double_t fMaxR; //r cut
+               Double_t fMinR; //r cut
+               Double_t fEtaCut; //eta cut
+               Double_t fEtaCutMin; //eta cut
+               Double_t fRapidityMesonCut; //rapidity for meson cut
+               Double_t fPtCut; // pt cut
+               Double_t fSinglePtCut; // pt cut for electron/positron
+               Double_t fMaxZ; //z cut
+               Double_t fMinClsTPC; // minimum clusters in the TPC
+               Double_t fMinClsTPCToF; // minimum clusters to findable clusters
+               Double_t fLineCutZRSlope; //linecut
+               Double_t fLineCutZValue; //linecut
+               Double_t fLineCutZRSlopeMin; //linecut
+               Double_t fLineCutZValueMin; //linecut
+               Double_t fChi2CutConversion; //chi2cut
+               Double_t fChi2CutMeson;  //chi2cut
+               Double_t fAlphaCutMeson;  //alphacut
+               Double_t fAlphaMinCutMeson;  //alphacut
+               Double_t fPIDProbabilityCutNegativeParticle; //pid cut
+               Double_t fPIDProbabilityCutPositiveParticle; //pid cut
+               Bool_t   fDodEdxSigmaCut; // flag to use the dEdxCut based on sigmas
+               Bool_t   fDoTOFsigmaCut; // flag to use TOF pid cut RRnewTOF
+               Double_t fPIDnSigmaAboveElectronLine; // sigma cut
+               Double_t fPIDnSigmaBelowElectronLine; // sigma cut
+               Double_t fTofPIDnSigmaAboveElectronLine; // sigma cut RRnewTOF
+               Double_t fTofPIDnSigmaBelowElectronLine; // sigma cut RRnewTOF 
+               Double_t fPIDnSigmaAbovePionLine;     // sigma cut
+               Double_t fPIDnSigmaAbovePionLineHighPt;     // sigma cut
+               Double_t fPIDMinPnSigmaAbovePionLine; // sigma cut
+               Double_t fPIDMaxPnSigmaAbovePionLine; // sigma cut
+               Double_t fDoKaonRejectionLowP;   // Kaon rejection at low p
+               Double_t fDoProtonRejectionLowP; // Proton rejection at low p
+               Double_t fDoPionRejectionLowP;   // Pion rejection at low p
+               Double_t fPIDnSigmaAtLowPAroundKaonLine; // sigma cut
+               Double_t fPIDnSigmaAtLowPAroundProtonLine; // sigma cut
+               Double_t fPIDnSigmaAtLowPAroundPionLine; // sigma cut
+               Double_t fPIDMinPKaonRejectionLowP; // Momentum limit to apply kaon rejection
+               Double_t fPIDMinPProtonRejectionLowP; // Momentum limit to apply proton rejection
+               Double_t fPIDMinPPionRejectionLowP; // Momentum limit to apply proton rejection
+               Bool_t   fDoQtGammaSelection; // Select gammas using qtMax
+               Bool_t   fDoHighPtQtGammaSelection; // RRnew Select gammas using qtMax for high pT
+               Double_t fQtMax; // Maximum Qt from Armenteros to select Gammas
+               Double_t fHighPtQtMax; // RRnew Maximum Qt for High pT from Armenteros to select Gammas
+               Double_t fPtBorderForQt; // RRnew 
+               Double_t fXVertexCut; //vertex cut
+               Double_t fYVertexCut; //vertex cut
+               Double_t fZVertexCut; // vertexcut
+               Double_t fPsiPairCut;
+               Double_t fCosinePointCut;
+               
+                       
+               Double_t fNSigmaMass; //nsigma cut
+                       
+               Bool_t fUseImprovedVertex; //flag
 
- private:
-  AliStack * fMCStack;           // pointer to MonteCarlo particle stack 
-  //  AliMCEventHandler* fMCTruth;   // for CF    pointer to the MC object
-  AliMCEvent *fMCEvent;                        //  for CF      pointer to MC event
-  TChain * fChain;               // pointer to the TChain
-       
-  //  AliESDInputHandler* fESDHandler;      //! pointer to esd object
-  AliESDEvent *fESDEvent;               //! pointer to esd object
-       
-       
-  // for CF
-  AliCFManager *fCFManager; // pointer to the cf manager
-  //  AliCFContainer *container;
-       
-  // for dEdx cut based on nSigma to a particle line
-  //AliESDpid * fESDpid; // esd pid
-       
-  AliGammaConversionHistograms *fHistograms; // pointer to histogram handling class
-       
-  Int_t fCurrentV0IndexNumber;  // the current v0 index number
-  AliESDv0 * fCurrentV0;                //! pointer to the current v0
-  AliKFParticle * fCurrentNegativeKFParticle;  //! pointer to the negative KF particle
-  AliKFParticle * fCurrentPositiveKFParticle;  //! pointer to the positive KF particle
-  AliKFParticle * fCurrentMotherKFCandidate;   //! pointer to the positive KF particle
-       
-  AliESDtrack * fCurrentNegativeESDTrack;      //! pointer to the negative ESD track
-  AliESDtrack * fCurrentPositiveESDTrack;      //! pointer to the positive ESD track
-       
-  TLorentzVector * fNegativeTrackLorentzVector; //! pointer to the negative Track Lorentz Vector
-  TLorentzVector * fPositiveTrackLorentzVector; //! pointer to the positive Track Lorentz Vector
-  TLorentzVector * fMotherCandidateLorentzVector;   //! pointer to the mother candidate Track Lorentz Vector
-       
-  Double_t fCurrentXValue;   // current x value
-  Double_t fCurrentYValue;   // current y value
-  Double_t fCurrentZValue;   // current z value
-       
-  Int_t fPositiveTrackPID;   // positive track pid
-  Int_t fNegativeTrackPID;   // negative track pid
-       
-  TParticle *fNegativeMCParticle;      //!
-  TParticle *fPositiveMCParticle;      //!
-  TParticle *fMotherMCParticle;        //!
-       
-  Double_t fMotherCandidateKFMass;   // mass of mother candidate KF particle
-  Double_t fMotherCandidateKFWidth;  // width of mother candidate KF particle
-       
-  Bool_t fUseKFParticle;   // flag 
-  Bool_t fUseESDTrack;     // flag 
-  Bool_t fDoMC;            // flag 
-
-  //Event Cuts
-  Double_t fMaxVertexZ; // max z vertex cut
-  //cuts
-  Double_t fMaxR; //r cut
-  Double_t fMinR; //r cut
-  Double_t fEtaCut; //eta cut
-  Double_t fEtaCutMin; //eta cut
-  Double_t fRapidityMesonCut; //rapidity for meson cut
-  Double_t fPtCut; // pt cut
-  Double_t fSinglePtCut; // pt cut for electron/positron
-  Double_t fMaxZ; //z cut
-  Double_t fMinClsTPC; // minimum clusters in the TPC
-  Double_t fMinClsTPCToF; // minimum clusters to findable clusters
-  Double_t fLineCutZRSlope; //linecut
-  Double_t fLineCutZValue; //linecut
-  Double_t fLineCutZRSlopeMin; //linecut
-  Double_t fLineCutZValueMin; //linecut
-  Double_t fChi2CutConversion; //chi2cut
-  Double_t fChi2CutMeson;  //chi2cut
-  Double_t fAlphaCutMeson;  //alphacut
-  Double_t fAlphaMinCutMeson;  //alphacut
-  Double_t fPIDProbabilityCutNegativeParticle; //pid cut
-  Double_t fPIDProbabilityCutPositiveParticle; //pid cut
-  Bool_t   fDodEdxSigmaCut; // flag to use the dEdxCut based on sigmas
-  Bool_t   fDoTOFsigmaCut; // flag to use TOF pid cut RRnewTOF
-  Double_t fPIDnSigmaAboveElectronLine; // sigma cut
-  Double_t fPIDnSigmaBelowElectronLine; // sigma cut
-  Double_t fTofPIDnSigmaAboveElectronLine; // sigma cut RRnewTOF
-  Double_t fTofPIDnSigmaBelowElectronLine; // sigma cut RRnewTOF 
-  Double_t fPIDnSigmaAbovePionLine;     // sigma cut
-  Double_t fPIDnSigmaAbovePionLineHighPt;     // sigma cut
-  Double_t fPIDMinPnSigmaAbovePionLine; // sigma cut
-  Double_t fPIDMaxPnSigmaAbovePionLine; // sigma cut
-  Double_t fDoKaonRejectionLowP;   // Kaon rejection at low p
-  Double_t fDoProtonRejectionLowP; // Proton rejection at low p
-  Double_t fDoPionRejectionLowP;   // Pion rejection at low p
-  Double_t fPIDnSigmaAtLowPAroundKaonLine; // sigma cut
-  Double_t fPIDnSigmaAtLowPAroundProtonLine; // sigma cut
-  Double_t fPIDnSigmaAtLowPAroundPionLine; // sigma cut
-  Double_t fPIDMinPKaonRejectionLowP; // Momentum limit to apply kaon rejection
-  Double_t fPIDMinPProtonRejectionLowP; // Momentum limit to apply proton rejection
-  Double_t fPIDMinPPionRejectionLowP; // Momentum limit to apply proton rejection
-  Bool_t   fDoQtGammaSelection; // Select gammas using qtMax
-  Bool_t   fDoHighPtQtGammaSelection; // RRnew Select gammas using qtMax for high pT
-  Double_t fQtMax; // Maximum Qt from Armenteros to select Gammas
-  Double_t fHighPtQtMax; // RRnew Maximum Qt for High pT from Armenteros to select Gammas
-  Double_t fPtBorderForQt; // RRnew 
-  Double_t fXVertexCut; //vertex cut
-  Double_t fYVertexCut; //vertex cut
-  Double_t fZVertexCut; // vertexcut
-       
-  Double_t fNSigmaMass; //nsigma cut
-       
-  Bool_t fUseImprovedVertex; //flag
+               Bool_t fUseOwnXYZCalculation; //flag that determines if we use our own calculation of xyz (markus)
 
-  Bool_t fUseOwnXYZCalculation; //flag that determines if we use our own calculation of xyz (markus)
+               Bool_t fUseConstructGamma; //flag that determines if we use ConstructGamma method from AliKF
 
-  Bool_t fUseConstructGamma; //flag that determines if we use ConstructGamma method from AliKF
+               Bool_t fDoCF; //flag
 
-  Bool_t fDoCF; //flag
+               Bool_t fUseEtaMinCut; //flag
 
-  Bool_t fUseEtaMinCut; //flag
+               Bool_t fUseOnFlyV0Finder; //flag
 
-  Bool_t fUseOnFlyV0Finder; //flag
+               Bool_t fUpdateV0AlreadyCalled; //flag
+                       
+               TClonesArray* fCurrentEventGoodV0s; //vector of good v0s
+               
+               vector<Int_t> fV0Pindex; // index of positive track belonging to a V0
+               vector<Int_t> fV0Nindex; // index of positive track belonging to a V0
+               //  vector<AliKFParticle> fPreviousEventGoodV0s; // vector of good v0s from prevous events
 
-  Bool_t fUpdateV0AlreadyCalled; //flag
-       
-  TClonesArray* fCurrentEventGoodV0s; //vector of good v0s
-  vector<Int_t> fV0Pindex; // index of positive track belonging to a V0
-  vector<Int_t> fV0Nindex; // index of positive track belonging to a V0
-  //  vector<AliKFParticle> fPreviousEventGoodV0s; // vector of good v0s from prevous events
-
-  Bool_t fCalculateBackground; //flag
-  AliGammaConversionBGHandler *fBGEventHandler; // background handler
-  Bool_t fBGEventInitialized; //flag
-       
-  AliESDtrackCuts *fEsdTrackCuts; // track cuts
-  Int_t fNumberOfESDTracks; //track counter
+               Bool_t fCalculateBackground; //flag
+               AliGammaConversionBGHandler *fBGEventHandler; // background handler
+               Bool_t fBGEventInitialized; //flag
+                       
+               AliESDtrackCuts *fEsdTrackCuts; // track cuts
+               Int_t fNumberOfESDTracks; //track counter
 
-  static AliESDpid* fgESDpid;                 // ESD pid object
+               static AliESDpid* fgESDpid;                 // ESD pid object
 
-  Int_t fNEventsForBGCalculation; // Number of events used for background calculation
-  
-  Bool_t fUseChargedTrackMultiplicityForBG; // flag
-  Int_t fNumberOfGoodV0s; // number of good V0s
-  Int_t fIsHeavyIon; // flag
-  Bool_t fUseCorrectedTPCClsInfo;
-  Int_t fUseMCPSmearing;
-  Double_t fPBremSmearing;
-  Double_t fPSigSmearing;
-  Double_t fPSigSmearingCte;
-  TRandom3 fRandom;
-  TF1 * fBrem; 
-  Bool_t   fDoPhotonAsymmetryCut; // flag to use the PhotonAsymetryCut
-  Double_t fMinPPhotonAsymmetryCut;
-  Double_t fMinPhotonAsymmetry;
-  ClassDef(AliV0Reader,22) // RRnewTOF
+               Int_t fNEventsForBGCalculation; // Number of events used for background calculation
+               
+               Bool_t fUseChargedTrackMultiplicityForBG; // flag
+               Int_t fNumberOfGoodV0s; // number of good V0s
+               Int_t fIsHeavyIon; // flag
+               Bool_t fUseCorrectedTPCClsInfo;
+               Int_t fUseMCPSmearing;
+               Double_t fPBremSmearing;
+               Double_t fPSigSmearing;
+               Double_t fPSigSmearingCte;
+               TRandom3 fRandom;
+               TF1 * fBrem;    
+               Bool_t   fDoPhotonAsymmetryCut; // flag to use the PhotonAsymetryCut
+               Int_t    fdoESDQtCut; // flag for ESD based Qt cut
+               Double_t fMinPPhotonAsymmetryCut;
+               Double_t fMinPhotonAsymmetry;
+                Bool_t fExcludeBackgroundEventForGammaCorrection; // flag for excluding Gamma from BGEvent for
+                Int_t fNumberOfPrimerisFromHijingAndPythia; //Number Of Primaries from Hijing and Pythia for PbPb
+               ClassDef(AliV0Reader,22) // RRnewTOF
 };
 
 inline void AliV0Reader::InitESDpid(Int_t type)
@@ -1050,32 +1096,32 @@ inline void AliV0Reader::InitESDpid(Int_t type)
   // type=0 is simulation
   // type=1 is data
 
-  if (!fgESDpid) fgESDpid=new AliESDpid;
-  Double_t alephParameters[5];
-  // simulation
-  alephParameters[0] = 2.15898e+00/50.;
-  alephParameters[1] = 1.75295e+01;
-  alephParameters[2] = 3.40030e-09;
-  alephParameters[3] = 1.96178e+00;
-  alephParameters[4] = 3.91720e+00;
-  fgESDpid->GetTOFResponse().SetTimeResolution(80.);
-
-  // data
-  if (type==1){
-    alephParameters[0] = 0.0283086/0.97;
-    alephParameters[1] = 2.63394e+01;
-    alephParameters[2] = 5.04114e-11;
-    alephParameters[3] = 2.12543e+00;
-    alephParameters[4] = 4.88663e+00;
-    fgESDpid->GetTOFResponse().SetTimeResolution(130.);
-    fgESDpid->GetTPCResponse().SetMip(50.);
-  }
-
-  fgESDpid->GetTPCResponse().SetBetheBlochParameters(
-    alephParameters[0],alephParameters[1],alephParameters[2],
-    alephParameters[3],alephParameters[4]);
-
-  fgESDpid->GetTPCResponse().SetSigma(3.79301e-03, 2.21280e+04);
+       if (!fgESDpid) fgESDpid=new AliESDpid;
+       Double_t alephParameters[5];
+       // simulation
+       alephParameters[0] = 2.15898e+00/50.;
+       alephParameters[1] = 1.75295e+01;
+       alephParameters[2] = 3.40030e-09;
+       alephParameters[3] = 1.96178e+00;
+       alephParameters[4] = 3.91720e+00;
+       fgESDpid->GetTOFResponse().SetTimeResolution(80.);
+
+       // data
+       if (type==1){
+               alephParameters[0] = 0.0283086/0.97;
+               alephParameters[1] = 2.63394e+01;
+               alephParameters[2] = 5.04114e-11;
+               alephParameters[3] = 2.12543e+00;
+               alephParameters[4] = 4.88663e+00;
+               fgESDpid->GetTOFResponse().SetTimeResolution(130.);
+               fgESDpid->GetTPCResponse().SetMip(50.);
+       }
+
+       fgESDpid->GetTPCResponse().SetBetheBlochParameters(
+               alephParameters[0],alephParameters[1],alephParameters[2],
+               alephParameters[3],alephParameters[4]);
+
+       fgESDpid->GetTPCResponse().SetSigma(3.79301e-03, 2.21280e+04);
 
 }
 
@@ -1085,3 +1131,4 @@ inline void AliV0Reader::InitESDpid(Int_t type)
 
 
 
+
index e45e378d9e7dda1b455edd2c7296086eff2a8806..6cb0fa1e0f7e27e6953d84abf7a652ef8fc0658d 100644 (file)
@@ -86,10 +86,6 @@ void AliAnaConvCorrBase::SetUpDefaultBins() {
   fAxiscPt.SetNameTitle("cPt", "track Pt");
   fAxesList.AddAt(&fAxiscPt, 3);
 
-  // TAxis * isoAxis = new TAxis();
-  // isoAxis->Set(2, 0, 2);
-  // fAxesList.AddAt(isoAxis, 5);
-  
   for(int iIso = 0; iIso < 2; iIso++) {
     fHNTriggers[iIso] = NULL;
   }
@@ -204,7 +200,7 @@ void AliAnaConvCorrBase::FillTriggerCounters(const AliAODConversionParticle * pa
 
 
 //________________________________________________________________
-void AliAnaConvCorrBase::CorrelateWithTracks(const AliAODConversionParticle * particle, const TObjArray * tracks, Int_t const tIDs[4], Bool_t isolated /*= kFALSE*/) {
+void AliAnaConvCorrBase::CorrelateWithTracks(AliAODConversionParticle * particle, TObjArray * tracks, Int_t const tIDs[4], Bool_t isolated /*= kFALSE*/) {
   //Correlate particle with tracks
 
   FillTriggerCounters(particle, isolated);
index 202cb82bc478fc3e090f75baafca0bc80b6024aa..c9a9fd6da3f03cd760e2eef77fe40250e9b9f9c8 100644 (file)
@@ -63,7 +63,7 @@ public:
 \r
   void PrintStatistics();\r
 \r
-  void CorrelateWithTracks(const AliAODConversionParticle * particle, const TObjArray * tracks, const Int_t tIDs[4], Bool_t isolated);\r
+  void CorrelateWithTracks(AliAODConversionParticle * particle, TObjArray * tracks, const Int_t tIDs[4], Bool_t isolated);\r
   virtual void FillTriggerCounters(const AliAODConversionParticle * particle, Bool_t leading);\r
 \r
   TAxis& GetAxistPt()  { return fAxistPt;   }\r
index 4c9e539cb8b1488e0ce435f8ab7ea346aefb76d5..d6a0b22049fe9c576a2949d6f0fcbfb20db62b25 100644 (file)
@@ -52,17 +52,17 @@ AliAnaConvCorrPhoton::~AliAnaConvCorrPhoton() {
   //destructor
 }
 
-//________________________________________________________________________________
-void AliAnaConvCorrPhoton::Process(TClonesArray * photons, TClonesArray * tracks, Bool_t isolated = kFALSE) {
-  //Process list of photons and correlate w tracks
-  for(Int_t ig = 0; ig < photons->GetEntriesFast(); ig++) {
+// //________________________________________________________________________________
+// void AliAnaConvCorrPhoton::Process(const TClonesArray * photons, const TClonesArray * tracks, Bool_t isolated = kFALSE) {
+//   //Process list of photons and correlate w tracks
+//   for(Int_t ig = 0; ig < photons->GetEntriesFast(); ig++) {
 
-       AliAODConversionParticle * photon = static_cast<AliAODConversionParticle*>(photons->UncheckedAt(ig));
+//     AliAODConversionParticle * photon = static_cast<AliAODConversionParticle*>(photons->UncheckedAt(ig));
 
-       Int_t tIDs[4] = {-1, -1, -1, -1};
-       tIDs[0] =  photon->GetLabel(0);
-       tIDs[1] =  photon->GetLabel(1);
-       CorrelateWithTracks(photon, tracks, tIDs, isolated);
+//     Int_t tIDs[4] = {-1, -1, -1, -1};
+//     tIDs[0] =  photon->GetLabel(0);
+//     tIDs[1] =  photon->GetLabel(1);
+//     CorrelateWithTracks(photon, tracks, tIDs, isolated);
                
-  }
-}
+//   }
+// }
index 5b9b66355877fe51b5e3d7d24a5e1c95d78660a8..d116c736935b7e4a98ef1f983e58aeee8fa2efe8 100644 (file)
@@ -30,7 +30,7 @@ public:
   void DoDecayParticles() { fSkipDecayParticles = kFALSE; }\r
   void DoDecayOnly() { fSkipDecayParticles = kFALSE; fDecayOnly = kTRUE; }\r
 \r
-  void Process(TClonesArray * photons, TClonesArray * tracks, Bool_t isolated);\r
+  //void Process(const TClonesArray * photons, const TClonesArray * tracks, Bool_t isolated);\r
 \r
  private:\r
 \r
index 35de87a83862d5e1950858ed5bf1a1444d530594..fcad5284970215db396b28906ad535b62285699f 100644 (file)
@@ -59,9 +59,8 @@ AliAnaConvCorrPion::AliAnaConvCorrPion(TString name, TString title = "Pion Corr"
 AliAnaConvCorrPion::~AliAnaConvCorrPion() {
   //destructor
 }
-//________________________________________________________________________________
+
 void AliAnaConvCorrPion::InitMassAxis() {
-  ///Add mass axis to axis list
   Double_t mbins[7] = {0.1, 0.11, 0.12, 0.15, 0.16, 0.18, 0.2};
   fAxisM.Set(6, mbins);
   fAxisM.SetNameTitle("InvMass", "invariant mass");
index 0a10f8a06bb8c47f6a45f26d11ae165bc105c2bb..26d2c3276048497670e230736a341eba749d1bef 100644 (file)
@@ -26,4 +26,6 @@
 #pragma link C++ class AliKFConversionPhoton++;
 #pragma link C++ class AliKFConversionMother++;
 
+#pragma link C++ class AliAnalysisTaskdPhi+;
+#pragma link C++ class AliConversionCuts++;
 #endif