directory restuctured

This commit is contained in:
2017-12-06 09:10:13 +01:00
parent 7f256c868b
commit 1bf7b4a6a1
78 changed files with 4212 additions and 8344 deletions

View File

@ -0,0 +1,33 @@
#CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
#ZMQLIB=../slsReceiverSoftware/include
#LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
INCDIR=-IslsDetectorCalibration -I. -IetaVEL -I../slsReceiverSoftware/include
#-I$(CBFLIBDIR)/include/
#LIBHDF5=
LDFLAG= -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
moenchClusterFinder: $(MAIN) $(INCS) clean
g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
moenchMakeEta: moench03MakeEta.cpp $(INCS) clean
g++ -o moenchMakeEta moench03MakeEta.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
moenchInterpolation: moench03Interpolation.cpp $(INCS) clean
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
moenchNoInterpolation: moench03NoInterpolation.cpp $(INCS) clean
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
clean:
rm -f moenchClusterFinder moenchMakeEta

View File

@ -0,0 +1,20 @@
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

View File

@ -0,0 +1,23 @@
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

View File

@ -0,0 +1,22 @@
CBFLIBDIR=/afs/psi.ch/project/sls_det_software/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=moench03ZmqOnTheFly.cpp
#DESTDIR?=../bin
all: moench03ZmqOnTheFly
moench03ZmqOnTheFly: $(MAIN) $(INCS) clean
g++ -o moench03ZmqOnTheFly $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
clean:
rm -f moench03ZmqOnTheFlyEta

View File

@ -0,0 +1,30 @@
CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
#ZMQLIB=../slsReceiverSoftware/include
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
INCDIR=-IslsDetectorCalibration -I. -IetaVEL -I../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/
#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) tiffIO.cpp -DSAVE_ALL
moenchMakeEtaPhoenix: moench03MakeEtaPhoenix.cpp $(INCS) clean
g++ -o moenchMakeEta moench03MakeEta.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
moenchInterpolationPhoenix: moench03InterpolationPhoenix.cpp $(INCS) clean
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
clean:
rm -f moenchClusterFinderPhoenix moenchMakeEtaPhoenix moenchInterpolationPhoenix

View File

@ -0,0 +1,25 @@
#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=-IslsDetectorCalibration -I. -IetaVEL -I../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I$(ROOTSYS)/include
#LIBHDF5=
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff -L$(ZMQLIB) -lzmq
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) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp
clean:
rm -f tiff_to_th2f

View File

@ -0,0 +1,255 @@
//#include "ansi.h"
#include <iostream>
//#include "moench03T1ZmqData.h"
#include "moench03T1ReceiverData.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<7) {
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax pedfname" << endl;
}
int p=10000;
int fifosize=1000;
int nthreads=20;
int nsubpix=25;
int etabins=nsubpix*10;
double etamin=-1, etamax=2;
int csize=3;
int nx=400, ny=400;
int save=1;
int nsigma=5;
int nped=1000;
int ndark=100;
int ok;
int iprog=0;
moench03T1ReceiverData *decoder=new moench03T1ReceiverData();
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
// char tit[10000];
// filter->readPedestals("/scratch/ped_100.tiff");
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
// cout << "filter "<< endl;
int size = 327680;////atoi(argv[3]);
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;
cout << "pedestal file is " << fformat << endl;
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
filter->setFrameMode(eFrame);
// mt->setFrameMode(ePedestal);
cout << pedfname<< endl;
filebin.open((const char *)(pedfname), ios::in | ios::binary);
//filebin.open((const char *)(fname), ios::in | ios::binary);
// //open file
if (filebin.is_open()){
// //while read frame
cout << "pedestal file " << endl;
while (decoder->readNextFrame(filebin, ff, np,data)) {
// cout << ff << " " << np << endl;
// //push
// mt->pushData(buff);
// // //pop
//mt->nextThread();
// // // cout << " " << (void*)buff;
//mt->popFree(buff);
filter->processData(data);
}
filebin.close();
// //close file
// //join threads
// while (mt->isBusy()) {;}//wait until all data are processed from the queues
// cout << outfname << endl;
// filter->writePedestals(outfname);
// sprintf(outfname,"%s/%s_pedimg.tiff",outdir,fn);
// cout << outfname << endl;
// filter->writeImage(outfname);
// //mt->clearImage();
} else
cout << "Could not open "<< pedfname << " for reading " << endl;
// 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;
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
// mt->prepareInterpolation(ok);
mt->setFrameMode(eFrame);
mt->StartThreads();
mt->popFree(buff);
int ifr=0;
// //loop on files
// mt->setFrameMode(eFrame);
//mt->setFrameMode(eFlat);
for (int irun=runmin; irun<runmin+5; irun++) {
sprintf(fn,fformat,irun);
sprintf(fname,"%s/%s.raw",indir,fn);
filebin.open((const char *)(fname), ios::in | ios::binary);
// //open file
if (filebin.is_open()){
// //while read frame
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);
}
// cout << "--" << endl;
filebin.close();
}
}
while (mt->isBusy()) {;}//wait until all data are processed from the queues
mt->clearImage();
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
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);
}
// 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;
}

View File

@ -0,0 +1,192 @@
//#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 p=10000;
int fifosize=1000;
int nthreads=20;
int nsubpix=25;
int etabins=nsubpix*10;
double etamin=-1, etamax=2;
int csize=3;
int nx=400, ny=400;
int save=1;
int nsigma=5;
int nped=1000;
int ndark=100;
int ok;
int iprog=0;
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, 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();
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;
}
// 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;
}

View File

@ -0,0 +1,171 @@
#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
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);
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;
}

View File

