]>
Commit | Line | Data |
---|---|---|
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 | ||
27 | ClassImp(AliEveEventManagerEditor) | |
28 | ||
29 | //______________________________________________________________________________ | |
30 | AliEveEventManagerEditor::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 | 67 | void 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 | //______________________________________________________________________________ |
79 | void 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 | ||
96 | ClassImp(AliEveEventManagerWindow) | |
97 | ||
4d62585e | 98 | AliEveEventManagerWindow::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), | |
ecb84424 | 106 | fTrigger (0), |
80547f2d | 107 | fEventId (0), |
108 | fInfoLabel (0), | |
109 | fAutoLoad (0), | |
110 | fAutoLoadTime (0), | |
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 | |
161 | MkLabel(f, "||", 0, 8, 8); | |
162 | ||
163 | MkLabel(f, "TRG select:", 0, 0, 4, 4); | |
164 | fTrigger = new TGComboBox(f); | |
165 | f->AddFrame(fTrigger, new TGLayoutHints(kLHintsNormal)); | |
166 | fTrigger->Resize(75,20); | |
167 | //fTrigger->EnableTextInput(kTRUE); | |
168 | fTrigger->Connect("Selected(const char*)", cls, this, "DoSetTriggerType(const char*)"); | |
12365217 | 169 | } |
170 | ||
80547f2d | 171 | fEventInfo = new TGTextView(this, 400, 600); |
172 | AddFrame(fEventInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY)); | |
173 | ||
4d62585e | 174 | fM->Connect("NewEventLoaded()", cls, this, "Update()"); |
f76c9e9b | 175 | |
176 | SetCleanup(kDeepCleanup); | |
177 | Layout(); | |
178 | MapSubwindows(); | |
179 | MapWindow(); | |
180 | } | |
181 | ||
182 | //______________________________________________________________________________ | |
183 | AliEveEventManagerWindow::~AliEveEventManagerWindow() | |
184 | { | |
185 | // Destructor. | |
186 | ||
4d62585e | 187 | fM->Disconnect("NewEventLoaded()", this); |
f76c9e9b | 188 | } |
189 | ||
190 | //______________________________________________________________________________ | |
191 | void AliEveEventManagerWindow::DoFirstEvent() | |
192 | { | |
193 | // Load previous event | |
4d62585e | 194 | fM->GotoEvent(0); |
f76c9e9b | 195 | } |
196 | ||
197 | //______________________________________________________________________________ | |
198 | void AliEveEventManagerWindow::DoPrevEvent() | |
199 | { | |
200 | // Load previous event | |
4d62585e | 201 | fM->PrevEvent(); |
f76c9e9b | 202 | } |
203 | ||
204 | //______________________________________________________________________________ | |
205 | void AliEveEventManagerWindow::DoNextEvent() | |
206 | { | |
207 | // Load next event | |
4d62585e | 208 | fM->NextEvent(); |
f76c9e9b | 209 | } |
210 | ||
211 | //______________________________________________________________________________ | |
212 | void AliEveEventManagerWindow::DoLastEvent() | |
213 | { | |
214 | // Load previous event | |
4d62585e | 215 | fM->GotoEvent(-1); |
f76c9e9b | 216 | } |
217 | ||
218 | //______________________________________________________________________________ | |
219 | void AliEveEventManagerWindow::DoSetEvent() | |
220 | { | |
221 | // Set current event | |
4d62585e | 222 | fM->GotoEvent((Int_t) fEventId->GetNumber()); |
f76c9e9b | 223 | } |
224 | ||
80547f2d | 225 | //______________________________________________________________________________ |
226 | void AliEveEventManagerWindow::DoRefresh() | |
227 | { | |
228 | // Refresh event status. | |
229 | ||
4d62585e | 230 | Int_t ev = fM->GetEventId(); |
231 | fM->Close(); | |
232 | fM->Open(); | |
233 | fM->GotoEvent(ev); | |
80547f2d | 234 | } |
235 | ||
236 | //______________________________________________________________________________ | |
237 | void AliEveEventManagerWindow::DoSetAutoLoad() | |
238 | { | |
239 | // Set the auto-load flag | |
240 | ||
4d62585e | 241 | fM->SetAutoLoad(fAutoLoad->IsOn()); |
80547f2d | 242 | Update(); |
243 | } | |
244 | ||
245 | //______________________________________________________________________________ | |
246 | void AliEveEventManagerWindow::DoSetAutoLoadTime() | |
247 | { | |
248 | // Set the auto-load time in seconds | |
249 | ||
4d62585e | 250 | fM->SetAutoLoadTime(fAutoLoadTime->GetValue()); |
80547f2d | 251 | } |
252 | ||
ecb84424 | 253 | //______________________________________________________________________________ |
254 | void AliEveEventManagerWindow::DoSetTriggerType(const char* type) | |
255 | { | |
256 | // Slot for setting trigger type. | |
257 | ||
258 | TString typestr = type; | |
259 | if (typestr=="") | |
260 | { | |
4d62585e | 261 | fM->SetSelectOnTriggerType(kFALSE); |
ecb84424 | 262 | } |
263 | else | |
264 | { | |
4d62585e | 265 | fM->SetTriggerType( typestr ); |
266 | fM->SetSelectOnTriggerType(kTRUE); | |
ecb84424 | 267 | } |
268 | } | |
269 | ||
f76c9e9b | 270 | //______________________________________________________________________________ |
271 | void AliEveEventManagerWindow::Update() | |
272 | { | |
ecb84424 | 273 | // Update current event, number of available events, list of active triggers |
f76c9e9b | 274 | |
4d62585e | 275 | Bool_t autoLoad = fM->GetAutoLoad(); |
276 | Bool_t extCtrl = fM->IsUnderExternalControl(); | |
80547f2d | 277 | Bool_t evNavOn = !autoLoad && !extCtrl; |
278 | ||
279 | fFirstEvent->SetEnabled(evNavOn); | |
280 | fPrevEvent ->SetEnabled(evNavOn); | |
281 | fLastEvent ->SetEnabled(evNavOn); | |
282 | fNextEvent ->SetEnabled(!autoLoad); | |
283 | fRefresh ->SetEnabled(evNavOn); | |
284 | ||
4d62585e | 285 | fEventId->SetNumber(fM->GetEventId()); |
80547f2d | 286 | fEventId->SetState(evNavOn); |
4d62585e | 287 | fInfoLabel->SetText(Form("/ %d", fM->GetMaxEventId())); |
12365217 | 288 | |
4d62585e | 289 | fAutoLoad->SetState(fM->GetAutoLoad() ? kButtonDown : kButtonUp); |
290 | fAutoLoadTime->SetValue(fM->GetAutoLoadTime()); | |
80547f2d | 291 | |
4d62585e | 292 | fEventInfo->LoadBuffer(fM->GetEventInfoHorizontal()); |
12365217 | 293 | |
ecb84424 | 294 | SetupTriggerSelect(); |
295 | ||
f76c9e9b | 296 | Layout(); |
297 | } | |
80547f2d | 298 | |
299 | //------------------------------------------------------------------------------ | |
300 | // Protected methods | |
301 | //------------------------------------------------------------------------------ | |
302 | ||
303 | //______________________________________________________________________________ | |
304 | TGTextButton* AliEveEventManagerWindow::MkTxtButton(TGCompositeFrame* p, | |
305 | const char* txt, Int_t width, | |
306 | Int_t lo, Int_t ro, Int_t to, Int_t bo) | |
307 | { | |
308 | // Create a standard button. | |
309 | // If width is not zero, the fixed-width flag is set. | |
310 | ||
311 | TGTextButton* b = new TGTextButton(p, txt); | |
312 | if (width > 0) { | |
313 | b->SetWidth(width); | |
314 | b->ChangeOptions(b->GetOptions() | kFixedWidth); | |
315 | } | |
316 | p->AddFrame(b, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo)); | |
317 | return b; | |
318 | } | |
319 | ||
320 | //______________________________________________________________________________ | |
321 | TGLabel* AliEveEventManagerWindow::MkLabel(TGCompositeFrame* p, | |
322 | const char* txt, Int_t width, | |
323 | Int_t lo, Int_t ro, Int_t to, Int_t bo) | |
324 | { | |
325 | // Create a standard button. | |
326 | // If width is not zero, the fixed-width flag is set. | |
327 | ||
328 | TGLabel* l = new TGLabel(p, txt); | |
329 | if (width > 0) { | |
330 | l->SetWidth(width); | |
331 | l->ChangeOptions(l->GetOptions() | kFixedWidth); | |
332 | } | |
333 | p->AddFrame(l, new TGLayoutHints(kLHintsNormal, lo,ro,to,bo)); | |
334 | return l; | |
335 | } | |
ecb84424 | 336 | |
337 | void AliEveEventManagerWindow::SetupTriggerSelect() | |
338 | { | |
77e5986c | 339 | // Do nothing if already enabled. |
340 | if (fTrigger->GetNumberOfEntries() > 0) | |
341 | return; | |
ecb84424 | 342 | |
4d62585e | 343 | AliESDEvent* esd = fM->GetESD(); |
344 | if (esd && fM->GetESDFile() != 0) | |
ecb84424 | 345 | { |
346 | TString activetrg = esd->GetESDRun()->GetActiveTriggerClasses(); //Get list of active classes | |
347 | TObjArray* activetrgarr = activetrg.Tokenize(" "); //break up the classes string, space as separator | |
348 | Int_t entries = activetrgarr->GetEntries(); //how many triggerclasses | |
349 | TString entry; //to hold the triger class name | |
350 | TObjString* entryobj; | |
351 | if (entries == 0) | |
352 | { | |
353 | fTrigger->SetEnabled(kFALSE); //no trigger classes | |
354 | } | |
355 | else | |
356 | { | |
357 | fTrigger->RemoveAll(); //some initial cleanup | |
358 | fTrigger->SetEnabled(kTRUE); //no trigger classes | |
359 | fTrigger->AddEntry("",-1); //first entry empty - select to not filter by trigger | |
360 | for (Int_t i=0;i<entries;i++) | |
361 | { | |
362 | entryobj = (TObjString*)activetrgarr->At(i); | |
363 | entry = entryobj->GetString(); | |
364 | fTrigger->AddEntry(entry.Data(), i); | |
365 | } | |
366 | } | |
367 | fTrigger->Select(-1, kTRUE); //set default no filtering and emit | |
77e5986c | 368 | fTrigger->SetEnabled(kTRUE); |
ecb84424 | 369 | } |
370 | else | |
371 | { | |
372 | fTrigger->SetEnabled(kFALSE); | |
373 | } | |
374 | } | |
375 |