From a6d9f681d8dfd7e81613e39565f577d044c3dc5c Mon Sep 17 00:00:00 2001 From: Dhanya Maliakal Date: Fri, 14 Oct 2016 16:07:51 +0200 Subject: [PATCH] works for missing packets and image reconstruction --- slsDetectorCalibration/eigerHalfModuleData.h | 246 +++++++++++++------ slsDetectorCalibration/slsReceiverData.h | 5 +- 2 files changed, 178 insertions(+), 73 deletions(-) diff --git a/slsDetectorCalibration/eigerHalfModuleData.h b/slsDetectorCalibration/eigerHalfModuleData.h index a022c2920..c9087e8a7 100644 --- a/slsDetectorCalibration/eigerHalfModuleData.h +++ b/slsDetectorCalibration/eigerHalfModuleData.h @@ -23,8 +23,7 @@ public: slsReceiverData(x, y, npf, psize), top(t), left(l), dynamicRange(dr), tenGiga(tg), - packetSize(psize), dataSize(dsize), numberofPacketsPerFrame(npf), - xpixels(x),ypixels(y), + packetSize(psize), onepacketdataSize(dsize), numberofPacketsPerFrame(npf), xtalk(c), header_t(0), footer_t(0){ @@ -32,13 +31,13 @@ public: int **dMap; uint32_t **dMask; - dMap=new int*[ypixels]; - dMask=new uint32_t*[ypixels]; + dMap=new int*[ny]; + dMask=new uint32_t*[ny]; - for (int i = 0; i < ypixels; i++) { - dMap[i] = new int[xpixels]; - dMask[i] = new uint32_t[xpixels]; + for (int i = 0; i < ny; i++) { + dMap[i] = new int[nx]; + dMask[i] = new uint32_t[nx]; } //Map @@ -53,13 +52,13 @@ public: } if(top){ - for (int ir=0; ir= dataSize){ + if(iData >= onepacketdataSize){ iPacket += 16; iData = 0; } @@ -82,8 +81,8 @@ public: if((dynamicRange == 32) && (!tenGiga)) iPacket -= 16; - for (int ir=0; irpacketnum)); }; @@ -222,14 +221,10 @@ public: header_t = (eiger_packet_header_t*)((char*)(data +(dataMap[newiy][newix]-8))); uint16_t identifier = (uint16_t)*( (uint16_t*) header_t->missingpacket); - if(identifier==missingPacketValue){ - // cprintf(RED,"missing packet\n"); - return -1; + if(identifier==deactivatedPacketValue){ + // cprintf(RED,"deactivated packet\n"); + return -2; } - else if(identifier==deactivatedPacketValue){ - // cprintf(RED,"deactivated packet\n"); - return -2; - } // -----END OF CHECK ------------------------------------------------------------- @@ -268,80 +263,187 @@ public: */ double getXTalk() {return xtalk;} + void getChannelArray(double* data, char* buffer){ + for(int iy = 0; iy < ny; iy++){ + for(int ix = 0; ix < nx; ix++){ + data[iy*nx+ix] = getValue((char*)buffer,ix,iy); + //cprintf(BLUE,"%d,%d :%f\n",ix,iy,value); + } + } + } - //have to make the frame here itself as 1 frame will have less packets than trying to read - char *readNextFrame(ifstream &filebin, int& fnum) { + int* decodeData(int *datain) { - char *data=new char[packetSize*numberofPacketsPerFrame]; - char *retval=0; - int np=0, nd; + int dataBytes = numberofPacketsPerFrame * onepacketdataSize; + int nch = nx*ny; + int* dataout = new int [nch]; + char *ptr=(char*)datain; + char iptr; + + const int bytesize=8; + int ival=0; + int ipos=0, ichan=0, ibyte; + + switch (dynamicRange) { + case 4: + for (ibyte=0; ibyte>(ipos*4))&0xf; //pick the right 4bit + dataout[ichan]=ival; + ichan++; + } + } + break; + case 8: + for (ichan=0; ichannumberofPacketsPerFrame) { - cout << "too many packets!!!!!!!!!!" << endl; - delete [] data; - return NULL; - } else if (retval!=NULL) { - // cout << "+" << endl;; - for (int ip=0; ipnumberofPacketsPerFrame) { - cout << "*******too many packets!!!!!!!!!!" << endl; - delete [] data; - return NULL; - } else { - // cout << "." << endl;; - np++; - cout<<"np:"<