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>
60 ClassImp(AliTPCMonitorDialog)
61 //_____________________________________________________________________________________________
62 AliTPCMonitorDialog::AliTPCMonitorDialog(TGWindow *p, TGWindow *main, UInt_t w,
63 UInt_t h, UInt_t options, Int_t version,AliTPCMonitor* monitor):
65 fFrameMain(new TGTransientFrame(p, main, w, h, options)),
67 fFrameHor(new TGHorizontalFrame(fFrameMain, 60, 20, kFixedWidth)),
69 fOkButton(new TGTextButton(fFrameHor, "&Ok", 1)),
71 fTab(new TGTab(fFrameMain, 300, 300)),
72 fLayout1(new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2)),
73 fLayout2(new TGLayoutHints(kLHintsBottom | kLHintsRight , 2, 2, 5, 1)),
74 fLayout3(new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5)),
83 // Constructor for Dialog window.
84 // Create a dialog window.depending on the version it is called with..
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
89 fFrameMain->Connect("CloseWindow()", "AliTPCMonitorDialog", this, "DoClose()");
90 fFrameMain->DontCallClose();
91 fFrameMain->SetCleanup(kDeepCleanup);
92 fOkButton->Connect("Clicked()", "AliTPCMonitorDialog", this, "DoOK()");
93 fFrameHor->AddFrame(fOkButton, fLayout1);
94 fFrameHor->Resize(150, fOkButton->GetDefaultHeight());
95 fFrameMain->AddFrame( fFrameHor, fLayout2);
96 fTab->Connect("Selected(Int_t)", "AliTPCMonitorDialog", this, "DoTab(Int_t)");
97 CreateDialogVersion(version);
100 //_____________________________________________________________________________
101 AliTPCMonitorDialog::AliTPCMonitorDialog(const AliTPCMonitorDialog &dialog) :
102 TNamed(dialog.GetName(),dialog.GetTitle()),
104 fFrameMain(new TGTransientFrame(dialog.GetClient(), dialog.GetMainFrame(), dialog.GetWidth(), dialog.GetHeight())),
106 fFrameHor(new TGHorizontalFrame(fFrameMain, 60, 20, kFixedWidth)),
108 fOkButton(new TGTextButton(fFrameHor, "&Ok", 1)),
110 fTab(new TGTab(fFrameMain, 300, 300)),
111 fLayout1(new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2)),
112 fLayout2(new TGLayoutHints(kLHintsBottom | kLHintsRight , 2, 2, 5, 1)),
113 fLayout3(new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5)),
114 fMonitor(dialog.GetMonitor()),
115 fWidth(dialog.GetWidth()),
116 fHeight(dialog.GetHeight()),
117 fOptions(dialog.GetOptions()),
118 fVersion(dialog.GetVersion()),
119 fClient(dialog.GetClient()),
120 fMain(dialog.GetMainFrame())
122 // copy constructor (actually none forseen for this class)
123 fFrameMain->Connect("CloseWindow()", "AliTPCMonitorDialog", this, "DoClose()");
124 fFrameMain->DontCallClose();
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());
135 //_____________________________________________________________________________
136 AliTPCMonitorDialog &AliTPCMonitorDialog::operator =(const AliTPCMonitorDialog& dialog)
138 // assignement operator (actually none forseen for this class)
141 fFrameMain = new TGTransientFrame(dialog.GetClient(), dialog.GetMainFrame(), dialog.GetWidth(), dialog.GetHeight());
143 fFrameHor = new TGHorizontalFrame(fFrameMain, 60, 20, kFixedWidth);
145 fOkButton = new TGTextButton(fFrameHor, "&Ok", 1);
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());
173 //_____________________________________________________________________________________________
174 void AliTPCMonitorDialog::CreateDialogVersion(Int_t version)
176 // Create a dialog window depending on the version passed
180 // Choose DATA Format ////////////////////////////////////////////////////
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);
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);
193 fListBox->Resize(200, 80);
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));
204 const Char_t names[6][40] ={
212 for (Int_t j = 0; j < 6; j++)
214 fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(names[j])));
216 fBuf[j] = new TGTextBuffer(10);
217 fBuf[j]->AddText(0, "all");
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]);
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();
232 // choose component to be displayed /////////////////////////////////////
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));
238 const Char_t names[3][40] = {
244 for (Int_t j = 0; j < 3; j++) {
245 fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(names[j])));
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()));
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]);
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);
264 TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
265 kLHintsExpandY, 2, 2, 5, 1);
266 fFrameMain->AddFrame(fTab, fL5);
267 fFrameMain->MapSubwindows();
268 fFrameMain->Resize();
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();
277 //_____________________________________________________________________________________________
278 AliTPCMonitorDialog::~AliTPCMonitorDialog()
280 // Delete test dialog widgets.
281 fFrameMain->DeleteWindow();
284 //_____________________________________________________________________________________________
285 void AliTPCMonitorDialog::HandleButtons(Int_t id)
287 // Handle different buttons.
289 TGButton *btn = (TGButton*) gTQSender;
290 id = btn->WidgetId();
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);
308 // Select FEE Component
310 Int_t fComponents[10];
311 for(Int_t j = 0; j < 6; j++)
313 TString s1 = fEnt[j]->GetDisplayText();
314 if(s1=="all"){ fComponents[j] = -1; }
315 else { fComponents[j] = (int)atoi(s1.Data()); }
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 )) )
325 AliError("Settings out of range ( version 2) ");
330 if(fMonitor!=0 && fMonitor->GetEventProcessed() )fMonitor->ShowSel((Int_t*)fComponents);
331 else AliError("No event processed up to now");
337 // Set Configuration (base, max, sum)
340 string s1((TString)fEnt[0]->GetDisplayText().Data());
341 string s2((TString)fEnt[1]->GetDisplayText().Data());
342 string s3((TString)fEnt[2]->GetDisplayText().Data());
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]);
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]);
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]);
371 if(error!=0) AliError("Settings out of range (version 3)");
379 //_____________________________________________________________________________________________
380 void AliTPCMonitorDialog::DoTab(Int_t id)
382 printf("Tab item %d activated\n", id);
385 //_____________________________________________________________________________________________
386 void AliTPCMonitorDialog::DoClose() const
388 // Close the dialog window
389 printf("\nTerminating dialog: via window manager\n");
391 // Close the Ged editor if it was activated.
392 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
393 TVirtualPadEditor::Terminate();
396 //_____________________________________________________________________________________________
397 void AliTPCMonitorDialog::CloseWindow() const
399 // Called when window is closed via the window manager.
403 //_____________________________________________________________________________________________
404 void AliTPCMonitorDialog::DoOK()
406 // Call from OK button
407 printf("\nTerminating dialog: OK pressed\n");
409 // The same effect can be obtained by using a singleshot timer:
410 TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()");
412 // Close the Ged editor if it was activated.
413 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
414 TVirtualPadEditor::Terminate();
418 //_____________________________________________________________________________________________
419 void AliTPCMonitorDialog::DoCancel()
421 // Cancel operation and close the dialog window
422 printf("\nTerminating dialog: Cancel pressed\n");
423 TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()");
425 // Close the Ged editor if it was activated.
426 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
427 TVirtualPadEditor::Terminate();