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