]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG4/PartCorrDep/AliAnaCalorimeterQA.cxx
Calculate the fraction of maximum cell energy using method in AliCalorimeterUtils...
[u/mrichter/AliRoot.git] / PWG4 / PartCorrDep / AliAnaCalorimeterQA.cxx
index f8b1f43a1a627ff15360f95ee0fd2ae77803f5aa..838e3ea7dc2a7bbea481a137181dd452bba7dce5 100755 (executable)
@@ -56,69 +56,89 @@ ClassImp(AliAnaCalorimeterQA)
 
 //____________________________________________________________________________
 AliAnaCalorimeterQA::AliAnaCalorimeterQA() : 
-AliAnaPartCorrBaseClass(), fCalorimeter(""), fStyleMacro(""), 
-fFillAllPosHisto(kFALSE), fFillAllTH12(kFALSE),
-fCorrelate(kTRUE), fNModules(12), fNRCU(2),
-fTimeCutMin(-1), fTimeCutMax(9999999),
-fEMCALCellAmpMin(0),fPHOSCellAmpMin(0), 
-fHistoFinePtBins(1000),    fHistoFinePtMax(5.),        fHistoFinePtMin(0.),
-fHistoPOverEBins(100),     fHistoPOverEMax(100.),      fHistoPOverEMin(0.),
-fHistodEdxBins(100),       fHistodEdxMax(100.),        fHistodEdxMin(0.),
-fHistodRBins(100),         fHistodRMax(100.),          fHistodRMin(0.),
-fHistoTimeBins(100),       fHistoTimeMax(100.),        fHistoTimeMin(0.),
-fHistoNBins(100),          fHistoNMax(100),            fHistoNMin(0),
-fHistoRatioBins(100),      fHistoRatioMax(100.),       fHistoRatioMin(0.),
-fHistoVertexDistBins(100), fHistoVertexDistMax(100.),  fHistoVertexDistMin(0.),
-fHistoRBins(100),          fHistoRMax(1000),           fHistoRMin(-1000),
-fHistoXBins(100),          fHistoXMax(1000),           fHistoXMin(-1000),
-fHistoYBins(100),          fHistoYMax(1000),           fHistoYMin(-1000),
-fHistoZBins(100),          fHistoZMax(1000),           fHistoZMin(-1000),
-fHistoSSBins(25),          fHistoSSMax(5),             fHistoSSMin(0),
-fhE(0),fhPt(0),fhPhi(0),fhEta(0),   fhEtaPhiE(0),
-fhECharged(0),fhPtCharged(0),fhPhiCharged(0),fhEtaCharged(0), fhEtaPhiECharged(0), 
-fhDeltaE(0), fhDeltaPt(0),fhDeltaPhi(0),fhDeltaEta(0), fhRatioE(0), fhRatioPt(0),fhRatioPhi(0),fhRatioEta(0),
-fh2E(0),fh2Pt(0),fh2Phi(0),fh2Eta(0),
-fhLambda(0), fhDispersion(0), 
-fhIM(0), fhIMCellCut(0),fhAsym(0), 
-fhNCellsPerCluster(0),fhNCellsPerClusterMIP(0), fhNCellsPerClusterMIPCharged(0), fhNClusters(0), 
-fhClusterTimeEnergy(0),fhCellTimeSpreadRespectToCellMax(0),fhCellIdCellLargeTimeSpread(0), 
-fhBadClusterMaxCellTimeEnergy(0), fhBadClusterMaxCellCloseCellRatio(0),fhClusterMaxCellTimeEnergy(0), fhClusterMaxCellCloseCellRatio(0), 
-fhRNCells(0),fhXNCells(0),fhYNCells(0),fhZNCells(0),
-fhRE(0),     fhXE(0),     fhYE(0),     fhZE(0),    fhXYZ(0),
-fhRCellE(0), fhXCellE(0), fhYCellE(0), fhZCellE(0),fhXYZCell(0),
+AliAnaPartCorrBaseClass(), fCalorimeter(""),           fStyleMacro(""), 
+fFillAllPosHisto(kFALSE),  fFillAllPosHisto2(kTRUE), 
+fFillAllTH12(kFALSE),      fFillAllTH3(kTRUE), 
+fFillAllTMHisto(kTRUE),    fFillAllPi0Histo(kTRUE),
+fCorrelate(kTRUE),         fNModules(12),              fNRCU(2),
+fTimeCutMin(-1),           fTimeCutMax(9999999),
+fEMCALCellAmpMin(0),       fPHOSCellAmpMin(0), 
+fhE(0),                    fhPt(0),                    fhPhi(0),                fhEta(0),        fhEtaPhiE(0),
+fhECharged(0),             fhPtCharged(0),             fhPhiCharged(0),         fhEtaCharged(0), fhEtaPhiECharged(0), 
+
+//Invariant mass
+fhIM(0 ),                  fhIMCellCut(0),             fhAsym(0), 
+fhNCellsPerCluster(0),     fhNCellsPerClusterNoCut(0), fhNCellsPerClusterMIP(0),   fhNCellsPerClusterMIPCharged(0), 
+fhNCellsvsClusterMaxCellDiffE0(0),    fhNCellsvsClusterMaxCellDiffE2(0),        fhNCellsvsClusterMaxCellDiffE6(0),
+fhNClusters(0),    
+
+//Timing
+fhClusterTimeEnergy(0),               fhCellTimeSpreadRespectToCellMax(0),  
+fhCellIdCellLargeTimeSpread(0),       fhClusterPairDiffTimeE(0),
+
+fhClusterMaxCellCloseCellRatio(0),    fhClusterMaxCellDiff(0),                  fhClusterMaxCellDiffNoCut(0), 
+//fhClusterMaxCellDiffDivLambda0(0),
+fhLambda0vsClusterMaxCellDiffE0(0),   fhLambda0vsClusterMaxCellDiffE2(0),       fhLambda0vsClusterMaxCellDiffE6(0),
+
+//
+//bad cells
+fhBadClusterEnergy(0),                fhBadClusterTimeEnergy(0),            fhBadClusterPairDiffTimeE(0),
+fhBadClusterMaxCellCloseCellRatio(0), fhBadClusterMaxCellDiff(0),
+
+//Position
+fhRNCells(0),              fhXNCells(0),               fhYNCells(0),            fhZNCells(0),
+fhRE(0),                   fhXE(0),                    fhYE(0),                 fhZE(0),    
+fhXYZ(0),
+fhRCellE(0),               fhXCellE(0),                fhYCellE(0),             fhZCellE(0),
+fhXYZCell(0),
 fhDeltaCellClusterRNCells(0),fhDeltaCellClusterXNCells(0),fhDeltaCellClusterYNCells(0),fhDeltaCellClusterZNCells(0),
 fhDeltaCellClusterRE(0),     fhDeltaCellClusterXE(0),     fhDeltaCellClusterYE(0),     fhDeltaCellClusterZE(0),
-fhNCells(0), fhAmplitude(0), fhAmpId(0), fhEtaPhiAmp(0), 
-fhTime(0), fhTimeId(0), fhTimeAmp(0), //fhT0Time(0), fhT0TimeId(0), fhT0TimeAmp(0), 
-fhCaloCorrNClusters(0), fhCaloCorrEClusters(0), fhCaloCorrNCells(0), fhCaloCorrECells(0),
-fhCaloV0SCorrNClusters(0), fhCaloV0SCorrEClusters(0), fhCaloV0SCorrNCells(0), fhCaloV0SCorrECells(0),
-fhCaloV0MCorrNClusters(0), fhCaloV0MCorrEClusters(0), fhCaloV0MCorrNCells(0), fhCaloV0MCorrECells(0),
+// Cells
+fhNCells(0),               fhAmplitude(0),             fhAmpId(0),              fhEtaPhiAmp(0), 
+fhTime(0),                 fhTimeId(0),                fhTimeAmp(0), 
+//fhT0Time(0),               fhT0TimeId(0),              fhT0TimeAmp(0), 
+fhCaloCorrNClusters(0),    fhCaloCorrEClusters(0),     fhCaloCorrNCells(0),     fhCaloCorrECells(0),
+fhCaloV0SCorrNClusters(0), fhCaloV0SCorrEClusters(0),  fhCaloV0SCorrNCells(0),  fhCaloV0SCorrECells(0),
+fhCaloV0MCorrNClusters(0), fhCaloV0MCorrEClusters(0),  fhCaloV0MCorrNCells(0),  fhCaloV0MCorrECells(0),
 fhCaloTrackMCorrNClusters(0), fhCaloTrackMCorrEClusters(0), fhCaloTrackMCorrNCells(0), fhCaloTrackMCorrECells(0),
