]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
- added new task for pi0 reconstruction using purely calorimeter clusters
authorfbock <friederike.bock@cern.ch>
Tue, 12 Aug 2014 12:30:55 +0000 (14:30 +0200)
committerfbock <friederike.bock@cern.ch>
Tue, 12 Aug 2014 12:30:55 +0000 (14:30 +0200)
- added track matching of conversions and cluster for AliAnalysisTaskGammaConvCalo
- added functioning MC part for AliAnalysisTaskNeutralMesonToPiPlPiMiPiZero.cxx

14 files changed:
PWGGA/CMakelibPWGGAGammaConv.pkg
PWGGA/GammaConv/AliAODConversionPhoton.cxx
PWGGA/GammaConv/AliAODConversionPhoton.h
PWGGA/GammaConv/AliAnalysisTaskGammaCalo.cxx [new file with mode: 0644]
PWGGA/GammaConv/AliAnalysisTaskGammaCalo.h [new file with mode: 0644]
PWGGA/GammaConv/AliAnalysisTaskGammaConvCalo.cxx
PWGGA/GammaConv/AliAnalysisTaskGammaConvCalo.h
PWGGA/GammaConv/AliAnalysisTaskNeutralMesonToPiPlPiMiPiZero.cxx
PWGGA/GammaConv/AliCaloPhotonCuts.cxx
PWGGA/GammaConv/AliCaloPhotonCuts.h
PWGGA/GammaConv/AliV0ReaderV1.cxx
PWGGA/GammaConv/macros/AddTask_GammaCalo_pPb.C [new file with mode: 0644]
PWGGA/GammaConv/macros/AddTask_GammaConvCalo_pPb.C
PWGGA/PWGGAGammaConvLinkDef.h

index afadd733d47c3c889542616e2d3fec2e917fd718..08f9b1351d7ff0a0d178de7ac6b318281a315148 100644 (file)
@@ -62,6 +62,7 @@ set ( SRCS
        GammaConv/AliAnalysisTaskEtaToPiPlPiMiGamma.cxx
        GammaConv/AliAnalysisTaskNeutralMesonToPiPlPiMiPiZero.cxx
         GammaConv/AliAnalysisTaskGammaConvCalo.cxx
+       GammaConv/AliAnalysisTaskGammaCalo.cxx
 )
 
 string ( REPLACE ".cxx" ".h" HDRS "${SRCS}" )
index bdb432943505dcf4336855fa7a5437ee9d484895..636d131e4981735e984716bd17d72d90ff0e010f 100644 (file)
@@ -13,6 +13,7 @@ AliConversionPhotonBase(),
 fDCArPrimVtx(0),
 fDCAzPrimVtx(0),
 fCaloPhoton(0),
+fCaloClusterRef(-1),
 fNCaloPhotonMCLabels(0),
 fNCaloPhotonMotherMCLabels(0),
 fCaloPhotonMCFlags(0)
@@ -33,6 +34,7 @@ AliConversionPhotonBase(*((AliConversionPhotonBase*)kfphoton)),
 fDCArPrimVtx(0),
 fDCAzPrimVtx(0),
 fCaloPhoton(0),
+fCaloClusterRef(-1),
 fNCaloPhotonMCLabels(0),
 fNCaloPhotonMotherMCLabels(0),
 fCaloPhotonMCFlags(0)
@@ -60,6 +62,7 @@ AliConversionPhotonBase(),
 fDCArPrimVtx(0),
 fDCAzPrimVtx(0),
 fCaloPhoton(0),
+fCaloClusterRef(-1),
 fNCaloPhotonMCLabels(0),
 fNCaloPhotonMotherMCLabels(0),
 fCaloPhotonMCFlags(0)
@@ -83,6 +86,7 @@ AliConversionPhotonBase(original),
 fDCArPrimVtx(original.fDCArPrimVtx),
 fDCAzPrimVtx(original.fDCAzPrimVtx),
 fCaloPhoton(original.fCaloPhoton),
+fCaloClusterRef(original.fCaloClusterRef),
 fNCaloPhotonMCLabels(original.fNCaloPhotonMCLabels),
 fNCaloPhotonMotherMCLabels(original.fNCaloPhotonMotherMCLabels),
 fCaloPhotonMCFlags(original.fCaloPhotonMCFlags)
index 6d56d23c5f602390b61b03962c5c990a4f411a6b..247f787280f0131ccfebea84766400502e7fe0c2 100644 (file)
@@ -57,6 +57,8 @@ class AliAODConversionPhoton : public AliAODConversionParticle, public AliConver
         Int_t GetNCaloPhotonMotherMCLabels(){return fNCaloPhotonMotherMCLabels;}
                void SetCaloPhotonMCFlags(AliStack *MCStack);
                void SetCaloPhotonMCFlagsAOD(AliVEvent* event);
+               void SetCaloClusterRef(Long_t ref){fCaloClusterRef = ref;}
+               Long_t GetCaloClusterRef()const {return fCaloClusterRef;}
                
                //Calo cluster MC identifiers
                Bool_t IsLargestComponentPhoton(){return fCaloPhotonMCFlags&kIsPhoton;}                                         // largest contribution to cluster is photon
@@ -76,6 +78,7 @@ class AliAODConversionPhoton : public AliAODConversionParticle, public AliConver
                Float_t fDCArPrimVtx;
                Float_t fDCAzPrimVtx;
                Bool_t fCaloPhoton;
+               Long_t fCaloClusterRef;
                Int_t fNCaloPhotonMCLabels;
         Int_t fNCaloPhotonMotherMCLabels;
         Int_t fCaloPhotonMCFlags;
diff --git a/PWGGA/GammaConv/AliAnalysisTaskGammaCalo.cxx b/PWGGA/GammaConv/AliAnalysisTaskGammaCalo.cxx
new file mode 100644 (file)
index 0000000..c3af50e
--- /dev/null
@@ -0,0 +1,2160 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                                                                                               *
+ * Author: Baldo Sahlmueller, 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 used to do analysis on conversion photons + calo photons
+//----------------------------------------------------------------
+//////////////////////////////////////////////////////////////////
+#include "TChain.h"
+#include "TTree.h"
+#include "TBranch.h"
+#include "TFile.h"
+#include "TH1F.h"
+#include "TH2F.h"
+#include "TH3F.h"
+#include "THnSparse.h"
+#include "TCanvas.h"
+#include "TNtuple.h"
+#include "AliAnalysisTask.h"
+#include "AliAnalysisManager.h"
+#include "AliESDEvent.h"
+#include "AliESDInputHandler.h"
+#include "AliMCEventHandler.h"
+#include "AliMCEvent.h"
+#include "AliMCParticle.h"
+#include "AliCentrality.h"
+#include "AliESDVZERO.h"
+#include "AliESDpid.h"
+#include "AliAnalysisTaskGammaCalo.h"
+#include "AliVParticle.h"
+#include "AliESDtrack.h"
+#include "AliESDtrackCuts.h"
+#include "AliKFVertex.h"
+#include "AliV0ReaderV1.h"
+#include "AliGenCocktailEventHeader.h"
+#include "AliAODMCParticle.h"
+#include "AliAODMCHeader.h"
+#include "AliEventplane.h"
+#include "AliAnalysisTaskEMCALClusterizeFast.h"
+#include "AliAODEvent.h"
+#include "AliAODInputHandler.h"
+#include "AliESDEvent.h"
+#include "AliESDInputHandler.h"
+#include "AliInputEventHandler.h"
+
+ClassImp(AliAnalysisTaskGammaCalo)
+
+//________________________________________________________________________
+AliAnalysisTaskGammaCalo::AliAnalysisTaskGammaCalo(): AliAnalysisTaskSE(),
+       fV0Reader(NULL),
+       fBGHandler(NULL),
+       fInputEvent(NULL),
+       fMCEvent(NULL),
+       fMCStack(NULL),
+       fCutFolder(NULL),
+       fESDList(NULL),
+       fBackList(NULL),
+       fMotherList(NULL),
+       fTrueList(NULL),
+       fMCList(NULL),
+       fHeaderNameList(NULL),
+       fOutputContainer(NULL),
+       fClusterCandidates(NULL),
+       fEventCutArray(NULL),
+       fEventCuts(NULL),
+       fClusterCutArray(NULL),
+       fCaloPhotonCuts(NULL),
+       fMesonCutArray(NULL),
+       fMesonCuts(NULL),
+       fHistoMotherInvMassPt(NULL),
+       fSparseMotherInvMassPtZM(NULL),
+       fHistoMotherBackInvMassPt(NULL),
+       fSparseMotherBackInvMassPtZM(NULL),
+       fHistoMotherInvMassEalpha(NULL),
+       fHistoMotherPi0PtY(NULL),
+       fHistoMotherEtaPtY(NULL),
+       fHistoMotherPi0PtAlpha(NULL),
+       fHistoMotherEtaPtAlpha(NULL),
+       fHistoMotherPi0PtOpenAngle(NULL),
+       fHistoMotherEtaPtOpenAngle(NULL),
+       fHistoMotherInvMassECalib(NULL),
+       fHistoMotherInvMassECalibalpha(NULL),
+       fHistoClusGammaPt(NULL),
+       fHistoMCHeaders(NULL),
+       fHistoMCAllGammaPt(NULL),
+       fHistoMCDecayGammaPi0Pt(NULL),
+       fHistoMCDecayGammaRhoPt(NULL),
+       fHistoMCDecayGammaEtaPt(NULL),
+       fHistoMCDecayGammaOmegaPt(NULL),
+       fHistoMCDecayGammaEtapPt(NULL),
+       fHistoMCDecayGammaPhiPt(NULL),
+       fHistoMCDecayGammaSigmaPt(NULL),
+       fHistoMCPi0Pt(NULL),
+       fHistoMCPi0WOWeightPt(NULL),
+       fHistoMCEtaPt(NULL),
+       fHistoMCEtaWOWeightPt(NULL),
+       fHistoMCPi0InAccPt(NULL),
+       fHistoMCEtaInAccPt(NULL),
+       fHistoMCPi0PtY(NULL),
+       fHistoMCEtaPtY(NULL),
+       fHistoMCK0sPt(NULL),
+       fHistoMCK0sWOWeightPt(NULL),
+       fHistoMCK0sPtY(NULL),
+       fHistoMCSecPi0PtvsSource(NULL),
+       fHistoMCSecPi0Source(NULL),
+       fHistoMCSecEtaPt(NULL),
+       fHistoMCSecEtaSource(NULL),
+       fHistoTrueMotherInvMassPt(NULL),
+       fHistoTrueMotherCaloPhotonInvMassPt(NULL),
+       fHistoTrueMotherCaloConvertedPhotonInvMassPt(NULL),
+       fHistoTrueMotherCaloMixedPhotonConvPhotonInvMassPt(NULL),
+       fHistoTruePi0CaloConvertedPhotonInvMassPt(NULL),
+       fHistoTrueEtaCaloConvertedPhotonInvMassPt(NULL),
+       fHistoTrueMotherCaloElectronInvMassPt(NULL),
+       fHistoTrueMotherCaloMergedClusterInvMassPt(NULL),
+       fHistoTrueMotherCaloMergedClusterPartConvInvMassPt(NULL),
+       fHistoTruePrimaryMotherInvMassPt(NULL),
+       fHistoTruePrimaryMotherW0WeightingInvMassPt(NULL),
+       fProfileTruePrimaryMotherWeightsInvMassPt(NULL),
+       fHistoTruePrimaryPi0MCPtResolPt(NULL),
+       fHistoTruePrimaryEtaMCPtResolPt(NULL),
+       fHistoTrueSecondaryMotherInvMassPt(NULL),
+       fHistoTrueSecondaryMotherFromK0sInvMassPt(NULL),
+       fHistoTrueK0sWithPi0DaughterMCPt(NULL),
+       fHistoTrueSecondaryMotherFromEtaInvMassPt(NULL),
+       fHistoTrueEtaWithPi0DaughterMCPt(NULL),
+       fHistoTrueSecondaryMotherFromLambdaInvMassPt(NULL),
+       fHistoTrueLambdaWithPi0DaughterMCPt(NULL),
+       fHistoTrueBckGGInvMassPt(NULL),
+       fHistoTrueBckContInvMassPt(NULL),
+       fHistoTruePi0PtY(NULL),
+       fHistoTrueEtaPtY(NULL),
+       fHistoTruePi0PtAlpha(NULL),
+       fHistoTrueEtaPtAlpha(NULL),
+       fHistoTruePi0PtOpenAngle(NULL),
+       fHistoTrueEtaPtOpenAngle(NULL),
+       fHistoClusPhotonBGPt(NULL),
+       fHistoClusPhotonPlusConvBGPt(NULL),
+       fHistoTrueClusGammaPt(NULL),
+       fHistoTrueClusUnConvGammaPt(NULL),
+       fHistoTrueClusUnConvGammaMCPt(NULL),
+       fHistoTrueClusElectronPt(NULL),
+       fHistoTrueClusConvGammaPt(NULL),
+       fHistoTrueClusConvGammaMCPt(NULL),
+       fHistoTrueClusConvGammaFullyPt(NULL),
+       fHistoTrueClusMergedGammaPt(NULL),
+       fHistoTrueClusMergedPartConvGammaPt(NULL),
+       fHistoTrueClusDalitzPt(NULL),
+       fHistoTrueClusDalitzMergedPt(NULL),
+       fHistoTrueClusPhotonFromElecMotherPt(NULL),
+       fHistoTrueClusShowerPt(NULL),
+       fHistoTrueClusSubLeadingPt(NULL),
+       fHistoTrueClusNParticles(NULL),
+       fHistoTrueClusEMNonLeadingPt(NULL),
+       fHistoTrueNLabelsInClus(NULL),
+       fHistoTruePrimaryClusGammaPt(NULL),
+       fHistoTruePrimaryClusGammaESDPtMCPt(NULL),
+       fHistoTruePrimaryClusConvGammaPt(NULL),
+       fHistoTruePrimaryClusConvGammaESDPtMCPt(NULL),
+       fHistoTrueSecondaryClusGammaPt(NULL),
+       fHistoTrueSecondaryClusConvGammaPt(NULL),
+       fHistoTrueSecondaryClusGammaFromXFromK0sPt(NULL),
+       fHistoTrueSecondaryClusConvGammaFromXFromK0sPt(NULL),
+       fHistoTrueSecondaryClusGammaFromXFromLambdaPt(NULL),
+       fHistoTrueSecondaryClusConvGammaFromXFromLambdaPt(NULL),
+       fHistoTrueSecondaryClusGammaFromXFromEtasPt(NULL),
+       fHistoTrueSecondaryClusConvGammaFromXFromEtasPt(NULL),
+       fHistoNEvents(NULL),
+       fHistoNGoodESDTracks(NULL),
+       fHistoNGammaCandidates(NULL),
+       fHistoNGoodESDTracksVsNGammaCanditates(NULL),
+       fHistoNV0Tracks(NULL),
+       fProfileEtaShift(NULL),
+       fEventPlaneAngle(-100),
+       fRandom(0),
+       fnCuts(0),
+       fiCut(0),
+       fIsHeavyIon(0),
+       fDoMesonAnalysis(kTRUE),
+       fDoMesonQA(0),
+       fDoClusterQA(0),
+       fIsFromMBHeader(kTRUE),
+       fIsMC(kFALSE)
+{
+  
+}
+
+//________________________________________________________________________
+AliAnalysisTaskGammaCalo::AliAnalysisTaskGammaCalo(const char *name):
+       AliAnalysisTaskSE(name),
+       fV0Reader(NULL),
+       fBGHandler(NULL),
+       fInputEvent(NULL),
+       fMCEvent(NULL),
+       fMCStack(NULL),
+       fCutFolder(NULL),
+       fESDList(NULL),
+       fBackList(NULL),
+       fMotherList(NULL),
+       fTrueList(NULL),
+       fMCList(NULL),
+       fHeaderNameList(NULL),
+       fOutputContainer(0),
+       fClusterCandidates(NULL),
+       fEventCutArray(NULL),
+       fEventCuts(NULL),
+       fClusterCutArray(NULL),
+       fCaloPhotonCuts(NULL),
+       fMesonCutArray(NULL),
+       fMesonCuts(NULL),
+       fHistoMotherInvMassPt(NULL),
+       fSparseMotherInvMassPtZM(NULL),
+       fHistoMotherBackInvMassPt(NULL),
+       fSparseMotherBackInvMassPtZM(NULL),
+       fHistoMotherInvMassEalpha(NULL),
+       fHistoMotherPi0PtY(NULL),
+       fHistoMotherEtaPtY(NULL),
+       fHistoMotherPi0PtAlpha(NULL),
+       fHistoMotherEtaPtAlpha(NULL),
+       fHistoMotherPi0PtOpenAngle(NULL),
+       fHistoMotherEtaPtOpenAngle(NULL),
+       fHistoMotherInvMassECalib(NULL),
+       fHistoMotherInvMassECalibalpha(NULL),
+       fHistoClusGammaPt(NULL),
+       fHistoMCHeaders(NULL),
+       fHistoMCAllGammaPt(NULL),
+       fHistoMCDecayGammaPi0Pt(NULL),
+       fHistoMCDecayGammaRhoPt(NULL),
+       fHistoMCDecayGammaEtaPt(NULL),
+       fHistoMCDecayGammaOmegaPt(NULL),
+       fHistoMCDecayGammaEtapPt(NULL),
+       fHistoMCDecayGammaPhiPt(NULL),
+       fHistoMCDecayGammaSigmaPt(NULL),
+       fHistoMCPi0Pt(NULL),
+       fHistoMCPi0WOWeightPt(NULL),
+       fHistoMCEtaPt(NULL),
+       fHistoMCEtaWOWeightPt(NULL),
+       fHistoMCPi0InAccPt(NULL),
+       fHistoMCEtaInAccPt(NULL),
+       fHistoMCPi0PtY(NULL),
+       fHistoMCEtaPtY(NULL),
+       fHistoMCK0sPt(NULL),
+       fHistoMCK0sWOWeightPt(NULL),
+       fHistoMCK0sPtY(NULL),
+       fHistoMCSecPi0PtvsSource(NULL),
+       fHistoMCSecPi0Source(NULL),
+       fHistoMCSecEtaPt(NULL),
+       fHistoMCSecEtaSource(NULL),
+       fHistoTrueMotherInvMassPt(NULL),
+       fHistoTrueMotherCaloPhotonInvMassPt(NULL),
+       fHistoTrueMotherCaloConvertedPhotonInvMassPt(NULL),
+       fHistoTrueMotherCaloMixedPhotonConvPhotonInvMassPt(NULL),
+       fHistoTruePi0CaloConvertedPhotonInvMassPt(NULL),
+       fHistoTrueEtaCaloConvertedPhotonInvMassPt(NULL),
+       fHistoTrueMotherCaloElectronInvMassPt(NULL),
+       fHistoTrueMotherCaloMergedClusterInvMassPt(NULL),
+       fHistoTrueMotherCaloMergedClusterPartConvInvMassPt(NULL),
+       fHistoTruePrimaryMotherInvMassPt(NULL),
+       fHistoTruePrimaryMotherW0WeightingInvMassPt(NULL),
+       fProfileTruePrimaryMotherWeightsInvMassPt(NULL),
+       fHistoTruePrimaryPi0MCPtResolPt(NULL),
+       fHistoTruePrimaryEtaMCPtResolPt(NULL),
+       fHistoTrueSecondaryMotherInvMassPt(NULL),
+       fHistoTrueSecondaryMotherFromK0sInvMassPt(NULL),
+       fHistoTrueK0sWithPi0DaughterMCPt(NULL),
+       fHistoTrueSecondaryMotherFromEtaInvMassPt(NULL),
+       fHistoTrueEtaWithPi0DaughterMCPt(NULL),
+       fHistoTrueSecondaryMotherFromLambdaInvMassPt(NULL),
+       fHistoTrueLambdaWithPi0DaughterMCPt(NULL),
+       fHistoTrueBckGGInvMassPt(NULL),
+       fHistoTrueBckContInvMassPt(NULL),
+       fHistoTruePi0PtY(NULL),
+       fHistoTrueEtaPtY(NULL),
+       fHistoTruePi0PtAlpha(NULL),
+       fHistoTrueEtaPtAlpha(NULL),
+       fHistoTruePi0PtOpenAngle(NULL),
+       fHistoTrueEtaPtOpenAngle(NULL),
+       fHistoClusPhotonBGPt(NULL),
+       fHistoClusPhotonPlusConvBGPt(NULL),
+       fHistoTrueClusGammaPt(NULL),
+       fHistoTrueClusUnConvGammaPt(NULL),
+       fHistoTrueClusUnConvGammaMCPt(NULL),
+       fHistoTrueClusElectronPt(NULL),
+       fHistoTrueClusConvGammaPt(NULL),
+       fHistoTrueClusConvGammaMCPt(NULL),
+       fHistoTrueClusConvGammaFullyPt(NULL),
+       fHistoTrueClusMergedGammaPt(NULL),
+       fHistoTrueClusMergedPartConvGammaPt(NULL),
+       fHistoTrueClusDalitzPt(NULL),
+       fHistoTrueClusDalitzMergedPt(NULL),
+       fHistoTrueClusPhotonFromElecMotherPt(NULL),
+       fHistoTrueClusShowerPt(NULL),
+       fHistoTrueClusSubLeadingPt(NULL),
+       fHistoTrueClusNParticles(NULL),
+       fHistoTrueClusEMNonLeadingPt(NULL),
+       fHistoTrueNLabelsInClus(NULL),
+       fHistoTruePrimaryClusGammaPt(NULL),
+       fHistoTruePrimaryClusGammaESDPtMCPt(NULL),
+       fHistoTruePrimaryClusConvGammaPt(NULL),
+       fHistoTruePrimaryClusConvGammaESDPtMCPt(NULL),
+       fHistoTrueSecondaryClusGammaPt(NULL),
+       fHistoTrueSecondaryClusConvGammaPt(NULL),
+       fHistoTrueSecondaryClusGammaFromXFromK0sPt(NULL),
+       fHistoTrueSecondaryClusConvGammaFromXFromK0sPt(NULL),
+       fHistoTrueSecondaryClusGammaFromXFromLambdaPt(NULL),
+       fHistoTrueSecondaryClusConvGammaFromXFromLambdaPt(NULL),
+       fHistoTrueSecondaryClusGammaFromXFromEtasPt(NULL),
+       fHistoTrueSecondaryClusConvGammaFromXFromEtasPt(NULL),
+       fHistoNEvents(NULL),
+       fHistoNGoodESDTracks(NULL),
+       fHistoNGammaCandidates(NULL),
+       fHistoNGoodESDTracksVsNGammaCanditates(NULL),
+       fHistoNV0Tracks(NULL),
+       fProfileEtaShift(NULL),
+       fEventPlaneAngle(-100),
+       fRandom(0),
+       fnCuts(0),
+       fiCut(0),
+       fIsHeavyIon(0),
+       fDoMesonAnalysis(kTRUE),
+       fDoMesonQA(0),
+       fDoClusterQA(0),
+       fIsFromMBHeader(kTRUE),
+       fIsMC(kFALSE)
+{
+  // Define output slots here
+  DefineOutput(1, TList::Class());
+}
+
+AliAnalysisTaskGammaCalo::~AliAnalysisTaskGammaCalo()
+{
+       if(fClusterCandidates){
+               delete fClusterCandidates;
+               fClusterCandidates = 0x0;
+       }
+       if(fBGHandler){
+               delete[] fBGHandler;
+               fBGHandler = 0x0;
+       }
+}
+//___________________________________________________________
+void AliAnalysisTaskGammaCalo::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};
+       
+       fSparseMotherInvMassPtZM = new THnSparseF*[fnCuts];
+       fSparseMotherBackInvMassPtZM = new THnSparseF*[fnCuts];
+       
+       fBGHandler = new AliGammaConversionAODBGHandler*[fnCuts];
+
+       
+       for(Int_t iCut = 0; iCut<fnCuts;iCut++){
+               if (((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
+                       TString cutstringEvent  = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
+                       TString cutstringCalo   = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
+                       TString cutstringMeson  = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
+                       
+                       Int_t collisionSystem = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(0,1));
+                       Int_t centMin = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(1,1));
+                       Int_t centMax = atoi((TString)(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber())(2,1));
+                       
+                       if(collisionSystem == 1 || collisionSystem == 2 ||
+                               collisionSystem == 5 || collisionSystem == 8 ||
+                               collisionSystem == 9){
+                               centMin = centMin*10;
+                               centMax = centMax*10;
+                               if(centMax ==0 && centMax!=centMin) centMax=100;
+                       } 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",cutstringEvent.Data(),cutstringCalo.Data(), cutstringMeson.Data()));
+                       fBackList[iCut]->SetOwner(kTRUE);
+                       fCutFolder[iCut]->Add(fBackList[iCut]);
+                       
+                       fSparseMotherBackInvMassPtZM[iCut] = new THnSparseF("Back_Back_InvMass_Pt_z_m","Back_Back_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
+                       fBackList[iCut]->Add(fSparseMotherBackInvMassPtZM[iCut]);
+                       
+                       fMotherList[iCut] = new TList();
+                       fMotherList[iCut]->SetName(Form("%s_%s_%s Mother histograms",cutstringEvent.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
+                       fMotherList[iCut]->SetOwner(kTRUE);
+                       fCutFolder[iCut]->Add(fMotherList[iCut]);
+                       
+                       fSparseMotherInvMassPtZM[iCut] = new THnSparseF("Back_Mother_InvMass_Pt_z_m","Back_Mother_InvMass_Pt_z_m",nDim,nBins,xMin,xMax);
+                       fMotherList[iCut]->Add(fSparseMotherInvMassPtZM[iCut]);
+                       
+                       if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
+                               fBGHandler[iCut] = new AliGammaConversionAODBGHandler(
+                                                                                                                                       collisionSystem,centMin,centMax,
+                                                                                                                                       ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetNumberOfBGEvents(),
+                                                                                                                                       ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->UseTrackMultiplicity());
+                       }
+               }
+       }
+}
+//________________________________________________________________________
+void AliAnalysisTaskGammaCalo::UserCreateOutputObjects(){
+  
+       // Create histograms
+       if(fOutputContainer != NULL){
+               delete fOutputContainer;
+               fOutputContainer = NULL;
+       }
+       if(fOutputContainer == NULL){
+               fOutputContainer = new TList();
+               fOutputContainer->SetOwner(kTRUE);
+       }
+  
+       // Array of current cut's gammas
+       fClusterCandidates = new TList();
+  
+       fCutFolder = new TList*[fnCuts];
+       fESDList = new TList*[fnCuts];
+       fBackList = new TList*[fnCuts];
+       fMotherList = new TList*[fnCuts];
+       fHistoNEvents = new TH1I*[fnCuts];
+       fHistoNGoodESDTracks = new TH1I*[fnCuts];
+       fHistoNGammaCandidates = new TH1I*[fnCuts];
+       fHistoNGoodESDTracksVsNGammaCanditates = new TH2F*[fnCuts];
+       fHistoNV0Tracks = new TH1I*[fnCuts];
+       fProfileEtaShift = new TProfile*[fnCuts];
+       
+       if(fDoMesonAnalysis){
+               fHistoMotherInvMassPt = new TH2F*[fnCuts];
+               fHistoMotherBackInvMassPt = new TH2F*[fnCuts];
+               fHistoMotherInvMassEalpha = new TH2F*[fnCuts];
+               if (fDoMesonQA > 0){
+                       fHistoMotherPi0PtY =  new TH2F*[fnCuts];
+                       fHistoMotherEtaPtY =  new TH2F*[fnCuts];
+                       fHistoMotherPi0PtAlpha =  new TH2F*[fnCuts];
+                       fHistoMotherEtaPtAlpha =  new TH2F*[fnCuts];
+                       fHistoMotherPi0PtOpenAngle =  new TH2F*[fnCuts];
+                       fHistoMotherEtaPtOpenAngle =  new TH2F*[fnCuts];
+               }
+               if(fDoMesonQA == 1){
+                       fHistoMotherInvMassECalib = new TH2F*[fnCuts];
+                       fHistoMotherInvMassECalibalpha = new TH2F*[fnCuts];
+               }
+       }
+               
+       fHistoClusGammaPt = new TH1F*[fnCuts];
+       
+       for(Int_t iCut = 0; iCut<fnCuts;iCut++){
+               TString cutstringEvent  = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
+               TString cutstringCalo   = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
+               TString cutstringMeson  = "NoMesonCut";
+               if(fDoMesonAnalysis)cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
+    
+               fCutFolder[iCut] = new TList();
+               fCutFolder[iCut]->SetName(Form("Cut Number %s_%s_%s",cutstringEvent.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
+               fCutFolder[iCut]->SetOwner(kTRUE);
+               fOutputContainer->Add(fCutFolder[iCut]);
+               fESDList[iCut] = new TList();
+               fESDList[iCut]->SetName(Form("%s_%s_%s ESD histograms",cutstringEvent.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
+               fESDList[iCut]->SetOwner(kTRUE);
+               fCutFolder[iCut]->Add(fESDList[iCut]);
+    
+               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");
+               if (((AliConvEventCuts*)fEventCutArray->At(iCut))->IsSpecialTrigger() == 4 ){
+                       TString TriggerNames = "Not Trigger: ";
+                       TriggerNames = TriggerNames+ ( (AliConvEventCuts*)fEventCutArray->At(iCut))->GetSpecialTriggerName();
+                       fHistoNEvents[iCut]->GetXaxis()->SetBinLabel(4,TriggerNames.Data());
+               } else {
+                       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 == 1) fHistoNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",4000,0,4000);
+               else if(fIsHeavyIon == 2) fHistoNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",400,0,400);
+               else fHistoNGoodESDTracks[iCut] = new TH1I("GoodESDTracks","GoodESDTracks",200,0,200);
+               fESDList[iCut]->Add(fHistoNGoodESDTracks[iCut]);
+               if(fIsHeavyIon == 1) fHistoNGammaCandidates[iCut] = new TH1I("GammaCandidates","GammaCandidates",600,0,600);
+               else if(fIsHeavyIon == 2) fHistoNGammaCandidates[iCut] = new TH1I("GammaCandidates","GammaCandidates",400,0,400);
+               else fHistoNGammaCandidates[iCut] = new TH1I("GammaCandidates","GammaCandidates",100,0,100);
+               fESDList[iCut]->Add(fHistoNGammaCandidates[iCut]);
+               if(fIsHeavyIon == 1) fHistoNGoodESDTracksVsNGammaCanditates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",4000,0,4000,600,0,600);
+               else if(fIsHeavyIon == 2) fHistoNGoodESDTracksVsNGammaCanditates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",400,0,400,400,0,400);
+               else fHistoNGoodESDTracksVsNGammaCanditates[iCut] = new TH2F("GoodESDTracksVsGammaCandidates","GoodESDTracksVsGammaCandidates",200,0,200,100,0,100);
+               fESDList[iCut]->Add(fHistoNGoodESDTracksVsNGammaCanditates[iCut]);
+    
+               
+               if(fIsHeavyIon == 1) fHistoNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",30000,0,30000);
+               else if(fIsHeavyIon == 2) fHistoNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",2500,0,2500);
+               else fHistoNV0Tracks[iCut] = new TH1I("V0 Multiplicity","V0 Multiplicity",1500,0,1500);
+               fESDList[iCut]->Add(fHistoNV0Tracks[iCut]);
+               fProfileEtaShift[iCut] = new TProfile("Eta Shift","Eta Shift",1, -0.5,0.5);
+               fESDList[iCut]->Add(fProfileEtaShift[iCut]);
+    
+               fHistoClusGammaPt[iCut] = new TH1F("ClusGamma_Pt","ClusGamma_Pt",250,0,25);
+               fESDList[iCut]->Add(fHistoClusGammaPt[iCut]);
+
+               
+               if(fDoMesonAnalysis){
+                       fHistoMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt","ESD_Mother_InvMass_Pt",800,0,0.8,250,0,25);
+                       fESDList[iCut]->Add(fHistoMotherInvMassPt[iCut]);
+                       fHistoMotherBackInvMassPt[iCut] = new TH2F("ESD_Background_InvMass_Pt","ESD_Background_InvMass_Pt",800,0,0.8,250,0,25);
+                       fESDList[iCut]->Add(fHistoMotherBackInvMassPt[iCut]);
+                       fHistoMotherInvMassEalpha[iCut] = new TH2F("ESD_Mother_InvMass_vs_E_alpha","ESD_Mother_InvMass_vs_E_alpha",800,0,0.8,250,0,25);
+                       fESDList[iCut]->Add(fHistoMotherInvMassEalpha[iCut]);
+                       if(fDoMesonQA == 1){
+                               fHistoMotherInvMassECalib[iCut] = new TH2F("ESD_Mother_InvMass_Pt_Calib","ESD_Mother_InvMass_Pt_Calib",800,0,0.8,250,0,25);
+                               fESDList[iCut]->Add(fHistoMotherInvMassECalib[iCut]);
+                               fHistoMotherInvMassECalibalpha[iCut] = new TH2F("ESD_Mother_InvMass_vs_E_Calib_alpha","ESD_Mother_InvMass_vs_E_Calib_alpha",800,0,0.8,250,0,25);
+                               fESDList[iCut]->Add(fHistoMotherInvMassECalibalpha[iCut]);
+                       }
+
+                       if (fDoMesonQA > 0 ){
+                               fHistoMotherPi0PtY[iCut] = new TH2F("ESD_MotherPi0_Pt_Y","ESD_MotherPi0_Pt_Y",150,0.03,15.,150,-1.5,1.5);
+                               SetLogBinningXTH2(fHistoMotherPi0PtY[iCut]);
+                               fESDList[iCut]->Add(fHistoMotherPi0PtY[iCut]);
+                               fHistoMotherEtaPtY[iCut] = new TH2F("ESD_MotherEta_Pt_Y","ESD_MotherEta_Pt_Y",150,0.03,15.,150,-1.5,1.5);
+                               SetLogBinningXTH2(fHistoMotherEtaPtY[iCut]);
+                               fESDList[iCut]->Add(fHistoMotherEtaPtY[iCut]);
+                               fHistoMotherPi0PtAlpha[iCut] = new TH2F("ESD_MotherPi0_Pt_Alpha","ESD_MotherPi0_Pt_Alpha",150,0.03,15.,100,0,1);
+                               SetLogBinningXTH2(fHistoMotherPi0PtAlpha[iCut]);
+                               fESDList[iCut]->Add(fHistoMotherPi0PtAlpha[iCut]);
+                               fHistoMotherEtaPtAlpha[iCut] = new TH2F("ESD_MotherEta_Pt_Alpha","ESD_MotherEta_Pt_Alpha",150,0.03,15.,100,0,1);
+                               SetLogBinningXTH2(fHistoMotherEtaPtAlpha[iCut]);
+                               fESDList[iCut]->Add(fHistoMotherEtaPtAlpha[iCut]);
+                               fHistoMotherPi0PtOpenAngle[iCut] = new TH2F("ESD_MotherPi0_Pt_OpenAngle","ESD_MotherPi0_Pt_OpenAngle",150,0.03,15.,200,0,2*TMath::Pi());
+                               SetLogBinningXTH2(fHistoMotherPi0PtOpenAngle[iCut]);
+                               fESDList[iCut]->Add(fHistoMotherPi0PtOpenAngle[iCut]);
+                               fHistoMotherEtaPtOpenAngle[iCut] = new TH2F("ESD_MotherEta_Pt_OpenAngle","ESD_MotherEta_Pt_OpenAngle",150,0.03,15.,200,0,2*TMath::Pi());
+                               SetLogBinningXTH2(fHistoMotherEtaPtOpenAngle[iCut]);
+                               fESDList[iCut]->Add(fHistoMotherEtaPtOpenAngle[iCut]);
+                       }
+               }    
+       }
+       if(fDoMesonAnalysis){
+               InitBack(); // Init Background Handler
+       }
+  
+       if(fIsMC){
+               // MC Histogramms
+               fMCList         = new TList*[fnCuts];
+               // True Histogramms
+               fTrueList       = new TList*[fnCuts];
+               // Selected Header List
+               fHeaderNameList                                         = new TList*[fnCuts];
+               fHistoMCHeaders                                         = new TH1I*[fnCuts];
+               fHistoMCAllGammaPt                                      = new TH1F*[fnCuts];
+               fHistoMCDecayGammaPi0Pt                         = new TH1F*[fnCuts];
+               fHistoMCDecayGammaRhoPt                         = new TH1F*[fnCuts];
+               fHistoMCDecayGammaEtaPt                         = new TH1F*[fnCuts];
+               fHistoMCDecayGammaOmegaPt                       = new TH1F*[fnCuts];
+               fHistoMCDecayGammaEtapPt                        = new TH1F*[fnCuts];
+               fHistoMCDecayGammaPhiPt                         = new TH1F*[fnCuts];
+               fHistoMCDecayGammaSigmaPt                       = new TH1F*[fnCuts];
+       
+               fHistoClusPhotonBGPt                                                    = new TH2F*[fnCuts];
+               fHistoClusPhotonPlusConvBGPt                                    = new TH2F*[fnCuts];
+       
+               fHistoTrueClusGammaPt                                                           = new TH1F*[fnCuts];
+               fHistoTruePrimaryClusGammaPt                                            = new TH1F*[fnCuts];
+               fHistoTruePrimaryClusGammaESDPtMCPt                             = new TH2F*[fnCuts];
+               fHistoTruePrimaryClusConvGammaPt                                        = new TH1F*[fnCuts];
+               fHistoTruePrimaryClusConvGammaESDPtMCPt                         = new TH2F*[fnCuts];
+               fHistoTrueSecondaryClusGammaPt                                          = new TH1F*[fnCuts];
+               fHistoTrueSecondaryClusConvGammaPt                                      = new TH1F*[fnCuts];
+               fHistoTrueSecondaryClusGammaFromXFromK0sPt                      = new TH1F*[fnCuts];
+               fHistoTrueSecondaryClusConvGammaFromXFromK0sPt          = new TH1F*[fnCuts];
+               fHistoTrueSecondaryClusGammaFromXFromLambdaPt           = new TH1F*[fnCuts];
+               fHistoTrueSecondaryClusConvGammaFromXFromLambdaPt       = new TH1F*[fnCuts];
+               fHistoTrueSecondaryClusGammaFromXFromEtasPt             = new TH1F*[fnCuts];
+               fHistoTrueSecondaryClusConvGammaFromXFromEtasPt         = new TH1F*[fnCuts];
+    
+               
+               if (fDoClusterQA > 0){  
+                       fHistoTrueClusUnConvGammaPt             = new TH1F*[fnCuts];
+                       fHistoTrueClusUnConvGammaMCPt           = new TH1F*[fnCuts];
+                       fHistoTrueClusElectronPt                        = new TH1F*[fnCuts];
+                       fHistoTrueClusConvGammaPt                       = new TH1F*[fnCuts];
+                       fHistoTrueClusConvGammaMCPt                     = new TH1F*[fnCuts];
+                       fHistoTrueClusConvGammaFullyPt          = new TH1F*[fnCuts];
+                       fHistoTrueClusMergedGammaPt             = new TH1F*[fnCuts];
+                       fHistoTrueClusMergedPartConvGammaPt = new TH1F*[fnCuts];
+                       fHistoTrueClusDalitzPt                          = new TH1F*[fnCuts];
+                       fHistoTrueClusDalitzMergedPt            = new TH1F*[fnCuts];
+                       fHistoTrueClusPhotonFromElecMotherPt= new TH1F*[fnCuts];
+                       fHistoTrueClusShowerPt                          = new TH1F*[fnCuts];
+                       fHistoTrueClusSubLeadingPt                      = new TH1F*[fnCuts];
+                       fHistoTrueClusNParticles                        = new TH1I*[fnCuts];
+                       fHistoTrueClusEMNonLeadingPt            = new TH1F*[fnCuts];
+                       fHistoTrueNLabelsInClus                         = new TH1F*[fnCuts];                    
+               }
+    
+               if(fDoMesonAnalysis){
+                       fHistoMCPi0Pt                                   = new TH1F*[fnCuts];
+                       fHistoMCPi0WOWeightPt                   = new TH1F*[fnCuts];
+                       fHistoMCEtaPt                                   = new TH1F*[fnCuts];
+                       fHistoMCEtaWOWeightPt                   = new TH1F*[fnCuts];
+                       fHistoMCPi0InAccPt                              = new TH1F*[fnCuts];
+                       fHistoMCEtaInAccPt                              = new TH1F*[fnCuts];
+      
+                       fHistoTrueMotherInvMassPt                                       = new TH2F*[fnCuts];
+                       fHistoTruePrimaryMotherInvMassPt                        = new TH2F*[fnCuts];
+                       fHistoTruePrimaryMotherW0WeightingInvMassPt = new TH2F*[fnCuts];
+                       fProfileTruePrimaryMotherWeightsInvMassPt       = new TProfile2D*[fnCuts];
+                       fHistoTrueSecondaryMotherInvMassPt                      = new TH2F*[fnCuts];
+                       fHistoTrueSecondaryMotherFromK0sInvMassPt       = new TH2F*[fnCuts];
+                       fHistoTrueSecondaryMotherFromEtaInvMassPt       = new TH2F*[fnCuts];
+                       fHistoTrueSecondaryMotherFromLambdaInvMassPt = new TH2F*[fnCuts];
+                       if (fDoMesonQA > 0){
+                               fHistoMCPi0PtY                                                          = new TH2F*[fnCuts];
+                               fHistoMCEtaPtY                                                          = new TH2F*[fnCuts];
+                               fHistoMCK0sPt                                                           = new TH1F*[fnCuts];
+                               fHistoMCK0sWOWeightPt                                           = new TH1F*[fnCuts];
+                               fHistoMCK0sPtY                                                          = new TH2F*[fnCuts];
+                               fHistoMCSecPi0PtvsSource                                        = new TH2F*[fnCuts];
+                               fHistoMCSecPi0Source                                            = new TH1F*[fnCuts];
+                               fHistoMCSecEtaPt                                                        = new TH1F*[fnCuts];
+                               fHistoMCSecEtaSource                                            = new TH1F*[fnCuts];
+                               fHistoTrueMotherCaloPhotonInvMassPt                     = new TH2F*[fnCuts];
+                               fHistoTrueMotherCaloConvertedPhotonInvMassPt= new TH2F*[fnCuts];
+                               fHistoTrueMotherCaloMixedPhotonConvPhotonInvMassPt= new TH2F*[fnCuts];
+                               fHistoTruePi0CaloConvertedPhotonInvMassPt       = new TH2F*[fnCuts];
+                               fHistoTrueEtaCaloConvertedPhotonInvMassPt       = new TH2F*[fnCuts];
+                               fHistoTrueMotherCaloElectronInvMassPt           = new TH2F*[fnCuts];
+                               fHistoTrueMotherCaloMergedClusterInvMassPt      = new TH2F*[fnCuts];
+                               fHistoTrueMotherCaloMergedClusterPartConvInvMassPt      = new TH2F*[fnCuts];
+                               fHistoTruePrimaryPi0MCPtResolPt                         = new TH2F*[fnCuts];
+                               fHistoTruePrimaryEtaMCPtResolPt                         = new TH2F*[fnCuts];
+                               fHistoTrueK0sWithPi0DaughterMCPt                        = new TH1F*[fnCuts];
+                               fHistoTrueEtaWithPi0DaughterMCPt                        = new TH1F*[fnCuts];
+                               fHistoTrueLambdaWithPi0DaughterMCPt             = new TH1F*[fnCuts];
+                               fHistoTrueBckGGInvMassPt                                        = new TH2F*[fnCuts];
+                               fHistoTrueBckContInvMassPt                                      = new TH2F*[fnCuts];
+                               fHistoTruePi0PtY                                                        = new TH2F*[fnCuts];
+                               fHistoTrueEtaPtY                                                        = new TH2F*[fnCuts];
+                               fHistoTruePi0PtAlpha                                            = new TH2F*[fnCuts];
+                               fHistoTrueEtaPtAlpha                                            = new TH2F*[fnCuts];
+                               fHistoTruePi0PtOpenAngle                                        = new TH2F*[fnCuts];
+                               fHistoTrueEtaPtOpenAngle                                        = new TH2F*[fnCuts];
+                       }
+               }
+    
+    
+    
+               for(Int_t iCut = 0; iCut<fnCuts;iCut++){
+                       TString cutstringEvent  = ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber();
+                       TString cutstringCalo   = ((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutNumber();
+                       TString cutstringMeson  = "NoMesonCut";
+                       if(fDoMesonAnalysis)cutstringMeson = ((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutNumber();
+      
+                       fMCList[iCut] = new TList();
+                       fMCList[iCut]->SetName(Form("%s_%s_%s MC histograms",cutstringEvent.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
+                       fMCList[iCut]->SetOwner(kTRUE);
+                       fCutFolder[iCut]->Add(fMCList[iCut]);
+                       fHistoMCHeaders[iCut] = new TH1I("MC_Headers","MC_Headers",20,0,20);
+                       fMCList[iCut]->Add(fHistoMCHeaders[iCut]);
+                       fHistoMCAllGammaPt[iCut] = new TH1F("MC_AllGamma_Pt","MC_AllGamma_Pt",250,0,25);
+                       fMCList[iCut]->Add(fHistoMCAllGammaPt[iCut]);
+                       fHistoMCDecayGammaPi0Pt[iCut] = new TH1F("MC_DecayGammaPi0_Pt","MC_DecayGammaPi0_Pt",250,0,25);
+                       fMCList[iCut]->Add(fHistoMCDecayGammaPi0Pt[iCut]);
+                       fHistoMCDecayGammaRhoPt[iCut] = new TH1F("MC_DecayGammaRho_Pt","MC_DecayGammaRho_Pt",250,0,25);
+                       fMCList[iCut]->Add(fHistoMCDecayGammaRhoPt[iCut]);
+                       fHistoMCDecayGammaEtaPt[iCut] = new TH1F("MC_DecayGammaEta_Pt","MC_DecayGammaEta_Pt",250,0,25);
+                       fMCList[iCut]->Add(fHistoMCDecayGammaEtaPt[iCut]);
+                       fHistoMCDecayGammaOmegaPt[iCut] = new TH1F("MC_DecayGammaOmega_Pt","MC_DecayGammaOmmega_Pt",250,0,25);
+                       fMCList[iCut]->Add(fHistoMCDecayGammaOmegaPt[iCut]);
+                       fHistoMCDecayGammaEtapPt[iCut] = new TH1F("MC_DecayGammaEtap_Pt","MC_DecayGammaEtap_Pt",250,0,25);
+                       fMCList[iCut]->Add(fHistoMCDecayGammaEtapPt[iCut]);
+                       fHistoMCDecayGammaPhiPt[iCut] = new TH1F("MC_DecayGammaPhi_Pt","MC_DecayGammaPhi_Pt",250,0,25);
+                       fMCList[iCut]->Add(fHistoMCDecayGammaPhiPt[iCut]);
+                       fHistoMCDecayGammaSigmaPt[iCut] = new TH1F("MC_DecayGammaSigma_Pt","MC_DecayGammaSigma_Pt",250,0,25);
+                       fMCList[iCut]->Add(fHistoMCDecayGammaSigmaPt[iCut]);
+                       
+                       if(fDoMesonAnalysis){
+                               fHistoMCPi0Pt[iCut] = new TH1F("MC_Pi0_Pt","MC_Pi0_Pt",250,0,25);
+                               fHistoMCPi0Pt[iCut]->Sumw2();
+                               fMCList[iCut]->Add(fHistoMCPi0Pt[iCut]);
+                               fHistoMCPi0WOWeightPt[iCut] = new TH1F("MC_Pi0_WOWeights_Pt","MC_Pi0_WOWeights_Pt",250,0,25);
+                               fHistoMCPi0WOWeightPt[iCut]->Sumw2();
+                               fMCList[iCut]->Add(fHistoMCPi0WOWeightPt[iCut]);
+                               
+                               fHistoMCEtaPt[iCut] = new TH1F("MC_Eta_Pt","MC_Eta_Pt",250,0,25);
+                               fHistoMCEtaPt[iCut]->Sumw2();
+                               fMCList[iCut]->Add(fHistoMCEtaPt[iCut]);
+                               fHistoMCEtaWOWeightPt[iCut] = new TH1F("MC_Eta_WOWeights_Pt","MC_Eta_WOWeights_Pt",250,0,25);
+                               fHistoMCEtaWOWeightPt[iCut]->Sumw2();
+                               fMCList[iCut]->Add(fHistoMCEtaWOWeightPt[iCut]);
+                               fHistoMCPi0InAccPt[iCut] = new TH1F("MC_Pi0InAcc_Pt","MC_Pi0InAcc_Pt",250,0,25);
+                               fHistoMCPi0InAccPt[iCut]->Sumw2();
+                               fMCList[iCut]->Add(fHistoMCPi0InAccPt[iCut]);
+                               fHistoMCEtaInAccPt[iCut] = new TH1F("MC_EtaInAcc_Pt","MC_EtaInAcc_Pt",250,0,25);
+                               fHistoMCEtaInAccPt[iCut]->Sumw2();
+                               fMCList[iCut]->Add(fHistoMCEtaInAccPt[iCut]);
+                               if (fDoMesonQA > 0){
+                                       fHistoMCPi0PtY[iCut] = new TH2F("MC_Pi0_Pt_Y","MC_Pi0_Pt_Y",150,0.03,15.,150,-1.5,1.5);
+                                       fHistoMCPi0PtY[iCut]->Sumw2();
+                                       SetLogBinningXTH2(fHistoMCPi0PtY[iCut]);
+                                       fMCList[iCut]->Add(fHistoMCPi0PtY[iCut]);
+                                       fHistoMCEtaPtY[iCut] = new TH2F("MC_Eta_Pt_Y","MC_Eta_Pt_Y",150,0.03,15.,150,-1.5,1.5);
+                                       fHistoMCEtaPtY[iCut]->Sumw2();
+                                       SetLogBinningXTH2(fHistoMCEtaPtY[iCut]);
+                                       fMCList[iCut]->Add(fHistoMCEtaPtY[iCut]);
+                                       fHistoMCK0sPt[iCut] = new TH1F("MC_K0s_Pt","MC_K0s_Pt",150,0,15);
+                                       fHistoMCK0sPt[iCut]->Sumw2();
+                                       fMCList[iCut]->Add(fHistoMCK0sPt[iCut]);
+                                       fHistoMCK0sWOWeightPt[iCut] = new TH1F("MC_K0s_WOWeights_Pt","MC_K0s_WOWeights_Pt",150,0,15);
+                                       fHistoMCK0sWOWeightPt[iCut]->Sumw2();
+                                       fMCList[iCut]->Add(fHistoMCK0sWOWeightPt[iCut]);
+                                       fHistoMCK0sPtY[iCut] = new TH2F("MC_K0s_Pt_Y","MC_K0s_Pt_Y",150,0.03,15.,150,-1.5,1.5);
+                                       fHistoMCK0sPtY[iCut]->Sumw2();
+                                       SetLogBinningXTH2(fHistoMCK0sPtY[iCut]);
+                                       fMCList[iCut]->Add(fHistoMCK0sPtY[iCut]);
+                                       
+                                       fHistoMCSecPi0Source[iCut] = new TH1F("MC_SecPi0_Source","MC_SecPi0_Source",5000,0.,5000);
+                                       fMCList[iCut]->Add(fHistoMCSecPi0Source[iCut]);
+                                       fHistoMCSecEtaSource[iCut] = new TH1F("MC_SecEta_Source","MC_SecEta_Source",5000,0,5000);
+                                       fMCList[iCut]->Add(fHistoMCSecEtaSource[iCut]);
+                                       fHistoMCSecPi0PtvsSource[iCut] = new TH2F("MC_SecPi0_Pt_Source","MC_SecPi0_Pt_Source",250,0.0,25.,16,-0.5,15.5);
+                                       fHistoMCSecPi0PtvsSource[iCut]->Sumw2();
+                                       fMCList[iCut]->Add(fHistoMCSecPi0PtvsSource[iCut]);
+                                       fHistoMCSecEtaPt[iCut] = new TH1F("MC_SecEta_Pt","MC_SecEta_Pt",250,0,25);
+                                       fHistoMCSecEtaPt[iCut]->Sumw2();
+                                       fMCList[iCut]->Add(fHistoMCSecEtaPt[iCut]);
+                               }
+        
+                       }
+                       fTrueList[iCut] = new TList();
+                       fTrueList[iCut]->SetName(Form("%s_%s_%s True histograms",cutstringEvent.Data(),cutstringCalo.Data(),cutstringMeson.Data()));
+                       fTrueList[iCut]->SetOwner(kTRUE);
+                       fCutFolder[iCut]->Add(fTrueList[iCut]);
+                  
+                       fHistoClusPhotonBGPt[iCut] = new TH2F("ESD_TrueClusPhotonBG_Pt","ESD_TrueClusPhotonBG_Pt",250,0,25,9,-0.5,8.5);
+                       fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 1,"Elec");
+                       fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 2,"Pion");
+                       fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 3,"Proton");
+                       fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 4,"Kaon");
+                       fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 5,"Neutron");
+                       fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 6,"K0s");
+                       fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 7,"Lambda");
+                       fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel( 8,"Muon");
+                       fHistoClusPhotonBGPt[iCut]->GetYaxis()->SetBinLabel(9,"Rest");
+                       fTrueList[iCut]->Add(fHistoClusPhotonBGPt[iCut]);
+                       fHistoClusPhotonPlusConvBGPt[iCut] = new TH2F("ESD_TrueClusPhotonPlusConvBG_Pt","ESD_TrueClusPhotonPlusConvBG_Pt",250,0,25,9,-0.5,8.5);
+                       fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel( 1,"Elec");
+                       fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel( 2,"Pion");
+                       fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel( 3,"Proton");
+                       fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel( 4,"Kaon");
+                       fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel( 5,"Neutron");
+                       fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel( 6,"K0s");
+                       fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel( 7,"Lambda");
+                       fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel( 8,"Muon");
+                       fHistoClusPhotonPlusConvBGPt[iCut]->GetYaxis()->SetBinLabel(9,"Rest");
+                       fTrueList[iCut]->Add(fHistoClusPhotonPlusConvBGPt[iCut]);
+               
+                       fHistoTrueClusGammaPt[iCut] = new TH1F("TrueClusGamma_Pt","ESD_TrueClusGamma_Pt",250,0,25);
+                       fTrueList[iCut]->Add(fHistoTrueClusGammaPt[iCut]);
+                       fHistoTruePrimaryClusGammaPt[iCut] = new TH1F("TruePrimaryClusGamma_Pt","ESD_TruePrimaryClusGamma_Pt",250,0,25);
+                       fTrueList[iCut]->Add(fHistoTruePrimaryClusGammaPt[iCut]);
+                       fHistoTruePrimaryClusGammaESDPtMCPt[iCut] = new TH2F("TruePrimaryClusGamma_Pt_MCPt","ESD_TruePrimaryClusGamma_MCPt",250,0,25,250,0,25);
+                       fTrueList[iCut]->Add(fHistoTruePrimaryClusGammaESDPtMCPt[iCut]);
+                       fHistoTruePrimaryClusConvGammaPt[iCut] = new TH1F("TruePrimaryClusConvGamma_Pt","ESD_TruePrimaryClusConvGamma_Pt",250,0,25);
+                       fTrueList[iCut]->Add(fHistoTruePrimaryClusConvGammaPt[iCut]);
+                       fHistoTruePrimaryClusConvGammaESDPtMCPt[iCut] = new TH2F("TruePrimaryClusConvGamma_Pt_MCPt","ESD_TruePrimaryClusConvGamma_MCPt",250,0,25,250,0,25);
+                       fTrueList[iCut]->Add(fHistoTruePrimaryClusConvGammaESDPtMCPt[iCut]);
+                       fHistoTrueSecondaryClusGammaPt[iCut] = new TH1F("ESD_TrueSecondaryClusGamma_Pt","ESD_TrueSecondaryClusGamma_Pt",250,0,25);
+                       fTrueList[iCut]->Add(fHistoTrueSecondaryClusGammaPt[iCut]);      
+                       fHistoTrueSecondaryClusConvGammaPt[iCut] = new TH1F("ESD_TrueSecondaryClusConvGamma_Pt","ESD_TrueSecondaryClusConvGamma_Pt",250,0,25);
+                       fTrueList[iCut]->Add(fHistoTrueSecondaryClusConvGammaPt[iCut]);      
+
+                       fHistoTrueSecondaryClusGammaFromXFromK0sPt[iCut] = new TH1F("ESD_TrueSecondaryClusGammaFromXFromK0s_Pt", "ESD_TrueSecondaryClusGammaFromXFromK0s_Pt",250,0,25);
+                       fTrueList[iCut]->Add(fHistoTrueSecondaryClusGammaFromXFromK0sPt[iCut]);
+                       fHistoTrueSecondaryClusConvGammaFromXFromK0sPt[iCut] = new TH1F("ESD_TrueSecondaryClusConvGammaFromXFromK0s_Pt", "ESD_TrueSecondaryClusConvGammaFromXFromK0s_Pt",250,0,25);
+                       fTrueList[iCut]->Add(fHistoTrueSecondaryClusConvGammaFromXFromK0sPt[iCut]);
+                       fHistoTrueSecondaryClusGammaFromXFromLambdaPt[iCut] = new TH1F("ESD_TrueSecondaryClusGammaFromXFromLambda_Pt", "ESD_TrueSecondaryClusGammaFromXFromLambda_Pt",250,0,25);
+                       fTrueList[iCut]->Add(fHistoTrueSecondaryClusGammaFromXFromLambdaPt[iCut]);
+                       fHistoTrueSecondaryClusConvGammaFromXFromLambdaPt[iCut] = new TH1F("ESD_TrueSecondaryClusConvGammaFromXFromLambda_Pt", "ESD_TrueSecondaryClusConvGammaFromXFromLambda_Pt",250,0,25);
+                       fTrueList[iCut]->Add(fHistoTrueSecondaryClusConvGammaFromXFromLambdaPt[iCut]);
+                       fHistoTrueSecondaryClusGammaFromXFromEtasPt[iCut] = new TH1F("ESD_TrueSecondaryClusGammaFromXFromEtas_Pt", "ESD_TrueSecondaryClusGammaFromXFromEtas_Pt",250,0,25);
+                       fTrueList[iCut]->Add(fHistoTrueSecondaryClusGammaFromXFromEtasPt[iCut]);
+                       fHistoTrueSecondaryClusConvGammaFromXFromEtasPt[iCut] = new TH1F("ESD_TrueSecondaryClusConvGammaFromXFromEtas_Pt", "ESD_TrueSecondaryClusConvGammaFromXFromEtas_Pt",250,0,25);
+                       fTrueList[iCut]->Add(fHistoTrueSecondaryClusConvGammaFromXFromEtasPt[iCut]);
+
+                       
+                       if (fDoClusterQA > 0){  
+                               fHistoTrueClusUnConvGammaPt[iCut] = new TH1F("TrueClusUnConvGamma_Pt","TrueClusUnConvGamma_Pt",250,0,25);
+                               fTrueList[iCut]->Add(fHistoTrueClusUnConvGammaPt[iCut]);
+                               fHistoTrueClusUnConvGammaMCPt[iCut] = new TH1F("TrueClusUnConvGamma_MCPt","TrueClusUnConvGamma_MCPt",250,0,25);
+                               fTrueList[iCut]->Add(fHistoTrueClusUnConvGammaMCPt[iCut]);
+                               fHistoTrueClusElectronPt[iCut] = new TH1F("TrueClusElectron_Pt","TrueElectronGamma_Pt",250,0,25);
+                               fTrueList[iCut]->Add(fHistoTrueClusElectronPt[iCut]);
+                               fHistoTrueClusConvGammaPt[iCut] = new TH1F("TrueClusConvGamma_Pt","TrueClusConvGamma_Pt",250,0,25);
+                               fTrueList[iCut]->Add(fHistoTrueClusConvGammaPt[iCut]);
+                               fHistoTrueClusConvGammaMCPt[iCut] = new TH1F("TrueClusConvGamma_MCPt","TrueClusConvGamma_MCPt",250,0,25);
+                               fTrueList[iCut]->Add(fHistoTrueClusConvGammaMCPt[iCut]);
+                               fHistoTrueClusConvGammaFullyPt[iCut] = new TH1F("TrueClusConvGammaFullyContained_Pt","TrueClusConvGammaFullyContained_Pt",250,0,25);
+                               fTrueList[iCut]->Add(fHistoTrueClusConvGammaFullyPt[iCut]);
+                               fHistoTrueClusMergedGammaPt[iCut] = new TH1F("TrueClusMergedGamma_Pt","TrueClusMergedGamma_Pt",250,0,25);
+                               fTrueList[iCut]->Add(fHistoTrueClusMergedGammaPt[iCut]);
+                               fHistoTrueClusMergedPartConvGammaPt[iCut] = new TH1F("TrueClusMergedPartConvGamma_Pt","TrueClusMergedPartConvGamma_Pt",250,0,25);
+                               fTrueList[iCut]->Add(fHistoTrueClusMergedPartConvGammaPt[iCut]);
+                               fHistoTrueClusDalitzPt[iCut] = new TH1F("TrueClusDalitz_Pt","TrueClusDalitz_Pt",250,0,25);
+                               fTrueList[iCut]->Add(fHistoTrueClusDalitzPt[iCut]);
+                               fHistoTrueClusDalitzMergedPt[iCut] = new TH1F("TrueClusDalitzMerged_Pt","TrueClusDalitzMerged_Pt",250,0,25);
+                               fTrueList[iCut]->Add(fHistoTrueClusDalitzMergedPt[iCut]);
+                               fHistoTrueClusPhotonFromElecMotherPt[iCut] = new TH1F("TrueClusPhotonFromElecMother_Pt","TrueClusPhotonFromElecMother_Pt",250,0,25);
+                               fTrueList[iCut]->Add(fHistoTrueClusPhotonFromElecMotherPt[iCut]);
+                               fHistoTrueClusShowerPt[iCut] = new TH1F("TrueClusShower_Pt","TrueClusShower_Pt",250,0,25);
+                               fTrueList[iCut]->Add(fHistoTrueClusShowerPt[iCut]);
+                               fHistoTrueClusSubLeadingPt[iCut] = new TH1F("TrueClusSubleading_Pt","TrueClusSubleading_Pt",250,0,25);
+                               fTrueList[iCut]->Add(fHistoTrueClusSubLeadingPt[iCut]);
+                               fHistoTrueClusNParticles[iCut] = new TH1I("TrueClusNParticles","TrueClusNParticles",20,0,20);
+                               fTrueList[iCut]->Add(fHistoTrueClusNParticles[iCut]);
+                               fHistoTrueClusEMNonLeadingPt[iCut] = new TH1F("TrueClusEMNonLeading_Pt","TrueClusEMNonLeading_Pt",250,0,25);
+                               fTrueList[iCut]->Add(fHistoTrueClusEMNonLeadingPt[iCut]);
+                               fHistoTrueNLabelsInClus[iCut] = new TH1F("TrueNLabelsInClus","TrueNLabelsInClus",100,-0.5,99.5);
+                               fTrueList[iCut]->Add(fHistoTrueNLabelsInClus[iCut]);    
+                       }       
+
+                       if(fDoMesonAnalysis){
+                               fHistoTrueMotherInvMassPt[iCut] = new TH2F("ESD_TrueMother_InvMass_Pt","ESD_TrueMother_InvMass_Pt",800,0,0.8,250,0,25);
+                               fTrueList[iCut]->Add(fHistoTrueMotherInvMassPt[iCut]);
+                               fHistoTruePrimaryMotherInvMassPt[iCut] = new TH2F("ESD_TruePrimaryMother_InvMass_Pt", "ESD_TruePrimaryMother_InvMass_Pt", 800,0,0.8,250,0,25);
+                               fHistoTruePrimaryMotherInvMassPt[iCut]->Sumw2();
+                               fTrueList[iCut]->Add(fHistoTruePrimaryMotherInvMassPt[iCut]);
+                               fHistoTruePrimaryMotherW0WeightingInvMassPt[iCut] = new TH2F("ESD_TruePrimaryMotherW0Weights_InvMass_Pt", "ESD_TruePrimaryMotherW0Weights_InvMass_Pt", 800,0,0.8,250,0,25);
+                               fHistoTruePrimaryMotherW0WeightingInvMassPt[iCut]->Sumw2();
+                               fTrueList[iCut]->Add(fHistoTruePrimaryMotherW0WeightingInvMassPt[iCut]);
+                               fProfileTruePrimaryMotherWeightsInvMassPt[iCut] = new TProfile2D("ESD_TruePrimaryMotherWeights_InvMass_Pt", "ESD_TruePrimaryMotherWeights_InvMass_Pt", 800,0,0.8,250,0,25);
+                               fProfileTruePrimaryMotherWeightsInvMassPt[iCut]->Sumw2();
+                               fTrueList[iCut]->Add(fProfileTruePrimaryMotherWeightsInvMassPt[iCut]);
+                               fHistoTrueSecondaryMotherInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMother_InvMass_Pt", "ESD_TrueSecondaryMother_InvMass_Pt", 800,0,0.8,250,0,25);
+                               fHistoTrueSecondaryMotherInvMassPt[iCut]->Sumw2();
+                               fTrueList[iCut]->Add(fHistoTrueSecondaryMotherInvMassPt[iCut]);
+                               fHistoTrueSecondaryMotherFromK0sInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMotherFromK0s_InvMass_Pt","ESD_TrueSecondaryMotherFromK0s_InvMass_Pt",800,0,0.8,250,0,25);
+                               fHistoTrueSecondaryMotherFromK0sInvMassPt[iCut]->Sumw2();
+                               fTrueList[iCut]->Add(fHistoTrueSecondaryMotherFromK0sInvMassPt[iCut]);
+                               fHistoTrueSecondaryMotherFromEtaInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMotherFromEta_InvMass_Pt","ESD_TrueSecondaryMotherFromEta_InvMass_Pt",800,0,0.8,250,0,25);
+                               fTrueList[iCut]->Add(fHistoTrueSecondaryMotherFromEtaInvMassPt[iCut]);
+                               fHistoTrueSecondaryMotherFromLambdaInvMassPt[iCut] = new TH2F("ESD_TrueSecondaryMotherFromLambda_InvMass_Pt","ESD_TrueSecondaryMotherFromLambda_InvMass_Pt",800,0,0.8,250,0,25);
+                               fTrueList[iCut]->Add(fHistoTrueSecondaryMotherFromLambdaInvMassPt[iCut]);
+                               if (fDoMesonQA > 0){
+                                       fHistoTrueMotherCaloPhotonInvMassPt[iCut] = new TH2F("ESD_TrueMotherCaloPhoton_InvMass_Pt","ESD_TrueMotherCaloPhoton_InvMass_Pt",800,0,0.8,250,0,25);
+                                       fTrueList[iCut]->Add(fHistoTrueMotherCaloPhotonInvMassPt[iCut]);
+                                       fHistoTrueMotherCaloConvertedPhotonInvMassPt[iCut] = new TH2F("ESD_TrueMotherCaloConvertedPhoton_InvMass_Pt","ESD_TrueMotherCaloConvertedPhoton_InvMass_Pt",800,0,0.8,250,0,25);
+                                       fTrueList[iCut]->Add(fHistoTrueMotherCaloConvertedPhotonInvMassPt[iCut]);
+                                       fHistoTrueMotherCaloMixedPhotonConvPhotonInvMassPt[iCut] = new TH2F("ESD_TrueMotherCaloMixedPhotonConvertedPhoton_InvMass_Pt","ESD_TrueMotherCaloMixedPhotonConvertedPhoton_InvMass_Pt",800,0,0.8,250,0,25);
+                                       fTrueList[iCut]->Add(fHistoTrueMotherCaloMixedPhotonConvPhotonInvMassPt[iCut]);
+
+                                       fHistoTruePi0CaloConvertedPhotonInvMassPt[iCut] = new TH2F("ESD_TruePi0CaloConvertedPhoton_InvMass_Pt","ESD_TruePi0CaloConvertedPhoton_InvMass_Pt",800,0,0.8,250,0,25);
+                                       fTrueList[iCut]->Add(fHistoTruePi0CaloConvertedPhotonInvMassPt[iCut]);
+
+                                       fHistoTrueEtaCaloConvertedPhotonInvMassPt[iCut] = new TH2F("ESD_TrueEtaCaloConvertedPhoton_InvMass_Pt","ESD_TrueEtaCaloConvertedPhoton_InvMass_Pt",800,0,0.8,250,0,25);
+                                       fTrueList[iCut]->Add(fHistoTrueEtaCaloConvertedPhotonInvMassPt[iCut]);
+
+                                       fHistoTrueMotherCaloElectronInvMassPt[iCut] = new TH2F("ESD_TrueMotherCaloElectron_InvMass_Pt","ESD_TrueMotherCaloElectron_InvMass_Pt",800,0,0.8,250,0,25);
+                                       fTrueList[iCut]->Add(fHistoTrueMotherCaloElectronInvMassPt[iCut]);
+                                       fHistoTrueMotherCaloMergedClusterInvMassPt[iCut] = new TH2F("ESD_TrueMotherCaloMergedCluster_InvMass_Pt","ESD_TrueMotherCaloMergedCluster_InvMass_Pt",800,0,0.8,250,0,25);
+                                       fTrueList[iCut]->Add(fHistoTrueMotherCaloMergedClusterInvMassPt[iCut]);
+                                       fHistoTrueMotherCaloMergedClusterPartConvInvMassPt[iCut] = new TH2F("ESD_TrueMotherCaloMergedClusterPartConv_InvMass_Pt","ESD_TrueMotherCaloMergedClusterPartConv_InvMass_Pt",800,0,0.8,250,0,25);
+                                       fTrueList[iCut]->Add(fHistoTrueMotherCaloMergedClusterPartConvInvMassPt[iCut]);
+                                       
+                                       fHistoTruePrimaryPi0MCPtResolPt[iCut] = new TH2F("ESD_TruePrimaryPi0_MCPt_ResolPt","ESD_TruePrimaryPi0_ResolPt_MCPt",500,0.03,25,1000,-1.,1.);
+                                       fHistoTruePrimaryPi0MCPtResolPt[iCut]->Sumw2();
+                                       SetLogBinningXTH2(fHistoTruePrimaryPi0MCPtResolPt[iCut]);
+                                       fTrueList[iCut]->Add(fHistoTruePrimaryPi0MCPtResolPt[iCut]);
+                                       fHistoTruePrimaryEtaMCPtResolPt[iCut]  = new TH2F("ESD_TruePrimaryEta_MCPt_ResolPt","ESD_TruePrimaryEta_ResolPt_MCPt",500,0.03,25,1000,-1.,1.);
+                                       fHistoTruePrimaryEtaMCPtResolPt[iCut]->Sumw2();
+                                       SetLogBinningXTH2(fHistoTruePrimaryEtaMCPtResolPt[iCut]);
+                                       fTrueList[iCut]->Add(fHistoTruePrimaryEtaMCPtResolPt[iCut]);
+                                       fHistoTrueBckGGInvMassPt[iCut] = new TH2F("ESD_TrueBckGG_InvMass_Pt","ESD_TrueBckGG_InvMass_Pt",800,0,0.8,250,0,25);
+                                       fTrueList[iCut]->Add(fHistoTrueBckGGInvMassPt[iCut]);
+                                       fHistoTrueBckContInvMassPt[iCut] = new TH2F("ESD_TrueBckCont_InvMass_Pt","ESD_TrueBckCont_InvMass_Pt",800,0,0.8,250,0,25);
+                                       fTrueList[iCut]->Add(fHistoTrueBckContInvMassPt[iCut]);
+                                       fHistoTrueK0sWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueK0sWithPi0Daughter_MCPt","ESD_TrueK0sWithPi0Daughter_MCPt",250,0,25);
+                                       fTrueList[iCut]->Add(fHistoTrueK0sWithPi0DaughterMCPt[iCut]);
+                                       fHistoTrueEtaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueEtaWithPi0Daughter_MCPt","ESD_TrueEtaWithPi0Daughter_MCPt",250,0,25);
+                                       fTrueList[iCut]->Add(fHistoTrueEtaWithPi0DaughterMCPt[iCut]);
+                                       fHistoTrueLambdaWithPi0DaughterMCPt[iCut] = new TH1F("ESD_TrueLambdaWithPi0Daughter_MCPt","ESD_TrueLambdaWithPi0Daughter_MCPt",250,0,25);
+                                       fTrueList[iCut]->Add(fHistoTrueLambdaWithPi0DaughterMCPt[iCut]);
+          
+                                       fHistoTruePi0PtY[iCut] = new TH2F("ESD_TruePi0_Pt_Y","ESD_TruePi0_Pt_Y",150,0.03,15.,150,-1.5,1.5);
+                                       SetLogBinningXTH2(fHistoTruePi0PtY[iCut]);
+                                       fTrueList[iCut]->Add(fHistoTruePi0PtY[iCut]);
+                                       fHistoTrueEtaPtY[iCut] = new TH2F("ESD_TrueEta_Pt_Y","ESD_TrueEta_Pt_Y",150,0.03,15.,150,-1.5,1.5);
+                                       SetLogBinningXTH2(fHistoTrueEtaPtY[iCut]);
+                                       fTrueList[iCut]->Add(fHistoTrueEtaPtY[iCut]);
+                                       fHistoTruePi0PtAlpha[iCut] = new TH2F("ESD_TruePi0_Pt_Alpha","ESD_TruePi0_Pt_Alpha",150,0.03,15.,100,0,1);
+                                       SetLogBinningXTH2(fHistoTruePi0PtAlpha[iCut]);
+                                       fTrueList[iCut]->Add(fHistoTruePi0PtAlpha[iCut]);
+                                       fHistoTrueEtaPtAlpha[iCut] = new TH2F("ESD_TrueEta_Pt_Alpha","ESD_TrueEta_Pt_Alpha",150,0.03,15.,100,0,1);
+                                       SetLogBinningXTH2(fHistoTrueEtaPtAlpha[iCut]);
+                                       fTrueList[iCut]->Add(fHistoTrueEtaPtAlpha[iCut]);
+                                       
+                                       fHistoTruePi0PtOpenAngle[iCut] = new TH2F("ESD_TruePi0_Pt_OpenAngle","ESD_TruePi0_Pt_OpenAngle",150,0.03,15.,200,0,2*TMath::Pi());
+                                       SetLogBinningXTH2(fHistoTruePi0PtOpenAngle[iCut]);
+                                       fTrueList[iCut]->Add(fHistoTruePi0PtOpenAngle[iCut]);
+                                       fHistoTrueEtaPtOpenAngle[iCut] = new TH2F("ESD_TrueEta_Pt_OpenAngle","ESD_TrueEta_Pt_OpenAngle",150,0.03,15.,200,0,2*TMath::Pi());
+                                       SetLogBinningXTH2(fHistoTrueEtaPtOpenAngle[iCut]);
+                                       fTrueList[iCut]->Add(fHistoTrueEtaPtOpenAngle[iCut]);
+                               }
+                       }
+               }
+       }  
+    
+       fV0Reader=(AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask("V0ReaderV1");
+       if(!fV0Reader){printf("Error: No V0 Reader");return;} // GetV0Reader
+  
+       if(fV0Reader)
+               if((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())
+                       if(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms())
+                               fOutputContainer->Add(((AliConversionPhotonCuts*)fV0Reader->GetConversionCuts())->GetCutHistograms());
+       if(fV0Reader)
+               if((AliConvEventCuts*)fV0Reader->GetEventCuts())
+                       if(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms())
+                               fOutputContainer->Add(((AliConvEventCuts*)fV0Reader->GetEventCuts())->GetCutHistograms());
+
+                       
+       for(Int_t iCut = 0; iCut<fnCuts;iCut++){
+               if(!((AliConvEventCuts*)fEventCutArray->At(iCut))) continue;
+               if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms()){
+                       fCutFolder[iCut]->Add(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutHistograms());
+               }
+               if(!((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))) continue;
+               if(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms()){
+                       fCutFolder[iCut]->Add(((AliCaloPhotonCuts*)fClusterCutArray->At(iCut))->GetCutHistograms());
+               }
+               if(fDoMesonAnalysis){
+                       if(!((AliConversionMesonCuts*)fMesonCutArray->At(iCut))) continue;
+                       if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms()){
+                               fCutFolder[iCut]->Add(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->GetCutHistograms());
+                       }
+               }
+       }
+       PostData(1, fOutputContainer);
+}
+//_____________________________________________________________________________
+Bool_t AliAnalysisTaskGammaCalo::Notify()
+{
+       for(Int_t iCut = 0; iCut<fnCuts;iCut++){
+               if(!((AliConvEventCuts*)fEventCutArray->At(iCut))->GetDoEtaShift()){
+                       fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
+                       continue; // No Eta Shift requested, continue
+               }
+               if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift() == 0.0){ // Eta Shift requested but not set, get shift automatically
+                       ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCorrectEtaShiftFromPeriod(fV0Reader->GetPeriodName());
+                       fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
+                       ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
+                       continue;
+               }
+               else{
+                       printf(" Gamma Conversion Task %s :: Eta Shift Manually Set to %f \n\n",
+                                       (((AliConvEventCuts*)fEventCutArray->At(iCut))->GetCutNumber()).Data(),((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift());
+                       fProfileEtaShift[iCut]->Fill(0.,(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetEtaShift()));
+                       ((AliConvEventCuts*)fEventCutArray->At(iCut))->DoEtaShift(kFALSE); // Eta Shift Set, make sure that it is called only once
+               }
+       }
+       
+       return kTRUE;
+}
+//_____________________________________________________________________________
+void AliAnalysisTaskGammaCalo::UserExec(Option_t *)
+{
+       //
+       // Called for each event
+       //
+       Int_t eventQuality = ((AliConvEventCuts*)fV0Reader->GetEventCuts())->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;
+       }
+       
+       if(fIsMC) fMCEvent = MCEvent();
+       if(fMCEvent == NULL) fIsMC = kFALSE;
+       
+       fInputEvent = InputEvent();
+       
+       if(fIsMC && fInputEvent->IsA()==AliESDEvent::Class()){
+               fMCStack = fMCEvent->Stack();
+               if(fMCStack == NULL) fIsMC = kFALSE;
+       }
+       
+       // ------------------- BeginEvent ----------------------------
+       
+       AliEventplane *EventPlane = fInputEvent->GetEventplane();
+       if(fIsHeavyIon ==1)fEventPlaneAngle = EventPlane->GetEventplane("V0",fInputEvent,2);
+       else fEventPlaneAngle=0.0;
+       
+       for(Int_t iCut = 0; iCut<fnCuts; iCut++){
+               
+               fiCut = iCut;
+               Int_t eventNotAccepted = ((AliConvEventCuts*)fEventCutArray->At(iCut))->IsEventAcceptedByCut(fV0Reader->GetEventCuts(),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); // Should be 0 here
+               fHistoNGoodESDTracks[iCut]->Fill(fV0Reader->GetNumberOfPrimaryTracks());
+               if(((AliConvEventCuts*)fEventCutArray->At(iCut))->IsHeavyIon() == 2)    fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A());
+                       else fHistoNV0Tracks[iCut]->Fill(fInputEvent->GetVZEROData()->GetMTotV0A()+fInputEvent->GetVZEROData()->GetMTotV0C());
+
+               if(fIsMC){
+                       // Process MC Particle
+                       if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection() != 0){
+                               if(fInputEvent->IsA()==AliESDEvent::Class()){
+                               ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
+                                                                                                                                                                       ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
+                                                                                                                                                                       fMCEvent);
+                               }
+                               else if(fInputEvent->IsA()==AliAODEvent::Class()){
+                               ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetNotRejectedParticles(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetSignalRejection(),
+                                                                                                                                                                       ((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader(),
+                                                                                                                                                                       fInputEvent);
+                               }
+
+                               if(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader()){
+                                       for(Int_t i = 0;i<(((AliConvEventCuts*)fEventCutArray->At(iCut))->GetAcceptedHeader())->GetEntries();i++){
+                                               TString nameBin= fHistoMCHeaders[iCut]->GetXaxis()->GetBinLabel(i+1);
+                                               if (nameBin.CompareTo("")== 0){
+                                                       TString nameHeader = ((TObjString*)((TList*)((AliConvEventCuts*)fEventCutArray->At(iCut))
+                                                                                                                               ->GetAcceptedHeader())->At(i))->GetString();
+                                                       fHistoMCHeaders[iCut]->GetXaxis()->SetBinLabel(i+1,nameHeader.Data());
+                                               }
+                                       }
+                               }
+                       }
+               }
+               if(fIsMC){
+               if(fInputEvent->IsA()==AliESDEvent::Class())
+                       ProcessMCParticles();
+               if(fInputEvent->IsA()==AliAODEvent::Class())
+                       ProcessAODMCParticles();
+               }
+               
+               // it is in the loop to have the same conversion cut string (used also for MC stuff that should be same for V0 and Cluster)
+               ProcessClusters();                                      // process calo clusters
+
+               fHistoNGammaCandidates[iCut]->Fill(fClusterCandidates->GetEntries());
+               fHistoNGoodESDTracksVsNGammaCanditates[iCut]->Fill(fV0Reader->GetNumberOfPrimaryTracks(),fClusterCandidates->GetEntries());
+               if(fDoMesonAnalysis){ // Meson Analysis
+
+                       CalculatePi0Candidates(); // Combine Gammas from conversion and from calo
+
+                       if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->DoBGCalculation()){
+                               if(((AliConversionMesonCuts*)fMesonCutArray->At(iCut))->BackgroundHandlerType() == 0){
+                                       CalculateBackground(); // Combinatorial Background
+                                       UpdateEventByEventData(); // Store Event for mixed Events
+                               }
+                               
+                       }
+               }
+
+               fClusterCandidates->Clear(); // delete cluster candidates
+       }
+       
+       PostData(1, fOutputContainer);
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskGammaCalo::ProcessClusters()
+{
+       
+       Int_t nclus = 0;
+       nclus = fInputEvent->GetNumberOfCaloClusters();
+       
+//     cout << nclus << endl;
+       
+       if(nclus == 0)  return;
+       
+       // vertex
+       Double_t vertex[3] = {0};
+       InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
+       
+       // Loop over EMCal clusters
+       for(Long_t i = 0; i < nclus; i++){
+               
+               AliVCluster* clus = NULL;
+               clus = fInputEvent->GetCaloCluster(i);          
+               if (!clus) continue;
+               if(!((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelected(clus,fInputEvent,fIsMC)) continue;
+               // TLorentzvector with cluster
+               TLorentzVector clusterVector;
+               clus->GetMomentum(clusterVector,vertex);
+               
+               TLorentzVector* tmpvec = new TLorentzVector();
+               tmpvec->SetPxPyPzE(clusterVector.Px(),clusterVector.Py(),clusterVector.Pz(),clusterVector.E());
+               
+               // convert to AODConversionPhoton
+               AliAODConversionPhoton *PhotonCandidate=new AliAODConversionPhoton(tmpvec);
+               if(!PhotonCandidate) continue;
+               
+               // Flag Photon as CaloPhoton
+               PhotonCandidate->SetIsCaloPhoton();
+               PhotonCandidate->SetCaloClusterRef(i);
+               // get MC label
+               if(fIsMC){
+                       Int_t* mclabelsCluster = clus->GetLabels();
+                       PhotonCandidate->SetNCaloPhotonMCLabels(clus->GetNLabels());
+//                     cout << clus->GetNLabels() << endl;
+                       if (clus->GetNLabels()>0){
+                               for (Int_t k =0; k< (Int_t)clus->GetNLabels(); k++){
+                                       if (k< 20)PhotonCandidate->SetCaloPhotonMCLabel(k,mclabelsCluster[k]);
+//                                     Int_t pdgCode = fMCStack->Particle(mclabelsCluster[k])->GetPdgCode();
+//                                     cout << "label " << k << "\t" << mclabelsCluster[k] << " pdg code: " << pdgCode << endl;
+                               }       
+                       }
+               }
+               
+               fIsFromMBHeader = kTRUE; 
+               // test whether largest contribution to cluster orginates in added signals
+               if (fIsMC && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(PhotonCandidate->GetCaloPhotonMCLabel(0), fMCStack, fInputEvent) == 0) fIsFromMBHeader = kFALSE;
+               
+               if (fIsFromMBHeader)fHistoClusGammaPt[fiCut]->Fill(PhotonCandidate->Pt());
+               fClusterCandidates->Add(PhotonCandidate); // if no second loop is required add to events good gammas
+               
+               if(fIsMC){
+                       if(fInputEvent->IsA()==AliESDEvent::Class()){
+                               ProcessTrueClusterCandidates(PhotonCandidate);
+                       } else {
+                               ProcessTrueClusterCandidatesAOD(PhotonCandidate);
+                       }       
+               }
+               
+               delete tmpvec;
+       }
+       
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskGammaCalo::ProcessTrueClusterCandidates(AliAODConversionPhoton *TruePhotonCandidate)
+{
+               
+       TParticle *Photon = NULL;
+       if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
+       fHistoTrueNLabelsInClus[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMCLabels());
+       
+       if (TruePhotonCandidate->GetNCaloPhotonMCLabels()>0)Photon = fMCStack->Particle(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
+               else return;
+               
+       if(Photon == NULL){
+       //    cout << "no photon" << endl;
+               return;
+       }
+
+       Int_t pdgCodeParticle = Photon->GetPdgCode();
+       TruePhotonCandidate->SetCaloPhotonMCFlags(fMCStack);
+       
+       // True Photon
+       if(fIsFromMBHeader){
+               if (TruePhotonCandidate->IsLargestComponentPhoton() || TruePhotonCandidate->IsLargestComponentElectron() )fHistoTrueClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       else fHistoTrueClusEMNonLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+               if (fDoClusterQA > 0){
+                       if (TruePhotonCandidate->IsLargestComponentPhoton()){ 
+                               fHistoTrueClusUnConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                               fHistoTrueClusUnConvGammaMCPt[fiCut]->Fill(Photon->Pt());
+                       }       
+                       if (TruePhotonCandidate->IsLargestComponentElectron()) 
+                               fHistoTrueClusElectronPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
+                               fHistoTrueClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                               fHistoTrueClusConvGammaMCPt[fiCut]->Fill(((TParticle*)fMCStack->Particle(Photon->GetMother(0)))->Pt());
+                       }       
+                       if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion() && TruePhotonCandidate->IsConversionFullyContained()) 
+                               fHistoTrueClusConvGammaFullyPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsMerged() || TruePhotonCandidate->IsMergedPartConv() || TruePhotonCandidate->IsDalitzMerged())
+                               fHistoTrueClusMergedGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsMergedPartConv())
+                               fHistoTrueClusMergedPartConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsDalitz()) 
+                               fHistoTrueClusDalitzPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsDalitzMerged()) 
+                               fHistoTrueClusDalitzMergedPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsPhotonWithElecMother()) 
+                               fHistoTrueClusPhotonFromElecMotherPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsShower()) 
+                               fHistoTrueClusShowerPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsSubLeadingEM())
+                               fHistoTrueClusSubLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       fHistoTrueClusNParticles[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMotherMCLabels());
+                       if (!TruePhotonCandidate->IsLargestComponentPhoton())
+                               FillPhotonBackgroundHist(TruePhotonCandidate,pdgCodeParticle);
+                       if (!(TruePhotonCandidate->IsLargestComponentPhoton() || (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())) )
+                               FillPhotonPlusConversionBackgroundHist(TruePhotonCandidate,pdgCodeParticle);
+               }
+               
+               if(Photon->GetMother(0) <= fMCStack->GetNprimary()){
+                       if (TruePhotonCandidate->IsLargestComponentPhoton()){
+                               fHistoTruePrimaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                               fHistoTruePrimaryClusGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt()); // Allways Filled
+                       }
+                       if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
+                               fHistoTruePrimaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                               fHistoTruePrimaryClusConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt()); // Allways Filled
+                       }
+                       
+               } else {
+                       if (TruePhotonCandidate->IsLargestComponentPhoton())
+                               fHistoTrueSecondaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())
+                               fHistoTrueSecondaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if(fMCStack->Particle(Photon->GetMother(0))->GetMother(0) > -1){
+                               if(fMCStack->Particle(fMCStack->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 3122){
+                                       if (TruePhotonCandidate->IsLargestComponentPhoton())
+                                               fHistoTrueSecondaryClusGammaFromXFromLambdaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                                       if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())
+                                               fHistoTrueSecondaryClusConvGammaFromXFromLambdaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                               }
+                               if(fMCStack->Particle(fMCStack->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 310){
+                                       if (TruePhotonCandidate->IsLargestComponentPhoton())
+                                               fHistoTrueSecondaryClusGammaFromXFromK0sPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                                       if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())
+                                               fHistoTrueSecondaryClusConvGammaFromXFromK0sPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                               }
+                               if(fMCStack->Particle(fMCStack->Particle(Photon->GetMother(0))->GetMother(0))->GetPdgCode() == 221){
+                                       if (TruePhotonCandidate->IsLargestComponentPhoton())
+                                               fHistoTrueSecondaryClusGammaFromXFromEtasPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                                       if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())
+                                               fHistoTrueSecondaryClusConvGammaFromXFromEtasPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                                               
+                               }       
+                       }
+               }
+       }
+       return;
+}
+
+
+//________________________________________________________________________
+void AliAnalysisTaskGammaCalo::ProcessTrueClusterCandidatesAOD(AliAODConversionPhoton *TruePhotonCandidate)
+{
+       AliAODMCParticle *Photon = NULL;
+       TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
+       if (AODMCTrackArray){
+               if (!TruePhotonCandidate->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set task will abort");
+               if (TruePhotonCandidate->GetNCaloPhotonMCLabels()>0) Photon = (AliAODMCParticle*) AODMCTrackArray->At(TruePhotonCandidate->GetCaloPhotonMCLabel(0));
+                       else return;
+       } else {
+               AliInfo("AODMCTrackArray could not be loaded");
+               return;
+       }
+
+       if(Photon == NULL){
+       //      cout << "no photon" << endl;
+               return;
+       }
+       Int_t pdgCodeParticle = Photon->GetPdgCode();
+       TruePhotonCandidate->SetCaloPhotonMCFlagsAOD(fInputEvent);
+       
+       // True Photon
+       if(fIsFromMBHeader){
+               if (TruePhotonCandidate->IsLargestComponentPhoton() || TruePhotonCandidate->IsLargestComponentElectron() )fHistoTrueClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       else fHistoTrueClusEMNonLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+               if (fDoClusterQA > 0){
+                       if (TruePhotonCandidate->IsLargestComponentPhoton()) {
+                               fHistoTrueClusUnConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                               fHistoTrueClusUnConvGammaMCPt[fiCut]->Fill(Photon->Pt());
+                       }       
+                       if (TruePhotonCandidate->IsLargestComponentElectron()) 
+                               fHistoTrueClusElectronPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()) {
+                               fHistoTrueClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                               AliAODMCParticle *Mother = (AliAODMCParticle*) AODMCTrackArray->At(Photon->GetMother());
+                               fHistoTrueClusConvGammaMCPt[fiCut]->Fill(Mother->Pt());
+                       }       
+                       if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion() && TruePhotonCandidate->IsConversionFullyContained()) 
+                               fHistoTrueClusConvGammaFullyPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsMerged() || TruePhotonCandidate->IsMergedPartConv() || TruePhotonCandidate->IsDalitzMerged())
+                               fHistoTrueClusMergedGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsMergedPartConv())
+                               fHistoTrueClusMergedPartConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsDalitz()) 
+                               fHistoTrueClusDalitzPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsDalitzMerged()) 
+                               fHistoTrueClusDalitzMergedPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsPhotonWithElecMother()) 
+                               fHistoTrueClusPhotonFromElecMotherPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsShower()) 
+                               fHistoTrueClusShowerPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsSubLeadingEM())
+                               fHistoTrueClusSubLeadingPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       fHistoTrueClusNParticles[fiCut]->Fill(TruePhotonCandidate->GetNCaloPhotonMotherMCLabels());
+                       
+                       if (!TruePhotonCandidate->IsLargestComponentPhoton())
+                               FillPhotonBackgroundHist(TruePhotonCandidate,pdgCodeParticle);
+                       if (!(TruePhotonCandidate->IsLargestComponentPhoton() || (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())) )
+                               FillPhotonPlusConversionBackgroundHist(TruePhotonCandidate,pdgCodeParticle);
+               }
+               
+               if(Photon->IsPrimary()){
+                       if (TruePhotonCandidate->IsLargestComponentPhoton()){
+                               fHistoTruePrimaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                               fHistoTruePrimaryClusGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt()); // Allways Filled
+                       }
+                       if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion()){
+                               fHistoTruePrimaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                               fHistoTruePrimaryClusConvGammaESDPtMCPt[fiCut]->Fill(TruePhotonCandidate->Pt(),Photon->Pt()); // Allways Filled
+                       }
+                       
+               } else {
+                       if (TruePhotonCandidate->IsLargestComponentPhoton())
+                               fHistoTrueSecondaryClusGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())
+                               fHistoTrueSecondaryClusConvGammaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                       if(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother() > -1){
+                               if(((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 3122){
+                                       if (TruePhotonCandidate->IsLargestComponentPhoton())
+                                               fHistoTrueSecondaryClusGammaFromXFromLambdaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                                       if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())
+                                               fHistoTrueSecondaryClusConvGammaFromXFromLambdaPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                               }
+                               if(((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 310){
+                                       if (TruePhotonCandidate->IsLargestComponentPhoton())
+                                               fHistoTrueSecondaryClusGammaFromXFromK0sPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                                       if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())
+                                               fHistoTrueSecondaryClusConvGammaFromXFromK0sPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                               }
+                               if(((AliAODMCParticle*)AODMCTrackArray->At(((AliAODMCParticle*)AODMCTrackArray->At(Photon->GetMother()))->GetMother()))->GetPdgCode() == 221){
+                                       if (TruePhotonCandidate->IsLargestComponentPhoton())
+                                               fHistoTrueSecondaryClusGammaFromXFromEtasPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                                       if (TruePhotonCandidate->IsLargestComponentElectron() && TruePhotonCandidate->IsConversion())
+                                               fHistoTrueSecondaryClusConvGammaFromXFromEtasPt[fiCut]->Fill(TruePhotonCandidate->Pt());
+                                               
+                               }       
+                       }
+               }       
+       }
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskGammaCalo::ProcessAODMCParticles()
+{
+       
+       TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
+       
+       // Loop over all primary MC particle
+       for(Int_t i = 0; i < AODMCTrackArray->GetEntriesFast(); i++) {
+               
+               AliAODMCParticle* particle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(i));
+               if (!particle) continue;
+               if (!particle->IsPrimary()) continue;
+               
+               Int_t isMCFromMBHeader = -1;
+               if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
+                       isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent);
+                       if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
+               }
+               
+               if(((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(particle,AODMCTrackArray)){
+                       fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt()); // All MC Gamma
+                       if(particle->GetMother() >-1){ // Meson Decay Gamma
+                               switch((static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetMother())))->GetPdgCode()){
+                               case 111: // Pi0
+                                       fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt());
+                                       break;
+                               case 113: // Rho0
+                                       fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt());
+                                       break;
+                               case 221: // Eta
+                                       fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt());
+                                       break;
+                               case 223: // Omega
+                                       fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt());
+                                       break;
+                               case 331: // Eta'
+                                       fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt());
+                                       break;
+                               case 333: // Phi
+                                       fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt());
+                                       break;
+                               case 3212: // Sigma
+                                       fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt());
+                                       break;
+                               }
+                       }
+               }
+                       // Converted MC Gamma
+               if(fDoMesonAnalysis){
+                       if(particle->GetPdgCode() == 310 && fDoMesonQA > 0){
+                               Double_t mesonY = 10.;
+                               if(particle->E() - particle->Pz() == 0 || particle->E() + particle->Pz() == 0){
+                                       mesonY=10.-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
+                               } else {
+                                       mesonY = 0.5*(TMath::Log((particle->E()+particle->Pz()) / (particle->E()-particle->Pz())))-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
+                               }
+                               Float_t weightedK0s= 1;
+                               if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent)){
+                                       if (particle->Pt()>0.005){
+                                               weightedK0s= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, 0x0, fInputEvent);
+                                               //cout << "MC input \t"<<i << "\t" <<  particle->Pt()<<"\t"<<weighted << endl;
+                                       }
+                               }
+                               fHistoMCK0sPt[fiCut]->Fill(particle->Pt(),weightedK0s);
+                               fHistoMCK0sWOWeightPt[fiCut]->Fill(particle->Pt());
+                               fHistoMCK0sPtY[fiCut]->Fill(particle->Pt(),mesonY,weightedK0s);
+                       }
+                       if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))
+                               ->MesonIsSelectedAODMC(particle,AODMCTrackArray,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
+                               AliAODMCParticle* daughter0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(0)));
+                               AliAODMCParticle* daughter1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(particle->GetDaughter(1)));
+                               Float_t weighted= 1;
+                               if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent)){
+                                       if (particle->Pt()>0.005){
+                                               weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, 0x0, fInputEvent);
+                                               //                   if(particle->GetPdgCode() == 221){
+                                               //                      cout << "MC input \t"<<i << "\t" <<  particle->Pt()<<"\t"<<weighted << endl;
+                                               //                   }
+                                       }
+                               }
+                               Double_t mesonY = 10.;
+                               if(particle->E() - particle->Pz() == 0 || particle->E() + particle->Pz() == 0){
+                                       mesonY=10.-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
+                               } else{
+                                       mesonY = 0.5*(TMath::Log((particle->E()+particle->Pz()) / (particle->E()-particle->Pz())))-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
+                               }
+                               
+                               if(particle->GetPdgCode() == 111){
+                                       fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted); // All MC Pi0
+                                       fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt());
+                                       if (fDoMesonQA > 0) fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
+                               } else if(particle->GetPdgCode() == 221){
+                                       fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted); // All MC Eta
+                                       fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt());
+                                       if (fDoMesonQA > 0) fHistoMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
+                               }
+                               
+                               // Check the acceptance for both gammas
+                               if(((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter0,AODMCTrackArray) &&
+                               ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedAODMC(daughter1,AODMCTrackArray) ){
+                                       
+                                       if(particle->GetPdgCode() == 111){
+                                               fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted); // MC Pi0 with gamma in acc
+                                       } else if(particle->GetPdgCode() == 221){
+                                               fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted); // MC Eta with gamma in acc
+                                       }
+                               }
+                       }
+               }
+       }
+       
+}
+//________________________________________________________________________
+void AliAnalysisTaskGammaCalo::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(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
+                       isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent);
+                       if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
+               }
+               
+               if(((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(particle,fMCStack)){
+                       fHistoMCAllGammaPt[fiCut]->Fill(particle->Pt()); // All MC Gamma                        
+                       if(particle->GetMother(0) >-1){ // Meson Decay Gamma
+                               switch(fMCStack->Particle(particle->GetMother(0))->GetPdgCode()){
+                               case 111: // Pi0
+                                       fHistoMCDecayGammaPi0Pt[fiCut]->Fill(particle->Pt());
+                                       break;
+                               case 113: // Rho0
+                                       fHistoMCDecayGammaRhoPt[fiCut]->Fill(particle->Pt());
+                                       break;
+                               case 221: // Eta
+                                       fHistoMCDecayGammaEtaPt[fiCut]->Fill(particle->Pt());
+                                       break;
+                               case 223: // Omega
+                                       fHistoMCDecayGammaOmegaPt[fiCut]->Fill(particle->Pt());
+                                       break;
+                               case 331: // Eta'
+                                       fHistoMCDecayGammaEtapPt[fiCut]->Fill(particle->Pt());
+                                       break;
+                               case 333: // Phi
+                                       fHistoMCDecayGammaPhiPt[fiCut]->Fill(particle->Pt());
+                                       break;
+                               case 3212: // Sigma
+                                       fHistoMCDecayGammaSigmaPt[fiCut]->Fill(particle->Pt());
+                                       break;
+                               }
+                       }
+               }
+               if(fDoMesonAnalysis){
+                       if(particle->GetPdgCode() == 310 && fDoMesonQA > 0){
+                               Double_t mesonY = 10.;
+                               if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
+                                       mesonY=10.-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
+                               } else{
+                                       mesonY = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())))-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
+                               }
+                               Float_t weightedK0s= 1;
+                               if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent)){
+                                       if (particle->Pt()>0.005){
+                                               weightedK0s= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, fMCStack, fInputEvent);
+                                               //cout << "MC input \t"<<i << "\t" <<  particle->Pt()<<"\t"<<weighted << endl;
+                                       }
+                               }
+                               if (fMCStack->IsPhysicalPrimary(i)){
+                                       fHistoMCK0sPt[fiCut]->Fill(particle->Pt(),weightedK0s);
+                                       fHistoMCK0sWOWeightPt[fiCut]->Fill(particle->Pt());
+                                       fHistoMCK0sPtY[fiCut]->Fill(particle->Pt(),mesonY,weightedK0s);
+                               }
+                       }
+                       if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))
+                               ->MesonIsSelectedMC(particle,fMCStack,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
+                               TParticle* daughter0 = (TParticle*)fMCStack->Particle(particle->GetFirstDaughter());
+                               TParticle* daughter1 = (TParticle*)fMCStack->Particle(particle->GetLastDaughter());
+                               
+                               Float_t weighted= 1;
+                               if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent)){
+                                       if (particle->Pt()>0.005){
+                                               weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, fMCStack, fInputEvent);
+                                               //                   if(particle->GetPdgCode() == 221){
+                                               //                      cout << "MC input \t"<<i << "\t" <<  particle->Pt()<<"\t"<<weighted << endl;
+                                               //                   }
+                                       }
+                               }
+                               Double_t mesonY = 10.;
+                               if(particle->Energy() - particle->Pz() == 0 || particle->Energy() + particle->Pz() == 0){
+                                       mesonY=10.-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
+                               } else{
+                                       mesonY = 0.5*(TMath::Log((particle->Energy()+particle->Pz()) / (particle->Energy()-particle->Pz())))-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift();
+                               }
+                               
+                               if(particle->GetPdgCode() == 111){
+                                       fHistoMCPi0Pt[fiCut]->Fill(particle->Pt(),weighted); // All MC Pi0
+                                       fHistoMCPi0WOWeightPt[fiCut]->Fill(particle->Pt());
+                                       if (fDoMesonQA > 0) fHistoMCPi0PtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
+                               } else if(particle->GetPdgCode() == 221){
+                                       fHistoMCEtaPt[fiCut]->Fill(particle->Pt(),weighted); // All MC Eta
+                                       fHistoMCEtaWOWeightPt[fiCut]->Fill(particle->Pt());
+                                       if (fDoMesonQA > 0) fHistoMCEtaPtY[fiCut]->Fill(particle->Pt(),mesonY,weighted); // All MC Pi0
+                               }
+                               
+                               // Check the acceptance for both gammas
+                               if(((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter0,fMCStack) &&
+                               ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->ClusterIsSelectedMC(daughter1,fMCStack) ){                                   
+                                       if(particle->GetPdgCode() == 111){
+                                               fHistoMCPi0InAccPt[fiCut]->Fill(particle->Pt(),weighted); // MC Pi0 with gamma in acc
+                                       } else if(particle->GetPdgCode() == 221){
+                                               fHistoMCEtaInAccPt[fiCut]->Fill(particle->Pt(),weighted); // MC Eta with gamma in acc
+                                       }
+                               }
+                       }
+               }
+       }
+  
+       if (fDoMesonQA){
+               for(Int_t i = fMCStack->GetNprimary(); i < fMCStack->GetNtrack(); i++) {
+                       TParticle* particle = (TParticle *)fMCStack->Particle(i);
+                       if (!particle) continue;
+      
+                       Int_t isMCFromMBHeader = -1;
+                       if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 0){
+                               isMCFromMBHeader = ((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent);
+                               if(isMCFromMBHeader == 0 && ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetSignalRejection() != 3) continue;
+                       }
+      
+                       if(fDoMesonAnalysis){
+                               if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelectedMC(particle,fMCStack,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift())){
+                                       Float_t weighted= 1;
+                                       if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(i, fMCStack, fInputEvent)){
+                                               if (particle->Pt()>0.005){
+                                                       weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),i, fMCStack, fInputEvent);
+              //                   if(particle->GetPdgCode() == 221){
+              //                      cout << "MC input \t"<<i << "\t" <<  particle->Pt()<<"\t"<<weighted << endl;
+              //                   }
+                                               }
+                                       }
+                                       
+                                       if(particle->GetPdgCode() == 111){
+                                               Int_t pdgCode = ((TParticle*)fMCStack->Particle( particle->GetFirstMother() ))->GetPdgCode();
+                                               Int_t source = GetSourceClassification(111,pdgCode);
+                                               fHistoMCSecPi0PtvsSource[fiCut]->Fill(particle->Pt(),source,weighted); // All MC Pi0
+                                               fHistoMCSecPi0Source[fiCut]->Fill(pdgCode);
+                                       } else if(particle->GetPdgCode() == 221){
+                                               Int_t pdgCode = ((TParticle*)fMCStack->Particle( particle->GetFirstMother() ))->GetPdgCode();
+                                               fHistoMCSecEtaPt[fiCut]->Fill(particle->Pt(),weighted); // All MC Pi0
+                                               fHistoMCSecEtaSource[fiCut]->Fill(pdgCode);
+                                       }
+                               }
+                       }
+               }
+       }
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskGammaCalo::CalculatePi0Candidates(){
+       
+       // Conversion Gammas
+       if(fClusterCandidates->GetEntries()>0){
+
+               // vertex
+               Double_t vertex[3] = {0};
+               InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
+
+               for(Int_t firstGammaIndex=0;firstGammaIndex<fClusterCandidates->GetEntries();firstGammaIndex++){
+                       AliAODConversionPhoton *gamma0=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(firstGammaIndex));
+                       if (gamma0==NULL) continue;
+                       
+                       for(Int_t secondGammaIndex=0;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
+                               AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
+                               if (gamma1==NULL) continue;
+                                                               
+                               AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma0,gamma1);
+                               pi0cand->SetLabels(firstGammaIndex,secondGammaIndex);
+                               
+                               
+                               
+                               if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
+                                       fHistoMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
+                                       // fill new histograms
+                                       if(pi0cand->GetAlpha()<0.1)
+                                               fHistoMotherInvMassEalpha[fiCut]->Fill(pi0cand->M(),pi0cand->E());
+                                       
+                                       if (fDoMesonQA > 0){
+                                               if ( pi0cand->M() > 0.05 && pi0cand->M() < 0.17){
+                                                       fHistoMotherPi0PtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
+                                                       fHistoMotherPi0PtAlpha[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetAlpha());
+                                                       fHistoMotherPi0PtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle());      
+                                               }
+                                               if ( pi0cand->M() > 0.45 && pi0cand->M() < 0.65){
+                                                       fHistoMotherEtaPtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
+                                                       fHistoMotherEtaPtAlpha[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetAlpha());
+                                                       fHistoMotherEtaPtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle());
+                                               }
+                                       }
+                                       if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGCalculation()){
+                                               Int_t zbin = 0;
+                                               Int_t mbin = 0;
+                                               
+                                               if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->BackgroundHandlerType() == 0){
+                                                       zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
+                                                       if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
+                                                               mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
+                                                       } else {
+                                                               mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fClusterCandidates->GetEntries());
+                                                       }
+                                               } 
+                                               Double_t sparesFill[4] = {pi0cand->M(),pi0cand->Pt(),(Double_t)zbin,(Double_t)mbin};
+                                               fSparseMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
+                                       }
+                               
+                                       if(fIsMC){
+                                               if(fInputEvent->IsA()==AliESDEvent::Class())
+                                                       ProcessTrueMesonCandidates(pi0cand,gamma0,gamma1);
+                                               if(fInputEvent->IsA()==AliAODEvent::Class())
+                                                       ProcessTrueMesonCandidatesAOD(pi0cand,gamma0,gamma1);
+                                       }
+                                       
+                                       if (fDoMesonQA == 1){
+                                               fHistoMotherInvMassECalib[fiCut]->Fill(pi0cand->M(),gamma1->E());
+                                               if(pi0cand->GetAlpha()<0.1)
+                                               fHistoMotherInvMassECalibalpha[fiCut]->Fill(pi0cand->M(),gamma1->E());            
+                                       }
+                                       
+                               }
+                               delete pi0cand;
+                               pi0cand=0x0;
+                       }
+               }
+       }
+}
+//______________________________________________________________________
+void AliAnalysisTaskGammaCalo::ProcessTrueMesonCandidates(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1)
+{
+       // Process True Mesons
+       AliStack *MCStack = fMCEvent->Stack();
+       
+       Bool_t isTruePi0 = kFALSE;
+       Bool_t isTrueEta = kFALSE;
+       Int_t gamma0MCLabel = TrueGammaCandidate0->GetCaloPhotonMCLabel(0);     // get most probable MC label
+       Int_t gamma0MotherLabel = -1;
+
+       if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
+               TParticle * gammaMC0 = (TParticle*)MCStack->Particle(gamma0MCLabel);
+               if (TrueGammaCandidate0->IsLargestComponentPhoton() || TrueGammaCandidate0->IsLargestComponentElectron()){              // largest component is electro magnetic
+                       // get mother of interest (pi0 or eta)
+                       if (TrueGammaCandidate0->IsLargestComponentPhoton()){                                                                                                           // for photons its the direct mother 
+                               gamma0MotherLabel=gammaMC0->GetMother(0);
+                       } else if (TrueGammaCandidate0->IsLargestComponentElectron()){                                                                                          // for electrons its either the direct mother or for conversions the grandmother
+                               if (TrueGammaCandidate0->IsConversion()) gamma0MotherLabel=MCStack->Particle(gammaMC0->GetMother(0))->GetMother(0);
+                               else gamma0MotherLabel=gammaMC0->GetMother(0); 
+                       }
+               }       
+       }
+       if (!TrueGammaCandidate1->GetIsCaloPhoton()) AliFatal("CaloPhotonFlag has not been set. Aborting");
+       
+       Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0);     // get most probable MC label
+       Int_t gamma1MotherLabel = -1;
+       // check if 
+
+       if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
+               // Daughters Gamma 1
+               TParticle * gammaMC1 = (TParticle*)MCStack->Particle(gamma1MCLabel);
+               if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){              // largest component is electro magnetic
+                       // get mother of interest (pi0 or eta)
+                       if (TrueGammaCandidate1->IsLargestComponentPhoton()){                                                                                                           // for photons its the direct mother 
+                               gamma1MotherLabel=gammaMC1->GetMother(0);
+                       } else if (TrueGammaCandidate1->IsLargestComponentElectron()){                                                                                          // for electrons its either the direct mother or for conversions the grandmother
+                               if (TrueGammaCandidate1->IsConversion()) gamma1MotherLabel=MCStack->Particle(gammaMC1->GetMother(0))->GetMother(0);
+                               else gamma1MotherLabel=gammaMC1->GetMother(0); 
+                       }
+               }       
+       }
+                       
+       if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
+               if(((TParticle*)MCStack->Particle(gamma1MotherLabel))->GetPdgCode() == 111){
+                       isTruePi0=kTRUE;
+               }
+               if(((TParticle*)MCStack->Particle(gamma1MotherLabel))->GetPdgCode() == 221){
+                       isTrueEta=kTRUE;
+               }
+       }
+       
+       if(isTruePi0 || isTrueEta){// True Pion or Eta
+               fHistoTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+               if (fDoMesonQA > 0){
+                       // both gammas are real gammas
+                       if (TrueGammaCandidate0->IsLargestComponentPhoton() && TrueGammaCandidate1->IsLargestComponentPhoton()) 
+                               fHistoTrueMotherCaloPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                       // both particles are electrons
+                       if (TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate1->IsLargestComponentElectron() ) 
+                               fHistoTrueMotherCaloElectronInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                       // both particles are converted electrons
+                       if ((TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion()) && (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()) ){
+                               fHistoTrueMotherCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                               if (isTruePi0 )fHistoTruePi0CaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                               if (isTrueEta )fHistoTrueEtaCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                       }
+                       // 1 gamma is converted the other one is normals
+                       if ( (TrueGammaCandidate0->IsLargestComponentPhoton() && TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()) ||
+                                (TrueGammaCandidate1->IsLargestComponentPhoton() && TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion())
+                       ) 
+                               fHistoTrueMotherCaloMixedPhotonConvPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                       
+                       // at least one of the photon is merged
+                       if (TrueGammaCandidate0->IsMerged() || TrueGammaCandidate0->IsMergedPartConv() || TrueGammaCandidate0->IsDalitzMerged() || TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate1->IsDalitzMerged() )
+                               fHistoTrueMotherCaloMergedClusterInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                       // at least one of the photon is merged and part conv
+                       if (TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate0->IsMergedPartConv()) 
+                               fHistoTrueMotherCaloMergedClusterPartConvInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+               }
+       
+               if (fDoMesonQA > 0){
+                       if (isTruePi0){
+                               if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
+                                       fHistoTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
+                                       fHistoTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetAlpha());
+                                       fHistoTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
+                               }
+                       } else if (isTrueEta){
+                               if ( Pi0Candidate->M() > 0.45 && Pi0Candidate->M() < 0.65){
+                                       fHistoTrueEtaPtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
+                                       fHistoTrueEtaPtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetAlpha());
+                                       fHistoTrueEtaPtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
+                               }
+                       }
+               }
+               
+               if(gamma0MotherLabel >= MCStack->GetNprimary()){ // Secondary Meson
+                       Int_t secMotherLabel = ((TParticle*)MCStack->Particle(gamma0MotherLabel))->GetMother(0);
+                       Float_t weightedSec= 1;
+                       if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, fMCStack, fInputEvent) && MCStack->Particle(secMotherLabel)->GetPdgCode()==310){
+                               weightedSec= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),secMotherLabel, fMCStack, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
+                               //cout << "MC input \t"<<i << "\t" <<  particle->Pt()<<"\t"<<weighted << endl;
+                       }
+                       fHistoTrueSecondaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+                       if (secMotherLabel >-1){
+                               if(MCStack->Particle(secMotherLabel)->GetPdgCode()==310){
+                                       fHistoTrueSecondaryMotherFromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+                                       if (fDoMesonQA > 0)fHistoTrueK0sWithPi0DaughterMCPt[fiCut]->Fill(MCStack->Particle(secMotherLabel)->Pt());
+                               }
+                               if(MCStack->Particle(secMotherLabel)->GetPdgCode()==221){
+                                       fHistoTrueSecondaryMotherFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+                                       if (fDoMesonQA > 0)fHistoTrueEtaWithPi0DaughterMCPt[fiCut]->Fill(MCStack->Particle(secMotherLabel)->Pt());
+                               }
+                               if(MCStack->Particle(secMotherLabel)->GetPdgCode()==3122){
+                                       fHistoTrueSecondaryMotherFromLambdaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+                                       if (fDoMesonQA > 0)fHistoTrueLambdaWithPi0DaughterMCPt[fiCut]->Fill(MCStack->Particle(secMotherLabel)->Pt());
+                               }
+                       }
+               } else { // Only primary pi0 for efficiency calculation
+                       Float_t weighted= 1;
+                       if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, fMCStack, fInputEvent)){
+                               if (((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt()>0.005){
+                                       weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),gamma1MotherLabel, fMCStack, fInputEvent);
+                                       //                      cout << "rec \t " <<gamma1MotherLabel << "\t" <<  weighted << endl;
+                               }
+                       }
+                       fHistoTruePrimaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
+                       fHistoTruePrimaryMotherW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                       fProfileTruePrimaryMotherWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
+                               
+                       if (fDoMesonQA > 0){
+                               if(isTruePi0){ // Only primary pi0 for resolution
+                                       fHistoTruePrimaryPi0MCPtResolPt[fiCut]->Fill(((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt())/((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),weighted);
+                               }
+                               if (isTrueEta){ // Only primary eta for resolution
+                                       fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt())/((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),weighted);
+                               }
+                       }
+               }       
+       } else if(!isTruePi0 && !isTrueEta){ // Background
+               if (fDoMesonQA > 0){
+                       if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
+                               fHistoTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                       } else { // No photon or without mother
+                               fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                       }
+               }
+       }
+
+}
+//______________________________________________________________________
+void AliAnalysisTaskGammaCalo::ProcessTrueMesonCandidatesAOD(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1)
+{
+       
+       // Process True Mesons
+       TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(fInputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
+       Bool_t isTruePi0 = kFALSE;
+       Bool_t isTrueEta = kFALSE;
+               
+       Int_t gamma0MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0);     // get most probable MC label
+       Int_t gamma0MotherLabel = -1;
+               // check if 
+
+       if(gamma0MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
+               // Daughters Gamma 0
+               AliAODMCParticle * gammaMC0 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MCLabel));
+               if (TrueGammaCandidate0->IsLargestComponentPhoton() || TrueGammaCandidate0->IsLargestComponentElectron()){              // largest component is electro magnetic
+                       // get mother of interest (pi0 or eta)
+                       if (TrueGammaCandidate0->IsLargestComponentPhoton()){                                                                                                           // for photons its the direct mother 
+                               gamma0MotherLabel=gammaMC0->GetMother();
+                       } else if (TrueGammaCandidate0->IsLargestComponentElectron()){                                                                                          // for electrons its either the direct mother or for conversions the grandmother
+                               if (TrueGammaCandidate0->IsConversion()){
+                                       AliAODMCParticle * gammaGrandMotherMC0 =  static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC0->GetMother()));
+                                       gamma0MotherLabel=gammaGrandMotherMC0->GetMother();
+                               } else gamma0MotherLabel=gammaMC0->GetMother(); 
+                       }
+               }       
+       }
+
+       Int_t gamma1MCLabel = TrueGammaCandidate1->GetCaloPhotonMCLabel(0);     // get most probable MC label
+       Int_t gamma1MotherLabel = -1;
+               // check if 
+
+       if(gamma1MCLabel != -1){ // Gamma is Combinatorial; MC Particles don't belong to the same Mother
+               // Daughters Gamma 1
+               AliAODMCParticle * gammaMC1 = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MCLabel));
+               if (TrueGammaCandidate1->IsLargestComponentPhoton() || TrueGammaCandidate1->IsLargestComponentElectron()){              // largest component is electro magnetic
+                       // get mother of interest (pi0 or eta)
+                       if (TrueGammaCandidate1->IsLargestComponentPhoton()){                                                                                                           // for photons its the direct mother 
+                               gamma1MotherLabel=gammaMC1->GetMother();
+                       } else if (TrueGammaCandidate1->IsLargestComponentElectron()){                                                                                          // for electrons its either the direct mother or for conversions the grandmother
+                               if (TrueGammaCandidate1->IsConversion()){
+                                       AliAODMCParticle * gammaGrandMotherMC1 =  static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gammaMC1->GetMother()));
+                                       gamma1MotherLabel=gammaGrandMotherMC1->GetMother();
+                               } else gamma1MotherLabel=gammaMC1->GetMother(); 
+                       }
+               }       
+       }
+                       
+       if(gamma0MotherLabel>=0 && gamma0MotherLabel==gamma1MotherLabel){
+               if(((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 111){
+                       isTruePi0=kTRUE;
+               }
+               if(((AliAODMCParticle*)AODMCTrackArray->At(gamma1MotherLabel))->GetPdgCode() == 221){
+                       isTrueEta=kTRUE;
+               }
+       }
+       
+       if(isTruePi0 || isTrueEta){// True Pion or Eta
+               fHistoTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+               if (fDoMesonQA > 0){
+                       // both gammas are real gammas
+                       if (TrueGammaCandidate0->IsLargestComponentPhoton() && TrueGammaCandidate1->IsLargestComponentPhoton()) 
+                               fHistoTrueMotherCaloPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                       // both particles are electrons
+                       if (TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate1->IsLargestComponentElectron() ) 
+                               fHistoTrueMotherCaloElectronInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                       // both particles are converted electrons
+                       if ((TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion()) && (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()) ){
+                               fHistoTrueMotherCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                               if (isTruePi0 )fHistoTruePi0CaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                               if (isTrueEta )fHistoTrueEtaCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                       }
+                       // 1 gamma is converted the other one is normals
+                       if ( (TrueGammaCandidate0->IsLargestComponentPhoton() && TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()) ||
+                                (TrueGammaCandidate1->IsLargestComponentPhoton() && TrueGammaCandidate0->IsLargestComponentElectron() && TrueGammaCandidate0->IsConversion())
+                       ) 
+                               fHistoTrueMotherCaloMixedPhotonConvPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                       
+                       // at least one of the photon is merged
+                       if (TrueGammaCandidate0->IsMerged() || TrueGammaCandidate0->IsMergedPartConv() || TrueGammaCandidate0->IsDalitzMerged() || TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate1->IsDalitzMerged() )
+                               fHistoTrueMotherCaloMergedClusterInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                       // at least one of the photon is merged and part conv
+                       if (TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate0->IsMergedPartConv()) 
+                               fHistoTrueMotherCaloMergedClusterPartConvInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+               }
+
+               if (fDoMesonQA > 0){
+                       if (isTruePi0){
+                               if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
+                               fHistoTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
+                               fHistoTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetAlpha());
+                               fHistoTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
+                               }
+                       } else if (isTrueEta){
+                               if ( Pi0Candidate->M() > 0.45 && Pi0Candidate->M() < 0.65){
+                               fHistoTrueEtaPtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
+                               fHistoTrueEtaPtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetAlpha());
+                               fHistoTrueEtaPtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
+                               }
+                       }
+               }
+               if(!(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel))->IsPrimary())){ // Secondary Meson
+                       Int_t secMotherLabel = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetMother();
+                       Float_t weightedSec= 1;
+                       if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, 0x0, fInputEvent) && static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
+                               weightedSec= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),secMotherLabel, 0x0, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
+                               //cout << "MC input \t"<<i << "\t" <<  particle->Pt()<<"\t"<<weighted << endl;
+                       }
+                       fHistoTrueSecondaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+                       if (secMotherLabel >-1){
+                               if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
+                                       fHistoTrueSecondaryMotherFromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+                                       if (fDoMesonQA > 0)fHistoTrueK0sWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
+                               }
+                               if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==221){
+                                       fHistoTrueSecondaryMotherFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+                                       if (fDoMesonQA > 0)fHistoTrueEtaWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
+                               }
+                               if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==3122){
+                                       fHistoTrueSecondaryMotherFromLambdaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+                                       if (fDoMesonQA > 0)fHistoTrueLambdaWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
+                               }
+                       }       
+               } else{ // Only primary pi0 for efficiency calculation
+                       Float_t weighted= 1;
+                       if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, 0x0, fInputEvent)){
+                               if (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt()>0.005){
+                               weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),gamma1MotherLabel, 0x0, fInputEvent);
+                               //                      cout << "rec \t " <<gamma1MotherLabel << "\t" <<  weighted << endl;
+                               }
+                       }
+                       fHistoTruePrimaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
+                       fHistoTruePrimaryMotherW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                       fProfileTruePrimaryMotherWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
+                       
+                       if (fDoMesonQA > 0){
+                               if(isTruePi0){ // Only primary pi0 for resolution
+                                       fHistoTruePrimaryPi0MCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
+                                                                                                                       (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted);
+                               
+                               }
+                               if (isTrueEta){ // Only primary eta for resolution
+                                       fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
+                                                                                                                       (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted);
+                               }
+                       }
+               }
+       } else if(!isTruePi0 && !isTrueEta) { // Background
+               if (fDoMesonQA > 0){
+                       if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
+                               fHistoTrueBckGGInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                       } else { // No photon or without mother
+                               fHistoTrueBckContInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                       }
+               }
+       }
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskGammaCalo::CalculateBackground(){
+       
+       Int_t zbin= fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
+       Int_t mbin = 0;
+       
+       if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
+               mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
+       } else {
+               mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fClusterCandidates->GetEntries());
+       }
+       
+       if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
+               for(Int_t nEventsInBG=0;nEventsInBG<fBGHandler[fiCut]->GetNBGEvents();nEventsInBG++){
+                       AliGammaConversionAODVector *previousEventV0s = fBGHandler[fiCut]->GetBGGoodV0s(zbin,mbin,nEventsInBG);
+                       
+                       for(Int_t iCurrent=0;iCurrent<fClusterCandidates->GetEntries();iCurrent++){
+                               AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fClusterCandidates->At(iCurrent));
+                               for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
+                                       AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
+                                       AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
+                                       backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
+                                       if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))
+                                               ->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
+                                               fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
+                                               Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
+                                               fSparseMotherBackInvMassPtZM[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){
+                               for(Int_t iCurrent=0;iCurrent<fClusterCandidates->GetEntries();iCurrent++){
+                                       AliAODConversionPhoton currentEventGoodV0 = *(AliAODConversionPhoton*)(fClusterCandidates->At(iCurrent));
+                                       for(UInt_t iPrevious=0;iPrevious<previousEventV0s->size();iPrevious++){
+                               
+                                               AliAODConversionPhoton previousGoodV0 = (AliAODConversionPhoton)(*(previousEventV0s->at(iPrevious)));
+                                               AliAODConversionMother *backgroundCandidate = new AliAODConversionMother(&currentEventGoodV0,&previousGoodV0);
+                                               backgroundCandidate->CalculateDistanceOfClossetApproachToPrimVtx(fInputEvent->GetPrimaryVertex());
+                                               if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(backgroundCandidate,kFALSE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
+                                                       fHistoMotherBackInvMassPt[fiCut]->Fill(backgroundCandidate->M(),backgroundCandidate->Pt());
+                                                       Double_t sparesFill[4] = {backgroundCandidate->M(),backgroundCandidate->Pt(),(Double_t)zbin,(Double_t)mbin};
+                                                       fSparseMotherBackInvMassPtZM[fiCut]->Fill(sparesFill,1);
+                                               }
+                                               delete backgroundCandidate;
+                                               backgroundCandidate = 0x0;
+                                       }
+                               }
+                       }
+               }
+       }
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskGammaCalo::RotateParticle(AliAODConversionPhoton *gamma){
+       Int_t fNDegreesPMBackground= ((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->NDegreesRotation();
+       Double_t nRadiansPM = fNDegreesPMBackground*TMath::Pi()/180;
+       Double_t rotationValue = fRandom.Rndm()*2*nRadiansPM + TMath::Pi()-nRadiansPM;
+       gamma->RotateZ(rotationValue);
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskGammaCalo::UpdateEventByEventData(){
+       //see header file for documentation
+       if(fClusterCandidates->GetEntries() >0 ){
+               if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
+                       fBGHandler[fiCut]->AddEvent(fClusterCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fV0Reader->GetNumberOfPrimaryTracks(),fEventPlaneAngle);
+               } else { // means we use #V0s for multiplicity
+                       fBGHandler[fiCut]->AddEvent(fClusterCandidates,fInputEvent->GetPrimaryVertex()->GetX(),fInputEvent->GetPrimaryVertex()->GetY(),fInputEvent->GetPrimaryVertex()->GetZ(),fClusterCandidates->GetEntries(),fEventPlaneAngle);
+               }
+       }
+}
+
+
+//________________________________________________________________________
+void AliAnalysisTaskGammaCalo::FillPhotonBackgroundHist(AliAODConversionPhoton *TruePhotonCandidate, Int_t pdgCode)
+{
+       // Bck = 0 e+-, 1 pi+-, 2 p+-, 3 K+-, 4 n, 5 K0s, 6 Lambda, 7 mu+-, 8 rest
+       if(fIsFromMBHeader){
+               if(abs(pdgCode) == 11)                  fHistoClusPhotonBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0);
+               else if( abs(pdgCode)==211)     fHistoClusPhotonBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1);
+               else if( abs(pdgCode)==2212)    fHistoClusPhotonBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2);
+               else if( abs(pdgCode)==321)     fHistoClusPhotonBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3);
+               else if( abs(pdgCode)==2112)    fHistoClusPhotonBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),4);
+               else if( abs(pdgCode)==310)     fHistoClusPhotonBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),5);   
+               else if( abs(pdgCode)==3122)    fHistoClusPhotonBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),6);
+               else if( abs(pdgCode)==13)              fHistoClusPhotonBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),7);
+               else                                                    fHistoClusPhotonBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),8);
+       }       
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskGammaCalo::FillPhotonPlusConversionBackgroundHist(AliAODConversionPhoton *TruePhotonCandidate, Int_t pdgCode)
+{
+       // Bck = 0 e+-, 1 pi+-, 2 p+-, 3 K+-, 4 n, 5 K0s, 6 Lambda, 7 mu+-, 8 rest
+       if(fIsFromMBHeader){
+               if(abs(pdgCode) == 11)                  fHistoClusPhotonPlusConvBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),0);
+               else if( abs(pdgCode)==211)     fHistoClusPhotonPlusConvBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),1);
+               else if( abs(pdgCode)==2212)    fHistoClusPhotonPlusConvBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),2);
+               else if( abs(pdgCode)==321)     fHistoClusPhotonPlusConvBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),3);
+               else if( abs(pdgCode)==2112)    fHistoClusPhotonPlusConvBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),4);
+               else if( abs(pdgCode)==310)     fHistoClusPhotonPlusConvBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),5);   
+               else if( abs(pdgCode)==3122)    fHistoClusPhotonPlusConvBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),6);
+               else if( abs(pdgCode)==13)              fHistoClusPhotonPlusConvBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),7);
+               else                                                    fHistoClusPhotonPlusConvBGPt[fiCut]->Fill(TruePhotonCandidate->Pt(),8);
+       }       
+}
+
+
+void AliAnalysisTaskGammaCalo::SetLogBinningXTH2(TH2* histoRebin){
+       TAxis *axisafter = histoRebin->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);
+       delete [] newbins;
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskGammaCalo::Terminate(const Option_t *)
+{
+  
+  //fOutputContainer->Print(); // Will crash on GRID
+}
+
+//________________________________________________________________________
+Int_t AliAnalysisTaskGammaCalo::GetSourceClassification(Int_t daughter, Int_t pdgCode){
+  
+       if (daughter == 111) {
+               if (abs(pdgCode) == 310) return 1; // k0s
+               else if (abs(pdgCode) == 3122) return 2; // Lambda
+               else if (abs(pdgCode) == 130) return 3; // K0L
+               else if (abs(pdgCode) == 2212) return 4; // proton
+               else if (abs(pdgCode) == 2112) return 5; // neutron
+               else if (abs(pdgCode) == 211) return 6; // pion
+               else if (abs(pdgCode) == 321) return 7; // kaon
+               else if (abs(pdgCode) == 113 || abs(pdgCode) == 213 ) return 8; // rho 0,+,-
+               else if (abs(pdgCode) == 3222 || abs(pdgCode) == 3212 || abs(pdgCode) == 3112  ) return 9; // Sigma
+               else if (abs(pdgCode) == 2224 || abs(pdgCode) == 2214 || abs(pdgCode) == 2114 || abs(pdgCode) == 1114  ) return 10; // Delta
+               else if (abs(pdgCode) == 313 || abs(pdgCode) == 323   ) return 11; // K*
+               else return 15;
+       }
+       return 15;
+  
+}
diff --git a/PWGGA/GammaConv/AliAnalysisTaskGammaCalo.h b/PWGGA/GammaConv/AliAnalysisTaskGammaCalo.h
new file mode 100644 (file)
index 0000000..bbed4e4
--- /dev/null
@@ -0,0 +1,241 @@
+#ifndef ALIANLYSISTASKGAMMACALO_cxx
+#define ALIANLYSISTASKGAMMACALO_cxx
+
+#include "AliAnalysisTaskSE.h"
+#include "AliESDtrack.h"
+#include "AliV0ReaderV1.h"
+#include "AliKFConversionPhoton.h"
+#include "AliGammaConversionAODBGHandler.h"
+#include "AliConversionAODBGHandlerRP.h"
+#include "AliCaloPhotonCuts.h"
+#include "AliConvEventCuts.h"
+#include "AliConversionPhotonCuts.h"
+#include "AliConversionMesonCuts.h"
+#include "AliAnalysisManager.h"
+#include "TProfile2D.h"
+#include "TH3.h"
+#include "TH3F.h"
+
+class AliAnalysisTaskGammaCalo : public AliAnalysisTaskSE {
+       public:
+
+               AliAnalysisTaskGammaCalo();
+               AliAnalysisTaskGammaCalo(const char *name);
+               virtual ~AliAnalysisTaskGammaCalo();
+
+               virtual void   UserCreateOutputObjects();
+               virtual Bool_t Notify();
+               virtual void   UserExec(Option_t *);
+               virtual void   Terminate(const Option_t*);
+               void InitBack();
+
+               void SetIsHeavyIon(Int_t flag){
+                       fIsHeavyIon = flag;    
+               }
+
+               // base functions for selecting photon and meson candidates in reconstructed data
+               void ProcessClusters();
+               void CalculatePi0Candidates();
+               
+               // MC functions
+               void SetIsMC(Bool_t isMC){fIsMC=isMC;}
+               void ProcessMCParticles();
+               void ProcessAODMCParticles();
+               void ProcessTrueClusterCandidates( AliAODConversionPhoton* TruePhotonCandidate);
+               void ProcessTrueClusterCandidatesAOD( AliAODConversionPhoton* TruePhotonCandidate);
+               void ProcessTrueMesonCandidates( AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1);
+               void ProcessTrueMesonCandidatesAOD(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1);
+               
+               // switches for additional analysis streams or outputs
+               void SetDoMesonAnalysis(Bool_t flag){fDoMesonAnalysis = flag;}
+               void SetDoMesonQA(Int_t flag){fDoMesonQA = flag;}
+               void SetDoClusterQA(Int_t flag){fDoClusterQA = flag;}
+               
+           // Setting the cut lists for the conversion photons
+               void SetEventCutList(Int_t nCuts, TList *CutArray){
+                       fnCuts = nCuts;
+                       fEventCutArray = CutArray;
+               }
+
+           // Setting the cut lists for the calo photons
+               void SetCaloCutList(Int_t nCuts, TList *CutArray){
+                       fnCuts = nCuts;
+                       fClusterCutArray = CutArray;
+               }
+               
+               // Setting the cut lists for the meson
+               void SetMesonCutList(Int_t nCuts, TList *CutArray){
+                       fnCuts = nCuts;
+                       fMesonCutArray = CutArray;
+               }
+
+               // BG HandlerSettings
+               void CalculateBackground();
+               void CalculateBackgroundRP();
+               void RotateParticle(AliAODConversionPhoton *gamma);
+               void RotateParticleAccordingToEP(AliAODConversionPhoton *gamma, Double_t previousEventEP, Double_t thisEventEP);
+               void FillPhotonBackgroundHist(AliAODConversionPhoton *TruePhotonCandidate, Int_t pdgCode);
+               void FillPhotonPlusConversionBackgroundHist(AliAODConversionPhoton *TruePhotonCandidate, Int_t pdgCode);
+               void UpdateEventByEventData();
+               
+               // Additional functions for convenience
+               void SetLogBinningXTH2(TH2* histoRebin);
+               Int_t GetSourceClassification(Int_t daughter, Int_t pdgCode);
+       
+       protected:
+               AliV0ReaderV1                                           *fV0Reader;                                                     // basic photon Selection Task
+               AliGammaConversionAODBGHandler          **fBGHandler;                                           // BG handler for Conversion 
+               AliVEvent                                                       *fInputEvent;                                           // current event
+               AliMCEvent                                                      *fMCEvent;                                                      // corresponding MC event
+               AliStack                                                        *fMCStack;                                                      // stack belonging to MC event
+               TList                                                           **fCutFolder;                                           // Array of lists for containers belonging to cut
+               TList                                                           **fESDList;                                                     // Array of lists with histograms with reconstructed properties   
+               TList                                                           **fBackList;                                            // Array of lists with BG THnSparseF
+               TList                                                           **fMotherList;                                          // Array of lists with Signal THnSparseF
+               TList                                                           **fTrueList;                                            // Array of lists with histograms with MC validated reconstructed properties
+               TList                                                           **fMCList;                                                      // Array of lists with histograms with pure MC information
+               TList                                                           **fHeaderNameList;                                      // Array of lists with header names for MC header selection
+               TList                                                           *fOutputContainer;                                      // Output container
+               TList                                                           *fClusterCandidates;                            //! current list of cluster candidates
+               TList                                                           *fEventCutArray;                                        // List with Event Cuts
+               AliConvEventCuts                                        *fEventCuts;                                            // EventCutObject
+               TList                                                           *fClusterCutArray;                                      // List with Cluster Cuts
+               AliCaloPhotonCuts                                       *fCaloPhotonCuts;                                       // CaloPhotonCutObject
+               TList                                                           *fMesonCutArray;                                        // List with Meson Cuts
+               AliConversionMesonCuts                          *fMesonCuts;                                            // MesonCutObject
+               
+               //histograms for mesons reconstructed quantities
+               TH2F                                                            **fHistoMotherInvMassPt;                        //! array of histogram with signal + BG for same event photon pairs, inv Mass, pt
+               THnSparseF                                                      **fSparseMotherInvMassPtZM;                     //! array of THnSparseF with signal + BG for same event photon pairs, inv Mass, pt
+               TH2F                                                            **fHistoMotherBackInvMassPt;            //! array of histogram with BG for mixed event photon pairs, inv Mass, pt
+               THnSparseF                                                      **fSparseMotherBackInvMassPtZM;         //! array of THnSparseF with BG for same event photon pairs, inv Mass, pt
+               TH2F                                                            **fHistoMotherInvMassEalpha;            //! array of histograms with alpha cut of 0.1 for inv mass vs pt
+               TH2F                                                            **fHistoMotherPi0PtY;                           //! array of histograms with invariant mass cut of 0.05 && pi0cand->M() < 0.17, pt, Y
+               TH2F                                                            **fHistoMotherEtaPtY;                           //! array of histograms with invariant mass cut of 0.45 && pi0cand->M() < 0.65, pt, Y
+               TH2F                                                            **fHistoMotherPi0PtAlpha;                       //! array of histograms with invariant mass cut of 0.05 && pi0cand->M() < 0.17, pt, alpha
+               TH2F                                                            **fHistoMotherEtaPtAlpha;                       //! array of histograms with invariant mass cut of 0.45 && pi0cand->M() < 0.65, pt, alpha
+               TH2F                                                            **fHistoMotherPi0PtOpenAngle;           //! array of histograms with invariant mass cut of 0.05 && pi0cand->M() < 0.17, pt, openAngle
+               TH2F                                                            **fHistoMotherEtaPtOpenAngle;           //! array of histograms with invariant mass cut of 0.45 && pi0cand->M() < 0.65, pt, openAngle
+               TH2F                                                            **fHistoMotherInvMassECalib;            //! array of histogram with signal + BG for same event photon pairs, inv Mass, energy of cluster
+               TH2F                                                            **fHistoMotherInvMassECalibalpha;       //! array of histogram with signal + BG for same event photon pairs, inv Mass, energy of cluster, alpha cut 0.1
+
+               // histograms for rec photon clusters
+               TH1F                                                            ** fHistoClusGammaPt;                           //! array of histos with cluster, pt
+                                                                               
+               //histograms for pure MC quantities
+               TH1I                                                            **fHistoMCHeaders;                                      //! array of histos for header names
+               TH1F                                                            **fHistoMCAllGammaPt;                           //! array of histos with all gamma, pT
+               TH1F                                                            **fHistoMCDecayGammaPi0Pt;                      //! array of histos with decay gamma from pi0, pT
+               TH1F                                                            **fHistoMCDecayGammaRhoPt;                      //! array of histos with decay gamma from rho, pT
+               TH1F                                                            **fHistoMCDecayGammaEtaPt;                      //! array of histos with decay gamma from eta, pT
+               TH1F                                                            **fHistoMCDecayGammaOmegaPt;            //! array of histos with decay gamma from omega, pT
+               TH1F                                                            **fHistoMCDecayGammaEtapPt;                     //! array of histos with decay gamma from eta', pT
+               TH1F                                                            **fHistoMCDecayGammaPhiPt;                      //! array of histos with decay gamma from phi, pT
+               TH1F                                                            **fHistoMCDecayGammaSigmaPt;            //! array of histos with decay gamma from Sigma0, pT
+               TH1F                                                            **fHistoMCPi0Pt;                                        //! array of histos with weighted pi0, pT
+               TH1F                                                            **fHistoMCPi0WOWeightPt;                        //! array of histos with unweighted pi0, pT
+               TH1F                                                            **fHistoMCEtaPt;                                        //! array of histos with weighted eta, pT
+               TH1F                                                            **fHistoMCEtaWOWeightPt;                        //! array of histos with unweighted eta, pT
+               TH1F                                                            **fHistoMCPi0InAccPt;                           //! array of histos with weighted pi0 in acceptance, pT
+               TH1F                                                            **fHistoMCEtaInAccPt;                           //! array of histos with weighted eta in acceptance, pT
+               TH2F                                                            **fHistoMCPi0PtY;                                       //! array of histos with weighted pi0, pT, Y
+               TH2F                                                            **fHistoMCEtaPtY;                                       //! array of histos with weighted eta, pT, Y
+               TH1F                                                            **fHistoMCK0sPt;                                        //! array of histos with weighted K0s, pT
+               TH1F                                                            **fHistoMCK0sWOWeightPt;                        //! array of histos with unweighted K0s, pT
+               TH2F                                                            **fHistoMCK0sPtY;                                       //! array of histos with weighted K0s, pT, Y
+               TH2F                                                            **fHistoMCSecPi0PtvsSource;                     //! array of histos with secondary pi0, pT, source
+               TH1F                                                            **fHistoMCSecPi0Source;                         //! array of histos with secondary pi0, source
+               TH1F                                                            **fHistoMCSecEtaPt;                                     //! array of histos with secondary eta, pT
+               TH1F                                                            **fHistoMCSecEtaSource;                         //! array of histos with secondary eta, source
+               // MC validated reconstructed quantities mesons
+               TH2F                                                            **fHistoTrueMotherInvMassPt;                                    //! array of histos with validated mothers, invMass, pt
+               TH2F                                                            **fHistoTrueMotherCaloPhotonInvMassPt;                  //! array of histos with validated mothers, photon leading, invMass, pt
+               TH2F                                                            **fHistoTrueMotherCaloConvertedPhotonInvMassPt; //! array of histos with validated mothers, converted photon leading, invMass, pt
+               TH2F                                                            **fHistoTrueMotherCaloMixedPhotonConvPhotonInvMassPt; //! array of histos with validated mothers, converted photon leading, invMass, pt
+               TH2F                                                            **fHistoTruePi0CaloConvertedPhotonInvMassPt;    //! array of histos with validated pi0, converted photon leading, invMass, pt
+               TH2F                                                            **fHistoTrueEtaCaloConvertedPhotonInvMassPt;    //! array of histos with validated eta, converted photon leading, invMass, pt
+               TH2F                                                            **fHistoTrueMotherCaloElectronInvMassPt;                //! array of histos with validated mothers, electron leading, invMass, pt
+               TH2F                                                            **fHistoTrueMotherCaloMergedClusterInvMassPt;   //! array of histos with validated mothers, merged cluster invMass, pt
+               TH2F                                                            **fHistoTrueMotherCaloMergedClusterPartConvInvMassPt; //! array of histos with validated mothers, merged cluster part conv, invMass, pt
+               TH2F                                                            **fHistoTruePrimaryMotherInvMassPt;                             //! array of histos with validated weighted primary mothers, invMass, pt
+               TH2F                                                            **fHistoTruePrimaryMotherW0WeightingInvMassPt;  //! array of histos with validated unweighted primary mothers, invMass, pt
+               TProfile2D                                                      **fProfileTruePrimaryMotherWeightsInvMassPt;    //! array of profiles with weights for validated primary mothers, invMass, pt   
+               TH2F                                                            **fHistoTruePrimaryPi0MCPtResolPt;                              //! array of histos with validated weighted primary pi0, MCpt, resol pt
+               TH2F                                                            **fHistoTruePrimaryEtaMCPtResolPt;                              //! array of histos with validated weighted primary eta, MCpt, resol pt
+               TH2F                                                            **fHistoTrueSecondaryMotherInvMassPt;                   //! array of histos with validated secondary mothers, invMass, pt
+               TH2F                                                            **fHistoTrueSecondaryMotherFromK0sInvMassPt;    //! array of histos with validated secondary mothers from K0s, invMass, pt
+               TH1F                                                            **fHistoTrueK0sWithPi0DaughterMCPt;                             //! array of histos with K0s with reconstructed pi0 as daughter, pt
+               TH2F                                                            **fHistoTrueSecondaryMotherFromEtaInvMassPt;    //! array of histos with validated secondary mothers from eta, invMass, pt
+               TH1F                                                            **fHistoTrueEtaWithPi0DaughterMCPt;                             //! array of histos with eta with reconstructed pi0 as daughter, pt
+               TH2F                                                            **fHistoTrueSecondaryMotherFromLambdaInvMassPt; //! array of histos with validated secondary mothers from Lambda, invMass, pt
+               TH1F                                                            **fHistoTrueLambdaWithPi0DaughterMCPt;                  //! array of histos with lambda with reconstructed pi0 as daughter, pt
+               TH2F                                                            **fHistoTrueBckGGInvMassPt;                                             //! array of histos with pure gamma gamma combinatorial BG, invMass, pt
+               TH2F                                                            **fHistoTrueBckContInvMassPt;                                   //! array of histos with contamination BG, invMass, pt
+               TH2F                                                            **fHistoTruePi0PtY;                                                             //! array of histos with validated pi0, pt, Y
+               TH2F                                                            **fHistoTrueEtaPtY;                                                             //! array of histos with validated eta, pt, Y
+               TH2F                                                            **fHistoTruePi0PtAlpha;                                                 //! array of histos with validated pi0, pt, alpha
+               TH2F                                                            **fHistoTrueEtaPtAlpha;                                                 //! array of histos with validated eta, pt, alpha
+               TH2F                                                            **fHistoTruePi0PtOpenAngle;                                             //! array of histos with validated pi0, pt, openAngle
+               TH2F                                                            **fHistoTrueEtaPtOpenAngle;                                             //! array of histos with validated eta, pt, openAngle
+               // MC validated reconstructed quantities photons
+               TH2F                                                            **fHistoClusPhotonBGPt;                                                 //! array of histos with cluster photon BG, pt, source
+               TH2F                                                            **fHistoClusPhotonPlusConvBGPt;                                 //! array of histos with cluster photon plus conv BG, pt, source
+               TH1F                                                            **fHistoTrueClusGammaPt;                                                //! array of histos with validated cluster (electron or photon), pt
+               TH1F                                                            **fHistoTrueClusUnConvGammaPt;                                  //! array of histos with validated unconverted photon, pt
+               TH1F                                                            **fHistoTrueClusUnConvGammaMCPt;                                        //! array of histos with validated unconverted photon, pt
+               TH1F                                                            **fHistoTrueClusElectronPt;                                             //! array of histos with validated electron, pt
+               TH1F                                                            **fHistoTrueClusConvGammaPt;                                    //! array of histos with validated converted photon, pt
+               TH1F                                                            **fHistoTrueClusConvGammaMCPt;                                  //! array of histos with validated converted photon, pt
+               TH1F                                                            **fHistoTrueClusConvGammaFullyPt;                               //! array of histos with validated converted photon, fully contained, pt
+               TH1F                                                            **fHistoTrueClusMergedGammaPt;                                  //! array of histos with validated merged photons, electrons, dalitz, pt
+               TH1F                                                            **fHistoTrueClusMergedPartConvGammaPt;                  //! array of histos with validated merged partially converted photons, pt
+               TH1F                                                            **fHistoTrueClusDalitzPt;                                               //! array of histos with validated Dalitz decay, pt
+               TH1F                                                            **fHistoTrueClusDalitzMergedPt;                                 //! array of histos with validated Dalitz decay, more than one decay product in cluster, pt
+               TH1F                                                            **fHistoTrueClusPhotonFromElecMotherPt;                 //! array of histos with validated photon from electron, pt
+               TH1F                                                            **fHistoTrueClusShowerPt;                                               //! array of histos with validated shower, pt
+        TH1F                                **fHistoTrueClusSubLeadingPt;                   //! array of histos with pi0/eta/eta_prime in subleading contribution
+        TH1I                                **fHistoTrueClusNParticles;                     //! array of histos with number of different particles (pi0/eta/eta_prime) contributing to cluster
+               TH1F                                                            **fHistoTrueClusEMNonLeadingPt;                                 //! array of histos with cluster with largest energy by hadron
+               TH1F                                                            **fHistoTrueNLabelsInClus;                                              //! array of histos with number of labels in cluster 
+               TH1F                                                            **fHistoTruePrimaryClusGammaPt;                                 //! array of histos with validated primary photon cluster, pt
+               TH2F                                                            **fHistoTruePrimaryClusGammaESDPtMCPt;                  //! array of histos with validated primary photon cluster, rec Pt, MC pt
+               TH1F                                                            **fHistoTruePrimaryClusConvGammaPt;                             //! array of histos with validated primary conv photon cluster, pt
+               TH2F                                                            **fHistoTruePrimaryClusConvGammaESDPtMCPt;              //! array of histos with validated primary conv photon cluster, rec Pt, MC pt
+               TH1F                                                            **fHistoTrueSecondaryClusGammaPt;                               //! array of histos with validated secondary cluster photon, pt  
+               TH1F                                                            **fHistoTrueSecondaryClusConvGammaPt;                   //! array of histos with validated secondary cluster photon, pt  
+               TH1F                                                            **fHistoTrueSecondaryClusGammaFromXFromK0sPt;   //! array of histos with validated secondary cluster photon from K0s, pt  
+               TH1F                                                            **fHistoTrueSecondaryClusConvGammaFromXFromK0sPt;//! array of histos with validated secondary cluster conversion photon from K0s, pt  
+               TH1F                                                            **fHistoTrueSecondaryClusGammaFromXFromLambdaPt;//! array of histos with validated secondary cluster photon from Lambda, pt  
+               TH1F                                                            **fHistoTrueSecondaryClusConvGammaFromXFromLambdaPt;//! array of histos with validated secondary cluster conversion photon from Lambda, pt  
+               TH1F                                                            **fHistoTrueSecondaryClusGammaFromXFromEtasPt;  //! array of histos with validated secondary Cluster photon from Eta, pt  
+               TH1F                                                            **fHistoTrueSecondaryClusConvGammaFromXFromEtasPt;//! array of histos with validated secondary cluster conversion photon from Eta, pt  
+
+               // event histograms
+               TH1I                                                            **fHistoNEvents;                                                                //! array of histos with event information
+               TH1I                                                            **fHistoNGoodESDTracks;                                                 //! array of histos with number of good tracks (2010 Standard track cuts)
+               TH1I                                                            **fHistoNGammaCandidates;                                               //! array of histos with number of gamma candidates per event
+               TH2F                                                            **fHistoNGoodESDTracksVsNGammaCanditates;               //! array of histos with number of good tracks vs gamma candidates
+               TH1I                                                            **fHistoNV0Tracks;                                                              //! array of histos with V0 counts
+               TProfile                                                        **fProfileEtaShift;                                                             //! array of profiles with eta shift
+               
+               // additional variables
+               Double_t                                                        fEventPlaneAngle;                                       // EventPlaneAngle
+               TRandom3                                                        fRandom;                                                        // random 
+               Int_t                                                           fnCuts;                                                         // number of cuts to be analysed in parallel
+               Int_t                                                           fiCut;                                                          // current cut  
+               Int_t                                                           fIsHeavyIon;                                            // switch for pp = 0, PbPb = 1, pPb = 2
+               Bool_t                                                          fDoMesonAnalysis;                                       // flag for meson analysis
+               Int_t                                                           fDoMesonQA;                                                     // flag for meson QA
+               Int_t                                                           fDoClusterQA;                                           // flag for cluster QA
+               Bool_t                                                          fIsFromMBHeader;                                        // flag for MC headers
+               Bool_t                                                          fIsMC;                                                          // flag for MC information
+
+
+       private:
+               AliAnalysisTaskGammaCalo(const AliAnalysisTaskGammaCalo&); // Prevent copy-construction
+               AliAnalysisTaskGammaCalo &operator=(const AliAnalysisTaskGammaCalo&); // Prevent assignment
+
+               ClassDef(AliAnalysisTaskGammaCalo, 1);
+};
+
+#endif
index 95ac3ce142dbc0d95d41f9750c7d25d9199aab7e..da015d86114dc5e0cdc393b628a80583b1e10683 100644 (file)
@@ -102,6 +102,7 @@ AliAnalysisTaskGammaConvCalo::AliAnalysisTaskGammaConvCalo(): AliAnalysisTaskSE(
        fCharCatPhoton(0),
        fCharPhotonMCInfo(0),
        fHistoMotherInvMassPt(NULL),
+       fHistoMotherMatchedInvMassPt(NULL),
        fSparseMotherInvMassPtZM(NULL),
        fHistoMotherBackInvMassPt(NULL),
        fSparseMotherBackInvMassPtZM(NULL),
@@ -241,10 +242,7 @@ AliAnalysisTaskGammaConvCalo::AliAnalysisTaskGammaConvCalo(): AliAnalysisTaskSE(
        fDoPhotonQA(0),
        fDoClusterQA(0),
        fIsFromMBHeader(kTRUE),
-       fIsMC(kFALSE),
-       fMinE(0.1),
-       fNminCells(2),
-       fEMCm02cut(0.5)
+       fIsMC(kFALSE)
 {
   
 }
@@ -293,6 +291,7 @@ AliAnalysisTaskGammaConvCalo::AliAnalysisTaskGammaConvCalo(const char *name):
        fCharCatPhoton(0),
        fCharPhotonMCInfo(0),
        fHistoMotherInvMassPt(NULL),
+       fHistoMotherMatchedInvMassPt(NULL),
        fSparseMotherInvMassPtZM(NULL),
        fHistoMotherBackInvMassPt(NULL),
        fSparseMotherBackInvMassPtZM(NULL),
@@ -432,10 +431,7 @@ AliAnalysisTaskGammaConvCalo::AliAnalysisTaskGammaConvCalo(const char *name):
        fDoPhotonQA(0),
        fDoClusterQA(0),
        fIsFromMBHeader(kTRUE),
-       fIsMC(kFALSE),
-       fMinE(0.1),
-       fNminCells(2),
-       fEMCm02cut(0.5)
+       fIsMC(kFALSE)
 {
   // Define output slots here
   DefineOutput(1, TList::Class());
@@ -590,6 +586,7 @@ void AliAnalysisTaskGammaConvCalo::UserCreateOutputObjects(){
        
        if(fDoMesonAnalysis){
                fHistoMotherInvMassPt = new TH2F*[fnCuts];
+               fHistoMotherMatchedInvMassPt = new TH2F*[fnCuts];
                fHistoMotherBackInvMassPt = new TH2F*[fnCuts];
                fHistoMotherInvMassEalpha = new TH2F*[fnCuts];
                if (fDoMesonQA == 2){
@@ -753,6 +750,8 @@ void AliAnalysisTaskGammaConvCalo::UserCreateOutputObjects(){
                if(fDoMesonAnalysis){
                        fHistoMotherInvMassPt[iCut] = new TH2F("ESD_Mother_InvMass_Pt","ESD_Mother_InvMass_Pt",800,0,0.8,250,0,25);
                        fESDList[iCut]->Add(fHistoMotherInvMassPt[iCut]);
+                       fHistoMotherMatchedInvMassPt[iCut] = new TH2F("ESD_MotherMatched_InvMass_Pt","ESD_MotherMatched_InvMass_Pt",800,0,0.8,250,0,25);
+                       fESDList[iCut]->Add(fHistoMotherMatchedInvMassPt[iCut]);
                        fHistoMotherBackInvMassPt[iCut] = new TH2F("ESD_Background_InvMass_Pt","ESD_Background_InvMass_Pt",800,0,0.8,250,0,25);
                        fESDList[iCut]->Add(fHistoMotherBackInvMassPt[iCut]);
                        fHistoMotherInvMassEalpha[iCut] = new TH2F("ESD_Mother_InvMass_vs_E_alpha","ESD_Mother_InvMass_vs_E_alpha",800,0,0.8,250,0,25);
@@ -1421,7 +1420,7 @@ void AliAnalysisTaskGammaConvCalo::ProcessClusters()
        InputEvent()->GetPrimaryVertex()->GetXYZ(vertex);
        
        // Loop over EMCal clusters
-       for(Int_t i = 0; i < nclus; i++){
+       for(Long_t i = 0; i < nclus; i++){
                
                AliVCluster* clus = NULL;
                clus = fInputEvent->GetCaloCluster(i);          
@@ -1440,6 +1439,7 @@ void AliAnalysisTaskGammaConvCalo::ProcessClusters()
                
                // Flag Photon as CaloPhoton
                PhotonCandidate->SetIsCaloPhoton();
+               PhotonCandidate->SetCaloClusterRef(i);
                // get MC label
                if(fIsMC){
                        Int_t* mclabelsCluster = clus->GetLabels();
@@ -2308,92 +2308,104 @@ void AliAnalysisTaskGammaConvCalo::CalculatePi0Candidates(){
                        if (gamma0==NULL) continue;
                        
                        for(Int_t secondGammaIndex=0;secondGammaIndex<fClusterCandidates->GetEntries();secondGammaIndex++){
-
+                               Bool_t matched = kFALSE;
                                AliAODConversionPhoton *gamma1=dynamic_cast<AliAODConversionPhoton*>(fClusterCandidates->At(secondGammaIndex));
                                if (gamma1==NULL) continue;
                                
+                               if (gamma1->GetIsCaloPhoton()){
+                                       AliVCluster* cluster = fInputEvent->GetCaloCluster(gamma1->GetCaloClusterRef());
+                                       matched = ((AliCaloPhotonCuts*)fClusterCutArray->At(fiCut))->MatchConvPhotonToCluster(gamma0,cluster, fInputEvent );
+                               }       
+                               
                                AliAODConversionMother *pi0cand = new AliAODConversionMother(gamma0,gamma1);
                                pi0cand->SetLabels(firstGammaIndex,secondGammaIndex);
                                
+                               
+                               
                                if((((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->MesonIsSelected(pi0cand,kTRUE,((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift()))){
-                                       fHistoMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
-                                       
+                                       if (matched){
+                                               fHistoMotherMatchedInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
+                                       } else {
+                                               fHistoMotherInvMassPt[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
+                                       }       
                                        // fill new histograms
-                                       fHistoPhotonPairAll[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
-                                       fHistoPhotonPairAllGam[fiCut]->Fill(pi0cand->M(),gamma0->Pt());
-                                       
-                                       if(pi0cand->GetAlpha()<0.1)
-                                               fHistoMotherInvMassEalpha[fiCut]->Fill(pi0cand->M(),pi0cand->E());
-                                       
-                                       if (fDoMesonQA > 0){
-                                               if ( pi0cand->M() > 0.05 && pi0cand->M() < 0.17){
-                                                       fHistoMotherPi0PtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
-                                                       fHistoMotherPi0PtAlpha[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetAlpha());
-                                                       fHistoMotherPi0PtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle());      
-                                               }
-                                               if ( pi0cand->M() > 0.45 && pi0cand->M() < 0.65){
-                                                       fHistoMotherEtaPtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
-                                                       fHistoMotherEtaPtAlpha[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetAlpha());
-                                                       fHistoMotherEtaPtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle());
-                                               }
-                                       }
-                                       if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGCalculation()){
-                                               Int_t zbin = 0;
-                                               Int_t mbin = 0;
+                                       if (!matched){
+                                               fHistoPhotonPairAll[fiCut]->Fill(pi0cand->M(),pi0cand->Pt());
+                                               fHistoPhotonPairAllGam[fiCut]->Fill(pi0cand->M(),gamma0->Pt());
                                                
-                                               if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->BackgroundHandlerType() == 0){
-                                                       zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
-                                                       if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
-                                                               mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
-                                                       } else {
-                                                               mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
+                                               if(pi0cand->GetAlpha()<0.1)
+                                                       fHistoMotherInvMassEalpha[fiCut]->Fill(pi0cand->M(),pi0cand->E());
+                                               
+                                               if (fDoMesonQA > 0){
+                                                       if ( pi0cand->M() > 0.05 && pi0cand->M() < 0.17){
+                                                               fHistoMotherPi0PtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
+                                                               fHistoMotherPi0PtAlpha[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetAlpha());
+                                                               fHistoMotherPi0PtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle());      
                                                        }
-                                               } else{
-                                                       zbin = fBGHandlerRP[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
-                                                       if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
-                                                               mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
-                                                       } else {
-                                                               mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
+                                                       if ( pi0cand->M() > 0.45 && pi0cand->M() < 0.65){
+                                                               fHistoMotherEtaPtY[fiCut]->Fill(pi0cand->Pt(),pi0cand->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
+                                                               fHistoMotherEtaPtAlpha[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetAlpha());
+                                                               fHistoMotherEtaPtOpenAngle[fiCut]->Fill(pi0cand->Pt(),pi0cand->GetOpeningAngle());
+                                                       }
+                                               }
+                                               if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->DoBGCalculation()){
+                                                       Int_t zbin = 0;
+                                                       Int_t mbin = 0;
+                                                       
+                                                       if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->BackgroundHandlerType() == 0){
+                                                               zbin = fBGHandler[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
+                                                               if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
+                                                                       mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
+                                                               } else {
+                                                                       mbin = fBGHandler[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
+                                                               }
+                                                       } else{
+                                                               zbin = fBGHandlerRP[fiCut]->GetZBinIndex(fInputEvent->GetPrimaryVertex()->GetZ());
+                                                               if(((AliConversionMesonCuts*)fMesonCutArray->At(fiCut))->UseTrackMultiplicity()){
+                                                                       mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fV0Reader->GetNumberOfPrimaryTracks());
+                                                               } else {
+                                                                       mbin = fBGHandlerRP[fiCut]->GetMultiplicityBinIndex(fGammaCandidates->GetEntries());
+                                                               }
                                                        }
+                                                       Double_t sparesFill[4] = {pi0cand->M(),pi0cand->Pt(),(Double_t)zbin,(Double_t)mbin};
+                                                       fSparseMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
                                                }
-                                               Double_t sparesFill[4] = {pi0cand->M(),pi0cand->Pt(),(Double_t)zbin,(Double_t)mbin};
-                                               fSparseMotherInvMassPtZM[fiCut]->Fill(sparesFill,1);
                                        }
                                        
-                                       
                                        if(fIsMC){
                                                if(fInputEvent->IsA()==AliESDEvent::Class())
-                                                       ProcessTrueMesonCandidates(pi0cand,gamma0,gamma1);
+                                                       ProcessTrueMesonCandidates(pi0cand,gamma0,gamma1, matched);
                                                if(fInputEvent->IsA()==AliAODEvent::Class())
-                                                       ProcessTrueMesonCandidatesAOD(pi0cand,gamma0,gamma1);
+                                                       ProcessTrueMesonCandidatesAOD(pi0cand,gamma0,gamma1, matched);
                                        }
-                                       if (fDoMesonQA == 2){
-                                               fInvMass = pi0cand->M();
-                                               fPt  = pi0cand->Pt();
-                                               if (abs(gamma0->GetDCAzToPrimVtx()) < abs(gamma1->GetDCAzToPrimVtx())){
-                                                       fDCAzGammaMin = gamma0->GetDCAzToPrimVtx();
-                                                       fDCAzGammaMax = gamma1->GetDCAzToPrimVtx();
-                                               } else {
-                                                       fDCAzGammaMin = gamma1->GetDCAzToPrimVtx();
-                                                       fDCAzGammaMax = gamma0->GetDCAzToPrimVtx();
+                                       if (!matched){
+                                               if (fDoMesonQA == 2){
+                                                       fInvMass = pi0cand->M();
+                                                       fPt  = pi0cand->Pt();
+                                                       if (abs(gamma0->GetDCAzToPrimVtx()) < abs(gamma1->GetDCAzToPrimVtx())){
+                                                               fDCAzGammaMin = gamma0->GetDCAzToPrimVtx();
+                                                               fDCAzGammaMax = gamma1->GetDCAzToPrimVtx();
+                                                       } else {
+                                                               fDCAzGammaMin = gamma1->GetDCAzToPrimVtx();
+                                                               fDCAzGammaMax = gamma0->GetDCAzToPrimVtx();
+                                                       }
+                                                       fCharFlag = pi0cand->GetMesonQuality();
+                                                       //                   cout << "gamma 0: " << gamma0->GetV0Index()<< "\t" << gamma0->GetPx() << "\t" << gamma0->GetPy() << "\t" <<  gamma0->GetPz() << "\t" << endl;
+                                                       //                   cout << "gamma 1: " << gamma1->GetV0Index()<< "\t"<< gamma1->GetPx() << "\t" << gamma1->GetPy() << "\t" <<  gamma1->GetPz() << "\t" << endl;
+                                                       //                    cout << "pi0: "<<fInvMass << "\t" << fPt <<"\t" << fDCAzGammaMin << "\t" << fDCAzGammaMax << "\t" << (Int_t)fCharFlag << "\t" << (Int_t)fCharMesonMCInfo <<endl;
+                                                       if (fIsHeavyIon == 1 && fPt > 0.399 && fPt < 20. ) {
+                                                               if (fInvMass > 0.08 && fInvMass < 0.2) fTreeMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
+                                                               if ((fInvMass > 0.45 && fInvMass < 0.6) &&  (fPt > 0.999 && fPt < 20.) )fTreeMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
+                                                       } else if (fPt > 0.299 && fPt < 20. )  {
+                                                               if ( (fInvMass > 0.08 && fInvMass < 0.2) || (fInvMass > 0.45 && fInvMass < 0.6)) fTreeMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
+                                                       }
                                                }
-                                               fCharFlag = pi0cand->GetMesonQuality();
-                                               //                   cout << "gamma 0: " << gamma0->GetV0Index()<< "\t" << gamma0->GetPx() << "\t" << gamma0->GetPy() << "\t" <<  gamma0->GetPz() << "\t" << endl;
-                                               //                   cout << "gamma 1: " << gamma1->GetV0Index()<< "\t"<< gamma1->GetPx() << "\t" << gamma1->GetPy() << "\t" <<  gamma1->GetPz() << "\t" << endl;
-                                               //                    cout << "pi0: "<<fInvMass << "\t" << fPt <<"\t" << fDCAzGammaMin << "\t" << fDCAzGammaMax << "\t" << (Int_t)fCharFlag << "\t" << (Int_t)fCharMesonMCInfo <<endl;
-                                               if (fIsHeavyIon == 1 && fPt > 0.399 && fPt < 20. ) {
-                                                       if (fInvMass > 0.08 && fInvMass < 0.2) fTreeMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
-                                                       if ((fInvMass > 0.45 && fInvMass < 0.6) &&  (fPt > 0.999 && fPt < 20.) )fTreeMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
-                                               } else if (fPt > 0.299 && fPt < 20. )  {
-                                                       if ( (fInvMass > 0.08 && fInvMass < 0.2) || (fInvMass > 0.45 && fInvMass < 0.6)) fTreeMesonsInvMassPtDcazMinDcazMaxFlag[fiCut]->Fill();
+                                               if (fDoMesonQA == 1){
+                                                       fHistoMotherInvMassECalib[fiCut]->Fill(pi0cand->M(),gamma1->E());
+                                                       if(pi0cand->GetAlpha()<0.1)
+                                                       fHistoMotherInvMassECalibalpha[fiCut]->Fill(pi0cand->M(),gamma1->E());            
                                                }
                                        }
-                                       if (fDoMesonQA == 1){
-                                               fHistoMotherInvMassECalib[fiCut]->Fill(pi0cand->M(),gamma1->E());
-                                               if(pi0cand->GetAlpha()<0.1)
-                                               fHistoMotherInvMassECalibalpha[fiCut]->Fill(pi0cand->M(),gamma1->E());            
-                                       }
-
                                }
                                delete pi0cand;
                                pi0cand=0x0;
@@ -2402,7 +2414,7 @@ void AliAnalysisTaskGammaConvCalo::CalculatePi0Candidates(){
        }
 }
 //______________________________________________________________________
-void AliAnalysisTaskGammaConvCalo::ProcessTrueMesonCandidates(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1)
+void AliAnalysisTaskGammaConvCalo::ProcessTrueMesonCandidates(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1, Bool_t matched)
 {
        // Process True Mesons
        AliStack *MCStack = fMCEvent->Stack();
@@ -2457,89 +2469,94 @@ void AliAnalysisTaskGammaConvCalo::ProcessTrueMesonCandidates(AliAODConversionMo
                }
                
                if(isTruePi0 || isTrueEta){// True Pion or Eta
-                       fHistoTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                       if (!matched)fHistoTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
                        if (fDoMesonQA > 0){
-                               if (TrueGammaCandidate1->IsLargestComponentPhoton()) 
+                               if (TrueGammaCandidate1->IsLargestComponentPhoton() && !matched
                                        fHistoTrueMotherCaloPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
-                               if (TrueGammaCandidate1->IsLargestComponentElectron()) 
+                               if (TrueGammaCandidate1->IsLargestComponentElectron() && !matched
                                        fHistoTrueMotherCaloElectronInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
-                               if (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()){
-                                       fHistoTrueMotherCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
-                                       if (isTruePi0)fHistoTruePi0CaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
-                                       if (isTrueEta)fHistoTrueEtaCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
-                                       if ((TrueGammaCandidate0->GetMCLabelPositive() == gamma1MCLabel || TrueGammaCandidate0->GetMCLabelNegative() == gamma1MCLabel) && isTruePi0)
+                               if (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion() ){
+                                       if (!matched)fHistoTrueMotherCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                                       if (isTruePi0 && !matched)fHistoTruePi0CaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                                       if (isTrueEta && !matched)fHistoTrueEtaCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                                       if ((TrueGammaCandidate0->GetMCLabelPositive() == gamma1MCLabel || TrueGammaCandidate0->GetMCLabelNegative() == gamma1MCLabel) && isTruePi0){
                                                fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
-                                       if ((TrueGammaCandidate0->GetMCLabelPositive() == gamma1MCLabel || TrueGammaCandidate0->GetMCLabelNegative() == gamma1MCLabel) && isTrueEta)
+                                       }       
+                                       if ((TrueGammaCandidate0->GetMCLabelPositive() == gamma1MCLabel || TrueGammaCandidate0->GetMCLabelNegative() == gamma1MCLabel) && isTrueEta){
                                                fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                                       }       
                                }       
-                               if (TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate1->IsDalitzMerged() )
+                               if ((TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate1->IsDalitzMerged()) && !matched )
                                        fHistoTrueMotherCaloMergedClusterInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
-                               if (TrueGammaCandidate1->IsMergedPartConv()) 
+                               if (TrueGammaCandidate1->IsMergedPartConv() && !matched
                                        fHistoTrueMotherCaloMergedClusterPartConvInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
                        }
-                       if (fDoMesonQA > 0){
-                               if (isTruePi0){
-                                       if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
-                                               fHistoTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
-                                               fHistoTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetAlpha());
-                                               fHistoTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
-                                       }
-                               } else if (isTrueEta){
-                                       if ( Pi0Candidate->M() > 0.45 && Pi0Candidate->M() < 0.65){
-                                               fHistoTrueEtaPtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
-                                               fHistoTrueEtaPtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetAlpha());
-                                               fHistoTrueEtaPtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
+                       if (!matched){
+                               if (fDoMesonQA > 0){
+                                       if (isTruePi0){
+                                               if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
+                                                       fHistoTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
+                                                       fHistoTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetAlpha());
+                                                       fHistoTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
+                                               }
+                                       } else if (isTrueEta){
+                                               if ( Pi0Candidate->M() > 0.45 && Pi0Candidate->M() < 0.65){
+                                                       fHistoTrueEtaPtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
+                                                       fHistoTrueEtaPtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetAlpha());
+                                                       fHistoTrueEtaPtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
+                                               }
                                        }
                                }
-                       }
-                       if(gamma0MotherLabel >= MCStack->GetNprimary()){ // Secondary Meson
-                               Int_t secMotherLabel = ((TParticle*)MCStack->Particle(gamma0MotherLabel))->GetMother(0);
-                               Float_t weightedSec= 1;
-                               if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, fMCStack, fInputEvent) && MCStack->Particle(secMotherLabel)->GetPdgCode()==310){
-                                       weightedSec= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),secMotherLabel, fMCStack, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
-                                       //cout << "MC input \t"<<i << "\t" <<  particle->Pt()<<"\t"<<weighted << endl;
-                               }
-                               fHistoTrueSecondaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
-                               fCharMesonMCInfo = 2;
-                               if (secMotherLabel >-1){
-                                       if(MCStack->Particle(secMotherLabel)->GetPdgCode()==310){
-                                               fCharMesonMCInfo = 4;
-                                               fHistoTrueSecondaryMotherFromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
-                                               if (fDoMesonQA > 0)fHistoTrueK0sWithPi0DaughterMCPt[fiCut]->Fill(MCStack->Particle(secMotherLabel)->Pt());
-                                       }
-                                       if(MCStack->Particle(secMotherLabel)->GetPdgCode()==221){
-                                               fCharMesonMCInfo = 3;
-                                               fHistoTrueSecondaryMotherFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
-                                               if (fDoMesonQA > 0)fHistoTrueEtaWithPi0DaughterMCPt[fiCut]->Fill(MCStack->Particle(secMotherLabel)->Pt());
-                                       }
-                                       if(MCStack->Particle(secMotherLabel)->GetPdgCode()==3122){
-                                               fCharMesonMCInfo = 7;
-                                               fHistoTrueSecondaryMotherFromLambdaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
-                                               if (fDoMesonQA > 0)fHistoTrueLambdaWithPi0DaughterMCPt[fiCut]->Fill(MCStack->Particle(secMotherLabel)->Pt());
+                               
+                               if(gamma0MotherLabel >= MCStack->GetNprimary()){ // Secondary Meson
+                                       Int_t secMotherLabel = ((TParticle*)MCStack->Particle(gamma0MotherLabel))->GetMother(0);
+                                       Float_t weightedSec= 1;
+                                       if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, fMCStack, fInputEvent) && MCStack->Particle(secMotherLabel)->GetPdgCode()==310){
+                                               weightedSec= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),secMotherLabel, fMCStack, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
+                                               //cout << "MC input \t"<<i << "\t" <<  particle->Pt()<<"\t"<<weighted << endl;
                                        }
-                               }
-                       } else { // Only primary pi0 for efficiency calculation
-                               fCharMesonMCInfo = 6;
-                               Float_t weighted= 1;
-                               if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, fMCStack, fInputEvent)){
-                                       if (((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt()>0.005){
-                                               weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),gamma1MotherLabel, fMCStack, fInputEvent);
-                                               //                      cout << "rec \t " <<gamma1MotherLabel << "\t" <<  weighted << endl;
+                                       fHistoTrueSecondaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+                                       fCharMesonMCInfo = 2;
+                                       if (secMotherLabel >-1){
+                                               if(MCStack->Particle(secMotherLabel)->GetPdgCode()==310){
+                                                       fCharMesonMCInfo = 4;
+                                                       fHistoTrueSecondaryMotherFromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+                                                       if (fDoMesonQA > 0)fHistoTrueK0sWithPi0DaughterMCPt[fiCut]->Fill(MCStack->Particle(secMotherLabel)->Pt());
+                                               }
+                                               if(MCStack->Particle(secMotherLabel)->GetPdgCode()==221){
+                                                       fCharMesonMCInfo = 3;
+                                                       fHistoTrueSecondaryMotherFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+                                                       if (fDoMesonQA > 0)fHistoTrueEtaWithPi0DaughterMCPt[fiCut]->Fill(MCStack->Particle(secMotherLabel)->Pt());
+                                               }
+                                               if(MCStack->Particle(secMotherLabel)->GetPdgCode()==3122){
+                                                       fCharMesonMCInfo = 7;
+                                                       fHistoTrueSecondaryMotherFromLambdaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+                                                       if (fDoMesonQA > 0)fHistoTrueLambdaWithPi0DaughterMCPt[fiCut]->Fill(MCStack->Particle(secMotherLabel)->Pt());
+                                               }
                                        }
-                               }
-                               fHistoTruePrimaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
-                               fHistoTruePrimaryMotherW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
-                               fProfileTruePrimaryMotherWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
-                                       
-                               if (fDoMesonQA > 0){
-                                       if(isTruePi0){ // Only primary pi0 for resolution
-                                               fHistoTruePrimaryPi0MCPtResolPt[fiCut]->Fill(((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt())/((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),weighted);
+                               } else { // Only primary pi0 for efficiency calculation
+                                       fCharMesonMCInfo = 6;
+                                       Float_t weighted= 1;
+                                       if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, fMCStack, fInputEvent)){
+                                               if (((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt()>0.005){
+                                                       weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),gamma1MotherLabel, fMCStack, fInputEvent);
+                                                       //                      cout << "rec \t " <<gamma1MotherLabel << "\t" <<  weighted << endl;
+                                               }
                                        }
-                                       if (isTrueEta){ // Only primary eta for resolution
-                                               fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt())/((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),weighted);
+                                       fHistoTruePrimaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
+                                       fHistoTruePrimaryMotherW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                                       fProfileTruePrimaryMotherWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
+                                               
+                                       if (fDoMesonQA > 0){
+                                               if(isTruePi0){ // Only primary pi0 for resolution
+                                                       fHistoTruePrimaryPi0MCPtResolPt[fiCut]->Fill(((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt())/((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),weighted);
+                                               }
+                                               if (isTrueEta){ // Only primary eta for resolution
+                                                       fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),(Pi0Candidate->Pt()-((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt())/((TParticle*)MCStack->Particle(gamma1MotherLabel))->Pt(),weighted);
+                                               }
                                        }
                                }
-                       }
+                       }       
                } else if(!isTruePi0 && !isTrueEta){ // Background
                        if (fDoMesonQA > 0){
                                if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
@@ -2553,7 +2570,7 @@ void AliAnalysisTaskGammaConvCalo::ProcessTrueMesonCandidates(AliAODConversionMo
        }
 }
 //______________________________________________________________________
-void AliAnalysisTaskGammaConvCalo::ProcessTrueMesonCandidatesAOD(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1)
+void AliAnalysisTaskGammaConvCalo::ProcessTrueMesonCandidatesAOD(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1, Bool_t matched)
 {
        
        // Process True Mesons
@@ -2618,93 +2635,95 @@ void AliAnalysisTaskGammaConvCalo::ProcessTrueMesonCandidatesAOD(AliAODConversio
        }
        
        if(isTruePi0 || isTrueEta){// True Pion or Eta
-               fHistoTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+               if (!matched)fHistoTrueMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
                if (fDoMesonQA > 0){
-                       if (TrueGammaCandidate1->IsLargestComponentPhoton()) 
+                       if (TrueGammaCandidate1->IsLargestComponentPhoton() && !matched
                                fHistoTrueMotherCaloPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
-                       if (TrueGammaCandidate1->IsLargestComponentElectron()) 
+                       if (TrueGammaCandidate1->IsLargestComponentElectron() && !matched
                                fHistoTrueMotherCaloElectronInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
                        if (TrueGammaCandidate1->IsLargestComponentElectron() && TrueGammaCandidate1->IsConversion()){
-                               fHistoTrueMotherCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
-                               if (isTruePi0)fHistoTruePi0CaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
-                               if (isTrueEta)fHistoTrueEtaCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                               if (!matched)fHistoTrueMotherCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                               if (isTruePi0 && !matched)fHistoTruePi0CaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                               if (isTrueEta && !matched)fHistoTrueEtaCaloConvertedPhotonInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
                                if ((TrueGammaCandidate0->GetMCLabelPositive() == gamma1MCLabel || TrueGammaCandidate0->GetMCLabelNegative() == gamma1MCLabel) && isTruePi0)
                                        fHistoTruePi0CaloConvertedPhotonMatchedInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
                                if ((TrueGammaCandidate0->GetMCLabelPositive() == gamma1MCLabel || TrueGammaCandidate0->GetMCLabelNegative() == gamma1MCLabel) && isTrueEta)
                                        fHistoTrueEtaCaloConvertedPhotonMatchedInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
                        }       
-                       if (TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate1->IsDalitzMerged() )
+                       if ((TrueGammaCandidate1->IsMerged() || TrueGammaCandidate1->IsMergedPartConv() || TrueGammaCandidate1->IsDalitzMerged()) && !matched )
                                fHistoTrueMotherCaloMergedClusterInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
-                       if (TrueGammaCandidate1->IsMergedPartConv()) 
+                       if (TrueGammaCandidate1->IsMergedPartConv() && !matched
                                fHistoTrueMotherCaloMergedClusterPartConvInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
                }
 
-               if (fDoMesonQA > 0){
-                       if (isTruePi0){
-                               if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
-                               fHistoTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
-                               fHistoTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetAlpha());
-                               fHistoTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
-                               }
-                       } else if (isTrueEta){
-                               if ( Pi0Candidate->M() > 0.45 && Pi0Candidate->M() < 0.65){
-                               fHistoTrueEtaPtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
-                               fHistoTrueEtaPtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetAlpha());
-                               fHistoTrueEtaPtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
+               if ( !matched){
+                       if (fDoMesonQA > 0){
+                               if (isTruePi0){
+                                       if ( Pi0Candidate->M() > 0.05 && Pi0Candidate->M() < 0.17){
+                                       fHistoTruePi0PtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
+                                       fHistoTruePi0PtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetAlpha());
+                                       fHistoTruePi0PtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
+                                       }
+                               } else if (isTrueEta){
+                                       if ( Pi0Candidate->M() > 0.45 && Pi0Candidate->M() < 0.65){
+                                       fHistoTrueEtaPtY[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->Rapidity()-((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetEtaShift());
+                                       fHistoTrueEtaPtAlpha[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetAlpha());
+                                       fHistoTrueEtaPtOpenAngle[fiCut]->Fill(Pi0Candidate->Pt(),Pi0Candidate->GetOpeningAngle());
+                                       }
                                }
                        }
-               }
-               if(!(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel))->IsPrimary())){ // Secondary Meson
-                       Int_t secMotherLabel = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetMother();
-                       Float_t weightedSec= 1;
-                       if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, 0x0, fInputEvent) && static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
-                               weightedSec= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),secMotherLabel, 0x0, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
-                               //cout << "MC input \t"<<i << "\t" <<  particle->Pt()<<"\t"<<weighted << endl;
-                       }
-                       fHistoTrueSecondaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
-                       fCharMesonMCInfo = 2;
-                       if (secMotherLabel >-1){
-                               if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
-                                       fCharMesonMCInfo = 4;
-                                       fHistoTrueSecondaryMotherFromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
-                                       if (fDoMesonQA > 0)fHistoTrueK0sWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
-                               }
-                               if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==221){
-                                       fCharMesonMCInfo = 3;
-                                       fHistoTrueSecondaryMotherFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
-                                       if (fDoMesonQA > 0)fHistoTrueEtaWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
+                       if(!(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma0MotherLabel))->IsPrimary())){ // Secondary Meson
+                               Int_t secMotherLabel = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->GetMother();
+                               Float_t weightedSec= 1;
+                               if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(secMotherLabel, 0x0, fInputEvent) && static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
+                                       weightedSec= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),secMotherLabel, 0x0, fInputEvent)/2.; //invariant mass is additive thus the weight for the daughters has to be devide by two for the K0s at a certain pt
+                                       //cout << "MC input \t"<<i << "\t" <<  particle->Pt()<<"\t"<<weighted << endl;
                                }
-                               if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==3122){
-                                       fCharMesonMCInfo = 7;
-                                       fHistoTrueSecondaryMotherFromLambdaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
-                                       if (fDoMesonQA > 0)fHistoTrueLambdaWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
+                               fHistoTrueSecondaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+                               fCharMesonMCInfo = 2;
+                               if (secMotherLabel >-1){
+                                       if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==310){
+                                               fCharMesonMCInfo = 4;
+                                               fHistoTrueSecondaryMotherFromK0sInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+                                               if (fDoMesonQA > 0)fHistoTrueK0sWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
+                                       }
+                                       if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==221){
+                                               fCharMesonMCInfo = 3;
+                                               fHistoTrueSecondaryMotherFromEtaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+                                               if (fDoMesonQA > 0)fHistoTrueEtaWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
+                                       }
+                                       if(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->GetPdgCode()==3122){
+                                               fCharMesonMCInfo = 7;
+                                               fHistoTrueSecondaryMotherFromLambdaInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weightedSec);
+                                               if (fDoMesonQA > 0)fHistoTrueLambdaWithPi0DaughterMCPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(secMotherLabel))->Pt());
+                                       }
                                }
-                       }
-               }else{ // Only primary pi0 for efficiency calculation
-                       Float_t weighted= 1;
-                       fCharMesonMCInfo = 6;
-                       if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, 0x0, fInputEvent)){
-                               if (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt()>0.005){
-                               weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),gamma1MotherLabel, 0x0, fInputEvent);
-                               //                      cout << "rec \t " <<gamma1MotherLabel << "\t" <<  weighted << endl;
+                       } else{ // Only primary pi0 for efficiency calculation
+                               Float_t weighted= 1;
+                               fCharMesonMCInfo = 6;
+                               if(((AliConvEventCuts*)fEventCutArray->At(fiCut))->IsParticleFromBGEvent(gamma1MotherLabel, 0x0, fInputEvent)){
+                                       if (static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt()>0.005){
+                                       weighted= ((AliConvEventCuts*)fEventCutArray->At(fiCut))->GetWeightForMeson(fV0Reader->GetPeriodName(),gamma1MotherLabel, 0x0, fInputEvent);
+                                       //                      cout << "rec \t " <<gamma1MotherLabel << "\t" <<  weighted << endl;
+                                       }
                                }
-                       }
-                       fHistoTruePrimaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
-                       fHistoTruePrimaryMotherW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
-                       fProfileTruePrimaryMotherWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
-                       
-                       if (fDoMesonQA > 0){
-                               if(isTruePi0){ // Only primary pi0 for resolution
-                                       fHistoTruePrimaryPi0MCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
-                                                                                                                       (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted);
+                               fHistoTruePrimaryMotherInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
+                               fHistoTruePrimaryMotherW0WeightingInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt());
+                               fProfileTruePrimaryMotherWeightsInvMassPt[fiCut]->Fill(Pi0Candidate->M(),Pi0Candidate->Pt(),weighted);
                                
-                               }
-                               if (isTrueEta){ // Only primary eta for resolution
-                                       fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
-                                                                                                                       (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted);
+                               if (fDoMesonQA > 0){
+                                       if(isTruePi0){ // Only primary pi0 for resolution
+                                               fHistoTruePrimaryPi0MCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
+                                                                                                                               (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted);
+                                       
+                                       }
+                                       if (isTrueEta){ // Only primary eta for resolution
+                                               fHistoTruePrimaryEtaMCPtResolPt[fiCut]->Fill(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),
+                                                                                                                               (Pi0Candidate->Pt()-static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt())/static_cast<AliAODMCParticle*>(AODMCTrackArray->At(gamma1MotherLabel))->Pt(),weighted);
+                                       }
                                }
                        }
-               }
+               }       
        } else if(!isTruePi0 && !isTrueEta) { // Background
                if (fDoMesonQA > 0){
                        if(gamma0MotherLabel>-1 && gamma1MotherLabel>-1){ // Both Tracks are Photons and have a mother but not Pi0 or Eta
@@ -3052,30 +3071,3 @@ Int_t AliAnalysisTaskGammaConvCalo::GetSourceClassification(Int_t daughter, Int_
        return 15;
   
 }
-
-// //________________________________________________________________________
-// Double_t AliAnalysisTaskGammaConvCalo::GetMaxCellEnergy(const AliVCluster *cluster, Short_t &id) const
-// {
-//   // Get maximum energy of attached cell.
-//   
-//   id = -1;
-//   Double_t maxe = 0;
-//   Int_t ncells = cluster->GetNCells();
-//   if (fEsdCells) {
-//     for (Int_t i=0; i<ncells; i++) {
-//       Double_t e = fEsdCells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
-//       if (e>maxe) {
-//         maxe = e;
-//         id   = cluster->GetCellAbsId(i);
-//       }
-//     }
-//   } else {
-//     for (Int_t i=0; i<ncells; i++) {
-//       Double_t e = fAodCells->GetCellAmplitude(TMath::Abs(cluster->GetCellAbsId(i)));
-//       if (e>maxe)
-//         maxe = e;
-//       id   = cluster->GetCellAbsId(i);
-//     }
-//   }
-//   return maxe;
-// }
index 61c62213f5d09207219479a8a6ce4c2d819702b5..c3c13d76d9217fa890976d53a145827333bd3ce9 100644 (file)
@@ -48,8 +48,8 @@ class AliAnalysisTaskGammaConvCalo : public AliAnalysisTaskSE {
                void ProcessTrueClusterCandidates( AliAODConversionPhoton* TruePhotonCandidate);
                void ProcessTrueClusterCandidatesAOD( AliAODConversionPhoton* TruePhotonCandidate);
                void ProcessTruePhotonCandidatesAOD( AliAODConversionPhoton* TruePhotonCandidate);
-               void ProcessTrueMesonCandidates( AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1);
-               void ProcessTrueMesonCandidatesAOD(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1);
+               void ProcessTrueMesonCandidates( AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1, Bool_t matched);
+               void ProcessTrueMesonCandidatesAOD(AliAODConversionMother *Pi0Candidate, AliAODConversionPhoton *TrueGammaCandidate0, AliAODConversionPhoton *TrueGammaCandidate1, Bool_t matched);
                
                // switches for additional analysis streams or outputs
                void SetDoMesonAnalysis(Bool_t flag){fDoMesonAnalysis = flag;}
@@ -81,10 +81,6 @@ class AliAnalysisTaskGammaConvCalo : public AliAnalysisTaskSE {
                        fMesonCutArray = CutArray;
                }
 
-               // emcal functions
-               Double_t GetMaxCellEnergy(const AliVCluster *c) const { Short_t id=-1; return GetMaxCellEnergy(c,id); }
-               Double_t GetMaxCellEnergy(const AliVCluster *c, Short_t &id) const;
-
                // BG HandlerSettings
                void CalculateBackground();
                void CalculateBackgroundRP();
@@ -157,6 +153,7 @@ class AliAnalysisTaskGammaConvCalo : public AliAnalysisTaskSE {
                                                                                        // 6: primary gamma
                //histograms for mesons reconstructed quantities
                TH2F                                                            **fHistoMotherInvMassPt;                        //! array of histogram with signal + BG for same event photon pairs, inv Mass, pt
+               TH2F                                                            **fHistoMotherMatchedInvMassPt;         //! array of histogram with signal + BG for same event photon pairs, inv Mass, pt
                THnSparseF                                                      **fSparseMotherInvMassPtZM;                     //! array of THnSparseF with signal + BG for same event photon pairs, inv Mass, pt
                TH2F                                                            **fHistoMotherBackInvMassPt;            //! array of histogram with BG for mixed event photon pairs, inv Mass, pt
                THnSparseF                                                      **fSparseMotherBackInvMassPtZM;         //! array of THnSparseF with BG for same event photon pairs, inv Mass, pt
@@ -316,19 +313,6 @@ class AliAnalysisTaskGammaConvCalo : public AliAnalysisTaskSE {
                Bool_t                                                          fIsFromMBHeader;                                        // flag for MC headers
                Bool_t                                                          fIsMC;                                                          // flag for MC information
 
-
-               // cluster cut variables
-               Double_t                                                        fMinE;
-               Int_t                                                           fNminCells;
-               Double_t                                                        fEMCm02cut;
-               //double                                                        fMinErat = 0;
-               //double                                                        fMinEcc = 0;
-
-               
-               //  TString                                                      fClusName;                                                     // cluster branch name (def="")
-               //  const TObjArray                                     *fRecPoints;                                            // pointer to rec points (AliAnalysisTaskEMCALClusterizeFast)
-               //  const TClonesArray                          *fDigits;                                                       // pointer to digits     (AliAnalysisTaskEMCALClusterizeFast)
-
        private:
                AliAnalysisTaskGammaConvCalo(const AliAnalysisTaskGammaConvCalo&); // Prevent copy-construction
                AliAnalysisTaskGammaConvCalo &operator=(const AliAnalysisTaskGammaConvCalo&); // Prevent assignment
index 075171b0122516458be931a9a761d1e420dcbb27..88e1fee281dafdd5c51db86c22fdfa3a48c6c691 100644 (file)
@@ -257,9 +257,9 @@ AliAnalysisTaskNeutralMesonToPiPlPiMiPiZero::~AliAnalysisTaskNeutralMesonToPiPlP
 void AliAnalysisTaskNeutralMesonToPiPlPiMiPiZero::InitBack(){
 
        const Int_t nDim = 4;
-       Int_t nBins[nDim] = {450,250,7,4};
-       Double_t xMin[nDim] = {0.3,0, 0,0};
-       Double_t xMax[nDim] = {0.75,25,7,4};
+       Int_t nBins[nDim] = {500,250,7,4};
+       Double_t xMin[nDim] = {0.4,0, 0,0};
+       Double_t xMax[nDim] = {0.9,25,7,4};
        
        fTHnSparseMotherInvMassPtZM = new THnSparseF*[fnCuts];
        fTHnSparseMotherBackInvMassPtZM = new THnSparseF*[fnCuts];
index 52ea0620f6e0557dd263078dbcc51830313905a8..f493604a5049c5f00d78f9dbbaf4a5e6ea868ebd 100644 (file)
@@ -30,6 +30,7 @@
 #include "TF1.h"
 #include "AliStack.h"
 #include "AliAODConversionMother.h"
+#include "AliAODConversionPhoton.h"
 #include "TObjString.h"
 #include "AliAODEvent.h"
 #include "AliESDEvent.h"
@@ -41,6 +42,7 @@
 #include "AliAODMCParticle.h"
 #include "AliAODMCHeader.h"
 #include "AliPicoTrack.h"
+#include "AliEMCALRecoUtils.h"
 
 class iostream;
 
@@ -325,187 +327,48 @@ void AliCaloPhotonCuts::InitCutHistograms(TString name){
        TH1::AddDirectory(kTRUE);
 }
 
-/*
+
 ///________________________________________________________________________
-Bool_t AliCaloPhotonCuts::ClusterIsSelectedMC(TParticle *particle,AliStack *fMCStack,Bool_t checkForConvertedGamma){
+Bool_t AliCaloPhotonCuts::ClusterIsSelectedMC(TParticle *particle,AliStack *fMCStack){
    // MonteCarlo Photon Selection
 
-   if(!fMCStack)return kFALSE;
-
-   if (particle->GetPdgCode() == 22){
-
-
-     if( particle->Eta() > (fEtaCut) || particle->Eta() < (-fEtaCut) )
-         return kFALSE;
-      if(fEtaCutMin>-0.1){
-         if( particle->Eta() < (fEtaCutMin) && particle->Eta() > (-fEtaCutMin) )
-            return kFALSE;
-      }
-
-      if(particle->GetMother(0) >-1 && fMCStack->Particle(particle->GetMother(0))->GetPdgCode() == 22){
-         return kFALSE; // no photon as mothers!
-      }
-
-      if(particle->GetMother(0) >= fMCStack->GetNprimary()){
-         return kFALSE; // the gamma has a mother, and it is not a primary particle
-      }
-
-      if(!checkForConvertedGamma) return kTRUE; // return in case of accepted gamma
-
-      // looking for conversion gammas (electron + positron from pairbuilding (= 5) )
-      TParticle* ePos = NULL;
-      TParticle* eNeg = NULL;
-
-      if(particle->GetNDaughters() >= 2){
-         for(Int_t daughterIndex=particle->GetFirstDaughter();daughterIndex<=particle->GetLastDaughter();daughterIndex++){
-            TParticle *tmpDaughter = fMCStack->Particle(daughterIndex);
-            if(tmpDaughter->GetUniqueID() == 5){
-               if(tmpDaughter->GetPdgCode() == 11){
-                  eNeg = tmpDaughter;
-               } else if(tmpDaughter->GetPdgCode() == -11){
-                  ePos = tmpDaughter;
-               }
-            }
-         }
-      }
-
-      if(ePos == NULL || eNeg == NULL){ // means we do not have two daughters from pair production
-         return kFALSE;
-      }
-
-      if(ePos->Pt()<fSinglePtCut || eNeg->Pt()<fSinglePtCut){
-         return kFALSE; // no reconstruction below the Pt cut
-      }
-
-      if( ePos->Eta() > (fEtaCut) || ePos->Eta() < (-fEtaCut) ||
-          eNeg->Eta() > (fEtaCut) || eNeg->Eta() < (-fEtaCut) )
-         return kFALSE;
-
-      if(fEtaCutMin > -0.1){
-         if( (ePos->Eta() < (fEtaCutMin) && ePos->Eta() > (-fEtaCutMin)) ||
-             (eNeg->Eta() < (fEtaCutMin) && eNeg->Eta() > (-fEtaCutMin)) )
-            return kFALSE;
-      }
-
-      if(ePos->R()>fMaxR){
-         return kFALSE; // cuts on distance from collision point
-      }
-
-      if(abs(ePos->Vz()) > fMaxZ){
-         return kFALSE;  // outside material
-      }
-      if(abs(eNeg->Vz()) > fMaxZ){
-         return kFALSE;  // outside material
-      }
-
-      if( ePos->R() <= ((abs(ePos->Vz()) * fLineCutZRSlope) - fLineCutZValue)){
-         return kFALSE;  // line cut to exclude regions where we do not reconstruct
-      } else if ( fEtaCutMin != -0.1 &&   ePos->R() >= ((abs(ePos->Vz()) * fLineCutZRSlopeMin) - fLineCutZValueMin)){
-         return kFALSE;
-      }
-
-      if( eNeg->R() <= ((abs(eNeg->Vz()) * fLineCutZRSlope) - fLineCutZValue)){
-         return kFALSE; // line cut to exclude regions where we do not reconstruct
-      } else if ( fEtaCutMin != -0.1 &&   eNeg->R() >= ((abs(eNeg->Vz()) * fLineCutZRSlopeMin) - fLineCutZValueMin)){
-         return kFALSE;
-      }
-
-      return kTRUE;
-      //if(AcceptanceCut(particle,ePos,eNeg))return kTRUE;
-   }
-   return kFALSE;
+       if(!fMCStack)return kFALSE;
+
+       if (particle->GetPdgCode() == 22){
+
+               if ( particle->Eta() < fMinEtaCut || particle->Eta() > fMaxEtaCut ) return kFALSE;
+               if ( particle->Phi() < fMinPhiCut || particle->Phi() > fMaxPhiCut ) return kFALSE;
+               
+               if(particle->GetMother(0) >-1 && fMCStack->Particle(particle->GetMother(0))->GetPdgCode() == 22){
+                       return kFALSE; // no photon as mothers!
+               }
+               if(particle->GetMother(0) >= fMCStack->GetNprimary()){
+                       return kFALSE; // the gamma has a mother, and it is not a primary particle
+               }
+               return kTRUE;
+       }
+       return kFALSE;
 }
 ///________________________________________________________________________
-Bool_t AliCaloPhotonCuts::ClusterIsSelectedAODMC(AliAODMCParticle *particle,TClonesArray *aodmcArray,Bool_t checkForConvertedGamma){
-   // MonteCarlo Photon Selection
-
-   if(!aodmcArray)return kFALSE;
-
-   if (particle->GetPdgCode() == 22){
-      if( particle->Eta() > (fEtaCut) || particle->Eta() < (-fEtaCut) )
-         return kFALSE;
-      if(fEtaCutMin>-0.1){
-         if( particle->Eta() < (fEtaCutMin) && particle->Eta() > (-fEtaCutMin) )
-            return kFALSE;
-      }
-
-      if(particle->GetMother() > -1){
-         if((static_cast<AliAODMCParticle*>(aodmcArray->At(particle->GetMother())))->GetPdgCode() == 22){
-            return kFALSE; // no photon as mothers!
-         }
-         if(!(static_cast<AliAODMCParticle*>(aodmcArray->At(particle->GetMother()))->IsPrimary())){
-            return kFALSE; // the gamma has a mother, and it is not a primary particle
-         }
-      }
-
-      if(!checkForConvertedGamma) return kTRUE; // return in case of accepted gamma
-
-      // looking for conversion gammas (electron + positron from pairbuilding (= 5) )
-      AliAODMCParticle* ePos = NULL;
-      AliAODMCParticle* eNeg = NULL;
-
-      if(particle->GetNDaughters() >= 2){
-         for(Int_t daughterIndex=particle->GetDaughter(0);daughterIndex<=particle->GetDaughter(1);daughterIndex++){
-            AliAODMCParticle *tmpDaughter = static_cast<AliAODMCParticle*>(aodmcArray->At(daughterIndex));
-            if(!tmpDaughter) continue;
-            if(((tmpDaughter->GetMCProcessCode())) == 5){    // STILL A BUG IN ALIROOT >>8 HAS TPO BE REMOVED AFTER FIX
-               if(tmpDaughter->GetPdgCode() == 11){
-                  eNeg = tmpDaughter;
-               } else if(tmpDaughter->GetPdgCode() == -11){
-                  ePos = tmpDaughter;
-               }
-            }
-         }
-      }
-
-      if(ePos == NULL || eNeg == NULL){ // means we do not have two daughters from pair production
-         return kFALSE;
-      }
-
-      if(ePos->Pt()<fSinglePtCut || eNeg->Pt()<fSinglePtCut){
-         return kFALSE; // no reconstruction below the Pt cut
-      }
-
-      if( ePos->Eta() > (fEtaCut) || ePos->Eta() < (-fEtaCut) ||
-          eNeg->Eta() > (fEtaCut) || eNeg->Eta() < (-fEtaCut) )
-         return kFALSE;
-
-      if(fEtaCutMin > -0.1){
-         if( (ePos->Eta() < (fEtaCutMin) && ePos->Eta() > (-fEtaCutMin)) ||
-             (eNeg->Eta() < (fEtaCutMin) && eNeg->Eta() > (-fEtaCutMin)) )
-            return kFALSE;
-      }
-
-      Double_t rPos = sqrt( (ePos->Xv()*ePos->Xv()) + (ePos->Yv()*ePos->Yv()) );
-      Double_t rNeg = sqrt( (eNeg->Xv()*eNeg->Xv()) + (eNeg->Yv()*eNeg->Yv()) );
-
-      if(rPos>fMaxR){
-         return kFALSE; // cuts on distance from collision point
-      }
-      if(abs(ePos->Zv()) > fMaxZ){
-         return kFALSE;  // outside material
-      }
-      if(abs(eNeg->Zv()) > fMaxZ){
-         return kFALSE;  // outside material
-      }
-
-      if( rPos <= ((abs(ePos->Zv()) * fLineCutZRSlope) - fLineCutZValue)){
-         return kFALSE;  // line cut to exclude regions where we do not reconstruct
-      } else if ( fEtaCutMin != -0.1 &&   rPos >= ((abs(ePos->Zv()) * fLineCutZRSlopeMin) - fLineCutZValueMin)){
-         return kFALSE;
-      }
-
-      if( rNeg <= ((abs(eNeg->Zv()) * fLineCutZRSlope) - fLineCutZValue)){
-         return kFALSE; // line cut to exclude regions where we do not reconstruct
-      } else if ( fEtaCutMin != -0.1 &&   rNeg >= ((abs(eNeg->Zv()) * fLineCutZRSlopeMin) - fLineCutZValueMin)){
-         return kFALSE;
-      }
-
-      return kTRUE;
-      //if(AcceptanceCut(particle,ePos,eNeg))return kTRUE;
-   }
-   return kFALSE;
-}*/
+Bool_t AliCaloPhotonCuts::ClusterIsSelectedAODMC(AliAODMCParticle *particle,TClonesArray *aodmcArray){
+       // MonteCarlo Photon Selection
+
+       if(!aodmcArray)return kFALSE;
+       if (particle->GetPdgCode() == 22){
+               if ( particle->Eta() < fMinEtaCut || particle->Eta() > fMaxEtaCut ) return kFALSE;
+               if ( particle->Phi() < fMinPhiCut || particle->Phi() > fMaxPhiCut ) return kFALSE;
+               if(particle->GetMother() > -1){
+                       if((static_cast<AliAODMCParticle*>(aodmcArray->At(particle->GetMother())))->GetPdgCode() == 22){
+                               return kFALSE; // no photon as mothers!
+                       }
+                       if(!(static_cast<AliAODMCParticle*>(aodmcArray->At(particle->GetMother()))->IsPrimary())){
+                               return kFALSE; // the gamma has a mother, and it is not a primary particle
+                       }
+               }
+               return kTRUE; // return in case of accepted gamma
+       }
+       return kFALSE;
+}
 
 
 
@@ -519,9 +382,9 @@ Bool_t AliCaloPhotonCuts::ClusterQualityCuts(AliVCluster* cluster, AliVEvent *ev
        if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex);
        cutIndex++;
 
-       Double_t minR = 999.0;
+//     Double_t minR = 999.0;
        // get the minimum radius of tracks to cluster
-       if(fHistDistanceTrackToClusterBeforeQA || fHistDistanceTrackToClusterAfterQA){
+//     if(fHistDistanceTrackToClusterBeforeQA || fHistDistanceTrackToClusterAfterQA){
 //             Float_t pos[3];
 //             cluster->GetPosition(pos);  // Get cluster position
 //             
@@ -546,12 +409,12 @@ Bool_t AliCaloPhotonCuts::ClusterQualityCuts(AliVCluster* cluster, AliVEvent *ev
 //                     if(dr < minR)
 //                             minR = dr;
 //             }//loop over tracks
-       }
+//     }
        
        // Fill Histos before Cuts
        if(fHistClusterTimevsEBeforeQA) fHistClusterTimevsEBeforeQA->Fill(cluster->GetTOF(), cluster->E());
 //     if(fHistExoticCellBeforeQA) fHistExoticCellBeforeQA->Fill(cluster->E(), );
-       if(fHistDistanceTrackToClusterBeforeQA) fHistDistanceTrackToClusterBeforeQA->Fill(minR);
+//     if(fHistDistanceTrackToClusterBeforeQA) fHistDistanceTrackToClusterBeforeQA->Fill(minR);
        if(fHistEnergyOfClusterBeforeQA) fHistEnergyOfClusterBeforeQA->Fill(cluster->E());
        if(fHistNCellsBeforeQA) fHistNCellsBeforeQA->Fill(cluster->GetNCells());
        if(fHistM02BeforeQA) fHistM02BeforeQA->Fill(cluster->GetM02());
@@ -569,45 +432,45 @@ Bool_t AliCaloPhotonCuts::ClusterQualityCuts(AliVCluster* cluster, AliVEvent *ev
        cutIndex++; //2, next cut
 
        // Minimum distance to track
-       if (fUseDistTrackToCluster){
-               Float_t pos[3];
-               cluster->GetPosition(pos);  // Get cluster position
-               TVector3 cp(pos);
-               int NtrMatched = 0;
-               NtrMatched = cluster->GetNTracksMatched();
-               fHistNMatchedTracks->Fill(NtrMatched);
-               if(NtrMatched > 0){
-                       //loop over tracks for QA
-                       TList *l = event->GetList();
-                       TClonesArray *tracks = dynamic_cast<TClonesArray*>(l->FindObject("Tracks"));
-                       
-                       Double_t dphi = 999.0;
-                       Double_t deta = 999.0;
-                       Double_t dr2 = 999.0;
-
-                       for(int itrack = 0; itrack < NtrMatched; itrack++){
-                               AliVTrack *trackcluster = NULL;
-                               trackcluster = static_cast<AliVTrack*>(tracks->At(itrack));
-                               if (! trackcluster) {
-                               AliError(Form("Couldn't get ESD track %d\n", itrack));
-                               continue;
-                               }
-                               AliPicoTrack::GetEtaPhiDiff(trackcluster, cluster, dphi, deta);
-                               dr2 = dphi*dphi + deta+deta;
-                               //cout << dr << endl;
-                               if(dr2 < fMinDistTrackToCluster*fMinDistTrackToCluster){
-               //        if(dphi < fMinDistTrackToCluster || deta < fMinDistTrackToCluster){
-                               if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //2
-                               return kFALSE;
-                               }
-                               
-                       }//loop over tracks
-               }
-//             if(cluster->GetEmcCpvDistance() < fMinDistTrackToCluster){
-//                     if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //2
-//                     return kFALSE;
-//             }
-       }
+//     if (fUseDistTrackToCluster){
+//             Float_t pos[3];
+//             cluster->GetPosition(pos);  // Get cluster position
+//             TVector3 cp(pos);
+//             int NtrMatched = 0;
+//             NtrMatched = cluster->GetNTracksMatched();
+//             fHistNMatchedTracks->Fill(NtrMatched);
+//             if(NtrMatched > 0){
+//                     //loop over tracks for QA
+//                     TList *l = event->GetList();
+//                     TClonesArray *tracks = dynamic_cast<TClonesArray*>(l->FindObject("Tracks"));
+//                     
+//                     Double_t dphi = 999.0;
+//                     Double_t deta = 999.0;
+//                     Double_t dr2 = 999.0;
+// 
+//                     for(int itrack = 0; itrack < NtrMatched; itrack++){
+//                             AliVTrack *trackcluster = NULL;
+//                             trackcluster = static_cast<AliVTrack*>(tracks->At(itrack));
+//                             if (! trackcluster) {
+//                             AliError(Form("Couldn't get ESD track %d\n", itrack));
+//                             continue;
+//                             }
+//                             AliPicoTrack::GetEtaPhiDiff(trackcluster, cluster, dphi, deta);
+//                             dr2 = dphi*dphi + deta+deta;
+//                             //cout << dr << endl;
+//                             if(dr2 < fMinDistTrackToCluster*fMinDistTrackToCluster){
+//             //        if(dphi < fMinDistTrackToCluster || deta < fMinDistTrackToCluster){
+//                             if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //2
+//                             return kFALSE;
+//                             }
+//                             
+//                     }//loop over tracks
+//             }
+// //          if(cluster->GetEmcCpvDistance() < fMinDistTrackToCluster){
+// //                  if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //2
+// //                  return kFALSE;
+// //          }
+//     }
        cutIndex++;//3, next cut
 
        // exotic cell cut --IMPLEMENT LATER---
@@ -686,8 +549,7 @@ Bool_t AliCaloPhotonCuts::ClusterQualityCuts(AliVCluster* cluster, AliVEvent *ev
        if(fHistClusterEtavsPhiAfterQA) fHistClusterEtavsPhiAfterQA->Fill(phiCluster,etaCluster);
        if(fHistClusterTimevsEAfterQA) fHistClusterTimevsEAfterQA->Fill(cluster->GetTOF(), cluster->E());
 //     if(fHistExoticCellAfterQA) fHistExoticCellAfterQA->Fill(cluster->E(), );
-       if(fHistDistanceTrackToClusterAfterQA) fHistDistanceTrackToClusterAfterQA->Fill(minR);
-       if(fHistDistanceTrackToClusterAfterQA) fHistDistanceTrackToClusterAfterQA->Fill(cluster->GetEmcCpvDistance());
+//     if(fHistDistanceTrackToClusterAfterQA) fHistDistanceTrackToClusterAfterQA->Fill(minR);
        if(fHistEnergyOfClusterAfterQA) fHistEnergyOfClusterAfterQA->Fill(cluster->E());
        if(fHistNCellsAfterQA) fHistNCellsAfterQA->Fill(cluster->GetNCells());
        if(fHistM02AfterQA) fHistM02AfterQA->Fill(cluster->GetM02());
@@ -801,6 +663,82 @@ Bool_t AliCaloPhotonCuts::AcceptanceCuts(AliVCluster *cluster, AliVEvent* event)
        return kTRUE;
 }
 
+Bool_t AliCaloPhotonCuts::MatchConvPhotonToCluster(AliAODConversionPhoton* convPhoton, AliVCluster* cluster, AliVEvent* event ){
+
+       if (!fUseDistTrackToCluster) return kFALSE;
+       
+       AliESDEvent *esdev = dynamic_cast<AliESDEvent*>(event);
+       AliAODEvent *aodev = 0;
+       if (!esdev) {
+               aodev = dynamic_cast<AliAODEvent*>(event);
+               if (!aodev) {
+                       AliError("Task needs AOD or ESD event, returning");
+                       return kFALSE;
+               }
+       }
+
+//     cout << "Got the event" << endl; 
+       
+       Double_t vertex[3] = {0};
+       event->GetPrimaryVertex()->GetXYZ(vertex);
+       // TLorentzvector with cluster
+       TLorentzVector clusterVector;
+       cluster->GetMomentum(clusterVector,vertex);
+       Double_t etaCluster = clusterVector.Eta();
+       Double_t phiCluster = clusterVector.Phi();
+
+       Bool_t matched = kFALSE;
+       for (Int_t i = 0; i < 2; i++){
+               Int_t tracklabel = convPhoton->GetLabel(i);
+               AliVTrack *inTrack = 0x0;       
+               if(esdev) {
+                       if(tracklabel > event->GetNumberOfTracks() ) continue;
+                       inTrack = esdev->GetTrack(tracklabel);
+               } else {
+                       if(((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask("V0ReaderV1"))->AreAODsRelabeled()){
+                               inTrack = dynamic_cast<AliVTrack*>(event->GetTrack(tracklabel));        
+                       } else {
+                               for(Int_t ii=0; ii<event->GetNumberOfTracks(); ii++) {
+                                       inTrack = dynamic_cast<AliVTrack*>(event->GetTrack(ii));
+                                       if(inTrack){
+                                               if(inTrack->GetID() == tracklabel) {
+                                                       continue;
+                                               }
+                                       }
+                               }
+                       }
+               }
+//             cout << "found track " << endl;
+//             AliVTrack *outTrack = 0x00;
+//             if (esdev)
+//                     outTrack = new AliESDtrack(*((AliESDtrack*)inTrack));
+//             else
+//                     outTrack = new AliAODTrack(*((AliAODTrack*)inTrack));
+
+               
+
+               Bool_t propagated = AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(inTrack,440, 0.000510999,20,0.05);
+               if (propagated){
+//                     cout << "Track "<< i  << "\t"<< inTrack->GetTrackPhiOnEMCal() << "\t" << inTrack->GetTrackEtaOnEMCal() << endl;
+//                     cout << "Cluster " << phiCluster << "\t" << etaCluster << endl;
+                       Double_t dPhi = abs(phiCluster-inTrack->GetTrackPhiOnEMCal());
+                       Double_t dEta = abs(etaCluster-inTrack->GetTrackEtaOnEMCal());
+                       
+                       Double_t dR2 = dPhi*dPhi + dEta+dEta;
+//                     cout << "distance to cluster \t" << sqrt(dR2) << endl;
+                       if (fHistDistanceTrackToClusterBeforeQA)fHistDistanceTrackToClusterBeforeQA->Fill(sqrt(dR2));   
+                       if(dR2 < fMinDistTrackToCluster*fMinDistTrackToCluster){
+                               matched = kTRUE;
+                               if (fHistDistanceTrackToClusterAfterQA)fHistDistanceTrackToClusterAfterQA->Fill(sqrt(dR2));     
+                       }
+               } 
+       }       
+       return matched;
+}
+
+//____________________________________________________________________________________________
+
+
 ///________________________________________________________________________
 Bool_t AliCaloPhotonCuts::UpdateCutString() {
    ///Update the cut string (if it has been created yet)
@@ -1195,8 +1133,41 @@ Bool_t AliCaloPhotonCuts::SetTrackMatchingCut(Int_t trackMatching)
                break;
        case 1: 
                if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
-               fMinDistTrackToCluster=5; 
+               fMinDistTrackToCluster=0.04; 
+               break;
+       case 2: 
+               if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
+               fMinDistTrackToCluster=0.05; 
+               break;
+       case 3: 
+               if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
+               fMinDistTrackToCluster=0.1; 
                break;
+       case 4: 
+               if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
+               fMinDistTrackToCluster=0.13; 
+               break;
+       case 5: 
+               if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
+               fMinDistTrackToCluster=0.15; 
+               break;
+       case 6: 
+               if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
+               fMinDistTrackToCluster=0.2; 
+               break;
+       case 7: 
+               if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
+               fMinDistTrackToCluster=0.3; 
+               break;
+       case 8: 
+               if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
+               fMinDistTrackToCluster=0.4; 
+               break;
+       case 9: 
+               if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
+               fMinDistTrackToCluster=0.5; 
+               break;
+
        default:
                AliError(Form("Track Matching Cut not defined %d",trackMatching));
                return kFALSE;
index c445a5084965836e26f83d1c97499cf117207744..1acee0a00339b31124c04841019871ea31e9ce35 100644 (file)
@@ -89,8 +89,8 @@ class AliCaloPhotonCuts : public AliAnalysisCuts {
                virtual Bool_t IsSelected(TList* /*list*/) {return kTRUE;}
 
                Bool_t ClusterIsSelected(AliVCluster* cluster, AliVEvent *event, Bool_t isMC);
-               Bool_t PhotonIsSelectedMC(TParticle *particle,AliStack *fMCStack,Bool_t checkForConvertedGamma=kTRUE);
-               Bool_t PhotonIsSelectedAODMC(AliAODMCParticle *particle,TClonesArray *aodmcArray,Bool_t checkForConvertedGamma=kTRUE);
+               Bool_t ClusterIsSelectedMC(TParticle *particle,AliStack *fMCStack);
+               Bool_t ClusterIsSelectedAODMC(AliAODMCParticle *particle,TClonesArray *aodmcArray);
                        
                void InitCutHistograms(TString name="");
                void SetFillCutHistograms(TString name=""){if(!fHistograms){InitCutHistograms(name);};}
@@ -101,6 +101,8 @@ class AliCaloPhotonCuts : public AliAnalysisCuts {
                Bool_t AcceptanceCuts(AliVCluster* cluster, AliVEvent *event);
                Bool_t ClusterQualityCuts(AliVCluster* cluster,AliVEvent *event, Bool_t isMC);
 
+               Bool_t MatchConvPhotonToCluster(AliAODConversionPhoton* convPhoton, AliVCluster* cluster, AliVEvent* event );
+
                // Set Individual Cuts
                Bool_t SetClusterTypeCut(Int_t);
                Bool_t SetMinEtaCut(Int_t);
index 759251e1c5b51f51c9d03b0335dcd0effd79c6ce..8667fea1819ef32abe41e701f2ccaaa348a66cee 100644 (file)
@@ -646,18 +646,8 @@ Bool_t AliV0ReaderV1::GetHelixCenter(const AliExternalTrackParam *track,Double_t
                        xpoint = - xpoint;
                        ypoint = - ypoint;
                }
-
-               if(charge < 0){
-                       xpoint =        xpoint;
-                       ypoint =        ypoint;
-               }
        }
        if(b>0){
-               if(charge > 0){
-                       xpoint =        xpoint;
-                       ypoint =        ypoint;
-               }
-
                if(charge < 0){
                        xpoint = - xpoint;
                        ypoint = - ypoint;
diff --git a/PWGGA/GammaConv/macros/AddTask_GammaCalo_pPb.C b/PWGGA/GammaConv/macros/AddTask_GammaCalo_pPb.C
new file mode 100644 (file)
index 0000000..3ee3e6e
--- /dev/null
@@ -0,0 +1,218 @@
+void AddTask_GammaCalo_pPb(  Int_t trainConfig = 1,  //change different set of cuts
+                              Bool_t isMC   = kFALSE, //run MC
+                              Int_t enableQAMesonTask = 0, //enable QA in AliAnalysisTaskGammaConvV1
+                              Int_t enableQAClusterTask = 0, // enable additional QA task
+                              TString fileNameInputForWeighting = "MCSpectraInput.root", // path to file for weigting input
+                              Int_t doWeightingPart = 0,  //enable Weighting
+                              TString generatorName = "DPMJET",
+                              TString cutnumberAODBranch = "8000000060084000001500000" // cutnumber for AOD branch
+                                                       ) {
+
+       // ================= 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");
+               
+       Int_t isHeavyIon = 2;
+       
+       // ================== GetAnalysisManager ===============================
+       AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+       if (!mgr) {
+               Error(Form("AddTask_GammaConvV1_%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);
+       }
+       
+       Printf("here \n");
+       
+       //=========  Set Cutnumber for V0Reader ================================
+       TString cutnumberPhoton = "060084001001500000000";
+       TString cutnumberEvent = "8000000";
+       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;
+               }
+               AliConvEventCuts *fEventCuts=NULL;
+               if(cutnumberEvent!=""){
+                       fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data());
+                       fEventCuts->SetPreSelectionCutFlag(kTRUE);
+                       if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){
+                               fEventCuts->DoEtaShift(doEtaShift);
+                               fV0ReaderV1->SetEventCuts(fEventCuts);
+                               fEventCuts->SetFillCutHistograms("",kTRUE);
+                       }
+               }
+               // Set AnalysisCut Number
+               AliConversionPhotonCuts *fCuts=NULL;
+               if(cutnumberPhoton!=""){
+                       fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
+                       fCuts->SetPreSelectionCutFlag(kTRUE);
+                       fCuts->SetIsHeavyIon(isHeavyIon);
+                       if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
+                               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::kFatal);
+
+               //connect input V0Reader
+               mgr->AddTask(fV0ReaderV1);
+               mgr->ConnectInput(fV0ReaderV1,0,cinput);
+       }
+
+       //================================================
+       //========= Add task to the ANALYSIS manager =====
+       //================================================
+       AliAnalysisTaskGammaCalo *task=NULL;
+       task= new AliAnalysisTaskGammaCalo(Form("GammaCalo_%i",trainConfig));
+       task->SetIsHeavyIon(isHeavyIon);
+       task->SetIsMC(isMC);
+       // Cut Numbers to use in Analysis
+       Int_t numberOfCuts = 2;
+       if (trainConfig==3 || trainConfig==5  ){ numberOfCuts =6;}
+       if (trainConfig==6   ){ numberOfCuts =5;}
+       
+       TString *eventCutArray = new TString[numberOfCuts];
+       TString *clusterCutArray = new TString[numberOfCuts];
+       TString *mesonCutArray = new TString[numberOfCuts];
+
+       // cluster cuts
+       // 0 "ClusterType",  1 "EtaMin", 2 "EtaMax", 3 "PhiMin", 4 "PhiMax", 5 "DistanceToBadChannel", 6 "Timing", 7 "TrackMatching", 8 "ExoticCell",
+       // 9 "MinEnergy", 10 "MinNCells", 11 "MinM02", 12 "MaxM02", 13 "MinM20", 14 "MaxM20", 15 "MaximumDispersion", 16 "NLM"
+       
+       if (trainConfig == 1){ 
+               eventCutArray[ 0] = "8000001"; clusterCutArray[0] = "10000040022030000"; mesonCutArray[0] = "01525065000000"; //standart cut, kINT7 // EMCAL clusters
+               eventCutArray[ 1] = "8005201"; clusterCutArray[1] = "10000040022030000"; mesonCutArray[1] = "01525065000000"; //standard cut, kEMC7 // EMCAL clusters
+       } else if (trainConfig == 2) {  
+               eventCutArray[ 0] = "8000001"; clusterCutArray[0] = "20000030022000000"; mesonCutArray[0] = "01525065000000"; //standart cut, kINT7 // PHOS clusters
+               eventCutArray[ 1] = "8006201"; clusterCutArray[1] = "20000030022000000"; mesonCutArray[1] = "01525065000000"; //standard cut, kPHI7     // PHOS clusters        
+       } else if (trainConfig == 3){ 
+               eventCutArray[ 0] = "8008101"; clusterCutArray[0] = "10000040022030000"; mesonCutArray[0] = "01525065000000"; //standart cut, kEMCEGA based on INT7 // EMCAL clusters
+               eventCutArray[ 1] = "8008301"; clusterCutArray[1] = "10000040022030000"; mesonCutArray[1] = "01525065000000"; //standard cut, kEMCEG1 based on INT7 // EMCAL clusters
+               eventCutArray[ 2] = "8008501"; clusterCutArray[2] = "10000040022030000"; mesonCutArray[2] = "01525065000000"; //standard cut, kEMCEG2 based on INT7 // EMCAL clusters
+               eventCutArray[ 3] = "8009101"; clusterCutArray[3] = "10000040022030000"; mesonCutArray[3] = "01525065000000"; //standard cut, kEMCEJE based on INT7 // EMCAL clusters
+               eventCutArray[ 4] = "8009301"; clusterCutArray[4] = "10000040022030000"; mesonCutArray[4] = "01525065000000"; //standard cut, kEMCEJ1 based on INT7 // EMCAL clusters
+               eventCutArray[ 5] = "8009501"; clusterCutArray[5] = "10000040022030000"; mesonCutArray[5] = "01525065000000"; //standard cut, kEMCEG2 based on INT7 // EMCAL clusters
+       } else if (trainConfig == 4){ 
+               eventCutArray[ 0] = "8000001"; clusterCutArray[0] = "10000040052030000"; mesonCutArray[0] = "01525065000000"; //standart cut, kINT7 // EMCAL clusters
+               eventCutArray[ 1] = "8005201"; clusterCutArray[1] = "10000040052030000"; mesonCutArray[1] = "01525065000000"; //standard cut, kEMC7 // EMCAL clusters   
+       } else if (trainConfig == 5){ 
+               eventCutArray[ 0] = "8008101"; clusterCutArray[0] = "10000040052030000"; mesonCutArray[0] = "01525065000000"; //standart cut, kEMCEGA based on INT7 // EMCAL clusters
+               eventCutArray[ 1] = "8008301"; clusterCutArray[1] = "10000040052030000"; mesonCutArray[1] = "01525065000000"; //standard cut, kEMCEG1 based on INT7 // EMCAL clusters
+               eventCutArray[ 2] = "8008501"; clusterCutArray[2] = "10000040052030000"; mesonCutArray[2] = "01525065000000"; //standard cut, kEMCEG2 based on INT7 // EMCAL clusters
+               eventCutArray[ 3] = "8009101"; clusterCutArray[3] = "10000040052030000"; mesonCutArray[3] = "01525065000000"; //standard cut, kEMCEJE based on INT7 // EMCAL clusters
+               eventCutArray[ 4] = "8009301"; clusterCutArray[4] = "10000040052030000"; mesonCutArray[4] = "01525065000000"; //standard cut, kEMCEJ1 based on INT7 // EMCAL clusters
+               eventCutArray[ 5] = "8009501"; clusterCutArray[5] = "10000040052030000"; mesonCutArray[5] = "01525065000000"; //standard cut, kEMCEG2 based on INT7 // EMCAL clusters           
+       } else if (trainConfig == 6){ 
+               eventCutArray[ 0] = "8000001"; clusterCutArray[0] = "10000043052030000"; mesonCutArray[0] = "01525065000000"; //standart cut, kINT7 // EMCAL clusters
+               eventCutArray[ 1] = "8000001"; clusterCutArray[1] = "10000044052030000"; mesonCutArray[1] = "01525065000000"; //standard cut, kEMC7 // EMCAL clusters   
+               eventCutArray[ 2] = "8000001"; clusterCutArray[2] = "10000045052030000"; mesonCutArray[2] = "01525065000000"; //standard cut, kEMC7 // EMCAL clusters   
+               eventCutArray[ 3] = "8000001"; clusterCutArray[3] = "10000046052030000"; mesonCutArray[3] = "01525065000000"; //standard cut, kEMC7 // EMCAL clusters   
+               eventCutArray[ 4] = "8000001"; clusterCutArray[4] = "10000047052030000"; mesonCutArray[4] = "01525065000000"; //standard cut, kEMC7 // EMCAL clusters   
+       } else {
+               Error(Form("GammaCalo_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
+               return;
+       }
+
+       TList *EventCutList = new TList();
+       TList *ClusterCutList = new TList();
+       TList *MesonCutList = new TList();
+
+       TList *HeaderList = new TList();
+       if (doWeightingPart==1) {
+               TObjString *Header1 = new TObjString("pi0_1");
+               HeaderList->Add(Header1);
+       }
+       if (doWeightingPart==2){
+               TObjString *Header3 = new TObjString("eta_2");
+               HeaderList->Add(Header3);
+       }
+       if (doWeightingPart==3) {
+               TObjString *Header1 = new TObjString("pi0_1");
+               HeaderList->Add(Header1);
+               TObjString *Header3 = new TObjString("eta_2");
+               HeaderList->Add(Header3);
+       }
+
+       EventCutList->SetOwner(kTRUE);
+       AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];
+       ClusterCutList->SetOwner(kTRUE);
+       AliCaloPhotonCuts **analysisClusterCuts = new AliCaloPhotonCuts*[numberOfCuts];
+       MesonCutList->SetOwner(kTRUE);
+       AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];
+
+       for(Int_t i = 0; i<numberOfCuts; i++){
+               analysisEventCuts[i] = new AliConvEventCuts();   
+               analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
+               EventCutList->Add(analysisEventCuts[i]);
+               analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);
+                       
+               analysisClusterCuts[i] = new AliCaloPhotonCuts();
+               analysisClusterCuts[i]->InitializeCutsFromCutString(clusterCutArray[i].Data());
+               ClusterCutList->Add(analysisClusterCuts[i]);
+               analysisClusterCuts[i]->SetFillCutHistograms("");
+               
+               analysisMesonCuts[i] = new AliConversionMesonCuts();
+               analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
+               MesonCutList->Add(analysisMesonCuts[i]);
+               analysisMesonCuts[i]->SetFillCutHistograms("");
+               analysisEventCuts[i]->SetAcceptedHeader(HeaderList);
+       }
+       task->SetEventCutList(numberOfCuts,EventCutList);
+       task->SetCaloCutList(numberOfCuts,ClusterCutList);
+       task->SetMesonCutList(numberOfCuts,MesonCutList);
+       task->SetDoMesonAnalysis(kTRUE);
+       task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
+       task->SetDoClusterQA(enableQAClusterTask);  //Attention new switch small for Cluster QA
+
+       //connect containers
+       AliAnalysisDataContainer *coutput =
+               mgr->CreateContainer(Form("GammaCalo_%i",trainConfig), TList::Class(),
+                                                       AliAnalysisManager::kOutputContainer,Form("GammaCalo_%i.root",trainConfig));
+
+       mgr->AddTask(task);
+       mgr->ConnectInput(task,0,cinput);
+       mgr->ConnectOutput(task,1,coutput);
+
+       return;
+
+}
index efeaa40309523964fd19087b9d205c5f7fbd344e..867fed494bdcdf12a5841e870294e7a0424ae7a1 100644 (file)
@@ -112,7 +112,8 @@ void AddTask_GammaConvCalo_pPb(  Int_t trainConfig = 1,  //change different set
        // Cut Numbers to use in Analysis
        Int_t numberOfCuts = 2;
        if (trainConfig==3 || trainConfig==5  ){ numberOfCuts =6;}
-
+       if (trainConfig==6   ){ numberOfCuts =5;}
+       
        TString *eventCutArray = new TString[numberOfCuts];
        TString *photonCutArray = new TString[numberOfCuts];
        TString *clusterCutArray = new TString[numberOfCuts];
@@ -145,6 +146,12 @@ void AddTask_GammaConvCalo_pPb(  Int_t trainConfig = 1,  //change different set
                eventCutArray[ 3] = "8009101"; photonCutArray[ 3] = "002092970028250400000"; clusterCutArray[3] = "10000040052030000"; mesonCutArray[3] = "01525065000000"; //standard cut, kEMCEJE based on INT7 // EMCAL clusters
                eventCutArray[ 4] = "8009301"; photonCutArray[ 4] = "002092970028250400000"; clusterCutArray[4] = "10000040052030000"; mesonCutArray[4] = "01525065000000"; //standard cut, kEMCEJ1 based on INT7 // EMCAL clusters
                eventCutArray[ 5] = "8009501"; photonCutArray[ 5] = "002092970028250400000"; clusterCutArray[5] = "10000040052030000"; mesonCutArray[5] = "01525065000000"; //standard cut, kEMCEG2 based on INT7 // EMCAL clusters             
+       } else if (trainConfig == 6){ 
+               eventCutArray[ 0] = "8000001"; photonCutArray[ 0] = "002092970028250400000"; clusterCutArray[0] = "10000043052030000"; mesonCutArray[0] = "01525065000000"; //standart cut, kINT7 // EMCAL clusters
+               eventCutArray[ 1] = "8000001"; photonCutArray[ 1] = "002092970028250400000"; clusterCutArray[1] = "10000044052030000"; mesonCutArray[1] = "01525065000000"; //standard cut, kEMC7 // EMCAL clusters     
+               eventCutArray[ 2] = "8000001"; photonCutArray[ 2] = "002092970028250400000"; clusterCutArray[2] = "10000045052030000"; mesonCutArray[2] = "01525065000000"; //standard cut, kEMC7 // EMCAL clusters     
+               eventCutArray[ 3] = "8000001"; photonCutArray[ 3] = "002092970028250400000"; clusterCutArray[3] = "10000046052030000"; mesonCutArray[3] = "01525065000000"; //standard cut, kEMC7 // EMCAL clusters     
+               eventCutArray[ 4] = "8000001"; photonCutArray[ 4] = "002092970028250400000"; clusterCutArray[4] = "10000047052030000"; mesonCutArray[4] = "01525065000000"; //standard cut, kEMC7 // EMCAL clusters     
        } else {
                Error(Form("GammaConvCalo_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
                return;
index c6c804eddb0a0ba3cfa1014e0db4bed49fde2254..0e7e7777c3cc7e51764bc71344f078f6897dad69 100644 (file)
@@ -46,5 +46,6 @@
 #pragma link C++ class AliAnalysisTaskEtaToPiPlPiMiGamma+;
 #pragma link C++ class AliAnalysisTaskNeutralMesonToPiPlPiMiPiZero+;
 #pragma link C++ class AliAnalysisTaskGammaConvCalo+;
+#pragma link C++ class AliAnalysisTaskGammaCalo+;
 
 #endif