Subversion Repositories f9daq

Rev

Rev 146 | Rev 172 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
146 f9daq 1
#include "../include/sipmscan.h"
2
#include "../include/workstation.h"
3
#include "../include/substructure.h"
4
 
5
#include <stdio.h>
6
#include <stdlib.h>
7
 
8
// Main window constructor (+layout) ---------------------------------
9
 
10
TGAppMainFrame::TGAppMainFrame(const TGWindow *p, int w, int h)
11
{
12
   TGCompositeFrame *fT1;
13
   idtotal = 0;
14
 
15
   char *cTemp;
16
 
167 f9daq 17
   // Prepare the default open directory (basedir)
18
   currentOpenDir = new char[1024];
19
   sprintf(currentOpenDir, "%s/results", rootdir);
20
 
146 f9daq 21
   // CAMAC and Scope objects
22
   gDaq = new daq();
23
   gScopeDaq = new daqscope();
24
 
25
   // Define main window and menubar
26
   fMain = new TGMainFrame(p, w, h, kVerticalFrame);
27
 
28
   // Initialize the menu
29
   fMenuBar = new TGMenuBar(fMain, 200, 30);
30
   InitMenu();
31
   fMain->AddFrame(fMenuBar, new TGLayoutHints(kLHintsExpandX | kLHintsTop));
32
 
33
   // Prepare the tabbed structure
34
   fTab = new TGTab(fMain, 500, 500);
35
 
36
   // Read the layout we wish to use
37
   int frmWidth[measwin+analysiswin], frmHeight[measwin+analysiswin];
38
   LayoutRead(measwin+analysiswin, frmWidth, frmHeight);
39
 
40
   // Structure the measurement layout window
41
   int *vert, *hor, *wPane, *hPane;
42
 
43
   vert = new int[2]; hor = new int;
44
   *hor = 1;
45
   vert[0] = 1; vert[1] = 0;
46
 
47
   const char *measFrmTit[] = {"Settings pane", "Display", "Main measurement window"};
48
   wPane = new int[measwin]; hPane = new int[measwin];
49
   for(int i = 0; i < measwin; i++)
50
   {
51
      wPane[i] = frmWidth[i];
52
      hPane[i] = frmHeight[i];
53
   }
54
 
55
   fT1 = fTab->AddTab("Measurement");
56
   TGSplitter(fT1, "horizontal", hor, vert, measFrmTit, measLayout, wPane, hPane);
57
   fT1->AddFrame(fLayout[idtotal], new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
58
   idtotal++;
59
   delete[] vert; delete hor; delete[] wPane; delete[] hPane;
60
 
61
   // Structure the analysis layout window
62
   vert = new int[2]; hor = new int;
63
   *hor = 1;
64
   vert[0] = 1; vert[1] = 1;
65
 
66
   const char *analysisFrmTit[] = {"Histogram file selection", "Analysis", "Histogram", "Histogram controls"};
67
   wPane = new int[analysiswin]; hPane = new int[analysiswin];
68
   for(int i = 0; i < analysiswin; i++)
69
   {
70
      wPane[i] = frmWidth[i+measwin];
71
      hPane[i] = frmHeight[i+measwin];
72
   }
73
 
74
   fT1 = fTab->AddTab("Analysis");
75
   TGSplitter(fT1, "horizontal", hor, vert, analysisFrmTit, analysisLayout, wPane, hPane);
76
   fT1->AddFrame(fLayout[idtotal], new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
77
   idtotal++;
78
   delete[] vert; delete hor; delete[] wPane; delete[] hPane;
79
 
80
   // Structure the monitoring layout window (Fieldpoint) //TODO
81
   fT1 = fTab->AddTab("Monitoring");
82
   fTab->SetEnabled(2,kFALSE); //TODO
83
 
84
   // Structure the help layout window
85
   fT1 = fTab->AddTab("Help");
86
   TGTextView *helpdesc;
87
   const TGFont *tfont = gClient->GetFont(HELPFONT);
88
   FontStruct_t helpFont = tfont->GetFontStruct();
89
   helpdesc = new TGTextView(fT1,100,100);
90
   helpdesc->SetFont(helpFont);
91
   helpdesc->SetForegroundColor(0x000000);
92
   fT1->AddFrame(helpdesc, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
93
 
94
   cTemp = new char[1024];
95
   sprintf(cTemp, "%s/doc/README", rootdir);
96
   if(helpdesc->LoadFile(cTemp))
97
   {
98
      if(DBGSIG) printf("TGAppMainFrame(): Help file correctly loaded.\n");
99
   }
100
   else
101
      printf("Error! Help file not loaded.\n");
102
   delete[] cTemp;
103
   helpdesc->AddLine("");
104
 
105
   fMain->AddFrame(fTab, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
106
 
107
   // Set the inner layout of each frame
108
   AppLayout();
109
 
110
   fMain->SetWindowName(WINDOW_NAME);
111
   fMain->MapSubwindows();
112
   fMain->MapWindow();
113
   fMain->Layout();
114
 
115
   // Prepare initial settings
116
   EnableScan(0);       //. 
117
   EnableScan(1);       // Grey out scan
118
   EnableScan(2);       // options by default
119
   EnableScan(3);       //.
120
   EnableLiveUpdate();  //. Disable the live histogram update at beginning
121
   VoltOut(1);          //. Get the output voltage save in file
122
   HistogramOptions(1); //. Enable clean plots by default
123
   plotType->widgetTB[0]->SetDown(kTRUE);                       //.
124
   fMenuHisttype->CheckEntry(M_ANALYSIS_HISTTYPE_1DADC);        // Set the ADC histogram
125
   fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DTDC);      // to show by default
126
   fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_2D);         //.
127
   acqStarted = false;  //. At program start, the acquisition is stopped
128
   ToolTipSet();        //. Turn on tooltips
129
   PositionSet(1);      //. Get starting table position
130
   RotationSet(1);      //. Get starting rotation
131
 
132
   if(DBGSIG > 1)
133
   {
134
      printf("TGAppMainFrame(): At end of constructor\n");
135
      gObjectTable->Print();
136
   }
137
}
138
 
139
TGAppMainFrame::~TGAppMainFrame()
140
{
141
   fMain->Cleanup();
142
   delete fMain;
143
}
144
 
145
// -------------------------------------------------------------------
146
 
147
// Event handler for menubar actions ---------------------------------
148
 
149
void TGAppMainFrame::HandleMenu(Int_t id)
150
{
151
//   int ret = 0;
152
   char cmd[256];
153
 
154
   switch(id)
155
   {
156
      case M_FILE_SET_LAYOUT:
157
         LayoutSet();
158
         break;
159
 
160
      case M_FILE_SAVE_LAYOUT:
161
         LayoutSave();
162
         break;
163
 
164
      case M_FILE_SAVE_MSETTINGS:
165
         // Here, we save the set values in the measurement layout (automatically done when we safely exit the application and after each start of measurement).
166
         break;
167
 
168
      case M_FILE_SAVE_ASETTINGS:
169
         // Here, we save the set values in the analysis layout (automatically done when we safely exit the application and after each start of analysis).
170
         break;
171
 
172
      case M_FILE_CHECK_WIDTH:
173
         printf("\nSettings window: %dx%d\n", measLayout[0]->GetWidth(), measLayout[0]->GetHeight());
174
         printf("Histogram window: %dx%d\n", measLayout[1]->GetWidth(), measLayout[1]->GetHeight());
175
         printf("Main measurement window: %dx%d\n", measLayout[2]->GetWidth(), measLayout[2]->GetHeight());
176
         printf("Histogram file window: %dx%d\n", analysisLayout[0]->GetWidth(), analysisLayout[0]->GetHeight());
177
         printf("Analysis window: %dx%d\n", analysisLayout[1]->GetWidth(), analysisLayout[1]->GetHeight());
178
         printf("Histogram window: %dx%d\n", analysisLayout[2]->GetWidth(), analysisLayout[2]->GetHeight());
179
         printf("Histogram controls window: %dx%d\n", analysisLayout[3]->GetWidth(), analysisLayout[3]->GetHeight());
180
 
181
         printf("Main window: %dx%d\n", fMain->GetWidth(), fMain->GetHeight());
182
         printf("Menu bar: %dx%d\n", fMenuBar->GetWidth(), fMenuBar->GetHeight());
183
         printf("Tab window: %dx%d\n", fTab->GetWidth(), fTab->GetHeight());
184
         break;
185
 
186
      case M_FILE_EXIT:
187
         CloseWindow();
188
         break;
189
 
190
      case M_ANALYSIS_HISTTYPE_1DADC:
191
         ChangeHisttype(0);
192
         break;
193
 
194
      case M_ANALYSIS_HISTTYPE_1DTDC:
195
         ChangeHisttype(1);
196
         break;
197
 
198
      case M_ANALYSIS_HISTTYPE_2D:
199
         ChangeHisttype(2);
200
         break;
201
 
202
      case M_ANALYSIS_INTEG:
203
         fTab->SetTab(1);
204
         analTab->SetTab(0);
205
         for(int i = 0; i < 3; i++)
206
         {
207
            if(intSpect->widgetChBox[i]->IsDown())
208
               intSpect->widgetChBox[i]->SetState(kButtonUp);
209
         }
210
         break;
211
 
212
      case M_ANALYSIS_INTEGX:
213
         fTab->SetTab(1);
214
         analTab->SetTab(0);
215
         for(int i = 0; i < 3; i++)
216
         {
217
            if(i == 0)
218
               intSpect->widgetChBox[i]->SetState(kButtonDown);
219
            else
220
            {
221
               if(intSpect->widgetChBox[i]->IsDown())
222
                  intSpect->widgetChBox[i]->SetState(kButtonUp);
223
            }
224
         }
225
         break;
226
 
227
      case M_ANALYSIS_INTEGY:
228
         fTab->SetTab(1);
229
         analTab->SetTab(0);
230
         for(int i = 0; i < 3; i++)
231
         {
232
            if(i == 1)
233
               intSpect->widgetChBox[i]->SetState(kButtonDown);
234
            else
235
            {
236
               if(intSpect->widgetChBox[i]->IsDown())
237
                  intSpect->widgetChBox[i]->SetState(kButtonUp);
238
            }
239
         }
240
         break;
241
 
242
      case M_ANALYSIS_PHOTMU:
243
         fTab->SetTab(1);
244
         analTab->SetTab(1);
245
         for(int i = 0; i < 3; i++)
246
         {
247
            if(i == 2)
248
               intSpect->widgetChBox[i]->SetState(kButtonDown);
249
            else
250
            {
251
               if(intSpect->widgetChBox[i]->IsDown())
252
                  intSpect->widgetChBox[i]->SetState(kButtonUp);
253
            }
254
         }
255
         break;
256
 
257
      case M_ANALYSIS_BREAKDOWN:
258
         fTab->SetTab(1);
259
         analTab->SetTab(2);
260
         break;
261
 
262
      case M_ANALYSIS_SURFSCAN:
263
         fTab->SetTab(1);
264
         analTab->SetTab(3);
265
         break;
266
 
267
      case M_ANALYSIS_TIMING:
268
         fTab->SetTab(1);
269
         analTab->SetTab(4);
270
         break;
271
 
272
      case M_HELP_WEBHELP:
273
         printf("TGAppMainFrame::HandleMenu(): Opening %s/doc/documentation.html in a web browser.\n", rootdir);
274
         sprintf(cmd, "xdg-open %s/doc/documentation.html &", rootdir);
275
         system(cmd);
276
         break;
277
 
278
      case M_HELP_ABOUT:
279
         About();
280
         break;
281
 
282
      default:
283
//         fMainFrame->SetCurrent(id);
284
         break;
285
   }
286
}
287
 
288
// -------------------------------------------------------------------
289
 
290
// Initialize the main window menu -----------------------------------
291
 
292
void TGAppMainFrame::InitMenu()
293
{
294
   fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
295
 
296
   // Popup menu in menubar for File controls
297
   fMenuFile = new TGPopupMenu(gClient->GetRoot());
298
   fMenuFile->AddEntry(new TGHotString("Set &user layout"), M_FILE_SET_LAYOUT);
299
   fMenuFile->AddEntry(new TGHotString("Save &current layout"), M_FILE_SAVE_LAYOUT);
300
   fMenuFile->AddSeparator();
301
   fMenuFile->AddEntry(new TGHotString("Save current &measurement settings"), M_FILE_SAVE_MSETTINGS);
302
   fMenuFile->AddEntry(new TGHotString("Save current &analysis settings"), M_FILE_SAVE_ASETTINGS);
303
   fMenuFile->AddEntry(new TGHotString("&Check frame width (Testing)"), M_FILE_CHECK_WIDTH);
304
   fMenuFile->AddSeparator();
305
   fMenuFile->AddEntry(new TGHotString("E&xit"), M_FILE_EXIT);
306
 
307
   // Popup menu in menubar for Analysis controls
308
   fMenuHisttype = new TGPopupMenu(gClient->GetRoot()); // adds a cascade menu that will be incorporated into analysis controls
309
   fMenuHisttype->AddEntry(new TGHotString("1D &ADC histogram"), M_ANALYSIS_HISTTYPE_1DADC);
310
   fMenuHisttype->AddEntry(new TGHotString("1D &TDC histogram"), M_ANALYSIS_HISTTYPE_1DTDC);
311
   fMenuHisttype->AddEntry(new TGHotString("&2D ADC vs. TDC histogram"), M_ANALYSIS_HISTTYPE_2D);
312
 
313
   fMenuAnalysis = new TGPopupMenu(gClient->GetRoot()); // adds a new popup menu to the menubar
314
   fMenuAnalysis->AddPopup(new TGHotString("&Histogram type"), fMenuHisttype);
315
   fMenuAnalysis->AddEntry(new TGHotString("&Integrate spectrum"), M_ANALYSIS_INTEG);
316
   fMenuAnalysis->AddEntry(new TGHotString("Integrate spectrum (&X direction)"), M_ANALYSIS_INTEGX);
317
   fMenuAnalysis->AddEntry(new TGHotString("Integrate spectrum (&Y direction)"), M_ANALYSIS_INTEGY);
318
   fMenuAnalysis->AddEntry(new TGHotString("&Relative PDE"), M_ANALYSIS_PHOTMU);
319
   fMenuAnalysis->AddEntry(new TGHotString("&Breakdown voltage"), M_ANALYSIS_BREAKDOWN);
320
   fMenuAnalysis->AddEntry(new TGHotString("Surface 2&D scan"), M_ANALYSIS_SURFSCAN);
321
   fMenuAnalysis->AddEntry(new TGHotString("&Timing analysis"), M_ANALYSIS_TIMING);
322
 
323
   // Popup menu in menubar for File controls
324
   fMenuHelp = new TGPopupMenu(gClient->GetRoot());
325
   fMenuHelp->AddEntry(new TGHotString("Open &help in web browser"), M_HELP_WEBHELP);
326
   fMenuHelp->AddEntry(new TGHotString("&About"), M_HELP_ABOUT);
327
 
328
   // Connect all menu items with actions
329
   fMenuFile->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)");
330
   fMenuAnalysis->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)");
331
   fMenuHelp->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)");
