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 **************************************************************************/
21 #include "AliTPCMonitorDialog.h"
24 ClassImp(AliTPCMonitorDialog)
25 //_____________________________________________________________________________________________
26 AliTPCMonitorDialog::AliTPCMonitorDialog(const TGWindow *p, const TGWindow *main, UInt_t w,
27 UInt_t h, UInt_t options, Int_t version,AliTPCMonitor* monitor)
29 // Constructor for Dialog window.
30 // Create a dialog window.depending on the version it is called with..
31 // Verrion 0: Choose DATA Format
32 // Version 1: Choose FEC components to display
33 // Version 2: Choose Ranges for base and max adc calculation
37 fFrameMain = new TGTransientFrame(p, main, w, h, options);
38 fFrameMain->Connect("CloseWindow()", "AliTPCMonitorDialog", this, "DoClose()");
39 fFrameMain->DontCallClose();
40 fFrameMain->SetCleanup(kDeepCleanup);
42 fFrameHor = new TGHorizontalFrame(fFrameMain, 60, 20, kFixedWidth);
43 fOkButton = new TGTextButton(fFrameHor, "&Ok", 1);
44 fOkButton->Connect("Clicked()", "AliTPCMonitorDialog", this, "DoOK()");
46 fLayout1 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2);
47 fLayout2 = new TGLayoutHints(kLHintsBottom | kLHintsRight , 2, 2, 5, 1);
48 fLayout3 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 5, 5, 5, 5);
50 fFrameHor->AddFrame(fOkButton, fLayout1);
51 fFrameHor->Resize(150, fOkButton->GetDefaultHeight());
52 fFrameMain->AddFrame( fFrameHor, fLayout2);
54 fTab = new TGTab(fFrameMain, 300, 300);
55 fTab->Connect("Selected(Int_t)", "AliTPCMonitorDialog", this, "DoTab(Int_t)");
57 CreateDialogVersion(version);
60 //_____________________________________________________________________________________________
61 void AliTPCMonitorDialog::CreateDialogVersion(Int_t version)
63 // Create a dialog window depending on the version passed
68 // Choose DATA Format ////////////////////////////////////////////////////
70 TGCompositeFrame* tf = fTab->AddTab("Select Format");
71 fFrameComp = new TGCompositeFrame(tf, 60, 20, kVerticalFrame);
72 fFrameComp->AddFrame(bt = new TGTextButton(fFrameComp, "Select Entry", 1), fLayout3);
74 bt->Connect("Clicked()", "AliTPCMonitorDialog", this, "HandleButtons()");
75 fFrameComp->AddFrame(fListBox = new TGListBox(fFrameComp, 1), fLayout3);
76 tf->AddFrame(fFrameComp, fLayout3);
77 sprintf(tmp, "ROOT file "); fListBox->AddEntry(tmp, 0);
78 sprintf(tmp, "DATE file "); fListBox->AddEntry(tmp, 1);
79 sprintf(tmp, "DATE file/stream "); fListBox->AddEntry(tmp, 2);
81 fListBox->Resize(200, 80);
86 // choose component to be displayed /////////////////////////////////////
87 fFrameGroup = new TGGroupFrame(fFrameMain, "Components", kVerticalFrame);
88 fFrameGroup->SetTitlePos(TGGroupFrame::kRight); // right aligned
89 fFrameMain->AddFrame(fFrameGroup, fLayout3);
90 fFrameGroup->SetLayoutManager(new TGMatrixLayout(fFrameGroup, 0, 2, 10));
93 Char_t names[6][40] ={
101 for (Int_t j = 0; j < 6; j++)
103 sprintf(buff, "%s", names[j]);
104 fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(buff)));
106 fBuf[j] = new TGTextBuffer(10);
107 fBuf[j]->AddText(0, "all");
109 fEnt[j] = new TGTextEntry(fFrameMain, fBuf[j]);
110 fEnt[j]->Resize(50, fEnt[j]->GetDefaultHeight());
111 fEnt[j]->SetFont("-adobe-courier-bold-r-*-*-14-*-*-*-*-*-iso8859-1");
112 fFrameGroup->AddFrame(fEnt[j]);
115 TGTextButton* bt2 =0;
116 fFrameGroup->AddFrame(bt2 = new TGTextButton(fFrameGroup, "Select Config", 2), fLayout3);
117 bt2->Connect("Clicked()", "AliTPCMonitorDialog", this, "HandleButtons()");
118 fFrameGroup->Resize();
122 // choose component to be displayed /////////////////////////////////////
123 fFrameGroup = new TGGroupFrame(fFrameMain, "Ranges BASE/MAX/SUM ", kVerticalFrame);
124 fFrameGroup->SetTitlePos(TGGroupFrame::kRight);
125 fFrameMain->AddFrame(fFrameGroup, fLayout3);
126 fFrameGroup->SetLayoutManager(new TGMatrixLayout(fFrameGroup, 0, 2, 10));
129 Char_t names[3][40] = {
135 Char_t namebas[40]; sprintf(namebas,"%i,%i",fMonitor->GetRangeBaseMin() , fMonitor->GetRangeBaseMax() );
136 Char_t namemax[40]; sprintf(namemax,"%i,%i",fMonitor->GetRangeMaxAdcMin(), fMonitor->GetRangeMaxAdcMax());
137 Char_t namesum[40]; sprintf(namesum,"%i,%i",fMonitor->GetRangeSumMin() , fMonitor->GetRangeSumMax() );
139 for (Int_t j = 0; j < 3; j++) {
140 sprintf(buff, "%s", names[j]);
141 fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(buff)));
143 fBuf[j] = new TGTextBuffer(30);
144 if(j==0) fBuf[j]->AddText(0,namebas);
145 if(j==1) fBuf[j]->AddText(0,namemax);
146 if(j==2) fBuf[j]->AddText(0,namesum);
148 fEnt[j] = new TGTextEntry(fFrameMain, fBuf[j]);
149 fEnt[j]->Resize(100, fEnt[j]->GetDefaultHeight());
150 fEnt[j]->SetFont("-adobe-courier-bold-r-*-*-14-*-*-*-*-*-iso8859-1");
151 fFrameGroup->AddFrame(fEnt[j]);
154 TGTextButton* bt2 =0;
155 fFrameGroup->AddFrame(bt2 = new TGTextButton(fFrameGroup, "Select Config", 3), fLayout3);
156 bt2->Connect("Clicked()", "AliTPCMonitorDialog", this, "HandleButtons()");
157 fFrameGroup->Resize(100,300);
160 TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
161 kLHintsExpandY, 2, 2, 5, 1);
162 fFrameMain->AddFrame(fTab, fL5);
163 fFrameMain->MapSubwindows();
164 fFrameMain->Resize();
166 fFrameMain->CenterOnParent();
167 if( version==3) fFrameMain->SetWindowName("Select Ranges");
168 else if(version==1) fFrameMain->SetWindowName("Select Component");
169 else fFrameMain->SetWindowName("Select Format");
170 fFrameMain->MapWindow();
173 //_____________________________________________________________________________________________
174 AliTPCMonitorDialog::~AliTPCMonitorDialog()
176 // Delete test dialog widgets.
177 fFrameMain->DeleteWindow();
180 //_____________________________________________________________________________________________
181 void AliTPCMonitorDialog::HandleButtons(Int_t id)
183 // Handle different buttons.
185 TGButton *btn = (TGButton*) gTQSender;
186 id = btn->WidgetId();
194 Int_t fsel = fListBox->GetSelected();
195 if(fsel==-1) { AliError("Warning: No Format selected "); }
196 TGLBEntry* libentr = (TGLBEntry*)fListBox->GetEntry(fsel);
197 AliInfo(Form("Selected Format : %i : %s",fsel,libentr->GetTitle()));
198 fMonitor->SetFormat(fsel);
204 // Select FEE Component
206 Int_t fComponents[10];
207 for(Int_t j = 0; j < 6; j++)
209 TString s1 = fEnt[j]->GetDisplayText();
210 if(s1=="all"){ fComponents[j] = -1; }
211 else { fComponents[j] = (int)atoi(s1.Data()); }
213 j==0 && (fComponents[j] < -1 || fComponents[j]>5000) ||
214 j==1 && (fComponents[j] < -1 || fComponents[j]>5 ) ||
215 j==2 && (fComponents[j] < -1 || fComponents[j]>1 ) ||
216 j==3 && (fComponents[j] < -1 || fComponents[j]>25 ) ||
217 j==4 && (fComponents[j] < -1 || fComponents[j]>6 ) ||
218 j==5 && (fComponents[j] < -1 || fComponents[j]>8 ) )
221 AliError("Settings out of range ( version 2) ");
226 if(fMonitor!=0 && fMonitor->GetEventProcessed() )fMonitor->ShowSel((Int_t*)fComponents);
227 else AliError("No event processed up to now");
233 // Set Configuration (base, max, sum)
236 string s1((TString)fEnt[0]->GetDisplayText().Data());
237 string s2((TString)fEnt[1]->GetDisplayText().Data());
238 string s3((TString)fEnt[2]->GetDisplayText().Data());
242 if(s1.find(",")!=string::npos){
243 string sub1_1 = s1.substr(0,s1.find(",")) ;fConfigArr[0] = atoi(sub1_1.data());
244 string sub1_2 = s1.substr(s1.find(",")+1,s1.length() ) ;fConfigArr[1] = atoi(sub1_2.data());
245 if(fConfigArr[0]<fConfigArr[1] && fConfigArr[1]<1024){
246 fMonitor->SetRangeBase(fConfigArr[0],fConfigArr[1]);
250 if(s2.find(",")!=string::npos){
251 string sub2_1 = s2.substr(0,s2.find(",")) ;fConfigArr[2] = atoi(sub2_1.data());
252 string sub2_2 = s2.substr(s2.find(",")+1,s2.length() ) ;fConfigArr[3] = atoi(sub2_2.data());
253 if(fConfigArr[2]<fConfigArr[3] && fConfigArr[3]<1024){
254 fMonitor->SetRangeMax(fConfigArr[2],fConfigArr[3]);
259 if(s3.find(",")!=string::npos){
260 string sub3_1 = s3.substr(0,s3.find(",")) ;fConfigArr[4] = atoi(sub3_1.data());
261 string sub3_2 = s3.substr(s3.find(",")+1,s3.length() ) ;fConfigArr[5] = atoi(sub3_2.data());
262 if(fConfigArr[4]<fConfigArr[5] && fConfigArr[5]<1024){
263 fMonitor->SetRangeSum(fConfigArr[4],fConfigArr[5]);
267 if(error!=0) AliError("Settings out of range (version 3)");
275 //_____________________________________________________________________________________________
276 void AliTPCMonitorDialog::DoTab(Int_t id)
278 printf("Tab item %d activated\n", id);
281 //_____________________________________________________________________________________________
282 void AliTPCMonitorDialog::DoClose()
284 // Close the dialog window
285 printf("\nTerminating dialog: via window manager\n");
287 // Close the Ged editor if it was activated.
288 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
289 TVirtualPadEditor::Terminate();
292 //_____________________________________________________________________________________________
293 void AliTPCMonitorDialog::CloseWindow()
295 // Called when window is closed via the window manager.
299 //_____________________________________________________________________________________________
300 void AliTPCMonitorDialog::DoOK()
302 // Call from OK button
303 printf("\nTerminating dialog: OK pressed\n");
305 // The same effect can be obtained by using a singleshot timer:
306 TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()");
308 // Close the Ged editor if it was activated.
309 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
310 TVirtualPadEditor::Terminate();
314 //_____________________________________________________________________________________________
315 void AliTPCMonitorDialog::DoCancel()
317 // Cancel operation and close the dialog window
318 printf("\nTerminating dialog: Cancel pressed\n");
319 TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()");
321 // Close the Ged editor if it was activated.
322 if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
323 TVirtualPadEditor::Terminate();