]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MONITOR/AliQAHistViewer.cxx
- make nested classes in AliTRDtrapConfig public for cling compatible I/O
[u/mrichter/AliRoot.git] / MONITOR / AliQAHistViewer.cxx
index e07dc0b0ff7eea79f3b1ba05a884b56efc054cd9..afafda410c8ca76f6cf59e53581c8f9de84f6aec 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
-
 ////////////////////////////////////////////////////////////////////////////
 //
 //  QA histogram viewer
+//  scans the current directory fro files with QA
+//  and plots them.
 //
 //  origin: Mikolaj Krzewicki, Nikhef, Mikolaj.Krzewicki@cern.ch
 //
 ///////////////////////////////////////////////////////////////////////////
 
+#include <TApplication.h>
+#include <TGButton.h>
+#include <TGFrame.h>
+#include <TFrame.h>
+#include <TRootEmbeddedCanvas.h>
+#include <TGStatusBar.h>
+#include <TCanvas.h>
+#include <TH1.h>
+#include <TF1.h>
+#include <TString.h>
+#include <TGComboBox.h>
+#include <TList.h>
+#include "AliQAHistNavigator.h"
 #include "AliQAHistViewer.h"
 
 ClassImp(AliQAHistViewer)
@@ -28,6 +42,7 @@ ClassImp(AliQAHistViewer)
 //_________________________________________________________________________
 void AliQAHistViewer::DoDrawNext()
 {
+   //draw next histogram
    Int_t rows = 2;
    Int_t cols = 2;
    TString oldDirStr;
@@ -49,20 +64,23 @@ void AliQAHistViewer::DoDrawNext()
        }
        c1->cd(i);
        TH1* hist;
-       if (!fQANavigator->GetHistogram(hist)) break;
-       if (hist) hist->Draw();
-       else continue;
+       if (fQANavigator->GetHistogram(hist))
+       {
+          if (hist) hist->Draw();
+       }
        if (!fQANavigator->Next())
        {
            break;
        }
    }
+   c1->cd(0);
    c1->Update();
 }
 
 //_________________________________________________________________________
 void AliQAHistViewer::DoDrawPrev()
 {
+   //draw previous histogram
    Int_t rows = 2;
    Int_t cols = 2;
    TString oldDirStr;
@@ -84,20 +102,23 @@ void AliQAHistViewer::DoDrawPrev()
        }
        c1->cd(i);
        TH1* hist;
-       if (!fQANavigator->GetHistogram(hist)) break;
-       if (hist) hist->Draw();
-       else continue;
+       if (fQANavigator->GetHistogram(hist))
+       {
+          if (hist) hist->Draw();
+       }
        if (!fQANavigator->Prev())
        {
            break;
        }
    }
+   c1->cd(0);
    c1->Update();
 }
 
 //_________________________________________________________________________
 void AliQAHistViewer::DoExit()
 {
+   //exit
    printf("Exit application...");
    gApplication->Terminate(0);
 }
@@ -105,25 +126,16 @@ void AliQAHistViewer::DoExit()
 //_________________________________________________________________________
 AliQAHistViewer::AliQAHistViewer(const TGWindow *p, UInt_t w, UInt_t h, Bool_t embed) :
     TGMainFrame(p, w, h),
+    fEcan(NULL),
+    fQANavigator(new AliQAHistNavigator()),
     fFileListBox(NULL),
     fDetectorListBox(NULL),
     fLevelListBox(NULL),
     fHistListBox(NULL),
+    fExpertMode(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); 
@@ -144,7 +156,22 @@ AliQAHistViewer::AliQAHistViewer(const TGWindow *p, UInt_t w, UInt_t h, Bool_t e
    hframenav->AddFrame(fHistListBox, new TGLayoutHints(kLHintsLeft));
    AddFrame(hframenav, new TGLayoutHints((kLHintsLeft|kLHintsExpandX), 5,5,5,5));
    UpdateAllPathComboBoxes();
-   // Create a horizontal frame containing two buttons
+   fExpertMode = new TGCheckButton(hframenav,"Expert");
+   hframenav->AddFrame(fExpertMode,new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0));
+   fExpertMode->SetToolTipText("Show expert histograms");
+   fExpertMode->Connect("Toggled(Bool_t)", "AliQAHistViewer", this, "DoSetExpertMode(Bool_t)");
+   // 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));
+  
+   // Create a horizontal frame containing the buttons
    TGHorizontalFrame *hframebuttons = new TGHorizontalFrame(this, 200, 40); 
    TGTextButton *prev = new TGTextButton(hframebuttons, "&Prev");
    prev->Connect("Clicked()", "AliQAHistViewer", this, "DoDrawPrev()");
