]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliQACheckerBase.cxx
Increasing the class version number.
[u/mrichter/AliRoot.git] / STEER / AliQACheckerBase.cxx
index e5301312f339d489146a9ba0eabdfae9f0b7f4b7..043653d871109f48f1ec45d27969b5e042fdab37 100644 (file)
 #include <TFile.h> 
 #include <TList.h>
 #include <TNtupleD.h>
+#include <TParameter.h>
 #include <TPaveText.h>
 
 // --- Standard library ---
 
 // --- AliRoot header files ---
+#include "AliCDBEntry.h"
 #include "AliLog.h"
 #include "AliQAv1.h"
 #include "AliQAChecker.h"
 #include "AliQACheckerBase.h"
 #include "AliQADataMaker.h"
+#include "AliQAManager.h"
 #include "AliDetectorRecoParam.h"
 
 ClassImp(AliQACheckerBase)
@@ -53,14 +56,13 @@ AliQACheckerBase::AliQACheckerBase(const char * name, const char * title) :
   fDataSubDir(0x0),
   fRefSubDir(0x0), 
   fRefOCDBSubDir(new TObjArray*[AliRecoParam::kNSpecies]), 
-  fLowTestValue(0x0),
-  fUpTestValue(0x0),
+  fLowTestValue(new Float_t[AliQAv1::kNBIT]),
+  fUpTestValue(new Float_t[AliQAv1::kNBIT]),
   fImage(new TCanvas*[AliRecoParam::kNSpecies]), 
-  fPrintImage(kTRUE)
+  fPrintImage(kTRUE), 
+  fExternParamList(new TList())
 {
   // ctor
-  fLowTestValue = new Float_t[AliQAv1::kNBIT] ; 
-  fUpTestValue  = new Float_t[AliQAv1::kNBIT] ; 
   fLowTestValue[AliQAv1::kINFO]    =  0.5   ; 
   fUpTestValue[AliQAv1::kINFO]     = 1.0 ; 
   fLowTestValue[AliQAv1::kWARNING] =  0.002 ; 
@@ -92,10 +94,11 @@ AliQACheckerBase::AliQACheckerBase(const AliQACheckerBase& qac) :
   fDataSubDir(qac.fDataSubDir), 
   fRefSubDir(qac.fRefSubDir), 
   fRefOCDBSubDir(qac.fRefOCDBSubDir), 
-  fLowTestValue(qac.fLowTestValue),
-  fUpTestValue(qac.fLowTestValue), 
-  fImage(NULL),  
-  fPrintImage(kTRUE)
+  fLowTestValue(new Float_t[AliQAv1::kNBIT]),
+  fUpTestValue(new Float_t[AliQAv1::kNBIT]), 
+  fImage(new TCanvas*[AliRecoParam::kNSpecies]),  
+  fPrintImage(kTRUE), 
+  fExternParamList(new TList())  
 {
   //copy ctor
   for (Int_t index = 0 ; index < AliQAv1::kNBIT ; index++) {
@@ -106,6 +109,12 @@ AliQACheckerBase::AliQACheckerBase(const AliQACheckerBase& qac) :
       fImage[specie] = qac.fImage[specie] ; 
       fRefOCDBSubDir[specie] = qac.fRefOCDBSubDir[specie] ; 
     }
+  if (qac.fExternParamList) {
+    TIter next(qac.fExternParamList) ; 
+    TParameter<double> * p ; 
+    while ( (p = (TParameter<double>*)next()) )
+      fExternParamList->Add(p) ;
+  }
 }
 
 //____________________________________________________________________________
@@ -131,10 +140,14 @@ AliQACheckerBase::~AliQACheckerBase()
   delete[] fImage ; 
   delete[] fRefOCDBSubDir ; 
   AliQAv1::GetQAResultFile()->Close() ; 
+  if (fExternParamList) {
+    fExternParamList->Clear() ; 
+    delete fExternParamList ; 
+  }
 }
 
 //____________________________________________________________________________
