]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - VZERO/AliVZEROQAChecker.cxx
default name for AliStackPartonInfo
[u/mrichter/AliRoot.git] / VZERO / AliVZEROQAChecker.cxx
index dfd897aacb3bc76d527b8fba0f64fe73db0ac476..1ea5877fdcea6e512651859c6faa17f0d83795f2 100644 (file)
@@ -15,7 +15,7 @@
 
 
 /*
-  Checks the quality assurance. 
+  Checks the quality assurance. Under construction. 
   By comparing with reference data
 
 */
 
 // --- AliRoot header files ---
 #include "AliLog.h"
-#include "AliQA.h"
+#include "AliQAv1.h"
 #include "AliQAChecker.h"
 #include "AliVZEROQAChecker.h"
-//#include "AliCDBEntry.h"
-//#include "AliCDBManager.h"
+#include "AliVZEROQADataMakerRec.h"
 
 ClassImp(AliVZEROQAChecker)
 
 //__________________________________________________________________
-const Double_t AliVZEROQAChecker::Check(AliQA::ALITASK_t index, TObjArray * list) 
+AliVZEROQAChecker::AliVZEROQAChecker() : AliQACheckerBase("VZERO","VZERO Quality Assurance Data Checker"),
+  fLowEventCut(1000),
+  fORvsANDCut(0.2),
+  fBGvsBBCut(0.2)
 {
+  // Default constructor
+  // Nothing else here
+}
 
-// Main check function: Depending on the TASK, different checks will be applied
-// Check for empty histograms 
-
-//   AliDebug(1,Form("AliVZEROChecker"));
-//   AliCDBEntry *QARefRec = AliCDBManager::Instance()->Get("VZERO/QARef/RAW");
-//   if( !QARefRec){
-//     AliInfo("QA reference data NOT retrieved for QA check...");
-//     return 1.;
-//   }
-
-// checking for empty histograms
-
-//   Double_t check = 0.0;
-//   if(CheckEntries(list) == 0)  {
-//      AliWarning(Form("Histograms are empty !"));
-//      check = 0.4;          
-//      return check;
-     
-  if ( index == AliQA::kRAW ) 
-  {
-       printf(" index = %d, Check = %f\n\n", index,CheckEntries(list));
-       return CheckEntries(list);
+//__________________________________________________________________
+void AliVZEROQAChecker::Check(Double_t * check, AliQAv1::ALITASK_t index, TObjArray ** list, const AliDetectorRecoParam * /*recoParam*/) 
+{
+  // Main check function: Depending on the TASK, different checks will be applied
+  // Check for missing channels and check on the trigger type for raw data
+  // Check for missing disk or rings for esd (to be redone)
+
+  for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+    check[specie] = 1.0;
+    // no check on cosmic or calibration events
+    if (AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCosmic || AliRecoParam::ConvertIndex(specie) == AliRecoParam::kCalib)
+      continue;
+    if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) 
+      continue;
+    if (index == AliQAv1::kRAW) {
+      check[specie] =  CheckRaws(list[specie]);
+    } else if (index == AliQAv1::kESD) {
+      // Check for one disk missing (FATAL) or one ring missing (ERROR) in ESDs (to be redone)
+      check[specie] =  CheckEsds(list[specie]);
+    } 
   }
-  
-  AliWarning(Form("Checker for task %d not implemented for the moment",index));
-  return 0.0;    
-
 }
+
 //_________________________________________________________________
