X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;ds=sidebyside;f=STEER%2FAliQAChecker.cxx;h=6436154840466967cd94217bbc770c16e801ec07;hb=c421499fe0651d2fa382a44e97a97ddffe1bd376;hp=2bdbe49afe17502cfefeacb7db54d3f72adad3fd;hpb=4edbc5bc72e058d14f3abe309ad004f257ab7c15;p=u%2Fmrichter%2FAliRoot.git diff --git a/STEER/AliQAChecker.cxx b/STEER/AliQAChecker.cxx index 2bdbe49afe1..64361548404 100644 --- a/STEER/AliQAChecker.cxx +++ b/STEER/AliQAChecker.cxx @@ -23,20 +23,27 @@ #include "AliCDBEntry.h" #include "AliCDBManager.h" +#include "AliCDBStorage.h" +#include "AliRunInfo.h" #include "AliLog.h" #include "AliModule.h" #include "AliQA.h" #include "AliQAChecker.h" #include "AliQACheckerBase.h" +#include "AliCorrQAChecker.h" +#include "AliGlobalQAChecker.h" +#include "AliGRPObject.h" #include #include +#include #include #include #include #include #include #include +#include ClassImp(AliQAChecker) AliQAChecker * AliQAChecker::fgQAChecker = 0x0 ; @@ -45,8 +52,11 @@ ClassImp(AliQAChecker) AliQAChecker::AliQAChecker(const char* name, const char* title) : TNamed(name, title), fDataFile(0x0), + fRunInfo(0x0), + fRunInfoOwner(kFALSE), fRefFile(0x0), - fFoundDetectors(".") + fFoundDetectors("."), + fEventSpecie(AliRecoParam::kDefault) { // ctor: initialise checkers and open the data file for (Int_t det = 0 ; det < AliQA::kNDET ; det++) @@ -57,8 +67,11 @@ AliQAChecker::AliQAChecker(const char* name, const char* title) : AliQAChecker::AliQAChecker(const AliQAChecker& qac) : TNamed(qac), fDataFile(qac.fDataFile), + fRunInfo(qac.fRunInfo), + fRunInfoOwner(kFALSE), fRefFile(qac.fRefFile), - fFoundDetectors(qac.fFoundDetectors) + fFoundDetectors(qac.fFoundDetectors), + fEventSpecie(qac.fEventSpecie) { // copy constructor @@ -80,6 +93,8 @@ AliQAChecker& AliQAChecker::operator = (const AliQAChecker& qac) AliQAChecker::~AliQAChecker() { // clean up + if (fRunInfo) + delete fRunInfo ; delete [] fCheckers ; AliQA::Close() ; } @@ -87,79 +102,106 @@ AliQAChecker::~AliQAChecker() //_____________________________________________________________________________ AliQACheckerBase * AliQAChecker::GetDetQAChecker(Int_t det) { - // Gets the Quality Assurance checker for the detector specified by its name - - if (fCheckers[det]) + // Gets the Quality Assurance checker for the detector specified by its name + + if (fCheckers[det]) return fCheckers[det]; - TString detName(AliQA::GetDetName(det)) ; + AliQACheckerBase * qac = NULL ; - AliInfo(Form("Retrieving QA checker for %s", detName.Data())) ; - TPluginManager* pluginManager = gROOT->GetPluginManager() ; - TString qacName = "Ali" + detName + "QAChecker" ; + TString detName(AliQA::GetDetName(det)) ; + + if (det == AliQA::kGLOBAL) { + qac = new AliGlobalQAChecker() ; + } else if (det == AliQA::kCORR) { + qac = new AliCorrQAChecker() ; + } else { + AliDebug(1, Form("Retrieving QA checker for %s", detName.Data())) ; + TPluginManager* pluginManager = gROOT->GetPluginManager() ; + TString qacName = "Ali" + detName + "QAChecker" ; - AliQACheckerBase * qac = NULL ; - // first check if a plugin is defined for the quality assurance checker - TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQAChecker", detName.Data()); - // if not, add a plugin for it - if (!pluginHandler) { - //AliInfo(Form("defining plugin for %s", qacName.Data())); - TString libs = gSystem->GetLibraries(); - - if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) - pluginManager->AddHandler("AliQAChecker", detName, qacName, detName + "qac", qacName + "()"); - else - pluginManager->AddHandler("AliQAChecker", detName, qacName, detName, qacName + "()"); + // first check if a plugin is defined for the quality assurance checker + TPluginHandler* pluginHandler = pluginManager->FindHandler("AliQAChecker", detName.Data()); + // if not, add a plugin for it + if (!pluginHandler) { + //AliInfo(Form("defining plugin for %s", qacName.Data())); + TString libs = gSystem->GetLibraries(); + + if (libs.Contains("lib" + detName + "base.so") || (gSystem->Load("lib" + detName + "base.so") >= 0)) + pluginManager->AddHandler("AliQAChecker", detName, qacName, detName + "qac", qacName + "()"); + else + pluginManager->AddHandler("AliQAChecker", detName, qacName, detName, qacName + "()"); - pluginHandler = pluginManager->FindHandler("AliQAChecker", detName); + pluginHandler = pluginManager->FindHandler("AliQAChecker", detName); - if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) - qac = (AliQACheckerBase *) pluginHandler->ExecPlugin(0); + if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) + qac = (AliQACheckerBase *) pluginHandler->ExecPlugin(0); - if (qac) - fCheckers[det] = qac ; - } - - return qac ; + } + } + if (qac) + fCheckers[det] = qac ; + + return qac ; } - - + //_____________________________________________________________________________ -void AliQAChecker::GetRefSubDir(const char * det, const char * task, TDirectory *& dirFile, TList *& dirOCDB) +void AliQAChecker::GetRefSubDir(const char * det, const char * task, TDirectory *& dirFile, TObjArray **& dirOCDB) { // Opens and returns the file with the reference data - - 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() ; - char detOCDBDir[20] ; - sprintf(detOCDBDir, "%s/%s", AliQA::GetQARefFileName(), det) ; - AliCDBEntry * entry = man->Get(detOCDBDir) ; - TList * listDetQAD = dynamic_cast(entry->GetObject()) ; - if ( listDetQAD ) - dirOCDB = dynamic_cast(listDetQAD->FindObject(task)) ; - } + dirFile = NULL ; + TString refStorage(AliQA::GetQARefStorage()) ; +// if (refStorage.Contains(AliQA::GetLabLocalFile())) { +// refStorage.ReplaceAll(AliQA::GetLabLocalFile(), "") ; +// refStorage += AliQA::GetQARefFileName() ; +// 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())) { + AliError(Form("%s is not a valid location for reference data", refStorage.Data())) ; + return ; + } else { + AliCDBManager* man = AliCDBManager::Instance() ; + for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { + if ( !AliQA::Instance()->IsEventSpecieSet(specie) ) + continue ; + //if ( strcmp(AliQA::GetRefDataDirName(), "") == 0 ) { // the name of the last level of the directory is not set (EventSpecie) + // Get it from RunInfo + //if (!fRunInfo) // not yet set, get the info from GRP + // LoadRunInfoFromGRP() ; + AliQA::SetQARefDataDirName(specie) ; + //} + if ( ! man->GetLock() ) { + man->SetDefaultStorage(AliQA::GetQARefStorage()) ; + man->SetSpecificStorage("*", AliQA::GetQARefStorage()) ; + } + char * detOCDBDir = Form("%s/%s/%s", det, AliQA::GetRefOCDBDirName(), AliQA::GetRefDataDirName()) ; + AliCDBEntry * entry = man->Get(detOCDBDir, man->GetRun()) ; + if (entry) { + dirOCDB = new TObjArray*[AliRecoParam::kNSpecies] ; + TList * listDetQAD = dynamic_cast(entry->GetObject()) ; + TIter next(listDetQAD) ; + TObjArray * ar ; + while ( (ar = (TObjArray*)next()) ) + if ( listDetQAD ) + dirOCDB[specie] = dynamic_cast(listDetQAD->FindObject(Form("%s/%s", task, AliRecoParam::GetEventSpecieName(specie)))) ; + } + } + } } //_____________________________________________________________________________ @@ -171,14 +213,105 @@ AliQAChecker * AliQAChecker::Instance() return fgQAChecker ; } +//_____________________________________________________________________________ +void AliQAChecker::LoadRunInfoFromGRP() +{ + AliCDBManager* man = AliCDBManager::Instance() ; + AliCDBEntry* entry = man->Get(AliQA::GetGRPPath().Data()); + AliGRPObject* grpObject = 0x0; + if (entry) { + + TMap* m = dynamic_cast(entry->GetObject()); // old GRP entry + + if (m) { + AliInfo("It is a map"); + //m->Print(); + grpObject = new AliGRPObject(); + grpObject->ReadValuesFromMap(m); + } + + else { + AliInfo("It is a new GRP object"); + grpObject = dynamic_cast(entry->GetObject()); // new GRP entry + } + + entry->SetOwner(0); + AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data"); + } + + if (!grpObject) { + AliFatal("No GRP entry found in OCDB!"); + } + + TString lhcState = grpObject->GetLHCState(); + if (lhcState==AliGRPObject::GetInvalidString()) { + AliError("GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN"); + lhcState = "UNKNOWN"; + } + + TString beamType = grpObject->GetBeamType(); + if (beamType==AliGRPObject::GetInvalidString()) { + AliError("GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN"); + beamType = "UNKNOWN"; + } + + Float_t beamEnergy = grpObject->GetBeamEnergy(); + if (beamEnergy==AliGRPObject::GetInvalidFloat()) { + AliError("GRP/GRP/Data entry: missing value for the beam energy ! Using 0"); + beamEnergy = 0; + } + + TString runType = grpObject->GetRunType(); + if (runType==AliGRPObject::GetInvalidString()) { + AliError("GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN"); + runType = "UNKNOWN"; + } + + Int_t activeDetectors = grpObject->GetDetectorMask(); + if (activeDetectors==AliGRPObject::GetInvalidInt()) { + AliError("GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399"); + activeDetectors = 1074790399; + } + + fRunInfo = new AliRunInfo(lhcState, beamType, beamEnergy, runType, activeDetectors); + + fRunInfoOwner = kTRUE ; + + // set the event specie + fEventSpecie = AliRecoParam::kDefault ; + if (strcmp(runType,"PHYSICS")) { + // Not a physics run, the event specie is set to kCalib + fEventSpecie = AliRecoParam::kCalib ; + return; + } + if (strcmp(lhcState,"STABLE_BEAMS") == 0) { + // Heavy ion run (any beam tha is not pp, the event specie is set to kHighMult + fEventSpecie = AliRecoParam::kHighMult ; + if ((strcmp(beamType,"p-p") == 0) || + (strcmp(beamType,"p-") == 0) || + (strcmp(beamType,"-p") == 0) || + (strcmp(beamType,"P-P") == 0) || + (strcmp(beamType,"P-") == 0) || + (strcmp(beamType,"-P") == 0)) { + // Proton run, the event specie is set to kLowMult + fEventSpecie = AliRecoParam::kLowMult ; + } + else if (strcmp(beamType,"-") == 0) { + // No beams, we assume cosmic data + fEventSpecie = AliRecoParam::kCosmic ; + } + else if (strcmp(beamType,"UNKNOWN") == 0) { + // No LHC beam information is available, we use the default event specie + fEventSpecie = AliRecoParam::kDefault ; + } + } +} + //_____________________________________________________________________________ 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 - - Bool_t rv = kFALSE ; - + // starting from data in file TStopwatch stopwatch; stopwatch.Start(); @@ -187,7 +320,7 @@ Bool_t AliQAChecker::Run(const char * fileName) TIter nextd(detKeyList) ; TKey * detKey ; while ( (detKey = dynamic_cast(nextd()) ) ) { - AliInfo(Form("Found %s", detKey->GetName())) ; + AliDebug(1, Form("Found %s", detKey->GetName())) ; //Check which detector TString detName ; TString detNameQA(detKey->GetName()) ; @@ -195,9 +328,9 @@ Bool_t AliQAChecker::Run(const char * fileName) for ( det = 0; det < AliQA::kNDET ; det++) { detName = AliQA::GetDetName(det) ; if (detNameQA.Contains(detName)) { - fFoundDetectors+=detName ; - fFoundDetectors+="." ; - break ; + fFoundDetectors+=detName ; + fFoundDetectors+="." ; + break ; } } TDirectory * detDir = AliQA::GetQADataFile(fileName)->GetDirectory(detKey->GetName()) ; @@ -212,34 +345,32 @@ Bool_t AliQAChecker::Run(const char * fileName) taskDir->cd() ; AliQACheckerBase * qac = GetDetQAChecker(det) ; if (qac) - AliInfo(Form("QA checker found for %s", detName.Data())) ; + AliInfo(Form("QA checker found for %s", detName.Data())) ; if (!qac) - AliFatal(Form("QA checker not found for %s", detName.Data())) ; - AliQA::ALITASK index = AliQA::kNULLTASK ; + AliFatal(Form("QA checker not found for %s", detName.Data())) ; + AliQA::ALITASK_t index = AliQA::kNULLTASK ; if ( taskName == AliQA::GetTaskName(AliQA::kHITS) ) - index = AliQA::kSIM ; + index = AliQA::kSIM ; if ( taskName == AliQA::GetTaskName(AliQA::kSDIGITS) ) - index = AliQA::kSIM ; + index = AliQA::kSIM ; if ( taskName == AliQA::GetTaskName(AliQA::kDIGITS) ) - index = AliQA::kSIM ; + index = AliQA::kSIM ; if ( taskName == AliQA::GetTaskName(AliQA::kRECPOINTS) ) - index = AliQA::kREC ; + index = AliQA::kREC ; if ( taskName == AliQA::GetTaskName(AliQA::kTRACKSEGMENTS) ) - index = AliQA::kREC ; + index = AliQA::kREC ; if ( taskName == AliQA::GetTaskName(AliQA::kRECPARTICLES) ) - index = AliQA::kREC ; + index = AliQA::kREC ; if ( taskName == AliQA::GetTaskName(AliQA::kESDS) ) - index = AliQA::kESD ; - qac->Init(AliQA::DETECTORINDEX(det)) ; - - TDirectory * refDir = NULL ; - TList * refOCDBDir = NULL ; - GetRefSubDir(detNameQA.Data(), taskName.Data(), refDir, refOCDBDir) ; - if ( refDir || refOCDBDir) { + index = AliQA::kESD ; + qac->Init(AliQA::DETECTORINDEX_t(det)) ; + + TDirectory * refDir = NULL ; + TObjArray ** refOCDBDir = NULL ; + GetRefSubDir(detNameQA.Data(), taskName.Data(), 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++) { @@ -249,52 +380,81 @@ Bool_t AliQAChecker::Run(const char * fileName) } } printf("\n") ; - rv = kTRUE ; - - return rv ; - + return kTRUE ; } //_____________________________________________________________________________ -Bool_t AliQAChecker::Run(AliQA::DETECTORINDEX det, AliQA::TASKINDEX task, TObjArray * list) +Bool_t AliQAChecker::Run(AliQA::DETECTORINDEX_t det, AliQA::TASKINDEX_t task, TObjArray ** list) { - // run the Quality Assurance Checker for detector det, for task task starting from data in list + // run the Quality Assurance Checker for detector det, for task task starting from data in list - AliQACheckerBase * qac = GetDetQAChecker(det) ; - if (qac) - AliInfo(Form("QA checker found for %s", AliQA::GetDetName(det).Data())) ; - if (!qac) - AliFatal(Form("QA checker not found for %s", AliQA::GetDetName(det).Data())) ; + AliQACheckerBase * qac = GetDetQAChecker(det) ; + if (qac) + AliDebug(1, Form("QA checker found for %s", AliQA::GetDetName(det).Data())) ; + if (!qac) + AliError(Form("QA checker not found for %s", AliQA::GetDetName(det).Data())) ; - AliQA::ALITASK index = AliQA::kNULLTASK ; - if ( task == AliQA::kRAWS ) + AliQA::ALITASK_t index = AliQA::kNULLTASK ; + if ( task == AliQA::kRAWS ) index = AliQA::kRAW ; - else if ( task == AliQA::kHITS ) + else if ( task == AliQA::kHITS ) index = AliQA::kSIM ; - else if ( task == AliQA::kSDIGITS ) + else if ( task == AliQA::kSDIGITS ) index = AliQA::kSIM ; - else if ( task == AliQA::kDIGITS ) + else if ( task == AliQA::kDIGITS ) index = AliQA::kSIM ; - else if ( task == AliQA::kRECPOINTS ) + else if ( task == AliQA::kRECPOINTS ) index = AliQA::kREC ; - else if ( task == AliQA::kTRACKSEGMENTS ) + else if ( task == AliQA::kTRACKSEGMENTS ) index = AliQA::kREC ; - else if ( task == AliQA::kRECPARTICLES ) + else if ( task == AliQA::kRECPARTICLES ) index = AliQA::kREC ; - else if ( task == AliQA::kESDS ) + else if ( task == AliQA::kESDS ) index = AliQA::kESD ; - TDirectory * refDir = NULL ; - TList *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 ; - + TDirectory * refDir = NULL ; + TObjArray ** refOCDBDir = NULL ; + qac->Init(det) ; + GetRefSubDir(AliQA::GetDetName(det), AliQA::GetTaskName(task), refDir, refOCDBDir) ; + qac->SetRefandData(refDir, refOCDBDir) ; + qac->Run(index, list) ; + return kTRUE ; } - - +//_____________________________________________________________________________ +Bool_t AliQAChecker::Run(AliQA::DETECTORINDEX_t det, AliQA::TASKINDEX_t task, TNtupleD ** list) +{ + // run the Quality Assurance Checker for detector det, for task task starting from data in list + + AliQACheckerBase * qac = GetDetQAChecker(det) ; + if (qac) + AliDebug(1, Form("QA checker found for %s", AliQA::GetDetName(det).Data())) ; + if (!qac) + AliError(Form("QA checker not found for %s", AliQA::GetDetName(det).Data())) ; + + AliQA::ALITASK_t index = AliQA::kNULLTASK ; + if ( task == AliQA::kRAWS ) + index = AliQA::kRAW ; + else if ( task == AliQA::kHITS ) + index = AliQA::kSIM ; + else if ( task == AliQA::kSDIGITS ) + index = AliQA::kSIM ; + else if ( task == AliQA::kDIGITS ) + index = AliQA::kSIM ; + else if ( task == AliQA::kRECPOINTS ) + index = AliQA::kREC ; + else if ( task == AliQA::kTRACKSEGMENTS ) + index = AliQA::kREC ; + else if ( task == AliQA::kRECPARTICLES ) + index = AliQA::kREC ; + else if ( task == AliQA::kESDS ) + index = AliQA::kESD ; + + TDirectory * refDir = NULL ; + TObjArray ** refOCDBDir = NULL ; + qac->Init(det) ; + GetRefSubDir(AliQA::GetDetName(det), AliQA::GetTaskName(task), refDir, refOCDBDir) ; + qac->SetRefandData(refDir, refOCDBDir) ; + qac->Run(index, list) ; + return kTRUE ; +}