]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG4/PartCorrDep/AliAnaCalorimeterQA.cxx
Setters added (Magnus)
[u/mrichter/AliRoot.git] / PWG4 / PartCorrDep / AliAnaCalorimeterQA.cxx
index cb85899ca8c5611f155ac5d0155a2af48b52c293..eff534682da1d529c60d2e1f62e5908aae808b45 100755 (executable)
@@ -42,7 +42,7 @@
 #include "AliStack.h"
 #include "AliVCaloCells.h"
 #include "AliFiducialCut.h"
-#include "AliVTrack.h"
+#include "AliAODTrack.h"
 #include "AliVCluster.h"
 #include "AliVEvent.h"
 #include "AliVEventHandler.h"
@@ -57,8 +57,8 @@ ClassImp(AliAnaCalorimeterQA)
 //____________________________________________________________________________
 AliAnaCalorimeterQA::AliAnaCalorimeterQA() : 
 AliAnaPartCorrBaseClass(), fCalorimeter(""), fStyleMacro(""), 
-fMakePlots(kFALSE), fFillAllPosHisto(kFALSE), fFillAllTH12(kFALSE),
-fCorrelateCalos(kFALSE), fNModules(12), fNRCU(2),
+fFillAllPosHisto(kFALSE), fFillAllTH12(kFALSE),
+fCorrelate(kTRUE), fNModules(12), fNRCU(2),
 fTimeCutMin(-1), fTimeCutMax(9999999),
 fEMCALCellAmpMin(0),fPHOSCellAmpMin(0), 
 fHistoFinePtBins(1000),    fHistoFinePtMax(5.),        fHistoFinePtMin(0.),
@@ -81,7 +81,8 @@ 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),
+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),
@@ -90,6 +91,9 @@ fhDeltaCellClusterRE(0),     fhDeltaCellClusterXE(0),     fhDeltaCellClusterYE(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),
+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),
@@ -176,7 +180,10 @@ 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(); 
+
   //EMCAL
   Int_t colmax = 48;
   Int_t rowmax = 24;
@@ -219,7 +226,30 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
   fhClusterTimeEnergy->SetXTitle("E (GeV) ");
   fhClusterTimeEnergy->SetYTitle("TOF (ns)");
   outputContainer->Add(fhClusterTimeEnergy);
+    
+  fhClusterMaxCellCloseCellRatio  = new TH2F ("hClusterMaxCellCloseCell","energy vs ratio of max cell / neighbour cell, reconstructed clusters",
+                                          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",
@@ -485,7 +515,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);
@@ -515,13 +545,14 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
     //         outputContainer->Add(fhT0TimeAmp);
   }
        
-  if(fCorrelateCalos){
+  if(fCorrelate){
+    //PHOS vs EMCAL
     fhCaloCorrNClusters  = new TH2F ("hCaloCorrNClusters","# clusters in EMCAL vs PHOS", nbins,nmin,nmax,nbins,nmin,nmax); 
     fhCaloCorrNClusters->SetXTitle("number of clusters in EMCAL");
     fhCaloCorrNClusters->SetYTitle("number of clusters in PHOS");
     outputContainer->Add(fhCaloCorrNClusters);
     
-    fhCaloCorrEClusters  = new TH2F ("hCaloCorrEClusters","summed energy of clusters in EMCAL vs PHOS", nptbins*2,ptmin,ptmax*2,nptbins,ptmin,ptmax*2); 
+    fhCaloCorrEClusters  = new TH2F ("hCaloCorrEClusters","summed energy of clusters in EMCAL vs PHOS", nptbins,ptmin,ptmax,nptbins,ptmin,ptmax); 
     fhCaloCorrEClusters->SetXTitle("#Sigma E of clusters in EMCAL (GeV)");
     fhCaloCorrEClusters->SetYTitle("#Sigma E of clusters in PHOS (GeV)");
     outputContainer->Add(fhCaloCorrEClusters);
@@ -531,10 +562,75 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
     fhCaloCorrNCells->SetYTitle("number of Cells in PHOS");
     outputContainer->Add(fhCaloCorrNCells);
     
-    fhCaloCorrECells  = new TH2F ("hCaloCorrECells","summed energy of Cells in EMCAL vs PHOS", nptbins*2,ptmin,ptmax*2,nptbins,ptmin,ptmax*2); 
+    fhCaloCorrECells  = new TH2F ("hCaloCorrECells","summed energy of Cells in EMCAL vs PHOS", nptbins*2,ptmin,ptmax*2,nptbins*2,ptmin,ptmax*2); 
     fhCaloCorrECells->SetXTitle("#Sigma E of Cells in EMCAL (GeV)");
     fhCaloCorrECells->SetYTitle("#Sigma E of Cells in PHOS (GeV)");
     outputContainer->Add(fhCaloCorrECells);
+    
+    //Calorimeter VS V0 signal
+    fhCaloV0SCorrNClusters  = new TH2F ("hCaloV0SNClusters",Form("# clusters in %s vs V0 signal",fCalorimeter.Data()), nv0sbins,nv0smin,nv0smax,nbins,nmin,nmax); 
+    fhCaloV0SCorrNClusters->SetXTitle("V0 signal");
+    fhCaloV0SCorrNClusters->SetYTitle(Form("number of clusters in %s",fCalorimeter.Data()));
+    outputContainer->Add(fhCaloV0SCorrNClusters);
+    
+    fhCaloV0SCorrEClusters  = new TH2F ("hCaloV0SEClusters",Form("summed energy of clusters in %s vs V0 signal",fCalorimeter.Data()), nv0sbins,nv0smin,nv0smax,nptbins,ptmin,ptmax); 
+    fhCaloV0SCorrEClusters->SetXTitle("V0 signal");
+    fhCaloV0SCorrEClusters->SetYTitle(Form("#Sigma E of clusters in %s (GeV)",fCalorimeter.Data()));
+    outputContainer->Add(fhCaloV0SCorrEClusters);
+    
+    fhCaloV0SCorrNCells  = new TH2F ("hCaloV0SNCells",Form("# Cells in %s vs V0 signal",fCalorimeter.Data()), nv0sbins,nv0smin,nv0smax, nbins,nmin,nmax); 
+    fhCaloV0SCorrNCells->SetXTitle("V0 signal");
+    fhCaloV0SCorrNCells->SetYTitle(Form("number of Cells in %s",fCalorimeter.Data()));
+    outputContainer->Add(fhCaloV0SCorrNCells);
+    
+    fhCaloV0SCorrECells  = new TH2F ("hCaloV0SECells",Form("summed energy of Cells in %s vs V0 signal",fCalorimeter.Data()), nv0sbins,nv0smin,nv0smax,nptbins,ptmin,ptmax); 
+    fhCaloV0SCorrECells->SetXTitle("V0 signal");
+    fhCaloV0SCorrECells->SetYTitle(Form("#Sigma E of Cells in %s (GeV)",fCalorimeter.Data()));
+    outputContainer->Add(fhCaloV0SCorrECells);    
+    
+    //Calorimeter VS V0 multiplicity
+    fhCaloV0MCorrNClusters  = new TH2F ("hCaloV0MNClusters",Form("# clusters in %s vs V0 signal",fCalorimeter.Data()), nv0mbins,nv0mmin,nv0mmax,nbins,nmin,nmax); 
+    fhCaloV0MCorrNClusters->SetXTitle("V0 signal");
+    fhCaloV0MCorrNClusters->SetYTitle(Form("number of clusters in %s",fCalorimeter.Data()));
+    outputContainer->Add(fhCaloV0MCorrNClusters);
+    
+    fhCaloV0MCorrEClusters  = new TH2F ("hCaloV0MEClusters",Form("summed energy of clusters in %s vs V0 signal",fCalorimeter.Data()), nv0mbins,nv0mmin,nv0mmax,nptbins,ptmin,ptmax); 
+    fhCaloV0MCorrEClusters->SetXTitle("V0 signal");
+    fhCaloV0MCorrEClusters->SetYTitle(Form("#Sigma E of clusters in %s (GeV)",fCalorimeter.Data()));
+    outputContainer->Add(fhCaloV0MCorrEClusters);
+    
+    fhCaloV0MCorrNCells  = new TH2F ("hCaloV0MNCells",Form("# Cells in %s vs V0 signal",fCalorimeter.Data()), nv0mbins,nv0mmin,nv0mmax, nbins,nmin,nmax); 
+    fhCaloV0MCorrNCells->SetXTitle("V0 signal");
+    fhCaloV0MCorrNCells->SetYTitle(Form("number of Cells in %s",fCalorimeter.Data()));
+    outputContainer->Add(fhCaloV0MCorrNCells);
+    
+    fhCaloV0MCorrECells  = new TH2F ("hCaloV0MECells",Form("summed energy of Cells in %s vs V0 signal",fCalorimeter.Data()), nv0mbins,nv0mmin,nv0mmax,nptbins,ptmin,ptmax); 
+    fhCaloV0MCorrECells->SetXTitle("V0 signal");
+    fhCaloV0MCorrECells->SetYTitle(Form("#Sigma E of Cells in %s (GeV)",fCalorimeter.Data()));
+    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->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->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->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->SetYTitle(Form("#Sigma E of Cells in %s (GeV)",fCalorimeter.Data()));
+    outputContainer->Add(fhCaloTrackMCorrECells);    
+    
+    
   }//correlate calorimeters
   
   //Module histograms
@@ -600,43 +696,44 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
     
     if(fCalorimeter == "EMCAL"){
       for(Int_t ifrac = 0; ifrac < 3; ifrac++){
-       fhAmplitudeModFraction[imod*3+ifrac]  = new TH1F (Form("hAmplitude_Mod%d_Frac%d",imod,ifrac),Form("Cell reconstructed Energy in Module %d, Fraction %d ",imod,ifrac), nptbins,ptmin,ptmax); 
-       fhAmplitudeModFraction[imod*3+ifrac]->SetXTitle("E (GeV)");
-       outputContainer->Add(fhAmplitudeModFraction[imod*3+ifrac]);
+        fhAmplitudeModFraction[imod*3+ifrac]  = new TH1F (Form("hAmplitude_Mod%d_Frac%d",imod,ifrac),Form("Cell reconstructed Energy in Module %d, Fraction %d ",imod,ifrac), nptbins,ptmin,ptmax); 
+        fhAmplitudeModFraction[imod*3+ifrac]->SetXTitle("E (GeV)");
+        outputContainer->Add(fhAmplitudeModFraction[imod*3+ifrac]);
       }
       
     }
-    
-    for(Int_t ircu = 0; ircu < fNRCU; ircu++){
-      fhTimeAmpPerRCU[imod*fNRCU+ircu]  = new TH2F (Form("hTimeAmp_Mod%d_RCU%d",imod,ircu),
-                                                    Form("Cell Energy vs Cell Time in Module %d, RCU %d ",imod,ircu), 
-                                                    nptbins,ptmin,ptmax,ntimebins,timemin,timemax); 
-      fhTimeAmpPerRCU[imod*fNRCU+ircu]->SetXTitle("E (GeV)");
-      fhTimeAmpPerRCU[imod*fNRCU+ircu]->SetYTitle("time (ns)");
-      outputContainer->Add(fhTimeAmpPerRCU[imod*fNRCU+ircu]);
+    if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
       
-      //                               fhT0TimeAmpPerRCU[imod*fNRCU+ircu]  = new TH2F (Form("hT0TimeAmp_Mod%d_RCU%d",imod,ircu),
-      //                                                                                                                         Form("Cell Energy vs T0-Cell Time in Module %d, RCU %d ",imod,ircu), 
-      //                                                                                                                         nptbins,ptmin,ptmax,ntimebins,timemin,timemax); 
-      //                               fhT0TimeAmpPerRCU[imod*fNRCU+ircu]->SetXTitle("E (GeV)");
-      //                               fhT0TimeAmpPerRCU[imod*fNRCU+ircu]->SetYTitle("T_{0} - T_{EMCal} (ns)");
-      //                               outputContainer->Add(fhT0TimeAmpPerRCU[imod*fNRCU+ircu]);
-      //                       
-                       
-      //                               for(Int_t imod2 = 0; imod2 < fNModules; imod2++){
-      //                                               for(Int_t ircu2 = 0; ircu2 < fNModules; ircu2++){
-      //                                                       Int_t index =  (imod2*fNRCU+ircu2)+(fNModules*fNRCU)*(ircu+imod)+fNRCU*fNModules*imod; 
-      //                                                       fhTimeCorrRCU[index]  = new TH2F (Form("hTimeCorrRCU_Mod%d_RCU%d_CompareTo_Mod%d_RCU%d",imod, ircu,imod2, ircu2),
-      //                                                                                                                                                       Form("Cell Energy > 0.3, Correlate cell Time in Module %d, RCU %d to Module %d, RCU %d",imod,ircu,imod2, ircu2),
-      //                                                                                                                                                       ntimebins,timemin,timemax,ntimebins,timemin,timemax); 
-      //                                                       fhTimeCorrRCU[index]->SetXTitle("Trigger Cell Time (ns)");
-      //                                                       fhTimeCorrRCU[index]->SetYTitle("Cell Time (ns)");
-      //                                                       outputContainer->Add(fhTimeCorrRCU[index]);
-      //                                               }
-      //                               }
+      for(Int_t ircu = 0; ircu < fNRCU; ircu++){
+        fhTimeAmpPerRCU[imod*fNRCU+ircu]  = new TH2F (Form("hTimeAmp_Mod%d_RCU%d",imod,ircu),
+                                                      Form("Cell Energy vs Cell Time in Module %d, RCU %d ",imod,ircu), 
+                                                      nptbins,ptmin,ptmax,ntimebins,timemin,timemax); 
+        fhTimeAmpPerRCU[imod*fNRCU+ircu]->SetXTitle("E (GeV)");
+        fhTimeAmpPerRCU[imod*fNRCU+ircu]->SetYTitle("time (ns)");
+        outputContainer->Add(fhTimeAmpPerRCU[imod*fNRCU+ircu]);
+        
+        //                             fhT0TimeAmpPerRCU[imod*fNRCU+ircu]  = new TH2F (Form("hT0TimeAmp_Mod%d_RCU%d",imod,ircu),
+        //                                                                                                                       Form("Cell Energy vs T0-Cell Time in Module %d, RCU %d ",imod,ircu), 
+        //                                                                                                                       nptbins,ptmin,ptmax,ntimebins,timemin,timemax); 
+        //                             fhT0TimeAmpPerRCU[imod*fNRCU+ircu]->SetXTitle("E (GeV)");
+        //                             fhT0TimeAmpPerRCU[imod*fNRCU+ircu]->SetYTitle("T_{0} - T_{EMCal} (ns)");
+        //                             outputContainer->Add(fhT0TimeAmpPerRCU[imod*fNRCU+ircu]);
+        //                     
+        
+        //                             for(Int_t imod2 = 0; imod2 < fNModules; imod2++){
+        //                                             for(Int_t ircu2 = 0; ircu2 < fNModules; ircu2++){
+        //                                                     Int_t index =  (imod2*fNRCU+ircu2)+(fNModules*fNRCU)*(ircu+imod)+fNRCU*fNModules*imod; 
+        //                                                     fhTimeCorrRCU[index]  = new TH2F (Form("hTimeCorrRCU_Mod%d_RCU%d_CompareTo_Mod%d_RCU%d",imod, ircu,imod2, ircu2),
+        //                                                                                                                                                     Form("Cell Energy > 0.3, Correlate cell Time in Module %d, RCU %d to Module %d, RCU %d",imod,ircu,imod2, ircu2),
+        //                                                                                                                                                     ntimebins,timemin,timemax,ntimebins,timemin,timemax); 
+        //                                                     fhTimeCorrRCU[index]->SetXTitle("Trigger Cell Time (ns)");
+        //                                                     fhTimeCorrRCU[index]->SetYTitle("Cell Time (ns)");
+        //                                                     outputContainer->Add(fhTimeCorrRCU[index]);
+        //                                             }
+        //                             }
+      }
     }
     
-    
     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); 
@@ -1115,6 +1212,9 @@ 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());
+  
   return outputContainer;
 }
 
