From 384c0618e025235fbc2903f1b85e3b2847f2ff86 Mon Sep 17 00:00:00 2001 From: schutz Date: Fri, 1 Aug 2008 20:33:59 +0000 Subject: [PATCH] a new macro providing a QA GUI for shifter --- STEER/AliQA.cxx | 46 ++++++++++++- STEER/AliQA.h | 2 + test/QA/menuQA.C | 155 +++++++++++++++++++++++++++++++++++++++++++ test/cosmic/rawqa.sh | 1 + 4 files changed, 202 insertions(+), 2 deletions(-) create mode 100644 test/QA/menuQA.C diff --git a/STEER/AliQA.cxx b/STEER/AliQA.cxx index 776b10f3b45..198805cf19e 100644 --- a/STEER/AliQA.cxx +++ b/STEER/AliQA.cxx @@ -405,11 +405,11 @@ const AliQA::TASKINDEX_t AliQA::GetTaskIndex(const char * name) const Bool_t AliQA::IsSet(DETECTORINDEX_t det, ALITASK_t tsk, QABIT_t bit) const { // Checks is the requested bit is set - + CheckRange(det) ; CheckRange(tsk) ; CheckRange(bit) ; - + ULong_t offset = Offset(tsk) ; ULong_t status = GetStatus(det) ; offset+= bit ; @@ -417,6 +417,48 @@ const Bool_t AliQA::IsSet(DETECTORINDEX_t det, ALITASK_t tsk, QABIT_t bit) const return status ; } +//_______________________________________________________________ +const Bool_t AliQA::IsSetAny(DETECTORINDEX_t det, ALITASK_t tsk) const +{ + // Checks is the requested bit is set + + CheckRange(det) ; + CheckRange(tsk) ; + + ULong_t offset = Offset(tsk) ; + ULong_t status = GetStatus(det) ; + UShort_t st = 0 ; + for ( Int_t bit = 0 ; bit < kNBIT ; bit++) { + offset+= bit ; + st += (status & 1 << offset) != 0 ; + } + if ( st == 0 ) + return kFALSE ; + else + return kTRUE ; +} +//_______________________________________________________________ +const Bool_t AliQA::IsSetAny(DETECTORINDEX_t det) const +{ + // Checks is the requested bit is set + + CheckRange(det) ; + + ULong_t status = GetStatus(det) ; + UShort_t st = 0 ; + for ( Int_t tsk = 0 ; tsk < kNTASK ; tsk++) { + ULong_t offset = Offset(ALITASK_t(tsk)) ; + for ( Int_t bit = 0 ; bit < kNBIT ; bit++) { + offset+= bit ; + st += (status & 1 << offset) != 0 ; + } + } + if ( st == 0 ) + return kFALSE ; + else + return kTRUE ; +} + //_______________________________________________________________ AliQA * AliQA::Instance() { diff --git a/STEER/AliQA.h b/STEER/AliQA.h index 066364f5968..3bee309d97c 100644 --- a/STEER/AliQA.h +++ b/STEER/AliQA.h @@ -74,6 +74,8 @@ public: static const TASKINDEX_t GetTaskIndex(const char * name) ; static const TString GetTaskName(UInt_t tsk) { return fgTaskNames[tsk] ; } const Bool_t IsSet(DETECTORINDEX_t det, ALITASK_t tsk, QABIT_t bit) const ; + const Bool_t IsSetAny(DETECTORINDEX_t det, ALITASK_t tsk) const ; + const Bool_t IsSetAny(DETECTORINDEX_t det) const ; void Set(QABIT_t bit) ; static void SetQAResultDirName(const char * name) ; static void SetQARefStorage(const char * name) ; diff --git a/test/QA/menuQA.C b/test/QA/menuQA.C new file mode 100644 index 00000000000..105b2cfb59d --- /dev/null +++ b/test/QA/menuQA.C @@ -0,0 +1,155 @@ +/* + * menuQA.C + * + * + * Created by schutz on 01/08/08. + * Copyright 2008 CERN. All rights reserved. + *fQA + */ +gROOT->Reset("a") ; + +TControlBar * fQA = NULL ; +TControlBar * fDet = NULL ; +TControlBar * fHist = NULL ; +const Int_t fRun = 48868 ; +AliQA * fQAResult = NULL ; +TCanvas * fCa = NULL ; + +void menuQA() +{ + cout << AliQA::GetQAResultFileName() << endl ; + TFile * qaResultFile = TFile::Open("QA.root") ; //AliQA::GetQAResultFileName() ) ; + if ( ! qaResultFile ) { + printf("File %s not found in current directory\n", AliQA::GetQAResultFileName() ) ; + return ; + } + fQAResult = (AliQA *)qaResultFile->Get("QA") ; + if ( ! fQAResult ) { + printf("QA object not found in %s\n", AliQA::GetQAResultFileName() ) ; + return ; + } + + TFile * qaDataFile = TFile::Open(Form("Merged.QA.%d.root", fRun)) ; + if ( ! qaDataFile ) { + printf("File Merged.QA.%d.root not found in current directory\n", fRun) ; + return ; + } + if (fQA) + delete fQA ; + TCanvas * cc = new TCanvas("test", "", 400, 800) ; + fQA = new TControlBar("vertical", Form("Active detectors in Run %d", fRun), 100, 20); + fQA->SetButtonWidth(24) ; + fQA->AddButton("Clean Screen", "Cls()", "Clean the screen"); + // search active detectors + TList * listOfDetectors = qaDataFile->GetListOfKeys() ; + for (Int_t det = 0 ; det < listOfDetectors->GetEntries() ; det++) { + char * detName = listOfDetectors->At(det)->GetName() ; + if (fQAResult->IsSetAny(AliQA::GetDetIndex(detName))) + char * buttonName = Form("QA SIGNALLED !! : %s", detName) ; + else + char * buttonName = Form("QA OK : %s", detName) ; + fQA->AddButton(buttonName, Form("MakeDetMenu(\"%s\")", detName), Form("Display the QA histograms for %s", detName)); + } + fQA->Show(); +} + +void MakeDetMenu(char * detName) +{ + if (fDet) + delete fDet ; + if (fHist) + delete fHist ; + if (fCa) + delete fCa ; + fDet = new TControlBar("vertical", detName, 6000, 8000); + fDet->SetButtonWidth(100) ; + // serach all the QA tasks + TDirectory * save = gDirectory ; + gDirectory->cd(detName) ; + TList * listOfTasks = gDirectory->GetListOfKeys() ; + for (Int_t task = 0 ; task < listOfTasks->GetEntries() ; task++) { + char * taskName = listOfTasks->At(task)->GetName() ; + if (fQAResult->IsSetAny(AliQA::GetDetIndex(detName), AliQA::GetTaskIndex(taskName))) + char * buttonName = Form("QA SIGNALLED !! : %s", taskName) ; + else + char * buttonName = Form("QA OK : %s", taskName) ; + fDet->AddButton(buttonName, Form("MakeTaskMenu(\"%s\", \"%s\")", detName, taskName), Form("Display the QA histograms for %s", taskName)); + } + fDet->Show() ; + gDirectory = save ; +} + +void MakeTaskMenu(char * detName, char * taskName ) +{ + if (fHist) + delete fHist ; + if (fCa) + delete fCa ; + fHist = new TControlBar("vertical", Form("Found QA histo for %s/%s", detName, taskName)); + fHist->SetButtonWidth(100) ; + fHist->AddButton("ALL", Form("DisplayAll(\"%s\", \"%s\")", detName, taskName), Form("Display the QA histograms for %s", detName)); + TDirectory * save = gDirectory ; + gDirectory->cd(Form("%s/%s", detName, taskName)) ; + TList * listOfHistos = gDirectory->GetListOfKeys() ; + for (Int_t h = 0 ; h < listOfHistos->GetEntries() ; h++) { + char * hName = listOfHistos->At(h)->GetName() ; + fHist->AddButton(hName, Form("Display(\"%s\")", hName), Form("Display the QA histograms %s", hName)); + } + fHist->Show() ; + gDirectory = save ; +} + + +void Display(char * hName) +{ + if (fCa) + delete fCa ; + cout << Display << " " << hName << endl ; + fCa = new TCanvas(hName, "test", 800, 600) ; + fCa->SetLogy() ; + TH1 * hh = dynamic_cast(gDirectory->FindObjectAny(hName)); + if (hh) { + hh->Draw() ; + fCa->Modified() ; + fCa->Update() ; + } +} + +void DisplayAll(char * detName, char * taskName) +{ + cout << Display << " " << detName << endl ; + TDirectory * save = gDirectory ; + gDirectory->cd(Form("%s/%s", detName, taskName)) ; + TList * listOfHistos = gDirectory->GetListOfKeys() ; + Int_t nHisto = listOfHistos->GetEntries() ; + Int_t ny = TMath::Sqrt(nHisto) ; + Int_t nx = nHisto / ny + 1 ; + if (fCa) + delete fCa ; + fCa = new TCanvas(Form("QA %s in %s", taskName, detName), Form("QA %s in %s", taskName, detName), nx*300, ny*300) ; + fCa->Divide(nx, ny) ; + for (Int_t h = 0 ; h < listOfHistos->GetEntries() ; h++) { + char * hName = listOfHistos->At(h)->GetName() ; + TH1 * hh = dynamic_cast(gDirectory->FindObjectAny(hName)); + TPad * pad = fCa->cd(h+1) ; + pad->SetLogy() ; + if (hh) { + hh->Draw() ; + fCa->Modified() ; + fCa->Update() ; + } + } + fCa->Modified() ; + fCa->Update() ; + gDirectory = save ; +} + +void Cls() +{ + if (fDet) + delete fDet ; + if (fHist) + delete fHist ; + if (fCa) + delete fCa ; +} diff --git a/test/cosmic/rawqa.sh b/test/cosmic/rawqa.sh index a88260fe020..acb2ef906df 100755 --- a/test/cosmic/rawqa.sh +++ b/test/cosmic/rawqa.sh @@ -93,4 +93,5 @@ EOF rm -f tempo.txt $PROGRAM -b -q $ALICE_ROOT/test/cosmic/qasummary.C +$PROGRAM -b $ALICE_ROOT/test/QA/menuQA.C cd .. -- 2.31.1