332
 
333
   // Draw the created popup menus on the menubar
334
   fMenuBar->AddPopup(new TGHotString("&File"), fMenuFile, fMenuBarItemLayout);
335
   fMenuBar->AddPopup(new TGHotString("&Analysis"),fMenuAnalysis,fMenuBarItemLayout);
336
   fMenuBar->AddPopup(new TGHotString("&Help"), fMenuHelp, fMenuBarItemLayout);
337
}
338
 
339
// -------------------------------------------------------------------
340
 
341
// Setting the application subwindow layout --------------------------
342
 
343
void TGAppMainFrame::AppLayout()
344
{
345
   double numform[6], numform2[6];
346
   int *checksel;
347
   char selected[256];
348
   int subgroup[2];
349
   TGCompositeFrame *fH1, *fV1, *fH2, *fT1;
350
   TGGroupFrame *fG1;
351
 
352
   TGLayoutHints *f0centerX = new TGLayoutHints(kLHintsCenterX,2,2,2,2);
353
   TGLayoutHints *f0leftX = new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2);
354
   TGLayoutHints *f0leftXnoleft = new TGLayoutHints(kLHintsLeft | kLHintsTop,0,2,2,2);
355
   TGLayoutHints *f0leftXpad = new TGLayoutHints(kLHintsLeft | kLHintsTop,12,12,2,2);
356
   TGLayoutHints *f0rightX = new TGLayoutHints(kLHintsRight | kLHintsTop,2,2,2,2);
357
   TGLayoutHints *f0rightXpad = new TGLayoutHints(kLHintsRight | kLHintsTop,12,12,2,2);
358
   TGLayoutHints *f0centerY = new TGLayoutHints(kLHintsCenterY,2,2,2,2);
359
   TGLayoutHints *f0center2d = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,2,2,2,2);
360
   TGLayoutHints *f1expandX = new TGLayoutHints(kLHintsExpandX,2,2,2,2);
361
   TGLayoutHints *f1expand2d = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,2,2,2,2);
362
   TGLayoutHints *f1expandXpad = new TGLayoutHints(kLHintsExpandX,12,12,2,2);
363
 
364
// Settings pane ---------------------------------------------------------------------------
365
   subgroup[0] = (measLayout[0]->GetWidth())-4;
366
 
367
   // Check buttons to toggle voltage, surface and Z axis scans
368
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *scansOn -> 4 check buttons (voltage, surface, Z axis, incidence angle scans)\n");
369
   scansOn = new TSubStructure();
370
   checksel = new int[4];
371
   checksel[0] = 0; checksel[1] = 0; checksel[2] = 0; checksel[3] = 0;
372
   const char *selnames[] = {"Voltage scan ON/OFF", "Surface scan ON/OFF", "Z-axis scan ON/OFF","Rotation scan ON/OFF","0","0","0","0","0","0","0","0","0","0","0","0"};
373
   if(scansOn->TGCheckList(measLayout[0], subgroup[0], 30, 4, selnames, checksel, "vertical", "center"))
374
      measLayout[0]->AddFrame(scansOn->outsidebox, f1expandXpad);
