mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-04 00:50:42 +02:00
some fixes in the cluster finder
This commit is contained in:
parent
f264691dc1
commit
d1ef6bf94b
@ -50,9 +50,13 @@ public:
|
||||
for(int ix=0; ix<xpixels; ix++) {
|
||||
imod=ix%2;
|
||||
if (imod==0)
|
||||
dMap[0][ix] =ix+offset;
|
||||
ipix=ix/2;
|
||||
else
|
||||
dMap[0][ix] = 1280*2+2*offset+2*(1280-1-ix/2);//dataSize-2-ix;//+2*offset;
|
||||
ipix=1280-1-ix/2;
|
||||
if (imod==0)
|
||||
dMap[0][ix] =ipix*2+offset;
|
||||
else
|
||||
dMap[0][ix] = 1280*2+2*offset+ipix*2;//dataSize-2-ix;//+2*offset;
|
||||
// dMap[0][ix] = 2*ipix+offset*(imod+1)+1280*2*imod;
|
||||
dMask[0][ix] = 0x0;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ int main(int argc, char *argv[]){
|
||||
|
||||
|
||||
int fifosize=1000;
|
||||
int nthreads=3;
|
||||
int nthreads=1;
|
||||
int nph, nph1;
|
||||
int etabins=550;
|
||||
double etamin=-1, etamax=2;
|
||||
@ -72,8 +72,8 @@ int main(int argc, char *argv[]){
|
||||
|
||||
gotthardModuleDataNew *decoder=new gotthardModuleDataNew();
|
||||
gotthardDoubleModuleDataNew *det=new gotthardDoubleModuleDataNew(offset);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 200);
|
||||
filter->setROI(0,512,0,1);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 100);
|
||||
filter->setROI(0,2560,0,1);
|
||||
char *buff;//[2*(48+1280*2)];
|
||||
char *buff0;
|
||||
char *buff1;
|
||||
@ -82,7 +82,7 @@ int main(int argc, char *argv[]){
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
buff0=buff;
|
||||
buff1=buff+48+1280*2;
|
||||
buff1=buff+offset*2+1280*2;
|
||||
int photons[1280*2];
|
||||
int nf=0;
|
||||
int ok=0;
|
||||
@ -249,7 +249,6 @@ int main(int argc, char *argv[]){
|
||||
int runmax=atoi(argv[4]);
|
||||
char *outdir=argv[5];
|
||||
sprintf(ff,"%s/%s",indir,fformat);
|
||||
|
||||
// strcpy(fformat,"/external_pool/gotthard_data/datadir_gotthardI/bchip074075/20170731/Xray/xray_15kV_200uA_5us_d%d_f000000000000_0.raw");
|
||||
// sprintf(fname0,fformat,0,0);
|
||||
// sprintf(fname1,fformat,1,1);
|
||||
@ -277,21 +276,37 @@ int main(int argc, char *argv[]){
|
||||
|
||||
#ifdef ZMQ
|
||||
|
||||
int end_of_acquisition;
|
||||
while(1) {
|
||||
if ((!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) && (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1))){
|
||||
end_of_acquisition=0;
|
||||
// cout << "Receive header " << nf << endl;
|
||||
if (!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) {
|
||||
|
||||
cout << "************************************************************************** packet0!*****************************"<< endl;
|
||||
|
||||
end_of_acquisition++;
|
||||
}
|
||||
if (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1)) {
|
||||
cout << "************************************************************************** packet1!*****************************"<< endl;
|
||||
|
||||
end_of_acquisition++;
|
||||
}
|
||||
|
||||
// if ((!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) && (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1))){
|
||||
if (end_of_acquisition) {
|
||||
cout << "************************************************************************** END OF FRAME" << end_of_acquisition << " !*****************************"<< endl;
|
||||
// return 0;
|
||||
|
||||
while (mt->isBusy()) {;}
|
||||
image=filter->getImage();
|
||||
if (image) {
|
||||
fout=fopen(ofname,"w");
|
||||
//cout << nf << "*****************" << endl;
|
||||
for (int i=0; i<512; i++) {
|
||||
fprintf(fout,"%d %d\n",i,image[i]);
|
||||
dout[i]=image[i];
|
||||
//fout=fopen(ofname,"w");
|
||||
cout << nf << "*****************" << endl;
|
||||
for (int i=0; i<2560; i++) {
|
||||
// // fprintf(fout,"%d %d\n",i,image[i]);
|
||||
dout[i]=image[i];
|
||||
}
|
||||
fclose(fout);;
|
||||
// // fclose(fout);;
|
||||
}
|
||||
|
||||
|
||||
@ -330,9 +345,10 @@ int main(int argc, char *argv[]){
|
||||
cout << "different frame indexes " << frameIndex0 << " and " << frameIndex1 << endl;
|
||||
|
||||
|
||||
|
||||
// cout << "Receive data " << nf << endl;
|
||||
length = zmqsocket0->ReceiveData(0, buff0, size/2);
|
||||
length += zmqsocket0->ReceiveData(0, buff1, size/2);
|
||||
length += zmqsocket1->ReceiveData(0, buff1, size/2);
|
||||
|
||||
irun=fileindex0;
|
||||
sprintf(ofname,"%s_%d.ph",filename0.c_str(),fileindex0);
|
||||
|
||||
@ -344,7 +360,7 @@ int main(int argc, char *argv[]){
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
buff0=buff;
|
||||
buff1=buff+48+1280*2;
|
||||
buff1=buff+offset*2+1280*2;
|
||||
|
||||
nf++;
|
||||
|
||||
|
@ -3,17 +3,19 @@
|
||||
|
||||
|
||||
#include "tiffIO.h"
|
||||
#include "etaInterpolationBase.h"
|
||||
//#include "etaInterpolationBase.h"
|
||||
#include "etaInterpolationPosXY.h"
|
||||
|
||||
class etaInterpolationAdaptiveBins : public etaInterpolationPosXY {
|
||||
|
||||
class etaInterpolationAdaptiveBins : public etaInterpolationBase{
|
||||
private:
|
||||
double calcDiff(double avg, double *hx, double *hy) {
|
||||
double calcDiff(double avg, float *hx, float *hy) {
|
||||
double p_tot=0;
|
||||
double diff=0;
|
||||
double bsize=1./nSubPixels;
|
||||
|
||||
for (int ipx=0; ipx=nSubPixels; ipx++) {
|
||||
for (int ipy=0; ipy=nSubPixels; ipy++) {
|
||||
for (int ipx=0; ipx<nSubPixels; ipx++) {
|
||||
for (int ipy=0; ipy<nSubPixels; ipy++) {
|
||||
p_tot=0;
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
@ -23,15 +25,19 @@ class etaInterpolationAdaptiveBins : public etaInterpolationBase{
|
||||
}
|
||||
}
|
||||
|
||||
cout << p_tot << " \t ";
|
||||
|
||||
|
||||
|
||||
diff+=(p_tot-avg)*(p_tot-avg);
|
||||
|
||||
}
|
||||
cout << "\n";
|
||||
}
|
||||
return diff;
|
||||
|
||||
}
|
||||
|
||||
void iterate(double *newhhx, double *newhhy) {
|
||||
void iterate(float *newhhx, float *newhhy) {
|
||||
|
||||
double bsize=1./nSubPixels;
|
||||
|
||||
@ -42,55 +48,71 @@ class etaInterpolationAdaptiveBins : public etaInterpolationBase{
|
||||
|
||||
double tot_eta_x=0;
|
||||
double tot_eta_y=0;
|
||||
for (int ipy=0; ipy=nSubPixels; ipy++) {
|
||||
for (int ipy=0; ipy<nSubPixels; ipy++) {
|
||||
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
if ( hhy[ibx+iby*nbeta]>=((ipy)*bsize) && hhy[ibx+iby*nbeta]<((ipy+1)*bsize)) {
|
||||
hx[ibx]+=heta[ibx+iby*nbeta];
|
||||
}
|
||||
if ( hhx[ibx+iby*nbeta]>=((ipy)*bsize) && hhx[ibx+iby*nbeta]<((ipy+1)*bsize)) {
|
||||
hy[iby]+=heta[ibx+iby*nbeta];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
hix[0]=hx[0];
|
||||
hiy[0]=hy[0];
|
||||
for (int ib=1; ib<nbeta; ib++) {
|
||||
hix[ib]=hix[ib-1]+hx[ib];
|
||||
hiy[ib]=hiy[ib-1]+hy[ib];
|
||||
}
|
||||
tot_eta_x=hix[nbeta-1];
|
||||
tot_eta_y=hiy[nbeta-1];
|
||||
|
||||
for (int ipy=0; ipy=nSubPixels; ipy++) {
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
|
||||
if ( hhy[ibx+iby*nbeta]>=((ipy)*bsize) && hhy[ibx+iby*nbeta]<((ipy+1)*bsize)) {
|
||||
newhhx[ibx+iby*nbeta]=hix[ibx]/((double)tot_eta_x);
|
||||
}
|
||||
if ( hhx[ibx+iby*nbeta]>=((ipy)*bsize) && hhx[ibx+iby*nbeta]<((ipy+1)*bsize)) {
|
||||
newhhy[ibx+iby*nbeta]=hiy[iby]/((double)tot_eta_y);
|
||||
}
|
||||
}
|
||||
hx[ibx]=0;
|
||||
hy[ibx]=0;
|
||||
}
|
||||
|
||||
tot_eta_x=0;
|
||||
tot_eta_y=0;
|
||||
// cout << ipy << " " << ((ipy)*bsize) << " " << ((ipy+1)*bsize) << endl;
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
|
||||
if (hhy[ibx+iby*nbeta]>=((ipy)*bsize) && hhy[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
|
||||
hx[ibx]+=heta[ibx+iby*nbeta];
|
||||
tot_eta_x+=heta[ibx+iby*nbeta];
|
||||
}
|
||||
|
||||
|
||||
if (hhx[ibx+iby*nbeta]>=((ipy)*bsize) && hhx[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
|
||||
hy[iby]+=heta[ibx+iby*nbeta];
|
||||
tot_eta_y+=heta[ibx+iby*nbeta];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hix[0]=hx[0];
|
||||
hiy[0]=hy[0];
|
||||
for (int ib=1; ib<nbeta; ib++) {
|
||||
hix[ib]=hix[ib-1]+hx[ib];
|
||||
hiy[ib]=hiy[ib-1]+hy[ib];
|
||||
}
|
||||
// tot_eta_x=hix[nbeta-1];
|
||||
// tot_eta_y=hiy[nbeta-1];
|
||||
/* cout << "ipx " << ipy << " x: " << tot_eta_x << " " << hix[10]<< " " << hix[nbeta-1] << endl; */
|
||||
/* cout << "ipy " << ipy << " y: " << tot_eta_y << " " << hiy[10]<< " " << hiy[nbeta-1] << endl; */
|
||||
|
||||
// for (int ipy=0; ipy<nSubPixels; ipy++) {
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
|
||||
if ( hhy[ibx+iby*nbeta]>=((ipy)*bsize) && hhy[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
|
||||
newhhx[ibx+iby*nbeta]=hix[ibx]/((double)tot_eta_x);
|
||||
if (newhhx[ibx+iby*nbeta]>1) cout << "***"<< ibx << " " << iby << newhhx[ibx+iby*nbeta] << endl;
|
||||
// if (ipy==3 && ibx==10) cout << newhhx[ibx+iby*nbeta] << " " << hix[ibx] << " " << ibx+iby*nbeta << endl;
|
||||
}
|
||||
if (hhx[ibx+iby*nbeta]>=((ipy)*bsize) && hhx[ibx+iby*nbeta]<=((ipy+1)*bsize)) {
|
||||
newhhy[ibx+iby*nbeta]=hiy[iby]/((double)tot_eta_y);
|
||||
if (newhhy[ibx+iby*nbeta]>1) cout << "***"<< ibx << " " << iby << newhhy[ibx+iby*nbeta] << endl;
|
||||
// if (ipy==3 && iby==10) cout << newhhy[ibx+iby*nbeta] << " " << hiy[iby] << " " << ibx+iby*nbeta << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
etaInterpolationAdaptiveBins(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax){};
|
||||
etaInterpolationAdaptiveBins(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationPosXY(nx,ny,ns, nb, emin,emax){};
|
||||
|
||||
etaInterpolationAdaptiveBins(etaInterpolationAdaptiveBins *orig): etaInterpolationBase(orig){};
|
||||
etaInterpolationAdaptiveBins(etaInterpolationAdaptiveBins *orig): etaInterpolationPosXY(orig){};
|
||||
|
||||
virtual etaInterpolationAdaptiveBins* Clone() {
|
||||
|
||||
@ -103,7 +125,7 @@ class etaInterpolationAdaptiveBins : public etaInterpolationBase{
|
||||
virtual void prepareInterpolation(int &ok)
|
||||
{
|
||||
ok=1;
|
||||
|
||||
cout << "Adaptive bins" << endl;
|
||||
|
||||
///*Eta Distribution Rebinning*///
|
||||
double bsize=1./nSubPixels; //precision
|
||||
@ -113,7 +135,6 @@ class etaInterpolationAdaptiveBins : public etaInterpolationBase{
|
||||
double tot_eta_y=0;
|
||||
for (int ip=0; ip<nbeta*nbeta; ip++)
|
||||
tot_eta+=heta[ip];
|
||||
cout << "total eta entries is :"<< tot_eta << endl;
|
||||
if (tot_eta<=0) {ok=0; return;};
|
||||
|
||||
|
||||
@ -125,41 +146,82 @@ class etaInterpolationAdaptiveBins : public etaInterpolationBase{
|
||||
|
||||
|
||||
/** initialize distribution to linear interpolation */
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int ib=0; ib<nbeta; ib++) {
|
||||
hhx[ibx+ib*nbeta]=((float)ibx)/((float)nbeta);
|
||||
hhy[ibx+ib*nbeta]=((float)ibx)/((float)nbeta);
|
||||
}
|
||||
}
|
||||
// for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
// for (int ib=0; ib<nbeta; ib++) {
|
||||
// hhx[ibx+ib*nbeta]=((float)ibx)/((float)nbeta);
|
||||
// hhy[ibx+ib*nbeta]=((float)ib)/((float)nbeta);
|
||||
// }
|
||||
// }
|
||||
|
||||
int nint=10;
|
||||
etaInterpolationPosXY::prepareInterpolation(ok);
|
||||
|
||||
double thr=1./((double)/nSubPixels);
|
||||
double avg=tot_eta/((double)(nSubPixels*nSubPixels));
|
||||
#ifdef SAVE_ALL
|
||||
|
||||
char tit[10000];
|
||||
float *etah=new float[nbeta*nbeta];
|
||||
int etabins=nbeta;
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
|
||||
etah[ii]=hhx[ii];
|
||||
}
|
||||
sprintf(tit,"/scratch/start_hhx.tiff");
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
etah[ii]=hhy[ii];
|
||||
}
|
||||
sprintf(tit,"/scratch/start_hhy.tiff");
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
|
||||
#endif
|
||||
int nint=1000;
|
||||
|
||||
double thr=1./((double)nSubPixels);
|
||||
double avg=tot_eta/((double)(nSubPixels*nSubPixels));
|
||||
cout << "total eta entries is :"<< tot_eta << " avg: "<< avg << endl;
|
||||
cout << "Start " << endl;
|
||||
double old_diff=calcDiff(avg, hhx, hhy), new_diff=old_diff+1;
|
||||
cout << " diff= " << new_diff << endl;
|
||||
|
||||
|
||||
int iint=0;
|
||||
double newhhx=new double[nbeta*nbeta]; //profile x
|
||||
double newhhy=new double[nbeta*nbeta]; //profile y
|
||||
float *newhhx=new float[nbeta*nbeta]; //profile x
|
||||
float *newhhy=new float[nbeta*nbeta]; //profile y
|
||||
while (iint<nint) {
|
||||
|
||||
|
||||
cout << "Iteration " << iint << endl;
|
||||
iterate(newhhx,newhhy);
|
||||
new_diff=calcDiff(avg, newhhx, newhhy);
|
||||
if (new_diff<old_diff) {
|
||||
cout << " diff= " << new_diff << endl;
|
||||
#ifdef SAVE_ALL
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
etah[ii]=newhhx[ii];
|
||||
if (etah[ii]>1 || etah[ii]<0 ) cout << "***"<< ii << etah[ii] << endl;
|
||||
|
||||
}
|
||||
sprintf(tit,"/scratch/neweta_hhx_%d.tiff",iint);
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
etah[ii]=newhhy[ii];
|
||||
if (etah[ii]>1 || etah[ii]<0 ) cout << "***"<< ii << etah[ii] << endl;
|
||||
}
|
||||
sprintf(tit,"/scratch/neweta_hhy_%d.tiff",iint);
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
#endif
|
||||
// if (new_diff<old_diff) {
|
||||
delete [] hhx;
|
||||
delete [] hhy;
|
||||
hhx=newhhx;
|
||||
hhy=newhhy;
|
||||
newhhx=new double[nbeta*nbeta]; //profile x
|
||||
newhhy=new double[nbeta*nbeta]; //profile y
|
||||
newhhx=new float[nbeta*nbeta]; //profile x
|
||||
newhhy=new float[nbeta*nbeta]; //profile y
|
||||
old_diff=new_diff;
|
||||
} else {
|
||||
cout << "Difference not decreasing after "<< iint << " iterations (" << old_diff << " < " << new_diff << ")"<< endl;
|
||||
break;
|
||||
}
|
||||
// } /* else { */
|
||||
/* cout << "Difference not decreasing after "<< iint << " iterations (" << old_diff << " < " << new_diff << ")"<< endl; */
|
||||
/* break; */
|
||||
/* } */
|
||||
|
||||
iint++;
|
||||
}
|
||||
@ -170,10 +232,7 @@ class etaInterpolationAdaptiveBins : public etaInterpolationBase{
|
||||
|
||||
|
||||
#ifdef SAVE_ALL
|
||||
char tit[10000];
|
||||
|
||||
float *etah=new float[nbeta*nbeta];
|
||||
int etabins=nbeta;
|
||||
|
||||
for (int ii=0; ii<etabins*etabins; ii++) {
|
||||
etah[ii]=hhx[ii];
|
||||
@ -193,7 +252,7 @@ class etaInterpolationAdaptiveBins : public etaInterpolationBase{
|
||||
sprintf(tit,"/scratch/eta_%d.tiff",id);
|
||||
WriteToTiff(etah, tit, etabins, etabins);
|
||||
delete [] etah;
|
||||
#endif
|
||||
#endif
|
||||
return ;
|
||||
}
|
||||
|
||||
|
@ -285,25 +285,21 @@ float *gethhx()
|
||||
switch (corner)
|
||||
{
|
||||
case TOP_LEFT:
|
||||
dX=-1.;//.99;
|
||||
dY=0;//+1.;//.99;
|
||||
//etay=1-etay;
|
||||
dX=-1.;
|
||||
dY=0;
|
||||
break;
|
||||
case TOP_RIGHT:
|
||||
;
|
||||
dX=0;//+1.;//.99;
|
||||
dY=0;//+1.;//.99;
|
||||
dX=0;
|
||||
dY=0;
|
||||
break;
|
||||
case BOTTOM_LEFT:
|
||||
//etax=1-etax;
|
||||
//etay=1-etay;
|
||||
dX=-1.;//99;
|
||||
dY=-1.;//.99;
|
||||
dX=-1.;
|
||||
dY=-1.;
|
||||
break;
|
||||
case BOTTOM_RIGHT:
|
||||
//etay=1-etay;
|
||||
dX=0;//1.;//+.99;
|
||||
dY=-1.;//-.99;
|
||||
dX=0;
|
||||
dY=-1.;
|
||||
break;
|
||||
default:
|
||||
cout << "bad quadrant" << endl;
|
||||
@ -353,16 +349,9 @@ float *gethhx()
|
||||
ypos_eta=0.5*dY+0.25;
|
||||
}
|
||||
|
||||
// int_x=((double)x) + 0.5*dX + xpos_eta;
|
||||
// int_y=((double)y) + 0.5*dY + ypos_eta;
|
||||
int_x=((double)x) + xpos_eta;
|
||||
int_y=((double)y) + ypos_eta;
|
||||
/* if (int_x<x-0.5 || int_y<y-0.5 ) { */
|
||||
/* // cout << "***"<< x <<" " << y << " " << int_x << " " << int_y << endl; */
|
||||
/* cout << corner << " X "<< x << " " << etax << " " << xpos_eta << " " << int_x <<" Y "<< y << " " << etay << " " << ypos_eta << " " <<int_y << endl; */
|
||||
/* } */
|
||||
|
||||
//return 1;
|
||||
int_x=((double)x) + xpos_eta+0.5;
|
||||
int_y=((double)y) + ypos_eta+0.5;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,10 @@
|
||||
|
||||
#CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
|
||||
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/
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/
|
||||
#LIBHDF5=
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff
|
||||
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff
|
||||
#-L$(ZMQLIB) -lzmq
|
||||
#-L../../bin
|
||||
MAIN=moench03ClusterFinder.cpp
|
||||
@ -17,17 +16,18 @@ all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation
|
||||
|
||||
|
||||
moenchClusterFinder: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
|
||||
g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DOLDDATA
|
||||
|
||||
moenchMakeEta: moench03MakeEta.cpp $(INCS) clean
|
||||
g++ -o moenchMakeEta moench03MakeEta.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
|
||||
g++ -o moenchMakeEta moench03MakeEta.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
moenchInterpolation: moench03Interpolation.cpp $(INCS) clean
|
||||
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
|
||||
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
moenchNoInterpolation: moench03NoInterpolation.cpp $(INCS) clean
|
||||
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
|
||||
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
clean:
|
||||
rm -f moenchClusterFinder moenchMakeEta
|
||||
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation
|
||||
|
||||
|
||||
|
@ -5,9 +5,9 @@
|
||||
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
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -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
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff
|
||||
|
||||
MAIN=tiff_to_th2f.cpp
|
||||
|
||||
@ -18,7 +18,7 @@ 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
|
||||
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
|
||||
|
@ -1,8 +1,18 @@
|
||||
//#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
#ifdef NEWRECEIVER
|
||||
#include "moench03T1ReceiverDataNew.h"
|
||||
#endif
|
||||
#ifdef CSAXS_FP
|
||||
#include "moench03T1ReceiverData.h"
|
||||
#endif
|
||||
#ifdef OLDDATA
|
||||
#include "moench03Ctb10GbT1Data.h"
|
||||
#endif
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
@ -24,12 +34,13 @@ using namespace std;
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
if (argc<7) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax pedfname" << endl;
|
||||
if (argc<6) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " << endl;
|
||||
return 1;
|
||||
}
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=20;
|
||||
int nthreads=8;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
@ -42,11 +53,30 @@ int main(int argc, char *argv[]) {
|
||||
int ok;
|
||||
int iprog=0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef NEWRECEIVER
|
||||
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
|
||||
cout << "RECEIVER DATA WITH ONE HEADER!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef CSAXS_FP
|
||||
moench03T1ReceiverData *decoder=new moench03T1ReceiverData();
|
||||
cout << "RECEIVER DATA WITH ALL HEADERS!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef OLDDATA
|
||||
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
|
||||
cout << "OLD RECEIVER DATA!"<<endl;
|
||||
#endif
|
||||
|
||||
|
||||
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
|
||||
// char tit[10000];
|
||||
|
||||
cout << "filter " << endl;
|
||||
|
||||
|
||||
|
||||
@ -80,7 +110,7 @@ int main(int argc, char *argv[]) {
|
||||
char outfname[10000];
|
||||
char imgfname[10000];
|
||||
char pedfname[10000];
|
||||
strcpy(pedfname,argv[6]);
|
||||
// strcpy(pedfname,argv[6]);
|
||||
char fn[10000];
|
||||
|
||||
std::time_t end_time;
|
||||
@ -89,52 +119,52 @@ int main(int argc, char *argv[]) {
|
||||
cout << "input directory is " << indir << endl;
|
||||
cout << "output directory is " << outdir << endl;
|
||||
cout << "fileformat is " << fformat << endl;
|
||||
cout << "pedestal file 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;
|
||||
// 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);
|
||||
// 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);
|
||||
// // //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;
|
||||
// // cout << outfname << endl;
|
||||
|
||||
// filter->writeImage(outfname);
|
||||
// //mt->clearImage();
|
||||
} else
|
||||
cout << "Could not open "<< pedfname << " for reading " << 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;
|
||||
// // 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;
|
||||
|
||||
|
||||
|
||||
@ -149,11 +179,12 @@ filter->setFrameMode(eFrame);
|
||||
|
||||
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
cout << "mt " << endl;
|
||||
|
||||
int ifr=0;
|
||||
// //loop on files
|
||||
@ -165,37 +196,37 @@ filter->setFrameMode(eFrame);
|
||||
|
||||
|
||||
|
||||
for (int irun=runmin; irun<runmin+5; irun++) {
|
||||
sprintf(fn,fformat,irun);
|
||||
sprintf(fname,"%s/%s.raw",indir,fn);
|
||||
// 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);
|
||||
// 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();
|
||||
// }
|
||||
// // cout << "--" << endl;
|
||||
// filebin.close();
|
||||
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
mt->clearImage();
|
||||
// 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);
|
||||
@ -218,18 +249,19 @@ filter->setFrameMode(eFrame);
|
||||
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);
|
||||
mt->pushData(buff);
|
||||
// // //pop
|
||||
mt->nextThread();
|
||||
mt->nextThread();
|
||||
// // // cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
mt->popFree(buff);
|
||||
ff=-1;
|
||||
}
|
||||
// cout << "--" << endl;
|
||||
cout << "--" << endl;
|
||||
filebin.close();
|
||||
// //close file
|
||||
// //join threads
|
||||
|
@ -5,8 +5,8 @@
|
||||
#include "moench03T1ZmqData.h"
|
||||
#include "single_photon_hit.h"
|
||||
|
||||
#include "etaInterpolationPosXY.h"
|
||||
|
||||
// #include "etaInterpolationPosXY.h"
|
||||
#include "etaInterpolationAdaptiveBins.h"
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
@ -43,9 +43,13 @@ int main(int argc, char *argv[]) {
|
||||
FILE *f=NULL;
|
||||
|
||||
single_photon_hit cl(3,3);
|
||||
etaInterpolationPosXY *interp=new etaInterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
// etaInterpolationPosXY *interp=new etaInterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
etaInterpolationAdaptiveBins *interp=new etaInterpolationAdaptiveBins (NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
//#ifndef FF
|
||||
cout << "read ff " << argv[2] << endl;
|
||||
interp->readFlatField(argv[2]);
|
||||
interp->prepareInterpolation(ok);
|
||||
//#endif
|
||||
|
||||
int *img;
|
||||
float *totimg=new float[NC*NR*nsubpix*nsubpix];
|
||||
@ -133,7 +137,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
cout << "writing eta!" << endl;
|
||||
WriteToTiff(ffimg, outfname,NC*nsubpix,NR*nsubpix);
|
||||
|
||||
|
||||
|
@ -1,5 +1,10 @@
|
||||
#include "../single_photon_hit.h"
|
||||
//#include "etaVEL/etaInterpolationPosXY.h"
|
||||
#include <TH1F.h>
|
||||
#include <TH2F.h>
|
||||
#include <TCanvas.h>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
TH2F *readClusters(char *fname, int nx, int ny, TH2F *h2=NULL) {
|
||||
FILE *f=fopen(fname,"r");
|
||||
@ -13,21 +18,21 @@ TH2F *readClusters(char *fname, int nx, int ny, TH2F *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);
|
||||
TH1F *hf=new TH1F("hf","hf",1000,0,3000000);
|
||||
TH1F *hf=new TH1F("hf","hf",1000,0,10E6);
|
||||
//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);
|
||||
TH1F *hsp1=new TH1F("hsp1",fname,500,0,2000);
|
||||
TH1F *hsp=new TH1F("hsp",fname,500,0,10000);
|
||||
// TH1F *hsp1=new TH1F("hsp1",fname,500,0,10000);
|
||||
// TH1F *hsp2=new TH1F("hsp2",fname,500,0,1000);
|
||||
// TH1F *hsp3=new TH1F("hsp3",fname,500,0,1000);
|
||||
hsp1->SetLineColor(2);
|
||||
// hsp1->SetLineColor(2);
|
||||
// hsp2->SetLineColor(3);
|
||||
// hsp3->SetLineColor(4);
|
||||
TCanvas *c=new TCanvas();
|
||||
c->SetLogz(kTRUE);
|
||||
h2->Draw("colz");
|
||||
TCanvas *c1=new TCanvas();
|
||||
hsp->Draw();
|
||||
hsp1->Draw("same");
|
||||
c1->SetLogy(kTRUE);
|
||||
// hsp1->Draw("same");
|
||||
// hsp2->Draw("same");
|
||||
// hsp3->Draw("same");
|
||||
TCanvas *c2=new TCanvas();
|
||||
@ -40,6 +45,8 @@ TH2F *readClusters(char *fname, int nx, int ny, TH2F *h2=NULL) {
|
||||
double phw=340, phs=62;
|
||||
int f0=-1;
|
||||
double tl, bl, tr, br, qt;
|
||||
int iimage=0;
|
||||
|
||||
while (cl.read(f)) {
|
||||
//cl.get_pixel(x1, y1);
|
||||
//cout << cl.iframe << " " << cl.x << " " << cl.y << endl;
|
||||
@ -64,7 +71,6 @@ TH2F *readClusters(char *fname, int nx, int ny, TH2F *h2=NULL) {
|
||||
// if (iy>0) top+=cl.get_data(ix,iy);
|
||||
|
||||
}
|
||||
|
||||
qt=bl;
|
||||
if (br>qt) qt=br;
|
||||
if (tl>qt) qt=tl;
|
||||
@ -75,22 +81,22 @@ TH2F *readClusters(char *fname, int nx, int ny, TH2F *h2=NULL) {
|
||||
//max at 340
|
||||
//if (tot>200) {
|
||||
w=1;
|
||||
|
||||
if (qt>1000) {
|
||||
if (qt/tot>0.8 && qt/tot<1.2){
|
||||
if (f0<0)
|
||||
f0=cl.iframe;
|
||||
hf->Fill(cl.iframe-f0);
|
||||
if (qt>540) w++;
|
||||
if (qt>820) w++;
|
||||
// if (qt>540) w++;
|
||||
// if (qt>820) w++;
|
||||
//(tot+3.5*phs)/phw;
|
||||
//} else
|
||||
//w=0;
|
||||
// if (w) {
|
||||
// if (cl.y<350) {
|
||||
// if (cl.y<100 || cl.y>300) {
|
||||
if (cl.x>150 && cl.x<250 && cl.y>200 && cl.y<250)
|
||||
hsp1->Fill(qt);
|
||||
else
|
||||
// if (cl.x>150 && cl.x<250 && cl.y>200 && cl.y<250)
|
||||
// hsp1->Fill(qt);
|
||||
// else
|
||||
hsp->Fill(qt);
|
||||
|
||||
// hsp2->Fill(cl.get_data(0,0));
|
||||
@ -122,10 +128,11 @@ TH2F *readClusters(char *fname, int nx, int ny, TH2F *h2=NULL) {
|
||||
c2->Modified();;
|
||||
c2->Update();
|
||||
}
|
||||
|
||||
// if (iph>1E7)
|
||||
// break;
|
||||
//}
|
||||
// if (iph>0.5E7) break;
|
||||
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
// hff->Scale(hff->GetNbinsX()*hff->GetNbinsY()/hff->Integral());
|
||||
|
@ -447,7 +447,7 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
|
||||
|
||||
(clusters+nph)->rms=getPedestalRMS(ix,iy);
|
||||
|
||||
cluster=clusters+nph;
|
||||
|
||||
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user