]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/EveBase/AliEveEventManagerEditor.cxx
Add method:
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveEventManagerEditor.cxx
index c53fe53256ba4145b9af1064d77aa12bc9337dc9..f45b0f137623275f9211cc852947427a73121602 100644 (file)
@@ -10,7 +10,9 @@
 #include "AliEveEventManagerEditor.h"
 #include "AliEveEventManager.h"
 
-#include "TVirtualPad.h"
+#include <AliESDEvent.h>
+
+#include <TVirtualPad.h>
 #include "TColor.h"
 
 #include <TEveGValuators.h>
@@ -18,6 +20,8 @@
 #include <TGTextView.h>
 #include <TGLabel.h>
 
+#include "Riostream.h"
+
 //______________________________________________________________________________
 // GUI editor for AliEveEventManager.
 //
@@ -26,72 +30,27 @@ ClassImp(AliEveEventManagerEditor)
 
 //______________________________________________________________________________
 AliEveEventManagerEditor::AliEveEventManagerEditor(const TGWindow *p, Int_t width, Int_t height,
-             UInt_t options, Pixel_t back) :
+                                                  UInt_t options, Pixel_t back) :
   TGedFrame(p, width, height, options | kVerticalFrame, back),
   fM(0),
-  fAutoLoad(0),
-  fAutoLoadTime(0),
-  fNextEvent(0),
-  fPrevEvent(0),
-  fLastEvent(0),
-  fRefresh(0),
+  fDumpEventInfo(0),
   fEventInfo(0)
 {
   // Constructor.
 
   MakeTitle("AliEveEventManager");
 
-  // Create widgets
-  {
-    fAutoLoadTime = new TEveGValuator(this, "Autoload time:", 110, 0);
-    fAutoLoadTime->SetShowSlider(kFALSE);
-    fAutoLoadTime->SetNELength(4);
-    fAutoLoadTime->Build();
-    fAutoLoadTime->SetLimits(0, 1000);
-    fAutoLoadTime->SetToolTip("Automatic event loading time in seconds");
-    fAutoLoadTime->Connect("ValueSet(Double_t)",
-                          "AliEveEventManagerEditor", this, "DoSetAutoLoadTime()");
-
-    fAutoLoad = new TGCheckButton(fAutoLoadTime,"Autoload");
-    fAutoLoad->SetToolTipText("Automatic event loading (online)");
-    fAutoLoadTime->AddFrame(fAutoLoad, new TGLayoutHints(kLHintsLeft, 12, 0, 2, 0));
-    fAutoLoad->Connect("Toggled(Bool_t)",
-                      "AliEveEventManagerEditor", this, "DoSetAutoLoad()");
-    AddFrame(fAutoLoadTime);
-  }
   {
     TGHorizontalFrame* f = new TGHorizontalFrame(this);
-    fPrevEvent = new TGTextButton(f, "Previous Event");
-    fPrevEvent->SetWidth(100);
-    fPrevEvent->ChangeOptions(fPrevEvent->GetOptions() | kFixedWidth);
-    f->AddFrame(fPrevEvent, new TGLayoutHints(kLHintsNormal, 0,4,0,0));
-    fPrevEvent->Connect("Clicked()",
-                       "AliEveEventManagerEditor", this, "DoPrevEvent()");
-    fNextEvent = new TGTextButton(f, "Next Event");
-    fNextEvent->SetWidth(100);
-    fNextEvent->ChangeOptions(fNextEvent->GetOptions() | kFixedWidth);
-    f->AddFrame(fNextEvent, new TGLayoutHints(kLHintsNormal, 4,0,0,0));
-    fNextEvent->Connect("Clicked()",
-                       "AliEveEventManagerEditor", this, "DoNextEvent()");
+    fDumpEventInfo = new TGTextButton(f, "Dump Event Info");
+    fDumpEventInfo->SetToolTipText("Append information about current event to event_info.txt file.");
+    fDumpEventInfo->SetWidth(120);
+    fDumpEventInfo->ChangeOptions(fDumpEventInfo->GetOptions() | kFixedWidth);
+    f->AddFrame(fDumpEventInfo, new TGLayoutHints(kLHintsNormal, 4,0,0,0));
+    fDumpEventInfo->Connect("Clicked()",
+                       "AliEveEventManagerEditor", this, "DumpEventInfo()");
     AddFrame(f, new TGLayoutHints(kLHintsExpandX, 8,8,8,0));
   }
-  {
-    TGHorizontalFrame* f = new TGHorizontalFrame(this);
-    fLastEvent = new TGTextButton(f, "Last Event");
-    fLastEvent->SetWidth(100);
-    fLastEvent->ChangeOptions(fLastEvent->GetOptions() | kFixedWidth);
-    f->AddFrame(fLastEvent, new TGLayoutHints(kLHintsNormal, 0,4,0,0));
-    fLastEvent->Connect("Clicked()",
-                       "AliEveEventManagerEditor", this, "DoLastEvent()");
-    fRefresh = new TGTextButton(f, "Refresh");
-    fRefresh->SetWidth(100);
-    fRefresh->ChangeOptions(fRefresh->GetOptions() | kFixedWidth);
-    f->AddFrame(fRefresh, new TGLayoutHints(kLHintsNormal, 4,0,0,0));
-    fRefresh->Connect("Clicked()",
-                       "AliEveEventManagerEditor", this, "DoRefresh()");
-    AddFrame(f, new TGLayoutHints(kLHintsExpandX, 8,8,8,0));
-  }
-
   {
     TGVerticalFrame* f = new TGVerticalFrame(this);
 
@@ -107,80 +66,36 @@ AliEveEventManagerEditor::AliEveEventManagerEditor(const TGWindow *p, Int_t widt
 
 /******************************************************************************/
 
+//______________________________________________________________________________
 void AliEveEventManagerEditor::SetModel(TObject* obj)
 {
   // Set model object.
 
   fM = dynamic_cast<AliEveEventManager*>(obj);
 
-  // Set values of widgets
-  fAutoLoadTime->SetValue(fM->GetAutoLoadTime());
-  fAutoLoadTime->SetEnabled(fM->GetAutoLoad());
-  fAutoLoad->SetState(fM->GetAutoLoad() ? kButtonDown : kButtonUp);
-
-  fPrevEvent->SetEnabled(!fM->GetIsOnline()); 
-
   fEventInfo->LoadBuffer(fM->GetEventInfoVertical());
 }
 
 /******************************************************************************/
 
-// Implements callback/slot methods
-
-//______________________________________________________________________________
-void AliEveEventManagerEditor::DoSetAutoLoad()
-{
-  // Set the auto-load flag
-  //
-  fM->SetAutoLoad(fAutoLoad->IsOn());
-  Update();
-}
-
-//______________________________________________________________________________
-void AliEveEventManagerEditor::DoSetAutoLoadTime()
-{
-  // Set the auto-load time in seconds
-  //
-  fM->SetAutoLoadTime(fAutoLoadTime->GetValue());
-  fM->SetAutoLoad(fAutoLoad->IsOn());
-  Update();
-}
-
 //______________________________________________________________________________
-void AliEveEventManagerEditor::DoPrevEvent()
+void AliEveEventManagerEditor::DumpEventInfo()
 {
-  // Load previous event
-  fM->PrevEvent();
-}
+  // Dump event-info into event_info.txt.
+  // The info is appended into the file.
 
-//______________________________________________________________________________
-void AliEveEventManagerEditor::DoNextEvent()
-{
-  // Load next event
-  fM->NextEvent();
-}
+  ofstream f("event_info.txt", ios::out | ios::app);
 
-//______________________________________________________________________________
-void AliEveEventManagerEditor::DoLastEvent()
-{
-  // Load last event
-  fM->GotoEvent(-1);
-}
+  f << "================================================================================\n\n";
+  f << fM->GetEventInfoHorizontal() << std::endl << std::endl;
 
-//______________________________________________________________________________
-void AliEveEventManagerEditor::DoRefresh()
-{
-  // Refresh / reopen data-files
-  Int_t ev = fM->GetEventId();
-  fM->Close();
-  fM->Open();
-  fM->GotoEvent(ev);
+  f.close();
 }
 
 
-/******************************************************************************/
+//==============================================================================
 // AliEveEventManagerWindow
-/******************************************************************************/
+//==============================================================================
 
 //______________________________________________________________________________
 //
@@ -189,67 +104,81 @@ void AliEveEventManagerEditor::DoRefresh()
 
 ClassImp(AliEveEventManagerWindow)
 
-AliEveEventManagerWindow::AliEveEventManagerWindow() :
+AliEveEventManagerWindow::AliEveEventManagerWindow(AliEveEventManager* mgr) :
   TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame),
-  fFirstEvent(0),
-  fPrevEvent(0),
-  fNextEvent(0),
-  fLastEvent(0),
-  fEventId  (0),
-  fInfoLabel(0),
-  fEventInfo(0)
+  fM            (mgr),
+  fFirstEvent   (0),
+  fPrevEvent    (0),
+  fNextEvent    (0),
+  fLastEvent    (0),
+  fRefresh      (0),
+  fEventId      (0),
+  fInfoLabel    (0),
+  fAutoLoad     (0),
+  fAutoLoadTime (0),
+  fTrigSel      (0),
+  fEventInfo    (0)
 {
   // Constructor.
 
+  const TString cls("AliEveEventManagerWindow");
+  TGTextButton *b = 0;
   {
     Int_t width = 50;
 
     TGHorizontalFrame* f = new TGHorizontalFrame(this);
-    fFirstEvent = new TGTextButton(f, "First");
-    fFirstEvent->SetWidth(width);
-    fFirstEvent->ChangeOptions(fFirstEvent->GetOptions() | kFixedWidth);
-    f->AddFrame(fFirstEvent, new TGLayoutHints(kLHintsNormal, 2,2,0,0));
-    fFirstEvent->Connect("Clicked()",
-                         "AliEveEventManagerWindow", this, "DoFirstEvent()");
-    fPrevEvent = new TGTextButton(f, "Prev");
-    fPrevEvent->SetWidth(width);
-    fPrevEvent->ChangeOptions(fPrevEvent->GetOptions() | kFixedWidth);
-    f->AddFrame(fPrevEvent, new TGLayoutHints(kLHintsNormal, 2,2,0,0));
-    fPrevEvent->Connect("Clicked()",
-                       "AliEveEventManagerWindow", this, "DoPrevEvent()");
+    AddFrame(f, new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
+
+    fFirstEvent = b = MkTxtButton(f, "First", width);
+    b->Connect("Clicked()", cls, this, "DoFirstEvent()");
+    fPrevEvent = b = MkTxtButton(f, "Prev", width);
+    b->Connect("Clicked()", cls, this, "DoPrevEvent()");
 
     fEventId = new TGNumberEntry(f, 0, 5, -1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
                                  TGNumberFormat::kNELLimitMinMax, 0, 10000);
     f->AddFrame(fEventId, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
-    fEventId->Connect("ValueSet(Long_t)",
-                      "AliEveEventManagerWindow", this, "DoSetEvent()");
+    fEventId->Connect("ValueSet(Long_t)", cls, this, "DoSetEvent()");
     fInfoLabel = new TGLabel(f);
     f->AddFrame(fInfoLabel, new TGLayoutHints(kLHintsNormal, 5, 10, 4, 0));
 
-    fNextEvent = new TGTextButton(f, "Next");
-    fNextEvent->SetWidth(width);
-    fNextEvent->ChangeOptions(fNextEvent->GetOptions() | kFixedWidth);
-    f->AddFrame(fNextEvent, new TGLayoutHints(kLHintsNormal, 2,2,0,0));
-    fNextEvent->Connect("Clicked()",
-                       "AliEveEventManagerWindow", this, "DoNextEvent()");
-    fLastEvent = new TGTextButton(f, "Last");
-    fLastEvent->SetWidth(width);
-    fLastEvent->ChangeOptions(fLastEvent->GetOptions() | kFixedWidth);
-    f->AddFrame(fLastEvent, new TGLayoutHints(kLHintsNormal, 2,2,0,0));
-    fLastEvent->Connect("Clicked()",
-                       "AliEveEventManagerWindow", this, "DoLastEvent()");
-    AddFrame(f, new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
-  }
+    fNextEvent = b = MkTxtButton(f, "Next", width);
+    b->Connect("Clicked()", cls, this, "DoNextEvent()");
+    fLastEvent = b = MkTxtButton(f, "Last", width);
+    b->Connect("Clicked()", cls, this, "DoLastEvent()");
 
-  {
-    TGHorizontalFrame* f = new TGHorizontalFrame(this);
-    fEventInfo = new TGTextView(f, 800, 600);
-    f->AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
-    AddFrame(f, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY, 0,0,2,2));
+    MkLabel(f, "||", 0, 8, 8);
+
+    fRefresh = b = MkTxtButton(f, "Refresh", width + 8);
+    b->Connect("Clicked()",cls, this, "DoRefresh()");
+
+    MkLabel(f, "||", 0, 8, 8);
+
+    fAutoLoad = new TGCheckButton(f, "Autoload");
+    f->AddFrame(fAutoLoad, new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0));
+    fAutoLoad->SetToolTipText("Automatic event loading.");
+    fAutoLoad->Connect("Toggled(Bool_t)", cls, this, "DoSetAutoLoad()");
+
+    fAutoLoadTime = new TEveGValuator(f, "Time: ", 110, 0);
+    f->AddFrame(fAutoLoadTime);
+    fAutoLoadTime->SetShowSlider(kFALSE);
+    fAutoLoadTime->SetNELength(4);
+    fAutoLoadTime->Build();
+    fAutoLoadTime->SetLimits(0, 1000);
+    fAutoLoadTime->SetToolTip("Automatic event loading time in seconds.");
+    fAutoLoadTime->Connect("ValueSet(Double_t)", cls, this, "DoSetAutoLoadTime()");
+
+    fTrigSel = new TGComboBox(f);
+    fTrigSel->Resize(4*width,b->GetDefaultHeight());
+    fTrigSel->AddEntry("No trigger selection",-1);
+    fTrigSel->Select(-1,kFALSE);
+    f->AddFrame(fTrigSel, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
+    fTrigSel->Connect("Selected(char*)", cls, this, "DoSetTrigSel()");
   }
 
-  gAliEveEvent->Connect("NewEventLoaded()",
-                        "AliEveEventManagerWindow", this, "Update()");
+  fEventInfo = new TGTextView(this, 400, 600);
+  AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
+
+  fM->Connect("NewEventLoaded()", cls, this, "Update()");
 
   SetCleanup(kDeepCleanup);
   Layout();
@@ -262,53 +191,159 @@ AliEveEventManagerWindow::~AliEveEventManagerWindow()
 {
   // Destructor.
 
-  gAliEveEvent->Disconnect("NewEventLoaded()", this);
+  fM->Disconnect("NewEventLoaded()", this);
 }
 
 //______________________________________________________________________________
 void AliEveEventManagerWindow::DoFirstEvent()
 {
   // Load previous event
-  gAliEveEvent->GotoEvent(0);
+  fM->GotoEvent(0);
 }
 
 //______________________________________________________________________________
 void AliEveEventManagerWindow::DoPrevEvent()
 {
   // Load previous event
-  gAliEveEvent->PrevEvent();
+  fM->PrevEvent();
 }
 
 //______________________________________________________________________________
 void AliEveEventManagerWindow::DoNextEvent()
 {
   // Load next event
-  gAliEveEvent->NextEvent();
+  fM->NextEvent();
 }
 
 //______________________________________________________________________________
 void AliEveEventManagerWindow::DoLastEvent()
 {
   // Load previous event
-  gAliEveEvent->GotoEvent(-1);
+  fM->GotoEvent(-1);
 }
 
 //______________________________________________________________________________
 void AliEveEventManagerWindow::DoSetEvent()
 {
   // Set current event
-  gAliEveEvent->GotoEvent((Int_t) fEventId->GetNumber());
+  fM->GotoEvent((Int_t) fEventId->GetNumber());
+}
+
+//______________________________________________________________________________
+void AliEveEventManagerWindow::DoRefresh()
+{
+  // Refresh event status.
+
+  Int_t ev = fM->GetEventId();
+  fM->Close();
+  fM->Open();
+  fM->GotoEvent(ev);
+}
+
+//______________________________________________________________________________
+void AliEveEventManagerWindow::DoSetAutoLoad()
+{
+  // Set the auto-load flag
+
+  fM->SetAutoLoad(fAutoLoad->IsOn());
+  Update();
+}
+
+//______________________________________________________________________________
+void AliEveEventManagerWindow::DoSetAutoLoadTime()
+{
+  // Set the auto-load time in seconds
+
+  fM->SetAutoLoadTime(fAutoLoadTime->GetValue());
+}
+
+//______________________________________________________________________________
+void AliEveEventManagerWindow::DoSetTrigSel()
+{
+  // Set the trigger selection
+
+  fM->SetTrigSel(fTrigSel->GetSelectedEntry()->EntryId());
 }
 
 //______________________________________________________________________________
 void AliEveEventManagerWindow::Update()
 {
-  // Update current event, number of available events.
+  // Update current event, number of available events, list of active triggers
+
+  Bool_t autoLoad = fM->GetAutoLoad();
+  Bool_t extCtrl  = fM->IsUnderExternalControl();
+  Bool_t evNavOn  = !autoLoad && !extCtrl;
+
+  fFirstEvent->SetEnabled(evNavOn);
+  fPrevEvent ->SetEnabled(evNavOn);
+  fLastEvent ->SetEnabled(evNavOn);
+  fNextEvent ->SetEnabled(!autoLoad);
+  fRefresh   ->SetEnabled(evNavOn);
+
+  fEventId->SetNumber(fM->GetEventId());
+  fEventId->SetState(evNavOn);
+  fInfoLabel->SetText(Form("/ %d", fM->GetMaxEventId()));
+
+  fAutoLoad->SetState(fM->GetAutoLoad() ? kButtonDown : kButtonUp);
+  fAutoLoadTime->SetValue(fM->GetAutoLoadTime());
 
-  fEventId->SetNumber(gAliEveEvent->GetEventId());
-  fInfoLabel->SetText(Form("/ %d", gAliEveEvent->GetMaxEventId()));
+  // Loop over active trigger classes
+  if (fM->GetESD()) {
+    for(Int_t iTrig = 0; iTrig < AliESDRun::kNTriggerClasses; iTrig++) {
+      TString trigName = fM->GetESD()->GetESDRun()->GetTriggerClass(iTrig);
+      if (trigName.IsNull()) {
+       if (fTrigSel->GetListBox()->GetEntry(iTrig)) {
+         if (fTrigSel->GetSelected() == iTrig) fTrigSel->Select(-1);
+         fTrigSel->RemoveEntry(iTrig);
+       }
+       continue;
+      }
+      if (!fTrigSel->FindEntry(trigName.Data()))
+       fTrigSel->AddEntry(trigName.Data(),iTrig);
+    }
+  }
+  fTrigSel->SetEnabled(!evNavOn);
 
-  fEventInfo->LoadBuffer(gAliEveEvent->GetEventInfoHorizontal());
+  fEventInfo->LoadBuffer(fM->GetEventInfoHorizontal());
 
   Layout();
 }
+
+//------------------------------------------------------------------------------
+// Protected methods
+//------------------------------------------------------------------------------
+
+//______________________________________________________________________________
+TGTextButton* AliEveEventManagerWindow::MkTxtButton(TGCompositeFrame* p,
+                                                   const char* txt, Int_t width,
+                                                   Int_t lo, Int_t ro, Int_t to, Int_t bo)
+{
+  // Create a standard button.
+  // If width is not zero, the fixed-width flag is set.
+
+  TGTextButton* b = new TGTextButton(p, txt);
+  if (width > 0) {
+    b->SetWidth(width);
+    b->ChangeOptions(b->GetOptions() | kFixedWidth);
+  }
+  p->AddFrame(b, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
+  return b;
+}
+
+//______________________________________________________________________________
+TGLabel* AliEveEventManagerWindow::MkLabel(TGCompositeFrame* p,
+                                          const char* txt, Int_t width,
+                                          Int_t lo, Int_t ro, Int_t to, Int_t bo)
+{
+  // Create a standard button.
+  // If width is not zero, the fixed-width flag is set.
+
+  TGLabel* l = new TGLabel(p, txt);
+  if (width > 0) {
+    l->SetWidth(width);
+    l->ChangeOptions(l->GetOptions() | kFixedWidth);
+  }
+  p->AddFrame(l, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
+  return l;
+}
+