Some fixes to the offline processing - could also affect hte zmq process

This commit is contained in:
2020-04-06 09:42:38 +02:00
parent 95351d0924
commit 163eb2710f
12 changed files with 332 additions and 218 deletions

View File

@ -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

View File

@ -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
@ -33,7 +34,9 @@
#include "multiThreadedAnalogDetector.h"
#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,21 +123,21 @@ 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];
char fn[10000];
std::time_t end_time;
@ -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;
@ -212,7 +218,7 @@ int main(int argc, char *argv[]) {
}
ff=-1;
}
cout << "--" << endl;
cout << "--" << endl;
filebin.close();
// //close file
// //join threads
@ -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);

View File

@ -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,23 +74,46 @@ 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;
FILE *f=NULL;
//badph=0,
int nph=0, totph=0;
FILE *f=NULL;
#ifdef DOUBLE_SPH
single_photon_hit_double cl(3,3);
@ -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;

View File

@ -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;

View File

@ -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,28 +345,23 @@ 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 (thr<=0 && cf!=0) { //cluster finder
if (of==NULL) {
of=fopen(cfname,"w");
if (of) {
@ -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,18 +438,28 @@ 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);
}
while (mt->isBusy()) {;}
if (nframes>=0) {
if (nframes>0) {
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
sprintf(imgfname,ffname,irun);
}
cout << "Writing tiff to " << imgfname << " " << thr1 <<endl;
} else {
sprintf(imgfname,"%s/%s_%d.tiff",outdir,fformat,irun);
//sprintf(imgfname,ffname,irun);
}
cout << "Writing tiff to " << imgfname << " " << thr1 <<endl;
mt->writeImage(imgfname, thr1);
mt->clearImage();
if (of) {
@ -431,21 +467,27 @@ int main(int argc, char *argv[]) {
of=NULL;
mt->setFilePointer(NULL);
}
}
std::time(&end_time);
cout << std::ctime(&end_time) << endl;
} else
cout << "Could not open "<< fname << " for reading " << endl;
}
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 << " " << thr1 <<endl;
mt->writeImage(imgfname, thr1);
}
return 0;
}

View File

@ -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;