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