]> 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 1875d714d7a6d11b242dadf06513dfedd788ac09..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"
@@ -81,7 +81,8 @@ fh2E(0),fh2Pt(0),fh2Phi(0),fh2Eta(0),
 fhLambda(0), fhDispersion(0), 
 fhIM(0), fhIMCellCut(0),fhAsym(0), 
 fhNCellsPerCluster(0),fhNCellsPerClusterMIP(0), fhNCellsPerClusterMIPCharged(0), fhNClusters(0), 
-fhClusterTimeEnergy(0),fhCellTimeSpreadRespectToCellMax(0),fhCellIdCellLargeTimeSpread(0),
+fhClusterTimeEnergy(0),fhCellTimeSpreadRespectToCellMax(0),fhCellIdCellLargeTimeSpread(0), 
+fhBadClusterMaxCellTimeEnergy(0), fhBadClusterMaxCellCloseCellRatio(0),fhClusterMaxCellTimeEnergy(0), fhClusterMaxCellCloseCellRatio(0), 
 fhRNCells(0),fhXNCells(0),fhYNCells(0),fhZNCells(0),
 fhRE(0),     fhXE(0),     fhYE(0),     fhZE(0),    fhXYZ(0),
 fhRCellE(0), fhXCellE(0), fhYCellE(0), fhZCellE(0),fhXYZCell(0),
@@ -225,7 +226,30 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
   fhClusterTimeEnergy->SetXTitle("E (GeV) ");
   fhClusterTimeEnergy->SetYTitle("TOF (ns)");
   outputContainer->Add(fhClusterTimeEnergy);
-  
+    
+  fhClusterMaxCellCloseCellRatio  = new TH2F ("hClusterMaxCellCloseCell","energy vs ratio of max cell / neighbour cell, reconstructed clusters",
+                                          nptbins,ptmin,ptmax, 100,0,1.); 
+  fhClusterMaxCellCloseCellRatio->SetXTitle("E_{cluster} (GeV) ");
+  fhClusterMaxCellCloseCellRatio->SetYTitle("ratio");
+  outputContainer->Add(fhClusterMaxCellCloseCellRatio);
+  
+  fhBadClusterMaxCellCloseCellRatio  = new TH2F ("hBadClusterMaxCellCloseCell","energy vs ratio of max cell / neighbour cell constributing cell, reconstructed bad clusters",
+                                             nptbins,ptmin,ptmax, 100,0,1.); 
+  fhBadClusterMaxCellCloseCellRatio->SetXTitle("E_{cluster} (GeV) ");
+  fhBadClusterMaxCellCloseCellRatio->SetYTitle("ratio");
+  outputContainer->Add(fhBadClusterMaxCellCloseCellRatio);
+  
+  fhClusterMaxCellTimeEnergy  = new TH2F ("hClusterMaxCellTimeEnergy","energy vs TOF of maximum constributing cell, reconstructed clusters",
+                                          nptbins,ptmin,ptmax, ntimebins,timemin,timemax); 
+  fhClusterMaxCellTimeEnergy->SetXTitle("E_{cluster} (GeV) ");
+  fhClusterMaxCellTimeEnergy->SetYTitle("TOF (ns)");
+  outputContainer->Add(fhClusterMaxCellTimeEnergy);
+  
+  fhBadClusterMaxCellTimeEnergy  = new TH2F ("hBadClusterMaxCellTimeEnergy","energy vs TOF of maximum constributing cell, reconstructed clusters",
+                                             nptbins,ptmin,ptmax, ntimebins,timemin,timemax); 
+  fhBadClusterMaxCellTimeEnergy->SetXTitle("E_{cluster} (GeV) ");
+  fhBadClusterMaxCellTimeEnergy->SetYTitle("TOF (ns)");
+  outputContainer->Add(fhBadClusterMaxCellTimeEnergy);    
   
   //Shower shape
   fhLambda  = new TH3F ("hLambda","#lambda_{0}^{2} vs #lambda_{1}^{2} vs energy, reconstructed clusters",
@@ -491,7 +515,7 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
     fhCellIdCellLargeTimeSpread= new TH1F ("hCellIdCellLargeTimeSpread","", colmax*rowmax*fNModules,0,colmax*rowmax*fNModules); 
     fhCellIdCellLargeTimeSpread->SetXTitle("Absolute Cell Id");
     outputContainer->Add(fhCellIdCellLargeTimeSpread);
-    
+
     fhTime  = new TH1F ("hTime","Cell Time",ntimebins,timemin,timemax); 
     fhTime->SetXTitle("Cell Time (ns)");
     outputContainer->Add(fhTime);
@@ -678,37 +702,38 @@ TList *  AliAnaCalorimeterQA::GetCreateOutputObjects()
       }
       
     }
