1 | /*
|
---|
2 | * QtGl.cpp
|
---|
3 | *
|
---|
4 | * Created on: Jul 19, 2011
|
---|
5 | * Author: lyard
|
---|
6 | */
|
---|
7 | //FIXME replace with FACT++ Time class
|
---|
8 | #include <boost/date_time/local_time/local_time.hpp>
|
---|
9 |
|
---|
10 |
|
---|
11 | #include "RawEventsViewer.h"
|
---|
12 | #include "viewer.h"
|
---|
13 | #include <math.h>
|
---|
14 | #include <fstream>
|
---|
15 |
|
---|
16 | #ifdef LOAD_RAW
|
---|
17 | int16_t eventsData[NUM_STORED_EVENTS][ACTUAL_NUM_PIXELS][1024];
|
---|
18 | #include </home/lyard/Code/display.C>
|
---|
19 | #endif
|
---|
20 |
|
---|
21 | #define VALUES_SPAN 4096
|
---|
22 |
|
---|
23 | #include <QFileDialog>
|
---|
24 |
|
---|
25 | #include <qwt_plot_grid.h>
|
---|
26 | #include <qwt_symbol.h>
|
---|
27 |
|
---|
28 | #include "src/Configuration.h"
|
---|
29 | #include "externals/fits.h"
|
---|
30 |
|
---|
31 |
|
---|
32 | using namespace std;
|
---|
33 |
|
---|
34 | #undef ACTUAL_NUM_PIXELS
|
---|
35 | #define ACTUAL_NUM_PIXELS 1440
|
---|
36 |
|
---|
37 | //bounding box for diplaying the impulse curve
|
---|
38 | float bboxMin[2] = {-0.8,-0.9};
|
---|
39 | float bboxMax[2] = {0.8,-0.3};
|
---|
40 | /************************************************************
|
---|
41 | * CALC BLUR COLOR if in blur display mode, calculate the interpolated
|
---|
42 | * colour for a given vertex
|
---|
43 | ************************************************************/
|
---|
44 | void RawDataViewer::calcBlurColor(int pixel, int vertex)
|
---|
45 | {
|
---|
46 | GLfloat color[3];
|
---|
47 | int first, second;
|
---|
48 | first = vertex-1;
|
---|
49 | second = vertex;
|
---|
50 | if (first < 0)
|
---|
51 | first = 5;
|
---|
52 | first = neighbors[pixel][first];
|
---|
53 | second = neighbors[pixel][second];
|
---|
54 | for (int i=0;i<3;i++)
|
---|
55 | color[i] = pixelsColor[pixel][i];
|
---|
56 | float divide = 1;
|
---|
57 | if (first != -1)
|
---|
58 | {
|
---|
59 | divide++;
|
---|
60 | for (int i=0;i<3;i++)
|
---|
61 | color[i] += pixelsColor[first][i];
|
---|
62 | }
|
---|
63 | if (second != -1)
|
---|
64 | {
|
---|
65 | divide++;
|
---|
66 | for (int i=0;i<3;i++)
|
---|
67 | color[i] += pixelsColor[second][i];
|
---|
68 | }
|
---|
69 | for (int i=0;i<3;i++)
|
---|
70 | color[i] /= divide;
|
---|
71 | glColor3fv(color);
|
---|
72 | }
|
---|
73 | /************************************************************
|
---|
74 | * DRAW BLURRY HEXAGON. draws a solid hexagon, with interpolated colours
|
---|
75 | ************************************************************/
|
---|
76 | void RawDataViewer::drawBlurryHexagon(int index)
|
---|
77 | {
|
---|
78 | GLfloat color[3];
|
---|
79 | for (int i=0;i<3;i++)
|
---|
80 | color[i] = pixelsColor[index][i];
|
---|
81 | glBegin(GL_TRIANGLES);
|
---|
82 | calcBlurColor(index, 0);
|
---|
83 | glVertex2fv(verticesList[verticesIndices[index][0]]);
|
---|
84 | glColor3fv(color);
|
---|
85 | glVertex2fv(pixelsCoords[index]);
|
---|
86 | calcBlurColor(index, 1);
|
---|
87 | glVertex2fv(verticesList[verticesIndices[index][1]]);
|
---|
88 |
|
---|
89 | glVertex2fv(verticesList[verticesIndices[index][1]]);
|
---|
90 | glColor3fv(color);
|
---|
91 | glVertex2fv(pixelsCoords[index]);
|
---|
92 | calcBlurColor(index, 2);
|
---|
93 | glVertex2fv(verticesList[verticesIndices[index][2]]);
|
---|
94 |
|
---|
95 | glVertex2fv(verticesList[verticesIndices[index][2]]);
|
---|
96 | glColor3fv(color);
|
---|
97 | glVertex2fv(pixelsCoords[index]);
|
---|
98 | calcBlurColor(index, 3);
|
---|
99 | glVertex2fv(verticesList[verticesIndices[index][3]]);
|
---|
100 |
|
---|
101 | glVertex2fv(verticesList[verticesIndices[index][3]]);
|
---|
102 | glColor3fv(color);
|
---|
103 | glVertex2fv(pixelsCoords[index]);
|
---|
104 | calcBlurColor(index, 4);
|
---|
105 | glVertex2fv(verticesList[verticesIndices[index][4]]);
|
---|
106 |
|
---|
107 | glVertex2fv(verticesList[verticesIndices[index][4]]);
|
---|
108 | glColor3fv(color);
|
---|
109 | glVertex2fv(pixelsCoords[index]);
|
---|
110 | calcBlurColor(index, 5);
|
---|
111 | glVertex2fv(verticesList[verticesIndices[index][5]]);
|
---|
112 |
|
---|
113 | glVertex2fv(verticesList[verticesIndices[index][5]]);
|
---|
114 | glColor3fv(color);
|
---|
115 | glVertex2fv(pixelsCoords[index]);
|
---|
116 | calcBlurColor(index, 0);
|
---|
117 | glVertex2fv(verticesList[verticesIndices[index][0]]);
|
---|
118 | glEnd();
|
---|
119 |
|
---|
120 | return;
|
---|
121 | }
|
---|
122 |
|
---|
123 | /************************************************************
|
---|
124 | * DRAW CAMERA draws all the camera pixels
|
---|
125 | ************************************************************/
|
---|
126 | void RawDataViewer::drawCamera(bool alsoWire)
|
---|
127 | {
|
---|
128 | glLoadIdentity();
|
---|
129 | if (!drawImpulse)
|
---|
130 | {
|
---|
131 | glTranslatef(0,-0.44,0);
|
---|
132 | glRotatef(cameraRotation, 0,0,-1);
|
---|
133 | if (cameraRotation == 90)
|
---|
134 | {
|
---|
135 | glTranslatef(-0.45,-0.45,0);
|
---|
136 | // cout << "correction" << endl;
|
---|
137 | }
|
---|
138 | if (cameraRotation == -90)
|
---|
139 | {
|
---|
140 | glTranslatef(0.45,-0.45,0);
|
---|
141 | }
|
---|
142 | glScalef(1.5,1.5,1);
|
---|
143 | }
|
---|
144 | else
|
---|
145 | {
|
---|
146 | glRotatef(cameraRotation, 0,0,-1);
|
---|
147 | if (cameraRotation == 90)
|
---|
148 | {
|
---|
149 | glTranslatef(-0.45/1.5,-0.45/1.5,0);
|
---|
150 | // cout << "correction" << endl;
|
---|
151 | }
|
---|
152 | if (cameraRotation == -90)
|
---|
153 | {
|
---|
154 | glTranslatef(0.45/1.5,-0.45/1.5,0);
|
---|
155 | }
|
---|
156 | }
|
---|
157 | glColor3f(0.5,0.5,0.5);
|
---|
158 | glLineWidth(1.0);
|
---|
159 | float color;
|
---|
160 | //cout << "Actual num pixels: " << ACTUAL_NUM_PIXELS << endl;
|
---|
161 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
162 | {
|
---|
163 | if (!nRoi)
|
---|
164 | color = (float)(i)/(float)(ACTUAL_NUM_PIXELS);
|
---|
165 | else
|
---|
166 | #ifdef LOAD_RAW
|
---|
167 | color = float(eventsData[eventNum][i][whichSlice]+(VALUES_SPAN/2))/(float)(VALUES_SPAN-1);
|
---|
168 | #else
|
---|
169 | color = float(eventData[nRoi*hardwareMapping[i] + whichSlice]+(VALUES_SPAN/2))/(float)(VALUES_SPAN-1);
|
---|
170 | if (logScale)
|
---|
171 | {
|
---|
172 | color *= 9;
|
---|
173 | color += 1;
|
---|
174 | color = log10(color);
|
---|
175 | }
|
---|
176 | #endif
|
---|
177 | if (color < 0)
|
---|
178 | {
|
---|
179 | pixelsColor[i][0] = tooLowValueCoulour[0];
|
---|
180 | pixelsColor[i][1] = tooLowValueCoulour[1];
|
---|
181 | pixelsColor[i][2] = tooLowValueCoulour[2];
|
---|
182 | continue;
|
---|
183 | }
|
---|
184 | if (color > 1)
|
---|
185 | {
|
---|
186 | pixelsColor[i][0] = tooHighValueCoulour[0];
|
---|
187 | pixelsColor[i][1] = tooHighValueCoulour[1];
|
---|
188 | pixelsColor[i][2] = tooHighValueCoulour[2];
|
---|
189 | continue;
|
---|
190 | }
|
---|
191 | int index = 0;
|
---|
192 | while (ss[index] < color && index < 4)
|
---|
193 | index++;
|
---|
194 | index--;
|
---|
195 | if (index < 0) index = 0;
|
---|
196 | float weight0 = (color-ss[index]) / (ss[index+1]-ss[index]);
|
---|
197 | if (weight0 > 1.0f) weight0 = 1.0f;
|
---|
198 | if (weight0 < 0.0f) weight0 = 0.0f;
|
---|
199 | float weight1 = 1.0f-weight0;
|
---|
200 | pixelsColor[i][0] = weight1*rr[index] + weight0*rr[index+1];
|
---|
201 | pixelsColor[i][1] = weight1*gg[index] + weight0*gg[index+1];
|
---|
202 | pixelsColor[i][2] = weight1*bb[index] + weight0*bb[index+1];
|
---|
203 | }
|
---|
204 |
|
---|
205 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
206 | {
|
---|
207 | // if (i == 690 ||
|
---|
208 | // i == 70)
|
---|
209 | // continue;
|
---|
210 | glColor3fv(pixelsColor[i]);
|
---|
211 | glLoadName(i);
|
---|
212 | if (drawBlur)
|
---|
213 | drawBlurryHexagon(i);
|
---|
214 | else
|
---|
215 | drawHexagon(i,true);
|
---|
216 |
|
---|
217 | }
|
---|
218 | if (!alsoWire)
|
---|
219 | return;
|
---|
220 | glTranslatef(0,0,0.1f);
|
---|
221 | glColor3f(0.0f,0.0f,0.0f);
|
---|
222 | for (int i=0;i<ACTUAL_NUM_PIXELS;i++)
|
---|
223 | {
|
---|
224 | // if (i == 690 ||
|
---|
225 | // i == 70)
|
---|
226 | // continue;
|
---|
227 | drawHexagon(i, false);
|
---|
228 | }
|
---|
229 |
|
---|
230 | }
|
---|
231 |
|
---|
232 | /************************************************************
|
---|
233 | * TRIM. FIXME this should not be here but taken from an existing class (somewhere)
|
---|
234 | ***********************************************************
|
---|
235 | string Trim(const string &str)
|
---|
236 | {
|
---|
237 | // Trim Both leading and trailing spaces
|
---|
238 | const size_t start = str.find_first_not_of(' '); // Find the first character position after excluding leading blank spaces
|
---|
239 | const size_t end = str.find_last_not_of(' '); // Find the first character position from reverse af
|
---|
240 |
|
---|
241 | // if all spaces or empty return an empty string
|
---|
242 | if (string::npos==start || string::npos==end)
|
---|
243 | return string();
|
---|
244 |
|
---|
245 | return str.substr(start, end-start+1);
|
---|
246 | }*/
|
---|
247 | /************************************************************
|
---|
248 | * DRAW PIXEL CURVE. draws the raw impulse curve of the currently selected pixel
|
---|
249 | ************************************************************/
|
---|
250 | void RawDataViewer::drawPixelCurve()
|
---|
251 | {
|
---|
252 | if (!nRoi)
|
---|
253 | return;
|
---|
254 |
|
---|
255 | float xZoom, yZoom;
|
---|
256 | xZoom = yZoom = 1.0f;
|
---|
257 |
|
---|
258 | glBegin(GL_LINES);
|
---|
259 | glLineWidth(1.0f);
|
---|
260 | glColor3f(0.5,0.5,0.5);
|
---|
261 | glVertex2f(bboxMin[0], bboxMin[1]);
|
---|
262 | glVertex2f(bboxMax[0], bboxMin[1]);
|
---|
263 | glVertex2f(bboxMin[0], bboxMin[1]);
|
---|
264 | glVertex2f(bboxMin[0], bboxMax[1]);
|
---|
265 | glVertex2f(bboxMin[0], (bboxMin[1]+bboxMax[1])/2.0f);
|
---|
266 | glVertex2f(bboxMax[0], (bboxMin[1]+bboxMax[1])/2.0f);
|
---|
267 | float xRange = bboxMax[0] - bboxMin[0];
|
---|
268 | float yRange = bboxMax[1] - bboxMin[1];
|
---|
269 | glColor3f(1.0,1.0,1.0);
|
---|
270 | float divideMe = (float)(VALUES_SPAN-1);
|
---|
271 | float plusMe = VALUES_SPAN/2;
|
---|
272 |
|
---|
273 | /*
|
---|
274 | if (drawCalibrationLoaded)
|
---|
275 | plusMe += 0;//VALUES_SPAN/2;
|
---|
276 | if (drawCalibrationLoaded && calibrationLoaded)
|
---|
277 | {
|
---|
278 | divideMe /=2;
|
---|
279 | plusMe = 0 ;///=2;
|
---|
280 | }*/
|
---|
281 |
|
---|
282 | const int hw = hardwareMapping[selectedPixel];
|
---|
283 |
|
---|
284 | for (int i=0;i<nRoi-1;i++)
|
---|
285 | {
|
---|
286 | #ifdef LOAD_RAW
|
---|
287 | glVertex2f(bboxMin[0] + xRange*i/(float)nRoi,
|
---|
288 | bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i]+plusMe) /divideMe);
|
---|
289 | glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi,
|
---|
290 | bboxMin[1] + yRange*(eventsData[eventNum][selectedPixel][i+1]+plusMe) /divideMe);
|
---|
291 | #else
|
---|
292 |
|
---|
293 |
|
---|
294 | float d1 = eventData[nRoi*hw + i]+plusMe;
|
---|
295 | float d2 = eventData[nRoi*hw + i+1]+plusMe;
|
---|
296 | if (!finite(d1)) d1 = 20000;
|
---|
297 | if (!finite(d2)) d2 = 20000;
|
---|
298 | glVertex2f(bboxMin[0] + xRange*i/(float)nRoi,
|
---|
299 | bboxMin[1] + yRange*(d1) /divideMe);
|
---|
300 | glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi,
|
---|
301 | bboxMin[1] + yRange*(d2) /divideMe);
|
---|
302 | #endif
|
---|
303 | }
|
---|
304 | glEnd();
|
---|
305 | glTranslatef(0,0,0.1f);
|
---|
306 | glBegin(GL_LINES);
|
---|
307 | glColor3f(1.0,0.0,0.0);
|
---|
308 | glVertex2f(bboxMin[0] + xRange*whichSlice/(float)nRoi,
|
---|
309 | bboxMin[1]);
|
---|
310 | glVertex2f(bboxMin[0] + xRange*whichSlice/(float)nRoi,
|
---|
311 | bboxMax[1]);
|
---|
312 |
|
---|
313 | /* glColor3f(0.f,0.5f,0.f);
|
---|
314 | for (int i=0;i<nRoi-1;i++)
|
---|
315 | {
|
---|
316 | glVertex2f(bboxMin[0] + xRange*i/(float)nRoi,
|
---|
317 | bboxMin[1] + yRange*(n1mean[ i]+plusMe) /divideMe);
|
---|
318 | glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi,
|
---|
319 | bboxMin[1] + yRange*(n1mean[i+1]+plusMe) /divideMe);
|
---|
320 | }
|
---|
321 | */
|
---|
322 | glEnd();
|
---|
323 | // glEnable(GL_MULTISAMPLE);
|
---|
324 | /* setFont(QFont("Times", 12));
|
---|
325 | qglColor(QColor(255,223,127));
|
---|
326 | float xShift = 0.10f;
|
---|
327 | float yShift = 0.01f;
|
---|
328 | renderText(bboxMin[0]-xShift/2.0f, bboxMax[1]+3*yShift, 0, QString("Volts"));
|
---|
329 | if (drawCalibrationLoaded)
|
---|
330 | {
|
---|
331 | renderText(bboxMin[0]-xShift, bboxMax[1]-yShift,0,QString("+2.10"));
|
---|
332 | renderText(bboxMin[0]-xShift, ((bboxMin[1]+bboxMax[1])/2.0f) - yShift, 0, QString("+1.05"));//((bboxMin[1]+bboxMax[1])/2.0f)
|
---|
333 | renderText(bboxMin[0]-xShift, bboxMin[1]-yShift, 0, QString("0.00"));
|
---|
334 | }
|
---|
335 | else
|
---|
336 | {
|
---|
337 | renderText(bboxMin[0]-xShift, bboxMax[1]-yShift,0,QString("+1.05"));
|
---|
338 | renderText(bboxMin[0]-xShift, ((bboxMin[1]+bboxMax[1])/2.0f) - yShift, 0, QString("+0.00"));//((bboxMin[1]+bboxMax[1])/2.0f)
|
---|
339 | renderText(bboxMin[0]-xShift, bboxMin[1]-yShift, 0, QString("-1.05"));
|
---|
340 | }
|
---|
341 | renderText(bboxMax[0]+xShift/2.0f, bboxMin[1]-4*yShift, 0, QString("Slices"));
|
---|
342 | renderText(bboxMin[0]-yShift/2.0f, bboxMin[1]-4*yShift, 0, QString("0"));
|
---|
343 | ostringstream str;
|
---|
344 | str << nRoi/2;
|
---|
345 | renderText(((bboxMin[0]+bboxMax[0])/2.0f)-xShift/2.0f, bboxMin[1]-4*yShift, 0, QString(str.str().c_str()));
|
---|
346 | str.str("");
|
---|
347 | str << nRoi;
|
---|
348 | renderText(bboxMax[0]-xShift/2.0f, bboxMin[1]-4*yShift, 0, QString(str.str().c_str()));
|
---|
349 | */
|
---|
350 | }
|
---|
351 | /************************************************************
|
---|
352 | * CONSTRUCTOR.
|
---|
353 | ************************************************************/
|
---|
354 | RawDataViewer::RawDataViewer(QWidget *cParent) : BasicGlCamera(cParent), RMSvalues(1440)
|
---|
355 | {
|
---|
356 | // setFormat(QGLFormat(QGL::DoubleBuffer));// | QGL::DepthBuffer));
|
---|
357 | whichSlice = 0;
|
---|
358 | #ifdef LOAD_RAW
|
---|
359 | nRoi = 1024;
|
---|
360 | #else
|
---|
361 | nRoi = 0;
|
---|
362 | #endif
|
---|
363 | eventNum = 0;
|
---|
364 | rowNum = -1;
|
---|
365 | eventStep = 1;
|
---|
366 | selectedPixel = 393;
|
---|
367 | inputFile = NULL;
|
---|
368 | eventData = NULL;
|
---|
369 | drawPatch = true;
|
---|
370 | drawImpulse = true;
|
---|
371 | drawBlur = false;
|
---|
372 | loopCurrentEvent = false;
|
---|
373 | SetAutoRefresh(true);
|
---|
374 | #ifdef LOAD_RAW
|
---|
375 | loadEvents("/scratch/00000043.001_T.bin");
|
---|
376 | #endif
|
---|
377 | PixelMap mypMap;
|
---|
378 | if (!mypMap.Read("FACTmapV5a.txt"))
|
---|
379 | {
|
---|
380 | cerr << "ERROR - Problems reading FACTmapV5a.txt" << endl;
|
---|
381 | exit(-1);
|
---|
382 | }
|
---|
383 |
|
---|
384 | assignPixelMap(mypMap);
|
---|
385 | buildVerticesList();
|
---|
386 |
|
---|
387 | for (int i=0;i<160;i++)
|
---|
388 | {
|
---|
389 | const float color[3] = { 0.5, 0.5, 0.3 };
|
---|
390 |
|
---|
391 | for (int j=0;j<3;j++)
|
---|
392 | patchesColor[i][j] = color[j];
|
---|
393 | }
|
---|
394 |
|
---|
395 | //calibrationLoaded = false;
|
---|
396 | //drawCalibrationLoaded = false;
|
---|
397 |
|
---|
398 | }
|
---|
399 | /************************************************************
|
---|
400 | * DESTRUCTOR
|
---|
401 | ************************************************************/
|
---|
402 | RawDataViewer::~RawDataViewer()
|
---|
403 | {
|
---|
404 | if (inputFile != NULL)
|
---|
405 | {
|
---|
406 | inputFile->close();
|
---|
407 | delete inputFile;
|
---|
408 | }
|
---|
409 | if (eventData != NULL) {
|
---|
410 | delete[] eventData;
|
---|
411 | delete[] rawEventData;
|
---|
412 | delete[] waveLetArray;
|
---|
413 | }
|
---|
414 | }
|
---|
415 |
|
---|
416 | /************************************************************
|
---|
417 | * PAINT GL. main drawing function.
|
---|
418 | ************************************************************/
|
---|
419 | void RawDataViewer::paintGL()
|
---|
420 | {
|
---|
421 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
---|
422 | glLoadIdentity();
|
---|
423 |
|
---|
424 | glTranslatef(0,0,-0.5);
|
---|
425 |
|
---|
426 | if (drawBlur)
|
---|
427 | {
|
---|
428 | glShadeModel(GL_SMOOTH);
|
---|
429 | drawCamera(false);
|
---|
430 | }
|
---|
431 | else
|
---|
432 | {
|
---|
433 | glShadeModel(GL_FLAT);
|
---|
434 | drawCamera(true);
|
---|
435 | }
|
---|
436 | glTranslatef(0,0,0.1f);
|
---|
437 | if (drawPatch)
|
---|
438 | drawPatches();
|
---|
439 | glTranslatef(0,0,0.1f);
|
---|
440 | if (!drawBlur)
|
---|
441 | {
|
---|
442 | glLineWidth(1.0f);
|
---|
443 | glColor3f(1.0,1.0,1.0);
|
---|
444 | drawHexagon(selectedPixel, false);
|
---|
445 | }
|
---|
446 | glTranslatef(0,0,0.1f);
|
---|
447 | if (drawImpulse)
|
---|
448 | {
|
---|
449 | // glRotatef(cameraRotation, 0,0,1);
|
---|
450 | glLoadIdentity();
|
---|
451 | glLineWidth(2.0);
|
---|
452 | drawPixelCurve();
|
---|
453 | }
|
---|
454 | glTranslatef(0,0,0.1f);
|
---|
455 | DrawScale();
|
---|
456 | }
|
---|
457 |
|
---|
458 | /************************************************************
|
---|
459 | * MOUSE PRESS EVENT. mouse click handler.
|
---|
460 | ************************************************************/
|
---|
461 | void RawDataViewer::mousePressEvent(QMouseEvent *cEvent)
|
---|
462 | {
|
---|
463 | if (cEvent->pos().x() > width()-(width()/50.f))
|
---|
464 | {
|
---|
465 | toggleInterfaceDisplay();
|
---|
466 | return;
|
---|
467 | }
|
---|
468 | lastPos = cEvent->pos();
|
---|
469 | setCorrectSlice(cEvent);
|
---|
470 | int face = PixelAtPosition(cEvent->pos());
|
---|
471 | if (face != -1) {
|
---|
472 | selectedPixel = face;
|
---|
473 | emit signalCurrentPixel(face);
|
---|
474 | }
|
---|
475 | updateGL();
|
---|
476 | }
|
---|
477 |
|
---|
478 | /************************************************************
|
---|
479 | * SET CORRECT SLICE. if displayed, figures out if the graph was
|
---|
480 | * clicked, and if so, which slice should be displayed
|
---|
481 | ************************************************************/
|
---|
482 | void RawDataViewer::setCorrectSlice(QMouseEvent* cEvent)
|
---|
483 | {
|
---|
484 | if (!drawImpulse)
|
---|
485 | return;
|
---|
486 | float cx = (float)cEvent->x() * pixelSize - shownSizex/2;
|
---|
487 | float cy = ((float)height()-(float)cEvent->y())*pixelSize - shownSizey/2;
|
---|
488 | if (cx < bboxMin[0] ||
|
---|
489 | cx > bboxMax[0] ||
|
---|
490 | cy < bboxMin[1] ||
|
---|
491 | cy > bboxMax[1])
|
---|
492 | return;
|
---|
493 | whichSlice = (cx - bboxMin[0])*1024/(bboxMax[0] - bboxMin[0]);
|
---|
494 | emit signalCurrentSlice(whichSlice);
|
---|
495 | }
|
---|
496 |
|
---|
497 | /************************************************************
|
---|
498 | * MOUSE MOVE EVENT. used to track the dragging of slices display
|
---|
499 | ************************************************************/
|
---|
500 | void RawDataViewer::mouseMoveEvent(QMouseEvent *cEvent)
|
---|
501 | {
|
---|
502 | if (cEvent->buttons() & Qt::LeftButton) {
|
---|
503 | setCorrectSlice(cEvent);
|
---|
504 | updateGL();
|
---|
505 | } else if (cEvent->buttons() & Qt::RightButton) {
|
---|
506 | updateGL();
|
---|
507 | }
|
---|
508 | lastPos = cEvent->pos();
|
---|
509 | }
|
---|
510 |
|
---|
511 | /************************************************************
|
---|
512 | * MOUSE DOUBLE CLICK EVENT. used to select pixels
|
---|
513 | ************************************************************/
|
---|
514 | void RawDataViewer::mouseDoubleClickEvent(QMouseEvent *cEvent)
|
---|
515 | {
|
---|
516 | int face = PixelAtPosition(cEvent->pos());
|
---|
517 | if (face != -1) {
|
---|
518 | selectedPixel = face;
|
---|
519 | emit signalCurrentPixel(face);
|
---|
520 | updateGL();
|
---|
521 | }
|
---|
522 | }
|
---|
523 |
|
---|
524 | /************************************************************
|
---|
525 | * OPEN FILE. opens a new fits file
|
---|
526 | ************************************************************/
|
---|
527 | void RawDataViewer::openFile(string& file)
|
---|
528 | {
|
---|
529 | if (inputFile)
|
---|
530 | {
|
---|
531 | inputFile->close();
|
---|
532 | delete inputFile;
|
---|
533 | }
|
---|
534 | try {
|
---|
535 | inputFile = new fits(file);
|
---|
536 | }
|
---|
537 | catch (std::runtime_error e)
|
---|
538 | {
|
---|
539 | cout << "Something went wrong while loading fits. aborting: " << e.what() << endl;
|
---|
540 | return;
|
---|
541 | }
|
---|
542 | if (!*inputFile)
|
---|
543 | {
|
---|
544 | delete inputFile;
|
---|
545 | inputFile = NULL;
|
---|
546 | return;
|
---|
547 | }
|
---|
548 | vector<string> entriesToCheck;
|
---|
549 | entriesToCheck.push_back("NAXIS2");
|
---|
550 | entriesToCheck.push_back("NROI");
|
---|
551 | entriesToCheck.push_back("REVISION");
|
---|
552 | entriesToCheck.push_back("RUNID");
|
---|
553 | entriesToCheck.push_back("NBOARD");
|
---|
554 | entriesToCheck.push_back("NPIX");
|
---|
555 | entriesToCheck.push_back("NROITM");
|
---|
556 | entriesToCheck.push_back("TIMESYS");
|
---|
557 | entriesToCheck.push_back("DATE");
|
---|
558 | entriesToCheck.push_back("NIGHT");
|
---|
559 | entriesToCheck.push_back("CAMERA");
|
---|
560 | entriesToCheck.push_back("DAQ");
|
---|
561 | entriesToCheck.push_back("TSTART");
|
---|
562 | entriesToCheck.push_back("TSTOP");
|
---|
563 | //entriesToCheck.push_back("ADCRANGE");
|
---|
564 | //entriesToCheck.push_back("NBEVTOK");
|
---|
565 | //entriesToCheck.push_back("NBEVTREJ");
|
---|
566 | //entriesToCheck.push_back("NBEVTBAD");
|
---|
567 |
|
---|
568 | for (vector<string>::const_iterator it=entriesToCheck.begin(); it != entriesToCheck.end(); it++)
|
---|
569 | {
|
---|
570 | try {
|
---|
571 | if (!inputFile->HasKey(*it)){
|
---|
572 | cout << *it << " missing. Aborting load..." << endl;
|
---|
573 | return;}
|
---|
574 | }
|
---|
575 | catch (std::runtime_error e)
|
---|
576 | {
|
---|
577 | cout << e.what() << endl;
|
---|
578 | return;
|
---|
579 | }
|
---|
580 | }
|
---|
581 | nRows = inputFile->GetInt("NAXIS2");
|
---|
582 | nRoi = inputFile->GetInt("NROI");
|
---|
583 | runNumber = inputFile->GetInt("RUNID");
|
---|
584 | nTM = inputFile->HasKey("NTMARK") ? inputFile->GetInt("NTMARK") : 0;
|
---|
585 | runType = inputFile->HasKey("RUNTYPE") ? inputFile->GetInt("RUNTYPE") : -1;
|
---|
586 | firstDataTime = inputFile->GetInt("TSTART");
|
---|
587 | lastDataTime = inputFile->GetInt("TSTOP");
|
---|
588 | nRoiTM = inputFile->GetInt("NROITM");
|
---|
589 | revision = inputFile->GetInt("REVISION");
|
---|
590 | builderVersion = inputFile->HasKey("BLDVER") ? inputFile->GetInt("BLDVER") : -1;
|
---|
591 | nBoards = inputFile->GetInt("NBOARD");
|
---|
592 | nPixels = inputFile->GetInt("NPIX");
|
---|
593 | timeSystem = inputFile->GetStr("TIMESYS");
|
---|
594 | creationDate = inputFile->GetStr("DATE");
|
---|
595 | nightInt = inputFile->GetInt("NIGHT");
|
---|
596 | camera = inputFile->GetStr("CAMERA");
|
---|
597 | daq = inputFile->GetStr("DAQ");
|
---|
598 | adcCount = inputFile->HasKey("ADCRANGE") ? inputFile->GetFloat("ADCRANGE") : 2000;
|
---|
599 | nbOk = 0;//inputFile->GetInt("NBEVTOK");
|
---|
600 | nbRej = 0;//inputFile->GetInt("NBEVTREJ");
|
---|
601 | nbBad = 0;//inputFile->GetInt("NBEVTBAD");
|
---|
602 |
|
---|
603 | eventNum = 0;
|
---|
604 |
|
---|
605 | #ifdef LOAD_RAW
|
---|
606 | nRows = NUM_STORED_EVENTS;
|
---|
607 | #endif
|
---|
608 |
|
---|
609 | if (eventData != NULL) {
|
---|
610 | delete[] eventData;
|
---|
611 | delete[] rawEventData;
|
---|
612 | delete[] waveLetArray;
|
---|
613 | }
|
---|
614 | eventData = new float[(1440+160)*nRoi];
|
---|
615 |
|
---|
616 | rawEventData = new int16_t[(1440+160)*nRoi];
|
---|
617 | waveLetArray = new int16_t[1024*1440];
|
---|
618 | try
|
---|
619 | {
|
---|
620 | inputFile->SetPtrAddress("Data", rawEventData);
|
---|
621 | inputFile->SetPtrAddress("EventNum", &eventNum);
|
---|
622 | inputFile->SetPtrAddress("TriggerType", &triggerType);
|
---|
623 | inputFile->SetPtrAddress("SoftTrig", &softTrig);
|
---|
624 | inputFile->SetPtrAddress("BoardTime", boardTime);
|
---|
625 | inputFile->SetPtrAddress("StartCellData", startPix);
|
---|
626 | inputFile->SetPtrAddress("StartCellTimeMarker", startTM);
|
---|
627 | }
|
---|
628 | catch (const runtime_error &e)
|
---|
629 | {
|
---|
630 | cout << e.what() << endl;
|
---|
631 | cout << "Loading aborted." << endl;
|
---|
632 |
|
---|
633 | nRoi = nRows = 0;
|
---|
634 |
|
---|
635 | return;
|
---|
636 | }
|
---|
637 |
|
---|
638 | try
|
---|
639 | {
|
---|
640 | pcTime[0] = pcTime[1] = 0;
|
---|
641 | inputFile->SetPtrAddress("UnixTimeUTC", pcTime);
|
---|
642 | }
|
---|
643 | catch (const runtime_error&)
|
---|
644 | {
|
---|
645 | try
|
---|
646 | {
|
---|
647 | inputFile->SetPtrAddress("PCTime", pcTime);
|
---|
648 | }
|
---|
649 | catch (const runtime_error&)
|
---|
650 | {
|
---|
651 |
|
---|
652 | }
|
---|
653 | }
|
---|
654 |
|
---|
655 |
|
---|
656 | int backupStep = eventStep;
|
---|
657 | rowNum = -1;
|
---|
658 | eventStep = 1;
|
---|
659 |
|
---|
660 | doMyWaveletTestPlease();
|
---|
661 |
|
---|
662 |
|
---|
663 | plusEvent();
|
---|
664 | eventStep = backupStep;
|
---|
665 | emit newFileLoaded();
|
---|
666 | emit signalCurrentPixel(selectedPixel);
|
---|
667 | }
|
---|
668 | /*
|
---|
669 | bool RawDataViewer::doWaveLetsPlease(int givenSpan, int16_t* orig_in, int16_t* wavelets_in, bool verifyResult)
|
---|
670 | {
|
---|
671 | float* interArray = new float[givenSpan];
|
---|
672 | float* resultArray = new float[givenSpan];
|
---|
673 | float* orig = new float[givenSpan];
|
---|
674 | float* wavelets = new float[givenSpan];
|
---|
675 | for (int i=0;i<givenSpan;i++)
|
---|
676 | {
|
---|
677 | if (fabs((float)(orig_in[i])) > 32767.f)
|
---|
678 | cout << "Input overflow: " << orig_in[i] << endl;
|
---|
679 | orig[i] = (float)orig_in[i];
|
---|
680 | }
|
---|
681 | for (int k=0;k<givenSpan;k++)
|
---|
682 | interArray[k] = orig[k];
|
---|
683 | int span = givenSpan/2;
|
---|
684 | while (span > 0)
|
---|
685 | {
|
---|
686 | for (int k=0;k<span;k++)
|
---|
687 | {
|
---|
688 | wavelets[k] = (interArray[2*k] + interArray[2*k + 1])/2.f;
|
---|
689 | wavelets[k + span] = (interArray[2*k + 1] - interArray[2*k])/2.f;
|
---|
690 | }
|
---|
691 | for (int k=0;k<givenSpan;k++)
|
---|
692 | interArray[k] = wavelets[k];
|
---|
693 | span /= 2;
|
---|
694 | }
|
---|
695 | //move float results to int16_t array
|
---|
696 | float intScaling = 15.9f;
|
---|
697 | int max = 0;
|
---|
698 | for (int i=0;i<givenSpan;i++)
|
---|
699 | {
|
---|
700 | float cValue = intScaling*wavelets[i];//
|
---|
701 | if (cValue > 0)
|
---|
702 | cValue += 0.5f;
|
---|
703 | else
|
---|
704 | cValue -= 0.5f;
|
---|
705 | wavelets_in[i] = (int16_t)(cValue);
|
---|
706 | if (fabs(cValue) > 32767.f)
|
---|
707 | {
|
---|
708 | cout << "Overflow ! " << cValue << endl;
|
---|
709 | }
|
---|
710 | if (fabs(cValue) > fabs(max))
|
---|
711 | max = cValue;
|
---|
712 | }
|
---|
713 | // cout << "Max wave value: " << max << endl;
|
---|
714 | //result reconstruction and checking
|
---|
715 | if (!verifyResult)
|
---|
716 | return true;
|
---|
717 |
|
---|
718 | for (int k=0;k<givenSpan;k++)
|
---|
719 | {
|
---|
720 | resultArray[k] = wavelets_in[k]/intScaling;
|
---|
721 | }
|
---|
722 |
|
---|
723 | span = 1;
|
---|
724 | while (span < givenSpan)
|
---|
725 | {
|
---|
726 | for (int k=0;k<givenSpan;k++)
|
---|
727 | interArray[k] = resultArray[k];
|
---|
728 | for (int k=0;k<span;k++)
|
---|
729 | {
|
---|
730 | resultArray[2*k] = (float)(((interArray[k] - interArray[k + span])*(1.f/1.f)) + 0.0f);
|
---|
731 | resultArray[2*k + 1] = (float)(((interArray[k] + interArray[k + span])*(1.f/1.f)) + 0.0f);
|
---|
732 | }
|
---|
733 | span *= 2;
|
---|
734 | }
|
---|
735 |
|
---|
736 | for (int k=0;k<givenSpan;k++)
|
---|
737 | {
|
---|
738 | float plus = 0.5f;
|
---|
739 | if (resultArray[k] < 0)
|
---|
740 | plus *= -1.f;
|
---|
741 | if ((int)(resultArray[k]+plus) != (int)(orig_in[k]))
|
---|
742 | {
|
---|
743 | cout << "Nop, sorry: k: " << k << " " << resultArray[k] << " " << (int)(resultArray[k]+plus) << " " << plus << " " << orig[k] << endl;
|
---|
744 | return false;
|
---|
745 | }
|
---|
746 | }
|
---|
747 | return true;
|
---|
748 | }
|
---|
749 | */
|
---|
750 | bool RawDataViewer::doWaveLetsPlease(int givenSpan, int16_t* orig_in, int16_t* wavelets_in, bool verifyResult)
|
---|
751 | {
|
---|
752 | float* interArray = new float[givenSpan];
|
---|
753 | float* resultArray = new float[givenSpan];
|
---|
754 | float* orig = new float[givenSpan];
|
---|
755 | float* wavelets = new float[givenSpan];
|
---|
756 | for (int i=0;i<givenSpan;i++)
|
---|
757 | {
|
---|
758 | if (fabs((float)(orig_in[i])) > 32767.f)
|
---|
759 | cout << "Input overflow: " << orig_in[i] << endl;
|
---|
760 | orig[i] = (float)orig_in[i];
|
---|
761 | }
|
---|
762 | for (int k=0;k<givenSpan;k++)
|
---|
763 | interArray[k] = orig[k];
|
---|
764 | int span = givenSpan/2;
|
---|
765 | while (span > 0)
|
---|
766 | {
|
---|
767 | for (int k=0;k<span;k++)
|
---|
768 | {
|
---|
769 | wavelets[k] = interArray[2*k];// + interArray[2*k + 1])/2.f;
|
---|
770 | wavelets[k + span] = interArray[2*k + 1] - interArray[2*k];//)/2.f;
|
---|
771 | }
|
---|
772 | for (int k=0;k<givenSpan;k++)
|
---|
773 | interArray[k] = wavelets[k];
|
---|
774 | span /= 2;
|
---|
775 | }
|
---|
776 | //move float results to int16_t array
|
---|
777 | float intScaling = 1.f;
|
---|
778 | int max = 0;
|
---|
779 | for (int i=0;i<givenSpan;i++)
|
---|
780 | {
|
---|
781 | float cValue = intScaling*wavelets[i];//
|
---|
782 | if (cValue > 0)
|
---|
783 | cValue += 0.5f;
|
---|
784 | else
|
---|
785 | cValue -= 0.5f;
|
---|
786 | wavelets_in[i] = (int16_t)(cValue);
|
---|
787 | if (fabs(cValue) > 32767.f)
|
---|
788 | {
|
---|
789 | cout << "Overflow ! " << cValue << endl;
|
---|
790 | }
|
---|
791 | if (fabs(cValue) > fabs(max))
|
---|
792 | max = cValue;
|
---|
793 | }
|
---|
794 | // cout << "Max wave value: " << max << endl;
|
---|
795 | //result reconstruction and checking
|
---|
796 | if (!verifyResult)
|
---|
797 | return true;
|
---|
798 |
|
---|
799 | for (int k=0;k<givenSpan;k++)
|
---|
800 | {
|
---|
801 | resultArray[k] = wavelets_in[k]/intScaling;
|
---|
802 | }
|
---|
803 |
|
---|
804 | span = 1;
|
---|
805 | while (span < givenSpan)
|
---|
806 | {
|
---|
807 | for (int k=0;k<givenSpan;k++)
|
---|
808 | interArray[k] = resultArray[k];
|
---|
809 | for (int k=0;k<span;k++)
|
---|
810 | {
|
---|
811 | resultArray[2*k] = (float)(((interArray[k])*(1.f/1.f)) + 0.0f);
|
---|
812 | resultArray[2*k + 1] = (float)(((interArray[k] + interArray[k + span])*(1.f/1.f)) + 0.0f);
|
---|
813 | }
|
---|
814 | span *= 2;
|
---|
815 | }
|
---|
816 |
|
---|
817 | for (int k=0;k<givenSpan;k++)
|
---|
818 | {
|
---|
819 | float plus = 0.5f;
|
---|
820 | if (resultArray[k] < 0)
|
---|
821 | plus *= -1.f;
|
---|
822 | if ((int)(resultArray[k]+plus) != (int)(orig_in[k]))
|
---|
823 | {
|
---|
824 | cout << "Nop, sorry: k: " << k << " " << resultArray[k] << " " << (int)(resultArray[k]+plus) << " " << plus << " " << orig[k] << endl;
|
---|
825 | return false;
|
---|
826 | }
|
---|
827 | }
|
---|
828 | delete[] interArray;
|
---|
829 | delete[] resultArray;
|
---|
830 | delete[] orig;
|
---|
831 | delete[] wavelets;
|
---|
832 | return true;
|
---|
833 | }
|
---|
834 |
|
---|
835 | void RawDataViewer::doWaveLetOnCurrentEventPlease()
|
---|
836 | {
|
---|
837 | int16_t* origTheWayIWant = new int16_t[1024*1440];
|
---|
838 |
|
---|
839 | // int numPixels = 1024;
|
---|
840 | // int leftOver = 1440-numPixels;
|
---|
841 | for (int k=0;k<1024;k++)
|
---|
842 | for (int j=0;j<1440;j++)
|
---|
843 | {
|
---|
844 | origTheWayIWant[k*1440 + j] = rawEventData[j + k*1440];
|
---|
845 | }
|
---|
846 |
|
---|
847 | int waveSpan = 1024;
|
---|
848 | int waveToPixelsRatio = 32;
|
---|
849 | waveSpan = waveSpan*waveToPixelsRatio;
|
---|
850 | int totalNumSamples = 1024*1440;
|
---|
851 | int j=0;
|
---|
852 | for (;j<totalNumSamples;j+= waveSpan)
|
---|
853 | {
|
---|
854 | if (j + waveSpan < totalNumSamples)
|
---|
855 | if (!doWaveLetsPlease(waveSpan, &origTheWayIWant[j], &waveLetArray[j], true))
|
---|
856 | return;
|
---|
857 | }
|
---|
858 |
|
---|
859 | while (j%1440 != 0)
|
---|
860 | {
|
---|
861 | int lastRun = 1;
|
---|
862 | while (lastRun < 1440 - j%1440)
|
---|
863 | lastRun *= 2;
|
---|
864 | lastRun /= 2;
|
---|
865 | if (lastRun > 2)
|
---|
866 | {
|
---|
867 | doWaveLetsPlease(lastRun, &origTheWayIWant[j], &waveLetArray[j], true);
|
---|
868 | }
|
---|
869 | else
|
---|
870 | {
|
---|
871 | for (int l=0;l<lastRun;l++)
|
---|
872 | waveLetArray[j+l] = origTheWayIWant[j+l];
|
---|
873 | }
|
---|
874 | if (!lastRun)
|
---|
875 | break;
|
---|
876 | j += lastRun;
|
---|
877 | }
|
---|
878 |
|
---|
879 | delete[] origTheWayIWant;
|
---|
880 |
|
---|
881 | }
|
---|
882 | void RawDataViewer::doMyWaveletTestPlease()
|
---|
883 | {
|
---|
884 | // cout << "Size of float: " << sizeof(float) << endl;
|
---|
885 | return;
|
---|
886 | ofstream outBin("/scratch/bin/outputBin.bin", ios_base::out | ios_base::binary);
|
---|
887 | ofstream outWave("/scratch/bin/outputWave.bin", ios_base::out | ios_base::binary);
|
---|
888 | int16_t* waveLetArray_ = new int16_t[1024*1440];
|
---|
889 | int16_t* origTheWayIWant = new int16_t[1024*1440];
|
---|
890 |
|
---|
891 | for (int i=0;i<nRows;i++)
|
---|
892 | {
|
---|
893 | cout << '\r' << "Doing row " << i << " of " << nRows;
|
---|
894 | cout.flush();
|
---|
895 | inputFile->GetRow(i);
|
---|
896 | outBin.write((const char*)(rawEventData), 1440*1024*2);
|
---|
897 |
|
---|
898 | // int numPixels = 1024;
|
---|
899 | // int leftOver = 1440-numPixels;
|
---|
900 | for (int k=0;k<1024;k++)
|
---|
901 | for (int j=0;j<1440;j++)
|
---|
902 | {
|
---|
903 | origTheWayIWant[k*1440 + j] = rawEventData[j + k*1440];
|
---|
904 | }
|
---|
905 |
|
---|
906 | int waveSpan = 1024;
|
---|
907 | int waveToPixelsRatio = 32;
|
---|
908 | waveSpan = waveSpan*waveToPixelsRatio;
|
---|
909 | int totalNumSamples = 1024*1440;
|
---|
910 | int j=0;
|
---|
911 | for (;j<totalNumSamples;j+= waveSpan)//1440/waveToPixelsRatio;j++)
|
---|
912 | {
|
---|
913 | if (j + waveSpan < totalNumSamples)
|
---|
914 | if (!doWaveLetsPlease(waveSpan, &origTheWayIWant[j], &waveLetArray_[j], true))
|
---|
915 | return;
|
---|
916 | }
|
---|
917 |
|
---|
918 | while (j%1440 != 0)// < totalNumSamples)
|
---|
919 | {
|
---|
920 | cout << "Copying the remaining of the data" << endl;
|
---|
921 | int lastRun = 1;
|
---|
922 | while (lastRun < 1440 - j%1440)//totalNumSamples-j)
|
---|
923 | lastRun *= 2;
|
---|
924 | lastRun /= 2;
|
---|
925 | if (lastRun > 2)
|
---|
926 | {
|
---|
927 | // cout << " Doint one last run of " << lastRun << " samples" << endl;
|
---|
928 | doWaveLetsPlease(lastRun, &origTheWayIWant[j], &waveLetArray_[j], true);
|
---|
929 | }
|
---|
930 | else
|
---|
931 | {
|
---|
932 | // cout << " Filling in " << lastRun << " samples" << endl;
|
---|
933 | for (int l=0;l<lastRun;l++)
|
---|
934 | waveLetArray_[j+l] = origTheWayIWant[j+l];
|
---|
935 | }
|
---|
936 | if (!lastRun)
|
---|
937 | break;
|
---|
938 | j += lastRun;
|
---|
939 | }
|
---|
940 | outWave.write((const char*)(waveLetArray_), 1440*1024*2);
|
---|
941 | }
|
---|
942 | outWave.close();
|
---|
943 | outBin.close();
|
---|
944 | inputFile->GetRow(0);
|
---|
945 |
|
---|
946 | delete[] waveLetArray_;
|
---|
947 | delete[] origTheWayIWant;
|
---|
948 | }
|
---|
949 | void RawDataViewer::openCalibFile(string& file)
|
---|
950 | {
|
---|
951 | //calibrationLoaded = false;
|
---|
952 |
|
---|
953 | MessageImp msg;
|
---|
954 | if (!DataCalib::ReadFits(file, msg))
|
---|
955 | {
|
---|
956 | DataCalib::Restart();
|
---|
957 | return;
|
---|
958 | }
|
---|
959 | /*
|
---|
960 |
|
---|
961 | calibInputFile = new fits(file);
|
---|
962 | if (!*calibInputFile)
|
---|
963 | {
|
---|
964 | delete calibInputFile;
|
---|
965 | calibInputFile = NULL;
|
---|
966 | return;
|
---|
967 | }
|
---|
968 |
|
---|
969 | // if (calibInputFile->HasKey("NROI"))
|
---|
970 | // {
|
---|
971 | // cout << "Looks like you're trying to load a regular raw data file as DRS calib. aborting." << endl;
|
---|
972 | // delete calibInputFile;
|
---|
973 | // calibInputFile = NULL;
|
---|
974 | // return;
|
---|
975 | // }
|
---|
976 |
|
---|
977 | if (!calibInputFile->SetPtrAddress("BaselineMean", baseLineMean)){
|
---|
978 | cout << "Missing column " << "BaseLineMean" << " Aborting load..." << endl;
|
---|
979 | return;}
|
---|
980 | if (!calibInputFile->SetPtrAddress("GainMean", gainMean)){
|
---|
981 | cout << "Missing column " << "GainMean" << " Aborting load..." << endl;
|
---|
982 | return;}
|
---|
983 | if (!calibInputFile->SetPtrAddress("TriggerOffsetMean", triggerOffsetMean)){
|
---|
984 | cout << "Missing column " << "TriggerOffsetMean" << " Aborting load..." << endl;
|
---|
985 | return;}
|
---|
986 |
|
---|
987 | calibInputFile->GetNextRow();
|
---|
988 |
|
---|
989 | // for (int i=0;i<1024;i++)
|
---|
990 | // cout << gainMean[i] << " ";
|
---|
991 | // cout << endl << endl;
|
---|
992 |
|
---|
993 | delete calibInputFile;
|
---|
994 | */
|
---|
995 | //calibrationLoaded = true;
|
---|
996 |
|
---|
997 | emit newFileLoaded();
|
---|
998 |
|
---|
999 | //if (calibratedCheckBox->isChecked())
|
---|
1000 | updateGL();
|
---|
1001 | }
|
---|
1002 | /************************************************************
|
---|
1003 | * PLUS EVENT
|
---|
1004 | ************************************************************/
|
---|
1005 | void RawDataViewer::plusEvent()
|
---|
1006 | {
|
---|
1007 | eventStepping(true);
|
---|
1008 | }
|
---|
1009 | /************************************************************
|
---|
1010 | * MINUS EVENT
|
---|
1011 | ************************************************************/
|
---|
1012 | void RawDataViewer::minusEvent()
|
---|
1013 | {
|
---|
1014 | eventStepping(false);
|
---|
1015 | }
|
---|
1016 | /************************************************************
|
---|
1017 | * SET EVENT STEP
|
---|
1018 | ************************************************************/
|
---|
1019 | void RawDataViewer::setEventStep(int step)
|
---|
1020 | {
|
---|
1021 | eventStep = step;
|
---|
1022 | }
|
---|
1023 | /************************************************************
|
---|
1024 | * EVENT STEPPING
|
---|
1025 | ************************************************************/
|
---|
1026 | void RawDataViewer::eventStepping(bool plus)
|
---|
1027 | {
|
---|
1028 | if (plus)
|
---|
1029 | rowNum += eventStep;
|
---|
1030 | else
|
---|
1031 | rowNum -= eventStep;
|
---|
1032 | if (rowNum >= nRows)
|
---|
1033 | rowNum -= nRows;
|
---|
1034 | if (rowNum < 0)
|
---|
1035 | rowNum += nRows;
|
---|
1036 | #ifdef LOAD_RAW
|
---|
1037 | eventNum+=eventStep;
|
---|
1038 | #else
|
---|
1039 | if (inputFile == NULL)
|
---|
1040 | return;
|
---|
1041 | inputFile->GetRow(rowNum);
|
---|
1042 | // cout << "Getting row " << rowNum << endl;
|
---|
1043 | for (int i=0;i<(1440+160)*nRoi;i++)
|
---|
1044 | eventData[i] = (float)rawEventData[i];
|
---|
1045 | #endif
|
---|
1046 |
|
---|
1047 | // if (drawCalibrationLoaded && calibrationLoaded)
|
---|
1048 | // {
|
---|
1049 |
|
---|
1050 | // if (calibratedCheckBox->isChecked())
|
---|
1051 | DataCalib::Apply(eventData, rawEventData, startPix, nRoi);
|
---|
1052 | CalibData::RemoveSpikes(eventData, nRoi);
|
---|
1053 |
|
---|
1054 | vector<float> pixelStatsData(1440*4);
|
---|
1055 | CalibData::GetPixelStats(pixelStatsData.data(), eventData, nRoi);
|
---|
1056 |
|
---|
1057 |
|
---|
1058 | for (vector<PixelMapEntry>::const_iterator it=fPixelMap.begin(); it!=fPixelMap.end(); it++)
|
---|
1059 | {
|
---|
1060 | RMSvalues[it->index] = pixelStatsData[1*1440+it->hw()];
|
---|
1061 | }
|
---|
1062 |
|
---|
1063 | /*
|
---|
1064 |
|
---|
1065 | for (int i=0;i<1440;i++)
|
---|
1066 | for (int j=0;j<nRoi;j++)
|
---|
1067 | {
|
---|
1068 | int realj = (j+startPix[i])%1024;
|
---|
1069 | eventData[i*1024+j] *= 2000.f/4096.f;
|
---|
1070 | eventData[i*1024+j] -= (baseLineMean[i*1024+realj]+triggerOffsetMean[i*1024+j]);
|
---|
1071 | eventData[i*1024+j] /= gainMean[i*1024+realj];
|
---|
1072 | eventData[i*1024+j] *= (50000.f/65536.f) * 2500.f;
|
---|
1073 | }
|
---|
1074 | }
|
---|
1075 | */
|
---|
1076 | if (isVisible())
|
---|
1077 | updateGL();
|
---|
1078 | emit signalCurrentEvent(eventNum);
|
---|
1079 | emit signalCurrentPixel(selectedPixel);
|
---|
1080 | }
|
---|
1081 | /************************************************************
|
---|
1082 | * NEXT SLICE. deprec ?
|
---|
1083 | ************************************************************/
|
---|
1084 | void RawDataViewer::nextSlice()
|
---|
1085 | {
|
---|
1086 | whichSlice++;
|
---|
1087 | if (whichSlice >= nRoi)
|
---|
1088 | {
|
---|
1089 | whichSlice = 0;
|
---|
1090 | if (!loopCurrentEvent)
|
---|
1091 | {
|
---|
1092 | int backupStep = eventStep;
|
---|
1093 | eventStep = 1;
|
---|
1094 | eventStepping(true);
|
---|
1095 | eventStep = backupStep;
|
---|
1096 | }
|
---|
1097 | }
|
---|
1098 | emit signalCurrentSlice(whichSlice);
|
---|
1099 | updateGL();
|
---|
1100 | }
|
---|
1101 | void RawDataViewer::previousSlice()
|
---|
1102 | {
|
---|
1103 | whichSlice--;
|
---|
1104 | if (whichSlice < 0)
|
---|
1105 | {
|
---|
1106 | whichSlice = nRoi-1;
|
---|
1107 | if (!loopCurrentEvent)
|
---|
1108 | {
|
---|
1109 | int backupStep = eventStep;
|
---|
1110 | eventStep = 1;
|
---|
1111 | eventStepping(false);
|
---|
1112 | eventStep = backupStep;
|
---|
1113 | }
|
---|
1114 | }
|
---|
1115 | emit signalCurrentSlice(whichSlice);
|
---|
1116 | updateGL();
|
---|
1117 | }
|
---|
1118 | void RawDataViewer::setCurrentPixel(int pix)
|
---|
1119 | {
|
---|
1120 | if (pix == -1)
|
---|
1121 | return;
|
---|
1122 | selectedPixel = pix;
|
---|
1123 | if (isVisible())
|
---|
1124 | updateGL();
|
---|
1125 | emit signalCurrentPixel(pix);
|
---|
1126 | }
|
---|
1127 | void RawDataViewer::computePulsesStatistics()
|
---|
1128 | {
|
---|
1129 | if (!inputFile)
|
---|
1130 | {
|
---|
1131 | cout << "A FITS file must be open in order to complete this operation" << endl;
|
---|
1132 | return;
|
---|
1133 | }
|
---|
1134 |
|
---|
1135 |
|
---|
1136 | // for (int i=0;i<nRows;i++)//for all events
|
---|
1137 | // {
|
---|
1138 | // inputFile->GetRow(rowNum);
|
---|
1139 | // for (int i=0;i<(1440+160)*nRoi;i++)
|
---|
1140 | // eventData[i] = (float)rawEventData[i];
|
---|
1141 |
|
---|
1142 | // for (int j=0;j<ACTUAL_NUM_PIXELS;j++)
|
---|
1143 | /// {
|
---|
1144 | int j = selectedPixel;
|
---|
1145 | for (int i=0;i<nRoi;i++)
|
---|
1146 | {
|
---|
1147 | aMeas[i] = eventData[j*nRoi+i];// * adcCount;
|
---|
1148 |
|
---|
1149 | }
|
---|
1150 | for (int i=0;i<nRoi;i++)
|
---|
1151 | {
|
---|
1152 | if (i==0)
|
---|
1153 | n1mean[i] = aMeas[i+1];
|
---|
1154 | else
|
---|
1155 | {
|
---|
1156 | if (i==1023)
|
---|
1157 | n1mean[i] = aMeas[i-1];
|
---|
1158 | else
|
---|
1159 | n1mean[i] = (aMeas[i-1]+aMeas[i+1])/2.f;
|
---|
1160 | }
|
---|
1161 | }
|
---|
1162 | //find spike
|
---|
1163 | for (int i=0;i<nRoi-3;i++)
|
---|
1164 | {
|
---|
1165 | const float fract = 0.8f;
|
---|
1166 | float xx, xp, xpp;
|
---|
1167 | vCorr[i] = 0;//aMeas[i];
|
---|
1168 | xx = aMeas[i] - n1mean[i];
|
---|
1169 | if (xx < -8.f)
|
---|
1170 | {
|
---|
1171 | xp = aMeas[i+1] - n1mean[i+1];
|
---|
1172 | xpp = aMeas[i+2] - n1mean[i+2];
|
---|
1173 | if ((aMeas[i+2] - (aMeas[i] + aMeas[i+3])/2.f) > 10.f)
|
---|
1174 | {
|
---|
1175 | vCorr[i+1] = (aMeas[i] + aMeas[i+3])/2.f;
|
---|
1176 | vCorr[i+2] = (aMeas[i] + aMeas[i+3])/2.f;
|
---|
1177 | i = i+2;
|
---|
1178 | }
|
---|
1179 | else
|
---|
1180 | {
|
---|
1181 | if ((xp > -2.*xx*fract) && (xpp < -10.f))
|
---|
1182 | {
|
---|
1183 | vCorr[i+1] = n1mean[i+1];
|
---|
1184 | n1mean[i+2] = aMeas[i+1] - aMeas[i+3]/2.f;
|
---|
1185 | i++;
|
---|
1186 | }
|
---|
1187 | }
|
---|
1188 | }
|
---|
1189 | }
|
---|
1190 | for (int i=0;i<nRoi;i++)
|
---|
1191 | n1mean[i] = aMeas[i]-n1mean[i];
|
---|
1192 | // }
|
---|
1193 | // }
|
---|
1194 | }
|
---|
1195 | /************************************************************
|
---|
1196 | * UICONNECTOR CONSTRUCTOR
|
---|
1197 | ************************************************************/
|
---|
1198 | UIConnector::UIConnector(QWidget *p)
|
---|
1199 | {
|
---|
1200 | setupUi(this);
|
---|
1201 | initHistograms();
|
---|
1202 |
|
---|
1203 | currentFile = "none";
|
---|
1204 | currentCalibFile = "none";
|
---|
1205 |
|
---|
1206 | updateSpinnerDisplay = true;
|
---|
1207 | updating = false;
|
---|
1208 |
|
---|
1209 | timer.setInterval(10.0);
|
---|
1210 | QObject::connect(&timer, SIGNAL(timeout()),
|
---|
1211 | this, SLOT(nextSlicePlease()));
|
---|
1212 |
|
---|
1213 | QButtonGroup &scaleGroup = *new QButtonGroup(p);// = new QButtonGroup(canvas);
|
---|
1214 | QButtonGroup &animateGroup = *new QButtonGroup(p);// = new QButtonGroup(canvas);
|
---|
1215 |
|
---|
1216 | scaleGroup.addButton(currentPixelScale);
|
---|
1217 | scaleGroup.addButton(entireCameraScale);
|
---|
1218 |
|
---|
1219 | animateGroup.addButton(playEventsRadio);
|
---|
1220 | animateGroup.addButton(playSlicesRadio);
|
---|
1221 |
|
---|
1222 | entireCameraScale->setChecked(true);
|
---|
1223 |
|
---|
1224 | GLWindow_2->enableText(false);
|
---|
1225 | // GLWindow_2->ShowPatchCursor(true);
|
---|
1226 |
|
---|
1227 | QObject::connect(GLWindow, SIGNAL(colorPaletteHasChanged()),
|
---|
1228 | this, SLOT(on_autoScaleColor_clicked()));
|
---|
1229 | QObject::connect(GLWindow, SIGNAL(signalCurrentSlice(int)),
|
---|
1230 | this, SLOT(currentSliceHasChanged(int)));
|
---|
1231 | QObject::connect(GLWindow, SIGNAL(signalCurrentEvent(int)),
|
---|
1232 | this, SLOT(currentEventHasChanged(int)));
|
---|
1233 | QObject::connect(GLWindow, SIGNAL(signalCurrentPixel(int)),
|
---|
1234 | this, SLOT(pixelChanged(int)));
|
---|
1235 | QObject::connect(GLWindow, SIGNAL(newFileLoaded()),
|
---|
1236 | this, SLOT(newFileLoaded()));
|
---|
1237 |
|
---|
1238 | QObject::connect(GLWindow_2, SIGNAL(signalCurrentPixel(int)),
|
---|
1239 | GLWindow, SLOT(setCurrentPixel(int)));
|
---|
1240 |
|
---|
1241 |
|
---|
1242 | show();
|
---|
1243 | }
|
---|
1244 |
|
---|
1245 | void UIConnector::slicesPlusPlus()
|
---|
1246 | {
|
---|
1247 | GLWindow->nextSlice();
|
---|
1248 | }
|
---|
1249 | void UIConnector::slicesMinusMinus()
|
---|
1250 | {
|
---|
1251 | GLWindow->previousSlice();
|
---|
1252 | }
|
---|
1253 | void UIConnector::on_calibratedCheckBox_stateChanged(int state)
|
---|
1254 | {
|
---|
1255 | for (int i=0;i<(1440+160)*GLWindow->nRoi;i++)
|
---|
1256 | GLWindow->eventData[i] = (float)GLWindow->rawEventData[i];
|
---|
1257 |
|
---|
1258 | // if (GLWindow->calibratedCheckBox->isChecked())
|
---|
1259 | if (state)
|
---|
1260 | {
|
---|
1261 | DataCalib::Apply(GLWindow->eventData, GLWindow->rawEventData, GLWindow->startPix, GLWindow->nRoi);
|
---|
1262 | CalibData::RemoveSpikes(GLWindow->eventData, GLWindow->nRoi);
|
---|
1263 | }
|
---|
1264 |
|
---|
1265 | GLWindow->updateGL();
|
---|
1266 |
|
---|
1267 | //drawCalibrationCheckBox->setChecked(false);
|
---|
1268 |
|
---|
1269 | on_autoScaleColor_clicked();
|
---|
1270 | pixelChanged(GLWindow->selectedPixel);
|
---|
1271 |
|
---|
1272 | }
|
---|
1273 | /************************************************************
|
---|
1274 | * DRAW PATCHES CHECK CHANGE. checkbox handler
|
---|
1275 | ************************************************************/
|
---|
1276 | void UIConnector::on_drawPatchCheckBox_stateChanged(int state)
|
---|
1277 | {
|
---|
1278 | GLWindow->drawPatch = state;
|
---|
1279 | GLWindow->updateGL();
|
---|
1280 | }
|
---|
1281 | /************************************************************
|
---|
1282 | * DRAW IMPULSE CHECK CHANGE. checkbox handler
|
---|
1283 | ************************************************************/
|
---|
1284 | void UIConnector::on_drawImpulseCheckBox_stateChanged(int state)
|
---|
1285 | {
|
---|
1286 | GLWindow->drawImpulse = state;
|
---|
1287 | GLWindow->updateGL();
|
---|
1288 | }
|
---|
1289 | /************************************************************
|
---|
1290 | * DRAW BLUR CHECK CHANGE. checkbox handler
|
---|
1291 | ************************************************************/
|
---|
1292 | void UIConnector::on_drawBlurCheckBox_stateChanged(int state)
|
---|
1293 | {
|
---|
1294 | GLWindow->drawBlur = state;
|
---|
1295 | GLWindow->updateGL();
|
---|
1296 | }
|
---|
1297 | void UIConnector::on_loopOverCurrentEventBox_stateChanged(int state)
|
---|
1298 | {
|
---|
1299 | GLWindow->loopCurrentEvent = state;
|
---|
1300 | }
|
---|
1301 |
|
---|
1302 | /************************************************************
|
---|
1303 | * NEXT SLICE PLEASE
|
---|
1304 | ************************************************************/
|
---|
1305 | void UIConnector::nextSlicePlease()
|
---|
1306 | {
|
---|
1307 | if (playEventsRadio->isChecked ())
|
---|
1308 | GLWindow->eventStepping(true);
|
---|
1309 | else
|
---|
1310 | GLWindow->nextSlice();
|
---|
1311 | }
|
---|
1312 |
|
---|
1313 | /************************************************************
|
---|
1314 | * SET VIEWER.
|
---|
1315 | ************************************************************/
|
---|
1316 | //void UIConnector::setViewer(RawDataViewer* v)
|
---|
1317 | //{
|
---|
1318 | // viewer = v;
|
---|
1319 | //}
|
---|
1320 | /************************************************************
|
---|
1321 | * SLICES PER SECOND CHANGED. timing ui handler
|
---|
1322 | ************************************************************/
|
---|
1323 | void UIConnector::slicesPerSecondChanged(double value)
|
---|
1324 | {
|
---|
1325 | timer.setInterval(1000.0/value);
|
---|
1326 | }
|
---|
1327 |
|
---|
1328 | void UIConnector::on_colorRange0_valueChanged(double value) { GLWindow->ss[0] = (float)value; GLWindow->updateGL(); }
|
---|
1329 | void UIConnector::on_colorRange1_valueChanged(double value) { GLWindow->ss[1] = (float)value; GLWindow->updateGL(); }
|
---|
1330 | void UIConnector::on_colorRange2_valueChanged(double value) { GLWindow->ss[2] = (float)value; GLWindow->updateGL(); }
|
---|
1331 | void UIConnector::on_colorRange3_valueChanged(double value) { GLWindow->ss[3] = (float)value; GLWindow->updateGL(); }
|
---|
1332 | void UIConnector::on_colorRange4_valueChanged(double value) { GLWindow->ss[4] = (float)value; GLWindow->updateGL(); }
|
---|
1333 |
|
---|
1334 | void UIConnector::on_redValue0_valueChanged(double value) { GLWindow->rr[0] = (float)value; GLWindow->updateGL(); }
|
---|
1335 | void UIConnector::on_redValue1_valueChanged(double value) { GLWindow->rr[1] = (float)value; GLWindow->updateGL(); }
|
---|
1336 | void UIConnector::on_redValue2_valueChanged(double value) { GLWindow->rr[2] = (float)value; GLWindow->updateGL(); }
|
---|
1337 | void UIConnector::on_redValue3_valueChanged(double value) { GLWindow->rr[3] = (float)value; GLWindow->updateGL(); }
|
---|
1338 | void UIConnector::on_redValue4_valueChanged(double value) { GLWindow->rr[4] = (float)value; GLWindow->updateGL(); }
|
---|
1339 |
|
---|
1340 | void UIConnector::on_greenValue0_valueChanged(double value) { GLWindow->gg[0] = (float)value; GLWindow->updateGL(); }
|
---|
1341 | void UIConnector::on_greenValue1_valueChanged(double value) { GLWindow->gg[1] = (float)value; GLWindow->updateGL(); }
|
---|
1342 | void UIConnector::on_greenValue2_valueChanged(double value) { GLWindow->gg[2] = (float)value; GLWindow->updateGL(); }
|
---|
1343 | void UIConnector::on_greenValue3_valueChanged(double value) { GLWindow->gg[3] = (float)value; GLWindow->updateGL(); }
|
---|
1344 | void UIConnector::on_greenValue4_valueChanged(double value) { GLWindow->gg[4] = (float)value; GLWindow->updateGL(); }
|
---|
1345 |
|
---|
1346 | void UIConnector::on_blueValue0_valueChanged(double value) { GLWindow->bb[0] = (float)value; GLWindow->updateGL(); }
|
---|
1347 | void UIConnector::on_blueValue1_valueChanged(double value) { GLWindow->bb[1] = (float)value; GLWindow->updateGL(); }
|
---|
1348 | void UIConnector::on_blueValue2_valueChanged(double value) { GLWindow->bb[2] = (float)value; GLWindow->updateGL(); }
|
---|
1349 | void UIConnector::on_blueValue3_valueChanged(double value) { GLWindow->bb[3] = (float)value; GLWindow->updateGL(); }
|
---|
1350 | void UIConnector::on_blueValue4_valueChanged(double value) { GLWindow->bb[4] = (float)value; GLWindow->updateGL(); }
|
---|
1351 |
|
---|
1352 | /************************************************************
|
---|
1353 | * LOAD NEW FILE CLICKED. button handler
|
---|
1354 | ************************************************************/
|
---|
1355 | void UIConnector::on_loadNewFileButton_clicked()
|
---|
1356 | {
|
---|
1357 | QFileDialog dialog;
|
---|
1358 | dialog.setFileMode(QFileDialog::ExistingFile);
|
---|
1359 | dialog.open(this, SLOT(fileSelected(QString)));
|
---|
1360 | dialog.setVisible(true);
|
---|
1361 | dialog.exec();
|
---|
1362 | }
|
---|
1363 | void UIConnector::on_loadDRSCalibButton_clicked()
|
---|
1364 | {
|
---|
1365 | QFileDialog dialog;
|
---|
1366 | dialog.setFileMode(QFileDialog::ExistingFile);
|
---|
1367 | dialog.open(this, SLOT(calibFileSelected(QString)));
|
---|
1368 | dialog.setVisible(true);
|
---|
1369 | dialog.exec();
|
---|
1370 | }
|
---|
1371 | /************************************************************
|
---|
1372 | * FILE SELECTED. return of the file open dialog handler
|
---|
1373 | ************************************************************/
|
---|
1374 | void UIConnector::fileSelected(QString file)
|
---|
1375 | {
|
---|
1376 | currentFile = file.toStdString();
|
---|
1377 | if (currentFile != "")
|
---|
1378 | GLWindow->openFile(currentFile);
|
---|
1379 | }
|
---|
1380 | void UIConnector::calibFileSelected(QString file)
|
---|
1381 | {
|
---|
1382 | currentCalibFile = file.toStdString();
|
---|
1383 | if (currentCalibFile != "")
|
---|
1384 | GLWindow->openCalibFile(currentCalibFile);
|
---|
1385 | }
|
---|
1386 | /************************************************************
|
---|
1387 | * NEW FILE LOADED. update of the UI after a new file has been loaded
|
---|
1388 | ************************************************************/
|
---|
1389 | void UIConnector::newFileLoaded()
|
---|
1390 | {
|
---|
1391 | ostringstream str;
|
---|
1392 |
|
---|
1393 | //extract the file name only (no path) from the full name
|
---|
1394 | str << "File: " << currentFile.substr(currentFile.find_last_of("//")+1, currentFile.size()) << "\n";
|
---|
1395 | str << "Calibration: " << currentCalibFile.substr(currentCalibFile.find_last_of("//")+1, currentCalibFile.size()) << "\n";
|
---|
1396 | // fileLoadedLabel->setText(QString(str.str().c_str()));
|
---|
1397 | // str.str("");
|
---|
1398 | str << "Run number: " << GLWindow->runNumber << "\n";
|
---|
1399 | // runNumberLabel->setText(QString(str.str().c_str()));
|
---|
1400 | // str.str("");
|
---|
1401 | str << "Number of Events: " << GLWindow->nRows << "\n";
|
---|
1402 |
|
---|
1403 | displayingEventBox->setMaximum(GLWindow->nRows-1);
|
---|
1404 |
|
---|
1405 | str << "Number of Slices: " << GLWindow->nRoi << "\n";// << "/1024";
|
---|
1406 | // numberOfSlicesLabel->setText(QString(str.str().c_str()));
|
---|
1407 | // str.str("");
|
---|
1408 | str << "Number of Time Marks: " << GLWindow->nTM << "\n";
|
---|
1409 | // numberOfTimeMarksLabel->setText(QString(str.str().c_str()));
|
---|
1410 |
|
---|
1411 | // str.str("");
|
---|
1412 | str << "Run Type: " << GLWindow->runType << "\n";
|
---|
1413 | // runTypeLabel->setText(QString(str.str().c_str()));
|
---|
1414 | // str.str("");
|
---|
1415 | str << "Time of 1st data: " << GLWindow->firstDataTime << "\n";
|
---|
1416 | // firstTimeLabel->setText(QString(str.str().c_str()));
|
---|
1417 | // str.str("");
|
---|
1418 | str << "Time of last data: " << GLWindow->lastDataTime << "\n";
|
---|
1419 | // lastTimeLabel->setText(QString(str.str().c_str()));
|
---|
1420 | // str.str("");
|
---|
1421 | str << "SVN revision: " << GLWindow->revision << '\n';
|
---|
1422 | str << "Number of boards: " << GLWindow->nBoards << '\n';
|
---|
1423 | str << "Number of pixels: " << GLWindow->nPixels << '\n';
|
---|
1424 | str << "Number of Slices TM: " << GLWindow->nRoiTM << '\n';
|
---|
1425 | str << "Time system: " << GLWindow->timeSystem << '\n';
|
---|
1426 | str << "Date: " << GLWindow->creationDate << '\n';
|
---|
1427 | str << "Night: " << GLWindow->nightInt << '\n';
|
---|
1428 | str << "Camera: " << GLWindow->camera << '\n';
|
---|
1429 | str << "DAQ: " << GLWindow->daq << '\n';
|
---|
1430 | str << "ADC Count: " << GLWindow->adcCount << '\n';
|
---|
1431 | str << "NB Evts OK:" << GLWindow->nbOk << '\n';
|
---|
1432 | str << "NB Evts Rejected: " << GLWindow->nbRej << '\n';
|
---|
1433 | str << "NB Evts Bad: " << GLWindow->nbBad << '\n';
|
---|
1434 | extraInfoLabel->setText(QString(str.str().c_str()));
|
---|
1435 |
|
---|
1436 | /*
|
---|
1437 | if (GLWindow->calibrationLoaded)
|
---|
1438 | {
|
---|
1439 | drawCalibrationCheckBox->setEnabled(true);
|
---|
1440 | }*/
|
---|
1441 |
|
---|
1442 |
|
---|
1443 | }
|
---|
1444 | /************************************************************
|
---|
1445 | * PLAY PAUSE CLICKED. ui handler
|
---|
1446 | ************************************************************/
|
---|
1447 | void UIConnector::on_playPauseButton_clicked()
|
---|
1448 | {
|
---|
1449 | if (timer.isActive())
|
---|
1450 | timer.stop();
|
---|
1451 | else
|
---|
1452 | timer.start();
|
---|
1453 | }
|
---|
1454 |
|
---|
1455 | void UIConnector::displaySliceValue()
|
---|
1456 | {
|
---|
1457 | if (!GLWindow->nRoi)
|
---|
1458 | return;
|
---|
1459 |
|
---|
1460 | const int idx =
|
---|
1461 | GLWindow->nRoi*GLWindow->hardwareMapping[GLWindow->selectedPixel]
|
---|
1462 | + GLWindow->whichSlice;
|
---|
1463 |
|
---|
1464 | ostringstream str;
|
---|
1465 | str << "Current Pixel val.: " << GLWindow->eventData[idx];
|
---|
1466 | currentPixelValue->setText(QString(str.str().c_str()));
|
---|
1467 | }
|
---|
1468 |
|
---|
1469 | /************************************************************
|
---|
1470 | * CURRENT SLICE HAS CHANGE. ui handler
|
---|
1471 | ************************************************************/
|
---|
1472 | void UIConnector::currentSliceHasChanged(int slice)
|
---|
1473 | {
|
---|
1474 | if (!GLWindow->nRoi)
|
---|
1475 | return;
|
---|
1476 |
|
---|
1477 | if (updateSpinnerDisplay)
|
---|
1478 | displayingSliceBox->setValue(slice);
|
---|
1479 |
|
---|
1480 | displaySliceValue();
|
---|
1481 | }
|
---|
1482 |
|
---|
1483 | /*****
|
---|
1484 | *******************************************************
|
---|
1485 | * CURRENT EVENT HAS CHANGED. ui handler
|
---|
1486 | ************************************************************/
|
---|
1487 |
|
---|
1488 | double xval[50000];
|
---|
1489 | double yval[50000];
|
---|
1490 | void UIConnector::on_displayingEventBox_valueChanged(int cEvent)
|
---|
1491 | {
|
---|
1492 | // cout << "Here " << updateSpinnerDisplay << endl;
|
---|
1493 | if (!updateSpinnerDisplay)
|
---|
1494 | return;
|
---|
1495 | updateSpinnerDisplay = false;
|
---|
1496 | // currentEventHasChanged(cEvent);
|
---|
1497 | GLWindow->rowNum = cEvent - GLWindow->eventStep;
|
---|
1498 | GLWindow->eventStepping(true);
|
---|
1499 | updateSpinnerDisplay = true;
|
---|
1500 |
|
---|
1501 | // GLWindow->updateGL();
|
---|
1502 | }
|
---|
1503 | void UIConnector::on_displayingSliceBox_valueChanged(int cSlice)
|
---|
1504 | {
|
---|
1505 | updateSpinnerDisplay = false;
|
---|
1506 | currentSliceHasChanged(cSlice);
|
---|
1507 | updateSpinnerDisplay = true;
|
---|
1508 | GLWindow->whichSlice = cSlice;
|
---|
1509 | GLWindow->updateGL();
|
---|
1510 | }
|
---|
1511 | void UIConnector::currentEventHasChanged(int )
|
---|
1512 | {
|
---|
1513 |
|
---|
1514 | GLWindow_2->SetData(GLWindow->RMSvalues);
|
---|
1515 | if (GLWindow_2->isVisible())
|
---|
1516 | GLWindow_2->updateGL();
|
---|
1517 | ostringstream str;
|
---|
1518 | // str << "Displaying Event " << cEvent;
|
---|
1519 | // QString qstr(str.str().c_str());
|
---|
1520 | // emit updateCurrentEventDisplay(qstr);
|
---|
1521 | if (updateSpinnerDisplay)
|
---|
1522 | {
|
---|
1523 | updateSpinnerDisplay = false;
|
---|
1524 | displayingEventBox->setValue(GLWindow->rowNum);
|
---|
1525 | updateSpinnerDisplay = true;
|
---|
1526 | }
|
---|
1527 |
|
---|
1528 | // GLWindow->doWaveLetOnCurrentEventPlease();
|
---|
1529 |
|
---|
1530 | //retrieve the data that we want to display
|
---|
1531 | boost::posix_time::ptime hrTime( boost::gregorian::date(1970, boost::gregorian::Jan, 1),
|
---|
1532 | boost::posix_time::seconds(GLWindow->pcTime[0]) + boost::posix_time::microsec(GLWindow->pcTime[1]));
|
---|
1533 |
|
---|
1534 | str.str("");
|
---|
1535 | str << "PC Time: " << boost::posix_time::to_iso_extended_string(hrTime);
|
---|
1536 | PCTimeLabel->setText(QString(str.str().c_str()));
|
---|
1537 |
|
---|
1538 | str.str("");
|
---|
1539 | str << "Software Trigger: " << GLWindow->softTrig;
|
---|
1540 | softwareTriggerLabel->setText(QString(str.str().c_str()));
|
---|
1541 |
|
---|
1542 | str.str("");
|
---|
1543 | str << "Trigger Type: " << GLWindow->triggerType;
|
---|
1544 | triggerTypeLabel->setText(QString(str.str().c_str()));
|
---|
1545 |
|
---|
1546 | displaySliceValue();
|
---|
1547 |
|
---|
1548 | if (autoScaleColor->isChecked())
|
---|
1549 | emit GLWindow->colorPaletteHasChanged();//autoScalePressed();
|
---|
1550 |
|
---|
1551 | boardsTimeList->clear();
|
---|
1552 | startPixelsList->clear();
|
---|
1553 | startTimeMarksList->clear();
|
---|
1554 | triggerDelayList->clear();
|
---|
1555 | std::map<int, int> boardsHistoMap;
|
---|
1556 | for (int i=0;i <NBOARDS; i++)
|
---|
1557 | {
|
---|
1558 | str.str("");
|
---|
1559 | str << i;
|
---|
1560 | if (i<10) str << " ";
|
---|
1561 | if (i<100) str << " ";
|
---|
1562 | if (i<1000) str << " ";
|
---|
1563 | str << ": " << GLWindow->boardTime[i];
|
---|
1564 | boardsTimeList->addItem(QString(str.str().c_str()));
|
---|
1565 | if (boardsHistoMap.find(GLWindow->boardTime[i]) != boardsHistoMap.end())
|
---|
1566 | boardsHistoMap[GLWindow->boardTime[i]]++;
|
---|
1567 | else
|
---|
1568 | boardsHistoMap[GLWindow->boardTime[i]] = 1;
|
---|
1569 | }
|
---|
1570 | std::map<int, int> pixelHistoMap;
|
---|
1571 | for (int i=0;i <NPIX; i++)
|
---|
1572 | {
|
---|
1573 | str.str("");
|
---|
1574 | str << i;
|
---|
1575 | if (i<10) str << " ";
|
---|
1576 | if (i<100) str << " ";
|
---|
1577 | if (i<1000) str << " ";
|
---|
1578 | str << ": " << GLWindow->startPix[i];
|
---|
1579 | startPixelsList->addItem(QString(str.str().c_str()));
|
---|
1580 | if (pixelHistoMap.find(GLWindow->startPix[i]) != pixelHistoMap.end())
|
---|
1581 | pixelHistoMap[GLWindow->startPix[i]]++;
|
---|
1582 | else
|
---|
1583 | pixelHistoMap[GLWindow->startPix[i]] = 1;
|
---|
1584 | }
|
---|
1585 |
|
---|
1586 | std::map<int, int> timeMarksMap;
|
---|
1587 | for (int i=0;i <NTMARK; i++)
|
---|
1588 | {
|
---|
1589 | str.str("");
|
---|
1590 | str << i;
|
---|
1591 | if (i<10) str << " ";
|
---|
1592 | if (i<100) str << " ";
|
---|
1593 | if (i<1000) str << " ";
|
---|
1594 | str << ": " << GLWindow->startTM[i];
|
---|
1595 | startTimeMarksList->addItem(QString(str.str().c_str()));
|
---|
1596 | if (timeMarksMap.find(GLWindow->startTM[i]) != timeMarksMap.end())
|
---|
1597 | timeMarksMap[GLWindow->startTM[i]]++;
|
---|
1598 | else
|
---|
1599 | timeMarksMap[GLWindow->startTM[i]] = 1;
|
---|
1600 | }
|
---|
1601 | std::map<int,int> delayMap;
|
---|
1602 | triggerDelayList->addItem(QString("Patch | Slice:Delay Slice:Delay..."));
|
---|
1603 | for (int i=0;i<NTMARK; i++)
|
---|
1604 | {
|
---|
1605 | str.str("");
|
---|
1606 | str << i << " | ";
|
---|
1607 | for (int j=0;j<GLWindow->nRoi;j++)
|
---|
1608 | {
|
---|
1609 | int value = GLWindow->eventData[1440*GLWindow->nRoi + i*GLWindow->nRoi + j];
|
---|
1610 | if (delayMap.find(value) != delayMap.end())
|
---|
1611 | delayMap[value]++;
|
---|
1612 | else
|
---|
1613 | delayMap[value] = 1;
|
---|
1614 | str << j << ":" << value << " ";
|
---|
1615 | }
|
---|
1616 | triggerDelayList->addItem(QString(str.str().c_str()));
|
---|
1617 | }
|
---|
1618 |
|
---|
1619 | std::map<int,int>::iterator it = boardsHistoMap.begin();
|
---|
1620 | int nsamples = 0;
|
---|
1621 | int previousValue = it->first-10;
|
---|
1622 | for (unsigned int i=0;i<boardsHistoMap.size();i++)
|
---|
1623 | {
|
---|
1624 | if (previousValue != it->first-1)
|
---|
1625 | {
|
---|
1626 | xval[nsamples] = previousValue+1;
|
---|
1627 | yval[nsamples] = 0;
|
---|
1628 | nsamples++;
|
---|
1629 | xval[nsamples] = it->first-1;
|
---|
1630 | yval[nsamples] = 0;
|
---|
1631 | nsamples++;
|
---|
1632 | }
|
---|
1633 | xval[nsamples] = it->first;
|
---|
1634 | yval[nsamples] = it->second;
|
---|
1635 | previousValue = it->first;
|
---|
1636 | it++;
|
---|
1637 | nsamples++;
|
---|
1638 | xval[nsamples] = previousValue;
|
---|
1639 | yval[nsamples] = 0;
|
---|
1640 | nsamples++;
|
---|
1641 | if (nsamples > 4090)
|
---|
1642 | {
|
---|
1643 | cout << "Error: Maximum number of samples reached for histograms. skipping what's remaining" << endl;
|
---|
1644 | break;
|
---|
1645 | }
|
---|
1646 | }
|
---|
1647 | xval[nsamples] = it==boardsHistoMap.begin() ? 0 : (--it)->first+1;
|
---|
1648 | yval[nsamples] = 0;
|
---|
1649 | nsamples++;
|
---|
1650 | // if (nsamples > 5)
|
---|
1651 | #if QWT_VERSION < 0x060000
|
---|
1652 | boardsTimeHistoItem.setData(xval, yval, nsamples);
|
---|
1653 | #else
|
---|
1654 | boardsTimeHistoItem.setSamples(xval, yval, nsamples);
|
---|
1655 | #endif
|
---|
1656 |
|
---|
1657 | it = pixelHistoMap.begin();
|
---|
1658 | nsamples = 0;
|
---|
1659 | previousValue = it->first-10;
|
---|
1660 | for (unsigned int i=0;i<pixelHistoMap.size();i++)
|
---|
1661 | {
|
---|
1662 | if (previousValue != it->first-1)
|
---|
1663 | {
|
---|
1664 | xval[nsamples] = previousValue+1;
|
---|
1665 | yval[nsamples] = 0;
|
---|
1666 | nsamples++;
|
---|
1667 | xval[nsamples] = it->first-1;
|
---|
1668 | yval[nsamples] = 0;
|
---|
1669 | nsamples++;
|
---|
1670 | }
|
---|
1671 | xval[nsamples] = it->first;
|
---|
1672 | yval[nsamples] = it->second;
|
---|
1673 | previousValue = it->first;
|
---|
1674 | it++;
|
---|
1675 | nsamples++;
|
---|
1676 | xval[nsamples] = previousValue;
|
---|
1677 | yval[nsamples] = 0;
|
---|
1678 | nsamples++;
|
---|
1679 | if (nsamples > 4090)
|
---|
1680 | {
|
---|
1681 | cout << "Error: Maximum number of samples reached for histograms. skipping what's remaining" << endl;
|
---|
1682 | break;
|
---|
1683 | }
|
---|
1684 | }
|
---|
1685 | xval[nsamples] = it==pixelHistoMap.begin() ? 0 : (--it)->first+1;
|
---|
1686 | yval[nsamples] = 0;
|
---|
1687 | nsamples++;
|
---|
1688 | // if (nsamples > 5)
|
---|
1689 | #if QWT_VERSION < 0x060000
|
---|
1690 | startCellHistoItem.setData(xval, yval, nsamples);
|
---|
1691 | #else
|
---|
1692 | startCellHistoItem.setSamples(xval, yval, nsamples);
|
---|
1693 | #endif
|
---|
1694 |
|
---|
1695 | it = timeMarksMap.begin();
|
---|
1696 | nsamples = 0;
|
---|
1697 | previousValue = it->first-10;
|
---|
1698 | for (unsigned int i=0;i<timeMarksMap.size();i++)
|
---|
1699 | {
|
---|
1700 | if (previousValue != it->first-1)
|
---|
1701 | {
|
---|
1702 | xval[nsamples] = previousValue+1;
|
---|
1703 | yval[nsamples] = 0;
|
---|
1704 | nsamples++;
|
---|
1705 | xval[nsamples] = it->first-1;
|
---|
1706 | yval[nsamples] = 0;
|
---|
1707 | nsamples++;
|
---|
1708 | }
|
---|
1709 | xval[nsamples] = it->first;
|
---|
1710 | yval[nsamples] = it->second;
|
---|
1711 | previousValue = it->first;
|
---|
1712 | it++;
|
---|
1713 | nsamples++;
|
---|
1714 | xval[nsamples] = previousValue;
|
---|
1715 | yval[nsamples] = 0;
|
---|
1716 | nsamples++;
|
---|
1717 | if (nsamples > 4090)
|
---|
1718 | {
|
---|
1719 | cout << "Error: Maximum number of samples reached for histograms. skipping what's remaining" << endl;
|
---|
1720 | break;
|
---|
1721 | }
|
---|
1722 | }
|
---|
1723 | xval[nsamples] = it==timeMarksMap.begin() ? 0 : (--it)->first+1;
|
---|
1724 | yval[nsamples] = 0;
|
---|
1725 | nsamples++;
|
---|
1726 | // if (nsamples > 5)
|
---|
1727 | #if QWT_VERSION < 0x060000
|
---|
1728 | startTimeMarkHistoItem.setData(xval, yval, nsamples);
|
---|
1729 | #else
|
---|
1730 | startTimeMarkHistoItem.setSamples(xval, yval, nsamples);
|
---|
1731 | #endif
|
---|
1732 |
|
---|
1733 | it = delayMap.begin();
|
---|
1734 | nsamples = 0;
|
---|
1735 | previousValue = it->first-10;
|
---|
1736 | for (unsigned int i=0;i<delayMap.size();i++)
|
---|
1737 | {
|
---|
1738 | if (previousValue != it->first-1)
|
---|
1739 | {
|
---|
1740 | xval[nsamples] = previousValue+1;
|
---|
1741 | yval[nsamples] = 0;
|
---|
1742 | nsamples++;
|
---|
1743 | xval[nsamples] = it->first-1;
|
---|
1744 | yval[nsamples] = 0;
|
---|
1745 | nsamples++;
|
---|
1746 | }
|
---|
1747 | xval[nsamples] = it->first;
|
---|
1748 | yval[nsamples] = it->second;
|
---|
1749 | previousValue = it->first;
|
---|
1750 | it++;
|
---|
1751 | nsamples++;
|
---|
1752 | xval[nsamples] = previousValue;
|
---|
1753 | yval[nsamples] = 0;
|
---|
1754 | nsamples++;
|
---|
1755 | if (nsamples > 4090)
|
---|
1756 | {
|
---|
1757 | cout << "Error: Maximum number of samples reached for histograms. skipping what's remaining" << endl;
|
---|
1758 | break;
|
---|
1759 | }
|
---|
1760 | }
|
---|
1761 | xval[nsamples] = it==delayMap.begin() ? 0 : (--it)->first+1;
|
---|
1762 | yval[nsamples] = 0;
|
---|
1763 | nsamples++;
|
---|
1764 | // if (nsamples > 5)
|
---|
1765 | #if QWT_VERSION < 0x060000
|
---|
1766 | triggerDelayHistoItem.setData(xval, yval, nsamples);
|
---|
1767 | #else
|
---|
1768 | triggerDelayHistoItem.setSamples(xval, yval, nsamples);
|
---|
1769 | #endif
|
---|
1770 | //WAVELETS HACK
|
---|
1771 | /* std::map<int, int> valuesHistoMap;
|
---|
1772 | std::map<int, int> waveletHistoMap;
|
---|
1773 | for (int i=0;i<1024*1440;i++)
|
---|
1774 | {
|
---|
1775 | if (valuesHistoMap.find(GLWindow->rawEventData[i]) != valuesHistoMap.end())
|
---|
1776 | valuesHistoMap[GLWindow->rawEventData[i]]++;
|
---|
1777 | else
|
---|
1778 | valuesHistoMap[GLWindow->rawEventData[i]] = 1;
|
---|
1779 | if (waveletHistoMap.find(GLWindow->waveLetArray[i]) != waveletHistoMap.end())
|
---|
1780 | waveletHistoMap[GLWindow->waveLetArray[i]]++;
|
---|
1781 | else
|
---|
1782 | waveletHistoMap[GLWindow->waveLetArray[i]] = 1;
|
---|
1783 | }
|
---|
1784 |
|
---|
1785 | it = valuesHistoMap.begin();
|
---|
1786 | nsamples = 0;
|
---|
1787 | previousValue = it->first-10;
|
---|
1788 | cout << "Num values Original: " << valuesHistoMap.size() << endl;
|
---|
1789 | for (unsigned int i=0;i<valuesHistoMap.size();i++)
|
---|
1790 | {
|
---|
1791 | if (previousValue != it->first-1)
|
---|
1792 | {
|
---|
1793 | xval[nsamples] = previousValue+1;
|
---|
1794 | yval[nsamples] = 0;
|
---|
1795 | nsamples++;
|
---|
1796 | xval[nsamples] = it->first-1;
|
---|
1797 | yval[nsamples] = 0;
|
---|
1798 | nsamples++;
|
---|
1799 | }
|
---|
1800 | xval[nsamples] = it->first;
|
---|
1801 | yval[nsamples] = it->second;
|
---|
1802 | previousValue = it->first;
|
---|
1803 | it++;
|
---|
1804 | nsamples++;
|
---|
1805 | xval[nsamples] = previousValue;
|
---|
1806 | yval[nsamples] = 0;
|
---|
1807 | nsamples++;
|
---|
1808 | if (nsamples > 50000)
|
---|
1809 | {
|
---|
1810 | cout << "Error: Maximum number of samples reached for histograms. skipping what's remaining" << endl;
|
---|
1811 | break;
|
---|
1812 | }
|
---|
1813 | }
|
---|
1814 | xval[nsamples] = it==valuesHistoMap.begin() ? 0 : (--it)->first+1;
|
---|
1815 | yval[nsamples] = 0;
|
---|
1816 | nsamples++;
|
---|
1817 | // if (nsamples > 5)
|
---|
1818 | #if QWT_VERSION < 0x060000
|
---|
1819 | triggerDelayHistoItem.setData(xval, yval, nsamples);
|
---|
1820 | #else
|
---|
1821 | triggerDelayHistoItem.setSamples(xval, yval, nsamples);
|
---|
1822 | #endif
|
---|
1823 |
|
---|
1824 | it = waveletHistoMap.begin();
|
---|
1825 | nsamples = 0;
|
---|
1826 | previousValue = it->first-10;
|
---|
1827 | cout << "Num values WaveLets: " << waveletHistoMap.size() << endl;
|
---|
1828 | for (unsigned int i=0;i<waveletHistoMap.size();i++)
|
---|
1829 | {
|
---|
1830 | if (previousValue != it->first-1)
|
---|
1831 | {
|
---|
1832 | xval[nsamples] = previousValue+1;
|
---|
1833 | yval[nsamples] = 0;
|
---|
1834 | nsamples++;
|
---|
1835 | xval[nsamples] = it->first-1;
|
---|
1836 | yval[nsamples] = 0;
|
---|
1837 | nsamples++;
|
---|
1838 | }
|
---|
1839 | xval[nsamples] = it->first;
|
---|
1840 | yval[nsamples] = it->second;
|
---|
1841 | previousValue = it->first;
|
---|
1842 | it++;
|
---|
1843 | nsamples++;
|
---|
1844 | xval[nsamples] = previousValue;
|
---|
1845 | yval[nsamples] = 0;
|
---|
1846 | nsamples++;
|
---|
1847 | if (nsamples > 50000)
|
---|
1848 | {
|
---|
1849 | cout << "Error: Maximum number of samples reached for histograms. skipping what's remaining" << endl;
|
---|
1850 | break;
|
---|
1851 | }
|
---|
1852 | }
|
---|
1853 | xval[nsamples] = it==waveletHistoMap.begin() ? 0 : (--it)->first+1;
|
---|
1854 | yval[nsamples] = 0;
|
---|
1855 | nsamples++;
|
---|
1856 | // if (nsamples > 5)
|
---|
1857 | #if QWT_VERSION < 0x060000
|
---|
1858 | startTimeMarkHistoItem.setData(xval, yval, nsamples);
|
---|
1859 | #else
|
---|
1860 | startTimeMarkHistoItem.setSamples(xval, yval, nsamples);
|
---|
1861 | #endif
|
---|
1862 | */
|
---|
1863 | //END OF WAVELETS HACK
|
---|
1864 | // startCellHistoZoom->setZoomBase(startCellHistoItem.boundingRect());
|
---|
1865 | QStack< QRectF > stack;
|
---|
1866 | // QRectF cRectangle = boardsTimeHistoItem.boundingRect();
|
---|
1867 | stack.push(scaleBoundingRectangle(boardsTimeHistoItem.boundingRect(), 1.05f));//cRectangle);//boardsTimeHistoItem.boundingRect());
|
---|
1868 | boardsTimeHistoZoom->setZoomStack(stack);
|
---|
1869 | stack.pop();
|
---|
1870 | stack.push(scaleBoundingRectangle(startCellHistoItem.boundingRect(), 1.05f));
|
---|
1871 | startCellHistoZoom->setZoomStack(stack);
|
---|
1872 | stack.pop();
|
---|
1873 | stack.push(scaleBoundingRectangle(startTimeMarkHistoItem.boundingRect(), 1.05f));
|
---|
1874 | startTimeMarkHistoZoom->setZoomStack(stack);
|
---|
1875 | stack.pop();
|
---|
1876 | stack.push(scaleBoundingRectangle(triggerDelayHistoItem.boundingRect(), 1.05f));
|
---|
1877 | triggerDelayHistoZoom->setZoomStack(stack);
|
---|
1878 | stack.pop();
|
---|
1879 |
|
---|
1880 | pixelChanged(GLWindow->selectedPixel);
|
---|
1881 | }
|
---|
1882 | //can't use a ref to rectangle, as the type must be converted first
|
---|
1883 | QRectF UIConnector::scaleBoundingRectangle(QRectF rectangle, float scale)
|
---|
1884 | {
|
---|
1885 | QPointF bottomRight = rectangle.bottomRight();
|
---|
1886 | QPointF topLeft = rectangle.topLeft();
|
---|
1887 | QPointF center = rectangle.center();
|
---|
1888 | return QRectF(topLeft + (topLeft-center)*(scale-1.0f), //top left
|
---|
1889 | bottomRight + (bottomRight-center)*(scale-1.0f)); //bottom right
|
---|
1890 | }
|
---|
1891 | void UIConnector::initHistograms()
|
---|
1892 | {
|
---|
1893 | // QwtPlot* boardsTimeHisto;
|
---|
1894 | // QwtPlotHistogram boardsTimeHistoItem;
|
---|
1895 | QwtPlotGrid* grid = new QwtPlotGrid;
|
---|
1896 | grid->enableX(false);
|
---|
1897 | grid->enableY(true);
|
---|
1898 | grid->enableXMin(false);
|
---|
1899 | grid->enableYMin(false);
|
---|
1900 | grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
|
---|
1901 | grid->attach(boardsTimeHisto);
|
---|
1902 |
|
---|
1903 | grid = new QwtPlotGrid;
|
---|
1904 | grid->enableX(false);
|
---|
1905 | grid->enableY(true);
|
---|
1906 | grid->enableXMin(false);
|
---|
1907 | grid->enableYMin(false);
|
---|
1908 | grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
|
---|
1909 | grid->attach(startCellsHisto);
|
---|
1910 |
|
---|
1911 | grid = new QwtPlotGrid;
|
---|
1912 | grid->enableX(false);
|
---|
1913 | grid->enableY(true);
|
---|
1914 | grid->enableXMin(false);
|
---|
1915 | grid->enableYMin(false);
|
---|
1916 | grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
|
---|
1917 | grid->attach(startTimeMarkHisto);
|
---|
1918 |
|
---|
1919 | grid = new QwtPlotGrid;
|
---|
1920 | grid->enableX(false);
|
---|
1921 | grid->enableY(true);
|
---|
1922 | grid->enableXMin(false);
|
---|
1923 | grid->enableYMin(false);
|
---|
1924 | grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
|
---|
1925 | grid->attach(pixelValueCurve);
|
---|
1926 |
|
---|
1927 | grid = new QwtPlotGrid;
|
---|
1928 | grid->enableX(false);
|
---|
1929 | grid->enableY(true);
|
---|
1930 | grid->enableXMin(false);
|
---|
1931 | grid->enableYMin(false);
|
---|
1932 | grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
|
---|
1933 | grid->attach(triggerDelayHisto);
|
---|
1934 |
|
---|
1935 | boardsTimeHisto->setAutoReplot(true);
|
---|
1936 | startCellsHisto->setAutoReplot(true);
|
---|
1937 | startTimeMarkHisto->setAutoReplot(true);
|
---|
1938 | pixelValueCurve->setAutoReplot(true);
|
---|
1939 | triggerDelayHisto->setAutoReplot(true);
|
---|
1940 | boardsTimeHisto->setTitle("Boards time values");
|
---|
1941 | startCellsHisto->setTitle("Start Cell values");
|
---|
1942 | startTimeMarkHisto->setTitle("Start Time Marks values");
|
---|
1943 | pixelValueCurve->setTitle("Current pixel values");
|
---|
1944 | triggerDelayHisto->setTitle("Trigger Delays");
|
---|
1945 |
|
---|
1946 | // boardsTimeHistoItem.setBrush(QBrush(Qt::red));
|
---|
1947 | // startCellHistoItem.setBrush(QBrush(Qt::red));
|
---|
1948 | // startTimeMarkHistoItem.setBrush(QBrush(Qt::red));
|
---|
1949 | // triggerDelayHistoItem.setBrush(QBrush(Qt::red));
|
---|
1950 | // pixelValueCurveItem.setBrush(QBrush(Qt::red));
|
---|
1951 |
|
---|
1952 | boardsTimeHistoItem.setPen(QColor(Qt::darkGreen));
|
---|
1953 | boardsTimeHistoItem.setStyle(QwtPlotCurve::Steps);
|
---|
1954 | startCellHistoItem.setPen(QColor(Qt::darkGreen));
|
---|
1955 | startCellHistoItem.setStyle(QwtPlotCurve::Steps);
|
---|
1956 | startTimeMarkHistoItem.setPen(QColor(Qt::darkGreen));
|
---|
1957 | startTimeMarkHistoItem.setStyle(QwtPlotCurve::Steps);
|
---|
1958 | triggerDelayHistoItem.setPen(QColor(Qt::darkGreen));
|
---|
1959 | triggerDelayHistoItem.setStyle(QwtPlotCurve::Steps);
|
---|
1960 |
|
---|
1961 | boardsTimeHistoItem.attach(boardsTimeHisto);
|
---|
1962 | startCellHistoItem.attach(startCellsHisto);
|
---|
1963 | startTimeMarkHistoItem.attach(startTimeMarkHisto);
|
---|
1964 | triggerDelayHistoItem.attach(triggerDelayHisto);
|
---|
1965 |
|
---|
1966 | //curve
|
---|
1967 | // pixelValueCurveItem.setSymbol(new QwtSymbol(QwtSymbol::Cross, Qt::NoBrush, QPen(Qt::black), QSize(5,5)));
|
---|
1968 | pixelValueCurveItem.setPen(QColor(Qt::black));
|
---|
1969 | aMeanCurveItem.setPen(QColor(Qt::darkGreen));
|
---|
1970 | vCorrCurveItem.setPen(QColor(Qt::red));
|
---|
1971 | meanCurveItem.setPen(QColor(Qt::blue));
|
---|
1972 | pixelValueCurveItem.setStyle(QwtPlotCurve::Lines);
|
---|
1973 | aMeanCurveItem.setStyle(QwtPlotCurve::Lines);
|
---|
1974 | vCorrCurveItem.setStyle(QwtPlotCurve::Lines);
|
---|
1975 | meanCurveItem.setStyle(QwtPlotCurve::Lines);
|
---|
1976 |
|
---|
1977 | // pixelValueCurveItem.setCurveAttribute(QwtPlotCurve::Fitted);
|
---|
1978 | pixelValueCurveItem.attach(pixelValueCurve);
|
---|
1979 | // aMeanCurveItem.attach(pixelValueCurve);
|
---|
1980 | // vCorrCurveItem.attach(pixelValueCurve);
|
---|
1981 | // meanCurveItem.attach(pixelValueCurve);
|
---|
1982 |
|
---|
1983 | //FIXME delete these pointers with the destructor
|
---|
1984 | curveZoom = new QwtPlotZoomer(pixelValueCurve->canvas());
|
---|
1985 | curveZoom->setRubberBandPen(QPen(Qt::gray, 2, Qt::DotLine));
|
---|
1986 | curveZoom->setTrackerPen(QPen(Qt::gray));
|
---|
1987 |
|
---|
1988 | boardsTimeHistoZoom = new QwtPlotZoomer(boardsTimeHisto->canvas());
|
---|
1989 | boardsTimeHistoZoom->setRubberBandPen(QPen(Qt::gray, 2, Qt::DotLine));
|
---|
1990 | boardsTimeHistoZoom->setTrackerPen(QPen(Qt::gray));
|
---|
1991 |
|
---|
1992 | startCellHistoZoom = new QwtPlotZoomer(startCellsHisto->canvas());
|
---|
1993 | startCellHistoZoom->setRubberBandPen(QPen(Qt::gray, 2, Qt::DotLine));
|
---|
1994 | startCellHistoZoom->setTrackerPen(QPen(Qt::gray));
|
---|
1995 |
|
---|
1996 | startTimeMarkHistoZoom = new QwtPlotZoomer(startTimeMarkHisto->canvas());
|
---|
1997 | startTimeMarkHistoZoom->setRubberBandPen(QPen(Qt::gray, 2, Qt::DotLine));
|
---|
1998 | startTimeMarkHistoZoom->setTrackerPen(QPen(Qt::gray));
|
---|
1999 |
|
---|
2000 | triggerDelayHistoZoom = new QwtPlotZoomer(triggerDelayHisto->canvas());
|
---|
2001 | triggerDelayHistoZoom->setRubberBandPen(QPen(Qt::gray, 2, Qt::DotLine));
|
---|
2002 | triggerDelayHistoZoom->setTrackerPen(QPen(Qt::gray));
|
---|
2003 |
|
---|
2004 |
|
---|
2005 | }
|
---|
2006 |
|
---|
2007 | void UIConnector::pixelChanged(int pixel)
|
---|
2008 | {
|
---|
2009 | GLWindow_2->fWhite = pixel;
|
---|
2010 | GLWindow_2->fWhitePatch = GLWindow_2->pixelsPatch[pixel];
|
---|
2011 |
|
---|
2012 |
|
---|
2013 | pixel = GLWindow->hardwareMapping[pixel];
|
---|
2014 |
|
---|
2015 | HwIDBox->setValue(pixel);
|
---|
2016 |
|
---|
2017 | if (!GLWindow->nRoi)
|
---|
2018 | return;
|
---|
2019 |
|
---|
2020 | for (int i=0;i<GLWindow->nRoi;i++)
|
---|
2021 | {
|
---|
2022 | xval[i] = i;
|
---|
2023 | #ifdef LOAD_RAW
|
---|
2024 | yval[i] = eventsData[0][pixel][i];
|
---|
2025 | #else
|
---|
2026 | yval[i] = GLWindow->eventData[GLWindow->nRoi*pixel + i];
|
---|
2027 | #endif
|
---|
2028 | }
|
---|
2029 |
|
---|
2030 | // GLWindow->computePulsesStatistics();
|
---|
2031 | #if QWT_VERSION < 0x060000
|
---|
2032 | pixelValueCurveItem.setData(xval, yval, GLWindow->nRoi);
|
---|
2033 | //// aMeanCurveItem.setData(xval, GLWindow->aMeas, GLWindow->nRoi);
|
---|
2034 | // meanCurveItem.setData(xval, GLWindow->n1mean, GLWindow->nRoi);
|
---|
2035 | // vCorrCurveItem.setData(xval, GLWindow->vCorr, GLWindow->nRoi-3);
|
---|
2036 | #else
|
---|
2037 | pixelValueCurveItem.setSamples(xval, yval, GLWindow->nRoi);
|
---|
2038 | // aMeanCurveItem.setSamples(xval, GLWindow->aMeas, GLWindow->nRoi);
|
---|
2039 | // meanCurveItem.setSamples(xval, GLWindow->n1mean, GLWindow->nRoi);
|
---|
2040 | // vCorrCurveItem.setSamples(xval, GLWindow->vCorr, GLWindow->nRoi-3);
|
---|
2041 | #endif
|
---|
2042 |
|
---|
2043 |
|
---|
2044 | QStack< QRectF > stack;
|
---|
2045 | stack.push(scaleBoundingRectangle(pixelValueCurveItem.boundingRect(), 1.5f));
|
---|
2046 | curveZoom->setZoomStack(stack);
|
---|
2047 | stack.pop();
|
---|
2048 |
|
---|
2049 | displaySliceValue();
|
---|
2050 | on_autoScaleColor_clicked();
|
---|
2051 | }
|
---|
2052 |
|
---|
2053 | void UIConnector::on_HwIDBox_valueChanged(int)
|
---|
2054 | {
|
---|
2055 | updating = true;
|
---|
2056 |
|
---|
2057 | const int hwID = HwIDBox->value();
|
---|
2058 |
|
---|
2059 | const int crateID = hwID/360;
|
---|
2060 | const int boardID = (hwID%360)/36;
|
---|
2061 | const int patchID = (hwID%36 )/9;
|
---|
2062 | const int pixelID = hwID%9;
|
---|
2063 |
|
---|
2064 | SwIDBox->setValue(GLWindow->softwareMapping[hwID]);
|
---|
2065 |
|
---|
2066 | crateIDBox->setValue(crateID);
|
---|
2067 | boardIDBox->setValue(boardID);
|
---|
2068 | patchIDBox->setValue(patchID);
|
---|
2069 | pixelIDBox->setValue(pixelID);
|
---|
2070 |
|
---|
2071 | updating = false;
|
---|
2072 |
|
---|
2073 | GLWindow->selectedPixel = GLWindow->softwareMapping[hwID];
|
---|
2074 | GLWindow->updateGL();
|
---|
2075 |
|
---|
2076 | pixelChanged(GLWindow->selectedPixel);
|
---|
2077 | }
|
---|
2078 |
|
---|
2079 | void UIConnector::cbpxChanged()
|
---|
2080 | {
|
---|
2081 | if (updating)
|
---|
2082 | return;
|
---|
2083 |
|
---|
2084 | const int hwid = crateIDBox->value()*360 + boardIDBox->value()*36 + patchIDBox->value()*9 + pixelIDBox->value();
|
---|
2085 | HwIDBox->setValue(hwid);
|
---|
2086 | }
|
---|
2087 |
|
---|
2088 | void UIConnector::on_SwIDBox_valueChanged(int swid)
|
---|
2089 | {
|
---|
2090 | if (updating)
|
---|
2091 | return;
|
---|
2092 |
|
---|
2093 | HwIDBox->setValue(GLWindow->hardwareMapping[swid]);
|
---|
2094 | }
|
---|
2095 |
|
---|
2096 | void UIConnector::on_autoScaleColor_clicked()
|
---|
2097 | {
|
---|
2098 | if (!autoScaleColor->isChecked())
|
---|
2099 | {
|
---|
2100 | /*
|
---|
2101 | GLWindow->ss[0] = 0.496;
|
---|
2102 | GLWindow->ss[1] = 0.507;
|
---|
2103 | GLWindow->ss[2] = 0.518;
|
---|
2104 | GLWindow->ss[3] = 0.529;
|
---|
2105 | GLWindow->ss[4] = 0.540;;
|
---|
2106 | colorRange0->setValue(GLWindow->ss[0]);
|
---|
2107 | colorRange1->setValue(GLWindow->ss[1]);
|
---|
2108 | colorRange2->setValue(GLWindow->ss[2]);
|
---|
2109 | colorRange3->setValue(GLWindow->ss[3]);
|
---|
2110 | colorRange4->setValue(GLWindow->ss[4]);
|
---|
2111 | */
|
---|
2112 | return;
|
---|
2113 | }
|
---|
2114 | if (!GLWindow->nRoi)
|
---|
2115 | return;
|
---|
2116 |
|
---|
2117 | int start = 0;
|
---|
2118 | int end = 1440;
|
---|
2119 |
|
---|
2120 | if (!entireCameraScale->isChecked())
|
---|
2121 | {
|
---|
2122 | start = GLWindow->selectedPixel;
|
---|
2123 | end = GLWindow->selectedPixel+1;
|
---|
2124 | }
|
---|
2125 |
|
---|
2126 | int min = 100000; //real min = -2048, int_16 = -32768 to 32767
|
---|
2127 | int max = -100000; //real max = 2047
|
---|
2128 |
|
---|
2129 | long average = 0;
|
---|
2130 | long numSamples = 0;
|
---|
2131 | int errorDetected = -1;
|
---|
2132 |
|
---|
2133 | for (int i=start;i<end;i++)
|
---|
2134 | {
|
---|
2135 | for (int j=0;j<GLWindow->nRoi;j++)
|
---|
2136 | {
|
---|
2137 | int cValue = GLWindow->eventData[i*GLWindow->nRoi+j];
|
---|
2138 | if (cValue > max && cValue < 32767)
|
---|
2139 | max = cValue;
|
---|
2140 | if (cValue < min && cValue > -32768)
|
---|
2141 | min = cValue;
|
---|
2142 | if (cValue < 32767 && cValue > -32768)
|
---|
2143 | {
|
---|
2144 | average+=cValue;
|
---|
2145 | numSamples++;
|
---|
2146 | }
|
---|
2147 | else
|
---|
2148 | {
|
---|
2149 | errorDetected = i;
|
---|
2150 | }
|
---|
2151 | // numSamples++;
|
---|
2152 | }
|
---|
2153 | }
|
---|
2154 | average /= numSamples;
|
---|
2155 | if (errorDetected != -1)
|
---|
2156 | {
|
---|
2157 | cout << "Overflow detected at pixel " << errorDetected << " (at least)" << endl;
|
---|
2158 | }
|
---|
2159 | // cout << "min: " << min << " max: " << max << " average: " << average << endl;
|
---|
2160 | double minRange = (double)(min+(VALUES_SPAN/2))/(double)VALUES_SPAN;
|
---|
2161 | double maxRange = (double)(max+(VALUES_SPAN/2))/(double)VALUES_SPAN;
|
---|
2162 | double midRange = (double)(average+(VALUES_SPAN/2))/(double)VALUES_SPAN;
|
---|
2163 | if (GLWindow->logScale)
|
---|
2164 | {
|
---|
2165 | minRange *= 9;
|
---|
2166 | maxRange *= 9;
|
---|
2167 | // midRange *= 9;
|
---|
2168 | minRange += 1;
|
---|
2169 | maxRange += 1;
|
---|
2170 | // midRange += 1;
|
---|
2171 | minRange = log10(minRange);
|
---|
2172 | maxRange = log10(maxRange);
|
---|
2173 | // midRange = (minRange + maxRange)/2.f;
|
---|
2174 | midRange = log10(midRange);
|
---|
2175 | }
|
---|
2176 |
|
---|
2177 | GLWindow->ss[0] = minRange;
|
---|
2178 | colorRange0->setValue(GLWindow->ss[0]);
|
---|
2179 | GLWindow->ss[4] = maxRange;
|
---|
2180 | colorRange4->setValue(GLWindow->ss[4]);
|
---|
2181 | // GLWindow->ss[2] = midRange;
|
---|
2182 | // range2->setValue(GLWindow->ss[2]);
|
---|
2183 | // GLWindow->ss[1] = (minRange+midRange)/2;
|
---|
2184 | // range1->setValue(GLWindow->ss[1]);
|
---|
2185 | // GLWindow->ss[3] = (maxRange+midRange)/2;
|
---|
2186 | // range3->setValue(GLWindow->ss[3]);
|
---|
2187 |
|
---|
2188 | GLWindow->ss[2] = (maxRange+minRange)/2;
|
---|
2189 | colorRange2->setValue(GLWindow->ss[2]);
|
---|
2190 |
|
---|
2191 | GLWindow->ss[1] = minRange+(maxRange-minRange)/4;
|
---|
2192 | colorRange1->setValue(GLWindow->ss[1]);
|
---|
2193 |
|
---|
2194 | GLWindow->ss[3] = minRange+3*(maxRange-minRange)/4;
|
---|
2195 | colorRange3->setValue(GLWindow->ss[3]);
|
---|
2196 | }
|
---|
2197 |
|
---|
2198 | void PrintUsage()
|
---|
2199 | {
|
---|
2200 | cout << "\n"
|
---|
2201 | "The FACT++ raw data viewer.\n"
|
---|
2202 | "\n"
|
---|
2203 | "Usage: viewer [OPTIONS] [datafile.fits[.gz] [calibration.drs.fits[.gz]]]\n"
|
---|
2204 | " or: viewer [OPTIONS]\n";
|
---|
2205 | cout << endl;
|
---|
2206 |
|
---|
2207 | }
|
---|
2208 |
|
---|
2209 | void PrintHelp()
|
---|
2210 | {
|
---|
2211 | cout <<
|
---|
2212 | "\n"
|
---|
2213 | << endl;
|
---|
2214 | }
|
---|
2215 |
|
---|
2216 | int UIConnector::SetupConfiguration(Configuration &conf)
|
---|
2217 | {
|
---|
2218 | RawDataViewer *canvas = GLWindow;
|
---|
2219 |
|
---|
2220 | if (conf.Has("color.range"))
|
---|
2221 | {
|
---|
2222 | vector<double> value = conf.Vec<double>("color.range");
|
---|
2223 | if (value.size() != 5)
|
---|
2224 | {
|
---|
2225 | cout << "Error, colorRange option should have exactly 5 double values" << endl;
|
---|
2226 | return -1;
|
---|
2227 | }
|
---|
2228 | for (int i=0;i<5;i++)
|
---|
2229 | canvas->ss[i] = value[i];
|
---|
2230 | }
|
---|
2231 |
|
---|
2232 | if (conf.Has("color.red"))
|
---|
2233 | {
|
---|
2234 | vector<double> value = conf.Vec<double>("color.red");
|
---|
2235 | if (value.size() != 5)
|
---|
2236 | {
|
---|
2237 | cout << "Error, colorRed option should have exactly 5 double values" << endl;
|
---|
2238 | return -1;
|
---|
2239 | }
|
---|
2240 | for (int i=0;i<5;i++)
|
---|
2241 | canvas->rr[i] = value[i];
|
---|
2242 | }
|
---|
2243 |
|
---|
2244 | if (conf.Has("color.green"))
|
---|
2245 | {
|
---|
2246 | vector<double> value = conf.Vec<double>("color.green");
|
---|
2247 | if (value.size() != 5)
|
---|
2248 | {
|
---|
2249 | cout << "Error, colorGreen option should have exactly 5 double values" << endl;
|
---|
2250 | return -1;
|
---|
2251 | }
|
---|
2252 | for (int i=0;i<5;i++)
|
---|
2253 | canvas->gg[i] = value[i];
|
---|
2254 | }
|
---|
2255 |
|
---|
2256 | if (conf.Has("color.blue"))
|
---|
2257 | {
|
---|
2258 | vector<double> value = conf.Vec<double>("color.blue");
|
---|
2259 | if (value.size() != 5)
|
---|
2260 | {
|
---|
2261 | cout << "Error, colorBlue option should have exactly 5 double values" << endl;
|
---|
2262 | return -1;
|
---|
2263 | }
|
---|
2264 | for (int i=0;i<5;i++)
|
---|
2265 | canvas->bb[i] = value[i];
|
---|
2266 | }
|
---|
2267 |
|
---|
2268 | colorRange0->setValue(canvas->ss[0]);
|
---|
2269 | colorRange1->setValue(canvas->ss[1]);
|
---|
2270 | colorRange2->setValue(canvas->ss[2]);
|
---|
2271 | colorRange3->setValue(canvas->ss[3]);
|
---|
2272 | colorRange4->setValue(canvas->ss[4]);
|
---|
2273 | redValue0->setValue(canvas->rr[0]);
|
---|
2274 | redValue1->setValue(canvas->rr[1]);
|
---|
2275 | redValue2->setValue(canvas->rr[2]);
|
---|
2276 | redValue3->setValue(canvas->rr[3]);
|
---|
2277 | redValue4->setValue(canvas->rr[4]);
|
---|
2278 | greenValue0->setValue(canvas->gg[0]);
|
---|
2279 | greenValue1->setValue(canvas->gg[1]);
|
---|
2280 | greenValue2->setValue(canvas->gg[2]);
|
---|
2281 | greenValue3->setValue(canvas->gg[3]);
|
---|
2282 | greenValue4->setValue(canvas->gg[4]);
|
---|
2283 | blueValue0->setValue(canvas->bb[0]);
|
---|
2284 | blueValue1->setValue(canvas->bb[1]);
|
---|
2285 | blueValue2->setValue(canvas->bb[2]);
|
---|
2286 | blueValue3->setValue(canvas->bb[3]);
|
---|
2287 | blueValue4->setValue(canvas->bb[4]);
|
---|
2288 |
|
---|
2289 | if (conf.Has("drs"))
|
---|
2290 | {
|
---|
2291 | const QString qstr(conf.Get<string>("drs").c_str());
|
---|
2292 | calibFileSelected(qstr);
|
---|
2293 | }
|
---|
2294 |
|
---|
2295 | if (conf.Has("file"))
|
---|
2296 | {
|
---|
2297 | const QString qstr(conf.Get<string>("file").c_str());
|
---|
2298 | fileSelected(qstr);
|
---|
2299 | }
|
---|
2300 |
|
---|
2301 |
|
---|
2302 | return 0;
|
---|
2303 | }
|
---|
2304 |
|
---|
2305 | void SetupConfiguration(Configuration& conf)
|
---|
2306 | {
|
---|
2307 | po::options_description configs("Raw Events Viewer Options");
|
---|
2308 | configs.add_options()
|
---|
2309 | ("color.range", vars<double>(), "Range of the display colours")
|
---|
2310 | ("color.red", vars<double>(), "Range of red values")
|
---|
2311 | ("color.green", vars<double>(), "Range of green values")
|
---|
2312 | ("color.blue", vars<double>(), "Range of blue values")
|
---|
2313 | ("file,f", var<string>(), "File to be loaded")
|
---|
2314 | ("drs,d", var<string>(), "DRS calibration file to be loaded")
|
---|
2315 | ;
|
---|
2316 | conf.AddOptions(configs);
|
---|
2317 |
|
---|
2318 | po::positional_options_description p;
|
---|
2319 | p.add("file", 1); // The first positional options
|
---|
2320 | p.add("drs", 2); // The first positional options
|
---|
2321 | conf.SetArgumentPositions(p);
|
---|
2322 |
|
---|
2323 | }
|
---|
2324 |
|
---|
2325 | /************************************************************
|
---|
2326 | * MAIN PROGRAM FUNCTION.
|
---|
2327 | ************************************************************/
|
---|
2328 | int main(int argc, const char *argv[])
|
---|
2329 | {
|
---|
2330 | QApplication app(argc, const_cast<char**>(argv));
|
---|
2331 |
|
---|
2332 | if (!QGLFormat::hasOpenGL()) {
|
---|
2333 | std::cerr << "This system has no OpenGL support" << std::endl;
|
---|
2334 | return 1;
|
---|
2335 | }
|
---|
2336 |
|
---|
2337 | Configuration conf(argv[0]);
|
---|
2338 | conf.SetPrintUsage(PrintUsage);
|
---|
2339 | SetupConfiguration(conf);
|
---|
2340 | if (!conf.DoParse(argc, argv, PrintHelp))
|
---|
2341 | return 2;
|
---|
2342 |
|
---|
2343 | UIConnector myUi;
|
---|
2344 | if (myUi.SetupConfiguration(conf)<0)
|
---|
2345 | return 3;
|
---|
2346 |
|
---|
2347 | return app.exec();
|
---|
2348 | }
|
---|
2349 |
|
---|