]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ZDC/AliZDCQAChecker.cxx
Prepare for TPC code changes
[u/mrichter/AliRoot.git] / ZDC / AliZDCQAChecker.cxx
index 505b256cad565de9f19dea7d753f378bc8e2297c..71972a17289139cb4c139d216f86fdc0683751f7 100644 (file)
 #include <TH1F.h> 
 #include <TIterator.h> 
 #include <TString.h> 
-
-// --- Standard library ---
+#include <TPaveText.h> 
+#include <TObjArray.h>
+#include <TParameter.h> 
+#include <TList.h>
 
 // --- AliRoot header files ---
 #include "AliLog.h"
+#include "AliCDBManager.h"
+#include "AliCDBEntry.h"
+#include "AliQAThresholds.h"
 #include "AliZDCQAChecker.h"
 
 ClassImp(AliZDCQAChecker)
 
+ //_________________________________________________________________
+AliZDCQAChecker::AliZDCQAChecker() : 
+  AliQACheckerBase("ZDC","ZDC Quality Assurance Data Maker"), 
+  fQAThresholds(NULL),
+  fZDCQAThr_ZNCTDCRefThr(-322.7),
+  fZDCQAThr_ZPCTDCRefThr(-321.4),
+  fZDCQAThr_ZNATDCRefThr(-321.6),
+  fZDCQAThr_ZPATDCRefThr(-321.7),
+  fZDCQAThr_ZEM1TDCRefThr(-316.2),
+  fZDCQAThr_ZEM2TDCRefThr(-315.4)
+{
+   //constructor
+}
+
 //____________________________________________________________________________
 void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArray ** list,
       const AliDetectorRecoParam * /*recoParam*/) 
@@ -39,6 +58,11 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
   Int_t ihitHisto=0, idigHisto=0;
   Int_t irecHisto=0, irawHisto=0, esdInd=0;
 
+  TObjArray messages;
+  messages.SetOwner(kTRUE);
+  
+  GetThresholds();
+
   for(Int_t specie = 0; specie<AliRecoParam::kNSpecies; specie++){
     Int_t count = 0; 
     if(!AliQAv1::Instance(AliQAv1::GetDetIndex(GetName()))->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie))) 
@@ -60,13 +84,14 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
       count = 0; 
       TH1 * hdata;       
       
