// //
///////////////////////////////////////////////////////////////////////////////
+#include "AliCDBEntry.h"
+#include "AliCDBManager.h"
#include "AliLog.h"
#include "AliModule.h"
#include "AliQA.h"
ClassImp(AliQAChecker)
AliQAChecker * AliQAChecker::fgQAChecker = 0x0 ;
- TFile * AliQAChecker::fgQAResultFile = 0x0 ;
- TString AliQAChecker::fgQAResultDirName = "local://RUN/";
- TString AliQAChecker::fgQAResultFileName = "QA.root" ;
//_____________________________________________________________________________
AliQAChecker::AliQAChecker(const char* name, const char* title) :
TNamed(name, title),
fDataFile(0x0),
- fRefDirName("./Ref/"),
- fRefName("QA.root"),
+ fRefFile(0x0),
fFoundDetectors(".")
{
// ctor: initialise checkers and open the data file
for (Int_t det = 0 ; det < AliQA::kNDET ; det++)
fCheckers[det] = NULL ;
-
- GetDataFile() ;
- fRefDirName.Append(fRefName) ;
}
//_____________________________________________________________________________
AliQAChecker::AliQAChecker(const AliQAChecker& qac) :
TNamed(qac),
fDataFile(qac.fDataFile),
- fRefDirName(qac.fRefDirName),
- fRefName(qac.fRefName),
+ fRefFile(qac.fRefFile),
fFoundDetectors(qac.fFoundDetectors)
{
// copy constructor
{
// clean up
delete [] fCheckers ;
- fgQAResultFile->Close() ;
-}
-
-//_____________________________________________________________________________
-TFile * AliQAChecker:: GetDataFile()
-{
- // Open if necessary the Data file and return its pointer
-
- if (!fDataFile)
- if (gSystem->AccessPathName(AliQA::GetDataName()))
- fDataFile = TFile::Open(AliQA::GetDataName()) ;
- return fDataFile ;
-}
-
-//_____________________________________________________________________________
-TFile * AliQAChecker:: GetQAResultFile()
-{
- // Check if file to store QA exists, if not create it
-
- if (fgQAResultFile) {
- if (fgQAResultFile->IsOpen()){
- fgQAResultFile->Close() ;
- fgQAResultFile = 0x0 ;
- }
- }
- if ( fgQAResultFileName.Contains("local://"))
- fgQAResultFileName.ReplaceAll("local:/", "") ;
-
- TString opt("") ;
- if ( !gSystem->AccessPathName(fgQAResultFileName) )
- opt = "UPDATE" ;
- else
- opt = "NEW" ;
- fgQAResultFile = TFile::Open(fgQAResultFileName, opt) ;
-
- return fgQAResultFile ;
+ AliQA::Close() ;
}
//_____________________________________________________________________________
//_____________________________________________________________________________
-TDirectory * AliQAChecker::GetRefSubDir(const char * det, const char * task)
+void AliQAChecker::GetRefSubDir(const char * det, const char * task, TDirectory *& dirFile, TObjArray *& dirOCDB)
{
// Opens and returns the file with the reference data
- TFile * f = TFile::Open(fRefDirName, "READ") ;
- if (!f)
- AliFatal(Form("Cannot find reference file %s", fRefDirName.Data())) ;
- TDirectory * rv = NULL ;
- rv = f->GetDirectory(det) ;
- if (!rv) {
- AliWarning(Form("Directory %s not found in %d", det, fRefDirName.Data())) ;
- } else {
- rv = rv->GetDirectory(task) ;
- if (!rv)
- AliWarning(Form("Directory %s/%s not found in %s", det, task, fRefDirName.Data())) ;
- }
- return rv ;
+
+ dirFile = NULL ;
+ dirOCDB = NULL ;
+ TString refStorage(AliQA::GetQARefStorage()) ;
+ refStorage += AliQA::GetQARefFileName() ;
+ if (refStorage.Contains(AliQA::GetLabLocalFile())) {
+ refStorage.ReplaceAll(AliQA::GetLabLocalFile(), "") ;
+ if ( fRefFile )
+ if ( fRefFile->IsOpen() )
+ fRefFile->Close() ;
+ fRefFile = TFile::Open(refStorage.Data()) ;
+ if (!fRefFile) {
+ AliError(Form("Cannot find reference file %s", refStorage.Data())) ;
+ dirFile = NULL ;
+ }
+ dirFile = fRefFile->GetDirectory(det) ;
+ if (!dirFile) {
+ AliWarning(Form("Directory %s not found in %d", det, refStorage.Data())) ;
+ } else {
+ dirFile = dirFile->GetDirectory(task) ;
+ if (!dirFile)
+ AliWarning(Form("Directory %s/%s not found in %s", det, task, refStorage.Data())) ;
+ }
+ } else if (refStorage.Contains(AliQA::GetLabLocalOCDB()) || refStorage.Contains(AliQA::GetLabAliEnOCDB())) {
+ AliCDBManager* man = AliCDBManager::Instance() ;
+ if ( ! man->IsDefaultStorageSet() ) {
+ man->SetDefaultStorage(AliQA::GetQARefDefaultStorage()) ;
+ man->SetSpecificStorage(Form("%s/*", AliQA::GetQAOCDBDirName()), AliQA::GetQARefStorage()) ;
+ }
+ char detOCDBDir[20] ;
+ sprintf(detOCDBDir, "%s/%s/%s", AliQA::GetQAOCDBDirName(), det, AliQA::GetRefOCDBDirName()) ;
+ AliCDBEntry * entry = man->Get(detOCDBDir, 0) ; //FIXME 0 --> RUN NUMBER
+ if (entry) {
+ TList * listDetQAD = dynamic_cast<TList *>(entry->GetObject()) ;
+ if ( listDetQAD )
+ dirOCDB = dynamic_cast<TObjArray *>(listDetQAD->FindObject(task)) ;
+ }
+ }
}
//_____________________________________________________________________________
}
//_____________________________________________________________________________
-Bool_t AliQAChecker::Run()
+Bool_t AliQAChecker::Run(const char * fileName)
{
// run the Quality Assurance Checker for all tasks Hits, SDigits, Digits, recpoints, tracksegments, recparticles and ESDs
// starting from data in file
stopwatch.Start();
//search for all detectors QA directories
- TList * detKeyList = GetDataFile()->GetListOfKeys() ;
+ TList * detKeyList = AliQA::GetQADataFile(fileName)->GetListOfKeys() ;
TIter nextd(detKeyList) ;
TKey * detKey ;
while ( (detKey = dynamic_cast<TKey *>(nextd()) ) ) {
break ;
}
}
- TDirectory * detDir = GetDataFile()->GetDirectory(detKey->GetName()) ;
+ TDirectory * detDir = AliQA::GetQADataFile(fileName)->GetDirectory(detKey->GetName()) ;
TList * taskKeyList = detDir->GetListOfKeys() ;
TIter nextt(taskKeyList) ;
TKey * taskKey ;
if ( taskName == AliQA::GetTaskName(AliQA::kESDS) )
index = AliQA::kESD ;
qac->Init(AliQA::DETECTORINDEX(det)) ;
- qac->SetRefandData(GetRefSubDir(detNameQA.Data(), taskName.Data()), taskDir) ;
- qac->Run(index) ;
- }
- }
+
+ TDirectory * refDir = NULL ;
+ TObjArray * refOCDBDir = NULL ;
+ GetRefSubDir(detNameQA.Data(), taskName.Data(), refDir, refOCDBDir) ;
+ if ( refDir || refOCDBDir) {
+ qac->SetRefandData(refDir, refOCDBDir, taskDir) ;
+ qac->Run(index) ;
+ }
+ }
+ }
AliInfo("QA performed for following detectors:") ;
for ( Int_t det = 0; det < AliQA::kNDET; det++) {
if (fFoundDetectors.Contains(AliQA::GetDetName(det))) {
}
//_____________________________________________________________________________
-Bool_t AliQAChecker::Run(AliQA::DETECTORINDEX det, AliQA::TASKINDEX task, TList * list)
+Bool_t AliQAChecker::Run(AliQA::DETECTORINDEX det, AliQA::TASKINDEX task, TObjArray * list)
{
// run the Quality Assurance Checker for detector det, for task task starting from data in list
else if ( task == AliQA::kESDS )
index = AliQA::kESD ;
- qac->Init(det) ;
- qac->SetRefandData(GetRefSubDir(AliQA::GetDetName(det).Data(), AliQA::GetTaskName(task).Data())) ;
- qac->Run(index, list) ;
-
+ TDirectory * refDir = NULL ;
+ TObjArray * refOCDBDir = NULL ;
+ GetRefSubDir(AliQA::GetDetName(det), AliQA::GetTaskName(task), refDir, refOCDBDir) ;
+ if ( refDir || refOCDBDir) {
+ qac->Init(det) ;
+ qac->SetRefandData(refDir, refOCDBDir) ;
+ qac->Run(index, list) ;
+ }
return kTRUE ;
}
-//_____________________________________________________________________________
-void AliQAChecker::SetQAResultDirName(const char * name)
-{
- // Set the root directory where to store the QA status object
-
- fgQAResultDirName.Prepend(name) ;
- AliInfo(Form("QA results are in %s", fgQAResultDirName.Data())) ;
- if ( fgQAResultDirName.Contains("local://"))
- fgQAResultDirName.ReplaceAll("local:/", "") ;
- fgQAResultFileName.Prepend(fgQAResultDirName) ;
-}
-
-//_____________________________________________________________________________
-void AliQAChecker::SetRefDirName(const char * name)
-{
- // Set the root directory of reference data
-
- fRefDirName.Prepend(name) ;
- fRefDirName.Append(fRefName) ;
- AliInfo(Form("Reference data are taken from %s", fRefDirName.Data())) ;
- if ( fRefDirName.Contains("local://"))
- fRefDirName.ReplaceAll("local:/", "") ;
-}
-
-
-