@@ -1133,15 +1233,12 @@ Int_t AliAnaCalorimeterQA::GetNewRebinForRePlotting(TH1D* histo, const Float_t n
 void AliAnaCalorimeterQA::Init()
 { 
   //Check if the data or settings are ok
-  if(fCalorimeter != "PHOS" && fCalorimeter !="EMCAL"){
-    printf("AliAnaCalorimeterQA::Init() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data());
-    abort();
-  }    
   
-  if(GetReader()->GetDataType()== AliCaloTrackReader::kMC){
-    printf("AliAnaCalorimeterQA::Init() - Analysis of reconstructed data, MC reader not aplicable\n");
-    abort();
-  }    
+  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");
   
 }
 
@@ -1187,7 +1284,6 @@ void AliAnaCalorimeterQA::Print(const Option_t * opt) const
   AliAnaPartCorrBaseClass::Print(" ");
   
   printf("Select Calorimeter %s \n",fCalorimeter.Data());
-  printf("Make plots?        %d \n",fMakePlots);       
   printf("Plots style macro  %s \n",fStyleMacro.Data()); 
   printf("Time Cut: %3.1f < TOF  < %3.1f\n", fTimeCutMin, fTimeCutMax);
   printf("EMCAL Min Amplitude   : %2.1f GeV/c\n", fEMCALCellAmpMin) ;
@@ -1232,10 +1328,9 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
   if(IsDataMC()){
     if(GetReader()->ReadStack()){
       
-      if(!GetMCStack()) {
-        printf("AliAnaPhoton::MakeAnalysisFillHistograms() - Stack not available, is the MC handler called? STOP\n");
-        abort();
-      }
+      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) ;
@@ -1247,10 +1342,9 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
     }
     else if(GetReader()->ReadAODMCParticles()){
       
-      if(!GetReader()->GetAODMCParticles(0))   {
-        printf("AliAnaPhoton::MakeAnalysisFillHistograms() -  AODMCParticles not available!\n");
-        abort();
-      }
+      if(!GetReader()->GetAODMCParticles(0))   
+        AliFatal("AODMCParticles not available!");
+      
       //Fill some pure MC histograms, only primaries.
       for(Int_t i=0 ; i < (GetReader()->GetAODMCParticles(0))->GetEntriesFast(); i++){
         AliAODMCParticle *aodprimary = (AliAODMCParticle*) (GetReader()->GetAODMCParticles(0))->At(i) ;
@@ -1283,11 +1377,9 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
   }
   else{
     //----------------------------------------------------------
-    //Correlate Calorimeters
+    //Correlate Calorimeters and V0 and track Multiplicity
     //----------------------------------------------------------
-    //if(fCorrelateCalos)      CorrelateCalorimeters(caloClusters);
-    if(fCorrelateCalos)        CorrelateCalorimeters();
-    
+    if(fCorrelate)     Correlate();
     
     //----------------------------------------------------------
     // CALOCLUSTERS
@@ -1311,38 +1403,38 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
       if(GetDebug() > 0) printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - cluster: %d/%d, data %d \n",
                                 iclus+1,nCaloClusters,GetReader()->GetDataType());
       
-      if(GetReader()->GetDataType()==AliCaloTrackReader::kESD){
-        AliVCluster* clus =  (AliVCluster*)caloClusters->At(iclus);
-        AliVCaloCells * cell = 0x0; 
-        if(fCalorimeter == "PHOS") cell =  GetPHOSCells();
-        else                                    cell =  GetEMCALCells();
-        
-        //Get cluster kinematics
-        clus->GetPosition(pos);
-        clus->GetMomentum(mom,v);
-        tof = clus->GetTOF()*1e9;
-        if(tof < fTimeCutMin || tof > fTimeCutMax) continue;
-        
-        //Check only certain regions
-        Bool_t in = kTRUE;
-        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();
-        //if(mom.E() > 10 && nCaloCellsPerCluster == 1 ) printf("%s:************** E = %f ********** ncells = %d\n",fCalorimeter.Data(), mom.E(),nCaloCellsPerCluster);
-        
-        //matched cluster with tracks
-        nTracksMatched = clus->GetNTracksMatched();
+      AliVCluster* clus =  (AliVCluster*)caloClusters->At(iclus);
+      AliVCaloCells * cell = 0x0; 
+      if(fCalorimeter == "PHOS") cell =  GetPHOSCells();
+      else                                      cell =  GetEMCALCells();
+      
+      //Get cluster kinematics
+      clus->GetPosition(pos);
+      clus->GetMomentum(mom,v);
+      tof = clus->GetTOF()*1e9;
+      if(tof < fTimeCutMin || tof > fTimeCutMax) continue;
+      
+      //Check only certain regions
+      Bool_t in = kTRUE;
+      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();
+      //if(mom.E() > 10 && nCaloCellsPerCluster == 1 ) printf("%s:************** E = %f ********** ncells = %d\n",fCalorimeter.Data(), mom.E(),nCaloCellsPerCluster);
+      
+      //matched cluster with tracks
+      nTracksMatched = clus->GetNTracksMatched();
+      if(GetReader()->GetDataType() == AliCaloTrackReader::kESD){
         trackIndex     = clus->GetTrackMatchedIndex();
         if(trackIndex >= 0){
           track = (AliVTrack*)GetReader()->GetInputEvent()->GetTrack(trackIndex);
@@ -1351,172 +1443,207 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
           if(nTracksMatched == 1) nTracksMatched = 0;
           track = 0;
         }
+      }//kESD
+      else{//AODs
+        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
+      //======================
+      
+      //Get list of contributors
+      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]; 
         
-        //Shower shape parameters
-        showerShape[0] = clus->GetM20();
-        showerShape[1] = clus->GetM02();
-        showerShape[2] = clus->GetDispersion();
+        //Get position of cell compare to cluster
+        if(fFillAllPosHisto){
+          if(fCalorimeter=="EMCAL" && GetCaloUtils()->IsEMCALGeoMatrixSet()){
+            
+            Double_t cellpos[] = {0, 0, 0};
+            GetEMCALGeometry()->GetGlobal(absId, cellpos);
+            
+            fhDeltaCellClusterXNCells->Fill(pos[0]-cellpos[0],nCaloCellsPerCluster) ; 
+            fhDeltaCellClusterYNCells->Fill(pos[1]-cellpos[1],nCaloCellsPerCluster) ; 
+            fhDeltaCellClusterZNCells->Fill(pos[2]-cellpos[2],nCaloCellsPerCluster) ;
+            
+            fhDeltaCellClusterXE->Fill(pos[0]-cellpos[0],mom.E())  ; 
+            fhDeltaCellClusterYE->Fill(pos[1]-cellpos[1],mom.E())  ; 
+            fhDeltaCellClusterZE->Fill(pos[2]-cellpos[2],mom.E())  ; 
+            
+            Float_t r     = TMath::Sqrt(pos[0]*pos[0]        +pos[1]*pos[1]);//     +pos[2]*pos[2]);
+            Float_t rcell = TMath::Sqrt(cellpos[0]*cellpos[0]+cellpos[1]*cellpos[1]);//+cellpos[2]*cellpos[2]);
+            fhDeltaCellClusterRNCells->Fill(r-rcell, nCaloCellsPerCluster) ; 
+            fhDeltaCellClusterRE     ->Fill(r-rcell, mom.E())  ; 
+            
+            //                                 Float_t celleta = 0, cellphi = 0;
+            //                                 GetEMCALGeometry()->EtaPhiFromIndex(absId, celleta, cellphi); 
+            //                                 Int_t imod = -1, iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1;
+            //                                 GetEMCALGeometry()->GetCellIndex(absId,imod,iTower,iIphi,iIeta); 
+            //                                 GetEMCALGeometry()->GetCellPhiEtaIndexInSModule(imod,iTower,
+            //                                                                                                                                                          iIphi, iIeta,iphi,ieta);
+            //                                 printf("AbsId %d, SM %d, Index eta %d, phi %d\n", absId, imod, ieta, iphi);
+            //                                 printf("Cluster E %f, eta %f, phi %f; Cell: Amp %f, eta %f, phi%f\n", mom.E(),mom.Eta(), mom.Phi()*TMath::RadToDeg(), cell->GetCellAmplitude(absId),celleta, cellphi*TMath::RadToDeg());
+            //                                 printf("x cluster %f, x cell %f, cluster-cell %f\n",pos[0], cellpos[0],pos[0]-cellpos[0]);
+            //                                 printf("y cluster %f, y cell %f, cluster-cell %f\n",pos[1], cellpos[1],pos[1]-cellpos[1]);
+            //                                 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);
+            //                                 
+            
+          }//EMCAL and its matrices are available
+          else if(fCalorimeter=="PHOS" && GetCaloUtils()->IsPHOSGeoMatrixSet()){
+            TVector3 xyz;
+            Int_t relId[4], module;
+            Float_t xCell, zCell;
+            
+            GetPHOSGeometry()->AbsToRelNumbering(absId,relId);
+            module = relId[0];
+            GetPHOSGeometry()->RelPosInModule(relId,xCell,zCell);
+            GetPHOSGeometry()->Local2Global(module,xCell,zCell,xyz);
+            
+            fhDeltaCellClusterXNCells->Fill(pos[0]-xyz.X(),nCaloCellsPerCluster) ; 
+            fhDeltaCellClusterYNCells->Fill(pos[1]-xyz.Y(),nCaloCellsPerCluster) ; 
+            fhDeltaCellClusterZNCells->Fill(pos[2]-xyz.Z(),nCaloCellsPerCluster) ;
+            
+            fhDeltaCellClusterXE->Fill(pos[0]-xyz.X(),mom.E())  ; 
+            fhDeltaCellClusterYE->Fill(pos[1]-xyz.Y(),mom.E())  ; 
+            fhDeltaCellClusterZE->Fill(pos[2]-xyz.Z(),mom.E())  ; 
+            
+            Float_t r     = TMath::Sqrt(pos[0]*pos[0]  +pos[1]*pos[1]);//     +pos[2]*pos[2]);
+            Float_t rcell = TMath::Sqrt(xyz.X()*xyz.X()+xyz.Y()*xyz.Y());//+xyz.Z()*xyz.Z());
+            fhDeltaCellClusterRNCells->Fill(r-rcell, nCaloCellsPerCluster) ; 
+            fhDeltaCellClusterRE     ->Fill(r-rcell, mom.E())  ; 
+            
+            //                   printf("x cluster %f, x cell %f, cluster-cell %f\n",pos[0], cellpos[0],pos[0]-cellpos[0]);
+            //                 printf("y cluster %f, y cell %f, cluster-cell %f\n",pos[1], cellpos[1],pos[1]-cellpos[1]);
+            //                 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
         
-        //======================
-        //Cells in cluster
-        //======================
+        //Find maximum energy cluster
+        if(cell->GetCellAmplitude(absId) > emax) {
+          imax = ipos;
+          emax = cell->GetCellAmplitude(absId);
+          tmax = cell->GetCellTime(absId);
+        } 
         
-        //Get list of contributors
-        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
+      }// 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);
+
         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(fCalorimeter=="EMCAL" && GetCaloUtils()->IsEMCALGeoMatrixSet()){
-              
-              Double_t cellpos[] = {0, 0, 0};
-              GetEMCALGeometry()->GetGlobal(absId, cellpos);
-              
-              fhDeltaCellClusterXNCells->Fill(pos[0]-cellpos[0],nCaloCellsPerCluster) ; 
-              fhDeltaCellClusterYNCells->Fill(pos[1]-cellpos[1],nCaloCellsPerCluster) ; 
-              fhDeltaCellClusterZNCells->Fill(pos[2]-cellpos[2],nCaloCellsPerCluster) ;
-              
-              fhDeltaCellClusterXE->Fill(pos[0]-cellpos[0],mom.E())  ; 
-              fhDeltaCellClusterYE->Fill(pos[1]-cellpos[1],mom.E())  ; 
-              fhDeltaCellClusterZE->Fill(pos[2]-cellpos[2],mom.E())  ; 
-              
-              Float_t r     = TMath::Sqrt(pos[0]*pos[0]        +pos[1]*pos[1]);//     +pos[2]*pos[2]);
-              Float_t rcell = TMath::Sqrt(cellpos[0]*cellpos[0]+cellpos[1]*cellpos[1]);//+cellpos[2]*cellpos[2]);
-              fhDeltaCellClusterRNCells->Fill(r-rcell, nCaloCellsPerCluster) ; 
-              fhDeltaCellClusterRE     ->Fill(r-rcell, mom.E())  ; 
-              
-              //                                       Float_t celleta = 0, cellphi = 0;
-              //                                       GetEMCALGeometry()->EtaPhiFromIndex(absId, celleta, cellphi); 
-              //                                       Int_t imod = -1, iTower = -1, iIphi = -1, iIeta = -1, iphi = -1, ieta = -1;
-              //                                       GetEMCALGeometry()->GetCellIndex(absId,imod,iTower,iIphi,iIeta); 
-              //                                       GetEMCALGeometry()->GetCellPhiEtaIndexInSModule(imod,iTower,
-              //                                                                                                                                                                iIphi, iIeta,iphi,ieta);
-              //                                       printf("AbsId %d, SM %d, Index eta %d, phi %d\n", absId, imod, ieta, iphi);
-              //                                       printf("Cluster E %f, eta %f, phi %f; Cell: Amp %f, eta %f, phi%f\n", mom.E(),mom.Eta(), mom.Phi()*TMath::RadToDeg(), cell->GetCellAmplitude(absId),celleta, cellphi*TMath::RadToDeg());
-              //                                       printf("x cluster %f, x cell %f, cluster-cell %f\n",pos[0], cellpos[0],pos[0]-cellpos[0]);
-              //                                       printf("y cluster %f, y cell %f, cluster-cell %f\n",pos[1], cellpos[1],pos[1]-cellpos[1]);
-              //                                       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);
-              //                                       
-              
-            }//EMCAL and its matrices are available
-            else if(fCalorimeter=="PHOS" && GetCaloUtils()->IsPHOSGeoMatrixSet()){
-              TVector3 xyz;
-              Int_t relId[4], module;
-              Float_t xCell, zCell;
-              
-              GetPHOSGeometry()->AbsToRelNumbering(absId,relId);
-              module = relId[0];
-              GetPHOSGeometry()->RelPosInModule(relId,xCell,zCell);
-              GetPHOSGeometry()->Local2Global(module,xCell,zCell,xyz);
-              
-              fhDeltaCellClusterXNCells->Fill(pos[0]-xyz.X(),nCaloCellsPerCluster) ; 
-              fhDeltaCellClusterYNCells->Fill(pos[1]-xyz.Y(),nCaloCellsPerCluster) ; 
-              fhDeltaCellClusterZNCells->Fill(pos[2]-xyz.Z(),nCaloCellsPerCluster) ;
-              
-              fhDeltaCellClusterXE->Fill(pos[0]-xyz.X(),mom.E())  ; 
-              fhDeltaCellClusterYE->Fill(pos[1]-xyz.Y(),mom.E())  ; 
-              fhDeltaCellClusterZE->Fill(pos[2]-xyz.Z(),mom.E())  ; 
-              
-              Float_t r     = TMath::Sqrt(pos[0]*pos[0]  +pos[1]*pos[1]);//     +pos[2]*pos[2]);
-              Float_t rcell = TMath::Sqrt(xyz.X()*xyz.X()+xyz.Y()*xyz.Y());//+xyz.Z()*xyz.Z());
-              fhDeltaCellClusterRNCells->Fill(r-rcell, nCaloCellsPerCluster) ; 
-              fhDeltaCellClusterRE     ->Fill(r-rcell, mom.E())  ; 
-              
-              //                         printf("x cluster %f, x cell %f, cluster-cell %f\n",pos[0], cellpos[0],pos[0]-cellpos[0]);
-              //                       printf("y cluster %f, y cell %f, cluster-cell %f\n",pos[1], cellpos[1],pos[1]-cellpos[1]);
-              //                       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
-        
-        // check time of cells respect to max energy cell
-        if(nCaloCellsPerCluster > 1){
-          for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
-            if(imax == ipos) continue;
+          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
+      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){
             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
+            Float_t frac = cell->GetCellAmplitude(absId)/emax;
+            //printf("good frac : %2.3f\n",frac);
+            fhClusterMaxCellCloseCellRatio->Fill(mom.E(),frac);
+          }
+        }
+      }//good cluster
           
-        }//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");
+      // check time of cells respect to max energy cell
+      if(nCaloCellsPerCluster > 1 &&  GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
+        for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
+          if(imax == ipos) continue;
+          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();
+        }
+        //Fill invariant mass histograms
+        //All modules
         
-        //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)
+        //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());
         
-        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
+        //Select only clusters with at least 2 cells
+        if(nCaloCellsPerCluster > 1 && nCaloCellsPerCluster2 > 1) {
           //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
+          fhIMCellCut  ->Fill((mom+mom2).Pt(),(mom+mom2).M());
+          //Single modules
           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
-      }////more than 1 cluster in calorimeter          
+            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
     }//cluster loop
     
     //Number of clusters histograms
@@ -1552,18 +1679,18 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
   else                       
     cell = GetEMCALCells();
   
-  if(!cell) {
-    printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - STOP: No %s ESD CELLS available for analysis\n",fCalorimeter.Data());
-    abort();
-  }
+  if(!cell) 
+    AliFatal(Form("No %s CELLS available for analysis",fCalorimeter.Data()));
   
   if(GetDebug() > 0) 
-    printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - In ESD %s cell entries %d\n", fCalorimeter.Data(), cell->GetNumberOfCells());    
+    printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - %s cell entries %d\n", fCalorimeter.Data(), cell->GetNumberOfCells());    
   
   for (Int_t iCell = 0; iCell < cell->GetNumberOfCells(); iCell++) {      
-    if(GetDebug() > 2)  printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Cell : amp %f, absId %d \n", cell->GetAmplitude(iCell), cell->GetCellNumber(iCell));
+    if(GetDebug() > 2)  
+      printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Cell : amp %f, absId %d \n", cell->GetAmplitude(iCell), cell->GetCellNumber(iCell));
     nModule = GetModuleNumberCellIndexes(cell->GetCellNumber(iCell),fCalorimeter, icol, irow, iRCU);
-    if(GetDebug() > 2) printf("\t module %d, column %d, row %d \n", nModule,icol,irow);
+    if(GetDebug() > 2) 
+      printf("\t module %d, column %d, row %d \n", nModule,icol,irow);
     
     if(nModule < fNModules) {  
       //Check if the cell is a bad channel
@@ -1578,7 +1705,11 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
           }
         }
       }
-      
+      else {
+        delete [] nCellsInModule;
+        return;
+      }
+
       //Get Recalibration factor if set
       if (GetCaloUtils()->IsRecalibrationOn()) {
         if(fCalorimeter == "PHOS") recalF = GetCaloUtils()->GetPHOSChannelRecalibrationFactor(nModule,icol,irow);
@@ -1588,26 +1719,17 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
       
       amp     = cell->GetAmplitude(iCell)*recalF;
       time    = cell->GetTime(iCell)*1e9;//transform time to ns
-      if(time < fTimeCutMin || time > fTimeCutMax) continue;
       
+      //Remove noisy channels, only possible in ESDs
+      if(GetReader()->GetDataType() == AliCaloTrackReader::kESD){
+        if(time < fTimeCutMin || time > fTimeCutMax) continue;
+      }
       //if(amp > 3 && fCalorimeter=="EMCAL") printf("Amp = %f, time = %f, (mod, col, row)= (%d,%d,%d)\n",
       //                                                                                  amp,time,nModule,icol,irow);
       
-      //printf("%s: time %g\n",fCalorimeter.Data(), time);
       id      = cell->GetCellNumber(iCell);
       fhAmplitude->Fill(amp);
       fhAmpId    ->Fill(amp,id);
-      fhTime     ->Fill(time);
-      fhTimeId   ->Fill(time,id);
-      fhTimeAmp  ->Fill(amp,time);
-      //Double_t t0 = GetReader()->GetInputEvent()->GetT0();
-      //printf("---->>> Time EMCal %e, T0 %e, T0 vertex %e, T0 clock %e, T0 trig %d \n",time,t0, 
-      //          GetReader()->GetInputEvent()->GetT0zVertex(),
-      //          GetReader()->GetInputEvent()->GetT0clock(),
-      //          GetReader()->GetInputEvent()->GetT0Trig());
-      //fhT0Time     ->Fill(time-t0);
-      //fhT0TimeId   ->Fill(time-t0,id);
-      //fhT0TimeAmp  ->Fill(amp,time-t0);
       
       fhAmplitudeMod[nModule]->Fill(amp);
       if(fCalorimeter=="EMCAL"){
@@ -1617,48 +1739,69 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
         fhAmplitudeModFraction[nModule*3+ifrac]->Fill(amp);
       }
       
-      fhTimeAmpPerRCU  [nModule*fNRCU+iRCU]->Fill(amp, time);
-      //printf("id %d, nModule %d, iRCU %d: Histo Name %s\n",id, nModule,iRCU, fhTimeAmpPerRCU[nModule*fNRCU+iRCU]->GetName());
-      //fhT0TimeAmpPerRCU[nModule*fNRCU+iRCU]->Fill(amp, time-t0);
       nCellsInModule[nModule]++;
       fhGridCellsMod[nModule]    ->Fill(icol,irow);
       fhGridCellsEMod[nModule]   ->Fill(icol,irow,amp);
-      if(amp > 0.3){
-        fhGridCellsTimeMod[nModule]->Fill(icol,irow,time);
+      
+      if(GetReader()->GetDataType() == AliCaloTrackReader::kESD){
+        //printf("%s: time %g\n",fCalorimeter.Data(), time);
+        fhTime     ->Fill(time);
+        fhTimeId   ->Fill(time,id);
+        fhTimeAmp  ->Fill(amp,time);
         
-        //                                     AliESDCaloCells * cell2 = 0x0; 
-        //                                     if(fCalorimeter == "PHOS") cell2 =  GetReader()->GetInputEvent()->GetPHOSCells();
-        //                                     else                       cell2 = GetReader()->GetInputEvent()->GetEMCALCells();
-        //                                     Int_t icol2    = -1;
-        //                                     Int_t irow2    = -1;
-        //                                     Int_t iRCU2    = -1;
-        //                                     Float_t amp2   =  0.;
-        //                                     Float_t time2  =  0.;
-        //                                     Int_t id2      = -1;
-        //                                     Int_t nModule2 = -1;
-        //                                     for (Int_t iCell2 = 0; iCell2 < ncells; iCell2++) {  
-        //                                             amp2    = cell2->GetAmplitude(iCell2);
-        //                                             if(amp2 < 0.3) continue;
-        //                                             if(iCell2 == iCell) continue;
-        //                                             time2    = cell2->GetTime(iCell2)*1e9;//transform time to ns
-        //                                             //printf("%s: time %g\n",fCalorimeter.Data(), time);
-        //                                             id2      = cell2->GetCellNumber(iCell2);
-        //                                             nModule2 = GetModuleNumberCellIndexes(cell2->GetCellNumber(iCell2), fCalorimeter, icol2, irow2, iRCU2);
-        //                                             Int_t index = (nModule2*fNRCU+iRCU2)+(fNModules*fNRCU)*(iRCU+fNRCU*nModule); 
-        //                                             //printf("id %d, nModule %d, iRCU %d, id2 %d, nModule2 %d, iRCU2 %d, index %d: Histo Name %s\n",id, nModule,iRCU,cell2->GetCellNumber(iCell2),nModule2,iRCU2,index, fhTimeCorrRCU[index]->GetName());
-        //                                             fhTimeCorrRCU[index]->Fill(time,time2); 
-        //                                             
-        //                                     }// second cell loop
-      }// amplitude cut
-    }//nmodules
+        //Double_t t0 = GetReader()->GetInputEvent()->GetT0();
+        //printf("---->>> Time EMCal %e, T0 %e, T0 vertex %e, T0 clock %e, T0 trig %d \n",time,t0, 
+        //        GetReader()->GetInputEvent()->GetT0zVertex(),
+        //        GetReader()->GetInputEvent()->GetT0clock(),
+        //        GetReader()->GetInputEvent()->GetT0Trig());
+        //fhT0Time     ->Fill(time-t0);
+        //fhT0TimeId   ->Fill(time-t0,id);
+        //fhT0TimeAmp  ->Fill(amp,time-t0);
+        
+        //printf("id %d, nModule %d, iRCU %d: Histo Name %s\n",id, nModule,iRCU, fhTimeAmpPerRCU[nModule*fNRCU+iRCU]->GetName());
+        //fhT0TimeAmpPerRCU[nModule*fNRCU+iRCU]->Fill(amp, time-t0);
+        
+        fhTimeAmpPerRCU  [nModule*fNRCU+iRCU]->Fill(amp, time);
+        
+        if(amp > 0.3){
+          fhGridCellsTimeMod[nModule]->Fill(icol,irow,time);
+          
+          //                                   AliESDCaloCells * cell2 = 0x0; 
+          //                                   if(fCalorimeter == "PHOS") cell2 =  GetReader()->GetInputEvent()->GetPHOSCells();
+          //                                   else                       cell2 = GetReader()->GetInputEvent()->GetEMCALCells();
+          //                                   Int_t icol2    = -1;
+          //                                   Int_t irow2    = -1;
+          //                                   Int_t iRCU2    = -1;
+          //                                   Float_t amp2   =  0.;
+          //                                   Float_t time2  =  0.;
+          //                                   Int_t id2      = -1;
+          //                                   Int_t nModule2 = -1;
+          //                                   for (Int_t iCell2 = 0; iCell2 < ncells; iCell2++) {  
+          //                                           amp2    = cell2->GetAmplitude(iCell2);
+          //                                           if(amp2 < 0.3) continue;
+          //                                           if(iCell2 == iCell) continue;
+          //                                           time2    = cell2->GetTime(iCell2)*1e9;//transform time to ns
+          //                                           //printf("%s: time %g\n",fCalorimeter.Data(), time);
+          //                                           id2      = cell2->GetCellNumber(iCell2);
+          //                                           nModule2 = GetModuleNumberCellIndexes(cell2->GetCellNumber(iCell2), fCalorimeter, icol2, irow2, iRCU2);
+          //                                           Int_t index = (nModule2*fNRCU+iRCU2)+(fNModules*fNRCU)*(iRCU+fNRCU*nModule); 
+          //                                           //printf("id %d, nModule %d, iRCU %d, id2 %d, nModule2 %d, iRCU2 %d, index %d: Histo Name %s\n",id, nModule,iRCU,cell2->GetCellNumber(iCell2),nModule2,iRCU2,index, fhTimeCorrRCU[index]->GetName());
+          //                                           fhTimeCorrRCU[index]->Fill(time,time2); 
+          //                                           
+          //                                   }// second cell loop
+          
+        }// amplitude cut
+      }
+    
     
     //Get Eta-Phi position of Cell
-    //if(fFillAllPosHisto)
+    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);
@@ -1686,10 +1829,12 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
         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());       