@@ -152,13 +179,14 @@ AliQAHistViewer::AliQAHistViewer(const TGWindow *p, UInt_t w, UInt_t h, Bool_t e
    TGTextButton *next = new TGTextButton(hframebuttons, "&Next");
    next->Connect("Clicked()", "AliQAHistViewer", this, "DoDrawNext()");
    hframebuttons->AddFrame(next, new TGLayoutHints(kLHintsCenterX, 5, 5, 3, 4));
+   AddFrame(hframebuttons, new TGLayoutHints(kLHintsCenterX, 2, 2, 2, 2));
+
    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");
@@ -177,13 +205,14 @@ AliQAHistViewer::~AliQAHistViewer()
 {
    // Clean up main frame...
    Cleanup();
-   delete fEcan;
+   //delete fEcan;
    delete fQANavigator;
 }
 
 //_________________________________________________________________________
 void AliQAHistViewer::FillComboBoxWithListEntries( TGComboBox* box, const TList* list )
 {
+    //fill the combobox with list entries
     box->RemoveAll();
     Int_t i=0;
     TIter listiter(list);
@@ -198,19 +227,22 @@ void AliQAHistViewer::FillComboBoxWithListEntries( TGComboBox* box, const TList*
 //_________________________________________________________________________
 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);
+    //make gui elements up to date
+    if (!fQANavigator->InitOK()) return;
+    FillComboBoxWithListEntries( fFileListBox, (TList*)fQANavigator->GetFileList()->GetDirs() );
+    FillComboBoxWithListEntries( fDetectorListBox, (TList*)fQANavigator->GetDetectorList()->GetDirs() );
+    FillComboBoxWithListEntries( fLevelListBox, (TList*)fQANavigator->GetLevelList()->GetDirs() );
+    FillComboBoxWithListEntries( fHistListBox, (TList*)fQANavigator->GetItemList() );
+    fFileListBox->Select(fQANavigator->GetCurrListOfFiles()->GetDirs()->IndexOf(fQANavigator->GetCurrFile()),kFALSE);
+    fDetectorListBox->Select(fQANavigator->GetCurrFile()->GetDirs()->IndexOf(fQANavigator->GetCurrDetector()),kFALSE);
+    fLevelListBox->Select(fQANavigator->GetCurrDetector()->GetDirs()->IndexOf(fQANavigator->GetCurrLevel()),kFALSE);
+    fHistListBox->Select(fQANavigator->GetItemList()->IndexOf(fQANavigator->GetCurrItem()),kFALSE);
 }
 
 //_________________________________________________________________________
 void AliQAHistViewer::DoSetFile( Int_t s )
 {
+    //set file from user choice
     fQANavigator->SetFile(s);
     DoDrawNext();
 }
@@ -218,6 +250,7 @@ void AliQAHistViewer::DoSetFile( Int_t s )
 //_________________________________________________________________________
 void AliQAHistViewer::DoSetDetector( Int_t s )
 {
+    //set detector number from user choice
     fQANavigator->SetDetector(s);
     DoDrawNext();
 }
@@ -225,6 +258,7 @@ void AliQAHistViewer::DoSetDetector( Int_t s )
 //_________________________________________________________________________
 void AliQAHistViewer::DoSetLevel( Int_t s )
 {
+    //set QA level
     fQANavigator->SetLevel(s);
     DoDrawNext();
 }
@@ -232,6 +266,15 @@ void AliQAHistViewer::DoSetLevel( Int_t s )
 //_________________________________________________________________________
 void AliQAHistViewer::DoSetHistogram( Int_t s )
 {
-    fQANavigator->SetHist(s);
+    //set histogram
+    fQANavigator->SetItem(s);
+    DoDrawNext();
+}
+
+//_________________________________________________________________________
+void AliQAHistViewer::DoSetExpertMode(Bool_t mode)
+{
+    //set expert mode
+    fQANavigator->SetExpertMode(mode);
     DoDrawNext();
 }