mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-23 06:50:02 +02:00
Merge branch 'developer' of github.com:slsdetectorgroup/slsDetectorPackage into developer
This commit is contained in:
commit
f1333c7a90
@ -709,6 +709,7 @@ template <class dataType> class analogDetector {
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Sets region of interest in which data should be processed
|
||||
\param xmi minimum x. if -1 or out of range remains unchanged
|
||||
|
@ -43,7 +43,7 @@ class mythen3_01_jctbData : public slsDetectorData<short unsigned int> {
|
||||
}
|
||||
|
||||
|
||||
static short unsigned int* mythen03_frame(char *ptr, int dr=24, int nch=64*3, int off=5) {
|
||||
virtual short unsigned int* mythen03_frame(char *ptr, int dr=24, int nch=64*3, int off=5) {
|
||||
// off=0;
|
||||
int iarg;
|
||||
int64_t word, *wp;
|
||||
|
127
slsDetectorCalibration/dataStructures/Mythen3_02_jctbData.h
Normal file
127
slsDetectorCalibration/dataStructures/Mythen3_02_jctbData.h
Normal file
@ -0,0 +1,127 @@
|
||||
#ifndef MYTHEN302JCTBDATA_H
|
||||
#define MYTHEN302JCTBDATA_H
|
||||
|
||||
|
||||
#include "Mythen3_01_jctbData.h"
|
||||
//class mythen3_02_jctbData : public slsDetectorData<short unsigned int> {
|
||||
class mythen3_02_jctbData : public mythen3_01_jctbData {
|
||||
|
||||
|
||||
public:
|
||||
mythen3_02_jctbData( int nch=64*3,int dr=24, int off=5): mythen3_01_jctbData( nch,dr, off)
|
||||
//slsDetectorData<short unsigned int>(64*3,1,dr*8*nch,NULL,NULL,NULL), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch)
|
||||
{};
|
||||
|
||||
/* virtual void getPixel(int ip, int &x, int &y) {x=-1; y=-1;}; */
|
||||
|
||||
/* virtual short unsigned int getChannel(char *data, int ix, int iy=0) { */
|
||||
/* int ret=-1; */
|
||||
/* short unsigned int *val=mythen03_frame(data,dynamicRange,numberOfCounters,serialOffset); */
|
||||
/* if (ix>=0 && ix<numberOfCounters) ret=val[ix]; */
|
||||
/* delete [] val; */
|
||||
/* return ret; */
|
||||
/* }; */
|
||||
|
||||
/* virtual int getFrameNumber(char *buff) {return frameNumber;}; */
|
||||
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize) { */
|
||||
/* ndata=dsize; */
|
||||
/* return data; */
|
||||
/* } */
|
||||
|
||||
/* virtual char *readNextFrame(ifstream &filebin) { */
|
||||
/* char *data=NULL; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* data=new char[dataSize]; */
|
||||
/* filebin.read(data,dataSize); */
|
||||
/* } */
|
||||
/* return data; */
|
||||
/* } */
|
||||
|
||||
/* virtual short unsigned int **getData(char *ptr, int dsize=-1) { */
|
||||
/* short unsigned int **val; */
|
||||
/* val=new short unsigned int*[1]; */
|
||||
/* val[0]=mythen03_frame(ptr,dynamicRange,nx,serialOffset); */
|
||||
/* return val; */
|
||||
|
||||
/* } */
|
||||
|
||||
|
||||
virtual short unsigned int* mythen03_frame(char *ptr, int dr=24, int nch=64*3, int off=5) {
|
||||
// off=0;
|
||||
int iarg;
|
||||
int64_t word, *wp;
|
||||
short unsigned int* val=new short unsigned int[nch];
|
||||
int bit[64];
|
||||
int nb=2;
|
||||
int ioff=0;
|
||||
int idr=0;
|
||||
int ib=0;
|
||||
int iw=0;
|
||||
int ii=0;
|
||||
bit[0]=17;//19;
|
||||
bit[1]=6;//8;
|
||||
idr=0;
|
||||
for (ib=0; ib<nch; ib++) {
|
||||
val[ib]=0;
|
||||
}
|
||||
wp=(int64_t*)ptr;
|
||||
|
||||
for (iw=0; iw<nch/nb; iw) {
|
||||
word=*wp;;
|
||||
if (ioff<off) {
|
||||
ioff++;
|
||||
cout <<"*";
|
||||
} else {
|
||||
|
||||
if (idr<16) {
|
||||
for (ib=0; ib<nb; ib++) {
|
||||
if (word&(1<<bit[ib])) {
|
||||
cout << "+" ;
|
||||
val[iw+nch*(ib/nb)]|=(1<<idr);
|
||||
} else {
|
||||
cout << "-" ;
|
||||
}
|
||||
}//end for()
|
||||
}
|
||||
|
||||
idr++;
|
||||
|
||||
|
||||
if (idr==dr) {
|
||||
idr=0;
|
||||
// cout << dec << " " << iw << " " << val[iw] << " " << val[iw+nch/2] << endl;
|
||||
cout <<dec << iw<<endl;
|
||||
iw++;
|
||||
}//end if()
|
||||
|
||||
}//end else()
|
||||
wp+=1;
|
||||
ii++;
|
||||
}//end for
|
||||
|
||||
cout << "Decoded "<<ii << " samples"<< endl;
|
||||
cout << "Should be "<< nch/nb*dr+off << " samples"<< endl;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
/* virtual int setFrameNumber(int f=0) {if (f>=0) frameNumber=f; return frameNumber; }; */
|
||||
/* virtual int setDynamicRange(int d=-1) {if (d>0 && d<=24) dynamicRange=d; return dynamicRange;}; */
|
||||
/* virtual int setSerialOffset(int d=-1) {if (d>=0) serialOffset=d; return serialOffset;}; */
|
||||
/* virtual int setNumberOfCounters(int d=-1) {if (d>=0) numberOfCounters=d; return numberOfCounters;}; */
|
||||
|
||||
|
||||
/* private: */
|
||||
|
||||
/* int dynamicRange; */
|
||||
/* int serialOffset; */
|
||||
/* int frameNumber; */
|
||||
/* int numberOfCounters; */
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -31,23 +31,28 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
|
||||
*/
|
||||
|
||||
|
||||
moench02CtbData(int ns=6400): slsDetectorData<uint16_t>(160, 160, ns*2*32, NULL, NULL) , nadc(4), sc_width(40), sc_height(160) {
|
||||
moench02CtbData(int ns=6400): slsDetectorData<uint16_t>(160, 160, ns*2*32, NULL, NULL) , nadc(32), sc_width(40), sc_height(160) {
|
||||
|
||||
|
||||
int adc_nr[4]={120,0,80,40};
|
||||
int adc_off[4]={0,40,80,120};
|
||||
int adc_nr[4]={8,10,20,23};
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int iadc, iiadc;
|
||||
int ix, iy;
|
||||
maplength=this->getDataSize()/2;
|
||||
|
||||
//cout << maplength << endl;
|
||||
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
for (iiadc=0; iiadc<4; iiadc++) {
|
||||
|
||||
iadc=adc_nr[iiadc];
|
||||
//cout << iiadc << endl;
|
||||
for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=adc_nr[iadc]+(i%sc_width);
|
||||
|
||||
col=adc_off[iiadc]+(i%sc_width);
|
||||
row=i/sc_width;
|
||||
dataMap[row][col]=(32*i+iadc+2)*2;
|
||||
dataMap[row][col]=(32*i+iadc)*2;
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=dataSize) {
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
@ -56,12 +61,17 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
|
||||
}
|
||||
|
||||
for (int i=0; i<maplength; i++) {
|
||||
//cout << i << endl;
|
||||
isample=i/32;
|
||||
iadc=i%32;
|
||||
iiadc=i%32;
|
||||
iadc=-1;
|
||||
for (int iii=0; iii<4; iii++) {
|
||||
if (iiadc==adc_nr[iii]) iadc=iii;
|
||||
}
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
if(iadc>1 && iadc<6){
|
||||
xmap[i]=adc_nr[iadc-2]+ix;
|
||||
if(iadc>=0){
|
||||
xmap[i]=adc_off[iadc]+ix;
|
||||
ymap[i]=iy;
|
||||
}else{
|
||||
xmap[i]=-1;
|
||||
@ -71,7 +81,7 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
|
||||
iframe=0;
|
||||
cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
|
||||
void getPixel(int ip, int &x, int &y) {
|
||||
if(ip>=0 && ip<maplength){
|
||||
x=xmap[ip];
|
||||
@ -137,7 +147,9 @@ class moench02CtbData : public slsDetectorData<uint16_t> {
|
||||
}
|
||||
if (ib>0) {
|
||||
iframe++;
|
||||
//cout << ib << "-" << endl;
|
||||
//cout << ib/2 << "-" << endl;
|
||||
//for (int i=0; i<ib/2; i++)
|
||||
//cout << i << " " << afifo_cont[i] << endl;
|
||||
return (char*)afifo_cont;
|
||||
} else {
|
||||
delete [] afifo_cont;
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "slsInterpolation.h"
|
||||
|
||||
#define M015
|
||||
//#define M015
|
||||
|
||||
#ifdef MYROOT1
|
||||
#include <TTree.h>
|
||||
@ -17,10 +17,7 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
#define XMIN 350/2
|
||||
#define XMAX 600/2
|
||||
#define YMIN 0
|
||||
#define YMAX 400
|
||||
|
||||
|
||||
class interpolatingDetector : public singlePhotonDetector {
|
||||
|
||||
@ -50,8 +47,8 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
commonModeSubtraction *cm=NULL,
|
||||
int nped=1000,
|
||||
int nd=100, int nnx=-1, int nny=-1) :
|
||||
singlePhotonDetector(d, 3,nsigma,sign, cm, nped, nd, nnx, nny) , interp(inte), id(0), xmin(XMIN), xmax(XMAX), ymin(YMIN), ymax(YMAX) {
|
||||
cout << "**"<< xmin << " " << xmax << " " << ymin << " " << ymax << endl;
|
||||
singlePhotonDetector(d, 3,nsigma,sign, cm, nped, nd, nnx, nny) , interp(inte), id(0) {
|
||||
//cout << "**"<< xmin << " " << xmax << " " << ymin << " " << ymax << endl;
|
||||
|
||||
};
|
||||
|
||||
@ -60,10 +57,10 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
interpolatingDetector(interpolatingDetector *orig) : singlePhotonDetector(orig) {
|
||||
interp=(orig->interp)->Clone();
|
||||
id=orig->id;
|
||||
xmin=orig->xmin;
|
||||
xmax=orig->xmax;
|
||||
ymin=orig->ymin;
|
||||
ymax=orig->ymax;
|
||||
/* xmin=orig->xmin; */
|
||||
/* xmax=orig->xmax; */
|
||||
/* ymin=orig->ymin; */
|
||||
/* ymax=orig->ymax; */
|
||||
|
||||
}
|
||||
|
||||
@ -157,10 +154,10 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
|
||||
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;
|
||||
|
||||
@ -169,6 +166,7 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
|
||||
return 0;
|
||||
}
|
||||
newFrame();
|
||||
// cout << "********** Data "<< endl;
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
|
||||
@ -185,8 +183,8 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
|
||||
|
||||
eventMask[iy][ix]=PEDESTAL;
|
||||
|
||||
|
||||
(clusters+nph)->rms=getPedestalRMS(ix,iy);
|
||||
rms=getPedestalRMS(ix,iy);
|
||||
(clusters+nph)->rms=rms;
|
||||
|
||||
|
||||
|
||||
@ -213,7 +211,7 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
|
||||
|
||||
|
||||
if (ir==0 && ic==0) {
|
||||
if (*v<-nSigma*cluster->rms)
|
||||
if (*v<-nSigma*rms)
|
||||
eventMask[iy][ix]=NEGATIVE_PEDESTAL;
|
||||
}
|
||||
|
||||
@ -234,7 +232,7 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
|
||||
(clusters+nph)->quadTot=tr;
|
||||
}
|
||||
|
||||
if (max>nSigma*cluster->rms || tot>sqrt(clusterSizeY*clusterSize)*nSigma*cluster->rms || ((clusters+nph)->quadTot)>sqrt(cy*cs)*nSigma*cluster->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;
|
||||
(clusters+nph)->tot=tot;
|
||||
@ -646,8 +644,6 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
|
||||
|
||||
slsInterpolation *interp;
|
||||
int id;
|
||||
//should put it to analogDetector
|
||||
int xmin, xmax, ymin, ymax;
|
||||
};
|
||||
|
||||
|
||||
|
@ -97,7 +97,9 @@ class etaInterpolationBase : public slsInterpolation {
|
||||
#ifndef MYROOT1
|
||||
int *setEta(int *h, int nb=-1, double emin=1, double emax=0)
|
||||
{
|
||||
if (h) {heta=h;
|
||||
if (h) {
|
||||
if (heta) delete [] heta;
|
||||
heta=h;
|
||||
nbeta=nb;
|
||||
if (nb<=0) nbeta=nSubPixels*10;
|
||||
etamin=emin;
|
||||
|
@ -15,11 +15,11 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
||||
|
||||
etaInterpolationPosXY(etaInterpolationPosXY *orig): etaInterpolationBase(orig) {};
|
||||
|
||||
virtual etaInterpolationPosXY* Clone()=0;/** {
|
||||
virtual etaInterpolationPosXY* Clone()=0; /* { */
|
||||
|
||||
return new etaInterpolationPosXY(this);
|
||||
/* return new etaInterpolationPosXY(this); */
|
||||
|
||||
};*/
|
||||
/* }; */
|
||||
|
||||
virtual void prepareInterpolation(int &ok)
|
||||
{
|
||||
|
@ -40,7 +40,21 @@ class linearInterpolation : public slsInterpolation{
|
||||
return;
|
||||
};
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y)
|
||||
{
|
||||
double sDum[2][2];
|
||||
double tot, totquad;
|
||||
double etax,etay;
|
||||
|
||||
int corner;
|
||||
corner=calcQuad(data, tot, totquad, sDum);
|
||||
if (nSubPixels>2)
|
||||
calcEta(totquad, sDum, etax, etay);
|
||||
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,double *cl,double &int_x, double &int_y) {
|
||||
|
||||
double eta_x, eta_y;
|
||||
@ -78,6 +92,7 @@ class linearInterpolation : public slsInterpolation{
|
||||
cc[1][1]=cluster[yoff+1][xoff+1];
|
||||
calcEta(totquad,cc,eta_x,eta_y);
|
||||
}
|
||||
// cout << x << " " << y << " " << eta_x << " " << eta_y << " " << int_x << " " << int_y << endl;
|
||||
return getInterpolatedPosition(x,y,eta_x, eta_y,quad,int_x,int_y);
|
||||
|
||||
|
||||
@ -86,6 +101,49 @@ class linearInterpolation : public slsInterpolation{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y) {
|
||||
|
||||
double cc[2][2];
|
||||
int *cluster[3];
|
||||
int xoff, yoff;
|
||||
cluster[0]=cl;
|
||||
cluster[1]=cl+3;
|
||||
cluster[2]=cl+6;
|
||||
|
||||
switch (quad) {
|
||||
case BOTTOM_LEFT:
|
||||
xoff=0;
|
||||
yoff=0;
|
||||
break;
|
||||
case BOTTOM_RIGHT:
|
||||
xoff=1;
|
||||
yoff=0;
|
||||
break;
|
||||
case TOP_LEFT:
|
||||
xoff=0;
|
||||
yoff=1;
|
||||
break;
|
||||
case TOP_RIGHT:
|
||||
xoff=1;
|
||||
yoff=1;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
double etax, etay;
|
||||
if (nSubPixels>2) {
|
||||
cc[0][0]=cluster[yoff][xoff];
|
||||
cc[1][0]=cluster[yoff+1][xoff];
|
||||
cc[0][1]=cluster[yoff][xoff+1];
|
||||
cc[1][1]=cluster[yoff+1][xoff+1];
|
||||
calcEta(totquad,cc,etax,etay);
|
||||
}
|
||||
// cout << x << " " << y << " " << etax << " " << etay << " " << int_x << " " << int_y << endl;
|
||||
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -125,11 +183,11 @@ class linearInterpolation : public slsInterpolation{
|
||||
ypos_eta=(etay)+dY;
|
||||
} else {
|
||||
xpos_eta=0.5*dX+0.25;
|
||||
xpos_eta=0.5*dY+0.25;
|
||||
ypos_eta=0.5*dY+0.25;
|
||||
}
|
||||
int_x=((double)x) + xpos_eta;
|
||||
int_y=((double)y) + ypos_eta;
|
||||
|
||||
// cout <<"**"<< x << " " << y << " " << xpos_eta << " " << ypos_eta << " " << corner << endl;
|
||||
return;
|
||||
};
|
||||
|
||||
@ -162,8 +220,10 @@ class linearInterpolation : public slsInterpolation{
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual int addToFlatField(double *cluster, double &etax, double &etay){};
|
||||
virtual int addToFlatField(int *cluster, double &etax, double &etay){};
|
||||
virtual int addToFlatField(double etax, double etay){};
|
||||
virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay) {};
|
||||
virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay) {};
|
||||
|
||||
protected:
|
||||
;
|
||||
|
@ -24,7 +24,10 @@
|
||||
#endif
|
||||
#include <memory.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
//#ifdef MYROOT1
|
||||
//: public TObject
|
||||
//#endif
|
||||
@ -84,7 +87,13 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
||||
#endif
|
||||
|
||||
#ifndef MYROOT1
|
||||
virtual int *getInterpolatedImage(){return hint;};
|
||||
virtual int *getInterpolatedImage(){
|
||||
// cout << "return interpolated image " << endl;
|
||||
/* for (int i=0; i<nSubPixels* nSubPixels* nPixelsX*nPixelsY; i++) { */
|
||||
/* cout << i << " " << hint[i] << endl; */
|
||||
/* } */
|
||||
return hint;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@ -146,8 +155,13 @@ hint=new TH2F("hint","hint",ns*nx, 0, nx, ns*ny, 0, ny);
|
||||
virtual int *addToImage(double int_x, double int_y){
|
||||
int iy=((double)nSubPixels)*int_y;
|
||||
int ix=((double)nSubPixels)*int_x;
|
||||
// cout << int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << endl;
|
||||
if (ix>=0 && ix<(nPixelsX*nSubPixels) && iy<(nSubPixels*nPixelsY) && iy>=0 )(*(hint+ix+iy*nPixelsX*nSubPixels))+=1;
|
||||
if (ix>=0 && ix<(nPixelsX*nSubPixels) && iy<(nSubPixels*nPixelsY) && iy>=0 ){
|
||||
// cout << int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << " " << hint[ix+iy*nPixelsX*nSubPixels];
|
||||
(*(hint+ix+iy*nPixelsX*nSubPixels))+=1;
|
||||
// cout << " " << hint[ix+iy*nPixelsX*nSubPixels] << endl;
|
||||
}// else
|
||||
// cout << "bad! "<< int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << endl;
|
||||
|
||||
return hint;
|
||||
};
|
||||
#endif
|
||||
|
@ -2,14 +2,15 @@
|
||||
CBFLIBDIR=/afs/psi.ch/project/sls_det_software/CBFlib-0.9.5
|
||||
ZMQLIB=../../slsReceiverSoftware/include
|
||||
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
INCDIR=-I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -I../interpolations/etaVEL -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/
|
||||
INCDIR=-I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/
|
||||
LIBHDF5=
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff -L$(ZMQLIB)
|
||||
#-I../interpolations/etaVEL
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -lhdf5 -ltiff -L$(ZMQLIB) -L$(CBFLIBDIR)/lib/
|
||||
#-L../../bin
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moenchZmqClusterFinder moenchZmqInterpolating
|
||||
all: moenchZmqClusterFinder moenchZmqInterpolating moenchZmqAnalog
|
||||
|
||||
|
||||
moenchZmqInterpolating: $(MAIN) $(INCS) clean
|
||||
@ -18,6 +19,10 @@ moenchZmqInterpolating: $(MAIN) $(INCS) clean
|
||||
moenchZmqClusterFinder: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchZmqClusterFinder moenchZmqClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
clean:
|
||||
rm -f moench03ZmqOnTheFlyEta moench03ZmqClusterFinder
|
||||
moenchZmqAnalog: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchZmqAnalog moenchZmqAnalog.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
clean:
|
||||
rm -f moench03ZmqInterpolating moench03ZmqClusterFinder moenchZmqAnalog
|
||||
|
||||
|
||||
|
@ -0,0 +1,22 @@
|
||||
|
||||
CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
|
||||
#ZMQLIB=../slsReceiverSoftware/include
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/
|
||||
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff
|
||||
MAIN=moench03ReorderImage.cpp
|
||||
|
||||
all: moenchReorderImage moenchClusterFinder
|
||||
|
||||
|
||||
|
||||
moenchReorderImage: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchReorderImage $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER
|
||||
|
||||
moenchClusterFinder: moench03ClusterFinder.cpp
|
||||
g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER
|
||||
|
||||
|
||||
clean:
|
||||
rm -f moenchReorderImage moenchClusterFinder
|
||||
|
||||
|
@ -2,12 +2,14 @@
|
||||
#INCS= $(INCSROOT) moench03_receiver.h
|
||||
#LINKDEF=receiverGuiLinkDef.h
|
||||
|
||||
CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
|
||||
ZMQLIB=../slsReceiverSoftware/include
|
||||
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I$(ROOTSYS)/include
|
||||
#CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
|
||||
#ZMQLIB=../slsReceiverSoftware/include
|
||||
#LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include -I$(ROOTSYS)/include
|
||||
#-I$(CBFLIBDIR)/include/
|
||||
#LIBHDF5=
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -ltiff
|
||||
#-L$(CBFLIBDIR)/lib/ -lhdf5
|
||||
|
||||
MAIN=tiff_to_th2f.cpp
|
||||
|
||||
@ -18,8 +20,8 @@ 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) ../tiffIO.cpp
|
||||
#$(LIBRARYCBF) $(LIBHDF5)
|
||||
clean:
|
||||
rm -f tiff_to_th2f
|
||||
|
||||
|
@ -40,7 +40,7 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=8;
|
||||
int nthreads=1;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
|
@ -30,9 +30,10 @@ int main(int argc, char *argv[]) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " << endl;
|
||||
return 0;
|
||||
}
|
||||
int ii=0;
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=1;
|
||||
int nthreads=5;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
@ -165,6 +166,14 @@ int main(int argc, char *argv[]) {
|
||||
mt->popFree(buff);
|
||||
|
||||
ff=-1;
|
||||
ii++;
|
||||
if (ii%10000==0) {
|
||||
|
||||
cout << ii << endl;
|
||||
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
mt->writeImage("/scratch/tmp.tiff");
|
||||
}
|
||||
}
|
||||
// cout << "--" << endl;
|
||||
filebin.close();
|
||||
|
@ -0,0 +1,163 @@
|
||||
//#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
|
||||
#include "moench03T1ReceiverDataNew.h"
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include <ctime>
|
||||
using namespace std;
|
||||
|
||||
#define NX 400 //number of x pixels
|
||||
#define NY 400 //number of y pixels
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
if (argc<6) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " << endl;
|
||||
return 1;
|
||||
}
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=8;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
int iprog=0;
|
||||
|
||||
|
||||
|
||||
|
||||
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
|
||||
|
||||
|
||||
uint16_t data[NY*NX];
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
int* image;
|
||||
|
||||
int ff, np;
|
||||
int dsize=decoder->getDataSize();
|
||||
|
||||
|
||||
//char data[dsize];
|
||||
|
||||
ifstream filebin;
|
||||
char *indir=argv[1];
|
||||
char *outdir=argv[2];
|
||||
char *fformat=argv[3];
|
||||
int runmin=atoi(argv[4]);
|
||||
int runmax=atoi(argv[5]);
|
||||
|
||||
char fname[10000];
|
||||
char outfname[10000];
|
||||
char imgfname[10000];
|
||||
char pedfname[10000];
|
||||
// strcpy(pedfname,argv[6]);
|
||||
char fn[10000];
|
||||
|
||||
std::time_t end_time;
|
||||
|
||||
FILE *of=NULL;
|
||||
cout << "input directory is " << indir << endl;
|
||||
cout << "output directory is " << outdir << endl;
|
||||
cout << "fileformat is " << fformat << endl;
|
||||
|
||||
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
char* buff;
|
||||
|
||||
|
||||
|
||||
|
||||
int ifr=0;
|
||||
|
||||
|
||||
for (int irun=runmin; irun<runmax; irun++) {
|
||||
sprintf(fn,fformat,irun);
|
||||
sprintf(fname,"%s/%s.raw",indir,fn);
|
||||
sprintf(outfname,"%s/%s_image.raw",outdir,fn);
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
cout << fname << " " << outfname << " " << imgfname << endl;
|
||||
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||
// //open file
|
||||
if (filebin.is_open()){
|
||||
of=fopen(outfname,"w");
|
||||
if (of) {
|
||||
;
|
||||
} else {
|
||||
cout << "Could not open "<< outfname << " for writing " << endl;
|
||||
return 1;
|
||||
}
|
||||
// //while read frame
|
||||
ff=-1;
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
for (int ix=0; ix<400; ix++)
|
||||
for (int iy=0; iy<400; iy++)
|
||||
data[iy*NX+ix]=decoder->getChannel(buff,ix,iy);
|
||||
|
||||
ifr++;
|
||||
|
||||
fwrite(&ff, 8, 1,of);//write detector frame number
|
||||
fwrite(&ifr, 8, 1,of);//write datset frame number
|
||||
fwrite(data,2,NX*NY,of);//write reordered data
|
||||
|
||||
if (ifr%10000==0) cout << ifr << " " << ff << endl;
|
||||
ff=-1;
|
||||
|
||||
}
|
||||
cout << "--" << endl;
|
||||
filebin.close();
|
||||
// //close file
|
||||
// //join threads
|
||||
|
||||
if (of)
|
||||
fclose(of);
|
||||
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
} else
|
||||
cout << "Could not open "<< fname << " for reading " << endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,272 +0,0 @@
|
||||
#include "ZmqSocket.h"
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
#include "interpolatingDetector.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=20;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
int iprog=0;
|
||||
char outfname[10000];
|
||||
|
||||
|
||||
moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
// cout << "decoder "<< endl;
|
||||
//etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
|
||||
// linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
|
||||
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
//interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 100);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
|
||||
char tit[10000];
|
||||
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
char* buff;
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
//mt->setFrameMode(eFrame);
|
||||
mt->setFrameMode(eFlat);
|
||||
|
||||
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
// help
|
||||
if (argc < 2 || (argc > 2)) {
|
||||
cprintf(RED, "Help: %s [receive socket ip]\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip = argv[1];
|
||||
uint32_t portnum = 30001;//atoi(argv[2]);
|
||||
// char fn[10000];
|
||||
// strcpy(fn, argv[2]);
|
||||
// send parameters if any
|
||||
// char* socketip2 = 0;
|
||||
// uint32_t portnum2 = 0;
|
||||
// if (argc > 4) {
|
||||
// send = true;
|
||||
// socketip2 = argv[4];
|
||||
// portnum2 = atoi(argv[5]);
|
||||
// }
|
||||
cout << "\nrx socket ip : " << socketip ; // <<
|
||||
// "\nrx port num : " << portnum <<
|
||||
// "\nsize : " << size;
|
||||
// "\nfname : " << fn ;
|
||||
// if (send) {
|
||||
// cout << "\nsd socket ip : " << socketip2 <<
|
||||
// "\nsd port num : " << portnum2;
|
||||
// }
|
||||
cout << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
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;
|
||||
}
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
// ZmqSocket* zmqsocket2 = 0;
|
||||
// if (send) {
|
||||
// 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);
|
||||
// delete zmqsocket2;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
// }
|
||||
|
||||
|
||||
// cout << "size " << 327680/sizeof(int) << endl;
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
string filename = "";
|
||||
int nnx, nny, nns;
|
||||
int imsize=filter->getImageSize(nnx,nny,nns);
|
||||
//int imsize=nx*ny;
|
||||
int i_image=0;
|
||||
cout << "Image size is "<< nnx << " " << nny << " " << nns << " " << imsize << endl;
|
||||
int iframe=0;
|
||||
int ff=0;
|
||||
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// cprintf(GREEN, "Got ?\n");
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
|
||||
cprintf(RED, "Acquisition finished\n");
|
||||
|
||||
|
||||
|
||||
cout << "Received " << ff << " frames for a total of "<< iframe << endl;
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
// if (send) {
|
||||
// zmqsocket2->SendData((char*)(mt->getImage()),imsize*sizeof(int));
|
||||
// cprintf(BLUE, "Sent Interpolated image\n");
|
||||
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// // cprintf(RED, "Sent Dummy\n");
|
||||
// }
|
||||
// if (save) {
|
||||
sprintf(tit,"%s_%05d.tiff",filename.c_str(), ff);
|
||||
// cout << tit << endl;
|
||||
mt->writeImage(tit);
|
||||
mt->clearImage();
|
||||
// }
|
||||
// sprintf(tit,"%s_%05d_eta_i.tiff",filename.c_str(), ff);
|
||||
// interp->writeFlatField(tit);
|
||||
// sprintf(tit,"%s_%05d_eta.tiff",filename.c_str(), ff);
|
||||
// cout << tit << endl;
|
||||
// mt->writeFlatField(tit);
|
||||
|
||||
i_image++;
|
||||
ff=0;
|
||||
// dont get data
|
||||
continue; //continue to not get out
|
||||
}
|
||||
|
||||
if (ff==0)
|
||||
cprintf(GREEN, "Start acquisition \n");
|
||||
// cout << filename << endl;
|
||||
// cprintf(GREEN, "Got Header \n");
|
||||
// get data
|
||||
// cprintf(GREEN, "Got Header\n");
|
||||
//image=(int*)buff;
|
||||
//cout << buff << endl;
|
||||
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
|
||||
// int length = zmqsocket->ReceiveData(0, (int*)image, size);
|
||||
// cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
|
||||
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
iframe++;
|
||||
ff++;
|
||||
// if (iframe%p==0) {
|
||||
|
||||
// while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
// sprintf(tit,"tmp.tiff",filename.c_str(), i_image);
|
||||
// mt->writeImage(tit);
|
||||
// // mt->clearImage();
|
||||
// // }
|
||||
// //interp->writeFlatField(tit);
|
||||
// // i_image++;
|
||||
// // sprintf(tit,"%s_tmp.tiff",fn);
|
||||
// // mt->writeImage(tit);
|
||||
// // //mt->clearImage();
|
||||
|
||||
// // cout <<"*"<< iprog++ << endl;
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //stream data from socket 2
|
||||
// if (send) {
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
|
||||
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
// cprintf(GREEN, "Sent Header\n");
|
||||
|
||||
// zmqsocket2->SendData((char*)image,length);
|
||||
// cprintf(GREEN, "Sent Data\n");
|
||||
// }
|
||||
|
||||
|
||||
}// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
// if (send)
|
||||
// delete zmqsocket2;
|
||||
|
||||
|
||||
// cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,306 +0,0 @@
|
||||
#include "ZmqSocket.h"
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
#include "interpolatingDetector.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
|
||||
int p=1000; //1.5s with 15ms period
|
||||
int fifosize=1000;
|
||||
int nthreads=8;
|
||||
int nsubpix=2;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
int iprog=0;
|
||||
char outfname[10000];
|
||||
|
||||
if (nsubpix>2) p=5000;
|
||||
|
||||
|
||||
moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
// cout << "decoder "<< endl;
|
||||
etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
|
||||
// linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
|
||||
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 100);
|
||||
// singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
|
||||
char tit[10000];
|
||||
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
char* buff;
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
//
|
||||
if (nsubpix>2)
|
||||
mt->setFrameMode(eFlat);
|
||||
else
|
||||
mt->setFrameMode(eFrame);
|
||||
|
||||
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
// help
|
||||
if (argc < 2 || (argc > 2)) {
|
||||
cprintf(RED, "Help: %s [receive socket ip]\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip = argv[1];
|
||||
uint32_t portnum = 30001;//atoi(argv[2]);
|
||||
// char fn[10000];
|
||||
// strcpy(fn, argv[2]);
|
||||
// send parameters if any
|
||||
// char* socketip2 = 0;
|
||||
// uint32_t portnum2 = 0;
|
||||
// if (argc > 4) {
|
||||
// send = true;
|
||||
// socketip2 = argv[4];
|
||||
// portnum2 = atoi(argv[5]);
|
||||
// }
|
||||
cout << "\nrx socket ip : " << socketip ; // <<
|
||||
// "\nrx port num : " << portnum <<
|
||||
// "\nsize : " << size;
|
||||
// "\nfname : " << fn ;
|
||||
// if (send) {
|
||||
// cout << "\nsd socket ip : " << socketip2 <<
|
||||
// "\nsd port num : " << portnum2;
|
||||
// }
|
||||
cout << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
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;
|
||||
}
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
// ZmqSocket* zmqsocket2 = 0;
|
||||
// if (send) {
|
||||
// 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);
|
||||
// delete zmqsocket2;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
// }
|
||||
|
||||
|
||||
// cout << "size " << 327680/sizeof(int) << endl;
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
string filename = "";
|
||||
int nnx, nny, nns;
|
||||
int imsize=filter->getImageSize(nnx,nny,nns);
|
||||
//int imsize=nx*ny;
|
||||
int i_image=0;
|
||||
cout << "Image size is "<< nnx << " " << nny << " " << nns << " " << imsize << endl;
|
||||
int iframe=0;
|
||||
int ff=0;
|
||||
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// cprintf(GREEN, "Got ?\n");
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
|
||||
cprintf(RED, "Acquisition finished\n");
|
||||
|
||||
|
||||
|
||||
cout << "Received " << ff << " frames for a total of "<< iframe << endl;
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
// if (send) {
|
||||
// zmqsocket2->SendData((char*)(mt->getImage()),imsize*sizeof(int));
|
||||
// cprintf(BLUE, "Sent Interpolated image\n");
|
||||
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// // cprintf(RED, "Sent Dummy\n");
|
||||
// }
|
||||
// if (save) {
|
||||
// if (iframe>p) {
|
||||
sprintf(tit,"%s_%05d_%05d.tiff",filename.c_str(), ff, i_image);
|
||||
cout << tit << endl;
|
||||
mt->writeImage(tit);
|
||||
sprintf(tit,"/home/l_msdetect/slsbl/x07mb/x07mbop/Data1/2017/11/06/tmp.tiff");
|
||||
cout <<"*"<< iframe<< endl;
|
||||
mt->writeImage(tit);
|
||||
mt->clearImage();
|
||||
//}
|
||||
|
||||
|
||||
|
||||
// }
|
||||
//sprintf(tit,"%s_%05d_eta_i.tiff",filename.c_str(), ff);
|
||||
//interp->writeFlatField(tit);
|
||||
// sprintf(tit,"%s_%05d_eta_%d.tiff",filename.c_str(), ff, acqIndex);
|
||||
// // cout << tit << endl;
|
||||
// mt->writeFlatField(tit);
|
||||
|
||||
i_image++;
|
||||
ff=0;
|
||||
//filter->newDataSet();
|
||||
|
||||
// dont get data
|
||||
continue; //continue to not get out
|
||||
}
|
||||
|
||||
if (ff==0)
|
||||
cprintf(GREEN, "Start acquisition %d\n",acqIndex);
|
||||
// cout << filename << endl;
|
||||
// cprintf(GREEN, "Got Header \n");
|
||||
// get data
|
||||
// cprintf(GREEN, "Got Header\n");
|
||||
//image=(int*)buff;
|
||||
//cout << buff << endl;
|
||||
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
|
||||
// int length = zmqsocket->ReceiveData(0, (int*)image, size);
|
||||
// cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
|
||||
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
iframe++;
|
||||
if (nsubpix>2) {
|
||||
if (iframe==p) {
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->prepareInterpolation(ok);
|
||||
|
||||
sprintf(tit,"%s_%05d_eta.tiff",filename.c_str(), ff);
|
||||
cout << tit << endl;
|
||||
mt->writeFlatField(tit);
|
||||
}
|
||||
} //else {
|
||||
// cout << iframe << " " << p << endl;
|
||||
if (iframe%p==0) {
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
sprintf(tit,"/home/l_msdetect/slsbl/x07mb/x07mbop/Data1/2017/11/06/tmp.tiff");
|
||||
cout <<"*"<< iframe<< endl;
|
||||
mt->writeImage(tit);
|
||||
// mt->clearImage();
|
||||
}
|
||||
//}
|
||||
ff++;
|
||||
// if (iframe%p==0) {
|
||||
|
||||
// while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
// sprintf(tit,"tmp.tiff",filename.c_str(), i_image);
|
||||
// mt->writeImage(tit);
|
||||
// // mt->clearImage();
|
||||
// // }
|
||||
// //interp->writeFlatField(tit);
|
||||
// // i_image++;
|
||||
// // sprintf(tit,"%s_tmp.tiff",fn);
|
||||
// // mt->writeImage(tit);
|
||||
// // //mt->clearImage();
|
||||
|
||||
// // cout <<"*"<< iprog++ << endl;
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //stream data from socket 2
|
||||
// if (send) {
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
|
||||
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
// cprintf(GREEN, "Sent Header\n");
|
||||
|
||||
// zmqsocket2->SendData((char*)image,length);
|
||||
// cprintf(GREEN, "Sent Data\n");
|
||||
// }
|
||||
|
||||
|
||||
}// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
// if (send)
|
||||
// delete zmqsocket2;
|
||||
|
||||
|
||||
// cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,251 +0,0 @@
|
||||
#include "ZmqSocket.h"
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
//#include "singlePhotonDetector.h"
|
||||
#include "interpolatingDetector.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
|
||||
int p=1000;
|
||||
int fifosize=1000;
|
||||
int nthreads=6;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
int iprog=0;
|
||||
char outfname[10000];
|
||||
|
||||
|
||||
moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
// cout << "decoder "<< endl;
|
||||
etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
|
||||
// linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
|
||||
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
// interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 100);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
|
||||
char tit[10000];
|
||||
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
char* buff;
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
mt->setFrameMode(eFrame);
|
||||
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
// help
|
||||
if (argc < 3 || (argc > 3)) {
|
||||
cprintf(RED, "Help: %s [receive socket ip] [fname]\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip = argv[1];
|
||||
uint32_t portnum = 30001;//atoi(argv[2]);
|
||||
char fn[10000];
|
||||
strcpy(fn, argv[2]);
|
||||
// send parameters if any
|
||||
// char* socketip2 = 0;
|
||||
// uint32_t portnum2 = 0;
|
||||
// if (argc > 4) {
|
||||
// send = true;
|
||||
// socketip2 = argv[4];
|
||||
// portnum2 = atoi(argv[5]);
|
||||
// }
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
// "\nrx port num : " << portnum <<
|
||||
// "\nsize : " << size;
|
||||
"\nfname : " << fn ;
|
||||
// if (send) {
|
||||
// cout << "\nsd socket ip : " << socketip2 <<
|
||||
// "\nsd port num : " << portnum2;
|
||||
// }
|
||||
cout << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
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;
|
||||
}
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
// ZmqSocket* zmqsocket2 = 0;
|
||||
// if (send) {
|
||||
// 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);
|
||||
// delete zmqsocket2;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
// }
|
||||
|
||||
|
||||
cout << "size " << 327680/sizeof(int) << endl;
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
string filename = "";
|
||||
int nnx, nny, nns;
|
||||
int imsize=filter->getImageSize(nnx,nny,nns);
|
||||
//int imsize=nx*ny;
|
||||
int i_image=0;
|
||||
cout << "Image size is "<< nnx << " " << nny << " " << nns << " " << imsize << endl;
|
||||
int iframe=0;
|
||||
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// cprintf(GREEN, "Got ?\n");
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
|
||||
cprintf(RED, "Acquisition finished\n");
|
||||
|
||||
|
||||
|
||||
cout << "Recieved " << iframe << " frames " << endl;
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
// if (send) {
|
||||
// zmqsocket2->SendData((char*)(mt->getImage()),imsize*sizeof(int));
|
||||
// cprintf(BLUE, "Sent Interpolated image\n");
|
||||
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// // cprintf(RED, "Sent Dummy\n");
|
||||
// }
|
||||
// if (save) {
|
||||
sprintf(tit,"%s_%d.tiff",fn, i_image);
|
||||
mt->writeImage(tit);
|
||||
mt->clearImage();
|
||||
// }
|
||||
//interp->writeFlatField(tit);
|
||||
i_image++;
|
||||
// dont get data
|
||||
continue; //continue to not get out
|
||||
}
|
||||
// cprintf(GREEN, "Got Header \n");
|
||||
// get data
|
||||
// cprintf(GREEN, "Got Header\n");
|
||||
//image=(int*)buff;
|
||||
//cout << buff << endl;
|
||||
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
|
||||
// int length = zmqsocket->ReceiveData(0, (int*)image, size);
|
||||
// cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
|
||||
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
iframe++;
|
||||
// if (iframe%p==0) {
|
||||
|
||||
// while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
// sprintf(tit,"%s_tmp.tiff",fn);
|
||||
// mt->writeImage(tit);
|
||||
// //mt->clearImage();
|
||||
|
||||
// cout <<"*"<< iprog++ << endl;
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //stream data from socket 2
|
||||
// if (send) {
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
|
||||
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
// cprintf(GREEN, "Sent Header\n");
|
||||
|
||||
// zmqsocket2->SendData((char*)image,length);
|
||||
// cprintf(GREEN, "Sent Data\n");
|
||||
// }
|
||||
|
||||
|
||||
}// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
// if (send)
|
||||
// delete zmqsocket2;
|
||||
|
||||
|
||||
// cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,219 +0,0 @@
|
||||
#include "ZmqSocket.h"
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
|
||||
#include "interpolatingDetector.h"
|
||||
#include "etaInterpolationPosXY.h"
|
||||
#include "linearInterpolation.h"
|
||||
#include "noInterpolation.h"
|
||||
#include "multiThreadedDetector.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [image size] [send_socket ip] [send port number]
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
|
||||
int nthreads=3;
|
||||
int nsubpix=5;
|
||||
int etabins=550;
|
||||
double etamin=-1, etamax=2;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ok;
|
||||
//int* image = new int[(size/sizeof(int))]();
|
||||
char* buff;
|
||||
|
||||
moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
// cout << "decoder "<< endl;
|
||||
etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
|
||||
//linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
|
||||
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 10);
|
||||
|
||||
|
||||
|
||||
|
||||
filter->readPedestals("/scratch/ped_100.tiff");
|
||||
interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
cout << "filter "<< endl;
|
||||
|
||||
|
||||
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
|
||||
multiThreadedDetector *mt=new multiThreadedDetector(filter,nthreads,100);
|
||||
|
||||
|
||||
|
||||
mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
// help
|
||||
if (argc < 4 || (argc > 4 && argc != 6)) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [image size] [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 size = atoi(argv[3]);
|
||||
|
||||
// send parameters if any
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
if (argc > 4) {
|
||||
send = true;
|
||||
socketip2 = argv[4];
|
||||
portnum2 = atoi(argv[5]);
|
||||
}
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum <<
|
||||
"\nsize : " << size;
|
||||
if (send) {
|
||||
cout << "\nsd socket ip : " << socketip2 <<
|
||||
"\nsd port num : " << portnum2;
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
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;
|
||||
}
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
if (send) {
|
||||
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);
|
||||
delete zmqsocket2;
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
string filename = "";
|
||||
int imsize=nx*ny*nsubpix*nsubpix;
|
||||
int i_image=0;
|
||||
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
|
||||
cprintf(RED, "Acquisition finished\n");
|
||||
|
||||
|
||||
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
if (send) {
|
||||
zmqsocket2->SendData((char*)(mt->getInterpolatedImage()),imsize*sizeof(int));
|
||||
cprintf(BLUE, "Sent Interpolated image\n");
|
||||
// zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// cprintf(RED, "Sent Dummy\n");
|
||||
}
|
||||
if (save) {
|
||||
char tit[10000];
|
||||
sprintf(tit,"/scratch/int_image_%d.tiff",i_image);
|
||||
mt->writeInterpolatedImage(tit);
|
||||
mt->clearInterpolatedImage(tit);
|
||||
}
|
||||
i_image++;
|
||||
// dont get data
|
||||
break; //continue to not get out
|
||||
}
|
||||
cprintf(GREEN, "Got Header \n");
|
||||
// get data
|
||||
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
|
||||
cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //stream data from socket 2
|
||||
// if (send) {
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
|
||||
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
// cprintf(GREEN, "Sent Header\n");
|
||||
|
||||
// zmqsocket2->SendData((char*)image,length);
|
||||
// cprintf(GREEN, "Sent Data\n");
|
||||
// }
|
||||
|
||||
|
||||
}// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
if (send)
|
||||
delete zmqsocket2;
|
||||
|
||||
|
||||
cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,248 +0,0 @@
|
||||
#include "ZmqSocket.h"
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
// #include "etaInterpolationPosXY.h"
|
||||
#include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
//#include "singlePhotonDetector.h"
|
||||
#include "interpolatingDetector.h"
|
||||
|
||||
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
|
||||
int p=1000;
|
||||
int fifosize=1000;
|
||||
int nthreads=6;
|
||||
int nsubpix=2;
|
||||
// int etabins=550;
|
||||
// double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int nx=400, ny=400;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
//int* image = new int[(size/sizeof(int))]();
|
||||
char* buff;
|
||||
int iprog=0;
|
||||
char outfname[10000];
|
||||
|
||||
|
||||
moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
// cout << "decoder "<< endl;
|
||||
//etaInterpolationPosXY *interp=new etaInterpolationPosXY(nx, ny, nsubpix, etabins, etamin, etamax);
|
||||
// linearInterpolation *interp=new linearInterpolation(NC, NR, nsubpix);
|
||||
//noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
// interpolatingDetector *filter=new interpolatingDetector(decoder,interp, nsigma, 1, 0, nped, 10);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
|
||||
char tit[10000];
|
||||
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
|
||||
mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
// help
|
||||
if (argc < 4 || (argc > 4 && argc != 6)) {
|
||||
cprintf(RED, "Help: %s [receive socket ip] [receive starting port number] [fname]\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip = argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
char fn[10000];
|
||||
strcpy(fn, argv[3]);
|
||||
// send parameters if any
|
||||
// char* socketip2 = 0;
|
||||
// uint32_t portnum2 = 0;
|
||||
// if (argc > 4) {
|
||||
// send = true;
|
||||
// socketip2 = argv[4];
|
||||
// portnum2 = atoi(argv[5]);
|
||||
// }
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum <<
|
||||
// "\nsize : " << size;
|
||||
"\nfname : " << fn ;
|
||||
// if (send) {
|
||||
// cout << "\nsd socket ip : " << socketip2 <<
|
||||
// "\nsd port num : " << portnum2;
|
||||
// }
|
||||
cout << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
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;
|
||||
}
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
// ZmqSocket* zmqsocket2 = 0;
|
||||
// if (send) {
|
||||
// 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);
|
||||
// delete zmqsocket2;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
string filename = "";
|
||||
int nnx, nny, nns;
|
||||
int imsize=filter->getImageSize(nnx,nny,nns);
|
||||
//int imsize=nx*ny;
|
||||
int i_image=0;
|
||||
|
||||
int iframe=0;
|
||||
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename)) {
|
||||
cprintf(RED, "Acquisition finished\n");
|
||||
|
||||
|
||||
|
||||
cout << "Recieved " << iframe << " frames " << endl;
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
cout << "threads done " << endl;
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
// if (send) {
|
||||
// zmqsocket2->SendData((char*)(mt->getImage()),imsize*sizeof(int));
|
||||
// cprintf(BLUE, "Sent Interpolated image\n");
|
||||
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// // cprintf(RED, "Sent Dummy\n");
|
||||
// }
|
||||
// if (save) {
|
||||
sprintf(tit,"%s_%d.tiff",fn, i_image);
|
||||
cout << tit << endl;
|
||||
mt->writeImage(tit);
|
||||
cout << "wrote" << endl;
|
||||
mt->clearImage();
|
||||
// }
|
||||
i_image++;
|
||||
// dont get data
|
||||
continue; //continue to not get out
|
||||
}
|
||||
// cprintf(GREEN, "Got Header \n");
|
||||
// get data
|
||||
int length = zmqsocket->ReceiveData(0, (int*)buff, size);
|
||||
// cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
|
||||
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
iframe++;
|
||||
if (iframe%p==0) {
|
||||
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
sprintf(tit,"%s_tmp.tiff",fn);
|
||||
mt->writeImage(tit);
|
||||
//mt->clearImage();
|
||||
|
||||
cout <<"*"<< iprog++ << endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// //stream data from socket 2
|
||||
// if (send) {
|
||||
// zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,
|
||||
// 0,0,0,acqIndex,frameIndex,(char*)"run", acqIndex, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
// cprintf(GREEN, "Sent Header\n");
|
||||
|
||||
// zmqsocket2->SendData((char*)image,length);
|
||||
// cprintf(GREEN, "Sent Data\n");
|
||||
// }
|
||||
|
||||
|
||||
}// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
// if (send)
|
||||
// delete zmqsocket2;
|
||||
|
||||
|
||||
cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
394
slsDetectorCalibration/moenchExecutables/moenchZmqAnalog.cpp
Normal file
394
slsDetectorCalibration/moenchExecutables/moenchZmqAnalog.cpp
Normal file
@ -0,0 +1,394 @@
|
||||
//#define ROOTSPECTRUM
|
||||
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
|
||||
#include "sls_receiver_defs.h"
|
||||
#include "ZmqSocket.h"
|
||||
#include "moench03T1ZmqDataNew.h"
|
||||
|
||||
#ifdef ROOTSPECTRUM
|
||||
#include <TPaveText.h>
|
||||
#include <TLegend.h>
|
||||
#include <TF1.h>
|
||||
#include <TGraphErrors.h>
|
||||
#include <TH2F.h>
|
||||
#include <TASImage.h>
|
||||
#include <TImage.h>
|
||||
#include <TFile.h>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include "tiffIO.h"
|
||||
|
||||
#include<iostream>
|
||||
|
||||
//#include "analogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [send_socket ip] [send port number]
|
||||
*
|
||||
*/
|
||||
int fifosize=1000;
|
||||
int nthreads=20;
|
||||
char* buff;
|
||||
char tit[10000];
|
||||
// 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 size = 32*2*5000;//atoi(argv[3]);
|
||||
|
||||
// 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 << "\nsd socket ip : " << socketip2 <<
|
||||
"\nsd port num : " << portnum2;
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||
analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
|
||||
//singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10);
|
||||
//filter->setROI(250, 400, 30, 150);
|
||||
float threshold=1;
|
||||
if (argc > 5) {
|
||||
threshold=atof(argv[5]);
|
||||
filter->setThreshold(threshold);
|
||||
cout << "Threshold set to " << threshold << endl;
|
||||
}
|
||||
|
||||
int nnx, nny, nns;
|
||||
int imsize=filter->getImageSize(nnx,nny,nns);
|
||||
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
|
||||
cout << "det " << endl;
|
||||
int16_t dout[400*400];
|
||||
double ddark[400*400];
|
||||
cout << "dout " << endl;
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
#ifdef ROOTSPECTRUM
|
||||
TH2F *h2=NULL;
|
||||
TH2F *hmap=NULL;
|
||||
TFile *froot=NULL;
|
||||
|
||||
h2=new TH2F("hs","hs",500,-500,500,400*400,-0.5,400*400-0.5);
|
||||
hmap=new TH2F("hmap","hmap",400,-0.5,400-0.5,400,-0.5,400-0.5);
|
||||
#endif
|
||||
cout << "zmq1 " << endl;
|
||||
|
||||
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();
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
cout << "zmq2 " << endl;
|
||||
if (send) {
|
||||
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);
|
||||
delete zmqsocket2;
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
zmqsocket2->Connect();
|
||||
printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
// zmqsocket2->Disconnect();
|
||||
}
|
||||
|
||||
|
||||
// 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))]();
|
||||
|
||||
int *nph;//[400*400];
|
||||
int iframe=0;
|
||||
char rootfname[10000];
|
||||
|
||||
char fname[10000];
|
||||
char ff[10000];
|
||||
int fi;
|
||||
int length;
|
||||
char newped=-1, ped=-1, dat=-1, isdark=-1;
|
||||
|
||||
double *peds;
|
||||
int *im;
|
||||
int fnumber;
|
||||
float *gm=new float[400*400];
|
||||
// infinite loop
|
||||
while(1) {
|
||||
|
||||
|
||||
// cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){
|
||||
// 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
|
||||
if (dat==1) {
|
||||
|
||||
sprintf(tit,"%s_%lld.tiff",filename.c_str(),fi);
|
||||
cout << tit << endl;
|
||||
im=mt->getImage(nnx,nny,nns);
|
||||
if (isdark) cout << "getting dark "<< endl;
|
||||
else cout << "subtracting dark"<< endl;
|
||||
if (gm) {
|
||||
for (int ii=0; ii<400*400; ii++) {
|
||||
// if (image[ix]>0) cout << ix << " " << image[ix]<< endl;
|
||||
if (isdark) {
|
||||
ddark[ii]=(double)im[ii]/((double)iframe);
|
||||
if (ddark[ii]>0) cout << "*" ;
|
||||
gm[ii]=im[ii];
|
||||
if (send) dout[ii]=im[ii];
|
||||
} else {
|
||||
gm[ii]=im[ii];//-ddark[ii]*iframe;
|
||||
if (gm[ii]<0) gm[ii]=0;
|
||||
if (send) dout[ii]=gm[ii];
|
||||
}
|
||||
//cout << endl;
|
||||
|
||||
}
|
||||
cout << endl;
|
||||
//cout << "image " << nnx << " " << nny << endl;
|
||||
WriteToTiff(gm,tit ,nnx, nny);
|
||||
// delete [] gm;
|
||||
} else cout << "Could not allocate float image " << endl;
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
sprintf(tit,"%s_%lld.tiff",filename.c_str(),fi);
|
||||
cout << tit << endl;
|
||||
mt->writePedestal(tit);
|
||||
|
||||
}
|
||||
|
||||
// mt->writeImage(tit);
|
||||
// cout << "wrote" << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (send) {
|
||||
if (dat==1) {
|
||||
//im=mt->getImage(nnx,nny,nns);
|
||||
|
||||
//if (im)
|
||||
// cout << "got image" << endl;
|
||||
//else
|
||||
// cout << "could not get image" << endl;
|
||||
|
||||
|
||||
//for (int ii=0; ii<400*400; ii++) {
|
||||
//if (im[ii]>0)
|
||||
//cout << im[ii] << endl;
|
||||
// if (im[ii]>=0)
|
||||
|
||||
// if (isdark) {
|
||||
//ddark[ii]=im[ii];
|
||||
// dout[ii]=im[ii];
|
||||
// } else {
|
||||
// dout[ii]=im[ii]-ddark[ii];
|
||||
// if (dout[ii]<0) dout[ii]=0;
|
||||
// }
|
||||
// else
|
||||
// dout[ii]=0;
|
||||
//else
|
||||
//dout[ii]=0;
|
||||
// cout << im[ii] << " " << dout[ii] << endl;
|
||||
// }
|
||||
//for (int iiy=49; iiy<52; iiy++)
|
||||
// for (int iix=80; iix<83; iix++)
|
||||
// dout[iiy*400+iix]=0;
|
||||
;
|
||||
} else {
|
||||
peds=mt->getPedestal();
|
||||
// sprintf(tit,"%s_%lld.tiff",filename.c_str(),fi);
|
||||
//cout << tit << endl;
|
||||
//mt->writePedestal(tit);
|
||||
if (peds)
|
||||
cout << "got peds" << endl;
|
||||
else
|
||||
cout << "could not get peds" << endl;
|
||||
for (int ii=0; ii<400*400; ii++) {
|
||||
dout[ii]=peds[ii];
|
||||
// if (ii%400==10 && ii/400==10)
|
||||
// cout << ii/400 << " " << ii%400 << " " << peds[ii] << " " << dout[ii] << endl;
|
||||
// if (ii%400==100 && ii/400==100)
|
||||
// cout << ii/400 << " " << ii%400 << " " << peds[ii] << " " << dout[ii] << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 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);
|
||||
// delete zmqsocket2;
|
||||
// delete zmqsocket;
|
||||
// return EXIT_FAILURE;
|
||||
// }
|
||||
// zmqsocket2->Connect();
|
||||
// printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
//zmqsocket2->Connect();
|
||||
|
||||
|
||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,ff, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
|
||||
|
||||
zmqsocket2->SendData((char*)dout,length);
|
||||
cprintf(GREEN, "Sent Data %d \n",length);
|
||||
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
// zmqsocket2->Disconnect();
|
||||
|
||||
// delete zmqsocket2;
|
||||
}
|
||||
cout << "Acquired "<< iframe << " frames " << endl;
|
||||
iframe=0;
|
||||
newped=-1;
|
||||
ped=-1;
|
||||
dat=-1;
|
||||
mt->clearImage();
|
||||
isdark=0;
|
||||
continue; //continue to not get out
|
||||
}
|
||||
// cprintf(GREEN, "Got Header \n");
|
||||
|
||||
strcpy(ff,filename.c_str());
|
||||
fi=fileindex;
|
||||
//isdark=0;
|
||||
if (newped<0) {
|
||||
if (filename.find("newped")!=std::string::npos) {
|
||||
cout << "NEWPED" << endl;
|
||||
if (newped<=0) {
|
||||
newped=1;
|
||||
ped=1;
|
||||
while (mt->isBusy()) {;}
|
||||
mt->newDataSet(); //resets pedestal
|
||||
mt->setFrameMode(ePedestal);
|
||||
cout << "New data set"<< endl;
|
||||
}
|
||||
} else {
|
||||
newped=0;
|
||||
}
|
||||
}
|
||||
if (ped<0) {
|
||||
if (filename.find("ped")!=std::string::npos) {
|
||||
ped=1;
|
||||
dat=0;
|
||||
while (mt->isBusy()) {;}
|
||||
mt->setFrameMode(ePedestal);
|
||||
cout << "pedestal!"<< endl;
|
||||
} else {
|
||||
ped=0;
|
||||
dat=1;
|
||||
while (mt->isBusy()) {;}
|
||||
mt->setFrameMode(eFrame);
|
||||
cout << "data!"<< endl;
|
||||
if (filename.find("dark")!=std::string::npos) {
|
||||
isdark=1;
|
||||
cout << "this is a dark image" << endl;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// get data
|
||||
length = zmqsocket->ReceiveData(0, buff, size);
|
||||
// cprintf(GREEN, "Got Data\n");
|
||||
|
||||
//processing with image
|
||||
//...
|
||||
// if (iframe<10) {
|
||||
// filter->addToPedestal(image);
|
||||
//} else {
|
||||
//SLOW!!!
|
||||
//***
|
||||
//filter->getNPhotons(image);
|
||||
//nph=filter->getImage();
|
||||
//filter->addToPedestal(image);
|
||||
//*****
|
||||
|
||||
// cprintf(BLUE, "Data processed\n");
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
|
||||
//stream data from socket 2
|
||||
|
||||
iframe++;
|
||||
}
|
||||
|
||||
// }// exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
if (send)
|
||||
delete zmqsocket2;
|
||||
|
||||
|
||||
cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -22,55 +22,86 @@ using namespace std;
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [send_socket ip] [send port number]
|
||||
*
|
||||
*/
|
||||
|
||||
int nthreads=20;
|
||||
int nsigma=5;
|
||||
int xmin=0;
|
||||
int xmax=400;
|
||||
int ymin=0;
|
||||
int ymax=400;
|
||||
int nsubpixels=2;
|
||||
|
||||
|
||||
FILE *of=NULL;
|
||||
int fifosize=1000;
|
||||
int nthreads=20;
|
||||
int nsubpixels=2;
|
||||
// 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;
|
||||
}
|
||||
int int_ready=0;
|
||||
int ok;
|
||||
// help
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: %s [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number] [nsubpixels] [nthreads] [nsigma] [xmin xmax ymin ymax]\n", argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip=argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
int size = 32*2*5000;//atoi(argv[3]);
|
||||
int size = 32*2*5000;//atoi(argv[3]);
|
||||
bool send = false;
|
||||
|
||||
// send parameters if any
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
if (argc > 3) {
|
||||
send = true;
|
||||
socketip2 = argv[3];
|
||||
portnum2 = atoi(argv[4]);
|
||||
|
||||
|
||||
char* socketip=argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
if (argc > 3) {
|
||||
send = true;
|
||||
socketip2 = argv[3];
|
||||
portnum2 = atoi(argv[4]);
|
||||
}
|
||||
if (argc > 5) {
|
||||
nsubpixels=atoi(argv[5]);
|
||||
}
|
||||
if (argc>6) {
|
||||
nthreads=atoi(argv[6]);
|
||||
}
|
||||
if (argc>7) {
|
||||
nsigma=atoi(argv[7]);
|
||||
}
|
||||
if (argc>11) {
|
||||
xmin=atoi(argv[8]);
|
||||
xmax=atoi(argv[8]);
|
||||
ymin=atoi(argv[10]);
|
||||
ymax=atoi(argv[11]);
|
||||
}
|
||||
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum ;
|
||||
if (send) {
|
||||
cout << "\nsd socket ip : " << socketip2 <<
|
||||
"\nsd port num : " << portnum2;
|
||||
}
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum ;
|
||||
if (send) {
|
||||
cout << "\nsd socket ip : " << socketip2 <<
|
||||
"\nsd port num : " << portnum2;
|
||||
}
|
||||
cout << endl;
|
||||
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
int npx, npy;
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||
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);
|
||||
linearInterpolation *interp=new linearInterpolation(npx,npy,nsubpixels);
|
||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, 5, 1, 0, 1000, 100,npx,npy);
|
||||
cout << endl;
|
||||
|
||||
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
mt->setFrameMode(eFrame);
|
||||
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
int npx, npy;
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||
det->getDetectorSize(npx, npy);
|
||||
linearInterpolation *interp=new linearInterpolation(npx,npy,nsubpixels);
|
||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, nsigma, 1, 0, 1000, 100,npx,npy);
|
||||
cout << "Setting noise cut to " << nsigma << " sigma"<< endl;
|
||||
filter->setROI(xmin,xmax,ymin,ymax);
|
||||
cout << "Setting ROI to "<< xmin << " " << xmax << " " << ymin << " " << ymax << endl;
|
||||
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
int frameMode=eFrame;
|
||||
mt->setFrameMode(frameMode);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
@ -80,9 +111,6 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
|
||||
|
||||
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
@ -93,7 +121,6 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
cout << "zmq2 " << endl;
|
||||
if (send) {
|
||||
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
if (zmqsocket2->IsError()) {
|
||||
@ -113,6 +140,9 @@ int main(int argc, char *argv[]) {
|
||||
uint32_t subframeIndex = -1;
|
||||
uint64_t fileindex = -1;
|
||||
string filename = "";
|
||||
char ffname[10000];
|
||||
int ffindex;
|
||||
|
||||
char* image = new char[size];
|
||||
//int* image = new int[(size/sizeof(int))]();
|
||||
|
||||
@ -138,36 +168,54 @@ int main(int argc, char *argv[]) {
|
||||
// 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(nix,niy,nis);
|
||||
|
||||
if (detimage) {
|
||||
for (ix=0; ix<nnx; ix++) {
|
||||
for (iy=0; iy<nny; iy++) {
|
||||
dout[iy*nnx+ix]=0;
|
||||
for (isx=0; isx<nis; isx++) {
|
||||
for (isy=0; isy<nis; isy++) {
|
||||
dout[iy*nnx+ix]+=detimage[(iy+isy)*nix+(ix+isx)];
|
||||
}
|
||||
if (frameMode==ePedestal) {
|
||||
detped=mt->getPedestal();
|
||||
if (detped) {
|
||||
|
||||
for (ix=0; ix<400; ix++) {
|
||||
for (iy=0; iy<400; iy++) {
|
||||
dout[iy*400+ix]+=detped[iy*400+ix];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
zmqsocket2->SendData((char*)dout,length);
|
||||
cprintf(GREEN, "Sent Data\n");
|
||||
} else {
|
||||
detimage=mt->getImage(nix,niy,nis);
|
||||
if (detimage) {
|
||||
for (ix=0; ix<nix/nis; ix++) {
|
||||
for (iy=0; iy<niy/nis; iy++) {
|
||||
dout[iy*(nix/nis)+ix]=0;
|
||||
}
|
||||
}
|
||||
for (ix=0; ix<nix; ix++) {
|
||||
for (iy=0; iy<niy; iy++) {
|
||||
dout[(iy/nis)*(nix/nis)+(ix/nis)]+=detimage[iy*nix+ix];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(ofname,"%s_%d.tiff",filename.c_str(),fileindex);
|
||||
mt->writeImage(ofname);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
zmqsocket2->SendData((char*)dout,length);
|
||||
cprintf(GREEN, "Sent Data\n");
|
||||
}
|
||||
|
||||
sprintf(ofname,"%s_%d.tiff",ffname,ffindex);
|
||||
if (frameMode==eFlat)
|
||||
mt->writeFlatField(ofname);
|
||||
else if (frameMode==ePedestal)
|
||||
mt->writePedestal(ofname);
|
||||
else
|
||||
mt->writeImage(ofname);
|
||||
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
if (send) {
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
@ -184,7 +232,8 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
|
||||
if (of==NULL) {
|
||||
if (of==NULL) {
|
||||
while (mt->isBusy()) {;}
|
||||
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
|
||||
of=fopen(ofname,"w");
|
||||
if (of) {
|
||||
@ -193,6 +242,32 @@ int main(int argc, char *argv[]) {
|
||||
cout << "Could not open "<< ofname << " for writing " << endl;
|
||||
mt->setFilePointer(NULL);
|
||||
}
|
||||
ffindex=fileindex;
|
||||
strcpy(ffname,filename.c_str());
|
||||
if (filename.find("flat")!=std::string::npos) {
|
||||
cout << "add to ff" << endl;
|
||||
frameMode=eFlat;//ePedestal;
|
||||
int_ready=0;
|
||||
|
||||
} else if (filename.find("newped")!=std::string::npos) {
|
||||
frameMode=ePedestal;
|
||||
cout << "new pedestal" << endl;
|
||||
|
||||
mt->newDataSet();
|
||||
} else if (filename.find("ped")!=std::string::npos){
|
||||
frameMode=ePedestal;
|
||||
cout << "pedestal" << endl;
|
||||
} else {
|
||||
frameMode=eFrame;
|
||||
cout << "data" << endl;
|
||||
if (int_ready==0) {
|
||||
mt->prepareInterpolation(ok);
|
||||
cout << "prepare interpolation " << endl;
|
||||
int_ready=1;
|
||||
}
|
||||
}
|
||||
|
||||
mt->setFrameMode(frameMode);
|
||||
}
|
||||
|
||||
// get data
|
||||
|
@ -50,7 +50,7 @@ public:
|
||||
|
||||
|
||||
virtual int setFrameMode(int fm) {fMode=fm; if (fMode>=0) det->setFrameMode((frameMode)fMode);};
|
||||
|
||||
virtual void newDataSet(){det->newDataSet();};
|
||||
//fMode=fm; return fMode;}
|
||||
|
||||
/* void prepareInterpolation(int &ok) { */
|
||||
@ -235,6 +235,7 @@ public:
|
||||
|
||||
int setFrameMode(int fm) { int ret; for (int i=0; i<nThreads; i++) ret=dets[i]->setFrameMode(fm); return ret;};
|
||||
|
||||
void newDataSet(){for (int i=0; i<nThreads; i++) dets[i]->newDataSet();};
|
||||
int *getImage(int &nnx, int &nny, int &ns) {
|
||||
int *img;
|
||||
// int nnx, nny, ns;
|
||||
@ -242,13 +243,14 @@ public:
|
||||
//for (i=0; i<nn; i++) image[i]=0;
|
||||
|
||||
for (int ii=0; ii<nThreads; ii++) {
|
||||
// cout << ii << " " << dets[ii]->getImageSize(nnx, nny, ns) << " " << nnx << " " << nny << " " << ns << endl;
|
||||
//cout << ii << " " << nn << " " << nnx << " " << nny << " " << ns << endl;
|
||||
img=dets[ii]->getImage();
|
||||
for (int i=0; i<nn; i++) {
|
||||
if (ii==0)
|
||||
image[i]=img[i];
|
||||
else
|
||||
image[i]+=img[i];
|
||||
//if (img[i]) cout << "det " << ii << " pix " << i << " val " << img[i] << " " << image[i] << endl;
|
||||
}
|
||||
|
||||
}
|
||||
@ -280,8 +282,8 @@ public:
|
||||
float *gm=new float[nn];
|
||||
if (gm) {
|
||||
for (int ix=0; ix<nn; ix++) {
|
||||
// if (image[ix]>0) cout << ix << " " << image[ix]<< endl;
|
||||
gm[ix]=image[ix];
|
||||
// if (image[ix]>0 && ix/nnx<350) cout << ix/nnx << " " << ix%nnx << " " << image[ix]<< " " << gm[ix] << endl;
|
||||
}
|
||||
//cout << "image " << nnx << " " << nny << endl;
|
||||
WriteToTiff(gm,imgname ,nnx, nny);
|
||||
@ -403,7 +405,7 @@ public:
|
||||
} else cout << "Could not allocate float image " << endl;
|
||||
}
|
||||
} else
|
||||
cout << "Not interpolating detector! " << endl;
|
||||
cout << "Detector without flat field! " << endl;
|
||||
|
||||
return NULL;
|
||||
|
||||
@ -449,7 +451,7 @@ public:
|
||||
p0=dets[i]->getPedestal(p0);
|
||||
if (p0) {
|
||||
for (int ib=0; ib<nx*ny; ib++) {
|
||||
ped[ib]+=p0[ib];
|
||||
ped[ib]+=p0[ib]/((double)nThreads);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,10 +187,10 @@ public analogDetector<uint16_t> {
|
||||
double g=1.;
|
||||
|
||||
|
||||
double tthr=thr;
|
||||
double tthr=thr, tthr1, tthr2;
|
||||
int nn=0;
|
||||
double max=0, tl=0, tr=0, bl=0,br=0, v;
|
||||
|
||||
double rms=0;
|
||||
|
||||
int cm=0;
|
||||
if (cmSub) cm=1;
|
||||
@ -240,56 +240,62 @@ public analogDetector<uint16_t> {
|
||||
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)>=0 && (iy+ir)<ny && (ix+ic)>=0 && (ix+ic)<nx) {
|
||||
//clusters->set_data(rest[iy+ir][ix+ic], ic, ir);
|
||||
|
||||
if (rest[iy][ix]>0.25*tthr) {
|
||||
eventMask[iy][ix]=NEIGHBOUR;
|
||||
for (int ir=-(clusterSizeY/2); ir<(clusterSizeY/2)+1; ir++) {
|
||||
for (int ic=-(clusterSize/2); ic<(clusterSize/2)+1; ic++) {
|
||||
if ((iy+ir)>=0 && (iy+ir)<ny && (ix+ic)>=0 && (ix+ic)<nx) {
|
||||
//clusters->set_data(rest[iy+ir][ix+ic], ic, ir);
|
||||
|
||||
|
||||
v=rest[iy+ir][ix+ic];//clusters->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;
|
||||
v=rest[iy+ir][ix+ic];//clusters->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 (rest[iy][ix]>=max) {
|
||||
if (bl>=br && bl>=tl && bl>=tr) {
|
||||
quad=BOTTOM_LEFT;
|
||||
quadTot=bl;
|
||||
} else if (br>=bl && br>=tl && br>=tr) {
|
||||
quad=BOTTOM_RIGHT;
|
||||
quadTot=br;
|
||||
|
||||
if (rest[iy][ix]>=max) {
|
||||
if (bl>=br && bl>=tl && bl>=tr) {
|
||||
quad=BOTTOM_LEFT;
|
||||
quadTot=bl;
|
||||
} else if (br>=bl && br>=tl && br>=tr) {
|
||||
quad=BOTTOM_RIGHT;
|
||||
quadTot=br;
|
||||
} else if (tl>=br && tl>=bl && tl>=tr) {
|
||||
quad=TOP_LEFT;
|
||||
quadTot=tl;
|
||||
quad=TOP_LEFT;
|
||||
quadTot=tl;
|
||||
} else if (tr>=bl && tr>=tl && tr>=br) {
|
||||
quad=TOP_RIGHT;
|
||||
quadTot=tr;
|
||||
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) {
|
||||
eventMask[iy][ix]=PHOTON;
|
||||
nph[ix+nx*iy]++;
|
||||
nphFrame++;
|
||||
nphTot++;
|
||||
|
||||
}
|
||||
}
|
||||
if (max>tthr || tot>sqrt(ccy*ccs)*tthr || quadTot>sqrt(cy*cs)*tthr) {
|
||||
eventMask[iy][ix]=PHOTON;
|
||||
nph[ix+nx*iy]++;
|
||||
nphFrame++;
|
||||
nphTot++;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ void qTabSettings::SetupDetectorSettings(){
|
||||
default:
|
||||
cout << "Unknown detector type. Exiting GUI." << endl;
|
||||
qDefs::Message(qDefs::CRITICAL,"Unknown detector type. Exiting GUI.","qTabSettings::SetupDetectorSettings");
|
||||
exit(-1);
|
||||
exit(-1);
|
||||
break;
|
||||
}
|
||||
// detector settings selected NOT ENABLED.
|
||||
@ -198,7 +198,8 @@ void qTabSettings::SetupDetectorSettings(){
|
||||
#ifdef VERBOSE
|
||||
cout << "ERROR: Unknown Detector Settings retrieved from detector." << endl;
|
||||
#endif
|
||||
exit(-1);
|
||||
sett= Undefined;
|
||||
// exit(-1);
|
||||
}
|
||||
// Setting the detector settings
|
||||
else comboSettings->setCurrentIndex(sett);
|
||||
|
141
slsDetectorSoftware/jctbDetectorServer/AD9257.h
Executable file
141
slsDetectorSoftware/jctbDetectorServer/AD9257.h
Executable file
@ -0,0 +1,141 @@
|
||||
#ifndef AD9257_H
|
||||
#define AD9257_H
|
||||
|
||||
#include "ansi.h"
|
||||
|
||||
#include "commonServerFunctions.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/* AD9257 ADC DEFINES */
|
||||
#define AD9257_ADC_NUMBITS (24)
|
||||
|
||||
#define AD9257_DEV_IND_2_REG (0x04)
|
||||
#define AD9257_CHAN_H_OFST (0)
|
||||
#define AD9257_CHAN_H_MSK (0x00000001 << AD9257_CHAN_H_OFST)
|
||||
#define AD9257_CHAN_G_OFST (1)
|
||||
#define AD9257_CHAN_G_MSK (0x00000001 << AD9257_CHAN_G_OFST)
|
||||
#define AD9257_CHAN_F_OFST (2)
|
||||
#define AD9257_CHAN_F_MSK (0x00000001 << AD9257_CHAN_F_OFST)
|
||||
#define AD9257_CHAN_E_OFST (3)
|
||||
#define AD9257_CHAN_E_MSK (0x00000001 << AD9257_CHAN_E_OFST)
|
||||
|
||||
#define AD9257_DEV_IND_1_REG (0x05)
|
||||
#define AD9257_CHAN_D_OFST (0)
|
||||
#define AD9257_CHAN_D_MSK (0x00000001 << AD9257_CHAN_D_OFST)
|
||||
#define AD9257_CHAN_C_OFST (1)
|
||||
#define AD9257_CHAN_C_MSK (0x00000001 << AD9257_CHAN_C_OFST)
|
||||
#define AD9257_CHAN_B_OFST (2)
|
||||
#define AD9257_CHAN_B_MSK (0x00000001 << AD9257_CHAN_B_OFST)
|
||||
#define AD9257_CHAN_A_OFST (3)
|
||||
#define AD9257_CHAN_A_MSK (0x00000001 << AD9257_CHAN_A_OFST)
|
||||
#define AD9257_CLK_CH_DCO_OFST (4)
|
||||
#define AD9257_CLK_CH_DCO_MSK (0x00000001 << AD9257_CLK_CH_DCO_OFST)
|
||||
#define AD9257_CLK_CH_IFCO_OFST (5)
|
||||
#define AD9257_CLK_CH_IFCO_MSK (0x00000001 << AD9257_CLK_CH_IFCO_OFST)
|
||||
|
||||
#define AD9257_POWER_MODE_REG (0x08)
|
||||
#define AD9257_POWER_INTERNAL_OFST (0)
|
||||
#define AD9257_POWER_INTERNAL_MSK (0x00000003 << AD9257_POWER_INTERNAL_OFST)
|
||||
#define AD9257_INT_RESET_VAL (0x3)
|
||||
#define AD9257_INT_CHIP_RUN_VAL (0x0)
|
||||
#define AD9257_POWER_EXTERNAL_OFST (5)
|
||||
#define AD9257_POWER_EXTERNAL_MSK (0x00000001 << AD9257_POWER_EXTERNAL_OFST)
|
||||
#define AD9257_EXT_FULL_POWER_VAL (0x0)
|
||||
#define AD9257_EXT_STANDBY_VAL (0x1)
|
||||
|
||||
#define AD9257_OUT_MODE_REG (0x14)
|
||||
#define AD9257_OUT_FORMAT_OFST (0)
|
||||
#define AD9257_OUT_FORMAT_MSK (0x00000001 << AD9257_OUT_FORMAT_OFST)
|
||||
#define AD9257_OUT_BINARY_OFST_VAL (0)
|
||||
#define AD9257_OUT_TWOS_COMPL_VAL (1)
|
||||
#define AD9257_OUT_LVDS_OPT_OFST (6)
|
||||
#define AD9257_OUT_LVDS_OPT_MSK (0x00000001 << AD9257_OUT_LVDS_OPT_OFST)
|
||||
#define AD9257_OUT_LVDS_ANSI_VAL (0)
|
||||
#define AD9257_OUT_LVDS_IEEE_VAL (1)
|
||||
|
||||
#define AD9257_OUT_PHASE_REG (0x16)
|
||||
#define AD9257_OUT_CLK_OFST (0)
|
||||
#define AD9257_OUT_CLK_MSK (0x0000000F << AD9257_OUT_CLK_OFST)
|
||||
#define AD9257_OUT_CLK_60_VAL (0x1)
|
||||
#define AD9257_IN_CLK_OFST (4)
|
||||
#define AD9257_IN_CLK_MSK (0x00000007 << AD9257_IN_CLK_OFST)
|
||||
#define AD9257_IN_CLK_0_VAL (0x0)
|
||||
|
||||
#define AD9257_VREF_REG (0x18)
|
||||
#define AD9257_VREF_OFST (0)
|
||||
#define AD9257_VREF_MSK (0x00000003 << AD9257_VREF_OFST)
|
||||
#define AD9257_VREF_1_33_VAL (0x2)
|
||||
|
||||
#define AD9257_TEST_MODE_REG (0x0D)
|
||||
#define AD9257_OUT_TEST_OFST (0)
|
||||
#define AD9257_OUT_TEST_MSK (0x0000000F << AD9257_OUT_TEST_OFST)
|
||||
#define AD9257_NONE_VAL (0x0)
|
||||
#define AD9257_MIXED_BIT_FREQ_VAL (0xC)
|
||||
#define AD9257_TEST_RESET_SHORT_GEN (4)
|
||||
#define AD9257_TEST_RESET_LONG_GEN (5)
|
||||
#define AD9257_USER_IN_MODE_OFST (6)
|
||||
#define AD9257_USER_IN_MODE_MSK (0x00000003 << AD9257_USER_IN_MODE_OFST)
|
||||
|
||||
|
||||
void setAdc(int addr, int val) {
|
||||
|
||||
u_int32_t codata;
|
||||
codata = val + (addr << 8);
|
||||
printf(" Setting ADC SPI Register. Wrote 0x%04x at 0x%04x\n", val, addr);
|
||||
serializeToSPI(ADC_SPI_REG, codata, ADC_SERIAL_CS_OUT_MSK, AD9257_ADC_NUMBITS,
|
||||
ADC_SERIAL_CLK_OUT_MSK, ADC_SERIAL_DATA_OUT_MSK, ADC_SERIAL_DATA_OUT_OFST);
|
||||
}
|
||||
|
||||
void prepareADC(){
|
||||
printf("\n\nPreparing ADC ... \n");
|
||||
|
||||
//power mode reset
|
||||
printf("power mode reset:\n");
|
||||
setAdc(AD9257_POWER_MODE_REG,
|
||||
(AD9257_INT_RESET_VAL << AD9257_POWER_INTERNAL_OFST) & AD9257_POWER_INTERNAL_MSK);
|
||||
|
||||
//power mode chip run
|
||||
printf("power mode chip run:\n");
|
||||
setAdc(AD9257_POWER_MODE_REG,
|
||||
(AD9257_INT_CHIP_RUN_VAL << AD9257_POWER_INTERNAL_OFST) & AD9257_POWER_INTERNAL_MSK);
|
||||
|
||||
//output clock phase
|
||||
printf("output clock phase:\n");
|
||||
setAdc(AD9257_OUT_PHASE_REG,
|
||||
(AD9257_OUT_CLK_60_VAL << AD9257_OUT_CLK_OFST) & AD9257_OUT_CLK_MSK);
|
||||
|
||||
// lvds-iee reduced , binary offset
|
||||
printf("lvds-iee reduced, binary offset:\n");
|
||||
setAdc(AD9257_OUT_MODE_REG,
|
||||
(AD9257_OUT_LVDS_IEEE_VAL << AD9257_OUT_LVDS_OPT_OFST) & AD9257_OUT_LVDS_OPT_MSK);
|
||||
|
||||
// all devices on chip to receive next command
|
||||
printf("all devices on chip to receive next command:\n");
|
||||
setAdc(AD9257_DEV_IND_2_REG,
|
||||
AD9257_CHAN_H_MSK | AD9257_CHAN_G_MSK | AD9257_CHAN_F_MSK | AD9257_CHAN_E_MSK);
|
||||
setAdc(AD9257_DEV_IND_1_REG,
|
||||
AD9257_CHAN_D_MSK | AD9257_CHAN_C_MSK | AD9257_CHAN_B_MSK | AD9257_CHAN_A_MSK |
|
||||
AD9257_CLK_CH_DCO_MSK | AD9257_CLK_CH_IFCO_MSK);
|
||||
|
||||
// vref 1.33
|
||||
printf("vref 1.33:\n");
|
||||
setAdc(AD9257_VREF_REG,
|
||||
(AD9257_VREF_1_33_VAL << AD9257_VREF_OFST) & AD9257_VREF_MSK);
|
||||
|
||||
// no test mode
|
||||
printf("no test mode:\n");
|
||||
setAdc(AD9257_TEST_MODE_REG,
|
||||
(AD9257_NONE_VAL << AD9257_OUT_TEST_OFST) & AD9257_OUT_TEST_MSK);
|
||||
|
||||
#ifdef TESTADC
|
||||
printf("***************************************** *******\n");
|
||||
printf("******* PUTTING ADC IN TEST MODE!!!!!!!!! *******\n");
|
||||
printf("***************************************** *******\n");
|
||||
// mixed bit frequency test mode
|
||||
printf("mixed bit frequency test mode:\n");
|
||||
setAdc(AD9257_TEST_MODE_REG,
|
||||
(AD9257_MIXED_BIT_FREQ_VAL << AD9257_OUT_TEST_OFST) & AD9257_OUT_TEST_MSK);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif //AD9257_H
|
@ -6,10 +6,10 @@
|
||||
CROSS = bfin-uclinux-
|
||||
CC = $(CROSS)gcc
|
||||
|
||||
CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DV1 -DCTB #-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER
|
||||
CFLAGS += -Wall -DMOENCHD -DMCB_FUNCS -DDACS_INT -DDEBUG -DV1 -DCTB -DOLDVERSION #-DVERBOSE #-DVERYVERBOSE #-DVIRTUAL #-DDACS_INT_CSERVER
|
||||
|
||||
|
||||
PROGS= jctbDetectorServer
|
||||
PROGS= jctbDetectorServer
|
||||
INSTDIR= /tftpboot
|
||||
INSTMODE= 0777
|
||||
|
||||
@ -31,10 +31,14 @@ boot: $(OBJS)
|
||||
versioning:
|
||||
@echo `tput setaf 6; ./updateGitVersion.sh; tput sgr0;`
|
||||
|
||||
jctbDetectorServer: $(OBJS)
|
||||
jctbDetectorServerNew: $(OBJS)
|
||||
echo $(OBJS)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@)
|
||||
|
||||
jctbDetectorServer: $(OBJS)
|
||||
echo $(OBJS)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@) -DOLDVERSION
|
||||
|
||||
jungfrauADCTEst: $(OBJS)
|
||||
echo $(OBJS)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS_$@) $(LDFLAGS_$@) -DTESTADC
|
||||
|
@ -2,9 +2,13 @@
|
||||
#define BLACKFIN_H
|
||||
|
||||
#define CSP0 0x20200000
|
||||
#define MEM_SIZE 0x100000
|
||||
#define MEM_SIZE 0x100000
|
||||
#ifndef OLDVERSION
|
||||
#define MEM_MAP_SHIFT 1
|
||||
|
||||
#endif
|
||||
#ifdef OLDVERSION
|
||||
#define MEM_MAP_SHIFT 11
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
int mapCSP0(void);
|
||||
|
73
slsDetectorSoftware/jctbDetectorServer/commonServerFunctions.h
Executable file
73
slsDetectorSoftware/jctbDetectorServer/commonServerFunctions.h
Executable file
@ -0,0 +1,73 @@
|
||||
#ifndef COMMON_SERVER_FUNCTIONS_H
|
||||
#define COMMON_SERVER_FUNCTIONS_H
|
||||
|
||||
#ifndef GOTTHARDD //gotthard already had bus_w etc defined in its firmware_funcs.c (not yet made with common files)
|
||||
#include "blackfin.h"
|
||||
#endif
|
||||
|
||||
/* global variables */
|
||||
|
||||
void SPIChipSelect (u_int32_t* valw, u_int32_t addr, u_int32_t csmask) {
|
||||
|
||||
// start point
|
||||
(*valw) = 0xffffffff; // old board compatibility (not using specific bits)
|
||||
bus_w (addr, (*valw));
|
||||
|
||||
// chip sel bar down
|
||||
(*valw) &= ~csmask; /* todo with test: done a bit different, not with previous value */
|
||||
bus_w (addr, (*valw));
|
||||
}
|
||||
|
||||
|
||||
void SPIChipDeselect (u_int32_t* valw, u_int32_t addr, u_int32_t csmask, u_int32_t clkmask) {
|
||||
// chip sel bar up
|
||||
(*valw) |= csmask; /* todo with test: not done for spi */
|
||||
bus_w (addr, (*valw));
|
||||
|
||||
//clk down
|
||||
(*valw) &= ~clkmask;
|
||||
bus_w (addr, (*valw));
|
||||
|
||||
// stop point = start point of course
|
||||
(*valw) = 0xffffffff; // old board compatibility (not using specific bits)
|
||||
bus_w (addr, (*valw));
|
||||
}
|
||||
|
||||
void sendDataToSPI (u_int32_t* valw, u_int32_t addr, u_int32_t val, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset) {
|
||||
int i = 0;
|
||||
for (i = 0; i < numbitstosend; ++i) {
|
||||
|
||||
// clk down
|
||||
(*valw) &= ~clkmask;
|
||||
bus_w (addr, (*valw));
|
||||
|
||||
// write data (i)
|
||||
(*valw) = (((*valw) & ~digoutmask) + // unset bit
|
||||
(((val >> (numbitstosend - 1 - i)) & 0x1) << digofset)); // each bit from val starting from msb
|
||||
bus_w (addr, (*valw));
|
||||
|
||||
// clk up
|
||||
(*valw) |= clkmask ;
|
||||
bus_w (addr, (*valw));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void serializeToSPI(u_int32_t addr, u_int32_t val, u_int32_t csmask, int numbitstosend, u_int32_t clkmask, u_int32_t digoutmask, int digofset) {
|
||||
#ifdef VERBOSE
|
||||
if (numbitstosend == 16)
|
||||
printf("Writing to SPI Register: 0x%04x\n",val);
|
||||
else
|
||||
printf("Writing to SPI Register: 0x%08x\n", val);
|
||||
#endif
|
||||
|
||||
u_int32_t valw;
|
||||
|
||||
SPIChipSelect (&valw, addr, csmask);
|
||||
|
||||
sendDataToSPI(&valw, addr, val, numbitstosend, clkmask, digoutmask, digofset);
|
||||
|
||||
SPIChipDeselect(&valw, addr, csmask, clkmask);
|
||||
}
|
||||
|
||||
#endif //COMMON_SERVER_FUNCTIONS_H
|
@ -8,6 +8,16 @@
|
||||
#include "mcb_funcs.h"
|
||||
#include "slow_adc.h"
|
||||
#include "registers_m.h"
|
||||
#define ADC_SPI_REG ADC_WRITE_REG
|
||||
|
||||
#define ADC_SERIAL_CLK_OUT_OFST (0)
|
||||
#define ADC_SERIAL_CLK_OUT_MSK (0x00000001 << ADC_SERIAL_CLK_OUT_OFST)
|
||||
#define ADC_SERIAL_DATA_OUT_OFST (1)
|
||||
#define ADC_SERIAL_DATA_OUT_MSK (0x00000001 << ADC_SERIAL_DATA_OUT_OFST)
|
||||
#define ADC_SERIAL_CS_OUT_OFST (2)
|
||||
#define ADC_SERIAL_CS_OUT_MSK (0x0000000F << ADC_SERIAL_CS_OUT_OFST)
|
||||
|
||||
#include "AD9257.h"
|
||||
|
||||
//#define VERBOSE
|
||||
//#define VERYVERBOSE
|
||||
@ -1718,60 +1728,60 @@ int initConfGain(int isettings,int val,int imod){
|
||||
|
||||
|
||||
|
||||
int setADC(int adc){
|
||||
/* int reg,nchips,mask,nchans; */
|
||||
/* int setADC(int adc){ */
|
||||
/* /\* int reg,nchips,mask,nchans; *\/ */
|
||||
|
||||
/* if(adc==-1) ROI_flag=0; */
|
||||
/* else ROI_flag=1; */
|
||||
/* /\* if(adc==-1) ROI_flag=0; *\/ */
|
||||
/* /\* else ROI_flag=1; *\/ */
|
||||
|
||||
/* // setDAQRegister();//token timing */
|
||||
/* cleanFifo();//adc sync */
|
||||
/* /\* // setDAQRegister();//token timing *\/ */
|
||||
/* /\* cleanFifo();//adc sync *\/ */
|
||||
|
||||
/* //with gotthard module */
|
||||
/* if(withGotthard){ */
|
||||
/* //set packet size */
|
||||
/* ipPacketSize= DEFAULT_IP_PACKETSIZE; */
|
||||
/* udpPacketSize=DEFAULT_UDP_PACKETSIZE; */
|
||||
/* //set channel mask */
|
||||
/* nchips = GOTTHARDNCHIP; */
|
||||
/* nchans = GOTTHARDNCHAN; */
|
||||
/* mask = ACTIVE_ADC_MASK; */
|
||||
/* } */
|
||||
/* /\* //with gotthard module *\/ */
|
||||
/* /\* if(withGotthard){ *\/ */
|
||||
/* /\* //set packet size *\/ */
|
||||
/* /\* ipPacketSize= DEFAULT_IP_PACKETSIZE; *\/ */
|
||||
/* /\* udpPacketSize=DEFAULT_UDP_PACKETSIZE; *\/ */
|
||||
/* /\* //set channel mask *\/ */
|
||||
/* /\* nchips = GOTTHARDNCHIP; *\/ */
|
||||
/* /\* nchans = GOTTHARDNCHAN; *\/ */
|
||||
/* /\* mask = ACTIVE_ADC_MASK; *\/ */
|
||||
/* /\* } *\/ */
|
||||
|
||||
/* //with moench module all adc */
|
||||
/* else{/\* if(adc==-1){*\/ */
|
||||
/* //set packet size */
|
||||
/* ipPacketSize= DEFAULT_IP_PACKETSIZE; */
|
||||
/* udpPacketSize=DEFAULT_UDP_PACKETSIZE; */
|
||||
/* //set channel mask */
|
||||
/* nchips = N_CHIP; */
|
||||
/* nchans = N_CHANS; */
|
||||
/* mask = ACTIVE_ADC_MASK; */
|
||||
/* }/\* */
|
||||
/* //with moench module 1 adc -- NOT IMPLEMENTED */
|
||||
/* else{ */
|
||||
/* ipPacketSize= ADC1_IP_PACKETSIZE; */
|
||||
/* udpPacketSize=ADC1_UDP_PACKETSIZE; */
|
||||
/* //set channel mask */
|
||||
/* nchips = NCHIPS_PER_ADC; */
|
||||
/* nchans = GOTTHARDNCHAN; */
|
||||
/* mask = 1<<adc; */
|
||||
/* }*\/ */
|
||||
/* /\* //with moench module all adc *\/ */
|
||||
/* /\* else{/\\* if(adc==-1){*\\/ *\/ */
|
||||
/* /\* //set packet size *\/ */
|
||||
/* /\* ipPacketSize= DEFAULT_IP_PACKETSIZE; *\/ */
|
||||
/* /\* udpPacketSize=DEFAULT_UDP_PACKETSIZE; *\/ */
|
||||
/* /\* //set channel mask *\/ */
|
||||
/* /\* nchips = N_CHIP; *\/ */
|
||||
/* /\* nchans = N_CHANS; *\/ */
|
||||
/* /\* mask = ACTIVE_ADC_MASK; *\/ */
|
||||
/* /\* }/\\* *\/ */
|
||||
/* /\* //with moench module 1 adc -- NOT IMPLEMENTED *\/ */
|
||||
/* /\* else{ *\/ */
|
||||
/* /\* ipPacketSize= ADC1_IP_PACKETSIZE; *\/ */
|
||||
/* /\* udpPacketSize=ADC1_UDP_PACKETSIZE; *\/ */
|
||||
/* /\* //set channel mask *\/ */
|
||||
/* /\* nchips = NCHIPS_PER_ADC; *\/ */
|
||||
/* /\* nchans = GOTTHARDNCHAN; *\/ */
|
||||
/* /\* mask = 1<<adc; *\/ */
|
||||
/* /\* }*\\/ *\/ */
|
||||
|
||||
/* //set channel mask */
|
||||
/* reg = (nchans*nchips)<<CHANNEL_OFFSET; */
|
||||
/* reg&=CHANNEL_MASK; */
|
||||
/* reg|=(ACTIVE_ADC_MASK & mask); */
|
||||
/* bus_w(CHIP_OF_INTRST_REG,reg); */
|
||||
/* /\* //set channel mask *\/ */
|
||||
/* /\* reg = (nchans*nchips)<<CHANNEL_OFFSET; *\/ */
|
||||
/* /\* reg&=CHANNEL_MASK; *\/ */
|
||||
/* /\* reg|=(ACTIVE_ADC_MASK & mask); *\/ */
|
||||
/* /\* bus_w(CHIP_OF_INTRST_REG,reg); *\/ */
|
||||
|
||||
/* //#ifdef DDEBUG */
|
||||
/* printf("Chip of Interest Reg:%x\n",bus_r(CHIP_OF_INTRST_REG)); */
|
||||
/* //#endif */
|
||||
/* /\* //#ifdef DDEBUG *\/ */
|
||||
/* /\* printf("Chip of Interest Reg:%x\n",bus_r(CHIP_OF_INTRST_REG)); *\/ */
|
||||
/* /\* //#endif *\/ */
|
||||
|
||||
/* adcConfigured = adc; */
|
||||
/* /\* adcConfigured = adc; *\/ */
|
||||
|
||||
return adcConfigured;
|
||||
}
|
||||
/* return adcConfigured; */
|
||||
/* } */
|
||||
|
||||
|
||||
|
||||
@ -2450,103 +2460,101 @@ int allocateRAM() {
|
||||
|
||||
|
||||
int writeADC(int addr, int val) {
|
||||
|
||||
|
||||
u_int32_t valw,codata,csmask;
|
||||
int i,cdx,ddx;
|
||||
cdx=0; ddx=1;
|
||||
csmask=0xfc; // 1111100
|
||||
|
||||
codata=val + (addr<< 8);
|
||||
printf("***** ADC SPI WRITE TO REGISTER %04X value %04X\n",addr,val);
|
||||
// start point
|
||||
valw=0xff;
|
||||
bus_w16(ADC_WRITE_REG,(valw));
|
||||
|
||||
//chip sel bar down
|
||||
valw=((0xffffffff&(~csmask)));
|
||||
bus_w16(ADC_WRITE_REG,valw);
|
||||
|
||||
for (i=0;i<24;i++) {
|
||||
//cldwn
|
||||
valw=valw&(~(0x1<<cdx));
|
||||
bus_w16(ADC_WRITE_REG,valw);
|
||||
// usleep(0);
|
||||
|
||||
//write data (i)
|
||||
valw=(valw&(~(0x1<<ddx)))+(((codata>>(23-i))&0x1)<<ddx);
|
||||
bus_w16(ADC_WRITE_REG,valw);
|
||||
// usleep(0);
|
||||
|
||||
//clkup
|
||||
valw=valw+(0x1<<cdx);
|
||||
bus_w16(ADC_WRITE_REG,valw);
|
||||
// usleep(0);
|
||||
}
|
||||
|
||||
// stop point =start point
|
||||
valw=valw&(~(0x1<<cdx));
|
||||
// usleep(0);
|
||||
valw=0xff;
|
||||
bus_w16(ADC_WRITE_REG,(valw));
|
||||
|
||||
//usleep in between
|
||||
// usleep(50000);
|
||||
|
||||
setAdc(addr,val);
|
||||
return OK;
|
||||
/* u_int32_t valw,codata,csmask; */
|
||||
/* int i,cdx,ddx; */
|
||||
/* cdx=0; ddx=1; */
|
||||
/* csmask=0xfc; // 1111100 */
|
||||
|
||||
/* codata=val + (addr<< 8); */
|
||||
/* printf("***** ADC SPI WRITE TO REGISTER %04X value %04X\n",addr,val); */
|
||||
/* // start point */
|
||||
/* valw=0xff; */
|
||||
/* bus_w16(ADC_WRITE_REG,(valw)); */
|
||||
|
||||
/* //chip sel bar down */
|
||||
/* valw=((0xffffffff&(~csmask))); */
|
||||
/* bus_w16(ADC_WRITE_REG,valw); */
|
||||
|
||||
/* for (i=0;i<24;i++) { */
|
||||
/* //cldwn */
|
||||
/* valw=valw&(~(0x1<<cdx)); */
|
||||
/* bus_w16(ADC_WRITE_REG,valw); */
|
||||
/* // usleep(0); */
|
||||
|
||||
/* //write data (i) */
|
||||
/* valw=(valw&(~(0x1<<ddx)))+(((codata>>(23-i))&0x1)<<ddx); */
|
||||
/* bus_w16(ADC_WRITE_REG,valw); */
|
||||
/* // usleep(0); */
|
||||
|
||||
/* //clkup */
|
||||
/* valw=valw+(0x1<<cdx); */
|
||||
/* bus_w16(ADC_WRITE_REG,valw); */
|
||||
/* // usleep(0); */
|
||||
/* } */
|
||||
|
||||
/* // stop point =start point */
|
||||
/* valw=valw&(~(0x1<<cdx)); */
|
||||
/* // usleep(0); */
|
||||
/* valw=0xff; */
|
||||
/* bus_w16(ADC_WRITE_REG,(valw)); */
|
||||
/* //usleep in between */
|
||||
/* // usleep(50000); */
|
||||
/* return OK; */
|
||||
}
|
||||
|
||||
int prepareADC(){
|
||||
printf("Preparing ADC\n");
|
||||
u_int32_t codata,csmask;
|
||||
int cdx,ddx;
|
||||
cdx=0; ddx=1;
|
||||
csmask=0x7c; // 1111100
|
||||
/* int prepareADC(){ */
|
||||
/* printf("Preparing ADC\n"); */
|
||||
/* u_int32_t codata,csmask; */
|
||||
/* int cdx,ddx; */
|
||||
/* cdx=0; ddx=1; */
|
||||
/* csmask=0x7c; // 1111100 */
|
||||
|
||||
/* #define ADCREG1 0x08 */
|
||||
/* #define ADCREG2 0x14//20 */
|
||||
/* #define ADCREG3 0x4 */
|
||||
/* #define ADCREG4 0x5 */
|
||||
codata=0;
|
||||
writeADC(0x08,0x3);//reset
|
||||
writeADC(0x08,0x0);//run!
|
||||
writeADC(0x04,0xf);//all chans
|
||||
writeADC(0x04,0x3f);//all chans
|
||||
/* /\* #define ADCREG1 0x08 *\/ */
|
||||
/* /\* #define ADCREG2 0x14//20 *\/ */
|
||||
/* /\* #define ADCREG3 0x4 *\/ */
|
||||
/* /\* #define ADCREG4 0x5 *\/ */
|
||||
/* codata=0; */
|
||||
/* writeADC(0x08,0x3);//reset */
|
||||
/* writeADC(0x08,0x0);//run! */
|
||||
/* writeADC(0x04,0xf);//all chans */
|
||||
/* writeADC(0x04,0x3f);//all chans */
|
||||
|
||||
// writeADC(0x16,0x4);//output clock phase
|
||||
// writeADC(0x18,0x4);// vref 1V
|
||||
// writeADC(0x14,0x0);
|
||||
writeADC(0x14,0x40);//lvds reduced range -- offset binary
|
||||
/* // writeADC(0x16,0x4);//output clock phase */
|
||||
/* // writeADC(0x18,0x4);// vref 1V */
|
||||
/* // writeADC(0x14,0x0); */
|
||||
/* writeADC(0x14,0x40);//lvds reduced range -- offset binary */
|
||||
|
||||
writeADC(0xD,0x0);//no test mode
|
||||
/* writeADC(0xD,0x0);//no test mode */
|
||||
|
||||
#ifdef TESTADC
|
||||
/* #ifdef TESTADC */
|
||||
|
||||
|
||||
////////////TEST ADC!!!!!!!!!!
|
||||
/* ////////////TEST ADC!!!!!!!!!! */
|
||||
|
||||
printf("***************************************** *******\n");
|
||||
printf("******* PUTTING ADC IN TEST MODE!!!!!!!!! *******\n");
|
||||
printf("***************************************** *******\n");
|
||||
/* printf("***************************************** *******\n"); */
|
||||
/* printf("******* PUTTING ADC IN TEST MODE!!!!!!!!! *******\n"); */
|
||||
/* printf("***************************************** *******\n"); */
|
||||
|
||||
|
||||
// writeADC(0xD,0x4);//ALTERNATING CHECKERBOARD
|
||||
/* // writeADC(0xD,0x4);//ALTERNATING CHECKERBOARD */
|
||||
|
||||
// writeADC(0xD,0x7);//ONE/ZERO WORD TOGGLE
|
||||
/* // writeADC(0xD,0x7);//ONE/ZERO WORD TOGGLE */
|
||||
|
||||
/* writeADC(0x19,0xf0);//user input */
|
||||
/* writeADC(0x1A,0xf0);//user input */
|
||||
/* writeADC(0x1B,0x0f);//user input */
|
||||
/* writeADC(0x1C,0x0f);//user input */
|
||||
/* writeADC(0xD,0x48);//user input, alternate */
|
||||
/* /\* writeADC(0x19,0xf0);//user input *\/ */
|
||||
/* /\* writeADC(0x1A,0xf0);//user input *\/ */
|
||||
/* /\* writeADC(0x1B,0x0f);//user input *\/ */
|
||||
/* /\* writeADC(0x1C,0x0f);//user input *\/ */
|
||||
/* /\* writeADC(0xD,0x48);//user input, alternate *\/ */
|
||||
|
||||
/* //writeADC(0xD,0xA);//1xsync */
|
||||
// writeADC(0xD,0xB);//1xbit high
|
||||
writeADC(0xD,0xC);//1xmixed frequqncy
|
||||
/* /\* //writeADC(0xD,0xA);//1xsync *\/ */
|
||||
/* // writeADC(0xD,0xB);//1xbit high */
|
||||
/* writeADC(0xD,0xC);//1xmixed frequqncy */
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
/* #endif */
|
||||
|
||||
|
||||
|
||||
@ -2554,15 +2562,15 @@ int prepareADC(){
|
||||
|
||||
|
||||
|
||||
bus_w(ADC_LATCH_DISABLE_REG,0x0); // enable all ADCs
|
||||
// bus_w(DAQ_REG,0x12); //adc pipeline=18
|
||||
/* bus_w(ADC_LATCH_DISABLE_REG,0x0); // enable all ADCs */
|
||||
/* // bus_w(DAQ_REG,0x12); //adc pipeline=18 */
|
||||
|
||||
//bus_w(DAQ_REG,0xbbbbbbbb);
|
||||
// bus_w(ADC_INVERSION_REG,0x1f6170c6);
|
||||
/* //bus_w(DAQ_REG,0xbbbbbbbb); */
|
||||
/* // bus_w(ADC_INVERSION_REG,0x1f6170c6); */
|
||||
|
||||
return OK;
|
||||
/* return OK; */
|
||||
|
||||
}
|
||||
/* } */
|
||||
|
||||
|
||||
int clearRAM() {
|
||||
|
@ -81,7 +81,7 @@ int getTemperature(int tempSensor);
|
||||
int initHighVoltage(int val,int imod);
|
||||
int initConfGain(int isettings,int val,int imod);
|
||||
|
||||
int setADC(int adc);
|
||||
//int setADC(int adc);
|
||||
//int configureMAC(int ipad, long long int macad, long long int detectormacadd, int detipad, int ival, int udpport);
|
||||
int configureMAC(uint32_t destip,uint64_t destmac,uint64_t sourcemac,int detipad,int ival,uint32_t destport);
|
||||
int getAdcConfigured();
|
||||
@ -160,7 +160,7 @@ int allocateRAM();
|
||||
|
||||
|
||||
int writeADC(int addr, int val);
|
||||
int prepareADC();
|
||||
//int prepareADC();
|
||||
|
||||
|
||||
|
||||
|
@ -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: c35203ebfb35ba605eaff601ce46e4d29c1f5690
|
||||
Revision: 24
|
||||
Repsitory UUID: 9ae128961675230ad322ff2867f1862dbe8566a7
|
||||
Revision: 25
|
||||
Branch: developer
|
||||
Last Changed Author: Anna_Bergamaschi
|
||||
Last Changed Rev: 3761
|
||||
Last Changed Date: 2018-04-27 14:46:10.176661554 +0200 ./server_funcs.h
|
||||
Last Changed Rev: 3764
|
||||
Last Changed Date: 2018-05-07 14:30:14.000000002 +0200 ./Makefile
|
||||
|
@ -1,6 +1,6 @@
|
||||
#define GITURL "git@github.com:slsdetectorgroup/slsDetectorPackage.git"
|
||||
#define GITREPUUID "c35203ebfb35ba605eaff601ce46e4d29c1f5690"
|
||||
#define GITREPUUID "9ae128961675230ad322ff2867f1862dbe8566a7"
|
||||
#define GITAUTH "Anna_Bergamaschi"
|
||||
#define GITREV 0x3761
|
||||
#define GITDATE 0x20180427
|
||||
#define GITREV 0x3764
|
||||
#define GITDATE 0x20180507
|
||||
#define GITBRANCH "developer"
|
||||
|
Loading…
x
Reference in New Issue
Block a user