]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG4/PartCorrDep/AliAnaCalorimeterQA.cxx
remove unnecessary return
[u/mrichter/AliRoot.git] / PWG4 / PartCorrDep / AliAnaCalorimeterQA.cxx
index a32f0667dfc1ac249c9fbebc39655ba23aa8b2ee..0f03d5d49dbeba49b13845f4af17777dbaa62663 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,9 +57,11 @@ 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.),
 fHistoPOverEBins(100),     fHistoPOverEMax(100.),      fHistoPOverEMin(0.),
 fHistodEdxBins(100),       fHistodEdxMax(100.),        fHistodEdxMin(0.),
 fHistodRBins(100),         fHistodRMax(100.),          fHistodRMin(0.),
@@ -79,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),
@@ -88,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),
@@ -124,23 +130,25 @@ fh1pOverER02(0), fhMCEle1pOverER02(0), fhMCChHad1pOverER02(0), fhMCNeutral1pOver
 TObjString *  AliAnaCalorimeterQA::GetAnalysisCuts()
 {      
   //Save parameters used for analysis
-       TString parList ; //this will be list of parameters used for this analysis.
-       char onePar[255] ;
-       
-       sprintf(onePar,"--- AliAnaCalorimeterQA ---\n") ;
-       parList+=onePar ;       
-       sprintf(onePar,"Calorimeter: %s\n",fCalorimeter.Data()) ;
-       parList+=onePar ;
-       sprintf(onePar,"Time Cut : %2.2f < T < %2.2f ns  \n",fTimeCutMin, fTimeCutMax) ;
-       parList+=onePar ;
+  TString parList ; //this will be list of parameters used for this analysis.
+  const Int_t buffersize = 255;
+  char onePar[buffersize] ;
   
+  snprintf(onePar,buffersize,"--- AliAnaCalorimeterQA ---\n") ;
+  parList+=onePar ;    
+  snprintf(onePar,buffersize,"Calorimeter: %s\n",fCalorimeter.Data()) ;
+  parList+=onePar ;
+  snprintf(onePar,buffersize,"Time Cut : %2.2f < T < %2.2f ns  \n",fTimeCutMin, fTimeCutMax) ;
+  parList+=onePar ;
+  snprintf(onePar,buffersize,"PHOS Cell Amplitude > %2.2f GeV, EMCAL Cell Amplitude > %2.2f GeV  \n",fPHOSCellAmpMin, fEMCALCellAmpMin) ;
+  parList+=onePar ;
   //Get parameters set in base class.
   //parList += GetBaseParametersList() ;
-       
+  
   //Get parameters set in FiducialCut class (not available yet)
   //parlist += GetFidCut()->GetFidCutParametersList() 
        
-       return new TObjString(parList) ;
+  return new TObjString(parList) ;
 }
 
 
@@ -150,45 +158,49 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
   // Create histograms to be saved in output file and 
   // store them in outputContainer
   
-       TList * outputContainer = new TList() ; 
-       outputContainer->SetName("QAHistos") ; 
-       
+  TList * outputContainer = new TList() ; 
+  outputContainer->SetName("QAHistos") ; 
+  
   //Histograms
-       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 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 ssbins      = GetHistoShowerShapeBins();  Float_t ssmax     = GetHistoShowerShapeMax();  Float_t ssmin     = GetHistoShowerShapeMin();
-       
+  Int_t nptbins     = GetHistoPtBins();                Float_t ptmax     = GetHistoPtMax();           Float_t ptmin     = GetHistoPtMin();
+  Int_t nfineptbins = GetHistoFinePtBins();        Float_t ptfinemax = GetHistoFinePtMax();       Float_t ptfinemin = GetHistoFinePtMin();
+  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 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 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;
-       fNRCU   = 2 ;
+  Int_t colmax = 48;
+  Int_t rowmax = 24;
+  fNRCU   = 2 ;
   //PHOS
-       if(fCalorimeter=="PHOS"){
-               colmax = 56;
-               rowmax = 64;
-               fNRCU   = 4 ;
-       }
-       
-       
-       fhE  = new TH1F ("hE","E reconstructed clusters ", nptbins*5,ptmin,ptmax*5); 
-       fhE->SetXTitle("E (GeV)");
-       outputContainer->Add(fhE);
+  if(fCalorimeter=="PHOS"){
+    colmax = 56;
+    rowmax = 64;
+    fNRCU   = 4 ;
+  }
+  
+  
+  fhE  = new TH1F ("hE","E reconstructed clusters ", nptbins*5,ptmin,ptmax*5); 
+  fhE->SetXTitle("E (GeV)");
+  outputContainer->Add(fhE);
   
-       if(fFillAllTH12){
+  if(fFillAllTH12){
     fhPt  = new TH1F ("hPt","p_{T} reconstructed clusters", nptbins,ptmin,ptmax); 
     fhPt->SetXTitle("p_{T} (GeV/c)");
     outputContainer->Add(fhPt);
@@ -200,36 +212,59 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
     fhEta  = new TH1F ("hEta","#eta reconstructed clusters ",netabins,etamin,etamax); 
     fhEta->SetXTitle("#eta ");
     outputContainer->Add(fhEta);
-       }
+  }
   
