1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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.
23 ////////////////////////////////////////////////////////////////////////
25 //// AliTPCMonitorDialog class
27 //// Class to handle dialogs for settings of files and configurations
28 //// for the AliTPCMonitor
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.
36 //// Author: Stefan Kniege, IKF, Frankfurt
39 /////////////////////////////////////////////////////////////////////////
45 #include "AliTPCMonitorDialog.h"
49 #include "TGListBox.h"
51 #include "TGTextBuffer.h"
52 #include "TGTextEntry.h"
54 #include "TVirtualPadEditor.h"
56 #include <Riostream.h>
62 ClassImp(AliTPCMonitorDialog)
63 //_____________________________________________________________________________________________
64 AliTPCMonitorDialog::AliTPCMonitorDialog(TGWindow *p, TGWindow *main, UInt_t w,
65 UInt_t h, UInt_t options, Int_t version,AliTPCMonitor* monitor):
67 fFrameMain(new TGTransientFrame(p, main, w, h, options)),
69 fFrameHor(new TGHorizontalFrame(fFrameMain, 60, 20, kFixedWidth)),
71 fOkButton(new TGTextButton(fFrameHor, "&Ok", 1)),
73 fTab(new TGTab(fFrameMain, 300, 300)),
74 fLayout1(new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2)),
75 fLayout2(new TGLayoutHints(kLHintsBottom | kLHintsRight , 2, 2, 5, 1)),
76 fLayout3(new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5)),
85 // Constructor for Dialog window.
86 // Create a dialog window.depending on the version it is called with..
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
91 fFrameMain->Connect("CloseWindow()", "AliTPCMonitorDialog", this, "DoClose()");
92 fFrameMain->DontCallClose();
93 fFrameMain->SetCleanup(kDeepCleanup);
94 fOkButton->Connect("Clicked()", "AliTPCMonitorDialog", this, "DoOK()");
95 fFrameHor->AddFrame(fOkButton, fLayout1);
96 fFrameHor->Resize(150, fOkButton->GetDefaultHeight());
97 fFrameMain->AddFrame( fFrameHor, fLayout2);
98 fTab->Connect("Selected(Int_t)", "AliTPCMonitorDialog", this, "DoTab(Int_t)");
99 CreateDialogVersion(version);
102 //_____________________________________________________________________________
103 AliTPCMonitorDialog::AliTPCMonitorDialog(const AliTPCMonitorDialog &dialog) :
104 TNamed(dialog.GetName(),dialog.GetTitle()),
106 fFrameMain(new TGTransientFrame(dialog.GetClient(), dialog.GetMainFrame(), dialog.GetWidth(), dialog.GetHeight())),
108 fFrameHor(new TGHorizontalFrame(fFrameMain, 60, 20, kFixedWidth)),
110 fOkButton(new TGTextButton(fFrameHor, "&Ok", 1)),
112 fTab(new TGTab(fFrameMain, 300, 300)),
113 fLayout1(new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2)),
114 fLayout2(new TGLayoutHints(kLHintsBottom | kLHintsRight , 2, 2, 5, 1)),
115 fLayout3(new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5)),
116 fMonitor(dialog.GetMonitor()),
117 fWidth(dialog.GetWidth()),
118 fHeight(dialog.GetHeight()),
119 fOptions(dialog.GetOptions()),
120 fVersion(dialog.GetVersion()),
121 fClient(dialog.GetClient()),
122 fMain(dialog.GetMainFrame())
124 // copy constructor (actually none forseen for this class)
125 fFrameMain->Connect("CloseWindow()", "AliTPCMonitorDialog", this, "DoClose()");
126 fFrameMain->DontCallClose();
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());
137 //_____________________________________________________________________________
138 AliTPCMonitorDialog &AliTPCMonitorDialog::operator =(const AliTPCMonitorDialog& dialog)
140 // assignement operator (actually none forseen for this class)
143 fFrameMain = new TGTransientFrame(dialog.GetClient(), dialog.GetMainFrame(), dialog.GetWidth(), dialog.GetHeight());
145 fFrameHor = new TGHorizontalFrame(fFrameMain, 60, 20, kFixedWidth);
147 fOkButton = new TGTextButton(fFrameHor, "&Ok", 1);
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());
175 //_____________________________________________________________________________________________
176 void AliTPCMonitorDialog::CreateDialogVersion(Int_t version)
178 // Create a dialog window depending on the version passed
182 // Choose DATA Format ////////////////////////////////////////////////////
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);
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);
195 fListBox->Resize(200, 80);
200 // choose component to be displayed /////////////////////////////////////
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));
206 const Char_t names[6][40] ={
214 for (Int_t j = 0; j < 6; j++)
216 fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(names[j])));
218 fBuf[j] = new TGTextBuffer(10);
219 fBuf[j]->AddText(0, "all");
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]);
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();
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));
240 const Char_t names[3][40] = {
246 for (Int_t j = 0; j < 3; j++) {
247 fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(names[j])));
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()));
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]);
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);
266 TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
267 kLHintsExpandY, 2, 2, 5, 1);
268 fFrameMain->AddFrame(fTab, fL5);
269 fFrameMain->MapSubwindows();
270 fFrameMain->Resize();
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();
279 //_____________________________________________________________________________________________
280 AliTPCMonitorDialog::~AliTPCMonitorDialog()
282 // Delete test dialog widgets.
283 fFrameMain->DeleteWindow();
286 //_____________________________________________________________________________________________
287 void AliTPCMonitorDialog::HandleButtons(Int_t id)
289 // Handle different buttons.
291 TGButton *btn = (TGButton*) gTQSender;
292 id = btn->WidgetId();
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);
310 // Select FEE Component
312 Int_t fComponents[10];
313 for(Int_t j = 0; j < 6; j++)
315 TString s1 = fEnt[j]->GetDisplayText();
316 if(s1=="all"){ fComponents[j] = -1; }
317 else { fComponents[j] = (int)atoi(s1.Data()); }
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 )) )
327 AliError("Settings out of range ( version 2) ");
332 if(fMonitor!=0 && fMonitor->GetEventProcessed() )fMonitor->ShowSel((Int_t*)fComponents);
333 else AliError("No event processed up to now");
339 // Set Configuration (base, max, sum)
342 string s1((TString)fEnt[0]->GetDisplayText().Data());
343 string s2((TString)fEnt[1]->GetDisplayText().Data());
344 string s3((TString)fEnt[2]->GetDisplayText().Data());
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]);
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]);
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]);
373 if(error!=0) AliError("Settings out of range (version 3)");
381 //_____________________________________________________________________________________________
382 void AliTPCMonitorDialog::DoTab(Int_t id)
384 printf("Tab item %d activated\n", id);
387 //_____________________________________________________________________________________________
388 void AliTPCMonitorDialog::DoClose() const
390 // Close the dialog window
391 printf("\nTerminating dialog: via window manager\n");
393 // Close the Ged editor if it was activated.
394 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
395 TVirtualPadEditor::Terminate();
398 //_____________________________________________________________________________________________
399 void AliTPCMonitorDialog::CloseWindow() const
401 // Called when window is closed via the window manager.
405 //_____________________________________________________________________________________________
406 void AliTPCMonitorDialog::DoOK()
408 // Call from OK button
409 printf("\nTerminating dialog: OK pressed\n");
411 // The same effect can be obtained by using a singleshot timer:
412 TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()");
414 // Close the Ged editor if it was activated.
415 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
416 TVirtualPadEditor::Terminate();
420 //_____________________________________________________________________________________________
421 void AliTPCMonitorDialog::DoCancel()
423 // Cancel operation and close the dialog window
424 printf("\nTerminating dialog: Cancel pressed\n");
425 TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()");
427 // Close the Ged editor if it was activated.
428 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
429 TVirtualPadEditor::Terminate();