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