@ -0,0 +1,62 @@
#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
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;
int quad;
double sum, totquad;
double sDum[2][2];
char fname[10000];
double etax, etay;
int runmin, runmax;
single_photon_hit cl(3,3);
if (argc<5) {
cout << "Wrong usage! Should be: "<< argv[0] << " infile " << " outfile runmin runmax" << endl;
return 1;
}
etaInterpolationPosXY *interp=new etaInterpolationPosXY(NR, NC, nsubpix, etabins, etamin, etamax);
runmin=atoi(argv[3]);
runmax=atoi(argv[4]);
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)) {
interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
if (sum>200 && sum<580 && cl.y<350)
interp->addToFlatField(cl.get_cluster(),etax, etay);
}
fclose(f);
interp->writeFlatField(argv[2]);
}
else cout << "could not open file " << fname << endl;
}
interp->writeFlatField(argv[2]);
return 0;
}

View File

@ -0,0 +1,171 @@
#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;
}

View File

@ -0,0 +1,160 @@
#include <vector>
#include <string>
#include <sstream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
//#include <deque>
//#include <list>
//#include <queue>
#include <fstream>
#include "moench03Ctb10GbT1Data.h"
#include "interpolatingDetector.h"
#include "etaInterpolationPosXY.h"
#include "linearInterpolation.h"
#include "noInterpolation.h"
#include "multiThreadedDetector.h"
#include <ctime>
#define NC 400
#define NR 400
#include "tiffIO.h"
void *moenchProcessFrame() {
char fname[10000];
strcpy(fname,"/mnt/moench_data/m03-15_mufocustube/plant_40kV_10uA/m03-15_100V_g4hg_300us_dtf_0.raw");
int nthreads=3;
int nph, nph1;
single_photon_hit clusters[NR*NC];
// cout << "hits "<< endl;
int etabins=550;
double etamin=-1, etamax=2;
int nsubpix=4;
float *etah=new float[etabins*etabins];
// cout << "etah "<< endl;
cout << "image size "<< nsubpix*nsubpix*NC*NR << endl;
float *image=new float[nsubpix*nsubpix*NC*NR];
int *heta, *himage;
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
// cout << "decoder "<< endl;
etaInterpolationPosXY *interp=new etaInterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
// cout << "interp "<< endl;
//linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
interpolatingDetector *filter=new interpolatingDetector(decoder,interp, 5, 1, 0, 1000, 10);
filter->readPedestals("/scratch/ped_100.tiff");
cout << "filter "<< endl;
char *buff;
int nf=0;
int ok=0;
ifstream filebin;
std::time_t end_time;
int iFrame=-1;
int np=-1;
filter->newDataSet();
multiThreadedDetector *mt=new multiThreadedDetector(filter,nthreads,100);
nph=0;
nph1=0;
//int np;
int iph;
cout << "file name " << fname << endl;
filebin.open((const char *)(fname), ios::in | ios::binary);
if (filebin.is_open())
cout << "Opened file " << fname<< endl;
else
cout << "Could not open file " << fname<< endl;
mt->setFrameMode(eFrame);
mt->prepareInterpolation(ok);
mt->StartThreads();
mt->popFree(buff);
while ((decoder->readNextFrame(filebin, iFrame, np, buff)) && nf<1.5E4) {
if (nf<9E3)
;
else {
// if (nf>1.1E4 && ok==0) {
// mt->prepareInterpolation(ok);
// mt->setFrameMode(eFrame);
// //ok=1;
// }
mt->pushData(buff);
mt->nextThread();
// cout << " " << (void*)buff;
mt->popFree(buff);
// if (ok==0) {
// cout << "**************************************************************************"<< endl;
// heta=interp->getFlatField();
// // for (int ii=0; ii<etabins*etabins; ii++) {
// // etah[ii]=(float)heta[ii];
// // }
// std::time(&end_time);
// cout << std::ctime(&end_time) << " " << nf << endl;
// // WriteToTiff(etah, "/scratch/eta.tiff", etabins, etabins);
// interp->prepareInterpolation(ok);
// cout << "**************************************************************************"<< endl;
// std::time(&end_time);
// cout << std::ctime(&end_time) << " " << nf << endl;
// }
// filter->processData(buff,eFrame);
// }
// nph+=nph1;
}
if (nf%1000==0) {
std::time(&end_time);
cout << std::ctime(&end_time) << " " << nf << endl;
}
nf++;
//delete [] buff;
iFrame=-1;
}
if (filebin.is_open())
filebin.close();
else
cout << "could not open file " << fname << endl;
mt->StopThreads();
char tit[10000];
sprintf(tit,"/scratch/int_image_mt%d.tiff",nthreads);
mt->writeInterpolatedImage(tit);
// delete [] etah;
// delete interp;
//delete decoder;
//cout << "Read " << nf << " frames" << endl;
return NULL;
}
int main(int argc, char *argv[]){
moenchProcessFrame();
}

View File

