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