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