From 923f55ee5f9b3315c4059343804cc49c71c543d1 Mon Sep 17 00:00:00 2001 From: cvetan Date: Fri, 15 Aug 2008 15:41:42 +0000 Subject: [PATCH] New code for visualization of QA histos. Will be embedded in AliEve (Mikolaj) --- MONITOR/AliQAHistNavigator.cxx | 593 +++++++++++++++++++++++++++++++++ MONITOR/AliQAHistNavigator.h | 99 ++++++ MONITOR/AliQAHistViewer.cxx | 237 +++++++++++++ MONITOR/AliQAHistViewer.h | 58 ++++ MONITOR/MONITORLinkDef.h | 2 + MONITOR/libMONITOR.pkg | 3 +- 6 files changed, 991 insertions(+), 1 deletion(-) create mode 100644 MONITOR/AliQAHistNavigator.cxx create mode 100644 MONITOR/AliQAHistNavigator.h create mode 100644 MONITOR/AliQAHistViewer.cxx create mode 100644 MONITOR/AliQAHistViewer.h diff --git a/MONITOR/AliQAHistNavigator.cxx b/MONITOR/AliQAHistNavigator.cxx new file mode 100644 index 00000000000..fc90b708a05 --- /dev/null +++ b/MONITOR/AliQAHistNavigator.cxx @@ -0,0 +1,593 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +//////////////////////////////////////////////////////////////////////////// +// +// support class for the QA histogram viewer +// +// origin: Mikolaj Krzewicki, Nikhef, Mikolaj.Krzewicki@cern.ch +// +/////////////////////////////////////////////////////////////////////////// + +#include "AliQAHistNavigator.h" + +ClassImp(AliQAHistNavigator) + +//_________________________________________________________________________ +AliQAHistNavigator::AliQAHistNavigator(Int_t run, Int_t rev): + fPFile( NULL ), + fRun( run ), + fCyc( rev ), + fPCurrFile( NULL ), + fPCurrDetector( NULL ), + fPCurrLevel( NULL ), + fPCurrHistName( NULL ), + fPListOfFiles( new TList() ), + fLoopAllFiles(kTRUE), + fLoopAllDetectors(kTRUE), + fLoopAllLevels(kTRUE) +{ + if (CloneDirStructure()) + { + fPCurrFile = (TList*)fPListOfFiles->First(); + if (fPCurrFile) + { + fPCurrDetector = (TList*)fPCurrFile->First(); + if (fPCurrDetector) + { + fPCurrLevel = (TList*) fPCurrDetector->First(); + if (fPCurrLevel) + { + fPCurrHistName = (TObjString*) fPCurrLevel->First(); + if (fPCurrHistName) + { + OpenCurrentFile(); + OpenCurrentDirectory(); + } + } + } + } + } else + { + printf("AliQAHistNavigator::AliQAHistNavigator(): error reading files\n"); + } + +} + +//_________________________________________________________________________ +Bool_t AliQAHistNavigator::GetNextHistogram(TH1*& hist) +{ + //moves to the next histogram from the list and tries to get it. + if (!Next()) + { + hist = NULL; + return kFALSE; + } + if (GetHistName()=="") + if (!Next()) + { + hist = NULL; + return kTRUE; + } + return GetHistogram(hist); +} + +//_________________________________________________________________________ +Bool_t AliQAHistNavigator::GetHistogram(TH1*& hist) +{ + gDirectory->GetObject(GetFileName()+":"+GetDirName()+"/"+GetHistName(),hist); + if (!hist) + { + printf("GetHistogram: null pointer returned by gDirectory\n"); + return kFALSE; + } + return kTRUE; +} + +//_________________________________________________________________________ +Bool_t AliQAHistNavigator::GetPrevHistogram(TH1*& hist) +{ + //moves to the prev histogram from the list and tries to get it. + if (!Prev()) + { + hist = NULL; + return kFALSE; + } + if (GetHistName()=="") + if (!Prev()) + { + hist = NULL; + return kTRUE; + } + return GetHistogram(hist); +} + +//_________________________________________________________________________ +Bool_t AliQAHistNavigator::Next() +{ + if (!fPCurrHistName) return kFALSE; + if (!(fPCurrHistName=(TObjString*)fPCurrLevel->After(fPCurrHistName))) + { + if (!(fPCurrLevel=(TList*)fPCurrDetector->After(fPCurrLevel))) + { + if (!(fPCurrDetector=(TList*)fPCurrFile->After(fPCurrDetector))) + { + if (!(fPCurrFile=(TList*)fPListOfFiles->After(fPCurrFile))) + { + //we're at the end of everything + if (fLoopAllFiles) + { + //rewind to the beginning + fPCurrFile = (TList*)fPListOfFiles->First(); + fPCurrDetector = (TList*)fPCurrFile->First(); + fPCurrLevel = (TList*) fPCurrDetector->First(); + fPCurrHistName = (TObjString*) fPCurrLevel->First(); + OpenCurrentFile(); + OpenCurrentDirectory(); + printf("----------------back at the beginning!\n"); + } else return kFALSE; //no rewind, we finish + } else //if there is a next file + { + fPCurrDetector = (TList*)fPCurrFile->First(); + fPCurrLevel=(TList*)fPCurrDetector->First(); + fPCurrHistName=(TObjString*)fPCurrLevel->First(); + cout<First(); + fPCurrHistName=(TObjString*)fPCurrLevel->First(); + cout<First(); + cout<Before(fPCurrHistName))) + { + if (!(fPCurrLevel=(TList*)fPCurrDetector->Before(fPCurrLevel))) + { + if (!(fPCurrDetector=(TList*)fPCurrFile->Before(fPCurrDetector))) + { + if (!(fPCurrFile=(TList*)fPListOfFiles->Before(fPCurrFile))) + { + //we're at the end of everything + if (fLoopAllFiles) + { + //rewind to the beginning + fPCurrFile = (TList*)fPListOfFiles->Last(); + fPCurrDetector = (TList*)fPCurrFile->Last(); + fPCurrLevel = (TList*) fPCurrDetector->Last(); + fPCurrHistName = (TObjString*) fPCurrLevel->Last(); + OpenCurrentFile(); + OpenCurrentDirectory(); + printf("----------------back at the end!\n"); + } else return kFALSE; //no rewind, we finish + } else //if there is a next file + { + fPCurrDetector = (TList*)fPCurrFile->Last(); + fPCurrLevel=(TList*)fPCurrDetector->Last(); + fPCurrHistName=(TObjString*)fPCurrLevel->Last(); + cout<Last(); + fPCurrHistName=(TObjString*)fPCurrLevel->Last(); + cout<Last(); + cout<Close(); + if (!(fPFile->Open(GetFileName(),"READ"))) + { + return kFALSE; + cout<<"There is no file: "<cd(GetDirName())) return kFALSE; + return kTRUE; +} + +//_________________________________________________________________________ +Bool_t AliQAHistNavigator::SetFile( TString file ) +{ + TList* tmp = (TList*)fPListOfFiles->FindObject ( file.Data() ); + if (!tmp) return kFALSE; + fPCurrFile = tmp; + OpenCurrentFile(); + fPCurrDetector = (TList*)fPCurrFile->First(); + fPCurrLevel = (TList*)fPCurrDetector->First(); + fPCurrHistName = (TObjString*)fPCurrLevel->First(); + return kTRUE; +} + +//_________________________________________________________________________ +Bool_t AliQAHistNavigator::SetFile( Int_t file ) +{ + printf("AliQAHistNavigator::SetFile(%i)\n",file); + TList* tmp = (TList*)fPListOfFiles->At(file); + if (!tmp) return kFALSE; + fPCurrFile = tmp; + OpenCurrentFile(); + fPCurrDetector = (TList*)fPCurrFile->First(); + fPCurrLevel = (TList*)fPCurrDetector->First(); + fPCurrHistName = (TObjString*)fPCurrLevel->First(); + OpenCurrentDirectory(); + return kTRUE; +} + +//_________________________________________________________________________ +Bool_t AliQAHistNavigator::SetDetector( TString det ) +{ + TList* tmp = (TList*)fPCurrFile->FindObject( det.Data() ); + if (!tmp) return kFALSE; + fPCurrDetector = tmp; + fPCurrLevel = (TList*)fPCurrDetector->First(); + fPCurrHistName = (TObjString*)fPCurrLevel->First(); + OpenCurrentDirectory(); + return kTRUE; +} + +//_________________________________________________________________________ +Bool_t AliQAHistNavigator::SetDetector( Int_t det ) +{ + printf("AliQAHistNavigator::SetDetector(%i)\n",det); + TList* tmp = (TList*)fPCurrFile->At( det ); + if (!tmp) return kFALSE; + fPCurrDetector = tmp; + fPCurrLevel = (TList*)fPCurrDetector->First(); + fPCurrHistName = (TObjString*)fPCurrLevel->First(); + OpenCurrentDirectory(); + return kTRUE; +} + +//_________________________________________________________________________ +Bool_t AliQAHistNavigator::SetLevel( TString level ) +{ + TList* tmp = (TList*)fPCurrDetector->FindObject( level.Data() ); + if (!tmp) return kFALSE; + fPCurrLevel = tmp; + fPCurrHistName = (TObjString*)fPCurrLevel->First(); + OpenCurrentDirectory(); + return kTRUE; +} + +//_________________________________________________________________________ +Bool_t AliQAHistNavigator::SetLevel( Int_t level ) +{ + TList* tmp = (TList*)fPCurrDetector->At( level ); + if (!tmp) return kFALSE; + fPCurrLevel = tmp; + fPCurrHistName = (TObjString*)fPCurrLevel->First(); + OpenCurrentDirectory(); + return kTRUE; +} + +//_________________________________________________________________________ +Bool_t AliQAHistNavigator::SetHist( TString hist ) +{ + TObjString* tmp = (TObjString*)fPCurrLevel->FindObject( hist.Data() ); + if (!tmp) return kFALSE; + fPCurrHistName = tmp; + return kTRUE; +} + +//_________________________________________________________________________ +Bool_t AliQAHistNavigator::SetHist( Int_t hist ) +{ + TObjString* tmp = (TObjString*)fPCurrLevel->At( hist ); + if (!tmp) return kFALSE; + fPCurrHistName = tmp; + return kTRUE; +} + +//_________________________________________________________________________ +void AliQAHistNavigator::PrintDebugInfo() +{ + if (!fPCurrHistName) {cout<<"no more histograms"<pwd();cout<GetName(); + return name; +} + +//_________________________________________________________________________ +TString AliQAHistNavigator::GetLevelName() +{ + if (!fPCurrLevel) return ""; + TString name = fPCurrLevel->GetName(); + return name; +} + +//_________________________________________________________________________ +TString AliQAHistNavigator::GetFileName() +{ + if (!fPCurrFile) return ""; + TString file = fPCurrFile->GetName(); + return file; +} + +//_________________________________________________________________________ +TString AliQAHistNavigator::GetDirName() +{ + TString dir = "/"+ GetDetectorName()+"/"+GetLevelName(); + return dir; +} + +//_________________________________________________________________________ +TString AliQAHistNavigator::GetHistName() +{ + if (!fPCurrHistName) return ""; + return fPCurrHistName->GetString(); +} + +//_________________________________________________________________________ +Bool_t AliQAHistNavigator::DumpList( TString filename ) +{ + ofstream fout(filename); + if (fout.bad()) return kFALSE; + TString lastlevel=""; + TString lastdet=""; + if (!Next()) return kTRUE; + do + { + if (GetLevelName()!=lastlevel) + { + fout<SetName(det); + //lastdet = det; + //pLevel->SetName(level); + //lastlevel = level; + //pLevel->AddLast(new TObjString("DO NOT REMOVE THIS LINE")); + // + //while (!fin.eof()) + //{ + // line.ReadLine(fin,kFALSE); + // cout<<"read line: "<AddLast(pLevel); + // fPListOfFiles->AddLast(pDetector); + // pDetector = new TList(); + // pDetector->SetName(det); + // cout<<"new detector: "<SetName(level); + // cout<<"new level: "<AddLast(pLevel); + // pLevel = new TList(); + // pLevel->SetName(level); + // cout<<"new level: "<AddLast(new TObjString(line)); + // cout<<"added line: "<First(); + //fPCurrLevel = (TList*) fPCurrDetector->First(); + //fPCurrHistName = (TObjString*) fPCurrLevel->First(); + //OpenCurrentFile(); + //OpenCurrentDirectory(); + //fPListOfFiles->Print(); + return kFALSE; +} + +//_________________________________________________________________________ +Bool_t AliQAHistNavigator::GetListOfFiles() +{ + delete fPListOfFiles; + fPListOfFiles = new TList(); + + TString macdir("."); + gSystem->ExpandPathName(macdir); + + void* dirhandle = gSystem->OpenDirectory(macdir.Data()); + if(dirhandle != 0) + { + const char* filename; + TString runstr = ""; + TString revstr = ""; + runstr += fRun; + revstr += fCyc; + TString reg; + reg+= ".*QA\\."; + reg+= (fRun==0) ? "[0-9].*" : runstr.Data(); + reg+= "\\."; + reg+= (fRun==0) ? "[0-9].*" : revstr.Data(); + reg+= "\\.root$"; + cout< names; + while((filename = gSystem->GetDirEntry(dirhandle)) != 0) + { + if(re.Match(filename)) + { + names.push_back(filename); + } + } + if (names.empty()) + { + printf("GetListOfFiles: no files matching...\n"); + return kFALSE; + } + names.sort(); + char fullName[1000]; + for (std::list::iterator si=names.begin(); si!=names.end(); ++si) + { + sprintf(fullName,"%s", si->c_str()); + TList* f = new TList(); + f->SetName(fullName); + fPListOfFiles->AddLast(f); + } + } + else + { + gSystem->FreeDirectory(dirhandle); + return kFALSE; + } + return kTRUE; +} + +//_________________________________________________________________________ +Bool_t AliQAHistNavigator::CloneDirStructure() +{ + if (!GetListOfFiles()) return kFALSE; + if (fPListOfFiles->GetEntries()==0) return kFALSE; + TIter fileiter(fPListOfFiles); + TList* f; + while ((f = (TList*)fileiter.Next())) + { + TString filename = f->GetName(); + cout<GetPath(); + //returns false if dir in file empty + TList* keys = gDirectory->GetListOfKeys(); + if (!keys) return kFALSE; + if (keys->GetEntries()==0) return kFALSE; + TIter keyiter(keys); + TKey* key; + while ((key = dynamic_cast (keyiter.Next()) )) + { + TString classname=key->GetClassName(); + if (!classname) return kFALSE; + if (classname=="TDirectoryFile") + { + gDirectory->cd(key->GetName()); + gDirectory->pwd(); + TList* newdir = new TList(); + if (!Crawl(newdir)) + { + gDirectory->cd(pwd); + continue; + } + gDirectory->cd(pwd); + + newdir->SetName(key->GetName()); + dir->AddLast(newdir); + } + else + { + cout<GetName()<AddLast(new TObjString(key->GetName())); + } + } + return kTRUE; +} diff --git a/MONITOR/AliQAHistNavigator.h b/MONITOR/AliQAHistNavigator.h new file mode 100644 index 00000000000..58b68473d07 --- /dev/null +++ b/MONITOR/AliQAHistNavigator.h @@ -0,0 +1,99 @@ +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/////////////////////////////////////////////////////////////////////////////// +// +// (see AliQAHistNavigator.cxx for details) +// +// Origin: Mikolaj Krzewicki, Nikhef, Mikolaj.Krzewicki@cern.ch +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef ALIQAHISTNAVIGATOR_H +#define ALIQAHISTNAVIGATOR_H + +#include "TSystem.h" +#include "Riostream.h" +#include "TH1D.h" +#include "TF1.h" +#include "TList.h" +#include "TObjString.h" +#include "TString.h" +#include "TFile.h" +#include "TRegexp.h" +#include "TPRegexp.h" +#include "TKey.h" +#include "TText.h" +#include +#include + +class AliQAHistNavigator { + +public: + AliQAHistNavigator( Int_t run=0, Int_t rev=0 ); + + Bool_t GetHistogram(TH1*& hist); + Bool_t GetNextHistogram(TH1*& hist); + Bool_t GetPrevHistogram(TH1*& hist); + Bool_t Next(); + Bool_t Prev(); + void PrintDebugInfo(); + Bool_t DumpList(TString file="AliQAHistNavigator.conf"); + Bool_t ReadList(TString file="AliQAHistNavigator.conf"); + + Bool_t SetFile (TString file ); + Bool_t SetFile (Int_t file ); + Bool_t SetDetector( TString detector ); + Bool_t SetDetector( Int_t detector ); + Bool_t SetLevel( TString type ); + Bool_t SetLevel( Int_t type ); + Bool_t SetHist( TString histo ); + Bool_t SetHist( Int_t histo ); + void SetLoopAllFiles( const Bool_t s=kTRUE ) {fLoopAllFiles=s;} + void SetLoopAllDetectors( const Bool_t s=kTRUE ) {fLoopAllDetectors=s;} + void SetLoopAllLevels( const Bool_t s=kTRUE ) {fLoopAllLevels=s;} + TString GetDetectorName(); + TString GetLevelName(); + TString GetHistName(); + TString GetFileName(); + TString GetDirName(); + TList* GetFileList() {return fPListOfFiles;} + TList* GetDetectorList() {return fPCurrFile;} + TList* GetLevelList() {return fPCurrDetector;} + TList* GetHistList() {return fPCurrLevel;} + TList* GetCurrListOfFiles() {return fPListOfFiles;} + TList* GetCurrFile() {return fPCurrFile;} + TList* GetCurrDetector() {return fPCurrDetector;} + TList* GetCurrLevel() {return fPCurrLevel;} + TObjString* GetCurrHistName() {return fPCurrHistName;} + + Bool_t CloneDirStructure(); + +private: + + Bool_t OpenCurrentFile(); + Bool_t OpenCurrentDirectory(); + Bool_t GetListOfFiles(); + Bool_t Crawl(TList* parent); + + TFile* fPFile; //pointer to current open file + Int_t fRun; //runnumber + Int_t fCyc; //Cycle number + + //The state of the navigator, these help navigate the "tree" + TList* fPCurrFile; //current list holding detectors + TList* fPCurrDetector; //current list holding levels + TList* fPCurrLevel; //current list holding histograms + TObjString* fPCurrHistName; //current histogram name + + TList* fPListOfFiles; //Tree-like structure of lists within lists mirroring the layout of histogtams in files + + Bool_t fLoopAllFiles; //whether to loop over all files + Bool_t fLoopAllDetectors; //whether to loop over all detectors + Bool_t fLoopAllLevels; //whether to loop over all levels + + ClassDef(AliQAHistNavigator,999) //AliQAHistNavigator class +}; + +#endif + diff --git a/MONITOR/AliQAHistViewer.cxx b/MONITOR/AliQAHistViewer.cxx new file mode 100644 index 00000000000..e07dc0b0ff7 --- /dev/null +++ b/MONITOR/AliQAHistViewer.cxx @@ -0,0 +1,237 @@ +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + +//////////////////////////////////////////////////////////////////////////// +// +// QA histogram viewer +// +// origin: Mikolaj Krzewicki, Nikhef, Mikolaj.Krzewicki@cern.ch +// +/////////////////////////////////////////////////////////////////////////// + +#include "AliQAHistViewer.h" + +ClassImp(AliQAHistViewer) + +//_________________________________________________________________________ +void AliQAHistViewer::DoDrawNext() +{ + Int_t rows = 2; + Int_t cols = 2; + TString oldDirStr; + TString newDirStr; + oldDirStr = fQANavigator->GetDirName(); + + UpdateAllPathComboBoxes(); + + TCanvas *c1 = fEcan->GetCanvas(); + c1->Clear(); + c1->Divide(rows,cols); + for (Int_t i=1; i<=rows*cols;i++) + { + newDirStr = fQANavigator->GetDirName(); + if (newDirStr!=oldDirStr) + { + oldDirStr=newDirStr; + break; + } + c1->cd(i); + TH1* hist; + if (!fQANavigator->GetHistogram(hist)) break; + if (hist) hist->Draw(); + else continue; + if (!fQANavigator->Next()) + { + break; + } + } + c1->Update(); +} + +//_________________________________________________________________________ +void AliQAHistViewer::DoDrawPrev() +{ + Int_t rows = 2; + Int_t cols = 2; + TString oldDirStr; + TString newDirStr; + oldDirStr = fQANavigator->GetDirName(); + + UpdateAllPathComboBoxes(); + + TCanvas *c1 = fEcan->GetCanvas(); + c1->Clear(); + c1->Divide(rows,cols); + for (Int_t i=1; i<=rows*cols;i++) + { + newDirStr = fQANavigator->GetDirName(); + if (newDirStr!=oldDirStr) + { + oldDirStr=newDirStr; + break; + } + c1->cd(i); + TH1* hist; + if (!fQANavigator->GetHistogram(hist)) break; + if (hist) hist->Draw(); + else continue; + if (!fQANavigator->Prev()) + { + break; + } + } + c1->Update(); +} + +//_________________________________________________________________________ +void AliQAHistViewer::DoExit() +{ + printf("Exit application..."); + gApplication->Terminate(0); +} + +//_________________________________________________________________________ +AliQAHistViewer::AliQAHistViewer(const TGWindow *p, UInt_t w, UInt_t h, Bool_t embed) : + TGMainFrame(p, w, h), + fFileListBox(NULL), + fDetectorListBox(NULL), + fLevelListBox(NULL), + fHistListBox(NULL), + fIsEmbedded(embed) +{ + //initialize the QA navigator + fQANavigator = new AliQAHistNavigator(); + // Create the embedded canvas + fEcan = new TRootEmbeddedCanvas(0,this,800,600); + Int_t wid = fEcan->GetCanvasWindowId(); + TCanvas *myc = new TCanvas("MyCanvas", 10,10,wid); + fEcan->AdoptCanvas(myc); + //myc->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)","AliQAHistViewer",this, + // "EventInfo(Int_t,Int_t,Int_t,TObject*)"); + + AddFrame(fEcan, new TGLayoutHints(kLHintsTop | kLHintsLeft | + kLHintsExpandX | kLHintsExpandY,0,0,1,1)); + + // horizontal frame with comboboxes for navigation + TGHorizontalFrame *hframenav = new TGHorizontalFrame(this, 200,40); + fFileListBox = new TGComboBox(hframenav); + fFileListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetFile(Int_t)"); + fFileListBox->Resize(150,20); + hframenav->AddFrame(fFileListBox, new TGLayoutHints(kLHintsExpandY|kLHintsLeft)); + fDetectorListBox = new TGComboBox(hframenav); + fDetectorListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetDetector(Int_t)"); + fDetectorListBox->Resize(100,20); + hframenav->AddFrame(fDetectorListBox, new TGLayoutHints(kLHintsLeft)); + fLevelListBox = new TGComboBox(hframenav); + fLevelListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetLevel(Int_t)"); + fLevelListBox->Resize(100,20); + hframenav->AddFrame(fLevelListBox, new TGLayoutHints(kLHintsLeft)); + fHistListBox = new TGComboBox(hframenav); + fHistListBox->Connect("Selected(Int_t)", "AliQAHistViewer", this, "DoSetHistogram(Int_t)"); + fHistListBox->Resize(250,20); + hframenav->AddFrame(fHistListBox, new TGLayoutHints(kLHintsLeft)); + AddFrame(hframenav, new TGLayoutHints((kLHintsLeft|kLHintsExpandX), 5,5,5,5)); + UpdateAllPathComboBoxes(); + // Create a horizontal frame containing two buttons + TGHorizontalFrame *hframebuttons = new TGHorizontalFrame(this, 200, 40); + TGTextButton *prev = new TGTextButton(hframebuttons, "&Prev"); + prev->Connect("Clicked()", "AliQAHistViewer", this, "DoDrawPrev()"); + hframebuttons->AddFrame(prev, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4)); + TGTextButton *next = new TGTextButton(hframebuttons, "&Next"); + next->Connect("Clicked()", "AliQAHistViewer", this, "DoDrawNext()"); + hframebuttons->AddFrame(next, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4)); + if ((!fIsEmbedded)) + { + TGTextButton *exit = new TGTextButton(hframebuttons, "&Exit "); + exit->Connect("Pressed()", "AliQAHistViewer", this, "DoExit()"); + hframebuttons->AddFrame(exit, new TGLayoutHints(kLHintsRight, 5, 5, 3, 4)); + } + AddFrame(hframebuttons, new TGLayoutHints(kLHintsCenterX, 2, 2, 2, 2)); + + // Set a name to the main frame + SetWindowName("Quality Assurance Monitoring"); + MapSubwindows(); + + // Initialize the layout algorithm via Resize() + Resize(GetDefaultSize()); + + // Map main frame + MapWindow(); + DoDrawNext(); +} + +//_________________________________________________________________________ +AliQAHistViewer::~AliQAHistViewer() +{ + // Clean up main frame... + Cleanup(); + delete fEcan; + delete fQANavigator; +} + +//_________________________________________________________________________ +void AliQAHistViewer::FillComboBoxWithListEntries( TGComboBox* box, const TList* list ) +{ + box->RemoveAll(); + Int_t i=0; + TIter listiter(list); + TObject* o = NULL; + while ((o = (TObject*)listiter.Next())) + { + TString name = o->GetName(); + box->AddEntry( name.Data(), i++ ); + } +} + +//_________________________________________________________________________ +void AliQAHistViewer::UpdateAllPathComboBoxes() +{ + FillComboBoxWithListEntries( fFileListBox, fQANavigator->GetFileList() ); + FillComboBoxWithListEntries( fDetectorListBox, fQANavigator->GetDetectorList() ); + FillComboBoxWithListEntries( fLevelListBox, fQANavigator->GetLevelList() ); + FillComboBoxWithListEntries( fHistListBox, fQANavigator->GetHistList() ); + fFileListBox->Select(fQANavigator->GetCurrListOfFiles()->IndexOf(fQANavigator->GetCurrFile()),kFALSE); + fDetectorListBox->Select(fQANavigator->GetCurrFile()->IndexOf(fQANavigator->GetCurrDetector()),kFALSE); + fLevelListBox->Select(fQANavigator->GetCurrDetector()->IndexOf(fQANavigator->GetCurrLevel()),kFALSE); + fHistListBox->Select(fQANavigator->GetCurrLevel()->IndexOf(fQANavigator->GetCurrHistName()),kFALSE); +} + +//_________________________________________________________________________ +void AliQAHistViewer::DoSetFile( Int_t s ) +{ + fQANavigator->SetFile(s); + DoDrawNext(); +} + +//_________________________________________________________________________ +void AliQAHistViewer::DoSetDetector( Int_t s ) +{ + fQANavigator->SetDetector(s); + DoDrawNext(); +} + +//_________________________________________________________________________ +void AliQAHistViewer::DoSetLevel( Int_t s ) +{ + fQANavigator->SetLevel(s); + DoDrawNext(); +} + +//_________________________________________________________________________ +void AliQAHistViewer::DoSetHistogram( Int_t s ) +{ + fQANavigator->SetHist(s); + DoDrawNext(); +} diff --git a/MONITOR/AliQAHistViewer.h b/MONITOR/AliQAHistViewer.h new file mode 100644 index 00000000000..37cfd8f0a66 --- /dev/null +++ b/MONITOR/AliQAHistViewer.h @@ -0,0 +1,58 @@ +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +/////////////////////////////////////////////////////////////////////////////// +// +// (see AliQAHistNavigator.cxx for details) +// +// Origin: Mikolaj Krzewicki, Nikhef, Mikolaj.Krzewicki@cern.ch +// +////////////////////////////////////////////////////////////////////////////// + +#ifndef ALIQAHISTVIEWER_H +#define ALIQAHISTVIEWER_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "AliQAHistNavigator.h" + +class AliQAHistViewer : public TGMainFrame { + +private: + TRootEmbeddedCanvas *fEcan; //embedded canvas + AliQAHistNavigator *fQANavigator; //the navigator engine + TGComboBox *fFileListBox; //drop down menu + TGComboBox *fDetectorListBox; //drop down menun + TGComboBox *fLevelListBox; //drop down menu + TGComboBox *fHistListBox; //drop down menu + Bool_t fIsEmbedded; //whether the window is embedded somewhere + +public: + AliQAHistViewer(const TGWindow *p, UInt_t w=500, UInt_t h=500, Bool_t embed=kFALSE); + virtual ~AliQAHistViewer(); + void DoExit(); + void DoDrawNext(); + void DoDrawPrev(); + void DoSetFile(Int_t s); + void DoSetDetector(Int_t s); + void DoSetLevel(Int_t s); + void DoSetHistogram(Int_t s); + void FillComboBoxWithListEntries( TGComboBox* box, const TList* list ); + void UpdateAllPathComboBoxes(); + + ClassDef(AliQAHistViewer, 999) +}; + +#endif diff --git a/MONITOR/MONITORLinkDef.h b/MONITOR/MONITORLinkDef.h index 430c4e17f5b..550461b1acc 100644 --- a/MONITOR/MONITORLinkDef.h +++ b/MONITOR/MONITORLinkDef.h @@ -25,5 +25,7 @@ #pragma link C++ class AliMonitorDialog+; #pragma link C++ class AliMonitorClient+; +#pragma link C++ class AliQAHistNavigator+; +#pragma link C++ class AliQAHistViewer+; #endif diff --git a/MONITOR/libMONITOR.pkg b/MONITOR/libMONITOR.pkg index bd1e52c070b..333376cef0b 100644 --- a/MONITOR/libMONITOR.pkg +++ b/MONITOR/libMONITOR.pkg @@ -6,7 +6,8 @@ SRCS:= AliMonitorPlot.cxx AliMonitorHisto.cxx AliMonitorTrend.cxx \ AliMonitorTPC.cxx AliMonitorITS.cxx AliMonitorV0s.cxx \ AliMonitorDataTPC.cxx \ AliMonitorProcess.cxx AliMonitorControl.cxx \ - AliMonitorDialog.cxx AliMonitorClient.cxx + AliMonitorDialog.cxx AliMonitorClient.cxx \ + AliQAHistNavigator.cxx AliQAHistViewer.cxx # Matthias 2007-10-03 HLT legacy code disabled # AliMonitorHLT.cxx AliMonitorHLTHough.cxx \ -- 2.39.3