-fhEMod(0), fhNClustersMod(0), fhNCellsPerClusterMod(0), fhNCellsMod(0),  
-fhGridCellsMod(0), fhGridCellsEMod(0), fhGridCellsTimeMod(0), 
-fhAmplitudeMod(0), fhAmplitudeModFraction(0),fhTimeAmpPerRCU(0), //fhT0TimeAmpPerRCU(0), fhTimeCorrRCU(0),
-fhIMMod(0),  fhIMCellCutMod(0),
-fhGenGamPt(0),fhGenGamEta(0),fhGenGamPhi(0),fhGenPi0Pt(0),fhGenPi0Eta(0),fhGenPi0Phi(0),
-fhGenEtaPt(0),fhGenEtaEta(0),fhGenEtaPhi(0),fhGenOmegaPt(0),fhGenOmegaEta(0),fhGenOmegaPhi(0),
-fhGenElePt(0),fhGenEleEta(0),fhGenElePhi(0), fhEMVxyz(0),  fhEMR(0), fhHaVxyz(0),  fhHaR(0),
-fhGamE(0),fhGamPt(0),fhGamPhi(0),fhGamEta(0), 
-fhGamDeltaE(0), fhGamDeltaPt(0),fhGamDeltaPhi(0),fhGamDeltaEta(0), 
-fhGamRatioE(0), fhGamRatioPt(0),fhGamRatioPhi(0),fhGamRatioEta(0),
-fhEleE(0),fhElePt(0),fhElePhi(0),fhEleEta(0),
-fhPi0E(0),fhPi0Pt(0),fhPi0Phi(0),fhPi0Eta(0), 
-fhNeHadE(0),fhNeHadPt(0),fhNeHadPhi(0),fhNeHadEta(0), 
-fhChHadE(0),fhChHadPt(0),fhChHadPhi(0),fhChHadEta(0),
-fhGamECharged(0),fhGamPtCharged(0),fhGamPhiCharged(0),fhGamEtaCharged(0), 
-fhEleECharged(0),fhElePtCharged(0),fhElePhiCharged(0),fhEleEtaCharged(0),
-fhPi0ECharged(0),fhPi0PtCharged(0),fhPi0PhiCharged(0),fhPi0EtaCharged(0), 
-fhNeHadECharged(0),fhNeHadPtCharged(0),fhNeHadPhiCharged(0),fhNeHadEtaCharged(0), 
-fhChHadECharged(0),fhChHadPtCharged(0),fhChHadPhiCharged(0),fhChHadEtaCharged(0),
-fhGenGamAccE(0),fhGenGamAccPt(0),fhGenGamAccEta(0),fhGenGamAccPhi(0),
-fhGenPi0AccE(0),fhGenPi0AccPt(0),fhGenPi0AccEta(0),fhGenPi0AccPhi(0),
-fh1pOverE(0),fh1dR(0),fh2EledEdx(0), fh2MatchdEdx(0),fhMCEle1pOverE(0),fhMCEle1dR(0),fhMCEle2MatchdEdx(0),
-fhMCChHad1pOverE(0),  fhMCChHad1dR(0),  fhMCChHad2MatchdEdx(0),
-fhMCNeutral1pOverE(0),fhMCNeutral1dR(0),fhMCNeutral2MatchdEdx(0),
-fh1pOverER02(0), fhMCEle1pOverER02(0), fhMCChHad1pOverER02(0), fhMCNeutral1pOverER02(0)
+//Super-Module dependent histgrams
+fhEMod(0),                 fhNClustersMod(0),          fhNCellsPerClusterMod(0),  fhNCellsPerClusterModNoCut(0), fhNCellsMod(0),  
+fhGridCellsMod(0),         fhGridCellsEMod(0),         fhGridCellsTimeMod(0), 
+fhAmplitudeMod(0),         fhAmplitudeModFraction(0),  fhTimeAmpPerRCU(0), 
+//fhT0TimeAmpPerRCU(0),      fhTimeCorrRCU(0),
+fhIMMod(0),                fhIMCellCutMod(0),
+
+// MC and reco
+fhDeltaE(0),               fhDeltaPt(0),               fhDeltaPhi(0),           fhDeltaEta(0),   
+fhRatioE(0),               fhRatioPt(0),               fhRatioPhi(0),           fhRatioEta(0),
+fh2E(0),                   fh2Pt(0),                   fh2Phi(0),               fh2Eta(0),
+
+// MC only
+fhGenGamPt(0),             fhGenGamEta(0),             fhGenGamPhi(0),
+fhGenPi0Pt(0),             fhGenPi0Eta(0),             fhGenPi0Phi(0),
+fhGenEtaPt(0),             fhGenEtaEta(0),             fhGenEtaPhi(0),
+fhGenOmegaPt(0),           fhGenOmegaEta(0),           fhGenOmegaPhi(0),
+fhGenElePt(0),             fhGenEleEta(0),             fhGenElePhi(0), 
+fhEMVxyz(0),               fhEMR(0),                   fhHaVxyz(0),             fhHaR(0),
+fhGamE(0),                 fhGamPt(0),                 fhGamPhi(0),             fhGamEta(0), 
+fhGamDeltaE(0),            fhGamDeltaPt(0),            fhGamDeltaPhi(0),        fhGamDeltaEta(0), 
+fhGamRatioE(0),            fhGamRatioPt(0),            fhGamRatioPhi(0),        fhGamRatioEta(0),
+fhEleE(0),                 fhElePt(0),                 fhElePhi(0),             fhEleEta(0),
+fhPi0E(0),                 fhPi0Pt(0),                 fhPi0Phi(0),             fhPi0Eta(0), 
+fhNeHadE(0),               fhNeHadPt(0),               fhNeHadPhi(0),           fhNeHadEta(0), 
+fhChHadE(0),               fhChHadPt(0),               fhChHadPhi(0),           fhChHadEta(0),
+fhGamECharged(0),          fhGamPtCharged(0),          fhGamPhiCharged(0),      fhGamEtaCharged(0), 
+fhEleECharged(0),          fhElePtCharged(0),          fhElePhiCharged(0),      fhEleEtaCharged(0),
+fhPi0ECharged(0),          fhPi0PtCharged(0),          fhPi0PhiCharged(0),      fhPi0EtaCharged(0), 
+fhNeHadECharged(0),        fhNeHadPtCharged(0),        fhNeHadPhiCharged(0),    fhNeHadEtaCharged(0), 
+fhChHadECharged(0),        fhChHadPtCharged(0),        fhChHadPhiCharged(0),    fhChHadEtaCharged(0),
+fhGenGamAccE(0),           fhGenGamAccPt(0),           fhGenGamAccEta(0),       fhGenGamAccPhi(0),
+fhGenPi0AccE(0),           fhGenPi0AccPt(0),           fhGenPi0AccEta(0),       fhGenPi0AccPhi(0),
+fh1pOverE(0),              fh1dR(0),                   fh2EledEdx(0),           fh2MatchdEdx(0),
+fhMCEle1pOverE(0),         fhMCEle1dR(0),              fhMCEle2MatchdEdx(0),
+fhMCChHad1pOverE(0),       fhMCChHad1dR(0),            fhMCChHad2MatchdEdx(0),
+fhMCNeutral1pOverE(0),     fhMCNeutral1dR(0),          fhMCNeutral2MatchdEdx(0),fh1pOverER02(0),           
+fhMCEle1pOverER02(0),      fhMCChHad1pOverER02(0),     fhMCNeutral1pOverER02(0)
 {
   //Default Ctor
   
@@ -172,7 +192,7 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
   Int_t ndedxbins   = GetHistodEdxBins();         Float_t dedxmax   = GetHistodEdxMax();         Float_t dedxmin   = GetHistodEdxMin();
   Int_t ndRbins     = GetHistodRBins();           Float_t dRmax     = GetHistodRMax();           Float_t dRmin     = GetHistodRMin();
   Int_t ntimebins   = GetHistoTimeBins();         Float_t timemax   = GetHistoTimeMax();         Float_t timemin   = GetHistoTimeMin();       
-  Int_t nbins       = GetHistoNClusterCellBins(); Int_t nmax        = GetHistoNClusterCellMax(); Int_t nmin        = GetHistoNClusterCellMin(); 
+  Int_t nbins       = GetHistoNClusterCellBins(); Int_t   nmax      = GetHistoNClusterCellMax(); Int_t   nmin      = GetHistoNClusterCellMin(); 
   Int_t nratiobins  = GetHistoRatioBins();        Float_t ratiomax  = GetHistoRatioMax();        Float_t ratiomin  = GetHistoRatioMin();
   Int_t nvdistbins  = GetHistoVertexDistBins();   Float_t vdistmax  = GetHistoVertexDistMax();   Float_t vdistmin  = GetHistoVertexDistMin();
   Int_t rbins       = GetHistoRBins();            Float_t rmax      = GetHistoRMax();            Float_t rmin      = GetHistoRMin(); 
@@ -180,10 +200,13 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
   Int_t ybins       = GetHistoYBins();            Float_t ymax      = GetHistoYMax();            Float_t ymin      = GetHistoYMin(); 
   Int_t zbins       = GetHistoZBins();            Float_t zmax      = GetHistoZMax();            Float_t zmin      = GetHistoZMin(); 
   Int_t ssbins      = GetHistoShowerShapeBins();  Float_t ssmax     = GetHistoShowerShapeMax();  Float_t ssmin     = GetHistoShowerShapeMin();
-  Int_t nv0sbins    = GetHistoV0SignalBins();     Int_t nv0smax     = GetHistoV0SignalMax();     Int_t nv0smin     = GetHistoV0SignalMin(); 
-  Int_t nv0mbins    = GetHistoV0MultiplicityBins();Int_t nv0mmax    = GetHistoV0MultiplicityMax();Int_t nv0mmin    = GetHistoV0MultiplicityMin(); 
-  Int_t ntrmbins    = GetHistoTrackMultiplicityBins();Int_t ntrmmax = GetHistoTrackMultiplicityMax();Int_t ntrmmin = GetHistoTrackMultiplicityMin(); 
+  Int_t tdbins      = GetHistoDiffTimeBins() ;    Float_t tdmax     = GetHistoDiffTimeMax();     Float_t tdmin     = GetHistoDiffTimeMin();
 
+  Int_t nv0sbins    = GetHistoV0SignalBins();          Int_t nv0smax = GetHistoV0SignalMax();          Int_t nv0smin = GetHistoV0SignalMin(); 
+  Int_t nv0mbins    = GetHistoV0MultiplicityBins();    Int_t nv0mmax = GetHistoV0MultiplicityMax();    Int_t nv0mmin = GetHistoV0MultiplicityMin(); 
+  Int_t ntrmbins    = GetHistoTrackMultiplicityBins(); Int_t ntrmmax = GetHistoTrackMultiplicityMax(); Int_t ntrmmin = GetHistoTrackMultiplicityMin(); 
+  
+  
   //EMCAL
   Int_t colmax = 48;
   Int_t rowmax = 24;
@@ -196,7 +219,7 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
   }
   
   
-  fhE  = new TH1F ("hE","E reconstructed clusters ", nptbins*5,ptmin,ptmax*5); 
+  fhE  = new TH1F ("hE","E reconstructed clusters ", nptbins*5,ptmin,ptmax*5);  
   fhE->SetXTitle("E (GeV)");
   outputContainer->Add(fhE);
   
@@ -227,190 +250,262 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
   fhClusterTimeEnergy->SetYTitle("TOF (ns)");
   outputContainer->Add(fhClusterTimeEnergy);
     
+  fhClusterPairDiffTimeE = new TH2F("hClusterPairDiffTimeE","cluster pair time difference vs E, only good clusters",
+                                    nptbins,ptmin,ptmax, tdbins,tdmin,tdmax);
+  fhClusterPairDiffTimeE->SetXTitle("E_{cluster} (GeV)");
+  fhClusterPairDiffTimeE->SetYTitle("#Delta t (ns)");
+  outputContainer->Add(fhClusterPairDiffTimeE);  
+  
+  
   fhClusterMaxCellCloseCellRatio  = new TH2F ("hClusterMaxCellCloseCell","energy vs ratio of max cell / neighbour cell, reconstructed clusters",
-                                          nptbins,ptmin,ptmax, 100,0,1.); 
+                                              nptbins,ptmin,ptmax, 100,0,1.); 
   fhClusterMaxCellCloseCellRatio->SetXTitle("E_{cluster} (GeV) ");
   fhClusterMaxCellCloseCellRatio->SetYTitle("ratio");
   outputContainer->Add(fhClusterMaxCellCloseCellRatio);
   
-  fhBadClusterMaxCellCloseCellRatio  = new TH2F ("hBadClusterMaxCellCloseCell","energy vs ratio of max cell / neighbour cell constributing cell, reconstructed bad clusters",
-                                             nptbins,ptmin,ptmax, 100,0,1.); 
-  fhBadClusterMaxCellCloseCellRatio->SetXTitle("E_{cluster} (GeV) ");
-  fhBadClusterMaxCellCloseCellRatio->SetYTitle("ratio");
-  outputContainer->Add(fhBadClusterMaxCellCloseCellRatio);
-  
-  fhClusterMaxCellTimeEnergy  = new TH2F ("hClusterMaxCellTimeEnergy","energy vs TOF of maximum constributing cell, reconstructed clusters",
-                                          nptbins,ptmin,ptmax, ntimebins,timemin,timemax); 
-  fhClusterMaxCellTimeEnergy->SetXTitle("E_{cluster} (GeV) ");
-  fhClusterMaxCellTimeEnergy->SetYTitle("TOF (ns)");
-  outputContainer->Add(fhClusterMaxCellTimeEnergy);
-  
-  fhBadClusterMaxCellTimeEnergy  = new TH2F ("hBadClusterMaxCellTimeEnergy","energy vs TOF of maximum constributing cell, reconstructed clusters",
-                                             nptbins,ptmin,ptmax, ntimebins,timemin,timemax); 
-  fhBadClusterMaxCellTimeEnergy->SetXTitle("E_{cluster} (GeV) ");
-  fhBadClusterMaxCellTimeEnergy->SetYTitle("TOF (ns)");
-  outputContainer->Add(fhBadClusterMaxCellTimeEnergy);    
-  
-  //Shower shape
-  fhLambda  = new TH3F ("hLambda","#lambda_{0}^{2} vs #lambda_{1}^{2} vs energy, reconstructed clusters",
-                        ssbins,ssmin,ssmax,ssbins,ssmin,ssmax,nptbins,ptmin,ptmax); 
-  fhLambda->SetXTitle("#lambda_{0}^{2}  ");
-  fhLambda->SetYTitle("#lambda_{1}^{2}  ");
-  fhLambda->SetZTitle("E (GeV) ");
-  outputContainer->Add(fhLambda);
-  
-  fhDispersion  = new TH2F ("hDispersion"," dispersion vs energy, reconstructed clusters",
-                            ssbins,ssmin,ssmax,nptbins,ptmin,ptmax); 
-  fhDispersion->SetXTitle("Dispersion  ");
-  fhDispersion->SetYTitle("E (GeV) ");
-  outputContainer->Add(fhDispersion);
+  fhClusterMaxCellDiff  = new TH2F ("hClusterMaxCellDiff","energy vs difference of cluster energy - max cell energy / cluster energy, good clusters",
+                                       nptbins,ptmin,ptmax, 500,0,1.); 
+  fhClusterMaxCellDiff->SetXTitle("E_{cluster} (GeV) ");
+  fhClusterMaxCellDiff->SetYTitle("(E_{cluster} - E_{cell max})/ E_{cluster}");
+  outputContainer->Add(fhClusterMaxCellDiff);  
+
+  fhClusterMaxCellDiffNoCut  = new TH2F ("hClusterMaxCellDiffNoCut","energy vs difference of cluster energy - max cell energy / cluster energy",
+                                    nptbins,ptmin,ptmax, 500,0,1.); 
+  fhClusterMaxCellDiffNoCut->SetXTitle("E_{cluster} (GeV) ");
+  fhClusterMaxCellDiffNoCut->SetYTitle("(E_{cluster} - E_{cell max})/ E_{cluster}");
+  outputContainer->Add(fhClusterMaxCellDiffNoCut);  
+  
+//  fhClusterMaxCellDiffDivLambda0  = new TH2F ("hClusterMaxCellDiffDivLambda0;","",
+//                                         nptbins,ptmin,ptmax, 500,0,5.); 
+//  fhClusterMaxCellDiffDivLambda0->SetXTitle("E_{cluster} (GeV) ");
+//  fhClusterMaxCellDiffDivLambda0->SetYTitle("(E_{cluster} - E_{cell max})/ E_{cluster} / #lambda_{0}");
+//  outputContainer->Add(fhClusterMaxCellDiffDivLambda0);    
+  
+  fhLambda0vsClusterMaxCellDiffE0  = new TH2F ("hLambda0vsClusterMaxCellDiffE0","shower shape, #lambda^{2}_{0} vs fraction of energy carried by max cell, E < 2 GeV ",
+                                               ssbins,ssmin,ssmax,500,0,1.); 
+  fhLambda0vsClusterMaxCellDiffE0->SetYTitle("(E_{cluster} - E_{cell max})/ E_{cluster}");
+  fhLambda0vsClusterMaxCellDiffE0->SetXTitle("#lambda^{2}_{0}");
+  outputContainer->Add(fhLambda0vsClusterMaxCellDiffE0); 
+  
+  fhLambda0vsClusterMaxCellDiffE2  = new TH2F ("hLambda0vsClusterMaxCellDiffE2","shower shape, #lambda^{2}_{0} vs fraction of energy carried by max cell, 2 < E < 6 GeV ",
+                                               ssbins,ssmin,ssmax,500,0,1.); 
+  fhLambda0vsClusterMaxCellDiffE2->SetYTitle("(E_{cluster} - E_{cell max})/ E_{cluster}");
+  fhLambda0vsClusterMaxCellDiffE2->SetXTitle("#lambda^{2}_{0}");
+  outputContainer->Add(fhLambda0vsClusterMaxCellDiffE2); 
+  
+  fhLambda0vsClusterMaxCellDiffE6  = new TH2F ("hLambda0vsClusterMaxCellDiffE6","shower shape, #lambda^{2}_{0} vs fraction of energy carried by max cell, E > 6 ",
+                                               ssbins,ssmin,ssmax,500,0,1.); 
+  fhLambda0vsClusterMaxCellDiffE6->SetYTitle("(E_{cluster} - E_{cell max})/ E_{cluster}");
+  fhLambda0vsClusterMaxCellDiffE6->SetXTitle("#lambda^{2}_{0}");
+  outputContainer->Add(fhLambda0vsClusterMaxCellDiffE6); 
+
+  fhNCellsvsClusterMaxCellDiffE0  = new TH2F ("hNCellsvsClusterMaxCellDiffE0","N cells per cluster vs fraction of energy carried by max cell, E < 2 GeV ",
+                                               nbins/5,nmin,nmax/5,500,0,1.); 
+  fhNCellsvsClusterMaxCellDiffE0->SetYTitle("(E_{cluster} - E_{cell max})/ E_{cluster}");
+  fhNCellsvsClusterMaxCellDiffE0->SetXTitle("N cells per cluster");
+  outputContainer->Add(fhNCellsvsClusterMaxCellDiffE0); 
+  
+  fhNCellsvsClusterMaxCellDiffE2  = new TH2F ("hNCellsvsClusterMaxCellDiffE2","N cells per cluster vs fraction of energy carried by max cell, 2 < E < 6 GeV ",
+                                               nbins/5,nmin,nmax/5,500,0,1.); 
+  fhNCellsvsClusterMaxCellDiffE2->SetYTitle("(E_{cluster} - E_{cell max})/ E_{cluster}");
+  fhNCellsvsClusterMaxCellDiffE2->SetXTitle("N cells per cluster");
+  outputContainer->Add(fhNCellsvsClusterMaxCellDiffE2); 
+  
+  fhNCellsvsClusterMaxCellDiffE6  = new TH2F ("hNCellsvsClusterMaxCellDiffE6","N cells per cluster vs fraction of energy carried by max cell, E > 6 ",
+                                               nbins/5,nmin,nmax/5,500,0,1.); 
+  fhNCellsvsClusterMaxCellDiffE6->SetYTitle("(E_{cluster} - E_{cell max})/ E_{cluster}");
+  fhNCellsvsClusterMaxCellDiffE6->SetXTitle("N cells per cluster");
+  outputContainer->Add(fhNCellsvsClusterMaxCellDiffE6); 
+  
+  
+  if(fCalorimeter=="EMCAL" && !GetCaloUtils()->GetEMCALRecoUtils()->IsRejectExoticCluster()){
+    
+    fhBadClusterEnergy  = new TH1F ("hBadClusterEnergy","Bad cluster energy", nptbins,ptmin,ptmax); 
+    fhBadClusterEnergy->SetXTitle("E_{cluster} (GeV) ");
+    outputContainer->Add(fhBadClusterEnergy);
+    
+    fhBadClusterMaxCellCloseCellRatio  = new TH2F ("hBadClusterMaxCellCloseCell","energy vs ratio of max cell / neighbour cell constributing cell, reconstructed bad clusters",
+                                                   nptbins,ptmin,ptmax, 100,0,1.); 
+    fhBadClusterMaxCellCloseCellRatio->SetXTitle("E_{cluster} (GeV) ");
+    fhBadClusterMaxCellCloseCellRatio->SetYTitle("ratio");
+    outputContainer->Add(fhBadClusterMaxCellCloseCellRatio);
+        
+    fhBadClusterMaxCellDiff  = new TH2F ("hBadClusterMaxCellDiff","energy vs difference of cluster energy - max cell energy / cluster energy for bad clusters",
+                                                   nptbins,ptmin,ptmax, 500,0,1.); 
+    fhBadClusterMaxCellDiff->SetXTitle("E_{cluster} (GeV) ");
+    fhBadClusterMaxCellDiff->SetYTitle("(E_{cluster} - E_{cell max}) / E_{cluster}");
+    outputContainer->Add(fhBadClusterMaxCellDiff);
+    
+    fhBadClusterTimeEnergy  = new TH2F ("hBadClusterTimeEnergy","energy vs TOF of reconstructed bad clusters",
+                                               nptbins,ptmin,ptmax, ntimebins,timemin,timemax); 
+    fhBadClusterTimeEnergy->SetXTitle("E_{cluster} (GeV) ");
+    fhBadClusterTimeEnergy->SetYTitle("TOF (ns)");
+    outputContainer->Add(fhBadClusterTimeEnergy);    
+
+    fhBadClusterPairDiffTimeE = new TH2F("hBadClusterPairDiffTimeE","cluster pair time difference (bad - good) vs E from bad cluster",nptbins,ptmin,ptmax, tdbins,tdmin,tdmax);
+    fhBadClusterPairDiffTimeE->SetXTitle("E_{bad cluster} (GeV)");
+    fhBadClusterPairDiffTimeE->SetYTitle("#Delta t (ns)");
+    outputContainer->Add(fhBadClusterPairDiffTimeE);    
+      
+  }
   
   //Track Matching