-    
-    for(Int_t ircu = 0; ircu < fNRCU; ircu++){
-      fhTimeAmpPerRCU[imod*fNRCU+ircu]  = new TH2F (Form("hTimeAmp_Mod%d_RCU%d",imod,ircu),
-                                                    Form("Cell Energy vs Cell Time in Module %d, RCU %d ",imod,ircu), 
-                                                    nptbins,ptmin,ptmax,ntimebins,timemin,timemax); 
-      fhTimeAmpPerRCU[imod*fNRCU+ircu]->SetXTitle("E (GeV)");
-      fhTimeAmpPerRCU[imod*fNRCU+ircu]->SetYTitle("time (ns)");
-      outputContainer->Add(fhTimeAmpPerRCU[imod*fNRCU+ircu]);
+    if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
       
-      //                               fhT0TimeAmpPerRCU[imod*fNRCU+ircu]  = new TH2F (Form("hT0TimeAmp_Mod%d_RCU%d",imod,ircu),
-      //                                                                                                                         Form("Cell Energy vs T0-Cell Time in Module %d, RCU %d ",imod,ircu), 
-      //                                                                                                                         nptbins,ptmin,ptmax,ntimebins,timemin,timemax); 
-      //                               fhT0TimeAmpPerRCU[imod*fNRCU+ircu]->SetXTitle("E (GeV)");
-      //                               fhT0TimeAmpPerRCU[imod*fNRCU+ircu]->SetYTitle("T_{0} - T_{EMCal} (ns)");
-      //                               outputContainer->Add(fhT0TimeAmpPerRCU[imod*fNRCU+ircu]);
-      //                       
-                       
-      //                               for(Int_t imod2 = 0; imod2 < fNModules; imod2++){
-      //                                               for(Int_t ircu2 = 0; ircu2 < fNModules; ircu2++){
-      //                                                       Int_t index =  (imod2*fNRCU+ircu2)+(fNModules*fNRCU)*(ircu+imod)+fNRCU*fNModules*imod; 
-      //                                                       fhTimeCorrRCU[index]  = new TH2F (Form("hTimeCorrRCU_Mod%d_RCU%d_CompareTo_Mod%d_RCU%d",imod, ircu,imod2, ircu2),
-      //                                                                                                                                                       Form("Cell Energy > 0.3, Correlate cell Time in Module %d, RCU %d to Module %d, RCU %d",imod,ircu,imod2, ircu2),
-      //                                                                                                                                                       ntimebins,timemin,timemax,ntimebins,timemin,timemax); 
-      //                                                       fhTimeCorrRCU[index]->SetXTitle("Trigger Cell Time (ns)");
-      //                                                       fhTimeCorrRCU[index]->SetYTitle("Cell Time (ns)");
-      //                                                       outputContainer->Add(fhTimeCorrRCU[index]);
-      //                                               }
-      //                               }
+      for(Int_t ircu = 0; ircu < fNRCU; ircu++){
+        fhTimeAmpPerRCU[imod*fNRCU+ircu]  = new TH2F (Form("hTimeAmp_Mod%d_RCU%d",imod,ircu),
+                                                      Form("Cell Energy vs Cell Time in Module %d, RCU %d ",imod,ircu), 
+                                                      nptbins,ptmin,ptmax,ntimebins,timemin,timemax); 
+        fhTimeAmpPerRCU[imod*fNRCU+ircu]->SetXTitle("E (GeV)");
+        fhTimeAmpPerRCU[imod*fNRCU+ircu]->SetYTitle("time (ns)");
+        outputContainer->Add(fhTimeAmpPerRCU[imod*fNRCU+ircu]);
+        
+        //                             fhT0TimeAmpPerRCU[imod*fNRCU+ircu]  = new TH2F (Form("hT0TimeAmp_Mod%d_RCU%d",imod,ircu),
+        //                                                                                                                       Form("Cell Energy vs T0-Cell Time in Module %d, RCU %d ",imod,ircu), 
+        //                                                                                                                       nptbins,ptmin,ptmax,ntimebins,timemin,timemax); 
+        //                             fhT0TimeAmpPerRCU[imod*fNRCU+ircu]->SetXTitle("E (GeV)");
+        //                             fhT0TimeAmpPerRCU[imod*fNRCU+ircu]->SetYTitle("T_{0} - T_{EMCal} (ns)");
+        //                             outputContainer->Add(fhT0TimeAmpPerRCU[imod*fNRCU+ircu]);
+        //                     
+        
+        //                             for(Int_t imod2 = 0; imod2 < fNModules; imod2++){
+        //                                             for(Int_t ircu2 = 0; ircu2 < fNModules; ircu2++){
+        //                                                     Int_t index =  (imod2*fNRCU+ircu2)+(fNModules*fNRCU)*(ircu+imod)+fNRCU*fNModules*imod; 
+        //                                                     fhTimeCorrRCU[index]  = new TH2F (Form("hTimeCorrRCU_Mod%d_RCU%d_CompareTo_Mod%d_RCU%d",imod, ircu,imod2, ircu2),
+        //                                                                                                                                                     Form("Cell Energy > 0.3, Correlate cell Time in Module %d, RCU %d to Module %d, RCU %d",imod,ircu,imod2, ircu2),
+        //                                                                                                                                                     ntimebins,timemin,timemax,ntimebins,timemin,timemax); 
+        //                                                     fhTimeCorrRCU[index]->SetXTitle("Trigger Cell Time (ns)");
+        //                                                     fhTimeCorrRCU[index]->SetYTitle("Cell Time (ns)");
+        //                                                     outputContainer->Add(fhTimeCorrRCU[index]);
+        //                                             }
+        //                             }
+      }
     }
     
