X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=STEER%2FAliQACheckerBase.cxx;h=043653d871109f48f1ec45d27969b5e042fdab37;hb=b9d1a7e2fd1fffbe9f0d37c43424b0943c915d52;hp=6464cf8a4f96b35b9f0b16fdf5856f75c99288e9;hpb=c39ee44c31896b46e6df5ba21f7db8150e96f350;p=u%2Fmrichter%2FAliRoot.git diff --git a/STEER/AliQACheckerBase.cxx b/STEER/AliQACheckerBase.cxx index 6464cf8a4f9..043653d8711 100644 --- a/STEER/AliQACheckerBase.cxx +++ b/STEER/AliQACheckerBase.cxx @@ -32,16 +32,20 @@ #include #include #include +#include #include // --- 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) @@ -52,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 ; @@ -91,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++) { @@ -105,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 * p ; + while ( (p = (TParameter*)next()) ) + fExternParamList->Add(p) ; + } } //____________________________________________________________________________ @@ -129,76 +139,64 @@ AliQACheckerBase::~AliQACheckerBase() } delete[] fImage ; delete[] fRefOCDBSubDir ; + AliQAv1::GetQAResultFile()->Close() ; + if (fExternParamList) { + fExternParamList->Clear() ; + delete fExternParamList ; + } } //____________________________________________________________________________ -Double_t * AliQACheckerBase::Check(AliQAv1::ALITASK_t /*index*/) +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 // With reference histograms either in a file of in OCDB - Double_t * test = new Double_t[AliRecoParam::kNSpecies] ; - Int_t count[AliRecoParam::kNSpecies] = { 0 }; - + TObjArray ** list = new TObjArray *[AliRecoParam::kNSpecies] ; Int_t specie ; for (specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { - test[specie] = 1.0 ; + list[specie] = new TObjArray(AliQAv1::GetMaxQAObj()) ; if ( !AliQAv1::Instance()->IsEventSpecieSet(specie) ) continue ; if (fDataSubDir) { - if (!fRefSubDir && !fRefOCDBSubDir) { - test[specie] = -1 ; // no reference data - } else { - TList * keyList = fDataSubDir->GetListOfKeys() ; - TIter next(keyList) ; - TKey * key ; - while ( (key = static_cast(next())) ) { - TDirectory * specieDir = fDataSubDir->GetDirectory(key->GetName()) ; - TList * keykeyList = specieDir->GetListOfKeys() ; - TIter next2(keykeyList) ; - TKey * keykey ; - count[specie] = 0 ; - while ( (keykey = static_cast(next2())) ) { - TObject * odata = specieDir->Get(keykey->GetName()) ; - if ( odata->IsA()->InheritsFrom("TH1") ) { - TH1 * hdata = static_cast(odata) ; - TH1 * href = NULL ; - if (fRefSubDir) { - TDirectory * subdir = fRefSubDir->GetDirectory(key->GetName()) ; - href = static_cast(subdir->Get(keykey->GetName())) ; - } else if (fRefOCDBSubDir[specie]) { - href = static_cast(fRefOCDBSubDir[specie]->FindObject(keykey->GetName())) ; - } - if (!href) - test[specie] = -1 ; // no reference data ; - else { - Double_t rv = DiffK(hdata, href) ; - AliDebug(AliQAv1::GetQADebugLevel(), Form("%s ->Test = %f", hdata->GetName(), rv)) ; - test[specie] += rv ; - count[specie]++ ; - } - } else if (!odata->IsA()->InheritsFrom("TDirectory")) // skip the expert directory - AliError(Form("%s Is a Classname that cannot be processed", key->GetClassName())) ; - if (count[specie] != 0) - test[specie] /= count[specie] ; - } + TList * keyList = fDataSubDir->GetListOfKeys() ; + TIter next(keyList) ; + TKey * key ; + while ( (key = static_cast(next())) ) { + TDirectory * specieDir = fDataSubDir->GetDirectory(key->GetName()) ; + TList * keykeyList = specieDir->GetListOfKeys() ; + TIter next2(keykeyList) ; + TKey * keykey ; + while ( (keykey = static_cast(next2())) ) { + TObject * odata = specieDir->Get(keykey->GetName()) ; + if ( odata->IsA()->InheritsFrom("TH1") ) { + TH1 * hdata = static_cast(odata) ; + list[specie]->Add(hdata) ; + } else if (!odata->IsA()->InheritsFrom("TDirectory")) // skip the expert directory + AliError(Form("%s Is a Classname that cannot be processed", key->GetClassName())) ; } } } } - return test ; + + Check(test, index, list, recoParam) ; + + delete[] list ; + } //____________________________________________________________________________ -Double_t * AliQACheckerBase::Check(AliQAv1::ALITASK_t /*index*/, TObjArray ** list) +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)) @@ -213,24 +211,21 @@ Double_t * AliQACheckerBase::Check(AliQAv1::ALITASK_t /*index*/, TObjArray ** li TH1 * hdata ; count[specie] = 0 ; while ( (hdata = static_cast(next())) ) { - TString cln(hdata->ClassName()) ; - if ( cln.Contains("TH1") ) { - if ( hdata) { - if ( hdata->TestBit(AliQAv1::GetExpertBit()) ) // does not perform the test for expert data - continue ; - TH1 * href = NULL ; - if (fRefSubDir) - href = static_cast(fRefSubDir->Get(hdata->GetName())) ; - else if (fRefOCDBSubDir[specie]) - href = static_cast(fRefOCDBSubDir[specie]->FindObject(hdata->GetName())) ; - if (!href) - test[specie] = -1 ; // no reference data ; - else { - Double_t rv = DiffK(hdata, href) ; - AliDebug(AliQAv1::GetQADebugLevel(), Form("%s ->Test = %f", hdata->GetName(), rv)) ; - test[specie] += rv ; - count[specie]++ ; - } + if ( hdata->IsA()->InheritsFrom("TH1") ) { + if ( hdata->TestBit(AliQAv1::GetExpertBit()) ) // does not perform the test for expert data + continue ; + TH1 * href = NULL ; + if (fRefSubDir) + href = static_cast(fRefSubDir->Get(hdata->GetName())) ; + else if (fRefOCDBSubDir[specie]) + href = static_cast(fRefOCDBSubDir[specie]->FindObject(hdata->GetName())) ; + if (!href) + test[specie] = -1 ; // no reference data ; + else { + Double_t rv = DiffK(hdata, href) ; + AliDebug(AliQAv1::GetQADebugLevel(), Form("%s ->Test = %f", hdata->GetName(), rv)) ; + test[specie] += rv ; + count[specie]++ ; } } else AliError("Data type cannot be processed") ; @@ -240,7 +235,6 @@ Double_t * AliQACheckerBase::Check(AliQAv1::ALITASK_t /*index*/, TObjArray ** li } } } - return test ; } @@ -268,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(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(listDetQAD->FindObject(Form("%s/%s", task, AliRecoParam::GetEventSpecieName(specie)))) ; + } + } + } + } +} + +//____________________________________________________________________________ +void AliQACheckerBase::PrintExternParam() +{ + // Print the list of external parameter list + TIter next(fExternParamList) ; + TParameter *pp ; + TString printit("\n") ; + while( (pp = (TParameter*)next()) ) + printit += Form("%s = %f\n", pp->GetName(), pp->GetVal()); + AliInfo(Form("%s", printit.Data())) ; +} + //____________________________________________________________________________ -void AliQACheckerBase::Run(AliQAv1::ALITASK_t index) +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) ; + Check(rv, index, recoParam) ; SetQA(index, rv) ; AliDebug(AliQAv1::GetQADebugLevel(), Form("Test result of %s", AliQAv1::GetAliTaskName(index))) ; @@ -285,18 +334,17 @@ void AliQACheckerBase::Run(AliQAv1::ALITASK_t index) } //____________________________________________________________________________ -void AliQACheckerBase::Run(AliQAv1::ALITASK_t index, TObjArray ** list) +void AliQACheckerBase::Run(AliQAv1::ALITASK_t index, TObjArray ** list, AliDetectorRecoParam * recoParam) { AliDebug(AliQAv1::GetQADebugLevel(), Form("Processing %s", AliQAv1::GetAliTaskName(index))) ; - Double_t * rv = NULL ; - rv = Check(index, list) ; + 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() ; } @@ -304,11 +352,9 @@ void AliQACheckerBase::Run(AliQAv1::ALITASK_t index, TObjArray ** list) void AliQACheckerBase::Finish() const { // wrap up and save QA in proper file + AliQAv1::GetQAResultFile() ; AliQAv1 * qa = AliQAv1::Instance() ; - //qa->Show() ; - AliQAv1::GetQAResultFile()->cd() ; - qa->Write(qa->GetName(), kWriteDelete) ; - AliQAv1::GetQAResultFile()->Close() ; + qa->Write(AliQAv1::GetQAName(), kWriteDelete) ; } //____________________________________________________________________________ @@ -347,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) ; @@ -364,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") ; } } } @@ -406,18 +461,21 @@ void AliQACheckerBase::SetQA(AliQAv1::ALITASK_t index, Double_t * value) const // sets the QA according the return value of the Check AliQAv1 * qa = AliQAv1::Instance(index) ; + for (Int_t specie = 0 ; specie < AliRecoParam::kNSpecies ; specie++) { + if (! qa->IsEventSpecieSet(AliRecoParam::ConvertIndex(specie))) + continue ; if ( value == NULL ) { // 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) ; + qa->Set(AliQAv1::kFATAL, AliRecoParam::ConvertIndex(specie)) ; else if ( value[specie] > fLowTestValue[AliQAv1::kERROR] && value[specie] <= fUpTestValue[AliQAv1::kERROR] ) - qa->Set(AliQAv1::kERROR, specie) ; + qa->Set(AliQAv1::kERROR, AliRecoParam::ConvertIndex(specie)) ; else if ( value[specie] > fLowTestValue[AliQAv1::kWARNING] && value[specie] <= fUpTestValue[AliQAv1::kWARNING] ) - qa->Set(AliQAv1::kWARNING, specie) ; + qa->Set(AliQAv1::kWARNING, AliRecoParam::ConvertIndex(specie)) ; else if ( value[specie] > fLowTestValue[AliQAv1::kINFO] && value[specie] <= fUpTestValue[AliQAv1::kINFO] ) - qa->Set(AliQAv1::kINFO, specie) ; + qa->Set(AliQAv1::kINFO, AliRecoParam::ConvertIndex(specie)) ; } } }