-  if(fFillAllTH12){
-    fhECharged  = new TH1F ("hECharged","E reconstructed clusters, matched with track", nptbins,ptmin,ptmax); 
-    fhECharged->SetXTitle("E (GeV)");
-    outputContainer->Add(fhECharged);
+  if(fFillAllTMHisto){
+    if(fFillAllTH12){
+      fhECharged  = new TH1F ("hECharged","E reconstructed clusters, matched with track", nptbins,ptmin,ptmax); 
+      fhECharged->SetXTitle("E (GeV)");
+      outputContainer->Add(fhECharged);
+      
+      fhPtCharged  = new TH1F ("hPtCharged","p_{T} reconstructed clusters, matched with track", nptbins,ptmin,ptmax); 
+      fhPtCharged->SetXTitle("p_{T} (GeV/c)");
+      outputContainer->Add(fhPtCharged);
+      
+      fhPhiCharged  = new TH1F ("hPhiCharged","#phi reconstructed clusters, matched with track",nphibins,phimin,phimax); 
+      fhPhiCharged->SetXTitle("#phi (rad)");
+      outputContainer->Add(fhPhiCharged);
+      
+      fhEtaCharged  = new TH1F ("hEtaCharged","#eta reconstructed clusters, matched with track",netabins,etamin,etamax); 
+      fhEtaCharged->SetXTitle("#eta ");
+      outputContainer->Add(fhEtaCharged);
+    }
+    if(fFillAllTH3){
+      fhEtaPhiECharged  = new TH3F ("hEtaPhiECharged","#eta vs #phi, reconstructed clusters, matched with track",
+                                    netabins,etamin,etamax,nphibins,phimin,phimax,nptbins,ptmin,ptmax); 
+      fhEtaPhiECharged->SetXTitle("#eta ");
+      fhEtaPhiECharged->SetYTitle("#phi ");
+      fhEtaPhiECharged->SetZTitle("E (GeV) ");
+      outputContainer->Add(fhEtaPhiECharged);  
+    }
+    
+    fh1pOverE = new TH2F("h1pOverE","TRACK matches p/E",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
+    fh1pOverE->SetYTitle("p/E");
+    fh1pOverE->SetXTitle("p_{T} (GeV/c)");
+    outputContainer->Add(fh1pOverE);
+    
+    fh1dR = new TH1F("h1dR","TRACK matches dR",ndRbins,dRmin,dRmax);
+    fh1dR->SetXTitle("#Delta R (rad)");
+    outputContainer->Add(fh1dR) ;
+    
+    fh2MatchdEdx = new TH2F("h2MatchdEdx","dE/dx vs. p for all matches",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
+    fh2MatchdEdx->SetXTitle("p (GeV/c)");
+    fh2MatchdEdx->SetYTitle("<dE/dx>");
+    outputContainer->Add(fh2MatchdEdx);
+    
+    fh2EledEdx = new TH2F("h2EledEdx","dE/dx vs. p for electrons",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
+    fh2EledEdx->SetXTitle("p (GeV/c)");
+    fh2EledEdx->SetYTitle("<dE/dx>");
+    outputContainer->Add(fh2EledEdx) ;
+    
+    fh1pOverER02 = new TH2F("h1pOverER02","TRACK matches p/E, all",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
+    fh1pOverER02->SetYTitle("p/E");
+    fh1pOverER02->SetXTitle("p_{T} (GeV/c)");
+    outputContainer->Add(fh1pOverER02);        
+  }
+  
+  if(fFillAllPi0Histo){
+    fhIM  = new TH2F ("hIM","Cluster pairs Invariant mass vs reconstructed pair energy",nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
+    fhIM->SetXTitle("p_{T, cluster pairs} (GeV) ");
+    fhIM->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
+    outputContainer->Add(fhIM);
     
-    fhPtCharged  = new TH1F ("hPtCharged","p_{T} reconstructed clusters, matched with track", nptbins,ptmin,ptmax); 
-    fhPtCharged->SetXTitle("p_{T} (GeV/c)");
-    outputContainer->Add(fhPtCharged);
+    fhIMCellCut  = new TH2F ("hIMCellCut","Cluster (n cell > 1) pairs Invariant mass vs reconstructed pair energy",nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
+    fhIMCellCut->SetXTitle("p_{T, cluster pairs} (GeV) ");
+    fhIMCellCut->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
+    outputContainer->Add(fhIMCellCut);
     
-    fhPhiCharged  = new TH1F ("hPhiCharged","#phi reconstructed clusters, matched with track",nphibins,phimin,phimax); 
-    fhPhiCharged->SetXTitle("#phi (rad)");
-    outputContainer->Add(fhPhiCharged);
+    fhAsym  = new TH2F ("hAssym","Cluster pairs Asymmetry vs reconstructed pair energy",nptbins,ptmin,ptmax,nasymbins,asymmin,asymmax); 
+    fhAsym->SetXTitle("p_{T, cluster pairs} (GeV) ");
+    fhAsym->SetYTitle("Asymmetry");
+    outputContainer->Add(fhAsym);      
     
-    fhEtaCharged  = new TH1F ("hEtaCharged","#eta reconstructed clusters, matched with track",netabins,etamin,etamax); 
-    fhEtaCharged->SetXTitle("#eta ");
-    outputContainer->Add(fhEtaCharged);
   }
-  
-  fhEtaPhiECharged  = new TH3F ("hEtaPhiECharged","#eta vs #phi, reconstructed clusters, matched with track",
-                                netabins,etamin,etamax,nphibins,phimin,phimax,nptbins,ptmin,ptmax); 
-  fhEtaPhiECharged->SetXTitle("#eta ");
-  fhEtaPhiECharged->SetYTitle("#phi ");
-  fhEtaPhiECharged->SetZTitle("E (GeV) ");
-  outputContainer->Add(fhEtaPhiECharged);      
-  
-  fh1pOverE = new TH2F("h1pOverE","TRACK matches p/E",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
-  fh1pOverE->SetYTitle("p/E");
-  fh1pOverE->SetXTitle("p_{T} (GeV/c)");
-  outputContainer->Add(fh1pOverE);
-  
-  fh1dR = new TH1F("h1dR","TRACK matches dR",ndRbins,dRmin,dRmax);
-  fh1dR->SetXTitle("#Delta R (rad)");
-  outputContainer->Add(fh1dR) ;
-  
-  fh2MatchdEdx = new TH2F("h2MatchdEdx","dE/dx vs. p for all matches",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
-  fh2MatchdEdx->SetXTitle("p (GeV/c)");
-  fh2MatchdEdx->SetYTitle("<dE/dx>");
-  outputContainer->Add(fh2MatchdEdx);
-  
-  fh2EledEdx = new TH2F("h2EledEdx","dE/dx vs. p for electrons",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
-  fh2EledEdx->SetXTitle("p (GeV/c)");
-  fh2EledEdx->SetYTitle("<dE/dx>");
-  outputContainer->Add(fh2EledEdx) ;
-  
-  fh1pOverER02 = new TH2F("h1pOverER02","TRACK matches p/E, all",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
-  fh1pOverER02->SetYTitle("p/E");
-  fh1pOverER02->SetXTitle("p_{T} (GeV/c)");
-  outputContainer->Add(fh1pOverER02);  
-  
-  fhIM  = new TH2F ("hIM","Cluster pairs Invariant mass vs reconstructed pair energy",nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
-  fhIM->SetXTitle("p_{T, cluster pairs} (GeV) ");
-  fhIM->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
-  outputContainer->Add(fhIM);
-  
-  fhIMCellCut  = new TH2F ("hIMCellCut","Cluster (n cell > 1) pairs Invariant mass vs reconstructed pair energy",nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
-  fhIMCellCut->SetXTitle("p_{T, cluster pairs} (GeV) ");
-  fhIMCellCut->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
-  outputContainer->Add(fhIMCellCut);
-  
-  fhAsym  = new TH2F ("hAssym","Cluster pairs Asymmetry vs reconstructed pair energy",nptbins,ptmin,ptmax,nasymbins,asymmin,asymmax); 
-  fhAsym->SetXTitle("p_{T, cluster pairs} (GeV) ");
-  fhAsym->SetYTitle("Asymmetry");
-  outputContainer->Add(fhAsym);        
-  
-  
-  Int_t nlargeetabins = 3;
-  if(fCalorimeter=="EMCAL") nlargeetabins = 8;
-  
-  fhNCellsPerCluster  = new TH3F ("hNCellsPerCluster","# cells per cluster vs energy vs #eta",nptbins,ptmin,ptmax, nbins,nmin,nmax, nlargeetabins,etamin,etamax); 
+
+  fhNCellsPerClusterNoCut  = new TH2F ("hNCellsPerClusterNoCut","# cells per cluster vs energy vs #eta, no bad clusters cut",nptbins,ptmin,ptmax, nbins/5,nmin,nmax/5); 
+  fhNCellsPerClusterNoCut->SetXTitle("E (GeV)");
+  fhNCellsPerClusterNoCut->SetYTitle("n cells");
+  outputContainer->Add(fhNCellsPerClusterNoCut);
+    
+  fhNCellsPerCluster  = new TH2F ("hNCellsPerCluster","# cells per cluster vs energy vs #eta",nptbins,ptmin,ptmax, nbins/5,nmin,nmax/5); 
   fhNCellsPerCluster->SetXTitle("E (GeV)");
   fhNCellsPerCluster->SetYTitle("n cells");
-  fhNCellsPerCluster->SetZTitle("#eta");
   outputContainer->Add(fhNCellsPerCluster);
+    
+  if((fCalorimeter=="EMCAL" && GetReader()->GetEMCALPtMin() < 0.3) ||
+     (fCalorimeter=="PHOS"  && GetReader()->GetPHOSPtMin()  < 0.3)) {
+    fhNCellsPerClusterMIP  = new TH2F ("hNCellsPerClusterMIP","# cells per cluster vs energy vs #eta, smaller bin for MIP search", 
+                                       40,0.,2., 11,0,10); 
+    fhNCellsPerClusterMIP->SetXTitle("E (GeV)");
+    fhNCellsPerClusterMIP->SetYTitle("n cells");
+    outputContainer->Add(fhNCellsPerClusterMIP);
+    
+    
+    if(fFillAllTMHisto){
+      fhNCellsPerClusterMIPCharged  = new TH2F ("hNCellsPerClusterMIPCharged","# cells per track-matched cluster vs energy vs #eta, smaller bin for MIP search", 
+                                                40,0.,2., 11,0,10); 
+      fhNCellsPerClusterMIPCharged->SetXTitle("E (GeV)");
+      fhNCellsPerClusterMIPCharged->SetYTitle("n cells");
+      outputContainer->Add(fhNCellsPerClusterMIPCharged);
+    }
+       }
   
-  
-  fhNCellsPerClusterMIP  = new TH3F ("hNCellsPerClusterMIP","# cells per cluster vs energy vs #eta, smaller bin for MIP search", 
-                                     40,0.,2., 11,0,10,nlargeetabins,etamin,etamax); 
-  fhNCellsPerClusterMIP->SetXTitle("E (GeV)");
-  fhNCellsPerClusterMIP->SetYTitle("n cells");
-  fhNCellsPerClusterMIP->SetZTitle("#eta");
-  outputContainer->Add(fhNCellsPerClusterMIP);
-  
-  
-  fhNCellsPerClusterMIPCharged  = new TH3F ("hNCellsPerClusterMIPCharged","# cells per track-matched cluster vs energy vs #eta, smaller bin for MIP search", 
-                                            40,0.,2., 11,0,10,nlargeetabins,etamin,etamax); 
-  fhNCellsPerClusterMIPCharged->SetXTitle("E (GeV)");
-  fhNCellsPerClusterMIPCharged->SetYTitle("n cells");
-  fhNCellsPerClusterMIPCharged->SetZTitle("#eta");
-  outputContainer->Add(fhNCellsPerClusterMIPCharged);
-       
-       
   fhNClusters  = new TH1F ("hNClusters","# clusters", nbins,nmin,nmax); 
   fhNClusters->SetXTitle("number of clusters");
   outputContainer->Add(fhNClusters);
   
-  fhXYZ  = new TH3F ("hXYZ","Cluster: x vs y vs z",xbins,xmin,xmax,ybins,ymin,ymax,zbins,zmin,zmax); 
-  fhXYZ->SetXTitle("x (cm)");
-  fhXYZ->SetYTitle("y (cm)");
-  fhXYZ->SetZTitle("z (cm) ");
-  outputContainer->Add(fhXYZ);  
-  
-  fhXNCells  = new TH2F ("hXNCells","Cluster X position vs N Clusters per Cell",xbins,xmin,xmax,nbins,nmin,nmax); 
-  fhXNCells->SetXTitle("x (cm)");
-  fhXNCells->SetYTitle("N cells per cluster");
-  outputContainer->Add(fhXNCells);
-  
-  fhZNCells  = new TH2F ("hZNCells","Cluster Z position vs N Clusters per Cell",zbins,zmin,zmax,nbins,nmin,nmax); 
-  fhZNCells->SetXTitle("z (cm)");
-  fhZNCells->SetYTitle("N cells per cluster");
-  outputContainer->Add(fhZNCells);
-  
-  fhXE  = new TH2F ("hXE","Cluster X position vs cluster energy",xbins,xmin,xmax,nptbins,ptmin,ptmax); 
-  fhXE->SetXTitle("x (cm)");
-  fhXE->SetYTitle("E (GeV)");
-  outputContainer->Add(fhXE);
-  
-  fhZE  = new TH2F ("hZE","Cluster Z position vs cluster energy",zbins,zmin,zmax,nptbins,ptmin,ptmax); 
-  fhZE->SetXTitle("z (cm)");
-  fhZE->SetYTitle("E (GeV)");
-  outputContainer->Add(fhZE);    
-  
-  
-  fhRNCells  = new TH2F ("hRNCells","Cluster R position vs N Clusters per Cell",rbins,rmin,rmax,nbins,nmin,nmax); 
-  fhRNCells->SetXTitle("r = #sqrt{x^{2}+y^{2}} (cm)");
-  fhRNCells->SetYTitle("N cells per cluster");
-  outputContainer->Add(fhRNCells);
-  
-  
-  fhYNCells  = new TH2F ("hYNCells","Cluster Y position vs N Clusters per Cell",ybins,ymin,ymax,nbins,nmin,nmax); 
-  fhYNCells->SetXTitle("y (cm)");
-  fhYNCells->SetYTitle("N cells per cluster");
-  outputContainer->Add(fhYNCells);
-  
-  fhRE  = new TH2F ("hRE","Cluster R position vs cluster energy",rbins,rmin,rmax,nptbins,ptmin,ptmax); 
-  fhRE->SetXTitle("r = #sqrt{x^{2}+y^{2}} (cm)");
-  fhRE->SetYTitle("E (GeV)");
-  outputContainer->Add(fhRE);
-  
-  fhYE  = new TH2F ("hYE","Cluster Y position vs cluster energy",ybins,ymin,ymax,nptbins,ptmin,ptmax); 
-  fhYE->SetXTitle("y (cm)");
-  fhYE->SetYTitle("E (GeV)");
-  outputContainer->Add(fhYE);
+  if(fFillAllPosHisto2){
     
+    if(fFillAllTH3){
+      fhXYZ  = new TH3F ("hXYZ","Cluster: x vs y vs z",xbins,xmin,xmax,ybins,ymin,ymax,zbins,zmin,zmax); 
+      fhXYZ->SetXTitle("x (cm)");
+      fhXYZ->SetYTitle("y (cm)");
+      fhXYZ->SetZTitle("z (cm) ");
+      outputContainer->Add(fhXYZ);  
+    }
+    
+    fhXNCells  = new TH2F ("hXNCells","Cluster X position vs N Clusters per Cell",xbins,xmin,xmax,nbins,nmin,nmax); 
+    fhXNCells->SetXTitle("x (cm)");
+    fhXNCells->SetYTitle("N cells per cluster");
+    outputContainer->Add(fhXNCells);
+    
+    fhZNCells  = new TH2F ("hZNCells","Cluster Z position vs N Clusters per Cell",zbins,zmin,zmax,nbins,nmin,nmax); 
+    fhZNCells->SetXTitle("z (cm)");
+    fhZNCells->SetYTitle("N cells per cluster");
+    outputContainer->Add(fhZNCells);
+    
+    fhXE  = new TH2F ("hXE","Cluster X position vs cluster energy",xbins,xmin,xmax,nptbins,ptmin,ptmax); 
+    fhXE->SetXTitle("x (cm)");
+    fhXE->SetYTitle("E (GeV)");
+    outputContainer->Add(fhXE);
+    
+    fhZE  = new TH2F ("hZE","Cluster Z position vs cluster energy",zbins,zmin,zmax,nptbins,ptmin,ptmax); 
+    fhZE->SetXTitle("z (cm)");
+    fhZE->SetYTitle("E (GeV)");
+    outputContainer->Add(fhZE);    
+    
+    
+    fhRNCells  = new TH2F ("hRNCells","Cluster R position vs N Clusters per Cell",rbins,rmin,rmax,nbins,nmin,nmax); 
+    fhRNCells->SetXTitle("r = #sqrt{x^{2}+y^{2}} (cm)");
+    fhRNCells->SetYTitle("N cells per cluster");
+    outputContainer->Add(fhRNCells);
+    
+    
+    fhYNCells  = new TH2F ("hYNCells","Cluster Y position vs N Clusters per Cell",ybins,ymin,ymax,nbins,nmin,nmax); 
+    fhYNCells->SetXTitle("y (cm)");
+    fhYNCells->SetYTitle("N cells per cluster");
+    outputContainer->Add(fhYNCells);
+    
+    fhRE  = new TH2F ("hRE","Cluster R position vs cluster energy",rbins,rmin,rmax,nptbins,ptmin,ptmax); 
+    fhRE->SetXTitle("r = #sqrt{x^{2}+y^{2}} (cm)");
+    fhRE->SetYTitle("E (GeV)");
+    outputContainer->Add(fhRE);
+    
+    fhYE  = new TH2F ("hYE","Cluster Y position vs cluster energy",ybins,ymin,ymax,nptbins,ptmin,ptmax); 
+    fhYE->SetXTitle("y (cm)");
+    fhYE->SetYTitle("E (GeV)");
+    outputContainer->Add(fhYE);
+  }
   if(fFillAllPosHisto){
-
+    
     fhRCellE  = new TH2F ("hRCellE","Cell R position vs cell energy",rbins,rmin,rmax,nptbins,ptmin,ptmax); 
     fhRCellE->SetXTitle("r = #sqrt{x^{2}+y^{2}} (cm)");
     fhRCellE->SetYTitle("E (GeV)");
@@ -515,7 +610,7 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
     fhCellIdCellLargeTimeSpread= new TH1F ("hCellIdCellLargeTimeSpread","", colmax*rowmax*fNModules,0,colmax*rowmax*fNModules); 
     fhCellIdCellLargeTimeSpread->SetXTitle("Absolute Cell Id");
     outputContainer->Add(fhCellIdCellLargeTimeSpread);
-
+    
     fhTime  = new TH1F ("hTime","Cell Time",ntimebins,timemin,timemax); 
     fhTime->SetXTitle("Cell Time (ns)");
     outputContainer->Add(fhTime);
@@ -610,23 +705,23 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
     outputContainer->Add(fhCaloV0MCorrECells);    
     
     //Calorimeter VS Track multiplicity
-    fhCaloTrackMCorrNClusters  = new TH2F ("hCaloTrackMNClusters",Form("# clusters in %s vs V0 signal",fCalorimeter.Data()), ntrmbins,ntrmmin,ntrmmax,nbins,nmin,nmax); 
-    fhCaloTrackMCorrNClusters->SetXTitle("Track Multiplicity");
+    fhCaloTrackMCorrNClusters  = new TH2F ("hCaloTrackMNClusters",Form("# clusters in %s vs # tracks",fCalorimeter.Data()), ntrmbins,ntrmmin,ntrmmax,nbins,nmin,nmax); 
+    fhCaloTrackMCorrNClusters->SetXTitle("# tracks");
     fhCaloTrackMCorrNClusters->SetYTitle(Form("number of clusters in %s",fCalorimeter.Data()));
     outputContainer->Add(fhCaloTrackMCorrNClusters);
     
-    fhCaloTrackMCorrEClusters  = new TH2F ("hCaloTrackMEClusters",Form("summed energy of clusters in %s vs V0 signal",fCalorimeter.Data()), ntrmbins,ntrmmin,ntrmmax,nptbins,ptmin,ptmax); 
-    fhCaloTrackMCorrEClusters->SetXTitle("Track Multiplicity");
+    fhCaloTrackMCorrEClusters  = new TH2F ("hCaloTrackMEClusters",Form("summed energy of clusters in %s vs # tracks",fCalorimeter.Data()), ntrmbins,ntrmmin,ntrmmax,nptbins,ptmin,ptmax); 
+    fhCaloTrackMCorrEClusters->SetXTitle("# tracks");
     fhCaloTrackMCorrEClusters->SetYTitle(Form("#Sigma E of clusters in %s (GeV)",fCalorimeter.Data()));
     outputContainer->Add(fhCaloTrackMCorrEClusters);
     
-    fhCaloTrackMCorrNCells  = new TH2F ("hCaloTrackMNCells",Form("# Cells in %s vs V0 signal",fCalorimeter.Data()), ntrmbins,ntrmmin,ntrmmax, nbins,nmin,nmax); 
-    fhCaloTrackMCorrNCells->SetXTitle("Track Multiplicity");
+    fhCaloTrackMCorrNCells  = new TH2F ("hCaloTrackMNCells",Form("# Cells in %s vs # tracks",fCalorimeter.Data()), ntrmbins,ntrmmin,ntrmmax, nbins,nmin,nmax); 
+    fhCaloTrackMCorrNCells->SetXTitle("# tracks");
     fhCaloTrackMCorrNCells->SetYTitle(Form("number of Cells in %s",fCalorimeter.Data()));
     outputContainer->Add(fhCaloTrackMCorrNCells);
     
-    fhCaloTrackMCorrECells  = new TH2F ("hCaloTrackMECells",Form("summed energy of Cells in %s vs V0 signal",fCalorimeter.Data()), ntrmbins,ntrmmin,ntrmmax,nptbins,ptmin,ptmax); 
-    fhCaloTrackMCorrECells->SetXTitle("Track Multiplicity");
+    fhCaloTrackMCorrECells  = new TH2F ("hCaloTrackMECells",Form("summed energy of Cells in %s vs # tracks",fCalorimeter.Data()), ntrmbins,ntrmmin,ntrmmax,nptbins,ptmin,ptmax); 
+    fhCaloTrackMCorrECells->SetXTitle("# tracks");
     fhCaloTrackMCorrECells->SetYTitle(Form("#Sigma E of Cells in %s (GeV)",fCalorimeter.Data()));
     outputContainer->Add(fhCaloTrackMCorrECells);    
     
@@ -637,6 +732,7 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
   fhEMod                 = new TH1F*[fNModules];
   fhNClustersMod         = new TH1F*[fNModules];
   fhNCellsPerClusterMod  = new TH2F*[fNModules];
+  fhNCellsPerClusterModNoCut  = new TH2F*[fNModules];
   fhNCellsMod            = new TH1F*[fNModules];
   fhGridCellsMod         = new TH2F*[fNModules];
   fhGridCellsEMod        = new TH2F*[fNModules];
@@ -668,6 +764,14 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
     fhNCellsPerClusterMod[imod]->SetXTitle("E (GeV)");
     fhNCellsPerClusterMod[imod]->SetYTitle("n cells");
     outputContainer->Add(fhNCellsPerClusterMod[imod]);
+
+    fhNCellsPerClusterModNoCut[imod]  = new TH2F (Form("hNCellsPerClusterNoCut_Mod%d",imod),
+                                             Form("# cells per cluster vs cluster energy in Module %d, no cut",imod), 
+                                             nptbins,ptmin,ptmax, nbins,nmin,nmax); 
+    fhNCellsPerClusterModNoCut[imod]->SetXTitle("E (GeV)");
+    fhNCellsPerClusterModNoCut[imod]->SetYTitle("n cells");
+    outputContainer->Add(fhNCellsPerClusterModNoCut[imod]);
+    
     
     fhNCellsMod[imod]  = new TH1F (Form("hNCells_Mod%d",imod),Form("# cells in Module %d",imod), colmax*rowmax,0,colmax*rowmax); 
     fhNCellsMod[imod]->SetXTitle("n cells");
@@ -733,21 +837,21 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
         //                             }
       }
     }
-    
-    fhIMMod[imod]  = new TH2F (Form("hIM_Mod%d",imod),
-                               Form("Cluster pairs Invariant mass vs reconstructed pair energy in Module %d",imod),
-                               nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
-    fhIMMod[imod]->SetXTitle("p_{T, cluster pairs} (GeV) ");
-    fhIMMod[imod]->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
-    outputContainer->Add(fhIMMod[imod]);
-    
-    fhIMCellCutMod[imod]  = new TH2F (Form("hIMCellCut_Mod%d",imod),
-                                      Form("Cluster (n cells > 1) pairs Invariant mass vs reconstructed pair energy in Module %d",imod),
-                                      nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
-    fhIMCellCutMod[imod]->SetXTitle("p_{T, cluster pairs} (GeV) ");
-    fhIMCellCutMod[imod]->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
-    outputContainer->Add(fhIMCellCutMod[imod]);
-    
+    if(fFillAllPi0Histo){
+      fhIMMod[imod]  = new TH2F (Form("hIM_Mod%d",imod),
+                                 Form("Cluster pairs Invariant mass vs reconstructed pair energy in Module %d",imod),
+                                 nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
+      fhIMMod[imod]->SetXTitle("p_{T, cluster pairs} (GeV) ");
+      fhIMMod[imod]->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
+      outputContainer->Add(fhIMMod[imod]);
+      
+      fhIMCellCutMod[imod]  = new TH2F (Form("hIMCellCut_Mod%d",imod),
+                                        Form("Cluster (n cells > 1) pairs Invariant mass vs reconstructed pair energy in Module %d",imod),
+                                        nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
+      fhIMCellCutMod[imod]->SetXTitle("p_{T, cluster pairs} (GeV) ");
+      fhIMCellCutMod[imod]->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
+      outputContainer->Add(fhIMCellCutMod[imod]);
+    }
   }
   
   
@@ -1212,8 +1316,8 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
     outputContainer->Add(fhMCNeutral1pOverER02);
   }
   
-//  for(Int_t i = 0; i < outputContainer->GetEntries() ; i++)
-//    printf("i=%d, name= %s\n",i,outputContainer->At(i)->GetName());
+  //  for(Int_t i = 0; i < outputContainer->GetEntries() ; i++)
+  //    printf("i=%d, name= %s\n",i,outputContainer->At(i)->GetName());
   
   return outputContainer;
 }
@@ -1222,11 +1326,14 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
 Int_t AliAnaCalorimeterQA::GetNewRebinForRePlotting(TH1D* histo, const Float_t newXmin, const Float_t newXmax,const Int_t newXnbins) const
 {
   //Calculate the rebinning for the new requested bin size, only used when replotting executing the Terminte
   Float_t oldbinsize =  histo->GetBinWidth(0);
   Float_t newbinsize = TMath::Abs(newXmax-newXmin) / newXnbins;
+
   //printf("bin size, old %f, new %f\n",oldbinsize,newbinsize);
   if(newbinsize > oldbinsize) return (Int_t) (newbinsize/oldbinsize);
   else  return 1;
+
 }
 
 //__________________________________________________
@@ -1236,7 +1343,7 @@ void AliAnaCalorimeterQA::Init()
   
   if(fCalorimeter != "PHOS" && fCalorimeter !="EMCAL")
     AliFatal(Form("Wrong calorimeter name <%s>", fCalorimeter.Data()));
-
+  
   if(GetReader()->GetDataType()== AliCaloTrackReader::kMC)
     AliFatal("Analysis of reconstructed data, MC reader not aplicable");
   
@@ -1249,28 +1356,15 @@ void AliAnaCalorimeterQA::InitParameters()
   //Initialize the parameters of the analysis.
   AddToHistogramsName("AnaCaloQA_");
   
-  fCalorimeter = "EMCAL"; //or PHOS
-  fStyleMacro  = "" ;
-  fNModules    = 12; // set maximum to maximum number of EMCAL modules
-  fNRCU        = 2;  // set maximum number of RCU in EMCAL per SM
-  fTimeCutMin  = -1;
-  fTimeCutMax  = 9999999;
+  fCalorimeter     = "EMCAL"; //or PHOS
+  fStyleMacro      = "" ;
+  fNModules        = 12; // set maximum to maximum number of EMCAL modules
+  fNRCU            = 2;  // set maximum number of RCU in EMCAL per SM
+  fTimeCutMin      = -1;
+  fTimeCutMax      = 9999999;
   fEMCALCellAmpMin = 0.0;
   fPHOSCellAmpMin  = 0.0;
-  
-  fHistoPOverEBins     = 100 ;  fHistoPOverEMax     = 10.  ;  fHistoPOverEMin     = 0. ;
-  fHistodEdxBins       = 200 ;  fHistodEdxMax       = 400. ;  fHistodEdxMin       = 0. ;  
-  fHistodRBins         = 300 ;  fHistodRMax         = 3.15 ;  fHistodRMin         = 0. ;
-  fHistoTimeBins       = 1000;  fHistoTimeMax       = 1.e3 ;  fHistoTimeMin       = 0. ;//ns
-  fHistoNBins          = 300 ;  fHistoNMax          = 300  ;  fHistoNMin          = 0  ;
-  fHistoRatioBins      = 200 ;  fHistoRatioMax      = 2    ;  fHistoRatioMin      = 0. ;
-  fHistoVertexDistBins = 100 ;  fHistoVertexDistMax = 500. ;  fHistoVertexDistMin = 0. ;
-  fHistoRBins          = 100 ;  fHistoRMax          = 500  ;  fHistoRMin          = -500  ;//cm
-  fHistoXBins          = 100 ;  fHistoXMax          = 500  ;  fHistoXMin          = -500  ;//cm
-  fHistoYBins          = 100 ;  fHistoYMax          = 500  ;  fHistoYMin          = -500  ;//cm
-  fHistoZBins          = 100 ;  fHistoZMax          = 600  ;  fHistoZMin          = -500  ;//cm
-  fHistoSSBins         = 40  ;  fHistoSSMax         = 10  ;   fHistoSSMin         = 0  ;
-       
+       
 }
 
 //__________________________________________________________________
@@ -1288,18 +1382,7 @@ void AliAnaCalorimeterQA::Print(const Option_t * opt) const
   printf("Time Cut: %3.1f < TOF  < %3.1f\n", fTimeCutMin, fTimeCutMax);
   printf("EMCAL Min Amplitude   : %2.1f GeV/c\n", fEMCALCellAmpMin) ;
   printf("PHOS Min Amplitude    : %2.1f GeV/c\n", fPHOSCellAmpMin) ;
-  printf("Histograms: %3.1f < p/E  < %3.1f, Nbin = %d\n", fHistoPOverEMin, fHistoPOverEMax, fHistoPOverEBins);
-  printf("Histograms: %3.1f < dEdx < %3.1f, Nbin = %d\n", fHistodEdxMin,   fHistodEdxMax,   fHistodEdxBins);
-  printf("Histograms: %3.1f < dR (track cluster)   < %3.1f, Nbin = %d\n", fHistodRMin,     fHistodRMax,     fHistodRBins);
-  printf("Histograms: %3.1f < R=sqrt{x^2+y^2}    < %3.1f, Nbin = %d\n", fHistoRMin,      fHistoRMax,      fHistoRBins);
-  printf("Histograms: %3.1f < X    < %3.1f, Nbin = %d\n", fHistoXMin,      fHistoXMax,      fHistoXBins);
-  printf("Histograms: %3.1f < Y    < %3.1f, Nbin = %d\n", fHistoYMin,      fHistoYMax,      fHistoYBins);
-  printf("Histograms: %3.1f < Z    < %3.1f, Nbin = %d\n", fHistoZMin,      fHistoZMax,      fHistoZBins);
-  printf("Histograms: %g < Time < %g, Nbin = %d\n"      , fHistoTimeMin,   fHistoTimeMax,   fHistoTimeBins);
-  printf("Histograms: %d < N    < %d, Nbin = %d\n"      , fHistoNMin,      fHistoNMax,      fHistoNBins);
-  printf("Histograms: %3.1f < Ratio< %3.1f, Nbin = %d\n", fHistoRatioMin,  fHistoRatioMax,  fHistoRatioBins);
-  printf("Histograms: %3.1f < Vertex Distance < %3.1f, Nbin = %d\n", fHistoVertexDistMin, fHistoVertexDistMax, fHistoVertexDistBins);
-  
+
 } 
 
 //__________________________________________________________________
@@ -1330,7 +1413,7 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
       
       if(!GetMCStack()) 
         AliFatal("Stack not available, is the MC handler called?\n");
-        
+      
       //Fill some pure MC histograms, only primaries.
       for(Int_t i=0 ; i<GetMCStack()->GetNprimary(); i++){//Only primary particles, for all MC transport put GetNtrack()
         TParticle *primary = GetMCStack()->Particle(i) ;
@@ -1362,13 +1445,13 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
   
   
   //Get List with CaloClusters  
-  if      (fCalorimeter == "PHOS")  caloClusters = GetAODPHOS();
-  else if (fCalorimeter == "EMCAL") caloClusters = GetAODEMCAL();
+  if      (fCalorimeter == "PHOS")  caloClusters = GetPHOSClusters();
+  else if (fCalorimeter == "EMCAL") caloClusters = GetEMCALClusters();
   else 
     AliFatal(Form("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data()));
   
-  //  if     (fCalorimeter == "EMCAL") GetReader()->GetInputEvent()->GetEMCALClusters(caloClusters);//GetAODEMCAL();
-  //  else if(fCalorimeter == "PHOS")  GetReader()->GetInputEvent()->GetPHOSClusters (caloClusters);//GetAODPHOS();
+  //  if     (fCalorimeter == "EMCAL") GetReader()->GetInputEvent()->GetEMCALClusters(caloClusters);//GetEMCALClusters();
+  //  else if(fCalorimeter == "PHOS")  GetReader()->GetInputEvent()->GetPHOSClusters (caloClusters);//GetPHOSClusters();
   //  else 
   //    AliFatal(Form("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data()));
   
@@ -1394,7 +1477,6 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
     
     AliVTrack * track = 0x0;
     Float_t pos[3] ;
-    Float_t showerShape[3] ;
     Double_t tof = 0;
     //Loop over CaloClusters
     //if(nCaloClusters > 0)printf("QA  : Vertex Cut passed %f, cut %f, entries %d, %s\n",v[2], 40., nCaloClusters, fCalorimeter.Data());
@@ -1419,17 +1501,12 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
       if(IsFiducialCutOn()) in =  GetFiducialCut()->IsInFiducialCut(mom,fCalorimeter) ;
       if(!in) continue;
       
-      //Get module of cluster
-      nCaloClustersAccepted++;
-      nModule = GetModuleNumber(clus);
-      if(nModule >=0 && nModule < fNModules) nClustersInModule[nModule]++;
-      
       //MC labels
       nLabel = clus->GetNLabels();
       labels = clus->GetLabels();
       
       //Cells per cluster
-      nCaloCellsPerCluster =  clus->GetNCells();
+      nCaloCellsPerCluster = clus->GetNCells();
       //if(mom.E() > 10 && nCaloCellsPerCluster == 1 ) printf("%s:************** E = %f ********** ncells = %d\n",fCalorimeter.Data(), mom.E(),nCaloCellsPerCluster);
       
       //matched cluster with tracks
@@ -1448,11 +1525,6 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
         if(nTracksMatched > 0) track = (AliVTrack*)clus->GetTrackMatched(0);
       }
       
-      //Shower shape parameters
-      showerShape[0] = clus->GetM20();
-      showerShape[1] = clus->GetM02();
-      showerShape[2] = clus->GetDispersion();
-      
       //======================
       //Cells in cluster
       //======================
@@ -1461,18 +1533,16 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
       UShort_t * indexList = clus->GetCellsAbsId() ;
       // check time of cells respect to max energy cell
       //Get maximum energy cell
-      Float_t emax  = -1;
-      Double_t tmax = -1;
-      Int_t imax    = -1;
       Int_t absId   = -1 ;
       //printf("nCaloCellsPerCluster %d\n",nCaloCellsPerCluster);
-      //Loop on cluster cells
-      for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
-        //     printf("Index %d\n",ipos);
-        absId  = indexList[ipos]; 
-        
-        //Get position of cell compare to cluster
-        if(fFillAllPosHisto){
+      if(fFillAllPosHisto){
+        //Loop on cluster cells
+        for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
+          //   printf("Index %d\n",ipos);
+          absId  = indexList[ipos]; 
+          
+          //Get position of cell compare to cluster
+          
           if(fCalorimeter=="EMCAL" && GetCaloUtils()->IsEMCALGeoMatrixSet()){
             
             Double_t cellpos[] = {0, 0, 0};
@@ -1534,118 +1604,211 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
             //                 printf("z cluster %f, z cell %f, cluster-cell %f\n",pos[2], cellpos[2],pos[2]-cellpos[2]);
             //                                 printf("r cluster %f, r cell %f, cluster-cell %f\n",r,      rcell,     r-rcell);
           }//PHOS and its matrices are available
-        }//Fill all position histograms
-        
-        //Find maximum energy cluster
-        if(cell->GetCellAmplitude(absId) > emax) {
-          imax = ipos;
-          emax = cell->GetCellAmplitude(absId);
-          tmax = cell->GetCellTime(absId);
-        } 
-        
-      }// cluster cell loop
-      //Bad clusters histograms
-      Float_t minNCells = 1+mom.E()/3;//-x*x*0.0033
-      if(nCaloCellsPerCluster < minNCells) {
-        if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) 
-          fhBadClusterMaxCellTimeEnergy->Fill(mom.E(),tmax);
-        else 
-          fhBadClusterMaxCellTimeEnergy->Fill(mom.E(),tof);
-        //printf("bad tof : %2.3f\n",tof);
+          
+          
+        }// cluster cell loop
+      }//Fill all position histograms
 
-        for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
-          //   printf("Index %d\n",ipos);
-          if(ipos!=imax){
-            absId  = indexList[ipos]; 
-            Float_t frac = cell->GetCellAmplitude(absId)/emax;
-            //printf("bad frac : %2.3f, e %2.2f, ncells %d, min %2.1f\n",frac,mom.E(),nCaloCellsPerCluster,minNCells);
-            fhBadClusterMaxCellCloseCellRatio->Fill(mom.E(),frac);
-          }
-        }
-      }//Bad cluster
+      // Get the fraction of the cluster energy that carries the cell with highest energy
+      Float_t maxCellFraction = 0.;
+      Int_t absIdMax = GetCaloUtils()->GetMaxEnergyCell(cell, clus,maxCellFraction);
+      Double_t tmax  = cell->GetCellTime(absIdMax)*1e9;
+
+      if     (clus->E() < 2.){
+        fhLambda0vsClusterMaxCellDiffE0->Fill(clus->GetM02(),      maxCellFraction);
+        fhNCellsvsClusterMaxCellDiffE0 ->Fill(nCaloCellsPerCluster,maxCellFraction);
+      }
+      else if(clus->E() < 6.){
+        fhLambda0vsClusterMaxCellDiffE2->Fill(clus->GetM02(),      maxCellFraction);
+        fhNCellsvsClusterMaxCellDiffE2 ->Fill(nCaloCellsPerCluster,maxCellFraction);
+      }
       else{
-        if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) 
-          fhClusterMaxCellTimeEnergy->Fill(mom.E(),tmax);
-        else 
-          fhClusterMaxCellTimeEnergy->Fill(mom.E(),tof);
-        for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
-          //   printf("Index %d\n",ipos);
-          if(ipos!=imax){
+        fhLambda0vsClusterMaxCellDiffE6->Fill(clus->GetM02(),      maxCellFraction);  
+        fhNCellsvsClusterMaxCellDiffE6 ->Fill(nCaloCellsPerCluster,maxCellFraction);
+      }
+      
+      fhNCellsPerClusterNoCut  ->Fill(clus->E(), nCaloCellsPerCluster);
+      nModule = GetModuleNumber(clus);
+      if(nModule >=0 && nModule < fNModules) fhNCellsPerClusterModNoCut[nModule]->Fill(clus->E(), nCaloCellsPerCluster);
+
+      fhClusterMaxCellDiffNoCut->Fill(clus->E(),maxCellFraction);
+      //fhClusterMaxCellDiffDivLambda0->Fill(clus->E(),maxCellFraction / clus->GetNCells());
+
+      //Check bad clusters if rejection was not on
+      Bool_t badCluster = kFALSE;
+      if(fCalorimeter=="EMCAL" && !GetCaloUtils()->GetEMCALRecoUtils()->IsRejectExoticCluster()){
+        //Bad clusters histograms
+        //Float_t minNCells = TMath::Max(1,TMath::Nint(1 + TMath::Log(clus->E() - 5 )*1.5 ));
+        //if(nCaloCellsPerCluster <= minNCells) {
+        if(clus->GetM02() < 0.05) {
+
+          //if(clus->GetM02() > 0 || TMath::Abs(clus->GetM20()) > 0 || clus->GetDispersion() > 0)
+          
+          Int_t sm =0; Int_t ietaa=-1; Int_t iphii = 0; Int_t rcu = 0;
+          sm = GetModuleNumberCellIndexes(absId,fCalorimeter, ietaa, iphii, rcu);
+//          if(clus->GetNCells() > 3){
+//            printf("Bad  : E %f, ncells %d, nclusters %d, dist to bad %f, l0 %f, l1 %f, d %f, cell max t %f, cluster TOF %f, sm %d, icol %d, irow %d, rcu %d\n", 
+//                   clus->E(), clus->GetNCells(),nCaloClusters, clus->GetDistanceToBadChannel(), 
+//                   clus->GetM02(), clus->GetM20(), clus->GetDispersion(),tmax, tof,sm,ietaa,iphii,rcu);
+//          }
+          
+          badCluster = kTRUE;
+          
+          fhBadClusterEnergy     ->Fill(clus->E());
+          fhBadClusterMaxCellDiff->Fill(clus->E(),maxCellFraction);
+          fhBadClusterTimeEnergy ->Fill(clus->E(),tof);
+          //printf("bad tof : %2.3f\n",tof);
+          //if(clus->E() - emax < 0)printf("What?\n");
+
+          //Clusters in event time difference
+          
+            for(Int_t iclus2 = 0; iclus2 < nCaloClusters; iclus2++ ){
+              
+              AliVCluster* clus2 =  (AliVCluster*)caloClusters->At(iclus2);
+              
+              if(clus->GetID()==clus2->GetID()) continue;
+              
+              if(clus->GetM02() > 0.01) {
+                fhBadClusterPairDiffTimeE  ->Fill(clus->E(), tof-clus2->GetTOF()*1.e9);
+//               if(clus->GetNCells()>3) printf("\t i %d, E %f, nCells %d, dist to bad %f, good tof %f, bad tof %f, diff %f \n",
+//                       iclus2, clus2->E(), clus2->GetNCells(), clus->GetDistanceToBadChannel(), tof,clus2->GetTOF()*1.e9,tof-clus2->GetTOF()*1.e9);
+              }
+//              else{  
+//                Int_t absId2 = clus2->GetCellsAbsId()[0];
+//                Int_t sm2 =0; Int_t ietaa2=-1; Int_t iphii2 = 0; Int_t rcu2 = 0;
+//                sm2 = GetModuleNumberCellIndexes(absId2,fCalorimeter, ietaa2, iphii2, rcu2);
+//                 if(clus->GetNCells()>3) printf("i %d, E %f, nCells %d, bad tof %f, bad tof %f, diff %f, sm %d, icol %d, irow %d, rcu %d\n",
+//                       iclus2, clus2->E(), clus2->GetNCells(), tof,clus2->GetTOF()*1.e9,tof-clus2->GetTOF()*1.e9,sm2,ietaa2,iphii2,rcu2);
+//                
+//              }
+              
+            }
+          
+          
+          for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
+            // printf("Index %d\n",ipos);  
             absId  = indexList[ipos]; 
-            Float_t frac = cell->GetCellAmplitude(absId)/emax;
-            //printf("good frac : %2.3f\n",frac);
-            fhClusterMaxCellCloseCellRatio->Fill(mom.E(),frac);
+            if(absId!=absIdMax){
+              Float_t frac = cell->GetCellAmplitude(absId)/cell->GetCellAmplitude(absIdMax);
+              //printf("bad frac : %2.3f, e %2.2f, ncells %d, min %2.1f\n",frac,mom.E(),nCaloCellsPerCluster,minNCells);
+              fhBadClusterMaxCellCloseCellRatio->Fill(mom.E(),frac);
+            }
           }
-        }
-      }//good cluster
+        }//Bad cluster
+      }
+      
+      if(!badCluster){
+        
+        //        if(TMath::Abs(clus->GetM20()) < 0.0001 && clus->GetNCells() > 3){
+        //          Int_t sm =0; Int_t ietaa=-1; Int_t iphii = 0; Int_t rcu = 0;
+        //          sm = GetModuleNumberCellIndexes(absId,fCalorimeter, ietaa, iphii, rcu);
+        //          printf("Good : E %f, mcells %d, l0 %f, l1 %f, d %f, cell max t %f, cluster TOF %f, sm %d, icol %d, irow %d \n", 
+        //                 clus->E(), clus->GetNCells(),clus->GetM02(), clus->GetM20(), clus->GetDispersion(),tmax, tof,sm,ietaa,iphii);
+        //
+        //        }
+        
+        fhClusterMaxCellDiff->Fill(clus->E(),maxCellFraction);
+        fhClusterTimeEnergy ->Fill(mom.E(),tof);
+        
+        //Clusters in event time difference
+        for(Int_t iclus2 = 0; iclus2 < nCaloClusters; iclus2++ ){
           
-      // check time of cells respect to max energy cell
-      if(nCaloCellsPerCluster > 1 &&  GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
+          AliVCluster* clus2 =  (AliVCluster*) caloClusters->At(iclus2);
+          
+          if(clus->GetID()==clus2->GetID()) continue;
+          
+          if(clus->GetM02() > 0.01) {
+            fhClusterPairDiffTimeE  ->Fill(clus->E(), tof-clus2->GetTOF()*1.e9);
+          }
+        }        
+        
         for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
-          if(imax == ipos) continue;
+          //   printf("Index %d\n",ipos);            
           absId  = indexList[ipos]; 
-          Float_t diff = (tmax-cell->GetCellTime(absId))*1e9;
-          fhCellTimeSpreadRespectToCellMax->Fill(diff);
-          if(TMath::Abs(TMath::Abs(diff) > 100)) fhCellIdCellLargeTimeSpread->Fill(absId);
-        }// fill cell-cluster histogram loop
-      }//check time of cells respect to max energy cell
-      
-      //-----------------------------------------------------------
-      //Fill histograms related to single cluster or track matching
-      //-----------------------------------------------------------
-      ClusterHistograms(mom, tof, pos, showerShape, nCaloCellsPerCluster, nModule, nTracksMatched, track, labels, nLabel);     
-      
-      
-      //-----------------------------------------------------------
-      //Invariant mass
-      //-----------------------------------------------------------
-      if(GetDebug()>1) printf("Invariant mass \n");
-      
-      //do not do for bad vertex
-      // Float_t fZvtxCut = 40. ;      
-      if(v[2]<-GetZvertexCut() || v[2]> GetZvertexCut()) continue ; //Event can not be used (vertex, centrality,... cuts not fulfilled)
-      
-      Int_t nModule2 = -1;
-      Int_t nCaloCellsPerCluster2=0;
-      if (nCaloClusters > 1 ) {
-        for(Int_t jclus = iclus + 1 ; jclus < nCaloClusters ; jclus++) {
-          AliVCluster* clus2 =  (AliVCluster*)caloClusters->At(jclus);
-          
-          //Get cluster kinematics
-          clus2->GetMomentum(mom2,v);
-          //Check only certain regions
-          Bool_t in2 = kTRUE;
-          if(IsFiducialCutOn()) in2 =  GetFiducialCut()->IsInFiducialCut(mom2,fCalorimeter) ;
-          if(!in2) continue;   
-          //Get module of cluster
-          nModule2 = GetModuleNumber(clus2);
-          //Cells per cluster
-          nCaloCellsPerCluster2 = clus2->GetNCells();
+          if(absId!=absIdMax){
+            Float_t frac = cell->GetCellAmplitude(absId)/cell->GetCellAmplitude(absIdMax);
+            //printf("good frac : %2.3f\n",frac);
+            fhClusterMaxCellCloseCellRatio->Fill(mom.E(),frac);
+          }
         }
-        //Fill invariant mass histograms
-        //All modules
         
-        //printf("QA : Fill inv mass histo: pt1 %f, pt2 %f, pt12 %f, mass %f, calo %s \n",mom.Pt(),mom2.Pt(),(mom+mom2).Pt(),(mom+mom2).M(), fCalorimeter.Data());
-        fhIM  ->Fill((mom+mom2).Pt(),(mom+mom2).M());
-        //Single module
-        if(nModule == nModule2 && nModule >=0 && nModule < fNModules)
-          fhIMMod[nModule]->Fill((mom+mom2).Pt(),(mom+mom2).M());
+        // check time of cells respect to max energy cell
+        if(nCaloCellsPerCluster > 1 &&  GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
+          for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
+            absId  = indexList[ipos];             
+            if(absId == absIdMax) continue;
+            Float_t diff = (tmax-cell->GetCellTime(absId))*1e9;
+            fhCellTimeSpreadRespectToCellMax->Fill(diff);
+            if(TMath::Abs(TMath::Abs(diff) > 100)) fhCellIdCellLargeTimeSpread->Fill(absId);
+          }// fill cell-cluster histogram loop
+        }//check time of cells respect to max energy cell
         
-        //Select only clusters with at least 2 cells
-        if(nCaloCellsPerCluster > 1 && nCaloCellsPerCluster2 > 1) {
-          //All modules
-          fhIMCellCut  ->Fill((mom+mom2).Pt(),(mom+mom2).M());
-          //Single modules
-          if(nModule == nModule2 && nModule >=0 && nModule < fNModules)
-            fhIMCellCutMod[nModule]->Fill((mom+mom2).Pt(),(mom+mom2).M());
-        }
         
-        //Asymetry histograms
-        fhAsym->Fill((mom+mom2).Pt(),TMath::Abs((mom.E()-mom2.E())/(mom.E()+mom2.E())));
+        //Get module of cluster
+        nCaloClustersAccepted++;
+        if(nModule >=0 && nModule < fNModules) nClustersInModule[nModule]++;
+        
+        //-----------------------------------------------------------
+        //Fill histograms related to single cluster or track matching
+        //-----------------------------------------------------------
+        ClusterHistograms(mom, pos, nCaloCellsPerCluster, nModule, nTracksMatched, track, labels, nLabel);     
+        
+        
+        //-----------------------------------------------------------
+        //Invariant mass
+        //-----------------------------------------------------------
+        if(fFillAllPi0Histo){
+          if(GetDebug()>1) printf("Invariant mass \n");
+          
+          //do not do for bad vertex
+          // Float_t fZvtxCut = 40. ;  
+          if(v[2]<-GetZvertexCut() || v[2]> GetZvertexCut()) continue ; //Event can not be used (vertex, centrality,... cuts not fulfilled)
+          
+          Int_t nModule2 = -1;
+          Int_t nCaloCellsPerCluster2=0;
+          if (nCaloClusters > 1 ) {
+            for(Int_t jclus = iclus + 1 ; jclus < nCaloClusters ; jclus++) {
+              AliVCluster* clus2 =  (AliVCluster*)caloClusters->At(jclus);
+              
+              //Get cluster kinematics
+              clus2->GetMomentum(mom2,v);
+              //Check only certain regions
+              Bool_t in2 = kTRUE;
+              if(IsFiducialCutOn()) in2 =  GetFiducialCut()->IsInFiducialCut(mom2,fCalorimeter) ;
+              if(!in2) continue;       
+              //Get module of cluster
+              nModule2 = GetModuleNumber(clus2);
+              //Cells per cluster
+              nCaloCellsPerCluster2 = clus2->GetNCells();
+            }
+            //Fill invariant mass histograms
+            //All modules
+            
+            //printf("QA : Fill inv mass histo: pt1 %f, pt2 %f, pt12 %f, mass %f, calo %s \n",mom.Pt(),mom2.Pt(),(mom+mom2).Pt(),(mom+mom2).M(), fCalorimeter.Data());
+            fhIM  ->Fill((mom+mom2).Pt(),(mom+mom2).M());
+            //Single module
+            if(nModule == nModule2 && nModule >=0 && nModule < fNModules)
+              fhIMMod[nModule]->Fill((mom+mom2).Pt(),(mom+mom2).M());
+            
+            //Select only clusters with at least 2 cells
+            if(nCaloCellsPerCluster > 1 && nCaloCellsPerCluster2 > 1) {
+              //All modules
+              fhIMCellCut  ->Fill((mom+mom2).Pt(),(mom+mom2).M());
+              //Single modules
+              if(nModule == nModule2 && nModule >=0 && nModule < fNModules)
+                fhIMCellCutMod[nModule]->Fill((mom+mom2).Pt(),(mom+mom2).M());
+            }
+            
+            //Asymetry histograms
+            fhAsym->Fill((mom+mom2).Pt(),TMath::Abs((mom.E()-mom2.E())/(mom.E()+mom2.E())));
+            
+          }// 2nd cluster loop
+        }//Fill Pi0
         
-      }// 2nd cluster loop
+      }//good cluster
+      
     }//cluster loop
-    
+
     //Number of clusters histograms
     if(nCaloClustersAccepted > 0) fhNClusters->Fill(nCaloClustersAccepted);
     //  Number of clusters per module
@@ -1661,7 +1824,7 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
   //----------------------------------------------------------
   // CALOCELLS
   //----------------------------------------------------------
-         
+  
   AliVCaloCells * cell = 0x0; 
   Int_t ncells = 0;
   if(fCalorimeter == "PHOS") 
@@ -1696,6 +1859,7 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
       printf("\t module %d, column %d, row %d \n", nModule,icol,irow);
     
     if(nModule < fNModules) {  
+      
       //Check if the cell is a bad channel
       if(GetCaloUtils()->IsBadChannelsRemovalSwitchedOn()){
         if(fCalorimeter=="EMCAL"){
@@ -1707,12 +1871,8 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
             continue;
           }
         }
-      }
-      else {
-        delete [] nCellsInModule;
-        return;
-      }
-
+      } // use bad channel map
+      
       //Get Recalibration factor if set
       if (GetCaloUtils()->IsRecalibrationOn()) {
         if(fCalorimeter == "PHOS") recalF = GetCaloUtils()->GetPHOSChannelRecalibrationFactor(nModule,icol,irow);
@@ -1795,69 +1955,68 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
           
         }// amplitude cut
       }
-    
-    
-    //Get Eta-Phi position of Cell
-    if(fFillAllPosHisto)
-    {
-      if(fCalorimeter=="EMCAL" && GetCaloUtils()->IsEMCALGeoMatrixSet()){
-        Float_t celleta = 0.;
-        Float_t cellphi = 0.;
-        GetEMCALGeometry()->EtaPhiFromIndex(id, celleta, cellphi); 
-        
-        fhEtaPhiAmp->Fill(celleta,cellphi,amp);
-        Double_t cellpos[] = {0, 0, 0};
-        GetEMCALGeometry()->GetGlobal(id, cellpos);
-        fhXCellE->Fill(cellpos[0],amp)  ; 
-        fhYCellE->Fill(cellpos[1],amp)  ; 
-        fhZCellE->Fill(cellpos[2],amp)  ;
-        Float_t rcell = TMath::Sqrt(cellpos[0]*cellpos[0]+cellpos[1]*cellpos[1]);//+cellpos[2]*cellpos[2]);
-        fhRCellE->Fill(rcell,amp)  ;
-        fhXYZCell->Fill(cellpos[0],cellpos[1],cellpos[2])  ;
-      }//EMCAL Cells
-      else if(fCalorimeter=="PHOS" && GetCaloUtils()->IsPHOSGeoMatrixSet()){
-        TVector3 xyz;
-        Int_t relId[4], module;
-        Float_t xCell, zCell;
-        
-        GetPHOSGeometry()->AbsToRelNumbering(id,relId);
-        module = relId[0];
-        GetPHOSGeometry()->RelPosInModule(relId,xCell,zCell);
-        GetPHOSGeometry()->Local2Global(module,xCell,zCell,xyz);
-        Float_t rcell = TMath::Sqrt(xyz.X()*xyz.X()+xyz.Y()*xyz.Y());
-        fhXCellE ->Fill(xyz.X(),amp)  ; 
-        fhYCellE ->Fill(xyz.Y(),amp)  ; 
-        fhZCellE ->Fill(xyz.Z(),amp)  ;
-        fhRCellE ->Fill(rcell  ,amp)  ;
-        fhXYZCell->Fill(xyz.X(),xyz.Y(),xyz.Z())  ;
-      }//PHOS cells
-    }//fill cell position histograms
-    
-    if     (fCalorimeter=="EMCAL" && amp > fEMCALCellAmpMin) ncells ++ ;
-    else if(fCalorimeter=="PHOS"  && amp > fPHOSCellAmpMin)  ncells ++ ;
-    //else  
-    //  printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - no %s CELLS passed the analysis cut\n",fCalorimeter.Data());    
+      
+      
+      //Get Eta-Phi position of Cell
+      if(fFillAllPosHisto)
+      {
+        if(fCalorimeter=="EMCAL" && GetCaloUtils()->IsEMCALGeoMatrixSet()){
+          Float_t celleta = 0.;
+          Float_t cellphi = 0.;
+          GetEMCALGeometry()->EtaPhiFromIndex(id, celleta, cellphi); 
+          
+          fhEtaPhiAmp->Fill(celleta,cellphi,amp);
+          Double_t cellpos[] = {0, 0, 0};
+          GetEMCALGeometry()->GetGlobal(id, cellpos);
+          fhXCellE->Fill(cellpos[0],amp)  ; 
+          fhYCellE->Fill(cellpos[1],amp)  ; 
+          fhZCellE->Fill(cellpos[2],amp)  ;
+          Float_t rcell = TMath::Sqrt(cellpos[0]*cellpos[0]+cellpos[1]*cellpos[1]);//+cellpos[2]*cellpos[2]);
+          fhRCellE->Fill(rcell,amp)  ;
+          fhXYZCell->Fill(cellpos[0],cellpos[1],cellpos[2])  ;
+        }//EMCAL Cells
+        else if(fCalorimeter=="PHOS" && GetCaloUtils()->IsPHOSGeoMatrixSet()){
+          TVector3 xyz;
+          Int_t relId[4], module;
+          Float_t xCell, zCell;
+          
+          GetPHOSGeometry()->AbsToRelNumbering(id,relId);
+          module = relId[0];
+          GetPHOSGeometry()->RelPosInModule(relId,xCell,zCell);
+          GetPHOSGeometry()->Local2Global(module,xCell,zCell,xyz);
+          Float_t rcell = TMath::Sqrt(xyz.X()*xyz.X()+xyz.Y()*xyz.Y());
+          fhXCellE ->Fill(xyz.X(),amp)  ; 
+          fhYCellE ->Fill(xyz.Y(),amp)  ; 
+          fhZCellE ->Fill(xyz.Z(),amp)  ;
+          fhRCellE ->Fill(rcell  ,amp)  ;
+          fhXYZCell->Fill(xyz.X(),xyz.Y(),xyz.Z())  ;
+        }//PHOS cells
+      }//fill cell position histograms
+      
+      if     (fCalorimeter=="EMCAL" && amp > fEMCALCellAmpMin) ncells ++ ;
+      else if(fCalorimeter=="PHOS"  && amp > fPHOSCellAmpMin)  ncells ++ ;
+      //else  
+      //  printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - no %s CELLS passed the analysis cut\n",fCalorimeter.Data());    
     }//nmodules
   }//cell loop
   if(ncells > 0 )fhNCells->Fill(ncells) ; //fill the cells after the cut 
   
   //Number of cells per module
