Rev 117 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
117 | f9daq | 1 | #include "workstation.h" |
2 | #include "daq.h" |
||
3 | #include "root_include.h" |
||
4 | #include "windowed_test.h" |
||
5 | |||
6 | #include <stdio.h> |
||
7 | #include <stdlib.h> |
||
8 | #include <time.h> |
||
9 | #include <unistd.h> |
||
10 | |||
11 | #include "daqscope.h" |
||
12 | |||
13 | //--------------------------------------------------------------- |
||
14 | // Subwindow layout class |
||
15 | |||
16 | class TGMdiSubwindow |
||
17 | { |
||
18 | RQ_OBJECT("TGMdiSubwindow") |
||
19 | |||
20 | protected: |
||
21 | TGMdiFrame *fMdiFrame; |
||
22 | |||
23 | public: |
||
24 | TGMdiSubwindow(TGMdiMainFrame *main, int w, int h); |
||
25 | |||
26 | TGMdiFrame *GetMdiFrame() const { return fMdiFrame; } |
||
27 | virtual Bool_t CloseWindow(); |
||
28 | }; |
||
29 | |||
30 | //--------------------------------------------------------------- |
||
31 | // Main window class |
||
32 | |||
33 | class TGAppMainFrame |
||
34 | { |
||
35 | RQ_OBJECT("TGAppMainFrame") |
||
36 | |||
37 | protected: |
||
38 | TGMainFrame *fMain; |
||
39 | TGMdiMainFrame *fMainFrame; |
||
40 | TGMdiMenuBar *fMenuBar; |
||
41 | TGLayoutHints *fMenuBarItemLayout; |
||
42 | TGPopupMenu *fMenuFile, *fMenuAnalysis, *fMenuWindow, *fMenuHelp; |
||
43 | TGPopupMenu *fMenuHisttype; |
||
44 | TGMdiSubwindow *settingsPane, *mainSubwindow, *histogramPane, *histogramPaneFile, *histogramPaneCtr; |
||
45 | |||
46 | void InitMenu(); |
||
47 | void MeasurementLayout(); |
||
48 | void CloseWindow(); |
||
49 | Bool_t About(); |
||
50 | public: |
||
51 | TGAppMainFrame(const TGWindow *p, int w, int h); |
||
52 | |||
53 | void HandleMenu(Int_t id); |
||
54 | |||
55 | void EnableVoltScan(); |
||
56 | void EnableSurfScan(); |
||
57 | void EnableZaxisScan(); |
||
58 | void VoltageLimit(); |
||
59 | void ChannelLimit(); |
||
60 | void CleanPlotToggle(); |
||
61 | void ConnectToScope(); |
||
62 | |||
63 | void SetVoltOut(); |
||
64 | void GetVoltOut(); |
||
65 | void ResetVoltOut(); |
||
66 | void SetPosition(); |
||
67 | void GetPosition(); |
||
68 | void HomePosition(); |
||
127 | f9daq | 69 | |
70 | void InitializeScope(); |
||
71 | void StartScopeAcq(); |
||
72 | void CustomScopeCommand(); |
||
73 | void SelectedMeasType(int mtype); |
||
74 | |||
117 | f9daq | 75 | void SaveFile(); |
76 | void StartAcq(); |
||
77 | |||
78 | void SelectDirectory(); |
||
79 | void ListMultiSelect(); |
||
80 | void ListSelectAll(); |
||
81 | void FileListNavigation(int pn); |
||
82 | |||
83 | void DisplayHistogram(char *histfile, int histtype); |
||
84 | void SetHistRange(); |
||
85 | void ChangeHisttype(int type); |
||
86 | void ChangeChannel(); |
||
87 | void HistogramExport(); |
||
88 | void MakeSurfPlot(TList *files); |
||
89 | void MakeBreakdownPlot(int nrp, double *volt, double *volterr, double *psep1, double *pseperr1, double *psep2, double *pseperr2, double *psep3, double *pseperr3, char *plotfile); |
||
90 | |||
91 | void FitSpectrum(TList *files, int q); |
||
92 | void EdgeDetection(TGraph *pdf, TGraph *cdf, char *outname, TCanvas *g1dCanvas, double pdfmax, int direction); |
||
93 | void IntegSpectrum(TList *files, int direction); |
||
94 | |||
95 | void RunMeas(void *ptr, int runCase, int zaxisscan); |
||
96 | }; |
||
97 | |||
98 | const char *histExt = ".root"; |
||
99 | const char *histExtAll = "*.root"; |
||
100 | daq *gDaq; |
||
101 | daqscope *gScopeDaq; |
||
102 | int debugSig = 0; |
||
103 | int retTemp; |
||
104 | int gStop=0; |
||
105 | unsigned int gBuf[BSIZE]; |
||
106 | int logchange = 0; |
||
107 | double tdctimeconversion = 45.0909; |
||
108 | double lenconversion = 0.3595; |
||
109 | int oscOn; |
||
127 | f9daq | 110 | const char *allMeasNames[11] = {"Amplitude","Area","Delay","Fall","Frequency","Maximum","Mean","Minimum","Peak-to-peak","Peak width","Rise"}; |
117 | f9daq | 111 | |
112 | // ROOT file variable structure ----------- |
||
113 | struct EventHeader { |
||
114 | int nrch; |
||
115 | int timestamp; |
||
116 | double biasvolt; |
||
117 | int xpos; |
||
118 | int ypos; |
||
119 | int zpos; |
||
120 | double temperature; |
||
121 | char laserinfo[256]; |
||
122 | } evtheader; |
||
123 | |||
124 | struct EventData { |
||
125 | int adcdata[8]; |
||
126 | int tdcdata[8]; |
||
127 | } evtdata; |
||
128 | |||
127 | f9daq | 129 | struct EventMeas { |
130 | double measdata; |
||
131 | } evtmeas; |
||
132 | |||
117 | f9daq | 133 | TFile *inroot; |
134 | TFile *outroot; |
||
135 | |||
127 | f9daq | 136 | // Test graphs for scope measurements |
137 | TCanvas *wCanvas; |
||
138 | TGraph *testgraph; |
||
139 | |||
117 | f9daq | 140 | //--------------------------------------------------------------- |
141 | // Global variables |
||
142 | |||
143 | TGCheckButton *voltscanOn; |
||
144 | TGCheckButton *surfscanOn; |
||
145 | TGCheckButton *zscanOn; |
||
146 | TGTextEntry *oscIP; |
||
147 | TGTextButton *oscConnect; |
||
148 | TGCheckButton *histogramOn; |
||
149 | TGNumberEntry *vHardlimit; |
||
150 | TGNumberEntry *NCH; |
||
151 | TGTextEntry *laserInfo; |
||
127 | f9daq | 152 | TGNumberEntry *chtemp; |
117 | f9daq | 153 | TGCheckButton *cleanOn; |
154 | |||
155 | TGTab *setTab; |
||
156 | TGComboBox *vOutCh; |
||
157 | TGNumberEntry *vOut; |
||
158 | TGCheckButton *vOutOnOff; |
||
159 | TGTextButton *vOutSet; |
||
160 | TGTextButton *vOutGet; |
||
161 | TGTextButton *vOutReset; |
||
162 | TGNumberEntry *vOutStart; |
||
163 | TGNumberEntry *vOutStop; |
||
164 | TGNumberEntry *vOutStep; |
||
165 | TGNumberEntry *xPos; |
||
166 | TGNumberEntry *yPos; |
||
167 | TGNumberEntry *zPos; |
||
168 | TGTextButton *positionSet; |
||
169 | TGTextButton *positionGet; |
||
170 | TGTextButton *positionHome; |
||
171 | TGNumberEntry *xPosMin; |
||
172 | TGNumberEntry *xPosMax; |
||
173 | TGNumberEntry *xPosStep; |
||
174 | TGNumberEntry *yPosMin; |
||
175 | TGNumberEntry *yPosMax; |
||
176 | TGNumberEntry *yPosStep; |
||
177 | TGNumberEntry *zPosMin; |
||
178 | TGNumberEntry *zPosMax; |
||
179 | TGNumberEntry *zPosStep; |
||
180 | TGNumberEntry *evtNum; |
||
181 | TGTextEntry *timeStamp; |
||
182 | TGTextEntry *fileName; |
||
183 | TGTextButton *saveFile; |
||
184 | TGTextButton *measStart; |
||
185 | TGLabel *busyLabel; |
||
186 | TGHProgressBar *curProgress; |
||
187 | |||
188 | TRootEmbeddedCanvas *histCanvas; |
||
189 | |||
190 | TGTextButton *selectDir; |
||
191 | TGListBox *fileList; |
||
192 | TGCheckButton *multiSelect; |
||
193 | TGCheckButton *multiSelectAll; |
||
194 | TGTextButton *prevFile; |
||
195 | TGTextButton *nextFile; |
||
196 | |||
197 | TGNumberEntry *adcMinRange; |
||
198 | TGNumberEntry *adcMaxRange; |
||
199 | TGNumberEntry *tdcMinwindow; |
||
200 | TGNumberEntry *tdcMaxwindow; |
||
201 | TGNumberEntry *yMinRange; |
||
202 | TGNumberEntry *yMaxRange; |
||
203 | TGNumberEntry *selectCh; |
||
204 | TGTextButton *changeADC; |
||
205 | TGTextButton *changeTDC; |
||
206 | TGTextButton *changeADCTDC; |
||
207 | TGTextButton *change2Dsurf; |
||
208 | TGCheckButton *logscale; |
||
209 | TGTextButton *exportHist; |
||
210 | TGNumberEntry *fitSigma; |
||
211 | TGNumberEntry *fitTresh; |
||
212 | TGNumberEntry *fitInter; |
||
213 | TGNumberEntry *accError; |
||
214 | TGCheckButton *exfitplots; |
||
215 | |||
127 | f9daq | 216 | //TGButtonGroup *sChangroup; |
217 | TGCheckButton *sCH[8]; |
||
218 | TGComboBox *sMeasType; |
||
219 | TGCheckButton *sCamaclink; |
||
220 | TGTextEntry *scopeCommand; |
||
221 | TGTextEntry *scopeReturn; |
||
222 | TGTextButton *sendScopeCustom; |
||
223 | TGComboBox *sMeasgroup; |
||
224 | TGTextButton *scopeInit; |
||
225 | |||
117 | f9daq | 226 | Bool_t firstrun = kTRUE; |
227 | Bool_t started; |
||
228 | Bool_t cleanPlots = kTRUE; |
||
229 | |||
230 | // Layout hints definitions |
||
231 | TGLayoutHints *f0 = new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2); |
||
232 | TGLayoutHints *f0centerx = new TGLayoutHints(kLHintsCenterX,2,2,2,2); |
||
233 | TGLayoutHints *f0centery = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,2,2); |
||
234 | TGLayoutHints *f0center2d = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,2,2,2,2); |
||
235 | TGLayoutHints *f0right = new TGLayoutHints(kLHintsRight | kLHintsTop,2,2,2,2); |
||
236 | TGLayoutHints *f1 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,2,2,2,2); |
||
237 | TGLayoutHints *f2 = new TGLayoutHints(kLHintsExpandX,2,2,2,2); |
||
238 | TGLayoutHints *f3 = new TGLayoutHints(kLHintsCenterY,2,2,20,2); |
||
239 | TGLayoutHints *f3notop = new TGLayoutHints(kLHintsCenterY,4,4,2,30); |
||
240 | |||
241 | // Separate functions ----------------------------------------- |
||
242 | void GetTime(int intime, char *outtime) |
||
243 | { |
||
244 | time_t rawtime; |
||
245 | struct tm * timeinfo; |
||
246 | if(intime < 0) |
||
247 | time(&rawtime); |
||
248 | else |
||
249 | rawtime = (time_t)intime; |
||
250 | timeinfo = localtime(&rawtime); |
||
251 | sprintf(outtime, "%s", asctime(timeinfo)); |
||
252 | int len = strlen(outtime); |
||
253 | if(len) outtime[len-1] = 0; |
||
254 | } |
||
255 | |||
256 | int MyTimer() |
||
257 | { |
||
258 | char cmd[100]; |
||
259 | GetTime(-1, cmd); |
||
260 | if (timeStamp) timeStamp->SetText(cmd); |
||
261 | return 0; |
||
262 | } |
||
263 | |||
264 | int GetChannel() |
||
265 | { |
||
266 | int selectedOutput; |
||
267 | if(vOutCh->GetSelected() < 8) selectedOutput = (vOutCh->GetSelected())+1; |
||
268 | else if( (vOutCh->GetSelected() >= 8) && (vOutCh->GetSelected() < 16) ) selectedOutput = (vOutCh->GetSelected())+93; |
||
269 | else selectedOutput = 1; |
||
270 | |||
271 | return selectedOutput; |
||
272 | } |
||
273 | |||
274 | void remove_ext(char *inname, char *outname) |
||
275 | { |
||
276 | char ctemp[256]; |
||
277 | for(int i = 0; i < (int)strlen(inname); i++) |
||
278 | { |
||
279 | if( (inname[i] == '.') && (i > (int)(strlen(inname)-6)) ) |
||
280 | { |
||
281 | ctemp[i] = '\0'; |
||
282 | sprintf(outname, "%s", ctemp); |
||
283 | break; |
||
284 | } |
||
285 | else |
||
286 | ctemp[i] = inname[i]; |
||
287 | } |
||
288 | |||
289 | if(debugSig) |
||
290 | printf("Outfile (remove_ext): %s\n", outname); |
||
291 | } |
||
292 | |||
293 | void remove_from_last(char *inname, char search, char *outname) |
||
294 | { |
||
295 | char ctemp[256]; |
||
296 | int searchpos = -1; |
||
297 | for(int i = (int)strlen(inname); i >= 0; i--) |
||
298 | { |
||
299 | if(inname[i] == search) |
||
300 | { |
||
301 | searchpos = i; |
||
302 | break; |
||
303 | } |
||
304 | } |
||
305 | |||
306 | for(int i = 0; i < searchpos; i++) |
||
307 | ctemp[i] = inname[i]; |
||
308 | |||
309 | ctemp[searchpos] = '\0'; |
||
310 | sprintf(outname, "%s", ctemp); |
||
311 | |||
312 | if(debugSig) |
||
313 | printf("Outfile (remove_from_last): %s\n", outname); |
||
314 | } |
||
315 | |||
127 | f9daq | 316 | void SeqNumber(int innum, int maxnum, char *outstr) |
317 | { |
||
318 | int zeronum = 5; |
||
319 | |||
320 | // Check how many zeroes we need to add to get sequential numbers |
||
321 | if( (maxnum > 0) && (maxnum < 1000) ) |
||
322 | zeronum = 2; |
||
323 | else if( (maxnum >= 1000) && (maxnum < 10000) ) |
||
324 | zeronum = 3; |
||
325 | else if( (maxnum >= 10000) && (maxnum < 100000) ) |
||
326 | zeronum = 4; |
||
327 | else if( (maxnum >= 100000) && (maxnum < 1000000) ) |
||
328 | zeronum = 5; |
||
329 | |||
330 | // Make the sequence number depending on the number of zeroes |
||
331 | if(zeronum == 2) |
||
332 | { |
||
333 | if(innum < 10) |
||
334 | sprintf(outstr, "00%d", innum); |
||
335 | else if( (innum >= 10) && (innum < 100) ) |
||
336 | sprintf(outstr, "0%d", innum); |
||
337 | else if( (innum >= 100) && (innum < 1000) ) |
||
338 | sprintf(outstr, "%d", innum); |
||
339 | } |
||
340 | else if(zeronum == 3) |
||
341 | { |
||
342 | if(innum < 10) |
||
343 | sprintf(outstr, "000%d", innum); |
||
344 | else if( (innum >= 10) && (innum < 100) ) |
||
345 | sprintf(outstr, "00%d", innum); |
||
346 | else if( (innum >= 100) && (innum < 1000) ) |
||
347 | sprintf(outstr, "0%d", innum); |
||
348 | else if( (innum >= 1000) && (innum < 10000) ) |
||
349 | sprintf(outstr, "%d", innum); |
||
350 | } |
||
351 | else if(zeronum == 4) |
||
352 | { |
||
353 | if(innum < 10) |
||
354 | sprintf(outstr, "0000%d", innum); |
||
355 | else if( (innum >= 10) && (innum < 100) ) |
||
356 | sprintf(outstr, "000%d", innum); |
||
357 | else if( (innum >= 100) && (innum < 1000) ) |
||
358 | sprintf(outstr, "00%d", innum); |
||
359 | else if( (innum >= 1000) && (innum < 10000) ) |
||
360 | sprintf(outstr, "0%d", innum); |
||
361 | else if( (innum >= 10000) && (innum < 100000) ) |
||
362 | sprintf(outstr, "%d", innum); |
||
363 | } |
||
364 | else if(zeronum == 5) |
||
365 | { |
||
366 | if(innum < 10) |
||
367 | sprintf(outstr, "00000%d", innum); |
||
368 | else if( (innum >= 10) && (innum < 100) ) |
||
369 | sprintf(outstr, "0000%d", innum); |
||
370 | else if( (innum >= 100) && (innum < 1000) ) |
||
371 | sprintf(outstr, "000%d", innum); |
||
372 | else if( (innum >= 1000) && (innum < 10000) ) |
||
373 | sprintf(outstr, "00%d", innum); |
||
374 | else if( (innum >= 10000) && (innum < 100000) ) |
||
375 | sprintf(outstr, "0%d", innum); |
||
376 | else if( (innum >= 100000) && (innum < 1000000) ) |
||
377 | sprintf(outstr, "%d", innum); |
||
378 | } |
||
379 | } |
||
380 | |||
117 | f9daq | 381 | // Peak detection function |
382 | int npeaks; |
||
383 | double FindPeaks(double *x, double *par) |
||
384 | { |
||
385 | double result = 0; |
||
386 | for(int i = 0; i < npeaks; i++) |
||
387 | { |
||
388 | double norm = par[3*i]; |
||
389 | double mean = par[3*i+1]; |
||
390 | double sigma = par[3*i+2]; |
||
391 | result += norm*TMath::Gaus(x[0], mean, sigma); |
||
392 | } |
||
393 | return result; |
||
394 | } |
||
395 | |||
396 | // Class related functions -------------------------------------- |
||
397 | |||
398 | // Apply the upper voltage limit from settings pane to main window |
||
399 | void TGAppMainFrame::VoltageLimit() |
||
400 | { |
||
401 | vOut->SetLimitValues(0, vHardlimit->GetNumber() ); |
||
402 | } |
||
403 | |||
404 | // Apply the upper channel limit from settings pane to histogram settings |
||
405 | void TGAppMainFrame::ChannelLimit() |
||
406 | { |
||
407 | selectCh->SetLimitValues(0, (NCH->GetNumber()-1) ); |
||
408 | } |
||
409 | |||
410 | // Enable or disable voltage scan controls |
||
411 | void TGAppMainFrame::EnableVoltScan() |
||
412 | { |
||
413 | if(voltscanOn->IsOn()) |
||
414 | { |
||
415 | vOutStart->SetState(kTRUE); |
||
416 | vOutStop->SetState(kTRUE); |
||
417 | vOutStep->SetState(kTRUE); |
||
418 | } |
||
419 | else |
||
420 | { |
||
421 | vOutStart->SetState(kFALSE); |
||
422 | vOutStop->SetState(kFALSE); |
||
423 | vOutStep->SetState(kFALSE); |
||
424 | } |
||
425 | } |
||
426 | |||
427 | // Enable or disable surface scan controls |
||
428 | void TGAppMainFrame::EnableSurfScan() |
||
429 | { |
||
430 | if(surfscanOn->IsOn()) |
||
431 | { |
||
432 | xPosMin->SetState(kTRUE); |
||
433 | xPosMax->SetState(kTRUE); |
||
434 | xPosStep->SetState(kTRUE); |
||
435 | yPosMin->SetState(kTRUE); |
||
436 | yPosMax->SetState(kTRUE); |
||
437 | yPosStep->SetState(kTRUE); |
||
438 | } |
||
439 | else |
||
440 | { |
||
441 | xPosMin->SetState(kFALSE); |
||
442 | xPosMax->SetState(kFALSE); |
||
443 | xPosStep->SetState(kFALSE); |
||
444 | yPosMin->SetState(kFALSE); |
||
445 | yPosMax->SetState(kFALSE); |
||
446 | yPosStep->SetState(kFALSE); |
||
447 | } |
||
448 | } |
||
449 | |||
450 | // Enable or disable Z axis scan controls |
||
451 | void TGAppMainFrame::EnableZaxisScan() |
||
452 | { |
||
453 | if(zscanOn->IsOn()) |
||
454 | { |
||
455 | zPosMin->SetState(kTRUE); |
||
456 | zPosMax->SetState(kTRUE); |
||
457 | zPosStep->SetState(kTRUE); |
||
458 | } |
||
459 | else |
||
460 | { |
||
461 | zPosMin->SetState(kFALSE); |
||
462 | zPosMax->SetState(kFALSE); |
||
463 | zPosStep->SetState(kFALSE); |
||
464 | } |
||
465 | } |
||
466 | |||
467 | // Toggle clean plots on/off |
||
468 | void TGAppMainFrame::CleanPlotToggle() |
||
469 | { |
||
470 | cleanPlots = cleanOn->IsDown(); |
||
471 | } |
||
472 | |||
473 | // Connect to oscilloscope |
||
474 | void TGAppMainFrame::ConnectToScope() |
||
475 | { |
||
476 | int scopeState = -1; |
||
477 | char *IPaddr = (char*)oscIP->GetText(); |
||
478 | int IPcorr = 0; |
||
479 | |||
480 | if(oscOn == 0) |
||
481 | { |
||
482 | // Check if the IP address has the required three . |
||
483 | for(int i = 0; i < (int)strlen(IPaddr); i++) |
||
484 | if(IPaddr[i] == '.') |
||
485 | IPcorr++; |
||
486 | |||
487 | if( (IPaddr != NULL) && (IPcorr == 3) ) |
||
488 | { |
||
127 | f9daq | 489 | #if WORKSTAT == 'I' || WORKSTAT == 'S' |
117 | f9daq | 490 | printf("Connecting to oscilloscope.\n"); |
491 | retTemp = gScopeDaq->connect(IPaddr); |
||
492 | scopeState = 1; // For testing instead of making a real connection |
||
493 | #else |
||
494 | scopeState = 1; |
||
127 | f9daq | 495 | retTemp = 0; |
117 | f9daq | 496 | #endif |
497 | } |
||
498 | else |
||
499 | { |
||
500 | scopeState = -1; |
||
501 | printf("Please enter a valid scope IP address.\n"); |
||
502 | } |
||
503 | } |
||
127 | f9daq | 504 | else if(oscOn > 0) |
117 | f9daq | 505 | { |
127 | f9daq | 506 | #if WORKSTAT == 'I' || WORKSTAT == 'S' |
117 | f9daq | 507 | printf("Disconnecting from oscilloscope.\n"); |
508 | retTemp = gScopeDaq->disconnect(IPaddr); |
||
509 | scopeState = -1; // For testing instead of making a real disconnection |
||
510 | #else |
||
511 | scopeState = -1; |
||
127 | f9daq | 512 | retTemp = 0; |
117 | f9daq | 513 | #endif |
514 | } |
||
515 | |||
127 | f9daq | 516 | if(retTemp == 0) |
117 | f9daq | 517 | { |
127 | f9daq | 518 | if(scopeState >= 0) |
519 | { |
||
520 | oscIP->SetEnabled(kFALSE); |
||
521 | oscConnect->SetText("Disconnect"); |
||
522 | oscConnect->SetTextJustify(36); |
||
523 | oscConnect->SetWrapLength(-1); |
||
524 | oscConnect->Resize(60,22); |
||
525 | |||
526 | for(int i = 0; i < 8; i++) |
||
527 | { |
||
528 | sCH[i]->SetState(kButtonUp); |
||
529 | sCH[i]->SetEnabled(kFALSE); |
||
530 | } |
||
531 | sMeasType->SetEnabled(kTRUE); |
||
532 | sCamaclink->SetState(kButtonUp); |
||
533 | sCamaclink->SetEnabled(kFALSE); |
||
534 | scopeCommand->SetEnabled(kTRUE); |
||
535 | sendScopeCustom->SetEnabled(kTRUE); |
||
536 | sMeasgroup->SetEnabled(kFALSE); |
||
537 | scopeInit->SetEnabled(kFALSE); |
||
538 | |||
539 | oscOn = 1; |
||
540 | } |
||
541 | else |
||
542 | { |
||
543 | oscIP->SetEnabled(kTRUE); |
||
544 | oscConnect->SetText("Connect"); |
||
545 | oscConnect->SetTextJustify(36); |
||
546 | oscConnect->SetWrapLength(-1); |
||
547 | oscConnect->Resize(60,22); |
||
548 | |||
549 | for(int i = 0; i < 8; i++) |
||
550 | { |
||
551 | sCH[i]->SetState(kButtonUp); |
||
552 | sCH[i]->SetEnabled(kFALSE); |
||
553 | } |
||
554 | sMeasType->Select(0); |
||
555 | sMeasType->SetEnabled(kFALSE); |
||
556 | sCamaclink->SetState(kButtonUp); |
||
557 | sCamaclink->SetEnabled(kFALSE); |
||
558 | scopeCommand->SetEnabled(kFALSE); |
||
559 | sendScopeCustom->SetEnabled(kFALSE); |
||
560 | sMeasgroup->SetEnabled(kFALSE); |
||
561 | scopeInit->SetEnabled(kFALSE); |
||
562 | |||
563 | oscOn = 0; |
||
564 | } |
||
117 | f9daq | 565 | } |
566 | else |
||
127 | f9daq | 567 | printf("Error! Connecting/disconnecting failed.\n"); |
117 | f9daq | 568 | } |
569 | |||
570 | // Set the output voltage |
||
571 | void TGAppMainFrame::SetVoltOut() |
||
572 | { |
||
573 | char cmd[256]; |
||
574 | int outOn; |
||
575 | float outputVoltage; |
||
576 | |||
577 | outputVoltage = vOut->GetNumber(); |
||
578 | |||
579 | if(vOutOnOff->IsOn()) outOn = 1; |
||
580 | else outOn = 0; |
||
581 | |||
582 | fflush(stdout); |
||
583 | sprintf(cmd, "%s/mpod/mpod_voltage.sh -o %d -v %f -s %d", rootdir, GetChannel(), outputVoltage, outOn); |
||
584 | #if WORKSTAT == 'I' |
||
585 | retTemp = system(cmd); |
||
586 | #else |
||
587 | printf("Cmd: %s\n",cmd); |
||
588 | #endif |
||
589 | fflush(stdout); |
||
590 | } |
||
591 | |||
592 | // Get the output voltage |
||
593 | void TGAppMainFrame::GetVoltOut() |
||
594 | { |
||
595 | char cmd[256]; |
||
596 | |||
597 | fflush(stdout); |
||
598 | sprintf(cmd, "%s/mpod/mpod_voltage.sh -o %d -g > %s/curvolt.txt", rootdir, GetChannel(), rootdir); |
||
599 | #if WORKSTAT == 'I' |
||
600 | retTemp = system(cmd); |
||
601 | #else |
||
602 | printf("Cmd: %s\n",cmd); |
||
603 | #endif |
||
604 | fflush(stdout); |
||
605 | |||
606 | #if WORKSTAT == 'I' |
||
607 | FILE* fvolt; |
||
608 | double dtemp; |
||
609 | char ctemp[24]; |
||
610 | sprintf(cmd, "%s/curvolt.txt", rootdir); |
||
611 | fvolt = fopen(cmd, "r"); |
||
612 | |||
613 | if(fvolt != NULL) |
||
614 | { |
||
615 | sprintf(cmd, "WIENER-CRATE-MIB::outputVoltage.u%d = Opaque: Float: %s V\n", GetChannel()-1, "%lf" ); |
||
616 | retTemp = fscanf(fvolt, cmd, &dtemp); |
||
617 | vOut->SetNumber(dtemp); |
||
618 | sprintf(cmd, "WIENER-CRATE-MIB::outputSwitch.u%d = INTEGER: %s\n", GetChannel()-1, "%s" ); |
||
619 | retTemp = fscanf(fvolt, cmd, ctemp); |
||
620 | if( strcmp(ctemp, "On(1)") == 0 ) |
||
621 | vOutOnOff->SetState(kButtonDown); |
||
622 | else if( strcmp(ctemp, "Off(0)") == 0 ) |
||
623 | vOutOnOff->SetState(kButtonUp); |
||
624 | } |
||
625 | |||
626 | fclose(fvolt); |
||
627 | #endif |
||
628 | } |
||
629 | |||
630 | // Reset the output voltage |
||
631 | void TGAppMainFrame::ResetVoltOut() |
||
632 | { |
||
633 | char cmd[256]; |
||
634 | |||
635 | vOut->SetNumber(0.000); |
||
636 | vOutOnOff->SetState(kButtonUp); |
||
637 | |||
638 | fflush(stdout); |
||
639 | sprintf(cmd, "%s/mpod/mpod_voltage.sh -r %d", rootdir, GetChannel()); |
||
640 | #if WORKSTAT == 'I' |
||
641 | retTemp = system(cmd); |
||
642 | #else |
||
643 | printf("Cmd: %s\n",cmd); |
||
644 | #endif |
||
645 | fflush(stdout); |
||
646 | } |
||
647 | |||
648 | // Get the current table position |
||
649 | void TGAppMainFrame::GetPosition() |
||
650 | { |
||
651 | char cmd[256]; |
||
652 | |||
653 | fflush(stdout); |
||
654 | |||
655 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 1 -p > %s/curpos.txt", rootdir, rootdir); // X-axis |
||
656 | fflush(stdout); |
||
657 | #if WORKSTAT == 'I' |
||
658 | retTemp = system(cmd); |
||
659 | #else |
||
660 | printf("Cmd: %s\n",cmd); |
||
661 | #endif |
||
662 | |||
663 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 2 -p >> %s/curpos.txt", rootdir, rootdir); // Y-axis |
||
664 | fflush(stdout); |
||
665 | #if WORKSTAT == 'I' |
||
666 | retTemp = system(cmd); |
||
667 | #else |
||
668 | printf("Cmd: %s\n",cmd); |
||
669 | #endif |
||
670 | |||
671 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 3 -p >> %s/curpos.txt", rootdir, rootdir); // Z-axis |
||
672 | fflush(stdout); |
||
673 | #if WORKSTAT == 'I' |
||
674 | retTemp = system(cmd); |
||
675 | #else |
||
676 | printf("Cmd: %s\n",cmd); |
||
677 | #endif |
||
678 | |||
679 | #if WORKSTAT == 'I' |
||
680 | FILE* fpos; |
||
681 | int itemp; |
||
682 | sprintf(cmd, "%s/curpos.txt", rootdir); |
||
683 | fpos = fopen(cmd, "r"); |
||
684 | |||
685 | if(fpos != NULL) |
||
686 | { |
||
687 | retTemp = fscanf(fpos, "%d\n", &itemp); |
||
688 | xPos->SetNumber(itemp); |
||
689 | retTemp = fscanf(fpos, "%d\n", &itemp); |
||
690 | yPos->SetNumber(itemp); |
||
691 | retTemp = fscanf(fpos, "%d\n", &itemp); |
||
692 | zPos->SetNumber(itemp); |
||
693 | } |
||
694 | |||
695 | fclose(fpos); |
||
696 | #endif |
||
697 | } |
||
698 | |||
699 | // Set the current table position |
||
700 | void TGAppMainFrame::SetPosition() |
||
701 | { |
||
702 | char cmd[256]; |
||
703 | int positX, positY, positZ; |
||
704 | |||
705 | positX = xPos->GetNumber(); |
||
706 | positY = yPos->GetNumber(); |
||
707 | positZ = zPos->GetNumber(); |
||
708 | |||
709 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 1 -v %d -s la && %s/MIKRO/mikro_ctrl -n 1 -c m", rootdir, positX, rootdir); |
||
710 | #if WORKSTAT == 'I' |
||
711 | retTemp = system(cmd); |
||
712 | #else |
||
713 | printf("Cmd: %s\n",cmd); |
||
714 | #endif |
||
715 | |||
716 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 2 -v %d -s la && %s/MIKRO/mikro_ctrl -n 2 -c m", rootdir, positY, rootdir); |
||
717 | #if WORKSTAT == 'I' |
||
718 | retTemp = system(cmd); |
||
719 | #else |
||
720 | printf("Cmd: %s\n",cmd); |
||
721 | #endif |
||
722 | |||
723 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 3 -v %d -s la && %s/MIKRO/mikro_ctrl -n 3 -c m", rootdir, positZ, rootdir); |
||
724 | #if WORKSTAT == 'I' |
||
725 | retTemp = system(cmd); |
||
726 | #else |
||
727 | printf("Cmd: %s\n",cmd); |
||
728 | #endif |
||
729 | } |
||
730 | |||
731 | // Set the current table position to a predetermined HOME position |
||
732 | void TGAppMainFrame::HomePosition() |
||
733 | { |
||
734 | char cmd[256]; |
||
735 | |||
736 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 1 -h", rootdir); // X-axis |
||
737 | #if WORKSTAT == 'I' |
||
738 | retTemp = system(cmd); |
||
739 | #else |
||
740 | printf("Cmd: %s\n",cmd); |
||
741 | #endif |
||
742 | |||
743 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 2 -h", rootdir); // Y-axis |
||
744 | #if WORKSTAT == 'I' |
||
745 | retTemp = system(cmd); |
||
746 | #else |
||
747 | printf("Cmd: %s\n",cmd); |
||
748 | #endif |
||
749 | |||
750 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 3 -h", rootdir); // Z-axis |
||
751 | #if WORKSTAT == 'I' |
||
752 | retTemp = system(cmd); |
||
753 | #else |
||
754 | printf("Cmd: %s\n",cmd); |
||
755 | #endif |
||
756 | } |
||
757 | |||
127 | f9daq | 758 | // Initialize the currently connected scope for measurements |
759 | void TGAppMainFrame::InitializeScope() |
||
760 | { |
||
761 | int iTemp; |
||
762 | int chTemp[8]; |
||
763 | for(int i = 0; i < 8; i++) chTemp[i] = -1; |
||
764 | gScopeDaq->scopeUseType = sMeasType->GetSelected(); |
||
765 | |||
766 | // Check what channels are selected |
||
767 | iTemp = 0; |
||
768 | for(int i = 0; i < 8; i++) |
||
769 | { |
||
770 | if(sCH[i]->IsDown()) |
||
771 | { |
||
772 | chTemp[iTemp] = i; |
||
773 | iTemp++; |
||
774 | } |
||
775 | } |
||
776 | if(iTemp == 0) |
||
777 | { |
||
778 | // If no channel is selected, we select the first one |
||
779 | chTemp[0] = 0; |
||
780 | iTemp++; |
||
781 | sCH[0]->SetState(kButtonDown); |
||
782 | } |
||
783 | // If measurement is used, only use the first selected channel |
||
784 | if(gScopeDaq->scopeUseType == 2) |
||
785 | { |
||
786 | for(int i = 1; i < iTemp; i++) |
||
787 | sCH[chTemp[i]]->SetState(kButtonUp); |
||
788 | iTemp = 1; |
||
789 | } |
||
790 | |||
791 | gScopeDaq->scopeChanNr = iTemp; |
||
792 | for(int i = 0; i < 8; i++) gScopeDaq->scopeChans[i] = chTemp[i]; |
||
793 | |||
794 | // Check which measurement is selected |
||
795 | gScopeDaq->scopeMeasSel = sMeasgroup->GetSelected(); |
||
796 | |||
797 | gScopeDaq->init(); |
||
798 | } |
||
799 | |||
800 | // Run a scope measurement |
||
801 | void TGAppMainFrame::StartScopeAcq() |
||
802 | { |
||
803 | // Lock the scope front panel |
||
804 | gScopeDaq->lockunlock(true); |
||
805 | |||
806 | retTemp = gScopeDaq->event(); |
||
807 | |||
808 | if(gScopeDaq->scopeUseType == 1) |
||
809 | { |
||
810 | char len[16]; |
||
811 | int sval; |
||
812 | short *spoints; |
||
813 | |||
814 | if(retTemp == 0) |
||
815 | { |
||
816 | // Read the number of y bytes at beginning of CURVE binary data |
||
817 | memcpy(len, &gScopeDaq->eventbuf[1],1); |
||
818 | len[1] = 0; |
||
819 | sval = atoi(len); |
||
820 | // printf("Number of y bytes = %d\n", sval); |
||
821 | |||
822 | // Read the data |
||
823 | spoints = (short *)(&gScopeDaq->eventbuf[2+sval]); |
||
824 | |||
825 | // Read the number of data points |
||
826 | memcpy(len, &gScopeDaq->eventbuf[2],sval); |
||
827 | len[sval] = 0; |
||
828 | sval = atoi(len); |
||
829 | // printf("Number of data points = %d\n", sval/2); |
||
830 | |||
831 | double *grafx, *grafy; |
||
832 | grafx = new double[sval/2]; |
||
833 | grafy = new double[sval/2]; |
||
834 | // Parse data and graph it |
||
835 | for(int i = 0; i < sval/2; i++) |
||
836 | { |
||
837 | grafx[i] = i*gScopeDaq->tektime*10./(sval/2.); |
||
838 | grafy[i] = ((double)spoints[i]*5.*gScopeDaq->tekvolt/32767.) - (gScopeDaq->choffset*gScopeDaq->tekvolt); |
||
839 | } |
||
840 | |||
841 | wCanvas->cd(); |
||
842 | testgraph = new TGraph(sval/2, grafx, grafy); |
||
843 | testgraph->GetXaxis()->SetTitle("Time [s]"); |
||
844 | testgraph->GetXaxis()->SetRangeUser(grafx[0], grafx[(sval/2)-1]); |
||
845 | testgraph->GetYaxis()->SetTitle("Voltage [V]"); |
||
846 | testgraph->Draw("AL"); |
||
847 | wCanvas->Modified(); |
||
848 | wCanvas->Update(); |
||
849 | |||
850 | delete[] grafx; |
||
851 | delete[] grafy; |
||
852 | } |
||
853 | } |
||
854 | else if(gScopeDaq->scopeUseType == 2) |
||
855 | { |
||
856 | if(retTemp == 0) |
||
857 | { |
||
858 | if(gScopeDaq->measubuf < 1.e-4) |
||
859 | printf("Measurement: %le\n", gScopeDaq->measubuf); |
||
860 | else |
||
861 | printf("Measurement: %lf\n", gScopeDaq->measubuf); |
||
862 | } |
||
863 | } |
||
864 | |||
865 | // Unlock the scope front panel |
||
866 | gScopeDaq->lockunlock(false); |
||
867 | } |
||
868 | |||
869 | // Send a custom command to the scope |
||
870 | void TGAppMainFrame::CustomScopeCommand() |
||
871 | { |
||
872 | char *cmd = (char*)scopeCommand->GetText(); |
||
873 | char ret[100000]; |
||
874 | if( strchr(cmd, '?') == NULL) |
||
875 | { |
||
876 | printf("Sending command: %s\n", cmd); |
||
877 | #if WORKSTAT == 'I' || WORKSTAT == 'S' |
||
878 | gScopeDaq->customCommand(cmd, false, ret); |
||
879 | #endif |
||
880 | } |
||
881 | else |
||
882 | { |
||
883 | printf("Sending query: %s\n", cmd); |
||
884 | #if WORKSTAT == 'I' || WORKSTAT == 'S' |
||
885 | gScopeDaq->customCommand(cmd, true, ret); |
||
886 | #endif |
||
887 | } |
||
888 | |||
889 | #if WORKSTAT == 'I' || WORKSTAT == 'S' |
||
890 | scopeReturn->SetText(ret); |
||
891 | #endif |
||
892 | } |
||
893 | |||
894 | // When we select the measurement type, change other scope settings accordingly |
||
895 | void TGAppMainFrame::SelectedMeasType(int mtype) |
||
896 | { |
||
897 | // No waveform analysis |
||
898 | if(mtype == 0) |
||
899 | { |
||
900 | for(int i = 0; i < 8; i++) |
||
901 | { |
||
902 | sCH[i]->SetState(kButtonUp); |
||
903 | sCH[i]->SetEnabled(kFALSE); |
||
904 | } |
||
905 | sMeasType->SetEnabled(kTRUE); |
||
906 | sCamaclink->SetState(kButtonUp); |
||
907 | sCamaclink->SetEnabled(kFALSE); |
||
908 | scopeCommand->SetEnabled(kTRUE); |
||
909 | sendScopeCustom->SetEnabled(kTRUE); |
||
910 | sMeasgroup->SetEnabled(kFALSE); |
||
911 | scopeInit->SetEnabled(kFALSE); |
||
912 | |||
913 | oscOn = 1; |
||
914 | } |
||
915 | // Complete waveform acquisition |
||
916 | else if(mtype == 1) |
||
917 | { |
||
918 | for(int i = 0; i < 8; i++) |
||
919 | sCH[i]->SetEnabled(kTRUE); |
||
920 | sMeasType->SetEnabled(kTRUE); |
||
921 | sCamaclink->SetState(kButtonDown); |
||
922 | sCamaclink->SetEnabled(kTRUE); |
||
923 | scopeCommand->SetEnabled(kTRUE); |
||
924 | sendScopeCustom->SetEnabled(kTRUE); |
||
925 | sMeasgroup->SetEnabled(kFALSE); |
||
926 | scopeInit->SetEnabled(kTRUE); |
||
927 | |||
928 | oscOn = 2; |
||
929 | } |
||
930 | // Waveform measurements |
||
931 | else if(mtype == 2) |
||
932 | { |
||
933 | for(int i = 0; i < 8; i++) |
||
934 | sCH[i]->SetEnabled(kTRUE); |
||
935 | sMeasType->SetEnabled(kTRUE); |
||
936 | sCamaclink->SetState(kButtonUp); |
||
937 | sCamaclink->SetEnabled(kTRUE); |
||
938 | scopeCommand->SetEnabled(kTRUE); |
||
939 | sendScopeCustom->SetEnabled(kTRUE); |
||
940 | sMeasgroup->SetEnabled(kTRUE); |
||
941 | scopeInit->SetEnabled(kTRUE); |
||
942 | |||
943 | oscOn = 3; |
||
944 | } |
||
945 | } |
||
946 | |||
117 | f9daq | 947 | // Make breakdown voltage plot |
948 | void TGAppMainFrame::MakeBreakdownPlot(int nrp, double *volt, double *volterr, double *psep1, double *pseperr1, double *psep2, double *pseperr2, double *psep3, double *pseperr3, char *plotfile) |
||
949 | { |
||
950 | double fparam[2], fparamerr[2], meanval; |
||
951 | TLatex *latex; |
||
952 | char ctemp[256]; |
||
953 | int sortindex[nrp]; |
||
954 | |||
955 | TCanvas *canvas = new TCanvas("canv","canv",900,1200); |
||
956 | canvas->Divide(1,3); |
||
957 | |||
958 | TGraphErrors *gr1 = new TGraphErrors(nrp, volt, psep1, volterr, pseperr1); |
||
959 | TGraphErrors *gr2 = new TGraphErrors(nrp, volt, psep2, volterr, pseperr2); |
||
960 | TGraphErrors *gr3 = new TGraphErrors(nrp, volt, psep3, volterr, pseperr3); |
||
961 | |||
962 | if(!cleanPlots) |
||
963 | gr1->SetTitle("1st - 2nd peak separation"); |
||
964 | else |
||
965 | gr1->SetTitle(); |
||
966 | gr1->SetLineColor(kBlue); |
||
967 | gr1->SetMarkerColor(kBlue); |
||
968 | gr1->SetMarkerStyle(20); |
||
969 | gr1->SetMarkerSize(0.6); |
||
970 | |||
971 | |||
972 | if(!cleanPlots) |
||
973 | gr2->SetTitle("2nd - 3rd peak separation"); |
||
974 | else |
||
975 | gr2->SetTitle(); |
||
976 | gr2->SetLineColor(kMagenta); |
||
977 | gr2->SetMarkerColor(kMagenta); |
||
978 | gr2->SetMarkerStyle(21); |
||
979 | gr2->SetMarkerSize(0.4); |
||
980 | |||
981 | if(!cleanPlots) |
||
982 | gr3->SetTitle("3rd - 4th peak separation"); |
||
983 | else |
||
984 | gr3->SetTitle(); |
||
985 | gr3->SetLineColor(kGreen); |
||
986 | gr3->SetMarkerColor(kGreen); |
||
987 | gr3->SetMarkerStyle(22); |
||
988 | gr3->SetMarkerSize(0.6); |
||
989 | |||
990 | // Plotting the first breakdown voltage plot |
||
991 | canvas->cd(1); |
||
992 | gPad->SetGridx(1); |
||
993 | gPad->SetGridy(1); |
||
994 | |||
995 | gr1->Draw("AP"); |
||
996 | gr1->GetXaxis()->SetTitle("Bias voltage (V)"); |
||
997 | gr1->GetYaxis()->SetTitle("Peak separation"); |
||
998 | gr1->GetYaxis()->CenterTitle(); |
||
999 | gr1->Fit("pol1","Q"); |
||
1000 | |||
1001 | TF1 *fit1 = gr1->GetFunction("pol1"); |
||
1002 | fparam[0] = fit1->GetParameter(0); |
||
1003 | fparamerr[0] = fit1->GetParError(0); |
||
1004 | fparam[1] = fit1->GetParameter(1); |
||
1005 | fparamerr[1] = fit1->GetParError(1); |
||
1006 | |||
1007 | TMath::Sort(nrp, psep1, sortindex, kFALSE); |
||
1008 | |||
1009 | meanval = -fparam[0]/fparam[1]; |
||
1010 | if(!cleanPlots) |
||
1011 | { |
||
1012 | sprintf(ctemp, "#splitline{#Delta_{p}(U) = (%.2lf #pm %.2lf)#timesU + (%.2lf #pm %.3lf)}{U_{0} = %.2lf #pm %.3lf}", fparam[0], fparamerr[0], fparam[1], fparamerr[1], meanval, meanval*(TMath::Abs(fparamerr[0]/fparam[0]) + TMath::Abs(fparamerr[1]/fparam[1])) ); |
||
1013 | latex = new TLatex(); |
||
1014 | latex->SetTextSize(0.039); |
||
1015 | latex->DrawLatex(volt[0]-(volt[1]-volt[0]), 0.97*psep1[sortindex[nrp-1]], ctemp); |
||
1016 | } |
||
1017 | else |
||
1018 | printf("#Delta_p(U) = (%.2lf #pm %.2lf)*U + (%.2lf #pm %.3lf)\nU_0 = %.2lf #pm %.3lf", fparam[0], fparamerr[0], fparam[1], fparamerr[1], meanval, meanval*(TMath::Abs(fparamerr[0]/fparam[0]) + TMath::Abs(fparamerr[1]/fparam[1])) ); |
||
1019 | |||
1020 | // Plotting the second breakdown voltage plot |
||
1021 | canvas->cd(2); |
||
1022 | gPad->SetGridx(1); |
||
1023 | gPad->SetGridy(1); |
||
1024 | |||
1025 | gr2->Draw("AP"); |
||
1026 | gr2->GetXaxis()->SetTitle("Bias voltage (V)"); |
||
1027 | gr2->GetYaxis()->SetTitle("Peak separation"); |
||
1028 | gr2->GetYaxis()->CenterTitle(); |
||
1029 | gr2->Fit("pol1","Q"); |
||
1030 | |||
1031 | TF1 *fit2 = gr2->GetFunction("pol1"); |
||
1032 | fparam[0] = fit2->GetParameter(0); |
||
1033 | fparamerr[0] = fit2->GetParError(0); |
||
1034 | fparam[1] = fit2->GetParameter(1); |
||
1035 | fparamerr[1] = fit2->GetParError(1); |
||
1036 | |||
1037 | meanval = -fparam[0]/fparam[1]; |
||
1038 | if(!cleanPlots) |
||
1039 | { |
||
1040 | sprintf(ctemp, "#splitline{#Delta_{p}(U) = (%.2lf #pm %.2lf)#timesU + (%.2lf #pm %.3lf)}{U_{0} = %.2lf #pm %.3lf}", fparam[0], fparamerr[0], fparam[1], fparamerr[1], meanval, meanval*(TMath::Abs(fparamerr[0]/fparam[0]) + TMath::Abs(fparamerr[1]/fparam[1])) ); |
||
1041 | latex = new TLatex(); |
||
1042 | latex->SetTextSize(0.039); |
||
1043 | latex->DrawLatex(volt[0]-(volt[1]-volt[0]), 0.97*psep2[sortindex[nrp-1]], ctemp); |
||
1044 | } |
||
1045 | else |
||
1046 | printf("#Delta_p(U) = (%.2lf #pm %.2lf)*U + (%.2lf #pm %.3lf)\nU_0 = %.2lf #pm %.3lf", fparam[0], fparamerr[0], fparam[1], fparamerr[1], meanval, meanval*(TMath::Abs(fparamerr[0]/fparam[0]) + TMath::Abs(fparamerr[1]/fparam[1])) ); |
||
1047 | |||
1048 | // Plotting the third breakdown voltage plot |
||
1049 | canvas->cd(3); |
||
1050 | gPad->SetGridx(1); |
||
1051 | gPad->SetGridy(1); |
||
1052 | |||
1053 | gr3->Draw("AP"); |
||
1054 | gr3->GetXaxis()->SetTitle("Bias voltage (V)"); |
||
1055 | gr3->GetYaxis()->SetTitle("Peak separation"); |
||
1056 | gr3->GetYaxis()->CenterTitle(); |
||
1057 | gr3->Fit("pol1","Q"); |
||
1058 | |||
1059 | TF1 *fit3 = gr3->GetFunction("pol1"); |
||
1060 | fparam[0] = fit3->GetParameter(0); |
||
1061 | fparamerr[0] = fit3->GetParError(0); |
||
1062 | fparam[1] = fit3->GetParameter(1); |
||
1063 | fparamerr[1] = fit3->GetParError(1); |
||
1064 | |||
1065 | meanval = -fparam[0]/fparam[1]; |
||
1066 | if(!cleanPlots) |
||
1067 | { |
||
1068 | sprintf(ctemp, "#splitline{#Delta_{p}(U) = (%.2lf #pm %.2lf)#timesU + (%.2lf #pm %.3lf)}{U_{0} = %.2lf #pm %.3lf}", fparam[0], fparamerr[0], fparam[1], fparamerr[1], meanval, meanval*(TMath::Abs(fparamerr[0]/fparam[0]) + TMath::Abs(fparamerr[1]/fparam[1])) ); |
||
1069 | latex = new TLatex(); |
||
1070 | latex->SetTextSize(0.039); |
||
1071 | latex->DrawLatex(volt[0]-(volt[1]-volt[0]), 0.97*psep3[sortindex[nrp-1]], ctemp); |
||
1072 | } |
||
1073 | else |
||
1074 | printf("#Delta_p(U) = (%.2lf #pm %.2lf)*U + (%.2lf #pm %.3lf)\nU_0 = %.2lf #pm %.3lf", fparam[0], fparamerr[0], fparam[1], fparamerr[1], meanval, meanval*(TMath::Abs(fparamerr[0]/fparam[0]) + TMath::Abs(fparamerr[1]/fparam[1])) ); |
||
1075 | |||
1076 | canvas->SaveAs(plotfile); |
||
1077 | } |
||
1078 | |||
1079 | // Fit the ADC spectrum peaks and make a breakdown voltage plot |
||
1080 | void TGAppMainFrame::FitSpectrum(TList *files, int q) |
||
1081 | { |
||
1082 | TCanvas *gCanvas = histCanvas->GetCanvas(); |
||
1083 | gCanvas->cd(); |
||
1084 | TH1F *histtemp; |
||
1085 | TSpectrum *spec; |
||
1086 | TH1 *histback; |
||
1087 | TH1F *h2; |
||
1088 | float *xpeaks; |
||
1089 | TF1 *fit; |
||
1090 | TF1 *fittingfunc; |
||
1091 | double *fparam; |
||
1092 | double *fparamerr; |
||
1093 | double meanparam[20], meanparamerr[20]; |
||
1094 | int sortindex[20]; |
||
1095 | char exportname[256]; |
||
1096 | char paramname[256]; |
||
1097 | char ctemp[256]; |
||
1098 | |||
1099 | FILE *fp; |
||
1100 | remove_from_last((char*)files->At(0)->GetTitle(), '_', ctemp); |
||
1101 | sprintf(paramname, "%s_fitresult.txt", ctemp); |
||
1102 | fp = fopen(paramname, "w"); |
||
1103 | fclose(fp); |
||
1104 | |||
1105 | int peaklimit = 5; |
||
1106 | int p = 0; |
||
1107 | double dtemp; |
||
1108 | double volt[files->GetSize()], volterr[files->GetSize()], sep[3][files->GetSize()], seperr[3][files->GetSize()]; |
||
1109 | for(int m = 0; m < files->GetSize(); m++) |
||
1110 | { |
||
1111 | volt[m] = 0; volterr[m] = 0; |
||
1112 | for(int i = 0; i < 3; i++) |
||
1113 | { sep[i][m] = 0; seperr[i][m] = 0; } |
||
1114 | } |
||
1115 | |||
1116 | for(int m = 0; m < files->GetSize(); m++) |
||
1117 | { |
||
1118 | for(int i = 0; i < 20; i++) { meanparam[20] = 0; meanparamerr[20] = 0; } |
||
1119 | |||
1120 | DisplayHistogram( (char*)(files->At(m)->GetTitle()), 0); |
||
1121 | dtemp = evtheader.biasvolt; |
||
1122 | gCanvas->Modified(); |
||
1123 | gCanvas->Update(); |
||
1124 | |||
1125 | histtemp = (TH1F*)gCanvas->GetPrimitive(histname); |
||
1126 | npeaks = 20; |
||
1127 | double par[3000]; |
||
1128 | spec = new TSpectrum(npeaks); |
||
1129 | // Find spectrum background |
||
1130 | histback = spec->Background(histtemp, (int)fitInter->GetNumber(), "same"); |
||
1131 | // Clone histogram and subtract background from it |
||
1132 | h2 = (TH1F*)histtemp->Clone("h2"); |
||
1133 | h2->Add(histback, -1); |
||
1134 | // Search for the peaks |
||
1135 | int found = spec->Search(h2, fitSigma->GetNumber(), "goff", fitTresh->GetNumber() ); |
||
1136 | printf("Found %d candidates to fit.\n",found); |
||
1137 | npeaks = found; |
||
1138 | |||
1139 | xpeaks = spec->GetPositionX(); |
||
1140 | for(int i = 0; i < found; i++) |
||
1141 | { |
||
1142 | float xp = xpeaks[i]; |
||
1143 | int bin = h2->GetXaxis()->FindBin(xp); |
||
1144 | float yp = h2->GetBinContent(bin); |
||
1145 | par[3*i] = yp; |
||
1146 | par[3*i+1] = xp; |
||
1147 | // par[3*i+2] = 3; |
||
1148 | par[3*i+2] = (double)fitSigma->GetNumber(); |
||
1149 | // printf("Peak %d: %f\n", i+1, xp); |
||
1150 | } |
||
1151 | |||
1152 | // Fit the histogram |
||
1153 | fit = new TF1("fit", FindPeaks, 0, 400, 3*npeaks); |
||
1154 | TVirtualFitter::Fitter(histtemp, 3*npeaks); |
||
1155 | fit->SetParameters(par); |
||
1156 | fit->SetNpx(300); |
||
1157 | h2->Fit("fit","Q"); // for quiet mode, add Q |
||
1158 | fittingfunc = h2->GetFunction("fit"); |
||
1159 | fparam = fittingfunc->GetParameters(); |
||
1160 | fparamerr = fittingfunc->GetParErrors(); |
||
1161 | |||
1162 | // Gather the parameters (mean peak value for now) |
||
1163 | int j = 1; |
||
1164 | int nrfit = 0; |
||
1165 | while(1) |
||
1166 | { |
||
1167 | if( (fparam[j] < 1.E-30) || (fparamerr[j] < 1.E-10) ) |
||
1168 | break; |
||
1169 | else |
||
1170 | { |
||
1171 | if(fparam[j] > 0) |
||
1172 | { |
||
1173 | meanparam[nrfit] = fparam[j]; |
||
1174 | meanparamerr[nrfit] = fparamerr[j]; |
||
1175 | nrfit++; |
||
1176 | } |
||
1177 | } |
||
1178 | |||
1179 | j+=3; |
||
1180 | } |
||
1181 | |||
1182 | // Write out parameters to a file |
||
1183 | fp = fopen(paramname, "a"); |
||
1184 | |||
1185 | fprintf(fp, "%d\t", nrfit); |
||
1186 | TMath::Sort(nrfit, meanparam, sortindex, kFALSE); |
||
1187 | for(int i = 0; i < nrfit; i++) |
||
1188 | { |
||
1189 | if(debugSig) |
||
1190 | printf("Peak %d: %lf\t%lf\n", i+1, meanparam[sortindex[i]], meanparamerr[sortindex[i]]); |
||
1191 | fprintf(fp, "%le\t%le\t", meanparam[sortindex[i]], meanparamerr[sortindex[i]]); |
||
1192 | } |
||
1193 | printf("\n"); |
||
1194 | fprintf(fp, "\n"); |
||
1195 | |||
1196 | fclose(fp); |
||
1197 | |||
1198 | h2->SetStats(0); |
||
1199 | |||
1200 | gCanvas->Modified(); |
||
1201 | gCanvas->Update(); |
||
1202 | |||
1203 | // Save each fitting plot |
||
1204 | if(exfitplots->IsDown()) |
||
1205 | { |
||
1206 | remove_ext((char*)files->At(m)->GetTitle(), ctemp); |
||
1207 | sprintf(exportname, "%s_fit.pdf", ctemp); |
||
1208 | gCanvas->SaveAs(exportname); |
||
1209 | } |
||
1210 | |||
1211 | // Get points for mean peak values and create a breakdown voltage plot |
||
1212 | if(nrfit >= peaklimit) |
||
1213 | { |
||
1214 | sep[0][p] = meanparam[sortindex[2]] - meanparam[sortindex[1]]; |
||
1215 | sep[1][p] = meanparam[sortindex[3]] - meanparam[sortindex[2]]; |
||
1216 | sep[2][p] = meanparam[sortindex[4]] - meanparam[sortindex[3]]; |
||
1217 | |||
1218 | seperr[0][p] = TMath::Abs(meanparamerr[sortindex[2]]) + TMath::Abs(meanparamerr[sortindex[1]]); |
||
1219 | seperr[1][p] = TMath::Abs(meanparamerr[sortindex[3]]) + TMath::Abs(meanparamerr[sortindex[2]]); |
||
1220 | seperr[2][p] = TMath::Abs(meanparamerr[sortindex[4]]) + TMath::Abs(meanparamerr[sortindex[3]]); |
||
1221 | |||
1222 | volt[p] = dtemp; |
||
1223 | volterr[p] = 1.e-4; |
||
1224 | |||
1225 | if(debugSig) |
||
1226 | printf("p=%d:\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\t%lf\n", p, volt[p], sep[0][p], seperr[0][p], sep[1][p], seperr[1][p], sep[2][p], seperr[2][p]); |
||
1227 | |||
1228 | // Accept only the points with a small enough error |
||
1229 | if( (seperr[0][p]/sep[0][p] < accError->GetNumber()) && (seperr[1][p]/sep[1][p] < accError->GetNumber()) && (seperr[2][p]/sep[2][p] < accError->GetNumber()) ) |
||
1230 | p++; |
||
1231 | else |
||
1232 | printf("Point (at %.2lfV) rejected due to errors: %lf, %lf, %lf\n", volt[p], seperr[0][p]/sep[0][p], seperr[1][p]/sep[1][p], seperr[2][p]/sep[2][p]); |
||
1233 | } |
||
1234 | |||
1235 | if(q == 1) break; |
||
1236 | } |
||
1237 | |||
1238 | // Plot & fit breakdown voltage plots |
||
1239 | if(q > 1) |
||
1240 | { |
||
1241 | remove_from_last((char*)files->At(0)->GetTitle(), '_', ctemp); |
||
1242 | sprintf(paramname, "%s_breakdown.pdf", ctemp); |
||
1243 | MakeBreakdownPlot(p, volt, volterr, sep[0], seperr[0], sep[1], seperr[1], sep[2], seperr[2], paramname); |
||
1244 | } |
||
1245 | } |
||
1246 | |||
1247 | // Plotting of PDF and CDF functions for the edge (with the added fit) |
||
1248 | void TGAppMainFrame::EdgeDetection(TGraph *pdf, TGraph *cdf, char *outname, TCanvas *g1dCanvas, double pdfmax, int direction) |
||
1249 | { |
||
1250 | // double x, y; |
||
1251 | |||
1252 | pdf->Fit("gaus","Q"); |
||
1253 | pdf->GetFunction("gaus")->SetNpx(400); |
||
1254 | /* |
||
1255 | for(int i = 0; i < nrpoints; i++) |
||
1256 | { |
||
1257 | pdf->GetPoint(i, x, y); |
||
1258 | pdf->SetPoint(i, x, (y/pdfmax) ); |
||
1259 | } |
||
1260 | */ |
||
1261 | gStyle->SetOptFit(1); |
||
1262 | |||
1263 | cdf->Draw("AL"); |
||
1264 | gPad->Update(); |
||
1265 | pdf->Draw("LP"); |
||
1266 | |||
1267 | g1dCanvas->Modified(); |
||
1268 | g1dCanvas->Update(); |
||
1269 | |||
1270 | TPaveStats *stats = (TPaveStats*)pdf->FindObject("stats"); |
||
1271 | if(!cleanPlots) |
||
1272 | { |
||
1273 | // stats->SetX1NDC(0.14); stats->SetX2NDC(0.28); |
||
1274 | // stats->SetY1NDC(0.83); stats->SetY2NDC(0.96); |
||
1275 | stats->SetX1NDC(0.86); stats->SetX2NDC(1.0); |
||
1276 | stats->SetY1NDC(0.87); stats->SetY2NDC(1.0); |
||
1277 | } |
||
1278 | else |
||
1279 | { |
||
1280 | stats->SetX1NDC(1.1); stats->SetX2NDC(1.3); |
||
1281 | stats->SetY1NDC(1.1); stats->SetY2NDC(1.3); |
||
1282 | } |
||
1283 | |||
1284 | g1dCanvas->SetGridx(1); |
||
1285 | g1dCanvas->SetGridy(1); |
||
1286 | if(direction == 1) |
||
1287 | cdf->GetXaxis()->SetTitle("X [#mum]"); |
||
1288 | else if(direction == 2) |
||
1289 | cdf->GetXaxis()->SetTitle("Y [#mum]"); |
||
1290 | cdf->GetXaxis()->CenterTitle(kTRUE); |
||
1291 | cdf->GetXaxis()->SetLabelSize(0.022); |
||
1292 | cdf->GetYaxis()->SetTitle("Normalized ADC integral"); |
||
1293 | // cdf->GetYaxis()->SetTitle("Normalized ADC integral (CDF)"); |
||
1294 | // cdf->GetYaxis()->SetTitleColor(kBlue); |
||
1295 | cdf->GetYaxis()->CenterTitle(kTRUE); |
||
1296 | cdf->GetYaxis()->SetLabelSize(0.022); |
||
1297 | cdf->GetYaxis()->SetRangeUser(0,1); |
||
1298 | cdf->GetYaxis()->SetTitleSize(0.030); |
||
1299 | // cdf->GetYaxis()->SetLabelColor(kBlue); |
||
1300 | if(!cleanPlots) |
||
1301 | cdf->SetTitle("SiPM edge detection"); |
||
1302 | else |
||
1303 | cdf->SetTitle(); |
||
1304 | cdf->SetLineColor(kBlue); |
||
1305 | pdf->SetLineWidth(2); |
||
1306 | cdf->SetLineWidth(2); |
||
1307 | |||
1308 | /* TGaxis *axis = new TGaxis(gPad->GetUxmax(), 0, gPad->GetUxmax(), 1, 0, pdfmax, 510, "+L"); |
||
1309 | axis->Draw(); |
||
1310 | axis->SetTitle("Normalized ADC integral (PDF)"); |
||
1311 | axis->SetTitleSize(0.035); |
||
1312 | axis->CenterTitle(); |
||
1313 | axis->SetTitleColor(kBlack); |
||
1314 | axis->SetTitleFont(42); |
||
1315 | axis->SetLabelSize(0.022); |
||
1316 | axis->SetLabelColor(kBlack);*/ |
||
1317 | |||
1318 | g1dCanvas->Modified(); |
||
1319 | g1dCanvas->Update(); |
||
1320 | |||
1321 | g1dCanvas->SaveAs(outname); |
||
1322 | } |
||
1323 | |||
1324 | // Integrate the spectrum |
||
1325 | void TGAppMainFrame::IntegSpectrum(TList *files, int direction) |
||
1326 | { |
||
1327 | unsigned int nrfiles = fileList->GetNumberOfEntries(); |
||
1328 | char ctemp[256]; |
||
1329 | int j, k = 0, m = 0, n = 0; |
||
1330 | |||
1331 | TCanvas *gCanvas = new TCanvas("canv","canv",900,900); |
||
1332 | TCanvas *g1dCanvas = new TCanvas("canv1d","canv1d",1200,900); |
||
1333 | TTree *header_data, *meas_data; |
||
1334 | double *integralCount, *integralAcc; |
||
1335 | integralCount = new double[nrfiles]; |
||
1336 | integralAcc = new double[nrfiles]; |
||
1337 | // double xsurfmin, ysurfmin, zsurfmin; |
||
1338 | double *surfx, *surfy, *surfz; |
||
1339 | surfx = new double[nrfiles]; |
||
1340 | surfy = new double[nrfiles]; |
||
1341 | surfz = new double[nrfiles]; |
||
1342 | for(int i = 0; i < (int)nrfiles; i++) {integralCount[i] = 0; integralAcc[i] = 0; } |
||
1343 | |||
1344 | TGraph *gScan[2]; // graphs for PDF and CDF functions |
||
1345 | double pdfmax = -1; |
||
1346 | TGraph2D *gScan2D; |
||
1347 | gScan2D = new TGraph2D(); |
||
1348 | int nrentries; |
||
1349 | double minInteg, maxInteg; |
||
1350 | |||
1351 | char exportname[256]; |
||
1352 | |||
1353 | if(files->GetSize() > 0) |
||
1354 | { |
||
1355 | for(int i = 0; i < (int)files->GetSize(); i++) |
||
1356 | { |
||
1357 | n++; |
||
1358 | if(files->At(i)) |
||
1359 | { |
||
1360 | sprintf(ctemp, "%s", files->At(i)->GetTitle()); |
||
1361 | inroot = new TFile(ctemp, "READ"); |
||
1362 | |||
1363 | inroot->GetObject("header_data", header_data); |
||
1364 | inroot->GetObject("meas_data", meas_data); |
||
1365 | |||
1366 | // Reading the header |
||
1367 | header_data->SetBranchAddress("xpos", &evtheader.xpos); |
||
1368 | header_data->GetEntry(0); |
||
1369 | header_data->SetBranchAddress("ypos", &evtheader.ypos); |
||
1370 | header_data->GetEntry(0); |
||
1371 | header_data->SetBranchAddress("zpos", &evtheader.zpos); |
||
1372 | header_data->GetEntry(0); |
||
1373 | |||
1374 | char rdc[256]; |
||
1375 | j = selectCh->GetNumber(); |
||
1376 | double rangetdc[2]; |
||
1377 | rangetdc[0] = tdcMinwindow->GetNumber(); |
||
1378 | rangetdc[1] = tdcMaxwindow->GetNumber(); |
||
1379 | |||
1380 | k = 0; |
||
1381 | m = 0; |
||
1382 | |||
1383 | // Reading the data |
||
1384 | for(int e = 0; e < meas_data->GetEntries(); e++) |
||
1385 | { |
||
1386 | sprintf(rdc, "ADC%d", j); |
||
1387 | meas_data->SetBranchAddress(rdc, &evtdata.adcdata[j]); |
||
1388 | meas_data->GetEntry(e); |
||
1389 | |||
1390 | sprintf(rdc, "TDC%d", j); |
||
1391 | meas_data->SetBranchAddress(rdc, &evtdata.tdcdata[j]); |
||
1392 | meas_data->GetEntry(e); |
||
1393 | |||
1394 | // If our data point is inside the TDC window |
||
1395 | if( ((double)evtdata.tdcdata[j]/tdctimeconversion >= rangetdc[0]) && ((double)evtdata.tdcdata[j]/tdctimeconversion <= rangetdc[1]) ) |
||
1396 | { |
||
1397 | k++; |
||
1398 | m += evtdata.adcdata[j]; |
||
1399 | } |
||
1400 | } |
||
1401 | |||
1402 | /* if(n == 1) // these values can be used to set 0 value at first X, Y and Z positions |
||
1403 | { |
||
1404 | xsurfmin = evtheader.xpos; |
||
1405 | ysurfmin = evtheader.ypos; |
||
1406 | zsurfmin = evtheader.zpos; |
||
1407 | } |
||
1408 | surfx[i] = (double)(evtheader.xpos-xsurfmin)*lenconversion; |
||
1409 | surfy[i] = (double)(evtheader.ypos-ysurfmin)*lenconversion; |
||
1410 | surfz[i] = (double)(evtheader.zpos-zsurfmin)*lenconversion;*/ |
||
1411 | surfx[i] = (double)(evtheader.xpos*lenconversion); |
||
1412 | surfy[i] = (double)(evtheader.ypos*lenconversion); |
||
1413 | surfz[i] = (double)(evtheader.zpos*lenconversion); |
||
1414 | |||
1415 | /* surfx[i] = evtheader.xpos; |
||
1416 | surfy[i] = evtheader.ypos; |
||
1417 | surfz[i] = evtheader.zpos; |
||
1418 | */ |
||
1419 | integralCount[i] += ((double)m)/((double)k); |
||
1420 | |||
1421 | delete inroot; |
||
1422 | } |
||
1423 | } |
||
1424 | |||
1425 | nrentries = n; |
||
1426 | printf("%d files were selected.\n", nrentries); |
||
1427 | |||
1428 | double curzval = surfz[0]; |
||
1429 | j = 0; |
||
1430 | int acc = 0; |
||
1431 | int zb; |
||
1432 | for(int i = 0; i <= nrentries; i++) |
||
1433 | { |
||
1434 | if(acc == nrentries) |
||
1435 | { |
||
1436 | minInteg = TMath::MinElement(j, integralAcc); |
||
1437 | |||
1438 | for(int za = 0; za < j; za++) |
||
1439 | integralAcc[za] = integralAcc[za] - minInteg; |
||
1440 | |||
1441 | maxInteg = TMath::MaxElement(j, integralAcc); |
||
1442 | |||
1443 | for(int za = 0; za < j; za++) |
||
1444 | { |
||
1445 | zb = i-j+za; |
||
1446 | integralCount[zb] = integralAcc[za]/maxInteg; |
||
1447 | if(debugSig) |
||
1448 | printf("Integral check 2 (i=%d,j=%d,za=%d,z=%.2lf,zb=%d): %lf\t%lf\n", i, j, za, surfz[i-j], zb, integralCount[zb], integralAcc[za]/maxInteg); |
||
1449 | } |
||
1450 | |||
1451 | // Plotting of PDF and CDF functions for the edge (with the added fit) |
||
1452 | gScan[1] = new TGraph(); |
||
1453 | for(int za = 0; za < j; za++) |
||
1454 | { |
||
1455 | zb = i-j+za; |
||
1456 | if(direction == 1) |
||
1457 | gScan[1]->SetPoint(za, (double)surfx[zb], (double)integralAcc[za]/maxInteg); |
||
1458 | else if(direction == 2) |
||
1459 | gScan[1]->SetPoint(za, (double)surfy[zb], (double)integralAcc[za]/maxInteg); |
||
1460 | |||
1461 | if( ((integralAcc[za+1]-integralAcc[za])/maxInteg > pdfmax) && (za < j-1) ) |
||
1462 | pdfmax = (integralAcc[za+1]-integralAcc[za])/maxInteg; |
||
1463 | } |
||
1464 | |||
1465 | pdfmax = (TMath::Ceil(pdfmax*10))/10.; |
||
1466 | |||
1467 | gScan[0] = new TGraph(); |
||
1468 | for(int za = j-1; za >= 0; za--) |
||
1469 | { |
||
1470 | zb = (i-1)-(j-1)+za; |
||
1471 | if((integralAcc[za]-integralAcc[za-1])/(maxInteg) < 0) |
||
1472 | { |
||
1473 | if(direction == 1) |
||
1474 | gScan[0]->SetPoint(za, (double)surfx[zb], 0); |
||
1475 | else if(direction == 2) |
||
1476 | gScan[0]->SetPoint(za, (double)surfy[zb], 0); |
||
1477 | } |
||
1478 | else |
||
1479 | { |
||
1480 | if(direction == 1) |
||
1481 | gScan[0]->SetPoint(za, (double)surfx[zb], (integralAcc[za]-integralAcc[za-1])/(maxInteg)); |
||
1482 | else if(direction == 2) |
||
1483 | gScan[0]->SetPoint(za, (double)surfy[zb], (integralAcc[za]-integralAcc[za-1])/(maxInteg)); |
||
1484 | // gScan[0]->SetPoint(za, (double)surfx[zb], (integralAcc[za]-integralAcc[za-1])/(pdfmax*maxInteg)); |
||
1485 | } |
||
1486 | } |
||
1487 | |||
1488 | remove_from_last((char*)files->At(i-1)->GetTitle(), '_', ctemp); |
||
1489 | sprintf(exportname, "%s_edge.pdf", ctemp); |
||
1490 | EdgeDetection(gScan[0], gScan[1], exportname, g1dCanvas, pdfmax, direction); |
||
1491 | |||
1492 | // delete gScan[0]; |
||
1493 | // delete gScan[1]; |
||
1494 | |||
1495 | i--; |
||
1496 | pdfmax = 0; |
||
1497 | break; |
||
1498 | } |
||
1499 | else |
||
1500 | { |
||
1501 | if(surfz[i] == curzval) |
||
1502 | { |
||
1503 | integralAcc[j] = integralCount[i]; |
||
1504 | if(debugSig) |
||
1505 | printf("Integral check 1 (i=%d,j=%d,z=%.2lf): %lf\t%lf\n", i, j, surfz[i], integralCount[i], integralAcc[j]); |
||
1506 | j++; |
||
1507 | acc++; |
||
1508 | } |
||
1509 | else |
||
1510 | { |
||
1511 | minInteg = TMath::MinElement(j, integralAcc); |
||
1512 | |||
1513 | for(int za = 0; za < j; za++) |
||
1514 | integralAcc[za] = integralAcc[za] - minInteg; |
||
1515 | |||
1516 | maxInteg = TMath::MaxElement(j, integralAcc); |
||
1517 | |||
1518 | for(int za = 0; za < j; za++) |
||
1519 | { |
||
1520 | zb = i-j+za; |
||
1521 | integralCount[zb] = integralAcc[za]/maxInteg; |
||
1522 | if(debugSig) |
||
1523 | printf("Integral check 2 (i=%d,j=%d,za=%d,z=%.2lf,zb=%d): %lf\t%lf\n", i, j, za, surfz[i-j], zb, integralCount[zb], integralAcc[za]/maxInteg); |
||
1524 | } |
||
1525 | |||
1526 | curzval = surfz[i]; |
||
1527 | i--; |
||
1528 | |||
1529 | // Plotting of PDF and CDF functions for the edge (with the added fit) |
||
1530 | gScan[1] = new TGraph(); |
||
1531 | for(int za = 0; za < j; za++) |
||
1532 | { |
||
1533 | zb = i-(j-1)+za; |
||
1534 | if(direction == 1) |
||
1535 | gScan[1]->SetPoint(za, (double)surfx[zb], (double)integralAcc[za]/maxInteg); |
||
1536 | else if(direction == 2) |
||
1537 | gScan[1]->SetPoint(za, (double)surfy[zb], (double)integralAcc[za]/maxInteg); |
||
1538 | |||
1539 | if( ((integralAcc[za+1]-integralAcc[za])/maxInteg > pdfmax) && (za < j-1) ) |
||
1540 | pdfmax = (integralAcc[za+1]-integralAcc[za])/maxInteg; |
||
1541 | } |
||
1542 | |||
1543 | pdfmax = (TMath::Ceil(pdfmax*10))/10.; |
||
1544 | |||
1545 | gScan[0] = new TGraph(); |
||
1546 | for(int za = j-1; za >= 0; za--) |
||
1547 | { |
||
1548 | zb = i-(j-1)+za; |
||
1549 | if((integralAcc[za]-integralAcc[za-1])/(maxInteg) < 0) |
||
1550 | { |
||
1551 | if(direction == 1) |
||
1552 | gScan[0]->SetPoint(za, (double)surfx[zb], 0); |
||
1553 | else if(direction == 2) |
||
1554 | gScan[0]->SetPoint(za, (double)surfy[zb], 0); |
||
1555 | } |
||
1556 | else |
||
1557 | { |
||
1558 | if(direction == 1) |
||
1559 | gScan[0]->SetPoint(za, (double)surfx[zb], (integralAcc[za]-integralAcc[za-1])/(maxInteg)); |
||
1560 | else if(direction == 2) |
||
1561 | gScan[0]->SetPoint(za, (double)surfy[zb], (integralAcc[za]-integralAcc[za-1])/(maxInteg)); |
||
1562 | // gScan[0]->SetPoint(za, (double)surfx[zb], (integralAcc[za]-integralAcc[za-1])/(pdfmax*maxInteg)); |
||
1563 | } |
||
1564 | } |
||
1565 | |||
1566 | remove_from_last((char*)files->At(i)->GetTitle(), '_', ctemp); |
||
1567 | sprintf(exportname, "%s_edge.pdf", ctemp); |
||
1568 | EdgeDetection(gScan[0], gScan[1], exportname, g1dCanvas, pdfmax, direction); |
||
1569 | |||
1570 | delete gScan[0]; |
||
1571 | delete gScan[1]; |
||
1572 | |||
1573 | j = 0; |
||
1574 | pdfmax = 0; |
||
1575 | } |
||
1576 | } |
||
1577 | } |
||
1578 | |||
1579 | // delete g1dCanvas; |
||
1580 | |||
1581 | double range[4]; |
||
1582 | if(direction == 1) |
||
1583 | { |
||
1584 | range[0] = TMath::MinElement(nrentries, surfx); |
||
1585 | range[1] = TMath::MaxElement(nrentries, surfx); |
||
1586 | } |
||
1587 | else if(direction == 2) |
||
1588 | { |
||
1589 | range[0] = TMath::MinElement(nrentries, surfy); |
||
1590 | range[1] = TMath::MaxElement(nrentries, surfy); |
||
1591 | } |
||
1592 | else |
||
1593 | { |
||
1594 | range[0] = TMath::MinElement(nrentries, surfx); |
||
1595 | range[1] = TMath::MaxElement(nrentries, surfx); |
||
1596 | } |
||
1597 | range[2] = TMath::MinElement(nrentries, surfz); |
||
1598 | range[3] = TMath::MaxElement(nrentries, surfz); |
||
1599 | |||
1600 | // Plotting of 2D edge plot |
||
1601 | for(int i = 0; i < nrentries; i++) |
||
1602 | { |
||
1603 | if(direction == 1) |
||
1604 | { |
||
1605 | if(debugSig) |
||
1606 | printf("%.2lf\t%.2lf\t%lf\n", surfx[i], surfz[i], integralCount[i]); |
||
1607 | gScan2D->SetPoint(i, surfx[i], surfz[i], integralCount[i]); |
||
1608 | } |
||
1609 | else if(direction == 2) |
||
1610 | { |
||
1611 | if(debugSig) |
||
1612 | printf("%.2lf\t%.2lf\t%lf\n", surfy[i], surfz[i], integralCount[i]); |
||
1613 | gScan2D->SetPoint(i, surfy[i], surfz[i], integralCount[i]); |
||
1614 | } |
||
1615 | } |
||
1616 | |||
1617 | gCanvas->cd(); |
||
1618 | gStyle->SetPalette(1); |
||
1619 | gScan2D->Draw("COLZ"); |
||
1620 | |||
1621 | gCanvas->Modified(); |
||
1622 | gCanvas->Update(); |
||
1623 | |||
1624 | if(direction == 1) |
||
1625 | gScan2D->GetXaxis()->SetTitle("X [#mum]"); |
||
1626 | else if(direction == 2) |
||
1627 | gScan2D->GetXaxis()->SetTitle("Y [#mum]"); |
||
1628 | gScan2D->GetXaxis()->CenterTitle(kTRUE); |
||
1629 | gScan2D->GetXaxis()->SetLabelSize(0.022); |
||
1630 | gScan2D->GetXaxis()->SetRangeUser(range[0], range[1]); |
||
1631 | gScan2D->GetXaxis()->SetNoExponent(); |
||
1632 | gScan2D->GetYaxis()->SetTitle("Z [#mum]"); |
||
1633 | gScan2D->GetYaxis()->SetTitleOffset(1.3); |
||
1634 | gScan2D->GetYaxis()->CenterTitle(kTRUE); |
||
1635 | gScan2D->GetYaxis()->SetLabelSize(0.022); |
||
1636 | gScan2D->GetYaxis()->SetRangeUser(range[2], range[3]); |
||
1637 | TGaxis *yax = (TGaxis*)gScan2D->GetYaxis(); |
||
1638 | yax->SetMaxDigits(4); |
||
1639 | if(!cleanPlots) |
||
1640 | gScan2D->SetTitle("Laser focal point"); |
||
1641 | else |
||
1642 | gScan2D->SetTitle(); |
||
1643 | |||
1644 | gCanvas->Modified(); |
||
1645 | gCanvas->Update(); |
||
1646 | |||
1647 | remove_from_last((char*)files->At(0)->GetTitle(), '_', ctemp); |
||
1648 | sprintf(exportname, "%s", ctemp); |
||
1649 | remove_from_last(exportname, '_', ctemp); |
||
1650 | if(direction == 1) |
||
1651 | sprintf(exportname, "%s_xdir_focalpoint.pdf", ctemp); |
||
1652 | else if(direction == 2) |
||
1653 | sprintf(exportname, "%s_ydir_focalpoint.pdf", ctemp); |
||
1654 | gCanvas->SaveAs(exportname); |
||
1655 | } |
||
1656 | } |
||
1657 | |||
1658 | void TGAppMainFrame::RunMeas(void *ptr, int runCase, int zaxisscan) |
||
1659 | { |
||
1660 | printf("Start of Run, run case %d\n", runCase); |
||
1661 | float progVal; |
||
1662 | |||
1663 | char ctemp[256]; |
||
127 | f9daq | 1664 | char ctemp2[256]; |
117 | f9daq | 1665 | char fname[256]; |
127 | f9daq | 1666 | int itemp = 0; |
117 | f9daq | 1667 | |
1668 | remove_ext((char*)fileName->GetText(), ctemp); |
||
1669 | // printf("Save name: %s\nNo extension: %s\n", fileName->GetText(), ctemp); |
||
1670 | |||
1671 | // Open file for writing |
||
1672 | /* if(runCase == 0) |
||
1673 | { |
||
1674 | sprintf(fname, "rm %s_%s", ctemp, histExtAll); |
||
1675 | retTemp = system(fname); |
||
1676 | }*/ // deleting might not be necesary due to RECREATE in root file open |
||
1677 | |||
1678 | if( voltscanOn->IsOn() || surfscanOn->IsOn() ) |
||
1679 | { |
||
1680 | if(zaxisscan == 0) |
||
1681 | { |
||
127 | f9daq | 1682 | if( (voltscanOn->IsOn()) && (vOutStep->GetNumber() > 0.) ) |
1683 | SeqNumber(runCase, (int)((vOutStop->GetNumber())-(vOutStart->GetNumber()))/(vOutStep->GetNumber()), ctemp2); |
||
1684 | else if( surfscanOn->IsOn() ) |
||
1685 | { |
||
1686 | if( xPosStep->GetNumber() == 0 ) |
||
1687 | itemp = 1; |
||
1688 | else |
||
1689 | itemp = (int)((xPosMax->GetNumber())-(xPosMin->GetNumber()))/(xPosStep->GetNumber()); |
||
1690 | |||
1691 | if( yPosStep->GetNumber() == 0 ) |
||
1692 | itemp *= 1; |
||
1693 | else |
||
1694 | itemp *= (int)((yPosMax->GetNumber())-(yPosMin->GetNumber()))/(yPosStep->GetNumber()); |
||
1695 | SeqNumber(runCase, itemp, ctemp2); |
||
1696 | } |
||
1697 | sprintf(fname, "%s_%s%s", ctemp, ctemp2, histExt); |
||
117 | f9daq | 1698 | } |
1699 | else if(zaxisscan == 1) |
||
1700 | { |
||
127 | f9daq | 1701 | SeqNumber((int)zPos->GetNumber(), (int)zPosMax->GetNumber(), ctemp2); |
1702 | |||
1703 | if( (voltscanOn->IsOn()) && (vOutStep->GetNumber() > 0.) ) |
||
1704 | { |
||
1705 | sprintf(fname, "%s_z%s_", ctemp, ctemp2); |
||
1706 | SeqNumber(runCase, (int)((vOutStop->GetNumber())-(vOutStart->GetNumber()))/(vOutStep->GetNumber())+1, ctemp2); |
||
1707 | strcat(fname, ctemp2); |
||
1708 | strcat(fname, histExt); |
||
1709 | } |
||
1710 | else if( surfscanOn->IsOn() ) |
||
1711 | { |
||
1712 | sprintf(fname, "%s_z%s_", ctemp, ctemp2); |
||
1713 | |||
1714 | if( xPosStep->GetNumber() == 0 ) |
||
1715 | itemp = 1; |
||
1716 | else |
||
1717 | itemp = (int)((xPosMax->GetNumber())-(xPosMin->GetNumber()))/(xPosStep->GetNumber())+1; |
||
1718 | |||
1719 | if( yPosStep->GetNumber() == 0 ) |
||
1720 | itemp *= 1; |
||
1721 | else |
||
1722 | itemp *= (int)((yPosMax->GetNumber())-(yPosMin->GetNumber()))/(yPosStep->GetNumber())+1; |
||
1723 | SeqNumber(runCase, itemp, ctemp2); |
||
1724 | strcat(fname, ctemp2); |
||
1725 | strcat(fname, histExt); |
||
1726 | } |
||
1727 | else |
||
1728 | sprintf(fname, "%s_z%s%s", ctemp, ctemp2, histExt); |
||
1729 | |||
1730 | /* if(runCase < 10) |
||
117 | f9daq | 1731 | sprintf(fname, "%s_z%d_0000%d%s", ctemp, (int)zPos->GetNumber(), runCase, histExt); |
1732 | else if( (runCase >= 10) && (runCase < 100) ) |
||
1733 | sprintf(fname, "%s_z%d_000%d%s", ctemp, (int)zPos->GetNumber(), runCase, histExt); |
||
1734 | else if( (runCase >= 100) && (runCase < 1000) ) |
||
1735 | sprintf(fname, "%s_z%d_00%d%s", ctemp, (int)zPos->GetNumber(), runCase, histExt); |
||
1736 | else if( (runCase >= 1000) && (runCase < 10000) ) |
||
1737 | sprintf(fname, "%s_z%d_0%d%s", ctemp, (int)zPos->GetNumber(), runCase, histExt); |
||
1738 | else if( (runCase >= 10000) && (runCase < 100000) ) |
||
1739 | sprintf(fname, "%s_z%d_0%d%s", ctemp, (int)zPos->GetNumber(), runCase, histExt); |
||
127 | f9daq | 1740 | */ } |
117 | f9daq | 1741 | } |
1742 | else if( !voltscanOn->IsOn() && !surfscanOn->IsOn() ) |
||
1743 | sprintf(fname, "%s%s", ctemp, histExt); |
||
1744 | // printf("Rootfile: %s\n", fname); |
||
1745 | |||
1746 | // Check if set voltage is below the hard limit |
||
1747 | if( vOut->GetNumber() > vHardlimit->GetNumber() ) |
||
1748 | { |
||
1749 | printf("Voltage hard limit triggered (%lf > %lf)!\n", vOut->GetNumber(), vHardlimit->GetNumber() ); |
||
1750 | vOut->SetNumber( vHardlimit->GetNumber() ); |
||
1751 | } |
||
1752 | |||
1753 | outroot = new TFile(fname, "RECREATE"); |
||
1754 | |||
1755 | TTree *header_data = new TTree("header_data", "Header information for the measurement."); |
||
127 | f9daq | 1756 | TTree *meas_data = new TTree("meas_data", "Saved ADC and TDC measurement data."); |
1757 | TTree *scope_data = new TTree("scope_data", "Saved scope measurement data."); |
||
117 | f9daq | 1758 | |
1759 | // Branches for the header |
||
1760 | header_data->Branch("nrch", &evtheader.nrch, "nrch/I"); |
||
1761 | header_data->Branch("timestamp", &evtheader.timestamp, "timestamp/I"); |
||
1762 | header_data->Branch("biasvolt", &evtheader.biasvolt, "biasvolt/D"); |
||
1763 | header_data->Branch("xpos", &evtheader.xpos, "xpos/I"); |
||
1764 | header_data->Branch("ypos", &evtheader.ypos, "ypos/I"); |
||
1765 | header_data->Branch("zpos", &evtheader.zpos, "zpos/I"); |
||
1766 | header_data->Branch("temperature", &evtheader.temperature, "temperature/D"); |
||
1767 | header_data->Branch("laserinfo", &evtheader.laserinfo, "laserinfo/C"); |
||
1768 | |||
1769 | evtheader.nrch = (int)NCH->GetNumber()*2; |
||
1770 | evtheader.timestamp = (int)time(NULL); |
||
1771 | evtheader.biasvolt = (double)vOut->GetNumber(); |
||
1772 | evtheader.xpos = (int)xPos->GetNumber(); |
||
1773 | evtheader.ypos = (int)yPos->GetNumber(); |
||
1774 | evtheader.zpos = (int)zPos->GetNumber(); |
||
127 | f9daq | 1775 | evtheader.temperature = (double)chtemp->GetNumber(); |
117 | f9daq | 1776 | sprintf(evtheader.laserinfo, "%s", laserInfo->GetText()); |
1777 | |||
1778 | char histtime[256]; |
||
1779 | GetTime(evtheader.timestamp, histtime); |
||
1780 | |||
1781 | printf("Save file header information:\n"); |
||
1782 | printf("- Number of channels: %d\n", evtheader.nrch); |
||
1783 | printf("- Timestamp: %d (%s)\n", evtheader.timestamp, histtime); |
||
1784 | printf("- Bias voltage: %lf\n", evtheader.biasvolt); |
||
1785 | printf("- Table position (X,Y,Z): %d, %d, %d\n", evtheader.xpos, evtheader.ypos, evtheader.zpos); |
||
1786 | printf("- Temperature: %lf\n", evtheader.temperature); |
||
1787 | printf("- Laser and filter settings: %s\n", evtheader.laserinfo); |
||
1788 | |||
1789 | header_data->Fill(); |
||
1790 | |||
1791 | // Branches for ADC and TDC data |
||
1792 | for(int i = 0; i < evtheader.nrch/2; i++) |
||
1793 | { |
||
1794 | sprintf(ctemp, "ADC%d", i); |
||
1795 | sprintf(fname, "ADC%d/I", i); |
||
1796 | meas_data->Branch(ctemp, &evtdata.adcdata[i], fname); |
||
1797 | |||
1798 | sprintf(ctemp, "TDC%d", i); |
||
1799 | sprintf(fname, "TDC%d/I", i); |
||
1800 | meas_data->Branch(ctemp, &evtdata.tdcdata[i], fname); |
||
1801 | } |
||
1802 | |||
127 | f9daq | 1803 | // Initialize the scope before measurement |
1804 | if( sCamaclink->IsDown() ) |
||
1805 | InitializeScope(); |
||
1806 | |||
1807 | // Branch for scope measurement data |
||
1808 | if(gScopeDaq->scopeUseType == 2) // only if we select waveform measurement |
||
1809 | { |
||
1810 | if(gScopeDaq->scopeMeasSel == 0) |
||
1811 | scope_data->Branch("amp", &evtmeas.measdata, "amp/D"); |
||
1812 | else if(gScopeDaq->scopeMeasSel == 1) |
||
1813 | scope_data->Branch("area", &evtmeas.measdata, "area/D"); |
||
1814 | else if(gScopeDaq->scopeMeasSel == 2) |
||
1815 | scope_data->Branch("delay", &evtmeas.measdata, "delay/D"); |
||
1816 | else if(gScopeDaq->scopeMeasSel == 3) |
||
1817 | scope_data->Branch("fall", &evtmeas.measdata, "fall/D"); |
||
1818 | else if(gScopeDaq->scopeMeasSel == 4) |
||
1819 | scope_data->Branch("freq", &evtmeas.measdata, "freq/D"); |
||
1820 | else if(gScopeDaq->scopeMeasSel == 5) |
||
1821 | scope_data->Branch("max", &evtmeas.measdata, "max/D"); |
||
1822 | else if(gScopeDaq->scopeMeasSel == 6) |
||
1823 | scope_data->Branch("mean", &evtmeas.measdata, "mean/D"); |
||
1824 | else if(gScopeDaq->scopeMeasSel == 7) |
||
1825 | scope_data->Branch("min", &evtmeas.measdata, "min/D"); |
||
1826 | else if(gScopeDaq->scopeMeasSel == 8) |
||
1827 | scope_data->Branch("pk2p", &evtmeas.measdata, "pk2p/D"); |
||
1828 | else if(gScopeDaq->scopeMeasSel == 9) |
||
1829 | scope_data->Branch("pwidth", &evtmeas.measdata, "pwidth/D"); |
||
1830 | else if(gScopeDaq->scopeMeasSel == 10) |
||
1831 | scope_data->Branch("rise", &evtmeas.measdata, "rise/D"); |
||
1832 | } |
||
1833 | |||
117 | f9daq | 1834 | int neve = (int) evtNum->GetNumber(); |
1835 | int allEvt, zProg; |
||
1836 | zProg = 1; |
||
1837 | |||
1838 | #if WORKSTAT == 'I' |
||
1839 | #else |
||
1840 | // ONLY FOR TESTING! |
||
1841 | TRandom *randNum = new TRandom(); |
||
1842 | randNum->SetSeed(0); |
||
1843 | // ONLY FOR TESTING! |
||
1844 | #endif |
||
1845 | |||
1846 | if (gDaq) |
||
1847 | { |
||
1848 | gDaq->fStop=0; |
||
1849 | // Start gathering |
||
1850 | gDaq->start(); |
||
1851 | |||
1852 | busyLabel->Enable(); |
||
1853 | |||
1854 | for (int n=0;n<neve && !gDaq->fStop ;/*n++*/) |
||
1855 | { |
||
1856 | int nb = gDaq->event(gBuf,BSIZE); |
||
1857 | |||
1858 | #if WORKSTAT == 'I' |
||
1859 | #else |
||
1860 | // ONLY FOR TESTING! |
||
1861 | for(int i=0; i < evtheader.nrch; i++) |
||
1862 | { |
||
1863 | if(i == 1) |
||
1864 | gBuf[i] = randNum->Gaus(1500,300); |
||
1865 | else if(i == 0) |
||
1866 | gBuf[i] = randNum->Poisson(2500); |
||
1867 | } |
||
1868 | // ONLY FOR TESTING! |
||
1869 | #endif |
||
1870 | if (nb<=0) n--; |
||
1871 | |||
1872 | int nc=0; |
||
1873 | |||
1874 | while ( (nb>0) && (n<neve) ) |
||
1875 | { |
||
1876 | for(int i = 0; i < evtheader.nrch; i++) |
||
1877 | { |
||
1878 | unsigned short adc = gBuf[i+nc]&0xFFFF; |
||
1879 | if(i % 2 == 0) // TDC |
||
1880 | evtdata.tdcdata[i/2] = (int)adc; |
||
1881 | else if(i % 2 == 1) // ADC |
||
1882 | evtdata.adcdata[i/2] = (int)adc; |
||
127 | f9daq | 1883 | |
1884 | // Start plotting the scope waveform |
||
1885 | if( (gScopeDaq->scopeUseType == 1) && (sCamaclink->IsDown()) ) |
||
1886 | StartScopeAcq(); |
||
117 | f9daq | 1887 | } |
1888 | meas_data->Fill(); |
||
127 | f9daq | 1889 | |
1890 | // Start making a scope measurement |
||
1891 | if( (gScopeDaq->scopeUseType == 2) && (sCamaclink->IsDown()) ) |
||
1892 | { |
||
1893 | StartScopeAcq(); |
||
1894 | evtmeas.measdata = gScopeDaq->measubuf; |
||
1895 | } |
||
1896 | scope_data->Fill(); |
||
117 | f9daq | 1897 | |
1898 | n++; |
||
1899 | nc += evtheader.nrch; |
||
1900 | nb -= evtheader.nrch; |
||
1901 | } |
||
1902 | |||
1903 | MyTimer(); |
||
1904 | allEvt = n; |
||
1905 | if (gSystem->ProcessEvents()) printf("Run Interrupted\n"); |
||
1906 | |||
1907 | if( (started) && (n == (neve*zProg)/10) ) |
||
1908 | { |
||
1909 | progVal = (float)zProg*10; |
||
1910 | curProgress->SetPosition(progVal); |
||
1911 | zProg++; |
||
1912 | } |
||
1913 | } |
||
1914 | |||
1915 | printf("Number of gathered events: %d\n", allEvt); |
||
1916 | measStart->SetText("Start acquisition"); |
||
1917 | started = kFALSE; |
||
1918 | |||
1919 | gDaq->stop(); |
||
1920 | } |
||
1921 | |||
1922 | busyLabel->Disable(); |
||
1923 | printf("End of Run neve=%d\n",neve); |
||
1924 | |||
1925 | header_data->Write(); |
||
1926 | meas_data->Write(); |
||
127 | f9daq | 1927 | scope_data->Write(); |
117 | f9daq | 1928 | delete header_data; |
1929 | delete meas_data; |
||
127 | f9daq | 1930 | delete scope_data; |
117 | f9daq | 1931 | |
1932 | outroot->Close(); |
||
1933 | } |
||
1934 | |||
1935 | // Start the acquisition |
||
1936 | void TGAppMainFrame::StartAcq() |
||
1937 | { |
||
1938 | // Determine the type of measurement to perform |
||
1939 | int vscan = 0, pscan = 0, zscan = 0; |
||
1940 | if(voltscanOn->IsOn()) vscan = 1; |
||
1941 | if(surfscanOn->IsOn()) pscan = 1; |
||
1942 | if(zscanOn->IsOn()) zscan = 1; |
||
1943 | |||
1944 | char cmd[256]; |
||
1945 | int i, j, k; |
||
1946 | float progVal; |
||
1947 | FILE *pfin; |
||
1948 | |||
1949 | // Variables for voltage scan |
||
1950 | float currentVoltage, minVoltage, maxVoltage, stepVoltage; |
||
1951 | int repetition; |
||
1952 | |||
1953 | // Variables for surface scan |
||
1954 | int minXpos, maxXpos, stepXpos; |
||
1955 | int minYpos, maxYpos, stepYpos; |
||
1956 | int minZpos, maxZpos, stepZpos; |
||
1957 | int repetX, repetY, repetZ; |
||
1958 | |||
1959 | // Voltage scan |
||
1960 | if( (vscan == 1) && (pscan == 0) ) |
||
1961 | { |
||
1962 | if(started) |
||
1963 | { |
||
1964 | printf("Stopping current voltage scan...\n"); |
||
1965 | gROOT->SetInterrupt(); |
||
1966 | measStart->SetText("Start acquisition"); |
||
1967 | started = kFALSE; |
||
1968 | |||
1969 | pfin = fopen("finish_sig.txt","w"); |
||
1970 | fprintf(pfin, "%s: Voltage scan stopped.", timeStamp->GetText()); |
||
1971 | fclose(pfin); |
||
1972 | } |
||
1973 | else if(!started) |
||
1974 | { |
||
1975 | measStart->SetText("Stop acquisition"); |
||
1976 | started = kTRUE; |
||
1977 | |||
1978 | printf("Running a voltage scan...\n"); |
||
1979 | |||
1980 | minVoltage = vOutStart->GetNumber(); |
||
1981 | maxVoltage = vOutStop->GetNumber(); |
||
1982 | stepVoltage = vOutStep->GetNumber(); |
||
1983 | |||
1984 | if(stepVoltage == 0.) |
||
1985 | repetition = 1; |
||
1986 | else |
||
1987 | repetition = ((maxVoltage - minVoltage)/stepVoltage)+1; |
||
1988 | |||
1989 | for(i=0; i < repetition; i++) |
||
1990 | { |
||
1991 | progVal = (float)(100.00/repetition)*i; |
||
1992 | curProgress->SetPosition(progVal); |
||
1993 | |||
1994 | fflush(stdout); |
||
1995 | currentVoltage = minVoltage + stepVoltage*i; |
||
1996 | sprintf(cmd, "%s/mpod/mpod_voltage.sh -o %d -v %f -s 1", rootdir, GetChannel(), currentVoltage); |
||
1997 | #if WORKSTAT == 'I' |
||
1998 | retTemp = system(cmd); |
||
1999 | #else |
||
2000 | printf("Cmd: %s\n",cmd); |
||
2001 | #endif |
||
2002 | fflush(stdout); |
||
2003 | |||
2004 | printf("Waiting for voltage change...\n"); |
||
127 | f9daq | 2005 | sleep(3); |
117 | f9daq | 2006 | vOut->SetNumber(currentVoltage); |
2007 | printf("Continuing...\n"); |
||
2008 | |||
2009 | // Here comes function to start histogramming <<<<<<<<<<<<<<<<<<<<<<<< |
||
2010 | RunMeas((void*)0, i, 0); |
||
2011 | fflush(stdout); |
||
2012 | } |
||
2013 | |||
2014 | // Set output back to off |
||
2015 | fflush(stdout); |
||
2016 | printf("Measurement finished, returning to starting voltage...\n"); |
||
2017 | sprintf(cmd, "%s/mpod/mpod_voltage.sh -o %d -v %f -s 1", rootdir, GetChannel(), minVoltage); |
||
2018 | vOut->SetNumber(minVoltage); |
||
2019 | #if WORKSTAT == 'I' |
||
2020 | retTemp = system(cmd); |
||
2021 | #else |
||
2022 | printf("Cmd: %s\n",cmd); |
||
2023 | #endif |
||
2024 | fflush(stdout); |
||
2025 | |||
2026 | progVal = 100.00; |
||
2027 | curProgress->SetPosition(progVal); |
||
2028 | printf("\n"); |
||
2029 | |||
2030 | pfin = fopen("finish_sig.txt","w"); |
||
2031 | fprintf(pfin, "%s: Voltage scan finished.", timeStamp->GetText()); |
||
2032 | fclose(pfin); |
||
2033 | } |
||
2034 | } |
||
2035 | // Surface scan |
||
2036 | else if( (pscan == 1) && (vscan == 0) ) |
||
2037 | { |
||
2038 | minXpos = xPosMin->GetNumber(); |
||
2039 | maxXpos = xPosMax->GetNumber(); |
||
2040 | stepXpos = xPosStep->GetNumber(); |
||
2041 | minYpos = yPosMin->GetNumber(); |
||
2042 | maxYpos = yPosMax->GetNumber(); |
||
2043 | stepYpos = yPosStep->GetNumber(); |
||
2044 | minZpos = zPosMin->GetNumber(); |
||
2045 | maxZpos = zPosMax->GetNumber(); |
||
2046 | stepZpos = zPosStep->GetNumber(); |
||
2047 | |||
2048 | if(zscan == 1) |
||
2049 | { |
||
2050 | if(stepZpos == 0.) repetZ = 1; |
||
2051 | else repetZ = ((maxZpos - minZpos)/stepZpos)+1; |
||
2052 | } |
||
2053 | else |
||
2054 | { |
||
2055 | minZpos = zPos->GetNumber(); |
||
2056 | repetZ = 1; |
||
2057 | } |
||
2058 | |||
2059 | if(stepXpos == 0.) repetX = 1; |
||
2060 | else repetX = ((maxXpos - minXpos)/stepXpos)+1; |
||
2061 | if(stepYpos == 0.) repetY = 1; |
||
2062 | else repetY = ((maxYpos - minYpos)/stepYpos)+1; |
||
2063 | |||
2064 | for(k=0; k < repetZ; k++) |
||
2065 | { |
||
2066 | fflush(stdout); |
||
2067 | // Y-axis change |
||
2068 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 3 -v %d -s la && %s/MIKRO/mikro_ctrl -n 3 -c m", rootdir, minZpos + stepZpos*k, rootdir); |
||
2069 | #if WORKSTAT == 'I' |
||
2070 | retTemp = system(cmd); |
||
2071 | #else |
||
2072 | printf("Cmd: %s\n",cmd); |
||
2073 | #endif |
||
2074 | fflush(stdout); |
||
2075 | |||
2076 | printf("Next Z position...\n"); |
||
2077 | zPos->SetNumber(minZpos + stepZpos*k); |
||
2078 | fflush(stdout); |
||
2079 | |||
2080 | for(j=0; j < repetY; j++) |
||
2081 | { |
||
2082 | fflush(stdout); |
||
2083 | // Y-axis change |
||
2084 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 2 -v %d -s la && %s/MIKRO/mikro_ctrl -n 2 -c m", rootdir, minYpos + stepYpos*j, rootdir); |
||
2085 | #if WORKSTAT == 'I' |
||
2086 | retTemp = system(cmd); |
||
2087 | #else |
||
2088 | printf("Cmd: %s\n",cmd); |
||
2089 | #endif |
||
2090 | fflush(stdout); |
||
2091 | |||
2092 | sleep(4); |
||
2093 | printf("Next Y position...\n"); |
||
2094 | yPos->SetNumber(minYpos + stepYpos*j); |
||
2095 | fflush(stdout); |
||
2096 | |||
2097 | for(i=0; i < repetX; i++) |
||
2098 | { |
||
2099 | progVal = (float)(100.00/(repetX*repetY))*(j*repetX+i); |
||
2100 | curProgress->SetPosition(progVal); |
||
2101 | |||
2102 | // X-axis change |
||
2103 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 1 -v %d -s la && %s/MIKRO/mikro_ctrl -n 1 -c m", rootdir, minXpos + stepXpos*i, rootdir); |
||
2104 | #if WORKSTAT == 'I' |
||
2105 | retTemp = system(cmd); |
||
2106 | #else |
||
2107 | printf("Cmd: %s\n",cmd); |
||
2108 | #endif |
||
2109 | fflush(stdout); |
||
2110 | |||
2111 | printf("Next X position...\n"); |
||
2112 | fflush(stdout); |
||
2113 | |||
2114 | printf("Waiting for position change...\n"); |
||
2115 | sleep(2); |
||
2116 | xPos->SetNumber(minXpos + stepXpos*i); |
||
2117 | printf("Continuing...\n"); |
||
2118 | |||
2119 | // for (k=0;k<(NTDCCH+NADCCH);k++) gHisto1D[k]->Reset(); |
||
2120 | // for (k=0;k<(NTDCCH+NADCCH)/2;k++) gHisto2D[k]->Reset(); |
||
2121 | |||
2122 | // Here comes function to start histogramming <<<<<<<<<<<<<<<<<<<<<<<< |
||
2123 | RunMeas((void*)0, (j*repetX + i), zscan ); |
||
2124 | |||
2125 | fflush(stdout); |
||
2126 | } |
||
2127 | |||
2128 | printf("\n"); |
||
2129 | } |
||
2130 | } |
||
2131 | |||
2132 | fflush(stdout); |
||
2133 | printf("Measurement finished, returning to starting position...\n"); |
||
2134 | // X-axis return |
||
2135 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 1 -v %d -s la && %s/MIKRO/mikro_ctrl -n 1 -c m", rootdir, minXpos, rootdir); |
||
2136 | #if WORKSTAT == 'I' |
||
2137 | retTemp = system(cmd); |
||
2138 | #else |
||
2139 | printf("Cmd: %s\n",cmd); |
||
2140 | #endif |
||
2141 | fflush(stdout); |
||
2142 | |||
2143 | // Y-axis return |
||
2144 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 2 -v %d -s la && %s/MIKRO/mikro_ctrl -n 2 -c m", rootdir, minYpos, rootdir); |
||
2145 | #if WORKSTAT == 'I' |
||
2146 | retTemp = system(cmd); |
||
2147 | #else |
||
2148 | printf("Cmd: %s\n",cmd); |
||
2149 | #endif |
||
2150 | |||
2151 | // Z-axis return |
||
2152 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 3 -v %d -s la && %s/MIKRO/mikro_ctrl -n 3 -c m", rootdir, minZpos, rootdir); |
||
2153 | #if WORKSTAT == 'I' |
||
2154 | retTemp = system(cmd); |
||
2155 | #else |
||
2156 | printf("Cmd: %s\n",cmd); |
||
2157 | #endif |
||
2158 | xPos->SetNumber(minXpos); |
||
2159 | yPos->SetNumber(minYpos); |
||
2160 | zPos->SetNumber(minZpos); |
||
2161 | |||
2162 | progVal = 100.00; |
||
2163 | curProgress->SetPosition(progVal); |
||
2164 | printf("\n"); |
||
2165 | |||
2166 | pfin = fopen("finish_sig.txt","w"); |
||
2167 | fprintf(pfin, "%s: Surface scan finished.", timeStamp->GetText()); |
||
2168 | fclose(pfin); |
||
2169 | } |
||
2170 | // Normal single measurement |
||
2171 | else if( (vscan == 0) && (pscan == 0) ) |
||
2172 | { |
||
2173 | // Set the start button to stop and enable stopping of measurement |
||
2174 | if(started) |
||
2175 | { |
||
2176 | printf("Stopping current single scan...\n"); |
||
2177 | gROOT->SetInterrupt(); |
||
2178 | // gDaq->fStop=1; |
||
2179 | measStart->SetText("Start acquisition"); |
||
2180 | started = kFALSE; |
||
2181 | } |
||
2182 | else if(!started) |
||
2183 | { |
||
2184 | measStart->SetText("Stop acquisition"); |
||
2185 | started = kTRUE; |
||
2186 | |||
2187 | printf("Running a single scan...\n"); |
||
2188 | RunMeas((void*)0, 0, 0); |
||
2189 | printf("Measurement finished...\n"); |
||
2190 | printf("\n"); |
||
2191 | } |
||
2192 | } |
||
2193 | } |
||
2194 | |||
2195 | // File browser for opening histograms |
||
2196 | void TGAppMainFrame::SelectDirectory() |
||
2197 | { |
||
2198 | int i = fileList->GetNumberOfEntries(); |
||
2199 | |||
2200 | TGFileInfo file_info; |
||
2201 | const char *filetypes[] = {"Histograms",histExtAll,0,0}; |
||
2202 | file_info.fFileTypes = filetypes; |
||
2203 | file_info.fIniDir = StrDup("./results"); |
||
2204 | file_info.fMultipleSelection = kTRUE; |
||
2205 | new TGFileDialog(gClient->GetDefaultRoot(), fMain, kFDOpen, &file_info); |
||
2206 | |||
2207 | TList *files = file_info.fFileNamesList; |
||
2208 | if(files) |
||
2209 | { |
||
2210 | TSystemFile *file; |
||
2211 | TString fname; |
||
2212 | TIter next(files); |
||
2213 | while(file=(TSystemFile*)next()) |
||
2214 | { |
||
2215 | fname = file->GetName(); |
||
2216 | fileList->AddEntry(fname.Data(), i); |
||
2217 | i++; |
||
2218 | } |
||
2219 | } |
||
2220 | fileList->Layout(); |
||
2221 | } |
||
2222 | |||
2223 | // File browser for selecting the save file |
||
2224 | void TGAppMainFrame::SaveFile() |
||
2225 | { |
||
2226 | TGFileInfo file_info; |
||
2227 | const char *filetypes[] = {"Histograms",histExtAll,0,0}; |
||
2228 | file_info.fFileTypes = filetypes; |
||
2229 | file_info.fIniDir = StrDup("./results"); |
||
2230 | new TGFileDialog(gClient->GetDefaultRoot(), fMain, kFDSave, &file_info); |
||
2231 | |||
2232 | fileName->SetText(file_info.fFilename); |
||
2233 | } |
||
2234 | |||
2235 | // Toggle multiple selection in filelist |
||
2236 | void TGAppMainFrame::ListMultiSelect() |
||
2237 | { |
||
2238 | fileList->SetMultipleSelections((multiSelect->IsOn())); |
||
2239 | |||
2240 | if(multiSelectAll->IsDown()) |
||
2241 | multiSelectAll->SetState(kButtonUp); |
||
2242 | } |
||
2243 | |||
2244 | // Select all entries in filelist |
||
2245 | void TGAppMainFrame::ListSelectAll() |
||
2246 | { |
||
2247 | if(multiSelectAll->IsDown()) |
||
2248 | { |
||
2249 | multiSelect->SetState(kButtonDown); |
||
2250 | fileList->SetMultipleSelections((multiSelect->IsOn())); |
||
2251 | for(int i = 0; i < fileList->GetNumberOfEntries(); i++) |
||
2252 | fileList->Select(i,kTRUE); |
||
2253 | } |
||
2254 | else if(!multiSelectAll->IsDown()) |
||
2255 | { |
||
2256 | multiSelect->SetState(kButtonUp); |
||
2257 | fileList->SetMultipleSelections((multiSelect->IsOn())); |
||
2258 | for(int i = 0; i < fileList->GetNumberOfEntries(); i++) |
||
2259 | fileList->Select(i,kFALSE); |
||
2260 | } |
||
2261 | } |
||
2262 | |||
2263 | // Navigation buttons for the filelist (<<, >>) and double click |
||
2264 | void TGAppMainFrame::FileListNavigation(int pn) |
||
2265 | { |
||
2266 | unsigned int nrfiles = fileList->GetNumberOfEntries(); |
||
2267 | int curSel; |
||
2268 | TList *files; |
||
2269 | if( nrfiles > 0 ) |
||
2270 | { |
||
2271 | if(pn < -1) |
||
2272 | { |
||
2273 | if(multiSelect->IsOn()) |
||
2274 | { |
||
2275 | // turn off multiple selection and select first file on list |
||
2276 | fileList->SetMultipleSelections(kFALSE); |
||
2277 | multiSelect->SetState(kButtonUp); |
||
2278 | multiSelectAll->SetState(kButtonUp); |
||
2279 | |||
2280 | fileList->Select(0,kTRUE); |
||
2281 | } |
||
2282 | else |
||
2283 | { |
||
2284 | // if nothing is selected, curSel will be -1 |
||
2285 | curSel = fileList->GetSelected(); |
||
2286 | // go to next file on list |
||
2287 | if(pn == -3) |
||
2288 | { |
||
2289 | if( (curSel == (int)(nrfiles-1)) || (curSel == -1) ) |
||
2290 | fileList->Select(0); |
||
2291 | else |
||
2292 | fileList->Select(curSel+1); |
||
2293 | } |
||
2294 | // go to previous file on list |
||
2295 | else if(pn == -2) |
||
2296 | { |
||
2297 | if( (curSel == 0) || (curSel == -1) ) |
||
2298 | fileList->Select(nrfiles-1); |
||
2299 | else |
||
2300 | fileList->Select(curSel-1); |
||
2301 | } |
||
2302 | } |
||
2303 | } |
||
2304 | |||
2305 | // check the newly selected file/files and return its name/their names |
||
2306 | files = new TList(); |
||
2307 | fileList->GetSelectedEntries(files); |
||
2308 | if(files) |
||
2309 | { |
||
2310 | for(int i = 0; i < (int)nrfiles; i++) |
||
2311 | { |
||
2312 | if(files->At(i)) |
||
2313 | { |
||
2314 | if(debugSig) |
||
2315 | printf("Filename: %s\n", files->At(i)->GetTitle()); |
||
2316 | if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DADC) ) |
||
2317 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0); |
||
2318 | else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DTDC) ) |
||
2319 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 1); |
||
2320 | else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_2D) ) |
||
2321 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 2); |
||
2322 | } |
||
2323 | } |
||
2324 | } |
||
2325 | |||
2326 | // Still need to include drawing of histograms we move to!!! |
||
2327 | } |
||
2328 | } |
||
2329 | |||
2330 | // Display the currently selected histogram in file list |
||
2331 | void TGAppMainFrame::DisplayHistogram(char* histfile, int histtype) |
||
2332 | { |
||
2333 | if(debugSig) |
||
2334 | printf("Selected file: %s\n", histfile); |
||
2335 | |||
2336 | TCanvas *gCanvas = histCanvas->GetCanvas(); |
||
2337 | |||
2338 | inroot = new TFile(histfile, "READ"); |
||
2339 | |||
2340 | TTree *header_data, *meas_data; |
||
2341 | inroot->GetObject("header_data", header_data); |
||
2342 | inroot->GetObject("meas_data", meas_data); |
||
2343 | |||
2344 | // Reading the header |
||
2345 | header_data->SetBranchAddress("nrch", &evtheader.nrch); |
||
2346 | header_data->GetEntry(0); |
||
2347 | header_data->SetBranchAddress("timestamp", &evtheader.timestamp); |
||
2348 | header_data->GetEntry(0); |
||
2349 | header_data->SetBranchAddress("biasvolt", &evtheader.biasvolt); |
||
2350 | header_data->GetEntry(0); |
||
2351 | header_data->SetBranchAddress("xpos", &evtheader.xpos); |
||
2352 | header_data->GetEntry(0); |
||
2353 | header_data->SetBranchAddress("ypos", &evtheader.ypos); |
||
2354 | header_data->GetEntry(0); |
||
2355 | header_data->SetBranchAddress("zpos", &evtheader.zpos); |
||
2356 | header_data->GetEntry(0); |
||
2357 | header_data->SetBranchAddress("temperature", &evtheader.temperature); |
||
2358 | header_data->GetEntry(0); |
||
2359 | header_data->SetBranchAddress("laserinfo", &evtheader.laserinfo); |
||
2360 | header_data->GetEntry(0); |
||
2361 | |||
2362 | char histtime[256]; |
||
2363 | GetTime(evtheader.timestamp, histtime); |
||
2364 | |||
2365 | if(debugSig) |
||
2366 | { |
||
2367 | printf("Opened file header information:\n"); |
||
2368 | printf("- Number of channels: %d\n", evtheader.nrch); |
||
2369 | printf("- Timestamp: %d (%s)\n", evtheader.timestamp, histtime); |
||
2370 | printf("- Bias voltage: %lf\n", evtheader.biasvolt); |
||
2371 | printf("- Table position (X,Y,Z): %d, %d, %d\n", evtheader.xpos, evtheader.ypos, evtheader.zpos); |
||
2372 | printf("- Temperature: %lf\n", evtheader.temperature); |
||
2373 | printf("- Laser and filter settings: %s\n", evtheader.laserinfo); |
||
2374 | } |
||
2375 | |||
2376 | int j; |
||
2377 | char rdc[256]; |
||
2378 | char rdcsel[256]; |
||
2379 | |||
2380 | j = selectCh->GetNumber(); |
||
2381 | |||
2382 | printf("Found %d data points.\n", (int)meas_data->GetEntries()); |
||
2383 | |||
2384 | gCanvas->cd(); |
||
2385 | double range[4]; |
||
2386 | range[0] = adcMinRange->GetNumber(); |
||
2387 | range[1] = adcMaxRange->GetNumber(); |
||
2388 | range[2] = tdcMinwindow->GetNumber(); |
||
2389 | range[3] = tdcMaxwindow->GetNumber(); |
||
2390 | |||
2391 | if(histtype == 0) |
||
2392 | { |
||
2393 | if( range[0] == range[1] ) |
||
2394 | sprintf(rdc, "ADC%d>>%s", j, histname); |
||
2395 | else |
||
2396 | sprintf(rdc, "ADC%d>>%s(%d,%lf,%lf)", j, histname, (int)(range[1]-range[0]), range[0]-0.5, range[1]-0.5); |
||
2397 | |||
2398 | sprintf(rdcsel, "(TDC%d>%lf)&&(TDC%d<%lf)", j, range[2]*tdctimeconversion, j, range[3]*tdctimeconversion); |
||
2399 | meas_data->Draw(rdc, rdcsel); |
||
2400 | |||
2401 | sprintf(rdc, "ADC%d, Vbias=%.3lf, TDC=(%.2lf,%.2lf);ADC;", j, evtheader.biasvolt, range[2], range[3]); |
||
2402 | TH1F *histtemp = (TH1F*)gCanvas->GetPrimitive(histname); |
||
2403 | if(!cleanPlots) |
||
2404 | histtemp->SetTitle(rdc); |
||
2405 | else |
||
2406 | histtemp->SetTitle(";ADC;"); |
||
2407 | histtemp->GetXaxis()->SetLabelSize(0.025); |
||
2408 | histtemp->GetXaxis()->CenterTitle(kTRUE); |
||
2409 | histtemp->GetYaxis()->SetLabelSize(0.025); |
||
2410 | if(cleanPlots) |
||
2411 | { |
||
2412 | TGaxis *yax = (TGaxis*)histtemp->GetYaxis(); |
||
2413 | yax->SetMaxDigits(4); |
||
2414 | } |
||
2415 | |||
2416 | gCanvas->Modified(); |
||
2417 | gCanvas->Update(); |
||
2418 | |||
2419 | if( yMinRange->GetNumber() != yMaxRange->GetNumber() ) |
||
2420 | { |
||
2421 | if( (logscale->IsDown()) && (yMinRange->GetNumber() <= 0) ) |
||
2422 | { |
||
2423 | histtemp->GetYaxis()->SetRangeUser(0.5, yMaxRange->GetNumber()); |
||
2424 | yMinRange->SetNumber(0.5); |
||
2425 | logchange = 1; |
||
2426 | } |
||
2427 | else |
||
2428 | { |
||
2429 | gCanvas->SetLogy(kFALSE); |
||
2430 | if(logchange == 1) |
||
2431 | { |
||
2432 | yMinRange->SetNumber(0.0); |
||
2433 | logchange = 0; |
||
2434 | } |
||
2435 | histtemp->GetYaxis()->SetRangeUser(yMinRange->GetNumber(), yMaxRange->GetNumber()); |
||
2436 | } |
||
2437 | } |
||
2438 | |||
2439 | TPaveStats *stats = (TPaveStats*)histtemp->FindObject("stats"); |
||
2440 | if(!cleanPlots) |
||
2441 | { |
||
2442 | stats->SetX1NDC(0.84); stats->SetX2NDC(0.97); |
||
2443 | stats->SetY1NDC(0.87); stats->SetY2NDC(0.97); |
||
2444 | } |
||
2445 | else |
||
2446 | { |
||
2447 | stats->SetX1NDC(1.1); stats->SetX2NDC(1.3); |
||
2448 | stats->SetY1NDC(1.1); stats->SetY2NDC(1.3); |
||
2449 | } |
||
2450 | } |
||
2451 | else if(histtype == 1) |
||
2452 | { |
||
2453 | if( range[0] == range[1] ) |
||
2454 | sprintf(rdc, "(TDC%d/%lf)>>%s", j, tdctimeconversion, histname); |
||
2455 | else |
||
2456 | sprintf(rdc, "(TDC%d/%lf)>>%s(%d,%lf,%lf)", j, tdctimeconversion, histname, (int)((range[3]-range[2])*tdctimeconversion), range[2], range[3]); |
||
2457 | sprintf(rdcsel, "(TDC%d>%lf)&&(TDC%d<%lf)", j, range[2]*tdctimeconversion, j, range[3]*tdctimeconversion); |
||
2458 | meas_data->Draw(rdc, rdcsel); |
||
2459 | |||
2460 | sprintf(rdc, "TDC%d, Vbias=%.3lf, TDC=(%.2lf,%.2lf);Time (TDC channel) [ns];", j, evtheader.biasvolt, range[2], range[3]); |
||
2461 | TH1F *histtemp = (TH1F*)gCanvas->GetPrimitive(histname); |
||
2462 | if(!cleanPlots) |
||
2463 | histtemp->SetTitle(rdc); |
||
2464 | else |
||
2465 | histtemp->SetTitle(";Time (TDC channel) [ns];"); |
||
2466 | histtemp->GetXaxis()->SetLabelSize(0.025); |
||
2467 | histtemp->GetXaxis()->CenterTitle(kTRUE); |
||
2468 | histtemp->GetYaxis()->SetLabelSize(0.025); |
||
2469 | if(cleanPlots) |
||
2470 | { |
||
2471 | TGaxis *yax = (TGaxis*)histtemp->GetYaxis(); |
||
2472 | yax->SetMaxDigits(4); |
||
2473 | } |
||
2474 | |||
2475 | gCanvas->Modified(); |
||
2476 | gCanvas->Update(); |
||
2477 | |||
2478 | if( yMinRange->GetNumber() != yMaxRange->GetNumber() ) |
||
2479 | { |
||
2480 | if( (logscale->IsDown()) && (yMinRange->GetNumber() <= 0) ) |
||
2481 | { |
||
2482 | histtemp->GetYaxis()->SetRangeUser(0.5, yMaxRange->GetNumber()); |
||
2483 | yMinRange->SetNumber(0.5); |
||
2484 | logchange = 1; |
||
2485 | } |
||
2486 | else |
||
2487 | { |
||
2488 | gCanvas->SetLogy(kFALSE); |
||
2489 | if(logchange == 1) |
||
2490 | { |
||
2491 | yMinRange->SetNumber(0.0); |
||
2492 | logchange = 0; |
||
2493 | } |
||
2494 | histtemp->GetYaxis()->SetRangeUser(yMinRange->GetNumber(), yMaxRange->GetNumber()); |
||
2495 | } |
||
2496 | } |
||
2497 | |||
2498 | TPaveStats *stats = (TPaveStats*)histtemp->FindObject("stats"); |
||
2499 | if(!cleanPlots) |
||
2500 | { |
||
2501 | stats->SetX1NDC(0.84); stats->SetX2NDC(0.97); |
||
2502 | stats->SetY1NDC(0.87); stats->SetY2NDC(0.97); |
||
2503 | } |
||
2504 | else |
||
2505 | { |
||
2506 | stats->SetX1NDC(1.1); stats->SetX2NDC(1.3); |
||
2507 | stats->SetY1NDC(1.1); stats->SetY2NDC(1.3); |
||
2508 | } |
||
2509 | } |
||
2510 | else if(histtype == 2) |
||
2511 | { |
||
2512 | if( ((range[0] == range[1]) && (range[2] == range[3])) || (range[2] == range[3]) || (range[0] == range[1]) ) |
||
2513 | sprintf(rdc, "(TDC%d/%lf):ADC%d>>%s", j, tdctimeconversion, j, histname); |
||
2514 | else |
||
2515 | sprintf(rdc, "(TDC%d/%lf):ADC%d>>%s(%d,%lf,%lf,%d,%lf,%lf)", j, tdctimeconversion, j, histname, (int)(range[1]-range[0])/2, range[0]-0.5, range[1]-0.5, (int)((range[3]-range[2])*tdctimeconversion)/2, range[2], range[3]); |
||
2516 | meas_data->Draw(rdc,"","COLZ"); |
||
2517 | |||
2518 | sprintf(rdc, "ADC/TDC%d, Vbias=%.3lf, TDC=(%.2lf,%.2lf);ADC;TDC", j, evtheader.biasvolt, range[2], range[3]); |
||
2519 | TH2F *histtemp = (TH2F*)gCanvas->GetPrimitive(histname); |
||
2520 | if(!cleanPlots) |
||
2521 | histtemp->SetTitle(rdc); |
||
2522 | else |
||
2523 | histtemp->SetTitle(";ADC;Time (TDC channel) [ns]"); |
||
2524 | histtemp->GetXaxis()->SetLabelSize(0.025); |
||
2525 | histtemp->GetXaxis()->CenterTitle(kTRUE); |
||
2526 | histtemp->GetYaxis()->SetLabelSize(0.025); |
||
2527 | histtemp->GetYaxis()->CenterTitle(kTRUE); |
||
2528 | histtemp->GetYaxis()->SetTitleOffset(1.35); |
||
2529 | if(cleanPlots) |
||
2530 | { |
||
2531 | TGaxis *yax = (TGaxis*)histtemp->GetYaxis(); |
||
2532 | yax->SetMaxDigits(4); |
||
2533 | } |
||
2534 | |||
2535 | gCanvas->Modified(); |
||
2536 | gCanvas->Update(); |
||
2537 | |||
2538 | TPaveStats *stats = (TPaveStats*)histtemp->FindObject("stats"); |
||
2539 | // stats->SetOptStat(0); |
||
2540 | stats->SetX1NDC(1.1); stats->SetX2NDC(1.3); |
||
2541 | stats->SetY1NDC(1.1); stats->SetY2NDC(1.3); |
||
2542 | |||
2543 | TPaletteAxis *gpalette = (TPaletteAxis*)histtemp->GetListOfFunctions()->FindObject("palette"); |
||
2544 | gpalette->SetLabelSize(0.022); |
||
2545 | } |
||
2546 | |||
2547 | if(histtype < 2) |
||
2548 | { |
||
2549 | if( logscale->IsDown() ) |
||
2550 | gCanvas->SetLogy(kTRUE); |
||
2551 | else if( !logscale->IsDown() ) |
||
2552 | gCanvas->SetLogy(kFALSE); |
||
2553 | } |
||
2554 | else |
||
2555 | gCanvas->SetLogy(kFALSE); |
||
2556 | |||
2557 | gCanvas->Modified(); |
||
2558 | gCanvas->Update(); |
||
2559 | |||
2560 | // If you close the opened file, the data can't be accessed by other functions |
||
2561 | } |
||
2562 | |||
2563 | // Create a 2D surface plot and plot it |
||
2564 | void TGAppMainFrame::MakeSurfPlot(TList *files) |
||
2565 | { |
||
2566 | unsigned int nrfiles = fileList->GetNumberOfEntries(); |
||
2567 | int j, k = 0, m = 0, n = 0; |
||
2568 | char ctemp[256]; |
||
2569 | TCanvas *gCanvas = histCanvas->GetCanvas(); |
||
2570 | TTree *header_data, *meas_data; |
||
2571 | double *integralCount; |
||
2572 | double *surfx, *surfy; |
||
2573 | double xsurfmin = 0, ysurfmin = 0; |
||
2574 | integralCount = new double[nrfiles]; |
||
2575 | for(int i = 0; i < (int)nrfiles; i++) integralCount[i] = 0; |
||
2576 | surfx = new double[nrfiles]; |
||
2577 | surfy = new double[nrfiles]; |
||
2578 | int nrentries; |
||
2579 | TGraph2D *gScan2D; |
||
2580 | gScan2D = new TGraph2D(); |
||
2581 | |||
2582 | /* int zProg = 0; |
||
2583 | float progVal; |
||
2584 | curProgress->SetPosition(zProg);*/ |
||
2585 | |||
2586 | char exportname[256]; |
||
2587 | |||
2588 | if(multiSelect->IsOn()) |
||
2589 | { |
||
2590 | printf("Creating a surface plot. Please wait...\n"); |
||
2591 | fileList->GetSelectedEntries(files); |
||
2592 | if(files) |
||
2593 | { |
||
2594 | busyLabel->Enable(); |
||
2595 | |||
2596 | for(int i = 0; i < (int)nrfiles; i++) |
||
2597 | { |
||
2598 | if(files->At(i)) |
||
2599 | { |
||
2600 | n++; |
||
2601 | // printf("Filename: %s\n", files->At(i)->GetTitle()); |
||
2602 | |||
2603 | sprintf(ctemp, "%s", files->At(i)->GetTitle()); |
||
2604 | inroot = new TFile(ctemp, "READ"); |
||
2605 | |||
2606 | inroot->GetObject("header_data", header_data); |
||
2607 | inroot->GetObject("meas_data", meas_data); |
||
2608 | |||
2609 | // Reading the header |
||
2610 | header_data->SetBranchAddress("xpos", &evtheader.xpos); |
||
2611 | header_data->GetEntry(0); |
||
2612 | header_data->SetBranchAddress("ypos", &evtheader.ypos); |
||
2613 | header_data->GetEntry(0); |
||
2614 | |||
2615 | char rdc[256]; |
||
2616 | j = selectCh->GetNumber(); |
||
2617 | double rangetdc[2]; |
||
2618 | rangetdc[0] = tdcMinwindow->GetNumber(); |
||
2619 | rangetdc[1] = tdcMaxwindow->GetNumber(); |
||
2620 | |||
2621 | k = 0; |
||
2622 | m = 0; |
||
2623 | |||
2624 | // Reading the data |
||
2625 | for(int i = 0; i < meas_data->GetEntries(); i++) |
||
2626 | { |
||
2627 | sprintf(rdc, "ADC%d", j); |
||
2628 | meas_data->SetBranchAddress(rdc, &evtdata.adcdata[j]); |
||
2629 | meas_data->GetEntry(i); |
||
2630 | |||
2631 | sprintf(rdc, "TDC%d", j); |
||
2632 | meas_data->SetBranchAddress(rdc, &evtdata.tdcdata[j]); |
||
2633 | meas_data->GetEntry(i); |
||
2634 | |||
2635 | // If our data point is inside the TDC window |
||
2636 | if( ((double)evtdata.tdcdata[j]/tdctimeconversion >= rangetdc[0]) && ((double)evtdata.tdcdata[j]/tdctimeconversion <= rangetdc[1]) ) |
||
2637 | { |
||
2638 | k++; |
||
2639 | m += evtdata.adcdata[j]; |
||
2640 | } |
||
2641 | } |
||
2642 | |||
2643 | integralCount[n-1] += ((double)m)/((double)k); |
||
2644 | if(n == 1) |
||
2645 | { |
||
2646 | xsurfmin = evtheader.xpos; |
||
2647 | ysurfmin = evtheader.ypos; |
||
2648 | } |
||
2649 | surfx[n-1] = (double)(evtheader.xpos-xsurfmin)*lenconversion; |
||
2650 | surfy[n-1] = (double)(evtheader.ypos-ysurfmin)*lenconversion; |
||
2651 | |||
2652 | /* if( n == (((files->GetSize())*zProg)/20)+1 ) // divide by 20 because files->GetSize() gives a double value of the files selected |
||
2653 | { |
||
2654 | progVal = (float)n; |
||
2655 | curProgress->SetPosition(progVal); |
||
2656 | zProg++; |
||
2657 | printf("Progress = %lf\n", progVal); |
||
2658 | }*/ |
||
2659 | |||
2660 | delete inroot; |
||
2661 | } |
||
2662 | } |
||
2663 | |||
2664 | busyLabel->Disable(); |
||
2665 | |||
2666 | nrentries = n; |
||
2667 | printf("%d files were selected.\n", nrentries); |
||
2668 | |||
2669 | for(int i = 0; i < nrentries; i++) |
||
2670 | { |
||
2671 | // printf("At position (%d,%d), the ADC integral is: %lf.\n", surfx[i], surfy[i], integralCount[i]); |
||
2672 | gScan2D->SetPoint(i, surfx[i], surfy[i], integralCount[i]); |
||
2673 | } |
||
2674 | gCanvas->cd(); |
||
2675 | gScan2D->Draw("COLZ"); |
||
2676 | |||
2677 | gCanvas->Modified(); |
||
2678 | gCanvas->Update(); |
||
2679 | |||
2680 | gScan2D->GetXaxis()->SetTitle("X [#mum]"); |
||
2681 | gScan2D->GetXaxis()->CenterTitle(kTRUE); |
||
2682 | gScan2D->GetXaxis()->SetLabelSize(0.022); |
||
2683 | gScan2D->GetXaxis()->SetRangeUser(surfx[0], surfx[nrentries-1]); |
||
2684 | // j = 500+(int)((surfx[nrentries-1]-surfx[0])/(surfx[1]-surfx[0])); |
||
2685 | // if(j > 510) j = 510; |
||
2686 | gScan2D->GetXaxis()->SetNdivisions(510, kTRUE); |
||
2687 | gScan2D->GetYaxis()->SetTitle("Y [#mum]"); |
||
2688 | gScan2D->GetYaxis()->SetTitleOffset(1.3); |
||
2689 | gScan2D->GetYaxis()->CenterTitle(kTRUE); |
||
2690 | gScan2D->GetYaxis()->SetLabelSize(0.022); |
||
2691 | gScan2D->GetYaxis()->SetRangeUser(surfy[0], surfy[nrentries-1]); |
||
2692 | // j = 500+(int)((surfy[nrentries-1]-surfy[0])/(surfy[(int)((surfx[nrentries-1]-surfx[0])/(surfx[1]-surfx[0])+1)]-surfy[0])); |
||
2693 | // if(j > 510) j = 510; |
||
2694 | gScan2D->GetYaxis()->SetNdivisions(510, kTRUE); |
||
2695 | |||
2696 | TGaxis *yax = (TGaxis*)gScan2D->GetYaxis(); |
||
2697 | yax->SetMaxDigits(4); |
||
2698 | |||
2699 | if(!cleanPlots) |
||
2700 | gScan2D->SetTitle("Surface scan"); |
||
2701 | else |
||
2702 | gScan2D->SetTitle(); |
||
2703 | |||
2704 | // TPaletteAxis *gpalette = (TPaletteAxis*)gScan2D->GetListOfFunctions()->FindObject("palette"); |
||
2705 | // gpalette->SetLabelSize(0.022); |
||
2706 | |||
2707 | gCanvas->Modified(); |
||
2708 | gCanvas->Update(); |
||
2709 | |||
2710 | remove_from_last((char*)files->At(0)->GetTitle(), '_', ctemp); |
||
2711 | sprintf(exportname, "%s_surfscan.pdf", ctemp); |
||
2712 | gCanvas->SaveAs(exportname); |
||
2713 | } |
||
2714 | } |
||
2715 | else |
||
2716 | { |
||
2717 | printf("To make a 2D surface scan plot, select multiple root files.\n"); |
||
2718 | change2Dsurf->SetDown(kFALSE); |
||
2719 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_SURF); |
||
2720 | } |
||
2721 | |||
2722 | delete[] surfx; |
||
2723 | delete[] surfy; |
||
2724 | delete[] integralCount; |
||
2725 | } |
||
2726 | |||
2727 | // Change histogram when changing the channel |
||
2728 | void TGAppMainFrame::ChangeChannel() |
||
2729 | { |
||
2730 | unsigned int nrfiles = fileList->GetNumberOfEntries(); |
||
2731 | TList *files; |
||
2732 | |||
2733 | if( nrfiles > 0 ) |
||
2734 | { |
||
2735 | // check the newly selected file/files and return its name/their names |
||
2736 | files = new TList(); |
||
2737 | fileList->GetSelectedEntries(files); |
||
2738 | if(files) |
||
2739 | { |
||
2740 | for(int i = 0; i < (int)nrfiles; i++) |
||
2741 | { |
||
2742 | if(files->At(i)) |
||
2743 | { |
||
2744 | if(debugSig) |
||
2745 | printf("Filename: %s\n", files->At(i)->GetTitle()); |
||
2746 | if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DADC) ) |
||
2747 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0); |
||
2748 | else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DTDC) ) |
||
2749 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 1); |
||
2750 | else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_2D) ) |
||
2751 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 2); |
||
2752 | } |
||
2753 | } |
||
2754 | } |
||
2755 | } |
||
2756 | } |
||
2757 | |||
2758 | // Setting a predetermined X range |
||
2759 | void TGAppMainFrame::SetHistRange() |
||
2760 | { |
||
2761 | unsigned int nrfiles = fileList->GetNumberOfEntries(); |
||
2762 | |||
2763 | if(nrfiles > 0) |
||
2764 | { |
||
2765 | TList *files; |
||
2766 | files = new TList(); |
||
2767 | fileList->GetSelectedEntries(files); |
||
2768 | if(files) |
||
2769 | { |
||
2770 | for(int i = 0; i < (int)nrfiles; i++) |
||
2771 | { |
||
2772 | if(files->At(i)) |
||
2773 | { |
||
2774 | if(debugSig) |
||
2775 | printf("Filename: %s\n", files->At(i)->GetTitle()); |
||
2776 | if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DADC) ) |
||
2777 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0); |
||
2778 | else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DTDC) ) |
||
2779 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 1); |
||
2780 | else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_2D) ) |
||
2781 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 2); |
||
2782 | } |
||
2783 | } |
||
2784 | } |
||
2785 | } |
||
2786 | } |
||
2787 | |||
2788 | // Changing the histogram type to display |
||
2789 | void TGAppMainFrame::ChangeHisttype(int type) |
||
2790 | { |
||
2791 | TGTextButton *pressedB = new TGTextButton(); |
||
2792 | int menuID = 0; |
||
2793 | unsigned int nrfiles = fileList->GetNumberOfEntries(); |
||
2794 | |||
2795 | // ADC histogram |
||
2796 | if(type == 0) |
||
2797 | { |
||
2798 | pressedB = changeADC; |
||
2799 | menuID = M_ANALYSIS_HISTTYPE_1DADC; |
||
2800 | |||
2801 | changeTDC->SetDown(kFALSE); |
||
2802 | changeADCTDC->SetDown(kFALSE); |
||
2803 | change2Dsurf->SetDown(kFALSE); |
||
2804 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DTDC); |
||
2805 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_2D); |
||
2806 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_SURF); |
||
2807 | } |
||
2808 | // TDC histogram |
||
2809 | else if(type == 1) |
||
2810 | { |
||
2811 | pressedB = changeTDC; |
||
2812 | menuID = M_ANALYSIS_HISTTYPE_1DTDC; |
||
2813 | |||
2814 | changeADC->SetDown(kFALSE); |
||
2815 | changeADCTDC->SetDown(kFALSE); |
||
2816 | change2Dsurf->SetDown(kFALSE); |
||
2817 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DADC); |
||
2818 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_2D); |
||
2819 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_SURF); |
||
2820 | } |
||
2821 | // ADC vs. TDC histogram |
||
2822 | else if(type == 2) |
||
2823 | { |
||
2824 | pressedB = changeADCTDC; |
||
2825 | menuID = M_ANALYSIS_HISTTYPE_2D; |
||
2826 | |||
2827 | changeADC->SetDown(kFALSE); |
||
2828 | changeTDC->SetDown(kFALSE); |
||
2829 | change2Dsurf->SetDown(kFALSE); |
||
2830 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DADC); |
||
2831 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DTDC); |
||
2832 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_SURF); |
||
2833 | } |
||
2834 | // Surface scan plot |
||
2835 | else if(type == 3) |
||
2836 | { |
||
2837 | pressedB = change2Dsurf; |
||
2838 | menuID = M_ANALYSIS_HISTTYPE_SURF; |
||
2839 | |||
2840 | changeADC->SetDown(kFALSE); |
||
2841 | changeTDC->SetDown(kFALSE); |
||
2842 | changeADCTDC->SetDown(kFALSE); |
||
2843 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DADC); |
||
2844 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DTDC); |
||
2845 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_2D); |
||
2846 | } |
||
2847 | |||
2848 | if( fMenuHisttype->IsEntryChecked(menuID) ) |
||
2849 | { |
||
2850 | pressedB->SetDown(kFALSE); |
||
2851 | fMenuHisttype->UnCheckEntry(menuID); |
||
2852 | } |
||
2853 | else if( !fMenuHisttype->IsEntryChecked(menuID) ) |
||
2854 | { |
||
2855 | pressedB->SetDown(kTRUE); |
||
2856 | fMenuHisttype->CheckEntry(menuID); |
||
2857 | } |
||
2858 | |||
2859 | if(nrfiles > 0) |
||
2860 | { |
||
2861 | // Still need to add the switch!!! |
||
2862 | TList *files; |
||
2863 | files = new TList(); |
||
2864 | fileList->GetSelectedEntries(files); |
||
2865 | |||
2866 | if(type < 3) |
||
2867 | DisplayHistogram( (char*)(files->At(0)->GetTitle()), type); |
||
2868 | else if(type == 3) |
||
2869 | MakeSurfPlot( files ); |
||
2870 | } |
||
2871 | } |
||
2872 | |||
2873 | // Changing the histogram type to display |
||
2874 | void TGAppMainFrame::HistogramExport() |
||
2875 | { |
||
2876 | unsigned int nrfiles = fileList->GetNumberOfEntries(); |
||
2877 | TList *files; |
||
2878 | TCanvas *gCanvas = histCanvas->GetCanvas(); |
||
2879 | |||
2880 | char exportname[256]; |
||
2881 | char ctemp[256]; |
||
2882 | |||
2883 | if(nrfiles > 0) |
||
2884 | { |
||
2885 | files = new TList(); |
||
2886 | fileList->GetSelectedEntries(files); |
||
2887 | if(files) |
||
2888 | { |
||
2889 | if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_SURF) ) // for the surface scan, the plot from all selected files is already created |
||
2890 | { |
||
2891 | remove_from_last((char*)files->At(0)->GetTitle(), '_', ctemp); |
||
2892 | sprintf(exportname, "%s_surfscan.pdf", ctemp); |
||
2893 | gCanvas->SaveAs(exportname); |
||
2894 | } |
||
2895 | else |
||
2896 | { |
||
2897 | for(int i = 0; i < (int)nrfiles; i++) |
||
2898 | { |
||
2899 | if(files->At(i)) |
||
2900 | { |
||
2901 | remove_ext((char*)files->At(i)->GetTitle(), ctemp); |
||
2902 | |||
2903 | if(debugSig) |
||
2904 | printf("Filename: %s\n", files->At(i)->GetTitle()); |
||
2905 | if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DADC) ) |
||
2906 | { |
||
2907 | sprintf(exportname, "%s_adc%d.pdf", ctemp, (int)selectCh->GetNumber()); |
||
2908 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0); |
||
2909 | } |
||
2910 | else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DTDC) ) |
||
2911 | { |
||
2912 | sprintf(exportname, "%s_tdc%d.pdf", ctemp, (int)selectCh->GetNumber()); |
||
2913 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 1); |
||
2914 | } |
||
2915 | else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_2D) ) |
||
2916 | { |
||
2917 | sprintf(exportname, "%s_adctdc%d.pdf", ctemp, (int)selectCh->GetNumber()); |
||
2918 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 2); |
||
2919 | } |
||
2920 | |||
2921 | gCanvas->SaveAs(exportname); |
||
2922 | } |
||
2923 | } |
||
2924 | } |
||
2925 | } |
||
2926 | } |
||
2927 | } |
||
2928 | |||
2929 | //--------------------------------------------------------------- |
||
2930 | // Main window constructor definition (& layout) |
||
2931 | |||
2932 | TGAppMainFrame::TGAppMainFrame(const TGWindow *p, int w, int h) |
||
2933 | { |
||
2934 | gDaq = new daq(); |
||
2935 | gScopeDaq = new daqscope(); |
||
2936 | |||
2937 | // Define the main window and menubar |
||
2938 | fMain = new TGMainFrame(p, w, h, kVerticalFrame); // vertical frame split into menubar and main frame |
||
2939 | fMenuBar = new TGMdiMenuBar(fMain, 10, 10); // just prepare menubar, draw it with InitMenu() |
||
2940 | fMain->AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX)); |
||
2941 | |||
2942 | // Define the main frame where opened subwindows will appear |
||
2943 | fMainFrame = new TGMdiMainFrame(fMain, fMenuBar, 300, 300); |
||
2944 | fMain->AddFrame(fMainFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY)); |
||
2945 | |||
2946 | // Initialize the menubar the initial measurement layout subwindows and display the main window |
||
2947 | InitMenu(); |
||
2948 | MeasurementLayout(); |
||
2949 | fMain->SetWindowName(WINDOW_NAME); |
||
2950 | fMain->MapSubwindows(); |
||
2951 | fMain->MapWindow(); |
||
2952 | fMain->Layout(); |
||
2953 | GetPosition(); |
||
2954 | GetVoltOut(); |
||
2955 | } |
||
2956 | |||
2957 | //--------------------------------------------------------------- |
||
2958 | // Event handler for menubar actions |
||
2959 | |||
2960 | void TGAppMainFrame::HandleMenu(Int_t id) |
||
2961 | { |
||
2962 | TList *files; |
||
2963 | |||
2964 | switch (id) { |
||
2965 | case M_FILE_NEW: |
||
2966 | // Clear any values and histogram |
||
2967 | break; |
||
2968 | |||
2969 | case M_FILE_EXIT: |
||
2970 | CloseWindow(); |
||
2971 | break; |
||
2972 | |||
2973 | case M_ANALYSIS_HISTTYPE_1DADC: |
||
2974 | // Toggles the ADC button |
||
2975 | ChangeHisttype(0); |
||
2976 | break; |
||
2977 | |||
2978 | case M_ANALYSIS_HISTTYPE_1DTDC: |
||
2979 | ChangeHisttype(1); |
||
2980 | break; |
||
2981 | |||
2982 | case M_ANALYSIS_HISTTYPE_2D: |
||
2983 | ChangeHisttype(2); |
||
2984 | break; |
||
2985 | |||
2986 | case M_ANALYSIS_HISTTYPE_SURF: |
||
2987 | ChangeHisttype(3); |
||
2988 | break; |
||
2989 | |||
2990 | case M_ANALYSIS_FIT: |
||
2991 | // Fit spectrum |
||
2992 | files = new TList(); |
||
2993 | fileList->GetSelectedEntries(files); |
||
2994 | |||
2995 | if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DADC) && (files->GetSize() > 0) ) |
||
2996 | FitSpectrum(files, 1); |
||
2997 | break; |
||
2998 | |||
2999 | case M_ANALYSIS_FITSEL: |
||
3000 | // Fit all spectra |
||
3001 | files = new TList(); |
||
3002 | fileList->GetSelectedEntries(files); |
||
3003 | |||
3004 | if( (fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DADC)) && (files->GetSize() > 1) ) |
||
3005 | FitSpectrum(files, files->GetSize()); |
||
3006 | break; |
||
3007 | |||
3008 | case M_ANALYSIS_INTEGX: |
||
3009 | // Integrate the current spectra |
||
3010 | files = new TList(); |
||
3011 | fileList->GetSelectedEntries(files); |
||
3012 | |||
3013 | IntegSpectrum(files, 1); |
||
3014 | break; |
||
3015 | |||
3016 | case M_ANALYSIS_INTEGY: |
||
3017 | // Integrate the current spectra |
||
3018 | files = new TList(); |
||
3019 | fileList->GetSelectedEntries(files); |
||
3020 | |||
3021 | IntegSpectrum(files, 2); |
||
3022 | break; |
||
3023 | |||
3024 | case M_WINDOW_HOR: |
||
3025 | fMainFrame->TileHorizontal(); |
||
3026 | break; |
||
3027 | |||
3028 | case M_WINDOW_VERT: |
||
3029 | fMainFrame->TileVertical(); |
||
3030 | break; |
||
3031 | |||
3032 | case M_HELP_ABOUT: |
||
3033 | About(); |
||
3034 | break; |
||
3035 | |||
3036 | default: |
||
3037 | fMainFrame->SetCurrent(id); |
||
3038 | break; |
||
3039 | } |
||
3040 | } |
||
3041 | |||
3042 | //--------------------------------------------------------------- |
||
3043 | // Initialize the main window menu |
||
3044 | |||
3045 | void TGAppMainFrame::InitMenu() |
||
3046 | { |
||
3047 | fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0); |
||
3048 | |||
3049 | // Popup menu in menubar for File controls |
||
3050 | fMenuFile = new TGPopupMenu(gClient->GetRoot()); // adds a new popup menu to the menubar |
||
3051 | fMenuFile->AddEntry(new TGHotString("&New Measurement"), M_FILE_NEW); |
||
3052 | fMenuFile->AddSeparator(); |
||
3053 | fMenuFile->AddEntry(new TGHotString("E&xit"), M_FILE_EXIT); |
||
3054 | |||
3055 | // Popup menu in menubar for Analysis controls |
||
3056 | fMenuHisttype = new TGPopupMenu(gClient->GetRoot()); // adds a cascade menu that will be incorporated into analysis controls |
||
3057 | fMenuHisttype->AddEntry(new TGHotString("1D &ADC histogram"), M_ANALYSIS_HISTTYPE_1DADC); |
||
3058 | fMenuHisttype->AddEntry(new TGHotString("1D &TDC histogram"), M_ANALYSIS_HISTTYPE_1DTDC); |
||
3059 | fMenuHisttype->AddEntry(new TGHotString("&2D ADC vs. TDC histogram"), M_ANALYSIS_HISTTYPE_2D); |
||
3060 | fMenuHisttype->AddEntry(new TGHotString("2D &surface scan plot"), M_ANALYSIS_HISTTYPE_SURF); |
||
3061 | |||
3062 | fMenuAnalysis = new TGPopupMenu(gClient->GetRoot()); // adds a new popup menu to the menubar |
||
3063 | fMenuAnalysis->AddPopup(new TGHotString("&Histogram type"), fMenuHisttype); |
||
3064 | |||
3065 | fMenuAnalysis->AddEntry(new TGHotString("&Fit spectrum"), M_ANALYSIS_FIT); |
||
3066 | fMenuAnalysis->AddEntry(new TGHotString("Fit &all selected"), M_ANALYSIS_FITSEL); |
||
3067 | fMenuAnalysis->AddEntry(new TGHotString("Integrate spectrum (&X direction)"), M_ANALYSIS_INTEGX); |
||
3068 | fMenuAnalysis->AddEntry(new TGHotString("Integrate spectrum (&Y direction)"), M_ANALYSIS_INTEGY); |
||
3069 | |||
3070 | // Popup menu in menubar for Window controls |
||
3071 | fMenuWindow = new TGPopupMenu(gClient->GetRoot()); // adds a new popup menu to the menubar |
||
3072 | fMenuWindow->AddEntry(new TGHotString("Tile &Horizontally"), M_WINDOW_HOR); |
||
3073 | fMenuWindow->AddEntry(new TGHotString("Tile &Vertically"), M_WINDOW_VERT); |
||
3074 | fMenuWindow->AddPopup(new TGHotString("&Windows"), fMainFrame->GetWinListMenu()); |
||
3075 | |||
3076 | // Popup menu in menubar for Help controls |
||
3077 | fMenuHelp = new TGPopupMenu(gClient->GetRoot()); |
||
3078 | fMenuHelp->AddEntry(new TGHotString("&About"), M_HELP_ABOUT); |
||
3079 | |||
3080 | // Connect all menu items with actions - handled by HandleMenu() |
||
3081 | fMenuFile->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)"); |
||
3082 | fMenuAnalysis->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)"); |
||
3083 | fMenuWindow->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)"); |
||
3084 | fMenuHelp->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)"); |
||
3085 | |||
3086 | // Draw the created popup menus on the menubar |
||
3087 | fMenuBar->AddPopup(new TGHotString("&File"), fMenuFile, fMenuBarItemLayout); |
||
3088 | fMenuBar->AddPopup(new TGHotString("&Analysis"),fMenuAnalysis,fMenuBarItemLayout); |
||
3089 | fMenuBar->AddPopup(new TGHotString("&Windows"),fMenuWindow,fMenuBarItemLayout); |
||
3090 | fMenuBar->AddPopup(new TGHotString("&Help"), fMenuHelp, fMenuBarItemLayout); |
||
3091 | } |
||
3092 | |||
3093 | //--------------------------------------------------------------- |
||
3094 | // Set the measurement subwindow layout |
||
3095 | |||
3096 | void TGAppMainFrame::MeasurementLayout() |
||
3097 | { |
||
3098 | TGMdiFrame *mdiFrame; |
||
3099 | |||
3100 | // Generic horizontal and vertical frames |
||
3101 | TGHorizontalFrame *fH1, *fH2, *fH3; |
||
3102 | TGVerticalFrame *fV1; |
||
3103 | TGGroupFrame *fG1; |
||
3104 | TGLabel *lab; |
||
3105 | TGCompositeFrame *fT1; |
||
3106 | |||
3107 | // Sizes of internal group and subwindow structures |
||
3108 | int subwin[2]; |
||
3109 | int subgroup[2]; |
||
3110 | |||
3111 | // Settings pane --------------------------------------------------------------------------- |
||
3112 | subwin[0] = (winWidth/6)-5; subwin[1] = 3*((winHeight/5)-5)-10; |
||
3113 | settingsPane = new TGMdiSubwindow(fMainFrame, subwin[0], subwin[1]); |
||
3114 | mdiFrame = settingsPane->GetMdiFrame(); |
||
3115 | |||
3116 | // Check button to toggle voltage scan |
||
3117 | voltscanOn = new TGCheckButton(mdiFrame, "Voltage scan ON/OFF"); |
||
3118 | voltscanOn->Resize(50,22); |
||
3119 | voltscanOn->SetState(kButtonUp); |
||
3120 | mdiFrame->AddFrame(voltscanOn, f0centerx); |
||
3121 | |||
3122 | // Check button to toggle surface scan |
||
3123 | surfscanOn = new TGCheckButton(mdiFrame, "Surface scan ON/OFF"); |
||
3124 | surfscanOn->Resize(50,22); |
||
3125 | surfscanOn->SetState(kButtonUp); |
||
3126 | mdiFrame->AddFrame(surfscanOn, f0centerx); |
||
3127 | |||
3128 | // Check button to toggle Z direction scan |
||
3129 | zscanOn = new TGCheckButton(mdiFrame, "Z-axis scan ON/OFF"); |
||
3130 | zscanOn->Resize(50,22); |
||
3131 | zscanOn->SetState(kButtonUp); |
||
3132 | mdiFrame->AddFrame(zscanOn, f0centerx); |
||
3133 | |||
3134 | // Check button to toggle (open) the histogram window |
||
3135 | // histogramOn = new TGCheckButton(mdiFrame, "Histogram display ON/OFF"); |
||
3136 | // histogramOn->Resize(50,22); |
||
3137 | // histogramOn->SetState(kButtonUp); |
||
3138 | // mdiFrame->AddFrame(histogramOn, f0centerx); |
||
3139 | |||
3140 | subgroup[0] = subwin[0]-10; |
||
3141 | // Hard limit for maximum voltage we can set |
||
3142 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30); |
||
3143 | lab = new TGLabel(fH1, "Voltage limit:"); |
||
3144 | fH1->AddFrame(lab, f0center2d); |
||
3145 | vHardlimit = new TGNumberEntry(fH1, 70.00, 4, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEAAnyNumber); |
||
3146 | vHardlimit->Resize(80,22); |
||
3147 | fH1->AddFrame(vHardlimit, f0center2d); |
||
3148 | mdiFrame->AddFrame(fH1, f2); |
||
3149 | |||
3150 | // Number of used channels |
||
3151 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30); |
||
3152 | lab = new TGLabel(fH1, "Nr. of channels:"); |
||
3153 | fH1->AddFrame(lab, f0center2d); |
||
3154 | NCH = new TGNumberEntry(fH1, 1, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 1, 8); |
||
3155 | NCH->Resize(40,22); |
||
3156 | fH1->AddFrame(NCH, f0center2d); |
||
3157 | mdiFrame->AddFrame(fH1, f2); |
||
3158 | |||
3159 | // Check button to toggle plots with additional information or clean plots |
||
3160 | cleanOn = new TGCheckButton(mdiFrame, "Clean plots ON/OFF"); |
||
3161 | cleanOn->Resize(50,22); |
||
3162 | cleanOn->SetState(kButtonDown); |
||
3163 | cleanPlots = 1; |
||
3164 | mdiFrame->AddFrame(cleanOn, f0centerx); |
||
3165 | |||
3166 | // Button and textbox to enter the oscilloscope IP address |
||
3167 | lab = new TGLabel(mdiFrame, "Scope IP:"); |
||
3168 | mdiFrame->AddFrame(lab, f0); |
||
3169 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30); |
||
3170 | oscIP = new TGTextEntry(fH1, "178.172.43.157"); |
||
3171 | oscIP->Resize(110,22); |
||
3172 | fH1->AddFrame(oscIP, f0); |
||
3173 | oscConnect = new TGTextButton(fH1, "Connect"); |
||
3174 | oscConnect->SetTextJustify(36); |
||
3175 | oscConnect->SetWrapLength(-1); |
||
3176 | oscConnect->Resize(60,22); |
||
3177 | fH1->AddFrame(oscConnect, f0); |
||
3178 | oscOn = 0; |
||
3179 | mdiFrame->AddFrame(fH1, f2); |
||
3180 | |||
3181 | // Laser settings (freq., tune, ND filter) |
||
3182 | lab = new TGLabel(mdiFrame, "Laser settings:"); |
||
3183 | mdiFrame->AddFrame(lab, f0); |
||
3184 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30); |
||
3185 | laserInfo = new TGTextEntry(fH1, "kHz, tune, ND"); |
||
3186 | fH1->AddFrame(laserInfo, f2); |
||
3187 | mdiFrame->AddFrame(fH1, f2); |
||
3188 | |||
127 | f9daq | 3189 | // Chamber temperature (will only be manually set until we can get it directly from the chamber) |
3190 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30); |
||
3191 | lab = new TGLabel(fH1, "Chamber temp.:"); |
||
3192 | fH1->AddFrame(lab, f0center2d); |
||
3193 | chtemp = new TGNumberEntry(fH1, 25.0, 6, 999, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -70., 150.); |
||
3194 | chtemp->Resize(60,22); |
||
3195 | fH1->AddFrame(chtemp, f0center2d); |
||
3196 | mdiFrame->AddFrame(fH1, f2); |
||
3197 | |||
117 | f9daq | 3198 | mdiFrame->SetMdiHints(kMdiMinimize); |
3199 | mdiFrame->SetWindowName("Settings pane"); |
||
3200 | mdiFrame->MapSubwindows(); |
||
3201 | mdiFrame->Layout(); |
||
3202 | mdiFrame->Move(0,0); |
||
3203 | // Settings pane --------------------------------------------------------------------------- |
||
3204 | |||
3205 | // Main window ----------------------------------------------------------------------------- |
||
3206 | subwin[0] = 3*((winWidth/6)-5); subwin[1] = 3*((winHeight/5)-5)-10; |
||
3207 | mainSubwindow = new TGMdiSubwindow(fMainFrame, subwin[0], subwin[1]); |
||
3208 | mdiFrame = mainSubwindow->GetMdiFrame(); |
||
3209 | |||
3210 | // Voltage and position tab |
||
3211 | subgroup[0] = 2*subwin[0]/5-12; |
||
3212 | subgroup[1] = (subwin[1]+15)/2+5; |
||
3213 | setTab = new TGTab(mdiFrame, subgroup[0], subgroup[1]); |
||
3214 | |||
3215 | fT1 = setTab->AddTab("Voltage + Position"); |
||
3216 | |||
3217 | fH1 = new TGHorizontalFrame(fT1, subwin[0], subgroup[1], kFixedHeight); |
||
3218 | // Left pane (Bias voltage controls) |
||
3219 | fV1 = new TGVerticalFrame(fH1, subgroup[0], subgroup[1], kFixedWidth | kFixedHeight); |
||
3220 | fG1 = new TGGroupFrame(fV1, "Bias voltage controls"); |
||
3221 | |||
3222 | // Output voltage supply channel |
||
3223 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3224 | lab = new TGLabel(fH2, "Output channel:"); |
||
3225 | fH2->AddFrame(lab, f0center2d); |
||
3226 | vOutCh = new TGComboBox(fH2, 200); |
||
3227 | vOutCh->AddEntry("1", 0); |
||
3228 | vOutCh->AddEntry("2", 1); |
||
3229 | vOutCh->AddEntry("3", 2); |
||
3230 | vOutCh->AddEntry("4", 3); |
||
3231 | vOutCh->AddEntry("5", 4); |
||
3232 | vOutCh->AddEntry("6", 5); |
||
3233 | vOutCh->AddEntry("7", 6); |
||
3234 | vOutCh->AddEntry("8", 7); |
||
3235 | vOutCh->AddEntry("101", 8); |
||
3236 | vOutCh->AddEntry("102", 9); |
||
3237 | vOutCh->AddEntry("103", 10); |
||
3238 | vOutCh->AddEntry("104", 11); |
||
3239 | vOutCh->AddEntry("105", 12); |
||
3240 | vOutCh->AddEntry("106", 13); |
||
3241 | vOutCh->AddEntry("107", 14); |
||
3242 | vOutCh->AddEntry("108", 15); |
||
3243 | vOutCh->Resize(50,22); |
||
3244 | vOutCh->Select(0); |
||
3245 | fH2->AddFrame(vOutCh, f0center2d); |
||
3246 | fG1->AddFrame(fH2, f2); |
||
3247 | |||
3248 | // Output voltage setting |
||
3249 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3250 | lab = new TGLabel(fH2, "Output voltage:"); |
||
3251 | fH2->AddFrame(lab, f0center2d); |
||
3252 | vOut = new TGNumberEntry(fH2, 0.00, 4, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, 0, vHardlimit->GetNumber()); |
||
3253 | vOut->Resize(80,22); |
||
3254 | fH2->AddFrame(vOut, f0center2d); |
||
3255 | fG1->AddFrame(fH2, f2); |
||
3256 | |||
3257 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3258 | vOutOnOff = new TGCheckButton(fH2, "Output ON/OFF"); |
||
3259 | vOutOnOff->Resize(subgroup[0]-10,22); |
||
3260 | vOutOnOff->SetState(kButtonUp); |
||
3261 | fH2->AddFrame(vOutOnOff, f0centerx); |
||
3262 | fG1->AddFrame(fH2, f2); |
||
3263 | |||
3264 | // Set, get and reset voltage buttons |
||
3265 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3266 | fH3 = new TGHorizontalFrame(fH2, subgroup[0], 30); |
||
3267 | vOutSet = new TGTextButton(fH3, "Set"); |
||
3268 | vOutSet->SetTextJustify(36); |
||
3269 | vOutSet->SetWrapLength(-1); |
||
3270 | vOutSet->Resize(60,22); |
||
3271 | fH3->AddFrame(vOutSet, f0); |
||
3272 | vOutGet = new TGTextButton(fH3, "Get"); |
||
3273 | vOutGet->SetTextJustify(36); |
||
3274 | vOutGet->SetWrapLength(-1); |
||
3275 | vOutGet->Resize(60,22); |
||
3276 | fH3->AddFrame(vOutGet, f0); |
||
3277 | vOutReset = new TGTextButton(fH3, "Reset"); |
||
3278 | vOutReset->SetTextJustify(36); |
||
3279 | vOutReset->SetWrapLength(-1); |
||
3280 | vOutReset->Resize(60,22); |
||
3281 | fH3->AddFrame(vOutReset, f0); |
||
3282 | fH2->AddFrame(fH3, f0centerx); |
||
3283 | fG1->AddFrame(fH2, f2); |
||
3284 | |||
3285 | // Voltage scan controls |
||
3286 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3287 | lab = new TGLabel(fH2, "V (min):"); |
||
3288 | fH2->AddFrame(lab, f0center2d); |
||
3289 | vOutStart = new TGNumberEntry(fH2, 0.00, 4, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEAAnyNumber); |
||
3290 | vOutStart->Resize(80,22); |
||
3291 | fH2->AddFrame(vOutStart, f0center2d); |
||
3292 | fG1->AddFrame(fH2, f2); |
||
3293 | |||
3294 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3295 | lab = new TGLabel(fH2, "V (max):"); |
||
3296 | fH2->AddFrame(lab, f0center2d); |
||
3297 | vOutStop = new TGNumberEntry(fH2, 0.00, 4, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEAAnyNumber); |
||
3298 | vOutStop->Resize(80,22); |
||
3299 | fH2->AddFrame(vOutStop, f0center2d); |
||
3300 | fG1->AddFrame(fH2, f2); |
||
3301 | |||
3302 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3303 | lab = new TGLabel(fH2, "V (step):"); |
||
3304 | fH2->AddFrame(lab, f0center2d); |
||
3305 | vOutStep = new TGNumberEntry(fH2, 0.00, 4, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEAAnyNumber); |
||
3306 | vOutStep->Resize(80,22); |
||
3307 | fH2->AddFrame(vOutStep, f0center2d); |
||
3308 | fG1->AddFrame(fH2, f2); |
||
3309 | |||
3310 | fV1->AddFrame(fG1, f1); |
||
3311 | // Left pane (Bias voltage controls) |
||
3312 | fH1->AddFrame(fV1, f0); |
||
3313 | |||
3314 | // Right pane (Table position controls) |
||
3315 | subgroup[0] = 3*subwin[0]/5-12; |
||
3316 | fV1 = new TGVerticalFrame(fH1, subgroup[0], subgroup[1], kFixedWidth | kFixedHeight); |
||
3317 | fG1 = new TGGroupFrame(fV1, "Table position controls"); |
||
3318 | |||
3319 | // X, Y and Z positions |
||
3320 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3321 | lab = new TGLabel(fH2, "X:"); |
||
3322 | fH2->AddFrame(lab, f0center2d); |
||
3323 | xPos = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 215000); |
||
3324 | xPos->Resize(80,22); |
||
3325 | fH2->AddFrame(xPos, f0center2d); |
||
3326 | |||
3327 | lab = new TGLabel(fH2, "Z (min):"); |
||
3328 | fH2->AddFrame(lab, f0center2d); |
||
3329 | zPosMin = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 375000); |
||
3330 | zPosMin->Resize(80,22); |
||
3331 | fH2->AddFrame(zPosMin, f0center2d); |
||
3332 | fG1->AddFrame(fH2, f2); |
||
3333 | |||
3334 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3335 | lab = new TGLabel(fH2, "Y:"); |
||
3336 | fH2->AddFrame(lab, f0center2d); |
||
3337 | yPos = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 215000); |
||
3338 | yPos->Resize(80,22); |
||
3339 | fH2->AddFrame(yPos, f0center2d); |
||
3340 | |||
3341 | lab = new TGLabel(fH2, "Z (max):"); |
||
3342 | fH2->AddFrame(lab, f0center2d); |
||
3343 | zPosMax = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 375000); |
||
3344 | zPosMax->Resize(80,22); |
||
3345 | fH2->AddFrame(zPosMax, f0center2d); |
||
3346 | fG1->AddFrame(fH2, f2); |
||
3347 | |||
3348 | fH2 = new TGHorizontalFrame(fG1, subgroup[0] ,30); |
||
3349 | lab = new TGLabel(fH2, "Z:"); |
||
3350 | fH2->AddFrame(lab, f0center2d); |
||
3351 | zPos = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 375000); |
||
3352 | zPos->Resize(80,22); |
||
3353 | fH2->AddFrame(zPos, f0center2d); |
||
3354 | |||
3355 | lab = new TGLabel(fH2, "Z (step):"); |
||
3356 | fH2->AddFrame(lab, f0center2d); |
||
3357 | zPosStep = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); |
||
3358 | zPosStep->Resize(80,22); |
||
3359 | fH2->AddFrame(zPosStep, f0center2d); |
||
3360 | fG1->AddFrame(fH2, f2); |
||
3361 | |||
3362 | // Set, Get and Home the table position |
||
3363 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3364 | fH3 = new TGHorizontalFrame(fH2, subgroup[0], 30); |
||
3365 | positionSet = new TGTextButton(fH3, "Set"); |
||
3366 | positionSet->SetTextJustify(36); |
||
3367 | positionSet->SetWrapLength(-1); |
||
3368 | positionSet->Resize(60,22); |
||
3369 | fH3->AddFrame(positionSet, f0); |
||
3370 | positionGet = new TGTextButton(fH3, "Get"); |
||
3371 | positionGet->SetTextJustify(36); |
||
3372 | positionGet->SetWrapLength(-1); |
||
3373 | positionGet->Resize(60,22); |
||
3374 | fH3->AddFrame(positionGet, f0); |
||
3375 | positionHome = new TGTextButton(fH3, "Home"); |
||
3376 | positionHome->SetTextJustify(36); |
||
3377 | positionHome->SetWrapLength(-1); |
||
3378 | positionHome->Resize(60,22); |
||
3379 | fH3->AddFrame(positionHome, f0); |
||
3380 | fH2->AddFrame(fH3, f0centerx); |
||
3381 | fG1->AddFrame(fH2, f2); |
||
3382 | |||
3383 | // Position scan controls |
||
3384 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3385 | lab = new TGLabel(fH2, "X (min):"); |
||
3386 | fH2->AddFrame(lab, f0center2d); |
||
3387 | xPosMin = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 215000); |
||
3388 | xPosMin->Resize(80,22); |
||
3389 | fH2->AddFrame(xPosMin, f0center2d); |
||
3390 | |||
3391 | lab = new TGLabel(fH2, "Y (min):"); |
||
3392 | fH2->AddFrame(lab, f0center2d); |
||
3393 | yPosMin = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 215000); |
||
3394 | yPosMin->Resize(80,22); |
||
3395 | fH2->AddFrame(yPosMin, f0center2d); |
||
3396 | fG1->AddFrame(fH2, f2); |
||
3397 | |||
3398 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3399 | lab = new TGLabel(fH2, "X (max):"); |
||
3400 | fH2->AddFrame(lab, f0center2d); |
||
3401 | xPosMax = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 215000); |
||
3402 | xPosMax->Resize(80,22); |
||
3403 | fH2->AddFrame(xPosMax, f0center2d); |
||
3404 | |||
3405 | lab = new TGLabel(fH2, "Y (max):"); |
||
3406 | fH2->AddFrame(lab, f0center2d); |
||
3407 | yPosMax = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 215000); |
||
3408 | yPosMax->Resize(80,22); |
||
3409 | fH2->AddFrame(yPosMax, f0center2d); |
||
3410 | fG1->AddFrame(fH2, f2); |
||
3411 | |||
3412 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3413 | lab = new TGLabel(fH2, "X (step):"); |
||
3414 | fH2->AddFrame(lab, f0center2d); |
||
3415 | xPosStep = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); |
||
3416 | xPosStep->Resize(80,22); |
||
3417 | fH2->AddFrame(xPosStep, f0center2d); |
||
3418 | |||
3419 | lab = new TGLabel(fH2, "Y (step):"); |
||
3420 | fH2->AddFrame(lab, f0center2d); |
||
3421 | yPosStep = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); |
||
3422 | yPosStep->Resize(80,22); |
||
3423 | fH2->AddFrame(yPosStep, f0center2d); |
||
3424 | fG1->AddFrame(fH2, f2); |
||
3425 | |||
3426 | fV1->AddFrame(fG1, f1); |
||
3427 | // Right pane (Table position controls) |
||
3428 | fH1->AddFrame(fV1, f0); |
||
3429 | fT1->AddFrame(fH1, f1); |
||
3430 | |||
3431 | // Waveform tab |
||
127 | f9daq | 3432 | fT1 = setTab->AddTab("Waveform analysis"); |
117 | f9daq | 3433 | fH1 = new TGHorizontalFrame(fT1, subwin[0], subgroup[1], kFixedHeight); |
127 | f9daq | 3434 | subgroup[0] = 1*subwin[0]/2-12; |
3435 | fV1 = new TGVerticalFrame(fH1, subgroup[0], subgroup[1]/3, kFixedWidth); |
||
117 | f9daq | 3436 | |
127 | f9daq | 3437 | fG1 = new TGGroupFrame(fV1, "Acquisition channel"); |
117 | f9daq | 3438 | |
127 | f9daq | 3439 | // Selection of channels |
3440 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 100); |
||
3441 | sCH[0] = new TGCheckButton(fH2, "CH1"); |
||
3442 | sCH[0]->Resize(50,22); |
||
3443 | sCH[0]->SetState(kButtonUp); |
||
3444 | fH2->AddFrame(sCH[0], f0centerx); |
||
3445 | sCH[1] = new TGCheckButton(fH2, "CH2"); |
||
3446 | sCH[1]->Resize(50,22); |
||
3447 | sCH[1]->SetState(kButtonUp); |
||
3448 | fH2->AddFrame(sCH[1], f0centerx); |
||
3449 | sCH[2] = new TGCheckButton(fH2, "CH3"); |
||
3450 | sCH[2]->Resize(50,22); |
||
3451 | sCH[2]->SetState(kButtonUp); |
||
3452 | fH2->AddFrame(sCH[2], f0centerx); |
||
3453 | sCH[3] = new TGCheckButton(fH2, "CH4"); |
||
3454 | sCH[3]->Resize(50,22); |
||
3455 | sCH[3]->SetState(kButtonUp); |
||
3456 | fH2->AddFrame(sCH[3], f0centerx); |
||
3457 | fG1->AddFrame(fH2, f0centerx); |
||
3458 | |||
3459 | // Selection of MATH channels |
||
3460 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 100); |
||
3461 | sCH[4] = new TGCheckButton(fH2, "MATH1"); |
||
3462 | sCH[4]->Resize(50,22); |
||
3463 | sCH[4]->SetState(kButtonUp); |
||
3464 | fH2->AddFrame(sCH[4], f0centerx); |
||
3465 | sCH[5] = new TGCheckButton(fH2, "MATH2"); |
||
3466 | sCH[5]->Resize(50,22); |
||
3467 | sCH[5]->SetState(kButtonUp); |
||
3468 | fH2->AddFrame(sCH[5], f0centerx); |
||
3469 | sCH[6] = new TGCheckButton(fH2, "MATH3"); |
||
3470 | sCH[6]->Resize(50,22); |
||
3471 | sCH[6]->SetState(kButtonUp); |
||
3472 | fH2->AddFrame(sCH[6], f0centerx); |
||
3473 | sCH[7] = new TGCheckButton(fH2, "MATH4"); |
||
3474 | sCH[7]->Resize(50,22); |
||
3475 | sCH[7]->SetState(kButtonUp); |
||
3476 | fH2->AddFrame(sCH[7], f0centerx); |
||
3477 | fG1->AddFrame(fH2, f0centerx); |
||
3478 | |||
3479 | fV1->AddFrame(fG1, f2); |
||
3480 | |||
3481 | // Selection of measurement type |
||
3482 | fH2 = new TGHorizontalFrame(fV1, subgroup[0], 30); |
||
3483 | lab = new TGLabel(fH2, "Scope use type:"); |
||
3484 | fH2->AddFrame(lab, f0center2d); |
||
3485 | sMeasType = new TGComboBox(fH2, 200); |
||
3486 | sMeasType->AddEntry("No waveform analysis", 0); |
||
3487 | sMeasType->AddEntry("Waveform acquisition", 1); |
||
3488 | sMeasType->AddEntry("Measurement", 2); |
||
3489 | sMeasType->Resize(150,22); |
||
3490 | sMeasType->Select(0); |
||
3491 | fH2->AddFrame(sMeasType, f0center2d); |
||
3492 | fV1->AddFrame(fH2, f2); |
||
3493 | |||
3494 | // Link waveform analysis to CAMAC acquisition |
||
3495 | sCamaclink = new TGCheckButton(fV1, "Link waveform to CAMAC acquisition"); |
||
3496 | sCamaclink->Resize(200,22); |
||
3497 | sCamaclink->SetState(kButtonUp); |
||
3498 | fV1->AddFrame(sCamaclink, f0centerx); |
||
3499 | |||
3500 | // Custom command interface for the scope |
||
3501 | lab = new TGLabel(fV1, "Custom scope command:"); |
||
3502 | fV1->AddFrame(lab, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,10,2) ); |
||
3503 | fH2 = new TGHorizontalFrame(fV1, subgroup[0], 30); |
||
3504 | scopeCommand = new TGTextEntry(fH2, ""); |
||
3505 | scopeCommand->Resize(subgroup[0]-45,22); |
||
3506 | fH2->AddFrame(scopeCommand, f2); |
||
3507 | sendScopeCustom = new TGTextButton(fH2, "Send"); |
||
3508 | sendScopeCustom->SetTextJustify(36); |
||
3509 | sendScopeCustom->SetWrapLength(-1); |
||
3510 | sendScopeCustom->Resize(80,22); |
||
3511 | fH2->AddFrame(sendScopeCustom, f0centery); |
||
3512 | fV1->AddFrame(fH2, f0); |
||
3513 | |||
3514 | // Return value for custom scope command |
||
3515 | lab = new TGLabel(fV1, "Return:"); |
||
3516 | fV1->AddFrame(lab, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,10,2) ); |
||
3517 | scopeReturn = new TGTextEntry(fV1, ""); |
||
3518 | scopeReturn->Resize(subgroup[0],22); |
||
3519 | fV1->AddFrame(scopeReturn, f2); |
||
3520 | |||
3521 | fH1->AddFrame(fV1, f0); |
||
3522 | |||
3523 | // Wave measurement type |
||
3524 | fV1 = new TGVerticalFrame(fH1, subgroup[0], subgroup[1]/3, kFixedWidth); |
||
3525 | fH2 = new TGHorizontalFrame(fV1, subgroup[0], 30); |
||
3526 | lab = new TGLabel(fH2, "Meas. type:"); |
||
3527 | fH2->AddFrame(lab, f0center2d); |
||
3528 | sMeasgroup = new TGComboBox(fH2, 200); |
||
3529 | for(int i = 0; i < 11; i++) |
||
3530 | sMeasgroup->AddEntry(allMeasNames[i], i); |
||
3531 | sMeasgroup->Resize(150,22); |
||
3532 | sMeasgroup->Select(4); |
||
3533 | fH2->AddFrame(sMeasgroup, f0center2d); |
||
3534 | fV1->AddFrame(fH2, f2); |
||
3535 | |||
3536 | // Initialize current acquisition settings |
||
3537 | scopeInit = new TGTextButton(fV1, "Initialize scope"); |
||
3538 | scopeInit->SetTextJustify(36); |
||
3539 | scopeInit->SetWrapLength(-1); |
||
3540 | scopeInit->Resize(80,22); |
||
3541 | fV1->AddFrame(scopeInit, f0centerx); |
||
3542 | |||
3543 | fH1->AddFrame(fV1, f0); |
||
3544 | fT1->AddFrame(fH1, f1); |
||
3545 | |||
117 | f9daq | 3546 | mdiFrame->AddFrame(setTab, f0); |
3547 | |||
3548 | // Bottom pane (File controls) |
||
3549 | subgroup[0] = subwin[0]-20; |
||
3550 | subgroup[1] = subwin[1]/3-30; //2*(3*((winWidth/6)-5))/5+10; |
||
3551 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], subgroup[1] /*1*(3*((winWidth/6)-5))/5+15*/ , kFixedWidth | kFixedHeight); |
||
3552 | fG1 = new TGGroupFrame(fH1, "Event/Data file controls"); |
||
3553 | |||
3554 | // Number of events |
||
3555 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3556 | lab = new TGLabel(fH2, "Number of events:"); |
||
3557 | fH2->AddFrame(lab, f0centery); |
||
3558 | evtNum = new TGNumberEntry(fH2, 10000, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); |
||
3559 | evtNum->Resize(80,22); |
||
3560 | fH2->AddFrame(evtNum, f0centery); |
||
3561 | fG1->AddFrame(fH2, f2); |
||
3562 | |||
3563 | // Time stamp display |
||
3564 | fH2 = new TGHorizontalFrame(fG1,600,200); |
||
3565 | lab = new TGLabel(fH2, "Time stamp:"); |
||
3566 | fH2->AddFrame(lab, f0centery); |
||
3567 | timeStamp = new TGTextEntry(fH2, ""); |
||
3568 | timeStamp->Resize(440,22); |
||
3569 | timeStamp->SetState(kFALSE); // time stamp is read-only |
||
3570 | fH2->AddFrame(timeStamp, f0centery); |
||
3571 | fG1->AddFrame(fH2, f2); |
||
3572 | |||
3573 | // Save to file |
||
3574 | fH2 = new TGHorizontalFrame(fG1,600,200); |
||
3575 | lab = new TGLabel(fH2, "Save to file:"); |
||
3576 | fH2->AddFrame(lab, f0centery); |
||
3577 | char *cTemp; |
||
3578 | cTemp = new char[256]; |
||
3579 | sprintf(cTemp, "./results/test%s", histExt); |
||
3580 | fileName = new TGTextEntry(fH2, cTemp); |
||
3581 | delete[] cTemp; |
||
3582 | fileName->Resize(400,22); |
||
3583 | fileName->SetState(kFALSE); |
||
3584 | fH2->AddFrame(fileName, f0centery); |
||
3585 | saveFile = new TGTextButton(fH2, "..."); |
||
3586 | saveFile->SetTextJustify(36); |
||
3587 | saveFile->SetWrapLength(-1); |
||
3588 | saveFile->Resize(80,22); |
||
3589 | fH2->AddFrame(saveFile, f0centery); |
||
3590 | // mdiFrame->AddFrame(fH2, f0); |
||
3591 | fG1->AddFrame(fH2, f2); |
||
3592 | fH1->AddFrame(fG1, f1); |
||
3593 | // Bottom pane (File controls) |
||
3594 | mdiFrame->AddFrame(fH1, f0); |
||
3595 | |||
3596 | subgroup[0] = subwin[0]-70; |
||
3597 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30); |
||
3598 | fH2 = new TGHorizontalFrame(fH1, 3*subgroup[0]/4, 30, kFixedWidth); |
||
3599 | measStart = new TGTextButton(fH2, "Start acquisition"); |
||
3600 | measStart->SetTextJustify(36); |
||
3601 | measStart->SetWrapLength(-1); |
||
3602 | measStart->Resize(80,22); |
||
3603 | fH2->AddFrame(measStart, f0center2d); |
||
3604 | |||
3605 | ULong_t fcolor; |
||
3606 | gClient->GetColorByName("red", fcolor); |
||
3607 | |||
3608 | busyLabel = new TGLabel(fH2, "Busy"); //, fTextGC->GetGC(), labelfont, kChildFrame); |
||
3609 | busyLabel->SetTextJustify(36); |
||
3610 | busyLabel->Resize(80,22); |
||
3611 | busyLabel->Disable(); |
||
3612 | busyLabel->SetTextColor(fcolor); |
||
3613 | fH2->AddFrame(busyLabel, f0center2d); |
||
3614 | |||
3615 | curProgress = new TGHProgressBar(fH2, TGProgressBar::kStandard, 150); |
||
3616 | curProgress->ShowPosition(); |
||
3617 | curProgress->SetRange(0,100); |
||
3618 | curProgress->SetBarColor("green"); |
||
3619 | fH2->AddFrame(curProgress, f0center2d); |
||
3620 | fH1->AddFrame(fH2, f0centerx); |
||
3621 | mdiFrame->AddFrame(fH1, f2); |
||
3622 | |||
3623 | mdiFrame->SetMdiHints(kMdiMinimize | kMdiMaximize); |
||
3624 | mdiFrame->SetWindowName("Main measurement window"); |
||
3625 | mdiFrame->MapSubwindows(); |
||
3626 | mdiFrame->Layout(); |
||
3627 | mdiFrame->Move((winWidth/6),0); |
||
3628 | // Main window ----------------------------------------------------------------------------- |
||
3629 | |||
3630 | // Histogram pane -------------------------------------------------------------------------- |
||
3631 | subwin[0] = 2*((winWidth/6)-5); subwin[1] = (int)(2.5*((winHeight/5)-5))-5; |
||
3632 | histogramPane = new TGMdiSubwindow(fMainFrame, subwin[0], subwin[1]); |
||
3633 | mdiFrame = histogramPane->GetMdiFrame(); |
||
3634 | |||
3635 | histCanvas = new TRootEmbeddedCanvas("histCanvas",mdiFrame,900,900); |
||
3636 | mdiFrame->AddFrame(histCanvas, f1); |
||
3637 | TCanvas *gCanvas = histCanvas->GetCanvas(); |
||
3638 | gCanvas->SetGridx(); |
||
3639 | gCanvas->SetGridy(); |
||
3640 | |||
3641 | mdiFrame->SetMdiHints(kMdiMinimize | kMdiMaximize); |
||
3642 | mdiFrame->SetWindowName("Histogram"); |
||
3643 | mdiFrame->MapSubwindows(); |
||
3644 | mdiFrame->Layout(); |
||
3645 | mdiFrame->Move(4*((winWidth/6)-5)+10,0); |
||
3646 | // Histogram pane -------------------------------------------------------------------------- |
||
3647 | |||
3648 | // Histogram file selection pane ----------------------------------------------------------- |
||
3649 | subwin[0] = 4*((winWidth/6)-5); subwin[1] = 2*((winHeight/5)-5)+15; |
||
3650 | histogramPaneFile = new TGMdiSubwindow(fMainFrame, subwin[0]+5, subwin[1]); |
||
3651 | mdiFrame = histogramPaneFile->GetMdiFrame(); |
||
3652 | |||
3653 | // Open browser for file selection |
||
3654 | subgroup[0] = subwin[0]-10; |
||
3655 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30); |
||
3656 | lab = new TGLabel(fH1, "File selection:"); |
||
3657 | fH1->AddFrame(lab, f0centery); |
||
3658 | |||
3659 | selectDir = new TGTextButton(fH1, "..."); |
||
3660 | selectDir->SetTextJustify(36); |
||
3661 | selectDir->SetWrapLength(-1); |
||
3662 | selectDir->Resize(80,22); |
||
3663 | fH1->AddFrame(selectDir, f0centery); |
||
3664 | mdiFrame->AddFrame(fH1, f2); |
||
3665 | |||
3666 | // List view of the opened files |
||
3667 | fileList = new TGListBox(mdiFrame,1); |
||
3668 | fileList->GetVScrollbar(); |
||
3669 | fileList->Resize(300, (subwin[1]/2)-10 ); |
||
3670 | mdiFrame->AddFrame(fileList, f2); |
||
3671 | |||
3672 | // Multiple file selection toggle, previous/next controls and clear list |
||
3673 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30); |
||
3674 | multiSelect = new TGCheckButton(fH1, "Multiple file select"); |
||
3675 | multiSelect->Resize(50,22); |
||
3676 | multiSelect->SetState(kButtonUp); |
||
3677 | fH1->AddFrame(multiSelect, f0); |
||
3678 | |||
3679 | multiSelectAll = new TGCheckButton(fH1, "Select all listed files"); |
||
3680 | multiSelectAll->Resize(50,22); |
||
3681 | multiSelectAll->SetState(kButtonUp); |
||
3682 | fH1->AddFrame(multiSelectAll, f0); |
||
3683 | |||
3684 | TGTextButton *clearList = new TGTextButton(fH1, "Clear list"); |
||
3685 | clearList->SetTextJustify(36); |
||
3686 | clearList->SetWrapLength(-1); |
||
3687 | clearList->Resize(80,22); |
||
3688 | fH1->AddFrame(clearList, f0right); |
||
3689 | |||
3690 | nextFile = new TGTextButton(fH1, ">>"); |
||
3691 | nextFile->SetTextJustify(36); |
||
3692 | nextFile->SetWrapLength(-1); |
||
3693 | nextFile->Resize(80,22); |
||
3694 | fH1->AddFrame(nextFile, f0right); |
||
3695 | |||
3696 | prevFile = new TGTextButton(fH1, "<<"); |
||
3697 | prevFile->SetTextJustify(36); |
||
3698 | prevFile->SetWrapLength(-1); |
||
3699 | prevFile->Resize(80,22); |
||
3700 | fH1->AddFrame(prevFile, f0right); |
||
3701 | mdiFrame->AddFrame(fH1, f2); |
||
3702 | |||
3703 | mdiFrame->SetMdiHints(kMdiMinimize); |
||
3704 | mdiFrame->SetWindowName("Histogram file selection"); |
||
3705 | mdiFrame->MapSubwindows(); |
||
3706 | mdiFrame->Layout(); |
||
3707 | mdiFrame->Move(0,3*((winHeight/5)-5)-5); |
||
3708 | // Histogram file selection pane ----------------------------------------------------------- |
||
3709 | |||
3710 | // Histogram controls pane ----------------------------------------------------------------- |
||
3711 | subwin[0] = 2*((winWidth/6)-5); subwin[1] = (int)(2.5*((winHeight/5)-5))+10; |
||
3712 | histogramPaneCtr = new TGMdiSubwindow(fMainFrame, subwin[0], subwin[1]); |
||
3713 | mdiFrame = histogramPaneCtr->GetMdiFrame(); |
||
3714 | |||
3715 | // Control for histogram X range |
||
3716 | subgroup[0] = subwin[0]-10; |
||
3717 | fG1 = new TGGroupFrame(mdiFrame, "Histogram display"); |
||
3718 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3719 | lab = new TGLabel(fH1, "ADC range (min, max):"); |
||
3720 | fH1->AddFrame(lab, f0centery); |
||
3721 | adcMinRange = new TGNumberEntry(fH1, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber); |
||
3722 | adcMinRange->Resize(80,22); |
||
3723 | fH1->AddFrame(adcMinRange, f0centery); |
||
3724 | adcMaxRange = new TGNumberEntry(fH1, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber); |
||
3725 | adcMaxRange->Resize(80,22); |
||
3726 | fH1->AddFrame(adcMaxRange, f0centery); |
||
3727 | fG1->AddFrame(fH1, f2); |
||
3728 | |||
3729 | // TDC window for getting data |
||
3730 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3731 | lab = new TGLabel(fH1, "TDC range (min, max):"); |
||
3732 | fH1->AddFrame(lab, f0centery); |
||
3733 | tdcMinwindow = new TGNumberEntry(fH1, 0.0, 6, 999, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEAAnyNumber); |
||
3734 | tdcMinwindow->Resize(80,22); |
||
3735 | fH1->AddFrame(tdcMinwindow, f0centery); |
||
3736 | tdcMaxwindow = new TGNumberEntry(fH1, 221.8, 6, 999, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEAAnyNumber); |
||
3737 | tdcMaxwindow->Resize(80,22); |
||
3738 | fH1->AddFrame(tdcMaxwindow, f0centery); |
||
3739 | fG1->AddFrame(fH1, f2); |
||
3740 | |||
3741 | // Y axis range settings |
||
3742 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3743 | lab = new TGLabel(fH1, "Y range (min, max):"); |
||
3744 | fH1->AddFrame(lab, f0centery); |
||
3745 | yMinRange = new TGNumberEntry(fH1, 0, 6, 999, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAAnyNumber); |
||
3746 | yMinRange->Resize(80,22); |
||
3747 | fH1->AddFrame(yMinRange, f0centery); |
||
3748 | yMaxRange = new TGNumberEntry(fH1, 0, 6, 999, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAAnyNumber); |
||
3749 | yMaxRange->Resize(80,22); |
||
3750 | fH1->AddFrame(yMaxRange, f0centery); |
||
3751 | fG1->AddFrame(fH1, f2); |
||
3752 | |||
3753 | // Select the channel to display |
||
3754 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3755 | lab = new TGLabel(fH1, "Display channel:"); |
||
3756 | fH1->AddFrame(lab, f0centery); |
||
3757 | selectCh = new TGNumberEntry(fH1, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, (NCH->GetNumber())-1); |
||
3758 | selectCh->Resize(40,22); |
||
3759 | fH1->AddFrame(selectCh, f0centery); |
||
3760 | |||
3761 | changeADC = new TGTextButton(fH1, "ADC"); |
||
3762 | changeADC->AllowStayDown(kTRUE); |
||
3763 | changeADC->SetDown(kTRUE); |
||
3764 | fMenuHisttype->CheckEntry(M_ANALYSIS_HISTTYPE_1DADC); |
||
3765 | changeADC->SetTextJustify(36); |
||
3766 | changeADC->SetWrapLength(-1); |
||
3767 | changeADC->Resize(60,22); |
||
3768 | fH1->AddFrame(changeADC, f0centery); |
||
3769 | |||
3770 | changeTDC = new TGTextButton(fH1, "TDC"); |
||
3771 | changeTDC->AllowStayDown(kTRUE); |
||
3772 | changeTDC->SetTextJustify(36); |
||
3773 | changeTDC->SetWrapLength(-1); |
||
3774 | changeTDC->Resize(60,22); |
||
3775 | fH1->AddFrame(changeTDC, f0centery); |
||
3776 | |||
3777 | changeADCTDC = new TGTextButton(fH1, "ADC/TDC"); |
||
3778 | changeADCTDC->AllowStayDown(kTRUE); |
||
3779 | changeADCTDC->SetTextJustify(36); |
||
3780 | changeADCTDC->SetWrapLength(-1); |
||
3781 | changeADCTDC->Resize(60,22); |
||
3782 | fH1->AddFrame(changeADCTDC, f0centery); |
||
3783 | |||
3784 | change2Dsurf = new TGTextButton(fH1, "Surf 2D"); |
||
3785 | change2Dsurf->AllowStayDown(kTRUE); |
||
3786 | change2Dsurf->SetTextJustify(36); |
||
3787 | change2Dsurf->SetWrapLength(-1); |
||
3788 | change2Dsurf->Resize(60,22); |
||
3789 | fH1->AddFrame(change2Dsurf, f0); |
||
3790 | fG1->AddFrame(fH1, f2); |
||
3791 | |||
3792 | logscale = new TGCheckButton(fG1, "Logarithmic scale ON/OFF"); |
||
3793 | logscale->Resize(50,22); |
||
3794 | logscale->SetState(kButtonUp); |
||
3795 | fG1->AddFrame(logscale, f0centerx); |
||
3796 | |||
3797 | // Export the selected files |
||
3798 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 100); |
||
3799 | fH2 = new TGHorizontalFrame(fH1, subgroup[0], 100); |
||
3800 | lab = new TGLabel(fH2, "Export selected histograms:"); |
||
3801 | fH2->AddFrame(lab, f0centery); |
||
3802 | |||
3803 | exportHist = new TGTextButton(fH2, "Export"); |
||
3804 | exportHist->SetTextJustify(36); |
||
3805 | exportHist->SetWrapLength(-1); |
||
3806 | exportHist->Resize(80,22); |
||
3807 | fH2->AddFrame(exportHist, f0centery); |
||
3808 | fH1->AddFrame(fH2, f0centerx); |
||
3809 | fG1->AddFrame(fH1, f2); |
||
3810 | mdiFrame->AddFrame(fG1, f2); |
||
3811 | |||
3812 | // Fitting controls for ADC spectrum |
||
3813 | fG1 = new TGGroupFrame(mdiFrame, "Fit Settings"); |
||
3814 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3815 | lab = new TGLabel(fH1, "Peak sigma:"); |
||
3816 | fH1->AddFrame(lab, f0centery); |
||
3817 | fitSigma = new TGNumberEntry(fH1, 1.5, 3, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEANonNegative); |
||
3818 | fitSigma->Resize(60,22); |
||
3819 | fH1->AddFrame(fitSigma, f0centery); |
||
3820 | fG1->AddFrame(fH1, f2); |
||
3821 | |||
3822 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3823 | lab = new TGLabel(fH1, "Signal/Noise treshold:"); |
||
3824 | fH1->AddFrame(lab, f0centery); |
||
3825 | fitTresh = new TGNumberEntry(fH1, 5.0E-3, 3, 999, TGNumberFormat::kNESReal, TGNumberFormat::kNEANonNegative); |
||
3826 | fitTresh->Resize(60,22); |
||
3827 | fH1->AddFrame(fitTresh, f0centery); |
||
3828 | fG1->AddFrame(fH1, f2); |
||
3829 | |||
3830 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3831 | lab = new TGLabel(fH1, "Background interpolation:"); |
||
3832 | fH1->AddFrame(lab, f0centery); |
||
3833 | fitInter = new TGNumberEntry(fH1, 8, 3, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); |
||
3834 | fitInter->Resize(60,22); |
||
3835 | fH1->AddFrame(fitInter, f0centery); |
||
3836 | fG1->AddFrame(fH1, f2); |
||
3837 | |||
3838 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
3839 | lab = new TGLabel(fH1, "Peak fit max. acceptable error:"); |
||
3840 | fH1->AddFrame(lab, f0centery); |
||
3841 | accError = new TGNumberEntry(fH1, 0.15, 3, 999, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative); |
||
3842 | accError->Resize(60,22); |
||
3843 | fH1->AddFrame(accError, f0centery); |
||
3844 | fG1->AddFrame(fH1, f2); |
||
3845 | |||
3846 | exfitplots = new TGCheckButton(fG1, "Export fitting plots ON/OFF"); |
||
3847 | exfitplots->Resize(50,22); |
||
3848 | exfitplots->SetState(kButtonDown); |
||
3849 | fG1->AddFrame(exfitplots, f0centerx); |
||
3850 | mdiFrame->AddFrame(fG1, f2); |
||
3851 | |||
3852 | mdiFrame->SetMdiHints(kMdiMinimize); |
||
3853 | mdiFrame->SetWindowName("Histogram controls"); |
||
3854 | mdiFrame->MapSubwindows(); |
||
3855 | mdiFrame->Layout(); |
||
3856 | mdiFrame->Move(4*((winWidth/6)-5)+10,(int)(2.5*((winHeight/5)-5))); |
||
3857 | // Histogram controls pane ----------------------------------------------------------------- |
||
3858 | |||
3859 | // Action connections |
||
3860 | voltscanOn->Connect("Clicked()", "TGAppMainFrame", this, "EnableVoltScan()"); |
||
3861 | surfscanOn->Connect("Clicked()", "TGAppMainFrame", this, "EnableSurfScan()"); |
||
3862 | zscanOn->Connect("Clicked()", "TGAppMainFrame", this, "EnableZaxisScan()"); |
||
3863 | // histogramOn->Connect("Clicked()", "TGAppMainFrame", this, "HistogramToggle()"); |
||
3864 | vHardlimit->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "VoltageLimit()"); |
||
3865 | (vHardlimit->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "VoltageLimit()"); |
||
3866 | NCH->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "ChannelLimit()"); |
||
3867 | (NCH->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "ChannelLimit()"); |
||
3868 | cleanOn->Connect("Clicked()", "TGAppMainFrame", this, "CleanPlotToggle()"); |
||
3869 | oscConnect->Connect("Clicked()", "TGAppMainFrame", this, "ConnectToScope()"); |
||
3870 | vOutSet->Connect("Clicked()", "TGAppMainFrame", this, "SetVoltOut()"); |
||
3871 | vOutGet->Connect("Clicked()", "TGAppMainFrame", this, "GetVoltOut()"); |
||
3872 | vOutReset->Connect("Clicked()", "TGAppMainFrame", this, "ResetVoltOut()"); |
||
3873 | positionSet->Connect("Clicked()", "TGAppMainFrame", this, "SetPosition()"); |
||
3874 | positionGet->Connect("Clicked()", "TGAppMainFrame", this, "GetPosition()"); |
||
3875 | positionHome->Connect("Clicked()", "TGAppMainFrame", this, "HomePosition()"); |
||
3876 | saveFile->Connect("Clicked()", "TGAppMainFrame", this, "SaveFile()"); |
||
3877 | measStart->Connect("Clicked()", "TGAppMainFrame", this, "StartAcq()"); |
||
3878 | selectDir->Connect("Clicked()", "TGAppMainFrame", this, "SelectDirectory()"); |
||
3879 | multiSelect->Connect("Clicked()", "TGAppMainFrame", this, "ListMultiSelect()"); |
||
3880 | multiSelectAll->Connect("Clicked()", "TGAppMainFrame", this, "ListSelectAll()"); |
||
3881 | prevFile->Connect("Clicked()", "TGAppMainFrame", this, "FileListNavigation(=-2)"); |
||
3882 | nextFile->Connect("Clicked()", "TGAppMainFrame", this, "FileListNavigation(=-3)"); |
||
3883 | fileList->Connect("DoubleClicked(Int_t)", "TGAppMainFrame", this, "FileListNavigation(Int_t)"); |
||
3884 | clearList->Connect("Clicked()", "TGListBox", fileList, "RemoveAll()"); |
||
3885 | |||
3886 | adcMinRange->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "SetHistRange()"); |
||
3887 | (adcMinRange->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "SetHistRange()"); |
||
3888 | adcMaxRange->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "SetHistRange()"); |
||
3889 | (adcMaxRange->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "SetHistRange()"); |
||
3890 | yMinRange->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "SetHistRange()"); |
||
3891 | (yMinRange->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "SetHistRange()"); |
||
3892 | yMaxRange->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "SetHistRange()"); |
||
3893 | (yMaxRange->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "SetHistRange()"); |
||
3894 | tdcMinwindow->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "SetHistRange()"); |
||
3895 | (tdcMinwindow->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "SetHistRange()"); |
||
3896 | tdcMaxwindow->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "SetHistRange()"); |
||
3897 | (tdcMaxwindow->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "SetHistRange()"); |
||
3898 | changeADC->Connect("Clicked()", "TGAppMainFrame", this, "ChangeHisttype(=0)"); |
||
3899 | changeTDC->Connect("Clicked()", "TGAppMainFrame", this, "ChangeHisttype(=1)"); |
||
3900 | changeADCTDC->Connect("Clicked()", "TGAppMainFrame", this, "ChangeHisttype(=2)"); |
||
3901 | change2Dsurf->Connect("Clicked()", "TGAppMainFrame", this, "ChangeHisttype(=3)"); |
||
3902 | selectCh->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "ChangeChannel()"); |
||
3903 | (selectCh->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "ChangeChannel()"); |
||
3904 | logscale->Connect("Clicked()", "TGAppMainFrame", this, "SetHistRange()"); |
||
3905 | exportHist->Connect("Clicked()", "TGAppMainFrame", this, "HistogramExport()"); |
||
3906 | |||
127 | f9daq | 3907 | scopeInit->Connect("Clicked()", "TGAppMainFrame", this, "InitializeScope()"); |
3908 | sendScopeCustom->Connect("Clicked()", "TGAppMainFrame", this, "CustomScopeCommand()"); |
||
3909 | sMeasType->Connect("Selected(Int_t)", "TGAppMainFrame", this, "SelectedMeasType(Int_t)"); |
||
3910 | |||
117 | f9daq | 3911 | started = kFALSE; |
127 | f9daq | 3912 | |
3913 | for(int i = 0; i < 8; i++) sCH[i]->SetEnabled(kFALSE); |
||
3914 | sMeasType->SetEnabled(kFALSE); |
||
3915 | sCamaclink->SetEnabled(kFALSE); |
||
3916 | scopeCommand->SetEnabled(kFALSE); |
||
3917 | sendScopeCustom->SetEnabled(kFALSE); |
||
3918 | sMeasgroup->SetEnabled(kFALSE); |
||
3919 | scopeInit->SetEnabled(kFALSE); |
||
3920 | |||
117 | f9daq | 3921 | EnableVoltScan(); |
3922 | EnableSurfScan(); |
||
3923 | EnableZaxisScan(); |
||
127 | f9daq | 3924 | |
3925 | // Testing canvas for scope waveforms |
||
3926 | wCanvas = new TCanvas("wCanvas", "Waveform canvas", 600, 300); |
||
117 | f9daq | 3927 | } |
3928 | |||
3929 | //--------------------------------------------------------------- |
||
3930 | // Closing the main application window and checking the about information |
||
3931 | |||
3932 | void TGAppMainFrame::CloseWindow() |
||
3933 | { |
||
3934 | gApplication->Terminate(0); |
||
3935 | } |
||
3936 | |||
3937 | Bool_t TGAppMainFrame::About() |
||
3938 | { |
||
3939 | int ret = 0; |
||
3940 | |||
3941 | new TGMsgBox(gClient->GetRoot(), fMain, |
||
3942 | fMain->GetWindowName(), "This is an application.", |
||
3943 | kMBIconQuestion, kMBClose, &ret); |
||
3944 | |||
3945 | if(debug == 1) |
||
3946 | if(ret == kMBClose) |
||
3947 | printf("Closing the About window (%d).\n", ret); |
||
3948 | |||
3949 | return kFALSE; |
||
3950 | } |
||
3951 | |||
3952 | //--------------------------------------------------------------- |
||
3953 | // Subwindow constructor definition (& layout) and close subwindow action |
||
3954 | |||
3955 | TGMdiSubwindow::TGMdiSubwindow(TGMdiMainFrame *main, int w, int h) |
||
3956 | { |
||
3957 | // Create a new subwindow |
||
3958 | fMdiFrame = new TGMdiFrame(main, w, h); |
||
3959 | fMdiFrame->Connect("CloseWindow()", "TGMdiSubwindow", this, "CloseWindow()"); // setting here to =0 -> will always ask before closing window |
||
3960 | fMdiFrame->DontCallClose(); // only let this window close if Yes is pressed when closing window |
||
3961 | |||
3962 | } |
||
3963 | |||
3964 | Bool_t TGMdiSubwindow::CloseWindow() |
||
3965 | { |
||
3966 | int ret = 0; |
||
3967 | |||
3968 | // if(noq == 0) |
||
3969 | // { |
||
3970 | new TGMsgBox(gClient->GetRoot(), fMdiFrame, |
||
3971 | fMdiFrame->GetWindowName(), "Really want to close the window?", |
||
3972 | kMBIconExclamation, kMBYes | kMBNo, &ret); |
||
3973 | if (ret == kMBYes) return fMdiFrame->CloseWindow(); |
||
3974 | |||
3975 | return kFALSE; |
||
3976 | // } |
||
3977 | // else |
||
3978 | // return fMdiFrame->CloseWindow(); |
||
3979 | } |
||
3980 | |||
3981 | //--------------------------------------------------------------- |
||
3982 | // Main function |
||
3983 | |||
3984 | void windowed_test() |
||
3985 | { |
||
3986 | new TGAppMainFrame(gClient->GetRoot(), winWidth, winHeight); |
||
3987 | } |
||
3988 | |||
3989 | //#ifdef STANDALONE |
||
3990 | int main(int argc, char **argv) |
||
3991 | { |
||
3992 | TApplication theApp("MdiTest", &argc, argv); |
||
3993 | |||
3994 | windowed_test(); |
||
3995 | |||
3996 | theApp.Run(); |
||
3997 | |||
3998 | return 0; |
||
3999 | } |
||
4000 | //#endif |