@ -0,0 +1,272 @@
#include "ZmqSocket.h"
#include "ansi.h"
#include <iostream>
#include "moench03T1ZmqData.h"
// #include "interpolatingDetector.h"
//#include "etaInterpolationPosXY.h"
// #include "linearInterpolation.h"
// #include "noInterpolation.h"
#include "multiThreadedAnalogDetector.h"
#include "singlePhotonDetector.h"
#include "interpolatingDetector.h"
using namespace std;
#define NC 400
#define NR 400
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
int main(int argc, char *argv[]) {
/**
* trial.o [socket ip] [starting port number] [outfname]
*
*/
int p=10000;
int fifosize=1000;
int nthreads=20;
int nsubpix=25;
int etabins=nsubpix*10;
double etamin=-1, etamax=2;
int csize=3;
int nx=400, ny=400;
int save=1;
int nsigma=5;
int nped=1000;
int ndark=100;
int ok;
int iprog=0;
char outfname[10000];
moench03T1ZmqData *decoder=new moench03T1ZmqData();
// cout << "decoder "<< endl;
//etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
// linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
//interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 100);
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
char tit[10000];
// filter->readPedestals("/scratch/ped_100.tiff");
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
// cout << "filter "<< endl;
int size = 327680;////atoi(argv[3]);
char* buff;
int* image;
//int* image =new int[327680/sizeof(int)];
filter->newDataSet();
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
//mt->setFrameMode(eFrame);
mt->setFrameMode(eFlat);
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
// mt->prepareInterpolation(ok);
mt->StartThreads();
mt->popFree(buff);
// help
if (argc < 2 || (argc > 2)) {
cprintf(RED, "Help: %s [receive socket ip]\n", argv[0]);
return EXIT_FAILURE;
}
// receive parameters
bool send = false;
char* socketip = argv[1];
uint32_t portnum = 30001;//atoi(argv[2]);
// char fn[10000];
// strcpy(fn, argv[2]);
// send parameters if any
// char* socketip2 = 0;
// uint32_t portnum2 = 0;
// if (argc > 4) {
// send = true;
// socketip2 = argv[4];
// portnum2 = atoi(argv[5]);
// }
cout << "\nrx socket ip : " << socketip ; // <<
// "\nrx port num : " << portnum <<
// "\nsize : " << size;
// "\nfname : " << fn ;
// if (send) {
// cout << "\nsd socket ip : " << socketip2 <<
// "\nsd port num : " << portnum2;
// }
cout << endl;
// receive socket
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
if (zmqsocket->IsError()) {
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
delete zmqsocket;
return EXIT_FAILURE;
}
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
// send socket
// ZmqSocket* zmqsocket2 = 0;
// if (send) {
// zmqsocket2 = new ZmqSocket(portnum2, socketip2);
// if (zmqsocket2->IsError()) {
// bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
// delete zmqsocket2;
// delete zmqsocket;
// return EXIT_FAILURE;
// }
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
// }
// cout << "size " << 327680/sizeof(int) << endl;
// header variables
uint64_t acqIndex = -1;
uint64_t frameIndex = -1;
uint32_t subframeIndex = -1;
string filename = "";
int nnx, nny, nns;
int imsize=filter->getImageSize(nnx,nny,nns);
//int imsize=nx*ny;
int i_image=0;
cout << "Image size is "<< nnx << " " << nny << " " << nns << " " << imsize << endl;
int iframe=0;
int ff=0;
// infinite loop
while(1) {
// cprintf(GREEN, "Got ?\n");
// get header, (if dummy, fail is on parse error or end of acquisition)
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
cprintf(RED, "Acquisition finished\n");
cout << "Received " << ff << " frames for a total of "<< iframe << endl;
while (mt->isBusy()) {;}//wait until all data are processed from the queues
// stream dummy to socket2 to signal end of acquisition
// if (send) {
// zmqsocket2->SendData((char*)(mt->getImage()),imsize*sizeof(int));
// cprintf(BLUE, "Sent Interpolated image\n");
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
// // cprintf(RED, "Sent Dummy\n");
// }
// if (save) {
sprintf(tit,"%s_%05d.tiff",filename.c_str(), ff);
// cout << tit << endl;
mt->writeImage(tit);
mt->clearImage();
// }
// sprintf(tit,"%s_%05d_eta_i.tiff",filename.c_str(), ff);
// interp->writeFlatField(tit);
// sprintf(tit,"%s_%05d_eta.tiff",filename.c_str(), ff);
// cout << tit << endl;
// mt->writeFlatField(tit);
i_image++;
ff=0;
// dont get data
continue; //continue to not get out
}
if (ff==0)
cprintf(GREEN, "Start acquisition \n");
// cout << filename << endl;
// cprintf(GREEN, "Got Header \n");
// get data
// cprintf(GREEN, "Got Header\n");
//image=(int*)buff;
//cout << buff << endl;
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
// int length = zmqsocket->ReceiveData(0, (int*)image, size);
// cprintf(GREEN, "Got Data\n");
//processing with image
//...
mt->pushData(buff);
mt->nextThread();
// cout << " " << (void*)buff;
mt->popFree(buff);
iframe++;
ff++;
// if (iframe%p==0) {
// while (mt->isBusy()) {;}//wait until all data are processed from the queues
// sprintf(tit,"tmp.tiff",filename.c_str(), i_image);
// mt->writeImage(tit);
// // mt->clearImage();
// // }
// //interp->writeFlatField(tit);
// // i_image++;
// // sprintf(tit,"%s_tmp.tiff",fn);
// // mt->writeImage(tit);
// // //mt->clearImage();
// // cout <<"*"<< iprog++ << endl;
// }
// //stream data from socket 2
// if (send) {
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
// cprintf(GREEN, "Sent Header\n");
// zmqsocket2->SendData((char*)image,length);
// cprintf(GREEN, "Sent Data\n");
// }
}// exiting infinite loop
delete zmqsocket;
// if (send)
// delete zmqsocket2;
// cout<<"Goodbye"<< endl;
return 0;
}

View File

