]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG4/PartCorrDep/AliAnaCalorimeterQA.cxx
Many fixes:
[u/mrichter/AliRoot.git] / PWG4 / PartCorrDep / AliAnaCalorimeterQA.cxx
index 5bfb531f93d93e3f3f6cebcafad7f7f4f93336f0..d3b4cbddcf34b07583a11e542b7d07beb589c89c 100755 (executable)
@@ -57,7 +57,7 @@ ClassImp(AliAnaCalorimeterQA)
 //____________________________________________________________________________
 AliAnaCalorimeterQA::AliAnaCalorimeterQA() : 
 AliAnaPartCorrBaseClass(), fCalorimeter(""), fStyleMacro(""), 
-fMakePlots(kFALSE), fFillAllPosHisto(kFALSE), fFillAllTH12(kFALSE),
+fFillAllPosHisto(kFALSE), fFillAllTH12(kFALSE),
 fCorrelateCalos(kFALSE), fNModules(12), fNRCU(2),
 fTimeCutMin(-1), fTimeCutMax(9999999),
 fEMCALCellAmpMin(0),fPHOSCellAmpMin(0), 
@@ -1187,7 +1187,6 @@ void AliAnaCalorimeterQA::Print(const Option_t * opt) const
   AliAnaPartCorrBaseClass::Print(" ");
   
   printf("Select Calorimeter %s \n",fCalorimeter.Data());
-  printf("Make plots?        %d \n",fMakePlots);       
   printf("Plots style macro  %s \n",fStyleMacro.Data()); 
   printf("Time Cut: %3.1f < TOF  < %3.1f\n", fTimeCutMin, fTimeCutMax);
   printf("EMCAL Min Amplitude   : %2.1f GeV/c\n", fEMCALCellAmpMin) ;
@@ -1222,40 +1221,45 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
   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(!GetMCStack()) {
-       printf("AliAnaPhoton::MakeAnalysisFillHistograms() - Stack not available, is the MC handler called? STOP\n");
-       abort();
+        printf("AliAnaPhoton::MakeAnalysisFillHistograms() - Stack not available, is the MC handler called? STOP\n");
+        abort();
       }
       //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) ;
+        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()));
+        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))   {
-       printf("AliAnaPhoton::MakeAnalysisFillHistograms() -  AODMCParticles not available!\n");
-       abort();
+        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) ;
+        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()));
+        mom.SetPxPyPzE(aodprimary->Px(),aodprimary->Py(),aodprimary->Pz(),aodprimary->E());
+        MCHistograms(mom,TMath::Abs(aodprimary->GetPdgCode()));
       } //primary loop
       
     }
@@ -1295,11 +1299,7 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
     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;
@@ -1326,7 +1326,7 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
         Bool_t in = kTRUE;
         if(IsFiducialCutOn()) in =  GetFiducialCut()->IsInFiducialCut(mom,fCalorimeter) ;
         if(!in) continue;
-                
+        
         //Get module of cluster
         nCaloClustersAccepted++;
         nModule = GetModuleNumber(clus);
@@ -1339,7 +1339,7 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
         //Cells per cluster
         nCaloCellsPerCluster =  clus->GetNCells();
         //if(mom.E() > 10 && nCaloCellsPerCluster == 1 ) printf("%s:************** E = %f ********** ncells = %d\n",fCalorimeter.Data(), mom.E(),nCaloCellsPerCluster);
-   
+        
         //matched cluster with tracks
         nTracksMatched = clus->GetNTracksMatched();
         trackIndex     = clus->GetTrackMatchedIndex();
@@ -1473,8 +1473,8 @@ 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;
@@ -1687,8 +1687,8 @@ void  AliAnaCalorimeterQA::MakeAnalysisFillHistograms()
     }//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());       
+    //else  
+    //  printf("AliAnaCalorimeterQA::MakeAnalysisFillHistograms() - no %s CELLS passed the analysis cut\n",fCalorimeter.Data());       
   }//cell loop
   if(ncells > 0 )fhNCells->Fill(ncells) ; //fill the cells after the cut 
   
@@ -1751,7 +1751,7 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
     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);
@@ -1790,8 +1790,8 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
     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 ;
+        if(GetDebug() >= 0) printf("AliAnaCalorimeterQA::ClusterHistograms() *** large label ***:  label %d, n tracks %d \n", label, GetMCStack()->GetNtrack());
+        return ;
       }
       
       primary = GetMCStack()->Particle(label);
@@ -1804,50 +1804,50 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
       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);
+        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)){
         //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) || 
          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);
       }
       
@@ -1862,8 +1862,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();
+        printf("AliAnaCalorimeterQA::ClusterHistograms() -  MCParticles not available!\n");
+        abort();
       }                
       
       aodprimary = (AliAODMCParticle*) (GetReader()->GetAODMCParticles(0))->At(label);
@@ -1876,58 +1876,58 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
       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",
+        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(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) || 
          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){
+          
+          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(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");
+          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);
       }        
       
@@ -2009,10 +2009,10 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
       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);
+        fhEleECharged     ->Fill(e,eMC);               
+        fhElePtCharged    ->Fill(pt,ptMC);
+        fhElePhiCharged   ->Fill(phi,phiMC);
+        fhEleEtaCharged   ->Fill(eta,etaMC);
       }
     }
     else if(charge == 0){
@@ -2023,10 +2023,10 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
       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);
+        fhNeHadECharged     ->Fill(e,eMC);             
+        fhNeHadPtCharged    ->Fill(pt,ptMC);
+        fhNeHadPhiCharged   ->Fill(phi,phiMC);
+        fhNeHadEtaCharged   ->Fill(eta,etaMC);
       }
     }
     else if(charge!=0){
@@ -2037,10 +2037,10 @@ void AliAnaCalorimeterQA::ClusterHistograms(const TLorentzVector mom, const Doub
       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);
+        fhChHadECharged     ->Fill(e,eMC);             
+        fhChHadPtCharged    ->Fill(pt,ptMC);
+        fhChHadPhiCharged   ->Fill(phi,phiMC);
+        fhChHadEtaCharged   ->Fill(eta,etaMC);
       }
     }
   }//Work with MC
