diff --git a/examples/moench03_T1_lab.config b/examples/moench03_T1_lab.config index a47d9080f..4886a7986 100644 --- a/examples/moench03_T1_lab.config +++ b/examples/moench03_T1_lab.config @@ -1,4 +1,4 @@ -hostname bchip011 +hostname bchip119 patword 0000 0000000000000000 patword 0001 0000000000000000 @@ -415,27 +415,45 @@ patwait2 0400 patwaittime2 0 +####mcp2011 +#0:rx_udpip 10.1.1.102 +#0:detectorip 10.1.1.19 +#0:rx_udpport 32410 +####gui listening to +#zmqip 129.129.202.131 +#zmqport 30001 +####data streaming out of +#rx_zmqip 10.1.2.103 +#rx_zmqport 30003 +#0:rx_hostname mpc2011 -0:rx_udpip 10.1.1.102 +####mx-test-1 +0:rx_udpip 10.1.1.120 0:detectorip 10.1.1.19 0:rx_udpport 32410 -#0:detectormac 00:ab:bc:cd:de:ef -#0:rx_udpmac 70:10:6f:a0:b5:b1 - -#gui listening to -zmqip 129.129.202.131 +####gui listening to (on receiver pc) +zmqip 129.129.202.146 zmqport 30001 - -#data streaming out of -rx_zmqip 10.1.2.103 +####data streaming out of +rx_zmqip 10.1.4.120 rx_zmqport 30003 +0:rx_hostname mx-test-1 + + + + + + + + + + #turn on datastream from commandline rx_datastream 1 r_readfreq 1 -0:rx_hostname mpc2011 #0:configuremac -1 rx_datastream 1 diff --git a/slsDetectorCalibration/analogDetector.h b/slsDetectorCalibration/analogDetector.h index 7db308b79..65eaa651c 100644 --- a/slsDetectorCalibration/analogDetector.h +++ b/slsDetectorCalibration/analogDetector.h @@ -221,8 +221,8 @@ template class analogDetector { if (gm) { if (gmap) delete [] gmap; gmap=new double[nnx*nny]; - for (int ix=0; ix class analogDetector { void *ret; if (gmap) { gm=new float[nx*ny]; - for (int ix=0; ix class analogDetector { virtual void addToCommonMode(char *data){ if (cmSub) { - for (int ix=xmin; ix0) if (det->isGood(ix,iy)) addToCommonMode(data, ix, iy); @@ -387,8 +387,8 @@ template class analogDetector { virtual double* getPedestal(double *ped){ if (ped==NULL) ped=new double[nx*ny]; - for (int ix=0; ix class analogDetector { virtual double* getPedestalRMS(double *ped=NULL){ if (ped==NULL) ped=new double[nx*ny]; - for (int ix=0; ix class analogDetector { */ virtual void setPedestal(double *ped, double *rms=NULL, int m=-1){ double rr=0; - for (int ix=xmin; ix class analogDetector { \param rms pointer to array of pedestal rms */ virtual void setPedestalRMS(double *rms){ - for (int ix=xmin; ix class analogDetector { #endif gm=new float[nx*ny]; - for (int ix=0; ixSetBinContent(ix+1, iy+1,image[iy*nx+ix]); @@ -546,8 +546,8 @@ template class analogDetector { TH2F *hmap=new TH2F("hmap","hmap",nx, -0.5,nx-0.5, ny, -0.5, ny-0.5); #endif - for (int ix=0; ixgetCommonMode(); */ /* else */ @@ -593,8 +593,8 @@ template class analogDetector { if (gm) { - for (int ix=0; ix class analogDetector { if (gm) { - for (int ix=0; ix class analogDetector { float *gm=NULL; void *ret; gm=new float[nx*ny]; - for (int ix=0; ix class analogDetector { if (nnx>nx) nnx=nx; if (nny>ny) nny=ny; if (gm) { - for (int ix=0; ix class analogDetector { //cout << xmin << " " << xmax << endl; // cout << ymin << " " << ymax << endl; - for (int ix=xmin; ixisGood(ix,iy)) { addToPedestal(data,ix,iy,1); //if (ix==10 && iy==10) @@ -823,8 +823,8 @@ template class analogDetector { if (val==NULL) val=image;//new double[nx*ny]; - for (int ix=xmin; ixisGood(ix,iy)) val[iy*nx+ix]+=subtractPedestal(data, ix, iy,cm); } @@ -951,8 +951,8 @@ template class analogDetector { addToCommonMode(data); - for (int ix=xmin; ixisGood(ix,iy)) nph[iy*nx+ix]+=getNPhotons(data, ix, iy); } @@ -966,8 +966,8 @@ template class analogDetector { */ virtual void clearImage(){ - for (int ix=0; ix class analogDetector { int SetNPedestals(int i=-1) { int ix=0, iy=0; if (i>0) - for (ix=0; ix class analogDetector { if (ymi<0) ymi=ymin; if (yma<0) yma=ymax; - for (int ix=xmi; ixisGood(ix,iy)) { if (ix>=0 && ix=0 && iy { private: - int iframe; + // int iframe; int nadc; int sc_width; int sc_height; const int nSamples; + const int offset; public: @@ -25,7 +25,7 @@ class moench03T1ZmqDataNew : public slsDetectorData { \param c crosstalk parameter for the output buffer */ - moench03T1ZmqDataNew(int ns=5000): slsDetectorData(400, 400, ns*32*2), nSamples(ns) { + moench03T1ZmqDataNew(int ns=5000): slsDetectorData(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)) { int nadc=32; int sc_width=25; @@ -37,7 +37,7 @@ class moench03T1ZmqDataNew : public slsDetectorData { 0,25,50,75,0,25,50,75}; int row, col; - + int isample; int iadc; int ix, iy; @@ -60,50 +60,48 @@ class moench03T1ZmqDataNew : public slsDetectorData { } else { row=200+i/sc_width; } - dataMap[row][col]=(nadc*i+iadc)*2;//+16*(ip+1); - if (dataMap[row][col]<0 || dataMap[row][col]>=nSamples*2*32) + dataMap[row][col]=(nadc*i+iadc)*2+offset;//+16*(ip+1); + if (dataMap[row][col]<0 || dataMap[row][col]>=dataSize) cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; } } } } - int ipacket; - int ibyte; + int ii=0; - for (int ipacket=0; ipacket { - int getFrameNumber(char *buff){return iframe;};//*((int*)(buff+5))&0xffffff;}; + int getFrameNumber(char *buff){return *((int*)buff);};//*((int*)(buff+5))&0xffffff;}; /** @@ -215,8 +213,8 @@ class moench03T1ZmqDataNew : public slsDetectorData { if (filebin.is_open()) { if (filebin.read(data, 32*2*nSamples) ){ - iframe++; - ff=iframe; + // iframe++; + //ff=iframe; return data; } } @@ -249,6 +247,8 @@ class moench03T1ZmqDataNew : public slsDetectorData { + // virtual int setFrameNumber(int ff){iframe=ff}; + diff --git a/slsDetectorCalibration/interpolatingDetector.h b/slsDetectorCalibration/interpolatingDetector.h index 6bad86bb6..f5ce437bd 100644 --- a/slsDetectorCalibration/interpolatingDetector.h +++ b/slsDetectorCalibration/interpolatingDetector.h @@ -178,7 +178,7 @@ int addFrame(char *data, int *ph=NULL, int ff=0) { double int_x, int_y; double eta_x, eta_y; if (interp) { - cout << "int" << endl; + // cout << "int" << endl; pthread_mutex_lock(fi); for (nph=0; nphprepareInterpolation(ok); pthread_mutex_unlock(fi); */ - cout << "det" << endl; + // cout << "det" << endl; return interp; }; diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.moench_zmq_rh7 b/slsDetectorCalibration/moenchExecutables/Makefile.moench_zmq_rh7 index 51187595f..89c794c17 100644 --- a/slsDetectorCalibration/moenchExecutables/Makefile.moench_zmq_rh7 +++ b/slsDetectorCalibration/moenchExecutables/Makefile.moench_zmq_rh7 @@ -1,7 +1,7 @@ ZMQLIB=../../slsReceiverSoftware/include INCDIR= -I$(ZMQLIB) -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/ -LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -L$(ZMQLIB) -O3 +LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -L$(ZMQLIB) -O3 -g #-L../../bin -lhdf5 -L. #DESTDIR?=../bin diff --git a/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp b/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp index 5ae6f937b..186b71c23 100644 --- a/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp +++ b/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp @@ -1,3 +1,5 @@ +#define WRITE_QUAD + #include "sls_receiver_defs.h" #include "ZmqSocket.h" #include "moench03T1ZmqDataNew.h" @@ -8,7 +10,6 @@ #include #include "tiffIO.h" - //#define NEWZMQ #ifdef NEWZMQ #include //json header in zmq stream @@ -25,10 +26,15 @@ #include "etaInterpolationPosXY.h" #include "ansi.h" #include + +//#include +#include // time_t +#include + using namespace std; +//using namespace std::chrono; - -#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2 +//#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2 // myDet->setNetworkParameter(ADDITIONAL_JSON_HEADER, " \"what\":\"nothing\" "); @@ -38,7 +44,7 @@ int main(int argc, char *argv[]) { * */ FILE *of=NULL; - int fifosize=1000; + int fifosize=5000; int etabins=1000;//nsubpix*2*100; double etamin=-1, etamax=2; // help @@ -58,7 +64,9 @@ int main(int argc, char *argv[]) { int ok; - + // high_resolution_clock::time_point t1; + // high_resolution_clock::time_point t2 ; + time_t begin,end,finished; @@ -283,13 +291,13 @@ int main(int argc, char *argv[]) { #ifdef NEWZMQ rapidjson::Document doc; if (!zmqsocket->ReceiveHeader(0, doc, SLS_DETECTOR_JSON_HEADER_VERSION)) { - zmqsocket->CloseHeaderMessage(); + /* zmqsocket->CloseHeaderMessage();*/ #endif // if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) { - cprintf(RED, "Got Dummy\n"); - - + // cprintf(RED, "Got Dummy\n"); + // t1=high_resolution_clock::now(); + time(&end); while (mt->isBusy()) {;}//wait until all data are processed from the queues @@ -413,6 +421,14 @@ int main(int argc, char *argv[]) { mt->clearImage(); newFrame=1; + //t2 = high_resolution_clock::now(); + + time(&finished); + // auto meas_duration = duration_cast( t2 - t0 ).count(); + // auto real_duration = duration_cast( t2 - t1 ).count(); + + cout << "Measurement lasted " << difftime(end,begin) << endl; + cout << "Processing lasted " << difftime(finished,begin) << endl; continue; //continue to not get out @@ -420,31 +436,29 @@ int main(int argc, char *argv[]) { #ifdef NEWZMQ if (newFrame) { - + time(&begin); + // t0 = high_resolution_clock::now(); + //cout <<"new frame" << endl; // acqIndex, frameIndex, subframeIndex, filename, fileindex size = doc["size"].GetUint(); - multisize = size;// * zmqsocket->size(); + // multisize = size;// * zmqsocket->size(); dynamicRange = doc["bitmode"].GetUint(); - nPixelsX = doc["shape"][0].GetUint(); - nPixelsY = doc["shape"][1].GetUint(); + // nPixelsX = doc["shape"][0].GetUint(); + // nPixelsY = doc["shape"][1].GetUint(); filename = doc["fname"].GetString(); - acqIndex = doc["acqIndex"].GetUint64(); - frameIndex = doc["fIndex"].GetUint64(); + //acqIndex = doc["acqIndex"].GetUint64(); + //frameIndex = doc["fIndex"].GetUint64(); fileindex = doc["fileIndex"].GetUint64(); - subFrameIndex = doc["expLength"].GetUint(); - xCoord = doc["xCoord"].GetUint(); - yCoord = doc["yCoord"].GetUint(); - zCoord = doc["zCoord"].GetUint(); - flippedDataX=doc["flippedDataX"].GetUint(); - packetNumber=doc["packetNumber"].GetUint(); - bunchId=doc["bunchId"].GetUint(); - timestamp=doc["timestamp"].GetUint(); - modId=doc["modId"].GetUint(); - debug=doc["debug"].GetUint(); - roundRNumber=doc["roundRNumber"].GetUint(); - detType=doc["detType"].GetUint(); - version=doc["version"].GetUint(); + //subFrameIndex = doc["expLength"].GetUint(); + //packetNumber=doc["packetNumber"].GetUint(); + //bunchId=doc["bunchId"].GetUint(); + //timestamp=doc["timestamp"].GetUint(); + //modId=doc["modId"].GetUint(); + //debug=doc["debug"].GetUint(); + //roundRNumber=doc["roundRNumber"].GetUint(); + //detType=doc["detType"].GetUint(); + //version=doc["version"].GetUint(); dataSize=size; @@ -636,7 +650,7 @@ int main(int argc, char *argv[]) { newFrame=0; - zmqsocket->CloseHeaderMessage(); + /* zmqsocket->CloseHeaderMessage();*/ } #endif @@ -656,11 +670,22 @@ int main(int argc, char *argv[]) { // cout << "data" << endl; // get data - length = zmqsocket->ReceiveData(0, buff, size); - mt->pushData(buff); - mt->nextThread(); - mt->popFree(buff); - + // acqIndex = doc["acqIndex"].GetUint64(); + frameIndex = doc["fIndex"].GetUint64(); + // subFrameIndex = doc["expLength"].GetUint(); + + // bunchId=doc["bunchId"].GetUint(); + // timestamp=doc["timestamp"].GetUint(); + packetNumber=doc["packetNumber"].GetUint(); + // cout << acqIndex << " " << frameIndex << " " << subFrameIndex << " "<< bunchId << " " << timestamp << " " << packetNumber << endl; + if (packetNumber>=40) { + //*((int*)buff)=frameIndex; + memcpy(buff,&frameIndex,sizeof(int)); + length = zmqsocket->ReceiveData(0, buff+sizeof(int), size); + mt->pushData(buff); + mt->nextThread(); + mt->popFree(buff); + } diff --git a/slsDetectorCalibration/multiThreadedAnalogDetector.h b/slsDetectorCalibration/multiThreadedAnalogDetector.h index 6fce26934..1f400819d 100644 --- a/slsDetectorCalibration/multiThreadedAnalogDetector.h +++ b/slsDetectorCalibration/multiThreadedAnalogDetector.h @@ -27,6 +27,7 @@ using namespace std; + class threadedAnalogDetector { public: @@ -35,12 +36,25 @@ public: det=d; fifoFree=new CircularFifo(fs); fifoData=new CircularFifo(fs); - mem=(char*)malloc(fs*det->getDataSize()); - // cout << "data size is " << det->getDataSize()*fs << endl; - for (int i=0; igetDataSize(); - fifoFree->push(mm); + + /* mem=(char*)calloc(fs, det->getDataSize()); */ + /* if (mem) */ + /* memset(mem,0, fs*det->getDataSize()); */ + int i; + for (i=0; igetDataSize(); + // cout << i << endl; + mm=(char*)calloc(1, det->getDataSize()); + if (mm) { + //memset(mm,0, det->getDataSize()); + fifoFree->push(mm); + } else + break; } + if (i { cout << "add to common mode?"<< endl; addToCommonMode(data); } - for (int ix=xmin; ixisGood(ix,iy)) { val=subtractPedestal(data,ix,iy, cm); @@ -236,8 +236,8 @@ public analogDetector { } } - for (int ix=xmin; ixisGood(ix,iy)) { eventMask[iy][ix]=PEDESTAL; @@ -276,7 +276,6 @@ public analogDetector { //} } } - } if (rest[iy][ix]>=max) { if (bl>=br && bl>=tl && bl>=tr) { @@ -324,6 +323,7 @@ public analogDetector { } } } + } } } else return getClusters(data, nph); } @@ -331,113 +331,6 @@ public analogDetector { }; - /* /\** finds event type for pixel and fills cluster structure. The algorithm loops only if the evenMask for this pixel is still undefined. */ - /* if pixel or cluster around it are above threshold (nsigma*pedestalRMS) cluster is filled and pixel mask is PHOTON_MAX (if maximum in cluster) or NEIGHBOUR; If PHOTON_MAX, the elements of the cluster are also set as NEIGHBOURs in order to speed up the looping */ - /* if below threshold the pixel is either marked as PEDESTAL (and added to the pedestal calculator) or NEGATIVE_PEDESTAL is case it's lower than -threshold, otherwise the pedestal average would drift to negative values while it should be 0. */ - - /* /param data pointer to the data */ - /* /param ix pixel x coordinate */ - /* /param iy pixel y coordinate */ - /* /param cm enable(1)/disable(0) common mode subtraction (if defined). */ - /* /returns event type for the given pixel */ - /* *\/ */ - /* eventType getEventType(char *data, int ix, int iy, int cm=0) { */ - - /* // eventType ret=PEDESTAL; */ - /* double max=0, tl=0, tr=0, bl=0,br=0, v; */ - /* // cout << iframe << endl; */ - - /* int cy=(clusterSizeY+1)/2; */ - /* int cs=(clusterSize+1)/2; */ - /* double val; */ - /* tot=0; */ - /* quadTot=0; */ - /* quad=UNDEFINED_QUADRANT; */ - - /* if (iframex=ix; */ - /* clusters->y=iy; */ - /* clusters->rms=getPedestalRMS(ix,iy); */ - /* clusters->ped=getPedestal(ix,iy, cm); */ - - - /* for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { */ - /* for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) { */ - /* if ((iy+ir)>=0 && (iy+ir)=0 && (ix+ic)set_data(v, ic, ir); */ - /* // v=clusters->get_data(ic,ir); */ - /* tot+=v; */ - /* if (ir<=0 && ic<=0) */ - /* bl+=v; */ - /* if (ir<=0 && ic>=0) */ - /* br+=v; */ - /* if (ir>=0 && ic<=0) */ - /* tl+=v; */ - /* if (ir>=0 && ic>=0) */ - /* tr+=v; */ - - /* if (v>max) { */ - /* max=v; */ - /* } */ - /* if (ir==0 && ic==0) { */ - /* if (v<-nSigma*clusters->rms) */ - /* eventMask[iy][ix]=NEGATIVE_PEDESTAL; */ - /* } */ - /* } */ - /* } */ - /* } */ - - /* if (bl>=br && bl>=tl && bl>=tr) { */ - /* quad=BOTTOM_LEFT; */ - /* quadTot=bl; */ - /* } else if (br>=bl && br>=tl && br>=tr) { */ - /* quad=BOTTOM_RIGHT; */ - /* quadTot=br; */ - /* } else if (tl>=br && tl>=bl && tl>=tr) { */ - /* quad=TOP_LEFT; */ - /* quadTot=tl; */ - /* } else if (tr>=bl && tr>=tl && tr>=br) { */ - /* quad=TOP_RIGHT; */ - /* quadTot=tr; */ - /* } */ - - /* if (max>nSigma*clusters->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*clusters->rms || quadTot>cy*cs*nSigma*clusters->rms) { */ - /* if (clusters->get_data(0,0)>=max) { */ - /* eventMask[iy][ix]=PHOTON_MAX; */ - /* } else { */ - /* eventMask[iy][ix]=PHOTON; */ - /* } */ - /* } else if (eventMask[iy][ix]==PEDESTAL) { */ - /* if (cm==0) { */ - /* if (det) */ - /* val=dataSign*det->getValue(data, ix, iy); */ - /* else */ - /* val=((double**)data)[iy][ix]; */ - /* addToPedestal(val,ix,iy); */ - /* } */ - /* } */ - - - - /* return eventMask[iy][ix]; */ - - /* }; */ @@ -477,8 +370,8 @@ int *getClusters(char *data, int *ph=NULL) { addToCommonMode(data); - for (int ix=xmin; ixisGood(ix,iy)) { max=0; tl=0; @@ -523,10 +416,14 @@ int *getClusters(char *data, int *ph=NULL) { if (ir==0 && ic==0) { if (*v<-nSigma*(clusters+nph)->rms) eventMask[iy][ix]=NEGATIVE_PEDESTAL; + else if (*v>nSigma*(clusters+nph)->rms) + eventMask[iy][ix]=PHOTON; } + } } - } + if (eventMask[iy][ix]==PHOTON && val[iy][ix]=br && bl>=tl && bl>=tr) { (clusters+nph)->quad=BOTTOM_LEFT; @@ -548,7 +445,8 @@ int *getClusters(char *data, int *ph=NULL) { (clusters+nph)->tot=tot; (clusters+nph)->x=ix; (clusters+nph)->y=iy; - (clusters+nph)->iframe=det->getFrameNumber(data); + // (clusters+nph)->iframe=det->getFrameNumber(data); + // cout << det->getFrameNumber(data) << " " << (clusters+nph)->iframe << endl; (clusters+nph)->ped=getPedestal(ix,iy,0); for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) { for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) { @@ -576,8 +474,8 @@ int *getClusters(char *data, int *ph=NULL) { nphFrame=nph; nphTot+=nph; //cout << nphFrame << endl; - // cout <<"**********************************"<< endl; - writeClusters(); + // cout <<"**********************************"<< det->getFrameNumber(data) << " " << nphFrame << endl; + writeClusters(det->getFrameNumber(data)); return image; }; @@ -662,13 +560,27 @@ int *getClusters(char *data, int *ph=NULL) { */ -static void writeClusters(FILE *f, single_photon_hit *clusters, int nph){for (int i=0; iwrite(f);}; -void writeClusters(FILE *f){for (int i=0; iwrite(f);}; - void writeClusters(){if (myFile) { + static void writeClusters(FILE *f, single_photon_hit *cl, int nph, int fn=0){ + +#ifndef OLDFORMAT + if (fwrite((void*)&fn, 1, sizeof(int), f)) + if (fwrite((void*)&nph, 1, sizeof(int), f)) +#endif + for (int i=0; iwrite(f); +}; + void writeClusters(FILE *f, int fn=0){ + writeClusters(f,clusters,nphFrame, fn); + //for (int i=0; iwrite(f); +}; + void writeClusters(int fn){ + if (myFile) { //cout << "++" << endl; pthread_mutex_lock(fm); - for (int i=0; iwrite(myFile); + // cout <<"**********************************"<< fn << " " << nphFrame << endl; + writeClusters(myFile,clusters,nphFrame, fn); + // for (int i=0; iwrite(myFile); pthread_mutex_unlock(fm); //cout << "--" << endl; } diff --git a/slsDetectorCalibration/single_photon_hit.h b/slsDetectorCalibration/single_photon_hit.h index 696868b87..23dbe6dc0 100644 --- a/slsDetectorCalibration/single_photon_hit.h +++ b/slsDetectorCalibration/single_photon_hit.h @@ -38,8 +38,60 @@ class single_photon_hit { size_t write(FILE *myFile) { //fwrite((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile); - if (fwrite((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile)) + // if (fwrite((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile)) +#ifdef OLDFORMAT + if (fwrite((void*)&iframe, 1, sizeof(int), myFile)) +#endif +#ifndef WRITE_QUAD + if (fwrite((void*)&x, 2, sizeof(int16_t), myFile)) return fwrite((void*)data, 1, dx*dy*sizeof(int), myFile); +#endif +#ifdef WRITE_QUAD + int qq[4]; + switch(quad) { + case TOP_LEFT: + qq[0]=data[3]; + qq[1]=data[4]; + qq[2]=data[6]; + qq[3]=data[7]; + x=x-1; + y=y; + break; + + case TOP_RIGHT: + qq[0]=data[4]; + qq[1]=data[5]; + qq[2]=data[7]; + qq[3]=data[8]; + x=x; + y=y; + break; + + + case BOTTOM_LEFT: + qq[0]=data[0]; + qq[1]=data[1]; + qq[2]=data[3]; + qq[3]=data[4]; + x=x-1; + y=y-1; + break; + case BOTTOM_RIGHT: + qq[0]=data[1]; + qq[1]=data[2]; + qq[2]=data[4]; + qq[3]=data[5]; + x=x; + y=y-1; + break; + + + default: + ; + } + if (fwrite((void*)&x, 2, sizeof(int16_t), myFile)) + return fwrite((void*)qq, 1, 4*sizeof(int), myFile); +#endif return 0; }; @@ -50,8 +102,83 @@ class single_photon_hit { size_t read(FILE *myFile) { //fread((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile); - if (fread((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile)) +#ifdef OLDFORMAT + if (fread((void*)&iframe, 1, sizeof(int), myFile)) +#endif +#ifndef WRITE_QUAD + if (fread((void*)&x, 2, sizeof(int16_t), myFile)) return fread((void*)data, 1, dx*dy*sizeof(int), myFile); +#endif +#ifdef WRITE_QUAD + int qq[4]; + if (fread((void*)&x, 2, sizeof(int16_t), myFile)) + if (fread((void*)qq, 1, 4*sizeof(int), myFile)) { + + switch(quad) { + case TOP_LEFT: + data[0]=0; + data[1]=0; + data[2]=0; + data[3]=qq[0]; + data[4]=qq[1]; + data[5]=0; + data[6]=qq[2]; + data[7]=qq[3]; + data[8]=0; + x=x+1; + y=y; + break; + + case TOP_RIGHT: + data[0]=0; + data[1]=0; + data[2]=0; + data[3]=0; + data[4]=qq[0]; + data[5]=qq[1]; + data[6]=0; + data[7]=qq[2]; + data[8]=qq[3]; + x=x; + y=y; + break; + + + case BOTTOM_LEFT: + data[0]=qq[0]; + data[1]=qq[1]; + data[2]=0; + data[3]=qq[2]; + data[4]=qq[3]; + data[5]=0; + data[6]=0; + data[7]=0; + data[8]=0; + x=x+1; + y=y+1; + break; + case BOTTOM_RIGHT: + data[0]=0; + data[1]=qq[0]; + data[2]=qq[1]; + data[3]=0; + data[4]=qq[2]; + data[5]=qq[3]; + data[6]=0; + data[7]=0; + data[8]=0; + x=x; + y=y+1; + break; + + + default: + ; + } + return 1; + } +#endif + return 0; }; diff --git a/slsDetectorCalibration/slsDetectorData.h b/slsDetectorCalibration/slsDetectorData.h index 16b1c9767..912573f3b 100644 --- a/slsDetectorCalibration/slsDetectorData.h +++ b/slsDetectorCalibration/slsDetectorData.h @@ -331,8 +331,6 @@ class slsDetectorData { */ virtual char *readNextFrame(ifstream &filebin)=0; - - };