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
181 // Choose DATA Format ////////////////////////////////////////////////////
183 TGCompositeFrame* tf = fTab->AddTab("Select Format");
184 fFrameComp = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
185 fFrameComp->AddFrame(bt = new TGTextButton(fFrameComp, "Select Entry", 1), fLayout3);
187 bt->Connect("Clicked()", "AliTPCMonitorDialog", this, "HandleButtons()");
188 fFrameComp->AddFrame(fListBox = new TGListBox(fFrameComp, 1), fLayout3);
189 tf->AddFrame(fFrameComp, fLayout3);
190 sprintf(tmp, "ROOT file "); fListBox->AddEntry(tmp, 0);
191 sprintf(tmp, "DATE file "); fListBox->AddEntry(tmp, 1);
192 sprintf(tmp, "DATE file/stream "); fListBox->AddEntry(tmp, 2);
194 fListBox->Resize(200, 80);
199 // choose component to be displayed /////////////////////////////////////
200 fFrameGroup = new TGGroupFrame(fFrameMain, "Components", kVerticalFrame);
201 fFrameGroup->SetTitlePos(TGGroupFrame::kRight); // right aligned
202 fFrameMain->AddFrame(fFrameGroup, fLayout3);
203 fFrameGroup->SetLayoutManager(new TGMatrixLayout(fFrameGroup, 0, 2, 10));
206 Char_t names[6][40] ={
214 for (Int_t j = 0; j < 6; j++)
216 sprintf(buff, "%s", names[j]);
217 fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(buff)));
219 fBuf[j] = new TGTextBuffer(10);
220 fBuf[j]->AddText(0, "all");
222 fEnt[j] = new TGTextEntry(fFrameMain, fBuf[j]);
223 fEnt[j]->Resize(50, fEnt[j]->GetDefaultHeight());
224 fEnt[j]->SetFont("-adobe-courier-bold-r-*-*-14-*-*-*-*-*-iso8859-1");
225 fFrameGroup->AddFrame(fEnt[j]);
228 TGTextButton* bt2 =0;
229 fFrameGroup->AddFrame(bt2 = new TGTextButton(fFrameGroup, "Select Config", 2), fLayout3);
230 bt2->Connect("Clicked()", "AliTPCMonitorDialog", this, "HandleButtons()");
231 fFrameGroup->Resize();
235 // choose component to be displayed /////////////////////////////////////
236 fFrameGroup = new TGGroupFrame(fFrameMain, "Ranges BASE/MAX/SUM ", kVerticalFrame);
237 fFrameGroup->SetTitlePos(TGGroupFrame::kRight);
238 fFrameMain->AddFrame(fFrameGroup, fLayout3);
239 fFrameGroup->SetLayoutManager(new TGMatrixLayout(fFrameGroup, 0, 2, 10));
242 Char_t names[3][40] = {
248 Char_t namebas[40]; sprintf(namebas,"%i,%i",fMonitor->GetRangeBaseMin() , fMonitor->GetRangeBaseMax() );
249 Char_t namemax[40]; sprintf(namemax,"%i,%i",fMonitor->GetRangeMaxAdcMin(), fMonitor->GetRangeMaxAdcMax());
250 Char_t namesum[40]; sprintf(namesum,"%i,%i",fMonitor->GetRangeSumMin() , fMonitor->GetRangeSumMax() );
252 for (Int_t j = 0; j < 3; j++) {
253 sprintf(buff, "%s", names[j]);
254 fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(buff)));
256 fBuf[j] = new TGTextBuffer(30);
257 if(j==0) fBuf[j]->AddText(0,namebas);
258 if(j==1) fBuf[j]->AddText(0,namemax);
259 if(j==2) fBuf[j]->AddText(0,namesum);
261 fEnt[j] = new TGTextEntry(fFrameMain, fBuf[j]);
262 fEnt[j]->Resize(100, fEnt[j]->GetDefaultHeight());
263 fEnt[j]->SetFont("-adobe-courier-bold-r-*-*-14-*-*-*-*-*-iso8859-1");
264 fFrameGroup->AddFrame(fEnt[j]);
267 TGTextButton* bt2 =0;
268 fFrameGroup->AddFrame(bt2 = new TGTextButton(fFrameGroup, "Select Config", 3), fLayout3);
269 bt2->Connect("Clicked()", "AliTPCMonitorDialog", this, "HandleButtons()");
270 fFrameGroup->Resize(100,300);
273 TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
274 kLHintsExpandY, 2, 2, 5, 1);
275 fFrameMain->AddFrame(fTab, fL5);
276 fFrameMain->MapSubwindows();
277 fFrameMain->Resize();
279 fFrameMain->CenterOnParent();
280 if( version==3) fFrameMain->SetWindowName("Select Ranges");
281 else if(version==1) fFrameMain->SetWindowName("Select Component");
282 else fFrameMain->SetWindowName("Select Format");
283 fFrameMain->MapWindow();
286 //_____________________________________________________________________________________________
287 AliTPCMonitorDialog::~AliTPCMonitorDialog()
289 // Delete test dialog widgets.
290 fFrameMain->DeleteWindow();
293 //_____________________________________________________________________________________________
294 void AliTPCMonitorDialog::HandleButtons(Int_t id)
296 // Handle different buttons.
298 TGButton *btn = (TGButton*) gTQSender;
299 id = btn->WidgetId();
307 Int_t fsel = fListBox->GetSelected();
308 if(fsel==-1) { AliError("Warning: No Format selected "); }
309 TGLBEntry* libentr = (TGLBEntry*)fListBox->GetEntry(fsel);
310 AliInfo(Form("Selected Format : %i : %s",fsel,libentr->GetTitle()));
311 fMonitor->SetFormat(fsel);
317 // Select FEE Component
319 Int_t fComponents[10];
320 for(Int_t j = 0; j < 6; j++)
322 TString s1 = fEnt[j]->GetDisplayText();
323 if(s1=="all"){ fComponents[j] = -1; }
324 else { fComponents[j] = (int)atoi(s1.Data()); }
326 (j==0 && (fComponents[j] < -1 || fComponents[j]>5000)) ||
327 (j==1 && (fComponents[j] < -1 || fComponents[j]>5 )) ||
328 (j==2 && (fComponents[j] < -1 || fComponents[j]>1 )) ||
329 (j==3 && (fComponents[j] < -1 || fComponents[j]>25 )) ||
330 (j==4 && (fComponents[j] < -1 || fComponents[j]>6 )) ||
331 (j==5 && (fComponents[j] < -1 || fComponents[j]>8 )) )
334 AliError("Settings out of range ( version 2) ");
339 if(fMonitor!=0 && fMonitor->GetEventProcessed() )fMonitor->ShowSel((Int_t*)fComponents);
340 else AliError("No event processed up to now");
346 // Set Configuration (base, max, sum)
349 string s1((TString)fEnt[0]->GetDisplayText().Data());
350 string s2((TString)fEnt[1]->GetDisplayText().Data());
351 string s3((TString)fEnt[2]->GetDisplayText().Data());
355 if(s1.find(",")!=string::npos){
356 string sub11 = s1.substr(0,s1.find(",")) ;fConfigArr[0] = atoi(sub11.data());
357 string sub12 = s1.substr(s1.find(",")+1,s1.length() ) ;fConfigArr[1] = atoi(sub12.data());
358 if(fConfigArr[0]<fConfigArr[1] && fConfigArr[1]<1024){
359 fMonitor->SetRangeBase(fConfigArr[0],fConfigArr[1]);
363 if(s2.find(",")!=string::npos){
364 string sub21 = s2.substr(0,s2.find(",")) ;fConfigArr[2] = atoi(sub21.data());
365 string sub22 = s2.substr(s2.find(",")+1,s2.length() ) ;fConfigArr[3] = atoi(sub22.data());
366 if(fConfigArr[2]<fConfigArr[3] && fConfigArr[3]<1024){
367 fMonitor->SetRangeMax(fConfigArr[2],fConfigArr[3]);
372 if(s3.find(",")!=string::npos){
373 string sub31 = s3.substr(0,s3.find(",")) ;fConfigArr[4] = atoi(sub31.data());
374 string sub32 = s3.substr(s3.find(",")+1,s3.length() ) ;fConfigArr[5] = atoi(sub32.data());
375 if(fConfigArr[4]<fConfigArr[5] && fConfigArr[5]<1024){
376 fMonitor->SetRangeSum(fConfigArr[4],fConfigArr[5]);
380 if(error!=0) AliError("Settings out of range (version 3)");
388 //_____________________________________________________________________________________________
389 void AliTPCMonitorDialog::DoTab(Int_t id)
391 printf("Tab item %d activated\n", id);
394 //_____________________________________________________________________________________________
395 void AliTPCMonitorDialog::DoClose() const
397 // Close the dialog window
398 printf("\nTerminating dialog: via window manager\n");
400 // Close the Ged editor if it was activated.
401 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
402 TVirtualPadEditor::Terminate();
405 //_____________________________________________________________________________________________
406 void AliTPCMonitorDialog::CloseWindow() const
408 // Called when window is closed via the window manager.
412 //_____________________________________________________________________________________________
413 void AliTPCMonitorDialog::DoOK()
415 // Call from OK button
416 printf("\nTerminating dialog: OK pressed\n");
418 // The same effect can be obtained by using a singleshot timer:
419 TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()");
421 // Close the Ged editor if it was activated.
422 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
423 TVirtualPadEditor::Terminate();
427 //_____________________________________________________________________________________________
428 void AliTPCMonitorDialog::DoCancel()
430 // Cancel operation and close the dialog window
431 printf("\nTerminating dialog: Cancel pressed\n");
432 TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()");
434 // Close the Ged editor if it was activated.
435 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
436 TVirtualPadEditor::Terminate();