-       for(Int_t imod = 0; imod < fNModules; imod++ ) {
-               if(GetDebug() > 1) 
-                       printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - module %d calo %s cells %d\n", imod, fCalorimeter.Data(), nCellsInModule[imod]); 
-               fhNCellsMod[imod]->Fill(nCellsInModule[imod]) ;
-       }
-       delete [] nCellsInModule;
-       
-       if(GetDebug() > 0)
-               printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - End \n");
+  for(Int_t imod = 0; imod < fNModules; imod++ ) {
+    if(GetDebug() > 1) 
+      printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - module %d calo %s cells %d\n", imod, fCalorimeter.Data(), nCellsInModule[imod]); 
+    fhNCellsMod[imod]->Fill(nCellsInModule[imod]) ;
+  }
+  delete [] nCellsInModule;
+  
+  if(GetDebug() > 0)
+    printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - End \n");
 }
 
 
 //_____________________________________________________________________________________________
-void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Double_t tof, 
-                                            Float_t *pos, Float_t *showerShape,
-                                            const Int_t nCaloCellsPerCluster,const Int_t nModule,
+void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, 
+                                            Float_t *pos, const Int_t nCaloCellsPerCluster,const Int_t nModule,
                                             const Int_t nTracksMatched,  const AliVTrack * track,  
                                             const Int_t * labels, const Int_t nLabels){
   //Fill CaloCluster related histograms
@@ -1887,30 +2046,29 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
     fhPhi    ->Fill(phi);
     fhEta    ->Fill(eta);
   }
