From: Jan Michel Date: Thu, 26 Jun 2014 16:24:19 +0000 (+0200) Subject: fixed column error in unpacker X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=990b7f281266fa29d5223372ceb4c6422f6f0365;p=mvdsensorcontrol.git fixed column error in unpacker --- diff --git a/tools/unpacker/unpacker.cxx b/tools/unpacker/unpacker.cxx index 9622666..58db4dd 100644 --- a/tools/unpacker/unpacker.cxx +++ b/tools/unpacker/unpacker.cxx @@ -90,19 +90,19 @@ signed analyzeData(hadaq::RawSubevent* sub, unsigned ix, unsigned datalen, unsig unsigned mySensor = getSensor(sensorId); ix += 2; //Skip time -#if DEBUG>=1 + #if DEBUG>=1 printf("Head\t%08x\tID\t%08x\tStatus\t%08x\tError\t%08x\tDebug\t%08x\n", sensorHead, sensorId, sensorStatus, sensorError, sensorDebug); -#endif + #endif if(sensorHead != 0xffffffff) { //Something is really wrong with data. Skip SubEvent! printf("Broken Sensor Header\n"); statistics[mySensor][FRREALBROKEN]++; -#if DEBUG!=1 - printf("Head\t%08x\tID\t%08x\tStatus\t%08x\tError\t%08x\tDebug\t%08x\n", - sensorHead, sensorId, sensorStatus, sensorError, sensorDebug); -#endif + #if DEBUG!=1 + printf("Head\t%08x\tID\t%08x\tStatus\t%08x\tError\t%08x\tDebug\t%08x\n", + sensorHead, sensorId, sensorStatus, sensorError, sensorDebug); + #endif return -1; } @@ -125,10 +125,10 @@ signed analyzeData(hadaq::RawSubevent* sub, unsigned ix, unsigned datalen, unsig unsigned frameEndPos = ix + sensorLength; unsigned d,line = 0,column,pixels,statecnt = 0,ovf = 0; -#if DEBUG>=1 - printf("\t\t\tHeader\t%08x\tFrame\t%08x\tLength\t%i\n", + #if DEBUG>=1 + printf("\t\t\tHeader\t%08x\tFrame\t%08x\tLength\t%i\n", sensorDummy, sensorNumber, sensorLength); -#endif + #endif if(sensorLength == 0) { goto FrameEnd; } @@ -148,9 +148,9 @@ signed analyzeData(hadaq::RawSubevent* sub, unsigned ix, unsigned datalen, unsig else { pixels = (d & 0x3); column = (d >> 2) & 0x7FF; -#if DEBUG>1 + #if DEBUG>1 printf("\t%d, %d x %d\n",line,column,pixels+1); -#endif + #endif pixelcount[mySensor][column] += pixels+1; pixelMap[mySensor][line][column]++; @@ -159,7 +159,7 @@ signed analyzeData(hadaq::RawSubevent* sub, unsigned ix, unsigned datalen, unsig if (pixels > 1) { pixelMap[mySensor][line][column+2]++; if (pixels > 2) { - pixelMap[mySensor][line][column]++; + pixelMap[mySensor][line][column+3]++; } } } @@ -227,48 +227,48 @@ void writeResults() { FILE* cvt; int status; cvt = popen("gnuplot", "w"); - fprintf(cvt, "set terminal png size 800,400 font \",9\";\n"); - fprintf(cvt, "set palette model RGB;\n"); - fprintf(cvt, "set xrange [0:1152];\n"); - fprintf(cvt, "set yrange [0:576];\n"); - fprintf(cvt, "set cbrange [0:%i];\n",statistics[i][FRVALID]); - fprintf(cvt, "set palette defined ( 0 'white', 1 'red', 5 'black', 10 'blue', %i 'green');\n",statistics[i][FRVALID]); + if (!cvt) { + printf("couldn't open a pipe; quitting\n"); + exit(1); + } + fprintf(cvt, "set terminal png size 800,400 font \",9\";\n"); + fprintf(cvt, "set palette model RGB;\n"); + fprintf(cvt, "set xrange [0:1152];\n"); + fprintf(cvt, "set yrange [0:576];\n"); + fprintf(cvt, "set cbrange [0:%i];\n",statistics[i][FRVALID]); + fprintf(cvt, "set palette defined ( 0 'white', 1 'red', 5 'black', 10 'blue', %i 'green');\n",statistics[i][FRVALID]); - time_t rawtime; - struct tm * timeinfo; - time (&rawtime); - timeinfo = localtime (&rawtime); - char ts[200]; - strftime (ts,200,"set label 100 \"%H:%M:%S\" at screen 0.98,0.02 right tc rgb \"#000044\" font \"monospace,8\"\n",timeinfo); - fprintf(cvt,ts); + time_t rawtime; + struct tm * timeinfo; + time (&rawtime); + timeinfo = localtime (&rawtime); + char ts[200]; + strftime (ts,200,"set label 100 \"%H:%M:%S\" at screen 0.98,0.02 right tc rgb \"#000044\" font \"monospace,8\"\n",timeinfo); + fprintf(cvt,ts); - fprintf(cvt, "set label 101 \"%i States, %i good, %i broken, %i invalid\" at screen 0.02,0.01 left tc rgb \"#000044\" font \"monospace,8\"\n", - hitcount[i], - statistics[i][FRVALID], - statistics[i][FRBROKEN], - statistics[i][FRREALBROKEN]); + fprintf(cvt, "set label 101 \"%i States, %i good, %i broken, %i invalid\" at screen 0.02,0.01 left tc rgb \"#000044\" font \"monospace,8\"\n", + hitcount[i], + statistics[i][FRVALID], + statistics[i][FRBROKEN], + statistics[i][FRREALBROKEN]); - fprintf(cvt, "set label 102 \"hit rates: A: %.3e B: %.3e C: %.3e D:%.3e\" at screen 0.4,0.01 left tc rgb \"#000044\" font \"monospace,8\"\n", - hitrates[0], - hitrates[1], - hitrates[2], - hitrates[3]); - fprintf(cvt, "set output '%s/%s_%08x.png';\n",picPath,mySystem,sensors[i]); - fprintf(cvt, "plot '-' matrix with image\n"); - - for(unsigned r = 0; r < 576; r++) { - for(unsigned c = 0; c < 1152; c++) { - fprintf(cvt,"%i ",pixelMap[i][r][c]); - } - fprintf(cvt,"\n"); + fprintf(cvt, "set label 102 \"hit rates: A: %.3e B: %.3e C: %.3e D:%.3e\" at screen 0.4,0.01 left tc rgb \"#000044\" font \"monospace,8\"\n", + hitrates[0], + hitrates[1], + hitrates[2], + hitrates[3]); + fprintf(cvt, "set output '%s/%s_%08x.png';\n",picPath,mySystem,sensors[i]); + fprintf(cvt, "plot '-' matrix with image\n"); + + for(unsigned r = 0; r < 576; r++) { + for(unsigned c = 0; c < 1152; c++) { + fprintf(cvt,"%d ",pixelMap[i][r][c]); } - - - fprintf(cvt, "e\n\n"); - if (!cvt) { - printf("couldn't open a pipe; quitting\n"); - exit(1); + fprintf(cvt,"\n"); } + + + fprintf(cvt, "e\n\n"); fflush(cvt); status=pclose(cvt); if (!WIFEXITED(status)) printf("error on closing the pipe\n");