]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGGA/CaloTrackCorrelations/AliAnaPi0EbE.cxx
put different cluster parameters (time, n cells, n SM) in the AOD particle, recover...
[u/mrichter/AliRoot.git] / PWGGA / CaloTrackCorrelations / AliAnaPi0EbE.cxx
index 043e1180b4e5044f599dfeb7f8dc1e5a02115d3b..ebddf0bd4697329873ce031461a956da2b56adab 100755 (executable)
@@ -48,16 +48,21 @@ ClassImp(AliAnaPi0EbE)
 
 //____________________________
 AliAnaPi0EbE::AliAnaPi0EbE() :
-AliAnaCaloTrackCorrBaseClass(),     fAnaType(kIMCalo),                  fCalorimeter(""),
+AliAnaCaloTrackCorrBaseClass(),
+fAnaType(kIMCalo),
 fMinDist(0.),fMinDist2(0.),         fMinDist3(0.),
 fNLMCutMin(-1),                     fNLMCutMax(10),
 fTimeCutMin(-10000),                fTimeCutMax(10000),
-fRejectTrackMatch(kTRUE),
-fFillPileUpHistograms(0),
+fRejectTrackMatch(kTRUE),           fSelectIsolatedDecay(kFALSE),
+fCheckSplitDistToBad(0),            fSelectPairInIsoCone(0),
+fR(0),                              fIsoCandMinPt(0),
 fFillWeightHistograms(kFALSE),      fFillTMHisto(0),
-fFillSelectClHisto(0),              fFillOnlySimpleSSHisto(1),          fFillEMCALBCHistograms(0),
+fFillSelectClHisto(0),              fFillOnlySimpleSSHisto(1),
+fFillEMCALBCHistograms(0),
+fFillAllNLMHistograms(0),
 fInputAODGammaConvName(""),
-fCheckSplitDistToBad(0),
+fMomentum(),  fMomentum1(),  fMomentum2(),
+fMomentum12(),fPrimaryMom(), fGrandMotherMom(),
 // Histograms
 fhPt(0),                            fhE(0),
 fhPtEta(0),                         fhPtPhi(0),                         fhEtaPhi(0),
@@ -65,11 +70,12 @@ fhEtaPhiEMCALBC0(0),                fhEtaPhiEMCALBC1(0),                fhEtaPhi
 fhTimeTriggerEMCALBC0UMReMatchOpenTime(0),
 fhTimeTriggerEMCALBC0UMReMatchCheckNeigh(0),
 fhTimeTriggerEMCALBC0UMReMatchBoth(0),
-fhPtCentrality(),                   fhPtEventPlane(0),
+fhPtCentrality(),                   fhPtEventPlane(0),                  fhMCPtCentrality(),
 fhPtReject(0),                      fhEReject(0),
 fhPtEtaReject(0),                   fhPtPhiReject(0),                   fhEtaPhiReject(0),
 fhMass(0),                          fhMassPt(0),                        fhMassSplitPt(0),
-fhSelectedMass(),                   fhSelectedMassPt(0),                fhSelectedMassSplitPt(0),
+fhSelectedMass(0),                  fhSelectedMassPt(0),                fhSelectedMassSplitPt(0),
+fhMassPtIsoRCut(0),
 fhMassNoOverlap(0),                 fhMassPtNoOverlap(0),               fhMassSplitPtNoOverlap(0),
 fhSelectedMassNoOverlap(0),         fhSelectedMassPtNoOverlap(0),       fhSelectedMassSplitPtNoOverlap(0),
 fhMCPi0PtRecoPtPrim(0),                       fhMCEtaPtRecoPtPrim(0),
@@ -84,10 +90,11 @@ fhAsymmetry(0),                     fhSelectedAsymmetry(0),
 fhSplitE(0),                        fhSplitPt(0),
 fhSplitPtEta(0),                    fhSplitPtPhi(0),
 fhNLocMaxSplitPt(0),
-fhPtDecay(0),                       fhEDecay(0),
+fhPtDecay(0),
+
 // Shower shape histos
-fhPtDispersion(0),                  fhPtLambda0(0),                     fhPtLambda1(0),
-fhPtLambda0NoTRD(0),                fhPtLambda0FracMaxCellCut(0),
+fhPtDispersion(0),                  fhPtLambda0(0),                     fhPtLambda0NoSplitCut(0),
+fhPtLambda1(0),                     fhPtLambda0NoTRD(0),                fhPtLambda0FracMaxCellCut(0),
 fhPtFracMaxCell(0),                 fhPtFracMaxCellNoTRD(0),
 fhPtNCells(0),                      fhPtTime(0),                        fhEPairDiffTime(0),
 fhPtDispEta(0),                     fhPtDispPhi(0),
@@ -95,10 +102,10 @@ fhPtSumEta(0),                      fhPtSumPhi(0),                      fhPtSumE
 fhPtDispEtaPhiDiff(0),              fhPtSphericity(0),
 
 // MC histos
+fhMCPtDecayLostPairPi0(0),          fhMCPtDecayLostPairEta(0),
 fhMCE(),                            fhMCPt(),
 fhMCPtPhi(),                        fhMCPtEta(),
 fhMCEReject(),                      fhMCPtReject(),
-fhMCPtCentrality(),
 fhMCPi0PtGenRecoFraction(0),        fhMCEtaPtGenRecoFraction(0),
 fhMCPi0DecayPt(0),                  fhMCPi0DecayPtFraction(0),
 fhMCEtaDecayPt(0),                  fhMCEtaDecayPtFraction(0),
