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.
29 ClassImp(AliEveEventManagerEditor)
31 //______________________________________________________________________________
32 AliEveEventManagerEditor::AliEveEventManagerEditor(const TGWindow *p, Int_t width, Int_t height,
33 UInt_t options, Pixel_t back) :
34 TGedFrame(p, width, height, options | kVerticalFrame, back),
41 MakeTitle("AliEveEventManager");
44 TGHorizontalFrame* f = new TGHorizontalFrame(this);
45 fDumpEventInfo = new TGTextButton(f, "Dump Event Info");
46 fDumpEventInfo->SetToolTipText("Append information about current event to event_info.txt file.");
47 fDumpEventInfo->SetWidth(120);
48 fDumpEventInfo->ChangeOptions(fDumpEventInfo->GetOptions() | kFixedWidth);
49 f->AddFrame(fDumpEventInfo, new TGLayoutHints(kLHintsNormal, 4,0,0,0));
50 fDumpEventInfo->Connect("Clicked()",
51 "AliEveEventManagerEditor", this, "DumpEventInfo()");
52 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 8,8,8,0));
55 TGVerticalFrame* f = new TGVerticalFrame(this);
57 TGLabel *eventInfoLabel = new TGLabel(f, "Event Information:");
58 f->AddFrame(eventInfoLabel, new TGLayoutHints(kLHintsNormal, 0,0,6,2));
60 fEventInfo = new TGTextView(f, 200, 300);
61 f->AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
63 AddFrame(f, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
67 /******************************************************************************/
69 //______________________________________________________________________________
70 void AliEveEventManagerEditor::SetModel(TObject* obj)
74 fM = dynamic_cast<AliEveEventManager*>(obj);
76 fEventInfo->LoadBuffer(fM->GetEventInfoVertical());
79 /******************************************************************************/
81 //______________________________________________________________________________
82 void AliEveEventManagerEditor::DumpEventInfo()
84 // Dump event-info into event_info.txt.
85 // The info is appended into the file.
87 ofstream f("event_info.txt", ios::out | ios::app);
89 f << "================================================================================\n\n";
90 f << fM->GetEventInfoHorizontal() << std::endl << std::endl;
96 //==============================================================================
97 // AliEveEventManagerWindow
98 //==============================================================================
100 //______________________________________________________________________________
102 // Horizontal GUI for AliEveEventManager, to be placed in the
103 // bottom part of ROOT browser.
105 ClassImp(AliEveEventManagerWindow)
107 AliEveEventManagerWindow::AliEveEventManagerWindow(AliEveEventManager* mgr) :
108 TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame),
124 const TString cls("AliEveEventManagerWindow");
129 TGHorizontalFrame* f = new TGHorizontalFrame(this);
130 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
132 fFirstEvent = b = MkTxtButton(f, "First", width);
133 b->Connect("Clicked()", cls, this, "DoFirstEvent()");
134 fPrevEvent = b = MkTxtButton(f, "Prev", width);
135 b->Connect("Clicked()", cls, this, "DoPrevEvent()");
137 fEventId = new TGNumberEntry(f, 0, 5, -1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
138 TGNumberFormat::kNELLimitMinMax, 0, 10000);
139 f->AddFrame(fEventId, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
140 fEventId->Connect("ValueSet(Long_t)", cls, this, "DoSetEvent()");
141 fInfoLabel = new TGLabel(f);
142 f->AddFrame(fInfoLabel, new TGLayoutHints(kLHintsNormal, 5, 10, 4, 0));
144 fNextEvent = b = MkTxtButton(f, "Next", width);
145 b->Connect("Clicked()", cls, this, "DoNextEvent()");
146 fLastEvent = b = MkTxtButton(f, "Last", width);
147 b->Connect("Clicked()", cls, this, "DoLastEvent()");
149 MkLabel(f, "||", 0, 8, 8);
151 fRefresh = b = MkTxtButton(f, "Refresh", width + 8);
152 b->Connect("Clicked()",cls, this, "DoRefresh()");
154 MkLabel(f, "||", 0, 8, 8);
156 fAutoLoad = new TGCheckButton(f, "Autoload");
157 f->AddFrame(fAutoLoad, new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0));
158 fAutoLoad->SetToolTipText("Automatic event loading.");
159 fAutoLoad->Connect("Toggled(Bool_t)", cls, this, "DoSetAutoLoad()");
161 fAutoLoadTime = new TEveGValuator(f, "Time: ", 110, 0);
162 f->AddFrame(fAutoLoadTime);
163 fAutoLoadTime->SetShowSlider(kFALSE);
164 fAutoLoadTime->SetNELength(4);
165 fAutoLoadTime->Build();
166 fAutoLoadTime->SetLimits(0, 1000);
167 fAutoLoadTime->SetToolTip("Automatic event loading time in seconds.");
168 fAutoLoadTime->Connect("ValueSet(Double_t)", cls, this, "DoSetAutoLoadTime()");
170 fTrigSel = new TGComboBox(f);
171 fTrigSel->Resize(4*width,b->GetDefaultHeight());
172 fTrigSel->AddEntry("No trigger selection",-1);
173 fTrigSel->Select(-1,kFALSE);
174 f->AddFrame(fTrigSel, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
175 fTrigSel->Connect("Selected(char*)", cls, this, "DoSetTrigSel()");
178 fEventInfo = new TGTextView(this, 400, 600);
179 AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
181 fM->Connect("NewEventLoaded()", cls, this, "Update()");
183 SetCleanup(kDeepCleanup);
189 //______________________________________________________________________________
190 AliEveEventManagerWindow::~AliEveEventManagerWindow()
194 fM->Disconnect("NewEventLoaded()", this);
197 //______________________________________________________________________________
198 void AliEveEventManagerWindow::DoFirstEvent()
200 // Load previous event
204 //______________________________________________________________________________
205 void AliEveEventManagerWindow::DoPrevEvent()
207 // Load previous event
211 //______________________________________________________________________________
212 void AliEveEventManagerWindow::DoNextEvent()
218 //______________________________________________________________________________
219 void AliEveEventManagerWindow::DoLastEvent()
221 // Load previous event
225 //______________________________________________________________________________
226 void AliEveEventManagerWindow::DoSetEvent()
229 fM->GotoEvent((Int_t) fEventId->GetNumber());
232 //______________________________________________________________________________
233 void AliEveEventManagerWindow::DoRefresh()
235 // Refresh event status.
237 Int_t ev = fM->GetEventId();
243 //______________________________________________________________________________
244 void AliEveEventManagerWindow::DoSetAutoLoad()
246 // Set the auto-load flag
248 fM->SetAutoLoad(fAutoLoad->IsOn());
252 //______________________________________________________________________________
253 void AliEveEventManagerWindow::DoSetAutoLoadTime()
255 // Set the auto-load time in seconds
257 fM->SetAutoLoadTime(fAutoLoadTime->GetValue());
260 //______________________________________________________________________________
261 void AliEveEventManagerWindow::DoSetTrigSel()
263 // Set the trigger selection
265 fM->SetTrigSel(fTrigSel->GetSelectedEntry()->EntryId());
268 //______________________________________________________________________________
269 void AliEveEventManagerWindow::Update()
271 // Update current event, number of available events, list of active triggers
273 Bool_t autoLoad = fM->GetAutoLoad();
274 Bool_t extCtrl = fM->IsUnderExternalControl();
275 Bool_t evNavOn = !autoLoad && !extCtrl;
277 fFirstEvent->SetEnabled(evNavOn);
278 fPrevEvent ->SetEnabled(evNavOn);
279 fLastEvent ->SetEnabled(evNavOn);
280 fNextEvent ->SetEnabled(!autoLoad);
281 fRefresh ->SetEnabled(evNavOn);
283 fEventId->SetNumber(fM->GetEventId());
284 fEventId->SetState(evNavOn);
285 fInfoLabel->SetText(Form("/ %d", fM->GetMaxEventId()));
287 fAutoLoad->SetState(fM->GetAutoLoad() ? kButtonDown : kButtonUp);
288 fAutoLoadTime->SetValue(fM->GetAutoLoadTime());
290 // Loop over active trigger classes
292 for(Int_t iTrig = 0; iTrig < AliESDRun::kNTriggerClasses; iTrig++) {
293 TString trigName = fM->GetESD()->GetESDRun()->GetTriggerClass(iTrig);
294 if (trigName.IsNull()) {
295 if (fTrigSel->GetListBox()->GetEntry(iTrig)) {
296 if (fTrigSel->GetSelected() == iTrig) fTrigSel->Select(-1);
297 fTrigSel->RemoveEntry(iTrig);
301 if (!fTrigSel->FindEntry(trigName.Data()))
302 fTrigSel->AddEntry(trigName.Data(),iTrig);
305 fTrigSel->SetEnabled(!evNavOn);
307 fEventInfo->LoadBuffer(fM->GetEventInfoHorizontal());
312 //------------------------------------------------------------------------------
314 //------------------------------------------------------------------------------
316 //______________________________________________________________________________
317 TGTextButton* AliEveEventManagerWindow::MkTxtButton(TGCompositeFrame* p,
318 const char* txt, Int_t width,
319 Int_t lo, Int_t ro, Int_t to, Int_t bo)
321 // Create a standard button.
322 // If width is not zero, the fixed-width flag is set.
324 TGTextButton* b = new TGTextButton(p, txt);
327 b->ChangeOptions(b->GetOptions() | kFixedWidth);
329 p->AddFrame(b, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
333 //______________________________________________________________________________
334 TGLabel* AliEveEventManagerWindow::MkLabel(TGCompositeFrame* p,
335 const char* txt, Int_t width,
336 Int_t lo, Int_t ro, Int_t to, Int_t bo)
338 // Create a standard button.
339 // If width is not zero, the fixed-width flag is set.
341 TGLabel* l = new TGLabel(p, txt);
344 l->ChangeOptions(l->GetOptions() | kFixedWidth);
346 p->AddFrame(l, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));