+    //  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 
   
@@ -1746,20 +1891,17 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
   fhNCellsPerClusterMIP->Fill(e, nCaloCellsPerCluster,eta);
   
   //Position
-  //if(fFillAllPosHisto)
-  {
-    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);
-  }
+  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);
        
@@ -1862,10 +2004,8 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
     }
     else if(GetReader()->ReadAODMCParticles() && !GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCUnknown)){//it MC AOD and known tag
       //Get the list of MC particles
-      if(!GetReader()->GetAODMCParticles(0))   {
-        printf("AliAnaCalorimeterQA::ClusterHistograms() -  MCParticles not available!\n");
-        abort();
-      }                
+      if(!GetReader()->GetAODMCParticles(0)) 
+        AliFatal("MCParticles not available!");
       
       aodprimary = (AliAODMCParticle*) (GetReader()->GetAODMCParticles(0))->At(label);
       iMother = label;
@@ -2049,9 +2189,7 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
        
   //Match tracks and clusters
   //To be Modified in case of AODs
-       
-  //if(ntracksmatched==1 && trackIndex==-1) ntracksmatched=0;
-       
+               
   if( nTracksMatched > 0){
     if(fFillAllTH12){
       fhECharged      ->Fill(e);       
@@ -2082,54 +2220,53 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
     Int_t nTPC   = 0;
     
     //In case of ESDs get the parameters in this way
-    //         if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
-    if (track->GetOuterParam() ) {
-      okout = kTRUE;
-      
-      bfield = GetReader()->GetInputEvent()->GetMagneticField();
-      okpos = track->GetOuterParam()->GetXYZAt(radius,bfield,emcpos);
-      okmom = track->GetOuterParam()->GetPxPyPzAt(radius,bfield,emcmom);
-      if(!(okpos && okmom)) return;
-      
-      TVector3 position(emcpos[0],emcpos[1],emcpos[2]);
-      TVector3 momentum(emcmom[0],emcmom[1],emcmom[2]);
-      tphi = position.Phi();
-      teta = position.Eta();
-      tmom = momentum.Mag();
-      
-      //Double_t tphi  = track->GetOuterParam()->Phi();
-      //Double_t teta  = track->GetOuterParam()->Eta();
-      //Double_t tmom  = track->GetOuterParam()->P();
-      tpt       = track->Pt();
-      tmom2     = track->P();
-      tpcSignal = track->GetTPCsignal();
-      
-      nITS = track->GetNcls(0);
-      nTPC = track->GetNcls(1);
-    }//Outer param available 
-    //}// ESDs
-    //                 else if(GetReader()->GetDataType()==AliCaloTrackReader::kAOD) {
-    //                         AliAODPid* pid = (AliAODPid*) ((AliAODTrack *) track)->GetDetPid();
-    //                         if (pid) {
-    //                                 okout = kTRUE;
-    //                                 pid->GetEMCALPosition(emcpos);
-    //                                 pid->GetEMCALMomentum(emcmom);  
-    //                                 
-    //                                 TVector3 position(emcpos[0],emcpos[1],emcpos[2]);
-    //                                 TVector3 momentum(emcmom[0],emcmom[1],emcmom[2]);
-    //                                 tphi = position.Phi();
-    //                                 teta = position.Eta();
-    //                                 tmom = momentum.Mag();
-    //                                 
-    //                                 tpt       = ((AliAODTrack*)track)->Pt();
-    //                                 tmom2     = ((AliAODTrack*)track)->P();
-    //                                 tpcSignal = pid->GetTPCsignal();
-    //                         
-    //                                 //nITS = ((AliAODTrack*)track)->GetNcls(0);
-    //                                 //nTPC = ((AliAODTrack*)track)->GetNcls(1);
-    //                         }//Outer param available 
-    //                 }//AODs
-    //                 else return; //Do nothing case not implemented.
+    if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
+      if (track->GetOuterParam() ) {
+        okout = kTRUE;
+        
+        bfield = GetReader()->GetInputEvent()->GetMagneticField();
+        okpos = track->GetOuterParam()->GetXYZAt(radius,bfield,emcpos);
+        okmom = track->GetOuterParam()->GetPxPyPzAt(radius,bfield,emcmom);
+        if(!(okpos && okmom)) return;
+        
+        TVector3 position(emcpos[0],emcpos[1],emcpos[2]);
+        TVector3 momentum(emcmom[0],emcmom[1],emcmom[2]);
+        tphi = position.Phi();
+        teta = position.Eta();
+        tmom = momentum.Mag();
+        
+        //Double_t tphi  = track->GetOuterParam()->Phi();
+        //Double_t teta  = track->GetOuterParam()->Eta();
+        //Double_t tmom  = track->GetOuterParam()->P();
+        tpt       = track->Pt();
+        tmom2     = track->P();
+        tpcSignal = track->GetTPCsignal();
+        
+        nITS = track->GetNcls(0);
+        nTPC = track->GetNcls(1);
+      }//Outer param available 
+    }// ESDs
+    else if(GetReader()->GetDataType()==AliCaloTrackReader::kAOD) {
+      AliAODPid* pid = (AliAODPid*) ((AliAODTrack *) track)->GetDetPid();
+      if (pid) {
+        okout = kTRUE;
+        pid->GetEMCALPosition(emcpos);
+        pid->GetEMCALMomentum(emcmom); 
+        
+        TVector3 position(emcpos[0],emcpos[1],emcpos[2]);
+        TVector3 momentum(emcmom[0],emcmom[1],emcmom[2]);
+        tphi = position.Phi();
+        teta = position.Eta();
+        tmom = momentum.Mag();
+        
+        tpt       = track->Pt();
+        tmom2     = track->P();
+        tpcSignal = pid->GetTPCsignal();
+        
+        //nITS = ((AliAODTrack*)track)->GetNcls(0);
+        //nTPC = ((AliAODTrack*)track)->GetNcls(1);
+      }//pid 
+    }//AODs
                
     if(okout){
       Double_t deta = teta - eta;
@@ -2192,72 +2329,18 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
   
 }// Clusters
 
-//__________________________________
-//void AliAnaCalorimeterQA::CorrelateCalorimeters(TRefArray* refArray){
-//  // Correlate information from PHOS and EMCAL
-//     TRefArray * caloClustersEMCAL = 0;
-//     TRefArray * caloClustersPHOS  = 0;
-//     
-//  // Get once the array of clusters per calorimeter, avoid an extra loop.
-//  if(fCalorimeter == "EMCAL"){ 
-//    caloClustersPHOS = new TRefArray();
-//    GetReader()->GetInputEvent()->GetPHOSClusters(caloClustersPHOS);
-//    caloClustersEMCAL = new TRefArray(*refArray);
-//  }
-//  else if(fCalorimeter == "PHOS") { 
-//    caloClustersEMCAL = new TRefArray();
-//    GetReader()->GetInputEvent()->GetEMCALClusters (caloClustersEMCAL);
-//    caloClustersPHOS = new TRefArray(*refArray);
-//  }
-//  
-//  //Fill histograms with clusters
-//  
-//  fhCaloCorrNClusters->Fill(caloClustersEMCAL->GetEntriesFast(),caloClustersPHOS->GetEntriesFast());
-//  Float_t sumClusterEnergyEMCAL = 0;
-//  Float_t sumClusterEnergyPHOS  = 0;
-//  Int_t iclus = 0;
-//  for(iclus = 0 ; iclus <  caloClustersEMCAL->GetEntriesFast() ; iclus++) 
-//    sumClusterEnergyEMCAL += ((AliVCluster*)caloClustersEMCAL->At(iclus))->E();
-//  for(iclus = 0 ; iclus <  caloClustersPHOS->GetEntriesFast(); iclus++) 
-//    sumClusterEnergyPHOS += ((AliVCluster*)caloClustersPHOS->At(iclus))->E();
-//  fhCaloCorrEClusters->Fill(sumClusterEnergyEMCAL,sumClusterEnergyPHOS);
-//  
-//  //Fill histograms with cells
-//  
-//  AliVCaloCells * cellsEMCAL = GetReader()->GetInputEvent()->GetEMCALCells();
-//  AliVCaloCells * cellsPHOS  = GetReader()->GetInputEvent()->GetPHOSCells();
-//  fhCaloCorrNCells   ->Fill(cellsEMCAL->GetNumberOfCells(),cellsPHOS->GetNumberOfCells());
-//  
-//  Int_t icell = 0;
-//  Float_t sumCellEnergyEMCAL = 0;
-//  Float_t sumCellEnergyPHOS  = 0;
-//  for(icell = 0 ; icell < cellsEMCAL->GetNumberOfCells()  ; icell++) 
-//    sumCellEnergyEMCAL += cellsEMCAL->GetAmplitude(icell);
-//  for(icell = 0 ; icell <  cellsPHOS->GetNumberOfCells(); icell++) 
-//    sumCellEnergyPHOS += cellsPHOS->GetAmplitude(icell);
-//  fhCaloCorrECells->Fill(sumCellEnergyEMCAL,sumCellEnergyPHOS);
-//  if(GetDebug() > 0 ){
-//    printf("AliAnaCalorimeterQA::CorrelateCalorimeters() - ESD: \n");
-//    printf("\t EMCAL: N cells %d, N clusters  %d, summed E cells %f, summed E clusters %f \n",
-//           cellsEMCAL->GetNumberOfCells(),caloClustersEMCAL->GetEntriesFast(),sumCellEnergyEMCAL,sumClusterEnergyEMCAL);
-//    printf("\t PHOS : N cells %d, N clusters  %d, summed E cells %f, summed E clusters %f \n",
-//           cellsPHOS->GetNumberOfCells(),caloClustersPHOS->GetEntriesFast(),sumCellEnergyPHOS,sumClusterEnergyPHOS);
-//  }
-//     
-//     delete caloClustersEMCAL;
-//     delete caloClustersPHOS;
-//     
-//}
 
 //__________________________________
-void AliAnaCalorimeterQA::CorrelateCalorimeters(){
-  // Correlate information from PHOS and EMCAL
+void AliAnaCalorimeterQA::Correlate(){
+  // Correlate information from PHOS and EMCAL and with V0 and track multiplicity
+  //Clusters 
   TObjArray * caloClustersEMCAL = GetAODEMCAL();
   TObjArray * caloClustersPHOS  = GetAODPHOS();
   
-  //Fill histograms with clusters
+  Int_t nclEMCAL = caloClustersEMCAL->GetEntriesFast();
+  Int_t nclPHOS  = caloClustersPHOS ->GetEntriesFast();
   
-  fhCaloCorrNClusters->Fill(caloClustersEMCAL->GetEntriesFast(),caloClustersPHOS->GetEntriesFast());
   Float_t sumClusterEnergyEMCAL = 0;
   Float_t sumClusterEnergyPHOS  = 0;
   Int_t iclus = 0;
@@ -2265,28 +2348,75 @@ void AliAnaCalorimeterQA::CorrelateCalorimeters(){
     sumClusterEnergyEMCAL += ((AliVCluster*)caloClustersEMCAL->At(iclus))->E();
   for(iclus = 0 ; iclus <  caloClustersPHOS->GetEntriesFast(); iclus++) 
     sumClusterEnergyPHOS += ((AliVCluster*)caloClustersPHOS->At(iclus))->E();
-  fhCaloCorrEClusters->Fill(sumClusterEnergyEMCAL,sumClusterEnergyPHOS);
   
-  //Fill histograms with cells
+
+  //Cells
   
   AliVCaloCells * cellsEMCAL = GetEMCALCells();
   AliVCaloCells * cellsPHOS  = GetPHOSCells();
-  fhCaloCorrNCells   ->Fill(cellsEMCAL->GetNumberOfCells(),cellsPHOS->GetNumberOfCells());
+
+  Int_t ncellsEMCAL = cellsEMCAL->GetNumberOfCells();
+  Int_t ncellsPHOS  = cellsPHOS ->GetNumberOfCells();
   
-  Int_t icell = 0;
   Float_t sumCellEnergyEMCAL = 0;
   Float_t sumCellEnergyPHOS  = 0;
+  Int_t icell = 0;
   for(icell = 0 ; icell < cellsEMCAL->GetNumberOfCells()  ; icell++) 
     sumCellEnergyEMCAL += cellsEMCAL->GetAmplitude(icell);
   for(icell = 0 ; icell <  cellsPHOS->GetNumberOfCells(); icell++) 
     sumCellEnergyPHOS += cellsPHOS->GetAmplitude(icell);
-  fhCaloCorrECells->Fill(sumCellEnergyEMCAL,sumCellEnergyPHOS);
-  if(GetDebug() > 0 ){
-    printf("AliAnaCalorimeterQA::CorrelateCalorimeters() - ESD: \n");
+  
+  
+  //Fill Histograms
+  fhCaloCorrNClusters->Fill(nclEMCAL,nclPHOS);
+  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();
+  if(fCalorimeter=="PHOS"){
+    fhCaloV0MCorrNClusters   ->Fill(v0M,nclPHOS);
+    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);
+    fhCaloTrackMCorrECells   ->Fill(trM,sumCellEnergyPHOS);
+  }
+  else{
+    fhCaloV0MCorrNClusters   ->Fill(v0M,nclEMCAL);
+    fhCaloV0MCorrEClusters   ->Fill(v0M,sumClusterEnergyEMCAL);
+    fhCaloV0MCorrNCells      ->Fill(v0M,ncellsEMCAL);
+    fhCaloV0MCorrECells      ->Fill(v0M,sumCellEnergyEMCAL);
+    
+    fhCaloV0SCorrNClusters   ->Fill(v0S,nclEMCAL);
+    fhCaloV0SCorrEClusters   ->Fill(v0S,sumClusterEnergyEMCAL);
+    fhCaloV0SCorrNCells      ->Fill(v0S,ncellsEMCAL);
+    fhCaloV0SCorrECells      ->Fill(v0S,sumCellEnergyEMCAL);
+    
+    fhCaloTrackMCorrNClusters->Fill(trM,nclEMCAL);
+    fhCaloTrackMCorrEClusters->Fill(trM,sumClusterEnergyEMCAL);    
+    fhCaloTrackMCorrNCells   ->Fill(trM,ncellsEMCAL);
+    fhCaloTrackMCorrECells   ->Fill(trM,sumCellEnergyEMCAL);
+  }
+  
+  if(GetDebug() > 0 )
+  {
+    printf("AliAnaCalorimeterQA::Correlate(): \n");
     printf("\t EMCAL: N cells %d, N clusters  %d, summed E cells %f, summed E clusters %f \n",
-           cellsEMCAL->GetNumberOfCells(),caloClustersEMCAL->GetEntriesFast(),sumCellEnergyEMCAL,sumClusterEnergyEMCAL);
+           ncellsEMCAL,nclEMCAL, sumCellEnergyEMCAL,sumClusterEnergyEMCAL);
     printf("\t PHOS : N cells %d, N clusters  %d, summed E cells %f, summed E clusters %f \n",
-           cellsPHOS->GetNumberOfCells(),caloClustersPHOS->GetEntriesFast(),sumCellEnergyPHOS,sumClusterEnergyPHOS);
+           ncellsPHOS,nclPHOS,sumCellEnergyPHOS,sumClusterEnergyPHOS);
+    printf("\t V0 : Signal %d, Multiplicity  %d, Track Multiplicity %d \n", v0S,v0M,trM);
   }
 }
 
@@ -2440,11 +2570,26 @@ void AliAnaCalorimeterQA::ReadHistograms(TList* outputList)
   }
   
   
-  if(fCorrelateCalos){
+  if(fCorrelate){
     fhCaloCorrNClusters = (TH2F *) outputList->At(index++);
     fhCaloCorrEClusters = (TH2F *) outputList->At(index++); 
     fhCaloCorrNCells    = (TH2F *) outputList->At(index++); 
     fhCaloCorrECells    = (TH2F *) outputList->At(index++); 
+    
+    fhCaloV0SCorrNClusters = (TH2F *) outputList->At(index++);
+    fhCaloV0SCorrEClusters = (TH2F *) outputList->At(index++); 
+    fhCaloV0SCorrNCells    = (TH2F *) outputList->At(index++); 
+    fhCaloV0SCorrECells    = (TH2F *) outputList->At(index++); 
+    
+    fhCaloV0MCorrNClusters = (TH2F *) outputList->At(index++);
+    fhCaloV0MCorrEClusters = (TH2F *) outputList->At(index++); 
+    fhCaloV0MCorrNCells    = (TH2F *) outputList->At(index++); 
+    fhCaloV0MCorrECells    = (TH2F *) outputList->At(index++); 
+    
+    fhCaloTrackMCorrNClusters = (TH2F *) outputList->At(index++);
+    fhCaloTrackMCorrEClusters = (TH2F *) outputList->At(index++); 
+    fhCaloTrackMCorrNCells    = (TH2F *) outputList->At(index++); 
+    fhCaloTrackMCorrECells    = (TH2F *) outputList->At(index++); 
   }
   
   //Module histograms
@@ -2634,463 +2779,462 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
 {
   //Do plots if requested      
   
-       if(GetDebug() > 0) printf("AliAnaCalorimeterQA::Terminate() - Make plots for %s? %d\n",fCalorimeter.Data(), fMakePlots);
-       if(!fMakePlots) return;
-       
+  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.   
-       ReadHistograms(outputList);
-       
+  ReadHistograms(outputList);
+  
   //printf(" AliAnaCalorimeterQA::Terminate()  *** %s Report:", GetName()) ; 
   //printf(" AliAnaCalorimeterQA::Terminate()        pt         : %5.3f , RMS : %5.3f \n", fhPt->GetMean(),   fhPt->GetRMS() ) ;
   
   const Int_t buffersize = 255;
-       char name[buffersize];
-       char cname[buffersize];
-       
+  char name[buffersize];
+  char cname[buffersize];
+  
   //In case terminate is executed after the analysis, in a second step, and we want to rebin or to change the range of the histograms for plotting
-       Int_t nptbins     = GetHistoPtBins();           Float_t ptmax     = GetHistoPtMax();           Float_t ptmin     = GetHistoPtMin();
-       Int_t nphibins    = GetHistoPhiBins();          Float_t phimax    = GetHistoPhiMax();          Float_t phimin    = GetHistoPhiMin();
-       Int_t netabins    = GetHistoEtaBins();          Float_t etamax    = GetHistoEtaMax();          Float_t etamin    = GetHistoEtaMin();    
+  Int_t nptbins     = GetHistoPtBins();                Float_t ptmax     = GetHistoPtMax();           Float_t ptmin     = GetHistoPtMin();
+  Int_t nphibins    = GetHistoPhiBins();          Float_t phimax    = GetHistoPhiMax();          Float_t phimin    = GetHistoPhiMin();
+  Int_t netabins    = GetHistoEtaBins();          Float_t etamax    = GetHistoEtaMax();          Float_t etamin    = GetHistoEtaMin(); 
   //   Int_t nmassbins   = GetHistoMassBins();         Float_t massmax   = GetHistoMassMax();         Float_t massmin   = GetHistoMassMin();
   //   Int_t nasymbins   = GetHistoAsymmetryBins();    Float_t asymmax   = GetHistoAsymmetryMax();    Float_t asymmin   = GetHistoAsymmetryMin();
   //   Int_t nPoverEbins = GetHistoPOverEBins();       Float_t pOverEmax = GetHistoPOverEMax();       Float_t pOverEmin = GetHistoPOverEMin();
   //   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 ntimebins   = GetHistoTimeBins();         Float_t timemax   = GetHistoTimeMax();         Float_t timemin   = GetHistoTimeMin();       
+  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(); 
-       Int_t xbins       = GetHistoXBins();            Float_t xmax        = GetHistoXMax();          Float_t xmin      = GetHistoXMin(); 
-       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 rbins       = GetHistoRBins();            Float_t rmax        = GetHistoRMax();          Float_t rmin      = GetHistoRMin(); 
+  Int_t xbins       = GetHistoXBins();            Float_t xmax        = GetHistoXMax();          Float_t xmin      = GetHistoXMin(); 
+  Int_t ybins       = GetHistoYBins();            Float_t ymax        = GetHistoYMax();          Float_t ymin      = GetHistoYMin(); 
+  Int_t zbins       = GetHistoZBins();            Float_t zmax        = GetHistoZMax();          Float_t zmin      = GetHistoZMin(); 
+  
   //Color code for the different modules
-       Int_t modColorIndex[]={2,4,6,8};
-       
+  Int_t modColorIndex[]={2,4,6,8};
+  
   //--------------------------------------------------
   // Cluster energy distributions, module dependence
   //--------------------------------------------------
-       snprintf(cname,buffersize,"QA_%s_ClusterEnergy",fCalorimeter.Data());
-       TCanvas  * c = new TCanvas(cname, "Energy distributions", 800, 400) ;
-       c->Divide(2, 1);
-       Int_t rbE = GetNewRebinForRePlotting((TH1D*)fhE, ptmin, ptmax,nptbins) ;
+  snprintf(cname,buffersize,"QA_%s_ClusterEnergy",fCalorimeter.Data());
+  TCanvas  * c = new TCanvas(cname, "Energy distributions", 800, 400) ;
+  c->Divide(2, 1);
+  Int_t rbE = GetNewRebinForRePlotting((TH1D*)fhE, ptmin, ptmax,nptbins) ;
   //printf("new E rb %d\n",rbE);
-       fhE->Rebin(rbE);
-       fhE->SetAxisRange(ptmin,ptmax,"X");
-       c->cd(1) ; 
-       if(fhE->GetEntries() > 0) gPad->SetLogy();
-       TLegend pLegendE(0.7,0.6,0.9,0.8);
-       pLegendE.SetTextSize(0.03);
-       pLegendE.AddEntry(fhE,"all modules","L");
-       pLegendE.SetFillColor(10);
-       pLegendE.SetBorderSize(1);
-       
-       fhE->SetMinimum(1);     
-       fhE->SetLineColor(1);
-       fhE->Draw("HE");
-       for(Int_t imod = 0; imod < fNModules; imod++){
-               fhEMod[imod]->Rebin(rbE);
-               fhEMod[imod]->SetLineColor(modColorIndex[imod]);
-               fhEMod[imod]->Draw("HE same");
-               pLegendE.AddEntry(fhEMod[imod],Form("module %d",imod),"L");
-       }
-       pLegendE.Draw();
-       
+  fhE->Rebin(rbE);
+  fhE->SetAxisRange(ptmin,ptmax,"X");
+  c->cd(1) ; 
+  if(fhE->GetEntries() > 0) gPad->SetLogy();
+  TLegend pLegendE(0.7,0.6,0.9,0.8);
+  pLegendE.SetTextSize(0.03);
+  pLegendE.AddEntry(fhE,"all modules","L");
+  pLegendE.SetFillColor(10);
+  pLegendE.SetBorderSize(1);
+  
+  fhE->SetMinimum(1);  
+  fhE->SetLineColor(1);
+  fhE->Draw("HE");
+  for(Int_t imod = 0; imod < fNModules; imod++){
+    fhEMod[imod]->Rebin(rbE);
+    fhEMod[imod]->SetLineColor(modColorIndex[imod]);
+    fhEMod[imod]->Draw("HE same");
+    pLegendE.AddEntry(fhEMod[imod],Form("module %d",imod),"L");
+  }
+  pLegendE.Draw();
+  
   //Ratio of modules
-       c->cd(2) ; 
-       TLegend pLegendER(0.55,0.8,0.9,0.9);
-       pLegendER.SetTextSize(0.03);
-       pLegendER.SetFillColor(10);
-       pLegendER.SetBorderSize(1);
-  
-       for(Int_t imod = 1; imod < fNModules; imod++){
-               TH1D * htmp = (TH1D*)fhEMod[imod]->Clone(Form("hERat%d",imod));
-               htmp->Divide(fhEMod[0]);
-               htmp->SetLineColor(modColorIndex[imod]);
-               if(imod==1){
-                       htmp->SetTitle("Ratio module X / module 0");
-                       htmp->SetAxisRange(ptmin,ptmax,"X");
-                       htmp->SetMaximum(5);
-                       htmp->SetMinimum(0);
-                       htmp->SetAxisRange(ptmin,ptmax,"X");
-                       htmp->Draw("HE");
-               }
-               else 
-                       htmp->Draw("same HE");
-               
-               pLegendER.AddEntry(fhEMod[imod],Form("module %d / module 0",imod),"L");
-       }
-       pLegendER.Draw();
-       
-       snprintf(name,buffersize,"QA_%s_ClusterEnergy.eps",fCalorimeter.Data());
-       c->Print(name); printf("Plot: %s\n",name);
-       
+  c->cd(2) ; 
+  TLegend pLegendER(0.55,0.8,0.9,0.9);
+  pLegendER.SetTextSize(0.03);
+  pLegendER.SetFillColor(10);
+  pLegendER.SetBorderSize(1);
+  
+  for(Int_t imod = 1; imod < fNModules; imod++){
+    TH1D * htmp = (TH1D*)fhEMod[imod]->Clone(Form("hERat%d",imod));
+    htmp->Divide(fhEMod[0]);
+    htmp->SetLineColor(modColorIndex[imod]);
+    if(imod==1){
+      htmp->SetTitle("Ratio module X / module 0");
+      htmp->SetAxisRange(ptmin,ptmax,"X");
+      htmp->SetMaximum(5);
+      htmp->SetMinimum(0);
+      htmp->SetAxisRange(ptmin,ptmax,"X");
+      htmp->Draw("HE");
+    }
+    else 
+      htmp->Draw("same HE");
+    
+    pLegendER.AddEntry(fhEMod[imod],Form("module %d / module 0",imod),"L");
+  }
+  pLegendER.Draw();
+  
+  snprintf(name,buffersize,"QA_%s_ClusterEnergy.eps",fCalorimeter.Data());
+  c->Print(name); printf("Plot: %s\n",name);
+  
   //--------------------------------------------------
   // Cell energy distributions, module dependence
   //--------------------------------------------------
-       snprintf(cname,buffersize,"%s_QA_CellEnergy",fCalorimeter.Data());
-       TCanvas  * ca = new TCanvas(cname, "Cell Energy distributions", 800, 400) ;
-       ca->Divide(2, 1);
-       
-       Int_t rbAmp = GetNewRebinForRePlotting((TH1D*)fhAmplitude, ptmin, ptmax,nptbins*2) ;
+  snprintf(cname,buffersize,"%s_QA_CellEnergy",fCalorimeter.Data());
+  TCanvas  * ca = new TCanvas(cname, "Cell Energy distributions", 800, 400) ;
+  ca->Divide(2, 1);
+  
+  Int_t rbAmp = GetNewRebinForRePlotting((TH1D*)fhAmplitude, ptmin, ptmax,nptbins*2) ;
   //printf("new Amp rb %d\n",rbAmp);
-       fhAmplitude->Rebin(rbAmp);
-       fhAmplitude->SetAxisRange(ptmin,ptmax,"X");
-       
-       ca->cd(1) ; 
-       if(fhAmplitude->GetEntries() > 0) gPad->SetLogy();
-       TLegend pLegendA(0.7,0.6,0.9,0.8);
-       pLegendA.SetTextSize(0.03);
-       pLegendA.AddEntry(fhE,"all modules","L");
-       pLegendA.SetFillColor(10);
-       pLegendA.SetBorderSize(1);
-       fhAmplitude->SetMinimum(0.1);
-       fhAmplitude->SetLineColor(1);
-       fhAmplitude->Draw("HE");
-       
-       for(Int_t imod = 0; imod < fNModules; imod++){
-               fhAmplitudeMod[imod]->Rebin(rbAmp);
-               fhAmplitudeMod[imod]->SetLineColor(modColorIndex[imod]);
-               fhAmplitudeMod[imod]->Draw("HE same");
-               pLegendA.AddEntry(fhAmplitudeMod[imod],Form("module %d",imod),"L");
-       }
-       pLegendA.Draw();
-       
-       
-       ca->cd(2) ; 
-       TLegend pLegendAR(0.55,0.8,0.9,0.9);
-       pLegendAR.SetTextSize(0.03);
-       pLegendAR.SetFillColor(10);
-       pLegendAR.SetBorderSize(1);
-       
-       for(Int_t imod = 1; imod < fNModules; imod++){
-               TH1D * htmp = (TH1D*)fhAmplitudeMod[imod]->Clone(Form("hAmpRat%d",imod));
-               htmp->Divide(fhAmplitudeMod[0]);
-               htmp->SetLineColor(modColorIndex[imod]);
-               if(imod==1){
-                       htmp->SetTitle("Ratio cells energy in  module X / module 0");
-                       htmp->SetAxisRange(ptmin,ptmax,"X");
-                       htmp->SetMaximum(5);
-                       htmp->SetMinimum(0);
-                       htmp->Draw("HE");
-               }
-               else 
-                       htmp->Draw("same HE");
-               pLegendAR.AddEntry(fhAmplitudeMod[imod],Form("module %d",imod),"L");
-       }
-       
-       pLegendAR.Draw();
-       snprintf(name,buffersize,"QA_%s_CellEnergy.eps",fCalorimeter.Data());
-       ca->Print(name); printf("Plot: %s\n",name);     
+  fhAmplitude->Rebin(rbAmp);
+  fhAmplitude->SetAxisRange(ptmin,ptmax,"X");
+  
+  ca->cd(1) ; 
+  if(fhAmplitude->GetEntries() > 0) gPad->SetLogy();
+  TLegend pLegendA(0.7,0.6,0.9,0.8);
+  pLegendA.SetTextSize(0.03);
+  pLegendA.AddEntry(fhE,"all modules","L");
+  pLegendA.SetFillColor(10);
+  pLegendA.SetBorderSize(1);
+  fhAmplitude->SetMinimum(0.1);
+  fhAmplitude->SetLineColor(1);
+  fhAmplitude->Draw("HE");
+  
+  for(Int_t imod = 0; imod < fNModules; imod++){
+    fhAmplitudeMod[imod]->Rebin(rbAmp);
+    fhAmplitudeMod[imod]->SetLineColor(modColorIndex[imod]);
+    fhAmplitudeMod[imod]->Draw("HE same");
+    pLegendA.AddEntry(fhAmplitudeMod[imod],Form("module %d",imod),"L");
+  }
+  pLegendA.Draw();
+  
+  
+  ca->cd(2) ; 
+  TLegend pLegendAR(0.55,0.8,0.9,0.9);
+  pLegendAR.SetTextSize(0.03);
+  pLegendAR.SetFillColor(10);
+  pLegendAR.SetBorderSize(1);
+  
+  for(Int_t imod = 1; imod < fNModules; imod++){
+    TH1D * htmp = (TH1D*)fhAmplitudeMod[imod]->Clone(Form("hAmpRat%d",imod));
+    htmp->Divide(fhAmplitudeMod[0]);
+    htmp->SetLineColor(modColorIndex[imod]);
+    if(imod==1){
+      htmp->SetTitle("Ratio cells energy in  module X / module 0");
+      htmp->SetAxisRange(ptmin,ptmax,"X");
+      htmp->SetMaximum(5);
+      htmp->SetMinimum(0);
+      htmp->Draw("HE");
+    }
+    else 
+      htmp->Draw("same HE");
+    pLegendAR.AddEntry(fhAmplitudeMod[imod],Form("module %d",imod),"L");
+  }
+  
+  pLegendAR.Draw();
+  snprintf(name,buffersize,"QA_%s_CellEnergy.eps",fCalorimeter.Data());
+  ca->Print(name); printf("Plot: %s\n",name);  
   
   //----------------------------------------------------------
   // Cell energy distributions, FRACTION of module dependence
   // See Super Module calibration difference
   //---------------------------------------------------------  
-       if(fCalorimeter=="EMCAL"){
+  if(fCalorimeter=="EMCAL"){
     //Close To Eta 0 
-               snprintf(cname,buffersize,"%s_QA_SMThirds",fCalorimeter.Data());
-               TCanvas  * cfrac = new TCanvas(cname, "SM Thirds ratios", 800, 1200) ;
-               cfrac->Divide(2, 3);
-               cfrac->cd(1) ; 
-               if(fhAmplitude->GetEntries() > 0) 
-                       gPad->SetLogy();
-               TLegend pLegend1(0.6,0.6,0.9,0.8);
-               pLegend1.SetTextSize(0.03);
-               pLegend1.SetFillColor(10);
-               pLegend1.SetBorderSize(1);
-               pLegend1.SetHeader("Third close to Eta=0");
-               fhAmplitudeModFraction[0]->SetTitle("Third close to Eta=0");
-               fhAmplitudeModFraction[0]->SetAxisRange(ptmin,ptmax,"X");
-               fhAmplitudeModFraction[0]->Draw("axis");
-               TH1D * hAverageThird1 = (TH1D *)fhAmplitudeModFraction[3*0+2]->Clone("AverageThird1");
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       Int_t ifrac = 0;
-                       if(imod%2==0) ifrac = 2;
-                       if(imod > 0) hAverageThird1->Add( fhAmplitudeModFraction[3*imod+ifrac]);
-                       fhAmplitudeModFraction[3*imod+ifrac]->SetLineColor(modColorIndex[imod]);
-                       fhAmplitudeModFraction[3*imod+ifrac]->Draw("HE same");
-                       pLegend1.AddEntry(fhAmplitudeModFraction[3*imod+ifrac],Form("super module %d",imod),"L");
-               }
-               hAverageThird1 ->Scale(1./fNModules);
-               pLegend1.Draw();
+    snprintf(cname,buffersize,"%s_QA_SMThirds",fCalorimeter.Data());
+    TCanvas  * cfrac = new TCanvas(cname, "SM Thirds ratios", 800, 1200) ;
+    cfrac->Divide(2, 3);
+    cfrac->cd(1) ; 
+    if(fhAmplitude->GetEntries() > 0) 
+      gPad->SetLogy();
+    TLegend pLegend1(0.6,0.6,0.9,0.8);
+    pLegend1.SetTextSize(0.03);
+    pLegend1.SetFillColor(10);
+    pLegend1.SetBorderSize(1);
+    pLegend1.SetHeader("Third close to Eta=0");
+    fhAmplitudeModFraction[0]->SetTitle("Third close to Eta=0");
+    fhAmplitudeModFraction[0]->SetAxisRange(ptmin,ptmax,"X");
+    fhAmplitudeModFraction[0]->Draw("axis");
+    TH1D * hAverageThird1 = (TH1D *)fhAmplitudeModFraction[3*0+2]->Clone("AverageThird1");
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      Int_t ifrac = 0;
+      if(imod%2==0) ifrac = 2;
+      if(imod > 0) hAverageThird1->Add( fhAmplitudeModFraction[3*imod+ifrac]);
+      fhAmplitudeModFraction[3*imod+ifrac]->SetLineColor(modColorIndex[imod]);
+      fhAmplitudeModFraction[3*imod+ifrac]->Draw("HE same");
+      pLegend1.AddEntry(fhAmplitudeModFraction[3*imod+ifrac],Form("super module %d",imod),"L");
+    }
+    hAverageThird1 ->Scale(1./fNModules);
+    pLegend1.Draw();
     //Ratio
-               cfrac->cd(2) ; 
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       Int_t ifrac = 0;
-                       if(imod%2==0) ifrac = 2;
-                       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");
-                       }
-                       else htmp -> Draw("same HE");
-               }
+    cfrac->cd(2) ; 
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      Int_t ifrac = 0;
+      if(imod%2==0) ifrac = 2;
+      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");
+      }
+      else htmp -> Draw("same HE");
+    }
     //pLegend1.Draw();
