- added new task for eta -> gamma pi+ pi- analysis with conversions
authorfbock <Friederike.Bock@cern.ch>
Thu, 6 Feb 2014 14:48:26 +0000 (15:48 +0100)
committerfbock <Friederike.Bock@cern.ch>
Thu, 6 Feb 2014 14:48:26 +0000 (15:48 +0100)
- changes by Pedro Gonzales for dalitz task

16 files changed:
PWGGA/CMakelibPWGGAGammaConv.pkg
PWGGA/GammaConv/AliAnalysisTaskEtaToPiPlPiMiGamma.cxx [new file with mode: 0644]
PWGGA/GammaConv/AliAnalysisTaskEtaToPiPlPiMiGamma.h [new file with mode: 0644]
PWGGA/GammaConv/AliConversionCuts.cxx
PWGGA/GammaConv/AliConversionMesonCuts.cxx
PWGGA/GammaConv/AliConversionMesonCuts.h
PWGGA/GammaConv/AliDalitzElectronCuts.cxx
PWGGA/GammaConv/AliDalitzElectronCuts.h
PWGGA/GammaConv/AliPrimaryPionCuts.cxx [new file with mode: 0644]
PWGGA/GammaConv/AliPrimaryPionCuts.h [new file with mode: 0644]
PWGGA/GammaConv/AliPrimaryPionSelector.cxx [new file with mode: 0644]
PWGGA/GammaConv/AliPrimaryPionSelector.h [new file with mode: 0644]
PWGGA/GammaConv/macros/AddTask_GammaConvDalitzV1_pPb.C
PWGGA/GammaConv/macros/AddTask_GammaConvEtaPiPlPiMiGamma_pPb.C [new file with mode: 0644]
PWGGA/GammaConv/macros/AddTask_GammaConvV1_pPb.C
PWGGA/PWGGAGammaConvLinkDef.h