-Double_t AliVZEROQAChecker::CheckEntries(TObjArray * list) const
+Double_t AliVZEROQAChecker::CheckRaws(TObjArray * list) const
 {
-  
-  //  check on the QA histograms on the input list: 
-   
-
-  Double_t test = 0.0  ;
-  Int_t   count = 0 ; 
-  printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"); 
-  printf(" Number of entries = %d \n", list->GetEntries() );
-   
+
+  //  Check on the QA histograms on the raw-data input list:
+  //  Two things are checked: the presence of data in all channels and
+  //  the ratio between different trigger types
+
+  Double_t test = 1.0;
   if (list->GetEntries() == 0){  
-      test = 1.0; 
-      AliInfo(Form("There are no entries to be checked..."));
-  }
-  else {
-      TIter next(list) ; 
-      TH1 * hdata ;
-      count = 0 ; 
-      while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
-        if (hdata) { 
-         Double_t rv = 0.0;
-          Printf("Histogram %s     has entries: %f ",hdata->GetName(),hdata->GetEntries());
-         if(hdata->GetEntries()>0)rv=1.0; 
-         count++ ; 
-         test += rv ; 
-         printf(" count = %d, rv = %f \n", count,rv);
-        }
-        else{
-         AliError(Form("Data type cannot be processed"));
-        }      
-      }
-      if (count != 0) { 
-        if (test==0.0) {
-           AliInfo(Form("Histograms are booked for THIS specific Task, but they are all empty: setting flag to kWARNING"));
-//         test = 0.0;  //upper limit value to set kWARNING flag for a task
-        }
-        else test = 1.0;
+    AliWarning("There are no histograms to be checked");
+  } else {
+    TH1F *hTriggers  = (TH1F*)list->At(AliVZEROQADataMakerRec::kTriggers);
+    if (!hTriggers) {
+      AliWarning("Trigger type histogram is not found");
+    }
+    else if (hTriggers->GetEntries() < fLowEventCut) {
+      AliInfo("Not enough events to perform QA checks");
+    }
+    else {
+      Double_t nANDs = hTriggers->GetBinContent(hTriggers->FindBin(0));
+      Double_t nORs = hTriggers->GetBinContent(hTriggers->FindBin(1));
+      Double_t nBGAs = hTriggers->GetBinContent(hTriggers->FindBin(2));
+      Double_t nBGCs = hTriggers->GetBinContent(hTriggers->FindBin(3));
+      if ((nORs - nANDs) > fORvsANDCut*nANDs) test = 0.001;
+      if ((nBGAs + nBGCs) > fBGvsBBCut*nANDs) test = 0.002;
+    }
+    TH1F *hBBflags = (TH1F*)list->At(AliVZEROQADataMakerRec::kBBFlagsPerChannel);
+    if (!hBBflags) {
+      AliWarning("BB-flags per channel histogram is not found");
+    }
+    else if (hBBflags->GetEntries() < fLowEventCut) {
+      AliInfo("Not enough events to perform QA checks");
+    }
+    else {
+      for(Int_t iBin = 1; iBin <= 64; ++iBin) {
+       if (hBBflags->GetBinContent(iBin) < 1.0) test = -1.0;
       }
+    }
   }
-
   return test ; 
 }  
