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 "RQ_OBJECT.h"
56 #include <Riostream.h>
60 ClassImp(AliTPCMonitorDialog)
61 //_____________________________________________________________________________________________
62 AliTPCMonitorDialog::AliTPCMonitorDialog(const TGWindow *p, const TGWindow *main, UInt_t w,
63 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)),
77 // Constructor for Dialog window.
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
83 fFrameMain->Connect("CloseWindow()", "AliTPCMonitorDialog", this, "DoClose()");
84 fFrameMain->DontCallClose();
85 fFrameMain->SetCleanup(kDeepCleanup);
86 fOkButton->Connect("Clicked()", "AliTPCMonitorDialog", this, "DoOK()");
87 fFrameHor->AddFrame(fOkButton, fLayout1);
88 fFrameHor->Resize(150, fOkButton->GetDefaultHeight());
89 fFrameMain->AddFrame( fFrameHor, fLayout2);
90 fTab->Connect("Selected(Int_t)", "AliTPCMonitorDialog", this, "DoTab(Int_t)");
91 CreateDialogVersion(version);
94 // //_____________________________________________________________________________
95 // AliTPCMonitorDialog::AliTPCMonitorDialog(const AliTPCMonitorDialog &dialog) :
97 // // copy constructor (actually none forseen for this class
98 // AliWarning("No copying forseen for this class");
102 // //_____________________________________________________________________________
103 // AliTPCMonitorDialog &AliTPCMonitorDialog::operator =(const AliTPCMonitorDialog& dialog)
105 // // assignement operator
106 // AliWarning("No assignment forseen for this class");
112 //_____________________________________________________________________________________________
113 void AliTPCMonitorDialog::CreateDialogVersion(Int_t version)
115 // Create a dialog window depending on the version passed
120 // Choose DATA Format ////////////////////////////////////////////////////
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);
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);
133 fListBox->Resize(200, 80);
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));
145 Char_t names[6][40] ={
153 for (Int_t j = 0; j < 6; j++)
155 sprintf(buff, "%s", names[j]);
156 fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(buff)));
158 fBuf[j] = new TGTextBuffer(10);
159 fBuf[j]->AddText(0, "all");
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]);
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();
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));
181 Char_t names[3][40] = {
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() );
191 for (Int_t j = 0; j < 3; j++) {
192 sprintf(buff, "%s", names[j]);
193 fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(buff)));
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);
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]);
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);
212 TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
213 kLHintsExpandY, 2, 2, 5, 1);
214 fFrameMain->AddFrame(fTab, fL5);
215 fFrameMain->MapSubwindows();
216 fFrameMain->Resize();
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();
225 //_____________________________________________________________________________________________
226 AliTPCMonitorDialog::~AliTPCMonitorDialog()
228 // Delete test dialog widgets.
229 fFrameMain->DeleteWindow();
232 //_____________________________________________________________________________________________
233 void AliTPCMonitorDialog::HandleButtons(Int_t id)
235 // Handle different buttons.
237 TGButton *btn = (TGButton*) gTQSender;
238 id = btn->WidgetId();
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);
256 // Select FEE Component
258 Int_t fComponents[10];
259 for(Int_t j = 0; j < 6; j++)
261 TString s1 = fEnt[j]->GetDisplayText();
262 if(s1=="all"){ fComponents[j] = -1; }
263 else { fComponents[j] = (int)atoi(s1.Data()); }
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 ) )
273 AliError("Settings out of range ( version 2) ");
278 if(fMonitor!=0 && fMonitor->GetEventProcessed() )fMonitor->ShowSel((Int_t*)fComponents);
279 else AliError("No event processed up to now");
285 // Set Configuration (base, max, sum)
288 string s1((TString)fEnt[0]->GetDisplayText().Data());
289 string s2((TString)fEnt[1]->GetDisplayText().Data());
290 string s3((TString)fEnt[2]->GetDisplayText().Data());
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]);
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]);
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]);
319 if(error!=0) AliError("Settings out of range (version 3)");
327 //_____________________________________________________________________________________________
328 void AliTPCMonitorDialog::DoTab(Int_t id)
330 printf("Tab item %d activated\n", id);
333 //_____________________________________________________________________________________________
334 void AliTPCMonitorDialog::DoClose()
336 // Close the dialog window
337 printf("\nTerminating dialog: via window manager\n");
339 // Close the Ged editor if it was activated.
340 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
341 TVirtualPadEditor::Terminate();
344 //_____________________________________________________________________________________________
345 void AliTPCMonitorDialog::CloseWindow()
347 // Called when window is closed via the window manager.
351 //_____________________________________________________________________________________________
352 void AliTPCMonitorDialog::DoOK()
354 // Call from OK button
355 printf("\nTerminating dialog: OK pressed\n");
357 // The same effect can be obtained by using a singleshot timer:
358 TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()");
360 // Close the Ged editor if it was activated.
361 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
362 TVirtualPadEditor::Terminate();
366 //_____________________________________________________________________________________________
367 void AliTPCMonitorDialog::DoCancel()
369 // Cancel operation and close the dialog window
370 printf("\nTerminating dialog: Cancel pressed\n");
371 TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()");
373 // Close the Ged editor if it was activated.
374 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
375 TVirtualPadEditor::Terminate();