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"
13 #include <AliESDEvent.h>
15 #include <TVirtualPad.h>
18 #include <TEveGValuators.h>
20 #include <TGTextView.h>
23 #include "Riostream.h"
25 //______________________________________________________________________________
26 // GUI editor for AliEveEventManager.
31 ClassImp(AliEveEventManagerEditor)
33 //______________________________________________________________________________
34 AliEveEventManagerEditor::AliEveEventManagerEditor(const TGWindow *p, Int_t width, Int_t height,
35 UInt_t options, Pixel_t back) :
36 TGedFrame(p, width, height, options | kVerticalFrame, back),
43 MakeTitle("AliEveEventManager");
46 TGHorizontalFrame* f = new TGHorizontalFrame(this);
47 fDumpEventInfo = new TGTextButton(f, "Dump Event Info");
48 fDumpEventInfo->SetToolTipText("Append information about current event to event_info.txt file.");
49 fDumpEventInfo->SetWidth(120);
50 fDumpEventInfo->ChangeOptions(fDumpEventInfo->GetOptions() | kFixedWidth);
51 f->AddFrame(fDumpEventInfo, new TGLayoutHints(kLHintsNormal, 4,0,0,0));
52 fDumpEventInfo->Connect("Clicked()",
53 "AliEveEventManagerEditor", this, "DumpEventInfo()");
54 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 8,8,8,0));
57 TGVerticalFrame* f = new TGVerticalFrame(this);
59 TGLabel *eventInfoLabel = new TGLabel(f, "Event Information:");
60 f->AddFrame(eventInfoLabel, new TGLayoutHints(kLHintsNormal, 0,0,6,2));
62 fEventInfo = new TGTextView(f, 200, 300);
63 f->AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
65 AddFrame(f, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
69 /******************************************************************************/
71 //______________________________________________________________________________
72 void AliEveEventManagerEditor::SetModel(TObject* obj)
76 fM = static_cast<AliEveEventManager*>(obj);
78 fEventInfo->LoadBuffer(fM->GetEventInfoVertical());
81 /******************************************************************************/
83 //______________________________________________________________________________
84 void AliEveEventManagerEditor::DumpEventInfo()
86 // Dump event-info into event_info.txt.
87 // The info is appended into the file.
89 ofstream f("event_info.txt", ios::out | ios::app);
91 f << "================================================================================\n\n";
92 f << fM->GetEventInfoHorizontal() << std::endl << std::endl;
98 //==============================================================================
99 // AliEveEventManagerWindow
100 //==============================================================================
102 //______________________________________________________________________________
104 // Horizontal GUI for AliEveEventManager, to be placed in the
105 // bottom part of ROOT browser.
107 ClassImp(AliEveEventManagerWindow)
109 AliEveEventManagerWindow::AliEveEventManagerWindow(AliEveEventManager* mgr) :
110 TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame),
126 const TString cls("AliEveEventManagerWindow");
131 TGHorizontalFrame* f = new TGHorizontalFrame(this);
132 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
134 fFirstEvent = b = MkTxtButton(f, "First", width);
135 b->Connect("Clicked()", cls, this, "DoFirstEvent()");
136 fPrevEvent = b = MkTxtButton(f, "Prev", width);
137 b->Connect("Clicked()", cls, this, "DoPrevEvent()");
139 fEventId = new TGNumberEntry(f, 0, 5, -1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
140 TGNumberFormat::kNELLimitMinMax, 0, 10000);
141 f->AddFrame(fEventId, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
142 fEventId->Connect("ValueSet(Long_t)", cls, this, "DoSetEvent()");
143 fInfoLabel = new TGLabel(f);
144 f->AddFrame(fInfoLabel, new TGLayoutHints(kLHintsNormal, 5, 10, 4, 0));
146 fNextEvent = b = MkTxtButton(f, "Next", width);
147 b->Connect("Clicked()", cls, this, "DoNextEvent()");
148 fLastEvent = b = MkTxtButton(f, "Last", width);
149 b->Connect("Clicked()", cls, this, "DoLastEvent()");
150 fMarkEvent = b = MkTxtButton(f, "Mark", width);
151 b->Connect("Clicked()", cls, this, "DoMarkEvent()");
153 MkLabel(f, "||", 0, 8, 8);
155 fRefresh = b = MkTxtButton(f, "Refresh", width + 8);
156 b->Connect("Clicked()",cls, this, "DoRefresh()");
158 MkLabel(f, "||", 0, 8, 8);
160 fAutoLoad = new TGCheckButton(f, "Autoload");
161 f->AddFrame(fAutoLoad, new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0));
162 fAutoLoad->SetToolTipText("Automatic event loading.");
163 fAutoLoad->Connect("Toggled(Bool_t)", cls, this, "DoSetAutoLoad()");
165 fAutoLoadTime = new TEveGValuator(f, "Time: ", 110, 0);
166 f->AddFrame(fAutoLoadTime);
167 fAutoLoadTime->SetShowSlider(kFALSE);
168 fAutoLoadTime->SetNELength(4);
169 fAutoLoadTime->Build();
170 fAutoLoadTime->SetLimits(0, 1000);
171 fAutoLoadTime->SetToolTip("Automatic event loading time in seconds.");
172 fAutoLoadTime->Connect("ValueSet(Double_t)", cls, this, "DoSetAutoLoadTime()");
174 fTrigSel = new TGComboBox(f);
175 fTrigSel->Resize(4*width,b->GetDefaultHeight());
176 fTrigSel->AddEntry("No trigger selection",-1);
177 fTrigSel->Select(-1,kFALSE);
178 f->AddFrame(fTrigSel, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
179 fTrigSel->Connect("Selected(char*)", cls, this, "DoSetTrigSel()");
181 fStorageStatus = MkLabel(f,"Storage: Waiting",0,8,8);
185 fEventInfo = new TGTextView(this, 400, 600);
186 AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
188 fM->Connect("NewEventLoaded()", cls, this, "Update()");
189 fM->Connect("StorageManagerOk()",cls,this,"StorageManagerChangedState(=1)");
190 fM->Connect("StorageManagerDown()",cls,this,"StorageManagerChangedState(=0)");
192 SetCleanup(kDeepCleanup);
198 //______________________________________________________________________________
199 AliEveEventManagerWindow::~AliEveEventManagerWindow()
203 fM->Disconnect("NewEventLoaded()", this);
206 //______________________________________________________________________________
207 void AliEveEventManagerWindow::DoFirstEvent()
209 // Load previous event
213 //______________________________________________________________________________
214 void AliEveEventManagerWindow::DoPrevEvent()
216 // Load previous event
222 //______________________________________________________________________________
223 void AliEveEventManagerWindow::DoNextEvent()
231 //______________________________________________________________________________
232 void AliEveEventManagerWindow::DoLastEvent()
234 // Load previous event
238 //______________________________________________________________________________
239 void AliEveEventManagerWindow::DoMarkEvent()
241 // Mark current event
242 fM->MarkCurrentEvent();
245 //______________________________________________________________________________
246 void AliEveEventManagerWindow::DoSetEvent()
249 fM->GotoEvent((Int_t) fEventId->GetNumber());
252 //______________________________________________________________________________
253 void AliEveEventManagerWindow::DoRefresh()
255 // Refresh event status.
257 Int_t ev = fM->GetEventId();
263 //______________________________________________________________________________
264 void AliEveEventManagerWindow::DoSetAutoLoad()
266 // Set the auto-load flag
268 fM->SetAutoLoad(fAutoLoad->IsOn());
272 //______________________________________________________________________________
273 void AliEveEventManagerWindow::DoSetAutoLoadTime()
275 // Set the auto-load time in seconds
277 fM->SetAutoLoadTime(fAutoLoadTime->GetValue());
280 //______________________________________________________________________________
281 void AliEveEventManagerWindow::DoSetTrigSel()
283 // Set the trigger selection
285 fM->SetTrigSel(fTrigSel->GetSelectedEntry()->EntryId());
288 //______________________________________________________________________________
289 void AliEveEventManagerWindow::Update()
291 // Update current event, number of available events, list of active triggers
293 Bool_t autoLoad = fM->GetAutoLoad();
294 Bool_t extCtrl = fM->IsUnderExternalControl();
295 Bool_t evNavOn = !autoLoad && !extCtrl;
297 // fFirstEvent->SetEnabled(evNavOn);
298 // fPrevEvent ->SetEnabled(evNavOn);
299 // fLastEvent ->SetEnabled(evNavOn);
300 fFirstEvent->SetEnabled(!autoLoad);
301 fPrevEvent ->SetEnabled(!autoLoad);
302 fLastEvent ->SetEnabled(!autoLoad);
303 fNextEvent ->SetEnabled(!autoLoad);
304 fRefresh ->SetEnabled(evNavOn);
306 fEventId->SetNumber(fM->GetEventId());
307 fEventId->SetState(evNavOn);
308 fInfoLabel->SetText(Form("/ %d", fM->GetMaxEventId()));
310 fAutoLoad->SetState(fM->GetAutoLoad() ? kButtonDown : kButtonUp);
311 fAutoLoadTime->SetValue(fM->GetAutoLoadTime());
313 // Loop over active trigger classes
315 for(Int_t iTrig = 0; iTrig < AliESDRun::kNTriggerClasses; iTrig++) {
316 TString trigName = fM->GetESD()->GetESDRun()->GetTriggerClass(iTrig);
317 if (trigName.IsNull()) {
318 if (fTrigSel->GetListBox()->GetEntry(iTrig)) {
319 if (fTrigSel->GetSelected() == iTrig) fTrigSel->Select(-1);
320 fTrigSel->RemoveEntry(iTrig);
324 if (!fTrigSel->FindEntry(trigName.Data()))
325 fTrigSel->AddEntry(trigName.Data(),iTrig);
328 fTrigSel->SetEnabled(!evNavOn);
330 fEventInfo->LoadBuffer(fM->GetEventInfoHorizontal());
335 void AliEveEventManagerWindow::StorageManagerChangedState(int state)
339 fStorageStatus->SetText("Storage: DOWN");
340 fMarkEvent->SetEnabled(false);
341 fNextEvent->SetEnabled(false);
342 fLastEvent->SetEnabled(false);
343 fPrevEvent->SetEnabled(false);
344 fFirstEvent->SetEnabled(false);
348 fStorageStatus->SetText("Storage: OK");
349 fMarkEvent->SetEnabled(true);
350 fNextEvent->SetEnabled(true);
351 fLastEvent->SetEnabled(true);
352 fPrevEvent->SetEnabled(true);
353 fFirstEvent->SetEnabled(true);
357 //------------------------------------------------------------------------------
359 //------------------------------------------------------------------------------
361 //______________________________________________________________________________
362 TGTextButton* AliEveEventManagerWindow::MkTxtButton(TGCompositeFrame* p,
363 const char* txt, Int_t width,
364 Int_t lo, Int_t ro, Int_t to, Int_t bo)
366 // Create a standard button.
367 // If width is not zero, the fixed-width flag is set.
369 TGTextButton* b = new TGTextButton(p, txt);
372 b->ChangeOptions(b->GetOptions() | kFixedWidth);
374 p->AddFrame(b, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
378 //______________________________________________________________________________
379 TGLabel* AliEveEventManagerWindow::MkLabel(TGCompositeFrame* p,
380 const char* txt, Int_t width,
381 Int_t lo, Int_t ro, Int_t to, Int_t bo)
383 // Create a standard button.
384 // If width is not zero, the fixed-width flag is set.
386 TGLabel* l = new TGLabel(p, txt);
389 l->ChangeOptions(l->GetOptions() | kFixedWidth);
391 p->AddFrame(l, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));