2 // Author: Matevz Tadel 2007
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 **************************************************************************/
10 #include "AliEveEventManagerEditor.h"
11 #include "AliEveEventManager.h"
12 #include "AliEveConfigManager.h"
14 #include <AliESDEvent.h>
16 #include <TVirtualPad.h>
19 #include <TEveGValuators.h>
21 #include <TGTextView.h>
24 #include "Riostream.h"
27 #include "AliStorageAdministratorPanelListEvents.h"
28 #include "AliStorageAdministratorPanelMarkEvent.h"
31 //______________________________________________________________________________
32 // GUI editor for AliEveEventManager.
40 ClassImp(AliEveEventManagerEditor)
42 //______________________________________________________________________________
43 AliEveEventManagerEditor::AliEveEventManagerEditor(const TGWindow *p, Int_t width, Int_t height,
44 UInt_t options, Pixel_t back) :
45 TGedFrame(p, width, height, options | kVerticalFrame, back),
52 MakeTitle("AliEveEventManager");
55 TGHorizontalFrame* f = new TGHorizontalFrame(this);
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()");
63 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 8,8,8,0));
66 TGVerticalFrame* f = new TGVerticalFrame(this);
68 TGLabel *eventInfoLabel = new TGLabel(f, "Event Information:");
69 f->AddFrame(eventInfoLabel, new TGLayoutHints(kLHintsNormal, 0,0,6,2));
71 fEventInfo = new TGTextView(f, 200, 300);
72 f->AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
74 AddFrame(f, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
78 /******************************************************************************/
80 //______________________________________________________________________________
81 void AliEveEventManagerEditor::SetModel(TObject* obj)
85 fM = static_cast<AliEveEventManager*>(obj);
87 fEventInfo->LoadBuffer(fM->GetEventInfoVertical());
90 /******************************************************************************/
92 //______________________________________________________________________________
93 void AliEveEventManagerEditor::DumpEventInfo()
95 // Dump event-info into event_info.txt.
96 // The info is appended into the file.
98 ofstream f("event_info.txt", ios::out | ios::app);
100 f << "================================================================================\n\n";
101 f << fM->GetEventInfoHorizontal() << std::endl << std::endl;
107 //==============================================================================
108 // AliEveEventManagerWindow
109 //==============================================================================
111 //______________________________________________________________________________
113 // Horizontal GUI for AliEveEventManager, to be placed in the
114 // bottom part of ROOT browser.
116 ClassImp(AliEveEventManagerWindow)
118 AliEveEventManagerWindow::AliEveEventManagerWindow(AliEveEventManager* mgr) :
119 TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame),
136 const TString cls("AliEveEventManagerWindow");
141 TGHorizontalFrame* f = new TGHorizontalFrame(this);
142 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
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()");
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));
152 fEventId->Connect("ValueSet(Long_t)", cls, this, "DoSetEvent()");
153 fInfoLabel = new TGLabel(f);
154 f->AddFrame(fInfoLabel, new TGLayoutHints(kLHintsNormal, 5, 10, 4, 0));
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()");
160 fMarkEvent = b = MkTxtButton(f, "Mark", width);
161 b->Connect("Clicked()", cls, this, "DoMarkEvent()");
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()");
168 MkLabel(f, "||", 0, 8, 8);
170 fRefresh = b = MkTxtButton(f, "Refresh", width + 8);
171 b->Connect("Clicked()",cls, this, "DoRefresh()");
173 MkLabel(f, "||", 0, 8, 8);
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()");
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()");
185 fAutoLoadTime = new TEveGValuator(f, "Time: ", 110, 0);
186 f->AddFrame(fAutoLoadTime);
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()");
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()");
201 fStorageStatus = MkLabel(f,"Storage: Waiting",0,8,8);
202 fEventServerStatus = MkLabel(f,"Event Server: Waiting",0,10,10);
206 fEventInfo = new TGTextView(this, 400, 600);
207 AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
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)");
214 SetCleanup(kDeepCleanup);
220 //______________________________________________________________________________
221 AliEveEventManagerWindow::~AliEveEventManagerWindow()
225 fM->Disconnect("NewEventLoaded()", this);
228 //______________________________________________________________________________
229 void AliEveEventManagerWindow::DoFirstEvent()
231 // Load previous event
235 //______________________________________________________________________________
236 void AliEveEventManagerWindow::DoPrevEvent()
238 // Load previous event
240 if (fM->IsOnlineMode()) {
244 fM->GotoEvent((Int_t) fEventId->GetNumber()-1);
250 //______________________________________________________________________________
251 void AliEveEventManagerWindow::DoNextEvent()
255 if (fM->IsOnlineMode()) {
256 cout<<"next event, online node"<<endl;
260 cout<<"next event, offline mode"<<endl;
261 fM->GotoEvent((Int_t) fEventId->GetNumber()+1);
265 //______________________________________________________________________________
266 void AliEveEventManagerWindow::DoLastEvent()
268 // Load previous event
272 //______________________________________________________________________________
273 void AliEveEventManagerWindow::DoMarkEvent()
275 // Mark current event
276 fM->MarkCurrentEvent();
279 //______________________________________________________________________________
280 void AliEveEventManagerWindow::DoRestartReco()
282 // Kill reconstruction server
283 gSystem->Exec("ssh -n -f edis@pcald39fix \"killall alieventserver\"");
286 void AliEveEventManagerWindow::DoRestartManager()
288 // Kill storage manager
289 gSystem->Exec("ssh -n -f edis@pcald39fix \"killall alistorage\"");
292 //______________________________________________________________________________
293 void AliEveEventManagerWindow::DoSetEvent()
296 fM->GotoEvent((Int_t) fEventId->GetNumber());
299 //______________________________________________________________________________
300 void AliEveEventManagerWindow::DoRefresh()
302 // Refresh event status.
304 Int_t ev = fM->GetEventId();
310 //______________________________________________________________________________
311 void AliEveEventManagerWindow::DoSetAutoLoad()
313 // Set the auto-load flag
315 fM->SetAutoLoad(fAutoLoad->IsOn());
316 Update(fM->NewEventAvailable());
319 //______________________________________________________________________________
320 void AliEveEventManagerWindow::DoSetLoopMarked()
322 // Set the auto-load flag
323 fM->SetLoopMarked(fLoopMarked->IsOn());
324 // Update(fM->NewEventAvailable());
327 //______________________________________________________________________________
328 void AliEveEventManagerWindow::DoSetAutoLoadTime()
330 // Set the auto-load time in seconds
332 fM->SetAutoLoadTime(fAutoLoadTime->GetValue());
335 //______________________________________________________________________________
336 void AliEveEventManagerWindow::DoSetTrigSel()
338 // Set the trigger selection
340 fM->SetTrigSel(fTrigSel->GetSelectedEntry()->EntryId());
343 //______________________________________________________________________________
344 void AliEveEventManagerWindow::Update(int state)
347 Bool_t autoLoad = fM->GetAutoLoad();
348 Bool_t extCtrl = fM->IsUnderExternalControl();
349 Bool_t evNavOn = !autoLoad && !extCtrl;
353 AliESDEvent* esd = fM->GetESD();
354 AliStorageAdministratorPanelListEvents* listEventsTab = AliStorageAdministratorPanelListEvents::GetInstance();
355 AliEveConfigManager *configManager = AliEveConfigManager::GetMaster();
357 if (!fM->IsOnlineMode()) {
359 listEventsTab->SetOfflineMode(kTRUE);
361 fFirstEvent->SetEnabled(!autoLoad);
362 fPrevEvent ->SetEnabled(!autoLoad);
363 fLastEvent ->SetEnabled(!autoLoad);
364 fNextEvent ->SetEnabled(!autoLoad);
365 fMarkEvent ->SetEnabled(kFALSE);
367 fInfoLabel->SetText(Form("/ %d", fM->GetMaxEventId()));
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()));
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);
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);
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);
410 fRefresh ->SetEnabled(evNavOn);
412 fEventId->SetNumber(fM->GetEventId());
413 fEventId->SetState(evNavOn);
414 // fInfoLabel->SetText(Form("/ %d", fM->GetMaxEventId()));
416 fAutoLoad->SetState(fM->GetAutoLoad() ? kButtonDown : kButtonUp);
417 fAutoLoadTime->SetValue(fM->GetAutoLoadTime());
419 // Loop over active trigger classes
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);
430 if (!fTrigSel->FindEntry(trigName.Data()))
431 fTrigSel->AddEntry(trigName.Data(),iTrig);
434 fTrigSel->SetEnabled(!evNavOn);
436 fEventInfo->LoadBuffer(fM->GetEventInfoHorizontal());
442 void AliEveEventManagerWindow::StorageManagerChangedState(int state)
446 Bool_t autoLoad = fM->GetAutoLoad();
447 AliStorageAdministratorPanelListEvents* listEventsTab = AliStorageAdministratorPanelListEvents::GetInstance();
448 AliEveConfigManager *configManager = AliEveConfigManager::GetMaster();
450 if (fM->IsOnlineMode()) {
453 fStorageStatus->SetText("Storage: DOWN");
454 fMarkEvent->SetEnabled(kFALSE);
455 fNextEvent->SetEnabled(kFALSE);
456 fLastEvent->SetEnabled(!autoLoad);
457 fPrevEvent->SetEnabled(kFALSE);
458 fFirstEvent->SetEnabled(kFALSE);
459 listEventsTab->SetOfflineMode(kTRUE);
460 fEventId->SetState(kFALSE);
464 listEventsTab->SetOfflineMode(kFALSE);
466 fStorageStatus->SetText("Storage: OK");
467 fMarkEvent->SetEnabled(kTRUE);
468 fNextEvent->SetEnabled(!autoLoad);
469 fLastEvent->SetEnabled(!autoLoad);
470 fPrevEvent->SetEnabled(!autoLoad);
471 fFirstEvent->SetEnabled(!autoLoad);
472 fEventId->SetState(!autoLoad);
478 //------------------------------------------------------------------------------
480 //------------------------------------------------------------------------------
482 //______________________________________________________________________________
483 TGTextButton* AliEveEventManagerWindow::MkTxtButton(TGCompositeFrame* p,
484 const char* txt, Int_t width,
485 Int_t lo, Int_t ro, Int_t to, Int_t bo)
487 // Create a standard button.
488 // If width is not zero, the fixed-width flag is set.
490 TGTextButton* b = new TGTextButton(p, txt);
493 b->ChangeOptions(b->GetOptions() | kFixedWidth);
495 p->AddFrame(b, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
499 //______________________________________________________________________________
500 TGLabel* AliEveEventManagerWindow::MkLabel(TGCompositeFrame* p,
501 const char* txt, Int_t width,
502 Int_t lo, Int_t ro, Int_t to, Int_t bo)
504 // Create a standard button.
505 // If width is not zero, the fixed-width flag is set.
507 TGLabel* l = new TGLabel(p, txt);
510 l->ChangeOptions(l->GetOptions() | kFixedWidth);
512 p->AddFrame(l, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));