]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MONITOR/AliMonitorControl.cxx
new cuts and tasks added
[u/mrichter/AliRoot.git] / MONITOR / AliMonitorControl.cxx
index 8e045e9d66a05baacac971b3fccde2fe3d4ecd3a..1788dd4a5309fcb806af67f48966c8d0291bebe3 100644 (file)
 ///////////////////////////////////////////////////////////////////////////////
 
 
+#include <cstdlib>
 #include "AliMonitorControl.h"
 #include "AliMonitorHisto.h"
-#include "AliMonitorDialog.h"
+#include "AliLog.h"
 #include <TGNumberEntry.h>
 #include <TGTextView.h>
 #include <TGMsgBox.h>
 #include <TSystem.h>
-#include <TROOT.h>
+#include <TSocket.h>
+#include <TGFrame.h>
+#include <TGMenu.h>
+#include <TGButton.h>
+#include <TGLabel.h>
+#include <TGTextEntry.h>
+#include <TTimer.h>
+#include <TApplication.h>
+#include "AliMonitorProcess.h"
 
 
 ClassImp(AliMonitorControl) 
 
 
-//_____________________________________________________________________________
-class AliMonitorBufferDlg : public AliMonitorDialog {
-
-public:
-  AliMonitorBufferDlg(Int_t& size, TGFrame* main);
-  virtual ~AliMonitorBufferDlg();
-
-  virtual void       OnOkClicked();
-
-private:
-  TGLayoutHints*     fBufferLayout;
-  TGLabel*           fBufferLabel;
-  TGNumberEntry*     fBufferEntry;
-
-  Int_t&             fSize;
-};
-
 
 //_____________________________________________________________________________
-AliMonitorBufferDlg::AliMonitorBufferDlg(Int_t& size, TGFrame* main) :
-  AliMonitorDialog(main, 250, 80), fSize(size)
+AliMonitorControl::AliMonitorBufferDlg::AliMonitorBufferDlg(Int_t& size, 
+                                                           TGFrame* main) :
+  AliMonitorDialog(main, 250, 80),
+  fBufferLayout(new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2)),
+  fBufferLabel(new TGLabel(fFrame, "size of histogram buffer:")),
+  fBufferEntry(new TGNumberEntry(fFrame, size, 2, -1,
+                                TGNumberFormat::kNESInteger)),
+  fSize(size)
 {
 // create a dialog for setting the size of the buffer for monitor histos
 
-  fBufferLayout = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 5, 2, 2);
-  fBufferLabel = new TGLabel(fFrame, "size of histogram buffer:");
   fFrame->AddFrame(fBufferLabel, fBufferLayout);
-  fBufferEntry = new TGNumberEntry(fFrame, size, 2, -1,
-                                  TGNumberFormat::kNESInteger);
   fBufferEntry->SetLimits(TGNumberFormat::kNELLimitMinMax, 1, 99);
   fFrame->AddFrame(fBufferEntry, fBufferLayout);
 
@@ -76,7 +70,7 @@ AliMonitorBufferDlg::AliMonitorBufferDlg(Int_t& size, TGFrame* main) :
 }
 
 //_____________________________________________________________________________
-AliMonitorBufferDlg::~AliMonitorBufferDlg()
+AliMonitorControl::AliMonitorBufferDlg::~AliMonitorBufferDlg()
 {
 // clean up
 
@@ -86,28 +80,19 @@ AliMonitorBufferDlg::~AliMonitorBufferDlg()
 }
 
 //_____________________________________________________________________________
-void AliMonitorBufferDlg::OnOkClicked()
+void AliMonitorControl::AliMonitorBufferDlg::OnOkClicked()
 {
   fSize = fBufferEntry->GetIntNumber();
 }
 
 
 //_____________________________________________________________________________
