Fixes for building of DA (Anshul)
[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
48265b32 60ClassImp(AliTPCMonitorDialog)
61//_____________________________________________________________________________________________
fb3305d1 62AliTPCMonitorDialog::AliTPCMonitorDialog(TGWindow *p, TGWindow *main, UInt_t w,
c60053f6 63 UInt_t h, UInt_t options, Int_t version,AliTPCMonitor* monitor):
fb3305d1 64 //fQObject(0),
c60053f6 65fFrameMain(new TGTransientFrame(p, main, w, h, options)),
66fFrameComp(0),
67fFrameHor(new TGHorizontalFrame(fFrameMain, 60, 20, kFixedWidth)),
68fFrameGroup(0),
69fOkButton(new TGTextButton(fFrameHor, "&Ok", 1)),
70fListBox(0),
71fTab(new TGTab(fFrameMain, 300, 300)),
72fLayout1(new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2)),
73fLayout2(new TGLayoutHints(kLHintsBottom | kLHintsRight , 2, 2, 5, 1)),
74fLayout3(new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5)),
75fMonitor(monitor),
76fWidth(w),
77fHeight(h),
78fOptions(options),
79fVersion(version),
80fClient(p),
81fMain(main)
48265b32 82{
c60053f6 83 // Constructor for Dialog window.
84 // Create a dialog window.depending on the version it is called with..
48265b32 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
c60053f6 88
48265b32 89 fFrameMain->Connect("CloseWindow()", "AliTPCMonitorDialog", this, "DoClose()");
c60053f6 90 fFrameMain->DontCallClose();
48265b32 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//_____________________________________________________________________________
101AliTPCMonitorDialog::AliTPCMonitorDialog(const AliTPCMonitorDialog &dialog) :
102TNamed(dialog.GetName(),dialog.GetTitle()),
103//fQObject(0),
104fFrameMain(new TGTransientFrame(dialog.GetClient(), dialog.GetMainFrame(), dialog.GetWidth(), dialog.GetHeight())),
105fFrameComp(0),
106fFrameHor(new TGHorizontalFrame(fFrameMain, 60, 20, kFixedWidth)),
107fFrameGroup(0),
108fOkButton(new TGTextButton(fFrameHor, "&Ok", 1)),
109fListBox(0),
110fTab(new TGTab(fFrameMain, 300, 300)),
111fLayout1(new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2)),
112fLayout2(new TGLayoutHints(kLHintsBottom | kLHintsRight , 2, 2, 5, 1)),
113fLayout3(new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5)),
114fMonitor(dialog.GetMonitor()),
115fWidth(dialog.GetWidth()),
116fHeight(dialog.GetHeight()),
117fOptions(dialog.GetOptions()),
118fVersion(dialog.GetVersion()),
119fClient(dialog.GetClient()),
120fMain(dialog.GetMainFrame())
121{
122 // copy constructor (actually none forseen for this class)
123 fFrameMain->Connect("CloseWindow()", "AliTPCMonitorDialog", this, "DoClose()");
c60053f6 124 fFrameMain->DontCallClose();
fb3305d1 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());
c60053f6 132
fb3305d1 133}
ca7b8371 134
fb3305d1 135 //_____________________________________________________________________________
136AliTPCMonitorDialog &AliTPCMonitorDialog::operator =(const AliTPCMonitorDialog& dialog)
137{
138 // assignement operator (actually none forseen for this class)
139 if(this!=&dialog)
c60053f6 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//_____________________________________________________________________________________________
174void AliTPCMonitorDialog::CreateDialogVersion(Int_t version)
175{
176 // Create a dialog window depending on the version passed
c60053f6 177
48265b32 178 if(version==1)
c60053f6 179 {
48265b32 180 // Choose DATA Format ////////////////////////////////////////////////////
c60053f6 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 }
48265b32 196 else if(version==2)
c60053f6 197 {
48265b32 198 // choose component to be displayed /////////////////////////////////////
c60053f6 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]);
48265b32 223
48265b32 224 }
c60053f6 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 }
48265b32 230 else if(version==3)
c60053f6 231 {
48265b32 232 // choose component to be displayed /////////////////////////////////////
c60053f6 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])));
48265b32 246
c60053f6 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()));
48265b32 251
c60053f6 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]);
48265b32 256
48265b32 257 }
c60053f6 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 }
48265b32 263
264 TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
c60053f6 265 kLHintsExpandY, 2, 2, 5, 1);
48265b32 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//_____________________________________________________________________________________________
278AliTPCMonitorDialog::~AliTPCMonitorDialog()
279{
280 // Delete test dialog widgets.
c60053f6 281 fFrameMain->DeleteWindow();
48265b32 282}
283
284//_____________________________________________________________________________________________
285void 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
c60053f6 293 switch (id)
294 {
295 case 1:
48265b32 296 {
c60053f6 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++)
48265b32 312 {
c60053f6 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 }
48265b32 327 }
c60053f6 328 if(compsel==1)
48265b32 329 {
c60053f6 330 if(fMonitor!=0 && fMonitor->GetEventProcessed() )fMonitor->ShowSel((Int_t*)fComponents);
331 else AliError("No event processed up to now");
48265b32 332 }
48265b32 333 break;
334 }
c60053f6 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 }
48265b32 377}
378
379//_____________________________________________________________________________________________
fb3305d1 380void AliTPCMonitorDialog::DoTab(Int_t id)
48265b32 381{
382 printf("Tab item %d activated\n", id);
383}
384
385//_____________________________________________________________________________________________
fb3305d1 386void AliTPCMonitorDialog::DoClose() const
48265b32 387{
388 // Close the dialog window
389 printf("\nTerminating dialog: via window manager\n");
c60053f6 390 CloseWindow();
48265b32 391 // Close the Ged editor if it was activated.
392 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
393 TVirtualPadEditor::Terminate();
394}
395
396//_____________________________________________________________________________________________
fb3305d1 397void AliTPCMonitorDialog::CloseWindow() const
48265b32 398{
399 // Called when window is closed via the window manager.
400 delete this;
401}
402
403//_____________________________________________________________________________________________
404void AliTPCMonitorDialog::DoOK()
405{
406 // Call from OK button
407 printf("\nTerminating dialog: OK pressed\n");
c60053f6 408
48265b32 409 // The same effect can be obtained by using a singleshot timer:
410 TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()");
c60053f6 411
48265b32 412 // Close the Ged editor if it was activated.
413 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
414 TVirtualPadEditor::Terminate();
415}
416
417
418//_____________________________________________________________________________________________
419void 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