]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TPC/AliTPCMonitorDialog.cxx
Coding convention fixes from Stefan
[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////////////////////////////////////////////////////////////////////////
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
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"
55#include "RQ_OBJECT.h"
56#include <Riostream.h>
48265b32 57#include "Rtypes.h"
58#include "AliLog.h"
ca7b8371 59
48265b32 60ClassImp(AliTPCMonitorDialog)
61//_____________________________________________________________________________________________
62AliTPCMonitorDialog::AliTPCMonitorDialog(const TGWindow *p, const TGWindow *main, UInt_t w,
ca7b8371 63 UInt_t h, UInt_t options, Int_t version,AliTPCMonitor* monitor):
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)),
74 fMonitor(monitor)
75
48265b32 76{
ca7b8371 77 // Constructor for Dialog window.
48265b32 78 // Create a dialog window.depending on the version it is called with..
79 // Verrion 0: Choose DATA Format
80 // Version 1: Choose FEC components to display
81 // Version 2: Choose Ranges for base and max adc calculation
82
48265b32 83 fFrameMain->Connect("CloseWindow()", "AliTPCMonitorDialog", this, "DoClose()");
84 fFrameMain->DontCallClose();
85 fFrameMain->SetCleanup(kDeepCleanup);
48265b32 86 fOkButton->Connect("Clicked()", "AliTPCMonitorDialog", this, "DoOK()");
48265b32 87 fFrameHor->AddFrame(fOkButton, fLayout1);
88 fFrameHor->Resize(150, fOkButton->GetDefaultHeight());
89 fFrameMain->AddFrame( fFrameHor, fLayout2);
48265b32 90 fTab->Connect("Selected(Int_t)", "AliTPCMonitorDialog", this, "DoTab(Int_t)");
48265b32 91 CreateDialogVersion(version);
92}
93
ca7b8371 94// //_____________________________________________________________________________
95// AliTPCMonitorDialog::AliTPCMonitorDialog(const AliTPCMonitorDialog &dialog) :
96// {
97// // copy constructor (actually none forseen for this class
98// AliWarning("No copying forseen for this class");
99
100// }
101
102// //_____________________________________________________________________________
103// AliTPCMonitorDialog &AliTPCMonitorDialog::operator =(const AliTPCMonitorDialog& dialog)
104// {
105// // assignement operator
106// AliWarning("No assignment forseen for this class");
107// return *this;
108// }
109
110
111
48265b32 112//_____________________________________________________________________________________________
113void AliTPCMonitorDialog::CreateDialogVersion(Int_t version)
114{
115 // Create a dialog window depending on the version passed
116
117 Char_t tmp[256];
118 if(version==1)
119 {
120 // Choose DATA Format ////////////////////////////////////////////////////
121 TGTextButton *bt;
122 TGCompositeFrame* tf = fTab->AddTab("Select Format");
123 fFrameComp = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
124 fFrameComp->AddFrame(bt = new TGTextButton(fFrameComp, "Select Entry", 1), fLayout3);
125
126 bt->Connect("Clicked()", "AliTPCMonitorDialog", this, "HandleButtons()");
127 fFrameComp->AddFrame(fListBox = new TGListBox(fFrameComp, 1), fLayout3);
128 tf->AddFrame(fFrameComp, fLayout3);
129 sprintf(tmp, "ROOT file "); fListBox->AddEntry(tmp, 0);
130 sprintf(tmp, "DATE file "); fListBox->AddEntry(tmp, 1);
131 sprintf(tmp, "DATE file/stream "); fListBox->AddEntry(tmp, 2);
132
133 fListBox->Resize(200, 80);
134
135 }
136 else if(version==2)
137 {
138 // choose component to be displayed /////////////////////////////////////
139 fFrameGroup = new TGGroupFrame(fFrameMain, "Components", kVerticalFrame);
140 fFrameGroup->SetTitlePos(TGGroupFrame::kRight); // right aligned
141 fFrameMain->AddFrame(fFrameGroup, fLayout3);
142 fFrameGroup->SetLayoutManager(new TGMatrixLayout(fFrameGroup, 0, 2, 10));
143
144 Char_t buff[100];
145 Char_t names[6][40] ={
146 "FEC (global)",
147 "RCU (patch) ",
148 "Branch ",
149 "FEC (local) ",
150 "Connector ",
151 "Chip "
152 };
153 for (Int_t j = 0; j < 6; j++)
154 {
155 sprintf(buff, "%s", names[j]);
156 fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(buff)));
157
158 fBuf[j] = new TGTextBuffer(10);
159 fBuf[j]->AddText(0, "all");
160
161 fEnt[j] = new TGTextEntry(fFrameMain, fBuf[j]);
162 fEnt[j]->Resize(50, fEnt[j]->GetDefaultHeight());
163 fEnt[j]->SetFont("-adobe-courier-bold-r-*-*-14-*-*-*-*-*-iso8859-1");
164 fFrameGroup->AddFrame(fEnt[j]);
165
166 }
167 TGTextButton* bt2 =0;
168 fFrameGroup->AddFrame(bt2 = new TGTextButton(fFrameGroup, "Select Config", 2), fLayout3);
169 bt2->Connect("Clicked()", "AliTPCMonitorDialog", this, "HandleButtons()");
170 fFrameGroup->Resize();
171 }
172 else if(version==3)
173 {
174 // choose component to be displayed /////////////////////////////////////
175 fFrameGroup = new TGGroupFrame(fFrameMain, "Ranges BASE/MAX/SUM ", kVerticalFrame);
176 fFrameGroup->SetTitlePos(TGGroupFrame::kRight);
177 fFrameMain->AddFrame(fFrameGroup, fLayout3);
178 fFrameGroup->SetLayoutManager(new TGMatrixLayout(fFrameGroup, 0, 2, 10));
179
180 Char_t buff[100];
181 Char_t names[3][40] = {
182 "baseline",
183 "maximum adc",
184 "sum adc ",
185 };
186
187 Char_t namebas[40]; sprintf(namebas,"%i,%i",fMonitor->GetRangeBaseMin() , fMonitor->GetRangeBaseMax() );
188 Char_t namemax[40]; sprintf(namemax,"%i,%i",fMonitor->GetRangeMaxAdcMin(), fMonitor->GetRangeMaxAdcMax());
189 Char_t namesum[40]; sprintf(namesum,"%i,%i",fMonitor->GetRangeSumMin() , fMonitor->GetRangeSumMax() );
190
191 for (Int_t j = 0; j < 3; j++) {
192 sprintf(buff, "%s", names[j]);
193 fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(buff)));
194
195 fBuf[j] = new TGTextBuffer(30);
196 if(j==0) fBuf[j]->AddText(0,namebas);
197 if(j==1) fBuf[j]->AddText(0,namemax);
198 if(j==2) fBuf[j]->AddText(0,namesum);
199
200 fEnt[j] = new TGTextEntry(fFrameMain, fBuf[j]);
201 fEnt[j]->Resize(100, fEnt[j]->GetDefaultHeight());
202 fEnt[j]->SetFont("-adobe-courier-bold-r-*-*-14-*-*-*-*-*-iso8859-1");
203 fFrameGroup->AddFrame(fEnt[j]);
204
205 }
206 TGTextButton* bt2 =0;
207 fFrameGroup->AddFrame(bt2 = new TGTextButton(fFrameGroup, "Select Config", 3), fLayout3);
208 bt2->Connect("Clicked()", "AliTPCMonitorDialog", this, "HandleButtons()");
209 fFrameGroup->Resize(100,300);
210 }
211
212 TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
213 kLHintsExpandY, 2, 2, 5, 1);
214 fFrameMain->AddFrame(fTab, fL5);
215 fFrameMain->MapSubwindows();
216 fFrameMain->Resize();
217
218 fFrameMain->CenterOnParent();
219 if( version==3) fFrameMain->SetWindowName("Select Ranges");
220 else if(version==1) fFrameMain->SetWindowName("Select Component");
221 else fFrameMain->SetWindowName("Select Format");
222 fFrameMain->MapWindow();
223}
224
225//_____________________________________________________________________________________________
226AliTPCMonitorDialog::~AliTPCMonitorDialog()
227{
228 // Delete test dialog widgets.
229 fFrameMain->DeleteWindow();
230}
231
232//_____________________________________________________________________________________________
233void AliTPCMonitorDialog::HandleButtons(Int_t id)
234{
235 // Handle different buttons.
236 if (id == -1) {
237 TGButton *btn = (TGButton*) gTQSender;
238 id = btn->WidgetId();
239 }
240
241 switch (id)
242 {
243 case 1:
244 {
245 // Select Format
246 Int_t fsel = fListBox->GetSelected();
247 if(fsel==-1) { AliError("Warning: No Format selected "); }
248 TGLBEntry* libentr = (TGLBEntry*)fListBox->GetEntry(fsel);
249 AliInfo(Form("Selected Format : %i : %s",fsel,libentr->GetTitle()));
250 fMonitor->SetFormat(fsel);
251
252 break;
253 }
254 case 2:
255 {
256 // Select FEE Component
257 Int_t comp_sel=1;
258 Int_t fComponents[10];
259 for(Int_t j = 0; j < 6; j++)
260 {
261 TString s1 = fEnt[j]->GetDisplayText();
262 if(s1=="all"){ fComponents[j] = -1; }
263 else { fComponents[j] = (int)atoi(s1.Data()); }
264 if(
265 j==0 && (fComponents[j] < -1 || fComponents[j]>5000) ||
266 j==1 && (fComponents[j] < -1 || fComponents[j]>5 ) ||
267 j==2 && (fComponents[j] < -1 || fComponents[j]>1 ) ||
268 j==3 && (fComponents[j] < -1 || fComponents[j]>25 ) ||
269 j==4 && (fComponents[j] < -1 || fComponents[j]>6 ) ||
270 j==5 && (fComponents[j] < -1 || fComponents[j]>8 ) )
271 {
272 comp_sel =0;
273 AliError("Settings out of range ( version 2) ");
274 }
275 }
276 if(comp_sel==1)
277 {
278 if(fMonitor!=0 && fMonitor->GetEventProcessed() )fMonitor->ShowSel((Int_t*)fComponents);
279 else AliError("No event processed up to now");
280 }
281 break;
282 }
283 case 3:
284 {
285 // Set Configuration (base, max, sum)
286 Int_t fConfigArr[6];
287
288 string s1((TString)fEnt[0]->GetDisplayText().Data());
289 string s2((TString)fEnt[1]->GetDisplayText().Data());
290 string s3((TString)fEnt[2]->GetDisplayText().Data());
291
292 Int_t error = 1;
293
294 if(s1.find(",")!=string::npos){
295 string sub1_1 = s1.substr(0,s1.find(",")) ;fConfigArr[0] = atoi(sub1_1.data());
296 string sub1_2 = s1.substr(s1.find(",")+1,s1.length() ) ;fConfigArr[1] = atoi(sub1_2.data());
297 if(fConfigArr[0]<fConfigArr[1] && fConfigArr[1]<1024){
298 fMonitor->SetRangeBase(fConfigArr[0],fConfigArr[1]);
299 error=0;
300 }
301 }
302 if(s2.find(",")!=string::npos){
303 string sub2_1 = s2.substr(0,s2.find(",")) ;fConfigArr[2] = atoi(sub2_1.data());
304 string sub2_2 = s2.substr(s2.find(",")+1,s2.length() ) ;fConfigArr[3] = atoi(sub2_2.data());
305 if(fConfigArr[2]<fConfigArr[3] && fConfigArr[3]<1024){
306 fMonitor->SetRangeMax(fConfigArr[2],fConfigArr[3]);
307 error=0;
308 }
309 }
310
311 if(s3.find(",")!=string::npos){
312 string sub3_1 = s3.substr(0,s3.find(",")) ;fConfigArr[4] = atoi(sub3_1.data());
313 string sub3_2 = s3.substr(s3.find(",")+1,s3.length() ) ;fConfigArr[5] = atoi(sub3_2.data());
314 if(fConfigArr[4]<fConfigArr[5] && fConfigArr[5]<1024){
315 fMonitor->SetRangeSum(fConfigArr[4],fConfigArr[5]);
316 error=0;
317 }
318 }
319 if(error!=0) AliError("Settings out of range (version 3)");
320 break;
321 }
322 default:
323 break;
324 }
325}
326
327//_____________________________________________________________________________________________
328void AliTPCMonitorDialog::DoTab(Int_t id)
329{
330 printf("Tab item %d activated\n", id);
331}
332
333//_____________________________________________________________________________________________
334void AliTPCMonitorDialog::DoClose()
335{
336 // Close the dialog window
337 printf("\nTerminating dialog: via window manager\n");
338 CloseWindow();
339 // Close the Ged editor if it was activated.
340 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
341 TVirtualPadEditor::Terminate();
342}
343
344//_____________________________________________________________________________________________
345void AliTPCMonitorDialog::CloseWindow()
346{
347 // Called when window is closed via the window manager.
348 delete this;
349}
350
351//_____________________________________________________________________________________________
352void AliTPCMonitorDialog::DoOK()
353{
354 // Call from OK button
355 printf("\nTerminating dialog: OK pressed\n");
356
357 // The same effect can be obtained by using a singleshot timer:
358 TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()");
359
360 // Close the Ged editor if it was activated.
361 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
362 TVirtualPadEditor::Terminate();
363}
364
365
366//_____________________________________________________________________________________________
367void AliTPCMonitorDialog::DoCancel()
368{
369 // Cancel operation and close the dialog window
370 printf("\nTerminating dialog: Cancel pressed\n");
371 TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()");
372
373 // Close the Ged editor if it was activated.
374 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
375 TVirtualPadEditor::Terminate();
376}
377