mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-20 02:40:03 +02:00
reordered moenchExecutables
This commit is contained in:
parent
44fdc46c11
commit
df75fef6f6
@ -6,7 +6,7 @@
|
||||
|
||||
#include "slsInterpolation.h"
|
||||
|
||||
#define M015
|
||||
//#define M015
|
||||
|
||||
#ifdef MYROOT1
|
||||
#include <TTree.h>
|
||||
@ -48,7 +48,7 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
int nped=1000,
|
||||
int nd=100, int nnx=-1, int nny=-1) :
|
||||
singlePhotonDetector(d, 3,nsigma,sign, cm, nped, nd, nnx, nny) , interp(inte), id(0) {
|
||||
cout << "**"<< xmin << " " << xmax << " " << ymin << " " << ymax << endl;
|
||||
//cout << "**"<< xmin << " " << xmax << " " << ymin << " " << ymax << endl;
|
||||
|
||||
};
|
||||
|
||||
|
@ -2,14 +2,15 @@
|
||||
CBFLIBDIR=/afs/psi.ch/project/sls_det_software/CBFlib-0.9.5
|
||||
ZMQLIB=../../slsReceiverSoftware/include
|
||||
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
INCDIR=-I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -I../interpolations/etaVEL -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/
|
||||
INCDIR=-I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/
|
||||
LIBHDF5=
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff -L$(ZMQLIB)
|
||||
#-I../interpolations/etaVEL
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -lhdf5 -ltiff -L$(ZMQLIB) -L$(CBFLIBDIR)/lib/
|
||||
#-L../../bin
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moenchZmqClusterFinder moenchZmqInterpolating
|
||||
all: moenchZmqClusterFinder moenchZmqInterpolating moenchZmqAnalog
|
||||
|
||||
|
||||
moenchZmqInterpolating: $(MAIN) $(INCS) clean
|
||||
@ -18,6 +19,10 @@ moenchZmqInterpolating: $(MAIN) $(INCS) clean
|
||||
moenchZmqClusterFinder: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchZmqClusterFinder moenchZmqClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
clean:
|
||||
rm -f moench03ZmqOnTheFlyEta moench03ZmqClusterFinder
|
||||
moenchZmqAnalog: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchZmqAnalog moenchZmqAnalog.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
clean:
|
||||
rm -f moench03ZmqInterpolating moench03ZmqClusterFinder moenchZmqAnalog
|
||||
|
||||
|
||||
|
@ -1,272 +0,0 @@
|
||||
#include "ZmqSocket.h"
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
#include "interpolatingDetector.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=20;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
int iprog=0;
|
||||
char outfname[10000];
|
||||
|
||||
|
||||
moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
// cout << "decoder "<< endl;
|
||||
//etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
|
||||
// linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
|
||||
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
//interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 100);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
|
||||
char tit[10000];
|
||||
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
char* buff;
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
//mt->setFrameMode(eFrame);
|
||||
mt->setFrameMode(eFlat);
|
||||
|
||||
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
// help
|
||||
if (argc < 2 || (argc > 2)) {
|
||||
cprintf(RED, "Help: %s [receive socket ip]\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip = argv[1];
|
||||
uint32_t portnum = 30001;//atoi(argv[2]);
|
||||
// char fn[10000];
|
||||
// strcpy(fn, argv[2]);
|
||||
// send parameters if any
|
||||
// char* socketip2 = 0;
|
||||
// uint32_t portnum2 = 0;
|
||||
// if (argc > 4) {
|
||||
// send = true;
|
||||
// socketip2 = argv[4];
|
||||
// portnum2 = atoi(argv[5]);
|
||||
// }
|
||||
cout << "\nrx socket ip : " << socketip ; // <<
|
||||
// "\nrx port num : " << portnum <<
|
||||
// "\nsize : " << size;
|
||||
// "\nfname : " << fn ;
|
||||
// if (send) {
|
||||
// cout << "\nsd socket ip : " << socketip2 <<
|
||||
// "\nsd port num : " << portnum2;
|
||||
// }
|
||||
cout << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
// ZmqSocket* zmqsocket2 = 0;
|
||||
// if (send) {
|
||||
// zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
// if (zmqsocket2->IsError()) {
|
||||
// bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
// delete zmqsocket2;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
// }
|
||||
|
||||
|
||||
// cout << "size " << 327680/sizeof(int) << endl;
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
string filename = "";
|
||||
int nnx, nny, nns;
|
||||
int imsize=filter->getImageSize(nnx,nny,nns);
|
||||
//int imsize=nx*ny;
|
||||
int i_image=0;
|
||||
cout << "Image size is "<< nnx << " " << nny << " " << nns << " " << imsize << endl;
|
||||
int iframe=0;
|
||||
int ff=0;
|
||||
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// cprintf(GREEN, "Got ?\n");
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
|
||||
cprintf(RED, "Acquisition finished\n");
|
||||
|
||||
|
||||
|
||||
cout << "Received " << ff << " frames for a total of "<< iframe << endl;
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
// if (send) {
|
||||
// zmqsocket2->SendData((char*)(mt->getImage()),imsize*sizeof(int));
|
||||
// cprintf(BLUE, "Sent Interpolated image\n");
|
||||
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// // cprintf(RED, "Sent Dummy\n");
|
||||
// }
|
||||
// if (save) {
|
||||
sprintf(tit,"%s_%05d.tiff",filename.c_str(), ff);
|
||||
// cout << tit << endl;
|
||||
mt->writeImage(tit);
|
||||
mt->clearImage();
|
||||
// }
|
||||
// sprintf(tit,"%s_%05d_eta_i.tiff",filename.c_str(), ff);
|
||||
// interp->writeFlatField(tit);
|
||||
// sprintf(tit,"%s_%05d_eta.tiff",filename.c_str(), ff);
|
||||
// cout << tit << endl;
|
||||
// mt->writeFlatField(tit);
|
||||
|
||||
i_image++;
|
||||
ff=0;
|
||||
// dont get data
|
||||
continue; //continue to not get out
|
||||
}
|
||||
|
||||
if (ff==0)
|
||||
cprintf(GREEN, "Start acquisition \n");
|
||||
// cout << filename << endl;
|
||||
// cprintf(GREEN, "Got Header \n");
|
||||
// get data
|
||||
// cprintf(GREEN, "Got Header\n");
|
||||
//image=(int*)buff;
|
||||
//cout << buff << endl;
|
||||
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
|
||||
// int length = zmqsocket->ReceiveData(0, (int*)image, size);
|
||||
// cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
|
||||
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
iframe++;
|
||||
ff++;
|
||||
// if (iframe%p==0) {
|
||||
|
||||
// while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
// sprintf(tit,"tmp.tiff",filename.c_str(), i_image);
|
||||
// mt->writeImage(tit);
|
||||
// // mt->clearImage();
|
||||
// // }
|
||||
// //interp->writeFlatField(tit);
|
||||
// // i_image++;
|
||||
// // sprintf(tit,"%s_tmp.tiff",fn);
|
||||
// // mt->writeImage(tit);
|
||||
// // //mt->clearImage();
|
||||
|
||||
// // cout <<"*"<< iprog++ << endl;
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //stream data from socket 2
|
||||
// if (send) {
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
|
||||
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
// cprintf(GREEN, "Sent Header\n");
|
||||
|
||||
// zmqsocket2->SendData((char*)image,length);
|
||||
// cprintf(GREEN, "Sent Data\n");
|
||||
// }
|
||||
|
||||
|
||||
}// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
// if (send)
|
||||
// delete zmqsocket2;
|
||||
|
||||
|
||||
// cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,306 +0,0 @@
|
||||
#include "ZmqSocket.h"
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
#include "interpolatingDetector.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
|
||||
int p=1000; //1.5s with 15ms period
|
||||
int fifosize=1000;
|
||||
int nthreads=8;
|
||||
int nsubpix=2;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
int iprog=0;
|
||||
char outfname[10000];
|
||||
|
||||
if (nsubpix>2) p=5000;
|
||||
|
||||
|
||||
moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
// cout << "decoder "<< endl;
|
||||
etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
|
||||
// linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
|
||||
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 100);
|
||||
// singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
|
||||
char tit[10000];
|
||||
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
char* buff;
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
//
|
||||
if (nsubpix>2)
|
||||
mt->setFrameMode(eFlat);
|
||||
else
|
||||
mt->setFrameMode(eFrame);
|
||||
|
||||
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
// help
|
||||
if (argc < 2 || (argc > 2)) {
|
||||
cprintf(RED, "Help: %s [receive socket ip]\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip = argv[1];
|
||||
uint32_t portnum = 30001;//atoi(argv[2]);
|
||||
// char fn[10000];
|
||||
// strcpy(fn, argv[2]);
|
||||
// send parameters if any
|
||||
// char* socketip2 = 0;
|
||||
// uint32_t portnum2 = 0;
|
||||
// if (argc > 4) {
|
||||
// send = true;
|
||||
// socketip2 = argv[4];
|
||||
// portnum2 = atoi(argv[5]);
|
||||
// }
|
||||
cout << "\nrx socket ip : " << socketip ; // <<
|
||||
// "\nrx port num : " << portnum <<
|
||||
// "\nsize : " << size;
|
||||
// "\nfname : " << fn ;
|
||||
// if (send) {
|
||||
// cout << "\nsd socket ip : " << socketip2 <<
|
||||
// "\nsd port num : " << portnum2;
|
||||
// }
|
||||
cout << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
// ZmqSocket* zmqsocket2 = 0;
|
||||
// if (send) {
|
||||
// zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
// if (zmqsocket2->IsError()) {
|
||||
// bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
// delete zmqsocket2;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
// }
|
||||
|
||||
|
||||
// cout << "size " << 327680/sizeof(int) << endl;
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
string filename = "";
|
||||
int nnx, nny, nns;
|
||||
int imsize=filter->getImageSize(nnx,nny,nns);
|
||||
//int imsize=nx*ny;
|
||||
int i_image=0;
|
||||
cout << "Image size is "<< nnx << " " << nny << " " << nns << " " << imsize << endl;
|
||||
int iframe=0;
|
||||
int ff=0;
|
||||
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// cprintf(GREEN, "Got ?\n");
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
|
||||
cprintf(RED, "Acquisition finished\n");
|
||||
|
||||
|
||||
|
||||
cout << "Received " << ff << " frames for a total of "<< iframe << endl;
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
// if (send) {
|
||||
// zmqsocket2->SendData((char*)(mt->getImage()),imsize*sizeof(int));
|
||||
// cprintf(BLUE, "Sent Interpolated image\n");
|
||||
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// // cprintf(RED, "Sent Dummy\n");
|
||||
// }
|
||||
// if (save) {
|
||||
// if (iframe>p) {
|
||||
sprintf(tit,"%s_%05d_%05d.tiff",filename.c_str(), ff, i_image);
|
||||
cout << tit << endl;
|
||||
mt->writeImage(tit);
|
||||
sprintf(tit,"/home/l_msdetect/slsbl/x07mb/x07mbop/Data1/2017/11/06/tmp.tiff");
|
||||
cout <<"*"<< iframe<< endl;
|
||||
mt->writeImage(tit);
|
||||
mt->clearImage();
|
||||
//}
|
||||
|
||||
|
||||
|
||||
// }
|
||||
//sprintf(tit,"%s_%05d_eta_i.tiff",filename.c_str(), ff);
|
||||
//interp->writeFlatField(tit);
|
||||
// sprintf(tit,"%s_%05d_eta_%d.tiff",filename.c_str(), ff, acqIndex);
|
||||
// // cout << tit << endl;
|
||||
// mt->writeFlatField(tit);
|
||||
|
||||
i_image++;
|
||||
ff=0;
|
||||
//filter->newDataSet();
|
||||
|
||||
// dont get data
|
||||
continue; //continue to not get out
|
||||
}
|
||||
|
||||
if (ff==0)
|
||||
cprintf(GREEN, "Start acquisition %d\n",acqIndex);
|
||||
// cout << filename << endl;
|
||||
// cprintf(GREEN, "Got Header \n");
|
||||
// get data
|
||||
// cprintf(GREEN, "Got Header\n");
|
||||
//image=(int*)buff;
|
||||
//cout << buff << endl;
|
||||
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
|
||||
// int length = zmqsocket->ReceiveData(0, (int*)image, size);
|
||||
// cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
|
||||
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
iframe++;
|
||||
if (nsubpix>2) {
|
||||
if (iframe==p) {
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->prepareInterpolation(ok);
|
||||
|
||||
sprintf(tit,"%s_%05d_eta.tiff",filename.c_str(), ff);
|
||||
cout << tit << endl;
|
||||
mt->writeFlatField(tit);
|
||||
}
|
||||
} //else {
|
||||
// cout << iframe << " " << p << endl;
|
||||
if (iframe%p==0) {
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
sprintf(tit,"/home/l_msdetect/slsbl/x07mb/x07mbop/Data1/2017/11/06/tmp.tiff");
|
||||
cout <<"*"<< iframe<< endl;
|
||||
mt->writeImage(tit);
|
||||
// mt->clearImage();
|
||||
}
|
||||
//}
|
||||
ff++;
|
||||
// if (iframe%p==0) {
|
||||
|
||||
// while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
// sprintf(tit,"tmp.tiff",filename.c_str(), i_image);
|
||||
// mt->writeImage(tit);
|
||||
// // mt->clearImage();
|
||||
// // }
|
||||
// //interp->writeFlatField(tit);
|
||||
// // i_image++;
|
||||
// // sprintf(tit,"%s_tmp.tiff",fn);
|
||||
// // mt->writeImage(tit);
|
||||
// // //mt->clearImage();
|
||||
|
||||
// // cout <<"*"<< iprog++ << endl;
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //stream data from socket 2
|
||||
// if (send) {
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
|
||||
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
// cprintf(GREEN, "Sent Header\n");
|
||||
|
||||
// zmqsocket2->SendData((char*)image,length);
|
||||
// cprintf(GREEN, "Sent Data\n");
|
||||
// }
|
||||
|
||||
|
||||
}// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
// if (send)
|
||||
// delete zmqsocket2;
|
||||
|
||||
|
||||
// cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,251 +0,0 @@
|
||||
#include "ZmqSocket.h"
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
//#include "singlePhotonDetector.h"
|
||||
#include "interpolatingDetector.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
|
||||
int p=1000;
|
||||
int fifosize=1000;
|
||||
int nthreads=6;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
int iprog=0;
|
||||
char outfname[10000];
|
||||
|
||||
|
||||
moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
// cout << "decoder "<< endl;
|
||||
etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
|
||||
// linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
|
||||
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
// interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 100);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
|
||||
char tit[10000];
|
||||
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
char* buff;
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
mt->setFrameMode(eFrame);
|
||||
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
// help
|
||||
if (argc < 3 || (argc > 3)) {
|
||||
cprintf(RED, "Help: %s [receive socket ip] [fname]\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip = argv[1];
|
||||
uint32_t portnum = 30001;//atoi(argv[2]);
|
||||
char fn[10000];
|
||||
strcpy(fn, argv[2]);
|
||||
// send parameters if any
|
||||
// char* socketip2 = 0;
|
||||
// uint32_t portnum2 = 0;
|
||||
// if (argc > 4) {
|
||||
// send = true;
|
||||
// socketip2 = argv[4];
|
||||
// portnum2 = atoi(argv[5]);
|
||||
// }
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
// "\nrx port num : " << portnum <<
|
||||
// "\nsize : " << size;
|
||||
"\nfname : " << fn ;
|
||||
// if (send) {
|
||||
// cout << "\nsd socket ip : " << socketip2 <<
|
||||
// "\nsd port num : " << portnum2;
|
||||
// }
|
||||
cout << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
// ZmqSocket* zmqsocket2 = 0;
|
||||
// if (send) {
|
||||
// zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
// if (zmqsocket2->IsError()) {
|
||||
// bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
// delete zmqsocket2;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
// }
|
||||
|
||||
|
||||
cout << "size " << 327680/sizeof(int) << endl;
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
string filename = "";
|
||||
int nnx, nny, nns;
|
||||
int imsize=filter->getImageSize(nnx,nny,nns);
|
||||
//int imsize=nx*ny;
|
||||
int i_image=0;
|
||||
cout << "Image size is "<< nnx << " " << nny << " " << nns << " " << imsize << endl;
|
||||
int iframe=0;
|
||||
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// cprintf(GREEN, "Got ?\n");
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
|
||||
cprintf(RED, "Acquisition finished\n");
|
||||
|
||||
|
||||
|
||||
cout << "Recieved " << iframe << " frames " << endl;
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
// if (send) {
|
||||
// zmqsocket2->SendData((char*)(mt->getImage()),imsize*sizeof(int));
|
||||
// cprintf(BLUE, "Sent Interpolated image\n");
|
||||
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// // cprintf(RED, "Sent Dummy\n");
|
||||
// }
|
||||
// if (save) {
|
||||
sprintf(tit,"%s_%d.tiff",fn, i_image);
|
||||
mt->writeImage(tit);
|
||||
mt->clearImage();
|
||||
// }
|
||||
//interp->writeFlatField(tit);
|
||||
i_image++;
|
||||
// dont get data
|
||||
continue; //continue to not get out
|
||||
}
|
||||
// cprintf(GREEN, "Got Header \n");
|
||||
// get data
|
||||
// cprintf(GREEN, "Got Header\n");
|
||||
//image=(int*)buff;
|
||||
//cout << buff << endl;
|
||||
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
|
||||
// int length = zmqsocket->ReceiveData(0, (int*)image, size);
|
||||
// cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
|
||||
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
iframe++;
|
||||
// if (iframe%p==0) {
|
||||
|
||||
// while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
// sprintf(tit,"%s_tmp.tiff",fn);
|
||||
// mt->writeImage(tit);
|
||||
// //mt->clearImage();
|
||||
|
||||
// cout <<"*"<< iprog++ << endl;
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //stream data from socket 2
|
||||
// if (send) {
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
|
||||
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
// cprintf(GREEN, "Sent Header\n");
|
||||
|
||||
// zmqsocket2->SendData((char*)image,length);
|
||||
// cprintf(GREEN, "Sent Data\n");
|
||||
// }
|
||||
|
||||
|
||||
}// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
// if (send)
|
||||
// delete zmqsocket2;
|
||||
|
||||
|
||||
// cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,219 +0,0 @@
|
||||
#include "ZmqSocket.h"
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
|
||||
#include "interpolatingDetector.h"
|
||||
#include "etaInterpolationPosXY.h"
|
||||
#include "linearInterpolation.h"
|
||||
#include "noInterpolation.h"
|
||||
#include "multiThreadedDetector.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [image size] [send_socket ip] [send port number]
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
int nthreads=3;
|
||||
int nsubpix=5;
|
||||
int etabins=550;
|
||||
double etamin=-1, etamax=2;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ok;
|
||||
//int* image = new int[(size/sizeof(int))]();
|
||||
char* buff;
|
||||
|
||||
moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
// cout << "decoder "<< endl;
|
||||
etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
|
||||
//linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
|
||||
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 10);
|
||||
|
||||
|
||||
|
||||
|
||||
filter->readPedestals("/scratch/ped_100.tiff");
|
||||
interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
cout << "filter "<< endl;
|
||||
|
||||
|
||||
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
|
||||
multiThreadedDetector *mt=new multiThreadedDetector(filter,nthreads,100);
|
||||
|
||||
|
||||
|
||||
mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
// help
|
||||
if (argc < 4 || (argc > 4 && argc != 6)) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [image size] [send_socket ip] [send starting port number]\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip = argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
int size = atoi(argv[3]);
|
||||
|
||||
// send parameters if any
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
if (argc > 4) {
|
||||
send = true;
|
||||
socketip2 = argv[4];
|
||||
portnum2 = atoi(argv[5]);
|
||||
}
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum <<
|
||||
"\nsize : " << size;
|
||||
if (send) {
|
||||
cout << "\nsd socket ip : " << socketip2 <<
|
||||
"\nsd port num : " << portnum2;
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
if (send) {
|
||||
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
if (zmqsocket2->IsError()) {
|
||||
bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
delete zmqsocket2;
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
string filename = "";
|
||||
int imsize=nx*ny*nsubpix*nsubpix;
|
||||
int i_image=0;
|
||||
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
|
||||
cprintf(RED, "Acquisition finished\n");
|
||||
|
||||
|
||||
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
if (send) {
|
||||
zmqsocket2->SendData((char*)(mt->getInterpolatedImage()),imsize*sizeof(int));
|
||||
cprintf(BLUE, "Sent Interpolated image\n");
|
||||
// zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// cprintf(RED, "Sent Dummy\n");
|
||||
}
|
||||
if (save) {
|
||||
char tit[10000];
|
||||
sprintf(tit,"/scratch/int_image_%d.tiff",i_image);
|
||||
mt->writeInterpolatedImage(tit);
|
||||
mt->clearInterpolatedImage(tit);
|
||||
}
|
||||
i_image++;
|
||||
// dont get data
|
||||
break; //continue to not get out
|
||||
}
|
||||
cprintf(GREEN, "Got Header \n");
|
||||
// get data
|
||||
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
|
||||
cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //stream data from socket 2
|
||||
// if (send) {
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
|
||||
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
// cprintf(GREEN, "Sent Header\n");
|
||||
|
||||
// zmqsocket2->SendData((char*)image,length);
|
||||
// cprintf(GREEN, "Sent Data\n");
|
||||
// }
|
||||
|
||||
|
||||
}// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
if (send)
|
||||
delete zmqsocket2;
|
||||
|
||||
|
||||
cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,248 +0,0 @@
|
||||
#include "ZmqSocket.h"
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
// #include "etaInterpolationPosXY.h"
|
||||
#include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
//#include "singlePhotonDetector.h"
|
||||
#include "interpolatingDetector.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
|
||||
int p=1000;
|
||||
int fifosize=1000;
|
||||
int nthreads=6;
|
||||
int nsubpix=2;
|
||||
// int etabins=550;
|
||||
// double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
//int* image = new int[(size/sizeof(int))]();
|
||||
char* buff;
|
||||
int iprog=0;
|
||||
char outfname[10000];
|
||||
|
||||
|
||||
moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
// cout << "decoder "<< endl;
|
||||
//etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
|
||||
// linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
|
||||
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
// interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 10);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
|
||||
char tit[10000];
|
||||
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
|
||||
mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
// help
|
||||
if (argc < 4 || (argc > 4 && argc != 6)) {
|
||||
cprintf(RED, "Help: %s [receive socket ip] [receive starting port number] [fname]\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip = argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
char fn[10000];
|
||||
strcpy(fn, argv[3]);
|
||||
// send parameters if any
|
||||
// char* socketip2 = 0;
|
||||
// uint32_t portnum2 = 0;
|
||||
// if (argc > 4) {
|
||||
// send = true;
|
||||
// socketip2 = argv[4];
|
||||
// portnum2 = atoi(argv[5]);
|
||||
// }
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum <<
|
||||
// "\nsize : " << size;
|
||||
"\nfname : " << fn ;
|
||||
// if (send) {
|
||||
// cout << "\nsd socket ip : " << socketip2 <<
|
||||
// "\nsd port num : " << portnum2;
|
||||
// }
|
||||
cout << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
// ZmqSocket* zmqsocket2 = 0;
|
||||
// if (send) {
|
||||
// zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
// if (zmqsocket2->IsError()) {
|
||||
// bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
// delete zmqsocket2;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
string filename = "";
|
||||
int nnx, nny, nns;
|
||||
int imsize=filter->getImageSize(nnx,nny,nns);
|
||||
//int imsize=nx*ny;
|
||||
int i_image=0;
|
||||
|
||||
int iframe=0;
|
||||
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
|
||||
cprintf(RED, "Acquisition finished\n");
|
||||
|
||||
|
||||
|
||||
cout << "Recieved " << iframe << " frames " << endl;
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
cout << "threads done " << endl;
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
// if (send) {
|
||||
// zmqsocket2->SendData((char*)(mt->getImage()),imsize*sizeof(int));
|
||||
// cprintf(BLUE, "Sent Interpolated image\n");
|
||||
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// // cprintf(RED, "Sent Dummy\n");
|
||||
// }
|
||||
// if (save) {
|
||||
sprintf(tit,"%s_%d.tiff",fn, i_image);
|
||||
cout << tit << endl;
|
||||
mt->writeImage(tit);
|
||||
cout << "wrote" << endl;
|
||||
mt->clearImage();
|
||||
// }
|
||||
i_image++;
|
||||
// dont get data
|
||||
continue; //continue to not get out
|
||||
}
|
||||
// cprintf(GREEN, "Got Header \n");
|
||||
// get data
|
||||
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
|
||||
// cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
|
||||
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
iframe++;
|
||||
if (iframe%p==0) {
|
||||
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
sprintf(tit,"%s_tmp.tiff",fn);
|
||||
mt->writeImage(tit);
|
||||
//mt->clearImage();
|
||||
|
||||
cout <<"*"<< iprog++ << endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //stream data from socket 2
|
||||
// if (send) {
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
|
||||
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
// cprintf(GREEN, "Sent Header\n");
|
||||
|
||||
// zmqsocket2->SendData((char*)image,length);
|
||||
// cprintf(GREEN, "Sent Data\n");
|
||||
// }
|
||||
|
||||
|
||||
}// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
// if (send)
|
||||
// delete zmqsocket2;
|
||||
|
||||
|
||||
cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
394
slsDetectorCalibration/moenchExecutables/moenchZmqAnalog.cpp
Normal file
394
slsDetectorCalibration/moenchExecutables/moenchZmqAnalog.cpp
Normal file
@ -0,0 +1,394 @@
|
||||
//#define ROOTSPECTRUM
|
||||
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
|
||||
#include "sls_receiver_defs.h"
|
||||
#include "ZmqSocket.h"
|
||||
#include "moench03T1ZmqDataNew.h"
|
||||
|
||||
#ifdef ROOTSPECTRUM
|
||||
#include <TPaveText.h>
|
||||
#include <TLegend.h>
|
||||
#include <TF1.h>
|
||||
#include <TGraphErrors.h>
|
||||
#include <TH2F.h>
|
||||
#include <TASImage.h>
|
||||
#include <TImage.h>
|
||||
#include <TFile.h>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include "tiffIO.h"
|
||||
|
||||
#include<iostream>
|
||||
|
||||
//#include "analogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [send_socket ip] [send port number]
|
||||
*
|
||||
*/
|
||||
int fifosize=1000;
|
||||
int nthreads=20;
|
||||
char* buff;
|
||||
char tit[10000];
|
||||
// help
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number]\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip=argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
int size = 32*2*5000;//atoi(argv[3]);
|
||||
|
||||
// send parameters if any
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
if (argc > 3) {
|
||||
send = true;
|
||||
socketip2 = argv[3];
|
||||
portnum2 = atoi(argv[4]);
|
||||
}
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum ;
|
||||
if (send) {
|
||||
cout << "\nsd socket ip : " << socketip2 <<
|
||||
"\nsd port num : " << portnum2;
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||
analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
|
||||
//singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10);
|
||||
//filter->setROI(250, 400, 30, 150);
|
||||
float threshold=1;
|
||||
if (argc > 5) {
|
||||
threshold=atof(argv[5]);
|
||||
filter->setThreshold(threshold);
|
||||
cout << "Threshold set to " << threshold << endl;
|
||||
}
|
||||
|
||||
int nnx, nny, nns;
|
||||
int imsize=filter->getImageSize(nnx,nny,nns);
|
||||
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
|
||||
cout << "det " << endl;
|
||||
int16_t dout[400*400];
|
||||
double ddark[400*400];
|
||||
cout << "dout " << endl;
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
#ifdef ROOTSPECTRUM
|
||||
TH2F *h2=NULL;
|
||||
TH2F *hmap=NULL;
|
||||
TFile *froot=NULL;
|
||||
|
||||
h2=new TH2F("hs","hs",500,-500,500,400*400,-0.5,400*400-0.5);
|
||||
hmap=new TH2F("hmap","hmap",400,-0.5,400-0.5,400,-0.5,400-0.5);
|
||||
#endif
|
||||
cout << "zmq1 " << endl;
|
||||
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
zmqsocket->Connect();
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
cout << "zmq2 " << endl;
|
||||
if (send) {
|
||||
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
if (zmqsocket2->IsError()) {
|
||||
bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
delete zmqsocket2;
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
zmqsocket2->Connect();
|
||||
printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
// zmqsocket2->Disconnect();
|
||||
}
|
||||
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
uint64_t fileindex = -1;
|
||||
string filename = "";
|
||||
//char* image = new char[size];
|
||||
//int* image = new int[(size/sizeof(int))]();
|
||||
|
||||
int *nph;//[400*400];
|
||||
int iframe=0;
|
||||
char rootfname[10000];
|
||||
|
||||
char fname[10000];
|
||||
char ff[10000];
|
||||
int fi;
|
||||
int length;
|
||||
char newped=-1, ped=-1, dat=-1, isdark=-1;
|
||||
|
||||
double *peds;
|
||||
int *im;
|
||||
int fnumber;
|
||||
float *gm=new float[400*400];
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){
|
||||
// if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) {
|
||||
cprintf(RED, "Got Dummy\n");
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
if (dat==1) {
|
||||
|
||||
sprintf(tit,"%s_%lld.tiff",filename.c_str(),fi);
|
||||
cout << tit << endl;
|
||||
im=mt->getImage(nnx,nny,nns);
|
||||
if (isdark) cout << "getting dark "<< endl;
|
||||
else cout << "subtracting dark"<< endl;
|
||||
if (gm) {
|
||||
for (int ii=0; ii<400*400; ii++) {
|
||||
// if (image[ix]>0) cout << ix << " " << image[ix]<< endl;
|
||||
if (isdark) {
|
||||
ddark[ii]=(double)im[ii]/((double)iframe);
|
||||
if (ddark[ii]>0) cout << "*" ;
|
||||
gm[ii]=im[ii];
|
||||
if (send) dout[ii]=im[ii];
|
||||
} else {
|
||||
gm[ii]=im[ii];//-ddark[ii]*iframe;
|
||||
if (gm[ii]<0) gm[ii]=0;
|
||||
if (send) dout[ii]=gm[ii];
|
||||
}
|
||||
//cout << endl;
|
||||
|
||||
}
|
||||
cout << endl;
|
||||
//cout << "image " << nnx << " " << nny << endl;
|
||||
WriteToTiff(gm,tit ,nnx, nny);
|
||||
// delete [] gm;
|
||||
} else cout << "Could not allocate float image " << endl;
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
sprintf(tit,"%s_%lld.tiff",filename.c_str(),fi);
|
||||
cout << tit << endl;
|
||||
mt->writePedestal(tit);
|
||||
|
||||
}
|
||||
|
||||
// mt->writeImage(tit);
|
||||
// cout << "wrote" << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (send) {
|
||||
if (dat==1) {
|
||||
//im=mt->getImage(nnx,nny,nns);
|
||||
|
||||
//if (im)
|
||||
// cout << "got image" << endl;
|
||||
//else
|
||||
// cout << "could not get image" << endl;
|
||||
|
||||
|
||||
//for (int ii=0; ii<400*400; ii++) {
|
||||
//if (im[ii]>0)
|
||||
//cout << im[ii] << endl;
|
||||
// if (im[ii]>=0)
|
||||
|
||||
// if (isdark) {
|
||||
//ddark[ii]=im[ii];
|
||||
// dout[ii]=im[ii];
|
||||
// } else {
|
||||
// dout[ii]=im[ii]-ddark[ii];
|
||||
// if (dout[ii]<0) dout[ii]=0;
|
||||
// }
|
||||
// else
|
||||
// dout[ii]=0;
|
||||
//else
|
||||
//dout[ii]=0;
|
||||
// cout << im[ii] << " " << dout[ii] << endl;
|
||||
// }
|
||||
//for (int iiy=49; iiy<52; iiy++)
|
||||
// for (int iix=80; iix<83; iix++)
|
||||
// dout[iiy*400+iix]=0;
|
||||
;
|
||||
} else {
|
||||
peds=mt->getPedestal();
|
||||
// sprintf(tit,"%s_%lld.tiff",filename.c_str(),fi);
|
||||
//cout << tit << endl;
|
||||
//mt->writePedestal(tit);
|
||||
if (peds)
|
||||
cout << "got peds" << endl;
|
||||
else
|
||||
cout << "could not get peds" << endl;
|
||||
for (int ii=0; ii<400*400; ii++) {
|
||||
dout[ii]=peds[ii];
|
||||
// if (ii%400==10 && ii/400==10)
|
||||
// cout << ii/400 << " " << ii%400 << " " << peds[ii] << " " << dout[ii] << endl;
|
||||
// if (ii%400==100 && ii/400==100)
|
||||
// cout << ii/400 << " " << ii%400 << " " << peds[ii] << " " << dout[ii] << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
// if (zmqsocket2->IsError()) {
|
||||
// bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
// delete zmqsocket2;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
// zmqsocket2->Connect();
|
||||
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
//zmqsocket2->Connect();
|
||||
|
||||
|
||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,ff, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
|
||||
|
||||
zmqsocket2->SendData((char*)dout,length);
|
||||
cprintf(GREEN, "Sent Data %d \n",length);
|
||||
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
// zmqsocket2->Disconnect();
|
||||
|
||||
// delete zmqsocket2;
|
||||
}
|
||||
cout << "Acquired "<< iframe << " frames " << endl;
|
||||
iframe=0;
|
||||
newped=-1;
|
||||
ped=-1;
|
||||
dat=-1;
|
||||
mt->clearImage();
|
||||
isdark=0;
|
||||
continue; //continue to not get out
|
||||
}
|
||||
// cprintf(GREEN, "Got Header \n");
|
||||
|
||||
strcpy(ff,filename.c_str());
|
||||
fi=fileindex;
|
||||
//isdark=0;
|
||||
if (newped<0) {
|
||||
if (filename.find("newped")!=std::string::npos) {
|
||||
cout << "NEWPED" << endl;
|
||||
if (newped<=0) {
|
||||
newped=1;
|
||||
ped=1;
|
||||
while (mt->isBusy()) {;}
|
||||
mt->newDataSet(); //resets pedestal
|
||||
mt->setFrameMode(ePedestal);
|
||||
cout << "New data set"<< endl;
|
||||
}
|
||||
} else {
|
||||
newped=0;
|
||||
}
|
||||
}
|
||||
if (ped<0) {
|
||||
if (filename.find("ped")!=std::string::npos) {
|
||||
ped=1;
|
||||
dat=0;
|
||||
while (mt->isBusy()) {;}
|
||||
mt->setFrameMode(ePedestal);
|
||||
cout << "pedestal!"<< endl;
|
||||
} else {
|
||||
ped=0;
|
||||
dat=1;
|
||||
while (mt->isBusy()) {;}
|
||||
mt->setFrameMode(eFrame);
|
||||
cout << "data!"<< endl;
|
||||
if (filename.find("dark")!=std::string::npos) {
|
||||
isdark=1;
|
||||
cout << "this is a dark image" << endl;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// get data
|
||||
length = zmqsocket->ReceiveData(0, buff, size);
|
||||
// cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
// if (iframe<10) {
|
||||
// filter->addToPedestal(image);
|
||||
//} else {
|
||||
//SLOW!!!
|
||||
//***
|
||||
//filter->getNPhotons(image);
|
||||
//nph=filter->getImage();
|
||||
//filter->addToPedestal(image);
|
||||
//*****
|
||||
|
||||
// cprintf(BLUE, "Data processed\n");
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
|
||||
//stream data from socket 2
|
||||
|
||||
iframe++;
|
||||
}
|
||||
|
||||
// }// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
if (send)
|
||||
delete zmqsocket2;
|
||||
|
||||
|
||||
cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -30,54 +30,76 @@ int main(int argc, char *argv[]) {
|
||||
*
|
||||
*/
|
||||
|
||||
int nthreads=20;
|
||||
int nsigma=5;
|
||||
int xmin=0;
|
||||
int xmax=400;
|
||||
int ymin=0;
|
||||
int ymax=400;
|
||||
int nsubpixels=2;
|
||||
|
||||
|
||||
FILE *of=NULL;
|
||||
int fifosize=1000;
|
||||
int nthreads=20;
|
||||
int int_ready=0;
|
||||
int ok;
|
||||
// help
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number]\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// help
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: %s [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number] [nsubpixels] [nthreads] [nsigma] [xmin xmax ymin ymax]\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip=argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
int size = 32*2*5000;//atoi(argv[3]);
|
||||
|
||||
// send parameters if any
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
if (argc > 3) {
|
||||
send = true;
|
||||
socketip2 = argv[3];
|
||||
portnum2 = atoi(argv[4]);
|
||||
}
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum ;
|
||||
if (send) {
|
||||
cout << "\nsd socket ip : " << socketip2 <<
|
||||
"\nsd port num : " << portnum2;
|
||||
}
|
||||
cout << endl;
|
||||
int nsubpixels=2;
|
||||
if (argc > 5) {
|
||||
nsubpixels=atoi(argv[5]);
|
||||
}
|
||||
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
int npx, npy;
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||
det->getDetectorSize(npx, npy);
|
||||
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
|
||||
//singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10);
|
||||
linearInterpolation *interp=new linearInterpolation(npx,npy,nsubpixels);
|
||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, 5, 1, 0, 1000, 100,npx,npy);
|
||||
int size = 32*2*5000;//atoi(argv[3]);
|
||||
bool send = false;
|
||||
|
||||
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
char* socketip=argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
if (argc > 3) {
|
||||
send = true;
|
||||
socketip2 = argv[3];
|
||||
portnum2 = atoi(argv[4]);
|
||||
}
|
||||
if (argc > 5) {
|
||||
nsubpixels=atoi(argv[5]);
|
||||
}
|
||||
if (argc>6) {
|
||||
nthreads=atoi(argv[6]);
|
||||
}
|
||||
if (argc>7) {
|
||||
nsigma=atoi(argv[7]);
|
||||
}
|
||||
if (argc>11) {
|
||||
xmin=atoi(argv[8]);
|
||||
xmax=atoi(argv[8]);
|
||||
ymin=atoi(argv[10]);
|
||||
ymax=atoi(argv[11]);
|
||||
}
|
||||
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum ;
|
||||
if (send) {
|
||||
cout << "\nsd socket ip : " << socketip2 <<
|
||||
"\nsd port num : " << portnum2;
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
int npx, npy;
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||
det->getDetectorSize(npx, npy);
|
||||
linearInterpolation *interp=new linearInterpolation(npx,npy,nsubpixels);
|
||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, nsigma, 1, 0, 1000, 100,npx,npy);
|
||||
cout << "Setting noise cut to " << nsigma << " sigma"<< endl;
|
||||
filter->setROI(xmin,xmax,ymin,ymax);
|
||||
cout << "Setting ROI to "<< xmin << " " << xmax << " " << ymin << " " << ymax << endl;
|
||||
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
int frameMode=eFrame;
|
||||
mt->setFrameMode(frameMode);
|
||||
mt->StartThreads();
|
||||
@ -89,9 +111,6 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
|
||||
|
||||
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
@ -102,7 +121,6 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
cout << "zmq2 " << endl;
|
||||
if (send) {
|
||||
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
if (zmqsocket2->IsError()) {
|
||||
@ -150,25 +168,36 @@ int main(int argc, char *argv[]) {
|
||||
// if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) {
|
||||
// cprintf(RED, "Got Dummy\n");
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
if (frameMode==ePedestal) {
|
||||
detped=mt->getPedestal();
|
||||
if (detped) {
|
||||
|
||||
if (frameMode==eFrame) {
|
||||
detimage=mt->getImage(nix,niy,nis);
|
||||
|
||||
if (detimage) {
|
||||
for (ix=0; ix<nnx/nis; ix++) {
|
||||
for (iy=0; iy<nny/nis; iy++) {
|
||||
dout[iy*nnx+ix]=0;
|
||||
for (isx=0; isx<nis; isx++) {
|
||||
for (isy=0; isy<nis; isy++) {
|
||||
dout[iy*nnx+ix]+=detimage[(iy+isy)*nix+(ix+isx)];
|
||||
// if (detimage[(iy+isy)*nix+(ix+isx)]) cout << ix << " " << iy << " " << isx << " " << isy << " " << detimage[(iy+isy)*nix+(ix+isx)] << " " << dout[iy*nnx+ix] << endl;
|
||||
}
|
||||
for (ix=0; ix<400; ix++) {
|
||||
for (iy=0; iy<400; iy++) {
|
||||
dout[iy*400+ix]+=detped[iy*400+ix];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
detimage=mt->getImage(nix,niy,nis);
|
||||
if (detimage) {
|
||||
for (ix=0; ix<nix/nis; ix++) {
|
||||
for (iy=0; iy<niy/nis; iy++) {
|
||||
dout[iy*(nix/nis)+ix]=0;
|
||||
}
|
||||
}
|
||||
for (ix=0; ix<nix; ix++) {
|
||||
for (iy=0; iy<niy; iy++) {
|
||||
dout[(iy/nis)*(nix/nis)+(ix/nis)]+=detimage[iy*nix+ix];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (send) {
|
||||
strcpy(fname,filename.c_str());
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,16,fileindex,400,400,400*400, acqIndex,frameIndex,fname, acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
|
@ -451,7 +451,7 @@ public:
|
||||
p0=dets[i]->getPedestal(p0);
|
||||
if (p0) {
|
||||
for (int ib=0; ib<nx*ny; ib++) {
|
||||
ped[ib]+=p0[ib];
|
||||
ped[ib]+=p0[ib]/((double)nThreads);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user