375
   delete[] checksel;
376
 
377
   // Hard limit for maximum voltage we can set
378
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vHardlimit -> Number entry for voltage limit\n");
379
   vHardlimit = new TSubStructure();
380
   for(int i = 0; i < 6; i++) numform[i] = 0;
381
   numform[0] = 6; numform[1] = 2;
382
   if(vHardlimit->TGLabelNEntry(measLayout[0], subgroup[0], 30, "Voltage limit:", 70.00, numform, "center"))
383
      measLayout[0]->AddFrame(vHardlimit->outsidebox, f1expandXpad);
384
 
385
   // Number of used channels
386
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *NCH -> Number entry for number of channels to capture\n");
387
   NCH = new TSubStructure();
388
   for(int i = 0; i < 6; i++) numform[i] = 0;
389
   numform[0] = 3; numform[2] = 2; numform[3] = 2; numform[4] = 1; numform[5] = 8;
390
   if(NCH->TGLabelNEntry(measLayout[0], subgroup[0], 30, "Nr. of channels:", 1, numform, "center"))
391
      measLayout[0]->AddFrame(NCH->outsidebox, f1expandXpad);
392
 
393
   // Select the units to use for table positioning (micrometer, table position units)
394
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *posUnits -> Dropdown menu for selecting the units for table positioning\n");
395
   posUnits = new TSubStructure();
396
   selnames[0] = "table units"; selnames[1] = "micrometers";
397
   sprintf(selected, "table units");
398
   if(posUnits->TGLabelDrop(measLayout[0], 2*subgroup[0]/3, 30, "Position units:", 2, selnames, selected))
399
      measLayout[0]->AddFrame(posUnits->outsidebox, f1expandXpad);
400
 
401
   // Select the units to use for rotation platform (degrees, table rotation units)
402
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotUnits -> Dropdown menu for selecting the units for rotation\n");
403
   rotUnits = new TSubStructure();
404
   selnames[0] = "table units"; selnames[1] = "degrees";
405
   sprintf(selected, "degrees");
406
   if(rotUnits->TGLabelDrop(measLayout[0], 2*subgroup[0]/3, 30, "Rotation units:", 2, selnames, selected))
407
      measLayout[0]->AddFrame(rotUnits->outsidebox, f1expandXpad);
408
 
409
   // Button and textbox to enter the oscilloscope IP address
410
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *oscConnect -> Text Entry (oscilloscope IP address)\n");
411
   oscConnect = new TSubStructure();
412
   if(oscConnect->TGLabelTEntryButton(measLayout[0], subgroup[0], 30, "Scope IP:", "178.172.43.157", "Connect", "twoline"))
413
      measLayout[0]->AddFrame(oscConnect->outsidebox, f1expandXpad);
414
 
415
   // Laser settings (freq., tune, ND filter)
416
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *laserInfo -> Text Entry (Laser setting information)\n");
417
   laserInfo = new TSubStructure();
418
   if(laserInfo->TGLabelTEntry(measLayout[0], subgroup[0], 30, "Laser settings:", "kHz, tune, ND", "twoline"))
419
      measLayout[0]->AddFrame(laserInfo->outsidebox, f1expandXpad);
420
 
421
   // Chamber temperature (will only be manually set until we can get it directly from the chamber)
422
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *chtemp -> Number entry for chamber temperature\n");
423
   chtemp = new TSubStructure();
424
   for(int i = 0; i < 6; i++) numform[i] = 0;
425
   numform[0] = 5; numform[1] = 1; numform[3] = 2; numform[4] = -70.; numform[5] = 140.;
426
   if(chtemp->TGLabelNEntry(measLayout[0], subgroup[0], 30, "Chamber temp.:", 25.0, numform, "center"))
427
      measLayout[0]->AddFrame(chtemp->outsidebox, f1expandXpad);
428
 
429
   // Check button to toggle live update of histogram (in display canvas)
430
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *liveDisp -> 1 check button (live histogram update)\n");
431
   liveDisp = new TSubStructure();
432
   checksel = new int;
433
   *checksel = 0;
434
   selnames[0] = "Live histogram ON/OFF";
435
   if(liveDisp->TGCheckList(measLayout[0], subgroup[0], 30, 1, selnames, checksel, "vertical", "center"))
436
      measLayout[0]->AddFrame(liveDisp->outsidebox, f1expandXpad);
437
   delete checksel;
438
 
439
   // Actions for Settings pane //TODO
440
   scansOn->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EnableScan(=0)");
441
   scansOn->widgetChBox[1]->Connect("Clicked()", "TGAppMainFrame", this, "EnableScan(=1)");
442
   scansOn->widgetChBox[2]->Connect("Clicked()", "TGAppMainFrame", this, "EnableScan(=2)");
443
   scansOn->widgetChBox[3]->Connect("Clicked()", "TGAppMainFrame", this, "EnableScan(=3)");
444
   vHardlimit->widgetNE[0]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "VoltageLimit()");
445
   (vHardlimit->widgetNE[0]->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "VoltageLimit()");
446
   posUnits->widgetCB->Connect("Selected(Int_t)", "TGAppMainFrame", this, "ChangeUnits(Int_t)");
447
   rotUnits->widgetCB->Connect("Selected(Int_t)", "TGAppMainFrame", this, "ChangeUnitsRot(Int_t)");
448
   liveDisp->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "EnableLiveUpdate()");
449
// Settings pane ---------------------------------------------------------------------------
450
 
451
// Main window -----------------------------------------------------------------------------
452
   TGTab *setTab;
453
 
454
   // Voltage, position and incidence angle tab
455
   subgroup[0] = 2*(measLayout[2]->GetWidth())/7-14;
456
   subgroup[1] = (measLayout[2]->GetHeight())/2-4;
457
   setTab = new TGTab(measLayout[2], subgroup[0], subgroup[1]);
458
 
459
   fT1 = setTab->AddTab("Voltage, position and incidence angle");
460
   fH1 = new TGCompositeFrame(fT1, measLayout[2]->GetWidth(), subgroup[1], kFixedHeight | kHorizontalFrame);
461
 
462
   // Left pane (Bias voltage controls)
463
   fV1 = new TGCompositeFrame(fH1, subgroup[0], subgroup[1], kFixedWidth | kFixedHeight | kVerticalFrame);
464
   fG1 = new TGGroupFrame(fV1, "Bias voltage controls");
465
 
466
   // Output voltage supply channel
467
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutCh -> Dropdown menu for bias voltage channel\n");
468
   vOutCh = new TSubStructure();
469
   selnames[0] = "U0"; selnames[1] = "U1"; selnames[2] = "U2"; selnames[3] = "U3"; selnames[4] = "U4"; selnames[5] = "U5"; selnames[6] = "U6"; selnames[7] = "U7"; selnames[8] = "U100"; selnames[9] = "U101"; selnames[10] = "U102"; selnames[11] = "U103"; selnames[12] = "U104"; selnames[13] = "U105"; selnames[14] = "U106"; selnames[15] = "U107";
470
   sprintf(selected, "U0");
471
   if(vOutCh->TGLabelDrop(fG1, 2*subgroup[0]/3, 30, "Output channel:", 16, selnames, selected))
472
      fG1->AddFrame(vOutCh->outsidebox, f1expandXpad);
473
 
474
   // Output voltage setting
475
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutOpt -> 2 check buttons (negative polarity, ON/OFF toggle switch)\n");
476
   vOutOpt = new TSubStructure();
477
   checksel = new int[2];
478
   checksel[0] = 0; checksel[1] = 0;
479
   selnames[1] = "Output ON/OFF"; selnames[0] = "Negative polarity";
480
   if(vOutOpt->TGCheckList(fG1, 3*subgroup[0]/4, 30, 2, selnames, checksel, "vertical", "center"))
481
      fG1->AddFrame(vOutOpt->outsidebox, f1expandXpad);
482
   delete[] checksel;
483
 
484
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOut -> Number entry for bias voltage\n");
485
   vOut = new TSubStructure();
486
   for(int i = 0; i < 6; i++) numform[i] = 0;
487
   numform[0] = 7; numform[1] = 2; numform[3] = 2; numform[4] = 0.; numform[5] = vHardlimit->widgetNE[0]->GetNumber();
488
   if(vOut->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Output voltage:", 0.00, numform, "center"))
489
      fG1->AddFrame(vOut->outsidebox, f1expandXpad);
490
 
491
   // Set, get and reset voltage buttons
492
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutButtons -> 3 buttons (set bias voltage, read current bias voltage, reset voltage output when it gets interlocked)\n");
493
   vOutButtons = new TSubStructure();
494
   selnames[0] = "Set"; selnames[1] = "Get"; selnames[2] = "Reset";
495
   if(vOutButtons->TGMultiButton(fG1, 3*subgroup[0]/4, 30, 3, selnames, "center"))
496
      fG1->AddFrame(vOutButtons->outsidebox, f1expandXpad);
497
 
498
   // Voltage scan controls
499
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutStart -> Number entry for starting bias voltage\n");
500
   vOutStart = new TSubStructure();
501
   for(int i = 0; i < 6; i++) numform[i] = 0;
502
   numform[0] = 7; numform[1] = 2;
503
   if(vOutStart->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "V (min):", 0.00, numform, "center"))