@ -0,0 +1,306 @@
#include "ZmqSocket.h"
#include "ansi.h"
#include <iostream>
#include "moench03T1ZmqData.h"
// #include "interpolatingDetector.h"
#include "etaInterpolationPosXY.h"
// #include "linearInterpolation.h"
// #include "noInterpolation.h"
#include "multiThreadedAnalogDetector.h"
#include "singlePhotonDetector.h"
#include "interpolatingDetector.h"
using namespace std;
#define NC 400
#define NR 400
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
int main(int argc, char *argv[]) {
/**
* trial.o [socket ip] [starting port number] [outfname]
*
*/
int p=1000; //1.5s with 15ms period
int fifosize=1000;
int nthreads=8;
int nsubpix=2;
int etabins=nsubpix*10;
double etamin=-1, etamax=2;
int csize=3;
int nx=400, ny=400;
int save=1;
int nsigma=5;
int nped=1000;
int ndark=100;
int ok;
int iprog=0;
char outfname[10000];
if (nsubpix>2) p=5000;
moench03T1ZmqData *decoder=new moench03T1ZmqData();
// cout << "decoder "<< endl;
etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
// linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 100);
// singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
char tit[10000];
// filter->readPedestals("/scratch/ped_100.tiff");
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
// cout << "filter "<< endl;
int size = 327680;////atoi(argv[3]);
char* buff;
int* image;
//int* image =new int[327680/sizeof(int)];
filter->newDataSet();
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
//
if (nsubpix>2)
mt->setFrameMode(eFlat);
else
mt->setFrameMode(eFrame);
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
// mt->prepareInterpolation(ok);
mt->StartThreads();
mt->popFree(buff);
// help
if (argc < 2 || (argc > 2)) {
cprintf(RED, "Help: %s [receive socket ip]\n", argv[0]);
return EXIT_FAILURE;
}
// receive parameters
bool send = false;
char* socketip = argv[1];
uint32_t portnum = 30001;//atoi(argv[2]);
// char fn[10000];
// strcpy(fn, argv[2]);
// send parameters if any
// char* socketip2 = 0;
// uint32_t portnum2 = 0;
// if (argc > 4) {
// send = true;
// socketip2 = argv[4];
// portnum2 = atoi(argv[5]);
// }
cout << "\nrx socket ip : " << socketip ; // <<
// "\nrx port num : " << portnum <<
// "\nsize : " << size;
// "\nfname : " << fn ;
// if (send) {
// cout << "\nsd socket ip : " << socketip2 <<
// "\nsd port num : " << portnum2;
// }
cout << endl;
// receive socket
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
if (zmqsocket->IsError()) {
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
delete zmqsocket;
return EXIT_FAILURE;
}
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
// send socket
// ZmqSocket* zmqsocket2 = 0;
// if (send) {
// zmqsocket2 = new ZmqSocket(portnum2, socketip2);
// if (zmqsocket2->IsError()) {
// bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
// delete zmqsocket2;
// delete zmqsocket;
// return EXIT_FAILURE;
// }
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
// }
// cout << "size " << 327680/sizeof(int) << endl;
// header variables
uint64_t acqIndex = -1;
uint64_t frameIndex = -1;
uint32_t subframeIndex = -1;
string filename = "";
int nnx, nny, nns;
int imsize=filter->getImageSize(nnx,nny,nns);
//int imsize=nx*ny;
int i_image=0;
cout << "Image size is "<< nnx << " " << nny << " " << nns << " " << imsize << endl;
int iframe=0;
int ff=0;
// infinite loop
while(1) {
// cprintf(GREEN, "Got ?\n");
// get header, (if dummy, fail is on parse error or end of acquisition)
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
cprintf(RED, "Acquisition finished\n");
cout << "Received " << ff << " frames for a total of "<< iframe << endl;
while (mt->isBusy()) {;}//wait until all data are processed from the queues
// stream dummy to socket2 to signal end of acquisition
// if (send) {
// zmqsocket2->SendData((char*)(mt->getImage()),imsize*sizeof(int));
// cprintf(BLUE, "Sent Interpolated image\n");
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
// // cprintf(RED, "Sent Dummy\n");
// }
// if (save) {
// if (iframe>p) {
sprintf(tit,"%s_%05d_%05d.tiff",filename.c_str(), ff, i_image);
cout << tit << endl;
mt->writeImage(tit);
sprintf(tit,"/home/l_msdetect/slsbl/x07mb/x07mbop/Data1/2017/11/06/tmp.tiff");
cout <<"*"<< iframe<< endl;
mt->writeImage(tit);
mt->clearImage();
//}
// }
//sprintf(tit,"%s_%05d_eta_i.tiff",filename.c_str(), ff);
//interp->writeFlatField(tit);
// sprintf(tit,"%s_%05d_eta_%d.tiff",filename.c_str(), ff, acqIndex);
// // cout << tit << endl;
// mt->writeFlatField(tit);
i_image++;
ff=0;
//filter->newDataSet();
// dont get data
continue; //continue to not get out
}
if (ff==0)
cprintf(GREEN, "Start acquisition %d\n",acqIndex);
// cout << filename << endl;
// cprintf(GREEN, "Got Header \n");
// get data
// cprintf(GREEN, "Got Header\n");
//image=(int*)buff;
//cout << buff << endl;
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
// int length = zmqsocket->ReceiveData(0, (int*)image, size);
// cprintf(GREEN, "Got Data\n");
//processing with image
//...
mt->pushData(buff);
mt->nextThread();
// cout << " " << (void*)buff;
mt->popFree(buff);
iframe++;
if (nsubpix>2) {
if (iframe==p) {
mt->setFrameMode(eFrame);
mt->prepareInterpolation(ok);
sprintf(tit,"%s_%05d_eta.tiff",filename.c_str(), ff);
cout << tit << endl;
mt->writeFlatField(tit);
}
} //else {
// cout << iframe << " " << p << endl;
if (iframe%p==0) {
while (mt->isBusy()) {;}//wait until all data are processed from the queues
sprintf(tit,"/home/l_msdetect/slsbl/x07mb/x07mbop/Data1/2017/11/06/tmp.tiff");
cout <<"*"<< iframe<< endl;
mt->writeImage(tit);
// mt->clearImage();
}
//}
ff++;
// if (iframe%p==0) {
// while (mt->isBusy()) {;}//wait until all data are processed from the queues
// sprintf(tit,"tmp.tiff",filename.c_str(), i_image);
// mt->writeImage(tit);
// // mt->clearImage();
// // }
// //interp->writeFlatField(tit);
// // i_image++;
// // sprintf(tit,"%s_tmp.tiff",fn);
// // mt->writeImage(tit);
// // //mt->clearImage();
// // cout <<"*"<< iprog++ << endl;
// }
// //stream data from socket 2
// if (send) {
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
// cprintf(GREEN, "Sent Header\n");
// zmqsocket2->SendData((char*)image,length);
// cprintf(GREEN, "Sent Data\n");
// }
}// exiting infinite loop
delete zmqsocket;
// if (send)
// delete zmqsocket2;
// cout<<"Goodbye"<< endl;
return 0;
}