+  
   fhEtaPhiE->Fill(eta,phi,e);
   
   //Cells per cluster
-  fhNCellsPerCluster   ->Fill(e, nCaloCellsPerCluster,eta);
-  fhNCellsPerClusterMIP->Fill(e, nCaloCellsPerCluster,eta);
+  fhNCellsPerCluster   ->Fill(e, nCaloCellsPerCluster);
+  if((fCalorimeter=="EMCAL" && GetReader()->GetEMCALPtMin() < 0.3) ||
+     (fCalorimeter=="PHOS"  && GetReader()->GetPHOSPtMin()  < 0.3)) fhNCellsPerClusterMIP->Fill(e, nCaloCellsPerCluster);
   
   //Position
-  fhXE     ->Fill(pos[0],e);
-  fhYE     ->Fill(pos[1],e);
-  fhZE     ->Fill(pos[2],e);
-  fhXYZ    ->Fill(pos[0], pos[1],pos[2]);
-    
-  fhXNCells->Fill(pos[0],nCaloCellsPerCluster);
-  fhYNCells->Fill(pos[1],nCaloCellsPerCluster);
-  fhZNCells->Fill(pos[2],nCaloCellsPerCluster);
-  Float_t rxyz = TMath::Sqrt(pos[0]*pos[0]+pos[1]*pos[1]);//+pos[2]*pos[2]);
-  fhRE     ->Fill(rxyz,e);
-  fhRNCells->Fill(rxyz  ,nCaloCellsPerCluster);
-  
-  fhClusterTimeEnergy->Fill(e,tof);
-       
-  //Shower shape parameters
-  fhLambda->Fill(showerShape[0], showerShape[1], e);
-  fhDispersion->Fill(showerShape[2],e);
+  if(fFillAllPosHisto2){
+    fhXE     ->Fill(pos[0],e);
+    fhYE     ->Fill(pos[1],e);
+    fhZE     ->Fill(pos[2],e);
+    if(fFillAllTH3)
+      fhXYZ    ->Fill(pos[0], pos[1],pos[2]);
+    
+    fhXNCells->Fill(pos[0],nCaloCellsPerCluster);
+    fhYNCells->Fill(pos[1],nCaloCellsPerCluster);
+    fhZNCells->Fill(pos[2],nCaloCellsPerCluster);
+    Float_t rxyz = TMath::Sqrt(pos[0]*pos[0]+pos[1]*pos[1]);//+pos[2]*pos[2]);
+    fhRE     ->Fill(rxyz,e);
+    fhRNCells->Fill(rxyz  ,nCaloCellsPerCluster);
+  }
   
   if(nModule >=0 && nModule < fNModules) fhNCellsPerClusterMod[nModule]->Fill(e, nCaloCellsPerCluster);
   
