]>
Commit | Line | Data |
---|---|---|
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$ | |
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 | ||
21 | */ | |
22 | ||
23 | //////////////////////////////////////////////////////////////////////// | |
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 | //// | |
39 | ///////////////////////////////////////////////////////////////////////// | |
40 | ||
41 | ||
42 | ||
43 | ||
44 | #include <cstdlib> | |
45 | #include "AliTPCMonitorDialog.h" | |
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" | |
56 | #include <Riostream.h> | |
57 | #include "Rtypes.h" | |
58 | #include "AliLog.h" | |
59 | ||
60 | ClassImp(AliTPCMonitorDialog) | |
61 | //_____________________________________________________________________________________________ | |
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), | |
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)), | |
75 | fMonitor(monitor), | |
76 | fWidth(w), | |
77 | fHeight(h), | |
78 | fOptions(options), | |
79 | fVersion(version), | |
80 | fClient(p), | |
81 | fMain(main) | |
82 | { | |
83 | // Constructor for Dialog window. | |
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 | ||
89 | fFrameMain->Connect("CloseWindow()", "AliTPCMonitorDialog", this, "DoClose()"); | |
90 | fFrameMain->DontCallClose(); | |
91 | fFrameMain->SetCleanup(kDeepCleanup); | |
92 | fOkButton->Connect("Clicked()", "AliTPCMonitorDialog", this, "DoOK()"); | |
93 | fFrameHor->AddFrame(fOkButton, fLayout1); | |
94 | fFrameHor->Resize(150, fOkButton->GetDefaultHeight()); | |
95 | fFrameMain->AddFrame( fFrameHor, fLayout2); | |
96 | fTab->Connect("Selected(Int_t)", "AliTPCMonitorDialog", this, "DoTab(Int_t)"); | |
97 | CreateDialogVersion(version); | |
98 | } | |
99 | ||
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 | } | |
134 | ||
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 | } | |
170 | ||
171 | ||
172 | ||
173 | //_____________________________________________________________________________________________ | |
174 | void AliTPCMonitorDialog::CreateDialogVersion(Int_t version) | |
175 | { | |
176 | // Create a dialog window depending on the version passed | |
177 | ||
178 | if(version==1) | |
179 | { | |
180 | // Choose DATA Format //////////////////////////////////////////////////// | |
181 | TGTextButton *bt; | |
182 | TGCompositeFrame* tf = fTab->AddTab("Select Format"); | |
183 | fFrameComp = new TGCompositeFrame(tf, 60, 20, kVerticalFrame); | |
184 | fFrameComp->AddFrame(bt = new TGTextButton(fFrameComp, "Select Entry", 1), fLayout3); | |
185 | ||
186 | bt->Connect("Clicked()", "AliTPCMonitorDialog", this, "HandleButtons()"); | |
187 | fFrameComp->AddFrame(fListBox = new TGListBox(fFrameComp, 1), fLayout3); | |
188 | tf->AddFrame(fFrameComp, fLayout3); | |
189 | fListBox->AddEntry("ROOT file ", 0); | |
190 | fListBox->AddEntry("DATE file ", 1); | |
191 | fListBox->AddEntry("DATE file/stream ", 2); | |
192 | ||
193 | fListBox->Resize(200, 80); | |
194 | ||
195 | } | |
196 | else if(version==2) | |
197 | { | |
198 | // choose component to be displayed ///////////////////////////////////// | |
199 | fFrameGroup = new TGGroupFrame(fFrameMain, "Components", kVerticalFrame); | |
200 | fFrameGroup->SetTitlePos(TGGroupFrame::kRight); // right aligned | |
201 | fFrameMain->AddFrame(fFrameGroup, fLayout3); | |
202 | fFrameGroup->SetLayoutManager(new TGMatrixLayout(fFrameGroup, 0, 2, 10)); | |
203 | ||
204 | const Char_t names[6][40] ={ | |
205 | "FEC (global)", | |
206 | "RCU (patch) ", | |
207 | "Branch ", | |
208 | "FEC (local) ", | |
209 | "Connector ", | |
210 | "Chip " | |
211 | }; | |
212 | for (Int_t j = 0; j < 6; j++) | |
213 | { | |
214 | fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(names[j]))); | |
215 | ||
216 | fBuf[j] = new TGTextBuffer(10); | |
217 | fBuf[j]->AddText(0, "all"); | |
218 | ||
219 | fEnt[j] = new TGTextEntry(fFrameMain, fBuf[j]); | |
220 | fEnt[j]->Resize(50, fEnt[j]->GetDefaultHeight()); | |
221 | fEnt[j]->SetFont("-adobe-courier-bold-r-*-*-14-*-*-*-*-*-iso8859-1"); | |
222 | fFrameGroup->AddFrame(fEnt[j]); | |
223 | ||
224 | } | |
225 | TGTextButton* bt2 =0; | |
226 | fFrameGroup->AddFrame(bt2 = new TGTextButton(fFrameGroup, "Select Config", 2), fLayout3); | |
227 | bt2->Connect("Clicked()", "AliTPCMonitorDialog", this, "HandleButtons()"); | |
228 | fFrameGroup->Resize(); | |
229 | } | |
230 | else if(version==3) | |
231 | { | |
232 | // choose component to be displayed ///////////////////////////////////// | |
233 | fFrameGroup = new TGGroupFrame(fFrameMain, "Ranges BASE/MAX/SUM ", kVerticalFrame); | |
234 | fFrameGroup->SetTitlePos(TGGroupFrame::kRight); | |
235 | fFrameMain->AddFrame(fFrameGroup, fLayout3); | |
236 | fFrameGroup->SetLayoutManager(new TGMatrixLayout(fFrameGroup, 0, 2, 10)); | |
237 | ||
238 | const Char_t names[3][40] = { | |
239 | "baseline", | |
240 | "maximum adc", | |
241 | "sum adc ", | |
242 | }; | |
243 | ||
244 | for (Int_t j = 0; j < 3; j++) { | |
245 | fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(names[j]))); | |
246 | ||
247 | fBuf[j] = new TGTextBuffer(30); | |
248 | if(j==0) fBuf[j]->AddText(0,Form("%i,%i",fMonitor->GetRangeBaseMin() , fMonitor->GetRangeBaseMax())); | |
249 | if(j==1) fBuf[j]->AddText(0,Form("%i,%i",fMonitor->GetRangeMaxAdcMin(), fMonitor->GetRangeMaxAdcMax())); | |
250 | if(j==2) fBuf[j]->AddText(0,Form("%i,%i",fMonitor->GetRangeSumMin() , fMonitor->GetRangeSumMax())); | |
251 | ||
252 | fEnt[j] = new TGTextEntry(fFrameMain, fBuf[j]); | |
253 | fEnt[j]->Resize(100, fEnt[j]->GetDefaultHeight()); | |
254 | fEnt[j]->SetFont("-adobe-courier-bold-r-*-*-14-*-*-*-*-*-iso8859-1"); | |
255 | fFrameGroup->AddFrame(fEnt[j]); | |
256 | ||
257 | } | |
258 | TGTextButton* bt2 =0; | |
259 | fFrameGroup->AddFrame(bt2 = new TGTextButton(fFrameGroup, "Select Config", 3), fLayout3); | |
260 | bt2->Connect("Clicked()", "AliTPCMonitorDialog", this, "HandleButtons()"); | |
261 | fFrameGroup->Resize(100,300); | |
262 | } | |
263 | ||
264 | TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX | | |
265 | kLHintsExpandY, 2, 2, 5, 1); | |
266 | fFrameMain->AddFrame(fTab, fL5); | |
267 | fFrameMain->MapSubwindows(); | |
268 | fFrameMain->Resize(); | |
269 | ||
270 | fFrameMain->CenterOnParent(); | |
271 | if( version==3) fFrameMain->SetWindowName("Select Ranges"); | |
272 | else if(version==1) fFrameMain->SetWindowName("Select Component"); | |
273 | else fFrameMain->SetWindowName("Select Format"); | |
274 | fFrameMain->MapWindow(); | |
275 | } | |
276 | ||
277 | //_____________________________________________________________________________________________ | |
278 | AliTPCMonitorDialog::~AliTPCMonitorDialog() | |
279 | { | |
280 | // Delete test dialog widgets. | |
281 | fFrameMain->DeleteWindow(); | |
282 | } | |
283 | ||
284 | //_____________________________________________________________________________________________ | |
285 | void AliTPCMonitorDialog::HandleButtons(Int_t id) | |
286 | { | |
287 | // Handle different buttons. | |
288 | if (id == -1) { | |
289 | TGButton *btn = (TGButton*) gTQSender; | |
290 | id = btn->WidgetId(); | |
291 | } | |
292 | ||
293 | switch (id) | |
294 | { | |
295 | case 1: | |
296 | { | |
297 | // Select Format | |
298 | Int_t fsel = fListBox->GetSelected(); | |
299 | if(fsel==-1) { AliError("Warning: No Format selected "); } | |
300 | TGLBEntry* libentr = (TGLBEntry*)fListBox->GetEntry(fsel); | |
301 | AliInfo(Form("Selected Format : %i : %s",fsel,libentr->GetTitle())); | |
302 | fMonitor->SetFormat(fsel); | |
303 | ||
304 | break; | |
305 | } | |
306 | case 2: | |
307 | { | |
308 | // Select FEE Component | |
309 | Int_t compsel=1; | |
310 | Int_t fComponents[10]; | |
311 | for(Int_t j = 0; j < 6; j++) | |
312 | { | |
313 | TString s1 = fEnt[j]->GetDisplayText(); | |
314 | if(s1=="all"){ fComponents[j] = -1; } | |
315 | else { fComponents[j] = (int)atoi(s1.Data()); } | |
316 | if( | |
317 | (j==0 && (fComponents[j] < -1 || fComponents[j]>5000)) || | |
318 | (j==1 && (fComponents[j] < -1 || fComponents[j]>5 )) || | |
319 | (j==2 && (fComponents[j] < -1 || fComponents[j]>1 )) || | |
320 | (j==3 && (fComponents[j] < -1 || fComponents[j]>25 )) || | |
321 | (j==4 && (fComponents[j] < -1 || fComponents[j]>6 )) || | |
322 | (j==5 && (fComponents[j] < -1 || fComponents[j]>8 )) ) | |
323 | { | |
324 | compsel =0; | |
325 | AliError("Settings out of range ( version 2) "); | |
326 | } | |
327 | } | |
328 | if(compsel==1) | |
329 | { | |
330 | if(fMonitor!=0 && fMonitor->GetEventProcessed() )fMonitor->ShowSel((Int_t*)fComponents); | |
331 | else AliError("No event processed up to now"); | |
332 | } | |
333 | break; | |
334 | } | |
335 | case 3: | |
336 | { | |
337 | // Set Configuration (base, max, sum) | |
338 | Int_t fConfigArr[6]; | |
339 | ||
340 | string s1((TString)fEnt[0]->GetDisplayText().Data()); | |
341 | string s2((TString)fEnt[1]->GetDisplayText().Data()); | |
342 | string s3((TString)fEnt[2]->GetDisplayText().Data()); | |
343 | ||
344 | Int_t error = 1; | |
345 | ||
346 | if(s1.find(",")!=string::npos){ | |
347 | string sub11 = s1.substr(0,s1.find(",")) ;fConfigArr[0] = atoi(sub11.data()); | |
348 | string sub12 = s1.substr(s1.find(",")+1,s1.length() ) ;fConfigArr[1] = atoi(sub12.data()); | |
349 | if(fConfigArr[0]<fConfigArr[1] && fConfigArr[1]<1024){ | |
350 | fMonitor->SetRangeBase(fConfigArr[0],fConfigArr[1]); | |
351 | error=0; | |
352 | } | |
353 | } | |
354 | if(s2.find(",")!=string::npos){ | |
355 | string sub21 = s2.substr(0,s2.find(",")) ;fConfigArr[2] = atoi(sub21.data()); | |
356 | string sub22 = s2.substr(s2.find(",")+1,s2.length() ) ;fConfigArr[3] = atoi(sub22.data()); | |
357 | if(fConfigArr[2]<fConfigArr[3] && fConfigArr[3]<1024){ | |
358 | fMonitor->SetRangeMax(fConfigArr[2],fConfigArr[3]); | |
359 | error=0; | |
360 | } | |
361 | } | |
362 | ||
363 | if(s3.find(",")!=string::npos){ | |
364 | string sub31 = s3.substr(0,s3.find(",")) ;fConfigArr[4] = atoi(sub31.data()); | |
365 | string sub32 = s3.substr(s3.find(",")+1,s3.length() ) ;fConfigArr[5] = atoi(sub32.data()); | |
366 | if(fConfigArr[4]<fConfigArr[5] && fConfigArr[5]<1024){ | |
367 | fMonitor->SetRangeSum(fConfigArr[4],fConfigArr[5]); | |
368 | error=0; | |
369 | } | |
370 | } | |
371 | if(error!=0) AliError("Settings out of range (version 3)"); | |
372 | break; | |
373 | } | |
374 | default: | |
375 | break; | |
376 | } | |
377 | } | |
378 | ||
379 | //_____________________________________________________________________________________________ | |
380 | void AliTPCMonitorDialog::DoTab(Int_t id) | |
381 | { | |
382 | printf("Tab item %d activated\n", id); | |
383 | } | |
384 | ||
385 | //_____________________________________________________________________________________________ | |
386 | void AliTPCMonitorDialog::DoClose() const | |
387 | { | |
388 | // Close the dialog window | |
389 | printf("\nTerminating dialog: via window manager\n"); | |
390 | CloseWindow(); | |
391 | // Close the Ged editor if it was activated. | |
392 | if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0) | |
393 | TVirtualPadEditor::Terminate(); | |
394 | } | |
395 | ||
396 | //_____________________________________________________________________________________________ | |
397 | void AliTPCMonitorDialog::CloseWindow() const | |
398 | { | |
399 | // Called when window is closed via the window manager. | |
400 | delete this; | |
401 | } | |
402 | ||
403 | //_____________________________________________________________________________________________ | |
404 | void AliTPCMonitorDialog::DoOK() | |
405 | { | |
406 | // Call from OK button | |
407 | printf("\nTerminating dialog: OK pressed\n"); | |
408 | ||
409 | // The same effect can be obtained by using a singleshot timer: | |
410 | TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()"); | |
411 | ||
412 | // Close the Ged editor if it was activated. | |
413 | if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0) | |
414 | TVirtualPadEditor::Terminate(); | |
415 | } | |
416 | ||
417 | ||
418 | //_____________________________________________________________________________________________ | |
419 | void AliTPCMonitorDialog::DoCancel() | |
420 | { | |
421 | // Cancel operation and close the dialog window | |
422 | printf("\nTerminating dialog: Cancel pressed\n"); | |
423 | TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()"); | |
424 | ||
425 | // Close the Ged editor if it was activated. | |
426 | if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0) | |
427 | TVirtualPadEditor::Terminate(); | |
428 | } | |
429 |