504
      fG1->AddFrame(vOutStart->outsidebox, f1expandXpad);
505
 
506
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutStop -> Number entry for starting bias voltage\n");
507
   vOutStop = new TSubStructure();
508
   for(int i = 0; i < 6; i++) numform[i] = 0;
509
   numform[0] = 7; numform[1] = 2;
510
   if(vOutStop->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "V (max):", 0.00, numform, "center"))
511
      fG1->AddFrame(vOutStop->outsidebox, f1expandXpad);
512
 
513
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *vOutStep -> Number entry for starting bias voltage\n");
514
   vOutStep = new TSubStructure();
515
   for(int i = 0; i < 6; i++) numform[i] = 0;
516
   numform[0] = 7; numform[1] = 2;
517
   if(vOutStep->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "V (step):", 0.00, numform, "center"))
518
      fG1->AddFrame(vOutStep->outsidebox, f1expandXpad);
519
 
520
   fV1->AddFrame(fG1, f1expand2d);
521
   // Left pane (Bias voltage controls)
522
   fH1->AddFrame(fV1, f0leftX);
523
 
524
   // Center pane (Table position controls)
525
   subgroup[0] = 3*(measLayout[2]->GetWidth())/7-13;
526
   fV1 = new TGCompositeFrame(fH1, subgroup[0], subgroup[1], kFixedWidth | kFixedHeight | kVerticalFrame);
527
   fG1 = new TGGroupFrame(fV1, "Table position controls");
528
 
529
   // X, Y and Z positions
530
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *xPos, *yPos, *zPos, *zPosMin, *zPosMax, *zPosStep -> Settings for position and Z axis scan\n");
531
   fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
532
   xPos = new TSubStructure();
533
   for(int i = 0; i < 6; i++) numform[i] = 0;
534
   numform[0] = 9; numform[3] = 2; numform[4] = -100; numform[5] = 215000;
535
   if(xPos->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "X:", 0, numform, "center"))
536
      fH2->AddFrame(xPos->outsidebox, f0centerX);
537
 
538
   zPosMin = new TSubStructure();
539
   numform[5] = 375000;
540
   if(zPosMin->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Z (min):", 0, numform, "center"))
541
      fH2->AddFrame(zPosMin->outsidebox, f0centerX);
542
   fG1->AddFrame(fH2, f1expandXpad);
543
 
544
   fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
545
   yPos = new TSubStructure();
546
   numform[5] = 215000;
547
   if(yPos->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Y:", 0, numform, "center"))
548
      fH2->AddFrame(yPos->outsidebox, f0centerX);
549
 
550
   zPosMax = new TSubStructure();
551
   numform[5] = 375000;
552
   if(zPosMax->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Z (max):", 0, numform, "center"))
553
      fH2->AddFrame(zPosMax->outsidebox, f0centerX);
554
   fG1->AddFrame(fH2, f1expandXpad);
555
 
556
   fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
557
   zPos = new TSubStructure();
558
   numform[5] = 375000;
559
   if(zPos->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Z:", 0, numform, "center"))
560
      fH2->AddFrame(zPos->outsidebox, f0centerX);
561
 
562
   zPosStep = new TSubStructure();
563
   for(int i = 0; i < 6; i++) numform[i] = 0;
564
   numform[0] = 9;
565
   if(zPosStep->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Z (step):", 0, numform, "center"))
566
      fH2->AddFrame(zPosStep->outsidebox, f0centerX);
567
   fG1->AddFrame(fH2, f1expandXpad);
568
 
569
   // Set, get, home and reset position buttons
570
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *posButtons -> 4 buttons (set position, read current position, home the motor and reset all three controllers)\n");
571
   posButtons = new TSubStructure();
572
   selnames[0] = "Set"; selnames[1] = "Get"; selnames[2] = "Home"; selnames[3] = "Reset";
573
   if(posButtons->TGMultiButton(fG1, 3*subgroup[0]/4, 30, 4, selnames, "center"))
574
      fG1->AddFrame(posButtons->outsidebox, f1expandXpad);
575
 
576
   // Position scan controls
577
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *xPosMin, *xPosMax, *xPosStep, *yPosMin, *yPosMax, *yPosStep -> Settings for X and Y axis scans\n");
578
   fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
579
   xPosMin = new TSubStructure();
580
   for(int i = 0; i < 6; i++) numform[i] = 0;
581
   numform[0] = 9; numform[3] = 2; numform[4] = -100; numform[5] = 215000;
582
   if(xPosMin->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "X (min):", 0, numform, "center"))
583
      fH2->AddFrame(xPosMin->outsidebox, f0centerX);
584
 
585
   yPosMin = new TSubStructure();
586
   if(yPosMin->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Y (min):", 0, numform, "center"))
587
      fH2->AddFrame(yPosMin->outsidebox, f0centerX);
588
   fG1->AddFrame(fH2, f1expandXpad);
589
 
590
   fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
591
   xPosMax = new TSubStructure();
592
   if(xPosMax->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "X (max):", 0, numform, "center"))
593
      fH2->AddFrame(xPosMax->outsidebox, f0centerX);
594
 
595
   yPosMax = new TSubStructure();
596
   if(yPosMax->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Y (max):", 0, numform, "center"))
597
      fH2->AddFrame(yPosMax->outsidebox, f0centerX);
598
   fG1->AddFrame(fH2, f1expandXpad);
599
 
600
   fH2 = new TGCompositeFrame(fG1, 3*subgroup[0]/4, 30, kFixedWidth | kHorizontalFrame);
601
   xPosStep = new TSubStructure();
602
   for(int i = 0; i < 6; i++) numform[i] = 0;
603
   numform[0] = 9;
604
   if(xPosStep->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "X (step):", 0, numform, "center"))
605
      fH2->AddFrame(xPosStep->outsidebox, f0centerX);
606
 
607
   yPosStep = new TSubStructure();
608
   if(yPosStep->TGLabelNEntry(fH2, 8*subgroup[0]/16, 30, "Y (step):", 0, numform, "center"))
609
      fH2->AddFrame(yPosStep->outsidebox, f0centerX);
610
   fG1->AddFrame(fH2, f1expandXpad);
611
 
612
   fV1->AddFrame(fG1, f1expand2d);
613
   // Center pane (Table position controls)
614
   fH1->AddFrame(fV1, f0leftX);
615
 
616
   // Right pane (Incidence angle controls)
617
   subgroup[0] = 2*(measLayout[2]->GetWidth())/7-14;
618
   fV1 = new TGCompositeFrame(fH1, subgroup[0], subgroup[1], kFixedWidth | kFixedHeight | kVerticalFrame);
619
   fG1 = new TGGroupFrame(fV1, "Incidence angle controls");
620
 
621
   // Rotation positions
622
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotPos -> Setting for rotation position\n");
623
   rotPos = new TSubStructure();
624
   for(int i = 0; i < 6; i++) numform[i] = 0;
625
   numform[0] = 7; numform[1] = 2; numform[3] = 2; numform[4] = -180.; numform[5] = 180.;
626
   if(rotPos->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Incidence angle:", 0., numform, "center"))
627
      fG1->AddFrame(rotPos->outsidebox, f1expandXpad);
628
 
629
   // Set, get, home and reset rotation buttons
630
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotButtons -> 4 buttons (set rotation, read current rotation, home the motor and reset controller)\n");
631
   rotButtons = new TSubStructure();
632
   selnames[0] = "Set"; selnames[1] = "Get"; selnames[2] = "Home"; selnames[3] = "Reset";
633
   if(rotButtons->TGMultiButton(fG1, 3*subgroup[0]/4, 30, 4, selnames, "center"))
634
      fG1->AddFrame(rotButtons->outsidebox, f1expandXpad);
635
 
636
   // Rotation scan controls
637
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotPosMin -> Number entry for starting angle\n");
638
   rotPosMin = new TSubStructure();
639
   if(rotPosMin->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Angle (min):", 0.0, numform, "center"))
640
      fG1->AddFrame(rotPosMin->outsidebox, f1expandXpad);
641
 
642
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotPosMax -> Number entry for finishing angle\n");
643
   rotPosMax = new TSubStructure();
644
   if(rotPosMax->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Angle (max):", 0.0, numform, "center"))
645
      fG1->AddFrame(rotPosMax->outsidebox, f1expandXpad);
646
 
647
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *rotPosStep -> Number entry for angle step\n");
648
   rotPosStep = new TSubStructure();
649
   for(int i = 0; i < 6; i++) numform[i] = 0;
650
   numform[0] = 7; numform[1] = 1;
651
   if(rotPosStep->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Angle (step):", 0.0, numform, "center"))
652
      fG1->AddFrame(rotPosStep->outsidebox, f1expandXpad);
653
 
654
   fV1->AddFrame(fG1, f1expand2d);
655
   // Right pane (Incidence angle controls)
656
   fH1->AddFrame(fV1, f0leftX);
657
 
658
   fT1->AddFrame(fH1, f1expand2d);
659
 
660
   // Waveform tab
661
   //TODO
662
   measLayout[2]->AddFrame(setTab, f0leftX);
663
 
664
   // Bottom pane (File controls)
665
   subgroup[0] = measLayout[2]->GetWidth()-19;
666
   subgroup[1] = (measLayout[2]->GetHeight())/4-4;
667
   fH1 = new TGCompositeFrame(measLayout[2], subgroup[0], subgroup[1], kFixedWidth | kFixedHeight | kHorizontalFrame);
668
   fG1 = new TGGroupFrame(fH1, "Event/Data file controls");
669
 
670
   // Number of events
671
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *evtNum -> Number entry for set number of events to acquire\n");
672
   evtNum = new TSubStructure();
673
   for(int i = 0; i < 6; i++) numform[i] = 0;
674
   numform[0] = 8; numform[2] = 1;
675
   if(evtNum->TGLabelNEntry(fG1, 3*subgroup[0]/4, 30, "Number of events:", 10000, numform, "left"))
676
      fG1->AddFrame(evtNum->outsidebox, f0leftXpad);
677
 
678
   // Time stamp display
679
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *timeStamp -> Text entry for timestamp\n");
680
   timeStamp = new TSubStructure();
681
   if(timeStamp->TGLabelTEntry(fG1, 3*subgroup[0]/4, 30, "Time stamp:", "", "oneline"))
682
   {
683
      timeStamp->widgetTE->SetState(kFALSE);
684
      fG1->AddFrame(timeStamp->outsidebox, f1expandXpad);
685
   }
686
 
687
   // Save to file
688
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fileName -> Text entry for timestamp\n");
689
   fileName = new TSubStructure();
690
   char *cTemp;
691
   cTemp = new char[256];
692
   sprintf(cTemp, "%s/results/test%s", rootdir, histext);
693
   if(fileName->TGLabelTEntryButton(fG1, 3*subgroup[0]/4, 30, "Save to file:", cTemp, "...", "oneline"))
694
   {
695
      fileName->widgetTE->SetState(kFALSE);
696
      fG1->AddFrame(fileName->outsidebox, f1expandXpad);
697
   }
698
 
699
   fH1->AddFrame(fG1, new TGLayoutHints(kLHintsExpandX,8,2,2,2));
700
   // Bottom pane (File controls)
701
   measLayout[2]->AddFrame(fH1, f0leftX);
702
 
703
   // Start acquisition and progress bar
704
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *measProgress -> Button to start acquiring data and horizontal progress bar\n");
705
   measProgress = new TSubStructure();
706
   if(measProgress->TGButtonProgressTEntry(measLayout[2], 3*subgroup[0]/4, 30, "Start acquisition", "Estimated end time: "))
707
   {
708
      measProgress->widgetTE->SetState(kFALSE);
709
      measLayout[2]->AddFrame(measProgress->outsidebox, f1expandXpad);
710
   }
711
 
712
   // Actions for Main window //TODO
713
   vOutOpt->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "NegativePolarity()");
714
   vOutButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "VoltOut(=0)");
715
   vOutButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "VoltOut(=1)");
716
   vOutButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "VoltOut(=2)");
717
   posButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "PositionSet(=0)");
718
   posButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "PositionSet(=1)");
719
   posButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "PositionSet(=2)");
720
   posButtons->widgetTB[3]->Connect("Clicked()", "TGAppMainFrame", this, "PositionSet(=3)");
721
   rotButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=0)");