View File

@ -0,0 +1,251 @@
#include "ZmqSocket.h"
#include "ansi.h"
#include <iostream>
#include "moench03T1ZmqData.h"
// #include "interpolatingDetector.h"
#include "etaInterpolationPosXY.h"
// #include "linearInterpolation.h"
// #include "noInterpolation.h"
#include "multiThreadedAnalogDetector.h"
//#include "singlePhotonDetector.h"
#include "interpolatingDetector.h"
using namespace std;
#define NC 400
#define NR 400
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
int main(int argc, char *argv[]) {
/**
* trial.o [socket ip] [starting port number] [outfname]
*
*/
int p=1000;
int fifosize=1000;
int nthreads=6;
int nsubpix=25;
int etabins=nsubpix*10;
double etamin=-1, etamax=2;
int csize=3;
int nx=400, ny=400;
int save=1;
int nsigma=5;
int nped=1000;
int ndark=100;
int ok;
int iprog=0;
char outfname[10000];
moench03T1ZmqData *decoder=new moench03T1ZmqData();
// cout << "decoder "<< endl;
etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
// linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
// interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 100);
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
char tit[10000];
// filter->readPedestals("/scratch/ped_100.tiff");
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
// cout << "filter "<< endl;
int size = 327680;////atoi(argv[3]);
char* buff;
int* image;
//int* image =new int[327680/sizeof(int)];
filter->newDataSet();
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
mt->setFrameMode(eFrame);
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
// mt->prepareInterpolation(ok);
mt->StartThreads();
mt->popFree(buff);
// help
if (argc < 3 || (argc > 3)) {
cprintf(RED, "Help: %s [receive socket ip] [fname]\n", argv[0]);
return EXIT_FAILURE;
}
// receive parameters
bool send = false;
char* socketip = argv[1];
uint32_t portnum = 30001;//atoi(argv[2]);
char fn[10000];
strcpy(fn, argv[2]);
// send parameters if any
// char* socketip2 = 0;
// uint32_t portnum2 = 0;
// if (argc > 4) {
// send = true;
// socketip2 = argv[4];
// portnum2 = atoi(argv[5]);
// }
cout << "\nrx socket ip : " << socketip <<
// "\nrx port num : " << portnum <<
// "\nsize : " << size;
"\nfname : " << fn ;
// if (send) {
// cout << "\nsd socket ip : " << socketip2 <<
// "\nsd port num : " << portnum2;
// }
cout << endl;
// receive socket
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
if (zmqsocket->IsError()) {
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
delete zmqsocket;
return EXIT_FAILURE;
}
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
// send socket
// ZmqSocket* zmqsocket2 = 0;
// if (send) {
// zmqsocket2 = new ZmqSocket(portnum2, socketip2);
// if (zmqsocket2->IsError()) {
// bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
// delete zmqsocket2;
// delete zmqsocket;
// return EXIT_FAILURE;
// }
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
// }
cout << "size " << 327680/sizeof(int) << endl;
// header variables
uint64_t acqIndex = -1;
uint64_t frameIndex = -1;
uint32_t subframeIndex = -1;
string filename = "";
int nnx, nny, nns;
int imsize=filter->getImageSize(nnx,nny,nns);
//int imsize=nx*ny;
int i_image=0;
cout << "Image size is "<< nnx << " " << nny << " " << nns << " " << imsize << endl;
int iframe=0;
// infinite loop
while(1) {
// cprintf(GREEN, "Got ?\n");
// get header, (if dummy, fail is on parse error or end of acquisition)
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
cprintf(RED, "Acquisition finished\n");
cout << "Recieved " << iframe << " frames " << endl;
while (mt->isBusy()) {;}//wait until all data are processed from the queues
// stream dummy to socket2 to signal end of acquisition
// if (send) {
// zmqsocket2->SendData((char*)(mt->getImage()),imsize*sizeof(int));
// cprintf(BLUE, "Sent Interpolated image\n");
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
// // cprintf(RED, "Sent Dummy\n");
// }
// if (save) {
sprintf(tit,"%s_%d.tiff",fn, i_image);
mt->writeImage(tit);
mt->clearImage();
// }
//interp->writeFlatField(tit);
i_image++;
// dont get data
continue; //continue to not get out
}
// cprintf(GREEN, "Got Header \n");
// get data
// cprintf(GREEN, "Got Header\n");
//image=(int*)buff;
//cout << buff << endl;
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
// int length = zmqsocket->ReceiveData(0, (int*)image, size);
// cprintf(GREEN, "Got Data\n");
//processing with image
//...
mt->pushData(buff);
mt->nextThread();
// cout << " " << (void*)buff;
mt->popFree(buff);
iframe++;
// if (iframe%p==0) {
// while (mt->isBusy()) {;}//wait until all data are processed from the queues
// sprintf(tit,"%s_tmp.tiff",fn);
// mt->writeImage(tit);
// //mt->clearImage();
// cout <<"*"<< iprog++ << endl;
// }
// //stream data from socket 2
// if (send) {
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
// cprintf(GREEN, "Sent Header\n");
// zmqsocket2->SendData((char*)image,length);
// cprintf(GREEN, "Sent Data\n");
// }
}// exiting infinite loop
delete zmqsocket;
// if (send)
// delete zmqsocket2;
// cout<<"Goodbye"<< endl;
return 0;
}

