mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-12 04:47:14 +02:00
merging refactor (replacing)
This commit is contained in:
@ -1,39 +0,0 @@
|
||||
|
||||
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/
|
||||
#LIBHDF5=
|
||||
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff
|
||||
#-L$(ZMQLIB) -lzmq
|
||||
#-L../../bin
|
||||
MAIN=moench03ClusterFinder.cpp
|
||||
#-lhdf5
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
|
||||
|
||||
|
||||
|
||||
moenchClusterFinder: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DOLDDATA #-DNEWRECEIVER
|
||||
|
||||
moenchMakeEta: moench03MakeEta.cpp $(INCS) clean
|
||||
g++ -o moenchMakeEta moench03MakeEta.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
moenchInterpolation: moench03Interpolation.cpp $(INCS) clean
|
||||
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
moenchNoInterpolation: moench03NoInterpolation.cpp $(INCS) clean
|
||||
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
moenchPhotonCounter: moenchPhotonCounter.cpp $(INCS) clean
|
||||
g++ -o moenchPhotonCounter moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER
|
||||
|
||||
moenchAnalog: moenchPhotonCounter.cpp $(INCS) clean
|
||||
g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER -DANALOG
|
||||
|
||||
clean:
|
||||
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter
|
||||
|
||||
|
@ -1,34 +0,0 @@
|
||||
#module add CBFlib/0.9.5
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include
|
||||
|
||||
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -pthread -lrt -ltiff -O3
|
||||
|
||||
MAIN=moench03ClusterFinder.cpp
|
||||
|
||||
|
||||
all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
|
||||
|
||||
|
||||
|
||||
moenchClusterFinder: moench03ClusterFinder.cpp $(INCS) clean
|
||||
g++ -o moenchClusterFinder moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER
|
||||
|
||||
moenchMakeEta: moench03Interpolation.cpp $(INCS) clean
|
||||
g++ -o moenchMakeEta moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF
|
||||
|
||||
moenchInterpolation: moench03Interpolation.cpp $(INCS) clean
|
||||
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
|
||||
|
||||
moenchNoInterpolation: moench03NoInterpolation.cpp $(INCS) clean
|
||||
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
|
||||
|
||||
moenchPhotonCounter: moenchPhotonCounter.cpp $(INCS) clean
|
||||
g++ -o moenchPhotonCounter moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER
|
||||
|
||||
moenchAnalog: moenchPhotonCounter.cpp $(INCS) clean
|
||||
g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG
|
||||
|
||||
clean:
|
||||
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
|
||||
|
||||
|
@ -1,20 +0,0 @@
|
||||
|
||||
CBFLIBDIR=/afs/psi.ch/project/sls_det_software/CBFlib-0.9.5
|
||||
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
INCDIR=-IslsDetectorCalibration -I../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -IetaVEL
|
||||
LIBHDF5=-L$(CBFLIBDIR)/lib/ -lhdf5
|
||||
LDFLAG= -L/usr/lib64/ -lpthread
|
||||
#-L../../bin
|
||||
MAIN=moench03OnTheFlyAnalysis.C
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moench03OnTheFlyAnalysis
|
||||
|
||||
|
||||
|
||||
moench03OnTheFlyAnalysis: $(MAIN) $(INCS) clean
|
||||
g++ -o moench03OnTheFlyAnalysis $(MAIN) -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
clean:
|
||||
rm -f moench03OnTheFlyAnalysis
|
@ -1,23 +0,0 @@
|
||||
|
||||
CBFLIBDIR= /home/l_msdetect/CBFlib-0.9.5
|
||||
ZMQLIB=../slsReceiverSoftware/include
|
||||
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
INCDIR=-IslsDetectorCalibration -I../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I.
|
||||
#-IetaVEL
|
||||
LIBHDF5=
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff -L$(ZMQLIB)
|
||||
#-L../../bin
|
||||
MAIN=moench03ClusterFinder.cpp
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moench03ClusterFinder
|
||||
|
||||
|
||||
|
||||
moench03ClusterFinder: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
|
||||
|
||||
clean:
|
||||
rm -f moench03ClusterFinder
|
||||
|
@ -1,32 +0,0 @@
|
||||
|
||||
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../dataStructures ../tiffIO.cpp -I../ -I../interpolations/
|
||||
LIBHDF5=
|
||||
#-I../interpolations/etaVEL
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -lhdf5 -ltiff -L$(ZMQLIB) -L$(CBFLIBDIR)/lib/ -O3
|
||||
#-L../../bin
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
aaa: moenchZmqProcess
|
||||
|
||||
all: moenchZmqClusterFinder moenchZmqInterpolating moenchZmqAnalog
|
||||
|
||||
moenchZmqProcess: moenchZmqProcess.cpp $(INCS) clean
|
||||
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ
|
||||
|
||||
moenchZmqInterpolating: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchZmqInterpolating moenchZmqInterpolating.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
moenchZmqClusterFinder: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchZmqClusterFinder moenchZmqClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
moenchZmqAnalog: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchZmqAnalog moenchZmqAnalog.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
clean:
|
||||
rm -f moench03ZmqInterpolating moench03ZmqClusterFinder moenchZmqAnalog moenchZmqProcess
|
||||
|
||||
|
@ -1,17 +0,0 @@
|
||||
|
||||
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 -g
|
||||
#-L../../bin -lhdf5 -L.
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moenchZmqProcess
|
||||
|
||||
moenchZmqProcess: moenchZmqProcess.cpp clean
|
||||
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP
|
||||
|
||||
clean:
|
||||
rm -f moenchZmqProcess
|
||||
|
||||
|
@ -1,24 +0,0 @@
|
||||
|
||||
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../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ ../tiffIO.cpp -I../dataStructures
|
||||
#LIBHDF5=
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff -lhdf5
|
||||
#-L$(ZMQLIB) -lzmq
|
||||
#-L../../bin
|
||||
MAIN=moench03ClusterFinderPhoenix.cpp
|
||||
#
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moenchClusterFinderPhoenix
|
||||
#moenchMakeEtaPhoenix moenchInterpolationPhoenix
|
||||
|
||||
|
||||
|
||||
moenchClusterFinderPhoenix: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchClusterFinderPhoenix $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
|
||||
|
||||
clean:
|
||||
rm -f moenchClusterFinderPhoenix
|
||||
|
@ -1,22 +0,0 @@
|
||||
|
||||
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
|
||||
|
||||
|
@ -1,27 +0,0 @@
|
||||
#INCSROOT= receiverGui.h
|
||||
#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$(ROOTSYS)/include
|
||||
#-I$(CBFLIBDIR)/include/
|
||||
#LIBHDF5=
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -ltiff
|
||||
#-L$(CBFLIBDIR)/lib/ -lhdf5
|
||||
|
||||
MAIN=tiff_to_th2f.cpp
|
||||
|
||||
|
||||
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) ../tiffIO.cpp
|
||||
#$(LIBRARYCBF) $(LIBHDF5)
|
||||
clean:
|
||||
rm -f tiff_to_th2f
|
||||
|
@ -1,218 +0,0 @@
|
||||
//#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
#ifdef NEWRECEIVER
|
||||
#ifndef RECT
|
||||
#include "moench03T1ReceiverDataNew.h"
|
||||
#endif
|
||||
|
||||
#ifdef RECT
|
||||
#include "moench03T1ReceiverDataNewRect.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CSAXS_FP
|
||||
#include "moench03T1ReceiverData.h"
|
||||
#endif
|
||||
#ifdef OLDDATA
|
||||
#include "moench03Ctb10GbT1Data.h"
|
||||
#endif
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ctime>
|
||||
using namespace std;
|
||||
|
||||
|
||||
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=24;
|
||||
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;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef NEWRECEIVER
|
||||
#ifdef RECT
|
||||
cout << "Should be rectangular!" <<endl;
|
||||
#endif
|
||||
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
|
||||
cout << "RECEIVER DATA WITH ONE HEADER!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef CSAXS_FP
|
||||
moench03T1ReceiverData *decoder=new moench03T1ReceiverData();
|
||||
cout << "RECEIVER DATA WITH ALL HEADERS!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef OLDDATA
|
||||
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
|
||||
cout << "OLD RECEIVER DATA!"<<endl;
|
||||
#endif
|
||||
|
||||
|
||||
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
|
||||
// char tit[10000];
|
||||
cout << "filter " << endl;
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
int ff, np;
|
||||
int dsize=decoder->getDataSize();
|
||||
cout << " data size is " << dsize;
|
||||
|
||||
|
||||
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;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
mt->setDetectorMode(ePhotonCounting);
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
cout << "mt " << endl;
|
||||
|
||||
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.clust",outdir,fn);
|
||||
sprintf(imgfname,"%s/%s.tiff",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) {
|
||||
mt->setFilePointer(of);
|
||||
// cout << "file pointer set " << endl;
|
||||
} else {
|
||||
cout << "Could not open "<< outfname << " for writing " << endl;
|
||||
mt->setFilePointer(NULL);
|
||||
return 1;
|
||||
}
|
||||
// //while read frame
|
||||
ff=-1;
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
// cout << "*"<<ifr++<<"*"<<ff<< endl;
|
||||
// cout << ff << " " << np << endl;
|
||||
// //push
|
||||
mt->pushData(buff);
|
||||
// // //pop
|
||||
mt->nextThread();
|
||||
// // // cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
ifr++;
|
||||
if (ifr%10000==0) cout << ifr << " " << ff << endl;
|
||||
ff=-1;
|
||||
}
|
||||
cout << "--" << endl;
|
||||
filebin.close();
|
||||
// //close file
|
||||
// //join threads
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
if (of)
|
||||
fclose(of);
|
||||
|
||||
mt->writeImage(imgfname);
|
||||
mt->clearImage();
|
||||
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
} else
|
||||
cout << "Could not open "<< fname << " for reading " << endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,201 +0,0 @@
|
||||
//#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
//#include "moench03T1ReceiverData.h"
|
||||
|
||||
#include "moench03Ctb10GbT1Data.h"
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ctime>
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
if (argc<6) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " << endl;
|
||||
return 0;
|
||||
}
|
||||
int ii=0;
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=5;
|
||||
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;
|
||||
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
|
||||
cout << "decoder" << endl;
|
||||
//moench03T1ReceiverData *decoder=new moench03T1ReceiverData();
|
||||
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
|
||||
// char tit[10000];
|
||||
cout << "filter" << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
cout << "dataset" << endl;
|
||||
|
||||
int ff, np;
|
||||
int dsize=decoder->getDataSize();
|
||||
cout << " data size is " << dsize << endl;
|
||||
|
||||
|
||||
char data[dsize];
|
||||
|
||||
ifstream filebin;
|
||||
char *indir=argv[1];
|
||||
cout << "input directory is " << indir << endl;
|
||||
char *outdir=argv[2];
|
||||
cout << "output directory is " << outdir << endl;
|
||||
char *fformat=argv[3];
|
||||
cout << "fileformat is " << fformat << endl;
|
||||
int runmin=atoi(argv[4]);
|
||||
cout << "runmin : " << runmin << endl;
|
||||
int runmax=atoi(argv[5]);
|
||||
cout << "runmax : " << runmax << endl;
|
||||
|
||||
char fname[10000];
|
||||
char outfname[10000];
|
||||
char imgfname[10000];
|
||||
char pedfname[10000];
|
||||
char fn[10000];
|
||||
|
||||
std::time_t end_time;
|
||||
|
||||
FILE *of=NULL;
|
||||
|
||||
|
||||
cout << "time " << endl;
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
filter->setFrameMode(eFrame);
|
||||
// mt->setFrameMode(ePedestal);
|
||||
|
||||
|
||||
// for (int ix=0; ix<400; ix++)
|
||||
// for (int iy=0; iy<400; iy++)
|
||||
// cout << ix << " " << iy << " " << filter->getPedestal(ix,iy) << " " << filter->getPedestalRMS(ix,iy) << endl;
|
||||
|
||||
|
||||
char* buff;
|
||||
cout << "aa " << endl;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
cout << "mt " << endl;
|
||||
|
||||
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
|
||||
int ifr=0;
|
||||
// //loop on files
|
||||
// mt->setFrameMode(eFrame);
|
||||
//mt->setFrameMode(eFlat);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (int irun=runmin; irun<runmax; irun++) {
|
||||
sprintf(fn,fformat,irun);
|
||||
sprintf(fname,"%s/%s.raw",indir,fn);
|
||||
sprintf(outfname,"%s/%s.clust",outdir,fn);
|
||||
sprintf(imgfname,"%s/%s.tiff",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) {
|
||||
mt->setFilePointer(of);
|
||||
// cout << "file pointer set " << endl;
|
||||
} else {
|
||||
cout << "Could not open "<< outfname << " for writing " << endl;
|
||||
mt->setFilePointer(NULL);
|
||||
return 1;
|
||||
}
|
||||
// //while read frame
|
||||
ff=-1;
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
//cout << "*"<<ifr++<<"*"<<ff<< endl;
|
||||
//cout << ff << " " << np << endl;
|
||||
// //push
|
||||
mt->pushData(buff);
|
||||
// // //pop
|
||||
mt->nextThread();
|
||||
// // // cout << " " << (void*)buff;
|
||||
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();
|
||||
// //close file
|
||||
// //join threads
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
if (of)
|
||||
fclose(of);
|
||||
|
||||
mt->writeImage(imgfname);
|
||||
mt->clearImage();
|
||||
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
} else
|
||||
cout << "Could not open "<< fname << " for reading " << endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,249 +0,0 @@
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
//#define DOUBLE_SPH
|
||||
//#define MANYFILES
|
||||
|
||||
#ifdef DOUBLE_SPH
|
||||
#include "single_photon_hit_double.h"
|
||||
#endif
|
||||
|
||||
#ifndef DOUBLE_SPH
|
||||
#include "single_photon_hit.h"
|
||||
#endif
|
||||
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
#include "noInterpolation.h"
|
||||
#include "etaInterpolationCleverAdaptiveBins.h"
|
||||
//#include "etaInterpolationRandomBins.h"
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
#define MAX_ITERATIONS (nSubPixels*100)
|
||||
|
||||
#define XTALK
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
#ifndef FF
|
||||
if (argc<9) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile outfile runmin runmax ns cmin cmax" << endl;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FF
|
||||
if (argc<7) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile runmin runmax cmin cmax" << endl;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
int iarg=4;
|
||||
char infname[10000];
|
||||
char fname[10000];
|
||||
char outfname[10000];
|
||||
#ifndef FF
|
||||
iarg=4;
|
||||
#endif
|
||||
|
||||
#ifdef FF
|
||||
iarg=3;
|
||||
#endif
|
||||
int runmin=atoi(argv[iarg++]);
|
||||
int runmax=atoi(argv[iarg++]);
|
||||
cout << "Run min: " << runmin << endl;
|
||||
cout << "Run max: " << runmax << endl;
|
||||
|
||||
int nsubpix=4;
|
||||
#ifndef FF
|
||||
nsubpix=atoi(argv[iarg++]);
|
||||
cout << "Subpix: " << nsubpix << endl;
|
||||
#endif
|
||||
float cmin=atof(argv[iarg++]);
|
||||
float cmax=atof(argv[iarg++]);
|
||||
cout << "Energy min: " << cmin << endl;
|
||||
cout << "Energy max: " << cmax << endl;
|
||||
//int etabins=500;
|
||||
int etabins=1000;//nsubpix*2*100;
|
||||
double etamin=-1, etamax=2;
|
||||
//double etamin=-0.1, etamax=1.1;
|
||||
double eta3min=-2, eta3max=2;
|
||||
int quad;
|
||||
double sum, totquad;
|
||||
double sDum[2][2];
|
||||
double etax, etay, int_x, int_y;
|
||||
double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y;
|
||||
int ok;
|
||||
int f0=-1;
|
||||
int ix, iy, isx, isy;
|
||||
int nframes=0, lastframe=-1;
|
||||
double d_x, d_y, res=5, xx, yy;
|
||||
int nph=0, badph=0, totph=0;
|
||||
FILE *f=NULL;
|
||||
|
||||
#ifdef DOUBLE_SPH
|
||||
single_photon_hit_double cl(3,3);
|
||||
#endif
|
||||
|
||||
#ifndef DOUBLE_SPH
|
||||
single_photon_hit cl(3,3);
|
||||
#endif
|
||||
|
||||
int nSubPixels=nsubpix;
|
||||
#ifndef NOINTERPOLATION
|
||||
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
//eta2InterpolationCleverAdaptiveBins *interp=new eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
#endif
|
||||
#ifdef NOINTERPOLATION
|
||||
noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef FF
|
||||
#ifndef NOINTERPOLATION
|
||||
cout << "read ff " << argv[2] << endl;
|
||||
sprintf(fname,"%s",argv[2]);
|
||||
interp->readFlatField(fname);
|
||||
interp->prepareInterpolation(ok);//, MAX_ITERATIONS);
|
||||
#endif
|
||||
// return 0;
|
||||
#endif
|
||||
#ifdef FF
|
||||
cout << "Will write eta file " << argv[2] << endl;
|
||||
#endif
|
||||
|
||||
int *img;
|
||||
float *totimg=new float[NC*NR*nsubpix*nsubpix];
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR; iy++) {
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FF
|
||||
sprintf(outfname,argv[2]);
|
||||
#endif
|
||||
|
||||
int irun;
|
||||
for (irun=runmin; irun<runmax; irun++) {
|
||||
sprintf(infname,argv[1],irun);
|
||||
#ifndef FF
|
||||
sprintf(outfname,argv[3],irun);
|
||||
#endif
|
||||
|
||||
f=fopen(infname,"r");
|
||||
if (f) {
|
||||
cout << infname << endl;
|
||||
nframes=0;
|
||||
f0=-1;
|
||||
|
||||
while (cl.read(f)) {
|
||||
totph++;
|
||||
if (lastframe!=cl.iframe) {
|
||||
lastframe=cl.iframe;
|
||||
// cout << cl.iframe << endl;
|
||||
// f0=cl.iframe;
|
||||
if (nframes==0) f0=lastframe;
|
||||
nframes++;
|
||||
}
|
||||
//quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
||||
quad=interp->calcEta(cl.get_cluster(), etax, etay, sum, totquad, sDum);
|
||||
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && sum<cmax ) {
|
||||
nph++;
|
||||
// if (sum>200 && sum<580) {
|
||||
// interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y);
|
||||
// #ifdef SOLEIL
|
||||
// if (cl.x>210 && cl.x<240 && cl.y>210 && cl.y<240) {
|
||||
// #endif
|
||||
#ifndef FF
|
||||
// interp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y);
|
||||
interp->getInterpolatedPosition(cl.x,cl.y, etax, etay, quad,int_x, int_y);
|
||||
// cout <<"**************"<< endl;
|
||||
// cout << cl.x << " " << cl.y << " " << sum << endl;
|
||||
// cl.print();
|
||||
// cout << int_x << " " << int_y << endl;
|
||||
// cout <<"**************"<< endl;
|
||||
// if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
|
||||
interp->addToImage(int_x, int_y);
|
||||
if (int_x<0 || int_y<0 || int_x>400 || int_y>400) {
|
||||
cout <<"**************"<< endl;
|
||||
cout << cl.x << " " << cl.y << " " << sum << endl;
|
||||
cl.print();
|
||||
cout << int_x << " " << int_y << endl;
|
||||
cout <<"**************"<< endl;
|
||||
}
|
||||
#endif
|
||||
#ifdef FF
|
||||
// interp->addToFlatField(cl.get_cluster(), etax, etay);
|
||||
// #ifdef UCL
|
||||
// if (cl.x>50)
|
||||
// #endif
|
||||
// if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
|
||||
interp->addToFlatField(etax, etay);
|
||||
// if (etax==0 || etay==0) cout << cl.x << " " << cl.y << endl;
|
||||
|
||||
#endif
|
||||
// #ifdef SOLEIL
|
||||
// }
|
||||
// #endif
|
||||
|
||||
if (nph%1000000==0) cout << nph << endl;
|
||||
if (nph%10000000==0) {
|
||||
#ifndef FF
|
||||
interp->writeInterpolatedImage(outfname);
|
||||
#endif
|
||||
#ifdef FF
|
||||
interp->writeFlatField(outfname);
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
fclose(f);
|
||||
#ifdef FF
|
||||
interp->writeFlatField(outfname);
|
||||
#endif
|
||||
|
||||
#ifndef FF
|
||||
interp->writeInterpolatedImage(outfname);
|
||||
|
||||
img=interp->getInterpolatedImage();
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR; iy++) {
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]+=img[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << "Read " << nframes << " frames (first frame: " << f0 << " last frame: " << lastframe << " delta:" << lastframe-f0 << ") nph="<< nph <<endl;
|
||||
interp->clearInterpolatedImage();
|
||||
#endif
|
||||
|
||||
} else
|
||||
cout << "could not open file " << infname << endl;
|
||||
}
|
||||
#ifndef FF
|
||||
sprintf(outfname,argv[3],11111);
|
||||
WriteToTiff(totimg, outfname,NC*nsubpix,NR*nsubpix);
|
||||
#endif
|
||||
|
||||
#ifdef FF
|
||||
interp->writeFlatField(outfname);
|
||||
#endif
|
||||
|
||||
cout << "Filled " << nph << " (/"<< totph <<") " << endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,269 +0,0 @@
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
//#define DOUBLE_SPH
|
||||
//#define MANYFILES
|
||||
|
||||
#ifdef DOUBLE_SPH
|
||||
#include "single_photon_hit_double.h"
|
||||
#endif
|
||||
|
||||
#ifndef DOUBLE_SPH
|
||||
#include "single_photon_hit.h"
|
||||
#endif
|
||||
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
#include "noInterpolation.h"
|
||||
#include "etaInterpolationCleverAdaptiveBins.h"
|
||||
//#include "etaInterpolationRandomBins.h"
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
#define MAX_ITERATIONS (nSubPixels*100)
|
||||
#define MAX_EBINS 100
|
||||
#define XTALK
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
#ifndef FF
|
||||
if (argc<9) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile outfile runmin runmax ns cmin cmax" << endl;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FF
|
||||
if (argc<7) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile runmin runmax cmin cmax" << endl;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
int iarg=4;
|
||||
char infname[10000];
|
||||
char fname[10000];
|
||||
char outfname[10000];
|
||||
#ifndef FF
|
||||
iarg=4;
|
||||
#endif
|
||||
|
||||
#ifdef FF
|
||||
iarg=3;
|
||||
#endif
|
||||
int runmin=atoi(argv[iarg++]);
|
||||
int runmax=atoi(argv[iarg++]);
|
||||
cout << "Run min: " << runmin << endl;
|
||||
cout << "Run max: " << runmax << endl;
|
||||
|
||||
int nsubpix=4;
|
||||
#ifndef FF
|
||||
nsubpix=atoi(argv[iarg++]);
|
||||
cout << "Subpix: " << nsubpix << endl;
|
||||
#endif
|
||||
float cmin=atof(argv[iarg++]);
|
||||
float cmax=atof(argv[iarg++]);
|
||||
cout << "Energy min: " << cmin << endl;
|
||||
cout << "Energy max: " << cmax << endl;
|
||||
int n_ebins=1;
|
||||
if (argc>iarg)
|
||||
n_ebins=atoi(argv[iarg++]);
|
||||
//int etabins=500;
|
||||
int etabins=1000;//nsubpix*2*100;
|
||||
double etamin=-1, etamax=2;
|
||||
//double etamin=-0.1, etamax=1.1;
|
||||
double eta3min=-2, eta3max=2;
|
||||
int quad;
|
||||
double sum, totquad;
|
||||
double sDum[2][2];
|
||||
double etax, etay, int_x, int_y;
|
||||
double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y;
|
||||
int ok;
|
||||
int f0=-1;
|
||||
int ix, iy, isx, isy;
|
||||
int nframes=0, lastframe=-1;
|
||||
double d_x, d_y, res=5, xx, yy;
|
||||
int nph=0, badph=0, totph=0;
|
||||
FILE *f=NULL;
|
||||
|
||||
#ifdef DOUBLE_SPH
|
||||
single_photon_hit_double cl(3,3);
|
||||
#endif
|
||||
|
||||
#ifndef DOUBLE_SPH
|
||||
single_photon_hit cl(3,3);
|
||||
#endif
|
||||
|
||||
int nSubPixels=nsubpix;
|
||||
|
||||
int iebin=0;
|
||||
double eb_size=(cmax-cmin)/n_ebins;
|
||||
#ifndef NOINTERPOLATION
|
||||
// eta2InterpolationPosXY *interp[MAX_EBINS];
|
||||
eta2InterpolationCleverAdaptiveBins *interp[MAX_EBINS];
|
||||
for (int i=0; i< n_ebins; i++) {
|
||||
//interp[i]=new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
interp[i]=new eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
}
|
||||
#endif
|
||||
#ifdef NOINTERPOLATION
|
||||
noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef FF
|
||||
#ifndef NOINTERPOLATION
|
||||
cout << "read ff " << argv[2] << endl;
|
||||
for (int i=0; i< n_ebins; i++) {
|
||||
sprintf(fname,argv[2],i);
|
||||
interp[i]->readFlatField(fname);
|
||||
interp[i]->prepareInterpolation(ok);//, MAX_ITERATIONS);
|
||||
}
|
||||
#endif
|
||||
// return 0;
|
||||
#endif
|
||||
#ifdef FF
|
||||
cout << "Will write eta file " << argv[2] << endl;
|
||||
#endif
|
||||
|
||||
int *img;
|
||||
float *totimg=new float[NC*NR*nsubpix*nsubpix];
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR; iy++) {
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FF
|
||||
sprintf(outfname,argv[2]);
|
||||
#endif
|
||||
|
||||
int irun;
|
||||
for (irun=runmin; irun<runmax; irun++) {
|
||||
sprintf(infname,argv[1],irun);
|
||||
#ifndef FF
|
||||
sprintf(outfname,argv[3],irun);
|
||||
#endif
|
||||
|
||||
f=fopen(infname,"r");
|
||||
if (f) {
|
||||
cout << infname << endl;
|
||||
nframes=0;
|
||||
f0=-1;
|
||||
|
||||
while (cl.read(f)) {
|
||||
totph++;
|
||||
if (lastframe!=cl.iframe) {
|
||||
lastframe=cl.iframe;
|
||||
// cout << cl.iframe << endl;
|
||||
// f0=cl.iframe;
|
||||
if (nframes==0) f0=lastframe;
|
||||
nframes++;
|
||||
}
|
||||
//quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
||||
quad=interp[0]->calcEta(cl.get_cluster(), etax, etay, sum, totquad, sDum);
|
||||
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && sum<cmax ) {
|
||||
nph++;
|
||||
iebin=(sum-cmin)/eb_size;
|
||||
if (iebin>=0 && iebin<n_ebins) {
|
||||
// if (sum>200 && sum<580) {
|
||||
// interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y);
|
||||
// #ifdef SOLEIL
|
||||
// if (cl.x>210 && cl.x<240 && cl.y>210 && cl.y<240) {
|
||||
// #endif
|
||||
#ifndef FF
|
||||
// interp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y);
|
||||
interp[iebin]->getInterpolatedPosition(cl.x,cl.y, etax, etay, quad,int_x, int_y);
|
||||
// cout <<"**************"<< endl;
|
||||
// cout << cl.x << " " << cl.y << " " << sum << endl;
|
||||
// cl.print();
|
||||
// cout << int_x << " " << int_y << endl;
|
||||
// cout <<"**************"<< endl;
|
||||
if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
|
||||
interp[iebin]->addToImage(int_x, int_y);
|
||||
#endif
|
||||
#ifdef FF
|
||||
// interp->addToFlatField(cl.get_cluster(), etax, etay);
|
||||
#ifdef UCL
|
||||
if (cl.x>50)
|
||||
#endif
|
||||
if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
|
||||
interp[iebin]->addToFlatField(etax, etay);
|
||||
// if (etax==0 || etay==0) cout << cl.x << " " << cl.y << endl;
|
||||
|
||||
#endif
|
||||
// #ifdef SOLEIL
|
||||
// }
|
||||
// #endif
|
||||
|
||||
if (nph%1000000==0) cout << nph << endl;
|
||||
if (nph%10000000==0) {
|
||||
#ifndef FF
|
||||
for (int i=0; i<n_ebins; i++) {
|
||||
sprintf(outfname,argv[3],i);
|
||||
interp[i]->writeInterpolatedImage(outfname);
|
||||
}
|
||||
#endif
|
||||
#ifdef FF
|
||||
for (int i=0; i<n_ebins; i++) {
|
||||
sprintf(outfname,argv[2],i);
|
||||
cout << outfname << " " << argv[2] << " " << i << endl;
|
||||
interp[i]->writeFlatField(outfname);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
fclose(f);
|
||||
#ifdef FF
|
||||
for (int i=0; i<n_ebins; i++) {
|
||||
sprintf(outfname,argv[2],i);
|
||||
cout << outfname << " " << argv[2] << " " << i << endl;
|
||||
interp[i]->writeFlatField(outfname);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FF
|
||||
for (int i=0; i<n_ebins; i++) {
|
||||
sprintf(outfname,argv[3],i,irun);
|
||||
interp[i]->writeInterpolatedImage(outfname);
|
||||
img=interp[i]->getInterpolatedImage();
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR; iy++) {
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]+=img[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//interp[i]->clearInterpolatedImage();
|
||||
}
|
||||
cout << "Read " << nframes << " frames (first frame: " << f0 << " last frame: " << lastframe << " delta:" << lastframe-f0 << ")"<<endl;
|
||||
#endif
|
||||
|
||||
} else
|
||||
cout << "could not open file " << infname << endl;
|
||||
}
|
||||
#ifndef FF
|
||||
sprintf(outfname,argv[3], 11111);
|
||||
WriteToTiff(totimg, outfname,NC*nsubpix,NR*nsubpix);
|
||||
#endif
|
||||
|
||||
#ifdef FF
|
||||
interp[iebin]->writeFlatField(outfname);
|
||||
#endif
|
||||
|
||||
cout << "Filled " << nph << " (/"<< totph <<") " << endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,114 +0,0 @@
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
#include "single_photon_hit.h"
|
||||
|
||||
#include "etaInterpolationPosXY.h"
|
||||
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
|
||||
#define XTALK
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
int nsubpix=10;
|
||||
int etabins=nsubpix*100;
|
||||
double etamin=-1, etamax=2;
|
||||
double eta3min=-2, eta3max=2;
|
||||
int quad;
|
||||
double sum, totquad;
|
||||
double sDum[2][2];
|
||||
char fname[10000];
|
||||
double etax, etay;
|
||||
int runmin, runmax;
|
||||
single_photon_hit cl(3,3);
|
||||
int iph=0;
|
||||
|
||||
if (argc<7) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile " << " outfile runmin runmax cmin cmax" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
eta2InterpolationPosXY *interp2=new eta2InterpolationPosXY(NR, NC, nsubpix, etabins, etamin, etamax);
|
||||
cout << "###########"<< endl;
|
||||
eta3InterpolationPosXY *interp3=new eta3InterpolationPosXY(NR, NC, nsubpix, etabins, eta3min, eta3max);
|
||||
// cout << eta3min << " " << eta3max << endl;
|
||||
runmin=atoi(argv[3]);
|
||||
runmax=atoi(argv[4]);
|
||||
double cmin=atof(argv[5]); //200
|
||||
double cmax=atof(argv[6]); //3000
|
||||
|
||||
#ifdef XTALK
|
||||
int old_val[3][3];
|
||||
int new_val[3][3];
|
||||
double xcorr=0.04;
|
||||
|
||||
// int ix=0;
|
||||
#endif
|
||||
|
||||
FILE *f;
|
||||
for (int i=runmin; i<runmax; i++) {
|
||||
sprintf(fname,argv[1],i);
|
||||
f=fopen(fname,"r");
|
||||
if (f) {
|
||||
cout << "*" << endl;
|
||||
while (cl.read(f)) {
|
||||
#ifdef XTALK
|
||||
if ((cl.x+1)%25!=0) {
|
||||
for (int ix=-1; ix<2; ix++) {
|
||||
for (int iy=-1; iy<2; iy++) {
|
||||
old_val[iy+1][ix+1]=cl.get_data(ix,iy);
|
||||
if (ix>=0) {
|
||||
new_val[iy+1][ix+1]=old_val[iy+1][ix+1]-old_val[iy+1][ix]*xcorr;
|
||||
cl.set_data(new_val[iy+1][ix+1],ix,iy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
quad=interp2->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
||||
|
||||
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && totquad<cmax && quad<cmax) {
|
||||
/* Cross talk corrections !!! */
|
||||
// for (int ix=0; ix<2; ix++) {
|
||||
|
||||
|
||||
interp2->addToFlatField(cl.get_cluster(),etax, etay);
|
||||
// if (etax>0.49 && etax<0.51 && etay>0.49 && etay<0.51 ) {
|
||||
// cout << cl.y << " " << cl.x << " " << quad << " "<< totquad << " " <<sum << endl;
|
||||
|
||||
// }
|
||||
interp3->addToFlatField(cl.get_cluster(),etax, etay);
|
||||
iph++;
|
||||
if (iph%1000000==0) cout << iph << endl;
|
||||
if (iph%100000000==0) {
|
||||
sprintf(fname,"%s_eta2.tiff",argv[2]);
|
||||
interp2->writeFlatField(fname);
|
||||
sprintf(fname,"%s_eta3.tiff",argv[2]);
|
||||
interp3->writeFlatField(fname);
|
||||
}
|
||||
// if (iph>1E8) break;
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
}
|
||||
else cout << "could not open file " << fname << endl;
|
||||
}
|
||||
|
||||
sprintf(fname,"%s_eta2.tiff",argv[2]);
|
||||
interp2->writeFlatField(fname);
|
||||
sprintf(fname,"%s_eta3.tiff",argv[2]);
|
||||
interp3->writeFlatField(fname);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,171 +0,0 @@
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
#include "single_photon_hit.h"
|
||||
|
||||
#include "noInterpolation.h"
|
||||
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
|
||||
if (argc<7) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile " << " etafile outfile runmin runmax ns" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
char infname[10000];
|
||||
char outfname[10000];
|
||||
int runmin=atoi(argv[4]);
|
||||
int runmax=atoi(argv[5]);
|
||||
int nsubpix=atoi(argv[6]);
|
||||
|
||||
int etabins=1000;//nsubpix*2*100;
|
||||
double etamin=-1, etamax=2;
|
||||
int quad;
|
||||
double sum, totquad;
|
||||
double sDum[2][2];
|
||||
double etax, etay, int_x, int_y;
|
||||
int ok;
|
||||
|
||||
int ix, iy, isx, isy;
|
||||
|
||||
|
||||
FILE *f=NULL;
|
||||
|
||||
single_photon_hit cl(3,3);
|
||||
// etaInterpolationPosXY *interp=new etaInterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
// interp->readFlatField(argv[2]);
|
||||
// interp->prepareInterpolation(ok);
|
||||
|
||||
int *img;
|
||||
float *totimg=new float[NC*NR*nsubpix*nsubpix];
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR; iy++) {
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef FF
|
||||
|
||||
float ff[nsubpix*nsubpix];
|
||||
float *ffimg=new float[NC*NR*nsubpix*nsubpix];
|
||||
float totff=0;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
for (int irun=runmin; irun<runmax; irun++) {
|
||||
sprintf(infname,argv[1],irun);
|
||||
sprintf(outfname,argv[3],irun);
|
||||
|
||||
f=fopen(infname,"r");
|
||||
|
||||
if (f) {
|
||||
while (cl.read(f)) {
|
||||
quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
||||
if (sum>200 && sum<580) {
|
||||
interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y);
|
||||
interp->addToImage(int_x, int_y);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
#ifdef FF
|
||||
img=interp->getInterpolatedImage();
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
ff[isy*nsubpix+isx]=0;
|
||||
}
|
||||
}
|
||||
totff=0;
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR-100; iy++) {
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
ff[isy*nsubpix+isx]+=img[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
totff+=ff[isy*nsubpix+isx];
|
||||
}
|
||||
}
|
||||
totff/=nsubpix*nsubpix;
|
||||
|
||||
|
||||
if (totff) {
|
||||
|
||||
cout << "ff: " << totff << endl;
|
||||
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
ff[isy*nsubpix+isx]/=totff;
|
||||
cout << ff[isy*nsubpix+isx] << "\t";
|
||||
}
|
||||
cout << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR; iy++) {
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
ffimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]=img[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]/ff[isy*nsubpix+isx];
|
||||
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]+=ffimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
WriteToTiff(ffimg, outfname,NC*nsubpix,NR*nsubpix);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
#endif
|
||||
#ifndef FF
|
||||
interp->writeInterpolatedImage(outfname);
|
||||
img=interp->getInterpolatedImage();
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR; iy++) {
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]+=img[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
interp->clearInterpolatedImage();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(outfname,argv[3],11111);
|
||||
WriteToTiff(totimg, outfname,NC*nsubpix,NR*nsubpix);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,163 +0,0 @@
|
||||
//#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;
|
||||
}
|
||||
|
@ -1,242 +0,0 @@
|
||||
//#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
#ifdef NEWRECEIVER
|
||||
#include "moench03T1ReceiverDataNew.h"
|
||||
#endif
|
||||
#ifdef CSAXS_FP
|
||||
#include "moench03T1ReceiverData.h"
|
||||
#endif
|
||||
#ifdef OLDDATA
|
||||
#include "moench03Ctb10GbT1Data.h"
|
||||
#endif
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ctime>
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
if (argc<4) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname [pedfile] [threshold]" << 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;
|
||||
|
||||
|
||||
|
||||
#ifdef NEWRECEIVER
|
||||
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
|
||||
cout << "RECEIVER DATA WITH ONE HEADER!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef CSAXS_FP
|
||||
moench03T1ReceiverData *decoder=new moench03T1ReceiverData();
|
||||
cout << "RECEIVER DATA WITH ALL HEADERS!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef OLDDATA
|
||||
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
|
||||
cout << "OLD RECEIVER DATA!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifndef ANALOG
|
||||
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
|
||||
// char tit[10000];
|
||||
cout << "filter " << endl;
|
||||
#endif
|
||||
|
||||
#ifdef ANALOG
|
||||
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(decoder, 1, 0, nped);
|
||||
// char tit[10000];
|
||||
cout << "filter " << endl;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
int ff, np;
|
||||
int dsize=decoder->getDataSize();
|
||||
cout << " data size is " << dsize;
|
||||
|
||||
|
||||
char data[dsize];
|
||||
|
||||
ifstream filebin;
|
||||
char *indir=argv[1];
|
||||
char *outdir=argv[2];
|
||||
char *fformat=argv[3];
|
||||
char *pedfile=NULL;
|
||||
if (argc>=5) {
|
||||
pedfile=argv[4];
|
||||
}
|
||||
double thr=0;
|
||||
if (argc>=6) {
|
||||
thr=atoi(argv[5]);
|
||||
}
|
||||
|
||||
|
||||
char fname[10000];
|
||||
char imgfname[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 << "input file is " << fformat << endl;
|
||||
if (pedfile)
|
||||
cout << "pedestal file is " << pedfile << endl;
|
||||
if (thr>0) {
|
||||
cout << "threshold is " << thr << endl;
|
||||
filter->setThreshold(thr);
|
||||
}
|
||||
|
||||
filter->setROI(0,150,0,150);
|
||||
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
cout << "mt " << endl;
|
||||
|
||||
int ifr=0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (int irun=0; irun<2; irun++) {
|
||||
if (irun>0) {
|
||||
mt->setFrameMode(eFrame);
|
||||
// sprintf(fn,fformat,irun);
|
||||
sprintf(fname,"%s/%s.raw",indir,fformat);
|
||||
// sprintf(outfname,"%s/%s.clust",outdir,fn);
|
||||
sprintf(imgfname,"%s/%s.tiff",outdir,fformat);
|
||||
} else {
|
||||
mt->setFrameMode(ePedestal);
|
||||
// sprintf(fn,fformat,irun);
|
||||
sprintf(fname,"%s/%s.raw",indir,pedfile);
|
||||
// sprintf(outfname,"%s/%s.clust",outdir,fn);
|
||||
// sprintf(imgfname,"%s/%s.tiff",outdir,fn);
|
||||
}
|
||||
cout << fname << endl;
|
||||
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) {
|
||||
// mt->setFilePointer(of);
|
||||
// // cout << "file pointer set " << endl;
|
||||
// } else {
|
||||
// cout << "Could not open "<< outfname << " for writing " << endl;
|
||||
// mt->setFilePointer(NULL);
|
||||
// return 1;
|
||||
// }
|
||||
// //while read frame
|
||||
ff=-1;
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
// cout << "*"<<ifr++<<"*"<<ff<< endl;
|
||||
// cout << ff << " " << np << endl;
|
||||
// //push
|
||||
mt->pushData(buff);
|
||||
// // //pop
|
||||
mt->nextThread();
|
||||
// // // cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
ifr++;
|
||||
if (ifr%10000==0) cout << ifr << " " << ff << endl;
|
||||
ff=-1;
|
||||
}
|
||||
cout << "--" << endl;
|
||||
filebin.close();
|
||||
// //close file
|
||||
// //join threads
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
// if (of)
|
||||
// fclose(of);
|
||||
if (irun>0) {
|
||||
cout << "Writing tiff to " << imgfname << endl;
|
||||
mt->writeImage(imgfname);
|
||||
// mt->clearImage();
|
||||
}
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
} else
|
||||
cout << "Could not open "<< fname << " for reading " << endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,347 +0,0 @@
|
||||
//#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
#ifdef NEWRECEIVER
|
||||
#ifndef RECT
|
||||
#include "moench03T1ReceiverDataNew.h"
|
||||
#endif
|
||||
|
||||
#ifdef RECT
|
||||
#include "moench03T1ReceiverDataNewRect.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CSAXS_FP
|
||||
#include "moench03T1ReceiverData.h"
|
||||
#endif
|
||||
#ifdef OLDDATA
|
||||
#include "moench03Ctb10GbT1Data.h"
|
||||
#endif
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ctime>
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
if (argc<4) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname [runmin] [runmax] [pedfile] [threshold] [nframes] [xmin xmax ymin ymax]" << endl;
|
||||
cout << "threshold <0 means analog; threshold=0 means cluster finder; threshold>0 means photon counting" << endl;
|
||||
cout << "nframes <0 means sum everything; nframes=0 means one file per run; nframes>0 means one file every nframes" << 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 save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
int iprog=0;
|
||||
|
||||
int cf=0;
|
||||
|
||||
#ifdef NEWRECEIVER
|
||||
#ifdef RECT
|
||||
cout << "Should be rectangular!" <<endl;
|
||||
#endif
|
||||
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
|
||||
cout << "RECEIVER DATA WITH ONE HEADER!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef CSAXS_FP
|
||||
moench03T1ReceiverData *decoder=new moench03T1ReceiverData();
|
||||
cout << "RECEIVER DATA WITH ALL HEADERS!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef OLDDATA
|
||||
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
|
||||
cout << "OLD RECEIVER DATA!"<<endl;
|
||||
#endif
|
||||
|
||||
int nx=400, ny=400;
|
||||
|
||||
decoder->getDetectorSize(nx,ny);
|
||||
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
int ff, np;
|
||||
int dsize=decoder->getDataSize();
|
||||
//cout << " data size is " << dsize;
|
||||
|
||||
|
||||
char data[dsize];
|
||||
|
||||
ifstream filebin;
|
||||
char *indir=argv[1];
|
||||
char *outdir=argv[2];
|
||||
char *fformat=argv[3];
|
||||
int runmin=0;
|
||||
|
||||
// cout << "argc is " << argc << endl;
|
||||
if (argc>=5) {
|
||||
runmin=atoi(argv[4]);
|
||||
}
|
||||
|
||||
int runmax=runmin;
|
||||
|
||||
if (argc>=6) {
|
||||
runmax=atoi(argv[5]);
|
||||
}
|
||||
|
||||
char *pedfile=NULL;
|
||||
if (argc>=7) {
|
||||
pedfile=argv[6];
|
||||
}
|
||||
double thr=0;
|
||||
double thr1=1;
|
||||
|
||||
if (argc>=8) {
|
||||
thr=atoi(argv[7]);
|
||||
}
|
||||
|
||||
|
||||
int nframes=0;
|
||||
|
||||
if (argc>=9) {
|
||||
nframes=atoi(argv[8]);
|
||||
}
|
||||
int xmin=0, xmax=nx, ymin=0, ymax=ny;
|
||||
if (argc>=13) {
|
||||
xmin=atoi(argv[9]);
|
||||
xmax=atoi(argv[10]);
|
||||
ymin=atoi(argv[11]);
|
||||
ymax=atoi(argv[12]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
char ffname[10000];
|
||||
char fname[10000];
|
||||
char imgfname[10000];
|
||||
char cfname[10000];
|
||||
char fn[10000];
|
||||
|
||||
std::time_t end_time;
|
||||
|
||||
FILE *of=NULL;
|
||||
cout << "input directory is " << indir << endl;
|
||||
cout << "output directory is " << outdir << endl;
|
||||
cout << "input file is " << fformat << endl;
|
||||
cout << "runmin is " << runmin << endl;
|
||||
cout << "runmax is " << runmax << endl;
|
||||
if (pedfile)
|
||||
cout << "pedestal file is " << pedfile << endl;
|
||||
//#ifndef ANALOG
|
||||
if (thr>0) {
|
||||
cout << "threshold is " << thr << endl;
|
||||
filter->setThreshold(thr);
|
||||
} else
|
||||
cf=1;
|
||||
//#endif
|
||||
|
||||
|
||||
filter->setROI(xmin,xmax,ymin,ymax);
|
||||
#ifdef SOLEIL
|
||||
filter->setROI(150,210,170,230);
|
||||
nframes=-1;
|
||||
#endif
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
#ifndef ANALOG
|
||||
mt->setDetectorMode(ePhotonCounting);
|
||||
cout << "Counting!" << endl;
|
||||
if (thr>0) {
|
||||
cf=0;
|
||||
}
|
||||
#endif
|
||||
//{
|
||||
#ifdef ANALOG
|
||||
mt->setDetectorMode(eAnalog);
|
||||
cout << "Analog!" << endl;
|
||||
cf=0;
|
||||
// #ifdef ANALOG
|
||||
// thr1=thr;
|
||||
#endif
|
||||
// }
|
||||
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
// cout << "mt " << endl;
|
||||
|
||||
int ifr=0;
|
||||
|
||||
|
||||
|
||||
|
||||
if (pedfile) {
|
||||
cout << "PEDESTAL " ;
|
||||
sprintf(fname,"%s.raw",pedfile);
|
||||
cout << fname << endl ;
|
||||
sprintf(imgfname,"%s/pedestals.tiff",outdir,fformat);
|
||||
std::time(&end_time);
|
||||
cout << "aaa" << std::ctime(&end_time) << endl;
|
||||
|
||||
|
||||
mt->setFrameMode(ePedestal);
|
||||
// sprintf(fn,fformat,irun);
|
||||
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||
// //open file
|
||||
if (filebin.is_open()){
|
||||
ff=-1;
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
ifr++;
|
||||
if (ifr%10000==0)
|
||||
cout << ifr << " " << ff << " " << np << endl;
|
||||
ff=-1;
|
||||
}
|
||||
filebin.close();
|
||||
while (mt->isBusy()) {;}
|
||||
mt->writePedestal(imgfname);
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
} else
|
||||
cout << "Could not open "<< fname << " for reading " << endl;
|
||||
}
|
||||
|
||||
|
||||
ifr=0;
|
||||
int ifile=0;
|
||||
|
||||
for (int irun=runmin; irun<=runmax; irun++) {
|
||||
cout << "DATA " ;
|
||||
mt->setFrameMode(eFrame);
|
||||
// sprintf(fn,fformat,irun);
|
||||
sprintf(ffname,"%s/%s.raw",indir,fformat);
|
||||
sprintf(fname,ffname,irun);
|
||||
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
|
||||
sprintf(imgfname,ffname,irun);
|
||||
sprintf(ffname,"%s/%s.clust",outdir,fformat);
|
||||
sprintf(cfname,ffname,irun);
|
||||
cout << fname << " " ;
|
||||
cout << imgfname << endl;
|
||||
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
|
||||
ifile=0;
|
||||
if (filebin.is_open()){
|
||||
if (thr<=0) {
|
||||
if (cf) {
|
||||
if (of==NULL) {
|
||||
of=fopen(cfname,"w");
|
||||
if (of) {
|
||||
mt->setFilePointer(of);
|
||||
cout << "file pointer set " << endl;
|
||||
} else {
|
||||
cout << "Could not open "<< cfname << " for writing " << endl;
|
||||
mt->setFilePointer(NULL);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// //while read frame
|
||||
ff=-1;
|
||||
ifr=0;
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
// cout << "*"<<ifr++<<"*"<<ff<< endl;
|
||||
// cout << ff << " " << np << endl;
|
||||
// //push
|
||||
mt->pushData(buff);
|
||||
// // //pop
|
||||
mt->nextThread();
|
||||
// // // cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
ifr++;
|
||||
if (ifr%1000==0) cout << ifr << " " << ff << endl;
|
||||
if (nframes>0) {
|
||||
if (ifr%nframes==0) {
|
||||
//The name has an additional "_fXXXXX" at the end, where "XXXXX" is the initial frame number of the image (0,1000,2000...)
|
||||
|
||||
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
|
||||
sprintf(imgfname,ffname,irun);
|
||||
//cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
|
||||
mt->writeImage(imgfname, thr1);
|
||||
mt->clearImage();
|
||||
ifile++;
|
||||
}
|
||||
}
|
||||
|
||||
ff=-1;
|
||||
}
|
||||
cout << "--" << endl;
|
||||
filebin.close();
|
||||
// //close file
|
||||
// //join threads
|
||||
while (mt->isBusy()) {;}
|
||||
if (nframes>=0) {
|
||||
if (nframes>0) {
|
||||
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
|
||||
sprintf(imgfname,ffname,irun);
|
||||
}
|
||||
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
|
||||
sprintf(imgfname,ffname,irun);
|
||||
cout << "Writing tiff to " << imgfname << " " << thr1 <<endl;
|
||||
mt->writeImage(imgfname, thr1);
|
||||
mt->clearImage();
|
||||
if (of) {
|
||||
fclose(of);
|
||||
of=NULL;
|
||||
mt->setFilePointer(NULL);
|
||||
}
|
||||
}
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
} else
|
||||
cout << "Could not open "<< fname << " for reading " << endl;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,394 +0,0 @@
|
||||
//#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;
|
||||
}
|
||||
|
@ -1,402 +0,0 @@
|
||||
#include "sls_receiver_defs.h"
|
||||
#include "ZmqSocket.h"
|
||||
#include "moench03T1ZmqDataNew.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include "tiffIO.h"
|
||||
|
||||
|
||||
//#define NEWZMQ
|
||||
#ifdef NEWZMQ
|
||||
#include <rapidjson/document.h> //json header in zmq stream
|
||||
#endif
|
||||
|
||||
#include<iostream>
|
||||
|
||||
//#include "analogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
#include "multiThreadedAnalogDetector.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]
|
||||
*
|
||||
*/
|
||||
FILE *of=NULL;
|
||||
int fifosize=1000;
|
||||
int nthreads=20;
|
||||
// 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 maxSize = 32*2*8192;//5000;//atoi(argv[3]);
|
||||
int size= 32*2*5000;
|
||||
int multisize=size;
|
||||
// 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);
|
||||
|
||||
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
ZmqSocket* zmqsocket=NULL;
|
||||
|
||||
#ifdef NEWZMQ
|
||||
// receive socket
|
||||
try{
|
||||
#endif
|
||||
|
||||
zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
|
||||
|
||||
#ifdef NEWZMQ
|
||||
} catch (...) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEWZMQ
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
if (zmqsocket->Connect()) {
|
||||
cprintf(RED, "Error: Could not connect to socket %s\n",
|
||||
zmqsocket->GetZmqServerAddress());
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
} else
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
cout << "zmq2 " << endl;
|
||||
if (send) {
|
||||
#ifdef NEWZMQ
|
||||
// receive socket
|
||||
try{
|
||||
#endif
|
||||
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
|
||||
|
||||
|
||||
#ifdef NEWZMQ
|
||||
} catch (...) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
delete zmqsocket2;
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEWZMQ
|
||||
if (zmqsocket2->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
delete zmqsocket2;
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif
|
||||
if (zmqsocket2->Connect()) {
|
||||
cprintf(RED, "Error: Could not connect to socket %s\n",
|
||||
zmqsocket2->GetZmqServerAddress());
|
||||
delete zmqsocket2;
|
||||
return EXIT_FAILURE;
|
||||
} else
|
||||
printf("Zmq Client at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 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))]();
|
||||
uint32_t flippedDataX = -1;
|
||||
int *nph;
|
||||
int iframe=0;
|
||||
char ofname[10000];
|
||||
|
||||
char fname[10000];
|
||||
int length;
|
||||
int *detimage;
|
||||
int nnx, nny,nns;
|
||||
uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0, dynamicRange = 0;
|
||||
filter->getImageSize(nnx, nny,nns);
|
||||
int16_t *dout=new int16_t [nnx*nny];
|
||||
// infinite loop
|
||||
uint32_t packetNumber = 0;
|
||||
uint64_t bunchId = 0;
|
||||
uint64_t timestamp = 0;
|
||||
int16_t modId = 0;
|
||||
uint16_t xCoord = 0;
|
||||
uint16_t yCoord = 0;
|
||||
uint16_t zCoord = 0;
|
||||
uint32_t debug = 0;
|
||||
uint32_t dr = 16;
|
||||
uint16_t roundRNumber = 0;
|
||||
uint8_t detType = 0;
|
||||
uint8_t version = 0;
|
||||
int* flippedData = 0;
|
||||
char* additionalJsonHeader = 0;
|
||||
|
||||
uint32_t threshold=0;
|
||||
|
||||
uint32_t xmin=0, xmax=400, ymin=0, ymax=400;
|
||||
|
||||
string frameMode_s, detectorMode_s;
|
||||
|
||||
int emin, emax;
|
||||
|
||||
|
||||
int newFrame=1;
|
||||
|
||||
while(1) {
|
||||
|
||||
|
||||
// cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
#ifndef NEWZMQ
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){
|
||||
#endif
|
||||
|
||||
#ifdef NEWZMQ
|
||||
rapidjson::Document doc;
|
||||
if (!zmqsocket->ReceiveHeader(0, doc, SLS_DETECTOR_JSON_HEADER_VERSION)) {
|
||||
zmqsocket->CloseHeaderMessage();
|
||||
|
||||
#endif
|
||||
// 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
|
||||
|
||||
|
||||
detimage=mt->getImage(nnx,nny,nns);
|
||||
for (int ix=0; ix<nnx; ix++) {
|
||||
for (int iy=0; iy<nny; iy++) {
|
||||
dout[iy*nnx+ix]=detimage[iy*nnx+ix];
|
||||
}
|
||||
}
|
||||
|
||||
if (send) {
|
||||
strcpy(fname,filename.c_str());
|
||||
#ifdef NEWZMQ
|
||||
//zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dynamicRange, fileindex,
|
||||
// nnx, nny, nns*dynamicRange/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
|
||||
|
||||
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex,
|
||||
nnx, nny, nns*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NEWZMQ
|
||||
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);
|
||||
#endif
|
||||
|
||||
zmqsocket2->SendData((char*)dout,length);
|
||||
cprintf(GREEN, "Sent Data\n");
|
||||
}
|
||||
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
if (send) {
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
}
|
||||
mt->clearImage();
|
||||
if (of) {
|
||||
fclose(of);
|
||||
of=NULL;
|
||||
}
|
||||
|
||||
newFrame=1;
|
||||
continue; //continue to not get out
|
||||
}
|
||||
|
||||
#ifdef NEWZMQ
|
||||
if (newFrame) {
|
||||
// acqIndex, frameIndex, subframeIndex, filename, fileindex
|
||||
size = doc["size"].GetUint();
|
||||
multisize = size;// * zmqsocket->size();
|
||||
dynamicRange = doc["bitmode"].GetUint();
|
||||
nPixelsX = doc["shape"][0].GetUint();
|
||||
nPixelsY = doc["shape"][1].GetUint();
|
||||
filename = doc["fname"].GetString();
|
||||
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();
|
||||
|
||||
|
||||
|
||||
cprintf(BLUE, "Header Info:\n"
|
||||
"size: %u\n"
|
||||
"multisize: %u\n"
|
||||
"dynamicRange: %u\n"
|
||||
"nPixelsX: %u\n"
|
||||
"nPixelsY: %u\n"
|
||||
"currentFileName: %s\n"
|
||||
"currentAcquisitionIndex: %lu\n"
|
||||
"currentFrameIndex: %lu\n"
|
||||
"currentFileIndex: %lu\n"
|
||||
"currentSubFrameIndex: %u\n"
|
||||
"xCoordX: %u\n"
|
||||
"yCoordY: %u\n"
|
||||
"zCoordZ: %u\n"
|
||||
"flippedDataX: %u\n"
|
||||
"packetNumber: %u\n"
|
||||
"bunchId: %u\n"
|
||||
"timestamp: %u\n"
|
||||
"modId: %u\n"
|
||||
"debug: %u\n"
|
||||
"roundRNumber: %u\n"
|
||||
"detType: %u\n"
|
||||
"version: %u\n",
|
||||
size, multisize, dynamicRange, nPixelsX, nPixelsY,
|
||||
filename.c_str(), acqIndex,
|
||||
frameIndex, fileindex, subFrameIndex,
|
||||
xCoord, yCoord,zCoord,
|
||||
flippedDataX, packetNumber, bunchId, timestamp, modId, debug, roundRNumber, detType, version);
|
||||
|
||||
|
||||
if (doc.HasMember("threshold")) {
|
||||
version=doc["threshold"].GetUint();
|
||||
|
||||
}
|
||||
|
||||
if (doc.HasMember("roi")) {
|
||||
xmin=doc["roi"][0].GetUint();
|
||||
xmax=doc["roi"][1].GetUint();
|
||||
ymin=doc["roi"][2].GetUint();
|
||||
ymax=doc["roi"][3].GetUint();
|
||||
|
||||
}
|
||||
|
||||
if (doc.HasMember("frameMode")) {
|
||||
frameMode_s=doc["frameMode"].GetString();
|
||||
|
||||
}
|
||||
|
||||
if (doc.HasMember("detectorMode")) {
|
||||
detectorMode_s=doc["detectorMode"].GetString();
|
||||
|
||||
}
|
||||
|
||||
if (doc.HasMember("energyRange")) {
|
||||
emin=doc["energyRange"][0].GetUint();
|
||||
emax=doc["energyRange"][0].GetUint();
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (doc.HasMember("dynamicRange")) {
|
||||
dr=doc["dynamicRange"].GetUint();
|
||||
}
|
||||
|
||||
if (doc.HasMember("nSubPixels")) {
|
||||
nsubPixels=doc["nSubPixels"].GetUint();
|
||||
}
|
||||
|
||||
|
||||
|
||||
newFrame=0;
|
||||
zmqsocket->CloseHeaderMessage();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (of==NULL) {
|
||||
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
|
||||
of=fopen(ofname,"w");
|
||||
if (of) {
|
||||
mt->setFilePointer(of);
|
||||
}else {
|
||||
cout << "Could not open "<< ofname << " for writing " << endl;
|
||||
mt->setFilePointer(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
// get data
|
||||
length = zmqsocket->ReceiveData(0, buff, size);
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
|
||||
|
||||
iframe++;
|
||||
} // exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
if (send)
|
||||
delete zmqsocket2;
|
||||
|
||||
|
||||
cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,292 +0,0 @@
|
||||
#include "sls_receiver_defs.h"
|
||||
#include "ZmqSocket.h"
|
||||
#include "moench03T1ZmqDataNew.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include "tiffIO.h"
|
||||
|
||||
#include<iostream>
|
||||
|
||||
//#include "analogDetector.h"
|
||||
#include "interpolatingDetector.h"
|
||||
#include "linearInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.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 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 int_ready=0;
|
||||
int ok;
|
||||
// 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
|
||||
int size = 32*2*5000;//atoi(argv[3]);
|
||||
bool send = false;
|
||||
|
||||
|
||||
|
||||
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();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
zmqsocket->Connect();
|
||||
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;
|
||||
}
|
||||
zmqsocket2->Connect();
|
||||
printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
}
|
||||
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
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))]();
|
||||
|
||||
int *nph;
|
||||
int iframe=0;
|
||||
char ofname[10000];
|
||||
|
||||
char fname[10000];
|
||||
int length;
|
||||
int *detimage;
|
||||
int nnx, nny,nns;
|
||||
int nix, niy,nis;
|
||||
filter->getImageSize(nnx, nny,nns);
|
||||
int16_t *dout=new int16_t [nnx*nny];
|
||||
// infinite loop
|
||||
int ix, iy, isx, isy;
|
||||
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 (frameMode==ePedestal) {
|
||||
detped=mt->getPedestal();
|
||||
if (detped) {
|
||||
|
||||
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);
|
||||
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);
|
||||
// cprintf(RED, "Sent Dummy\n");
|
||||
cprintf(RED, "Received %d frames\n", iframe);
|
||||
}
|
||||
mt->clearImage();
|
||||
if (of) {
|
||||
fclose(of);
|
||||
of=NULL;
|
||||
}
|
||||
iframe=0;
|
||||
continue; //continue to not get out
|
||||
}
|
||||
|
||||
|
||||
if (of==NULL) {
|
||||
while (mt->isBusy()) {;}
|
||||
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
|
||||
of=fopen(ofname,"w");
|
||||
if (of) {
|
||||
mt->setFilePointer(of);
|
||||
}else {
|
||||
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
|
||||
length = zmqsocket->ReceiveData(0, buff, size);
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
|
||||
iframe++;
|
||||
} // exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
if (send)
|
||||
delete zmqsocket2;
|
||||
|
||||
|
||||
// cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,710 +0,0 @@
|
||||
#define WRITE_QUAD
|
||||
|
||||
#include "sls_receiver_defs.h"
|
||||
#include "ZmqSocket.h"
|
||||
#include "moench03T1ZmqDataNew.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include "tiffIO.h"
|
||||
|
||||
//#define NEWZMQ
|
||||
#ifdef NEWZMQ
|
||||
#include <rapidjson/document.h> //json header in zmq stream
|
||||
#endif
|
||||
|
||||
#include<iostream>
|
||||
|
||||
//#include "analogDetector.h"
|
||||
//#include "multiThreadedAnalogDetector.h"
|
||||
//#include "singlePhotonDetector.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
//#include "multiThreadedCountingDetector.h"
|
||||
#include "multiThreadedInterpolatingDetector.h"
|
||||
#include "etaInterpolationPosXY.h"
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
//#include <chrono>
|
||||
#include <ctime> // time_t
|
||||
#include <cstdio>
|
||||
|
||||
using namespace std;
|
||||
//using namespace std::chrono;
|
||||
|
||||
//#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
// myDet->setNetworkParameter(ADDITIONAL_JSON_HEADER, " \"what\":\"nothing\" ");
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [send_socket ip] [send port number]
|
||||
*
|
||||
*/
|
||||
FILE *of=NULL;
|
||||
int fifosize=5000;
|
||||
int etabins=1000;//nsubpix*2*100;
|
||||
double etamin=-1, etamax=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] [etafile]\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip=argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
// send parameters if any
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
|
||||
|
||||
int ok;
|
||||
|
||||
// high_resolution_clock::time_point t1;
|
||||
// high_resolution_clock::time_point t2 ;
|
||||
time_t begin,end,finished;
|
||||
|
||||
|
||||
if (argc > 4) {
|
||||
socketip2 = argv[3];
|
||||
portnum2 = atoi(argv[4]);
|
||||
if (portnum2>0)
|
||||
send = true;
|
||||
}
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum ;
|
||||
if (send) {
|
||||
cout << "\ntx socket ip : " << socketip2 <<
|
||||
"\ntx port num : " << portnum2;
|
||||
}
|
||||
int nthreads=5;
|
||||
if (argc>5)
|
||||
nthreads=atoi(argv[5]);
|
||||
|
||||
cout << "Number of threads is: " << nthreads << endl;
|
||||
int nSubPixels=2;
|
||||
if (argc>6)
|
||||
nSubPixels=atoi(argv[6]);
|
||||
cout << "Number of subpixels is: " << nSubPixels << endl;
|
||||
|
||||
char *etafname=NULL;
|
||||
if (argc>7) {
|
||||
etafname=argv[7];
|
||||
cout << "Eta file name is: " << etafname << endl;
|
||||
}
|
||||
|
||||
|
||||
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||
cout << endl << " det" <<endl;
|
||||
int npx, npy;
|
||||
det->getDetectorSize(npx, npy);
|
||||
|
||||
|
||||
|
||||
|
||||
int maxSize = npx*npy*2;//32*2*8192;//5000;//atoi(argv[3]);
|
||||
int size= maxSize;//32*2*5000;
|
||||
int multisize=size;
|
||||
int dataSize=size;
|
||||
|
||||
char dummybuff[size];
|
||||
|
||||
|
||||
|
||||
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
|
||||
#ifndef INTERP
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10);
|
||||
|
||||
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);
|
||||
|
||||
if (etafname) interp->readFlatField(etafname);
|
||||
|
||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, 5, 1, 0, 1000, 10);
|
||||
multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
char* buff;
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
ZmqSocket* zmqsocket=NULL;
|
||||
|
||||
#ifdef NEWZMQ
|
||||
// receive socket
|
||||
try{
|
||||
#endif
|
||||
|
||||
zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
|
||||
|
||||
#ifdef NEWZMQ
|
||||
} catch (...) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEWZMQ
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
if (zmqsocket->Connect()) {
|
||||
cprintf(RED, "Error: Could not connect to socket %s\n",
|
||||
zmqsocket->GetZmqServerAddress());
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
} else
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
// cout << "zmq2 " << endl;
|
||||
if (send) {
|
||||
#ifdef NEWZMQ
|
||||
// receive socket
|
||||
try{
|
||||
#endif
|
||||
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
|
||||
|
||||
|
||||
#ifdef NEWZMQ
|
||||
} catch (...) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
// delete zmqsocket2;
|
||||
// zmqsocket2=NULL;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
send = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEWZMQ
|
||||
if (zmqsocket2->IsError()) {
|
||||
cprintf(RED, "AAA Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
// delete zmqsocket2;
|
||||
//delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
send = false;
|
||||
}
|
||||
#endif
|
||||
if (zmqsocket2->Connect()) {
|
||||
cprintf(RED, "BBB Error: Could not connect to socket %s\n",
|
||||
zmqsocket2->GetZmqServerAddress());
|
||||
// delete zmqsocket2;
|
||||
send = false;
|
||||
// return EXIT_FAILURE;
|
||||
} else
|
||||
printf("Zmq Client at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 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))]();
|
||||
uint32_t flippedDataX = -1;
|
||||
int *nph;
|
||||
int iframe=0;
|
||||
char ofname[10000];
|
||||
|
||||
char fname[10000];
|
||||
int length;
|
||||
int *detimage;
|
||||
int nnx, nny,nns;
|
||||
uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0, dynamicRange = 0;
|
||||
// infinite loop
|
||||
uint32_t packetNumber = 0;
|
||||
uint64_t bunchId = 0;
|
||||
uint64_t timestamp = 0;
|
||||
int16_t modId = 0;
|
||||
uint16_t xCoord = 0;
|
||||
uint16_t yCoord = 0;
|
||||
uint16_t zCoord = 0;
|
||||
uint32_t debug = 0;
|
||||
//uint32_t dr = 16;
|
||||
//int16_t *dout;//=new int16_t [nnx*nny];
|
||||
uint32_t dr = 32;
|
||||
int32_t *dout=NULL;//=new int32_t [nnx*nny];
|
||||
uint32_t nSigma=5;
|
||||
uint16_t roundRNumber = 0;
|
||||
uint8_t detType = 0;
|
||||
uint8_t version = 0;
|
||||
int* flippedData = 0;
|
||||
char* additionalJsonHeader = 0;
|
||||
|
||||
int32_t threshold=0;
|
||||
|
||||
int32_t xmin=0, xmax=400, ymin=0, ymax=400;
|
||||
|
||||
string frameMode_s, detectorMode_s, intMode_s;
|
||||
|
||||
int emin, emax;
|
||||
int resetFlat=0;
|
||||
int resetPed=0;
|
||||
int nsubPixels=1;
|
||||
int isPedestal;
|
||||
int isFlat=0;
|
||||
int newFrame=1;
|
||||
detectorMode dMode;
|
||||
frameMode fMode;
|
||||
double *ped;
|
||||
|
||||
filter->getImageSize(nnx, nny,nns);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
while(1) {
|
||||
|
||||
|
||||
// cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
#ifndef NEWZMQ
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){
|
||||
#endif
|
||||
|
||||
#ifdef NEWZMQ
|
||||
rapidjson::Document doc;
|
||||
if (!zmqsocket->ReceiveHeader(0, doc, SLS_DETECTOR_JSON_HEADER_VERSION)) {
|
||||
/* zmqsocket->CloseHeaderMessage();*/
|
||||
|
||||
#endif
|
||||
// if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) {
|
||||
// cprintf(RED, "Got Dummy\n");
|
||||
// t1=high_resolution_clock::now();
|
||||
time(&end);
|
||||
|
||||
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
if (of) {
|
||||
fclose(of);
|
||||
of=NULL;
|
||||
}
|
||||
if (newFrame>0) {
|
||||
cprintf(RED,"DIDn't receive any data!\n");
|
||||
if (send) {
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
}
|
||||
} else {
|
||||
if (fMode==ePedestal) {
|
||||
sprintf(ofname,"%s_%d_ped.tiff",fname,fileindex);
|
||||
mt->writePedestal(ofname);
|
||||
cout << "Writing pedestal to " << ofname << endl;
|
||||
}
|
||||
#ifdef INTERP
|
||||
else if (fMode==eFlat) {
|
||||
mt->prepareInterpolation(ok);
|
||||
sprintf(ofname,"%s_%d_eta.tiff",fname,fileindex);
|
||||
mt->writeFlatField(ofname);
|
||||
cout << "Writing eta to " << ofname << endl;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
sprintf(ofname,"%s_%d.tiff",fname,fileindex);
|
||||
mt->writeImage(ofname);
|
||||
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;
|
||||
nnx=npx;
|
||||
nny=npy;
|
||||
//dout= new int16_t[nnx*nny*nns*nns];
|
||||
dout= new int32_t[nnx*nny*nns*nns];
|
||||
// cout << "get pedestal " << endl;
|
||||
ped=mt->getPedestal();
|
||||
// cout << "got pedestal " << endl;
|
||||
for (int ix=0; ix<nnx*nny; ix++) {
|
||||
|
||||
dout[ix]=ped[ix];
|
||||
// if (ix<100*400)
|
||||
// cout << ix << " " << ped[ix] << endl;
|
||||
}
|
||||
|
||||
}
|
||||
#ifdef INTERP
|
||||
else if (fMode==eFlat) {
|
||||
int nb;
|
||||
double emi, ema;
|
||||
int *ff=mt->getFlatField(nb, emi, ema);
|
||||
nnx=nb;
|
||||
nny=nb;
|
||||
dout= new int32_t[nb*nb];
|
||||
for (int ix=0; ix<nb*nb; ix++) {
|
||||
dout[ix]=ff[ix];
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
detimage=mt->getImage(nnx,nny,nns);
|
||||
cprintf(MAGENTA,"Get image!\n");
|
||||
cout << nnx << " " << nny << " " << nns << endl;
|
||||
// nns=1;
|
||||
// nnx=npx;
|
||||
// nny=npy;
|
||||
// nnx=nnx*nns;
|
||||
//nny=nny*nns;
|
||||
dout= new int32_t[nnx*nny];
|
||||
for (int ix=0; ix<nnx*nny; ix++) {
|
||||
// for (int iy=0; iy<nny*nns; iy++) {
|
||||
// for (int isx=0; isx<nns; isx++) {
|
||||
// for (int isy=0; isy<nns; isy++) {
|
||||
// if (isx==0 && isy==0)
|
||||
// dout[iy*nnx+ix]=detimage[(iy+isy)*nnx*nns+ix+isx];
|
||||
// else
|
||||
// dout[iy*nnx+ix]+=detimage[(iy+isy)*nnx*nns+ix+isx];
|
||||
|
||||
// }
|
||||
// }
|
||||
dout[ix]=detimage[ix];
|
||||
if (dout[ix]<0) dout[ix]=0;
|
||||
// cout << ix << " " << dout[ix] << endl;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef NEWZMQ
|
||||
cout << "Sending image size " << nnx << " " << nny << endl;
|
||||
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NEWZMQ
|
||||
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);
|
||||
#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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
mt->clearImage();
|
||||
|
||||
newFrame=1;
|
||||
//t2 = high_resolution_clock::now();
|
||||
|
||||
time(&finished);
|
||||
// auto meas_duration = duration_cast<microseconds>( t2 - t0 ).count();
|
||||
// auto real_duration = duration_cast<microseconds>( t2 - t1 ).count();
|
||||
|
||||
cout << "Measurement lasted " << difftime(end,begin) << endl;
|
||||
cout << "Processing lasted " << difftime(finished,begin) << endl;
|
||||
continue; //continue to not get out
|
||||
|
||||
|
||||
}
|
||||
|
||||
#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();
|
||||
dynamicRange = doc["bitmode"].GetUint();
|
||||
// nPixelsX = doc["shape"][0].GetUint();
|
||||
// nPixelsY = doc["shape"][1].GetUint();
|
||||
filename = doc["fname"].GetString();
|
||||
//acqIndex = doc["acqIndex"].GetUint64();
|
||||
//frameIndex = doc["fIndex"].GetUint64();
|
||||
fileindex = doc["fileIndex"].GetUint64();
|
||||
//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;
|
||||
|
||||
strcpy(fname,filename.c_str());
|
||||
|
||||
// cprintf(BLUE, "Header Info:\n"
|
||||
// "size: %u\n"
|
||||
// "multisize: %u\n"
|
||||
// "dynamicRange: %u\n"
|
||||
// "nPixelsX: %u\n"
|
||||
// "nPixelsY: %u\n"
|
||||
// "currentFileName: %s\n"
|
||||
// "currentAcquisitionIndex: %lu\n"
|
||||
// "currentFrameIndex: %lu\n"
|
||||
// "currentFileIndex: %lu\n"
|
||||
// "currentSubFrameIndex: %u\n"
|
||||
// "xCoordX: %u\n"
|
||||
// "yCoordY: %u\n"
|
||||
// "zCoordZ: %u\n"
|
||||
// "flippedDataX: %u\n"
|
||||
// "packetNumber: %u\n"
|
||||
// "bunchId: %u\n"
|
||||
// "timestamp: %u\n"
|
||||
// "modId: %u\n"
|
||||
// "debug: %u\n"
|
||||
// "roundRNumber: %u\n"
|
||||
// "detType: %u\n"
|
||||
// "version: %u\n",
|
||||
// size, multisize, dynamicRange, nPixelsX, nPixelsY,
|
||||
// filename.c_str(), acqIndex,
|
||||
// frameIndex, fileindex, subFrameIndex,
|
||||
// xCoord, yCoord,zCoord,
|
||||
// flippedDataX, packetNumber, bunchId, timestamp, modId, debug, roundRNumber, detType, version);
|
||||
|
||||
/* Analog detector commands */
|
||||
isPedestal=0;
|
||||
isFlat=0;
|
||||
fMode=eFrame;
|
||||
frameMode_s="frame";
|
||||
cprintf(MAGENTA, "Frame mode: ");
|
||||
if (doc.HasMember("frameMode")) {
|
||||
if (doc["frameMode"].IsString()) {
|
||||
frameMode_s=doc["frameMode"].GetString();
|
||||
if (frameMode_s == "pedestal"){
|
||||
fMode=ePedestal;
|
||||
isPedestal=1;
|
||||
} else if (frameMode_s == "newPedestal"){
|
||||
mt->newDataSet(); //resets pedestal
|
||||
// cprintf(MAGENTA, "Resetting pedestal\n");
|
||||
fMode=ePedestal;
|
||||
isPedestal=1;
|
||||
}
|
||||
#ifdef INTERP
|
||||
else if (frameMode_s == "flatfield") {
|
||||
fMode=eFlat;
|
||||
isFlat=1;
|
||||
} else if (frameMode_s == "newFlatfield") {
|
||||
mt->resetFlatField();
|
||||
isFlat=1;
|
||||
cprintf(MAGENTA, "Resetting flatfield\n");
|
||||
fMode=eFlat;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
fMode=eFrame;
|
||||
isPedestal=0;
|
||||
isFlat=0;
|
||||
fMode=eFrame;
|
||||
frameMode_s="frame";
|
||||
}
|
||||
}
|
||||
}
|
||||
cprintf(MAGENTA, "%s\n" , frameMode_s.c_str());
|
||||
mt->setFrameMode(fMode);
|
||||
|
||||
// threshold=0;
|
||||
cprintf(MAGENTA, "Threshold: ");
|
||||
if (doc.HasMember("threshold")) {
|
||||
if (doc["threshold"].IsInt()) {
|
||||
threshold=doc["threshold"].GetInt();
|
||||
mt->setThreshold(threshold);
|
||||
}
|
||||
}
|
||||
cprintf(MAGENTA, "%d\n", threshold);
|
||||
|
||||
xmin=0;
|
||||
xmax=npx;
|
||||
ymin=0;
|
||||
ymax=npy;
|
||||
cprintf(MAGENTA, "ROI: ");
|
||||
if (doc.HasMember("roi")) {
|
||||
if (doc["roi"].IsArray()) {
|
||||
if (doc["roi"].Size() > 0 )
|
||||
if (doc["roi"][0].IsInt())
|
||||
xmin=doc["roi"][0].GetInt();
|
||||
|
||||
if (doc["roi"].Size() > 1 )
|
||||
if (doc["roi"][1].IsInt())
|
||||
xmax=doc["roi"][1].GetInt();
|
||||
|
||||
if (doc["roi"].Size() > 2 )
|
||||
if (doc["roi"][2].IsInt())
|
||||
ymin=doc["roi"][2].GetInt();
|
||||
|
||||
if (doc["roi"].Size() > 3 )
|
||||
if (doc["roi"][3].IsInt())
|
||||
ymax=doc["roi"][3].GetInt();
|
||||
}
|
||||
}
|
||||
|
||||
cprintf(MAGENTA, "%d %d %d %d\n", xmin, xmax, ymin, ymax);
|
||||
mt->setROI(xmin, xmax, ymin, ymax);
|
||||
|
||||
if (doc.HasMember("dynamicRange")) {
|
||||
dr=doc["dynamicRange"].GetUint();
|
||||
dr=32;
|
||||
}
|
||||
|
||||
dMode=eAnalog;
|
||||
detectorMode_s="analog";
|
||||
cprintf(MAGENTA, "Detector mode: ");
|
||||
if (doc.HasMember("detectorMode")) {
|
||||
if (doc["detectorMode"].IsString()) {
|
||||
detectorMode_s=doc["detectorMode"].GetString();
|
||||
#ifdef INTERP
|
||||
if (detectorMode_s == "interpolating"){
|
||||
dMode=eInterpolating;
|
||||
mt->setInterpolation(interp);
|
||||
} else
|
||||
#endif
|
||||
if (detectorMode_s == "counting"){
|
||||
dMode=ePhotonCounting;
|
||||
#ifdef INTERP
|
||||
mt->setInterpolation(NULL);
|
||||
#endif
|
||||
} else {
|
||||
dMode=eAnalog;
|
||||
#ifdef INTERP
|
||||
mt->setInterpolation(NULL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
mt->setDetectorMode(dMode);
|
||||
cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
|
||||
|
||||
// cout << "done " << endl;
|
||||
|
||||
// /* Single Photon Detector commands */
|
||||
// nSigma=5;
|
||||
// if (doc.HasMember("nSigma")) {
|
||||
// if (doc["nSigma"].IsInt())
|
||||
// nSigma=doc["nSigma"].GetInt();
|
||||
// mt->setNSigma(nSigma);
|
||||
// }
|
||||
|
||||
// emin=-1;
|
||||
// emax=-1;
|
||||
// if (doc.HasMember("energyRange")) {
|
||||
// if (doc["energyRange"].IsArray()) {
|
||||
// if (doc["energyRange"].Size() > 0 )
|
||||
// if (doc["energyRange"][0].IsInt())
|
||||
// emin=doc["energyRange"][0].GetInt();
|
||||
|
||||
// if (doc["energyRange"].Size() > 1 )
|
||||
// if (doc["energyRange"][1].IsInt())
|
||||
// emax=doc["energyRange"][1].GetUint();
|
||||
// }
|
||||
// }
|
||||
// if (doc.HasMember("eMin")) {
|
||||
// if (doc["eMin"][1].IsInt())
|
||||
// emin=doc["eMin"].GetInt();
|
||||
// }
|
||||
// if (doc.HasMember("eMax")) {
|
||||
// if (doc["eMax"][1].IsInt())
|
||||
// emin=doc["eMax"].GetInt();
|
||||
// }
|
||||
// mt->setEnergyRange(emin,emax);
|
||||
|
||||
// /* interpolating detector commands */
|
||||
|
||||
// if (doc.HasMember("nSubPixels")) {
|
||||
// if (doc["nSubPixels"].IsUint())
|
||||
// nSubPixels=doc["nSubPixels"].GetUint();
|
||||
// mt->setNSubPixels(nSubPixels);
|
||||
// }
|
||||
|
||||
|
||||
newFrame=0;
|
||||
/* zmqsocket->CloseHeaderMessage();*/
|
||||
}
|
||||
#endif
|
||||
|
||||
// cout << "file" << endl;
|
||||
// cout << "data " << endl;
|
||||
if (of==NULL) {
|
||||
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
|
||||
of=fopen(ofname,"w");
|
||||
if (of) {
|
||||
mt->setFilePointer(of);
|
||||
}else {
|
||||
cout << "Could not open "<< ofname << " for writing " << endl;
|
||||
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);
|
||||
} else {
|
||||
cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber);
|
||||
length = zmqsocket->ReceiveData(0, dummybuff, size);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
iframe++;
|
||||
|
||||
} // exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
if (send)
|
||||
delete zmqsocket2;
|
||||
|
||||
|
||||
cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,57 +0,0 @@
|
||||
#include <TPaveText.h>
|
||||
#include <TLegend.h>
|
||||
#include <TF1.h>
|
||||
#include <TGraphErrors.h>
|
||||
#include <TH2F.h>
|
||||
#include <TASImage.h>
|
||||
#include <TImage.h>
|
||||
#include <TFile.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include "tiffIO.h"
|
||||
|
||||
#include<iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
|
||||
if (argc<3) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile " << " outfile " << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32 nx, ny;
|
||||
|
||||
float *data=ReadFromTiff(argv[1],nx, ny);
|
||||
|
||||
TH2F *h2=NULL;
|
||||
if (data) {
|
||||
TFile *fout=new TFile(argv[2],"RECREATE");
|
||||
if (fout) {
|
||||
h2=new TH2F("h2",argv[1],nx,0,nx,ny,0, ny);
|
||||
for (int ix=0; ix<nx ; ix++) {
|
||||
for (int iy=0; iy<ny ; iy++) {
|
||||
|
||||
h2->SetBinContent(ix+1, iy+1, data[ix+iy*nx]);
|
||||
}
|
||||
}
|
||||
h2->Write();
|
||||
fout->Close();
|
||||
}
|
||||
delete [] data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user