]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONQAChecker.cxx
Make the Scan method public
[u/mrichter/AliRoot.git] / MUON / AliMUONQAChecker.cxx
index 6f90733b7c25b84926c64d8d25016a32fc39970a..8cc7f15a4331eebbfd9c61507b9206eea12f7037 100644 (file)
 ///
 /// Implementation of AliQACheckerBase for MCH and MTR
 ///
-/// For the moment we only implement the checking of raw data QA for the tracker
-/// by looking at the occupancy at the manu level.
-/// We count the number of manus above a given occupancy threshold, and
-/// depending on that number, the resulting QA flag is warning, error or fatal.
-/// (there's no "info" type in this case).
-///
 /// \author Laurent Aphecetche, Subatech
 
-#include "AliLog.h"
-#include "AliMUONVTrackerData.h"
-#include "AliMpManuIterator.h"
-#include "AliQA.h"
-#include <TDirectory.h>
-#include <TH1.h>
+#include "AliMUONRecoParam.h"
+#include "AliMUONTrackerQAChecker.h"
+#include "AliMUONTriggerQAChecker.h"
+#include "AliCodeTimer.h"
+#include "AliMUONQAIndices.h"
 
 /// \cond CLASSIMP
 ClassImp(AliMUONQAChecker)
 /// \endcond
 
+namespace
+{
+  const Int_t TRACKER=0;
+  const Int_t TRIGGER=1;
+}
+
 //__________________________________________________________________
 AliMUONQAChecker::AliMUONQAChecker() : 
-    AliQACheckerBase("MUON","MUON Quality Assurance Data Maker") 
+    AliQACheckerBase("MUON","MUON Quality Assurance Data Maker"),
+fCheckers(new TObjArray)
 {
        /// ctor
+  fCheckers->SetOwner(kTRUE);
+  fCheckers->AddAt(new AliMUONTrackerQAChecker(),TRACKER);
+  fCheckers->AddAt(new AliMUONTriggerQAChecker(),TRIGGER);
 }          
 
 //__________________________________________________________________
 AliMUONQAChecker::~AliMUONQAChecker() 
 {
        /// dtor
-}
-
-//__________________________________________________________________
-AliMUONQAChecker::AliMUONQAChecker(const AliMUONQAChecker& qac) : 
-    AliQACheckerBase(qac.GetName(), qac.GetTitle()) 
-{
-       /// copy ctor 
-}   
-
-//______________________________________________________________________________
-Double_t 
-AliMUONQAChecker::Check(AliQA::ALITASK_t /*index*/)
-{
-  /// Check data
-  
-  AliError(Form("This method is not implemented. Should it be ? fDataSubDir = %p (%s)",
-                fDataSubDir, ( fDataSubDir ? fDataSubDir->GetPath() : "")));
-  return 0.0;
+  delete fCheckers;
 }
 
 //______________________________________________________________________________
