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 /////////////////////////////////////////////////////////////////////////
44 #include "AliTPCMonitorDialog.h"
48 #include "TGListBox.h"
50 #include "TGTextBuffer.h"
51 #include "TGTextEntry.h"
53 #include "TVirtualPadEditor.h"
55 #include <Riostream.h>
59 ClassImp(AliTPCMonitorDialog)
60 //_____________________________________________________________________________________________
61 AliTPCMonitorDialog::AliTPCMonitorDialog(TGWindow *p, TGWindow *main, UInt_t w,
62 UInt_t h, UInt_t options, Int_t version,AliTPCMonitor* monitor):
64 fFrameMain(new TGTransientFrame(p, main, w, h, options)),
66 fFrameHor(new TGHorizontalFrame(fFrameMain, 60, 20, kFixedWidth)),
68 fOkButton(new TGTextButton(fFrameHor, "&Ok", 1)),
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)),
82 // Constructor for Dialog window.
83 // Create a dialog window.depending on the version it is called with..
84 // Verrion 0: Choose DATA Format
85 // Version 1: Choose FEC components to display
86 // Version 2: Choose Ranges for base and max adc calculation
88 fFrameMain->Connect("CloseWindow()", "AliTPCMonitorDialog", this, "DoClose()");
89 fFrameMain->DontCallClose();
90 fFrameMain->SetCleanup(kDeepCleanup);
91 fOkButton->Connect("Clicked()", "AliTPCMonitorDialog", this, "DoOK()");
92 fFrameHor->AddFrame(fOkButton, fLayout1);
93 fFrameHor->Resize(150, fOkButton->GetDefaultHeight());
94 fFrameMain->AddFrame( fFrameHor, fLayout2);
95 fTab->Connect("Selected(Int_t)", "AliTPCMonitorDialog", this, "DoTab(Int_t)");
96 CreateDialogVersion(version);
99 //_____________________________________________________________________________
100 AliTPCMonitorDialog::AliTPCMonitorDialog(const AliTPCMonitorDialog &dialog) :
101 TNamed(dialog.GetName(),dialog.GetTitle()),
103 fFrameMain(new TGTransientFrame(dialog.GetClient(), dialog.GetMainFrame(), dialog.GetWidth(), dialog.GetHeight())),
105 fFrameHor(new TGHorizontalFrame(fFrameMain, 60, 20, kFixedWidth)),
107 fOkButton(new TGTextButton(fFrameHor, "&Ok", 1)),
109 fTab(new TGTab(fFrameMain, 300, 300)),
110 fLayout1(new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2)),
111 fLayout2(new TGLayoutHints(kLHintsBottom | kLHintsRight , 2, 2, 5, 1)),
112 fLayout3(new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5)),
113 fMonitor(dialog.GetMonitor()),
114 fWidth(dialog.GetWidth()),
115 fHeight(dialog.GetHeight()),
116 fOptions(dialog.GetOptions()),
117 fVersion(dialog.GetVersion()),
118 fClient(dialog.GetClient()),
119 fMain(dialog.GetMainFrame())
121 // copy constructor (actually none forseen for this class)
122 fFrameMain->Connect("CloseWindow()", "AliTPCMonitorDialog", this, "DoClose()");
123 fFrameMain->DontCallClose();
124 fFrameMain->SetCleanup(kDeepCleanup);
125 fOkButton->Connect("Clicked()", "AliTPCMonitorDialog", this, "DoOK()");
126 fFrameHor->AddFrame(fOkButton, fLayout1);
127 fFrameHor->Resize(150, fOkButton->GetDefaultHeight());
128 fFrameMain->AddFrame( fFrameHor, fLayout2);
129 fTab->Connect("Selected(Int_t)", "AliTPCMonitorDialog", this, "DoTab(Int_t)");
130 CreateDialogVersion(dialog.GetVersion());
134 //_____________________________________________________________________________
135 AliTPCMonitorDialog &AliTPCMonitorDialog::operator =(const AliTPCMonitorDialog& dialog)
137 // assignement operator (actually none forseen for this class)
140 fFrameMain = new TGTransientFrame(dialog.GetClient(), dialog.GetMainFrame(), dialog.GetWidth(), dialog.GetHeight());
142 fFrameHor = new TGHorizontalFrame(fFrameMain, 60, 20, kFixedWidth);
144 fOkButton = new TGTextButton(fFrameHor, "&Ok", 1);
146 fTab = new TGTab(fFrameMain, 300, 300);
147 fLayout1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2);
148 fLayout2 = new TGLayoutHints(kLHintsBottom | kLHintsRight , 2, 2, 5, 1);
149 fLayout3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
150 fMonitor = dialog.GetMonitor();
151 fWidth = dialog.GetWidth();
152 fHeight = dialog.GetHeight();
153 fOptions = dialog.GetOptions();
154 fClient = dialog.GetClient();
155 fVersion = dialog.GetVersion();
156 fMain = dialog.GetMainFrame();
157 fFrameMain->Connect("CloseWindow()", "AliTPCMonitorDialog", this, "DoClose()");
158 fFrameMain->DontCallClose();
159 fFrameMain->SetCleanup(kDeepCleanup);
160 fOkButton->Connect("Clicked()", "AliTPCMonitorDialog", this, "DoOK()");
161 fFrameHor->AddFrame(fOkButton, fLayout1);
162 fFrameHor->Resize(150, fOkButton->GetDefaultHeight());
163 fFrameMain->AddFrame( fFrameHor, fLayout2);
164 fTab->Connect("Selected(Int_t)", "AliTPCMonitorDialog", this, "DoTab(Int_t)");
165 CreateDialogVersion(dialog.GetVersion());
172 //_____________________________________________________________________________________________
173 void AliTPCMonitorDialog::CreateDialogVersion(Int_t version)
175 // 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 sprintf(tmp, "ROOT file "); fListBox->AddEntry(tmp, 0);
190 sprintf(tmp, "DATE file "); fListBox->AddEntry(tmp, 1);
191 sprintf(tmp, "DATE file/stream "); fListBox->AddEntry(tmp, 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));
205 Char_t names[6][40] ={
213 for (Int_t j = 0; j < 6; j++)
215 sprintf(buff, "%s", names[j]);
216 fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(buff)));
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));
241 Char_t names[3][40] = {
247 Char_t namebas[40]; sprintf(namebas,"%i,%i",fMonitor->GetRangeBaseMin() , fMonitor->GetRangeBaseMax() );
248 Char_t namemax[40]; sprintf(namemax,"%i,%i",fMonitor->GetRangeMaxAdcMin(), fMonitor->GetRangeMaxAdcMax());
249 Char_t namesum[40]; sprintf(namesum,"%i,%i",fMonitor->GetRangeSumMin() , fMonitor->GetRangeSumMax() );
251 for (Int_t j = 0; j < 3; j++) {
252 sprintf(buff, "%s", names[j]);
253 fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(buff)));
255 fBuf[j] = new TGTextBuffer(30);
256 if(j==0) fBuf[j]->AddText(0,namebas);
257 if(j==1) fBuf[j]->AddText(0,namemax);
258 if(j==2) fBuf[j]->AddText(0,namesum);
260 fEnt[j] = new TGTextEntry(fFrameMain, fBuf[j]);
261 fEnt[j]->Resize(100, fEnt[j]->GetDefaultHeight());
262 fEnt[j]->SetFont("-adobe-courier-bold-r-*-*-14-*-*-*-*-*-iso8859-1");
263 fFrameGroup->AddFrame(fEnt[j]);
266 TGTextButton* bt2 =0;
267 fFrameGroup->AddFrame(bt2 = new TGTextButton(fFrameGroup, "Select Config", 3), fLayout3);
268 bt2->Connect("Clicked()", "AliTPCMonitorDialog", this, "HandleButtons()");
269 fFrameGroup->Resize(100,300);
272 TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
273 kLHintsExpandY, 2, 2, 5, 1);
274 fFrameMain->AddFrame(fTab, fL5);
275 fFrameMain->MapSubwindows();
276 fFrameMain->Resize();
278 fFrameMain->CenterOnParent();
279 if( version==3) fFrameMain->SetWindowName("Select Ranges");
280 else if(version==1) fFrameMain->SetWindowName("Select Component");
281 else fFrameMain->SetWindowName("Select Format");
282 fFrameMain->MapWindow();
285 //_____________________________________________________________________________________________
286 AliTPCMonitorDialog::~AliTPCMonitorDialog()
288 // Delete test dialog widgets.
289 fFrameMain->DeleteWindow();
292 //_____________________________________________________________________________________________
293 void AliTPCMonitorDialog::HandleButtons(Int_t id)
295 // Handle different buttons.
297 TGButton *btn = (TGButton*) gTQSender;
298 id = btn->WidgetId();
306 Int_t fsel = fListBox->GetSelected();
307 if(fsel==-1) { AliError("Warning: No Format selected "); }
308 TGLBEntry* libentr = (TGLBEntry*)fListBox->GetEntry(fsel);
309 AliInfo(Form("Selected Format : %i : %s",fsel,libentr->GetTitle()));
310 fMonitor->SetFormat(fsel);
316 // Select FEE Component
318 Int_t fComponents[10];
319 for(Int_t j = 0; j < 6; j++)
321 TString s1 = fEnt[j]->GetDisplayText();
322 if(s1=="all"){ fComponents[j] = -1; }
323 else { fComponents[j] = (int)atoi(s1.Data()); }
325 j==0 && (fComponents[j] < -1 || fComponents[j]>5000) ||
326 j==1 && (fComponents[j] < -1 || fComponents[j]>5 ) ||
327 j==2 && (fComponents[j] < -1 || fComponents[j]>1 ) ||
328 j==3 && (fComponents[j] < -1 || fComponents[j]>25 ) ||
329 j==4 && (fComponents[j] < -1 || fComponents[j]>6 ) ||
330 j==5 && (fComponents[j] < -1 || fComponents[j]>8 ) )
333 AliError("Settings out of range ( version 2) ");
338 if(fMonitor!=0 && fMonitor->GetEventProcessed() )fMonitor->ShowSel((Int_t*)fComponents);
339 else AliError("No event processed up to now");
345 // Set Configuration (base, max, sum)
348 string s1((TString)fEnt[0]->GetDisplayText().Data());
349 string s2((TString)fEnt[1]->GetDisplayText().Data());
350 string s3((TString)fEnt[2]->GetDisplayText().Data());
354 if(s1.find(",")!=string::npos){
355 string sub11 = s1.substr(0,s1.find(",")) ;fConfigArr[0] = atoi(sub11.data());
356 string sub12 = s1.substr(s1.find(",")+1,s1.length() ) ;fConfigArr[1] = atoi(sub12.data());
357 if(fConfigArr[0]<fConfigArr[1] && fConfigArr[1]<1024){
358 fMonitor->SetRangeBase(fConfigArr[0],fConfigArr[1]);
362 if(s2.find(",")!=string::npos){
363 string sub21 = s2.substr(0,s2.find(",")) ;fConfigArr[2] = atoi(sub21.data());
364 string sub22 = s2.substr(s2.find(",")+1,s2.length() ) ;fConfigArr[3] = atoi(sub22.data());
365 if(fConfigArr[2]<fConfigArr[3] && fConfigArr[3]<1024){
366 fMonitor->SetRangeMax(fConfigArr[2],fConfigArr[3]);
371 if(s3.find(",")!=string::npos){
372 string sub31 = s3.substr(0,s3.find(",")) ;fConfigArr[4] = atoi(sub31.data());
373 string sub32 = s3.substr(s3.find(",")+1,s3.length() ) ;fConfigArr[5] = atoi(sub32.data());
374 if(fConfigArr[4]<fConfigArr[5] && fConfigArr[5]<1024){
375 fMonitor->SetRangeSum(fConfigArr[4],fConfigArr[5]);
379 if(error!=0) AliError("Settings out of range (version 3)");
387 //_____________________________________________________________________________________________
388 void AliTPCMonitorDialog::DoTab(Int_t id)
390 printf("Tab item %d activated\n", id);
393 //_____________________________________________________________________________________________
394 void AliTPCMonitorDialog::DoClose() const
396 // Close the dialog window
397 printf("\nTerminating dialog: via window manager\n");
399 // Close the Ged editor if it was activated.
400 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
401 TVirtualPadEditor::Terminate();
404 //_____________________________________________________________________________________________
405 void AliTPCMonitorDialog::CloseWindow() const
407 // Called when window is closed via the window manager.
411 //_____________________________________________________________________________________________
412 void AliTPCMonitorDialog::DoOK()
414 // Call from OK button
415 printf("\nTerminating dialog: OK pressed\n");
417 // The same effect can be obtained by using a singleshot timer:
418 TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()");
420 // Close the Ged editor if it was activated.
421 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
422 TVirtualPadEditor::Terminate();
426 //_____________________________________________________________________________________________
427 void AliTPCMonitorDialog::DoCancel()
429 // Cancel operation and close the dialog window
430 printf("\nTerminating dialog: Cancel pressed\n");
431 TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()");
433 // Close the Ged editor if it was activated.
434 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
435 TVirtualPadEditor::Terminate();