mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2026-01-16 23:28:04 +01:00
some changes in the moench executables
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
|
||||
CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
|
||||
#ZMQLIB=../slsReceiverSoftware/include
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/
|
||||
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff
|
||||
MAIN=moench03ReorderImage.cpp
|
||||
|
||||
all: moenchReorderImage moenchClusterFinder
|
||||
|
||||
|
||||
|
||||
moenchReorderImage: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchReorderImage $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER
|
||||
|
||||
moenchClusterFinder: moench03ClusterFinder.cpp
|
||||
g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER
|
||||
|
||||
|
||||
clean:
|
||||
rm -f moenchReorderImage moenchClusterFinder
|
||||
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
#INCS= $(INCSROOT) moench03_receiver.h
|
||||
#LINKDEF=receiverGuiLinkDef.h
|
||||
|
||||
CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
|
||||
ZMQLIB=../slsReceiverSoftware/include
|
||||
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I$(ROOTSYS)/include
|
||||
#CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
|
||||
#ZMQLIB=../slsReceiverSoftware/include
|
||||
#LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include -I$(ROOTSYS)/include
|
||||
#-I$(CBFLIBDIR)/include/
|
||||
#LIBHDF5=
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -ltiff
|
||||
#-L$(CBFLIBDIR)/lib/ -lhdf5
|
||||
|
||||
MAIN=tiff_to_th2f.cpp
|
||||
|
||||
@@ -18,8 +20,8 @@ all: tiff_to_th2f
|
||||
|
||||
tiff_to_th2f: $(MAIN) $(INCS)
|
||||
|
||||
g++ -o tiff_to_th2f $(MAIN) `root-config --cflags --glibs` -lMinuit -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) ../tiffIO.cpp
|
||||
|
||||
g++ -o tiff_to_th2f $(MAIN) `root-config --cflags --glibs` -lMinuit -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) ../tiffIO.cpp
|
||||
#$(LIBRARYCBF) $(LIBHDF5)
|
||||
clean:
|
||||
rm -f tiff_to_th2f
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=8;
|
||||
int nthreads=1;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
|
||||
@@ -30,9 +30,10 @@ int main(int argc, char *argv[]) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " << endl;
|
||||
return 0;
|
||||
}
|
||||
int ii=0;
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=1;
|
||||
int nthreads=5;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
@@ -165,6 +166,14 @@ int main(int argc, char *argv[]) {
|
||||
mt->popFree(buff);
|
||||
|
||||
ff=-1;
|
||||
ii++;
|
||||
if (ii%10000==0) {
|
||||
|
||||
cout << ii << endl;
|
||||
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
mt->writeImage("/scratch/tmp.tiff");
|
||||
}
|
||||
}
|
||||
// cout << "--" << endl;
|
||||
filebin.close();
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
//#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
|
||||
#include "moench03T1ReceiverDataNew.h"
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <ctime>
|
||||
using namespace std;
|
||||
|
||||
#define NX 400 //number of x pixels
|
||||
#define NY 400 //number of y pixels
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
if (argc<6) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " << endl;
|
||||
return 1;
|
||||
}
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=8;
|
||||
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;
|
||||
|
||||
|
||||
|
||||
|
||||
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
|
||||
|
||||
|
||||
uint16_t data[NY*NX];
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
int* image;
|
||||
|
||||
int ff, np;
|
||||
int dsize=decoder->getDataSize();
|
||||
|
||||
|
||||
//char data[dsize];
|
||||
|
||||
ifstream filebin;
|
||||
char *indir=argv[1];
|
||||
char *outdir=argv[2];
|
||||
char *fformat=argv[3];
|
||||
int runmin=atoi(argv[4]);
|
||||
int runmax=atoi(argv[5]);
|
||||
|
||||
char fname[10000];
|
||||
char outfname[10000];
|
||||
char imgfname[10000];
|
||||
char pedfname[10000];
|
||||
// strcpy(pedfname,argv[6]);
|
||||
char fn[10000];
|
||||
|
||||
std::time_t end_time;
|
||||
|
||||
FILE *of=NULL;
|
||||
cout << "input directory is " << indir << endl;
|
||||
cout << "output directory is " << outdir << endl;
|
||||
cout << "fileformat is " << fformat << endl;
|
||||
|
||||
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
char* buff;
|
||||
|
||||
|
||||
|
||||
|
||||
int ifr=0;
|
||||
|
||||
|
||||
for (int irun=runmin; irun<runmax; irun++) {
|
||||
sprintf(fn,fformat,irun);
|
||||
sprintf(fname,"%s/%s.raw",indir,fn);
|
||||
sprintf(outfname,"%s/%s_image.raw",outdir,fn);
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
cout << fname << " " << outfname << " " << imgfname << endl;
|
||||
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||
// //open file
|
||||
if (filebin.is_open()){
|
||||
of=fopen(outfname,"w");
|
||||
if (of) {
|
||||
;
|
||||
} else {
|
||||
cout << "Could not open "<< outfname << " for writing " << endl;
|
||||
return 1;
|
||||
}
|
||||
// //while read frame
|
||||
ff=-1;
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
for (int ix=0; ix<400; ix++)
|
||||
for (int iy=0; iy<400; iy++)
|
||||
data[iy*NX+ix]=decoder->getChannel(buff,ix,iy);
|
||||
|
||||
ifr++;
|
||||
|
||||
fwrite(&ff, 8, 1,of);//write detector frame number
|
||||
fwrite(&ifr, 8, 1,of);//write datset frame number
|
||||
fwrite(data,2,NX*NY,of);//write reordered data
|
||||
|
||||
if (ifr%10000==0) cout << ifr << " " << ff << endl;
|
||||
ff=-1;
|
||||
|
||||
}
|
||||
cout << "--" << endl;
|
||||
filebin.close();
|
||||
// //close file
|
||||
// //join threads
|
||||
|
||||
if (of)
|
||||
fclose(of);
|
||||
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
} else
|
||||
cout << "Could not open "<< fname << " for reading " << endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -22,15 +22,19 @@ 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]
|
||||
*
|
||||
*/
|
||||
|
||||
FILE *of=NULL;
|
||||
int fifosize=1000;
|
||||
int nthreads=20;
|
||||
int nsubpixels=2;
|
||||
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");
|
||||
@@ -58,6 +62,10 @@ int main(int argc, char *argv[]) {
|
||||
"\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();
|
||||
@@ -70,7 +78,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
mt->setFrameMode(eFrame);
|
||||
int frameMode=eFrame;
|
||||
mt->setFrameMode(frameMode);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
@@ -113,6 +122,9 @@ int main(int argc, char *argv[]) {
|
||||
uint32_t subframeIndex = -1;
|
||||
uint64_t fileindex = -1;
|
||||
string filename = "";
|
||||
char ffname[10000];
|
||||
int ffindex;
|
||||
|
||||
char* image = new char[size];
|
||||
//int* image = new int[(size/sizeof(int))]();
|
||||
|
||||
@@ -139,35 +151,42 @@ int main(int argc, char *argv[]) {
|
||||
// cprintf(RED, "Got Dummy\n");
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
|
||||
if (frameMode==eFrame) {
|
||||
detimage=mt->getImage(nix,niy,nis);
|
||||
|
||||
|
||||
if (detimage) {
|
||||
for (ix=0; ix<nnx; ix++) {
|
||||
for (iy=0; iy<nny; iy++) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
|
||||
zmqsocket2->SendData((char*)dout,length);
|
||||
cprintf(GREEN, "Sent Data\n");
|
||||
}
|
||||
|
||||
sprintf(ofname,"%s_%d.tiff",filename.c_str(),fileindex);
|
||||
mt->writeImage(ofname);
|
||||
|
||||
}
|
||||
}
|
||||
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);
|
||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
|
||||
zmqsocket2->SendData((char*)dout,length);
|
||||
cprintf(GREEN, "Sent Data\n");
|
||||
}
|
||||
|
||||
sprintf(ofname,"%s_%d.tiff",ffname,ffindex);
|
||||
if (frameMode==eFlat)
|
||||
mt->writeFlatField(ofname);
|
||||
else if (frameMode==ePedestal)
|
||||
mt->writePedestal(ofname);
|
||||
else
|
||||
mt->writeImage(ofname);
|
||||
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
if (send) {
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
@@ -184,7 +203,8 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
|
||||
if (of==NULL) {
|
||||
if (of==NULL) {
|
||||
while (mt->isBusy()) {;}
|
||||
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
|
||||
of=fopen(ofname,"w");
|
||||
if (of) {
|
||||
@@ -193,6 +213,32 @@ int main(int argc, char *argv[]) {
|
||||
cout << "Could not open "<< ofname << " for writing " << endl;
|
||||
mt->setFilePointer(NULL);
|
||||
}
|
||||
ffindex=fileindex;
|
||||
strcpy(ffname,filename.c_str());
|
||||
if (filename.find("flat")!=std::string::npos) {
|
||||
cout << "add to ff" << endl;
|
||||
frameMode=eFlat;//ePedestal;
|
||||
int_ready=0;
|
||||
|
||||
} else if (filename.find("newped")!=std::string::npos) {
|
||||
frameMode=ePedestal;
|
||||
cout << "new pedestal" << endl;
|
||||
|
||||
mt->newDataSet();
|
||||
} else if (filename.find("ped")!=std::string::npos){
|
||||
frameMode=ePedestal;
|
||||
cout << "pedestal" << endl;
|
||||
} else {
|
||||
frameMode=eFrame;
|
||||
cout << "data" << endl;
|
||||
if (int_ready==0) {
|
||||
mt->prepareInterpolation(ok);
|
||||
cout << "prepare interpolation " << endl;
|
||||
int_ready=1;
|
||||
}
|
||||
}
|
||||
|
||||
mt->setFrameMode(frameMode);
|
||||
}
|
||||
|
||||
// get data
|
||||
|
||||
Reference in New Issue
Block a user