-Double_t 
-AliMUONQAChecker::Check(AliQA::ALITASK_t index, TObjArray * list)
+void
+AliMUONQAChecker::Check(Double_t* rv, AliQAv1::ALITASK_t index, 
+                        TObjArray** list, 
+                        const AliDetectorRecoParam * recoParam)
 {
   /// Check objects in list
   
-  if ( index == AliQA::kRAW ) 
-  {
-    return CheckRaws(list);
-  }
-  
-  if ( index == AliQA::kREC)
-  {
-    return CheckRecPoints(list);
-  }
-  
-  if ( index == AliQA::kESD )
-  {
-    return CheckESD(list);
-  }
-  
-  AliWarning(Form("Checker for task %d not implement for the moment",index));
-  return 0.0;
-}
-
-//______________________________________________________________________________
-TH1* 
-AliMUONQAChecker::GetHisto(TObjArray* list, const char* hname) const
-{
-  /// Get a given histo from the list
-  TH1* h = static_cast<TH1*>(list->FindObject(hname));
-  if (!h)
-  {
-    AliError(Form("Did not find expected histo %s",hname));
-  }
-  return h;
-}
-
-//______________________________________________________________________________
-const Double_t 
-AliMUONQAChecker::CheckRecPoints(TObjArray * list)
-{
-  /// Check rec points
-  /// Very binary check for the moment. 
-  
-  TH1* h = GetHisto(list,"hTrackerNumberOfClustersPerDE");
-  
-  if ( !h ) return 0.75; // only a warning if histo not found, in order not to kill anything because QA failed...
-  
-  if ( h->GetMean() == 0.0 ) return MarkHisto(*h,0.0);
-  
-  return 1.0;
-}
-
-//______________________________________________________________________________
-const Double_t 
-AliMUONQAChecker::MarkHisto(TH1& histo, Double_t value) const
-{
-  /// Mark histo as originator of some QA error/warning
-  
-  if ( value != 1.0 )
-  {
-    histo.SetBit(AliQA::GetQABit());
-  }
-  
-  return value;
-}
-
-//______________________________________________________________________________
-const Double_t 
-AliMUONQAChecker::CheckESD(TObjArray * list)
-{
-  /// Check ESD
-  
-  TH1* h = GetHisto(list,"hESDnTracks");
-  
-  if (!h) return 0.75;
-  
-  if ( h->GetMean() == 0.0 ) return MarkHisto(*h,0.0); // no track -> fatal
-  
-  h = GetHisto(list,"hESDMatchTrig");
-  
-  if (!h) return 0.75;
-  
-  if (h->GetMean() == 0.0 ) return MarkHisto(*h,0.25); // no trigger matching -> error
-  
-  return 1.0;
-}
-
-//______________________________________________________________________________
-const Double_t 
-AliMUONQAChecker::CheckRaws(TObjArray * list)
-{
-  /// Check raws
-
-       TIter next(list);
-       TObject* object;
-       AliMUONVTrackerData* data(0x0);
+  AliCodeTimerAuto(AliQAv1::GetTaskName(index),0);
   
-       while ( (object=next()) && !data )
-       {
-               if (object->InheritsFrom("AliMUONVTrackerData"))
-               {
-                       data = static_cast<AliMUONVTrackerData*>(object);
-               }
-       }
+  const AliMUONRecoParam* muonRecoParam = static_cast<const AliMUONRecoParam*>(recoParam);
+  AliMUONVQAChecker::ECheckCode* ecc(0x0);
 
-  if ( !data ) 
+  for ( Int_t i = 0; i < AliRecoParam::kNSpecies; ++i ) 
   {
-    AliError("Did not find TrackerData in the list !");
-    return 0.0;
+    rv[i] = -1.0;
   }
   
-  AliMpManuIterator it;
-  Int_t detElemId;
-  Int_t manuId;
-  Int_t n50(0); // number of manus with occupancy above 0.5
-  Int_t n75(0); // number of manus with occupancy above 0.75
-  Int_t n(0); // number of manus with some occupancy
-  
-  while ( it.Next(detElemId,manuId) )
+  for ( Int_t ic = 0; ic <= fCheckers->GetLast(); ++ic )
   {
-    Float_t occ = data->Manu(detElemId,manuId,2);
-    if (occ > 0 ) ++n;
-    if (occ >= 0.5 ) ++n50;
-    if (occ >= 0.75 ) ++n75;    
-  }
-
-  AliInfo(Form("n %d n50 %d n75 %d",n,n50,n75));
-  
-  if ( n == 0 ) 
-  {
-    AliError("Oups. Got zero occupancy in all manus ?!");
-    return 0.0;
-  }
+    if ( ic != TRACKER && ic != TRIGGER ) continue;
 
-  if ( n75 ) 
-  {
-    AliError(Form("Got %d manus with occupancy above 0.75",n75));
-    return 0.1;
-  }
+    Bool_t trackerRequested(kFALSE);
+    Bool_t triggerRequested(kFALSE);
     
-  if ( n50 ) 
-  {
-    AliWarning(Form("Got %d manus with occupancy above 0.5",n50));
-    return 0.9;
+    for ( Int_t i = 0; i < AliRecoParam::kNSpecies; ++i ) 
+    {
+      // no need to take into account detector that was not requested
+      if ( ic == TRACKER && AliQAv1::GetData(list,AliMUONQAIndices::kTrackerIsThere,AliRecoParam::ConvertIndex(i)) ) trackerRequested=kTRUE;
+      if ( ic == TRIGGER && AliQAv1::GetData(list,AliMUONQAIndices::kTriggerIsThere,AliRecoParam::ConvertIndex(i)) ) triggerRequested=kTRUE;
+    }
+    
+    if ( ic == TRACKER && !trackerRequested ) 
+    {
+      AliInfo("Skipping tracker check as tracker not requested");
+      continue;      
+    }
+    
+    if ( ic == TRIGGER && !triggerRequested ) 
+    {
+      AliInfo("Skipping trigger check as trigger not requested");
+      continue;      
+    }
+    
+    AliMUONVQAChecker* qac = static_cast<AliMUONVQAChecker*>(fCheckers->At(ic));
+    
+    if ( index == AliQAv1::kRAW ) 
+    {    
+      ecc = qac->CheckRaws(list,muonRecoParam);
+    }
+
+    if ( index == AliQAv1::kREC)
+    {
+      ecc = qac->CheckRecPoints(list,muonRecoParam);
+    }
+    
+    if ( index == AliQAv1::kESD )
+    {
+      ecc = qac->CheckESD(list,muonRecoParam);
+    }
+    
+    if ( ecc ) 
+    {
+      for ( Int_t i = 0; i < AliRecoParam::kNSpecies; ++i ) 
+      {
+        // no need to take into account detector that was not requested
+        if ( ic == TRACKER && AliQAv1::GetData(list,AliMUONQAIndices::kTrackerIsThere,AliRecoParam::ConvertIndex(i))==0x0 ) continue;
+        if ( ic == TRIGGER && AliQAv1::GetData(list,AliMUONQAIndices::kTriggerIsThere,AliRecoParam::ConvertIndex(i))==0x0 ) continue;
+                
+        switch ( ecc[i] ) 
+        {
+          case AliMUONVQAChecker::kInfo:
+            rv[i] = 1.0;
+            break;
+          case AliMUONVQAChecker::kWarning:
+            rv[i] = 0.75;
+            break;
+          case AliMUONVQAChecker::kError:
+            rv[i] = 0.25;
+            break;
+          case AliMUONVQAChecker::kFatal:
+            rv[i] = -1.0;
+            break;
+          default:
+            AliError("Invalid ecc value. FIXME !");
+            rv[i] = -1.0;
+            break;
+        }
+      }
+    }
+
+    delete[] ecc;
   }
-
-       return 1.0;
 }
 
 //______________________________________________________________________________
