TENDER becomes Tender, removing .so
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / AliConversionCuts.cxx
index 6f66aff..18db1a9 100644 (file)
@@ -1,16 +1,16 @@
 /**************************************************************************
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
- *                                 *
- * Authors: Svein Lindal, Daniel Lohner                 *
- * Version 1.0                        *
- *                           *
+ *                                                                       *
+ * 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.      *
+ * about the suitability of this software for any purpose. It is         *
+ * provided "as is" without express or implied warranty.                         *
  **************************************************************************/
 
 ////////////////////////////////////////////////
@@ -32,6 +32,7 @@
 #include "AliPIDResponse.h"
 #include "TH1.h"
 #include "TH2.h"
+#include "TF1.h"
 #include "AliStack.h"
 #include "AliAODConversionMother.h"
 #include "TObjString.h"
@@ -49,6 +50,7 @@
 #include "AliV0ReaderV1.h"
 #include "AliAODMCParticle.h"
 #include "AliAODMCHeader.h"
+#include "AliTRDTriggerAnalysis.h"
 
 class iostream;
 
@@ -61,8 +63,8 @@ const char* AliConversionCuts::fgkCutNames[AliConversionCuts::kNCuts] = {
    "HeavyIon",//0
    "CentralityMin",//1
    "CentralityMax",//2
-   "SelectV0AND",//3
-   "MultiplicityMethod",//4
+   "SelectSpecialTrigger",//3
+   "SelectSpecialSubTriggerClass",//4
    "RemovePileUp",//5
    "RejectExtraSignals",//6
    "V0FinderType",//7
@@ -84,7 +86,8 @@ const char* AliConversionCuts::fgkCutNames[AliConversionCuts::kNCuts] = {
    "SharedElectronCuts", //23
    "RejectToCloseV0s", //24
    "DcaRPrimVtx", //25
-   "DcaZPrimVtx" //26
+   "DcaZPrimVtx", //26
+   "EvetPlane" //27
 };
 
 
@@ -133,10 +136,8 @@ AliConversionCuts::AliConversionCuts(const char *name,const char *title) :
    fPIDMinPProtonRejectionLowP(2),
    fPIDMinPPionRejectionLowP(0),
    fDoQtGammaSelection(kTRUE),
-   fDoHighPtQtGammaSelection(kFALSE),
+   fDo2DQt(kFALSE),
    fQtMax(100),
-   fHighPtQtMax(0.),
-   fPtBorderForQt(0),
    fXVertexCut(0.),
    fYVertexCut(0.),
    fZVertexCut(0.),
@@ -156,14 +157,18 @@ AliConversionCuts::AliConversionCuts(const char *name,const char *title) :
    fUseTOFpid(kFALSE),
    fMultiplicityMethod(0),
    fSpecialTrigger(0),
+   fSpecialSubTrigger(0),
    fRemovePileUp(kFALSE),
    fOpeningAngle(0.005),
    fPsiPairCut(10000),
+   fDo2DPsiPairChi2(kFALSE),
    fCosPAngleCut(10000),
    fDoToCloseV0sCut(kFALSE),
    fRejectExtraSignals(0),
    fminV0Dist(200.),
    fDoSharedElecCut(kFALSE),
+   fDoPhotonQualitySelectionCut(kFALSE),
+   fPhotonQualityCut(0),
    fOfflineTriggerMask(0),
    fHasV0AND(kTRUE),
    fIsSDDFired(kTRUE),
@@ -172,6 +177,7 @@ AliConversionCuts::AliConversionCuts(const char *name,const char *title) :
    fElectronLabelArray(NULL),
    fDCAZPrimVtxCut(1000),
    fDCARPrimVtxCut(1000),
+   fInPlaneOutOfPlane(0),
    fConversionPointXArray(0.0),
    fConversionPointYArray(0.0),
    fConversionPointZArray(0.0),
@@ -193,6 +199,8 @@ AliConversionCuts::AliConversionCuts(const char *name,const char *title) :
    fNameFitDataPi0(""),
    fNameFitDataEta(""),
    fNameFitDataK0s(""),
+   hEtaDistV0s(NULL),
+   hEtaDistV0sAfterdEdxCuts(NULL),
    hdEdxCuts(NULL),
    hTPCdEdxbefore(NULL),
    hTPCdEdxafter(NULL),
@@ -201,6 +209,7 @@ AliConversionCuts::AliConversionCuts(const char *name,const char *title) :
    hTOFbefore(NULL),
    hTOFSigbefore(NULL),
    hTOFSigafter(NULL),
+   hPsiPairDeltaPhiafter(NULL),
    hTrackCuts(NULL),
    hPhotonCuts(NULL),
    hInvMassbefore(NULL),
@@ -213,6 +222,7 @@ AliConversionCuts::AliConversionCuts(const char *name,const char *title) :
    hCentrality(NULL),
    hCentralityVsNumberOfPrimaryTracks(NULL),
    hVertexZ(NULL),
+   hEventPlanePhi(NULL),
    hTriggerClass(NULL),
    hTriggerClassSelected(NULL),
    hReweightMCHistPi0(NULL),
@@ -221,10 +231,13 @@ AliConversionCuts::AliConversionCuts(const char *name,const char *title) :
    fFitDataPi0(NULL),
    fFitDataEta(NULL),
    fFitDataK0s(NULL),
+   fAddedSignalPDGCode(0),
    fPreSelCut(kFALSE),
    fTriggerSelectedManually(kFALSE),
-   fSpecialTriggerName("")
-   
+   fSpecialTriggerName(""),
+   fSpecialSubTriggerName(""),
+   fNSpecialSubTriggerOptions(0)
+
 {
    InitPIDResponse();
    for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=0;}
@@ -283,10 +296,8 @@ AliConversionCuts::AliConversionCuts(const AliConversionCuts &ref) :
    fPIDMinPProtonRejectionLowP(ref.fPIDMinPProtonRejectionLowP),
    fPIDMinPPionRejectionLowP(ref.fPIDMinPPionRejectionLowP),
    fDoQtGammaSelection(ref.fDoQtGammaSelection),
-   fDoHighPtQtGammaSelection(ref.fDoHighPtQtGammaSelection),
+   fDo2DQt(ref.fDo2DQt),
    fQtMax(ref.fQtMax),
-   fHighPtQtMax(ref.fHighPtQtMax),
-   fPtBorderForQt(ref.fPtBorderForQt),
    fXVertexCut(ref.fXVertexCut),
    fYVertexCut(ref.fYVertexCut),
    fZVertexCut(ref.fZVertexCut),
@@ -306,14 +317,18 @@ AliConversionCuts::AliConversionCuts(const AliConversionCuts &ref) :
    fUseTOFpid(ref.fUseTOFpid),
    fMultiplicityMethod(ref.fMultiplicityMethod),
    fSpecialTrigger(ref.fSpecialTrigger),
+   fSpecialSubTrigger(ref.fSpecialSubTrigger),
    fRemovePileUp(ref.fRemovePileUp),
    fOpeningAngle(ref.fOpeningAngle),
    fPsiPairCut(ref.fPsiPairCut),
+   fDo2DPsiPairChi2(ref.fDo2DPsiPairChi2),
    fCosPAngleCut(ref.fCosPAngleCut),
    fDoToCloseV0sCut(ref.fDoToCloseV0sCut),
    fRejectExtraSignals(ref.fRejectExtraSignals),
    fminV0Dist(ref.fminV0Dist),
    fDoSharedElecCut(ref.fDoSharedElecCut),
+   fDoPhotonQualitySelectionCut(ref.fDoPhotonQualitySelectionCut),
+   fPhotonQualityCut(ref.fPhotonQualityCut),
    fOfflineTriggerMask(ref.fOfflineTriggerMask),
    fHasV0AND(ref.fHasV0AND),
    fIsSDDFired(ref.fIsSDDFired),
@@ -322,6 +337,7 @@ AliConversionCuts::AliConversionCuts(const AliConversionCuts &ref) :
    fElectronLabelArray(NULL),
    fDCAZPrimVtxCut(ref.fDCAZPrimVtxCut),
    fDCARPrimVtxCut(ref.fDCAZPrimVtxCut),
+   fInPlaneOutOfPlane(ref.fInPlaneOutOfPlane),
    fConversionPointXArray(ref.fConversionPointXArray),
    fConversionPointYArray(ref.fConversionPointYArray),
    fConversionPointZArray(ref.fConversionPointZArray),
@@ -343,6 +359,8 @@ AliConversionCuts::AliConversionCuts(const AliConversionCuts &ref) :
    fNameFitDataPi0(ref.fNameFitDataPi0),
    fNameFitDataEta(ref.fNameFitDataEta),
    fNameFitDataK0s(ref.fNameFitDataK0s),
+   hEtaDistV0s(NULL),
+   hEtaDistV0sAfterdEdxCuts(NULL),
    hdEdxCuts(NULL),
    hTPCdEdxbefore(NULL),
    hTPCdEdxafter(NULL),
@@ -351,6 +369,7 @@ AliConversionCuts::AliConversionCuts(const AliConversionCuts &ref) :
    hTOFbefore(NULL),
    hTOFSigbefore(NULL),
    hTOFSigafter(NULL),
+   hPsiPairDeltaPhiafter(NULL),
    hTrackCuts(NULL),
    hPhotonCuts(NULL),
    hInvMassbefore(NULL),
@@ -363,17 +382,21 @@ AliConversionCuts::AliConversionCuts(const AliConversionCuts &ref) :
    hCentrality(NULL),
    hCentralityVsNumberOfPrimaryTracks(NULL),
    hVertexZ(NULL),
+   hEventPlanePhi(NULL),
    hTriggerClass(NULL),
    hTriggerClassSelected(NULL),
-   hReweightMCHistPi0(NULL),
-   hReweightMCHistEta(NULL),
-   hReweightMCHistK0s(NULL),
-   fFitDataPi0(NULL),
-   fFitDataEta(NULL),
-   fFitDataK0s(NULL),
+   hReweightMCHistPi0(ref.hReweightMCHistPi0),
+   hReweightMCHistEta(ref.hReweightMCHistEta),
+   hReweightMCHistK0s(ref.hReweightMCHistK0s),
+   fFitDataPi0(ref.fFitDataPi0),
+   fFitDataEta(ref.fFitDataEta),
+   fFitDataK0s(ref.fFitDataK0s),
+   fAddedSignalPDGCode(ref.fAddedSignalPDGCode),
    fPreSelCut(ref.fPreSelCut),
    fTriggerSelectedManually(ref.fTriggerSelectedManually),
-   fSpecialTriggerName(ref.fSpecialTriggerName)
+   fSpecialTriggerName(ref.fSpecialTriggerName),
+   fSpecialSubTriggerName(ref.fSpecialSubTriggerName),
+   fNSpecialSubTriggerOptions(ref.fNSpecialSubTriggerOptions)
 {
    // Copy Constructor
    for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=ref.fCuts[jj];}
@@ -443,25 +466,25 @@ void AliConversionCuts::InitCutHistograms(TString name, Bool_t preCut){
    if (hReweightMCHistEta){
       hReweightMCHistEta->SetName("MCInputForWeightingEta");
       fHistograms->Add(hReweightMCHistEta);
-   }   
+   }
    if (hReweightMCHistK0s){
       hReweightMCHistK0s->SetName("MCInputForWeightingK0s");
       fHistograms->Add(hReweightMCHistK0s);
-   }   
-   if (fFitDataPi0){
-      fFitDataPi0->SetName("DataFitForWeightingPi0");
-      fHistograms->Add(fFitDataPi0);
-   }   
-   if (fFitDataEta){
-      fFitDataEta->SetName("DataFitForWeightingEta");
-      fHistograms->Add(fFitDataEta);
-   }
-   if (fFitDataK0s){
-      fFitDataK0s->SetName("DataFitForWeightingK0s");
-      fHistograms->Add(fFitDataK0s);
    }
+//    if (fFitDataPi0){
+//       fFitDataPi0->SetName("DataFitForWeightingPi0");
+//       fHistograms->Add(fFitDataPi0);
+//    }
+//    if (fFitDataEta){
+//       fFitDataEta->SetName("DataFitForWeightingEta");
+//       fHistograms->Add(fFitDataEta);
+//    }
+//    if (fFitDataK0s){
+//       fFitDataK0s->SetName("DataFitForWeightingK0s");
+//       fHistograms->Add(fFitDataK0s);
+//    }
    // IsPhotonSelected
-   hCutIndex=new TH1F(Form("IsPhotonSelected %s",GetCutNumber().Data()),"IsPhotonSelected",10,-0.5,9.5);
+   hCutIndex=new TH1F(Form("IsPhotonSelected %s",GetCutNumber().Data()),"IsPhotonSelected",11,-0.5,10.5);
    hCutIndex->GetXaxis()->SetBinLabel(kPhotonIn+1,"in");
    hCutIndex->GetXaxis()->SetBinLabel(kOnFly+1,"onfly");
    hCutIndex->GetXaxis()->SetBinLabel(kNoTracks+1,"no tracks");
@@ -469,6 +492,7 @@ void AliConversionCuts::InitCutHistograms(TString name, Bool_t preCut){
    hCutIndex->GetXaxis()->SetBinLabel(kTrackCuts+1,"Track cuts");
    hCutIndex->GetXaxis()->SetBinLabel(kConvPointFail+1,"ConvPoint fail");
    hCutIndex->GetXaxis()->SetBinLabel(kPhotonCuts+1,"PhotonCuts");
+   hCutIndex->GetXaxis()->SetBinLabel(kEventPlane+1,"EventPlane");
    hCutIndex->GetXaxis()->SetBinLabel(kPhotonOut+1,"out");
    fHistograms->Add(hCutIndex);
 
@@ -485,7 +509,7 @@ void AliConversionCuts::InitCutHistograms(TString name, Bool_t preCut){
    fHistograms->Add(hTrackCuts);
 
    // Photon Cuts
-   hPhotonCuts=new TH1F(Form("PhotonCuts %s",GetCutNumber().Data()),"PhotonCuts",14,-0.5,13.5);
+   hPhotonCuts=new TH1F(Form("PhotonCuts %s",GetCutNumber().Data()),"PhotonCuts",15,-0.5,14.5);
    hPhotonCuts->GetXaxis()->SetBinLabel(1,"in");
    hPhotonCuts->GetXaxis()->SetBinLabel(2,"qtcut");
    hPhotonCuts->GetXaxis()->SetBinLabel(3,"chi2");
@@ -497,7 +521,8 @@ void AliConversionCuts::InitCutHistograms(TString name, Bool_t preCut){
    hPhotonCuts->GetXaxis()->SetBinLabel(9,"CosPAngle");
    hPhotonCuts->GetXaxis()->SetBinLabel(10,"DCA R");
    hPhotonCuts->GetXaxis()->SetBinLabel(11,"DCA Z");
-   hPhotonCuts->GetXaxis()->SetBinLabel(12,"out");
+   hPhotonCuts->GetXaxis()->SetBinLabel(12,"Photon Quality");
+   hPhotonCuts->GetXaxis()->SetBinLabel(13,"out");
    fHistograms->Add(hPhotonCuts);
 
    if(preCut){
@@ -505,6 +530,9 @@ void AliConversionCuts::InitCutHistograms(TString name, Bool_t preCut){
       fHistograms->Add(hInvMassbefore);
       hArmenterosbefore=new TH2F(Form("Armenteros_before %s",GetCutNumber().Data()),"Armenteros_before",200,-1,1,1000,0,1.);
       fHistograms->Add(hArmenterosbefore);
+      hEtaDistV0s = new TH1F(Form("Eta_before %s",GetCutNumber().Data()),"Eta_before",2000,-2,2);
+      fHistograms->Add(hEtaDistV0s);
+
    }
    hInvMassafter=new TH1F(Form("InvMass_after %s",GetCutNumber().Data()),"InvMass_after",1000,0,0.3);
    fHistograms->Add(hInvMassafter);
@@ -565,6 +593,12 @@ void AliConversionCuts::InitCutHistograms(TString name, Bool_t preCut){
    hTOFSigafter=new TH2F(Form("Gamma_TOFSig_after %s",GetCutNumber().Data()),"TOF Sigma Gamma after" ,150,0.03,20,400,-6,10);
    fHistograms->Add(hTOFSigafter);
 
+   hEtaDistV0sAfterdEdxCuts = new TH1F(Form("Eta_afterdEdx %s",GetCutNumber().Data()),"Eta_afterdEdx",2000,-2,2);
+   fHistograms->Add(hEtaDistV0sAfterdEdxCuts);
+
+   hPsiPairDeltaPhiafter=new TH2F(Form("Gamma_PsiPairDeltaPhi_after %s",GetCutNumber().Data()),"Psi Pair vs Delta Phi Gamma after" ,200,-2,2,200,-2,2);
+   fHistograms->Add(hPsiPairDeltaPhiafter);
+
    TAxis *AxisAfter = hTPCdEdxSigafter->GetXaxis();
    Int_t bins = AxisAfter->GetNbins();
    Double_t from = AxisAfter->GetXmin();
@@ -586,6 +620,11 @@ void AliConversionCuts::InitCutHistograms(TString name, Bool_t preCut){
    }
    delete [] newBins;
 
+   hCentrality=new TH1F(Form("Centrality %s",GetCutNumber().Data()),"Centrality",100,0,100);
+   fHistograms->Add(hCentrality);
+   hCentralityVsNumberOfPrimaryTracks=new TH2F(Form("Centrality vs Primary Tracks %s",GetCutNumber().Data()),"Centrality vs Primary Tracks ",100,0,100,4000,0,4000);
+   fHistograms->Add(hCentralityVsNumberOfPrimaryTracks);
+
    // Event Cuts and Info
    if(preCut){
       hV0EventCuts=new TH1F(Form("ESD_EventCuts %s",GetCutNumber().Data()),"Event Cuts",7,-0.5,6.5);
@@ -598,10 +637,6 @@ void AliConversionCuts::InitCutHistograms(TString name, Bool_t preCut){
       hV0EventCuts->GetXaxis()->SetBinLabel(7,"out");
       fHistograms->Add(hV0EventCuts);
 
-      hCentrality=new TH1F(Form("Centrality %s",GetCutNumber().Data()),"Centrality",1000,0,100);
-      fHistograms->Add(hCentrality);
-      hCentralityVsNumberOfPrimaryTracks=new TH2F(Form("Centrality vs Primary Tracks %s",GetCutNumber().Data()),"Centrality vs Primary Tracks ",100,0,100,4000,0,4000);
-      fHistograms->Add(hCentralityVsNumberOfPrimaryTracks);
       hVertexZ=new TH1F(Form("VertexZ %s",GetCutNumber().Data()),"VertexZ",1000,-50,50);
       fHistograms->Add(hVertexZ);
 
@@ -680,6 +715,11 @@ void AliConversionCuts::InitCutHistograms(TString name, Bool_t preCut){
       hTriggerClassSelected->GetXaxis()->SetBinLabel(33,"V0AND");
       hTriggerClassSelected->GetXaxis()->SetBinLabel(34,"NOT kFastOnly");
       fHistograms->Add(hTriggerClassSelected);
+      
+      hEventPlanePhi=new TH1F(Form("EventPlaneMinusPhotonAngle %s",GetCutNumber().Data()),"EventPlaneMinusPhotonAngle",360,-TMath::Pi(),TMath::Pi());
+      fHistograms->Add(hEventPlanePhi);
+
+      
    }
    TH1::AddDirectory(kTRUE);
 }
@@ -802,10 +842,10 @@ Bool_t AliConversionCuts::PhotonIsSelectedMC(TParticle *particle,AliStack *fMCSt
    if (particle->GetPdgCode() == 22){
 
 
-      if( particle->Eta() > (fEtaCut + fEtaShift) || particle->Eta() < (-fEtaCut + fEtaShift) )
+     if( particle->Eta() > (fEtaCut) || particle->Eta() < (-fEtaCut) )
          return kFALSE;
       if(fEtaCutMin>-0.1){
-         if( particle->Eta() < (fEtaCutMin + fEtaShift) && particle->Eta() > (-fEtaCutMin + fEtaShift) )
+         if( particle->Eta() < (fEtaCutMin) && particle->Eta() > (-fEtaCutMin) )
             return kFALSE;
       }
 
@@ -844,13 +884,13 @@ Bool_t AliConversionCuts::PhotonIsSelectedMC(TParticle *particle,AliStack *fMCSt
          return kFALSE; // no reconstruction below the Pt cut
       }
 
-      if( ePos->Eta() > (fEtaCut + fEtaShift) || ePos->Eta() < (-fEtaCut + fEtaShift) ||
-          eNeg->Eta() > (fEtaCut + fEtaShift) || eNeg->Eta() < (-fEtaCut + fEtaShift) )
+      if( ePos->Eta() > (fEtaCut) || ePos->Eta() < (-fEtaCut) ||
+          eNeg->Eta() > (fEtaCut) || eNeg->Eta() < (-fEtaCut) )
          return kFALSE;
 
       if(fEtaCutMin > -0.1){
-         if( (ePos->Eta() < (fEtaCutMin + fEtaShift) && ePos->Eta() > (-fEtaCutMin + fEtaShift)) ||
-             (eNeg->Eta() < (fEtaCutMin + fEtaShift) && eNeg->Eta() > (-fEtaCutMin + fEtaShift)) )
+         if( (ePos->Eta() < (fEtaCutMin) && ePos->Eta() > (-fEtaCutMin)) ||
+             (eNeg->Eta() < (fEtaCutMin) && eNeg->Eta() > (-fEtaCutMin)) )
             return kFALSE;
       }
 
@@ -887,12 +927,12 @@ Bool_t AliConversionCuts::PhotonIsSelectedAODMC(AliAODMCParticle *particle,TClon
    // MonteCarlo Photon Selection
 
    if(!aodmcArray)return kFALSE;
-   
+
    if (particle->GetPdgCode() == 22){
-      if( particle->Eta() > (fEtaCut + fEtaShift) || particle->Eta() < (-fEtaCut + fEtaShift) )
+      if( particle->Eta() > (fEtaCut) || particle->Eta() < (-fEtaCut) )
          return kFALSE;
       if(fEtaCutMin>-0.1){
-         if( particle->Eta() < (fEtaCutMin + fEtaShift) && particle->Eta() > (-fEtaCutMin + fEtaShift) )
+         if( particle->Eta() < (fEtaCutMin) && particle->Eta() > (-fEtaCutMin) )
             return kFALSE;
       }
 
@@ -904,7 +944,7 @@ Bool_t AliConversionCuts::PhotonIsSelectedAODMC(AliAODMCParticle *particle,TClon
             return kFALSE; // the gamma has a mother, and it is not a primary particle
          }
       }
-      
+
       if(!checkForConvertedGamma) return kTRUE; // return in case of accepted gamma
 
       // looking for conversion gammas (electron + positron from pairbuilding (= 5) )
@@ -924,7 +964,7 @@ Bool_t AliConversionCuts::PhotonIsSelectedAODMC(AliAODMCParticle *particle,TClon
             }
          }
       }
-      
+
       if(ePos == NULL || eNeg == NULL){ // means we do not have two daughters from pair production
          return kFALSE;
       }
@@ -933,19 +973,19 @@ Bool_t AliConversionCuts::PhotonIsSelectedAODMC(AliAODMCParticle *particle,TClon
          return kFALSE; // no reconstruction below the Pt cut
       }
 
-      if( ePos->Eta() > (fEtaCut + fEtaShift) || ePos->Eta() < (-fEtaCut + fEtaShift) ||
-          eNeg->Eta() > (fEtaCut + fEtaShift) || eNeg->Eta() < (-fEtaCut + fEtaShift) )
+      if( ePos->Eta() > (fEtaCut) || ePos->Eta() < (-fEtaCut) ||
+          eNeg->Eta() > (fEtaCut) || eNeg->Eta() < (-fEtaCut) )
          return kFALSE;
 
       if(fEtaCutMin > -0.1){
-         if( (ePos->Eta() < (fEtaCutMin + fEtaShift) && ePos->Eta() > (-fEtaCutMin + fEtaShift)) ||
-             (eNeg->Eta() < (fEtaCutMin + fEtaShift) && eNeg->Eta() > (-fEtaCutMin + fEtaShift)) )
+         if( (ePos->Eta() < (fEtaCutMin) && ePos->Eta() > (-fEtaCutMin)) ||
+             (eNeg->Eta() < (fEtaCutMin) && eNeg->Eta() > (-fEtaCutMin)) )
             return kFALSE;
       }
 
       Double_t rPos = sqrt( (ePos->Xv()*ePos->Xv()) + (ePos->Yv()*ePos->Yv()) );
       Double_t rNeg = sqrt( (eNeg->Xv()*eNeg->Xv()) + (eNeg->Yv()*eNeg->Yv()) );
-     
+
       if(rPos>fMaxR){
          return kFALSE; // cuts on distance from collision point
       }
@@ -983,7 +1023,6 @@ Bool_t AliConversionCuts::PhotonCuts(AliConversionPhotonBase *photon,AliVEvent *
 
    // Fill Histos before Cuts
    if(hInvMassbefore)hInvMassbefore->Fill(photon->GetMass());
-
    if(hArmenterosbefore)hArmenterosbefore->Fill(photon->GetArmenterosAlpha(),photon->GetArmenterosQt());
 
    // Gamma selection based on QT from Armenteros
@@ -1032,6 +1071,16 @@ Bool_t AliConversionCuts::PhotonCuts(AliConversionPhotonBase *photon,AliVEvent *
       return kFALSE;
    }
 
+   Double_t magField = event->GetMagneticField();
+   if( magField  < 0.0 ){
+      magField =  1.0;
+   } else {
+      magField =  -1.0;
+   }
+   
+   AliVTrack * electronCandidate = GetTrack(event,photon->GetTrackLabelNegative() );
+   AliVTrack * positronCandidate = GetTrack(event,photon->GetTrackLabelPositive() );
+   Double_t deltaPhi = magField * TVector2::Phi_mpi_pi( electronCandidate->Phi()-positronCandidate->Phi());
 
    cutIndex++; //7
    if(!PsiPairCut(photon)) {
@@ -1048,13 +1097,13 @@ Bool_t AliConversionCuts::PhotonCuts(AliConversionPhotonBase *photon,AliVEvent *
    AliAODConversionPhoton* photonAOD = dynamic_cast<AliAODConversionPhoton*>(photon);
    if (photonAOD){
       photonAOD->CalculateDistanceOfClossetApproachToPrimVtx(event->GetPrimaryVertex());
-      
+
       cutIndex++; //9
       if(photonAOD->GetDCArToPrimVtx() > fDCARPrimVtxCut) { //DCA R cut of photon to primary vertex
          if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //9
          return kFALSE;
       }
-      
+
       cutIndex++; //10
       if(abs(photonAOD->GetDCAzToPrimVtx()) > fDCAZPrimVtxCut) { //DCA Z cut of photon to primary vertex
          if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //10
@@ -1065,12 +1114,27 @@ Bool_t AliConversionCuts::PhotonCuts(AliConversionPhotonBase *photon,AliVEvent *
       cutIndex++; //10
    }
    cutIndex++; //11
+
+   if (photonAOD){
+          UChar_t photonQuality = 0;
+           AliAODEvent * aodEvent = dynamic_cast<AliAODEvent*>(event);
+               if(aodEvent) {
+                       photonQuality = DeterminePhotonQualityAOD(photonAOD, event);
+               } else {
+                       photonQuality = photonAOD->GetPhotonQuality();
+               }       
+               if (fDoPhotonQualitySelectionCut && photonQuality != fPhotonQualityCut){
+                       if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //11
+                       return kFALSE;
+               }       
+   } 
+   cutIndex++; //12
    if(hPhotonCuts)hPhotonCuts->Fill(cutIndex); //11
 
    // Histos after Cuts
    if(hInvMassafter)hInvMassafter->Fill(photon->GetMass());
    if(hArmenterosafter)hArmenterosafter->Fill(photon->GetArmenterosAlpha(),photon->GetArmenterosQt());
-   
+   if(hPsiPairDeltaPhiafter)hPsiPairDeltaPhiafter->Fill(deltaPhi,photon->GetPsiPair());
    return kTRUE;
 
 }
@@ -1144,13 +1208,13 @@ Bool_t AliConversionCuts::PhotonIsSelected(AliConversionPhotonBase *photon, AliV
       FillPhotonCutIndex(kTrackCuts);
       return kFALSE;
    }
-   
+   if (hEtaDistV0s)hEtaDistV0s->Fill(photon->GetPhotonEta());
    // dEdx Cuts
    if(!dEdxCuts(negTrack) || !dEdxCuts(posTrack)) {
       FillPhotonCutIndex(kdEdxCuts);
       return kFALSE;
    }
-
+   if (hEtaDistV0sAfterdEdxCuts)hEtaDistV0sAfterdEdxCuts->Fill(photon->GetPhotonEta());
    // Photon Cuts
    if(!PhotonCuts(photon,event)){
       FillPhotonCutIndex(kPhotonCuts);
@@ -1165,19 +1229,11 @@ Bool_t AliConversionCuts::PhotonIsSelected(AliConversionPhotonBase *photon, AliV
 ///________________________________________________________________________
 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;
-         }
+   if(fDo2DQt){
+      if ( !(TMath::Power(photon->GetArmenterosAlpha()/0.95,2)+TMath::Power(photon->GetArmenterosQt()/fQtMax,2) < 1) ){
+         return kFALSE;
       }
    } else {
-
       if(photon->GetArmenterosQt()>fQtMax){
          return kFALSE;
       }
@@ -1223,12 +1279,12 @@ Bool_t AliConversionCuts::AcceptanceCuts(AliConversionPhotonBase *photon) {
    cutIndex++;
 
 
-   if( photon->GetPhotonEta() > (fEtaCut + fEtaShift)    || photon->GetPhotonEta() < (-fEtaCut + fEtaShift) ){
+   if( photon->GetPhotonEta() > (fEtaCut)    || photon->GetPhotonEta() < (-fEtaCut) ){
       if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
       return kFALSE;
    }
    if(fEtaCutMin>-0.1){
-      if( photon->GetPhotonEta() < (fEtaCutMin + fEtaShift) && photon->GetPhotonEta() > (-fEtaCutMin + fEtaShift) ){
+      if( photon->GetPhotonEta() < (fEtaCutMin) && photon->GetPhotonEta() > (-fEtaCutMin) ){
          if(hAcceptanceCuts)hAcceptanceCuts->Fill(cutIndex);
          return kFALSE;
       }
@@ -1303,8 +1359,8 @@ Bool_t AliConversionCuts::TracksAreSelected(AliVTrack * negTrack, AliVTrack * po
    cutIndex++;
 
    // Number of TPC Clusters
-   
-   
+
+
    if( negTrack->GetNcls(1) < fMinClsTPC || posTrack->GetNcls(1) < fMinClsTPC ) {
       if(hTrackCuts)hTrackCuts->Fill(cutIndex);
       return kFALSE;
@@ -1312,14 +1368,14 @@ Bool_t AliConversionCuts::TracksAreSelected(AliVTrack * negTrack, AliVTrack * po
    cutIndex++;
 
    // Acceptance
-   if( posTrack->Eta() > (fEtaCut + fEtaShift) || posTrack->Eta() < (-fEtaCut + fEtaShift) ||
-       negTrack->Eta() > (fEtaCut + fEtaShift) || negTrack->Eta() < (-fEtaCut + fEtaShift) ){
+   if( posTrack->Eta() > (fEtaCut) || posTrack->Eta() < (-fEtaCut) ||
+       negTrack->Eta() > (fEtaCut) || negTrack->Eta() < (-fEtaCut) ){
       if(hTrackCuts)hTrackCuts->Fill(cutIndex);
       return kFALSE;
    }
    if(fEtaCutMin>-0.1){
-      if( (posTrack->Eta() < (fEtaCutMin + fEtaShift) && posTrack->Eta() > (-fEtaCutMin + fEtaShift)) ||
-          (negTrack->Eta() < (fEtaCutMin + fEtaShift) && negTrack->Eta() > (-fEtaCutMin + fEtaShift)) ){
+      if( (posTrack->Eta() < (fEtaCutMin) && posTrack->Eta() > (-fEtaCutMin)) ||
+          (negTrack->Eta() < (fEtaCutMin) && negTrack->Eta() > (-fEtaCutMin)) ){
          if(hTrackCuts)hTrackCuts->Fill(cutIndex);
          return kFALSE;
       }
@@ -1357,7 +1413,6 @@ Bool_t AliConversionCuts::TracksAreSelected(AliVTrack * negTrack, AliVTrack * po
 ///________________________________________________________________________
 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
 
@@ -1367,7 +1422,6 @@ Bool_t AliConversionCuts::dEdxCuts(AliVTrack *fCurrentTrack){
    if(hTPCdEdxbefore)hTPCdEdxbefore->Fill(fCurrentTrack->P(),fCurrentTrack->GetTPCsignal());
    cutIndex++;
 
-
    if(fDodEdxSigmaCut == kTRUE){
       // TPC Electron Line
       if( fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kElectron)<fPIDnSigmaBelowElectronLine ||
@@ -1414,7 +1468,6 @@ Bool_t AliConversionCuts::dEdxCuts(AliVTrack *fCurrentTrack){
       }
    }
    cutIndex++;
-
    if(fDoProtonRejectionLowP == kTRUE){
       if( fCurrentTrack->P()<fPIDMinPProtonRejectionLowP ){
          if( abs(fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kProton))<fPIDnSigmaAtLowPAroundProtonLine){
@@ -1454,7 +1507,7 @@ Bool_t AliConversionCuts::dEdxCuts(AliVTrack *fCurrentTrack){
    if((fCurrentTrack->GetStatus() & AliESDtrack::kTOFpid) && !(fCurrentTrack->GetStatus() & AliESDtrack::kTOFmismatch)){
       if(hTOFbefore){
          Double_t t0 = fPIDResponse->GetTOFResponse().GetStartTime(fCurrentTrack->P());
-         Double_t times[5];
+         Double_t  times[AliPID::kSPECIESC];
          fCurrentTrack->GetIntegratedTimes(times);
          Double_t TOFsignal = fCurrentTrack->GetTOFsignal();
          Double_t dT = TOFsignal - t0 - times[0];
@@ -1471,7 +1524,6 @@ Bool_t AliConversionCuts::dEdxCuts(AliVTrack *fCurrentTrack){
       if(hTOFSigafter)hTOFSigafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kElectron));
    }
    cutIndex++;
-
    // Apply TRD PID
    if(fDoTRDPID){
       if(!fPIDResponse->IdentifiedAsElectronTRD(fCurrentTrack,fPIDTRDEfficiency)){
@@ -1484,6 +1536,7 @@ Bool_t AliConversionCuts::dEdxCuts(AliVTrack *fCurrentTrack){
    if(hdEdxCuts)hdEdxCuts->Fill(cutIndex);
    if(hTPCdEdxSigafter)hTPCdEdxSigafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTPC(fCurrentTrack, AliPID::kElectron));
    if(hTPCdEdxafter)hTPCdEdxafter->Fill(fCurrentTrack->P(),fCurrentTrack->GetTPCsignal());
+   
    return kTRUE;
 }
 
@@ -1500,7 +1553,7 @@ Bool_t AliConversionCuts::AsymmetryCut(AliConversionPhotonBase * photon,AliVEven
          if (photon->GetPhotonP()!=0.){
             trackNegAsy= track->P()/photon->GetPhotonP();
          }
-         
+
          if( trackNegAsy<fMinPhotonAsymmetry ||trackNegAsy>(1.- fMinPhotonAsymmetry)){
             return kFALSE;
          }
@@ -1528,7 +1581,7 @@ AliVTrack *AliConversionCuts::GetTrack(AliVEvent * event, Int_t label){
          track = dynamic_cast<AliVTrack*>(event->GetTrack(label));
          return track;
       }
-      else{      
+      else{
          for(Int_t ii=0; ii<event->GetNumberOfTracks(); ii++) {
             track = dynamic_cast<AliVTrack*>(event->GetTrack(ii));
             if(track){
@@ -1637,23 +1690,23 @@ Bool_t AliConversionCuts::AcceptanceCut(TParticle *particle, TParticle * ePos,TP
    }
 
 
-   if( particle->Eta() > (fEtaCut + fEtaShift) || particle->Eta() < (-fEtaCut + fEtaShift) ){
+   if( particle->Eta() > (fEtaCut) || particle->Eta() < (-fEtaCut) ){
       return kFALSE;
    }
-   if( ePos->Eta() > (fEtaCut + fEtaShift) || ePos->Eta() < (-fEtaCut + fEtaShift) ){
+   if( ePos->Eta() > (fEtaCut) || ePos->Eta() < (-fEtaCut) ){
       return kFALSE;
    }
-   if( eNeg->Eta() > (fEtaCut + fEtaShift) || eNeg->Eta() < (-fEtaCut + fEtaShift) ){
+   if( eNeg->Eta() > (fEtaCut) || eNeg->Eta() < (-fEtaCut) ){
       return kFALSE;
    }
    if(fEtaCutMin>-0.1){
-      if( particle->Eta() < (fEtaCutMin + fEtaShift) && particle->Eta() > (-fEtaCutMin + fEtaShift) ){
+      if( particle->Eta() < (fEtaCutMin) && particle->Eta() > (-fEtaCutMin) ){
          return kFALSE;
       }
-      if( ePos->Eta() < (fEtaCutMin + fEtaShift) && ePos->Eta() > (-fEtaCutMin + fEtaShift) ){
+      if( ePos->Eta() < (fEtaCutMin) && ePos->Eta() > (-fEtaCutMin) ){
          return kFALSE;
       }
-      if( eNeg->Eta() < (fEtaCutMin + fEtaShift) && eNeg->Eta() > (-fEtaCutMin + fEtaShift) ){
+      if( eNeg->Eta() < (fEtaCutMin) && eNeg->Eta() > (-fEtaCutMin) ){
          return kFALSE;
       }
    }
@@ -1679,7 +1732,7 @@ Bool_t AliConversionCuts::UpdateCutString() {
    }
    return kTRUE;
 }
-
+///________________________________________________________________________
 void AliConversionCuts::LoadReweightingHistosMCFromFile() {
 
   AliInfo("Entering loading of histograms for weighting");
@@ -1687,44 +1740,58 @@ void AliConversionCuts::LoadReweightingHistosMCFromFile() {
   if(!f){
      AliError(Form("file for weighting %s not found",fPathTrFReweighting.Data()));
      return;
-  } 
+  }
   if (fNameHistoReweightingPi0.CompareTo("") != 0 && fDoReweightHistoMCPi0 ){
-     hReweightMCHistPi0 = (TH1D*)f->Get(fNameHistoReweightingPi0.Data());
+        cout << "I have to find: " <<  fNameHistoReweightingPi0.Data() << endl;
+     TH1D *hReweightMCHistPi0temp = (TH1D*)f->Get(fNameHistoReweightingPi0.Data());
+     hReweightMCHistPi0 = new TH1D(*hReweightMCHistPi0temp);
      if (hReweightMCHistPi0) AliInfo(Form("%s has been loaded from %s", fNameHistoReweightingPi0.Data(),fPathTrFReweighting.Data() ));
-       else AliWarning(Form("%s not found in %s", fNameHistoReweightingPi0.Data() ,fPathTrFReweighting.Data()));
+     else AliWarning(Form("%s not found in %s", fNameHistoReweightingPi0.Data() ,fPathTrFReweighting.Data()));
+        hReweightMCHistPi0->SetDirectory(0);
   }
   if (fNameFitDataPi0.CompareTo("") != 0 && fDoReweightHistoMCPi0 ){
-     fFitDataPi0 = (TF1*)f->Get(fNameFitDataPi0.Data());
+         cout << "I have to find: " <<  fNameFitDataPi0.Data() << endl;
+     TF1 *fFitDataPi0temp = (TF1*)f->Get(fNameFitDataPi0.Data());
+     fFitDataPi0 = new TF1(*fFitDataPi0temp);
      if (fFitDataPi0) AliInfo(Form("%s has been loaded from %s", fNameFitDataPi0.Data(),fPathTrFReweighting.Data() ));
-       else AliWarning(Form("%s not found in %s",fPathTrFReweighting.Data(), fNameFitDataPi0.Data() ));
+     else AliWarning(Form("%s not found in %s",fPathTrFReweighting.Data(), fNameFitDataPi0.Data() ));
   }
-  
+
   if (fNameHistoReweightingEta.CompareTo("") != 0 && fDoReweightHistoMCEta){
-     hReweightMCHistEta = (TH1D*)f->Get(fNameHistoReweightingEta.Data());
+        cout << "I have to find: " <<  fNameHistoReweightingEta.Data() << endl;
+     TH1D *hReweightMCHistEtatemp = (TH1D*)f->Get(fNameHistoReweightingEta.Data());
+     hReweightMCHistEta = new TH1D(*hReweightMCHistEtatemp);
      if (hReweightMCHistEta) AliInfo(Form("%s has been loaded from %s", fNameHistoReweightingEta.Data(),fPathTrFReweighting.Data() ));
-       else AliWarning(Form("%s not found in %s", fNameHistoReweightingEta.Data(),fPathTrFReweighting.Data() ));
-
+     else AliWarning(Form("%s not found in %s", fNameHistoReweightingEta.Data(),fPathTrFReweighting.Data() ));
+        hReweightMCHistEta->SetDirectory(0);
   }
-  
+
   if (fNameFitDataEta.CompareTo("") != 0 && fDoReweightHistoMCEta){
-     fFitDataEta = (TF1*)f->Get(fNameFitDataEta.Data());
+        cout << "I have to find: " <<  fNameFitDataEta.Data() << endl;
+     TF1 *fFitDataEtatemp = (TF1*)f->Get(fNameFitDataEta.Data());
+     fFitDataEta = new TF1(*fFitDataEtatemp);
      if (fFitDataEta) AliInfo(Form("%s has been loaded from %s", fNameFitDataEta.Data(),fPathTrFReweighting.Data() ));
-       else AliWarning(Form("%s not found in %s", fNameFitDataEta.Data(),fPathTrFReweighting.Data() ));
+     else AliWarning(Form("%s not found in %s", fNameFitDataEta.Data(),fPathTrFReweighting.Data() ));
 
   }
   if (fNameHistoReweightingK0s.CompareTo("") != 0 && fDoReweightHistoMCK0s){
-     hReweightMCHistK0s = (TH1D*)f->Get(fNameHistoReweightingK0s.Data());
+        cout << "I have to find: " <<  fNameHistoReweightingK0s.Data() << endl;
+     TH1D *hReweightMCHistK0stemp = (TH1D*)f->Get(fNameHistoReweightingK0s.Data());
+     hReweightMCHistK0s = new TH1D(*hReweightMCHistK0stemp);
      if (hReweightMCHistK0s) AliInfo(Form("%s has been loaded from %s", fNameHistoReweightingK0s.Data(),fPathTrFReweighting.Data() ));
-       else AliWarning(Form("%s not found in %s", fNameHistoReweightingK0s.Data(),fPathTrFReweighting.Data() ));
-
+     else AliWarning(Form("%s not found in %s", fNameHistoReweightingK0s.Data(),fPathTrFReweighting.Data() ));
+        hReweightMCHistK0s->SetDirectory(0);
   }
 
   if (fNameFitDataK0s.CompareTo("") != 0 && fDoReweightHistoMCK0s){
-     fFitDataK0s = (TF1*)f->Get(fNameFitDataK0s.Data());
+        cout << "I have to find: " <<  fNameFitDataK0s.Data() << endl; 
+     TF1 *fFitDataK0stemp = (TF1*)f->Get(fNameFitDataK0s.Data());
+     fFitDataK0s = new TF1(*fFitDataK0stemp);
      if (fFitDataK0s) AliInfo(Form("%s has been loaded from %s", fNameFitDataK0s.Data(),fPathTrFReweighting.Data() ));
-       else AliWarning(Form("%s not found in %s", fNameFitDataK0s.Data(),fPathTrFReweighting.Data() ));
-
+     else AliWarning(Form("%s not found in %s", fNameFitDataK0s.Data(),fPathTrFReweighting.Data() ));
   }
+  f->Close();
+  delete f;
   
 }
 
@@ -1735,9 +1802,8 @@ Bool_t AliConversionCuts::InitializeCutsFromCutString(const TString analysisCutS
    if(fDoReweightHistoMCPi0 || fDoReweightHistoMCEta || fDoReweightHistoMCK0s) {
       AliInfo("Weighting was enabled");
       LoadReweightingHistosMCFromFile();
-      
    }
-   
+
    AliInfo(Form("Set Photoncut Number: %s",analysisCutSelection.Data()));
    if(analysisCutSelection.Length()!=kNCuts) {
       AliError(Form("Cut selection has the wrong length! size is %d, number of cuts is %d", analysisCutSelection.Length(), kNCuts));
@@ -1759,7 +1825,7 @@ Bool_t AliConversionCuts::InitializeCutsFromCutString(const TString analysisCutS
       if(!SetCut(cutIds(ii),fCuts[ii]))return kFALSE;
    }
 
-   //PrintCuts();
+   PrintCutsWithValues();
 
    return kTRUE;
 }
@@ -1860,16 +1926,16 @@ Bool_t AliConversionCuts::SetCut(cutIds cutID, const Int_t value) {
          return kTRUE;
       } else return kFALSE;
 
-   case kselectV0AND:
+   case kSelectSpecialTriggerAlias:
       if( SetSelectSpecialTrigger(value)) {
-         fCuts[kselectV0AND] = value;
+         fCuts[kSelectSpecialTriggerAlias] = value;
          UpdateCutString();
          return kTRUE;
       } else return kFALSE;
 
-   case kmultiplicityMethod:
-      if( SetMultiplicityMethod(value)) {
-         fCuts[kmultiplicityMethod] = value;
+   case kSelectSubTriggerClass:
+      if( SetSelectSubTriggerClass(value)) {
+         fCuts[kSelectSubTriggerClass] = value;
          UpdateCutString();
          return kTRUE;
       } else return kFALSE;
@@ -1959,7 +2025,16 @@ Bool_t AliConversionCuts::SetCut(cutIds cutID, const Int_t value) {
          return kTRUE;
       } else return kFALSE;
 
+   case kInPlaneOutOfPlane:
+   if( SetInPlaneOutOfPlane(value)) {
+      fCuts[kInPlaneOutOfPlane] = value;
+      UpdateCutString();
+      return kTRUE;
+   } else return kFALSE;
+
+
       
+
    case kNCuts:
       AliError("Cut id out of range");
       return kFALSE;
@@ -1977,6 +2052,118 @@ void AliConversionCuts::PrintCuts() {
       printf("%-30s : %d \n", fgkCutNames[ic], fCuts[ic]);
    }
 }
+
+void AliConversionCuts::PrintCutsWithValues() {
+   // Print out current Cut Selection with value
+       printf("\nConversion cutnumber \n");
+       for(Int_t ic = 0; ic < kNCuts; ic++) {
+               printf("%d",fCuts[ic]);
+       }
+       printf("\n\n");
+
+       
+   if (fIsHeavyIon == 0) {
+      printf("Running in pp mode \n");
+      if (fSpecialTrigger == 0){
+        printf("\t only events triggered by V0OR will be analysed \n");
+      } else if (fSpecialTrigger == 1){
+        printf("\t only events triggered by V0AND will be analysed \n");
+      } else if (fSpecialTrigger == 2){
+         printf("\t only events where SDD was present will be analysed \n");
+      } else if (fSpecialTrigger == 3){
+         printf("\t only events where SDD was present will be analysed and triggered by VOAND\n");
+      } else if (fSpecialTrigger > 3){ 
+         printf("\t only events triggered by %s %s\n", fSpecialTriggerName.Data(), fSpecialSubTriggerName.Data());
+      }
+   } else if (fIsHeavyIon == 1){ 
+      printf("Running in PbPb mode \n");
+      if (fDetectorCentrality == 0){
+         printf("\t centrality selection based on V0M \n");
+      } else if (fDetectorCentrality == 1){
+         printf("\t centrality selection based on Cl1 \n");
+      }   
+      if (fModCentralityClass == 0){
+        printf("\t %d - %d \n", fCentralityMin*10, fCentralityMax*10);
+      } else if ( fModCentralityClass == 1){ 
+        printf("\t %d - %d \n", fCentralityMin*5, fCentralityMax*5);
+      } else if ( fModCentralityClass == 2){ 
+        printf("\t %d - %d \n", fCentralityMin*5+45, fCentralityMax*5+45);
+      } else if (fModCentralityClass == 3){
+        printf("\t %d - %d, with Track mult in MC as data \n", fCentralityMin*10, fCentralityMax*10);
+      } else if ( fModCentralityClass == 4){ 
+        printf("\t %d - %d, with Track mult in MC as data \n", fCentralityMin*5, fCentralityMax*5);
+      } else if ( fModCentralityClass == 5){ 
+        printf("\t %d - %d, with Track mult in MC as data \n", fCentralityMin*5+45, fCentralityMax*5+45);
+      }
+      if (fSpecialTrigger == 0){
+        printf("\t only events triggered by kMB, kCentral, kSemiCentral will be analysed \n");
+      } else if (fSpecialTrigger > 4){   
+         printf("\t only events triggered by %s %s\n", fSpecialTriggerName.Data(), fSpecialSubTriggerName.Data());
+      }
+   } else if (fIsHeavyIon == 2){
+      printf("Running in pPb mode \n");
+      if (fDetectorCentrality == 0){
+         printf("\t centrality selection based on V0A \n");
+      } else if (fDetectorCentrality == 1){
+         printf("\t centrality selection based on Cl1 \n");
+      }   
+      if (fModCentralityClass == 0){
+        printf("\t %d - %d \n", fCentralityMin*10, fCentralityMax*10);
+      }
+      if (fSpecialTrigger == 0){
+        printf("\t only events triggered by kINT7 will be analysed \n");
+      } else if (fSpecialTrigger > 4){   
+         printf("\t only events triggered by %s %s\n", fSpecialTriggerName.Data(), fSpecialSubTriggerName.Data());
+      }
+   }
+   printf("MC event cuts: \n");
+   if (fRejectExtraSignals == 0) printf("\t no rejection was applied \n");
+       else if (fRejectExtraSignals == 1) printf("\t only MB header will be inspected \n");
+       else if (fRejectExtraSignals > 1) printf("\t special header have been selected \n");
+       
+   printf("Electron cuts & Secondary Track Cuts - only track from secondaries enter analysis: \n");
+   printf("\t no like sign pairs from V0s \n");
+   if (!fUseCorrectedTPCClsInfo) printf("\t # TPC clusters > %3.2f \n", fMinClsTPC);
+   if (fEtaCutMin > -0.1) printf("\t %3.2f < eta_{e} < %3.2f\n", fEtaCutMin, fEtaCut );
+     else printf("\t eta_{e} < %3.2f\n", fEtaCut );
+   printf("\t p_{T,e} > %3.2f\n", fSinglePtCut );
+   printf("\t TPC refit \n");
+   printf("\t no kinks \n");
+   printf("\t accept: %3.2f < n sigma_{e,TPC} < %3.2f\n", fPIDnSigmaBelowElectronLine, fPIDnSigmaAboveElectronLine );
+   printf("\t reject: %3.2f < p_{e,T} < %3.2f, n sigma_{pi,TPC} < %3.2f\n", fPIDMinPnSigmaAbovePionLine, fPIDMaxPnSigmaAbovePionLine, fPIDnSigmaAbovePionLine );
+   printf("\t reject: p_{e,T} > %3.2f, n sigma_{pi,TPC} < %3.2f\n", fPIDMaxPnSigmaAbovePionLine, fPIDnSigmaAbovePionLineHighPt );
+   if (fDoPionRejectionLowP) printf("\t reject: p_{e,T} < %3.2f, -%3.2f < n sigma_{pi,TPC} < %3.2f\n", fPIDMinPPionRejectionLowP, fPIDnSigmaAtLowPAroundPionLine, fPIDnSigmaAtLowPAroundPionLine );
+   if (fDoKaonRejectionLowP) printf("\t reject: -%3.2f < n sigma_{K,TPC} < %3.2f\n", fPIDnSigmaAtLowPAroundKaonLine, fPIDnSigmaAtLowPAroundKaonLine );
+   if (fDoProtonRejectionLowP) printf("\t reject: -%3.2f < n sigma_{K,TPC} < %3.2f\n", fPIDnSigmaAtLowPAroundProtonLine, fPIDnSigmaAtLowPAroundProtonLine );
+   if (fUseTOFpid) printf("\t accept: %3.2f < n sigma_{e,TOF} < %3.2f\n", fTofPIDnSigmaBelowElectronLine, fTofPIDnSigmaAboveElectronLine);
+   
+   printf("Photon cuts: \n");
+   if (fUseOnFlyV0Finder) printf("\t using Onfly V0 finder \n");
+   else printf("\t using Offline V0 finder \n");
+   if (fDo2DQt){
+         printf("\t 2 dimensional q_{T} cut applied with maximum of %3.2f \n", fQtMax );
+   } else {
+         printf("\t 1 dimensional q_{T} cut applied with maximum of %3.2f \n", fQtMax );
+   }
+   if (fDo2DPsiPairChi2){
+         printf("\t 2 dimensional triangle chi^{2} and psi_{pair} cut applied with maximum of chi^{2} = %3.2f and |psi_{pair}| = %3.2f \n", fChi2CutConversion, fPsiPairCut ); 
+   } else {
+      printf("\t chi^{2} max cut chi^{2} < %3.2f \n", fChi2CutConversion ); 
+         printf("\t psi_{pair} max cut |psi_{pair}| < %3.2f \n", fPsiPairCut ); 
+   }         
+   printf("\t %3.2f < R_{conv} < %3.2f\n", fMinR, fMaxR );
+   printf("\t Z_{conv} < %3.2f\n", fMaxZ );
+   if (fEtaCutMin > -0.1) printf("\t %3.2f < eta_{conv} < %3.2f\n", fEtaCutMin, fEtaCut );
+     else printf("\t eta_{conv} < %3.2f\n", fEtaCut );
+   if (fDoPhotonAsymmetryCut) printf("\t for p_{T,track} > %3.2f,  A_{gamma} < %3.2f \n", fMinPPhotonAsymmetryCut, fMinPhotonAsymmetry  );
+   if (fUseCorrectedTPCClsInfo) printf("\t #cluster TPC/ #findable clusters TPC (corrected for radius) > %3.2f\n", fMinClsTPCToF );
+   printf("\t p_{T,gamma} > %3.2f\n", fPtCut );         
+   printf("\t cos(Theta_{point}) > %3.2f \n", fCosPAngleCut );
+   printf("\t dca_{R} < %3.2f \n", fDCARPrimVtxCut );
+   printf("\t dca_{Z} < %3.2f \n", fDCAZPrimVtxCut );
+   if (fDoPhotonQualitySelectionCut) printf("\t selection based on photon quality with quality %d \n", fPhotonQualityCut );
+}
+
 ///________________________________________________________________________
 Bool_t AliConversionCuts::SetIsHeavyIon(Int_t isHeavyIon)
 {   // Set Cut
@@ -2058,7 +2245,7 @@ Bool_t AliConversionCuts::SetCentralityMax(Int_t maxCentrality)
    return kTRUE;
 }
 ///________________________________________________________________________
-Int_t AliConversionCuts::SetSelectSpecialTrigger(Int_t selectSpecialTrigger)
+Bool_t AliConversionCuts::SetSelectSpecialTrigger(Int_t selectSpecialTrigger)
 {// Set Cut
 
    switch(selectSpecialTrigger){
@@ -2074,37 +2261,300 @@ Int_t AliConversionCuts::SetSelectSpecialTrigger(Int_t selectSpecialTrigger)
    case 3:
       fSpecialTrigger=3; // V0AND plus with SDD requested
       break;
-   // allows to run MB & 6 other different trigger classes in parallel with the same photon cut   
-   case 4: 
-      fSpecialTrigger=4; // different trigger class as MB
+   // allows to run MB & 6 other different trigger classes in parallel with the same photon cut
+   case 4:
+      fSpecialTrigger=4; // trigger alias kTRD 
+      fOfflineTriggerMask=AliVEvent::kTRD;
       fTriggerSelectedManually = kTRUE;
+         fSpecialTriggerName="AliVEvent::kTRD";
       break;
-   case 5: 
-      fSpecialTrigger=4; // different trigger class as MB
+   case 5:
+      fSpecialTrigger=5; // trigger alias kEMC
+      fOfflineTriggerMask=AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMC1 ;
       fTriggerSelectedManually = kTRUE;
+         fSpecialTriggerName="AliVEvent::kEMC7/kEMC8/kEMC1";
       break;
-   case 6: 
-      fSpecialTrigger=4; // different trigger class as MB
+   case 6:
+      fSpecialTrigger=6; // trigger alias kPHI
+      fOfflineTriggerMask=AliVEvent::kPHI7 | AliVEvent::kPHI1 | AliVEvent::kPHI8 | AliVEvent::kPHOSPb;
       fTriggerSelectedManually = kTRUE;
+         fSpecialTriggerName="AliVEvent::kPHI7/kPHI1/kPHI8/kPHOSPb";
       break;
-   case 7: 
-      fSpecialTrigger=4; // different trigger class as MB
+   case 7:
+      fSpecialTrigger=7; // trigger alias kHighMult
+      fOfflineTriggerMask=AliVEvent::kHighMult;
       fTriggerSelectedManually = kTRUE;
+         fSpecialTriggerName="AliVEvent::kHighMult";
       break;
-    case 8: 
-      fSpecialTrigger=4; // different trigger class as MB
+    case 8:
+      fSpecialTrigger=8; // trigger alias kEMCEGA
+      fOfflineTriggerMask=AliVEvent::kEMCEGA;
       fTriggerSelectedManually = kTRUE;
-      break;  
-    case 9: 
-      fSpecialTrigger=4; // different trigger class as MB
+         fSpecialTriggerName="AliVEvent::kEMCEGA";
+      break;
+    case 9:
+      fSpecialTrigger=9; // trigger alias kEMCEJE
+      fOfflineTriggerMask=AliVEvent::kEMCEJE;
       fTriggerSelectedManually = kTRUE;
-      break;    
+         fSpecialTriggerName="AliVEvent::kEMCEJE";
+      break;
    default:
       AliError("Warning: Special Trigger Not known");
-      return kFALSE;
+      return 0;
    }
-   return kTRUE;
+   return 1;
+}
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetSelectSubTriggerClass(Int_t selectSpecialSubTriggerClass)
+{// Set Cut
+
+       if (fSpecialTrigger == 1){ //V0AND with different detectors
+               switch(selectSpecialSubTriggerClass){
+               case 0: //with VZERO
+                       fSpecialTrigger=1;
+                       fSpecialSubTrigger=0; 
+//                     AliInfo("Info: Nothing to be done");
+                       break;
+               case 1: //with TZERO
+                       fSpecialTrigger=0;
+                       fSpecialSubTrigger=0; 
+                       fOfflineTriggerMask=AliVEvent::kINT8;
+                       fTriggerSelectedManually = kTRUE;
+                       fSpecialTriggerName="AliVEvent::kINT8";
+                       break;
+               default:
+                       AliError("Warning: Special Subtrigger Class Not known");
+                       return 0;
+               }       
+                       
+       } else if (fSpecialTrigger == 4){ // Subdivision of TRD trigger classes
+               switch(selectSpecialSubTriggerClass){
+               case 0: // all together
+                       fSpecialSubTrigger=0; 
+                       fSpecialSubTriggerName="";
+//                     AliInfo("Info: Nothing to be done");
+                       break;
+               case 1: // 7WUHSH - V0AND with single electron in TRD & EMCAL
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="7WUHEE";
+                       break;
+               case 2: // 8WUHSH - T0AND with single electron in TRD & EMCAL
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="8WUHEE";
+                       break;
+               case 3: // 7WUHSE - V0AND with single high pt electron in TRD
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="7WUHSE";
+                       break;
+               case 4: // 8WUHSE - T0AND with single high pt electron in TRD
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="8WUHSE";
+                       break;
+               case 5: // 7WUHJE - V0AND with jet in TRD
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="7WUHJT";
+                       break;
+               case 6: // 8WUHJE - T0AND with jet in TRD
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="8WUHJT";
+                       break;
+               case 7: // 7WUHQU - V0AND with dielectron pair in TRD
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="7WUHQU";
+                       break;
+               case 8: // 8WUHQU - T0AND with dielectron pair in TRD
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="8WUHQU";
+                       break;
+               default:
+                       AliError("Warning: Special Subtrigger Class Not known");
+                       return 0;
+               }                  
+       } else if (fSpecialTrigger == 5){ // Subdivision of kEMC trigger classes
+               switch(selectSpecialSubTriggerClass){
+               case 0: // all together
+                       fSpecialSubTrigger=0; 
+                       fSpecialSubTriggerName="";
+//                     AliInfo("Info: Nothing to be done");
+                       break;
+               case 1: // CEMC1 - V0OR and EMCAL fired
+                       fOfflineTriggerMask=AliVEvent::kEMC1;
+                       fSpecialTriggerName="AliVEvent::kEMC1";
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="CEMC1";
+                       break;
+               case 2: // CEMC7 - V0AND and EMCAL fired 
+                       fSpecialSubTrigger=1; 
+                       fOfflineTriggerMask=AliVEvent::kEMC7;
+                       fSpecialTriggerName="AliVEvent::kEMC7";
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="CEMC7";
+                       break;
+               case 3: // CEMC8  - T0OR and EMCAL fired
+                       fOfflineTriggerMask=AliVEvent::kEMC8;
+                       fSpecialTriggerName="AliVEvent::kEMC8";
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="CEMC8";
+                       break;
+               default:
+                       AliError("Warning: Special Subtrigger Class Not known");
+                       return 0;
+               }                  
+       }  else if (fSpecialTrigger == 6){ // Subdivision of kPHI trigger classes
+               switch(selectSpecialSubTriggerClass){
+               case 0: // all together
+                       fSpecialSubTrigger=0; 
+                       fSpecialSubTriggerName="";
+//                     AliInfo("Info: Nothing to be done");
+                       break;
+               case 1: // CEMC1 - V0OR and EMCAL fired
+                       fOfflineTriggerMask=AliVEvent::kPHI1;
+                       fSpecialTriggerName="AliVEvent::kPHI1";
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="CPHI1";
+                       break;
+               case 2: // CEMC7 - V0AND and EMCAL fired 
+                       fSpecialSubTrigger=1; 
+                       fOfflineTriggerMask=AliVEvent::kPHI7;
+                       fSpecialTriggerName="AliVEvent::kPHI7";
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="CPHI7";
+                       break;
+               case 3: // CEMC8  - T0OR and EMCAL fired
+                       fOfflineTriggerMask=AliVEvent::kPHI8;
+                       fSpecialTriggerName="AliVEvent::kPHI8";
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="CPHI8";
+                       break;
+               default:
+                       AliError("Warning: Special Subtrigger Class Not known");
+                       return 0;
+               }                  
+       } else if (fSpecialTrigger == 7){ // Subdivision of kHighMult trigger classes
+               switch(selectSpecialSubTriggerClass){
+               case 0: // all together
+                       fSpecialSubTrigger=0; 
+                       fSpecialSubTriggerName="";
+//                     AliInfo("Info: Nothing to be done");
+                       break;
+               case 1: // CSHM1 - V0OR and high mult fired
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="CSHM1";
+                       break;
+               case 2: // CSHM7 - V0AND and high mult fired 
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="CSHM7";
+                       break;
+               case 3: // CSHM8  - T0OR and high mult fired
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="CSHM8";
+                       break;
+               default:
+                       AliError("Warning: Special Subtrigger Class Not known");
+                       return 0;
+               }                  
+       }  else if (fSpecialTrigger == 8){ // Subdivision of kEMCEGA trigger classes
+               switch(selectSpecialSubTriggerClass){
+               case 0: // all together
+                       fSpecialSubTrigger=0; 
+                       fSpecialSubTriggerName="";
+//                     AliInfo("Info: Nothing to be done");
+                       break;
+               case 1: // 7EGA - CINT7 EGA
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="7EGA";
+                       break;
+               case 2: // 8EGA - CINT8 EGA
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="8EGA";
+                       break;
+               case 3: // 7EG1 - CINT7 EG1
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="7EG1";
+                       break;
+               case 4: // 8EG1 - CINT8 EG1
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="8EG1";
+                       break;
+               case 5: // 7EG2 - CINT7 EG2
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="7EG2";
+                       break;
+               case 6: // 8EG2 - CINT8 EG2
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="8EG2";
+                       break;
+               default:
+                       AliError("Warning: Special Subtrigger Class Not known");
+                       return 0;
+               }                  
+       } else if (fSpecialTrigger == 9){ // Subdivision of kEMCEGA trigger classes
+               switch(selectSpecialSubTriggerClass){
+               case 0: // all together
+                       fSpecialSubTrigger=0; 
+                       fSpecialSubTriggerName="";
+//                     AliInfo("Info: Nothing to be done");
+                       break;
+               case 1: // 7EJE - CINT7 EJE
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="7EJE";
+                       break;
+               case 2: // 8EJE - CINT8 EJE
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="8EJE";
+                       break;
+               case 3: // 7EJ1 - CINT7 EJ1
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="7EJ1";
+                       break;
+               case 4: // 8EJ1 - CINT8 EJ1
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="8EJ1";
+                       break;
+               case 5: // 7EJ2 - CINT7 EJ2
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="7EJ2";
+                       break;
+               case 6: // 8EJ2 - CINT8 EJ2
+                       fSpecialSubTrigger=1; 
+                       fNSpecialSubTriggerOptions=1;
+                       fSpecialSubTriggerName="8EJ2";
+                       break;
+               default:
+                       AliError("Warning: Special Subtrigger Class Not known");
+                       return 0;
+               }                  
+       }
+       return 1;
 }
+
 ///________________________________________________________________________
 Bool_t AliConversionCuts::SetMultiplicityMethod(Int_t multiplicityMethod)
 {
@@ -2189,7 +2639,7 @@ Bool_t AliConversionCuts::SetEtaCut(Int_t etaCut)
       fEtaCutMin     = -0.1;
       fLineCutZRSlopeMin = 0.;
       break;
-   case 1:  // 1.2  // changed from 1.2 to 0.6 on 2013.06.10
+   case 1:  // 0.6  // changed from 1.2 to 0.6 on 2013.06.10
       fEtaCut     = 0.6;
       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
       fEtaCutMin     = -0.1;
@@ -2201,8 +2651,8 @@ Bool_t AliConversionCuts::SetEtaCut(Int_t etaCut)
       fEtaCutMin     = -0.1;
       fLineCutZRSlopeMin = 0.;
       break;
-   case 3: // 0.8
-      fEtaCut     = 0.8;
+   case 3: // 0.65
+      fEtaCut     = 0.65;
       fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
       fEtaCutMin     = -0.1;
       fLineCutZRSlopeMin = 0.;
@@ -2226,11 +2676,19 @@ Bool_t AliConversionCuts::SetEtaCut(Int_t etaCut)
       fLineCutZRSlopeMin = 0.;
       break;
    case 7:
-      fEtaCut     = 0.3;
-      fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
-      fEtaCutMin     = -0.1;
-      fLineCutZRSlopeMin = 0.;
-      break;
+      if (fIsHeavyIon==1){
+         fEtaCut     = 0.7;
+         fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
+         fEtaCutMin     = -0.1;
+         fLineCutZRSlopeMin = 0.;
+         break;
+      } else {   
+         fEtaCut     = 0.3;
+         fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
+         fEtaCutMin     = -0.1;
+         fLineCutZRSlopeMin = 0.;
+         break;
+      }
    // case 8: // 0.1 - 0.8
    //    fEtaCut     = 0.9;
    //    fLineCutZRSlope = tan(2*atan(exp(-fEtaCut)));
@@ -2279,7 +2737,6 @@ Bool_t AliConversionCuts::SetRCut(Int_t RCut){
       fMaxR = 70.;
       fMinR = 5.;
       break;
-      // High purity cuts for PbPb (remove first layers of material)
    case 5:
       fMaxR = 180.;
       fMinR = 10.;
@@ -2290,15 +2747,15 @@ Bool_t AliConversionCuts::SetRCut(Int_t RCut){
       break;
    case 7:
       fMaxR = 180.;
-      fMinR = 26.;
+      fMinR = 35.; //old 26.
       break;
    case 8:
       fMaxR = 180.;
-      fMinR = 35.;
+      fMinR = 12.5;
       break;
    case 9:
-      fMaxR = 35.;
-      fMinR = 5.;
+      fMaxR = 180.;
+      fMinR = 7.5;
       break;
 
    default:
@@ -2675,52 +3132,44 @@ Bool_t AliConversionCuts::SetQtMaxCut(Int_t QtMaxCut)
    case 0: //
       fQtMax=1.;
       fDoQtGammaSelection=kFALSE;
-      fDoHighPtQtGammaSelection=kFALSE;
-      fHighPtQtMax=100.;
-      fPtBorderForQt=100.;
+      fDo2DQt=kFALSE;
       break;
    case 1:
       fQtMax=0.1;
-      fDoHighPtQtGammaSelection=kFALSE;
-      fHighPtQtMax=100.;
-      fPtBorderForQt=100.;
+      fDo2DQt=kFALSE;
       break;
    case 2:
       fQtMax=0.07;
-      fDoHighPtQtGammaSelection=kFALSE;
-      fHighPtQtMax=100.;
-      fPtBorderForQt=100.;
+      fDo2DQt=kFALSE;
       break;
    case 3:
       fQtMax=0.05;
-      fDoHighPtQtGammaSelection=kFALSE;
-      fHighPtQtMax=100.;
-      fPtBorderForQt=100.;
+      fDo2DQt=kFALSE;
       break;
    case 4:
       fQtMax=0.03;
-      fDoHighPtQtGammaSelection=kFALSE;
-      fHighPtQtMax=100.;
-      fPtBorderForQt=100.;
+      fDo2DQt=kFALSE;
       break;
    case 5:
       fQtMax=0.02;
-      fDoHighPtQtGammaSelection=kFALSE;
-      fHighPtQtMax=100.;
-      fPtBorderForQt=100.;
+      fDo2DQt=kFALSE;
       break;
    case 6:
       fQtMax=0.02;
-      fDoHighPtQtGammaSelection=kTRUE;
-      fHighPtQtMax=0.06;
-      fPtBorderForQt=2.5;
+      fDo2DQt=kTRUE;
       break;
    case 7:
       fQtMax=0.15;
-      fDoHighPtQtGammaSelection=kFALSE;
-      fHighPtQtMax=100.;
-      fPtBorderForQt=100.;
+      fDo2DQt=kFALSE;
       break;
+   case 8:
+      fQtMax=0.05;
+      fDo2DQt=kTRUE;
+      break;   
+   case 9:
+      fQtMax=0.03;
+      fDo2DQt=kTRUE;
+      break;      
    default:
       AliError(Form("Warning: QtMaxCut not defined %d",QtMaxCut));
       return kFALSE;
@@ -2785,19 +3234,23 @@ Bool_t AliConversionCuts::SetPsiPairCut(Int_t psiCut) {
       fPsiPairCut = 0.035; //
       break;
    case 4:
-      fPsiPairCut = 0.15; //
-      break;
-   case 5:
       fPsiPairCut = 0.2; //
+      break;   
+   case 5:
+      fPsiPairCut = 0.1; //
+      fDo2DPsiPairChi2 = kTRUE;
       break;
    case 6:
-      fPsiPairCut = 0.03; //
+      fPsiPairCut = 0.05; //
+      fDo2DPsiPairChi2 = kTRUE;
       break;
    case 7:
-      fPsiPairCut = 0.025; //
+      fPsiPairCut = 0.035; //
+      fDo2DPsiPairChi2 = kTRUE;
       break;
    case 8:
-      fPsiPairCut = 0.01; //
+      fPsiPairCut = 0.2; //
+      fDo2DPsiPairChi2 = kTRUE; //
       break;
    case 9:
       fPsiPairCut = 0.5; //
@@ -2828,6 +3281,11 @@ Bool_t AliConversionCuts::SetPhotonAsymmetryCut(Int_t doPhotonAsymmetryCut){
       fMinPPhotonAsymmetryCut=3.5;
       fMinPhotonAsymmetry=0.06;
       break;
+   case 3:
+      fDoPhotonAsymmetryCut=1;
+      fMinPPhotonAsymmetryCut=0.0;
+      fMinPhotonAsymmetry=0.05;
+      break; 
    default:
       AliError(Form("PhotonAsymmetryCut not defined %d",doPhotonAsymmetryCut));
       return kFALSE;
@@ -2840,28 +3298,28 @@ Bool_t AliConversionCuts::SetCosPAngleCut(Int_t cosCut) {
 
    switch(cosCut){
    case 0:
-      fCosPAngleCut = TMath::Pi(); // -1
+      fCosPAngleCut = -1; 
       break;
    case 1:
-      fCosPAngleCut = 0.1; // 0.99500
+      fCosPAngleCut = 0; 
       break;
    case 2:
-      fCosPAngleCut = 0.05; // 0.99875
+      fCosPAngleCut = 0.5; 
       break;
    case 3:
-      fCosPAngleCut = 0.025; // 0.99969
+      fCosPAngleCut = 0.75; 
       break;
    case 4:
-      fCosPAngleCut = 0.01; // 0.99995
+      fCosPAngleCut = 0.85; 
       break;
    case 5:
-      fCosPAngleCut = 0.2; // 0.98007
+      fCosPAngleCut = 0.88; 
       break;
    case 6:
-      fCosPAngleCut = 0.5; // 0.87758
+      fCosPAngleCut = 0.9;
       break;
    case 7:
-      fCosPAngleCut = 0.075; // 0.73169
+      fCosPAngleCut = 0.95;
       break;
    default:
       AliError(Form("Cosine Pointing Angle cut not defined %d",cosCut));
@@ -2873,16 +3331,35 @@ Bool_t AliConversionCuts::SetCosPAngleCut(Int_t cosCut) {
 ///________________________________________________________________________
 Bool_t AliConversionCuts::SetSharedElectronCut(Int_t sharedElec) {
 
-   switch(sharedElec){
-   case 0:
-      fDoSharedElecCut = kFALSE;
-      break;
-   case 1:
-      fDoSharedElecCut = kTRUE;
-      break;
-   default:
-      AliError(Form("Shared Electron Cut not defined %d",sharedElec));
-      return kFALSE;
+       switch(sharedElec){
+       case 0:
+               fDoSharedElecCut = kFALSE;
+               fDoPhotonQualitySelectionCut = kFALSE;
+               fPhotonQualityCut = 0;
+               break;
+       case 1:
+               fDoSharedElecCut = kTRUE;
+               fDoPhotonQualitySelectionCut = kFALSE;
+               fPhotonQualityCut = 0;
+               break;
+       case 2:
+               fDoSharedElecCut = kFALSE;
+               fDoPhotonQualitySelectionCut = kTRUE;
+               fPhotonQualityCut = 1;
+               break;
+       case 3:
+               fDoSharedElecCut = kFALSE;
+               fDoPhotonQualitySelectionCut = kTRUE;     
+               fPhotonQualityCut = 2;
+               break;
+       case 4:
+               fDoSharedElecCut = kFALSE;
+               fDoPhotonQualitySelectionCut = kTRUE;     
+               fPhotonQualityCut = 3;
+               break;
+       default:
+               AliError(Form("Shared Electron Cut not defined %d",sharedElec));        
+               return kFALSE;
    }
 
    return kTRUE;
@@ -2941,11 +3418,11 @@ Bool_t AliConversionCuts::SetTRDElectronCut(Int_t TRDElectronCut)
 }
 
 ///________________________________________________________________________
-Bool_t AliConversionCuts::SetDCAZPhotonPrimVtxCut(Int_t DCAZPhotonPrimVtx){ 
+Bool_t AliConversionCuts::SetDCAZPhotonPrimVtxCut(Int_t DCAZPhotonPrimVtx){
    // Set Cut
    switch(DCAZPhotonPrimVtx){
    case 0:  //
-      fDCAZPrimVtxCut   = 1000; 
+      fDCAZPrimVtxCut   = 1000;
       break;
    case 1:  //
       fDCAZPrimVtxCut   = 10;
@@ -2982,11 +3459,11 @@ Bool_t AliConversionCuts::SetDCAZPhotonPrimVtxCut(Int_t DCAZPhotonPrimVtx){
 }
 
 ///________________________________________________________________________
-Bool_t AliConversionCuts::SetDCARPhotonPrimVtxCut(Int_t DCARPhotonPrimVtx){ 
+Bool_t AliConversionCuts::SetDCARPhotonPrimVtxCut(Int_t DCARPhotonPrimVtx){
    // Set Cut
    switch(DCARPhotonPrimVtx){
    case 0:  //
-      fDCARPrimVtxCut   = 1000; 
+      fDCARPrimVtxCut   = 1000;
       break;
    case 1:  //
       fDCARPrimVtxCut   = 10;
@@ -3022,6 +3499,26 @@ Bool_t AliConversionCuts::SetDCARPhotonPrimVtxCut(Int_t DCARPhotonPrimVtx){
    return kTRUE;
 }
 
+///________________________________________________________________________
+Bool_t AliConversionCuts::SetInPlaneOutOfPlane(Int_t inOutPlane){
+   // Set Cut
+   switch(inOutPlane){
+   case 0:  //
+      fInPlaneOutOfPlane = 0; // No Event Plane
+      break;
+   case 1:  //
+      fInPlaneOutOfPlane = 1; // In-Plane
+      break;
+   case 2:  //
+      fInPlaneOutOfPlane = 2; // Out-Of-Plane
+      break;
+   default:
+      cout<<"Warning: In-Plane or Out-Of-Plane not defined "<<inOutPlane<<endl;
+      return kFALSE;
+   }
+   return kTRUE;
+}
+
 
 //-------------------------------------------------------------
 Double_t AliConversionCuts::GetCentrality(AliVEvent *event)
@@ -3045,7 +3542,7 @@ Double_t AliConversionCuts::GetCentrality(AliVEvent *event)
 
    AliAODEvent *aodEvent=dynamic_cast<AliAODEvent*>(event);
    if(aodEvent){
-      if(aodEvent->GetHeader()){return aodEvent->GetHeader()->GetCentrality();}
+     if(aodEvent->GetHeader()){return ((AliVAODHeader*)aodEvent->GetHeader())->GetCentrality();}
    }
 
    return -1;
@@ -3057,7 +3554,7 @@ Bool_t AliConversionCuts::IsCentralitySelected(AliVEvent *event, AliVEvent *fMCE
 
    if(fCentralityMin == fCentralityMax ) return kTRUE;//0-100%
    else if(fCentralityMax==0) fCentralityMax=10; //CentralityRange = fCentralityMin-100%
-         
+
    Double_t centrality=GetCentrality(event);
    if(centrality<0)return kFALSE;
 
@@ -3080,52 +3577,51 @@ Bool_t AliConversionCuts::IsCentralitySelected(AliVEvent *event, AliVEvent *fMCE
          return kTRUE;
       else return kFALSE;
    }
-   
+
    Int_t nprimaryTracks = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask("V0ReaderV1"))->GetNumberOfPrimaryTracks();
-   Int_t PrimaryTracks10[10][2] = 
+   Int_t PrimaryTracks10[10][2] =
       {
          {9999,9999}, //  0
-         {1210,2150}, // 10
-         { 817,1435}, // 20
-         { 536, 930}, // 30
-         { 337, 570}, // 40
-         { 197, 327}, // 50
-         { 106, 173}, // 60
-         {  51,  81}, // 70
-         {  21,  34}, // 80
+         {1210, 928}, // 10
+         { 817, 658}, // 20
+         { 536, 435}, // 30
+         { 337, 276}, // 40
+         { 197, 162}, // 50
+         { 106, 100}, // 60
+         {  51,  44}, // 70
+         {  21,  18}, // 80
          {   0,   0}  // 90
       };
-   Int_t PrimaryTracks5a[10][2] = 
+   Int_t PrimaryTracks5a[10][2] =
       {
          {9999,9999}, // 0
-         {1485,2640}, // 5
-         {1210,2150}, // 10
-         { 995,1760}, // 15
-         { 817,1435}, // 20
-         { 666,1160}, // 25
-         { 536, 930}, // 30
-         { 428, 731}, // 35
-         { 337, 570}, // 40
-         { 260, 436}  // 45
+         {1485,1168}, // 5
+         {1210, 928}, // 10
+         { 995, 795}, // 15
+         { 817, 658}, // 20
+         { 666, 538}, // 25
+         { 536, 435}, // 30
+         { 428, 350}, // 35
+         { 337, 276}, // 40
+         { 260, 214}  // 45
       };
-   Int_t PrimaryTracks5b[10][2] = 
+   Int_t PrimaryTracks5b[10][2] =
       {
-         { 260, 436}, // 45
-         { 197, 327}, // 50
-         { 147, 239}, // 55
-         { 106, 173}, // 60
-         {  75, 120}, // 65
-         {  51,  81}, // 70
-         {  34,  53}, // 75
-         {  21,  34}, // 80
-         {  13,  19}, // 85
+         { 260, 214}, // 45
+         { 197, 162}, // 50
+         { 147, 125}, // 55
+         { 106, 100}, // 60
+         {  75,  63}, // 65
+         {  51,  44}, // 70
+         {  34,  29}, // 75
+         {  21,  18}, // 80
+         {  13,  11}, // 85
          {   0,   0}  // 90
       };
-
-   Int_t column = -1;
+   Int_t column = 0;
    if(event->IsA()==AliESDEvent::Class()) column = 0;
    if(event->IsA()==AliAODEvent::Class()) column = 1;
-      
+
    if (fModCentralityClass == 3){
       if(fMCEvent){
          if(nprimaryTracks > PrimaryTracks10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracks10[fCentralityMin][column])
@@ -3172,13 +3668,27 @@ Bool_t AliConversionCuts::IsCentralitySelected(AliVEvent *event, AliVEvent *fMCE
 Bool_t AliConversionCuts::VertexZCut(AliVEvent *event){
    // Cut on z position of primary vertex
    Double_t fVertexZ=event->GetPrimaryVertex()->GetZ();
-
+   Double_t fVertexZSPD = 0;
+   AliESDEvent *fESDEvent=dynamic_cast<AliESDEvent*>(event);
+   if(fESDEvent){
+      fVertexZSPD = fESDEvent->GetPrimaryVertexSPD()->GetZ();
+   } 
+   AliAODEvent *fAODEvent=dynamic_cast<AliAODEvent*>(event);
+   if(fAODEvent){
+      fVertexZSPD = fAODEvent->GetPrimaryVertexSPD()->GetZ();
+   }
+  
    if(abs(fVertexZ)>fMaxVertexZ)return kFALSE;
 
+   TString periodName = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()
+                                                ->GetTask("V0ReaderV1"))->GetPeriodName();
+   if (periodName.CompareTo("LHC11h")==0){
+     if (abs(fVertexZ-fVertexZSPD) > 0.1) return kFALSE;
+   }                                           
    if (fIsHeavyIon == 2){
      if(fUtils->IsFirstEventInChunk(event)) return kFALSE;
      if(!fUtils->IsVertexSelected2013pA(event)) return kFALSE;
-
+     if(fUtils->IsPileUpEvent(event)) return kFALSE;
    }
 
    return kTRUE;
@@ -3234,122 +3744,161 @@ Int_t AliConversionCuts::GetNumberOfContributorsVtx(AliVEvent *event){
 Bool_t AliConversionCuts::IsTriggerSelected(AliVEvent *fInputEvent)
 {
 
-   AliInputEventHandler *fInputHandler=(AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
-
-   UInt_t isSelected = AliVEvent::kAny;
-   if (fInputHandler==NULL) return kFALSE;
-   if( fInputHandler->GetEventSelection() || fInputEvent->IsA()==AliAODEvent::Class()) {
-      if (!fTriggerSelectedManually){
-         if (fPreSelCut) fOfflineTriggerMask = AliVEvent::kAny;
-         else {
-            if (fIsHeavyIon == 1) fOfflineTriggerMask = AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral;
-               else if (fIsHeavyIon == 2) fOfflineTriggerMask = AliVEvent::kINT7;
-               else fOfflineTriggerMask = AliVEvent::kMB;
-         } 
-      }
-      // Get the actual offline trigger mask for the event and AND it with the
-      // requested mask. If no mask requested select by default the event.
-//       if (fPreSelCut) cout << "Trigger selected from outside: "<< fTriggerSelectedManually <<"\t Offline Trigger mask for Precut: " << fOfflineTriggerMask << endl;
-//       else cout << "Trigger selected from outside: "<< fTriggerSelectedManually <<"\t Offline Trigger mask: " << fOfflineTriggerMask << endl;
-      
-      if (fOfflineTriggerMask)
-         isSelected = fOfflineTriggerMask & fInputHandler->IsEventSelected();
-   }
-   fIsSDDFired = !(fInputHandler->IsEventSelected() & AliVEvent::kFastOnly);
-
-   // Fill Histogram
-   if(hTriggerClass){
-      if (fIsSDDFired) hTriggerClass->Fill(33);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClass->Fill(0);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClass->Fill(1);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClass->Fill(2);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClass->Fill(3);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClass->Fill(4);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClass->Fill(5);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClass->Fill(6);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClass->Fill(6);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClass->Fill(7);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClass->Fill(7);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClass->Fill(8);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClass->Fill(8);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClass->Fill(9);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClass->Fill(9);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClass->Fill(10);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClass->Fill(10);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClass->Fill(11);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClass->Fill(12);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClass->Fill(13);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClass->Fill(13);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClass->Fill(13);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClass->Fill(14);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClass->Fill(15);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClass->Fill(16);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClass->Fill(17);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClass->Fill(18);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClass->Fill(19);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClass->Fill(20);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClass->Fill(20);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClass->Fill(21);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClass->Fill(22);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClass->Fill(23);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClass->Fill(24);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClass->Fill(25);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClass->Fill(26);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClass->Fill(27);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClass->Fill(28);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClass->Fill(29);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClass->Fill(30);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClass->Fill(31);
-      if (!fInputHandler->IsEventSelected()) hTriggerClass->Fill(34);
-   }
-
-   if(hTriggerClassSelected && isSelected){
-      if (!fIsSDDFired) hTriggerClassSelected->Fill(33);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassSelected->Fill(0);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassSelected->Fill(1);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClassSelected->Fill(2);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClassSelected->Fill(3);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassSelected->Fill(4);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClassSelected->Fill(5);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClassSelected->Fill(6);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClassSelected->Fill(6);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClassSelected->Fill(7);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClassSelected->Fill(7);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClassSelected->Fill(8);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClassSelected->Fill(8);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClassSelected->Fill(9);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClassSelected->Fill(9);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClassSelected->Fill(10);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClassSelected->Fill(10);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClassSelected->Fill(11);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClassSelected->Fill(12);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClassSelected->Fill(13);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClassSelected->Fill(13);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClassSelected->Fill(13);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClassSelected->Fill(14);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClassSelected->Fill(15);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClassSelected->Fill(16);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClassSelected->Fill(17);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClassSelected->Fill(18);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClassSelected->Fill(19);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClassSelected->Fill(20);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClassSelected->Fill(20);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClassSelected->Fill(21);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClassSelected->Fill(22);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClassSelected->Fill(23);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClassSelected->Fill(24);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClassSelected->Fill(25);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClassSelected->Fill(26);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClassSelected->Fill(27);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClassSelected->Fill(28);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClassSelected->Fill(29);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClassSelected->Fill(30);
-      if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClassSelected->Fill(31);
-   }
-
-   if(!isSelected)return kFALSE;
-
-   return kTRUE;
+       AliInputEventHandler *fInputHandler=(AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
+//     AliTRDTriggerAnalysis *trdSelection=  new AliTRDTriggerAnalysis();
+//     trdSelection->CalcTriggers(fInputEvent);
+       
+       UInt_t isSelected = AliVEvent::kAny;
+       TString periodName = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask("V0ReaderV1"))->GetPeriodName();
+       //    cout <<   periodName.Data() << endl;
+       
+       if (fInputHandler==NULL) return kFALSE;
+       if( fInputHandler->GetEventSelection() || fInputEvent->IsA()==AliAODEvent::Class()) {
+       
+               TString firedTrigClass = fInputEvent->GetFiredTriggerClasses();  
+               if (!fTriggerSelectedManually){
+                       if (fPreSelCut) fOfflineTriggerMask = AliVEvent::kAny;
+                       else {
+                               if (fIsHeavyIon == 1) fOfflineTriggerMask = AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral;
+                               else if (fIsHeavyIon == 2) fOfflineTriggerMask = AliVEvent::kINT7;
+                               else if (periodName.CompareTo("LHC11c") == 0 || periodName.CompareTo("LHC11d") == 0 || periodName.CompareTo("LHC11e") == 0 || periodName.CompareTo("LHC11f") == 0 || periodName.CompareTo("LHC11g") == 0  || periodName.CompareTo("LHC12a") == 0 || periodName.CompareTo("LHC12b") == 0 || periodName.CompareTo("LHC12c") == 0 || periodName.CompareTo("LHC12d") == 0 || periodName.CompareTo("LHC12f") == 0  || periodName.CompareTo("LHC12g") == 0  || periodName.CompareTo("LHC12h") == 0  || periodName.CompareTo("LHC12i") == 0  ||periodName.CompareTo("LHC13g") == 0 ) {
+                                       fOfflineTriggerMask = AliVEvent::kINT7;      
+       //                              cout << "will take kINT7 as trigger mask" << endl; 
+                               }       
+                               else fOfflineTriggerMask = AliVEvent::kMB;
+                       }
+               }
+               // Get the actual offline trigger mask for the event and AND it with the
+               // requested mask. If no mask requested select by default the event.
+       //       if (fPreSelCut) cout << "Trigger selected from outside: "<< fTriggerSelectedManually <<"\t Offline Trigger mask for Precut: " << fOfflineTriggerMask << endl;
+       //       else cout << "Trigger selected from outside: "<< fTriggerSelectedManually <<"\t Offline Trigger mask: " << fOfflineTriggerMask << endl;
+
+               if (fOfflineTriggerMask){
+                       isSelected = fOfflineTriggerMask & fInputHandler->IsEventSelected();             
+                       if (isSelected && !fPreSelCut){
+//                             if (fSpecialTriggerName.Contains("kTRD")){ // make special selection for TRD trigger
+//                                     Bool_t bTRDHasFiredConfirmed= 0; // bool whether the TRD has triggered and has been read out due to that trigger & should have triggered
+//                                     Bool_t bTRDClassContainedInTriggerList= 1; //check whether the trigger list contains the requested trigger
+//                                     if (fSpecialSubTrigger>0){
+//                                             if (fSpecialSubTriggerName.Contains("HSE")){
+//                                                     bTRDHasFiredConfirmed = trdSelection->HasTriggeredConfirmed(AliTRDTriggerAnalysis::kHSE);
+//                                             } else if (fSpecialSubTriggerName.Contains("HJT")){
+//                                                     bTRDHasFiredConfirmed = trdSelection->HasTriggeredConfirmed(AliTRDTriggerAnalysis::kHJT);
+//                                             } else if (fSpecialSubTriggerName.Contains("HEE")){
+//                                                     bTRDHasFiredConfirmed = trdSelection->HasTriggeredConfirmed(AliTRDTriggerAnalysis::kHEE);
+//                                             } else if (fSpecialSubTriggerName.Contains("HQU")){     
+//                                                     bTRDHasFiredConfirmed = trdSelection->HasTriggeredConfirmed(AliTRDTriggerAnalysis::kHQU);
+//                                             }
+//                                             if (!firedTrigClass.Contains(fSpecialSubTriggerName.Data())) bTRDClassContainedInTriggerList = 0;
+//                                     } else {
+//                                             bTRDHasFiredConfirmed = trdSelection->HasTriggeredConfirmed(AliTRDTriggerAnalysis::kHQU)  || trdSelection->HasTriggeredConfirmed(AliTRDTriggerAnalysis::kHSE) || trdSelection->HasTriggeredConfirmed(AliTRDTriggerAnalysis::kHJT) || trdSelection->HasTriggeredConfirmed(AliTRDTriggerAnalysis::kHEE);
+//                                     }       
+//                                     if (!bTRDHasFiredConfirmed || !bTRDClassContainedInTriggerList)  isSelected = 0;                                                                        
+//                             } else { // more general condition for all other sub-triggers
+//                                     if (fSpecialTriggerName.Contains("kEMCE"))cout << fSpecialTriggerName.Data() << "\t" <<fSpecialSubTriggerName.Data()<< endl;
+                                       if (fSpecialSubTrigger>0){
+                                               if (!firedTrigClass.Contains(fSpecialSubTriggerName.Data())) isSelected = 0;
+                                       }        
+//                                     if (fSpecialTriggerName.Contains("kEMCE"))cout <<firedTrigClass << endl;
+//                             }
+                       }                               
+               }        
+       }
+       fIsSDDFired = !(fInputHandler->IsEventSelected() & AliVEvent::kFastOnly);
+
+       // Fill Histogram
+       if(hTriggerClass){
+               if (fIsSDDFired) hTriggerClass->Fill(33);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClass->Fill(0);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClass->Fill(1);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClass->Fill(2);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClass->Fill(3);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClass->Fill(4);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClass->Fill(5);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClass->Fill(6);
+       //       if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClass->Fill(6);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClass->Fill(7);
+       //       if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClass->Fill(7);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClass->Fill(8);
+       //       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClass->Fill(8);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClass->Fill(9);
+       //       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClass->Fill(9);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClass->Fill(10);
+       //       if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClass->Fill(10);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClass->Fill(11);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClass->Fill(12);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClass->Fill(13);
+       //       if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClass->Fill(13);
+       //       if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClass->Fill(13);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClass->Fill(14);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClass->Fill(15);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClass->Fill(16);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClass->Fill(17);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClass->Fill(18);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClass->Fill(19);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClass->Fill(20);
+       //       if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClass->Fill(20);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClass->Fill(21);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClass->Fill(22);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClass->Fill(23);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClass->Fill(24);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClass->Fill(25);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClass->Fill(26);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClass->Fill(27);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClass->Fill(28);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClass->Fill(29);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClass->Fill(30);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClass->Fill(31);
+               if (!fInputHandler->IsEventSelected()) hTriggerClass->Fill(34);
+       }
+
+       if(hTriggerClassSelected && isSelected){
+               if (!fIsSDDFired) hTriggerClassSelected->Fill(33);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassSelected->Fill(0);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassSelected->Fill(1);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClassSelected->Fill(2);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClassSelected->Fill(3);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassSelected->Fill(4);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClassSelected->Fill(5);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClassSelected->Fill(6);
+       //       if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClassSelected->Fill(6);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClassSelected->Fill(7);
+       //       if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClassSelected->Fill(7);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClassSelected->Fill(8);
+       //       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClassSelected->Fill(8);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClassSelected->Fill(9);
+       //       if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClassSelected->Fill(9);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClassSelected->Fill(10);
+       //       if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClassSelected->Fill(10);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClassSelected->Fill(11);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClassSelected->Fill(12);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClassSelected->Fill(13);
+       //       if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClassSelected->Fill(13);
+       //       if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClassSelected->Fill(13);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClassSelected->Fill(14);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClassSelected->Fill(15);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClassSelected->Fill(16);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClassSelected->Fill(17);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClassSelected->Fill(18);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClassSelected->Fill(19);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClassSelected->Fill(20);
+       //       if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClassSelected->Fill(20);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClassSelected->Fill(21);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClassSelected->Fill(22);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClassSelected->Fill(23);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClassSelected->Fill(24);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClassSelected->Fill(25);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClassSelected->Fill(26);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClassSelected->Fill(27);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClassSelected->Fill(28);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClassSelected->Fill(29);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClassSelected->Fill(30);
+               if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClassSelected->Fill(31);
+       }
+
+       if(!isSelected)return kFALSE;
+
+       return kTRUE;
 
 }
 
@@ -3385,7 +3934,7 @@ Int_t AliConversionCuts::GetFirstTPCRow(Double_t radius){
 
 Bool_t AliConversionCuts::CosinePAngleCut(const AliConversionPhotonBase * photon, AliVEvent * event) const {
    ///Check if passes cosine of pointing angle cut
-   if(GetCosineOfPointingAngle(photon, event) < (TMath::Cos(fCosPAngleCut))){
+   if(GetCosineOfPointingAngle(photon, event) < fCosPAngleCut){
       return kFALSE;
    }
    return kTRUE;
@@ -3427,10 +3976,17 @@ Double_t AliConversionCuts::GetCosineOfPointingAngle( const AliConversionPhotonB
 ///________________________________________________________________________
 Bool_t AliConversionCuts::PsiPairCut(const AliConversionPhotonBase * photon) const {
 
-   if(photon->GetPsiPair() > fPsiPairCut){
-      return kFALSE;}
-   else{return kTRUE;}
-
+   if (fDo2DPsiPairChi2){
+      if (abs(photon->GetPsiPair()) < -fPsiPairCut/fChi2CutConversion*photon->GetChi2perNDF() + fPsiPairCut ){  
+         return kTRUE;
+      } else {
+         return kFALSE;
+      }    
+   } else {
+      if(abs(photon->GetPsiPair()) > fPsiPairCut){
+         return kFALSE;}
+      else{return kTRUE;}
+   } 
 }
 
 ///________________________________________________________________________
@@ -3498,171 +4054,290 @@ Bool_t AliConversionCuts::RejectToCloseV0s(AliAODConversionPhoton* photon, TList
 ///________________________________________________________________________
 void AliConversionCuts::GetNotRejectedParticles(Int_t rejection, TList *HeaderList, AliVEvent *MCEvent){
 
-
-
-   if(fNotRejectedStart){
-      delete[] fNotRejectedStart;
-      fNotRejectedStart = NULL;
-   }
-   if(fNotRejectedEnd){
-      delete[] fNotRejectedEnd;
-      fNotRejectedEnd = NULL;
-   }
-   if(fGeneratorNames){
-      delete[] fGeneratorNames;
-      fGeneratorNames = NULL;
-   }
-
-   if(rejection == 0) return; // No Rejection
-
-   AliGenCocktailEventHeader *cHeader = 0x0;
-   AliAODMCHeader *cHeaderAOD = 0x0;
-   Bool_t headerFound = kFALSE;
-
-   if(MCEvent->IsA()==AliMCEvent::Class()){
-      cHeader = dynamic_cast<AliGenCocktailEventHeader*>(dynamic_cast<AliMCEvent*>(MCEvent)->GenEventHeader());
-      if(cHeader) headerFound = kTRUE;
-   }
-   if(MCEvent->IsA()==AliAODEvent::Class()){ // MCEvent is a AODEvent in case of AOD
-      cHeaderAOD = dynamic_cast<AliAODMCHeader*>(MCEvent->FindListObject(AliAODMCHeader::StdBranchName()));
-      if(cHeaderAOD) headerFound = kTRUE;
-   }
-      
-   if(headerFound){
-      TList *genHeaders = 0x0;
-      if(cHeader) genHeaders = cHeader->GetHeaders();
-      if(cHeaderAOD){
-         genHeaders = cHeaderAOD->GetCocktailHeaders();
-         if(genHeaders->GetEntries()==1){
-            SetRejectExtraSignalsCut(0);
-            return;
-         }
-      }
-      AliGenEventHeader* gh = 0;
-      fnHeaders = 0;
-      if(rejection == 1 || rejection == 3) fnHeaders = 1; // MinBiasHeader
-      if(rejection == 2){ // TList of Headers Names
-         for(Int_t i = 0; i<genHeaders->GetEntries();i++){
-            gh = (AliGenEventHeader*)genHeaders->At(i);
-            TString GeneratorName = gh->GetName();
-            for(Int_t j = 0; j<HeaderList->GetEntries();j++){
-               TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
-               if(GeneratorName.CompareTo(GeneratorInList) == 0){
-                  fnHeaders++;
-                  continue;
-               }
-            }
-         }
-      }
-
-      fNotRejectedStart = new Int_t[fnHeaders];
-      fNotRejectedEnd = new Int_t[fnHeaders];
-      fGeneratorNames = new TString[fnHeaders];
-
-      if(rejection == 1 || rejection == 3){
-         fNotRejectedStart[0] = 0;
-         fNotRejectedEnd[0] = ((AliGenEventHeader*)genHeaders->At(0))->NProduced()-1;
-         fGeneratorNames[0] = ((AliGenEventHeader*)genHeaders->At(0))->GetName();
-         return;
-      }
-
-      Int_t firstindex = 0;
-      Int_t lastindex =  -1;
-      Int_t nummer = 0;
-      for(Int_t i = 0; i<genHeaders->GetEntries();i++){
-         gh = (AliGenEventHeader*)genHeaders->At(i);
-         TString GeneratorName = gh->GetName();
-         lastindex = lastindex + gh->NProduced();
-         for(Int_t j = 0; j<HeaderList->GetEntries();j++){
-            TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
-            if(GeneratorName.CompareTo(GeneratorInList) == 0){
-               fNotRejectedStart[nummer] = firstindex;
-               fNotRejectedEnd[nummer] = lastindex;
-               fGeneratorNames[nummer] = GeneratorName;
-               //cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
-               nummer++;
-               continue;
-            }
-         }
-         firstindex = firstindex + gh->NProduced();
-      }
-   } else { // No Cocktail Header Found
-      fNotRejectedStart = new Int_t[1];
-      fNotRejectedEnd = new Int_t[1];
-
-      fnHeaders = 1;
-      fNotRejectedStart[0] = 0;
-      fNotRejectedEnd[0] = static_cast<AliMCEvent*>(MCEvent)->Stack()->GetNprimary()-1;
-      fGeneratorNames = new TString[1];
-      fGeneratorNames[0] = "NoCocktailGeneratorFound";
-
-      AliGenPythiaEventHeader *mcHeaderPythia = dynamic_cast<AliGenPythiaEventHeader*>(static_cast<AliMCEvent*>(MCEvent)->GenEventHeader());
-      if (mcHeaderPythia) fGeneratorNames[0] = "NoCocktailGeneratorFound_Pythia";
-      AliGenDPMjetEventHeader *mcHeaderPhojet = dynamic_cast<AliGenDPMjetEventHeader*>(static_cast<AliMCEvent*>(MCEvent)->GenEventHeader());
-      if (mcHeaderPhojet) fGeneratorNames[0] = "NoCocktailGeneratorFound_Phojet";
-      AliGenHijingEventHeader *mcHeaderHijing = dynamic_cast<AliGenHijingEventHeader*>(static_cast<AliMCEvent*>(MCEvent)->GenEventHeader());
-      if (mcHeaderHijing) fGeneratorNames[0] = "NoCocktailGeneratorFound_Hijing";
-
-      SetRejectExtraSignalsCut(0);
-   }
-
+       TString periodName = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask("V0ReaderV1"))->GetPeriodName();
+
+
+       if(fNotRejectedStart){
+               delete[] fNotRejectedStart;
+               fNotRejectedStart = NULL;
+       }
+       if(fNotRejectedEnd){
+               delete[] fNotRejectedEnd;
+               fNotRejectedEnd = NULL;
+       }
+       if(fGeneratorNames){
+               delete[] fGeneratorNames;
+               fGeneratorNames = NULL;
+       }
+
+       if(rejection == 0) return; // No Rejection
+
+       AliGenCocktailEventHeader *cHeader = 0x0;
+       AliAODMCHeader *cHeaderAOD = 0x0;
+       Bool_t headerFound = kFALSE;
+       AliStack *fMCStack = 0x0;
+       TClonesArray *fMCStackAOD = 0x0;
+       if(MCEvent->IsA()==AliMCEvent::Class()){
+               cHeader = dynamic_cast<AliGenCocktailEventHeader*>(dynamic_cast<AliMCEvent*>(MCEvent)->GenEventHeader());
+               if(cHeader) headerFound = kTRUE;
+               if(dynamic_cast<AliMCEvent*>(MCEvent))fMCStack = dynamic_cast<AliStack*>(dynamic_cast<AliMCEvent*>(MCEvent)->Stack());
+       }
+       if(MCEvent->IsA()==AliAODEvent::Class()){ // MCEvent is a AODEvent in case of AOD
+               cHeaderAOD = dynamic_cast<AliAODMCHeader*>(MCEvent->FindListObject(AliAODMCHeader::StdBranchName()));
+               fMCStackAOD = dynamic_cast<TClonesArray*>(MCEvent->FindListObject(AliAODMCParticle::StdBranchName()));
+               
+               
+               if(cHeaderAOD) headerFound = kTRUE;
+       }
+
+       if(headerFound){
+               TList *genHeaders = 0x0;
+               if(cHeader) genHeaders = cHeader->GetHeaders();
+               if(cHeaderAOD){
+                       genHeaders = cHeaderAOD->GetCocktailHeaders();
+                       if(genHeaders->GetEntries()==1){
+                               SetRejectExtraSignalsCut(0);
+                               return;
+                       }
+               }
+               AliGenEventHeader* gh = 0;
+               fnHeaders = 0;
+               Int_t firstindexA = 0;
+               Int_t lastindexA =  -1;
+               if(rejection == 1 || rejection == 3) fnHeaders = 1; // MinBiasHeader
+               if(rejection == 2){ // TList of Headers Names
+                       for(Int_t i = 0; i<genHeaders->GetEntries();i++){
+                               gh = (AliGenEventHeader*)genHeaders->At(i);
+                               TString GeneratorName = gh->GetName();
+                               lastindexA = lastindexA + gh->NProduced();
+//                             cout << i << "\t" << GeneratorName.Data() << endl;
+                               for(Int_t j = 0; j<HeaderList->GetEntries();j++){
+                                       TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
+                                       if(GeneratorName.CompareTo(GeneratorInList) == 0){
+                                               if (GeneratorInList.CompareTo("PARAM") == 0 || GeneratorInList.CompareTo("BOX") == 0 ){
+                                                       if(fMCStack){
+                                                               if (fMCStack->Particle(firstindexA)->GetPdgCode() == fAddedSignalPDGCode ) {
+                                                                       if (periodName.CompareTo("LHC14a1b")==0 || periodName.CompareTo("LHC14a1c")==0 ){
+                                                                               if (gh->NProduced() > 10 && fMCStack->Particle(firstindexA+10)->GetPdgCode() == fAddedSignalPDGCode ){
+//                                                                                     cout << "cond 1: "<< fnHeaders << endl;
+                                                                                       fnHeaders++;
+                                                                                       continue;
+                                                                               }       
+                                                                               continue;
+                                                                       } else {
+//                                                                             cout << "cond 2: " << fnHeaders << endl;
+                                                                               fnHeaders++;
+                                                                               continue;
+                                                                       }       
+                                                               }
+                                                       }   
+                                                       if ( fMCStackAOD){
+                                                               AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCStackAOD->At(firstindexA));
+                                                               if (  aodMCParticle->GetPdgCode() == fAddedSignalPDGCode ){
+                                                                       if (periodName.CompareTo("LHC14a1b")==0 || periodName.CompareTo("LHC14a1c")==0 ){
+                                                                               if (gh->NProduced() > 10){
+                                                                                       AliAODMCParticle *aodMCParticle2 = static_cast<AliAODMCParticle*>(fMCStackAOD->At(firstindexA+10));
+                                                                                       if (  aodMCParticle2->GetPdgCode() == fAddedSignalPDGCode ){
+//                                                                                             cout << "cond 1: " << fnHeaders << endl;
+                                                                                               fnHeaders++;
+                                                                                               continue;
+                                                                                       } 
+                                                                               }       
+                                                                               continue;
+                                                                       } else {
+//                                                                             cout << "cond 2: " << fnHeaders << endl;
+                                                                               fnHeaders++;
+                                                                               continue;
+                                                                       }       
+                                                               }   
+                                                       }
+                                                       continue;
+                                               }
+//                                             cout << "cond 3: "<< fnHeaders << endl;
+                                               fnHeaders++;
+                                               continue;
+                                       }
+                               }
+                               firstindexA = firstindexA + gh->NProduced();
+                       }
+               }
+//             cout << "number of headers: " <<fnHeaders << endl;
+               
+               fNotRejectedStart = new Int_t[fnHeaders];
+               fNotRejectedEnd = new Int_t[fnHeaders];
+               fGeneratorNames = new TString[fnHeaders];
+
+               if(rejection == 1 || rejection == 3){
+                       fNotRejectedStart[0] = 0;
+                       fNotRejectedEnd[0] = ((AliGenEventHeader*)genHeaders->At(0))->NProduced()-1;
+                       fGeneratorNames[0] = ((AliGenEventHeader*)genHeaders->At(0))->GetName();
+                       return;
+               }
+
+               Int_t firstindex = 0;
+               Int_t lastindex =  -1;
+               Int_t number = 0;
+               
+               for(Int_t i = 0; i<genHeaders->GetEntries();i++){
+                       gh = (AliGenEventHeader*)genHeaders->At(i);
+                       TString GeneratorName = gh->GetName();
+                       lastindex = lastindex + gh->NProduced();
+                       for(Int_t j = 0; j<HeaderList->GetEntries();j++){
+                               TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
+//                             cout << i << "\t" << GeneratorName.Data() << endl;
+                               if(GeneratorName.CompareTo(GeneratorInList) == 0){
+                                       if (GeneratorInList.CompareTo("PARAM") == 0 || GeneratorInList.CompareTo("BOX") == 0 ){
+                                               if(fMCStack){
+                                                       if (fMCStack->Particle(firstindex)->GetPdgCode() == fAddedSignalPDGCode ) {
+                                                               if (periodName.CompareTo("LHC14a1b")==0 || periodName.CompareTo("LHC14a1c")==0 ){
+//                                                                     cout << "produced " << gh->NProduced() << " with box generator" << endl;
+                                                                       if (gh->NProduced() > 10 && fMCStack->Particle(firstindex+10)->GetPdgCode() == fAddedSignalPDGCode){
+//                                                                             cout << "one of them was a pi0 or eta" <<  endl;
+                                                                               fNotRejectedStart[number] = firstindex;
+                                                                               fNotRejectedEnd[number] = lastindex;
+                                                                               fGeneratorNames[number] = GeneratorName;
+                                                                               number++;
+//                                                                             cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
+                                                                               continue;
+                                                                       }       
+                                                               } else {
+                                                                       fNotRejectedStart[number] = firstindex;
+                                                                       fNotRejectedEnd[number] = lastindex;
+                                                                       fGeneratorNames[number] = GeneratorName;
+                                                                       number++;
+                                                                       continue;
+                                                               }       
+                                                       }
+                                               }   
+                                               if ( fMCStackAOD){
+                                                       AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCStackAOD->At(firstindex));
+                                                       if (  aodMCParticle->GetPdgCode() == fAddedSignalPDGCode ){
+                                                               if (periodName.CompareTo("LHC14a1b")==0 || periodName.CompareTo("LHC14a1c")==0 ){
+                                                                       if (gh->NProduced() > 10) {
+                                                                               AliAODMCParticle *aodMCParticle2 = static_cast<AliAODMCParticle*>(fMCStackAOD->At(firstindex+10));
+                                                                               if ( aodMCParticle2->GetPdgCode() == fAddedSignalPDGCode ){
+                                                                                       fNotRejectedEnd[number] = lastindex;
+                                                                                       fNotRejectedStart[number] = firstindex;
+                                                                                       fGeneratorNames[number] = GeneratorName;
+                                                                                       number++;
+                                                                       } 
+                                                                                       continue;
+                                                                               }
+                                                               } else {
+                                                                       fNotRejectedStart[number] = firstindex;
+                                                                       fNotRejectedEnd[number] = lastindex;
+                                                                       fGeneratorNames[number] = GeneratorName;
+                                                                       number++;
+                                                                       continue;       
+                                                               }       
+                                                       }   
+                                               }
+                                               continue;
+                                       } else {
+                                               fNotRejectedStart[number] = firstindex;
+                                               fNotRejectedEnd[number] = lastindex;
+                                               fGeneratorNames[number] = GeneratorName;
+//                                             cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
+                                               number++;
+                                               continue;
+                                       }
+                                       
+                               }
+                       }
+                       firstindex = firstindex + gh->NProduced();
+               }
+//             for (Int_t i = 0; i < number; i++){
+//                     cout << i << "\t" <<fGeneratorNames[i] << "\t" << fNotRejectedStart[i] << "\t" <<fNotRejectedEnd[i] << endl;
+//             }       
+       
+       } else { // No Cocktail Header Found
+               fNotRejectedStart = new Int_t[1];
+               fNotRejectedEnd = new Int_t[1];
+
+               fnHeaders = 1;
+               fNotRejectedStart[0] = 0;
+               fNotRejectedEnd[0] = static_cast<AliMCEvent*>(MCEvent)->Stack()->GetNprimary()-1;
+               fGeneratorNames = new TString[1];
+               fGeneratorNames[0] = "NoCocktailGeneratorFound";
+
+               AliGenPythiaEventHeader *mcHeaderPythia = dynamic_cast<AliGenPythiaEventHeader*>(static_cast<AliMCEvent*>(MCEvent)->GenEventHeader());
+               if (mcHeaderPythia) fGeneratorNames[0] = "NoCocktailGeneratorFound_Pythia";
+               AliGenDPMjetEventHeader *mcHeaderPhojet = dynamic_cast<AliGenDPMjetEventHeader*>(static_cast<AliMCEvent*>(MCEvent)->GenEventHeader());
+               if (mcHeaderPhojet) fGeneratorNames[0] = "NoCocktailGeneratorFound_Phojet";
+               AliGenHijingEventHeader *mcHeaderHijing = dynamic_cast<AliGenHijingEventHeader*>(static_cast<AliMCEvent*>(MCEvent)->GenEventHeader());
+               if (mcHeaderHijing) fGeneratorNames[0] = "NoCocktailGeneratorFound_Hijing";
+
+               SetRejectExtraSignalsCut(0);
+       }
+       
 }
+
 //_________________________________________________________________________
 Int_t AliConversionCuts::IsParticleFromBGEvent(Int_t index, AliStack *MCStack, AliVEvent *InputEvent){
 
-   // Not Accepted == kFALSE == 0
-   //     Accepted ==  kTRUE == 1
-   //  FirstHeader ==  kTRUE == 3
-   if(index < 0) return 0; // No Particle
-
-   Int_t accepted = 0;
-   if(!InputEvent || InputEvent->IsA()==AliESDEvent::Class()){
-      if( index >= MCStack->GetNprimary()){ // Secondary Particle
-         if( ((TParticle*)MCStack->Particle(index))->GetMother(0) < 0) return 1; // Secondary Particle without Mother??
-         return IsParticleFromBGEvent(((TParticle*)MCStack->Particle(index))->GetMother(0),MCStack,InputEvent);
-      }
-      for(Int_t i = 0;i<fnHeaders;i++){
-         if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
-            accepted = 1;
-            if(i == 0) accepted = 2; // MB Header
-         }
-      }
-   }
-   else if(InputEvent->IsA()==AliAODEvent::Class()){
-      TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(InputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
-      AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index));
-      if(!aodMCParticle) return 1; // Photon Without a Mother ? --> Accepted
-      if(!aodMCParticle->IsPrimary()){
-         if( aodMCParticle->GetMother() < 0) return 1;// Secondary Particle without Mother??
-         return IsParticleFromBGEvent(aodMCParticle->GetMother(),MCStack,InputEvent);
-      }
-      index = abs(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index))->GetLabel());
-      for(Int_t i = 0;i<fnHeaders;i++){
-         if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
-            accepted = 1;
-            if(i == 0) accepted = 2; // MB Header
-         }
-      }
-   }
-
-   return accepted;
+       // Not Accepted == kFALSE == 0
+       //     Accepted ==  kTRUE == 1
+       //  FirstHeader ==  kTRUE == 3
+       if(index < 0) return 0; // No Particle
+
+//     if (index == 100){
+//             cout << "possible headers" << endl;
+//             for(Int_t i = 0;i<fnHeaders;i++){
+//                     cout << i << "\t" <<fGeneratorNames[i] << "\t" << fNotRejectedStart[i] << "\t" <<fNotRejectedEnd[i] << endl;
+//             }
+//     }       
+       Int_t accepted = 0;
+       if(!InputEvent || InputEvent->IsA()==AliESDEvent::Class()){
+               if( index >= MCStack->GetNprimary()){ // Secondary Particle
+                       if( ((TParticle*)MCStack->Particle(index))->GetMother(0) < 0) return 1; // Secondary Particle without Mother??
+                       return IsParticleFromBGEvent(((TParticle*)MCStack->Particle(index))->GetMother(0),MCStack,InputEvent);
+               }
+               for(Int_t i = 0;i<fnHeaders;i++){
+                       if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
+                               accepted = 1;
+                               if(i == 0) accepted = 2; // MB Header
+                       }
+               }
+       }
+       else if(InputEvent->IsA()==AliAODEvent::Class()){
+               TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(InputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
+               if (AODMCTrackArray){
+                       AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index));
+                       if(!aodMCParticle) return 1; // Photon Without a Mother ? --> Accepted
+                       if(!aodMCParticle->IsPrimary()){
+                               if( aodMCParticle->GetMother() < 0) return 1;// Secondary Particle without Mother??
+                               return IsParticleFromBGEvent(aodMCParticle->GetMother(),MCStack,InputEvent);
+                       }
+                       index = abs(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index))->GetLabel());
+                       for(Int_t i = 0;i<fnHeaders;i++){
+                               if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
+                                       accepted = 1;
+                                       if(i == 0) accepted = 2; // MB Header
+                               }
+                       }
+               }       
+       }
+
+       return accepted;
 }
+
 //_________________________________________________________________________
-Int_t AliConversionCuts::IsEventAcceptedByConversionCut(AliConversionCuts *ReaderCuts, AliVEvent *InputEvent, AliMCEvent *MCEvent, Bool_t isHeavyIon){
+Int_t AliConversionCuts::IsEventAcceptedByConversionCut(AliConversionCuts *ReaderCuts, AliVEvent *InputEvent, AliMCEvent *MCEvent, Int_t isHeavyIon){
 
    if ( !IsTriggerSelected(InputEvent) )
       return 3;
-   
-   if(isHeavyIon && !(IsCentralitySelected(InputEvent,MCEvent)))
-      return 1; // Check Centrality --> Not Accepted => eventQuality = 1
 
-   if(!isHeavyIon && GetIsFromPileup()){
+   if(isHeavyIon != 0 && !(IsCentralitySelected(InputEvent,MCEvent)))
+      return 1; // Check Centrality --> Not Accepted => eventQuality = 1
+      
+      
+   if(isHeavyIon == 0 && GetIsFromPileup()){
       if(InputEvent->IsPileupFromSPD(3,0.8,3.,2.,5.)){
 
          return 6; // Check Pileup --> Not Accepted => eventQuality = 6
       }
    }
-   
+
    Bool_t hasV0And = ReaderCuts->HasV0AND();
    Bool_t isSDDFired = ReaderCuts->IsSDDFired();
    if( (IsSpecialTrigger() == 2 || IsSpecialTrigger() == 3) && !isSDDFired && !MCEvent)
@@ -3670,254 +4345,192 @@ Int_t AliConversionCuts::IsEventAcceptedByConversionCut(AliConversionCuts *Reade
 
    if( (IsSpecialTrigger() == 1 || IsSpecialTrigger() == 3) && !hasV0And)
       return 8; // V0AND requested but no fired
-   
+
+   if(hCentrality)hCentrality->Fill(GetCentrality(InputEvent));
+   if(hCentralityVsNumberOfPrimaryTracks)
+      hCentralityVsNumberOfPrimaryTracks->Fill(GetCentrality(InputEvent),
+                                             ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()
+                                                ->GetTask("V0ReaderV1"))->GetNumberOfPrimaryTracks());     
 
    return 0;
 }
+
 //_________________________________________________________________________
 Float_t AliConversionCuts::GetWeightForMeson(TString period, Int_t index, AliStack *MCStack, AliVEvent *InputEvent){
-   if (!(period.CompareTo("LHC12f1a") == 0 || period.CompareTo("LHC12f1b") == 0  || period.CompareTo("LHC12i3") == 0 || period.CompareTo("LHC11a10a") == 0 || period.CompareTo("LHC11a10b") == 0 || period.CompareTo("LHC11a10b_bis") == 0 || period.CompareTo("LHC11a10a_bis") == 0 || period.CompareTo("LHC11a10b_plus") == 0 || period.CompareTo("LHC13d2") == 0)) return 1.;
-   
-   Int_t kCaseGen = 0;
-   for (Int_t i = 0; i < fnHeaders; i++){
-      if (index >= fNotRejectedStart[i] && index < fNotRejectedEnd[i]+1){
-         if (fGeneratorNames[i].CompareTo("Pythia") == 0){
-            kCaseGen = 1;
-         } else if (fGeneratorNames[i].CompareTo("DPMJET") == 0){
-            kCaseGen = 2;
-         } else if (fGeneratorNames[i].CompareTo("HIJING") == 0 || 
-                    fGeneratorNames[i].CompareTo("Hijing") == 0 || 
-                    fGeneratorNames[i].Contains("hijing")){
-            kCaseGen = 3;
-         } else if (fGeneratorNames[i].CompareTo("BOX") == 0){
-             kCaseGen = 4;
-         } else if (fGeneratorNames[i].CompareTo("PARAM") == 0){
-            kCaseGen = 5;
-         } else if (fGeneratorNames[i].CompareTo("NoCocktailGeneratorFound") == 0){
-            kCaseGen = 6;
-         } else if (fGeneratorNames[i].CompareTo("NoCocktailGeneratorFound_Pythia") == 0){
-            kCaseGen = 1;
-         } else if (fGeneratorNames[i].CompareTo("NoCocktailGeneratorFound_Phojet") == 0){
-            kCaseGen = 2;
-         } else if (fGeneratorNames[i].CompareTo("NoCocktailGeneratorFound_Hijing") == 0){
-            kCaseGen = 3;
-         }
-         TString periodName = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()
-                                                ->GetTask("V0ReaderV1"))->GetPeriodName();
-                                                
-         if (periodName.Contains("LHC13d2")){
-            kCaseGen = 3; 
-         }
-      }
-   }
-   if (kCaseGen == 0) return 1;
-   
-
-   Double_t mesonPt = 0;
-   Double_t mesonMass = 0;
-   Int_t PDGCode = 0;
-   if(!InputEvent || InputEvent->IsA()==AliESDEvent::Class()){
-      mesonPt = ((TParticle*)MCStack->Particle(index))->Pt();
-      mesonMass = ((TParticle*)MCStack->Particle(index))->GetCalcMass();
-      PDGCode = ((TParticle*)MCStack->Particle(index))->GetPdgCode();
-   }
-   else if(InputEvent->IsA()==AliAODEvent::Class()){
-      TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(InputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
-      AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index));
-      mesonPt = aodMCParticle->Pt();
-      mesonMass = aodMCParticle->GetCalcMass();
-      PDGCode = aodMCParticle->GetPdgCode();
-   }   
-
-   Float_t functionResultMC = 1.;
-   if (kCaseGen == 1){ // Pythia 6
-      Float_t dNdyMC = 2.1462;
-      Float_t nMC = 7.06055;
-      Float_t tMC = 0.12533;
-      if ( PDGCode ==  111){
-         dNdyMC = 2.1462;
-         nMC = 7.06055;
-         tMC = 0.12533;
-      } else if ( PDGCode ==  221){
-         dNdyMC = 0.2357;
-         nMC = 5.9105;
-         tMC = 0.1525;
-      }
-      functionResultMC = dNdyMC / ( 2 * TMath::Pi())*(nMC-1.)*(nMC-2.) / (nMC*tMC*(nMC*tMC+mesonMass*(nMC-2.)))  * TMath::Power(1.+(TMath::Sqrt(mesonPt*mesonPt+mesonMass*mesonMass)-mesonMass)/(nMC*tMC), -nMC);
-   } else if (kCaseGen == 2){ // Phojet
-      Float_t dNdyMC = 2.35978;
-      Float_t nMC = 6.81795;
-      Float_t tMC = 0.11492;
-      if ( PDGCode ==  111){
-         dNdyMC = 2.35978;
-         nMC = 6.81795;
-         tMC = 0.11492;
-      } else if ( PDGCode ==  221){
-         dNdyMC = 0.3690;
-         nMC = 5.55809;
-         tMC = 0.13387;
-      }
-      functionResultMC = dNdyMC / ( 2 * TMath::Pi())*(nMC-1.)*(nMC-2.) / (nMC*tMC*(nMC*tMC+mesonMass*(nMC-2.)))  * TMath::Power(1.+(TMath::Sqrt(mesonPt*mesonPt+mesonMass*mesonMass)-mesonMass)/(nMC*tMC), -nMC);
-   } else if (kCaseGen == 4){ // BOX generators pp
-//       functionResultMC = 1./sqrt(1.-mesonMass*mesonMass/((mesonMass*mesonMass+mesonPt*mesonPt)*cosh(mesonY)*cosh(mesonY)));
-      Float_t a = 0.23437;
-      Float_t b = 5.6661;
-      Float_t c = -1430.5863;
-      Float_t d = -0.6966624;
-      Float_t e = 252.3742;
-      if ( PDGCode ==  111){
-         a = 0.23437;
-         b = 5.6661;
-         c = -1430.5863;
-         d = -0.6966624;
-         e = 252.3742;
-      } else if ( PDGCode ==  221){
-         a = 0.10399;
-         b = 4.35311;
-         c = -12.17723;
-         d = -0.01172;
-         e =1.85140;
-      }
-      functionResultMC = a*TMath::Power(mesonPt,-1.*(b+c/(TMath::Power(mesonPt,d)+e)))*1./mesonPt *1./1.6 *1./(2.* TMath::Pi());
-//       cout << functionResultMC << endl;
-   } else if (kCaseGen == 3 ){ // HIJING
-      if ( PDGCode ==  111 && fDoReweightHistoMCPi0 && hReweightMCHistPi0!= 0x0){
-         functionResultMC = hReweightMCHistPi0->Interpolate(mesonPt);
-      }
-      if ( PDGCode ==  221 && fDoReweightHistoMCEta && hReweightMCHistEta!= 0x0){
-         functionResultMC = hReweightMCHistEta->Interpolate(mesonPt);
-      }
-      if ( PDGCode ==  310 && fDoReweightHistoMCK0s && hReweightMCHistK0s!= 0x0){
-         functionResultMC = hReweightMCHistK0s->Interpolate(mesonPt);
-      }
-   }
-
-   Float_t functionResultData = 1;
-   if (kCaseGen == 1 || kCaseGen == 2 || kCaseGen == 4 ){
-      Float_t dNdyData = 2.2328;
-      Float_t nData = 7.1473;
-      Float_t tData = 0.1346;
-      if ( PDGCode ==  111){
-         dNdyData = 2.2328;
-         nData = 7.1473;
-         tData = 0.1346;
-      } else if ( PDGCode ==  221){
-         dNdyData = 0.38992; //be careful this fit is not optimal, eta in data still has problems
-         nData = 5.72778;
-         tData = 0.13835;
-      }
-      functionResultData = dNdyData / ( 2 * TMath::Pi())*(nData-1.)*(nData-2.) / (nData*tData*(nData*tData+mesonMass*(nData-2.)))  * TMath::Power(1.+(TMath::Sqrt(mesonPt*mesonPt+mesonMass*mesonMass)-mesonMass)/(nData*tData), -nData);
-//       cout << functionResultData << endl;
-   } else {
-      if ( PDGCode ==  111 && fDoReweightHistoMCPi0 && fFitDataPi0!= 0x0){
-         functionResultData = fFitDataPi0->Eval(mesonPt);
-      }
-      if ( PDGCode ==  221 && fDoReweightHistoMCEta && fFitDataEta!= 0x0){
-         functionResultData = fFitDataEta->Eval(mesonPt);
-      }
-      if ( PDGCode ==  310 && fDoReweightHistoMCK0s && fFitDataK0s!= 0x0){
-         functionResultData = fFitDataK0s->Eval(mesonPt);
-      }
-      
-//       Float_t a = 0.;
-//       Float_t b = 0.;
-//       Float_t c = 0.;
-//       Float_t d = 0.;
-//       Float_t e = 0.;
-//       if ( PDGCode ==  111 ){
-//          if (fModCentralityClass == 1 && fCentralityMin == 0 && fCentralityMax == 1 ){ // 0-5 % PbPb
-//             a = 25.8747458223;
-//             b = 5.8761820045;
-//             c = -33.9928191673;
-//             d = 3.0731850142;
-//             e = 13.2500447620;
-//          } else if (fModCentralityClass == 1 && fCentralityMin == 1 && fCentralityMax == 2){ // 5-10% PbPb
-//             a = 21.7518148922;
-//             b = 5.8441200081;
-//             c = -17.1497051691;
-//             d = 2.3799090842;
-//             e = 5.4346404718;
-//          } else if (fModCentralityClass == 0 && fCentralityMin == 0 && fCentralityMax == 1){ // 0-10% PbPb
-//             a = 22.9852133622;
-//             b = 5.8602063916;
-//             c = -17.0992478654;
-//             d = 2.4426218039;
-//             e = 5.1194526345;
-//          } else if (fModCentralityClass == 0 && fCentralityMin == 1 && fCentralityMax == 2){ // 10-20% PbPb
-//             a = 19.3237333776;
-//             b = 5.8145906958;
-//             c = -13.8316665424;
-//             d = 2.3737630637;
-//             e = 4.7690300693;
-//          } else if (fModCentralityClass == 0 && fCentralityMin == 2 && fCentralityMax == 4){ // 20-40% PbPb
-//             a = 11.2656032751;
-//             b = 5.8003194354;
-//             c = -13.3936105929;
-//             d = 2.3371452334;
-//             e = 4.4726244958;
-//          } else if (fModCentralityClass == 0 && fCentralityMin == 4 && fCentralityMax == 6){ // 40-60% PbPb   
-//             a = 4.1578154081;
-//             b = 5.6450005163;
-//             c = -8.4309375240;
-//             d = 1.8918308704;
-//             e = 2.9429194709;
-//          } else if (fModCentralityClass == 0 && fCentralityMin == 6 && fCentralityMax == 8){ // 60-80% PbPb      
-//             a = 1.0635443810;
-//             b = 5.1337469970;
-//             c = -8.5906997238;
-//             d = 2.9794995997;
-//             e = 3.9294980048;
-//          }  else if (fModCentralityClass == 0 && fCentralityMin == 0 && fCentralityMax == 2){ // 0-20% PbPb      
-//             a = 21.7018745556;
-//             b = 5.9019352094;
-//             c = -14.2295510326;
-//             d = 2.2104490688;
-//             e = 4.2969671500;
-//          }  else if (fModCentralityClass == 0 && fCentralityMin == 0 && fCentralityMax == 4){ // 0-40% PbPb      
-//             a = 16.8227412106;
-//             b = 5.8660502207;
-//             c = -12.0978551215;
-//             d = 2.1695068981;
-//             e = 3.5349621182;
-//          }   else if (fModCentralityClass == 0 && fCentralityMin == 0 && fCentralityMax == 8){ // 0-80% PbPb      
-//             a = 9.4675681080;
-//             b = 5.8114944205;
-//             c = -10.4901523616;
-//             d = 2.0607982712;
-//             e = 2.9262259130;
-//          }   else if (fModCentralityClass == 0 && fCentralityMin == 4 && fCentralityMax == 8){ // 60-80% PbPb      
-//             a = 2.5985551785;
-//             b = 5.4118895738;
-//             c = -8.2510958428;
-//             d = 2.2551249190;
-//             e = 3.0700919491;
-//          }
-//          
-//          functionResultData = a*TMath::Power(mesonPt,-1*(b+c/(TMath::Power(mesonPt,d)+e)));
-//       } 
-      
-   }
-   
-   Double_t weight = 1;
-   if (PDGCode ==  111 || PDGCode ==  221){
-      if (functionResultData != 0. && functionResultMC != 0. && isfinite(functionResultData) && isfinite(functionResultMC)){
-         weight = functionResultData/functionResultMC;
-         if ( kCaseGen == 3){
-            if (!(fDoReweightHistoMCPi0 && hReweightMCHistPi0!= 0x0 && PDGCode ==  111)){
-               weight = 1.;  
-            }
-         }
-         if (!isfinite(functionResultData)) weight = 1.;  
-         if (!isfinite(weight)) weight = 1.;  
-      }
-   } else if (PDGCode ==  310 && functionResultMC != 0 && isfinite(functionResultMC)){
-        weight = functionResultMC;
-   }
-      
-//    if (fModCentralityClass == 0 && fCentralityMin == 4 && fCentralityMax == 6 && PDGCode ==  111){
-//        cout << period.Data() << "\t" << kCaseGen << "\t" <<fModCentralityClass<< "\t" <<fCentralityMin<< "\t" <<fCentralityMax << "\t" << mesonPt << "\t" <<mesonMass<< "\t"<<functionResultData << "\t"<< functionResultMC << "\t" << weight <<endl;
-//    }
-   return weight;
+       if (!(period.CompareTo("LHC12f1a") == 0 || period.CompareTo("LHC12f1b") == 0  || period.CompareTo("LHC12i3") == 0 || period.CompareTo("LHC11a10a") == 0 || period.CompareTo("LHC11a10b") == 0 || period.CompareTo("LHC11a10b_bis") == 0 || period.CompareTo("LHC11a10a_bis") == 0 || period.CompareTo("LHC11a10b_plus") == 0 || period.Contains("LHC13d2")|| period.Contains("LHC14a1") || 
+       period.CompareTo("LHC13e7") == 0 || period.Contains("LHC13b2_efix") || period.CompareTo("LHC14b2") == 0 )) return 1.;
+
+       Int_t kCaseGen = 0;
+       for (Int_t i = 0; i < fnHeaders; i++){
+               if (index >= fNotRejectedStart[i] && index < fNotRejectedEnd[i]+1){
+                       if (fGeneratorNames[i].CompareTo("Pythia") == 0){
+                               kCaseGen = 1;
+                       } else if (fGeneratorNames[i].CompareTo("DPMJET") == 0){
+                               kCaseGen = 2;
+                       } else if (fGeneratorNames[i].CompareTo("HIJING") == 0 ||
+                                               fGeneratorNames[i].CompareTo("Hijing") == 0 ||
+                                               fGeneratorNames[i].Contains("hijing")){
+                               kCaseGen = 3;
+                       } else if (fGeneratorNames[i].CompareTo("BOX") == 0){
+                               kCaseGen = 4;
+                       } else if (fGeneratorNames[i].CompareTo("PARAM") == 0){
+                               kCaseGen = 5;
+                       } else if (fGeneratorNames[i].CompareTo("NoCocktailGeneratorFound") == 0){
+                               kCaseGen = 6;
+                       } else if (fGeneratorNames[i].CompareTo("NoCocktailGeneratorFound_Pythia") == 0){
+                               kCaseGen = 1;
+                       } else if (fGeneratorNames[i].CompareTo("NoCocktailGeneratorFound_Phojet") == 0){
+                               kCaseGen = 2;
+                       } else if (fGeneratorNames[i].CompareTo("NoCocktailGeneratorFound_Hijing") == 0){
+                               kCaseGen = 3;
+                       }
+                       if (period.Contains("LHC13d2") || period.CompareTo("LHC13e7") == 0 || period.Contains("LHC13b2_efix")  || period.Contains("LHC14a1") || period.CompareTo("LHC14b2") == 0 ){
+                               kCaseGen = 3;
+                       }
+               }
+       }
+       if (kCaseGen == 0) return 1;
+
+
+       Double_t mesonPt = 0;
+       Double_t mesonMass = 0;
+       Int_t PDGCode = 0;
+       if(!InputEvent || InputEvent->IsA()==AliESDEvent::Class()){
+               mesonPt = ((TParticle*)MCStack->Particle(index))->Pt();
+               mesonMass = ((TParticle*)MCStack->Particle(index))->GetCalcMass();
+               PDGCode = ((TParticle*)MCStack->Particle(index))->GetPdgCode();
+       }
+       else if(InputEvent->IsA()==AliAODEvent::Class()){
+               TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(InputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
+               if (AODMCTrackArray){
+                       AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index));
+                       mesonPt = aodMCParticle->Pt();
+                       mesonMass = aodMCParticle->GetCalcMass();
+                       PDGCode = aodMCParticle->GetPdgCode();
+               } else {
+                       return 1;
+               }       
+       }
+
+       Float_t functionResultMC = 1.;
+       if (kCaseGen == 1){ // Pythia 6
+               Float_t dNdyMC = 2.1462;
+               Float_t nMC = 7.06055;
+               Float_t tMC = 0.12533;
+               if ( PDGCode ==  111){
+                       dNdyMC = 2.1462;
+                       nMC = 7.06055;
+                       tMC = 0.12533;
+               } else if ( PDGCode ==  221){
+                       dNdyMC = 0.2357;
+                       nMC = 5.9105;
+                       tMC = 0.1525;
+               }
+               functionResultMC = dNdyMC / ( 2 * TMath::Pi())*(nMC-1.)*(nMC-2.) / (nMC*tMC*(nMC*tMC+mesonMass*(nMC-2.)))  * TMath::Power(1.+(TMath::Sqrt(mesonPt*mesonPt+mesonMass*mesonMass)-mesonMass)/(nMC*tMC), -nMC);
+       } else if (kCaseGen == 2){ // Phojet
+               Float_t dNdyMC = 2.35978;
+               Float_t nMC = 6.81795;
+               Float_t tMC = 0.11492;
+               if ( PDGCode ==  111){
+                       dNdyMC = 2.35978;
+                       nMC = 6.81795;
+                       tMC = 0.11492;
+               } else if ( PDGCode ==  221){
+                       dNdyMC = 0.3690;
+                       nMC = 5.55809;
+                       tMC = 0.13387;
+               }
+               functionResultMC = dNdyMC / ( 2 * TMath::Pi())*(nMC-1.)*(nMC-2.) / (nMC*tMC*(nMC*tMC+mesonMass*(nMC-2.)))  * TMath::Power(1.+(TMath::Sqrt(mesonPt*mesonPt+mesonMass*mesonMass)-mesonMass)/(nMC*tMC), -nMC);
+       } else if (kCaseGen == 4){ // BOX generators pp
+       //       functionResultMC = 1./sqrt(1.-mesonMass*mesonMass/((mesonMass*mesonMass+mesonPt*mesonPt)*cosh(mesonY)*cosh(mesonY)));
+               Float_t a = 0.23437;
+               Float_t b = 5.6661;
+               Float_t c = -1430.5863;
+               Float_t d = -0.6966624;
+               Float_t e = 252.3742;
+               if ( PDGCode ==  111){
+                       a = 0.23437;
+                       b = 5.6661;
+                       c = -1430.5863;
+                       d = -0.6966624;
+                       e = 252.3742;
+               } else if ( PDGCode ==  221){
+                       a = 0.10399;
+                       b = 4.35311;
+                       c = -12.17723;
+                       d = -0.01172;
+                       e =1.85140;
+               }
+               functionResultMC = a*TMath::Power(mesonPt,-1.*(b+c/(TMath::Power(mesonPt,d)+e)))*1./mesonPt *1./1.6 *1./(2.* TMath::Pi());
+       //       cout << functionResultMC << endl;
+       } else if (kCaseGen == 3 ){ // HIJING
+               if ( PDGCode ==  111 && fDoReweightHistoMCPi0 && hReweightMCHistPi0!= 0x0){
+                       functionResultMC = hReweightMCHistPi0->Interpolate(mesonPt);
+               }
+               if ( PDGCode ==  221 && fDoReweightHistoMCEta && hReweightMCHistEta!= 0x0){
+                       functionResultMC = hReweightMCHistEta->Interpolate(mesonPt);
+               }
+               if ( PDGCode ==  310 && fDoReweightHistoMCK0s && hReweightMCHistK0s!= 0x0){
+                       functionResultMC = hReweightMCHistK0s->Interpolate(mesonPt);
+               }
+       }
+
+       Float_t functionResultData = 1;
+       if (kCaseGen == 1 || kCaseGen == 2 || kCaseGen == 4 ){
+               Float_t dNdyData = 2.2328;
+               Float_t nData = 7.1473;
+               Float_t tData = 0.1346;
+               if ( PDGCode ==  111){
+                       dNdyData = 2.2328;
+                       nData = 7.1473;
+                       tData = 0.1346;
+               } else if ( PDGCode ==  221){
+                       dNdyData = 0.38992; //be careful this fit is not optimal, eta in data still has problems
+                       nData = 5.72778;
+                       tData = 0.13835;
+               }
+               functionResultData = dNdyData / ( 2 * TMath::Pi())*(nData-1.)*(nData-2.) / (nData*tData*(nData*tData+mesonMass*(nData-2.)))  * TMath::Power(1.+(TMath::Sqrt(mesonPt*mesonPt+mesonMass*mesonMass)-mesonMass)/(nData*tData), -nData);
+       //       cout << functionResultData << endl;
+       } else {
+               if ( PDGCode ==  111 && fDoReweightHistoMCPi0 && fFitDataPi0!= 0x0){
+                       functionResultData = fFitDataPi0->Eval(mesonPt);
+               }
+               if ( PDGCode ==  221 && fDoReweightHistoMCEta && fFitDataEta!= 0x0){
+                       functionResultData = fFitDataEta->Eval(mesonPt);
+               }
+               if ( PDGCode ==  310 && fDoReweightHistoMCK0s && fFitDataK0s!= 0x0){
+                       functionResultData = fFitDataK0s->Eval(mesonPt);
+               }
+
+       }
+
+       Double_t weight = 1;
+       if (PDGCode ==  111 || PDGCode ==  221){
+               if (functionResultData != 0. && functionResultMC != 0. && isfinite(functionResultData) && isfinite(functionResultMC)){
+                       weight = functionResultData/functionResultMC;
+                       if ( kCaseGen == 3){
+                               if (PDGCode ==  111){ 
+                               if (!(fDoReweightHistoMCPi0 && hReweightMCHistPi0!= 0x0 && PDGCode ==  111)){
+                                       weight = 1.;
+                               }
+                               } 
+                               if (PDGCode ==  221){ 
+                               if (!(fDoReweightHistoMCEta && hReweightMCHistEta!= 0x0 && PDGCode ==  221)){
+                                       weight = 1.;
+                               }
+                               }
+                       }
+                       if (!isfinite(functionResultData)) weight = 1.;
+                       if (!isfinite(weight)) weight = 1.;
+               }
+       } else if (PDGCode ==  310 && functionResultMC != 0 && isfinite(functionResultMC)){
+                       weight = functionResultMC;
+       }
+
+       //    if (fModCentralityClass == 0 && fCentralityMin == 4 && fCentralityMax == 6 && PDGCode ==  111){
+       //        cout << period.Data() << "\t" << kCaseGen << "\t" <<fModCentralityClass<< "\t" <<fCentralityMin<< "\t" <<fCentralityMax << "\t" << mesonPt << "\t" <<mesonMass<< "\t"<<functionResultData << "\t"<< functionResultMC << "\t" << weight <<endl;
+       //    }
+       return weight;
 }
 ///________________________________________________________________________
 AliConversionCuts* AliConversionCuts::GetStandardCuts2010PbPb(){
@@ -3948,6 +4561,11 @@ void AliConversionCuts::GetCorrectEtaShiftFromPeriod(TString periodName){
       periodName.CompareTo("LHC13c2") == 0 || //MC Starlight, coherent J/Psi, UPC muon anchor LHC13d+e
       periodName.CompareTo("LHC13b4") == 0 || //MC Pythia 6 (Jet-Jet), anchor LHC13b
       periodName.CompareTo("LHC13b2_fix_1") == 0 || //MC DPMJET, anchr LHC13b+c
+      periodName.CompareTo("LHC13b2_efix_p1") == 0 || //MC DPMJET, anchr LHC13b+c
+      periodName.CompareTo("LHC13b2_efix_p2") == 0 || //MC DPMJET, anchr LHC13b+c
+      periodName.CompareTo("LHC13b2_efix_p3") == 0 || //MC DPMJET, anchr LHC13b+c
+      periodName.CompareTo("LHC13b2_efix_p4") == 0 || //MC DPMJET, anchr LHC13b+c
+      periodName.CompareTo("LHC13e7") == 0 || //MC DPMJET, anchr LHC13b+c
       periodName.CompareTo("LHC13b3") == 0 || //MC HIJING, weighted to number of events per run, anchor LHC13b
       periodName.CompareTo("LHC13b2") == 0 ||  // MC DPMJET, wrong energy, anchor LHC13b
       periodName.CompareTo("LHC13b2_plus") == 0 || // MC DPMJET, weighted to number event per run, anchor LHC13b
@@ -3978,3 +4596,61 @@ void AliConversionCuts::GetCorrectEtaShiftFromPeriod(TString periodName){
       }
    else printf(" Gamma Conversion Cuts %s :: Automatic Eta Shift requested but Period is not known -> No Shift \n\n",(GetCutNumber()).Data());
 }
+
+///________________________________________________________________________
+Bool_t AliConversionCuts::InPlaneOutOfPlaneCut(Double_t photonPhi, Double_t eventPlaneAngle, Bool_t fill){
+   
+   //GetPhotonPhi() 0-2 Pi  //eventPlaneAngle -1pi-1pi
+   eventPlaneAngle=eventPlaneAngle+TMath::Pi();
+   Double_t gammaToEPAngle = eventPlaneAngle-photonPhi;
+   if(gammaToEPAngle < 0) gammaToEPAngle=gammaToEPAngle+2*TMath::Pi();
+   gammaToEPAngle = gammaToEPAngle-TMath::Pi(); // angle from -pi +pi
+
+   if(!fInPlaneOutOfPlane){
+      if(fill&&hEventPlanePhi)hEventPlanePhi->Fill(gammaToEPAngle);
+      return kTRUE;
+   }
+   else if(fInPlaneOutOfPlane == 1){
+      if(abs(gammaToEPAngle)<=0.25*TMath::Pi() || abs(gammaToEPAngle)>=0.75*TMath::Pi()){
+         if(fill&&hEventPlanePhi)hEventPlanePhi->Fill(gammaToEPAngle);
+         return kTRUE;
+      }
+      else return kFALSE;
+   }
+   else if(fInPlaneOutOfPlane == 2){
+      if(abs(gammaToEPAngle)>0.25*TMath::Pi() && abs(gammaToEPAngle)<0.75*TMath::Pi()){
+         if(fill&&hEventPlanePhi)hEventPlanePhi->Fill(gammaToEPAngle);
+         return kTRUE;
+      }
+      else return kFALSE;
+   }
+   return kFALSE;
+
+}
+
+///________________________________________________________________________
+UChar_t AliConversionCuts::DeterminePhotonQualityAOD(AliAODConversionPhoton* photon, AliVEvent* eventDummy){
+
+   AliAODTrack * negTrack = static_cast<AliAODTrack*>(GetTrack(eventDummy, photon->GetTrackLabelNegative()));
+   AliAODTrack * posTrack = static_cast<AliAODTrack*>(GetTrack(eventDummy, photon->GetTrackLabelPositive()));
+
+   if(!negTrack || !posTrack) {
+        return 0;
+   }
+   if(negTrack->Charge() == posTrack->Charge()){
+        return 0;
+   }   
+   Int_t nClusterITSneg = negTrack->GetITSNcls();
+   Int_t nClusterITSpos = posTrack->GetITSNcls();
+//    cout << nClusterITSneg << "\t" << nClusterITSpos <<endl;
+   
+   if (nClusterITSneg > 1 && nClusterITSpos > 1){
+      return 3;
+   } else if (nClusterITSneg > 1 || nClusterITSpos > 1){
+      return 2;
+   } else {
+      return 1;
+   }
+   return 0;
+   
+}