@@ -2633,460 +2633,462 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
 {
   //Do plots if requested      
   
-       if(GetDebug() > 0) printf("AliAnaCalorimeterQA::Terminate() - Make plots for %s? %d\n",fCalorimeter.Data(), fMakePlots);
-       if(!fMakePlots) return;
-       
+  if(GetDebug() > 0) printf("AliAnaCalorimeterQA::Terminate() - Make plots for %s? %d\n",fCalorimeter.Data(), MakePlotsOn());
   //Do some plots to end
   if(fStyleMacro!="")gROOT->Macro(fStyleMacro); 
   //Recover histograms from output histograms list, needed for distributed analysis.   
-       ReadHistograms(outputList);
-       
+  ReadHistograms(outputList);
+  
   //printf(" AliAnaCalorimeterQA::Terminate()  *** %s Report:", GetName()) ; 
   //printf(" AliAnaCalorimeterQA::Terminate()        pt         : %5.3f , RMS : %5.3f \n", fhPt->GetMean(),   fhPt->GetRMS() ) ;
   
   const Int_t buffersize = 255;
-       char name[buffersize];
-       char cname[buffersize];
-       
+  char name[buffersize];
+  char cname[buffersize];
+  
   //In case terminate is executed after the analysis, in a second step, and we want to rebin or to change the range of the histograms for plotting
-       Int_t nptbins     = GetHistoPtBins();           Float_t ptmax     = GetHistoPtMax();           Float_t ptmin     = GetHistoPtMin();
-       Int_t nphibins    = GetHistoPhiBins();          Float_t phimax    = GetHistoPhiMax();          Float_t phimin    = GetHistoPhiMin();
-       Int_t netabins    = GetHistoEtaBins();          Float_t etamax    = GetHistoEtaMax();          Float_t etamin    = GetHistoEtaMin();    
+  Int_t nptbins     = GetHistoPtBins();                Float_t ptmax     = GetHistoPtMax();           Float_t ptmin     = GetHistoPtMin();
+  Int_t nphibins    = GetHistoPhiBins();          Float_t phimax    = GetHistoPhiMax();          Float_t phimin    = GetHistoPhiMin();
+  Int_t netabins    = GetHistoEtaBins();          Float_t etamax    = GetHistoEtaMax();          Float_t etamin    = GetHistoEtaMin(); 
   //   Int_t nmassbins   = GetHistoMassBins();         Float_t massmax   = GetHistoMassMax();         Float_t massmin   = GetHistoMassMin();
   //   Int_t nasymbins   = GetHistoAsymmetryBins();    Float_t asymmax   = GetHistoAsymmetryMax();    Float_t asymmin   = GetHistoAsymmetryMin();
   //   Int_t nPoverEbins = GetHistoPOverEBins();       Float_t pOverEmax = GetHistoPOverEMax();       Float_t pOverEmin = GetHistoPOverEMin();
   //   Int_t ndedxbins   = GetHistodEdxBins();         Float_t dedxmax   = GetHistodEdxMax();         Float_t dedxmin   = GetHistodEdxMin();
   //   Int_t ndRbins     = GetHistodRBins();           Float_t dRmax     = GetHistodRMax();           Float_t dRmin     = GetHistodRMin();
-       Int_t ntimebins   = GetHistoTimeBins();         Float_t timemax   = GetHistoTimeMax();         Float_t timemin   = GetHistoTimeMin();       
-       Int_t nbins       = GetHistoNClusterCellBins(); Int_t nmax        = GetHistoNClusterCellMax(); Int_t nmin        = GetHistoNClusterCellMin(); 
+  Int_t ntimebins   = GetHistoTimeBins();         Float_t timemax   = GetHistoTimeMax();         Float_t timemin   = GetHistoTimeMin();       
+  Int_t nbins       = GetHistoNClusterCellBins(); Int_t nmax        = GetHistoNClusterCellMax(); Int_t nmin        = GetHistoNClusterCellMin(); 
   //   Int_t nratiobins  = GetHistoRatioBins();        Float_t ratiomax  = GetHistoRatioMax();        Float_t ratiomin  = GetHistoRatioMin();
   //   Int_t nvdistbins  = GetHistoVertexDistBins();   Float_t vdistmax  = GetHistoVertexDistMax();   Float_t vdistmin  = GetHistoVertexDistMin();
-       Int_t rbins       = GetHistoRBins();            Float_t rmax        = GetHistoRMax();          Float_t rmin      = GetHistoRMin(); 
-       Int_t xbins       = GetHistoXBins();            Float_t xmax        = GetHistoXMax();          Float_t xmin      = GetHistoXMin(); 
-       Int_t ybins       = GetHistoYBins();            Float_t ymax        = GetHistoYMax();          Float_t ymin      = GetHistoYMin(); 
-       Int_t zbins       = GetHistoZBins();            Float_t zmax        = GetHistoZMax();          Float_t zmin      = GetHistoZMin(); 
-       
+  Int_t rbins       = GetHistoRBins();            Float_t rmax        = GetHistoRMax();          Float_t rmin      = GetHistoRMin(); 
+  Int_t xbins       = GetHistoXBins();            Float_t xmax        = GetHistoXMax();          Float_t xmin      = GetHistoXMin(); 
+  Int_t ybins       = GetHistoYBins();            Float_t ymax        = GetHistoYMax();          Float_t ymin      = GetHistoYMin(); 
+  Int_t zbins       = GetHistoZBins();            Float_t zmax        = GetHistoZMax();          Float_t zmin      = GetHistoZMin(); 
+  
   //Color code for the different modules
-       Int_t modColorIndex[]={2,4,6,8};
-       
+  Int_t modColorIndex[]={2,4,6,8};
+  
   //--------------------------------------------------
   // Cluster energy distributions, module dependence
   //--------------------------------------------------
-       snprintf(cname,buffersize,"QA_%s_ClusterEnergy",fCalorimeter.Data());
-       TCanvas  * c = new TCanvas(cname, "Energy distributions", 800, 400) ;
-       c->Divide(2, 1);
-       Int_t rbE = GetNewRebinForRePlotting((TH1D*)fhE, ptmin, ptmax,nptbins) ;
+  snprintf(cname,buffersize,"QA_%s_ClusterEnergy",fCalorimeter.Data());
+  TCanvas  * c = new TCanvas(cname, "Energy distributions", 800, 400) ;
+  c->Divide(2, 1);
+  Int_t rbE = GetNewRebinForRePlotting((TH1D*)fhE, ptmin, ptmax,nptbins) ;
   //printf("new E rb %d\n",rbE);
-       fhE->Rebin(rbE);
-       fhE->SetAxisRange(ptmin,ptmax,"X");
-       c->cd(1) ; 
-       if(fhE->GetEntries() > 0) gPad->SetLogy();
-       TLegend pLegendE(0.7,0.6,0.9,0.8);
-       pLegendE.SetTextSize(0.03);
-       pLegendE.AddEntry(fhE,"all modules","L");
-       pLegendE.SetFillColor(10);
-       pLegendE.SetBorderSize(1);
-       
-       fhE->SetMinimum(1);     
-       fhE->SetLineColor(1);
-       fhE->Draw("HE");
-       for(Int_t imod = 0; imod < fNModules; imod++){
-               fhEMod[imod]->Rebin(rbE);
-               fhEMod[imod]->SetLineColor(modColorIndex[imod]);
-               fhEMod[imod]->Draw("HE same");
-               pLegendE.AddEntry(fhEMod[imod],Form("module %d",imod),"L");
-       }
-       pLegendE.Draw();
-       
+  fhE->Rebin(rbE);
+  fhE->SetAxisRange(ptmin,ptmax,"X");
+  c->cd(1) ; 
+  if(fhE->GetEntries() > 0) gPad->SetLogy();
+  TLegend pLegendE(0.7,0.6,0.9,0.8);
+  pLegendE.SetTextSize(0.03);
+  pLegendE.AddEntry(fhE,"all modules","L");
+  pLegendE.SetFillColor(10);
+  pLegendE.SetBorderSize(1);
+  
+  fhE->SetMinimum(1);  
+  fhE->SetLineColor(1);
+  fhE->Draw("HE");
+  for(Int_t imod = 0; imod < fNModules; imod++){
+    fhEMod[imod]->Rebin(rbE);
+    fhEMod[imod]->SetLineColor(modColorIndex[imod]);
+    fhEMod[imod]->Draw("HE same");
+    pLegendE.AddEntry(fhEMod[imod],Form("module %d",imod),"L");
+  }
+  pLegendE.Draw();
+  
   //Ratio of modules
-       c->cd(2) ; 
-       TLegend pLegendER(0.55,0.8,0.9,0.9);
-       pLegendER.SetTextSize(0.03);
-       pLegendER.SetFillColor(10);
-       pLegendER.SetBorderSize(1);
-  
-       for(Int_t imod = 1; imod < fNModules; imod++){
-               TH1D * htmp = (TH1D*)fhEMod[imod]->Clone(Form("hERat%d",imod));
-               htmp->Divide(fhEMod[0]);
-               htmp->SetLineColor(modColorIndex[imod]);
-               if(imod==1){
-                       htmp->SetTitle("Ratio module X / module 0");
-                       htmp->SetAxisRange(ptmin,ptmax,"X");
-                       htmp->SetMaximum(5);
-                       htmp->SetMinimum(0);
-                       htmp->SetAxisRange(ptmin,ptmax,"X");
-                       htmp->Draw("HE");
-               }
-               else 
-                       htmp->Draw("same HE");
-               
-               pLegendER.AddEntry(fhEMod[imod],Form("module %d / module 0",imod),"L");
-       }
-       pLegendER.Draw();
-       
-       snprintf(name,buffersize,"QA_%s_ClusterEnergy.eps",fCalorimeter.Data());
-       c->Print(name); printf("Plot: %s\n",name);
-       
+  c->cd(2) ; 
+  TLegend pLegendER(0.55,0.8,0.9,0.9);
+  pLegendER.SetTextSize(0.03);
+  pLegendER.SetFillColor(10);
+  pLegendER.SetBorderSize(1);
+  
+  for(Int_t imod = 1; imod < fNModules; imod++){
+    TH1D * htmp = (TH1D*)fhEMod[imod]->Clone(Form("hERat%d",imod));
+    htmp->Divide(fhEMod[0]);
+    htmp->SetLineColor(modColorIndex[imod]);
+    if(imod==1){
+      htmp->SetTitle("Ratio module X / module 0");
+      htmp->SetAxisRange(ptmin,ptmax,"X");
+      htmp->SetMaximum(5);
+      htmp->SetMinimum(0);
+      htmp->SetAxisRange(ptmin,ptmax,"X");
+      htmp->Draw("HE");
+    }
+    else 
+      htmp->Draw("same HE");
+    
+    pLegendER.AddEntry(fhEMod[imod],Form("module %d / module 0",imod),"L");
+  }
+  pLegendER.Draw();
+  
+  snprintf(name,buffersize,"QA_%s_ClusterEnergy.eps",fCalorimeter.Data());
+  c->Print(name); printf("Plot: %s\n",name);
+  
   //--------------------------------------------------
   // Cell energy distributions, module dependence
   //--------------------------------------------------
-       snprintf(cname,buffersize,"%s_QA_CellEnergy",fCalorimeter.Data());
-       TCanvas  * ca = new TCanvas(cname, "Cell Energy distributions", 800, 400) ;
-       ca->Divide(2, 1);
-       
-       Int_t rbAmp = GetNewRebinForRePlotting((TH1D*)fhAmplitude, ptmin, ptmax,nptbins*2) ;
+  snprintf(cname,buffersize,"%s_QA_CellEnergy",fCalorimeter.Data());
+  TCanvas  * ca = new TCanvas(cname, "Cell Energy distributions", 800, 400) ;
+  ca->Divide(2, 1);
+  
+  Int_t rbAmp = GetNewRebinForRePlotting((TH1D*)fhAmplitude, ptmin, ptmax,nptbins*2) ;
   //printf("new Amp rb %d\n",rbAmp);
-       fhAmplitude->Rebin(rbAmp);
-       fhAmplitude->SetAxisRange(ptmin,ptmax,"X");
-       
-       ca->cd(1) ; 
-       if(fhAmplitude->GetEntries() > 0) gPad->SetLogy();
-       TLegend pLegendA(0.7,0.6,0.9,0.8);
-       pLegendA.SetTextSize(0.03);
-       pLegendA.AddEntry(fhE,"all modules","L");
-       pLegendA.SetFillColor(10);
-       pLegendA.SetBorderSize(1);
-       fhAmplitude->SetMinimum(0.1);
-       fhAmplitude->SetLineColor(1);
-       fhAmplitude->Draw("HE");
-       
-       for(Int_t imod = 0; imod < fNModules; imod++){
-               fhAmplitudeMod[imod]->Rebin(rbAmp);
-               fhAmplitudeMod[imod]->SetLineColor(modColorIndex[imod]);
-               fhAmplitudeMod[imod]->Draw("HE same");
-               pLegendA.AddEntry(fhAmplitudeMod[imod],Form("module %d",imod),"L");
-       }
-       pLegendA.Draw();
-       
-       
-       ca->cd(2) ; 
-       TLegend pLegendAR(0.55,0.8,0.9,0.9);
-       pLegendAR.SetTextSize(0.03);
-       pLegendAR.SetFillColor(10);
-       pLegendAR.SetBorderSize(1);
-       
-       for(Int_t imod = 1; imod < fNModules; imod++){
-               TH1D * htmp = (TH1D*)fhAmplitudeMod[imod]->Clone(Form("hAmpRat%d",imod));
-               htmp->Divide(fhAmplitudeMod[0]);
-               htmp->SetLineColor(modColorIndex[imod]);
-               if(imod==1){
-                       htmp->SetTitle("Ratio cells energy in  module X / module 0");
-                       htmp->SetAxisRange(ptmin,ptmax,"X");
-                       htmp->SetMaximum(5);
-                       htmp->SetMinimum(0);
-                       htmp->Draw("HE");
-               }
-               else 
-                       htmp->Draw("same HE");
-               pLegendAR.AddEntry(fhAmplitudeMod[imod],Form("module %d",imod),"L");
-       }
-       
-       pLegendAR.Draw();
-       snprintf(name,buffersize,"QA_%s_CellEnergy.eps",fCalorimeter.Data());
-       ca->Print(name); printf("Plot: %s\n",name);     
+  fhAmplitude->Rebin(rbAmp);
+  fhAmplitude->SetAxisRange(ptmin,ptmax,"X");
+  
+  ca->cd(1) ; 
+  if(fhAmplitude->GetEntries() > 0) gPad->SetLogy();
+  TLegend pLegendA(0.7,0.6,0.9,0.8);
+  pLegendA.SetTextSize(0.03);
+  pLegendA.AddEntry(fhE,"all modules","L");
+  pLegendA.SetFillColor(10);
+  pLegendA.SetBorderSize(1);
+  fhAmplitude->SetMinimum(0.1);
+  fhAmplitude->SetLineColor(1);
+  fhAmplitude->Draw("HE");
+  
+  for(Int_t imod = 0; imod < fNModules; imod++){
+    fhAmplitudeMod[imod]->Rebin(rbAmp);
+    fhAmplitudeMod[imod]->SetLineColor(modColorIndex[imod]);
+    fhAmplitudeMod[imod]->Draw("HE same");
+    pLegendA.AddEntry(fhAmplitudeMod[imod],Form("module %d",imod),"L");
+  }
+  pLegendA.Draw();
+  
+  
+  ca->cd(2) ; 
+  TLegend pLegendAR(0.55,0.8,0.9,0.9);
+  pLegendAR.SetTextSize(0.03);
+  pLegendAR.SetFillColor(10);
+  pLegendAR.SetBorderSize(1);
+  
+  for(Int_t imod = 1; imod < fNModules; imod++){
+    TH1D * htmp = (TH1D*)fhAmplitudeMod[imod]->Clone(Form("hAmpRat%d",imod));
+    htmp->Divide(fhAmplitudeMod[0]);
+    htmp->SetLineColor(modColorIndex[imod]);
+    if(imod==1){
+      htmp->SetTitle("Ratio cells energy in  module X / module 0");
+      htmp->SetAxisRange(ptmin,ptmax,"X");
+      htmp->SetMaximum(5);
+      htmp->SetMinimum(0);
+      htmp->Draw("HE");
+    }
+    else 
+      htmp->Draw("same HE");
+    pLegendAR.AddEntry(fhAmplitudeMod[imod],Form("module %d",imod),"L");
+  }
+  
+  pLegendAR.Draw();
+  snprintf(name,buffersize,"QA_%s_CellEnergy.eps",fCalorimeter.Data());
+  ca->Print(name); printf("Plot: %s\n",name);  
   
   //----------------------------------------------------------
   // Cell energy distributions, FRACTION of module dependence
   // See Super Module calibration difference
   //---------------------------------------------------------  
-       if(fCalorimeter=="EMCAL"){
+  if(fCalorimeter=="EMCAL"){
     //Close To Eta 0 
-               snprintf(cname,buffersize,"%s_QA_SMThirds",fCalorimeter.Data());
-               TCanvas  * cfrac = new TCanvas(cname, "SM Thirds ratios", 800, 1200) ;
-               cfrac->Divide(2, 3);
-               cfrac->cd(1) ; 
-               if(fhAmplitude->GetEntries() > 0) 
-                       gPad->SetLogy();
-               TLegend pLegend1(0.6,0.6,0.9,0.8);
-               pLegend1.SetTextSize(0.03);
-               pLegend1.SetFillColor(10);
-               pLegend1.SetBorderSize(1);
-               pLegend1.SetHeader("Third close to Eta=0");
-               fhAmplitudeModFraction[0]->SetTitle("Third close to Eta=0");
-               fhAmplitudeModFraction[0]->SetAxisRange(ptmin,ptmax,"X");
-               fhAmplitudeModFraction[0]->Draw("axis");
-               TH1D * hAverageThird1 = (TH1D *)fhAmplitudeModFraction[3*0+2]->Clone("AverageThird1");
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       Int_t ifrac = 0;
-                       if(imod%2==0) ifrac = 2;
-                       if(imod > 0) hAverageThird1->Add( fhAmplitudeModFraction[3*imod+ifrac]);
-                       fhAmplitudeModFraction[3*imod+ifrac]->SetLineColor(modColorIndex[imod]);
-                       fhAmplitudeModFraction[3*imod+ifrac]->Draw("HE same");
-                       pLegend1.AddEntry(fhAmplitudeModFraction[3*imod+ifrac],Form("super module %d",imod),"L");
-               }
-               hAverageThird1 ->Scale(1./fNModules);
-               pLegend1.Draw();
+    snprintf(cname,buffersize,"%s_QA_SMThirds",fCalorimeter.Data());
+    TCanvas  * cfrac = new TCanvas(cname, "SM Thirds ratios", 800, 1200) ;
+    cfrac->Divide(2, 3);
+    cfrac->cd(1) ; 
+    if(fhAmplitude->GetEntries() > 0) 
+      gPad->SetLogy();
+    TLegend pLegend1(0.6,0.6,0.9,0.8);
+    pLegend1.SetTextSize(0.03);
+    pLegend1.SetFillColor(10);
+    pLegend1.SetBorderSize(1);
+    pLegend1.SetHeader("Third close to Eta=0");
+    fhAmplitudeModFraction[0]->SetTitle("Third close to Eta=0");
+    fhAmplitudeModFraction[0]->SetAxisRange(ptmin,ptmax,"X");
+    fhAmplitudeModFraction[0]->Draw("axis");
+    TH1D * hAverageThird1 = (TH1D *)fhAmplitudeModFraction[3*0+2]->Clone("AverageThird1");
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      Int_t ifrac = 0;
+      if(imod%2==0) ifrac = 2;
+      if(imod > 0) hAverageThird1->Add( fhAmplitudeModFraction[3*imod+ifrac]);
+      fhAmplitudeModFraction[3*imod+ifrac]->SetLineColor(modColorIndex[imod]);
+      fhAmplitudeModFraction[3*imod+ifrac]->Draw("HE same");
+      pLegend1.AddEntry(fhAmplitudeModFraction[3*imod+ifrac],Form("super module %d",imod),"L");
+    }
+    hAverageThird1 ->Scale(1./fNModules);
+    pLegend1.Draw();
     //Ratio
-               cfrac->cd(2) ; 
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       Int_t ifrac = 0;
-                       if(imod%2==0) ifrac = 2;
-                       TH1D * htmp =  (TH1D*)fhAmplitudeModFraction[3*imod+ifrac]->Clone(Form("ThirdFractionAverage_%d_%d",imod,ifrac));
-                       htmp->Divide(hAverageThird1);
-                       if(imod ==0) {
-                               htmp ->SetTitle("Close to eta = 0");
-                               htmp ->SetMaximum(5);
-                               htmp ->SetMinimum(0);
-                               htmp ->SetAxisRange(ptmin,ptmax,"X");
-                               htmp ->SetYTitle("ratio third to average");
-                               htmp -> Draw("HE");
-                       }
-                       else htmp -> Draw("same HE");
-               }
+    cfrac->cd(2) ; 
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      Int_t ifrac = 0;
+      if(imod%2==0) ifrac = 2;
+      TH1D * htmp =  (TH1D*)fhAmplitudeModFraction[3*imod+ifrac]->Clone(Form("ThirdFractionAverage_%d_%d",imod,ifrac));
+      htmp->Divide(hAverageThird1);
+      if(imod ==0) {
+       htmp ->SetTitle("Close to eta = 0");
+       htmp ->SetMaximum(5);
+       htmp ->SetMinimum(0);
+       htmp ->SetAxisRange(ptmin,ptmax,"X");
+       htmp ->SetYTitle("ratio third to average");
+       htmp -> Draw("HE");
+      }
+      else htmp -> Draw("same HE");
+    }
     //pLegend1.Draw();
