#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), dataSize(dsize), numberofPacketsPerFrame(npf), xpixels(x),ypixels(y), xtalk(c), header_t(0), footer_t(0){ int **dMap; uint32_t **dMask; dMap=new int*[ypixels]; dMask=new uint32_t*[ypixels]; for (int i = 0; i < ypixels; i++) { dMap[i] = new int[xpixels]; dMask[i] = new uint32_t[xpixels]; } //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= dataSize){ 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==missingPacketValue){ // cprintf(RED,"missing packet\n"); return -1; } else 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;} //have to make the frame here itself as 1 frame will have less packets than trying to read char *readNextFrame(ifstream &filebin, int& fnum) { char *data=new char[packetSize*numberofPacketsPerFrame]; char *retval=0; int np=0, nd; fnum = -1; int pnum=-1; if (filebin.is_open()) { while (filebin.read(data+np*packetSize,packetSize)) { fnum = getFrameNumber(data); cout << "fnum:"<numberofPacketsPerFrame) { 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:"<