View File

@ -0,0 +1,219 @@
#include "ZmqSocket.h"
#include "ansi.h"
#include <iostream>
#include "moench03T1ZmqData.h"
#include "interpolatingDetector.h"
#include "etaInterpolationPosXY.h"
#include "linearInterpolation.h"
#include "noInterpolation.h"
#include "multiThreadedDetector.h"
using namespace std;
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
int main(int argc, char *argv[]) {
/**
* trial.o [socket ip] [starting port number] [image size] [send_socket ip] [send port number]
*
*/
int nthreads=3;
int nsubpix=5;
int etabins=550;
double etamin=-1, etamax=2;
int nx=400, ny=400;
int save=1;
int nsigma=5;
int nped=1000;
int ok;
//int* image = new int[(size/sizeof(int))]();
char* buff;
moench03T1ZmqData *decoder=new moench03T1ZmqData();
// cout << "decoder "<< endl;
etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
//linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 10);
filter->readPedestals("/scratch/ped_100.tiff");
interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
cout << "filter "<< endl;
filter->newDataSet();
multiThreadedDetector *mt=new multiThreadedDetector(filter,nthreads,100);
mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
mt->prepareInterpolation(ok);
mt->StartThreads();
mt->popFree(buff);
// help
if (argc < 4 || (argc > 4 && argc != 6)) {
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [image size] [send_socket ip] [send starting port number]\n");
return EXIT_FAILURE;
}
// receive parameters
bool send = false;
char* socketip = argv[1];
uint32_t portnum = atoi(argv[2]);
int size = atoi(argv[3]);
// send parameters if any
char* socketip2 = 0;
uint32_t portnum2 = 0;
if (argc > 4) {
send = true;
socketip2 = argv[4];
portnum2 = atoi(argv[5]);
}
cout << "\nrx socket ip : " << socketip <<
"\nrx port num : " << portnum <<
"\nsize : " << size;
if (send) {
cout << "\nsd socket ip : " << socketip2 <<
"\nsd port num : " << portnum2;
}
cout << endl;
// receive socket
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
if (zmqsocket->IsError()) {
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
delete zmqsocket;
return EXIT_FAILURE;
}
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
// send socket
ZmqSocket* zmqsocket2 = 0;
if (send) {
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
if (zmqsocket2->IsError()) {
bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
delete zmqsocket2;
delete zmqsocket;
return EXIT_FAILURE;
}
printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
}
// header variables
uint64_t acqIndex = -1;
uint64_t frameIndex = -1;
uint32_t subframeIndex = -1;
string filename = "";
int imsize=nx*ny*nsubpix*nsubpix;
int i_image=0;
// infinite loop
while(1) {
// get header, (if dummy, fail is on parse error or end of acquisition)
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
cprintf(RED, "Acquisition finished\n");
while (mt->isBusy()) {;}//wait until all data are processed from the queues
// stream dummy to socket2 to signal end of acquisition
if (send) {
zmqsocket2->SendData((char*)(mt->getInterpolatedImage()),imsize*sizeof(int));
cprintf(BLUE, "Sent Interpolated image\n");
// zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
// cprintf(RED, "Sent Dummy\n");
}
if (save) {
char tit[10000];
sprintf(tit,"/scratch/int_image_%d.tiff",i_image);
mt->writeInterpolatedImage(tit);
mt->clearInterpolatedImage(tit);
}
i_image++;
// dont get data
break; //continue to not get out
}
cprintf(GREEN, "Got Header \n");
// get data
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
cprintf(GREEN, "Got Data\n");
//processing with image
//...
mt->pushData(buff);
mt->nextThread();
// cout << " " << (void*)buff;
mt->popFree(buff);
// //stream data from socket 2
// if (send) {
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
// cprintf(GREEN, "Sent Header\n");
// zmqsocket2->SendData((char*)image,length);
// cprintf(GREEN, "Sent Data\n");
// }
}// exiting infinite loop
delete zmqsocket;
if (send)
delete zmqsocket2;
cout<<"Goodbye"<< endl;
return 0;
}

View File