-class AliMonitorClientsDlg : public AliMonitorDialog {
-
-public:
-  AliMonitorClientsDlg(TObjArray* clients, TGFrame* main);
-  virtual ~AliMonitorClientsDlg();
-
-private:
-  TGLayoutHints*     fClientsLayout;
-  TGTextView*        fClients;
-};
-
-
-//_____________________________________________________________________________
-AliMonitorClientsDlg::AliMonitorClientsDlg(TObjArray* clients, TGFrame* main) :
-  AliMonitorDialog(main, 450, 300, kFALSE)
+AliMonitorControl::AliMonitorClientsDlg::AliMonitorClientsDlg(TObjArray* clients, 
+                                                             TGFrame* main) :
+  AliMonitorDialog(main, 450, 300, kFALSE),
+  fClientsLayout(new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 
+                                  0, 0, 0, 0)),
+  fClients(new TGTextView(fFrame, 420, 230))
 {
 // create a dialog to display the list of clients
 
@@ -115,9 +100,6 @@ AliMonitorClientsDlg::AliMonitorClientsDlg(TObjArray* clients, TGFrame* main) :
   fFrameLayout = new TGLayoutHints(kLHintsCenterX | kLHintsTop, 
                                   10, 10, 15, 15);
   ((TGFrameElement*)(fMain->GetList()->First()))->fLayout = fFrameLayout;
-  fClientsLayout = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 
-                                    0, 0, 0, 0);
-  fClients = new TGTextView(fFrame, 420, 230);
   fFrame->AddFrame(fClients, fClientsLayout);
 
   char line[256];
@@ -144,7 +126,7 @@ AliMonitorClientsDlg::AliMonitorClientsDlg(TObjArray* clients, TGFrame* main) :
 }
 
 //_____________________________________________________________________________
-AliMonitorClientsDlg::~AliMonitorClientsDlg()
+AliMonitorControl::AliMonitorClientsDlg::~AliMonitorClientsDlg()
 {
 // clean up
 
@@ -161,11 +143,50 @@ enum {kMenuFileExit, kMenuFileAbort,
 
 
 //_____________________________________________________________________________
-AliMonitorControl::AliMonitorControl(AliMonitorProcess* process)
+AliMonitorControl::AliMonitorControl(AliMonitorProcess* process):
+  TObject(),
+  fQObject(),
+  fMonitorProcess(process),
+  fColorStatus(0),
+  fColorStart(0),
+  fColorStop(0),
+  fMain(new TGMainFrame(gClient->GetRoot(), 380, 200)),
+  fMenuBarLayout(new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 1, 1)),
+  fMenuBarItemLayout(new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0)),
+  fMenuBarHelpLayout(new TGLayoutHints(kLHintsTop | kLHintsRight)),
+  fMenuFile(new TGPopupMenu(gClient->GetRoot())),
+  fMenuOptions(new TGPopupMenu(gClient->GetRoot())),
+  fMenuHelp(new TGPopupMenu(gClient->GetRoot())),
+  fMenuBar(new TGMenuBar(fMain, 1, 1, kHorizontalFrame)),
+  fFrameLayout(new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 2, 2, 2, 2)),
+  fFrame(new TGVerticalFrame(fMain, 0, 0, kChildFrame | kSunkenFrame)),
+  fStatusLayout(new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 10, 2, 2, 2)),
+  fStatusFrameLayout(new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 2, 2, 2)),
+  fStatus1Frame(new TGHorizontalFrame(fFrame, 0, 0)),
+  fRunNumberLabel(new TGLabel(fStatus1Frame, "current run:")),
+  fRunNumber(new TGTextEntry(fStatus1Frame, "-")),
+  fEventNumberLabel(new TGLabel(fStatus1Frame,"  event:")),
+  fEventNumber(new TGTextEntry(fStatus1Frame, "-/-/-")),
+  fStatus2Frame(new TGHorizontalFrame(fFrame, 0, 0)),
+  fStatusLabel(new TGLabel(fStatus2Frame, "current status:")),
+  fStatus(new TGTextEntry(fStatus2Frame, "stopped")),
+  fStatus3Frame(new TGHorizontalFrame(fFrame, 0, 0)),
+  fEventsLabel(new TGLabel(fStatus3Frame, "monitored events:")),
+  fEvents(new TGTextEntry(fStatus3Frame, "-")),
+  fClientsLabel(new TGLabel(fStatus3Frame, " number of clients:")),
+  fClients(new TGTextEntry(fStatus3Frame, "-")),
+  fButtonFrameLayout(new TGLayoutHints(kLHintsExpandX | kLHintsBottom, 50, 50, 10, 10)),
+  fButtonFrame(new TGHorizontalFrame(fMain, 0, 0)),
+  fButtonLayout(new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2, 2, 2, 2)),
+  fResetButton(new TGTextButton(fButtonFrame, " &Reset ", 1)),
+  fStartStopButton(new TGTextButton(fButtonFrame, " &Start ", 2)),
+  fStartButtonStatus(kTRUE),
+  fTerminating(kFALSE),
+  fTimer(new TTimer(this, 10, kTRUE))
+  
 {
 // initialize the monitoring control window
 
-  fMonitorProcess = process;
 
 
   // colors
@@ -173,35 +194,22 @@ AliMonitorControl::AliMonitorControl(AliMonitorProcess* process)
   gClient->GetColorByName("green", fColorStart);
   gClient->GetColorByName("red", fColorStop);
 
-  // main window
-  fMain = new TGMainFrame(gClient->GetRoot(), 380, 200);
-
-  // menu bar
-  fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX,
-                                      0, 0, 1, 1);
-  fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
-  fMenuBarHelpLayout = new TGLayoutHints(kLHintsTop | kLHintsRight);
-
-  fMenuFile = new TGPopupMenu(gClient->GetRoot());
   fMenuFile->AddEntry("E&xit", kMenuFileExit);
   fMenuFile->AddEntry("&Abort", kMenuFileAbort);
   fMenuFile->DisableEntry(kMenuFileAbort);
   fMenuFile->Connect("Activated(Int_t)", "AliMonitorControl", this,
                     "HandleMenu(Int_t)");
 