-void 
-AliMUONQAChecker::SetQA(AliQA::ALITASK_t index, const Double_t value) const
+void AliMUONQAChecker::Init(const AliQAv1::DETECTORINDEX_t det) 
 {
-  /// sets the QA according the return value of the Check
-
-  AliQA * qa = AliQA::Instance(index);
-  
-  qa->UnSet(AliQA::kFATAL);
-  qa->UnSet(AliQA::kWARNING);
-  qa->UnSet(AliQA::kERROR);
-  qa->UnSet(AliQA::kINFO);
-  
-  if ( value == 1.0 ) 
-  {
-    qa->Set(AliQA::kINFO);
-  }
-  else if ( value == 0.0 )
-  {
-    qa->Set(AliQA::kFATAL);
-  }
-  else if ( value > 0.5 ) 
-  {
-    qa->Set(AliQA::kWARNING);
-  }
-  else
-  {
-    qa->Set(AliQA::kERROR);
-  }
+  /// intialises QA and QA checker settings
+  AliQAv1::Instance(det) ; 
+  Float_t hiValue[AliQAv1::kNBIT] ; 
+  Float_t lowValue[AliQAv1::kNBIT] ;
+  lowValue[AliQAv1::kINFO]      = 0.999   ; 
+  hiValue[AliQAv1::kINFO]       = 1.0 ; 
+  hiValue[AliQAv1::kWARNING]    = 0.99 ; 
+  lowValue[AliQAv1::kWARNING]   = 0.5 ; 
+  lowValue[AliQAv1::kERROR]     = 0.0   ; 
+  hiValue[AliQAv1::kERROR]      = 0.5 ; 
+  lowValue[AliQAv1::kFATAL]     = -1.0   ; 
+  hiValue[AliQAv1::kFATAL]      = 0.0 ; 
+  SetHiLo(&hiValue[0], &lowValue[0]) ; 
 }