index 8a72345..d78b72f 100644 (file)
@@ -53,8 +53,10 @@ set ( SRCS
        GammaConv/AliAnaConvCorrPion.cxx
        GammaConv/AliAnaConvCorrPhoton.cxx
        GammaConv/AliAnalysisTaskdPhi.cxx
-       GammaConv/AliAnalysisTaskCaloConv.cxx
        GammaConv/AliAnalysisTaskGCPartToPWG4Part.cxx
+       GammaConv/AliPrimaryPionSelector.cxx
+       GammaConv/AliPrimaryPionCuts.cxx
+       GammaConv/AliAnalysisTaskEtaToPiPlPiMiGamma.cxx
 )
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
diff --git a/PWGGA/GammaConv/AliAnalysisTaskEtaToPiPlPiMiGamma.cxx b/PWGGA/GammaConv/AliAnalysisTaskEtaToPiPlPiMiGamma.cxx
new file mode 100644 (file)
index 0000000..6fbf9bb
--- /dev/null
@@ -0,0 +1,1447 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: Pedro Gonz??lez, Pedro Ladr??n de Guevara, Ernesto L??pez Torres, *
+ *         Eulogio Serradilla, Ana Marin, Friederike Bock                 *
+ * Version 2                                                              *
+ *                                                                        *
+ * 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.                  *
+ **************************************************************************/
+
+// Analysis task for pi0->e+e-gamma (Dalitz decay)
+// Analysis task for chic->JPsi+gamma
+
+#include <vector>
+
+#include "TParticle.h"
+#include "TPDGCode.h"
+#include "TMCProcess.h"
+#include "TDatabasePDG.h"
+#include "TList.h"
+#include "TChain.h"
+#include "TDirectory.h"
+#include "TTree.h"
+#include "TH1.h"
+#include "TH1F.h"
+#include "THnSparse.h"
+#include "TH2F.h"
+#include "AliStack.h"
+#include "AliAnalysisManager.h"
+#include "AliESDInputHandler.h"
+#include "AliESDtrack.h"
+#include "AliMCEvent.h"
+#include "AliStack.h"
+#include "AliMCEventHandler.h"
+#include "AliPID.h"
+#include "AliLog.h"
+#include "AliESDtrackCuts.h"
+#include "AliESDpidCuts.h"
+#include "AliMCEvent.h"
+#include "AliESDv0.h"
+#include "AliESDEvent.h"
+#include "AliESDpid.h"
+#include "AliKFParticle.h"
+#include "AliMCEventHandler.h"
+#include "AliKFVertex.h"
+#include "AliTriggerAnalysis.h"
+#include "AliCentrality.h"
+#include "AliMultiplicity.h"
+#include "AliAnalysisTaskEtaToPiPlPiMiGamma.h"
+
+
+ClassImp( AliAnalysisTaskEtaToPiPlPiMiGamma )
+
+//-----------------------------------------------------------------------------------------------
+AliAnalysisTaskEtaToPiPlPiMiGamma::AliAnalysisTaskEtaToPiPlPiMiGamma():
+       fV0Reader(NULL),
+       fPionSelector(NULL),
+       fBGHandler(NULL),
+       fESDEvent(NULL),
+       fMCEvent(NULL),
+       fMCStack(NULL),
+       fCutFolder(NULL),
+       fESDList(NULL),
+       fBackList(NULL),
+       fMotherList(NULL),
+       fTrueList(NULL),
+       fMCList(NULL),
+       fOutputContainer(0),
+       fReaderGammas(NULL),
+       fSelectorNegPionIndex(0),
+       fSelectorPosPionIndex(0),
+       fGoodGammas(NULL),
+       fGoodVirtualParticles(NULL),
+       fGammaCutArray(NULL),
+       fPionCutArray(NULL),
+       fMesonCutArray(NULL),
+       fConversionCuts(NULL),
+       fHistoConvGammaPt(NULL),
+       fHistoConvGammaEta(NULL),
+       fHistoNegPionPt(NULL),
+       fHistoPosPionPt(NULL),
+       fHistoNegPionPhi(NULL),
+       fHistoPosPionPhi(NULL),
+       fHistoNegPionEta(NULL),
+       fHistoPosPionEta(NULL),
+       fHistoNegPionClsTPC(NULL),
+       fHistoPosPionClsTPC(NULL),
+       fHistoPionDCAxy(NULL),
+       fHistoPionDCAz(NULL),
+       fHistoPionTPCdEdxNSigma(NULL),
+       fHistoPionTPCdEdx(NULL),
+       fHistoMotherInvMassPt(NULL),
+       fTHnSparseMotherInvMassPtZM(NULL),
+       fHistoMotherBackInvMassPt(NULL),
+       fTHnSparseMotherBackInvMassPtZM(NULL),
+       fHistoMCAllGammaPt(NULL),
+       fHistoMCConvGammaPt(NULL),
+       fHistoMCAllPosPionsPt(NULL),
+       fHistoMCAllNegPionsPt(NULL),
+       fHistoMCGammaFromEtaPt(NULL),
+       fHistoMCPosPionsFromEtaPt(NULL),
+       fHistoMCNegPionsFromEtaPt(NULL),
+       fHistoMCEtaPiPlPiMiGammaPt(NULL),
+       fHistoMCEtaGGPt(NULL),
+       fHistoMCEtaDalitzPt(NULL),
+       fHistoMCEtaPiPlPiMiGammaInAccPt(NULL),
+       fHistoTrueMotherPiPlPiMiGammaInvMassPt(NULL),
+       fHistoTrueMotherGammaGammaInvMassPt(NULL),
+       fHistoTrueMotherDalitzInvMassPt(NULL),
+       fHistoTrueConvGammaPt(NULL),
+       fHistoTrueConvGammaFromEtaPt(NULL),
+       fHistoTruePosPionPt(NULL),
+       fHistoTruePosPionFromEtaPt(NULL),
+       fHistoTrueNegPionPt(NULL),
+       fHistoTrueNegPionFromEtaPt(NULL),
+       fHistoNEvents(NULL),
+       fHistoNGoodESDTracks(NULL),
+       fProfileEtaShift(NULL),
+       fRandom(0),
+       fnCuts(0),
+       fiCut(0),
+       fNumberOfESDTracks(0),
+       fMoveParticleAccordingToVertex(kFALSE),
+       fIsHeavyIon(kFALSE),
+       fDoMesonAnalysis(kTRUE),
+       fDoMesonQA(kFALSE),
+       fIsFromMBHeader(kTRUE),
+       fIsMC(kFALSE)
+{
+
+}
+
+//-----------------------------------------------------------------------------------------------
+AliAnalysisTaskEtaToPiPlPiMiGamma::AliAnalysisTaskEtaToPiPlPiMiGamma( const char* name ):
+       AliAnalysisTaskSE(name),
+       fV0Reader(NULL),
+       fPionSelector(NULL),
+       fBGHandler(NULL),
+       fESDEvent(NULL),
+       fMCEvent(NULL),
+       fMCStack(NULL),
+       fCutFolder(NULL),
+       fESDList(NULL),
+       fBackList(NULL),
+       fMotherList(NULL),
+       fTrueList(NULL),
+       fMCList(NULL),
+       fOutputContainer(0),
+       fReaderGammas(NULL),
+       fSelectorNegPionIndex(0),
+       fSelectorPosPionIndex(0),
+       fGoodGammas(NULL),
+       fGoodVirtualParticles(NULL),
+       fGammaCutArray(NULL),
+       fPionCutArray(NULL),
+       fMesonCutArray(NULL),
+       fConversionCuts(NULL),
+       fHistoConvGammaPt(NULL),
+       fHistoConvGammaEta(NULL),
+       fHistoNegPionPt(NULL),
+       fHistoPosPionPt(NULL),
+       fHistoNegPionPhi(NULL),
+       fHistoPosPionPhi(NULL),
+       fHistoNegPionEta(NULL),
+       fHistoPosPionEta(NULL),
+       fHistoNegPionClsTPC(NULL),
+       fHistoPosPionClsTPC(NULL),
+       fHistoPionDCAxy(NULL),
+       fHistoPionDCAz(NULL),
+       fHistoPionTPCdEdxNSigma(NULL),
+       fHistoPionTPCdEdx(NULL),
+       fHistoMotherInvMassPt(NULL),
+       fTHnSparseMotherInvMassPtZM(NULL),
+       fHistoMotherBackInvMassPt(NULL),
+       fTHnSparseMotherBackInvMassPtZM(NULL),
+       fHistoMCAllGammaPt(NULL),
+       fHistoMCConvGammaPt(NULL),
+       fHistoMCAllPosPionsPt(NULL),
+       fHistoMCAllNegPionsPt(NULL),
+       fHistoMCGammaFromEtaPt(NULL),
+       fHistoMCPosPionsFromEtaPt(NULL),
+       fHistoMCNegPionsFromEtaPt(NULL),
+       fHistoMCEtaPiPlPiMiGammaPt(NULL),
+       fHistoMCEtaGGPt(NULL),
+       fHistoMCEtaDalitzPt(NULL),
+       fHistoMCEtaPiPlPiMiGammaInAccPt(NULL),
+       fHistoTrueMotherPiPlPiMiGammaInvMassPt(NULL),
+       fHistoTrueMotherGammaGammaInvMassPt(NULL),
+       fHistoTrueMotherDalitzInvMassPt(NULL),
+       fHistoTrueConvGammaPt(NULL),
+       fHistoTrueConvGammaFromEtaPt(NULL),
+       fHistoTruePosPionPt(NULL),
+       fHistoTruePosPionFromEtaPt(NULL),
+       fHistoTrueNegPionPt(NULL),
+       fHistoTrueNegPionFromEtaPt(NULL),
+       fHistoNEvents(NULL),
+       fHistoNGoodESDTracks(NULL),
+       fProfileEtaShift(NULL),
+       fRandom(0),
+       fnCuts(0),
+       fiCut(0),
+       fNumberOfESDTracks(0),
+       fMoveParticleAccordingToVertex(kFALSE),
+       fIsHeavyIon(kFALSE),
+       fDoMesonAnalysis(kTRUE),
+       fDoMesonQA(kFALSE),
+       fIsFromMBHeader(kTRUE),
+       fIsMC(kFALSE)
+{
+   DefineOutput(1, TList::Class());
+}
+
+//-----------------------------------------------------------------------------------------------
+AliAnalysisTaskEtaToPiPlPiMiGamma::~AliAnalysisTaskEtaToPiPlPiMiGamma()
+{
+       //
+       // virtual destructor
+       //
+       cout<<"Destructor"<<endl;
+       if(fGoodGammas){
+               delete fGoodGammas;
+               fGoodGammas = 0x0;
+       }
+       if(fGoodVirtualParticles){
+               delete fGoodVirtualParticles;
+               fGoodGammas = 0x0;
+       }
+       if(fBGHandler){
+               delete[] fBGHandler;
+               fBGHandler = 0x0;
+       }
+}
+//___________________________________________________________
+void AliAnalysisTaskEtaToPiPlPiMiGamma::InitBack(){
+
+       const Int_t nDim = 4;
+       Int_t nBins[nDim] = {800,250,7,4};
+       Double_t xMin[nDim] = {0,0, 0,0};
+       Double_t xMax[nDim] = {0.8,25,7,4};
+       
+       fTHnSparseMotherInvMassPtZM = new THnSparseF*[fnCuts];
+       fTHnSparseMotherBackInvMassPtZM = new THnSparseF*[fnCuts];
+
+       fBGHandler = new AliGammaConversionAODBGHandler*[fnCuts];
+       for(Int_t iCut = 0; iCut<fnCuts;iCut++){
+               
+               TString cutstringPion     =   ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutNumber();
+               TString cutstringMeson        =   ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
+               TString cutstringGamma        =   ((AliConversionCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
+               
+               Int_t collisionSystem = atoi((TString)(((AliConversionCuts*)fGammaCutArray->At(iCut))->GetCutNumber())(0,1));
+               Int_t centMin = atoi((TString)(((AliConversionCuts*)fGammaCutArray->At(iCut))->GetCutNumber())(1,1));
+               Int_t centMax = atoi((TString)(((AliConversionCuts*)fGammaCutArray->At(iCut))->GetCutNumber())(2,1));
+               
+               if(collisionSystem == 1 || collisionSystem == 2 ||
+                       collisionSystem == 5 || collisionSystem == 8 ||
+                       collisionSystem == 9){
+                       centMin = centMin*10;
+                       centMax = centMax*10; 
+               }
+               else if(collisionSystem == 3 || collisionSystem == 6){
+                       centMin = centMin*5;
+                       centMax = centMax*5;
+               }
+               else if(collisionSystem == 4 || collisionSystem == 7){
+                       centMin = ((centMin*5)+45);
+                       centMax = ((centMax*5)+45);
+               }
+
+
+               fBackList[iCut] = new TList();
+               fBackList[iCut]->SetName(Form("%s_%s_%s Back histograms",cutstringGamma.Data(),cutstringPion.Data(),cutstringMeson.Data()));
+               fBackList[iCut]->SetOwner(kTRUE);
+               fCutFolder[iCut]->Add(fBackList[iCut]);
+
+               fTHnSparseMotherBackInvMassPtZM[iCut] = new THnSparseF("Back_Back_InvMass_Pt_z_m","Back_Back_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
+               fBackList[iCut]->Add(fTHnSparseMotherBackInvMassPtZM[iCut]);
+
+               fMotherList[iCut] = new TList();
+               fMotherList[iCut]->SetName(Form("%s_%s_%s Mother histograms",cutstringGamma.Data(),cutstringPion.Data(),cutstringMeson.Data()));
+               fMotherList[iCut]->SetOwner(kTRUE);
+               fCutFolder[iCut]->Add(fMotherList[iCut]);
+
+               fTHnSparseMotherInvMassPtZM[iCut] = new THnSparseF("Back_Mother_InvMass_Pt_z_m","Back_Mother_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
+               fMotherList[iCut]->Add(fTHnSparseMotherInvMassPtZM[iCut]);
+
+               
+               fBGHandler[iCut] = new AliGammaConversionAODBGHandler(  collisionSystem,centMin,centMax,
+                                                                                                                               ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->GetNumberOfBGEvents(),
+                                                                                                                               ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity());
+               
+       }
+}
+
+//______________________________________________________________________
+void AliAnalysisTaskEtaToPiPlPiMiGamma::UserCreateOutputObjects()
+{
+       //
+       // Create ouput objects
+       //
+
+       // Create the output container
+       if(fOutputContainer != NULL){
+               delete fOutputContainer;
+               fOutputContainer = NULL;
+       }
+       if(fOutputContainer == NULL){
+               fOutputContainer = new TList();
+               fOutputContainer->SetOwner(kTRUE);
+       }
+
+       fGoodGammas = new TList();
+       //fGoodGammas->SetOwner(kTRUE);
+
+       fGoodVirtualParticles = new TList();
+       //fGoodVirtualParticles->SetOwner(kTRUE);
+
+       fCutFolder                              = new TList*[fnCuts];
+       fESDList                                = new TList*[fnCuts];
+       fBackList                               = new TList*[fnCuts];
+       fMotherList                     = new TList*[fnCuts];
+       fHistoNEvents                   = new TH1I*[fnCuts];
+       fHistoNGoodESDTracks    = new TH1I*[fnCuts];
+       fProfileEtaShift                = new TProfile*[fnCuts];
+       fHistoConvGammaPt               = new TH1F*[fnCuts];
+       fHistoConvGammaEta              = new TH1F*[fnCuts];
+       fHistoNegPionPt                 = new TH1F*[fnCuts];
+       fHistoPosPionPt                 = new TH1F*[fnCuts];
+       fHistoNegPionPhi                = new TH1F*[fnCuts];
+       fHistoPosPionPhi                = new TH1F*[fnCuts];
+       
+       if( fDoMesonQA ) {                      
+               fHistoNegPionEta                = new TH1F*[fnCuts];
+               fHistoPosPionEta                = new TH1F*[fnCuts];
+               fHistoNegPionClsTPC             = new TH2F*[fnCuts];
+               fHistoPosPionClsTPC             = new TH2F*[fnCuts];
+               fHistoPionDCAxy                 = new TH2F*[fnCuts];
+               fHistoPionDCAz                  = new TH2F*[fnCuts];
+               fHistoPionTPCdEdxNSigma = new TH2F*[fnCuts];
+               fHistoPionTPCdEdx               = new TH2F*[fnCuts];
+       }
+       
+       fHistoMotherInvMassPt           = new TH2F*[fnCuts];
+       fHistoMotherBackInvMassPt       = new TH2F*[fnCuts];
+
+       for(Int_t iCut = 0; iCut<fnCuts;iCut++){
+               TString cutstringPion =((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutNumber();
+               TString cutstringMeson= ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
+               TString cutstringGamma = ((AliConversionCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
+
+               fCutFolder[iCut] = new TList();
+               fCutFolder[iCut]->SetName(Form("Cut Number %s_%s_%s",cutstringGamma.Data(),cutstringPion.Data(),cutstringMeson.Data()));
+               fCutFolder[iCut]->SetOwner(kTRUE);
+               fOutputContainer->Add(fCutFolder[iCut]);
+
+               fESDList[iCut] = new TList();
+               fESDList[iCut]->SetName(Form("%s_%s_%s ESD histograms",cutstringGamma.Data(),cutstringPion.Data(),cutstringMeson.Data()));
+               fESDList[iCut]->SetOwner(kTRUE);
+
+               fHistoNEvents[iCut] = new TH1I("NEvents","NEvents",9,-0.5,8.5);
+               fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(1,"Accepted");
+               fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(2,"Centrality");
+               fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(3,"Missing MC");
+               fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,"Trigger");
+               fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(5,"Vertex Z");
+               fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(6,"Cont. Vertex");
+               fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(7,"Pile-Up");
+               fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(8,"no SDD");
+               fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(9,"no V0AND");
+               fESDList[iCut]->Add(fHistoNEvents[iCut]);
+
+               if(fIsHeavyIon) fHistoNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",3000,0,3000);
+                       else fHistoNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",200,0,200);
+               fESDList[iCut]->Add(fHistoNGoodESDTracks[iCut]);
+
+               fProfileEtaShift[iCut] = new TProfile("Eta Shift","Eta Shift",1, -0.5,0.5);
+               fESDList[iCut]->Add(fProfileEtaShift[iCut]);
+               fHistoConvGammaPt[iCut] = new TH1F("ESD_ConvGamma_Pt","ESD_ConvGamma_Pt",250,0,25);
+               fESDList[iCut]->Add(fHistoConvGammaPt[iCut]);
+               fHistoConvGammaEta[iCut] = new TH1F("ESD_ConvGamma_Eta","ESD_ConvGamma_Eta",600,-1.5,1.5);
+               fESDList[iCut]->Add(fHistoConvGammaEta[iCut]);
+               fHistoNegPionPt[iCut] = new TH1F("ESD_PrimaryNegPions_Pt","ESD_PrimaryNegPions_Pt",1000,0,25);
+               fESDList[iCut]->Add(fHistoNegPionPt[iCut]);
+               fHistoPosPionPt[iCut] = new TH1F("ESD_PrimaryPosPions_Pt","ESD_PrimaryPosPions_Pt",1000,0,25);
+               fESDList[iCut]->Add(fHistoPosPionPt[iCut]);
+               fHistoNegPionPhi[iCut] = new TH1F("ESD_PrimaryNegPions_Phi","ESD_PrimaryNegPions_Phi",360,0,2*TMath::Pi());
+               fESDList[iCut]->Add(fHistoNegPionPhi[iCut]);
+               fHistoPosPionPhi[iCut] = new TH1F("ESD_PrimaryPosPions_Phi","ESD_PrimaryPosPions_Phi",360,0,2*TMath::Pi());
+               fESDList[iCut]->Add(fHistoPosPionPhi[iCut]);
+               
+               if ( fDoMesonQA ) {
+                       fHistoNegPionEta[iCut] = new TH1F("ESD_PrimaryNegPions_Eta","ESD_PrimaryNegPions_Eta",600,-1.5,1.5);
+                       fESDList[iCut]->Add(fHistoNegPionEta[iCut]);
+                       fHistoPosPionEta[iCut] = new TH1F("ESD_PrimaryPosPions_Eta","ESD_PrimaryPosPions_Eta",600,-1.5,1.5);
+                       fESDList[iCut]->Add(fHistoPosPionEta[iCut]);
+                       fHistoNegPionClsTPC[iCut]  = new TH2F("ESD_PrimaryNegPions_ClsTPC","ESD_PrimaryNegPions_ClsTPC",100,0,1,400,0.,10.);
+                       fESDList[iCut]->Add(fHistoNegPionClsTPC[iCut]);
+                       fHistoPosPionClsTPC[iCut]  = new TH2F("ESD_PrimaryPosPions_ClsTPC","ESD_PrimaryPosPions_ClsTPC",100,0,1,400,0.,10.);
+                       fESDList[iCut]->Add(fHistoPosPionClsTPC[iCut]);
+                       fHistoPionDCAxy[iCut] = new TH2F("ESD_PrimaryPions_DCAxy","ESD_PrimaryPions_DCAxy",800,-4.0,4.0,400,0.,10.);
+                       fESDList[iCut]->Add(fHistoPionDCAxy[iCut]);
+                       fHistoPionDCAz[iCut]  = new TH2F("ESD_PrimaryPions_DCAz","ESD_PrimaryPions_DCAz",800,-4.0,4.0,400,0.,10.);
+                       fESDList[iCut]->Add(fHistoPionDCAz[iCut]);
+                       fHistoPionTPCdEdxNSigma[iCut] = new TH2F("ESD_PrimaryPions_TPCdEdx","ESD_PrimaryPions_TPCdEdx",150,0.05,20,400,-10,10);
+                       fESDList[iCut]->Add(fHistoPionTPCdEdxNSigma[iCut]);
+                       fHistoPionTPCdEdx[iCut] =new TH2F("ESD_PrimaryPions_TPCdEdxSignal","ESD_PrimaryPions_TPCdEdxSignal" ,150,0.05,20.0,800,0.0,200);
+                       fESDList[iCut]->Add(fHistoPionTPCdEdx[iCut]);                   
+               }
+
+               fHistoMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt","ESD_Mother_InvMass_Pt",900,0.3,1.2,250,0,25);
+               fESDList[iCut]->Add(fHistoMotherInvMassPt[iCut]);
+               fHistoMotherBackInvMassPt[iCut] = new TH2F("ESD_Background_InvMass_Pt","ESD_Background_InvMass_Pt",900,0.3,1.2,250,0,25);
+               fESDList[iCut]->Add(fHistoMotherBackInvMassPt[iCut]);
+
+               if ( fDoMesonQA ) {
+                       TAxis *AxisAfter = fHistoPionTPCdEdxNSigma[iCut]->GetXaxis(); 
+                       Int_t bins = AxisAfter->GetNbins();
+                       Double_t from = AxisAfter->GetXmin();
+                       Double_t to = AxisAfter->GetXmax();
+                       Double_t *newBins = new Double_t[bins+1];
+                       newBins[0] = from;
+                       Double_t factor = TMath::Power(to/from, 1./bins);
+                       for(Int_t i=1; i<=bins; ++i) newBins[i] = factor * newBins[i-1];
+
+                       AxisAfter->Set(bins, newBins);
+                       AxisAfter = fHistoPionTPCdEdx[iCut]->GetXaxis(); 
+                       AxisAfter->Set(bins, newBins);
+
+                       delete [] newBins;              
+               }
+
+               fCutFolder[iCut]->Add(fESDList[iCut]);
+
+       }
+
+       if( fIsMC ){
+               // MC Histogramms
+               fMCList = new TList*[fnCuts];
+               // True Histogramms
+               fTrueList = new TList*[fnCuts];
+               fHistoTrueConvGammaPt = new TH1F*[fnCuts];
+               fHistoTrueConvGammaFromEtaPt = new TH1F*[fnCuts];
+               fHistoTruePosPionPt  = new TH1F*[fnCuts];
+               fHistoTrueNegPionPt  = new TH1F*[fnCuts];               
+               fHistoTruePosPionFromEtaPt  = new TH1F*[fnCuts];
+               fHistoTrueNegPionFromEtaPt  = new TH1F*[fnCuts];
+               
+
+               fHistoMCAllGammaPt  = new TH1F*[fnCuts];
+               fHistoMCConvGammaPt = new TH1F*[fnCuts];
+               fHistoMCAllPosPionsPt = new TH1F*[fnCuts];
+               fHistoMCAllNegPionsPt = new TH1F*[fnCuts];
+               fHistoMCGammaFromEtaPt  = new TH1F*[fnCuts];
+               fHistoMCPosPionsFromEtaPt = new TH1F*[fnCuts];
+               fHistoMCNegPionsFromEtaPt = new TH1F*[fnCuts];
+
+//             hMCPi0DalitzGammaPt    = new TH1F*[fnCuts];
+//             hMCPi0DalitzElectronPt = new TH1F*[fnCuts];
+//             hMCPi0DalitzPositronPt = new TH1F*[fnCuts];
+
+               fHistoMCEtaPiPlPiMiGammaPt = new TH1F*[fnCuts];
+               fHistoMCEtaDalitzPt = new TH1F*[fnCuts];
+               fHistoMCEtaGGPt = new TH1F*[fnCuts];
+               fHistoMCEtaPiPlPiMiGammaInAccPt = new TH1F*[fnCuts];
+//                             
+               fHistoTrueMotherPiPlPiMiGammaInvMassPt = new TH2F*[fnCuts];
+               fHistoTrueMotherDalitzInvMassPt = new TH2F*[fnCuts];
+               fHistoTrueMotherGammaGammaInvMassPt = new TH2F*[fnCuts];
+
+               for(Int_t iCut = 0; iCut<fnCuts;iCut++){
+                       TString cutstringPion =((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutNumber();
+                       TString cutstringMeson= ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
+                       TString cutstringGamma = ((AliConversionCuts*)fGammaCutArray->At(iCut))->GetCutNumber();
+
+                       fMCList[iCut] = new TList();
+                       fMCList[iCut]->SetName(Form("%s_%s_%s MC histograms",cutstringGamma.Data(),cutstringPion.Data(),cutstringMeson.Data()));
+                       fMCList[iCut]->SetOwner(kTRUE);
+                       fCutFolder[iCut]->Add(fMCList[iCut]);
+
+                       fHistoMCAllGammaPt[iCut] = new TH1F("MC_AllGamma_Pt","MC_AllGamma_Pt",250,0,25);
+                       fMCList[iCut]->Add(fHistoMCAllGammaPt[iCut]);                   
+                       fHistoMCConvGammaPt[iCut] = new TH1F("MC_ConvGamma_Pt","MC_ConvGamma_Pt",250,0,25);
+                       fMCList[iCut]->Add(fHistoMCConvGammaPt[iCut]);                                          
+                       fHistoMCAllPosPionsPt[iCut] = new TH1F("MC_AllPosPions_Pt","MC_AllPosPions_Pt",1000,0,25);
+                       fMCList[iCut]->Add(fHistoMCAllPosPionsPt[iCut]);
+                       fHistoMCAllNegPionsPt[iCut] = new TH1F("MC_AllNegPions_Pt","MC_AllNegPions_Pt",1000,0,25);
+                       fMCList[iCut]->Add(fHistoMCAllNegPionsPt[iCut]);
+                       fHistoMCGammaFromEtaPt[iCut] = new TH1F("MC_GammaFromEta_Pt","MC_GammaFromEta_Pt",250,0,25);
+                       fMCList[iCut]->Add(fHistoMCGammaFromEtaPt[iCut]);       
+                       fHistoMCPosPionsFromEtaPt[iCut] = new TH1F("MC_PosPionsFromEta_Pt","MC_PosPionsFromEta_Pt",1000,0,25);
+                       fMCList[iCut]->Add(fHistoMCPosPionsFromEtaPt[iCut]);
+                       fHistoMCNegPionsFromEtaPt[iCut] = new TH1F("MC_NegPionsFromEta_Pt","MC_NegPionsFromEta_Pt",1000,0,25);
+                       fMCList[iCut]->Add(fHistoMCNegPionsFromEtaPt[iCut]);            
+
+                       fHistoMCEtaPiPlPiMiGammaPt[iCut] = new TH1F("MC_Eta_Pt","MC_Eta_Pt",250,0,25);
+                       fHistoMCEtaPiPlPiMiGammaPt[iCut]->Sumw2();
+                       fMCList[iCut]->Add(fHistoMCEtaPiPlPiMiGammaPt[iCut]);
+
+                       fHistoMCEtaDalitzPt[iCut] = new TH1F("MC_Eta_Dalitz_Pt","MC_Eta_Pt",250,0,25);
+                       fHistoMCEtaDalitzPt[iCut]->Sumw2();
+                       fMCList[iCut]->Add(fHistoMCEtaDalitzPt[iCut]);
+
+                       fHistoMCEtaGGPt[iCut] = new TH1F("MC_Eta_GG_Pt","MC_Eta_GG_Pt",250,0,25);
+                       fHistoMCEtaGGPt[iCut]->Sumw2();
+                       fMCList[iCut]->Add(fHistoMCEtaGGPt[iCut]);
+                       
+                       fHistoMCEtaPiPlPiMiGammaInAccPt[iCut] = new TH1F("MC_EtaDalitzInAcc_Pt","MC_EtaDalitzInAcc_Pt",250,0,25);
+                       fHistoMCEtaPiPlPiMiGammaInAccPt[iCut]->Sumw2();
+                       fMCList[iCut]->Add(fHistoMCEtaPiPlPiMiGammaInAccPt[iCut]);
+
+                       fTrueList[iCut] = new TList();
+                       fTrueList[iCut]->SetName(Form("%s_%s_%s True histograms",cutstringGamma.Data(),cutstringPion.Data(),cutstringMeson.Data()));
+                       fTrueList[iCut]->SetOwner(kTRUE);
+                       fCutFolder[iCut]->Add(fTrueList[iCut]);
+
+                       fHistoTrueConvGammaPt[iCut] = new TH1F("ESD_TrueConvGamma_Pt","ESD_TrueConvGamma_Pt",250,0,25);
+                       fTrueList[iCut]->Add(fHistoTrueConvGammaPt[iCut]);
+                       fHistoTrueConvGammaFromEtaPt[iCut] = new TH1F("ESD_TrueConvGammaFromEta_Pt","ESD_TrueConvGammaFromEta_Pt",250,0,25);
+                       fTrueList[iCut]->Add(fHistoTrueConvGammaFromEtaPt[iCut]);
+               
+                       fHistoTruePosPionPt[iCut] = new TH1F("ESD_TruePosPion_Pt","ESD_TruePosPion_Pt",1000,0,25);
+                       fTrueList[iCut]->Add(fHistoTruePosPionPt[iCut]);
+                       fHistoTrueNegPionPt[iCut] = new TH1F("ESD_TrueNegPion_Pt","ESD_TrueNegPion_Pt",1000,0,25);
+                       fTrueList[iCut]->Add(fHistoTrueNegPionPt[iCut]);        
+
+                       fHistoTrueNegPionFromEtaPt[iCut] = new TH1F("ESD_TrueNegPionFromEta_Pt","ESD_TrueNegPionFromEta_Pt",1000,0,25);
+                       fTrueList[iCut]->Add(fHistoTrueNegPionFromEtaPt[iCut]);
+                       fHistoTruePosPionFromEtaPt[iCut] = new TH1F("ESD_TruePosPionFromEta_Pt","ESD_TruePosPionFromEta_Pt",1000,0,25);
+                       fTrueList[iCut]->Add(fHistoTruePosPionFromEtaPt[iCut]);
+
+                       fHistoTrueMotherPiPlPiMiGammaInvMassPt[iCut] = new TH2F("ESD_TrueMotherPiPlPiMiGamma_InvMass_Pt","ESD_TrueMotherPiPlPiMiGamma_InvMass_Pt",900,0.3,1.4,250,0,25);
+                       fHistoTrueMotherPiPlPiMiGammaInvMassPt[iCut]->Sumw2();
+                       fTrueList[iCut]->Add(fHistoTrueMotherPiPlPiMiGammaInvMassPt[iCut]);
+               
+                       fHistoTrueMotherGammaGammaInvMassPt[iCut] = new TH2F("ESD_TrueMotherGG_InvMass_Pt","ESD_TrueMotherGG_InvMass_Pt",900,0.3,1.4,250,0,25);
+                       fHistoTrueMotherGammaGammaInvMassPt[iCut]->Sumw2();
+                       fTrueList[iCut]->Add(fHistoTrueMotherGammaGammaInvMassPt[iCut]);
+                       
+                       fHistoTrueMotherDalitzInvMassPt[iCut] = new TH2F("ESD_TrueMotherDalitz_InvMass_Pt","ESD_TrueMotherDalitz_InvMass_Pt",900,0.3,1.4,250,0,25);
+                       fHistoTrueMotherDalitzInvMassPt[iCut]->Sumw2();
+                       fTrueList[iCut]->Add(fHistoTrueMotherDalitzInvMassPt[iCut]);
+                       
+               }
+       }
+
+       
+
+       InitBack(); // Init Background Handler
+
+       fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask("V0ReaderV1");
+       if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
+               
+       if(fV0Reader)
+               if((AliConversionCuts*)fV0Reader->GetConversionCuts())
+                       if(((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
+                               fOutputContainer->Add(((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
+               
+               
+               
+       fPionSelector=(AliPrimaryPionSelector*)AliAnalysisManager::GetAnalysisManager()->GetTask("PionSelector");
+       if(!fPionSelector){printf("Error: No PionSelector");return;} // GetV0Reader
+               
+       if( fPionSelector ){
+               if ( ((AliPrimaryPionCuts*)fPionSelector->GetPrimaryPionCuts())->GetCutHistograms() ){
+                       fOutputContainer->Add( ((AliPrimaryPionCuts*)fPionSelector->GetPrimaryPionCuts())->GetCutHistograms() );
+               }
+       }  
+
+       for(Int_t iCut = 0; iCut<fnCuts;iCut++){
+               if( fPionCutArray ){
+                       if( ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutHistograms() ) {
+                               fCutFolder[iCut]->Add( ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->GetCutHistograms() );
+                       }
+               }
+               if( fMesonCutArray  ) {
+                       if( ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms() ) {
+                               fCutFolder[iCut]->Add( ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
+                       }
+               }
+               if( fGammaCutArray ) {
+                       if( ((AliConversionCuts*)fGammaCutArray->At(iCut))->GetCutHistograms() ) {
+                               fCutFolder[iCut]->Add( ((AliConversionCuts*)fGammaCutArray->At(iCut))->GetCutHistograms()  );
+                       }
+               }
+       }
+
+       PostData(1, fOutputContainer);
+
+}
+
+//______________________________________________________________________
+void AliAnalysisTaskEtaToPiPlPiMiGamma::UserExec(Option_t *){
+
+       //
+       // Execute analysis for current event
+       //
+
+       fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask("V0ReaderV1");
+       if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
+
+       Int_t eventQuality = ((AliConversionCuts*)fV0Reader->GetConversionCuts())->GetEventQuality();
+
+       if(eventQuality == 2 || eventQuality == 3){// Event Not Accepted due to MC event missing or wrong trigger for V0ReaderV1
+               for(Int_t iCut = 0; iCut<fnCuts; iCut++){
+                       fHistoNEvents[iCut]->Fill(eventQuality);
+               }
+               return;
+       }
+
+       fPionSelector=(AliPrimaryPionSelector*)AliAnalysisManager::GetAnalysisManager()->GetTask("PionSelector");
+       if(!fPionSelector){printf("Error: No PionSelector");return;} // GetV0Reader
+
+       if(fIsMC) fMCEvent     =  MCEvent();
+       fESDEvent        = (AliESDEvent*)InputEvent();
+       fReaderGammas    = fV0Reader->GetReconstructedGammas(); // Gammas from default Cut
+       fSelectorNegPionIndex = fPionSelector->GetReconstructedNegPionIndex(); // Electrons from default Cut
+       fSelectorPosPionIndex = fPionSelector->GetReconstructedPosPionIndex(); // Positrons from default Cut
+
+       fNumberOfESDTracks = fV0Reader->GetNumberOfPrimaryTracks();
+       //AddTaskContainers(); //Add conatiner
+
+       for(Int_t iCut = 0; iCut<fnCuts; iCut++){
+               fiCut = iCut;
+               Int_t eventNotAccepted =
+                       ((AliConversionCuts*)fGammaCutArray->At(iCut))
+                       ->IsEventAcceptedByConversionCut(fV0Reader->GetConversionCuts(),fInputEvent,fMCEvent,fIsHeavyIon);
+               
+               if(eventNotAccepted){
+                       //                      cout << "event rejected due to wrong trigger: " <<eventNotAccepted << endl;
+                       fHistoNEvents[iCut]->Fill(eventNotAccepted); // Check Centrality, PileUp, SDD and V0AND --> Not Accepted => eventQuality = 1
+                       continue;
+               }
+
+               if(eventQuality != 0){// Event Not Accepted
+                       //                      cout << "event rejected due to: " <<eventQuality << endl;
+                       fHistoNEvents[iCut]->Fill(eventQuality);
+                       continue;
+               }
+
+               fHistoNEvents[iCut]->Fill(eventQuality);
+               fHistoNGoodESDTracks[iCut]->Fill(fNumberOfESDTracks);
+
+               if(fMCEvent){ // Process MC Particle
+                       fMCStack = fMCEvent->Stack();                   
+                       if(((AliConversionCuts*)fGammaCutArray->At(iCut))->GetSignalRejection() != 0){
+                               ((AliConversionCuts*)fGammaCutArray->At(iCut))->GetNotRejectedParticles(((AliConversionCuts*)fGammaCutArray->At(iCut))->GetSignalRejection(), ((AliConversionCuts*)fGammaCutArray->At(iCut))->GetAcceptedHeader(),
+                                                                                                       fMCEvent);
+                       } 
+                       ProcessMCParticles();
+               }
+
+//             cout << "new event" << endl;
+               ProcessPhotonCandidates(); // Process this cuts gammas
+               ProcessPionCandidates(); // Process this cuts gammas
+               
+       
+               CalculateMesonCandidates();
+               CalculateBackground();
+               UpdateEventByEventData();
+                               
+               fGoodGammas->Clear(); // delete this cuts good gammas
+               fGoodVirtualParticles->Clear(); // delete this cuts good gammas
+       }
+
+       fSelectorNegPionIndex.clear();
+       fSelectorPosPionIndex.clear();
+
+       PostData( 1, fOutputContainer );
+}
+
+Bool_t AliAnalysisTaskEtaToPiPlPiMiGamma::Notify(){
+       for(Int_t iCut = 0; iCut<fnCuts;iCut++){
+               if( !((AliConversionCuts*)fGammaCutArray->At(iCut))->GetDoEtaShift() ){
+                       fProfileEtaShift[iCut]->Fill(0.,0.);
+                       continue; // No Eta Shift requested, continue
+               }
+               if( ((AliConversionCuts*)fGammaCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
+                       ((AliConversionCuts*)fGammaCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod(fV0Reader->GetPeriodName());
+                       ((AliConversionCuts*)fGammaCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once   
+                       ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->SetEtaShift( ((AliConversionCuts*)fGammaCutArray->At(iCut))->GetEtaShift() );
+                       fProfileEtaShift[iCut]->Fill(0.,(((AliConversionCuts*)fGammaCutArray->At(iCut))->GetEtaShift()));
+                       continue;
+               } else {
+                       printf(" Eta t PiPlusPiMinus Gamma Task %s :: Eta Shift Manually Set to %f \n\n",
+                       (((AliConversionCuts*)fGammaCutArray->At(iCut))->GetCutNumber()).Data(),((AliConversionCuts*)fGammaCutArray->At(iCut))->GetEtaShift());
+                       ((AliConversionCuts*)fGammaCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once   
+                       ((AliPrimaryPionCuts*)fPionCutArray->At(iCut))->SetEtaShift( ((AliConversionCuts*)fGammaCutArray->At(iCut))->GetEtaShift() );
+                       fProfileEtaShift[iCut]->Fill(0.,(((AliConversionCuts*)fGammaCutArray->At(iCut))->GetEtaShift()));
+               }
+       }
+       return kTRUE;
+}
+
+
+void AliAnalysisTaskEtaToPiPlPiMiGamma::Terminate(const Option_t *){
+///Grid
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskEtaToPiPlPiMiGamma::ProcessPhotonCandidates(){
+       Int_t nV0 = 0;
+       TList *GoodGammasStepOne = new TList();
+       TList *GoodGammasStepTwo = new TList();
+       // Loop over Photon Candidates allocated by ReaderV1
+       
+       for(Int_t i = 0; i < fReaderGammas->GetEntriesFast(); i++){
+               AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) fReaderGammas->At(i);
+               if(!PhotonCandidate) continue;
+               
+               fIsFromMBHeader = kTRUE;
+               
+               if( fMCEvent && ((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetSignalRejection() != 0 ){           
+                       Int_t isPosFromMBHeader
+                               = ((AliConversionCuts*)fGammaCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack, fInputEvent);
+                       if(isPosFromMBHeader == 0 && ((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
+                       Int_t isNegFromMBHeader
+                               = ((AliConversionCuts*)fGammaCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack,fInputEvent);
+                       if(isNegFromMBHeader == 0 && ((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
+                       if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
+               }
+               
+               if(!((AliConversionCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelected(PhotonCandidate,fESDEvent)) continue;
+
+               if(!((AliConversionCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut() &&
+                       !((AliConversionCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // if no post reader loop is required add to events good gammas
+                       
+                       fGoodGammas->Add(PhotonCandidate);
+               
+                       if(fIsFromMBHeader){
+                               fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
+                               fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
+                       }
+               
+                       if(fMCEvent){
+                               ProcessTruePhotonCandidates(PhotonCandidate);
+                       }
+               } else if(((AliConversionCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut()){ // if Shared Electron cut is enabled, Fill array, add to step one
+                       ((AliConversionCuts*)fGammaCutArray->At(fiCut))->FillElectonLabelArray(PhotonCandidate,nV0);
+                       nV0++;
+                       GoodGammasStepOne->Add(PhotonCandidate);
+               } else if(!((AliConversionCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut() &&
+                               ((AliConversionCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // shared electron is disabled, step one not needed -> step two
+                       GoodGammasStepTwo->Add(PhotonCandidate);
+               }
+       }
+       
+       
+       if(((AliConversionCuts*)fGammaCutArray->At(fiCut))->UseElecSharingCut()){
+               for(Int_t i = 0;i<GoodGammasStepOne->GetEntries();i++){
+                       AliAODConversionPhoton *PhotonCandidate= (AliAODConversionPhoton*) GoodGammasStepOne->At(i);
+                       if(!PhotonCandidate) continue;
+                       fIsFromMBHeader = kTRUE;
+                       if(fMCEvent && ((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetSignalRejection() != 0){
+                               Int_t isPosFromMBHeader
+                               = ((AliConversionCuts*)fGammaCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack,fInputEvent);
+                               Int_t isNegFromMBHeader
+                               = ((AliConversionCuts*)fGammaCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack,fInputEvent);
+                               if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
+                       }
+                       if(!((AliConversionCuts*)fGammaCutArray->At(fiCut))->RejectSharedElectronV0s(PhotonCandidate,i,GoodGammasStepOne->GetEntries())) continue;
+                       if(!((AliConversionCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){ // To Colse v0s cut diabled, step two not needed
+                               fGoodGammas->Add(PhotonCandidate);
+                               if(fIsFromMBHeader){
+                                       fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
+                                       fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
+                               }
+                               if(fMCEvent){
+                                       ProcessTruePhotonCandidates(PhotonCandidate);
+                               }
+                       }
+                       else GoodGammasStepTwo->Add(PhotonCandidate); // Close v0s cut enabled -> add to list two
+               }
+       }
+       if(((AliConversionCuts*)fGammaCutArray->At(fiCut))->UseToCloseV0sCut()){
+               for(Int_t i = 0;i<GoodGammasStepTwo->GetEntries();i++){
+                       AliAODConversionPhoton* PhotonCandidate = (AliAODConversionPhoton*) GoodGammasStepTwo->At(i);
+                       if(!PhotonCandidate) continue;
+                       
+                       if(fMCEvent && ((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetSignalRejection() != 0){
+                               Int_t isPosFromMBHeader
+                               = ((AliConversionCuts*)fGammaCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelPositive(), fMCStack,fInputEvent);
+                               Int_t isNegFromMBHeader
+                               = ((AliConversionCuts*)fGammaCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetMCLabelNegative(), fMCStack,fInputEvent);
+                               if( (isNegFromMBHeader+isPosFromMBHeader) != 4) fIsFromMBHeader = kFALSE;
+                       }
+                       
+                       if(!((AliConversionCuts*)fGammaCutArray->At(fiCut))->RejectToCloseV0s(PhotonCandidate,GoodGammasStepTwo,i)) continue;
+                       fGoodGammas->Add(PhotonCandidate); // Add gamma to current cut TList
+               
+                       if(fIsFromMBHeader){
+                               fHistoConvGammaPt[fiCut]->Fill(PhotonCandidate->Pt()); // Differences to old V0Reader in p_t due to conversion KF->TLorentzVector
+                               fHistoConvGammaEta[fiCut]->Fill(PhotonCandidate->Eta());
+                       }
+               
+                       if(fMCEvent){
+                               ProcessTruePhotonCandidates(PhotonCandidate);
+                       }
+               }
+       }
+
+       delete GoodGammasStepOne;
+       GoodGammasStepOne = 0x0;
+       delete GoodGammasStepTwo;
+       GoodGammasStepTwo = 0x0;
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskEtaToPiPlPiMiGamma::ProcessTruePhotonCandidates(AliAODConversionPhoton *TruePhotonCandidate)
+{
+       // Process True Photons
+       AliStack *MCStack = fMCEvent->Stack();
+       TParticle *posDaughter = TruePhotonCandidate->GetPositiveMCDaughter(MCStack);
+       TParticle *negDaughter = TruePhotonCandidate->GetNegativeMCDaughter(MCStack);
+
+       if(posDaughter == NULL || negDaughter == NULL) return; // One particle does not exist
+       if(posDaughter->GetMother(0) != negDaughter->GetMother(0)){  // Not Same Mother == Combinatorial Bck
+               return;
+       }
+       
+       else if (posDaughter->GetMother(0) == -1){
+               return;
+       }
+       
+       if(TMath::Abs(posDaughter->GetPdgCode())!=11 || TMath::Abs(negDaughter->GetPdgCode())!=11) return; //One Particle is not electron
+       if(posDaughter->GetPdgCode()==negDaughter->GetPdgCode()) return; // Same Charge
+       if(posDaughter->GetUniqueID() != 5 || negDaughter->GetUniqueID() !=5) return;// check if the daughters come from a conversion
+
+       TParticle *Photon = TruePhotonCandidate->GetMCParticle(MCStack);
+       if(Photon->GetPdgCode() != 22) return; // Mother is no Photon
+
+       // True Photon
+       
+       Int_t labelGamma = TruePhotonCandidate->GetMCParticleLabel(MCStack);
+       
+       if( labelGamma < MCStack->GetNprimary() ){
+               if( fIsFromMBHeader ){
+               fHistoTrueConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+               }
+       }
+       
+       if( IsEtaPiPlPiMiGammaDaughter(labelGamma) == kTRUE ) {
+               if( labelGamma < MCStack->GetNprimary() ) {
+                       if( fIsFromMBHeader ){
+                               fHistoTrueConvGammaFromEtaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       }
+               }
+       } 
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskEtaToPiPlPiMiGamma::ProcessPionCandidates(){
+
+       Double_t magField = fInputEvent->GetMagneticField();
+       if( magField  < 0.0 ){
+               magField =  1.0;
+       } else {
+               magField =  -1.0;
+       }
+
+       vector<Int_t> lGoodNegPionIndexPrev(0);
+       vector<Int_t> lGoodPosPionIndexPrev(0);
+       
+       for(UInt_t i = 0; i < fSelectorNegPionIndex.size(); i++){
+               AliESDtrack* negPionCandidate = fESDEvent->GetTrack(fSelectorNegPionIndex[i]);
+               if(! ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelected(negPionCandidate) ) continue;
+               lGoodNegPionIndexPrev.push_back(   fSelectorNegPionIndex[i] );
+               fHistoNegPionPt[fiCut]->Fill(negPionCandidate->Pt());
+               fHistoNegPionPhi[fiCut]->Fill(negPionCandidate->Phi());
+               if( fMCEvent ) {
+                       Int_t labelNegPion = TMath::Abs( negPionCandidate->GetLabel() );
+                       if( labelNegPion < fMCStack->GetNtrack() ){
+                               TParticle* negPion = fMCStack->Particle(labelNegPion);
+                               if( negPion->GetPdgCode() ==  -211 ){
+                                       if( labelNegPion < fMCStack->GetNprimary() ){
+                                               fHistoTrueNegPionPt[fiCut]->Fill(negPionCandidate->Pt());    //primary negPion
+                                       }               
+                                       if( IsEtaPiPlPiMiGammaDaughter(labelNegPion) == kTRUE ) {
+                                               if( labelNegPion < fMCStack->GetNprimary() ) {
+                                                       fHistoTrueNegPionFromEtaPt[fiCut]->Fill(negPionCandidate->Pt());
+                                               } 
+                                       }       
+                               }
+                       }
+               }
+       }
+
+       for(UInt_t i = 0; i < fSelectorPosPionIndex.size(); i++){
+               AliESDtrack* posPionCandidate = fESDEvent->GetTrack( fSelectorPosPionIndex[i] );
+               if(! ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelected(posPionCandidate) ) continue;
+               lGoodPosPionIndexPrev.push_back(   fSelectorPosPionIndex[i]  );
+               fHistoPosPionPt[fiCut]->Fill( posPionCandidate->Pt() );
+               fHistoPosPionPhi[fiCut]->Fill( posPionCandidate->Phi() );
+               
+               if( fMCEvent ) {
+                       Int_t labelPosPion = TMath::Abs( posPionCandidate->GetLabel() );
+                       if( labelPosPion < fMCStack->GetNtrack() ) {
+                               TParticle* posPion = fMCStack->Particle(labelPosPion);
+                               if( posPion->GetPdgCode() ==  211 ){
+                                       if( labelPosPion < fMCStack->GetNprimary() ){
+                                               fHistoTruePosPionPt[fiCut]->Fill(posPionCandidate->Pt());
+                                       } 
+                                       if( IsEtaPiPlPiMiGammaDaughter(labelPosPion) == kTRUE ) {
+                                               if( labelPosPion < fMCStack->GetNprimary() ){
+                                                       fHistoTruePosPionFromEtaPt[fiCut]->Fill(posPionCandidate->Pt());
+                                               } 
+                                       }
+                               }
+                       }
+               }
+       }
+
+
+       for(UInt_t i = 0; i < lGoodNegPionIndexPrev.size(); i++){
+
+               AliESDtrack *negPionCandidate = fESDEvent->GetTrack(lGoodNegPionIndexPrev[i]);
+               AliKFParticle negPionCandidateKF( *negPionCandidate->GetConstrainedParam(), 211 );
+
+               for(UInt_t j = 0; j < lGoodPosPionIndexPrev.size(); j++){
+
+                       AliESDtrack *posPionCandidate = fESDEvent->GetTrack(lGoodPosPionIndexPrev[j]);
+                       AliKFParticle posPionCandidateKF( *posPionCandidate->GetConstrainedParam(), 211 );
+
+                       AliKFConversionPhoton* virtualPhoton = NULL;
+                       virtualPhoton = new AliKFConversionPhoton(negPionCandidateKF,posPionCandidateKF);
+                       AliKFVertex primaryVertexImproved(*fInputEvent->GetPrimaryVertex());
+//                     primaryVertexImproved+=*virtualPhoton;
+                       virtualPhoton->SetProductionVertex(primaryVertexImproved);
+                       virtualPhoton->SetTrackLabels( lGoodPosPionIndexPrev[j], lGoodNegPionIndexPrev[i]);
+                       
+                       
+                       if( fMCEvent ) {
+                               Int_t labeln=TMath::Abs(negPionCandidate->GetLabel());
+                               Int_t labelp=TMath::Abs(posPionCandidate->GetLabel());
+                               TParticle *fNegativeMCParticle = fMCStack->Particle(labeln);
+                               TParticle *fPositiveMCParticle = fMCStack->Particle(labelp);
+                               
+                               if( fPositiveMCParticle && fNegativeMCParticle) {
+                                       virtualPhoton->SetMCLabelPositive(labelp);
+                                       virtualPhoton->SetMCLabelNegative(labeln);
+                               }
+                       }
+                       
+                       AliAODConversionPhoton *vphoton = new AliAODConversionPhoton(virtualPhoton); //To Apply PsiPairCut
+                       fGoodVirtualParticles->Add(  vphoton );
+                       delete virtualPhoton;
+                       virtualPhoton=NULL;
+                                       
+               }
+       }
+}
+
+//_____________________________________________________________________________
+void AliAnalysisTaskEtaToPiPlPiMiGamma::ProcessMCParticles(){
+
+       // Loop over all primary MC particle
+
+       for(Int_t i = 0; i < fMCStack->GetNprimary(); i++) {
+
+               TParticle* particle = (TParticle *)fMCStack->Particle(i);
+               if (!particle) continue;
+
+               Int_t isMCFromMBHeader = -1;
+               if(((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetSignalRejection() != 0){
+                       isMCFromMBHeader
+                               = ((AliConversionCuts*)fGammaCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent);
+                       if(isMCFromMBHeader == 0 && ((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
+               }
+
+               if(((AliConversionCuts*)fGammaCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack,fInputEvent)){
+                       
+                       if(((AliConversionCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCStack,kFALSE)){
+                               fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt()); // All MC Gamma
+                               if(particle->GetMother(0) >-1){
+                                       if (fMCStack->Particle(particle->GetMother(0))->GetPdgCode() ==221 && fMCStack->Particle(particle->GetMother(0))->GetNDaughters()==3 ) fHistoMCGammaFromEtaPt[fiCut]->Fill(particle->Pt()); // All pos from eta
+                               }       
+                       }
+                       
+                       if(((AliConversionCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(particle,fMCStack,kTRUE)){
+                               fHistoMCConvGammaPt[fiCut]->Fill(particle->Pt());
+                       } // Converted MC Gamma
+                       
+                       if(((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(i,fMCStack)){
+                               if( particle->GetPdgCode() == 211){
+                                       fHistoMCAllPosPionsPt[fiCut]->Fill(particle->Pt()); // All pos pions
+                                       if(particle->GetMother(0) >-1){
+                                               if (fMCStack->Particle(particle->GetMother(0))->GetPdgCode() ==221) fHistoMCPosPionsFromEtaPt[fiCut]->Fill(particle->Pt()); // All pos from eta
+                                       }       
+                               }       
+                               if( particle->GetPdgCode() == -211){
+                                       fHistoMCAllNegPionsPt[fiCut]->Fill(particle->Pt()); // All neg pions
+                                       if(particle->GetMother(0) >-1){
+                                               if (fMCStack->Particle(particle->GetMother(0))->GetPdgCode() ==221) fHistoMCNegPionsFromEtaPt[fiCut]->Fill(particle->Pt()); // All pos from eta
+                                       }       
+                               }
+                       }
+                       
+                       // \eta -> \gamma \gamma 
+                       
+                       if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedMC( particle,fMCStack,((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetEtaShift() ) ){
+                               Float_t weighted= 1;
+                               if( ((AliPrimaryPionCuts*) fPionCutArray->At(fiCut))->DoWeights() ) { 
+                                       if(((AliConversionCuts*)fGammaCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent)){
+                                               if (particle->Pt()>0.005){
+                                                       weighted= ((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, fMCStack,fInputEvent);
+                                               }
+                                       }
+                               }
+                               if(particle->GetPdgCode() == 221)fHistoMCEtaGGPt[fiCut]->Fill( particle->Pt() , weighted); // All MC Eta GG decay
+                       }
+                       
+                       // \eta -> e+ e- \gamma 
+                       Int_t labelgamma          = -1;
+                       Int_t labelelectron = -1;
+                       Int_t labelpositron = -1;
+
+                       if( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedMCDalitz(particle,fMCStack,labelelectron,labelpositron,labelgamma,((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetEtaShift())){
+                               Float_t weighted= 1;
+                               if( ((AliPrimaryPionCuts*) fPionCutArray->At(fiCut))->DoWeights() ) { 
+                                       if(((AliConversionCuts*)fGammaCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack,fInputEvent)){
+                                               if (particle->Pt()>0.005){
+                                                       weighted= ((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, fMCStack,fInputEvent);
+                                               }
+                                       }
+                               }
+                               if(particle->GetPdgCode() == 221)fHistoMCEtaDalitzPt[fiCut]->Fill(particle->Pt(), weighted); // All MC Eta
+                       }               
+                       
+                       
+                       // \eta -> pi+ pi- \gamma 
+                       Int_t labelGamma3Body     = -1;
+                       Int_t labelNegPion = -1;
+                       Int_t labelPosPion = -1;
+
+                       if( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedMCEtaPiPlPiMiGamma(particle,fMCStack,labelNegPion,labelPosPion,labelGamma3Body,((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetEtaShift())){       
+                               Float_t weighted= 1;
+                               if( ((AliPrimaryPionCuts*) fPionCutArray->At(fiCut))->DoWeights() ) { 
+                                       if(((AliConversionCuts*)fGammaCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack,fInputEvent)){
+                                               if (particle->Pt()>0.005){
+                                                       weighted= ((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, fMCStack,fInputEvent);
+                                               }
+                                       }
+                               }
+                               if(particle->GetPdgCode() == 221)fHistoMCEtaPiPlPiMiGammaPt[fiCut]->Fill(particle->Pt(), weighted); // All MC Eta
+               
+                               TParticle *gamma    = fMCStack->Particle(labelGamma3Body);
+                               if(((AliConversionCuts*)fGammaCutArray->At(fiCut))->PhotonIsSelectedMC(gamma,fMCStack,kFALSE) &&
+                               ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(labelNegPion,fMCStack) &&
+                               ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->PionIsSelectedMC(labelPosPion,fMCStack) ) {
+                                       if(particle->GetPdgCode() == 221)fHistoMCEtaPiPlPiMiGammaInAccPt[fiCut]->Fill(particle->Pt(), weighted ); // MC EtaDalitz with gamma and e+e- in acc
+                               }                               
+                       }
+               }
+       }
+}
+
+
+//________________________________________________________________________
+void AliAnalysisTaskEtaToPiPlPiMiGamma::CalculateMesonCandidates(){
+
+       // Conversion Gammas
+       if( fGoodGammas->GetEntries() > 0 && fGoodVirtualParticles->GetEntries() > 0 ){
+
+               vector<Bool_t> lGoodVirtualParticle(fGoodVirtualParticles->GetEntries(), kFALSE);
+               
+               for(Int_t GammaIndex=0; GammaIndex<fGoodGammas->GetEntries(); GammaIndex++){
+
+                       AliAODConversionPhoton *gamma=dynamic_cast<AliAODConversionPhoton*>(fGoodGammas->At(GammaIndex));
+                       if (gamma==NULL) continue;
+                       for(Int_t virtualParticleIndex=0;virtualParticleIndex<fGoodVirtualParticles->GetEntries();virtualParticleIndex++){
+
+                               AliAODConversionPhoton *Vgamma=dynamic_cast<AliAODConversionPhoton*>(fGoodVirtualParticles->At(virtualParticleIndex));
+                               if (Vgamma==NULL) continue;
+                               //Check for same Electron ID
+                               if(gamma->GetTrackLabelPositive() == Vgamma->GetTrackLabelPositive() ||
+                               gamma->GetTrackLabelNegative() == Vgamma->GetTrackLabelNegative() ||
+                               gamma->GetTrackLabelNegative() == Vgamma->GetTrackLabelPositive() ||
+                               gamma->GetTrackLabelPositive() == Vgamma->GetTrackLabelNegative() ) continue;
+
+                               AliAODConversionMother *etacand = new AliAODConversionMother(gamma,Vgamma);
+                               etacand->SetLabels(GammaIndex,virtualParticleIndex);
+                                               
+
+                               if( ( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(etacand,kTRUE,((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetEtaShift())) ){
+                       
+                                       //cout<< "Meson Accepted "<<endl;
+                                       
+                                       Int_t zbin= fBGHandler[fiCut]->GetZBinIndex(fESDEvent->GetPrimaryVertex()->GetZ());
+                                       Int_t mbin = 0;
+                                       if( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
+                                               mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fNumberOfESDTracks);
+                                       } else {
+                                               mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGoodGammas->GetEntries());
+                                       }
+                                       
+                                       AliESDtrack *posPionVgamma = 0;
+                                       AliESDtrack *negPionVgamma = 0;
+                                       
+                                       Double_t clsToFPos = -1.0;
+                                       Double_t clsToFNeg = -1.0;
+                                       
+                                       Float_t dcaToVertexXYPos = -1.0;
+                                       Float_t dcaToVertexZPos  = -1.0;
+                                       Float_t dcaToVertexXYNeg = -1.0;
+                                       Float_t dcaToVertexZNeg  = -1.0;
+                                       
+                                       
+                                       if ( fDoMesonQA ) {
+                                       
+                                               posPionVgamma = fESDEvent->GetTrack( Vgamma->GetTrackLabelPositive() );
+                                               negPionVgamma = fESDEvent->GetTrack( Vgamma->GetTrackLabelNegative() );
+                                               clsToFPos = ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetNFindableClustersTPC(posPionVgamma);
+                                               clsToFNeg = ((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetNFindableClustersTPC(negPionVgamma);
+                                               
+                                               Float_t bPos[2];
+                                               Float_t bCovPos[3];
+                                               posPionVgamma->GetImpactParameters(bPos,bCovPos);
+                                               if (bCovPos[0]<=0 || bCovPos[2]<=0) {
+                                                       AliDebug(1, "Estimated b resolution lower or equal zero!");
+                                                       bCovPos[0]=0; bCovPos[2]=0;
+                                               }
+                                               
+                                               Float_t bNeg[2];
+                                               Float_t bCovNeg[3];
+                                               posPionVgamma->GetImpactParameters(bNeg,bCovNeg);
+                                               if (bCovNeg[0]<=0 || bCovNeg[2]<=0) {
+                                                       AliDebug(1, "Estimated b resolution lower or equal zero!");
+                                                       bCovNeg[0]=0; bCovNeg[2]=0;
+                                               }
+                                               
+                                               dcaToVertexXYPos = bPos[0];
+                                               dcaToVertexZPos  = bPos[1];
+                                               dcaToVertexXYNeg = bNeg[0];
+                                               dcaToVertexZNeg  = bNeg[1];
+                                       }
+                                       
+                                       fHistoMotherInvMassPt[fiCut]->Fill(etacand->M(),etacand->Pt());
+                                       Double_t sparesFill[4] = {etacand->M(),etacand->Pt(),(Double_t)zbin,(Double_t)mbin};
+                                       fTHnSparseMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
+                                       
+                                       if ( fDoMesonQA ) {
+                                               if( lGoodVirtualParticle[virtualParticleIndex] == kFALSE ) {
+                                       
+                                                       fHistoNegPionEta[fiCut]->Fill( negPionVgamma->Eta() );
+                                                       fHistoPosPionEta[fiCut]->Fill( posPionVgamma->Eta() );
+                                                                       
+                                                       fHistoNegPionClsTPC[fiCut]->Fill(clsToFNeg,negPionVgamma->Pt());
+                                                       fHistoPosPionClsTPC[fiCut]->Fill(clsToFPos,posPionVgamma->Pt());
+                                                       
+                                                       fHistoPionDCAxy[fiCut]->Fill(  dcaToVertexXYNeg, negPionVgamma->Pt() );
+                                                       fHistoPionDCAz[fiCut]->Fill(   dcaToVertexZNeg,  negPionVgamma->Pt() );
+                                                       fHistoPionDCAxy[fiCut]->Fill(  dcaToVertexXYPos, posPionVgamma->Pt() );
+                                                       fHistoPionDCAz[fiCut]->Fill(   dcaToVertexZPos,  posPionVgamma->Pt() );
+                                                       
+                                                       fHistoPionTPCdEdxNSigma[fiCut]->Fill( posPionVgamma->P(),((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetPIDResponse()->NumberOfSigmasTPC(posPionVgamma, AliPID::kPion) );
+                                                       fHistoPionTPCdEdxNSigma[fiCut]->Fill( negPionVgamma->P(),((AliPrimaryPionCuts*)fPionCutArray->At(fiCut))->GetPIDResponse()->NumberOfSigmasTPC(negPionVgamma, AliPID::kPion) );
+                                                       
+                                                       fHistoPionTPCdEdx[fiCut]->Fill( posPionVgamma->P(), TMath::Abs(posPionVgamma->GetTPCsignal()));
+                                                       fHistoPionTPCdEdx[fiCut]->Fill( negPionVgamma->P(), TMath::Abs(negPionVgamma->GetTPCsignal()));
+                                                       
+                                                       lGoodVirtualParticle[virtualParticleIndex] = kTRUE;
+                                       
+                                               }
+                                       }
+               
+                               
+                                       if(fMCEvent){
+                                               ProcessTrueMesonCandidates(etacand,gamma,Vgamma);
+                                       }
+                               }
+                               delete etacand;
+                               etacand=0x0;
+                       }
+               }
+       }
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskEtaToPiPlPiMiGamma::CalculateBackground(){
+
+       Int_t zbin= fBGHandler[fiCut]->GetZBinIndex(fESDEvent->GetPrimaryVertex()->GetZ());
+       Int_t mbin = 0;
+
+
+       if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
+               mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fNumberOfESDTracks);
+       } else {
+               mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGoodGammas->GetEntries());
+       }
+
+       Int_t method = 1;
+       AliGammaConversionAODBGHandler::GammaConversionVertex *bgEventVertex = NULL;
+       if( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity() ) {
+               for(Int_t nEventsInBG=0;nEventsInBG<fBGHandler[fiCut]->GetNBGEvents();nEventsInBG++){
+                       AliGammaConversionAODVector *previousEventV0s = fBGHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
+                       if(fMoveParticleAccordingToVertex == kTRUE && method == 1){
+                               bgEventVertex = fBGHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
+                       }
+
+                       for(Int_t iCurrent=0;iCurrent<fGoodVirtualParticles->GetEntries();iCurrent++){
+                               AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGoodVirtualParticles->At(iCurrent));
+
+                               for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
+                                       AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
+
+                                       if(fMoveParticleAccordingToVertex == kTRUE && method == 1 ){
+                                               MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
+                                       }
+
+                                       AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
+                                                               
+
+                                       if( ( ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(backgroundCandidate,kFALSE, ((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetEtaShift()))){
+                                               fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
+                                               Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
+                                               fTHnSparseMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
+                                       }
+                                       delete backgroundCandidate;
+                                       backgroundCandidate = 0x0;
+                               }
+                       }
+               }
+       } else {
+               for(Int_t nEventsInBG=0;nEventsInBG <fBGHandler[fiCut]->GetNBGEvents();nEventsInBG++){
+                       AliGammaConversionAODVector *previousEventV0s = fBGHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
+                       if(previousEventV0s){
+                               if(fMoveParticleAccordingToVertex == kTRUE && method == 1){
+                                       bgEventVertex = fBGHandler[fiCut]->GetBGEventVertex(zbin,mbin,nEventsInBG);
+                               }
+                               for(Int_t iCurrent=0;iCurrent<fGoodVirtualParticles->GetEntries();iCurrent++){
+
+                                       AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fGoodVirtualParticles->At(iCurrent));
+
+                                       for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
+
+                                               AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
+
+                                               if(fMoveParticleAccordingToVertex == kTRUE && method ==1){
+                                                       MoveParticleAccordingToVertex(&previousGoodV0,bgEventVertex);
+                                               }
+
+                                               AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
+                                                               
+                                               if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(backgroundCandidate,kFALSE,((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetEtaShift()))){
+                                                       fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
+                                                       Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
+                                                       fTHnSparseMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
+                                               }
+                                               delete backgroundCandidate;
+                                               backgroundCandidate = 0x0;
+                                       }
+                               }
+                       }
+               }
+       }
+}
+
+//______________________________________________________________________
+void AliAnalysisTaskEtaToPiPlPiMiGamma::ProcessTrueMesonCandidates(AliAODConversionMother *EtaCandidate, AliAODConversionPhoton *TrueGammaCandidate, AliAODConversionPhoton *TrueVirtualParticleCandidate){
+
+       // Process True Mesons
+
+       AliStack *MCStack = fMCEvent->Stack();
+
+       if(     TrueGammaCandidate->GetV0Index()<fESDEvent->GetNumberOfV0s()    ){
+               
+               Bool_t isTrueEta = kFALSE;
+               Int_t gammaMCLabel = TrueGammaCandidate->GetMCParticleLabel(MCStack);
+               Int_t gammaMotherLabel = -1;
+               
+               if(gammaMCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
+                       // Daughters Gamma 0
+                       TParticle * negativeMC = (TParticle*)TrueGammaCandidate->GetNegativeMCDaughter(MCStack);
+                       TParticle * positiveMC = (TParticle*)TrueGammaCandidate->GetPositiveMCDaughter(MCStack);
+                       TParticle * gammaMC = (TParticle*)MCStack->Particle(gammaMCLabel);
+
+                       if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){  // Electrons ...
+                               if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
+                                       if(gammaMC->GetPdgCode() == 22){ // ... with Gamma Mother
+                                               gammaMotherLabel=gammaMC->GetFirstMother();
+                                       }
+                               }
+                       }
+               }
+
+               Int_t virtualParticleMCLabel = TrueVirtualParticleCandidate->GetMCParticleLabel(MCStack);
+               Int_t virtualParticleMotherLabel = -1;
+
+               Bool_t isPiPiDecay = kFALSE;
+               Bool_t isDalitz = kFALSE;
+               Bool_t isRealGamma = kFALSE;
+               
+               if(virtualParticleMCLabel != -1){ // if virtualParticleMCLabel==-1 particles don't have same mother 
+                       TParticle * negativeMC = (TParticle*)TrueVirtualParticleCandidate->GetNegativeMCDaughter(MCStack);
+                       TParticle * positiveMC = (TParticle*)TrueVirtualParticleCandidate->GetPositiveMCDaughter(MCStack);
+//                     cout << "neg Part: label - " <<  TrueVirtualParticleCandidate->GetMCLabelNegative() <<" pdg-code - " << negativeMC->GetPdgCode() << endl;
+//                     cout << "pos Part: label - " <<  TrueVirtualParticleCandidate->GetMCLabelPositive() <<" pdg-code - " << positiveMC->GetPdgCode() << endl;
+                       
+                       TParticle * virtualParticleMotherMC = (TParticle*)MCStack->Particle(virtualParticleMCLabel);
+//                     cout << "pdg code same mother - " << virtualParticleMotherMC->GetPdgCode() << endl;
+                       
+                       if(TMath::Abs(negativeMC->GetPdgCode())==211 && TMath::Abs(positiveMC->GetPdgCode())==211){  // Pions ...
+                               virtualParticleMotherLabel=virtualParticleMCLabel;
+                               isPiPiDecay=kTRUE;
+                       } else if(TMath::Abs(negativeMC->GetPdgCode())==11 && TMath::Abs(positiveMC->GetPdgCode())==11){  // Electrons ...
+                               if( virtualParticleMotherMC->GetPdgCode() != 22 ){
+                                       virtualParticleMotherLabel=virtualParticleMCLabel;
+                                       isDalitz = kTRUE;
+                               } else if(negativeMC->GetUniqueID() == 5 && positiveMC->GetUniqueID() ==5){ // ... From Conversion ...
+                                       virtualParticleMotherLabel=virtualParticleMotherMC->GetFirstMother();
+                                       isRealGamma = kTRUE; //no virtual gamma
+                               }
+                       }       
+               }
+
+               if(gammaMotherLabel >= 0 && ( gammaMotherLabel == virtualParticleMotherLabel) ){
+                       if(((TParticle*)MCStack->Particle(virtualParticleMotherLabel))->GetPdgCode() == 221){
+                               isTrueEta=kTRUE;
+                       }
+               }
+
+               if( isTrueEta ){ // True Eta
+                       if ( isPiPiDecay) { //real eta -> Pi+ Pi- Gamma
+                               Float_t weighted= 1;
+                               if( ((AliPrimaryPionCuts*) fPionCutArray->At(fiCut))->DoWeights() ) { 
+                                       if(((AliConversionCuts*)fGammaCutArray->At(fiCut))->IsParticleFromBGEvent(gammaMotherLabel, fMCStack,fInputEvent)){
+                                               if (((TParticle*)MCStack->Particle(gammaMotherLabel))->Pt()>0.005){
+                                                       weighted= ((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),gammaMotherLabel,fMCStack,fInputEvent);
+                                               }
+                                       }
+                               }
+
+                               fHistoTrueMotherPiPlPiMiGammaInvMassPt[fiCut]->Fill(EtaCandidate->M(),EtaCandidate->Pt(),weighted);
+                       } else if ( isRealGamma ){
+                               Float_t weighted= 1;
+                               if( ((AliPrimaryPionCuts*) fPionCutArray->At(fiCut))->DoWeights() ) {
+                                       if(((AliConversionCuts*)fGammaCutArray->At(fiCut))->IsParticleFromBGEvent(gammaMotherLabel, fMCStack,fInputEvent)){
+                                               if (((TParticle*)MCStack->Particle(gammaMotherLabel))->Pt()>0.005){
+                                                       weighted= ((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),gammaMotherLabel,fMCStack,fInputEvent);
+                                               }
+                                       }
+                               }
+
+                               fHistoTrueMotherGammaGammaInvMassPt[fiCut]->Fill(EtaCandidate->M(),EtaCandidate->Pt(),weighted); 
+                       } else if (isDalitz) {
+                               Float_t weighted= 1;
+                               if( ((AliPrimaryPionCuts*) fPionCutArray->At(fiCut))->DoWeights() ) {
+                                       if(((AliConversionCuts*)fGammaCutArray->At(fiCut))->IsParticleFromBGEvent(gammaMotherLabel, fMCStack,fInputEvent)){
+                                               if (((TParticle*)MCStack->Particle(gammaMotherLabel))->Pt()>0.005){
+                                                       weighted= ((AliConversionCuts*)fGammaCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),gammaMotherLabel,fMCStack,fInputEvent);
+                                               }
+                                       }
+                               }
+                               fHistoTrueMotherDalitzInvMassPt[fiCut]->Fill(EtaCandidate->M(),EtaCandidate->Pt(),weighted);
+                       }
+               }
+       }
+}
+
+
+//________________________________________________________________________
+void AliAnalysisTaskEtaToPiPlPiMiGamma::UpdateEventByEventData(){
+   //see header file for documentation
+
+       Int_t method = 1;
+       if( method == 1 ) {
+               if(fGoodGammas->GetEntries() >0 ){
+                       if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
+                               fBGHandler[fiCut]->AddEvent(fGoodGammas,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),0);
+                       } else{ // means we use #V0s for multiplicity
+                               fBGHandler[fiCut]->AddEvent(fGoodGammas,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fGoodGammas->GetEntries(),0);
+                       }
+               }
+       } else if ( method == 2 ){
+               if(fGoodVirtualParticles->GetEntries() > 0 ){
+                       if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
+                               fBGHandler[fiCut]->AddEvent(fGoodVirtualParticles,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),0);
+                       } else{ // means we use #V0s for multiplicity
+                               fBGHandler[fiCut]->AddEvent(fGoodVirtualParticles,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fGoodVirtualParticles->GetEntries(),0);
+                       }
+               }
+       }
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskEtaToPiPlPiMiGamma::MoveParticleAccordingToVertex(AliAODConversionPhoton* particle,const AliGammaConversionAODBGHandler::GammaConversionVertex *vertex){
+   //see header file for documentation
+
+   Double_t dx = vertex->fX - fInputEvent->GetPrimaryVertex()->GetX();
+   Double_t dy = vertex->fY - fInputEvent->GetPrimaryVertex()->GetY();
+   Double_t dz = vertex->fZ - fInputEvent->GetPrimaryVertex()->GetZ();
+
+   Double_t movedPlace[3] = {particle->GetConversionX() - dx,particle->GetConversionY() - dy,particle->GetConversionZ() - dz};
+   particle->SetConversionPoint(movedPlace);
+}
+
+//_____________________________________________________________________________________
+Bool_t AliAnalysisTaskEtaToPiPlPiMiGamma::IsEtaPiPlPiMiGammaDaughter( Int_t label ) const {
+//
+// Returns true if the particle comes from eta -> pi+ pi- gamma
+//
+       Int_t motherLabel = fMCStack->Particle( label )->GetMother(0);
+       if( motherLabel < 0 || motherLabel >= fMCStack->GetNtrack() ) return kFALSE;
+       
+       TParticle* mother = fMCStack->Particle( motherLabel );
+       if( mother->GetPdgCode() != 221 ) return kFALSE;
+       if( IsPiPlPiMiGammaDecay( mother ) ) return kTRUE;      
+       return kFALSE;       
+}
+
+//_____________________________________________________________________________
+Bool_t AliAnalysisTaskEtaToPiPlPiMiGamma::IsPiPlPiMiGammaDecay(TParticle *fMCMother) const
+{
+
+       if( fMCMother->GetNDaughters() != 3 ) return kFALSE;
+       if( fMCMother->GetPdgCode() != 221 ) return kFALSE;
+       
+       
+       TParticle *posPion = 0x0;
+       TParticle *negPion = 0x0;
+       TParticle *gamma    = 0x0;
+       
+       for(Int_t index= fMCMother->GetFirstDaughter();index<= fMCMother->GetLastDaughter();index++){                           
+               TParticle* temp = (TParticle*)fMCStack->Particle( index );
+               
+               switch( temp->GetPdgCode() ) {
+               case 211:
+                       posPion =  temp;
+                       break;
+               case -211:
+                       negPion =  temp;
+                       break;
+               case ::kGamma:
+                       gamma    =  temp;
+                       break;
+               }
+       }
+  
+       if( posPion && negPion && gamma) return kTRUE;
+       
+       return kFALSE;
+}
diff --git a/PWGGA/GammaConv/AliAnalysisTaskEtaToPiPlPiMiGamma.h b/PWGGA/GammaConv/AliAnalysisTaskEtaToPiPlPiMiGamma.h
new file mode 100644 (file)
index 0000000..d1235f3
--- /dev/null
@@ -0,0 +1,172 @@
+#ifndef ALIANALYSISTASKHEAVYMESONTHREEBODY_H
+#define ALIANALYSISTASKHEAVYMESONTHREEBODY_H
+
+/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * See cxx source for full Copyright notice                               */
+
+// Analysis task for pi0->e+e-gamma (Dalitz decay)
+
+#include "AliAnalysisTaskSE.h"
+#include "AliV0ReaderV1.h"
+#include "AliKFConversionPhoton.h"
+#include "AliPrimaryPionSelector.h"
+#include "AliConversionMesonCuts.h"
+#include "AliGammaConversionAODBGHandler.h"
+#include "TProfile2D.h"
+
+class AliESDInputHandler;
+class AliMCEventHandler;
+class AliESDEvent;
+class AliESDtrack;
+class AliESDtrackCuts;
+class AliESDpidCuts;
+class AliV0Reader;
+class AliTriggerAnalysis;
+
+class AliAnalysisTaskEtaToPiPlPiMiGamma: public AliAnalysisTaskSE
+{
+       public:
+
+               AliAnalysisTaskEtaToPiPlPiMiGamma();
+               AliAnalysisTaskEtaToPiPlPiMiGamma( const char* name );
+               virtual ~AliAnalysisTaskEtaToPiPlPiMiGamma();
+
+               virtual void UserExec(Option_t *);
+               virtual void UserCreateOutputObjects();
+               virtual Bool_t Notify();
+               virtual void Terminate(const Option_t *);
+
+                       
+               void SetMoveParticleAccordingToVertex(Bool_t flag){fMoveParticleAccordingToVertex = flag;}
+                       
+               void SetIsHeavyIon(Int_t flag){
+                       if (flag == 1 || flag ==2 ){
+                               fIsHeavyIon = 1;    
+                       } else {
+                               fIsHeavyIon = 0;    
+                       }
+               }
+               
+               void SetIsMC(Bool_t isMC){fIsMC=isMC;}
+               void SetConversionCutList(Int_t nCuts, TList *CutArray){
+                       fnCuts= nCuts;
+                       fGammaCutArray = CutArray;
+               }
+               void SetPionCutList(TList *CutArray){
+                       fPionCutArray = CutArray;
+               }
+               void SetMesonCutList(TList *CutArray){
+                       fMesonCutArray = CutArray;
+               }
+               void SetDoMesonQA(Bool_t flag){ fDoMesonQA = flag; }
+       
+
+       private:
+
+               void InitBack();
+               void ProcessPhotonCandidates();
+               void ProcessTruePhotonCandidates(AliAODConversionPhoton*);
+               void ProcessTrueMesonCandidates(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate, AliAODConversionPhoton *TrueVirtualGammaCandidate);
+               void MoveParticleAccordingToVertex(AliAODConversionPhoton* particle,const AliGammaConversionAODBGHandler::GammaConversionVertex *vertex);
+       void ProcessPionCandidates();
+               void ProcessMCParticles();
+               void CalculateMesonCandidates();
+        void CalculateBackground();
+               void UpdateEventByEventData();
+        
+               Bool_t IsPiPlPiMiGammaDecay(TParticle *fMCMother) const;
+               Bool_t IsEtaPiPlPiMiGammaDaughter( Int_t label ) const;
+               
+               
+
+               AliV0ReaderV1 *fV0Reader;
+               AliPrimaryPionSelector* fPionSelector;
+               AliGammaConversionAODBGHandler **fBGHandler;
+               AliESDEvent *fESDEvent;
+               AliMCEvent *fMCEvent;
+               AliStack *fMCStack;
+               TList **fCutFolder;
+               TList **fESDList;
+               TList **fBackList;
+               TList **fMotherList;
+               TList **fTrueList;
+               TList **fMCList;
+               TList *fOutputContainer;
+               TClonesArray *fReaderGammas;
+               vector<Int_t> fSelectorNegPionIndex;
+               vector<Int_t> fSelectorPosPionIndex;
+               TList *fGoodGammas;
+               TList *fGoodVirtualParticles;
+               TList *fGammaCutArray;
+               TList *fPionCutArray;
+               TList *fMesonCutArray;
+               AliConversionCuts *fConversionCuts;
+               
+               // reconstructed particles
+               TH1F **fHistoConvGammaPt;
+               TH1F **fHistoConvGammaEta;
+               TH1F **fHistoNegPionPt;
+               TH1F **fHistoPosPionPt;
+               TH1F **fHistoNegPionPhi;
+               TH1F **fHistoPosPionPhi;
+               TH1F **fHistoNegPionEta;
+               TH1F **fHistoPosPionEta;
+               TH2F **fHistoNegPionClsTPC;
+               TH2F **fHistoPosPionClsTPC;
+               TH2F **fHistoPionDCAxy;
+               TH2F **fHistoPionDCAz;
+               TH2F **fHistoPionTPCdEdxNSigma;
+               TH2F **fHistoPionTPCdEdx;
+               TH2F **fHistoMotherInvMassPt;
+               THnSparseF **fTHnSparseMotherInvMassPtZM;
+               TH2F **fHistoMotherBackInvMassPt;
+               THnSparseF **fTHnSparseMotherBackInvMassPtZM;
+               
+               // pure MC properties
+               TH1F **fHistoMCAllGammaPt;
+               TH1F **fHistoMCConvGammaPt;
+               TH1F **fHistoMCAllPosPionsPt;
+               TH1F **fHistoMCAllNegPionsPt;
+               TH1F **fHistoMCGammaFromEtaPt;
+               TH1F **fHistoMCPosPionsFromEtaPt;
+               TH1F **fHistoMCNegPionsFromEtaPt;
+               TH1F **fHistoMCEtaPiPlPiMiGammaPt;
+               TH1F **fHistoMCEtaGGPt;
+               TH1F **fHistoMCEtaDalitzPt;
+               TH1F **fHistoMCEtaPiPlPiMiGammaInAccPt;
+               
+               // reconstructed particles MC validated
+               TH2F **fHistoTrueMotherPiPlPiMiGammaInvMassPt;
+               TH2F **fHistoTrueMotherGammaGammaInvMassPt;
+               TH2F **fHistoTrueMotherDalitzInvMassPt;
+               TH1F **fHistoTrueConvGammaPt;
+               TH1F **fHistoTrueConvGammaFromEtaPt;
+               TH1F **fHistoTruePosPionPt;
+               TH1F **fHistoTruePosPionFromEtaPt;
+               TH1F **fHistoTrueNegPionPt;
+               TH1F **fHistoTrueNegPionFromEtaPt;
+               // Event properties
+               TH1I **fHistoNEvents;
+               TH1I **fHistoNGoodESDTracks;
+               TProfile **fProfileEtaShift;
+                       
+               TRandom3 fRandom;
+               Int_t fnCuts;
+               Int_t fiCut;
+               Int_t fNumberOfESDTracks;
+               Bool_t fMoveParticleAccordingToVertex;
+               Bool_t fIsHeavyIon;
+               Bool_t fDoMesonAnalysis;
+               Bool_t fDoMesonQA;
+               Bool_t fIsFromMBHeader;
+               Bool_t fIsMC;
+
+       private:
+               AliAnalysisTaskEtaToPiPlPiMiGamma( const AliAnalysisTaskEtaToPiPlPiMiGamma& ); // Not implemented
+               AliAnalysisTaskEtaToPiPlPiMiGamma& operator=( const AliAnalysisTaskEtaToPiPlPiMiGamma& ); // Not implemented
+
+               ClassDef( AliAnalysisTaskEtaToPiPlPiMiGamma, 1 );
+};
+
+#endif // ALIANALYSISTASKHEAVYMESONTHREEBODY_H
+
index 93df03e..064bc31 100644 (file)
@@ -3807,8 +3807,8 @@ void AliConversionCuts::GetNotRejectedParticles(Int_t rejection, TList *HeaderLi
 
       SetRejectExtraSignalsCut(0);
    }
-
 }
+
 //_________________________________________________________________________
 Int_t AliConversionCuts::IsParticleFromBGEvent(Int_t index, AliStack *MCStack, AliVEvent *InputEvent){
 
@@ -3849,6 +3849,7 @@ Int_t AliConversionCuts::IsParticleFromBGEvent(Int_t index, AliStack *MCStack, A
 
    return accepted;
 }
+
 //_________________________________________________________________________
 Int_t AliConversionCuts::IsEventAcceptedByConversionCut(AliConversionCuts *ReaderCuts, AliVEvent *InputEvent, AliMCEvent *MCEvent, Int_t isHeavyIon){
 
@@ -3882,6 +3883,7 @@ Int_t AliConversionCuts::IsEventAcceptedByConversionCut(AliConversionCuts *Reade
 
    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.Contains("LHC13d2") || 
index ce96091..7ef663b 100644 (file)
@@ -338,6 +338,7 @@ Bool_t AliConversionMesonCuts::MesonIsSelectedAODMC(AliAODMCParticle *MCMother,T
    }
    return kFALSE;
 }
+
 //________________________________________________________________________
 Bool_t AliConversionMesonCuts::MesonIsSelectedMCDalitz(TParticle *fMCMother,AliStack *fMCStack, Int_t &labelelectron, Int_t &labelpositron, Int_t &labelgamma, Double_t fRapidityShift){
 
@@ -391,9 +392,63 @@ Bool_t AliConversionMesonCuts::MesonIsSelectedMCDalitz(TParticle *fMCMother,AliS
 
    if( positron && electron && gamma) return kTRUE;
    return kFALSE;
+}
+
+//________________________________________________________________________
+Bool_t AliConversionMesonCuts::MesonIsSelectedMCEtaPiPlPiMiGamma(TParticle *fMCMother,AliStack *fMCStack, Int_t &labelNegPion, Int_t &labelPosPion, Int_t &labelGamma, Double_t fRapidityShift){
+
+       // Returns true for all pions within acceptance cuts for decay into 2 photons
+       // If bMCDaughtersInAcceptance is selected, it requires in addition that both daughter photons are within acceptance cuts
+
+       if( !fMCStack )return kFALSE;
+
+       if( fMCMother->GetPdgCode() != 221 ) return kFALSE;
+
+       if( fMCMother->R()>fMaxR ) return kFALSE; // cuts on distance from collision point
 
+       Double_t rapidity = 10.;
 
+       if( fMCMother->Energy() - fMCMother->Pz() == 0 || fMCMother->Energy() + fMCMother->Pz() == 0 ){
+               rapidity=8.-fRapidityShift;
+       }
+       else{
+               rapidity = 0.5*(TMath::Log((fMCMother->Energy()+fMCMother->Pz()) / (fMCMother->Energy()-fMCMother->Pz())))-fRapidityShift;
+       }
+
+       // Rapidity Cut
+       if( abs(rapidity) > fRapidityCutMeson )return kFALSE;
+
+       // Select only -> Dalitz decay channel
+       if( fMCMother->GetNDaughters() != 3 )return kFALSE;
+
+       TParticle *posPion = 0x0;
+       TParticle *negPion = 0x0;
+       TParticle    *gamma = 0x0;
+
+       for(Int_t index= fMCMother->GetFirstDaughter();index<= fMCMother->GetLastDaughter();index++){
+
+               TParticle* temp = (TParticle*)fMCStack->Particle( index );
+
+               switch( temp->GetPdgCode() ) {
+               case 211:
+                       posPion      =  temp;
+                       labelPosPion = index;
+                       break;
+               case -211:
+                       negPion      =  temp;
+                       labelNegPion = index;
+                       break;
+               case ::kGamma:
+                       gamma         =  temp;
+                       labelGamma    = index;
+                       break;
+               }
+       }
+
+       if( posPion && negPion && gamma) return kTRUE;
+       return kFALSE;
 }
+
 //________________________________________________________________________
 Bool_t AliConversionMesonCuts::MesonIsSelectedMCChiC(TParticle *fMCMother,AliStack *fMCStack,Int_t & labelelectronChiC, Int_t & labelpositronChiC, Int_t & labelgammaChiC, Double_t fRapidityShift){
    // Returns true for all ChiC within acceptance cuts for decay into JPsi + gamma -> e+ + e- + gamma
index 2de9314..5805a6b 100644 (file)
@@ -80,6 +80,7 @@ class AliConversionMesonCuts : public AliAnalysisCuts {
   Bool_t MesonIsSelectedMC(TParticle *fMCMother,AliStack *fMCStack, Double_t fRapidityShift=0.);
   Bool_t MesonIsSelectedAODMC(AliAODMCParticle *MCMother,TClonesArray *AODMCArray, Double_t fRapidityShift=0.);
   Bool_t MesonIsSelectedMCDalitz(TParticle *fMCMother,AliStack *fMCStack, Int_t &labelelectron, Int_t &labelpositron, Int_t &labelgamma,Double_t fRapidityShift=0.);
+  Bool_t MesonIsSelectedMCEtaPiPlPiMiGamma(TParticle *fMCMother,AliStack *fMCStack, Int_t &labelNegPion, Int_t &labelPosPion, Int_t &labelGamma, Double_t fRapidityShift=0);
   Bool_t MesonIsSelectedMCChiC(TParticle *fMCMother,AliStack *fMCStack, Int_t &, Int_t &, Int_t &, Double_t fRapidityShift=0. );
   void PrintCuts();
 
index c6d3d72..509a2ec 100644 (file)
@@ -108,6 +108,7 @@ AliDalitzElectronCuts::AliDalitzElectronCuts(const char *name,const char *title)
     fPIDMinPProtonRejectionLowP(2.0),
     fPIDMinPPionRejectionLowP(0.5),
     fUseCorrectedTPCClsInfo(kFALSE),
+    fUseCrossedRows(kFALSE),
     fUseTOFpid(kFALSE),
     fRequireTOF(kFALSE),
     fUseTrackMultiplicityForBG(kFALSE),
@@ -660,7 +661,8 @@ Double_t AliDalitzElectronCuts::GetNFindableClustersTPC(AliESDtrack* lTrack){
   
   
   Double_t clsToF=0;
-
+  
+  if( fUseCrossedRows == kFALSE ) {
 
     if ( !fUseCorrectedTPCClsInfo ){
         if(lTrack->GetTPCNclsF()!=0){
@@ -674,6 +676,14 @@ Double_t AliDalitzElectronCuts::GetNFindableClustersTPC(AliESDtrack* lTrack){
               clsToF = lTrack->GetTPCClusterInfo(2,0); //NOTE ask friederike
                 
     }
+  } else  {
+   
+        Float_t nCrossedRowsTPC = lTrack->GetTPCCrossedRows();
+        clsToF = 1.0;
+         if ( lTrack->GetTPCNclsF()>0 ) {
+             clsToF = nCrossedRowsTPC / lTrack->GetTPCNclsF();
+         }     
+    }
   
   return clsToF;
    
@@ -725,10 +735,10 @@ Bool_t AliDalitzElectronCuts::UpdateCutString(cutIds cutID, Int_t value) {
 ///Update the cut string (if it has been created yet)
 
   if(fCutString && fCutString->GetString().Length() == kNCuts) {
-//         cout << "Updating cut id in spot number " << cutID << " to " << value << endl;
+         cout << "Updating cut id in spot number " << cutID << " to " << value << endl;
        fCutString->SetString(GetCutNumber());
   } else {
-//         cout << "fCutString not yet initialized, will not be updated" << endl;
+         cout << "fCutString not yet initialized, will not be updated" << endl;
        return kFALSE;
   }
  // cout << fCutString->GetString().Data() << endl;
@@ -1199,9 +1209,11 @@ Bool_t AliDalitzElectronCuts::SetTPCClusterCut(Int_t clsTPCCut)
                fMinClsTPC= 80.;
                fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
                break;
-       case 3:  // 100
-               fMinClsTPC= 100.;
-               fesdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
+       case 3:  // Changed 2014-02-04  before fMinClsTPC = 50.;
+               fMinClsTPCToF = 0.8;
+               fesdTrackCuts->SetMinNCrossedRowsTPC(70);
+               fesdTrackCuts->SetMinNClustersTPC(0);
+               fUseCrossedRows = kTRUE;
                break;
        case 4:  // 0% of findable clusters
                fMinClsTPC= 70.;  
@@ -1350,6 +1362,10 @@ Bool_t AliDalitzElectronCuts::SetDCACut(Int_t dcaCut)
                fesdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
                break; 
                
+       case 3: fesdTrackCuts->SetMaxDCAToVertexXYPtDep("0.0105+0.0350/pt^1.1");
+               fesdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
+               break;
+               
        default:
                cout<<"Warning: dcaCut not defined "<<dcaCut<<endl;
                return kFALSE;
@@ -1558,14 +1574,13 @@ Bool_t AliDalitzElectronCuts::SetPsiPairCut(Int_t psiCut) {
         fPsiPairCut = 0.52;
         fDeltaPhiCutMin = 0.0;
         fDeltaPhiCutMax = 0.12;
-        break;
   case 4:
         fDoPsiPairCut = kTRUE;
         fPsiPairCut = 0.30;
         fDeltaPhiCutMin = 0.0;
         fDeltaPhiCutMax = 0.12;
         break;
-      
+    
   default:
       cout<<"Warning: PsiPairCut not defined "<<fPsiPairCut<<endl;
       return kFALSE;
index bf5857c..5c7ce1f 100644 (file)
@@ -205,6 +205,7 @@ class AliDalitzElectronCuts : public AliAnalysisCuts {
   Double_t fPIDMinPPionRejectionLowP; // Momentum limit to apply proton rejection
 
   Bool_t   fUseCorrectedTPCClsInfo; // flag to use corrected tpc cl info
+  Bool_t   fUseCrossedRows;  //UseCrossedRows 2011
   Bool_t   fUseTOFpid; // flag to use tof pid
   Bool_t   fRequireTOF; //flg to analyze only tracks with TOF signal
   Bool_t   fUseTrackMultiplicityForBG; // use multiplicity
diff --git a/PWGGA/GammaConv/AliPrimaryPionCuts.cxx b/PWGGA/GammaConv/AliPrimaryPionCuts.cxx
new file mode 100644 (file)
index 0000000..b3f99a1
--- /dev/null
@@ -0,0 +1,982 @@
+
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved.      *
+ *                                                                                                                                             *
+ * Authors: Friederike Bock                                                                                                    *
+ * Version 1.0                                                                                                                         *
+ *                                                                                                                                                     *
+ * Permission to use, copy, modify and distribute this software and its                *
+ * documentation strictly for non-commercial purposes is hereby granted                *
+ * without fee, provided that the above copyright notice appears in all                *
+ * copies and that both the copyright notice and this permission notice                *
+ * appear in the supporting documentation. The authors make no claims          *
+ * about the suitability of this software for any purpose. It is                       *
+ * provided "as is" without express or implied warranty.                                       *
+ **************************************************************************/
+
+////////////////////////////////////////////////
+//--------------------------------------------- 
+// Class handling all kinds of selection cuts for
+// Gamma Conversion analysis
+//---------------------------------------------
+////////////////////////////////////////////////
+
+
+#include "AliPrimaryPionCuts.h"
+#include "AliAODConversionPhoton.h"
+#include "AliKFVertex.h"
+#include "AliAODTrack.h"
+#include "AliESDtrack.h"
+#include "AliAnalysisManager.h"
+#include "AliInputEventHandler.h"
+#include "AliMCEventHandler.h"
+#include "AliAODHandler.h"
+#include "AliPIDResponse.h"
+#include "TH1.h"
+#include "TH2.h"
+#include "AliStack.h"
+#include "TObjString.h"
+#include "AliAODEvent.h"
+#include "AliESDEvent.h"
+#include "TList.h"
+class iostream;
+
+using namespace std;
+
+ClassImp(AliPrimaryPionCuts)
+
+
+const char* AliPrimaryPionCuts::fgkCutNames[AliPrimaryPionCuts::kNCuts] = {
+       "kEtaCut",
+       "kClsITSCut",
+       "kClsTPCCut",
+       "kDCAcut",      
+       "kPtCut",
+       "kPiDedxSigmaITSCut",
+       "kPiDedxSigmaTPCCut",
+       "kPiTOFSigmaCut",
+};
+
+//________________________________________________________________________
+AliPrimaryPionCuts::AliPrimaryPionCuts(const char *name,const char *title) : AliAnalysisCuts(name,title),
+       fHistograms(NULL),
+       fPIDResponse(NULL),
+       fEsdTrackCuts(NULL),
+       fEtaCut(0.9),
+       fEtaShift(0.0),
+       fDoEtaCut(kFALSE),
+       fPtCut(0.0),
+       fMinClsTPC(0), // minimum clusters in the TPC
+       fMinClsTPCToF(0), // minimum clusters to findable clusters
+       fDodEdxSigmaITSCut(kFALSE),
+       fDodEdxSigmaTPCCut(kTRUE),
+       fDoTOFsigmaCut(kFALSE), // RRnewTOF
+       fPIDnSigmaAbovePionLineITS(100),
+       fPIDnSigmaBelowPionLineITS(-100),
+       fPIDnSigmaAbovePionLineTPC(100),
+       fPIDnSigmaBelowPionLineTPC(-100),
+       fPIDnSigmaAbovePionLineTOF(100), // RRnewTOF
+       fPIDnSigmaBelowPionLineTOF(-100), // RRnewTOF
+       fUseCorrectedTPCClsInfo(kFALSE),
+       fUseTOFpid(kFALSE),
+       fRequireTOF(kFALSE),
+       fDoWeights(kFALSE),
+       fCutString(NULL),
+       fHistCutIndex(NULL),
+       fHistdEdxCuts(NULL),
+       fHistITSdEdxbefore(NULL),
+       fHistITSdEdxafter(NULL),
+       fHistTPCdEdxbefore(NULL),
+       fHistTPCdEdxafter(NULL),
+       fHistTPCdEdxSignalbefore(NULL),
+       fHistTPCdEdxSignalafter(NULL),
+       fHistTOFbefore(NULL),
+       fHistTOFafter(NULL),
+       fHistTrackDCAxyPtbefore(NULL),
+       fHistTrackDCAxyPtafter(NULL),
+       fHistTrackDCAzPtbefore(NULL),
+       fHistTrackDCAzPtafter(NULL),
+       fHistTrackNFindClsPtTPCbefore(NULL),
+       fHistTrackNFindClsPtTPCafter(NULL)
+{
+       InitPIDResponse();
+       for(Int_t jj=0;jj<kNCuts;jj++){ fCuts[jj]=0; }
+       fCutString=new TObjString((GetCutNumber()).Data());
+
+       // Using standard function for setting Cuts
+       Bool_t selectPrimaries=kFALSE;
+       fEsdTrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(selectPrimaries);
+}
+
+//________________________________________________________________________
+AliPrimaryPionCuts::~AliPrimaryPionCuts() {
+               // Destructor
+       //Deleting fHistograms leads to seg fault it it's added to output collection of a task
+       // if(fHistograms)
+       //      delete fHistograms;
+       // fHistograms = NULL;
+
+       if(fCutString != NULL){
+               delete fCutString;
+               fCutString = NULL;
+       }
+}
+
+//________________________________________________________________________
+void AliPrimaryPionCuts::InitCutHistograms(TString name, Bool_t preCut,TString cutNumber){
+
+       // Initialize Cut Histograms for QA (only initialized and filled if function is called)
+
+       TString cutName = "";
+       
+       if( cutNumber==""){
+               cutName = GetCutNumber().Data();
+       }
+       else {
+               cutName = cutNumber.Data();
+       } 
+
+       if(fHistograms != NULL){
+               delete fHistograms;
+               fHistograms=NULL;
+       }
+       if(fHistograms==NULL){
+               fHistograms=new TList();
+               if(name=="")fHistograms->SetName(Form("PionCuts_%s",cutName.Data()));
+               else fHistograms->SetName(Form("%s_%s",name.Data(),cutName.Data()));
+       }
+
+
+       fHistCutIndex=new TH1F(Form("IsPionSelected %s",cutName.Data()),"IsPionSelected",10,-0.5,9.5);
+       fHistCutIndex->GetXaxis()->SetBinLabel(kPionIn+1,"in");
+       fHistCutIndex->GetXaxis()->SetBinLabel(kNoTracks+1,"no tracks");
+       fHistCutIndex->GetXaxis()->SetBinLabel(kTrackCuts+1,"Track cuts");
+       fHistCutIndex->GetXaxis()->SetBinLabel(kdEdxCuts+1,"dEdx");
+       fHistCutIndex->GetXaxis()->SetBinLabel(kPionOut+1,"out");
+       fHistograms->Add(fHistCutIndex);
+
+       // dEdx Cuts
+       fHistdEdxCuts=new TH1F(Form("dEdxCuts %s",cutName.Data()),"dEdxCuts",5,-0.5,4.5);
+       fHistdEdxCuts->GetXaxis()->SetBinLabel(1,"in");
+       fHistdEdxCuts->GetXaxis()->SetBinLabel(2,"ITSpion");
+       fHistdEdxCuts->GetXaxis()->SetBinLabel(3,"TPCpion");
+       fHistdEdxCuts->GetXaxis()->SetBinLabel(4,"TOFpion");
+       fHistdEdxCuts->GetXaxis()->SetBinLabel(5,"out");
+       fHistograms->Add(fHistdEdxCuts);
+       
+       TAxis *axisBeforeITS  = NULL;
+       TAxis *axisBeforedEdx = NULL;
+       TAxis *axisBeforeTOF  = NULL;
+       TAxis *axisBeforedEdxSignal = NULL;
+
+       if(preCut){
+               fHistITSdEdxbefore=new TH2F(Form("Pion_ITS_before %s",cutName.Data()),"ITS dEdx pion before" ,150,0.05,20,400,-10,10);
+               fHistograms->Add(fHistITSdEdxbefore);
+               axisBeforeITS = fHistITSdEdxbefore->GetXaxis();
+
+               fHistTPCdEdxbefore=new TH2F(Form("Pion_dEdx_before %s",cutName.Data()),"dEdx pion before" ,150,0.05,20,400,-10,10);
+               fHistograms->Add(fHistTPCdEdxbefore);
+               axisBeforedEdx = fHistTPCdEdxbefore->GetXaxis();
+
+               fHistTPCdEdxSignalbefore=new TH2F(Form("Pion_dEdxSignal_before %s",cutName.Data()),"dEdx pion signal before" ,150,0.05,20.0,800,0.0,200);
+               fHistograms->Add(fHistTPCdEdxSignalbefore);
+               axisBeforedEdxSignal = fHistTPCdEdxSignalbefore->GetXaxis();
+
+               fHistTOFbefore=new TH2F(Form("Pion_TOF_before %s",cutName.Data()),"TOF pion before" ,150,0.05,20,400,-6,10);
+               fHistograms->Add(fHistTOFbefore);
+               axisBeforeTOF = fHistTOFbefore->GetXaxis();
+               
+               fHistTrackDCAxyPtbefore = new TH2F(Form("hTrack_DCAxy_Pt_before %s",cutName.Data()),"DCAxy Vs Pt of tracks before",800,-4.0,4.0,400,0.,10.);
+               fHistograms->Add(fHistTrackDCAxyPtbefore);      
+               
+               fHistTrackDCAzPtbefore  = new TH2F(Form("hTrack_DCAz_Pt_before %s",cutName.Data()), "DCAz  Vs Pt of tracks before",800,-4.0,4.0,400,0.,10.);
+               fHistograms->Add(fHistTrackDCAzPtbefore); 
+               
+               fHistTrackNFindClsPtTPCbefore = new TH2F(Form("hTrack_NFindCls_Pt_TPC_before %s",cutName.Data()),"Track: N Findable Cls TPC Vs Pt before",100,0,1,400,0.,10.);
+               fHistograms->Add(fHistTrackNFindClsPtTPCbefore); 
+       }
+
+       fHistITSdEdxafter=new TH2F(Form("Pion_ITS_after %s",cutName.Data()),"ITS dEdx pion after" ,150,0.05,20,400, -10,10);
+       fHistograms->Add(fHistITSdEdxafter);
+
+       fHistTPCdEdxafter=new TH2F(Form("Pion_dEdx_after %s",cutName.Data()),"dEdx pion after" ,150,0.05,20,400, -10,10);
+       fHistograms->Add(fHistTPCdEdxafter);
+
+       fHistTPCdEdxSignalafter=new TH2F(Form("Pion_dEdxSignal_after %s",cutName.Data()),"dEdx pion signal after" ,150,0.05,20.0,800,0.0,200);
+       fHistograms->Add(fHistTPCdEdxSignalafter);
+
+       fHistTOFafter=new TH2F(Form("Pion_TOF_after %s",cutName.Data()),"TOF pion after" ,150,0.05,20,400,-6,10);
+       fHistograms->Add(fHistTOFafter);
+       
+       fHistTrackDCAxyPtafter  = new TH2F(Form("hTrack_DCAxy_Pt_after %s",cutName.Data()),"DCAxy Vs Pt of tracks after",800,-4.0,4.0,400,0.,10.);
+       fHistograms->Add(fHistTrackDCAxyPtafter); 
+       
+       fHistTrackDCAzPtafter  = new TH2F(Form("hTrack_DCAz_Pt_after %s",cutName.Data()), "DCAz Vs Pt of tracks  after",800,-4.0,4.0,400,0.,10.);
+       fHistograms->Add(fHistTrackDCAzPtafter); 
+       
+       fHistTrackNFindClsPtTPCafter = new TH2F(Form("hTrack_NFindCls_Pt_TPC_after %s",cutName.Data()),"Track: N Findable Cls TPC Vs Pt after",100,0,1,400,0.,10.);
+       fHistograms->Add(fHistTrackNFindClsPtTPCafter); 
+       
+       TAxis *AxisAfter = fHistTPCdEdxafter->GetXaxis(); 
+       Int_t bins = AxisAfter->GetNbins();
+       Double_t from = AxisAfter->GetXmin();
+       Double_t to = AxisAfter->GetXmax();
+       Double_t *newBins = new Double_t[bins+1];
+       newBins[0] = from;
+       Double_t factor = TMath::Power(to/from, 1./bins);
+       for(Int_t i=1; i<=bins; ++i) newBins[i] = factor * newBins[i-1];
+       AxisAfter->Set(bins, newBins);
+       AxisAfter = fHistTOFafter->GetXaxis(); 
+       AxisAfter->Set(bins, newBins);
+       AxisAfter = fHistITSdEdxafter->GetXaxis();
+       AxisAfter->Set(bins,newBins); 
+       AxisAfter = fHistTPCdEdxSignalafter->GetXaxis();
+       AxisAfter->Set(bins,newBins);
+       
+       if(preCut){
+               axisBeforeITS->Set(bins, newBins);
+               axisBeforedEdx->Set(bins, newBins);
+               axisBeforedEdxSignal->Set(bins,newBins);
+               axisBeforeTOF->Set(bins, newBins);
+       
+       }
+       delete [] newBins;
+       
+       // Event Cuts and Info
+}
+
+
+//________________________________________________________________________
+Bool_t AliPrimaryPionCuts::InitPIDResponse(){
+
+// Set Pointer to AliPIDResponse
+
+  AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
+
+  if(man) {
+    AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
+    fPIDResponse = (AliPIDResponse*)inputHandler->GetPIDResponse();
+    if(fPIDResponse)return kTRUE;
+
+  }
+
+  return kFALSE;
+}
+///________________________________________________________________________
+Bool_t AliPrimaryPionCuts::PionIsSelectedMC(Int_t labelParticle,AliStack *fMCStack){
+       
+       if( labelParticle < 0 || labelParticle >= fMCStack->GetNtrack() ) return kFALSE;
+       if( fMCStack->IsPhysicalPrimary(labelParticle) == kFALSE ) return kFALSE; 
+
+       TParticle* particle = fMCStack->Particle(labelParticle);
+
+       if( TMath::Abs( particle->GetPdgCode() ) != 211 )  return kFALSE;
+       
+       if( fDoEtaCut ){
+       if( particle->Eta() > (fEtaCut + fEtaShift) || particle->Eta() < (-fEtaCut + fEtaShift) )
+               return kFALSE;
+       }
+       
+       return kTRUE;
+}
+
+
+///________________________________________________________________________
+Bool_t AliPrimaryPionCuts::PionIsSelected(AliESDtrack* lTrack){
+    //Selection of Reconstructed electrons
+       
+       Float_t b[2];
+       Float_t bCov[3];
+       lTrack->GetImpactParameters(b,bCov);
+
+       if (bCov[0]<=0 || bCov[2]<=0) {
+               AliDebug(1, "Estimated b resolution lower or equal zero!");
+               bCov[0]=0; bCov[2]=0;
+       }
+
+       Float_t dcaToVertexXY = b[0];
+       Float_t dcaToVertexZ  = b[1];
+       Double_t clsToF = GetNFindableClustersTPC(lTrack);
+
+       if (fHistTrackDCAxyPtbefore) fHistTrackDCAxyPtbefore->Fill(dcaToVertexXY,lTrack->Pt());
+       if (fHistTrackDCAzPtbefore) fHistTrackDCAzPtbefore->Fill( dcaToVertexZ, lTrack->Pt());
+       if (fHistTrackNFindClsPtTPCbefore) fHistTrackNFindClsPtTPCbefore->Fill( clsToF, lTrack->Pt());
+
+       if (fHistCutIndex) fHistCutIndex->Fill(kPionIn);
+
+       if (lTrack == NULL){
+               if (fHistCutIndex) fHistCutIndex->Fill(kNoTracks);
+               return kFALSE;  
+       }   
+       
+       if ( ! lTrack->GetConstrainedParam() ){
+               return kFALSE;
+       }
+       AliVTrack * track = dynamic_cast<AliVTrack*>(lTrack);
+
+       // Track Cuts
+       if( !TrackIsSelected(lTrack) ){
+               if (fHistCutIndex) fHistCutIndex->Fill(kTrackCuts);
+               return kFALSE;
+       }
+
+       // dEdx Cuts
+       if( ! dEdxCuts( track ) ) {
+               if(fHistCutIndex)fHistCutIndex->Fill(kdEdxCuts);
+               return kFALSE;
+
+       }
+
+       //Pion passed the cuts
+       if (fHistCutIndex) fHistCutIndex->Fill(kPionOut);
+       if (fHistTrackDCAxyPtafter) fHistTrackDCAxyPtafter->Fill(dcaToVertexXY,lTrack->Pt());
+       if (fHistTrackDCAzPtafter) fHistTrackDCAzPtafter->Fill(dcaToVertexZ,lTrack->Pt());
+       if (fHistTrackNFindClsPtTPCafter) fHistTrackNFindClsPtTPCafter->Fill( clsToF, lTrack->Pt());
+
+       return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliPrimaryPionCuts::TrackIsSelected(AliESDtrack* lTrack) {
+       // Track Selection for Photon Reconstruction
+       
+       Double_t clsToF = GetNFindableClustersTPC(lTrack);
+       
+       if( ! fEsdTrackCuts->AcceptTrack(lTrack) ){
+               return kFALSE;
+       }
+               
+       if( fDoEtaCut ) {
+               if(  lTrack->Eta() > (fEtaCut + fEtaShift) || lTrack->Eta() < (-fEtaCut + fEtaShift) ) {
+                       return kFALSE;
+               }
+       }
+       
+       if( lTrack->Pt() < fPtCut ) {
+               return kFALSE;          
+       }
+
+       if( clsToF < fMinClsTPCToF){
+               return kFALSE;
+       }
+
+       return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliPrimaryPionCuts::dEdxCuts(AliVTrack *fCurrentTrack){
+
+       // Pion Identification Cuts for Photon reconstruction
+
+       if(!fPIDResponse){  InitPIDResponse();  }// Try to reinitialize PID Response
+       if(!fPIDResponse){  AliError("No PID Response"); return kFALSE;}// if still missing fatal error
+
+       Int_t cutIndex=0;
+
+       if(fHistdEdxCuts)fHistdEdxCuts->Fill(cutIndex);
+       if(fHistITSdEdxbefore)fHistITSdEdxbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasITS(fCurrentTrack, AliPID::kPion));
+       if(fHistTPCdEdxbefore)fHistTPCdEdxbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTPC(fCurrentTrack, AliPID::kPion));
+       if(fHistTPCdEdxSignalbefore)fHistTPCdEdxSignalbefore->Fill(fCurrentTrack->P(),TMath::Abs(fCurrentTrack->GetTPCsignal()));
+
+       cutIndex++;
+
+       if( fDodEdxSigmaITSCut == kTRUE ){
+               if( fPIDResponse->NumberOfSigmasITS(fCurrentTrack,AliPID::kPion)<fPIDnSigmaBelowPionLineITS ||
+                               fPIDResponse->NumberOfSigmasITS(fCurrentTrack,AliPID::kPion)> fPIDnSigmaAbovePionLineITS ){     
+                       if(fHistdEdxCuts)fHistdEdxCuts->Fill(cutIndex);
+                       return kFALSE;
+               }
+       }
+               
+       if(fHistITSdEdxafter)fHistITSdEdxafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasITS(fCurrentTrack, AliPID::kPion));
+       
+       
+       cutIndex++;
+               
+               
+       if(fDodEdxSigmaTPCCut == kTRUE){
+               // TPC Pion Line
+               if( fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)<fPIDnSigmaBelowPionLineTPC ||
+                       fPIDResponse->NumberOfSigmasTPC(fCurrentTrack,AliPID::kPion)>fPIDnSigmaAbovePionLineTPC){
+                       if(fHistdEdxCuts)fHistdEdxCuts->Fill(cutIndex);
+                       return kFALSE;
+               }
+               cutIndex++;
+       } else { cutIndex+=1; }
+       
+       if( ( fCurrentTrack->GetStatus() & AliESDtrack::kTOFpid ) && ( !( fCurrentTrack->GetStatus() & AliESDtrack::kTOFmismatch) ) ){
+               if(fHistTOFbefore) fHistTOFbefore->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kPion));
+               if(fUseTOFpid){
+                       if( fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kPion)>fPIDnSigmaAbovePionLineTOF ||
+                               fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kPion)<fPIDnSigmaBelowPionLineTOF ){
+                               if(fHistdEdxCuts)fHistdEdxCuts->Fill(cutIndex);
+                               return kFALSE;
+                       }
+               }
+               if(fHistTOFafter)fHistTOFafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTOF(fCurrentTrack, AliPID::kPion));
+       } else if ( fRequireTOF == kTRUE ) {
+               if(fHistdEdxCuts)fHistdEdxCuts->Fill(cutIndex);
+               return kFALSE;
+       }
+       cutIndex++;
+               
+       if(fHistdEdxCuts)fHistdEdxCuts->Fill(cutIndex);
+       if(fHistTPCdEdxafter)fHistTPCdEdxafter->Fill(fCurrentTrack->P(),fPIDResponse->NumberOfSigmasTPC(fCurrentTrack, AliPID::kPion));
+       if(fHistTPCdEdxSignalafter)fHistTPCdEdxSignalafter->Fill(fCurrentTrack->P(),TMath::Abs(fCurrentTrack->GetTPCsignal()));
+       
+       return kTRUE;
+}
+
+///________________________________________________________________________
+AliVTrack *AliPrimaryPionCuts::GetTrack(AliVEvent * event, Int_t label){
+    //Returns pointer to the track with given ESD label
+    //(Important for AOD implementation, since Track array in AOD data is different
+    //from ESD array, but ESD tracklabels are stored in AOD Tracks)
+
+       AliESDEvent * esdEvent = dynamic_cast<AliESDEvent*>(event);
+       if(esdEvent) {
+               if(label > event->GetNumberOfTracks() ) return NULL;
+               AliESDtrack * track = esdEvent->GetTrack(label);
+               return track;           
+       } else { 
+               for(Int_t ii=0; ii<event->GetNumberOfTracks(); ii++) {
+                       AliVTrack * track = dynamic_cast<AliVTrack*>(event->GetTrack(ii));              
+                       if(track) { 
+                               if(track->GetID() == label) {
+                                       return track;
+                               }
+                       }
+               }
+       }
+       cout << "track not found " << label << " " << event->GetNumberOfTracks() << endl;
+       return NULL;
+}
+
+///________________________________________________________________________
+Double_t AliPrimaryPionCuts::GetNFindableClustersTPC(AliESDtrack* lTrack){
+
+       Double_t clsToF=0;
+       if ( !fUseCorrectedTPCClsInfo ){
+               if(lTrack->GetTPCNclsF()!=0){
+                       clsToF = (Double_t)lTrack->GetNcls(1)/(Double_t)lTrack->GetTPCNclsF();
+               }
+       } else {
+               clsToF = lTrack->GetTPCClusterInfo(2,0); //NOTE ask friederike  
+       }
+       return clsToF;
+
+}
+
+///________________________________________________________________________
+Bool_t AliPrimaryPionCuts::UpdateCutString() {
+///Update the cut string (if it has been created yet)
+
+       if(fCutString && fCutString->GetString().Length() == kNCuts) {
+               fCutString->SetString(GetCutNumber());
+       } else {
+               return kFALSE;
+       }
+       return kTRUE;
+
+}
+
+///________________________________________________________________________
+Bool_t AliPrimaryPionCuts::InitializeCutsFromCutString(const TString analysisCutSelection ) {
+       // Initialize Cuts from a given Cut string
+
+       AliInfo(Form("Set PionCuts 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));
+               return kFALSE;
+       }
+       if(!analysisCutSelection.IsDigit()){
+               AliError("Cut selection contains characters");
+               return kFALSE;
+       }
+       
+       const char *cutSelection = analysisCutSelection.Data();
+       #define ASSIGNARRAY(i)  fCuts[i] = cutSelection[i] - '0'
+       for(Int_t ii=0;ii<kNCuts;ii++){
+               ASSIGNARRAY(ii);
+       }
+
+       // Set Individual Cuts
+       for(Int_t ii=0;ii<kNCuts;ii++){
+               if(!SetCut(cutIds(ii),fCuts[ii]))return kFALSE;
+       }
+
+       PrintCuts();
+       return kTRUE;
+}
+///________________________________________________________________________
+Bool_t AliPrimaryPionCuts::SetCut(cutIds cutID, const Int_t value) {
+       ///Set individual cut ID
+
+       //cout << "Updating cut  " << fgkCutNames[cutID] << " (" << cutID << ") to " << value << endl;
+
+       switch (cutID) {
+               case kEtaCut:
+                       if( SetEtaCut(value)) {
+                               fCuts[kEtaCut] = value;
+                               UpdateCutString();
+                               return kTRUE;
+                       } else return kFALSE;
+               case kClsITSCut:
+                       if( SetITSClusterCut(value) ) {
+                               fCuts[kClsITSCut] = value;
+                               UpdateCutString();
+                               return kTRUE;                   
+                       } else return kFALSE;
+               case kClsTPCCut:
+                       if( SetTPCClusterCut(value)) {
+                               fCuts[kClsTPCCut] = value;
+                               UpdateCutString();
+                               return kTRUE;
+                       } else return kFALSE;
+               case kDCACut:
+                       if( SetDCACut(value)) {
+                               fCuts[kDCACut] = value;
+                               UpdateCutString();
+                               return kTRUE;
+                       } else return kFALSE;
+               case kPtCut:    
+                       if( SetPtCut(value)) {
+                               fCuts[kPtCut] = value;
+                               UpdateCutString();
+                               return kTRUE;
+                       } else return kFALSE;
+               case kPidedxSigmaITSCut:
+                       if( SetITSdEdxCutPionLine(value)) { 
+                               fCuts[kPidedxSigmaITSCut] = value;
+                               UpdateCutString();
+                               return kTRUE;
+                       } else return kFALSE;
+               case kPidedxSigmaTPCCut:
+                       if( SetTPCdEdxCutPionLine(value)) { 
+                               fCuts[kPidedxSigmaTPCCut] = value;
+                               UpdateCutString();
+                               return kTRUE;
+                       } else return kFALSE;
+               case kPiTOFSigmaPID:
+                       if( SetTOFPionPIDCut(value)) {
+                               fCuts[kPiTOFSigmaPID] = value;
+                               UpdateCutString();
+                               return kTRUE;
+                       } else return kFALSE;
+               case kNCuts:
+                       cout << "Error:: Cut id out of range"<< endl;
+                       return kFALSE;
+       }
+               
+       cout << "Error:: Cut id " << cutID << " not recognized "<< endl;
+       return kFALSE;
+}
+
+///________________________________________________________________________
+
+void AliPrimaryPionCuts::PrintCuts() {
+    // Print out current Cut Selection
+       for(Int_t ic = 0; ic < kNCuts; ic++) {
+               printf("%-30s : %d \n", fgkCutNames[ic], fCuts[ic]);
+       }
+}
+
+///________________________________________________________________________
+Bool_t AliPrimaryPionCuts::SetITSdEdxCutPionLine(Int_t ededxSigmaCut){ 
+       switch(ededxSigmaCut){
+               case 0: 
+                       fDodEdxSigmaITSCut = kFALSE;
+                       fPIDnSigmaBelowPionLineITS=-100;
+                       fPIDnSigmaAbovePionLineITS= 100;
+                       break;
+               case 1: // -10,10
+                       fDodEdxSigmaITSCut = kTRUE;
+                       fPIDnSigmaBelowPionLineITS=-10;
+                       fPIDnSigmaAbovePionLineITS=10;
+                       break;
+               case 2: // -6,7
+                       fDodEdxSigmaITSCut = kTRUE;
+                       fPIDnSigmaBelowPionLineITS=-6;
+                       fPIDnSigmaAbovePionLineITS=7;
+                       break;
+               case 3: // -5,5
+                       fDodEdxSigmaITSCut = kTRUE;
+                       fPIDnSigmaBelowPionLineITS=-5;
+                       fPIDnSigmaAbovePionLineITS=5;
+                       break;
+               case 4: // -4,5
+                       fDodEdxSigmaITSCut = kTRUE;
+                       fPIDnSigmaBelowPionLineITS=-4;
+                       fPIDnSigmaAbovePionLineITS=5;
+                       break;
+               case 5: // -3,5
+                       fDodEdxSigmaITSCut = kTRUE;
+                       fPIDnSigmaBelowPionLineITS=-3;
+                       fPIDnSigmaAbovePionLineITS=5;
+                       break;
+               case 6: // -4,4
+                       fDodEdxSigmaITSCut = kTRUE;
+                       fPIDnSigmaBelowPionLineITS=-4;
+                       fPIDnSigmaAbovePionLineITS=4;
+                       break;
+               case 7: // -2.5,4
+                       fDodEdxSigmaITSCut = kTRUE;
+                       fPIDnSigmaBelowPionLineITS=-2.5;
+                       fPIDnSigmaAbovePionLineITS=4;
+                       break;
+               case 8: // -2,3.5
+                       fDodEdxSigmaITSCut = kTRUE;
+                       fPIDnSigmaBelowPionLineITS=-2;
+                       fPIDnSigmaAbovePionLineITS=3.5;
+                       break;
+               default:
+                       cout<<"Warning: ITSdEdxCutPionLine not defined"<<ededxSigmaCut<<endl;
+                       return kFALSE;
+               
+       }
+       return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliPrimaryPionCuts::SetTPCdEdxCutPionLine(Int_t ededxSigmaCut){
+       switch(ededxSigmaCut){
+               case 0: 
+                       fDodEdxSigmaTPCCut = kFALSE;
+                       fPIDnSigmaBelowPionLineTPC=-10;
+                       fPIDnSigmaAbovePionLineTPC=10;
+                       break;
+               case 1: // -10,10
+                       fDodEdxSigmaTPCCut = kTRUE;
+                       fPIDnSigmaBelowPionLineTPC=-10;
+                       fPIDnSigmaAbovePionLineTPC=10;
+                       break;
+               case 2: // -6,7
+                       fDodEdxSigmaTPCCut = kTRUE;
+                       fPIDnSigmaBelowPionLineTPC=-6;
+                       fPIDnSigmaAbovePionLineTPC=7;
+                       break;
+               case 3: // -5,5
+                       fDodEdxSigmaTPCCut = kTRUE;
+                       fPIDnSigmaBelowPionLineTPC=-5;
+                       fPIDnSigmaAbovePionLineTPC=5;
+                       break;
+               case 4: // -4,5
+                       fDodEdxSigmaTPCCut = kTRUE;
+                       fPIDnSigmaBelowPionLineTPC=-4;
+                       fPIDnSigmaAbovePionLineTPC=5;
+                       break;  
+               case 5: // -3,5
+                       fDodEdxSigmaTPCCut = kTRUE;
+                       fPIDnSigmaBelowPionLineTPC=-3;
+                       fPIDnSigmaAbovePionLineTPC=5;
+                       break;
+               case 6: // -4,4
+                       fDodEdxSigmaTPCCut = kTRUE;
+                       fPIDnSigmaBelowPionLineTPC=-4;
+                       fPIDnSigmaAbovePionLineTPC=4;
+                       break;
+               case 7: // -2.5,4
+                       fDodEdxSigmaTPCCut = kTRUE;
+                       fPIDnSigmaBelowPionLineTPC=-2.5;
+                       fPIDnSigmaAbovePionLineTPC=4;
+                       break;
+               case 8: // -2,3.5
+                       fDodEdxSigmaTPCCut = kTRUE;
+                       fPIDnSigmaBelowPionLineTPC=-2;
+                       fPIDnSigmaAbovePionLineTPC=3.5;
+                       break;
+               default:
+                       cout<<"Warning: TPCdEdxCutPionLine not defined"<<ededxSigmaCut<<endl;
+                       return kFALSE;
+       }
+       return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliPrimaryPionCuts::SetITSClusterCut(Int_t clsITSCut){
+       if( !fEsdTrackCuts ) {
+               cout<<"Warning: AliESDtrackCut is not initialized "<<endl;
+               return kFALSE;
+       }
+
+       switch(clsITSCut){
+               case 0: 
+                       fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kOff);
+                       break;
+               case 1: 
+                       fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kFirst);
+                       break;  //1 hit first layer of SPD
+               case 2: 
+                       fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
+                       break; //1 hit in any layer of SPD
+               case 3: 
+                       fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kFirst);
+                       fEsdTrackCuts->SetMinNClustersITS(4);
+                       // 4 hits in total in the ITS. At least 1 hit in the first layer of SPD  
+                       break;
+               case 4: 
+                       fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
+                       fEsdTrackCuts->SetMinNClustersITS(3);
+                       // 3 hits in total in the ITS. At least 1 hit in any layer of SPD
+                       break;
+               case 5: 
+                       fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
+                       fEsdTrackCuts->SetMinNClustersITS(4);
+                       // 4 hits in total in the ITS. At least 1 hit in any layer of SPD
+                       break;
+               case 6: 
+                       fEsdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
+                       fEsdTrackCuts->SetMinNClustersITS(5);
+                       // 5 hits in total in the ITS. At least 1 hit in any layer of SPD
+                       break;
+               default:
+                       cout<<"Warning: clsITSCut not defined "<<clsITSCut<<endl;
+                       return kFALSE;
+       }
+       return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliPrimaryPionCuts::SetTPCClusterCut(Int_t clsTPCCut){  
+       switch(clsTPCCut){
+               case 0: // 0
+                       fMinClsTPC= 0.;
+                       fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
+                       break;
+               case 1:  // 70
+                       fMinClsTPC= 70.;
+                       fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
+                       break;
+               case 2:  // 80
+                       fMinClsTPC= 80.;
+                       fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
+                       break;
+               case 3:  // 100
+                       fMinClsTPC= 100.;
+                       fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
+                       break;
+               case 4:  // 0% of findable clusters
+                               fMinClsTPC= 70.;  
+                       fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
+                       fMinClsTPCToF= 0.0;
+                       fUseCorrectedTPCClsInfo=0;
+                       break;
+               case 5:  // 35% of findable clusters
+                       fMinClsTPC = 70.;  
+                       fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
+                       fMinClsTPCToF= 0.35;
+                       fUseCorrectedTPCClsInfo=0;
+                       break;
+               case 6:  // 60% of findable clusters
+                       fMinClsTPC= 70.;  
+                       fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
+                       fMinClsTPCToF= 0.6;
+                       fUseCorrectedTPCClsInfo=0;
+                       break;
+               case 7:  // 70% of findable clusters
+                       fMinClsTPC= 70.;  
+                       fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
+                       fMinClsTPCToF= 0.7;
+                       fUseCorrectedTPCClsInfo=0;
+                       break;
+               case 8: fMinClsTPC = 0.;  
+                       fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
+                       fMinClsTPCToF= 0.35;
+                       fUseCorrectedTPCClsInfo=0;
+                       break;
+               case 9:  // 35% of findable clusters
+                       fMinClsTPC = 70.;  
+                       fEsdTrackCuts->SetMinNClustersTPC(fMinClsTPC);
+                       fMinClsTPCToF= 0.35;
+                       fUseCorrectedTPCClsInfo=1;
+                       break;
+               
+               default:
+                       cout<<"Warning: clsTPCCut not defined "<<clsTPCCut<<endl;
+                       return kFALSE;
+       }
+       return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliPrimaryPionCuts::SetEtaCut(Int_t etaCut){ 
+       // Set eta Cut
+       switch(etaCut){
+               case 0: 
+                       fEtaCut = 100.;
+                       fDoEtaCut = kFALSE;
+                       break;
+               case 1: // 1.4
+                       fEtaCut = 1.4;
+                       fDoEtaCut = kTRUE;
+                       break;
+               case 2: // 1.2
+                       fEtaCut = 1.2;
+                       fDoEtaCut = kTRUE;
+                       break;
+               case 3: // 0.9
+                       fEtaCut = 0.9;
+                       fDoEtaCut = kTRUE;
+                       break;
+               case 4: // 0.8
+                       fEtaCut = 0.8;
+                       fDoEtaCut = kTRUE;
+                       break;
+               case 5: // 0.75
+                       fEtaCut = 0.75;
+                       fDoEtaCut = kTRUE;
+                       break;
+               case 6: //0.6
+                       fEtaCut = 0.6; //changed from 0.4 to 0.6 2013.06.10
+                       fDoEtaCut = kTRUE;
+                       break;
+               case 7: //0.5
+                       fEtaCut = 0.5; //changed from 0.3 to 0.5 2013.06.10
+                       fDoEtaCut = kTRUE;
+                       break;
+               case 8: 
+                       fEtaCut = 0.4;
+                       fDoEtaCut = kTRUE;
+                       break;
+               default:
+                       cout<<"Warning: EtaCut not defined "<<etaCut<<endl;
+                       return kFALSE;
+       }
+       return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliPrimaryPionCuts::SetPtCut(Int_t ptCut){ 
+       switch(ptCut){    
+               case 0: 
+                       fPtCut = 0.075;         
+                       break;
+               case 1:  // 0.1
+                       fPtCut  = 0.1;  
+                       break;
+               case 2:  // 0.125 GeV
+                       fPtCut  = 0.125;                
+                       break;
+               case 3: // 0.15 GeV
+                       fPtCut  = 0.15;
+                       break;
+               default:
+                       cout<<"Warning: PtCut not defined "<<ptCut<<endl;
+                       return kFALSE;
+       }
+       return kTRUE;
+}
+
+
+///________________________________________________________________________
+Bool_t AliPrimaryPionCuts::SetDCACut(Int_t dcaCut)
+{ 
+       // Set DCA Cut
+       if( !fEsdTrackCuts ) {
+               cout<<"Warning: AliESDtrackCut is not initialized "<<endl;
+               return kFALSE;
+       }
+  
+       switch(dcaCut){   
+               case 0: 
+                       //Open cuts//
+                       fEsdTrackCuts->SetMaxDCAToVertexZ(1000);
+                       fEsdTrackCuts->SetMaxDCAToVertexXY(1000);
+                       fEsdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
+                       break;
+               case 1: 
+                       fEsdTrackCuts->SetMaxDCAToVertexXYPtDep("0.0182+0.0350/pt^1.01");
+                       fEsdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
+                       break;
+               case 2: fEsdTrackCuts->SetMaxDCAToVertexZ(2);
+                       fEsdTrackCuts->SetMaxDCAToVertexXY(1);
+                       fEsdTrackCuts->SetMaxChi2TPCConstrainedGlobal(36);
+                       break; 
+               default:
+                       cout<<"Warning: dcaCut not defined "<<dcaCut<<endl;
+                       return kFALSE;
+       }
+       return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliPrimaryPionCuts::SetTOFPionPIDCut(Int_t TOFelectronPID){
+    // Set Cut
+       switch(TOFelectronPID){ 
+               case 0: // no cut
+                       fRequireTOF = kFALSE;
+                       fUseTOFpid = kFALSE;
+                       fPIDnSigmaBelowPionLineTOF=-100;
+                       fPIDnSigmaAbovePionLineTOF=100;
+                       break;
+               case 1: // -7,7
+                       fRequireTOF = kFALSE;
+                       fUseTOFpid = kTRUE;
+                       fPIDnSigmaBelowPionLineTOF=-7;
+                       fPIDnSigmaAbovePionLineTOF=7;
+                       break;
+               case 2: // -5,5
+                       fRequireTOF = kFALSE;
+                       fUseTOFpid = kTRUE;
+                       fPIDnSigmaBelowPionLineTOF=-5;
+                       fPIDnSigmaAbovePionLineTOF=5;
+                       break;
+               case 3: // -3,5
+                       fRequireTOF = kFALSE;
+                       fUseTOFpid = kTRUE;
+                       fPIDnSigmaBelowPionLineTOF=-3;
+                       fPIDnSigmaAbovePionLineTOF=5;
+                       break;
+               case 4: // -2,3
+                       fRequireTOF = kFALSE;
+                       fUseTOFpid = kTRUE;
+                       fPIDnSigmaBelowPionLineTOF=-2;
+                       fPIDnSigmaAbovePionLineTOF=3;
+                       break;
+               case 5: // -3, 3 TOF mandatory
+                       fRequireTOF = kTRUE;
+                       fUseTOFpid  = kTRUE;
+                       fPIDnSigmaBelowPionLineTOF= -3;
+                       fPIDnSigmaAbovePionLineTOF=  3;
+                       break;
+               default:
+                       cout<<"Warning: TOFPionCut not defined "<<TOFelectronPID<<endl;
+               return kFALSE;
+    } 
+    return kTRUE;
+}
+
+
+///________________________________________________________________________
+TString AliPrimaryPionCuts::GetCutNumber(){
+       // returns TString with current cut number
+       TString a(kNCuts);
+       for(Int_t ii=0;ii<kNCuts;ii++){
+               a.Append(Form("%d",fCuts[ii]));
+       }
+       return a;
+}
+
+
+///________________________________________________________________________
+AliPrimaryPionCuts* AliPrimaryPionCuts::GetStandardCuts2010PbPb(){
+    //Create and return standard 2010 PbPb cuts
+    AliPrimaryPionCuts *cuts=new AliPrimaryPionCuts("StandardCuts2010PbPb","StandardCuts2010PbPb");
+    if(!cuts->InitializeCutsFromCutString("9069640364102")){
+               cout<<"Warning: Initialization of Standardcuts2010PbPb failed"<<endl;   
+       }
+    return cuts;
+}
+
+///________________________________________________________________________
+AliPrimaryPionCuts* AliPrimaryPionCuts::GetStandardCuts2010pp(){
+    //Create and return standard 2010 PbPb cuts
+    AliPrimaryPionCuts *cuts=new AliPrimaryPionCuts("StandardCuts2010pp","StandardCuts2010pp");
+                                          
+    if(!cuts->InitializeCutsFromCutString("9069640364102")){
+               cout<<"Warning: Initialization of Standardcuts2010pp failed"<<endl;
+       }
+    return cuts;
+}
+
diff --git a/PWGGA/GammaConv/AliPrimaryPionCuts.h b/PWGGA/GammaConv/AliPrimaryPionCuts.h
new file mode 100644 (file)
index 0000000..205e784
--- /dev/null
@@ -0,0 +1,172 @@
+#ifndef ALIPRIMARYPIONCUTS_H
+#define ALIPRIMARYPIONCUTS_H
+
+// Class handling all kinds of selection cuts for primary
+
+// Authors: Svein Lindal, Daniel Lohner                                                                                                *
+
+
+#include "AliAODpidUtil.h"
+#include "AliAODTrack.h"
+#include "AliESDtrack.h"
+#include "AliVTrack.h"
+#include "AliAODTrack.h"
+#include "AliStack.h"
+#include "AliAnalysisCuts.h"
+#include "AliESDtrackCuts.h"
+#include "TH1F.h"
+
+class AliESDEvent;
+class AliAODEvent;
+class AliConversionPhotonBase;
+class AliKFVertex;
+class AliKFParticle;
+class TH1F;
+class TH2F;
+class AliPIDResponse;
+class AliAnalysisCuts;
+class iostream;
+class TList;
+class AliAnalysisManager;
+
+
+using namespace std;
+
+class AliPrimaryPionCuts : public AliAnalysisCuts {
+               
+       public: 
+
+
+       enum cutIds {
+               kEtaCut,
+               kClsITSCut,
+               kClsTPCCut,
+               kDCACut,
+               kPtCut,
+               kPidedxSigmaITSCut,
+               kPidedxSigmaTPCCut,
+               kPiTOFSigmaPID,
+               kNCuts
+       };
+
+
+       enum pionCuts {
+               kPionIn=0,
+               kNoTracks,
+               kTrackCuts,
+               kdEdxCuts,
+               kPionOut
+       };
+
+
+       Bool_t SetCutIds(TString cutString); 
+       Int_t fCuts[kNCuts];
+       Bool_t SetCut(cutIds cutID, Int_t cut);
+       Bool_t UpdateCutString();
+       static const char * fgkCutNames[kNCuts];
+
+
+       Bool_t InitializeCutsFromCutString(const TString analysisCutSelection); 
+       
+
+       AliPrimaryPionCuts(const char *name="PionCuts", const char * title="Pion Cuts");
+       virtual ~AliPrimaryPionCuts();                            //virtual destructor
+
+       virtual Bool_t IsSelected(TObject* /*obj*/){return kTRUE;}
+       virtual Bool_t IsSelected(TList* /*list*/) {return kTRUE;}
+
+       TString GetCutNumber();
+
+               // Cut Selection
+       Bool_t PionIsSelectedMC(Int_t labelParticle,AliStack *fMCStack);
+       Bool_t TrackIsSelected(AliESDtrack* lTrack);
+       Bool_t PionIsSelected(AliESDtrack* lTrack);
+       static AliPrimaryPionCuts * GetStandardCuts2010PbPb();
+       static AliPrimaryPionCuts * GetStandardCuts2010pp();
+       Bool_t InitPIDResponse();
+       
+       void SetPIDResponse(AliPIDResponse * pidResponse) {fPIDResponse = pidResponse;}
+       AliPIDResponse * GetPIDResponse() { return fPIDResponse;}
+       
+       void PrintCuts();
+
+       void InitCutHistograms(TString name="",Bool_t preCut = kTRUE,TString cutName="");
+       void SetFillCutHistograms(TString name="",Bool_t preCut = kTRUE,TString cutName=""){if(!fHistograms){InitCutHistograms(name,preCut,cutName);};}
+       TList *GetCutHistograms(){return fHistograms;}
+
+       static AliVTrack * GetTrack(AliVEvent * event, Int_t label);
+
+       ///Cut functions
+       Bool_t dEdxCuts(AliVTrack * track);
+
+       Bool_t SetTPCdEdxCutPionLine(Int_t pidedxSigmaCut);
+       Bool_t SetITSdEdxCutPionLine(Int_t ededxSigmaCut);
+       Bool_t SetITSClusterCut(Int_t clsITSCut);
+       Bool_t SetTPCClusterCut(Int_t clsTPCCut);
+       Bool_t SetEtaCut(Int_t etaCut);
+       Bool_t SetPtCut(Int_t ptCut);
+       Bool_t SetDCACut(Int_t dcaCut);
+       void SetEtaShift(Double_t etaShift){fEtaShift = etaShift;}
+       Bool_t SetTOFPionPIDCut(Int_t TOFelectronPID);
+       
+       // Request Flags
+       Double_t GetEtaCut(){ return  fEtaCut;}
+       Double_t GetNFindableClustersTPC(AliESDtrack* lTrack);
+       Bool_t   DoWeights(){return fDoWeights;}
+       
+       protected:
+
+       TList *fHistograms;
+       AliPIDResponse *fPIDResponse;
+       AliESDtrackCuts *fEsdTrackCuts;
+
+       Double_t fEtaCut; //eta cutç
+       Double_t fEtaShift;
+       Bool_t   fDoEtaCut;
+       Double_t fPtCut;
+       Double_t fMinClsTPC; // minimum clusters in the TPC
+       Double_t fMinClsTPCToF; // minimum clusters to findable clusters
+       Bool_t   fDodEdxSigmaITSCut; // flag to use the dEdxCut ITS based on sigmas
+       Bool_t   fDodEdxSigmaTPCCut; // flag to use the dEdxCut TPC based on sigmas
+       Bool_t   fDoTOFsigmaCut; // flag to use TOF pid cut RRnewTOF
+       Double_t fPIDnSigmaAbovePionLineITS; // sigma cut ITS
+       Double_t fPIDnSigmaBelowPionLineITS; // sigma cut ITS
+       Double_t fPIDnSigmaAbovePionLineTPC; // sigma cut TPC
+       Double_t fPIDnSigmaBelowPionLineTPC; // sigma cut TPC
+       Double_t fPIDnSigmaAbovePionLineTOF; // sigma cut TOF
+       Double_t fPIDnSigmaBelowPionLineTOF; // sigma cut TOF 
+       Bool_t   fUseCorrectedTPCClsInfo; // flag to use corrected tpc cl info
+       Bool_t   fUseTOFpid; // flag to use tof pid
+       Bool_t   fRequireTOF; //flg to analyze only tracks with TOF signal
+       Bool_t   fDoWeights;
+
+
+       // Histograms
+       TObjString *fCutString; // cut number used for analysis
+       TH1F *fHistCutIndex; // bookkeeping for cuts
+       TH1F *fHistdEdxCuts;  // bookkeeping for dEdx cuts
+       TH2F *fHistITSdEdxbefore; // ITS dEdx before cuts
+       TH2F *fHistITSdEdxafter;
+       TH2F *fHistTPCdEdxbefore; // TPC dEdx before cuts
+       TH2F *fHistTPCdEdxafter; // TPC dEdx after cuts
+       TH2F *fHistTPCdEdxSignalbefore; //TPC dEdx signal before
+       TH2F *fHistTPCdEdxSignalafter; //TPC dEdx signal  after
+       TH2F *fHistTOFbefore; // TOF after cuts
+       TH2F *fHistTOFafter; // TOF after cuts
+       TH2F *fHistTrackDCAxyPtbefore;
+       TH2F *fHistTrackDCAxyPtafter;
+       TH2F *fHistTrackDCAzPtbefore;
+       TH2F *fHistTrackDCAzPtafter;
+       TH2F *fHistTrackNFindClsPtTPCbefore;
+       TH2F *fHistTrackNFindClsPtTPCafter;
+       
+       private:
+
+       AliPrimaryPionCuts(const AliPrimaryPionCuts&); // not implemented
+       AliPrimaryPionCuts& operator=(const AliPrimaryPionCuts&); // not implemented
+
+
+       ClassDef(AliPrimaryPionCuts,2)
+};
+
+#endif
diff --git a/PWGGA/GammaConv/AliPrimaryPionSelector.cxx b/PWGGA/GammaConv/AliPrimaryPionSelector.cxx
new file mode 100644 (file)
index 0000000..0623f25
--- /dev/null
@@ -0,0 +1,146 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved.      *
+ *                                                                                                                                                     *
+ * Authors: Friederike Bock                                                                                                    *
+ * Version 1.0                                                                                                                         *
+ *                                                                                                                                                     *
+ * Permission to use, copy, modify and distribute this software and its                *
+ * documentation strictly for non-commercial purposes is hereby granted                *
+ * without fee, provided that the above copyright notice appears in all                *
+ * copies and that both the copyright notice and this permission notice                *
+ * appear in the supporting documentation. The authors make no claims          *
+ * about the suitability of this software for any purpose. It is                       *
+ * provided "as is" without express or implied warranty.                                       *
+ **************************************************************************/
+
+////////////////////////////////////////////////
+//--------------------------------------------- 
+// Class reconstructing primary electrons
+//---------------------------------------------
+////////////////////////////////////////////////
+
+
+#include "AliPrimaryPionSelector.h"
+#include "AliPrimaryPionCuts.h"
+#include "AliAODv0.h"
+#include "AliESDv0.h"
+#include "AliAODEvent.h"
+#include "AliESDEvent.h"
+#include "TVector.h"
+#include "AliESDtrack.h"
+#include "AliAnalysisManager.h"
+#include "AliInputEventHandler.h"
+#include "TChain.h"
+#include "AliStack.h"
+
+class iostream;
+
+using namespace std;
+
+
+
+ClassImp(AliPrimaryPionSelector)
+
+//________________________________________________________________________
+AliPrimaryPionSelector::AliPrimaryPionSelector(const char *name) : AliAnalysisTaskSE(name),
+    fPionCuts(0),
+    fPosPionsIndex(),
+    fNegPionsIndex(),
+    fEventIsSelected(kFALSE)
+{
+    // Default constructor
+    DefineInput(0, TChain::Class());
+}
+
+//________________________________________________________________________
+AliPrimaryPionSelector::~AliPrimaryPionSelector()
+{
+    // default deconstructor
+
+   
+}
+//________________________________________________________________________
+void AliPrimaryPionSelector::Init()
+{
+    // Initialize function to be called once before analysis
+
+    if(fPionCuts == 0){
+    //  fPionCuts=AliConversionCuts::GetStandardCuts2010PbPb();
+        AliError("No Cut Selection initialized");
+    }
+
+}
+
+//________________________________________________________________________
+void AliPrimaryPionSelector::UserCreateOutputObjects()
+{
+    // Create User Output Objects
+}
+
+//________________________________________________________________________
+void AliPrimaryPionSelector::UserExec(Option_t *){
+    // User Exec
+       fEventIsSelected=ProcessEvent(fInputEvent,fMCEvent);
+}
+
+//________________________________________________________________________
+Bool_t AliPrimaryPionSelector::ProcessEvent(AliVEvent *inputEvent,AliMCEvent *mcEvent)
+{
+       //Reset the index
+
+       fPosPionsIndex.clear();
+       fNegPionsIndex.clear();
+
+
+       fInputEvent=inputEvent;
+       fMCEvent=mcEvent;
+
+       if(!fInputEvent){
+               AliError("No Input event");
+               return kFALSE;
+       }
+
+       if(!fPionCuts){AliError("No ConversionCuts");return kFALSE;}
+
+
+       if(fInputEvent->IsA()==AliESDEvent::Class()){
+               ProcessESDs();
+       }
+
+       //if(fInputEvent->IsA()==AliAODEvent::Class()){
+       //GetAODConversionGammas();
+       //}
+
+
+       return kTRUE;
+}
+
+///________________________________________________________________________
+Bool_t AliPrimaryPionSelector::ProcessESDs(){
+       // Process ESD V0s for conversion photon reconstruction
+       AliESDEvent *fESDEvent=dynamic_cast<AliESDEvent*>(fInputEvent);
+       if(fESDEvent){
+               for(Int_t currentTrackIndex=0;currentTrackIndex<fESDEvent->GetNumberOfTracks();currentTrackIndex++){
+                       AliESDtrack *fCurrentTrack = (AliESDtrack*)(fESDEvent->GetTrack(currentTrackIndex));
+                       if(!fCurrentTrack){
+                               printf("Requested Track does not exist");
+                               continue;
+                       }
+                       if (  fPionCuts->PionIsSelected( fCurrentTrack ) ) {
+                               if( fCurrentTrack->GetSign() > 0.0 ){
+                                       fPosPionsIndex.push_back(currentTrackIndex);
+                               } else {
+                                       fNegPionsIndex.push_back(currentTrackIndex);
+                               }
+                       }
+               }
+       }
+       return kTRUE;
+}
+
+
+//________________________________________________________________________
+void AliPrimaryPionSelector::Terminate(Option_t *)
+{
+
+}
diff --git a/PWGGA/GammaConv/AliPrimaryPionSelector.h b/PWGGA/GammaConv/AliPrimaryPionSelector.h
new file mode 100644 (file)
index 0000000..274052c
--- /dev/null
@@ -0,0 +1,76 @@
+#ifndef ALIPRIMARYPIONSELECTOR_H
+#define ALIPRIMARYPIONSELECTOR_H
+
+#include "AliAnalysisTaskSE.h"
+#include "AliAODv0.h"
+#include "AliESDv0.h"
+#include "AliPrimaryPionCuts.h"
+#include "AliExternalTrackParam.h"
+
+class TRandom3;
+class AliStack;
+class TList;
+class TString;
+class TH1F;
+class TH2F;
+
+using namespace std;
+
+class AliPrimaryPionSelector : public AliAnalysisTaskSE {
+
+ public:
+
+   AliPrimaryPionSelector(const char *name="PionSelector");
+   //Uncopyable & operator=(const Uncopyable&);
+
+   virtual ~AliPrimaryPionSelector();                            //virtual destructor
+   void UserCreateOutputObjects();
+
+   virtual void UserExec(Option_t *option);
+   virtual void Terminate(Option_t *);
+   virtual void Init();
+
+   Bool_t ProcessEvent(AliVEvent *inputEvent,AliMCEvent *mcEvent=NULL);
+   Bool_t IsEventSelected(){return fEventIsSelected;}
+
+   // Return selected electron/positron array
+   vector <Int_t> GetReconstructedNegPionIndex(){ return fNegPionsIndex; }
+   vector <Int_t> GetReconstructedPosPionIndex(){ return fPosPionsIndex; }
+   AliPrimaryPionCuts *GetPrimaryPionCuts(){   return fPionCuts; }
+   TList *GetCutHistograms(){ if(fPionCuts){return fPionCuts->GetCutHistograms();} return NULL;}
+   // Set Options
+
+   void SetPrimaryPionCuts(const TString cut);
+   void SetPrimaryPionCuts(AliPrimaryPionCuts *cuts){fPionCuts=cuts;}
+
+ protected:
+   //selected electron arrays
+   
+   Bool_t ProcessESDs();
+   AliPrimaryPionCuts *fPionCuts; // Pointer to the ConversionCut Selection
+   vector<Int_t> fPosPionsIndex;
+   vector<Int_t> fNegPionsIndex;
+   Bool_t fEventIsSelected;
+
+ private:
+   AliPrimaryPionSelector (const AliPrimaryPionSelector&); // not implemented
+   AliPrimaryPionSelector & operator=(const AliPrimaryPionSelector&); // not implemented
+
+
+   
+   ClassDef(AliPrimaryPionSelector,1)
+      };
+
+inline void AliPrimaryPionSelector::SetPrimaryPionCuts(const TString cut){
+   if(fPionCuts != NULL){
+      delete fPionCuts;
+      fPionCuts=NULL;
+   }
+   if(fPionCuts == NULL){
+      fPionCuts=new AliPrimaryPionCuts("ElectronCuts","ElectronCuts");
+      fPionCuts->InitializeCutsFromCutString(cut.Data());
+   }
+}
+
+
+#endif
index 13c8a67..ba5f465 100644 (file)
@@ -10,7 +10,15 @@ void AddTask_GammaConvDalitzV1_pPb(    Int_t trainConfig = 1,
 
 
    
-   cout<<"Entro -1"<<endl;
+   cout<<"*********Parameters*******"<<endl;
+   cout<<"trainConfig: "<<trainConfig<<endl;
+   cout<<"isMC: "<<isMC<<endl;
+   cout<<"enableQAMesonTask: "<<enableQAMesonTask<<endl;
+   cout<<"enableDoMesonChic: "<<enableDoMesonChic<<endl;
+   cout<<"fileNameInputForWeighting: "<<fileNameInputForWeighting.Data()<<endl;
+   cout<<"doWeighting: "<<doWeighting<<endl;
+   cout<<"generatorName: "<<generatorName.Data()<<endl;
+   cout<<"cutnumberAODBranch: "<<cutnumberAODBranch.Data()<<endl;
 
   // ================= Load Librariers =================================
    gSystem->Load("libCore.so");  
@@ -175,7 +183,7 @@ void AddTask_GammaConvDalitzV1_pPb(    Int_t trainConfig = 1,
 
    if( trainConfig == 1 ) {
         
-     //No eta shift Standard
+     // Eta shift Standard
      
         ConvCutarray[0] = "8000011082093603007200000000"; ElecCutarray[0] = "9047540025810262171"; MesonCutarray[0] = "01039035009000"; //standard cut Pi0 PbPb 00-100
         ConvCutarray[1] = "8020011082093603007200000000"; ElecCutarray[1] = "9047540025810262171"; MesonCutarray[1] = "01039035009000"; //standard cut Pi0 PbPb 00-20
@@ -187,7 +195,7 @@ void AddTask_GammaConvDalitzV1_pPb(    Int_t trainConfig = 1,
    } 
   
   else if( trainConfig == 2 ) {
-       //Standard cut
+       // Eta shift Standard  no weights
        
         ConvCutarray[0] = "8000011082093603007200000000"; ElecCutarray[0] = "9047540025810262170"; MesonCutarray[0] = "01039035009000"; //standard cut Pi0 PbPb 00-100
         ConvCutarray[1] = "8020011082093603007200000000"; ElecCutarray[1] = "9047540025810262170"; MesonCutarray[1] = "01039035009000"; //standard cut Pi0 PbPb 00-20
@@ -210,7 +218,7 @@ void AddTask_GammaConvDalitzV1_pPb(    Int_t trainConfig = 1,
    
  }
 
-else if( trainConfig == 4 ) {
+else if( trainConfig == 4 ) { //Eta Shift 
 
         ConvCutarray[0] = "8000011082093603007200000000"; ElecCutarray[0] = "9047540025810262171"; MesonCutarray[0] = "01039035009000"; //standard cut Pi0 PbPb 00-100
         ConvCutarray[1] = "8020011082093603007200000000"; ElecCutarray[1] = "9047540025810262171"; MesonCutarray[1] = "01039035009000"; //standard cut Pi0 PbPb 00-20
@@ -219,7 +227,7 @@ else if( trainConfig == 4 ) {
         ConvCutarray[4] = "8680011082093603007200000000"; ElecCutarray[4] = "9047540025810262171"; MesonCutarray[4] = "01039035009000"; //standard cut Pi0 PbPb 60-80        
         ConvCutarray[5] = "8600011082093603007200000000"; ElecCutarray[5] = "9047540025810262171"; MesonCutarray[5] = "01039035009000"; //standard cut Pi0 PbPb 60-100
 
-} else if( trainConfig == 5 ) {
+} else if( trainConfig == 5 ) { //Eta shift added signals 
 
         ConvCutarray[0] = "8000012082093603007200000000"; ElecCutarray[0] = "9047540025810262171"; MesonCutarray[0] = "01039035009000"; //standard cut Pi0 PbPb 00-100
         ConvCutarray[1] = "8020012082093603007200000000"; ElecCutarray[1] = "9047540025810262171"; MesonCutarray[1] = "01039035009000"; //standard cut Pi0 PbPb 00-20
@@ -228,9 +236,7 @@ else if( trainConfig == 4 ) {
         ConvCutarray[4] = "8680012082093603007200000000"; ElecCutarray[4] = "9047540025810262171"; MesonCutarray[4] = "01039035009000"; //standard cut Pi0 PbPb 60-80        
         ConvCutarray[5] = "8600012082093603007200000000"; ElecCutarray[5] = "9047540025810262171"; MesonCutarray[5] = "01039035009000"; //standard cut Pi0 PbPb 60-100
        
-} else if( trainConfig == 6 ) {
-  
-       //No eta shift |Y| < 0.8 |electrons.eta| < 0.9 |gamma.eta| < 0.9
+} else if( trainConfig == 6 ) { //No eta shift |Y| < 0.8 |electrons.eta| < 0.9 |gamma.eta| < 0.9 added signals
        
        ConvCutarray[0] = "8000012002093603007200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 PbPb 00-100
         ConvCutarray[1] = "8020012002093603007200000000"; ElecCutarray[1] = "9047540025310262171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-20
@@ -238,17 +244,8 @@ else if( trainConfig == 4 ) {
         ConvCutarray[3] = "8460012002093603007200000000"; ElecCutarray[3] = "9047540025310262171"; MesonCutarray[3] = "01031035009000"; //standard cut Pi0 PbPb 40-60
         ConvCutarray[4] = "8680012002093603007200000000"; ElecCutarray[4] = "9047540025310262171"; MesonCutarray[4] = "01031035009000"; //standard cut Pi0 PbPb 60-80        
         ConvCutarray[5] = "8600012002093603007200000000"; ElecCutarray[5] = "9047540025310262171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 60-100
- }  else if( trainConfig == 7 ) {
-       //No eta shift added signals
-    
-        ConvCutarray[0] = "8000012082093603007200000000"; ElecCutarray[0] = "9047540025810262171"; MesonCutarray[0] = "01039035009000"; //standard cut Pi0 PbPb 00-100
-        ConvCutarray[1] = "8020012082093603007200000000"; ElecCutarray[1] = "9047540025810262171"; MesonCutarray[1] = "01039035009000"; //standard cut Pi0 PbPb 00-20
-        ConvCutarray[2] = "8240012082093603007200000000"; ElecCutarray[2] = "9047540025810262171"; MesonCutarray[2] = "01039035009000"; //standard cut Pi0 PbPb 20-40
-        ConvCutarray[3] = "8460012082093603007200000000"; ElecCutarray[3] = "9047540025810262171"; MesonCutarray[3] = "01039035009000"; //standard cut Pi0 PbPb 40-60
-        ConvCutarray[4] = "8680012082093603007200000000"; ElecCutarray[4] = "9047540025810262171"; MesonCutarray[4] = "01039035009000"; //standard cut Pi0 PbPb 60-80        
-        ConvCutarray[5] = "8600012082093603007200000000"; ElecCutarray[5] = "9047540025810262171"; MesonCutarray[5] = "01039035009000"; //standard cut Pi0 PbPb 60-100
        
-}  else if( trainConfig == 8 ) {  //No eta shift |Y| < 0.8
+ } else if( trainConfig == 7 ) {  // No eta shift |Y| < 0.8
        
        
        ConvCutarray[0] = "8000011002093653007200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx pion rejec sec 0.3 GeV Low and 3.5 High momentum
@@ -259,7 +256,7 @@ else if( trainConfig == 4 ) {
        ConvCutarray[5] = "8000011002093603002200000000"; ElecCutarray[5] = "9047540025310262171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Qt < 0.7
        
        
-}  else if( trainConfig == 9 ) {       //No eta shift |Y| < 0.8
+}  else if( trainConfig == 8 ) {  // No eta shift |Y| < 0.8
 
        ConvCutarray[0] = "8000011002093603003200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Qt < 0.5
        ConvCutarray[1] = "8000011002093603007200000000"; ElecCutarray[1] = "9047540015310262171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + SPD first layer
@@ -269,7 +266,7 @@ else if( trainConfig == 4 ) {
        ConvCutarray[5] = "8000011002093603007200000000"; ElecCutarray[5] = "9047540025310263171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Single prim Pt cut > 0.150
        
        
-} else if ( trainConfig == 10 ) {      //No eta shift |Y| < 0.8
+} else if ( trainConfig == 9 ) {  // No eta shift |Y| < 0.8
 
        ConvCutarray[0] = "8000011002493603007200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Single sec  Pt cut > 0.075
        ConvCutarray[1] = "8000011002193603007200000000"; ElecCutarray[1] = "9047540025310262171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Single sec  Pt cut > 0.100
@@ -279,7 +276,7 @@ else if( trainConfig == 4 ) {
        ConvCutarray[5] = "8000011002093603007200000000"; ElecCutarray[5] = "9057540025310262171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx primary electron -3,5
        
        
-} else if ( trainConfig == 11 ) {        //No eta shift |Y| < 0.8
+} else if ( trainConfig == 10 ) {  // No eta shift |Y| < 0.8
        
        ConvCutarray[0] = "8000011002093603007200000000"; ElecCutarray[0] = "9043540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx pion rejec primary 2.0sigmas Low and 0 High momentum
        ConvCutarray[1] = "8000011002093603007200000000"; ElecCutarray[1] = "9047740025310262171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx pion rejec primary 0.3 GeV Low and 3.5 High momentum
@@ -289,7 +286,7 @@ else if( trainConfig == 4 ) {
        ConvCutarray[5] = "8000011002093603007200000000"; ElecCutarray[5] = "9047540025310262171"; MesonCutarray[5] = "01031005009000"; //standard cut Pi0 pPb 00-100 Standard cut + Alpha cut < 0.7
        
        
-} else if ( trainConfig == 12 ) {         //No eta shift |Y| < 0.8
+} else if ( trainConfig == 11 ) {  //No eta shift |Y| < 0.8
 
        ConvCutarray[0] = "8000011002093603001200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + qT < 0.1
        ConvCutarray[1] = "8000011002093603007200000000"; ElecCutarray[1] = "9047540025310262141"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + InvMass(e+,e-) < 0.050
@@ -299,18 +296,18 @@ else if( trainConfig == 4 ) {
        ConvCutarray[5] = "8000011002093603007200000000"; ElecCutarray[5] = "9042540025310262171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + dEdx pion rejec  primary  2.0sigmas Low and -1 High momentum 
            
        
-} else if ( trainConfig == 13 ) {
+} else if ( trainConfig == 12 ) {  //No eta shift |Y| < 0.8
   
        ConvCutarray[0] = "8000011002093803007200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + dEdx pion rejec  secon    2.0sigmas Low and  1 High momentum
        ConvCutarray[1] = "8000011002093603007200000000"; ElecCutarray[1] = "9047540025310272171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100 + 100 events backgroubd
        ConvCutarray[2] = "8000011002093603007200000000"; ElecCutarray[2] = "9047540025310262171"; MesonCutarray[2] = "01031035009000"; //standard cut Pi0 PbPb 00-100 + Standard
        ConvCutarray[3] = "8000011002093603007200000000"; ElecCutarray[3] = "9047540025310262171"; MesonCutarray[3] = "01031035000000"; //standard cut Pi0 PbPb 00-100 + No extra smearing
        ConvCutarray[4] = "8000011002093603007200000000"; ElecCutarray[4] = "9047540025300262171"; MesonCutarray[4] = "01031035009000"; //standard cut Pi0 PbPb 00-100 + No psi pair 
-       ConvCutarray[5] = "8000011002093603007200000000"; ElecCutarray[5] = "9047540025310252171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100 + 50 events background
+       ConvCutarray[5] = "8000011002093603007200000000"; ElecCutarray[5] = "9047540023310262371"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100  //Tracks 2011
  
    
 
-} else if( trainConfig == 14 ) {  //No eta shift |Y| < 0.8 addedSignal
+} else if( trainConfig == 13 ) {  //No eta shift |Y| < 0.8 addedSignal
        
        
        ConvCutarray[0] = "8000012002093653007200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx pion rejec sec 0.3 GeV Low and 3.5 High momentum
@@ -321,7 +318,7 @@ else if( trainConfig == 4 ) {
        ConvCutarray[5] = "8000012002093603002200000000"; ElecCutarray[5] = "9047540025310262171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Qt < 0.7
        
        
-}  else if( trainConfig == 15 ) {      //No eta shift |Y| < 0.8 addedSignal
+}  else if( trainConfig == 14 ) {      //No eta shift |Y| < 0.8 addedSignal
 
        ConvCutarray[0] = "8000012002093603003200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Qt < 0.5
        ConvCutarray[1] = "8000012002093603007200000000"; ElecCutarray[1] = "9047540015310262171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + SPD first layer
@@ -331,7 +328,7 @@ else if( trainConfig == 4 ) {
        ConvCutarray[5] = "8000012002093603007200000000"; ElecCutarray[5] = "9047540025310263171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Single prim Pt cut > 0.150
        
        
-} else if ( trainConfig == 16 ) {      //No eta shift |Y| < 0.8 addedSignal
+} else if ( trainConfig == 15 ) {      //No eta shift |Y| < 0.8 addedSignal
 
        ConvCutarray[0] = "8000012002493603007200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Single sec  Pt cut > 0.075
        ConvCutarray[1] = "8000012002193603007200000000"; ElecCutarray[1] = "9047540025310262171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + Single sec  Pt cut > 0.100
@@ -341,7 +338,7 @@ else if( trainConfig == 4 ) {
        ConvCutarray[5] = "8000012002093603007200000000"; ElecCutarray[5] = "9057540025310262171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx primary electron -3,5
        
        
-} else if ( trainConfig == 17 ) {        //No eta shift |Y| < 0.8 addedSignal
+} else if ( trainConfig == 16 ) {        //No eta shift |Y| < 0.8 addedSignal
        
        ConvCutarray[0] = "8000012002093603007200000000"; ElecCutarray[0] = "9043540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx pion rejec primary 2.0sigmas Low and 0 High momentum
        ConvCutarray[1] = "8000012002093603007200000000"; ElecCutarray[1] = "9047740025310262171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100  New Standard cut + dEdx pion rejec primary 0.3 GeV Low and 3.5 High momentum
@@ -351,7 +348,7 @@ else if( trainConfig == 4 ) {
        ConvCutarray[5] = "8000012002093603007200000000"; ElecCutarray[5] = "9047540025310262171"; MesonCutarray[5] = "01031005009000"; //standard cut Pi0 pPb 00-100 Standard cut + Alpha cut < 0.7
        
        
-} else if ( trainConfig == 18 ) {         //No eta shift |Y| < 0.8 addedSignal
+} else if ( trainConfig == 17 ) {         //No eta shift |Y| < 0.8 addedSignal
 
        ConvCutarray[0] = "8000012002093603001200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + qT < 0.1
        ConvCutarray[1] = "8000012002093603007200000000"; ElecCutarray[1] = "9047540025310262141"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + InvMass(e+,e-) < 0.050
@@ -361,20 +358,18 @@ else if( trainConfig == 4 ) {
        ConvCutarray[5] = "8000012002093603007200000000"; ElecCutarray[5] = "9042540025310262171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + dEdx pion rejec  primary  2.0sigmas Low and -1 High momentum 
            
        
-} else if ( trainConfig == 19 ) {         //No eta shift |Y| < 0.8 addedSignal
+} else if ( trainConfig == 18 ) {         //No eta shift |Y| < 0.8 addedSignal
   
         ConvCutarray[0] = "8000012002093803007200000000"; ElecCutarray[0] = "9047540025310262171"; MesonCutarray[0] = "01031035009000"; //standard cut Pi0 pPb 00-100 Standard cut + dEdx pion rejec  secon    2.0sigmas Low and  1 High momentum
        ConvCutarray[1] = "8000012002093603007200000000"; ElecCutarray[1] = "9047540025310272171"; MesonCutarray[1] = "01031035009000"; //standard cut Pi0 PbPb 00-100 + 100 events backgroubd
        ConvCutarray[2] = "8000012002093603007200000000"; ElecCutarray[2] = "9047540025310262171"; MesonCutarray[2] = "01031035009000"; //standard cut Pi0 PbPb 00-100 + Standard
        ConvCutarray[3] = "8000012002093603007200000000"; ElecCutarray[3] = "9047540025310262171"; MesonCutarray[3] = "01031035000000"; //standard cut Pi0 PbPb 00-100 + No extra smearing
        ConvCutarray[4] = "8000012002093603007200000000"; ElecCutarray[4] = "9047540025300262171"; MesonCutarray[4] = "01031035009000"; //standard cut Pi0 PbPb 00-100 + No psi pair 
-       ConvCutarray[5] = "8000012002093603007200000000"; ElecCutarray[5] = "9047540025310252171"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100 + 50 events background
+       ConvCutarray[5] = "8000012002093603007200000000"; ElecCutarray[5] = "9047540023310262371"; MesonCutarray[5] = "01031035009000"; //standard cut Pi0 PbPb 00-100  //Tracks 2011
  } 
 
  
-   
-   
-
+  
        
 
    TList *ConvCutList  = new TList();
@@ -400,11 +395,10 @@ else if( trainConfig == 4 ) {
 
 
       analysisCuts[i] = new AliConversionCuts();
-      if( ! analysisCuts[i]->InitializeCutsFromCutString(ConvCutarray[i].Data()) ) {
+   if( ! analysisCuts[i]->InitializeCutsFromCutString(ConvCutarray[i].Data()) ) {
             cout<<"ERROR: analysisCuts [" <<i<<"]"<<endl;
             return 0;
-      }
-   else {
+   } else {
 
    if ( trainConfig == 1 || trainConfig == 3 || trainConfig == 4  ){
 
@@ -451,20 +445,17 @@ else if( trainConfig == 4 ) {
                analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_pPb_5023GeV_60100V0A", "Eta_Hijing_LHC13e7_pPb_5023GeV_60100V0A", "","Pi0_Fit_Data_pPb_5023GeV_60100V0A","Eta_Fit_Data_pPb_5023GeV_60100V0A");
             }
          }
-   }
-      
-  else if ( trainConfig == 5 ||  trainConfig == 6  || trainConfig == 7 ){
+         
+   } else if ( trainConfig == 5 ||  trainConfig == 6 ){
 
          if (i == 0 && doWeighting){
             analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_addSig_pPb_5023GeV_MBV0A", "Eta_Hijing_LHC13e7_addSig_pPb_5023GeV_MBV0A", "","Pi0_Fit_Data_pPb_5023GeV_MBV0A","Eta_Fit_Data_pPb_5023GeV_MBV0A");
          }
          if (i == 1 && doWeighting){
             analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_addSig_pPb_5023GeV_0020V0A", "Eta_Hijing_LHC13e7_addSig_pPb_5023GeV_0020V0A", "","Pi0_Fit_Data_pPb_5023GeV_0020V0A","Eta_Fit_Data_pPb_5023GeV_0020V0A");
-            
          }
          if (i == 2 && doWeighting){
             analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_addSig_pPb_5023GeV_2040V0A", "Eta_Hijing_LHC13e7_addSig_pPb_5023GeV_2040V0A", "","Pi0_Fit_Data_pPb_5023GeV_2040V0A","Eta_Fit_Data_pPb_5023GeV_2040V0A");
-            
          }
          if (i == 3 && doWeighting){
             analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_addSig_pPb_5023GeV_4060V0A", "Eta_Hijing_LHC13e7_addSig_pPb_5023GeV_4060V0A", "","Pi0_Fit_Data_pPb_5023GeV_4060V0A","Eta_Fit_Data_pPb_5023GeV_4060V0A");
@@ -475,19 +466,19 @@ else if( trainConfig == 4 ) {
          if (i == 5 && doWeighting){
             analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_addSig_pPb_5023GeV_60100V0A", "Eta_Hijing_LHC13e7_addSig_pPb_5023GeV_60100V0A", "","Pi0_Fit_Data_pPb_5023GeV_60100V0A","Eta_Fit_Data_pPb_5023GeV_60100V0A");
          }
-   
-  }
-  else if ( trainConfig == 8 ||  trainConfig == 9  || trainConfig == 10 || trainConfig == 11 ||  trainConfig == 12  || trainConfig == 13 ){
+         
+ }  else if ( trainConfig == 7 ||  trainConfig == 8  || trainConfig == 9 || trainConfig == 10 ||  trainConfig == 11  || trainConfig == 12 ){
     
          if (doWeighting){
             if (generatorName.CompareTo("DPMJET")==0){
                analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_DPMJET_LHC13b2_efix_pPb_5023GeV_MBV0A", "Eta_DPMJET_LHC13b2_efix_pPb_5023GeV_MBV0A", "","Pi0_Fit_Data_pPb_5023GeV_MBV0A","Eta_Fit_Data_pPb_5023GeV_MBV0A");
             } else if (generatorName.CompareTo("HIJING")==0){
+             
                analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_pPb_5023GeV_MBV0A", "Eta_Hijing_LHC13e7_pPb_5023GeV_MBV0A", "","Pi0_Fit_Data_pPb_5023GeV_MBV0A","Eta_Fit_Data_pPb_5023GeV_MBV0A");
             }
          }
   }
-  else if ( trainConfig == 14 ||  trainConfig == 15  || trainConfig == 16 || trainConfig == 17 ||  trainConfig == 18  || trainConfig == 19 ){
+  else if ( trainConfig == 13 ||  trainConfig == 14  || trainConfig == 15 || trainConfig == 16 ||  trainConfig == 17  || trainConfig == 18 ){
     
          if (doWeighting){
              analysisCuts[i]->SetUseReweightingWithHistogramFromFile(kTRUE, kTRUE, kFALSE, fileNameInputForWeighting, "Pi0_Hijing_LHC13e7_addSig_pPb_5023GeV_MBV0A", "Eta_Hijing_LHC13e7_addSig_pPb_5023GeV_MBV0A", "","Pi0_Fit_Data_pPb_5023GeV_MBV0A","Eta_Fit_Data_pPb_5023GeV_MBV0A");
@@ -500,7 +491,7 @@ else if( trainConfig == 4 ) {
       
        if (doEtaShiftIndCuts) {
          
-         if( trainConfig == 2 || trainConfig == 4 || trainConfig == 5 ){   //Apply_eta shift
+         if( trainConfig == 1 || trainConfig == 2 || trainConfig == 4 || trainConfig == 5 ){   //Apply_eta shift
          
              analysisCuts[i]->DoEtaShift(doEtaShiftIndCuts);
              analysisCuts[i]->SetEtaShift(stringShift);
diff --git a/PWGGA/GammaConv/macros/AddTask_GammaConvEtaPiPlPiMiGamma_pPb.C b/PWGGA/GammaConv/macros/AddTask_GammaConvEtaPiPlPiMiGamma_pPb.C
new file mode 100644 (file)
index 0000000..bab51b7
--- /dev/null
@@ -0,0 +1,222 @@
+void AddTask_GammaConvEtaPiPlPiMiGamma_pPb(    
+                                                                               Int_t trainConfig = 1,
+                                                                               Bool_t isMC       = kFALSE, //run MC 
+                                                                               Bool_t enableQAMesonTask = kTRUE, //enable QA in AliAnalysisTaskEtaToPiPlPiMiGamma
+                                                                               TString fileNameInputForWeighting = "MCSpectraInput.root", // path to file for weigting input
+                                                                               Bool_t doWeighting = kFALSE,  //enable Weighting
+                                                                               TString generatorName = "HIJING",                               
+                                                                               TString cutnumberAODBranch = "0000000060084001001500000"
+                                                                               ) {
+
+
+       // ================= Load Librariers =================================
+       gSystem->Load("libCore.so");  
+       gSystem->Load("libTree.so");
+       gSystem->Load("libGeom.so");
+       gSystem->Load("libVMC.so");
+       gSystem->Load("libPhysics.so");
+       gSystem->Load("libMinuit");
+       gSystem->Load("libSTEERBase");
+       gSystem->Load("libESD");
+       gSystem->Load("libAOD");
+       gSystem->Load("libANALYSIS");
+       gSystem->Load("libANALYSISalice");  
+       gSystem->Load("libPWGGAGammaConv.so");
+       gSystem->Load("libCDB.so");
+       gSystem->Load("libSTEER.so");
+       gSystem->Load("libSTEERBase.so");
+       gSystem->Load("libTENDER.so");
+       gSystem->Load("libTENDERSupplies.so");
+
+       // ================== GetAnalysisManager ===============================
+       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+       if (!mgr) {
+               Error(Form("AddTask_GammaConvEtaPiPlPiMiGamma_pPb_%i",trainConfig), "No analysis manager found.");
+               return ;
+       }
+
+       // ================== GetInputEventHandler =============================
+       AliVEventHandler *inputHandler=mgr->GetInputEventHandler();
+       
+       //========= Add PID Reponse to ANALYSIS manager ====
+       if(!(AliPIDResponse*)mgr->GetTask("PIDResponseTask")){
+               gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
+               AddTaskPIDResponse(isMC);
+       }
+       
+       //=========  Set Cutnumber for V0Reader ================================
+       TString ConvCutnumber = "8000000060084001001500000000";   //Online  V0 finder
+       TString PionCuts      = "00000221";            //Electron Cuts
+               
+       Bool_t doEtaShift = kFALSE;
+
+       AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
+       
+       //========= Add V0 Reader to  ANALYSIS manager if not yet existent =====
+       if( !(AliV0ReaderV1*)mgr->GetTask("V0ReaderV1") ){
+               AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1("V0ReaderV1");
+               
+               fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
+               fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
+               fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
+               
+               if (!mgr) {
+                       Error("AddTask_V0ReaderV1", "No analysis manager found.");
+                       return;
+               }
+
+               // Set AnalysisCut Number
+               AliConversionCuts *fCuts=NULL;
+               if( ConvCutnumber !=""){
+                       fCuts= new AliConversionCuts(ConvCutnumber.Data(),ConvCutnumber.Data());
+                       fCuts->SetPreSelectionCutFlag(kTRUE);
+                       if(fCuts->InitializeCutsFromCutString(ConvCutnumber.Data())){
+                               fCuts->DoEtaShift(doEtaShift);
+                               fV0ReaderV1->SetConversionCuts(fCuts);
+                               fCuts->SetFillCutHistograms("",kTRUE);
+                       }
+               }
+               if(inputHandler->IsA()==AliAODInputHandler::Class()){
+               // AOD mode
+                       fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
+               }
+               fV0ReaderV1->Init();
+
+               AliLog::SetGlobalLogLevel(AliLog::kInfo);
+
+               //connect input V0Reader
+               mgr->AddTask(fV0ReaderV1);
+               mgr->ConnectInput(fV0ReaderV1,0,cinput);
+       }
+
+       //================================================
+       //========= Add Electron Selector ================
+
+
+       if( !(AliPrimaryPionSelector*)mgr->GetTask("PionSelector") ){
+
+               AliPrimaryPionSelector *fPionSelector = new AliPrimaryPionSelector("PionSelector");
+               // Set AnalysisCut Number
+
+               AliPrimaryPionCuts *fPionCuts=0;
+               if( PionCuts!=""){
+                       fPionCuts= new AliPrimaryPionCuts(PionCuts.Data(),PionCuts.Data());
+                       if(fPionCuts->InitializeCutsFromCutString(PionCuts.Data())){
+                               fPionSelector->SetPrimaryPionCuts(fPionCuts);
+                               fPionCuts->SetFillCutHistograms("",kTRUE);
+
+                       }
+               }
+
+               fPionSelector->Init();
+               mgr->AddTask(fPionSelector);
+               
+               AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer();
+
+               //connect input V0Reader
+               mgr->ConnectInput (fPionSelector,0,cinput1);
+
+       }
+
+       
+       
+       AliAnalysisTaskEtaToPiPlPiMiGamma *task=NULL;
+
+       task= new AliAnalysisTaskEtaToPiPlPiMiGamma(Form("GammaConvEtaPiPlPiMiGamma_%i",trainConfig));
+
+       task->SetIsHeavyIon(2);
+       task->SetIsMC(isMC);
+
+       // Cut Numbers to use in Analysis
+       Int_t numberOfCuts = 1;
+       TString *ConvCutarray    = new TString[numberOfCuts];
+       TString *PionCutarray    = new TString[numberOfCuts];
+
+       TString *MesonCutarray   = new TString[numberOfCuts];
+
+       Bool_t doEtaShiftIndCuts = kFALSE;
+       TString stringShift = "";
+
+       // Shifting in pPb direction
+
+       doEtaShiftIndCuts = kTRUE;
+       stringShift = "pPb";
+
+       if( trainConfig == 1 ) {
+               ConvCutarray[0] = "8000011002092170008260400000"; PionCutarray[0] = "00000362"; MesonCutarray[0] = "01039035009000"; //standard cut Pi0 PbPb 00-100                     
+       } 
+       
+       TList *ConvCutList  = new TList();
+       TList *MesonCutList = new TList();
+       TList *PionCutList  = new TList();
+
+       TList *HeaderList = new TList();
+       TObjString *Header1 = new TObjString("pi0_1");
+       HeaderList->Add(Header1);
+       TObjString *Header3 = new TObjString("eta_2");
+       HeaderList->Add(Header3);
+       
+       ConvCutList->SetOwner(kTRUE);
+       AliConversionCuts **analysisCuts             = new AliConversionCuts*[numberOfCuts];
+       MesonCutList->SetOwner(kTRUE);
+       AliConversionMesonCuts **analysisMesonCuts   = new AliConversionMesonCuts*[numberOfCuts];
+       PionCutList->SetOwner(kTRUE);
+       AliPrimaryPionCuts **analysisPionCuts     = new AliPrimaryPionCuts*[numberOfCuts];
+
+       for(Int_t i = 0; i<numberOfCuts; i++){
+
+               analysisCuts[i] = new AliConversionCuts();
+               if( ! analysisCuts[i]->InitializeCutsFromCutString(ConvCutarray[i].Data()) ) {
+                               cout<<"ERROR: analysisCuts [" <<i<<"]"<<endl;
+                               return 0;
+               } else {                                
+                       ConvCutList->Add(analysisCuts[i]);
+                       analysisCuts[i]->SetFillCutHistograms("",kFALSE);
+                       analysisCuts[i]->SetAcceptedHeader(HeaderList);
+               }
+
+               analysisMesonCuts[i] = new AliConversionMesonCuts();
+               
+               if( ! analysisMesonCuts[i]->InitializeCutsFromCutString(MesonCutarray[i].Data()) ) {
+                       cout<<"ERROR: analysisMesonCuts [ " <<i<<" ] "<<endl;
+                       return 0;
+               } else {
+                       MesonCutList->Add(analysisMesonCuts[i]);
+                       analysisMesonCuts[i]->SetFillCutHistograms("");
+               }
+
+
+               TString cutName( Form("%s_%s_%s",ConvCutarray[i].Data(),PionCutarray[i].Data(),MesonCutarray[i].Data() ) );
+               analysisPionCuts[i] = new AliPrimaryPionCuts();
+               if( !analysisPionCuts[i]->InitializeCutsFromCutString(PionCutarray[i].Data())) {
+                       cout<< "ERROR:  analysisPionCuts [ " <<i<<" ] "<<endl;
+                       return 0;
+               } else { 
+                       PionCutList->Add(analysisPionCuts[i]);
+                       analysisPionCuts[i]->SetFillCutHistograms("",kFALSE,cutName); 
+               }
+               
+
+       }
+
+
+       task->SetConversionCutList(numberOfCuts,ConvCutList);
+       task->SetMesonCutList(MesonCutList);
+       task->SetPionCutList(PionCutList);
+
+       task->SetMoveParticleAccordingToVertex(kTRUE);
+
+       if(enableQAMesonTask) task->SetDoMesonQA(kTRUE);
+
+       //connect containers
+       AliAnalysisDataContainer *coutput =
+       mgr->CreateContainer(Form("GammaConvEtaPiPlPiMiGamma_%i",trainConfig), TList::Class(),
+                                                       AliAnalysisManager::kOutputContainer,Form("GammaConvEtaPiPlPiMiGamma_%i.root",trainConfig));
+
+       mgr->AddTask(task);
+       mgr->ConnectInput(task,0,cinput);
+       mgr->ConnectOutput(task,1,coutput);
+
+       return;
+
+}
index dc51a29..8827e4c 100644 (file)
@@ -125,12 +125,12 @@ void AddTask_GammaConvV1_pPb(  Int_t trainConfig = 1,  //change different set of
                cutarray[ 0] = "8000011002092170008220000000"; mesonCutArray[ 0] = "01621035009000"; //tighten psi pair and qt in 2D
                cutarray[ 1] = "8000011002092170008260000000"; mesonCutArray[ 1] = "01621035009000"; //tighten psi pair and chi2 in 2D and qt in 2D                      
                cutarray[ 2] = "8000011002092170008220400000"; mesonCutArray[ 2] = "01621035009000"; //clean cuts
-               cutarray[ 3] = "8000011002092170008260400000"; mesonCutArray[ 3] = "01621035009000"; //clean cuts
+               cutarray[ 3] = "8000011002092170008260400000"; mesonCutArray[ 3] = "01621035009000"; //clean cuts ///New STANDARD CUT
        } else if (trainConfig == 6) {
                cutarray[ 0] = "8000012002092170008220000000"; mesonCutArray[ 0] = "01621035009000"; //tighten psi pair and qt in 2D
                cutarray[ 1] = "8000012002092170008260000000"; mesonCutArray[ 1] = "01621035009000"; //tighten psi pair and chi2 in 2D and qt in 2D                      
                cutarray[ 2] = "8000012002092170008220400000"; mesonCutArray[ 2] = "01621035009000"; //clean cuts
-               cutarray[ 3] = "8000012002092170008260400000"; mesonCutArray[ 3] = "01621035009000"; //clean cuts
+               cutarray[ 3] = "8000012002092170008260400000"; mesonCutArray[ 3] = "01621035009000"; //clean cuts ///New STANDARD CUT
        } else if (trainConfig == 7) {
                cutarray[ 0] = "8000011001092170008260400000"; mesonCutArray[ 0] = "01621035009000";  //new standard eta=0.9 y=0.8  // minR 2.8
                cutarray[ 1] = "8000011009092170008260400000"; mesonCutArray[ 1] = "01621035009000";  //new standard eta=0.9 y=0.8  //minR 7.5
index 11daf1a..9f52c2e 100644 (file)
 #pragma link C++ class AliAnalysisTaskdPhi+;
 
 // Old tasks
-#pragma link C++ class AliAnalysisTaskCaloConv+;
 #pragma link C++ class AliAnalysisTaskGCPartToPWG4Part+;
 
+#pragma link C++ class AliPrimaryPionSelector+;
+#pragma link C++ class AliPrimaryPionCuts+;
+#pragma link C++ class AliAnalysisTaskEtaToPiPlPiMiGamma+;
+
+
 #endif