722
   rotButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=1)");
723
   rotButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=2)");
724
   rotButtons->widgetTB[3]->Connect("Clicked()", "TGAppMainFrame", this, "RotationSet(=3)");
725
   fileName->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "SaveFile()");
726
   measProgress->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "StartAcq()");
727
   // TODO - Save file
728
 
729
// Main window -----------------------------------------------------------------------------
730
 
731
// Display pane ----------------------------------------------------------------------------
732
   measCanvas = new TRootEmbeddedCanvas("measCanvas",measLayout[1],300,300);
733
   measLayout[1]->AddFrame(measCanvas, f1expand2d);
734
// Display pane ----------------------------------------------------------------------------
735
 
736
// Histogram file selection pane -----------------------------------------------------------
737
   subgroup[0] = (analysisLayout[0]->GetWidth())-4;
738
 
739
   // Open browser for file selection 
740
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *selectDir -> Button to open histogram files\n");
741
   selectDir = new TSubStructure();
742
   if(selectDir->TGLabelButton(analysisLayout[0], 3*subgroup[0]/4, 30, "File selection:", "...", "left"))
743
      analysisLayout[0]->AddFrame(selectDir->outsidebox, f0leftXpad);
744
 
745
   // List view of the opened files
746
   if(DBGSIG > 1) printf("AppLayout(): Creating TGListBox *fileList -> List box for opened histograms\n");
747
   fileList = new TGListBox(analysisLayout[0],1);
748
   fileList->GetVScrollbar();
749
   fileList->Resize(300, (3*analysisLayout[0]->GetHeight()/7)-10 );
750
   analysisLayout[0]->AddFrame(fileList, f1expandXpad);
751
 
752
   fH1 = new TGCompositeFrame(analysisLayout[0], subgroup[0], 30, kHorizontalFrame);
753
   // Multiple file selection toggle
754
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *multiSelect -> 2 check buttons (enable multiple select, select everything)\n");
755
   multiSelect = new TSubStructure();
756
   checksel = new int[2];
757
   checksel[0] = 0; checksel[1] = 0;
758
   selnames[0] = "Multiple file select"; selnames[1] = "Select all listed files";
759
   if(multiSelect->TGCheckList(fH1, subgroup[0]/2, 30, 2, selnames, checksel, "horizontal", "left"))
760
      fH1->AddFrame(multiSelect->outsidebox, f0leftX);
761
   delete[] checksel;
762
 
763
   // Previous/next controls, clear list and edit header
764
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fileListCtrl -> Multiple buttons for controlling and displaying the histograms in list box\n");
765
   fileListCtrl = new TSubStructure();
766
   selnames[0] = "<<"; selnames[1] = ">>"; selnames[2] = "Edit header"; selnames[3] = "Clear list";
767
   if(fileListCtrl->TGMultiButton(fH1, subgroup[0]/3, 30, 4, selnames, "right"))
768
      fH1->AddFrame(fileListCtrl->outsidebox, f0rightX);
769
 
770
   analysisLayout[0]->AddFrame(fH1, f1expandXpad);
771
 
772
   // Header information of opened file
773
   fG1 = new TGGroupFrame(analysisLayout[0], "Opened file header information");
774
 
775
   fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
776
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispTime -> Display text Entry for opened histogram (time stamp)\n");
777
   dispTime = new TSubStructure();
778
   if(dispTime->TGLabelTEntry(fH1, 3*subgroup[0]/4-24, 30, "Time:", "", "oneline"))
779
      fH1->AddFrame(dispTime->outsidebox, f0leftXnoleft);
780
   dispTime->widgetTE->SetState(kFALSE);
781
 
782
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispBias -> Number entry for opened histogram (bias voltage)\n");
783
   dispBias = new TSubStructure();
784
   for(int i = 0; i < 6; i++) numform[i] = 0;
785
   numform[0] = 7; numform[1] = 2;
786
   if(dispBias->TGLabelNEntry(fH1, subgroup[0]/4-24, 30, "Bias voltage:", 0.00, numform, "center"))
787
      fH1->AddFrame(dispBias->outsidebox, f0leftX);
788
   dispBias->widgetNE[0]->SetState(kFALSE);
789
   fG1->AddFrame(fH1, f0leftXpad);
790
 
791
   fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30);
792
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispPos -> Display text Entry for opened histogram (table position)\n");
793
   dispPos = new TSubStructure();
794
   if(dispPos->TGLabelTEntry(fH1, subgroup[0]/2-12, 30, "Position:", "", "oneline"))
795
      fH1->AddFrame(dispPos->outsidebox, f0leftXnoleft);
796
   dispPos->widgetTE->SetState(kFALSE);
797
 
798
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispTemp -> Number entry for opened histogram (temperature)\n");
799
   dispTemp = new TSubStructure();
800
   for(int i = 0; i < 6; i++) numform[i] = 0;
801
   numform[0] = 6; numform[1] = 1;
802
   if(dispTemp->TGLabelNEntry(fH1, subgroup[0]/4-18, 30, "Temperature:", 0.0, numform, "center"))
803
      fH1->AddFrame(dispTemp->outsidebox, f0leftX);
804
   dispTemp->widgetNE[0]->SetState(kFALSE);
805
 
806
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispAngle -> Number entry for opened histogram (incidence angle)\n");
807
   dispAngle = new TSubStructure();
808
   for(int i = 0; i < 6; i++) numform[i] = 0;
809
   numform[0] = 7; numform[1] = 2;
810
   if(dispAngle->TGLabelNEntry(fH1, subgroup[0]/4-18, 30, "Angle:", 0.00, numform, "center"))
811
      fH1->AddFrame(dispAngle->outsidebox, f0leftX);
812
   dispAngle->widgetNE[0]->SetState(kFALSE);
813
   fG1->AddFrame(fH1, f0leftXpad);
814
 