-  fMenuOptions = new TGPopupMenu(gClient->GetRoot());
   fMenuOptions->AddEntry("&Histogram buffer...", kMenuOptBuffer);
   fMenuOptions->AddEntry("List of &Clients...", kMenuOptClients);
   fMenuOptions->Connect("Activated(Int_t)", "AliMonitorControl", this,
                        "HandleMenu(Int_t)");
 
-  fMenuHelp = new TGPopupMenu(gClient->GetRoot());
   fMenuHelp->AddEntry("&Documentation...", kMenuHelpDoc);
   fMenuHelp->AddEntry("A&bout...", kMenuHelpAbout);
   fMenuHelp->Connect("Activated(Int_t)", "AliMonitorControl", this,
                     "HandleMenu(Int_t)");
 
-  fMenuBar = new TGMenuBar(fMain, 1, 1, kHorizontalFrame);
   fMenuBar->AddPopup("&File", fMenuFile, fMenuBarItemLayout);
   fMenuBar->AddPopup("&Options", fMenuOptions, fMenuBarItemLayout);
   fMenuBar->AddPopup("&Help", fMenuHelp, fMenuBarHelpLayout);
@@ -210,32 +218,19 @@ AliMonitorControl::AliMonitorControl(AliMonitorProcess* process)
 
 
   // status frame
-  fFrameLayout = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 
-                                  2, 2, 2, 2);
-  fFrame = new TGVerticalFrame(fMain, 0, 0, kChildFrame | kSunkenFrame);
   fMain->AddFrame(fFrame, fFrameLayout);
 
-  fStatusLayout = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 10, 2, 2, 2);
-  fStatusFrameLayout = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 2, 2, 2, 2);
-
-
   // run and event number
-  fStatus1Frame = new TGHorizontalFrame(fFrame, 0, 0);
   fFrame->AddFrame(fStatus1Frame, fStatusFrameLayout);
 
-  fRunNumberLabel = new TGLabel(fStatus1Frame, "current run:");
   fStatus1Frame->AddFrame(fRunNumberLabel, fStatusLayout);
-  fRunNumber = new TGTextEntry(fStatus1Frame, "-");
   fRunNumber->Resize(60, fRunNumber->GetDefaultHeight());
   fRunNumber->SetAlignment(kTextRight);
   fRunNumber->SetEnabled(kFALSE);
   fRunNumber->SetBackgroundColor(fColorStatus);
   fStatus1Frame->AddFrame(fRunNumber, fStatusLayout);
 
-  fEventNumberLabel = new TGLabel(fStatus1Frame, 
-                                 "  event:");
   fStatus1Frame->AddFrame(fEventNumberLabel, fStatusLayout);
-  fEventNumber = new TGTextEntry(fStatus1Frame, "-/-/-");
   fEventNumber->Resize(100, fEventNumber->GetDefaultHeight());
   fEventNumber->SetAlignment(kTextRight);
   fEventNumber->SetEnabled(kFALSE);
@@ -244,12 +239,9 @@ AliMonitorControl::AliMonitorControl(AliMonitorProcess* process)
 
 
   // process status
-  fStatus2Frame = new TGHorizontalFrame(fFrame, 0, 0);
   fFrame->AddFrame(fStatus2Frame, fStatusFrameLayout);
 
-  fStatusLabel = new TGLabel(fStatus2Frame, "current status:");
   fStatus2Frame->AddFrame(fStatusLabel, fStatusLayout);
