]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGGA/GammaConv/AliCaloPhotonCuts.cxx
fix coverity 24652
[u/mrichter/AliRoot.git] / PWGGA / GammaConv / AliCaloPhotonCuts.cxx
index 0ec31f28f59da839f2cb4035fc7291fa562a29b6..c36a13ac47532ad678d2115fb781ad177ecb1d2e 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"
@@ -40,6 +41,9 @@
 #include "AliV0ReaderV1.h"
 #include "AliAODMCParticle.h"
 #include "AliAODMCHeader.h"
+#include "AliPicoTrack.h"
+#include "AliEMCALRecoUtils.h"
+#include "AliTrackerBase.h"
 
 class iostream;
 
@@ -49,17 +53,17 @@ ClassImp(AliCaloPhotonCuts)
 
 
 const char* AliCaloPhotonCuts::fgkCutNames[AliCaloPhotonCuts::kNCuts] = {
-       "ClusterType",                  //0              
-       "EtaMin",                               //1
-       "EtaMax",                               //2
-       "PhiMin",                               //3
-       "PhiMax",                               //4
-       "DistanceToBadChannel", //5
-       "Timing",                               //6
-       "TrackMatching",                //7
-       "ExoticCell",                   //8
-       "MinEnergy",                    //9
-       "MinNCells",                    //10
+       "ClusterType",          //0   0: all,    1: EMCAL,   2: PHOS
+       "EtaMin",               //1   0: -10,    1: -0.6687, 2: -0,5, 3: -2
+       "EtaMax",               //2   0: 10,     1: 0.66465, 2: 0.5,  3: 2
+       "PhiMin",               //3   0: -10000, 1: 1.39626
+       "PhiMax",               //4   0: 10000, 1: 3.125
+       "DistanceToBadChannel", //5   0: 0,      1: 5
+       "Timing",               //6   0: no cut
+       "TrackMatching",        //7   0: 0,      1: 5
+       "ExoticCell",           //8   0: no cut
+       "MinEnergy",            //9   0: no cut, 1: 0.05,    2: 0.1,  3: 0.15, 4: 0.2, 5: 0.3, 6: 0.5, 7: 0.75, 8: 1, 9: 1.25 (all GeV)
+       "MinNCells",            //10  0: no cut, 1: 1,       2: 2,    3: 3,    4: 4,   5: 5,   6: 6
        "MinM02",                               //11
        "MaxM02",                               //12
        "MinM20",                               //13
@@ -76,21 +80,34 @@ AliCaloPhotonCuts::AliCaloPhotonCuts(const char *name,const char *title) :
        fClusterType(0),
        fMinEtaCut(-10),
        fMaxEtaCut(10),
+       fUseEtaCut(0),
        fMinPhiCut(-10000),
        fMaxPhiCut(-10000),
+       fUsePhiCut(0),
        fMinDistanceToBadChannel(0),
+       fUseDistanceToBadChannel(0),
        fMaxTimeDiff(10e10),
+       fUseTimeDiff(0),
        fMinDistTrackToCluster(0),
+       fUseDistTrackToCluster(0),
+    fExtendedMatching(kFALSE),
        fExoticCell(0),
+       fUseExoticCell(0),
        fMinEnergy(0),
+       fUseMinEnergy(0),
        fMinNCells(0),
+       fUseNCells(0),
        fMaxM02(1000),
        fMinM02(0),
+       fUseM02(0),
        fMaxM20(1000),
        fMinM20(0),
+       fUseM20(0),
        fMaxDispersion(1000),
+       fUseDispersion(0),
        fMinNLM(0),
        fMaxNLM(1000),
+       fUseNLM(0),
        fCutString(NULL),
        fHistCutIndex(NULL),
        fHistAcceptanceCuts(NULL),
@@ -98,14 +115,13 @@ AliCaloPhotonCuts::AliCaloPhotonCuts(const char *name,const char *title) :
        fHistClusterEtavsPhiBeforeAcc(NULL),
        fHistClusterEtavsPhiAfterAcc(NULL),
        fHistClusterEtavsPhiAfterQA(NULL),
-       fHistDistanceToBadChannelBeforeAcc(NULL),
-       fHistDistanceToBadChannelAfterAcc(NULL),
+    //fHistDistanceToBadChannelBeforeAcc(NULL),
+    //fHistDistanceToBadChannelAfterAcc(NULL),
        fHistClusterTimevsEBeforeQA(NULL),
        fHistClusterTimevsEAfterQA(NULL),
-       fHistExoticCellBeforeQA(NULL),
-       fHistExoticCellAfterQA(NULL),
-       fHistDistanceTrackToClusterBeforeQA(NULL),
-       fHistDistanceTrackToClusterAfterQA(NULL),
+    //fHistExoticCellBeforeQA(NULL),
+    //fHistExoticCellAfterQA(NULL),
+    //fHistNMatchedTracks(NULL),
        fHistEnergyOfClusterBeforeQA(NULL),
        fHistEnergyOfClusterAfterQA(NULL),
        fHistNCellsBeforeQA(NULL),
@@ -115,9 +131,23 @@ AliCaloPhotonCuts::AliCaloPhotonCuts(const char *name,const char *title) :
        fHistM20BeforeQA(NULL),
        fHistM20AfterQA(NULL),
        fHistDispersionBeforeQA(NULL),
-       fHistDispersionAfterQA(NULL),
-       fHistNLMBeforeQA(NULL),
-       fHistNLMAfterQA(NULL)
+    fHistDispersionAfterQA(NULL),
+    //fHistNLMBeforeQA(NULL),
+    //fHistNLMAfterQA(NULL),
+    fHistClusterRBeforeQA(NULL),
+    fHistClusterRAfterQA(NULL),
+    fHistClusterdEtadPhiBeforeQA(NULL),
+    fHistClusterdEtadPhiAfterQA(NULL),
+    fHistDistanceTrackToClusterBeforeQA(NULL),
+    fHistDistanceTrackToClusterAfterQA(NULL),
+    fHistClusterdEtadPhiPosTracksBeforeQA(NULL),
+    fHistClusterdEtadPhiNegTracksBeforeQA(NULL),
+    fHistClusterdEtadPtBeforeQA(NULL),
+    fHistClusterdPhidPtBeforeQA(NULL),
+    fHistClusterM20Pt_dPhiBeforeQA(NULL),
+    fHistClusterM02Pt_dPhiBeforeQA(NULL),
+    fHistClusterM20M02BeforeQA(NULL),
+    fHistClusterM20M02AfterQA(NULL)
 {
    for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=0;}
    fCutString=new TObjString((GetCutNumber()).Data());
@@ -127,24 +157,37 @@ AliCaloPhotonCuts::AliCaloPhotonCuts(const char *name,const char *title) :
 AliCaloPhotonCuts::AliCaloPhotonCuts(const AliCaloPhotonCuts &ref) :
    AliAnalysisCuts(ref),
        fHistograms(NULL),      
-       fClusterType(ref.fClusterType),
+       fClusterType(ref.fClusterType),
        fMinEtaCut(ref.fMinEtaCut),
        fMaxEtaCut(ref.fMaxEtaCut),
+       fUseEtaCut(ref.fUseEtaCut),
        fMinPhiCut(ref.fMinPhiCut),
        fMaxPhiCut(ref.fMaxPhiCut),
+       fUsePhiCut(ref.fUsePhiCut),
        fMinDistanceToBadChannel(ref.fMinDistanceToBadChannel),
+       fUseDistanceToBadChannel(ref.fUseDistanceToBadChannel),
        fMaxTimeDiff(ref.fMaxTimeDiff),
+       fUseTimeDiff(ref.fUseTimeDiff),
        fMinDistTrackToCluster(ref.fMinDistTrackToCluster),
+       fUseDistTrackToCluster(ref.fUseDistTrackToCluster),
+    fExtendedMatching(ref.fExtendedMatching),
        fExoticCell(ref.fExoticCell),
+       fUseExoticCell(ref.fUseExoticCell),
        fMinEnergy(ref.fMinEnergy),
+       fUseMinEnergy(ref.fUseMinEnergy),
        fMinNCells(ref.fMinNCells),
+       fUseNCells(ref.fUseNCells),
        fMaxM02(ref.fMaxM02),
        fMinM02(ref.fMinM02),
+       fUseM02(ref.fUseM02),
        fMaxM20(ref.fMaxM20),
        fMinM20(ref.fMinM20),
+       fUseM20(ref.fUseDispersion),
        fMaxDispersion(ref.fMaxDispersion),
+       fUseDispersion(ref.fUseDispersion),
        fMinNLM(ref.fMinNLM),
        fMaxNLM(ref.fMaxNLM),
+       fUseNLM(ref.fUseNLM),
        fCutString(NULL),
        fHistCutIndex(NULL),
        fHistAcceptanceCuts(NULL),
@@ -152,14 +195,13 @@ AliCaloPhotonCuts::AliCaloPhotonCuts(const AliCaloPhotonCuts &ref) :
        fHistClusterEtavsPhiBeforeAcc(NULL),
        fHistClusterEtavsPhiAfterAcc(NULL),
        fHistClusterEtavsPhiAfterQA(NULL),
-       fHistDistanceToBadChannelBeforeAcc(NULL),
-       fHistDistanceToBadChannelAfterAcc(NULL),
+    //fHistDistanceToBadChannelBeforeAcc(NULL),
+    //fHistDistanceToBadChannelAfterAcc(NULL),
        fHistClusterTimevsEBeforeQA(NULL),
        fHistClusterTimevsEAfterQA(NULL),
-       fHistExoticCellBeforeQA(NULL),
-       fHistExoticCellAfterQA(NULL),
-       fHistDistanceTrackToClusterBeforeQA(NULL),
-       fHistDistanceTrackToClusterAfterQA(NULL),
+    //fHistExoticCellBeforeQA(NULL),
+    //fHistExoticCellAfterQA(NULL),
+    //fHistNMatchedTracks(NULL),
        fHistEnergyOfClusterBeforeQA(NULL),
        fHistEnergyOfClusterAfterQA(NULL),
        fHistNCellsBeforeQA(NULL),
@@ -169,9 +211,23 @@ AliCaloPhotonCuts::AliCaloPhotonCuts(const AliCaloPhotonCuts &ref) :
        fHistM20BeforeQA(NULL),
        fHistM20AfterQA(NULL),
        fHistDispersionBeforeQA(NULL),
-       fHistDispersionAfterQA(NULL),
-       fHistNLMBeforeQA(NULL),
-       fHistNLMAfterQA(NULL)
+    fHistDispersionAfterQA(NULL),
+    //fHistNLMBeforeQA(NULL),
+    //fHistNLMAfterQA(NULL),
+    fHistClusterRBeforeQA(NULL),
+    fHistClusterRAfterQA(NULL),
+    fHistClusterdEtadPhiBeforeQA(NULL),
+    fHistClusterdEtadPhiAfterQA(NULL),
+    fHistDistanceTrackToClusterBeforeQA(NULL),
+    fHistDistanceTrackToClusterAfterQA(NULL),
+    fHistClusterdEtadPhiPosTracksBeforeQA(NULL),
+    fHistClusterdEtadPhiNegTracksBeforeQA(NULL),
+    fHistClusterdEtadPtBeforeQA(NULL),
+    fHistClusterdPhidPtBeforeQA(NULL),
+    fHistClusterM20Pt_dPhiBeforeQA(NULL),
+    fHistClusterM02Pt_dPhiBeforeQA(NULL),
+    fHistClusterM20M02BeforeQA(NULL),
+    fHistClusterM20M02AfterQA(NULL)
 {
    // Copy Constructor
    for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=ref.fCuts[jj];}
@@ -229,44 +285,45 @@ void AliCaloPhotonCuts::InitCutHistograms(TString name){
        fHistograms->Add(fHistAcceptanceCuts);
 
        // Cluster Cuts
-       fHistClusterIdentificationCuts =new TH1F(Form("ClusterQualityCuts %s",GetCutNumber().Data()),"ClusterQualityCuts",10,-0.5,9.5);
+       fHistClusterIdentificationCuts =new TH1F(Form("ClusterQualityCuts %s",GetCutNumber().Data()),"ClusterQualityCuts",11,-0.5,10.5);
        fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(1,"in");
        fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(2,"timing");
        fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(3,"track matching");
        fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(4,"Exotics");
        fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(5,"minimum energy");
-       fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(6,"M02");
-       fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(7,"M20");
-       fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(8,"dispersion");
-       fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(9,"NLM");
-       fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(10,"out");
+       fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(6,"minimum NCells");
+       fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(7,"M02");
+       fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(8,"M20");
+       fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(9,"dispersion");
+       fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(10,"NLM");
+       fHistClusterIdentificationCuts->GetXaxis()->SetBinLabel(11,"out");
        fHistograms->Add(fHistClusterIdentificationCuts);
 
        // Acceptance related histogramms
-       fHistClusterEtavsPhiBeforeAcc=new TH2F(Form("EtaPhi_beforeAcceptance %s",GetCutNumber().Data()),"EtaPhi_beforeAcceptance",462,-TMath::Pi(),TMath::Pi(),110,-0.7,0.7);
+    fHistClusterEtavsPhiBeforeAcc=new TH2F(Form("EtaPhi_beforeAcceptance %s",GetCutNumber().Data()),"EtaPhi_beforeAcceptance",430,-TMath::Pi(),TMath::Pi(),96,-0.7,0.7); // 462->430, 110->96
        fHistograms->Add(fHistClusterEtavsPhiBeforeAcc);
-       fHistClusterEtavsPhiAfterAcc=new TH2F(Form("EtaPhi_afterAcceptance %s",GetCutNumber().Data()),"EtaPhi_afterAcceptance",462,-TMath::Pi(),TMath::Pi(),110,-0.7,0.7);
+    fHistClusterEtavsPhiAfterAcc=new TH2F(Form("EtaPhi_afterAcceptance %s",GetCutNumber().Data()),"EtaPhi_afterAcceptance",430,-TMath::Pi(),TMath::Pi(),96,-0.7,0.7); // 462->430, 110->96
        fHistograms->Add(fHistClusterEtavsPhiAfterAcc);
-       fHistClusterEtavsPhiAfterQA=new TH2F(Form("EtaPhi_afterClusterQA %s",GetCutNumber().Data()),"EtaPhi_afterClusterQA",462,-TMath::Pi(),TMath::Pi(),110,-0.7,0.7);
+    fHistClusterEtavsPhiAfterQA=new TH2F(Form("EtaPhi_afterClusterQA %s",GetCutNumber().Data()),"EtaPhi_afterClusterQA",430,-TMath::Pi(),TMath::Pi(),96,-0.7,0.7); // 462->430, 110->96
        fHistograms->Add(fHistClusterEtavsPhiAfterQA);
-       fHistDistanceToBadChannelBeforeAcc = new TH1F(Form("DistanceToBadChannel_beforeAcceptance %s",GetCutNumber().Data()),"DistanceToBadChannel_beforeAcceptance",200,0,40);
-       fHistograms->Add(fHistDistanceToBadChannelBeforeAcc);
-       fHistDistanceToBadChannelAfterAcc = new TH1F(Form("DistanceToBadChannel_afterAcceptance %s",GetCutNumber().Data()),"DistanceToBadChannel_afterAcceptance",200,0,40);
-       fHistograms->Add(fHistDistanceToBadChannelAfterAcc);
+    //fHistDistanceToBadChannelBeforeAcc = new TH1F(Form("DistanceToBadChannel_beforeAcceptance %s",GetCutNumber().Data()),"DistanceToBadChannel_beforeAcceptance",200,0,40);
+    //fHistograms->Add(fHistDistanceToBadChannelBeforeAcc);
+    //fHistDistanceToBadChannelAfterAcc = new TH1F(Form("DistanceToBadChannel_afterAcceptance %s",GetCutNumber().Data()),"DistanceToBadChannel_afterAcceptance",200,0,40);
+    //fHistograms->Add(fHistDistanceToBadChannelAfterAcc);
        
        // Cluster quality related histograms
-       fHistClusterTimevsEBeforeQA=new TH2F(Form("ClusterTimeVsE_beforeClusterQA %s",GetCutNumber().Data()),"ClusterTimeVsE_beforeClusterQA",400,-10e-6,10e-6,100,0.,40);
+       Double_t timeMin = -10e-6;
+       Double_t timeMax = 10e-6;
+       fHistClusterTimevsEBeforeQA=new TH2F(Form("ClusterTimeVsE_beforeClusterQA %s",GetCutNumber().Data()),"ClusterTimeVsE_beforeClusterQA",400,timeMin,timeMax,100,0.,40);
        fHistograms->Add(fHistClusterTimevsEBeforeQA);
-       fHistClusterTimevsEAfterQA=new TH2F(Form("ClusterTimeVsE_afterClusterQA %s",GetCutNumber().Data()),"ClusterTimeVsE_afterClusterQA",400,-10e-6,10e-6,100,0.,40);
+       fHistClusterTimevsEAfterQA=new TH2F(Form("ClusterTimeVsE_afterClusterQA %s",GetCutNumber().Data()),"ClusterTimeVsE_afterClusterQA",400,timeMin,timeMax,100,0.,40);
        fHistograms->Add(fHistClusterTimevsEAfterQA);
-       fHistExoticCellBeforeQA=new TH2F(Form("ExoticCell_beforeClusterQA %s",GetCutNumber().Data()),"ExoticCell_beforeClusterQA",400,0,40,50,0.75,1);
-       fHistograms->Add(fHistExoticCellBeforeQA);
-       fHistExoticCellAfterQA=new TH2F(Form("ExoticCell_afterClusterQA %s",GetCutNumber().Data()),"ExoticCell_afterClusterQA",400,0,40,50,0.75,1);
-       fHistograms->Add(fHistExoticCellAfterQA);
-       fHistDistanceTrackToClusterBeforeQA = new TH1F(Form("DistanceToTrack_beforeClusterQA %s",GetCutNumber().Data()),"DistanceToTrack_beforeClusterQA",200,0,40);
-       fHistograms->Add(fHistDistanceTrackToClusterBeforeQA);
-       fHistDistanceTrackToClusterAfterQA = new TH1F(Form("DistanceToTrack_afterClusterQA %s",GetCutNumber().Data()),"DistanceToTrack_afterClusterQA",200,0,40);
-       fHistograms->Add(fHistDistanceTrackToClusterAfterQA);
+    //fHistExoticCellBeforeQA=new TH2F(Form("ExoticCell_beforeClusterQA %s",GetCutNumber().Data()),"ExoticCell_beforeClusterQA",400,0,40,50,0.75,1);
+    //fHistograms->Add(fHistExoticCellBeforeQA);
+    //fHistExoticCellAfterQA=new TH2F(Form("ExoticCell_afterClusterQA %s",GetCutNumber().Data()),"ExoticCell_afterClusterQA",400,0,40,50,0.75,1);
+    //fHistograms->Add(fHistExoticCellAfterQA);
+    //fHistNMatchedTracks = new TH1F(Form("NMatchedTracks_%s",GetCutNumber().Data()),"NMatchedTracks",22,-1.5,20.5);
+    //fHistograms->Add(fHistNMatchedTracks);
        fHistEnergyOfClusterBeforeQA = new TH1F(Form("EnergyOfCluster_beforeClusterQA %s",GetCutNumber().Data()),"EnergyOfCluster_beforeClusterQA",300,0,30);
        fHistograms->Add(fHistEnergyOfClusterBeforeQA);
        fHistEnergyOfClusterAfterQA = new TH1F(Form("EnergyOfCluster_afterClusterQA %s",GetCutNumber().Data()),"EnergyOfCluster_afterClusterQA",300,0,30);
@@ -275,207 +332,102 @@ void AliCaloPhotonCuts::InitCutHistograms(TString name){
        fHistograms->Add(fHistNCellsBeforeQA);
        fHistNCellsAfterQA = new TH1F(Form("NCellPerCluster_afterClusterQA %s",GetCutNumber().Data()),"NCellPerCluster_afterClusterQA",50,0,50);
        fHistograms->Add(fHistNCellsAfterQA);
-       fHistM02BeforeQA = new TH1F(Form("M02_beforeClusterQA %s",GetCutNumber().Data()),"M02_beforeClusterQA",100,0,5);
+       fHistM02BeforeQA = new TH1F(Form("M02_beforeClusterQA %s",GetCutNumber().Data()),"M02_beforeClusterQA",400,0,5);
        fHistograms->Add(fHistM02BeforeQA);
-       fHistM02AfterQA = new TH1F(Form("M02_afterClusterQA %s",GetCutNumber().Data()),"M02_afterClusterQA",100,0,5);
+       fHistM02AfterQA = new TH1F(Form("M02_afterClusterQA %s",GetCutNumber().Data()),"M02_afterClusterQA",400,0,5);
        fHistograms->Add(fHistM02AfterQA);
-       fHistM20BeforeQA = new TH1F(Form("M20_beforeClusterQA %s",GetCutNumber().Data()),"M20_beforeClusterQA",100,0,2.5);
+       fHistM20BeforeQA = new TH1F(Form("M20_beforeClusterQA %s",GetCutNumber().Data()),"M20_beforeClusterQA",400,0,2.5);
        fHistograms->Add(fHistM20BeforeQA);
-       fHistM20AfterQA = new TH1F(Form("M20_afterClusterQA %s",GetCutNumber().Data()),"M20_afterClusterQA",100,0,2.5);
+       fHistM20AfterQA = new TH1F(Form("M20_afterClusterQA %s",GetCutNumber().Data()),"M20_afterClusterQA",400,0,2.5);
        fHistograms->Add(fHistM20AfterQA);
        fHistDispersionBeforeQA = new TH1F(Form("Dispersion_beforeClusterQA %s",GetCutNumber().Data()),"Dispersion_beforeClusterQA",100,0,4);
        fHistograms->Add(fHistDispersionBeforeQA);
        fHistDispersionAfterQA = new TH1F(Form("Dispersion_afterClusterQA %s",GetCutNumber().Data()),"Dispersion_afterClusterQA",100,0,4);
        fHistograms->Add(fHistDispersionAfterQA);
-       fHistNLMBeforeQA = new TH1F(Form("NLM_beforeClusterQA %s",GetCutNumber().Data()),"NLM_beforeClusterQA",10,0,10);
-       fHistograms->Add(fHistNLMBeforeQA);
-       fHistNLMAfterQA = new TH1F(Form("NLM_afterClusterQA %s",GetCutNumber().Data()),"NLM_afterClusterQA",10,0,10);
-       fHistograms->Add(fHistNLMAfterQA);
+    //fHistNLMBeforeQA = new TH1F(Form("NLM_beforeClusterQA %s",GetCutNumber().Data()),"NLM_beforeClusterQA",10,0,10);
+    //fHistograms->Add(fHistNLMBeforeQA);
+    //fHistNLMAfterQA = new TH1F(Form("NLM_afterClusterQA %s",GetCutNumber().Data()),"NLM_afterClusterQA",10,0,10);
+    //fHistograms->Add(fHistNLMAfterQA);
+
+    //TrackMatching histograms
+    if(fUseDistTrackToCluster) {
+        fHistClusterRBeforeQA = new TH1F(Form("R_Cluster_beforeClusterQA %s",GetCutNumber().Data()),"R of cluster",200,400,500);
+        fHistograms->Add(fHistClusterRBeforeQA);
+        fHistClusterRAfterQA = new TH1F(Form("R_Cluster_afterClusterQA %s",GetCutNumber().Data()),"R of cluster_matched",200,400,500);
+        fHistograms->Add(fHistClusterRAfterQA);
+        fHistClusterdEtadPhiBeforeQA=new TH2F(Form("dEtaVsdPhi_beforeClusterQA %s",GetCutNumber().Data()),"dEtaVsdPhi_beforeClusterQA",240,-0.3,0.3,240,-0.3,0.3);
+        fHistograms->Add(fHistClusterdEtadPhiBeforeQA);
+        fHistClusterdEtadPhiAfterQA=new TH2F(Form("dEtaVsdPhi_afterClusterQA %s",GetCutNumber().Data()),"dEtaVsdPhi_afterClusterQA",240,-0.3,0.3,240,-0.3,0.3);
+        fHistograms->Add(fHistClusterdEtadPhiAfterQA);
+        fHistDistanceTrackToClusterBeforeQA = new TH1F(Form("DistanceToTrack_beforeClusterQA %s",GetCutNumber().Data()),"DistanceToTrack_beforeClusterQA",200,0,2);
+        fHistograms->Add(fHistDistanceTrackToClusterBeforeQA);
+        fHistDistanceTrackToClusterAfterQA = new TH1F(Form("DistanceToTrack_afterClusterQA %s",GetCutNumber().Data()),"DistanceToTrack_afterClusterQA",200,0,2);
+        fHistograms->Add(fHistDistanceTrackToClusterAfterQA);
        
+        if(fExtendedMatching){
+            fHistClusterdEtadPhiPosTracksBeforeQA = new TH2F(Form("dEtaVsdPhi_posTracks_beforeClusterQA %s",GetCutNumber().Data()),"dEtaVsdPhi_posTracks_beforeClusterQA",240,-0.3,0.3,240,-0.3,0.3);
+            fHistograms->Add(fHistClusterdEtadPhiPosTracksBeforeQA);
+            fHistClusterdEtadPhiNegTracksBeforeQA = new TH2F(Form("dEtaVsdPhi_negTracks_beforeClusterQA %s",GetCutNumber().Data()),"dEtaVsdPhi_negTracks_beforeClusterQA",240,-0.3,0.3,240,-0.3,0.3);
+            fHistograms->Add(fHistClusterdEtadPhiNegTracksBeforeQA);
+            fHistClusterdEtadPtBeforeQA = new TH2F(Form("dEtaVsPt_beforeClusterQA %s",GetCutNumber().Data()),"dEtaVsPt_beforeClusterQA",240,-0.3,0.3,250,0,25);
+            fHistograms->Add(fHistClusterdEtadPtBeforeQA);
+            fHistClusterdPhidPtBeforeQA = new TH2F(Form("dPhiVsPt_beforeClusterQA %s",GetCutNumber().Data()),"dPhiVsPt_beforeClusterQA",480,-0.6,0.6,250,0,25);
+            fHistograms->Add(fHistClusterdPhidPtBeforeQA);
+            fHistClusterM20Pt_dPhiBeforeQA = new TH2F(Form("M20VsPt_dPhi_beforeClusterQA %s",GetCutNumber().Data()),"M20VsPt_dPhi_beforeClusterQA",200,0,2.5,250,0,25);
+            fHistograms->Add(fHistClusterM20Pt_dPhiBeforeQA);
+            fHistClusterM02Pt_dPhiBeforeQA = new TH2F(Form("M02VsPt_dPhi_beforeClusterQA %s",GetCutNumber().Data()),"M20VsPt_dPhi_beforeClusterQA",400,0,5,250,0,25);
+            fHistograms->Add(fHistClusterM02Pt_dPhiBeforeQA);
+            fHistClusterM20M02BeforeQA = new TH2F(Form("M20VsM02_beforeClusterQA %s",GetCutNumber().Data()),"M20VsM02_beforeClusterQA",200,0,2.5,400,0,5);
+            fHistograms->Add(fHistClusterM20M02BeforeQA);
+            fHistClusterM20M02AfterQA = new TH2F(Form("M20VsM02_afterClusterQA %s",GetCutNumber().Data()),"M20VsM02_afterClusterQA",200,0,2.5,400,0,5);
+            fHistograms->Add(fHistClusterM20M02AfterQA);
+        }
+    }
        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(!fMCStack)return kFALSE;
 
-      if(particle->GetMother(0) >= fMCStack->GetNprimary()){
-         return kFALSE; // the gamma has a mother, and it is not a primary particle
-      }
+       if (particle->GetPdgCode() == 22){
 
-      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 ( 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;
+}
 
 
 
@@ -489,11 +441,39 @@ Bool_t AliCaloPhotonCuts::ClusterQualityCuts(AliVCluster* cluster, AliVEvent *ev
        if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex);
        cutIndex++;
 
+//     Double_t minR = 999.0;
+       // get the minimum radius of tracks to cluster
+//     if(fHistDistanceTrackToClusterBeforeQA || fHistDistanceTrackToClusterAfterQA){
+//             Float_t pos[3];
+//             cluster->GetPosition(pos);  // Get cluster position
+//             
+//             TVector3 cp(pos);
+//             int NtrMatched = 0;
+//             NtrMatched = cluster->GetNTracksMatched();
+//             fHistNMatchedTracks->Fill(NtrMatched);
+//             //loop over tracks for Jet QA
+//             TList *l = event->GetList();
+//             TClonesArray *tracks = dynamic_cast<TClonesArray*>(l->FindObject("Tracks"));
+//             for(int itrack = 0; itrack < NtrMatched; itrack++){
+//                     AliVTrack *trackcluster = static_cast<AliVTrack*>(tracks->At(itrack));
+//                     if (! trackcluster) {
+//                             AliError(Form("Couldn't get ESD track %d\n", itrack));
+//                             continue;
+//                     }
+//                     Double_t dphi = -999.0;
+//                     Double_t deta = -999.0;
+//                     AliPicoTrack::GetEtaPhiDiff(trackcluster, cluster, dphi, deta);
+//                     cout << "here" << endl;
+//                     Double_t dr = sqrt(dphi*dphi + deta+deta);
+//                     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(cluster->GetEmcCpvDistance());
+//     if(fHistDistanceTrackToClusterBeforeQA) fHistDistanceTrackToClusterBeforeQA->Fill(minR);
        if(fHistEnergyOfClusterBeforeQA) fHistEnergyOfClusterBeforeQA->Fill(cluster->E());
        if(fHistNCellsBeforeQA) fHistNCellsBeforeQA->Fill(cluster->GetNCells());
        if(fHistM02BeforeQA) fHistM02BeforeQA->Fill(cluster->GetM02());
@@ -502,17 +482,54 @@ Bool_t AliCaloPhotonCuts::ClusterQualityCuts(AliVCluster* cluster, AliVEvent *ev
 //     if(fHistNLMBeforeQA) fHistNLMBeforeQA->Fill(cluster->GetNExMax());
        
        // Check wether timing is ok
-       if(abs(cluster->GetTOF()) > fMaxTimeDiff && !isMC){
-               if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //1
-               return kFALSE;
-       }
+       if (fUseTimeDiff){
+               if(abs(cluster->GetTOF()) > fMaxTimeDiff && !isMC){
+                       if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //1
+                       return kFALSE;
+               }
+       }       
        cutIndex++; //2, next cut
 
        // Minimum distance to track
-       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---
@@ -523,53 +540,65 @@ Bool_t AliCaloPhotonCuts::ClusterQualityCuts(AliVCluster* cluster, AliVEvent *ev
        cutIndex++; //4, next cut
        
        // minimum cell energy cut
-       if(cluster->E() < fMinEnergy){
-               if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //4
-               return kFALSE;
-       }
+       if (fUseMinEnergy){
+               if(cluster->E() < fMinEnergy){
+                       if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //4
+                       return kFALSE;
+               }
+       }       
        cutIndex++; //5, next cut
        
        // minimum number of cells
-       if(cluster->GetNCells() < fMinNCells) {
-               if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //5
-               return kFALSE;
-       }
+       if (fUseNCells){
+               if(cluster->GetNCells() < fMinNCells) {
+                       if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //5
+                       return kFALSE;
+               }
+       }       
        cutIndex++; //6, next cut
        
        // M02 cut
-       if( cluster->GetM02()< fMinM02 || cluster->GetM02() > fMaxM02 ) {
-               if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //6
-               return kFALSE;
-       }
+       if (fUseM02){
+               if( cluster->GetM02()< fMinM02 || cluster->GetM02() > fMaxM02 ) {
+                       if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //6
+                       return kFALSE;
+               }
+       }       
        cutIndex++; //7, next cut
        
        // M20 cut
-       if( cluster->GetM20()< fMinM20 || cluster->GetM20() > fMaxM20 ) {
-               if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //7
-               return kFALSE;
-       }
+       if (fUseM20){
+               if( cluster->GetM20()< fMinM20 || cluster->GetM20() > fMaxM20 ) {
+                       if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //7
+                       return kFALSE;
+               }
+       }       
        cutIndex++; //8, next cut
        
        // dispersion cut
-       if( cluster->GetDispersion()> fMaxDispersion) {
-               if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //8
-               return kFALSE;
-       }
+       if (fUseDispersion){
+               if( cluster->GetDispersion()> fMaxDispersion) {
+                       if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //8
+                       return kFALSE;
+               }
+       }       
        cutIndex++; //9, next cut
        
        // NLM cut --IMPLEMENT LATER---
-       if( cluster->GetDispersion()> fMaxDispersion) {
-               if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //9
-               return kFALSE;
-       }
+//     if (fUseNLM){
+//             if( cluster->GetDispersion()> fMaxDispersion) {
+//                     if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //9
+//                     return kFALSE;
+//             }
+//     }       
        cutIndex++; //9, next cut
        
        // DONE with selecting photons
        if(fHistClusterIdentificationCuts)fHistClusterIdentificationCuts->Fill(cutIndex); //10
 
        // Histos after Cuts
-       Double_t vertex[3] = {0};
-       event->GetPrimaryVertex()->GetXYZ(vertex);
+    Double_t vertex[3] = {0,0,0};
+//     event->GetPrimaryVertex()->GetXYZ(vertex);
        // TLorentzvector with cluster
        TLorentzVector clusterVector;
        cluster->GetMomentum(clusterVector,vertex);
@@ -579,7 +608,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(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());
@@ -599,8 +628,8 @@ Bool_t AliCaloPhotonCuts::ClusterIsSelected(AliVCluster *cluster, AliVEvent * ev
 
        FillClusterCutIndex(kPhotonIn);
 
-       Double_t vertex[3] = {0};
-       event->GetPrimaryVertex()->GetXYZ(vertex);
+    Double_t vertex[3] = {0,0,0};
+//     event->GetPrimaryVertex()->GetXYZ(vertex);
        // TLorentzvector with cluster
        TLorentzVector clusterVector;
        cluster->GetMomentum(clusterVector,vertex);
@@ -615,10 +644,12 @@ Bool_t AliCaloPhotonCuts::ClusterIsSelected(AliVCluster *cluster, AliVEvent * ev
                //Select EMCAL cluster
                if (fClusterType == 1 && !cluster->IsEMCAL()){
                        FillClusterCutIndex(kDetector);
+                       return kFALSE;
                }
                //Select PHOS cluster
                if (fClusterType == 2 && !cluster->IsPHOS()){
                        FillClusterCutIndex(kDetector);
+                       return kFALSE;
                }
        }
        
@@ -649,8 +680,8 @@ Bool_t AliCaloPhotonCuts::AcceptanceCuts(AliVCluster *cluster, AliVEvent* event)
        cutIndex++;
 
        
-       Double_t vertex[3] = {0};
-       event->GetPrimaryVertex()->GetXYZ(vertex);
+       Double_t vertex[3] = {0,0,0};
+//     event->GetPrimaryVertex()->GetXYZ(vertex);
        // TLorentzvector with cluster
        TLorentzVector clusterVector;
        cluster->GetMomentum(clusterVector,vertex);
@@ -658,17 +689,17 @@ Bool_t AliCaloPhotonCuts::AcceptanceCuts(AliVCluster *cluster, AliVEvent* event)
        Double_t phiCluster = clusterVector.Phi();
        
        // check eta range
-       if (fMinEtaCut !=-10 && fMaxEtaCut !=10 ){
+       if (fUseEtaCut){
                if (etaCluster < fMinEtaCut || etaCluster > fMaxEtaCut){
                        if(fHistAcceptanceCuts)fHistAcceptanceCuts->Fill(cutIndex);
                        return kFALSE;
                }
-       }       
+       }
        cutIndex++;
        
        // check phi range
-       if (fMinPhiCut !=-10000 && fMaxPhiCut !=-10000 ){
-               if (phiCluster < fMinPhiCut || phiCluster > fMaxEtaCut){
+       if (fUsePhiCut ){
+        if (phiCluster < fMinPhiCut || phiCluster > fMaxPhiCut){
                        if(fHistAcceptanceCuts)fHistAcceptanceCuts->Fill(cutIndex);
                        return kFALSE;
                }
@@ -676,11 +707,13 @@ Bool_t AliCaloPhotonCuts::AcceptanceCuts(AliVCluster *cluster, AliVEvent* event)
        cutIndex++;
        
        // check distance to bad channel
-       if (cluster->GetDistanceToBadChannel() < fMinDistanceToBadChannel){
-               if(fHistAcceptanceCuts)fHistAcceptanceCuts->Fill(cutIndex);
-               return kFALSE;
-       }       
-
+       if (fUseDistanceToBadChannel){
+               if (cluster->GetDistanceToBadChannel() < fMinDistanceToBadChannel){
+                       if(fHistAcceptanceCuts)fHistAcceptanceCuts->Fill(cutIndex);
+                       return kFALSE;
+               }       
+       }
+       cutIndex++;
        if(fHistAcceptanceCuts)fHistAcceptanceCuts->Fill(cutIndex);
 
        // Histos after cuts
@@ -689,6 +722,137 @@ 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;
+               }
+       }
+
+//    Double_t vertex[3] = {0,0,0};
+//     event->GetPrimaryVertex()->GetXYZ(vertex);
+
+    if(!cluster->IsEMCAL() && !cluster->IsPHOS()){AliError("Cluster is neither EMCAL nor PHOS, returning"); return kFALSE;}
+
+    Float_t clusterPosition[3] = {0,0,0};
+    cluster->GetPosition(clusterPosition);
+    Double_t clusterR = TMath::Sqrt( clusterPosition[0]*clusterPosition[0] + clusterPosition[1]*clusterPosition[1] );
+    if(fHistClusterRBeforeQA) fHistClusterRBeforeQA->Fill(clusterR);
+
+//cout << "+++++++++ Cluster: x, y, z, R" << clusterPosition[0] << ", " << clusterPosition[1] << ", " << clusterPosition[2] << ", " << clusterR << "+++++++++" << endl;
+
+       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;
+                                               }
+                                       }
+                               }
+                       }
+               }
+
+               AliESDtrack *esdt = dynamic_cast<AliESDtrack*>(inTrack);
+               AliAODTrack *aodt = 0;
+               if (!esdt) {
+                       aodt = dynamic_cast<AliAODTrack*>(inTrack);
+                       if (!aodt){AliError("Track is neither ESD nor AOD, continue"); continue;}
+               }
+
+               AliExternalTrackParam *trackParam = 0;
+               if (esdt) {
+                       const AliExternalTrackParam *in = esdt->GetInnerParam();
+                       if (!in){AliError("Could not get InnerParam of Track, continue"); continue;}
+                       trackParam = new AliExternalTrackParam(*in);
+               } else {
+                       Double_t xyz[3] = {0}, pxpypz[3] = {0}, cv[21] = {0};
+                       aodt->PxPyPz(pxpypz);
+                       aodt->XvYvZv(xyz);
+                       aodt->GetCovarianceXYZPxPyPz(cv);
+                       trackParam = new AliExternalTrackParam(xyz,pxpypz,cv,aodt->Charge());
+               }
+               if (!trackParam){AliError("Could not get TrackParameters, continue"); continue;}
+               
+               Bool_t propagated = kFALSE;
+               AliExternalTrackParam emcParam(*trackParam);
+               Float_t dPhi = 0;
+               Float_t dEta = 0;
+
+               if(cluster->IsEMCAL()){
+                       Float_t eta = 0; Float_t phi = 0; Float_t pt = 0;
+                       propagated = AliEMCALRecoUtils::ExtrapolateTrackToEMCalSurface(&emcParam, 430, 0.000510999, 20, eta, phi, pt);
+                       if(propagated){
+                               propagated = AliEMCALRecoUtils::ExtrapolateTrackToCluster(&emcParam, cluster, 0.000510999, 5, dEta, dPhi);
+                       }
+               }
+               if(cluster->IsPHOS()){
+                       propagated = AliTrackerBase::PropagateTrackToBxByBz(&emcParam, clusterR, 0.000510999, 20, kTRUE, 0.8, -1);
+                       if (propagated){
+                               Double_t trkPos[3] = {0,0,0};
+                               emcParam.GetXYZ(trkPos);
+                               TVector3 trkPosVec(trkPos[0],trkPos[1],trkPos[2]);
+                               TVector3 clsPosVec(clusterPosition);
+                               dPhi = clsPosVec.DeltaPhi(trkPosVec);
+                               dEta = clsPosVec.Eta()-trkPosVec.Eta();
+                       }
+               }
+
+               if (propagated){
+                       Float_t dR2 = dPhi*dPhi + dEta*dEta;
+            if(fHistDistanceTrackToClusterBeforeQA)fHistDistanceTrackToClusterBeforeQA->Fill(TMath::Sqrt(dR2));
+            if(fHistClusterdEtadPhiBeforeQA) fHistClusterdEtadPhiBeforeQA->Fill(dEta, dPhi);
+
+            Float_t clusM02 = (Float_t)cluster->GetM02();
+            Float_t clusM20 = (Float_t)cluster->GetM20();
+            if(fExtendedMatching){
+                if(inTrack->Charge() > 0) fHistClusterdEtadPhiPosTracksBeforeQA->Fill(dEta, dPhi);
+                if(inTrack->Charge() < 0) fHistClusterdEtadPhiNegTracksBeforeQA->Fill(dEta, dPhi);
+                fHistClusterdEtadPtBeforeQA->Fill(dEta, inTrack->Pt());
+                fHistClusterdPhidPtBeforeQA->Fill(dPhi, inTrack->Pt());
+                if(abs(dPhi) > 0.05) fHistClusterM20Pt_dPhiBeforeQA->Fill(clusM20, inTrack->Pt());
+                if(abs(dPhi) > 0.05) fHistClusterM02Pt_dPhiBeforeQA->Fill(clusM02, inTrack->Pt());
+                fHistClusterM20M02BeforeQA->Fill(clusM20, clusM02);
+            }
+
+                       if(dR2 < fMinDistTrackToCluster*fMinDistTrackToCluster){
+                               matched = kTRUE;
+                       } else {
+                if(fHistDistanceTrackToClusterAfterQA)fHistDistanceTrackToClusterAfterQA->Fill(TMath::Sqrt(dR2));
+                if(fHistClusterdEtadPhiAfterQA) fHistClusterdEtadPhiAfterQA->Fill(dEta, dPhi);
+                if(fHistClusterRAfterQA) fHistClusterRAfterQA->Fill(clusterR);
+                if(fExtendedMatching){
+                    fHistClusterM20M02AfterQA->Fill(clusM20, clusM02);
+                }
+                       }       
+               }
+               delete trackParam;
+       }
+
+       return matched;
+
+}
+
+//____________________________________________________________________________________________
+
+
 ///________________________________________________________________________
 Bool_t AliCaloPhotonCuts::UpdateCutString() {
    ///Update the cut string (if it has been created yet)
@@ -873,16 +1037,30 @@ void AliCaloPhotonCuts::PrintCuts() {
 
 void AliCaloPhotonCuts::PrintCutsWithValues() {
        // Print out current Cut Selection with value
+       printf("\nCluster cutnumber \n");
+       for(Int_t ic = 0; ic < kNCuts; ic++) {
+               printf("%d",fCuts[ic]);
+       }
+       printf("\n\n");
+
        printf("Acceptance cuts: \n");
-       printf("\t%3.2f < eta_{cluster} < %3.2f\n", fMinEtaCut, fMaxEtaCut );
-       printf("\t%3.2f < phi_{cluster} < %3.2f\n", fMinPhiCut, fMaxPhiCut );
-       printf("\tmin distance to bad channel > %3.2f\n", fMinDistanceToBadChannel );
+       if (fClusterType == 0) printf("\tall calorimeter clusters are used\n");
+       if (fClusterType == 1) printf("\tEMCAL calorimeter clusters are used\n");
+       if (fClusterType == 2) printf("\tPHOS calorimeter clusters are used\n");
+       if (fUseEtaCut) printf("\t%3.2f < eta_{cluster} < %3.2f\n", fMinEtaCut, fMaxEtaCut );
+       if (fUsePhiCut) printf("\t%3.2f < phi_{cluster} < %3.2f\n", fMinPhiCut, fMaxPhiCut );
+       if (fUseDistanceToBadChannel) printf("\tcut on exotics applied \n");
        
        printf("Cluster Quality cuts: \n");
-       printf("\t time difference < %3.2f\n", fMaxTimeDiff );
-       printf("\t min distance to track > %3.2f\n", fMinDistTrackToCluster );
-    printf("\t E_{cluster} > %3.2f\n", fMinEnergy );
-       printf("\t %3.2f < M02 < %3.2f\n", fMinM02, fMaxM02 );
+       if (fUseTimeDiff) printf("\t time difference < %3.2f\n", fMaxTimeDiff );
+       if (fUseDistTrackToCluster) printf("\tmin distance to track > %3.2f\n", fMinDistTrackToCluster );
+       if (fUseExoticCell)printf("\t min distance to track > %3.2f\n", fMinDistTrackToCluster );
+    if (fUseMinEnergy)printf("\t E_{cluster} > %3.2f\n", fMinEnergy );
+       if (fUseNCells) printf("\t number of cells per cluster >= %d\n", fMinNCells );
+       if (fUseM02) printf("\t %3.2f < M02 < %3.2f\n", fMinM02, fMaxM02 );
+       if (fUseM20) printf("\t %3.2f < M20 < %3.2f\n", fMinM20, fMaxM20 );
+       if (fUseDispersion) printf("\t dispersion < %3.2f\n", fMaxDispersion );
+       if (fUseNLM) printf("\t %d < NLM < %d\n", fMinNLM, fMaxNLM );
        
 }
 
@@ -915,14 +1093,21 @@ Bool_t AliCaloPhotonCuts::SetClusterTypeCut(Int_t clusterType)
 Bool_t AliCaloPhotonCuts::SetMinEtaCut(Int_t minEta)
 {
        switch(minEta){
-       case 0: 
-               fMinEtaCut=-0.6687;
+       case 0:
+               if (!fUseEtaCut) fUseEtaCut=0;
+               fMinEtaCut=-10.;
                break;
-       case 1: 
-               fClusterType=-0.5;
+       case 1:
+               if (!fUseEtaCut) fUseEtaCut=1;
+               fMinEtaCut=-0.6687;
                break;
        case 2: 
-               fClusterType=-2;
+               if (!fUseEtaCut) fUseEtaCut=1;
+               fMinEtaCut=-0.5;
+               break;
+       case 3: 
+               if (!fUseEtaCut) fUseEtaCut=1;
+               fMinEtaCut=-2;
                break;
        default:
                AliError(Form("MinEta Cut not defined %d",minEta));
@@ -937,12 +1122,19 @@ Bool_t AliCaloPhotonCuts::SetMaxEtaCut(Int_t maxEta)
 {
        switch(maxEta){
        case 0: 
+               if (!fUseEtaCut) fUseEtaCut=0;
+               fMaxEtaCut=10;
+               break;          
+       case 1:
+               if (!fUseEtaCut) fUseEtaCut=1;
                fMaxEtaCut=0.66465;
                break;
-       case 1: 
+       case 2: 
+               if (!fUseEtaCut) fUseEtaCut=1;
                fMaxEtaCut=0.5;
                break;
-       case 2: 
+       case 3: 
+               if (!fUseEtaCut) fUseEtaCut=1;
                fMaxEtaCut=2;
                break;
        default:
@@ -957,9 +1149,11 @@ Bool_t AliCaloPhotonCuts::SetMinPhiCut(Int_t minPhi)
 {
        switch(minPhi){
        case 0: 
+               if (!fUsePhiCut) fUsePhiCut=0;
                fMinPhiCut=-10000;
                break;
        case 1: 
+               if (!fUsePhiCut) fUsePhiCut=1;
                fMinPhiCut=1.39626;
                break;
        default:
@@ -974,9 +1168,11 @@ Bool_t AliCaloPhotonCuts::SetMaxPhiCut(Int_t maxPhi)
 {
        switch(maxPhi){
        case 0: 
-               fMaxPhiCut=-10000;
+               if (!fUsePhiCut) fUsePhiCut=0;
+               fMaxPhiCut=10000;
                break;
        case 1: 
+               if (!fUsePhiCut) fUsePhiCut=1;
                fMaxPhiCut=3.125;
                break;
        default:
@@ -991,9 +1187,11 @@ Bool_t AliCaloPhotonCuts::SetDistanceToBadChannelCut(Int_t distanceToBadChannel)
 {
        switch(distanceToBadChannel){
        case 0: 
+               fUseDistanceToBadChannel=0;
                fMinDistanceToBadChannel=0;
                break;
        case 1: 
+               if (!fUseDistanceToBadChannel) fUseDistanceToBadChannel=1;
                fMinDistanceToBadChannel=5;
                break;
        default:
@@ -1008,21 +1206,27 @@ Bool_t AliCaloPhotonCuts::SetTimingCut(Int_t timing)
 {
        switch(timing){
        case 0: 
+               fUseTimeDiff=0;
                fMaxTimeDiff=500;
                break;
        case 1: 
+               if (!fUseTimeDiff) fUseTimeDiff=1;
                fMaxTimeDiff=10e-7; //1000ns
                break;
        case 2: 
+               if (!fUseTimeDiff) fUseTimeDiff=1;
                fMaxTimeDiff=50e-8; //500ns
                break;
        case 3: 
+               if (!fUseTimeDiff) fUseTimeDiff=1;
                fMaxTimeDiff=20e-8; //200ns
                break;
        case 4: 
+               if (!fUseTimeDiff) fUseTimeDiff=1;
                fMaxTimeDiff=10e-8; //100ns
                break;
        case 5: 
+               if (!fUseTimeDiff) fUseTimeDiff=1;
                fMaxTimeDiff=50e-9; //50ns
                break;
 
@@ -1038,11 +1242,46 @@ Bool_t AliCaloPhotonCuts::SetTrackMatchingCut(Int_t trackMatching)
 {
        switch(trackMatching){
        case 0: 
+               fUseDistTrackToCluster=0;
                fMinDistTrackToCluster=0;
                break;
        case 1: 
-               fMinDistTrackToCluster=5; 
+               if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
+               fMinDistTrackToCluster= 0.03;   //0.04;  
+               break;
+       case 2: 
+               if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
+               fMinDistTrackToCluster= 0.035;  //0.05; 
+               break;
+       case 3: 
+               if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
+               fMinDistTrackToCluster= 0.04;   //0.1;  
+               break;
+       case 4: 
+               if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
+               fMinDistTrackToCluster= 0.045;  //0.13; 
+               break;
+       case 5: 
+               if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
+               fMinDistTrackToCluster= 0.05;   //0.15 
+               break;
+       case 6: 
+               if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
+               fMinDistTrackToCluster= 0.055;  //0.2; 
                break;
+       case 7: 
+               if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
+               fMinDistTrackToCluster= 0.06;   //0.3; 
+               break;
+       case 8: 
+               if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
+               fMinDistTrackToCluster= 0.07;   //0.4; 
+               break;
+       case 9: 
+               if (!fUseDistTrackToCluster) fUseDistTrackToCluster=1;
+               fMinDistTrackToCluster= 0.1;    //0.5; 
+               break;
+
        default:
                AliError(Form("Track Matching Cut not defined %d",trackMatching));
                return kFALSE;
@@ -1055,9 +1294,11 @@ Bool_t AliCaloPhotonCuts::SetExoticCellCut(Int_t exoticCell)
 {
        switch(exoticCell){
        case 0: 
+               fUseExoticCell=0;
                fExoticCell=0;
                break;
        case 1: 
+               if (!fUseExoticCell) fUseExoticCell=1;
                fExoticCell=5; 
                break;
        default:
@@ -1072,34 +1313,44 @@ Bool_t AliCaloPhotonCuts::SetMinEnergyCut(Int_t minEnergy)
 {
        switch(minEnergy){
        case 0: 
+               if (!fUseMinEnergy) fUseMinEnergy=0;
                fMinEnergy=0;
                break;
        case 1: 
+               if (!fUseMinEnergy) fUseMinEnergy=1;
                fMinEnergy=0.05; 
                break;
        case 2: 
+               if (!fUseMinEnergy) fUseMinEnergy=1;
                fMinEnergy=0.1; 
                break;
        case 3: 
+               if (!fUseMinEnergy) fUseMinEnergy=1;
                fMinEnergy=0.15; 
                break;
        case 4: 
+               if (!fUseMinEnergy) fUseMinEnergy=1;
                fMinEnergy=0.2; 
                break;
        case 5: 
+               if (!fUseMinEnergy) fUseMinEnergy=1;
                fMinEnergy=0.3; 
                break;
        case 6: 
-               fMinEnergy=0.5; 
+               if (!fUseMinEnergy) fUseMinEnergy=1;
+               fMinEnergy=0.4; 
                break;
        case 7: 
-               fMinEnergy=0.75; 
+               if (!fUseMinEnergy) fUseMinEnergy=1;
+               fMinEnergy=0.5; 
                break;
        case 8: 
-               fMinEnergy=1.; 
+               if (!fUseMinEnergy) fUseMinEnergy=1;
+               fMinEnergy=0.75; 
                break;
        case 9: 
-               fMinEnergy=1.25; 
+               if (!fUseMinEnergy) fUseMinEnergy=1;
+               fMinEnergy=1.; 
                break;
        default:
                AliError(Form("Minimum Energy Cut not defined %d",minEnergy));
@@ -1112,25 +1363,32 @@ Bool_t AliCaloPhotonCuts::SetMinEnergyCut(Int_t minEnergy)
 Bool_t AliCaloPhotonCuts::SetMinNCellsCut(Int_t minNCells)
 {
        switch(minNCells){
-       case 0: 
+       case 0:
+               if (!fUseNCells) fUseNCells=0;
                fMinNCells=0;
                break;
        case 1: 
+               if (!fUseNCells) fUseNCells=1;
                fMinNCells=1; 
                break;
        case 2: 
+               if (!fUseNCells) fUseNCells=1;
                fMinNCells=2; 
                break;
        case 3: 
+               if (!fUseNCells) fUseNCells=1;
                fMinNCells=3; 
                break;
        case 4: 
+               if (!fUseNCells) fUseNCells=1;
                fMinNCells=4; 
                break;
        case 5: 
+               if (!fUseNCells) fUseNCells=1;
                fMinNCells=5; 
                break;
        case 6: 
+               if (!fUseNCells) fUseNCells=1;
                fMinNCells=6; 
                break;
 
@@ -1146,21 +1404,25 @@ Bool_t AliCaloPhotonCuts::SetMaxM02(Int_t maxM02)
 {
        switch(maxM02){
        case 0: 
+               if (!fUseM02) fUseM02=0;
                fMaxM02=100;
                break;
        case 1: 
+               if (!fUseM02) fUseM02=1;
                fMaxM02=1.; 
                break;
        case 2: 
+               if (!fUseM02) fUseM02=1;
                fMaxM02=0.7; 
                break;
        case 3: 
+               if (!fUseM02) fUseM02=1;
                fMaxM02=0.5; 
                break;
        case 4: 
+               if (!fUseM02) fUseM02=1;
                fMaxM02=0.4; 
                break;
-
        default:
                AliError(Form("Max M02 Cut not defined %d",maxM02));
                return kFALSE;
@@ -1173,9 +1435,11 @@ Bool_t AliCaloPhotonCuts::SetMinM02(Int_t minM02)
 {
        switch(minM02){
        case 0: 
+               if (!fUseM02) fUseM02=0;
                fMinM02=0;
                break;
        case 1: 
+               if (!fUseM02) fUseM02=1;
                fMinM02=0.002; 
                break;
        default:
@@ -1190,9 +1454,11 @@ Bool_t AliCaloPhotonCuts::SetMaxM20(Int_t maxM20)
 {
        switch(maxM20){
        case 0: 
+               if (!fUseM20) fUseM20=0;
                fMaxM20=100;
                break;
        case 1: 
+               if (!fUseM20) fUseM20=1;
                fMaxM20=0.5; 
                break;
        default:
@@ -1207,9 +1473,11 @@ Bool_t AliCaloPhotonCuts::SetMinM20(Int_t minM20)
 {
        switch(minM20){
        case 0: 
+               if (!fUseM20) fUseM20=0;
                fMinM20=0;
                break;
        case 1: 
+               if (!fUseM20) fUseM20=1;
                fMinM20=0.002; 
                break;
        default:
@@ -1224,9 +1492,11 @@ Bool_t AliCaloPhotonCuts::SetDispersion(Int_t dispersion)
 {
        switch(dispersion){
        case 0: 
+               if (!fUseDispersion) fUseDispersion=0;
                fMaxDispersion =100;
                break;
        case 1: 
+               if (!fUseDispersion) fUseDispersion=1;
                fMaxDispersion=2.; 
                break;
        default:
@@ -1241,10 +1511,12 @@ Bool_t AliCaloPhotonCuts::SetNLM(Int_t nlm)
 {
        switch(nlm){
        case 0: 
+               if (!fUseNLM) fUseNLM=0;
                fMinNLM =0;
                fMaxNLM =100;
                break;
        case 1: 
+               if (!fUseNLM) fUseNLM=1;
                fMinNLM =0;
                fMaxNLM =1;
                break;
@@ -1265,4 +1537,4 @@ TString AliCaloPhotonCuts::GetCutNumber(){
    return a;
 }
        
-       
\ No newline at end of file
+