Rev 128 | 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 <unistd.h> |
||
9 | |||
10 | #include "daqscope.h" |
||
11 | |||
12 | //--------------------------------------------------------------- |
||
13 | // Subwindow layout class |
||
14 | |||
15 | class TGMdiSubwindow |
||
16 | { |
||
17 | RQ_OBJECT("TGMdiSubwindow") |
||
18 | |||
19 | protected: |
||
20 | TGMdiFrame *fMdiFrame; |
||
21 | |||
22 | public: |
||
23 | TGMdiSubwindow(TGMdiMainFrame *main, int w, int h); |
||
24 | |||
25 | TGMdiFrame *GetMdiFrame() const { return fMdiFrame; } |
||
26 | virtual Bool_t CloseWindow(); |
||
27 | }; |
||
28 | |||
29 | //--------------------------------------------------------------- |
||
30 | // Main window class |
||
31 | |||
32 | class TGAppMainFrame |
||
33 | { |
||
34 | RQ_OBJECT("TGAppMainFrame") |
||
35 | |||
36 | protected: |
||
37 | TGMainFrame *fMain; |
||
38 | TGMdiMainFrame *fMainFrame; |
||
39 | TGMdiMenuBar *fMenuBar; |
||
40 | TGLayoutHints *fMenuBarItemLayout; |
||
128 | f9daq | 41 | TGPopupMenu *fMenuFile, *fMenuAnalysis, *fMenuTools, *fMenuWindow, *fMenuHelp; |
117 | f9daq | 42 | TGPopupMenu *fMenuHisttype; |
129 | f9daq | 43 | TGMdiSubwindow *settingsPane, *mainSubwindow, *histogramPane, *histogramPaneFile, *histogramPaneCtr, *fieldpointPane, *headerPane; |
117 | f9daq | 44 | |
45 | void InitMenu(); |
||
46 | void MeasurementLayout(); |
||
128 | f9daq | 47 | void OpenWindow(int winid); |
117 | f9daq | 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); |
||
129 | f9daq | 82 | void HeaderEdit(); |
117 | f9daq | 83 | |
84 | void DisplayHistogram(char *histfile, int histtype); |
||
85 | void SetHistRange(); |
||
86 | void ChangeHisttype(int type); |
||
87 | void ChangeChannel(); |
||
88 | void HistogramExport(); |
||
89 | void MakeSurfPlot(TList *files); |
||
129 | f9daq | 90 | void MakeBreakdownPlot(int nrp, double *volt, double *volterr, double *psep1, double *pseperr1, double *psep2, double *pseperr2, double *psep3, double *pseperr3, char *plotfile, int separations); |
117 | f9daq | 91 | |
92 | void FitSpectrum(TList *files, int q); |
||
93 | void EdgeDetection(TGraph *pdf, TGraph *cdf, char *outname, TCanvas *g1dCanvas, double pdfmax, int direction); |
||
94 | void IntegSpectrum(TList *files, int direction); |
||
128 | f9daq | 95 | void PhotonMu(TList *files); |
117 | f9daq | 96 | |
128 | f9daq | 97 | void UpdateTempPlot(); |
98 | void TempEndToggle(); |
||
99 | void ExportTempPlot(); |
||
100 | void GetTempFile(int set); |
||
101 | |||
129 | f9daq | 102 | void EditTickToggle(int set); |
103 | void headerchange(char *histfile, bool *changetype); |
||
104 | void headeredit(); |
||
105 | |||
106 | void RunMeas(void *ptr, int runCase, int zaxisscan, int &scanon); |
||
117 | f9daq | 107 | }; |
108 | |||
109 | const char *histExt = ".root"; |
||
110 | const char *histExtAll = "*.root"; |
||
111 | daq *gDaq; |
||
112 | daqscope *gScopeDaq; |
||
128 | f9daq | 113 | //int debugSig = 0; |
117 | f9daq | 114 | int retTemp; |
115 | int gStop=0; |
||
116 | unsigned int gBuf[BSIZE]; |
||
117 | int logchange = 0; |
||
118 | double tdctimeconversion = 45.0909; |
||
119 | double lenconversion = 0.3595; |
||
120 | int oscOn; |
||
127 | f9daq | 121 | const char *allMeasNames[11] = {"Amplitude","Area","Delay","Fall","Frequency","Maximum","Mean","Minimum","Peak-to-peak","Peak width","Rise"}; |
117 | f9daq | 122 | |
123 | // ROOT file variable structure ----------- |
||
124 | struct EventHeader { |
||
125 | int nrch; |
||
126 | int timestamp; |
||
127 | double biasvolt; |
||
128 | int xpos; |
||
129 | int ypos; |
||
130 | int zpos; |
||
131 | double temperature; |
||
128 | f9daq | 132 | double angle; |
117 | f9daq | 133 | char laserinfo[256]; |
134 | } evtheader; |
||
135 | |||
136 | struct EventData { |
||
137 | int adcdata[8]; |
||
138 | int tdcdata[8]; |
||
139 | } evtdata; |
||
140 | |||
127 | f9daq | 141 | struct EventMeas { |
142 | double measdata; |
||
143 | } evtmeas; |
||
144 | |||
117 | f9daq | 145 | TFile *inroot; |
146 | TFile *outroot; |
||
147 | |||
127 | f9daq | 148 | // Test graphs for scope measurements |
149 | TCanvas *wCanvas; |
||
150 | TGraph *testgraph; |
||
151 | |||
117 | f9daq | 152 | //--------------------------------------------------------------- |
153 | // Global variables |
||
154 | |||
155 | TGCheckButton *voltscanOn; |
||
156 | TGCheckButton *surfscanOn; |
||
157 | TGCheckButton *zscanOn; |
||
158 | TGTextEntry *oscIP; |
||
159 | TGTextButton *oscConnect; |
||
160 | TGCheckButton *histogramOn; |
||
161 | TGNumberEntry *vHardlimit; |
||
162 | TGNumberEntry *NCH; |
||
163 | TGTextEntry *laserInfo; |
||
127 | f9daq | 164 | TGNumberEntry *chtemp; |
128 | f9daq | 165 | TGNumberEntry *incangle; |
117 | f9daq | 166 | TGCheckButton *cleanOn; |
167 | |||
168 | TGTab *setTab; |
||
169 | TGComboBox *vOutCh; |
||
170 | TGNumberEntry *vOut; |
||
171 | TGCheckButton *vOutOnOff; |
||
172 | TGTextButton *vOutSet; |
||
173 | TGTextButton *vOutGet; |
||
174 | TGTextButton *vOutReset; |
||
175 | TGNumberEntry *vOutStart; |
||
176 | TGNumberEntry *vOutStop; |
||
177 | TGNumberEntry *vOutStep; |
||
178 | TGNumberEntry *xPos; |
||
179 | TGNumberEntry *yPos; |
||
180 | TGNumberEntry *zPos; |
||
181 | TGTextButton *positionSet; |
||
182 | TGTextButton *positionGet; |
||
183 | TGTextButton *positionHome; |
||
184 | TGNumberEntry *xPosMin; |
||
185 | TGNumberEntry *xPosMax; |
||
186 | TGNumberEntry *xPosStep; |
||
187 | TGNumberEntry *yPosMin; |
||
188 | TGNumberEntry *yPosMax; |
||
189 | TGNumberEntry *yPosStep; |
||
190 | TGNumberEntry *zPosMin; |
||
191 | TGNumberEntry *zPosMax; |
||
192 | TGNumberEntry *zPosStep; |
||
193 | TGNumberEntry *evtNum; |
||
194 | TGTextEntry *timeStamp; |
||
195 | TGTextEntry *fileName; |
||
196 | TGTextButton *saveFile; |
||
197 | TGTextButton *measStart; |
||
198 | TGLabel *busyLabel; |
||
199 | TGHProgressBar *curProgress; |
||
200 | |||
201 | TRootEmbeddedCanvas *histCanvas; |
||
202 | |||
203 | TGTextButton *selectDir; |
||
204 | TGListBox *fileList; |
||
205 | TGCheckButton *multiSelect; |
||
206 | TGCheckButton *multiSelectAll; |
||
207 | TGTextButton *prevFile; |
||
208 | TGTextButton *nextFile; |
||
129 | f9daq | 209 | TGTextButton *editHeader; |
117 | f9daq | 210 | |
128 | f9daq | 211 | TGTextEntry *disptime; |
212 | TGNumberEntry *dispbias; |
||
213 | TGTextEntry *disppos; |
||
214 | TGNumberEntry *disptemp; |
||
215 | TGNumberEntry *dispangle; |
||
216 | TGTextEntry *displaser; |
||
217 | |||
117 | f9daq | 218 | TGNumberEntry *adcMinRange; |
219 | TGNumberEntry *adcMaxRange; |
||
220 | TGNumberEntry *tdcMinwindow; |
||
221 | TGNumberEntry *tdcMaxwindow; |
||
222 | TGNumberEntry *yMinRange; |
||
223 | TGNumberEntry *yMaxRange; |
||
224 | TGNumberEntry *selectCh; |
||
225 | TGTextButton *changeADC; |
||
226 | TGTextButton *changeTDC; |
||
227 | TGTextButton *changeADCTDC; |
||
228 | TGTextButton *change2Dsurf; |
||
229 | TGCheckButton *logscale; |
||
230 | TGTextButton *exportHist; |
||
231 | TGNumberEntry *fitSigma; |
||
232 | TGNumberEntry *fitTresh; |
||
233 | TGNumberEntry *fitInter; |
||
234 | TGNumberEntry *accError; |
||
129 | f9daq | 235 | TGNumberEntry *minPeak; |
236 | TGNumberEntry *pedesLow; |
||
117 | f9daq | 237 | TGCheckButton *exfitplots; |
238 | |||
127 | f9daq | 239 | TGCheckButton *sCH[8]; |
240 | TGComboBox *sMeasType; |
||
241 | TGCheckButton *sCamaclink; |
||
242 | TGTextEntry *scopeCommand; |
||
243 | TGTextEntry *scopeReturn; |
||
244 | TGTextButton *sendScopeCustom; |
||
245 | TGComboBox *sMeasgroup; |
||
246 | TGTextButton *scopeInit; |
||
247 | |||
128 | f9daq | 248 | TRootEmbeddedCanvas *displayCanvas; |
249 | TGComboBox *tempCh; |
||
250 | TGComboBox *tempDay[2]; |
||
251 | TGComboBox *tempMonth[2]; |
||
252 | TGComboBox *tempYear[2]; |
||
253 | TGComboBox *tempHour[2]; |
||
254 | TGComboBox *tempMinute[2]; |
||
255 | TGComboBox *tempSecond[2]; |
||
256 | TGTextButton *tempFile[2]; |
||
257 | TGCheckButton *tempEndOn; |
||
258 | TGTextButton *updateTemp; |
||
259 | TGTextButton *exportTemp; |
||
260 | //TGTextButton *closeTemp; |
||
261 | |||
129 | f9daq | 262 | TGCheckButton *biasedittick; |
263 | TGNumberEntry *biasedit; |
||
264 | TGCheckButton *posedittick; |
||
265 | TGNumberEntry *posedit[3]; |
||
266 | TGCheckButton *tempedittick; |
||
267 | TGNumberEntry *tempedit; |
||
268 | TGCheckButton *angleedittick; |
||
269 | TGNumberEntry *angleedit; |
||
270 | TGCheckButton *laseredittick; |
||
271 | TGTextEntry *laseredit; |
||
272 | TGTextButton *editHead; |
||
273 | |||
117 | f9daq | 274 | Bool_t firstrun = kTRUE; |
275 | Bool_t started; |
||
276 | Bool_t cleanPlots = kTRUE; |
||
277 | |||
278 | // Layout hints definitions |
||
279 | TGLayoutHints *f0 = new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,2,2); |
||
280 | TGLayoutHints *f0centerx = new TGLayoutHints(kLHintsCenterX,2,2,2,2); |
||
281 | TGLayoutHints *f0centery = new TGLayoutHints(kLHintsLeft | kLHintsCenterY,2,2,2,2); |
||
282 | TGLayoutHints *f0center2d = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,2,2,2,2); |
||
283 | TGLayoutHints *f0right = new TGLayoutHints(kLHintsRight | kLHintsTop,2,2,2,2); |
||
284 | TGLayoutHints *f1 = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY,2,2,2,2); |
||
285 | TGLayoutHints *f2 = new TGLayoutHints(kLHintsExpandX,2,2,2,2); |
||
286 | TGLayoutHints *f3 = new TGLayoutHints(kLHintsCenterY,2,2,20,2); |
||
287 | TGLayoutHints *f3notop = new TGLayoutHints(kLHintsCenterY,4,4,2,30); |
||
288 | |||
289 | // Separate functions ----------------------------------------- |
||
290 | void GetTime(int intime, char *outtime) |
||
291 | { |
||
292 | time_t rawtime; |
||
293 | struct tm * timeinfo; |
||
294 | if(intime < 0) |
||
295 | time(&rawtime); |
||
296 | else |
||
297 | rawtime = (time_t)intime; |
||
298 | timeinfo = localtime(&rawtime); |
||
299 | sprintf(outtime, "%s", asctime(timeinfo)); |
||
300 | int len = strlen(outtime); |
||
301 | if(len) outtime[len-1] = 0; |
||
302 | } |
||
303 | |||
304 | int MyTimer() |
||
305 | { |
||
306 | char cmd[100]; |
||
307 | GetTime(-1, cmd); |
||
308 | if (timeStamp) timeStamp->SetText(cmd); |
||
309 | return 0; |
||
310 | } |
||
311 | |||
312 | int GetChannel() |
||
313 | { |
||
314 | int selectedOutput; |
||
315 | if(vOutCh->GetSelected() < 8) selectedOutput = (vOutCh->GetSelected())+1; |
||
316 | else if( (vOutCh->GetSelected() >= 8) && (vOutCh->GetSelected() < 16) ) selectedOutput = (vOutCh->GetSelected())+93; |
||
317 | else selectedOutput = 1; |
||
318 | |||
319 | return selectedOutput; |
||
320 | } |
||
321 | |||
322 | void remove_ext(char *inname, char *outname) |
||
323 | { |
||
324 | char ctemp[256]; |
||
325 | for(int i = 0; i < (int)strlen(inname); i++) |
||
326 | { |
||
327 | if( (inname[i] == '.') && (i > (int)(strlen(inname)-6)) ) |
||
328 | { |
||
329 | ctemp[i] = '\0'; |
||
330 | sprintf(outname, "%s", ctemp); |
||
331 | break; |
||
332 | } |
||
333 | else |
||
334 | ctemp[i] = inname[i]; |
||
335 | } |
||
336 | |||
128 | f9daq | 337 | if(debug) |
117 | f9daq | 338 | printf("Outfile (remove_ext): %s\n", outname); |
339 | } |
||
340 | |||
341 | void remove_from_last(char *inname, char search, char *outname) |
||
342 | { |
||
343 | char ctemp[256]; |
||
344 | int searchpos = -1; |
||
345 | for(int i = (int)strlen(inname); i >= 0; i--) |
||
346 | { |
||
347 | if(inname[i] == search) |
||
348 | { |
||
349 | searchpos = i; |
||
350 | break; |
||
351 | } |
||
352 | } |
||
353 | |||
354 | for(int i = 0; i < searchpos; i++) |
||
355 | ctemp[i] = inname[i]; |
||
356 | |||
357 | ctemp[searchpos] = '\0'; |
||
358 | sprintf(outname, "%s", ctemp); |
||
359 | |||
128 | f9daq | 360 | if(debug) |
117 | f9daq | 361 | printf("Outfile (remove_from_last): %s\n", outname); |
362 | } |
||
363 | |||
127 | f9daq | 364 | void SeqNumber(int innum, int maxnum, char *outstr) |
365 | { |
||
366 | int zeronum = 5; |
||
367 | |||
368 | // Check how many zeroes we need to add to get sequential numbers |
||
369 | if( (maxnum > 0) && (maxnum < 1000) ) |
||
370 | zeronum = 2; |
||
371 | else if( (maxnum >= 1000) && (maxnum < 10000) ) |
||
372 | zeronum = 3; |
||
373 | else if( (maxnum >= 10000) && (maxnum < 100000) ) |
||
374 | zeronum = 4; |
||
375 | else if( (maxnum >= 100000) && (maxnum < 1000000) ) |
||
376 | zeronum = 5; |
||
377 | |||
378 | // Make the sequence number depending on the number of zeroes |
||
379 | if(zeronum == 2) |
||
380 | { |
||
381 | if(innum < 10) |
||
382 | sprintf(outstr, "00%d", innum); |
||
383 | else if( (innum >= 10) && (innum < 100) ) |
||
384 | sprintf(outstr, "0%d", innum); |
||
385 | else if( (innum >= 100) && (innum < 1000) ) |
||
386 | sprintf(outstr, "%d", innum); |
||
387 | } |
||
388 | else if(zeronum == 3) |
||
389 | { |
||
390 | if(innum < 10) |
||
391 | sprintf(outstr, "000%d", innum); |
||
392 | else if( (innum >= 10) && (innum < 100) ) |
||
393 | sprintf(outstr, "00%d", innum); |
||
394 | else if( (innum >= 100) && (innum < 1000) ) |
||
395 | sprintf(outstr, "0%d", innum); |
||
396 | else if( (innum >= 1000) && (innum < 10000) ) |
||
397 | sprintf(outstr, "%d", innum); |
||
398 | } |
||
399 | else if(zeronum == 4) |
||
400 | { |
||
401 | if(innum < 10) |
||
402 | sprintf(outstr, "0000%d", innum); |
||
403 | else if( (innum >= 10) && (innum < 100) ) |
||
404 | sprintf(outstr, "000%d", innum); |
||
405 | else if( (innum >= 100) && (innum < 1000) ) |
||
406 | sprintf(outstr, "00%d", innum); |
||
407 | else if( (innum >= 1000) && (innum < 10000) ) |
||
408 | sprintf(outstr, "0%d", innum); |
||
409 | else if( (innum >= 10000) && (innum < 100000) ) |
||
410 | sprintf(outstr, "%d", innum); |
||
411 | } |
||
412 | else if(zeronum == 5) |
||
413 | { |
||
414 | if(innum < 10) |
||
415 | sprintf(outstr, "00000%d", innum); |
||
416 | else if( (innum >= 10) && (innum < 100) ) |
||
417 | sprintf(outstr, "0000%d", innum); |
||
418 | else if( (innum >= 100) && (innum < 1000) ) |
||
419 | sprintf(outstr, "000%d", innum); |
||
420 | else if( (innum >= 1000) && (innum < 10000) ) |
||
421 | sprintf(outstr, "00%d", innum); |
||
422 | else if( (innum >= 10000) && (innum < 100000) ) |
||
423 | sprintf(outstr, "0%d", innum); |
||
424 | else if( (innum >= 100000) && (innum < 1000000) ) |
||
425 | sprintf(outstr, "%d", innum); |
||
426 | } |
||
427 | } |
||
428 | |||
117 | f9daq | 429 | // Peak detection function |
430 | int npeaks; |
||
431 | double FindPeaks(double *x, double *par) |
||
432 | { |
||
433 | double result = 0; |
||
434 | for(int i = 0; i < npeaks; i++) |
||
435 | { |
||
436 | double norm = par[3*i]; |
||
437 | double mean = par[3*i+1]; |
||
438 | double sigma = par[3*i+2]; |
||
439 | result += norm*TMath::Gaus(x[0], mean, sigma); |
||
440 | } |
||
441 | return result; |
||
442 | } |
||
443 | |||
128 | f9daq | 444 | // Temperature sensor functions ----------------------------- |
445 | const char* dbname = "mysql://f9lab08.ijs.si/f9phdet"; |
||
446 | const char* tblname = "fprtd122"; |
||
447 | const char* username = "f9daq"; |
||
448 | const char* userpass = "f9lab"; |
||
449 | |||
450 | // Get the temperature from MYSQL database |
||
451 | double GetTemperature(int ch, const char *s) |
||
452 | { |
||
453 | int bin=5+7*4-ch*4; |
||
454 | char hex[16]; |
||
455 | strncpy(hex, (const char *) &s[bin], 4); |
||
456 | hex[4]=0; |
||
457 | int ix; |
||
458 | sscanf (hex,"%x",&ix); |
||
459 | //printf("0x%s\t",hex); |
||
460 | return (ix/65535.)*1050.-200.; |
||
461 | } |
||
462 | |||
463 | // Transform local time to timestamp |
||
464 | int GetTimeStamp(int *intime) |
||
465 | { |
||
466 | time_t rawtime; |
||
467 | struct tm * timeinfo; |
||
468 | time(&rawtime); |
||
469 | timeinfo = localtime(&rawtime); |
||
470 | |||
471 | printf("%d.%d.%d, %d:%d:%d\n", intime[0], intime[1], intime[2], intime[3], intime[4], intime[5]); |
||
472 | |||
473 | timeinfo->tm_mday = intime[0]; |
||
474 | timeinfo->tm_mon = intime[1] - 1; |
||
475 | timeinfo->tm_year = intime[2] - 1900; |
||
476 | timeinfo->tm_hour = intime[3]; |
||
477 | timeinfo->tm_min = intime[4]; |
||
478 | timeinfo->tm_sec = intime[5]; |
||
479 | |||
480 | return (int)mktime(timeinfo); |
||
481 | } |
||
482 | |||
483 | // Get data from MYSQL database |
||
484 | void fieldpoint(int *timerange, int selch) |
||
485 | { |
||
486 | char humantime[256]; |
||
487 | |||
488 | // Display selected timestamps |
||
489 | GetTime(timerange[0], humantime); |
||
490 | printf("Minimum time set to: %s (%d)\n", humantime, timerange[0]); |
||
491 | if(timerange[1] != -1) |
||
492 | { |
||
493 | GetTime(timerange[1], humantime); |
||
494 | printf("Maximum time set to: %s (%d)\n", humantime, timerange[1]); |
||
495 | } |
||
496 | printf("Selected fieldpoint channel: %d\n", selch); |
||
497 | printf("\n"); |
||
498 | |||
499 | // Database settings |
||
500 | TSQLServer *db = TSQLServer::Connect(dbname, username, userpass); |
||
501 | printf("Server info: %s\n", db->ServerInfo()); |
||
502 | TSQLRow *row; |
||
503 | TSQLResult *res; |
||
504 | |||
505 | // list databases available on server |
||
506 | printf("\nList all databases on server %s\n", db->GetHost()); |
||
507 | res = db->GetDataBases(); |
||
508 | while ((row = res->Next())) { |
||
509 | printf("%s\n", row->GetField(0)); |
||
510 | delete row; |
||
511 | } |
||
512 | delete res; |
||
513 | |||
514 | // list tables in database "test" (the permission tables) |
||
515 | printf("\nList all tables in database \"f9phdet\" on server %s\n", db->GetHost()); |
||
516 | res = db->GetTables("f9phdet"); |
||
517 | while ((row = res->Next())) { |
||
518 | printf("%s\n", row->GetField(0)); |
||
519 | delete row; |
||
520 | } |
||
521 | delete res; |
||
522 | |||
523 | // list columns in table "runcatalog" in database "mysql" |
||
524 | printf("\nList all columns in table \"f9phdet\" in database \"f9rtd122\" on server %s\n", db->GetHost()); |
||
525 | res = db->GetColumns("f9phdet", "fprtd122"); |
||
526 | while ((row = res->Next())) { |
||
527 | printf("%s\n", row->GetField(0)); |
||
528 | delete row; |
||
529 | } |
||
530 | delete res; |
||
531 | |||
532 | // query database and print results |
||
533 | char sql[1000] = "SELECT status,data,timestamp FROM fprtd122 WHERE status='A272727272727272748' AND substring(data,1,4)='A00C' "; |
||
534 | if(timerange[1] == -1) |
||
535 | sprintf(sql,"%s AND timestamp>='%d'", sql, timerange[0]); |
||
536 | else |
||
537 | sprintf(sql,"%s AND timestamp>='%d' AND timestamp<='%d'", sql, timerange[0], timerange[1]); |
||
538 | printf("%s\n",sql); |
||
539 | |||
540 | res = db->Query(sql); |
||
541 | |||
542 | int nrows = res->GetRowCount(); |
||
543 | printf("\nGot %d rows in result\n", nrows); |
||
544 | |||
545 | // Printing and plotting |
||
546 | char timeval[256]; |
||
547 | TGraph *gr; |
||
548 | gr = new TGraph(nrows); |
||
549 | gr->SetLineColor(kRed); |
||
550 | gr->SetLineWidth(1); |
||
551 | gr->SetMarkerColor(kRed); |
||
552 | gr->SetMarkerStyle(20); |
||
553 | gr->SetTitle("Temperature sensor;Time;Temperature (deg.)"); |
||
554 | |||
555 | FILE *fp; |
||
556 | fp = fopen("./fieldpoint/dataout_fieldpoint.txt", "w"); |
||
557 | |||
558 | if(debug) |
||
559 | printf("Time\tTemperature\n"); |
||
560 | for (int i = 0; i < nrows; i++) { |
||
561 | row = res->Next(); |
||
562 | |||
563 | GetTime((int)atof(row->GetField(2)), timeval); |
||
564 | double x = atof(row->GetField(2)); |
||
565 | double y = GetTemperature(selch,row->GetField(1)); |
||
566 | gr->SetPoint(i,x,y); |
||
567 | |||
568 | fprintf(fp, "%s\t%f\n",timeval,y); |
||
569 | |||
570 | if(debug) |
||
571 | printf("%s\t%f\n",timeval,y); |
||
572 | |||
573 | delete row; |
||
574 | } |
||
575 | |||
576 | fclose(fp); |
||
577 | |||
578 | delete res; |
||
579 | delete db; |
||
580 | |||
581 | TCanvas *gCanvas = displayCanvas->GetCanvas(); |
||
582 | gCanvas->SetGrid(); |
||
583 | gr->GetXaxis()->SetTimeDisplay(1); |
||
584 | gr->GetXaxis()->SetTimeFormat("%d.%m.%H:%M"); |
||
585 | gr->GetXaxis()->SetLabelSize(0.027); |
||
586 | gr->GetXaxis()->SetTitleSize(0.038); |
||
587 | gr->GetYaxis()->SetLabelSize(0.027); |
||
588 | gr->GetYaxis()->SetTitleSize(0.038); |
||
589 | gr->GetXaxis()->SetNdivisions(515,kTRUE); |
||
590 | gr->Draw("AL"); |
||
591 | |||
592 | gCanvas->Modified(); |
||
593 | gCanvas->Update(); |
||
594 | } |
||
595 | |||
596 | // Update the temperature plot |
||
597 | void TGAppMainFrame::UpdateTempPlot() |
||
598 | { |
||
599 | int stime[6]; |
||
600 | int etime[6]; |
||
601 | |||
602 | int timestamp[2]; |
||
603 | |||
604 | time_t rtime; |
||
605 | int curyear; |
||
606 | time(&rtime); |
||
607 | curyear = (int)(localtime(&rtime))->tm_year+1900; |
||
608 | |||
609 | int leapy = 0; |
||
610 | |||
611 | // Getting the start time |
||
612 | stime[0] = (int)(tempDay[0]->GetSelected())+1; |
||
613 | stime[2] = curyear - (int)(tempYear[0]->GetSelected()); |
||
614 | printf("%d, %d, %d\n", stime[2], curyear, (int)(tempYear[0]->GetSelected())); |
||
615 | stime[3] = (int)(tempHour[0]->GetSelected()); |
||
616 | stime[4] = (int)(tempMinute[0]->GetSelected()); |
||
617 | stime[5] = (int)(tempSecond[0]->GetSelected()); |
||
618 | |||
619 | switch( tempMonth[0]->GetSelected() ) |
||
620 | { |
||
621 | case 0: |
||
622 | stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
||
623 | break; |
||
624 | case 1: |
||
625 | if( stime[2]%4 == 0) |
||
626 | leapy = 1; |
||
627 | |||
628 | if( (leapy == 1) && (stime[0] > 29) ) |
||
629 | { |
||
630 | stime[0] = 29; |
||
631 | tempDay[0]->Select(28); |
||
632 | } |
||
633 | else if( (leapy == 0) && (stime[0] > 28) ) |
||
634 | { |
||
635 | stime[0] = 28; |
||
636 | tempDay[0]->Select(27); |
||
637 | } |
||
638 | stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
||
639 | break; |
||
640 | case 2: |
||
641 | stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
||
642 | break; |
||
643 | case 3: |
||
644 | if(stime[0] > 30) |
||
645 | { |
||
646 | stime[0] = 30; |
||
647 | tempDay[0]->Select(29); |
||
648 | } |
||
649 | stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
||
650 | break; |
||
651 | case 4: |
||
652 | stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
||
653 | break; |
||
654 | case 5: |
||
655 | if(stime[0] > 30) |
||
656 | { |
||
657 | stime[0] = 30; |
||
658 | tempDay[0]->Select(29); |
||
659 | } |
||
660 | stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
||
661 | break; |
||
662 | case 6: |
||
663 | stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
||
664 | break; |
||
665 | case 7: |
||
666 | stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
||
667 | break; |
||
668 | case 8: |
||
669 | if(stime[0] > 30) |
||
670 | { |
||
671 | stime[0] = 30; |
||
672 | tempDay[0]->Select(29); |
||
673 | } |
||
674 | stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
||
675 | break; |
||
676 | case 9: |
||
677 | stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
||
678 | break; |
||
679 | case 10: |
||
680 | if(stime[0] > 30) |
||
681 | { |
||
682 | stime[0] = 30; |
||
683 | tempDay[0]->Select(29); |
||
684 | } |
||
685 | stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
||
686 | break; |
||
687 | case 11: |
||
688 | stime[1] = (int)(tempMonth[0]->GetSelected())+1; |
||
689 | break; |
||
690 | default: |
||
691 | break; |
||
692 | } |
||
693 | |||
694 | timestamp[0] = GetTimeStamp(stime); |
||
695 | printf("Start time: %d\n", timestamp[0]); |
||
696 | |||
697 | // Getting the end time |
||
698 | etime[0] = (int)(tempDay[1]->GetSelected())+1; |
||
699 | etime[2] = curyear - (int)(tempYear[1]->GetSelected()); |
||
700 | etime[3] = (int)(tempHour[1]->GetSelected()); |
||
701 | etime[4] = (int)(tempMinute[1]->GetSelected()); |
||
702 | etime[5] = (int)(tempSecond[1]->GetSelected()); |
||
703 | |||
704 | switch( tempMonth[1]->GetSelected() ) |
||
705 | { |
||
706 | case 0: |
||
707 | etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
||
708 | break; |
||
709 | case 1: |
||
710 | if( etime[2]%4 == 0) |
||
711 | leapy = 1; |
||
712 | |||
713 | if( (leapy == 1) && (etime[0] > 29) ) |
||
714 | { |
||
715 | etime[0] = 29; |
||
716 | tempDay[1]->Select(28); |
||
717 | } |
||
718 | else if( (leapy == 0) && (etime[0] > 28) ) |
||
719 | { |
||
720 | etime[0] = 28; |
||
721 | tempDay[1]->Select(27); |
||
722 | } |
||
723 | etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
||
724 | break; |
||
725 | case 2: |
||
726 | etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
||
727 | break; |
||
728 | case 3: |
||
729 | if(etime[0] > 30) |
||
730 | { |
||
731 | etime[0] = 30; |
||
732 | tempDay[1]->Select(29); |
||
733 | } |
||
734 | etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
||
735 | break; |
||
736 | case 4: |
||
737 | etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
||
738 | break; |
||
739 | case 5: |
||
740 | if(etime[0] > 30) |
||
741 | { |
||
742 | etime[0] = 30; |
||
743 | tempDay[1]->Select(29); |
||
744 | } |
||
745 | etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
||
746 | break; |
||
747 | case 6: |
||
748 | etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
||
749 | break; |
||
750 | case 7: |
||
751 | etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
||
752 | break; |
||
753 | case 8: |
||
754 | if(etime[0] > 30) |
||
755 | { |
||
756 | etime[0] = 30; |
||
757 | tempDay[1]->Select(29); |
||
758 | } |
||
759 | etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
||
760 | break; |
||
761 | case 9: |
||
762 | etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
||
763 | break; |
||
764 | case 10: |
||
765 | if(etime[0] > 30) |
||
766 | { |
||
767 | etime[0] = 30; |
||
768 | tempDay[1]->Select(29); |
||
769 | } |
||
770 | etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
||
771 | break; |
||
772 | case 11: |
||
773 | etime[1] = (int)(tempMonth[1]->GetSelected())+1; |
||
774 | break; |
||
775 | default: |
||
776 | break; |
||
777 | } |
||
778 | |||
779 | if( tempEndOn->IsDown() ) |
||
780 | timestamp[1] = -1; |
||
781 | else |
||
782 | timestamp[1] = GetTimeStamp(etime); |
||
783 | printf("End time: %d\n", timestamp[1]); |
||
784 | |||
785 | fieldpoint(timestamp, tempCh->GetSelected()); |
||
786 | } |
||
787 | |||
788 | // Export the temperature plot to pdf |
||
789 | void TGAppMainFrame::ExportTempPlot() |
||
790 | { |
||
791 | TCanvas *gCanvas = displayCanvas->GetCanvas(); |
||
792 | gCanvas->Modified(); |
||
793 | gCanvas->Update(); |
||
794 | gCanvas->SaveAs("./fieldpoint/plotout_fieldpoint.pdf"); |
||
795 | } |
||
796 | |||
797 | // Get time information from a saved file |
||
798 | void TGAppMainFrame::GetTempFile(int set) |
||
799 | { |
||
800 | TGFileInfo file_info; |
||
801 | const char *filetypes[] = {"Histograms",histExtAll,0,0}; |
||
802 | file_info.fFileTypes = filetypes; |
||
803 | file_info.fIniDir = StrDup("./results"); |
||
804 | file_info.fMultipleSelection = kFALSE; |
||
805 | new TGFileDialog(gClient->GetDefaultRoot(), fMain, kFDOpen, &file_info); |
||
806 | int i = 0; |
||
807 | |||
808 | TTree *header_data; |
||
809 | time_t rtime, ctime; |
||
810 | struct tm * timeinfo; |
||
811 | |||
812 | int curyear; |
||
813 | time(&ctime); |
||
814 | curyear = (int)(localtime(&ctime))->tm_year+1900; |
||
815 | |||
816 | TList *files = file_info.fFileNamesList; |
||
817 | TString fname; |
||
818 | // If multiple files were selected, only use the first one |
||
819 | if(files) |
||
820 | { |
||
821 | printf("Using only the first selected file.\n"); |
||
822 | |||
823 | TSystemFile *file; |
||
824 | TIter next(files); |
||
825 | while(i == 0) |
||
826 | { |
||
827 | file=(TSystemFile*)next(); |
||
828 | fname = file->GetName(); |
||
829 | i++; |
||
830 | } |
||
831 | } |
||
832 | // If only one file was selected, use it |
||
833 | else |
||
834 | fname = file_info.fFilename; |
||
835 | |||
836 | if((int)fname.Length() > 0) |
||
837 | { |
||
838 | inroot = new TFile(fname, "READ"); |
||
839 | |||
840 | inroot->GetObject("header_data", header_data); |
||
841 | |||
842 | // Reading the timestamp information |
||
843 | header_data->SetBranchAddress("timestamp", &evtheader.timestamp); |
||
844 | header_data->GetEntry(0); |
||
845 | |||
846 | rtime = (time_t)evtheader.timestamp; |
||
847 | timeinfo = localtime(&rtime); |
||
848 | // printf("Time: %d.%d.%d, %d:%d:%d\n", timeinfo->tm_mday, timeinfo->tm_mon+1, timeinfo->tm_year+1900, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec); |
||
849 | |||
850 | tempDay[set]->Select(timeinfo->tm_mday - 1); |
||
851 | tempMonth[set]->Select(timeinfo->tm_mon); |
||
852 | tempYear[set]->Select(curyear - (timeinfo->tm_year+1900)); |
||
853 | tempHour[set]->Select(timeinfo->tm_hour); |
||
854 | tempMinute[set]->Select(timeinfo->tm_min); |
||
855 | tempSecond[set]->Select(timeinfo->tm_sec); |
||
129 | f9daq | 856 | |
857 | inroot->Close(); |
||
128 | f9daq | 858 | } |
859 | else |
||
860 | printf("No file selected.\n"); |
||
861 | |||
862 | delete inroot; |
||
863 | } |
||
864 | |||
865 | // Toggle the endtime settings for temperature sensor |
||
866 | void TGAppMainFrame::TempEndToggle() |
||
867 | { |
||
868 | if( tempEndOn->IsDown() ) |
||
869 | { |
||
870 | tempDay[1]->SetEnabled(kFALSE); |
||
871 | tempMonth[1]->SetEnabled(kFALSE); |
||
872 | tempYear[1]->SetEnabled(kFALSE); |
||
873 | tempHour[1]->SetEnabled(kFALSE); |
||
874 | tempMinute[1]->SetEnabled(kFALSE); |
||
875 | tempSecond[1]->SetEnabled(kFALSE); |
||
876 | tempFile[1]->SetEnabled(kFALSE); |
||
877 | } |
||
878 | else |
||
879 | { |
||
880 | tempDay[1]->SetEnabled(kTRUE); |
||
881 | tempMonth[1]->SetEnabled(kTRUE); |
||
882 | tempYear[1]->SetEnabled(kTRUE); |
||
883 | tempHour[1]->SetEnabled(kTRUE); |
||
884 | tempMinute[1]->SetEnabled(kTRUE); |
||
885 | tempSecond[1]->SetEnabled(kTRUE); |
||
886 | tempFile[1]->SetEnabled(kTRUE); |
||
887 | } |
||
888 | } |
||
889 | |||
890 | // -------------------------------------------------------------- |
||
891 | |||
129 | f9daq | 892 | // Header editor functions -------------------------------------- |
893 | |||
894 | // Toggle the edit possibility for header entries |
||
895 | void TGAppMainFrame::EditTickToggle(int set) |
||
896 | { |
||
897 | if(set == 1) |
||
898 | { |
||
899 | if(biasedittick->IsDown()) biasedit->SetState(kTRUE); |
||
900 | else biasedit->SetState(kFALSE); |
||
901 | } |
||
902 | else if(set == 2) |
||
903 | { |
||
904 | if(posedittick->IsDown()) |
||
905 | { |
||
906 | posedit[0]->SetState(kTRUE); |
||
907 | posedit[1]->SetState(kTRUE); |
||
908 | posedit[2]->SetState(kTRUE); |
||
909 | } |
||
910 | else |
||
911 | { |
||
912 | posedit[0]->SetState(kFALSE); |
||
913 | posedit[1]->SetState(kFALSE); |
||
914 | posedit[2]->SetState(kFALSE); |
||
915 | } |
||
916 | } |
||
917 | else if(set == 3) |
||
918 | { |
||
919 | if(tempedittick->IsDown()) tempedit->SetState(kTRUE); |
||
920 | else tempedit->SetState(kFALSE); |
||
921 | } |
||
922 | else if(set == 4) |
||
923 | { |
||
924 | if(angleedittick->IsDown()) angleedit->SetState(kTRUE); |
||
925 | else angleedit->SetState(kFALSE); |
||
926 | } |
||
927 | else if(set == 5) |
||
928 | { |
||
929 | if(laseredittick->IsDown()) laseredit->SetState(kTRUE); |
||
930 | else laseredit->SetState(kFALSE); |
||
931 | } |
||
932 | } |
||
933 | |||
934 | // Run the editing of file headers |
||
935 | void TGAppMainFrame::headerchange(char *histfile, bool *changetype) |
||
936 | { |
||
937 | if(debug) |
||
938 | printf("Selected file: %s\n", histfile); |
||
939 | |||
940 | // Preparing input file and the temporary output file |
||
941 | inroot = new TFile(histfile, "READ"); |
||
942 | |||
943 | char outname[256]; |
||
944 | sprintf(outname, "%s/results/temp.root", rootdir); |
||
945 | outroot = new TFile(outname, "RECREATE"); |
||
946 | |||
947 | // Tree structure of input file |
||
948 | TTree *header_data, *meas_data, *scope_data; |
||
949 | |||
950 | inroot->GetObject("header_data", header_data); |
||
951 | inroot->GetObject("meas_data", meas_data); |
||
952 | inroot->GetObject("scope_data", scope_data); |
||
953 | |||
954 | // Tree structure of output file |
||
955 | TTree *new_meas_data = meas_data->CloneTree(); |
||
956 | TTree *new_scope_data = scope_data->CloneTree(); |
||
957 | |||
958 | // Save branches from the old header to temporary variables |
||
959 | header_data->SetBranchAddress("nrch", &evtheader.nrch); |
||
960 | header_data->GetEntry(0); |
||
961 | header_data->SetBranchAddress("timestamp", &evtheader.timestamp); |
||
962 | header_data->GetEntry(0); |
||
963 | header_data->SetBranchAddress("biasvolt", &evtheader.biasvolt); |
||
964 | header_data->GetEntry(0); |
||
965 | header_data->SetBranchAddress("xpos", &evtheader.xpos); |
||
966 | header_data->GetEntry(0); |
||
967 | header_data->SetBranchAddress("ypos", &evtheader.ypos); |
||
968 | header_data->GetEntry(0); |
||
969 | header_data->SetBranchAddress("zpos", &evtheader.zpos); |
||
970 | header_data->GetEntry(0); |
||
971 | header_data->SetBranchAddress("temperature", &evtheader.temperature); |
||
972 | header_data->GetEntry(0); |
||
973 | if( header_data->FindBranch("angle") ) |
||
974 | { |
||
975 | header_data->SetBranchAddress("angle", &evtheader.angle); |
||
976 | header_data->GetEntry(0); |
||
977 | } |
||
978 | header_data->SetBranchAddress("laserinfo", &evtheader.laserinfo); |
||
979 | header_data->GetEntry(0); |
||
980 | |||
981 | int itemp[5] = {0,0,0,0,0}; |
||
982 | double dtemp[3] = {0.,0.,0.}; |
||
983 | char ctemp[256]; |
||
984 | |||
985 | itemp[0] = evtheader.nrch; |
||
986 | itemp[1] = evtheader.timestamp; |
||
987 | itemp[2] = evtheader.xpos; |
||
988 | itemp[3] = evtheader.ypos; |
||
989 | itemp[4] = evtheader.zpos; |
||
990 | dtemp[0] = evtheader.biasvolt; |
||
991 | dtemp[1] = evtheader.temperature; |
||
992 | if( header_data->FindBranch("angle") ) |
||
993 | dtemp[2] = evtheader.angle; |
||
994 | else |
||
995 | dtemp[2] = 0.; |
||
996 | sprintf(ctemp, "%s", evtheader.laserinfo); |
||
997 | |||
998 | delete header_data; |
||
999 | delete meas_data; |
||
1000 | delete scope_data; |
||
1001 | inroot->Close(); |
||
1002 | delete inroot; |
||
1003 | |||
1004 | // Prepare branches for the new header |
||
1005 | TTree *new_header_data = new TTree("header_data", "Header information for the measurement."); |
||
1006 | new_header_data->Branch("nrch", &evtheader.nrch, "nrch/I"); |
||
1007 | new_header_data->Branch("timestamp", &evtheader.timestamp, "timestamp/I"); |
||
1008 | new_header_data->Branch("biasvolt", &evtheader.biasvolt, "biasvolt/D"); |
||
1009 | new_header_data->Branch("xpos", &evtheader.xpos, "xpos/I"); |
||
1010 | new_header_data->Branch("ypos", &evtheader.ypos, "ypos/I"); |
||
1011 | new_header_data->Branch("zpos", &evtheader.zpos, "zpos/I"); |
||
1012 | new_header_data->Branch("temperature", &evtheader.temperature, "temperature/D"); |
||
1013 | new_header_data->Branch("angle", &evtheader.angle, "temperature/D"); |
||
1014 | new_header_data->Branch("laserinfo", &evtheader.laserinfo, "laserinfo/C"); |
||
1015 | |||
1016 | // Save new values (and old ones where we don't want to edit anything) |
||
1017 | evtheader.nrch = itemp[0]; |
||
1018 | evtheader.timestamp = itemp[1]; |
||
1019 | if(changetype[0]) |
||
1020 | evtheader.biasvolt = (double)biasedit->GetNumber(); |
||
1021 | else |
||
1022 | evtheader.biasvolt = dtemp[0]; |
||
1023 | if(changetype[1]) |
||
1024 | { |
||
1025 | evtheader.xpos = (int)posedit[0]->GetNumber(); |
||
1026 | evtheader.ypos = (int)posedit[1]->GetNumber(); |
||
1027 | evtheader.zpos = (int)posedit[2]->GetNumber(); |
||
1028 | } |
||
1029 | else |
||
1030 | { |
||
1031 | evtheader.xpos = itemp[2]; |
||
1032 | evtheader.ypos = itemp[3]; |
||
1033 | evtheader.zpos = itemp[4]; |
||
1034 | } |
||
1035 | if(changetype[2]) |
||
1036 | evtheader.temperature = (double)tempedit->GetNumber(); |
||
1037 | else |
||
1038 | evtheader.temperature = dtemp[1]; |
||
1039 | if(changetype[3]) |
||
1040 | evtheader.angle = (double)angleedit->GetNumber(); |
||
1041 | else |
||
1042 | evtheader.angle = dtemp[2]; |
||
1043 | if(changetype[4]) |
||
1044 | sprintf(evtheader.laserinfo, "%s", laseredit->GetText()); |
||
1045 | else |
||
1046 | sprintf(evtheader.laserinfo, "%s", ctemp); |
||
1047 | |||
1048 | new_header_data->Fill(); |
||
1049 | |||
1050 | // Write down the temporary output file |
||
1051 | new_header_data->Write(); |
||
1052 | new_meas_data->Write(); |
||
1053 | new_scope_data->Write(); |
||
1054 | |||
1055 | delete new_header_data; |
||
1056 | delete new_meas_data; |
||
1057 | delete new_scope_data; |
||
1058 | outroot->Close(); |
||
1059 | delete outroot; |
||
1060 | |||
1061 | // Replace the original file with temporary output file (and delete temporary file) |
||
1062 | sprintf(outname, "cp -f %s/results/temp.root %s", rootdir, histfile); |
||
1063 | retTemp = system(outname); |
||
1064 | sprintf(outname, "rm -f %s/results/temp.root", rootdir); |
||
1065 | retTemp = system(outname); |
||
1066 | |||
1067 | printf("Edited header in file: %s\n", histfile); |
||
1068 | } |
||
1069 | |||
1070 | // Setup the editing of file headers |
||
1071 | void TGAppMainFrame::headeredit() |
||
1072 | { |
||
1073 | unsigned int nrfiles = fileList->GetNumberOfEntries(); |
||
1074 | TList *files; |
||
1075 | // Changelist: Bias, Position, Temperature, Angle, Laser info |
||
1076 | bool changelist[] = { biasedittick->IsDown(), posedittick->IsDown(), tempedittick->IsDown(), angleedittick->IsDown(), laseredittick->IsDown() }; |
||
1077 | |||
1078 | if( nrfiles > 0 ) |
||
1079 | { |
||
1080 | // check the selected file/files and return its name/their names |
||
1081 | files = new TList(); |
||
1082 | fileList->GetSelectedEntries(files); |
||
1083 | if(files) |
||
1084 | { |
||
1085 | for(int i = 0; i < (int)nrfiles; i++) |
||
1086 | { |
||
1087 | if(files->At(i)) |
||
1088 | { |
||
1089 | if(debug) |
||
1090 | printf("Filename: %s\n", files->At(i)->GetTitle()); |
||
1091 | |||
1092 | headerchange( (char*)(files->At(i)->GetTitle()), changelist ); |
||
1093 | } |
||
1094 | } |
||
1095 | } |
||
1096 | } |
||
1097 | } |
||
1098 | |||
1099 | // -------------------------------------------------------------- |
||
1100 | |||
117 | f9daq | 1101 | // Class related functions -------------------------------------- |
1102 | |||
1103 | // Apply the upper voltage limit from settings pane to main window |
||
1104 | void TGAppMainFrame::VoltageLimit() |
||
1105 | { |
||
1106 | vOut->SetLimitValues(0, vHardlimit->GetNumber() ); |
||
1107 | } |
||
1108 | |||
1109 | // Apply the upper channel limit from settings pane to histogram settings |
||
1110 | void TGAppMainFrame::ChannelLimit() |
||
1111 | { |
||
1112 | selectCh->SetLimitValues(0, (NCH->GetNumber()-1) ); |
||
1113 | } |
||
1114 | |||
1115 | // Enable or disable voltage scan controls |
||
1116 | void TGAppMainFrame::EnableVoltScan() |
||
1117 | { |
||
1118 | if(voltscanOn->IsOn()) |
||
1119 | { |
||
1120 | vOutStart->SetState(kTRUE); |
||
1121 | vOutStop->SetState(kTRUE); |
||
1122 | vOutStep->SetState(kTRUE); |
||
1123 | } |
||
1124 | else |
||
1125 | { |
||
1126 | vOutStart->SetState(kFALSE); |
||
1127 | vOutStop->SetState(kFALSE); |
||
1128 | vOutStep->SetState(kFALSE); |
||
1129 | } |
||
1130 | } |
||
1131 | |||
1132 | // Enable or disable surface scan controls |
||
1133 | void TGAppMainFrame::EnableSurfScan() |
||
1134 | { |
||
1135 | if(surfscanOn->IsOn()) |
||
1136 | { |
||
1137 | xPosMin->SetState(kTRUE); |
||
1138 | xPosMax->SetState(kTRUE); |
||
1139 | xPosStep->SetState(kTRUE); |
||
1140 | yPosMin->SetState(kTRUE); |
||
1141 | yPosMax->SetState(kTRUE); |
||
1142 | yPosStep->SetState(kTRUE); |
||
1143 | } |
||
1144 | else |
||
1145 | { |
||
1146 | xPosMin->SetState(kFALSE); |
||
1147 | xPosMax->SetState(kFALSE); |
||
1148 | xPosStep->SetState(kFALSE); |
||
1149 | yPosMin->SetState(kFALSE); |
||
1150 | yPosMax->SetState(kFALSE); |
||
1151 | yPosStep->SetState(kFALSE); |
||
1152 | } |
||
1153 | } |
||
1154 | |||
1155 | // Enable or disable Z axis scan controls |
||
1156 | void TGAppMainFrame::EnableZaxisScan() |
||
1157 | { |
||
1158 | if(zscanOn->IsOn()) |
||
1159 | { |
||
1160 | zPosMin->SetState(kTRUE); |
||
1161 | zPosMax->SetState(kTRUE); |
||
1162 | zPosStep->SetState(kTRUE); |
||
1163 | } |
||
1164 | else |
||
1165 | { |
||
1166 | zPosMin->SetState(kFALSE); |
||
1167 | zPosMax->SetState(kFALSE); |
||
1168 | zPosStep->SetState(kFALSE); |
||
1169 | } |
||
1170 | } |
||
1171 | |||
1172 | // Toggle clean plots on/off |
||
1173 | void TGAppMainFrame::CleanPlotToggle() |
||
1174 | { |
||
1175 | cleanPlots = cleanOn->IsDown(); |
||
1176 | } |
||
1177 | |||
1178 | // Connect to oscilloscope |
||
1179 | void TGAppMainFrame::ConnectToScope() |
||
1180 | { |
||
1181 | int scopeState = -1; |
||
1182 | char *IPaddr = (char*)oscIP->GetText(); |
||
1183 | int IPcorr = 0; |
||
1184 | |||
1185 | if(oscOn == 0) |
||
1186 | { |
||
1187 | // Check if the IP address has the required three . |
||
1188 | for(int i = 0; i < (int)strlen(IPaddr); i++) |
||
1189 | if(IPaddr[i] == '.') |
||
1190 | IPcorr++; |
||
1191 | |||
1192 | if( (IPaddr != NULL) && (IPcorr == 3) ) |
||
1193 | { |
||
127 | f9daq | 1194 | #if WORKSTAT == 'I' || WORKSTAT == 'S' |
117 | f9daq | 1195 | printf("Connecting to oscilloscope.\n"); |
1196 | retTemp = gScopeDaq->connect(IPaddr); |
||
1197 | scopeState = 1; // For testing instead of making a real connection |
||
1198 | #else |
||
1199 | scopeState = 1; |
||
127 | f9daq | 1200 | retTemp = 0; |
117 | f9daq | 1201 | #endif |
1202 | } |
||
1203 | else |
||
1204 | { |
||
1205 | scopeState = -1; |
||
1206 | printf("Please enter a valid scope IP address.\n"); |
||
1207 | } |
||
1208 | } |
||
127 | f9daq | 1209 | else if(oscOn > 0) |
117 | f9daq | 1210 | { |
127 | f9daq | 1211 | #if WORKSTAT == 'I' || WORKSTAT == 'S' |
117 | f9daq | 1212 | printf("Disconnecting from oscilloscope.\n"); |
1213 | retTemp = gScopeDaq->disconnect(IPaddr); |
||
1214 | scopeState = -1; // For testing instead of making a real disconnection |
||
1215 | #else |
||
1216 | scopeState = -1; |
||
127 | f9daq | 1217 | retTemp = 0; |
117 | f9daq | 1218 | #endif |
1219 | } |
||
1220 | |||
127 | f9daq | 1221 | if(retTemp == 0) |
117 | f9daq | 1222 | { |
127 | f9daq | 1223 | if(scopeState >= 0) |
1224 | { |
||
1225 | oscIP->SetEnabled(kFALSE); |
||
1226 | oscConnect->SetText("Disconnect"); |
||
1227 | oscConnect->SetTextJustify(36); |
||
1228 | oscConnect->SetWrapLength(-1); |
||
1229 | oscConnect->Resize(60,22); |
||
1230 | |||
1231 | for(int i = 0; i < 8; i++) |
||
1232 | { |
||
1233 | sCH[i]->SetState(kButtonUp); |
||
1234 | sCH[i]->SetEnabled(kFALSE); |
||
1235 | } |
||
1236 | sMeasType->SetEnabled(kTRUE); |
||
1237 | sCamaclink->SetState(kButtonUp); |
||
1238 | sCamaclink->SetEnabled(kFALSE); |
||
1239 | scopeCommand->SetEnabled(kTRUE); |
||
1240 | sendScopeCustom->SetEnabled(kTRUE); |
||
1241 | sMeasgroup->SetEnabled(kFALSE); |
||
1242 | scopeInit->SetEnabled(kFALSE); |
||
1243 | |||
1244 | oscOn = 1; |
||
1245 | } |
||
1246 | else |
||
1247 | { |
||
1248 | oscIP->SetEnabled(kTRUE); |
||
1249 | oscConnect->SetText("Connect"); |
||
1250 | oscConnect->SetTextJustify(36); |
||
1251 | oscConnect->SetWrapLength(-1); |
||
1252 | oscConnect->Resize(60,22); |
||
1253 | |||
1254 | for(int i = 0; i < 8; i++) |
||
1255 | { |
||
1256 | sCH[i]->SetState(kButtonUp); |
||
1257 | sCH[i]->SetEnabled(kFALSE); |
||
1258 | } |
||
1259 | sMeasType->Select(0); |
||
1260 | sMeasType->SetEnabled(kFALSE); |
||
1261 | sCamaclink->SetState(kButtonUp); |
||
1262 | sCamaclink->SetEnabled(kFALSE); |
||
1263 | scopeCommand->SetEnabled(kFALSE); |
||
1264 | sendScopeCustom->SetEnabled(kFALSE); |
||
1265 | sMeasgroup->SetEnabled(kFALSE); |
||
1266 | scopeInit->SetEnabled(kFALSE); |
||
1267 | |||
1268 | oscOn = 0; |
||
1269 | } |
||
117 | f9daq | 1270 | } |
1271 | else |
||
127 | f9daq | 1272 | printf("Error! Connecting/disconnecting failed.\n"); |
117 | f9daq | 1273 | } |
1274 | |||
1275 | // Set the output voltage |
||
1276 | void TGAppMainFrame::SetVoltOut() |
||
1277 | { |
||
1278 | char cmd[256]; |
||
1279 | int outOn; |
||
1280 | float outputVoltage; |
||
1281 | |||
1282 | outputVoltage = vOut->GetNumber(); |
||
1283 | |||
1284 | if(vOutOnOff->IsOn()) outOn = 1; |
||
1285 | else outOn = 0; |
||
1286 | |||
1287 | fflush(stdout); |
||
1288 | sprintf(cmd, "%s/mpod/mpod_voltage.sh -o %d -v %f -s %d", rootdir, GetChannel(), outputVoltage, outOn); |
||
1289 | #if WORKSTAT == 'I' |
||
1290 | retTemp = system(cmd); |
||
1291 | #else |
||
1292 | printf("Cmd: %s\n",cmd); |
||
1293 | #endif |
||
1294 | fflush(stdout); |
||
1295 | } |
||
1296 | |||
1297 | // Get the output voltage |
||
1298 | void TGAppMainFrame::GetVoltOut() |
||
1299 | { |
||
1300 | char cmd[256]; |
||
1301 | |||
1302 | fflush(stdout); |
||
1303 | sprintf(cmd, "%s/mpod/mpod_voltage.sh -o %d -g > %s/curvolt.txt", rootdir, GetChannel(), rootdir); |
||
1304 | #if WORKSTAT == 'I' |
||
1305 | retTemp = system(cmd); |
||
1306 | #else |
||
1307 | printf("Cmd: %s\n",cmd); |
||
1308 | #endif |
||
1309 | fflush(stdout); |
||
1310 | |||
1311 | #if WORKSTAT == 'I' |
||
1312 | FILE* fvolt; |
||
1313 | double dtemp; |
||
1314 | char ctemp[24]; |
||
1315 | sprintf(cmd, "%s/curvolt.txt", rootdir); |
||
1316 | fvolt = fopen(cmd, "r"); |
||
1317 | |||
1318 | if(fvolt != NULL) |
||
1319 | { |
||
1320 | sprintf(cmd, "WIENER-CRATE-MIB::outputVoltage.u%d = Opaque: Float: %s V\n", GetChannel()-1, "%lf" ); |
||
1321 | retTemp = fscanf(fvolt, cmd, &dtemp); |
||
1322 | vOut->SetNumber(dtemp); |
||
1323 | sprintf(cmd, "WIENER-CRATE-MIB::outputSwitch.u%d = INTEGER: %s\n", GetChannel()-1, "%s" ); |
||
1324 | retTemp = fscanf(fvolt, cmd, ctemp); |
||
1325 | if( strcmp(ctemp, "On(1)") == 0 ) |
||
1326 | vOutOnOff->SetState(kButtonDown); |
||
1327 | else if( strcmp(ctemp, "Off(0)") == 0 ) |
||
1328 | vOutOnOff->SetState(kButtonUp); |
||
1329 | } |
||
1330 | |||
1331 | fclose(fvolt); |
||
1332 | #endif |
||
1333 | } |
||
1334 | |||
1335 | // Reset the output voltage |
||
1336 | void TGAppMainFrame::ResetVoltOut() |
||
1337 | { |
||
1338 | char cmd[256]; |
||
1339 | |||
1340 | vOut->SetNumber(0.000); |
||
1341 | vOutOnOff->SetState(kButtonUp); |
||
1342 | |||
1343 | fflush(stdout); |
||
1344 | sprintf(cmd, "%s/mpod/mpod_voltage.sh -r %d", rootdir, GetChannel()); |
||
1345 | #if WORKSTAT == 'I' |
||
1346 | retTemp = system(cmd); |
||
1347 | #else |
||
1348 | printf("Cmd: %s\n",cmd); |
||
1349 | #endif |
||
1350 | fflush(stdout); |
||
1351 | } |
||
1352 | |||
1353 | // Get the current table position |
||
1354 | void TGAppMainFrame::GetPosition() |
||
1355 | { |
||
1356 | char cmd[256]; |
||
1357 | |||
1358 | fflush(stdout); |
||
1359 | |||
1360 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 1 -p > %s/curpos.txt", rootdir, rootdir); // X-axis |
||
1361 | fflush(stdout); |
||
1362 | #if WORKSTAT == 'I' |
||
1363 | retTemp = system(cmd); |
||
1364 | #else |
||
1365 | printf("Cmd: %s\n",cmd); |
||
1366 | #endif |
||
1367 | |||
1368 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 2 -p >> %s/curpos.txt", rootdir, rootdir); // Y-axis |
||
1369 | fflush(stdout); |
||
1370 | #if WORKSTAT == 'I' |
||
1371 | retTemp = system(cmd); |
||
1372 | #else |
||
1373 | printf("Cmd: %s\n",cmd); |
||
1374 | #endif |
||
1375 | |||
1376 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 3 -p >> %s/curpos.txt", rootdir, rootdir); // Z-axis |
||
1377 | fflush(stdout); |
||
1378 | #if WORKSTAT == 'I' |
||
1379 | retTemp = system(cmd); |
||
1380 | #else |
||
1381 | printf("Cmd: %s\n",cmd); |
||
1382 | #endif |
||
1383 | |||
1384 | #if WORKSTAT == 'I' |
||
1385 | FILE* fpos; |
||
1386 | int itemp; |
||
1387 | sprintf(cmd, "%s/curpos.txt", rootdir); |
||
1388 | fpos = fopen(cmd, "r"); |
||
1389 | |||
1390 | if(fpos != NULL) |
||
1391 | { |
||
1392 | retTemp = fscanf(fpos, "%d\n", &itemp); |
||
1393 | xPos->SetNumber(itemp); |
||
1394 | retTemp = fscanf(fpos, "%d\n", &itemp); |
||
1395 | yPos->SetNumber(itemp); |
||
1396 | retTemp = fscanf(fpos, "%d\n", &itemp); |
||
1397 | zPos->SetNumber(itemp); |
||
1398 | } |
||
1399 | |||
1400 | fclose(fpos); |
||
1401 | #endif |
||
1402 | } |
||
1403 | |||
1404 | // Set the current table position |
||
1405 | void TGAppMainFrame::SetPosition() |
||
1406 | { |
||
1407 | char cmd[256]; |
||
1408 | int positX, positY, positZ; |
||
1409 | |||
1410 | positX = xPos->GetNumber(); |
||
1411 | positY = yPos->GetNumber(); |
||
1412 | positZ = zPos->GetNumber(); |
||
1413 | |||
1414 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 1 -v %d -s la && %s/MIKRO/mikro_ctrl -n 1 -c m", rootdir, positX, rootdir); |
||
1415 | #if WORKSTAT == 'I' |
||
1416 | retTemp = system(cmd); |
||
1417 | #else |
||
1418 | printf("Cmd: %s\n",cmd); |
||
1419 | #endif |
||
1420 | |||
1421 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 2 -v %d -s la && %s/MIKRO/mikro_ctrl -n 2 -c m", rootdir, positY, rootdir); |
||
1422 | #if WORKSTAT == 'I' |
||
1423 | retTemp = system(cmd); |
||
1424 | #else |
||
1425 | printf("Cmd: %s\n",cmd); |
||
1426 | #endif |
||
1427 | |||
1428 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 3 -v %d -s la && %s/MIKRO/mikro_ctrl -n 3 -c m", rootdir, positZ, rootdir); |
||
1429 | #if WORKSTAT == 'I' |
||
1430 | retTemp = system(cmd); |
||
1431 | #else |
||
1432 | printf("Cmd: %s\n",cmd); |
||
1433 | #endif |
||
1434 | } |
||
1435 | |||
1436 | // Set the current table position to a predetermined HOME position |
||
1437 | void TGAppMainFrame::HomePosition() |
||
1438 | { |
||
1439 | char cmd[256]; |
||
1440 | |||
1441 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 1 -h", rootdir); // X-axis |
||
1442 | #if WORKSTAT == 'I' |
||
1443 | retTemp = system(cmd); |
||
1444 | #else |
||
1445 | printf("Cmd: %s\n",cmd); |
||
1446 | #endif |
||
1447 | |||
1448 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 2 -h", rootdir); // Y-axis |
||
1449 | #if WORKSTAT == 'I' |
||
1450 | retTemp = system(cmd); |
||
1451 | #else |
||
1452 | printf("Cmd: %s\n",cmd); |
||
1453 | #endif |
||
1454 | |||
1455 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 3 -h", rootdir); // Z-axis |
||
1456 | #if WORKSTAT == 'I' |
||
1457 | retTemp = system(cmd); |
||
1458 | #else |
||
1459 | printf("Cmd: %s\n",cmd); |
||
1460 | #endif |
||
1461 | } |
||
1462 | |||
127 | f9daq | 1463 | // Initialize the currently connected scope for measurements |
1464 | void TGAppMainFrame::InitializeScope() |
||
1465 | { |
||
1466 | int iTemp; |
||
1467 | int chTemp[8]; |
||
1468 | for(int i = 0; i < 8; i++) chTemp[i] = -1; |
||
1469 | gScopeDaq->scopeUseType = sMeasType->GetSelected(); |
||
1470 | |||
1471 | // Check what channels are selected |
||
1472 | iTemp = 0; |
||
1473 | for(int i = 0; i < 8; i++) |
||
1474 | { |
||
1475 | if(sCH[i]->IsDown()) |
||
1476 | { |
||
1477 | chTemp[iTemp] = i; |
||
1478 | iTemp++; |
||
1479 | } |
||
1480 | } |
||
1481 | if(iTemp == 0) |
||
1482 | { |
||
1483 | // If no channel is selected, we select the first one |
||
1484 | chTemp[0] = 0; |
||
1485 | iTemp++; |
||
1486 | sCH[0]->SetState(kButtonDown); |
||
1487 | } |
||
1488 | // If measurement is used, only use the first selected channel |
||
1489 | if(gScopeDaq->scopeUseType == 2) |
||
1490 | { |
||
1491 | for(int i = 1; i < iTemp; i++) |
||
1492 | sCH[chTemp[i]]->SetState(kButtonUp); |
||
1493 | iTemp = 1; |
||
1494 | } |
||
1495 | |||
1496 | gScopeDaq->scopeChanNr = iTemp; |
||
1497 | for(int i = 0; i < 8; i++) gScopeDaq->scopeChans[i] = chTemp[i]; |
||
1498 | |||
1499 | // Check which measurement is selected |
||
1500 | gScopeDaq->scopeMeasSel = sMeasgroup->GetSelected(); |
||
1501 | |||
1502 | gScopeDaq->init(); |
||
1503 | } |
||
1504 | |||
1505 | // Run a scope measurement |
||
1506 | void TGAppMainFrame::StartScopeAcq() |
||
1507 | { |
||
1508 | // Lock the scope front panel |
||
1509 | gScopeDaq->lockunlock(true); |
||
1510 | |||
1511 | retTemp = gScopeDaq->event(); |
||
1512 | |||
1513 | if(gScopeDaq->scopeUseType == 1) |
||
1514 | { |
||
1515 | char len[16]; |
||
1516 | int sval; |
||
1517 | short *spoints; |
||
1518 | |||
1519 | if(retTemp == 0) |
||
1520 | { |
||
1521 | // Read the number of y bytes at beginning of CURVE binary data |
||
1522 | memcpy(len, &gScopeDaq->eventbuf[1],1); |
||
1523 | len[1] = 0; |
||
1524 | sval = atoi(len); |
||
1525 | // printf("Number of y bytes = %d\n", sval); |
||
1526 | |||
1527 | // Read the data |
||
1528 | spoints = (short *)(&gScopeDaq->eventbuf[2+sval]); |
||
1529 | |||
1530 | // Read the number of data points |
||
1531 | memcpy(len, &gScopeDaq->eventbuf[2],sval); |
||
1532 | len[sval] = 0; |
||
1533 | sval = atoi(len); |
||
1534 | // printf("Number of data points = %d\n", sval/2); |
||
1535 | |||
1536 | double *grafx, *grafy; |
||
1537 | grafx = new double[sval/2]; |
||
1538 | grafy = new double[sval/2]; |
||
1539 | // Parse data and graph it |
||
1540 | for(int i = 0; i < sval/2; i++) |
||
1541 | { |
||
1542 | grafx[i] = i*gScopeDaq->tektime*10./(sval/2.); |
||
1543 | grafy[i] = ((double)spoints[i]*5.*gScopeDaq->tekvolt/32767.) - (gScopeDaq->choffset*gScopeDaq->tekvolt); |
||
1544 | } |
||
1545 | |||
1546 | wCanvas->cd(); |
||
1547 | testgraph = new TGraph(sval/2, grafx, grafy); |
||
1548 | testgraph->GetXaxis()->SetTitle("Time [s]"); |
||
1549 | testgraph->GetXaxis()->SetRangeUser(grafx[0], grafx[(sval/2)-1]); |
||
1550 | testgraph->GetYaxis()->SetTitle("Voltage [V]"); |
||
1551 | testgraph->Draw("AL"); |
||
1552 | wCanvas->Modified(); |
||
1553 | wCanvas->Update(); |
||
1554 | |||
1555 | delete[] grafx; |
||
1556 | delete[] grafy; |
||
1557 | } |
||
1558 | } |
||
1559 | else if(gScopeDaq->scopeUseType == 2) |
||
1560 | { |
||
1561 | if(retTemp == 0) |
||
1562 | { |
||
1563 | if(gScopeDaq->measubuf < 1.e-4) |
||
1564 | printf("Measurement: %le\n", gScopeDaq->measubuf); |
||
1565 | else |
||
1566 | printf("Measurement: %lf\n", gScopeDaq->measubuf); |
||
1567 | } |
||
1568 | } |
||
1569 | |||
1570 | // Unlock the scope front panel |
||
1571 | gScopeDaq->lockunlock(false); |
||
1572 | } |
||
1573 | |||
1574 | // Send a custom command to the scope |
||
1575 | void TGAppMainFrame::CustomScopeCommand() |
||
1576 | { |
||
1577 | char *cmd = (char*)scopeCommand->GetText(); |
||
1578 | char ret[100000]; |
||
1579 | if( strchr(cmd, '?') == NULL) |
||
1580 | { |
||
1581 | printf("Sending command: %s\n", cmd); |
||
1582 | #if WORKSTAT == 'I' || WORKSTAT == 'S' |
||
1583 | gScopeDaq->customCommand(cmd, false, ret); |
||
1584 | #endif |
||
1585 | } |
||
1586 | else |
||
1587 | { |
||
1588 | printf("Sending query: %s\n", cmd); |
||
1589 | #if WORKSTAT == 'I' || WORKSTAT == 'S' |
||
1590 | gScopeDaq->customCommand(cmd, true, ret); |
||
1591 | #endif |
||
1592 | } |
||
1593 | |||
1594 | #if WORKSTAT == 'I' || WORKSTAT == 'S' |
||
1595 | scopeReturn->SetText(ret); |
||
1596 | #endif |
||
128 | f9daq | 1597 | |
1598 | #if WORKSTAT == 'O' |
||
1599 | sprintf(ret, "Program running in offline mode. Use I or S when configuring..."); |
||
1600 | scopeReturn->SetText(ret); |
||
1601 | #endif |
||
127 | f9daq | 1602 | } |
1603 | |||
1604 | // When we select the measurement type, change other scope settings accordingly |
||
1605 | void TGAppMainFrame::SelectedMeasType(int mtype) |
||
1606 | { |
||
1607 | // No waveform analysis |
||
1608 | if(mtype == 0) |
||
1609 | { |
||
1610 | for(int i = 0; i < 8; i++) |
||
1611 | { |
||
1612 | sCH[i]->SetState(kButtonUp); |
||
1613 | sCH[i]->SetEnabled(kFALSE); |
||
1614 | } |
||
1615 | sMeasType->SetEnabled(kTRUE); |
||
1616 | sCamaclink->SetState(kButtonUp); |
||
1617 | sCamaclink->SetEnabled(kFALSE); |
||
1618 | scopeCommand->SetEnabled(kTRUE); |
||
1619 | sendScopeCustom->SetEnabled(kTRUE); |
||
1620 | sMeasgroup->SetEnabled(kFALSE); |
||
1621 | scopeInit->SetEnabled(kFALSE); |
||
1622 | |||
1623 | oscOn = 1; |
||
1624 | } |
||
1625 | // Complete waveform acquisition |
||
1626 | else if(mtype == 1) |
||
1627 | { |
||
1628 | for(int i = 0; i < 8; i++) |
||
1629 | sCH[i]->SetEnabled(kTRUE); |
||
1630 | sMeasType->SetEnabled(kTRUE); |
||
1631 | sCamaclink->SetState(kButtonDown); |
||
1632 | sCamaclink->SetEnabled(kTRUE); |
||
1633 | scopeCommand->SetEnabled(kTRUE); |
||
1634 | sendScopeCustom->SetEnabled(kTRUE); |
||
1635 | sMeasgroup->SetEnabled(kFALSE); |
||
1636 | scopeInit->SetEnabled(kTRUE); |
||
1637 | |||
1638 | oscOn = 2; |
||
1639 | } |
||
1640 | // Waveform measurements |
||
1641 | else if(mtype == 2) |
||
1642 | { |
||
1643 | for(int i = 0; i < 8; i++) |
||
1644 | sCH[i]->SetEnabled(kTRUE); |
||
1645 | sMeasType->SetEnabled(kTRUE); |
||
1646 | sCamaclink->SetState(kButtonUp); |
||
1647 | sCamaclink->SetEnabled(kTRUE); |
||
1648 | scopeCommand->SetEnabled(kTRUE); |
||
1649 | sendScopeCustom->SetEnabled(kTRUE); |
||
1650 | sMeasgroup->SetEnabled(kTRUE); |
||
1651 | scopeInit->SetEnabled(kTRUE); |
||
1652 | |||
1653 | oscOn = 3; |
||
1654 | } |
||
1655 | } |
||
1656 | |||
117 | f9daq | 1657 | // Make breakdown voltage plot |
129 | f9daq | 1658 | void TGAppMainFrame::MakeBreakdownPlot(int nrp, double *volt, double *volterr, double *psep1, double *pseperr1, double *psep2, double *pseperr2, double *psep3, double *pseperr3, char *plotfile, int separations) |
117 | f9daq | 1659 | { |
1660 | double fparam[2], fparamerr[2], meanval; |
||
1661 | TLatex *latex; |
||
1662 | char ctemp[256]; |
||
1663 | int sortindex[nrp]; |
||
1664 | |||
129 | f9daq | 1665 | TCanvas *canvas; |
1666 | |||
1667 | if(separations == 1) |
||
1668 | { |
||
1669 | canvas = new TCanvas("canv","canv",900,400); |
||
1670 | } |
||
1671 | else if(separations == 2) |
||
1672 | { |
||
1673 | canvas = new TCanvas("canv","canv",900,800); |
||
1674 | canvas->Divide(1,2); |
||
1675 | } |
||
1676 | else |
||
1677 | { |
||
1678 | canvas = new TCanvas("canv","canv",900,1200); |
||
1679 | canvas->Divide(1,3); |
||
1680 | } |
||
1681 | |||
1682 | // First graph is plotted always |
||
117 | f9daq | 1683 | TGraphErrors *gr1 = new TGraphErrors(nrp, volt, psep1, volterr, pseperr1); |
1684 | |||
1685 | if(!cleanPlots) |
||
1686 | gr1->SetTitle("1st - 2nd peak separation"); |
||
1687 | else |
||
1688 | gr1->SetTitle(); |
||
1689 | gr1->SetLineColor(kBlue); |
||
1690 | gr1->SetMarkerColor(kBlue); |
||
1691 | gr1->SetMarkerStyle(20); |
||
129 | f9daq | 1692 | gr1->SetMarkerSize(0.4); |
117 | f9daq | 1693 | |
1694 | // Plotting the first breakdown voltage plot |
||
1695 | canvas->cd(1); |
||
1696 | gPad->SetGridx(1); |
||
1697 | gPad->SetGridy(1); |
||
1698 | |||
1699 | gr1->Draw("AP"); |
||
1700 | gr1->GetXaxis()->SetTitle("Bias voltage (V)"); |
||
1701 | gr1->GetYaxis()->SetTitle("Peak separation"); |
||
1702 | gr1->GetYaxis()->CenterTitle(); |
||
1703 | gr1->Fit("pol1","Q"); |
||
1704 | |||
1705 | TF1 *fit1 = gr1->GetFunction("pol1"); |
||
1706 | fparam[0] = fit1->GetParameter(0); |
||
1707 | fparamerr[0] = fit1->GetParError(0); |
||
1708 | fparam[1] = fit1->GetParameter(1); |
||
1709 | fparamerr[1] = fit1->GetParError(1); |
||
1710 | |||
1711 | TMath::Sort(nrp, psep1, sortindex, kFALSE); |
||
1712 | |||
1713 | meanval = -fparam[0]/fparam[1]; |
||
1714 | if(!cleanPlots) |
||
1715 | { |
||
1716 | 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])) ); |
||
1717 | latex = new TLatex(); |
||
1718 | latex->SetTextSize(0.039); |
||
129 | f9daq | 1719 | latex->DrawLatex(volt[0], 0.97*psep1[sortindex[nrp-1]], ctemp); |
117 | f9daq | 1720 | } |
1721 | else |
||
1722 | 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])) ); |
||
1723 | |||
129 | f9daq | 1724 | // Second graph |
1725 | if(separations > 1) |
||
117 | f9daq | 1726 | { |
129 | f9daq | 1727 | TGraphErrors *gr2 = new TGraphErrors(nrp, volt, psep2, volterr, pseperr2); |
1728 | |||
1729 | if(!cleanPlots) |
||
1730 | gr2->SetTitle("2nd - 3rd peak separation"); |
||
1731 | else |
||
1732 | gr2->SetTitle(); |
||
1733 | gr2->SetLineColor(kMagenta); |
||
1734 | gr2->SetMarkerColor(kMagenta); |
||
1735 | gr2->SetMarkerStyle(21); |
||
1736 | gr2->SetMarkerSize(0.4); |
||
1737 | |||
1738 | // Plotting the second breakdown voltage plot |
||
1739 | canvas->cd(2); |
||
1740 | gPad->SetGridx(1); |
||
1741 | gPad->SetGridy(1); |
||
1742 | |||
1743 | gr2->Draw("AP"); |
||
1744 | gr2->GetXaxis()->SetTitle("Bias voltage (V)"); |
||
1745 | gr2->GetYaxis()->SetTitle("Peak separation"); |
||
1746 | gr2->GetYaxis()->CenterTitle(); |
||
1747 | gr2->Fit("pol1","Q"); |
||
1748 | |||
1749 | TF1 *fit2 = gr2->GetFunction("pol1"); |
||
1750 | fparam[0] = fit2->GetParameter(0); |
||
1751 | fparamerr[0] = fit2->GetParError(0); |
||
1752 | fparam[1] = fit2->GetParameter(1); |
||
1753 | fparamerr[1] = fit2->GetParError(1); |
||
1754 | |||
1755 | meanval = -fparam[0]/fparam[1]; |
||
1756 | if(!cleanPlots) |
||
1757 | { |
||
1758 | 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])) ); |
||
1759 | latex = new TLatex(); |
||
1760 | latex->SetTextSize(0.039); |
||
1761 | latex->DrawLatex(volt[0], 0.97*psep2[sortindex[nrp-1]], ctemp); |
||
1762 | } |
||
1763 | else |
||
1764 | 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])) ); |
||
117 | f9daq | 1765 | } |
1766 | |||
129 | f9daq | 1767 | // Third graph |
1768 | if(separations > 2) |
||
117 | f9daq | 1769 | { |
129 | f9daq | 1770 | TGraphErrors *gr3 = new TGraphErrors(nrp, volt, psep3, volterr, pseperr3); |
1771 | |||
1772 | if(!cleanPlots) |
||
1773 | gr3->SetTitle("3rd - 4th peak separation"); |
||
1774 | else |
||
1775 | gr3->SetTitle(); |
||
1776 | gr3->SetLineColor(kGreen); |
||
1777 | gr3->SetMarkerColor(kGreen); |
||
1778 | gr3->SetMarkerStyle(22); |
||
1779 | gr3->SetMarkerSize(0.4); |
||
1780 | |||
1781 | // Plotting the third breakdown voltage plot |
||
1782 | canvas->cd(3); |
||
1783 | gPad->SetGridx(1); |
||
1784 | gPad->SetGridy(1); |
||
1785 | |||
1786 | gr3->Draw("AP"); |
||
1787 | gr3->GetXaxis()->SetTitle("Bias voltage (V)"); |
||
1788 | gr3->GetYaxis()->SetTitle("Peak separation"); |
||
1789 | gr3->GetYaxis()->CenterTitle(); |
||
1790 | gr3->Fit("pol1","Q"); |
||
1791 | |||
1792 | TF1 *fit3 = gr3->GetFunction("pol1"); |
||
1793 | fparam[0] = fit3->GetParameter(0); |
||
1794 | fparamerr[0] = fit3->GetParError(0); |
||
1795 | fparam[1] = fit3->GetParameter(1); |
||
1796 | fparamerr[1] = fit3->GetParError(1); |
||
1797 | |||
1798 | meanval = -fparam[0]/fparam[1]; |
||
1799 | if(!cleanPlots) |
||
1800 | { |
||
1801 | 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])) ); |
||
1802 | latex = new TLatex(); |
||
1803 | latex->SetTextSize(0.039); |
||
1804 | latex->DrawLatex(volt[0], 0.97*psep3[sortindex[nrp-1]], ctemp); |
||
1805 | } |
||
1806 | else |
||
1807 | 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])) ); |
||
117 | f9daq | 1808 | } |
1809 | |||
129 | f9daq | 1810 | // Saving the produced plot |
117 | f9daq | 1811 | canvas->SaveAs(plotfile); |
1812 | } |
||
1813 | |||
1814 | // Fit the ADC spectrum peaks and make a breakdown voltage plot |
||
1815 | void TGAppMainFrame::FitSpectrum(TList *files, int q) |
||
1816 | { |
||
1817 | TCanvas *gCanvas = histCanvas->GetCanvas(); |
||
1818 | gCanvas->cd(); |
||
1819 | TH1F *histtemp; |
||
1820 | TSpectrum *spec; |
||
1821 | TH1 *histback; |
||
1822 | TH1F *h2; |
||
1823 | float *xpeaks; |
||
1824 | TF1 *fit; |
||
1825 | TF1 *fittingfunc; |
||
1826 | double *fparam; |
||
1827 | double *fparamerr; |
||
1828 | double meanparam[20], meanparamerr[20]; |
||
1829 | int sortindex[20]; |
||
1830 | char exportname[256]; |
||
1831 | char paramname[256]; |
||
1832 | char ctemp[256]; |
||
1833 | |||
1834 | FILE *fp; |
||
1835 | remove_from_last((char*)files->At(0)->GetTitle(), '_', ctemp); |
||
1836 | sprintf(paramname, "%s_fitresult.txt", ctemp); |
||
1837 | fp = fopen(paramname, "w"); |
||
1838 | fclose(fp); |
||
1839 | |||
129 | f9daq | 1840 | int peaklimit = minPeak->GetNumber()+1; // +1 to account for the pedestal peak |
1841 | printf("The minimum peak limit is set to: %d\n", peaklimit); |
||
117 | f9daq | 1842 | int p = 0; |
1843 | double dtemp; |
||
1844 | double volt[files->GetSize()], volterr[files->GetSize()], sep[3][files->GetSize()], seperr[3][files->GetSize()]; |
||
129 | f9daq | 1845 | int first = 1; |
1846 | |||
1847 | // Initialize all values |
||
117 | f9daq | 1848 | for(int m = 0; m < files->GetSize(); m++) |
1849 | { |
||
1850 | volt[m] = 0; volterr[m] = 0; |
||
1851 | for(int i = 0; i < 3; i++) |
||
1852 | { sep[i][m] = 0; seperr[i][m] = 0; } |
||
129 | f9daq | 1853 | if(m < 20) { meanparam[m] = 0; meanparamerr[m] = 0; } |
117 | f9daq | 1854 | } |
1855 | |||
1856 | for(int m = 0; m < files->GetSize(); m++) |
||
1857 | { |
||
1858 | DisplayHistogram( (char*)(files->At(m)->GetTitle()), 0); |
||
1859 | dtemp = evtheader.biasvolt; |
||
1860 | gCanvas->Modified(); |
||
1861 | gCanvas->Update(); |
||
1862 | |||
1863 | histtemp = (TH1F*)gCanvas->GetPrimitive(histname); |
||
1864 | npeaks = 20; |
||
1865 | double par[3000]; |
||
1866 | spec = new TSpectrum(npeaks); |
||
1867 | // Find spectrum background |
||
1868 | histback = spec->Background(histtemp, (int)fitInter->GetNumber(), "same"); |
||
1869 | // Clone histogram and subtract background from it |
||
1870 | h2 = (TH1F*)histtemp->Clone("h2"); |
||
1871 | h2->Add(histback, -1); |
||
1872 | // Search for the peaks |
||
1873 | int found = spec->Search(h2, fitSigma->GetNumber(), "goff", fitTresh->GetNumber() ); |
||
1874 | printf("Found %d candidates to fit.\n",found); |
||
1875 | npeaks = found; |
||
1876 | |||
1877 | xpeaks = spec->GetPositionX(); |
||
1878 | for(int i = 0; i < found; i++) |
||
1879 | { |
||
1880 | float xp = xpeaks[i]; |
||
1881 | int bin = h2->GetXaxis()->FindBin(xp); |
||
1882 | float yp = h2->GetBinContent(bin); |
||
1883 | par[3*i] = yp; |
||
1884 | par[3*i+1] = xp; |
||
1885 | par[3*i+2] = (double)fitSigma->GetNumber(); |
||
1886 | } |
||
1887 | |||
1888 | // Fit the histogram |
||
1889 | fit = new TF1("fit", FindPeaks, 0, 400, 3*npeaks); |
||
1890 | TVirtualFitter::Fitter(histtemp, 3*npeaks); |
||
1891 | fit->SetParameters(par); |
||
1892 | fit->SetNpx(300); |
||
1893 | h2->Fit("fit","Q"); // for quiet mode, add Q |
||
1894 | fittingfunc = h2->GetFunction("fit"); |
||
1895 | fparam = fittingfunc->GetParameters(); |
||
1896 | fparamerr = fittingfunc->GetParErrors(); |
||
1897 | |||
1898 | // Gather the parameters (mean peak value for now) |
||
1899 | int j = 1; |
||
1900 | int nrfit = 0; |
||
129 | f9daq | 1901 | bool errors = false; |
117 | f9daq | 1902 | while(1) |
1903 | { |
||
1904 | if( (fparam[j] < 1.E-30) || (fparamerr[j] < 1.E-10) ) |
||
1905 | break; |
||
1906 | else |
||
1907 | { |
||
129 | f9daq | 1908 | if(fparam[j] > pedesLow->GetNumber()) |
117 | f9daq | 1909 | { |
1910 | meanparam[nrfit] = fparam[j]; |
||
1911 | meanparamerr[nrfit] = fparamerr[j]; |
||
1912 | nrfit++; |
||
1913 | } |
||
1914 | } |
||
1915 | |||
1916 | j+=3; |
||
1917 | } |
||
129 | f9daq | 1918 | printf("%d peaks fitted.\n",nrfit); |
117 | f9daq | 1919 | |
129 | f9daq | 1920 | if(nrfit >= peaklimit) |
117 | f9daq | 1921 | { |
129 | f9daq | 1922 | TMath::Sort(nrfit, meanparam, sortindex, kFALSE); |
128 | f9daq | 1923 | |
129 | f9daq | 1924 | // Write out parameters to a file |
1925 | // fp = fopen(paramname, "a"); |
||
1926 | |||
1927 | // Only save the ones that do not have a too large error on peak separation for the first three peaks |
||
1928 | // if( ((TMath::Abs(meanparamerr[sortindex[2]]) + TMath::Abs(meanparamerr[sortindex[1]]))/(meanparam[sortindex[2]] - meanparam[sortindex[1]]) < accError->GetNumber()) && ((TMath::Abs(meanparamerr[sortindex[3]]) + TMath::Abs(meanparamerr[sortindex[2]]))/(meanparam[sortindex[3]] - meanparam[sortindex[2]]) < accError->GetNumber()) && ((TMath::Abs(meanparamerr[sortindex[4]]) + TMath::Abs(meanparamerr[sortindex[3]]))/(meanparam[sortindex[4]] - meanparam[sortindex[3]]) < accError->GetNumber()) ) |
||
1929 | // if( (seperr[0][0]/sep[0][0] < accError->GetNumber()) && (seperr[1][0]/sep[1][0] < accError->GetNumber()) && (seperr[2][0]/sep[2][0] < accError->GetNumber()) ) |
||
1930 | // { |
||
1931 | // fprintf(fp, "%le\t%d\t", dtemp, nrfit); |
||
1932 | |||
1933 | // for(int i = 0; i < nrfit; i++) |
||
1934 | // { |
||
1935 | // if(debug) |
||
1936 | // printf("Peak %d (%lfV): %lf\t%lf\n", i+1, dtemp, meanparam[sortindex[i]], meanparamerr[sortindex[i]]); |
||
1937 | // fprintf(fp, "%le\t%le\t", meanparam[sortindex[i]], meanparamerr[sortindex[i]]); |
||
1938 | // } |
||
1939 | // printf("\n"); |
||
1940 | // fprintf(fp, "\n"); |
||
1941 | // } |
||
1942 | |||
1943 | // fclose(fp); |
||
1944 | |||
1945 | h2->SetStats(0); |
||
1946 | |||
1947 | gCanvas->Modified(); |
||
1948 | gCanvas->Update(); |
||
1949 | |||
1950 | // Save each fitting plot |
||
1951 | if(exfitplots->IsDown()) |
||
128 | f9daq | 1952 | { |
129 | f9daq | 1953 | remove_ext((char*)files->At(m)->GetTitle(), ctemp); |
1954 | sprintf(exportname, "%s_fit.pdf", ctemp); |
||
1955 | gCanvas->SaveAs(exportname); |
||
128 | f9daq | 1956 | } |
129 | f9daq | 1957 | |
1958 | volt[p] = dtemp; |
||
1959 | volterr[p] = 1.e-4; |
||
117 | f9daq | 1960 | |
129 | f9daq | 1961 | if(nrfit == 3) |
1962 | { |
||
1963 | sep[0][p] = meanparam[sortindex[2]] - meanparam[sortindex[1]]; |
||
1964 | seperr[0][p] = TMath::Abs(meanparamerr[sortindex[2]]) + TMath::Abs(meanparamerr[sortindex[1]]); |
||
117 | f9daq | 1965 | |
129 | f9daq | 1966 | errors = (seperr[0][p]/sep[0][p] < accError->GetNumber()); |
117 | f9daq | 1967 | |
129 | f9daq | 1968 | if(debug) |
1969 | printf("p=%d:\t%lf\t%lf\t%lf\n", p, volt[p], sep[0][p], seperr[0][p]); |
||
1970 | } |
||
1971 | else if(nrfit == 4) |
||
1972 | { |
||
1973 | sep[0][p] = meanparam[sortindex[2]] - meanparam[sortindex[1]]; |
||
1974 | sep[1][p] = meanparam[sortindex[3]] - meanparam[sortindex[2]]; |
||
1975 | seperr[0][p] = TMath::Abs(meanparamerr[sortindex[2]]) + TMath::Abs(meanparamerr[sortindex[1]]); |
||
1976 | seperr[1][p] = TMath::Abs(meanparamerr[sortindex[3]]) + TMath::Abs(meanparamerr[sortindex[2]]); |
||
117 | f9daq | 1977 | |
129 | f9daq | 1978 | errors = ((seperr[0][p]/sep[0][p] < accError->GetNumber()) && (seperr[1][p]/sep[1][p] < accError->GetNumber())); |
1979 | |||
1980 | if(debug) |
||
1981 | printf("p=%d:\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]); |
||
1982 | } |
||
1983 | else if(nrfit > 4) |
||
1984 | { |
||
1985 | sep[0][p] = meanparam[sortindex[2]] - meanparam[sortindex[1]]; |
||
1986 | sep[1][p] = meanparam[sortindex[3]] - meanparam[sortindex[2]]; |
||
1987 | sep[2][p] = meanparam[sortindex[4]] - meanparam[sortindex[3]]; |
||
1988 | seperr[0][p] = TMath::Abs(meanparamerr[sortindex[2]]) + TMath::Abs(meanparamerr[sortindex[1]]); |
||
1989 | seperr[1][p] = TMath::Abs(meanparamerr[sortindex[3]]) + TMath::Abs(meanparamerr[sortindex[2]]); |
||
1990 | seperr[2][p] = TMath::Abs(meanparamerr[sortindex[4]]) + TMath::Abs(meanparamerr[sortindex[3]]); |
||
1991 | |||
1992 | errors = ((seperr[0][p]/sep[0][p] < accError->GetNumber()) && (seperr[1][p]/sep[1][p] < accError->GetNumber()) && (seperr[2][p]/sep[2][p] < accError->GetNumber())); |
||
1993 | |||
1994 | if(debug) |
||
1995 | 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]); |
||
1996 | } |
||
1997 | |||
1998 | // Write out parameters to a file |
||
1999 | fp = fopen(paramname, "a"); |
||
2000 | |||
117 | f9daq | 2001 | // Accept only the points with a small enough error |
129 | f9daq | 2002 | if( errors ) |
2003 | { |
||
2004 | if(first == 1) |
||
2005 | { |
||
2006 | fprintf(fp, "%le\t%d\t", dtemp, nrfit); |
||
2007 | |||
2008 | for(int i = 0; i < nrfit; i++) |
||
2009 | { |
||
2010 | if(debug) |
||
2011 | printf("Peak %d (%lfV): %lf\t%lf\n", i+1, dtemp, meanparam[sortindex[i]], meanparamerr[sortindex[i]]); |
||
2012 | fprintf(fp, "%le\t%le\t", meanparam[sortindex[i]], meanparamerr[sortindex[i]]); |
||
2013 | } |
||
2014 | printf("\n"); |
||
2015 | fprintf(fp, "\n"); |
||
2016 | first = 0; |
||
2017 | } |
||
2018 | |||
117 | f9daq | 2019 | p++; |
129 | f9daq | 2020 | } |
117 | f9daq | 2021 | else |
129 | f9daq | 2022 | { |
2023 | if(nrfit == 3) |
||
2024 | printf("Point (at %.2lfV) rejected due to too large errors: %lf\n", volt[p], seperr[0][p]/sep[0][p]); |
||
2025 | else if(nrfit == 4) |
||
2026 | printf("Point (at %.2lfV) rejected due to too large errors: %lf, %lf\n", volt[p], seperr[0][p]/sep[0][p], seperr[1][p]/sep[1][p]); |
||
2027 | else if(nrfit > 4) |
||
2028 | printf("Point (at %.2lfV) rejected due to too large 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]); |
||
2029 | } |
||
2030 | |||
2031 | fclose(fp); |
||
117 | f9daq | 2032 | } |
2033 | |||
2034 | if(q == 1) break; |
||
129 | f9daq | 2035 | |
2036 | first = 1; |
||
117 | f9daq | 2037 | } |
2038 | |||
2039 | // Plot & fit breakdown voltage plots |
||
2040 | if(q > 1) |
||
2041 | { |
||
2042 | remove_from_last((char*)files->At(0)->GetTitle(), '_', ctemp); |
||
2043 | sprintf(paramname, "%s_breakdown.pdf", ctemp); |
||
129 | f9daq | 2044 | MakeBreakdownPlot(p, volt, volterr, sep[0], seperr[0], sep[1], seperr[1], sep[2], seperr[2], paramname, peaklimit-2); |
117 | f9daq | 2045 | } |
2046 | } |
||
2047 | |||
2048 | // Plotting of PDF and CDF functions for the edge (with the added fit) |
||
2049 | void TGAppMainFrame::EdgeDetection(TGraph *pdf, TGraph *cdf, char *outname, TCanvas *g1dCanvas, double pdfmax, int direction) |
||
2050 | { |
||
2051 | // double x, y; |
||
2052 | |||
2053 | pdf->Fit("gaus","Q"); |
||
2054 | pdf->GetFunction("gaus")->SetNpx(400); |
||
2055 | /* |
||
2056 | for(int i = 0; i < nrpoints; i++) |
||
2057 | { |
||
2058 | pdf->GetPoint(i, x, y); |
||
2059 | pdf->SetPoint(i, x, (y/pdfmax) ); |
||
2060 | } |
||
2061 | */ |
||
2062 | gStyle->SetOptFit(1); |
||
2063 | |||
2064 | cdf->Draw("AL"); |
||
2065 | gPad->Update(); |
||
2066 | pdf->Draw("LP"); |
||
2067 | |||
2068 | g1dCanvas->Modified(); |
||
2069 | g1dCanvas->Update(); |
||
2070 | |||
2071 | TPaveStats *stats = (TPaveStats*)pdf->FindObject("stats"); |
||
2072 | if(!cleanPlots) |
||
2073 | { |
||
2074 | // stats->SetX1NDC(0.14); stats->SetX2NDC(0.28); |
||
2075 | // stats->SetY1NDC(0.83); stats->SetY2NDC(0.96); |
||
2076 | stats->SetX1NDC(0.86); stats->SetX2NDC(1.0); |
||
2077 | stats->SetY1NDC(0.87); stats->SetY2NDC(1.0); |
||
2078 | } |
||
2079 | else |
||
2080 | { |
||
2081 | stats->SetX1NDC(1.1); stats->SetX2NDC(1.3); |
||
2082 | stats->SetY1NDC(1.1); stats->SetY2NDC(1.3); |
||
2083 | } |
||
2084 | |||
2085 | g1dCanvas->SetGridx(1); |
||
2086 | g1dCanvas->SetGridy(1); |
||
2087 | if(direction == 1) |
||
2088 | cdf->GetXaxis()->SetTitle("X [#mum]"); |
||
2089 | else if(direction == 2) |
||
2090 | cdf->GetXaxis()->SetTitle("Y [#mum]"); |
||
2091 | cdf->GetXaxis()->CenterTitle(kTRUE); |
||
2092 | cdf->GetXaxis()->SetLabelSize(0.022); |
||
2093 | cdf->GetYaxis()->SetTitle("Normalized ADC integral"); |
||
2094 | // cdf->GetYaxis()->SetTitle("Normalized ADC integral (CDF)"); |
||
2095 | // cdf->GetYaxis()->SetTitleColor(kBlue); |
||
2096 | cdf->GetYaxis()->CenterTitle(kTRUE); |
||
2097 | cdf->GetYaxis()->SetLabelSize(0.022); |
||
2098 | cdf->GetYaxis()->SetRangeUser(0,1); |
||
2099 | cdf->GetYaxis()->SetTitleSize(0.030); |
||
2100 | // cdf->GetYaxis()->SetLabelColor(kBlue); |
||
2101 | if(!cleanPlots) |
||
2102 | cdf->SetTitle("SiPM edge detection"); |
||
2103 | else |
||
2104 | cdf->SetTitle(); |
||
2105 | cdf->SetLineColor(kBlue); |
||
2106 | pdf->SetLineWidth(2); |
||
2107 | cdf->SetLineWidth(2); |
||
2108 | |||
2109 | /* TGaxis *axis = new TGaxis(gPad->GetUxmax(), 0, gPad->GetUxmax(), 1, 0, pdfmax, 510, "+L"); |
||
2110 | axis->Draw(); |
||
2111 | axis->SetTitle("Normalized ADC integral (PDF)"); |
||
2112 | axis->SetTitleSize(0.035); |
||
2113 | axis->CenterTitle(); |
||
2114 | axis->SetTitleColor(kBlack); |
||
2115 | axis->SetTitleFont(42); |
||
2116 | axis->SetLabelSize(0.022); |
||
2117 | axis->SetLabelColor(kBlack);*/ |
||
2118 | |||
2119 | g1dCanvas->Modified(); |
||
2120 | g1dCanvas->Update(); |
||
2121 | |||
2122 | g1dCanvas->SaveAs(outname); |
||
2123 | } |
||
2124 | |||
2125 | // Integrate the spectrum |
||
2126 | void TGAppMainFrame::IntegSpectrum(TList *files, int direction) |
||
2127 | { |
||
2128 | unsigned int nrfiles = fileList->GetNumberOfEntries(); |
||
2129 | char ctemp[256]; |
||
2130 | int j, k = 0, m = 0, n = 0; |
||
2131 | |||
2132 | TCanvas *gCanvas = new TCanvas("canv","canv",900,900); |
||
2133 | TCanvas *g1dCanvas = new TCanvas("canv1d","canv1d",1200,900); |
||
2134 | TTree *header_data, *meas_data; |
||
2135 | double *integralCount, *integralAcc; |
||
2136 | integralCount = new double[nrfiles]; |
||
2137 | integralAcc = new double[nrfiles]; |
||
2138 | // double xsurfmin, ysurfmin, zsurfmin; |
||
2139 | double *surfx, *surfy, *surfz; |
||
2140 | surfx = new double[nrfiles]; |
||
2141 | surfy = new double[nrfiles]; |
||
2142 | surfz = new double[nrfiles]; |
||
2143 | for(int i = 0; i < (int)nrfiles; i++) {integralCount[i] = 0; integralAcc[i] = 0; } |
||
2144 | |||
2145 | TGraph *gScan[2]; // graphs for PDF and CDF functions |
||
2146 | double pdfmax = -1; |
||
2147 | TGraph2D *gScan2D; |
||
2148 | gScan2D = new TGraph2D(); |
||
2149 | int nrentries; |
||
2150 | double minInteg, maxInteg; |
||
2151 | |||
2152 | char exportname[256]; |
||
2153 | |||
2154 | if(files->GetSize() > 0) |
||
2155 | { |
||
2156 | for(int i = 0; i < (int)files->GetSize(); i++) |
||
2157 | { |
||
2158 | n++; |
||
2159 | if(files->At(i)) |
||
2160 | { |
||
2161 | sprintf(ctemp, "%s", files->At(i)->GetTitle()); |
||
2162 | inroot = new TFile(ctemp, "READ"); |
||
2163 | |||
2164 | inroot->GetObject("header_data", header_data); |
||
2165 | inroot->GetObject("meas_data", meas_data); |
||
2166 | |||
2167 | // Reading the header |
||
2168 | header_data->SetBranchAddress("xpos", &evtheader.xpos); |
||
2169 | header_data->GetEntry(0); |
||
2170 | header_data->SetBranchAddress("ypos", &evtheader.ypos); |
||
2171 | header_data->GetEntry(0); |
||
2172 | header_data->SetBranchAddress("zpos", &evtheader.zpos); |
||
2173 | header_data->GetEntry(0); |
||
2174 | |||
2175 | char rdc[256]; |
||
2176 | j = selectCh->GetNumber(); |
||
2177 | double rangetdc[2]; |
||
2178 | rangetdc[0] = tdcMinwindow->GetNumber(); |
||
2179 | rangetdc[1] = tdcMaxwindow->GetNumber(); |
||
2180 | |||
2181 | k = 0; |
||
2182 | m = 0; |
||
2183 | |||
2184 | // Reading the data |
||
2185 | for(int e = 0; e < meas_data->GetEntries(); e++) |
||
2186 | { |
||
2187 | sprintf(rdc, "ADC%d", j); |
||
2188 | meas_data->SetBranchAddress(rdc, &evtdata.adcdata[j]); |
||
2189 | meas_data->GetEntry(e); |
||
2190 | |||
2191 | sprintf(rdc, "TDC%d", j); |
||
2192 | meas_data->SetBranchAddress(rdc, &evtdata.tdcdata[j]); |
||
2193 | meas_data->GetEntry(e); |
||
2194 | |||
2195 | // If our data point is inside the TDC window |
||
2196 | if( ((double)evtdata.tdcdata[j]/tdctimeconversion >= rangetdc[0]) && ((double)evtdata.tdcdata[j]/tdctimeconversion <= rangetdc[1]) ) |
||
2197 | { |
||
2198 | k++; |
||
2199 | m += evtdata.adcdata[j]; |
||
2200 | } |
||
2201 | } |
||
2202 | |||
2203 | /* if(n == 1) // these values can be used to set 0 value at first X, Y and Z positions |
||
2204 | { |
||
2205 | xsurfmin = evtheader.xpos; |
||
2206 | ysurfmin = evtheader.ypos; |
||
2207 | zsurfmin = evtheader.zpos; |
||
2208 | } |
||
2209 | surfx[i] = (double)(evtheader.xpos-xsurfmin)*lenconversion; |
||
2210 | surfy[i] = (double)(evtheader.ypos-ysurfmin)*lenconversion; |
||
2211 | surfz[i] = (double)(evtheader.zpos-zsurfmin)*lenconversion;*/ |
||
2212 | surfx[i] = (double)(evtheader.xpos*lenconversion); |
||
2213 | surfy[i] = (double)(evtheader.ypos*lenconversion); |
||
2214 | surfz[i] = (double)(evtheader.zpos*lenconversion); |
||
2215 | |||
2216 | /* surfx[i] = evtheader.xpos; |
||
2217 | surfy[i] = evtheader.ypos; |
||
2218 | surfz[i] = evtheader.zpos; |
||
2219 | */ |
||
2220 | integralCount[i] += ((double)m)/((double)k); |
||
2221 | |||
129 | f9daq | 2222 | inroot->Close(); |
117 | f9daq | 2223 | delete inroot; |
2224 | } |
||
2225 | } |
||
2226 | |||
2227 | nrentries = n; |
||
2228 | printf("%d files were selected.\n", nrentries); |
||
2229 | |||
2230 | double curzval = surfz[0]; |
||
2231 | j = 0; |
||
2232 | int acc = 0; |
||
2233 | int zb; |
||
2234 | for(int i = 0; i <= nrentries; i++) |
||
2235 | { |
||
2236 | if(acc == nrentries) |
||
2237 | { |
||
2238 | minInteg = TMath::MinElement(j, integralAcc); |
||
2239 | |||
2240 | for(int za = 0; za < j; za++) |
||
2241 | integralAcc[za] = integralAcc[za] - minInteg; |
||
2242 | |||
2243 | maxInteg = TMath::MaxElement(j, integralAcc); |
||
2244 | |||
2245 | for(int za = 0; za < j; za++) |
||
2246 | { |
||
2247 | zb = i-j+za; |
||
2248 | integralCount[zb] = integralAcc[za]/maxInteg; |
||
128 | f9daq | 2249 | if(debug) |
117 | f9daq | 2250 | 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); |
2251 | } |
||
2252 | |||
2253 | // Plotting of PDF and CDF functions for the edge (with the added fit) |
||
2254 | gScan[1] = new TGraph(); |
||
2255 | for(int za = 0; za < j; za++) |
||
2256 | { |
||
2257 | zb = i-j+za; |
||
2258 | if(direction == 1) |
||
2259 | gScan[1]->SetPoint(za, (double)surfx[zb], (double)integralAcc[za]/maxInteg); |
||
2260 | else if(direction == 2) |
||
2261 | gScan[1]->SetPoint(za, (double)surfy[zb], (double)integralAcc[za]/maxInteg); |
||
2262 | |||
2263 | if( ((integralAcc[za+1]-integralAcc[za])/maxInteg > pdfmax) && (za < j-1) ) |
||
2264 | pdfmax = (integralAcc[za+1]-integralAcc[za])/maxInteg; |
||
2265 | } |
||
2266 | |||
2267 | pdfmax = (TMath::Ceil(pdfmax*10))/10.; |
||
2268 | |||
2269 | gScan[0] = new TGraph(); |
||
2270 | for(int za = j-1; za >= 0; za--) |
||
2271 | { |
||
2272 | zb = (i-1)-(j-1)+za; |
||
2273 | if((integralAcc[za]-integralAcc[za-1])/(maxInteg) < 0) |
||
2274 | { |
||
2275 | if(direction == 1) |
||
2276 | gScan[0]->SetPoint(za, (double)surfx[zb], 0); |
||
2277 | else if(direction == 2) |
||
2278 | gScan[0]->SetPoint(za, (double)surfy[zb], 0); |
||
2279 | } |
||
2280 | else |
||
2281 | { |
||
2282 | if(direction == 1) |
||
2283 | gScan[0]->SetPoint(za, (double)surfx[zb], (integralAcc[za]-integralAcc[za-1])/(maxInteg)); |
||
2284 | else if(direction == 2) |
||
2285 | gScan[0]->SetPoint(za, (double)surfy[zb], (integralAcc[za]-integralAcc[za-1])/(maxInteg)); |
||
2286 | // gScan[0]->SetPoint(za, (double)surfx[zb], (integralAcc[za]-integralAcc[za-1])/(pdfmax*maxInteg)); |
||
2287 | } |
||
2288 | } |
||
2289 | |||
2290 | remove_from_last((char*)files->At(i-1)->GetTitle(), '_', ctemp); |
||
2291 | sprintf(exportname, "%s_edge.pdf", ctemp); |
||
2292 | EdgeDetection(gScan[0], gScan[1], exportname, g1dCanvas, pdfmax, direction); |
||
2293 | |||
2294 | // delete gScan[0]; |
||
2295 | // delete gScan[1]; |
||
2296 | |||
2297 | i--; |
||
2298 | pdfmax = 0; |
||
2299 | break; |
||
2300 | } |
||
2301 | else |
||
2302 | { |
||
2303 | if(surfz[i] == curzval) |
||
2304 | { |
||
2305 | integralAcc[j] = integralCount[i]; |
||
128 | f9daq | 2306 | if(debug) |
117 | f9daq | 2307 | printf("Integral check 1 (i=%d,j=%d,z=%.2lf): %lf\t%lf\n", i, j, surfz[i], integralCount[i], integralAcc[j]); |
2308 | j++; |
||
2309 | acc++; |
||
2310 | } |
||
2311 | else |
||
2312 | { |
||
2313 | minInteg = TMath::MinElement(j, integralAcc); |
||
2314 | |||
2315 | for(int za = 0; za < j; za++) |
||
2316 | integralAcc[za] = integralAcc[za] - minInteg; |
||
2317 | |||
2318 | maxInteg = TMath::MaxElement(j, integralAcc); |
||
2319 | |||
2320 | for(int za = 0; za < j; za++) |
||
2321 | { |
||
2322 | zb = i-j+za; |
||
2323 | integralCount[zb] = integralAcc[za]/maxInteg; |
||
128 | f9daq | 2324 | if(debug) |
117 | f9daq | 2325 | 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); |
2326 | } |
||
2327 | |||
2328 | curzval = surfz[i]; |
||
2329 | i--; |
||
2330 | |||
2331 | // Plotting of PDF and CDF functions for the edge (with the added fit) |
||
2332 | gScan[1] = new TGraph(); |
||
2333 | for(int za = 0; za < j; za++) |
||
2334 | { |
||
2335 | zb = i-(j-1)+za; |
||
2336 | if(direction == 1) |
||
2337 | gScan[1]->SetPoint(za, (double)surfx[zb], (double)integralAcc[za]/maxInteg); |
||
2338 | else if(direction == 2) |
||
2339 | gScan[1]->SetPoint(za, (double)surfy[zb], (double)integralAcc[za]/maxInteg); |
||
2340 | |||
2341 | if( ((integralAcc[za+1]-integralAcc[za])/maxInteg > pdfmax) && (za < j-1) ) |
||
2342 | pdfmax = (integralAcc[za+1]-integralAcc[za])/maxInteg; |
||
2343 | } |
||
2344 | |||
2345 | pdfmax = (TMath::Ceil(pdfmax*10))/10.; |
||
2346 | |||
2347 | gScan[0] = new TGraph(); |
||
2348 | for(int za = j-1; za >= 0; za--) |
||
2349 | { |
||
2350 | zb = i-(j-1)+za; |
||
2351 | if((integralAcc[za]-integralAcc[za-1])/(maxInteg) < 0) |
||
2352 | { |
||
2353 | if(direction == 1) |
||
2354 | gScan[0]->SetPoint(za, (double)surfx[zb], 0); |
||
2355 | else if(direction == 2) |
||
2356 | gScan[0]->SetPoint(za, (double)surfy[zb], 0); |
||
2357 | } |
||
2358 | else |
||
2359 | { |
||
2360 | if(direction == 1) |
||
2361 | gScan[0]->SetPoint(za, (double)surfx[zb], (integralAcc[za]-integralAcc[za-1])/(maxInteg)); |
||
2362 | else if(direction == 2) |
||
2363 | gScan[0]->SetPoint(za, (double)surfy[zb], (integralAcc[za]-integralAcc[za-1])/(maxInteg)); |
||
2364 | // gScan[0]->SetPoint(za, (double)surfx[zb], (integralAcc[za]-integralAcc[za-1])/(pdfmax*maxInteg)); |
||
2365 | } |
||
2366 | } |
||
2367 | |||
2368 | remove_from_last((char*)files->At(i)->GetTitle(), '_', ctemp); |
||
2369 | sprintf(exportname, "%s_edge.pdf", ctemp); |
||
2370 | EdgeDetection(gScan[0], gScan[1], exportname, g1dCanvas, pdfmax, direction); |
||
2371 | |||
2372 | delete gScan[0]; |
||
2373 | delete gScan[1]; |
||
2374 | |||
2375 | j = 0; |
||
2376 | pdfmax = 0; |
||
2377 | } |
||
2378 | } |
||
2379 | } |
||
2380 | |||
2381 | // delete g1dCanvas; |
||
2382 | |||
2383 | double range[4]; |
||
2384 | if(direction == 1) |
||
2385 | { |
||
2386 | range[0] = TMath::MinElement(nrentries, surfx); |
||
2387 | range[1] = TMath::MaxElement(nrentries, surfx); |
||
2388 | } |
||
2389 | else if(direction == 2) |
||
2390 | { |
||
2391 | range[0] = TMath::MinElement(nrentries, surfy); |
||
2392 | range[1] = TMath::MaxElement(nrentries, surfy); |
||
2393 | } |
||
2394 | else |
||
2395 | { |
||
2396 | range[0] = TMath::MinElement(nrentries, surfx); |
||
2397 | range[1] = TMath::MaxElement(nrentries, surfx); |
||
2398 | } |
||
2399 | range[2] = TMath::MinElement(nrentries, surfz); |
||
2400 | range[3] = TMath::MaxElement(nrentries, surfz); |
||
2401 | |||
2402 | // Plotting of 2D edge plot |
||
2403 | for(int i = 0; i < nrentries; i++) |
||
2404 | { |
||
2405 | if(direction == 1) |
||
2406 | { |
||
128 | f9daq | 2407 | if(debug) |
117 | f9daq | 2408 | printf("%.2lf\t%.2lf\t%lf\n", surfx[i], surfz[i], integralCount[i]); |
2409 | gScan2D->SetPoint(i, surfx[i], surfz[i], integralCount[i]); |
||
2410 | } |
||
2411 | else if(direction == 2) |
||
2412 | { |
||
128 | f9daq | 2413 | if(debug) |
117 | f9daq | 2414 | printf("%.2lf\t%.2lf\t%lf\n", surfy[i], surfz[i], integralCount[i]); |
2415 | gScan2D->SetPoint(i, surfy[i], surfz[i], integralCount[i]); |
||
2416 | } |
||
2417 | } |
||
2418 | |||
2419 | gCanvas->cd(); |
||
2420 | gStyle->SetPalette(1); |
||
2421 | gScan2D->Draw("COLZ"); |
||
2422 | |||
2423 | gCanvas->Modified(); |
||
2424 | gCanvas->Update(); |
||
2425 | |||
2426 | if(direction == 1) |
||
2427 | gScan2D->GetXaxis()->SetTitle("X [#mum]"); |
||
2428 | else if(direction == 2) |
||
2429 | gScan2D->GetXaxis()->SetTitle("Y [#mum]"); |
||
2430 | gScan2D->GetXaxis()->CenterTitle(kTRUE); |
||
2431 | gScan2D->GetXaxis()->SetLabelSize(0.022); |
||
2432 | gScan2D->GetXaxis()->SetRangeUser(range[0], range[1]); |
||
2433 | gScan2D->GetXaxis()->SetNoExponent(); |
||
2434 | gScan2D->GetYaxis()->SetTitle("Z [#mum]"); |
||
2435 | gScan2D->GetYaxis()->SetTitleOffset(1.3); |
||
2436 | gScan2D->GetYaxis()->CenterTitle(kTRUE); |
||
2437 | gScan2D->GetYaxis()->SetLabelSize(0.022); |
||
2438 | gScan2D->GetYaxis()->SetRangeUser(range[2], range[3]); |
||
2439 | TGaxis *yax = (TGaxis*)gScan2D->GetYaxis(); |
||
2440 | yax->SetMaxDigits(4); |
||
2441 | if(!cleanPlots) |
||
2442 | gScan2D->SetTitle("Laser focal point"); |
||
2443 | else |
||
2444 | gScan2D->SetTitle(); |
||
2445 | |||
2446 | gCanvas->Modified(); |
||
2447 | gCanvas->Update(); |
||
2448 | |||
2449 | remove_from_last((char*)files->At(0)->GetTitle(), '_', ctemp); |
||
2450 | sprintf(exportname, "%s", ctemp); |
||
2451 | remove_from_last(exportname, '_', ctemp); |
||
2452 | if(direction == 1) |
||
2453 | sprintf(exportname, "%s_xdir_focalpoint.pdf", ctemp); |
||
2454 | else if(direction == 2) |
||
2455 | sprintf(exportname, "%s_ydir_focalpoint.pdf", ctemp); |
||
2456 | gCanvas->SaveAs(exportname); |
||
2457 | } |
||
2458 | } |
||
2459 | |||
128 | f9daq | 2460 | // Integrate the spectrum |
2461 | void TGAppMainFrame::PhotonMu(TList *files) |
||
2462 | { |
||
2463 | unsigned int nrfiles = fileList->GetNumberOfEntries(); |
||
2464 | char ctemp[256]; |
||
2465 | int j, k = 0, m = 0, n = 0, k2 = 0, m2 = 0; |
||
2466 | |||
129 | f9daq | 2467 | TCanvas *gCanvas; |
128 | f9daq | 2468 | TTree *header_data, *meas_data; |
2469 | double *integralCount, *integralPedestal; |
||
2470 | integralCount = new double[nrfiles]; |
||
2471 | integralPedestal = new double[nrfiles]; |
||
2472 | double *angle; |
||
129 | f9daq | 2473 | double *pdeval; |
128 | f9daq | 2474 | double *muval; |
2475 | angle = new double[nrfiles]; |
||
129 | f9daq | 2476 | pdeval = new double[nrfiles]; |
128 | f9daq | 2477 | muval = new double[nrfiles]; |
2478 | for(int i = 0; i < (int)nrfiles; i++) {integralCount[i] = 0; integralPedestal[i] = 0; } |
||
2479 | |||
2480 | // TGraph *gScan[2]; // graph for angle dependence |
||
2481 | int nrentries; |
||
2482 | |||
2483 | TSpectrum *spec; |
||
2484 | TH1F *histtemp; |
||
2485 | TH1 *histback; |
||
2486 | TH1F *h2; |
||
2487 | float *xpeaks; |
||
2488 | TF1 *fit; |
||
2489 | TF1 *fittingfunc; |
||
2490 | double *fparam; |
||
2491 | double meanparam; |
||
2492 | int adcpedestal[2]; |
||
2493 | double paramsigma = 0; |
||
2494 | |||
2495 | if(files->GetSize() > 0) |
||
2496 | { |
||
2497 | for(int i = 0; i < (int)files->GetSize(); i++) |
||
2498 | { |
||
2499 | n++; |
||
2500 | if(files->At(i)) |
||
2501 | { |
||
2502 | // Find the pedestal peak and the first minimum after pedestal ---------------- |
||
2503 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0); |
||
2504 | histCanvas->GetCanvas()->Modified(); |
||
2505 | histCanvas->GetCanvas()->Update(); |
||
2506 | |||
2507 | histtemp = (TH1F*)histCanvas->GetCanvas()->GetPrimitive(histname); |
||
2508 | npeaks = 1; |
||
2509 | double par[300]; |
||
2510 | spec = new TSpectrum(npeaks); |
||
2511 | // Find spectrum background |
||
2512 | histback = spec->Background(histtemp, (int)fitInter->GetNumber(), "same"); |
||
2513 | // Clone histogram and subtract background from it |
||
2514 | h2 = (TH1F*)histtemp->Clone("h2"); |
||
2515 | h2->Add(histback, -1); |
||
2516 | // Search for the peaks |
||
2517 | int found = spec->Search(h2, fitSigma->GetNumber(), "goff", fitTresh->GetNumber() ); |
||
2518 | printf("Found %d candidates to fit.\n",found); |
||
2519 | npeaks = found; |
||
2520 | |||
2521 | xpeaks = spec->GetPositionX(); |
||
2522 | for(j = 0; j < found; j++) |
||
2523 | { |
||
2524 | float xp = xpeaks[j]; |
||
2525 | int bin = h2->GetXaxis()->FindBin(xp); |
||
2526 | float yp = h2->GetBinContent(bin); |
||
2527 | par[3*j] = yp; |
||
2528 | par[3*j+1] = xp; |
||
2529 | par[3*j+2] = (double)fitSigma->GetNumber(); |
||
2530 | } |
||
2531 | |||
2532 | // Fit the histogram |
||
2533 | fit = new TF1("fit", FindPeaks, 0, 400, 3*npeaks); |
||
2534 | TVirtualFitter::Fitter(histtemp, 3*npeaks); |
||
2535 | fit->SetParameters(par); |
||
2536 | fit->SetNpx(300); |
||
2537 | h2->Fit("fit","Q"); // for quiet mode, add Q |
||
2538 | fittingfunc = h2->GetFunction("fit"); |
||
2539 | fparam = fittingfunc->GetParameters(); |
||
2540 | |||
2541 | // Gather the parameters (mean peak value for now) |
||
2542 | j = 1; |
||
2543 | |||
2544 | meanparam = fparam[j]; |
||
2545 | paramsigma = fparam[j+1]; |
||
2546 | |||
2547 | /* while(1) |
||
2548 | { |
||
2549 | if( (fparam[j] < 1.E-30) || (fparamerr[j] < 1.E-10) ) |
||
2550 | break; |
||
2551 | else |
||
2552 | { |
||
2553 | if(fparam[j] > 0) |
||
2554 | { |
||
2555 | meanparam = fparam[j]; |
||
2556 | meanparamerr = fparamerr[j]; |
||
2557 | paramsigma = fparam[j+1]; |
||
2558 | nrfit++; |
||
2559 | } |
||
2560 | } |
||
2561 | |||
2562 | j+=3; |
||
2563 | } |
||
2564 | */ |
||
2565 | histCanvas->GetCanvas()->Modified(); |
||
2566 | histCanvas->GetCanvas()->Update(); |
||
2567 | |||
2568 | j = 0; |
||
2569 | adcpedestal[0] = 0; |
||
2570 | adcpedestal[1] = -1; |
||
2571 | while(1) |
||
2572 | { |
||
2573 | int bin = histtemp->GetXaxis()->FindBin((int)(j+meanparam+paramsigma)); |
||
2574 | |||
2575 | int yp = histtemp->GetBinContent(bin); |
||
2576 | if(adcpedestal[1] == -1) |
||
2577 | { |
||
2578 | adcpedestal[0] = j+meanparam+paramsigma; |
||
2579 | adcpedestal[1] = yp; |
||
2580 | } |
||
2581 | else |
||
2582 | { |
||
2583 | if(adcpedestal[1] >= yp) |
||
2584 | { |
||
2585 | adcpedestal[0] = j+meanparam+paramsigma; |
||
2586 | adcpedestal[1] = yp; |
||
2587 | } |
||
2588 | else |
||
2589 | break; |
||
2590 | } |
||
2591 | |||
2592 | j++; |
||
2593 | if(j > 50) break; |
||
2594 | } |
||
2595 | |||
2596 | cout << "Pedestal ends with ADC value: " << adcpedestal[0] << endl; |
||
2597 | |||
2598 | // ---------------------------------------------------------------------------- |
||
2599 | |||
2600 | sprintf(ctemp, "%s", files->At(i)->GetTitle()); |
||
2601 | inroot = new TFile(ctemp, "READ"); |
||
2602 | |||
2603 | inroot->GetObject("header_data", header_data); |
||
2604 | inroot->GetObject("meas_data", meas_data); |
||
2605 | |||
2606 | // Reading the header |
||
129 | f9daq | 2607 | if( header_data->FindBranch("angle") ) |
2608 | { |
||
2609 | header_data->SetBranchAddress("angle", &evtheader.angle); |
||
2610 | header_data->GetEntry(0); |
||
2611 | } |
||
2612 | else |
||
2613 | { |
||
2614 | printf("Error! Selected file has no angle header value. Please edit header to add the angle header value.\n"); |
||
2615 | break; |
||
2616 | } |
||
128 | f9daq | 2617 | |
2618 | char rdc[256]; |
||
2619 | j = selectCh->GetNumber(); |
||
2620 | double rangetdc[2]; |
||
2621 | rangetdc[0] = tdcMinwindow->GetNumber(); |
||
2622 | rangetdc[1] = tdcMaxwindow->GetNumber(); |
||
2623 | |||
2624 | k = 0; |
||
2625 | k2 = 0; |
||
2626 | m = 0; |
||
2627 | m2 = 0; |
||
2628 | |||
2629 | // Reading the data |
||
2630 | for(int e = 0; e < meas_data->GetEntries(); e++) |
||
2631 | { |
||
2632 | sprintf(rdc, "ADC%d", j); |
||
2633 | meas_data->SetBranchAddress(rdc, &evtdata.adcdata[j]); |
||
2634 | meas_data->GetEntry(e); |
||
2635 | |||
2636 | sprintf(rdc, "TDC%d", j); |
||
2637 | meas_data->SetBranchAddress(rdc, &evtdata.tdcdata[j]); |
||
2638 | meas_data->GetEntry(e); |
||
2639 | |||
2640 | // If our data point is inside the TDC window |
||
2641 | if( ((double)evtdata.tdcdata[j]/tdctimeconversion >= rangetdc[0]) && ((double)evtdata.tdcdata[j]/tdctimeconversion <= rangetdc[1]) ) |
||
2642 | { |
||
2643 | // Gather only the integral of the pedestal |
||
2644 | if((double)evtdata.adcdata[j] < (double)adcpedestal[0]+0.5 ) |
||
2645 | { |
||
2646 | k2++; |
||
2647 | m2 += evtdata.adcdata[j]; |
||
2648 | } |
||
2649 | |||
2650 | // Gather the complete integral |
||
2651 | k++; |
||
2652 | m += evtdata.adcdata[j]; |
||
2653 | } |
||
2654 | } |
||
2655 | |||
129 | f9daq | 2656 | angle[i] = (double)(evtheader.angle); // angle in radians |
128 | f9daq | 2657 | |
2658 | // integralCount[i] += ((double)m)/((double)k); |
||
2659 | integralCount[i] += (double)m; |
||
2660 | cout << "Integral (" << k << " evts) = " << integralCount[i] << endl; |
||
2661 | |||
2662 | integralPedestal[i] += (double)m2; |
||
2663 | cout << "Integral (" << k2 << " evts) = " << integralPedestal[i] << endl; |
||
2664 | |||
2665 | muval[i] = -TMath::Log((double)k2/(double)k); |
||
129 | f9daq | 2666 | |
2667 | pdeval[i] = muval[i]/(muval[0]*TMath::Cos(angle[i]*TMath::ACos(-1.)/180.)); |
||
128 | f9daq | 2668 | |
129 | f9daq | 2669 | inroot->Close(); |
128 | f9daq | 2670 | delete inroot; |
2671 | } |
||
2672 | } |
||
2673 | |||
2674 | nrentries = n; |
||
2675 | printf("%d files were selected.\n", nrentries); |
||
2676 | |||
2677 | cout << "angle\tmu\trelative PDE\n" << endl; |
||
2678 | for(int i = 0; i < (int)files->GetSize(); i++) |
||
2679 | { |
||
2680 | // Relative PDE calculation |
||
129 | f9daq | 2681 | cout << angle[i] << "\t" << muval[i] << "\t" << pdeval[i] << endl; |
128 | f9daq | 2682 | } |
129 | f9daq | 2683 | |
2684 | // Plot mu and PDE angle dependance plots |
||
2685 | gCanvas = new TCanvas("canv","canv",1200,900); |
||
2686 | gCanvas->SetGrid(); |
||
2687 | |||
2688 | TGraph *pde = new TGraph(nrentries, angle, pdeval); |
||
2689 | pde->SetMarkerStyle(21); |
||
2690 | pde->SetMarkerSize(1.0); |
||
2691 | pde->SetMarkerColor(2); |
||
2692 | pde->SetLineWidth(2); |
||
2693 | pde->SetLineColor(2); |
||
2694 | pde->GetXaxis()->SetLabelSize(0.030); |
||
2695 | pde->GetXaxis()->CenterTitle(); |
||
2696 | pde->GetXaxis()->SetRange(-5,90); |
||
2697 | pde->GetXaxis()->SetRangeUser(-5,90); |
||
2698 | pde->GetYaxis()->SetTitleOffset(1.2); |
||
2699 | pde->GetYaxis()->SetLabelSize(0.030); |
||
2700 | pde->GetYaxis()->CenterTitle(); |
||
2701 | pde->GetYaxis()->SetRangeUser(0.3, 1.18); |
||
2702 | pde->Draw("ALP"); |
||
2703 | |||
2704 | pde->SetTitle(";Incidence angle (#circ);Relative PDE(#theta) / #mu(#theta)"); |
||
2705 | |||
2706 | TGraph *mugr = new TGraph(nrentries, angle, muval); |
||
2707 | mugr->SetMarkerStyle(20); |
||
2708 | mugr->SetMarkerSize(1.0); |
||
2709 | mugr->SetMarkerColor(4); |
||
2710 | mugr->SetLineWidth(2); |
||
2711 | mugr->SetLineColor(4); |
||
2712 | mugr->Draw("SAME;LP"); |
||
2713 | |||
2714 | gCanvas->Modified(); |
||
2715 | gCanvas->Update(); |
||
128 | f9daq | 2716 | } |
2717 | } |
||
2718 | |||
129 | f9daq | 2719 | void TGAppMainFrame::RunMeas(void *ptr, int runCase, int zaxisscan, int &scanon) |
117 | f9daq | 2720 | { |
2721 | printf("Start of Run, run case %d\n", runCase); |
||
2722 | float progVal; |
||
2723 | |||
2724 | char ctemp[256]; |
||
127 | f9daq | 2725 | char ctemp2[256]; |
117 | f9daq | 2726 | char fname[256]; |
127 | f9daq | 2727 | int itemp = 0; |
117 | f9daq | 2728 | |
2729 | remove_ext((char*)fileName->GetText(), ctemp); |
||
2730 | // printf("Save name: %s\nNo extension: %s\n", fileName->GetText(), ctemp); |
||
2731 | |||
2732 | // Open file for writing |
||
2733 | /* if(runCase == 0) |
||
2734 | { |
||
2735 | sprintf(fname, "rm %s_%s", ctemp, histExtAll); |
||
2736 | retTemp = system(fname); |
||
2737 | }*/ // deleting might not be necesary due to RECREATE in root file open |
||
2738 | |||
2739 | if( voltscanOn->IsOn() || surfscanOn->IsOn() ) |
||
2740 | { |
||
2741 | if(zaxisscan == 0) |
||
2742 | { |
||
127 | f9daq | 2743 | if( (voltscanOn->IsOn()) && (vOutStep->GetNumber() > 0.) ) |
2744 | SeqNumber(runCase, (int)((vOutStop->GetNumber())-(vOutStart->GetNumber()))/(vOutStep->GetNumber()), ctemp2); |
||
2745 | else if( surfscanOn->IsOn() ) |
||
2746 | { |
||
2747 | if( xPosStep->GetNumber() == 0 ) |
||
2748 | itemp = 1; |
||
2749 | else |
||
2750 | itemp = (int)((xPosMax->GetNumber())-(xPosMin->GetNumber()))/(xPosStep->GetNumber()); |
||
2751 | |||
2752 | if( yPosStep->GetNumber() == 0 ) |
||
2753 | itemp *= 1; |
||
2754 | else |
||
2755 | itemp *= (int)((yPosMax->GetNumber())-(yPosMin->GetNumber()))/(yPosStep->GetNumber()); |
||
2756 | SeqNumber(runCase, itemp, ctemp2); |
||
2757 | } |
||
2758 | sprintf(fname, "%s_%s%s", ctemp, ctemp2, histExt); |
||
117 | f9daq | 2759 | } |
2760 | else if(zaxisscan == 1) |
||
2761 | { |
||
127 | f9daq | 2762 | SeqNumber((int)zPos->GetNumber(), (int)zPosMax->GetNumber(), ctemp2); |
2763 | |||
2764 | if( (voltscanOn->IsOn()) && (vOutStep->GetNumber() > 0.) ) |
||
2765 | { |
||
2766 | sprintf(fname, "%s_z%s_", ctemp, ctemp2); |
||
2767 | SeqNumber(runCase, (int)((vOutStop->GetNumber())-(vOutStart->GetNumber()))/(vOutStep->GetNumber())+1, ctemp2); |
||
2768 | strcat(fname, ctemp2); |
||
2769 | strcat(fname, histExt); |
||
2770 | } |
||
2771 | else if( surfscanOn->IsOn() ) |
||
2772 | { |
||
2773 | sprintf(fname, "%s_z%s_", ctemp, ctemp2); |
||
2774 | |||
2775 | if( xPosStep->GetNumber() == 0 ) |
||
2776 | itemp = 1; |
||
2777 | else |
||
2778 | itemp = (int)((xPosMax->GetNumber())-(xPosMin->GetNumber()))/(xPosStep->GetNumber())+1; |
||
2779 | |||
2780 | if( yPosStep->GetNumber() == 0 ) |
||
2781 | itemp *= 1; |
||
2782 | else |
||
2783 | itemp *= (int)((yPosMax->GetNumber())-(yPosMin->GetNumber()))/(yPosStep->GetNumber())+1; |
||
2784 | SeqNumber(runCase, itemp, ctemp2); |
||
2785 | strcat(fname, ctemp2); |
||
2786 | strcat(fname, histExt); |
||
2787 | } |
||
2788 | else |
||
2789 | sprintf(fname, "%s_z%s%s", ctemp, ctemp2, histExt); |
||
2790 | |||
2791 | /* if(runCase < 10) |
||
117 | f9daq | 2792 | sprintf(fname, "%s_z%d_0000%d%s", ctemp, (int)zPos->GetNumber(), runCase, histExt); |
2793 | else if( (runCase >= 10) && (runCase < 100) ) |
||
2794 | sprintf(fname, "%s_z%d_000%d%s", ctemp, (int)zPos->GetNumber(), runCase, histExt); |
||
2795 | else if( (runCase >= 100) && (runCase < 1000) ) |
||
2796 | sprintf(fname, "%s_z%d_00%d%s", ctemp, (int)zPos->GetNumber(), runCase, histExt); |
||
2797 | else if( (runCase >= 1000) && (runCase < 10000) ) |
||
2798 | sprintf(fname, "%s_z%d_0%d%s", ctemp, (int)zPos->GetNumber(), runCase, histExt); |
||
2799 | else if( (runCase >= 10000) && (runCase < 100000) ) |
||
2800 | sprintf(fname, "%s_z%d_0%d%s", ctemp, (int)zPos->GetNumber(), runCase, histExt); |
||
127 | f9daq | 2801 | */ } |
117 | f9daq | 2802 | } |
2803 | else if( !voltscanOn->IsOn() && !surfscanOn->IsOn() ) |
||
2804 | sprintf(fname, "%s%s", ctemp, histExt); |
||
2805 | // printf("Rootfile: %s\n", fname); |
||
2806 | |||
2807 | // Check if set voltage is below the hard limit |
||
2808 | if( vOut->GetNumber() > vHardlimit->GetNumber() ) |
||
2809 | { |
||
2810 | printf("Voltage hard limit triggered (%lf > %lf)!\n", vOut->GetNumber(), vHardlimit->GetNumber() ); |
||
2811 | vOut->SetNumber( vHardlimit->GetNumber() ); |
||
2812 | } |
||
2813 | |||
2814 | outroot = new TFile(fname, "RECREATE"); |
||
2815 | |||
2816 | TTree *header_data = new TTree("header_data", "Header information for the measurement."); |
||
127 | f9daq | 2817 | TTree *meas_data = new TTree("meas_data", "Saved ADC and TDC measurement data."); |
2818 | TTree *scope_data = new TTree("scope_data", "Saved scope measurement data."); |
||
117 | f9daq | 2819 | |
2820 | // Branches for the header |
||
2821 | header_data->Branch("nrch", &evtheader.nrch, "nrch/I"); |
||
2822 | header_data->Branch("timestamp", &evtheader.timestamp, "timestamp/I"); |
||
2823 | header_data->Branch("biasvolt", &evtheader.biasvolt, "biasvolt/D"); |
||
2824 | header_data->Branch("xpos", &evtheader.xpos, "xpos/I"); |
||
2825 | header_data->Branch("ypos", &evtheader.ypos, "ypos/I"); |
||
2826 | header_data->Branch("zpos", &evtheader.zpos, "zpos/I"); |
||
2827 | header_data->Branch("temperature", &evtheader.temperature, "temperature/D"); |
||
2828 | header_data->Branch("laserinfo", &evtheader.laserinfo, "laserinfo/C"); |
||
2829 | |||
2830 | evtheader.nrch = (int)NCH->GetNumber()*2; |
||
2831 | evtheader.timestamp = (int)time(NULL); |
||
2832 | evtheader.biasvolt = (double)vOut->GetNumber(); |
||
2833 | evtheader.xpos = (int)xPos->GetNumber(); |
||
2834 | evtheader.ypos = (int)yPos->GetNumber(); |
||
2835 | evtheader.zpos = (int)zPos->GetNumber(); |
||
127 | f9daq | 2836 | evtheader.temperature = (double)chtemp->GetNumber(); |
128 | f9daq | 2837 | evtheader.angle = (double)incangle->GetNumber(); |
117 | f9daq | 2838 | sprintf(evtheader.laserinfo, "%s", laserInfo->GetText()); |
2839 | |||
2840 | char histtime[256]; |
||
2841 | GetTime(evtheader.timestamp, histtime); |
||
2842 | |||
2843 | printf("Save file header information:\n"); |
||
2844 | printf("- Number of channels: %d\n", evtheader.nrch); |
||
2845 | printf("- Timestamp: %d (%s)\n", evtheader.timestamp, histtime); |
||
2846 | printf("- Bias voltage: %lf\n", evtheader.biasvolt); |
||
2847 | printf("- Table position (X,Y,Z): %d, %d, %d\n", evtheader.xpos, evtheader.ypos, evtheader.zpos); |
||
2848 | printf("- Temperature: %lf\n", evtheader.temperature); |
||
2849 | printf("- Laser and filter settings: %s\n", evtheader.laserinfo); |
||
2850 | |||
2851 | header_data->Fill(); |
||
2852 | |||
2853 | // Branches for ADC and TDC data |
||
2854 | for(int i = 0; i < evtheader.nrch/2; i++) |
||
2855 | { |
||
2856 | sprintf(ctemp, "ADC%d", i); |
||
2857 | sprintf(fname, "ADC%d/I", i); |
||
2858 | meas_data->Branch(ctemp, &evtdata.adcdata[i], fname); |
||
2859 | |||
2860 | sprintf(ctemp, "TDC%d", i); |
||
2861 | sprintf(fname, "TDC%d/I", i); |
||
2862 | meas_data->Branch(ctemp, &evtdata.tdcdata[i], fname); |
||
2863 | } |
||
2864 | |||
127 | f9daq | 2865 | // Initialize the scope before measurement |
2866 | if( sCamaclink->IsDown() ) |
||
2867 | InitializeScope(); |
||
2868 | |||
2869 | // Branch for scope measurement data |
||
2870 | if(gScopeDaq->scopeUseType == 2) // only if we select waveform measurement |
||
2871 | { |
||
2872 | if(gScopeDaq->scopeMeasSel == 0) |
||
2873 | scope_data->Branch("amp", &evtmeas.measdata, "amp/D"); |
||
2874 | else if(gScopeDaq->scopeMeasSel == 1) |
||
2875 | scope_data->Branch("area", &evtmeas.measdata, "area/D"); |
||
2876 | else if(gScopeDaq->scopeMeasSel == 2) |
||
2877 | scope_data->Branch("delay", &evtmeas.measdata, "delay/D"); |
||
2878 | else if(gScopeDaq->scopeMeasSel == 3) |
||
2879 | scope_data->Branch("fall", &evtmeas.measdata, "fall/D"); |
||
2880 | else if(gScopeDaq->scopeMeasSel == 4) |
||
2881 | scope_data->Branch("freq", &evtmeas.measdata, "freq/D"); |
||
2882 | else if(gScopeDaq->scopeMeasSel == 5) |
||
2883 | scope_data->Branch("max", &evtmeas.measdata, "max/D"); |
||
2884 | else if(gScopeDaq->scopeMeasSel == 6) |
||
2885 | scope_data->Branch("mean", &evtmeas.measdata, "mean/D"); |
||
2886 | else if(gScopeDaq->scopeMeasSel == 7) |
||
2887 | scope_data->Branch("min", &evtmeas.measdata, "min/D"); |
||
2888 | else if(gScopeDaq->scopeMeasSel == 8) |
||
2889 | scope_data->Branch("pk2p", &evtmeas.measdata, "pk2p/D"); |
||
2890 | else if(gScopeDaq->scopeMeasSel == 9) |
||
2891 | scope_data->Branch("pwidth", &evtmeas.measdata, "pwidth/D"); |
||
2892 | else if(gScopeDaq->scopeMeasSel == 10) |
||
2893 | scope_data->Branch("rise", &evtmeas.measdata, "rise/D"); |
||
2894 | } |
||
2895 | |||
117 | f9daq | 2896 | int neve = (int) evtNum->GetNumber(); |
2897 | int allEvt, zProg; |
||
2898 | zProg = 1; |
||
2899 | |||
2900 | #if WORKSTAT == 'I' |
||
2901 | #else |
||
2902 | // ONLY FOR TESTING! |
||
2903 | TRandom *randNum = new TRandom(); |
||
2904 | randNum->SetSeed(0); |
||
2905 | // ONLY FOR TESTING! |
||
2906 | #endif |
||
2907 | |||
2908 | if (gDaq) |
||
2909 | { |
||
129 | f9daq | 2910 | if(scanon == 0) |
2911 | { |
||
2912 | gDaq->init(evtheader.nrch); |
||
2913 | scanon = 1; |
||
2914 | } |
||
117 | f9daq | 2915 | gDaq->fStop=0; |
2916 | // Start gathering |
||
2917 | gDaq->start(); |
||
2918 | |||
2919 | busyLabel->Enable(); |
||
2920 | |||
2921 | for (int n=0;n<neve && !gDaq->fStop ;/*n++*/) |
||
2922 | { |
||
2923 | int nb = gDaq->event(gBuf,BSIZE); |
||
2924 | |||
2925 | #if WORKSTAT == 'I' |
||
2926 | #else |
||
2927 | // ONLY FOR TESTING! |
||
2928 | for(int i=0; i < evtheader.nrch; i++) |
||
2929 | { |
||
2930 | if(i == 1) |
||
2931 | gBuf[i] = randNum->Gaus(1500,300); |
||
2932 | else if(i == 0) |
||
2933 | gBuf[i] = randNum->Poisson(2500); |
||
2934 | } |
||
2935 | // ONLY FOR TESTING! |
||
2936 | #endif |
||
2937 | if (nb<=0) n--; |
||
2938 | |||
2939 | int nc=0; |
||
2940 | |||
2941 | while ( (nb>0) && (n<neve) ) |
||
2942 | { |
||
2943 | for(int i = 0; i < evtheader.nrch; i++) |
||
2944 | { |
||
2945 | unsigned short adc = gBuf[i+nc]&0xFFFF; |
||
2946 | if(i % 2 == 0) // TDC |
||
2947 | evtdata.tdcdata[i/2] = (int)adc; |
||
2948 | else if(i % 2 == 1) // ADC |
||
2949 | evtdata.adcdata[i/2] = (int)adc; |
||
127 | f9daq | 2950 | |
2951 | // Start plotting the scope waveform |
||
2952 | if( (gScopeDaq->scopeUseType == 1) && (sCamaclink->IsDown()) ) |
||
2953 | StartScopeAcq(); |
||
117 | f9daq | 2954 | } |
2955 | meas_data->Fill(); |
||
127 | f9daq | 2956 | |
2957 | // Start making a scope measurement |
||
2958 | if( (gScopeDaq->scopeUseType == 2) && (sCamaclink->IsDown()) ) |
||
2959 | { |
||
2960 | StartScopeAcq(); |
||
2961 | evtmeas.measdata = gScopeDaq->measubuf; |
||
2962 | } |
||
2963 | scope_data->Fill(); |
||
117 | f9daq | 2964 | |
2965 | n++; |
||
2966 | nc += evtheader.nrch; |
||
2967 | nb -= evtheader.nrch; |
||
2968 | } |
||
2969 | |||
2970 | MyTimer(); |
||
2971 | allEvt = n; |
||
2972 | if (gSystem->ProcessEvents()) printf("Run Interrupted\n"); |
||
2973 | |||
2974 | if( (started) && (n == (neve*zProg)/10) ) |
||
2975 | { |
||
2976 | progVal = (float)zProg*10; |
||
2977 | curProgress->SetPosition(progVal); |
||
2978 | zProg++; |
||
2979 | } |
||
2980 | } |
||
2981 | |||
2982 | printf("Number of gathered events: %d\n", allEvt); |
||
2983 | measStart->SetText("Start acquisition"); |
||
2984 | started = kFALSE; |
||
2985 | |||
2986 | gDaq->stop(); |
||
2987 | } |
||
2988 | |||
2989 | busyLabel->Disable(); |
||
2990 | printf("End of Run neve=%d\n",neve); |
||
2991 | |||
2992 | header_data->Write(); |
||
2993 | meas_data->Write(); |
||
127 | f9daq | 2994 | scope_data->Write(); |
117 | f9daq | 2995 | delete header_data; |
2996 | delete meas_data; |
||
127 | f9daq | 2997 | delete scope_data; |
117 | f9daq | 2998 | |
2999 | outroot->Close(); |
||
3000 | } |
||
3001 | |||
3002 | // Start the acquisition |
||
3003 | void TGAppMainFrame::StartAcq() |
||
3004 | { |
||
129 | f9daq | 3005 | // Variable that will initialize camac only once (for scans) |
3006 | int scanon = 0; |
||
3007 | |||
117 | f9daq | 3008 | // Determine the type of measurement to perform |
3009 | int vscan = 0, pscan = 0, zscan = 0; |
||
3010 | if(voltscanOn->IsOn()) vscan = 1; |
||
3011 | if(surfscanOn->IsOn()) pscan = 1; |
||
3012 | if(zscanOn->IsOn()) zscan = 1; |
||
3013 | |||
3014 | char cmd[256]; |
||
3015 | int i, j, k; |
||
3016 | float progVal; |
||
3017 | FILE *pfin; |
||
3018 | |||
3019 | // Variables for voltage scan |
||
3020 | float currentVoltage, minVoltage, maxVoltage, stepVoltage; |
||
3021 | int repetition; |
||
3022 | |||
3023 | // Variables for surface scan |
||
3024 | int minXpos, maxXpos, stepXpos; |
||
3025 | int minYpos, maxYpos, stepYpos; |
||
3026 | int minZpos, maxZpos, stepZpos; |
||
3027 | int repetX, repetY, repetZ; |
||
3028 | |||
3029 | // Voltage scan |
||
3030 | if( (vscan == 1) && (pscan == 0) ) |
||
3031 | { |
||
3032 | if(started) |
||
3033 | { |
||
3034 | printf("Stopping current voltage scan...\n"); |
||
3035 | gROOT->SetInterrupt(); |
||
3036 | measStart->SetText("Start acquisition"); |
||
3037 | started = kFALSE; |
||
3038 | |||
3039 | pfin = fopen("finish_sig.txt","w"); |
||
3040 | fprintf(pfin, "%s: Voltage scan stopped.", timeStamp->GetText()); |
||
3041 | fclose(pfin); |
||
3042 | } |
||
3043 | else if(!started) |
||
3044 | { |
||
3045 | measStart->SetText("Stop acquisition"); |
||
3046 | started = kTRUE; |
||
3047 | |||
3048 | printf("Running a voltage scan...\n"); |
||
3049 | |||
3050 | minVoltage = vOutStart->GetNumber(); |
||
3051 | maxVoltage = vOutStop->GetNumber(); |
||
3052 | stepVoltage = vOutStep->GetNumber(); |
||
3053 | |||
3054 | if(stepVoltage == 0.) |
||
3055 | repetition = 1; |
||
3056 | else |
||
3057 | repetition = ((maxVoltage - minVoltage)/stepVoltage)+1; |
||
3058 | |||
3059 | for(i=0; i < repetition; i++) |
||
3060 | { |
||
3061 | progVal = (float)(100.00/repetition)*i; |
||
3062 | curProgress->SetPosition(progVal); |
||
3063 | |||
3064 | fflush(stdout); |
||
3065 | currentVoltage = minVoltage + stepVoltage*i; |
||
3066 | sprintf(cmd, "%s/mpod/mpod_voltage.sh -o %d -v %f -s 1", rootdir, GetChannel(), currentVoltage); |
||
3067 | #if WORKSTAT == 'I' |
||
3068 | retTemp = system(cmd); |
||
3069 | #else |
||
3070 | printf("Cmd: %s\n",cmd); |
||
3071 | #endif |
||
3072 | fflush(stdout); |
||
3073 | |||
3074 | printf("Waiting for voltage change...\n"); |
||
127 | f9daq | 3075 | sleep(3); |
117 | f9daq | 3076 | vOut->SetNumber(currentVoltage); |
3077 | printf("Continuing...\n"); |
||
3078 | |||
3079 | // Here comes function to start histogramming <<<<<<<<<<<<<<<<<<<<<<<< |
||
129 | f9daq | 3080 | RunMeas((void*)0, i, 0, scanon); |
117 | f9daq | 3081 | fflush(stdout); |
3082 | } |
||
3083 | |||
3084 | // Set output back to off |
||
3085 | fflush(stdout); |
||
3086 | printf("Measurement finished, returning to starting voltage...\n"); |
||
3087 | sprintf(cmd, "%s/mpod/mpod_voltage.sh -o %d -v %f -s 1", rootdir, GetChannel(), minVoltage); |
||
3088 | vOut->SetNumber(minVoltage); |
||
3089 | #if WORKSTAT == 'I' |
||
3090 | retTemp = system(cmd); |
||
3091 | #else |
||
3092 | printf("Cmd: %s\n",cmd); |
||
3093 | #endif |
||
3094 | fflush(stdout); |
||
3095 | |||
3096 | progVal = 100.00; |
||
3097 | curProgress->SetPosition(progVal); |
||
3098 | printf("\n"); |
||
3099 | |||
3100 | pfin = fopen("finish_sig.txt","w"); |
||
3101 | fprintf(pfin, "%s: Voltage scan finished.", timeStamp->GetText()); |
||
3102 | fclose(pfin); |
||
3103 | } |
||
3104 | } |
||
3105 | // Surface scan |
||
3106 | else if( (pscan == 1) && (vscan == 0) ) |
||
3107 | { |
||
3108 | minXpos = xPosMin->GetNumber(); |
||
3109 | maxXpos = xPosMax->GetNumber(); |
||
3110 | stepXpos = xPosStep->GetNumber(); |
||
3111 | minYpos = yPosMin->GetNumber(); |
||
3112 | maxYpos = yPosMax->GetNumber(); |
||
3113 | stepYpos = yPosStep->GetNumber(); |
||
3114 | minZpos = zPosMin->GetNumber(); |
||
3115 | maxZpos = zPosMax->GetNumber(); |
||
3116 | stepZpos = zPosStep->GetNumber(); |
||
3117 | |||
3118 | if(zscan == 1) |
||
3119 | { |
||
3120 | if(stepZpos == 0.) repetZ = 1; |
||
3121 | else repetZ = ((maxZpos - minZpos)/stepZpos)+1; |
||
3122 | } |
||
3123 | else |
||
3124 | { |
||
3125 | minZpos = zPos->GetNumber(); |
||
3126 | repetZ = 1; |
||
3127 | } |
||
3128 | |||
3129 | if(stepXpos == 0.) repetX = 1; |
||
3130 | else repetX = ((maxXpos - minXpos)/stepXpos)+1; |
||
3131 | if(stepYpos == 0.) repetY = 1; |
||
3132 | else repetY = ((maxYpos - minYpos)/stepYpos)+1; |
||
3133 | |||
3134 | for(k=0; k < repetZ; k++) |
||
3135 | { |
||
3136 | fflush(stdout); |
||
3137 | // Y-axis change |
||
3138 | 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); |
||
3139 | #if WORKSTAT == 'I' |
||
3140 | retTemp = system(cmd); |
||
3141 | #else |
||
3142 | printf("Cmd: %s\n",cmd); |
||
3143 | #endif |
||
3144 | fflush(stdout); |
||
3145 | |||
3146 | printf("Next Z position...\n"); |
||
3147 | zPos->SetNumber(minZpos + stepZpos*k); |
||
3148 | fflush(stdout); |
||
3149 | |||
3150 | for(j=0; j < repetY; j++) |
||
3151 | { |
||
3152 | fflush(stdout); |
||
3153 | // Y-axis change |
||
3154 | 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); |
||
3155 | #if WORKSTAT == 'I' |
||
3156 | retTemp = system(cmd); |
||
3157 | #else |
||
3158 | printf("Cmd: %s\n",cmd); |
||
3159 | #endif |
||
3160 | fflush(stdout); |
||
3161 | |||
3162 | sleep(4); |
||
3163 | printf("Next Y position...\n"); |
||
3164 | yPos->SetNumber(minYpos + stepYpos*j); |
||
3165 | fflush(stdout); |
||
3166 | |||
3167 | for(i=0; i < repetX; i++) |
||
3168 | { |
||
3169 | progVal = (float)(100.00/(repetX*repetY))*(j*repetX+i); |
||
3170 | curProgress->SetPosition(progVal); |
||
3171 | |||
3172 | // X-axis change |
||
3173 | 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); |
||
3174 | #if WORKSTAT == 'I' |
||
3175 | retTemp = system(cmd); |
||
3176 | #else |
||
3177 | printf("Cmd: %s\n",cmd); |
||
3178 | #endif |
||
3179 | fflush(stdout); |
||
3180 | |||
3181 | printf("Next X position...\n"); |
||
3182 | fflush(stdout); |
||
3183 | |||
3184 | printf("Waiting for position change...\n"); |
||
3185 | sleep(2); |
||
3186 | xPos->SetNumber(minXpos + stepXpos*i); |
||
3187 | printf("Continuing...\n"); |
||
3188 | |||
3189 | // for (k=0;k<(NTDCCH+NADCCH);k++) gHisto1D[k]->Reset(); |
||
3190 | // for (k=0;k<(NTDCCH+NADCCH)/2;k++) gHisto2D[k]->Reset(); |
||
3191 | |||
3192 | // Here comes function to start histogramming <<<<<<<<<<<<<<<<<<<<<<<< |
||
129 | f9daq | 3193 | RunMeas((void*)0, (j*repetX + i), zscan , scanon); |
117 | f9daq | 3194 | |
3195 | fflush(stdout); |
||
3196 | } |
||
3197 | |||
3198 | printf("\n"); |
||
3199 | } |
||
3200 | } |
||
3201 | |||
3202 | fflush(stdout); |
||
3203 | printf("Measurement finished, returning to starting position...\n"); |
||
3204 | // X-axis return |
||
3205 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 1 -v %d -s la && %s/MIKRO/mikro_ctrl -n 1 -c m", rootdir, minXpos, rootdir); |
||
3206 | #if WORKSTAT == 'I' |
||
3207 | retTemp = system(cmd); |
||
3208 | #else |
||
3209 | printf("Cmd: %s\n",cmd); |
||
3210 | #endif |
||
3211 | fflush(stdout); |
||
3212 | |||
3213 | // Y-axis return |
||
3214 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 2 -v %d -s la && %s/MIKRO/mikro_ctrl -n 2 -c m", rootdir, minYpos, rootdir); |
||
3215 | #if WORKSTAT == 'I' |
||
3216 | retTemp = system(cmd); |
||
3217 | #else |
||
3218 | printf("Cmd: %s\n",cmd); |
||
3219 | #endif |
||
3220 | |||
3221 | // Z-axis return |
||
3222 | sprintf(cmd, "sudo %s/MIKRO/mikro_ctrl -n 3 -v %d -s la && %s/MIKRO/mikro_ctrl -n 3 -c m", rootdir, minZpos, rootdir); |
||
3223 | #if WORKSTAT == 'I' |
||
3224 | retTemp = system(cmd); |
||
3225 | #else |
||
3226 | printf("Cmd: %s\n",cmd); |
||
3227 | #endif |
||
3228 | xPos->SetNumber(minXpos); |
||
3229 | yPos->SetNumber(minYpos); |
||
3230 | zPos->SetNumber(minZpos); |
||
3231 | |||
3232 | progVal = 100.00; |
||
3233 | curProgress->SetPosition(progVal); |
||
3234 | printf("\n"); |
||
3235 | |||
3236 | pfin = fopen("finish_sig.txt","w"); |
||
3237 | fprintf(pfin, "%s: Surface scan finished.", timeStamp->GetText()); |
||
3238 | fclose(pfin); |
||
3239 | } |
||
3240 | // Normal single measurement |
||
3241 | else if( (vscan == 0) && (pscan == 0) ) |
||
3242 | { |
||
3243 | // Set the start button to stop and enable stopping of measurement |
||
3244 | if(started) |
||
3245 | { |
||
3246 | printf("Stopping current single scan...\n"); |
||
3247 | gROOT->SetInterrupt(); |
||
3248 | // gDaq->fStop=1; |
||
3249 | measStart->SetText("Start acquisition"); |
||
3250 | started = kFALSE; |
||
3251 | } |
||
3252 | else if(!started) |
||
3253 | { |
||
3254 | measStart->SetText("Stop acquisition"); |
||
3255 | started = kTRUE; |
||
3256 | |||
3257 | printf("Running a single scan...\n"); |
||
129 | f9daq | 3258 | RunMeas((void*)0, 0, 0, scanon); |
117 | f9daq | 3259 | printf("Measurement finished...\n"); |
3260 | printf("\n"); |
||
3261 | } |
||
3262 | } |
||
3263 | } |
||
3264 | |||
3265 | // File browser for opening histograms |
||
3266 | void TGAppMainFrame::SelectDirectory() |
||
3267 | { |
||
3268 | int i = fileList->GetNumberOfEntries(); |
||
3269 | |||
3270 | TGFileInfo file_info; |
||
3271 | const char *filetypes[] = {"Histograms",histExtAll,0,0}; |
||
3272 | file_info.fFileTypes = filetypes; |
||
3273 | file_info.fIniDir = StrDup("./results"); |
||
3274 | file_info.fMultipleSelection = kTRUE; |
||
3275 | new TGFileDialog(gClient->GetDefaultRoot(), fMain, kFDOpen, &file_info); |
||
3276 | |||
3277 | TList *files = file_info.fFileNamesList; |
||
3278 | if(files) |
||
3279 | { |
||
3280 | TSystemFile *file; |
||
3281 | TString fname; |
||
3282 | TIter next(files); |
||
3283 | while(file=(TSystemFile*)next()) |
||
3284 | { |
||
3285 | fname = file->GetName(); |
||
3286 | fileList->AddEntry(fname.Data(), i); |
||
3287 | i++; |
||
3288 | } |
||
3289 | } |
||
3290 | fileList->Layout(); |
||
3291 | } |
||
3292 | |||
3293 | // File browser for selecting the save file |
||
3294 | void TGAppMainFrame::SaveFile() |
||
3295 | { |
||
3296 | TGFileInfo file_info; |
||
3297 | const char *filetypes[] = {"Histograms",histExtAll,0,0}; |
||
3298 | file_info.fFileTypes = filetypes; |
||
3299 | file_info.fIniDir = StrDup("./results"); |
||
3300 | new TGFileDialog(gClient->GetDefaultRoot(), fMain, kFDSave, &file_info); |
||
3301 | |||
3302 | fileName->SetText(file_info.fFilename); |
||
3303 | } |
||
3304 | |||
3305 | // Toggle multiple selection in filelist |
||
3306 | void TGAppMainFrame::ListMultiSelect() |
||
3307 | { |
||
3308 | fileList->SetMultipleSelections((multiSelect->IsOn())); |
||
3309 | |||
3310 | if(multiSelectAll->IsDown()) |
||
3311 | multiSelectAll->SetState(kButtonUp); |
||
3312 | } |
||
3313 | |||
3314 | // Select all entries in filelist |
||
3315 | void TGAppMainFrame::ListSelectAll() |
||
3316 | { |
||
3317 | if(multiSelectAll->IsDown()) |
||
3318 | { |
||
3319 | multiSelect->SetState(kButtonDown); |
||
3320 | fileList->SetMultipleSelections((multiSelect->IsOn())); |
||
3321 | for(int i = 0; i < fileList->GetNumberOfEntries(); i++) |
||
3322 | fileList->Select(i,kTRUE); |
||
3323 | } |
||
3324 | else if(!multiSelectAll->IsDown()) |
||
3325 | { |
||
3326 | multiSelect->SetState(kButtonUp); |
||
3327 | fileList->SetMultipleSelections((multiSelect->IsOn())); |
||
3328 | for(int i = 0; i < fileList->GetNumberOfEntries(); i++) |
||
3329 | fileList->Select(i,kFALSE); |
||
3330 | } |
||
3331 | } |
||
3332 | |||
3333 | // Navigation buttons for the filelist (<<, >>) and double click |
||
3334 | void TGAppMainFrame::FileListNavigation(int pn) |
||
3335 | { |
||
3336 | unsigned int nrfiles = fileList->GetNumberOfEntries(); |
||
3337 | int curSel; |
||
3338 | TList *files; |
||
3339 | if( nrfiles > 0 ) |
||
3340 | { |
||
3341 | if(pn < -1) |
||
3342 | { |
||
3343 | if(multiSelect->IsOn()) |
||
3344 | { |
||
3345 | // turn off multiple selection and select first file on list |
||
3346 | fileList->SetMultipleSelections(kFALSE); |
||
3347 | multiSelect->SetState(kButtonUp); |
||
3348 | multiSelectAll->SetState(kButtonUp); |
||
3349 | |||
3350 | fileList->Select(0,kTRUE); |
||
3351 | } |
||
3352 | else |
||
3353 | { |
||
3354 | // if nothing is selected, curSel will be -1 |
||
3355 | curSel = fileList->GetSelected(); |
||
3356 | // go to next file on list |
||
3357 | if(pn == -3) |
||
3358 | { |
||
3359 | if( (curSel == (int)(nrfiles-1)) || (curSel == -1) ) |
||
3360 | fileList->Select(0); |
||
3361 | else |
||
3362 | fileList->Select(curSel+1); |
||
3363 | } |
||
3364 | // go to previous file on list |
||
3365 | else if(pn == -2) |
||
3366 | { |
||
3367 | if( (curSel == 0) || (curSel == -1) ) |
||
3368 | fileList->Select(nrfiles-1); |
||
3369 | else |
||
3370 | fileList->Select(curSel-1); |
||
3371 | } |
||
3372 | } |
||
3373 | } |
||
3374 | |||
3375 | // check the newly selected file/files and return its name/their names |
||
3376 | files = new TList(); |
||
3377 | fileList->GetSelectedEntries(files); |
||
3378 | if(files) |
||
3379 | { |
||
3380 | for(int i = 0; i < (int)nrfiles; i++) |
||
3381 | { |
||
3382 | if(files->At(i)) |
||
3383 | { |
||
128 | f9daq | 3384 | if(debug) |
117 | f9daq | 3385 | printf("Filename: %s\n", files->At(i)->GetTitle()); |
3386 | if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DADC) ) |
||
3387 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0); |
||
3388 | else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DTDC) ) |
||
3389 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 1); |
||
3390 | else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_2D) ) |
||
3391 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 2); |
||
3392 | } |
||
3393 | } |
||
3394 | } |
||
3395 | |||
3396 | // Still need to include drawing of histograms we move to!!! |
||
3397 | } |
||
3398 | } |
||
3399 | |||
129 | f9daq | 3400 | // Open the header edit window when pressing on editHeader button |
3401 | void TGAppMainFrame::HeaderEdit() |
||
3402 | { |
||
3403 | OpenWindow(2); |
||
3404 | } |
||
3405 | |||
117 | f9daq | 3406 | // Display the currently selected histogram in file list |
3407 | void TGAppMainFrame::DisplayHistogram(char* histfile, int histtype) |
||
3408 | { |
||
128 | f9daq | 3409 | if(debug) |
117 | f9daq | 3410 | printf("Selected file: %s\n", histfile); |
3411 | |||
3412 | TCanvas *gCanvas = histCanvas->GetCanvas(); |
||
3413 | |||
3414 | inroot = new TFile(histfile, "READ"); |
||
3415 | |||
3416 | TTree *header_data, *meas_data; |
||
3417 | inroot->GetObject("header_data", header_data); |
||
3418 | inroot->GetObject("meas_data", meas_data); |
||
3419 | |||
3420 | // Reading the header |
||
3421 | header_data->SetBranchAddress("nrch", &evtheader.nrch); |
||
3422 | header_data->GetEntry(0); |
||
3423 | header_data->SetBranchAddress("timestamp", &evtheader.timestamp); |
||
3424 | header_data->GetEntry(0); |
||
3425 | header_data->SetBranchAddress("biasvolt", &evtheader.biasvolt); |
||
3426 | header_data->GetEntry(0); |
||
3427 | header_data->SetBranchAddress("xpos", &evtheader.xpos); |
||
3428 | header_data->GetEntry(0); |
||
3429 | header_data->SetBranchAddress("ypos", &evtheader.ypos); |
||
3430 | header_data->GetEntry(0); |
||
3431 | header_data->SetBranchAddress("zpos", &evtheader.zpos); |
||
3432 | header_data->GetEntry(0); |
||
3433 | header_data->SetBranchAddress("temperature", &evtheader.temperature); |
||
3434 | header_data->GetEntry(0); |
||
129 | f9daq | 3435 | if( header_data->FindBranch("angle") ) |
3436 | { |
||
3437 | header_data->SetBranchAddress("angle", &evtheader.angle); |
||
3438 | header_data->GetEntry(0); |
||
3439 | } |
||
117 | f9daq | 3440 | header_data->SetBranchAddress("laserinfo", &evtheader.laserinfo); |
3441 | header_data->GetEntry(0); |
||
3442 | |||
3443 | char histtime[256]; |
||
3444 | GetTime(evtheader.timestamp, histtime); |
||
3445 | |||
128 | f9daq | 3446 | // Displaying header information (debug and on the GUI) |
3447 | if(debug) |
||
117 | f9daq | 3448 | { |
3449 | printf("Opened file header information:\n"); |
||
3450 | printf("- Number of channels: %d\n", evtheader.nrch); |
||
3451 | printf("- Timestamp: %d (%s)\n", evtheader.timestamp, histtime); |
||
3452 | printf("- Bias voltage: %lf\n", evtheader.biasvolt); |
||
3453 | printf("- Table position (X,Y,Z): %d, %d, %d\n", evtheader.xpos, evtheader.ypos, evtheader.zpos); |
||
128 | f9daq | 3454 | if(evtheader.temperature) |
3455 | printf("- Temperature: %lf\n", evtheader.temperature); |
||
129 | f9daq | 3456 | if( header_data->FindBranch("angle") ) |
128 | f9daq | 3457 | printf("- Incidence angle: %lf\n", evtheader.angle); |
129 | f9daq | 3458 | else |
3459 | printf("- Incidence angle: No angle information!\n"); |
||
117 | f9daq | 3460 | printf("- Laser and filter settings: %s\n", evtheader.laserinfo); |
3461 | } |
||
3462 | |||
128 | f9daq | 3463 | char ctemp[512]; |
3464 | disptime->SetText(histtime); |
||
3465 | dispbias->SetNumber(evtheader.biasvolt); |
||
3466 | sprintf(ctemp, "%d, %d, %d", evtheader.xpos, evtheader.ypos, evtheader.zpos); |
||
3467 | disppos->SetText(ctemp); |
||
3468 | if(evtheader.temperature) |
||
3469 | disptemp->SetNumber(evtheader.temperature); |
||
3470 | else |
||
3471 | disptemp->SetNumber(0.0); |
||
129 | f9daq | 3472 | if( header_data->FindBranch("angle") ) |
128 | f9daq | 3473 | dispangle->SetNumber(evtheader.angle); |
3474 | else |
||
3475 | dispangle->SetNumber(0.0); |
||
3476 | displaser->SetText(evtheader.laserinfo); |
||
3477 | |||
117 | f9daq | 3478 | int j; |
3479 | char rdc[256]; |
||
3480 | char rdcsel[256]; |
||
3481 | |||
3482 | j = selectCh->GetNumber(); |
||
3483 | |||
3484 | printf("Found %d data points.\n", (int)meas_data->GetEntries()); |
||
3485 | |||
3486 | gCanvas->cd(); |
||
3487 | double range[4]; |
||
3488 | range[0] = adcMinRange->GetNumber(); |
||
3489 | range[1] = adcMaxRange->GetNumber(); |
||
3490 | range[2] = tdcMinwindow->GetNumber(); |
||
3491 | range[3] = tdcMaxwindow->GetNumber(); |
||
3492 | |||
3493 | if(histtype == 0) |
||
3494 | { |
||
3495 | if( range[0] == range[1] ) |
||
3496 | sprintf(rdc, "ADC%d>>%s", j, histname); |
||
3497 | else |
||
3498 | sprintf(rdc, "ADC%d>>%s(%d,%lf,%lf)", j, histname, (int)(range[1]-range[0]), range[0]-0.5, range[1]-0.5); |
||
3499 | |||
3500 | sprintf(rdcsel, "(TDC%d>%lf)&&(TDC%d<%lf)", j, range[2]*tdctimeconversion, j, range[3]*tdctimeconversion); |
||
3501 | meas_data->Draw(rdc, rdcsel); |
||
3502 | |||
3503 | sprintf(rdc, "ADC%d, Vbias=%.3lf, TDC=(%.2lf,%.2lf);ADC;", j, evtheader.biasvolt, range[2], range[3]); |
||
3504 | TH1F *histtemp = (TH1F*)gCanvas->GetPrimitive(histname); |
||
3505 | if(!cleanPlots) |
||
3506 | histtemp->SetTitle(rdc); |
||
3507 | else |
||
3508 | histtemp->SetTitle(";ADC;"); |
||
3509 | histtemp->GetXaxis()->SetLabelSize(0.025); |
||
3510 | histtemp->GetXaxis()->CenterTitle(kTRUE); |
||
3511 | histtemp->GetYaxis()->SetLabelSize(0.025); |
||
3512 | if(cleanPlots) |
||
3513 | { |
||
3514 | TGaxis *yax = (TGaxis*)histtemp->GetYaxis(); |
||
3515 | yax->SetMaxDigits(4); |
||
3516 | } |
||
3517 | |||
3518 | gCanvas->Modified(); |
||
3519 | gCanvas->Update(); |
||
3520 | |||
3521 | if( yMinRange->GetNumber() != yMaxRange->GetNumber() ) |
||
3522 | { |
||
3523 | if( (logscale->IsDown()) && (yMinRange->GetNumber() <= 0) ) |
||
3524 | { |
||
3525 | histtemp->GetYaxis()->SetRangeUser(0.5, yMaxRange->GetNumber()); |
||
3526 | yMinRange->SetNumber(0.5); |
||
3527 | logchange = 1; |
||
3528 | } |
||
3529 | else |
||
3530 | { |
||
3531 | gCanvas->SetLogy(kFALSE); |
||
3532 | if(logchange == 1) |
||
3533 | { |
||
3534 | yMinRange->SetNumber(0.0); |
||
3535 | logchange = 0; |
||
3536 | } |
||
3537 | histtemp->GetYaxis()->SetRangeUser(yMinRange->GetNumber(), yMaxRange->GetNumber()); |
||
3538 | } |
||
3539 | } |
||
3540 | |||
3541 | TPaveStats *stats = (TPaveStats*)histtemp->FindObject("stats"); |
||
3542 | if(!cleanPlots) |
||
3543 | { |
||
3544 | stats->SetX1NDC(0.84); stats->SetX2NDC(0.97); |
||
3545 | stats->SetY1NDC(0.87); stats->SetY2NDC(0.97); |
||
3546 | } |
||
3547 | else |
||
3548 | { |
||
3549 | stats->SetX1NDC(1.1); stats->SetX2NDC(1.3); |
||
3550 | stats->SetY1NDC(1.1); stats->SetY2NDC(1.3); |
||
3551 | } |
||
3552 | } |
||
3553 | else if(histtype == 1) |
||
3554 | { |
||
3555 | if( range[0] == range[1] ) |
||
3556 | sprintf(rdc, "(TDC%d/%lf)>>%s", j, tdctimeconversion, histname); |
||
3557 | else |
||
3558 | sprintf(rdc, "(TDC%d/%lf)>>%s(%d,%lf,%lf)", j, tdctimeconversion, histname, (int)((range[3]-range[2])*tdctimeconversion), range[2], range[3]); |
||
3559 | sprintf(rdcsel, "(TDC%d>%lf)&&(TDC%d<%lf)", j, range[2]*tdctimeconversion, j, range[3]*tdctimeconversion); |
||
3560 | meas_data->Draw(rdc, rdcsel); |
||
3561 | |||
3562 | sprintf(rdc, "TDC%d, Vbias=%.3lf, TDC=(%.2lf,%.2lf);Time (TDC channel) [ns];", j, evtheader.biasvolt, range[2], range[3]); |
||
3563 | TH1F *histtemp = (TH1F*)gCanvas->GetPrimitive(histname); |
||
3564 | if(!cleanPlots) |
||
3565 | histtemp->SetTitle(rdc); |
||
3566 | else |
||
3567 | histtemp->SetTitle(";Time (TDC channel) [ns];"); |
||
3568 | histtemp->GetXaxis()->SetLabelSize(0.025); |
||
3569 | histtemp->GetXaxis()->CenterTitle(kTRUE); |
||
3570 | histtemp->GetYaxis()->SetLabelSize(0.025); |
||
3571 | if(cleanPlots) |
||
3572 | { |
||
3573 | TGaxis *yax = (TGaxis*)histtemp->GetYaxis(); |
||
3574 | yax->SetMaxDigits(4); |
||
3575 | } |
||
3576 | |||
3577 | gCanvas->Modified(); |
||
3578 | gCanvas->Update(); |
||
3579 | |||
3580 | if( yMinRange->GetNumber() != yMaxRange->GetNumber() ) |
||
3581 | { |
||
3582 | if( (logscale->IsDown()) && (yMinRange->GetNumber() <= 0) ) |
||
3583 | { |
||
3584 | histtemp->GetYaxis()->SetRangeUser(0.5, yMaxRange->GetNumber()); |
||
3585 | yMinRange->SetNumber(0.5); |
||
3586 | logchange = 1; |
||
3587 | } |
||
3588 | else |
||
3589 | { |
||
3590 | gCanvas->SetLogy(kFALSE); |
||
3591 | if(logchange == 1) |
||
3592 | { |
||
3593 | yMinRange->SetNumber(0.0); |
||
3594 | logchange = 0; |
||
3595 | } |
||
3596 | histtemp->GetYaxis()->SetRangeUser(yMinRange->GetNumber(), yMaxRange->GetNumber()); |
||
3597 | } |
||
3598 | } |
||
3599 | |||
3600 | TPaveStats *stats = (TPaveStats*)histtemp->FindObject("stats"); |
||
3601 | if(!cleanPlots) |
||
3602 | { |
||
3603 | stats->SetX1NDC(0.84); stats->SetX2NDC(0.97); |
||
3604 | stats->SetY1NDC(0.87); stats->SetY2NDC(0.97); |
||
3605 | } |
||
3606 | else |
||
3607 | { |
||
3608 | stats->SetX1NDC(1.1); stats->SetX2NDC(1.3); |
||
3609 | stats->SetY1NDC(1.1); stats->SetY2NDC(1.3); |
||
3610 | } |
||
3611 | } |
||
3612 | else if(histtype == 2) |
||
3613 | { |
||
3614 | if( ((range[0] == range[1]) && (range[2] == range[3])) || (range[2] == range[3]) || (range[0] == range[1]) ) |
||
3615 | sprintf(rdc, "(TDC%d/%lf):ADC%d>>%s", j, tdctimeconversion, j, histname); |
||
3616 | else |
||
3617 | 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]); |
||
3618 | meas_data->Draw(rdc,"","COLZ"); |
||
3619 | |||
3620 | sprintf(rdc, "ADC/TDC%d, Vbias=%.3lf, TDC=(%.2lf,%.2lf);ADC;TDC", j, evtheader.biasvolt, range[2], range[3]); |
||
3621 | TH2F *histtemp = (TH2F*)gCanvas->GetPrimitive(histname); |
||
3622 | if(!cleanPlots) |
||
3623 | histtemp->SetTitle(rdc); |
||
3624 | else |
||
3625 | histtemp->SetTitle(";ADC;Time (TDC channel) [ns]"); |
||
3626 | histtemp->GetXaxis()->SetLabelSize(0.025); |
||
3627 | histtemp->GetXaxis()->CenterTitle(kTRUE); |
||
3628 | histtemp->GetYaxis()->SetLabelSize(0.025); |
||
3629 | histtemp->GetYaxis()->CenterTitle(kTRUE); |
||
3630 | histtemp->GetYaxis()->SetTitleOffset(1.35); |
||
3631 | if(cleanPlots) |
||
3632 | { |
||
3633 | TGaxis *yax = (TGaxis*)histtemp->GetYaxis(); |
||
3634 | yax->SetMaxDigits(4); |
||
3635 | } |
||
3636 | |||
3637 | gCanvas->Modified(); |
||
3638 | gCanvas->Update(); |
||
3639 | |||
3640 | TPaveStats *stats = (TPaveStats*)histtemp->FindObject("stats"); |
||
3641 | // stats->SetOptStat(0); |
||
3642 | stats->SetX1NDC(1.1); stats->SetX2NDC(1.3); |
||
3643 | stats->SetY1NDC(1.1); stats->SetY2NDC(1.3); |
||
3644 | |||
3645 | TPaletteAxis *gpalette = (TPaletteAxis*)histtemp->GetListOfFunctions()->FindObject("palette"); |
||
3646 | gpalette->SetLabelSize(0.022); |
||
3647 | } |
||
3648 | |||
3649 | if(histtype < 2) |
||
3650 | { |
||
3651 | if( logscale->IsDown() ) |
||
3652 | gCanvas->SetLogy(kTRUE); |
||
3653 | else if( !logscale->IsDown() ) |
||
3654 | gCanvas->SetLogy(kFALSE); |
||
3655 | } |
||
3656 | else |
||
3657 | gCanvas->SetLogy(kFALSE); |
||
3658 | |||
3659 | gCanvas->Modified(); |
||
3660 | gCanvas->Update(); |
||
3661 | |||
3662 | // If you close the opened file, the data can't be accessed by other functions |
||
3663 | } |
||
3664 | |||
3665 | // Create a 2D surface plot and plot it |
||
3666 | void TGAppMainFrame::MakeSurfPlot(TList *files) |
||
3667 | { |
||
3668 | unsigned int nrfiles = fileList->GetNumberOfEntries(); |
||
3669 | int j, k = 0, m = 0, n = 0; |
||
3670 | char ctemp[256]; |
||
3671 | TCanvas *gCanvas = histCanvas->GetCanvas(); |
||
3672 | TTree *header_data, *meas_data; |
||
3673 | double *integralCount; |
||
3674 | double *surfx, *surfy; |
||
3675 | double xsurfmin = 0, ysurfmin = 0; |
||
3676 | integralCount = new double[nrfiles]; |
||
3677 | for(int i = 0; i < (int)nrfiles; i++) integralCount[i] = 0; |
||
3678 | surfx = new double[nrfiles]; |
||
3679 | surfy = new double[nrfiles]; |
||
3680 | int nrentries; |
||
3681 | TGraph2D *gScan2D; |
||
3682 | gScan2D = new TGraph2D(); |
||
3683 | |||
3684 | /* int zProg = 0; |
||
3685 | float progVal; |
||
3686 | curProgress->SetPosition(zProg);*/ |
||
3687 | |||
3688 | char exportname[256]; |
||
3689 | |||
3690 | if(multiSelect->IsOn()) |
||
3691 | { |
||
3692 | printf("Creating a surface plot. Please wait...\n"); |
||
3693 | fileList->GetSelectedEntries(files); |
||
3694 | if(files) |
||
3695 | { |
||
3696 | busyLabel->Enable(); |
||
3697 | |||
3698 | for(int i = 0; i < (int)nrfiles; i++) |
||
3699 | { |
||
3700 | if(files->At(i)) |
||
3701 | { |
||
3702 | n++; |
||
3703 | // printf("Filename: %s\n", files->At(i)->GetTitle()); |
||
3704 | |||
3705 | sprintf(ctemp, "%s", files->At(i)->GetTitle()); |
||
3706 | inroot = new TFile(ctemp, "READ"); |
||
3707 | |||
3708 | inroot->GetObject("header_data", header_data); |
||
3709 | inroot->GetObject("meas_data", meas_data); |
||
3710 | |||
3711 | // Reading the header |
||
3712 | header_data->SetBranchAddress("xpos", &evtheader.xpos); |
||
3713 | header_data->GetEntry(0); |
||
3714 | header_data->SetBranchAddress("ypos", &evtheader.ypos); |
||
3715 | header_data->GetEntry(0); |
||
3716 | |||
3717 | char rdc[256]; |
||
3718 | j = selectCh->GetNumber(); |
||
3719 | double rangetdc[2]; |
||
3720 | rangetdc[0] = tdcMinwindow->GetNumber(); |
||
3721 | rangetdc[1] = tdcMaxwindow->GetNumber(); |
||
3722 | |||
3723 | k = 0; |
||
3724 | m = 0; |
||
3725 | |||
3726 | // Reading the data |
||
3727 | for(int i = 0; i < meas_data->GetEntries(); i++) |
||
3728 | { |
||
3729 | sprintf(rdc, "ADC%d", j); |
||
3730 | meas_data->SetBranchAddress(rdc, &evtdata.adcdata[j]); |
||
3731 | meas_data->GetEntry(i); |
||
3732 | |||
3733 | sprintf(rdc, "TDC%d", j); |
||
3734 | meas_data->SetBranchAddress(rdc, &evtdata.tdcdata[j]); |
||
3735 | meas_data->GetEntry(i); |
||
3736 | |||
3737 | // If our data point is inside the TDC window |
||
3738 | if( ((double)evtdata.tdcdata[j]/tdctimeconversion >= rangetdc[0]) && ((double)evtdata.tdcdata[j]/tdctimeconversion <= rangetdc[1]) ) |
||
3739 | { |
||
3740 | k++; |
||
3741 | m += evtdata.adcdata[j]; |
||
3742 | } |
||
3743 | } |
||
3744 | |||
3745 | integralCount[n-1] += ((double)m)/((double)k); |
||
3746 | if(n == 1) |
||
3747 | { |
||
3748 | xsurfmin = evtheader.xpos; |
||
3749 | ysurfmin = evtheader.ypos; |
||
3750 | } |
||
3751 | surfx[n-1] = (double)(evtheader.xpos-xsurfmin)*lenconversion; |
||
3752 | surfy[n-1] = (double)(evtheader.ypos-ysurfmin)*lenconversion; |
||
3753 | |||
3754 | /* if( n == (((files->GetSize())*zProg)/20)+1 ) // divide by 20 because files->GetSize() gives a double value of the files selected |
||
3755 | { |
||
3756 | progVal = (float)n; |
||
3757 | curProgress->SetPosition(progVal); |
||
3758 | zProg++; |
||
3759 | printf("Progress = %lf\n", progVal); |
||
3760 | }*/ |
||
3761 | |||
129 | f9daq | 3762 | inroot->Close(); |
117 | f9daq | 3763 | delete inroot; |
3764 | } |
||
3765 | } |
||
3766 | |||
3767 | busyLabel->Disable(); |
||
3768 | |||
3769 | nrentries = n; |
||
3770 | printf("%d files were selected.\n", nrentries); |
||
3771 | |||
3772 | for(int i = 0; i < nrentries; i++) |
||
3773 | { |
||
3774 | // printf("At position (%d,%d), the ADC integral is: %lf.\n", surfx[i], surfy[i], integralCount[i]); |
||
3775 | gScan2D->SetPoint(i, surfx[i], surfy[i], integralCount[i]); |
||
3776 | } |
||
3777 | gCanvas->cd(); |
||
3778 | gScan2D->Draw("COLZ"); |
||
3779 | |||
3780 | gCanvas->Modified(); |
||
3781 | gCanvas->Update(); |
||
3782 | |||
3783 | gScan2D->GetXaxis()->SetTitle("X [#mum]"); |
||
3784 | gScan2D->GetXaxis()->CenterTitle(kTRUE); |
||
3785 | gScan2D->GetXaxis()->SetLabelSize(0.022); |
||
3786 | gScan2D->GetXaxis()->SetRangeUser(surfx[0], surfx[nrentries-1]); |
||
3787 | // j = 500+(int)((surfx[nrentries-1]-surfx[0])/(surfx[1]-surfx[0])); |
||
3788 | // if(j > 510) j = 510; |
||
3789 | gScan2D->GetXaxis()->SetNdivisions(510, kTRUE); |
||
3790 | gScan2D->GetYaxis()->SetTitle("Y [#mum]"); |
||
3791 | gScan2D->GetYaxis()->SetTitleOffset(1.3); |
||
3792 | gScan2D->GetYaxis()->CenterTitle(kTRUE); |
||
3793 | gScan2D->GetYaxis()->SetLabelSize(0.022); |
||
3794 | gScan2D->GetYaxis()->SetRangeUser(surfy[0], surfy[nrentries-1]); |
||
3795 | // j = 500+(int)((surfy[nrentries-1]-surfy[0])/(surfy[(int)((surfx[nrentries-1]-surfx[0])/(surfx[1]-surfx[0])+1)]-surfy[0])); |
||
3796 | // if(j > 510) j = 510; |
||
3797 | gScan2D->GetYaxis()->SetNdivisions(510, kTRUE); |
||
3798 | |||
3799 | TGaxis *yax = (TGaxis*)gScan2D->GetYaxis(); |
||
3800 | yax->SetMaxDigits(4); |
||
3801 | |||
3802 | if(!cleanPlots) |
||
3803 | gScan2D->SetTitle("Surface scan"); |
||
3804 | else |
||
3805 | gScan2D->SetTitle(); |
||
3806 | |||
3807 | // TPaletteAxis *gpalette = (TPaletteAxis*)gScan2D->GetListOfFunctions()->FindObject("palette"); |
||
3808 | // gpalette->SetLabelSize(0.022); |
||
3809 | |||
3810 | gCanvas->Modified(); |
||
3811 | gCanvas->Update(); |
||
3812 | |||
3813 | remove_from_last((char*)files->At(0)->GetTitle(), '_', ctemp); |
||
3814 | sprintf(exportname, "%s_surfscan.pdf", ctemp); |
||
3815 | gCanvas->SaveAs(exportname); |
||
3816 | } |
||
3817 | } |
||
3818 | else |
||
3819 | { |
||
3820 | printf("To make a 2D surface scan plot, select multiple root files.\n"); |
||
3821 | change2Dsurf->SetDown(kFALSE); |
||
3822 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_SURF); |
||
3823 | } |
||
3824 | |||
3825 | delete[] surfx; |
||
3826 | delete[] surfy; |
||
3827 | delete[] integralCount; |
||
3828 | } |
||
3829 | |||
3830 | // Change histogram when changing the channel |
||
3831 | void TGAppMainFrame::ChangeChannel() |
||
3832 | { |
||
3833 | unsigned int nrfiles = fileList->GetNumberOfEntries(); |
||
3834 | TList *files; |
||
3835 | |||
3836 | if( nrfiles > 0 ) |
||
3837 | { |
||
3838 | // check the newly selected file/files and return its name/their names |
||
3839 | files = new TList(); |
||
3840 | fileList->GetSelectedEntries(files); |
||
3841 | if(files) |
||
3842 | { |
||
3843 | for(int i = 0; i < (int)nrfiles; i++) |
||
3844 | { |
||
3845 | if(files->At(i)) |
||
3846 | { |
||
128 | f9daq | 3847 | if(debug) |
117 | f9daq | 3848 | printf("Filename: %s\n", files->At(i)->GetTitle()); |
3849 | if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DADC) ) |
||
3850 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0); |
||
3851 | else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DTDC) ) |
||
3852 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 1); |
||
3853 | else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_2D) ) |
||
3854 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 2); |
||
3855 | } |
||
3856 | } |
||
3857 | } |
||
3858 | } |
||
3859 | } |
||
3860 | |||
3861 | // Setting a predetermined X range |
||
3862 | void TGAppMainFrame::SetHistRange() |
||
3863 | { |
||
3864 | unsigned int nrfiles = fileList->GetNumberOfEntries(); |
||
3865 | |||
3866 | if(nrfiles > 0) |
||
3867 | { |
||
3868 | TList *files; |
||
3869 | files = new TList(); |
||
3870 | fileList->GetSelectedEntries(files); |
||
3871 | if(files) |
||
3872 | { |
||
3873 | for(int i = 0; i < (int)nrfiles; i++) |
||
3874 | { |
||
3875 | if(files->At(i)) |
||
3876 | { |
||
128 | f9daq | 3877 | if(debug) |
117 | f9daq | 3878 | printf("Filename: %s\n", files->At(i)->GetTitle()); |
3879 | if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DADC) ) |
||
3880 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0); |
||
3881 | else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DTDC) ) |
||
3882 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 1); |
||
3883 | else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_2D) ) |
||
3884 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 2); |
||
3885 | } |
||
3886 | } |
||
3887 | } |
||
3888 | } |
||
3889 | } |
||
3890 | |||
3891 | // Changing the histogram type to display |
||
3892 | void TGAppMainFrame::ChangeHisttype(int type) |
||
3893 | { |
||
3894 | TGTextButton *pressedB = new TGTextButton(); |
||
3895 | int menuID = 0; |
||
3896 | unsigned int nrfiles = fileList->GetNumberOfEntries(); |
||
3897 | |||
3898 | // ADC histogram |
||
3899 | if(type == 0) |
||
3900 | { |
||
3901 | pressedB = changeADC; |
||
3902 | menuID = M_ANALYSIS_HISTTYPE_1DADC; |
||
3903 | |||
3904 | changeTDC->SetDown(kFALSE); |
||
3905 | changeADCTDC->SetDown(kFALSE); |
||
3906 | change2Dsurf->SetDown(kFALSE); |
||
3907 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DTDC); |
||
3908 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_2D); |
||
3909 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_SURF); |
||
3910 | } |
||
3911 | // TDC histogram |
||
3912 | else if(type == 1) |
||
3913 | { |
||
3914 | pressedB = changeTDC; |
||
3915 | menuID = M_ANALYSIS_HISTTYPE_1DTDC; |
||
3916 | |||
3917 | changeADC->SetDown(kFALSE); |
||
3918 | changeADCTDC->SetDown(kFALSE); |
||
3919 | change2Dsurf->SetDown(kFALSE); |
||
3920 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DADC); |
||
3921 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_2D); |
||
3922 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_SURF); |
||
3923 | } |
||
3924 | // ADC vs. TDC histogram |
||
3925 | else if(type == 2) |
||
3926 | { |
||
3927 | pressedB = changeADCTDC; |
||
3928 | menuID = M_ANALYSIS_HISTTYPE_2D; |
||
3929 | |||
3930 | changeADC->SetDown(kFALSE); |
||
3931 | changeTDC->SetDown(kFALSE); |
||
3932 | change2Dsurf->SetDown(kFALSE); |
||
3933 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DADC); |
||
3934 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DTDC); |
||
3935 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_SURF); |
||
3936 | } |
||
3937 | // Surface scan plot |
||
3938 | else if(type == 3) |
||
3939 | { |
||
3940 | pressedB = change2Dsurf; |
||
3941 | menuID = M_ANALYSIS_HISTTYPE_SURF; |
||
3942 | |||
3943 | changeADC->SetDown(kFALSE); |
||
3944 | changeTDC->SetDown(kFALSE); |
||
3945 | changeADCTDC->SetDown(kFALSE); |
||
3946 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DADC); |
||
3947 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_1DTDC); |
||
3948 | fMenuHisttype->UnCheckEntry(M_ANALYSIS_HISTTYPE_2D); |
||
3949 | } |
||
3950 | |||
3951 | if( fMenuHisttype->IsEntryChecked(menuID) ) |
||
3952 | { |
||
3953 | pressedB->SetDown(kFALSE); |
||
3954 | fMenuHisttype->UnCheckEntry(menuID); |
||
3955 | } |
||
3956 | else if( !fMenuHisttype->IsEntryChecked(menuID) ) |
||
3957 | { |
||
3958 | pressedB->SetDown(kTRUE); |
||
3959 | fMenuHisttype->CheckEntry(menuID); |
||
3960 | } |
||
3961 | |||
3962 | if(nrfiles > 0) |
||
3963 | { |
||
3964 | // Still need to add the switch!!! |
||
3965 | TList *files; |
||
3966 | files = new TList(); |
||
3967 | fileList->GetSelectedEntries(files); |
||
3968 | |||
3969 | if(type < 3) |
||
3970 | DisplayHistogram( (char*)(files->At(0)->GetTitle()), type); |
||
3971 | else if(type == 3) |
||
3972 | MakeSurfPlot( files ); |
||
3973 | } |
||
3974 | } |
||
3975 | |||
3976 | // Changing the histogram type to display |
||
3977 | void TGAppMainFrame::HistogramExport() |
||
3978 | { |
||
3979 | unsigned int nrfiles = fileList->GetNumberOfEntries(); |
||
3980 | TList *files; |
||
3981 | TCanvas *gCanvas = histCanvas->GetCanvas(); |
||
3982 | |||
3983 | char exportname[256]; |
||
3984 | char ctemp[256]; |
||
3985 | |||
3986 | if(nrfiles > 0) |
||
3987 | { |
||
3988 | files = new TList(); |
||
3989 | fileList->GetSelectedEntries(files); |
||
3990 | if(files) |
||
3991 | { |
||
3992 | if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_SURF) ) // for the surface scan, the plot from all selected files is already created |
||
3993 | { |
||
3994 | remove_from_last((char*)files->At(0)->GetTitle(), '_', ctemp); |
||
3995 | sprintf(exportname, "%s_surfscan.pdf", ctemp); |
||
3996 | gCanvas->SaveAs(exportname); |
||
3997 | } |
||
3998 | else |
||
3999 | { |
||
4000 | for(int i = 0; i < (int)nrfiles; i++) |
||
4001 | { |
||
4002 | if(files->At(i)) |
||
4003 | { |
||
4004 | remove_ext((char*)files->At(i)->GetTitle(), ctemp); |
||
4005 | |||
128 | f9daq | 4006 | if(debug) |
117 | f9daq | 4007 | printf("Filename: %s\n", files->At(i)->GetTitle()); |
4008 | if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DADC) ) |
||
4009 | { |
||
4010 | sprintf(exportname, "%s_adc%d.pdf", ctemp, (int)selectCh->GetNumber()); |
||
4011 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 0); |
||
4012 | } |
||
4013 | else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DTDC) ) |
||
4014 | { |
||
4015 | sprintf(exportname, "%s_tdc%d.pdf", ctemp, (int)selectCh->GetNumber()); |
||
4016 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 1); |
||
4017 | } |
||
4018 | else if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_2D) ) |
||
4019 | { |
||
4020 | sprintf(exportname, "%s_adctdc%d.pdf", ctemp, (int)selectCh->GetNumber()); |
||
4021 | DisplayHistogram( (char*)(files->At(i)->GetTitle()), 2); |
||
4022 | } |
||
4023 | |||
4024 | gCanvas->SaveAs(exportname); |
||
4025 | } |
||
4026 | } |
||
4027 | } |
||
4028 | } |
||
4029 | } |
||
4030 | } |
||
4031 | |||
4032 | //--------------------------------------------------------------- |
||
4033 | // Main window constructor definition (& layout) |
||
4034 | |||
4035 | TGAppMainFrame::TGAppMainFrame(const TGWindow *p, int w, int h) |
||
4036 | { |
||
4037 | gDaq = new daq(); |
||
4038 | gScopeDaq = new daqscope(); |
||
4039 | |||
4040 | // Define the main window and menubar |
||
4041 | fMain = new TGMainFrame(p, w, h, kVerticalFrame); // vertical frame split into menubar and main frame |
||
4042 | fMenuBar = new TGMdiMenuBar(fMain, 10, 10); // just prepare menubar, draw it with InitMenu() |
||
4043 | fMain->AddFrame(fMenuBar, new TGLayoutHints(kLHintsTop | kLHintsExpandX)); |
||
4044 | |||
4045 | // Define the main frame where opened subwindows will appear |
||
4046 | fMainFrame = new TGMdiMainFrame(fMain, fMenuBar, 300, 300); |
||
4047 | fMain->AddFrame(fMainFrame, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY)); |
||
4048 | |||
4049 | // Initialize the menubar the initial measurement layout subwindows and display the main window |
||
4050 | InitMenu(); |
||
4051 | MeasurementLayout(); |
||
4052 | fMain->SetWindowName(WINDOW_NAME); |
||
4053 | fMain->MapSubwindows(); |
||
4054 | fMain->MapWindow(); |
||
4055 | fMain->Layout(); |
||
4056 | GetPosition(); |
||
4057 | GetVoltOut(); |
||
4058 | } |
||
4059 | |||
4060 | //--------------------------------------------------------------- |
||
4061 | // Event handler for menubar actions |
||
4062 | |||
4063 | void TGAppMainFrame::HandleMenu(Int_t id) |
||
4064 | { |
||
4065 | TList *files; |
||
4066 | |||
4067 | switch (id) { |
||
4068 | case M_FILE_NEW: |
||
4069 | // Clear any values and histogram |
||
4070 | break; |
||
4071 | |||
4072 | case M_FILE_EXIT: |
||
4073 | CloseWindow(); |
||
4074 | break; |
||
4075 | |||
4076 | case M_ANALYSIS_HISTTYPE_1DADC: |
||
4077 | // Toggles the ADC button |
||
4078 | ChangeHisttype(0); |
||
4079 | break; |
||
4080 | |||
4081 | case M_ANALYSIS_HISTTYPE_1DTDC: |
||
4082 | ChangeHisttype(1); |
||
4083 | break; |
||
4084 | |||
4085 | case M_ANALYSIS_HISTTYPE_2D: |
||
4086 | ChangeHisttype(2); |
||
4087 | break; |
||
4088 | |||
4089 | case M_ANALYSIS_HISTTYPE_SURF: |
||
4090 | ChangeHisttype(3); |
||
4091 | break; |
||
4092 | |||
4093 | case M_ANALYSIS_FIT: |
||
4094 | // Fit spectrum |
||
4095 | files = new TList(); |
||
4096 | fileList->GetSelectedEntries(files); |
||
4097 | |||
4098 | if( fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DADC) && (files->GetSize() > 0) ) |
||
4099 | FitSpectrum(files, 1); |
||
4100 | break; |
||
4101 | |||
4102 | case M_ANALYSIS_FITSEL: |
||
4103 | // Fit all spectra |
||
4104 | files = new TList(); |
||
4105 | fileList->GetSelectedEntries(files); |
||
4106 | |||
4107 | if( (fMenuHisttype->IsEntryChecked(M_ANALYSIS_HISTTYPE_1DADC)) && (files->GetSize() > 1) ) |
||
4108 | FitSpectrum(files, files->GetSize()); |
||
4109 | break; |
||
4110 | |||
4111 | case M_ANALYSIS_INTEGX: |
||
4112 | // Integrate the current spectra |
||
4113 | files = new TList(); |
||
4114 | fileList->GetSelectedEntries(files); |
||
4115 | |||
4116 | IntegSpectrum(files, 1); |
||
4117 | break; |
||
4118 | |||
4119 | case M_ANALYSIS_INTEGY: |
||
4120 | // Integrate the current spectra |
||
4121 | files = new TList(); |
||
4122 | fileList->GetSelectedEntries(files); |
||
4123 | |||
4124 | IntegSpectrum(files, 2); |
||
4125 | break; |
||
4126 | |||
128 | f9daq | 4127 | case M_ANALYSIS_PHOTMU: |
4128 | // Integrate the current spectra and calculate mean of detected photons: mu = -log(Nped/Ntot) |
||
4129 | files = new TList(); |
||
4130 | fileList->GetSelectedEntries(files); |
||
4131 | |||
4132 | PhotonMu(files); |
||
4133 | break; |
||
4134 | |||
4135 | case M_TOOLS_FIELDPOINT: |
||
4136 | OpenWindow(1); |
||
4137 | break; |
||
4138 | |||
117 | f9daq | 4139 | case M_WINDOW_HOR: |
4140 | fMainFrame->TileHorizontal(); |
||
4141 | break; |
||
4142 | |||
4143 | case M_WINDOW_VERT: |
||
4144 | fMainFrame->TileVertical(); |
||
4145 | break; |
||
4146 | |||
4147 | case M_HELP_ABOUT: |
||
4148 | About(); |
||
4149 | break; |
||
4150 | |||
4151 | default: |
||
4152 | fMainFrame->SetCurrent(id); |
||
4153 | break; |
||
4154 | } |
||
4155 | } |
||
4156 | |||
4157 | //--------------------------------------------------------------- |
||
4158 | // Initialize the main window menu |
||
4159 | |||
4160 | void TGAppMainFrame::InitMenu() |
||
4161 | { |
||
4162 | fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0); |
||
4163 | |||
4164 | // Popup menu in menubar for File controls |
||
4165 | fMenuFile = new TGPopupMenu(gClient->GetRoot()); // adds a new popup menu to the menubar |
||
4166 | fMenuFile->AddEntry(new TGHotString("&New Measurement"), M_FILE_NEW); |
||
4167 | fMenuFile->AddSeparator(); |
||
4168 | fMenuFile->AddEntry(new TGHotString("E&xit"), M_FILE_EXIT); |
||
4169 | |||
4170 | // Popup menu in menubar for Analysis controls |
||
4171 | fMenuHisttype = new TGPopupMenu(gClient->GetRoot()); // adds a cascade menu that will be incorporated into analysis controls |
||
4172 | fMenuHisttype->AddEntry(new TGHotString("1D &ADC histogram"), M_ANALYSIS_HISTTYPE_1DADC); |
||
4173 | fMenuHisttype->AddEntry(new TGHotString("1D &TDC histogram"), M_ANALYSIS_HISTTYPE_1DTDC); |
||
4174 | fMenuHisttype->AddEntry(new TGHotString("&2D ADC vs. TDC histogram"), M_ANALYSIS_HISTTYPE_2D); |
||
4175 | fMenuHisttype->AddEntry(new TGHotString("2D &surface scan plot"), M_ANALYSIS_HISTTYPE_SURF); |
||
4176 | |||
4177 | fMenuAnalysis = new TGPopupMenu(gClient->GetRoot()); // adds a new popup menu to the menubar |
||
4178 | fMenuAnalysis->AddPopup(new TGHotString("&Histogram type"), fMenuHisttype); |
||
4179 | |||
4180 | fMenuAnalysis->AddEntry(new TGHotString("&Fit spectrum"), M_ANALYSIS_FIT); |
||
4181 | fMenuAnalysis->AddEntry(new TGHotString("Fit &all selected"), M_ANALYSIS_FITSEL); |
||
4182 | fMenuAnalysis->AddEntry(new TGHotString("Integrate spectrum (&X direction)"), M_ANALYSIS_INTEGX); |
||
4183 | fMenuAnalysis->AddEntry(new TGHotString("Integrate spectrum (&Y direction)"), M_ANALYSIS_INTEGY); |
||
128 | f9daq | 4184 | fMenuAnalysis->AddEntry(new TGHotString("Relative &PDE"), M_ANALYSIS_PHOTMU); |
117 | f9daq | 4185 | |
128 | f9daq | 4186 | // Popup menu in menubar for External tools |
4187 | fMenuTools = new TGPopupMenu(gClient->GetRoot()); // adds a new popup menu to the menubar |
||
4188 | fMenuTools->AddEntry(new TGHotString("&Fieldpoint temperature sensor"), M_TOOLS_FIELDPOINT); |
||
4189 | |||
117 | f9daq | 4190 | // Popup menu in menubar for Window controls |
4191 | fMenuWindow = new TGPopupMenu(gClient->GetRoot()); // adds a new popup menu to the menubar |
||
4192 | fMenuWindow->AddEntry(new TGHotString("Tile &Horizontally"), M_WINDOW_HOR); |
||
4193 | fMenuWindow->AddEntry(new TGHotString("Tile &Vertically"), M_WINDOW_VERT); |
||
4194 | fMenuWindow->AddPopup(new TGHotString("&Windows"), fMainFrame->GetWinListMenu()); |
||
4195 | |||
4196 | // Popup menu in menubar for Help controls |
||
4197 | fMenuHelp = new TGPopupMenu(gClient->GetRoot()); |
||
4198 | fMenuHelp->AddEntry(new TGHotString("&About"), M_HELP_ABOUT); |
||
4199 | |||
4200 | // Connect all menu items with actions - handled by HandleMenu() |
||
4201 | fMenuFile->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)"); |
||
4202 | fMenuAnalysis->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)"); |
||
128 | f9daq | 4203 | fMenuTools->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)"); |
117 | f9daq | 4204 | fMenuWindow->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)"); |
4205 | fMenuHelp->Connect("Activated(Int_t)", "TGAppMainFrame", this, "HandleMenu(Int_t)"); |
||
4206 | |||
4207 | // Draw the created popup menus on the menubar |
||
4208 | fMenuBar->AddPopup(new TGHotString("&File"), fMenuFile, fMenuBarItemLayout); |
||
4209 | fMenuBar->AddPopup(new TGHotString("&Analysis"),fMenuAnalysis,fMenuBarItemLayout); |
||
128 | f9daq | 4210 | fMenuBar->AddPopup(new TGHotString("&Tools"),fMenuTools,fMenuBarItemLayout); |
117 | f9daq | 4211 | fMenuBar->AddPopup(new TGHotString("&Windows"),fMenuWindow,fMenuBarItemLayout); |
4212 | fMenuBar->AddPopup(new TGHotString("&Help"), fMenuHelp, fMenuBarItemLayout); |
||
129 | f9daq | 4213 | |
4214 | // Disable fieldpoint if we are not connected to the IJS network |
||
4215 | #if IJSNET == 0 |
||
4216 | fMenuTools->DisableEntry(M_TOOLS_FIELDPOINT); |
||
4217 | #endif |
||
117 | f9daq | 4218 | } |
4219 | |||
4220 | //--------------------------------------------------------------- |
||
4221 | // Set the measurement subwindow layout |
||
4222 | |||
4223 | void TGAppMainFrame::MeasurementLayout() |
||
4224 | { |
||
4225 | TGMdiFrame *mdiFrame; |
||
4226 | |||
4227 | // Generic horizontal and vertical frames |
||
4228 | TGHorizontalFrame *fH1, *fH2, *fH3; |
||
4229 | TGVerticalFrame *fV1; |
||
4230 | TGGroupFrame *fG1; |
||
4231 | TGLabel *lab; |
||
4232 | TGCompositeFrame *fT1; |
||
4233 | |||
4234 | // Sizes of internal group and subwindow structures |
||
4235 | int subwin[2]; |
||
4236 | int subgroup[2]; |
||
4237 | |||
4238 | // Settings pane --------------------------------------------------------------------------- |
||
4239 | subwin[0] = (winWidth/6)-5; subwin[1] = 3*((winHeight/5)-5)-10; |
||
4240 | settingsPane = new TGMdiSubwindow(fMainFrame, subwin[0], subwin[1]); |
||
4241 | mdiFrame = settingsPane->GetMdiFrame(); |
||
4242 | |||
4243 | // Check button to toggle voltage scan |
||
4244 | voltscanOn = new TGCheckButton(mdiFrame, "Voltage scan ON/OFF"); |
||
4245 | voltscanOn->Resize(50,22); |
||
4246 | voltscanOn->SetState(kButtonUp); |
||
4247 | mdiFrame->AddFrame(voltscanOn, f0centerx); |
||
4248 | |||
4249 | // Check button to toggle surface scan |
||
4250 | surfscanOn = new TGCheckButton(mdiFrame, "Surface scan ON/OFF"); |
||
4251 | surfscanOn->Resize(50,22); |
||
4252 | surfscanOn->SetState(kButtonUp); |
||
4253 | mdiFrame->AddFrame(surfscanOn, f0centerx); |
||
4254 | |||
4255 | // Check button to toggle Z direction scan |
||
4256 | zscanOn = new TGCheckButton(mdiFrame, "Z-axis scan ON/OFF"); |
||
4257 | zscanOn->Resize(50,22); |
||
4258 | zscanOn->SetState(kButtonUp); |
||
4259 | mdiFrame->AddFrame(zscanOn, f0centerx); |
||
4260 | |||
4261 | // Check button to toggle (open) the histogram window |
||
4262 | // histogramOn = new TGCheckButton(mdiFrame, "Histogram display ON/OFF"); |
||
4263 | // histogramOn->Resize(50,22); |
||
4264 | // histogramOn->SetState(kButtonUp); |
||
4265 | // mdiFrame->AddFrame(histogramOn, f0centerx); |
||
4266 | |||
4267 | subgroup[0] = subwin[0]-10; |
||
4268 | // Hard limit for maximum voltage we can set |
||
4269 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30); |
||
4270 | lab = new TGLabel(fH1, "Voltage limit:"); |
||
4271 | fH1->AddFrame(lab, f0center2d); |
||
4272 | vHardlimit = new TGNumberEntry(fH1, 70.00, 4, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEAAnyNumber); |
||
4273 | vHardlimit->Resize(80,22); |
||
4274 | fH1->AddFrame(vHardlimit, f0center2d); |
||
4275 | mdiFrame->AddFrame(fH1, f2); |
||
4276 | |||
4277 | // Number of used channels |
||
4278 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30); |
||
4279 | lab = new TGLabel(fH1, "Nr. of channels:"); |
||
4280 | fH1->AddFrame(lab, f0center2d); |
||
4281 | NCH = new TGNumberEntry(fH1, 1, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 1, 8); |
||
4282 | NCH->Resize(40,22); |
||
4283 | fH1->AddFrame(NCH, f0center2d); |
||
4284 | mdiFrame->AddFrame(fH1, f2); |
||
4285 | |||
4286 | // Check button to toggle plots with additional information or clean plots |
||
4287 | cleanOn = new TGCheckButton(mdiFrame, "Clean plots ON/OFF"); |
||
4288 | cleanOn->Resize(50,22); |
||
4289 | cleanOn->SetState(kButtonDown); |
||
4290 | cleanPlots = 1; |
||
4291 | mdiFrame->AddFrame(cleanOn, f0centerx); |
||
4292 | |||
4293 | // Button and textbox to enter the oscilloscope IP address |
||
4294 | lab = new TGLabel(mdiFrame, "Scope IP:"); |
||
4295 | mdiFrame->AddFrame(lab, f0); |
||
4296 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30); |
||
4297 | oscIP = new TGTextEntry(fH1, "178.172.43.157"); |
||
4298 | oscIP->Resize(110,22); |
||
4299 | fH1->AddFrame(oscIP, f0); |
||
4300 | oscConnect = new TGTextButton(fH1, "Connect"); |
||
4301 | oscConnect->SetTextJustify(36); |
||
4302 | oscConnect->SetWrapLength(-1); |
||
4303 | oscConnect->Resize(60,22); |
||
4304 | fH1->AddFrame(oscConnect, f0); |
||
4305 | oscOn = 0; |
||
4306 | mdiFrame->AddFrame(fH1, f2); |
||
4307 | |||
4308 | // Laser settings (freq., tune, ND filter) |
||
4309 | lab = new TGLabel(mdiFrame, "Laser settings:"); |
||
4310 | mdiFrame->AddFrame(lab, f0); |
||
4311 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30); |
||
4312 | laserInfo = new TGTextEntry(fH1, "kHz, tune, ND"); |
||
4313 | fH1->AddFrame(laserInfo, f2); |
||
4314 | mdiFrame->AddFrame(fH1, f2); |
||
4315 | |||
127 | f9daq | 4316 | // Chamber temperature (will only be manually set until we can get it directly from the chamber) |
4317 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30); |
||
4318 | lab = new TGLabel(fH1, "Chamber temp.:"); |
||
4319 | fH1->AddFrame(lab, f0center2d); |
||
4320 | chtemp = new TGNumberEntry(fH1, 25.0, 6, 999, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -70., 150.); |
||
4321 | chtemp->Resize(60,22); |
||
4322 | fH1->AddFrame(chtemp, f0center2d); |
||
4323 | mdiFrame->AddFrame(fH1, f2); |
||
128 | f9daq | 4324 | |
4325 | // Incidence angle (will only be manually set until we can make it motorized) |
||
4326 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30); |
||
4327 | lab = new TGLabel(fH1, "Incid. angle:"); |
||
4328 | fH1->AddFrame(lab, f0center2d); |
||
4329 | incangle = new TGNumberEntry(fH1, 0.0, 6, 999, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -180., 180.); |
||
4330 | incangle->Resize(60,22); |
||
4331 | fH1->AddFrame(incangle, f0center2d); |
||
4332 | mdiFrame->AddFrame(fH1, f2); |
||
127 | f9daq | 4333 | |
117 | f9daq | 4334 | mdiFrame->SetMdiHints(kMdiMinimize); |
4335 | mdiFrame->SetWindowName("Settings pane"); |
||
4336 | mdiFrame->MapSubwindows(); |
||
4337 | mdiFrame->Layout(); |
||
4338 | mdiFrame->Move(0,0); |
||
4339 | // Settings pane --------------------------------------------------------------------------- |
||
4340 | |||
4341 | // Main window ----------------------------------------------------------------------------- |
||
4342 | subwin[0] = 3*((winWidth/6)-5); subwin[1] = 3*((winHeight/5)-5)-10; |
||
4343 | mainSubwindow = new TGMdiSubwindow(fMainFrame, subwin[0], subwin[1]); |
||
4344 | mdiFrame = mainSubwindow->GetMdiFrame(); |
||
4345 | |||
4346 | // Voltage and position tab |
||
4347 | subgroup[0] = 2*subwin[0]/5-12; |
||
4348 | subgroup[1] = (subwin[1]+15)/2+5; |
||
4349 | setTab = new TGTab(mdiFrame, subgroup[0], subgroup[1]); |
||
4350 | |||
4351 | fT1 = setTab->AddTab("Voltage + Position"); |
||
4352 | |||
4353 | fH1 = new TGHorizontalFrame(fT1, subwin[0], subgroup[1], kFixedHeight); |
||
4354 | // Left pane (Bias voltage controls) |
||
4355 | fV1 = new TGVerticalFrame(fH1, subgroup[0], subgroup[1], kFixedWidth | kFixedHeight); |
||
4356 | fG1 = new TGGroupFrame(fV1, "Bias voltage controls"); |
||
4357 | |||
4358 | // Output voltage supply channel |
||
4359 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4360 | lab = new TGLabel(fH2, "Output channel:"); |
||
4361 | fH2->AddFrame(lab, f0center2d); |
||
4362 | vOutCh = new TGComboBox(fH2, 200); |
||
4363 | vOutCh->AddEntry("1", 0); |
||
4364 | vOutCh->AddEntry("2", 1); |
||
4365 | vOutCh->AddEntry("3", 2); |
||
4366 | vOutCh->AddEntry("4", 3); |
||
4367 | vOutCh->AddEntry("5", 4); |
||
4368 | vOutCh->AddEntry("6", 5); |
||
4369 | vOutCh->AddEntry("7", 6); |
||
4370 | vOutCh->AddEntry("8", 7); |
||
4371 | vOutCh->AddEntry("101", 8); |
||
4372 | vOutCh->AddEntry("102", 9); |
||
4373 | vOutCh->AddEntry("103", 10); |
||
4374 | vOutCh->AddEntry("104", 11); |
||
4375 | vOutCh->AddEntry("105", 12); |
||
4376 | vOutCh->AddEntry("106", 13); |
||
4377 | vOutCh->AddEntry("107", 14); |
||
4378 | vOutCh->AddEntry("108", 15); |
||
4379 | vOutCh->Resize(50,22); |
||
4380 | vOutCh->Select(0); |
||
4381 | fH2->AddFrame(vOutCh, f0center2d); |
||
4382 | fG1->AddFrame(fH2, f2); |
||
4383 | |||
4384 | // Output voltage setting |
||
4385 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4386 | lab = new TGLabel(fH2, "Output voltage:"); |
||
4387 | fH2->AddFrame(lab, f0center2d); |
||
4388 | vOut = new TGNumberEntry(fH2, 0.00, 4, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, 0, vHardlimit->GetNumber()); |
||
4389 | vOut->Resize(80,22); |
||
4390 | fH2->AddFrame(vOut, f0center2d); |
||
4391 | fG1->AddFrame(fH2, f2); |
||
4392 | |||
4393 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4394 | vOutOnOff = new TGCheckButton(fH2, "Output ON/OFF"); |
||
4395 | vOutOnOff->Resize(subgroup[0]-10,22); |
||
4396 | vOutOnOff->SetState(kButtonUp); |
||
4397 | fH2->AddFrame(vOutOnOff, f0centerx); |
||
4398 | fG1->AddFrame(fH2, f2); |
||
4399 | |||
4400 | // Set, get and reset voltage buttons |
||
4401 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4402 | fH3 = new TGHorizontalFrame(fH2, subgroup[0], 30); |
||
4403 | vOutSet = new TGTextButton(fH3, "Set"); |
||
4404 | vOutSet->SetTextJustify(36); |
||
4405 | vOutSet->SetWrapLength(-1); |
||
4406 | vOutSet->Resize(60,22); |
||
4407 | fH3->AddFrame(vOutSet, f0); |
||
4408 | vOutGet = new TGTextButton(fH3, "Get"); |
||
4409 | vOutGet->SetTextJustify(36); |
||
4410 | vOutGet->SetWrapLength(-1); |
||
4411 | vOutGet->Resize(60,22); |
||
4412 | fH3->AddFrame(vOutGet, f0); |
||
4413 | vOutReset = new TGTextButton(fH3, "Reset"); |
||
4414 | vOutReset->SetTextJustify(36); |
||
4415 | vOutReset->SetWrapLength(-1); |
||
4416 | vOutReset->Resize(60,22); |
||
4417 | fH3->AddFrame(vOutReset, f0); |
||
4418 | fH2->AddFrame(fH3, f0centerx); |
||
4419 | fG1->AddFrame(fH2, f2); |
||
4420 | |||
4421 | // Voltage scan controls |
||
4422 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4423 | lab = new TGLabel(fH2, "V (min):"); |
||
4424 | fH2->AddFrame(lab, f0center2d); |
||
4425 | vOutStart = new TGNumberEntry(fH2, 0.00, 4, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEAAnyNumber); |
||
4426 | vOutStart->Resize(80,22); |
||
4427 | fH2->AddFrame(vOutStart, f0center2d); |
||
4428 | fG1->AddFrame(fH2, f2); |
||
4429 | |||
4430 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4431 | lab = new TGLabel(fH2, "V (max):"); |
||
4432 | fH2->AddFrame(lab, f0center2d); |
||
4433 | vOutStop = new TGNumberEntry(fH2, 0.00, 4, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEAAnyNumber); |
||
4434 | vOutStop->Resize(80,22); |
||
4435 | fH2->AddFrame(vOutStop, f0center2d); |
||
4436 | fG1->AddFrame(fH2, f2); |
||
4437 | |||
4438 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4439 | lab = new TGLabel(fH2, "V (step):"); |
||
4440 | fH2->AddFrame(lab, f0center2d); |
||
4441 | vOutStep = new TGNumberEntry(fH2, 0.00, 4, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEAAnyNumber); |
||
4442 | vOutStep->Resize(80,22); |
||
4443 | fH2->AddFrame(vOutStep, f0center2d); |
||
4444 | fG1->AddFrame(fH2, f2); |
||
4445 | |||
4446 | fV1->AddFrame(fG1, f1); |
||
4447 | // Left pane (Bias voltage controls) |
||
4448 | fH1->AddFrame(fV1, f0); |
||
4449 | |||
4450 | // Right pane (Table position controls) |
||
4451 | subgroup[0] = 3*subwin[0]/5-12; |
||
4452 | fV1 = new TGVerticalFrame(fH1, subgroup[0], subgroup[1], kFixedWidth | kFixedHeight); |
||
4453 | fG1 = new TGGroupFrame(fV1, "Table position controls"); |
||
4454 | |||
4455 | // X, Y and Z positions |
||
4456 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4457 | lab = new TGLabel(fH2, "X:"); |
||
4458 | fH2->AddFrame(lab, f0center2d); |
||
4459 | xPos = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 215000); |
||
4460 | xPos->Resize(80,22); |
||
4461 | fH2->AddFrame(xPos, f0center2d); |
||
4462 | |||
4463 | lab = new TGLabel(fH2, "Z (min):"); |
||
4464 | fH2->AddFrame(lab, f0center2d); |
||
4465 | zPosMin = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 375000); |
||
4466 | zPosMin->Resize(80,22); |
||
4467 | fH2->AddFrame(zPosMin, f0center2d); |
||
4468 | fG1->AddFrame(fH2, f2); |
||
4469 | |||
4470 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4471 | lab = new TGLabel(fH2, "Y:"); |
||
4472 | fH2->AddFrame(lab, f0center2d); |
||
4473 | yPos = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 215000); |
||
4474 | yPos->Resize(80,22); |
||
4475 | fH2->AddFrame(yPos, f0center2d); |
||
4476 | |||
4477 | lab = new TGLabel(fH2, "Z (max):"); |
||
4478 | fH2->AddFrame(lab, f0center2d); |
||
4479 | zPosMax = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 375000); |
||
4480 | zPosMax->Resize(80,22); |
||
4481 | fH2->AddFrame(zPosMax, f0center2d); |
||
4482 | fG1->AddFrame(fH2, f2); |
||
4483 | |||
4484 | fH2 = new TGHorizontalFrame(fG1, subgroup[0] ,30); |
||
4485 | lab = new TGLabel(fH2, "Z:"); |
||
4486 | fH2->AddFrame(lab, f0center2d); |
||
4487 | zPos = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 375000); |
||
4488 | zPos->Resize(80,22); |
||
4489 | fH2->AddFrame(zPos, f0center2d); |
||
4490 | |||
4491 | lab = new TGLabel(fH2, "Z (step):"); |
||
4492 | fH2->AddFrame(lab, f0center2d); |
||
4493 | zPosStep = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); |
||
4494 | zPosStep->Resize(80,22); |
||
4495 | fH2->AddFrame(zPosStep, f0center2d); |
||
4496 | fG1->AddFrame(fH2, f2); |
||
4497 | |||
4498 | // Set, Get and Home the table position |
||
4499 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4500 | fH3 = new TGHorizontalFrame(fH2, subgroup[0], 30); |
||
4501 | positionSet = new TGTextButton(fH3, "Set"); |
||
4502 | positionSet->SetTextJustify(36); |
||
4503 | positionSet->SetWrapLength(-1); |
||
4504 | positionSet->Resize(60,22); |
||
4505 | fH3->AddFrame(positionSet, f0); |
||
4506 | positionGet = new TGTextButton(fH3, "Get"); |
||
4507 | positionGet->SetTextJustify(36); |
||
4508 | positionGet->SetWrapLength(-1); |
||
4509 | positionGet->Resize(60,22); |
||
4510 | fH3->AddFrame(positionGet, f0); |
||
4511 | positionHome = new TGTextButton(fH3, "Home"); |
||
4512 | positionHome->SetTextJustify(36); |
||
4513 | positionHome->SetWrapLength(-1); |
||
4514 | positionHome->Resize(60,22); |
||
4515 | fH3->AddFrame(positionHome, f0); |
||
4516 | fH2->AddFrame(fH3, f0centerx); |
||
4517 | fG1->AddFrame(fH2, f2); |
||
4518 | |||
4519 | // Position scan controls |
||
4520 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4521 | lab = new TGLabel(fH2, "X (min):"); |
||
4522 | fH2->AddFrame(lab, f0center2d); |
||
4523 | xPosMin = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 215000); |
||
4524 | xPosMin->Resize(80,22); |
||
4525 | fH2->AddFrame(xPosMin, f0center2d); |
||
4526 | |||
4527 | lab = new TGLabel(fH2, "Y (min):"); |
||
4528 | fH2->AddFrame(lab, f0center2d); |
||
4529 | yPosMin = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 215000); |
||
4530 | yPosMin->Resize(80,22); |
||
4531 | fH2->AddFrame(yPosMin, f0center2d); |
||
4532 | fG1->AddFrame(fH2, f2); |
||
4533 | |||
4534 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4535 | lab = new TGLabel(fH2, "X (max):"); |
||
4536 | fH2->AddFrame(lab, f0center2d); |
||
4537 | xPosMax = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 215000); |
||
4538 | xPosMax->Resize(80,22); |
||
4539 | fH2->AddFrame(xPosMax, f0center2d); |
||
4540 | |||
4541 | lab = new TGLabel(fH2, "Y (max):"); |
||
4542 | fH2->AddFrame(lab, f0center2d); |
||
4543 | yPosMax = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELLimitMinMax, -100, 215000); |
||
4544 | yPosMax->Resize(80,22); |
||
4545 | fH2->AddFrame(yPosMax, f0center2d); |
||
4546 | fG1->AddFrame(fH2, f2); |
||
4547 | |||
4548 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4549 | lab = new TGLabel(fH2, "X (step):"); |
||
4550 | fH2->AddFrame(lab, f0center2d); |
||
4551 | xPosStep = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); |
||
4552 | xPosStep->Resize(80,22); |
||
4553 | fH2->AddFrame(xPosStep, f0center2d); |
||
4554 | |||
4555 | lab = new TGLabel(fH2, "Y (step):"); |
||
4556 | fH2->AddFrame(lab, f0center2d); |
||
4557 | yPosStep = new TGNumberEntry(fH2, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); |
||
4558 | yPosStep->Resize(80,22); |
||
4559 | fH2->AddFrame(yPosStep, f0center2d); |
||
4560 | fG1->AddFrame(fH2, f2); |
||
4561 | |||
4562 | fV1->AddFrame(fG1, f1); |
||
4563 | // Right pane (Table position controls) |
||
4564 | fH1->AddFrame(fV1, f0); |
||
4565 | fT1->AddFrame(fH1, f1); |
||
4566 | |||
4567 | // Waveform tab |
||
127 | f9daq | 4568 | fT1 = setTab->AddTab("Waveform analysis"); |
117 | f9daq | 4569 | fH1 = new TGHorizontalFrame(fT1, subwin[0], subgroup[1], kFixedHeight); |
127 | f9daq | 4570 | subgroup[0] = 1*subwin[0]/2-12; |
4571 | fV1 = new TGVerticalFrame(fH1, subgroup[0], subgroup[1]/3, kFixedWidth); |
||
117 | f9daq | 4572 | |
127 | f9daq | 4573 | fG1 = new TGGroupFrame(fV1, "Acquisition channel"); |
117 | f9daq | 4574 | |
127 | f9daq | 4575 | // Selection of channels |
4576 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 100); |
||
4577 | sCH[0] = new TGCheckButton(fH2, "CH1"); |
||
4578 | sCH[0]->Resize(50,22); |
||
4579 | sCH[0]->SetState(kButtonUp); |
||
4580 | fH2->AddFrame(sCH[0], f0centerx); |
||
4581 | sCH[1] = new TGCheckButton(fH2, "CH2"); |
||
4582 | sCH[1]->Resize(50,22); |
||
4583 | sCH[1]->SetState(kButtonUp); |
||
4584 | fH2->AddFrame(sCH[1], f0centerx); |
||
4585 | sCH[2] = new TGCheckButton(fH2, "CH3"); |
||
4586 | sCH[2]->Resize(50,22); |
||
4587 | sCH[2]->SetState(kButtonUp); |
||
4588 | fH2->AddFrame(sCH[2], f0centerx); |
||
4589 | sCH[3] = new TGCheckButton(fH2, "CH4"); |
||
4590 | sCH[3]->Resize(50,22); |
||
4591 | sCH[3]->SetState(kButtonUp); |
||
4592 | fH2->AddFrame(sCH[3], f0centerx); |
||
4593 | fG1->AddFrame(fH2, f0centerx); |
||
4594 | |||
4595 | // Selection of MATH channels |
||
4596 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 100); |
||
4597 | sCH[4] = new TGCheckButton(fH2, "MATH1"); |
||
4598 | sCH[4]->Resize(50,22); |
||
4599 | sCH[4]->SetState(kButtonUp); |
||
4600 | fH2->AddFrame(sCH[4], f0centerx); |
||
4601 | sCH[5] = new TGCheckButton(fH2, "MATH2"); |
||
4602 | sCH[5]->Resize(50,22); |
||
4603 | sCH[5]->SetState(kButtonUp); |
||
4604 | fH2->AddFrame(sCH[5], f0centerx); |
||
4605 | sCH[6] = new TGCheckButton(fH2, "MATH3"); |
||
4606 | sCH[6]->Resize(50,22); |
||
4607 | sCH[6]->SetState(kButtonUp); |
||
4608 | fH2->AddFrame(sCH[6], f0centerx); |
||
4609 | sCH[7] = new TGCheckButton(fH2, "MATH4"); |
||
4610 | sCH[7]->Resize(50,22); |
||
4611 | sCH[7]->SetState(kButtonUp); |
||
4612 | fH2->AddFrame(sCH[7], f0centerx); |
||
4613 | fG1->AddFrame(fH2, f0centerx); |
||
4614 | |||
4615 | fV1->AddFrame(fG1, f2); |
||
4616 | |||
4617 | // Selection of measurement type |
||
4618 | fH2 = new TGHorizontalFrame(fV1, subgroup[0], 30); |
||
4619 | lab = new TGLabel(fH2, "Scope use type:"); |
||
4620 | fH2->AddFrame(lab, f0center2d); |
||
4621 | sMeasType = new TGComboBox(fH2, 200); |
||
4622 | sMeasType->AddEntry("No waveform analysis", 0); |
||
4623 | sMeasType->AddEntry("Waveform acquisition", 1); |
||
4624 | sMeasType->AddEntry("Measurement", 2); |
||
4625 | sMeasType->Resize(150,22); |
||
4626 | sMeasType->Select(0); |
||
4627 | fH2->AddFrame(sMeasType, f0center2d); |
||
4628 | fV1->AddFrame(fH2, f2); |
||
4629 | |||
4630 | // Link waveform analysis to CAMAC acquisition |
||
4631 | sCamaclink = new TGCheckButton(fV1, "Link waveform to CAMAC acquisition"); |
||
4632 | sCamaclink->Resize(200,22); |
||
4633 | sCamaclink->SetState(kButtonUp); |
||
4634 | fV1->AddFrame(sCamaclink, f0centerx); |
||
4635 | |||
4636 | // Custom command interface for the scope |
||
4637 | lab = new TGLabel(fV1, "Custom scope command:"); |
||
4638 | fV1->AddFrame(lab, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,10,2) ); |
||
4639 | fH2 = new TGHorizontalFrame(fV1, subgroup[0], 30); |
||
4640 | scopeCommand = new TGTextEntry(fH2, ""); |
||
4641 | scopeCommand->Resize(subgroup[0]-45,22); |
||
4642 | fH2->AddFrame(scopeCommand, f2); |
||
4643 | sendScopeCustom = new TGTextButton(fH2, "Send"); |
||
4644 | sendScopeCustom->SetTextJustify(36); |
||
4645 | sendScopeCustom->SetWrapLength(-1); |
||
4646 | sendScopeCustom->Resize(80,22); |
||
4647 | fH2->AddFrame(sendScopeCustom, f0centery); |
||
4648 | fV1->AddFrame(fH2, f0); |
||
4649 | |||
4650 | // Return value for custom scope command |
||
4651 | lab = new TGLabel(fV1, "Return:"); |
||
4652 | fV1->AddFrame(lab, new TGLayoutHints(kLHintsLeft | kLHintsTop,2,2,10,2) ); |
||
4653 | scopeReturn = new TGTextEntry(fV1, ""); |
||
4654 | scopeReturn->Resize(subgroup[0],22); |
||
4655 | fV1->AddFrame(scopeReturn, f2); |
||
4656 | |||
4657 | fH1->AddFrame(fV1, f0); |
||
4658 | |||
4659 | // Wave measurement type |
||
4660 | fV1 = new TGVerticalFrame(fH1, subgroup[0], subgroup[1]/3, kFixedWidth); |
||
4661 | fH2 = new TGHorizontalFrame(fV1, subgroup[0], 30); |
||
4662 | lab = new TGLabel(fH2, "Meas. type:"); |
||
4663 | fH2->AddFrame(lab, f0center2d); |
||
4664 | sMeasgroup = new TGComboBox(fH2, 200); |
||
4665 | for(int i = 0; i < 11; i++) |
||
4666 | sMeasgroup->AddEntry(allMeasNames[i], i); |
||
4667 | sMeasgroup->Resize(150,22); |
||
4668 | sMeasgroup->Select(4); |
||
4669 | fH2->AddFrame(sMeasgroup, f0center2d); |
||
4670 | fV1->AddFrame(fH2, f2); |
||
4671 | |||
4672 | // Initialize current acquisition settings |
||
4673 | scopeInit = new TGTextButton(fV1, "Initialize scope"); |
||
4674 | scopeInit->SetTextJustify(36); |
||
4675 | scopeInit->SetWrapLength(-1); |
||
4676 | scopeInit->Resize(80,22); |
||
4677 | fV1->AddFrame(scopeInit, f0centerx); |
||
4678 | |||
4679 | fH1->AddFrame(fV1, f0); |
||
4680 | fT1->AddFrame(fH1, f1); |
||
4681 | |||
117 | f9daq | 4682 | mdiFrame->AddFrame(setTab, f0); |
4683 | |||
4684 | // Bottom pane (File controls) |
||
4685 | subgroup[0] = subwin[0]-20; |
||
4686 | subgroup[1] = subwin[1]/3-30; //2*(3*((winWidth/6)-5))/5+10; |
||
4687 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], subgroup[1] /*1*(3*((winWidth/6)-5))/5+15*/ , kFixedWidth | kFixedHeight); |
||
4688 | fG1 = new TGGroupFrame(fH1, "Event/Data file controls"); |
||
4689 | |||
4690 | // Number of events |
||
4691 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4692 | lab = new TGLabel(fH2, "Number of events:"); |
||
4693 | fH2->AddFrame(lab, f0centery); |
||
4694 | evtNum = new TGNumberEntry(fH2, 10000, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); |
||
4695 | evtNum->Resize(80,22); |
||
4696 | fH2->AddFrame(evtNum, f0centery); |
||
4697 | fG1->AddFrame(fH2, f2); |
||
4698 | |||
4699 | // Time stamp display |
||
4700 | fH2 = new TGHorizontalFrame(fG1,600,200); |
||
4701 | lab = new TGLabel(fH2, "Time stamp:"); |
||
4702 | fH2->AddFrame(lab, f0centery); |
||
4703 | timeStamp = new TGTextEntry(fH2, ""); |
||
4704 | timeStamp->Resize(440,22); |
||
4705 | timeStamp->SetState(kFALSE); // time stamp is read-only |
||
4706 | fH2->AddFrame(timeStamp, f0centery); |
||
4707 | fG1->AddFrame(fH2, f2); |
||
4708 | |||
4709 | // Save to file |
||
4710 | fH2 = new TGHorizontalFrame(fG1,600,200); |
||
4711 | lab = new TGLabel(fH2, "Save to file:"); |
||
4712 | fH2->AddFrame(lab, f0centery); |
||
4713 | char *cTemp; |
||
4714 | cTemp = new char[256]; |
||
4715 | sprintf(cTemp, "./results/test%s", histExt); |
||
4716 | fileName = new TGTextEntry(fH2, cTemp); |
||
4717 | delete[] cTemp; |
||
4718 | fileName->Resize(400,22); |
||
4719 | fileName->SetState(kFALSE); |
||
4720 | fH2->AddFrame(fileName, f0centery); |
||
4721 | saveFile = new TGTextButton(fH2, "..."); |
||
4722 | saveFile->SetTextJustify(36); |
||
4723 | saveFile->SetWrapLength(-1); |
||
4724 | saveFile->Resize(80,22); |
||
4725 | fH2->AddFrame(saveFile, f0centery); |
||
4726 | // mdiFrame->AddFrame(fH2, f0); |
||
4727 | fG1->AddFrame(fH2, f2); |
||
4728 | fH1->AddFrame(fG1, f1); |
||
4729 | // Bottom pane (File controls) |
||
4730 | mdiFrame->AddFrame(fH1, f0); |
||
4731 | |||
4732 | subgroup[0] = subwin[0]-70; |
||
4733 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30); |
||
4734 | fH2 = new TGHorizontalFrame(fH1, 3*subgroup[0]/4, 30, kFixedWidth); |
||
4735 | measStart = new TGTextButton(fH2, "Start acquisition"); |
||
4736 | measStart->SetTextJustify(36); |
||
4737 | measStart->SetWrapLength(-1); |
||
4738 | measStart->Resize(80,22); |
||
4739 | fH2->AddFrame(measStart, f0center2d); |
||
4740 | |||
4741 | ULong_t fcolor; |
||
4742 | gClient->GetColorByName("red", fcolor); |
||
4743 | |||
4744 | busyLabel = new TGLabel(fH2, "Busy"); //, fTextGC->GetGC(), labelfont, kChildFrame); |
||
4745 | busyLabel->SetTextJustify(36); |
||
4746 | busyLabel->Resize(80,22); |
||
4747 | busyLabel->Disable(); |
||
4748 | busyLabel->SetTextColor(fcolor); |
||
4749 | fH2->AddFrame(busyLabel, f0center2d); |
||
4750 | |||
4751 | curProgress = new TGHProgressBar(fH2, TGProgressBar::kStandard, 150); |
||
4752 | curProgress->ShowPosition(); |
||
4753 | curProgress->SetRange(0,100); |
||
4754 | curProgress->SetBarColor("green"); |
||
4755 | fH2->AddFrame(curProgress, f0center2d); |
||
4756 | fH1->AddFrame(fH2, f0centerx); |
||
4757 | mdiFrame->AddFrame(fH1, f2); |
||
4758 | |||
4759 | mdiFrame->SetMdiHints(kMdiMinimize | kMdiMaximize); |
||
4760 | mdiFrame->SetWindowName("Main measurement window"); |
||
4761 | mdiFrame->MapSubwindows(); |
||
4762 | mdiFrame->Layout(); |
||
4763 | mdiFrame->Move((winWidth/6),0); |
||
4764 | // Main window ----------------------------------------------------------------------------- |
||
4765 | |||
4766 | // Histogram pane -------------------------------------------------------------------------- |
||
4767 | subwin[0] = 2*((winWidth/6)-5); subwin[1] = (int)(2.5*((winHeight/5)-5))-5; |
||
4768 | histogramPane = new TGMdiSubwindow(fMainFrame, subwin[0], subwin[1]); |
||
4769 | mdiFrame = histogramPane->GetMdiFrame(); |
||
4770 | |||
4771 | histCanvas = new TRootEmbeddedCanvas("histCanvas",mdiFrame,900,900); |
||
4772 | mdiFrame->AddFrame(histCanvas, f1); |
||
4773 | TCanvas *gCanvas = histCanvas->GetCanvas(); |
||
4774 | gCanvas->SetGridx(); |
||
4775 | gCanvas->SetGridy(); |
||
4776 | |||
4777 | mdiFrame->SetMdiHints(kMdiMinimize | kMdiMaximize); |
||
4778 | mdiFrame->SetWindowName("Histogram"); |
||
4779 | mdiFrame->MapSubwindows(); |
||
4780 | mdiFrame->Layout(); |
||
4781 | mdiFrame->Move(4*((winWidth/6)-5)+10,0); |
||
4782 | // Histogram pane -------------------------------------------------------------------------- |
||
4783 | |||
4784 | // Histogram file selection pane ----------------------------------------------------------- |
||
4785 | subwin[0] = 4*((winWidth/6)-5); subwin[1] = 2*((winHeight/5)-5)+15; |
||
4786 | histogramPaneFile = new TGMdiSubwindow(fMainFrame, subwin[0]+5, subwin[1]); |
||
4787 | mdiFrame = histogramPaneFile->GetMdiFrame(); |
||
4788 | |||
4789 | // Open browser for file selection |
||
4790 | subgroup[0] = subwin[0]-10; |
||
4791 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30); |
||
4792 | lab = new TGLabel(fH1, "File selection:"); |
||
4793 | fH1->AddFrame(lab, f0centery); |
||
4794 | |||
4795 | selectDir = new TGTextButton(fH1, "..."); |
||
4796 | selectDir->SetTextJustify(36); |
||
4797 | selectDir->SetWrapLength(-1); |
||
4798 | selectDir->Resize(80,22); |
||
4799 | fH1->AddFrame(selectDir, f0centery); |
||
4800 | mdiFrame->AddFrame(fH1, f2); |
||
4801 | |||
4802 | // List view of the opened files |
||
4803 | fileList = new TGListBox(mdiFrame,1); |
||
4804 | fileList->GetVScrollbar(); |
||
128 | f9daq | 4805 | fileList->Resize(300, (3*subwin[1]/7)-10 ); |
117 | f9daq | 4806 | mdiFrame->AddFrame(fileList, f2); |
4807 | |||
129 | f9daq | 4808 | // Multiple file selection toggle, previous/next controls, clear list and edit header |
117 | f9daq | 4809 | fH1 = new TGHorizontalFrame(mdiFrame, subgroup[0], 30); |
4810 | multiSelect = new TGCheckButton(fH1, "Multiple file select"); |
||
4811 | multiSelect->Resize(50,22); |
||
4812 | multiSelect->SetState(kButtonUp); |
||
4813 | fH1->AddFrame(multiSelect, f0); |
||
4814 | |||
4815 | multiSelectAll = new TGCheckButton(fH1, "Select all listed files"); |
||
4816 | multiSelectAll->Resize(50,22); |
||
4817 | multiSelectAll->SetState(kButtonUp); |
||
4818 | fH1->AddFrame(multiSelectAll, f0); |
||
4819 | |||
4820 | TGTextButton *clearList = new TGTextButton(fH1, "Clear list"); |
||
4821 | clearList->SetTextJustify(36); |
||
4822 | clearList->SetWrapLength(-1); |
||
4823 | clearList->Resize(80,22); |
||
4824 | fH1->AddFrame(clearList, f0right); |
||
4825 | |||
129 | f9daq | 4826 | TGTextButton *editHeader = new TGTextButton(fH1, "Edit header"); |
4827 | editHeader->SetTextJustify(36); |
||
4828 | editHeader->SetWrapLength(-1); |
||
4829 | editHeader->Resize(80,22); |
||
4830 | fH1->AddFrame(editHeader, f0right); |
||
4831 | |||
117 | f9daq | 4832 | nextFile = new TGTextButton(fH1, ">>"); |
4833 | nextFile->SetTextJustify(36); |
||
4834 | nextFile->SetWrapLength(-1); |
||
4835 | nextFile->Resize(80,22); |
||
4836 | fH1->AddFrame(nextFile, f0right); |
||
4837 | |||
4838 | prevFile = new TGTextButton(fH1, "<<"); |
||
4839 | prevFile->SetTextJustify(36); |
||
4840 | prevFile->SetWrapLength(-1); |
||
4841 | prevFile->Resize(80,22); |
||
4842 | fH1->AddFrame(prevFile, f0right); |
||
4843 | mdiFrame->AddFrame(fH1, f2); |
||
4844 | |||
128 | f9daq | 4845 | // Header information of opened file |
4846 | fG1 = new TGGroupFrame(mdiFrame, "Opened file header information"); |
||
4847 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4848 | lab = new TGLabel(fH1, "Time:"); |
||
4849 | fH1->AddFrame(lab, f0centery); |
||
4850 | disptime = new TGTextEntry(fH1, ""); |
||
4851 | disptime->Resize(440,22); |
||
4852 | disptime->SetState(kFALSE); |
||
4853 | fH1->AddFrame(disptime, f0centery); |
||
4854 | fG1->AddFrame(fH1, f2); |
||
4855 | |||
4856 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4857 | lab = new TGLabel(fH1, "Bias voltage:"); |
||
4858 | fH1->AddFrame(lab, f0centery); |
||
4859 | dispbias = new TGNumberEntry(fH1, 0.00, 4, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEAAnyNumber); |
||
4860 | dispbias->Resize(80,22); |
||
4861 | dispbias->SetState(kFALSE); |
||
4862 | fH1->AddFrame(dispbias, f0centery); |
||
4863 | |||
4864 | lab = new TGLabel(fH1, "Position:"); |
||
4865 | fH1->AddFrame(lab, f0centery); |
||
4866 | disppos = new TGTextEntry(fH1, ""); |
||
4867 | disppos->Resize(200,22); |
||
4868 | disppos->SetState(kFALSE); |
||
4869 | fH1->AddFrame(disppos, f0centery); |
||
4870 | |||
4871 | lab = new TGLabel(fH1, "Temperature:"); |
||
4872 | fH1->AddFrame(lab, f0centery); |
||
4873 | disptemp = new TGNumberEntry(fH1, 0.0, 6, 999, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAAnyNumber); |
||
4874 | disptemp->Resize(80,22); |
||
4875 | disptemp->SetState(kFALSE); |
||
4876 | fH1->AddFrame(disptemp, f0centery); |
||
4877 | |||
4878 | lab = new TGLabel(fH1, "Angle:"); |
||
4879 | fH1->AddFrame(lab, f0centery); |
||
4880 | dispangle = new TGNumberEntry(fH1, 0.0, 6, 999, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAAnyNumber); |
||
4881 | dispangle->Resize(80,22); |
||
4882 | dispangle->SetState(kFALSE); |
||
4883 | fH1->AddFrame(dispangle, f0centery); |
||
4884 | fG1->AddFrame(fH1, f2); |
||
4885 | |||
4886 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4887 | lab = new TGLabel(fH1, "Laser settings:"); |
||
4888 | fH1->AddFrame(lab, f0centery); |
||
4889 | displaser = new TGTextEntry(fH1, ""); |
||
4890 | displaser->Resize(440,22); |
||
4891 | displaser->SetState(kFALSE); |
||
4892 | fH1->AddFrame(displaser, f0centery); |
||
4893 | fG1->AddFrame(fH1, f2); |
||
4894 | mdiFrame->AddFrame(fG1, f2); |
||
4895 | |||
117 | f9daq | 4896 | mdiFrame->SetMdiHints(kMdiMinimize); |
4897 | mdiFrame->SetWindowName("Histogram file selection"); |
||
4898 | mdiFrame->MapSubwindows(); |
||
4899 | mdiFrame->Layout(); |
||
4900 | mdiFrame->Move(0,3*((winHeight/5)-5)-5); |
||
4901 | // Histogram file selection pane ----------------------------------------------------------- |
||
4902 | |||
4903 | // Histogram controls pane ----------------------------------------------------------------- |
||
4904 | subwin[0] = 2*((winWidth/6)-5); subwin[1] = (int)(2.5*((winHeight/5)-5))+10; |
||
4905 | histogramPaneCtr = new TGMdiSubwindow(fMainFrame, subwin[0], subwin[1]); |
||
4906 | mdiFrame = histogramPaneCtr->GetMdiFrame(); |
||
4907 | |||
4908 | // Control for histogram X range |
||
129 | f9daq | 4909 | subgroup[0] = subwin[0]-6; |
117 | f9daq | 4910 | fG1 = new TGGroupFrame(mdiFrame, "Histogram display"); |
4911 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4912 | lab = new TGLabel(fH1, "ADC range (min, max):"); |
||
4913 | fH1->AddFrame(lab, f0centery); |
||
4914 | adcMinRange = new TGNumberEntry(fH1, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber); |
||
4915 | adcMinRange->Resize(80,22); |
||
4916 | fH1->AddFrame(adcMinRange, f0centery); |
||
4917 | adcMaxRange = new TGNumberEntry(fH1, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber); |
||
4918 | adcMaxRange->Resize(80,22); |
||
4919 | fH1->AddFrame(adcMaxRange, f0centery); |
||
4920 | fG1->AddFrame(fH1, f2); |
||
4921 | |||
4922 | // TDC window for getting data |
||
4923 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4924 | lab = new TGLabel(fH1, "TDC range (min, max):"); |
||
4925 | fH1->AddFrame(lab, f0centery); |
||
4926 | tdcMinwindow = new TGNumberEntry(fH1, 0.0, 6, 999, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEAAnyNumber); |
||
4927 | tdcMinwindow->Resize(80,22); |
||
4928 | fH1->AddFrame(tdcMinwindow, f0centery); |
||
4929 | tdcMaxwindow = new TGNumberEntry(fH1, 221.8, 6, 999, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEAAnyNumber); |
||
4930 | tdcMaxwindow->Resize(80,22); |
||
4931 | fH1->AddFrame(tdcMaxwindow, f0centery); |
||
4932 | fG1->AddFrame(fH1, f2); |
||
4933 | |||
4934 | // Y axis range settings |
||
4935 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4936 | lab = new TGLabel(fH1, "Y range (min, max):"); |
||
4937 | fH1->AddFrame(lab, f0centery); |
||
4938 | yMinRange = new TGNumberEntry(fH1, 0, 6, 999, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAAnyNumber); |
||
4939 | yMinRange->Resize(80,22); |
||
4940 | fH1->AddFrame(yMinRange, f0centery); |
||
4941 | yMaxRange = new TGNumberEntry(fH1, 0, 6, 999, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAAnyNumber); |
||
4942 | yMaxRange->Resize(80,22); |
||
4943 | fH1->AddFrame(yMaxRange, f0centery); |
||
4944 | fG1->AddFrame(fH1, f2); |
||
4945 | |||
4946 | // Select the channel to display |
||
4947 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
4948 | lab = new TGLabel(fH1, "Display channel:"); |
||
4949 | fH1->AddFrame(lab, f0centery); |
||
4950 | selectCh = new TGNumberEntry(fH1, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, (NCH->GetNumber())-1); |
||
4951 | selectCh->Resize(40,22); |
||
4952 | fH1->AddFrame(selectCh, f0centery); |
||
4953 | |||
4954 | changeADC = new TGTextButton(fH1, "ADC"); |
||
4955 | changeADC->AllowStayDown(kTRUE); |
||
4956 | changeADC->SetDown(kTRUE); |
||
4957 | fMenuHisttype->CheckEntry(M_ANALYSIS_HISTTYPE_1DADC); |
||
4958 | changeADC->SetTextJustify(36); |
||
4959 | changeADC->SetWrapLength(-1); |
||
4960 | changeADC->Resize(60,22); |
||
4961 | fH1->AddFrame(changeADC, f0centery); |
||
4962 | |||
4963 | changeTDC = new TGTextButton(fH1, "TDC"); |
||
4964 | changeTDC->AllowStayDown(kTRUE); |
||
4965 | changeTDC->SetTextJustify(36); |
||
4966 | changeTDC->SetWrapLength(-1); |
||
4967 | changeTDC->Resize(60,22); |
||
4968 | fH1->AddFrame(changeTDC, f0centery); |
||
4969 | |||
4970 | changeADCTDC = new TGTextButton(fH1, "ADC/TDC"); |
||
4971 | changeADCTDC->AllowStayDown(kTRUE); |
||
4972 | changeADCTDC->SetTextJustify(36); |
||
4973 | changeADCTDC->SetWrapLength(-1); |
||
4974 | changeADCTDC->Resize(60,22); |
||
4975 | fH1->AddFrame(changeADCTDC, f0centery); |
||
4976 | |||
4977 | change2Dsurf = new TGTextButton(fH1, "Surf 2D"); |
||
4978 | change2Dsurf->AllowStayDown(kTRUE); |
||
4979 | change2Dsurf->SetTextJustify(36); |
||
4980 | change2Dsurf->SetWrapLength(-1); |
||
4981 | change2Dsurf->Resize(60,22); |
||
4982 | fH1->AddFrame(change2Dsurf, f0); |
||
4983 | fG1->AddFrame(fH1, f2); |
||
4984 | |||
4985 | logscale = new TGCheckButton(fG1, "Logarithmic scale ON/OFF"); |
||
4986 | logscale->Resize(50,22); |
||
4987 | logscale->SetState(kButtonUp); |
||
4988 | fG1->AddFrame(logscale, f0centerx); |
||
4989 | |||
4990 | // Export the selected files |
||
4991 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 100); |
||
4992 | fH2 = new TGHorizontalFrame(fH1, subgroup[0], 100); |
||
4993 | lab = new TGLabel(fH2, "Export selected histograms:"); |
||
4994 | fH2->AddFrame(lab, f0centery); |
||
4995 | |||
4996 | exportHist = new TGTextButton(fH2, "Export"); |
||
4997 | exportHist->SetTextJustify(36); |
||
4998 | exportHist->SetWrapLength(-1); |
||
4999 | exportHist->Resize(80,22); |
||
5000 | fH2->AddFrame(exportHist, f0centery); |
||
5001 | fH1->AddFrame(fH2, f0centerx); |
||
5002 | fG1->AddFrame(fH1, f2); |
||
5003 | mdiFrame->AddFrame(fG1, f2); |
||
5004 | |||
5005 | // Fitting controls for ADC spectrum |
||
5006 | fG1 = new TGGroupFrame(mdiFrame, "Fit Settings"); |
||
5007 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
129 | f9daq | 5008 | fH2 = new TGHorizontalFrame(fH1, subgroup[0], 30); |
5009 | lab = new TGLabel(fH2, "Peak sigma:"); |
||
5010 | fH2->AddFrame(lab, f0centery); |
||
5011 | fitSigma = new TGNumberEntry(fH2, 1.2, 3, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEANonNegative); |
||
117 | f9daq | 5012 | fitSigma->Resize(60,22); |
129 | f9daq | 5013 | fH2->AddFrame(fitSigma, f0centery); |
117 | f9daq | 5014 | |
129 | f9daq | 5015 | lab = new TGLabel(fH2, " Signal/Noise treshold:"); |
5016 | fH2->AddFrame(lab, f0centery); |
||
5017 | fitTresh = new TGNumberEntry(fH2, 5.0E-3, 3, 999, TGNumberFormat::kNESReal, TGNumberFormat::kNEANonNegative); |
||
117 | f9daq | 5018 | fitTresh->Resize(60,22); |
129 | f9daq | 5019 | fH2->AddFrame(fitTresh, f0centery); |
5020 | fH1->AddFrame(fH2, f0centerx); |
||
117 | f9daq | 5021 | fG1->AddFrame(fH1, f2); |
5022 | |||
5023 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
129 | f9daq | 5024 | fH2 = new TGHorizontalFrame(fH1, subgroup[0], 30); |
5025 | lab = new TGLabel(fH2, "Background interpolation:"); |
||
5026 | fH2->AddFrame(lab, f0centery); |
||
5027 | fitInter = new TGNumberEntry(fH2, 7, 3, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative); |
||
117 | f9daq | 5028 | fitInter->Resize(60,22); |
129 | f9daq | 5029 | fH2->AddFrame(fitInter, f0centery); |
5030 | fH1->AddFrame(fH2, f0centerx); |
||
117 | f9daq | 5031 | fG1->AddFrame(fH1, f2); |
5032 | |||
5033 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
129 | f9daq | 5034 | fH2 = new TGHorizontalFrame(fH1, subgroup[0], 30); |
5035 | lab = new TGLabel(fH2, "Peak fit max. acceptable error:"); |
||
5036 | fH2->AddFrame(lab, f0centery); |
||
5037 | accError = new TGNumberEntry(fH2, 0.15, 3, 999, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative); |
||
117 | f9daq | 5038 | accError->Resize(60,22); |
129 | f9daq | 5039 | fH2->AddFrame(accError, f0centery); |
5040 | fH1->AddFrame(fH2, f0centerx); |
||
117 | f9daq | 5041 | fG1->AddFrame(fH1, f2); |
5042 | |||
129 | f9daq | 5043 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
5044 | fH2 = new TGHorizontalFrame(fH1, subgroup[0], 30); |
||
5045 | lab = new TGLabel(fH2, "Peak min. limit:"); |
||
5046 | fH2->AddFrame(lab, f0centery); |
||
5047 | minPeak = new TGNumberEntry(fH2, 4, 3, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 2, 20); |
||
5048 | minPeak->Resize(50,22); |
||
5049 | fH2->AddFrame(minPeak, f0centery); |
||
5050 | |||
5051 | lab = new TGLabel(fH2, " Pedestal lower limit:"); |
||
5052 | fH2->AddFrame(lab, f0centery); |
||
5053 | pedesLow = new TGNumberEntry(fH2, 0.00, 3, 999, TGNumberFormat::kNESRealTwo, TGNumberFormat::kNEANonNegative); |
||
5054 | pedesLow->Resize(60,22); |
||
5055 | fH2->AddFrame(pedesLow, f0centery); |
||
5056 | fH1->AddFrame(fH2, f0centerx); |
||
5057 | fG1->AddFrame(fH1, f2); |
||
5058 | |||
117 | f9daq | 5059 | exfitplots = new TGCheckButton(fG1, "Export fitting plots ON/OFF"); |
5060 | exfitplots->Resize(50,22); |
||
128 | f9daq | 5061 | exfitplots->SetState(kButtonUp); |
117 | f9daq | 5062 | fG1->AddFrame(exfitplots, f0centerx); |
5063 | mdiFrame->AddFrame(fG1, f2); |
||
5064 | |||
5065 | mdiFrame->SetMdiHints(kMdiMinimize); |
||
5066 | mdiFrame->SetWindowName("Histogram controls"); |
||
5067 | mdiFrame->MapSubwindows(); |
||
5068 | mdiFrame->Layout(); |
||
5069 | mdiFrame->Move(4*((winWidth/6)-5)+10,(int)(2.5*((winHeight/5)-5))); |
||
5070 | // Histogram controls pane ----------------------------------------------------------------- |
||
5071 | |||
5072 | // Action connections |
||
5073 | voltscanOn->Connect("Clicked()", "TGAppMainFrame", this, "EnableVoltScan()"); |
||
5074 | surfscanOn->Connect("Clicked()", "TGAppMainFrame", this, "EnableSurfScan()"); |
||
5075 | zscanOn->Connect("Clicked()", "TGAppMainFrame", this, "EnableZaxisScan()"); |
||
5076 | // histogramOn->Connect("Clicked()", "TGAppMainFrame", this, "HistogramToggle()"); |
||
5077 | vHardlimit->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "VoltageLimit()"); |
||
5078 | (vHardlimit->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "VoltageLimit()"); |
||
5079 | NCH->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "ChannelLimit()"); |
||
5080 | (NCH->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "ChannelLimit()"); |
||
5081 | cleanOn->Connect("Clicked()", "TGAppMainFrame", this, "CleanPlotToggle()"); |
||
5082 | oscConnect->Connect("Clicked()", "TGAppMainFrame", this, "ConnectToScope()"); |
||
5083 | vOutSet->Connect("Clicked()", "TGAppMainFrame", this, "SetVoltOut()"); |
||
5084 | vOutGet->Connect("Clicked()", "TGAppMainFrame", this, "GetVoltOut()"); |
||
5085 | vOutReset->Connect("Clicked()", "TGAppMainFrame", this, "ResetVoltOut()"); |
||
5086 | positionSet->Connect("Clicked()", "TGAppMainFrame", this, "SetPosition()"); |
||
5087 | positionGet->Connect("Clicked()", "TGAppMainFrame", this, "GetPosition()"); |
||
5088 | positionHome->Connect("Clicked()", "TGAppMainFrame", this, "HomePosition()"); |
||
5089 | saveFile->Connect("Clicked()", "TGAppMainFrame", this, "SaveFile()"); |
||
5090 | measStart->Connect("Clicked()", "TGAppMainFrame", this, "StartAcq()"); |
||
5091 | selectDir->Connect("Clicked()", "TGAppMainFrame", this, "SelectDirectory()"); |
||
5092 | multiSelect->Connect("Clicked()", "TGAppMainFrame", this, "ListMultiSelect()"); |
||
5093 | multiSelectAll->Connect("Clicked()", "TGAppMainFrame", this, "ListSelectAll()"); |
||
129 | f9daq | 5094 | editHeader->Connect("Clicked()", "TGAppMainFrame", this, "HeaderEdit()"); |
117 | f9daq | 5095 | prevFile->Connect("Clicked()", "TGAppMainFrame", this, "FileListNavigation(=-2)"); |
5096 | nextFile->Connect("Clicked()", "TGAppMainFrame", this, "FileListNavigation(=-3)"); |
||
5097 | fileList->Connect("DoubleClicked(Int_t)", "TGAppMainFrame", this, "FileListNavigation(Int_t)"); |
||
5098 | clearList->Connect("Clicked()", "TGListBox", fileList, "RemoveAll()"); |
||
5099 | |||
5100 | adcMinRange->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "SetHistRange()"); |
||
5101 | (adcMinRange->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "SetHistRange()"); |
||
5102 | adcMaxRange->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "SetHistRange()"); |
||
5103 | (adcMaxRange->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "SetHistRange()"); |
||
5104 | yMinRange->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "SetHistRange()"); |
||
5105 | (yMinRange->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "SetHistRange()"); |
||
5106 | yMaxRange->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "SetHistRange()"); |
||
5107 | (yMaxRange->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "SetHistRange()"); |
||
5108 | tdcMinwindow->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "SetHistRange()"); |
||
5109 | (tdcMinwindow->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "SetHistRange()"); |
||
5110 | tdcMaxwindow->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "SetHistRange()"); |
||
5111 | (tdcMaxwindow->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "SetHistRange()"); |
||
5112 | changeADC->Connect("Clicked()", "TGAppMainFrame", this, "ChangeHisttype(=0)"); |
||
5113 | changeTDC->Connect("Clicked()", "TGAppMainFrame", this, "ChangeHisttype(=1)"); |
||
5114 | changeADCTDC->Connect("Clicked()", "TGAppMainFrame", this, "ChangeHisttype(=2)"); |
||
5115 | change2Dsurf->Connect("Clicked()", "TGAppMainFrame", this, "ChangeHisttype(=3)"); |
||
5116 | selectCh->Connect("ValueSet(Long_t)", "TGAppMainFrame", this, "ChangeChannel()"); |
||
5117 | (selectCh->GetNumberEntry())->Connect("ReturnPressed()", "TGAppMainFrame", this, "ChangeChannel()"); |
||
5118 | logscale->Connect("Clicked()", "TGAppMainFrame", this, "SetHistRange()"); |
||
5119 | exportHist->Connect("Clicked()", "TGAppMainFrame", this, "HistogramExport()"); |
||
5120 | |||
127 | f9daq | 5121 | scopeInit->Connect("Clicked()", "TGAppMainFrame", this, "InitializeScope()"); |
5122 | sendScopeCustom->Connect("Clicked()", "TGAppMainFrame", this, "CustomScopeCommand()"); |
||
5123 | sMeasType->Connect("Selected(Int_t)", "TGAppMainFrame", this, "SelectedMeasType(Int_t)"); |
||
5124 | |||
117 | f9daq | 5125 | started = kFALSE; |
127 | f9daq | 5126 | |
5127 | for(int i = 0; i < 8; i++) sCH[i]->SetEnabled(kFALSE); |
||
5128 | sMeasType->SetEnabled(kFALSE); |
||
5129 | sCamaclink->SetEnabled(kFALSE); |
||
5130 | scopeCommand->SetEnabled(kFALSE); |
||
5131 | sendScopeCustom->SetEnabled(kFALSE); |
||
5132 | sMeasgroup->SetEnabled(kFALSE); |
||
5133 | scopeInit->SetEnabled(kFALSE); |
||
5134 | |||
117 | f9daq | 5135 | EnableVoltScan(); |
5136 | EnableSurfScan(); |
||
5137 | EnableZaxisScan(); |
||
127 | f9daq | 5138 | |
5139 | // Testing canvas for scope waveforms |
||
5140 | wCanvas = new TCanvas("wCanvas", "Waveform canvas", 600, 300); |
||
117 | f9daq | 5141 | } |
5142 | |||
5143 | //--------------------------------------------------------------- |
||
128 | f9daq | 5144 | // Opening a new subwindow |
5145 | |||
5146 | void TGAppMainFrame::OpenWindow(int winid) |
||
5147 | { |
||
5148 | /* WinID: |
||
5149 | * - 1 = fieldpoint temperature sensor |
||
129 | f9daq | 5150 | * - 2 = file header editor |
128 | f9daq | 5151 | */ |
5152 | |||
5153 | TGMdiFrame *mdiFrame; |
||
5154 | |||
5155 | // Generic horizontal and vertical frames |
||
5156 | TGHorizontalFrame *fH1, *fH2; |
||
5157 | TGGroupFrame *fG1; |
||
5158 | TGLabel *lab; |
||
5159 | |||
5160 | int subwin[2]; |
||
5161 | int subgroup[2]; |
||
5162 | |||
5163 | char ctemp[256]; |
||
5164 | |||
5165 | // Fieldpoint pane ------------------------------------------------------------------------- |
||
5166 | if(winid == 1) |
||
5167 | { |
||
5168 | time_t rtime; |
||
5169 | int yearrange[2]; |
||
5170 | |||
5171 | subwin[0] = 3*((winWidth/4)-5); subwin[1] = (int)(2*((winHeight/3)-5))+10; |
||
129 | f9daq | 5172 | fieldpointPane = new TGMdiSubwindow(fMainFrame, subwin[0], subwin[1]); |
5173 | mdiFrame = fieldpointPane->GetMdiFrame(); |
||
128 | f9daq | 5174 | |
5175 | subgroup[0] = subwin[0]-10; |
||
5176 | subgroup[1] = 7*subwin[1]/12; |
||
5177 | |||
5178 | // Display canvas for temperature sensor |
||
5179 | displayCanvas = new TRootEmbeddedCanvas("displayCanvas",mdiFrame,subgroup[0],subgroup[1]); |
||
5180 | mdiFrame->AddFrame(displayCanvas, f0centerx); |
||
5181 | TCanvas *gCanvas = displayCanvas->GetCanvas(); |
||
5182 | gCanvas->SetGridx(); |
||
5183 | gCanvas->SetGridy(); |
||
5184 | |||
5185 | fG1 = new TGGroupFrame(mdiFrame, "Temperature sensor settings"); |
||
5186 | // Channel selector |
||
5187 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
5188 | lab = new TGLabel(fH1, "Fieldpoint channel:"); |
||
5189 | fH1->AddFrame(lab, f0centery); |
||
5190 | tempCh = new TGComboBox(fH1, 200); |
||
5191 | tempCh->AddEntry("0", 0); |
||
5192 | tempCh->AddEntry("1", 1); |
||
5193 | tempCh->AddEntry("2", 2); |
||
5194 | tempCh->AddEntry("3", 3); |
||
5195 | tempCh->AddEntry("4", 4); |
||
5196 | tempCh->AddEntry("5", 5); |
||
5197 | tempCh->AddEntry("6", 6); |
||
5198 | tempCh->AddEntry("7", 7); |
||
5199 | tempCh->Resize(50,22); |
||
5200 | tempCh->Select(1); |
||
5201 | fH1->AddFrame(tempCh, f0centery); |
||
5202 | fG1->AddFrame(fH1, f2); |
||
5203 | |||
5204 | // Start and stop time ------------------------ |
||
5205 | time(&rtime); |
||
5206 | |||
5207 | lab = new TGLabel(fG1, "Start time:"); |
||
5208 | fG1->AddFrame(lab, f0); |
||
5209 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
5210 | // Start day |
||
5211 | lab = new TGLabel(fH1, "\tDay: "); |
||
5212 | fH1->AddFrame(lab, f0centery); |
||
5213 | tempDay[0] = new TGComboBox(fH1, 200); |
||
5214 | for(int i = 0; i < 31; i++) |
||
5215 | { |
||
5216 | sprintf(ctemp, "%d", i+1); |
||
5217 | tempDay[0]->AddEntry(ctemp, i); |
||
5218 | } |
||
5219 | tempDay[0]->Resize(50,22); |
||
5220 | tempDay[0]->Select((int)(localtime(&rtime))->tm_mday-1); |
||
5221 | fH1->AddFrame(tempDay[0], f0centery); |
||
5222 | |||
5223 | // Start month |
||
5224 | lab = new TGLabel(fH1, " Month: "); |
||
5225 | fH1->AddFrame(lab, f0centery); |
||
5226 | tempMonth[0] = new TGComboBox(fH1, 200); |
||
5227 | tempMonth[0]->AddEntry("January", 0); |
||
5228 | tempMonth[0]->AddEntry("February", 1); |
||
5229 | tempMonth[0]->AddEntry("March", 2); |
||
5230 | tempMonth[0]->AddEntry("April", 3); |
||
5231 | tempMonth[0]->AddEntry("May", 4); |
||
5232 | tempMonth[0]->AddEntry("June", 5); |
||
5233 | tempMonth[0]->AddEntry("July", 6); |
||
5234 | tempMonth[0]->AddEntry("August", 7); |
||
5235 | tempMonth[0]->AddEntry("September", 8); |
||
5236 | tempMonth[0]->AddEntry("October", 9); |
||
5237 | tempMonth[0]->AddEntry("November", 10); |
||
5238 | tempMonth[0]->AddEntry("December", 11); |
||
5239 | tempMonth[0]->Resize(80,22); |
||
5240 | tempMonth[0]->Select((int)(localtime(&rtime))->tm_mon); |
||
5241 | fH1->AddFrame(tempMonth[0], f0centery); |
||
5242 | |||
5243 | // Start year |
||
5244 | yearrange[0] = 2010; |
||
5245 | yearrange[1] = (int)(localtime(&rtime))->tm_year+1900; |
||
5246 | |||
5247 | lab = new TGLabel(fH1, " Year: "); |
||
5248 | fH1->AddFrame(lab, f0centery); |
||
5249 | tempYear[0] = new TGComboBox(fH1, 200); |
||
5250 | for(int i = 0; i < (yearrange[1]-yearrange[0])+1; i++) |
||
5251 | { |
||
5252 | sprintf(ctemp, "%d", yearrange[1]-i); |
||
5253 | tempYear[0]->AddEntry(ctemp, i); |
||
5254 | } |
||
5255 | tempYear[0]->Resize(60,22); |
||
5256 | tempYear[0]->Select(0); |
||
5257 | fH1->AddFrame(tempYear[0], f0centery); |
||
5258 | |||
5259 | // Start hour |
||
5260 | lab = new TGLabel(fH1, " Hour: "); |
||
5261 | fH1->AddFrame(lab, f0centery); |
||
5262 | tempHour[0] = new TGComboBox(fH1, 200); |
||
5263 | for(int i = 0; i < 24; i++) |
||
5264 | { |
||
5265 | if(i < 10) |
||
5266 | sprintf(ctemp, "0%d", i); |
||
5267 | else |
||
5268 | sprintf(ctemp, "%d", i); |
||
5269 | tempHour[0]->AddEntry(ctemp, i); |
||
5270 | } |
||
5271 | tempHour[0]->Resize(50,22); |
||
5272 | tempHour[0]->Select(7); |
||
5273 | fH1->AddFrame(tempHour[0], f0centery); |
||
5274 | |||
5275 | // Start minute |
||
5276 | lab = new TGLabel(fH1, " Minute: "); |
||
5277 | fH1->AddFrame(lab, f0centery); |
||
5278 | tempMinute[0] = new TGComboBox(fH1, 200); |
||
5279 | for(int i = 0; i < 60; i++) |
||
5280 | { |
||
5281 | if(i < 10) |
||
5282 | sprintf(ctemp, "0%d", i); |
||
5283 | else |
||
5284 | sprintf(ctemp, "%d", i); |
||
5285 | tempMinute[0]->AddEntry(ctemp, i); |
||
5286 | } |
||
5287 | tempMinute[0]->Resize(50,22); |
||
5288 | tempMinute[0]->Select(0); |
||
5289 | fH1->AddFrame(tempMinute[0], f0centery); |
||
5290 | |||
5291 | // Start second |
||
5292 | lab = new TGLabel(fH1, " Second: "); |
||
5293 | fH1->AddFrame(lab, f0centery); |
||
5294 | tempSecond[0] = new TGComboBox(fH1, 200); |
||
5295 | for(int i = 0; i < 60; i++) |
||
5296 | { |
||
5297 | if(i < 10) |
||
5298 | sprintf(ctemp, "0%d", i); |
||
5299 | else |
||
5300 | sprintf(ctemp, "%d", i); |
||
5301 | tempSecond[0]->AddEntry(ctemp, i); |
||
5302 | } |
||
5303 | tempSecond[0]->Resize(50,22); |
||
5304 | tempSecond[0]->Select(0); |
||
5305 | fH1->AddFrame(tempSecond[0], f0centery); |
||
5306 | |||
5307 | // Get start time from file |
||
5308 | lab = new TGLabel(fH1, " "); |
||
5309 | fH1->AddFrame(lab, f0centery); |
||
5310 | tempFile[0] = new TGTextButton(fH1, "Get from file..."); |
||
5311 | tempFile[0]->SetTextJustify(36); |
||
5312 | tempFile[0]->SetWrapLength(-1); |
||
5313 | tempFile[0]->Resize(100,22); |
||
5314 | fH1->AddFrame(tempFile[0], f0centery); |
||
5315 | |||
5316 | fG1->AddFrame(fH1, f2); |
||
5317 | |||
5318 | // Use the end time or not |
||
5319 | tempEndOn = new TGCheckButton(fG1, "Draw to last time point (ON/OFF)"); |
||
5320 | tempEndOn->Resize(100,22); |
||
5321 | tempEndOn->SetState(kButtonUp); |
||
5322 | fG1->AddFrame(tempEndOn, f0); |
||
5323 | |||
5324 | lab = new TGLabel(fG1, "End time:"); |
||
5325 | fG1->AddFrame(lab, f0); |
||
5326 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
5327 | // End day |
||
5328 | lab = new TGLabel(fH1, "\tDay: "); |
||
5329 | fH1->AddFrame(lab, f0centery); |
||
5330 | tempDay[1] = new TGComboBox(fH1, 200); |
||
5331 | for(int i = 0; i < 31; i++) |
||
5332 | { |
||
5333 | sprintf(ctemp, "%d", i+1); |
||
5334 | tempDay[1]->AddEntry(ctemp, i); |
||
5335 | } |
||
5336 | tempDay[1]->Resize(50,22); |
||
5337 | tempDay[1]->Select((int)(localtime(&rtime))->tm_mday-1); |
||
5338 | fH1->AddFrame(tempDay[1], f0centery); |
||
5339 | |||
5340 | // End month |
||
5341 | lab = new TGLabel(fH1, " Month: "); |
||
5342 | fH1->AddFrame(lab, f0centery); |
||
5343 | tempMonth[1] = new TGComboBox(fH1, 200); |
||
5344 | tempMonth[1]->AddEntry("January", 0); |
||
5345 | tempMonth[1]->AddEntry("February", 1); |
||
5346 | tempMonth[1]->AddEntry("March", 2); |
||
5347 | tempMonth[1]->AddEntry("April", 3); |
||
5348 | tempMonth[1]->AddEntry("May", 4); |
||
5349 | tempMonth[1]->AddEntry("June", 5); |
||
5350 | tempMonth[1]->AddEntry("July", 6); |
||
5351 | tempMonth[1]->AddEntry("August", 7); |
||
5352 | tempMonth[1]->AddEntry("September", 8); |
||
5353 | tempMonth[1]->AddEntry("October", 9); |
||
5354 | tempMonth[1]->AddEntry("November", 10); |
||
5355 | tempMonth[1]->AddEntry("December", 11); |
||
5356 | tempMonth[1]->Resize(80,22); |
||
5357 | tempMonth[1]->Select((int)(localtime(&rtime))->tm_mon); |
||
5358 | fH1->AddFrame(tempMonth[1], f0centery); |
||
5359 | |||
5360 | // End year |
||
5361 | time(&rtime); |
||
5362 | yearrange[0] = 2010; |
||
5363 | yearrange[1] = (int)(localtime(&rtime))->tm_year+1900; |
||
5364 | |||
5365 | lab = new TGLabel(fH1, " Year: "); |
||
5366 | fH1->AddFrame(lab, f0centery); |
||
5367 | tempYear[1] = new TGComboBox(fH1, 200); |
||
5368 | for(int i = 0; i < (yearrange[1]-yearrange[0])+1; i++) |
||
5369 | { |
||
5370 | sprintf(ctemp, "%d", yearrange[1]-i); |
||
5371 | tempYear[1]->AddEntry(ctemp, i); |
||
5372 | } |
||
5373 | tempYear[1]->Resize(60,22); |
||
5374 | tempYear[1]->Select(0); |
||
5375 | fH1->AddFrame(tempYear[1], f0centery); |
||
5376 | |||
5377 | // End hour |
||
5378 | lab = new TGLabel(fH1, " Hour: "); |
||
5379 | fH1->AddFrame(lab, f0centery); |
||
5380 | tempHour[1] = new TGComboBox(fH1, 200); |
||
5381 | for(int i = 0; i < 24; i++) |
||
5382 | { |
||
5383 | if(i < 10) |
||
5384 | sprintf(ctemp, "0%d", i); |
||
5385 | else |
||
5386 | sprintf(ctemp, "%d", i); |
||
5387 | tempHour[1]->AddEntry(ctemp, i); |
||
5388 | } |
||
5389 | tempHour[1]->Resize(50,22); |
||
5390 | tempHour[1]->Select(18); |
||
5391 | fH1->AddFrame(tempHour[1], f0centery); |
||
5392 | |||
5393 | // End minute |
||
5394 | lab = new TGLabel(fH1, " Minute: "); |
||
5395 | fH1->AddFrame(lab, f0centery); |
||
5396 | tempMinute[1] = new TGComboBox(fH1, 200); |
||
5397 | for(int i = 0; i < 60; i++) |
||
5398 | { |
||
5399 | if(i < 10) |
||
5400 | sprintf(ctemp, "0%d", i); |
||
5401 | else |
||
5402 | sprintf(ctemp, "%d", i); |
||
5403 | tempMinute[1]->AddEntry(ctemp, i); |
||
5404 | } |
||
5405 | tempMinute[1]->Resize(50,22); |
||
5406 | tempMinute[1]->Select(0); |
||
5407 | fH1->AddFrame(tempMinute[1], f0centery); |
||
5408 | |||
5409 | // End second |
||
5410 | lab = new TGLabel(fH1, " Second: "); |
||
5411 | fH1->AddFrame(lab, f0centery); |
||
5412 | tempSecond[1] = new TGComboBox(fH1, 200); |
||
5413 | for(int i = 0; i < 60; i++) |
||
5414 | { |
||
5415 | if(i < 10) |
||
5416 | sprintf(ctemp, "0%d", i); |
||
5417 | else |
||
5418 | sprintf(ctemp, "%d", i); |
||
5419 | tempSecond[1]->AddEntry(ctemp, i); |
||
5420 | } |
||
5421 | tempSecond[1]->Resize(50,22); |
||
5422 | tempSecond[1]->Select(0); |
||
5423 | fH1->AddFrame(tempSecond[1], f0centery); |
||
5424 | |||
5425 | // Get start time from file |
||
5426 | lab = new TGLabel(fH1, " "); |
||
5427 | fH1->AddFrame(lab, f0centery); |
||
5428 | tempFile[1] = new TGTextButton(fH1, "Get from file..."); |
||
5429 | tempFile[1]->SetTextJustify(36); |
||
5430 | tempFile[1]->SetWrapLength(-1); |
||
5431 | tempFile[1]->Resize(100,22); |
||
5432 | fH1->AddFrame(tempFile[1], f0centery); |
||
5433 | |||
5434 | fG1->AddFrame(fH1, f2); |
||
5435 | // Start and stop time ------------------------ |
||
5436 | |||
5437 | // Control buttons |
||
5438 | fH2 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
5439 | fH1 = new TGHorizontalFrame(fH2, subgroup[0], 30); |
||
5440 | updateTemp = new TGTextButton(fH1, "Update"); |
||
5441 | updateTemp->SetTextJustify(36); |
||
5442 | updateTemp->SetWrapLength(-1); |
||
5443 | updateTemp->Resize(80,22); |
||
5444 | fH1->AddFrame(updateTemp, f0); |
||
5445 | |||
5446 | exportTemp = new TGTextButton(fH1, "Export"); |
||
5447 | exportTemp->SetTextJustify(36); |
||
5448 | exportTemp->SetWrapLength(-1); |
||
5449 | exportTemp->Resize(80,22); |
||
5450 | fH1->AddFrame(exportTemp, f0); |
||
5451 | |||
5452 | /* closeTemp = new TGTextButton(fH1, "Close"); |
||
5453 | closeTemp->SetTextJustify(36); |
||
5454 | closeTemp->SetWrapLength(-1); |
||
5455 | closeTemp->Resize(80,22); |
||
5456 | fH1->AddFrame(closeTemp, f0);*/ |
||
5457 | fH2->AddFrame(fH1, f0centerx); |
||
5458 | |||
5459 | fG1->AddFrame(fH2, f2); |
||
5460 | |||
5461 | mdiFrame->AddFrame(fG1, f1); |
||
5462 | |||
5463 | mdiFrame->SetMdiHints(kMdiMinimize | kMdiMaximize | kMdiClose); |
||
5464 | mdiFrame->SetWindowName("Fieldpoint FP RTD 122 temperature sensor"); |
||
5465 | mdiFrame->MapSubwindows(); |
||
5466 | mdiFrame->Layout(); |
||
5467 | mdiFrame->Move(1*((winWidth/12)-5)+10,(int)(1*((winHeight/12)-5))); |
||
5468 | |||
5469 | // Action connections |
||
5470 | updateTemp->Connect("Clicked()", "TGAppMainFrame", this, "UpdateTempPlot()"); |
||
5471 | tempEndOn->Connect("Clicked()", "TGAppMainFrame", this, "TempEndToggle()"); |
||
5472 | exportTemp->Connect("Clicked()", "TGAppMainFrame", this, "ExportTempPlot()"); |
||
5473 | tempFile[0]->Connect("Clicked()", "TGAppMainFrame", this, "GetTempFile(=0)"); |
||
5474 | tempFile[1]->Connect("Clicked()", "TGAppMainFrame", this, "GetTempFile(=1)"); |
||
5475 | // closeTemp->Connect("Clicked()", "TGAppMainFrame", this, "UpdateTempPlot()"); |
||
5476 | } |
||
5477 | // Fieldpoint pane ------------------------------------------------------------------------- |
||
129 | f9daq | 5478 | // |
5479 | // Header editor pane ---------------------------------------------------------------------- |
||
5480 | else if(winid == 2) |
||
5481 | { |
||
5482 | subwin[0] = 12*((winWidth/16)-5); subwin[1] = (int)(1*((winHeight/3)-10)); |
||
5483 | headerPane = new TGMdiSubwindow(fMainFrame, subwin[0], subwin[1]); |
||
5484 | mdiFrame = headerPane->GetMdiFrame(); |
||
5485 | |||
5486 | subgroup[0] = subwin[0]-10; |
||
5487 | subgroup[1] = 7*subwin[1]/12; |
||
5488 | |||
5489 | // Changing header info (no timestamp change possible) |
||
5490 | fG1 = new TGGroupFrame(mdiFrame, "Header edit information"); |
||
5491 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
5492 | biasedittick = new TGCheckButton(fH1, "Bias voltage edit: "); |
||
5493 | biasedittick->Resize(80,22); |
||
5494 | biasedittick->SetState(kButtonUp); |
||
5495 | fH1->AddFrame(biasedittick, f0centerx); |
||
5496 | biasedit = new TGNumberEntry(fH1, 0.00, 4, 999, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEANonNegative); |
||
5497 | biasedit->Resize(80,22); |
||
5498 | biasedit->SetState(kFALSE); |
||
5499 | fH1->AddFrame(biasedit, f0centery); |
||
5500 | fG1->AddFrame(fH1, f0); |
||
5501 | |||
5502 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
5503 | posedittick = new TGCheckButton(fH1, "Table position edit (X, Y, Z): "); |
||
5504 | posedittick->Resize(80,22); |
||
5505 | posedittick->SetState(kButtonUp); |
||
5506 | fH1->AddFrame(posedittick, f0centerx); |
||
5507 | for(int i = 0; i < 3; i++) |
||
5508 | { |
||
5509 | posedit[i] = new TGNumberEntry(fH1, 0, 6, 999, TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber); |
||
5510 | posedit[i]->Resize(80,22); |
||
5511 | posedit[i]->SetState(kFALSE); |
||
5512 | fH1->AddFrame(posedit[i], f0centery); |
||
5513 | } |
||
5514 | fG1->AddFrame(fH1, f0); |
||
5515 | |||
5516 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
5517 | tempedittick = new TGCheckButton(fH1, "Chamber temperature edit: "); |
||
5518 | tempedittick->Resize(80,22); |
||
5519 | tempedittick->SetState(kButtonUp); |
||
5520 | fH1->AddFrame(tempedittick, f0centerx); |
||
5521 | tempedit = new TGNumberEntry(fH1, 0.00, 6, 999, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAAnyNumber); |
||
5522 | tempedit->Resize(80,22); |
||
5523 | tempedit->SetState(kFALSE); |
||
5524 | fH1->AddFrame(tempedit, f0centery); |
||
5525 | fG1->AddFrame(fH1, f0); |
||
5526 | |||
5527 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
5528 | angleedittick = new TGCheckButton(fH1, "Incidence angle edit: "); |
||
5529 | angleedittick->Resize(80,22); |
||
5530 | angleedittick->SetState(kButtonUp); |
||
5531 | fH1->AddFrame(angleedittick, f0centerx); |
||
5532 | angleedit = new TGNumberEntry(fH1, 0.00, 6, 999, TGNumberFormat::kNESRealOne, TGNumberFormat::kNEAAnyNumber); |
||
5533 | angleedit->Resize(80,22); |
||
5534 | angleedit->SetState(kFALSE); |
||
5535 | fH1->AddFrame(angleedit, f0centery); |
||
5536 | fG1->AddFrame(fH1, f0); |
||
5537 | |||
5538 | fH1 = new TGHorizontalFrame(fG1, subgroup[0], 30); |
||
5539 | laseredittick = new TGCheckButton(fH1, "Laser settings edit: "); |
||
5540 | laseredittick->Resize(80,22); |
||
5541 | laseredittick->SetState(kButtonUp); |
||
5542 | fH1->AddFrame(laseredittick, f0centerx); |
||
5543 | laseredit = new TGTextEntry(fH1, ""); |
||
5544 | laseredit->Resize(440,22); |
||
5545 | laseredit->SetState(kFALSE); |
||
5546 | fH1->AddFrame(laseredit, f0centery); |
||
5547 | fG1->AddFrame(fH1, f0); |
||
5548 | |||
5549 | ULong_t fcolor; |
||
5550 | gClient->GetColorByName("red", fcolor); |
||
5551 | |||
5552 | lab = new TGLabel(fG1, "Note: Tick checkbox in front of each header information you wish to change (for security, they are unticked by default)."); |
||
5553 | fG1->AddFrame(lab, f0centerx); |
||
5554 | lab = new TGLabel(fG1, "Warning: Using button \"Edit header\" will edit headers in all files currently selected in the Histogram file selection window."); |
||
5555 | lab->SetTextColor(fcolor); |
||
5556 | fG1->AddFrame(lab, f0centerx); |
||
5557 | |||
5558 | mdiFrame->AddFrame(fG1, f2); |
||
5559 | |||
5560 | editHead = new TGTextButton(mdiFrame, "Edit header"); |
||
5561 | editHead->SetTextJustify(36); |
||
5562 | editHead->SetWrapLength(-1); |
||
5563 | editHead->Resize(80,22); |
||
5564 | mdiFrame->AddFrame(editHead, f0centerx); |
||
5565 | |||
5566 | mdiFrame->SetMdiHints(kMdiMinimize | kMdiMaximize | kMdiClose); |
||
5567 | mdiFrame->SetWindowName("Edit datafile header"); |
||
5568 | mdiFrame->MapSubwindows(); |
||
5569 | mdiFrame->Layout(); |
||
5570 | mdiFrame->Move(1*((winWidth/12)-5)-30,(int)(1*((winHeight/12)-5))); |
||
5571 | |||
5572 | // Action connections |
||
5573 | biasedittick->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=1)"); |
||
5574 | posedittick->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=2)"); |
||
5575 | tempedittick->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=3)"); |
||
5576 | angleedittick->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=4)"); |
||
5577 | laseredittick->Connect("Clicked()", "TGAppMainFrame", this, "EditTickToggle(=5)"); |
||
5578 | editHead->Connect("Clicked()", "TGAppMainFrame", this, "headeredit()"); |
||
5579 | /* updateTemp->Connect("Clicked()", "TGAppMainFrame", this, "UpdateTempPlot()"); |
||
5580 | tempEndOn->Connect("Clicked()", "TGAppMainFrame", this, "TempEndToggle()"); |
||
5581 | exportTemp->Connect("Clicked()", "TGAppMainFrame", this, "ExportTempPlot()"); |
||
5582 | tempFile[0]->Connect("Clicked()", "TGAppMainFrame", this, "GetTempFile(=0)"); |
||
5583 | tempFile[1]->Connect("Clicked()", "TGAppMainFrame", this, "GetTempFile(=1)"); |
||
5584 | */ } |
||
5585 | // Header editor pane ---------------------------------------------------------------------- |
||
5586 | // |
||
5587 | else |
||
5588 | printf("Window not implemented yet.\n"); |
||
128 | f9daq | 5589 | } |
5590 | |||
5591 | //--------------------------------------------------------------- |
||
117 | f9daq | 5592 | // Closing the main application window and checking the about information |
5593 | |||
5594 | void TGAppMainFrame::CloseWindow() |
||
5595 | { |
||
5596 | gApplication->Terminate(0); |
||
5597 | } |
||
5598 | |||
5599 | Bool_t TGAppMainFrame::About() |
||
5600 | { |
||
5601 | int ret = 0; |
||
5602 | |||
5603 | new TGMsgBox(gClient->GetRoot(), fMain, |
||
5604 | fMain->GetWindowName(), "This is an application.", |
||
5605 | kMBIconQuestion, kMBClose, &ret); |
||
5606 | |||
5607 | if(debug == 1) |
||
5608 | if(ret == kMBClose) |
||
5609 | printf("Closing the About window (%d).\n", ret); |
||
5610 | |||
5611 | return kFALSE; |
||
5612 | } |
||
5613 | |||
5614 | //--------------------------------------------------------------- |
||
5615 | // Subwindow constructor definition (& layout) and close subwindow action |
||
5616 | |||
5617 | TGMdiSubwindow::TGMdiSubwindow(TGMdiMainFrame *main, int w, int h) |
||
5618 | { |
||
5619 | // Create a new subwindow |
||
5620 | fMdiFrame = new TGMdiFrame(main, w, h); |
||
5621 | fMdiFrame->Connect("CloseWindow()", "TGMdiSubwindow", this, "CloseWindow()"); // setting here to =0 -> will always ask before closing window |
||
5622 | fMdiFrame->DontCallClose(); // only let this window close if Yes is pressed when closing window |
||
5623 | |||
5624 | } |
||
5625 | |||
5626 | Bool_t TGMdiSubwindow::CloseWindow() |
||
5627 | { |
||
129 | f9daq | 5628 | /* int ret = 0; |
117 | f9daq | 5629 | |
129 | f9daq | 5630 | new TGMsgBox(gClient->GetRoot(), fMdiFrame, |
5631 | fMdiFrame->GetWindowName(), "Really want to close the window?", |
||
5632 | kMBIconExclamation, kMBYes | kMBNo, &ret); |
||
5633 | if (ret == kMBYes) return fMdiFrame->CloseWindow(); |
||
117 | f9daq | 5634 | |
129 | f9daq | 5635 | return kFALSE;*/ |
5636 | return fMdiFrame->CloseWindow(); |
||
117 | f9daq | 5637 | } |
5638 | |||
5639 | //--------------------------------------------------------------- |
||
5640 | // Main function |
||
5641 | |||
5642 | void windowed_test() |
||
5643 | { |
||
5644 | new TGAppMainFrame(gClient->GetRoot(), winWidth, winHeight); |
||
5645 | } |
||
5646 | |||
5647 | //#ifdef STANDALONE |
||
5648 | int main(int argc, char **argv) |
||
5649 | { |
||
5650 | TApplication theApp("MdiTest", &argc, argv); |
||
5651 | |||
5652 | windowed_test(); |
||
5653 | |||
5654 | theApp.Run(); |
||
5655 | |||
5656 | return 0; |
||
5657 | } |
||
5658 | //#endif |