-Double_t * AliQACheckerBase::Check(AliQAv1::ALITASK_t index, AliDetectorRecoParam * recoParam) 
+void AliQACheckerBase::Check(Double_t * test, AliQAv1::ALITASK_t index, const AliDetectorRecoParam * recoParam) 
 {
   // Performs a basic checking
   // Compares all the histograms stored in the directory
@@ -167,22 +180,23 @@ Double_t * AliQACheckerBase::Check(AliQAv1::ALITASK_t index, AliDetectorRecoPara
     }
   }
  
-  Double_t * test = Check(index, list, recoParam) ;
+  Check(test, index, list, recoParam) ;
   
   delete[] list ; 
     
-  return test ;
 }  
 
 //____________________________________________________________________________
-Double_t * AliQACheckerBase::Check(AliQAv1::ALITASK_t /*index*/, TObjArray ** list, AliDetectorRecoParam * /*recoParam*/) 
+void AliQACheckerBase::Check(Double_t * test, AliQAv1::ALITASK_t task, TObjArray ** list, const AliDetectorRecoParam * /*recoParam*/) 
 {
   // Performs a basic checking
   // Compares all the histograms in the list
 
-       Double_t * test = new Double_t[AliRecoParam::kNSpecies] ;
        Int_t count[AliRecoParam::kNSpecies]   = { 0 }; 
 
+  GetRefSubDir(GetName(), AliQAv1::GetTaskName(task), fRefSubDir, fRefOCDBSubDir) ;
+ // SetRefandData(refDir, refOCDBDir) ; 
+  
   for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
     test[specie] = 1.0 ; 
     if ( !AliQAv1::Instance()->IsEventSpecieSet(specie)) 
@@ -221,7 +235,6 @@ Double_t * AliQACheckerBase::Check(AliQAv1::ALITASK_t /*index*/, TObjArray ** li
       }
     }
   }
-  return test ;
 }  
 
 
@@ -249,13 +262,68 @@ Double_t AliQACheckerBase::DiffK(const TH1 * href, const TH1 * hin) const
   return hin->KolmogorovTest(href) ;  
 }
 