-    
     fhIMMod[imod]  = new TH2F (Form("hIM_Mod%d",imod),
                                Form("Cluster pairs Invariant mass vs reconstructed pair energy in Module %d",imod),
                                nptbins,ptmin,ptmax,nmassbins,massmin,massmax); 
@@ -1208,15 +1233,12 @@ Int_t AliAnaCalorimeterQA::GetNewRebinForRePlotting(TH1D* histo, const Float_t n
 void AliAnaCalorimeterQA::Init()
 { 
   //Check if the data or settings are ok
-  if(fCalorimeter != "PHOS" && fCalorimeter !="EMCAL"){
-    printf("AliAnaCalorimeterQA::Init() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data());
-    abort();
-  }    
   
-  if(GetReader()->GetDataType()== AliCaloTrackReader::kMC){
-    printf("AliAnaCalorimeterQA::Init() - Analysis of reconstructed data, MC reader not aplicable\n");
-    abort();
-  }    
+  if(fCalorimeter != "PHOS" && fCalorimeter !="EMCAL")
+    AliFatal(Form("Wrong calorimeter name <%s>", fCalorimeter.Data()));
+
+  if(GetReader()->GetDataType()== AliCaloTrackReader::kMC)
+    AliFatal("Analysis of reconstructed data, MC reader not aplicable");
   
 }
 
@@ -1306,10 +1328,9 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
   if(IsDataMC()){
     if(GetReader()->ReadStack()){
       
-      if(!GetMCStack()) {
-        printf("AliAnaPhoton::MakeAnalysisFillHistograms() - Stack not available, is the MC handler called? STOP\n");
-        abort();
-      }
+      if(!GetMCStack()) 
+        AliFatal("Stack not available, is the MC handler called?\n");
+        
       //Fill some pure MC histograms, only primaries.
       for(Int_t i=0 ; i<GetMCStack()->GetNprimary(); i++){//Only primary particles, for all MC transport put GetNtrack()
         TParticle *primary = GetMCStack()->Particle(i) ;
@@ -1321,10 +1342,9 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
     }
     else if(GetReader()->ReadAODMCParticles()){
       
-      if(!GetReader()->GetAODMCParticles(0))   {
-        printf("AliAnaPhoton::MakeAnalysisFillHistograms() -  AODMCParticles not available!\n");
-        abort();
-      }
+      if(!GetReader()->GetAODMCParticles(0))   
+        AliFatal("AODMCParticles not available!");
+      
       //Fill some pure MC histograms, only primaries.
       for(Int_t i=0 ; i < (GetReader()->GetAODMCParticles(0))->GetEntriesFast(); i++){
         AliAODMCParticle *aodprimary = (AliAODMCParticle*) (GetReader()->GetAODMCParticles(0))->At(i) ;
@@ -1342,13 +1362,13 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
   
   
   //Get List with CaloClusters  
-  if      (fCalorimeter == "PHOS")  caloClusters = GetAODPHOS();
-  else if (fCalorimeter == "EMCAL") caloClusters = GetAODEMCAL();
+  if      (fCalorimeter == "PHOS")  caloClusters = GetPHOSClusters();
+  else if (fCalorimeter == "EMCAL") caloClusters = GetEMCALClusters();
   else 
     AliFatal(Form("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data()));
   
-  //  if     (fCalorimeter == "EMCAL") GetReader()->GetInputEvent()->GetEMCALClusters(caloClusters);//GetAODEMCAL();
-  //  else if(fCalorimeter == "PHOS")  GetReader()->GetInputEvent()->GetPHOSClusters (caloClusters);//GetAODPHOS();
+  //  if     (fCalorimeter == "EMCAL") GetReader()->GetInputEvent()->GetEMCALClusters(caloClusters);//GetEMCALClusters();
+  //  else if(fCalorimeter == "PHOS")  GetReader()->GetInputEvent()->GetPHOSClusters (caloClusters);//GetPHOSClusters();
   //  else 
   //    AliFatal(Form("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - Wrong calorimeter name <%s>, END\n", fCalorimeter.Data()));
   
@@ -1414,13 +1434,18 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
       
       //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;
+      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
@@ -1519,7 +1544,41 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
         } 
         
       }// 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 &&  GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
         for (Int_t ipos = 0; ipos < nCaloCellsPerCluster; ipos++) {
@@ -1602,17 +1661,7 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
   //----------------------------------------------------------
   // 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") 
@@ -1620,20 +1669,34 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
   else                       
     cell = GetEMCALCells();
   
-  if(!cell) {
-    printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - STOP: No %s ESD CELLS available for analysis\n",fCalorimeter.Data());
-    abort();
+  if(!cell)
+    AliFatal(Form("No %s CELLS available for analysis",fCalorimeter.Data()));
+    return; // just to trick coverity
   }
   
   if(GetDebug() > 0) 
-    printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - In ESD %s cell entries %d\n", fCalorimeter.Data(), cell->GetNumberOfCells());    
+    printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - %s cell entries %d\n", fCalorimeter.Data(), cell->GetNumberOfCells());    
+  
+  //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));
+    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"){
@@ -1645,8 +1708,8 @@ 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);
@@ -1656,26 +1719,17 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
       
       amp     = cell->GetAmplitude(iCell)*recalF;
       time    = cell->GetTime(iCell)*1e9;//transform time to ns
-      if(time < fTimeCutMin || time > fTimeCutMax) continue;
       
+      //Remove noisy channels, only possible in ESDs
+      if(GetReader()->GetDataType() == AliCaloTrackReader::kESD){
+        if(time < fTimeCutMin || time > fTimeCutMax) continue;
+      }
       //if(amp > 3 && fCalorimeter=="EMCAL") printf("Amp = %f, time = %f, (mod, col, row)= (%d,%d,%d)\n",
       //                                                                                  amp,time,nModule,icol,irow);
       
-      //printf("%s: time %g\n",fCalorimeter.Data(), time);
       id      = cell->GetCellNumber(iCell);
       fhAmplitude->Fill(amp);
       fhAmpId    ->Fill(amp,id);
-      fhTime     ->Fill(time);
-      fhTimeId   ->Fill(time,id);
-      fhTimeAmp  ->Fill(amp,time);
-      //Double_t t0 = GetReader()->GetInputEvent()->GetT0();
-      //printf("---->>> Time EMCal %e, T0 %e, T0 vertex %e, T0 clock %e, T0 trig %d \n",time,t0, 
-      //          GetReader()->GetInputEvent()->GetT0zVertex(),
-      //          GetReader()->GetInputEvent()->GetT0clock(),
-      //          GetReader()->GetInputEvent()->GetT0Trig());
-      //fhT0Time     ->Fill(time-t0);
-      //fhT0TimeId   ->Fill(time-t0,id);
-      //fhT0TimeAmp  ->Fill(amp,time-t0);
       
       fhAmplitudeMod[nModule]->Fill(amp);
       if(fCalorimeter=="EMCAL"){
@@ -1685,40 +1739,60 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
         fhAmplitudeModFraction[nModule*3+ifrac]->Fill(amp);
       }
       
-      fhTimeAmpPerRCU  [nModule*fNRCU+iRCU]->Fill(amp, time);
-      //printf("id %d, nModule %d, iRCU %d: Histo Name %s\n",id, nModule,iRCU, fhTimeAmpPerRCU[nModule*fNRCU+iRCU]->GetName());
-      //fhT0TimeAmpPerRCU[nModule*fNRCU+iRCU]->Fill(amp, time-t0);
       nCellsInModule[nModule]++;
       fhGridCellsMod[nModule]    ->Fill(icol,irow);
       fhGridCellsEMod[nModule]   ->Fill(icol,irow,amp);
-      if(amp > 0.3){
-        fhGridCellsTimeMod[nModule]->Fill(icol,irow,time);
+      
+      if(GetReader()->GetDataType() == AliCaloTrackReader::kESD){
+        //printf("%s: time %g\n",fCalorimeter.Data(), time);
+        fhTime     ->Fill(time);
+        fhTimeId   ->Fill(time,id);
+        fhTimeAmp  ->Fill(amp,time);
         
-        //                                     AliESDCaloCells * cell2 = 0x0; 
-        //                                     if(fCalorimeter == "PHOS") cell2 =  GetReader()->GetInputEvent()->GetPHOSCells();
-        //                                     else                       cell2 = GetReader()->GetInputEvent()->GetEMCALCells();
-        //                                     Int_t icol2    = -1;
-        //                                     Int_t irow2    = -1;
-        //                                     Int_t iRCU2    = -1;
-        //                                     Float_t amp2   =  0.;
-        //                                     Float_t time2  =  0.;
-        //                                     Int_t id2      = -1;
-        //                                     Int_t nModule2 = -1;
-        //                                     for (Int_t iCell2 = 0; iCell2 < ncells; iCell2++) {  
-        //                                             amp2    = cell2->GetAmplitude(iCell2);
-        //                                             if(amp2 < 0.3) continue;
-        //                                             if(iCell2 == iCell) continue;
-        //                                             time2    = cell2->GetTime(iCell2)*1e9;//transform time to ns
-        //                                             //printf("%s: time %g\n",fCalorimeter.Data(), time);
-        //                                             id2      = cell2->GetCellNumber(iCell2);
-        //                                             nModule2 = GetModuleNumberCellIndexes(cell2->GetCellNumber(iCell2), fCalorimeter, icol2, irow2, iRCU2);
-        //                                             Int_t index = (nModule2*fNRCU+iRCU2)+(fNModules*fNRCU)*(iRCU+fNRCU*nModule); 
-        //                                             //printf("id %d, nModule %d, iRCU %d, id2 %d, nModule2 %d, iRCU2 %d, index %d: Histo Name %s\n",id, nModule,iRCU,cell2->GetCellNumber(iCell2),nModule2,iRCU2,index, fhTimeCorrRCU[index]->GetName());
-        //                                             fhTimeCorrRCU[index]->Fill(time,time2); 
-        //                                             
-        //                                     }// second cell loop
-      }// amplitude cut
-    }//nmodules
+        //Double_t t0 = GetReader()->GetInputEvent()->GetT0();
+        //printf("---->>> Time EMCal %e, T0 %e, T0 vertex %e, T0 clock %e, T0 trig %d \n",time,t0, 
+        //        GetReader()->GetInputEvent()->GetT0zVertex(),
+        //        GetReader()->GetInputEvent()->GetT0clock(),
+        //        GetReader()->GetInputEvent()->GetT0Trig());
+        //fhT0Time     ->Fill(time-t0);
+        //fhT0TimeId   ->Fill(time-t0,id);
+        //fhT0TimeAmp  ->Fill(amp,time-t0);
+        
+        //printf("id %d, nModule %d, iRCU %d: Histo Name %s\n",id, nModule,iRCU, fhTimeAmpPerRCU[nModule*fNRCU+iRCU]->GetName());
+        //fhT0TimeAmpPerRCU[nModule*fNRCU+iRCU]->Fill(amp, time-t0);
+        
+        fhTimeAmpPerRCU  [nModule*fNRCU+iRCU]->Fill(amp, time);
+        
+        if(amp > 0.3){
+          fhGridCellsTimeMod[nModule]->Fill(icol,irow,time);
+          
+          //                                   AliESDCaloCells * cell2 = 0x0; 
+          //                                   if(fCalorimeter == "PHOS") cell2 =  GetReader()->GetInputEvent()->GetPHOSCells();
+          //                                   else                       cell2 = GetReader()->GetInputEvent()->GetEMCALCells();
+          //                                   Int_t icol2    = -1;
+          //                                   Int_t irow2    = -1;
+          //                                   Int_t iRCU2    = -1;
+          //                                   Float_t amp2   =  0.;
+          //                                   Float_t time2  =  0.;
+          //                                   Int_t id2      = -1;
+          //                                   Int_t nModule2 = -1;
+          //                                   for (Int_t iCell2 = 0; iCell2 < ncells; iCell2++) {  
+          //                                           amp2    = cell2->GetAmplitude(iCell2);
+          //                                           if(amp2 < 0.3) continue;
+          //                                           if(iCell2 == iCell) continue;
+          //                                           time2    = cell2->GetTime(iCell2)*1e9;//transform time to ns
+          //                                           //printf("%s: time %g\n",fCalorimeter.Data(), time);
+          //                                           id2      = cell2->GetCellNumber(iCell2);
+          //                                           nModule2 = GetModuleNumberCellIndexes(cell2->GetCellNumber(iCell2), fCalorimeter, icol2, irow2, iRCU2);
+          //                                           Int_t index = (nModule2*fNRCU+iRCU2)+(fNModules*fNRCU)*(iRCU+fNRCU*nModule); 
+          //                                           //printf("id %d, nModule %d, iRCU %d, id2 %d, nModule2 %d, iRCU2 %d, index %d: Histo Name %s\n",id, nModule,iRCU,cell2->GetCellNumber(iCell2),nModule2,iRCU2,index, fhTimeCorrRCU[index]->GetName());
+          //                                           fhTimeCorrRCU[index]->Fill(time,time2); 
+          //                                           
+          //                                   }// second cell loop
+          
+        }// amplitude cut
+      }
+    
     
     //Get Eta-Phi position of Cell
     if(fFillAllPosHisto)
@@ -1755,10 +1829,12 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
         fhXYZCell->Fill(xyz.X(),xyz.Y(),xyz.Z())  ;
       }//PHOS cells
     }//fill cell position histograms
+    
     if     (fCalorimeter=="EMCAL" && amp > fEMCALCellAmpMin) ncells ++ ;
     else if(fCalorimeter=="PHOS"  && amp > fPHOSCellAmpMin)  ncells ++ ;
     //else  
-    //  printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - no %s CELLS passed the analysis cut\n",fCalorimeter.Data());       
+    //  printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - no %s CELLS passed the analysis cut\n",fCalorimeter.Data());    
+    }//nmodules
   }//cell loop
   if(ncells > 0 )fhNCells->Fill(ncells) ; //fill the cells after the cut 
   
@@ -1815,20 +1891,17 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
   fhNCellsPerClusterMIP->Fill(e, nCaloCellsPerCluster,eta);
   
   //Position
-  if(fFillAllPosHisto)
-  {
-    fhXE     ->Fill(pos[0],e);
-    fhYE     ->Fill(pos[1],e);
-    fhZE     ->Fill(pos[2],e);
-    fhXYZ    ->Fill(pos[0], pos[1],pos[2]);
-    
-    fhXNCells->Fill(pos[0],nCaloCellsPerCluster);
-    fhYNCells->Fill(pos[1],nCaloCellsPerCluster);
-    fhZNCells->Fill(pos[2],nCaloCellsPerCluster);
-    Float_t rxyz = TMath::Sqrt(pos[0]*pos[0]+pos[1]*pos[1]);//+pos[2]*pos[2]);
-    fhRE     ->Fill(rxyz,e);
-    fhRNCells->Fill(rxyz  ,nCaloCellsPerCluster);
-  }
+  fhXE     ->Fill(pos[0],e);
+  fhYE     ->Fill(pos[1],e);
+  fhZE     ->Fill(pos[2],e);
+  fhXYZ    ->Fill(pos[0], pos[1],pos[2]);
+    
+  fhXNCells->Fill(pos[0],nCaloCellsPerCluster);
+  fhYNCells->Fill(pos[1],nCaloCellsPerCluster);
+  fhZNCells->Fill(pos[2],nCaloCellsPerCluster);
+  Float_t rxyz = TMath::Sqrt(pos[0]*pos[0]+pos[1]*pos[1]);//+pos[2]*pos[2]);
+  fhRE     ->Fill(rxyz,e);
+  fhRNCells->Fill(rxyz  ,nCaloCellsPerCluster);
   
   fhClusterTimeEnergy->Fill(e,tof);
        
@@ -1931,10 +2004,8 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
     }
     else if(GetReader()->ReadAODMCParticles() && !GetMCAnalysisUtils()->CheckTagBit(tag, AliMCAnalysisUtils::kMCUnknown)){//it MC AOD and known tag
       //Get the list of MC particles
-      if(!GetReader()->GetAODMCParticles(0))   {
-        printf("AliAnaCalorimeterQA::ClusterHistograms() -  MCParticles not available!\n");
-        abort();
-      }                
+      if(!GetReader()->GetAODMCParticles(0)) 
+        AliFatal("MCParticles not available!");
       
       aodprimary = (AliAODMCParticle*) (GetReader()->GetAODMCParticles(0))->At(label);
       iMother = label;
@@ -2118,9 +2189,7 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
        
   //Match tracks and clusters
   //To be Modified in case of AODs
-       
-  //if(ntracksmatched==1 && trackIndex==-1) ntracksmatched=0;
-       
+               
   if( nTracksMatched > 0){
     if(fFillAllTH12){
       fhECharged      ->Fill(e);       
@@ -2151,54 +2220,53 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
     Int_t nTPC   = 0;
     
     //In case of ESDs get the parameters in this way
-    //         if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
-    if (track->GetOuterParam() ) {
-      okout = kTRUE;
-      
-      bfield = GetReader()->GetInputEvent()->GetMagneticField();
-      okpos = track->GetOuterParam()->GetXYZAt(radius,bfield,emcpos);
-      okmom = track->GetOuterParam()->GetPxPyPzAt(radius,bfield,emcmom);
-      if(!(okpos && okmom)) return;
-      
-      TVector3 position(emcpos[0],emcpos[1],emcpos[2]);
-      TVector3 momentum(emcmom[0],emcmom[1],emcmom[2]);
-      tphi = position.Phi();
-      teta = position.Eta();
-      tmom = momentum.Mag();
-      
-      //Double_t tphi  = track->GetOuterParam()->Phi();
-      //Double_t teta  = track->GetOuterParam()->Eta();
-      //Double_t tmom  = track->GetOuterParam()->P();
-      tpt       = track->Pt();
-      tmom2     = track->P();
-      tpcSignal = track->GetTPCsignal();
-      
-      nITS = track->GetNcls(0);
-      nTPC = track->GetNcls(1);
-    }//Outer param available 
-    //}// ESDs
-    //                 else if(GetReader()->GetDataType()==AliCaloTrackReader::kAOD) {
-    //                         AliAODPid* pid = (AliAODPid*) ((AliAODTrack *) track)->GetDetPid();
-    //                         if (pid) {
-    //                                 okout = kTRUE;
-    //                                 pid->GetEMCALPosition(emcpos);
-    //                                 pid->GetEMCALMomentum(emcmom);  
-    //                                 
-    //                                 TVector3 position(emcpos[0],emcpos[1],emcpos[2]);
-    //                                 TVector3 momentum(emcmom[0],emcmom[1],emcmom[2]);
-    //                                 tphi = position.Phi();
-    //                                 teta = position.Eta();
-    //                                 tmom = momentum.Mag();
-    //                                 
-    //                                 tpt       = ((AliAODTrack*)track)->Pt();
-    //                                 tmom2     = ((AliAODTrack*)track)->P();
-    //                                 tpcSignal = pid->GetTPCsignal();
-    //                         
-    //                                 //nITS = ((AliAODTrack*)track)->GetNcls(0);
-    //                                 //nTPC = ((AliAODTrack*)track)->GetNcls(1);
-    //                         }//Outer param available 
-    //                 }//AODs
-    //                 else return; //Do nothing case not implemented.
+    if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
+      if (track->GetOuterParam() ) {
+        okout = kTRUE;
+        
+        bfield = GetReader()->GetInputEvent()->GetMagneticField();
+        okpos = track->GetOuterParam()->GetXYZAt(radius,bfield,emcpos);
+        okmom = track->GetOuterParam()->GetPxPyPzAt(radius,bfield,emcmom);
+        if(!(okpos && okmom)) return;
+        
+        TVector3 position(emcpos[0],emcpos[1],emcpos[2]);
+        TVector3 momentum(emcmom[0],emcmom[1],emcmom[2]);
+        tphi = position.Phi();
+        teta = position.Eta();
+        tmom = momentum.Mag();
+        
+        //Double_t tphi  = track->GetOuterParam()->Phi();
+        //Double_t teta  = track->GetOuterParam()->Eta();
+        //Double_t tmom  = track->GetOuterParam()->P();
+        tpt       = track->Pt();
+        tmom2     = track->P();
+        tpcSignal = track->GetTPCsignal();
+        
+        nITS = track->GetNcls(0);
+        nTPC = track->GetNcls(1);
+      }//Outer param available 
+    }// ESDs
+    else if(GetReader()->GetDataType()==AliCaloTrackReader::kAOD) {
+      AliAODPid* pid = (AliAODPid*) ((AliAODTrack *) track)->GetDetPid();
+      if (pid) {
+        okout = kTRUE;
+        pid->GetEMCALPosition(emcpos);
+        pid->GetEMCALMomentum(emcmom); 
+        
+        TVector3 position(emcpos[0],emcpos[1],emcpos[2]);
+        TVector3 momentum(emcmom[0],emcmom[1],emcmom[2]);
+        tphi = position.Phi();
+        teta = position.Eta();
+        tmom = momentum.Mag();
+        
+        tpt       = track->Pt();
+        tmom2     = track->P();
+        tpcSignal = pid->GetTPCsignal();
+        
+        //nITS = ((AliAODTrack*)track)->GetNcls(0);
+        //nTPC = ((AliAODTrack*)track)->GetNcls(1);
+      }//pid 
+    }//AODs
                
     if(okout){
       Double_t deta = teta - eta;
@@ -2267,8 +2335,8 @@ void AliAnaCalorimeterQA::Correlate(){
   // Correlate information from PHOS and EMCAL and with V0 and track multiplicity
  
   //Clusters 
-  TObjArray * caloClustersEMCAL = GetAODEMCAL();
-  TObjArray * caloClustersPHOS  = GetAODPHOS();
+  TObjArray * caloClustersEMCAL = GetEMCALClusters();
+  TObjArray * caloClustersPHOS  = GetPHOSClusters();
   
   Int_t nclEMCAL = caloClustersEMCAL->GetEntriesFast();
   Int_t nclPHOS  = caloClustersPHOS ->GetEntriesFast();