#ifndef EIGERMODULEDATA_H #define EIGERMODULEDATA_H #include "slsReceiverData.h" class eigerHalfModuleData : public slsReceiverData { public: /** Implements the slsReceiverData structure for the eiger prototype read out by a half module i.e. using the slsReceiver (256*256 pixels, 512 packets for 16 bit mode, 256 for 8, 128 for 4, 1024 for 32, 1040 etc.) \param d dynamic range \param c crosstalk parameter for the output buffer */ eigerHalfModuleData(bool t, bool l, int dr, int tg, int psize, int dsize, int npf, int x, int y, double c=0): slsReceiverData(x, y, npf, psize), top(t), left(l), dynamicRange(dr), tenGiga(tg), packetSize(psize), onepacketdataSize(dsize), numberofPacketsPerFrame(npf), xtalk(c), header_t(0), footer_t(0){ int **dMap; uint32_t **dMask; dMap=new int*[ny]; dMask=new uint32_t*[ny]; for (int i = 0; i < ny; i++) { dMap[i] = new int[nx]; dMask[i] = new uint32_t[nx]; } //Map int totalNumberOfBytes = numberofPacketsPerFrame * packetSize; int iPacket = 8; int iData = 0; int increment = (dynamicRange/8); int ic_increment = 1; if (dynamicRange == 4) { increment = 1; ic_increment = 2; } if(top){ for (int ir=0; ir= onepacketdataSize){ iPacket += 16; iData = 0; } } } } //bottom else{ iData = 0; int numbytesperline; switch(dynamicRange){ case 4: numbytesperline = 256; break; case 8: numbytesperline = 512; break; case 16:numbytesperline = 1024; break; case 32:numbytesperline = 2048; break; } iPacket = totalNumberOfBytes - numbytesperline - 8; if((dynamicRange == 32) && (!tenGiga)) iPacket -= 16; for (int ir=0; irpacketnum)); }; /** returns the pixel value as double correcting for the output buffer crosstalk \param data pointer to the memory \param ix coordinate in the x direction \param iy coordinate in the y direction \returns channel value as double */ double getValue(char *data, int ix, int iy=0) { // cout << "##" << (void*)data << " " << ix << " " <=0 && ix=0 && iy=0 && dataMap[iy][ix]missingpacket); if(identifier==deactivatedPacketValue){ // cprintf(RED,"deactivated packet\n"); return -2; } // -----END OF CHECK ------------------------------------------------------------- }else{ cprintf(RED,"outside limits\n"); return -99; } //get proper data n = ((uint32_t)(*((uint32_t*)(((char*)data)+(dataMap[iy][ix]))))); //each byte is shared by 2 pixels for 4 bit mode if(dynamicRange == 4){ if(ix != origX) return ((n & 0xf0)>>4)^m; return (n & 0xf)^m; } else if(dynamicRange == 8) return (n & 0xff)^m; else if(dynamicRange == 16) return (n & 0xffff)^m; else return (n & 0xffffffff)^m; }; /** sets the output buffer crosstalk correction parameter \param c output buffer crosstalk correction parameter to be set \returns current value for the output buffer crosstalk correction parameter */ double setXTalk(double c) {xtalk=c; return xtalk;} /** gets the output buffer crosstalk parameter \returns current value for the output buffer crosstalk correction parameter */ 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); } } } int* decodeData(int *datain) { 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; ichan