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.
42 ClassImp(AliEveEventManagerEditor)
44 //______________________________________________________________________________
45 AliEveEventManagerEditor::AliEveEventManagerEditor(const TGWindow *p, Int_t width, Int_t height,
46 UInt_t options, Pixel_t back) :
47 TGedFrame(p, width, height, options | kVerticalFrame, back),
54 MakeTitle("AliEveEventManager");
57 TGHorizontalFrame* f = new TGHorizontalFrame(this);
58 fDumpEventInfo = new TGTextButton(f, "Dump Event Info");
59 fDumpEventInfo->SetToolTipText("Append information about current event to event_info.txt file.");
60 fDumpEventInfo->SetWidth(120);
61 fDumpEventInfo->ChangeOptions(fDumpEventInfo->GetOptions() | kFixedWidth);
62 f->AddFrame(fDumpEventInfo, new TGLayoutHints(kLHintsNormal, 4,0,0,0));
63 fDumpEventInfo->Connect("Clicked()",
64 "AliEveEventManagerEditor", this, "DumpEventInfo()");
65 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 8,8,8,0));
68 TGVerticalFrame* f = new TGVerticalFrame(this);
70 TGLabel *eventInfoLabel = new TGLabel(f, "Event Information:");
71 f->AddFrame(eventInfoLabel, new TGLayoutHints(kLHintsNormal, 0,0,6,2));
73 fEventInfo = new TGTextView(f, 200, 300);
74 f->AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
76 AddFrame(f, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
80 /******************************************************************************/
82 //______________________________________________________________________________
83 void AliEveEventManagerEditor::SetModel(TObject* obj)
87 fM = static_cast<AliEveEventManager*>(obj);
89 fEventInfo->LoadBuffer(fM->GetEventInfoVertical());
92 /******************************************************************************/
94 //______________________________________________________________________________
95 void AliEveEventManagerEditor::DumpEventInfo()
97 // Dump event-info into event_info.txt.
98 // The info is appended into the file.
100 ofstream f("event_info.txt", ios::out | ios::app);
102 f << "================================================================================\n\n";
103 f << fM->GetEventInfoHorizontal() << std::endl << std::endl;
109 //==============================================================================
110 // AliEveEventManagerWindow
111 //==============================================================================
113 //______________________________________________________________________________
115 // Horizontal GUI for AliEveEventManager, to be placed in the
116 // bottom part of ROOT browser.
118 ClassImp(AliEveEventManagerWindow)
120 AliEveEventManagerWindow::AliEveEventManagerWindow(AliEveEventManager* mgr) :
121 TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame),
138 const TString cls("AliEveEventManagerWindow");
143 TGHorizontalFrame* f = new TGHorizontalFrame(this);
144 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
146 fFirstEvent = b = MkTxtButton(f, "First", width);
147 b->Connect("Clicked()", cls, this, "DoFirstEvent()");
148 fPrevEvent = b = MkTxtButton(f, "Prev", width);
149 b->Connect("Clicked()", cls, this, "DoPrevEvent()");
151 fEventId = new TGNumberEntry(f, 0, 5, -1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
152 TGNumberFormat::kNELLimitMinMax, 0, 10000);
153 f->AddFrame(fEventId, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
154 fEventId->Connect("ValueSet(Long_t)", cls, this, "DoSetEvent()");
155 fInfoLabel = new TGLabel(f);
156 f->AddFrame(fInfoLabel, new TGLayoutHints(kLHintsNormal, 5, 10, 4, 0));
158 fNextEvent = b = MkTxtButton(f, "Next", width);
159 b->Connect("Clicked()", cls, this, "DoNextEvent()");
160 fLastEvent = b = MkTxtButton(f, "Last", width);
161 b->Connect("Clicked()", cls, this, "DoLastEvent()");
162 fMarkEvent = b = MkTxtButton(f, "Mark", width);
163 b->Connect("Clicked()", cls, this, "DoMarkEvent()");
164 fRestartReco = b = MkTxtButton(f, "Restart reco", 2*width);
165 b->Connect("Clicked()", cls, this, "DoRestartReco()");
166 fRestartManager = b = MkTxtButton(f, "Restart manager", 2*width);
167 b->Connect("Clicked()", cls, this, "DoRestartManager()");
170 MkLabel(f, "||", 0, 8, 8);
172 fRefresh = b = MkTxtButton(f, "Refresh", width + 8);
173 b->Connect("Clicked()",cls, this, "DoRefresh()");
175 MkLabel(f, "||", 0, 8, 8);
177 fAutoLoad = new TGCheckButton(f, "Autoload");
178 f->AddFrame(fAutoLoad, new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0));
179 fAutoLoad->SetToolTipText("Automatic event loading.");
180 fAutoLoad->Connect("Toggled(Bool_t)", cls, this, "DoSetAutoLoad()");
182 fLoopMarked = new TGCheckButton(f, "Loop Marked");
183 f->AddFrame(fLoopMarked, new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0));
184 fLoopMarked->SetToolTipText("Automatic marked events loading.");
185 fLoopMarked->Connect("Toggled(Bool_t)", cls, this, "DoSetLoopMarked()");
187 fAutoLoadTime = new TEveGValuator(f, "Time: ", 110, 0);
188 f->AddFrame(fAutoLoadTime);
189 fAutoLoadTime->SetShowSlider(kFALSE);
190 fAutoLoadTime->SetNELength(4);
191 fAutoLoadTime->Build();
192 fAutoLoadTime->SetLimits(0, 1000);
193 fAutoLoadTime->SetToolTip("Automatic event loading time in seconds.");
194 fAutoLoadTime->Connect("ValueSet(Double_t)", cls, this, "DoSetAutoLoadTime()");
196 fTrigSel = new TGComboBox(f);
197 fTrigSel->Resize(4*width,b->GetDefaultHeight());
198 fTrigSel->AddEntry("No trigger selection",-1);
199 fTrigSel->Select(-1,kFALSE);
200 f->AddFrame(fTrigSel, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
201 fTrigSel->Connect("Selected(char*)", cls, this, "DoSetTrigSel()");
203 fStorageStatus = MkLabel(f,"Storage: Waiting",0,8,8);
204 fEventServerStatus = MkLabel(f,"Event Server: Waiting",0,10,10);
208 fEventInfo = new TGTextView(this, 400, 600);
209 AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
211 fM->Connect("NewEventLoaded()", cls, this, "Update(=1)");
212 fM->Connect("NoEventLoaded()", cls, this, "Update(=0)");
213 fM->Connect("StorageManagerOk()",cls,this,"StorageManagerChangedState(=1)");
214 fM->Connect("StorageManagerDown()",cls,this,"StorageManagerChangedState(=0)");
216 SetCleanup(kDeepCleanup);
222 //______________________________________________________________________________
223 AliEveEventManagerWindow::~AliEveEventManagerWindow()
227 fM->Disconnect("NewEventLoaded()", this);
230 //______________________________________________________________________________
231 void AliEveEventManagerWindow::DoFirstEvent()
233 // Load previous event
237 //______________________________________________________________________________
238 void AliEveEventManagerWindow::DoPrevEvent()
240 // Load previous event
242 if (fM->IsOnlineMode()) {
246 fM->GotoEvent((Int_t) fEventId->GetNumber()-1);
252 //______________________________________________________________________________
253 void AliEveEventManagerWindow::DoNextEvent()
257 if (fM->IsOnlineMode()) {
258 cout<<"next event, online node"<<endl;
262 cout<<"next event, offline mode"<<endl;
263 fM->GotoEvent((Int_t) fEventId->GetNumber()+1);
267 //______________________________________________________________________________
268 void AliEveEventManagerWindow::DoLastEvent()
270 // Load previous event
274 //______________________________________________________________________________
275 void AliEveEventManagerWindow::DoMarkEvent()
277 // Mark current event
278 fM->MarkCurrentEvent();
281 //______________________________________________________________________________
282 void AliEveEventManagerWindow::DoRestartReco()
284 ifstream configFile (GetConfigFilePath());
285 string username,hostname;
287 if (configFile.is_open())
291 while(configFile.good())
293 getline(configFile,line);
294 from = line.find("\"")+1;
295 to = line.find_last_of("\"");
296 if(line.find("EVENT_SERVER=")==0)
298 hostname=line.substr(from,to-from);
300 else if(line.find("EVENT_SERVER_USER=")==0)
302 username=line.substr(from,to-from);
305 if(configFile.eof()){configFile.clear();}
308 else{cout<<"Event Manager Editor -- Unable to open config file"<<endl;}
310 // Kill reconstruction server
311 gSystem->Exec(Form("ssh -n -f %s@%s \"killall alieventserver\"",username.c_str(),hostname.c_str()));
314 void AliEveEventManagerWindow::DoRestartManager()
316 ifstream configFile (GetConfigFilePath());
317 string username,hostname;
319 if (configFile.is_open())
323 while(configFile.good())
325 getline(configFile,line);
326 from = line.find("\"")+1;
327 to = line.find_last_of("\"");
328 if(line.find("STORAGE_SERVER=")==0)
330 hostname=line.substr(from,to-from);
332 else if(line.find("STORAGE_SERVER_USER=")==0)
334 username=line.substr(from,to-from);
337 if(configFile.eof()){configFile.clear();}
340 else{cout<<"Event Manager Editor -- Unable to open config file"<<endl;}
343 // Kill storage manager
344 gSystem->Exec(Form("ssh -n -f %s@%s \"killall alistorage\"",username.c_str(),hostname.c_str()));
347 //______________________________________________________________________________
348 void AliEveEventManagerWindow::DoSetEvent()
351 fM->GotoEvent((Int_t) fEventId->GetNumber());
354 //______________________________________________________________________________
355 void AliEveEventManagerWindow::DoRefresh()
357 // Refresh event status.
359 Int_t ev = fM->GetEventId();
365 //______________________________________________________________________________
366 void AliEveEventManagerWindow::DoSetAutoLoad()
368 // Set the auto-load flag
370 fM->SetAutoLoad(fAutoLoad->IsOn());
371 Update(fM->NewEventAvailable());
374 //______________________________________________________________________________
375 void AliEveEventManagerWindow::DoSetLoopMarked()
377 // Set the auto-load flag
378 fM->SetLoopMarked(fLoopMarked->IsOn());
379 // Update(fM->NewEventAvailable());
382 //______________________________________________________________________________
383 void AliEveEventManagerWindow::DoSetAutoLoadTime()
385 // Set the auto-load time in seconds
387 fM->SetAutoLoadTime(fAutoLoadTime->GetValue());
390 //______________________________________________________________________________
391 void AliEveEventManagerWindow::DoSetTrigSel()
393 // Set the trigger selection
395 fM->SetTrigSel(fTrigSel->GetSelectedEntry()->EntryId());
398 //______________________________________________________________________________
399 void AliEveEventManagerWindow::Update(int state)
402 Bool_t autoLoad = fM->GetAutoLoad();
403 // Bool_t extCtrl = fM->IsUnderExternalControl();
404 Bool_t evNavOn = !autoLoad;// && !extCtrl;
408 AliESDEvent* esd = fM->GetESD();
409 AliStorageAdministratorPanelListEvents* listEventsTab = AliStorageAdministratorPanelListEvents::GetInstance();
410 AliEveConfigManager *configManager = AliEveConfigManager::GetMaster();
412 if (!fM->IsOnlineMode()) {
414 listEventsTab->SetOfflineMode(kTRUE);
416 fFirstEvent->SetEnabled(!autoLoad);
417 fPrevEvent ->SetEnabled(!autoLoad);
418 fLastEvent ->SetEnabled(!autoLoad);
419 fNextEvent ->SetEnabled(!autoLoad);
420 fMarkEvent ->SetEnabled(kFALSE);
422 fInfoLabel->SetText(Form("/ %d", fM->GetMaxEventId()));
425 else if (1 == state && fStorageStatus->GetText()->Contains("DOWN")) {
426 fEventServerStatus->SetText("Event Server: OK");
427 fFirstEvent->SetEnabled(kFALSE);
428 fPrevEvent ->SetEnabled(kFALSE);
429 fLastEvent ->SetEnabled(!autoLoad);
430 fNextEvent ->SetEnabled(kFALSE);
431 fMarkEvent ->SetEnabled(kFALSE);
432 listEventsTab->SetOfflineMode(kTRUE);
433 fInfoLabel->SetText(Form("/ %d",fM->GetEventId()));
435 else if (0 == state && fStorageStatus->GetText()->Contains("DOWN")) {
436 fEventServerStatus->SetText("Event Server: Waiting");
437 fFirstEvent->SetEnabled(kFALSE);
438 fPrevEvent ->SetEnabled(kFALSE);
439 fLastEvent ->SetEnabled(!autoLoad);
440 fNextEvent ->SetEnabled(kFALSE);
441 fMarkEvent ->SetEnabled(kFALSE);
442 listEventsTab->SetOfflineMode(kTRUE);
444 else if (0 == state && fStorageStatus->GetText()->Contains("OK")) {
445 fEventServerStatus->SetText("Event Server: Waiting");
446 fFirstEvent->SetEnabled(!autoLoad);
447 fPrevEvent ->SetEnabled(!autoLoad);
448 fLastEvent ->SetEnabled(!autoLoad);
449 fNextEvent ->SetEnabled(!autoLoad);
450 fMarkEvent ->SetEnabled(kTRUE);
451 listEventsTab->SetOfflineMode(kFALSE);
454 fEventServerStatus->SetText("Event Server: OK");
455 fFirstEvent->SetEnabled(!autoLoad);
456 fPrevEvent ->SetEnabled(!autoLoad);
457 fLastEvent ->SetEnabled(!autoLoad);
458 fNextEvent ->SetEnabled(!autoLoad);
459 fMarkEvent ->SetEnabled(kTRUE);
460 listEventsTab->SetOfflineMode(kFALSE);
465 fRefresh ->SetEnabled(evNavOn);
467 fEventId->SetNumber(fM->GetEventId());
468 fEventId->SetState(evNavOn);
469 // fInfoLabel->SetText(Form("/ %d", fM->GetMaxEventId()));
471 fAutoLoad->SetState(fM->GetAutoLoad() ? kButtonDown : kButtonUp);
472 fAutoLoadTime->SetValue(fM->GetAutoLoadTime());
474 // Loop over active trigger classes
476 for(Int_t iTrig = 0; iTrig < AliESDRun::kNTriggerClasses; iTrig++) {
477 TString trigName = fM->GetESD()->GetESDRun()->GetTriggerClass(iTrig);
478 if (trigName.IsNull()) {
479 if (fTrigSel->GetListBox()->GetEntry(iTrig)) {
480 if (fTrigSel->GetSelected() == iTrig) fTrigSel->Select(-1);
481 fTrigSel->RemoveEntry(iTrig);
485 if (!fTrigSel->FindEntry(trigName.Data()))
486 fTrigSel->AddEntry(trigName.Data(),iTrig);
489 fTrigSel->SetEnabled(!evNavOn);
491 // fEventInfo->LoadBuffer(fM->GetEventInfoHorizontal());
497 void AliEveEventManagerWindow::StorageManagerChangedState(int state)
501 Bool_t autoLoad = fM->GetAutoLoad();
502 AliStorageAdministratorPanelListEvents* listEventsTab = AliStorageAdministratorPanelListEvents::GetInstance();
503 AliEveConfigManager *configManager = AliEveConfigManager::GetMaster();
505 if (fM->IsOnlineMode()) {
508 fStorageStatus->SetText("Storage: DOWN");
509 fMarkEvent->SetEnabled(kFALSE);
510 fNextEvent->SetEnabled(kFALSE);
511 fLastEvent->SetEnabled(!autoLoad);
512 fPrevEvent->SetEnabled(kFALSE);
513 fFirstEvent->SetEnabled(kFALSE);
514 listEventsTab->SetOfflineMode(kTRUE);
515 fEventId->SetState(kFALSE);
519 listEventsTab->SetOfflineMode(kFALSE);
521 fStorageStatus->SetText("Storage: OK");
522 fMarkEvent->SetEnabled(kTRUE);
523 fNextEvent->SetEnabled(!autoLoad);
524 fLastEvent->SetEnabled(!autoLoad);
525 fPrevEvent->SetEnabled(!autoLoad);
526 fFirstEvent->SetEnabled(!autoLoad);
527 fEventId->SetState(!autoLoad);
533 //------------------------------------------------------------------------------
535 //------------------------------------------------------------------------------
537 //______________________________________________________________________________
538 TGTextButton* AliEveEventManagerWindow::MkTxtButton(TGCompositeFrame* p,
539 const char* txt, Int_t width,
540 Int_t lo, Int_t ro, Int_t to, Int_t bo)
542 // Create a standard button.
543 // If width is not zero, the fixed-width flag is set.
545 TGTextButton* b = new TGTextButton(p, txt);
548 b->ChangeOptions(b->GetOptions() | kFixedWidth);
550 p->AddFrame(b, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
554 //______________________________________________________________________________
555 TGLabel* AliEveEventManagerWindow::MkLabel(TGCompositeFrame* p,
556 const char* txt, Int_t width,
557 Int_t lo, Int_t ro, Int_t to, Int_t bo)
559 // Create a standard button.
560 // If width is not zero, the fixed-width flag is set.
562 TGLabel* l = new TGLabel(p, txt);
565 l->ChangeOptions(l->GetOptions() | kFixedWidth);
567 p->AddFrame(l, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));