-               
+    
     //Middle Eta
-               cfrac->cd(3) ; 
-               if(fhAmplitude->GetEntries() > 0) 
-                       gPad->SetLogy();
-               TLegend pLegend2(0.6,0.6,0.9,0.8);
-               pLegend2.SetTextSize(0.03);
-               pLegend2.SetFillColor(10);
-               pLegend2.SetBorderSize(1);
-               pLegend2.SetHeader("Middle Third");
-               
-               fhAmplitudeModFraction[0]->SetTitle("Middle Third");
-               fhAmplitudeModFraction[0]->SetAxisRange(ptmin,ptmax,"X");
-               fhAmplitudeModFraction[0]->Draw("axis");
-               
-               TH1D * hAverageThird2 = (TH1D *)fhAmplitudeModFraction[3*0+1]->Clone("AverageThird2");
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       Int_t ifrac = 1;
-                       if(imod > 0) hAverageThird2->Add( fhAmplitudeModFraction[3*imod+ifrac]);
-                       fhAmplitudeModFraction[3*imod+ifrac]->SetLineColor(modColorIndex[imod]);
-                       fhAmplitudeModFraction[3*imod+ifrac]->Draw("HE same");
-                       pLegend2.AddEntry(fhAmplitudeModFraction[3*imod+ifrac],Form("super module %d",imod),"L");
-               }
-               hAverageThird2->Scale(1./fNModules);
-               pLegend2.Draw();
-               
+    cfrac->cd(3) ; 
+    if(fhAmplitude->GetEntries() > 0) 
+      gPad->SetLogy();
+    TLegend pLegend2(0.6,0.6,0.9,0.8);
+    pLegend2.SetTextSize(0.03);
+    pLegend2.SetFillColor(10);
+    pLegend2.SetBorderSize(1);
+    pLegend2.SetHeader("Middle Third");
+    
+    fhAmplitudeModFraction[0]->SetTitle("Middle Third");
+    fhAmplitudeModFraction[0]->SetAxisRange(ptmin,ptmax,"X");
+    fhAmplitudeModFraction[0]->Draw("axis");
+    
+    TH1D * hAverageThird2 = (TH1D *)fhAmplitudeModFraction[3*0+1]->Clone("AverageThird2");
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      Int_t ifrac = 1;
+      if(imod > 0) hAverageThird2->Add( fhAmplitudeModFraction[3*imod+ifrac]);
+      fhAmplitudeModFraction[3*imod+ifrac]->SetLineColor(modColorIndex[imod]);
+      fhAmplitudeModFraction[3*imod+ifrac]->Draw("HE same");
+      pLegend2.AddEntry(fhAmplitudeModFraction[3*imod+ifrac],Form("super module %d",imod),"L");
+    }
+    hAverageThird2->Scale(1./fNModules);
+    pLegend2.Draw();
+    
     //Ratio
-               cfrac->cd(4) ; 
-               
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       Int_t ifrac = 1;
-                       TH1D * htmp =  (TH1D*)fhAmplitudeModFraction[3*imod+ifrac]->Clone(Form("ThirdFractionAverage_%d_%d",imod,ifrac));
-                       htmp->Divide(hAverageThird2);
-                       if(imod ==0) {
-                               htmp ->SetTitle("Middle");
-                               htmp ->SetMaximum(5);
-                               htmp ->SetMinimum(0);
-                               htmp ->SetAxisRange(ptmin,ptmax,"X");
-                               htmp ->SetYTitle("ratio third to average");
-                               htmp -> Draw("HE");
-                       }
-                       else htmp -> Draw("same HE");
-               }
+    cfrac->cd(4) ; 
+    
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      Int_t ifrac = 1;
+      TH1D * htmp =  (TH1D*)fhAmplitudeModFraction[3*imod+ifrac]->Clone(Form("ThirdFractionAverage_%d_%d",imod,ifrac));
+      htmp->Divide(hAverageThird2);
+      if(imod ==0) {
+       htmp ->SetTitle("Middle");
+       htmp ->SetMaximum(5);
+       htmp ->SetMinimum(0);
+       htmp ->SetAxisRange(ptmin,ptmax,"X");
+       htmp ->SetYTitle("ratio third to average");
+       htmp -> Draw("HE");
+      }
+      else htmp -> Draw("same HE");
+    }
     //pLegend2.Draw();
-               
+    
     //Close To Eta 0.7 