@@ -2192,17 +2350,20 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
        
   //Match tracks and clusters
   //To be Modified in case of AODs
-               
-  if( nTracksMatched > 0){
-    if(fFillAllTH12){
+  
+  if( nTracksMatched > 0 &&  fFillAllTMHisto){
+    if(fFillAllTH12 && fFillAllTMHisto){
       fhECharged      ->Fill(e);       
       fhPtCharged     ->Fill(pt);
       fhPhiCharged    ->Fill(phi);
       fhEtaCharged    ->Fill(eta);
     }
-    fhEtaPhiECharged->Fill(eta,phi,e);         
-    fhNCellsPerClusterMIPCharged->Fill(e, nCaloCellsPerCluster,eta);
     
+    if(fFillAllTMHisto){
+      if(fFillAllTH3)fhEtaPhiECharged->Fill(eta,phi,e);                
+      if((fCalorimeter=="EMCAL" && GetReader()->GetEMCALPtMin() < 0.3) ||
+         (fCalorimeter=="PHOS"  && GetReader()->GetPHOSPtMin()  < 0.3))   fhNCellsPerClusterMIPCharged->Fill(e, nCaloCellsPerCluster);
+    }
     //printf("track index %d ntracks %d\n", esd->GetNumberOfTracks()); 
     //Study the track and matched cluster if track exists.
     if(!track) return;
@@ -2336,10 +2497,10 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
 //__________________________________
 void AliAnaCalorimeterQA::Correlate(){
   // Correlate information from PHOS and EMCAL and with V0 and track multiplicity
+  
   //Clusters 
-  TObjArray * caloClustersEMCAL = GetAODEMCAL();
-  TObjArray * caloClustersPHOS  = GetAODPHOS();
+  TObjArray * caloClustersEMCAL = GetEMCALClusters();
+  TObjArray * caloClustersPHOS  = GetPHOSClusters();
   
   Int_t nclEMCAL = caloClustersEMCAL->GetEntriesFast();
   Int_t nclPHOS  = caloClustersPHOS ->GetEntriesFast();
@@ -2352,12 +2513,12 @@ void AliAnaCalorimeterQA::Correlate(){
   for(iclus = 0 ; iclus <  caloClustersPHOS->GetEntriesFast(); iclus++) 
     sumClusterEnergyPHOS += ((AliVCluster*)caloClustersPHOS->At(iclus))->E();
   
-
+  
   //Cells
   
   AliVCaloCells * cellsEMCAL = GetEMCALCells();
   AliVCaloCells * cellsPHOS  = GetPHOSCells();
-
+  
   Int_t ncellsEMCAL = cellsEMCAL->GetNumberOfCells();
   Int_t ncellsPHOS  = cellsPHOS ->GetNumberOfCells();
   
@@ -2375,7 +2536,7 @@ void AliAnaCalorimeterQA::Correlate(){
   fhCaloCorrEClusters->Fill(sumClusterEnergyEMCAL,sumClusterEnergyPHOS);
   fhCaloCorrNCells   ->Fill(ncellsEMCAL,ncellsPHOS);
   fhCaloCorrECells   ->Fill(sumCellEnergyEMCAL,sumCellEnergyPHOS);
-
+  
   Int_t v0S = GetV0Signal(0)+GetV0Signal(1);
   Int_t v0M = GetV0Multiplicity(0)+GetV0Multiplicity(1);
   Int_t trM = GetTrackMultiplicity();
@@ -2384,12 +2545,12 @@ void AliAnaCalorimeterQA::Correlate(){
     fhCaloV0MCorrEClusters   ->Fill(v0M,sumClusterEnergyPHOS);
     fhCaloV0MCorrNCells      ->Fill(v0M,ncellsPHOS);
     fhCaloV0MCorrECells      ->Fill(v0M,sumCellEnergyPHOS);
-
+    
     fhCaloV0SCorrNClusters   ->Fill(v0S,nclPHOS);
     fhCaloV0SCorrEClusters   ->Fill(v0S,sumClusterEnergyPHOS);
     fhCaloV0SCorrNCells      ->Fill(v0S,ncellsPHOS);
     fhCaloV0SCorrECells      ->Fill(v0S,sumCellEnergyPHOS);
-
+    
     fhCaloTrackMCorrNClusters->Fill(trM,nclPHOS);
     fhCaloTrackMCorrEClusters->Fill(trM,sumClusterEnergyPHOS);    
     fhCaloTrackMCorrNCells   ->Fill(trM,ncellsPHOS);
@@ -2498,18 +2659,18 @@ void AliAnaCalorimeterQA::ReadHistograms(TList* outputList)
     fhPhi     = (TH1F *) outputList->At(index++); 
     fhEta     = (TH1F *) outputList->At(index++);
   }
+  
   fhEtaPhiE = (TH3F *) outputList->At(index++);
   
   fhClusterTimeEnergy = (TH2F*) outputList->At(index++);
   
-  fhLambda      = (TH3F *)  outputList->At(index++);
-  fhDispersion  = (TH2F *)  outputList->At(index++);
   if(fFillAllTH12){
     fhECharged       = (TH1F *) outputList->At(index++);       
     fhPtCharged      = (TH1F *) outputList->At(index++); 
     fhPhiCharged     = (TH1F *) outputList->At(index++); 
     fhEtaCharged     = (TH1F *) outputList->At(index++);
   }
+  
   fhEtaPhiECharged = (TH3F *) outputList->At(index++);
   
   fh1pOverE =    (TH2F *) outputList->At(index++);
@@ -2522,9 +2683,9 @@ void AliAnaCalorimeterQA::ReadHistograms(TList* outputList)
   fhIMCellCut = (TH2F *) outputList->At(index++);
   fhAsym      = (TH2F *) outputList->At(index++);
   
-  fhNCellsPerCluster           = (TH3F *) outputList->At(index++);
-  fhNCellsPerClusterMIP        = (TH3F *) outputList->At(index++);
-  fhNCellsPerClusterMIPCharged = (TH3F *) outputList->At(index++);
+  fhNCellsPerCluster           = (TH2F *) outputList->At(index++);
+  fhNCellsPerClusterMIP        = (TH2F *) outputList->At(index++);
+  fhNCellsPerClusterMIPCharged = (TH2F *) outputList->At(index++);
   fhNClusters  = (TH1F *) outputList->At(index++); 
   
   fhRNCells = (TH2F *) outputList->At(index++);
@@ -2627,7 +2788,7 @@ void AliAnaCalorimeterQA::ReadHistograms(TList* outputList)
     
     if(fCalorimeter=="EMCAL"){
       for(Int_t ifrac = 0; ifrac < 3; ifrac++){
-       fhAmplitudeModFraction[imod*3+ifrac] = (TH1F *) outputList->At(index++); 
+        fhAmplitudeModFraction[imod*3+ifrac] = (TH1F *) outputList->At(index++); 
       }
     }
     
@@ -2783,7 +2944,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
   //Do plots if requested      
   
   if(GetDebug() > 0) printf("AliAnaCalorimeterQA::Terminate() - Make plots for %s? %d\n",fCalorimeter.Data(), MakePlotsOn());
+  
   //Do some plots to end
   if(fStyleMacro!="")gROOT->Macro(fStyleMacro); 
   //Recover histograms from output histograms list, needed for distributed analysis.   
@@ -2972,12 +3133,12 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       TH1D * htmp =  (TH1D*)fhAmplitudeModFraction[3*imod+ifrac]->Clone(Form("ThirdFractionAverage_%d_%d",imod,ifrac));
       htmp->Divide(hAverageThird1);
       if(imod ==0) {
-       htmp ->SetTitle("Close to eta = 0");
-       htmp ->SetMaximum(5);
-       htmp ->SetMinimum(0);
-       htmp ->SetAxisRange(ptmin,ptmax,"X");
-       htmp ->SetYTitle("ratio third to average");
-       htmp -> Draw("HE");
+        htmp ->SetTitle("Close to eta = 0");
+        htmp ->SetMaximum(5);
+        htmp ->SetMinimum(0);
+        htmp ->SetAxisRange(ptmin,ptmax,"X");
+        htmp ->SetYTitle("ratio third to average");
+        htmp -> Draw("HE");
       }
       else htmp -> Draw("same HE");
     }
@@ -3016,12 +3177,12 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       TH1D * htmp =  (TH1D*)fhAmplitudeModFraction[3*imod+ifrac]->Clone(Form("ThirdFractionAverage_%d_%d",imod,ifrac));
       htmp->Divide(hAverageThird2);
       if(imod ==0) {
-       htmp ->SetTitle("Middle");
-       htmp ->SetMaximum(5);
-       htmp ->SetMinimum(0);
-       htmp ->SetAxisRange(ptmin,ptmax,"X");
-       htmp ->SetYTitle("ratio third to average");
-       htmp -> Draw("HE");
+        htmp ->SetTitle("Middle");
+        htmp ->SetMaximum(5);
+        htmp ->SetMinimum(0);
+        htmp ->SetAxisRange(ptmin,ptmax,"X");
+        htmp ->SetYTitle("ratio third to average");
+        htmp -> Draw("HE");
       }
       else htmp -> Draw("same HE");
     }
@@ -3061,12 +3222,12 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       TH1D * htmp =  (TH1D*)fhAmplitudeModFraction[3*imod+ifrac]->Clone(Form("ThirdFractionAverage_%d_%d",imod,ifrac));
       htmp->Divide(hAverageThird3);
       if(imod ==0) {
-       htmp ->SetTitle("Close to eta = 0.7");
-       htmp ->SetMaximum(5);
-       htmp ->SetMinimum(0);
-       htmp ->SetAxisRange(ptmin,ptmax,"X");
-       htmp ->SetYTitle("ratio third to average");
-       htmp ->Draw("HE");
+        htmp ->SetTitle("Close to eta = 0.7");
+        htmp ->SetMaximum(5);
+        htmp ->SetMinimum(0);
+        htmp ->SetAxisRange(ptmin,ptmax,"X");
+        htmp ->SetYTitle("ratio third to average");
+        htmp ->Draw("HE");
       }
       else htmp ->Draw("same HE");
     }
@@ -4116,7 +4277,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
   cN->cd(5) ; 
   if(fhNCellsPerCluster->GetEntries() > 0) gPad->SetLogy();
   gPad->SetLogx();
-  TH1D *cpc = fhNCellsPerCluster->ProjectionY("cpc",-1,-1,-1,-1);
+  TH1D *cpc = fhNCellsPerCluster->ProjectionY("cpc",-1,-1);
   cpc->SetLineColor(1);
   cpc->SetTitle("# cells per cluster");
   cpc->Draw("HE");