]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/EveBase/AliEveEventManagerEditor.cxx
* esd_spd_tracklets
[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"
12
b3b7b8d3 13#include <AliESDEvent.h>
14
15#include <TVirtualPad.h>
5655e9ce 16#include "TColor.h"
17
319f3084 18#include <TEveGValuators.h>
19#include <TGButton.h>
20#include <TGTextView.h>
21#include <TGLabel.h>
5655e9ce 22
23//______________________________________________________________________________
24// GUI editor for AliEveEventManager.
25//
26
27ClassImp(AliEveEventManagerEditor)
28
29//______________________________________________________________________________
30AliEveEventManagerEditor::AliEveEventManagerEditor(const TGWindow *p, Int_t width, Int_t height,
80547f2d 31 UInt_t options, Pixel_t back) :
5655e9ce 32 TGedFrame(p, width, height, options | kVerticalFrame, back),
319f3084 33 fM(0),
319f3084 34 fNextEvent(0),
319f3084 35 fEventInfo(0)
5655e9ce 36{
37 // Constructor.
38
39 MakeTitle("AliEveEventManager");
40
319f3084 41 {
42 TGHorizontalFrame* f = new TGHorizontalFrame(this);
319f3084 43 fNextEvent = new TGTextButton(f, "Next Event");
ca49b003 44 fNextEvent->SetWidth(100);
45 fNextEvent->ChangeOptions(fNextEvent->GetOptions() | kFixedWidth);
46 f->AddFrame(fNextEvent, new TGLayoutHints(kLHintsNormal, 4,0,0,0));
319f3084 47 fNextEvent->Connect("Clicked()",
48 "AliEveEventManagerEditor", this, "DoNextEvent()");
49 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 8,8,8,0));
50 }
319f3084 51 {
52 TGVerticalFrame* f = new TGVerticalFrame(this);
53
54 TGLabel *eventInfoLabel = new TGLabel(f, "Event Information:");
55 f->AddFrame(eventInfoLabel, new TGLayoutHints(kLHintsNormal, 0,0,6,2));
56
ec835ab5 57 fEventInfo = new TGTextView(f, 200, 300);
319f3084 58 f->AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
59
60 AddFrame(f, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
61 }
5655e9ce 62}
63
64/******************************************************************************/
65
80547f2d 66//______________________________________________________________________________
5655e9ce 67void AliEveEventManagerEditor::SetModel(TObject* obj)
68{
69 // Set model object.
70
71 fM = dynamic_cast<AliEveEventManager*>(obj);
72
12365217 73 fEventInfo->LoadBuffer(fM->GetEventInfoVertical());
5655e9ce 74}
75
76/******************************************************************************/
77
319f3084 78//______________________________________________________________________________
79void AliEveEventManagerEditor::DoNextEvent()
80{
81 // Load next event
ca49b003 82
80547f2d 83 fM->NextEvent();
ca49b003 84}
f76c9e9b 85
86
80547f2d 87//==============================================================================
f76c9e9b 88// AliEveEventManagerWindow
80547f2d 89//==============================================================================
f76c9e9b 90
91//______________________________________________________________________________
92//
93// Horizontal GUI for AliEveEventManager, to be placed in the
94// bottom part of ROOT browser.
95
96ClassImp(AliEveEventManagerWindow)
97
4d62585e 98AliEveEventManagerWindow::AliEveEventManagerWindow(AliEveEventManager* mgr) :
12365217 99 TGMainFrame(gClient->GetRoot(), 400, 100, kVerticalFrame),
4d62585e 100 fM (mgr),
80547f2d 101 fFirstEvent (0),
102 fPrevEvent (0),
103 fNextEvent (0),
104 fLastEvent (0),
105 fRefresh (0),
106 fEventId (0),
107 fInfoLabel (0),
108 fAutoLoad (0),
109 fAutoLoadTime (0),
969d3431 110 fTrigSel (0),
80547f2d 111 fEventInfo (0)
f76c9e9b 112{
113 // Constructor.
114
488869c1 115 const TString cls("AliEveEventManagerWindow");
80547f2d 116 TGTextButton *b = 0;
f76c9e9b 117 {
118 Int_t width = 50;
119
120 TGHorizontalFrame* f = new TGHorizontalFrame(this);
80547f2d 121 AddFrame(f, new TGLayoutHints(kLHintsExpandX, 0,0,2,2));
122
123 fFirstEvent = b = MkTxtButton(f, "First", width);
124 b->Connect("Clicked()", cls, this, "DoFirstEvent()");
125 fPrevEvent = b = MkTxtButton(f, "Prev", width);
126 b->Connect("Clicked()", cls, this, "DoPrevEvent()");
f76c9e9b 127
128 fEventId = new TGNumberEntry(f, 0, 5, -1,TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
129 TGNumberFormat::kNELLimitMinMax, 0, 10000);
130 f->AddFrame(fEventId, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
80547f2d 131 fEventId->Connect("ValueSet(Long_t)", cls, this, "DoSetEvent()");
f76c9e9b 132 fInfoLabel = new TGLabel(f);
133 f->AddFrame(fInfoLabel, new TGLayoutHints(kLHintsNormal, 5, 10, 4, 0));
134
80547f2d 135 fNextEvent = b = MkTxtButton(f, "Next", width);
136 b->Connect("Clicked()", cls, this, "DoNextEvent()");
137 fLastEvent = b = MkTxtButton(f, "Last", width);
138 b->Connect("Clicked()", cls, this, "DoLastEvent()");
f76c9e9b 139
80547f2d 140 MkLabel(f, "||", 0, 8, 8);
141
142 fRefresh = b = MkTxtButton(f, "Refresh", width + 8);
143 b->Connect("Clicked()",cls, this, "DoRefresh()");
144
145 MkLabel(f, "||", 0, 8, 8);
146
147 fAutoLoad = new TGCheckButton(f, "Autoload");
148 f->AddFrame(fAutoLoad, new TGLayoutHints(kLHintsLeft, 0, 4, 3, 0));
149 fAutoLoad->SetToolTipText("Automatic event loading.");
150 fAutoLoad->Connect("Toggled(Bool_t)", cls, this, "DoSetAutoLoad()");
151
152 fAutoLoadTime = new TEveGValuator(f, "Time: ", 110, 0);
ecb84424 153 f->AddFrame(fAutoLoadTime);
80547f2d 154 fAutoLoadTime->SetShowSlider(kFALSE);
155 fAutoLoadTime->SetNELength(4);
156 fAutoLoadTime->Build();
157 fAutoLoadTime->SetLimits(0, 1000);
158 fAutoLoadTime->SetToolTip("Automatic event loading time in seconds.");
159 fAutoLoadTime->Connect("ValueSet(Double_t)", cls, this, "DoSetAutoLoadTime()");
ecb84424 160
969d3431 161 fTrigSel = new TGComboBox(f);
162 fTrigSel->Resize(4*width,b->GetDefaultHeight());
163 fTrigSel->AddEntry("No trigger selection",-1);
164 fTrigSel->Select(-1,kFALSE);
165 f->AddFrame(fTrigSel, new TGLayoutHints(kLHintsNormal, 10, 5, 0, 0));
166 fTrigSel->Connect("Selected(char*)", cls, this, "DoSetTrigSel()");
12365217 167 }
168
80547f2d 169 fEventInfo = new TGTextView(this, 400, 600);
170 AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
171
4d62585e 172 fM->Connect("NewEventLoaded()", cls, this, "Update()");
f76c9e9b 173
174 SetCleanup(kDeepCleanup);
175 Layout();
176 MapSubwindows();
177 MapWindow();
178}
179
180//______________________________________________________________________________
181AliEveEventManagerWindow::~AliEveEventManagerWindow()
182{
183 // Destructor.
184
4d62585e 185 fM->Disconnect("NewEventLoaded()", this);
f76c9e9b 186}
187
188//______________________________________________________________________________
189void AliEveEventManagerWindow::DoFirstEvent()
190{
191 // Load previous event
4d62585e 192 fM->GotoEvent(0);
f76c9e9b 193}
194
195//______________________________________________________________________________
196void AliEveEventManagerWindow::DoPrevEvent()
197{
198 // Load previous event
4d62585e 199 fM->PrevEvent();
f76c9e9b 200}
201
202//______________________________________________________________________________
203void AliEveEventManagerWindow::DoNextEvent()
204{
205 // Load next event
4d62585e 206 fM->NextEvent();
f76c9e9b 207}
208
209//______________________________________________________________________________
210void AliEveEventManagerWindow::DoLastEvent()
211{
212 // Load previous event
4d62585e 213 fM->GotoEvent(-1);
f76c9e9b 214}
215
216//______________________________________________________________________________
217void AliEveEventManagerWindow::DoSetEvent()
218{
219 // Set current event
4d62585e 220 fM->GotoEvent((Int_t) fEventId->GetNumber());
f76c9e9b 221}
222
80547f2d 223//______________________________________________________________________________
224void AliEveEventManagerWindow::DoRefresh()
225{
226 // Refresh event status.
227
4d62585e 228 Int_t ev = fM->GetEventId();
229 fM->Close();
230 fM->Open();
231 fM->GotoEvent(ev);
80547f2d 232}
233
234//______________________________________________________________________________
235void AliEveEventManagerWindow::DoSetAutoLoad()
236{
237 // Set the auto-load flag
238
4d62585e 239 fM->SetAutoLoad(fAutoLoad->IsOn());
80547f2d 240 Update();
241}
242
243//______________________________________________________________________________
244void AliEveEventManagerWindow::DoSetAutoLoadTime()
245{
246 // Set the auto-load time in seconds
247
4d62585e 248 fM->SetAutoLoadTime(fAutoLoadTime->GetValue());
80547f2d 249}
250
969d3431 251//______________________________________________________________________________
252void AliEveEventManagerWindow::DoSetTrigSel()
253{
254 // Set the trigger selection
255
256 fM->SetTrigSel(fTrigSel->GetSelectedEntry()->EntryId());
257}
258
f76c9e9b 259//______________________________________________________________________________
260void AliEveEventManagerWindow::Update()
261{
ecb84424 262 // Update current event, number of available events, list of active triggers
f76c9e9b 263
4d62585e 264 Bool_t autoLoad = fM->GetAutoLoad();
265 Bool_t extCtrl = fM->IsUnderExternalControl();
80547f2d 266 Bool_t evNavOn = !autoLoad && !extCtrl;
267
268 fFirstEvent->SetEnabled(evNavOn);
269 fPrevEvent ->SetEnabled(evNavOn);
270 fLastEvent ->SetEnabled(evNavOn);
271 fNextEvent ->SetEnabled(!autoLoad);
272 fRefresh ->SetEnabled(evNavOn);
273
4d62585e 274 fEventId->SetNumber(fM->GetEventId());
80547f2d 275 fEventId->SetState(evNavOn);
4d62585e 276 fInfoLabel->SetText(Form("/ %d", fM->GetMaxEventId()));
12365217 277
4d62585e 278 fAutoLoad->SetState(fM->GetAutoLoad() ? kButtonDown : kButtonUp);
279 fAutoLoadTime->SetValue(fM->GetAutoLoadTime());
80547f2d 280
969d3431 281 // Loop over active trigger classes
282 if (fM->GetESD()) {
283 for(Int_t iTrig = 0; iTrig < AliESDRun::kNTriggerClasses; iTrig++) {
284 TString trigName = fM->GetESD()->GetESDRun()->GetTriggerClass(iTrig);
285 if (trigName.IsNull()) {
286 if (fTrigSel->GetListBox()->GetEntry(iTrig)) {
287 if (fTrigSel->GetSelected() == iTrig) fTrigSel->Select(-1);
288 fTrigSel->RemoveEntry(iTrig);
289 }
290 continue;
291 }
292 if (!fTrigSel->FindEntry(trigName.Data()))
293 fTrigSel->AddEntry(trigName.Data(),iTrig);
294 }
295 }
296 fTrigSel->SetEnabled(!evNavOn);
297
4d62585e 298 fEventInfo->LoadBuffer(fM->GetEventInfoHorizontal());
12365217 299
f76c9e9b 300 Layout();
301}
80547f2d 302
303//------------------------------------------------------------------------------
304// Protected methods
305//------------------------------------------------------------------------------
306
307//______________________________________________________________________________
308TGTextButton* AliEveEventManagerWindow::MkTxtButton(TGCompositeFrame* p,
309 const char* txt, Int_t width,
310 Int_t lo, Int_t ro, Int_t to, Int_t bo)
311{
312 // Create a standard button.
313 // If width is not zero, the fixed-width flag is set.
314
315 TGTextButton* b = new TGTextButton(p, txt);
316 if (width > 0) {
317 b->SetWidth(width);
318 b->ChangeOptions(b->GetOptions() | kFixedWidth);
319 }
320 p->AddFrame(b, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
321 return b;
322}
323
324//______________________________________________________________________________
325TGLabel* AliEveEventManagerWindow::MkLabel(TGCompositeFrame* p,
326 const char* txt, Int_t width,
327 Int_t lo, Int_t ro, Int_t to, Int_t bo)
328{
329 // Create a standard button.
330 // If width is not zero, the fixed-width flag is set.
331
332 TGLabel* l = new TGLabel(p, txt);
333 if (width > 0) {
334 l->SetWidth(width);
335 l->ChangeOptions(l->GetOptions() | kFixedWidth);
336 }
337 p->AddFrame(l, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo));
338 return l;
339}
ecb84424 340