-               cfrac->cd(5) ; 
-               if(fhAmplitude->GetEntries() > 0) 
-                       gPad->SetLogy();
-               TLegend pLegend3(0.6,0.6,0.9,0.8);
-               pLegend3.SetTextSize(0.03);
-               pLegend3.SetFillColor(10);
-               pLegend3.SetBorderSize(1);
-               pLegend3.SetHeader("Third close to Eta=0.7");
-               
-               fhAmplitudeModFraction[0]->SetTitle("Third close to Eta=0.7");
-               fhAmplitudeModFraction[0]->SetAxisRange(ptmin,ptmax,"X");
-               fhAmplitudeModFraction[0]->Draw("axis");
-               
-               TH1D * hAverageThird3 = (TH1D *)fhAmplitudeModFraction[3*0+0]->Clone("AverageThird3");
-               for(Int_t imod = 0; imod < 4; imod++){
-                       Int_t ifrac = 2;
-                       if(imod%2==0) ifrac = 0;
-                       if(imod > 0) hAverageThird3->Add( fhAmplitudeModFraction[3*imod+ifrac]);
-                       fhAmplitudeModFraction[3*imod+ifrac]->SetLineColor(modColorIndex[imod]);
-                       fhAmplitudeModFraction[3*imod+ifrac]->Draw("HE same");
-                       pLegend3.AddEntry(fhAmplitudeModFraction[3*imod+ifrac],Form("super module %d",imod),"L");
-               }
-               hAverageThird3 ->Scale(1./fNModules);
-               pLegend3.Draw();
-               
-               cfrac->cd(6) ; 
-               
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       Int_t ifrac = 2;
-                       if(imod%2==0) ifrac = 0;
-                       TH1D * htmp =  (TH1D*)fhAmplitudeModFraction[3*imod+ifrac]->Clone(Form("ThirdFractionAverage_%d_%d",imod,ifrac));
-                       htmp->Divide(hAverageThird3);
-                       if(imod ==0) {
-                               htmp ->SetTitle("Close to eta = 0.7");
-                               htmp ->SetMaximum(5);
-                               htmp ->SetMinimum(0);
-                               htmp ->SetAxisRange(ptmin,ptmax,"X");
-                               htmp ->SetYTitle("ratio third to average");
-                               htmp ->Draw("HE");
-                       }
-                       else htmp ->Draw("same HE");
-               }
+    cfrac->cd(5) ; 
+    if(fhAmplitude->GetEntries() > 0) 
+      gPad->SetLogy();
+    TLegend pLegend3(0.6,0.6,0.9,0.8);
+    pLegend3.SetTextSize(0.03);
+    pLegend3.SetFillColor(10);
+    pLegend3.SetBorderSize(1);
+    pLegend3.SetHeader("Third close to Eta=0.7");
+    
+    fhAmplitudeModFraction[0]->SetTitle("Third close to Eta=0.7");
+    fhAmplitudeModFraction[0]->SetAxisRange(ptmin,ptmax,"X");
+    fhAmplitudeModFraction[0]->Draw("axis");
+    
+    TH1D * hAverageThird3 = (TH1D *)fhAmplitudeModFraction[3*0+0]->Clone("AverageThird3");
+    for(Int_t imod = 0; imod < 4; imod++){
+      Int_t ifrac = 2;
+      if(imod%2==0) ifrac = 0;
+      if(imod > 0) hAverageThird3->Add( fhAmplitudeModFraction[3*imod+ifrac]);
+      fhAmplitudeModFraction[3*imod+ifrac]->SetLineColor(modColorIndex[imod]);
+      fhAmplitudeModFraction[3*imod+ifrac]->Draw("HE same");
+      pLegend3.AddEntry(fhAmplitudeModFraction[3*imod+ifrac],Form("super module %d",imod),"L");
+    }
+    hAverageThird3 ->Scale(1./fNModules);
+    pLegend3.Draw();
+    
+    cfrac->cd(6) ; 
+    
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      Int_t ifrac = 2;
+      if(imod%2==0) ifrac = 0;
+      TH1D * htmp =  (TH1D*)fhAmplitudeModFraction[3*imod+ifrac]->Clone(Form("ThirdFractionAverage_%d_%d",imod,ifrac));
+      htmp->Divide(hAverageThird3);
+      if(imod ==0) {
+       htmp ->SetTitle("Close to eta = 0.7");
+       htmp ->SetMaximum(5);
+       htmp ->SetMinimum(0);
+       htmp ->SetAxisRange(ptmin,ptmax,"X");
+       htmp ->SetYTitle("ratio third to average");
+       htmp ->Draw("HE");
+      }
+      else htmp ->Draw("same HE");
+    }
     //pLegend3.Draw();
-               
-               snprintf(name,buffersize,"QA_%s_CellEnergyModuleFraction.eps",fCalorimeter.Data());
-               cfrac->Print(name); printf("Create plot %s\n",name);
-       }//EMCAL        
-       
-       
+    
+    snprintf(name,buffersize,"QA_%s_CellEnergyModuleFraction.eps",fCalorimeter.Data());
+    cfrac->Print(name); printf("Create plot %s\n",name);
+  }//EMCAL     
+  
+  
   //----------------------------------------------------------
   // Cluster eta and phi distributions, energy cut dependence
   //---------------------------------------------------------  
-       
-       snprintf(cname,buffersize,"%s_QA_EtaPhiCluster",fCalorimeter.Data());
-       TCanvas  * cetaphic = new TCanvas(cname, "Eta-Phi Reconstructed distributions", 1200, 400) ;
-       cetaphic->Divide(3, 1);
-       Int_t binmin = 0;
-       Int_t rbPhi  = 1;
-       Int_t rbEta  = 1;
-       Int_t ncuts  = 7;
-       Float_t ecut[]     = {0.1, 0.3, 0.5, 0.7, 0.9, 1.1, 1.3};
-       Int_t   ecutcolor[]= {2, 4, 6, 7, 8, 9, 12};
-       TH1D * hE = fhEtaPhiE->ProjectionZ();
-       
+  
+  snprintf(cname,buffersize,"%s_QA_EtaPhiCluster",fCalorimeter.Data());
+  TCanvas  * cetaphic = new TCanvas(cname, "Eta-Phi Reconstructed distributions", 1200, 400) ;
+  cetaphic->Divide(3, 1);
+  Int_t binmin = 0;
+  Int_t rbPhi  = 1;
+  Int_t rbEta  = 1;
+  Int_t ncuts  = 7;
+  Float_t ecut[]     = {0.1, 0.3, 0.5, 0.7, 0.9, 1.1, 1.3};
+  Int_t   ecutcolor[]= {2, 4, 6, 7, 8, 9, 12};
+  TH1D * hE = fhEtaPhiE->ProjectionZ();
+  
   //PHI
-       cetaphic->cd(1) ; 
-       gPad->SetLogy();
-       gPad->SetGridy();
-       
-       TLegend pLegendPhiCl(0.83,0.6,0.95,0.93);
-       pLegendPhiCl.SetTextSize(0.03);
-       pLegendPhiCl.SetFillColor(10);
-       pLegendPhiCl.SetBorderSize(1);
-       
-       TH1D * htmp = fhEtaPhiE->ProjectionY("hphi_cluster_nocut",0,-1,0,-1);
-       if(htmp){
-         htmp->SetMinimum(1);
-         rbPhi =  GetNewRebinForRePlotting(htmp, phimin, phimax,nphibins) ;
+  cetaphic->cd(1) ; 
+  gPad->SetLogy();
+  gPad->SetGridy();
+  
+  TLegend pLegendPhiCl(0.83,0.6,0.95,0.93);
+  pLegendPhiCl.SetTextSize(0.03);
+  pLegendPhiCl.SetFillColor(10);
+  pLegendPhiCl.SetBorderSize(1);
+  
+  TH1D * htmp = fhEtaPhiE->ProjectionY("hphi_cluster_nocut",0,-1,0,-1);
+  if(htmp){
+    htmp->SetMinimum(1);
+    rbPhi =  GetNewRebinForRePlotting(htmp, phimin, phimax,nphibins) ;
     //printf("new Phi rb %d\n",rbPhi);
-         htmp->Rebin(rbPhi);
-         htmp->SetTitle("#phi of clusters for energy in cluster > threshold");
-         htmp->SetAxisRange(phimin,phimax,"X");
-         htmp->Draw("HE");
-         pLegendPhiCl.AddEntry(htmp,"No cut","L");
-    
-         for (Int_t i = 0; i < ncuts; i++) {
-           binmin =  hE->FindBin(ecut[i]);
+    htmp->Rebin(rbPhi);
+    htmp->SetTitle("#phi of clusters for energy in cluster > threshold");
+    htmp->SetAxisRange(phimin,phimax,"X");
+    htmp->Draw("HE");
+    pLegendPhiCl.AddEntry(htmp,"No cut","L");
+    
+    for (Int_t i = 0; i < ncuts; i++) {
+      binmin =  hE->FindBin(ecut[i]);
       //printf(" bins %d for e %f\n",binmin[i],ecut[i]);
-           htmp = fhEtaPhiE->ProjectionY(Form("hphi_cluster_cut%d",i),0,-1,binmin,-1);
-           htmp->SetLineColor(ecutcolor[i]);
-           htmp->Rebin(rbPhi);
-           htmp->Draw("same HE");
-           pLegendPhiCl.AddEntry(htmp,Form("E>%1.1f",ecut[i]),"L");
-           
-         }
-       }
-       pLegendPhiCl.Draw();
-       
+      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");
   
-       snprintf(name,buffersize,"QA_%s_ClusterEtaPhi.eps",fCalorimeter.Data());
-       cetaphic->Print(name); printf("Create plot %s\n",name);
+  snprintf(name,buffersize,"QA_%s_ClusterEtaPhi.eps",fCalorimeter.Data());
+  cetaphic->Print(name); printf("Create plot %s\n",name);
   
   //----------------------------------------------------------
   // Cell eta and phi distributions, energy cut dependence
   //---------------------------------------------------------  
        
-       snprintf(cname,buffersize,"%s_QA_EtaPhiCell",fCalorimeter.Data());
-       TCanvas  * cetaphicell = new TCanvas(cname, "Eta-Phi Cells distributions", 1200, 400) ;
-       cetaphicell->Divide(3, 1);
-       
+  snprintf(cname,buffersize,"%s_QA_EtaPhiCell",fCalorimeter.Data());
+  TCanvas  * cetaphicell = new TCanvas(cname, "Eta-Phi Cells distributions", 1200, 400) ;
+  cetaphicell->Divide(3, 1);
+  
   //PHI
-       cetaphicell->cd(1) ; 
-       gPad->SetLogy();
-       gPad->SetGridy();
-       
-       TLegend pLegendPhiCell(0.83,0.6,0.95,0.93);
-       pLegendPhiCell.SetTextSize(0.03);
-       pLegendPhiCell.SetFillColor(10);
-       pLegendPhiCell.SetBorderSize(1);
-       
-       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");
-       
-       snprintf(name,buffersize,"QA_%s_CellEtaPhi.eps",fCalorimeter.Data());
-       cetaphicell->Print(name); printf("Create plot %s\n",name);
-       
+  cetaphicell->cd(3) ;
+  TH2D* hEtaPhiCell = (TH2D*) fhEtaPhiAmp->Project3D("xy");
+  hEtaPhiCell->SetAxisRange(etamin,etamax,"X");
+  hEtaPhiCell->SetAxisRange(phimin,phimax,"Y");
+  hEtaPhiCell->Draw("colz");
+  
+  snprintf(name,buffersize,"QA_%s_CellEtaPhi.eps",fCalorimeter.Data());
+  cetaphicell->Print(name); printf("Create plot %s\n",name);
+  
   
   ////////////////////////////////////////        
   ///////// Global Positions /////////////       
@@ -3162,7 +3164,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     snprintf(name,buffersize,"QA_%s_ClusterX_Y_Z.eps",fCalorimeter.Data());
     cx->Print(name); printf("Create plot %s\n",name);
   }
-    //CELLS
+  //CELLS
   if(fFillAllPosHisto)
   { 
     snprintf(cname,buffersize,"%s_QA_CellXY",fCalorimeter.Data());
@@ -3243,6 +3245,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){
@@ -3271,6 +3274,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);
@@ -3292,6 +3296,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);
@@ -3314,6 +3320,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);
@@ -3354,6 +3361,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);
@@ -3380,6 +3388,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);
@@ -3400,6 +3410,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);
@@ -3421,6 +3432,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);
@@ -3459,6 +3471,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);
@@ -3485,6 +3498,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);
@@ -3506,6 +3520,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);
@@ -3517,6 +3532,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);
@@ -3527,6 +3543,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);
@@ -3538,6 +3555,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 = fhZCellE->ProjectionX(Form("hze_cells_cut%d",i),binmin,-1);
         htmp->SetLineColor(ecutcolor[i]);
         htmp->Rebin(rbZ);