@ -0,0 +1,248 @@
#include "ZmqSocket.h"
#include "ansi.h"
#include <iostream>
#include "moench03T1ZmqData.h"
// #include "interpolatingDetector.h"
// #include "etaInterpolationPosXY.h"
#include "linearInterpolation.h"
// #include "noInterpolation.h"
#include "multiThreadedAnalogDetector.h"
//#include "singlePhotonDetector.h"
#include "interpolatingDetector.h"
using namespace std;
#define NC 400
#define NR 400
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
int main(int argc, char *argv[]) {
/**
* trial.o [socket ip] [starting port number] [outfname]
*
*/
int p=1000;
int fifosize=1000;
int nthreads=6;
int nsubpix=2;
// int etabins=550;
// double etamin=-1, etamax=2;
int csize=3;
int nx=400, ny=400;
int save=1;
int nsigma=5;
int nped=1000;
int ndark=100;
int ok;
//int* image = new int[(size/sizeof(int))]();
char* buff;
int iprog=0;
char outfname[10000];
moench03T1ZmqData *decoder=new moench03T1ZmqData();
// cout << "decoder "<< endl;
//etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
// linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
// interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 10);
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
char tit[10000];
// filter->readPedestals("/scratch/ped_100.tiff");
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
// cout << "filter "<< endl;
filter->newDataSet();
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
// mt->prepareInterpolation(ok);
mt->StartThreads();
mt->popFree(buff);
// help
if (argc < 4 || (argc > 4 && argc != 6)) {
cprintf(RED, "Help: %s [receive socket ip] [receive starting port number] [fname]\n", argv[0]);
return EXIT_FAILURE;
}
// receive parameters
bool send = false;
char* socketip = argv[1];
uint32_t portnum = atoi(argv[2]);
int size = 327680;////atoi(argv[3]);
char fn[10000];
strcpy(fn, argv[3]);
// send parameters if any
// char* socketip2 = 0;
// uint32_t portnum2 = 0;
// if (argc > 4) {
// send = true;
// socketip2 = argv[4];
// portnum2 = atoi(argv[5]);
// }
cout << "\nrx socket ip : " << socketip <<
"\nrx port num : " << portnum <<
// "\nsize : " << size;
"\nfname : " << fn ;
// if (send) {
// cout << "\nsd socket ip : " << socketip2 <<
// "\nsd port num : " << portnum2;
// }
cout << endl;
// receive socket
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
if (zmqsocket->IsError()) {
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
delete zmqsocket;
return EXIT_FAILURE;
}
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
// send socket
// ZmqSocket* zmqsocket2 = 0;
// if (send) {
// zmqsocket2 = new ZmqSocket(portnum2, socketip2);
// if (zmqsocket2->IsError()) {
// bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
// delete zmqsocket2;
// delete zmqsocket;
// return EXIT_FAILURE;
// }
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
// }
// header variables
uint64_t acqIndex = -1;
uint64_t frameIndex = -1;
uint32_t subframeIndex = -1;
string filename = "";
int nnx, nny, nns;
int imsize=filter->getImageSize(nnx,nny,nns);
//int imsize=nx*ny;
int i_image=0;
int iframe=0;
// infinite loop
while(1) {
// get header, (if dummy, fail is on parse error or end of acquisition)
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
cprintf(RED, "Acquisition finished\n");
cout << "Recieved " << iframe << " frames " << endl;
while (mt->isBusy()) {;}//wait until all data are processed from the queues
cout << "threads done " << endl;
// stream dummy to socket2 to signal end of acquisition
// if (send) {
// zmqsocket2->SendData((char*)(mt->getImage()),imsize*sizeof(int));
// cprintf(BLUE, "Sent Interpolated image\n");
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
// // cprintf(RED, "Sent Dummy\n");
// }
// if (save) {
sprintf(tit,"%s_%d.tiff",fn, i_image);
cout << tit << endl;
mt->writeImage(tit);
cout << "wrote" << endl;
mt->clearImage();
// }
i_image++;
// dont get data
continue; //continue to not get out
}
// cprintf(GREEN, "Got Header \n");
// get data
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
// cprintf(GREEN, "Got Data\n");
//processing with image
//...
mt->pushData(buff);
mt->nextThread();
// cout << " " << (void*)buff;
mt->popFree(buff);
iframe++;
if (iframe%p==0) {
while (mt->isBusy()) {;}//wait until all data are processed from the queues
sprintf(tit,"%s_tmp.tiff",fn);
mt->writeImage(tit);
//mt->clearImage();
cout <<"*"<< iprog++ << endl;
}
// //stream data from socket 2
// if (send) {
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
// cprintf(GREEN, "Sent Header\n");
// zmqsocket2->SendData((char*)image,length);
// cprintf(GREEN, "Sent Data\n");
// }
}// exiting infinite loop
delete zmqsocket;
// if (send)
// delete zmqsocket2;
cout<<"Goodbye"<< endl;
return 0;
}

View File