-               
+    
     //Middle Eta
-               cfrac->cd(3) ; 
-               if(fhAmplitude->GetEntries() > 0) 
-                       gPad->SetLogy();
-               TLegend pLegend2(0.6,0.6,0.9,0.8);
-               pLegend2.SetTextSize(0.03);
-               pLegend2.SetFillColor(10);
-               pLegend2.SetBorderSize(1);
-               pLegend2.SetHeader("Middle Third");
-               
-               fhAmplitudeModFraction[0]->SetTitle("Middle Third");
-               fhAmplitudeModFraction[0]->SetAxisRange(ptmin,ptmax,"X");
-               fhAmplitudeModFraction[0]->Draw("axis");
-               
-               TH1D * hAverageThird2 = (TH1D *)fhAmplitudeModFraction[3*0+1]->Clone("AverageThird2");
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       Int_t ifrac = 1;
-                       if(imod > 0) hAverageThird2->Add( fhAmplitudeModFraction[3*imod+ifrac]);
-                       fhAmplitudeModFraction[3*imod+ifrac]->SetLineColor(modColorIndex[imod]);
-                       fhAmplitudeModFraction[3*imod+ifrac]->Draw("HE same");
-                       pLegend2.AddEntry(fhAmplitudeModFraction[3*imod+ifrac],Form("super module %d",imod),"L");
-               }
-               hAverageThird2->Scale(1./fNModules);
-               pLegend2.Draw();
-               
+    cfrac->cd(3) ; 
+    if(fhAmplitude->GetEntries() > 0) 
+      gPad->SetLogy();
+    TLegend pLegend2(0.6,0.6,0.9,0.8);
+    pLegend2.SetTextSize(0.03);
+    pLegend2.SetFillColor(10);
+    pLegend2.SetBorderSize(1);
+    pLegend2.SetHeader("Middle Third");
+    
+    fhAmplitudeModFraction[0]->SetTitle("Middle Third");
+    fhAmplitudeModFraction[0]->SetAxisRange(ptmin,ptmax,"X");
+    fhAmplitudeModFraction[0]->Draw("axis");
+    
+    TH1D * hAverageThird2 = (TH1D *)fhAmplitudeModFraction[3*0+1]->Clone("AverageThird2");
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      Int_t ifrac = 1;
+      if(imod > 0) hAverageThird2->Add( fhAmplitudeModFraction[3*imod+ifrac]);
+      fhAmplitudeModFraction[3*imod+ifrac]->SetLineColor(modColorIndex[imod]);
+      fhAmplitudeModFraction[3*imod+ifrac]->Draw("HE same");
+      pLegend2.AddEntry(fhAmplitudeModFraction[3*imod+ifrac],Form("super module %d",imod),"L");
+    }
+    hAverageThird2->Scale(1./fNModules);
+    pLegend2.Draw();
+    
     //Ratio