-       fhEtaPhiE  = new TH3F ("hEtaPhiE","#eta vs #phi vs energy, reconstructed clusters",
+  fhEtaPhiE  = new TH3F ("hEtaPhiE","#eta vs #phi vs energy, reconstructed clusters",
                          netabins,etamin,etamax,nphibins,phimin,phimax,nptbins,ptmin,ptmax); 
-       fhEtaPhiE->SetXTitle("#eta ");
-       fhEtaPhiE->SetYTitle("#phi (rad)");
-       fhEtaPhiE->SetZTitle("E (GeV) ");
-       outputContainer->Add(fhEtaPhiE);
-       
-       fhClusterTimeEnergy  = new TH2F ("hClusterTimeEnergy","energy vs TOF, reconstructed clusters",
+  fhEtaPhiE->SetXTitle("#eta ");
+  fhEtaPhiE->SetYTitle("#phi (rad)");
+  fhEtaPhiE->SetZTitle("E (GeV) ");
+  outputContainer->Add(fhEtaPhiE);
+  
+  fhClusterTimeEnergy  = new TH2F ("hClusterTimeEnergy","energy vs TOF, reconstructed clusters",
                                    nptbins,ptmin,ptmax, ntimebins,timemin,timemax); 
-       fhClusterTimeEnergy->SetXTitle("E (GeV) ");
-       fhClusterTimeEnergy->SetYTitle("TOF (ns)");
-       outputContainer->Add(fhClusterTimeEnergy);
-       
-       
+  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",
+  fhLambda  = new TH3F ("hLambda","#lambda_{0}^{2} vs #lambda_{1}^{2} vs energy, reconstructed clusters",
                         ssbins,ssmin,ssmax,ssbins,ssmin,ssmax,nptbins,ptmin,ptmax); 
-       fhLambda->SetXTitle("#lambda_{0}^{2}  ");
-       fhLambda->SetYTitle("#lambda_{1}^{2}  ");
-       fhLambda->SetZTitle("E (GeV) ");
-       outputContainer->Add(fhLambda);
-       
-       fhDispersion  = new TH2F ("hDispersion"," dispersion vs energy, reconstructed clusters",
+  fhLambda->SetXTitle("#lambda_{0}^{2}  ");
+  fhLambda->SetYTitle("#lambda_{1}^{2}  ");
+  fhLambda->SetZTitle("E (GeV) ");
+  outputContainer->Add(fhLambda);
+  
+  fhDispersion  = new TH2F ("hDispersion"," dispersion vs energy, reconstructed clusters",
                             ssbins,ssmin,ssmax,nptbins,ptmin,ptmax); 
-       fhDispersion->SetXTitle("Dispersion  ");
-       fhDispersion->SetYTitle("E (GeV) ");
-       outputContainer->Add(fhDispersion);
-       
+  fhDispersion->SetXTitle("Dispersion  ");
+  fhDispersion->SetYTitle("E (GeV) ");
+  outputContainer->Add(fhDispersion);
+  
   //Track Matching
   if(fFillAllTH12){
     fhECharged  = new TH1F ("hECharged","E reconstructed clusters, matched with track", nptbins,ptmin,ptmax); 
@@ -249,129 +284,133 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
     outputContainer->Add(fhEtaCharged);
   }
   
-       fhEtaPhiECharged  = new TH3F ("hEtaPhiECharged","#eta vs #phi, reconstructed clusters, matched with track",
+  fhEtaPhiECharged  = new TH3F ("hEtaPhiECharged","#eta vs #phi, reconstructed clusters, matched with track",
                                 netabins,etamin,etamax,nphibins,phimin,phimax,nptbins,ptmin,ptmax); 
-       fhEtaPhiECharged->SetXTitle("#eta ");
-       fhEtaPhiECharged->SetYTitle("#phi ");
-       fhEtaPhiECharged->SetZTitle("E (GeV) ");
-       outputContainer->Add(fhEtaPhiECharged); 
-  
-       fh1pOverE = new TH2F("h1pOverE","TRACK matches p/E",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
-       fh1pOverE->SetYTitle("p/E");
-       fh1pOverE->SetXTitle("p_{T} (GeV/c)");
-       outputContainer->Add(fh1pOverE);
-       
-       fh1dR = new TH1F("h1dR","TRACK matches dR",ndRbins,dRmin,dRmax);
-       fh1dR->SetXTitle("#Delta R (rad)");
-       outputContainer->Add(fh1dR) ;
-       
-       fh2MatchdEdx = new TH2F("h2MatchdEdx","dE/dx vs. p for all matches",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
-       fh2MatchdEdx->SetXTitle("p (GeV/c)");
-       fh2MatchdEdx->SetYTitle("<dE/dx>");
-       outputContainer->Add(fh2MatchdEdx);
-       
-       fh2EledEdx = new TH2F("h2EledEdx","dE/dx vs. p for electrons",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
-       fh2EledEdx->SetXTitle("p (GeV/c)");
-       fh2EledEdx->SetYTitle("<dE/dx>");
-       outputContainer->Add(fh2EledEdx) ;
-       
-       fh1pOverER02 = new TH2F("h1pOverER02","TRACK matches p/E, all",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
-       fh1pOverER02->SetYTitle("p/E");
-       fh1pOverER02->SetXTitle("p_{T} (GeV/c)");
-       outputContainer->Add(fh1pOverER02);     
-       
-       fhIM  = new TH2F ("hIM","Cluster pairs Invariant mass vs reconstructed pair energy",nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
-       fhIM->SetXTitle("p_{T, cluster pairs} (GeV) ");
-       fhIM->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
-       outputContainer->Add(fhIM);
-       
-       fhIMCellCut  = new TH2F ("hIMCellCut","Cluster (n cell > 1) pairs Invariant mass vs reconstructed pair energy",nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
-       fhIMCellCut->SetXTitle("p_{T, cluster pairs} (GeV) ");
-       fhIMCellCut->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
-       outputContainer->Add(fhIMCellCut);
+  fhEtaPhiECharged->SetXTitle("#eta ");
+  fhEtaPhiECharged->SetYTitle("#phi ");
+  fhEtaPhiECharged->SetZTitle("E (GeV) ");
+  outputContainer->Add(fhEtaPhiECharged);      
   
-  if(fFillAllTH12){
-    fhAsym  = new TH2F ("hAssym","Cluster pairs Asymmetry vs reconstructed pair energy",nptbins,ptmin,ptmax,nasymbins,asymmin,asymmax); 
-    fhAsym->SetXTitle("p_{T, cluster pairs} (GeV) ");
-    fhAsym->SetYTitle("Asymmetry");
-    outputContainer->Add(fhAsym);      
-  }
+  fh1pOverE = new TH2F("h1pOverE","TRACK matches p/E",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
+  fh1pOverE->SetYTitle("p/E");
+  fh1pOverE->SetXTitle("p_{T} (GeV/c)");
+  outputContainer->Add(fh1pOverE);
   
-       fhNCellsPerCluster  = new TH3F ("hNCellsPerCluster","# cells per cluster vs energy vs #eta",nptbins,ptmin,ptmax, nbins,nmin,nmax, 10,etamin,etamax); 
-       fhNCellsPerCluster->SetXTitle("E (GeV)");
-       fhNCellsPerCluster->SetYTitle("n cells");
-       fhNCellsPerCluster->SetZTitle("#eta");
-       outputContainer->Add(fhNCellsPerCluster);
-       
-       
-       fhNCellsPerClusterMIP  = new TH3F ("hNCellsPerClusterMIP","# cells per cluster vs energy vs #eta, smaller bin for MIP search", 
-                                     20,0.,1., 6,0,5,10,etamin,etamax); 
-       fhNCellsPerClusterMIP->SetXTitle("E (GeV)");
-       fhNCellsPerClusterMIP->SetYTitle("n cells");
-       fhNCellsPerClusterMIP->SetZTitle("#eta");
-       outputContainer->Add(fhNCellsPerClusterMIP);
-       
-       
-       fhNCellsPerClusterMIPCharged  = new TH3F ("hNCellsPerClusterMIPCharged","# cells per track-matched cluster vs energy vs #eta, smaller bin for MIP search", 
-                                            20,0.,1., 6,0,5,10,etamin,etamax); 
-       fhNCellsPerClusterMIPCharged->SetXTitle("E (GeV)");
-       fhNCellsPerClusterMIPCharged->SetYTitle("n cells");
-       fhNCellsPerClusterMIPCharged->SetZTitle("#eta");
-       outputContainer->Add(fhNCellsPerClusterMIPCharged);
+  fh1dR = new TH1F("h1dR","TRACK matches dR",ndRbins,dRmin,dRmax);
+  fh1dR->SetXTitle("#Delta R (rad)");
+  outputContainer->Add(fh1dR) ;
+  
+  fh2MatchdEdx = new TH2F("h2MatchdEdx","dE/dx vs. p for all matches",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
+  fh2MatchdEdx->SetXTitle("p (GeV/c)");
+  fh2MatchdEdx->SetYTitle("<dE/dx>");
+  outputContainer->Add(fh2MatchdEdx);
+  
+  fh2EledEdx = new TH2F("h2EledEdx","dE/dx vs. p for electrons",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
+  fh2EledEdx->SetXTitle("p (GeV/c)");
+  fh2EledEdx->SetYTitle("<dE/dx>");
+  outputContainer->Add(fh2EledEdx) ;
+  
+  fh1pOverER02 = new TH2F("h1pOverER02","TRACK matches p/E, all",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
+  fh1pOverER02->SetYTitle("p/E");
+  fh1pOverER02->SetXTitle("p_{T} (GeV/c)");
+  outputContainer->Add(fh1pOverER02);  
+  
+  fhIM  = new TH2F ("hIM","Cluster pairs Invariant mass vs reconstructed pair energy",nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
+  fhIM->SetXTitle("p_{T, cluster pairs} (GeV) ");
+  fhIM->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
+  outputContainer->Add(fhIM);
+  
+  fhIMCellCut  = new TH2F ("hIMCellCut","Cluster (n cell > 1) pairs Invariant mass vs reconstructed pair energy",nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
+  fhIMCellCut->SetXTitle("p_{T, cluster pairs} (GeV) ");
+  fhIMCellCut->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
+  outputContainer->Add(fhIMCellCut);
+  
+  fhAsym  = new TH2F ("hAssym","Cluster pairs Asymmetry vs reconstructed pair energy",nptbins,ptmin,ptmax,nasymbins,asymmin,asymmax); 
+  fhAsym->SetXTitle("p_{T, cluster pairs} (GeV) ");
+  fhAsym->SetYTitle("Asymmetry");
+  outputContainer->Add(fhAsym);        
+  
+  
+  Int_t nlargeetabins = 3;
+  if(fCalorimeter=="EMCAL") nlargeetabins = 8;
+  
+  fhNCellsPerCluster  = new TH3F ("hNCellsPerCluster","# cells per cluster vs energy vs #eta",nptbins,ptmin,ptmax, nbins,nmin,nmax, nlargeetabins,etamin,etamax); 
+  fhNCellsPerCluster->SetXTitle("E (GeV)");
+  fhNCellsPerCluster->SetYTitle("n cells");
+  fhNCellsPerCluster->SetZTitle("#eta");
+  outputContainer->Add(fhNCellsPerCluster);
+  
+  
+  fhNCellsPerClusterMIP  = new TH3F ("hNCellsPerClusterMIP","# cells per cluster vs energy vs #eta, smaller bin for MIP search", 
+                                     40,0.,2., 11,0,10,nlargeetabins,etamin,etamax); 
+  fhNCellsPerClusterMIP->SetXTitle("E (GeV)");
+  fhNCellsPerClusterMIP->SetYTitle("n cells");
+  fhNCellsPerClusterMIP->SetZTitle("#eta");
+  outputContainer->Add(fhNCellsPerClusterMIP);
+  
+  
+  fhNCellsPerClusterMIPCharged  = new TH3F ("hNCellsPerClusterMIPCharged","# cells per track-matched cluster vs energy vs #eta, smaller bin for MIP search", 
+                                            40,0.,2., 11,0,10,nlargeetabins,etamin,etamax); 
+  fhNCellsPerClusterMIPCharged->SetXTitle("E (GeV)");
+  fhNCellsPerClusterMIPCharged->SetYTitle("n cells");
+  fhNCellsPerClusterMIPCharged->SetZTitle("#eta");
+  outputContainer->Add(fhNCellsPerClusterMIPCharged);
        
        
-       fhNClusters  = new TH1F ("hNClusters","# clusters", nbins,nmin,nmax); 
-       fhNClusters->SetXTitle("number of clusters");
-       outputContainer->Add(fhNClusters);
+  fhNClusters  = new TH1F ("hNClusters","# clusters", nbins,nmin,nmax); 
+  fhNClusters->SetXTitle("number of clusters");
+  outputContainer->Add(fhNClusters);
   
-  if(fFillAllPosHisto){
-    
-    fhRNCells  = new TH2F ("hRNCells","Cluster R position vs N Clusters per Cell",rbins,rmin,rmax,nbins,nmin,nmax); 
-    fhRNCells->SetXTitle("r = #sqrt{x^{2}+y^{2}} (cm)");
-    fhRNCells->SetYTitle("N cells per cluster");
-    outputContainer->Add(fhRNCells);
-    
-    fhXNCells  = new TH2F ("hXNCells","Cluster X position vs N Clusters per Cell",xbins,xmin,xmax,nbins,nmin,nmax); 
-    fhXNCells->SetXTitle("x (cm)");
-    fhXNCells->SetYTitle("N cells per cluster");
-    outputContainer->Add(fhXNCells);
-    
-    fhYNCells  = new TH2F ("hYNCells","Cluster Y position vs N Clusters per Cell",ybins,ymin,ymax,nbins,nmin,nmax); 
-    fhYNCells->SetXTitle("y (cm)");
-    fhYNCells->SetYTitle("N cells per cluster");
-    outputContainer->Add(fhYNCells);
-    
-    fhZNCells  = new TH2F ("hZNCells","Cluster Z position vs N Clusters per Cell",zbins,zmin,zmax,nbins,nmin,nmax); 
-    fhZNCells->SetXTitle("z (cm)");
-    fhZNCells->SetYTitle("N cells per cluster");
-    outputContainer->Add(fhZNCells);
-    
-    fhRE  = new TH2F ("hRE","Cluster R position vs cluster energy",rbins,rmin,rmax,nptbins,ptmin,ptmax); 
-    fhRE->SetXTitle("r = #sqrt{x^{2}+y^{2}} (cm)");
-    fhRE->SetYTitle("E (GeV)");
-    outputContainer->Add(fhRE);
-    
-    fhXE  = new TH2F ("hXE","Cluster X position vs cluster energy",xbins,xmin,xmax,nptbins,ptmin,ptmax); 
-    fhXE->SetXTitle("x (cm)");
-    fhXE->SetYTitle("E (GeV)");
-    outputContainer->Add(fhXE);
-    
-    fhYE  = new TH2F ("hYE","Cluster Y position vs cluster energy",ybins,ymin,ymax,nptbins,ptmin,ptmax); 
-    fhYE->SetXTitle("y (cm)");
-    fhYE->SetYTitle("E (GeV)");
-    outputContainer->Add(fhYE);
-    
-    fhZE  = new TH2F ("hZE","Cluster Z position vs cluster energy",zbins,zmin,zmax,nptbins,ptmin,ptmax); 
-    fhZE->SetXTitle("z (cm)");
-    fhZE->SetYTitle("E (GeV)");
-    outputContainer->Add(fhZE);    
-    
-    fhXYZ  = new TH3F ("hXYZ","Cluster: x vs y vs z",xbins,xmin,xmax,ybins,ymin,ymax,zbins,zmin,zmax); 
-    fhXYZ->SetXTitle("x (cm)");
-    fhXYZ->SetYTitle("y (cm)");
-    fhXYZ->SetZTitle("z (cm) ");
-    outputContainer->Add(fhXYZ);
+  fhXYZ  = new TH3F ("hXYZ","Cluster: x vs y vs z",xbins,xmin,xmax,ybins,ymin,ymax,zbins,zmin,zmax); 
+  fhXYZ->SetXTitle("x (cm)");
+  fhXYZ->SetYTitle("y (cm)");
+  fhXYZ->SetZTitle("z (cm) ");
+  outputContainer->Add(fhXYZ);  
+  
+  fhXNCells  = new TH2F ("hXNCells","Cluster X position vs N Clusters per Cell",xbins,xmin,xmax,nbins,nmin,nmax); 
+  fhXNCells->SetXTitle("x (cm)");
+  fhXNCells->SetYTitle("N cells per cluster");
+  outputContainer->Add(fhXNCells);
+  
+  fhZNCells  = new TH2F ("hZNCells","Cluster Z position vs N Clusters per Cell",zbins,zmin,zmax,nbins,nmin,nmax); 
+  fhZNCells->SetXTitle("z (cm)");
+  fhZNCells->SetYTitle("N cells per cluster");
+  outputContainer->Add(fhZNCells);
+  
+  fhXE  = new TH2F ("hXE","Cluster X position vs cluster energy",xbins,xmin,xmax,nptbins,ptmin,ptmax); 
+  fhXE->SetXTitle("x (cm)");
+  fhXE->SetYTitle("E (GeV)");
+  outputContainer->Add(fhXE);
+  
+  fhZE  = new TH2F ("hZE","Cluster Z position vs cluster energy",zbins,zmin,zmax,nptbins,ptmin,ptmax); 
+  fhZE->SetXTitle("z (cm)");
+  fhZE->SetYTitle("E (GeV)");
+  outputContainer->Add(fhZE);    
+  
+  
+  fhRNCells  = new TH2F ("hRNCells","Cluster R position vs N Clusters per Cell",rbins,rmin,rmax,nbins,nmin,nmax); 
+  fhRNCells->SetXTitle("r = #sqrt{x^{2}+y^{2}} (cm)");
+  fhRNCells->SetYTitle("N cells per cluster");
+  outputContainer->Add(fhRNCells);
+  
+  
+  fhYNCells  = new TH2F ("hYNCells","Cluster Y position vs N Clusters per Cell",ybins,ymin,ymax,nbins,nmin,nmax); 
+  fhYNCells->SetXTitle("y (cm)");
+  fhYNCells->SetYTitle("N cells per cluster");
+  outputContainer->Add(fhYNCells);
+  
+  fhRE  = new TH2F ("hRE","Cluster R position vs cluster energy",rbins,rmin,rmax,nptbins,ptmin,ptmax); 
+  fhRE->SetXTitle("r = #sqrt{x^{2}+y^{2}} (cm)");
+  fhRE->SetYTitle("E (GeV)");
+  outputContainer->Add(fhRE);
+  
+  fhYE  = new TH2F ("hYE","Cluster Y position vs cluster energy",ybins,ymin,ymax,nptbins,ptmin,ptmax); 
+  fhYE->SetXTitle("y (cm)");
+  fhYE->SetYTitle("E (GeV)");
+  outputContainer->Add(fhYE);
     
+  if(fFillAllPosHisto){
+
     fhRCellE  = new TH2F ("hRCellE","Cell R position vs cell energy",rbins,rmin,rmax,nptbins,ptmin,ptmax); 
     fhRCellE->SetXTitle("r = #sqrt{x^{2}+y^{2}} (cm)");
     fhRCellE->SetYTitle("E (GeV)");
@@ -450,49 +489,47 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
     fhEtaPhiAmp->SetZTitle("E (GeV) ");
     outputContainer->Add(fhEtaPhiAmp);         
     
-       }
+  }
   
   //Calo cells
-       fhNCells  = new TH1F ("hNCells","# cells", colmax*rowmax*fNModules,0,colmax*rowmax*fNModules); 
-       fhNCells->SetXTitle("n cells");
-       outputContainer->Add(fhNCells);
-  
-       fhAmplitude  = new TH1F ("hAmplitude","Cell Energy", nptbins*2,ptmin,ptmax); 
-       fhAmplitude->SetXTitle("Cell Energy (GeV)");
-       outputContainer->Add(fhAmplitude);
-       Int_t nb = 5000;
-       Float_t ptmax2 = 5.;
-       if(fCalorimeter == "EMCAL") ptmax2 = 20.;
-       fhAmpId  = new TH2F ("hAmpId","Cell Energy", nb,0,ptmax2,rowmax*colmax*fNModules,0,rowmax*colmax*fNModules); 
-       fhAmpId->SetXTitle("Cell Energy (GeV)");
-       outputContainer->Add(fhAmpId);
-       
-       
+  fhNCells  = new TH1F ("hNCells","# cells", colmax*rowmax*fNModules,0,colmax*rowmax*fNModules); 
+  fhNCells->SetXTitle("n cells");
+  outputContainer->Add(fhNCells);
+  
+  fhAmplitude  = new TH1F ("hAmplitude","Cell Energy", nptbins*2,ptmin,ptmax); 
+  fhAmplitude->SetXTitle("Cell Energy (GeV)");
+  outputContainer->Add(fhAmplitude);
+  
+  fhAmpId  = new TH2F ("hAmpId","Cell Energy", nfineptbins,ptfinemin,ptfinemax,rowmax*colmax*fNModules,0,rowmax*colmax*fNModules); 
+  fhAmpId->SetXTitle("Cell Energy (GeV)");
+  outputContainer->Add(fhAmpId);
+  
+  
   //Cell Time histograms, time only available in ESDs
-       if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
-               
-               fhCellTimeSpreadRespectToCellMax = new TH1F ("hCellTimeSpreadRespectToCellMax","t_{cell max}-t_{cell i} per cluster", 100,-200,200); 
-               fhCellTimeSpreadRespectToCellMax->SetXTitle("#Delta t (ns)");
-               outputContainer->Add(fhCellTimeSpreadRespectToCellMax);
-               
-               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);
-    
-               fhTimeId  = new TH2F ("hTimeId","Cell Time vs Absolute Id",ntimebins,timemin,timemax,rowmax*colmax*fNModules,0,rowmax*colmax*fNModules); 
-               fhTimeId->SetXTitle("Cell Time (ns)");
-               fhTimeId->SetYTitle("Cell Absolute Id");
-               outputContainer->Add(fhTimeId);
-    
-               fhTimeAmp  = new TH2F ("hTimeAmp","Cell Time vs Cell Energy",nptbins*2,ptmin,ptmax,ntimebins,timemin,timemax); 
-               fhTimeAmp->SetYTitle("Cell Time (ns)");
-               fhTimeAmp->SetXTitle("Cell Energy (GeV)");
-               outputContainer->Add(fhTimeAmp);
-               
+  if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
+    
+    fhCellTimeSpreadRespectToCellMax = new TH1F ("hCellTimeSpreadRespectToCellMax","t_{cell max}-t_{cell i} per cluster", 100,-200,200); 
+    fhCellTimeSpreadRespectToCellMax->SetXTitle("#Delta t (ns)");
+    outputContainer->Add(fhCellTimeSpreadRespectToCellMax);
+    
+    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);
+    
+    fhTimeId  = new TH2F ("hTimeId","Cell Time vs Absolute Id",ntimebins,timemin,timemax,rowmax*colmax*fNModules,0,rowmax*colmax*fNModules); 
+    fhTimeId->SetXTitle("Cell Time (ns)");
+    fhTimeId->SetYTitle("Cell Absolute Id");
+    outputContainer->Add(fhTimeId);
+    
+    fhTimeAmp  = new TH2F ("hTimeAmp","Cell Time vs Cell Energy",nptbins*2,ptmin,ptmax,ntimebins,timemin,timemax); 
+    fhTimeAmp->SetYTitle("Cell Time (ns)");
+    fhTimeAmp->SetXTitle("Cell Energy (GeV)");
+    outputContainer->Add(fhTimeAmp);
+    
     //         fhT0Time  = new TH1F ("hT0Time","Cell Time",ntimebins,timemin,timemax); 
     //         fhT0Time->SetXTitle("T_{0} - T_{EMCal} (ns)");
     //         outputContainer->Add(fhT0Time);
@@ -506,609 +543,679 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
     //         fhT0TimeAmp->SetYTitle("T_{0} - T_{EMCal} (ns)");
     //         fhT0TimeAmp->SetXTitle("Cell Energy (GeV)");
     //         outputContainer->Add(fhT0TimeAmp);
-       }
-       
-       if(fCorrelateCalos){
-               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->SetXTitle("#Sigma E of clusters in EMCAL (GeV)");
-               fhCaloCorrEClusters->SetYTitle("#Sigma E of clusters in PHOS (GeV)");
-               outputContainer->Add(fhCaloCorrEClusters);
-    
-               fhCaloCorrNCells  = new TH2F ("hCaloCorrNCells","# Cells in EMCAL vs PHOS", nbins,nmin,nmax, nbins,nmin,nmax); 
-               fhCaloCorrNCells->SetXTitle("number of Cells in EMCAL");
-               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->SetXTitle("#Sigma E of Cells in EMCAL (GeV)");
-               fhCaloCorrECells->SetYTitle("#Sigma E of Cells in PHOS (GeV)");
-               outputContainer->Add(fhCaloCorrECells);
-       }//correlate calorimeters
+  }
        
+  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,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);
+    
+    fhCaloCorrNCells  = new TH2F ("hCaloCorrNCells","# Cells in EMCAL vs PHOS", nbins,nmin,nmax, nbins,nmin,nmax); 
+    fhCaloCorrNCells->SetXTitle("number of Cells in EMCAL");
+    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*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
-       fhEMod                 = new TH1F*[fNModules];
-       fhNClustersMod         = new TH1F*[fNModules];
-       fhNCellsPerClusterMod  = new TH2F*[fNModules];
-       fhNCellsMod            = new TH1F*[fNModules];
-       fhGridCellsMod         = new TH2F*[fNModules];
-       fhGridCellsEMod        = new TH2F*[fNModules];
-       fhGridCellsTimeMod     = new TH2F*[fNModules];
-       fhAmplitudeMod         = new TH1F*[fNModules];
-       if(fCalorimeter=="EMCAL")
-               fhAmplitudeModFraction = new TH1F*[fNModules*3];
-  
-       fhTimeAmpPerRCU        = new TH2F*[fNModules*fNRCU];
+  fhEMod                 = new TH1F*[fNModules];
+  fhNClustersMod         = new TH1F*[fNModules];
+  fhNCellsPerClusterMod  = new TH2F*[fNModules];
+  fhNCellsMod            = new TH1F*[fNModules];
+  fhGridCellsMod         = new TH2F*[fNModules];
+  fhGridCellsEMod        = new TH2F*[fNModules];
+  fhGridCellsTimeMod     = new TH2F*[fNModules];
+  fhAmplitudeMod         = new TH1F*[fNModules];
+  if(fCalorimeter=="EMCAL")
+    fhAmplitudeModFraction = new TH1F*[fNModules*3];
+  
+  fhTimeAmpPerRCU        = new TH2F*[fNModules*fNRCU];
   //fhT0TimeAmpPerRCU      = new TH2F*[fNModules*fNRCU];
   //fhTimeCorrRCU          = new TH2F*[fNModules*fNRCU*fNModules*fNRCU];
-       
-       fhIMMod                = new TH2F*[fNModules];
-       fhIMCellCutMod         = new TH2F*[fNModules];
   
-       for(Int_t imod = 0; imod < fNModules; imod++){
-               
-               fhEMod[imod]  = new TH1F (Form("hE_Mod%d",imod),Form("Cluster reconstructed Energy in Module %d ",imod), nptbins,ptmin,ptmax); 
-               fhEMod[imod]->SetXTitle("E (GeV)");
-               outputContainer->Add(fhEMod[imod]);
-               
-               fhNClustersMod[imod]  = new TH1F (Form("hNClusters_Mod%d",imod),Form("# clusters in Module %d",imod), nbins,nmin,nmax); 
-               fhNClustersMod[imod]->SetXTitle("number of clusters");
-               outputContainer->Add(fhNClustersMod[imod]);
-               
-               fhNCellsPerClusterMod[imod]  = new TH2F (Form("hNCellsPerCluster_Mod%d",imod),
+  fhIMMod                = new TH2F*[fNModules];
+  fhIMCellCutMod         = new TH2F*[fNModules];
+  
+  for(Int_t imod = 0; imod < fNModules; imod++){
+    
+    fhEMod[imod]  = new TH1F (Form("hE_Mod%d",imod),Form("Cluster reconstructed Energy in Module %d ",imod), nptbins,ptmin,ptmax); 
+    fhEMod[imod]->SetXTitle("E (GeV)");
+    outputContainer->Add(fhEMod[imod]);
+    
+    fhNClustersMod[imod]  = new TH1F (Form("hNClusters_Mod%d",imod),Form("# clusters in Module %d",imod), nbins,nmin,nmax); 
+    fhNClustersMod[imod]->SetXTitle("number of clusters");
+    outputContainer->Add(fhNClustersMod[imod]);
+    
+    fhNCellsPerClusterMod[imod]  = new TH2F (Form("hNCellsPerCluster_Mod%d",imod),
                                              Form("# cells per cluster vs cluster energy in Module %d",imod), 
                                              nptbins,ptmin,ptmax, nbins,nmin,nmax); 
-               fhNCellsPerClusterMod[imod]->SetXTitle("E (GeV)");
-               fhNCellsPerClusterMod[imod]->SetYTitle("n cells");
-               outputContainer->Add(fhNCellsPerClusterMod[imod]);
-               
-               fhNCellsMod[imod]  = new TH1F (Form("hNCells_Mod%d",imod),Form("# cells in Module %d",imod), colmax*rowmax,0,colmax*rowmax); 
-               fhNCellsMod[imod]->SetXTitle("n cells");
-               outputContainer->Add(fhNCellsMod[imod]);
-               fhGridCellsMod[imod]  = new TH2F (Form("hGridCells_Mod%d",imod),Form("Entries in grid of cells in Module %d",imod), 
+    fhNCellsPerClusterMod[imod]->SetXTitle("E (GeV)");
+    fhNCellsPerClusterMod[imod]->SetYTitle("n cells");
+    outputContainer->Add(fhNCellsPerClusterMod[imod]);
+    
+    fhNCellsMod[imod]  = new TH1F (Form("hNCells_Mod%d",imod),Form("# cells in Module %d",imod), colmax*rowmax,0,colmax*rowmax); 
+    fhNCellsMod[imod]->SetXTitle("n cells");
+    outputContainer->Add(fhNCellsMod[imod]);
+    fhGridCellsMod[imod]  = new TH2F (Form("hGridCells_Mod%d",imod),Form("Entries in grid of cells in Module %d",imod), 
                                       colmax+2,-1.5,colmax+0.5, rowmax+2,-1.5,rowmax+0.5); 
-               fhGridCellsMod[imod]->SetYTitle("row (phi direction)");
-               fhGridCellsMod[imod]->SetXTitle("column (eta direction)");
-               outputContainer->Add(fhGridCellsMod[imod]);
+    fhGridCellsMod[imod]->SetYTitle("row (phi direction)");
+    fhGridCellsMod[imod]->SetXTitle("column (eta direction)");
+    outputContainer->Add(fhGridCellsMod[imod]);
     
-               fhGridCellsEMod[imod]  = new TH2F (Form("hGridCellsE_Mod%d",imod),Form("Accumulated energy in grid of cells in Module %d",imod), 
+    fhGridCellsEMod[imod]  = new TH2F (Form("hGridCellsE_Mod%d",imod),Form("Accumulated energy in grid of cells in Module %d",imod), 
                                        colmax+2,-1.5,colmax+0.5, rowmax+2,-1.5,rowmax+0.5); 
-               fhGridCellsEMod[imod]->SetYTitle("row (phi direction)");
-               fhGridCellsEMod[imod]->SetXTitle("column (eta direction)");
-               outputContainer->Add(fhGridCellsEMod[imod]);
-               
-               fhGridCellsTimeMod[imod]  = new TH2F (Form("hGridCellsTime_Mod%d",imod),Form("Accumulated time in grid of cells in Module %d, with E > 0.5 GeV",imod), 
+    fhGridCellsEMod[imod]->SetYTitle("row (phi direction)");
+    fhGridCellsEMod[imod]->SetXTitle("column (eta direction)");
+    outputContainer->Add(fhGridCellsEMod[imod]);
+    
+    fhGridCellsTimeMod[imod]  = new TH2F (Form("hGridCellsTime_Mod%d",imod),Form("Accumulated time in grid of cells in Module %d, with E > 0.5 GeV",imod), 
                                           colmax+2,-1.5,colmax+0.5, rowmax+2,-1.5,rowmax+0.5); 
-               fhGridCellsTimeMod[imod]->SetYTitle("row (phi direction)");
-               fhGridCellsTimeMod[imod]->SetXTitle("column (eta direction)");
-               outputContainer->Add(fhGridCellsTimeMod[imod]);
-               
-               fhAmplitudeMod[imod]  = new TH1F (Form("hAmplitude_Mod%d",imod),Form("Cell Energy in Module %d",imod), nptbins*2,ptmin,ptmax); 
-               fhAmplitudeMod[imod]->SetXTitle("Cell Energy (GeV)");
-               outputContainer->Add(fhAmplitudeMod[imod]);
-               
-               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]);
-                       }
-                       
-               }
-               
-               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),
+    fhGridCellsTimeMod[imod]->SetYTitle("row (phi direction)");
+    fhGridCellsTimeMod[imod]->SetXTitle("column (eta direction)");
+    outputContainer->Add(fhGridCellsTimeMod[imod]);
+    
+    fhAmplitudeMod[imod]  = new TH1F (Form("hAmplitude_Mod%d",imod),Form("Cell Energy in Module %d",imod), nptbins*2,ptmin,ptmax); 
+    fhAmplitudeMod[imod]->SetXTitle("Cell Energy (GeV)");
+    outputContainer->Add(fhAmplitudeMod[imod]);
+    
+    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]);
+      }
+      
+    }
+    if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
+      
+      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); 
-               fhIMMod[imod]->SetXTitle("p_{T, cluster pairs} (GeV) ");
-               fhIMMod[imod]->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
-               outputContainer->Add(fhIMMod[imod]);
+    fhIMMod[imod]->SetXTitle("p_{T, cluster pairs} (GeV) ");
+    fhIMMod[imod]->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
+    outputContainer->Add(fhIMMod[imod]);
     
-               fhIMCellCutMod[imod]  = new TH2F (Form("hIMCellCut_Mod%d",imod),
+    fhIMCellCutMod[imod]  = new TH2F (Form("hIMCellCut_Mod%d",imod),
                                       Form("Cluster (n cells > 1) pairs Invariant mass vs reconstructed pair energy in Module %d",imod),
                                       nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
-               fhIMCellCutMod[imod]->SetXTitle("p_{T, cluster pairs} (GeV) ");
-               fhIMCellCutMod[imod]->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
-               outputContainer->Add(fhIMCellCutMod[imod]);
-               
-       }
-       
-       
+    fhIMCellCutMod[imod]->SetXTitle("p_{T, cluster pairs} (GeV) ");
+    fhIMCellCutMod[imod]->SetYTitle("M_{cluster pairs} (GeV/c^{2})");
+    outputContainer->Add(fhIMCellCutMod[imod]);
+    
+  }
+  
+  
   //Monte Carlo Histograms
-       if(IsDataMC()){
-               
-               fhDeltaE  = new TH1F ("hDeltaE","MC - Reco E ", nptbins*2,-ptmax,ptmax); 
-               fhDeltaE->SetXTitle("#Delta E (GeV)");
-               outputContainer->Add(fhDeltaE);
-               
-               fhDeltaPt  = new TH1F ("hDeltaPt","MC - Reco p_{T} ", nptbins*2,-ptmax,ptmax); 
-               fhDeltaPt->SetXTitle("#Delta p_{T} (GeV/c)");
-               outputContainer->Add(fhDeltaPt);
-               
-               fhDeltaPhi  = new TH1F ("hDeltaPhi","MC - Reco #phi ",nphibins*2,-phimax,phimax); 
-               fhDeltaPhi->SetXTitle("#Delta #phi (rad)");
-               outputContainer->Add(fhDeltaPhi);
-               
-               fhDeltaEta  = new TH1F ("hDeltaEta","MC- Reco #eta",netabins*2,-etamax,etamax); 
-               fhDeltaEta->SetXTitle("#Delta #eta ");
-               outputContainer->Add(fhDeltaEta);
-               
-               fhRatioE  = new TH1F ("hRatioE","Reco/MC E ", nratiobins,ratiomin,ratiomax); 
-               fhRatioE->SetXTitle("E_{reco}/E_{gen}");
-               outputContainer->Add(fhRatioE);
-               
-               fhRatioPt  = new TH1F ("hRatioPt","Reco/MC p_{T} ", nratiobins,ratiomin,ratiomax); 
-               fhRatioPt->SetXTitle("p_{T, reco}/p_{T, gen}");
-               outputContainer->Add(fhRatioPt);
-               
-               fhRatioPhi  = new TH1F ("hRatioPhi","Reco/MC #phi ",nratiobins,ratiomin,ratiomax); 
-               fhRatioPhi->SetXTitle("#phi_{reco}/#phi_{gen}");
-               outputContainer->Add(fhRatioPhi);
-               
-               fhRatioEta  = new TH1F ("hRatioEta","Reco/MC #eta",nratiobins,ratiomin,ratiomax); 
-               fhRatioEta->SetXTitle("#eta_{reco}/#eta_{gen} ");
-               outputContainer->Add(fhRatioEta);
-               
-               fh2E  = new TH2F ("h2E","E distribution, reconstructed vs generated", nptbins,ptmin,ptmax,nptbins,ptmin,ptmax); 
-               fh2E->SetXTitle("E_{rec} (GeV)");
-               fh2E->SetYTitle("E_{gen} (GeV)");
-               outputContainer->Add(fh2E);       
-               
-               fh2Pt  = new TH2F ("h2Pt","p_T distribution, reconstructed vs generated", nptbins,ptmin,ptmax,nptbins,ptmin,ptmax); 
-               fh2Pt->SetXTitle("p_{T,rec} (GeV/c)");
-               fh2Pt->SetYTitle("p_{T,gen} (GeV/c)");
-               outputContainer->Add(fh2Pt);
-               
-               fh2Phi  = new TH2F ("h2Phi","#phi distribution, reconstructed vs generated", nphibins,phimin,phimax, nphibins,phimin,phimax); 
-               fh2Phi->SetXTitle("#phi_{rec} (rad)");
-               fh2Phi->SetYTitle("#phi_{gen} (rad)");
-               outputContainer->Add(fh2Phi);
-               
-               fh2Eta  = new TH2F ("h2Eta","#eta distribution, reconstructed vs generated", netabins,etamin,etamax,netabins,etamin,etamax); 
-               fh2Eta->SetXTitle("#eta_{rec} ");
-               fh2Eta->SetYTitle("#eta_{gen} ");
-               outputContainer->Add(fh2Eta);
-               
+  if(IsDataMC()){
+    
+    fhDeltaE  = new TH1F ("hDeltaE","MC - Reco E ", nptbins*2,-ptmax,ptmax); 
+    fhDeltaE->SetXTitle("#Delta E (GeV)");
+    outputContainer->Add(fhDeltaE);
+    
+    fhDeltaPt  = new TH1F ("hDeltaPt","MC - Reco p_{T} ", nptbins*2,-ptmax,ptmax); 
+    fhDeltaPt->SetXTitle("#Delta p_{T} (GeV/c)");
+    outputContainer->Add(fhDeltaPt);
+    
+    fhDeltaPhi  = new TH1F ("hDeltaPhi","MC - Reco #phi ",nphibins*2,-phimax,phimax); 
+    fhDeltaPhi->SetXTitle("#Delta #phi (rad)");
+    outputContainer->Add(fhDeltaPhi);
+    
+    fhDeltaEta  = new TH1F ("hDeltaEta","MC- Reco #eta",netabins*2,-etamax,etamax); 
+    fhDeltaEta->SetXTitle("#Delta #eta ");
+    outputContainer->Add(fhDeltaEta);
+    
+    fhRatioE  = new TH1F ("hRatioE","Reco/MC E ", nratiobins,ratiomin,ratiomax); 
+    fhRatioE->SetXTitle("E_{reco}/E_{gen}");
+    outputContainer->Add(fhRatioE);
+    
+    fhRatioPt  = new TH1F ("hRatioPt","Reco/MC p_{T} ", nratiobins,ratiomin,ratiomax); 
+    fhRatioPt->SetXTitle("p_{T, reco}/p_{T, gen}");
+    outputContainer->Add(fhRatioPt);
+    
+    fhRatioPhi  = new TH1F ("hRatioPhi","Reco/MC #phi ",nratiobins,ratiomin,ratiomax); 
+    fhRatioPhi->SetXTitle("#phi_{reco}/#phi_{gen}");
+    outputContainer->Add(fhRatioPhi);
+    
+    fhRatioEta  = new TH1F ("hRatioEta","Reco/MC #eta",nratiobins,ratiomin,ratiomax); 
+    fhRatioEta->SetXTitle("#eta_{reco}/#eta_{gen} ");
+    outputContainer->Add(fhRatioEta);
+    
+    fh2E  = new TH2F ("h2E","E distribution, reconstructed vs generated", nptbins,ptmin,ptmax,nptbins,ptmin,ptmax); 
+    fh2E->SetXTitle("E_{rec} (GeV)");
+    fh2E->SetYTitle("E_{gen} (GeV)");
+    outputContainer->Add(fh2E);          
+    
+    fh2Pt  = new TH2F ("h2Pt","p_T distribution, reconstructed vs generated", nptbins,ptmin,ptmax,nptbins,ptmin,ptmax); 
+    fh2Pt->SetXTitle("p_{T,rec} (GeV/c)");
+    fh2Pt->SetYTitle("p_{T,gen} (GeV/c)");
+    outputContainer->Add(fh2Pt);
+    
+    fh2Phi  = new TH2F ("h2Phi","#phi distribution, reconstructed vs generated", nphibins,phimin,phimax, nphibins,phimin,phimax); 
+    fh2Phi->SetXTitle("#phi_{rec} (rad)");
+    fh2Phi->SetYTitle("#phi_{gen} (rad)");
+    outputContainer->Add(fh2Phi);
+    
+    fh2Eta  = new TH2F ("h2Eta","#eta distribution, reconstructed vs generated", netabins,etamin,etamax,netabins,etamin,etamax); 
+    fh2Eta->SetXTitle("#eta_{rec} ");
+    fh2Eta->SetYTitle("#eta_{gen} ");
+    outputContainer->Add(fh2Eta);
+    
     //Fill histos depending on origin of cluster
-               fhGamE  = new TH2F ("hGamE","E reconstructed vs E generated from #gamma", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhGamE->SetXTitle("E_{rec} (GeV)");
-               fhGamE->SetXTitle("E_{gen} (GeV)");
-               outputContainer->Add(fhGamE);
-               
-               fhGamPt  = new TH2F ("hGamPt","p_{T} reconstructed vs E generated from #gamma", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhGamPt->SetXTitle("p_{T rec} (GeV/c)");
-               fhGamPt->SetYTitle("p_{T gen} (GeV/c)");
-               outputContainer->Add(fhGamPt);
-               
-               fhGamPhi  = new TH2F ("hGamPhi","#phi reconstructed vs E generated from #gamma",nphibins,phimin,phimax,nphibins,phimin,phimax); 
-               fhGamPhi->SetXTitle("#phi_{rec} (rad)");
-               fhGamPhi->SetYTitle("#phi_{gen} (rad)");
-               outputContainer->Add(fhGamPhi);
-               
-               fhGamEta  = new TH2F ("hGamEta","#eta reconstructed vs E generated from #gamma",netabins,etamin,etamax,netabins,etamin,etamax); 
-               fhGamEta->SetXTitle("#eta_{rec} ");
-               fhGamEta->SetYTitle("#eta_{gen} ");
-               outputContainer->Add(fhGamEta);
-               
-               fhGamDeltaE  = new TH1F ("hGamDeltaE","#gamma MC - Reco E ", nptbins*2,-ptmax,ptmax); 
-               fhGamDeltaE->SetXTitle("#Delta E (GeV)");
-               outputContainer->Add(fhGamDeltaE);
-               
-               fhGamDeltaPt  = new TH1F ("hGamDeltaPt","#gamma MC - Reco p_{T} ", nptbins*2,-ptmax,ptmax); 
-               fhGamDeltaPt->SetXTitle("#Delta p_{T} (GeV/c)");
-               outputContainer->Add(fhGamDeltaPt);
-               
-               fhGamDeltaPhi  = new TH1F ("hGamDeltaPhi","#gamma MC - Reco #phi ",nphibins*2,-phimax,phimax); 
-               fhGamDeltaPhi->SetXTitle("#Delta #phi (rad)");
-               outputContainer->Add(fhGamDeltaPhi);
-               
-               fhGamDeltaEta  = new TH1F ("hGamDeltaEta","#gamma MC- Reco #eta",netabins*2,-etamax,etamax); 
-               fhGamDeltaEta->SetXTitle("#Delta #eta ");
-               outputContainer->Add(fhGamDeltaEta);
-               
-               fhGamRatioE  = new TH1F ("hGamRatioE","#gamma Reco/MC E ", nratiobins,ratiomin,ratiomax); 
-               fhGamRatioE->SetXTitle("E_{reco}/E_{gen}");
-               outputContainer->Add(fhGamRatioE);
-               
-               fhGamRatioPt  = new TH1F ("hGamRatioPt","#gamma Reco/MC p_{T} ", nratiobins,ratiomin,ratiomax); 
-               fhGamRatioPt->SetXTitle("p_{T, reco}/p_{T, gen}");
-               outputContainer->Add(fhGamRatioPt);
-               
-               fhGamRatioPhi  = new TH1F ("hGamRatioPhi","#gamma Reco/MC #phi ",nratiobins,ratiomin,ratiomax); 
-               fhGamRatioPhi->SetXTitle("#phi_{reco}/#phi_{gen}");
-               outputContainer->Add(fhGamRatioPhi);
-               
-               fhGamRatioEta  = new TH1F ("hGamRatioEta","#gamma Reco/MC #eta",nratiobins,ratiomin,ratiomax); 
-               fhGamRatioEta->SetXTitle("#eta_{reco}/#eta_{gen} ");
-               outputContainer->Add(fhGamRatioEta);
-    
-               fhPi0E  = new TH2F ("hPi0E","E reconstructed vs E generated from #pi^{0}", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhPi0E->SetXTitle("E_{rec} (GeV)");
-               fhPi0E->SetYTitle("E_{gen} (GeV)");
-               outputContainer->Add(fhPi0E);
-               
-               fhPi0Pt  = new TH2F ("hPi0Pt","p_{T} reconstructed vs E generated from #pi^{0}", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhPi0Pt->SetXTitle("p_{T rec} (GeV/c)");
-               fhPi0Pt->SetYTitle("p_{T gen} (GeV/c)");
-               outputContainer->Add(fhPi0Pt);
-               
-               fhPi0Phi  = new TH2F ("hPi0Phi","#phi reconstructed vs E generated from #pi^{0}",nphibins,phimin,phimax,nphibins,phimin,phimax); 
-               fhPi0Phi->SetXTitle("#phi_{rec} (rad)");
-               fhPi0Phi->SetYTitle("#phi_{gen} (rad)");
-               outputContainer->Add(fhPi0Phi);
-               
-               fhPi0Eta  = new TH2F ("hPi0Eta","#eta reconstructed vs E generated from #pi^{0}",netabins,etamin,etamax,netabins,etamin,etamax); 
-               fhPi0Eta->SetXTitle("#eta_{rec} ");
-               fhPi0Eta->SetYTitle("#eta_{gen} ");
-               outputContainer->Add(fhPi0Eta);
-               
-               fhEleE  = new TH2F ("hEleE","E reconstructed vs E generated from e^{#pm}", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhEleE->SetXTitle("E_{rec} (GeV)");
-               fhEleE->SetXTitle("E_{gen} (GeV)");             
-               outputContainer->Add(fhEleE);           
-               
-               fhElePt  = new TH2F ("hElePt","p_{T} reconstructed vs E generated from e^{#pm}", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhElePt->SetXTitle("p_{T rec} (GeV/c)");
-               fhElePt->SetYTitle("p_{T gen} (GeV/c)");
-               outputContainer->Add(fhElePt);
-               
-               fhElePhi  = new TH2F ("hElePhi","#phi reconstructed vs E generated from e^{#pm}",nphibins,phimin,phimax,nphibins,phimin,phimax); 
-               fhElePhi->SetXTitle("#phi_{rec} (rad)");
-               fhElePhi->SetYTitle("#phi_{gen} (rad)");
-               outputContainer->Add(fhElePhi);
-               
-               fhEleEta  = new TH2F ("hEleEta","#eta reconstructed vs E generated from e^{#pm}",netabins,etamin,etamax,netabins,etamin,etamax); 
-               fhEleEta->SetXTitle("#eta_{rec} ");
-               fhEleEta->SetYTitle("#eta_{gen} ");
-               outputContainer->Add(fhEleEta);
-               
-               fhNeHadE  = new TH2F ("hNeHadE","E reconstructed vs E generated from neutral hadron", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhNeHadE->SetXTitle("E_{rec} (GeV)");
-               fhNeHadE->SetYTitle("E_{gen} (GeV)");
-               outputContainer->Add(fhNeHadE);
-               
-               fhNeHadPt  = new TH2F ("hNeHadPt","p_{T} reconstructed vs E generated from neutral hadron", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhNeHadPt->SetXTitle("p_{T rec} (GeV/c)");
-               fhNeHadPt->SetYTitle("p_{T gen} (GeV/c)");
-               outputContainer->Add(fhNeHadPt);
-               
-               fhNeHadPhi  = new TH2F ("hNeHadPhi","#phi reconstructed vs E generated from neutral hadron",nphibins,phimin,phimax,nphibins,phimin,phimax); 
-               fhNeHadPhi->SetXTitle("#phi_{rec} (rad)");
-               fhNeHadPhi->SetYTitle("#phi_{gen} (rad)");
-               outputContainer->Add(fhNeHadPhi);
-               
-               fhNeHadEta  = new TH2F ("hNeHadEta","#eta reconstructed vs E generated from neutral hadron",netabins,etamin,etamax,netabins,etamin,etamax); 
-               fhNeHadEta->SetXTitle("#eta_{rec} ");
-               fhNeHadEta->SetYTitle("#eta_{gen} ");
-               outputContainer->Add(fhNeHadEta);
-               
-               fhChHadE  = new TH2F ("hChHadE","E reconstructed vs E generated from charged hadron", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhChHadE->SetXTitle("E_{rec} (GeV)");
-               fhChHadE->SetYTitle("E_{gen} (GeV)");
-               outputContainer->Add(fhChHadE);
-               
-               fhChHadPt  = new TH2F ("hChHadPt","p_{T} reconstructed vs E generated from charged hadron", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhChHadPt->SetXTitle("p_{T rec} (GeV/c)");
-               fhChHadPt->SetYTitle("p_{T gen} (GeV/c)");
-               outputContainer->Add(fhChHadPt);
-               
-               fhChHadPhi  = new TH2F ("hChHadPhi","#phi reconstructed vs E generated from charged hadron",nphibins,phimin,phimax,nphibins,phimin,phimax); 
-               fhChHadPhi->SetXTitle("#phi_{rec} (rad)");
-               fhChHadPhi->SetYTitle("#phi_{gen} (rad)");
-               outputContainer->Add(fhChHadPhi);
-               
-               fhChHadEta  = new TH2F ("hChHadEta","#eta reconstructed vs E generated from charged hadron",netabins,etamin,etamax,netabins,etamin,etamax); 
-               fhChHadEta->SetXTitle("#eta_{rec} ");
-               fhChHadEta->SetYTitle("#eta_{gen} ");
-               outputContainer->Add(fhChHadEta);
-               
+    fhGamE  = new TH2F ("hGamE","E reconstructed vs E generated from #gamma", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhGamE->SetXTitle("E_{rec} (GeV)");
+    fhGamE->SetXTitle("E_{gen} (GeV)");
+    outputContainer->Add(fhGamE);
+    
+    fhGamPt  = new TH2F ("hGamPt","p_{T} reconstructed vs E generated from #gamma", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhGamPt->SetXTitle("p_{T rec} (GeV/c)");
+    fhGamPt->SetYTitle("p_{T gen} (GeV/c)");
+    outputContainer->Add(fhGamPt);
+    
+    fhGamPhi  = new TH2F ("hGamPhi","#phi reconstructed vs E generated from #gamma",nphibins,phimin,phimax,nphibins,phimin,phimax); 
+    fhGamPhi->SetXTitle("#phi_{rec} (rad)");
+    fhGamPhi->SetYTitle("#phi_{gen} (rad)");
+    outputContainer->Add(fhGamPhi);
+    
+    fhGamEta  = new TH2F ("hGamEta","#eta reconstructed vs E generated from #gamma",netabins,etamin,etamax,netabins,etamin,etamax); 
+    fhGamEta->SetXTitle("#eta_{rec} ");
+    fhGamEta->SetYTitle("#eta_{gen} ");
+    outputContainer->Add(fhGamEta);
+    
+    fhGamDeltaE  = new TH1F ("hGamDeltaE","#gamma MC - Reco E ", nptbins*2,-ptmax,ptmax); 
+    fhGamDeltaE->SetXTitle("#Delta E (GeV)");
+    outputContainer->Add(fhGamDeltaE);
+    
+    fhGamDeltaPt  = new TH1F ("hGamDeltaPt","#gamma MC - Reco p_{T} ", nptbins*2,-ptmax,ptmax); 
+    fhGamDeltaPt->SetXTitle("#Delta p_{T} (GeV/c)");
+    outputContainer->Add(fhGamDeltaPt);
+    
+    fhGamDeltaPhi  = new TH1F ("hGamDeltaPhi","#gamma MC - Reco #phi ",nphibins*2,-phimax,phimax); 
+    fhGamDeltaPhi->SetXTitle("#Delta #phi (rad)");
+    outputContainer->Add(fhGamDeltaPhi);
+    
+    fhGamDeltaEta  = new TH1F ("hGamDeltaEta","#gamma MC- Reco #eta",netabins*2,-etamax,etamax); 
+    fhGamDeltaEta->SetXTitle("#Delta #eta ");
+    outputContainer->Add(fhGamDeltaEta);
+    
+    fhGamRatioE  = new TH1F ("hGamRatioE","#gamma Reco/MC E ", nratiobins,ratiomin,ratiomax); 
+    fhGamRatioE->SetXTitle("E_{reco}/E_{gen}");
+    outputContainer->Add(fhGamRatioE);
+    
+    fhGamRatioPt  = new TH1F ("hGamRatioPt","#gamma Reco/MC p_{T} ", nratiobins,ratiomin,ratiomax); 
+    fhGamRatioPt->SetXTitle("p_{T, reco}/p_{T, gen}");
+    outputContainer->Add(fhGamRatioPt);
+    
+    fhGamRatioPhi  = new TH1F ("hGamRatioPhi","#gamma Reco/MC #phi ",nratiobins,ratiomin,ratiomax); 
+    fhGamRatioPhi->SetXTitle("#phi_{reco}/#phi_{gen}");
+    outputContainer->Add(fhGamRatioPhi);
+    
+    fhGamRatioEta  = new TH1F ("hGamRatioEta","#gamma Reco/MC #eta",nratiobins,ratiomin,ratiomax); 
+    fhGamRatioEta->SetXTitle("#eta_{reco}/#eta_{gen} ");
+    outputContainer->Add(fhGamRatioEta);
+    
+    fhPi0E  = new TH2F ("hPi0E","E reconstructed vs E generated from #pi^{0}", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhPi0E->SetXTitle("E_{rec} (GeV)");
+    fhPi0E->SetYTitle("E_{gen} (GeV)");
+    outputContainer->Add(fhPi0E);
+    
+    fhPi0Pt  = new TH2F ("hPi0Pt","p_{T} reconstructed vs E generated from #pi^{0}", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhPi0Pt->SetXTitle("p_{T rec} (GeV/c)");
+    fhPi0Pt->SetYTitle("p_{T gen} (GeV/c)");
+    outputContainer->Add(fhPi0Pt);
+    
+    fhPi0Phi  = new TH2F ("hPi0Phi","#phi reconstructed vs E generated from #pi^{0}",nphibins,phimin,phimax,nphibins,phimin,phimax); 
+    fhPi0Phi->SetXTitle("#phi_{rec} (rad)");
+    fhPi0Phi->SetYTitle("#phi_{gen} (rad)");
+    outputContainer->Add(fhPi0Phi);
+    
+    fhPi0Eta  = new TH2F ("hPi0Eta","#eta reconstructed vs E generated from #pi^{0}",netabins,etamin,etamax,netabins,etamin,etamax); 
+    fhPi0Eta->SetXTitle("#eta_{rec} ");
+    fhPi0Eta->SetYTitle("#eta_{gen} ");
+    outputContainer->Add(fhPi0Eta);
+    
+    fhEleE  = new TH2F ("hEleE","E reconstructed vs E generated from e^{#pm}", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhEleE->SetXTitle("E_{rec} (GeV)");
+    fhEleE->SetXTitle("E_{gen} (GeV)");                
+    outputContainer->Add(fhEleE);              
+    
+    fhElePt  = new TH2F ("hElePt","p_{T} reconstructed vs E generated from e^{#pm}", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhElePt->SetXTitle("p_{T rec} (GeV/c)");
+    fhElePt->SetYTitle("p_{T gen} (GeV/c)");
+    outputContainer->Add(fhElePt);
+    
+    fhElePhi  = new TH2F ("hElePhi","#phi reconstructed vs E generated from e^{#pm}",nphibins,phimin,phimax,nphibins,phimin,phimax); 
+    fhElePhi->SetXTitle("#phi_{rec} (rad)");
+    fhElePhi->SetYTitle("#phi_{gen} (rad)");
+    outputContainer->Add(fhElePhi);
+    
+    fhEleEta  = new TH2F ("hEleEta","#eta reconstructed vs E generated from e^{#pm}",netabins,etamin,etamax,netabins,etamin,etamax); 
+    fhEleEta->SetXTitle("#eta_{rec} ");
+    fhEleEta->SetYTitle("#eta_{gen} ");
+    outputContainer->Add(fhEleEta);
+    
+    fhNeHadE  = new TH2F ("hNeHadE","E reconstructed vs E generated from neutral hadron", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhNeHadE->SetXTitle("E_{rec} (GeV)");
+    fhNeHadE->SetYTitle("E_{gen} (GeV)");
+    outputContainer->Add(fhNeHadE);
+    
+    fhNeHadPt  = new TH2F ("hNeHadPt","p_{T} reconstructed vs E generated from neutral hadron", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhNeHadPt->SetXTitle("p_{T rec} (GeV/c)");
+    fhNeHadPt->SetYTitle("p_{T gen} (GeV/c)");
+    outputContainer->Add(fhNeHadPt);
+    
+    fhNeHadPhi  = new TH2F ("hNeHadPhi","#phi reconstructed vs E generated from neutral hadron",nphibins,phimin,phimax,nphibins,phimin,phimax); 
+    fhNeHadPhi->SetXTitle("#phi_{rec} (rad)");
+    fhNeHadPhi->SetYTitle("#phi_{gen} (rad)");
+    outputContainer->Add(fhNeHadPhi);
+    
+    fhNeHadEta  = new TH2F ("hNeHadEta","#eta reconstructed vs E generated from neutral hadron",netabins,etamin,etamax,netabins,etamin,etamax); 
+    fhNeHadEta->SetXTitle("#eta_{rec} ");
+    fhNeHadEta->SetYTitle("#eta_{gen} ");
+    outputContainer->Add(fhNeHadEta);
+    
+    fhChHadE  = new TH2F ("hChHadE","E reconstructed vs E generated from charged hadron", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhChHadE->SetXTitle("E_{rec} (GeV)");
+    fhChHadE->SetYTitle("E_{gen} (GeV)");
+    outputContainer->Add(fhChHadE);
+    
+    fhChHadPt  = new TH2F ("hChHadPt","p_{T} reconstructed vs E generated from charged hadron", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhChHadPt->SetXTitle("p_{T rec} (GeV/c)");
+    fhChHadPt->SetYTitle("p_{T gen} (GeV/c)");
+    outputContainer->Add(fhChHadPt);
+    
+    fhChHadPhi  = new TH2F ("hChHadPhi","#phi reconstructed vs E generated from charged hadron",nphibins,phimin,phimax,nphibins,phimin,phimax); 
+    fhChHadPhi->SetXTitle("#phi_{rec} (rad)");
+    fhChHadPhi->SetYTitle("#phi_{gen} (rad)");
+    outputContainer->Add(fhChHadPhi);
+    
+    fhChHadEta  = new TH2F ("hChHadEta","#eta reconstructed vs E generated from charged hadron",netabins,etamin,etamax,netabins,etamin,etamax); 
+    fhChHadEta->SetXTitle("#eta_{rec} ");
+    fhChHadEta->SetYTitle("#eta_{gen} ");
+    outputContainer->Add(fhChHadEta);
+    
     //Charged clusters
-               
-               fhGamECharged  = new TH2F ("hGamECharged","E reconstructed vs E generated from #gamma, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhGamECharged->SetXTitle("E_{rec} (GeV)");
-               fhGamECharged->SetXTitle("E_{gen} (GeV)");
-               outputContainer->Add(fhGamECharged);
-               
-               fhGamPtCharged  = new TH2F ("hGamPtCharged","p_{T} reconstructed vs E generated from #gamma, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhGamPtCharged->SetXTitle("p_{T rec} (GeV/c)");
-               fhGamPtCharged->SetYTitle("p_{T gen} (GeV/c)");
-               outputContainer->Add(fhGamPtCharged);
-               
-               fhGamPhiCharged  = new TH2F ("hGamPhiCharged","#phi reconstructed vs E generated from #gamma, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
-               fhGamPhiCharged->SetXTitle("#phi_{rec} (rad)");
-               fhGamPhiCharged->SetYTitle("#phi_{gen} (rad)");
-               outputContainer->Add(fhGamPhiCharged);
-               
-               fhGamEtaCharged  = new TH2F ("hGamEtaCharged","#eta reconstructed vs E generated from #gamma, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
-               fhGamEtaCharged->SetXTitle("#eta_{rec} ");
-               fhGamEtaCharged->SetYTitle("#eta_{gen} ");
-               outputContainer->Add(fhGamEtaCharged);
-               
-               fhPi0ECharged  = new TH2F ("hPi0ECharged","E reconstructed vs E generated from #pi^{0}, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhPi0ECharged->SetXTitle("E_{rec} (GeV)");
-               fhPi0ECharged->SetYTitle("E_{gen} (GeV)");
-               outputContainer->Add(fhPi0ECharged);
-               
-               fhPi0PtCharged  = new TH2F ("hPi0PtCharged","p_{T} reconstructed vs E generated from #pi^{0}, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhPi0PtCharged->SetXTitle("p_{T rec} (GeV/c)");
-               fhPi0PtCharged->SetYTitle("p_{T gen} (GeV/c)");
-               outputContainer->Add(fhPi0PtCharged);
-               
-               fhPi0PhiCharged  = new TH2F ("hPi0PhiCharged","#phi reconstructed vs E generated from #pi^{0}, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
-               fhPi0PhiCharged->SetXTitle("#phi_{rec} (rad)");
-               fhPi0PhiCharged->SetYTitle("#phi_{gen} (rad)");
-               outputContainer->Add(fhPi0PhiCharged);
-               
-               fhPi0EtaCharged  = new TH2F ("hPi0EtaCharged","#eta reconstructed vs E generated from #pi^{0}, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
-               fhPi0EtaCharged->SetXTitle("#eta_{rec} ");
-               fhPi0EtaCharged->SetYTitle("#eta_{gen} ");
-               outputContainer->Add(fhPi0EtaCharged);
-               
-               fhEleECharged  = new TH2F ("hEleECharged","E reconstructed vs E generated from e^{#pm}, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhEleECharged->SetXTitle("E_{rec} (GeV)");
-               fhEleECharged->SetXTitle("E_{gen} (GeV)");              
-               outputContainer->Add(fhEleECharged);            
-               
-               fhElePtCharged  = new TH2F ("hElePtCharged","p_{T} reconstructed vs E generated from e^{#pm}, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhElePtCharged->SetXTitle("p_{T rec} (GeV/c)");
-               fhElePtCharged->SetYTitle("p_{T gen} (GeV/c)");
-               outputContainer->Add(fhElePtCharged);
-               
-               fhElePhiCharged  = new TH2F ("hElePhiCharged","#phi reconstructed vs E generated from e^{#pm}, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
-               fhElePhiCharged->SetXTitle("#phi_{rec} (rad)");
-               fhElePhiCharged->SetYTitle("#phi_{gen} (rad)");
-               outputContainer->Add(fhElePhiCharged);
-               
-               fhEleEtaCharged  = new TH2F ("hEleEtaCharged","#eta reconstructed vs E generated from e^{#pm}, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
-               fhEleEtaCharged->SetXTitle("#eta_{rec} ");
-               fhEleEtaCharged->SetYTitle("#eta_{gen} ");
-               outputContainer->Add(fhEleEtaCharged);
-               
-               fhNeHadECharged  = new TH2F ("hNeHadECharged","E reconstructed vs E generated from neutral hadron, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhNeHadECharged->SetXTitle("E_{rec} (GeV)");
-               fhNeHadECharged->SetYTitle("E_{gen} (GeV)");
-               outputContainer->Add(fhNeHadECharged);
-               
-               fhNeHadPtCharged  = new TH2F ("hNeHadPtCharged","p_{T} reconstructed vs E generated from neutral hadron, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhNeHadPtCharged->SetXTitle("p_{T rec} (GeV/c)");
-               fhNeHadPtCharged->SetYTitle("p_{T gen} (GeV/c)");
-               outputContainer->Add(fhNeHadPtCharged);
-               
-               fhNeHadPhiCharged  = new TH2F ("hNeHadPhiCharged","#phi reconstructed vs E generated from neutral hadron, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
-               fhNeHadPhiCharged->SetXTitle("#phi_{rec} (rad)");
-               fhNeHadPhiCharged->SetYTitle("#phi_{gen} (rad)");
-               outputContainer->Add(fhNeHadPhiCharged);
-               
-               fhNeHadEtaCharged  = new TH2F ("hNeHadEtaCharged","#eta reconstructed vs E generated from neutral hadron, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
-               fhNeHadEtaCharged->SetXTitle("#eta_{rec} ");
-               fhNeHadEtaCharged->SetYTitle("#eta_{gen} ");
-               outputContainer->Add(fhNeHadEtaCharged);
-               
-               fhChHadECharged  = new TH2F ("hChHadECharged","E reconstructed vs E generated from charged hadron, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhChHadECharged->SetXTitle("E_{rec} (GeV)");
-               fhChHadECharged->SetYTitle("E_{gen} (GeV)");
-               outputContainer->Add(fhChHadECharged);
-               
-               fhChHadPtCharged  = new TH2F ("hChHadPtCharged","p_{T} reconstructed vs E generated from charged hadron, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
-               fhChHadPtCharged->SetXTitle("p_{T rec} (GeV/c)");
-               fhChHadPtCharged->SetYTitle("p_{T gen} (GeV/c)");
-               outputContainer->Add(fhChHadPtCharged);
-               
-               fhChHadPhiCharged  = new TH2F ("hChHadPhiCharged","#phi reconstructed vs E generated from charged hadron, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
-               fhChHadPhiCharged->SetXTitle("#phi (rad)");
-               fhChHadPhiCharged->SetXTitle("#phi_{rec} (rad)");
-               fhChHadPhiCharged->SetYTitle("#phi_{gen} (rad)");
-               outputContainer->Add(fhChHadPhiCharged);
-               
-               fhChHadEtaCharged  = new TH2F ("hChHadEtaCharged","#eta reconstructed vs E generated from charged hadron, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
-               fhChHadEtaCharged->SetXTitle("#eta_{rec} ");
-               fhChHadEtaCharged->SetYTitle("#eta_{gen} ");
-               outputContainer->Add(fhChHadEtaCharged);
-               
+    
+    fhGamECharged  = new TH2F ("hGamECharged","E reconstructed vs E generated from #gamma, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhGamECharged->SetXTitle("E_{rec} (GeV)");
+    fhGamECharged->SetXTitle("E_{gen} (GeV)");
+    outputContainer->Add(fhGamECharged);
+    
+    fhGamPtCharged  = new TH2F ("hGamPtCharged","p_{T} reconstructed vs E generated from #gamma, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhGamPtCharged->SetXTitle("p_{T rec} (GeV/c)");
+    fhGamPtCharged->SetYTitle("p_{T gen} (GeV/c)");
+    outputContainer->Add(fhGamPtCharged);
+    
+    fhGamPhiCharged  = new TH2F ("hGamPhiCharged","#phi reconstructed vs E generated from #gamma, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
+    fhGamPhiCharged->SetXTitle("#phi_{rec} (rad)");
+    fhGamPhiCharged->SetYTitle("#phi_{gen} (rad)");
+    outputContainer->Add(fhGamPhiCharged);
+    
+    fhGamEtaCharged  = new TH2F ("hGamEtaCharged","#eta reconstructed vs E generated from #gamma, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
+    fhGamEtaCharged->SetXTitle("#eta_{rec} ");
+    fhGamEtaCharged->SetYTitle("#eta_{gen} ");
+    outputContainer->Add(fhGamEtaCharged);
+    
+    fhPi0ECharged  = new TH2F ("hPi0ECharged","E reconstructed vs E generated from #pi^{0}, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhPi0ECharged->SetXTitle("E_{rec} (GeV)");
+    fhPi0ECharged->SetYTitle("E_{gen} (GeV)");
+    outputContainer->Add(fhPi0ECharged);
+    
+    fhPi0PtCharged  = new TH2F ("hPi0PtCharged","p_{T} reconstructed vs E generated from #pi^{0}, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhPi0PtCharged->SetXTitle("p_{T rec} (GeV/c)");
+    fhPi0PtCharged->SetYTitle("p_{T gen} (GeV/c)");
+    outputContainer->Add(fhPi0PtCharged);
+    
+    fhPi0PhiCharged  = new TH2F ("hPi0PhiCharged","#phi reconstructed vs E generated from #pi^{0}, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
+    fhPi0PhiCharged->SetXTitle("#phi_{rec} (rad)");
+    fhPi0PhiCharged->SetYTitle("#phi_{gen} (rad)");
+    outputContainer->Add(fhPi0PhiCharged);
+    
+    fhPi0EtaCharged  = new TH2F ("hPi0EtaCharged","#eta reconstructed vs E generated from #pi^{0}, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
+    fhPi0EtaCharged->SetXTitle("#eta_{rec} ");
+    fhPi0EtaCharged->SetYTitle("#eta_{gen} ");
+    outputContainer->Add(fhPi0EtaCharged);
+    
+    fhEleECharged  = new TH2F ("hEleECharged","E reconstructed vs E generated from e^{#pm}, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhEleECharged->SetXTitle("E_{rec} (GeV)");
+    fhEleECharged->SetXTitle("E_{gen} (GeV)");         
+    outputContainer->Add(fhEleECharged);               
+    
+    fhElePtCharged  = new TH2F ("hElePtCharged","p_{T} reconstructed vs E generated from e^{#pm}, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhElePtCharged->SetXTitle("p_{T rec} (GeV/c)");
+    fhElePtCharged->SetYTitle("p_{T gen} (GeV/c)");
+    outputContainer->Add(fhElePtCharged);
+    
+    fhElePhiCharged  = new TH2F ("hElePhiCharged","#phi reconstructed vs E generated from e^{#pm}, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
+    fhElePhiCharged->SetXTitle("#phi_{rec} (rad)");
+    fhElePhiCharged->SetYTitle("#phi_{gen} (rad)");
+    outputContainer->Add(fhElePhiCharged);
+    
+    fhEleEtaCharged  = new TH2F ("hEleEtaCharged","#eta reconstructed vs E generated from e^{#pm}, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
+    fhEleEtaCharged->SetXTitle("#eta_{rec} ");
+    fhEleEtaCharged->SetYTitle("#eta_{gen} ");
+    outputContainer->Add(fhEleEtaCharged);
+    
+    fhNeHadECharged  = new TH2F ("hNeHadECharged","E reconstructed vs E generated from neutral hadron, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhNeHadECharged->SetXTitle("E_{rec} (GeV)");
+    fhNeHadECharged->SetYTitle("E_{gen} (GeV)");
+    outputContainer->Add(fhNeHadECharged);
+    
+    fhNeHadPtCharged  = new TH2F ("hNeHadPtCharged","p_{T} reconstructed vs E generated from neutral hadron, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhNeHadPtCharged->SetXTitle("p_{T rec} (GeV/c)");
+    fhNeHadPtCharged->SetYTitle("p_{T gen} (GeV/c)");
+    outputContainer->Add(fhNeHadPtCharged);
+    
+    fhNeHadPhiCharged  = new TH2F ("hNeHadPhiCharged","#phi reconstructed vs E generated from neutral hadron, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
+    fhNeHadPhiCharged->SetXTitle("#phi_{rec} (rad)");
+    fhNeHadPhiCharged->SetYTitle("#phi_{gen} (rad)");
+    outputContainer->Add(fhNeHadPhiCharged);
+    
+    fhNeHadEtaCharged  = new TH2F ("hNeHadEtaCharged","#eta reconstructed vs E generated from neutral hadron, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
+    fhNeHadEtaCharged->SetXTitle("#eta_{rec} ");
+    fhNeHadEtaCharged->SetYTitle("#eta_{gen} ");
+    outputContainer->Add(fhNeHadEtaCharged);
+    
+    fhChHadECharged  = new TH2F ("hChHadECharged","E reconstructed vs E generated from charged hadron, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhChHadECharged->SetXTitle("E_{rec} (GeV)");
+    fhChHadECharged->SetYTitle("E_{gen} (GeV)");
+    outputContainer->Add(fhChHadECharged);
+    
+    fhChHadPtCharged  = new TH2F ("hChHadPtCharged","p_{T} reconstructed vs E generated from charged hadron, track matched cluster", nptbins,ptmin,ptmax, nptbins,ptmin,ptmax); 
+    fhChHadPtCharged->SetXTitle("p_{T rec} (GeV/c)");
+    fhChHadPtCharged->SetYTitle("p_{T gen} (GeV/c)");
+    outputContainer->Add(fhChHadPtCharged);
+    
+    fhChHadPhiCharged  = new TH2F ("hChHadPhiCharged","#phi reconstructed vs E generated from charged hadron, track matched cluster",nphibins,phimin,phimax,nphibins,phimin,phimax); 
+    fhChHadPhiCharged->SetXTitle("#phi (rad)");
+    fhChHadPhiCharged->SetXTitle("#phi_{rec} (rad)");
+    fhChHadPhiCharged->SetYTitle("#phi_{gen} (rad)");
+    outputContainer->Add(fhChHadPhiCharged);
+    
+    fhChHadEtaCharged  = new TH2F ("hChHadEtaCharged","#eta reconstructed vs E generated from charged hadron, track matched cluster",netabins,etamin,etamax,netabins,etamin,etamax); 
+    fhChHadEtaCharged->SetXTitle("#eta_{rec} ");
+    fhChHadEtaCharged->SetYTitle("#eta_{gen} ");
+    outputContainer->Add(fhChHadEtaCharged);
+    
     //Vertex of generated particles 
-               
-               fhEMVxyz  = new TH2F ("hEMVxyz","Production vertex of reconstructed ElectroMagnetic particles",nvdistbins,vdistmin,vdistmax,nvdistbins,vdistmin,vdistmax);//,100,0,500); 
-               fhEMVxyz->SetXTitle("v_{x}");
-               fhEMVxyz->SetYTitle("v_{y}");
+    
+    fhEMVxyz  = new TH2F ("hEMVxyz","Production vertex of reconstructed ElectroMagnetic particles",nvdistbins,vdistmin,vdistmax,nvdistbins,vdistmin,vdistmax);//,100,0,500); 
+    fhEMVxyz->SetXTitle("v_{x}");
+    fhEMVxyz->SetYTitle("v_{y}");
     //fhEMVxyz->SetZTitle("v_{z}");
-               outputContainer->Add(fhEMVxyz);
-               
-               fhHaVxyz  = new TH2F ("hHaVxyz","Production vertex of reconstructed hadrons",nvdistbins,vdistmin,vdistmax,nvdistbins,vdistmin,vdistmax);//,100,0,500); 
-               fhHaVxyz->SetXTitle("v_{x}");
-               fhHaVxyz->SetYTitle("v_{y}");
+    outputContainer->Add(fhEMVxyz);
+    
+    fhHaVxyz  = new TH2F ("hHaVxyz","Production vertex of reconstructed hadrons",nvdistbins,vdistmin,vdistmax,nvdistbins,vdistmin,vdistmax);//,100,0,500); 
+    fhHaVxyz->SetXTitle("v_{x}");
+    fhHaVxyz->SetYTitle("v_{y}");
     //fhHaVxyz->SetZTitle("v_{z}");
-               outputContainer->Add(fhHaVxyz);
-               
-               fhEMR  = new TH2F ("hEMR","Distance to production vertex of reconstructed ElectroMagnetic particles vs E rec",nptbins,ptmin,ptmax,nvdistbins,vdistmin,vdistmax); 
-               fhEMR->SetXTitle("E (GeV)");
-               fhEMR->SetYTitle("TMath::Sqrt(v_{x}^{2}+v_{y}^{2})");
-               outputContainer->Add(fhEMR);
-               
-               fhHaR  = new TH2F ("hHaR","Distance to production vertex of reconstructed Hadrons vs E rec",nptbins,ptmin,ptmax,nvdistbins,vdistmin,vdistmax); 
-               fhHaR->SetXTitle("E (GeV)");
-               fhHaR->SetYTitle("TMath::Sqrt(v_{x}^{2}+v_{y}^{2})");
-               outputContainer->Add(fhHaR);
-               
+    outputContainer->Add(fhHaVxyz);
+    
+    fhEMR  = new TH2F ("hEMR","Distance to production vertex of reconstructed ElectroMagnetic particles vs E rec",nptbins,ptmin,ptmax,nvdistbins,vdistmin,vdistmax); 
+    fhEMR->SetXTitle("E (GeV)");
+    fhEMR->SetYTitle("TMath::Sqrt(v_{x}^{2}+v_{y}^{2})");
+    outputContainer->Add(fhEMR);
+    
+    fhHaR  = new TH2F ("hHaR","Distance to production vertex of reconstructed Hadrons vs E rec",nptbins,ptmin,ptmax,nvdistbins,vdistmin,vdistmax); 
+    fhHaR->SetXTitle("E (GeV)");
+    fhHaR->SetYTitle("TMath::Sqrt(v_{x}^{2}+v_{y}^{2})");
+    outputContainer->Add(fhHaR);
+    
+    
     
-               
     //Pure MC
-               fhGenGamPt  = new TH1F("hGenGamPt" ,"p_{T} of generated #gamma",nptbins,ptmin,ptmax);
-               fhGenGamEta = new TH1F("hGenGamEta","Y of generated #gamma",netabins,etamin,etamax);
-               fhGenGamPhi = new TH1F("hGenGamPhi","#phi of generated #gamma",nphibins,phimin,phimax);
-               
-               fhGenPi0Pt  = new TH1F("hGenPi0Pt" ,"p_{T} of generated #pi^{0}",nptbins,ptmin,ptmax);
-               fhGenPi0Eta = new TH1F("hGenPi0Eta","Y of generated #pi^{0}",netabins,etamin,etamax);
-               fhGenPi0Phi = new TH1F("hGenPi0Phi","#phi of generated #pi^{0}",nphibins,phimin,phimax);
-               
-               fhGenEtaPt  = new TH1F("hGenEtaPt" ,"p_{T} of generated #eta",nptbins,ptmin,ptmax);
-               fhGenEtaEta = new TH1F("hGenEtaEta","Y of generated #eta",netabins,etamin,etamax);
-               fhGenEtaPhi = new TH1F("hGenEtaPhi","#phi of generated #eta",nphibins,phimin,phimax);
-               
-               fhGenOmegaPt  = new TH1F("hGenOmegaPt" ,"p_{T} of generated #omega",nptbins,ptmin,ptmax);
-               fhGenOmegaEta = new TH1F("hGenOmegaEta","Y of generated #omega",netabins,etamin,etamax);
-               fhGenOmegaPhi = new TH1F("hGenOmegaPhi","#phi of generated #omega",nphibins,phimin,phimax);             
-               
-               fhGenElePt  = new TH1F("hGenElePt" ,"p_{T} of generated e^{#pm}",nptbins,ptmin,ptmax);
-               fhGenEleEta = new TH1F("hGenEleEta","Y of generated  e^{#pm}",netabins,etamin,etamax);
-               fhGenElePhi = new TH1F("hGenElePhi","#phi of generated  e^{#pm}",nphibins,phimin,phimax);               
-               
-               fhGenGamPt->SetXTitle("p_{T} (GeV/c)");
-               fhGenGamEta->SetXTitle("#eta");
-               fhGenGamPhi->SetXTitle("#phi (rad)");
-               outputContainer->Add(fhGenGamPt);
-               outputContainer->Add(fhGenGamEta);
-               outputContainer->Add(fhGenGamPhi);
-    
-               fhGenPi0Pt->SetXTitle("p_{T} (GeV/c)");
-               fhGenPi0Eta->SetXTitle("#eta");
-               fhGenPi0Phi->SetXTitle("#phi (rad)");
-               outputContainer->Add(fhGenPi0Pt);
-               outputContainer->Add(fhGenPi0Eta);
-               outputContainer->Add(fhGenPi0Phi);
-               
-               fhGenEtaPt->SetXTitle("p_{T} (GeV/c)");
-               fhGenEtaEta->SetXTitle("#eta");
-               fhGenEtaPhi->SetXTitle("#phi (rad)");
-               outputContainer->Add(fhGenEtaPt);
-               outputContainer->Add(fhGenEtaEta);
-               outputContainer->Add(fhGenEtaPhi);
-    
-               fhGenOmegaPt->SetXTitle("p_{T} (GeV/c)");
-               fhGenOmegaEta->SetXTitle("#eta");
-               fhGenOmegaPhi->SetXTitle("#phi (rad)");
-               outputContainer->Add(fhGenOmegaPt);
-               outputContainer->Add(fhGenOmegaEta);
-               outputContainer->Add(fhGenOmegaPhi);
-               
-               fhGenElePt->SetXTitle("p_{T} (GeV/c)");
-               fhGenEleEta->SetXTitle("#eta");
-               fhGenElePhi->SetXTitle("#phi (rad)");
-               outputContainer->Add(fhGenElePt);
-               outputContainer->Add(fhGenEleEta);
-               outputContainer->Add(fhGenElePhi);
-               
-               fhGenGamAccE   = new TH1F("hGenGamAccE" ,"E of generated #gamma in calorimeter acceptance",nptbins,ptmin,ptmax);
-               fhGenGamAccPt  = new TH1F("hGenGamAccPt" ,"p_{T} of generated #gamma in calorimeter acceptance",nptbins,ptmin,ptmax);
-               fhGenGamAccEta = new TH1F("hGenGamAccEta","Y of generated #gamma in calorimeter acceptance",netabins,etamin,etamax);
-               fhGenGamAccPhi = new TH1F("hGenGamAccPhi","#phi of generated #gamma  in calorimeter acceptance",nphibins,phimin,phimax);
-               
-               fhGenPi0AccE  = new TH1F("hGenPi0AccE" ,"E of generated #pi^{0} in calorimeter acceptance",nptbins,ptmin,ptmax);
-               fhGenPi0AccPt  = new TH1F("hGenPi0AccPt" ,"p_{T} of generated #pi^{0} in calorimeter acceptance",nptbins,ptmin,ptmax);
-               fhGenPi0AccEta = new TH1F("hGenPi0AccEta","Y of generated #pi^{0} in calorimeter acceptance",netabins,etamin,etamax);
-               fhGenPi0AccPhi = new TH1F("hGenPi0AccPhi","#phi of generated #pi^{0} in calorimeter acceptance",nphibins,phimin,phimax);
-               
-               fhGenGamAccE  ->SetXTitle("E (GeV)");
-               fhGenGamAccPt ->SetXTitle("p_{T} (GeV/c)");
-               fhGenGamAccEta->SetXTitle("#eta");
-               fhGenGamAccPhi->SetXTitle("#phi (rad)");
-               outputContainer->Add(fhGenGamAccE);             
-               outputContainer->Add(fhGenGamAccPt);
-               outputContainer->Add(fhGenGamAccEta);
-               outputContainer->Add(fhGenGamAccPhi);
-               
-               fhGenPi0AccE  ->SetXTitle("E (GeV)");           
-               fhGenPi0AccPt ->SetXTitle("p_{T} (GeV/c)");
-               fhGenPi0AccEta->SetXTitle("#eta");
-               fhGenPi0AccPhi->SetXTitle("#phi (rad)");
-               outputContainer->Add(fhGenPi0AccE);             
-               outputContainer->Add(fhGenPi0AccPt);
-               outputContainer->Add(fhGenPi0AccEta);
-               outputContainer->Add(fhGenPi0AccPhi);
-               
+    fhGenGamPt  = new TH1F("hGenGamPt" ,"p_{T} of generated #gamma",nptbins,ptmin,ptmax);
+    fhGenGamEta = new TH1F("hGenGamEta","Y of generated #gamma",netabins,etamin,etamax);
+    fhGenGamPhi = new TH1F("hGenGamPhi","#phi of generated #gamma",nphibins,phimin,phimax);
+    
+    fhGenPi0Pt  = new TH1F("hGenPi0Pt" ,"p_{T} of generated #pi^{0}",nptbins,ptmin,ptmax);
+    fhGenPi0Eta = new TH1F("hGenPi0Eta","Y of generated #pi^{0}",netabins,etamin,etamax);
+    fhGenPi0Phi = new TH1F("hGenPi0Phi","#phi of generated #pi^{0}",nphibins,phimin,phimax);
+    
+    fhGenEtaPt  = new TH1F("hGenEtaPt" ,"p_{T} of generated #eta",nptbins,ptmin,ptmax);
+    fhGenEtaEta = new TH1F("hGenEtaEta","Y of generated #eta",netabins,etamin,etamax);
+    fhGenEtaPhi = new TH1F("hGenEtaPhi","#phi of generated #eta",nphibins,phimin,phimax);
+    
+    fhGenOmegaPt  = new TH1F("hGenOmegaPt" ,"p_{T} of generated #omega",nptbins,ptmin,ptmax);
+    fhGenOmegaEta = new TH1F("hGenOmegaEta","Y of generated #omega",netabins,etamin,etamax);
+    fhGenOmegaPhi = new TH1F("hGenOmegaPhi","#phi of generated #omega",nphibins,phimin,phimax);                
+    
+    fhGenElePt  = new TH1F("hGenElePt" ,"p_{T} of generated e^{#pm}",nptbins,ptmin,ptmax);
+    fhGenEleEta = new TH1F("hGenEleEta","Y of generated  e^{#pm}",netabins,etamin,etamax);
+    fhGenElePhi = new TH1F("hGenElePhi","#phi of generated  e^{#pm}",nphibins,phimin,phimax);          
+    
+    fhGenGamPt->SetXTitle("p_{T} (GeV/c)");
+    fhGenGamEta->SetXTitle("#eta");
+    fhGenGamPhi->SetXTitle("#phi (rad)");
+    outputContainer->Add(fhGenGamPt);
+    outputContainer->Add(fhGenGamEta);
+    outputContainer->Add(fhGenGamPhi);
+    
+    fhGenPi0Pt->SetXTitle("p_{T} (GeV/c)");
+    fhGenPi0Eta->SetXTitle("#eta");
+    fhGenPi0Phi->SetXTitle("#phi (rad)");
+    outputContainer->Add(fhGenPi0Pt);
+    outputContainer->Add(fhGenPi0Eta);
+    outputContainer->Add(fhGenPi0Phi);
+    
+    fhGenEtaPt->SetXTitle("p_{T} (GeV/c)");
+    fhGenEtaEta->SetXTitle("#eta");
+    fhGenEtaPhi->SetXTitle("#phi (rad)");
+    outputContainer->Add(fhGenEtaPt);
+    outputContainer->Add(fhGenEtaEta);
+    outputContainer->Add(fhGenEtaPhi);
+    
+    fhGenOmegaPt->SetXTitle("p_{T} (GeV/c)");
+    fhGenOmegaEta->SetXTitle("#eta");
+    fhGenOmegaPhi->SetXTitle("#phi (rad)");
+    outputContainer->Add(fhGenOmegaPt);
+    outputContainer->Add(fhGenOmegaEta);
+    outputContainer->Add(fhGenOmegaPhi);
+    
+    fhGenElePt->SetXTitle("p_{T} (GeV/c)");
+    fhGenEleEta->SetXTitle("#eta");
+    fhGenElePhi->SetXTitle("#phi (rad)");
+    outputContainer->Add(fhGenElePt);
+    outputContainer->Add(fhGenEleEta);
+    outputContainer->Add(fhGenElePhi);
+    
+    fhGenGamAccE   = new TH1F("hGenGamAccE" ,"E of generated #gamma in calorimeter acceptance",nptbins,ptmin,ptmax);
+    fhGenGamAccPt  = new TH1F("hGenGamAccPt" ,"p_{T} of generated #gamma in calorimeter acceptance",nptbins,ptmin,ptmax);
+    fhGenGamAccEta = new TH1F("hGenGamAccEta","Y of generated #gamma in calorimeter acceptance",netabins,etamin,etamax);
+    fhGenGamAccPhi = new TH1F("hGenGamAccPhi","#phi of generated #gamma  in calorimeter acceptance",nphibins,phimin,phimax);
+    
+    fhGenPi0AccE   = new TH1F("hGenPi0AccE" ,"E of generated #pi^{0} in calorimeter acceptance",nptbins,ptmin,ptmax);
+    fhGenPi0AccPt  = new TH1F("hGenPi0AccPt" ,"p_{T} of generated #pi^{0} in calorimeter acceptance",nptbins,ptmin,ptmax);
+    fhGenPi0AccEta = new TH1F("hGenPi0AccEta","Y of generated #pi^{0} in calorimeter acceptance",netabins,etamin,etamax);
+    fhGenPi0AccPhi = new TH1F("hGenPi0AccPhi","#phi of generated #pi^{0} in calorimeter acceptance",nphibins,phimin,phimax);
+    
+    fhGenGamAccE  ->SetXTitle("E (GeV)");
+    fhGenGamAccPt ->SetXTitle("p_{T} (GeV/c)");
+    fhGenGamAccEta->SetXTitle("#eta");
+    fhGenGamAccPhi->SetXTitle("#phi (rad)");
+    outputContainer->Add(fhGenGamAccE);                
+    outputContainer->Add(fhGenGamAccPt);
+    outputContainer->Add(fhGenGamAccEta);
+    outputContainer->Add(fhGenGamAccPhi);
+    
+    fhGenPi0AccE  ->SetXTitle("E (GeV)");              
+    fhGenPi0AccPt ->SetXTitle("p_{T} (GeV/c)");
+    fhGenPi0AccEta->SetXTitle("#eta");
+    fhGenPi0AccPhi->SetXTitle("#phi (rad)");
+    outputContainer->Add(fhGenPi0AccE);                
+    outputContainer->Add(fhGenPi0AccPt);
+    outputContainer->Add(fhGenPi0AccEta);
+    outputContainer->Add(fhGenPi0AccPhi);
+    
     //Track Matching 
-               
-         fhMCEle1pOverE = new TH2F("hMCEle1pOverE","TRACK matches p/E, MC electrons",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
-         fhMCEle1pOverE->SetYTitle("p/E");
-         fhMCEle1pOverE->SetXTitle("p_{T} (GeV/c)");
-         outputContainer->Add(fhMCEle1pOverE);
-         
-         fhMCEle1dR = new TH1F("hMCEle1dR","TRACK matches dR, MC electrons",ndRbins,dRmin,dRmax);
-         fhMCEle1dR->SetXTitle("#Delta R (rad)");
-         outputContainer->Add(fhMCEle1dR) ;
-         
-         fhMCEle2MatchdEdx = new TH2F("hMCEle2MatchdEdx","dE/dx vs. p for all matches, MC electrons",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
-         fhMCEle2MatchdEdx->SetXTitle("p (GeV/c)");
-         fhMCEle2MatchdEdx->SetYTitle("<dE/dx>");
-         outputContainer->Add(fhMCEle2MatchdEdx);
-         
-         fhMCChHad1pOverE = new TH2F("hMCChHad1pOverE","TRACK matches p/E, MC charged hadrons",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
-         fhMCChHad1pOverE->SetYTitle("p/E");
-         fhMCChHad1pOverE->SetXTitle("p_{T} (GeV/c)");
-         outputContainer->Add(fhMCChHad1pOverE);
-         
-         fhMCChHad1dR = new TH1F("hMCChHad1dR","TRACK matches dR, MC charged hadrons",ndRbins,dRmin,dRmax);
-         fhMCChHad1dR->SetXTitle("#Delta R (rad)");
-         outputContainer->Add(fhMCChHad1dR) ;
-         
-         fhMCChHad2MatchdEdx = new TH2F("hMCChHad2MatchdEdx","dE/dx vs. p for all matches, MC charged hadrons",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
-         fhMCChHad2MatchdEdx->SetXTitle("p (GeV/c)");
-         fhMCChHad2MatchdEdx->SetYTitle("<dE/dx>");
-         outputContainer->Add(fhMCChHad2MatchdEdx);
-         
-         fhMCNeutral1pOverE = new TH2F("hMCNeutral1pOverE","TRACK matches p/E, MC neutrals",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
-         fhMCNeutral1pOverE->SetYTitle("p/E");
-         fhMCNeutral1pOverE->SetXTitle("p_{T} (GeV/c)");
-         outputContainer->Add(fhMCNeutral1pOverE);
-         
-         fhMCNeutral1dR = new TH1F("hMCNeutral1dR","TRACK matches dR, MC neutrals",ndRbins,dRmin,dRmax);
-         fhMCNeutral1dR->SetXTitle("#Delta R (rad)");
-         outputContainer->Add(fhMCNeutral1dR) ;
-         
-         fhMCNeutral2MatchdEdx = new TH2F("hMCNeutral2MatchdEdx","dE/dx vs. p for all matches, MC neutrals",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
-         fhMCNeutral2MatchdEdx->SetXTitle("p (GeV/c)");
-         fhMCNeutral2MatchdEdx->SetYTitle("<dE/dx>");
-         outputContainer->Add(fhMCNeutral2MatchdEdx);
-    
-         fhMCEle1pOverER02 = new TH2F("hMCEle1pOverER02","TRACK matches p/E, MC electrons",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
-         fhMCEle1pOverER02->SetYTitle("p/E");
-         fhMCEle1pOverER02->SetXTitle("p_{T} (GeV/c)");
-         outputContainer->Add(fhMCEle1pOverER02);
-         
-         fhMCChHad1pOverER02 = new TH2F("hMCChHad1pOverER02","TRACK matches p/E, MC charged hadrons",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
-         fhMCChHad1pOverER02->SetYTitle("p/E");
-         fhMCChHad1pOverER02->SetXTitle("p_{T} (GeV/c)");
-         outputContainer->Add(fhMCChHad1pOverER02);
-         
-         fhMCNeutral1pOverER02 = new TH2F("hMCNeutral1pOverER02","TRACK matches p/E, MC neutrals",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
-         fhMCNeutral1pOverER02->SetYTitle("p/E");
-         fhMCNeutral1pOverER02->SetXTitle("p_{T} (GeV/c)");
-         outputContainer->Add(fhMCNeutral1pOverER02);
-       }
+    
+    fhMCEle1pOverE = new TH2F("hMCEle1pOverE","TRACK matches p/E, MC electrons",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
+    fhMCEle1pOverE->SetYTitle("p/E");
+    fhMCEle1pOverE->SetXTitle("p_{T} (GeV/c)");
+    outputContainer->Add(fhMCEle1pOverE);
+    
+    fhMCEle1dR = new TH1F("hMCEle1dR","TRACK matches dR, MC electrons",ndRbins,dRmin,dRmax);
+    fhMCEle1dR->SetXTitle("#Delta R (rad)");
+    outputContainer->Add(fhMCEle1dR) ;
+    
+    fhMCEle2MatchdEdx = new TH2F("hMCEle2MatchdEdx","dE/dx vs. p for all matches, MC electrons",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
+    fhMCEle2MatchdEdx->SetXTitle("p (GeV/c)");
+    fhMCEle2MatchdEdx->SetYTitle("<dE/dx>");
+    outputContainer->Add(fhMCEle2MatchdEdx);
+    
+    fhMCChHad1pOverE = new TH2F("hMCChHad1pOverE","TRACK matches p/E, MC charged hadrons",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
+    fhMCChHad1pOverE->SetYTitle("p/E");
+    fhMCChHad1pOverE->SetXTitle("p_{T} (GeV/c)");
+    outputContainer->Add(fhMCChHad1pOverE);
+    
+    fhMCChHad1dR = new TH1F("hMCChHad1dR","TRACK matches dR, MC charged hadrons",ndRbins,dRmin,dRmax);
+    fhMCChHad1dR->SetXTitle("#Delta R (rad)");
+    outputContainer->Add(fhMCChHad1dR) ;
+    
+    fhMCChHad2MatchdEdx = new TH2F("hMCChHad2MatchdEdx","dE/dx vs. p for all matches, MC charged hadrons",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
+    fhMCChHad2MatchdEdx->SetXTitle("p (GeV/c)");
+    fhMCChHad2MatchdEdx->SetYTitle("<dE/dx>");
+    outputContainer->Add(fhMCChHad2MatchdEdx);
+    
+    fhMCNeutral1pOverE = new TH2F("hMCNeutral1pOverE","TRACK matches p/E, MC neutrals",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
+    fhMCNeutral1pOverE->SetYTitle("p/E");
+    fhMCNeutral1pOverE->SetXTitle("p_{T} (GeV/c)");
+    outputContainer->Add(fhMCNeutral1pOverE);
+    
+    fhMCNeutral1dR = new TH1F("hMCNeutral1dR","TRACK matches dR, MC neutrals",ndRbins,dRmin,dRmax);
+    fhMCNeutral1dR->SetXTitle("#Delta R (rad)");
+    outputContainer->Add(fhMCNeutral1dR) ;
+    
+    fhMCNeutral2MatchdEdx = new TH2F("hMCNeutral2MatchdEdx","dE/dx vs. p for all matches, MC neutrals",nptbins,ptmin,ptmax,ndedxbins,dedxmin,dedxmax);
+    fhMCNeutral2MatchdEdx->SetXTitle("p (GeV/c)");
+    fhMCNeutral2MatchdEdx->SetYTitle("<dE/dx>");
+    outputContainer->Add(fhMCNeutral2MatchdEdx);
+    
+    fhMCEle1pOverER02 = new TH2F("hMCEle1pOverER02","TRACK matches p/E, MC electrons",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
+    fhMCEle1pOverER02->SetYTitle("p/E");
+    fhMCEle1pOverER02->SetXTitle("p_{T} (GeV/c)");
+    outputContainer->Add(fhMCEle1pOverER02);
+    
+    fhMCChHad1pOverER02 = new TH2F("hMCChHad1pOverER02","TRACK matches p/E, MC charged hadrons",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
+    fhMCChHad1pOverER02->SetYTitle("p/E");
+    fhMCChHad1pOverER02->SetXTitle("p_{T} (GeV/c)");
+    outputContainer->Add(fhMCChHad1pOverER02);
+    
+    fhMCNeutral1pOverER02 = new TH2F("hMCNeutral1pOverER02","TRACK matches p/E, MC neutrals",nptbins,ptmin,ptmax, nPoverEbins,pOverEmin,pOverEmax);
+    fhMCNeutral1pOverER02->SetYTitle("p/E");
+    fhMCNeutral1pOverER02->SetXTitle("p_{T} (GeV/c)");
+    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;
+  return outputContainer;
 }
 
 //_______________________________________________________________________________________________________________________________________
@@ -1126,16 +1233,13 @@ 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");
+  
 }
 
 
@@ -1151,7 +1255,9 @@ void AliAnaCalorimeterQA::InitParameters()
   fNRCU        = 2;  // set maximum number of RCU in EMCAL per SM
   fTimeCutMin  = -1;
   fTimeCutMax  = 9999999;
-       
+  fEMCALCellAmpMin = 0.0;
+  fPHOSCellAmpMin  = 0.0;
+  
   fHistoPOverEBins     = 100 ;  fHistoPOverEMax     = 10.  ;  fHistoPOverEMin     = 0. ;
   fHistodEdxBins       = 200 ;  fHistodEdxMax       = 400. ;  fHistodEdxMin       = 0. ;  
   fHistodRBins         = 300 ;  fHistodRMax         = 3.15 ;  fHistodRMin         = 0. ;
@@ -1178,9 +1284,10 @@ 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) ;
+  printf("PHOS Min Amplitude    : %2.1f GeV/c\n", fPHOSCellAmpMin) ;
   printf("Histograms: %3.1f < p/E  < %3.1f, Nbin = %d\n", fHistoPOverEMin, fHistoPOverEMax, fHistoPOverEBins);
   printf("Histograms: %3.1f < dEdx < %3.1f, Nbin = %d\n", fHistodEdxMin,   fHistodEdxMax,   fHistodEdxBins);
   printf("Histograms: %3.1f < dR (track cluster)   < %3.1f, Nbin = %d\n", fHistodRMin,     fHistodRMax,     fHistodRBins);
@@ -1199,168 +1306,171 @@ void AliAnaCalorimeterQA::Print(const Option_t * opt) const
 void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms() 
 {
   //Fill Calorimeter QA histograms
-       TLorentzVector mom ;
-       TLorentzVector mom2 ;
-       TRefArray * caloClusters = new TRefArray();
-       Int_t nLabel = 0;
-       Int_t *labels=0x0;
-       Int_t nCaloClusters = 0;
-       Int_t nCaloCellsPerCluster = 0;
-       Int_t nTracksMatched = 0;
-       Int_t trackIndex = 0;
-       Int_t nModule = -1;
+  TLorentzVector mom  ;
+  TLorentzVector mom2 ;
+  TObjArray * caloClusters = NULL;
+  Int_t nLabel = 0;
+  Int_t *labels=0x0;
+  Int_t nCaloClusters = 0;
+  Int_t nCaloClustersAccepted = 0;
+  Int_t nCaloCellsPerCluster = 0;
+  Int_t nTracksMatched = 0;
+  Int_t trackIndex = 0;
+  Int_t nModule = -1;
+  
+  //Get vertex for photon momentum calculation and event selection
+  Double_t v[3] = {0,0,0}; //vertex ;
+  GetReader()->GetVertex(v);
+  if (TMath::Abs(v[2]) > GetZvertexCut()) return ;  
   
   //Play with the MC stack if available        
   //Get the MC arrays and do some checks
-       if(IsDataMC()){
-               if(GetReader()->ReadStack()){
+  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) ;
+      for(Int_t i=0 ; i<GetMCStack()->GetNprimary(); i++){//Only primary particles, for all MC transport put GetNtrack()
+        TParticle *primary = GetMCStack()->Particle(i) ;
         //printf("i %d, %s: status = %d, primary? %d\n",i, primary->GetName(), primary->GetStatusCode(), primary->IsPrimary());
-                               if (primary->GetStatusCode() > 11) continue; //Working for PYTHIA and simple generators, check for HERWIG 
-                               primary->Momentum(mom);
-                               MCHistograms(mom,TMath::Abs(primary->GetPdgCode()));
-                       } //primary loop
-               }
-               else if(GetReader()->ReadAODMCParticles()){
+        if (primary->GetStatusCode() > 11) continue; //Working for PYTHIA and simple generators, check for HERWIG 
+        primary->Momentum(mom);
+        MCHistograms(mom,TMath::Abs(primary->GetPdgCode()));
+      } //primary loop
+    }
+    else if(GetReader()->ReadAODMCParticles()){
+      
+      if(!GetReader()->GetAODMCParticles(0))   
+        AliFatal("AODMCParticles not available!");
       
-                       if(!GetReader()->GetAODMCParticles(0))  {
-                               printf("AliAnaPhoton::MakeAnalysisFillHistograms() -  AODMCParticles not available!\n");
-                               abort();
-                       }
       //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) ;
+      for(Int_t i=0 ; i < (GetReader()->GetAODMCParticles(0))->GetEntriesFast(); i++){
+        AliAODMCParticle *aodprimary = (AliAODMCParticle*) (GetReader()->GetAODMCParticles(0))->At(i) ;
         //printf("i %d, %s: primary? %d physical primary? %d, flag %d\n",
         //        i,(TDatabasePDG::Instance()->GetParticle(aodprimary->GetPdgCode()))->GetName(), 
         //        aodprimary->IsPrimary(), aodprimary->IsPhysicalPrimary(), aodprimary->GetFlag());
-                               if (!aodprimary->IsPrimary()) continue; //accept all which is not MC transport generated. Don't know how to avoid partons
+        if (!aodprimary->IsPrimary()) continue; //accept all which is not MC transport generated. Don't know how to avoid partons
         //aodprimary->Momentum(mom);
-                               mom.SetPxPyPzE(aodprimary->Px(),aodprimary->Py(),aodprimary->Pz(),aodprimary->E());
-                               MCHistograms(mom,TMath::Abs(aodprimary->GetPdgCode()));
-                       } //primary loop
-                       
-               }
-       }// is data and MC      
-       
-       
+        mom.SetPxPyPzE(aodprimary->Px(),aodprimary->Py(),aodprimary->Pz(),aodprimary->E());
+        MCHistograms(mom,TMath::Abs(aodprimary->GetPdgCode()));
+      } //primary loop
+      
+    }
+  }// is data and MC   
+  
+  
   //Get List with CaloClusters  
-       
-  if     (fCalorimeter == "EMCAL") GetReader()->GetInputEvent()->GetEMCALClusters(caloClusters);//GetAODEMCAL();
-  else if(fCalorimeter == "PHOS") GetReader()->GetInputEvent()->GetPHOSClusters (caloClusters);//GetAODPHOS();
+  if      (fCalorimeter == "PHOS")  caloClusters = GetPHOSClusters();
+  else if (fCalorimeter == "EMCAL") caloClusters = GetEMCALClusters();
   else 
     AliFatal(Form("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data()));
-       
-       if(!caloClusters) 
-               AliFatal(Form("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - No CaloClusters available\n"));
-       
-  //----------------------------------------------------------
-  //Correlate Calorimeters
-  //----------------------------------------------------------
-       if(fCorrelateCalos)     CorrelateCalorimeters(caloClusters);
   
-       
-  //----------------------------------------------------------
-  // CALOCLUSTERS
-  //----------------------------------------------------------
-       
-       nCaloClusters = caloClusters->GetEntriesFast() ; 
-       fhNClusters->Fill(nCaloClusters);
-       Int_t *nClustersInModule = new Int_t[fNModules];
-       for(Int_t imod = 0; imod < fNModules; imod++ ) nClustersInModule[imod] = 0;
-       
-       if(GetDebug() > 0)
-               printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - In %s there are %d clusters \n", fCalorimeter.Data(), nCaloClusters);
-       
-  //Get vertex for photon momentum calculation
-       Double_t v[3] = {0,0,0}; //vertex ;
-       GetReader()->GetVertex(v);
-       AliVTrack * track = 0x0;
-       
-       Float_t pos[3] ;
-       Float_t showerShape[3] ;
-       Double_t tof = 0;
-  //Loop over CaloClusters
-  //if(nCaloClusters > 0)printf("QA  : Vertex Cut passed %f, cut %f, entries %d, %s\n",v[2], 40., nCaloClusters, fCalorimeter.Data());
-       for(Int_t iclus = 0; iclus < nCaloClusters; iclus++){
-               
-               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 =  GetReader()->GetInputEvent()->GetPHOSCells();
-                       else                               cell =  GetReader()->GetInputEvent()->GetEMCALCells();
-                       
-      //Check if the cluster contains any bad channel or it is close to the calorimeter borders
-                       if( GetCaloUtils()->ClusterContainsBadChannel(fCalorimeter,clus->GetCellsAbsId(), clus->GetNCells())) continue; 
-                       if(!GetCaloUtils()->CheckCellFiducialRegion(clus, cell, GetReader()->GetInputEvent(), 0)) continue;
-      //Recalibrate the cluster energy 
-                       if( GetCaloUtils()->IsRecalibrationOn())        {
-                               Float_t energy = GetCaloUtils()->RecalibrateClusterEnergy(clus, cell);
-                               clus->SetE(energy);
-                       }
-                       
+  //  if     (fCalorimeter == "EMCAL") GetReader()->GetInputEvent()->GetEMCALClusters(caloClusters);//GetEMCALClusters();
+  //  else if(fCalorimeter == "PHOS")  GetReader()->GetInputEvent()->GetPHOSClusters (caloClusters);//GetPHOSClusters();
+  //  else 
+  //    AliFatal(Form("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data()));
+  
+  if(!caloClusters) {
+    AliFatal(Form("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - No CaloClusters available\n"));
+  }
+  else{
+    //----------------------------------------------------------
+    //Correlate Calorimeters and V0 and track Multiplicity
+    //----------------------------------------------------------
+    if(fCorrelate)     Correlate();
+    
+    //----------------------------------------------------------
+    // CALOCLUSTERS
+    //----------------------------------------------------------
+    
+    nCaloClusters = caloClusters->GetEntriesFast() ; 
+    Int_t *nClustersInModule = new Int_t[fNModules];
+    for(Int_t imod = 0; imod < fNModules; imod++ ) nClustersInModule[imod] = 0;
+    
+    if(GetDebug() > 0)
+      printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - In %s there are %d clusters \n", fCalorimeter.Data(), nCaloClusters);
+    
+    AliVTrack * track = 0x0;
+    Float_t pos[3] ;
+    Float_t showerShape[3] ;
+    Double_t tof = 0;
+    //Loop over CaloClusters
+    //if(nCaloClusters > 0)printf("QA  : Vertex Cut passed %f, cut %f, entries %d, %s\n",v[2], 40., nCaloClusters, fCalorimeter.Data());
+    for(Int_t iclus = 0; iclus < nCaloClusters; iclus++){
+      
+      if(GetDebug() > 0) printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - cluster: %d/%d, data %d \n",
+                                iclus+1,nCaloClusters,GetReader()->GetDataType());
+      
+      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;
-                       
+      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;
+      Bool_t in = kTRUE;
+      if(IsFiducialCutOn()) in =  GetFiducialCut()->IsInFiducialCut(mom,fCalorimeter) ;
+      if(!in) continue;
+      
       //Get module of cluster
-                       nModule = GetModuleNumber(clus);
-                       if(nModule < fNModules) nClustersInModule[nModule]++;
+      nCaloClustersAccepted++;
+      nModule = GetModuleNumber(clus);
+      if(nModule >=0 && nModule < fNModules) nClustersInModule[nModule]++;
+      
       //MC labels
-                       nLabel = clus->GetNLabels();
-                       labels = clus->GetLabels();
+      nLabel = clus->GetNLabels();
+      labels = clus->GetLabels();
+      
       //Cells per cluster
-                       nCaloCellsPerCluster =  clus->GetNCells();
+      nCaloCellsPerCluster =  clus->GetNCells();
       //if(mom.E() > 10 && nCaloCellsPerCluster == 1 ) printf("%s:************** E = %f ********** ncells = %d\n",fCalorimeter.Data(), mom.E(),nCaloCellsPerCluster);
+      
       //matched cluster with tracks
-                       nTracksMatched = clus->GetNTracksMatched();
-                       trackIndex     = clus->GetTrackMatchedIndex();
-                       if(trackIndex >= 0){
-                               track = (AliVTrack*)GetReader()->GetInputEvent()->GetTrack(trackIndex);
-                       }
-                       else{
-                               if(nTracksMatched == 1) nTracksMatched = 0;
-                               track = 0;
-                       }
-                       
+      nTracksMatched = clus->GetNTracksMatched();
+      if(GetReader()->GetDataType() == AliCaloTrackReader::kESD){
+        trackIndex     = clus->GetTrackMatchedIndex();
+        if(trackIndex >= 0){
+          track = (AliVTrack*)GetReader()->GetInputEvent()->GetTrack(trackIndex);
+        }
+        else{
+          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();
+      showerShape[0] = clus->GetM20();
+      showerShape[1] = clus->GetM02();
+      showerShape[2] = clus->GetDispersion();
       
       //======================
       //Cells in cluster
       //======================
       
       //Get list of contributors
-                       UShort_t * indexList = clus->GetCellsAbsId() ;
+      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 ;
+      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++) {
+      for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
         //     printf("Index %d\n",ipos);
-                         absId  = indexList[ipos]; 
-                         
+        absId  = indexList[ipos]; 
+        
         //Get position of cell compare to cluster
         if(fFillAllPosHisto){
           if(fCalorimeter=="EMCAL" && GetCaloUtils()->IsEMCALGeoMatrixSet()){
@@ -1419,38 +1529,70 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
             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("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);
-                         
+        if(cell->GetCellAmplitude(absId) > emax) {
+          imax = ipos;
+          emax = cell->GetCellAmplitude(absId);
+          tmax = cell->GetCellTime(absId);
+        } 
         
-                       }// cluster cell loop
-                       
+      }// 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);
+          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 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
-                       if(nCaloCellsPerCluster > 1){
-                         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
+      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);     
       
       
@@ -1460,103 +1602,101 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
       if(GetDebug()>1) printf("Invariant mass \n");
       
       //do not do for bad vertex
-      Float_t fZvtxCut = 40. ; 
-      if(v[2]<-fZvtxCut || v[2]> fZvtxCut) continue ; //Event can not be used (vertex, centrality,... cuts not fulfilled)
+      // 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);
-                                       AliVCaloCells  * cell2 = 0x0; 
-                                       if(fCalorimeter == "PHOS") cell2 =  GetReader()->GetInputEvent()->GetPHOSCells();
-                                       else                               cell2 =  GetReader()->GetInputEvent()->GetEMCALCells();
-          //Check if the cluster contains any bad channel or it is close to calorimeter borders
-                                       if( GetCaloUtils()->ClusterContainsBadChannel(fCalorimeter,clus2->GetCellsAbsId(), clus2->GetNCells())) continue;
-                                       if(!GetCaloUtils()->CheckCellFiducialRegion(clus2, cell2, GetReader()->GetInputEvent(), 0)) continue;
+          AliVCluster* clus2 =  (AliVCluster*)caloClusters->At(jclus);
           
           //Get cluster kinematics
-                                       clus2->GetMomentum(mom2,v);
+          clus2->GetMomentum(mom2,v);
           //Check only certain regions
-                                       Bool_t in2 = kTRUE;
-                                       if(IsFiducialCutOn()) in2 =  GetFiducialCut()->IsInFiducialCut(mom2,fCalorimeter) ;
-                                       if(!in2) continue;      
+          Bool_t in2 = kTRUE;
+          if(IsFiducialCutOn()) in2 =  GetFiducialCut()->IsInFiducialCut(mom2,fCalorimeter) ;
+          if(!in2) continue;   
           //Get module of cluster
-                                       nModule2 = GetModuleNumber(clus2);
+          nModule2 = GetModuleNumber(clus2);
           //Cells per cluster
-                                       nCaloCellsPerCluster2 = clus2->GetNCells();
+          nCaloCellsPerCluster2 = clus2->GetNCells();
         }
         //Fill invariant mass histograms
         //All modules
         
         //printf("QA : Fill inv mass histo: pt1 %f, pt2 %f, pt12 %f, mass %f, calo %s \n",mom.Pt(),mom2.Pt(),(mom+mom2).Pt(),(mom+mom2).M(), fCalorimeter.Data());
-                               fhIM  ->Fill((mom+mom2).Pt(),(mom+mom2).M());
+        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());
+        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) {
+        if(nCaloCellsPerCluster > 1 && nCaloCellsPerCluster2 > 1) {
           //All modules
-                                 fhIMCellCut  ->Fill((mom+mom2).Pt(),(mom+mom2).M());
+          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());
-                               }
+          if(nModule == nModule2 && nModule >=0 && nModule < fNModules)
+            fhIMCellCutMod[nModule]->Fill((mom+mom2).Pt(),(mom+mom2).M());
+        }
         
         //Asymetry histograms
-        if(fFillAllTH12) fhAsym->Fill((mom+mom2).Pt(),TMath::Abs((mom.E()-mom2.E())/(mom.E()+mom2.E())));
+        fhAsym->Fill((mom+mom2).Pt(),TMath::Abs((mom.E()-mom2.E())/(mom.E()+mom2.E())));
         
-                       }// 2nd cluster loop
-               }////more than 1 cluster in calorimeter         
-       }//cluster loop
-       
-  //Number of clusters per module
-       for(Int_t imod = 0; imod < fNModules; imod++ ){ 
-               if(GetDebug() > 1) 
-                       printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - module %d calo %s clusters %d\n", imod, fCalorimeter.Data(), nClustersInModule[imod]); 
-               fhNClustersMod[imod]->Fill(nClustersInModule[imod]);
-       }
-       delete [] nClustersInModule;
-       delete caloClusters;
+      }// 2nd cluster loop
+    }//cluster loop
+    
+    //Number of clusters histograms
+    if(nCaloClustersAccepted > 0) fhNClusters->Fill(nCaloClustersAccepted);
+    //  Number of clusters per module
+    for(Int_t imod = 0; imod < fNModules; imod++ ){ 
+      if(GetDebug() > 1) 
+        printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - module %d calo %s clusters %d\n", imod, fCalorimeter.Data(), nClustersInModule[imod]); 
+      fhNClustersMod[imod]->Fill(nClustersInModule[imod]);
+    }
+    delete [] nClustersInModule;
+    //delete caloClusters;
+  }// calo clusters array exists
   
   //----------------------------------------------------------
   // CALOCELLS
   //----------------------------------------------------------
-       
-       Int_t *nCellsInModule = new Int_t[fNModules];
-       for(Int_t imod = 0; imod < fNModules; imod++ ) nCellsInModule[imod] = 0;
-       Int_t icol     = -1;
-       Int_t irow     = -1;
-       Int_t iRCU     = -1;
-       Float_t amp    = 0.;
-       Float_t time   = 0.;
-       Int_t id       = -1;
-       Float_t recalF = 1.;
-       
+         
   AliVCaloCells * cell = 0x0; 
   Int_t ncells = 0;
   if(fCalorimeter == "PHOS") 
-    cell =  GetReader()->GetInputEvent()->GetPHOSCells();
+    cell = GetPHOSCells();
   else                       
-    cell = GetReader()->GetInputEvent()->GetEMCALCells();
+    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()));
+    return; // just to trick coverity
   }
   
-  ncells = cell->GetNumberOfCells() ;
-  fhNCells->Fill(ncells) ;
   if(GetDebug() > 0) 
-    printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - In ESD %s cell entries %d\n", fCalorimeter.Data(), ncells);    
+    printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - %s cell entries %d\n", fCalorimeter.Data(), cell->GetNumberOfCells());    
   
-  for (Int_t iCell = 0; iCell < ncells; iCell++) {      
-    if(GetDebug() > 2)  printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Cell : amp %f, absId %d \n", cell->GetAmplitude(iCell), cell->GetCellNumber(iCell));
+  //Init arrays and used variables
+  Int_t *nCellsInModule = new Int_t[fNModules];
+  for(Int_t imod = 0; imod < fNModules; imod++ ) nCellsInModule[imod] = 0;
+  Int_t icol     = -1;
+  Int_t irow     = -1;
+  Int_t iRCU     = -1;
+  Float_t amp    = 0.;
+  Float_t time   = 0.;
+  Int_t id       = -1;
+  Float_t recalF = 1.;  
+  
+  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));
     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
       if(GetCaloUtils()->IsBadChannelsRemovalSwitchedOn()){
         if(fCalorimeter=="EMCAL"){
@@ -1568,38 +1708,28 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
             continue;
           }
         }
-      }
-      
+      } // use bad channel map
+
       //Get Recalibration factor if set
       if (GetCaloUtils()->IsRecalibrationOn()) {
         if(fCalorimeter == "PHOS") recalF = GetCaloUtils()->GetPHOSChannelRecalibrationFactor(nModule,icol,irow);
-        else                          recalF = GetCaloUtils()->GetEMCALChannelRecalibrationFactor(nModule,icol,irow);
-        if(fCalorimeter == "PHOS")printf("Recalibration factor (sm,row,col)=(%d,%d,%d) -  %f\n",nModule,icol,irow,recalF);
+        else                              recalF = GetCaloUtils()->GetEMCALChannelRecalibrationFactor(nModule,icol,irow);
+        //if(fCalorimeter == "PHOS")printf("Recalibration factor (sm,row,col)=(%d,%d,%d) -  %f\n",nModule,icol,irow,recalF);
       }
       
       amp     = cell->GetAmplitude(iCell)*recalF;
       time    = cell->GetTime(iCell)*1e9;//transform time to ns
       
+      //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);
       
-      if(time < fTimeCutMin || time > fTimeCutMax) continue;
-      
-      //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"){
@@ -1607,44 +1737,62 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
         if(icol > 15 && icol < 32) ifrac = 1;
         else if(icol > 31) ifrac = 2;
         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)
@@ -1653,6 +1801,7 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
         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);
@@ -1680,7 +1829,14 @@ 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());    
+    }//nmodules
   }//cell loop
+  if(ncells > 0 )fhNCells->Fill(ncells) ; //fill the cells after the cut 
   
   //Number of cells per module
        for(Int_t imod = 0; imod < fNModules; imod++ ) {
@@ -1695,267 +1851,265 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
 }
 
 
-//__________________________________
-void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Double_t tof, Float_t *pos, Float_t *showerShape,
+//_____________________________________________________________________________________________
+void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Double_t tof, 
+                                            Float_t *pos, Float_t *showerShape,
                                             const Int_t nCaloCellsPerCluster,const Int_t nModule,
                                             const Int_t nTracksMatched,  const AliVTrack * track,  
                                             const Int_t * labels, const Int_t nLabels){
   //Fill CaloCluster related histograms
        
-       AliAODMCParticle * aodprimary  = 0x0;
-       TParticle * primary = 0x0;
+  AliAODMCParticle * aodprimary  = 0x0;
+  TParticle * primary = 0x0;
   Int_t tag = 0;       
-       
-       Float_t e   = mom.E();
-       Float_t pt  = mom.Pt();
-       Float_t eta = mom.Eta();
-       Float_t phi = mom.Phi();
-       if(phi < 0) phi +=TMath::TwoPi();
-       if(GetDebug() > 0) {
-               printf("AliAnaCalorimeterQA::ClusterHistograms() - cluster: E %2.3f, pT %2.3f, eta %2.3f, phi %2.3f \n",e,pt,eta,phi*TMath::RadToDeg());
-               if(IsDataMC()) {
+  
+  Float_t e   = mom.E();
+  Float_t pt  = mom.Pt();
+  Float_t eta = mom.Eta();
+  Float_t phi = mom.Phi();
+  if(phi < 0) phi +=TMath::TwoPi();
+  if(GetDebug() > 0) {
+    printf("AliAnaCalorimeterQA::ClusterHistograms() - cluster: E %2.3f, pT %2.3f, eta %2.3f, phi %2.3f \n",e,pt,eta,phi*TMath::RadToDeg());
+    if(IsDataMC()) {
       //printf("\t Primaries: nlabels %d, labels pointer %p\n",nLabels,labels);
-                       printf("\t Primaries: nlabels %d\n",nLabels);
-                       if(!nLabels || !labels) printf("\t Strange, no labels!!!\n");
-               }
-       }
+      printf("\t Primaries: nlabels %d\n",nLabels);
+      if(!nLabels || !labels) printf("\t Strange, no labels!!!\n");
+    }
+  }
   
-       fhE     ->Fill(e);      
-       if(nModule < fNModules) fhEMod[nModule]->Fill(e);
+  fhE     ->Fill(e);   
+  if(nModule >=0 && nModule < fNModules) fhEMod[nModule]->Fill(e);
   if(fFillAllTH12){
     fhPt     ->Fill(pt);
     fhPhi    ->Fill(phi);
     fhEta    ->Fill(eta);
   }
-       fhEtaPhiE->Fill(eta,phi,e);
+  fhEtaPhiE->Fill(eta,phi,e);
   
   //Cells per cluster
-       fhNCellsPerCluster   ->Fill(e, nCaloCellsPerCluster,eta);
-       fhNCellsPerClusterMIP->Fill(e, nCaloCellsPerCluster,eta);
+  fhNCellsPerCluster   ->Fill(e, nCaloCellsPerCluster,eta);
+  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);
-  }
-       fhClusterTimeEnergy->Fill(e,tof);
+  fhXE     ->Fill(pos[0],e);
+  fhYE     ->Fill(pos[1],e);
+  fhZE     ->Fill(pos[2],e);
+  fhXYZ    ->Fill(pos[0], pos[1],pos[2]);
+    
+  fhXNCells->Fill(pos[0],nCaloCellsPerCluster);
+  fhYNCells->Fill(pos[1],nCaloCellsPerCluster);
+  fhZNCells->Fill(pos[2],nCaloCellsPerCluster);
+  Float_t rxyz = TMath::Sqrt(pos[0]*pos[0]+pos[1]*pos[1]);//+pos[2]*pos[2]);
+  fhRE     ->Fill(rxyz,e);
+  fhRNCells->Fill(rxyz  ,nCaloCellsPerCluster);
+  
+  fhClusterTimeEnergy->Fill(e,tof);
        
   //Shower shape parameters
-       fhLambda->Fill(showerShape[0], showerShape[1], e);
-       fhDispersion->Fill(showerShape[2],e);
+  fhLambda->Fill(showerShape[0], showerShape[1], e);
+  fhDispersion->Fill(showerShape[2],e);
+  
+  if(nModule >=0 && nModule < fNModules) fhNCellsPerClusterMod[nModule]->Fill(e, nCaloCellsPerCluster);
   
-       if(nModule < fNModules) fhNCellsPerClusterMod[nModule]->Fill(e, nCaloCellsPerCluster);
-       
   //Fill histograms only possible when simulation
-       if(IsDataMC() && nLabels > 0 && labels){
+  if(IsDataMC() && nLabels > 0 && labels){
     
     //Play with the MC stack if available
-               Int_t label = labels[0];
+    Int_t label = labels[0];
     
-               if(label < 0) {
-                       if(GetDebug() >= 0) printf("AliAnaCalorimeterQA::ClusterHistograms() *** bad label ***:  label %d \n", label);
-                       return;
-               }
+    if(label < 0) {
+      if(GetDebug() >= 0) printf("AliAnaCalorimeterQA::ClusterHistograms() *** bad label ***:  label %d \n", label);
+      return;
+    }
+    
+    Int_t pdg  =-1; Int_t pdg0  =-1;Int_t status = -1; Int_t iMother = -1; Int_t iParent = -1;
+    Float_t vxMC= 0; Float_t vyMC = 0; 
+    Float_t eMC = 0; Float_t ptMC= 0; Float_t phiMC =0; Float_t etaMC = 0;
+    Int_t charge = 0;  
     
-               Int_t pdg  =-1; Int_t pdg0  =-1;Int_t status = -1; Int_t iMother = -1; Int_t iParent = -1;
-               Float_t vxMC= 0; Float_t vyMC = 0;      
-               Float_t eMC = 0; Float_t ptMC= 0; Float_t phiMC =0; Float_t etaMC = 0;
-               Int_t charge = 0;       
-               
     //Check the origin.
-               tag = GetMCAnalysisUtils()->CheckOrigin(labels,nLabels, GetReader(),0);
+    tag = GetMCAnalysisUtils()->CheckOrigin(labels,nLabels, GetReader(),0);
     
-               if(GetReader()->ReadStack() && !GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCUnknown)){ //it MC stack and known tag
+    if(GetReader()->ReadStack() && !GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCUnknown)){ //it MC stack and known tag
       
-                       if( label >= GetMCStack()->GetNtrack()) {
-                               if(GetDebug() >= 0) printf("AliAnaCalorimeterQA::ClusterHistograms() *** large label ***:  label %d, n tracks %d \n", label, GetMCStack()->GetNtrack());
-                               return ;
-                       }
-                       
-                       primary = GetMCStack()->Particle(label);
-                       iMother = label;
-                       pdg0    = TMath::Abs(primary->GetPdgCode());
-                       pdg     = pdg0;
-                       status  = primary->GetStatusCode();
-                       vxMC    = primary->Vx();
-                       vyMC    = primary->Vy();
-                       iParent = primary->GetFirstMother();
+      if( label >= GetMCStack()->GetNtrack()) {
+        if(GetDebug() >= 0) printf("AliAnaCalorimeterQA::ClusterHistograms() *** large label ***:  label %d, n tracks %d \n", label, GetMCStack()->GetNtrack());
+        return ;
+      }
+      
+      primary = GetMCStack()->Particle(label);
+      iMother = label;
+      pdg0    = TMath::Abs(primary->GetPdgCode());
+      pdg     = pdg0;
+      status  = primary->GetStatusCode();
+      vxMC    = primary->Vx();
+      vyMC    = primary->Vy();
+      iParent = primary->GetFirstMother();
       
-                       if(GetDebug() > 1 ) {
-                               printf("AliAnaCalorimeterQA::ClusterHistograms() - Cluster most contributing mother: \n");
-                               printf("\t Mother label %d, pdg %d, %s, status %d, parent %d \n",iMother, pdg0, primary->GetName(),status, iParent);
-                       }
+      if(GetDebug() > 1 ) {
+        printf("AliAnaCalorimeterQA::ClusterHistograms() - Cluster most contributing mother: \n");
+        printf("\t Mother label %d, pdg %d, %s, status %d, parent %d \n",iMother, pdg0, primary->GetName(),status, iParent);
+      }
       
       //Get final particle, no conversion products
-                       if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCConversion)){
+      if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCConversion)){
         //Get the parent
-                               primary = GetMCStack()->Particle(iParent);
-                               pdg = TMath::Abs(primary->GetPdgCode());
-                               if(GetDebug() > 1 ) printf("AliAnaCalorimeterQA::ClusterHistograms() - Converted cluster!. Find before conversion: \n");
-                               while((pdg == 22 || pdg == 11) && status != 1){
-                                       iMother = iParent;
-                                       primary = GetMCStack()->Particle(iMother);
-                                       status  = primary->GetStatusCode();
-                                       iParent = primary->GetFirstMother();
-                                       pdg     = TMath::Abs(primary->GetPdgCode());
-                                       if(GetDebug() > 1 )printf("\t pdg %d, index %d, %s, status %d \n",pdg, iMother,  primary->GetName(),status);    
-                               }       
+        primary = GetMCStack()->Particle(iParent);
+        pdg = TMath::Abs(primary->GetPdgCode());
+        if(GetDebug() > 1 ) printf("AliAnaCalorimeterQA::ClusterHistograms() - Converted cluster!. Find before conversion: \n");
+        while((pdg == 22 || pdg == 11) && status != 1){
+          iMother = iParent;
+          primary = GetMCStack()->Particle(iMother);
+          status  = primary->GetStatusCode();
+          iParent = primary->GetFirstMother();
+          pdg     = TMath::Abs(primary->GetPdgCode());
+          if(GetDebug() > 1 )printf("\t pdg %d, index %d, %s, status %d \n",pdg, iMother,  primary->GetName(),status); 
+        }      
         
-                               if(GetDebug() > 1 ) {
-                                       printf("AliAnaCalorimeterQA::ClusterHistograms() - Converted Cluster mother before conversion: \n");
-                                       printf("\t Mother label %d, pdg %d, %s, status %d, parent %d \n",iMother, pdg, primary->GetName(), status, iParent);
-                               }
+        if(GetDebug() > 1 ) {
+          printf("AliAnaCalorimeterQA::ClusterHistograms() - Converted Cluster mother before conversion: \n");
+          printf("\t Mother label %d, pdg %d, %s, status %d, parent %d \n",iMother, pdg, primary->GetName(), status, iParent);
+        }
         
-                       }
+      }
       
       //Overlapped pi0 (or eta, there will be very few), get the meson
-                       if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCPi0) || 
+      if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCPi0) || 
          GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCEta)){
-                               if(GetDebug() > 1 ) printf("AliAnaCalorimeterQA::ClusterHistograms() - Overlapped Meson decay!, Find it: \n");
-                               while(pdg != 111 && pdg != 221){
-                                       iMother = iParent;
-                                       primary = GetMCStack()->Particle(iMother);
-                                       status  = primary->GetStatusCode();
-                                       iParent = primary->GetFirstMother();
-                                       pdg     = TMath::Abs(primary->GetPdgCode());
-                                       if(GetDebug() > 1 ) printf("\t pdg %d, %s, index %d\n",pdg,  primary->GetName(),iMother);
-                                       if(iMother==-1) {
-                                               printf("AliAnaCalorimeterQA::ClusterHistograms() - Tagged as Overlapped photon but meson not found, why?\n");
+        if(GetDebug() > 1 ) printf("AliAnaCalorimeterQA::ClusterHistograms() - Overlapped Meson decay!, Find it: \n");
+        while(pdg != 111 && pdg != 221){
+          iMother = iParent;
+          primary = GetMCStack()->Particle(iMother);
+          status  = primary->GetStatusCode();
+          iParent = primary->GetFirstMother();
+          pdg     = TMath::Abs(primary->GetPdgCode());
+          if(GetDebug() > 1 ) printf("\t pdg %d, %s, index %d\n",pdg,  primary->GetName(),iMother);
+          if(iMother==-1) {
+            printf("AliAnaCalorimeterQA::ClusterHistograms() - Tagged as Overlapped photon but meson not found, why?\n");
             //break;
-                                       }
-                               }
+          }
+        }
         
-                               if(GetDebug() > 2 ) printf("AliAnaCalorimeterQA::ClusterHistograms() - Overlapped %s decay, label %d \n", 
+        if(GetDebug() > 2 ) printf("AliAnaCalorimeterQA::ClusterHistograms() - Overlapped %s decay, label %d \n", 
                                    primary->GetName(),iMother);
-                       }
+      }
       
-                       eMC    = primary->Energy();
-                       ptMC   = primary->Pt();
-                       phiMC  = primary->Phi();
-                       etaMC  = primary->Eta();
-                       pdg    = TMath::Abs(primary->GetPdgCode());
-                       charge = (Int_t) TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
+      eMC    = primary->Energy();
+      ptMC   = primary->Pt();
+      phiMC  = primary->Phi();
+      etaMC  = primary->Eta();
+      pdg    = TMath::Abs(primary->GetPdgCode());
+      charge = (Int_t) TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
       
-               }
-               else if(GetReader()->ReadAODMCParticles() && !GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCUnknown)){//it MC AOD and known tag
+    }
+    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();
-                       }               
-                       
-                       aodprimary = (AliAODMCParticle*) (GetReader()->GetAODMCParticles(0))->At(label);
-                       iMother = label;
-                       pdg0    = TMath::Abs(aodprimary->GetPdgCode());
-                       pdg     = pdg0;
-                       status  = aodprimary->IsPrimary();
-                       vxMC    = aodprimary->Xv();
-                       vyMC    = aodprimary->Yv();
-                       iParent = aodprimary->GetMother();
+      if(!GetReader()->GetAODMCParticles(0)) 
+        AliFatal("MCParticles not available!");
       
-                       if(GetDebug() > 1 ) {
-                               printf("AliAnaCalorimeterQA::ClusterHistograms() - Cluster most contributing mother: \n");
-                               printf("\t Mother label %d, pdg %d, Primary? %d, Physical Primary? %d, parent %d \n",
+      aodprimary = (AliAODMCParticle*) (GetReader()->GetAODMCParticles(0))->At(label);
+      iMother = label;
+      pdg0    = TMath::Abs(aodprimary->GetPdgCode());
+      pdg     = pdg0;
+      status  = aodprimary->IsPrimary();
+      vxMC    = aodprimary->Xv();
+      vyMC    = aodprimary->Yv();
+      iParent = aodprimary->GetMother();
+      
+      if(GetDebug() > 1 ) {
+        printf("AliAnaCalorimeterQA::ClusterHistograms() - Cluster most contributing mother: \n");
+        printf("\t Mother label %d, pdg %d, Primary? %d, Physical Primary? %d, parent %d \n",
                iMother, pdg0, aodprimary->IsPrimary(), aodprimary->IsPhysicalPrimary(), iParent);
-                       }
-                       
+      }
+      
       //Get final particle, no conversion products
-                       if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCConversion)){
-                               if(GetDebug() > 1 ) 
-                                       printf("AliAnaCalorimeterQA::ClusterHistograms() - Converted cluster!. Find before conversion: \n");
+      if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCConversion)){
+        if(GetDebug() > 1 ) 
+          printf("AliAnaCalorimeterQA::ClusterHistograms() - Converted cluster!. Find before conversion: \n");
         //Get the parent
-                               aodprimary = (AliAODMCParticle*)(GetReader()->GetAODMCParticles(0))->At(iParent);
-                               pdg = TMath::Abs(aodprimary->GetPdgCode());
-                               while ((pdg == 22 || pdg == 11) && !aodprimary->IsPhysicalPrimary()) {
-                                       iMother    = iParent;
-                                       aodprimary = (AliAODMCParticle*)(GetReader()->GetAODMCParticles(0))->At(iMother);
-                                       status     = aodprimary->IsPrimary();
-                                       iParent    = aodprimary->GetMother();
-                                       pdg        = TMath::Abs(aodprimary->GetPdgCode());
-                                       if(GetDebug() > 1 )
-                                               printf("\t pdg %d, index %d, Primary? %d, Physical Primary? %d \n",
+        aodprimary = (AliAODMCParticle*)(GetReader()->GetAODMCParticles(0))->At(iParent);
+        pdg = TMath::Abs(aodprimary->GetPdgCode());
+        while ((pdg == 22 || pdg == 11) && !aodprimary->IsPhysicalPrimary()) {
+          iMother    = iParent;
+          aodprimary = (AliAODMCParticle*)(GetReader()->GetAODMCParticles(0))->At(iMother);
+          status     = aodprimary->IsPrimary();
+          iParent    = aodprimary->GetMother();
+          pdg        = TMath::Abs(aodprimary->GetPdgCode());
+          if(GetDebug() > 1 )
+            printf("\t pdg %d, index %d, Primary? %d, Physical Primary? %d \n",
                    pdg, iMother, aodprimary->IsPrimary(), aodprimary->IsPhysicalPrimary());    
-                               }       
-                               
-                               if(GetDebug() > 1 ) {
-                                       printf("AliAnaCalorimeterQA::ClusterHistograms() - Converted Cluster mother before conversion: \n");
-                                       printf("\t Mother label %d, pdg %d, parent %d, Primary? %d, Physical Primary? %d \n",
+        }      
+        
+        if(GetDebug() > 1 ) {
+          printf("AliAnaCalorimeterQA::ClusterHistograms() - Converted Cluster mother before conversion: \n");
+          printf("\t Mother label %d, pdg %d, parent %d, Primary? %d, Physical Primary? %d \n",
                  iMother, pdg, iParent, aodprimary->IsPrimary(), aodprimary->IsPhysicalPrimary());
-                               }
-                               
-                       }
+        }
+        
+      }
       
       //Overlapped pi0 (or eta, there will be very few), get the meson
-                       if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCPi0) || 
+      if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCPi0) || 
          GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCEta)){
-                               if(GetDebug() > 1 ) printf("AliAnaCalorimeterQA::ClusterHistograms() - Overlapped Meson decay!, Find it: PDG %d, mom %d \n",pdg, iMother);
-                               while(pdg != 111 && pdg != 221){
-                                       
-                                       iMother    = iParent;
-                                       aodprimary = (AliAODMCParticle*)(GetReader()->GetAODMCParticles(0))->At(iMother);
-                                       status     = aodprimary->IsPrimary();
-                                       iParent    = aodprimary->GetMother();
-                                       pdg        = TMath::Abs(aodprimary->GetPdgCode());
+        if(GetDebug() > 1 ) printf("AliAnaCalorimeterQA::ClusterHistograms() - Overlapped Meson decay!, Find it: PDG %d, mom %d \n",pdg, iMother);
+        while(pdg != 111 && pdg != 221){
           
-                                       if(GetDebug() > 1 ) printf("\t pdg %d, index %d\n",pdg, iMother);
-                                       
-                                       if(iMother==-1) {
-                                               printf("AliAnaCalorimeterQA::ClusterHistograms() - Tagged as Overlapped photon but meson not found, why?\n");
+          iMother    = iParent;
+          aodprimary = (AliAODMCParticle*)(GetReader()->GetAODMCParticles(0))->At(iMother);
+          status     = aodprimary->IsPrimary();
+          iParent    = aodprimary->GetMother();
+          pdg        = TMath::Abs(aodprimary->GetPdgCode());
+          
+          if(GetDebug() > 1 ) printf("\t pdg %d, index %d\n",pdg, iMother);
+          
+          if(iMother==-1) {
+            printf("AliAnaCalorimeterQA::ClusterHistograms() - Tagged as Overlapped photon but meson not found, why?\n");
             //break;
-                                       }
-                               }       
-                               
-                               if(GetDebug() > 2 ) printf("AliAnaCalorimeterQA::ClusterHistograms() - Overlapped %s decay, label %d \n", 
+          }
+        }      
+        
+        if(GetDebug() > 2 ) printf("AliAnaCalorimeterQA::ClusterHistograms() - Overlapped %s decay, label %d \n", 
                                    aodprimary->GetName(),iMother);
-                       }       
+      }        
       
-                       status = aodprimary->IsPrimary();
-                       eMC    = aodprimary->E();
-                       ptMC   = aodprimary->Pt();
-                       phiMC  = aodprimary->Phi();
-                       etaMC  = aodprimary->Eta();
-                       pdg    = TMath::Abs(aodprimary->GetPdgCode());
-                       charge = aodprimary->Charge();
+      status = aodprimary->IsPrimary();
+      eMC    = aodprimary->E();
+      ptMC   = aodprimary->Pt();
+      phiMC  = aodprimary->Phi();
+      etaMC  = aodprimary->Eta();
+      pdg    = TMath::Abs(aodprimary->GetPdgCode());
+      charge = aodprimary->Charge();
       
-               }
+    }
     
     //Float_t vz = primary->Vz();
-               Float_t rVMC = TMath::Sqrt(vxMC*vxMC + vyMC*vyMC);
-               if((pdg == 22 || TMath::Abs(pdg)==11) && status!=1) {
-                       fhEMVxyz   ->Fill(vxMC,vyMC);//,vz);
-                       fhEMR      ->Fill(e,rVMC);
-               }
+    Float_t rVMC = TMath::Sqrt(vxMC*vxMC + vyMC*vyMC);
+    if((pdg == 22 || TMath::Abs(pdg)==11) && status!=1) {
+      fhEMVxyz   ->Fill(vxMC,vyMC);//,vz);
+      fhEMR      ->Fill(e,rVMC);
+    }
     
     //printf("reco e %f, pt %f, phi %f, eta %f \n", e, pt, phi, eta);
     //printf("prim e %f, pt %f, phi %f, eta %f \n", eMC,ptMC,phiMC ,etaMC );
     //printf("vertex: vx %f, vy %f, vz %f, r %f \n", vxMC, vyMC, vz, r);
     
     
-               fh2E      ->Fill(e, eMC);
-               fh2Pt     ->Fill(pt, ptMC);
-               fh2Phi    ->Fill(phi, phiMC);
-               fh2Eta    ->Fill(eta, etaMC);
-               fhDeltaE  ->Fill(eMC-e);
-               fhDeltaPt ->Fill(ptMC-pt);
-               fhDeltaPhi->Fill(phiMC-phi);
-               fhDeltaEta->Fill(etaMC-eta);
-               if(eMC   > 0) fhRatioE  ->Fill(e/eMC);
-               if(ptMC  > 0) fhRatioPt ->Fill(pt/ptMC);
-               if(phiMC > 0) fhRatioPhi->Fill(phi/phiMC);
-               if(etaMC > 0) fhRatioEta->Fill(eta/etaMC);                      
+    fh2E      ->Fill(e, eMC);
+    fh2Pt     ->Fill(pt, ptMC);
+    fh2Phi    ->Fill(phi, phiMC);
+    fh2Eta    ->Fill(eta, etaMC);
+    fhDeltaE  ->Fill(eMC-e);
+    fhDeltaPt ->Fill(ptMC-pt);
+    fhDeltaPhi->Fill(phiMC-phi);
+    fhDeltaEta->Fill(etaMC-eta);
+    if(eMC   > 0) fhRatioE  ->Fill(e/eMC);
+    if(ptMC  > 0) fhRatioPt ->Fill(pt/ptMC);
+    if(phiMC > 0) fhRatioPhi->Fill(phi/phiMC);
+    if(etaMC > 0) fhRatioEta->Fill(eta/etaMC);                 
     
     
     //Overlapped pi0 (or eta, there will be very few)
-               if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCPi0) || 
+    if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCPi0) || 
        GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCEta)){
       fhPi0E     ->Fill(e,eMC);        
       fhPi0Pt    ->Fill(pt,ptMC);
@@ -1967,8 +2121,8 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
         fhPi0PhiCharged   ->Fill(phi,phiMC);
         fhPi0EtaCharged   ->Fill(eta,etaMC);
       }
-               }//Overlapped pizero decay
-               else if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCPhoton)){
+    }//Overlapped pizero decay
+    else if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCPhoton)){
       fhGamE     ->Fill(e,eMC);        
       fhGamPt    ->Fill(pt,ptMC);
       fhGamEta   ->Fill(eta,etaMC);    
@@ -1987,135 +2141,132 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
         fhGamPhiCharged   ->Fill(phi,phiMC);
         fhGamEtaCharged   ->Fill(eta,etaMC);
       }
-               }//photon
-               else if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCElectron)){
-                       fhEleE     ->Fill(e,eMC);       
-                       fhElePt    ->Fill(pt,ptMC);
-                       fhEleEta   ->Fill(eta,etaMC);   
-                       fhElePhi   ->Fill(phi,phiMC);
-                       fhEMVxyz   ->Fill(vxMC,vyMC);//,vz);
-                       fhEMR      ->Fill(e,rVMC);
-                       if( nTracksMatched > 0){
-                               fhEleECharged     ->Fill(e,eMC);                
-                               fhElePtCharged    ->Fill(pt,ptMC);
-                               fhElePhiCharged   ->Fill(phi,phiMC);
-                               fhEleEtaCharged   ->Fill(eta,etaMC);
-                       }
-               }
-               else if(charge == 0){
-                       fhNeHadE     ->Fill(e,eMC);     
-                       fhNeHadPt    ->Fill(pt,ptMC);
-                       fhNeHadEta   ->Fill(eta,etaMC); 
-                       fhNeHadPhi   ->Fill(phi,phiMC); 
-                       fhHaVxyz     ->Fill(vxMC,vyMC);//,vz);
-                       fhHaR        ->Fill(e,rVMC);
-                       if( nTracksMatched > 0){
-                               fhNeHadECharged     ->Fill(e,eMC);              
-                               fhNeHadPtCharged    ->Fill(pt,ptMC);
-                               fhNeHadPhiCharged   ->Fill(phi,phiMC);
-                               fhNeHadEtaCharged   ->Fill(eta,etaMC);
-                       }
-               }
-               else if(charge!=0){
-                       fhChHadE     ->Fill(e,eMC);     
-                       fhChHadPt    ->Fill(pt,ptMC);
-                       fhChHadEta   ->Fill(eta,etaMC); 
-                       fhChHadPhi   ->Fill(phi,phiMC); 
-                       fhHaVxyz     ->Fill(vxMC,vyMC);//,vz);
-                       fhHaR        ->Fill(e,rVMC);
-                       if( nTracksMatched > 0){
-                               fhChHadECharged     ->Fill(e,eMC);              
-                               fhChHadPtCharged    ->Fill(pt,ptMC);
-                               fhChHadPhiCharged   ->Fill(phi,phiMC);
-                               fhChHadEtaCharged   ->Fill(eta,etaMC);
-                       }
-               }
-       }//Work with MC
+    }//photon
+    else if(GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCElectron)){
+      fhEleE     ->Fill(e,eMC);        
+      fhElePt    ->Fill(pt,ptMC);
+      fhEleEta   ->Fill(eta,etaMC);    
+      fhElePhi   ->Fill(phi,phiMC);
+      fhEMVxyz   ->Fill(vxMC,vyMC);//,vz);
+      fhEMR      ->Fill(e,rVMC);
+      if( nTracksMatched > 0){
+        fhEleECharged     ->Fill(e,eMC);               
+        fhElePtCharged    ->Fill(pt,ptMC);
+        fhElePhiCharged   ->Fill(phi,phiMC);
+        fhEleEtaCharged   ->Fill(eta,etaMC);
+      }
+    }
+    else if(charge == 0){
+      fhNeHadE     ->Fill(e,eMC);      
+      fhNeHadPt    ->Fill(pt,ptMC);
+      fhNeHadEta   ->Fill(eta,etaMC);  
+      fhNeHadPhi   ->Fill(phi,phiMC);  
+      fhHaVxyz     ->Fill(vxMC,vyMC);//,vz);
+      fhHaR        ->Fill(e,rVMC);
+      if( nTracksMatched > 0){
+        fhNeHadECharged     ->Fill(e,eMC);             
+        fhNeHadPtCharged    ->Fill(pt,ptMC);
+        fhNeHadPhiCharged   ->Fill(phi,phiMC);
+        fhNeHadEtaCharged   ->Fill(eta,etaMC);
+      }
+    }
+    else if(charge!=0){
+      fhChHadE     ->Fill(e,eMC);      
+      fhChHadPt    ->Fill(pt,ptMC);
+      fhChHadEta   ->Fill(eta,etaMC);  
+      fhChHadPhi   ->Fill(phi,phiMC);  
+      fhHaVxyz     ->Fill(vxMC,vyMC);//,vz);
+      fhHaR        ->Fill(e,rVMC);
+      if( nTracksMatched > 0){
+        fhChHadECharged     ->Fill(e,eMC);             
+        fhChHadPtCharged    ->Fill(pt,ptMC);
+        fhChHadPhiCharged   ->Fill(phi,phiMC);
+        fhChHadEtaCharged   ->Fill(eta,etaMC);
+      }
+    }
+  }//Work with MC
   
        
   //Match tracks and clusters
   //To be Modified in case of AODs
-       
-  //if(ntracksmatched==1 && trackIndex==-1) ntracksmatched=0;
-       
-       if( nTracksMatched > 0){
+               
+  if( nTracksMatched > 0){
     if(fFillAllTH12){
       fhECharged      ->Fill(e);       
       fhPtCharged     ->Fill(pt);
       fhPhiCharged    ->Fill(phi);
       fhEtaCharged    ->Fill(eta);
     }
-               fhEtaPhiECharged->Fill(eta,phi,e);              
-               fhNCellsPerClusterMIPCharged->Fill(e, nCaloCellsPerCluster,eta);
-               
+    fhEtaPhiECharged->Fill(eta,phi,e);         
+    fhNCellsPerClusterMIPCharged->Fill(e, nCaloCellsPerCluster,eta);
+    
     //printf("track index %d ntracks %d\n", esd->GetNumberOfTracks()); 
     //Study the track and matched cluster if track exists.
-               if(!track) return;
-               Double_t emcpos[3] = {0.,0.,0.};
-               Double_t emcmom[3] = {0.,0.,0.};
-               Double_t radius    = 441.0; //[cm] EMCAL radius +13cm
-               Double_t bfield    = 0.;
-               Double_t tphi      = 0;
-               Double_t teta      = 0;
-               Double_t tmom      = 0;
-               Double_t tpt       = 0;
-               Double_t tmom2     = 0;
-               Double_t tpcSignal = 0;
-               Bool_t okpos = kFALSE;
-               Bool_t okmom = kFALSE;
-               Bool_t okout = kFALSE;
-               Int_t nITS   = 0;
-               Int_t nTPC   = 0;
-               
+    if(!track) return;
+    Double_t emcpos[3] = {0.,0.,0.};
+    Double_t emcmom[3] = {0.,0.,0.};
+    Double_t radius    = 441.0; //[cm] EMCAL radius +13cm
+    Double_t bfield    = 0.;
+    Double_t tphi      = 0;
+    Double_t teta      = 0;
+    Double_t tmom      = 0;
+    Double_t tpt       = 0;
+    Double_t tmom2     = 0;
+    Double_t tpcSignal = 0;
+    Bool_t okpos = kFALSE;
+    Bool_t okmom = kFALSE;
+    Bool_t okout = kFALSE;
+    Int_t nITS   = 0;
+    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;
@@ -2174,31 +2325,22 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
       if(GetDebug() >= 0) printf("No ESD external param or AliAODPid \n");
       
     }//No out params
-       }//matched clusters with tracks
+  }//matched clusters with tracks
   
 }// 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);
-  }
+void AliAnaCalorimeterQA::Correlate(){
+  // Correlate information from PHOS and EMCAL and with V0 and track multiplicity
+  //Clusters 
+  TObjArray * caloClustersEMCAL = GetEMCALClusters();
+  TObjArray * caloClustersPHOS  = GetPHOSClusters();
   
-  //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;
@@ -2206,89 +2348,133 @@ void AliAnaCalorimeterQA::CorrelateCalorimeters(TRefArray* refArray){
     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 = GetReader()->GetInputEvent()->GetEMCALCells();
-  AliVCaloCells * cellsPHOS  = GetReader()->GetInputEvent()->GetPHOSCells();
-  fhCaloCorrNCells   ->Fill(cellsEMCAL->GetNumberOfCells(),cellsPHOS->GetNumberOfCells());
+  AliVCaloCells * cellsEMCAL = GetEMCALCells();
+  AliVCaloCells * cellsPHOS  = GetPHOSCells();
+
+  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);
   }
-       
-       delete caloClustersEMCAL;
-       delete caloClustersPHOS;
-       
 }
 
+
 //______________________________________________________________________________
 void AliAnaCalorimeterQA::MCHistograms(const TLorentzVector mom, const Int_t pdg){
   //Fill pure monte carlo related histograms
        
-       Float_t eMC    = mom.E();
-       Float_t ptMC   = mom.Pt();
-       Float_t phiMC  = mom.Phi();
-       if(phiMC < 0) 
-               phiMC  += TMath::TwoPi();
-       Float_t etaMC  = mom.Eta();
-       
-       if (TMath::Abs(etaMC) > 1) return;
+  Float_t eMC    = mom.E();
+  Float_t ptMC   = mom.Pt();
+  Float_t phiMC  = mom.Phi();
+  if(phiMC < 0) 
+    phiMC  += TMath::TwoPi();
+  Float_t etaMC  = mom.Eta();
+  
+  if (TMath::Abs(etaMC) > 1) return;
+  
+  Bool_t in = kTRUE;
+  if(IsFiducialCutOn()) in =  GetFiducialCut()->IsInFiducialCut(mom,fCalorimeter) ;
+  
+  if (pdg==22) {
+    fhGenGamPt ->Fill(ptMC);
+    fhGenGamEta->Fill(etaMC);
+    fhGenGamPhi->Fill(phiMC);
+    if(in){
+      fhGenGamAccE  ->Fill(eMC);
+      fhGenGamAccPt ->Fill(ptMC);
+      fhGenGamAccEta->Fill(etaMC);
+      fhGenGamAccPhi->Fill(phiMC);                                     
+    }
+  }
+  else if (pdg==111) {
+    fhGenPi0Pt ->Fill(ptMC);
+    fhGenPi0Eta->Fill(etaMC);
+    fhGenPi0Phi->Fill(phiMC);
+    if(in){
+      fhGenPi0AccE  ->Fill(eMC);                                       
+      fhGenPi0AccPt ->Fill(ptMC);
+      fhGenPi0AccEta->Fill(etaMC);
+      fhGenPi0AccPhi->Fill(phiMC);                                     
+    }
+  }
+  else if (pdg==221) {
+    fhGenEtaPt ->Fill(ptMC);
+    fhGenEtaEta->Fill(etaMC);
+    fhGenEtaPhi->Fill(phiMC);
+  }
+  else if (pdg==223) {
+    fhGenOmegaPt ->Fill(ptMC);
+    fhGenOmegaEta->Fill(etaMC);
+    fhGenOmegaPhi->Fill(phiMC);
+  }
+  else if (TMath::Abs(pdg)==11) {
+    fhGenElePt ->Fill(ptMC);
+    fhGenEleEta->Fill(etaMC);
+    fhGenElePhi->Fill(phiMC);
+  }    
   
-       Bool_t in = kTRUE;
-       if(IsFiducialCutOn()) in =  GetFiducialCut()->IsInFiducialCut(mom,fCalorimeter) ;
-       
-       if (pdg==22) {
-               fhGenGamPt ->Fill(ptMC);
-               fhGenGamEta->Fill(etaMC);
-               fhGenGamPhi->Fill(phiMC);
-               if(in){
-                       fhGenGamAccE  ->Fill(eMC);
-                       fhGenGamAccPt ->Fill(ptMC);
-                       fhGenGamAccEta->Fill(etaMC);
-                       fhGenGamAccPhi->Fill(phiMC);                                    
-               }
-       }
-       else if (pdg==111) {
-               fhGenPi0Pt ->Fill(ptMC);
-               fhGenPi0Eta->Fill(etaMC);
-               fhGenPi0Phi->Fill(phiMC);
-               if(in){
-                       fhGenPi0AccE  ->Fill(eMC);                                      
-                       fhGenPi0AccPt ->Fill(ptMC);
-                       fhGenPi0AccEta->Fill(etaMC);
-                       fhGenPi0AccPhi->Fill(phiMC);                                    
-               }
-       }
-       else if (pdg==221) {
-               fhGenEtaPt ->Fill(ptMC);
-               fhGenEtaEta->Fill(etaMC);
-               fhGenEtaPhi->Fill(phiMC);
-       }
-       else if (pdg==223) {
-               fhGenOmegaPt ->Fill(ptMC);
-               fhGenOmegaEta->Fill(etaMC);
-               fhGenOmegaPhi->Fill(phiMC);
-       }
-       else if (TMath::Abs(pdg)==11) {
-               fhGenElePt ->Fill(ptMC);
-               fhGenEleEta->Fill(etaMC);
-               fhGenElePhi->Fill(phiMC);
-       }       
-       
 }
 
 //________________________________________________________________________
@@ -2299,55 +2485,55 @@ void AliAnaCalorimeterQA::ReadHistograms(TList* outputList)
        
   // Histograms of this analsys are kept in the same list as other analysis, recover the position of
   // the first one and then add the next 
-       Int_t index = outputList->IndexOf(outputList->FindObject(GetAddedHistogramsStringToName()+"hE"));
+  Int_t index = outputList->IndexOf(outputList->FindObject(GetAddedHistogramsStringToName()+"hE"));
   //printf("Calo: %s, index: %d, nmodules %d\n",fCalorimeter.Data(),index,fNModules);
-       
+  
   //Read histograms, must be in the same order as in GetCreateOutputObject.
-       fhE       = (TH1F *) outputList->At(index++);   
+  fhE       = (TH1F *) outputList->At(index++);        
   if(fFillAllTH12){
     fhPt      = (TH1F *) outputList->At(index++); 
     fhPhi     = (TH1F *) outputList->At(index++); 
     fhEta     = (TH1F *) outputList->At(index++);
   }
-       fhEtaPhiE = (TH3F *) outputList->At(index++);
+  fhEtaPhiE = (TH3F *) outputList->At(index++);
   
-       fhClusterTimeEnergy = (TH2F*) outputList->At(index++);
-       
-       fhLambda      = (TH3F *)  outputList->At(index++);
-       fhDispersion  = (TH2F *)  outputList->At(index++);
+  fhClusterTimeEnergy = (TH2F*) outputList->At(index++);
+  
+  fhLambda      = (TH3F *)  outputList->At(index++);
+  fhDispersion  = (TH2F *)  outputList->At(index++);
   if(fFillAllTH12){
     fhECharged       = (TH1F *) outputList->At(index++);       
     fhPtCharged      = (TH1F *) outputList->At(index++); 
     fhPhiCharged     = (TH1F *) outputList->At(index++); 
     fhEtaCharged     = (TH1F *) outputList->At(index++);
   }
-       fhEtaPhiECharged = (TH3F *) outputList->At(index++);
-       
-       fh1pOverE =    (TH2F *) outputList->At(index++);
-       fh1dR =        (TH1F *) outputList->At(index++);
-       fh2MatchdEdx = (TH2F *) outputList->At(index++);
-       fh2EledEdx =   (TH2F *) outputList->At(index++);
-       fh1pOverER02 = (TH2F *) outputList->At(index++);
-       
-       fhIM        = (TH2F *) outputList->At(index++);
-       fhIMCellCut = (TH2F *) outputList->At(index++);
-  if(fFillAllTH12) fhAsym      = (TH2F *) outputList->At(index++);
-       
-       fhNCellsPerCluster           = (TH3F *) outputList->At(index++);
-       fhNCellsPerClusterMIP        = (TH3F *) outputList->At(index++);
-       fhNCellsPerClusterMIPCharged = (TH3F *) outputList->At(index++);
-       fhNClusters  = (TH1F *) outputList->At(index++); 
+  fhEtaPhiECharged = (TH3F *) outputList->At(index++);
+  
+  fh1pOverE =    (TH2F *) outputList->At(index++);
+  fh1dR =        (TH1F *) outputList->At(index++);
+  fh2MatchdEdx = (TH2F *) outputList->At(index++);
+  fh2EledEdx =   (TH2F *) outputList->At(index++);
+  fh1pOverER02 = (TH2F *) outputList->At(index++);
+  
+  fhIM        = (TH2F *) outputList->At(index++);
+  fhIMCellCut = (TH2F *) outputList->At(index++);
+  fhAsym      = (TH2F *) outputList->At(index++);
   
+  fhNCellsPerCluster           = (TH3F *) outputList->At(index++);
+  fhNCellsPerClusterMIP        = (TH3F *) outputList->At(index++);
+  fhNCellsPerClusterMIPCharged = (TH3F *) outputList->At(index++);
+  fhNClusters  = (TH1F *) outputList->At(index++); 
+  
+  fhRNCells = (TH2F *) outputList->At(index++);
+  fhXNCells = (TH2F *) outputList->At(index++);
+  fhYNCells = (TH2F *) outputList->At(index++);
+  fhZNCells = (TH2F *) outputList->At(index++);
+  fhRE   = (TH2F *) outputList->At(index++);
+  fhXE   = (TH2F *) outputList->At(index++);
+  fhYE   = (TH2F *) outputList->At(index++);
+  fhZE   = (TH2F *) outputList->At(index++); 
+  fhXYZ          = (TH3F *) outputList->At(index++);
   if(fFillAllPosHisto){
-    fhRNCells = (TH2F *) outputList->At(index++);
-    fhXNCells = (TH2F *) outputList->At(index++);
-    fhYNCells = (TH2F *) outputList->At(index++);
-    fhZNCells = (TH2F *) outputList->At(index++);
-    fhRE         = (TH2F *) outputList->At(index++);
-    fhXE         = (TH2F *) outputList->At(index++);
-    fhYE         = (TH2F *) outputList->At(index++);
-    fhZE         = (TH2F *) outputList->At(index++); 
-    fhXYZ        = (TH3F *) outputList->At(index++); 
     fhRCellE     = (TH2F *) outputList->At(index++);
     fhXCellE     = (TH2F *) outputList->At(index++);
     fhYCellE     = (TH2F *) outputList->At(index++);
@@ -2362,215 +2548,230 @@ void AliAnaCalorimeterQA::ReadHistograms(TList* outputList)
     fhDeltaCellClusterYE         = (TH2F *) outputList->At(index++);
     fhDeltaCellClusterZE         = (TH2F *) outputList->At(index++); 
     fhEtaPhiAmp               = (TH3F *) outputList->At(index++); 
-       }
+  }
   
-       fhNCells     = (TH1F *) outputList->At(index++); 
-       fhAmplitude  = (TH1F *) outputList->At(index++); 
-       fhAmpId      = (TH2F *) outputList->At(index++); 
+  fhNCells     = (TH1F *) outputList->At(index++); 
+  fhAmplitude  = (TH1F *) outputList->At(index++); 
+  fhAmpId      = (TH2F *) outputList->At(index++); 
   
-       if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
-               
-               fhCellTimeSpreadRespectToCellMax = (TH1F *) outputList->At(index++);
-               fhCellIdCellLargeTimeSpread      = (TH1F *) outputList->At(index++);
+  if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
+    
+    fhCellTimeSpreadRespectToCellMax = (TH1F *) outputList->At(index++);
+    fhCellIdCellLargeTimeSpread      = (TH1F *) outputList->At(index++);
+    
+    fhTime       = (TH1F *) outputList->At(index++); 
+    fhTimeId     = (TH2F *) outputList->At(index++); 
+    fhTimeAmp    = (TH2F *) outputList->At(index++); 
     
-               fhTime       = (TH1F *) outputList->At(index++); 
-               fhTimeId     = (TH2F *) outputList->At(index++); 
-               fhTimeAmp    = (TH2F *) outputList->At(index++); 
-               
     //         fhT0Time       = (TH1F *) outputList->At(index++); 
     //         fhT0TimeId     = (TH2F *) outputList->At(index++); 
     //         fhT0TimeAmp    = (TH2F *) outputList->At(index++); 
-               
-       }
-       
-       
-       if(fCorrelateCalos){
-               fhCaloCorrNClusters = (TH2F *) outputList->At(index++);
-               fhCaloCorrEClusters = (TH2F *) outputList->At(index++); 
-               fhCaloCorrNCells    = (TH2F *) outputList->At(index++); 
-               fhCaloCorrECells    = (TH2F *) outputList->At(index++); 
-       }
-       
+    
+  }
+  
+  
+  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
-       fhEMod                 = new TH1F*[fNModules];
-       fhNClustersMod         = new TH1F*[fNModules];
-       fhNCellsPerClusterMod  = new TH2F*[fNModules];
-       fhNCellsMod            = new TH1F*[fNModules];
-       fhGridCellsMod         = new TH2F*[fNModules];
-       fhGridCellsEMod        = new TH2F*[fNModules];
-       if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) 
-               fhGridCellsTimeMod     = new TH2F*[fNModules];
-       fhAmplitudeMod         = new TH1F*[fNModules];
-       if(fCalorimeter=="EMCAL")
-               fhAmplitudeModFraction = new TH1F*[fNModules*3];
-       
+  fhEMod                 = new TH1F*[fNModules];
+  fhNClustersMod         = new TH1F*[fNModules];
+  fhNCellsPerClusterMod  = new TH2F*[fNModules];
+  fhNCellsMod            = new TH1F*[fNModules];
+  fhGridCellsMod         = new TH2F*[fNModules];
+  fhGridCellsEMod        = new TH2F*[fNModules];
+  if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) 
+    fhGridCellsTimeMod     = new TH2F*[fNModules];
+  fhAmplitudeMod         = new TH1F*[fNModules];
+  if(fCalorimeter=="EMCAL")
+    fhAmplitudeModFraction = new TH1F*[fNModules*3];
+  
   //EMCAL
-       fhTimeAmpPerRCU        = new TH2F*[fNModules*fNRCU];
-       
-       fhIMMod                = new TH2F*[fNModules];
-       fhIMCellCutMod         = new TH2F*[fNModules];
-  
-       for(Int_t imod = 0 ; imod < fNModules; imod++){
-               fhEMod[imod]                 = (TH1F *) outputList->At(index++);
-               fhNClustersMod[imod]         = (TH1F *) outputList->At(index++); 
-               fhNCellsPerClusterMod[imod]  = (TH2F *) outputList->At(index++); 
-               fhNCellsMod[imod]            = (TH1F *) outputList->At(index++);        
-               fhGridCellsMod[imod]         = (TH2F *) outputList->At(index++);
-               fhGridCellsEMod[imod]        = (TH2F *) outputList->At(index++); 
-               if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) 
-                       fhGridCellsTimeMod[imod]     = (TH2F *) outputList->At(index++); 
-               fhAmplitudeMod[imod]         = (TH1F *) outputList->At(index++);
-               
-               if(fCalorimeter=="EMCAL"){
-                       for(Int_t ifrac = 0; ifrac < 3; ifrac++){
-                               fhAmplitudeModFraction[imod*3+ifrac] = (TH1F *) outputList->At(index++); 
-                       }
-               }
-               
-               for(Int_t ircu = 0; ircu < fNRCU; ircu++){
-                       fhTimeAmpPerRCU[imod*fNRCU+ircu] = (TH2F *) outputList->At(index++); 
+  fhTimeAmpPerRCU        = new TH2F*[fNModules*fNRCU];
+  
+  fhIMMod                = new TH2F*[fNModules];
+  fhIMCellCutMod         = new TH2F*[fNModules];
+  
+  for(Int_t imod = 0 ; imod < fNModules; imod++){
+    fhEMod[imod]                 = (TH1F *) outputList->At(index++);
+    fhNClustersMod[imod]         = (TH1F *) outputList->At(index++); 
+    fhNCellsPerClusterMod[imod]  = (TH2F *) outputList->At(index++); 
+    fhNCellsMod[imod]            = (TH1F *) outputList->At(index++);   
+    fhGridCellsMod[imod]         = (TH2F *) outputList->At(index++);
+    fhGridCellsEMod[imod]        = (TH2F *) outputList->At(index++); 
+    if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) 
+      fhGridCellsTimeMod[imod]     = (TH2F *) outputList->At(index++); 
+    fhAmplitudeMod[imod]         = (TH1F *) outputList->At(index++);
+    
+    if(fCalorimeter=="EMCAL"){
+      for(Int_t ifrac = 0; ifrac < 3; ifrac++){
+       fhAmplitudeModFraction[imod*3+ifrac] = (TH1F *) outputList->At(index++); 
+      }
+    }
+    
+    for(Int_t ircu = 0; ircu < fNRCU; ircu++){
+      fhTimeAmpPerRCU[imod*fNRCU+ircu] = (TH2F *) outputList->At(index++); 
       //fhT0TimeAmpPerRCU[imod*fNRCU+ircu] = (TH2F *) outputList->At(index++); 
       //                       for(Int_t imod2 = 0; imod2 < fNModules; imod2++){
       //                               for(Int_t ircu2 = 0; ircu2 < fNModules; ircu2++){
       //                                       fhTimeCorrRCU[imod*fNRCU+ircu+imod2*fNRCU+ircu2]  = (TH2F *) outputList->At(index++);
       //                               }
       //                       }
-               }
-               fhIMMod[imod]                = (TH2F *) outputList->At(index++); 
-               fhIMCellCutMod[imod]         = (TH2F *) outputList->At(index++);        
+    }
+    fhIMMod[imod]                = (TH2F *) outputList->At(index++); 
+    fhIMCellCutMod[imod]         = (TH2F *) outputList->At(index++);   
     
-       }
-       
-       if(IsDataMC()){
-               fhDeltaE   = (TH1F *) outputList->At(index++); 
-               fhDeltaPt  = (TH1F *) outputList->At(index++); 
-               fhDeltaPhi = (TH1F *) outputList->At(index++); 
-               fhDeltaEta = (TH1F *) outputList->At(index++); 
-               
-               fhRatioE   = (TH1F *) outputList->At(index++); 
-               fhRatioPt  = (TH1F *) outputList->At(index++); 
-               fhRatioPhi = (TH1F *) outputList->At(index++); 
-               fhRatioEta = (TH1F *) outputList->At(index++); 
-               
-               fh2E       = (TH2F *) outputList->At(index++); 
-               fh2Pt      = (TH2F *) outputList->At(index++); 
-               fh2Phi     = (TH2F *) outputList->At(index++); 
-               fh2Eta     = (TH2F *) outputList->At(index++); 
-               
-               fhGamE     = (TH2F *) outputList->At(index++); 
-               fhGamPt    = (TH2F *) outputList->At(index++); 
-               fhGamPhi   = (TH2F *) outputList->At(index++); 
-               fhGamEta   = (TH2F *) outputList->At(index++); 
-               
-               fhGamDeltaE   = (TH1F *) outputList->At(index++); 
-               fhGamDeltaPt  = (TH1F *) outputList->At(index++); 
-               fhGamDeltaPhi = (TH1F *) outputList->At(index++); 
-               fhGamDeltaEta = (TH1F *) outputList->At(index++); 
-               
-               fhGamRatioE   = (TH1F *) outputList->At(index++); 
-               fhGamRatioPt  = (TH1F *) outputList->At(index++); 
-               fhGamRatioPhi = (TH1F *) outputList->At(index++); 
-               fhGamRatioEta = (TH1F *) outputList->At(index++); 
-    
-               fhPi0E     = (TH2F *) outputList->At(index++); 
-               fhPi0Pt    = (TH2F *) outputList->At(index++); 
-               fhPi0Phi   = (TH2F *) outputList->At(index++); 
-               fhPi0Eta   = (TH2F *) outputList->At(index++);          
-               
-               fhEleE     = (TH2F *) outputList->At(index++); 
-               fhElePt    = (TH2F *) outputList->At(index++); 
-               fhElePhi   = (TH2F *) outputList->At(index++); 
-               fhEleEta   = (TH2F *) outputList->At(index++);          
-               
-               fhNeHadE     = (TH2F *) outputList->At(index++); 
-               fhNeHadPt    = (TH2F *) outputList->At(index++); 
-               fhNeHadPhi   = (TH2F *) outputList->At(index++); 
-               fhNeHadEta   = (TH2F *) outputList->At(index++);                
-               
-               fhChHadE     = (TH2F *) outputList->At(index++); 
-               fhChHadPt    = (TH2F *) outputList->At(index++); 
-               fhChHadPhi   = (TH2F *) outputList->At(index++); 
-               fhChHadEta   = (TH2F *) outputList->At(index++);                                
-               
-               fhGamECharged     = (TH2F *) outputList->At(index++); 
-               fhGamPtCharged    = (TH2F *) outputList->At(index++); 
-               fhGamPhiCharged   = (TH2F *) outputList->At(index++); 
-               fhGamEtaCharged   = (TH2F *) outputList->At(index++); 
-    
-               fhPi0ECharged     = (TH2F *) outputList->At(index++); 
-               fhPi0PtCharged    = (TH2F *) outputList->At(index++); 
-               fhPi0PhiCharged   = (TH2F *) outputList->At(index++); 
-               fhPi0EtaCharged   = (TH2F *) outputList->At(index++);           
-               
-               fhEleECharged     = (TH2F *) outputList->At(index++); 
-               fhElePtCharged    = (TH2F *) outputList->At(index++); 
-               fhElePhiCharged   = (TH2F *) outputList->At(index++); 
-               fhEleEtaCharged   = (TH2F *) outputList->At(index++);           
-               
-               fhNeHadECharged     = (TH2F *) outputList->At(index++); 
-               fhNeHadPtCharged    = (TH2F *) outputList->At(index++); 
-               fhNeHadPhiCharged   = (TH2F *) outputList->At(index++); 
-               fhNeHadEtaCharged   = (TH2F *) outputList->At(index++);                 
-               
-               fhChHadECharged     = (TH2F *) outputList->At(index++); 
-               fhChHadPtCharged    = (TH2F *) outputList->At(index++); 
-               fhChHadPhiCharged   = (TH2F *) outputList->At(index++); 
-               fhChHadEtaCharged   = (TH2F *) outputList->At(index++);                                 
+  }
+  
+  if(IsDataMC()){
+    fhDeltaE   = (TH1F *) outputList->At(index++); 
+    fhDeltaPt  = (TH1F *) outputList->At(index++); 
+    fhDeltaPhi = (TH1F *) outputList->At(index++); 
+    fhDeltaEta = (TH1F *) outputList->At(index++); 
+    
+    fhRatioE   = (TH1F *) outputList->At(index++); 
+    fhRatioPt  = (TH1F *) outputList->At(index++); 
+    fhRatioPhi = (TH1F *) outputList->At(index++); 
+    fhRatioEta = (TH1F *) outputList->At(index++); 
+    
+    fh2E       = (TH2F *) outputList->At(index++); 
+    fh2Pt      = (TH2F *) outputList->At(index++); 
+    fh2Phi     = (TH2F *) outputList->At(index++); 
+    fh2Eta     = (TH2F *) outputList->At(index++); 
+    
+    fhGamE     = (TH2F *) outputList->At(index++); 
+    fhGamPt    = (TH2F *) outputList->At(index++); 
+    fhGamPhi   = (TH2F *) outputList->At(index++); 
+    fhGamEta   = (TH2F *) outputList->At(index++); 
+    
+    fhGamDeltaE   = (TH1F *) outputList->At(index++); 
+    fhGamDeltaPt  = (TH1F *) outputList->At(index++); 
+    fhGamDeltaPhi = (TH1F *) outputList->At(index++); 
+    fhGamDeltaEta = (TH1F *) outputList->At(index++); 
+    
+    fhGamRatioE   = (TH1F *) outputList->At(index++); 
+    fhGamRatioPt  = (TH1F *) outputList->At(index++); 
+    fhGamRatioPhi = (TH1F *) outputList->At(index++); 
+    fhGamRatioEta = (TH1F *) outputList->At(index++); 
+    
+    fhPi0E     = (TH2F *) outputList->At(index++); 
+    fhPi0Pt    = (TH2F *) outputList->At(index++); 
+    fhPi0Phi   = (TH2F *) outputList->At(index++); 
+    fhPi0Eta   = (TH2F *) outputList->At(index++);             
+    
+    fhEleE     = (TH2F *) outputList->At(index++); 
+    fhElePt    = (TH2F *) outputList->At(index++); 
+    fhElePhi   = (TH2F *) outputList->At(index++); 
+    fhEleEta   = (TH2F *) outputList->At(index++);             
+    
+    fhNeHadE     = (TH2F *) outputList->At(index++); 
+    fhNeHadPt    = (TH2F *) outputList->At(index++); 
+    fhNeHadPhi   = (TH2F *) outputList->At(index++); 
+    fhNeHadEta   = (TH2F *) outputList->At(index++);           
+    
+    fhChHadE     = (TH2F *) outputList->At(index++); 
+    fhChHadPt    = (TH2F *) outputList->At(index++); 
+    fhChHadPhi   = (TH2F *) outputList->At(index++); 
+    fhChHadEta   = (TH2F *) outputList->At(index++);                           
+    
+    fhGamECharged     = (TH2F *) outputList->At(index++); 
+    fhGamPtCharged    = (TH2F *) outputList->At(index++); 
+    fhGamPhiCharged   = (TH2F *) outputList->At(index++); 
+    fhGamEtaCharged   = (TH2F *) outputList->At(index++); 
+    
+    fhPi0ECharged     = (TH2F *) outputList->At(index++); 
+    fhPi0PtCharged    = (TH2F *) outputList->At(index++); 
+    fhPi0PhiCharged   = (TH2F *) outputList->At(index++); 
+    fhPi0EtaCharged   = (TH2F *) outputList->At(index++);              
+    
+    fhEleECharged     = (TH2F *) outputList->At(index++); 
+    fhElePtCharged    = (TH2F *) outputList->At(index++); 
+    fhElePhiCharged   = (TH2F *) outputList->At(index++); 
+    fhEleEtaCharged   = (TH2F *) outputList->At(index++);              
+    
+    fhNeHadECharged     = (TH2F *) outputList->At(index++); 
+    fhNeHadPtCharged    = (TH2F *) outputList->At(index++); 
+    fhNeHadPhiCharged   = (TH2F *) outputList->At(index++); 
+    fhNeHadEtaCharged   = (TH2F *) outputList->At(index++);            
+    
+    fhChHadECharged     = (TH2F *) outputList->At(index++); 
+    fhChHadPtCharged    = (TH2F *) outputList->At(index++); 
+    fhChHadPhiCharged   = (TH2F *) outputList->At(index++); 
+    fhChHadEtaCharged   = (TH2F *) outputList->At(index++);                            
                
     //         fhEMVxyz     = (TH3F *) outputList->At(index++); 
     //         fhHaVxyz     = (TH3F *) outputList->At(index++); 
                
-               fhEMVxyz     = (TH2F *) outputList->At(index++); 
-               fhHaVxyz     = (TH2F *) outputList->At(index++); 
-               fhEMR        = (TH2F *) outputList->At(index++); 
-               fhHaR        = (TH2F *) outputList->At(index++); 
-               
-               fhGenGamPt    = (TH1F *) outputList->At(index++); 
-               fhGenGamEta   = (TH1F *) outputList->At(index++); 
-               fhGenGamPhi   = (TH1F *) outputList->At(index++); 
-               
-               fhGenPi0Pt    = (TH1F *) outputList->At(index++); 
-               fhGenPi0Eta   = (TH1F *) outputList->At(index++); 
-               fhGenPi0Phi   = (TH1F *) outputList->At(index++); 
-               
-               fhGenEtaPt    = (TH1F *) outputList->At(index++); 
-               fhGenEtaEta   = (TH1F *) outputList->At(index++); 
-               fhGenEtaPhi   = (TH1F *) outputList->At(index++); 
-               
-               fhGenOmegaPt  = (TH1F *) outputList->At(index++); 
-               fhGenOmegaEta = (TH1F *) outputList->At(index++); 
-               fhGenOmegaPhi = (TH1F *) outputList->At(index++); 
-               
-               fhGenElePt    = (TH1F *) outputList->At(index++); 
-               fhGenEleEta   = (TH1F *) outputList->At(index++); 
-               fhGenElePhi   = (TH1F *) outputList->At(index++); 
-               
-               fhGenGamAccE   = (TH1F *) outputList->At(index++);              
-               fhGenGamAccPt  = (TH1F *) outputList->At(index++); 
-               fhGenGamAccEta = (TH1F *) outputList->At(index++); 
-               fhGenGamAccPhi = (TH1F *) outputList->At(index++); 
-               
-               fhGenPi0AccE   = (TH1F *) outputList->At(index++);              
-               fhGenPi0AccPt  = (TH1F *) outputList->At(index++); 
-               fhGenPi0AccEta = (TH1F *) outputList->At(index++); 
-               fhGenPi0AccPhi = (TH1F *) outputList->At(index++); 
-               
-               fhMCEle1pOverE =    (TH2F *) outputList->At(index++);
-               fhMCEle1dR =        (TH1F *) outputList->At(index++);
-               fhMCEle2MatchdEdx = (TH2F *) outputList->At(index++);
-               
-               fhMCChHad1pOverE =    (TH2F *) outputList->At(index++);
-               fhMCChHad1dR =        (TH1F *) outputList->At(index++);
-               fhMCChHad2MatchdEdx = (TH2F *) outputList->At(index++);
-               
-               fhMCNeutral1pOverE    = (TH2F *) outputList->At(index++);
-               fhMCNeutral1dR        = (TH1F *) outputList->At(index++);
-               fhMCNeutral2MatchdEdx = (TH2F *) outputList->At(index++);
-               
-               fhMCEle1pOverER02     =    (TH2F *) outputList->At(index++);
-               fhMCChHad1pOverER02   =    (TH2F *) outputList->At(index++);
-               fhMCNeutral1pOverER02 =    (TH2F *) outputList->At(index++);
-       }
+    fhEMVxyz     = (TH2F *) outputList->At(index++); 
+    fhHaVxyz     = (TH2F *) outputList->At(index++); 
+    fhEMR        = (TH2F *) outputList->At(index++); 
+    fhHaR        = (TH2F *) outputList->At(index++); 
+    
+    fhGenGamPt    = (TH1F *) outputList->At(index++); 
+    fhGenGamEta   = (TH1F *) outputList->At(index++); 
+    fhGenGamPhi   = (TH1F *) outputList->At(index++); 
+    
+    fhGenPi0Pt    = (TH1F *) outputList->At(index++); 
+    fhGenPi0Eta   = (TH1F *) outputList->At(index++); 
+    fhGenPi0Phi   = (TH1F *) outputList->At(index++); 
+    
+    fhGenEtaPt    = (TH1F *) outputList->At(index++); 
+    fhGenEtaEta   = (TH1F *) outputList->At(index++); 
+    fhGenEtaPhi   = (TH1F *) outputList->At(index++); 
+    
+    fhGenOmegaPt  = (TH1F *) outputList->At(index++); 
+    fhGenOmegaEta = (TH1F *) outputList->At(index++); 
+    fhGenOmegaPhi = (TH1F *) outputList->At(index++); 
+    
+    fhGenElePt    = (TH1F *) outputList->At(index++); 
+    fhGenEleEta   = (TH1F *) outputList->At(index++); 
+    fhGenElePhi   = (TH1F *) outputList->At(index++); 
+    
+    fhGenGamAccE   = (TH1F *) outputList->At(index++);                 
+    fhGenGamAccPt  = (TH1F *) outputList->At(index++); 
+    fhGenGamAccEta = (TH1F *) outputList->At(index++); 
+    fhGenGamAccPhi = (TH1F *) outputList->At(index++); 
+    
+    fhGenPi0AccE   = (TH1F *) outputList->At(index++);                 
+    fhGenPi0AccPt  = (TH1F *) outputList->At(index++); 
+    fhGenPi0AccEta = (TH1F *) outputList->At(index++); 
+    fhGenPi0AccPhi = (TH1F *) outputList->At(index++); 
+    
+    fhMCEle1pOverE =    (TH2F *) outputList->At(index++);
+    fhMCEle1dR =        (TH1F *) outputList->At(index++);
+    fhMCEle2MatchdEdx = (TH2F *) outputList->At(index++);
+    
+    fhMCChHad1pOverE =    (TH2F *) outputList->At(index++);
+    fhMCChHad1dR =        (TH1F *) outputList->At(index++);
+    fhMCChHad2MatchdEdx = (TH2F *) outputList->At(index++);
+    
+    fhMCNeutral1pOverE    = (TH2F *) outputList->At(index++);
+    fhMCNeutral1dR        = (TH1F *) outputList->At(index++);
+    fhMCNeutral2MatchdEdx = (TH2F *) outputList->At(index++);
+    
+    fhMCEle1pOverER02     =    (TH2F *) outputList->At(index++);
+    fhMCChHad1pOverER02   =    (TH2F *) outputList->At(index++);
+    fhMCNeutral1pOverER02 =    (TH2F *) outputList->At(index++);
+  }
 }
 
 //__________________________________________________________________
@@ -2578,467 +2779,474 @@ 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() ) ;
   
-       char name[128];
-       char cname[128];
-       
+  const Int_t buffersize = 255;
+  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
   //--------------------------------------------------
-       sprintf(cname,"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();
-       
-       sprintf(name,"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
   //--------------------------------------------------
-       sprintf(cname,"%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();
-       sprintf(name,"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 
-               sprintf(cname,"%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();
-               
-               sprintf(name,"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
   //---------------------------------------------------------  
-       
-       sprintf(cname,"%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();
-       
+      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();
-       
-       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]);
+  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");
   
-       sprintf(name,"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
   //---------------------------------------------------------  
        
-       sprintf(cname,"%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);
-       
-       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();
-       
-       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");
-       
-       sprintf(name,"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 /////////////       
   ////////////////////////////////////////       
        
   //CLUSTERS
-  if(fFillAllPosHisto){
-    sprintf(cname,"%s_QA_ClusterXY",fCalorimeter.Data());
+  Int_t rbX = 1;
+  Int_t rbY = 1;
+  Int_t rbZ = 1;
+  if(fFillAllPosHisto)
+  {
+    snprintf(cname,buffersize,"%s_QA_ClusterXY",fCalorimeter.Data());
     TCanvas  * cxyz = new TCanvas(cname, "Cluster XY distributions", 1200, 400) ;
     cxyz->Divide(3, 1);
     
@@ -3058,14 +3266,10 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     hXZ->GetYaxis()->SetTitleOffset(1.6);
     hXZ->Draw("colz");
     
-    sprintf(name,"QA_%s_ClusterXY_YZ_XZ.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_ClusterXY_YZ_XZ.eps",fCalorimeter.Data());
     cxyz->Print(name); printf("Create plot %s\n",name);
     
-    Int_t rbX = 1;
-    Int_t rbY = 1;
-    Int_t rbZ = 1;
-    
-    sprintf(cname,"QA_%s_ClusterX",fCalorimeter.Data());
+    snprintf(cname,buffersize,"QA_%s_ClusterX",fCalorimeter.Data());
     TCanvas  * cx = new TCanvas(cname, "Cluster X distributions", 1200, 400) ;
     cx->Divide(3, 1);
     
@@ -3103,12 +3307,13 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     hZ->SetAxisRange(zmin,zmax);
     hZ->Draw("HE");
     
-    sprintf(name,"QA_%s_ClusterX_Y_Z.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_ClusterX_Y_Z.eps",fCalorimeter.Data());
     cx->Print(name); printf("Create plot %s\n",name);
-    
-    //CELLS
-    
-    sprintf(cname,"%s_QA_CellXY",fCalorimeter.Data());
+  }
+  //CELLS
+  if(fFillAllPosHisto)
+  { 
+    snprintf(cname,buffersize,"%s_QA_CellXY",fCalorimeter.Data());
     TCanvas  * cellxyz = new TCanvas(cname, "Cell XY distributions", 1200, 400) ;
     cellxyz->Divide(3, 1);
     
@@ -3128,11 +3333,11 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     hXZCell->GetYaxis()->SetTitleOffset(1.6);
     hXZCell->Draw("colz");
     
-    sprintf(name,"QA_%s_CellXY_YZ_XZ.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_CellXY_YZ_XZ.eps",fCalorimeter.Data());
     cellxyz->Print(name); printf("Create plot %s\n",name);
     
     
-    sprintf(cname,"%s_QA_CellX",fCalorimeter.Data());
+    snprintf(cname,buffersize,"%s_QA_CellX",fCalorimeter.Data());
     TCanvas  * cellx = new TCanvas(cname, "Cell X distributions", 1200, 400) ;
     cellx->Divide(3, 1);
     
@@ -3165,7 +3370,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     hZCell->SetMinimum(hZCell->GetMaximum()/2);
     hZCell->Draw("HE");
     
-    sprintf(name,"QA_%s_CellX_Y_Z.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_CellX_Y_Z.eps",fCalorimeter.Data());
     cellx->Print(name); printf("Create plot %s\n",name);
     
     
@@ -3173,7 +3378,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     // Cluster X, Y, Z, R, energy cut dependence
     //---------------------------------------------------------        
     
-    sprintf(cname,"%s_QA_ClusterX_Y_Z_R_ECut",fCalorimeter.Data());
+    snprintf(cname,buffersize,"%s_QA_ClusterX_Y_Z_R_ECut",fCalorimeter.Data());
     TCanvas  * cxe = new TCanvas(cname, "Cluster X Y Z R, E cut", 800, 800) ;
     cxe->Divide(2, 2);         
     //R
@@ -3186,6 +3391,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     pLegendXCl.SetFillColor(10);
     pLegendXCl.SetBorderSize(1);
     
+    delete htmp; 
     htmp = fhRE->ProjectionX("hre_cluster_nocut",0,-1);
     Int_t rbR=1;
     if(htmp){
@@ -3214,6 +3420,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     cxe->cd(2) ; 
     gPad->SetLogy();
     gPad->SetGridy();
+    delete htmp; 
     htmp = fhXE->ProjectionX("hxe_cluster_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3235,6 +3442,8 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     cxe->cd(3) ; 
     gPad->SetLogy();
     gPad->SetGridy();
+    
+    delete htmp; 
     htmp = fhYE->ProjectionX("hye_cluster_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3257,6 +3466,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     gPad->SetLogy();
     gPad->SetGridy();
     
+    delete htmp; 
     htmp = fhZE->ProjectionX("hze_cluster_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3275,7 +3485,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       }
     }
     
-    sprintf(name,"QA_%s_ClusterX_Y_Z_R_ECut.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_ClusterX_Y_Z_R_ECut.eps",fCalorimeter.Data());
     cxe->Print(name); printf("Create plot %s\n",name);
     
     
@@ -3284,7 +3494,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     //---------------------------------------------------------        
     Int_t ncellcut[]={2, 3, 4};
     Int_t ncellcuts = 3;
-    sprintf(cname,"%s_QA_ClusterX_Y_Z_R_NCellsCut",fCalorimeter.Data());
+    snprintf(cname,buffersize,"%s_QA_ClusterX_Y_Z_R_NCellsCut",fCalorimeter.Data());
     TCanvas  * cxn = new TCanvas(cname, "Cluster X Y Z R, NCells cut", 800, 800) ;
     cxn->Divide(2, 2);         
     //R
@@ -3297,6 +3507,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     pLegendXClN.SetFillColor(10);
     pLegendXClN.SetBorderSize(1);
     
+    delete htmp; 
     htmp = fhRNCells->ProjectionX("hrn_cluster_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3323,6 +3534,8 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     cxn->cd(2) ; 
     gPad->SetLogy();
     gPad->SetGridy();
+    
+    delete htmp; 
     htmp = fhXNCells->ProjectionX("hxn_cluster_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3343,6 +3556,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     cxn->cd(3) ; 
     gPad->SetLogy();
     gPad->SetGridy();
+    delete htmp; 
     htmp = fhYNCells->ProjectionX("hyn_cluster_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3364,6 +3578,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     gPad->SetLogy();
     gPad->SetGridy();
     
+    delete htmp; 
     htmp = fhZNCells->ProjectionX("hzn_cluster_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3381,7 +3596,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       }
     }
     
-    sprintf(name,"QA_%s_ClusterX_Y_Z_R_NCellsCut.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_ClusterX_Y_Z_R_NCellsCut.eps",fCalorimeter.Data());
     cxn->Print(name); printf("Create plot %s\n",name);
     
     
@@ -3389,7 +3604,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     // Cell X, Y, Z, R, energy cut dependence
     //---------------------------------------------------------        
     
-    sprintf(cname,"%s_QA_CellX_Y_Z_R_ECut",fCalorimeter.Data());
+    snprintf(cname,buffersize,"%s_QA_CellX_Y_Z_R_ECut",fCalorimeter.Data());
     TCanvas  * cxecell = new TCanvas(cname, "Cell X Y Z R, E cut", 800, 800) ;
     cxecell->Divide(2, 2);             
     //R
@@ -3402,6 +3617,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     pLegendXCell.SetFillColor(10);
     pLegendXCell.SetBorderSize(1);
     
+    delete htmp; 
     htmp = fhRCellE->ProjectionX("hre_cell_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3428,6 +3644,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     gPad->SetLogy();
     gPad->SetGridy();
     
+    delete htmp; 
     htmp = fhXCellE->ProjectionX("hxe_cells_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3449,6 +3666,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     cxecell->cd(3) ; 
     gPad->SetLogy();
     gPad->SetGridy();
+    delete htmp; 
     htmp = fhYCellE->ProjectionX("hye_cells_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3460,6 +3678,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       for (Int_t i = 0; i < ncuts; i++) {
         binmin =  hE->FindBin(ecut[i]);
         //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
+        delete htmp; 
         htmp = fhYCellE->ProjectionX(Form("hye_cells_cut%d",i),binmin,-1);
         htmp->SetLineColor(ecutcolor[i]);
         htmp->Rebin(rbY);
@@ -3470,6 +3689,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     cxecell->cd(4) ; 
     gPad->SetLogy();
     gPad->SetGridy();
+    delete htmp; 
     htmp = fhZCellE->ProjectionX("hze_cells_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3481,13 +3701,14 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       for (Int_t i = 0; i < ncuts; i++) {
         binmin =  hE->FindBin(ecut[i]);
         //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
+        delete htmp; 
         htmp = fhZCellE->ProjectionX(Form("hze_cells_cut%d",i),binmin,-1);
         htmp->SetLineColor(ecutcolor[i]);
         htmp->Rebin(rbZ);
         htmp->Draw("same HE"); 
       }
     }
-    sprintf(name,"QA_%s_CellX_Y_Z_R_ECut.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_CellX_Y_Z_R_ECut.eps",fCalorimeter.Data());
     cxecell->Print(name); printf("Create plot %s\n",name);
     
     
@@ -3499,7 +3720,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     Int_t rbDY= 1;//rbY;
     Int_t rbDZ= 1;//rbZ;
     
-    sprintf(cname,"%s_QA_DeltaClusterCellX_Y_Z_R_ECut",fCalorimeter.Data());
+    snprintf(cname,buffersize,"%s_QA_DeltaClusterCellX_Y_Z_R_ECut",fCalorimeter.Data());
     TCanvas  * cxde = new TCanvas(cname, "Cluster-Cell X, Y, Z, R, E cut", 800, 800) ;
     cxde->Divide(2, 2);                
     //R
@@ -3512,6 +3733,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     pLegendXClD.SetFillColor(10);
     pLegendXClD.SetBorderSize(1);
     
+    delete htmp; 
     htmp = fhDeltaCellClusterRE->ProjectionX("hrde_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3524,6 +3746,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       for (Int_t i = 0; i < ncuts; i++) {
         binmin =  hE->FindBin(ecut[i]);
         //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
+        delete htmp; 
         htmp = fhDeltaCellClusterRE->ProjectionX(Form("hrde_cut%d",i),binmin,-1);
         htmp->SetLineColor(ecutcolor[i]);
         htmp->Rebin(rbDR);
@@ -3537,6 +3760,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     cxde->cd(2) ; 
     gPad->SetLogy();
     gPad->SetGridy();
+    delete htmp; 
     htmp = fhDeltaCellClusterXE->ProjectionX("hxde_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3548,6 +3772,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       for (Int_t i = 0; i < ncuts; i++) {
         binmin =  hE->FindBin(ecut[i]);
         //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
+        delete htmp; 
         htmp = fhDeltaCellClusterXE->ProjectionX(Form("hxde_cut%d",i),binmin,-1);
         htmp->SetLineColor(ecutcolor[i]);
         htmp->Rebin(rbDX);
@@ -3559,6 +3784,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     cxde->cd(3) ; 
     gPad->SetLogy();
     gPad->SetGridy();
+    delete htmp; 
     htmp = fhDeltaCellClusterYE->ProjectionX("hyde_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3570,6 +3796,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       for (Int_t i = 0; i < ncuts; i++) {
         binmin =  hE->FindBin(ecut[i]);
         //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
+        delete htmp; 
         htmp = fhDeltaCellClusterYE->ProjectionX(Form("hyde_cut%d",i),binmin,-1);
         htmp->SetLineColor(ecutcolor[i]);
         htmp->Rebin(rbDY);
@@ -3582,6 +3809,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     gPad->SetLogy();
     gPad->SetGridy();
     
+    delete htmp; 
     htmp = fhDeltaCellClusterZE->ProjectionX("hzde_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3593,6 +3821,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       for (Int_t i = 0; i < ncuts; i++) {
         binmin =  hE->FindBin(ecut[i]);
         //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
+        delete htmp; 
         htmp = fhDeltaCellClusterZE->ProjectionX(Form("hzde_cut%d",i),binmin,-1);
         htmp->SetLineColor(ecutcolor[i]);
         htmp->Rebin(rbZ);
@@ -3601,14 +3830,14 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       }
     }
     
-    sprintf(name,"QA_%s_DeltaClusterCellX_Y_Z_R_ECut.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_DeltaClusterCellX_Y_Z_R_ECut.eps",fCalorimeter.Data());
     cxde->Print(name); printf("Create plot %s\n",name);
     
     
     //----------------------------------------------------------
     // Cluster-Cell X, Y, Z, R, NCells in cluster dependence
     //---------------------------------------------------------        
-    sprintf(cname,"%s_QA_DeltaClusterCellX_Y_Z_R_NCellsCut",fCalorimeter.Data());
+    snprintf(cname,buffersize,"%s_QA_DeltaClusterCellX_Y_Z_R_NCellsCut",fCalorimeter.Data());
     TCanvas  * cxdn = new TCanvas(cname, "Cluster-Cell X Y Z R, NCells cut", 800, 800) ;
     cxdn->Divide(2, 2);                
     //R
@@ -3620,7 +3849,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     pLegendXClDN.SetTextSize(0.03);
     pLegendXClDN.SetFillColor(10);
     pLegendXClDN.SetBorderSize(1);
-    
+    delete htmp; 
     htmp = fhDeltaCellClusterRNCells->ProjectionX("hrdn_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3631,6 +3860,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       pLegendXClDN.AddEntry(htmp,"No cut","L");
       
       for (Int_t i = 0; i < ncellcuts; i++) {
+        delete htmp; 
         if(i < ncellcuts-1) htmp = fhDeltaCellClusterRNCells->ProjectionX(Form("hrdn_cut%d",i),ncellcut[i],ncellcut[i]);
         else htmp = fhDeltaCellClusterRNCells->ProjectionX(Form("hrdn_cut%d",i),ncellcut[i],-1);
         htmp->SetLineColor(ecutcolor[i]);
@@ -3647,6 +3877,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     cxdn->cd(2) ; 
     gPad->SetLogy();
     gPad->SetGridy();
+    delete htmp; 
     htmp = fhDeltaCellClusterXNCells->ProjectionX("hxdn_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3656,6 +3887,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       htmp->Draw("HE");
       
       for (Int_t i = 0; i < ncellcuts; i++) {
+        delete htmp; 
         if(i < ncellcuts-1)htmp = fhDeltaCellClusterXNCells->ProjectionX(Form("hxdn_cut%d",i),ncellcut[i],ncellcut[i]);
         else htmp = fhDeltaCellClusterXNCells->ProjectionX(Form("hxdn_cut%d",i),ncellcut[i],-1);
         htmp->SetLineColor(ecutcolor[i]);
@@ -3668,6 +3900,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     cxdn->cd(3) ; 
     gPad->SetLogy();
     gPad->SetGridy();
+    delete htmp; 
     htmp = fhDeltaCellClusterYNCells->ProjectionX("hydn_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3677,6 +3910,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       htmp->Draw("HE");
       
       for (Int_t i = 0; i < ncellcuts; i++) {
+        delete htmp; 
         if(i < ncellcuts-1) htmp = fhDeltaCellClusterYNCells->ProjectionX(Form("hydn_cut%d",i),ncellcut[i],ncellcut[i]);
         else htmp = fhDeltaCellClusterYNCells->ProjectionX(Form("hydn_cut%d",i),ncellcut[i],-1);
         htmp->SetLineColor(ecutcolor[i]);
@@ -3689,7 +3923,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     cxdn->cd(4) ; 
     gPad->SetLogy();
     gPad->SetGridy();
-    
+    delete htmp; 
     htmp = fhDeltaCellClusterZNCells->ProjectionX("hzdn_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3699,6 +3933,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       htmp->Draw("HE");
       
       for (Int_t i = 0; i < ncellcuts; i++) {
+        delete htmp; 
         if(i < ncellcuts-1)htmp = fhDeltaCellClusterZNCells->ProjectionX(Form("hzdn_cut%d",i),ncellcut[i],ncellcut[i]);
         else htmp = fhDeltaCellClusterZNCells->ProjectionX(Form("hzdn_cut%d",i),ncellcut[i],-1);
         htmp->SetLineColor(ecutcolor[i]);
@@ -3708,10 +3943,10 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       }
     }
     
-    sprintf(name,"QA_%s_DeltaClusterCellX_Y_Z_R_NCellsCut.eps",fCalorimeter.Data());
+    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
@@ -3720,13 +3955,13 @@ 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()));
     hPhiChargedClone = (TH1F*)   fhPhiCharged->Clone(Form("%sClone",fhPhiCharged->GetName()));
     
-    sprintf(cname,"QA_%s_rectrackmatch",fCalorimeter.Data());
+    snprintf(cname,buffersize,"QA_%s_rectrackmatch",fCalorimeter.Data());
     TCanvas  * ccltm = new TCanvas(cname, "Reconstructed clusters E-Phi-Eta, matched with tracks", 1200, 400) ;
     ccltm->Divide(3, 1);
     
@@ -3751,14 +3986,14 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     fhEtaCharged->Draw();
     fhEtaCharged->Draw();
     
-    sprintf(name,"QA_%s_ClusterEnergyPhiEta_TrackMatched.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_ClusterEnergyPhiEta_TrackMatched.eps",fCalorimeter.Data());
     ccltm->Print(name); printf("Plot: %s\n",name);
     
     //----------------------------------------------------------
     // Ratio  of reconstructed clusters energy-eta-phi distributions, matched with tracks over all
     //----------------------------------------------------------
     
-    sprintf(cname,"%s_QA_ChargedRatio",fCalorimeter.Data());
+    snprintf(cname,buffersize,"%s_QA_ChargedRatio",fCalorimeter.Data());
     TCanvas  * ccharge = new TCanvas(cname, "Charged clusters over all clusters", 1200, 400) ;
     ccharge->Divide(3, 1);
     
@@ -3791,166 +4026,170 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     fhEtaCharged->SetYTitle("track-matched clusters / all clusters");
     fhEtaCharged->Draw("HE");
     
-    sprintf(name,"QA_%s_ClustersMatchedToAllRatios.eps",fCalorimeter.Data());
+    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
   //-------------------------------------------
-       sprintf(cname,"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++){
-               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*)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*)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");
+  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++){
+    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++){
+    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->SetAxisRange(ptmin,ptmax,"X");
-                       htmp->SetMaximum(3.5);
-                       htmp->SetMinimum(0);
-                       htmp->Draw("HE");
-               }
-               else 
-                       htmp->Draw("same HE");
-               
-       }
-       sprintf(name,"QA_%s_NumberCaloClustersAndCaloCells.eps",fCalorimeter.Data());
-       cN->Print(name); printf("Print plot %s\n",name);
-       
+      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);
+  
   //----------------------------------------------------       
   // Cell Time histograms, time only available in ESDs
   //----------------------------------------------------
-       if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
-    
-               sprintf(cname,"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");
-    
-               sprintf(name,"QA_%s_CellsTime.eps",fCalorimeter.Data());
-               ctime->Print(name); printf("Plot: %s\n",name);
-       }
-       
-       
+  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);
+  }
+  
+  
   //---------------------------------
   //Grid of cell per module plots 
   //---------------------------------
-       {
+  {
     //Number of entries per cell
     gStyle->SetPadRightMargin(0.15);
-    sprintf(cname,"%s_QA_GridCellEntries",fCalorimeter.Data());
+    snprintf(cname,buffersize,"%s_QA_GridCellEntries",fCalorimeter.Data());
     TCanvas *cgrid   = new TCanvas("cgrid","Number of entries per cell", 12,12,800,400);
     if(fNModules%2 == 0)
       cgrid->Divide(fNModules/2,2); 
@@ -3968,10 +4207,10 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       //fhGridCellsMod[imod]->SetLabelSize(0.025,"z");
       fhGridCellsMod[imod]->Draw("colz");
     }
-    sprintf(name,"QA_%s_GridCellsEntries.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_GridCellsEntries.eps",fCalorimeter.Data());
     cgrid->Print(name); printf("Create plot %s\n",name);
     
-    sprintf(cname,"%s_QA_GridCellAccumEnergy",fCalorimeter.Data());
+    snprintf(cname,buffersize,"%s_QA_GridCellAccumEnergy",fCalorimeter.Data());
     TCanvas *cgridE   = new TCanvas("cgridE","Summed energy per cell", 12,12,800,400);
     if(fNModules%2 == 0)
       cgridE->Divide(fNModules/2,2); 
@@ -3987,11 +4226,11 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       fhGridCellsEMod[imod]->SetYTitle("row (phi direction)    ");
       fhGridCellsEMod[imod]->Draw("colz");
     }
-    sprintf(name,"QA_%s_GridCellsAccumEnergy.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_GridCellsAccumEnergy.eps",fCalorimeter.Data());
     cgridE->Print(name); printf("Create plot %s\n",name);
     
     //Accumulated energy per cell
-    sprintf(cname,"%s_QA_GridCellAverageEnergy",fCalorimeter.Data());
+    snprintf(cname,buffersize,"%s_QA_GridCellAverageEnergy",fCalorimeter.Data());
     TCanvas *cgridEA   = new TCanvas("cgridEA","Average energy per cell", 12,12,800,400);
     if(fNModules%2 == 0)         
       cgridEA->Divide(fNModules/2,2);
@@ -4007,12 +4246,12 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       fhGridCellsEMod[imod]->Divide(fhGridCellsMod[imod]);
       fhGridCellsEMod[imod]->Draw("colz");
     }
-    sprintf(name,"QA_%s_GridCellsAverageEnergy.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_GridCellsAverageEnergy.eps",fCalorimeter.Data());
     cgridEA->Print(name); printf("Create plot %s\n",name);
                
     //Accumulated Time per cell, E > 0.5 GeV
                
-    sprintf(cname,"%s_QA_GridCellAccumTime",fCalorimeter.Data());
+    snprintf(cname,buffersize,"%s_QA_GridCellAccumTime",fCalorimeter.Data());
     TCanvas *cgridT   = new TCanvas("cgridT","Summed time per cell", 12,12,800,400);
     if(fNModules%2 == 0)
       cgridT->Divide(fNModules/2,2); 
@@ -4028,321 +4267,321 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       fhGridCellsTimeMod[imod]->SetYTitle("row (phi direction)    ");
       fhGridCellsTimeMod[imod]->Draw("colz");
     }
-    sprintf(name,"QA_%s_GridCellsAccumTime.eps",fCalorimeter.Data());
+    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){
-               
-               sprintf(cname,"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();
     
-               sprintf(name,"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);
-               
-               sprintf(cname,"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");
-               }
-               
-               sprintf(name,"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);
                
-               sprintf(cname,"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");
-               }
-               
-               sprintf(name,"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);
-               
-               sprintf(cname,"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();
-               
-               sprintf(name,"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");
-    sprintf(cname,"QA_%s_recvsmc",fCalorimeter.Data());
+    snprintf(cname,buffersize,"QA_%s_recvsmc",fCalorimeter.Data());
     TCanvas  * c6 = new TCanvas(cname, "Reconstructed vs MC distributions", 400, 400) ;
     c6->Divide(2, 2);
     
@@ -4366,12 +4605,12 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     fh2Eta->SetLineColor(4);
     fh2Eta->Draw();
     
-    sprintf(name,"QA_%s_ReconstructedVSMCDistributions.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_ReconstructedVSMCDistributions.eps",fCalorimeter.Data());
     c6->Print(name); printf("Plot: %s\n",name);        
     
     //Reconstructed vs MC distributions
     //printf("c6\n");
-    sprintf(cname,"QA_%s_gamrecvsmc",fCalorimeter.Data());
+    snprintf(cname,buffersize,"QA_%s_gamrecvsmc",fCalorimeter.Data());
     TCanvas  * c6Gam = new TCanvas(cname, "Reconstructed vs MC distributions", 400, 400) ;
     c6Gam->Divide(2, 2);
     
@@ -4387,12 +4626,12 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     c6Gam->cd(4) ; 
     fhGamEta->Draw();
     
-    sprintf(name,"QA_%s_GammaReconstructedVSMCDistributions.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_GammaReconstructedVSMCDistributions.eps",fCalorimeter.Data());
     c6->Print(name); printf("Plot: %s\n",name);        
     
     //Generated - reconstructed  
     //printf("c7\n");
-    sprintf(cname,"QA_%s_diffgenrec",fCalorimeter.Data());
+    snprintf(cname,buffersize,"QA_%s_diffgenrec",fCalorimeter.Data());
     TCanvas  * c7 = new TCanvas(cname, "generated - reconstructed", 400, 400) ;
     c7->Divide(2, 2);
     
@@ -4426,12 +4665,12 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     fhDeltaEta->Draw();
     fhGamDeltaEta->Draw("same");
     
-    sprintf(name,"QA_%s_DiffGeneratedReconstructed.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_DiffGeneratedReconstructed.eps",fCalorimeter.Data());
     c7->Print(name); printf("Plot: %s\n",name);
     
     // Reconstructed / Generated 
     //printf("c8\n");
-    sprintf(cname,"QA_%s_ratiorecgen",fCalorimeter.Data());
+    snprintf(cname,buffersize,"QA_%s_ratiorecgen",fCalorimeter.Data());
     TCanvas  * c8 = new TCanvas(cname, " reconstructed / generated", 400, 400) ;
     c8->Divide(2, 2);
     
@@ -4465,14 +4704,14 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     fhRatioEta->Draw();
     fhGamRatioEta->Draw("same");
     
-    sprintf(name,"QA_%s_ReconstructedDivGenerated.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_ReconstructedDivGenerated.eps",fCalorimeter.Data());
     c8->Print(name); printf("Plot: %s\n",name);
     
     //MC
     
     //Generated distributions
     //printf("c1\n");
-    sprintf(cname,"QA_%s_gen",fCalorimeter.Data());
+    snprintf(cname,buffersize,"QA_%s_gen",fCalorimeter.Data());
     TCanvas  * c10 = new TCanvas(cname, "Generated distributions", 600, 200) ;
     c10->Divide(3, 1);
     
@@ -4588,13 +4827,13 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     fhGenOmegaPhi->Draw("same");
     fhGenElePhi->Draw("same");
     
-    sprintf(name,"QA_%s_GeneratedDistributions.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_GeneratedDistributions.eps",fCalorimeter.Data());
     c10->Print(name); printf("Plot: %s\n",name);
     
     
     //Reconstructed clusters depending on its original particle.
     //printf("c1\n");
-    sprintf(cname,"QA_%s_recgenid",fCalorimeter.Data());
+    snprintf(cname,buffersize,"QA_%s_recgenid",fCalorimeter.Data());
     TCanvas  * c11 = new TCanvas(cname, "Reconstructed particles, function of their original particle ID", 400, 400) ;
     c11->Divide(2, 2);
     
@@ -4772,7 +5011,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     hChHadPhi->Draw("same");
     hElePhi->Draw("same");
     
-    sprintf(name,"QA_%s_RecDistributionsGenID.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_RecDistributionsGenID.eps",fCalorimeter.Data());
     c11->Print(name); printf("Plot: %s\n",name);
     
     
@@ -4788,7 +5027,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     TH1F *     hPi0PhiClone = (TH1F*)   hPi0Phi->Clone(Form("%s_Clone",fhPi0Phi->GetName()));
     TH1F *     hGamPhiClone = (TH1F*)   hGamPhi->Clone(Form("%s_Clone",fhGamPhi->GetName()));  
     
-    sprintf(cname,"QA_%s_recgenidratio",fCalorimeter.Data());
+    snprintf(cname,buffersize,"QA_%s_recgenidratio",fCalorimeter.Data());
     TCanvas  * c12 = new TCanvas(cname, "Ratio reconstructed clusters / generated particles in acceptance, for different particle ID", 400, 400) ;
     c12->Divide(2, 2);
     
@@ -4854,14 +5093,14 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     hPi0PhiClone->Draw("same");
     hGamPhiClone->Draw("same");
     
-    sprintf(name,"QA_%s_EfficiencyGenID.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_EfficiencyGenID.eps",fCalorimeter.Data());
     c12->Print(name); printf("Plot: %s\n",name);
     
     
     
     //Reconstructed distributions
     //printf("c1\n");
-    sprintf(cname,"QA_%s_vertex",fCalorimeter.Data());
+    snprintf(cname,buffersize,"QA_%s_vertex",fCalorimeter.Data());
     TCanvas  * c13 = new TCanvas(cname, "Particle vertex", 400, 400) ;
     c13->Divide(2, 2);
     
@@ -4888,7 +5127,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     hHaR->Draw();
     
     
-    sprintf(name,"QA_%s_ParticleVertex.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_ParticleVertex.eps",fCalorimeter.Data());
     c13->Print(name); printf("Plot: %s\n",name);
     
     
@@ -4896,7 +5135,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     if(fFillAllTH12){
       //Reconstructed distributions, matched with tracks, generated particle dependence
       //printf("c2\n");
-      sprintf(cname,"QA_%s_rectrackmatchGenID",fCalorimeter.Data());
+      snprintf(cname,buffersize,"QA_%s_rectrackmatchGenID",fCalorimeter.Data());
       TCanvas  * c22ch = new TCanvas(cname, "Reconstructed distributions, matched with tracks, for different particle ID", 400, 400) ;
       c22ch->Divide(2, 2);
       
@@ -5000,7 +5239,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       hElePhiCharged->Draw("same");
       
       
-      sprintf(name,"QA_%s_ReconstructedDistributions_TrackMatchedGenID.eps",fCalorimeter.Data());
+      snprintf(name,buffersize,"QA_%s_ReconstructedDistributions_TrackMatchedGenID.eps",fCalorimeter.Data());
       c22ch->Print(name); printf("Plot: %s\n",name);
       
       TH1F *   hGamEChargedClone   = (TH1F*)   hGamECharged->Clone(Form("%s_Clone",fhGamECharged->GetName()));
@@ -5030,7 +5269,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       
       //Ratio: reconstructed track matched/ all reconstructed
       //printf("c3\n");
-      sprintf(cname,"QA_%s_rectrackmatchratGenID",fCalorimeter.Data());
+      snprintf(cname,buffersize,"QA_%s_rectrackmatchratGenID",fCalorimeter.Data());
       TCanvas  * c3ch = new TCanvas(cname, "Ratio: reconstructed track matched/ all reconstructed, for different particle ID", 400, 400) ;
       c3ch->Divide(2, 2);
       
@@ -5114,48 +5353,48 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
       hNeHadPhiChargedClone->Draw("same");
       hChHadPhiChargedClone->Draw("same");
       
-      sprintf(name,"QA_%s_RatioReconstructedMatchedDistributionsGenID.eps",fCalorimeter.Data());
+      snprintf(name,buffersize,"QA_%s_RatioReconstructedMatchedDistributionsGenID.eps",fCalorimeter.Data());
       c3ch->Print(name); printf("Plot: %s\n",name);
       
     }  
   }
   //Track-matching distributions
   
-       sprintf(cname,"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();
-       
-       sprintf(name,"QA_%s_TrackMatchingEleDist.eps",fCalorimeter.Data());
-       cme->Print(name); printf("Plot: %s\n",name);       
-       
-       if(IsDataMC()){
-    sprintf(cname,"QA_%s_trkmatchMCEle",fCalorimeter.Data());
+  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);
     
@@ -5174,11 +5413,11 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     cmemc->cd(3);
     fhMCEle2MatchdEdx->Draw();
                
-    sprintf(name,"QA_%s_TrackMatchingDistMCEle.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_TrackMatchingDistMCEle.eps",fCalorimeter.Data());
     cmemc->Print(name); printf("Plot: %s\n",name);  
     
                
-    sprintf(cname,"QA_%s_trkmatchMCChHad",fCalorimeter.Data());
+    snprintf(cname,buffersize,"QA_%s_trkmatchMCChHad",fCalorimeter.Data());
     TCanvas *cmemchad = new TCanvas(cname,"Track-matching distributions from MC charged hadrons", 600, 200);
     cmemchad->Divide(3,1);
                
@@ -5197,10 +5436,10 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     cmemchad->cd(3);
     fhMCChHad2MatchdEdx->Draw();
                
-    sprintf(name,"QA_%s_TrackMatchingDistMCChHad.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_TrackMatchingDistMCChHad.eps",fCalorimeter.Data());
     cmemchad->Print(name); printf("Plot: %s\n",name);       
     
-    sprintf(cname,"QA_%s_trkmatchMCNeutral",fCalorimeter.Data());
+    snprintf(cname,buffersize,"QA_%s_trkmatchMCNeutral",fCalorimeter.Data());
     TCanvas *cmemcn = new TCanvas(cname,"Track-matching distributions from MC neutrals", 600, 200);
     cmemcn->Divide(3,1);
                
@@ -5219,10 +5458,10 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     cmemcn->cd(3);
     fhMCNeutral2MatchdEdx->Draw();
                
-    sprintf(name,"QA_%s_TrackMatchingDistMCNeutral.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_TrackMatchingDistMCNeutral.eps",fCalorimeter.Data());
     cmemcn->Print(name); printf("Plot: %s\n",name);       
     
-    sprintf(cname,"QA_%s_trkmatchpE",fCalorimeter.Data());
+    snprintf(cname,buffersize,"QA_%s_trkmatchpE",fCalorimeter.Data());
     TCanvas *cmpoe = new TCanvas(cname,"Track-matching distributions, p/E", 400, 200);
     cmpoe->Divide(2,1);
                
@@ -5268,16 +5507,16 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     //         pLegendpE2.SetBorderSize(1);
     //         pLegendpE2.Draw();
     
-    sprintf(name,"QA_%s_TrackMatchingPOverE.eps",fCalorimeter.Data());
+    snprintf(name,buffersize,"QA_%s_TrackMatchingPOverE.eps",fCalorimeter.Data());
     cmpoe->Print(name); printf("Plot: %s\n",name);                             
-       }
-       
-       char line[1024] ; 
-       sprintf(line, ".!tar -zcf QA_%s_%s.tar.gz *%s*.eps", fCalorimeter.Data(), GetName(),fCalorimeter.Data()) ; 
-       gROOT->ProcessLine(line);
-       sprintf(line, ".!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());
+  
 }