mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 12:57:13 +02:00
fixed slsDeetctorcalibration - including interpolation for rectangular pixels
This commit is contained in:
@ -7,7 +7,12 @@
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
#include "ZmqSocket.h"
|
||||
#ifndef RECT
|
||||
#include "moench03T1ZmqDataNew.h"
|
||||
#endif
|
||||
#ifdef RECT
|
||||
#include "moench03T1ZmqDataNewRect.h"
|
||||
#endif
|
||||
#include "moench03GhostSummation.h"
|
||||
#include "moench03CommonMode.h"
|
||||
#include <vector>
|
||||
@ -49,10 +54,11 @@ int main(int argc, char *argv[]) {
|
||||
*/
|
||||
FILE *of=NULL;
|
||||
int fifosize=5000;
|
||||
int etabins=1000;//nsubpix*2*100;
|
||||
int etabins=1000, etabinsy=1000;//nsubpix*2*100;
|
||||
double etamin=-1, etamax=2;
|
||||
int nSubPixels=2;
|
||||
int nSubPixelsX=2;
|
||||
// int emin, emax;
|
||||
int nSubPixelsY=2;
|
||||
// help
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number] [nthreads] [nsubpix] [gainmap] [etafile]\n");
|
||||
@ -75,13 +81,7 @@ int main(int argc, char *argv[]) {
|
||||
// high_resolution_clock::time_point t2 ;
|
||||
time_t begin,end,finished;
|
||||
int rms=0;
|
||||
|
||||
int nped=1000, nped0=100;
|
||||
|
||||
#ifdef PTC
|
||||
nped=10000;
|
||||
nped0=10000;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
if (argc > 4) {
|
||||
@ -101,10 +101,14 @@ int main(int argc, char *argv[]) {
|
||||
nthreads=atoi(argv[5]);
|
||||
|
||||
cout << "Number of threads is: " << nthreads << endl;
|
||||
if (argc>6)
|
||||
nSubPixels=atoi(argv[6]);
|
||||
cout << "Number of subpixels is: " << nSubPixels << endl;
|
||||
|
||||
if (argc>6) {
|
||||
nSubPixelsX=atoi(argv[6]);
|
||||
nSubPixelsY=nSubPixelsX;
|
||||
#ifdef RECT
|
||||
nSubPixelsX=2;
|
||||
#endif
|
||||
}
|
||||
cout << "Number of subpixels is: " << nSubPixelsX << " " << nSubPixelsY << endl;
|
||||
|
||||
char *gainfname=NULL;
|
||||
if (argc>7) {
|
||||
@ -119,12 +123,12 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew(5000,sizeof(int));
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||
cout << endl << " det" <<endl;
|
||||
int npx, npy;
|
||||
det->getDetectorSize(npx, npy);
|
||||
|
||||
|
||||
int send_something=0;
|
||||
|
||||
|
||||
int maxSize = npx*npy*2;//32*2*8192;//5000;//atoi(argv[3]);
|
||||
@ -137,15 +141,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
int ncol_cm=CM_ROWS;
|
||||
double xt_ghost=C_GHOST;
|
||||
|
||||
|
||||
moench03CommonMode *cm=NULL;
|
||||
moench03GhostSummation *gs=NULL;
|
||||
#ifdef CORR
|
||||
cm=new moench03CommonMode(ncol_cm);
|
||||
gs=new moench03GhostSummation(det, xt_ghost);
|
||||
#endif
|
||||
|
||||
moench03CommonMode *cm=new moench03CommonMode(ncol_cm);
|
||||
moench03GhostSummation *gs=new moench03GhostSummation(det, xt_ghost);
|
||||
double *gainmap=NULL;
|
||||
float *gm;
|
||||
double *gmap=NULL;
|
||||
@ -173,18 +170,18 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
|
||||
#ifndef INTERP
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(det,3, nSigma, 1, cm, nped, nped0, -1, -1, gainmap, gs);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(det,3, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs);
|
||||
|
||||
multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize);
|
||||
|
||||
// multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
#endif
|
||||
#ifdef INTERP
|
||||
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(npx, npy, nSubPixels, etabins, etamin, etamax);
|
||||
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(npx, npy, nSubPixelsX,nSubPixelsY, etabins, etabinsy, etamin, etamax);
|
||||
|
||||
if (etafname) interp->readFlatField(etafname);
|
||||
|
||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, nSigma, 1, cm, nped, nped0, -1, -1, gainmap, gs);
|
||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs);
|
||||
multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize);
|
||||
#endif
|
||||
|
||||
@ -275,7 +272,17 @@ int main(int argc, char *argv[]) {
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
//uint32_t subFrameIndex = -1;
|
||||
#ifdef MOENCH_BRANCH
|
||||
uint32_t subFrameIndex = -1;
|
||||
int* flippedData = 0;
|
||||
#endif
|
||||
|
||||
uint64_t subframes=0;
|
||||
//uint64_t isubframe=0;
|
||||
uint64_t insubframe=0;
|
||||
double subnorm=1;
|
||||
uint64_t f0=-1, nsubframes=0, nnsubframe=0;
|
||||
|
||||
uint64_t fileindex = -1;
|
||||
string filename = "";
|
||||
// char* image = new char[size];
|
||||
@ -285,10 +292,10 @@ int main(int argc, char *argv[]) {
|
||||
int iframe=0;
|
||||
char ofname[10000];
|
||||
|
||||
char fname[10000];
|
||||
string fname;
|
||||
// int length;
|
||||
int *detimage;
|
||||
int nnx, nny,nns;
|
||||
int *detimage=NULL;
|
||||
int nnx, nny,nnsx, nnsy;
|
||||
//uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0,
|
||||
//uint32_t dynamicRange = 0;
|
||||
// infinite loop
|
||||
@ -304,12 +311,11 @@ int main(int argc, char *argv[]) {
|
||||
//int16_t *dout;//=new int16_t [nnx*nny];
|
||||
uint32_t dr = 32;
|
||||
int32_t *dout=NULL;//=new int32_t [nnx*nny];
|
||||
float *doutf=NULL;//=new int32_t [nnx*nny];
|
||||
uint16_t roundRNumber = 0;
|
||||
uint8_t detType = 0;
|
||||
uint8_t version = 0;
|
||||
// int* flippedData = 0;
|
||||
string* additionalJsonHeader = 0;
|
||||
//char* additionalJsonHeader = 0;
|
||||
string additionalJsonHeader="" ;
|
||||
|
||||
int32_t threshold=0;
|
||||
|
||||
@ -327,7 +333,7 @@ int main(int argc, char *argv[]) {
|
||||
frameMode fMode=eFrame;
|
||||
double *ped;
|
||||
|
||||
filter->getImageSize(nnx, nny,nns);
|
||||
filter->getImageSize(nnx, nny,nnsx, nnsy);
|
||||
|
||||
|
||||
|
||||
@ -368,40 +374,75 @@ int main(int argc, char *argv[]) {
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
}
|
||||
} else {
|
||||
if (fMode==ePedestal) {
|
||||
sprintf(ofname,"%s_%ld_ped.tiff",fname,fileindex);
|
||||
mt->writePedestal(ofname);
|
||||
cout << "Writing pedestal to " << ofname << endl;
|
||||
if (rms) {
|
||||
sprintf(ofname,"%s_%ld_var.tiff",fname,fileindex);
|
||||
mt->writePedestalRMS(ofname);
|
||||
cout << "Writing pedestal variance to " << ofname << endl;
|
||||
}
|
||||
}
|
||||
send_something=0;
|
||||
if (fMode==ePedestal) {
|
||||
sprintf(ofname,"%s_%ld_ped.tiff",fname.c_str(),fileindex);
|
||||
mt->writePedestal(ofname);
|
||||
cout << "Writing pedestal to " << ofname << endl;
|
||||
if (rms){
|
||||
sprintf(ofname,"%s_%ld_var.tiff",fname.c_str(),fileindex);
|
||||
mt->writePedestalRMS(ofname);
|
||||
|
||||
}
|
||||
send_something=1;
|
||||
}
|
||||
#ifdef INTERP
|
||||
else if (fMode==eFlat) {
|
||||
mt->prepareInterpolation(ok);
|
||||
sprintf(ofname,"%s_%ld_eta.tiff",fname,fileindex);
|
||||
mt->writeFlatField(ofname);
|
||||
cout << "Writing eta to " << ofname << endl;
|
||||
}
|
||||
else if (fMode==eFlat) {
|
||||
mt->prepareInterpolation(ok);
|
||||
sprintf(ofname,"%s_%ld_eta.tiff",fname.c_str(),fileindex);
|
||||
mt->writeFlatField(ofname);
|
||||
cout << "Writing eta to " << ofname << endl;
|
||||
send_something=1;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
sprintf(ofname,"%s_%ld.tiff",fname,fileindex);
|
||||
mt->writeImage(ofname);
|
||||
cout << "Writing image to " << ofname << endl;
|
||||
}
|
||||
// cout << nns*nnx*nny*nns*dr/8 << " " << length << endl;
|
||||
else {
|
||||
if (subframes>0 ) {
|
||||
if (insubframe>0) {
|
||||
sprintf(ofname,"%s_sf%ld_%ld.tiff",fname.c_str(),nnsubframe,fileindex);
|
||||
// mt->writeImage(ofname);
|
||||
doutf= new float[nnx*nny];
|
||||
if (subframes>0 && insubframe!=subframes && insubframe>0)
|
||||
subnorm=((double)subframes)/((double)insubframe);
|
||||
else
|
||||
subnorm=1.;
|
||||
for (int ix=0; ix<nnx*nny; ix++) {
|
||||
doutf[ix]=detimage[ix]*subnorm;
|
||||
if (doutf[ix]<0) doutf[ix]=0;
|
||||
}
|
||||
|
||||
cout << "Writing image to " << ofname << endl;
|
||||
|
||||
WriteToTiff(doutf,ofname ,nnx, nny);
|
||||
|
||||
if (doutf)
|
||||
delete [] doutf;
|
||||
doutf=NULL;
|
||||
|
||||
nsubframes++;
|
||||
insubframe=0;
|
||||
send_something=1;
|
||||
}
|
||||
} else {
|
||||
sprintf(ofname,"%s_%ld.tiff",fname.c_str(),fileindex);
|
||||
mt->writeImage(ofname);
|
||||
send_something=1;
|
||||
}
|
||||
|
||||
cout << "Writing image to " << ofname << endl;
|
||||
}
|
||||
// cout << nns*nnx*nny*nns*dr/8 << " " << length << endl;
|
||||
|
||||
if (send) {
|
||||
|
||||
|
||||
if (fMode==ePedestal) {
|
||||
cprintf(MAGENTA,"Get pedestal!\n");
|
||||
nns=1;
|
||||
nnsx=1;
|
||||
nnsy=1;
|
||||
|
||||
nnx=npx;
|
||||
nny=npy;
|
||||
//dout= new int16_t[nnx*nny*nns*nns];
|
||||
dout= new int32_t[nnx*nny*nns*nns];
|
||||
dout= new int32_t[nnx*nny*nnsx*nnsy];
|
||||
// cout << "get pedestal " << endl;
|
||||
ped=mt->getPedestal();
|
||||
// cout << "got pedestal " << endl;
|
||||
@ -409,7 +450,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
dout[ix]=ped[ix];
|
||||
// if (ix<100*400)
|
||||
// cout << ix << " " << ped[ix] << " "<< dout[ix] << endl;
|
||||
// cout << ix << " " << ped[ix] << endl;
|
||||
}
|
||||
|
||||
}
|
||||
@ -427,15 +468,19 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
detimage=mt->getImage(nnx,nny,nns);
|
||||
detimage=mt->getImage(nnx,nny,nnsx, nnsy);
|
||||
cprintf(MAGENTA,"Get image!\n");
|
||||
cout << nnx << " " << nny << " " << nns << endl;
|
||||
cout << nnx << " " << nny << " " << nnsx << " " << nnsy << endl;
|
||||
// nns=1;
|
||||
// nnx=npx;
|
||||
// nny=npy;
|
||||
// nnx=nnx*nns;
|
||||
//nny=nny*nns;
|
||||
dout= new int32_t[nnx*nny];
|
||||
if (subframes>0 && insubframe!=subframes && insubframe>0)
|
||||
subnorm=((double)subframes)/((double)insubframe);
|
||||
else
|
||||
subnorm=1.;
|
||||
for (int ix=0; ix<nnx*nny; ix++) {
|
||||
// for (int iy=0; iy<nny*nns; iy++) {
|
||||
// for (int isx=0; isx<nns; isx++) {
|
||||
@ -447,53 +492,29 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// }
|
||||
// }
|
||||
dout[ix]=detimage[ix];
|
||||
if (dout[ix]<0) dout[ix]=0;
|
||||
//cout << ix << " " << dout[ix] << endl;
|
||||
dout[ix]=detimage[ix]*subnorm;
|
||||
if (dout[ix]<0) dout[ix]=0;
|
||||
// cout << ix << " " << dout[ix] << endl;
|
||||
// }
|
||||
}
|
||||
}
|
||||
//if ((insubframe>0 && subframes>0) || (subframes<=0) ){
|
||||
|
||||
|
||||
//// int SendHeaderData ( int index, bool dummy, uint32_t jsonversion, uint32_t dynamicrange = 0, uint64_t fileIndex = 0,
|
||||
// uint32_t ndetx = 0, uint32_t ndety = 0, uint32_t npixelsx = 0, uint32_t npixelsy = 0, uint32_t imageSize = 0,
|
||||
// uint64_t acqIndex = 0, uint64_t fIndex = 0, const char* fname = NULL,
|
||||
// uint64_t frameNumber = 0, uint32_t expLength = 0, uint32_t packetNumber = 0,
|
||||
// uint64_t bunchId = 0, uint64_t timestamp = 0,
|
||||
// uint16_t modId = 0, uint16_t row = 0, uint16_t column = 0, uint16_t reserved = 0,
|
||||
// uint32_t debug = 0, uint16_t roundRNumber = 0,
|
||||
// uint8_t detType = 0, uint8_t version = 0, int gapPixelsEnable = 0, int flippedDataX = 0,
|
||||
// char* additionalJsonHeader = 0) {
|
||||
|
||||
|
||||
|
||||
// cout << "Sending image size " << nnx << " " << nny << endl;
|
||||
|
||||
// #ifndef DEVELOPER
|
||||
// #ifndef MOENCH_BRANCH
|
||||
// zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, 1,1, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex,0 , packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, additionalJsonHeader);
|
||||
// #endif
|
||||
// #endif
|
||||
|
||||
|
||||
// #ifdef DEVELOPER
|
||||
// #ifdef CTBGUI
|
||||
// zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
|
||||
// #endif
|
||||
// #ifndef CTBGUI
|
||||
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 1,1,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
|
||||
//#endif
|
||||
|
||||
|
||||
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
|
||||
cprintf(GREEN, "Sent Data\n");
|
||||
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
if (dout)
|
||||
delete [] dout;
|
||||
dout=NULL;
|
||||
|
||||
if(send_something) {
|
||||
|
||||
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 1,1,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,&additionalJsonHeader);
|
||||
|
||||
|
||||
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
|
||||
cprintf(GREEN, "Sent Data\n");
|
||||
}
|
||||
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
if (dout)
|
||||
delete [] dout;
|
||||
dout=NULL;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -541,8 +562,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
//dataSize=size;
|
||||
|
||||
strcpy(fname,filename.c_str());
|
||||
|
||||
//strcpy(fname,filename.c_str());
|
||||
fname=filename;
|
||||
// cprintf(BLUE, "Header Info:\n"
|
||||
// "size: %u\n"
|
||||
// "multisize: %u\n"
|
||||
@ -585,7 +606,7 @@ int main(int argc, char *argv[]) {
|
||||
if (frameMode_s == "pedestal"){
|
||||
fMode=ePedestal;
|
||||
//isPedestal=1;
|
||||
} else if (frameMode_s == "newpedestal"){
|
||||
} else if (frameMode_s == "newPedestal"){
|
||||
mt->newDataSet(); //resets pedestal
|
||||
// cprintf(MAGENTA, "Resetting pedestal\n");
|
||||
fMode=ePedestal;
|
||||
@ -594,8 +615,8 @@ int main(int argc, char *argv[]) {
|
||||
mt->newDataSet(); //resets pedestal
|
||||
// cprintf(MAGENTA, "Resetting pedestal\n");
|
||||
fMode=ePedestal;
|
||||
rms=1;
|
||||
//isPedestal=1;
|
||||
rms=1;
|
||||
}
|
||||
#ifdef INTERP
|
||||
else if (frameMode_s == "flatfield") {
|
||||
@ -616,13 +637,11 @@ int main(int argc, char *argv[]) {
|
||||
frameMode_s="frame";
|
||||
}
|
||||
}
|
||||
cprintf(MAGENTA, "%s\n" , frameMode_s.c_str());
|
||||
} else
|
||||
cprintf(RED, "%s\n" , frameMode_s.c_str());
|
||||
|
||||
}
|
||||
cprintf(MAGENTA, "%s\n" , frameMode_s.c_str());
|
||||
mt->setFrameMode(fMode);
|
||||
|
||||
threshold=0;
|
||||
// threshold=0;
|
||||
cprintf(MAGENTA, "Threshold: ");
|
||||
if (doc.HasMember("threshold")) {
|
||||
if (doc["threshold"].IsInt()) {
|
||||
@ -690,11 +709,10 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
|
||||
} else
|
||||
cprintf(RED, "%s\n" , frameMode_s.c_str());
|
||||
}
|
||||
|
||||
mt->setDetectorMode(dMode);
|
||||
cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
|
||||
|
||||
// cout << "done " << endl;
|
||||
|
||||
@ -737,6 +755,21 @@ int main(int argc, char *argv[]) {
|
||||
// mt->setNSubPixels(nSubPixels);
|
||||
// }
|
||||
|
||||
// threshold=0;
|
||||
cprintf(MAGENTA, "Subframes: ");
|
||||
subframes=0;
|
||||
//isubframe=0;
|
||||
insubframe=0;
|
||||
subnorm=1;
|
||||
f0=0;
|
||||
nnsubframe=0;
|
||||
if (doc.HasMember("subframes")) {
|
||||
if (doc["subframes"].IsInt()) {
|
||||
subframes=doc["subframes"].GetInt();
|
||||
}
|
||||
}
|
||||
cprintf(MAGENTA, "%ld\n", subframes);
|
||||
|
||||
|
||||
newFrame=0;
|
||||
/* zmqsocket->CloseHeaderMessage();*/
|
||||
@ -745,7 +778,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// cout << "file" << endl;
|
||||
// cout << "data " << endl;
|
||||
if (of==NULL && dMode!=eAnalog && fMode!=ePedestal && threshold<=0) {
|
||||
if (of==NULL) {
|
||||
#ifdef WRITE_QUAD
|
||||
sprintf(ofname,"%s_%ld.clust2",filename.c_str(),fileindex);
|
||||
#endif
|
||||
@ -760,33 +793,98 @@ int main(int argc, char *argv[]) {
|
||||
mt->setFilePointer(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// cout << "data" << endl;
|
||||
// get data
|
||||
// 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);
|
||||
cprintf(GREEN, "Frame\n");
|
||||
} else {
|
||||
cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber);
|
||||
//length =
|
||||
zmqsocket->ReceiveData(0, dummybuff, size);
|
||||
packetNumber=doc["packetNumber"].GetUint();
|
||||
// cout << acqIndex << " " << frameIndex << " " << subFrameIndex << " "<< bunchId << " " << timestamp << " " << packetNumber << endl;
|
||||
if (packetNumber>=40) {
|
||||
//*((int*)buff)=frameIndex;
|
||||
if (insubframe==0) f0=frameIndex;
|
||||
memcpy(buff,&frameIndex,sizeof(int));
|
||||
//length =
|
||||
zmqsocket->ReceiveData(0, buff+sizeof(int), size);
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
insubframe++;
|
||||
nsubframes=frameIndex+1-f0;
|
||||
} else {
|
||||
cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber);
|
||||
//length =
|
||||
zmqsocket->ReceiveData(0, dummybuff, size);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (subframes>0 && insubframe>=subframes && fMode==eFrame) {
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
detimage=mt->getImage(nnx,nny,nnsx, nnsy);
|
||||
cprintf(MAGENTA,"Get image!\n");
|
||||
dout= new int32_t[nnx*nny];
|
||||
doutf= new float[nnx*nny];
|
||||
if (subframes>0 && insubframe!=subframes && insubframe>0)
|
||||
subnorm=((double)subframes)/((double)insubframe);
|
||||
else
|
||||
subnorm=1.;
|
||||
for (int ix=0; ix<nnx*nny; ix++) {
|
||||
dout[ix]=detimage[ix]*subnorm;
|
||||
if (dout[ix]<0) dout[ix]=0;
|
||||
doutf[ix]=dout[ix];
|
||||
}
|
||||
sprintf(ofname,"%s_sf%ld_%ld.tiff",fname.c_str(),nnsubframe,fileindex);
|
||||
|
||||
cout << "Writing image to " << ofname << endl;
|
||||
|
||||
WriteToTiff(doutf,ofname ,nnx, nny);
|
||||
nsubframes++;
|
||||
insubframe=0;
|
||||
nnsubframe++;
|
||||
|
||||
|
||||
|
||||
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 1,1,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,&additionalJsonHeader);
|
||||
|
||||
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
|
||||
cprintf(GREEN, "Sent subdata\n");
|
||||
|
||||
|
||||
if (dout)
|
||||
delete [] dout;
|
||||
dout=NULL;
|
||||
|
||||
if (doutf)
|
||||
delete [] doutf;
|
||||
doutf=NULL;
|
||||
|
||||
mt->clearImage();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
iframe++;
|
||||
|
||||
} // exiting infinite loop
|
||||
|
Reference in New Issue
Block a user