AliEveEventManager
[u/mrichter/AliRoot.git] / EVE / EveBase / AliEveEventManagerEditor.cxx
CommitLineData
5655e9ce 1// @(#)root/eve:$Id$
2// Author: Matevz Tadel 2007
3
4/**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
9
10#include "AliEveEventManagerEditor.h"
11#include "AliEveEventManager.h"
12
13#include "TVirtualPad.h"
14#include "TColor.h"
15
319f3084 16#include <TEveGValuators.h>
17#include <TGButton.h>
18#include <TGTextView.h>
19#include <TGLabel.h>
5655e9ce 20
21//______________________________________________________________________________
22// GUI editor for AliEveEventManager.
23//
24
25ClassImp(AliEveEventManagerEditor)
26
27//______________________________________________________________________________
28AliEveEventManagerEditor::AliEveEventManagerEditor(const TGWindow *p, Int_t width, Int_t height,
80547f2d 29 UInt_t options, Pixel_t back) :
5655e9ce 30 TGedFrame(p, width, height, options | kVerticalFrame, back),
319f3084 31 fM(0),
319f3084 32 fNextEvent(0),
319f3084 33 fEventInfo(0)
5655e9ce 34{
35 // Constructor.
36
37 MakeTitle("AliEveEventManager");
38
319f3084 39 {
40 TGHorizontalFrame* f = new TGHorizontalFrame(this);
319f3084 41 fNextEvent = new TGTextButton(f, "Next Event");
ca49b003 42 fNextEvent->SetWidth(100);
43 fNextEvent->ChangeOptions(fNextEvent->GetOptions() | kFixedWidth);
44 f->AddFrame(fNextEvent, new TGLayoutHints(kLHintsNormal, 4,0,0,0));
319f3084 45 fNextEvent->Connect("Clicked()",
46 "AliEveEventManagerEditor", this, "DoNextEvent()");
47 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 8,8,8,0));
48 }
319f3084 49 {
50 TGVerticalFrame* f = new TGVerticalFrame(this);
51
52 TGLabel *eventInfoLabel = new TGLabel(f, "Event Information:");
53 f->AddFrame(eventInfoLabel, new TGLayoutHints(kLHintsNormal, 0,0,6,2));
54
ec835ab5 55 fEventInfo = new TGTextView(f, 200, 300);
319f3084 56 f->AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
57
58 AddFrame(f, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
59 }
5655e9ce 60}
61
62/******************************************************************************/
63
80547f2d 64//______________________________________________________________________________
5655e9ce 65void AliEveEventManagerEditor::SetModel(TObject* obj)
66{
67 // Set model object.
68
69 fM = dynamic_cast<AliEveEventManager*>(obj);
70
12365217 71 fEventInfo->LoadBuffer(fM->GetEventInfoVertical());
5655e9ce 72}
73
74/******************************************************************************/
75
319f3084 76//______________________________________________________________________________
77void AliEveEventManagerEditor::DoNextEvent()
78{
79 // Load next event
ca49b003 80
80547f2d 81 fM->NextEvent();
ca49b003 82}
f76c9e9b 83
84
80547f2d 85//==============================================================================
f76c9e9b 86// AliEveEventManagerWindow
80547f2d 87//==============================================================================
f76c9e9b 88
89//______________________________________________________________________________
90//
91// Horizontal GUI for AliEveEventManager, to be placed in the
92// bottom part of ROOT browser.
93
94ClassImp(AliEveEventManagerWindow)
95
96AliEveEventManagerWindow::AliEveEventManagerWindow() :
12365217 97 TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame),
80547f2d 98 fFirstEvent (0),
99 fPrevEvent (0),
100 fNextEvent (0),
101 fLastEvent (0),
102 fRefresh (0),
ecb84424 103 fTrigger (0),
80547f2d 104 fEventId (0),
105 fInfoLabel (0),
106 fAutoLoad (0),
107 fAutoLoadTime (0),
108 fEventInfo (0)
f76c9e9b 109{
110 // Constructor.
111
488869c1 112 const TString cls("AliEveEventManagerWindow");
80547f2d 113 TGTextButton *b = 0;
f76c9e9b 114 {
115 Int_t width = 50;
116
117 TGHorizontalFrame* f = new TGHorizontalFrame(this);
80547f2d 118 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
119
120 fFirstEvent = b = MkTxtButton(f, "First", width);
121 b->Connect("Clicked()", cls, this, "DoFirstEvent()");
122 fPrevEvent = b = MkTxtButton(f, "Prev", width);
123 b->Connect("Clicked()", cls, this, "DoPrevEvent()");
f76c9e9b 124
125 fEventId = new TGNumberEntry(f, 0, 5, -1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
126 TGNumberFormat::kNELLimitMinMax, 0, 10000);
127 f->AddFrame(fEventId, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
80547f2d 128 fEventId->Connect("ValueSet(Long_t)", cls, this, "DoSetEvent()");
f76c9e9b 129 fInfoLabel = new TGLabel(f);
130 f->AddFrame(fInfoLabel, new TGLayoutHints(kLHintsNormal, 5, 10, 4, 0));
131
80547f2d 132 fNextEvent = b = MkTxtButton(f, "Next", width);
133 b->Connect("Clicked()", cls, this, "DoNextEvent()");
134 fLastEvent = b = MkTxtButton(f, "Last", width);
135 b->Connect("Clicked()", cls, this, "DoLastEvent()");
f76c9e9b 136
80547f2d 137 MkLabel(f, "||", 0, 8, 8);
138
139 fRefresh = b = MkTxtButton(f, "Refresh", width + 8);
140 b->Connect("Clicked()",cls, this, "DoRefresh()");
141
142 MkLabel(f, "||", 0, 8, 8);
143
144 fAutoLoad = new TGCheckButton(f, "Autoload");
145 f->AddFrame(fAutoLoad, new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0));
146 fAutoLoad->SetToolTipText("Automatic event loading.");
147 fAutoLoad->Connect("Toggled(Bool_t)", cls, this, "DoSetAutoLoad()");
148
149 fAutoLoadTime = new TEveGValuator(f, "Time: ", 110, 0);
ecb84424 150 f->AddFrame(fAutoLoadTime);
80547f2d 151 fAutoLoadTime->SetShowSlider(kFALSE);
152 fAutoLoadTime->SetNELength(4);
153 fAutoLoadTime->Build();
154 fAutoLoadTime->SetLimits(0, 1000);
155 fAutoLoadTime->SetToolTip("Automatic event loading time in seconds.");
156 fAutoLoadTime->Connect("ValueSet(Double_t)", cls, this, "DoSetAutoLoadTime()");
ecb84424 157
158 MkLabel(f, "||", 0, 8, 8);
159
160 MkLabel(f, "TRG select:", 0, 0, 4, 4);
161 fTrigger = new TGComboBox(f);
162 f->AddFrame(fTrigger, new TGLayoutHints(kLHintsNormal));
163 fTrigger->Resize(75,20);
164 //fTrigger->EnableTextInput(kTRUE);
165 fTrigger->Connect("Selected(const char*)", cls, this, "DoSetTriggerType(const char*)");
12365217 166 }
167
80547f2d 168 fEventInfo = new TGTextView(this, 400, 600);
169 AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
170
171 gAliEveEvent->Connect("NewEventLoaded()", cls, this, "Update()");
f76c9e9b 172
173 SetCleanup(kDeepCleanup);
174 Layout();
175 MapSubwindows();
176 MapWindow();
177}
178
179//______________________________________________________________________________
180AliEveEventManagerWindow::~AliEveEventManagerWindow()
181{
182 // Destructor.
183
184 gAliEveEvent->Disconnect("NewEventLoaded()", this);
185}
186
187//______________________________________________________________________________
188void AliEveEventManagerWindow::DoFirstEvent()
189{
190 // Load previous event
191 gAliEveEvent->GotoEvent(0);
192}
193
194//______________________________________________________________________________
195void AliEveEventManagerWindow::DoPrevEvent()
196{
197 // Load previous event
198 gAliEveEvent->PrevEvent();
199}
200
201//______________________________________________________________________________
202void AliEveEventManagerWindow::DoNextEvent()
203{
204 // Load next event
205 gAliEveEvent->NextEvent();
206}
207
208//______________________________________________________________________________
209void AliEveEventManagerWindow::DoLastEvent()
210{
211 // Load previous event
212 gAliEveEvent->GotoEvent(-1);
213}
214
215//______________________________________________________________________________
216void AliEveEventManagerWindow::DoSetEvent()
217{
218 // Set current event
219 gAliEveEvent->GotoEvent((Int_t) fEventId->GetNumber());
220}
221
80547f2d 222//______________________________________________________________________________
223void AliEveEventManagerWindow::DoRefresh()
224{
225 // Refresh event status.
226
227 Int_t ev = gAliEveEvent->GetEventId();
228 gAliEveEvent->Close();
229 gAliEveEvent->Open();
230 gAliEveEvent->GotoEvent(ev);
231}
232
233//______________________________________________________________________________
234void AliEveEventManagerWindow::DoSetAutoLoad()
235{
236 // Set the auto-load flag
237
238 gAliEveEvent->SetAutoLoad(fAutoLoad->IsOn());
239 Update();
240}
241
242//______________________________________________________________________________
243void AliEveEventManagerWindow::DoSetAutoLoadTime()
244{
245 // Set the auto-load time in seconds
246
247 gAliEveEvent->SetAutoLoadTime(fAutoLoadTime->GetValue());
80547f2d 248}
249
ecb84424 250//______________________________________________________________________________
251void AliEveEventManagerWindow::DoSetTriggerType(const char* type)
252{
253 // Slot for setting trigger type.
254
255 TString typestr = type;
256 if (typestr=="")
257 {
258 gAliEveEvent->SetSelectOnTriggerType(kFALSE);
259 }
260 else
261 {
262 gAliEveEvent->SetTriggerType( typestr );
263 gAliEveEvent->SetSelectOnTriggerType(kTRUE);
264 }
265}
266
f76c9e9b 267//______________________________________________________________________________
268void AliEveEventManagerWindow::Update()
269{
ecb84424 270 // Update current event, number of available events, list of active triggers
f76c9e9b 271
80547f2d 272 Bool_t autoLoad = gAliEveEvent->GetAutoLoad();
273 Bool_t extCtrl = gAliEveEvent->IsUnderExternalControl();
274 Bool_t evNavOn = !autoLoad && !extCtrl;
275
276 fFirstEvent->SetEnabled(evNavOn);
277 fPrevEvent ->SetEnabled(evNavOn);
278 fLastEvent ->SetEnabled(evNavOn);
279 fNextEvent ->SetEnabled(!autoLoad);
280 fRefresh ->SetEnabled(evNavOn);
281
f76c9e9b 282 fEventId->SetNumber(gAliEveEvent->GetEventId());
80547f2d 283 fEventId->SetState(evNavOn);
f76c9e9b 284 fInfoLabel->SetText(Form("/ %d", gAliEveEvent->GetMaxEventId()));
12365217 285
80547f2d 286 // fAutoLoadTime->SetEnabled(gAliEveEvent->GetAutoLoad());
287 fAutoLoad->SetState(gAliEveEvent->GetAutoLoad() ? kButtonDown : kButtonUp);
288 fAutoLoadTime->SetValue(gAliEveEvent->GetAutoLoadTime());
289
12365217 290 fEventInfo->LoadBuffer(gAliEveEvent->GetEventInfoHorizontal());
291
ecb84424 292 SetupTriggerSelect();
293
f76c9e9b 294 Layout();
295}
80547f2d 296
297//------------------------------------------------------------------------------
298// Protected methods
299//------------------------------------------------------------------------------
300
301//______________________________________________________________________________
302TGTextButton* AliEveEventManagerWindow::MkTxtButton(TGCompositeFrame* p,
303 const char* txt, Int_t width,
304 Int_t lo, Int_t ro, Int_t to, Int_t bo)
305{
306 // Create a standard button.
307 // If width is not zero, the fixed-width flag is set.
308
309 TGTextButton* b = new TGTextButton(p, txt);
310 if (width > 0) {
311 b->SetWidth(width);
312 b->ChangeOptions(b->GetOptions() | kFixedWidth);
313 }
314 p->AddFrame(b, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
315 return b;
316}
317
318//______________________________________________________________________________
319TGLabel* AliEveEventManagerWindow::MkLabel(TGCompositeFrame* p,
320 const char* txt, Int_t width,
321 Int_t lo, Int_t ro, Int_t to, Int_t bo)
322{
323 // Create a standard button.
324 // If width is not zero, the fixed-width flag is set.
325
326 TGLabel* l = new TGLabel(p, txt);
327 if (width > 0) {
328 l->SetWidth(width);
329 l->ChangeOptions(l->GetOptions() | kFixedWidth);
330 }
331 p->AddFrame(l, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
332 return l;
333}
ecb84424 334
335void AliEveEventManagerWindow::SetupTriggerSelect()
336{
77e5986c 337 // Do nothing if already enabled.
338 if (fTrigger->GetNumberOfEntries() > 0)
339 return;
ecb84424 340
77e5986c 341 AliESDEvent* esd = gAliEveEvent->GetESD();
342 if (esd && gAliEveEvent->GetESDFile() != 0)
ecb84424 343 {
344 TString activetrg = esd->GetESDRun()->GetActiveTriggerClasses(); //Get list of active classes
345 TObjArray* activetrgarr = activetrg.Tokenize(" "); //break up the classes string, space as separator
346 Int_t entries = activetrgarr->GetEntries(); //how many triggerclasses
347 TString entry; //to hold the triger class name
348 TObjString* entryobj;
349 if (entries == 0)
350 {
351 fTrigger->SetEnabled(kFALSE); //no trigger classes
352 }
353 else
354 {
355 fTrigger->RemoveAll(); //some initial cleanup
356 fTrigger->SetEnabled(kTRUE); //no trigger classes
357 fTrigger->AddEntry("",-1); //first entry empty - select to not filter by trigger
358 for (Int_t i=0;i<entries;i++)
359 {
360 entryobj = (TObjString*)activetrgarr->At(i);
361 entry = entryobj->GetString();
362 fTrigger->AddEntry(entry.Data(), i);
363 }
364 }
365 fTrigger->Select(-1, kTRUE); //set default no filtering and emit
77e5986c 366 fTrigger->SetEnabled(kTRUE);
ecb84424 367 }
368 else
369 {
370 fTrigger->SetEnabled(kFALSE);
371 }
372}
373