First implementation of EMCAL trigger QA from Nicola Arbor
[u/mrichter/AliRoot.git] / ZDC / AliZDCQAChecker.cxx
index 9414fe3..c6a4a9c 100644 (file)
@@ -18,6 +18,9 @@
 #include <TH1F.h> 
 #include <TIterator.h> 
 #include <TString.h> 
+#include <TPaveText.h> 
+#include <TObjArray.h>
+#include "TList.h"
 
 // --- Standard library ---
 
@@ -34,46 +37,57 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
   // Checks the QA histograms on the input list: 
   //
   const char* taskName = AliQAv1::GetAliTaskName(index);
-  printf("\n\tAliZDCQAChecker -> checking QA histos for task %s\n",taskName);
+  //printf("\n\tAliZDCQAChecker -> checking QA histos for task %s\n",taskName);
   //
+  Int_t ihitHisto=0, idigHisto=0;
+  Int_t irecHisto=0, irawHisto=0, esdInd=0;
+
+  TObjArray messages;
+  messages.SetOwner(kTRUE);
+
   for(Int_t specie = 0; specie<AliRecoParam::kNSpecies; specie++){
     Int_t count = 0; 
-    //printf("\tAliZDCQAChecker -> specie %d\n\n",specie);
+    if(!AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie))) 
+      continue ;
+    //printf("\tAliZDCQAChecker -> specie %d, AliRecoParam::ConvertIndex(specie) %d, AliRecoParam::kLowMult %d, IsEventSpecieSet(specie) %d\n",
+    //  specie, AliRecoParam::ConvertIndex(specie) ,AliRecoParam::kLowMult,
+    //  AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie)));
     
-    if(!AliQAv1::Instance()->IsEventSpecieSet(specie))  continue; 
     // ====================================================================
     //         Checks for p-p events
     // ====================================================================
