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