@@ -3569,6 +3587,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);
@@ -3581,6 +3600,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);
@@ -3594,6 +3614,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);
@@ -3605,6 +3626,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);
@@ -3616,6 +3638,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);
@@ -3627,6 +3650,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);
@@ -3639,6 +3663,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     gPad->SetLogy();
     gPad->SetGridy();
     
+    delete htmp; 
     htmp = fhDeltaCellClusterZE->ProjectionX("hzde_nocut",0,-1);
     if(htmp){
       htmp->SetMinimum(1);
@@ -3650,6 +3675,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);
@@ -3677,7 +3703,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);
@@ -3688,6 +3714,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]);
@@ -3704,6 +3731,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);
@@ -3713,6 +3741,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]);
@@ -3725,6 +3754,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);
@@ -3734,6 +3764,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]);
@@ -3746,7 +3777,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);
@@ -3756,6 +3787,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]);
@@ -3768,7 +3800,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     snprintf(name,buffersize,"QA_%s_DeltaClusterCellX_Y_Z_R_NCellsCut.eps",fCalorimeter.Data());
     cxdn->Print(name); printf("Create plot %s\n",name);
     
-       }
+  }
   
   //----------------------------------------------------------
   //Reconstructed clusters energy-eta-phi distributions, matched with tracks
@@ -3777,7 +3809,7 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
   TH1F *       hPtChargedClone  = 0 ;
   TH1F *       hEtaChargedClone = 0 ;
   TH1F *       hPhiChargedClone = 0 ;
-       if(fFillAllTH12){
+  if(fFillAllTH12){
     hEChargedClone   = (TH1F*)   fhECharged->Clone(Form("%sClone",fhECharged->GetName()));
     hPtChargedClone  = (TH1F*)   fhPtCharged->Clone(Form("%sClone",fhPtCharged->GetName()));
     hEtaChargedClone = (TH1F*)   fhEtaCharged->Clone(Form("%sClone",fhEtaCharged->GetName()));
@@ -3850,163 +3882,165 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     
     snprintf(name,buffersize,"QA_%s_ClustersMatchedToAllRatios.eps",fCalorimeter.Data());
     ccharge->Print(name); printf("Create plot %s\n",name);
-       }
+  }
   //-------------------------------------------        
   // N Cells - N Clusters - N Cells per cluster
   //-------------------------------------------
-       snprintf(cname,buffersize,"QA_%s_nclustercells",fCalorimeter.Data());
-       TCanvas  * cN = new TCanvas(cname, " Number of CaloClusters and CaloCells", 800, 1200) ;
-       cN->Divide(2, 3);
-       
-       cN->cd(1) ; 
-       
-       TLegend pLegendN(0.7,0.6,0.9,0.8);
-       pLegendN.SetTextSize(0.03);
-       pLegendN.AddEntry(fhNClusters,"all modules","L");
-       pLegendN.SetFillColor(10);
-       pLegendN.SetBorderSize(1);
-       
-       if(fhNClusters->GetEntries() > 0) gPad->SetLogy();
-       gPad->SetLogx();
-       fhNClusters->SetLineColor(1);
-       
-       Int_t rbN = 1;
-       if(fhNClusters->GetNbinsX()> nbins) rbN = fhNClusters->GetNbinsX()/nbins;
-       
-       fhNClusters->SetAxisRange(nmin,nmax,"X");
-       fhNClusters->Draw("HE");
-       for(Int_t imod = 0; imod < fNModules; imod++){
-               fhNClustersMod[imod]->SetAxisRange(nmin,nmax,"X");
-               fhNClustersMod[imod]->SetLineColor(modColorIndex[imod]);
-               fhNClustersMod[imod]->Draw("same");
-               pLegendN.AddEntry(fhNClustersMod[imod],Form("module %d",imod),"L");
-       }
-       pLegendN.Draw();
-       
-       cN->cd(2) ; 
-       gPad->SetLogx();
-       for(Int_t imod = 1; imod < fNModules; imod++){
-               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");
-      //htmp->SetAxisRange(ptmin,ptmax,"X");
-                       htmp->SetMaximum(3.5);
-                       htmp->SetMinimum(0);
-                       htmp->Draw("HE");
-               }
-               else 
-                       htmp->Draw("same HE");
-               
-    delete [] hNCellsCluster1D;
+  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");
     
-       }
-       snprintf(name,buffersize,"QA_%s_NumberCaloClustersAndCaloCells.eps",fCalorimeter.Data());
-       cN->Print(name); printf("Print plot %s\n",name);
-       
+  }
+  
+  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");
+  }
+  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) {
+  if(GetReader()->GetDataType()==AliCaloTrackReader::kESD) {
     
-               snprintf(cname,buffersize,"QA_%s_cellstime",fCalorimeter.Data());
-               TCanvas  * ctime = new TCanvas(cname, " Cells time", 1200, 400) ;
-               ctime->Divide(3, 1);
-               
-               Int_t rbTime = 1;
-               if(fhTime->GetNbinsX()> ntimebins) rbTime = fhTime->GetNbinsX()/ntimebins;
-               
-               ctime->cd(1) ; 
-               if(fhTime->GetEntries() > 0) gPad->SetLogy();
-               fhTime->Rebin(rbTime);
-               fhTime->SetAxisRange(timemin,timemax,"X");
-               fhTime->Draw();
-    
-               ctime->cd(2) ; 
-               fhTimeId->SetTitleOffset(1.8,"Y");
-               fhTimeId->SetAxisRange(timemin,timemax,"X");
-               fhTimeId->Draw("colz");
-    
-               ctime->cd(3) ; 
-               fhTimeAmp->SetTitle("Cell Energy vs Cell Time");
-               fhTimeAmp->SetTitleOffset(1.8,"Y");
-               fhTimeAmp->SetAxisRange(timemin,timemax,"Y");
-               fhTimeAmp->SetAxisRange(ptmin,ptmax,"X");               
-               fhTimeAmp->Draw("colz");
-    
-               snprintf(name,buffersize,"QA_%s_CellsTime.eps",fCalorimeter.Data());
-               ctime->Print(name); printf("Plot: %s\n",name);
-       }
-       
-       
+    snprintf(cname,buffersize,"QA_%s_cellstime",fCalorimeter.Data());
+    TCanvas  * ctime = new TCanvas(cname, " Cells time", 1200, 400) ;
+    ctime->Divide(3, 1);
+    
+    Int_t rbTime = 1;
+    if(fhTime->GetNbinsX()> ntimebins) rbTime = fhTime->GetNbinsX()/ntimebins;
+    
+    ctime->cd(1) ; 
+    if(fhTime->GetEntries() > 0) gPad->SetLogy();
+    fhTime->Rebin(rbTime);
+    fhTime->SetAxisRange(timemin,timemax,"X");
+    fhTime->Draw();
+    
+    ctime->cd(2) ; 
+    fhTimeId->SetTitleOffset(1.8,"Y");
+    fhTimeId->SetAxisRange(timemin,timemax,"X");
+    fhTimeId->Draw("colz");
+    
+    ctime->cd(3) ; 
+    fhTimeAmp->SetTitle("Cell Energy vs Cell Time");
+    fhTimeAmp->SetTitleOffset(1.8,"Y");
+    fhTimeAmp->SetAxisRange(timemin,timemax,"Y");
+    fhTimeAmp->SetAxisRange(ptmin,ptmax,"X");          
+    fhTimeAmp->Draw("colz");
+    
+    snprintf(name,buffersize,"QA_%s_CellsTime.eps",fCalorimeter.Data());
+    ctime->Print(name); printf("Plot: %s\n",name);
+  }
+  
+  
   //---------------------------------
   //Grid of cell per module plots 
   //---------------------------------
-       {
+  {
     //Number of entries per cell
     gStyle->SetPadRightMargin(0.15);
     snprintf(cname,buffersize,"%s_QA_GridCellEntries",fCalorimeter.Data());
@@ -4090,315 +4124,315 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     snprintf(name,buffersize,"QA_%s_GridCellsAccumTime.eps",fCalorimeter.Data());
     cgridT->Print(name); printf("Create plot %s\n",name);
                
-       }
-       
+  }
+  
   //---------------------------------------------
   //Calorimeter Correlation, PHOS vs EMCAL
   //---------------------------------------------
-       if(fCorrelateCalos){
-               
-               snprintf(cname,buffersize,"QA_%s_CaloCorr_EMCALvsPHOS",fCalorimeter.Data());
-               TCanvas  * ccorr = new TCanvas(cname, " EMCAL vs PHOS", 400, 400) ;
-               ccorr->Divide(2, 2);
+  if(fCorrelateCalos){
+    
+    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) ; 
+    ccorr->cd(1) ; 
     //gPad->SetLogy();
     //gPad->SetLogx();
-               fhCaloCorrNClusters->SetAxisRange(nmin,nmax,"X");
-               fhCaloCorrNClusters->SetAxisRange(nmin,nmax,"Y");               
-               fhCaloCorrNClusters ->Draw();
+    fhCaloCorrNClusters->SetAxisRange(nmin,nmax,"X");
+    fhCaloCorrNClusters->SetAxisRange(nmin,nmax,"Y");          
+    fhCaloCorrNClusters ->Draw();
     
-               ccorr->cd(2) ; 
+    ccorr->cd(2) ; 
     //gPad->SetLogy();
     //gPad->SetLogx();
-               fhCaloCorrNCells->SetAxisRange(nmin,nmax,"X");
-               fhCaloCorrNCells->SetAxisRange(nmin,nmax,"Y");          
-               fhCaloCorrNCells->Draw();
+    fhCaloCorrNCells->SetAxisRange(nmin,nmax,"X");
+    fhCaloCorrNCells->SetAxisRange(nmin,nmax,"Y");             
+    fhCaloCorrNCells->Draw();
     
     //gPad->SetLogy();
     //gPad->SetLogx();
-               fhCaloCorrEClusters->SetAxisRange(ptmin,ptmax,"X");
-               fhCaloCorrEClusters->SetAxisRange(ptmin,ptmax,"Y");             
-               fhCaloCorrEClusters->Draw();
+    fhCaloCorrEClusters->SetAxisRange(ptmin,ptmax,"X");
+    fhCaloCorrEClusters->SetAxisRange(ptmin,ptmax,"Y");                
+    fhCaloCorrEClusters->Draw();
     
-               ccorr->cd(4) ; 
+    ccorr->cd(4) ; 
     //gPad->SetLogy();
     //gPad->SetLogx();
-               fhCaloCorrECells->SetAxisRange(ptmin,ptmax,"X");
-               fhCaloCorrECells->SetAxisRange(ptmin,ptmax,"Y");                
-               fhCaloCorrECells->Draw();
+    fhCaloCorrECells->SetAxisRange(ptmin,ptmax,"X");
+    fhCaloCorrECells->SetAxisRange(ptmin,ptmax,"Y");           
+    fhCaloCorrECells->Draw();
     
-               snprintf(name,buffersize,"QA_%s_CaloCorr_EMCALvsPHOS.eps",fCalorimeter.Data());
-               ccorr->Print(name); printf("Plot: %s\n",name);
-       }
+    snprintf(name,buffersize,"QA_%s_CaloCorr_EMCALvsPHOS.eps",fCalorimeter.Data());
+    ccorr->Print(name); printf("Plot: %s\n",name);
+  }
   
   //----------------------------
   //Invariant mass
   //-----------------------------
        
-       Int_t imbinmin = -1;
-       Int_t imbinmax = -1;
-       
-       if(fhIM->GetEntries() > 1){
-               Int_t nebins  = fhIM->GetNbinsX();
-               Int_t emax = (Int_t) fhIM->GetXaxis()->GetXmax();
-               Int_t emin = (Int_t) fhIM->GetXaxis()->GetXmin();
-               if (emin != 0 ) printf("emin != 0 \n");
+  Int_t imbinmin = -1;
+  Int_t imbinmax = -1;
+  
+  if(fhIM->GetEntries() > 1){
+    Int_t nebins  = fhIM->GetNbinsX();
+    Int_t emax = (Int_t) fhIM->GetXaxis()->GetXmax();
+    Int_t emin = (Int_t) fhIM->GetXaxis()->GetXmin();
+    if (emin != 0 ) printf("emin != 0 \n");
     //printf("IM: nBinsX %d, emin %2.2f, emax %2.2f\n",nebins,emin,emax);
-               
-               snprintf(cname,buffersize,"QA_%s_IM",fCalorimeter.Data());
+    
+    snprintf(cname,buffersize,"QA_%s_IM",fCalorimeter.Data());
     // printf("c5\n");
-               TCanvas  * c5 = new TCanvas(cname, "Invariant mass", 600, 400) ;
-               c5->Divide(2, 3);
-               
-               c5->cd(1) ; 
+    TCanvas  * c5 = new TCanvas(cname, "Invariant mass", 600, 400) ;
+    c5->Divide(2, 3);
+    
+    c5->cd(1) ; 
     //fhIM->SetLineColor(4);
     //fhIM->Draw();
-               imbinmin = 0;
-               imbinmax =  (Int_t) (1-emin)*nebins/emax;
-               TH1D *pyim1 = fhIM->ProjectionY(Form("%s_py1",fhIM->GetName()),imbinmin,imbinmax);
-               pyim1->SetTitle("E_{pair} < 1 GeV");
-               pyim1->SetLineColor(1);
-               pyim1->Draw();
-               TLegend pLegendIM(0.7,0.6,0.9,0.8);
-               pLegendIM.SetTextSize(0.03);
-               pLegendIM.AddEntry(pyim1,"all modules","L");
-               pLegendIM.SetFillColor(10);
-               pLegendIM.SetBorderSize(1);
+    imbinmin = 0;
+    imbinmax =  (Int_t) (1-emin)*nebins/emax;
+    TH1D *pyim1 = fhIM->ProjectionY(Form("%s_py1",fhIM->GetName()),imbinmin,imbinmax);
+    pyim1->SetTitle("E_{pair} < 1 GeV");
+    pyim1->SetLineColor(1);
+    pyim1->Draw();
+    TLegend pLegendIM(0.7,0.6,0.9,0.8);
+    pLegendIM.SetTextSize(0.03);
+    pLegendIM.AddEntry(pyim1,"all modules","L");
+    pLegendIM.SetFillColor(10);
+    pLegendIM.SetBorderSize(1);
     //FIXME
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyim1 = fhIMMod[imod]->ProjectionY(Form("%s_py1",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
-                       pLegendIM.AddEntry(pyim1,Form("module %d",imod),"L");
-                       pyim1->SetLineColor(imod+1);
-                       pyim1->Draw("same");
-               }
-               pLegendIM.Draw();
-               
-               c5->cd(2) ; 
-               imbinmin =  (Int_t) (1-emin)*nebins/emax;
-               imbinmax =  (Int_t) (2-emin)*nebins/emax;
-               TH1D *pyim2 = fhIM->ProjectionY(Form("%s_py2",fhIM->GetName()),imbinmin,imbinmax);
-               pyim2->SetTitle("1 < E_{pair} < 2 GeV");
-               pyim2->SetLineColor(1);
-               pyim2->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyim2 = fhIMMod[imod]->ProjectionY(Form("%s_py2",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyim2->SetLineColor(imod+1);
-                       pyim2->Draw("same");
-               }
-               
-               c5->cd(3) ; 
-               imbinmin =  (Int_t) (2-emin)*nebins/emax;
-               imbinmax =  (Int_t) (3-emin)*nebins/emax;
-               TH1D *pyim3 = fhIM->ProjectionY(Form("%s_py3",fhIM->GetName()),imbinmin,imbinmax);
-               pyim3->SetTitle("2 < E_{pair} < 3 GeV");
-               pyim3->SetLineColor(1);
-               pyim3->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyim3 = fhIMMod[imod]->ProjectionY(Form("%s_py3",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyim3->SetLineColor(imod+1);
-                       pyim3->Draw("same");
-               }
-               
-               c5->cd(4) ;
-               imbinmin =  (Int_t) (3-emin)*nebins/emax;
-               imbinmax =  (Int_t) (4-emin)*nebins/emax;
-               TH1D *pyim4 = fhIM->ProjectionY(Form("%s_py4",fhIM->GetName()),imbinmin,imbinmax);
-               pyim4->SetTitle("3 < E_{pair} < 4 GeV");
-               pyim4->SetLineColor(1);
-               pyim4->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyim4 = fhIMMod[imod]->ProjectionY(Form("%s_py4",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyim4->SetLineColor(imod+1);
-                       pyim4->Draw("same");
-               }
-               
-               c5->cd(5) ;
-               imbinmin =  (Int_t) (4-emin)*nebins/emax;
-               imbinmax =  (Int_t) (5-emin)*nebins/emax;
-               TH1D *pyim5 = fhIM->ProjectionY(Form("%s_py5",fhIM->GetName()),imbinmin,imbinmax);
-               pyim5->SetTitle("4< E_{pair} < 5 GeV");
-               pyim5->SetLineColor(1);
-               pyim5->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyim5 = fhIMMod[imod]->ProjectionY(Form("%s_py5",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyim5->SetLineColor(imod+1);
-                       pyim5->Draw("same");
-               }
-               
-               c5->cd(6) ;
-               imbinmin =  (Int_t) (5-emin)*nebins/emax;
-               imbinmax =  -1;
-               TH1D *pyim10 = fhIM->ProjectionY(Form("%s_py6",fhIM->GetName()),imbinmin,imbinmax);
-               pyim10->SetTitle("E_{pair} > 5 GeV");
-               pyim10->SetLineColor(1);
-               pyim10->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyim10 = fhIMMod[imod]->ProjectionY(Form("%s_py6",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyim10->SetLineColor(imod+1);
-                       pyim10->Draw("same");
-               }
-               
-               snprintf(name,buffersize,"QA_%s_InvariantMass.eps",fCalorimeter.Data());
-               c5->Print(name); printf("Plot: %s\n",name);
-       }
-       
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyim1 = fhIMMod[imod]->ProjectionY(Form("%s_py1",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
+      pLegendIM.AddEntry(pyim1,Form("module %d",imod),"L");
+      pyim1->SetLineColor(imod+1);
+      pyim1->Draw("same");
+    }
+    pLegendIM.Draw();
+    
+    c5->cd(2) ; 
+    imbinmin =  (Int_t) (1-emin)*nebins/emax;
+    imbinmax =  (Int_t) (2-emin)*nebins/emax;
+    TH1D *pyim2 = fhIM->ProjectionY(Form("%s_py2",fhIM->GetName()),imbinmin,imbinmax);
+    pyim2->SetTitle("1 < E_{pair} < 2 GeV");
+    pyim2->SetLineColor(1);
+    pyim2->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyim2 = fhIMMod[imod]->ProjectionY(Form("%s_py2",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
+      pyim2->SetLineColor(imod+1);
+      pyim2->Draw("same");
+    }
+    
+    c5->cd(3) ; 
+    imbinmin =  (Int_t) (2-emin)*nebins/emax;
+    imbinmax =  (Int_t) (3-emin)*nebins/emax;
+    TH1D *pyim3 = fhIM->ProjectionY(Form("%s_py3",fhIM->GetName()),imbinmin,imbinmax);
+    pyim3->SetTitle("2 < E_{pair} < 3 GeV");
+    pyim3->SetLineColor(1);
+    pyim3->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyim3 = fhIMMod[imod]->ProjectionY(Form("%s_py3",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
+      pyim3->SetLineColor(imod+1);
+      pyim3->Draw("same");
+    }
+    
+    c5->cd(4) ;
+    imbinmin =  (Int_t) (3-emin)*nebins/emax;
+    imbinmax =  (Int_t) (4-emin)*nebins/emax;
+    TH1D *pyim4 = fhIM->ProjectionY(Form("%s_py4",fhIM->GetName()),imbinmin,imbinmax);
+    pyim4->SetTitle("3 < E_{pair} < 4 GeV");
+    pyim4->SetLineColor(1);
+    pyim4->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyim4 = fhIMMod[imod]->ProjectionY(Form("%s_py4",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
+      pyim4->SetLineColor(imod+1);
+      pyim4->Draw("same");
+    }
+    
+    c5->cd(5) ;
+    imbinmin =  (Int_t) (4-emin)*nebins/emax;
+    imbinmax =  (Int_t) (5-emin)*nebins/emax;
+    TH1D *pyim5 = fhIM->ProjectionY(Form("%s_py5",fhIM->GetName()),imbinmin,imbinmax);
+    pyim5->SetTitle("4< E_{pair} < 5 GeV");
+    pyim5->SetLineColor(1);
+    pyim5->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyim5 = fhIMMod[imod]->ProjectionY(Form("%s_py5",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
+      pyim5->SetLineColor(imod+1);
+      pyim5->Draw("same");
+    }
+    
+    c5->cd(6) ;
+    imbinmin =  (Int_t) (5-emin)*nebins/emax;
+    imbinmax =  -1;
+    TH1D *pyim10 = fhIM->ProjectionY(Form("%s_py6",fhIM->GetName()),imbinmin,imbinmax);
+    pyim10->SetTitle("E_{pair} > 5 GeV");
+    pyim10->SetLineColor(1);
+    pyim10->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyim10 = fhIMMod[imod]->ProjectionY(Form("%s_py6",fhIMMod[imod]->GetName()),imbinmin,imbinmax);
+      pyim10->SetLineColor(imod+1);
+      pyim10->Draw("same");
+    }
+    
+    snprintf(name,buffersize,"QA_%s_InvariantMass.eps",fCalorimeter.Data());
+    c5->Print(name); printf("Plot: %s\n",name);
+  }
+  
   //--------------------------------------------------
   //Invariant mass, clusters with more than one cell
   //-------------------------------------------------
-       if(fhIMCellCut->GetEntries() > 1){
-               Int_t nebins  = fhIMCellCut->GetNbinsX();
-               Int_t emax = (Int_t) fhIMCellCut->GetXaxis()->GetXmax();
-               Int_t emin = (Int_t) fhIMCellCut->GetXaxis()->GetXmin();
-               if (emin != 0 ) printf("emin != 0 \n");
+  if(fhIMCellCut->GetEntries() > 1){
+    Int_t nebins  = fhIMCellCut->GetNbinsX();
+    Int_t emax = (Int_t) fhIMCellCut->GetXaxis()->GetXmax();
+    Int_t emin = (Int_t) fhIMCellCut->GetXaxis()->GetXmin();
+    if (emin != 0 ) printf("emin != 0 \n");
     //printf("IMCellCut: nBinsX %d, emin %2.2f, emax %2.2f\n",nebins,emin,emax);
                
-               snprintf(cname,buffersize,"QA_%s_IMCellCut",fCalorimeter.Data());
+    snprintf(cname,buffersize,"QA_%s_IMCellCut",fCalorimeter.Data());
     // printf("c5cc\n");
-               TCanvas  * c5cc = new TCanvas(cname, "Invariant mass, Cell Cut", 600, 400) ;
-               c5cc->Divide(2, 3);
-               
-               c5cc->cd(1) ; 
+    TCanvas  * c5cc = new TCanvas(cname, "Invariant mass, Cell Cut", 600, 400) ;
+    c5cc->Divide(2, 3);
+    
+    c5cc->cd(1) ; 
     //fhIMCellCut->SetLineColor(4);
     //fhIMCellCut->Draw();
-               imbinmin = 0;
-               imbinmax =  (Int_t) (1-emin)*nebins/emax;
-               TH1D *pyimcc1 = fhIMCellCut->ProjectionY(Form("%s_py1",fhIMCellCut->GetName()),imbinmin,imbinmax);
-               pyimcc1->SetTitle("E_{pair} < 1 GeV");
-               pyimcc1->SetLineColor(1);
-               pyimcc1->Draw();
-               TLegend pLegendIMCellCut(0.7,0.6,0.9,0.8);
-               pLegendIMCellCut.SetTextSize(0.03);
-               pLegendIMCellCut.AddEntry(pyimcc1,"all modules","L");
-               pLegendIMCellCut.SetFillColor(10);
-               pLegendIMCellCut.SetBorderSize(1);
-               
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyimcc1 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
-                       pLegendIMCellCut.AddEntry(pyimcc1,Form("module %d",imod),"L");
-                       pyimcc1->SetLineColor(imod+1);
-                       pyimcc1->Draw("same");
-               }
-               pLegendIMCellCut.Draw();
-               
-               c5cc->cd(2) ; 
-               imbinmin =  (Int_t) (1-emin)*nebins/emax;
-               imbinmax =  (Int_t) (2-emin)*nebins/emax;
-               TH1D *pyimcc2 = fhIMCellCut->ProjectionY(Form("%s_py2",fhIMCellCut->GetName()),imbinmin,imbinmax);
-               pyimcc2->SetTitle("1 < E_{pair} < 2 GeV");
-               pyimcc2->SetLineColor(1);
-               pyimcc2->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyimcc2 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyimcc2->SetLineColor(imod+1);
-                       pyimcc2->Draw("same");
-               }
-               
-               c5cc->cd(3) ; 
-               imbinmin =  (Int_t) (2-emin)*nebins/emax;
-               imbinmax =  (Int_t) (3-emin)*nebins/emax;
-               TH1D *pyimcc3 = fhIMCellCut->ProjectionY(Form("%s_py3",fhIMCellCut->GetName()),imbinmin,imbinmax);
-               pyimcc3->SetTitle("2 < E_{pair} < 3 GeV");
-               pyimcc3->SetLineColor(1);
-               pyimcc3->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyimcc3 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyimcc3->SetLineColor(imod+1);
-                       pyimcc3->Draw("same");
-               }
-               
-               c5cc->cd(4) ;
-               imbinmin =  (Int_t) (3-emin)*nebins/emax;
-               imbinmax =  (Int_t) (4-emin)*nebins/emax;
-               TH1D *pyimcc4 = fhIMCellCut->ProjectionY(Form("%s_py4",fhIMCellCut->GetName()),imbinmin,imbinmax);
-               pyimcc4->SetTitle("3 < E_{pair} < 4 GeV");
-               pyimcc4->SetLineColor(1);
-               pyimcc4->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyimcc4 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py5",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyimcc4->SetLineColor(imod+1);
-                       pyimcc4->Draw("same");
-               }
-               
-               c5cc->cd(5) ;
-               imbinmin =  (Int_t) (4-emin)*nebins/emax;
-               imbinmax =  (Int_t) (5-emin)*nebins/emax;
-               TH1D *pyimcc5cc = fhIMCellCut->ProjectionY(Form("%s_py5",fhIMCellCut->GetName()),imbinmin,imbinmax);
-               pyimcc5cc->SetTitle("4< E_{pair} < 5 GeV");
-               pyimcc5cc->SetLineColor(1);
-               pyimcc5cc->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyimcc5cc = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py5",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyimcc5cc->SetLineColor(imod+1);
-                       pyimcc5cc->Draw("same");
-               }
-               
-               c5cc->cd(6) ;
-               imbinmin =  (Int_t) (5-emin)*nebins/emax;
-               imbinmax =  -1;
-               TH1D *pyimcc10 = fhIMCellCut->ProjectionY(Form("%s_py6",fhIMCellCut->GetName()),imbinmin,imbinmax);
-               pyimcc10->SetTitle("E_{pair} > 5 GeV");
-               pyimcc10->SetLineColor(1);
-               pyimcc10->Draw();
-               for(Int_t imod = 0; imod < fNModules; imod++){
-                       pyimcc10 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
-                       pyimcc10->SetLineColor(imod+1);
-                       pyimcc10->Draw("same");
-               }
-               
-               snprintf(name,buffersize,"QA_%s_InvariantMass_CellCut.eps",fCalorimeter.Data());
-               c5cc->Print(name); printf("Plot: %s\n",name);
-       }
-       
-       
+    imbinmin = 0;
+    imbinmax =  (Int_t) (1-emin)*nebins/emax;
+    TH1D *pyimcc1 = fhIMCellCut->ProjectionY(Form("%s_py1",fhIMCellCut->GetName()),imbinmin,imbinmax);
+    pyimcc1->SetTitle("E_{pair} < 1 GeV");
+    pyimcc1->SetLineColor(1);
+    pyimcc1->Draw();
+    TLegend pLegendIMCellCut(0.7,0.6,0.9,0.8);
+    pLegendIMCellCut.SetTextSize(0.03);
+    pLegendIMCellCut.AddEntry(pyimcc1,"all modules","L");
+    pLegendIMCellCut.SetFillColor(10);
+    pLegendIMCellCut.SetBorderSize(1);
+    
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyimcc1 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
+      pLegendIMCellCut.AddEntry(pyimcc1,Form("module %d",imod),"L");
+      pyimcc1->SetLineColor(imod+1);
+      pyimcc1->Draw("same");
+    }
+    pLegendIMCellCut.Draw();
+    
+    c5cc->cd(2) ; 
+    imbinmin =  (Int_t) (1-emin)*nebins/emax;
+    imbinmax =  (Int_t) (2-emin)*nebins/emax;
+    TH1D *pyimcc2 = fhIMCellCut->ProjectionY(Form("%s_py2",fhIMCellCut->GetName()),imbinmin,imbinmax);
+    pyimcc2->SetTitle("1 < E_{pair} < 2 GeV");
+    pyimcc2->SetLineColor(1);
+    pyimcc2->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyimcc2 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
+      pyimcc2->SetLineColor(imod+1);
+      pyimcc2->Draw("same");
+    }
+    
+    c5cc->cd(3) ; 
+    imbinmin =  (Int_t) (2-emin)*nebins/emax;
+    imbinmax =  (Int_t) (3-emin)*nebins/emax;
+    TH1D *pyimcc3 = fhIMCellCut->ProjectionY(Form("%s_py3",fhIMCellCut->GetName()),imbinmin,imbinmax);
+    pyimcc3->SetTitle("2 < E_{pair} < 3 GeV");
+    pyimcc3->SetLineColor(1);
+    pyimcc3->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyimcc3 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
+      pyimcc3->SetLineColor(imod+1);
+      pyimcc3->Draw("same");
+    }
+    
+    c5cc->cd(4) ;
+    imbinmin =  (Int_t) (3-emin)*nebins/emax;
+    imbinmax =  (Int_t) (4-emin)*nebins/emax;
+    TH1D *pyimcc4 = fhIMCellCut->ProjectionY(Form("%s_py4",fhIMCellCut->GetName()),imbinmin,imbinmax);
+    pyimcc4->SetTitle("3 < E_{pair} < 4 GeV");
+    pyimcc4->SetLineColor(1);
+    pyimcc4->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyimcc4 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py5",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
+      pyimcc4->SetLineColor(imod+1);
+      pyimcc4->Draw("same");
+    }
+    
+    c5cc->cd(5) ;
+    imbinmin =  (Int_t) (4-emin)*nebins/emax;
+    imbinmax =  (Int_t) (5-emin)*nebins/emax;
+    TH1D *pyimcc5cc = fhIMCellCut->ProjectionY(Form("%s_py5",fhIMCellCut->GetName()),imbinmin,imbinmax);
+    pyimcc5cc->SetTitle("4< E_{pair} < 5 GeV");
+    pyimcc5cc->SetLineColor(1);
+    pyimcc5cc->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyimcc5cc = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py5",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
+      pyimcc5cc->SetLineColor(imod+1);
+      pyimcc5cc->Draw("same");
+    }
+    
+    c5cc->cd(6) ;
+    imbinmin =  (Int_t) (5-emin)*nebins/emax;
+    imbinmax =  -1;
+    TH1D *pyimcc10 = fhIMCellCut->ProjectionY(Form("%s_py6",fhIMCellCut->GetName()),imbinmin,imbinmax);
+    pyimcc10->SetTitle("E_{pair} > 5 GeV");
+    pyimcc10->SetLineColor(1);
+    pyimcc10->Draw();
+    for(Int_t imod = 0; imod < fNModules; imod++){
+      pyimcc10 = fhIMCellCutMod[imod]->ProjectionY(Form("%s_py1",fhIMCellCutMod[imod]->GetName()),imbinmin,imbinmax);
+      pyimcc10->SetLineColor(imod+1);
+      pyimcc10->Draw("same");
+    }
+    
+    snprintf(name,buffersize,"QA_%s_InvariantMass_CellCut.eps",fCalorimeter.Data());
+    c5cc->Print(name); printf("Plot: %s\n",name);
+  }
+  
+  
   //Asymmetry
