]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/EveBase/AliEveEventManagerEditor.cxx
Fixed bug in AliEveEventManager causing frequent crashes. Fixed bug in Storage Manage...
[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"
01ca7d6f 12#include "AliEveConfigManager.h"
5655e9ce 13
b3b7b8d3 14#include <AliESDEvent.h>
15
16#include <TVirtualPad.h>
5655e9ce 17#include "TColor.h"
18
319f3084 19#include <TEveGValuators.h>
20#include <TGButton.h>
21#include <TGTextView.h>
22#include <TGLabel.h>
5655e9ce 23
fa6aa785 24#include "Riostream.h"
25
01ca7d6f 26#ifdef ZMQ
27#include "AliStorageAdministratorPanelListEvents.h"
28#include "AliStorageAdministratorPanelMarkEvent.h"
29#endif
30
5655e9ce 31//______________________________________________________________________________
32// GUI editor for AliEveEventManager.
33//
34
f65f2d99 35using std::ofstream;
36using std::ios;
66f33767 37using std::cout;
38using std::endl;
39
5655e9ce 40ClassImp(AliEveEventManagerEditor)
41
42//______________________________________________________________________________
43AliEveEventManagerEditor::AliEveEventManagerEditor(const TGWindow *p, Int_t width, Int_t height,
80547f2d 44 UInt_t options, Pixel_t back) :
5655e9ce 45 TGedFrame(p, width, height, options | kVerticalFrame, back),
319f3084 46 fM(0),
fa6aa785 47 fDumpEventInfo(0),
319f3084 48 fEventInfo(0)
5655e9ce 49{
50 // Constructor.
51
52 MakeTitle("AliEveEventManager");
53
319f3084 54 {
55 TGHorizontalFrame* f = new TGHorizontalFrame(this);
fa6aa785 56 fDumpEventInfo = new TGTextButton(f, "Dump Event Info");
57 fDumpEventInfo->SetToolTipText("Append information about current event to event_info.txt file.");
58 fDumpEventInfo->SetWidth(120);
59 fDumpEventInfo->ChangeOptions(fDumpEventInfo->GetOptions() | kFixedWidth);
60 f->AddFrame(fDumpEventInfo, new TGLayoutHints(kLHintsNormal, 4,0,0,0));
61 fDumpEventInfo->Connect("Clicked()",
62 "AliEveEventManagerEditor", this, "DumpEventInfo()");
319f3084 63 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 8,8,8,0));
64 }
319f3084 65 {
66 TGVerticalFrame* f = new TGVerticalFrame(this);
67
68 TGLabel *eventInfoLabel = new TGLabel(f, "Event Information:");
69 f->AddFrame(eventInfoLabel, new TGLayoutHints(kLHintsNormal, 0,0,6,2));
70
ec835ab5 71 fEventInfo = new TGTextView(f, 200, 300);
319f3084 72 f->AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
73
74 AddFrame(f, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
75 }
5655e9ce 76}
77
78/******************************************************************************/
79
80547f2d 80//______________________________________________________________________________
5655e9ce 81void AliEveEventManagerEditor::SetModel(TObject* obj)
82{
83 // Set model object.
84
04a6d27f 85 fM = static_cast<AliEveEventManager*>(obj);
5655e9ce 86
12365217 87 fEventInfo->LoadBuffer(fM->GetEventInfoVertical());
5655e9ce 88}
89
90/******************************************************************************/
91
319f3084 92//______________________________________________________________________________
fa6aa785 93void AliEveEventManagerEditor::DumpEventInfo()
319f3084 94{
fa6aa785 95 // Dump event-info into event_info.txt.
96 // The info is appended into the file.
97
98 ofstream f("event_info.txt", ios::out | ios::app);
99
100 f << "================================================================================\n\n";
101 f << fM->GetEventInfoHorizontal() << std::endl << std::endl;
ca49b003 102
fa6aa785 103 f.close();
ca49b003 104}
f76c9e9b 105
106
80547f2d 107//==============================================================================
f76c9e9b 108// AliEveEventManagerWindow
80547f2d 109//==============================================================================
f76c9e9b 110
111//______________________________________________________________________________
112//
113// Horizontal GUI for AliEveEventManager, to be placed in the
114// bottom part of ROOT browser.
115
116ClassImp(AliEveEventManagerWindow)
117
4d62585e 118AliEveEventManagerWindow::AliEveEventManagerWindow(AliEveEventManager* mgr) :
12365217 119 TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame),
4d62585e 120 fM (mgr),
80547f2d 121 fFirstEvent (0),
122 fPrevEvent (0),
123 fNextEvent (0),
124 fLastEvent (0),
125 fRefresh (0),
126 fEventId (0),
127 fInfoLabel (0),
128 fAutoLoad (0),
626a3158 129 fLoopMarked (0),
80547f2d 130 fAutoLoadTime (0),
969d3431 131 fTrigSel (0),
80547f2d 132 fEventInfo (0)
f76c9e9b 133{
134 // Constructor.
135
488869c1 136 const TString cls("AliEveEventManagerWindow");
80547f2d 137 TGTextButton *b = 0;
f76c9e9b 138 {
139 Int_t width = 50;
140
141 TGHorizontalFrame* f = new TGHorizontalFrame(this);
80547f2d 142 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
143
144 fFirstEvent = b = MkTxtButton(f, "First", width);
145 b->Connect("Clicked()", cls, this, "DoFirstEvent()");
146 fPrevEvent = b = MkTxtButton(f, "Prev", width);
147 b->Connect("Clicked()", cls, this, "DoPrevEvent()");
f76c9e9b 148
149 fEventId = new TGNumberEntry(f, 0, 5, -1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
150 TGNumberFormat::kNELLimitMinMax, 0, 10000);
151 f->AddFrame(fEventId, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
80547f2d 152 fEventId->Connect("ValueSet(Long_t)", cls, this, "DoSetEvent()");
f76c9e9b 153 fInfoLabel = new TGLabel(f);
154 f->AddFrame(fInfoLabel, new TGLayoutHints(kLHintsNormal, 5, 10, 4, 0));
155
80547f2d 156 fNextEvent = b = MkTxtButton(f, "Next", width);
157 b->Connect("Clicked()", cls, this, "DoNextEvent()");
158 fLastEvent = b = MkTxtButton(f, "Last", width);
159 b->Connect("Clicked()", cls, this, "DoLastEvent()");
164d3d29 160 fMarkEvent = b = MkTxtButton(f, "Mark", width);
161 b->Connect("Clicked()", cls, this, "DoMarkEvent()");
7f97b015 162 fRestartReco = b = MkTxtButton(f, "Restart reco", 2*width);
163 b->Connect("Clicked()", cls, this, "DoRestartReco()");
164 fRestartManager = b = MkTxtButton(f, "Restart manager", 2*width);
165 b->Connect("Clicked()", cls, this, "DoRestartManager()");
166
167
80547f2d 168 MkLabel(f, "||", 0, 8, 8);
169
170 fRefresh = b = MkTxtButton(f, "Refresh", width + 8);
171 b->Connect("Clicked()",cls, this, "DoRefresh()");
172
173 MkLabel(f, "||", 0, 8, 8);
174
175 fAutoLoad = new TGCheckButton(f, "Autoload");
176 f->AddFrame(fAutoLoad, new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0));
177 fAutoLoad->SetToolTipText("Automatic event loading.");
178 fAutoLoad->Connect("Toggled(Bool_t)", cls, this, "DoSetAutoLoad()");
179
626a3158 180 fLoopMarked = new TGCheckButton(f, "Loop Marked");
181 f->AddFrame(fLoopMarked, new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0));
182 fLoopMarked->SetToolTipText("Automatic marked events loading.");
183 fLoopMarked->Connect("Toggled(Bool_t)", cls, this, "DoSetLoopMarked()");
184
80547f2d 185 fAutoLoadTime = new TEveGValuator(f, "Time: ", 110, 0);
ecb84424 186 f->AddFrame(fAutoLoadTime);
80547f2d 187 fAutoLoadTime->SetShowSlider(kFALSE);
188 fAutoLoadTime->SetNELength(4);
189 fAutoLoadTime->Build();
190 fAutoLoadTime->SetLimits(0, 1000);
191 fAutoLoadTime->SetToolTip("Automatic event loading time in seconds.");
192 fAutoLoadTime->Connect("ValueSet(Double_t)", cls, this, "DoSetAutoLoadTime()");
ecb84424 193
969d3431 194 fTrigSel = new TGComboBox(f);
195 fTrigSel->Resize(4*width,b->GetDefaultHeight());
196 fTrigSel->AddEntry("No trigger selection",-1);
197 fTrigSel->Select(-1,kFALSE);
198 f->AddFrame(fTrigSel, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
199 fTrigSel->Connect("Selected(char*)", cls, this, "DoSetTrigSel()");
12365217 200
0790c3e6 201 fStorageStatus = MkLabel(f,"Storage: Waiting",0,8,8);
01ca7d6f 202 fEventServerStatus = MkLabel(f,"Event Server: Waiting",0,10,10);
0790c3e6 203
204 }
205
80547f2d 206 fEventInfo = new TGTextView(this, 400, 600);
207 AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
208
01ca7d6f 209 fM->Connect("NewEventLoaded()", cls, this, "Update(=1)");
210 fM->Connect("NoEventLoaded()", cls, this, "Update(=0)");
211 fM->Connect("StorageManagerOk()",cls,this,"StorageManagerChangedState(=1)");
212 fM->Connect("StorageManagerDown()",cls,this,"StorageManagerChangedState(=0)");
f76c9e9b 213
214 SetCleanup(kDeepCleanup);
215 Layout();
216 MapSubwindows();
217 MapWindow();
218}
219
220//______________________________________________________________________________
221AliEveEventManagerWindow::~AliEveEventManagerWindow()
222{
223 // Destructor.
224
4d62585e 225 fM->Disconnect("NewEventLoaded()", this);
f76c9e9b 226}
227
228//______________________________________________________________________________
229void AliEveEventManagerWindow::DoFirstEvent()
230{
231 // Load previous event
4d62585e 232 fM->GotoEvent(0);
f76c9e9b 233}
234
235//______________________________________________________________________________
236void AliEveEventManagerWindow::DoPrevEvent()
237{
238 // Load previous event
a410aca4 239 // fM->PrevEvent();
01ca7d6f 240 if (fM->IsOnlineMode()) {
241 fM->GotoEvent(1);
242 }
243 else {
244 fM->GotoEvent((Int_t) fEventId->GetNumber()-1);
245
246 }
a410aca4 247
f76c9e9b 248}
249
250//______________________________________________________________________________
251void AliEveEventManagerWindow::DoNextEvent()
252{
253 // Load next event
a410aca4 254 // fM->NextEvent();
01ca7d6f 255 if (fM->IsOnlineMode()) {
7f97b015 256 cout<<"next event, online node"<<endl;
01ca7d6f 257 fM->GotoEvent(2);
258 }
259 else {
7f97b015 260 cout<<"next event, offline mode"<<endl;
01ca7d6f 261 fM->GotoEvent((Int_t) fEventId->GetNumber()+1);
262 }
f76c9e9b 263}
264
265//______________________________________________________________________________
266void AliEveEventManagerWindow::DoLastEvent()
267{
268 // Load previous event
4d62585e 269 fM->GotoEvent(-1);
f76c9e9b 270}
271
164d3d29 272//______________________________________________________________________________
273void AliEveEventManagerWindow::DoMarkEvent()
274{
275 // Mark current event
276 fM->MarkCurrentEvent();
277}
278
7f97b015 279//______________________________________________________________________________
280void AliEveEventManagerWindow::DoRestartReco()
281{
282 // Kill reconstruction server
283 gSystem->Exec("ssh -n -f edis@pcald39fix \"killall alieventserver\"");
284}
285
286void AliEveEventManagerWindow::DoRestartManager()
287{
288 // Kill storage manager
289 gSystem->Exec("ssh -n -f edis@pcald39fix \"killall alistorage\"");
290}
291
f76c9e9b 292//______________________________________________________________________________
293void AliEveEventManagerWindow::DoSetEvent()
294{
295 // Set current event
4d62585e 296 fM->GotoEvent((Int_t) fEventId->GetNumber());
f76c9e9b 297}
298
80547f2d 299//______________________________________________________________________________
300void AliEveEventManagerWindow::DoRefresh()
301{
302 // Refresh event status.
303
4d62585e 304 Int_t ev = fM->GetEventId();
305 fM->Close();
306 fM->Open();
307 fM->GotoEvent(ev);
80547f2d 308}
309
310//______________________________________________________________________________
311void AliEveEventManagerWindow::DoSetAutoLoad()
312{
313 // Set the auto-load flag
314
4d62585e 315 fM->SetAutoLoad(fAutoLoad->IsOn());
01ca7d6f 316 Update(fM->NewEventAvailable());
80547f2d 317}
318
626a3158 319//______________________________________________________________________________
320void AliEveEventManagerWindow::DoSetLoopMarked()
321{
322 // Set the auto-load flag
323 fM->SetLoopMarked(fLoopMarked->IsOn());
324// Update(fM->NewEventAvailable());
325}
326
80547f2d 327//______________________________________________________________________________
328void AliEveEventManagerWindow::DoSetAutoLoadTime()
329{
330 // Set the auto-load time in seconds
331
4d62585e 332 fM->SetAutoLoadTime(fAutoLoadTime->GetValue());
80547f2d 333}
334
969d3431 335//______________________________________________________________________________
336void AliEveEventManagerWindow::DoSetTrigSel()
337{
338 // Set the trigger selection
339
340 fM->SetTrigSel(fTrigSel->GetSelectedEntry()->EntryId());
341}
342
f76c9e9b 343//______________________________________________________________________________
01ca7d6f 344void AliEveEventManagerWindow::Update(int state)
f76c9e9b 345{
f76c9e9b 346
4d62585e 347 Bool_t autoLoad = fM->GetAutoLoad();
348 Bool_t extCtrl = fM->IsUnderExternalControl();
80547f2d 349 Bool_t evNavOn = !autoLoad && !extCtrl;
350
e6194cd4 351#ifdef ZMQ
352
353 AliESDEvent* esd = fM->GetESD();
354 AliStorageAdministratorPanelListEvents* listEventsTab = AliStorageAdministratorPanelListEvents::GetInstance();
355 AliEveConfigManager *configManager = AliEveConfigManager::GetMaster();
356
01ca7d6f 357 if (!fM->IsOnlineMode()) {
358
359 listEventsTab->SetOfflineMode(kTRUE);
01ca7d6f 360
361 fFirstEvent->SetEnabled(!autoLoad);
362 fPrevEvent ->SetEnabled(!autoLoad);
363 fLastEvent ->SetEnabled(!autoLoad);
364 fNextEvent ->SetEnabled(!autoLoad);
365 fMarkEvent ->SetEnabled(kFALSE);
366
367 fInfoLabel->SetText(Form("/ %d", fM->GetMaxEventId()));
368
369 }
370 else if (1 == state && fStorageStatus->GetText()->Contains("DOWN")) {
371 fEventServerStatus->SetText("Event Server: OK");
372 fFirstEvent->SetEnabled(kFALSE);
373 fPrevEvent ->SetEnabled(kFALSE);
374 fLastEvent ->SetEnabled(!autoLoad);
375 fNextEvent ->SetEnabled(kFALSE);
376 fMarkEvent ->SetEnabled(kFALSE);
377 listEventsTab->SetOfflineMode(kTRUE);
378 fInfoLabel->SetText(Form("/ %d",fM->GetEventId()));
379 }
380 else if (0 == state && fStorageStatus->GetText()->Contains("DOWN")) {
381 fEventServerStatus->SetText("Event Server: Waiting");
382 fFirstEvent->SetEnabled(kFALSE);
383 fPrevEvent ->SetEnabled(kFALSE);
384 fLastEvent ->SetEnabled(!autoLoad);
385 fNextEvent ->SetEnabled(kFALSE);
386 fMarkEvent ->SetEnabled(kFALSE);
387 listEventsTab->SetOfflineMode(kTRUE);
388 }
389 else if (0 == state && fStorageStatus->GetText()->Contains("OK")) {
390 fEventServerStatus->SetText("Event Server: Waiting");
391 fFirstEvent->SetEnabled(!autoLoad);
392 fPrevEvent ->SetEnabled(!autoLoad);
393 fLastEvent ->SetEnabled(!autoLoad);
394 fNextEvent ->SetEnabled(!autoLoad);
395 fMarkEvent ->SetEnabled(kTRUE);
396 listEventsTab->SetOfflineMode(kFALSE);
397 }
398 else {
399 fEventServerStatus->SetText("Event Server: OK");
400 fFirstEvent->SetEnabled(!autoLoad);
401 fPrevEvent ->SetEnabled(!autoLoad);
402 fLastEvent ->SetEnabled(!autoLoad);
403 fNextEvent ->SetEnabled(!autoLoad);
404 fMarkEvent ->SetEnabled(kTRUE);
405 listEventsTab->SetOfflineMode(kFALSE);
406 }
e6194cd4 407#endif
01ca7d6f 408
409 if (1 == state) {
410 fRefresh ->SetEnabled(evNavOn);
411
412 fEventId->SetNumber(fM->GetEventId());
413 fEventId->SetState(evNavOn);
414 // fInfoLabel->SetText(Form("/ %d", fM->GetMaxEventId()));
415
416 fAutoLoad->SetState(fM->GetAutoLoad() ? kButtonDown : kButtonUp);
417 fAutoLoadTime->SetValue(fM->GetAutoLoadTime());
418
419 // Loop over active trigger classes
420 if (fM->GetESD()) {
421 for(Int_t iTrig = 0; iTrig < AliESDRun::kNTriggerClasses; iTrig++) {
422 TString trigName = fM->GetESD()->GetESDRun()->GetTriggerClass(iTrig);
423 if (trigName.IsNull()) {
424 if (fTrigSel->GetListBox()->GetEntry(iTrig)) {
425 if (fTrigSel->GetSelected() == iTrig) fTrigSel->Select(-1);
426 fTrigSel->RemoveEntry(iTrig);
427 }
428 continue;
969d3431 429 }
01ca7d6f 430 if (!fTrigSel->FindEntry(trigName.Data()))
431 fTrigSel->AddEntry(trigName.Data(),iTrig);
969d3431 432 }
969d3431 433 }
01ca7d6f 434 fTrigSel->SetEnabled(!evNavOn);
969d3431 435
efaef546 436// fEventInfo->LoadBuffer(fM->GetEventInfoHorizontal());
12365217 437
01ca7d6f 438 Layout();
439 }
f76c9e9b 440}
80547f2d 441
0790c3e6 442void AliEveEventManagerWindow::StorageManagerChangedState(int state)
443{
e6194cd4 444#ifdef ZMQ
445
01ca7d6f 446 Bool_t autoLoad = fM->GetAutoLoad();
447 AliStorageAdministratorPanelListEvents* listEventsTab = AliStorageAdministratorPanelListEvents::GetInstance();
448 AliEveConfigManager *configManager = AliEveConfigManager::GetMaster();
449
450 if (fM->IsOnlineMode()) {
0790c3e6 451 if (state == 0)
01ca7d6f 452 {
0790c3e6 453 fStorageStatus->SetText("Storage: DOWN");
01ca7d6f 454 fMarkEvent->SetEnabled(kFALSE);
455 fNextEvent->SetEnabled(kFALSE);
456 fLastEvent->SetEnabled(!autoLoad);
457 fPrevEvent->SetEnabled(kFALSE);
458 fFirstEvent->SetEnabled(kFALSE);
459 listEventsTab->SetOfflineMode(kTRUE);
01ca7d6f 460 fEventId->SetState(kFALSE);
461 }
0790c3e6 462 else if(state == 1)
01ca7d6f 463 {
464 listEventsTab->SetOfflineMode(kFALSE);
465
0790c3e6 466 fStorageStatus->SetText("Storage: OK");
01ca7d6f 467 fMarkEvent->SetEnabled(kTRUE);
468 fNextEvent->SetEnabled(!autoLoad);
469 fLastEvent->SetEnabled(!autoLoad);
470 fPrevEvent->SetEnabled(!autoLoad);
471 fFirstEvent->SetEnabled(!autoLoad);
472 fEventId->SetState(!autoLoad);
473 }
474 }
e6194cd4 475#endif
0790c3e6 476}
477
80547f2d 478//------------------------------------------------------------------------------
479// Protected methods
480//------------------------------------------------------------------------------
481
482//______________________________________________________________________________
483TGTextButton* AliEveEventManagerWindow::MkTxtButton(TGCompositeFrame* p,
484 const char* txt, Int_t width,
485 Int_t lo, Int_t ro, Int_t to, Int_t bo)
486{
487 // Create a standard button.
488 // If width is not zero, the fixed-width flag is set.
489
490 TGTextButton* b = new TGTextButton(p, txt);
491 if (width > 0) {
492 b->SetWidth(width);
493 b->ChangeOptions(b->GetOptions() | kFixedWidth);
494 }
495 p->AddFrame(b, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
496 return b;
497}
498
499//______________________________________________________________________________
500TGLabel* AliEveEventManagerWindow::MkLabel(TGCompositeFrame* p,
501 const char* txt, Int_t width,
502 Int_t lo, Int_t ro, Int_t to, Int_t bo)
503{
504 // Create a standard button.
505 // If width is not zero, the fixed-width flag is set.
506
507 TGLabel* l = new TGLabel(p, txt);
508 if (width > 0) {
509 l->SetWidth(width);
510 l->ChangeOptions(l->GetOptions() | kFixedWidth);
511 }
512 p->AddFrame(l, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
513 return l;
514}
ecb84424 515