-               cfrac->cd(4) ; 
-               
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       Int_t ifrac = 1;
-                       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");
-                       }
-                       else htmp -> Draw("same HE");
-               }
+    cfrac->cd(4) ; 
+    
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      Int_t ifrac = 1;
+      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");
+      }
+      else htmp -> Draw("same HE");
+    }
     //pLegend2.Draw();
-               
+    
     //Close To Eta 0.7 
-               cfrac->cd(5) ; 
-               if(fhAmplitude->GetEntries() > 0) 
-                       gPad->SetLogy();
-               TLegend pLegend3(0.6,0.6,0.9,0.8);
-               pLegend3.SetTextSize(0.03);
-               pLegend3.SetFillColor(10);
-               pLegend3.SetBorderSize(1);
-               pLegend3.SetHeader("Third close to Eta=0.7");
-               
-               fhAmplitudeModFraction[0]->SetTitle("Third close to Eta=0.7");
-               fhAmplitudeModFraction[0]->SetAxisRange(ptmin,ptmax,"X");
-               fhAmplitudeModFraction[0]->Draw("axis");
-               
-               TH1D * hAverageThird3 = (TH1D *)fhAmplitudeModFraction[3*0+0]->Clone("AverageThird3");
-               for(Int_t imod = 0; imod < 4; imod++){
-                       Int_t ifrac = 2;
-                       if(imod%2==0) ifrac = 0;
-                       if(imod > 0) hAverageThird3->Add( fhAmplitudeModFraction[3*imod+ifrac]);
-                       fhAmplitudeModFraction[3*imod+ifrac]->SetLineColor(modColorIndex[imod]);
-                       fhAmplitudeModFraction[3*imod+ifrac]->Draw("HE same");
-                       pLegend3.AddEntry(fhAmplitudeModFraction[3*imod+ifrac],Form("super module %d",imod),"L");
-               }
-               hAverageThird3 ->Scale(1./fNModules);
-               pLegend3.Draw();
-               
-               cfrac->cd(6) ; 
-               
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       Int_t ifrac = 2;
-                       if(imod%2==0) ifrac = 0;
-                       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");
-                       }
-                       else htmp ->Draw("same HE");
-               }
+    cfrac->cd(5) ; 
+    if(fhAmplitude->GetEntries() > 0) 
+      gPad->SetLogy();
+    TLegend pLegend3(0.6,0.6,0.9,0.8);
+    pLegend3.SetTextSize(0.03);
+    pLegend3.SetFillColor(10);
+    pLegend3.SetBorderSize(1);
+    pLegend3.SetHeader("Third close to Eta=0.7");
+    
+    fhAmplitudeModFraction[0]->SetTitle("Third close to Eta=0.7");
+    fhAmplitudeModFraction[0]->SetAxisRange(ptmin,ptmax,"X");
+    fhAmplitudeModFraction[0]->Draw("axis");
+    
+    TH1D * hAverageThird3 = (TH1D *)fhAmplitudeModFraction[3*0+0]->Clone("AverageThird3");
+    for(Int_t imod = 0; imod < 4; imod++){
+      Int_t ifrac = 2;
+      if(imod%2==0) ifrac = 0;
+      if(imod > 0) hAverageThird3->Add( fhAmplitudeModFraction[3*imod+ifrac]);
+      fhAmplitudeModFraction[3*imod+ifrac]->SetLineColor(modColorIndex[imod]);
+      fhAmplitudeModFraction[3*imod+ifrac]->Draw("HE same");
+      pLegend3.AddEntry(fhAmplitudeModFraction[3*imod+ifrac],Form("super module %d",imod),"L");
+    }
+    hAverageThird3 ->Scale(1./fNModules);
+    pLegend3.Draw();
+    
+    cfrac->cd(6) ; 
+    
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      Int_t ifrac = 2;
+      if(imod%2==0) ifrac = 0;
+      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");
+      }
+      else htmp ->Draw("same HE");
+    }
     //pLegend3.Draw();
-               
-               snprintf(name,buffersize,"QA_%s_CellEnergyModuleFraction.eps",fCalorimeter.Data());
-               cfrac->Print(name); printf("Create plot %s\n",name);
-       }//EMCAL        
-       
-       
+    
+    snprintf(name,buffersize,"QA_%s_CellEnergyModuleFraction.eps",fCalorimeter.Data());
+    cfrac->Print(name); printf("Create plot %s\n",name);
+  }//EMCAL     
+  
+  
   //----------------------------------------------------------
   // Cluster eta and phi distributions, energy cut dependence
   //---------------------------------------------------------  
-       
-       snprintf(cname,buffersize,"%s_QA_EtaPhiCluster",fCalorimeter.Data());
-       TCanvas  * cetaphic = new TCanvas(cname, "Eta-Phi Reconstructed distributions", 1200, 400) ;
-       cetaphic->Divide(3, 1);
-       Int_t binmin = 0;
-       Int_t rbPhi  = 1;
-       Int_t rbEta  = 1;
-       Int_t ncuts  = 7;
-       Float_t ecut[]     = {0.1, 0.3, 0.5, 0.7, 0.9, 1.1, 1.3};
-       Int_t   ecutcolor[]= {2, 4, 6, 7, 8, 9, 12};
-       TH1D * hE = fhEtaPhiE->ProjectionZ();
-       
+  
+  snprintf(cname,buffersize,"%s_QA_EtaPhiCluster",fCalorimeter.Data());
+  TCanvas  * cetaphic = new TCanvas(cname, "Eta-Phi Reconstructed distributions", 1200, 400) ;
+  cetaphic->Divide(3, 1);
+  Int_t binmin = 0;
+  Int_t rbPhi  = 1;
+  Int_t rbEta  = 1;
+  Int_t ncuts  = 7;
+  Float_t ecut[]     = {0.1, 0.3, 0.5, 0.7, 0.9, 1.1, 1.3};
+  Int_t   ecutcolor[]= {2, 4, 6, 7, 8, 9, 12};
+  TH1D * hE = fhEtaPhiE->ProjectionZ();
+  
   //PHI
-       cetaphic->cd(1) ; 
-       gPad->SetLogy();
-       gPad->SetGridy();
-       
-       TLegend pLegendPhiCl(0.83,0.6,0.95,0.93);
-       pLegendPhiCl.SetTextSize(0.03);
-       pLegendPhiCl.SetFillColor(10);
-       pLegendPhiCl.SetBorderSize(1);
-       
-       TH1D * htmp = fhEtaPhiE->ProjectionY("hphi_cluster_nocut",0,-1,0,-1);
-       if(htmp){
-         htmp->SetMinimum(1);
-         rbPhi =  GetNewRebinForRePlotting(htmp, phimin, phimax,nphibins) ;
+  cetaphic->cd(1) ; 
+  gPad->SetLogy();
+  gPad->SetGridy();
+  
+  TLegend pLegendPhiCl(0.83,0.6,0.95,0.93);
+  pLegendPhiCl.SetTextSize(0.03);
+  pLegendPhiCl.SetFillColor(10);
+  pLegendPhiCl.SetBorderSize(1);
+  
+  TH1D * htmp = fhEtaPhiE->ProjectionY("hphi_cluster_nocut",0,-1,0,-1);
+  if(htmp){
+    htmp->SetMinimum(1);
+    rbPhi =  GetNewRebinForRePlotting(htmp, phimin, phimax,nphibins) ;
     //printf("new Phi rb %d\n",rbPhi);
-         htmp->Rebin(rbPhi);
-         htmp->SetTitle("#phi of clusters for energy in cluster > threshold");
-         htmp->SetAxisRange(phimin,phimax,"X");
-         htmp->Draw("HE");
-         pLegendPhiCl.AddEntry(htmp,"No cut","L");
-    
-         for (Int_t i = 0; i < ncuts; i++) {
-           binmin =  hE->FindBin(ecut[i]);
+    htmp->Rebin(rbPhi);
+    htmp->SetTitle("#phi of clusters for energy in cluster > threshold");
+    htmp->SetAxisRange(phimin,phimax,"X");
+    htmp->Draw("HE");
+    pLegendPhiCl.AddEntry(htmp,"No cut","L");
+    
+    for (Int_t i = 0; i < ncuts; i++) {
+      binmin =  hE->FindBin(ecut[i]);
       //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
-           htmp = fhEtaPhiE->ProjectionY(Form("hphi_cluster_cut%d",i),0,-1,binmin,-1);
-           htmp->SetLineColor(ecutcolor[i]);
-           htmp->Rebin(rbPhi);
-           htmp->Draw("same HE");
-           pLegendPhiCl.AddEntry(htmp,Form("E>%1.1f",ecut[i]),"L");
-           
-         }
-       }
-       pLegendPhiCl.Draw();
-       
-       //ETA
-       cetaphic->cd(2) ; 
-       gPad->SetLogy();
-       gPad->SetGridy();
-  
-       delete htmp; 
-       htmp = fhEtaPhiE->ProjectionX("heta_cluster_nocut",0,-1,0,-1);
-       htmp ->SetLineColor(1);
-       rbEta =  GetNewRebinForRePlotting(htmp,etamin, etamax,netabins) ;
-  //printf("new Eta rb %d\n",rbEta);
-       if(htmp){
-         htmp->Rebin(rbEta);
-         htmp->SetMinimum(1);
-         htmp->SetTitle("#eta of clusters for energy in cluster > threshold");
-         htmp->SetAxisRange(etamin,etamax,"X");
-         htmp->Draw("HE");
-         
-         for (Int_t i = 0; i < ncuts; i++) {
-           binmin =  hE->FindBin(ecut[i]);
+      htmp = fhEtaPhiE->ProjectionY(Form("hphi_cluster_cut%d",i),0,-1,binmin,-1);
+      htmp->SetLineColor(ecutcolor[i]);
+      htmp->Rebin(rbPhi);
+      htmp->Draw("same HE");
+      pLegendPhiCl.AddEntry(htmp,Form("E>%1.1f",ecut[i]),"L");
+      
+    }
+  }
+  pLegendPhiCl.Draw();
+  
+  //ETA
+  cetaphic->cd(2) ; 
+  gPad->SetLogy();
+  gPad->SetGridy();
+  
+  delete htmp; 
+  htmp = fhEtaPhiE->ProjectionX("heta_cluster_nocut",0,-1,0,-1);
+  if(htmp){
+    rbEta =  GetNewRebinForRePlotting(htmp,etamin, etamax,netabins) ;
+    //printf("new Eta rb %d\n",rbEta);
+    htmp->Rebin(rbEta);
+    htmp->SetMinimum(1);
+    htmp ->SetLineColor(1);
+    htmp->SetTitle("#eta of clusters for energy in cluster > threshold");
+    htmp->SetAxisRange(etamin,etamax,"X");
+    htmp->Draw("HE");
+    
+    for (Int_t i = 0; i < ncuts; i++) {
+      binmin =  hE->FindBin(ecut[i]);
       //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
-           htmp = fhEtaPhiE->ProjectionX(Form("heta_cluster_cut%d",i),0,-1,binmin,-1);
-           htmp->SetLineColor(ecutcolor[i]);
-           htmp->Rebin(rbEta);
-           htmp->Draw("same HE");      
-         }
-       }
+      htmp = fhEtaPhiE->ProjectionX(Form("heta_cluster_cut%d",i),0,-1,binmin,-1);
+      htmp->SetLineColor(ecutcolor[i]);
+      htmp->Rebin(rbEta);
+      htmp->Draw("same HE");   
+    }
+  }
   //ETA vs PHI 
-       cetaphic->cd(3) ;
-       TH2D* hEtaPhiCl = (TH2D*) fhEtaPhiE->Project3D("xy");
-       hEtaPhiCl->SetAxisRange(etamin,etamax,"X");
-       hEtaPhiCl->SetAxisRange(phimin,phimax,"Y");
-       hEtaPhiCl->Draw("colz");
+  cetaphic->cd(3) ;
+  TH2D* hEtaPhiCl = (TH2D*) fhEtaPhiE->Project3D("xy");
+  hEtaPhiCl->SetAxisRange(etamin,etamax,"X");
+  hEtaPhiCl->SetAxisRange(phimin,phimax,"Y");
+  hEtaPhiCl->Draw("colz");
   
-       snprintf(name,buffersize,"QA_%s_ClusterEtaPhi.eps",fCalorimeter.Data());
-       cetaphic->Print(name); printf("Create plot %s\n",name);
+  snprintf(name,buffersize,"QA_%s_ClusterEtaPhi.eps",fCalorimeter.Data());
+  cetaphic->Print(name); printf("Create plot %s\n",name);
   
   //----------------------------------------------------------
   // Cell eta and phi distributions, energy cut dependence
   //---------------------------------------------------------  
        
-       snprintf(cname,buffersize,"%s_QA_EtaPhiCell",fCalorimeter.Data());
-       TCanvas  * cetaphicell = new TCanvas(cname, "Eta-Phi Cells distributions", 1200, 400) ;
-       cetaphicell->Divide(3, 1);
-       
+  snprintf(cname,buffersize,"%s_QA_EtaPhiCell",fCalorimeter.Data());
+  TCanvas  * cetaphicell = new TCanvas(cname, "Eta-Phi Cells distributions", 1200, 400) ;
+  cetaphicell->Divide(3, 1);
+  
   //PHI
-       cetaphicell->cd(1) ; 
-       gPad->SetLogy();
-       gPad->SetGridy();
-       
-       TLegend pLegendPhiCell(0.83,0.6,0.95,0.93);
-       pLegendPhiCell.SetTextSize(0.03);
-       pLegendPhiCell.SetFillColor(10);
-       pLegendPhiCell.SetBorderSize(1);
-  
-       delete htmp; 
-       htmp = fhEtaPhiAmp->ProjectionY("hphi_cell_nocut",0,-1,0,-1);
-       if(htmp){
-         htmp->SetMinimum(1);
-         htmp->Rebin(rbPhi);
-         htmp->SetTitle("#phi of cells for cell energy > threshold");
-         htmp->SetAxisRange(phimin,phimax,"X");
-         htmp->Draw("HE");
-         pLegendPhiCell.AddEntry(htmp,"No cut","L");
-         
-         for (Int_t i = 0; i < ncuts; i++) {
-           binmin =  hE->FindBin(ecut[i]);
+  cetaphicell->cd(1) ; 
+  gPad->SetLogy();
+  gPad->SetGridy();
+  
+  TLegend pLegendPhiCell(0.83,0.6,0.95,0.93);
+  pLegendPhiCell.SetTextSize(0.03);
+  pLegendPhiCell.SetFillColor(10);
+  pLegendPhiCell.SetBorderSize(1);
+  
+  delete htmp; 
+  htmp = fhEtaPhiAmp->ProjectionY("hphi_cell_nocut",0,-1,0,-1);
+  if(htmp){
+    htmp->SetMinimum(1);
+    htmp->Rebin(rbPhi);
+    htmp->SetTitle("#phi of cells for cell energy > threshold");
+    htmp->SetAxisRange(phimin,phimax,"X");
+    htmp->Draw("HE");
+    pLegendPhiCell.AddEntry(htmp,"No cut","L");
+    
+    for (Int_t i = 0; i < ncuts; i++) {
+      binmin =  hE->FindBin(ecut[i]);
       //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
-           htmp = fhEtaPhiAmp->ProjectionY(Form("hphi_cell_cut%d",i),0,-1,binmin,-1);
-           htmp->SetLineColor(ecutcolor[i]);
-           htmp->Rebin(rbPhi);
-           htmp->Draw("same HE");
-           pLegendPhiCl.AddEntry(htmp,Form("E>%1.1f",ecut[i]),"L");
-           
-         }
-       }
-       pLegendPhiCell.Draw();
-       
+      htmp = fhEtaPhiAmp->ProjectionY(Form("hphi_cell_cut%d",i),0,-1,binmin,-1);
+      htmp->SetLineColor(ecutcolor[i]);
+      htmp->Rebin(rbPhi);
+      htmp->Draw("same HE");
+      pLegendPhiCl.AddEntry(htmp,Form("E>%1.1f",ecut[i]),"L");
+      
+    }
+  }
+  pLegendPhiCell.Draw();
+  
   //ETA
-       cetaphicell->cd(2) ; 
-       gPad->SetLogy();
-       gPad->SetGridy();
-  
-       delete htmp; 
-       htmp = fhEtaPhiAmp->ProjectionX("heta_cell_nocut",0,-1,0,-1);
-       if(htmp){
-         htmp ->SetLineColor(1);
-         htmp->Rebin(rbEta);
-         htmp->SetMinimum(1);
-         htmp->SetTitle("#eta of cells for cell energy > threshold");
-         htmp->SetAxisRange(etamin,etamax,"X");
-         htmp->Draw("HE");
-         
-         for (Int_t i = 0; i < ncuts; i++) {
-           binmin =  hE->FindBin(ecut[i]);
+  cetaphicell->cd(2) ; 
+  gPad->SetLogy();
+  gPad->SetGridy();
+  
+  delete htmp; 
+  htmp = fhEtaPhiAmp->ProjectionX("heta_cell_nocut",0,-1,0,-1);
+  if(htmp){
+    htmp ->SetLineColor(1);
+    htmp->Rebin(rbEta);
+    htmp->SetMinimum(1);
+    htmp->SetTitle("#eta of cells for cell energy > threshold");
+    htmp->SetAxisRange(etamin,etamax,"X");
+    htmp->Draw("HE");
+    
+    for (Int_t i = 0; i < ncuts; i++) {
+      binmin =  hE->FindBin(ecut[i]);
       //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
-           htmp = fhEtaPhiAmp->ProjectionX(Form("heta_cell_cut%d",i),0,-1,binmin,-1);
-           htmp->SetLineColor(ecutcolor[i]);
-           htmp->Rebin(rbEta);
-           htmp->Draw("same HE");
-           
-         }
-       }
+      htmp = fhEtaPhiAmp->ProjectionX(Form("heta_cell_cut%d",i),0,-1,binmin,-1);
+      htmp->SetLineColor(ecutcolor[i]);
+      htmp->Rebin(rbEta);
+      htmp->Draw("same HE");
+      
+    }
+  }
   //ETA vs PHI 
-       cetaphicell->cd(3) ;
-       TH2D* hEtaPhiCell = (TH2D*) fhEtaPhiAmp->Project3D("xy");
-       hEtaPhiCell->SetAxisRange(etamin,etamax,"X");
-       hEtaPhiCell->SetAxisRange(phimin,phimax,"Y");
-       hEtaPhiCell->Draw("colz");
-       
-       snprintf(name,buffersize,"QA_%s_CellEtaPhi.eps",fCalorimeter.Data());
-       cetaphicell->Print(name); printf("Create plot %s\n",name);
-       
+  cetaphicell->cd(3) ;
+  TH2D* hEtaPhiCell = (TH2D*) fhEtaPhiAmp->Project3D("xy");
+  hEtaPhiCell->SetAxisRange(etamin,etamax,"X");
+  hEtaPhiCell->SetAxisRange(phimin,phimax,"Y");
+  hEtaPhiCell->Draw("colz");
+  
+  snprintf(name,buffersize,"QA_%s_CellEtaPhi.eps",fCalorimeter.Data());
+  cetaphicell->Print(name); printf("Create plot %s\n",name);
+  
   
   ////////////////////////////////////////        
   ///////// Global Positions /////////////       
@@ -3100,7 +3244,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
   Int_t rbX = 1;
   Int_t rbY = 1;
   Int_t rbZ = 1;
-  //if(fFillAllPosHisto)
+  if(fFillAllPosHisto)
   {
     snprintf(cname,buffersize,"%s_QA_ClusterXY",fCalorimeter.Data());
     TCanvas  * cxyz = new TCanvas(cname, "Cluster XY distributions", 1200, 400) ;
@@ -3802,7 +3946,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     snprintf(name,buffersize,"QA_%s_DeltaClusterCellX_Y_Z_R_NCellsCut.eps",fCalorimeter.Data());
     cxdn->Print(name); printf("Create plot %s\n",name);
     
-       }
+  }
   
   //----------------------------------------------------------
   //Reconstructed clusters energy-eta-phi distributions, matched with tracks
@@ -3811,7 +3955,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
   TH1F *       hPtChargedClone  = 0 ;
   TH1F *       hEtaChargedClone = 0 ;
   TH1F *       hPhiChargedClone = 0 ;
-       if(fFillAllTH12){
+  if(fFillAllTH12){
     hEChargedClone   = (TH1F*)   fhECharged->Clone(Form("%sClone",fhECharged->GetName()));
     hPtChargedClone  = (TH1F*)   fhPtCharged->Clone(Form("%sClone",fhPtCharged->GetName()));
     hEtaChargedClone = (TH1F*)   fhEtaCharged->Clone(Form("%sClone",fhEtaCharged->GetName()));
@@ -3884,165 +4028,165 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     
     snprintf(name,buffersize,"QA_%s_ClustersMatchedToAllRatios.eps",fCalorimeter.Data());
     ccharge->Print(name); printf("Create plot %s\n",name);
-       }
+  }
   //-------------------------------------------        
   // N Cells - N Clusters - N Cells per cluster
   //-------------------------------------------
-       snprintf(cname,buffersize,"QA_%s_nclustercells",fCalorimeter.Data());
-       TCanvas  * cN = new TCanvas(cname, " Number of CaloClusters and CaloCells", 800, 1200) ;
-       cN->Divide(2, 3);
-       
-       cN->cd(1) ; 
-       
-       TLegend pLegendN(0.7,0.6,0.9,0.8);
-       pLegendN.SetTextSize(0.03);
-       pLegendN.AddEntry(fhNClusters,"all modules","L");
-       pLegendN.SetFillColor(10);
-       pLegendN.SetBorderSize(1);
-       
-       if(fhNClusters->GetEntries() > 0) gPad->SetLogy();
-       gPad->SetLogx();
-       fhNClusters->SetLineColor(1);
-       
-       Int_t rbN = 1;
-       if(fhNClusters->GetNbinsX()> nbins) rbN = fhNClusters->GetNbinsX()/nbins;
-       
-       fhNClusters->SetAxisRange(nmin,nmax,"X");
-       fhNClusters->Draw("HE");
-       for(Int_t imod = 0; imod < fNModules; imod++){
-               fhNClustersMod[imod]->SetAxisRange(nmin,nmax,"X");
-               fhNClustersMod[imod]->SetLineColor(modColorIndex[imod]);
-               fhNClustersMod[imod]->Draw("same");
-               pLegendN.AddEntry(fhNClustersMod[imod],Form("module %d",imod),"L");
-       }
-       pLegendN.Draw();
-       
-       cN->cd(2) ; 
-       gPad->SetLogx();
-       for(Int_t imod = 1; imod < fNModules; imod++){
+  snprintf(cname,buffersize,"QA_%s_nclustercells",fCalorimeter.Data());
+  TCanvas  * cN = new TCanvas(cname, " Number of CaloClusters and CaloCells", 800, 1200) ;
+  cN->Divide(2, 3);
+  
+  cN->cd(1) ; 
+  
+  TLegend pLegendN(0.7,0.6,0.9,0.8);
+  pLegendN.SetTextSize(0.03);
+  pLegendN.AddEntry(fhNClusters,"all modules","L");
+  pLegendN.SetFillColor(10);
+  pLegendN.SetBorderSize(1);
+  
+  if(fhNClusters->GetEntries() > 0) gPad->SetLogy();
+  gPad->SetLogx();
+  fhNClusters->SetLineColor(1);
+  
+  Int_t rbN = 1;
+  if(fhNClusters->GetNbinsX()> nbins) rbN = fhNClusters->GetNbinsX()/nbins;
+  
+  fhNClusters->SetAxisRange(nmin,nmax,"X");
+  fhNClusters->Draw("HE");
+  for(Int_t imod = 0; imod < fNModules; imod++){
+    fhNClustersMod[imod]->SetAxisRange(nmin,nmax,"X");
+    fhNClustersMod[imod]->SetLineColor(modColorIndex[imod]);
+    fhNClustersMod[imod]->Draw("same");
+    pLegendN.AddEntry(fhNClustersMod[imod],Form("module %d",imod),"L");
+  }
+  pLegendN.Draw();
+  
+  cN->cd(2) ; 
+  gPad->SetLogx();
+  for(Int_t imod = 1; imod < fNModules; imod++){
     delete htmp; 
-               htmp = (TH1D*)fhNClustersMod[imod]->Clone(Form("hNClustersRat%d",imod));
-               htmp->Divide(fhNClustersMod[0]);
-               htmp->SetLineColor(modColorIndex[imod]);
-               if(imod==1){
-                       htmp->SetTitle("Ratio # clusters in  module X / module 0");
-                       htmp->SetMaximum(5);
-                       htmp->SetMinimum(0);
-                       htmp->Draw("HE");
-               }
-               else 
-                       htmp->Draw("same HE");
-               
-       }
-       
-       cN->cd(3) ; 
-       if(fhNCells->GetEntries() > 0) gPad->SetLogy();
-       gPad->SetLogx();
-       fhNCells->SetLineColor(1);
-       fhNCells->SetAxisRange(nmin,nmax,"X");
-       fhNCells->Draw("HE");
-       for(Int_t imod = 0; imod < fNModules; imod++){
-               fhNCellsMod[imod]->SetAxisRange(nmin,nmax,"X");
-               fhNCellsMod[imod]->SetLineColor(modColorIndex[imod]);
-               fhNCellsMod[imod]->Draw("same HE");
-       }
-       
-       
-       cN->cd(4) ; 
-       gPad->SetLogx();
-       for(Int_t imod = 1; imod < fNModules; imod++){
+    htmp = (TH1D*)fhNClustersMod[imod]->Clone(Form("hNClustersRat%d",imod));
+    htmp->Divide(fhNClustersMod[0]);
+    htmp->SetLineColor(modColorIndex[imod]);
+    if(imod==1){
+      htmp->SetTitle("Ratio # clusters in  module X / module 0");
+      htmp->SetMaximum(5);
+      htmp->SetMinimum(0);
+      htmp->Draw("HE");
+    }
+    else 
+      htmp->Draw("same HE");
+    
+  }
+  
+  cN->cd(3) ; 
+  if(fhNCells->GetEntries() > 0) gPad->SetLogy();
+  gPad->SetLogx();
+  fhNCells->SetLineColor(1);
+  fhNCells->SetAxisRange(nmin,nmax,"X");
+  fhNCells->Draw("HE");
+  for(Int_t imod = 0; imod < fNModules; imod++){
+    fhNCellsMod[imod]->SetAxisRange(nmin,nmax,"X");
+    fhNCellsMod[imod]->SetLineColor(modColorIndex[imod]);
+    fhNCellsMod[imod]->Draw("same HE");
+  }
+  
+  
+  cN->cd(4) ; 
+  gPad->SetLogx();
+  for(Int_t imod = 1; imod < fNModules; imod++){
     delete htmp; 
-               htmp = (TH1D*)fhNCellsMod[imod]->Clone(Form("hNCellsRat%d",imod));
-               htmp->Divide(fhNCellsMod[0]);
-               htmp->SetLineColor(modColorIndex[imod]);
-               if(imod==1){
-                       htmp->SetTitle("Ratio # cells in  module X / module 0");
-                       htmp->SetMaximum(5);
-                       htmp->SetMinimum(0);
-                       htmp->Draw("HE");
-               }
-               else 
-                       htmp->Draw("same HE");
-               
-       }
-       
-       cN->cd(5) ; 
-       if(fhNCellsPerCluster->GetEntries() > 0) gPad->SetLogy();
-       gPad->SetLogx();
-       TH1D *cpc = fhNCellsPerCluster->ProjectionY("cpc",-1,-1,-1,-1);
-       cpc->SetLineColor(1);
-       cpc->SetTitle("# cells per cluster");
-       cpc->Draw("HE"); 
-       TH1D ** hNCellsCluster1D = new TH1D*[fNModules];
-       
-       for(Int_t imod = 0; imod < fNModules; imod++){
-               hNCellsCluster1D[imod] = fhNCellsPerClusterMod[imod]->ProjectionY(Form("cpc_%d",imod),-1,-1);
-               hNCellsCluster1D[imod]->SetLineColor(modColorIndex[imod]);
-               hNCellsCluster1D[imod]->Draw("same HE");
-       }
-       
-       
-       cN->cd(6) ; 
-       gPad->SetLogx();
-       for(Int_t imod = 1; imod < fNModules; imod++){
+    htmp = (TH1D*)fhNCellsMod[imod]->Clone(Form("hNCellsRat%d",imod));
+    htmp->Divide(fhNCellsMod[0]);
+    htmp->SetLineColor(modColorIndex[imod]);
+    if(imod==1){
+      htmp->SetTitle("Ratio # cells in  module X / module 0");
+      htmp->SetMaximum(5);
+      htmp->SetMinimum(0);
+      htmp->Draw("HE");
+    }
+    else 
+      htmp->Draw("same HE");
+    
+  }
+  
+  cN->cd(5) ; 
+  if(fhNCellsPerCluster->GetEntries() > 0) gPad->SetLogy();
+  gPad->SetLogx();
+  TH1D *cpc = fhNCellsPerCluster->ProjectionY("cpc",-1,-1,-1,-1);
+  cpc->SetLineColor(1);
+  cpc->SetTitle("# cells per cluster");
+  cpc->Draw("HE"); 
+  TH1D ** hNCellsCluster1D = new TH1D*[fNModules];
+  
+  for(Int_t imod = 0; imod < fNModules; imod++){
+    hNCellsCluster1D[imod] = fhNCellsPerClusterMod[imod]->ProjectionY(Form("cpc_%d",imod),-1,-1);
+    hNCellsCluster1D[imod]->SetLineColor(modColorIndex[imod]);
+    hNCellsCluster1D[imod]->Draw("same HE");
+  }
+  
+  
+  cN->cd(6) ; 
+  gPad->SetLogx();
+  for(Int_t imod = 1; imod < fNModules; imod++){
     delete htmp; 
-               htmp = (TH1D*)hNCellsCluster1D[imod]->Clone(Form("hNClustersCells1DRat%d",imod));
-               htmp->Divide(hNCellsCluster1D[0]);
-               htmp->SetLineColor(modColorIndex[imod]);
-               if(imod==1){
-                       htmp->SetTitle("Ratio # cells per cluster in  module X / module 0");
+    htmp = (TH1D*)hNCellsCluster1D[imod]->Clone(Form("hNClustersCells1DRat%d",imod));
+    htmp->Divide(hNCellsCluster1D[0]);
+    htmp->SetLineColor(modColorIndex[imod]);
+    if(imod==1){
+      htmp->SetTitle("Ratio # cells per cluster in  module X / module 0");
       //htmp->SetAxisRange(ptmin,ptmax,"X");
-                       htmp->SetMaximum(3.5);
-                       htmp->SetMinimum(0);
-                       htmp->Draw("HE");
-               }
-               else 
-                       htmp->Draw("same HE");
-       }
+      htmp->SetMaximum(3.5);
+      htmp->SetMinimum(0);
+      htmp->Draw("HE");
+    }
+    else 
+      htmp->Draw("same HE");
+  }
   delete [] hNCellsCluster1D;
-
-       snprintf(name,buffersize,"QA_%s_NumberCaloClustersAndCaloCells.eps",fCalorimeter.Data());
-       cN->Print(name); printf("Print plot %s\n",name);
-       
+  
+  snprintf(name,buffersize,"QA_%s_NumberCaloClustersAndCaloCells.eps",fCalorimeter.Data());
+  cN->Print(name); printf("Print plot %s\n",name);
+  
   //----------------------------------------------------       
   // Cell Time histograms, time only available in ESDs
   //----------------------------------------------------