-  fStatus = new TGTextEntry(fStatus2Frame, "stopped");
   fStatus->Resize(250, fStatus->GetDefaultHeight());
   fStatus->SetAlignment(kTextLeft);
   fStatus->SetEnabled(kFALSE);
@@ -258,21 +250,16 @@ AliMonitorControl::AliMonitorControl(AliMonitorProcess* process)
 
 
   // process status
-  fStatus3Frame = new TGHorizontalFrame(fFrame, 0, 0);
   fFrame->AddFrame(fStatus3Frame, fStatusFrameLayout);
 
-  fEventsLabel = new TGLabel(fStatus3Frame, "monitored events:");
   fStatus3Frame->AddFrame(fEventsLabel, fStatusLayout);
-  fEvents = new TGTextEntry(fStatus3Frame, "-");
   fEvents->Resize(60, fEvents->GetDefaultHeight());
   fEvents->SetAlignment(kTextRight);
   fEvents->SetEnabled(kFALSE);
   fEvents->SetBackgroundColor(fColorStatus);
   fStatus3Frame->AddFrame(fEvents, fStatusLayout);
 
-  fClientsLabel = new TGLabel(fStatus3Frame, " number of clients:");
   fStatus3Frame->AddFrame(fClientsLabel, fStatusLayout);
-  fClients = new TGTextEntry(fStatus3Frame, "-");
   fClients->Resize(40, fClients->GetDefaultHeight());
   fClients->SetAlignment(kTextRight);
   fClients->SetEnabled(kFALSE);
@@ -281,23 +268,15 @@ AliMonitorControl::AliMonitorControl(AliMonitorProcess* process)
 
 
   // buttons
-  fButtonFrameLayout = new TGLayoutHints(kLHintsExpandX | kLHintsBottom, 
-                                        50, 50, 10, 10);
-  fButtonFrame = new TGHorizontalFrame(fMain, 0, 0);
   fMain->AddFrame(fButtonFrame, fButtonFrameLayout);
 
-  fButtonLayout = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 
-                                   2, 2, 2, 2);
-  fResetButton = new TGTextButton(fButtonFrame, " &Reset ", 1);
   fResetButton->Connect("Clicked()", "AliMonitorControl", this, "DoReset()");
   fButtonFrame->AddFrame(fResetButton, fButtonLayout);
 
-  fStartStopButton = new TGTextButton(fButtonFrame, " &Start ", 2);
   fStartStopButton->SetBackgroundColor(0x00FF00);
   fStartStopButton->Connect("Clicked()", "AliMonitorControl", this, 
                            "DoStartStop()");
   fButtonFrame->AddFrame(fStartStopButton, fButtonLayout);
-  fStartButtonStatus = kTRUE;
 
 
   // main window
@@ -312,9 +291,6 @@ AliMonitorControl::AliMonitorControl(AliMonitorProcess* process)
   fMain->MapWindow();
 
 
-  fTerminating = kFALSE;
-
-  fTimer = new TTimer(this, 100, kFALSE);
   fTimer->TurnOn();
 }
 
@@ -376,7 +352,10 @@ void AliMonitorControl::HandleMenu(Int_t id)
                 kMBIconQuestion, kMBYes | kMBNo, &result);
     if (result == kMBYes) {
       fMenuFile->EnableEntry(kMenuFileAbort);
-      if (fMonitorProcess->IsStopped()) exit(0);
+      if (fMonitorProcess->IsStopped()) {
+       delete fMonitorProcess;
+       gApplication->Terminate(0);
+      }
       fMonitorProcess->Stop();
       fTerminating = kTRUE;
     }
@@ -463,10 +442,14 @@ Bool_t AliMonitorControl::HandleTimer(TTimer* timer)
 // update the displayed information
 
   timer->TurnOff();
-  if (fTerminating && fMonitorProcess->IsStopped()) exit(0); 
+  if (fTerminating && fMonitorProcess->IsStopped()) {
+    delete fMonitorProcess;
+    gApplication->Terminate(0);
+  }
   UpdateStatus();
   gSystem->ProcessEvents();
   timer->TurnOn();
+
   return kFALSE;
 }
 
@@ -511,6 +494,8 @@ void AliMonitorControl::UpdateStatus()
     status = "running ITS reconstruction"; break;
   case AliMonitorProcess::kRecV0s: 
     status = "running V0 reconstruction"; break;
+  case AliMonitorProcess::kRecHLT: 
+    status = "running HLT reconstruction"; break;
   case AliMonitorProcess::kFilling: 
     status = "filling monitor histograms"; break;
   case AliMonitorProcess::kUpdating: