Zmq communication uses additional headers, moench processing fixed

This commit is contained in:
bergamaschi 2018-09-11 17:05:11 +02:00
parent 83600fcb15
commit f288390255
26 changed files with 1826 additions and 868 deletions

View File

@ -0,0 +1,61 @@
detsizechan 2560 1
hostname bchip074+bchip075+
#replace my_installation_path
settingsdir /my_installation_path/slsDetectorPackage/settingsdir/gotthard
caldir /my_installation_path/slsDetectorPackage/settingsdir/gotthard
0:extsig:0 trigger_in_rising_edge
0:rx_tcpport 1954
0:rx_udpport 50001
0:vhighvoltage 0
1:extsig:0 trigger_in_rising_edge
1:rx_tcpport 1955
1:rx_udpport 50002
#1:detectorip 10.1.1.52
1:vhighvoltage 0
##############################################################################
#########
######### Uncomment this part to use the gotthard25umZmq process
#########
##############################################################################
# #replace my_receiver_hostname with the hostname of IP of the machine where the receiver runs
#0:rx_zmqip my_receiver_hostname
#0:rx_zmqport 30003
# #replace my_client_hostname with the hostname of IP of the machine where the client/GUI or softIOC runs
#0:zmqip my_client_hostname
#0:zmqport 40003
# #replace my_receiver_hostname with the hostname of IP of the machine where the receiver runs
#1:rx_zmqip my_receiver_hostname
#1:rx_zmqport 30004
# #replace my_client_hostname with the hostname of IP of the machine where the client/GUI or softIOC runs
#1:zmqip my_client_hostname
#1:zmqport 40004
##############################################################################
#########
######### until here
#########
##############################################################################
r_readfreq 1
rx_datastream 1
#replace my_receiver_hostname with the hostname of 1Gb IP of the machine where the receiver runs
rx_hostname my_receiver_hostname
rx_datastream 1
outdir /tmp/
angconv none
threaded 1
settings veryhighgain
exptime 0.000005
period 0.0001
vhighvoltage 90

View File

@ -0,0 +1,61 @@
detsizechan 2560 1
hostname bchip074+bchip075+
#replace my_installation_path
settingsdir /my_installation_path/slsDetectorPackage/settingsdir/gotthard
caldir /my_installation_path/slsDetectorPackage/settingsdir/gotthard
0:extsig:0 trigger_in_rising_edge
0:rx_tcpport 1954
0:rx_udpport 50001
0:vhighvoltage 0
1:extsig:0 trigger_in_rising_edge
1:rx_tcpport 1955
1:rx_udpport 50002
#1:detectorip 10.1.1.52
1:vhighvoltage 0
##############################################################################
#########
######### Uncomment this part to use the gotthard25umZmq process
#########
##############################################################################
# #replace my_receiver_hostname with the hostname of IP of the machine where the receiver runs
#0:rx_zmqip my_receiver_hostname
#0:rx_zmqport 30003
# #replace my_client_hostname with the hostname of IP of the machine where the client/GUI or softIOC runs
#0:zmqip my_client_hostname
#0:zmqport 40003
# #replace my_receiver_hostname with the hostname of IP of the machine where the receiver runs
#1:rx_zmqip my_receiver_hostname
#1:rx_zmqport 30004
# #replace my_client_hostname with the hostname of IP of the machine where the client/GUI or softIOC runs
#1:zmqip my_client_hostname
#1:zmqport 40004
##############################################################################
#########
######### until here
#########
##############################################################################
r_readfreq 1
rx_datastream 1
#replace my_receiver_hostname with the hostname of 1Gb IP of the machine where the receiver runs
rx_hostname my_receiver_hostname
rx_datastream 1
outdir /tmp/
angconv none
threaded 1
settings veryhighgain
exptime 0.000005
period 0.0001
vhighvoltage 90

View File

@ -0,0 +1,14 @@
Turn on the two receivers:
slsReceiver --rx_tcpport 1954 &
slsReceiver --rx_tcpport 1955 &
Switch on the photon conversion on the receiver machine (replace my_receiver_hostname):
gotthard25umZmq my_receiver_hostname 30003 my_receiver_hostname 40003 &
Run the configuration file:
sls_detector_put config bchip2modules.config
Start your measurements using the command line, the slsDetectorGui or the EPICS driver

View File

@ -29,6 +29,10 @@ using namespace std;
enum to define the flags of the data set, which are needed to seect the type of processing it should undergo: frame, pedestal, flat
*/
enum frameMode { eFrame, ePedestal, eFlat };
/**
enum to define the detector mode
*/
enum detectorMode { eAnalog, ePhotonCounting, eInterpolating };
#endif
@ -386,6 +390,7 @@ template <class dataType> class analogDetector {
for (int ix=0; ix<nx; ix++) {
for (int iy=0; iy<ny; iy++) {
ped[iy*nx+ix]=stat[iy][ix].getPedestal();
//cout << ped[iy*nx+ix] << " " ;
}
}
return ped;
@ -682,9 +687,10 @@ template <class dataType> class analogDetector {
\param data pointer to the data
*/
virtual void addToPedestal(char *data, int cm=0) {
// cout << "add to pedestal " << endl;
newFrame();
if (cmSub) {
@ -696,7 +702,8 @@ template <class dataType> class analogDetector {
for (int ix=xmin; ix<xmax; ix++) {
for (int iy=ymin; iy<ymax; iy++) {
addToPedestal(data,ix,iy,1);
//if (ix==10 && iy==10)
// cout <<ix << " " << iy << " " << getPedestal(ix,iy)<< endl;
#ifdef ROOTSPECTRUM
subtractPedestal(data,ix,iy,cm);
#endif
@ -1039,10 +1046,11 @@ template <class dataType> class analogDetector {
virtual void processData(char *data,int *val=NULL) {
switch(fMode) {
case ePedestal:
// cout << "ped " << endl;
//cout << "analog ped " << endl;
addToPedestal(data);
break;
default:
// cout << "analog " << endl;
//subtractPedestal(data);
getNPhotons(data);
}
@ -1062,6 +1070,21 @@ template <class dataType> class analogDetector {
*/
frameMode getFrameMode() {return fMode;};
//enum detectorMode { eAnalog, ePhotonCounting, eInterpolating };
/** sets the current detector mode for the detector
\param f detector mode to be set
\returns current detector mode
*/
detectorMode setDetectorMode(detectorMode f) {dMode=f; return dMode;};
/** gets the current detector mode for the detector
\returns current detector mode
*/
detectorMode getDetectorMode() {return dMode;};
/** sets file pointer where to write the clusters to
\param f file pointer
\returns current file pointer
@ -1093,6 +1116,7 @@ FILE *getFilePointer(){return myFile;};
double thr; /**< threshold to be used for conversion into number of photons */
// int nSigma; /**< number of sigma to be used for conversion into number of photons if threshold is undefined */
frameMode fMode; /**< current detector frame mode */
detectorMode dMode; /**< current detector frame mode */
FILE *myFile; /**< file pointer to write to */
#ifdef ROOTSPECTRUM
TH2F *hs;

View File

@ -92,6 +92,14 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
};
/**
Returns the gain for the selected pixel (at the moemnt only 3rd supercolumn)
\param buff pointer to the dataset
\param ix x coordinate
\param iy y coordinate
\returns gain value
*/
int getGain(char *buff, int ix, int iy) {
int isample=iy*sc_width+iy;
if (ix<sc_width) return 0; //first supercolumn no gain switching - could return the static gain if wished

View File

@ -55,13 +55,11 @@ class interpolatingDetector : public singlePhotonDetector {
interpolatingDetector(interpolatingDetector *orig) : singlePhotonDetector(orig) {
if (orig->interp)
interp=(orig->interp)->Clone();
else
interp=orig->interp;
id=orig->id;
/* xmin=orig->xmin; */
/* xmax=orig->xmax; */
/* ymin=orig->ymin; */
/* ymax=orig->ymax; */
}
@ -72,26 +70,34 @@ class interpolatingDetector : public singlePhotonDetector {
virtual int setId(int i) {id=i; interp->setId(id); return id;};
virtual void prepareInterpolation(int &ok) {
cout << "*"<< endl;
#ifdef SAVE_ALL
char tit[1000];
sprintf(tit,"/scratch/ped_%d.tiff",id);
writePedestals(tit);
sprintf(tit,"/scratch/ped_rms_%d.tiff",id);
writePedestalRMS(tit);
if (gmap) {
sprintf(tit,"/scratch/gmap_%d.tiff",id);
writeGainMap(tit);
}
#endif
/* cout << "*"<< endl; */
/* #ifdef SAVE_ALL */
/* char tit[1000]; */
/* sprintf(tit,"/scratch/ped_%d.tiff",id); */
/* writePedestals(tit); */
/* sprintf(tit,"/scratch/ped_rms_%d.tiff",id); */
/* writePedestalRMS(tit); */
/* if (gmap) { */
/* sprintf(tit,"/scratch/gmap_%d.tiff",id); */
/* writeGainMap(tit); */
/* } */
/* #endif */
if (interp)
interp->prepareInterpolation(ok);
}
void clearImage() {if (interp) interp->clearInterpolatedImage(); else singlePhotonDetector::clearImage();};
void clearImage() {
if (interp) interp->clearInterpolatedImage();
else singlePhotonDetector::clearImage();
};
int getImageSize(int &nnx, int &nny, int &ns) {
if (interp) return interp->getImageSize(nnx, nny, ns);
else return analogDetector<uint16_t>::getImageSize(nnx, nny, ns);
};
int getImageSize(int &nnx, int &nny, int &ns) {if (interp) return interp->getImageSize(nnx, nny, ns); else return analogDetector<uint16_t>::getImageSize(nnx, nny, ns);};
#ifdef MYROOT1
virtual TH2F *getImage()
#endif
@ -146,365 +152,30 @@ class interpolatingDetector : public singlePhotonDetector {
return NULL;
}
int addFrame(char *data, int *ph=NULL, int ff=0) {
/* int addFrame(char *data, int *ph=NULL, int ff=0) { */
/* int nph=0; */
/* double val[ny][nx]; */
/* int cy=(clusterSizeY+1)/2; */
/* int cs=(clusterSize+1)/2; */
/* int ir, ic; */
/* double rms; */
/* double int_x,int_y, eta_x, eta_y; */
/* double max=0, tl=0, tr=0, bl=0,br=0, *v, vv; */
/* // cout << "********** Add frame "<< iframe << endl; */
/* if (ph==NULL) */
/* ph=image; */
/* if (iframe<nDark) { */
/* addToPedestal(data); */
/* return 0; */
/* } */
/* newFrame(); */
/* // cout << "********** Data "<< endl; */
/* for (int ix=xmin; ix<xmax; ix++) { */
/* for (int iy=ymin; iy<ymax; iy++) { */
int nph=0;
double val[ny][nx];
int cy=(clusterSizeY+1)/2;
int cs=(clusterSize+1)/2;
int ir, ic;
double rms;
double int_x,int_y, eta_x, eta_y;
double max=0, tl=0, tr=0, bl=0,br=0, *v, vv;
// cout << "********** Add frame "<< iframe << endl;
if (ph==NULL)
ph=image;
if (iframe<nDark) {
addToPedestal(data);
return 0;
}
newFrame();
// cout << "********** Data "<< endl;
for (int ix=xmin; ix<xmax; ix++) {
for (int iy=ymin; iy<ymax; iy++) {
max=0;
tl=0;
tr=0;
bl=0;
br=0;
tot=0;
quadTot=0;
quad=UNDEFINED_QUADRANT;
eventMask[iy][ix]=PEDESTAL;
rms=getPedestalRMS(ix,iy);
(clusters+nph)->rms=rms;
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) {
val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir);
}
v=&(val[iy+ir][ix+ic]);
tot+=*v;
if (ir<=0 && ic<=0)
bl+=*v;
if (ir<=0 && ic>=0)
br+=*v;
if (ir>=0 && ic<=0)
tl+=*v;
if (ir>=0 && ic>=0)
tr+=*v;
if (*v>max) {
max=*v;
}
if (ir==0 && ic==0) {
if (*v<-nSigma*rms)
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
}
}
}
if (bl>=br && bl>=tl && bl>=tr) {
(clusters+nph)->quad=BOTTOM_LEFT;
(clusters+nph)->quadTot=bl;
} else if (br>=bl && br>=tl && br>=tr) {
(clusters+nph)->quad=BOTTOM_RIGHT;
(clusters+nph)->quadTot=br;
} else if (tl>=br && tl>=bl && tl>=tr) {
(clusters+nph)->quad=TOP_LEFT;
(clusters+nph)->quadTot=tl;
} else if (tr>=bl && tr>=tl && tr>=br) {
(clusters+nph)->quad=TOP_RIGHT;
(clusters+nph)->quadTot=tr;
}
if (max>nSigma*rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*rms || ((clusters+nph)->quadTot)>sqrt(cy*cs)*nSigma*rms) {
if (val[iy][ix]>=max) {
eventMask[iy][ix]=PHOTON_MAX;
(clusters+nph)->tot=tot;
(clusters+nph)->x=ix;
(clusters+nph)->y=iy;
(clusters+nph)->iframe=det->getFrameNumber(data);
(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);
}
}
if (interp) {
if (ff) {
interp->addToFlatField((clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),eta_x, eta_y);
} else {
interp->getInterpolatedPosition(ix, iy, (clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),int_x, int_y);
interp->addToImage(int_x, int_y);
}
} else
image[ix+nx*iy]++;
nph++;
image[iy*nx+ix]++;
} else {
eventMask[iy][ix]=PHOTON;
}
} else if (eventMask[iy][ix]==PEDESTAL) {
addToPedestal(data,ix,iy);
}
}
}
nphFrame=nph;
nphTot+=nph;
//cout << nphFrame << endl;
// cout <<"**********************************"<< endl;
writeClusters();
return nphFrame;
};
/*********************************************************
int addFrame(char *data, int ff=0) {
double g=1;
single_photon_hit *cl;
single_photon_hit clust;
if (clusters)
cl=clusters;
else
cl=&clust;
int ccs=clusterSize;
int ccy=clusterSizeY;
double int_x,int_y, eta_x, eta_y;
int nph=0;
double rest[ny][nx];
int cy=(clusterSizeY+1)/2;
int cs=(clusterSize+1)/2;
int ir, ic;
double cc[2][2];
double max=0, tl=0, tr=0, bl=0,br=0, v, vv;
int xoff,yoff;
int skip=0;
// cout <<"fr"<< endl;
double tthr;
if (iframe<nDark) {
//cout << iframe << "+"<< nDark <<endl;
addToPedestal(data);
return 0;
}
newFrame();
// cout << xmin << " " << xmax << " " << ymin << " " << ymax << endl;
for (int ix=xmin; ix<xmax; ix++) {
for (int iy=ymin; iy<ymax; iy++) {
// for (int ix=clusterSize/2; ix<clusterSize/2-1; ix++) {
// for (int iy=clusterSizeY/2; iy<ny-clusterSizeY/2; iy++) {
// cout << ix << " " << iy << endl;
eventMask[iy][ix]=PEDESTAL;
tthr=nSigma*getPedestalRMS(ix,iy)/g;
if (ix==xmin || iy==ymin)
rest[iy][ix]=subtractPedestal(data,ix,iy);
max=0;
tl=0;
tr=0;
bl=0;
br=0;
tot=0;
quadTot=0;
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
if ((iy+ir)>=ymin && (iy+ir)<ymax && (ix+ic)>=xmin && (ix+ic)<xmax) {
//cluster->set_data(rest[iy+ir][ix+ic], ic, ir);
if (ir>=0 && ic>=0 )
rest[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir);
v=rest[iy+ir][ix+ic];//cluster->get_data(ic,ir);
tot+=v;
if (ir<=0 && ic<=0)
bl+=v;
if (ir<=0 && ic>=0)
br+=v;
if (ir>=0 && ic<=0)
tl+=v;
if (ir>=0 && ic>=0)
tr+=v;
if (v>max) {
max=v;
}
// if (ir==0 && ic==0) {
if (v>tthr) {
eventMask[iy][ix]=NEIGHBOUR;
}
//}
}
}
}
if (rest[iy][ix]<=-tthr) {
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
//if (cluster->get_data(0,0)>=max) {
} else if (max>tthr || tot>sqrt(ccy*ccs)*tthr || quadTot>sqrt(cy*cs)*tthr) {
if (rest[iy][ix]>=max) {
if (bl>=br && bl>=tl && bl>=tr) {
cl->quad=BOTTOM_LEFT;
cl->quadTot=bl;
} else if (br>=bl && br>=tl && br>=tr) {
cl->quad=BOTTOM_RIGHT;
cl->quadTot=br;
} else if (tl>=br && tl>=bl && tl>=tr) {
cl->quad=TOP_LEFT;
cl->quadTot=tl;
} else if (tr>=bl && tr>=tl && tr>=br) {
cl->quad=TOP_RIGHT;
cl->quadTot=tr;
}
eventMask[iy][ix]=PHOTON_MAX;
cl->tot=tot;
cl->x=ix;
cl->y=iy;
cl->ped=getPedestal(ix,iy, 0);
cl->rms=getPedestalRMS(ix,iy);
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
if ((iy+ir)>=ymin && (iy+ir)<ymax && (ix+ic)>=xmin && (ix+ic)<xmax) {
cl->set_data(rest[iy+ir][ix+ic],ic,ir);
}
}
}
if (interp) {
if (ff) {
#ifdef M015
if (iy>100)
#endif
interp->addToFlatField(cl->quadTot,cl->quad,cl->get_cluster(),eta_x, eta_y);
// if ((eta_x<0.1 || eta_x>0.9)&&(eta_y<0.1 || eta_y>0.9))
// cout << ix << " " << iy << " " << eta_x <<" " << eta_y << endl;
} else {
interp->getInterpolatedPosition(ix, iy, cl->quadTot,cl->quad,cl->get_cluster(),int_x, int_y);
interp->addToImage(int_x, int_y);
}
} else
image[ix+nx*iy]++;
nph++;
if (clusters) cl=(clusters+nph);
// rest[iy][ix]-=tthr;
} else
eventMask[iy][ix]=PHOTON;
//else if (thr<=0 ) {
//addToPedestal(data,ix,iy);
// }
}
if (eventMask[iy][ix]==PEDESTAL) {
addToPedestal(data,ix,iy);
}
}
}
return nph;
}
******************************************/
/* for (int ix=0; ix<nx; ix++) { */
/* for (int iy=0; iy<ny; iy++) { */
/* skip=0; */
/* max=0; */
/* tl=0; */
/* tr=0; */
@ -516,32 +187,21 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
/* eventMask[iy][ix]=PEDESTAL; */
/* rms=getPedestalRMS(ix,iy); */
/* (clusters+nph)->rms=rms; */
/* cl->rms=getPedestalRMS(ix,iy); */
/* //(clusters+nph)->rms=getPedestalRMS(ix,iy); */
/* // cout << iframe << " " << nph << " " << ix << " " << iy << endl; */
/* if (ix==0 || iy==0) */
/* val[iy][ix]=subtractPedestal(data,ix,iy); */
/* if (val[iy][ix]<-nSigma*cl->rms) { */
/* eventMask[iy][ix]=NEGATIVE_PEDESTAL; */
/* // cout << "neg ped" << endl; */
/* } else { */
/* 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) { */
/* if (ir>=0 && ic>=0) { */
/* if ((iy+ir)>=iy && (iy+ir)<ny && (ix+ic)>=ix && (ix+ic)<nx) { */
/* val[iy+ir][ix+ic]=subtractPedestal(data,ix+ic,iy+ir); */
/* eventMask[iy+ir][ix+ic]=PEDESTAL; */
/* } */
/* // cout << ir << " " << ic << " " << val[iy+ir][ix+ic] << endl; */
/* v=&(val[iy+ir][ix+ic]); */
/* // if (skip==0) { */
/* tot+=*v; */
/* if (ir<=0 && ic<=0) */
/* bl+=*v; */
@ -555,47 +215,47 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
/* max=*v; */
/* } */
/* if (ir==0 && ic==0) { */
/* if (*v<-nSigma*rms) */
/* eventMask[iy][ix]=NEGATIVE_PEDESTAL; */
/* } */
/* } */
/* } */
/* if (bl>=br && bl>=tl && bl>=tr) { */
/* cl->quad=BOTTOM_LEFT; */
/* cl->quadTot=bl; */
/* (clusters+nph)->quad=BOTTOM_LEFT; */
/* (clusters+nph)->quadTot=bl; */
/* } else if (br>=bl && br>=tl && br>=tr) { */
/* cl->quad=BOTTOM_RIGHT; */
/* cl->quadTot=br; */
/* (clusters+nph)->quad=BOTTOM_RIGHT; */
/* (clusters+nph)->quadTot=br; */
/* } else if (tl>=br && tl>=bl && tl>=tr) { */
/* cl->quad=TOP_LEFT; */
/* cl->quadTot=tl; */
/* (clusters+nph)->quad=TOP_LEFT; */
/* (clusters+nph)->quadTot=tl; */
/* } else if (tr>=bl && tr>=tl && tr>=br) { */
/* cl->quad=TOP_RIGHT; */
/* cl->quadTot=tr; */
/* (clusters+nph)->quad=TOP_RIGHT; */
/* (clusters+nph)->quadTot=tr; */
/* } */
/* if (max>nSigma*cl->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*cl->rms || (cl->quadTot)>sqrt(cy*cs)*nSigma*cl->rms) { */
/* if (max>nSigma*rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*rms || ((clusters+nph)->quadTot)>sqrt(cy*cs)*nSigma*rms) { */
/* if (val[iy][ix]>=max) { */
/* eventMask[iy][ix]=PHOTON_MAX; */
/* cl->tot=tot; */
/* cl->x=ix; */
/* cl->y=iy; */
/* cl->ped=getPedestal(ix,iy, 0); */
/* if (interp) { */
/* if (ff) { */
/* interp->addToFlatField(cl->quadTot,cl->quad,cl->get_cluster(),eta_x, eta_y); */
/* // if ((eta_x<0.1 || eta_x>0.9)&&(eta_y<0.1 || eta_y>0.9)) */
/* // cout << ix << " " << iy << " " << eta_x <<" " << eta_y << endl; */
/* } else { */
/* interp->getInterpolatedPosition(ix, iy, cl->quadTot,cl->quad,cl->get_cluster(),int_x, int_y); */
/* interp->addToImage(int_x, int_y); */
/* (clusters+nph)->tot=tot; */
/* (clusters+nph)->x=ix; */
/* (clusters+nph)->y=iy; */
/* (clusters+nph)->iframe=det->getFrameNumber(data); */
/* (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); */
/* } */
/* } */
/* } else */
/* image[ix+nx*iy]++; */
/* if (clusters) cl=(clusters+nph); */
/* nph++; */
/* image[iy*nx+ix]++; */
/* } else { */
/* eventMask[iy][ix]=PHOTON; */
@ -604,20 +264,37 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
/* addToPedestal(data,ix,iy); */
/* } */
/* } */
/* } */
/* } */
/* return nph; */
/* nphFrame=nph; */
/* nphTot+=nph; */
/* writeClusters(); */
/* return nphFrame; */
/* }; */
int addFrame(char *data, int *ph=NULL, int ff=0) {
singlePhotonDetector::processData(data,ph);
int nph=0;
double int_x, int_y;
double eta_x, eta_y;
if (interp) {
for (nph=0; nph<nphFrame; nph++) {
if (ff) {
interp->addToFlatField((clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),eta_x, eta_y);
} else {
interp->getInterpolatedPosition((clusters+nph)->x, (clusters+nph)->y, (clusters+nph)->quadTot,(clusters+nph)->quad,(clusters+nph)->get_cluster(),int_x, int_y);
interp->addToImage(int_x, int_y);
}
}
}
return nphFrame;
};
virtual void processData(char *data, int *val=NULL) {
if (interp){
@ -633,11 +310,12 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
}
} else
singlePhotonDetector::processData(data,val);
};
virtual char *getInterpolation(){return (char*)interp;};
virtual char *setInterpolation(char *ii){int ok; interp=(slsInterpolation*)ii; interp->prepareInterpolation(ok); return (char*)interp;};
protected:

View File

@ -0,0 +1,34 @@
#module add CBFlib/0.9.5
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 -O3
MAIN=moench03ClusterFinder.cpp
all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
moenchClusterFinder: moench03ClusterFinder.cpp $(INCS) clean
g++ -o moenchClusterFinder moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -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) $(LIBHDF5) $(LIBRARYCBF)
moenchNoInterpolation: moench03NoInterpolation.cpp $(INCS) clean
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
moenchPhotonCounter: moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchPhotonCounter moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER
moenchAnalog: moenchPhotonCounter.cpp $(INCS) clean
g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG
clean:
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog

View File

@ -5,13 +5,17 @@ LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
INCDIR=-I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/
LIBHDF5=
#-I../interpolations/etaVEL
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -lhdf5 -ltiff -L$(ZMQLIB) -L$(CBFLIBDIR)/lib/
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -lhdf5 -ltiff -L$(ZMQLIB) -L$(CBFLIBDIR)/lib/ -O3
#-L../../bin
#DESTDIR?=../bin
aaa: moenchZmqProcess
all: moenchZmqClusterFinder moenchZmqInterpolating moenchZmqAnalog
moenchZmqProcess: moenchZmqProcess.cpp $(INCS) clean
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ
moenchZmqInterpolating: $(MAIN) $(INCS) clean
g++ -o moenchZmqInterpolating moenchZmqInterpolating.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
@ -23,6 +27,6 @@ moenchZmqAnalog: $(MAIN) $(INCS) clean
g++ -o moenchZmqAnalog moenchZmqAnalog.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
clean:
rm -f moench03ZmqInterpolating moench03ZmqClusterFinder moenchZmqAnalog
rm -f moench03ZmqInterpolating moench03ZmqClusterFinder moenchZmqAnalog moenchZmqProcess

View File

@ -26,24 +26,45 @@ using namespace std;
#define XTALK
int main(int argc, char *argv[]) {
/**
* trial.o [socket ip] [starting port number] [outfname]
*
*/
#ifndef FF
if (argc<9) {
cout << "Wrong usage! Should be: "<< argv[0] << " infile " << " etafile outfile runmin runmax ns cmin cmax" << endl;
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile outfile runmin runmax ns cmin cmax" << endl;
return 1;
}
#endif
#ifdef FF
if (argc<7) {
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile runmin runmax cmin cmax" << endl;
return 1;
}
#endif
int iarg=4;
char infname[10000];
char fname[10000];
char outfname[10000];
int runmin=atoi(argv[4]);
int runmax=atoi(argv[5]);
int nsubpix=atoi(argv[6]);
float cmin=atof(argv[7]);
float cmax=atof(argv[8]);
#ifndef FF
iarg=4;
#endif
#ifdef FF
iarg=3;
#endif
int runmin=atoi(argv[iarg++]);
int runmax=atoi(argv[iarg++]);
cout << "Run min: " << runmin << endl;
cout << "Run max: " << runmax << endl;
int nsubpix=4;
#ifndef FF
nsubpix=atoi(argv[iarg++]);
cout << "Subpix: " << nsubpix << endl;
#endif
float cmin=atof(argv[iarg++]);
float cmax=atof(argv[iarg++]);
cout << "Energy min: " << cmin << endl;
cout << "Energy max: " << cmax << endl;
int etabins=1000;//nsubpix*2*100;
double etamin=-1, etamax=2;
@ -58,9 +79,6 @@ int main(int argc, char *argv[]) {
int ix, iy, isx, isy;
int nframes=0, lastframe=-1;
double d_x, d_y, res=5, xx, yy;
#ifdef MANYFILES
int ff=1000;
#endif
int nph=0, badph=0, totph=0;
FILE *f=NULL;
@ -72,32 +90,19 @@ int main(int argc, char *argv[]) {
single_photon_hit cl(3,3);
#endif
#ifdef XTALK
int old_val[3][3];
int new_val[3][3];
double xcorr=0.04;
// int ix=0;
#endif
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
eta3InterpolationPosXY *interp3=new eta3InterpolationPosXY(NC, NR, nsubpix, etabins, eta3min, eta3max);
noInterpolation *dummy=new noInterpolation(NC, NR, nsubpix);
noInterpolation *nointerp=new noInterpolation(NC, NR, nsubpix);
noInterpolation *mult=new noInterpolation(NC, NR, nsubpix);
//etaInterpolationAdaptiveBins *interp=new etaInterpolationAdaptiveBins (NC, NR, nsubpix, etabins, etamin, etamax);
//etaInterpolationRandomBins *interp=new etaInterpolationRandomBins (NC, NR, nsubpix, etabins, etamin, etamax);
//#ifndef FF
#ifndef FF
cout << "read ff " << argv[2] << endl;
sprintf(fname,"%s_eta2.tiff",argv[2]);
sprintf(fname,"%s",argv[2]);
interp->readFlatField(fname);
interp->prepareInterpolation(ok);
sprintf(fname,"%s_eta3.tiff",argv[2]);
interp3->readFlatField(fname);
interp3->prepareInterpolation(ok);
//#endif
#endif
#ifdef FF
cout << "Will write eta file " << argv[2] << endl;
#endif
int *img;
float *totimg=new float[NC*NR*nsubpix*nsubpix];
@ -110,20 +115,18 @@ int main(int argc, char *argv[]) {
}
}
}
#ifdef FF
float ff[nsubpix*nsubpix];
float *ffimg=new float[NC*NR*nsubpix*nsubpix];
float totff=0;
sprintf(outfname,argv[2]);
#endif
int irun;
for (irun=runmin; irun<runmax; irun++) {
sprintf(infname,argv[1],irun);
#ifndef MANYFILES
#ifndef FF
sprintf(outfname,argv[3],irun);
#endif
f=fopen(infname,"r");
if (f) {
cout << infname << endl;
@ -138,157 +141,44 @@ int main(int argc, char *argv[]) {
// f0=cl.iframe;
if (nframes==0) f0=lastframe;
nframes++;
#ifdef MANYFILES
if (nframes%ff==0) {
sprintf(outfname,argv[3],irun,nframes-ff);
cout << outfname << endl;
interp->writeInterpolatedImage(outfname);
interp->clearInterpolatedImage();
}
#endif
}
#ifdef XTALK
if ((cl.x+1)%25!=0) {
for (int ix=-1; ix<2; ix++) {
for (int iy=-1; iy<2; iy++) {
old_val[iy+1][ix+1]=cl.get_data(ix,iy);
if (ix>=0) {
new_val[iy+1][ix+1]=old_val[iy+1][ix+1]-old_val[iy+1][ix]*xcorr;
cl.set_data(new_val[iy+1][ix+1],ix,iy);
}
}
}
}
#endif
quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && totquad<cmax && quad<cmax) {
nph++;
// if (sum>200 && sum<580) {
// interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y);
#ifndef FF
interp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y);
interp->addToImage(int_x, int_y);
interp3->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int3_x, int3_y);
interp3->addToImage(int3_x, int3_y);
nointerp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),noint_x, noint_y);
nointerp->addToImage(noint_x, noint_y);
#endif
#ifdef FF
interp->addToFlatField(cl.get_cluster(), etax, etay);
#endif
d_x= (int_x-int3_x)*25.;
d_y= (int_y-int3_y)*25.;
dummy->calcEta(totquad, sDum, etax, etay);
xx=int_x;
yy=int_y;
if (etax<0.1 || etax>0.9) xx=int3_x;
if (etay<0.1 || etay>0.9) yy=int3_y;
dummy->addToImage(xx,yy);
if (d_x>res || d_x<-res || d_y>res || d_y<-res) {
badph++;
// cout << "delta (um): "<< d_x << " " << d_y << " " << cl.x << " " << cl.y << endl;
// cout << sum << " " << totquad << " " << etax << " "<< etay << endl;
// //cout<< int_x << " " << int_y << " " << int3_x << " " << int3_y << endl;
}
mult->addToImage(noint_x, noint_y);
if (nph%1000000==0) cout << nph << endl;
if (nph%100000000==0) {
sprintf(outfname,"%s_inteta2.tiff", argv[3]);
#ifndef FF
interp->writeInterpolatedImage(outfname);
sprintf(outfname,"%s_inteta3.tiff", argv[3]);
interp3->writeInterpolatedImage(outfname);
sprintf(outfname,"%s_mix.tiff", argv[3]);
dummy->writeInterpolatedImage(outfname);
sprintf(outfname,"%s_noint.tiff", argv[3]);
nointerp->writeInterpolatedImage(outfname);
sprintf(outfname,"%s_mult.tiff", argv[3]);
mult->writeInterpolatedImage(outfname);
#endif
#ifdef FF
interp->writeFlatField(outfname);
#endif
}
} else {
mult->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y);
for (int imult=0; imult<2.*sum/(cmax+cmin); imult++) mult->addToImage(int_x, int_y);
}
}
fclose(f);
#ifdef FF
img=interp->getInterpolatedImage();
for (isx=0; isx<nsubpix; isx++) {
for (isy=0; isy<nsubpix; isy++) {
ff[isy*nsubpix+isx]=0;
}
}
totff=0;
for (ix=0; ix<NC; ix++) {
for (iy=0; iy<NR-100; iy++) {
for (isx=0; isx<nsubpix; isx++) {
for (isy=0; isy<nsubpix; isy++) {
ff[isy*nsubpix+isx]+=img[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)];
}
}
}
}
for (isx=0; isx<nsubpix; isx++) {
for (isy=0; isy<nsubpix; isy++) {
totff+=ff[isy*nsubpix+isx];
}
}
totff/=nsubpix*nsubpix;
if (totff) {
cout << "ff: " << totff << endl;
for (isx=0; isx<nsubpix; isx++) {
for (isy=0; isy<nsubpix; isy++) {
ff[isy*nsubpix+isx]/=totff;
cout << ff[isy*nsubpix+isx] << "\t";
}
cout << endl;
}
for (ix=0; ix<NC; ix++) {
for (iy=0; iy<NR; iy++) {
for (isx=0; isx<nsubpix; isx++) {
for (isy=0; isy<nsubpix; isy++) {
ffimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]=img[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]/ff[isy*nsubpix+isx];
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]+=ffimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)];
}
}
}
}
cout << "writing eta!" << endl;
WriteToTiff(ffimg, outfname,NC*nsubpix,NR*nsubpix);
}
interp->writeFlatField(outfname);
#endif
#ifndef FF
#ifdef MANYFILES
sprintf(outfname,argv[3],irun,nframes-ff);
cout << outfname << endl;
#endif
sprintf(outfname,"%s_inteta2.tiff", argv[3]);
interp->writeInterpolatedImage(outfname);
sprintf(outfname,"%s_inteta3.tiff", argv[3]);
interp3->writeInterpolatedImage(outfname);
sprintf(outfname,"%s_mix.tiff", argv[3]);
dummy->writeInterpolatedImage(outfname);
sprintf(outfname,"%s_mult.tiff", argv[3]);
mult->writeInterpolatedImage(outfname);
#ifndef MANYFILES
img=interp->getInterpolatedImage();
for (ix=0; ix<NC; ix++) {
for (iy=0; iy<NR; iy++) {
@ -299,24 +189,23 @@ int main(int argc, char *argv[]) {
}
}
}
#endif
#endif
cout << "Read " << nframes << " frames (first frame: " << f0 << " last frame: " << lastframe << " delta:" << lastframe-f0 << ")"<<endl;
interp->clearInterpolatedImage();
interp3->clearInterpolatedImage();
dummy->clearInterpolatedImage();
mult->clearInterpolatedImage();
#endif
} else
cout << "could not open file " << infname << endl;
}
cout << irun << " " << runmax << endl;
#ifndef MANYFILES
#ifndef FF
sprintf(outfname,argv[3],11111);
WriteToTiff(totimg, outfname,NC*nsubpix,NR*nsubpix);
#endif
cout << "Filled " << nph << " (/"<< totph <<") of which " << badph << " badly interpolated " << endl;
#ifdef FF
interp->writeFlatField(outfname);
#endif
cout << "Filled " << nph << " (/"<< totph <<") " << endl;
return 0;
}