815
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *dispLaser -> Display text Entry for opened histogram (laser and additional info)\n");
816
   dispLaser = new TSubStructure();
817
   if(dispLaser->TGLabelTEntry(fG1, 3*subgroup[0]/4, 30, "Laser settings:", "", "oneline"))
818
      fG1->AddFrame(dispLaser->outsidebox, f1expandXpad);
819
   dispLaser->widgetTE->SetState(kFALSE);
820
 
821
   analysisLayout[0]->AddFrame(fG1, f1expandX);
822
 
823
   // Actions for histogram file selection pane
824
   selectDir->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "SelectDirectory()");
825
   multiSelect->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "ListMultiSelect(=0)");
826
   multiSelect->widgetChBox[1]->Connect("Clicked()", "TGAppMainFrame", this, "ListMultiSelect(=1)");
827
   fileList->Connect("DoubleClicked(Int_t)", "TGAppMainFrame", this, "FileListNavigation(Int_t)");
828
   fileListCtrl->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "FileListNavigation(=-2)");
829
   fileListCtrl->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "FileListNavigation(=-3)");
830
   fileListCtrl->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "HeaderEdit()");
831
   fileListCtrl->widgetTB[3]->Connect("Clicked()", "TGAppMainFrame", this, "ClearHistogramList()");
832
 
833
// Histogram file selection pane -----------------------------------------------------------
834
 
835
// Analysis pane ---------------------------------------------------------------------------
836
   fH1 = new TGCompositeFrame(analysisLayout[1], analysisLayout[1]->GetWidth(), 30, kHorizontalFrame);
837
 
838
   subgroup[0] = (analysisLayout[1]->GetWidth())/2-4;
839
   subgroup[1] = (analysisLayout[1]->GetHeight())-4;
840
 
841
   analTab = new TGTab(fH1, subgroup[0], subgroup[1]);
842
 
843
   // Analysis tabs
844
   // Integrate spectrum tab
845
   fT1 = analTab->AddTab("Integ. spectrum");
846
   fV1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kVerticalFrame | kFixedWidth | kFixedHeight);
847
 
848
   // Check buttons to toggle direction of integration and normalization
849
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *intSpect -> 3 check buttons (direction of integration, normalization)\n");
850
   intSpect = new TSubStructure();
851
   checksel = new int[3];
852
   checksel[0] = 0; checksel[1] = 0; checksel[2] = 1;
853
   selnames[0] = "X direction (for edge scans)";
854
   selnames[1] = "Y direction (for edge scans)";
855
   selnames[2] = "Normalize to number of events";
856
   if(intSpect->TGCheckList(fV1, subgroup[0], 30, 3, selnames, checksel, "vertical", "center"))
857
      fV1->AddFrame(intSpect->outsidebox, f1expandXpad);
858
   delete[] checksel;
859
 
860
   // Values for 2D plot pixel resolution
861
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *resol2d -> Pixel resolution for 2D plots\n");
862
   resol2d = new TSubStructure();
863
   for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
864
   numform[0] = 5; numform2[0] = 5; numform[2] = 2; numform2[2] = 2;
865
   if(resol2d->TGLabelDoubleNEntry(fV1, subgroup[0], 30, "2D plot pixel resolution (X, Y):", 40, numform, 40, numform2, "center"))
866
      fV1->AddFrame(resol2d->outsidebox, f1expandX);
867
 
868
   // Start integrating or set its defaults
869
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *intSpectButtons -> 2 buttons for integrating spectra\n");
870
   intSpectButtons = new TSubStructure();
871
   selnames[0] = "Start"; selnames[1] = "Start and edit"; selnames[2] = "Default values";
872
   if(intSpectButtons->TGMultiButton(fV1, subgroup[0], 30, 3, selnames, "center"))
873
      fV1->AddFrame(intSpectButtons->outsidebox, f1expandX);
874
 
875
   fT1->AddFrame(fV1, f1expandX);
876
 
877
   // Relative photon detection efficiency tab (PDE)
878
   fT1 = analTab->AddTab("Relative PDE");
879
   fV1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kVerticalFrame | kFixedWidth | kFixedHeight);
880
 
881
   // Check button to toggle normalization
882
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *relPde -> 2 check buttons (relative pde, normalization)\n");
883
   relPde = new TSubStructure();
884
   checksel = new int;
885
   *checksel = 1;
886
   selnames[0] = "Normalize to number of events";
887
   if(relPde->TGCheckList(fV1, subgroup[0], 30, 1, selnames, checksel, "vertical", "center"))
888
      fV1->AddFrame(relPde->outsidebox, f1expandXpad);
889
   delete[] checksel;
890
 
891
   // Calculate relative PDE using the middle of the pedestal peak
892
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *midPeak -> Calculate the relative PDE, by setting the middle of the pedestal peak.\n");
893
   midPeak = new TSubStructure();
894
   checksel = new int;
895
   *checksel = 0;
896
   selnames[0] = "Pedestal entries end at middle of ped. peak";
897
   if(midPeak->TGCheckList(fV1, subgroup[0], 30, 1, selnames, checksel, "vertical", "center"))
898
      fV1->AddFrame(midPeak->outsidebox, f1expandX);
899
   delete checksel;
900
 
901
   // Select the dark run 
902
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *darkRun -> Button to open histogram files of a dark run\n");
903
   darkRun = new TSubStructure();
904
   if(darkRun->TGLabelTEntryButton(fV1, 3*subgroup[0]/4, 30, "Select dark run histogram:", "", "...", "oneline"))
905
   {
906
      darkRun->widgetTE->SetState(kFALSE);
907
      fV1->AddFrame(darkRun->outsidebox, f1expandXpad);
908
   }
909
 
910
   // Select the offset of 0 angle
911
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *zeroAngle -> Set the offset for 0 angle\n");
912
   zeroAngle = new TSubStructure();
913
   for(int i = 0; i < 6; i++) numform[i] = 0;
914
   numform[0] = 6; numform[1] = 2;
915
   if(zeroAngle->TGLabelNEntry(fV1, 3*subgroup[0]/4, 30, "Offset to zero angle:", 0., numform, "center"))
916
      fV1->AddFrame(zeroAngle->outsidebox, f0centerX);
917
 
918
   // Start calculating the PDE or set its defaults
919
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *relPdeButtons -> 2 buttons for calculating the relative PDE\n");
920
   relPdeButtons = new TSubStructure();
921
   selnames[0] = "Start"; selnames[1] = "Start and edit"; selnames[2] = "Default values";
922
   if(relPdeButtons->TGMultiButton(fV1, subgroup[0], 30, 3, selnames, "center"))
923
      fV1->AddFrame(relPdeButtons->outsidebox, f1expandX);
924
 
925
   fT1->AddFrame(fV1, f1expandX);
926
 
927
   // Breaktown voltage tab
928
   fT1 = analTab->AddTab("Breakdown voltage");
929
   fV1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kVerticalFrame | kFixedWidth | kFixedHeight);
930
 
931
   // Select the minumum number of peaks for fitting to be initiated
932
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *minPeak -> Minimum number of peaks to fit for peak fitting\n");
933
   minPeak = new TSubStructure();
934
   for(int i = 0; i < 6; i++) numform[i] = 0;
935
   numform[0] = 4; numform[2] = 1; numform[3] = 2; numform[4] = 1; numform[5] = 20;
936
   if(minPeak->TGLabelNEntry(fV1, subgroup[0], 30, "Min. nr. of peaks:", 2, numform, "center"))
937
      fV1->AddFrame(minPeak->outsidebox, f0centerX);
938
 
939
   // Select which separation to use
940
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *peakSepCalc -> Make the separation between the selected peaks\n");
941
   peakSepCalc = new TSubStructure();
942
   for(int i = 0; i < 6; i++) numform[i] = 0;
943
   numform[0] = 4; numform[2] = 1; numform[3] = 2; numform[4] = 1; numform[5] = 3;
944
   if(peakSepCalc->TGLabelNEntry(fV1, subgroup[0], 30, "Calculate peak separation between N pe and N+1 pe peaks:", 1, numform, "center"))
945
      fV1->AddFrame(peakSepCalc->outsidebox, f0centerX);
946
 
947
   // Start calculating the breakdown voltage or set its defaults
948
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *brDownButtons -> 2 buttons for calculating the breakdown voltage\n");
949
   brDownButtons = new TSubStructure();
950
   selnames[0] = "Start"; selnames[1] = "Start and edit"; selnames[2] = "Default values";
951
   if(brDownButtons->TGMultiButton(fV1, subgroup[0], 30, 3, selnames, "center"))
952
      fV1->AddFrame(brDownButtons->outsidebox, f1expandX);
953
 
954
   fT1->AddFrame(fV1, f1expandX);
955
 
956
   // Surface scan tab
957
   fT1 = analTab->AddTab("Surface scan");
958
   fV1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kVerticalFrame | kFixedWidth | kFixedHeight);
959
 
960
   // Check button to toggle normalization
961
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *surfScanOpt -> 2 check buttons (normalization, zero bottom-left corner)\n");
962
   surfScanOpt = new TSubStructure();
963
   checksel = new int[2];
964
   checksel[0] = 1; checksel[1] = 0;
