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