]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCMonitorDialog.cxx
removinf effc++ warnings (Marian)
[u/mrichter/AliRoot.git] / TPC / AliTPCMonitorDialog.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /*
17 $Log$
18 */ 
19
20
21 #include "AliTPCMonitorDialog.h"
22 #include "Rtypes.h"
23 #include "AliLog.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)
28 {
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
34
35   fMonitor  = monitor; 
36   
37   fFrameMain = new TGTransientFrame(p, main, w, h, options);
38   fFrameMain->Connect("CloseWindow()", "AliTPCMonitorDialog", this, "DoClose()");
39   fFrameMain->DontCallClose(); 
40   fFrameMain->SetCleanup(kDeepCleanup);
41   
42   fFrameHor      = new TGHorizontalFrame(fFrameMain, 60, 20, kFixedWidth);
43   fOkButton      = new TGTextButton(fFrameHor, "&Ok", 1);
44   fOkButton->Connect("Clicked()", "AliTPCMonitorDialog", this, "DoOK()");
45
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);
49
50   fFrameHor->AddFrame(fOkButton, fLayout1);
51   fFrameHor->Resize(150, fOkButton->GetDefaultHeight());
52   fFrameMain->AddFrame(    fFrameHor, fLayout2);
53   
54   fTab      = new TGTab(fFrameMain, 300, 300);
55   fTab->Connect("Selected(Int_t)", "AliTPCMonitorDialog", this, "DoTab(Int_t)");
56   
57   CreateDialogVersion(version);
58 }
59
60 //_____________________________________________________________________________________________
61 void AliTPCMonitorDialog::CreateDialogVersion(Int_t version)
62 {
63   // Create a dialog window depending on the version passed
64
65   Char_t tmp[256];
66   if(version==1)
67     { 
68       // Choose DATA Format ////////////////////////////////////////////////////
69       TGTextButton *bt;
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);
73       
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);
80       
81       fListBox->Resize(200, 80);
82       
83     }
84   else if(version==2)
85     { 
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));
91       
92       Char_t buff[100];
93       Char_t names[6][40] ={
94           "FEC (global)",
95           "RCU (patch) ",
96           "Branch      ",
97           "FEC (local) ",
98           "Connector   ",
99           "Chip        "
100         };
101       for (Int_t j = 0; j < 6; j++) 
102         {
103           sprintf(buff, "%s", names[j]);
104           fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(buff)));
105           
106           fBuf[j] = new TGTextBuffer(10);
107           fBuf[j]->AddText(0, "all");
108           
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]);
113           
114         }
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();
119     }
120   else if(version==3)
121     { 
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));
127       
128       Char_t buff[100];
129       Char_t names[3][40] = {
130           "baseline",
131           "maximum adc",
132           "sum adc ",
133         };
134       
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()   );
138       
139       for (Int_t j = 0; j < 3; j++) {
140         sprintf(buff, "%s", names[j]);
141         fFrameGroup->AddFrame(new TGLabel(fFrameGroup, new TGHotString(buff)));
142         
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);
147         
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]);
152         
153       }
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);
158     }
159   
160   TGLayoutHints *fL5 = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
161                                          kLHintsExpandY, 2, 2, 5, 1);
162   fFrameMain->AddFrame(fTab, fL5);
163   fFrameMain->MapSubwindows();
164   fFrameMain->Resize();
165   
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();
171 }
172
173 //_____________________________________________________________________________________________
174 AliTPCMonitorDialog::~AliTPCMonitorDialog()
175 {
176   // Delete test dialog widgets.
177   fFrameMain->DeleteWindow(); 
178 }
179
180 //_____________________________________________________________________________________________
181 void AliTPCMonitorDialog::HandleButtons(Int_t id)
182 {
183   // Handle different buttons.
184   if (id == -1) {
185     TGButton *btn = (TGButton*) gTQSender;
186     id = btn->WidgetId();
187   }
188   
189   switch (id) 
190     {
191     case 1:
192       {  
193         // Select Format
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);
199         
200         break;
201       }
202     case 2: 
203       {
204         // Select FEE Component 
205         Int_t comp_sel=1;
206         Int_t fComponents[10];
207         for(Int_t j = 0; j < 6; j++) 
208           {
209             TString s1 =  fEnt[j]->GetDisplayText();
210             if(s1=="all"){  fComponents[j] = -1;              }
211             else         {  fComponents[j] = (int)atoi(s1.Data()); }
212             if(
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   )    )
219               {
220                 comp_sel =0;
221                 AliError("Settings out of range ( version 2) "); 
222               }
223           }
224         if(comp_sel==1) 
225           {
226             if(fMonitor!=0 && fMonitor->GetEventProcessed() )fMonitor->ShowSel((Int_t*)fComponents);
227             else                                             AliError("No event processed up to now");
228           }
229         break;
230       }
231     case 3:
232       {
233         // Set Configuration (base, max, sum)
234         Int_t fConfigArr[6];
235         
236         string s1((TString)fEnt[0]->GetDisplayText().Data());
237         string s2((TString)fEnt[1]->GetDisplayText().Data());
238         string s3((TString)fEnt[2]->GetDisplayText().Data());
239         
240         Int_t error = 1;
241         
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]);
247             error=0;
248           }
249         }
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]);
255             error=0;
256           }
257         }
258
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]);
264             error=0;
265           }
266         }
267         if(error!=0) AliError("Settings out of range (version 3)"); 
268         break;
269       }
270     default:
271       break;
272     }
273 }
274
275 //_____________________________________________________________________________________________
276 void AliTPCMonitorDialog::DoTab(Int_t id)
277 {
278   printf("Tab item %d activated\n", id);
279 }
280
281 //_____________________________________________________________________________________________
282 void AliTPCMonitorDialog::DoClose()
283 {
284   // Close the dialog window
285   printf("\nTerminating dialog: via window manager\n");
286   CloseWindow();
287   // Close the Ged editor if it was activated.
288   if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
289     TVirtualPadEditor::Terminate();
290 }
291
292 //_____________________________________________________________________________________________
293 void AliTPCMonitorDialog::CloseWindow()
294 {
295   // Called when window is closed via the window manager.
296   delete this;
297 }
298
299 //_____________________________________________________________________________________________
300 void AliTPCMonitorDialog::DoOK()
301 {
302   // Call from OK button
303   printf("\nTerminating dialog: OK pressed\n");
304  
305   // The same effect can be obtained by using a singleshot timer:
306   TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()");
307
308   // Close the Ged editor if it was activated.
309   if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
310     TVirtualPadEditor::Terminate();
311 }
312
313
314 //_____________________________________________________________________________________________
315 void AliTPCMonitorDialog::DoCancel()
316 {
317   // Cancel operation and close the dialog window
318   printf("\nTerminating dialog: Cancel pressed\n");
319   TTimer::SingleShot(150, "AliTPCMonitorDialog", this, "CloseWindow()");
320   
321   // Close the Ged editor if it was activated.
322   if (TVirtualPadEditor::GetPadEditor(kFALSE) != 0)
323     TVirtualPadEditor::Terminate();
324 }
325