-    if(specie == AliRecoParam::kLowMult){
+    if(AliRecoParam::ConvertIndex(specie) == AliRecoParam::kLowMult){
       if(list[specie]->GetEntries()==0){  
         AliWarning("\t The list to be checked is empty!"); // nothing to check
-        return ;
+        return;
       }
       //AliDebug(AliQAv1::GetQADebugLevel(), Form("\n\tAliZDCQAChecker-> checking QA histograms for task %s\n\n",taskName));
       TIter next(list[specie]); 
       count = 0; 
       TH1 * hdata;       
-      Float_t res=0., percentageDiff=0.15;
+      
+      Float_t res=0., percentageDiff=0.30;
+      Float_t meanZNA=0., meanZNC=0., meanZPA=0., meanZPC=0.;
+      Float_t pmCZNA=0., pmCZNC=0., pmCZPA=0., pmCZPC=0.;
+      Float_t pmQZNA=0., pmQZNC=0., pmQZPA=0., pmQZPC=0.;
+      Float_t sumADCZNA=0., sumADCZNC=0., sumADCZPA=0., sumADCZPC=0.;
+      Float_t adcCZNA=0., adcCZNC=0., adcCZPA=0., adcCZPC=0.;
+      Float_t adcQZNA=0., adcQZNC=0., adcQZPA=0., adcQZPC=0.;
+      Int_t nentries = -99;
+      
       while((hdata = dynamic_cast<TH1 *>(next()))){
         if(hdata){ 
           // -------------------------------------------------------------------
           if(index == AliQAv1::kSIM){
             //AliDebug(AliQAv1::GetQADebugLevel(), Form("\tAliZDCQAChecker-> checking histo %s",hdata->GetName()));
             // Check HITS histos
-            Float_t sumZNA=0., sumZNC=0., sumZPA=0., sumZPC=0.;
-            Float_t pmCZNA=0., pmCZNC=0., pmCZPA=0., pmCZPC=0.;
-            Float_t pmQZNA=0., pmQZNC=0., pmQZPA=0., pmQZPC=0.;
-            Float_t sumADCZNA=0., sumADCZNC=0., sumADCZPA=0., sumADCZPC=0.;
-            Float_t adcCZNA=0., adcCZNC=0., adcCZPA=0., adcCZPC=0.;
-            Float_t adcQZNA=0., adcQZNC=0., adcQZPA=0., adcQZPC=0.;
-           Int_t ihitHisto=0, idigHisto=0;
             //
            if(!(strncmp(hdata->GetName(),"hHits",5))){
               if(hdata->GetEntries()>0){
-               if(ihitHisto==0)      sumZNC = hdata->GetMean();
-               else if(ihitHisto==1) sumZNA = hdata->GetMean();
-               else if(ihitHisto==2) sumZPC = hdata->GetMean();
-               else if(ihitHisto==3) sumZPA = hdata->GetMean();
+               if(ihitHisto==0)      meanZNC = hdata->GetMean();
+               else if(ihitHisto==1) meanZNA = hdata->GetMean();
+               else if(ihitHisto==2) meanZPC = hdata->GetMean();
+               else if(ihitHisto==3) meanZPA = hdata->GetMean();
                else if(ihitHisto==4) pmQZNC = hdata->GetMean();
                else if(ihitHisto==5) pmQZNA = hdata->GetMean();
                else if(ihitHisto==6) pmQZPC = hdata->GetMean();
@@ -86,7 +100,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
              //
              // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
              if(ihitHisto==11){
-               if(sumZNC!=0){
+               if(TMath::Abs(meanZNC)>1.e-10){
                   if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff) 
                     res=1.;
                   else 
@@ -94,7 +108,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                   test[specie] += res;
                   count++;
                }
-               if(sumZNA!=0){
+               if(TMath::Abs(meanZNA)>1.e-10){
                   if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff) 
                     res=1.;
                   else percentageDiff=
@@ -102,7 +116,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                   test[specie] += res;
                   count++;
                }
-               if(sumZPC!=0){
+               if(TMath::Abs(meanZPC)>1.e-10){
                   if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff) 
                     res=1.;
                   else 
@@ -110,7 +124,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                   test[specie] += res;
                   count++;
                }
-               if(sumZPA!=0){
+               if(TMath::Abs(meanZPA)>1.e-10){
                   if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff) 
                     res=1.;
                   else 
@@ -140,7 +154,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
              //
              // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
              if(idigHisto==11){
-               if(sumADCZNC!=0){
+               if(TMath::Abs(sumADCZNC)>1.e-10){
                   if((TMath::Abs(adcQZNC-adcCZNC)/adcCZNC)<percentageDiff) 
                     res=1.;
                   else 
@@ -148,7 +162,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                   test[specie] += res;
                   count++;
                }
-               if(sumADCZNA!=0){
+               if(TMath::Abs(sumADCZNA)>1.e-10){
                   if((TMath::Abs(adcQZNA-adcCZNA)/adcCZNA)<percentageDiff) 
                     res=1.;
                   else 
@@ -156,7 +170,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                   test[specie] += res;
                   count++;
                }
-               if(sumADCZPC!=0){
+               if(TMath::Abs(sumADCZPC)>1.e-10){
                   if((TMath::Abs(adcQZPC-adcCZPC)/adcCZPC)<percentageDiff) 
                     res=1.;
                   else 
@@ -164,7 +178,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                   test[specie] += res;
                   count++;
                }
-               if(sumADCZPA!=0){
+               if(TMath::Abs(sumADCZPA)>1.e-10){
                   if((TMath::Abs(adcQZPA-adcCZPA)/adcCZPA)<percentageDiff) 
                     res=1.;
                   else 
@@ -178,77 +192,83 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
           } 
           // -------------------------------------------------------------------
          else if(index == AliQAv1::kRAW) {
-            Float_t sumADCZNA=0., sumADCZNC=0., sumADCZPA=0., sumADCZPC=0.;
-            Float_t adcCZNA=0., adcCZNC=0., adcCZPA=0., adcCZPC=0.;
-            Float_t adcQZNA=0., adcQZNC=0., adcQZPA=0., adcQZPC=0.;
-           Int_t irawHisto=0;
            //
             // Check RAW HIGH GAIN CHAIN histos
-            if(hdata->GetEntries()>0){
-             if(irawHisto==0)      sumADCZNC = hdata->GetMean();
-             else if(irawHisto==1) sumADCZNA = hdata->GetMean();
-             else if(irawHisto==2) sumADCZPC = hdata->GetMean();
-             else if(irawHisto==3) sumADCZPA = hdata->GetMean();
-             else if(irawHisto==6) adcQZNC = hdata->GetMean();
-             else if(irawHisto==7) adcQZNA = hdata->GetMean();
-             else if(irawHisto==8) adcQZPC = hdata->GetMean();
-             else if(irawHisto==9) adcQZPA = hdata->GetMean();
-             else if(irawHisto==10) adcCZNC = hdata->GetMean();
-             else if(irawHisto==11) adcCZNA = hdata->GetMean();
-             else if(irawHisto==12) adcCZPC = hdata->GetMean();
-             else if(irawHisto==13) adcCZPA = hdata->GetMean();
+            
+           messages.Clear();
+           
+           Bool_t iDetPM = kTRUE;
+           // --- Checks
+           if(irawHisto==16) nentries = Int_t (hdata->GetEntries());
+           if(irawHisto==18){ 
+             Float_t resADC=0.;
+             for(int ibin=1; ibin<=hdata->GetNbinsX(); ibin++){
+                if((hdata->GetBinContent(ibin))>10.){
+                  res=1.;
+                }
+                else if((hdata->GetBinContent(ibin))<10.){
+                  res=0.5;
+                  if(ibin==1 || ibin==6 || ibin==11 || ibin==12 || ibin==13 || ibin==18){
+                    iDetPM = kFALSE;
+                  }
+                }
+                //
+                resADC += res;
+                test[specie] += res;
+                count++;
+             }
+             if(nentries != -99) messages.Add(new TObjString(Form("#entries %d",nentries)));
+             else messages.Add(new TObjString("#entries not known"));
+             //
+             Float_t rv=1.;
+             if(hdata->GetNbinsX() != 0) rv = resADC/hdata->GetNbinsX();
+             if(rv == 1.) messages.Add(new TObjString("ADCs are OK!")); 
+             else if(iDetPM==kFALSE){
+               messages.Add(new TObjString("Problem with some ADC!"));
+                messages.Add(new TObjString("IF THIS IS A PHYSICS RUN"));
+             }
+             else if(iDetPM==kTRUE) messages.Add(new TObjString("Minor problem with ADCs"));
+             SetupHisto(messages, *hdata, rv);
            }
-           //
-           // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
-           if(irawHisto==11){
-             if(sumADCZNC!=0){
-               if((TMath::Abs(adcQZNC-adcCZNC)/adcCZNC)<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
-             if(sumADCZNA!=0){
-               if((TMath::Abs(adcQZNA-adcCZNA)/adcCZNA)<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
-             if(sumADCZPC!=0){
-               if((TMath::Abs(adcQZPC-adcCZPC)/adcCZPC)<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
-             if(sumADCZPA!=0){
-               if((TMath::Abs(adcQZPA-adcCZPA)/adcCZPA)<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
+           else if(irawHisto==19){
+             // Reference values from RUN 145456
+             Double_t refTDCs[6] = {-322.5,-319.1,-320.9,-319.2,-319.7,-319.2};
+             Float_t resTDC=0.;
+             for(int ibin=1; ibin<=hdata->GetNbinsX(); ibin++){
+                if(TMath::Abs((hdata->GetBinContent(ibin))-refTDCs[ibin-1])<3.){
+                  res=1.;
+                }
+                else if(TMath::Abs((hdata->GetBinContent(ibin))-refTDCs[ibin-1])<5.){
+                  res=0.8;
+                }
+                else res=0.5;
+                //
+                resTDC += res;
+                test[specie] += res;
+                count++;
+             }
+             Float_t rv=1.;
+             if(hdata->GetNbinsX() != 0) rv = resTDC/hdata->GetNbinsX();
+             if(rv == 1.) messages.Add(new TObjString("TDCs are OK!")); 
+             else if(rv<1. && rv>0.75) messages.Add(new TObjString("Minor problem with TDCs"));
+             else{
+               messages.Add(new TObjString("Serious problem in ZDC timing"));
+                messages.Add(new TObjString("IF THIS IS A PHYSICS RUN"));
+             }
+             SetupHisto(messages, *hdata, rv);
            }
-           irawHisto++;            
+           irawHisto++;
+           
           } 
           // -------------------------------------------------------------------
          else if(index == AliQAv1::kREC) {
-            Float_t sumZNA=0., sumZNC=0., sumZPA=0., sumZPC=0.;
-            Float_t pmCZNA=0., pmCZNC=0., pmCZPA=0., pmCZPC=0.;
-            Float_t pmQZNA=0., pmQZNC=0., pmQZPA=0., pmQZPC=0.;
-           Int_t irecHisto=0;
            //
             // Check REC HIGH GAIN CHAIN histos
             if(hdata->GetEntries()>0){
-             if(irecHisto==0)       sumZNC = hdata->GetMean();
-             else if(irecHisto==1)  sumZNA = hdata->GetMean();
-             else if(irecHisto==2)  sumZPC = hdata->GetMean();
-             else if(irecHisto==3)  sumZPA = hdata->GetMean();
+             if(irecHisto==0)       meanZNC = hdata->GetMean();
+             else if(irecHisto==1)  meanZNA = hdata->GetMean();
+             else if(irecHisto==2)  meanZPC = hdata->GetMean();
+             else if(irecHisto==3)  meanZPA = hdata->GetMean();
              else if(irecHisto==4)  pmQZNC = hdata->GetMean();
              else if(irecHisto==5)  pmQZNA = hdata->GetMean();
              else if(irecHisto==6)  pmQZPC = hdata->GetMean();
@@ -261,7 +281,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
            //
            // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
            if(irecHisto==11){
-             if(sumZNC!=0){
+             if(TMath::Abs(meanZNC)>1.e-10){
                if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff) 
                  res=1.;
                else 
@@ -269,7 +289,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
-             if(sumZNA!=0){
+             if(TMath::Abs(meanZNA)>1.e-10){
                if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff) 
                  res=1.;
                else 
@@ -277,7 +297,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
-             if(sumZPC!=0){
+             if(TMath::Abs(meanZPC)>1.e-10){
                if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff) 
                  res=1.;
                else 
@@ -285,7 +305,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
-             if(sumZPA!=0){
+             if(TMath::Abs(meanZPA)>1.e-10){
                if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff) 
                  res=1.;
                else 
@@ -298,30 +318,26 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
           } 
           // -------------------------------------------------------------------
          else if(index == AliQAv1::kESD) {
-            Float_t sumADCZNA=0., sumADCZNC=0., sumADCZPA=0., sumADCZPC=0.;
-            Float_t pmCZNA=0., pmCZNC=0., pmCZPA=0., pmCZPC=0.;
-            Float_t pmQZNA=0., pmQZNC=0., pmQZPA=0., pmQZPC=0.;
-            Int_t esdInd=0;
            //
             // Check ESD HIGH GAIN CHAIN histos
-            if(hdata->GetEntries()!=0){
-             if(esdInd==2)      sumADCZNC = hdata->GetMean();
-             else if(esdInd==3) sumADCZNA = hdata->GetMean();
-             else if(esdInd==4) sumADCZPC = hdata->GetMean();
-             else if(esdInd==5) sumADCZPA = hdata->GetMean();
-             else if(esdInd==8) pmQZNC = hdata->GetMean();
-             else if(esdInd==9) pmQZNA = hdata->GetMean();
-             else if(esdInd==10) pmQZPC = hdata->GetMean();
-             else if(esdInd==11) pmQZPA = hdata->GetMean();
-             else if(esdInd==12) pmCZNC = hdata->GetMean();
-             else if(esdInd==13) pmCZNA = hdata->GetMean();
-             else if(esdInd==14) pmCZPC = hdata->GetMean();
-             else if(esdInd==15) pmCZPA = hdata->GetMean();
+            if(hdata->GetEntries()>0){
+             if(esdInd==0)      sumADCZNC = hdata->GetMean();
+             else if(esdInd==1) sumADCZNA = hdata->GetMean();
+             else if(esdInd==2) sumADCZPC = hdata->GetMean();
+             else if(esdInd==3) sumADCZPA = hdata->GetMean();
+             else if(esdInd==6)  pmQZNC = hdata->GetMean();
+             else if(esdInd==7)  pmQZNA = hdata->GetMean();
+             else if(esdInd==8)  pmQZPC = hdata->GetMean();
+             else if(esdInd==9) pmQZPA = hdata->GetMean();
+             else if(esdInd==10) pmCZNC = hdata->GetMean();
+             else if(esdInd==11) pmCZNA = hdata->GetMean();
+             else if(esdInd==12) pmCZPC = hdata->GetMean();
+             else if(esdInd==13) pmCZPA = hdata->GetMean();
            }
            //
            // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
-           if(esdInd==13){
-             if(sumADCZNC!=0){
+           if(esdInd==15){
+             if(TMath::Abs(sumADCZNC)>1.e-10){
                if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff) 
                  res=1.;
                else 
@@ -329,7 +345,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
-             if(sumADCZNA!=0){
+             if(TMath::Abs(sumADCZNA)>1.e-10){
                if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff) 
                  res=1.;
                else 
@@ -337,7 +353,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
-             if(sumADCZPC!=0){
+             if(TMath::Abs(sumADCZPC)>1.e-10){
                if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff) 
                  res=1.;
                else 
@@ -345,7 +361,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
-             if(sumADCZPA!=0){
+             if(TMath::Abs(sumADCZPA)>1.e-10){
                if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff) 
                  res=1.;
                else 
@@ -367,7 +383,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
     // ====================================================================
     //         Checks for A-A events
     // ====================================================================
-    else if (specie == AliRecoParam::kHighMult) {
+    if (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kHighMult) {
       if(list[specie]->GetEntries()==0){  
         AliWarning("\t The list to be checked is empty!");
         return ;
@@ -377,40 +393,42 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
       TIter next(list[specie]); 
       count = 0; 
       TH1 * hdata;       
+      
       Float_t res=0., percentageDiff=0.10;
+      Float_t meanZNA=0., meanZNC=0., meanZPA=0., meanZPC=0.;
+      Float_t pmCZNA=0., pmCZNC=0., pmCZPA=0., pmCZPC=0.;
+      Float_t pmQZNA=0., pmQZNC=0., pmQZPA=0., pmQZPC=0.;
+      Float_t sumADCZNA=0., sumADCZNC=0., sumADCZPA=0., sumADCZPC=0.;
+      Float_t adcCZNA=0., adcCZNC=0., adcCZPA=0., adcCZPC=0.;
+      Float_t adcQZNA=0., adcQZNC=0., adcQZPA=0., adcQZPC=0.;
+      Int_t nentries=-99;
+      
       while((hdata = dynamic_cast<TH1 *>(next()))){
         if(hdata){ 
           //AliDebug(AliQAv1::GetQADebugLevel(), Form("\tAliZDCQAChecker-> checking histo %s",hdata->GetName()));
           // -------------------------------------------------------------------
           if(index == AliQAv1::kSIM){
-            Float_t meanZNA=0., meanZNC=0., meanZPA=0., meanZPC=0.;
-            Float_t pmCZNA=0., pmCZNC=0., pmCZPA=0., pmCZPC=0.;
-            Float_t pmQZNA=0., pmQZNC=0., pmQZPA=0., pmQZPC=0.;
-            Float_t sumADCZNA=0., sumADCZNC=0., sumADCZPA=0., sumADCZPC=0.;
-            Float_t adcCZNA=0., adcCZNC=0., adcCZPA=0., adcCZPC=0.;
-            Float_t adcQZNA=0., adcQZNC=0., adcQZPA=0., adcQZPC=0.;
-            Int_t hitInd=0, digInd=0;
             // Check HITS histos
             if (!(strncmp(hdata->GetName(),"hHits",5))){
               if(hdata->GetEntries()>0){
-               if(hitInd==0)      meanZNC = hdata->GetMean();
-               else if(hitInd==1) meanZNA = hdata->GetMean();
-               else if(hitInd==2) meanZPC = hdata->GetMean();
-               else if(hitInd==3) meanZPA = hdata->GetMean();
-               else if(hitInd==4) pmQZNC = hdata->GetMean();
-               else if(hitInd==5) pmQZNA = hdata->GetMean();
-               else if(hitInd==6) pmQZPC = hdata->GetMean();
-               else if(hitInd==7) pmQZPA = hdata->GetMean();
-               else if(hitInd==8)  pmCZNC = hdata->GetMean();
-               else if(hitInd==9)  pmCZNA = hdata->GetMean();
-               else if(hitInd==10) pmCZPC = hdata->GetMean();
-               else if(hitInd==11) pmCZPA = hdata->GetMean();
+               if(ihitHisto==0)      meanZNC = hdata->GetMean();
+               else if(ihitHisto==1) meanZNA = hdata->GetMean();
+               else if(ihitHisto==2) meanZPC = hdata->GetMean();
+               else if(ihitHisto==3) meanZPA = hdata->GetMean();
+               else if(ihitHisto==4) pmQZNC = hdata->GetMean();
+               else if(ihitHisto==5) pmQZNA = hdata->GetMean();
+               else if(ihitHisto==6) pmQZPC = hdata->GetMean();
+               else if(ihitHisto==7) pmQZPA = hdata->GetMean();
+               else if(ihitHisto==8)  pmCZNC = hdata->GetMean();
+               else if(ihitHisto==9)  pmCZNA = hdata->GetMean();
+               else if(ihitHisto==10) pmCZPC = hdata->GetMean();
+               else if(ihitHisto==11) pmCZPA = hdata->GetMean();
              }
              //
              // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
              // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
-             if(hitInd==3){
-               if(meanZNC!=0 && meanZNA!=0){
+             if(ihitHisto==3){
+               if(TMath::Abs(meanZNC)>1.e-10 && TMath::Abs(meanZNA)>1.e-10){
                   if((2*TMath::Abs(meanZNC-meanZNA)/(meanZNA+meanZNC))<percentageDiff) 
                     res=1.;
                   else 
@@ -418,7 +436,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                   test[specie] += res;
                   count++;
                }
-               if(meanZPC!=0 && meanZPA!=0){
+               if(TMath::Abs(meanZPC)>1.e-10 && TMath::Abs(meanZPA)>1.e-10){
                   if((TMath::Abs(meanZPC-meanZPA)/(meanZPA+meanZPC))<percentageDiff) 
                     res=1.;
                   else 
@@ -428,8 +446,8 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                }
               }
              // --- Check whether (mean PMQi - PMC)/PMC < percentageDiff
-             if(hitInd==11){
-               if(meanZNC!=0){
+             if(ihitHisto==11){
+               if(TMath::Abs(meanZNC)>1.e-10){
                   if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff) 
                     res=1.;
                   else 
@@ -437,7 +455,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                   test[specie] += res;
                   count++;
                }
-               if(meanZNA!=0){
+               if(TMath::Abs(meanZNA)>1.e-10){
                   if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff) 
                     res=1.;
                   else 
@@ -445,7 +463,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                   test[specie] += res;
                   count++;
                }
-               if(meanZPC!=0){
+               if(TMath::Abs(meanZPC)>1.e-10){
                   if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff) 
                     res=1.;
                   else 
@@ -453,7 +471,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                   test[specie] += res;
                   count++;
                }
-               if(meanZPA!=0){
+               if(TMath::Abs(meanZPA)>1.e-10){
                   if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff) 
                     res=1.;
                   else 
@@ -462,29 +480,29 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                   count++;
                }
              }
-             hitInd++;
+             ihitHisto++;
             }
             // Check DIGITS histos
             else if (!(strncmp(hdata->GetName(),"hDig",4))){
               if(hdata->GetEntries()>0){
-               if(digInd==0)      sumADCZNC = hdata->GetMean();
-               else if(digInd==1) sumADCZNA = hdata->GetMean();
-               else if(digInd==2) sumADCZPC = hdata->GetMean();
-               else if(digInd==3) sumADCZPA = hdata->GetMean();
-               else if(digInd==4) adcQZNC = hdata->GetMean();
-               else if(digInd==5) adcQZNA = hdata->GetMean();
-               else if(digInd==6) adcQZPC = hdata->GetMean();
-               else if(digInd==7) adcQZPA = hdata->GetMean();
-               else if(digInd==8)  adcCZNC = hdata->GetMean();
-               else if(digInd==9)  adcCZNA = hdata->GetMean();
-               else if(digInd==10) adcCZPC = hdata->GetMean();
-               else if(digInd==11) adcCZPA = hdata->GetMean();
+               if(idigHisto==0)      sumADCZNC = hdata->GetMean();
+               else if(idigHisto==1) sumADCZNA = hdata->GetMean();
+               else if(idigHisto==2) sumADCZPC = hdata->GetMean();
+               else if(idigHisto==3) sumADCZPA = hdata->GetMean();
+               else if(idigHisto==4) adcQZNC = hdata->GetMean();
+               else if(idigHisto==5) adcQZNA = hdata->GetMean();
+               else if(idigHisto==6) adcQZPC = hdata->GetMean();
+               else if(idigHisto==7) adcQZPA = hdata->GetMean();
+               else if(idigHisto==8)  adcCZNC = hdata->GetMean();
+               else if(idigHisto==9)  adcCZNA = hdata->GetMean();
+               else if(idigHisto==10) adcCZPC = hdata->GetMean();
+               else if(idigHisto==11) adcCZPA = hdata->GetMean();
              }
              //
              // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
              // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
-             if(digInd==3){
-               if(sumADCZNC!=0 && sumADCZNA!=0){
+             if(idigHisto==3){
+               if(TMath::Abs(sumADCZNC)>1.e-10 && TMath::Abs(sumADCZNA)>1.e-10){
                   if((2*TMath::Abs(sumADCZNC-sumADCZNA)/(sumADCZNA+sumADCZNC))<percentageDiff) 
                     res=1.;
                   else 
@@ -492,7 +510,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                   test[specie] += res;
                   count++;
                }
-               if(sumADCZPC!=0 && sumADCZPA!=0){
+               if(TMath::Abs(sumADCZPC)>1.e-10 && TMath::Abs(sumADCZPA)>1.e-10){
                   if((TMath::Abs(sumADCZPC-sumADCZPA)/(sumADCZPA+sumADCZPC))<percentageDiff) 
                     res=1.;
                   else 
@@ -502,8 +520,8 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                }
               }
              // --- Check whether (sumADC PMQi - PMC)/PMC < percentageDiff
-             if(digInd==11){
-               if(sumADCZNC!=0){
+             if(idigHisto==11){
+               if(TMath::Abs(sumADCZNC)>1.e-10){
                   if((TMath::Abs(adcQZNC-adcCZNC)/adcCZNC)<percentageDiff) 
                     res=1.;
                   else 
@@ -511,7 +529,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                   test[specie] += res;
                   count++;
                }
-               if(sumADCZNA!=0){
+               if(TMath::Abs(sumADCZNA)>1.e-10){
                   if((TMath::Abs(adcQZNA-adcCZNA)/adcCZNA)<percentageDiff) 
                     res=1.;
                   else 
@@ -519,7 +537,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                   test[specie] += res;
                   count++;
                }
-               if(sumADCZPC!=0){
+               if(TMath::Abs(sumADCZPC)>1.e-10){
                   if((TMath::Abs(adcQZPC-adcCZPC)/adcCZPC)<percentageDiff) 
                     res=1.;
                   else 
@@ -527,7 +545,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                   test[specie] += res;
                   count++;
                }
-               if(sumADCZPA!=0){
+               if(TMath::Abs(sumADCZPA)>1.e-10){
                   if((TMath::Abs(adcQZPA-adcCZPA)/adcCZPA)<percentageDiff) 
                     res=1.;
                   else 
@@ -536,125 +554,110 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                   count++;
                }
              }
-              digInd++;
+              idigHisto++;
             }
           }
           // -------------------------------------------------------------------
           else if(index == AliQAv1::kRAW){
-            Float_t sumADCZNA=0., sumADCZNC=0., sumADCZPA=0., sumADCZPC=0.;
-            Float_t adcCZNA=0., adcCZNC=0., adcCZPA=0., adcCZPC=0.;
-            Float_t adcQZNA=0., adcQZNC=0., adcQZPA=0., adcQZPC=0.;
-           Int_t rawInd=0;
            //
             // Check RAW HIGH GAIN CHAIN histos
-            if(hdata->GetEntries()>0){
-             if(rawInd==0)      sumADCZNC = hdata->GetMean();
-             else if(rawInd==1) sumADCZNA = hdata->GetMean();
-             else if(rawInd==2) sumADCZPC = hdata->GetMean();
-             else if(rawInd==3) sumADCZPA = hdata->GetMean();
-             else if(rawInd==4) adcQZNC = hdata->GetMean();
-             else if(rawInd==5) adcQZNA = hdata->GetMean();
-             else if(rawInd==6) adcQZPC = hdata->GetMean();
-             else if(rawInd==7) adcQZPA = hdata->GetMean();
-             else if(rawInd==8)  adcCZNC = hdata->GetMean();
-             else if(rawInd==9)  adcCZNA = hdata->GetMean();
-             else if(rawInd==10) adcCZPC = hdata->GetMean();
-             else if(rawInd==11) adcCZPA = hdata->GetMean();
+            
+           messages.Clear();
+           
+           Bool_t iDetPM = kTRUE;
+           // --- Checks
+           if(irawHisto==16) nentries = Int_t (hdata->GetEntries());
+           if(irawHisto==18){ 
+             Float_t resADC=0.;
+             for(int ibin=1; ibin<=hdata->GetNbinsX(); ibin++){
+                if((hdata->GetBinContent(ibin))>10.){
+                  res=1.;
+                }
+                else if((hdata->GetBinContent(ibin))<10. && 
+                  (ibin==1 || ibin==6 || ibin==11 || ibin==12 || ibin==13 || ibin==18)){
+                  res=0.5;
+                  iDetPM = kFALSE;
+                }
+                //
+                resADC += res;
+                test[specie] += res;
+                count++;
+             }
+             if(nentries != -99) messages.Add(new TObjString(Form("#entries %d",nentries)));
+             else messages.Add(new TObjString("#entries not known"));
+             //
+             Float_t rv=1.;
+             if(hdata->GetNbinsX() != 0) rv = resADC/hdata->GetNbinsX();
+             if(rv > 0.98) messages.Add(new TObjString("ADCs are OK!")); 
+             else if(iDetPM==kFALSE){
+               messages.Add(new TObjString("Problem with ADCs!"));
+                messages.Add(new TObjString("IF THIS IS A PHYSICS RUN"));
+             }
+             else if(iDetPM==kTRUE) messages.Add(new TObjString("Minor problem with ADCs"));
+             SetupHisto(messages, *hdata, rv);
            }
-            //
-           // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
-           // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
-           if(rawInd==3){
-             if(sumADCZNC!=0 && sumADCZNA!=0){
-               if((2*TMath::Abs(sumADCZNC-sumADCZNA)/(sumADCZNA+sumADCZNC))<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
-             if(sumADCZPC!=0 && sumADCZPA!=0){
-               if((TMath::Abs(sumADCZPC-sumADCZPA)/(sumADCZPA+sumADCZPC))<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
-            }
-           // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
-           if(rawInd==11){
-             if(sumADCZNC!=0){
-               if((TMath::Abs(adcQZNC-adcCZNC)/adcCZNC)<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
-             if(sumADCZNA!=0){
-               if((TMath::Abs(adcQZNA-adcCZNA)/adcCZNA)<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
-             if(sumADCZPC!=0){
-               if((TMath::Abs(adcQZPC-adcCZPC)/adcCZPC)<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
-             if(sumADCZPA!=0){
-               if((TMath::Abs(adcQZPA-adcCZPA)/adcCZPA)<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
+           else if(irawHisto==19){
+             // Reference values from RUN 137161
+             Double_t refTDCs[6] = {-320.7,-319.0,-318.6,-319.9,-321.3,-320.8};
+             Float_t resTDC=0.;
+             for(int ibin=1; ibin<=hdata->GetNbinsX(); ibin++){
+                if(TMath::Abs((hdata->GetBinContent(ibin))-refTDCs[ibin-1])<3.){
+                  res=1.;
+                }
+                else if(TMath::Abs((hdata->GetBinContent(ibin))-refTDCs[ibin-1])<4.){
+                  res=0.8;
+                }
+                else res=0.5;
+                //
+                resTDC += res;
+                test[specie] += res;
+                count++;
+             }
+             Float_t rv=1.;
+             if(hdata->GetNbinsX() != 0) rv = resTDC/hdata->GetNbinsX();
+             if(rv == 1.) messages.Add(new TObjString("TDCs are OK!")); 
+             else if(rv<1 && rv>0.75) messages.Add(new TObjString("Minor problem with TDCs"));
+             else{
+               messages.Add(new TObjString("Serious problem in ZDC timing"));
+                messages.Add(new TObjString("IF THIS IS A PHYSICS RUN"));
+             }
+             SetupHisto(messages, *hdata, rv);
            }
-           rawInd++;    
+           irawHisto++;
+           
          }   
           // -------------------------------------------------------------------
           else if(index == AliQAv1::kREC){
-            Float_t sumZNA=0., sumZNC=0., sumZPA=0., sumZPC=0.;
-            Float_t pmCZNA=0., pmCZNC=0., pmCZPA=0., pmCZPC=0.;
-            Float_t pmQZNA=0., pmQZNC=0., pmQZPA=0., pmQZPC=0.;
-           Int_t recInd=0;
            //
             // Check RAW HIGH GAIN CHAIN histos
             if(hdata->GetEntries()>0){
-             if(recInd==0)       sumZNC = hdata->GetMean();
-             else if(recInd==1)  sumZNA = hdata->GetMean();
-             else if(recInd==2)  sumZPC = hdata->GetMean();
-             else if(recInd==3)  sumZPA = hdata->GetMean();
-             else if(recInd==4)  pmQZNC = hdata->GetMean();
-             else if(recInd==5)  pmQZNA = hdata->GetMean();
-             else if(recInd==6)  pmQZPC = hdata->GetMean();
-             else if(recInd==7)  pmQZPA = hdata->GetMean();
-             else if(recInd==8)  pmCZNC = hdata->GetMean();
-             else if(recInd==9)  pmCZNA = hdata->GetMean();
-             else if(recInd==10) pmCZPC = hdata->GetMean();
-             else if(recInd==11) pmCZPA = hdata->GetMean();
+             if(irecHisto==0)       meanZNC = hdata->GetMean();
+             else if(irecHisto==1)  meanZNA = hdata->GetMean();
+             else if(irecHisto==2)  meanZPC = hdata->GetMean();
+             else if(irecHisto==3)  meanZPA = hdata->GetMean();
+             else if(irecHisto==4)  pmQZNC = hdata->GetMean();
+             else if(irecHisto==5)  pmQZNA = hdata->GetMean();
+             else if(irecHisto==6)  pmQZPC = hdata->GetMean();
+             else if(irecHisto==7)  pmQZPA = hdata->GetMean();
+             else if(irecHisto==8)  pmCZNC = hdata->GetMean();
+             else if(irecHisto==9)  pmCZNA = hdata->GetMean();
+             else if(irecHisto==10) pmCZPC = hdata->GetMean();
+             else if(irecHisto==11) pmCZPA = hdata->GetMean();
            }
             //
            // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
            // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
-           if(recInd==3){
-             if(sumZNC!=0 && sumZNA!=0){
-               if((2*TMath::Abs(sumZNC-sumZNA)/(sumZNA+sumZNC))<percentageDiff) 
+           if(irecHisto==3){
+             if(TMath::Abs(meanZNC)>1.e-10 && TMath::Abs(meanZNA)>1.e-10){
+               if((2*TMath::Abs(meanZNC-meanZNA)/(meanZNA+meanZNC))<percentageDiff) 
                  res=1.;
                else 
                  res=.5;
                test[specie] += res;
                count++;
              }
-             if(sumZPC!=0 && sumZPA!=0){
-               if((TMath::Abs(sumZPC-sumZPA)/(sumZPA+sumZPC))<percentageDiff) 
+             if(TMath::Abs(meanZPC)>1.e-10 && TMath::Abs(meanZPA)>1.e-10){
+               if((TMath::Abs(meanZPC-meanZPA)/(meanZPA+meanZPC))<percentageDiff) 
                  res=1.;
                else 
                  res=.5;
@@ -663,8 +666,8 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
              }
             }
            // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
-           if(recInd==11){
-             if(sumZNC!=0){
+           if(irecHisto==11){
+             if((TMath::Abs(meanZNC)>1.e-10) && (pmCZNC>1.e-10)){
                if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff) 
                  res=1.;
                else 
@@ -672,7 +675,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
-             if(sumZNA!=0){
+             if((TMath::Abs(meanZNA)>1.e-10) && (pmCZNA>1.e-10)){
                if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff) 
                  res=1.;
                else 
@@ -680,7 +683,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
-             if(sumZPC!=0){
+             if((TMath::Abs(meanZPC)>1.e-10) && (pmCZPC>1.e-10)){
                if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff) 
                  res=1.;
                else 
@@ -688,7 +691,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
-             if(sumZPA!=0){
+             if((TMath::Abs(meanZPA)>1.e-10) && (pmCZPA>1.e-10)){
                if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff) 
                  res=1.;
                else 
@@ -697,23 +700,19 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                count++;
              }
            }
-           recInd++;    
+           irecHisto++;         
          }   
           // -------------------------------------------------------------------
           else if(index == AliQAv1::kESD){
-            Float_t sumADCZNA=0., sumADCZNC=0., sumADCZPA=0., sumADCZPC=0.;
-            Float_t pmCZNA=0., pmCZNC=0., pmCZPA=0., pmCZPC=0.;
-            Float_t pmQZNA=0., pmQZNC=0., pmQZPA=0., pmQZPC=0.;
-            Int_t esdInd=0;
            //
             // Check ESD HIGH GAIN CHAIN histos
-            if(hdata->GetEntries()!=0){
-             if(esdInd==2)      sumADCZNC = hdata->GetMean();
-             else if(esdInd==3) sumADCZNA = hdata->GetMean();
-             else if(esdInd==4) sumADCZPC = hdata->GetMean();
-             else if(esdInd==5) sumADCZPA = hdata->GetMean();
-             else if(esdInd==6) pmQZNC = hdata->GetMean();
-             else if(esdInd==7) pmQZNA = hdata->GetMean();
+            if(hdata->GetEntries()>0){
+             if(esdInd==0)      sumADCZNC = hdata->GetMean();
+             else if(esdInd==1) sumADCZNA = hdata->GetMean();
+             else if(esdInd==2) sumADCZPC = hdata->GetMean();
+             else if(esdInd==3) sumADCZPA = hdata->GetMean();
+             else if(esdInd==6)  pmQZNC = hdata->GetMean();
+             else if(esdInd==7)  pmQZNA = hdata->GetMean();
              else if(esdInd==8) pmQZPC = hdata->GetMean();
              else if(esdInd==9) pmQZPA = hdata->GetMean();
              else if(esdInd==10) pmCZNC = hdata->GetMean();
@@ -725,7 +724,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
            // --- Check whether 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
            // --- and 2*|Mean ZPA - Mean ZPC|/(Mean ZPA + Mean ZPC) < 2*percentageDiff
            if(esdInd==5){
-             if(sumADCZNC!=0 && sumADCZNA!=0){
+             if(TMath::Abs(sumADCZNC)>1.e-10 && TMath::Abs(sumADCZNA)>1.e-10){
                if((2*TMath::Abs(sumADCZNC-sumADCZNA)/(sumADCZNA+sumADCZNC))<percentageDiff) 
                  res=1.;
                else 
@@ -733,7 +732,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
-             if(sumADCZPC!=0 && sumADCZPA!=0){
+             if(TMath::Abs(sumADCZPC)>1.e-10 && TMath::Abs(sumADCZPA)>1.e-10){
                if((TMath::Abs(sumADCZPC-sumADCZPA)/(sumADCZPA+sumADCZPC))<percentageDiff) 
                  res=1.;
                else 
@@ -743,8 +742,8 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
              }
             }
            // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
-           if(esdInd==13){
-             if(sumADCZNC!=0){
+           if(esdInd==15){
+             if(TMath::Abs(sumADCZNC)>1.e-10){
                if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff) 
                  res=1.;
                else 
@@ -752,7 +751,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
-             if(sumADCZNA!=0){
+             if(TMath::Abs(sumADCZNA)>1.e-10){
                if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff) 
                  res=1.;
                else 
@@ -760,7 +759,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
-             if(sumADCZPC!=0){
+/*           if(TMath::Abs(sumADCZPC)>1.e-10){
                if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff) 
                  res=1.;
                else 
@@ -768,7 +767,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
-             if(sumADCZPA!=0){
+             if(TMath::Abs(sumADCZPA)>1.e-10){
                if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff) 
                  res=1.;
                else 
@@ -776,6 +775,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
+*/
             }
             esdInd++;
           }  
@@ -790,18 +790,66 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
     // ====================================================================
     //         Checks for Calibration events
     // ====================================================================
-    else if (specie == AliRecoParam::kCalib) {
-      AliWarning(Form("\n\t No check implemented in ZDC QA for %s task\n",taskName)); 
+    if (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCalib) {
+      AliWarning(Form("\n\t No check implemented in ZDC QA for %s task in CALIBRATION events\n",taskName)); 
       return ;
     } // Calibration
     // ====================================================================
     //         Checks for cosmic events
     // ====================================================================
-    else if (specie == AliRecoParam::kCosmic) {
-      AliWarning(Form("\n\t No check implemented in ZDC QA for %s task\n",taskName)); 
+    else if (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCosmic) {
+      AliWarning(Form("\n\t No check needed in ZDC QA for %s task in COSMIC events\n",taskName)); 
       return ; 
     } // Cosmic
-    if(count!=0) test[specie] = test[specie]/count;
+    if(TMath::Abs(count)>1.e-10) test[specie] = test[specie]/count;
     AliDebug(AliQAv1::GetQADebugLevel(), Form("\n\t ZDC QA check result = %1.2f\n",test[specie]));
   } // Loop on species
 }  
+
+//___________________________________________________________________ 
+void AliZDCQAChecker::SetupHisto(const TObjArray& messages, TH1& histo, Float_t& code)
+{
+  //
+  /// Add text to histos
+  //
+
+  TPaveText* text = new TPaveText(0.70,0.70,0.99,0.99,"NDC");
+    
+  TIter next(&messages);
+  TObjString* str;
+    
+  while ( ( str = static_cast<TObjString*>(next()) ) ){
+    text->AddText(str->String());
+  }
+
+  TString defaultText = "";
+
+  Int_t color = 0;
+  if(code==1.){
+    color = kGreen;
+    defaultText = "Everything is fine!";
+  }  
+  else if(code<1. && code>=0.85){  
+    color = kYellow;
+    defaultText = "To be monitored in next runs";
+  }
+  else if(code<0.85 && code>=0.6){
+    color = kOrange;
+    defaultText = "notify the expert DURING THE DAY!";
+  }
+  else if(code<0.6){
+    color = kRed;
+    defaultText = "PLEASE CALL THE EXPERT!!!!";
+  }
+
+
+  text->AddText(defaultText.Data());
+  text->SetFillColor(color);
+                      
+  //histo.SetFillStyle(1001);
+  //histo.SetFillColor(color);
+
+  histo.SetStats(kFALSE);
+    
+  histo.GetListOfFunctions()->Add(text);
+}