-       if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
+  if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
     
-               snprintf(cname,buffersize,"QA_%s_cellstime",fCalorimeter.Data());
-               TCanvas  * ctime = new TCanvas(cname, " Cells time", 1200, 400) ;
-               ctime->Divide(3, 1);
-               
-               Int_t rbTime = 1;
-               if(fhTime->GetNbinsX()> ntimebins) rbTime = fhTime->GetNbinsX()/ntimebins;
-               
-               ctime->cd(1) ; 
-               if(fhTime->GetEntries() > 0) gPad->SetLogy();
-               fhTime->Rebin(rbTime);
-               fhTime->SetAxisRange(timemin,timemax,"X");
-               fhTime->Draw();
-    
-               ctime->cd(2) ; 
-               fhTimeId->SetTitleOffset(1.8,"Y");
-               fhTimeId->SetAxisRange(timemin,timemax,"X");
-               fhTimeId->Draw("colz");
-    
-               ctime->cd(3) ; 
-               fhTimeAmp->SetTitle("Cell Energy vs Cell Time");
-               fhTimeAmp->SetTitleOffset(1.8,"Y");
-               fhTimeAmp->SetAxisRange(timemin,timemax,"Y");
-               fhTimeAmp->SetAxisRange(ptmin,ptmax,"X");               
-               fhTimeAmp->Draw("colz");
-    
-               snprintf(name,buffersize,"QA_%s_CellsTime.eps",fCalorimeter.Data());
-               ctime->Print(name); printf("Plot: %s\n",name);
-       }
-       
-       
+    snprintf(cname,buffersize,"QA_%s_cellstime",fCalorimeter.Data());
+    TCanvas  * ctime = new TCanvas(cname, " Cells time", 1200, 400) ;
+    ctime->Divide(3, 1);
+    
+    Int_t rbTime = 1;
+    if(fhTime->GetNbinsX()> ntimebins) rbTime = fhTime->GetNbinsX()/ntimebins;
+    
+    ctime->cd(1) ; 
+    if(fhTime->GetEntries() > 0) gPad->SetLogy();
+    fhTime->Rebin(rbTime);
+    fhTime->SetAxisRange(timemin,timemax,"X");
+    fhTime->Draw();
+    
+    ctime->cd(2) ; 
+    fhTimeId->SetTitleOffset(1.8,"Y");
+    fhTimeId->SetAxisRange(timemin,timemax,"X");
+    fhTimeId->Draw("colz");
+    
+    ctime->cd(3) ; 
+    fhTimeAmp->SetTitle("Cell Energy vs Cell Time");
+    fhTimeAmp->SetTitleOffset(1.8,"Y");
+    fhTimeAmp->SetAxisRange(timemin,timemax,"Y");
+    fhTimeAmp->SetAxisRange(ptmin,ptmax,"X");          
+    fhTimeAmp->Draw("colz");
+    
+    snprintf(name,buffersize,"QA_%s_CellsTime.eps",fCalorimeter.Data());
+    ctime->Print(name); printf("Plot: %s\n",name);
+  }
+  
+  
   //---------------------------------
   //Grid of cell per module plots 
   //---------------------------------
-       {
+  {
     //Number of entries per cell
     gStyle->SetPadRightMargin(0.15);
     snprintf(cname,buffersize,"%s_QA_GridCellEntries",fCalorimeter.Data());
@@ -4126,315 +4270,315 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     snprintf(name,buffersize,"QA_%s_GridCellsAccumTime.eps",fCalorimeter.Data());
     cgridT->Print(name); printf("Create plot %s\n",name);
                
-       }
-       
+  }
+  
   //---------------------------------------------
   //Calorimeter Correlation, PHOS vs EMCAL
   //---------------------------------------------
-       if(fCorrelateCalos){
-               
-               snprintf(cname,buffersize,"QA_%s_CaloCorr_EMCALvsPHOS",fCalorimeter.Data());
-               TCanvas  * ccorr = new TCanvas(cname, " EMCAL vs PHOS", 400, 400) ;
-               ccorr->Divide(2, 2);
+  if(fCorrelate){
     
-               ccorr->cd(1) ; 
+    snprintf(cname,buffersize,"QA_%s_CaloCorr_EMCALvsPHOS",fCalorimeter.Data());
+    TCanvas  * ccorr = new TCanvas(cname, " EMCAL vs PHOS", 400, 400) ;
+    ccorr->Divide(2, 2);
+    
+    ccorr->cd(1) ; 
     //gPad->SetLogy();
     //gPad->SetLogx();
-               fhCaloCorrNClusters->SetAxisRange(nmin,nmax,"X");
-               fhCaloCorrNClusters->SetAxisRange(nmin,nmax,"Y");               
-               fhCaloCorrNClusters ->Draw();
+    fhCaloCorrNClusters->SetAxisRange(nmin,nmax,"X");
+    fhCaloCorrNClusters->SetAxisRange(nmin,nmax,"Y");          
+    fhCaloCorrNClusters ->Draw();
     
-               ccorr->cd(2) ; 
+    ccorr->cd(2) ; 
     //gPad->SetLogy();
     //gPad->SetLogx();
-               fhCaloCorrNCells->SetAxisRange(nmin,nmax,"X");
-               fhCaloCorrNCells->SetAxisRange(nmin,nmax,"Y");          
-               fhCaloCorrNCells->Draw();
+    fhCaloCorrNCells->SetAxisRange(nmin,nmax,"X");
+    fhCaloCorrNCells->SetAxisRange(nmin,nmax,"Y");             
+    fhCaloCorrNCells->Draw();
     
     //gPad->SetLogy();
     //gPad->SetLogx();
-               fhCaloCorrEClusters->SetAxisRange(ptmin,ptmax,"X");
-               fhCaloCorrEClusters->SetAxisRange(ptmin,ptmax,"Y");             
-               fhCaloCorrEClusters->Draw();
+    fhCaloCorrEClusters->SetAxisRange(ptmin,ptmax,"X");
+    fhCaloCorrEClusters->SetAxisRange(ptmin,ptmax,"Y");                
+    fhCaloCorrEClusters->Draw();
     
-               ccorr->cd(4) ; 
+    ccorr->cd(4) ; 
     //gPad->SetLogy();
     //gPad->SetLogx();
-               fhCaloCorrECells->SetAxisRange(ptmin,ptmax,"X");
-               fhCaloCorrECells->SetAxisRange(ptmin,ptmax,"Y");                
-               fhCaloCorrECells->Draw();
+    fhCaloCorrECells->SetAxisRange(ptmin,ptmax,"X");
+    fhCaloCorrECells->SetAxisRange(ptmin,ptmax,"Y");           
+    fhCaloCorrECells->Draw();
     
-               snprintf(name,buffersize,"QA_%s_CaloCorr_EMCALvsPHOS.eps",fCalorimeter.Data());
-               ccorr->Print(name); printf("Plot: %s\n",name);
-       }
+    snprintf(name,buffersize,"QA_%s_CaloCorr_EMCALvsPHOS.eps",fCalorimeter.Data());
+    ccorr->Print(name); printf("Plot: %s\n",name);
+  }
   
   //----------------------------
   //Invariant mass
   //-----------------------------
        
-       Int_t imbinmin = -1;
-       Int_t imbinmax = -1;
-       
-       if(fhIM->GetEntries() > 1){
-               Int_t nebins  = fhIM->GetNbinsX();
-               Int_t emax = (Int_t) fhIM->GetXaxis()->GetXmax();
-               Int_t emin = (Int_t) fhIM->GetXaxis()->GetXmin();
-               if (emin != 0 ) printf("emin != 0 \n");
+  Int_t imbinmin = -1;
+  Int_t imbinmax = -1;
+  
+  if(fhIM->GetEntries() > 1){
+    Int_t nebins  = fhIM->GetNbinsX();
+    Int_t emax = (Int_t) fhIM->GetXaxis()->GetXmax();
+    Int_t emin = (Int_t) fhIM->GetXaxis()->GetXmin();
+    if (emin != 0 ) printf("emin != 0 \n");
     //printf("IM: nBinsX %d, emin %2.2f, emax %2.2f\n",nebins,emin,emax);
-               
-               snprintf(cname,buffersize,"QA_%s_IM",fCalorimeter.Data());
+    
+    snprintf(cname,buffersize,"QA_%s_IM",fCalorimeter.Data());
     // printf("c5\n");
-               TCanvas  * c5 = new TCanvas(cname, "Invariant mass", 600, 400) ;
-               c5->Divide(2, 3);
-               
-               c5->cd(1) ; 
+    TCanvas  * c5 = new TCanvas(cname, "Invariant mass", 600, 400) ;
+    c5->Divide(2, 3);
+    
+    c5->cd(1) ; 
     //fhIM->SetLineColor(4);
     //fhIM->Draw();
-               imbinmin = 0;
-               imbinmax =  (Int_t) (1-emin)*nebins/emax;
-               TH1D *pyim1 = fhIM->ProjectionY(Form("%s_py1",fhIM->GetName()),imbinmin,imbinmax);
-               pyim1->SetTitle("E_{pair} < 1 GeV");
-               pyim1->SetLineColor(1);
-               pyim1->Draw();
-               TLegend pLegendIM(0.7,0.6,0.9,0.8);
-               pLegendIM.SetTextSize(0.03);
-               pLegendIM.AddEntry(pyim1,"all modules","L");
-               pLegendIM.SetFillColor(10);
-               pLegendIM.SetBorderSize(1);
+    imbinmin = 0;
+    imbinmax =  (Int_t) (1-emin)*nebins/emax;
+    TH1D *pyim1 = fhIM->ProjectionY(Form("%s_py1",fhIM->GetName()),imbinmin,imbinmax);
+    pyim1->SetTitle("E_{pair} < 1 GeV");
+    pyim1->SetLineColor(1);
+    pyim1->Draw();
+    TLegend pLegendIM(0.7,0.6,0.9,0.8);
+    pLegendIM.SetTextSize(0.03);
+    pLegendIM.AddEntry(pyim1,"all modules","L");
+    pLegendIM.SetFillColor(10);
+    pLegendIM.SetBorderSize(1);
     //FIXME
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyim1 = fhIMMod[imod]->ProjectionY(Form("%s_py1",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
-                       pLegendIM.AddEntry(pyim1,Form("module %d",imod),"L");
-                       pyim1->SetLineColor(imod+1);
-                       pyim1->Draw("same");
-               }
-               pLegendIM.Draw();
-               
-               c5->cd(2) ; 
-               imbinmin =  (Int_t) (1-emin)*nebins/emax;
-               imbinmax =  (Int_t) (2-emin)*nebins/emax;
-               TH1D *pyim2 = fhIM->ProjectionY(Form("%s_py2",fhIM->GetName()),imbinmin,imbinmax);
-               pyim2->SetTitle("1 < E_{pair} < 2 GeV");
-               pyim2->SetLineColor(1);
-               pyim2->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyim2 = fhIMMod[imod]->ProjectionY(Form("%s_py2",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyim2->SetLineColor(imod+1);
-                       pyim2->Draw("same");
-               }
-               
-               c5->cd(3) ; 
-               imbinmin =  (Int_t) (2-emin)*nebins/emax;
-               imbinmax =  (Int_t) (3-emin)*nebins/emax;
-               TH1D *pyim3 = fhIM->ProjectionY(Form("%s_py3",fhIM->GetName()),imbinmin,imbinmax);
-               pyim3->SetTitle("2 < E_{pair} < 3 GeV");
-               pyim3->SetLineColor(1);
-               pyim3->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyim3 = fhIMMod[imod]->ProjectionY(Form("%s_py3",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyim3->SetLineColor(imod+1);
-                       pyim3->Draw("same");
-               }
-               
-               c5->cd(4) ;
-               imbinmin =  (Int_t) (3-emin)*nebins/emax;
-               imbinmax =  (Int_t) (4-emin)*nebins/emax;
-               TH1D *pyim4 = fhIM->ProjectionY(Form("%s_py4",fhIM->GetName()),imbinmin,imbinmax);
-               pyim4->SetTitle("3 < E_{pair} < 4 GeV");
-               pyim4->SetLineColor(1);
-               pyim4->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyim4 = fhIMMod[imod]->ProjectionY(Form("%s_py4",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyim4->SetLineColor(imod+1);
-                       pyim4->Draw("same");
-               }
-               
-               c5->cd(5) ;
-               imbinmin =  (Int_t) (4-emin)*nebins/emax;
-               imbinmax =  (Int_t) (5-emin)*nebins/emax;
-               TH1D *pyim5 = fhIM->ProjectionY(Form("%s_py5",fhIM->GetName()),imbinmin,imbinmax);
-               pyim5->SetTitle("4< E_{pair} < 5 GeV");
-               pyim5->SetLineColor(1);
-               pyim5->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyim5 = fhIMMod[imod]->ProjectionY(Form("%s_py5",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyim5->SetLineColor(imod+1);
-                       pyim5->Draw("same");
-               }
-               
-               c5->cd(6) ;
-               imbinmin =  (Int_t) (5-emin)*nebins/emax;
-               imbinmax =  -1;
-               TH1D *pyim10 = fhIM->ProjectionY(Form("%s_py6",fhIM->GetName()),imbinmin,imbinmax);
-               pyim10->SetTitle("E_{pair} > 5 GeV");
-               pyim10->SetLineColor(1);
-               pyim10->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyim10 = fhIMMod[imod]->ProjectionY(Form("%s_py6",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyim10->SetLineColor(imod+1);
-                       pyim10->Draw("same");
-               }
-               
-               snprintf(name,buffersize,"QA_%s_InvariantMass.eps",fCalorimeter.Data());
-               c5->Print(name); printf("Plot: %s\n",name);
-       }
-       
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyim1 = fhIMMod[imod]->ProjectionY(Form("%s_py1",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
+      pLegendIM.AddEntry(pyim1,Form("module %d",imod),"L");
+      pyim1->SetLineColor(imod+1);
+      pyim1->Draw("same");
+    }
+    pLegendIM.Draw();
+    
+    c5->cd(2) ; 
+    imbinmin =  (Int_t) (1-emin)*nebins/emax;
+    imbinmax =  (Int_t) (2-emin)*nebins/emax;
+    TH1D *pyim2 = fhIM->ProjectionY(Form("%s_py2",fhIM->GetName()),imbinmin,imbinmax);
+    pyim2->SetTitle("1 < E_{pair} < 2 GeV");
+    pyim2->SetLineColor(1);
+    pyim2->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyim2 = fhIMMod[imod]->ProjectionY(Form("%s_py2",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
+      pyim2->SetLineColor(imod+1);
+      pyim2->Draw("same");
+    }
+    
+    c5->cd(3) ; 
+    imbinmin =  (Int_t) (2-emin)*nebins/emax;
+    imbinmax =  (Int_t) (3-emin)*nebins/emax;
+    TH1D *pyim3 = fhIM->ProjectionY(Form("%s_py3",fhIM->GetName()),imbinmin,imbinmax);
+    pyim3->SetTitle("2 < E_{pair} < 3 GeV");
+    pyim3->SetLineColor(1);
+    pyim3->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyim3 = fhIMMod[imod]->ProjectionY(Form("%s_py3",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
+      pyim3->SetLineColor(imod+1);
+      pyim3->Draw("same");
+    }
+    
+    c5->cd(4) ;
+    imbinmin =  (Int_t) (3-emin)*nebins/emax;
+    imbinmax =  (Int_t) (4-emin)*nebins/emax;
+    TH1D *pyim4 = fhIM->ProjectionY(Form("%s_py4",fhIM->GetName()),imbinmin,imbinmax);
+    pyim4->SetTitle("3 < E_{pair} < 4 GeV");
+    pyim4->SetLineColor(1);
+    pyim4->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyim4 = fhIMMod[imod]->ProjectionY(Form("%s_py4",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
+      pyim4->SetLineColor(imod+1);
+      pyim4->Draw("same");
+    }
+    
+    c5->cd(5) ;
+    imbinmin =  (Int_t) (4-emin)*nebins/emax;
+    imbinmax =  (Int_t) (5-emin)*nebins/emax;
+    TH1D *pyim5 = fhIM->ProjectionY(Form("%s_py5",fhIM->GetName()),imbinmin,imbinmax);
+    pyim5->SetTitle("4< E_{pair} < 5 GeV");
+    pyim5->SetLineColor(1);
+    pyim5->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyim5 = fhIMMod[imod]->ProjectionY(Form("%s_py5",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
+      pyim5->SetLineColor(imod+1);
+      pyim5->Draw("same");
+    }
+    
+    c5->cd(6) ;
+    imbinmin =  (Int_t) (5-emin)*nebins/emax;
+    imbinmax =  -1;
+    TH1D *pyim10 = fhIM->ProjectionY(Form("%s_py6",fhIM->GetName()),imbinmin,imbinmax);
+    pyim10->SetTitle("E_{pair} > 5 GeV");
+    pyim10->SetLineColor(1);
+    pyim10->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyim10 = fhIMMod[imod]->ProjectionY(Form("%s_py6",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
+      pyim10->SetLineColor(imod+1);
+      pyim10->Draw("same");
+    }
+    
+    snprintf(name,buffersize,"QA_%s_InvariantMass.eps",fCalorimeter.Data());
+    c5->Print(name); printf("Plot: %s\n",name);
+  }
+  
   //--------------------------------------------------
   //Invariant mass, clusters with more than one cell
   //-------------------------------------------------
-       if(fhIMCellCut->GetEntries() > 1){
-               Int_t nebins  = fhIMCellCut->GetNbinsX();
-               Int_t emax = (Int_t) fhIMCellCut->GetXaxis()->GetXmax();
-               Int_t emin = (Int_t) fhIMCellCut->GetXaxis()->GetXmin();
-               if (emin != 0 ) printf("emin != 0 \n");
+  if(fhIMCellCut->GetEntries() > 1){
+    Int_t nebins  = fhIMCellCut->GetNbinsX();
+    Int_t emax = (Int_t) fhIMCellCut->GetXaxis()->GetXmax();
+    Int_t emin = (Int_t) fhIMCellCut->GetXaxis()->GetXmin();
+    if (emin != 0 ) printf("emin != 0 \n");
     //printf("IMCellCut: nBinsX %d, emin %2.2f, emax %2.2f\n",nebins,emin,emax);
                
-               snprintf(cname,buffersize,"QA_%s_IMCellCut",fCalorimeter.Data());
+    snprintf(cname,buffersize,"QA_%s_IMCellCut",fCalorimeter.Data());
     // printf("c5cc\n");
-               TCanvas  * c5cc = new TCanvas(cname, "Invariant mass, Cell Cut", 600, 400) ;
-               c5cc->Divide(2, 3);
-               
-               c5cc->cd(1) ; 
+    TCanvas  * c5cc = new TCanvas(cname, "Invariant mass, Cell Cut", 600, 400) ;
+    c5cc->Divide(2, 3);
+    
+    c5cc->cd(1) ; 
     //fhIMCellCut->SetLineColor(4);
     //fhIMCellCut->Draw();
-               imbinmin = 0;
-               imbinmax =  (Int_t) (1-emin)*nebins/emax;
-               TH1D *pyimcc1 = fhIMCellCut->ProjectionY(Form("%s_py1",fhIMCellCut->GetName()),imbinmin,imbinmax);
-               pyimcc1->SetTitle("E_{pair} < 1 GeV");
-               pyimcc1->SetLineColor(1);
-               pyimcc1->Draw();
-               TLegend pLegendIMCellCut(0.7,0.6,0.9,0.8);
-               pLegendIMCellCut.SetTextSize(0.03);
-               pLegendIMCellCut.AddEntry(pyimcc1,"all modules","L");
-               pLegendIMCellCut.SetFillColor(10);
-               pLegendIMCellCut.SetBorderSize(1);
-               
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyimcc1 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
-                       pLegendIMCellCut.AddEntry(pyimcc1,Form("module %d",imod),"L");
-                       pyimcc1->SetLineColor(imod+1);
-                       pyimcc1->Draw("same");
-               }
-               pLegendIMCellCut.Draw();
-               
-               c5cc->cd(2) ; 
-               imbinmin =  (Int_t) (1-emin)*nebins/emax;
-               imbinmax =  (Int_t) (2-emin)*nebins/emax;
-               TH1D *pyimcc2 = fhIMCellCut->ProjectionY(Form("%s_py2",fhIMCellCut->GetName()),imbinmin,imbinmax);
-               pyimcc2->SetTitle("1 < E_{pair} < 2 GeV");
-               pyimcc2->SetLineColor(1);
-               pyimcc2->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyimcc2 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyimcc2->SetLineColor(imod+1);
-                       pyimcc2->Draw("same");
-               }
-               
-               c5cc->cd(3) ; 
-               imbinmin =  (Int_t) (2-emin)*nebins/emax;
-               imbinmax =  (Int_t) (3-emin)*nebins/emax;
-               TH1D *pyimcc3 = fhIMCellCut->ProjectionY(Form("%s_py3",fhIMCellCut->GetName()),imbinmin,imbinmax);
-               pyimcc3->SetTitle("2 < E_{pair} < 3 GeV");
-               pyimcc3->SetLineColor(1);
-               pyimcc3->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyimcc3 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyimcc3->SetLineColor(imod+1);
-                       pyimcc3->Draw("same");
-               }
-               
-               c5cc->cd(4) ;
-               imbinmin =  (Int_t) (3-emin)*nebins/emax;
-               imbinmax =  (Int_t) (4-emin)*nebins/emax;
-               TH1D *pyimcc4 = fhIMCellCut->ProjectionY(Form("%s_py4",fhIMCellCut->GetName()),imbinmin,imbinmax);
-               pyimcc4->SetTitle("3 < E_{pair} < 4 GeV");
-               pyimcc4->SetLineColor(1);
-               pyimcc4->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyimcc4 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py5",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyimcc4->SetLineColor(imod+1);
-                       pyimcc4->Draw("same");
-               }
-               
-               c5cc->cd(5) ;
-               imbinmin =  (Int_t) (4-emin)*nebins/emax;
-               imbinmax =  (Int_t) (5-emin)*nebins/emax;
-               TH1D *pyimcc5cc = fhIMCellCut->ProjectionY(Form("%s_py5",fhIMCellCut->GetName()),imbinmin,imbinmax);
-               pyimcc5cc->SetTitle("4< E_{pair} < 5 GeV");
-               pyimcc5cc->SetLineColor(1);
-               pyimcc5cc->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyimcc5cc = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py5",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyimcc5cc->SetLineColor(imod+1);
-                       pyimcc5cc->Draw("same");
-               }
-               
-               c5cc->cd(6) ;
-               imbinmin =  (Int_t) (5-emin)*nebins/emax;
-               imbinmax =  -1;
-               TH1D *pyimcc10 = fhIMCellCut->ProjectionY(Form("%s_py6",fhIMCellCut->GetName()),imbinmin,imbinmax);
-               pyimcc10->SetTitle("E_{pair} > 5 GeV");
-               pyimcc10->SetLineColor(1);
-               pyimcc10->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyimcc10 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyimcc10->SetLineColor(imod+1);
-                       pyimcc10->Draw("same");
-               }
-               
-               snprintf(name,buffersize,"QA_%s_InvariantMass_CellCut.eps",fCalorimeter.Data());
-               c5cc->Print(name); printf("Plot: %s\n",name);
-       }
-       
-       
+    imbinmin = 0;
+    imbinmax =  (Int_t) (1-emin)*nebins/emax;
+    TH1D *pyimcc1 = fhIMCellCut->ProjectionY(Form("%s_py1",fhIMCellCut->GetName()),imbinmin,imbinmax);
+    pyimcc1->SetTitle("E_{pair} < 1 GeV");
+    pyimcc1->SetLineColor(1);
+    pyimcc1->Draw();
+    TLegend pLegendIMCellCut(0.7,0.6,0.9,0.8);
+    pLegendIMCellCut.SetTextSize(0.03);
+    pLegendIMCellCut.AddEntry(pyimcc1,"all modules","L");
+    pLegendIMCellCut.SetFillColor(10);
+    pLegendIMCellCut.SetBorderSize(1);
+    
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyimcc1 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
+      pLegendIMCellCut.AddEntry(pyimcc1,Form("module %d",imod),"L");
+      pyimcc1->SetLineColor(imod+1);
+      pyimcc1->Draw("same");
+    }
+    pLegendIMCellCut.Draw();
+    
+    c5cc->cd(2) ; 
+    imbinmin =  (Int_t) (1-emin)*nebins/emax;
+    imbinmax =  (Int_t) (2-emin)*nebins/emax;
+    TH1D *pyimcc2 = fhIMCellCut->ProjectionY(Form("%s_py2",fhIMCellCut->GetName()),imbinmin,imbinmax);
+    pyimcc2->SetTitle("1 < E_{pair} < 2 GeV");
+    pyimcc2->SetLineColor(1);
+    pyimcc2->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyimcc2 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
+      pyimcc2->SetLineColor(imod+1);
+      pyimcc2->Draw("same");
+    }
+    
+    c5cc->cd(3) ; 
+    imbinmin =  (Int_t) (2-emin)*nebins/emax;
+    imbinmax =  (Int_t) (3-emin)*nebins/emax;
+    TH1D *pyimcc3 = fhIMCellCut->ProjectionY(Form("%s_py3",fhIMCellCut->GetName()),imbinmin,imbinmax);
+    pyimcc3->SetTitle("2 < E_{pair} < 3 GeV");
+    pyimcc3->SetLineColor(1);
+    pyimcc3->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyimcc3 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
+      pyimcc3->SetLineColor(imod+1);
+      pyimcc3->Draw("same");
+    }
+    
+    c5cc->cd(4) ;
+    imbinmin =  (Int_t) (3-emin)*nebins/emax;
+    imbinmax =  (Int_t) (4-emin)*nebins/emax;
+    TH1D *pyimcc4 = fhIMCellCut->ProjectionY(Form("%s_py4",fhIMCellCut->GetName()),imbinmin,imbinmax);
+    pyimcc4->SetTitle("3 < E_{pair} < 4 GeV");
+    pyimcc4->SetLineColor(1);
+    pyimcc4->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyimcc4 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py5",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
+      pyimcc4->SetLineColor(imod+1);
+      pyimcc4->Draw("same");
+    }
+    
+    c5cc->cd(5) ;
+    imbinmin =  (Int_t) (4-emin)*nebins/emax;
+    imbinmax =  (Int_t) (5-emin)*nebins/emax;
+    TH1D *pyimcc5cc = fhIMCellCut->ProjectionY(Form("%s_py5",fhIMCellCut->GetName()),imbinmin,imbinmax);
+    pyimcc5cc->SetTitle("4< E_{pair} < 5 GeV");
+    pyimcc5cc->SetLineColor(1);
+    pyimcc5cc->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyimcc5cc = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py5",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
+      pyimcc5cc->SetLineColor(imod+1);
+      pyimcc5cc->Draw("same");
+    }
+    
+    c5cc->cd(6) ;
+    imbinmin =  (Int_t) (5-emin)*nebins/emax;
+    imbinmax =  -1;
+    TH1D *pyimcc10 = fhIMCellCut->ProjectionY(Form("%s_py6",fhIMCellCut->GetName()),imbinmin,imbinmax);
+    pyimcc10->SetTitle("E_{pair} > 5 GeV");
+    pyimcc10->SetLineColor(1);
+    pyimcc10->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyimcc10 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
+      pyimcc10->SetLineColor(imod+1);
+      pyimcc10->Draw("same");
+    }
+    
+    snprintf(name,buffersize,"QA_%s_InvariantMass_CellCut.eps",fCalorimeter.Data());
+    c5cc->Print(name); printf("Plot: %s\n",name);
+  }
+  
+  
   //Asymmetry