965
   selnames[0] = "Normalize to number of events"; selnames[1] = "Zero the bottom left corner";
966
   if(surfScanOpt->TGCheckList(fV1, subgroup[0], 30, 2, selnames, checksel, "vertical", "center"))
967
      fV1->AddFrame(surfScanOpt->outsidebox, f1expandXpad);
968
   delete[] checksel;
969
 
970
   // Values for 2D plot pixel resolution
971
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *resolSurf -> Pixel resolution for surface plots\n");
972
   resolSurf = new TSubStructure();
973
   for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
974
   numform[0] = 5; numform2[0] = 5; numform[2] = 2; numform2[2] = 2;
975
   if(resolSurf->TGLabelDoubleNEntry(fV1, subgroup[0], 30, "Surface plot pixel resolution (X, Y):", 40, numform, 40, numform2, "center"))
976
      fV1->AddFrame(resolSurf->outsidebox, f1expandX);
977
 
978
   // Start calculating the breakdown voltage or set its defaults
979
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *surfButtons -> 2 buttons for calculating the surface scan\n");
980
   surfButtons = new TSubStructure();
981
   selnames[0] = "Start"; selnames[1] = "Start and edit"; selnames[2] = "Default values";
982
   if(surfButtons->TGMultiButton(fV1, subgroup[0], 30, 3, selnames, "center"))
983
      fV1->AddFrame(surfButtons->outsidebox, f1expandX);
984
 
985
   fT1->AddFrame(fV1, f1expandX);
986
 
987
   // Timing tab
988
   fT1 = analTab->AddTab("Timing");
989
   fV1 = new TGCompositeFrame(fT1, subgroup[0], subgroup[1], kVerticalFrame | kFixedWidth | kFixedHeight);
990
 
991
   fT1->AddFrame(fV1, f1expandX);
992
 
993
   // Analysis tabs
994
   fH1->AddFrame(analTab, /*f1expandX*/f0leftX);
995
 
996
   // Peak fitting settings
997
   fV1 = new TGCompositeFrame(fH1, subgroup[0], 30, kVerticalFrame);
998
 
999
   fH2 = new TGCompositeFrame(fV1, subgroup[0], 30, kHorizontalFrame);
1000
   // Select the sigma for peak fitting
1001
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fitSigma -> Sigma for peak fitting\n");
1002
   fitSigma = new TSubStructure();
1003
   for(int i = 0; i < 6; i++) numform[i] = 0;
1004
   numform[0] = 6; numform[1] = 3; numform[2] = 2;
1005
   if(fitSigma->TGLabelNEntry(fH2, subgroup[0]/2, 30, "Peak sigma:", 1.2, numform, "center"))
1006
      fH2->AddFrame(fitSigma->outsidebox, f0centerX);
1007
   // Select the signal to noise treshold for peak fitting
1008
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fitTresh -> S/N ratio for peak fitting\n");
1009
   fitTresh = new TSubStructure();
1010
   for(int i = 0; i < 6; i++) numform[i] = 0;
1011
   numform[0] = 6; numform[1] = 3; numform[2] = 2;
1012
   if(fitTresh->TGLabelNEntry(fH2, subgroup[0]/2, 30, "S/N ratio:", 0.005, numform, "center"))
1013
      fH2->AddFrame(fitTresh->outsidebox, f0centerX);
1014
   fV1->AddFrame(fH2, f1expandXpad);
1015
 
1016
   // Select the background interpolation for peak fitting
1017
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fitInter -> Background interpolation for peak fitting\n");
1018
   fitInter = new TSubStructure();
1019
   for(int i = 0; i < 6; i++) numform[i] = 0;
1020
   numform[0] = 5; numform[2] = 1;
1021
   if(fitInter->TGLabelNEntry(fV1, subgroup[0], 30, "Back. interpolation:", 7, numform, "center"))
1022
      fV1->AddFrame(fitInter->outsidebox, f0centerX);
1023
 
1024
   // Select the ADC offset
1025
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *adcOffset -> Select the offset for all ADC spectra\n");
1026
   adcOffset = new TSubStructure();
1027
   for(int i = 0; i < 6; i++) numform[i] = 0;
1028
   numform[0] = 6; numform[1] = 2;
1029
   if(adcOffset->TGLabelNEntry(fV1, subgroup[0], 30, "ADC spectrum offset:", 0.00, numform, "center"))
1030
      fV1->AddFrame(adcOffset->outsidebox, f0centerX);
1031
 
1032
   // Select the acceptable error for peak fitting
1033
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *accError -> Acceptable peak fitting error for peak fitting\n");
1034
   accError = new TSubStructure();
1035
   for(int i = 0; i < 6; i++) numform[i] = 0;
1036
   numform[0] = 6; numform[1] = 2; numform[2] = 1;
1037
   if(accError->TGLabelNEntry(fV1, subgroup[0], 30, "Max. peak fit error:", 0.15, numform, "center"))
1038
      fV1->AddFrame(accError->outsidebox, f0centerX);
1039
 
1040
   // Select the pedestal lower limit for peak fitting
1041
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *pedesLow -> Lower ADC limit of pedestal peak for peak fitting\n");
1042
   pedesLow = new TSubStructure();
1043
   for(int i = 0; i < 6; i++) numform[i] = 0;
1044
   numform[0] = 6; numform[1] = 1; numform[2] = 2;
1045
   if(pedesLow->TGLabelNEntry(fV1, subgroup[0], 30, "Pedestal low limit:", 0.0, numform, "center"))
1046
      fV1->AddFrame(pedesLow->outsidebox, f0centerX);
1047
 
1048
   // Check buttons to toggle subtracting the background and exporting the fitted spectra
1049
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *fitChecks -> 2 check buttons (substracting background, exporting fitted spectra)\n");
1050
   fitChecks = new TSubStructure();
1051
   checksel = new int[2];
1052
   checksel[0] = 1; checksel[1] = 0;
1053
   selnames[0] = "Backround subtraction ON/OFF";
1054
   selnames[1] = "Export fitted spectra ON/OFF";
1055
   if(fitChecks->TGCheckList(fV1, subgroup[0], 30, 2, selnames, checksel, "vertical", "center"))
1056
      fV1->AddFrame(fitChecks->outsidebox, f1expandXpad);
1057
   delete[] checksel;
1058
 
1059
   // Analysis progress bar
1060
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *analysisProgress -> Horizontal progress bar for analysis\n");
1061
   analysisProgress = new TSubStructure();
1062
   if(analysisProgress->TGLabelProgress(fV1, subgroup[0], 30, "Current analysis:"))
1063
      fV1->AddFrame(analysisProgress->outsidebox, f1expandXpad);
1064
 
1065
   fH1->AddFrame(fV1, f1expandX);
1066
 
1067
   analysisLayout[1]->AddFrame(fH1, f1expandXpad);
1068
 
1069
   // Actions for analysis pane
1070
   intSpectButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=0)");
1071
   intSpectButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=1)");
1072
   intSpectButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisDefaults()");
1073
 
1074
   relPdeButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=0)");
1075
   relPdeButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=1)");
1076
   relPdeButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisDefaults()");
1077
   darkRun->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "SelectDarkHist()");
1078
 
1079
   brDownButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=0)");
1080
   brDownButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=1)");
1081
   brDownButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisDefaults()");
1082
 
1083
   surfButtons->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=0)");
1084
   surfButtons->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisHandle(=1)");
1085
   surfButtons->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "AnalysisDefaults()");
1086
// Analysis pane ---------------------------------------------------------------------------
1087
 
1088
// Histogram pane --------------------------------------------------------------------------
1089
   analysisCanvas = new TRootEmbeddedCanvas("analysisCanvas",analysisLayout[2],300,300);
1090
   analysisLayout[2]->AddFrame(analysisCanvas, f1expand2d);
1091
   analysisCanvas->GetCanvas()->SetGrid();
1092
// Histogram pane --------------------------------------------------------------------------
1093
 
1094
// Histogram controls pane -----------------------------------------------------------------
1095
   subgroup[0] = (analysisLayout[3]->GetWidth())-4;
1096
 
1097
   // Control for histogram X range
1098
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *adcRange -> Range for ADC histogram\n");
1099
   adcRange = new TSubStructure();
1100
   for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
1101
   numform[0] = 6; numform2[0] = 6;
1102
   if(adcRange->TGLabelDoubleNEntry(analysisLayout[3], subgroup[0], 30, "ADC range (min, max):", 0, numform, 0, numform2, "center"))
1103
      analysisLayout[3]->AddFrame(adcRange->outsidebox, f1expandXpad);
1104
 
1105
   // TDC window for getting data
1106
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *tdcRange -> Range for TDC histogram\n");
1107
   tdcRange = new TSubStructure();
1108
   for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
1109
   numform[0] = 8; numform[1] = 2; numform2[0] = 8; numform2[1] = 2;
1110
   if(tdcRange->TGLabelDoubleNEntry(analysisLayout[3], subgroup[0], 30, "TDC range (min, max):", -0.5, numform, 221.8, numform2, "center"))
1111
      analysisLayout[3]->AddFrame(tdcRange->outsidebox, f1expandXpad);
1112
 