-       if(fhAsym->GetEntries() > 1){
-               Int_t nebins  = fhAsym->GetNbinsX();
-               Int_t emax = (Int_t) fhAsym->GetXaxis()->GetXmax();
-               Int_t emin = (Int_t) fhAsym->GetXaxis()->GetXmin();
-               if (emin != 0 ) printf("emin != 0 \n");
+  if(fhAsym->GetEntries() > 1){
+    Int_t nebins  = fhAsym->GetNbinsX();
+    Int_t emax = (Int_t) fhAsym->GetXaxis()->GetXmax();
+    Int_t emin = (Int_t) fhAsym->GetXaxis()->GetXmin();
+    if (emin != 0 ) printf("emin != 0 \n");
     //printf("Asym: nBinsX %d, emin %2.2f, emax %2.2f\n",nebins,emin,emax);
-               
-               snprintf(cname,buffersize,"QA_%s_Asym",fCalorimeter.Data());
+    
+    snprintf(cname,buffersize,"QA_%s_Asym",fCalorimeter.Data());
     // printf("c5\n");
-               TCanvas  * c5b = new TCanvas(cname, "Asymmetry", 400, 400) ;
-               c5b->Divide(2, 2);
-               
-               c5b->cd(1) ; 
-               fhAsym->SetTitleOffset(1.6,"Y");
-               fhAsym->SetLineColor(4);
-               fhAsym->Draw();
-               
-               c5b->cd(2) ; 
-               imbinmin = 0;
-               imbinmax = (Int_t) (5-emin)*nebins/emax;
-               TH1D *pyAsym5 = fhAsym->ProjectionY(Form("%s_py5",fhAsym->GetName()),imbinmin,imbinmax);
-               pyAsym5->SetTitle("E_{pair} < 5 GeV");
-               pyAsym5->SetLineColor(4);
-               pyAsym5->Draw();
-               
-               c5b->cd(3) ; 
-               imbinmin = (Int_t) (5-emin)*nebins/emax;
-               imbinmax = (Int_t) (10-emin)*nebins/emax;
-               TH1D *pyAsym510 = fhAsym->ProjectionY(Form("%s_py510",fhAsym->GetName()),imbinmin,imbinmax);
-               pyAsym510->SetTitle("5 < E_{pair} < 10 GeV");
-               pyAsym510->SetLineColor(4);
-               pyAsym510->Draw();
-               
-               c5b->cd(4) ;
-               imbinmin = (Int_t) (10-emin)*nebins/emax;
-               imbinmax = -1;
-               TH1D *pyAsym10 = fhAsym->ProjectionY(Form("%s_py10",fhAsym->GetName()),imbinmin,imbinmax);
-               pyAsym10->SetTitle("E_{pair} > 10 GeV");
-               pyAsym10->SetLineColor(4);
-               pyAsym10->Draw();
-               
-               snprintf(name,buffersize,"QA_%s_Asymmetry.eps",fCalorimeter.Data());
-               c5b->Print(name); printf("Plot: %s\n",name);
-       }
-       
-       
-       if(IsDataMC()){
+    TCanvas  * c5b = new TCanvas(cname, "Asymmetry", 400, 400) ;
+    c5b->Divide(2, 2);
+    
+    c5b->cd(1) ; 
+    fhAsym->SetTitleOffset(1.6,"Y");
+    fhAsym->SetLineColor(4);
+    fhAsym->Draw();
+    
+    c5b->cd(2) ; 
+    imbinmin = 0;
+    imbinmax = (Int_t) (5-emin)*nebins/emax;
+    TH1D *pyAsym5 = fhAsym->ProjectionY(Form("%s_py5",fhAsym->GetName()),imbinmin,imbinmax);
+    pyAsym5->SetTitle("E_{pair} < 5 GeV");
+    pyAsym5->SetLineColor(4);
+    pyAsym5->Draw();
+    
+    c5b->cd(3) ; 
+    imbinmin = (Int_t) (5-emin)*nebins/emax;
+    imbinmax = (Int_t) (10-emin)*nebins/emax;
+    TH1D *pyAsym510 = fhAsym->ProjectionY(Form("%s_py510",fhAsym->GetName()),imbinmin,imbinmax);
+    pyAsym510->SetTitle("5 < E_{pair} < 10 GeV");
+    pyAsym510->SetLineColor(4);
+    pyAsym510->Draw();
+    
+    c5b->cd(4) ;
+    imbinmin = (Int_t) (10-emin)*nebins/emax;
+    imbinmax = -1;
+    TH1D *pyAsym10 = fhAsym->ProjectionY(Form("%s_py10",fhAsym->GetName()),imbinmin,imbinmax);
+    pyAsym10->SetTitle("E_{pair} > 10 GeV");
+    pyAsym10->SetLineColor(4);
+    pyAsym10->Draw();
+    
+    snprintf(name,buffersize,"QA_%s_Asymmetry.eps",fCalorimeter.Data());
+    c5b->Print(name); printf("Plot: %s\n",name);
+  }
+  
+  
+  if(IsDataMC()){
     //Reconstructed vs MC distributions
     //printf("c6\n");
     snprintf(cname,buffersize,"QA_%s_recvsmc",fCalorimeter.Data());
@@ -5180,40 +5214,40 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
   }
   //Track-matching distributions
   
-       snprintf(cname,buffersize,"QA_%s_trkmatch",fCalorimeter.Data());
-       TCanvas *cme = new TCanvas(cname,"Track-matching distributions", 400, 400);
-       cme->Divide(2,2);
+  snprintf(cname,buffersize,"QA_%s_trkmatch",fCalorimeter.Data());
+  TCanvas *cme = new TCanvas(cname,"Track-matching distributions", 400, 400);
+  cme->Divide(2,2);
   
-       TLegend pLegendpE0(0.6,0.55,0.9,0.8);
-       pLegendpE0.SetTextSize(0.04);
-       pLegendpE0.AddEntry(fh1pOverE,"all","L");
-       pLegendpE0.AddEntry(fh1pOverER02,"dR < 0.02","L");              
-       pLegendpE0.SetFillColor(10);
-       pLegendpE0.SetBorderSize(1);
+  TLegend pLegendpE0(0.6,0.55,0.9,0.8);
+  pLegendpE0.SetTextSize(0.04);
+  pLegendpE0.AddEntry(fh1pOverE,"all","L");
+  pLegendpE0.AddEntry(fh1pOverER02,"dR < 0.02","L");           
+  pLegendpE0.SetFillColor(10);
+  pLegendpE0.SetBorderSize(1);
   //pLegendpE0.Draw();
   
-       cme->cd(1);
-       if(fh1pOverE->GetEntries() > 0) gPad->SetLogy();
-       fh1pOverE->SetTitle("Track matches p/E");
-       fh1pOverE->Draw();
-       fh1pOverER02->SetLineColor(4);
-       fh1pOverER02->Draw("same");
-       pLegendpE0.Draw();
-  
-       cme->cd(2);
-       if(fh1dR->GetEntries() > 0) gPad->SetLogy();
-       fh1dR->Draw();
-       
-       cme->cd(3);
-       fh2MatchdEdx->Draw();
-       
-       cme->cd(4);
-       fh2EledEdx->Draw();
-       
-       snprintf(name,buffersize,"QA_%s_TrackMatchingEleDist.eps",fCalorimeter.Data());
-       cme->Print(name); printf("Plot: %s\n",name);       
-       
-       if(IsDataMC()){
+  cme->cd(1);
+  if(fh1pOverE->GetEntries() > 0) gPad->SetLogy();
+  fh1pOverE->SetTitle("Track matches p/E");
+  fh1pOverE->Draw();
+  fh1pOverER02->SetLineColor(4);
+  fh1pOverER02->Draw("same");
+  pLegendpE0.Draw();
+  
+  cme->cd(2);
+  if(fh1dR->GetEntries() > 0) gPad->SetLogy();
+  fh1dR->Draw();
+  
+  cme->cd(3);
+  fh2MatchdEdx->Draw();
+  
+  cme->cd(4);
+  fh2EledEdx->Draw();
+  
+  snprintf(name,buffersize,"QA_%s_TrackMatchingEleDist.eps",fCalorimeter.Data());
+  cme->Print(name); printf("Plot: %s\n",name);       
+  
+  if(IsDataMC()){
     snprintf(cname,buffersize,"QA_%s_trkmatchMCEle",fCalorimeter.Data());
     TCanvas *cmemc = new TCanvas(cname,"Track-matching distributions from MC electrons", 600, 200);
     cmemc->Divide(3,1);
@@ -5329,14 +5363,14 @@ void  AliAnaCalorimeterQA::Terminate(TList* outputList)
     
     snprintf(name,buffersize,"QA_%s_TrackMatchingPOverE.eps",fCalorimeter.Data());
     cmpoe->Print(name); printf("Plot: %s\n",name);                             
-       }
-       
-       char line[buffersize] ; 
-       snprintf(line, buffersize,".!tar -zcf QA_%s_%s.tar.gz *%s*.eps", fCalorimeter.Data(), GetName(),fCalorimeter.Data()) ; 
-       gROOT->ProcessLine(line);
-       snprintf(line, buffersize,".!rm -fR *.eps"); 
-       gROOT->ProcessLine(line);
-       
-       printf("AliAnaCalorimeterQA::Terminate() - !! All the eps files are in QA_%s_%s.tar.gz !!!\n",  fCalorimeter.Data(), GetName());
-       
+  }
+  
+  char line[buffersize] ; 
+  snprintf(line, buffersize,".!tar -zcf QA_%s_%s.tar.gz *%s*.eps", fCalorimeter.Data(), GetName(),fCalorimeter.Data()) ; 
+  gROOT->ProcessLine(line);
+  snprintf(line, buffersize,".!rm -fR *.eps"); 
+  gROOT->ProcessLine(line);
+  
+  printf("AliAnaCalorimeterQA::Terminate() - !! All the eps files are in QA_%s_%s.tar.gz !!!\n",  fCalorimeter.Data(), GetName());
+  
 }