-       if(fhAsym->GetEntries() > 1){
-               Int_t nebins  = fhAsym->GetNbinsX();
-               Int_t emax = (Int_t) fhAsym->GetXaxis()->GetXmax();
-               Int_t emin = (Int_t) fhAsym->GetXaxis()->GetXmin();
-               if (emin != 0 ) printf("emin != 0 \n");
+  if(fhAsym->GetEntries() > 1){
+    Int_t nebins  = fhAsym->GetNbinsX();
+    Int_t emax = (Int_t) fhAsym->GetXaxis()->GetXmax();
+    Int_t emin = (Int_t) fhAsym->GetXaxis()->GetXmin();
+    if (emin != 0 ) printf("emin != 0 \n");
     //printf("Asym: nBinsX %d, emin %2.2f, emax %2.2f\n",nebins,emin,emax);
-               
-               snprintf(cname,buffersize,"QA_%s_Asym",fCalorimeter.Data());
+    
+    snprintf(cname,buffersize,"QA_%s_Asym",fCalorimeter.Data());
     // printf("c5\n");
-               TCanvas  * c5b = new TCanvas(cname, "Asymmetry", 400, 400) ;
-               c5b->Divide(2, 2);
-               
-               c5b->cd(1) ; 
-               fhAsym->SetTitleOffset(1.6,"Y");
-               fhAsym->SetLineColor(4);
-               fhAsym->Draw();
-               
-               c5b->cd(2) ; 
-               imbinmin = 0;
-               imbinmax = (Int_t) (5-emin)*nebins/emax;
-               TH1D *pyAsym5 = fhAsym->ProjectionY(Form("%s_py5",fhAsym->GetName()),imbinmin,imbinmax);
-               pyAsym5->SetTitle("E_{pair} < 5 GeV");
-               pyAsym5->SetLineColor(4);
-               pyAsym5->Draw();
-               
-               c5b->cd(3) ; 
-               imbinmin = (Int_t) (5-emin)*nebins/emax;
-               imbinmax = (Int_t) (10-emin)*nebins/emax;
-               TH1D *pyAsym510 = fhAsym->ProjectionY(Form("%s_py510",fhAsym->GetName()),imbinmin,imbinmax);
-               pyAsym510->SetTitle("5 < E_{pair} < 10 GeV");
-               pyAsym510->SetLineColor(4);
-               pyAsym510->Draw();
-               
-               c5b->cd(4) ;
-               imbinmin = (Int_t) (10-emin)*nebins/emax;
-               imbinmax = -1;
-               TH1D *pyAsym10 = fhAsym->ProjectionY(Form("%s_py10",fhAsym->GetName()),imbinmin,imbinmax);
-               pyAsym10->SetTitle("E_{pair} > 10 GeV");
-               pyAsym10->SetLineColor(4);
-               pyAsym10->Draw();
-               
-               snprintf(name,buffersize,"QA_%s_Asymmetry.eps",fCalorimeter.Data());
-               c5b->Print(name); printf("Plot: %s\n",name);
-       }
-       
-       
-       if(IsDataMC()){
+    TCanvas  * c5b = new TCanvas(cname, "Asymmetry", 400, 400) ;
+    c5b->Divide(2, 2);
+    
+    c5b->cd(1) ; 
+    fhAsym->SetTitleOffset(1.6,"Y");
+    fhAsym->SetLineColor(4);
+    fhAsym->Draw();
+    
+    c5b->cd(2) ; 
+    imbinmin = 0;
+    imbinmax = (Int_t) (5-emin)*nebins/emax;
+    TH1D *pyAsym5 = fhAsym->ProjectionY(Form("%s_py5",fhAsym->GetName()),imbinmin,imbinmax);
+    pyAsym5->SetTitle("E_{pair} < 5 GeV");
+    pyAsym5->SetLineColor(4);
+    pyAsym5->Draw();
+    
+    c5b->cd(3) ; 
+    imbinmin = (Int_t) (5-emin)*nebins/emax;
+    imbinmax = (Int_t) (10-emin)*nebins/emax;
+    TH1D *pyAsym510 = fhAsym->ProjectionY(Form("%s_py510",fhAsym->GetName()),imbinmin,imbinmax);
+    pyAsym510->SetTitle("5 < E_{pair} < 10 GeV");
+    pyAsym510->SetLineColor(4);
+    pyAsym510->Draw();
+    
+    c5b->cd(4) ;
+    imbinmin = (Int_t) (10-emin)*nebins/emax;
+    imbinmax = -1;
+    TH1D *pyAsym10 = fhAsym->ProjectionY(Form("%s_py10",fhAsym->GetName()),imbinmin,imbinmax);
+    pyAsym10->SetTitle("E_{pair} > 10 GeV");
+    pyAsym10->SetLineColor(4);
+    pyAsym10->Draw();
+    
+    snprintf(name,buffersize,"QA_%s_Asymmetry.eps",fCalorimeter.Data());
+    c5b->Print(name); printf("Plot: %s\n",name);
+  }
+  
+  
+  if(IsDataMC()){
     //Reconstructed vs MC distributions
     //printf("c6\n");
     snprintf(cname,buffersize,"QA_%s_recvsmc",fCalorimeter.Data());
@@ -5216,40 +5360,40 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
   }
   //Track-matching distributions
   
-       snprintf(cname,buffersize,"QA_%s_trkmatch",fCalorimeter.Data());
-       TCanvas *cme = new TCanvas(cname,"Track-matching distributions", 400, 400);
-       cme->Divide(2,2);
+  snprintf(cname,buffersize,"QA_%s_trkmatch",fCalorimeter.Data());
+  TCanvas *cme = new TCanvas(cname,"Track-matching distributions", 400, 400);
+  cme->Divide(2,2);
   
-       TLegend pLegendpE0(0.6,0.55,0.9,0.8);
-       pLegendpE0.SetTextSize(0.04);
-       pLegendpE0.AddEntry(fh1pOverE,"all","L");
-       pLegendpE0.AddEntry(fh1pOverER02,"dR < 0.02","L");              
-       pLegendpE0.SetFillColor(10);
-       pLegendpE0.SetBorderSize(1);
+  TLegend pLegendpE0(0.6,0.55,0.9,0.8);
+  pLegendpE0.SetTextSize(0.04);
+  pLegendpE0.AddEntry(fh1pOverE,"all","L");
+  pLegendpE0.AddEntry(fh1pOverER02,"dR < 0.02","L");           
+  pLegendpE0.SetFillColor(10);
+  pLegendpE0.SetBorderSize(1);
   //pLegendpE0.Draw();
   
-       cme->cd(1);
-       if(fh1pOverE->GetEntries() > 0) gPad->SetLogy();
-       fh1pOverE->SetTitle("Track matches p/E");
-       fh1pOverE->Draw();
-       fh1pOverER02->SetLineColor(4);
-       fh1pOverER02->Draw("same");
-       pLegendpE0.Draw();
-  
-       cme->cd(2);
-       if(fh1dR->GetEntries() > 0) gPad->SetLogy();
-       fh1dR->Draw();
-       
-       cme->cd(3);
-       fh2MatchdEdx->Draw();
-       
-       cme->cd(4);
-       fh2EledEdx->Draw();
-       
-       snprintf(name,buffersize,"QA_%s_TrackMatchingEleDist.eps",fCalorimeter.Data());
-       cme->Print(name); printf("Plot: %s\n",name);       
-       
-       if(IsDataMC()){
+  cme->cd(1);
+  if(fh1pOverE->GetEntries() > 0) gPad->SetLogy();
+  fh1pOverE->SetTitle("Track matches p/E");
+  fh1pOverE->Draw();
+  fh1pOverER02->SetLineColor(4);
+  fh1pOverER02->Draw("same");
+  pLegendpE0.Draw();
+  
+  cme->cd(2);
+  if(fh1dR->GetEntries() > 0) gPad->SetLogy();
+  fh1dR->Draw();
+  
+  cme->cd(3);
+  fh2MatchdEdx->Draw();
+  
+  cme->cd(4);
+  fh2EledEdx->Draw();
+  
+  snprintf(name,buffersize,"QA_%s_TrackMatchingEleDist.eps",fCalorimeter.Data());
+  cme->Print(name); printf("Plot: %s\n",name);       
+  
+  if(IsDataMC()){
     snprintf(cname,buffersize,"QA_%s_trkmatchMCEle",fCalorimeter.Data());
     TCanvas *cmemc = new TCanvas(cname,"Track-matching distributions from MC electrons", 600, 200);
     cmemc->Divide(3,1);
@@ -5365,14 +5509,14 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     
     snprintf(name,buffersize,"QA_%s_TrackMatchingPOverE.eps",fCalorimeter.Data());
     cmpoe->Print(name); printf("Plot: %s\n",name);                             
-       }
-       
-       char line[buffersize] ; 
-       snprintf(line, buffersize,".!tar -zcf QA_%s_%s.tar.gz *%s*.eps", fCalorimeter.Data(), GetName(),fCalorimeter.Data()) ; 
-       gROOT->ProcessLine(line);
-       snprintf(line, buffersize,".!rm -fR *.eps"); 
-       gROOT->ProcessLine(line);
-       
-       printf("AliAnaCalorimeterQA::Terminate() - !! All the eps files are in QA_%s_%s.tar.gz !!!\n",  fCalorimeter.Data(), GetName());
-       
+  }
+  
+  char line[buffersize] ; 
+  snprintf(line, buffersize,".!tar -zcf QA_%s_%s.tar.gz *%s*.eps", fCalorimeter.Data(), GetName(),fCalorimeter.Data()) ; 
+  gROOT->ProcessLine(line);
+  snprintf(line, buffersize,".!rm -fR *.eps"); 
+  gROOT->ProcessLine(line);
+  
+  printf("AliAnaCalorimeterQA::Terminate() - !! All the eps files are in QA_%s_%s.tar.gz !!!\n",  fCalorimeter.Data(), GetName());
+  
 }