View File

@ -8,6 +8,12 @@
#include <fstream>
#include "tiffIO.h"
//#define NEWZMQ
#ifdef NEWZMQ
#include <rapidjson/document.h> //json header in zmq stream
#endif
#include<iostream>
//#include "analogDetector.h"
@ -39,8 +45,9 @@ int main(int argc, char *argv[]) {
bool send = false;
char* socketip=argv[1];
uint32_t portnum = atoi(argv[2]);
int size = 32*2*5000;//atoi(argv[3]);
int maxSize = 32*2*8192;//5000;//atoi(argv[3]);
int size= 32*2*5000;
int multisize=size;
// send parameters if any
char* socketip2 = 0;
uint32_t portnum2 = 0;
@ -70,47 +77,88 @@ int main(int argc, char *argv[]) {
mt->popFree(buff);
ZmqSocket* zmqsocket=NULL;
#ifdef NEWZMQ
// receive socket
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
try{
#endif
zmqsocket = new ZmqSocket(socketip,portnum);
#ifdef NEWZMQ
} catch (...) {
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
delete zmqsocket;
return EXIT_FAILURE;
}
#endif
#ifndef NEWZMQ
if (zmqsocket->IsError()) {
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
delete zmqsocket;
return EXIT_FAILURE;
}
zmqsocket->Connect();
#endif
if (zmqsocket->Connect()) {
cprintf(RED, "Error: Could not connect to socket %s\n",
zmqsocket->GetZmqServerAddress());
delete zmqsocket;
return EXIT_FAILURE;
} else
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
// send socket
ZmqSocket* zmqsocket2 = 0;
cout << "zmq2 " << endl;
if (send) {
#ifdef NEWZMQ
// receive socket
try{
#endif
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
if (zmqsocket2->IsError()) {
bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
#ifdef NEWZMQ
} catch (...) {
cprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
delete zmqsocket2;
delete zmqsocket;
return EXIT_FAILURE;
}
zmqsocket2->Connect();
printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
#endif
#ifndef NEWZMQ
if (zmqsocket2->IsError()) {
cprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
delete zmqsocket2;
delete zmqsocket;
return EXIT_FAILURE;
}
#endif
if (zmqsocket2->Connect()) {
cprintf(RED, "Error: Could not connect to socket %s\n",
zmqsocket2->GetZmqServerAddress());
delete zmqsocket2;
return EXIT_FAILURE;
} else
printf("Zmq Client at %s\n", zmqsocket2->GetZmqServerAddress());
}
// header variables
uint64_t acqIndex = -1;
uint64_t frameIndex = -1;
uint32_t subframeIndex = -1;
uint32_t subFrameIndex = -1;
uint64_t fileindex = -1;
string filename = "";
char* image = new char[size];
// char* image = new char[size];
//int* image = new int[(size/sizeof(int))]();
uint32_t flippedDataX = -1;
int *nph;
int iframe=0;
char ofname[10000];
@ -119,17 +167,57 @@ int main(int argc, char *argv[]) {
int length;
int *detimage;
int nnx, nny,nns;
uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0, dynamicRange = 0;
filter->getImageSize(nnx, nny,nns);
int16_t *dout=new int16_t [nnx*nny];
// infinite loop
uint32_t packetNumber = 0;
uint64_t bunchId = 0;
uint64_t timestamp = 0;
int16_t modId = 0;
uint16_t xCoord = 0;
uint16_t yCoord = 0;
uint16_t zCoord = 0;
uint32_t debug = 0;
uint32_t dr = 16;
uint16_t roundRNumber = 0;
uint8_t detType = 0;
uint8_t version = 0;
int* flippedData = 0;
char* additionalJsonHeader = 0;
uint32_t threshold=0;
uint32_t xmin=0, xmax=400, ymin=0, ymax=400;
string frameMode_s, detectorMode_s;
int emin, emax;
int newFrame=1;
while(1) {
// cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
// get header, (if dummy, fail is on parse error or end of acquisition)
#ifndef NEWZMQ
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){
#endif
#ifdef NEWZMQ
rapidjson::Document doc;
if (!zmqsocket->ReceiveHeader(0, doc, SLS_DETECTOR_JSON_HEADER_VERSION)) {
zmqsocket->CloseHeaderMessage();
#endif
// if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) {
cprintf(RED, "Got Dummy\n");
while (mt->isBusy()) {;}//wait until all data are processed from the queues
@ -142,8 +230,18 @@ int main(int argc, char *argv[]) {
if (send) {
strcpy(fname,filename.c_str());
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,16,fileindex,400,400,400*400, acqIndex,frameIndex,fname, acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
#ifdef NEWZMQ
//zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dynamicRange, fileindex,
// nnx, nny, nns*dynamicRange/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex,
nnx, nny, nns*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
#endif
#ifndef NEWZMQ
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
#endif
zmqsocket2->SendData((char*)dout,length);
cprintf(GREEN, "Sent Data\n");
@ -161,9 +259,112 @@ int main(int argc, char *argv[]) {
of=NULL;
}
newFrame=1;
continue; //continue to not get out
}
#ifdef NEWZMQ
if (newFrame) {
// acqIndex, frameIndex, subframeIndex, filename, fileindex
size = doc["size"].GetUint();
multisize = size;// * zmqsocket->size();
dynamicRange = doc["bitmode"].GetUint();
nPixelsX = doc["shape"][0].GetUint();
nPixelsY = doc["shape"][1].GetUint();
filename = doc["fname"].GetString();
acqIndex = doc["acqIndex"].GetUint64();
frameIndex = doc["fIndex"].GetUint64();
fileindex = doc["fileIndex"].GetUint64();
subFrameIndex = doc["expLength"].GetUint();
xCoord = doc["xCoord"].GetUint();
yCoord = doc["yCoord"].GetUint();
zCoord = doc["zCoord"].GetUint();
flippedDataX=doc["flippedDataX"].GetUint();
packetNumber=doc["packetNumber"].GetUint();
bunchId=doc["bunchId"].GetUint();
timestamp=doc["timestamp"].GetUint();
modId=doc["modId"].GetUint();
debug=doc["debug"].GetUint();
roundRNumber=doc["roundRNumber"].GetUint();
detType=doc["detType"].GetUint();
version=doc["version"].GetUint();
cprintf(BLUE, "Header Info:\n"
"size: %u\n"
"multisize: %u\n"
"dynamicRange: %u\n"
"nPixelsX: %u\n"
"nPixelsY: %u\n"
"currentFileName: %s\n"
"currentAcquisitionIndex: %lu\n"
"currentFrameIndex: %lu\n"
"currentFileIndex: %lu\n"
"currentSubFrameIndex: %u\n"
"xCoordX: %u\n"
"yCoordY: %u\n"
"zCoordZ: %u\n"
"flippedDataX: %u\n"
"packetNumber: %u\n"
"bunchId: %u\n"
"timestamp: %u\n"
"modId: %u\n"
"debug: %u\n"
"roundRNumber: %u\n"
"detType: %u\n"
"version: %u\n",
size, multisize, dynamicRange, nPixelsX, nPixelsY,
filename.c_str(), acqIndex,
frameIndex, fileindex, subFrameIndex,
xCoord, yCoord,zCoord,
flippedDataX, packetNumber, bunchId, timestamp, modId, debug, roundRNumber, detType, version);
if (doc.HasMember("threshold")) {
version=doc["threshold"].GetUint();
}
if (doc.HasMember("roi")) {
xmin=doc["roi"][0].GetUint();
xmax=doc["roi"][1].GetUint();
ymin=doc["roi"][2].GetUint();
ymax=doc["roi"][3].GetUint();
}
if (doc.HasMember("frameMode")) {
frameMode_s=doc["frameMode"].GetString();
}
if (doc.HasMember("detectorMode")) {
detectorMode_s=doc["detectorMode"].GetString();
}
if (doc.HasMember("energyRange")) {
emin=doc["energyRange"][0].GetUint();
emax=doc["energyRange"][0].GetUint();
}
if (doc.HasMember("dynamicRange")) {
dr=doc["dynamicRange"].GetUint();
}
if (doc.HasMember("nSubPixels")) {
nsubPixels=doc["nSubPixels"].GetUint();
}
newFrame=0;
zmqsocket->CloseHeaderMessage();
}
#endif
if (of==NULL) {
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);

View File

@ -0,0 +1,529 @@
#include "sls_receiver_defs.h"
#include "ZmqSocket.h"
#include "moench03T1ZmqDataNew.h"
#include <vector>
#include <string>
#include <sstream>
#include <iomanip>
#include <fstream>
#include "tiffIO.h"
//#define NEWZMQ
#ifdef NEWZMQ
#include <rapidjson/document.h> //json header in zmq stream
#endif
#include<iostream>
//#include "analogDetector.h"
//#include "singlePhotonDetector.h"
#include "interpolatingDetector.h"
#include "multiThreadedAnalogDetector.h"
#include "ansi.h"
#include <iostream>
using namespace std;
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
// myDet->setNetworkParameter(ADDITIONAL_JSON_HEADER, " \"what\":\"nothing\" ");
int main(int argc, char *argv[]) {
/**
* trial.o [socket ip] [starting port number] [send_socket ip] [send port number]
*
*/
FILE *of=NULL;
int fifosize=1000;
int nthreads=20;
// help
if (argc < 3 ) {
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number]\n");
return EXIT_FAILURE;
}
// receive parameters
bool send = false;
char* socketip=argv[1];
uint32_t portnum = atoi(argv[2]);
int maxSize = 32*2*8192;//5000;//atoi(argv[3]);
int size= 32*2*5000;
int multisize=size;
// send parameters if any
char* socketip2 = 0;
uint32_t portnum2 = 0;
if (argc > 3) {
send = true;
socketip2 = argv[3];
portnum2 = atoi(argv[4]);
}
cout << "\nrx socket ip : " << socketip <<
"\nrx port num : " << portnum ;
if (send) {
cout << "\ntx socket ip : " << socketip2 <<
"\ntx port num : " << portnum2;
}
cout << endl;
//slsDetectorData *det=new moench03T1ZmqDataNew();
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
cout << endl << " det" <<endl;
int npx, npy;
det->getDetectorSize(npx, npy);
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10);
// interpolatingDetector *filter=new interpolatingDetector(det,NULL, 5, 1, 0, 1000, 10);
cout << " filter" <<endl;
char* buff;
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
cout << " multi" <<endl;
mt->setFrameMode(eFrame);
mt->StartThreads();
cout << " start" <<endl;
mt->popFree(buff);
cout << " pop" <<endl;
ZmqSocket* zmqsocket=NULL;
#ifdef NEWZMQ
// receive socket
try{
#endif
zmqsocket = new ZmqSocket(socketip,portnum);
#ifdef NEWZMQ
} catch (...) {
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
delete zmqsocket;
return EXIT_FAILURE;
}
#endif
#ifndef NEWZMQ
if (zmqsocket->IsError()) {
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
delete zmqsocket;
return EXIT_FAILURE;
}
#endif
if (zmqsocket->Connect()) {
cprintf(RED, "Error: Could not connect to socket %s\n",
zmqsocket->GetZmqServerAddress());
delete zmqsocket;
return EXIT_FAILURE;
} else
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
// send socket
ZmqSocket* zmqsocket2 = 0;
cout << "zmq2 " << endl;
if (send) {
#ifdef NEWZMQ
// receive socket
try{
#endif
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
#ifdef NEWZMQ
} catch (...) {
cprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
delete zmqsocket2;
delete zmqsocket;
return EXIT_FAILURE;
}
#endif
#ifndef NEWZMQ
if (zmqsocket2->IsError()) {
cprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
delete zmqsocket2;
delete zmqsocket;
return EXIT_FAILURE;
}
#endif
if (zmqsocket2->Connect()) {
cprintf(RED, "Error: Could not connect to socket %s\n",
zmqsocket2->GetZmqServerAddress());
delete zmqsocket2;
return EXIT_FAILURE;
} else
printf("Zmq Client at %s\n", zmqsocket2->GetZmqServerAddress());
}
// header variables
uint64_t acqIndex = -1;
uint64_t frameIndex = -1;
uint32_t subFrameIndex = -1;
uint64_t fileindex = -1;
string filename = "";
// char* image = new char[size];
//int* image = new int[(size/sizeof(int))]();
uint32_t flippedDataX = -1;
int *nph;
int iframe=0;
char ofname[10000];
char fname[10000];
int length;
int *detimage;
int nnx, nny,nns;
uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0, dynamicRange = 0;
filter->getImageSize(nnx, nny,nns);
// infinite loop
uint32_t packetNumber = 0;
uint64_t bunchId = 0;
uint64_t timestamp = 0;
int16_t modId = 0;
uint16_t xCoord = 0;
uint16_t yCoord = 0;
uint16_t zCoord = 0;
uint32_t debug = 0;
uint32_t dr = 16;
int16_t *dout=new int16_t [nnx*nny];
//uint32_t dr = 32;
//int32_t *dout=new int32_t [nnx*nny];
uint32_t nSigma=5;
uint16_t roundRNumber = 0;
uint8_t detType = 0;
uint8_t version = 0;
int* flippedData = 0;
char* additionalJsonHeader = 0;
int32_t threshold=0;
int32_t xmin=0, xmax=400, ymin=0, ymax=400;
string frameMode_s, detectorMode_s, intMode_s;
int emin, emax;
int resetFlat=0;
int resetPed=0;
int nsubPixels=1;
int isPedestal;
int isFlat=0;
int newFrame=1;
detectorMode dMode;
frameMode fMode;
double *ped;
while(1) {
// cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
// get header, (if dummy, fail is on parse error or end of acquisition)
#ifndef NEWZMQ
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){
#endif
#ifdef NEWZMQ
rapidjson::Document doc;
if (!zmqsocket->ReceiveHeader(0, doc, SLS_DETECTOR_JSON_HEADER_VERSION)) {
zmqsocket->CloseHeaderMessage();
#endif
// if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) {
cprintf(RED, "Got Dummy\n");
while (mt->isBusy()) {;}//wait until all data are processed from the queues
detimage=mt->getImage(nnx,nny,nns);
if (fMode==ePedestal) {
nns=1;
// cout << "get pedestal " << endl;
ped=mt->getPedestal();
// cout << "got pedestal " << endl;
for (int ix=0; ix<nnx; ix++) {
for (int iy=0; iy<nny; iy++) {
dout[iy*nnx+ix]=ped[(iy)*nnx+ix];
// cout << ped[(iy)*nnx+ix] << " " ;
}
}
// cout << endl ;
// cout << "done " << endl;
} else {
for (int ix=0; ix<nnx; ix++) {
for (int iy=0; iy<nny; iy++) {
for (int isx=0; isx<nns; isx++) {
for (int isy=0; isy<nns; isy++) {
if (isx==0 && isy==0)
dout[iy*nnx+ix]=detimage[(iy+isy)*nnx*nns+ix+isx];
else
dout[iy*nnx+ix]+=detimage[(iy+isy)*nnx*nns+ix+isx];
}
}
if (dout[iy*nnx+ix]<0) dout[iy*nnx+ix]=0;
}
}
}
// cout << nns*nnx*nny*nns*dr/8 << " " << length << endl;
if (send) {
strcpy(fname,filename.c_str());
#ifdef NEWZMQ
//zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dynamicRange, fileindex,
// nnx, nny, nns*dynamicRange/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
// zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nns*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
#endif
#ifndef NEWZMQ
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
#endif
zmqsocket2->SendData((char*)dout,length);//nns*dr/8);
cprintf(GREEN, "Sent Data\n");
}
// stream dummy to socket2 to signal end of acquisition
if (send) {
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
cprintf(RED, "Sent Dummy\n");
}
mt->clearImage();
if (of) {
fclose(of);
of=NULL;
}
newFrame=1;
continue; //continue to not get out
}
#ifdef NEWZMQ
if (newFrame) {
// acqIndex, frameIndex, subframeIndex, filename, fileindex
size = doc["size"].GetUint();
multisize = size;// * zmqsocket->size();
dynamicRange = doc["bitmode"].GetUint();
nPixelsX = doc["shape"][0].GetUint();
nPixelsY = doc["shape"][1].GetUint();
filename = doc["fname"].GetString();
acqIndex = doc["acqIndex"].GetUint64();
frameIndex = doc["fIndex"].GetUint64();
fileindex = doc["fileIndex"].GetUint64();
subFrameIndex = doc["expLength"].GetUint();
xCoord = doc["xCoord"].GetUint();
yCoord = doc["yCoord"].GetUint();
zCoord = doc["zCoord"].GetUint();
flippedDataX=doc["flippedDataX"].GetUint();
packetNumber=doc["packetNumber"].GetUint();
bunchId=doc["bunchId"].GetUint();
timestamp=doc["timestamp"].GetUint();
modId=doc["modId"].GetUint();
debug=doc["debug"].GetUint();
roundRNumber=doc["roundRNumber"].GetUint();
detType=doc["detType"].GetUint();
version=doc["version"].GetUint();
cprintf(BLUE, "Header Info:\n"
"size: %u\n"
"multisize: %u\n"
"dynamicRange: %u\n"
"nPixelsX: %u\n"
"nPixelsY: %u\n"
"currentFileName: %s\n"
"currentAcquisitionIndex: %lu\n"
"currentFrameIndex: %lu\n"
"currentFileIndex: %lu\n"
"currentSubFrameIndex: %u\n"
"xCoordX: %u\n"
"yCoordY: %u\n"
"zCoordZ: %u\n"
"flippedDataX: %u\n"
"packetNumber: %u\n"
"bunchId: %u\n"
"timestamp: %u\n"
"modId: %u\n"
"debug: %u\n"
"roundRNumber: %u\n"
"detType: %u\n"
"version: %u\n",
size, multisize, dynamicRange, nPixelsX, nPixelsY,
filename.c_str(), acqIndex,
frameIndex, fileindex, subFrameIndex,
xCoord, yCoord,zCoord,
flippedDataX, packetNumber, bunchId, timestamp, modId, debug, roundRNumber, detType, version);
/* Analog detector commands */
isPedestal=0;
isFlat=0;
fMode=eFrame;
frameMode_s="frame";
cprintf(MAGENTA, "Frame mode: ");
if (doc.HasMember("frameMode")) {
if (doc["frameMode"].IsString()) {
frameMode_s=doc["frameMode"].GetString();
if (frameMode_s == "pedestal"){
fMode=ePedestal;
isPedestal=1;
} else if (frameMode_s == "newPedestal"){
mt->newDataSet(); //resets pedestal
// cprintf(MAGENTA, "Resetting pedestal\n");
fMode=ePedestal;
isPedestal=1;
} else if (frameMode_s == "flatfield") {
fMode=eFlat;
isFlat=1;
} else if (frameMode_s == "newFlatfield") {
//mt->resetFlatfield();
isFlat=1;
//cprintf(MAGENTA, "Resetting flatfield\n");
fMode=eFlat;
} else
fMode=eFrame;
}
}
cprintf(MAGENTA, "%s\n" , frameMode_s.c_str());
mt->setFrameMode(fMode);
threshold=0;
cprintf(MAGENTA, "Threshold: ");
if (doc.HasMember("threshold")) {
if (doc["threshold"].IsInt())
threshold=doc["threshold"].GetInt();
}
mt->setThreshold(threshold);
cprintf(MAGENTA, "%d\n", threshold);
xmin=0;
xmax=npx;
ymin=0;
ymax=npy;
cprintf(MAGENTA, "ROI: ");
if (doc.HasMember("roi")) {
if (doc["roi"].IsArray()) {
if (doc["roi"].Size() > 0 )
if (doc["roi"][0].IsInt())
xmin=doc["roi"][0].GetInt();
if (doc["roi"].Size() > 1 )
if (doc["roi"][1].IsInt())
xmax=doc["roi"][1].GetInt();
if (doc["roi"].Size() > 2 )
if (doc["roi"][2].IsInt())
ymin=doc["roi"][2].GetInt();
if (doc["roi"].Size() > 3 )
if (doc["roi"][3].IsInt())
ymax=doc["roi"][3].GetInt();
}
}
cprintf(MAGENTA, "%d %d %d %d\n", xmin, xmax, ymin, ymax);
mt->setROI(xmin, xmax, ymin, ymax);
// if (doc.HasMember("dynamicRange")) {
// dr=doc["dynamicRange"].GetUint();
// }
dMode=eAnalog;
detectorMode_s="analog";
cprintf(MAGENTA, "Detector mode: ");
if (doc.HasMember("detectorMode")) {
if (doc["detectorMode"].IsString()) {
detectorMode_s=doc["detectorMode"].GetString();
if (detectorMode_s == "interpolating"){
dMode=eInterpolating;
} else if (detectorMode_s == "counting"){
dMode=ePhotonCounting;
} else {
dMode=eAnalog;
}
}
}
cprintf(MAGENTA, "%s\n" , detectorMode_s.c_str());
mt->setDetectorMode(dMode);
/* Single Photon Detector commands */
// if (doc.HasMember("nSigma")) {
// nSigma=doc["nSigma"].GetUint();
// }
// if (doc.HasMember("energyRange")) {
// emin=doc["energyRange"][0].GetUint();
// emax=doc["energyRange"][1].GetUint();
// }
/* interpolating detector commands */
// if (doc.HasMember("nSubPixels")) {
// nsubPixels=doc["nSubPixels"].GetUint();
// }
//if (doc.HasMember("interpolation")) {
// intMode_s=doc["intepolation"].GetString();
//}
newFrame=0;
zmqsocket->CloseHeaderMessage();
}
#endif
if (of==NULL) {
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
of=fopen(ofname,"w");
if (of) {
mt->setFilePointer(of);
}else {
cout << "Could not open "<< ofname << " for writing " << endl;
mt->setFilePointer(NULL);
}
}
// get data
length = zmqsocket->ReceiveData(0, buff, size);
mt->pushData(buff);
mt->nextThread();
mt->popFree(buff);
iframe++;
} // exiting infinite loop
delete zmqsocket;
if (send)
delete zmqsocket2;
cout<<"Goodbye"<< endl;
return 0;
}

View File

@ -49,7 +49,23 @@ public:
}
virtual int setFrameMode(int fm) {fMode=fm; if (fMode>=0) det->setFrameMode((frameMode)fMode);};
virtual int setFrameMode(int fm) {
if (fm>=0) {
det->setFrameMode((frameMode)fm);
fMode=fm;
}
return fMode;
};
virtual double setThreshold(double th) {return det->setThreshold(th);};
virtual void setROI(int xmin, int xmax, int ymin, int ymax) {det->setROI(xmin,xmax,ymin,ymax);};
virtual int setDetectorMode(int dm) {
if (dm>=0) {
det->setDetectorMode((detectorMode)dm);
dMode=dm;
}
return dMode;
};
virtual void newDataSet(){det->newDataSet();};
//fMode=fm; return fMode;}
@ -162,6 +178,7 @@ FILE *getFilePointer(){return det->getFilePointer();};
private:
analogDetector<uint16_t> *det;
int fMode;
int dMode;
int *dataSize;
pthread_t _thread;
char *mem;
@ -176,6 +193,7 @@ private:
threadedAnalogDetector *This=((threadedAnalogDetector *)ptr);
return This->processData();
}
void * processData() {
busy=1;
while (!stop) {
@ -234,6 +252,9 @@ public:
int setFrameMode(int fm) { int ret; for (int i=0; i<nThreads; i++) ret=dets[i]->setFrameMode(fm); return ret;};
double setThreshold(int fm) { double ret; for (int i=0; i<nThreads; i++) ret=dets[i]->setThreshold(fm); return ret;};
int setDetectorMode(int dm) { int ret; for (int i=0; i<nThreads; i++) ret=dets[i]->setDetectorMode(dm); return ret;};
void setROI(int xmin, int xmax, int ymin, int ymax) { for (int i=0; i<nThreads; i++) dets[i]->setROI(xmin, xmax,ymin,ymax);};
void newDataSet(){for (int i=0; i<nThreads; i++) dets[i]->newDataSet();};
int *getImage(int &nnx, int &nny, int &ns) {
@ -448,15 +469,17 @@ public:
for (int i=0; i<nThreads; i++) {
//inte=(slsInterpolation*)dets[i]->getInterpolation(nb,emi,ema);
// cout << i << endl;
p0=dets[i]->getPedestal(p0);
if (p0) {
for (int ib=0; ib<nx*ny; ib++) {
ped[ib]+=p0[ib]/((double)nThreads);
// cout << p0[ib] << " ";
}
}
delete [] p0;
}
delete [] p0;
return ped;
};

View File

@ -58,7 +58,7 @@ public analogDetector<uint16_t> {
int sign=1,
commonModeSubtraction *cm=NULL,
int nped=1000,
int nd=100, int nnx=-1, int nny=-1, double *gm=NULL) : analogDetector<uint16_t>(d, sign, cm, nped, nnx, nny, gm), nDark(nd), eventMask(NULL),nSigma (nsigma), clusterSize(csize), clusterSizeY(csize), clusters(NULL), quad(UNDEFINED_QUADRANT), tot(0), quadTot(0) {
int nd=100, int nnx=-1, int nny=-1, double *gm=NULL) : analogDetector<uint16_t>(d, sign, cm, nped, nnx, nny, gm), nDark(nd), eventMask(NULL),nSigma (nsigma), clusterSize(csize), clusterSizeY(csize), clusters(NULL), quad(UNDEFINED_QUADRANT), tot(0), quadTot(0), eMin(-1), eMax(-1) {
@ -101,6 +101,8 @@ public analogDetector<uint16_t> {
for (int i=0; i<ny; i++) {
eventMask[i]=new eventType[nx];
}
eMin=orig->eMin;
eMax=orig->eMax;
nSigma=orig->nSigma;
@ -178,11 +180,11 @@ public analogDetector<uint16_t> {
//nph=new int[nx*ny];
double rest[ny][nx];
int cy=(clusterSizeY+1)/2;
int cs=(clusterSize+1)/2;
int cy=(clusterSizeY+1)/2; //quad size
int cs=(clusterSize+1)/2; //quad size
int ccs=clusterSize;
int ccy=clusterSizeY;
int ccs=clusterSize; //cluster size
int ccy=clusterSizeY; //cluster size
double g=1.;
@ -210,6 +212,7 @@ public analogDetector<uint16_t> {
if (thr>0) {
newFrame();
if (cmSub) {
cout << "add to common mode?"<< endl;
addToCommonMode(data);
}
for (int ix=xmin; ix<xmax; ix++) {
@ -217,15 +220,28 @@ public analogDetector<uint16_t> {
val=subtractPedestal(data,ix,iy, cm);
nn=val/tthr;//analogDetector<uint16_t>::getNPhotons(data,ix,iy);
nn=analogDetector<uint16_t>::getNPhotons(data,ix,iy);//val/thr;//
if (nn>0) {
/* if (nph[ix+nx*iy]>0) { */
/* cout << nph[ix+nx*iy] << " => "; */
/* cout << ix << " " << iy << " " << val << " "<< nn << " " << nph[ix+nx*iy]+nn << endl; */
/* } */
nph[ix+nx*iy]+=nn;
rest[iy][ix]=(val-nn*tthr);
/* if (nph[ix+nx*iy]>1) { */
/* cout << nph[ix+nx*iy] << " => "; */
/* } */
rest[iy][ix]=(val-nn*thr+0.5*thr);
// if (ix==150 && iy==100)
// cout << ix << " " << iy << " " << val << " "<< nn << " " << rest[iy][ix] << " " << nph[ix+nx*iy] << endl;
nphFrame+=nn;
nphTot+=nn;
} else
rest[iy][ix]=val;
}
}
// }
for (int ix=xmin; ix<xmax; ix++) {
for (int iy=ymin; iy<ymax; iy++) {
@ -240,7 +256,7 @@ public analogDetector<uint16_t> {
tot=0;
quadTot=0;
if (rest[iy][ix]>0.25*tthr) {
if (rest[iy][ix]>0.25*thr) {
eventMask[iy][ix]=NEIGHBOUR;
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
@ -283,14 +299,25 @@ public analogDetector<uint16_t> {
quad=TOP_RIGHT;
quadTot=tr;
}
rms=getPedestalRMS(ix,iy);
tthr1=tthr-sqrt(ccy*ccs)*rms;
tthr2=tthr-sqrt(cy*cs)*rms;
if (tthr>sqrt(ccy*ccs)*rms) tthr1=tthr-sqrt(ccy*ccs)*rms; else tthr1=sqrt(ccy*ccs)*rms;
if (tthr>sqrt(cy*cs)*rms) tthr2=tthr-sqrt(cy*cs)*rms; else tthr2=sqrt(cy*cs)*rms;
if (tot>tthr1 || quadTot>tthr2) {
tthr=nSigma*rms;
tthr1=nSigma*sqrt(clusterSize*clusterSizeY)*rms;
tthr2=nSigma*sqrt((clusterSize+1)/2.*((clusterSizeY+1)/2.))*rms;
if (thr>tthr) tthr=thr-tthr;
if (thr>tthr1) tthr1=tthr-tthr1;
if (thr>tthr2) tthr2=tthr-tthr2;
if (tot>tthr1 || quadTot>tthr2 || max>tthr) {
eventMask[iy][ix]=PHOTON;
nph[ix+nx*iy]++;
// if (ix==150 && iy==100)
// if (iy<399)
// cout << "** " << ix << " " << iy << " " << quadTot << endl;
rest[iy][ix]-=thr;
nphFrame++;
nphTot++;
@ -436,6 +463,7 @@ int *getClusters(char *data, int *ph=NULL) {
double max=0, tl=0, tr=0, bl=0,br=0, *v, vv;
int cm=0;
int good=1;
if (cmSub) cm=1;
if (ph==NULL)
ph=image;
@ -531,8 +559,14 @@ int *getClusters(char *data, int *ph=NULL) {
}
}
// cout << (clusters+nph)->iframe << " " << ix << " " << nph << " " << tot << " " << (clusters+nph)->quadTot << endl;
good=1;
if (eMin>0 && tot<eMin) good=0;
if (eMax>0 && tot>eMax) good=0;
if (good) {
nph++;
image[iy*nx+ix]++;
}
} else {
eventMask[iy][ix]=PHOTON;
@ -540,8 +574,6 @@ int *getClusters(char *data, int *ph=NULL) {
} else if (eventMask[iy][ix]==PEDESTAL) {
addToPedestal(data,ix,iy,cm);
}
}
}
nphFrame=nph;
@ -650,21 +682,35 @@ void writeClusters(FILE *f){for (int i=0; i<nphFrame; i++) (clusters+i)->write(f
// cout << "sp" << endl;
switch(fMode) {
case ePedestal:
//cout <<"spc add to ped " << endl;
addToPedestal(data);
break;
default:
switch (dMode) {
case eAnalog:
analogDetector<uint16_t>::processData(data,val);
break;
default:
//cout <<"spc " << endl;
getNPhotons(data,val);
}
}
iframe++;
// cout << "done" << endl;
};
int getPhFrame(){return nphFrame;};
int getPhTot(){return nphTot;};
void setEnergyRange(double emi, double ema){eMin=emi; eMax=ema;};
void getEnergyRange(double &emi, double &ema){emi=eMin; ema=eMax;};
protected:
int nDark; /**< number of frames to be used at the beginning of the dataset to calculate pedestal without applying photon discrimination */
eventType **eventMask; /**< matrix of event type or each pixel */
double nSigma; /**< number of sigma parameter for photon discrimination */
double eMin, eMax;
int clusterSize; /**< cluster size in the x direction */
int clusterSizeY; /**< cluster size in the y direction i.e. 1 for strips, clusterSize for pixels */
// single_photon_hit *cluster; /**< single photon hit data structure */

View File

@ -486,13 +486,28 @@ enum readOutFlags {
READ_HITS=0x2, /**< return only the number of the channel which counted ate least one */
ZERO_COMPRESSION=0x4,/**< returned data are 0-compressed */
PUMP_PROBE_MODE=0x8,/**<pump-probe mode */
PEDESTAL=0x10,/**< frame mode set to pedestal */
FLAT=0x20,/**< frame mode set to flat */
NEWPEDESTAL=0x40,/**< frame mode set to pedestal and reset */
NEWFLAT=0x80,/**< frame mode set to flat and reset */
FRAME=0x100, /**< frame mode set to normal frame */
ANALOG=0x200, /**<detector working in analog mode */
COUNTING=0x400, /**<detector working in counting mode */
INTERPOLATING=0x800, /**<detector working in interpolating mode */
BACKGROUND_CORRECTIONS=0x1000, /**<background corrections */
TOT_MODE=0x2000,/**< pump-probe mode */
CONTINOUS_RO=0x4000,/**< pump-probe mode */
PARALLEL=0x10000,/**< eiger parallel mode */
NONPARALLEL=0x20000,/**< eiger serial mode */
SAFE=0x40000/**< eiger safe mode */,
DIGITAL_ONLY=0x80000, /** chiptest board read only digital bits (not adc values)*/
ANALOG_AND_DIGITAL=0x100000, /** chiptest board read adc values and digital bits digital bits */
DUT_CLK=0x200000, /** chiptest board fifo clock comes from device under test */
SHOW_OVERFLOW=0x400000, /** eiger 32 bit mode, show saturated for overflow of single subframes */

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 6bb7195a2c7dc9526088882e0244a7455d3c15b2
Revision: 1992
Branch: 3.3.0-rc
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 3941
Last Changed Date: 2018-07-18 12:26:21.000000002 +0200 ./threadFiles/ThreadPool.o
Repsitory UUID: 83600fcb15c8261173ab15a8ba8d1009693f2d23
Revision: 2005
Branch: anna
Last Changed Author: Anna_Bergamaschi
Last Changed Rev: 3962
Last Changed Date: 2018-09-11 16:29:59.000000002 +0200 ./slsDetector/slsDetector.o

View File

@ -84,10 +84,10 @@ u_int16_t a_bus_r16(u_int32_t offset){
u_int16_t bus_r16(u_int32_t offset){
u_int16_t r= a_bus_r16(offset);
#ifndef OLDVERSION
while (r!=a_bus_r16(offset))
r=a_bus_r16(offset);
#endif
/* #ifndef OLDVERSION */
/* while (r!=a_bus_r16(offset)) */
/* r=a_bus_r16(offset); */
/* #endif */
return r;
}
@ -117,10 +117,10 @@ u_int32_t a_bus_r(u_int32_t offset) {
u_int32_t bus_r(u_int32_t offset){
u_int32_t r= a_bus_r(offset);
#ifndef OLDVERSION
while (r!=a_bus_r(offset))
r=a_bus_r(offset);
#endif
/* #ifndef OLDVERSION */
/* while (r!=a_bus_r(offset)) */
/* r=a_bus_r(offset); */
/* #endif */
return r;
}

View File

@ -2003,7 +2003,7 @@ int startStateMachine(){
bus_w16(CONTROL_REG, FIFO_RESET_BIT);
bus_w16(CONTROL_REG, 0x0);
bus_w16(CONTROL_REG, START_ACQ_BIT | START_EXPOSURE_BIT);
// usleep(20);
usleep(20);
bus_w16(CONTROL_REG, 0x0);
//verify
/* if(bus_r(STATUS_REG) & RUN_BUSY_BIT) */
@ -2128,6 +2128,7 @@ u_int16_t* fifo_read_event(int ns)
a=bus_r16(LOOK_AT_ME_REG);
while(a==0) {
if (runBusy()==0) {
usleep(100);
a = bus_r(LOOK_AT_ME_REG);
if (a==0) {
printf("no frame found and acquisition finished - exiting\n");
@ -2137,36 +2138,29 @@ u_int16_t* fifo_read_event(int ns)
break;
}
}
a = bus_r(LOOK_AT_ME_REG);
//#ifdef VERBOSE
//printf(".");
//#endif
}
/* #ifdef TIMEDBG */
/* // tsss=tss; */
/* gettimeofday(&tss,NULL); */
/* printf("look for data = %ld usec\n", (tss.tv_usec) - (tse.tv_usec)); */
/* #endif */
// printf("LAM: %08x\n",a);
a = bus_r16(LOOK_AT_ME_REG);
}
// printf(".");
a = bus_r(LOOK_AT_ME_REG);
}
//a = bus_r16(LOOK_AT_ME_REG);
if (analogEnable) {
printf("*");
// printf("*");
bus_w16(DUMMY_REG,1<<8); // read strobe to all fifos
bus_w16(DUMMY_REG,0);
for (i=0; i<32; i++) {
if (~(mask&adcDisableMask)) {
*((u_int16_t*)now_ptr)=*values;//bus_r16(FIFO_DATA_REG);
if (i!=0 || ns!=0) {
a=0;
while (*((u_int16_t*)now_ptr)==*((u_int16_t*)(now_ptr)-1) && a++<10) {
*((u_int16_t*)now_ptr)=*values;
}
*((u_int16_t*)now_ptr)=bus_r16(FIFO_DATA_REG);
/* if (i!=0 || ns!=0) { */
/* a=0; */
/* while (*((u_int16_t*)now_ptr)==*((u_int16_t*)(now_ptr)-1) && a++<10 && *((u_int16_t*)now_ptr)!=0 && *((u_int16_t*)now_ptr)!=0x3ff) { */
/* printf("%d .",i); */
/* *((u_int16_t*)now_ptr)=bus_r16(FIFO_DATA_REG);//\*values; */
/* } */
/* } */
while (*((u_int16_t*)now_ptr)!=bus_r16(FIFO_DATA_REG)) {
printf("%d ,",i);
*((u_int16_t*)now_ptr)=bus_r16(FIFO_DATA_REG);
}
now_ptr+=2;
}
@ -2213,8 +2207,10 @@ u_int16_t* fifo_read_frame()
now_ptr=(char*)ram_values;
while(ns<nSamples && fifo_read_event(ns)) {
// now_ptr+=dataBytes;
// printf("%d %x\n",ns,bus_r16(LOOK_AT_ME_REG));
ns++;
}
// printf("Data in fifo %x\n",bus_r16(LOOK_AT_ME_REG));
#ifdef TIMEDBG
// usleep(10);
gettimeofday(&tss,NULL);

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsDetectorSoftware/jctbDetectorServer
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 52b1e987263c831adcfab79c1c2b7bb9c68b09c7
Revision: 26
Repsitory UUID: 83600fcb15c8261173ab15a8ba8d1009693f2d23
Revision: 27
Branch: anna
Last Changed Author: Anna_Bergamaschi
Last Changed Rev: 3960
Last Changed Date: 2018-08-09 14:00:05.000000002 +0200 ./server_funcs.c
Last Changed Rev: 3962
Last Changed Date: 2018-09-04 11:59:37.000000002 +0200 ./firmware_funcs.c

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "52b1e987263c831adcfab79c1c2b7bb9c68b09c7"
#define GITREPUUID "83600fcb15c8261173ab15a8ba8d1009693f2d23"
#define GITAUTH "Anna_Bergamaschi"
#define GITREV 0x3960
#define GITDATE 0x20180809
#define GITREV 0x3962
#define GITDATE 0x20180904
#define GITBRANCH "anna"

View File

@ -3202,6 +3202,7 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[]) {
if ((n < 0) || (roiLimits == NULL))
return FAIL;
// cout << "Setting ROI for " << n << "rois:" << endl;
//ensures min < max
verifyMinMaxROI(n, roiLimits);
#ifdef VERBOSE
@ -3216,7 +3217,7 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[]) {
xmax = roiLimits[i].xmax;
ymin = roiLimits[i].ymin;
ymax = roiLimits[i].ymax;
if (getDetectorsType() != JUNGFRAUCTB) {
//check roi max values
idet = decodeNChannel(xmax, ymax, channelX, channelY);
#ifdef VERBOSE
@ -3224,6 +3225,7 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[]) {
cout << "det:" << idet << "\t" << xmax << "\t" << ymax << "\t"
<< channelX << "\t" << channelY << endl;
#endif
//std::cout << getDetectorsType() << endl;
if (idet == -1 ) {
cout << "invalid roi" << endl;
continue;
@ -3289,6 +3291,17 @@ int multiSlsDetector::setROI(int n, ROI roiLimits[]) {
if ((lastChannelX + offsetX) == xmax)
xmin = xmax + 1;
}
}else {
idet=0;
nroi[idet]=n;
index = 0;
allroi[idet][index].xmin = xmin;
allroi[idet][index].xmax = xmax;
allroi[idet][index].ymin = ymin;
allroi[idet][index].ymax = ymax;
// nroi[idet] = nroi[idet] + 1;
}
}
#ifdef VERBOSE
@ -3335,6 +3348,7 @@ slsDetectorDefs::ROI* multiSlsDetector::getROI(int& n) {
//get each detector's roi array
for (unsigned i = 0; i < detectors.size(); ++i) {
temp = detectors[i]->getROI(index);
// cout << index << endl;
if (detectors[i]->getErrorMask())
setErrorMask(getErrorMask() | (1 << i));

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "6bb7195a2c7dc9526088882e0244a7455d3c15b2"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x3941
#define GITDATE 0x20180718
#define GITBRANCH "3.3.0-rc"
#define GITREPUUID "83600fcb15c8261173ab15a8ba8d1009693f2d23"
#define GITAUTH "Anna_Bergamaschi"
#define GITREV 0x3962
#define GITDATE 0x20180911
#define GITBRANCH "anna"

View File

@ -1053,14 +1053,18 @@ void slsDetector::disconnectControl() {
int slsDetector::connectData() {
//cout << "connect" << endl;
if (dataSocket){
if (dataSocket->Connect() >= 0)
if (dataSocket->Connect() >= 0) {
//cout << "ok" << endl;
return OK;
else{
} else{
std::cout << "cannot connect to receiver" << endl;
setErrorMask((getErrorMask())|(CANNOT_CONNECT_TO_RECEIVER));
//cout << "fail" << endl;
return FAIL;}
}
//cout << "undefined" << endl;
return UNDEFINED;
}
@ -2919,6 +2923,30 @@ int slsDetector::getThresholdEnergy(int imod) {
updateDetector();
}
}
if(thisDetector->myDetectorType==JUNGFRAUCTB) {
int en=-1;
string header=getNetworkParameter(ADDITIONAL_JSON_HEADER);
std::cout<< "Json header: " << header << std::endl;
//must be in the format '\"label1\":\"value1\",\"label2\":\"value2\"' etc."
//
size_t pos0;
pos0=header.find("\"threshold\"");
if (pos0!=std::string::npos) {
if (sscanf(header.substr(pos0).c_str(),"\"threshold\":%d", &en))
thisDetector->currentThresholdEV=en;
}
}
return thisDetector->currentThresholdEV;
}
@ -2962,6 +2990,62 @@ int slsDetector::setThresholdEnergy(int e_eV, int imod, detectorSettings isetti
} else {
thisDetector->currentThresholdEV=e_eV;
}
/* add threshold to zmq header */
string header=getNetworkParameter(ADDITIONAL_JSON_HEADER);
std::cout<< "Old json header: " << header << std::endl;
//must be in the format '\"label1\":\"value1\",\"label2\":\"value2\"' etc."
//
size_t pos0;
pos0=header.find(",\"threshold\"");
if (pos0==std::string::npos) {
pos0=header.find("\"threshold\"");
}
if (pos0!=std::string::npos) {
// remove old roi
// std::cout<< header.substr(0,pos) << std::endl;
// size_t pos0=header.find_last_of(",",0,pos);
// if (pos0==std::string::npos) {
// pos0=pos;
// } else
// std::cout<< header.substr(pos0) << std::endl;
size_t pos1=header.find_first_of(",",pos0+1);
// std::cout << pos0 << " " << pos1 << std::endl;
std::cout<< "Replacing old threshold: " << header.substr(pos0,pos1-pos0) << std::endl;
// if (pos1!=std::string::npos)
header.erase(pos0,pos1-pos0);
// else
// header.erase(pos0);
}
if (header.length()>0) {
if (header.at(0)==',')
header.erase(0,1);
if (header.length()>0)
header.append(",");
}
// std::cout<< "Left: " << header << std::endl;
char h[1000];
sprintf(h,"\"threshold\":%d",e_eV);
// std::cout<< "new ROI: " << h << std::endl;
header.append(h);
std::cout<< "New json header: " << header << std::endl;
setReceiverOnline(ONLINE_FLAG);
setNetworkParameter(ADDITIONAL_JSON_HEADER, header);
/***** END FOR ZMQ HEADER */
ret=OK;
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
thisDetector->currentThresholdEV=e_eV;
}
return thisDetector->currentThresholdEV;
}
@ -4771,7 +4855,8 @@ int slsDetector::setReadOutFlags(readOutFlags flag) {
int fnum=F_SET_READOUT_FLAGS;
readOutFlags retval;
//readOutFlags retval;
int retval;
char mess[MAX_STR_LENGTH]="";
int ret=OK;
@ -4790,7 +4875,7 @@ int slsDetector::setReadOutFlags(readOutFlags flag) {
setErrorMask((getErrorMask())|(COULD_NOT_SET_READOUT_FLAGS));
} else {
controlSocket->ReceiveDataOnly(&retval,sizeof(retval));
thisDetector->roFlags=retval;
thisDetector->roFlags=(readOutFlags)retval;
if (thisDetector->myDetectorType==JUNGFRAUCTB) {
getTotalNumberOfChannels();
@ -4807,6 +4892,150 @@ int slsDetector::setReadOutFlags(readOutFlags flag) {
thisDetector->roFlags=flag;
}
std::cout<< "***ZMQ: " << hex<< flag << std::endl;
if (flag & (PEDESTAL | NEWPEDESTAL | NEWFLAT | FLAT | FRAME)) {
std::cout<< "***frameMode: " << std::endl;
string header=getNetworkParameter(ADDITIONAL_JSON_HEADER);
std::cout<< "Old json header: " << header << std::endl;
//must be in the format '\"label1\":\"value1\",\"label2\":\"value2\"' etc."
//
size_t pos0;
pos0=header.find(",\"frameMode\"");
if (pos0==std::string::npos) {
pos0=header.find("\"frameMode\"");
}
if (pos0!=std::string::npos) {
size_t pos1=header.find_first_of(",",pos0+1);
// if (pos1!=std::string::npos)
if (flag!=GET_READOUT_FLAGS) {
cout << dec<< pos0 << " " << pos1 << endl;
std::cout<< "Replacing frame Mode: " << header.substr(pos0,pos1-pos0) << std::endl;
header.erase(pos0,pos1-pos0);
}
else if (header.substr(pos0,pos1+pos0)=="\"frameMode\":\"pedestal\"")
retval|=PEDESTAL;
else if (header.substr(pos0,pos1+pos0)=="\"frameMode\":\"newPedestal\"")
retval|=NEWPEDESTAL;
else if (header.substr(pos0,pos1+pos0)=="\"frameMode\":\"flatfield\"")
retval|=FLAT;
else if (header.substr(pos0,pos1+pos0)=="\"frameMode\":\"newFlatfield\"")
retval|=NEWFLAT;
else
retval|=FRAME;
}
char h[1000];
switch (flag) {
case PEDESTAL:
retval=PEDESTAL;
strcpy(h,"\"frameMode\":\"pedestal\"");
break;
case NEWPEDESTAL:
retval=NEWPEDESTAL;
strcpy(h,"\"frameMode\":\"newPedestal\"");
break;
case FLAT:
retval=FLAT;
strcpy(h,"\"frameMode\":\"flatfield\"");
break;
case NEWFLAT:
retval=NEWFLAT;
strcpy(h,"\"frameMode\":\"newFlatfield\"");
break;
default:
retval=FRAME;
strcpy(h,"\"frameMode\":\"frame\"");
}
if (flag!=GET_READOUT_FLAGS) {
if (header.length()>0) {
if (header.at(0)==',')
header.erase(0,1);
if (header.length()>0)
header.append(",");
}
header.append(h);
setReceiverOnline(ONLINE_FLAG);
setNetworkParameter(ADDITIONAL_JSON_HEADER, header);
}
std::cout<< "New json header: " << header << std::endl;
/***** END FOR ZMQ HEADER */
ret=OK;
// retval=flag;
}
if (flag & (COUNTING | INTERPOLATING | ANALOG)) {
std::cout<< "***detectorMode: " << std::endl;
string header=getNetworkParameter(ADDITIONAL_JSON_HEADER);
std::cout<< "Old json header: " << header << std::endl;
//must be in the format '\"label1\":\"value1\",\"label2\":\"value2\"' etc."
//
size_t pos0;
pos0=header.find(",\"detectorMode\"");
if (pos0==std::string::npos) {
pos0=header.find("\"detectorMode\"");
}
if (pos0!=std::string::npos) {
size_t pos1=header.find_first_of(",",pos0+1);
// if (pos1!=std::string::npos)
if (flag!=GET_READOUT_FLAGS) {
cout << dec<< pos0 << " " << pos1 << endl;
std::cout<< "Replacing detector Mode: " << header.substr(pos0,pos1-pos0) << std::endl;
header.erase(pos0,pos1-pos0);
}
else if (header.substr(pos0,pos1+pos0)=="\"detectorMode\":\"counting\"")
retval|=COUNTING;
else if (header.substr(pos0,pos1+pos0)=="\"detectorMode\":\"interpolating\"")
retval|=INTERPOLATING;
else
retval|=ANALOG;
}
char h[1000];
switch (flag) {
case COUNTING:
strcpy(h,"\"detectorMode\":\"counting\"");
retval=COUNTING;
break;
case INTERPOLATING:
retval=INTERPOLATING;
strcpy(h,"\"detectorMode\":\"interpolating\"");
break;
default:
retval=ANALOG;
strcpy(h,"\"detectorMode\":\"analog\"");
}
if (flag!=GET_READOUT_FLAGS) {
if (header.length()>0) {
if (header.at(0)==',')
header.erase(0,1);
if (header.length()>0)
header.append(",");
}
header.append(h);
setReceiverOnline(ONLINE_FLAG);
setNetworkParameter(ADDITIONAL_JSON_HEADER, header);
/***** END FOR ZMQ HEADER */
// retval=flag;
}
std::cout<< "New json header: " << header << std::endl;
ret=OK;
}
if (ret==OK) {
// thisDetector->roFlags=flag;
thisDetector->roFlags=(readOutFlags)retval;
}
std::cout<< retval << std::endl;
#ifdef VERBOSE
std::cout<< "Readout flag set to "<< retval << std::endl;
#endif
@ -5540,10 +5769,12 @@ string slsDetector::setAdditionalJsonHeader(string jsonheader) {
strcpy(arg, jsonheader.c_str());
if(thisDetector->receiverOnlineFlag==ONLINE_FLAG){
#ifdef VERBOSE
std::cout << "Sending additional json header " << arg << std::endl;
#endif
//#ifdef VERBOSE
// std::cout << "* Sending additional json header " << arg << std::endl;
//#endif
if (connectData() == OK){
// std::cout << "** Sending additional json header " << arg << std::endl;
ret=thisReceiver->sendString(fnum,retval,arg);
disconnectData();
}
@ -5994,6 +6225,70 @@ int slsDetector::setROI(int n,ROI roiLimits[]) {
//sort ascending order
int temp;
/***** NEW PART FOR ZMQ HEADER */
//std::cout<< "******* ROI" << std::endl;
// char header[1000];
string header=getNetworkParameter(ADDITIONAL_JSON_HEADER);
std::cout<< "Old json header: " << header << std::endl;
//must be in the format '\"label1\":\"value1\",\"label2\":\"value2\"' etc."
//
size_t pos0;
pos0=header.find(",\"roi\"");
if (pos0==std::string::npos) {
pos0=header.find("\"roi\"");
}
if (pos0!=std::string::npos) {
// remove old roi
// std::cout<< header.substr(0,pos) << std::endl;
// size_t pos0=header.find_last_of(",",0,pos);
// if (pos0==std::string::npos) {
// pos0=pos;
// } else
// std::cout<< header.substr(pos0) << std::endl;
size_t pos1=header.find_first_of("]",pos0+1);
// std::cout << pos0 << " " << pos1 << std::endl;
std::cout<< "Replacing old ROI: " << header.substr(pos0,pos1-pos0+1) << std::endl;
// if (pos1!=std::string::npos)
header.erase(pos0,pos1-pos0+1);
// else
// header.erase(pos0);
}
if (header.length()>0) {
if (header.at(0)==',')
header.erase(0,1);
if (header.length()>0)
header.append(",");
}
// std::cout<< "Left: " << header << std::endl;
char h[1000];
if (n) {
sprintf(h,"\"roi\":[%d, %d, %d, %d]",roiLimits[0].xmin, roiLimits[0].xmax, roiLimits[0].ymin, roiLimits[0].ymax);
// std::cout<< "new ROI: " << h << std::endl;
} else {
sprintf(h,"\"roi\":[%d, %d, %d, %d]",-1, -1, -1, -1);
}
header.append(h);
std::cout<< "New json header: " << header << std::endl;
setReceiverOnline(ONLINE_FLAG);
setNetworkParameter(ADDITIONAL_JSON_HEADER, header);
/***** END FOR ZMQ HEADER */
ret=OK;
if(thisDetector->myDetectorType==JUNGFRAUCTB) {
thisDetector->nROI = n;
thisDetector->roiLimits[0].xmin=roiLimits[0].xmin;
thisDetector->roiLimits[0].xmax=roiLimits[0].xmax;
thisDetector->roiLimits[0].ymin=roiLimits[0].ymin;
thisDetector->roiLimits[0].ymax=roiLimits[0].ymax;
// std::cout << "** " << thisDetector->nROI << endl;
getTotalNumberOfChannels();
// std::cout << "*** " << thisDetector->nROI << endl;
return ret;
}
// if(thisDetector->myDetectorType==JUNGFRAUCTB)
for(int i=0;i<n;++i){
// cout << "*** ROI "<< i << " xmin " << roiLimits[i].xmin << " xmax "
@ -6023,15 +6318,44 @@ int slsDetector::setROI(int n,ROI roiLimits[]) {
setErrorMask((getErrorMask())|(COULDNOT_SET_ROI));
if(thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels();
return ret;
}
slsDetectorDefs::ROI* slsDetector::getROI(int &n) {
if(thisDetector->myDetectorType==JUNGFRAUCTB) {
int xmin, xmax, ymin, ymax;
string header=getNetworkParameter(ADDITIONAL_JSON_HEADER);
std::cout<< "Json header: " << header << std::endl;
//must be in the format '\"label1\":\"value1\",\"label2\":\"value2\"' etc."
//
size_t pos0;
pos0=header.find("\"roi\"");
if (pos0!=std::string::npos) {
sscanf(header.substr(pos0).c_str(),"\"roi\":[%d, %d, %d, %d]", &xmin, &xmax, &ymin, &ymax);
if (xmin<0 && xmax<0 && ymin<0 && ymax<0)
thisDetector->nROI=0;
else {
thisDetector->nROI=1;
thisDetector->roiLimits[0].xmin=xmin;
thisDetector->roiLimits[0].xmax=xmax;
thisDetector->roiLimits[0].ymin=ymin;
thisDetector->roiLimits[0].ymax=ymax;
}
} else {
thisDetector->nROI=0;
}
// cout << thisDetector->nROI << endl;
getTotalNumberOfChannels();
} else
sendROI(-1,NULL);
n=thisDetector->nROI;
if(thisDetector->myDetectorType==JUNGFRAUCTB) getTotalNumberOfChannels();
return thisDetector->roiLimits;
}

View File

@ -991,9 +991,12 @@ slsDetectorCommand::slsDetectorCommand(slsDetectorUtils *det) {
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdImage;
++i;
/*! \page data
- <b>gainimage fn</b> Loads the gain image to the detector from file fn (gain map for translation into number of photons of an analog detector). Cannot get.
*/
descrToFuncMap[i].m_pFuncName="flatimage"; //
descrToFuncMap[i].m_pFuncPtr=&slsDetectorCommand::cmdImage;
++i;
@ -4089,7 +4092,6 @@ string slsDetectorCommand::cmdNetworkParameter(int narg, char *args[], int actio
t=ADDITIONAL_JSON_HEADER;
}
else return ("unknown network parameter")+cmd;
if (action==PUT_ACTION) {
myDet->setNetworkParameter(t, args[1]);
// switch it back on, if it had been switched on
@ -4454,8 +4456,9 @@ string slsDetectorCommand::cmdDetectorSize(int narg, char *args[], int action) {
if ((val<0) || (narg!=((val*4)+2)) )
return helpDetectorSize(narg,args,action);
ROI allroi[val];
pos=2;
for(i=0;i<val;++i){
pos=1;
// std::cout << val << std::endl;
for(i=0;i<val;i++){
if ((!sscanf(args[++pos],"%d",&allroi[i].xmin)) ||
(!sscanf(args[++pos],"%d",&allroi[i].xmax)) ||
(!sscanf(args[++pos],"%d",&allroi[i].ymin)) ||
@ -5977,6 +5980,22 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
flag=SHOW_OVERFLOW;
else if (sval=="nooverflow")
flag=NOOVERFLOW;
else if (sval=="pedestal")
flag=PEDESTAL;
else if (sval=="flatfield")
flag=FLAT;
else if (sval=="newpedestal")
flag=NEWPEDESTAL;
else if (sval=="newflatfield")
flag=NEWFLAT;
else if (sval=="frame")
flag=FRAME;
else if (sval=="analog")
flag=ANALOG;
else if (sval=="counting")
flag=COUNTING;
else if (sval=="interpolating")
flag=INTERPOLATING;
else
return string("could not scan flag ")+string(args[1]);
}
@ -6009,6 +6028,22 @@ string slsDetectorCommand::cmdAdvanced(int narg, char *args[], int action) {
strcat(answer,"overflow ");
if (retval & NOOVERFLOW)
strcat(answer,"nooverflow ");
if (retval & PEDESTAL)
strcat(answer,"pedestal ");
if (retval & NEWPEDESTAL)
strcat(answer,"newpedestal ");
if (retval & NEWFLAT)
strcat(answer,"newflat ");
if (retval & FLAT)
strcat(answer,"flatfield ");
if (retval & FRAME)
strcat(answer,"frame ");
if (retval & ANALOG)
strcat(answer,"analog ");
if (retval & COUNTING)
strcat(answer,"counting ");
if (retval & INTERPOLATING)
strcat(answer,"interpolating ");
if(strlen(answer))
return string(answer);

View File

@ -1,9 +1,9 @@
Path: slsDetectorsPackage/slsReceiverSoftware
URL: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repository Root: origin git@github.com:slsdetectorgroup/slsDetectorPackage.git
Repsitory UUID: 6bb7195a2c7dc9526088882e0244a7455d3c15b2
Revision: 809
Branch: 3.3.0-rc
Last Changed Author: Dhanya_Thattil
Last Changed Rev: 3941
Last Changed Date: 2018-07-18 12:11:38.000000002 +0200 ./include/HDF5FileStatic.h
Repsitory UUID: 83600fcb15c8261173ab15a8ba8d1009693f2d23
Revision: 813
Branch: anna
Last Changed Author: Anna_Bergamaschi
Last Changed Rev: 3962
Last Changed Date: 2018-09-04 08:41:33.000000002 +0200 ./src/slsReceiverTCPIPInterface.cpp

View File

@ -1,6 +1,6 @@
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
#define GITREPUUID "6bb7195a2c7dc9526088882e0244a7455d3c15b2"
#define GITAUTH "Dhanya_Thattil"
#define GITREV 0x3941
#define GITDATE 0x20180718
#define GITBRANCH "3.3.0-rc"
#define GITREPUUID "83600fcb15c8261173ab15a8ba8d1009693f2d23"
#define GITAUTH "Anna_Bergamaschi"
#define GITREV 0x3962
#define GITDATE 0x20180904
#define GITBRANCH "anna"

View File

@ -216,6 +216,7 @@ void slsReceiverTCPIPInterface::startTCPServer(){
#ifdef VERY_VERBOSE
FILE_LOG(logDEBUG5) << "Conenction accepted";
#endif
// std::cout << "connected" << std::endl;
v = decode_function();
#ifdef VERY_VERBOSE
FILE_LOG(logDEBUG5) << "function executed";
@ -2612,11 +2613,12 @@ int slsReceiverTCPIPInterface::set_additional_json_header() {
char arg[MAX_STR_LENGTH];
memset(arg, 0, sizeof(arg));
char* retval=NULL;
// std::cout << "set additional json header" << std::endl;
// receive arguments
if (mySock->ReceiveDataOnly(arg,MAX_STR_LENGTH) < 0 )
return printSocketReadError();
// std::cout << arg << endl;
// execute action
#ifdef SLS_RECEIVER_UDP_FUNCTIONS
if (receiverBase == NULL)