1113
   // Y axis range settings
1114
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *yRange -> Y axis range\n");
1115
   yRange = new TSubStructure();
1116
   for(int i = 0; i < 6; i++) { numform[i] = 0; numform2[i] = 0; }
1117
   numform[0] = 8; numform[1] = 1; numform2[0] = 8; numform2[1] = 1;
1118
   if(yRange->TGLabelDoubleNEntry(analysisLayout[3], subgroup[0], 30, "Y range (min, max):", 0, numform, 0, numform2, "center"))
1119
      analysisLayout[3]->AddFrame(yRange->outsidebox, f1expandXpad);
1120
 
1121
   fH1 = new TGHorizontalFrame(analysisLayout[3], subgroup[0], 30);
1122
   // Select the channel to display
1123
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *selectCh -> Channel to display\n");
1124
   selectCh = new TSubStructure();
1125
   for(int i = 0; i < 6; i++) numform[i] = 0;
1126
   numform[0] = 3; numform[2] = 2; numform[3] = 2; numform[4] = 0; numform[5] = 7; // TODO - ko odprem file, nastavi zgornjo limito
1127
   if(selectCh->TGLabelNEntry(fH1, subgroup[0]/2-24, 30, "Display channel:", 0, numform, "center"))
1128
      fH1->AddFrame(selectCh->outsidebox, f0leftX);
1129
   selChannel = -1;
1130
 
1131
   // Change plot type
1132
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *plotType -> 3 buttons for selecting the plot type (ADC, TDC, ADC/TDC)\n");
1133
   plotType = new TSubStructure();
1134
   selnames[0] = "ADC"; selnames[1] = "TDC"; selnames[2] = "ADC/TDC";
1135
   if(plotType->TGMultiButton(fH1, subgroup[0]/2-24, 30, 3, selnames, "center"))
1136
      fH1->AddFrame(plotType->outsidebox, f1expandX);
1137
   analysisLayout[3]->AddFrame(fH1, f1expandXpad);
1138
 
1139
   // Check button to toggle logarithmic scale
1140
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *histOpt -> 2 check buttons (histogram logarithmic scale, clean plots)\n");
1141
   histOpt = new TSubStructure();
1142
   checksel = new int[2];
1143
   checksel[0] = 0; checksel[1] = 1;
1144
   selnames[0] = "Logarithmic scale ON/OFF";
1145
   selnames[1] = "Clean plots ON/OFF";
1146
   if(histOpt->TGCheckList(analysisLayout[3], subgroup[0], 30, 2, selnames, checksel, "vertical", "center"))
1147
      analysisLayout[3]->AddFrame(histOpt->outsidebox, f1expandXpad);
1148
   delete[] checksel;
1149
 
1150
   // Export the selected files
1151
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *exportHist -> Button to export current histogram\n");
1152
   exportHist = new TSubStructure();
1153
   if(exportHist->TGLabelButton(analysisLayout[3], subgroup[0], 30, "Export selected histograms:", "Export", "center"))
1154
      analysisLayout[3]->AddFrame(exportHist->outsidebox, f1expandXpad);
1155
 
1156
   // Edit the selected histograms
1157
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *editSelHist -> Button to additionally edit the selected histograms (make a canvas clone in a new tab)\n");
1158
   editSelHist = new TSubStructure();
1159
   if(editSelHist->TGLabelButton(analysisLayout[3], subgroup[0], 30, "Edit selected histograms:", "Edit", "center"))
1160
      analysisLayout[3]->AddFrame(editSelHist->outsidebox, f1expandXpad);
1161
 
167 f9daq 1162
   // Select position units to use for ploting (micrometer, table position units)
1163
   if(DBGSIG > 1) printf("AppLayout(): Creating TSubStructure *posUnitsPlot -> Dropdown menu for selecting the position units for ploting\n");
1164
   posUnitsPlot = new TSubStructure();
1165
   selnames[0] = "table units"; selnames[1] = "micrometers";
1166
   sprintf(selected, "table units");
1167
   if(posUnitsPlot->TGLabelDrop(analysisLayout[3], 2.*subgroup[0]/3., 30, "Position units for plots:", 2, selnames, selected))
1168
      analysisLayout[3]->AddFrame(posUnitsPlot->outsidebox, f0centerX);
1169
 
146 f9daq 1170
   // Actions for histogram controls pane //TODO
1171
   for(int i = 0; i < 2; i++)
1172
   {
1173
      adcRange->widgetNE[i]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "UpdateHistogram(=0)");
1174
//      (adcRange->widgetNE[i]->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "UpdateHistogram(=0)");
1175
      tdcRange->widgetNE[i]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "UpdateHistogram(=0)");
1176
//      (tdcRange->widgetNE[i]->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "UpdateHistogram(=0)");
1177
      yRange->widgetNE[i]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "UpdateHistogram(=0)");
1178
//      (yRange->widgetNE[i]->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "UpdateHistogram(=0)");
1179
   }
1180
   plotType->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "ChangeHisttype(=0)");
1181
   plotType->widgetTB[1]->Connect("Clicked()", "TGAppMainFrame", this, "ChangeHisttype(=1)");
1182
   plotType->widgetTB[2]->Connect("Clicked()", "TGAppMainFrame", this, "ChangeHisttype(=2)");
1183
   selectCh->widgetNE[0]->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "UpdateHistogram(=2)");
1184
   selectCh->widgetNE[0]->Connect("ValueChanged(Long_t)", "TGAppMainFrame", this, "UpdateHistogram(=2)");
1185
   (selectCh->widgetNE[0]->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "UpdateHistogram(=2)");
1186
   histOpt->widgetChBox[0]->Connect("Clicked()", "TGAppMainFrame", this, "HistogramOptions(=0)");
1187
   histOpt->widgetChBox[1]->Connect("Clicked()", "TGAppMainFrame", this, "HistogramOptions(=1)");
1188
   exportHist->widgetTB[0]->Connect("Clicked()", "TGAppMainFrame", this, "UpdateHistogram(=1)");
1189
 
1190
// Histogram controls pane -----------------------------------------------------------------
1191
}
1192
 
1193
// -------------------------------------------------------------------
1194
 
1195
// Closing main window and checking about information ----------------
1196
 
1197
void TGAppMainFrame::CloseWindow()
1198
{
1199
   gApplication->Terminate(0);
1200
}
1201
 
1202
Bool_t TGAppMainFrame::About()
1203
{
1204
   int ret = 0;
1205
 
1206
   new TGMsgBox(gClient->GetRoot(), fMain, fMain->GetWindowName(), "Software for SiPM characterization with\nCAMAC, scope, bias voltage and table position support\n\nCreated by Gasper Kukec Mezek (gasper.kukec@ung.si),\nUpdated on July 17th 2015", kMBIconQuestion, kMBClose, &ret);
1207
 
1208
   return kFALSE;
1209
}
1210
 
1211
// -------------------------------------------------------------------
1212
 
1213
// Subwindow constructor (+layout) and close subwindow ---------------
1214
/*
1215
TGMdiSubwindow::TGMdiSubwindow(TGMdiMainFrame *main, int w, int h)
1216
{
1217
   // Create a new subwindow
1218
   fMdiFrame = new TGMdiFrame(main, w, h);
1219
   fMdiFrame->Connect("CloseWindow()", "TGMdiSubwindow", this, "CloseWindow(=0)");
1220
   fMdiFrame->DontCallClose();
1221
}
1222
 
1223
Bool_t TGMdiSubwindow::CloseWindow(int layoutchange)
1224
{
1225
   int ret = 0;
1226
 
1227
   if(layoutchange == 0)
1228
      new TGMsgBox(gClient->GetRoot(), fMdiFrame, fMdiFrame->GetWindowName(), "Really want to close the window?", kMBIconExclamation, kMBYes | kMBNo, &ret);
1229
   else if(layoutchange == 1)
1230
      ret = kMBYes;
1231
   if(ret == kMBYes)
1232
   {
1233
      if(strcmp("Information window", fMdiFrame->GetWindowName()) == 0)
1234
         id = -1;
1235
      return fMdiFrame->CloseWindow();
1236
   }
1237
 
1238
   return kFALSE;
1239
}*/
1240
 
1241
// -------------------------------------------------------------------
1242
 
1243
// Main function -----------------------------------------------------
1244
void root_app()
1245
{
1246
   if(DBGSIG > 1)
1247
   {
1248
      printf("root_app(): Starting objects\n");
1249
      gObjectTable->Print();
1250
   }
1251
 
1252
   int winWidth = 1240;
1253
   int winHeight = 800;
1254
   layoutMainWindow(&winWidth, &winHeight);
1255
 
1256
   new TGAppMainFrame(gClient->GetRoot(), winWidth, winHeight);
1257
}
1258
 
1259
int main(int argc, char **argv)
1260
{
1261
   if(DBGSIG > 1)
1262
   {
1263
      printf("main(): Starting objects\n");
1264
      gObjectTable->Print();
1265
   }
1266
 
1267
   TApplication theApp("MdiTest", &argc, argv);
1268
   root_app();
1269
   theApp.Run();
1270
 
1271
   return 0;
1272
}
1273
 
1274
// -------------------------------------------------------------------