-      Float_t res=0., percentageDiff=0.20;
+      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){ 
@@ -187,57 +212,82 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
          else if(index == AliQAv1::kRAW) {
            //
             // 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==20) nentries = Int_t (hdata->GetEntries());
+           if(irawHisto==22){ 
+             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==13){
-             if(TMath::Abs(sumADCZNC)>1.e-10){
-               if((TMath::Abs(adcQZNC-adcCZNC)/adcCZNC)<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
-             if(TMath::Abs(sumADCZNA)>1.e-10){
-               if((TMath::Abs(adcQZNA-adcCZNA)/adcCZNA)<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
-             if(TMath::Abs(sumADCZPC)>1.e-10){
-               if((TMath::Abs(adcQZPC-adcCZPC)/adcCZPC)<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
-             if(TMath::Abs(sumADCZPA)>1.e-10){
-               if((TMath::Abs(adcQZPA-adcCZPA)/adcCZPA)<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
+           else if(irawHisto==23){
+             // Reference values must be inserted in the order:
+             // ZNC, ZPC, ZNA, ZPA, ZEM1, ZEM2
+             // 2012 -> Reference values from RUN 177399
+             //Double_t refTDCs[6] = {-322.7,-321.4,-321.6,-321.7,-316.2,-315.4};
+             //  11/2012 -> QA threshold values x TDCs are read from configuration file
+             Double_t refTDCs[6];
+             refTDCs[0] = fZDCQAThr_ZNCTDCRefThr;
+             refTDCs[1] = fZDCQAThr_ZPCTDCRefThr;
+             refTDCs[2] = fZDCQAThr_ZNATDCRefThr;
+             refTDCs[3] = fZDCQAThr_ZPATDCRefThr;
+             refTDCs[4] = fZDCQAThr_ZEM1TDCRefThr;
+             refTDCs[5] = fZDCQAThr_ZEM2TDCRefThr;
+             //
+             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) {
@@ -300,18 +350,18 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
            //
             // 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(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
@@ -362,7 +412,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
     // ====================================================================
     //         Checks for A-A events
     // ====================================================================
-    else if (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kHighMult) {
+    if (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kHighMult) {
       if(list[specie]->GetEntries()==0){  
         AliWarning("\t The list to be checked is empty!");
         return ;
@@ -380,6 +430,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
       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){ 
@@ -539,77 +590,79 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
           else if(index == AliQAv1::kRAW){
            //
             // 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==20) nentries = Int_t (hdata->GetEntries());
+           if(irawHisto==22){ 
+             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(irawHisto==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 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
-             if(TMath::Abs(sumADCZPC)>1.e-10 && TMath::Abs(sumADCZPA)>1.e-10){
-               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(irawHisto==13){
-             if(TMath::Abs(sumADCZNC)>1.e-10){
-               if((TMath::Abs(adcQZNC-adcCZNC)/adcCZNC)<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
-             if(TMath::Abs(sumADCZNA)>1.e-10){
-               if((TMath::Abs(adcQZNA-adcCZNA)/adcCZNA)<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
-             if(TMath::Abs(sumADCZPC)>1.e-10){
-               if((TMath::Abs(adcQZPC-adcCZPC)/adcCZPC)<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
-             if(TMath::Abs(sumADCZPA)>1.e-10){
-               if((TMath::Abs(adcQZPA-adcCZPA)/adcCZPA)<percentageDiff) 
-                 res=1.;
-               else 
-                 res=.5;
-               test[specie] += res;
-               count++;
-             }
+           else if(irawHisto==23){
+             // Reference values from RUN 137161
+             //Double_t refTDCs[6] = {-320.7,-319.0,-318.6,-319.9,-321.3,-320.8};
+             //  11/2012 -> QA threshold values x TDCs are read from configuration file
+             Double_t refTDCs[6];
+             refTDCs[0] = fZDCQAThr_ZNCTDCRefThr;
+             refTDCs[1] = fZDCQAThr_ZPCTDCRefThr;
+             refTDCs[2] = fZDCQAThr_ZNATDCRefThr;
+             refTDCs[3] = fZDCQAThr_ZPATDCRefThr;
+             refTDCs[4] = fZDCQAThr_ZEM1TDCRefThr;
+             refTDCs[5] = fZDCQAThr_ZEM2TDCRefThr;
+             //
+             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);
            }
-           irawHisto++;         
+           irawHisto++;
+           
          }   
           // -------------------------------------------------------------------
           else if(index == AliQAv1::kREC){
@@ -652,7 +705,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
             }
            // --- Check whether (sum PMQi - PMC)/PMC < percentageDiff
            if(irecHisto==11){
-             if(TMath::Abs(meanZNC)>1.e-10){
+             if((TMath::Abs(meanZNC)>1.e-10) && (pmCZNC>1.e-10)){
                if((TMath::Abs(pmQZNC-pmCZNC)/pmCZNC)<percentageDiff) 
                  res=1.;
                else 
@@ -660,7 +713,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
-             if(TMath::Abs(meanZNA)>1.e-10){
+             if((TMath::Abs(meanZNA)>1.e-10) && (pmCZNA>1.e-10)){
                if((TMath::Abs(pmQZNA-pmCZNA)/pmCZNA)<percentageDiff) 
                  res=1.;
                else 
@@ -668,7 +721,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
-             if(TMath::Abs(meanZPC)>1.e-10){
+             if((TMath::Abs(meanZPC)>1.e-10) && (pmCZPC>1.e-10)){
                if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff) 
                  res=1.;
                else 
@@ -676,7 +729,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
-             if(TMath::Abs(meanZPA)>1.e-10){
+             if((TMath::Abs(meanZPA)>1.e-10) && (pmCZPA>1.e-10)){
                if((TMath::Abs(pmQZPA-pmCZPA)/pmCZPA)<percentageDiff) 
                  res=1.;
                else 
@@ -692,18 +745,18 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
            //
             // 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(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 2*|Mean ZNA - Mean ZNC|/(Mean ZNA + Mean ZNC) < percentageDiff
@@ -744,7 +797,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
-             if(TMath::Abs(sumADCZPC)>1.e-10){
+/*           if(TMath::Abs(sumADCZPC)>1.e-10){
                if((TMath::Abs(pmQZPC-pmCZPC)/pmCZPC)<percentageDiff) 
                  res=1.;
                else 
@@ -760,6 +813,7 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
                test[specie] += res;
                count++;
              }
+*/
             }
             esdInd++;
           }  
@@ -774,18 +828,143 @@ void AliZDCQAChecker::Check(Double_t *  test, AliQAv1::ALITASK_t index, TObjArra
     // ====================================================================
     //         Checks for Calibration events
     // ====================================================================
-    else if (AliRecoParam::ConvertIndex(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 (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCosmic) {
-      AliWarning(Form("\n\t No check implemented in ZDC QA for %s task\n",taskName)); 
+      AliWarning(Form("\n\t No check needed in ZDC QA for %s task in COSMIC events\n",taskName)); 
       return ; 
     } // Cosmic
     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);
+  
+  TList* lst = histo.GetListOfFunctions();
+  if(!lst){
+    printf(" No list found\n");
+  } 
+  else {
+     TObject *stats = lst->FindObject("stats");
+     lst->Remove(stats);
+     TObject *obj;
+     while ((obj = lst->First())) {
+       while(lst->Remove(obj)) { }
+       delete obj;
+    }
+    if(stats) lst->Add(stats);
+    lst->Add(text);
+  }   
+}
+
+//______________________________________________________________  
+void AliZDCQAChecker::GetThresholds()
+{
+  //
+  // Init the online thresholds from GRP generated by AMORE
+  //
+  AliCDBManager* man = AliCDBManager::Instance(); 
+  if(!man){     
+     AliWarning("No CDB -> ZDC TDC thresholds not read from OCDB");     
+     return;   
+  }
+  
+  AliCDBEntry* entry = man->Get("GRP/Calib/QAThresholds");
+  if(!entry){     
+     AliWarning("No ZDC TDC thresholds object");
+     return;    
+  }
+  TObjArray* obj = (TObjArray*) entry->GetObject();
+  if(!obj ){
+    AliWarning("No object inside OCDB entry GRP/Calib/QAThresholds");
+    return;    
+  }
+
+  AliQAThresholds* thresholds = (AliQAThresholds*) obj->FindObject("ZDC");  
+  if(!thresholds){ 
+    AliWarning("No object for ZDC thresholds inside OCDB object");
+    return;   
+  }
+  
+  TParameter<double>* myParam0 = (TParameter<double>*) thresholds->GetThreshold(0); 
+  fZDCQAThr_ZNCTDCRefThr = myParam0->GetVal();
+  
+  TParameter<double>* myParam1 = (TParameter<double>*) thresholds->GetThreshold(1); 
+  fZDCQAThr_ZPCTDCRefThr = myParam1->GetVal();
+  
+  TParameter<double>* myParam2 = (TParameter<double>*) thresholds->GetThreshold(2); 
+  fZDCQAThr_ZNATDCRefThr = myParam2->GetVal();
+  
+  TParameter<double>* myParam3 = (TParameter<double>*) thresholds->GetThreshold(3); 
+  fZDCQAThr_ZPATDCRefThr = myParam3->GetVal();
+  
+  TParameter<double>* myParam4 = (TParameter<double>*) thresholds->GetThreshold(4); 
+  fZDCQAThr_ZEM1TDCRefThr = myParam4->GetVal();
+  
+  TParameter<double>* myParam5 = (TParameter<double>*) thresholds->GetThreshold(5); 
+  fZDCQAThr_ZEM2TDCRefThr = myParam5->GetVal();
+  
+  PrintThresholds();
+}
+
+//_______________________________________________________________________________
+void AliZDCQAChecker::PrintThresholds()
+{
+  printf("\n ####    ZDC QA Thresholds  read from configuration file: \n");  
+  printf(" \t fZDCQAThr_ZNCTDCRefThr %f \n",fZDCQAThr_ZNCTDCRefThr);
+  printf(" \t fZDCQAThr_ZPCTDCRefThr %f \n",fZDCQAThr_ZPCTDCRefThr);
+  printf(" \t fZDCQAThr_ZNATDCRefThr %f \n",fZDCQAThr_ZNATDCRefThr);
+  printf(" \t fZDCQAThr_ZPATDCRefThr %f \n",fZDCQAThr_ZPATDCRefThr);
+  printf(" \t fZDCQAThr_ZEM1TDCRefThr %f \n",fZDCQAThr_ZEM1TDCRefThr);
+  printf(" \t fZDCQAThr_ZEM2TDCRefThr %f \n\n",fZDCQAThr_ZEM2TDCRefThr);
+}