@ -0,0 +1,209 @@
#include "single_photon_hit.h"
//#include "etaVEL/etaInterpolationPosXY.h"
TH2F *readClusters(char *fname, int nx, int ny, TH2F *h2=NULL) {
FILE *f=fopen(fname,"r");
int iph=0;
int ns=4;
double px, py;
double left, right, top, bottom;
if (f) {
int x1,y1;
if (h2==NULL)
h2=new TH2F("h2",fname,nx, -0.5, nx-0.5, ny, -0.5, ny-0.5);
h2mult=new TH2F("h2mult",fname,nx, -0.5, nx-0.5, ny, -0.5, ny-0.5);
TH2F *hint=new TH2F("hint",fname,nx*ns, -0.5, nx-0.5, ny*ns, -0.5, ny-0.5);
TH2F *hff=new TH2F("hff","hff",ns, -0.5, 0.5, ns, -0.5, +0.5);
TH1F *hsp=new TH1F("hsp",fname,500,0,2000);
TCanvas *c=new TCanvas();
c->SetLogz(kTRUE);
h2->Draw("colz");
TCanvas *c1=new TCanvas();
hsp->Draw();
TCanvas *c2=new TCanvas();
hint->Draw("colz");
c2->SetLogz(kTRUE);
single_photon_hit cl(3,3);
double tot;
int w;
double phw=340, phs=62;
while (cl.read(f)) {
//cl.get_pixel(x1, y1);
//cout << cl.iframe << " " << cl.x << " " << cl.y << endl;
//if (cl.x>80 && cl.x<280 && cl.y>80 && cl.y<300) {
tot=0;
left=0;
right=0;
top=0;
bottom=0;
for (int ix=-1; ix<2; ix++)
for (int iy=-1; iy<2; iy++){
tot+=cl.get_data(ix,iy);
if (ix<0) left+=cl.get_data(ix,iy);
if (ix>0) right+=cl.get_data(ix,iy);
if (iy<0) bottom+=cl.get_data(ix,iy);
if (iy>0) top+=cl.get_data(ix,iy);
}
px=(-left+right)/tot;
py=(-bottom+top)/tot;
//max at 340
if (tot>200) {
w=(tot+3.5*phs)/phw;
} else
w=0;
if (w) {
hsp->Fill(tot);
if (w==1) {
h2->Fill(cl.x,cl.y,w);
hint->Fill(px+cl.x,py+cl.y,w);
if (cl.y<350)
hff->Fill(px,py,w);
}
h2mult->Fill(cl.x,cl.y,w);
//}
iph+=w;
if (iph%100000==0) {
// c->Modified();
// c->Update();
c1->Modified();;
c1->Update();
// c2->Modified();;
// c2->Update();
}
}
// if (iph>0.5E7) break;
}
fclose(f);
hff->Scale(hff->GetNbinsX()*hff->GetNbinsY()/hff->Integral());
TH2F *hint2=(TH2F*)hint->Clone("hint2");
double ff;
for (int ibx=0; ibx<hint->GetNbinsX(); ibx++) {
for (int iby=0; iby<hint->GetNbinsY(); iby++) {
ff=hff->GetBinContent(ibx%ns+1, iby%ns+1);
// cout << ibx << " " << iby << " " << ibx%ns << " " << iby%ns << " " << ff << endl;
if (ff>0)
hint2->SetBinContent(ibx+1, iby+1,hint->GetBinContent(ibx+1,iby+1)/ff);
}
}
return h2;
} else
cout << "could not open file " << fname << endl;
return NULL;
}
// TH2F *getEta(char *fname, int nx, int ny, TH2F *h2=NULL) {
// int ns=10;
// slsInterpolation *inte=new etaInterpolationPosXY(nx,ny,ns,
// FILE *f=fopen(fname,"r");
// int iph=0;
// int ns=4;
// double px, py;
// double left, right, top, bottom;
// if (f) {
// int x1,y1;
// if (h2==NULL)
// h2=new TH2F("h2",fname,nx, -0.5, nx-0.5, ny, -0.5, ny-0.5);
// h2mult=new TH2F("h2mult",fname,nx, -0.5, nx-0.5, ny, -0.5, ny-0.5);
// TH2F *hint=new TH2F("hint",fname,nx*ns, -0.5, nx-0.5, ny*ns, -0.5, ny-0.5);
// // TH2F *hff=new TH2F("hff","hff",ns, -0.5, 0.5, ns, -0.5, +0.5);
// TH1F *hsp=new TH1F("hsp",fname,500,0,2000);
// TCanvas *c=new TCanvas();
// c->SetLogz(kTRUE);
// h2->Draw("colz");
// TCanvas *c1=new TCanvas();
// hsp->Draw();
// TCanvas *c2=new TCanvas();
// hint->Draw("colz");
// c2->SetLogz(kTRUE);
// single_photon_hit cl(3,3);
// double tot;
// int w;
// double phw=340, phs=62;
// while (cl.read(f)) {
// //cl.get_pixel(x1, y1);
// //cout << cl.iframe << " " << cl.x << " " << cl.y << endl;
// //if (cl.x>80 && cl.x<280 && cl.y>80 && cl.y<300) {
// tot=0;
// left=0;
// right=0;
// top=0;
// bottom=0;
// for (int ix=-1; ix<2; ix++)
// for (int iy=-1; iy<2; iy++){
// tot+=cl.get_data(ix,iy);
// if (ix<0) left+=cl.get_data(ix,iy);
// if (ix>0) right+=cl.get_data(ix,iy);
// if (iy<0) bottom+=cl.get_data(ix,iy);
// if (iy>0) top+=cl.get_data(ix,iy);
// }
// px=(-left+right)/tot;
// py=(-bottom+top)/tot;
// //max at 340
// if (tot>200) {
// w=(tot+3.5*phs)/phw;
// } else
// w=0;
// if (w) {
// hsp->Fill(tot);
// if (w==1) {
// h2->Fill(cl.x,cl.y,w);
// hint->Fill(px+cl.x,py+cl.y,w);
// }
// h2mult->Fill(cl.x,cl.y,w);
// // if (cl.y<350)
// // hff->Fill(px,py,w);
// //}
// iph+=w;
// if (iph%100000==0) {
// // c->Modified();
// // c->Update();
// c1->Modified();;
// c1->Update();
// // c2->Modified();;
// // c2->Update();
// }
// }
// // if (iph>0.5E7) break;
// }
// fclose(f);
// // hff->Scale(hff->GetNbinsX()*hff->GetNbinsY()/hff->Integral());
// // TH2F *hint2=(TH2F*)hint->Clone("hint2");
// // double ff;
// // for (int ibx=0; ibx<hint->GetNbinsX(); ibx++) {
// // for (int iby=0; iby<hint->GetNbinsY(); iby++) {
// // ff=hff->GetBinContent(ibx%ns+1, iby%ns+1);
// // // cout << ibx << " " << iby << " " << ibx%ns << " " << iby%ns << " " << ff << endl;
// // if (ff>0)
// // hint2->SetBinContent(ibx+1, iby+1,hint->GetBinContent(ibx+1,iby+1)/ff);
// // }
// // }
// return h2;
// } else
// cout << "could not open file " << fname << endl;
// return NULL;
// }

View File

@ -0,0 +1,57 @@
#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;
}