Changeset 12917 for trunk/FACT++/gui/RawEventsViewer
- Timestamp:
- 02/22/12 15:37:26 (13 years ago)
- Location:
- trunk/FACT++/gui/RawEventsViewer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc
r12677 r12917 14 14 #include <fstream> 15 15 16 #ifdef LOAD_RAW17 int16_t eventsData[NUM_STORED_EVENTS][ACTUAL_NUM_PIXELS][1024];18 #include </home/lyard/Code/display.C>19 #endif20 21 #define VALUES_SPAN 409622 23 16 #include <QFileDialog> 24 17 … … 49 42 if (first < 0) 50 43 first = 5; 51 // if (second > 5) 52 // second = 0; 44 53 45 first = neighbors[pixel][first]; 54 46 second = neighbors[pixel][second]; 47 // cout << pixel << " " << vertex << " " << "first: " << first << " second: " << second << endl; 55 48 for (int i=0;i<3;i++) 56 49 color[i] = pixelsColor[pixel][i]; … … 70 63 for (int i=0;i<3;i++) 71 64 color[i] /= divide; 65 66 // cout << color[0] << " " << color[1] << " " << color[2] << endl; 67 72 68 glColor3fv(color); 73 69 } … … 98 94 void RawDataViewer::drawBlurryHexagon(int index) 99 95 { 100 //alternative mesh 101 /* GLfloat color1[3]; 102 GLfloat color2[3]; 103 GLfloat color3[3]; 104 for (int i=0;i<3;i++) 105 color1[i] = pixelsColor[index][i]; 106 glBegin(GL_TRIANGLES); 107 for (int i=0;i<6;i++) 108 { 109 int first = i; 110 int second = i+1; 111 if (second == 6) second = 0; 112 first = neighbors[index][first]; 113 second = neighbors[index][second]; 114 if (first == -1 || second == -1) continue; 115 for (int j=0;j<3;j++) 116 { 117 color2[j] = pixelsColor[first][j]; 118 color3[j] = pixelsColor[second][j]; 119 } 120 glColor3fv(color2); 121 glVertex2fv(pixelsCoords[first]); 122 glColor3fv(color1); 123 glVertex2fv(pixelsCoords[index]); 124 glColor3fv(color3); 125 glVertex2fv(pixelsCoords[second]); 126 } 127 glEnd(); 128 return;*/ 96 129 97 //per-pixel mesh 130 98 GLfloat color[3]; … … 136 104 glColor3fv(color); 137 105 glVertex2fv(pixelsCoords[index]); 138 /* 139 calcMidBlurColor(index, 1); 140 glVertex2f((verticesList[verticesIndices[index][0]][0] + verticesList[verticesIndices[index][1]][0])/2.f, 141 (verticesList[verticesIndices[index][0]][1] + verticesList[verticesIndices[index][1]][1])/2.f); 142 glVertex2f((verticesList[verticesIndices[index][0]][0] + verticesList[verticesIndices[index][1]][0])/2.f, 143 (verticesList[verticesIndices[index][0]][1] + verticesList[verticesIndices[index][1]][1])/2.f); 144 glColor3fv(color); 145 glVertex2fv(pixelsCoords[index]); 146 */ 106 147 107 calcBlurColor(index, 1); 148 108 glVertex2fv(verticesList[verticesIndices[index][1]]); … … 151 111 glColor3fv(color); 152 112 glVertex2fv(pixelsCoords[index]); 153 /* 154 calcMidBlurColor(index, 2); 155 glVertex2f((verticesList[verticesIndices[index][1]][0] + verticesList[verticesIndices[index][2]][0])/2.f, 156 (verticesList[verticesIndices[index][1]][1] + verticesList[verticesIndices[index][2]][1])/2.f); 157 glVertex2f((verticesList[verticesIndices[index][1]][0] + verticesList[verticesIndices[index][2]][0])/2.f, 158 (verticesList[verticesIndices[index][1]][1] + verticesList[verticesIndices[index][2]][1])/2.f); 159 glColor3fv(color); 160 glVertex2fv(pixelsCoords[index]); 161 */ 113 162 114 calcBlurColor(index, 2); 163 115 glVertex2fv(verticesList[verticesIndices[index][2]]); … … 166 118 glColor3fv(color); 167 119 glVertex2fv(pixelsCoords[index]); 168 /* 169 calcMidBlurColor(index, 3); 170 glVertex2f((verticesList[verticesIndices[index][2]][0] + verticesList[verticesIndices[index][3]][0])/2.f, 171 (verticesList[verticesIndices[index][2]][1] + verticesList[verticesIndices[index][3]][1])/2.f); 172 glVertex2f((verticesList[verticesIndices[index][2]][0] + verticesList[verticesIndices[index][3]][0])/2.f, 173 (verticesList[verticesIndices[index][2]][1] + verticesList[verticesIndices[index][3]][1])/2.f); 174 glColor3fv(color); 175 glVertex2fv(pixelsCoords[index]); 176 */ 120 177 121 calcBlurColor(index, 3); 178 122 glVertex2fv(verticesList[verticesIndices[index][3]]); … … 181 125 glColor3fv(color); 182 126 glVertex2fv(pixelsCoords[index]); 183 /* 184 calcMidBlurColor(index, 4); 185 glVertex2f((verticesList[verticesIndices[index][3]][0] + verticesList[verticesIndices[index][4]][0])/2.f, 186 (verticesList[verticesIndices[index][3]][1] + verticesList[verticesIndices[index][4]][1])/2.f); 187 glVertex2f((verticesList[verticesIndices[index][3]][0] + verticesList[verticesIndices[index][4]][0])/2.f, 188 (verticesList[verticesIndices[index][3]][1] + verticesList[verticesIndices[index][4]][1])/2.f); 189 glColor3fv(color); 190 glVertex2fv(pixelsCoords[index]); 191 */ 127 192 128 calcBlurColor(index, 4); 193 129 glVertex2fv(verticesList[verticesIndices[index][4]]); … … 196 132 glColor3fv(color); 197 133 glVertex2fv(pixelsCoords[index]); 198 /* 199 calcMidBlurColor(index, 5); 200 glVertex2f((verticesList[verticesIndices[index][4]][0] + verticesList[verticesIndices[index][5]][0])/2.f, 201 (verticesList[verticesIndices[index][4]][1] + verticesList[verticesIndices[index][5]][1])/2.f); 202 glVertex2f((verticesList[verticesIndices[index][4]][0] + verticesList[verticesIndices[index][5]][0])/2.f, 203 (verticesList[verticesIndices[index][4]][1] + verticesList[verticesIndices[index][5]][1])/2.f); 204 glColor3fv(color); 205 glVertex2fv(pixelsCoords[index]); 206 */ 134 207 135 calcBlurColor(index, 5); 208 136 glVertex2fv(verticesList[verticesIndices[index][5]]); … … 211 139 glColor3fv(color); 212 140 glVertex2fv(pixelsCoords[index]); 213 /* 214 calcMidBlurColor(index, 0); 215 glVertex2f((verticesList[verticesIndices[index][5]][0] + verticesList[verticesIndices[index][0]][0])/2.f, 216 (verticesList[verticesIndices[index][5]][1] + verticesList[verticesIndices[index][0]][1])/2.f); 217 glVertex2f((verticesList[verticesIndices[index][5]][0] + verticesList[verticesIndices[index][0]][0])/2.f, 218 (verticesList[verticesIndices[index][5]][1] + verticesList[verticesIndices[index][0]][1])/2.f); 219 glColor3fv(color); 220 glVertex2fv(pixelsCoords[index]); 221 */ 141 222 142 calcBlurColor(index, 0); 223 143 glVertex2fv(verticesList[verticesIndices[index][0]]); … … 240 160 { 241 161 glTranslatef(-0.45,-0.45,0); 242 // cout << "correction" << endl;243 162 } 244 163 if (cameraRotation == -90) … … 254 173 { 255 174 glTranslatef(-0.45/1.5,-0.45/1.5,0); 256 // cout << "correction" << endl;257 175 } 258 176 if (cameraRotation == -90) … … 264 182 glLineWidth(1.0); 265 183 float color; 266 //cout << "Actual num pixels: " << ACTUAL_NUM_PIXELS << endl; 184 267 185 for (int i=0;i<ACTUAL_NUM_PIXELS;i++) 268 186 { … … 270 188 color = (float)(i)/(float)(ACTUAL_NUM_PIXELS); 271 189 else 272 #ifdef LOAD_RAW 273 color = float(eventsData[eventNum][i][whichSlice]+(VALUES_SPAN/2))/(float)(VALUES_SPAN-1); 274 #else 190 275 191 color = float(eventData[nRoi*hardwareMapping[i] + whichSlice]+(VALUES_SPAN/2))/(float)(VALUES_SPAN-1); 276 192 if (logScale) … … 280 196 color = log10(color); 281 197 } 282 #endif 198 283 199 if (color < ss[0]) 284 200 { … … 311 227 for (int i=0;i<ACTUAL_NUM_PIXELS;i++) 312 228 { 313 // if (i == 690 || 314 // i == 70) 315 // continue; 229 316 230 glColor3fv(pixelsColor[i]); 317 231 glLoadName(i); … … 328 242 for (int i=0;i<ACTUAL_NUM_PIXELS;i++) 329 243 { 330 // if (i == 690 || 331 // i == 70) 332 // continue; 244 333 245 drawHexagon(i, false); 334 246 } … … 336 248 } 337 249 338 /************************************************************339 * TRIM. FIXME this should not be here but taken from an existing class (somewhere)340 ***********************************************************341 string Trim(const string &str)342 {343 // Trim Both leading and trailing spaces344 const size_t start = str.find_first_not_of(' '); // Find the first character position after excluding leading blank spaces345 const size_t end = str.find_last_not_of(' '); // Find the first character position from reverse af346 347 // if all spaces or empty return an empty string348 if (string::npos==start || string::npos==end)349 return string();350 351 return str.substr(start, end-start+1);352 }*/353 250 /************************************************************ 354 251 * DRAW PIXEL CURVE. draws the raw impulse curve of the currently selected pixel … … 381 278 glColor3f(1.0f,1.0f,0.0f); 382 279 float divideMe = (float)(VALUES_SPAN-1); 383 float plusMe = VALUES_SPAN/2; 280 float plusMe = (float)(VALUES_SPAN)/2; 281 if (divideMe <= 0) 282 divideMe = 1; 384 283 385 284 /* … … 418 317 if (pixelIdInPatch == 8)//this channel has a time marker 419 318 { 420 //link between pixel slices and TM slices. should I draw it ? 421 // float d1 = eventData[nRoi*hw + nRoi-1]+plusMe; 422 // float d2 = eventData[nRoi*1440 + nRoiTM*(40*crateId + 4*boardId + patchId)] + plusMe; 423 // glVertex2f(bboxMin[0] + xRange*(nRoi-1)/(float)(nRoi+nRoiTM), 424 // bboxMin[1] + yRange*(d1) /divideMe); 425 // glVertex2f(bboxMin[0] + xRange*(nRoi)/(float)(nRoi+nRoiTM), 426 // bboxMin[1] + yRange*(d2)/divideMe); 319 427 320 for (int i=0;i<nRoiTM-1;i++) 428 321 { … … 448 341 bboxMax[1]); 449 342 450 /* glColor3f(0.f,0.5f,0.f);451 for (int i=0;i<nRoi-1;i++)452 {453 glVertex2f(bboxMin[0] + xRange*i/(float)nRoi,454 bboxMin[1] + yRange*(n1mean[ i]+plusMe) /divideMe);455 glVertex2f(bboxMin[0] + xRange*(i+1)/(float)nRoi,456 bboxMin[1] + yRange*(n1mean[i+1]+plusMe) /divideMe);457 }458 */459 343 glEnd(); 460 // glEnable(GL_MULTISAMPLE); 461 /* setFont(QFont("Times", 12)); 462 qglColor(QColor(255,223,127)); 463 float xShift = 0.10f; 464 float yShift = 0.01f; 465 renderText(bboxMin[0]-xShift/2.0f, bboxMax[1]+3*yShift, 0, QString("Volts")); 466 if (drawCalibrationLoaded) 467 { 468 renderText(bboxMin[0]-xShift, bboxMax[1]-yShift,0,QString("+2.10")); 469 renderText(bboxMin[0]-xShift, ((bboxMin[1]+bboxMax[1])/2.0f) - yShift, 0, QString("+1.05"));//((bboxMin[1]+bboxMax[1])/2.0f) 470 renderText(bboxMin[0]-xShift, bboxMin[1]-yShift, 0, QString("0.00")); 471 } 472 else 473 { 474 renderText(bboxMin[0]-xShift, bboxMax[1]-yShift,0,QString("+1.05")); 475 renderText(bboxMin[0]-xShift, ((bboxMin[1]+bboxMax[1])/2.0f) - yShift, 0, QString("+0.00"));//((bboxMin[1]+bboxMax[1])/2.0f) 476 renderText(bboxMin[0]-xShift, bboxMin[1]-yShift, 0, QString("-1.05")); 477 } 478 renderText(bboxMax[0]+xShift/2.0f, bboxMin[1]-4*yShift, 0, QString("Slices")); 479 renderText(bboxMin[0]-yShift/2.0f, bboxMin[1]-4*yShift, 0, QString("0")); 480 ostringstream str; 481 str << nRoi/2; 482 renderText(((bboxMin[0]+bboxMax[0])/2.0f)-xShift/2.0f, bboxMin[1]-4*yShift, 0, QString(str.str().c_str())); 483 str.str(""); 484 str << nRoi; 485 renderText(bboxMax[0]-xShift/2.0f, bboxMin[1]-4*yShift, 0, QString(str.str().c_str())); 486 */ 344 487 345 } 488 346 /************************************************************ 489 347 * CONSTRUCTOR. 490 348 ************************************************************/ 491 RawDataViewer::RawDataViewer(QWidget *cParent) : BasicGlCamera(cParent), RMSvalues(1440), Meanvalues(1440), Maxvalues(1440), PosOfMaxvalues(1440) 492 { 493 // setFormat(QGLFormat(QGL::DoubleBuffer));// | QGL::DepthBuffer)); 349 RawDataViewer::RawDataViewer(QWidget *cParent) : BasicGlCamera(cParent), RMSvalues(1440), Meanvalues(1440), Maxvalues(1440), PosOfMaxvalues(1440), VALUES_SPAN(4096) 350 351 { 352 494 353 whichSlice = 0; 495 #ifdef LOAD_RAW 496 nRoi = 1024; 497 #else 354 498 355 nRoi = 0; 499 #endif500 356 nRoiTM = 0; 501 357 offSetRoi = 0; … … 512 368 fIsDrsCalibration = false; 513 369 SetAutoRefresh(true); 514 #ifdef LOAD_RAW 515 loadEvents("/scratch/00000043.001_T.bin"); 516 #endif 370 517 371 PixelMap mypMap; 518 372 if (!mypMap.Read("FACTmap111030.txt")) … … 531 385 patchesColor[i][j] = color[j]; 532 386 } 533 534 //calibrationLoaded = false;535 //drawCalibrationLoaded = false;536 387 537 388 } … … 612 463 return; 613 464 int face = PixelAtPosition(cEvent->pos()); 614 // if (face != -1) { 465 615 466 selectedPixel = face; 616 467 emit signalCurrentPixel(face); 617 // } 468 618 469 updateGL(); 619 470 } … … 683 534 catch (std::runtime_error e) 684 535 { 685 cout << "Something went wrong while loading fits. aborting: " << e.what() << endl;536 cout << "Something went wrong while loading fits. Aborting: " << e.what() << endl; 686 537 return; 687 538 } … … 707 558 entriesToCheck.push_back("TSTART"); 708 559 entriesToCheck.push_back("TSTOP"); 709 //entriesToCheck.push_back("ADCRANGE"); 710 //entriesToCheck.push_back("NBEVTOK"); 711 //entriesToCheck.push_back("NBEVTREJ"); 712 //entriesToCheck.push_back("NBEVTBAD"); 560 713 561 714 562 for (vector<string>::const_iterator it=entriesToCheck.begin(); it != entriesToCheck.end(); it++) … … 753 601 eventNum = 0; 754 602 755 #ifdef LOAD_RAW756 nRows = NUM_STORED_EVENTS;757 #endif758 759 603 if (eventData != NULL) { 760 604 delete[] eventData; … … 809 653 eventStep = 1; 810 654 811 doMyWaveletTestPlease();812 813 814 655 plusEvent(); 815 656 eventStep = backupStep; … … 817 658 emit signalCurrentPixel(selectedPixel); 818 659 } 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 = 15.9f; 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] - interArray[k + span])*(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 return true; 899 } 900 */ 901 bool RawDataViewer::doWaveLetsPlease(int givenSpan, int16_t* orig_in, int16_t* wavelets_in, bool verifyResult) 902 { 903 float* interArray = new float[givenSpan]; 904 float* resultArray = new float[givenSpan]; 905 float* orig = new float[givenSpan]; 906 float* wavelets = new float[givenSpan]; 907 for (int i=0;i<givenSpan;i++) 908 { 909 if (fabs((float)(orig_in[i])) > 32767.f) 910 cout << "Input overflow: " << orig_in[i] << endl; 911 orig[i] = (float)orig_in[i]; 912 } 913 for (int k=0;k<givenSpan;k++) 914 interArray[k] = orig[k]; 915 int span = givenSpan/2; 916 while (span > 0) 917 { 918 for (int k=0;k<span;k++) 919 { 920 wavelets[k] = interArray[2*k];// + interArray[2*k + 1])/2.f; 921 wavelets[k + span] = interArray[2*k + 1] - interArray[2*k];//)/2.f; 922 } 923 for (int k=0;k<givenSpan;k++) 924 interArray[k] = wavelets[k]; 925 span /= 2; 926 } 927 //move float results to int16_t array 928 float intScaling = 1.f; 929 int max = 0; 930 for (int i=0;i<givenSpan;i++) 931 { 932 float cValue = intScaling*wavelets[i];// 933 if (cValue > 0) 934 cValue += 0.5f; 935 else 936 cValue -= 0.5f; 937 wavelets_in[i] = (int16_t)(cValue); 938 if (fabs(cValue) > 32767.f) 939 { 940 cout << "Overflow ! " << cValue << endl; 941 } 942 if (fabs(cValue) > fabs(max)) 943 max = cValue; 944 } 945 // cout << "Max wave value: " << max << endl; 946 //result reconstruction and checking 947 if (!verifyResult) 948 return true; 949 950 for (int k=0;k<givenSpan;k++) 951 { 952 resultArray[k] = wavelets_in[k]/intScaling; 953 } 954 955 span = 1; 956 while (span < givenSpan) 957 { 958 for (int k=0;k<givenSpan;k++) 959 interArray[k] = resultArray[k]; 960 for (int k=0;k<span;k++) 961 { 962 resultArray[2*k] = (float)(((interArray[k])*(1.f/1.f)) + 0.0f); 963 resultArray[2*k + 1] = (float)(((interArray[k] + interArray[k + span])*(1.f/1.f)) + 0.0f); 964 } 965 span *= 2; 966 } 967 968 for (int k=0;k<givenSpan;k++) 969 { 970 float plus = 0.5f; 971 if (resultArray[k] < 0) 972 plus *= -1.f; 973 if ((int)(resultArray[k]+plus) != (int)(orig_in[k])) 974 { 975 cout << "Nop, sorry: k: " << k << " " << resultArray[k] << " " << (int)(resultArray[k]+plus) << " " << plus << " " << orig[k] << endl; 976 return false; 977 } 978 } 979 delete[] interArray; 980 delete[] resultArray; 981 delete[] orig; 982 delete[] wavelets; 983 return true; 984 } 985 986 void RawDataViewer::doWaveLetOnCurrentEventPlease() 987 { 988 int16_t* origTheWayIWant = new int16_t[1024*1440]; 989 990 // int numPixels = 1024; 991 // int leftOver = 1440-numPixels; 992 for (int k=0;k<1024;k++) 993 for (int j=0;j<1440;j++) 994 { 995 origTheWayIWant[k*1440 + j] = rawEventData[j + k*1440]; 996 } 997 998 int waveSpan = 1024; 999 int waveToPixelsRatio = 32; 1000 waveSpan = waveSpan*waveToPixelsRatio; 1001 int totalNumSamples = 1024*1440; 1002 int j=0; 1003 for (;j<totalNumSamples;j+= waveSpan) 1004 { 1005 if (j + waveSpan < totalNumSamples) 1006 if (!doWaveLetsPlease(waveSpan, &origTheWayIWant[j], &waveLetArray[j], true)) 1007 return; 1008 } 1009 1010 while (j%1440 != 0) 1011 { 1012 int lastRun = 1; 1013 while (lastRun < 1440 - j%1440) 1014 lastRun *= 2; 1015 lastRun /= 2; 1016 if (lastRun > 2) 1017 { 1018 doWaveLetsPlease(lastRun, &origTheWayIWant[j], &waveLetArray[j], true); 1019 } 1020 else 1021 { 1022 for (int l=0;l<lastRun;l++) 1023 waveLetArray[j+l] = origTheWayIWant[j+l]; 1024 } 1025 if (!lastRun) 1026 break; 1027 j += lastRun; 1028 } 1029 1030 delete[] origTheWayIWant; 1031 1032 } 1033 void RawDataViewer::doMyWaveletTestPlease() 1034 { 1035 // cout << "Size of float: " << sizeof(float) << endl; 1036 return; 1037 ofstream outBin("/scratch/bin/outputBin.bin", ios_base::out | ios_base::binary); 1038 ofstream outWave("/scratch/bin/outputWave.bin", ios_base::out | ios_base::binary); 1039 int16_t* waveLetArray_ = new int16_t[1024*1440]; 1040 int16_t* origTheWayIWant = new int16_t[1024*1440]; 1041 1042 for (int i=0;i<nRows;i++) 1043 { 1044 cout << '\r' << "Doing row " << i << " of " << nRows; 1045 cout.flush(); 1046 inputFile->GetRow(i); 1047 outBin.write((const char*)(rawEventData), 1440*1024*2); 1048 1049 // int numPixels = 1024; 1050 // int leftOver = 1440-numPixels; 1051 for (int k=0;k<1024;k++) 1052 for (int j=0;j<1440;j++) 1053 { 1054 origTheWayIWant[k*1440 + j] = rawEventData[j + k*1440]; 1055 } 1056 1057 int waveSpan = 1024; 1058 int waveToPixelsRatio = 32; 1059 waveSpan = waveSpan*waveToPixelsRatio; 1060 int totalNumSamples = 1024*1440; 1061 int j=0; 1062 for (;j<totalNumSamples;j+= waveSpan)//1440/waveToPixelsRatio;j++) 1063 { 1064 if (j + waveSpan < totalNumSamples) 1065 if (!doWaveLetsPlease(waveSpan, &origTheWayIWant[j], &waveLetArray_[j], true)) 1066 return; 1067 } 1068 1069 while (j%1440 != 0)// < totalNumSamples) 1070 { 1071 cout << "Copying the remaining of the data" << endl; 1072 int lastRun = 1; 1073 while (lastRun < 1440 - j%1440)//totalNumSamples-j) 1074 lastRun *= 2; 1075 lastRun /= 2; 1076 if (lastRun > 2) 1077 { 1078 // cout << " Doint one last run of " << lastRun << " samples" << endl; 1079 doWaveLetsPlease(lastRun, &origTheWayIWant[j], &waveLetArray_[j], true); 1080 } 1081 else 1082 { 1083 // cout << " Filling in " << lastRun << " samples" << endl; 1084 for (int l=0;l<lastRun;l++) 1085 waveLetArray_[j+l] = origTheWayIWant[j+l]; 1086 } 1087 if (!lastRun) 1088 break; 1089 j += lastRun; 1090 } 1091 outWave.write((const char*)(waveLetArray_), 1440*1024*2); 1092 } 1093 outWave.close(); 1094 outBin.close(); 1095 inputFile->GetRow(0); 1096 1097 delete[] waveLetArray_; 1098 delete[] origTheWayIWant; 1099 } 660 1100 661 void RawDataViewer::openCalibFile(string& file) 1101 662 { 1102 663 //calibrationLoaded = false; 1103 1104 664 string msg; 1105 665 try … … 1122 682 } 1123 683 684 template <typename T> 685 void RawDataViewer::getCalibrationDataForDisplay(const CalibDataTypes calibTypes, 686 const vector<T>& inputData, 687 const int roi, 688 const int roiTM) 689 { 690 691 eventData = new float[1440*roi + 160*roiTM];//(1440+160)*nRoi]; 692 nRoi=roi; 693 nRoiTM=roiTM; 694 695 long long min, max, mean; 696 min = max = inputData[0]; 697 mean=0; 698 for (int i=0;i<1440*roi + 160*roiTM;i++) { 699 eventData[i] = (float)inputData[i]; 700 mean += inputData[i]; 701 if (inputData[i] > max) 702 max = inputData[i]; 703 if (inputData[i] < min) 704 min = inputData[i]; 705 } 706 mean /= 1440*roi + 160*roiTM; 707 for (int i=0;i<1440*roi + 160*roiTM;i++) 708 eventData[i] -= (float)mean; 709 VALUES_SPAN = max - min; 710 // cout << VALUES_SPAN << " " << min << " " << max << " " << mean << endl; 711 // cout << 1440*roi + 160*roiTM << " " << roi << " " << roiTM << " " << inputData.size() << endl; 712 } 1124 713 /************************************************************ 1125 714 * PLUS EVENT … … 1156 745 fDrsCalib.Apply(eventData, rawEventData, startPix, nRoi); 1157 746 DrsCalibrate::RemoveSpikes(eventData, nRoi); 1158 // for (int i=0;i<1024;i++)1159 // eventData[i] = eventData[i+1024];1160 747 //TODO apply calibration to the Time markers 1161 748 } … … 1178 765 if (pixelIdInPatch == 8) 1179 766 { 1180 // cout << patchId << " ";1181 767 for (int j=0;j<nSlicesToRemove;j++) 1182 768 { … … 1197 783 Maxvalues[it->index] = pixelStatsData[2*1440+it->hw()]; 1198 784 PosOfMaxvalues[it->index] = pixelStatsData[3*1440+it->hw()]; 1199 1200 785 } 1201 786 if (nRoiTM == 0)//move back the data back in place … … 1236 821 if (rowNum < 0) 1237 822 rowNum += nRows; 1238 #ifdef LOAD_RAW 1239 eventNum+=eventStep; 1240 #else 823 1241 824 if (inputFile == NULL) 1242 825 return; 1243 826 inputFile->GetRow(rowNum); 1244 827 // cout << "Getting row " << rowNum << endl; 1245 #endif 828 1246 829 1247 830 ApplyCalibration(); … … 1475 1058 { 1476 1059 GLWindow->drawImpulse = state; 1060 TriggerOffset_window->drawImpulse = state; 1061 Gain_window->drawImpulse = state; 1062 Baseline_window->drawImpulse = state; 1477 1063 GLWindow->updateGL(); 1064 TriggerOffset_window->updateGL(); 1065 Gain_window->updateGL(); 1066 Baseline_window->updateGL(); 1478 1067 } 1479 1068 /************************************************************ … … 1573 1162 if (currentCalibFile != "") 1574 1163 GLWindow->openCalibFile(currentCalibFile); 1164 if (GLWindow->fDrsCalib.fRoi != 0) 1165 {//spread the calibration data to the displayers 1166 Baseline_window->getCalibrationDataForDisplay(RawDataViewer::CALIB_BASELINE, 1167 GLWindow->fDrsCalib.fOffset, 1168 GLWindow->fDrsCalib.fRoi, 1169 GLWindow->fDrsCalib.fNumTm); 1170 1171 Gain_window->getCalibrationDataForDisplay(RawDataViewer::CALIB_GAIN, 1172 GLWindow->fDrsCalib.fGain, 1173 GLWindow->fDrsCalib.fRoi, 1174 GLWindow->fDrsCalib.fNumTm); 1175 1176 TriggerOffset_window->getCalibrationDataForDisplay(RawDataViewer::CALIB_TRIG_OFFSET, 1177 GLWindow->fDrsCalib.fTrgOff, 1178 GLWindow->fDrsCalib.fRoi, 1179 GLWindow->fDrsCalib.fNumTm); 1180 1181 } 1575 1182 } 1576 1183 /************************************************************ … … 2455 2062 } 2456 2063 // cout << "min: " << min << " max: " << max << " average: " << average << endl; 2457 float minRange = (float)(min+( VALUES_SPAN/2))/(float)(VALUES_SPAN-1);2458 float maxRange = (float)(max+( VALUES_SPAN/2))/(float)(VALUES_SPAN-1);2459 float midRange = (float)(average+( VALUES_SPAN/2))/(float)(VALUES_SPAN-1);2064 float minRange = (float)(min+(GLWindow->VALUES_SPAN/2))/(float)(GLWindow->VALUES_SPAN-1); 2065 float maxRange = (float)(max+(GLWindow->VALUES_SPAN/2))/(float)(GLWindow->VALUES_SPAN-1); 2066 float midRange = (float)(average+(GLWindow->VALUES_SPAN/2))/(float)(GLWindow->VALUES_SPAN-1); 2460 2067 if (GLWindow->logScale) 2461 2068 { -
trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h
r12678 r12917 62 62 friend class UIConnector; 63 63 64 64 enum CalibDataTypes { 65 CALIB_BASELINE, 66 CALIB_GAIN, 67 CALIB_TRIG_OFFSET 68 }; 65 69 66 70 public: … … 74 78 void openCalibFile(std::string& file); 75 79 76 80 template <typename T> 81 void getCalibrationDataForDisplay(const CalibDataTypes calibTypes, 82 const vector<T>& inputData, 83 const int roi, 84 const int roiTM); 77 85 78 86 public Q_SLOTS: … … 165 173 int eventStep; 166 174 175 176 177 167 178 // int hardwareMapping[1440]; 168 179 // int softwareMapping[1440]; … … 179 190 180 191 QPoint lastPos; 181 182 void doMyWaveletTestPlease();183 void doWaveLetOnCurrentEventPlease();184 bool doWaveLetsPlease(int givenSpan, int16_t* orig, int16_t* wavelets, bool verifyResult);185 192 public: 186 193 void computePulsesStatistics(); … … 189 196 double n2mean[1024]; 190 197 double vCorr[1024]; 198 int64_t VALUES_SPAN; 191 199 192 200 void ApplyCalibration(); -
trunk/FACT++/gui/RawEventsViewer/viewer.ui
r12677 r12917 39 39 </property> 40 40 <attribute name="title"> 41 <string>Camera View</string>41 <string>Camera</string> 42 42 </attribute> 43 43 <layout class="QGridLayout" name="gridLayout_3"> … … 65 65 </property> 66 66 <attribute name="title"> 67 <string>Data View</string>67 <string>Data</string> 68 68 </attribute> 69 69 <layout class="QVBoxLayout" name="verticalLayout_2"> … … 205 205 </layout> 206 206 </widget> 207 <widget class="QWidget" name="tab_ 2">207 <widget class="QWidget" name="tab_15"> 208 208 <attribute name="title"> 209 <string> RMS</string>209 <string>Statistics</string> 210 210 </attribute> 211 <layout class="QGridLayout" name="gridLayout_ 6">211 <layout class="QGridLayout" name="gridLayout_11"> 212 212 <item row="0" column="0"> 213 <widget class="QCameraWidget" name="RMS_window" native="true"> 214 <property name="enabled"> 215 <bool>true</bool> 216 </property> 217 <property name="sizePolicy"> 218 <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> 219 <horstretch>0</horstretch> 220 <verstretch>0</verstretch> 221 </sizepolicy> 222 </property> 223 <property name="maximumSize"> 224 <size> 225 <width>10000</width> 226 <height>10000</height> 227 </size> 228 </property> 213 <widget class="QTabWidget" name="tabWidget_4"> 214 <property name="currentIndex"> 215 <number>0</number> 216 </property> 217 <widget class="QWidget" name="tab_16"> 218 <attribute name="title"> 219 <string>RMS</string> 220 </attribute> 221 <layout class="QGridLayout" name="gridLayout_12"> 222 <item row="0" column="0"> 223 <widget class="QCameraWidget" name="RMS_window" native="true"> 224 <property name="enabled"> 225 <bool>true</bool> 226 </property> 227 <property name="sizePolicy"> 228 <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> 229 <horstretch>0</horstretch> 230 <verstretch>0</verstretch> 231 </sizepolicy> 232 </property> 233 <property name="maximumSize"> 234 <size> 235 <width>10000</width> 236 <height>10000</height> 237 </size> 238 </property> 239 </widget> 240 </item> 241 </layout> 242 </widget> 243 <widget class="QWidget" name="tab_17"> 244 <attribute name="title"> 245 <string>Mean</string> 246 </attribute> 247 <layout class="QGridLayout" name="gridLayout_13"> 248 <item row="0" column="0"> 249 <widget class="QCameraWidget" name="Mean_window" native="true"> 250 <property name="enabled"> 251 <bool>true</bool> 252 </property> 253 <property name="sizePolicy"> 254 <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> 255 <horstretch>0</horstretch> 256 <verstretch>0</verstretch> 257 </sizepolicy> 258 </property> 259 <property name="maximumSize"> 260 <size> 261 <width>10000</width> 262 <height>10000</height> 263 </size> 264 </property> 265 </widget> 266 </item> 267 </layout> 268 </widget> 269 <widget class="QWidget" name="tab_18"> 270 <attribute name="title"> 271 <string>Max</string> 272 </attribute> 273 <layout class="QGridLayout" name="gridLayout_14"> 274 <item row="0" column="0"> 275 <widget class="QCameraWidget" name="Max_window" native="true"> 276 <property name="enabled"> 277 <bool>true</bool> 278 </property> 279 <property name="sizePolicy"> 280 <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> 281 <horstretch>0</horstretch> 282 <verstretch>0</verstretch> 283 </sizepolicy> 284 </property> 285 <property name="maximumSize"> 286 <size> 287 <width>10000</width> 288 <height>10000</height> 289 </size> 290 </property> 291 </widget> 292 </item> 293 </layout> 294 </widget> 295 <widget class="QWidget" name="tab_19"> 296 <attribute name="title"> 297 <string>Pos. of Max.</string> 298 </attribute> 299 <layout class="QGridLayout" name="gridLayout_15"> 300 <item row="0" column="0"> 301 <widget class="QCameraWidget" name="PosOfMax_window" native="true"> 302 <property name="enabled"> 303 <bool>true</bool> 304 </property> 305 <property name="sizePolicy"> 306 <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> 307 <horstretch>0</horstretch> 308 <verstretch>0</verstretch> 309 </sizepolicy> 310 </property> 311 <property name="maximumSize"> 312 <size> 313 <width>10000</width> 314 <height>10000</height> 315 </size> 316 </property> 317 </widget> 318 </item> 319 </layout> 320 </widget> 229 321 </widget> 230 322 </item> 231 323 </layout> 232 324 </widget> 233 <widget class="QWidget" name="tab_ 8">325 <widget class="QWidget" name="tab_11"> 234 326 <attribute name="title"> 235 <string> Mean</string>327 <string>Calibration</string> 236 328 </attribute> 237 <layout class="QGridLayout" name="gridLayout_ 61">329 <layout class="QGridLayout" name="gridLayout_7"> 238 330 <item row="0" column="0"> 239 <widget class="QCameraWidget" name="Mean_window" native="true"> 240 <property name="enabled"> 241 <bool>true</bool> 242 </property> 243 <property name="sizePolicy"> 244 <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> 245 <horstretch>0</horstretch> 246 <verstretch>0</verstretch> 247 </sizepolicy> 248 </property> 249 <property name="maximumSize"> 250 <size> 251 <width>10000</width> 252 <height>10000</height> 253 </size> 254 </property> 255 </widget> 256 </item> 257 </layout> 258 </widget> 259 <widget class="QWidget" name="tab_9"> 260 <attribute name="title"> 261 <string>Max</string> 262 </attribute> 263 <layout class="QGridLayout" name="gridLayout_62"> 264 <item row="0" column="0"> 265 <widget class="QCameraWidget" name="Max_window" native="true"> 266 <property name="enabled"> 267 <bool>true</bool> 268 </property> 269 <property name="sizePolicy"> 270 <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> 271 <horstretch>0</horstretch> 272 <verstretch>0</verstretch> 273 </sizepolicy> 274 </property> 275 <property name="maximumSize"> 276 <size> 277 <width>10000</width> 278 <height>10000</height> 279 </size> 280 </property> 281 </widget> 282 </item> 283 </layout> 284 </widget> 285 <widget class="QWidget" name="tab_10"> 286 <attribute name="title"> 287 <string>Pos. of Max.</string> 288 </attribute> 289 <layout class="QGridLayout" name="gridLayout_63"> 290 <item row="0" column="0"> 291 <widget class="QCameraWidget" name="PosOfMax_window" native="true"> 292 <property name="enabled"> 293 <bool>true</bool> 294 </property> 295 <property name="sizePolicy"> 296 <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> 297 <horstretch>0</horstretch> 298 <verstretch>0</verstretch> 299 </sizepolicy> 300 </property> 301 <property name="maximumSize"> 302 <size> 303 <width>10000</width> 304 <height>10000</height> 305 </size> 306 </property> 331 <widget class="QTabWidget" name="tabWidget"> 332 <property name="currentIndex"> 333 <number>0</number> 334 </property> 335 <widget class="QWidget" name="tab_12"> 336 <attribute name="title"> 337 <string>Baseline</string> 338 </attribute> 339 <layout class="QGridLayout" name="gridLayout_8"> 340 <item row="0" column="0"> 341 <widget class="RawDataViewer" name="Baseline_window" native="true"> 342 <property name="enabled"> 343 <bool>true</bool> 344 </property> 345 <property name="sizePolicy"> 346 <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> 347 <horstretch>1</horstretch> 348 <verstretch>1</verstretch> 349 </sizepolicy> 350 </property> 351 </widget> 352 </item> 353 </layout> 354 </widget> 355 <widget class="QWidget" name="tab_13"> 356 <attribute name="title"> 357 <string>Gain</string> 358 </attribute> 359 <layout class="QGridLayout" name="gridLayout_9"> 360 <item row="0" column="0"> 361 <widget class="RawDataViewer" name="Gain_window" native="true"> 362 <property name="enabled"> 363 <bool>true</bool> 364 </property> 365 <property name="sizePolicy"> 366 <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> 367 <horstretch>1</horstretch> 368 <verstretch>1</verstretch> 369 </sizepolicy> 370 </property> 371 </widget> 372 </item> 373 </layout> 374 </widget> 375 <widget class="QWidget" name="tab_14"> 376 <attribute name="title"> 377 <string>Trigger Offset</string> 378 </attribute> 379 <layout class="QGridLayout" name="gridLayout_10"> 380 <item row="0" column="0"> 381 <widget class="RawDataViewer" name="TriggerOffset_window" native="true"> 382 <property name="enabled"> 383 <bool>true</bool> 384 </property> 385 <property name="sizePolicy"> 386 <sizepolicy hsizetype="Preferred" vsizetype="Preferred"> 387 <horstretch>1</horstretch> 388 <verstretch>1</verstretch> 389 </sizepolicy> 390 </property> 391 </widget> 392 </item> 393 </layout> 394 </widget> 307 395 </widget> 308 396 </item> … … 321 409 <widget class="QLabel" name="label"> 322 410 <property name="text"> 323 <string>FACT - Raw events viewer - v0. 5</string>411 <string>FACT - Raw events viewer - v0.6</string> 324 412 </property> 325 413 </widget>
Note:
See TracChangeset
for help on using the changeset viewer.