@@ -130,7 +137,7 @@ fhPtNPileUpSPDVtxTimeCut2(0),       fhPtNPileUpTrkVtxTimeCut2(0)
 {
   //default ctor
   
-  for(Int_t i = 0; i < 6; i++)
+  for(Int_t i = 0; i < fgkNmcTypes; i++)
   {
     fhMCE              [i] = 0;
     fhMCPt             [i] = 0;
@@ -147,6 +154,7 @@ fhPtNPileUpSPDVtxTimeCut2(0),       fhPtNPileUpTrkVtxTimeCut2(0)
     fhMCNLocMaxSplitPt [i] = 0;
     fhMCNLocMaxPtReject[i] = 0;
     
+    fhMCPtDecay         [i] = 0;
     fhMCPtLambda0       [i] = 0;
     fhMCPtLambda0NoTRD  [i] = 0;
     fhMCPtLambda0FracMaxCellCut[i]= 0;
@@ -207,7 +215,7 @@ fhPtNPileUpSPDVtxTimeCut2(0),       fhPtNPileUpTrkVtxTimeCut2(0)
     fhPtAsymmetryLocMax     [i] = 0;
     fhMassPtLocMax          [i] = 0;
     fhSelectedMassPtLocMax  [i] = 0;
-    for(Int_t ipart = 0; ipart<6; ipart++)
+    for(Int_t ipart = 0; ipart < fgkNmcTypes; ipart++)
     {
       fhMCPtLambda0LocMax     [ipart][i] = 0;
       fhMCSelectedMassPtLocMax[ipart][i] = 0;
@@ -257,11 +265,57 @@ fhPtNPileUpSPDVtxTimeCut2(0),       fhPtNPileUpTrkVtxTimeCut2(0)
   
 }
 
+//______________________________________________________________________________________________
+void AliAnaPi0EbE::FillEMCALBCHistograms(Float_t energy, Float_t eta, Float_t phi, Float_t time)
+{
+  // EMCal trigger cluster BC studies
+  
+  Int_t id = GetReader()->GetTriggerClusterId();
+  if( id < 0 ) return;
+
+  Int_t bc = GetReader()->GetTriggerClusterBC();
+  if(TMath::Abs(bc) >= 6) AliInfo(Form("Trigger BC not expected = %d",bc));
+  
+  if(phi < 0) phi+=TMath::TwoPi();
+  
+  if(energy > 2)
+  {
+    Double_t timeUS = TMath::Abs(time);
+
+    if      (timeUS < 25) fhEtaPhiEMCALBC0->Fill(eta, phi);
+    else if (timeUS < 75) fhEtaPhiEMCALBC1->Fill(eta, phi);
+    else                  fhEtaPhiEMCALBCN->Fill(eta, phi);
+  }
+  
+  if(TMath::Abs(bc) >= 6) return ;
+  
+  if(GetReader()->IsBadCellTriggerEvent() || GetReader()->IsExoticEvent()) return ;
+  
+  if(GetReader()->IsTriggerMatched())
+  {
+    if(energy > 2) fhEtaPhiTriggerEMCALBC[bc+5]->Fill(eta, phi);
+    fhTimeTriggerEMCALBC[bc+5]->Fill(energy, time);
+    if(GetReader()->IsPileUpFromSPD()) fhTimeTriggerEMCALBCPileUpSPD[bc+5]->Fill(energy, time);
+  }
+  else
+  {
+    if(energy > 2) fhEtaPhiTriggerEMCALBCUM[bc+5]->Fill(eta, phi);
+    fhTimeTriggerEMCALBCUM[bc+5]->Fill(energy, time);
+    
+    if(bc==0)
+    {
+      if(GetReader()->IsTriggerMatchedOpenCuts(0)) fhTimeTriggerEMCALBC0UMReMatchOpenTime   ->Fill(energy, time);
+      if(GetReader()->IsTriggerMatchedOpenCuts(1)) fhTimeTriggerEMCALBC0UMReMatchCheckNeigh ->Fill(energy, time);
+      if(GetReader()->IsTriggerMatchedOpenCuts(2)) fhTimeTriggerEMCALBC0UMReMatchBoth       ->Fill(energy, time);
+    }
+  }
+}
+
 //___________________________________________________________________________________
 void AliAnaPi0EbE::FillPileUpHistograms(Float_t pt, Float_t time, AliVCluster * calo)
 {
   // Fill some histograms to understand pile-up
-  if(!fFillPileUpHistograms) return;
+  if(!IsPileUpAnalysisOn()) return;
   
   //printf("E %f, time %f\n",energy,time);
   AliVEvent * event = GetReader()->GetInputEvent();
@@ -282,14 +336,14 @@ void AliAnaPi0EbE::FillPileUpHistograms(Float_t pt, Float_t time, AliVCluster *
   // cells in cluster
   
   AliVCaloCells* cells = 0;
-  if(fCalorimeter == "EMCAL") cells = GetEMCALCells();
+  if(GetCalorimeter() == kEMCAL) cells = GetEMCALCells();
   else                        cells = GetPHOSCells();
 
   Float_t maxCellFraction = 0.;
   Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(cells,calo,maxCellFraction);
   
   Double_t tmax  = cells->GetCellTime(absIdMax);
-  GetCaloUtils()->RecalibrateCellTime(tmax, fCalorimeter, absIdMax,GetReader()->GetInputEvent()->GetBunchCrossNumber());
+  GetCaloUtils()->RecalibrateCellTime(tmax, GetCalorimeter(), absIdMax,GetReader()->GetInputEvent()->GetBunchCrossNumber());
   tmax*=1.e9;
     
   //Loop on cells inside cluster, max cell must be over 100 MeV and time in BC=0
@@ -432,23 +486,22 @@ void AliAnaPi0EbE::FillPileUpHistograms(Float_t pt, Float_t time, AliVCluster *
 
 
 //______________________________________________________________________________________________
-void AliAnaPi0EbE::FillRejectedClusterHistograms(TLorentzVector mom, Int_t mctag, Int_t nMaxima)
+void AliAnaPi0EbE::FillRejectedClusterHistograms(Int_t mctag, Int_t nMaxima)
 {
   // Fill histograms that do not pass the identification (SS case only)
   
-  Float_t ener  = mom.E();
-  Float_t pt    = mom.Pt();
-  Float_t phi   = mom.Phi();
+  Float_t ener  = fMomentum.E();
+  Float_t pt    = fMomentum.Pt();
+  Float_t phi   = fMomentum.Phi();
   if(phi < 0) phi+=TMath::TwoPi();
-  Float_t eta = mom.Eta();
-  
+  Float_t eta = fMomentum.Eta();
+
   fhPtReject     ->Fill(pt);
   fhEReject      ->Fill(ener);
-  
+
   fhPtEtaReject  ->Fill(ener,eta);
   fhPtPhiReject  ->Fill(ener,phi);
   fhEtaPhiReject ->Fill(eta,phi);
-  
   fhNLocMaxPtReject->Fill(pt,nMaxima);
 
   if(IsDataMC())
@@ -456,8 +509,9 @@ void AliAnaPi0EbE::FillRejectedClusterHistograms(TLorentzVector mom, Int_t mctag
     Int_t mcIndex = GetMCIndex(mctag);
     fhMCEReject  [mcIndex] ->Fill(ener);
     fhMCPtReject [mcIndex] ->Fill(pt);
-    fhMCNLocMaxPtReject[mcIndex]->Fill(pt,nMaxima);
+    if(fFillAllNLMHistograms) fhMCNLocMaxPtReject[mcIndex]->Fill(pt,nMaxima);
   }
+
 }
 
 //___________________________________________________________________________________
@@ -486,31 +540,43 @@ void AliAnaPi0EbE::FillSelectedClusterHistograms(AliVCluster* cluster, Float_t p
   else if(nMaxima==2) indexMax = 1 ;
   else                indexMax = 2 ;
   
-  
-  AliVCaloCells * cell = 0x0;
-  if(fCalorimeter == "PHOS")
-    cell = GetPHOSCells();
-  else
-    cell = GetEMCALCells();
-  
-  Float_t maxCellFraction = 0;
-  GetCaloUtils()->GetMaxEnergyCell(cell, cluster, maxCellFraction);
-  fhPtFracMaxCell->Fill(pt,maxCellFraction);
-  
   FillWeightHistograms(cluster);
   
-  fhPtDispersion->Fill(pt, disp);
   fhPtLambda0   ->Fill(pt, l0  );
   fhPtLambda1   ->Fill(pt, l1  );
   
+  fhNLocMaxPt->Fill(pt,nMaxima);
+  
+  if(fFillAllNLMHistograms)
+  {
+    if(nSM < GetCaloUtils()->GetNumberOfSuperModulesUsed() && nSM >=0)
+      fhNLocMaxPtSM[nSM]->Fill(pt,nMaxima);
+    
+    fhPtLambda0LocMax   [indexMax]->Fill(pt,l0);
+    fhPtLambda1LocMax   [indexMax]->Fill(pt,l1);
+  }
+  
   Float_t ll0  = 0., ll1  = 0.;
   Float_t dispp= 0., dEta = 0., dPhi    = 0.;
   Float_t sEta = 0., sPhi = 0., sEtaPhi = 0.;
-  if(fCalorimeter == "EMCAL" && !fFillOnlySimpleSSHisto)
+  AliVCaloCells * cell = 0x0;
+  Float_t maxCellFraction = 0;
+
+  if(GetCalorimeter() == kEMCAL && !fFillOnlySimpleSSHisto)
   {
-    GetCaloUtils()->GetEMCALRecoUtils()->RecalculateClusterShowerShapeParameters(GetEMCALGeometry(), GetReader()->GetInputEvent()->GetEMCALCells(), cluster,
-                                                                                 ll0, ll1, dispp, dEta, dPhi, sEta, sPhi, sEtaPhi);
+    cell = GetEMCALCells();
     
+    GetCaloUtils()->GetMaxEnergyCell(cell, cluster, maxCellFraction);
+    fhPtFracMaxCell->Fill(pt,maxCellFraction);
+    
+    if(maxCellFraction < 0.5)
+      fhPtLambda0FracMaxCellCut->Fill(pt, l0  );
+    
+    GetCaloUtils()->GetEMCALRecoUtils()->RecalculateClusterShowerShapeParameters(GetEMCALGeometry(),
+                                                                                 cell, cluster,
+                                                                                 ll0, ll1, dispp, dEta, dPhi,
+                                                                                 sEta, sPhi, sEtaPhi);
+    fhPtDispersion    -> Fill(pt,disp);
     fhPtDispEta       -> Fill(pt,dEta);
     fhPtDispPhi       -> Fill(pt,dPhi);
     fhPtSumEta        -> Fill(pt,sEta);
@@ -530,38 +596,28 @@ void AliAnaPi0EbE::FillSelectedClusterHistograms(AliVCluster* cluster, Float_t p
       fhAsymmetryDispEta[ptbin]->Fill(dEta,asy);
       fhAsymmetryDispPhi[ptbin]->Fill(dPhi,asy);
     }
-  }
   
-  fhNLocMaxPt->Fill(pt,nMaxima);
-  
-  if(nSM < GetCaloUtils()->GetNumberOfSuperModulesUsed() && nSM >=0)
-    fhNLocMaxPtSM[nSM]->Fill(pt,nMaxima);
-  
-  fhPtLambda0LocMax   [indexMax]->Fill(pt,l0);
-  fhPtLambda1LocMax   [indexMax]->Fill(pt,l1);
-  fhPtDispersionLocMax[indexMax]->Fill(pt,disp);
-
-  if(fCalorimeter=="EMCAL" && !fFillOnlySimpleSSHisto)
-  {
-    fhPtDispEtaLocMax       [indexMax]-> Fill(pt,dEta);
-    fhPtDispPhiLocMax       [indexMax]-> Fill(pt,dPhi);
-    fhPtSumEtaPhiLocMax     [indexMax]-> Fill(pt,sEtaPhi);
-    fhPtDispEtaPhiDiffLocMax[indexMax]-> Fill(pt,dPhi-dEta);
-    if(dEta+dPhi>0)       fhPtSphericityLocMax[indexMax]->Fill(pt,(dPhi-dEta)/(dEta+dPhi));
-    if(fAnaType==kSSCalo) fhPtAsymmetryLocMax [indexMax]->Fill(pt  ,asy);
-    
+    if(fFillAllNLMHistograms)
+    {
+      fhPtDispersionLocMax    [indexMax]->Fill(pt,disp);
+      fhPtDispEtaLocMax       [indexMax]-> Fill(pt,dEta);
+      fhPtDispPhiLocMax       [indexMax]-> Fill(pt,dPhi);
+      fhPtSumEtaPhiLocMax     [indexMax]-> Fill(pt,sEtaPhi);
+      fhPtDispEtaPhiDiffLocMax[indexMax]-> Fill(pt,dPhi-dEta);
+      if(dEta+dPhi>0)       fhPtSphericityLocMax[indexMax]->Fill(pt,(dPhi-dEta)/(dEta+dPhi));
+      if(fAnaType==kSSCalo) fhPtAsymmetryLocMax [indexMax]->Fill(pt  ,asy);
+    }
   }
   
-  if(fCalorimeter=="EMCAL" &&  GetFirstSMCoveredByTRD() >= 0 &&
+  
+  if(GetCalorimeter()==kEMCAL &&  GetFirstSMCoveredByTRD() >= 0 &&
      GetModuleNumber(cluster) < GetFirstSMCoveredByTRD() )
   {
     fhPtLambda0NoTRD    ->Fill(pt, l0  );
-    fhPtFracMaxCellNoTRD->Fill(pt,maxCellFraction);
+    if(!fFillOnlySimpleSSHisto)
+      fhPtFracMaxCellNoTRD->Fill(pt,maxCellFraction);
   }
   
-  if(maxCellFraction < 0.5)
-    fhPtLambda0FracMaxCellCut->Fill(pt, l0  );
-  
   fhPtTime  ->Fill(pt, cluster->GetTOF()*1.e9);
   fhPtNCells->Fill(pt, cluster->GetNCells());
   
@@ -618,7 +674,7 @@ void AliAnaPi0EbE::FillSelectedClusterHistograms(AliVCluster* cluster, Float_t p
         fhEOverP->Fill(pt,  eOverp);
         
         // Change nSM for year > 2011 (< 4 in 2012-13, none after)
-        if(fCalorimeter=="EMCAL" &&  GetFirstSMCoveredByTRD() >= 0 &&
+        if(GetCalorimeter()==kEMCAL &&  GetFirstSMCoveredByTRD() >= 0 &&
            GetModuleNumber(cluster) < GetFirstSMCoveredByTRD() )
           fhEOverPNoTRD->Fill(pt,  eOverp);
         
@@ -647,7 +703,7 @@ void AliAnaPi0EbE::FillSelectedClusterHistograms(AliVCluster* cluster, Float_t p
           else                                                                                 mctag =  7.5 ;
         }
         
-        fhTrackMatchedMCParticlePt   ->Fill(pt, mctag);
+        fhTrackMatchedMCParticlePt  ->Fill(pt, mctag);
         fhTrackMatchedMCParticleDEta->Fill(dZ, mctag);
         fhTrackMatchedMCParticleDPhi->Fill(dR, mctag);
         
@@ -661,25 +717,25 @@ void AliAnaPi0EbE::FillSelectedClusterHistograms(AliVCluster* cluster, Float_t p
     
     fhMCPtLambda0[mcIndex]    ->Fill(pt, l0);
     fhMCPtLambda1[mcIndex]    ->Fill(pt, l1);
-    fhMCPtDispersion[mcIndex] ->Fill(pt, disp);
-    fhMCPtFracMaxCell[mcIndex]->Fill(pt,maxCellFraction);
-    
-    fhMCPtLambda0LocMax     [mcIndex][indexMax]->Fill(pt,l0);
+    if(fFillAllNLMHistograms) fhMCPtLambda0LocMax[mcIndex][indexMax]->Fill(pt,l0);
 
-    if(fCalorimeter=="EMCAL" && GetFirstSMCoveredByTRD() >= 0 &&
+    if(GetCalorimeter()==kEMCAL && GetFirstSMCoveredByTRD() >= 0 &&
        GetModuleNumber(cluster) < GetFirstSMCoveredByTRD() )
       fhMCPtLambda0NoTRD[mcIndex]->Fill(pt, l0  );
     
-    if(maxCellFraction < 0.5)
-      fhMCPtLambda0FracMaxCellCut[mcIndex]->Fill(pt, l0  );
-    
-    if(fCalorimeter == "EMCAL" && !fFillOnlySimpleSSHisto)
+    if(GetCalorimeter() == kEMCAL && !fFillOnlySimpleSSHisto)
     {
+      if(maxCellFraction < 0.5)
+        fhMCPtLambda0FracMaxCellCut[mcIndex]->Fill(pt, l0  );
+
+      fhMCPtDispersion     [mcIndex]->Fill(pt, disp);
+      fhMCPtFracMaxCell    [mcIndex]->Fill(pt,maxCellFraction);
+      
       fhMCPtDispEta        [mcIndex]-> Fill(pt,dEta);
       fhMCPtDispPhi        [mcIndex]-> Fill(pt,dPhi);
       fhMCPtSumEtaPhi      [mcIndex]-> Fill(pt,sEtaPhi);
       fhMCPtDispEtaPhiDiff [mcIndex]-> Fill(pt,dPhi-dEta);
-      if(dEta+dPhi>0)fhMCPtSphericity[mcIndex]-> Fill(pt,(dPhi-dEta)/(dEta+dPhi));
+      if(dEta+dPhi > 0) fhMCPtSphericity[mcIndex]-> Fill(pt,(dPhi-dEta)/(dEta+dPhi));
       
       if (fAnaType==kSSCalo)
       {
@@ -691,11 +747,10 @@ void AliAnaPi0EbE::FillSelectedClusterHistograms(AliVCluster* cluster, Float_t p
       fhMCDispEtaDispPhi[ptbin][mcIndex]->Fill(dEta,dPhi);
       fhMCLambda0DispEta[ptbin][mcIndex]->Fill(l0  ,dEta);
       fhMCLambda0DispPhi[ptbin][mcIndex]->Fill(l0  ,dPhi);
-      
-    }
+    }// only SS simple?
     
   }//MC
-  
+
 }
 
 //________________________________________________________
@@ -706,7 +761,7 @@ void AliAnaPi0EbE::FillWeightHistograms(AliVCluster *clus)
   if(!fFillWeightHistograms || GetMixedEvent()) return;
   
   AliVCaloCells* cells = 0;
-  if(fCalorimeter == "EMCAL") cells = GetEMCALCells();
+  if(GetCalorimeter() == kEMCAL) cells = GetEMCALCells();
   else                        cells = GetPHOSCells();
   
   // First recalculate energy in case non linearity was applied
@@ -719,7 +774,7 @@ void AliAnaPi0EbE::FillWeightHistograms(AliVCluster *clus)
     
     //Recalibrate cell energy if needed
     Float_t amp = cells->GetCellAmplitude(id);
-    GetCaloUtils()->RecalibrateCellAmplitude(amp,fCalorimeter, id);
+    GetCaloUtils()->RecalibrateCellAmplitude(amp,GetCalorimeter(), id);
     
     energy    += amp;
     
@@ -730,7 +785,7 @@ void AliAnaPi0EbE::FillWeightHistograms(AliVCluster *clus)
   
   if(energy <=0 )
   {
-    printf("AliAnaPi0EbE::WeightHistograms()- Wrong calculated energy %f\n",energy);
+    AliInfo(Form("Wrong calculated energy %f",energy));
     return;
   }
   
@@ -744,14 +799,14 @@ void AliAnaPi0EbE::FillWeightHistograms(AliVCluster *clus)
     
     //Recalibrate cell energy if needed
     Float_t amp = cells->GetCellAmplitude(id);
-    GetCaloUtils()->RecalibrateCellAmplitude(amp,fCalorimeter, id);
+    GetCaloUtils()->RecalibrateCellAmplitude(amp,GetCalorimeter(), id);
     
     fhECellClusterRatio   ->Fill(energy,amp/energy);
     fhECellClusterLogRatio->Fill(energy,TMath::Log(amp/energy));
   }
   
   //Recalculate shower shape for different W0
-  if(fCalorimeter=="EMCAL"){
+  if(GetCalorimeter()==kEMCAL){
     
     Float_t l0org = clus->GetM02();
     Float_t l1org = clus->GetM20();
@@ -785,37 +840,47 @@ TObjString * AliAnaPi0EbE::GetAnalysisCuts()
   
   snprintf(onePar,buffersize,"--- AliAnaPi0EbE ---\n") ;
   parList+=onePar ;
-  snprintf(onePar,buffersize,"fAnaType=%d (Pi0 selection type) \n",fAnaType) ;
+  snprintf(onePar,buffersize,"fAnaType=%d (selection type) \n",fAnaType) ;
+  parList+=onePar ;
+  snprintf(onePar,buffersize,"Calorimeter: %s;",GetCalorimeterString().Data()) ;
   parList+=onePar ;
-  snprintf(onePar,buffersize,"Calorimeter: %s;",fCalorimeter.Data()) ;
+  snprintf(onePar,buffersize,"Local maxima in cluster: %d < nlm < %d;",fNLMCutMin,fNLMCutMax) ;
   parList+=onePar ;
   
   if(fAnaType == kSSCalo)
   {
+    snprintf(onePar,buffersize,"E cut: %2.2f<E<%2.2f;",GetMinEnergy(),GetMaxEnergy()) ;
+    parList+=onePar ;
+    snprintf(onePar,buffersize,"N cell cut: N > %d;",GetCaloPID()->GetClusterSplittingMinNCells()) ;
+    parList+=onePar ;
     snprintf(onePar,buffersize,"Min Dist to Bad channel: fMinDist =%2.2f; fMinDist2=%2.2f, fMinDist3=%2.2f;",fMinDist, fMinDist2,fMinDist3) ;
     parList+=onePar ;
     snprintf(onePar,buffersize,"Min E cut for NLM cases: 1) %2.2f; 2) %2.2f; 3) %2.2f;",fNLMECutMin[0],fNLMECutMin[1],fNLMECutMin[2]) ;
     parList+=onePar ;
     snprintf(onePar,buffersize,"Reject Matched tracks?: %d;",fRejectTrackMatch) ;
     parList+=onePar ;
+    snprintf(onePar,buffersize,"Reject split cluster close to border or bad?: %d;",fCheckSplitDistToBad) ;
+    parList+=onePar ;
     snprintf(onePar,buffersize,"Time cut: %2.2f<t<%2.2f;",fTimeCutMin,fTimeCutMax) ;
     parList+=onePar ;
     //Get parameters set in PID class.
     parList += GetCaloPID()->GetPIDParametersList() ;
   }
-  else if(fAnaType == kIMCalo)
+  else if(fAnaType == kIMCalo || fAnaType == kIMCaloTracks)
   {
-    snprintf(onePar,buffersize,"Time Diff: %2.2f\n",GetPairTimeCut()) ;
+    snprintf(onePar,buffersize,"Select %s;", (GetNeutralMesonSelection()->GetParticle()).Data()) ;
     parList+=onePar ;
-    snprintf(onePar,buffersize,"Local maxima in cluster: %d < nlm < %d\n",fNLMCutMin,fNLMCutMax) ;
+    snprintf(onePar,buffersize,"Mass cut: %2.2f<M<%2.2f;",GetNeutralMesonSelection()->GetInvMassMinCut() ,GetNeutralMesonSelection()->GetInvMassMaxCut()) ;
     parList+=onePar ;
-    
   }
   else if(fAnaType == kIMCaloTracks)
   {
-    snprintf(onePar,buffersize,"Photon Conv Array: %s\n",fInputAODGammaConvName.Data()) ;
+    snprintf(onePar,buffersize,"Photon Conv Array: %s;",fInputAODGammaConvName.Data()) ;
     parList+=onePar ;
-    snprintf(onePar,buffersize,"Local maxima in cluster: %d < nlm < %d\n",fNLMCutMin,fNLMCutMax) ;
+  }
+  else if(fAnaType == kIMCalo)
+  {
+    snprintf(onePar,buffersize,"Time Diff: %2.2f;",GetPairTimeCut()) ;
     parList+=onePar ;
   }
   
@@ -864,10 +929,12 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
   Float_t timemin     = GetHistogramRanges()->GetHistoTimeMin();
   
   TString nlm[]   = {"1 Local Maxima","2 Local Maxima", "NLM > 2"};
-  TString ptype[] = {"#gamma","#gamma->e^{#pm}","#pi^{0}","#eta","e^{#pm}", "hadron"};
-  TString pname[] = {"Photon","Conversion",     "Pi0",    "Eta", "Electron","Hadron"};
-  Int_t   bin[]   = {0,2,4,6,10,15,20,100}; // energy bins
   
+  TString ptype [] = {"#pi^{0}", "#eta", "#gamma (direct)","#gamma (#pi^{0})", "#gamma (#eta)", "#gamma (other)",  "e^{#pm}"  , "hadron/other combinations"};
+  TString pname [] = {"Pi0"    , "Eta" , "Photon"         ,"Pi0Decay"        , "EtaDecay"     , "OtherDecay"    ,   "Electron", "Hadron"};
+  
+  Int_t   bin[]   = {0,2,4,6,10,15,20,100}; // energy bins
+
   fhPt  = new TH1F("hPt","Number of identified  #pi^{0} (#eta) decay",nptbins,ptmin,ptmax);
   fhPt->SetYTitle("#it{N}");
   fhPt->SetXTitle("#it{p}_{T} (GeV/#it{c})");
@@ -896,7 +963,7 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
   fhEtaPhi->SetXTitle("#eta");
   outputContainer->Add(fhEtaPhi) ;
   
-  if(fCalorimeter=="EMCAL" && fFillEMCALBCHistograms)
+  if(GetCalorimeter()==kEMCAL && fFillEMCALBCHistograms)
   {
     fhEtaPhiEMCALBC0  = new TH2F
     ("hEtaPhiEMCALBC0","cluster, #it{E} > 2 GeV, #eta vs #phi, for clusters with |#it{t}| < 25 ns, EMCAL-BC=0",netabins,etamin,etamax,nphibins,phimin,phimax);
@@ -984,15 +1051,18 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
     
   }
   
-  fhPtCentrality  = new TH2F("hPtCentrality","centrality vs #it{p}_{T}",nptbins,ptmin,ptmax, 100,0,100);
-  fhPtCentrality->SetYTitle("centrality");
-  fhPtCentrality->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-  outputContainer->Add(fhPtCentrality) ;
-  
-  fhPtEventPlane  = new TH2F("hPtEventPlane","event plane angle vs #it{p}_{T}",nptbins,ptmin,ptmax, 100,0,TMath::Pi());
-  fhPtEventPlane->SetYTitle("Event plane angle (rad)");
-  fhPtEventPlane->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-  outputContainer->Add(fhPtEventPlane) ;
+  if(IsHighMultiplicityAnalysisOn())
+  {
+    fhPtCentrality  = new TH2F("hPtCentrality","centrality vs #it{p}_{T}",nptbins,ptmin,ptmax, 100,0,100);
+    fhPtCentrality->SetYTitle("centrality");
+    fhPtCentrality->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+    outputContainer->Add(fhPtCentrality) ;
+    
+    fhPtEventPlane  = new TH2F("hPtEventPlane","event plane angle vs #it{p}_{T}",nptbins,ptmin,ptmax, 100,0,TMath::Pi());
+    fhPtEventPlane->SetYTitle("Event plane angle (rad)");
+    fhPtEventPlane->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+    outputContainer->Add(fhPtEventPlane) ;
+  }
   
   if(fAnaType == kSSCalo)
   {
@@ -1023,6 +1093,13 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
     fhEtaPhiReject->SetYTitle("#phi (rad)");
     fhEtaPhiReject->SetXTitle("#eta");
     outputContainer->Add(fhEtaPhiReject) ;
+    
+    fhNLocMaxPtReject = new TH2F("hNLocMaxPtReject","Number of local maxima in cluster, rejected clusters",
+                                 nptbins,ptmin,ptmax,20,0,20);
+    fhNLocMaxPtReject ->SetYTitle("N maxima");
+    fhNLocMaxPtReject ->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+    outputContainer->Add(fhNLocMaxPtReject) ;
+
   }
   
   fhMass  = new TH2F
@@ -1037,20 +1114,35 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
   fhSelectedMass->SetXTitle("#it{E} (GeV)");
   outputContainer->Add(fhSelectedMass) ;
   
+  fhMassPt  = new TH2F
+  ("hMassPt","all pairs #it{M}: #it{p}_{T} vs #it{M}",nptbins,ptmin,ptmax, nmassbins,massmin,massmax);
+  fhMassPt->SetYTitle("#it{M} (GeV/#it{c}^{2})");
+  fhMassPt->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+  outputContainer->Add(fhMassPt) ;
+  
+  fhSelectedMassPt  = new TH2F
+  ("hSelectedMassPt","Selected #pi^{0} (#eta) pairs #it{M}: #it{p}_{T} vs #it{M}",nptbins,ptmin,ptmax, nmassbins,massmin,massmax);
+  fhSelectedMassPt->SetYTitle("#it{M} (GeV/#it{c}^{2})");
+  fhSelectedMassPt->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+  outputContainer->Add(fhSelectedMassPt) ;
+  
+  if(fAnaType != kSSCalo && fSelectPairInIsoCone)
+  {
+    fhMassPtIsoRCut  = new TH2F
+    ("hMassPtIsoRCut",Form("#it{M}: #it{p}_{T} vs #it{M}, for R = %1.1f, #it{p}_{T,1} < %2.2f",fR,fIsoCandMinPt),
+     nptbins,ptmin,ptmax, nmassbins,massmin,massmax);
+    fhMassPtIsoRCut->SetYTitle("#it{M} (GeV/#it{c}^{2})");
+    fhMassPtIsoRCut->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+    outputContainer->Add(fhMassPtIsoRCut) ;
+  }
+  
   if(fAnaType == kSSCalo)
   {
-    
-    fhMassPt  = new TH2F
-    ("hMassPt","all pairs #it{M}: #it{p}_{T} vs #it{M}",nptbins,ptmin,ptmax, nmassbins,massmin,massmax);
-    fhMassPt->SetYTitle("#it{M} (GeV/#it{c}^{2})");
-    fhMassPt->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-    outputContainer->Add(fhMassPt) ;
-    
-    fhSelectedMassPt  = new TH2F
-    ("hSelectedMassPt","Selected #pi^{0} (#eta) pairs #it{M}: #it{p}_{T} vs #it{M}",nptbins,ptmin,ptmax, nmassbins,massmin,massmax);
-    fhSelectedMassPt->SetYTitle("#it{M} (GeV/#it{c}^{2})");
-    fhSelectedMassPt->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-    outputContainer->Add(fhSelectedMassPt) ;
+    fhPtLambda0NoSplitCut  = new TH2F
+    ("hPtLambda0NoSplitCut","all clusters: #it{p}_{T} vs #lambda_{0}^{2}",nptbins,ptmin,ptmax, ssbins,ssmin,ssmax);
+    fhPtLambda0NoSplitCut->SetYTitle("#lambda_{0}^{2}");
+    fhPtLambda0NoSplitCut->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+    outputContainer->Add(fhPtLambda0NoSplitCut) ;
     
     for(Int_t inlm = 0; inlm < 3; inlm++)
     {
@@ -1066,28 +1158,31 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
       fhSelectedMassPtLocMax[inlm]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
       outputContainer->Add(fhSelectedMassPtLocMax[inlm]) ;
       
-      for(Int_t iSM = 0; iSM < GetCaloUtils()->GetNumberOfSuperModulesUsed(); iSM++)
+      if(fFillAllNLMHistograms)
       {
-        fhSelectedMassPtLocMaxSM[inlm][iSM]  = new TH2F
-        (Form("hSelectedMassPtLocMax%d_SM%d",inlm+1,iSM),Form("Selected #pi^{0} (#eta) pairs #it{M}: #it{p}_{T} vs #it{M}, NLM=%s for SM=%d",nlm[inlm].Data(),iSM),nptbins,ptmin,ptmax, nmassbins,massmin,massmax);
-        fhSelectedMassPtLocMaxSM[inlm][iSM]->SetYTitle("#it{M} (GeV/#it{c}^{2})");
-        fhSelectedMassPtLocMaxSM[inlm][iSM]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        outputContainer->Add(fhSelectedMassPtLocMaxSM[inlm][iSM]) ;
-
-        fhSelectedLambda0PtLocMaxSM[inlm][iSM]  = new TH2F
-        (Form("hSelectedLambda0PtLocMax%d_SM%d",inlm+1,iSM),Form("Selected #pi^{0} (#eta) pairs #lambda_{0}^{2}: #it{p}_{T} vs #it{M}, NLM=%s for SM=%d",nlm[inlm].Data(),iSM),nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
-        fhSelectedLambda0PtLocMaxSM[inlm][iSM]->SetYTitle("#lambda_{0}^{2}");
-        fhSelectedLambda0PtLocMaxSM[inlm][iSM]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        outputContainer->Add(fhSelectedLambda0PtLocMaxSM[inlm][iSM]) ;
+        for(Int_t iSM = 0; iSM < GetCaloUtils()->GetNumberOfSuperModulesUsed(); iSM++)
+        {
+          fhSelectedMassPtLocMaxSM[inlm][iSM]  = new TH2F
+          (Form("hSelectedMassPtLocMax%d_SM%d",inlm+1,iSM),Form("Selected #pi^{0} (#eta) pairs #it{M}: #it{p}_{T} vs #it{M}, NLM=%s for SM=%d",nlm[inlm].Data(),iSM),nptbins,ptmin,ptmax, nmassbins,massmin,massmax);
+          fhSelectedMassPtLocMaxSM[inlm][iSM]->SetYTitle("#it{M} (GeV/#it{c}^{2})");
+          fhSelectedMassPtLocMaxSM[inlm][iSM]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+          outputContainer->Add(fhSelectedMassPtLocMaxSM[inlm][iSM]) ;
+          
+          fhSelectedLambda0PtLocMaxSM[inlm][iSM]  = new TH2F
+          (Form("hSelectedLambda0PtLocMax%d_SM%d",inlm+1,iSM),Form("Selected #pi^{0} (#eta) pairs #lambda_{0}^{2}: #it{p}_{T} vs #it{M}, NLM=%s for SM=%d",nlm[inlm].Data(),iSM),nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
+          fhSelectedLambda0PtLocMaxSM[inlm][iSM]->SetYTitle("#lambda_{0}^{2}");
+          fhSelectedLambda0PtLocMaxSM[inlm][iSM]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+          outputContainer->Add(fhSelectedLambda0PtLocMaxSM[inlm][iSM]) ;
+        }
       }
       
       if(IsDataMC())
       {
-        for(Int_t ipart = 0; ipart < 6; ipart++)
+        for(Int_t ipart = 0; ipart < fgkNmcTypes; ipart++)
         {
           fhMCSelectedMassPtLocMax[ipart][inlm]  = new TH2F
           (Form("hSelectedMassPtLocMax%d_MC%s",inlm+1,pname[ipart].Data()),
-           Form("Selected #pi^{0} (#eta) pairs #it{M}: #it{p}_{T} vs #it{M}, NLM=%s, %s",nlm[inlm].Data(),pname[ipart].Data()),
+           Form("Selected #pi^{0} (#eta) pairs #it{M}: #it{p}_{T} vs #it{M}, NLM=%s, from MC %s",nlm[inlm].Data(),ptype[ipart].Data()),
            nptbins,ptmin,ptmax, nmassbins,massmin,massmax);
           fhMCSelectedMassPtLocMax[ipart][inlm]->SetYTitle("#it{M} (GeV/#it{c}^{2})");
           fhMCSelectedMassPtLocMax[ipart][inlm]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
@@ -1126,27 +1221,41 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
   
   if(fAnaType != kSSCalo)
   {
-    fhPtDecay  = new TH1F("hPtDecay","Number of identified  #pi^{0} (#eta) decay photons",nptbins,ptmin,ptmax);
+    fhPtDecay  = new TH1F("hPtDecay","Selected #pi^{0} (#eta) decay photons",nptbins,ptmin,ptmax);
     fhPtDecay->SetYTitle("#it{N}");
     fhPtDecay->SetXTitle("#it{p}_{T} (GeV/#it{c})");
     outputContainer->Add(fhPtDecay) ;
     
-    fhEDecay  = new TH1F("hEDecay","Number of identified  #pi^{0} (#eta) decay photons",nptbins,ptmin,ptmax);
-    fhEDecay->SetYTitle("#it{N}");
-    fhEDecay->SetXTitle("#it{E} (GeV)");
-    outputContainer->Add(fhEDecay) ;
+    if(IsDataMC())
+    {
+      fhMCPtDecayLostPairPi0  = new TH1F("hPtDecay_MCPi0DecayLostPair","Selected  #pi^{0} (#eta) decay photons, from MC #gamma #pi^{0} decay, companion lost",
+                                     nptbins,ptmin,ptmax);
+      fhMCPtDecayLostPairPi0->SetYTitle("#it{N}");
+      fhMCPtDecayLostPairPi0->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+      outputContainer->Add(fhMCPtDecayLostPairPi0) ;
+
+      fhMCPtDecayLostPairEta  = new TH1F("hPtDecay_MCEtaDecayLostPair","Selected  #pi^{0} (#eta) decay photons, from MC #gamma #eta decay, companion lost",
+                                         nptbins,ptmin,ptmax);
+      fhMCPtDecayLostPairEta->SetYTitle("#it{N}");
+      fhMCPtDecayLostPairEta->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+      outputContainer->Add(fhMCPtDecayLostPairEta) ;
+      
+      for(Int_t ipart = 0; ipart < fgkNmcTypes; ipart++)
+      {
+        fhMCPtDecay[ipart]  = new TH1F(Form("hPtDecay_MC%s",pname[ipart].Data()),
+                                       Form("Selected  #pi^{0} (#eta) decay photons, from MC %s",ptype[ipart].Data()),
+                                       nptbins,ptmin,ptmax);
+        fhMCPtDecay[ipart]->SetYTitle("#it{N}");
+        fhMCPtDecay[ipart]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+        outputContainer->Add(fhMCPtDecay[ipart]) ;
+      }
+    }
   }
   
   ////////
   
   if( fFillSelectClHisto )
   {
-    fhPtDispersion  = new TH2F
-    ("hPtDispersion","Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs dispersion",nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
-    fhPtDispersion->SetYTitle("D^{2}");
-    fhPtDispersion->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-    outputContainer->Add(fhPtDispersion) ;
-    
     fhPtLambda0  = new TH2F
     ("hPtLambda0","Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #lambda_{0}",nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
     fhPtLambda0->SetYTitle("#lambda_{0}^{2}");
@@ -1159,19 +1268,7 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
     fhPtLambda1->SetXTitle("#it{p}_{T} (GeV/#it{c})");
     outputContainer->Add(fhPtLambda1) ;
     
-    fhPtLambda0FracMaxCellCut  = new TH2F
-    ("hPtLambda0FracMaxCellCut","Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #lambda_{0}, Max cell fraction of energy < 0.5",nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
-    fhPtLambda0FracMaxCellCut->SetYTitle("#lambda_{0}^{2}");
-    fhPtLambda0FracMaxCellCut->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-    outputContainer->Add(fhPtLambda0FracMaxCellCut) ;
-    
-    fhPtFracMaxCell  = new TH2F
-    ("hPtFracMaxCell","Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #lambda_{0}, Max cell fraction of energy",nptbins,ptmin,ptmax,100,0,1);
-    fhPtFracMaxCell->SetYTitle("Fraction");
-    fhPtFracMaxCell->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-    outputContainer->Add(fhPtFracMaxCell) ;
-    
-    if(fCalorimeter=="EMCAL" &&  GetFirstSMCoveredByTRD() >=0 )
+    if(GetCalorimeter()==kEMCAL &&  GetFirstSMCoveredByTRD() >=0 )
     {
       fhPtLambda0NoTRD  = new TH2F
       ("hPtLambda0NoTRD","Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #lambda_{0}, not behind TRD",nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
@@ -1179,178 +1276,191 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
       fhPtLambda0NoTRD->SetXTitle("#it{p}_{T} (GeV/#it{c})");
       outputContainer->Add(fhPtLambda0NoTRD) ;
       
-      fhPtFracMaxCellNoTRD  = new TH2F
-      ("hPtFracMaxCellNoTRD","Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #lambda_{0}, Max cell fraction of energy, not behind TRD",nptbins,ptmin,ptmax,100,0,1);
-      fhPtFracMaxCellNoTRD->SetYTitle("Fraction");
-      fhPtFracMaxCellNoTRD->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-      outputContainer->Add(fhPtFracMaxCellNoTRD) ;
-      
       if(!fFillOnlySimpleSSHisto)
       {
-        fhPtDispEta  = new TH2F ("hPtDispEta","#sigma^{2}_{#eta #eta} = #Sigma w_{i}(#eta_{i} - <#eta>)^{2}/ #Sigma w_{i} vs #it{p}_{T}",  nptbins,ptmin,ptmax, ssbins,ssmin,ssmax);
-        fhPtDispEta->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        fhPtDispEta->SetYTitle("#sigma^{2}_{#eta #eta}");
-        outputContainer->Add(fhPtDispEta);
-        
-        fhPtDispPhi  = new TH2F ("hPtDispPhi","#sigma^{2}_{#phi #phi} = #Sigma w_{i}(#phi_{i} - <#phi>)^{2} / #Sigma w_{i} vs #it{p}_{T}",  nptbins,ptmin,ptmax, ssbins,ssmin,ssmax);
-        fhPtDispPhi->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        fhPtDispPhi->SetYTitle("#sigma^{2}_{#phi #phi}");
-        outputContainer->Add(fhPtDispPhi);
-        
-        fhPtSumEta  = new TH2F ("hPtSumEta","#sigma^{2}_{#eta #eta} = #Sigma w_{i}(#eta_{i})^{2} / #Sigma w_{i} - <#eta>^{2} vs #it{p}_{T}",  nptbins,ptmin,ptmax, ssbins,ssmin,ssmax);
-        fhPtSumEta->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        fhPtSumEta->SetYTitle("#delta^{2}_{#eta #eta}");
-        outputContainer->Add(fhPtSumEta);
-        
-        fhPtSumPhi  = new TH2F ("hPtSumPhi","#sigma^{2}_{#phi #phi} = #Sigma w_{i}(#phi_{i})^{2}/ #Sigma w_{i} - <#phi>^{2} vs #it{p}_{T}",
-                               nptbins,ptmin,ptmax, ssbins,ssmin,ssmax);
-        fhPtSumPhi->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        fhPtSumPhi->SetYTitle("#delta^{2}_{#phi #phi}");
-        outputContainer->Add(fhPtSumPhi);
-        
-        fhPtSumEtaPhi  = new TH2F ("hPtSumEtaPhi","#delta^{2}_{#eta #phi} = #Sigma w_{i}(#phi_{i} #eta_{i} ) / #Sigma w_{i} - <#phi><#eta> vs #it{p}_{T}",
-                                  nptbins,ptmin,ptmax, 2*ssbins,-ssmax,ssmax);
-        fhPtSumEtaPhi->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        fhPtSumEtaPhi->SetYTitle("#delta^{2}_{#eta #phi}");
-        outputContainer->Add(fhPtSumEtaPhi);
-        
-        fhPtDispEtaPhiDiff  = new TH2F ("hPtDispEtaPhiDiff","#sigma^{2}_{#phi #phi} - #sigma^{2}_{#eta #eta} vs #it{p}_{T}",
-                                       nptbins,ptmin,ptmax,200, -10,10);
-        fhPtDispEtaPhiDiff->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        fhPtDispEtaPhiDiff->SetYTitle("#sigma^{2}_{#phi #phi}-#sigma^{2}_{#eta #eta}");
-        outputContainer->Add(fhPtDispEtaPhiDiff);
-        
-        fhPtSphericity  = new TH2F ("hPtSphericity","(#sigma^{2}_{#phi #phi} - #sigma^{2}_{#eta #eta}) / (#sigma^{2}_{#eta #eta} + #sigma^{2}_{#phi #phi}) vs #it{p}_{T} (GeV/#it{c})",
-                                   nptbins,ptmin,ptmax, 200, -1,1);
-        fhPtSphericity->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        fhPtSphericity->SetYTitle("s = (#sigma^{2}_{#phi #phi} - #sigma^{2}_{#eta #eta}) / (#sigma^{2}_{#eta #eta} + #sigma^{2}_{#phi #phi})");
-        outputContainer->Add(fhPtSphericity);
-        
-        for(Int_t i = 0; i < 7; i++)
-        {
-          fhDispEtaDispPhi[i] = new TH2F (Form("hDispEtaDispPhi_EBin%d",i),Form("#sigma^{2}_{#phi #phi} vs #sigma^{2}_{#eta #eta} for %d < E < %d GeV",bin[i],bin[i+1]),
-                                          ssbins,ssmin,ssmax , ssbins,ssmin,ssmax);
-          fhDispEtaDispPhi[i]->SetXTitle("#sigma^{2}_{#eta #eta}");
-          fhDispEtaDispPhi[i]->SetYTitle("#sigma^{2}_{#phi #phi}");
-          outputContainer->Add(fhDispEtaDispPhi[i]);
-          
-          fhLambda0DispEta[i] = new TH2F (Form("hLambda0DispEta_EBin%d",i),Form("#lambda^{2}_{0} vs #sigma^{2}_{#eta #eta} for %d < E < %d GeV",bin[i],bin[i+1]),
-                                          ssbins,ssmin,ssmax , ssbins,ssmin,ssmax);
-          fhLambda0DispEta[i]->SetXTitle("#lambda^{2}_{0}");
-          fhLambda0DispEta[i]->SetYTitle("#sigma^{2}_{#eta #eta}");
-          outputContainer->Add(fhLambda0DispEta[i]);
-          
-          fhLambda0DispPhi[i] = new TH2F (Form("hLambda0DispPhi_EBin%d",i),Form("#lambda^{2}_{0}} vs #sigma^{2}_{#phi #phi} for %d < E < %d GeV",bin[i],bin[i+1]),
-                                          ssbins,ssmin,ssmax , ssbins,ssmin,ssmax);
-          fhLambda0DispPhi[i]->SetXTitle("#lambda^{2}_{0}");
-          fhLambda0DispPhi[i]->SetYTitle("#sigma^{2}_{#phi #phi}");
-          outputContainer->Add(fhLambda0DispPhi[i]);
-          
-        }
+        fhPtFracMaxCellNoTRD  = new TH2F
+        ("hPtFracMaxCellNoTRD","Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #lambda_{0}, Max cell fraction of energy, not behind TRD",nptbins,ptmin,ptmax,100,0,1);
+        fhPtFracMaxCellNoTRD->SetYTitle("Fraction");
+        fhPtFracMaxCellNoTRD->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+        outputContainer->Add(fhPtFracMaxCellNoTRD) ;
       }
     }
-
+    
+    if(!fFillOnlySimpleSSHisto)
+    {
+      fhPtDispersion  = new TH2F
+      ("hPtDispersion","Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs dispersion",nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
+      fhPtDispersion->SetYTitle("D^{2}");
+      fhPtDispersion->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+      outputContainer->Add(fhPtDispersion) ;
+      
+      fhPtLambda0FracMaxCellCut  = new TH2F
+      ("hPtLambda0FracMaxCellCut","Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #lambda_{0}, Max cell fraction of energy < 0.5",nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
+      fhPtLambda0FracMaxCellCut->SetYTitle("#lambda_{0}^{2}");
+      fhPtLambda0FracMaxCellCut->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+      outputContainer->Add(fhPtLambda0FracMaxCellCut) ;
+      
+      fhPtFracMaxCell  = new TH2F
+      ("hPtFracMaxCell","Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #lambda_{0}, Max cell fraction of energy",nptbins,ptmin,ptmax,100,0,1);
+      fhPtFracMaxCell->SetYTitle("Fraction");
+      fhPtFracMaxCell->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+      outputContainer->Add(fhPtFracMaxCell) ;
+      
+      fhPtDispEta  = new TH2F ("hPtDispEta","#sigma^{2}_{#eta #eta} = #Sigma w_{i}(#eta_{i} - <#eta>)^{2}/ #Sigma w_{i} vs #it{p}_{T}",  nptbins,ptmin,ptmax, ssbins,ssmin,ssmax);
+      fhPtDispEta->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+      fhPtDispEta->SetYTitle("#sigma^{2}_{#eta #eta}");
+      outputContainer->Add(fhPtDispEta);
+      
+      fhPtDispPhi  = new TH2F ("hPtDispPhi","#sigma^{2}_{#phi #phi} = #Sigma w_{i}(#phi_{i} - <#phi>)^{2} / #Sigma w_{i} vs #it{p}_{T}",  nptbins,ptmin,ptmax, ssbins,ssmin,ssmax);
+      fhPtDispPhi->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+      fhPtDispPhi->SetYTitle("#sigma^{2}_{#phi #phi}");
+      outputContainer->Add(fhPtDispPhi);
+      
+      fhPtSumEta  = new TH2F ("hPtSumEta","#sigma^{2}_{#eta #eta} = #Sigma w_{i}(#eta_{i})^{2} / #Sigma w_{i} - <#eta>^{2} vs #it{p}_{T}",  nptbins,ptmin,ptmax, ssbins,ssmin,ssmax);
+      fhPtSumEta->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+      fhPtSumEta->SetYTitle("#delta^{2}_{#eta #eta}");
+      outputContainer->Add(fhPtSumEta);
+      
+      fhPtSumPhi  = new TH2F ("hPtSumPhi","#sigma^{2}_{#phi #phi} = #Sigma w_{i}(#phi_{i})^{2}/ #Sigma w_{i} - <#phi>^{2} vs #it{p}_{T}",
+                              nptbins,ptmin,ptmax, ssbins,ssmin,ssmax);
+      fhPtSumPhi->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+      fhPtSumPhi->SetYTitle("#delta^{2}_{#phi #phi}");
+      outputContainer->Add(fhPtSumPhi);
+      
+      fhPtSumEtaPhi  = new TH2F ("hPtSumEtaPhi","#delta^{2}_{#eta #phi} = #Sigma w_{i}(#phi_{i} #eta_{i} ) / #Sigma w_{i} - <#phi><#eta> vs #it{p}_{T}",
+                                 nptbins,ptmin,ptmax, 2*ssbins,-ssmax,ssmax);
+      fhPtSumEtaPhi->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+      fhPtSumEtaPhi->SetYTitle("#delta^{2}_{#eta #phi}");
+      outputContainer->Add(fhPtSumEtaPhi);
+      
+      fhPtDispEtaPhiDiff  = new TH2F ("hPtDispEtaPhiDiff","#sigma^{2}_{#phi #phi} - #sigma^{2}_{#eta #eta} vs #it{p}_{T}",
+                                      nptbins,ptmin,ptmax,200, -10,10);
+      fhPtDispEtaPhiDiff->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+      fhPtDispEtaPhiDiff->SetYTitle("#sigma^{2}_{#phi #phi}-#sigma^{2}_{#eta #eta}");
+      outputContainer->Add(fhPtDispEtaPhiDiff);
+      
+      fhPtSphericity  = new TH2F ("hPtSphericity","(#sigma^{2}_{#phi #phi} - #sigma^{2}_{#eta #eta}) / (#sigma^{2}_{#eta #eta} + #sigma^{2}_{#phi #phi}) vs #it{p}_{T} (GeV/#it{c})",
+                                  nptbins,ptmin,ptmax, 200, -1,1);
+      fhPtSphericity->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+      fhPtSphericity->SetYTitle("s = (#sigma^{2}_{#phi #phi} - #sigma^{2}_{#eta #eta}) / (#sigma^{2}_{#eta #eta} + #sigma^{2}_{#phi #phi})");
+      outputContainer->Add(fhPtSphericity);
+      
+      for(Int_t i = 0; i < 7; i++)
+      {
+        fhDispEtaDispPhi[i] = new TH2F (Form("hDispEtaDispPhi_EBin%d",i),Form("#sigma^{2}_{#phi #phi} vs #sigma^{2}_{#eta #eta} for %d < E < %d GeV",bin[i],bin[i+1]),
+                                        ssbins,ssmin,ssmax , ssbins,ssmin,ssmax);
+        fhDispEtaDispPhi[i]->SetXTitle("#sigma^{2}_{#eta #eta}");
+        fhDispEtaDispPhi[i]->SetYTitle("#sigma^{2}_{#phi #phi}");
+        outputContainer->Add(fhDispEtaDispPhi[i]);
+        
+        fhLambda0DispEta[i] = new TH2F (Form("hLambda0DispEta_EBin%d",i),Form("#lambda^{2}_{0} vs #sigma^{2}_{#eta #eta} for %d < E < %d GeV",bin[i],bin[i+1]),
+                                        ssbins,ssmin,ssmax , ssbins,ssmin,ssmax);
+        fhLambda0DispEta[i]->SetXTitle("#lambda^{2}_{0}");
+        fhLambda0DispEta[i]->SetYTitle("#sigma^{2}_{#eta #eta}");
+        outputContainer->Add(fhLambda0DispEta[i]);
+        
+        fhLambda0DispPhi[i] = new TH2F (Form("hLambda0DispPhi_EBin%d",i),Form("#lambda^{2}_{0}} vs #sigma^{2}_{#phi #phi} for %d < E < %d GeV",bin[i],bin[i+1]),
+                                        ssbins,ssmin,ssmax , ssbins,ssmin,ssmax);
+        fhLambda0DispPhi[i]->SetXTitle("#lambda^{2}_{0}");
+        fhLambda0DispPhi[i]->SetYTitle("#sigma^{2}_{#phi #phi}");
+        outputContainer->Add(fhLambda0DispPhi[i]);
+        
+      }
+    }
+    
     fhNLocMaxPt = new TH2F("hNLocMaxPt","Number of local maxima in cluster, selected clusters",
                            nptbins,ptmin,ptmax,20,0,20);
     fhNLocMaxPt ->SetYTitle("N maxima");
     fhNLocMaxPt ->SetXTitle("#it{p}_{T} (GeV/#it{c})");
     outputContainer->Add(fhNLocMaxPt) ;
-
-    for(Int_t iSM = 0; iSM < GetCaloUtils()->GetNumberOfSuperModulesUsed(); iSM++)
-    {
-      fhNLocMaxPtSM[iSM] = new TH2F(Form("hNLocMaxPt_SM%d",iSM),Form("Number of local maxima in cluster, selected clusters in SM %d",iSM),
-                               nptbins,ptmin,ptmax,20,0,20);
-      fhNLocMaxPtSM[iSM] ->SetYTitle("N maxima");
-      fhNLocMaxPtSM[iSM] ->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-      outputContainer->Add(fhNLocMaxPtSM[iSM]) ;
-    }
     
-    if(fAnaType == kSSCalo)
+    if(fFillAllNLMHistograms)
     {
-
-      fhNLocMaxPtReject = new TH2F("hNLocMaxPtReject","Number of local maxima in cluster, rejected clusters",
-                             nptbins,ptmin,ptmax,20,0,20);
-      fhNLocMaxPtReject ->SetYTitle("N maxima");
-      fhNLocMaxPtReject ->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-      outputContainer->Add(fhNLocMaxPtReject) ;
-    }
-    
-    for (Int_t i = 0; i < 3; i++)
-    {
-      fhPtLambda0LocMax[i]  = new TH2F(Form("hPtLambda0LocMax%d",i+1),
-                                      Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #lambda_{0}, NLM=%s",nlm[i].Data()),
-                                      nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
-      fhPtLambda0LocMax[i]->SetYTitle("#lambda_{0}^{2}");
-      fhPtLambda0LocMax[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-      outputContainer->Add(fhPtLambda0LocMax[i]) ;
-
-      if(IsDataMC())
+      for(Int_t iSM = 0; iSM < GetCaloUtils()->GetNumberOfSuperModulesUsed(); iSM++)
       {
-        for(Int_t ipart = 0; ipart < 6; ipart++)
-        {
-          fhMCPtLambda0LocMax[ipart][i]  = new TH2F
-          (Form("hPtLambda0LocMax%d_MC%s",i+1,pname[ipart].Data()),
-           Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #lambda_{0}, NLM=%s, MC %s",nlm[i].Data(),pname[ipart].Data()),
-           nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
-          fhMCPtLambda0LocMax[ipart][i]->SetYTitle("#lambda_{0}^{2}");
-          fhMCPtLambda0LocMax[ipart][i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-          outputContainer->Add(fhMCPtLambda0LocMax[ipart][i]) ;
-        }
+        fhNLocMaxPtSM[iSM] = new TH2F(Form("hNLocMaxPt_SM%d",iSM),Form("Number of local maxima in cluster, selected clusters in SM %d",iSM),
+                                      nptbins,ptmin,ptmax,20,0,20);
+        fhNLocMaxPtSM[iSM] ->SetYTitle("N maxima");
+        fhNLocMaxPtSM[iSM] ->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+        outputContainer->Add(fhNLocMaxPtSM[iSM]) ;
       }
       
-      fhPtLambda1LocMax[i]  = new TH2F(Form("hPtLambda1LocMax%d",i+1),
-                                      Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #lambda_{1}, %s",nlm[i].Data()),
-                                      nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
-      fhPtLambda1LocMax[i]->SetYTitle("#lambda_{1}^{2}");
-      fhPtLambda1LocMax[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-      outputContainer->Add(fhPtLambda1LocMax[i]) ;
-      
-      fhPtDispersionLocMax[i]  = new TH2F(Form("hPtDispersionLocMax%d",i+1),
-                                         Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs dispersion^{2}, %s",nlm[i].Data()),
-                                         nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
-      fhPtDispersionLocMax[i]->SetYTitle("dispersion^{2}");
-      fhPtDispersionLocMax[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-      outputContainer->Add(fhPtDispersionLocMax[i]) ;
-      
-      if(fCalorimeter == "EMCAL" && !fFillOnlySimpleSSHisto)
+      for (Int_t i = 0; i < 3; i++)
       {
-        fhPtDispEtaLocMax[i]  = new TH2F(Form("hPtDispEtaLocMax%d",i+1),
-                                        Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #sigma_{#eta #eta}, %s",nlm[i].Data()),
-                                        nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
-        fhPtDispEtaLocMax[i]->SetYTitle("#sigma_{#eta #eta}");
-        fhPtDispEtaLocMax[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        outputContainer->Add(fhPtDispEtaLocMax[i]) ;
-        
-        fhPtDispPhiLocMax[i]  = new TH2F(Form("hPtDispPhiLocMax%d",i+1),
-                                        Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #sigma_{#phi #phi}, %s",nlm[i].Data()),
-                                        nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
-        fhPtDispPhiLocMax[i]->SetYTitle("#sigma_{#phi #phi}");
-        fhPtDispPhiLocMax[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        outputContainer->Add(fhPtDispPhiLocMax[i]) ;
-        
-        fhPtSumEtaPhiLocMax[i]  = new TH2F(Form("hPtSumEtaPhiLocMax%d",i+1),
-                                          Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #sigma_{#eta #phi}, %s",nlm[i].Data()),
-                                          nptbins,ptmin,ptmax,2*ssbins,-ssmax,ssmax);
-        fhPtSumEtaPhiLocMax[i]->SetYTitle("#sigma_{#eta #phi}");
-        fhPtSumEtaPhiLocMax[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        outputContainer->Add(fhPtSumEtaPhiLocMax[i]) ;
-        
-        fhPtDispEtaPhiDiffLocMax[i]  = new TH2F(Form("hPtDispEtaPhiDiffLocMax%d",i+1),
-                                               Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #sigma_{#phi #phi} - #sigma_{#eta #eta}, %s",nlm[i].Data()),
-                                               nptbins,ptmin,ptmax,200, -10,10);
-        fhPtDispEtaPhiDiffLocMax[i]->SetYTitle("#sigma_{#phi #phi} - #sigma_{#eta #eta}");
-        fhPtDispEtaPhiDiffLocMax[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        outputContainer->Add(fhPtDispEtaPhiDiffLocMax[i]) ;
-        
-        fhPtSphericityLocMax[i]  = new TH2F(Form("hPtSphericityLocMax%d",i+1),
-                                           Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #sigma_{#phi #phi} - #sigma_{#eta #eta} / (#sigma_{#phi #phi} + #sigma_{#eta #eta}), %s",nlm[i].Data()),
-                                           nptbins,ptmin,ptmax,200, -1,1);
-        fhPtSphericityLocMax[i]->SetYTitle("#sigma_{#phi #phi} - #sigma_{#eta #eta} / (#sigma_{#phi #phi} + #sigma_{#eta #eta})");
-        fhPtSphericityLocMax[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        outputContainer->Add(fhPtSphericityLocMax[i]) ;
+        fhPtLambda0LocMax[i]  = new TH2F(Form("hPtLambda0LocMax%d",i+1),
+                                         Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #lambda_{0}, NLM=%s",nlm[i].Data()),
+                                         nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
+        fhPtLambda0LocMax[i]->SetYTitle("#lambda_{0}^{2}");
+        fhPtLambda0LocMax[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+        outputContainer->Add(fhPtLambda0LocMax[i]) ;
+        
+        if(IsDataMC())
+        {
+          for(Int_t ipart = 0; ipart < fgkNmcTypes; ipart++)
+          {
+            fhMCPtLambda0LocMax[ipart][i]  = new TH2F
+            (Form("hPtLambda0LocMax%d_MC%s",i+1,pname[ipart].Data()),
+             Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #lambda_{0}, NLM=%s, MC %s",nlm[i].Data(),ptype[ipart].Data()),
+             nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
+            fhMCPtLambda0LocMax[ipart][i]->SetYTitle("#lambda_{0}^{2}");
+            fhMCPtLambda0LocMax[ipart][i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+            outputContainer->Add(fhMCPtLambda0LocMax[ipart][i]) ;
+          }
+        }
+        
+        fhPtLambda1LocMax[i]  = new TH2F(Form("hPtLambda1LocMax%d",i+1),
+                                         Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #lambda_{1}, %s",nlm[i].Data()),
+                                         nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
+        fhPtLambda1LocMax[i]->SetYTitle("#lambda_{1}^{2}");
+        fhPtLambda1LocMax[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+        outputContainer->Add(fhPtLambda1LocMax[i]) ;
+        
+        if(GetCalorimeter() == kEMCAL && !fFillOnlySimpleSSHisto)
+        {
+          fhPtDispersionLocMax[i]  = new TH2F(Form("hPtDispersionLocMax%d",i+1),
+                                              Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs dispersion^{2}, %s",nlm[i].Data()),
+                                              nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
+          fhPtDispersionLocMax[i]->SetYTitle("dispersion^{2}");
+          fhPtDispersionLocMax[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+          outputContainer->Add(fhPtDispersionLocMax[i]) ;
+          
+          fhPtDispEtaLocMax[i]  = new TH2F(Form("hPtDispEtaLocMax%d",i+1),
+                                           Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #sigma_{#eta #eta}, %s",nlm[i].Data()),
+                                           nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
+          fhPtDispEtaLocMax[i]->SetYTitle("#sigma_{#eta #eta}");
+          fhPtDispEtaLocMax[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+          outputContainer->Add(fhPtDispEtaLocMax[i]) ;
+          
+          fhPtDispPhiLocMax[i]  = new TH2F(Form("hPtDispPhiLocMax%d",i+1),
+                                           Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #sigma_{#phi #phi}, %s",nlm[i].Data()),
+                                           nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
+          fhPtDispPhiLocMax[i]->SetYTitle("#sigma_{#phi #phi}");
+          fhPtDispPhiLocMax[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+          outputContainer->Add(fhPtDispPhiLocMax[i]) ;
+          
+          fhPtSumEtaPhiLocMax[i]  = new TH2F(Form("hPtSumEtaPhiLocMax%d",i+1),
+                                             Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #sigma_{#eta #phi}, %s",nlm[i].Data()),
+                                             nptbins,ptmin,ptmax,2*ssbins,-ssmax,ssmax);
+          fhPtSumEtaPhiLocMax[i]->SetYTitle("#sigma_{#eta #phi}");
+          fhPtSumEtaPhiLocMax[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+          outputContainer->Add(fhPtSumEtaPhiLocMax[i]) ;
+          
+          fhPtDispEtaPhiDiffLocMax[i]  = new TH2F(Form("hPtDispEtaPhiDiffLocMax%d",i+1),
+                                                  Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #sigma_{#phi #phi} - #sigma_{#eta #eta}, %s",nlm[i].Data()),
+                                                  nptbins,ptmin,ptmax,200, -10,10);
+          fhPtDispEtaPhiDiffLocMax[i]->SetYTitle("#sigma_{#phi #phi} - #sigma_{#eta #eta}");
+          fhPtDispEtaPhiDiffLocMax[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+          outputContainer->Add(fhPtDispEtaPhiDiffLocMax[i]) ;
+          
+          fhPtSphericityLocMax[i]  = new TH2F(Form("hPtSphericityLocMax%d",i+1),
+                                              Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #sigma_{#phi #phi} - #sigma_{#eta #eta} / (#sigma_{#phi #phi} + #sigma_{#eta #eta}), %s",nlm[i].Data()),
+                                              nptbins,ptmin,ptmax,200, -1,1);
+          fhPtSphericityLocMax[i]->SetYTitle("#sigma_{#phi #phi} - #sigma_{#eta #eta} / (#sigma_{#phi #phi} + #sigma_{#eta #eta})");
+          fhPtSphericityLocMax[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+          outputContainer->Add(fhPtSphericityLocMax[i]) ;
+        }
       }
-      
-    }
+    } // all NLM histos
     
     fhPtNCells  = new TH2F ("hPtNCells","N cells in cluster vs E ", nptbins,ptmin,ptmax, nbins,nmin,nmax);
     fhPtNCells->SetXTitle("#it{p}_{T} (GeV/#it{c})");
@@ -1364,11 +1474,13 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
     
   }
   
-  
-  fhEPairDiffTime = new TH2F("hEPairDiffTime","cluster pair time difference vs E",nptbins,ptmin,ptmax, tdbins,tdmin,tdmax);
-  fhEPairDiffTime->SetXTitle("#it{E}_{pair} (GeV)");
-  fhEPairDiffTime->SetYTitle("#Delta t (ns)");
-  outputContainer->Add(fhEPairDiffTime);
+  if(fAnaType != kIMCaloTracks)
+  {
+    fhEPairDiffTime = new TH2F("hEPairDiffTime","cluster pair time difference vs E",nptbins,ptmin,ptmax, tdbins,tdmin,tdmax);
+    fhEPairDiffTime->SetXTitle("#it{E}_{pair} (GeV)");
+    fhEPairDiffTime->SetYTitle("#Delta t (ns)");
+    outputContainer->Add(fhEPairDiffTime);
+  }
   
   if(fAnaType == kIMCalo)
   {
@@ -1378,18 +1490,20 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
       "2 Local Maxima paired with more than 2 Local Maxima",
       "1 Local Maxima paired with #lambda_{0}^{2}>0.3","N Local Maxima paired with 0.1<#lambda_{0}^{2}<0.3"};
     
-    for (Int_t i = 0; i < 8 ; i++)
+    if(fFillAllNLMHistograms)
     {
-      
-      if (fAnaType == kIMCaloTracks && i > 2 ) continue ;
-      
-      fhMassPairLocMax[i]  = new TH2F
-      (Form("MassPairLocMax%s",combiName[i].Data()),
-       Form("#it{M} for decay #gamma pair vs #it{E}_{pair}, origin #pi^{0}, %s", combiTitle[i].Data()),
-       nptbins,ptmin,ptmax,nmassbins,massmin,massmax);
-      fhMassPairLocMax[i]->SetYTitle("#it{M} (GeV/#it{c}^{2})");
-      fhMassPairLocMax[i]->SetXTitle("#it{E}_{pair} (GeV)");
-      outputContainer->Add(fhMassPairLocMax[i]) ;
+      for (Int_t i = 0; i < 8 ; i++)
+      {
+        if (fAnaType == kIMCaloTracks && i > 2 ) continue ;
+        
+        fhMassPairLocMax[i]  = new TH2F
+        (Form("MassPairLocMax%s",combiName[i].Data()),
+         Form("#it{M} for decay #gamma pair vs #it{E}_{pair}, origin #pi^{0}, %s", combiTitle[i].Data()),
+         nptbins,ptmin,ptmax,nmassbins,massmin,massmax);
+        fhMassPairLocMax[i]->SetYTitle("#it{M} (GeV/#it{c}^{2})");
+        fhMassPairLocMax[i]->SetXTitle("#it{E}_{pair} (GeV)");
+        outputContainer->Add(fhMassPairLocMax[i]) ;
+      }
     }
   }
   
@@ -1419,7 +1533,7 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
     outputContainer->Add(fhTrackMatchedDEta) ;
     outputContainer->Add(fhTrackMatchedDPhi) ;
     outputContainer->Add(fhTrackMatchedDEtaDPhi) ;
-
+    
     fhTrackMatchedDEtaPos  = new TH2F
     ("hTrackMatchedDEtaPos",
      "d#eta of cluster-track vs cluster #it{p}_{T}",
@@ -1444,7 +1558,7 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
     outputContainer->Add(fhTrackMatchedDEtaPos) ;
     outputContainer->Add(fhTrackMatchedDPhiPos) ;
     outputContainer->Add(fhTrackMatchedDEtaDPhiPos) ;
-
+    
     fhTrackMatchedDEtaNeg  = new TH2F
     ("hTrackMatchedDEtaNeg",
      "d#eta of cluster-track vs cluster #it{p}_{T}",
@@ -1480,7 +1594,7 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
     fhEOverP->SetYTitle("#it{E}/#it{p}");
     outputContainer->Add(fhEOverP);
     
-    if(fCalorimeter=="EMCAL" &&  GetFirstSMCoveredByTRD() >=0)
+    if(GetCalorimeter()==kEMCAL &&  GetFirstSMCoveredByTRD() >=0)
     {
       fhEOverPNoTRD  = new TH2F ("hEOverPNoTRD","matched track E/p vs cluster E, SM not behind TRD ", nptbins,ptmin,ptmax,nPoverEbins,pOverEmin,pOverEmax);
       fhEOverPNoTRD->SetXTitle("#it{E} (GeV)");
@@ -1543,8 +1657,6 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
       fhTrackMatchedMCParticleDPhi->GetYaxis()->SetBinLabel(8 ,"Conv. Rest");
       
       outputContainer->Add(fhTrackMatchedMCParticleDPhi);
-      
-      
     }
   }
   
@@ -1671,13 +1783,10 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
       fhMCOtherDecayPt->SetYTitle("#it{N}");
       fhMCOtherDecayPt->SetXTitle("#it{p}^{rec}_{T} (GeV/#it{c})");
       outputContainer->Add(fhMCOtherDecayPt) ;
-      
     }
     
-    if((GetReader()->GetDataType() == AliCaloTrackReader::kMC && fAnaType!=kSSCalo) ||
-       GetReader()->GetDataType() != AliCaloTrackReader::kMC)
+    if(fAnaType!=kSSCalo)
     {
-      
       fhAnglePairMCPi0  = new TH2F
       ("AnglePairMCPi0",
        "Angle between decay #gamma pair vs #it{E}_{pair}, origin #pi^{0}",nptbins,ptmin,ptmax,250,0,0.5);
@@ -1685,51 +1794,53 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
       fhAnglePairMCPi0->SetXTitle("#it{E}_{pair} (GeV)");
       outputContainer->Add(fhAnglePairMCPi0) ;
       
-      if (fAnaType!= kSSCalo)
-      {
-        fhAnglePairMCEta  = new TH2F
-        ("AnglePairMCEta",
-         "Angle between decay #gamma pair vs #it{E}_{pair}, origin #eta",nptbins,ptmin,ptmax,250,0,0.5);
-        fhAnglePairMCEta->SetYTitle("#alpha (rad)");
-        fhAnglePairMCEta->SetXTitle("#it{E}_{pair} (GeV)");
-        outputContainer->Add(fhAnglePairMCEta) ;
-        
-        fhMassPairMCPi0  = new TH2F
-        ("MassPairMCPi0",
-         "#it{M} for decay #gamma pair vs #it{E}_{pair}, origin #pi^{0}",nptbins,ptmin,ptmax,nmassbins,massmin,massmax);
-        fhMassPairMCPi0->SetYTitle("#it{M} (GeV/#it{c}^{2})");
-        fhMassPairMCPi0->SetXTitle("#it{E}_{pair} (GeV)");
-        outputContainer->Add(fhMassPairMCPi0) ;
-        
-        fhMassPairMCEta  = new TH2F
-        ("MassPairMCEta",
-         "#it{M} for decay #gamma pair vs #it{E}_{pair}, origin #eta",nptbins,ptmin,ptmax,nmassbins,massmin,massmax);
-        fhMassPairMCEta->SetYTitle("#it{M} (GeV/#it{c}^{2})");
-        fhMassPairMCEta->SetXTitle("#it{E}_{pair} (GeV)");
-        outputContainer->Add(fhMassPairMCEta) ;
-      }
-      
-      for(Int_t i = 0; i < 6; i++)
+      fhAnglePairMCEta  = new TH2F
+      ("AnglePairMCEta",
+       "Angle between decay #gamma pair vs #it{E}_{pair}, origin #eta",nptbins,ptmin,ptmax,250,0,0.5);
+      fhAnglePairMCEta->SetYTitle("#alpha (rad)");
+      fhAnglePairMCEta->SetXTitle("#it{E}_{pair} (GeV)");
+      outputContainer->Add(fhAnglePairMCEta) ;
+      
+      fhMassPairMCPi0  = new TH2F
+      ("MassPairMCPi0",
+       "#it{M} for decay #gamma pair vs #it{E}_{pair}, origin #pi^{0}",nptbins,ptmin,ptmax,nmassbins,massmin,massmax);
+      fhMassPairMCPi0->SetYTitle("#it{M} (GeV/#it{c}^{2})");
+      fhMassPairMCPi0->SetXTitle("#it{E}_{pair} (GeV)");
+      outputContainer->Add(fhMassPairMCPi0) ;
+      
+      fhMassPairMCEta  = new TH2F
+      ("MassPairMCEta",
+       "#it{M} for decay #gamma pair vs #it{E}_{pair}, origin #eta",nptbins,ptmin,ptmax,nmassbins,massmin,massmax);
+      fhMassPairMCEta->SetYTitle("#it{M} (GeV/#it{c}^{2})");
+      fhMassPairMCEta->SetXTitle("#it{E}_{pair} (GeV)");
+      outputContainer->Add(fhMassPairMCEta) ;
+    }
+    
+    Int_t ntypes = fgkNmcTypes;
+    if(fAnaType != kSSCalo) ntypes = 2;
+  
+    for(Int_t i = 0; i < ntypes; i++)
+    {
+      fhMCE[i]  = new TH1F
+      (Form("hE_MC%s",pname[i].Data()),
+       Form("Identified as #pi^{0} (#eta), cluster from %s",
+            ptype[i].Data()),
+       nptbins,ptmin,ptmax);
+      fhMCE[i]->SetYTitle("#it{N}");
+      fhMCE[i]->SetXTitle("#it{E} (GeV)");
+      outputContainer->Add(fhMCE[i]) ;
+      
+      fhMCPt[i]  = new TH1F
+      (Form("hPt_MC%s",pname[i].Data()),
+       Form("Identified as #pi^{0} (#eta), cluster from %s",
+            ptype[i].Data()),
+       nptbins,ptmin,ptmax);
+      fhMCPt[i]->SetYTitle("#it{N}");
+      fhMCPt[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+      outputContainer->Add(fhMCPt[i]) ;
+      
+      if(IsHighMultiplicityAnalysisOn())
       {
-        
-        fhMCE[i]  = new TH1F
-        (Form("hE_MC%s",pname[i].Data()),
-         Form("Identified as #pi^{0} (#eta), cluster from %s",
-              ptype[i].Data()),
-         nptbins,ptmin,ptmax);
-        fhMCE[i]->SetYTitle("#it{N}");
-        fhMCE[i]->SetXTitle("#it{E} (GeV)");
-        outputContainer->Add(fhMCE[i]) ;
-        
-        fhMCPt[i]  = new TH1F
-        (Form("hPt_MC%s",pname[i].Data()),
-         Form("Identified as #pi^{0} (#eta), cluster from %s",
-              ptype[i].Data()),
-         nptbins,ptmin,ptmax);
-        fhMCPt[i]->SetYTitle("#it{N}");
-        fhMCPt[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        outputContainer->Add(fhMCPt[i]) ;
-        
         fhMCPtCentrality[i]  = new TH2F
         (Form("hPtCentrality_MC%s",pname[i].Data()),
          Form("Identified as #pi^{0} (#eta), cluster from %s",
@@ -1738,209 +1849,208 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
         fhMCPtCentrality[i]->SetYTitle("centrality");
         fhMCPtCentrality[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
         outputContainer->Add(fhMCPtCentrality[i]) ;
+      }
+      
+      if(fAnaType == kSSCalo)
+      {
+        fhMCNLocMaxPt[i] = new TH2F
+        (Form("hNLocMaxPt_MC%s",pname[i].Data()),
+         Form("cluster from %s, #it{p}_{T} of cluster vs NLM, accepted",ptype[i].Data()),
+         nptbins,ptmin,ptmax,20,0,20);
+        fhMCNLocMaxPt[i] ->SetYTitle("#it{NLM}");
+        fhMCNLocMaxPt[i] ->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+        outputContainer->Add(fhMCNLocMaxPt[i]) ;
+
+        fhMCNLocMaxPtReject[i] = new TH2F
+        (Form("hNLocMaxPtReject_MC%s",pname[i].Data()),
+         Form("cluster from %s, #it{p}_{T} of cluster vs NLM, rejected",ptype[i].Data()),
+         nptbins,ptmin,ptmax,20,0,20);
+        fhMCNLocMaxPtReject[i] ->SetYTitle("#it{NLM}");
+        fhMCNLocMaxPtReject[i] ->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+        outputContainer->Add(fhMCNLocMaxPtReject[i]) ;
         
-        if(fAnaType == kSSCalo)
-        {
-          fhMCNLocMaxPt[i] = new TH2F
-          (Form("hNLocMaxPt_MC%s",pname[i].Data()),
-           Form("cluster from %s, #it{p}_{T} of cluster vs NLM, accepted",ptype[i].Data()),
-           nptbins,ptmin,ptmax,20,0,20);
-          fhMCNLocMaxPt[i] ->SetYTitle("#it{NLM}");
-          fhMCNLocMaxPt[i] ->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-          outputContainer->Add(fhMCNLocMaxPt[i]) ;
-          fhMCNLocMaxPtReject[i] = new TH2F
-          (Form("hNLocMaxPtReject_MC%s",pname[i].Data()),
-           Form("cluster from %s, #it{p}_{T} of cluster vs NLM, rejected",ptype[i].Data()),
-           nptbins,ptmin,ptmax,20,0,20);
-          fhMCNLocMaxPtReject[i] ->SetYTitle("#it{NLM}");
-          fhMCNLocMaxPtReject[i] ->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-          outputContainer->Add(fhMCNLocMaxPtReject[i]) ;
-          
-          fhMCEReject[i]  = new TH1F
-          (Form("hEReject_MC%s",pname[i].Data()),
-           Form("Rejected as #pi^{0} (#eta), cluster from %s",
-                ptype[i].Data()),
-           nptbins,ptmin,ptmax);
-          fhMCEReject[i]->SetYTitle("#it{N}");
-          fhMCEReject[i]->SetXTitle("#it{E} (GeV)");
-          outputContainer->Add(fhMCEReject[i]) ;
-          
-          fhMCPtReject[i]  = new TH1F
-          (Form("hPtReject_MC%s",pname[i].Data()),
-           Form("Rejected as #pi^{0} (#eta), cluster from %s",
-                ptype[i].Data()),
-           nptbins,ptmin,ptmax);
-          fhMCPtReject[i]->SetYTitle("#it{N}");
-          fhMCPtReject[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-          outputContainer->Add(fhMCPtReject[i]) ;
-        }
-        
-        fhMCPtPhi[i]  = new TH2F
-        (Form("hPtPhi_MC%s",pname[i].Data()),
-         Form("Identified as #pi^{0} (#eta), cluster from %s",ptype[i].Data()),
-         nptbins,ptmin,ptmax,nphibins,phimin,phimax);
-        fhMCPtPhi[i]->SetYTitle("#phi");
-        fhMCPtPhi[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        outputContainer->Add(fhMCPtPhi[i]) ;
-        
-        fhMCPtEta[i]  = new TH2F
-        (Form("hPtEta_MC%s",pname[i].Data()),
-         Form("Identified as #pi^{0} (#eta), cluster from %s",
-              ptype[i].Data()),nptbins,ptmin,ptmax,netabins,etamin,etamax);
-        fhMCPtEta[i]->SetYTitle("#eta");
-        fhMCPtEta[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        outputContainer->Add(fhMCPtEta[i]) ;
+        fhMCEReject[i]  = new TH1F
+        (Form("hEReject_MC%s",pname[i].Data()),
+         Form("Rejected as #pi^{0} (#eta), cluster from %s",
+              ptype[i].Data()),
+         nptbins,ptmin,ptmax);
+        fhMCEReject[i]->SetYTitle("#it{N}");
+        fhMCEReject[i]->SetXTitle("#it{E} (GeV)");
+        outputContainer->Add(fhMCEReject[i]) ;
         
-        fhMCMassPt[i]  = new TH2F
-        (Form("hMassPt_MC%s",pname[i].Data()),
-         Form("all pairs #it{M}: #it{p}_{T} vs #it{M} from %s",ptype[i].Data()),
+        fhMCPtReject[i]  = new TH1F
+        (Form("hPtReject_MC%s",pname[i].Data()),
+         Form("Rejected as #pi^{0} (#eta), cluster from %s",
+              ptype[i].Data()),
+         nptbins,ptmin,ptmax);
+        fhMCPtReject[i]->SetYTitle("#it{N}");
+        fhMCPtReject[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+        outputContainer->Add(fhMCPtReject[i]) ;
+      }
+      
+      fhMCPtPhi[i]  = new TH2F
+      (Form("hPtPhi_MC%s",pname[i].Data()),
+       Form("Identified as #pi^{0} (#eta), cluster from %s",ptype[i].Data()),
+       nptbins,ptmin,ptmax,nphibins,phimin,phimax);
+      fhMCPtPhi[i]->SetYTitle("#phi");
+      fhMCPtPhi[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+      outputContainer->Add(fhMCPtPhi[i]) ;
+      
+      fhMCPtEta[i]  = new TH2F
+      (Form("hPtEta_MC%s",pname[i].Data()),
+       Form("Identified as #pi^{0} (#eta), cluster from %s",
+            ptype[i].Data()),nptbins,ptmin,ptmax,netabins,etamin,etamax);
+      fhMCPtEta[i]->SetYTitle("#eta");
+      fhMCPtEta[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+      outputContainer->Add(fhMCPtEta[i]) ;
+      
+      fhMCMassPt[i]  = new TH2F
+      (Form("hMassPt_MC%s",pname[i].Data()),
+       Form("all pairs #it{M}: #it{p}_{T} vs #it{M} from %s",ptype[i].Data()),
+       nptbins,ptmin,ptmax, nmassbins,massmin,massmax);
+      fhMCMassPt[i]->SetYTitle("#it{M} (GeV/#it{c}^{2})");
+      fhMCMassPt[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+      outputContainer->Add(fhMCMassPt[i]) ;
+      
+      fhMCSelectedMassPt[i]  = new TH2F
+      (Form("hSelectedMassPt_MC%s",pname[i].Data()),
+       Form("Selected #pi^{0} (#eta) pairs #it{M}: #it{p}_{T} vs #it{M} from %s",ptype[i].Data()),
+       nptbins,ptmin,ptmax, nmassbins,massmin,massmax);
+      fhMCSelectedMassPt[i]->SetYTitle("#it{M} (GeV/#it{c}^{2})");
+      fhMCSelectedMassPt[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+      outputContainer->Add(fhMCSelectedMassPt[i]) ;
+      
+      if(fAnaType == kSSCalo)
+      {
+        fhMCMassPtNoOverlap[i]  = new TH2F
+        (Form("hMassPtNoOverlap_MC%s",pname[i].Data()),
+         Form("all pairs #it{M}: #it{p}_{T} vs #it{M} from %s, no overlap",ptype[i].Data()),
          nptbins,ptmin,ptmax, nmassbins,massmin,massmax);
         fhMCMassPt[i]->SetYTitle("#it{M} (GeV/#it{c}^{2})");
         fhMCMassPt[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        outputContainer->Add(fhMCMassPt[i]) ;
+        outputContainer->Add(fhMCMassPtNoOverlap[i]) ;
         
-        fhMCSelectedMassPt[i]  = new TH2F
-        (Form("hSelectedMassPt_MC%s",pname[i].Data()),
-         Form("Selected #pi^{0} (#eta) pairs #it{M}: #it{p}_{T} vs #it{M} from %s",ptype[i].Data()),
+        fhMCSelectedMassPtNoOverlap[i]  = new TH2F
+        (Form("hSelectedMassPtNoOverlap_MC%s",pname[i].Data()),
+         Form("Selected #pi^{0} (#eta) pairs #it{M}: #it{p}_{T} vs #it{M} from %s, no overlap",ptype[i].Data()),
          nptbins,ptmin,ptmax, nmassbins,massmin,massmax);
-        fhMCSelectedMassPt[i]->SetYTitle("#it{M} (GeV/#it{c}^{2})");
-        fhMCSelectedMassPt[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-        outputContainer->Add(fhMCSelectedMassPt[i]) ;
-        
-        if(fAnaType == kSSCalo)
+        fhMCSelectedMassPtNoOverlap[i]->SetYTitle("#it{M} (GeV/#it{c}^{2})");
+        fhMCSelectedMassPtNoOverlap[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+        outputContainer->Add(fhMCSelectedMassPtNoOverlap[i]) ;
+      }
+      
+      if( fFillSelectClHisto )
+      {
+        fhMCPtLambda0[i]  = new TH2F(Form("hELambda0_MC%s",pname[i].Data()),
+                                     Form("Selected pair, cluster from %s : #it{p}_{T} vs #lambda_{0}^{2}",ptype[i].Data()),
+                                     nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
+        fhMCPtLambda0[i]->SetYTitle("#lambda_{0}^{2}");
+        fhMCPtLambda0[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+        outputContainer->Add(fhMCPtLambda0[i]) ;
+        
+        fhMCPtLambda1[i]  = new TH2F(Form("hELambda1_MC%s",pname[i].Data()),
+                                     Form("Selected pair, cluster from %s : #it{p}_{T} vs #lambda_{1}^{2}",ptype[i].Data()),
+                                     nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
+        fhMCPtLambda1[i]->SetYTitle("#lambda_{1}^{2}");
+        fhMCPtLambda1[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+        outputContainer->Add(fhMCPtLambda1[i]) ;
+        
+        if(GetCalorimeter()==kEMCAL &&  GetFirstSMCoveredByTRD() >= 0)
         {
-          fhMCMassPtNoOverlap[i]  = new TH2F
-          (Form("hMassPtNoOverlap_MC%s",pname[i].Data()),
-           Form("all pairs #it{M}: #it{p}_{T} vs #it{M} from %s, no overlap",ptype[i].Data()),
-           nptbins,ptmin,ptmax, nmassbins,massmin,massmax);
-          fhMCMassPt[i]->SetYTitle("#it{M} (GeV/#it{c}^{2})");
-          fhMCMassPt[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-          outputContainer->Add(fhMCMassPtNoOverlap[i]) ;
-          
-          fhMCSelectedMassPtNoOverlap[i]  = new TH2F
-          (Form("hSelectedMassPtNoOverlap_MC%s",pname[i].Data()),
-           Form("Selected #pi^{0} (#eta) pairs #it{M}: #it{p}_{T} vs #it{M} from %s, no overlap",ptype[i].Data()),
-           nptbins,ptmin,ptmax, nmassbins,massmin,massmax);
-          fhMCSelectedMassPtNoOverlap[i]->SetYTitle("#it{M} (GeV/#it{c}^{2})");
-          fhMCSelectedMassPtNoOverlap[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-          outputContainer->Add(fhMCSelectedMassPtNoOverlap[i]) ;
+          fhMCPtLambda0NoTRD[i]  = new TH2F(Form("hELambda0NoTRD_MC%s",pname[i].Data()),
+                                            Form("Selected pair, cluster from %s : #it{p}_{T} vs #lambda_{0}^{2}, NoTRD",ptype[i].Data()),
+                                            nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
+          fhMCPtLambda0NoTRD[i]->SetYTitle("#lambda_{0}^{2}");
+          fhMCPtLambda0NoTRD[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+          outputContainer->Add(fhMCPtLambda0NoTRD[i]) ;
         }
         
-        if( fFillSelectClHisto )
+        if(!fFillOnlySimpleSSHisto)
         {
-          fhMCPtLambda0[i]  = new TH2F(Form("hELambda0_MC%s",pname[i].Data()),
-                                      Form("Selected pair, cluster from %s : #it{p}_{T} vs #lambda_{0}^{2}",ptype[i].Data()),
-                                      nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
-          fhMCPtLambda0[i]->SetYTitle("#lambda_{0}^{2}");
-          fhMCPtLambda0[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-          outputContainer->Add(fhMCPtLambda0[i]) ;
-          
-          fhMCPtLambda1[i]  = new TH2F(Form("hELambda1_MC%s",pname[i].Data()),
-                                      Form("Selected pair, cluster from %s : #it{p}_{T} vs #lambda_{1}^{2}",ptype[i].Data()),
-                                      nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
-          fhMCPtLambda1[i]->SetYTitle("#lambda_{1}^{2}");
-          fhMCPtLambda1[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-          outputContainer->Add(fhMCPtLambda1[i]) ;
-          
           fhMCPtDispersion[i]  = new TH2F(Form("hEDispersion_MC%s",pname[i].Data()),
-                                         Form("Selected pair, cluster from %s : #it{p}_{T} vs dispersion^{2}",ptype[i].Data()),
-                                         nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
+                                          Form("Selected pair, cluster from %s : #it{p}_{T} vs dispersion^{2}",ptype[i].Data()),
+                                          nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
           fhMCPtDispersion[i]->SetYTitle("#it{D}^{2}");
           fhMCPtDispersion[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
           outputContainer->Add(fhMCPtDispersion[i]) ;
           
-          if(fCalorimeter=="EMCAL" &&  GetFirstSMCoveredByTRD() >= 0)
+          fhMCPtDispEta[i]  = new TH2F (Form("hPtDispEta_MC%s",pname[i].Data()),
+                                        Form("cluster from %s : #sigma^{2}_{#eta #eta} = #Sigma w_{i}(#eta_{i} - <#eta>)^{2}/ #Sigma w_{i} vs #it{p}_{T}",ptype[i].Data()),
+                                        nptbins,ptmin,ptmax, ssbins,ssmin,ssmax);
+          fhMCPtDispEta[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+          fhMCPtDispEta[i]->SetYTitle("#sigma^{2}_{#eta #eta}");
+          outputContainer->Add(fhMCPtDispEta[i]);
+          
+          fhMCPtDispPhi[i]  = new TH2F (Form("hPtDispPhi_MC%s",pname[i].Data()),
+                                        Form("cluster from %s : #sigma^{2}_{#phi #phi} = #Sigma w_{i}(#phi_{i} - <#phi>)^{2} / #Sigma w_{i} vs #it{p}_{T}",ptype[i].Data()),
+                                        nptbins,ptmin,ptmax, ssbins,ssmin,ssmax);
+          fhMCPtDispPhi[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+          fhMCPtDispPhi[i]->SetYTitle("#sigma^{2}_{#phi #phi}");
+          outputContainer->Add(fhMCPtDispPhi[i]);
+          
+          fhMCPtSumEtaPhi[i]  = new TH2F (Form("hPtSumEtaPhi_MC%s",pname[i].Data()),
+                                          Form("cluster from %s : #delta^{2}_{#eta #phi} = #Sigma w_{i}(#phi_{i} #eta_{i} ) / #Sigma w_{i} - <#phi><#eta> vs #it{p}_{T}",ptype[i].Data()),
+                                          nptbins,ptmin,ptmax, 2*ssbins,-ssmax,ssmax);
+          fhMCPtSumEtaPhi[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+          fhMCPtSumEtaPhi[i]->SetYTitle("#delta^{2}_{#eta #phi}");
+          outputContainer->Add(fhMCPtSumEtaPhi[i]);
+          
+          fhMCPtDispEtaPhiDiff[i]  = new TH2F (Form("hPtDispEtaPhiDiff_MC%s",pname[i].Data()),
+                                               Form("cluster from %s : #sigma^{2}_{#phi #phi} - #sigma^{2}_{#eta #eta} vs #it{p}_{T}",ptype[i].Data()),
+                                               nptbins,ptmin,ptmax,200,-10,10);
+          fhMCPtDispEtaPhiDiff[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+          fhMCPtDispEtaPhiDiff[i]->SetYTitle("#sigma^{2}_{#phi #phi}-#sigma^{2}_{#eta #eta}");
+          outputContainer->Add(fhMCPtDispEtaPhiDiff[i]);
+          
+          fhMCPtSphericity[i]  = new TH2F (Form("hPtSphericity_MC%s",pname[i].Data()),
+                                           Form("cluster from %s : (#sigma^{2}_{#phi #phi} - #sigma^{2}_{#eta #eta}) / (#sigma^{2}_{#eta #eta} + #sigma^{2}_{#phi #phi}) vs E",ptype[i].Data()),
+                                           nptbins,ptmin,ptmax, 200,-1,1);
+          fhMCPtSphericity[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
+          fhMCPtSphericity[i]->SetYTitle("#it{s} = (#sigma^{2}_{#phi #phi} - #sigma^{2}_{#eta #eta}) / (#sigma^{2}_{#eta #eta} + #sigma^{2}_{#phi #phi})");
+          outputContainer->Add(fhMCPtSphericity[i]);
+          
+          for(Int_t ie = 0; ie < 7; ie++)
           {
-            fhMCPtLambda0NoTRD[i]  = new TH2F(Form("hELambda0NoTRD_MC%s",pname[i].Data()),
-                                             Form("Selected pair, cluster from %s : #it{p}_{T} vs #lambda_{0}^{2}, NoTRD",ptype[i].Data()),
-                                             nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
-            fhMCPtLambda0NoTRD[i]->SetYTitle("#lambda_{0}^{2}");
-            fhMCPtLambda0NoTRD[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-            outputContainer->Add(fhMCPtLambda0NoTRD[i]) ;
+            fhMCDispEtaDispPhi[ie][i] = new TH2F (Form("hMCDispEtaDispPhi_EBin%d_MC%s",ie,pname[i].Data()),
+                                                  Form("cluster from %s : #sigma^{2}_{#phi #phi} vs #sigma^{2}_{#eta #eta} for %d < E < %d GeV",ptype[i].Data(),bin[ie],bin[ie+1]),
+                                                  ssbins,ssmin,ssmax , ssbins,ssmin,ssmax);
+            fhMCDispEtaDispPhi[ie][i]->SetXTitle("#sigma^{2}_{#eta #eta}");
+            fhMCDispEtaDispPhi[ie][i]->SetYTitle("#sigma^{2}_{#phi #phi}");
+            outputContainer->Add(fhMCDispEtaDispPhi[ie][i]);
+            
+            fhMCLambda0DispEta[ie][i] = new TH2F (Form("hMCLambda0DispEta_EBin%d_MC%s",ie,pname[i].Data()),
+                                                  Form("cluster from %s : #lambda^{2}_{0} vs #sigma^{2}_{#eta #eta} for %d < E < %d GeV",ptype[i].Data(),bin[ie],bin[ie+1]),
+                                                  ssbins,ssmin,ssmax , ssbins,ssmin,ssmax);
+            fhMCLambda0DispEta[ie][i]->SetXTitle("#lambda^{2}_{0}");
+            fhMCLambda0DispEta[ie][i]->SetYTitle("#sigma^{2}_{#phi #phi}");
+            outputContainer->Add(fhMCLambda0DispEta[ie][i]);
+            
+            fhMCLambda0DispPhi[ie][i] = new TH2F (Form("hMCLambda0DispPhi_EBin%d_MC%s",ie,pname[i].Data()),
+                                                  Form("cluster from %s :#lambda^{2}_{0} vs #sigma^{2}_{#phi #phi} for %d < E < %d GeV",ptype[i].Data(),bin[ie],bin[ie+1]),
+                                                  ssbins,ssmin,ssmax , ssbins,ssmin,ssmax);
+            fhMCLambda0DispPhi[ie][i]->SetXTitle("#lambda^{2}_{0}");
+            fhMCLambda0DispPhi[ie][i]->SetYTitle("#sigma^{2}_{#phi #phi}");
+            outputContainer->Add(fhMCLambda0DispPhi[ie][i]);
             
-            if(!fFillOnlySimpleSSHisto)
-            {
-              fhMCPtDispEta[i]  = new TH2F (Form("hPtDispEta_MC%s",pname[i].Data()),
-                                           Form("cluster from %s : #sigma^{2}_{#eta #eta} = #Sigma w_{i}(#eta_{i} - <#eta>)^{2}/ #Sigma w_{i} vs #it{p}_{T}",ptype[i].Data()),
-                                           nptbins,ptmin,ptmax, ssbins,ssmin,ssmax);
-              fhMCPtDispEta[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-              fhMCPtDispEta[i]->SetYTitle("#sigma^{2}_{#eta #eta}");
-              outputContainer->Add(fhMCPtDispEta[i]);
-              
-              fhMCPtDispPhi[i]  = new TH2F (Form("hPtDispPhi_MC%s",pname[i].Data()),
-                                           Form("cluster from %s : #sigma^{2}_{#phi #phi} = #Sigma w_{i}(#phi_{i} - <#phi>)^{2} / #Sigma w_{i} vs #it{p}_{T}",ptype[i].Data()),
-                                           nptbins,ptmin,ptmax, ssbins,ssmin,ssmax);
-              fhMCPtDispPhi[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-              fhMCPtDispPhi[i]->SetYTitle("#sigma^{2}_{#phi #phi}");
-              outputContainer->Add(fhMCPtDispPhi[i]);
-              
-              fhMCPtSumEtaPhi[i]  = new TH2F (Form("hPtSumEtaPhi_MC%s",pname[i].Data()),
-                                             Form("cluster from %s : #delta^{2}_{#eta #phi} = #Sigma w_{i}(#phi_{i} #eta_{i} ) / #Sigma w_{i} - <#phi><#eta> vs #it{p}_{T}",ptype[i].Data()),
-                                             nptbins,ptmin,ptmax, 2*ssbins,-ssmax,ssmax);
-              fhMCPtSumEtaPhi[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-              fhMCPtSumEtaPhi[i]->SetYTitle("#delta^{2}_{#eta #phi}");
-              outputContainer->Add(fhMCPtSumEtaPhi[i]);
-              
-              fhMCPtDispEtaPhiDiff[i]  = new TH2F (Form("hPtDispEtaPhiDiff_MC%s",pname[i].Data()),
-                                                  Form("cluster from %s : #sigma^{2}_{#phi #phi} - #sigma^{2}_{#eta #eta} vs #it{p}_{T}",ptype[i].Data()),
-                                                  nptbins,ptmin,ptmax,200,-10,10);
-              fhMCPtDispEtaPhiDiff[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-              fhMCPtDispEtaPhiDiff[i]->SetYTitle("#sigma^{2}_{#phi #phi}-#sigma^{2}_{#eta #eta}");
-              outputContainer->Add(fhMCPtDispEtaPhiDiff[i]);
-              
-              fhMCPtSphericity[i]  = new TH2F (Form("hPtSphericity_MC%s",pname[i].Data()),
-                                              Form("cluster from %s : (#sigma^{2}_{#phi #phi} - #sigma^{2}_{#eta #eta}) / (#sigma^{2}_{#eta #eta} + #sigma^{2}_{#phi #phi}) vs E",ptype[i].Data()),
-                                              nptbins,ptmin,ptmax, 200,-1,1);
-              fhMCPtSphericity[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
-              fhMCPtSphericity[i]->SetYTitle("#it{s} = (#sigma^{2}_{#phi #phi} - #sigma^{2}_{#eta #eta}) / (#sigma^{2}_{#eta #eta} + #sigma^{2}_{#phi #phi})");
-              outputContainer->Add(fhMCPtSphericity[i]);
-              
-              for(Int_t ie = 0; ie < 7; ie++)
-              {
-                fhMCDispEtaDispPhi[ie][i] = new TH2F (Form("hMCDispEtaDispPhi_EBin%d_MC%s",ie,pname[i].Data()),
-                                                      Form("cluster from %s : #sigma^{2}_{#phi #phi} vs #sigma^{2}_{#eta #eta} for %d < E < %d GeV",pname[i].Data(),bin[ie],bin[ie+1]),
-                                                      ssbins,ssmin,ssmax , ssbins,ssmin,ssmax);
-                fhMCDispEtaDispPhi[ie][i]->SetXTitle("#sigma^{2}_{#eta #eta}");
-                fhMCDispEtaDispPhi[ie][i]->SetYTitle("#sigma^{2}_{#phi #phi}");
-                outputContainer->Add(fhMCDispEtaDispPhi[ie][i]);
-                
-                fhMCLambda0DispEta[ie][i] = new TH2F (Form("hMCLambda0DispEta_EBin%d_MC%s",ie,pname[i].Data()),
-                                                      Form("cluster from %s : #lambda^{2}_{0} vs #sigma^{2}_{#eta #eta} for %d < E < %d GeV",pname[i].Data(),bin[ie],bin[ie+1]),
-                                                      ssbins,ssmin,ssmax , ssbins,ssmin,ssmax);
-                fhMCLambda0DispEta[ie][i]->SetXTitle("#lambda^{2}_{0}");
-                fhMCLambda0DispEta[ie][i]->SetYTitle("#sigma^{2}_{#phi #phi}");
-                outputContainer->Add(fhMCLambda0DispEta[ie][i]);
-                
-                fhMCLambda0DispPhi[ie][i] = new TH2F (Form("hMCLambda0DispPhi_EBin%d_MC%s",ie,pname[i].Data()),
-                                                      Form("cluster from %s :#lambda^{2}_{0} vs #sigma^{2}_{#phi #phi} for %d < E < %d GeV",pname[i].Data(),bin[ie],bin[ie+1]),
-                                                      ssbins,ssmin,ssmax , ssbins,ssmin,ssmax);
-                fhMCLambda0DispPhi[ie][i]->SetXTitle("#lambda^{2}_{0}");
-                fhMCLambda0DispPhi[ie][i]->SetYTitle("#sigma^{2}_{#phi #phi}");
-                outputContainer->Add(fhMCLambda0DispPhi[ie][i]);
-                
-              }
-            }
           }
           
           fhMCPtLambda0FracMaxCellCut[i]  = new TH2F(Form("hELambda0FracMaxCellCut_MC%s",pname[i].Data()),
-                                                    Form("Selected pair, cluster from %s : #it{p}_{T} vs #lambda_{0}^{2}, Max cell fraction of energy < 0.5 ",ptype[i].Data()),
-                                                    nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
+                                                     Form("Selected pair, cluster from %s : #it{p}_{T} vs #lambda_{0}^{2}, Max cell fraction of energy < 0.5 ",ptype[i].Data()),
+                                                     nptbins,ptmin,ptmax,ssbins,ssmin,ssmax);
           fhMCPtLambda0FracMaxCellCut[i]->SetYTitle("#lambda_{0}^{2}");
           fhMCPtLambda0FracMaxCellCut[i]->SetXTitle("#it{E} (GeV)");
           outputContainer->Add(fhMCPtLambda0FracMaxCellCut[i]) ;
           
           fhMCPtFracMaxCell[i]  = new TH2F(Form("hEFracMaxCell_MC%s",pname[i].Data()),
-                                          Form("Selected pair, cluster from %s : #it{p}_{T} vs Max cell fraction of energy",ptype[i].Data()),
-                                          nptbins,ptmin,ptmax,100,0,1);
+                                           Form("Selected pair, cluster from %s : #it{p}_{T} vs Max cell fraction of energy",ptype[i].Data()),
+                                           nptbins,ptmin,ptmax,100,0,1);
           fhMCPtFracMaxCell[i]->SetYTitle("#it{Fraction}");
           fhMCPtFracMaxCell[i]->SetXTitle("#it{E} (GeV)");
           outputContainer->Add(fhMCPtFracMaxCell[i]) ;
           
-        }//
-      } // shower shape histo
-      
-    } //Not MC reader
+        }
+      }
+    }// MC particle loop
   }//Histos with MC
   
   if(fAnaType==kSSCalo)
@@ -2019,7 +2129,7 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
       fhSelectedMassSplitPtNoOverlap->SetYTitle("#it{M} (GeV/#it{c}^{2})");
       fhSelectedMassSplitPtNoOverlap->SetXTitle("#it{p}_{T} (GeV/#it{c})");
       outputContainer->Add(fhSelectedMassSplitPtNoOverlap) ;
-
+      
       
       fhMCPi0PtRecoPtPrim  = new TH2F
       ("hMCPi0PtRecoPtPrim","#it{p}_{T,reco} vs #it{p}_{T,gen}",
@@ -2048,7 +2158,7 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
       fhMCPi0SelectedPtRecoPtPrimNoOverlap ->SetYTitle("#it{p}_{T,gen} (GeV/#it{c})");
       fhMCPi0SelectedPtRecoPtPrimNoOverlap ->SetXTitle("#it{p}_{T,reco} (GeV/#it{c})");
       outputContainer->Add(fhMCPi0SelectedPtRecoPtPrimNoOverlap ) ;
-
+      
       
       fhMCPi0SplitPtRecoPtPrim  = new TH2F
       ("hMCPi0SplitPtRecoPtPrim","#it{p}_{T,reco} (split sum) vs #it{p}_{T,gen}",
@@ -2077,7 +2187,7 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
       fhMCPi0SelectedSplitPtRecoPtPrimNoOverlap ->SetYTitle("#it{p}_{T,gen} (GeV/#it{c})");
       fhMCPi0SelectedSplitPtRecoPtPrimNoOverlap ->SetXTitle("#it{p}_{T,reco} (GeV/#it{c})");
       outputContainer->Add(fhMCPi0SelectedSplitPtRecoPtPrimNoOverlap ) ;
-
+      
       fhMCEtaPtRecoPtPrim  = new TH2F
       ("hMCEtaPtRecoPtPrim","#it{p}_{T,reco} vs #it{p}_{T,gen}",
        nptbins,ptmin,ptmax,nptbins,ptmin,ptmax);
@@ -2196,11 +2306,11 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
         
       }
       
-      for(Int_t i = 0; i< 6; i++)
+      for(Int_t i = 0; i < fgkNmcTypes; i++)
       {
         fhMCPtAsymmetry[i]  = new TH2F (Form("hEAsymmetry_MC%s",pname[i].Data()),
-                                       Form("cluster from %s : #it{A} = ( #it{E}_{1} - #it{E}_{2} ) / ( #it{E}_{1} + #it{E}_{2} ) vs #it{E}",ptype[i].Data()),
-                                       nptbins,ptmin,ptmax, 200,-1,1);
+                                        Form("cluster from %s : #it{A} = ( #it{E}_{1} - #it{E}_{2} ) / ( #it{E}_{1} + #it{E}_{2} ) vs #it{E}",ptype[i].Data()),
+                                        nptbins,ptmin,ptmax, 200,-1,1);
         fhMCPtAsymmetry[i]->SetXTitle("#it{E} (GeV)");
         fhMCPtAsymmetry[i]->SetYTitle("#it{A} = ( #it{E}_{1} - #it{E}_{2} ) / ( #it{E}_{1} + #it{E}_{2} )");
         outputContainer->Add(fhMCPtAsymmetry[i]);
@@ -2262,7 +2372,7 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
         fhMCSelectedMassSplitPt[i]->SetYTitle("#it{M} (GeV/#it{c}^{2})");
         fhMCSelectedMassSplitPt[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
         outputContainer->Add(fhMCSelectedMassSplitPt[i]) ;
-
+        
         fhMCMassSplitPtNoOverlap[i]  = new TH2F
         (Form("hMassSplitPtNoOverlap_MC%s",pname[i].Data()),
          Form("all pairs #it{M}: split #it{p}_{T} vs #it{M} from %s, no overlap",ptype[i].Data()),
@@ -2284,19 +2394,17 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
   
   if(fAnaType==kSSCalo && fFillSelectClHisto && !fFillOnlySimpleSSHisto )
   {
-    
-    
     for(Int_t i = 0; i< 3; i++)
     {
       fhPtAsymmetryLocMax[i]  = new TH2F(Form("hEAsymmetryLocMax%d",i+1),
-                                        Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #it{A} = ( #it{E}_{1} - #it{E}_{2} ) / ( #it{E}_{1} + #it{E}_{2} ), %s",nlm[i].Data()),
-                                        nptbins,ptmin,ptmax,200, -1,1);
+                                         Form("Selected #pi^{0} (#eta) pairs: #it{p}_{T} vs #it{A} = ( #it{E}_{1} - #it{E}_{2} ) / ( #it{E}_{1} + #it{E}_{2} ), %s",nlm[i].Data()),
+                                         nptbins,ptmin,ptmax,200, -1,1);
       fhPtAsymmetryLocMax[i]->SetYTitle("#it{A} = ( #it{E}_{1} - #it{E}_{2} ) / ( #it{E}_{1} + #it{E}_{2} )");
       fhPtAsymmetryLocMax[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
       outputContainer->Add(fhPtAsymmetryLocMax[i]) ;
     }
     
-    for(Int_t ie = 0; ie< 7; ie++)
+    for(Int_t ie = 0; ie < 7; ie++)
     {
       
       fhAsymmetryLambda0[ie] = new TH2F (Form("hAsymmetryLambda0_EBin%d",ie),
@@ -2324,26 +2432,26 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
     
     if(IsDataMC())
     {
-      for(Int_t i = 0; i< 6; i++)
+      for(Int_t i = 0; i < fgkNmcTypes; i++)
       {
         for(Int_t ie = 0; ie < 7; ie++)
         {
           fhMCAsymmetryLambda0[ie][i] = new TH2F (Form("hMCAsymmetryLambda0_EBin%d_MC%s",ie,pname[i].Data()),
-                                                  Form("cluster from %s : #lambda_{0}^{2} vs A for %d < #it{E} < %d GeV",pname[i].Data(),bin[ie],bin[ie+1]),
+                                                  Form("cluster from %s : #lambda_{0}^{2} vs A for %d < #it{E} < %d GeV",ptype[i].Data(),bin[ie],bin[ie+1]),
                                                   ssbins,ssmin,ssmax , 200,-1,1);
           fhMCAsymmetryLambda0[ie][i]->SetXTitle("#lambda_{0}^{2}");
           fhMCAsymmetryLambda0[ie][i]->SetYTitle("#it{A} = ( #it{E}_{1} - #it{E}_{2} ) / ( #it{E}_{1} + #it{E}_{2} )");
           outputContainer->Add(fhMCAsymmetryLambda0[ie][i]);
           
           fhMCAsymmetryDispEta[ie][i] = new TH2F (Form("hMCAsymmetryDispEta_EBin%d_MC%s",ie,pname[i].Data()),
-                                                  Form("cluster from %s : #sigma^{2}_{#eta #eta} vs #it{A} for %d < #it{E} < %d GeV",pname[i].Data(),bin[ie],bin[ie+1]),
+                                                  Form("cluster from %s : #sigma^{2}_{#eta #eta} vs #it{A} for %d < #it{E} < %d GeV",ptype[i].Data(),bin[ie],bin[ie+1]),
                                                   ssbins,ssmin,ssmax , 200,-1,1);
           fhMCAsymmetryDispEta[ie][i]->SetXTitle("#sigma^{2}_{#eta #eta}");
           fhMCAsymmetryDispEta[ie][i]->SetYTitle("#it{A} = ( #it{E}_{1} - #it{E}_{2} ) / ( #it{E}_{1} + #it{E}_{2} )");
           outputContainer->Add(fhMCAsymmetryDispEta[ie][i]);
           
           fhMCAsymmetryDispPhi[ie][i] = new TH2F (Form("hMCAsymmetryDispPhi_EBin%d_MC%s",ie,pname[i].Data()),
-                                                  Form("cluster from %s : #sigma^{2}_{#phi #phi} vs #it{A} for %d < #it{E} < %d GeV",pname[i].Data(),bin[ie],bin[ie+1]),
+                                                  Form("cluster from %s : #sigma^{2}_{#phi #phi} vs #it{A} for %d < #it{E} < %d GeV",ptype[i].Data(),bin[ie],bin[ie+1]),
                                                   ssbins,ssmin,ssmax , 200,-1,1);
           fhMCAsymmetryDispPhi[ie][i]->SetXTitle("#sigma^{2}_{#phi #phi}");
           fhMCAsymmetryDispPhi[ie][i]->SetYTitle("#it{A} = ( #it{E}_{1} - #it{E}_{2} ) / ( #it{E}_{1} + #it{E}_{2} )");
@@ -2353,7 +2461,7 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
     }
   }
   
-  if(fFillPileUpHistograms)
+  if(IsPileUpAnalysisOn())
   {
     
     TString pileUpName[] = {"SPD","EMCAL","SPDOrEMCAL","SPDAndEMCAL","SPDAndNotEMCAL","EMCALAndNotSPD","NotSPDAndNotEMCAL"} ;
@@ -2361,24 +2469,24 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
     for(Int_t i = 0 ; i < 7 ; i++)
     {
       fhPtPileUp[i]  = new TH1F(Form("hPtPileUp%s",pileUpName[i].Data()),
-                                   Form("Selected #pi^{0} (#eta) #it{p}_{T} distribution, %s Pile-Up event",pileUpName[i].Data()), nptbins,ptmin,ptmax);
+                                Form("Selected #pi^{0} (#eta) #it{p}_{T} distribution, %s Pile-Up event",pileUpName[i].Data()), nptbins,ptmin,ptmax);
       fhPtPileUp[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
       outputContainer->Add(fhPtPileUp[i]);
       
       fhPtCellTimePileUp[i]  = new TH2F(Form("hPtCellTimePileUp%s",pileUpName[i].Data()),
-                                             Form("Pt vs cell time in cluster, %s Pile-Up event",pileUpName[i].Data()),
-                                             nptbins,ptmin,ptmax,ntimptbins,timemin,timemax);
+                                        Form("Pt vs cell time in cluster, %s Pile-Up event",pileUpName[i].Data()),
+                                        nptbins,ptmin,ptmax,ntimptbins,timemin,timemax);
       fhPtCellTimePileUp[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
       fhPtCellTimePileUp[i]->SetYTitle("#it{t}_{cell} (ns)");
       outputContainer->Add(fhPtCellTimePileUp[i]);
       
       fhPtTimeDiffPileUp[i]  = new TH2F(Form("hPtTimeDiffPileUp%s",pileUpName[i].Data()),
-                                             Form("Pt vs t_{max}-t_{cell} in cluster, %s Pile-Up event",pileUpName[i].Data()),
-                                             nptbins,ptmin,ptmax,400,-200,200);
+                                        Form("Pt vs t_{max}-t_{cell} in cluster, %s Pile-Up event",pileUpName[i].Data()),
+                                        nptbins,ptmin,ptmax,400,-200,200);
       fhPtTimeDiffPileUp[i]->SetXTitle("#it{p}_{T} (GeV/#it{c})");
       fhPtTimeDiffPileUp[i]->SetYTitle("#it{t}_{max}-#it{t}_{cell} (ns)");
       outputContainer->Add(fhPtTimeDiffPileUp[i]);
-
+      
     }
     
     fhTimePtNoCut  = new TH2F ("hTimePt_NoCut","#it{t} of cluster vs #it{E} of clusters, no cut", nptbins,ptmin,ptmax, ntimptbins,timemin,timemax);
@@ -2479,7 +2587,6 @@ TList *  AliAnaPi0EbE::GetCreateOutputObjects()
 //_____________________________________________
 Int_t AliAnaPi0EbE::GetMCIndex(const Int_t tag)
 {
-  
   // Assign mc index depending on MC bit set
   
   if       ( GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPi0)  )
@@ -2490,15 +2597,27 @@ Int_t AliAnaPi0EbE::GetMCIndex(const Int_t tag)
   {
     return kmcEta ;
   }//eta
+  else if  ( GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPrompt) ||
+             GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCFragmentation) ||
+             GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCISR))
+  {
+    return kmcPhoton ;
+  }//direct photon
   else if  ( GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPhoton) &&
-             GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCConversion) )
+             GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPi0Decay) )
   {
-    return kmcConversion ;
-  }//conversion photon
-  else if  ( GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPhoton) )
+      return kmcPi0Decay ;
+  }//decay photon from pi0
+  else if  ( GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPhoton) &&
+             GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCEtaDecay) )
   {
-    return kmcPhoton ;
-  }//photon   no conversion
+    return kmcEtaDecay ;
+  }//decay photon from eta
+  else if  ( GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPhoton) &&
+             GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCOtherDecay) )
+  {
+    return kmcOtherDecay ;
+  }//decay photon from other than eta or pi0
   else if  ( GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCElectron))
   {
     return kmcElectron ;
@@ -2511,31 +2630,26 @@ Int_t AliAnaPi0EbE::GetMCIndex(const Int_t tag)
 }
 
 //__________________________________________________________________
-void AliAnaPi0EbE::HasPairSameMCMother(AliAODPWG4Particle * photon1,
-                                       AliAODPWG4Particle * photon2,
+void AliAnaPi0EbE::HasPairSameMCMother(Int_t label1 , Int_t label2,
+                                       Int_t tag1   , Int_t tag2,
                                        Int_t & label, Int_t & tag)
 {
-  // Check the labels of pare in case mother was same pi0 or eta
+  // Check the labels of pair in case mother was same pi0 or eta
   // Set the new AOD accordingly
   
-  Int_t  label1 = photon1->GetLabel();
-  Int_t  label2 = photon2->GetLabel();
   
-  if(label1 < 0 || label2 < 0 ) return ;
+  if(label1 < 0 || label2 < 0 || label1 == label2) return ;
   
-  //Int_t tag1 = GetMCAnalysisUtils()->CheckOrigin(label1, GetReader());
-  //Int_t tag2 = GetMCAnalysisUtils()->CheckOrigin(label2, GetReader());
-  Int_t tag1 = photon1->GetTag();
-  Int_t tag2 = photon2->GetTag();
+  AliDebug(0,Form("Origin of: photon1 %d; photon2 %d",tag1, tag2));
   
-  if(GetDebug() > 0) printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - Origin of: photon1 %d; photon2 %d \n",tag1, tag2);
   if( (GetMCAnalysisUtils()->CheckTagBit(tag1,AliMCAnalysisUtils::kMCPi0Decay) &&
        GetMCAnalysisUtils()->CheckTagBit(tag2,AliMCAnalysisUtils::kMCPi0Decay)    ) ||
       (GetMCAnalysisUtils()->CheckTagBit(tag1,AliMCAnalysisUtils::kMCEtaDecay) &&
        GetMCAnalysisUtils()->CheckTagBit(tag2,AliMCAnalysisUtils::kMCEtaDecay)    )
      )
   {
-    
+    Int_t pdg1    = -1;//, pdg2    = -1;
+    Int_t ndaugh1 = -1, ndaugh2 = -1;
     //Check if pi0/eta mother is the same
     if(GetReader()->ReadStack())
     {
@@ -2543,13 +2657,17 @@ void AliAnaPi0EbE::HasPairSameMCMother(AliAODPWG4Particle * photon1,
       {
         TParticle * mother1 = GetMCStack()->Particle(label1);//photon in kine tree
         label1 = mother1->GetFirstMother();
-        //mother1 = GetMCStack()->Particle(label1);//pi0
+        mother1 = GetMCStack()->Particle(label1);//pi0
+        pdg1=mother1->GetPdgCode();
+        ndaugh1 = mother1->GetNDaughters();
       }
       if(label2>=0)
       {
         TParticle * mother2 = GetMCStack()->Particle(label2);//photon in kine tree
         label2 = mother2->GetFirstMother();
-        //mother2 = GetMCStack()->Particle(label2);//pi0
+        mother2 = GetMCStack()->Particle(label2);//pi0
+        //pdg2=mother2->GetPdgCode();
+        ndaugh2 = mother2->GetNDaughters();
       }
     } // STACK
     else if(GetReader()->ReadAODMCParticles())
@@ -2558,37 +2676,45 @@ void AliAnaPi0EbE::HasPairSameMCMother(AliAODPWG4Particle * photon1,
       {
         AliAODMCParticle * mother1 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles())->At(label1);//photon in kine tree
         label1 = mother1->GetMother();
-        //mother1 = GetMCStack()->Particle(label1);//pi0
+        mother1 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles())->At(label1);//pi0
+        pdg1=mother1->GetPdgCode();
+        ndaugh1 = mother1->GetNDaughters();
       }
       if(label2>=0)
       {
         AliAODMCParticle * mother2 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles())->At(label2);//photon in kine tree
         label2 = mother2->GetMother();
-        //mother2 = GetMCStack()->Particle(label2);//pi0
+        mother2 = (AliAODMCParticle *) (GetReader()->GetAODMCParticles())->At(label2);//pi0
+        //pdg2=mother2->GetPdgCode();
+        ndaugh2 = mother2->GetNDaughters();
       }
     }// AOD
     
     //printf("mother1 %d, mother2 %d\n",label1,label2);
-    if( label1 == label2 && label1>=0 )
+    if( label1 == label2 && label1>=0  && ndaugh1==ndaugh2 && ndaugh1==2)
     {
-      
       label = label1;
       
-      TLorentzVector mom1 = *(photon1->Momentum());
-      TLorentzVector mom2 = *(photon2->Momentum());
-      
-      Double_t angle = mom2.Angle(mom1.Vect());
-      Double_t mass  = (mom1+mom2).M();
-      Double_t epair = (mom1+mom2).E();
+      Double_t angle = fMomentum2.Angle(fMomentum1.Vect());
+      Double_t mass  = (fMomentum1+fMomentum2).M();
+      Double_t epair = (fMomentum1+fMomentum2).E();
       
-      if(GetMCAnalysisUtils()->CheckTagBit(tag1,AliMCAnalysisUtils::kMCPi0Decay))
+      if(pdg1==111)
       {
+        //printf("Real pi0 pair: pt %f, mass %f\n",(fMomentum1+fMomentum2).Pt(),mass);
         fhMassPairMCPi0 ->Fill(epair,mass);
         fhAnglePairMCPi0->Fill(epair,angle);
         GetMCAnalysisUtils()->SetTagBit(tag,AliMCAnalysisUtils::kMCPi0);
+//        printf(" Lab1 %d (%d), lab2 %d (%d), pdg1 %d, pdg2 %d, Is In calo %d, %d, Is lost %d, %d\n",
+//               label1,photon1->GetLabel(),label2,photon2->GetLabel(), pdg1, pdg2,
+//               GetMCAnalysisUtils()->CheckTagBit(photon1->GetTag(),AliMCAnalysisUtils::kMCDecayPairInCalo),
+//               GetMCAnalysisUtils()->CheckTagBit(photon2->GetTag(),AliMCAnalysisUtils::kMCDecayPairInCalo),
+//               GetMCAnalysisUtils()->CheckTagBit(photon1->GetTag(),AliMCAnalysisUtils::kMCDecayPairLost),
+//               GetMCAnalysisUtils()->CheckTagBit(photon2->GetTag(),AliMCAnalysisUtils::kMCDecayPairLost));
       }
-      else
+      else  if(pdg1==221)
       {
+        //printf("Real eta pair\n");
         fhMassPairMCEta ->Fill(epair,mass);
         fhAnglePairMCEta->Fill(epair,angle);
         GetMCAnalysisUtils()->SetTagBit(tag,AliMCAnalysisUtils::kMCEta);
@@ -2604,14 +2730,11 @@ void AliAnaPi0EbE::Init()
 {
   //Init
   //Do some checks
-  if(fCalorimeter == "PHOS" && !GetReader()->IsPHOSSwitchedOn() && NewOutputAOD()){
-    printf("AliAnaPi0EbE::Init() - !!STOP: You want to use PHOS in analysis but it is not read!! \n!!Check the configuration file!!\n");
-    abort();
-  }
-  else  if(fCalorimeter == "EMCAL" && !GetReader()->IsEMCALSwitchedOn() && NewOutputAOD()){
-    printf("AliAnaPi0EbE::Init() - !!STOP: You want to use EMCAL in analysis but it is not read!! \n!!Check the configuration file!!\n");
-    abort();
-  }
+  
+  if       ( GetCalorimeter() == kPHOS  && !GetReader()->IsPHOSSwitchedOn()  && NewOutputAOD() )
+    AliFatal("STOP: You want to use PHOS in analysis but it is not read!! \n!!Check the configuration file!!");
+  else  if ( GetCalorimeter() == kEMCAL && !GetReader()->IsEMCALSwitchedOn() && NewOutputAOD() )
+    AliFatal("STOP: You want to use EMCAL in analysis but it is not read!! \n!!Check the configuration file!!");
   
 }
 
@@ -2623,7 +2746,6 @@ void AliAnaPi0EbE::InitParameters()
   
   fInputAODGammaConvName = "PhotonsCTS" ;
   fAnaType = kIMCalo ;
-  fCalorimeter = "EMCAL" ;
   fMinDist  = 2.;
   fMinDist2 = 4.;
   fMinDist3 = 5.;
@@ -2631,6 +2753,10 @@ void AliAnaPi0EbE::InitParameters()
   fNLMECutMin[0] = 10.;
   fNLMECutMin[1] = 6. ;
   fNLMECutMin[2] = 6. ;
+  
+  fIsoCandMinPt = 8;
+  fR            = 0.4;
+  
 }
 
 //__________________________________________________________________
@@ -2638,6 +2764,8 @@ void  AliAnaPi0EbE::MakeAnalysisFillAOD()
 {
   //Do analysis and fill aods
   
+  AliDebug(1,Form("Start analysis type %d",fAnaType));
+  
   switch(fAnaType)
   {
     case kIMCalo:
@@ -2653,6 +2781,9 @@ void  AliAnaPi0EbE::MakeAnalysisFillAOD()
       break;
       
   }
+  
+  AliDebug(1,"End");
+
 }
 
 //____________________________________________
@@ -2663,65 +2794,77 @@ void  AliAnaPi0EbE::MakeInvMassInCalorimeter()
   //Read photon list from AOD, produced in class AliAnaPhoton
   //Check if 2 photons have the mass of the pi0.
   
-  TLorentzVector mom1;
-  TLorentzVector mom2;
-  TLorentzVector mom ;
-  
-  Int_t tag   = 0;
-  Int_t label = 0;
-  
-  if(!GetInputAODBranch()){
-    printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - No input calo photons in AOD with name branch < %s >, STOP \n",GetInputAODName().Data());
-    abort();
+  if(!GetInputAODBranch())
+  {
+    AliFatal(Form("No input calo photons in AOD with name branch < %s >, STOP",GetInputAODName().Data()));
+    return; // coverity
   }
   
   //Get shower shape information of clusters
   TObjArray *clusters = 0;
-  if     (fCalorimeter=="EMCAL") clusters = GetEMCALClusters();
-  else if(fCalorimeter=="PHOS")  clusters = GetPHOSClusters() ;
+  if     (GetCalorimeter()==kEMCAL) clusters = GetEMCALClusters();
+  else if(GetCalorimeter()==kPHOS)  clusters = GetPHOSClusters() ;
   
-  for(Int_t iphoton = 0; iphoton < GetInputAODBranch()->GetEntriesFast()-1; iphoton++){
+  Int_t nphoton = GetInputAODBranch()->GetEntriesFast();
+  for(Int_t iphoton = 0; iphoton < nphoton-1; iphoton++)
+  {
     AliAODPWG4Particle * photon1 =  (AliAODPWG4Particle*) (GetInputAODBranch()->At(iphoton));
     
-    //Vertex cut in case of mixed events
+    // Vertex cut in case of mixed events
     Int_t evtIndex1 = 0 ;
     if(GetMixedEvent())
+    {
       evtIndex1 = GetMixedEvent()->EventIndexForCaloCluster(photon1->GetCaloLabel(0)) ;
-    if(TMath::Abs(GetVertex(evtIndex1)[2]) > GetZvertexCut()) continue ;  //vertex cut
-    mom1 = *(photon1->Momentum());
+      if(TMath::Abs(GetVertex(evtIndex1)[2]) > GetZvertexCut()) continue ;  //vertex cut
+    }
+    
+    fMomentum1 = *(photon1->Momentum());
     
     //Get original cluster, to recover some information
     Int_t iclus = -1;
     AliVCluster *cluster1 = FindCluster(clusters,photon1->GetCaloLabel(0),iclus);
     
-    if(!cluster1){
-      printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - First cluster not found\n");
+    if(!cluster1)
+    {
+      AliWarning("First cluster not found");
       return;
     }
     
-    for(Int_t jphoton = iphoton+1; jphoton < GetInputAODBranch()->GetEntriesFast(); jphoton++)
+    for(Int_t jphoton = iphoton+1; jphoton < nphoton; jphoton++)
     {
       AliAODPWG4Particle * photon2 =  (AliAODPWG4Particle*) (GetInputAODBranch()->At(jphoton));
       
+      // Do analysis only when one of the decays is isolated
+      // Run AliAnaParticleIsolation before
+      if(fSelectIsolatedDecay)
+      {
+        Bool_t isolated1 = ((AliAODPWG4ParticleCorrelation*) photon1)->IsIsolated();
+        Bool_t isolated2 = ((AliAODPWG4ParticleCorrelation*) photon2)->IsIsolated();
+        if(!isolated1 && !isolated2) continue;
+      }
+      
+      // Vertex cut in case of mixed events
       Int_t evtIndex2 = 0 ;
       if(GetMixedEvent())
+      {
         evtIndex2 = GetMixedEvent()->EventIndexForCaloCluster(photon2->GetCaloLabel(0)) ;
+        
+        if(evtIndex1 == evtIndex2)
+          continue ;
+        
+        if(TMath::Abs(GetVertex(evtIndex2)[2]) > GetZvertexCut()) continue ;  //vertex cut
+      }
       
-      if(GetMixedEvent() && (evtIndex1 == evtIndex2))
-        continue ;
-      
-      if(TMath::Abs(GetVertex(evtIndex2)[2]) > GetZvertexCut()) continue ;  //vertex cut
-      
-      mom2 = *(photon2->Momentum());
+      fMomentum2 = *(photon2->Momentum());
       
       //Get original cluster, to recover some information
       Int_t iclus2 = -1;
       AliVCluster *cluster2 = FindCluster(clusters,photon2->GetCaloLabel(0),iclus2,iclus+1);
       // start new loop from iclus1+1 to gain some time
-
+      
       if(!cluster2)
       {
-        printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - Second cluster not found\n");
+        AliWarning("Second cluster not found");
         return;
       }
       
@@ -2736,107 +2879,180 @@ void  AliAnaPi0EbE::MakeInvMassInCalorimeter()
       if(TMath::Abs(t12diff) > GetPairTimeCut()) continue;
       
       //Play with the MC stack if available
-      if(IsDataMC()) HasPairSameMCMother(photon1, photon2, label, tag) ;
+      Int_t mcIndex = kmcHadron;
+      Int_t tag     = 0;
+      Int_t label   =-1;
+      if(IsDataMC())
+      {
+        HasPairSameMCMother(photon1->GetLabel(), photon2->GetLabel(),
+                            photon1->GetTag()  , photon2->GetTag(),
+                            label, tag) ;
+        mcIndex = GetMCIndex(tag);
+      }
       
       // Check the invariant mass for different selection on the local maxima
-      // Name of AOD method TO BE FIXED
-      Int_t nMaxima1 = photon1->GetFiducialArea();
-      Int_t nMaxima2 = photon2->GetFiducialArea();
+      Int_t nMaxima1 = photon1->GetNLM();
+      Int_t nMaxima2 = photon2->GetNLM();
       
-      mom = mom1+mom2;
+      fMomentum = fMomentum1+fMomentum2;
       
-      Double_t mass  = mom.M();
-      Double_t epair = mom.E();
+      Double_t mass  = fMomentum.M();
+      Double_t epair = fMomentum.E();
+      Float_t ptpair = fMomentum.Pt();
       
-      if(nMaxima1==nMaxima2)
+      if(fFillAllNLMHistograms)
       {
-        if     (nMaxima1==1) fhMassPairLocMax[0]->Fill(epair,mass);
-        else if(nMaxima1==2) fhMassPairLocMax[1]->Fill(epair,mass);
-        else                 fhMassPairLocMax[2]->Fill(epair,mass);
+        if(nMaxima1==nMaxima2)
+        {
+          if     (nMaxima1==1) fhMassPairLocMax[0]->Fill(epair,mass);
+          else if(nMaxima1==2) fhMassPairLocMax[1]->Fill(epair,mass);
+          else                 fhMassPairLocMax[2]->Fill(epair,mass);
+        }
+        else if(nMaxima1==1 || nMaxima2==1)
+        {
+          if  (nMaxima1==2 || nMaxima2==2) fhMassPairLocMax[3]->Fill(epair,mass);
+          else                             fhMassPairLocMax[4]->Fill(epair,mass);
+        }
+        else
+          fhMassPairLocMax[5]->Fill(epair,mass);
+        
+        // combinations with SS axis cut and NLM cut
+        if(nMaxima1 == 1 && cluster2->GetM02() > 0.3) fhMassPairLocMax[6]->Fill(epair,mass);
+        if(nMaxima2 == 1 && cluster1->GetM02() > 0.3) fhMassPairLocMax[6]->Fill(epair,mass);
+        if(nMaxima1 >  1 && cluster2->GetM02() < 0.3 && cluster2->GetM02()> 0.1 ) fhMassPairLocMax[7]->Fill(epair,mass);
+        if(nMaxima2 >  1 && cluster1->GetM02() < 0.3 && cluster1->GetM02()> 0.1 ) fhMassPairLocMax[7]->Fill(epair,mass);
       }
-      else if(nMaxima1==1 || nMaxima2==1)
+      
+      //
+      // Skip events with too few or too many  NLM
+      //
+      if((nMaxima1 < fNLMCutMin || nMaxima1 > fNLMCutMax) || (nMaxima2 < fNLMCutMin || nMaxima2 > fNLMCutMax))
       {
-        if  (nMaxima1==2 || nMaxima2==2) fhMassPairLocMax[3]->Fill(epair,mass);
-        else                             fhMassPairLocMax[4]->Fill(epair,mass);
+        AliDebug(1,Form("NLM out of range: cluster1 %d, cluster2 %d",nMaxima1, nMaxima2));
+        continue ;
       }
-      else
-        fhMassPairLocMax[5]->Fill(epair,mass);
-      
-      // combinations with SS axis cut and NLM cut
-      if(nMaxima1 == 1 && cluster2->GetM02() > 0.3) fhMassPairLocMax[6]->Fill(epair,mass);
-      if(nMaxima2 == 1 && cluster1->GetM02() > 0.3) fhMassPairLocMax[6]->Fill(epair,mass);
-      if(nMaxima1 >  1 && cluster2->GetM02() < 0.3 && cluster2->GetM02()> 0.1 ) fhMassPairLocMax[7]->Fill(epair,mass);
-      if(nMaxima2 >  1 && cluster1->GetM02() < 0.3 && cluster1->GetM02()> 0.1 ) fhMassPairLocMax[7]->Fill(epair,mass);
-      
-      //Skip events with too few or too many  NLM
-      if((nMaxima1 < fNLMCutMin || nMaxima1 > fNLMCutMax) || (nMaxima2 < fNLMCutMin || nMaxima2 > fNLMCutMax)) continue ;
-      
-      if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - NLM of out of range: cluster1 %d, cluster2 %d \n",nMaxima1, nMaxima2);
       
       //Mass of all pairs
-      fhMass->Fill(epair,mass);
+      fhMass  ->Fill( epair,mass);
+      fhMassPt->Fill(ptpair,mass);
+      if(IsDataMC() && mcIndex < 2) fhMCMassPt[mcIndex]->Fill(ptpair,mass);
       
-      //Select good pair (good phi, pt cuts, aperture and invariant mass)
-      if(GetNeutralMesonSelection()->SelectPair(mom1, mom2,fCalorimeter))
+      if(fSelectPairInIsoCone && fMomentum1.Pt() > fIsoCandMinPt)
       {
-        if(GetDebug()>1)
-          printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - Selected gamma pair: pt %f, phi %f, eta%f \n",
-                 mom.Pt(), mom.Phi()*TMath::RadToDeg(), mom.Eta());
-        
-        //Fill some histograms about shower shape
-        if(fFillSelectClHisto && clusters && GetReader()->GetDataType()!=AliCaloTrackReader::kMC)
-        {
-          FillSelectedClusterHistograms(cluster1, mom1.Pt(), nMaxima1, photon1->GetTag());
-          FillSelectedClusterHistograms(cluster2, mom2.Pt(), nMaxima2, photon2->GetTag());
-        }
-        
-        // Tag both photons as decay, !!careful!! since in case of SideBand analysis, also they will be tagged.
-        photon1->SetTagged(kTRUE);
-        photon2->SetTagged(kTRUE);
-        
-        fhPtDecay->Fill(photon1->Pt());
-        fhEDecay ->Fill(photon1->E() );
+        //Double_t angleOp  = fMomentum1.Angle(fMomentum2.Vect());
+        Double_t radius   = GetIsolationCut()->Radius(fMomentum1.Eta(),fMomentum1.Phi(),fMomentum2.Eta(),fMomentum2.Phi());
         
-        fhPtDecay->Fill(photon2->Pt());
-        fhEDecay ->Fill(photon2->E() );
+        //printf("pT pair (%f, %f), opening angle %f, radius %f; fR %1.1f, MinPt1 %2.2f\n",fMomentum1.Pt(),fMomentum2.Pt(),angleOp,radius,fR,fIsoCandMinPt);
         
-        //Mass of selected pairs
-        fhSelectedMass->Fill(epair,mass);
+        if(radius < fR) fhMassPtIsoRCut->Fill(ptpair,mass);
+      }
+      
+      //
+      // Select good pair (good phi, pt cuts, aperture and invariant mass)
+      //
+      if(!GetNeutralMesonSelection()->SelectPair(fMomentum1, fMomentum2,GetCalorimeter())) continue;
+      
+      AliDebug(1,Form("Selected gamma pair: pt %f, phi %f, eta%f",
+                      fMomentum.Pt(), fMomentum.Phi()*TMath::RadToDeg(), fMomentum.Eta()));
+      
+      //
+      // Tag both photons as decay if not done before
+      // set the corresponding bit for pi0 or eta or "side" case
+      //
+      Int_t bit1 = photon1->DecayTag();
+      if( bit1 < 0 ) bit1 = 0 ;
+      if( !GetNeutralMesonSelection()->CheckDecayBit(bit1) )
+      {
+        AliDebug(1,Form("pT1 %2.2f; bit requested %d; decay bit1: In %d",fMomentum1.Pt(), GetNeutralMesonSelection()->GetDecayBit(), bit1));
         
-        // Fill histograms to undertand pile-up before other cuts applied
-        // Remember to relax time cuts in the reader
-        FillPileUpHistograms(mom.Pt(),((cluster1->GetTOF()+cluster2->GetTOF())*1e9)/2,cluster1);
+        GetNeutralMesonSelection()->SetDecayBit(bit1);
+        photon1->SetDecayTag(bit1);
         
-        //Create AOD for analysis
+        AliDebug(1,Form("\t Out %d", bit1));
         
-        AliAODPWG4Particle pi0 = AliAODPWG4Particle(mom);
+        fhPtDecay->Fill(photon1->Pt());
+
+        //Fill some histograms about shower shape
+        if(fFillSelectClHisto && cluster1 && GetReader()->GetDataType()!=AliCaloTrackReader::kMC)
+          FillSelectedClusterHistograms(cluster1, fMomentum1.Pt(), nMaxima1, photon1->GetTag());
         
-        if     ( (GetNeutralMesonSelection()->GetParticle()).Contains("Pi0") ) pi0.SetIdentifiedParticleType(AliCaloPID::kPi0);
-        else if( (GetNeutralMesonSelection()->GetParticle()).Contains("Eta") ) pi0.SetIdentifiedParticleType(AliCaloPID::kEta);
-        else
+        if(IsDataMC())
         {
-          printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - Particle type declared in AliNeutralMeson not correct, do not add \n");
-          return ;
+          Int_t mcIndex1 = GetMCIndex(photon1->GetTag());
+          fhMCPtDecay[mcIndex1]->Fill(photon1->Pt());
+          if(GetMCAnalysisUtils()->CheckTagBit(photon1->GetTag(),AliMCAnalysisUtils::kMCDecayPairLost))
+          {
+            if     ( mcIndex1 == kmcPi0Decay ) fhMCPtDecayLostPairPi0->Fill(photon1->Pt());
+            else if( mcIndex1 == kmcEtaDecay ) fhMCPtDecayLostPairEta->Fill(photon1->Pt());
+          }
         }
-        pi0.SetDetector(photon1->GetDetector());
+      }
+      
+      Int_t bit2 = photon2->DecayTag();
+      if( bit2 < 0 ) bit2 = 0 ;
+      if( !GetNeutralMesonSelection()->CheckDecayBit(bit2) )
+      {
+        AliDebug(1,Form("pT2 %2.2f; bit requested %d; decay bit2: In %d",fMomentum2.Pt(), GetNeutralMesonSelection()->GetDecayBit(), bit2));
+        
+        GetNeutralMesonSelection()->SetDecayBit(bit2);
+        photon2->SetDecayTag(bit2);
         
-        // MC
-        pi0.SetLabel(label);
-        pi0.SetTag(tag);
+        AliDebug(1,Form("\t Out %d", bit2));
         
-        //Set the indeces of the original caloclusters
-        pi0.SetCaloLabel(photon1->GetCaloLabel(0), photon2->GetCaloLabel(0));
-        //pi0.SetInputFileIndex(input);
+        fhPtDecay->Fill(photon2->Pt());
         
-        AddAODParticle(pi0);
+        //Fill some histograms about shower shape
+        if(fFillSelectClHisto && cluster2 && GetReader()->GetDataType()!=AliCaloTrackReader::kMC)
+          FillSelectedClusterHistograms(cluster2, fMomentum2.Pt(), nMaxima2, photon2->GetTag());
         
-      }//pi0
+        if(IsDataMC())
+        {
+          Int_t mcIndex2 = GetMCIndex(photon2->GetTag());
+          fhMCPtDecay[mcIndex2]->Fill(photon2->Pt());
+          if(GetMCAnalysisUtils()->CheckTagBit(photon2->GetTag(),AliMCAnalysisUtils::kMCDecayPairLost))
+          {
+            if     ( mcIndex2 == kmcPi0Decay ) fhMCPtDecayLostPairPi0->Fill(photon2->Pt());
+            else if( mcIndex2 == kmcEtaDecay ) fhMCPtDecayLostPairEta->Fill(photon2->Pt());
+          }
+        }
+      }
+      
+      //Mass of selected pairs
+      fhSelectedMass  ->Fill( epair,mass);
+      fhSelectedMassPt->Fill(ptpair,mass);
+      if(IsDataMC()  && mcIndex < 2) fhMCSelectedMassPt[mcIndex]->Fill(ptpair,mass);
+      
+      // Fill histograms to undertand pile-up before other cuts applied
+      // Remember to relax time cuts in the reader
+      FillPileUpHistograms(ptpair,((cluster1->GetTOF()+cluster2->GetTOF())*1e9)/2,cluster1);
+      
+      //Create AOD for analysis
+      AliAODPWG4Particle pi0 = AliAODPWG4Particle(fMomentum);
+      
+      if     ( (GetNeutralMesonSelection()->GetParticle()).Contains("Pi0") ) pi0.SetIdentifiedParticleType(AliCaloPID::kPi0);
+      else if( (GetNeutralMesonSelection()->GetParticle()).Contains("Eta") ) pi0.SetIdentifiedParticleType(AliCaloPID::kEta);
+      else
+      {
+        AliWarning("Particle type declared in AliNeutralMeson not correct, do not add");
+        return ;
+      }
+      pi0.SetDetectorTag(photon1->GetDetectorTag());
+      
+      // MC
+      pi0.SetLabel(label);
+      pi0.SetTag(tag);
+      
+      //Set the indeces of the original caloclusters
+      pi0.SetCaloLabel(photon1->GetCaloLabel(0), photon2->GetCaloLabel(0));
+      //pi0.SetInputFileIndex(input);
+      
+      AddAODParticle(pi0);
       
     }//2n photon loop
     
   }//1st photon loop
   
-  if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeInvMassInCalorimeter() - End fill AODs \n");
+  AliDebug(1,"End fill AODs");
   
 }
 
@@ -2848,18 +3064,10 @@ void  AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS()
   //Read photon list from AOD, produced in class AliAnaPhoton and AliGammaConversion
   //Check if 2 photons have the mass of the pi0.
   
-  TLorentzVector mom1;
-  TLorentzVector mom2;
-  TLorentzVector mom ;
-  Int_t tag   = 0;
-  Int_t label = 0;
-  Int_t evtIndex = 0;
-  
   // Check calorimeter input
   if(!GetInputAODBranch())
   {
-    printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - No input calo photons in AOD branch with name < %s > , STOP\n",GetInputAODName().Data());
-    abort();
+    AliFatal(Form("No input calo photons in AOD branch with name < %s > , STOP",GetInputAODName().Data()));
   }
   
   // Get the array with conversion photons
@@ -2870,34 +3078,40 @@ void  AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS()
     
     if(!inputAODGammaConv)
     {
-      printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - No input gamma conversions in AOD branch with name < %s >\n",fInputAODGammaConvName.Data());
-      
-      return;
+      AliFatal(Form("No input gamma conversions in AOD branch with name < %s >",fInputAODGammaConvName.Data()));
+      return; // coverity
     }
   }
   
   //Get shower shape information of clusters
   TObjArray *clusters = 0;
-  if     (fCalorimeter=="EMCAL") clusters = GetEMCALClusters();
-  else if(fCalorimeter=="PHOS")  clusters = GetPHOSClusters() ;
+  if     (GetCalorimeter()==kEMCAL) clusters = GetEMCALClusters();
+  else if(GetCalorimeter()==kPHOS)  clusters = GetPHOSClusters() ;
   
   Int_t nCTS  = inputAODGammaConv->GetEntriesFast();
   Int_t nCalo = GetInputAODBranch()->GetEntriesFast();
   if(nCTS<=0 || nCalo <=0)
   {
-    if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - nCalo %d, nCTS %d, cannot loop\n",nCalo,nCTS);
+    AliDebug(1,Form("nCalo %d, nCTS %d, cannot loop",nCalo,nCTS));
     return;
   }
   
-  if(GetDebug() > 1)
-    printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - Number of conversion photons %d\n",nCTS);
+  AliDebug(1,Form("Number of conversion photons %d and number of clusters %d",nCTS,nCalo));
   
   // Do the loop, first calo, second CTS
   for(Int_t iphoton = 0; iphoton < GetInputAODBranch()->GetEntriesFast(); iphoton++)
   {
     AliAODPWG4Particle * photon1 =  (AliAODPWG4Particle*) (GetInputAODBranch()->At(iphoton));
-    mom1 = *(photon1->Momentum());
+    fMomentum1 = *(photon1->Momentum());
     
+    // Do analysis only when one of the decays is isolated
+    // Run AliAnaParticleIsolation before
+    if(fSelectIsolatedDecay)
+    {
+      Bool_t isolated1 = ((AliAODPWG4ParticleCorrelation*) photon1)->IsIsolated();
+      if(!isolated1) continue;
+    }
+
     //Get original cluster, to recover some information
     Int_t iclus = -1;
     AliVCluster *cluster = FindCluster(clusters,photon1->GetCaloLabel(0),iclus);
@@ -2906,122 +3120,168 @@ void  AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS()
     {
       AliAODPWG4Particle * photon2 =  (AliAODPWG4Particle*) (inputAODGammaConv->At(jphoton));
       
+      Int_t evtIndex = 0;
       if(GetMixedEvent())
+      {
         evtIndex = GetMixedEvent()->EventIndexForCaloCluster(photon2->GetCaloLabel(0)) ;
-      if(TMath::Abs(GetVertex(evtIndex)[2]) > GetZvertexCut()) continue ;  //vertex cut
+        if(TMath::Abs(GetVertex(evtIndex)[2]) > GetZvertexCut()) continue ;  //vertex cut
+      }
       
-      mom2 = *(photon2->Momentum());
+      fMomentum2 = *(photon2->Momentum());
       
-      mom = mom1+mom2;
+      fMomentum = fMomentum1+fMomentum2;
       
-      Double_t mass  = mom.M();
-      Double_t epair = mom.E();
+      Double_t mass  = fMomentum.M();
+      Double_t epair = fMomentum.E();
+      Float_t ptpair = fMomentum.Pt();
       
-      Int_t nMaxima = photon1->GetFiducialArea();
-      if     (nMaxima==1) fhMassPairLocMax[0]->Fill(epair,mass);
-      else if(nMaxima==2) fhMassPairLocMax[1]->Fill(epair,mass);
-      else                fhMassPairLocMax[2]->Fill(epair,mass);
+      Int_t nMaxima = photon1->GetNLM();
+      if(fFillAllNLMHistograms)
+      {
+        if     (nMaxima==1) fhMassPairLocMax[0]->Fill(epair,mass);
+        else if(nMaxima==2) fhMassPairLocMax[1]->Fill(epair,mass);
+        else                fhMassPairLocMax[2]->Fill(epair,mass);
+      }
       
-      if(nMaxima < fNLMCutMin || nMaxima > fNLMCutMax) continue ;
-      if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - NLM %d of out of range \n",nMaxima);
+      if(nMaxima < fNLMCutMin || nMaxima > fNLMCutMax)
+      {
+        AliDebug(1,Form("NLM %d out of range",nMaxima));
+        continue ;
+      }
       
       //Play with the MC stack if available
+      Int_t mcIndex = kmcHadron;
+      Int_t tag     = 0;
+      Int_t label   =-1;
       if(IsDataMC())
       {
         Int_t  label2 = photon2->GetLabel();
-        if(label2 >= 0 )photon2->SetTag(GetMCAnalysisUtils()->CheckOrigin(label2, GetReader()));
+        if(label2 >= 0 )photon2->SetTag(GetMCAnalysisUtils()->CheckOrigin(label2, GetReader(),kCTS));
         
-        HasPairSameMCMother(photon1, photon2, label, tag) ;
+        HasPairSameMCMother(photon1->GetLabel(), photon2->GetLabel(),
+                            photon1->GetTag()  , photon2->GetTag(),
+                            label, tag) ;
+        mcIndex = GetMCIndex(tag);
       }
       
       //Mass of selected pairs
-      fhMass->Fill(epair,mass);
-      
-      //Select good pair (good phi, pt cuts, aperture and invariant mass)
-      if(GetNeutralMesonSelection()->SelectPair(mom1, mom2,fCalorimeter))
+      fhMass  ->Fill( epair,mass);
+      fhMassPt->Fill(ptpair,mass);
+      if(IsDataMC() && mcIndex < 2 ) fhMCMassPt[mcIndex]->Fill(ptpair,mass);
+
+      //
+      // Select good pair (good phi, pt cuts, aperture and invariant mass)
+      //
+      if(!GetNeutralMesonSelection()->SelectPair(fMomentum1, fMomentum2,GetCalorimeter())) continue ;
+      
+      AliDebug(1,Form("Selected gamma pair: pt %f, phi %f, eta%f",fMomentum.Pt(), fMomentum.Phi()*TMath::RadToDeg(), fMomentum.Eta()));
+      
+      //
+      // Tag both photons as decay if not done before
+      // set the corresponding bit for pi0 or eta or "side" case
+      //
+      Int_t bit1 = photon1->DecayTag();
+      if( bit1 < 0 ) bit1 = 0 ;
+      if( !GetNeutralMesonSelection()->CheckDecayBit(bit1) )
       {
-        if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - Selected gamma pair: pt %f, phi %f, eta%f\n",
-                                  mom.Pt(), mom.Phi()*TMath::RadToDeg(), mom.Eta());
-        
-        //Fill some histograms about shower shape
-        if(fFillSelectClHisto && cluster && GetReader()->GetDataType()!=AliCaloTrackReader::kMC)
-        {
-          FillSelectedClusterHistograms(cluster, mom1.Pt(), nMaxima, photon1->GetTag());
-        }
-        
-        // Tag both photons as decay, !!careful!! since in case of SideBand analysis, also they will be tagged.
-        photon1->SetTagged(kTRUE);
-        photon2->SetTagged(kTRUE);
+        GetNeutralMesonSelection()->SetDecayBit(bit1);
+        photon1->SetDecayTag(bit1);
         
         fhPtDecay->Fill(photon1->Pt());
-        fhEDecay ->Fill(photon1->E() );
-        
-        //Mass of selected pairs
-        fhSelectedMass->Fill(epair,mass);
-        
-        // Fill histograms to undertand pile-up before other cuts applied
-        // Remember to relax time cuts in the reader
-        if(cluster) FillPileUpHistograms(mom.Pt(),cluster->GetTOF()*1e9,cluster);
-
-        //Create AOD for analysis
         
-        AliAODPWG4Particle pi0 = AliAODPWG4Particle(mom);
+        //Fill some histograms about shower shape
+        if(fFillSelectClHisto && cluster && GetReader()->GetDataType()!=AliCaloTrackReader::kMC)
+          FillSelectedClusterHistograms(cluster, fMomentum1.Pt(), nMaxima, photon1->GetTag());
         
-        if     ( (GetNeutralMesonSelection()->GetParticle()).Contains("Pi0") ) pi0.SetIdentifiedParticleType(AliCaloPID::kPi0);
-        else if( (GetNeutralMesonSelection()->GetParticle()).Contains("Eta") ) pi0.SetIdentifiedParticleType(AliCaloPID::kEta);
-        else
+        if(IsDataMC())
         {
-          printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - Particle type declared in AliNeutralMeson not correct, do not add \n");
-          return ;
+          Int_t mcIndex1 = GetMCIndex(photon1->GetTag());
+          fhMCPtDecay[mcIndex1]->Fill(photon1->Pt());
+          if(GetMCAnalysisUtils()->CheckTagBit(photon1->GetTag(),AliMCAnalysisUtils::kMCDecayPairLost))
+          {
+            if     ( mcIndex1 == kmcPi0Decay ) fhMCPtDecayLostPairPi0->Fill(photon1->Pt());
+            else if( mcIndex1 == kmcEtaDecay ) fhMCPtDecayLostPairEta->Fill(photon1->Pt());
+          }
         }
-        pi0.SetDetector(photon1->GetDetector());
-        
-        // MC
-        pi0.SetLabel(label);
-        pi0.SetTag(tag);
-        
-        //Set the indeces of the original tracks or caloclusters
-        pi0.SetCaloLabel (photon1->GetCaloLabel(0) , -1);
-        pi0.SetTrackLabel(photon2->GetTrackLabel(0), photon2->GetTrackLabel(1));
-        //pi0.SetInputFileIndex(input);
-        
-        AddAODParticle(pi0);
-        
-      }//pi0
+      }
+      
+      Int_t bit2 = photon2->DecayTag();
+      if( bit2 < 0 ) bit2 = 0 ;
+      if( !GetNeutralMesonSelection()->CheckDecayBit(bit2) )
+      {
+        GetNeutralMesonSelection()->SetDecayBit(bit2);
+        photon2->SetDecayTag(bit2);
+      }
+      
+      //Mass of selected pairs
+      fhSelectedMass  ->Fill( epair,mass);
+      fhSelectedMassPt->Fill(ptpair,mass);
+      if(IsDataMC()  && mcIndex < 2) fhMCSelectedMassPt[mcIndex]->Fill(ptpair,mass);
+      
+      // Fill histograms to undertand pile-up before other cuts applied
+      // Remember to relax time cuts in the reader
+      if(cluster) FillPileUpHistograms(fMomentum.Pt(),cluster->GetTOF()*1e9,cluster);
+      
+      //Create AOD for analysis
+      
+      AliAODPWG4Particle pi0 = AliAODPWG4Particle(fMomentum);
+      
+      if     ( (GetNeutralMesonSelection()->GetParticle()).Contains("Pi0") ) pi0.SetIdentifiedParticleType(AliCaloPID::kPi0);
+      else if( (GetNeutralMesonSelection()->GetParticle()).Contains("Eta") ) pi0.SetIdentifiedParticleType(AliCaloPID::kEta);
+      else
+      {
+        AliWarning("Particle type declared in AliNeutralMeson not correct, do not add");
+        return ;
+      }
+      pi0.SetDetectorTag(photon1->GetDetectorTag());
+      
+      // MC
+      pi0.SetLabel(label);
+      pi0.SetTag(tag);
+      
+      //Set the indeces of the original tracks or caloclusters
+      pi0.SetCaloLabel (photon1->GetCaloLabel(0) , -1);
+      pi0.SetTrackLabel(photon2->GetTrackLabel(0), photon2->GetTrackLabel(1));
+      //pi0.SetInputFileIndex(input);
+      
+      AddAODParticle(pi0);
+      
     }//2n photon loop
     
   }//1st photon loop
   
-  if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeInvMassInCalorimeterAndCTS() - End fill AODs \n");
+  AliDebug(1,"End fill AODs");
   
 }
 
 //_________________________________________________
 void  AliAnaPi0EbE::MakeShowerShapeIdentification()
 {
-  //Search for pi0 in fCalorimeter with shower shape analysis
-  
+  //Search for pi0 in GetCalorimeter() with shower shape analysis
+
   TObjArray * pl        = 0x0;
   AliVCaloCells * cells = 0x0;
   //Select the Calorimeter of the photon
-  if      (fCalorimeter == "PHOS" )
-  {
-    pl    = GetPHOSClusters();
-    cells = GetPHOSCells();
-  }
-  else if (fCalorimeter == "EMCAL")
+  if      (GetCalorimeter() == kEMCAL )
   {
     pl    = GetEMCALClusters();
     cells = GetEMCALCells();
   }
+  else if (GetCalorimeter() == kPHOS)
+  {
+    AliFatal("kSSCalo case not implememted for PHOS");
+    return; // for coverity
+    
+    //pl    = GetPHOSClusters();
+    //cells = GetPHOSCells();
+  }
   
   if(!pl)
   {
-    Info("MakeShowerShapeIdentification","TObjArray with %s clusters is NULL!\n",fCalorimeter.Data());
+    AliInfo(Form("TObjArray with %s clusters is NULL!",GetCalorimeterString().Data()));
     return;
   }
-       
-  TLorentzVector mom ;
+
   for(Int_t icalo = 0; icalo < pl->GetEntriesFast(); icalo++)
   {
     AliVCluster * calo = (AliVCluster*) (pl->At(icalo));
@@ -3030,73 +3290,69 @@ void  AliAnaPi0EbE::MakeShowerShapeIdentification()
     if (GetMixedEvent())
     {
       evtIndex=GetMixedEvent()->EventIndexForCaloCluster(calo->GetID()) ;
+      if(TMath::Abs(GetVertex(evtIndex)[2]) > GetZvertexCut()) continue ;  //vertex cut
     }
     
-    if(TMath::Abs(GetVertex(evtIndex)[2]) > GetZvertexCut()) continue ;  //vertex cut
-    
     //Get Momentum vector,
     Double_t vertex[]={0,0,0};
     if(GetReader()->GetDataType() != AliCaloTrackReader::kMC)
     {
-      calo->GetMomentum(mom,GetVertex(evtIndex)) ;
+      calo->GetMomentum(fMomentum,GetVertex(evtIndex)) ;
     }//Assume that come from vertex in straight line
     else
     {
-      calo->GetMomentum(mom,vertex) ;
+      calo->GetMomentum(fMomentum,vertex) ;
     }
-         
+    
     //If too small or big pt, skip it
-    if(mom.E() < GetMinEnergy() || mom.E() > GetMaxEnergy() ) continue ;
+    if(fMomentum.E() < GetMinEnergy() || fMomentum.E() > GetMaxEnergy() ) continue ;
     
     //Check acceptance selection
     if(IsFiducialCutOn())
     {
-      Bool_t in = GetFiducialCut()->IsInFiducialCut(mom,fCalorimeter) ;
+      Bool_t in = GetFiducialCut()->IsInFiducialCut(fMomentum.Eta(),fMomentum.Phi(),GetCalorimeter()) ;
       if(! in ) continue ;
     }
     
-    if(GetDebug() > 1)
-      printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - FillAOD: Min pt cut and fiducial cut passed: pt %3.2f, phi %2.2f, eta %1.2f\n",mom.Pt(),mom.Phi(),mom.Eta());
+    AliDebug(1,Form("Min pt cut and fiducial cut passed: pt %3.2f, phi %2.2f, eta %1.2f",fMomentum.Pt(),fMomentum.Phi(),fMomentum.Eta()));
     
     //Play with the MC stack if available
     //Check origin of the candidates
     Int_t tag  = 0 ;
     if(IsDataMC())
     {
-      tag = GetMCAnalysisUtils()->CheckOrigin(calo->GetLabels(),calo->GetNLabels(),GetReader());
+      tag = GetMCAnalysisUtils()->CheckOrigin(calo->GetLabels(),calo->GetNLabels(),GetReader(),GetCalorimeter());
       //GetMCAnalysisUtils()->CheckMultipleOrigin(calo->GetLabels(),calo->GetNLabels(), GetReader(), aodpi0.GetInputFileIndex(), tag);
-      if(GetDebug() > 0) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - Origin of candidate %d\n",tag);
+      AliDebug(1,Form("Origin of candidate %d",tag));
     }
-    
+
     //Int_t nMaxima = GetCaloUtils()->GetNumberOfLocalMaxima(calo, cells); // NLM
     
     //Check Distance to Bad channel, set bit.
     Double_t distBad=calo->GetDistanceToBadChannel() ; //Distance to bad channel
     if(distBad < 0.) distBad=9999. ; //workout strange convension dist = -1. ;
     if(distBad < fMinDist){ //In bad channel (PHOS cristal size 2.2x2.2 cm)
-      //FillRejectedClusterHistograms(mom,tag,nMaxima);
+      //FillRejectedClusterHistograms(tag,nMaxima);
       continue ;
     }
  
-    if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - FillAOD: Bad channel cut passed %4.2f\n",distBad);
+    AliDebug(1,Form("Bad channel cut passed %4.2f",distBad));
     
     //If too low number of cells, skip it
     if ( calo->GetNCells() < GetCaloPID()->GetClusterSplittingMinNCells())
     {
-      //FillRejectedClusterHistograms(mom,tag,nMaxima);
+      //FillRejectedClusterHistograms(tag,nMaxima);
       continue ;
     }
     
-    if(GetDebug() > 1)
-      printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - FillAOD: N cells cut passed %d > %d\n",
-             calo->GetNCells(), GetCaloPID()->GetClusterSplittingMinNCells());
+    AliDebug(1,Form("N cells cut passed %d > %d",calo->GetNCells(), GetCaloPID()->GetClusterSplittingMinNCells()));
     
     //.......................................
     // TOF cut, BE CAREFUL WITH THIS CUT
     Double_t tof = calo->GetTOF()*1e9;
     if(tof < fTimeCutMin || tof > fTimeCutMax)
     {
-      //FillRejectedClusterHistograms(mom,tag,nMaxima);
+      //FillRejectedClusterHistograms(tag,nMaxima);
       continue ;
     }
 
@@ -3107,51 +3363,70 @@ void  AliAnaPi0EbE::MakeShowerShapeIdentification()
     Int_t    absId1   =-1, absId2   =-1;
     Float_t  distbad1 =-1, distbad2 =-1;
     Bool_t   fidcut1  = 0, fidcut2  = 0;
-    TLorentzVector    l1, l2;
 
     Int_t idPartType = GetCaloPID()->GetIdentifiedParticleTypeFromClusterSplitting(calo,cells,GetCaloUtils(),
                                                                                    GetVertex(evtIndex),nMaxima,
-                                                                                   mass,angle,l1,l2,absId1,absId2,
-                                                                                   distbad1,distbad2,fidcut1,fidcut2) ;
+                                                                                   mass,angle,
+                                                                                   fMomentum1,fMomentum2,
+                                                                                   absId1,absId2,
+                                                                                   distbad1,distbad2,
+                                                                                   fidcut1,fidcut2) ;
     
     
-    if(GetDebug() > 1) printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - PDG of identified particle %d\n",idPartType);
-    
+    AliDebug(1,Form("PDG of identified particle %d",idPartType));
     
     // Skip events where one of the new clusters (lowest energy) is close to an EMCal border or a bad channel
     if( (fCheckSplitDistToBad) &&
        (!fidcut2 || !fidcut1 || distbad1 < fMinDist || distbad2 < fMinDist))
     {
-      if(GetDebug() > 1)
-        Info("MakeShowerShapeIdentification", "Dist to bad channel cl %f, cl1 %f, cl2 %f; fid cl1 %d, cl2 %d \n",
-               calo->GetDistanceToBadChannel(),distbad1,distbad2, fidcut1,fidcut2);
+      AliDebug(1,Form("Dist to bad channel cl %f, cl1 %f, cl2 %f; fid cl1 %d, cl2 %d",
+                      calo->GetDistanceToBadChannel(),distbad1,distbad2, fidcut1,fidcut2));
       
-      //FillRejectedClusterHistograms(mom,tag,nMaxima);
+      //FillRejectedClusterHistograms(tag,nMaxima);
       continue ;
     }
     
     //Skip events with too few or too many  NLM
     if(nMaxima < fNLMCutMin || nMaxima > fNLMCutMax)
     {
-      //FillRejectedClusterHistograms(mom,tag,nMaxima);
+      //FillRejectedClusterHistograms(tag,nMaxima);
       continue ;
     }
     
-    if(GetDebug() > 1)
-      printf("AliAnaPi0EbE::MakeShowerShapeIdentification() - NLM %d accepted \n",nMaxima);
+    AliDebug(1,Form("NLM %d accepted",nMaxima));
     
     //Skip matched clusters with tracks
     if(fRejectTrackMatch && IsTrackMatched(calo, GetReader()->GetInputEvent()))
     {
-      FillRejectedClusterHistograms(mom,tag,nMaxima);
+      FillRejectedClusterHistograms(tag,nMaxima);
       continue ;
     }
-
-    Float_t e1 = l1.Energy();
-    Float_t e2 = l2.Energy();
-    TLorentzVector l12 = l1+l2;
-    Float_t ptSplit = l12.Pt();
+    
+    Float_t l0 = calo->GetM02();
+    Float_t e1 = fMomentum1.Energy();
+    Float_t e2 = fMomentum2.Energy();
+    fMomentum12 = fMomentum1+fMomentum2;
+    Float_t ptSplit = fMomentum12.Pt();
     Float_t  eSplit = e1+e2;
+
+    //mass of all clusters
+    fhMass       ->Fill(fMomentum.E() ,mass);
+    fhMassPt     ->Fill(fMomentum.Pt(),mass);
+    fhMassSplitPt->Fill(ptSplit ,mass);
+    fhPtLambda0NoSplitCut->Fill(fMomentum.Pt(),l0);
+    
+    // Asymmetry of all clusters
+    Float_t asy =-10;
+    
+    if(e1+e2 > 0) asy = (e1-e2) / (e1+e2);
+    fhAsymmetry->Fill(fMomentum.E(),asy);
+    
+    // Divide NLM in 3 cases, 1 local maxima, 2 local maxima, more than 2 local maxima
+    Int_t indexMax = -1;
+    if     (nMaxima==1) indexMax = 0 ;
+    else if(nMaxima==2) indexMax = 1 ;
+    else                indexMax = 2 ;
+    fhMassPtLocMax[indexMax]->Fill(fMomentum.Pt(),mass);
     
     Int_t   mcIndex   =-1;
     Int_t   noverlaps = 0;
@@ -3163,7 +3438,7 @@ void  AliAnaPi0EbE::MakeShowerShapeIdentification()
       Bool_t ok      = kFALSE;
       Int_t  mcLabel = calo->GetLabel();
       
-      TLorentzVector primary = GetMCAnalysisUtils()->GetMother(mcLabel,GetReader(),ok);
+      fPrimaryMom = GetMCAnalysisUtils()->GetMother(mcLabel,GetReader(),ok);
       
       Int_t mesonLabel = -1;
       
@@ -3171,49 +3446,35 @@ void  AliAnaPi0EbE::MakeShowerShapeIdentification()
       {
         if(mcIndex == kmcPi0)
         {
-          TLorentzVector grandmom = GetMCAnalysisUtils()->GetMotherWithPDG(mcLabel,111,GetReader(),ok,mesonLabel);
-          if(grandmom.E() > 0 && ok) ptprim =  grandmom.Pt();
+          fGrandMotherMom = GetMCAnalysisUtils()->GetMotherWithPDG(mcLabel,111,GetReader(),ok,mesonLabel);
+          if(fGrandMotherMom.E() > 0 && ok) ptprim =  fGrandMotherMom.Pt();
         }
         else
         {
-          TLorentzVector grandmom = GetMCAnalysisUtils()->GetMotherWithPDG(mcLabel,221,GetReader(),ok,mesonLabel);
-          if(grandmom.E() > 0 && ok) ptprim =  grandmom.Pt();
+          fGrandMotherMom = GetMCAnalysisUtils()->GetMotherWithPDG(mcLabel,221,GetReader(),ok,mesonLabel);
+          if(fGrandMotherMom.E() > 0 && ok) ptprim = fGrandMotherMom.Pt();
         }
       }
             
       const UInt_t nlabels = calo->GetNLabels();
       Int_t overpdg[nlabels];
       noverlaps = GetMCAnalysisUtils()->GetNOverlaps(calo->GetLabels(), nlabels,tag,mesonLabel,GetReader(),overpdg);
-    }
-    
-    //mass of all clusters
-    fhMass       ->Fill(mom.E() ,mass);
-    fhMassPt     ->Fill(mom.Pt(),mass);
-    fhMassSplitPt->Fill(ptSplit ,mass);
-    
-    Int_t indexMax = -1;
-    if     (nMaxima==1) indexMax = 0 ;
-    else if(nMaxima==2) indexMax = 1 ;
-    else                indexMax = 2 ;
-    fhMassPtLocMax[indexMax]->Fill(mom.Pt(),mass);
-
-    if(IsDataMC())
-    {
-      fhMCMassPt[mcIndex]     ->Fill(mom.Pt(),mass);
+      fhMCMassPt     [mcIndex]->Fill(fMomentum.Pt(),mass);
       fhMCMassSplitPt[mcIndex]->Fill(ptSplit ,mass);
       if(mcIndex==kmcPi0)
       {
-        fhMCPi0PtRecoPtPrim                     ->Fill(mom.Pt(),ptprim);
+        fhMCPi0PtRecoPtPrim                     ->Fill(fMomentum.Pt(),ptprim);
         fhMCPi0SplitPtRecoPtPrim                ->Fill(ptSplit ,ptprim);
-        fhMCPi0PtRecoPtPrimLocMax     [indexMax]->Fill(mom.Pt(),ptprim);
+        fhMCPi0PtRecoPtPrimLocMax     [indexMax]->Fill(fMomentum.Pt(),ptprim);
         fhMCPi0SplitPtRecoPtPrimLocMax[indexMax]->Fill(ptSplit ,ptprim);
 
       }
       else if(mcIndex==kmcEta)
       {
-        fhMCEtaPtRecoPtPrim                     ->Fill(mom.Pt(),ptprim);
+        fhMCEtaPtRecoPtPrim                     ->Fill(fMomentum.Pt(),ptprim);
         fhMCEtaSplitPtRecoPtPrim                ->Fill(ptSplit ,ptprim);
-        fhMCEtaPtRecoPtPrimLocMax     [indexMax]->Fill(mom.Pt(),ptprim);
+        fhMCEtaPtRecoPtPrimLocMax     [indexMax]->Fill(fMomentum.Pt(),ptprim);
         fhMCEtaSplitPtRecoPtPrimLocMax[indexMax]->Fill(ptSplit ,ptprim);
       }
 
@@ -3221,99 +3482,88 @@ void  AliAnaPi0EbE::MakeShowerShapeIdentification()
       {
         if(mcIndex==kmcPi0)
         {
-          fhMCPi0PtRecoPtPrimNoOverlap     ->Fill(mom.Pt(),ptprim);
+          fhMCPi0PtRecoPtPrimNoOverlap     ->Fill(fMomentum.Pt(),ptprim);
           fhMCPi0SplitPtRecoPtPrimNoOverlap->Fill(ptSplit ,ptprim);
         }
         else if(mcIndex==kmcEta)
         {
-          fhMCEtaPtRecoPtPrimNoOverlap     ->Fill(mom.Pt(),ptprim);
+          fhMCEtaPtRecoPtPrimNoOverlap     ->Fill(fMomentum.Pt(),ptprim);
           fhMCEtaSplitPtRecoPtPrimNoOverlap->Fill(ptSplit ,ptprim);
         }
         
-        fhMassNoOverlap       ->Fill(mom.E() ,mass);
-        fhMassPtNoOverlap     ->Fill(mom.Pt(),mass);
+        fhMassNoOverlap       ->Fill(fMomentum.E() ,mass);
+        fhMassPtNoOverlap     ->Fill(fMomentum.Pt(),mass);
         fhMassSplitPtNoOverlap->Fill(ptSplit ,mass);
         
-        fhMCMassPtNoOverlap[mcIndex]     ->Fill(mom.Pt(),mass);
+        fhMCMassPtNoOverlap     [mcIndex]->Fill(fMomentum.Pt(),mass);
         fhMCMassSplitPtNoOverlap[mcIndex]->Fill(ptSplit ,mass);
       }
-    }
-    
-    // Asymmetry of all clusters
-    Float_t asy =-10;
-    
-    if(e1+e2 > 0) asy = (e1-e2) / (e1+e2);
-    fhAsymmetry->Fill(mom.E(),asy);
-    
-    if(IsDataMC())
-    {
-      fhMCPtAsymmetry[mcIndex]->Fill(mom.Pt(),asy);
+
+      fhMCPtAsymmetry[mcIndex]->Fill(fMomentum.Pt(),asy);
     }
     
     // If cluster does not pass pid, not pi0/eta, skip it.
     if     (GetOutputAODName().Contains("Pi0") && idPartType != AliCaloPID::kPi0)
     {
-      if(GetDebug() > 1) Info("MakeShowerShapeIdentification","Cluster is not Pi0\n");
-      FillRejectedClusterHistograms(mom,tag,nMaxima);
+      AliDebug(1,"Cluster is not Pi0");
+      FillRejectedClusterHistograms(tag,nMaxima);
       continue ;
     }
     
     else if(GetOutputAODName().Contains("Eta") && idPartType != AliCaloPID::kEta)
     {
-      if(GetDebug() > 1) Info("MakeShowerShapeIdentification","Cluster is not Eta\n");
-      FillRejectedClusterHistograms(mom,tag,nMaxima);
+      AliDebug(1,"Cluster is not Eta");
+      FillRejectedClusterHistograms(tag,nMaxima);
       continue ;
     }
     
-    if(GetDebug() > 1)
-      Info("MakeShowerShapeIdentification","Pi0/Eta selection cuts passed: pT %3.2f, pdg %d\n",
-             mom.Pt(), idPartType);
-    
+    AliDebug(1,Form("Pi0/Eta selection cuts passed: pT %3.2f, pdg %d",fMomentum.Pt(), idPartType));
+        
     //Mass and asymmetry of selected pairs
-    fhSelectedAsymmetry  ->Fill(mom.E() ,asy );
-    fhSelectedMass       ->Fill(mom.E() ,mass);
-    fhSelectedMassPt     ->Fill(mom.Pt(),mass);
+    fhSelectedAsymmetry  ->Fill(fMomentum.E() ,asy );
+    fhSelectedMass       ->Fill(fMomentum.E() ,mass);
+    fhSelectedMassPt     ->Fill(fMomentum.Pt(),mass);
     fhSelectedMassSplitPt->Fill(ptSplit ,mass);
-    fhSelectedMassPtLocMax[indexMax]->Fill(mom.Pt(),mass);
-    
+    fhSelectedMassPtLocMax[indexMax]->Fill(fMomentum.Pt(),mass);
+
     Int_t   nSM  = GetModuleNumber(calo);
-    if(nSM < GetCaloUtils()->GetNumberOfSuperModulesUsed() && nSM >=0)
+    if(nSM < GetCaloUtils()->GetNumberOfSuperModulesUsed() && nSM >=0 && fFillAllNLMHistograms)
     {
-      fhSelectedMassPtLocMaxSM   [indexMax][nSM]->Fill(mom.Pt(),mass);
-      fhSelectedLambda0PtLocMaxSM[indexMax][nSM]->Fill(mom.Pt(),calo->GetM02());
+      fhSelectedMassPtLocMaxSM   [indexMax][nSM]->Fill(fMomentum.Pt(),mass);
+      fhSelectedLambda0PtLocMaxSM[indexMax][nSM]->Fill(fMomentum.Pt(),l0  );
     }
-    
+
     if(IsDataMC())
     {
       if(mcIndex==kmcPi0)
       {
-        fhMCPi0SelectedPtRecoPtPrim                     ->Fill(mom.Pt(),ptprim);
+        fhMCPi0SelectedPtRecoPtPrim                     ->Fill(fMomentum.Pt(),ptprim);
         fhMCPi0SelectedSplitPtRecoPtPrim                ->Fill(ptSplit ,ptprim);
-        fhMCPi0SelectedPtRecoPtPrimLocMax     [indexMax]->Fill(mom.Pt(),ptprim);
+        fhMCPi0SelectedPtRecoPtPrimLocMax     [indexMax]->Fill(fMomentum.Pt(),ptprim);
         fhMCPi0SelectedSplitPtRecoPtPrimLocMax[indexMax]->Fill(ptSplit ,ptprim);
       }
       else if(mcIndex==kmcEta)
       {
-        fhMCEtaSelectedPtRecoPtPrim                     ->Fill(mom.Pt(),ptprim);
+        fhMCEtaSelectedPtRecoPtPrim                     ->Fill(fMomentum.Pt(),ptprim);
         fhMCEtaSelectedSplitPtRecoPtPrim                ->Fill(ptSplit ,ptprim);
-        fhMCEtaSelectedPtRecoPtPrimLocMax     [indexMax]->Fill(mom.Pt(),ptprim);
+        fhMCEtaSelectedPtRecoPtPrimLocMax     [indexMax]->Fill(fMomentum.Pt(),ptprim);
         fhMCEtaSelectedSplitPtRecoPtPrimLocMax[indexMax]->Fill(ptSplit ,ptprim);
       }
       
       if(noverlaps==0)
       {
-        fhSelectedMassNoOverlap       ->Fill(mom.E() ,mass);
-        fhSelectedMassPtNoOverlap     ->Fill(mom.Pt(),mass);
+        fhSelectedMassNoOverlap       ->Fill(fMomentum.E() ,mass);
+        fhSelectedMassPtNoOverlap     ->Fill(fMomentum.Pt(),mass);
         fhSelectedMassSplitPtNoOverlap->Fill(ptSplit ,mass);
         
         if(mcIndex==kmcPi0)
         {
-          fhMCPi0SelectedPtRecoPtPrimNoOverlap     ->Fill(mom.Pt(),ptprim);
+          fhMCPi0SelectedPtRecoPtPrimNoOverlap     ->Fill(fMomentum.Pt(),ptprim);
           fhMCPi0SelectedSplitPtRecoPtPrimNoOverlap->Fill(ptSplit ,ptprim);
         }
         else if(mcIndex==kmcEta)
         {
-          fhMCEtaSelectedPtRecoPtPrimNoOverlap     ->Fill(mom.Pt(),ptprim);
+          fhMCEtaSelectedPtRecoPtPrimNoOverlap     ->Fill(fMomentum.Pt(),ptprim);
           fhMCEtaSelectedSplitPtRecoPtPrimNoOverlap->Fill(ptSplit ,ptprim);
         }
       }
@@ -3321,19 +3571,19 @@ void  AliAnaPi0EbE::MakeShowerShapeIdentification()
     
     fhSplitE        ->Fill( eSplit);
     fhSplitPt       ->Fill(ptSplit);
-    Float_t phi = mom.Phi();
+    Float_t phi = fMomentum.Phi();
     if(phi<0) phi+=TMath::TwoPi();
     fhSplitPtPhi    ->Fill(ptSplit,phi);
-    fhSplitPtEta    ->Fill(ptSplit,mom.Eta());
+    fhSplitPtEta    ->Fill(ptSplit,fMomentum.Eta());
     fhNLocMaxSplitPt->Fill(ptSplit ,nMaxima);
     
     //Check split-clusters with good time window difference
     Double_t tof1  = cells->GetCellTime(absId1);
-    GetCaloUtils()->RecalibrateCellTime(tof1, fCalorimeter, absId1,GetReader()->GetInputEvent()->GetBunchCrossNumber());
+    GetCaloUtils()->RecalibrateCellTime(tof1, GetCalorimeter(), absId1,GetReader()->GetInputEvent()->GetBunchCrossNumber());
     tof1*=1.e9;
     
     Double_t tof2  = cells->GetCellTime(absId2);
-    GetCaloUtils()->RecalibrateCellTime(tof2, fCalorimeter, absId2,GetReader()->GetInputEvent()->GetBunchCrossNumber());
+    GetCaloUtils()->RecalibrateCellTime(tof2, GetCalorimeter(), absId2,GetReader()->GetInputEvent()->GetBunchCrossNumber());
     tof2*=1.e9;
     
     Double_t t12diff = tof1-tof2;
@@ -3344,34 +3594,50 @@ void  AliAnaPi0EbE::MakeShowerShapeIdentification()
       fhMCSplitE        [mcIndex]->Fill( eSplit);
       fhMCSplitPt       [mcIndex]->Fill(ptSplit);
       fhMCSplitPtPhi    [mcIndex]->Fill(ptSplit,phi);
-      fhMCSplitPtEta    [mcIndex]->Fill(ptSplit,mom.Eta());
+      fhMCSplitPtEta    [mcIndex]->Fill(ptSplit,fMomentum.Eta());
       fhMCNLocMaxSplitPt[mcIndex]->Fill(ptSplit ,nMaxima);
-      fhMCNLocMaxPt     [mcIndex]->Fill(mom.Pt(),nMaxima);
+      fhMCNLocMaxPt     [mcIndex]->Fill(fMomentum.Pt(),nMaxima);
       
-      fhMCSelectedMassPt     [mcIndex]->Fill(mom.Pt(),mass);
+      fhMCSelectedMassPt     [mcIndex]->Fill(fMomentum.Pt(),mass);
       fhMCSelectedMassSplitPt[mcIndex]->Fill(ptSplit,mass);
-      fhMCSelectedMassPtLocMax[mcIndex][indexMax]->Fill(mom.Pt(),mass);
+      fhMCSelectedMassPtLocMax[mcIndex][indexMax]->Fill(fMomentum.Pt(),mass);
 
       if(noverlaps==0)
       {
-        fhMCSelectedMassPtNoOverlap     [mcIndex]->Fill(mom.Pt(),mass);
+        fhMCSelectedMassPtNoOverlap     [mcIndex]->Fill(fMomentum.Pt(),mass);
         fhMCSelectedMassSplitPtNoOverlap[mcIndex]->Fill(ptSplit,mass);
       }
     }
     
+    // Remove clusters with NLM=x depeding on a minimim energy cut
+    if(nMaxima == 1 && fNLMECutMin[0] > fMomentum.E()) continue;
+    if(nMaxima == 2 && fNLMECutMin[1] > fMomentum.E()) continue;
+    if(nMaxima >  2 && fNLMECutMin[2] > fMomentum.E()) continue;
+
+    //Fill some histograms about shower shape
+    if(fFillSelectClHisto && GetReader()->GetDataType()!=AliCaloTrackReader::kMC)
+    {
+      FillSelectedClusterHistograms(calo, fMomentum.Pt(), nMaxima, tag, asy);
+    }
+    
+    // Fill histograms to undertand pile-up before other cuts applied
+    // Remember to relax time cuts in the reader
+    Double_t tofcluster   = calo->GetTOF()*1e9;
+    
+    FillPileUpHistograms(fMomentum.Pt(),tofcluster,calo);
+    
+    if(fFillEMCALBCHistograms && GetCalorimeter()==kEMCAL)
+      FillEMCALBCHistograms(fMomentum.E(), fMomentum.Eta(), fMomentum.Phi(), tofcluster);
+    
     //-----------------------
     //Create AOD for analysis
     
-    if(nMaxima == 1 && fNLMECutMin[0] > mom.E()) continue;
-    if(nMaxima == 2 && fNLMECutMin[1] > mom.E()) continue;
-    if(nMaxima >  2 && fNLMECutMin[2] > mom.E()) continue;
-    
-    AliAODPWG4Particle aodpi0 = AliAODPWG4Particle(mom);
+    AliAODPWG4Particle aodpi0 = AliAODPWG4Particle(fMomentum);
     aodpi0.SetLabel(calo->GetLabel());
     
     //Set the indeces of the original caloclusters
     aodpi0.SetCaloLabel(calo->GetID(),-1);
-    aodpi0.SetDetector(fCalorimeter);
+    aodpi0.SetDetectorTag(GetCalorimeter());
     
     if     (distBad > fMinDist3) aodpi0.SetDistToBad(2) ;
     else if(distBad > fMinDist2) aodpi0.SetDistToBad(1) ;
@@ -3380,69 +3646,20 @@ void  AliAnaPi0EbE::MakeShowerShapeIdentification()
     // Check if cluster is pi0 via cluster splitting
     aodpi0.SetIdentifiedParticleType(idPartType);
     
-    // Add number of local maxima to AOD, method name in AOD to be FIXED
-    aodpi0.SetFiducialArea(nMaxima);
-    
+    aodpi0.SetM02(l0);
+    aodpi0.SetNLM(nMaxima);
+    aodpi0.SetTime(tofcluster);
+    aodpi0.SetNCells(calo->GetNCells());
+    aodpi0.SetSModNumber(nSM);
+
     aodpi0.SetTag(tag);
-    
-    //Fill some histograms about shower shape
-    if(fFillSelectClHisto && GetReader()->GetDataType()!=AliCaloTrackReader::kMC)
-    {
-      FillSelectedClusterHistograms(calo, aodpi0.Pt(), nMaxima, tag, asy);
-    }
-    
-    // Fill histograms to undertand pile-up before other cuts applied
-    // Remember to relax time cuts in the reader
-    Double_t tofcluster   = calo->GetTOF()*1e9;
-    Double_t tofclusterUS = TMath::Abs(tofcluster);
-    
-    FillPileUpHistograms(aodpi0.Pt(),tofcluster,calo);
-    
-    Int_t id = GetReader()->GetTriggerClusterId();
-    if(fFillEMCALBCHistograms && fCalorimeter=="EMCAL" && id >=0 )
-    {
-      Float_t phicluster = aodpi0.Phi();
-      if(phicluster < 0) phicluster+=TMath::TwoPi();
-      
-      if(calo->E() > 2)
-      {
-        if      (tofclusterUS < 25) fhEtaPhiEMCALBC0->Fill(aodpi0.Eta(), phicluster);
-        else if (tofclusterUS < 75) fhEtaPhiEMCALBC1->Fill(aodpi0.Eta(), phicluster);
-        else                        fhEtaPhiEMCALBCN->Fill(aodpi0.Eta(), phicluster);
-      }
-      
-      Int_t bc = GetReader()->GetTriggerClusterBC();
-      if(TMath::Abs(bc) < 6  && !GetReader()->IsBadCellTriggerEvent() && !GetReader()->IsExoticEvent() )
-      {
-        if(GetReader()->IsTriggerMatched())
-        {
-          if(calo->E() > 2) fhEtaPhiTriggerEMCALBC[bc+5]->Fill(aodpi0.Eta(), phicluster);
-          fhTimeTriggerEMCALBC[bc+5]->Fill(calo->E(), tofcluster);
-          if(GetReader()->IsPileUpFromSPD()) fhTimeTriggerEMCALBCPileUpSPD[bc+5]->Fill(calo->E(), tofcluster);
-        }
-        else
-        {
-          if(calo->E() > 2) fhEtaPhiTriggerEMCALBCUM[bc+5]->Fill(aodpi0.Eta(), phicluster);
-          fhTimeTriggerEMCALBCUM[bc+5]->Fill(calo->E(), tofcluster);
-          
-          if(bc==0)
-          {
-            if(GetReader()->IsTriggerMatchedOpenCuts(0)) fhTimeTriggerEMCALBC0UMReMatchOpenTime   ->Fill(calo->E(), tofcluster);
-            if(GetReader()->IsTriggerMatchedOpenCuts(1)) fhTimeTriggerEMCALBC0UMReMatchCheckNeigh ->Fill(calo->E(), tofcluster);
-            if(GetReader()->IsTriggerMatchedOpenCuts(2)) fhTimeTriggerEMCALBC0UMReMatchBoth       ->Fill(calo->E(), tofcluster);
-          }
-         }
-      }
-      else if(TMath::Abs(bc) >= 6)
-        Info("MakeShowerShapeIdentification","Trigger BC not expected = %d\n",bc);
-    }
-    
+
     //Add AOD with pi0 object to aod branch
     AddAODParticle(aodpi0);
-    
+        
   }//loop
   
-  if(GetDebug() > 1) Info("MakeShowerShapeIdentification","End fill AODs \n");
+  AliDebug(1,"End fill AODs");
   
 }
 
@@ -3453,12 +3670,14 @@ void  AliAnaPi0EbE::MakeAnalysisFillHistograms()
   
   if(!GetOutputAODBranch())
   {
-    AliFatal(Form("No output pi0 in AOD branch with name < %s >,STOP \n",GetOutputAODName().Data()));
+    AliFatal(Form("No output pi0 in AOD branch with name < %s >,STOP",GetOutputAODName().Data()));
+    return;
   }
   
   //Loop on stored AOD pi0
   Int_t naod = GetOutputAODBranch()->GetEntriesFast();
-  if(GetDebug() > 0) Info("MakeAnalysisFillHistograms","aod branch entries %d\n", naod);
+  
+  AliDebug(1,Form("AOD branch entries %d", naod));
   
   Float_t cen = GetEventCentrality();
   Float_t ep  = GetEventPlaneAngle();
@@ -3484,66 +3703,73 @@ void  AliAnaPi0EbE::MakeAnalysisFillHistograms()
     fhPtPhi  ->Fill(pt  ,phi);
     fhEtaPhi ->Fill(eta ,phi);
     
-    fhPtCentrality ->Fill(pt,cen) ;
-    fhPtEventPlane ->Fill(pt,ep ) ;
+    if(IsHighMultiplicityAnalysisOn())
+    {
+      fhPtCentrality ->Fill(pt,cen) ;
+      fhPtEventPlane ->Fill(pt,ep ) ;
+    }
     
     if(IsDataMC())
     {
       Int_t tag     = pi0->GetTag();
       Int_t label   = pi0->GetLabel();
       Int_t mcIndex = GetMCIndex(tag);
+
+      if(fAnaType!=kSSCalo && mcIndex > 1) continue;
       
       fhMCE    [mcIndex] ->Fill(ener);
       fhMCPt   [mcIndex] ->Fill(pt);
       fhMCPtPhi[mcIndex] ->Fill(pt,phi);
       fhMCPtEta[mcIndex] ->Fill(pt,eta);
       
-      fhMCPtCentrality[mcIndex]->Fill(pt,cen);
+      if(IsHighMultiplicityAnalysisOn()) fhMCPtCentrality[mcIndex]->Fill(pt,cen);
       
-      if((mcIndex==kmcPhoton || mcIndex==kmcPi0 || mcIndex==kmcEta) && fAnaType==kSSCalo)
+      if((mcIndex==kmcPi0Decay || mcIndex==kmcEtaDecay ||
+          mcIndex==kmcPi0      || mcIndex==kmcEta         ) &&
+         fAnaType==kSSCalo)
       {
         Float_t efracMC   = 0;
         Int_t   momlabel  = -1;
         Bool_t  ok        = kFALSE;
         
-        TLorentzVector mom   = GetMCAnalysisUtils()->GetMother(label,GetReader(),ok);
+        fPrimaryMom = GetMCAnalysisUtils()->GetMother(label,GetReader(),ok);
         if(!ok) continue;
         
         if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPi0))
         {
-          TLorentzVector grandmom = GetMCAnalysisUtils()->GetMotherWithPDG(label,111,GetReader(),ok,momlabel);
-          if(grandmom.E() > 0 && ok)
+          fGrandMotherMom = GetMCAnalysisUtils()->GetMotherWithPDG(label,111,GetReader(),ok,momlabel);
+          if(fGrandMotherMom.E() > 0 && ok)
           {
-            efracMC =  grandmom.E()/ener;
+            efracMC =  fGrandMotherMom.E()/ener;
             fhMCPi0PtGenRecoFraction ->Fill(pt,efracMC);
           }
         }
         else if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCPi0Decay))
         {
           fhMCPi0DecayPt->Fill(pt);
-          TLorentzVector grandmom = GetMCAnalysisUtils()->GetMotherWithPDG(label,111,GetReader(),ok,momlabel);
-          if(grandmom.E() > 0 && ok)
+          fGrandMotherMom = GetMCAnalysisUtils()->GetMotherWithPDG(label,111,GetReader(),ok,momlabel);
+          if(fGrandMotherMom.E() > 0 && ok)
           {
-            efracMC =  mom.E()/grandmom.E();
+            efracMC =  fPrimaryMom.E()/fGrandMotherMom.E();
             fhMCPi0DecayPtFraction ->Fill(pt,efracMC);
           }
         }
         else if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCEta))
         {
-          TLorentzVector grandmom = GetMCAnalysisUtils()->GetMotherWithPDG(label,221,GetReader(),ok,momlabel);
-          if(grandmom.E() > 0 && ok)
+          fGrandMotherMom = GetMCAnalysisUtils()->GetMotherWithPDG(label,221,GetReader(),ok,momlabel);
+          if(fGrandMotherMom.E() > 0 && ok)
           {
-            efracMC =  grandmom.E()/ener;
+            efracMC =  fGrandMotherMom.E()/ener;
             fhMCEtaPtGenRecoFraction ->Fill(pt,efracMC);
           }
         }
         else if(GetMCAnalysisUtils()->CheckTagBit(tag,AliMCAnalysisUtils::kMCEtaDecay))
         {
           fhMCEtaDecayPt->Fill(pt);
-          TLorentzVector grandmom = GetMCAnalysisUtils()->GetMotherWithPDG(label,221,GetReader(),ok,momlabel);
-          if(grandmom.E() > 0 && ok)
+          fGrandMotherMom = GetMCAnalysisUtils()->GetMotherWithPDG(label,221,GetReader(),ok,momlabel);
+          if(fGrandMotherMom.E() > 0 && ok)
           {
-            efracMC =  mom.E()/grandmom.E();
+            efracMC =  fPrimaryMom.E()/fGrandMotherMom.E();
             fhMCEtaDecayPtFraction ->Fill(pt,efracMC);
           }
         }
@@ -3621,6 +3847,8 @@ void  AliAnaPi0EbE::MakeAnalysisFillHistograms()
     
   }// aod loop
   
+  AliDebug(1,"End");
+
 }
 
 //__________________________________________________________________
@@ -3635,7 +3863,7 @@ void AliAnaPi0EbE::Print(const Option_t * opt) const
   printf("Analysis Type = %d \n",  fAnaType) ;
   if(fAnaType == kSSCalo)
   {
-    printf("Calorimeter            =     %s\n", fCalorimeter.Data()) ;
+    printf("Calorimeter            =     %s\n", GetCalorimeterString().Data()) ;
     printf("Min Distance to Bad Channel   = %2.1f\n",fMinDist);
     printf("Min Distance to Bad Channel 2 = %2.1f\n",fMinDist2);
     printf("Min Distance to Bad Channel 3 = %2.1f\n",fMinDist3);