mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-17 15:27:13 +02:00
Some fixes to the offline processing - could also affect hte zmq process
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
hostname bchip071+
|
||||
hostname bchip135+
|
||||
|
||||
patword 0000 0000000000000000
|
||||
patword 0001 0000000000000000
|
||||
|
@ -226,8 +226,11 @@ template <class dataType> class analogDetector {
|
||||
\returns pointer to current gain map is file reading succeeded, NULL is file reading didn't work.
|
||||
*/
|
||||
double *readGainMap(const char * imgname) {
|
||||
uint32 nnx, nny;
|
||||
float *gm=ReadFromTiff( imgname, nny, nnx);
|
||||
uint32 unnx, unny;
|
||||
int nnx, nny;
|
||||
float *gm=ReadFromTiff( imgname, unny, unnx);
|
||||
nnx=unnx;
|
||||
nny=unny;
|
||||
if (gm) {
|
||||
if (gmap) delete [] gmap;
|
||||
gmap=new double[nnx*nny];
|
||||
|
@ -77,9 +77,9 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
|
||||
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
// int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
// int ix, iy;
|
||||
|
||||
int npackets=40;
|
||||
int i;
|
||||
@ -110,35 +110,35 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
|
||||
}
|
||||
}
|
||||
|
||||
int ipacket;
|
||||
int ibyte;
|
||||
int ii=0;
|
||||
for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){
|
||||
xmap[ibyte]=-1;
|
||||
ymap[ibyte]=-1;
|
||||
}
|
||||
int off=sizeof(sls_detector_header)/2;
|
||||
for (ipacket=0; ipacket<npackets; ipacket++) {
|
||||
for (ibyte=0; ibyte< 8192/2; ibyte++) {
|
||||
i=ipacket*8208/2+ibyte;
|
||||
isample=ii/nadc;
|
||||
if (isample<nSamples) {
|
||||
iadc=ii%nadc;
|
||||
adc4 = (int)iadc/4;
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
if (adc4%2==0) {
|
||||
xmap[i+off]=adc_nr[iadc]+ix;
|
||||
ymap[i+off]=ny/2-1-iy;
|
||||
} else {
|
||||
xmap[i+off]=adc_nr[iadc]+ix;
|
||||
ymap[i+off]=ny/2+iy;
|
||||
}
|
||||
}
|
||||
ii++;
|
||||
// int ipacket;
|
||||
// int ibyte;
|
||||
// int ii=0;
|
||||
// for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){
|
||||
// xmap[ibyte]=-1;
|
||||
// ymap[ibyte]=-1;
|
||||
// }
|
||||
// int off=sizeof(sls_detector_header)/2;
|
||||
// for (ipacket=0; ipacket<npackets; ipacket++) {
|
||||
// for (ibyte=0; ibyte< 8192/2; ibyte++) {
|
||||
// i=ipacket*8208/2+ibyte;
|
||||
// isample=ii/nadc;
|
||||
// if (isample<nSamples) {
|
||||
// iadc=ii%nadc;
|
||||
// adc4 = (int)iadc/4;
|
||||
// ix=isample%sc_width;
|
||||
// iy=isample/sc_width;
|
||||
// if (adc4%2==0) {
|
||||
// xmap[i+off]=adc_nr[iadc]+ix;
|
||||
// ymap[i+off]=ny/2-1-iy;
|
||||
// } else {
|
||||
// xmap[i+off]=adc_nr[iadc]+ix;
|
||||
// ymap[i+off]=ny/2+iy;
|
||||
// }
|
||||
// }
|
||||
// ii++;
|
||||
// // }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
@ -240,15 +240,15 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
char *retval=0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np=0;
|
||||
int pn;
|
||||
//char *retval=0;
|
||||
// int nd;
|
||||
//int fnum = -1;
|
||||
// np=0;
|
||||
// int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff>=0)
|
||||
fnum=ff;
|
||||
// if (ff>=0)
|
||||
// fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize) ){
|
||||
|
@ -253,12 +253,13 @@ class slsDetectorData {
|
||||
|
||||
*/
|
||||
virtual dataType getChannel(char *data, int ix, int iy=0) {
|
||||
dataType m=0, d=0;
|
||||
dataType m=0, d=0, *p;
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny && dataMap[iy][ix]>=0 && dataMap[iy][ix]<dataSize) {
|
||||
// cout << ix << " " << iy << " " ;
|
||||
//cout << dataMap[ix][iy] << " " << (void*)data << " " << dataSize<< endl;
|
||||
m=dataMask[iy][ix];
|
||||
d=*((dataType*)(data+dataMap[iy][ix]));
|
||||
p=(dataType*)(data+dataMap[iy][ix]);
|
||||
d=*p;
|
||||
}
|
||||
return d^m;
|
||||
};
|
||||
|
@ -1,8 +1,10 @@
|
||||
#module add CBFlib/0.9.5
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/
|
||||
|
||||
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -pthread -lrt -ltiff -O3 -std=c++11
|
||||
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 -std=c++11 -Wall -O3
|
||||
#-g3
|
||||
#-fsanitize=thread -fno-omit-frame-pointer
|
||||
#-fsanitize=address,undefined,
|
||||
MAIN=moench03ClusterFinder.cpp
|
||||
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
//#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
// bin/moenchClusterFinder moench03_25022020 moench_fluo_outputs flat_27keV_d0_f000000%d00000_1 0 10
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
#ifdef NEWRECEIVER
|
||||
@ -34,6 +35,8 @@
|
||||
#include "singlePhotonDetector.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <stdio.h>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
@ -50,20 +53,20 @@ int main(int argc, char *argv[]) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " << endl;
|
||||
return 1;
|
||||
}
|
||||
int p=10000;
|
||||
//int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=1;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
int nthreads=16;
|
||||
//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=1;
|
||||
//int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
int iprog=0;
|
||||
//int ndark=100;
|
||||
//int ok;
|
||||
//int iprog=0;
|
||||
|
||||
|
||||
|
||||
@ -108,9 +111,9 @@ int main(int argc, char *argv[]) {
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
//int size = 327680;////atoi(argv[3]);
|
||||
|
||||
int* image;
|
||||
//int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
@ -120,19 +123,19 @@ int main(int argc, char *argv[]) {
|
||||
cout << " data size is " << dsize;
|
||||
|
||||
|
||||
char data[dsize];
|
||||
//char data[dsize];
|
||||
|
||||
ifstream filebin;
|
||||
char *indir=argv[1];
|
||||
char *outdir=argv[2];
|
||||
char *fformat=argv[3];
|
||||
string indir=string(argv[1]);
|
||||
string outdir=string(argv[2]);
|
||||
string fformat=string(argv[3]);
|
||||
int runmin=atoi(argv[4]);
|
||||
int runmax=atoi(argv[5]);
|
||||
|
||||
char fname[10000];
|
||||
char outfname[10000];
|
||||
char imgfname[10000];
|
||||
char pedfname[10000];
|
||||
string fname;
|
||||
string outfname;
|
||||
string imgfname;
|
||||
//char pedfname[10000];
|
||||
// strcpy(pedfname,argv[6]);
|
||||
char fn[10000];
|
||||
|
||||
@ -148,12 +151,6 @@ int main(int argc, char *argv[]) {
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
@ -170,17 +167,26 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
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);
|
||||
sprintf(fn,fformat.c_str(),irun);
|
||||
fname=indir+"/"+string(fn)+".raw";
|
||||
//sprintf(fname,"%s/%s.raw",indir,fn);
|
||||
#ifndef WRITE_QUAD
|
||||
outfname=outdir+string(fn)+".clust";
|
||||
//sprintf(outfname,"%s/%s.clust",outdir,fn);
|
||||
#endif
|
||||
#ifdef WRITE_QUAD
|
||||
outfname=outdir+string(fn)+".clust2";
|
||||
// sprintf(outfname,"%s/%s.clust2",outdir,fn);
|
||||
#endif
|
||||
imgfname=outdir+string(fn)+".tiff";
|
||||
//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);
|
||||
filebin.open(fname.c_str(), ios::in | ios::binary);
|
||||
// //open file
|
||||
if (filebin.is_open()){
|
||||
of=fopen(outfname,"w");
|
||||
of=fopen(outfname.c_str(),"w");
|
||||
if (of) {
|
||||
mt->setFilePointer(of);
|
||||
// cout << "file pointer set " << endl;
|
||||
@ -220,7 +226,7 @@ int main(int argc, char *argv[]) {
|
||||
if (of)
|
||||
fclose(of);
|
||||
|
||||
mt->writeImage(imgfname);
|
||||
mt->writeImage(imgfname.c_str());
|
||||
mt->clearImage();
|
||||
|
||||
std::time(&end_time);
|
||||
|
@ -50,9 +50,9 @@ int main(int argc, char *argv[]) {
|
||||
#endif
|
||||
int iarg=4;
|
||||
char infname[10000];
|
||||
char fname[10000];
|
||||
char outfname[10000];
|
||||
#ifndef FF
|
||||
char fname[10000];
|
||||
iarg=4;
|
||||
#endif
|
||||
|
||||
@ -74,22 +74,45 @@ int main(int argc, char *argv[]) {
|
||||
cout << "Energy min: " << cmin << endl;
|
||||
cout << "Energy max: " << cmax << endl;
|
||||
//int etabins=500;
|
||||
#ifndef NOINTERPOLATION
|
||||
int etabins=1000;//nsubpix*2*100;
|
||||
int etabinsY=etabins;//nsubpix*2*100;
|
||||
#ifndef ETA3
|
||||
double etamin=-1, etamax=2;
|
||||
//double etamin=-0.1, etamax=1.1;
|
||||
double etax=0, etay=0;
|
||||
#ifndef FF
|
||||
double int_x, int_y;
|
||||
// double d_x, d_y, res=5, xx, yy;
|
||||
int ok;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef ETA3
|
||||
double eta3min=-2, eta3max=2;
|
||||
double eta3x, eta3y;
|
||||
|
||||
#ifndef FF
|
||||
double int3_x, int3_y;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#ifndef FF
|
||||
int quad;
|
||||
#endif
|
||||
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;
|
||||
|
||||
#ifdef NOINTERPOLATION
|
||||
#ifndef FF
|
||||
double noint_x, noint_y;
|
||||
#endif
|
||||
#endif
|
||||
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;
|
||||
|
||||
//badph=0,
|
||||
int nph=0, totph=0;
|
||||
FILE *f=NULL;
|
||||
|
||||
#ifdef DOUBLE_SPH
|
||||
@ -120,6 +143,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
#ifndef FF
|
||||
int *img;
|
||||
#ifndef NOINTERPOLATION
|
||||
cout << "read ff " << argv[2] << endl;
|
||||
sprintf(fname,"%s",argv[2]);
|
||||
@ -132,7 +156,6 @@ int main(int argc, char *argv[]) {
|
||||
cout << "Will write eta file " << argv[2] << endl;
|
||||
#endif
|
||||
|
||||
int *img;
|
||||
float *totimg=new float[NC*NR*nSubPixels*nSubPixelsY];
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR; iy++) {
|
||||
@ -168,7 +191,13 @@ int main(int argc, char *argv[]) {
|
||||
if (nframes==0) f0=lastframe;
|
||||
nframes++;
|
||||
}
|
||||
#ifndef FF
|
||||
quad=interp->calcEta(cl.get_cluster(), etax, etay, sum, totquad, sDum);
|
||||
#endif
|
||||
#ifdef FF
|
||||
interp->calcEta(cl.get_cluster(), etax, etay, sum, totquad, sDum);
|
||||
#endif
|
||||
|
||||
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && sum<cmax ) {
|
||||
nph++;
|
||||
// if (sum>200 && sum<580) {
|
||||
@ -263,9 +292,9 @@ int main(int argc, char *argv[]) {
|
||||
#ifdef RECT1
|
||||
WriteToTiff(rectimg, outfname,NC,NR*nSubPixelsY);
|
||||
#endif
|
||||
cout << "Read " << nframes << " frames (first frame: " << f0 << " last frame: " << lastframe << " delta:" << lastframe-f0 << ") nph="<< nph <<endl;
|
||||
interp->clearInterpolatedImage();
|
||||
#endif
|
||||
cout << "Read " << nframes << " frames (first frame: " << f0 << " last frame: " << lastframe << " delta:" << lastframe-f0 << ") nph="<< nph <<endl;
|
||||
|
||||
} else
|
||||
cout << "could not open file " << infname << endl;
|
||||
|
@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
|
||||
*/
|
||||
|
||||
if (argc<7) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile " << " etafile outfile runmin runmax ns" << endl;
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile " << " outfile runmin runmax ns" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -28,13 +28,14 @@ int main(int argc, char *argv[]) {
|
||||
int runmax=atoi(argv[5]);
|
||||
int nsubpix=atoi(argv[6]);
|
||||
|
||||
int etabins=1000;//nsubpix*2*100;
|
||||
double etamin=-1, etamax=2;
|
||||
// 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;
|
||||
//double etax, etay,
|
||||
double int_x, int_y;
|
||||
//int ok;
|
||||
|
||||
int ix, iy, isx, isy;
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <dirent.h>
|
||||
#include <ctime>
|
||||
using namespace std;
|
||||
|
||||
@ -58,19 +58,19 @@ int main(int argc, char *argv[]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int p=10000;
|
||||
//int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=10;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
//int nsubpix=25;
|
||||
//int etabins=nsubpix*10;
|
||||
//double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int save=1;
|
||||
//int save=1;
|
||||
int nsigma=5;
|
||||
int nped=10000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
int iprog=0;
|
||||
//int ndark=100;
|
||||
//int ok;
|
||||
//int iprog=0;
|
||||
|
||||
int cf=0;
|
||||
|
||||
@ -101,13 +101,13 @@ int main(int argc, char *argv[]) {
|
||||
moench03CommonMode *cm=NULL;
|
||||
moench03GhostSummation *gs;
|
||||
double *gainmap=NULL;
|
||||
float *gm;
|
||||
//float *gm;
|
||||
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
//int size = 327680;////atoi(argv[3]);
|
||||
|
||||
int* image;
|
||||
//int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
|
||||
int ff, np;
|
||||
@ -171,7 +171,7 @@ int main(int argc, char *argv[]) {
|
||||
char fname[10000];
|
||||
char imgfname[10000];
|
||||
char cfname[10000];
|
||||
char fn[10000];
|
||||
//char fn[10000];
|
||||
|
||||
std::time_t end_time;
|
||||
|
||||
@ -185,9 +185,9 @@ int main(int argc, char *argv[]) {
|
||||
cout << "pedestal file is " << pedfile << endl;
|
||||
if (thr>0)
|
||||
cout << "threshold is " << thr << endl;
|
||||
|
||||
uint32 nnx, nny;
|
||||
double *gmap;
|
||||
uint32 unnx, unny;
|
||||
int nnx, nny;
|
||||
//double *gmap;
|
||||
|
||||
// if (gainfname) {
|
||||
// gm=ReadFromTiff(gainfname, nny, nnx);
|
||||
@ -221,10 +221,10 @@ int main(int argc, char *argv[]) {
|
||||
} else
|
||||
thr=0.15*thr;
|
||||
filter->newDataSet();
|
||||
int dsize=decoder->getDataSize();
|
||||
//int dsize=decoder->getDataSize();
|
||||
|
||||
|
||||
char data[dsize];
|
||||
//char data[dsize];
|
||||
|
||||
|
||||
|
||||
@ -270,12 +270,14 @@ int main(int argc, char *argv[]) {
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
DIR *dir;
|
||||
struct dirent *ent;
|
||||
|
||||
// cout << "mt " << endl;
|
||||
|
||||
int ifr=0;
|
||||
|
||||
double ped[nx*ny], *ped1;
|
||||
double ped[nx*ny];//, *ped1;
|
||||
|
||||
|
||||
if (pedfile) {
|
||||
@ -314,7 +316,9 @@ int main(int argc, char *argv[]) {
|
||||
} else
|
||||
cout << "Could not open pedestal file "<< fname << " for reading " << endl;
|
||||
} else {
|
||||
float *pp=ReadFromTiff(pedfile, nny, nnx);
|
||||
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];
|
||||
@ -341,27 +345,22 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
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(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 << " " ;
|
||||
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;
|
||||
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 && cf!=0) { //cluster finder
|
||||
if (of==NULL) {
|
||||
of=fopen(cfname,"w");
|
||||
@ -375,6 +374,33 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@ -412,16 +438,26 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
cout << "--" << endl;
|
||||
filebin.close();
|
||||
} else
|
||||
cout << "Could not open "<< fname << " for reading " << endl;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// //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);
|
||||
} else {
|
||||
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
|
||||
sprintf(imgfname,ffname,irun);
|
||||
sprintf(imgfname,"%s/%s_%d.tiff",outdir,fformat,irun);
|
||||
//sprintf(imgfname,ffname,irun);
|
||||
}
|
||||
cout << "Writing tiff to " << imgfname << " " << thr1 <<endl;
|
||||
mt->writeImage(imgfname, thr1);
|
||||
@ -434,9 +470,15 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
} else
|
||||
cout << "Could not open "<< fname << " for reading " << 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);
|
||||
|
@ -1,4 +1,4 @@
|
||||
#define WRITE_QUAD
|
||||
//#define WRITE_QUAD
|
||||
#define MOENCH_BRANCH
|
||||
|
||||
#define C_GHOST 0.0004
|
||||
@ -139,8 +139,12 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
int ncol_cm=CM_ROWS;
|
||||
double xt_ghost=C_GHOST;
|
||||
moench03CommonMode *cm=new moench03CommonMode(ncol_cm);
|
||||
moench03GhostSummation *gs=new moench03GhostSummation(det, xt_ghost);
|
||||
moench03CommonMode *cm=NULL;
|
||||
moench03GhostSummation *gs=NULL;
|
||||
#ifdef CORR
|
||||
gs=new moench03GhostSummation(det, xt_ghost);
|
||||
cm=new moench03CommonMode(ncol_cm);
|
||||
#endif
|
||||
double *gainmap=NULL;
|
||||
float *gm;
|
||||
double *gmap=NULL;
|
||||
|
@ -322,19 +322,22 @@ public:
|
||||
|
||||
virtual int *getImage(int &nnx, int &nny, int &ns, int &nsy) {
|
||||
int *img;
|
||||
cout << "get image "<< image << endl;
|
||||
// int nnx, nny, ns;
|
||||
// int nnx, nny, ns;
|
||||
int nn=dets[0]->getImageSize(nnx, nny,ns, nsy);
|
||||
if (image) {
|
||||
delete image;
|
||||
cout << "del image "<< image << endl;
|
||||
delete [] image;
|
||||
image=NULL;
|
||||
}
|
||||
image=new int[nn];
|
||||
cout << "new image" << image << endl;
|
||||
//int nn=dets[0]->getImageSize(nnx, nny, ns);
|
||||
//for (i=0; i<nn; i++) image[i]=0;
|
||||
|
||||
if (image) {
|
||||
for (int ii=0; ii<nThreads; ii++) {
|
||||
//cout << ii << " " << nn << " " << nnx << " " << nny << " " << ns << endl;
|
||||
cout << ii << " " << nn << " " << nnx << " " << nny << " " << nsy << endl;
|
||||
img=dets[ii]->getImage();
|
||||
for (int i=0; i<nn; i++) {
|
||||
if (ii==0)
|
||||
@ -344,10 +347,15 @@ public:
|
||||
// image[i]=0;
|
||||
else //if (img[i]>0)
|
||||
image[i]+=img[i];
|
||||
/***
|
||||
gdb runtime error
|
||||
../multiThreadedAnalogDetector.h:349:14: runtime error: signed integer overflow: -1094794611 + -1094795013 cannot be rep
|
||||
**/
|
||||
//if (img[i]) cout << "det " << ii << " pix " << i << " val " << img[i] << " " << image[i] << endl;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return image;
|
||||
|
||||
}
|
||||
@ -369,6 +377,7 @@ public:
|
||||
/* dets[ii]->writeImage(tit); */
|
||||
/* } */
|
||||
/* #endif */
|
||||
cout << "write image" << endl;
|
||||
int nnx, nny, ns, nsy;
|
||||
getImage(nnx, nny, ns, nsy);
|
||||
//int nnx, nny, ns;
|
||||
@ -386,9 +395,11 @@ public:
|
||||
|
||||
//if (image[ix]>0 && ix/nnx<350) cout << ix/nnx << " " << ix%nnx << " " << image[ix]<< " " << gm[ix] << endl;
|
||||
}
|
||||
//cout << "image " << nnx << " " << nny << endl;
|
||||
cout << "image " << nnx << " " << nny << endl;
|
||||
WriteToTiff(gm,imgname ,nnx, nny);
|
||||
cout << imgname << endl;
|
||||
delete [] gm;
|
||||
cout << "del" << endl;
|
||||
} else cout << "Could not allocate float image " << endl;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "analogDetector.h"
|
||||
|
||||
#include "single_photon_hit.h"
|
||||
|
||||
#include <mutex>
|
||||
|
||||
|
||||
//#define MYROOT1
|
||||
@ -62,8 +62,8 @@ public analogDetector<uint16_t> {
|
||||
|
||||
|
||||
|
||||
|
||||
fm=new pthread_mutex_t ;
|
||||
fm=new mutex;
|
||||
// fm=new pthread_mutex_t ;
|
||||
|
||||
eventMask=new eventType*[ny];
|
||||
for (int i=0; i<ny; i++) {
|
||||
@ -117,6 +117,9 @@ public analogDetector<uint16_t> {
|
||||
|
||||
setClusterSize(clusterSize);
|
||||
fm=orig->fm;
|
||||
//setMutex(orig->fm);
|
||||
|
||||
|
||||
|
||||
quad=UNDEFINED_QUADRANT;
|
||||
tot=0;
|
||||
@ -350,7 +353,7 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
int cy=(clusterSizeY+1)/2;
|
||||
int cs=(clusterSize+1)/2;
|
||||
//int ir, ic;
|
||||
|
||||
int iframe=det->getFrameNumber(data);
|
||||
double max=0, tl=0, tr=0, bl=0,br=0, *v;
|
||||
int cm=0;
|
||||
int good=1;
|
||||
@ -394,9 +397,9 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
|
||||
if ((iy+ir)>=iy && (iy+ir)<ny && (ix+ic)>=ix && (ix+ic)<nx) {
|
||||
if ((iy+ir)>=0 && (iy+ir)>=iy && (iy+ir)<ny && (ix+ic)>=0 &&(ix+ic)>=ix && (ix+ic)<nx) {
|
||||
val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir, cm);
|
||||
}
|
||||
(clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir);
|
||||
|
||||
v=&(val[iy+ir][ix+ic]);
|
||||
tot+=*v;
|
||||
@ -420,6 +423,9 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
eventMask[iy][ix]=PHOTON;
|
||||
}
|
||||
|
||||
} else
|
||||
(clusters+nph)->set_data(0,ic,ir);
|
||||
|
||||
}
|
||||
}
|
||||
if (eventMask[iy][ix]==PHOTON && val[iy][ix]<max)
|
||||
@ -442,17 +448,21 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
if (max>nSigma*(clusters+nph)->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*(clusters+nph)->rms || ((clusters+nph)->quadTot)>sqrt(cy*cs)*nSigma*(clusters+nph)->rms) {
|
||||
if (val[iy][ix]>=max) {
|
||||
eventMask[iy][ix]=PHOTON_MAX;
|
||||
(clusters+nph)->tot=tot;
|
||||
// (clusters+nph)->tot=tot;
|
||||
(clusters+nph)->x=ix;
|
||||
(clusters+nph)->y=iy;
|
||||
// (clusters+nph)->iframe=det->getFrameNumber(data);
|
||||
(clusters+nph)->iframe=iframe;
|
||||
// cout << det->getFrameNumber(data) << " " << (clusters+nph)->iframe << endl;
|
||||
(clusters+nph)->ped=getPedestal(ix,iy,0);
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
(clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir);
|
||||
}
|
||||
}
|
||||
// (clusters+nph)->ped=getPedestal(ix,iy,0);
|
||||
// for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
// for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
// if ((iy+ir)>=0 && (iy+ir)<ny && (ix+ic)>=0 && (ix+ic)<nx)
|
||||
// (clusters+nph)->set_data(val[iy+ir][ix+ic],ic,ir);
|
||||
// else
|
||||
// (clusters+nph)->set_data(0,ic,ir);
|
||||
|
||||
// }
|
||||
// }
|
||||
good=1;
|
||||
if (eMin>0 && tot<eMin) good=0;
|
||||
if (eMax>0 && tot>eMax) good=0;
|
||||
@ -474,8 +484,9 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
nphFrame=nph;
|
||||
nphTot+=nph;
|
||||
//cout << nphFrame << endl;
|
||||
// cout <<"**********************************"<< det->getFrameNumber(data) << " " << nphFrame << endl;
|
||||
writeClusters(det->getFrameNumber(data));
|
||||
if (iframe%10000==0)
|
||||
cout <<"**********************************"<< iframe << " " << nphFrame << endl;
|
||||
writeClusters(iframe);
|
||||
return image;
|
||||
|
||||
};
|
||||
@ -576,12 +587,15 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
void writeClusters(int fn){
|
||||
if (myFile) {
|
||||
//cout << "++" << endl;
|
||||
pthread_mutex_lock(fm);
|
||||
// cout <<"**********************************"<< fn << " " << nphFrame << endl;
|
||||
//pthread_mutex_lock(fm);
|
||||
fm->lock();
|
||||
// cout <<id << " **********************************"<< fn << " " << nphFrame << endl;
|
||||
writeClusters(myFile,clusters,nphFrame, fn);
|
||||
// for (int i=0; i<nphFrame; i++)
|
||||
// (clusters+i)->write(myFile);
|
||||
pthread_mutex_unlock(fm);
|
||||
// cout << "--" << endl;
|
||||
fm->unlock();
|
||||
//pthread_mutex_unlock(fm);
|
||||
//cout << "--" << endl;
|
||||
}
|
||||
};
|
||||
@ -613,7 +627,8 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
void setEnergyRange(double emi, double ema){eMin=emi; eMax=ema;};
|
||||
void getEnergyRange(double &emi, double &ema){emi=eMin; ema=eMax;};
|
||||
|
||||
void setMutex(pthread_mutex_t *m){fm=m;};
|
||||
// void setMutex(pthread_mutex_t *m){fm=m;};
|
||||
void setMutex(mutex *m){fm=m;};
|
||||
|
||||
protected:
|
||||
|
||||
@ -631,8 +646,8 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
int nphTot;
|
||||
int nphFrame;
|
||||
|
||||
pthread_mutex_t *fm;
|
||||
|
||||
// pthread_mutex_t *fm;
|
||||
mutex *fm;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user