mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-17 23:37:14 +02:00
added photon counter no thread
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
hostname bchip135+
|
hostname bchip071+
|
||||||
|
|
||||||
patword 0000 0000000000000000
|
patword 0000 0000000000000000
|
||||||
patword 0001 0000000000000000
|
patword 0001 0000000000000000
|
||||||
@ -429,7 +429,7 @@ rx_zmqport 50003
|
|||||||
#rx_zmqip 10.1.2.117
|
#rx_zmqip 10.1.2.117
|
||||||
#0:rx_hostname mpc2608
|
#0:rx_hostname mpc2608
|
||||||
|
|
||||||
zmqip 129.129.202.136
|
zmqip 129.129.202.98
|
||||||
0:rx_udpip 10.1.1.102
|
0:rx_udpip 10.1.1.102
|
||||||
0:detectorip 10.1.1.19
|
0:detectorip 10.1.1.19
|
||||||
rx_zmqip 10.1.1.102
|
rx_zmqip 10.1.1.102
|
||||||
@ -489,10 +489,11 @@ period 0.005
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
r_discardpolicy discardpartial
|
||||||
|
|
||||||
|
|
||||||
frames 100
|
frames 100
|
||||||
period 0.1
|
period 0.1
|
||||||
outdir /mnt/raid0/moench/scratch/
|
outdir /mnt/moench_data/scratch/
|
||||||
enablefwrite 0
|
enablefwrite 0
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ class slsInterpolation
|
|||||||
virtual int *setFlatField(int *h, int nb=-1, double emin=-1, double emax=-1){return NULL;};
|
virtual int *setFlatField(int *h, int nb=-1, double emin=-1, double emax=-1){return NULL;};
|
||||||
virtual void *writeFlatField(const char * imgname){return NULL;};
|
virtual void *writeFlatField(const char * imgname){return NULL;};
|
||||||
virtual void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){return NULL;};
|
virtual void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){return NULL;};
|
||||||
virtual int *getFlatField(int &nb, double &emin, double &emax){nb=0; emin=0; emax=0; return getFlatField();};
|
virtual int *getFlatField(int &nb, int &nby, double &emin, double &emax){nb=0; nby=0; emin=0; emax=0; return getFlatField();};
|
||||||
|
|
||||||
virtual void resetFlatField()=0;
|
virtual void resetFlatField()=0;
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -pthread -lrt -
|
|||||||
MAIN=moench03ClusterFinder.cpp
|
MAIN=moench03ClusterFinder.cpp
|
||||||
|
|
||||||
|
|
||||||
all: moenchClusterFinder moenchMakeEta moenchMakeEta3 moenchInterpolation moenchInterpolation3 moenchNoInterpolation moenchPhotonCounter moenchAnalog
|
all: moenchClusterFinder moenchMakeEta moenchMakeEta3 moenchInterpolation moenchInterpolation3 moenchNoInterpolation moenchPhotonCounter moenchAnalog moenchPhotonCounterNoThread moenchAnalogNoThread
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -49,7 +49,13 @@ moenchPhotonCounterHighZ: moenchPhotonCounter.cpp $(INCS) clean
|
|||||||
moenchAnalogHighZ: moenchPhotonCounter.cpp $(INCS) clean
|
moenchAnalogHighZ: moenchPhotonCounter.cpp $(INCS) clean
|
||||||
g++ -o moenchAnalogHighZ moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG -DHIGHZ
|
g++ -o moenchAnalogHighZ moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG -DHIGHZ
|
||||||
|
|
||||||
|
moenchAnalogNoThread : moenchPhotonCounterNoThread.cpp $(INCS) clean
|
||||||
|
g++ -o moenchAnalogNoThread moenchPhotonCounterNoThread.cpp $(LDFLAG) $(INCDIR) -DNEWRECEIVER -DANALOG
|
||||||
|
|
||||||
|
moenchPhotonCounterNoThread : moenchPhotonCounterNoThread.cpp $(INCS) clean
|
||||||
|
g++ -o moenchPhotonCounterNoThread moenchPhotonCounterNoThread.cpp $(LDFLAG) $(INCDIR) $ -DNEWRECEIVER
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
|
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog moenchPhotonCounterNoThread moenchAnalogNoThread
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,40 +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 -ltiff
|
|
||||||
#-L$(ZMQLIB) -lzmq -L$(CBFLIBDIR)/lib/
|
|
||||||
#-L../../bin
|
|
||||||
MAIN=moench03ClusterFinder.cpp
|
|
||||||
#-lhdf5
|
|
||||||
#DESTDIR?=../bin
|
|
||||||
|
|
||||||
all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
moenchClusterFinder : moench03ClusterFinder.cpp $(INCS) clean
|
|
||||||
g++ -o moenchClusterFinder moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) -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)
|
|
||||||
|
|
||||||
moenchNoInterpolation : moench03NoInterpolation.cpp $(INCS) clean
|
|
||||||
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR)
|
|
||||||
|
|
||||||
moenchPhotonCounter : moenchPhotonCounter.cpp $(INCS) clean
|
|
||||||
g++ -o moenchPhotonCounter moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $ -DNEWRECEIVER
|
|
||||||
|
|
||||||
moenchAnalog : moenchPhotonCounter.cpp $(INCS) clean
|
|
||||||
g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) -DNEWRECEIVER -DANALOG
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
|
|
||||||
|
|
||||||
|
|
@ -385,88 +385,67 @@ int main(int argc, char *argv[]) {
|
|||||||
// printf ("+++++++++++++++ %s\n", ent->d_name);
|
// printf ("+++++++++++++++ %s\n", ent->d_name);
|
||||||
if (string(ent->d_name).find(ext)!= string::npos) {
|
if (string(ent->d_name).find(ext)!= string::npos) {
|
||||||
//printf ("**************8 %s\n", ent->d_name);
|
//printf ("**************8 %s\n", ent->d_name);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sprintf(fname,"%s/%s",indir,ent->d_name);
|
sprintf(fname,"%s/%s",indir,ent->d_name);
|
||||||
//sprintf(fname,ffname,irun);
|
//sprintf(fname,ffname,irun);
|
||||||
cout << fname << endl;
|
cout << fname << endl;
|
||||||
|
|
||||||
|
std::time(&end_time);
|
||||||
std::time(&end_time);
|
cout << std::ctime(&end_time) << endl;
|
||||||
cout << std::ctime(&end_time) << endl;
|
// cout << fname << " " << outfname << " " << imgfname << endl;
|
||||||
// cout << fname << " " << outfname << " " << imgfname << endl;
|
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||||
filebin.open((const char *)(fname), ios::in | ios::binary);
|
// //open file
|
||||||
// //open file
|
ifile=0;
|
||||||
ifile=0;
|
if (filebin.is_open()){
|
||||||
if (filebin.is_open()){
|
// //while read frame
|
||||||
|
ff=-1;
|
||||||
// //while read frame
|
ifr=0;
|
||||||
ff=-1;
|
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||||
ifr=0;
|
if (np==40) {
|
||||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
mt->pushData(buff);
|
||||||
if (np==40) {
|
mt->nextThread();
|
||||||
// cout << "*"<<ifr++<<"*"<<ff<< endl;
|
mt->popFree(buff);
|
||||||
// cout << ff << " " << np << endl;
|
ifr++;
|
||||||
// //push
|
if (ifr%10000==0) cout << ifr << " " << ff << endl;
|
||||||
mt->pushData(buff);
|
if (nframes>0) {
|
||||||
// // //pop
|
while (mt->isBusy()) {;}
|
||||||
mt->nextThread();
|
if (ifr%nframes==0) {
|
||||||
// // // cout << " " << (void*)buff;
|
//The name has an additional "_fXXXXX" at the end, where "XXXXX" is the initial frame number of the image (0,1000,2000...)
|
||||||
mt->popFree(buff);
|
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();
|
||||||
ifr++;
|
ifile++;
|
||||||
if (ifr%10000==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...)
|
ff=-1;
|
||||||
|
|
||||||
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++;
|
|
||||||
}
|
}
|
||||||
}
|
filebin.close();
|
||||||
}// else
|
} else
|
||||||
// cout << ifr << " " << ff << " " << np << endl;
|
cout << "Could not open "<< fname << " for reading " << endl;
|
||||||
ff=-1;
|
}
|
||||||
}
|
}
|
||||||
//cout << "--" << endl;
|
|
||||||
filebin.close();
|
|
||||||
} else
|
|
||||||
cout << "Could not open "<< fname << " for reading " << endl;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
// //close file
|
|
||||||
// //join threads
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (mt->isBusy()) {;}
|
while (mt->isBusy()) {;}
|
||||||
if (nframes>=0) {
|
if (nframes>=0) {
|
||||||
if (nframes>0) {
|
if (nframes>0) {
|
||||||
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
|
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
|
||||||
sprintf(imgfname,ffname,irun);
|
sprintf(imgfname,ffname,irun);
|
||||||
} else {
|
} else {
|
||||||
sprintf(imgfname,"%s/%s_%d.tiff",outdir,fformat,irun);
|
sprintf(imgfname,"%s/%s_%d.tiff",outdir,fformat,irun);
|
||||||
//sprintf(imgfname,ffname,irun);
|
//sprintf(imgfname,ffname,irun);
|
||||||
}
|
}
|
||||||
cout << "Writing tiff to " << imgfname << " " << thr1 <<endl;
|
cout << "Writing tiff to " << imgfname << " " << ifr <<endl;
|
||||||
mt->writeImage(imgfname, thr1);
|
mt->writeImage(imgfname, thr1);
|
||||||
mt->clearImage();
|
mt->clearImage();
|
||||||
if (of) {
|
if (of) {
|
||||||
fclose(of);
|
fclose(of);
|
||||||
of=NULL;
|
of=NULL;
|
||||||
mt->setFilePointer(NULL);
|
mt->setFilePointer(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::time(&end_time);
|
std::time(&end_time);
|
||||||
cout << std::ctime(&end_time) << endl;
|
cout << std::ctime(&end_time) << endl;
|
||||||
@ -482,7 +461,7 @@ int main(int argc, char *argv[]) {
|
|||||||
if (nframes<0){
|
if (nframes<0){
|
||||||
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
|
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
|
||||||
strcpy(imgfname,ffname);
|
strcpy(imgfname,ffname);
|
||||||
cout << "Writing tiff to " << imgfname << " " << thr1 <<endl;
|
cout << "Writing tiff to " << imgfname << " " << ifr <<endl;
|
||||||
mt->writeImage(imgfname, thr1);
|
mt->writeImage(imgfname, thr1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,527 @@
|
|||||||
|
//#include "ansi.h"
|
||||||
|
#include <iostream>
|
||||||
|
//#define CORR
|
||||||
|
#define NOTHREAD
|
||||||
|
|
||||||
|
#define C_GHOST 0.0004
|
||||||
|
|
||||||
|
#define CM_ROWS 50
|
||||||
|
|
||||||
|
//#define VERSION_V1
|
||||||
|
|
||||||
|
//#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 "multiThreadedCountingDetector.h"
|
||||||
|
//#include "multiThreadedAnalogDetector.h"
|
||||||
|
#include "singlePhotonDetector.h"
|
||||||
|
#include "moench03GhostSummation.h"
|
||||||
|
#include "moench03CommonMode.h"
|
||||||
|
//#include "interpolatingDetector.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <map>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <dirent.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] [gainmap]" << 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=10;
|
||||||
|
//int nsubpix=25;
|
||||||
|
//int etabins=nsubpix*10;
|
||||||
|
//double etamin=-1, etamax=2;
|
||||||
|
int csize=3;
|
||||||
|
//int save=1;
|
||||||
|
int nsigma=5;
|
||||||
|
int nped=10000;
|
||||||
|
//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);
|
||||||
|
|
||||||
|
int ncol_cm=CM_ROWS;
|
||||||
|
double xt_ghost=C_GHOST;
|
||||||
|
moench03CommonMode *cm=NULL;
|
||||||
|
moench03GhostSummation *gs;
|
||||||
|
double *gainmap=NULL;
|
||||||
|
//float *gm;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//int size = 327680;////atoi(argv[3]);
|
||||||
|
|
||||||
|
//int* image;
|
||||||
|
//int* image =new int[327680/sizeof(int)];
|
||||||
|
|
||||||
|
int ff, np;
|
||||||
|
//cout << " data size is " << 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=atof(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 *gainfname=NULL;
|
||||||
|
if (argc>13) {
|
||||||
|
gainfname=argv[13];
|
||||||
|
cout << "Gain map file name is: " << gainfname << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
if (thr>0)
|
||||||
|
cout << "threshold is " << thr << endl;
|
||||||
|
uint32 unnx, unny;
|
||||||
|
int nnx, nny;
|
||||||
|
//double *gmap;
|
||||||
|
|
||||||
|
// if (gainfname) {
|
||||||
|
// gm=ReadFromTiff(gainfname, nny, nnx);
|
||||||
|
// if (gm && nnx==nx && nny==ny) {
|
||||||
|
// gmap=new double[nx*ny];
|
||||||
|
// for (int i=0; i<nx*ny; i++) {
|
||||||
|
// gmap[i]=gm[i];
|
||||||
|
// }
|
||||||
|
// delete gm;
|
||||||
|
// } else
|
||||||
|
// cout << "Could not open gain map " << gainfname << endl;
|
||||||
|
// }
|
||||||
|
|
||||||
|
#ifdef CORR
|
||||||
|
cout << "Applying common mode " << ncol_cm << endl;
|
||||||
|
cm=new moench03CommonMode(ncol_cm);
|
||||||
|
|
||||||
|
|
||||||
|
cout << "Applying ghost corrections " << xt_ghost << endl;
|
||||||
|
gs=new moench03GhostSummation(decoder, xt_ghost);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, cm, nped, 200, -1, -1, gainmap, gs);
|
||||||
|
|
||||||
|
if (gainfname) {
|
||||||
|
|
||||||
|
if (filter->readGainMap(gainfname))
|
||||||
|
cout << "using gain map " << gainfname << endl;
|
||||||
|
else
|
||||||
|
cout << "Could not open gain map " << gainfname << endl;
|
||||||
|
} else
|
||||||
|
thr=0.15*thr;
|
||||||
|
filter->newDataSet();
|
||||||
|
//int dsize=decoder->getDataSize();
|
||||||
|
|
||||||
|
|
||||||
|
//char data[dsize];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#ifndef ANALOG
|
||||||
|
if (thr>0) {
|
||||||
|
cout << "threshold is " << thr << endl;
|
||||||
|
//#ifndef ANALOG
|
||||||
|
filter->setThreshold(thr);
|
||||||
|
//#endif
|
||||||
|
cf=0;
|
||||||
|
|
||||||
|
} else
|
||||||
|
cf=1;
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
|
||||||
|
filter->setROI(xmin,xmax,ymin,ymax);
|
||||||
|
std::time(&end_time);
|
||||||
|
cout << std::ctime(&end_time) << endl;
|
||||||
|
|
||||||
|
char* buff;
|
||||||
|
|
||||||
|
// multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||||
|
#ifndef NOTHREAD
|
||||||
|
multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize);
|
||||||
|
#endif
|
||||||
|
#ifdef NOTHREAD
|
||||||
|
singlePhotonDetector *mt=filter;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef ANALOG
|
||||||
|
mt->setDetectorMode(ePhotonCounting);
|
||||||
|
cout << "Counting!" << endl;
|
||||||
|
if (thr>0) {
|
||||||
|
cf=0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
//{
|
||||||
|
#ifdef ANALOG
|
||||||
|
mt->setDetectorMode(eAnalog);
|
||||||
|
cout << "Analog!" << endl;
|
||||||
|
cf=0;
|
||||||
|
//thr1=thr;
|
||||||
|
#endif
|
||||||
|
// }
|
||||||
|
#ifndef NOTHREAD
|
||||||
|
mt->StartThreads();
|
||||||
|
mt->popFree(buff);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DIR *dir;
|
||||||
|
struct dirent *ent;
|
||||||
|
|
||||||
|
// cout << "mt " << endl;
|
||||||
|
|
||||||
|
int ifr=0;
|
||||||
|
|
||||||
|
double ped[nx*ny];//, *ped1;
|
||||||
|
|
||||||
|
|
||||||
|
if (pedfile) {
|
||||||
|
|
||||||
|
cout << "PEDESTAL " << endl;
|
||||||
|
sprintf(imgfname,"%s/pedestals.tiff",outdir);
|
||||||
|
|
||||||
|
if (string(pedfile).find(".tif")==std::string::npos){
|
||||||
|
sprintf(fname,"%s.raw",pedfile);
|
||||||
|
cout << fname << endl ;
|
||||||
|
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)) {
|
||||||
|
if (np==40) {
|
||||||
|
#ifdef NOTHREAD
|
||||||
|
mt->processData(buff);
|
||||||
|
#endif
|
||||||
|
#ifndef NOTHREAD
|
||||||
|
mt->pushData(buff);
|
||||||
|
mt->nextThread();
|
||||||
|
mt->popFree(buff);
|
||||||
|
#endif
|
||||||
|
ifr++;
|
||||||
|
if (ifr%10000==0)
|
||||||
|
cout << ifr << " " << ff << " " << np << endl;
|
||||||
|
} else
|
||||||
|
cout << ifr << " " << ff << " " << np << endl;
|
||||||
|
ff=-1;
|
||||||
|
}
|
||||||
|
filebin.close();
|
||||||
|
#ifndef NOTHREAD
|
||||||
|
while (mt->isBusy()) {;}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
} else
|
||||||
|
cout << "Could not open pedestal file "<< fname << " for reading " << endl;
|
||||||
|
} else {
|
||||||
|
float *pp=ReadFromTiff(pedfile, unny, unnx);
|
||||||
|
nny=unny;
|
||||||
|
nnx=unnx;
|
||||||
|
if (pp && nnx==nx && nny==ny) {
|
||||||
|
for (int i=0; i<nx*ny; i++) {
|
||||||
|
ped[i]=pp[i];
|
||||||
|
}
|
||||||
|
delete [] pp;
|
||||||
|
mt->setPedestal(ped);
|
||||||
|
// ped1=mt->getPedestal();
|
||||||
|
|
||||||
|
// for (int i=0; i<nx*ny; i++) {
|
||||||
|
|
||||||
|
// cout << ped[i]<<"/"<<ped1[i] << " " ;
|
||||||
|
// }
|
||||||
|
cout << "Pedestal set from tiff file " << pedfile << endl;
|
||||||
|
} else {
|
||||||
|
cout << "Could not open pedestal tiff file "<< pedfile << " for reading " << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifdef NOTHREAD
|
||||||
|
mt->writePedestals(imgfname);
|
||||||
|
#endif
|
||||||
|
#ifndef NOTHREAD
|
||||||
|
mt->writePedestal(imgfname);
|
||||||
|
#endif
|
||||||
|
std::time(&end_time);
|
||||||
|
cout << std::ctime(&end_time) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ifr=0;
|
||||||
|
int ifile=0;
|
||||||
|
char ext[100];
|
||||||
|
mt->setFrameMode(eFrame);
|
||||||
|
for (int irun=runmin; irun<=runmax; irun++) {
|
||||||
|
cout << "DATA " ;
|
||||||
|
// sprintf(fn,fformat,irun);
|
||||||
|
sprintf(ext,"_%d.raw",irun);
|
||||||
|
|
||||||
|
|
||||||
|
sprintf(imgfname,"%s/%s_%d.tiff",outdir,fformat,irun);
|
||||||
|
// sprintf(imgfname,ffname,irun);
|
||||||
|
sprintf(cfname,"%s/%s_%d.clust",outdir,fformat, irun);
|
||||||
|
//sprintf(cfname,ffname,irun);
|
||||||
|
cout << cfname << " " ;
|
||||||
|
cout << imgfname << endl;
|
||||||
|
|
||||||
|
|
||||||
|
if (thr<=0 && cf!=0) { //cluster finder
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((dir = opendir (indir)) != NULL) {
|
||||||
|
/* print all the files and directories within directory */
|
||||||
|
while ((ent = readdir (dir)) != NULL) {
|
||||||
|
// printf ("----------- %s\n", ent->d_name);
|
||||||
|
// printf ("************** %s", ent->d_name);
|
||||||
|
// cout << string(ent->d_name).find(fformat) << endl;
|
||||||
|
if (string(ent->d_name).find(string(fformat)+"_d0_f0")==0) {
|
||||||
|
// printf ("+++++++++++++++ %s\n", ent->d_name);
|
||||||
|
if (string(ent->d_name).find(ext)!= string::npos) {
|
||||||
|
//printf ("**************8 %s\n", ent->d_name);
|
||||||
|
sprintf(fname,"%s/%s",indir,ent->d_name);
|
||||||
|
//sprintf(fname,ffname,irun);
|
||||||
|
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
|
||||||
|
ifile=0;
|
||||||
|
if (filebin.is_open()){
|
||||||
|
// //while read frame
|
||||||
|
ff=-1;
|
||||||
|
ifr=0;
|
||||||
|
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||||
|
if (np==40) {
|
||||||
|
#ifdef NOTHREAD
|
||||||
|
mt->processData(buff);
|
||||||
|
#endif
|
||||||
|
#ifndef NOTHREAD
|
||||||
|
mt->pushData(buff);
|
||||||
|
mt->nextThread();
|
||||||
|
mt->popFree(buff);
|
||||||
|
#endif
|
||||||
|
ifr++;
|
||||||
|
if (ifr%10000==0) cout << ifr << " " << ff << endl;
|
||||||
|
if (nframes>0) {
|
||||||
|
#ifndef NOTHREAD
|
||||||
|
while (mt->isBusy()) {;}
|
||||||
|
#endif
|
||||||
|
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;
|
||||||
|
#ifdef NOTHREAD
|
||||||
|
mt->writeImage(imgfname);
|
||||||
|
#endif
|
||||||
|
#ifndef NOTHREAD
|
||||||
|
mt->writeImage(imgfname, thr1);
|
||||||
|
#endif
|
||||||
|
mt->clearImage();
|
||||||
|
ifile++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ff=-1;
|
||||||
|
}
|
||||||
|
filebin.close();
|
||||||
|
} else
|
||||||
|
cout << "Could not open "<< fname << " for reading " << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
#ifndef NOTHREAD
|
||||||
|
while (mt->isBusy()) {;}
|
||||||
|
#endif
|
||||||
|
if (nframes>=0) {
|
||||||
|
if (nframes>0) {
|
||||||
|
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
|
||||||
|
sprintf(imgfname,ffname,irun);
|
||||||
|
} else {
|
||||||
|
sprintf(imgfname,"%s/%s_%d.tiff",outdir,fformat,irun);
|
||||||
|
//sprintf(imgfname,ffname,irun);
|
||||||
|
}
|
||||||
|
cout << "Writing tiff to " << imgfname << " " << ifr <<endl;
|
||||||
|
#ifdef NOTHREAD
|
||||||
|
mt->writeImage(imgfname);
|
||||||
|
#endif
|
||||||
|
#ifndef NOTHREAD
|
||||||
|
mt->writeImage(imgfname, thr1);
|
||||||
|
#endif
|
||||||
|
mt->clearImage();
|
||||||
|
if (of) {
|
||||||
|
fclose(of);
|
||||||
|
of=NULL;
|
||||||
|
mt->setFilePointer(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::time(&end_time);
|
||||||
|
cout << std::ctime(&end_time) << endl;
|
||||||
|
|
||||||
|
closedir (dir);
|
||||||
|
} else {
|
||||||
|
/* could not open directory */
|
||||||
|
cout << "could not open directory " << indir << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nframes<0){
|
||||||
|
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
|
||||||
|
strcpy(imgfname,ffname);
|
||||||
|
cout << "Writing tiff to " << imgfname << " " << ifr <<endl;
|
||||||
|
#ifdef NOTHREAD
|
||||||
|
mt->writeImage(imgfname);
|
||||||
|
#endif
|
||||||
|
#ifndef NOTHREAD
|
||||||
|
mt->writeImage(imgfname, thr1);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sprintf(imgfname,"%s/%s_ped.tiff",outdir,fformat);
|
||||||
|
#ifdef NOTHREAD
|
||||||
|
mt->writePedestals(imgfname);
|
||||||
|
#endif
|
||||||
|
#ifndef NOTHREAD
|
||||||
|
mt->writePedestal(imgfname);
|
||||||
|
#endif
|
||||||
|
sprintf(imgfname,"%s/%s_noise.tiff",outdir,fformat);
|
||||||
|
mt->writePedestalRMS(imgfname);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -208,11 +208,11 @@ FILE *getFilePointer(){return det->getFilePointer();};
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int *getFlatField(int &nb, double emi, double ema){
|
virtual int *getFlatField(int &nb, int &nby, double emi, double ema){
|
||||||
slsInterpolation *interp=(det)->getInterpolation();
|
slsInterpolation *interp=(det)->getInterpolation();
|
||||||
int *ff=NULL;
|
int *ff=NULL;
|
||||||
if (interp) {
|
if (interp) {
|
||||||
ff=interp->getFlatField(nb,emi,ema);
|
ff=interp->getFlatField(nb,nby,emi,ema);
|
||||||
}
|
}
|
||||||
return ff;
|
return ff;
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@ public:
|
|||||||
return (dets[0])->getFlatField();
|
return (dets[0])->getFlatField();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int *getFlatField(int &nb, double emi, double ema){
|
virtual int *getFlatField(int &nb, int &nby, double emi, double ema){
|
||||||
return (dets[0])->getFlatField(nb,emi,ema);
|
return (dets[0])->getFlatField(nb,nby,emi,ema);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int *setFlatField(int *h=NULL, int nb=-1, double emin=1, double emax=0){
|
virtual int *setFlatField(int *h=NULL, int nb=-1, double emin=1, double emax=0){
|
||||||
|
Reference in New Issue
Block a user