+  //_____________________________________________________________________________
+void AliQACheckerBase::GetRefSubDir(const char * det, const char * task, TDirectory *& dirFile, TObjArray **& dirOCDB)     
+{ 
+    // Opens and returns the file with the reference data 
+  dirFile = NULL ; 
+  TString refStorage(AliQAv1::GetQARefStorage()) ;
+  if (!refStorage.Contains(AliQAv1::GetLabLocalOCDB()) && !refStorage.Contains(AliQAv1::GetLabAliEnOCDB())) {
+    AliError(Form("%s is not a valid location for reference data", refStorage.Data())) ; 
+    return ; 
+  } else {
+    AliQAManager* manQA = AliQAManager::QAManager(AliQAv1::GetTaskIndex(task)) ;
+      //    dirOCDB = new TObjArray*[AliRecoParam::kNSpecies] ;        
+    for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) {
+      dirOCDB[specie] = NULL ; 
+      if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) 
+        continue ; 
+      AliQAv1::SetQARefDataDirName(specie) ;
+      if ( ! manQA->GetLock() ) { 
+        manQA->SetDefaultStorage(AliQAv1::GetQARefStorage()) ; 
+        manQA->SetSpecificStorage("*", AliQAv1::GetQARefStorage()) ;
+        manQA->SetRun(AliCDBManager::Instance()->GetRun()) ; 
+        manQA->SetLock() ; 
+      }
+      char * detOCDBDir = Form("%s/%s/%s", det, AliQAv1::GetRefOCDBDirName(), AliQAv1::GetRefDataDirName()) ; 
+      AliCDBEntry * entry = manQA->Get(detOCDBDir, manQA->GetRun()) ;
+      if (entry) {
+        TList * listDetQAD =static_cast<TList *>(entry->GetObject()) ;
+        if ( strcmp(listDetQAD->ClassName(), "TList") != 0 ) {
+          AliError(Form("Expected a Tlist and found a %s for detector %s", listDetQAD->ClassName(), det)) ; 
+          listDetQAD = NULL ; 
+          continue ; 
+        } 
+        if ( listDetQAD ) {
+          TIter next(listDetQAD) ;
+          TObjArray * ar ; 
+          while ( (ar = (TObjArray*)next()) ) 
+            dirOCDB[specie] = static_cast<TObjArray *>(listDetQAD->FindObject(Form("%s/%s", task, AliRecoParam::GetEventSpecieName(specie)))) ;             
+        }
+      }
+    }
+  }
+}
+
+//____________________________________________________________________________
+void AliQACheckerBase::PrintExternParam() 
+{
+    // Print the list of external parameter list
+  TIter next(fExternParamList) ; 
+  TParameter<double> *pp ; 
+  TString printit("\n") ;
+  while( (pp = (TParameter<double>*)next()) )
+    printit += Form("%s = %f\n", pp->GetName(), pp->GetVal());  
+  AliInfo(Form("%s", printit.Data())) ;
+}
+  
 //____________________________________________________________________________
 void AliQACheckerBase::Run(AliQAv1::ALITASK_t index, AliDetectorRecoParam * recoParam) 
 { 
        AliDebug(AliQAv1::GetQADebugLevel(), Form("Processing %s", AliQAv1::GetAliTaskName(index))) ; 
   
        Double_t * rv = NULL ;
-  rv = Check(index, recoParam) ;
+  Check(rv, index, recoParam) ;
        SetQA(index, rv) ;      
        
   AliDebug(AliQAv1::GetQADebugLevel(), Form("Test result of %s", AliQAv1::GetAliTaskName(index))) ;
@@ -270,14 +338,13 @@ void AliQACheckerBase::Run(AliQAv1::ALITASK_t index, TObjArray ** list, AliDetec
 { 
        AliDebug(AliQAv1::GetQADebugLevel(), Form("Processing %s", AliQAv1::GetAliTaskName(index))) ; 
   
-       Double_t * rv = NULL ;
-  rv = Check(index, list, recoParam) ;
+       Double_t * rv = new Double_t[AliRecoParam::kNSpecies] ;
+  Check(rv, index, list, recoParam) ;
        SetQA(index, rv) ;      
        
   AliDebug(AliQAv1::GetQADebugLevel(), Form("Test result of %s", AliQAv1::GetAliTaskName(index))) ;
        
-  if (rv) 
-    delete [] rv ; 
+  delete [] rv ; 
   Finish() ; 
 }
 
@@ -326,11 +393,11 @@ void AliQACheckerBase::MakeImage( TObjArray ** list, AliQAv1::TASKINDEX_t task,
       TPaveText someText(0.015, 0.015, 0.98, 0.98) ;
       someText.AddText(title) ;
       someText.Draw() ; 
-      fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat())) ; 
+      fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ; 
       fImage[esIndex]->Clear() ; 
-      Int_t nx = TMath::Sqrt(nImages) ; 
+      Int_t nx = TMath::Nint(TMath::Sqrt(nImages));
       Int_t ny = nx  ; 
-      while ( nx*ny <= nImages) 
+      if (nx < TMath::Sqrt(nImages))
         ny++ ; 
       
       fImage[esIndex]->Divide(nx, ny) ; 
@@ -343,11 +410,20 @@ void AliQACheckerBase::MakeImage( TObjArray ** list, AliQAv1::TASKINDEX_t task,
         if ( ! cln.Contains("TH") )
           continue ; 
         if(hist->TestBit(AliQAv1::GetImageBit())) {
-          hist->Draw() ; 
+          TString opts = hist->GetDrawOption();
+          if (opts.Contains("logy",TString::kIgnoreCase)) {
+            gPad->SetLogy();
+            opts.ReplaceAll("logy", "");
+          }
+          if (opts.Contains("logx", TString::kIgnoreCase)) {
+            gPad->SetLogx();
+            opts.ReplaceAll("logx", "");
+          }
+          hist->DrawCopy() ; 
           fImage[esIndex]->cd(++npad) ; 
         }
       }
-      fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat())) ; 
+      fImage[esIndex]->Print(Form("%s%s%d.%s", AliQAv1::GetImageFileName(), AliQAv1::GetModeName(mode), AliQAChecker::Instance()->GetRunNumber(), AliQAv1::GetImageFileFormat()), "ps") ; 
     }
   }  
 }