48265b32 |
1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * |
3 | * * |
4 | * Author: The ALICE Off-line Project. * |
5 | * Contributors are mentioned in the code where appropriate. * |
6 | * * |
7 | * Permission to use, copy, modify and distribute this software and its * |
8 | * documentation strictly for non-commercial purposes is hereby granted * |
9 | * without fee, provided that the above copyright notice appears in all * |
10 | * copies and that both the copyright notice and this permission notice * |
11 | * appear in the supporting documentation. The authors make no claims * |
12 | * about the suitability of this software for any purpose. It is * |
13 | * provided "as is" without express or implied warranty. * |
14 | **************************************************************************/ |
15 | |
16 | /* |
17 | $Log$ |
ca7b8371 |
18 | Revision 1.1 2007/09/17 10:23:31 cvetan |
19 | New TPC monitoring package from Stefan Kniege. The monitoring package can be started by running TPCMonitor.C macro located in macros folder. |
20 | |
48265b32 |
21 | */ |
22 | |
ca7b8371 |
23 | //////////////////////////////////////////////////////////////////////// |
fb3305d1 |
24 | //// |
25 | //// AliTPCMonitorDialog class |
26 | //// |
27 | //// Class to handle dialogs for settings of files and configurations |
28 | //// for the AliTPCMonitor |
29 | //// |
30 | //// The dialog will be called by an AliTPCMonitor object from the macro TPCMonitor.C. |
31 | //// Depending on the version number passed when creating an Object of this class |
32 | //// a certain dialog window (see constructor) for the TPCMonitor will be opened. |
33 | //// The data inserted will be passed to the configuration handler and read out |
34 | //// by the monitor object or a the monitor member function will be directly called. |
35 | //// |
36 | //// Author: Stefan Kniege, IKF, Frankfurt |
37 | //// |
38 | //// |
ca7b8371 |
39 | ///////////////////////////////////////////////////////////////////////// |
40 | |
48265b32 |
41 | |
ca7b8371 |
42 | |
43 | |
b09247a2 |
44 | #include <cstdlib> |
48265b32 |
45 | #include "AliTPCMonitorDialog.h" |
ca7b8371 |
46 | #include "TGTab.h" |
47 | #include "TGButton.h" |
48 | #include "TGLabel.h" |
49 | #include "TGListBox.h" |
50 | #include "TGLayout.h" |
51 | #include "TGTextBuffer.h" |
52 | #include "TGTextEntry.h" |
53 | #include "TGWindow.h" |
54 | #include "TVirtualPadEditor.h" |
55 | #include "TTimer.h" |
ca7b8371 |
56 | #include <Riostream.h> |
48265b32 |
57 | #include "Rtypes.h" |
58 | #include "AliLog.h" |
ca7b8371 |
59 | |
48265b32 |
60 | ClassImp(AliTPCMonitorDialog) |
61 | //_____________________________________________________________________________________________ |
fb3305d1 |
62 | AliTPCMonitorDialog::AliTPCMonitorDialog(TGWindow *p, TGWindow *main, UInt_t w, |
63 | UInt_t h, UInt_t options, Int_t version,AliTPCMonitor* monitor): |
64 | //fQObject(0), |
ca7b8371 |
65 | fFrameMain(new TGTransientFrame(p, main, w, h, options)), |
66 | fFrameComp(0), |
67 | fFrameHor(new TGHorizontalFrame(fFrameMain, 60, 20, kFixedWidth)), |
68 | fFrameGroup(0), |
69 | fOkButton(new TGTextButton(fFrameHor, "&Ok", 1)), |
70 | fListBox(0), |
71 | fTab(new TGTab(fFrameMain, 300, 300)), |
72 | fLayout1(new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2)), |
73 | fLayout2(new TGLayoutHints(kLHintsBottom | kLHintsRight , 2, 2, 5, 1)), |
74 | fLayout3(new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5)), |
fb3305d1 |
75 | fMonitor(monitor), |
76 | fWidth(w), |
77 | fHeight(h), |
78 | fOptions(options), |
79 | fVersion(version), |
80 | fClient(p), |
81 | fMain(main) |
48265b32 |
82 | { |
ca7b8371 |
83 | // Constructor for Dialog window. |
48265b32 |
84 | // Create a dialog window.depending on the version it is called with.. |
85 | // Verrion 0: Choose DATA Format |
86 | // Version 1: Choose FEC components to display |
87 | // Version 2: Choose Ranges for base and max adc calculation |
88 | |
48265b32 |
89 | fFrameMain->Connect("CloseWindow()", "AliTPCMonitorDialog", this, "DoClose()"); |
90 | fFrameMain->DontCallClose(); |
91 | fFrameMain->SetCleanup(kDeepCleanup); |
48265b32 |
92 | fOkButton->Connect("Clicked()", "AliTPCMonitorDialog", this, "DoOK()"); |
48265b32 |
93 | fFrameHor->AddFrame(fOkButton, fLayout1); |
94 | fFrameHor->Resize(150, fOkButton->GetDefaultHeight()); |
95 | fFrameMain->AddFrame( fFrameHor, fLayout2); |
48265b32 |
96 | fTab->Connect("Selected(Int_t)", "AliTPCMonitorDialog", this, "DoTab(Int_t)"); |
48265b32 |
97 | CreateDialogVersion(version); |
98 | } |
99 | |
fb3305d1 |
100 | //_____________________________________________________________________________ |
101 | AliTPCMonitorDialog::AliTPCMonitorDialog(const AliTPCMonitorDialog &dialog) : |
102 | TNamed(dialog.GetName(),dialog.GetTitle()), |
103 | //fQObject(0), |
104 | fFrameMain(new TGTransientFrame(dialog.GetClient(), dialog.GetMainFrame(), dialog.GetWidth(), dialog.GetHeight())), |
105 | fFrameComp(0), |
106 | fFrameHor(new TGHorizontalFrame(fFrameMain, 60, 20, kFixedWidth)), |
107 | fFrameGroup(0), |
108 | fOkButton(new TGTextButton(fFrameHor, "&Ok", 1)), |
109 | fListBox(0), |
110 | fTab(new TGTab(fFrameMain, 300, 300)), |
111 | fLayout1(new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2)), |
112 | fLayout2(new TGLayoutHints(kLHintsBottom | kLHintsRight , 2, 2, 5, 1)), |
113 | fLayout3(new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5)), |
114 | fMonitor(dialog.GetMonitor()), |
115 | fWidth(dialog.GetWidth()), |
116 | fHeight(dialog.GetHeight()), |
117 | fOptions(dialog.GetOptions()), |
118 | fVersion(dialog.GetVersion()), |
119 | fClient(dialog.GetClient()), |
120 | fMain(dialog.GetMainFrame()) |
121 | { |
122 | // copy constructor (actually none forseen for this class) |
123 | fFrameMain->Connect("CloseWindow()", "AliTPCMonitorDialog", this, "DoClose()"); |
124 | fFrameMain->DontCallClose(); |
125 | fFrameMain->SetCleanup(kDeepCleanup); |
126 | fOkButton->Connect("Clicked()", "AliTPCMonitorDialog", this, "DoOK()"); |
127 | fFrameHor->AddFrame(fOkButton, fLayout1); |
128 | fFrameHor->Resize(150, fOkButton->GetDefaultHeight()); |
129 | fFrameMain->AddFrame( fFrameHor, fLayout2); |
130 | fTab->Connect("Selected(Int_t)", "AliTPCMonitorDialog", this, "DoTab(Int_t)"); |
131 | CreateDialogVersion(dialog.GetVersion()); |
132 | |
133 | } |
ca7b8371 |
134 | |
fb3305d1 |
135 | //_____________________________________________________________________________ |
136 | AliTPCMonitorDialog &AliTPCMonitorDialog::operator =(const AliTPCMonitorDialog& dialog) |
137 | { |
138 | // assignement operator (actually none forseen for this class) |
139 | if(this!=&dialog) |
140 | { |
141 | fFrameMain = new TGTransientFrame(dialog.GetClient(), dialog.GetMainFrame(), dialog.GetWidth(), dialog.GetHeight()); |
142 | fFrameComp = 0; |
143 | fFrameHor = new TGHorizontalFrame(fFrameMain, 60, 20, kFixedWidth); |
144 | fFrameGroup = 0; |
145 | fOkButton = new TGTextButton(fFrameHor, "&Ok", 1); |
146 | fListBox = 0; |
147 | fTab = new TGTab(fFrameMain, 300, 300); |
148 | fLayout1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2); |
149 | fLayout2 = new TGLayoutHints(kLHintsBottom | kLHintsRight , 2, 2, 5, 1); |
150 | fLayout3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5); |
151 | fMonitor = dialog.GetMonitor(); |
152 | fWidth = dialog.GetWidth(); |
153 | fHeight = dialog.GetHeight(); |
154 | fOptions = dialog.GetOptions(); |
155 | fClient = dialog.GetClient(); |
156 | fVersion = dialog.GetVersion(); |
157 | fMain = dialog.GetMainFrame(); |
158 | fFrameMain->Connect("CloseWindow()", "AliTPCMonitorDialog", this, "DoClose()"); |
159 | fFrameMain->DontCallClose(); |
160 | fFrameMain->SetCleanup(kDeepCleanup); |
161 | fOkButton->Connect("Clicked()", "AliTPCMonitorDialog", this, "DoOK()"); |
162 | fFrameHor->AddFrame(fOkButton, fLayout1); |
163 | fFrameHor->Resize(150, fOkButton->GetDefaultHeight()); |
164 | fFrameMain->AddFrame( fFrameHor, fLayout2); |
165 | fTab->Connect("Selected(Int_t)", "AliTPCMonitorDialog", this, "DoTab(Int_t)"); |
166 | CreateDialogVersion(dialog.GetVersion()); |
167 | } |
168 | return *this; |
169 | } |
ca7b8371 |
170 | |
171 | |
172 | |
48265b32 |
173 | //_____________________________________________________________________________________________ |
174 | void AliTPCMonitorDialog::CreateDialogVersion(Int_t version) |
175 | { |
176 | // Create a dialog window depending on the version passed |
177 | |
178 | Char_t tmp[256]; |
179 | if(version==1) |
180 | { |
181 | // Choose DATA Format //////////////////////////////////////////////////// |
182 | TGTextButton *bt; |
183 | TGCompositeFrame* tf = fTab->AddTab("Select Format"); |
184 | fFrameComp = new TGCompositeFrame(tf, 60, 20, kVerticalFrame); |
185 | fFrameComp->AddFrame(bt = new TGTextButton(fFrameComp, "Select Entry", 1), fLayout3); |
186 | |
187 | bt->Connect("Clicked()", "AliTPCMonitorDialog", this, "HandleButtons()"); |
188 | fFrameComp->AddFrame(fListBox = new TGListBox(fFrameComp, 1), fLayout3); |
189 | tf->AddFrame(fFrameComp, fLayout3); |
190 | sprintf(tmp, "ROOT file "); fListBox->AddEntry(tmp, 0); |
191 | sprintf(tmp, "DATE file "); fListBox->AddEntry(tmp, 1); |
192 | sprintf(tmp, "DATE file/stream "); fListBox->AddEntry(tmp, 2); |
193 | |
194 | fListBox->Resize(200, 80); |
195 | |
196 | } |
197 | else if(version==2) |
198 | { |
199 | // choose component to be displayed ///////////////////////////////////// |
200 | fFrameGroup = new TGGroupFrame(fFrameMain, "Components", kVerticalFrame); |
201 | fFrameGroup->SetTitlePos(TGGroupFrame::kRight); // right aligned |
202 | fFrameMain->AddFrame(fFrameGroup, fLayout3); |
203 | fFrameGroup->SetLayoutManager(new TGMatrixLayout(fFrameGroup, 0, 2, 10)); |
204 | |
205 | Char_t buff[100]; |
206 | Char_t names[6][40] ={ |
207 | "FEC (global)", |
208 | "RCU (patch) ", |
209 | "Branch ", |
210 | "FEC (local) ", |
211 | "Connector ", |
212 | "Chip " |
213 | }; |
214 | for (Int_t j = 0; j < 6; j++) |
215 | { |
216 | sprintf(buff, "%s", names[j]); |
217 | fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(buff))); |
218 | |
219 | fBuf[j] = new TGTextBuffer(10); |
220 | fBuf[j]->AddText(0, "all"); |
221 | |
222 | fEnt[j] = new TGTextEntry(fFrameMain, fBuf[j]); |
223 | fEnt[j]->Resize(50, fEnt[j]->GetDefaultHeight()); |
224 | fEnt[j]->SetFont("-adobe-courier-bold-r-*-*-14-*-*-*-*-*-iso8859-1"); |
225 | fFrameGroup->AddFrame(fEnt[j]); |
226 | |
227 | } |
228 | TGTextButton* bt2 =0; |
229 | fFrameGroup->AddFrame(bt2 = new TGTextButton(fFrameGroup, "Select Config", 2), fLayout3); |
230 | bt2->Connect("Clicked()", "AliTPCMonitorDialog", this, "HandleButtons()"); |
231 | fFrameGroup->Resize(); |
232 | } |
233 | else if(version==3) |
234 | { |
235 | // choose component to be displayed ///////////////////////////////////// |
236 | fFrameGroup = new TGGroupFrame(fFrameMain, "Ranges BASE/MAX/SUM ", kVerticalFrame); |
237 | fFrameGroup->SetTitlePos(TGGroupFrame::kRight); |
238 | fFrameMain->AddFrame(fFrameGroup, fLayout3); |
239 | fFrameGroup->SetLayoutManager(new TGMatrixLayout(fFrameGroup, 0, 2, 10)); |
240 | |
241 | Char_t buff[100]; |
242 | Char_t names[3][40] = { |
243 | "baseline", |
244 | "maximum adc", |
245 | "sum adc ", |
246 | }; |
247 | |
248 | Char_t namebas[40]; sprintf(namebas,"%i,%i",fMonitor->GetRangeBaseMin() , fMonitor->GetRangeBaseMax() ); |
249 | Char_t namemax[40]; sprintf(namemax,"%i,%i",fMonitor->GetRangeMaxAdcMin(), fMonitor->GetRangeMaxAdcMax()); |
250 | Char_t namesum[40]; sprintf(namesum,"%i,%i",fMonitor->GetRangeSumMin() , fMonitor->GetRangeSumMax() ); |
251 | |
252 | for (Int_t j = 0; j < 3; j++) { |
253 | sprintf(buff, "%s", names[j]); |
254 | fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(buff))); |
255 | |
256 | fBuf[j] = new TGTextBuffer(30); |
257 | if(j==0) fBuf[j]->AddText(0,namebas); |
258 | if(j==1) fBuf[j]->AddText(0,namemax); |
259 | if(j==2) fBuf[j]->AddText(0,namesum); |
260 | |
261 | fEnt[j] = new TGTextEntry(fFrameMain, fBuf[j]); |
262 | fEnt[j]->Resize(100, fEnt[j]->GetDefaultHeight()); |
263 | fEnt[j]->SetFont("-adobe-courier-bold-r-*-*-14-*-*-*-*-*-iso8859-1"); |
264 | fFrameGroup->AddFrame(fEnt[j]); |
265 | |
266 | } |
267 | TGTextButton* bt2 =0; |
268 | fFrameGroup->AddFrame(bt2 = new TGTextButton(fFrameGroup, "Select Config", 3), fLayout3); |
269 | bt2->Connect("Clicked()", "AliTPCMonitorDialog", this, "HandleButtons()"); |
270 | fFrameGroup->Resize(100,300); |
271 | } |
272 | |
273 | TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX | |
274 | kLHintsExpandY, 2, 2, 5, 1); |
275 | fFrameMain->AddFrame(fTab, fL5); |
276 | fFrameMain->MapSubwindows(); |
277 | fFrameMain->Resize(); |
278 | |
279 | fFrameMain->CenterOnParent(); |
280 | if( version==3) fFrameMain->SetWindowName("Select Ranges"); |
281 | else if(version==1) fFrameMain->SetWindowName("Select Component"); |
282 | else fFrameMain->SetWindowName("Select Format"); |
283 | fFrameMain->MapWindow(); |
284 | } |
285 | |
286 | //_____________________________________________________________________________________________ |
287 | AliTPCMonitorDialog::~AliTPCMonitorDialog() |
288 | { |
289 | // Delete test dialog widgets. |
290 | fFrameMain->DeleteWindow(); |
291 | } |
292 | |
293 | //_____________________________________________________________________________________________ |
294 | void AliTPCMonitorDialog::HandleButtons(Int_t id) |
295 | { |
296 | // Handle different buttons. |
297 | if (id == -1) { |
298 | TGButton *btn = (TGButton*) gTQSender; |
299 | id = btn->WidgetId(); |
300 | } |
301 | |
302 | switch (id) |
303 | { |
304 | case 1: |
305 | { |
306 | // Select Format |
307 | Int_t fsel = fListBox->GetSelected(); |
308 | if(fsel==-1) { AliError("Warning: No Format selected "); } |
309 | TGLBEntry* libentr = (TGLBEntry*)fListBox->GetEntry(fsel); |
310 | AliInfo(Form("Selected Format : %i : %s",fsel,libentr->GetTitle())); |
311 | fMonitor->SetFormat(fsel); |
312 | |
313 | break; |
314 | } |
315 | case 2: |
316 | { |
317 | // Select FEE Component |
fb3305d1 |
318 | Int_t compsel=1; |
48265b32 |
319 | Int_t fComponents[10]; |
320 | for(Int_t j = 0; j < 6; j++) |
321 | { |
322 | TString s1 = fEnt[j]->GetDisplayText(); |
323 | if(s1=="all"){ fComponents[j] = -1; } |
324 | else { fComponents[j] = (int)atoi(s1.Data()); } |
325 | if( |
326 | j==0 && (fComponents[j] < -1 || fComponents[j]>5000) || |
327 | j==1 && (fComponents[j] < -1 || fComponents[j]>5 ) || |
328 | j==2 && (fComponents[j] < -1 || fComponents[j]>1 ) || |
329 | j==3 && (fComponents[j] < -1 || fComponents[j]>25 ) || |
330 | j==4 && (fComponents[j] < -1 || fComponents[j]>6 ) || |
331 | j==5 && (fComponents[j] < -1 || fComponents[j]>8 ) ) |
332 | { |
fb3305d1 |
333 | compsel =0; |
48265b32 |
334 | AliError("Settings out of range ( version 2) "); |
335 | } |
336 | } |
fb3305d1 |
337 | if(compsel==1) |
48265b32 |
338 | { |
339 | if(fMonitor!=0 && fMonitor->GetEventProcessed() )fMonitor->ShowSel((Int_t*)fComponents); |
340 | else AliError("No event processed up to now"); |
341 | } |
342 | break; |
343 | } |
344 | case 3: |
345 | { |
346 | // Set Configuration (base, max, sum) |
347 | Int_t fConfigArr[6]; |
348 | |
349 | string s1((TString)fEnt[0]->GetDisplayText().Data()); |
350 | string s2((TString)fEnt[1]->GetDisplayText().Data()); |
351 | string s3((TString)fEnt[2]->GetDisplayText().Data()); |
352 | |
353 | Int_t error = 1; |
354 | |
355 | if(s1.find(",")!=string::npos){ |
fb3305d1 |
356 | string sub11 = s1.substr(0,s1.find(",")) ;fConfigArr[0] = atoi(sub11.data()); |
357 | string sub12 = s1.substr(s1.find(",")+1,s1.length() ) ;fConfigArr[1] = atoi(sub12.data()); |
48265b32 |
358 | if(fConfigArr[0]<fConfigArr[1] && fConfigArr[1]<1024){ |
359 | fMonitor->SetRangeBase(fConfigArr[0],fConfigArr[1]); |
360 | error=0; |
361 | } |
362 | } |
363 | if(s2.find(",")!=string::npos){ |
fb3305d1 |
364 | string sub21 = s2.substr(0,s2.find(",")) ;fConfigArr[2] = atoi(sub21.data()); |
365 | string sub22 = s2.substr(s2.find(",")+1,s2.length() ) ;fConfigArr[3] = atoi(sub22.data()); |
48265b32 |
366 | if(fConfigArr[2]<fConfigArr[3] && fConfigArr[3]<1024){ |
367 | fMonitor->SetRangeMax(fConfigArr[2],fConfigArr[3]); |
368 | error=0; |
369 | } |
370 | } |
371 | |
372 | if(s3.find(",")!=string::npos){ |
fb3305d1 |
373 | string sub31 = s3.substr(0,s3.find(",")) ;fConfigArr[4] = atoi(sub31.data()); |
374 | string sub32 = s3.substr(s3.find(",")+1,s3.length() ) ;fConfigArr[5] = atoi(sub32.data()); |
48265b32 |
375 | if(fConfigArr[4]<fConfigArr[5] && fConfigArr[5]<1024){ |
376 | fMonitor->SetRangeSum(fConfigArr[4],fConfigArr[5]); |
377 | error=0; |
378 | } |
379 | } |
380 | if(error!=0) AliError("Settings out of range (version 3)"); |
381 | break; |
382 | } |
383 | default: |
384 | break; |
385 | } |
386 | } |
387 | |
388 | //_____________________________________________________________________________________________ |
fb3305d1 |
389 | void AliTPCMonitorDialog::DoTab(Int_t id) |
48265b32 |
390 | { |
391 | printf("Tab item %d activated\n", id); |
392 | } |
393 | |
394 | //_____________________________________________________________________________________________ |
fb3305d1 |
395 | void AliTPCMonitorDialog::DoClose() const |
48265b32 |
396 | { |
397 | // Close the dialog window |
398 | printf("\nTerminating dialog: via window manager\n"); |
fb3305d1 |
399 | CloseWindow(); |
48265b32 |
400 | // Close the Ged editor if it was activated. |
401 | if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0) |
402 | TVirtualPadEditor::Terminate(); |
403 | } |
404 | |
405 | //_____________________________________________________________________________________________ |
fb3305d1 |
406 | void AliTPCMonitorDialog::CloseWindow() const |
48265b32 |
407 | { |
408 | // Called when window is closed via the window manager. |
409 | delete this; |
410 | } |
411 | |
412 | //_____________________________________________________________________________________________ |
413 | void AliTPCMonitorDialog::DoOK() |
414 | { |
415 | // Call from OK button |
416 | printf("\nTerminating dialog: OK pressed\n"); |
417 | |
418 | // The same effect can be obtained by using a singleshot timer: |
419 | TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()"); |
420 | |
421 | // Close the Ged editor if it was activated. |
422 | if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0) |
423 | TVirtualPadEditor::Terminate(); |
424 | } |
425 | |
426 | |
427 | //_____________________________________________________________________________________________ |
428 | void AliTPCMonitorDialog::DoCancel() |
429 | { |
430 | // Cancel operation and close the dialog window |
431 | printf("\nTerminating dialog: Cancel pressed\n"); |
432 | TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()"); |
433 | |
434 | // Close the Ged editor if it was activated. |
435 | if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0) |
436 | TVirtualPadEditor::Terminate(); |
437 | } |
438 | |