-//______________________________________________________________________________
-void AliVZEROQAChecker::SetQA(AliQA::ALITASK_t index, const Double_t value) const
-{
-// sets the QA word according the return value of the Check
 
-  AliQA * qa = AliQA::Instance(index);
+//_________________________________________________________________
+Double_t AliVZEROQAChecker::CheckEsds(TObjArray * list) const
+{
   
-  qa->UnSet(AliQA::kFATAL);
-  qa->UnSet(AliQA::kWARNING);
-  qa->UnSet(AliQA::kERROR);
-  qa->UnSet(AliQA::kINFO);
+//  check the ESDs for missing disk or ring
+//  printf(" Number of entries in ESD list = %d\n", list->GetEntries()); 
+//  list->Print();
+
+  Double_t test     = 1.0;     // initialisation to OK
+  Int_t    histonb =   0; 
+  Double_t multV0A = 0.0;
+  Double_t multV0C = 0.0;
+  Double_t v0ABBRing[4], v0CBBRing[4];
+  Double_t v0ABGRing[4], v0CBGRing[4];
+  for (Int_t i=0; i<4; i++) { 
+       v0ABBRing[i]= v0CBBRing[i]= 0.0;
+       v0ABGRing[i]= v0CBGRing[i]= 0.0;
+  }  
+  TIter next(list) ; 
+  TH1 * hdata ;
   
-  if ( value == 1.0 ) 
-  {
-    qa->Set(AliQA::kINFO);
+  while ( (hdata = dynamic_cast<TH1 *>(next())) ) {
+         if (hdata) {
+                 switch (histonb) {
+                 case AliVZEROQADataMakerRec::kCellMultiV0A:
+                         multV0A  = hdata->GetMean();
+                         break;
+                 case AliVZEROQADataMakerRec::kCellMultiV0C:
+                         multV0C  = hdata->GetMean();
+                         break;
+                 case AliVZEROQADataMakerRec::kBBFlag:
+                 for (Int_t i=0; i<8; i++) {         
+                                 if(i<4) v0CBBRing[i]  = hdata->Integral((i*8)+1, (i*8) +8);
+                                 else v0ABBRing[i-4]  = hdata->Integral((i*8)+1, (i*8) +8);
+                         }           
+                         break;
+                 case AliVZEROQADataMakerRec::kBGFlag:
+                 for (Int_t i=0; i<8; i++) {         
+                                 if(i<4) v0CBGRing[i]  = hdata->Integral((i*8)+1, (i*8) +8);
+                                 else v0ABGRing[i-4]  = hdata->Integral((i*8)+1, (i*8) +8);
+                         }           
+                         break;
+                 }
+         }
+         histonb++;
   }
-  else if ( value == 0.0 )
-  {
-    qa->Set(AliQA::kFATAL);
+  
+  if(multV0A == 0.0 || multV0C == 0.0) {
+     AliWarning(Form("One of the two disks is missing !") );
+     test = 0.0; // bit FATAL set
   }
-  else if ( value > 0.5 ) 
-  {
-    qa->Set(AliQA::kWARNING);
+  if( v0ABBRing[0]+v0ABGRing[0] == 0.0 || 
+      v0ABBRing[1]+v0ABGRing[1] == 0.0 || 
+      v0ABBRing[2]+v0ABGRing[2] == 0.0 || 
+      v0ABBRing[3]+v0ABGRing[3] == 0.0 || 
+      v0CBBRing[0]+v0CBGRing[0] == 0.0 || 
+      v0CBBRing[1]+v0CBGRing[1] == 0.0 || 
+      v0CBBRing[2]+v0CBGRing[2] == 0.0 || 
+      v0CBBRing[3]+v0CBGRing[3] == 0.0  ){    
+      AliWarning(Form("One ring is missing !") );
+      test = 0.1;   // bit ERROR set
   }
-  else
-  {
-    qa->Set(AliQA::kERROR);
+
+  return test ; 
+} 
+
+//______________________________________________________________________________
+void AliVZEROQAChecker::Init(const AliQAv1::DETECTORINDEX_t det) 
+{
+  // intialises QA and QA checker settings
+  AliQAv1::Instance(det) ; 
+  Float_t * hiValue = new Float_t[AliQAv1::kNBIT] ; 
+  Float_t * lowValue = new Float_t[AliQAv1::kNBIT] ;
+  lowValue[AliQAv1::kINFO]      = 0.5   ; 
+  hiValue[AliQAv1::kINFO]       = 1.0 ; 
+  lowValue[AliQAv1::kWARNING]   = 0.2 ; 
+  hiValue[AliQAv1::kWARNING]    = 0.5 ; 
+  lowValue[AliQAv1::kERROR]     = 0.0   ; 
+  hiValue[AliQAv1::kERROR]      = 0.2 ; 
+  lowValue[AliQAv1::kFATAL]     = -1.0   ; 
+  hiValue[AliQAv1::kFATAL]      = 0.0 ; 
+  SetHiLo(hiValue, lowValue) ; 
+  delete [] hiValue;
+  delete [] lowValue;
+}
+
+//______________________________________________________________________________
+void AliVZEROQAChecker::SetQA(AliQAv1::ALITASK_t index, Double_t * value) const
+{
+// sets the QA word according to return value of the Check
+  AliQAv1 * qa = AliQAv1::Instance(index);
+  for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+    qa->UnSet(AliQAv1::kFATAL, specie);
+    qa->UnSet(AliQAv1::kWARNING, specie);
+    qa->UnSet(AliQAv1::kERROR, specie);
+    qa->UnSet(AliQAv1::kINFO, specie);
+    if ( ! value ) { // No checker is implemented, set all QA to Fatal
+      qa->Set(AliQAv1::kFATAL, specie) ; 
+    } else {
+      if ( value[specie] >= fLowTestValue[AliQAv1::kFATAL] && value[specie] < fUpTestValue[AliQAv1::kFATAL] ) 
+        qa->Set(AliQAv1::kFATAL, specie) ; 
+      else if ( value[specie] > fLowTestValue[AliQAv1::kERROR] && value[specie] <= fUpTestValue[AliQAv1::kERROR]  )
+        qa->Set(AliQAv1::kERROR, specie) ; 
+      else if ( value[specie] > fLowTestValue[AliQAv1::kWARNING] && value[specie] <= fUpTestValue[AliQAv1::kWARNING]  )
+        qa->Set(AliQAv1::kWARNING, specie) ;
+      else if ( value[specie] > fLowTestValue[AliQAv1::kINFO] && value[specie] <= fUpTestValue[AliQAv1::kINFO] ) 
+        qa->Set(AliQAv1::kINFO, specie) ;      
+    }
   }
 }
+