mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-13 05:17:13 +02:00
Compare commits
15 Commits
9.1.0
...
debugInter
Author | SHA1 | Date | |
---|---|---|---|
f7695113b8 | |||
27f2321d64 | |||
545684c8e3 | |||
9584ea626d | |||
a2c26664ee | |||
02a36a148f | |||
142b184e62 | |||
dd2fe28ce6 | |||
0afd096eae | |||
98ae93fdde | |||
c654ac7f1f | |||
db2742495a | |||
d0c5c2a6e5 | |||
2c09d394a6 | |||
52f74142b1 |
@ -1,4 +1,4 @@
|
||||
hostname bchip085+
|
||||
hostname bchip020+
|
||||
|
||||
patword 0000 0000000000000000
|
||||
patword 0001 0000000000000000
|
||||
@ -416,28 +416,32 @@ patwaittime2 0
|
||||
|
||||
|
||||
####mcp2011
|
||||
#0:rx_udpip 10.1.1.102
|
||||
0:rx_tcpport 1954
|
||||
0:rx_udpip 10.1.1.102
|
||||
0:detectorip 10.1.1.19
|
||||
0:rx_udpport 32411
|
||||
####gui listening to
|
||||
zmqip 129.129.202.106
|
||||
zmqport 50001
|
||||
####data streaming out of
|
||||
rx_zmqip 10.1.2.103
|
||||
rx_zmqport 50003
|
||||
|
||||
0:rx_hostname mpc2011
|
||||
|
||||
|
||||
####pcmoench01
|
||||
#0:rx_tcpport 1977
|
||||
#0:rx_udpip 10.1.1.100
|
||||
#0:detectorip 10.1.1.19
|
||||
#0:rx_udpport 32410
|
||||
####gui listening to
|
||||
#zmqip 129.129.202.131
|
||||
#zmqport 30001
|
||||
####data streaming out of
|
||||
#rx_zmqip 10.1.2.103
|
||||
#rx_zmqport 30003
|
||||
#0:rx_hostname mpc2011
|
||||
|
||||
####mx-test-1
|
||||
0:rx_udpip 10.1.1.100
|
||||
0:detectorip 10.1.1.19
|
||||
0:rx_udpport 32410
|
||||
####gui listening to (on receiver pc)
|
||||
zmqip 129.129.202.92
|
||||
zmqport 30001
|
||||
#zmqip 129.129.202.92
|
||||
#zmqport 50001
|
||||
####data streaming out of
|
||||
rx_zmqip 10.1.1.100
|
||||
rx_zmqport 30003
|
||||
0:rx_hostname pcmoench01
|
||||
#rx_zmqip 10.1.1.100
|
||||
#rx_zmqport 50003
|
||||
#0:rx_hostname mx-test-1
|
||||
|
||||
|
||||
|
||||
|
2
slsDetectorCalibration/.gitignore
vendored
2
slsDetectorCalibration/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
*.o
|
||||
*.*~
|
@ -31,18 +31,19 @@ class MovingStat
|
||||
*/
|
||||
void Set(double val, double rms=0, int m=-1)
|
||||
{
|
||||
if (m>=0) m_n = m; else m_n = n;
|
||||
if (m>0) m_n = m; else m_n = n;
|
||||
m_newM=val*m_n;
|
||||
// cout << "set " << val << " " << m << " " << m_n << " " << m_newM << endl;
|
||||
SetRMS(rms);
|
||||
}
|
||||
/**
|
||||
/**
|
||||
clears the moving average number of samples parameter, mean and standard deviation
|
||||
*/
|
||||
void SetRMS(double rms)
|
||||
{
|
||||
if (rms<=0) {
|
||||
m_newM2=m_newM*m_newM/n;
|
||||
m_n=0;
|
||||
//m_n=0;
|
||||
} else {
|
||||
if (m_n>0)
|
||||
m_newM2=(m_n*rms*rms+m_newM*m_newM/m_n);
|
||||
@ -120,6 +121,7 @@ class MovingStat
|
||||
*/
|
||||
inline double Mean() const
|
||||
{
|
||||
// cout << "get " << m_n << " " << m_newM << " " << m_newM/m_n << endl;
|
||||
return (m_n > 0) ? m_newM/m_n : 0.0;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,8 @@
|
||||
#include <pthread.h>
|
||||
#include "slsDetectorData.h"
|
||||
#include "pedestalSubtraction.h"
|
||||
#include "commonModeSubtraction.h"
|
||||
#include "commonModeSubtractionNew.h"
|
||||
#include "ghostSummation.h"
|
||||
#include "tiffIO.h"
|
||||
#include "slsInterpolation.h"
|
||||
|
||||
@ -61,7 +62,7 @@ template <class dataType> class analogDetector {
|
||||
|
||||
|
||||
analogDetector(slsDetectorData<dataType> *d, int sign=1,
|
||||
commonModeSubtraction *cm=NULL, int nped=1000, int nnx=-1, int nny=-1, double *gm=NULL) : det(d), nx(nnx), ny(nny), stat(NULL), cmSub(cm), iframe(-1), dataSign(sign), gmap(gm), id(0) {
|
||||
commonModeSubtraction *cm=NULL, int nped=1000, int nnx=-1, int nny=-1, double *gm=NULL, ghostSummation<dataType> *gs=NULL) : det(d), nx(nnx), ny(nny), stat(NULL), cmSub(cm), dataSign(sign), iframe(-1), gmap(gm), ghSum(gs), id(0) {
|
||||
|
||||
if (det)
|
||||
det->getDetectorSize(nx,ny);
|
||||
@ -118,7 +119,7 @@ template <class dataType> class analogDetector {
|
||||
dataSign=orig->dataSign;
|
||||
iframe=orig->iframe;
|
||||
gmap=orig->gmap;
|
||||
cmSub=orig->cmSub;
|
||||
// cmSub=orig->cmSub;
|
||||
id=orig->id;
|
||||
xmin=orig->xmin;
|
||||
xmax=orig->xmax;
|
||||
@ -153,7 +154,16 @@ template <class dataType> class analogDetector {
|
||||
hs9=(TH2F*)(orig->hs9)->Clone();//new TH2F("hs","hs",(orig->hs)-getNbins,-500,9500,nx*ny,-0.5,nx*ny-0.5);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (orig->cmSub) {
|
||||
cmSub=(orig->cmSub)->Clone();
|
||||
cout <<"cloning cm" << endl;
|
||||
}
|
||||
else cmSub=NULL;
|
||||
if (orig->ghSum) {
|
||||
ghSum=(orig->ghSum)->Clone();
|
||||
cout <<"cloning gs" << endl;
|
||||
}
|
||||
else ghSum=NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -221,9 +231,10 @@ template <class dataType> class analogDetector {
|
||||
if (gm) {
|
||||
if (gmap) delete [] gmap;
|
||||
gmap=new double[nnx*nny];
|
||||
for (int iy=0; iy<nny; iy++) {
|
||||
for (int ix=0; ix<nnx; ix++) {
|
||||
for (int iy=0; iy<nny; iy++) {
|
||||
for (int ix=0; ix<nnx; ix++) {
|
||||
gmap[iy*nnx+ix]=gm[iy*nnx+ix];
|
||||
// cout << gmap[iy*nnx+ix] << " " ;
|
||||
}
|
||||
}
|
||||
return gmap;
|
||||
@ -275,6 +286,14 @@ template <class dataType> class analogDetector {
|
||||
|
||||
/** resets the commonModeSubtraction and increases the frame index */
|
||||
virtual void newFrame(){iframe++; if (cmSub) cmSub->newFrame();};
|
||||
|
||||
/** resets the commonModeSubtraction and increases the frame index */
|
||||
virtual void newFrame(char *data){
|
||||
iframe++;
|
||||
if (cmSub) cmSub->newFrame();
|
||||
calcGhost(data);
|
||||
// cout << getId() << " Calc ghost " << getGhost(15,15) << endl;
|
||||
};
|
||||
|
||||
|
||||
/** sets the commonModeSubtraction algorithm to be used
|
||||
@ -289,6 +308,11 @@ template <class dataType> class analogDetector {
|
||||
commonModeSubtraction *getCommonModeSubtraction() {return cmSub;};
|
||||
|
||||
|
||||
ghostSummation<dataType> *getGhostSummation(){return ghSum;};
|
||||
ghostSummation<dataType> *setGhostSummation(ghostSummation<dataType> *gs){ghSum=gs; return ghSum;};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
sets the sign of the data
|
||||
\param sign 1 means positive values for photons, -1 negative, 0 gets
|
||||
@ -304,11 +328,17 @@ template <class dataType> class analogDetector {
|
||||
\param iy pixel y coordinate
|
||||
\param cm 1 adds the value to common mod, 0 skips it. Defaults to 0. - not properly implemented
|
||||
*/
|
||||
virtual void addToPedestal(double val, int ix, int iy=0, int cm=0){
|
||||
virtual void addToPedestal(double val, int ix, int iy, int cm=0){
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
|
||||
|
||||
// cout << val << " " ;
|
||||
if (cmSub && cm>0) {
|
||||
val-= getCommonMode(ix, iy);
|
||||
}
|
||||
// cout << val << " " ;
|
||||
val+=getGhost(ix,iy);
|
||||
// cout << val ;
|
||||
// cout << endl;
|
||||
stat[iy][ix].addToPedestal(val);
|
||||
/* if (cmSub && cm>0) { */
|
||||
/* if (det) if (det->isGood(ix, iy)==0) return; */
|
||||
@ -318,29 +348,47 @@ template <class dataType> class analogDetector {
|
||||
}
|
||||
|
||||
double getCommonMode(int ix, int iy) {
|
||||
if (cmSub) return cmSub->getCommonMode(ix, iy);
|
||||
else return 0;
|
||||
if (cmSub) {
|
||||
return cmSub->getCommonMode(ix, iy);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
virtual void addToCommonMode(char *data){
|
||||
// cout << "+"<< getId() << endl;
|
||||
if (cmSub) {
|
||||
//cout << "*" << endl;
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
// if (getNumpedestals(ix,iy)>0)
|
||||
if (det->isGood(ix,iy))
|
||||
// if (det->isGood(ix,iy)) {
|
||||
addToCommonMode(data, ix, iy);
|
||||
}
|
||||
// cout << ":";
|
||||
// }
|
||||
}
|
||||
}
|
||||
//cout << "cm " << getCommonMode(0,0) << " " << getCommonMode(1,0) << endl;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void addToCommonMode(char *data, int ix, int iy=0){
|
||||
// cout <<".";
|
||||
if (cmSub) {
|
||||
//cout <<":";
|
||||
if (det) if (det->isGood(ix, iy)==0) return;
|
||||
if (getNumpedestals(ix,iy)>0){
|
||||
cmSub->addToCommonMode(subtractPedestal(data,ix,iy,0), ix, iy);
|
||||
// cout << ix << " " <<subtractPedestal(data,ix,iy,0) << endl;
|
||||
double val;
|
||||
if (det) {
|
||||
/* if (det->getChannel(data, ix, iy)>=0x3fff) */
|
||||
/* cout << ix << " " << iy << " " << det->getChannel(data, ix, iy) <<endl; */
|
||||
val= (dataSign*det->getValue(data, ix, iy)-getPedestal(ix,iy,0));
|
||||
} else
|
||||
val= (((double*)data)[iy*nx+ix]-getPedestal(ix,iy));
|
||||
val+=getGhost(ix,iy);
|
||||
|
||||
cmSub->addToCommonMode(val, ix, iy);
|
||||
//cout << ":";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -351,12 +399,13 @@ template <class dataType> class analogDetector {
|
||||
\param cm 0 (default) without common mode subtraction, 1 with common mode subtraction (if defined)
|
||||
\returns pedestal value
|
||||
*/
|
||||
virtual double getPedestal(int ix, int iy, int cm=0){
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
|
||||
if (cmSub && cm>0)
|
||||
virtual double getPedestal (int ix, int iy, int cm=0){
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
|
||||
if (cmSub && cm>0) {
|
||||
return stat[iy][ix].getPedestal()+getCommonMode(ix,iy);
|
||||
else return stat[iy][ix].getPedestal();
|
||||
else return -1;
|
||||
|
||||
} else return stat[iy][ix].getPedestal();
|
||||
} else return -1;
|
||||
};
|
||||
|
||||
|
||||
@ -367,15 +416,22 @@ template <class dataType> class analogDetector {
|
||||
\returns pedestal rms
|
||||
*/
|
||||
virtual double getPedestalRMS(int ix, int iy){
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
|
||||
return stat[iy][ix].getPedestalRMS();
|
||||
else return -1;
|
||||
double g=1;
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
|
||||
if (gmap) {
|
||||
g=gmap[iy*nx+ix];
|
||||
if (g==0) g=-1.;
|
||||
}
|
||||
|
||||
return stat[iy][ix].getPedestalRMS()/g;//divide by gain?
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
|
||||
virtual int getNumpedestals(int ix, int iy){
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
|
||||
return stat[iy][ix].getNumpedestals();
|
||||
else return -1;
|
||||
return -1;
|
||||
};
|
||||
/**
|
||||
gets pedestal (and common mode)
|
||||
@ -387,10 +443,10 @@ template <class dataType> class analogDetector {
|
||||
virtual double* getPedestal(double *ped){
|
||||
if (ped==NULL)
|
||||
ped=new double[nx*ny];
|
||||
for (int iy=0; iy<ny; iy++) {
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
for (int iy=0; iy<ny; iy++) {
|
||||
for (int ix=0; ix<nx; ix++) {
|
||||
ped[iy*nx+ix]=stat[iy][ix].getPedestal();
|
||||
//cout << ped[iy*nx+ix] << " " ;
|
||||
//cout << ped[iy*nx+ix] << " " ;
|
||||
}
|
||||
}
|
||||
return ped;
|
||||
@ -445,13 +501,14 @@ template <class dataType> class analogDetector {
|
||||
*/
|
||||
virtual void setPedestal(double *ped, double *rms=NULL, int m=-1){
|
||||
double rr=0;
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
if (rms) rr=rms[iy*nx+ix];
|
||||
stat[iy][ix].setPedestal(ped[iy*nx+ix],rr, m);
|
||||
// cout << ix << " " << iy << " " << ped[iy*nx+ix] << " " << stat[iy][ix].getPedestal() << endl;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -482,7 +539,24 @@ template <class dataType> class analogDetector {
|
||||
|
||||
}
|
||||
|
||||
virtual void calcGhost(char *data, int ix, int iy=1) {
|
||||
if (ghSum) {
|
||||
ghSum->calcGhost(data, ix, iy);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
virtual void calcGhost(char *data){if (ghSum) {
|
||||
ghSum->calcGhost(data);
|
||||
|
||||
// cout << getId() << " @ " << ghSum->getXTalk() << " " << ghSum->getGhost(15,15) << endl;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
virtual double getGhost(int ix, int iy) {if (ghSum) return ghSum->getGhost(ix, iy); return 0;};
|
||||
|
||||
/**
|
||||
write 32bit tiff file with detector image data
|
||||
@ -601,7 +675,7 @@ template <class dataType> class analogDetector {
|
||||
delete [] gm;
|
||||
return 1;
|
||||
}
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -626,7 +700,7 @@ template <class dataType> class analogDetector {
|
||||
delete [] gm;
|
||||
return 1;
|
||||
}
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -690,19 +764,24 @@ template <class dataType> class analogDetector {
|
||||
|
||||
virtual void addToPedestal(char *data, int cm=0) {
|
||||
|
||||
// cout << "add to pedestal " << endl;
|
||||
newFrame();
|
||||
// cout << "add to pedestal " << endl;
|
||||
newFrame(data);
|
||||
|
||||
if (cmSub) {
|
||||
//calcGhost(data);
|
||||
|
||||
|
||||
if (cmSub && cm) {
|
||||
// cout <<",";
|
||||
addToCommonMode(data);
|
||||
}
|
||||
}
|
||||
|
||||
//cout << xmin << " " << xmax << endl;
|
||||
// cout << ymin << " " << ymax << endl;
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
if (det->isGood(ix,iy)) {
|
||||
addToPedestal(data,ix,iy,1);
|
||||
// addToPedestal(data,ix,iy,1);
|
||||
addToPedestal(data,ix,iy,cm);
|
||||
//if (ix==10 && iy==10)
|
||||
// cout <<ix << " " << iy << " " << getPedestal(ix,iy)<< endl;
|
||||
#ifdef ROOTSPECTRUM
|
||||
@ -782,7 +861,7 @@ template <class dataType> class analogDetector {
|
||||
*/
|
||||
|
||||
|
||||
virtual void addToPedestal(char *data, int ix, int iy=0, int cm=0) {
|
||||
virtual void addToPedestal(char *data, int ix, int iy, int cm=0) {
|
||||
|
||||
|
||||
double val;
|
||||
@ -792,12 +871,13 @@ template <class dataType> class analogDetector {
|
||||
val=dataSign*det->getValue(data, ix, iy);
|
||||
else
|
||||
val=((double*)data)[iy*nx+ix];
|
||||
|
||||
// cout << val << endl;
|
||||
/* if (ix==10 && iy==10) */
|
||||
/* cout << ix << " " << iy << " " << val ; */
|
||||
/* if (ix==100 && iy==100) */
|
||||
/* cout << ix << " " << iy << " " << val; */
|
||||
addToPedestal(val,ix,iy);
|
||||
// cout << val << endl;
|
||||
/* if (ix==10 && iy==10) */
|
||||
/* cout <<" " << getPedestal(ix,iy)<< endl; */
|
||||
/* if (ix==100 && iy==100) */
|
||||
@ -818,15 +898,17 @@ template <class dataType> class analogDetector {
|
||||
|
||||
virtual int *subtractPedestal(char *data, int *val=NULL, int cm=0) {
|
||||
|
||||
newFrame();
|
||||
newFrame(data);
|
||||
|
||||
if (val==NULL)
|
||||
val=image;//new double[nx*ny];
|
||||
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
if (det->isGood(ix,iy))
|
||||
val[iy*nx+ix]+=subtractPedestal(data, ix, iy,cm);
|
||||
//calcGhost(data);
|
||||
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
if (det->isGood(ix,iy))
|
||||
val[iy*nx+ix]+=subtractPedestal(data, ix, iy,cm);
|
||||
}
|
||||
}
|
||||
return val;
|
||||
@ -847,18 +929,25 @@ template <class dataType> class analogDetector {
|
||||
|
||||
virtual double subtractPedestal(char *data, int ix, int iy=0, int cm=0) {
|
||||
double g=1.;
|
||||
double val;
|
||||
double val =0;
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
|
||||
if (gmap) {
|
||||
g=gmap[iy*nx+ix];
|
||||
if (g==0) g=-1.;
|
||||
}
|
||||
|
||||
if (det)
|
||||
if (det) {
|
||||
/* if (det->getChannel(data, ix, iy)>=0x3fff) */
|
||||
/* cout << ix << " " << iy << " " << det->getChannel(data, ix, iy) <<endl; */
|
||||
val= (dataSign*det->getValue(data, ix, iy)-getPedestal(ix,iy,cm))/g;
|
||||
else
|
||||
} else
|
||||
val= (((double*)data)[iy*nx+ix]-getPedestal(ix,iy))/g;
|
||||
|
||||
|
||||
//if (val>=0.5*thr)
|
||||
// cout << val << " " << (dataSign*det->getValue(data, ix, iy)-getPedestal(ix,iy,cm)) << " " << g << " ";
|
||||
|
||||
val+=getGhost(ix,iy)/g;
|
||||
|
||||
#ifdef ROOTSPECTRUM
|
||||
hs->Fill(val,(iy-ymin)*(xmax-xmin)+(ix-xmin));
|
||||
#ifdef ROOTCLUST
|
||||
@ -890,6 +979,7 @@ template <class dataType> class analogDetector {
|
||||
#endif
|
||||
return val;
|
||||
}
|
||||
return val;
|
||||
};
|
||||
|
||||
|
||||
@ -917,8 +1007,7 @@ template <class dataType> class analogDetector {
|
||||
int nph=0;
|
||||
double v;
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny) {
|
||||
v=subtractPedestal(data,ix,iy);
|
||||
|
||||
v=subtractPedestal(data,ix,iy,1);
|
||||
/* // cout << v << " " ; */
|
||||
/* #ifdef ROOTSPECTRUM */
|
||||
/* // cout << (iy-ymin)*(xmax-xmin)+(ix-xmin) << endl; */
|
||||
@ -927,8 +1016,14 @@ template <class dataType> class analogDetector {
|
||||
if (thr>0) {
|
||||
v+=0.5*thr;
|
||||
nph=v/thr;
|
||||
if (nph>0)
|
||||
|
||||
/* if (ix ==10 && iy<20) */
|
||||
/* cout << det->getValue(data,ix,iy) << " " << stat[iy][ix].getPedestal() << " " << getCommonMode(ix,iy) << " " << getPedestal(ix,iy,0)<< " " << getPedestal(ix,iy,1) << endl; */
|
||||
// cout << subtractPedestal(data,ix,iy,0) << " " << subtractPedestal(data,ix,iy,1) << " " << nph << endl;
|
||||
if (nph>0) {
|
||||
//cout << " " << nph << endl;
|
||||
return nph;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return v;
|
||||
@ -944,15 +1039,16 @@ template <class dataType> class analogDetector {
|
||||
*/
|
||||
int *getNPhotons(char *data, int *nph=NULL) {
|
||||
|
||||
double val;
|
||||
//double val;
|
||||
if (nph==NULL)
|
||||
nph=image;
|
||||
newFrame();
|
||||
|
||||
newFrame(data);
|
||||
|
||||
//calcGhost(data);
|
||||
addToCommonMode(data);
|
||||
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
for (int iy=ymin; iy<ymax; iy++) {
|
||||
for (int ix=xmin; ix<xmax; ix++) {
|
||||
if (det->isGood(ix,iy))
|
||||
nph[iy*nx+ix]+=getNPhotons(data, ix, iy);
|
||||
}
|
||||
@ -1030,13 +1126,16 @@ template <class dataType> class analogDetector {
|
||||
if (ymi<0) ymi=ymin;
|
||||
if (yma<0) yma=ymax;
|
||||
|
||||
for (int iy=ymi; iy<yma; iy++)
|
||||
for (int ix=xmi; ix<xma; ix++)
|
||||
newFrame(data);
|
||||
//calcGhost(data);
|
||||
addToCommonMode(data);
|
||||
for (int iy=ymi; iy<yma; iy++)
|
||||
for (int ix=xmi; ix<xma; ix++)
|
||||
if (det->isGood(ix,iy)) {
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny)
|
||||
val+=getNPhotons(data, ix, iy);
|
||||
}
|
||||
|
||||
|
||||
return val;
|
||||
|
||||
};
|
||||
@ -1054,7 +1153,7 @@ template <class dataType> class analogDetector {
|
||||
switch(fMode) {
|
||||
case ePedestal:
|
||||
//cout << "analog ped " << endl;
|
||||
addToPedestal(data);
|
||||
addToPedestal(data,1);
|
||||
break;
|
||||
default:
|
||||
// cout << "analog " << endl;
|
||||
@ -1138,6 +1237,7 @@ FILE *getFilePointer(){return myFile;};
|
||||
int dataSign; /**< sign of the data i.e. 1 if photon is positive, -1 if negative */
|
||||
int iframe; /**< frame number (not from file but incremented within the dataset every time newFrame is called */
|
||||
double *gmap;
|
||||
ghostSummation<dataType> *ghSum;/**< ghostSummation class */
|
||||
int *image;
|
||||
int id;
|
||||
//int xmin, xmax, ymin, ymax; int xmin; /**< minimum x of the region of interest */
|
||||
|
@ -14,7 +14,7 @@ class commonModeSubtraction {
|
||||
\param iroi number of regions on which one can calculate the common mode separately. Defaults to 1 i.e. whole detector
|
||||
|
||||
*/
|
||||
commonModeSubtraction(int iroi=1, int ns=3) : nROI(iroi), nsigma(ns) {
|
||||
commonModeSubtraction(int iroi=1, int ns=3) : nsigma(ns), nROI(iroi) {
|
||||
mean=new double[nROI];
|
||||
mean2=new double[nROI];
|
||||
nCm=new double[nROI];
|
||||
@ -23,6 +23,13 @@ class commonModeSubtraction {
|
||||
/** destructor - deletes the moving average(s) and the sum of pedestals calculator(s) */
|
||||
virtual ~commonModeSubtraction() {delete [] mean; delete [] mean2; delete [] nCm;};
|
||||
|
||||
/* commonModeSubtraction(commonModeSubtraction *cs) { */
|
||||
/* if (cs) new commonModeSubtraction(cs->getNRoi(), cs->nsigma); */
|
||||
/* } */
|
||||
|
||||
virtual commonModeSubtraction *Clone() {
|
||||
return new commonModeSubtraction(this->nROI, this->nsigma);
|
||||
}
|
||||
|
||||
/** clears the moving average and the sum of pedestals calculation - virtual func*/
|
||||
virtual void Clear(){
|
||||
@ -34,6 +41,7 @@ class commonModeSubtraction {
|
||||
|
||||
/** adds the average of pedestals to the moving average and reinitializes the calculation of the sum of pedestals for all ROIs. - virtual func*/
|
||||
virtual void newFrame(){
|
||||
//cout << "Reset CM" << endl;
|
||||
for (int i=0; i<nROI; i++) {
|
||||
// if (nCm[i]>0) cmStat[i].Calc(cmPed[i]/nCm[i]);
|
||||
nCm[i]=0;
|
||||
@ -52,7 +60,10 @@ class commonModeSubtraction {
|
||||
// if (iroi==0) val=100;
|
||||
// else val=-100;
|
||||
// if (isc>=0 && isc<nROI) {
|
||||
// cout << ix << " " << iy << " " << iroi << endl;
|
||||
//if (ix==15 && iy==15) cout << "=" << val << endl;
|
||||
if (iroi>=0 && iroi<nROI) {
|
||||
// cout << ix << " " << iy << " " << iroi << endl;
|
||||
mean[iroi]+=val;
|
||||
mean2[iroi]+=val*val;
|
||||
nCm[iroi]++;
|
||||
@ -70,9 +81,10 @@ class commonModeSubtraction {
|
||||
/* return 100; */
|
||||
/* else */
|
||||
/* return -100; */
|
||||
|
||||
// cout << "*" << ix << " " << iy << " " << iroi << " " << mean[iroi] << " " << nCm[iroi]<< endl;
|
||||
// if (ix==15 && iy==15) cout << "-" << mean[iroi]/nCm[iroi] << endl;
|
||||
if (iroi>=0 && iroi<nROI) {
|
||||
if (nCm[iroi]>0)
|
||||
if (nCm[iroi]>0)
|
||||
return mean[iroi]/nCm[iroi];
|
||||
}
|
||||
return 0;
|
||||
@ -96,8 +108,7 @@ class commonModeSubtraction {
|
||||
gets the common mode ROI for pixel ix, iy -should be overloaded!
|
||||
*/
|
||||
virtual int getROI(int ix, int iy){ (void) ix; (void) iy; return 0;};
|
||||
|
||||
|
||||
int getNRoi(){return nROI;};
|
||||
|
||||
protected:
|
||||
double *mean; /**<array of moving average of the pedestal average per region of interest */
|
||||
|
@ -45,7 +45,7 @@ class mythen3_01_jctbData : public slsDetectorData<short unsigned int> {
|
||||
|
||||
virtual short unsigned int* mythen03_frame(char *ptr, int dr=24, int nch=64*3, int off=5) {
|
||||
// off=0;
|
||||
int iarg;
|
||||
//int iarg;
|
||||
int64_t word, *wp;
|
||||
short unsigned int* val=new short unsigned int[nch];
|
||||
int bit[64];
|
||||
|
@ -49,7 +49,7 @@ class mythen3_02_jctbData : public mythen3_01_jctbData {
|
||||
|
||||
virtual short unsigned int* mythen03_frame(char *ptr, int dr=24, int nch=64*3, int off=5) {
|
||||
// off=0;
|
||||
int iarg;
|
||||
//int iarg;
|
||||
int64_t word, *wp;
|
||||
short unsigned int* val=new short unsigned int[nch];
|
||||
int bit[64];
|
||||
@ -57,7 +57,7 @@ class mythen3_02_jctbData : public mythen3_01_jctbData {
|
||||
int ioff=0;
|
||||
int idr=0;
|
||||
int ib=0;
|
||||
int ich=0;
|
||||
//int ich=0;
|
||||
int ii=0;
|
||||
int iw=0;
|
||||
bit[0]=17;//19;
|
||||
|
171
slsDetectorCalibration/dataStructures/deserializer.h
Normal file
171
slsDetectorCalibration/dataStructures/deserializer.h
Normal file
@ -0,0 +1,171 @@
|
||||
#ifndef DESERIALIZER_H
|
||||
#define DESERIALIZER_H
|
||||
#include <vector>
|
||||
|
||||
class deserializer : public slsDetectorData<int> {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
deserializer( std::vector <int> dbl, int nch=64*3,int dr=24, int off=2): slsDetectorData<int>(nch,1,nch*dr*8+off*8,NULL,NULL,NULL), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch), dbitlist(dbl) {};
|
||||
|
||||
deserializer( std::vector <int> dbl, int nch,int dr, int off, int ds): slsDetectorData<int>(nch,1,ds,NULL,NULL,NULL), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch), dbitlist(dbl) {};
|
||||
|
||||
virtual void getPixel(int ip, int &x, int &y) {x=-1; y=-1;};
|
||||
|
||||
virtual int getChannel(char *data, int ix, int iy=0) {
|
||||
int ret=-1;
|
||||
if (ix>=0 && ix<numberOfCounters) {
|
||||
int *val=deserializeAll(data,dbitlist,dynamicRange,numberOfCounters,serialOffset);
|
||||
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 int **getData(char *ptr, int dsize=-1) {
|
||||
int **val;
|
||||
val=new int*[1];
|
||||
val[0]=deserializeAll(ptr,dbitlist,dynamicRange,nx,serialOffset);
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
|
||||
static int* deserializeAll(char *ptr, std::vector <int> dbl, int dr=24, int nch=64*3, int off=5) {
|
||||
// off=0;
|
||||
//int iarg;
|
||||
int64_t word, *wp;
|
||||
int* val=new int[nch];
|
||||
int ioff=0;
|
||||
int idr=0;
|
||||
int ib=0;
|
||||
int iw=0;
|
||||
int ii=0;
|
||||
int ich;
|
||||
int nb=dbl.size();
|
||||
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) {
|
||||
ib=0;
|
||||
for (const auto &bit : dbl) {
|
||||
ich=iw+nch/nb*(ib);
|
||||
if (word&(1<<bit) && ich<nch) {
|
||||
//cout << "+" ;
|
||||
val[ich]|=(1<<idr);
|
||||
} //else {
|
||||
//cout << "-" ;
|
||||
//}
|
||||
ib++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static int* deserializeList(char *ptr, std::vector <int> dbl, int dr=24, int nch=64*3, int off=5) {
|
||||
// off=0;
|
||||
//int iarg;
|
||||
// int64_t word;
|
||||
int* val=new int[nch];
|
||||
//int ioff=0;
|
||||
int idr=0;
|
||||
int ib=0;
|
||||
int iw=0;
|
||||
int ii=0;
|
||||
int ich;
|
||||
int nb=dbl.size();
|
||||
|
||||
char *dval;
|
||||
|
||||
idr=0;
|
||||
for (ib=0; ib<nch; ib++) {
|
||||
val[ib]=0;
|
||||
}
|
||||
dval=ptr;
|
||||
|
||||
ib=0;
|
||||
ich=0;
|
||||
for (const auto &bit : dbl) {
|
||||
//ioff=off;
|
||||
idr=0;
|
||||
for (iw=0; iw<(nch*dr/nb)/8; iw++) {
|
||||
val[ich]|=(*dval)<<idr;
|
||||
idr+=8;
|
||||
dval++;
|
||||
if (idr>=dr) {
|
||||
idr=0;
|
||||
ich++;
|
||||
}
|
||||
}
|
||||
ii++;
|
||||
ib++;
|
||||
}//end for
|
||||
|
||||
|
||||
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;};
|
||||
virtual std::vector <int> setDBitList(std::vector <int> dbl) {dbitlist=dbl; return dbitlist;};
|
||||
virtual std::vector <int> getDBitList() {return dbitlist;};
|
||||
|
||||
|
||||
private:
|
||||
|
||||
int dynamicRange;
|
||||
int serialOffset;
|
||||
int frameNumber;
|
||||
int numberOfCounters;
|
||||
std::vector <int> dbitlist;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -1,470 +0,0 @@
|
||||
#ifndef EIGERMODULEDATA_H
|
||||
#define EIGERMODULEDATA_H
|
||||
#include "slsReceiverData.h"
|
||||
|
||||
|
||||
|
||||
class eigerHalfModuleData : public slsReceiverData<uint32_t> {
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Implements the slsReceiverData structure for the eiger prototype read out by a half module i.e. using the slsReceiver
|
||||
(256*256 pixels, 512 packets for 16 bit mode, 256 for 8, 128 for 4, 1024 for 32, 1040 etc.)
|
||||
\param d dynamic range
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
|
||||
|
||||
eigerHalfModuleData(bool t, bool l, int dr, int tg, int psize, int dsize, int npf, int x, int y, double c=0):
|
||||
slsReceiverData<uint32_t>(x, y, npf, psize),
|
||||
top(t), left(l),
|
||||
dynamicRange(dr), tenGiga(tg),
|
||||
packetSize(psize), onepacketdataSize(dsize), numberofPacketsPerFrame(npf),
|
||||
xtalk(c),
|
||||
header_t(0), footer_t(0){
|
||||
|
||||
|
||||
int **dMap;
|
||||
uint32_t **dMask;
|
||||
|
||||
dMap=new int*[ny];
|
||||
dMask=new uint32_t*[ny];
|
||||
|
||||
|
||||
for (int i = 0; i < ny; i++) {
|
||||
dMap[i] = new int[nx];
|
||||
dMask[i] = new uint32_t[nx];
|
||||
}
|
||||
|
||||
//Map
|
||||
int totalNumberOfBytes = numberofPacketsPerFrame * packetSize;
|
||||
int iPacket = 8;
|
||||
int iData = 0;
|
||||
int increment = (dynamicRange/8);
|
||||
int ic_increment = 1;
|
||||
if (dynamicRange == 4) {
|
||||
increment = 1;
|
||||
ic_increment = 2;
|
||||
}
|
||||
|
||||
if(top){
|
||||
for (int ir=0; ir<ny; ir++) {
|
||||
for (int ic=0; ic<nx; ic = ic + ic_increment) {
|
||||
dMap[ir][ic] = iPacket;
|
||||
iPacket += increment;
|
||||
iData += increment;
|
||||
//increment header
|
||||
if(iData >= onepacketdataSize){
|
||||
iPacket += 16;
|
||||
iData = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//bottom
|
||||
else{
|
||||
iData = 0;
|
||||
int numbytesperline;
|
||||
switch(dynamicRange){
|
||||
case 4: numbytesperline = 256; break;
|
||||
case 8: numbytesperline = 512; break;
|
||||
case 16:numbytesperline = 1024; break;
|
||||
case 32:numbytesperline = 2048; break;
|
||||
}
|
||||
iPacket = totalNumberOfBytes - numbytesperline - 8;
|
||||
if((dynamicRange == 32) && (!tenGiga))
|
||||
iPacket -= 16;
|
||||
|
||||
for (int ir=0; ir<ny; ir++) {
|
||||
for (int ic=0; ic<nx; ic = ic + ic_increment) {
|
||||
dMap[ir][ic] = iPacket;
|
||||
iPacket += increment;
|
||||
iData += increment;
|
||||
//--------------------32 bit 1giga -------------------
|
||||
if((dynamicRange == 32) && (!tenGiga)){
|
||||
if(iData == numbytesperline){
|
||||
iPacket -= (numbytesperline*2 + 16*3);
|
||||
iData = 0;
|
||||
}
|
||||
if(iData == onepacketdataSize){
|
||||
iPacket += 16;
|
||||
}
|
||||
}//------------end of 32 bit -------------------------
|
||||
else if((iData % numbytesperline) == 0){
|
||||
iPacket -= (numbytesperline*2);
|
||||
if(iData == onepacketdataSize){
|
||||
iPacket -= 16;
|
||||
iData = 0;
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//Mask
|
||||
for(int ir=0; ir<ny; ++ir)
|
||||
for(int ic=0; ic<nx; ++ic)
|
||||
dMask[ir][ic] = 0x0;
|
||||
|
||||
setDataMap(dMap);
|
||||
setDataMask(dMask);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** Returns the frame number for the given dataset.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
*/
|
||||
int getFrameNumber(char *buff){
|
||||
footer_t = (eiger_packet_footer_t*)(buff + onepacketdataSize + sizeof(eiger_packet_header_t));
|
||||
return ((uint32_t)(*( (uint64_t*) footer_t)));
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** gets the packets number
|
||||
\param buff pointer to the memory
|
||||
\returns packet number
|
||||
*/
|
||||
int getPacketNumber(char *buff){
|
||||
footer_t = (eiger_packet_footer_t*)(buff + onepacketdataSize + sizeof(eiger_packet_header_t));
|
||||
return(*( (uint16_t*) footer_t->packetnum));
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
returns the pixel value as double correcting for the output buffer crosstalk
|
||||
\param data pointer to the memory
|
||||
\param ix coordinate in the x direction
|
||||
\param iy coordinate in the y direction
|
||||
\returns channel value as double
|
||||
|
||||
*/
|
||||
double getValue(char *data, int ix, int iy=0) {
|
||||
// cout << "##" << (void*)data << " " << ix << " " <<iy << endl;
|
||||
if (xtalk==0)
|
||||
return getChannelwithMissingPackets(data, ix, iy);
|
||||
else
|
||||
return getChannelwithMissingPackets(data, ix, iy)-xtalk * getChannelwithMissingPackets(data, ix-1, iy);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the value of the selected channel for the given dataset. Virtual function, can be overloaded.
|
||||
\param data pointer to the dataset (including headers etc)
|
||||
\param ix pixel number in the x direction
|
||||
\param iy pixel number in the y direction
|
||||
\returns data for the selected channel, with inversion if required
|
||||
|
||||
*/
|
||||
|
||||
virtual int getChannelwithMissingPackets(char *data, int ix, int iy) {
|
||||
uint32_t m=0, n = 0;
|
||||
int linesperpacket,newix, newiy,origX;
|
||||
|
||||
|
||||
//cout <<"ix:"<<ix<<" nx:"<<nx<<" iy:"<<iy<<" ny:"<<ny<<" datamap[iy][ix]:"<< dataMap[iy][ix] <<" datasize:"<< dataSize <<endl;
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny && dataMap[iy][ix]>=0 && dataMap[iy][ix]<dataSize) {
|
||||
m=dataMask[iy][ix];
|
||||
|
||||
|
||||
//pixelpos1d = (nx * iy + ix);
|
||||
|
||||
switch(dynamicRange){
|
||||
case 4: if(tenGiga) linesperpacket=16; else linesperpacket=4;break;
|
||||
case 8: if(tenGiga) linesperpacket=8; else linesperpacket=2;break;
|
||||
case 16: if(tenGiga) linesperpacket=4; else linesperpacket=1;break;
|
||||
case 32: if(tenGiga) linesperpacket=2; else linesperpacket=1;break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//each byte is shared by 2 pixels for 4 bit mode
|
||||
origX = ix;
|
||||
if((dynamicRange == 4) && (ix%2))
|
||||
ix--;
|
||||
|
||||
|
||||
|
||||
// ------check if missing packet, get to pixel at start of packet-----------------
|
||||
|
||||
//to get the starting of a packet (except 1g 32 bit)
|
||||
newix = 0;
|
||||
// 0.5 Lines per packet for 1g 32 bit
|
||||
if(dynamicRange == 32 && !tenGiga)
|
||||
newix = ix - (ix%256);
|
||||
|
||||
//iy divided by linesperpacket depending on bitmode
|
||||
if(!(iy%linesperpacket))
|
||||
newiy = iy;
|
||||
else
|
||||
newiy = (iy - (iy%linesperpacket));
|
||||
|
||||
header_t = (eiger_packet_header_t*)((char*)(data +(dataMap[newiy][newix]-8)));
|
||||
uint16_t identifier = (uint16_t)*( (uint16_t*) header_t->missingpacket);
|
||||
|
||||
if(identifier==deactivatedPacketValue){
|
||||
// cprintf(RED,"deactivated packet\n");
|
||||
return -2;
|
||||
}
|
||||
// -----END OF CHECK -------------------------------------------------------------
|
||||
|
||||
|
||||
}else{
|
||||
cprintf(RED,"outside limits\n");
|
||||
return -99;
|
||||
}
|
||||
|
||||
//get proper data
|
||||
n = ((uint32_t)(*((uint32_t*)(((char*)data)+(dataMap[iy][ix])))));
|
||||
|
||||
//each byte is shared by 2 pixels for 4 bit mode
|
||||
if(dynamicRange == 4){
|
||||
if(ix != origX)
|
||||
return ((n & 0xf0)>>4)^m;
|
||||
return (n & 0xf)^m;
|
||||
}
|
||||
else if(dynamicRange == 8) return (n & 0xff)^m;
|
||||
else if(dynamicRange == 16) return (n & 0xffff)^m;
|
||||
else return (n & 0xffffffff)^m;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
/** sets the output buffer crosstalk correction parameter
|
||||
\param c output buffer crosstalk correction parameter to be set
|
||||
\returns current value for the output buffer crosstalk correction parameter
|
||||
|
||||
*/
|
||||
double setXTalk(double c) {xtalk=c; return xtalk;}
|
||||
|
||||
|
||||
/** gets the output buffer crosstalk parameter
|
||||
\returns current value for the output buffer crosstalk correction parameter
|
||||
*/
|
||||
double getXTalk() {return xtalk;}
|
||||
|
||||
void getChannelArray(double* data, char* buffer){
|
||||
for(int iy = 0; iy < ny; iy++){
|
||||
for(int ix = 0; ix < nx; ix++){
|
||||
data[iy*nx+ix] = getValue((char*)buffer,ix,iy);
|
||||
//cprintf(BLUE,"%d,%d :%f\n",ix,iy,value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int* decodeData(int *datain) {
|
||||
|
||||
int dataBytes = numberofPacketsPerFrame * onepacketdataSize;
|
||||
int nch = nx*ny;
|
||||
int* dataout = new int [nch];
|
||||
char *ptr=(char*)datain;
|
||||
char iptr;
|
||||
|
||||
const int bytesize=8;
|
||||
int ival=0;
|
||||
int ipos=0, ichan=0, ibyte;
|
||||
|
||||
switch (dynamicRange) {
|
||||
case 4:
|
||||
for (ibyte=0; ibyte<dataBytes; ++ibyte) {//for every byte (1 pixel = 1/2 byte)
|
||||
iptr=ptr[ibyte]&0xff; //???? a byte mask
|
||||
for (ipos=0; ipos<2; ++ipos) { //loop over the 8bit (twice)
|
||||
ival=(iptr>>(ipos*4))&0xf; //pick the right 4bit
|
||||
dataout[ichan]=ival;
|
||||
ichan++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
for (ichan=0; ichan<dataBytes; ++ichan) {//for every pixel (1 pixel = 1 byte)
|
||||
ival=ptr[ichan]&0xff; //????? a byte mask
|
||||
dataout[ichan]=ival;
|
||||
}
|
||||
break;
|
||||
case 16:
|
||||
for (ichan=0; ichan<nch; ++ichan) { //for every pixel
|
||||
ival=0;
|
||||
for (ibyte=0; ibyte<2; ++ibyte) { //for each byte (concatenate 2 bytes to get 16 bit value)
|
||||
iptr=ptr[ichan*2+ibyte];
|
||||
ival|=((iptr<<(ibyte*bytesize))&(0xff<<(ibyte*bytesize)));
|
||||
}
|
||||
dataout[ichan]=ival;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
//for every 32 bit (every element in datain array)
|
||||
for (ichan=0; ichan<nch; ++ichan) { //for every pixel
|
||||
ival=datain[ichan]&0xffffff;
|
||||
dataout[ichan]=ival;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return dataout;
|
||||
|
||||
};
|
||||
|
||||
|
||||
int* readNextFrameOnlyData(ifstream &filebin, int& fnum) {
|
||||
int framesize = numberofPacketsPerFrame * onepacketdataSize;
|
||||
|
||||
int* data = new int[framesize/(sizeof(int))];
|
||||
char *packet=new char[packetSize];
|
||||
fnum = -1;
|
||||
int pn=-1;
|
||||
int dataoffset = 0;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
|
||||
while (filebin.read(packet,packetSize)) {
|
||||
|
||||
fnum = getFrameNumber(packet); //cout << "fn:"<<fn<<endl;
|
||||
pn = getPacketNumber(packet); //cout << "pn:"<<pn<<endl;
|
||||
|
||||
memcpy(((char*)data)+dataoffset,packet+DATA_PACKET_HEADER_SIZE,onepacketdataSize);
|
||||
dataoffset+=onepacketdataSize;
|
||||
if(pn == numberofPacketsPerFrame)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
delete [] packet;
|
||||
if(!dataoffset){
|
||||
delete [] data;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
/*
|
||||
when u get packet form next frames
|
||||
//to remember the position to read next frame
|
||||
filebin.seekg (position, filebin.beg);
|
||||
position = filebin.tellg();
|
||||
|
||||
*/
|
||||
|
||||
int *readNextFramewithMissingPackets(ifstream &filebin, int& fnum) {
|
||||
|
||||
int* data = new int[(numberofPacketsPerFrame * onepacketdataSize)/(sizeof(int))];
|
||||
char *packet=new char[packetSize];
|
||||
fnum = -1;
|
||||
int pnum = 0;
|
||||
int fn = -1;
|
||||
int pn =-1;
|
||||
int dataoffset = 0;
|
||||
int missingpackets;
|
||||
|
||||
|
||||
if (filebin.is_open()) {
|
||||
|
||||
while (filebin.read(packet,packetSize)) {
|
||||
|
||||
fn = getFrameNumber(packet); //cout << "fn:"<<fn<<endl;
|
||||
pn = getPacketNumber(packet); //cout << "pn:"<<pn<<endl;
|
||||
|
||||
//first packet
|
||||
if(fnum == -1){
|
||||
fnum = fn;
|
||||
}
|
||||
//next frame packet
|
||||
else if (fnum != fn){
|
||||
//set file reading to the last frame's packet in file
|
||||
filebin.seekg(-packetSize, ios::cur);//filebin.beg
|
||||
break;
|
||||
}
|
||||
|
||||
//missing packets
|
||||
missingpackets = pn - pnum - 1;
|
||||
if(missingpackets){
|
||||
memset(((char*)data)+dataoffset,0xFF,missingpackets*onepacketdataSize);
|
||||
dataoffset+=(missingpackets*onepacketdataSize);
|
||||
pnum+=missingpackets;
|
||||
}
|
||||
|
||||
memcpy(((char*)data)+dataoffset,packet+DATA_PACKET_HEADER_SIZE,onepacketdataSize);
|
||||
dataoffset+=onepacketdataSize;
|
||||
pnum++;
|
||||
if(pnum == numberofPacketsPerFrame)
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
delete [] packet;
|
||||
if(!pnum){
|
||||
delete [] data;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//missing packets (added here to also catch end of file)
|
||||
missingpackets = numberofPacketsPerFrame - pnum;
|
||||
if(missingpackets){
|
||||
memset(((char*)data)+dataoffset,0xFF,missingpackets*onepacketdataSize);
|
||||
dataoffset+=(missingpackets*onepacketdataSize);
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
/** Missing Packet identifier value */
|
||||
const static uint16_t deactivatedPacketValue = 0xFEFE;
|
||||
|
||||
const static int DATA_PACKET_HEADER_SIZE = 8;
|
||||
const bool top;
|
||||
const bool left;
|
||||
const int dynamicRange;
|
||||
const bool tenGiga;
|
||||
const int packetSize;
|
||||
const int onepacketdataSize;
|
||||
const int numberofPacketsPerFrame;
|
||||
double xtalk; /**<output buffer crosstalk correction parameter */
|
||||
|
||||
|
||||
/** structure of an eiger packet*/
|
||||
typedef struct{
|
||||
unsigned char subframenum[4];
|
||||
unsigned char missingpacket[2];
|
||||
unsigned char portnum[1];
|
||||
unsigned char dynamicrange[1];
|
||||
} eiger_packet_header_t;
|
||||
|
||||
typedef struct{
|
||||
unsigned char framenum[6];
|
||||
unsigned char packetnum[2];
|
||||
} eiger_packet_footer_t;
|
||||
|
||||
eiger_packet_header_t* header_t;
|
||||
eiger_packet_footer_t* footer_t;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,148 +0,0 @@
|
||||
#ifndef GOTTHARDMODULEDATA_H
|
||||
#define GOTTHARDMODULEDATA_H
|
||||
#include "slsReceiverData.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define FRAMEMASK 0xFFFFFFFE
|
||||
#define PACKETMASK 1
|
||||
#define FRAMEOFFSET 0x1
|
||||
|
||||
|
||||
class gotthardModuleData : public slsReceiverData<uint16_t> {
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Implements the slsReceiverData structure for the gotthard read out by a module i.e. using the slsReceiver
|
||||
(1x1280 pixels, 2 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
|
||||
|
||||
gotthardModuleData(double c=0): slsReceiverData<uint16_t>(xpixels, ypixels, npackets, buffersize), xtalk(c) {
|
||||
|
||||
uint16_t **dMask;
|
||||
int **dMap;
|
||||
int ix, iy;
|
||||
int initial_offset = 2;
|
||||
int offset = initial_offset;
|
||||
|
||||
dMask=new uint16_t*[ypixels];
|
||||
dMap=new int*[ypixels];
|
||||
for (int i = 0; i < ypixels; i++) {
|
||||
dMap[i] = new int[xpixels];
|
||||
dMask[i] = new uint16_t[xpixels];
|
||||
}
|
||||
|
||||
for(ix=0; ix<ypixels; ++ix)
|
||||
for(iy=0; iy<xpixels; ++iy)
|
||||
dMask[ix][iy] = 0x0;
|
||||
|
||||
for(ix=0; ix<ypixels; ++ix){
|
||||
if(ix == (ypixels/2)){
|
||||
offset += initial_offset;//2
|
||||
offset++;
|
||||
}
|
||||
for(iy=0; iy<xpixels; ++iy){
|
||||
dMap[ix][iy] = offset;
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
|
||||
setDataMap(dMap);
|
||||
setDataMask(dMask);
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
int getFrameNumber(char *buff){
|
||||
int np=(*(int*)buff);
|
||||
//gotthards frame header must be incremented
|
||||
++np;
|
||||
//packet index should be 1 or 2
|
||||
return ((np&FRAMEMASK)>>FRAMEOFFSET);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
gets the packets number (last packet is labelled with 0 and is replaced with 40)
|
||||
\param buff pointer to the memory
|
||||
\returns packet number
|
||||
|
||||
*/
|
||||
|
||||
int getPacketNumber(char *buff){
|
||||
int np=(*(int*)buff);
|
||||
//gotthards frame header must be incremented
|
||||
++np;
|
||||
//packet index should be 1 or 2
|
||||
return ((np&PACKETMASK)+1);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
returns the pixel value as double correcting for the output buffer crosstalk
|
||||
\param data pointer to the memory
|
||||
\param ix coordinate in the x direction
|
||||
\param iy coordinate in the y direction
|
||||
\returns channel value as double
|
||||
|
||||
*/
|
||||
double getValue(char *data, int ix, int iy=0) {
|
||||
//check how it is for gotthard
|
||||
if (xtalk==0)
|
||||
return slsDetectorData<uint16_t>::getValue(data, ix, iy);
|
||||
else
|
||||
return slsDetectorData<uint16_t>::getValue(data, ix, iy)-xtalk*slsDetectorData<uint16_t>::getValue(data, ix-1, iy);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** sets the output buffer crosstalk correction parameter
|
||||
\param c output buffer crosstalk correction parameter to be set
|
||||
\returns current value for the output buffer crosstalk correction parameter
|
||||
|
||||
*/
|
||||
double setXTalk(double c) {xtalk=c; return xtalk;}
|
||||
|
||||
|
||||
/** gets the output buffer crosstalk parameter
|
||||
\returns current value for the output buffer crosstalk correction parameter
|
||||
*/
|
||||
double getXTalk() {return xtalk;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
double xtalk; /**<output buffer crosstalk correction parameter */
|
||||
const static int xpixels = 1280;
|
||||
const static int ypixels = 1;
|
||||
const static int npackets = 2;
|
||||
const static int buffersize = 1286;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,170 +0,0 @@
|
||||
#ifndef GOTTHARDMODULEDATANEW_H
|
||||
#define GOTTHARDMODULEDATANEW_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint64_t frameNumber; /**< is the frame number */
|
||||
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
|
||||
uint32_t packetNumber; /**< is the packet number */
|
||||
uint64_t bunchId; /**< is the bunch id from beamline */
|
||||
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
|
||||
uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */
|
||||
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
|
||||
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
|
||||
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
|
||||
uint32_t debug; /**< is for debugging purposes */
|
||||
uint16_t roundRNumber; /**< is the round robin set number */
|
||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
uint8_t version; /**< is the version number of this structure format */
|
||||
} sls_detector_header;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class gotthardModuleDataNew : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
const int offset;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Implements the slsReceiverData structure for the gotthard read out by a module i.e. using the slsReceiver
|
||||
(1x1280 pixels, 2 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
|
||||
|
||||
gotthardModuleDataNew(int off=24*2, int nch=1280): slsDetectorData<uint16_t>(nch, 1, nch*2+off), offset(off) {
|
||||
|
||||
uint16_t **dMask;
|
||||
int **dMap;
|
||||
int ix, iy;
|
||||
int ypixels=1;
|
||||
int xpixels=nch;
|
||||
|
||||
dMask=new uint16_t*[1];
|
||||
dMap=new int*[1];
|
||||
dMap[0] = new int[nch];
|
||||
dMask[0] = new uint16_t[nch];
|
||||
|
||||
for(int ix=0; ix<xpixels; ix++) {
|
||||
dMap[0][ix] = 2*ix+offset;
|
||||
dMask[0][ix] = 0x0;
|
||||
}
|
||||
|
||||
setDataMap(dMap);
|
||||
setDataMask(dMask);
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
|
||||
int getFrameNumber(char *buff){if (offset>=sizeof(sls_detector_header)) return ((sls_detector_header*)buff)->frameNumber; return iframe;};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
gets the packets number (last packet is labelled with 0 and is replaced with 40)
|
||||
\param buff pointer to the memory
|
||||
\returns packet number
|
||||
|
||||
*/
|
||||
|
||||
int getPacketNumber(char *buff){if (offset>=sizeof(sls_detector_header))return ((sls_detector_header*)buff)->packetNumber;};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<dataSize) ndata=dsize;
|
||||
else ndata=dataSize;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[dataSize];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
char *retval=0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np=0;
|
||||
int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff>=0)
|
||||
fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize) ){
|
||||
ff=getFrameNumber(data);
|
||||
np=getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,156 +0,0 @@
|
||||
#ifndef JUNGFRAU02DATA_H
|
||||
#define JUNGFRAU02DATA_H
|
||||
|
||||
#include "chiptestBoardData.h"
|
||||
|
||||
|
||||
|
||||
class jungfrau02Data : public chiptestBoardData {
|
||||
public:
|
||||
|
||||
/* test :) */
|
||||
|
||||
|
||||
/**
|
||||
Implements the chiptestBoardData structure for the jungfrau02 prototype
|
||||
(48x48 pixels, ADC2 for analog output, 2 more ADCs used for readout of digital bits, pixel offset configurable.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
|
||||
|
||||
jungfrau02Data(int nadc, int offset, double c=0): chiptestBoardData(48, 48, nadc, offset),
|
||||
xtalk(c) {
|
||||
|
||||
|
||||
|
||||
|
||||
uint16_t **dMask;
|
||||
int **dMap;
|
||||
|
||||
|
||||
|
||||
dMask=new uint16_t*[48];
|
||||
dMap=new int*[48];
|
||||
for (int i = 0; i < 48; i++) {
|
||||
dMap[i] = new int[48];
|
||||
dMask[i] = new uint16_t[48];
|
||||
}
|
||||
|
||||
|
||||
for (int iy=0; iy<48; iy++) {
|
||||
for (int ix=0; ix<48; ix++) {
|
||||
|
||||
dMap[ix][iy]=offset+(iy*48+ix)*nAdc;//dMap[iy][ix]=offset+(iy*48+ix)*nAdc;
|
||||
// cout << ix << " " << iy << " " << dMap[ix][iy] << endl;
|
||||
}
|
||||
}
|
||||
|
||||
cout << (0,0) << " " << dMap[0][0] << endl;
|
||||
cout << (47,47) << " " << dMap[47][47] << endl;
|
||||
|
||||
|
||||
for (int ix=0; ix<48; ix++) {
|
||||
for (int iy=0; iy<48; iy++)
|
||||
dMask[iy][ix]=0x0;
|
||||
|
||||
setDataMap(dMap);
|
||||
setDataMask(dMask);
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Returns the value of the selected channel for the given dataset. Since the ADC is only 14bit wide, only bit 0-13 are occupied. If the gain bits are read out, they are returned in bit 14-15.
|
||||
\param data pointer to the dataset (including headers etc)
|
||||
\param ix pixel number in the x direction
|
||||
\param iy pixel number in the y direction
|
||||
\returns data for the selected channel, with inversion if required
|
||||
|
||||
*/
|
||||
|
||||
virtual uint16_t getChannel(char *data, int ix, int iy=0) {
|
||||
uint16_t m=0, d=0;
|
||||
if (ix>=0 && ix<nx && iy>=0 && iy<ny && dataMap[iy][ix]>=0 && dataMap[iy][ix]<dataSize) {
|
||||
m=dataMask[iy][ix];
|
||||
d=*(((uint16_t*)(data))+dataMap[iy][ix]);
|
||||
// cout << ix << " " << iy << " " << (uint16_t*)data << " " << ((uint16_t*)(data))+dataMap[iy][ix] << " " << d << endl;
|
||||
if (nAdc==3) {
|
||||
//cout << "Gain bit!" << endl;
|
||||
if (*((uint16_t*)(data)+dataMap[iy][ix]+2)>8000) //exchange if gainBits==2 is returned!
|
||||
d|=(1<<14); // gain bit 1
|
||||
if (*((uint16_t*)(data)+dataMap[iy][ix]+1)>8000) //exchange if gainBits==2 is returned!
|
||||
d|=(1<<15); // gain bit 0
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return d^m;
|
||||
};
|
||||
|
||||
/**
|
||||
returns the pixel value as double correcting for the output buffer crosstalk
|
||||
\param data pointer to the memory
|
||||
\param ix coordinate in the x direction
|
||||
\param iy coordinate in the y direction
|
||||
\returns channel value as double
|
||||
|
||||
*/
|
||||
double getValue(char *data, int ix, int iy=0) {
|
||||
// cout << "##" << (void*)data << " " << ix << " " <<iy << endl;
|
||||
uint16_t d=getChannel(data, ix, iy);
|
||||
// cout << d << " " << (d&0x3fff) << endl;
|
||||
if (xtalk==0 || ix==0)
|
||||
return (double)(getChannel(data, ix, iy)&0x3fff);
|
||||
else
|
||||
return (double)(getChannel(data, ix, iy)&0x3fff)-xtalk* (double)(getChannel(data, ix, iy)&0x3fff);
|
||||
};
|
||||
|
||||
/**
|
||||
returns the gain bit value, i.e. returns 0 if(GB0==0 && GB1==0), returns 1 if(GB0==1 && GB1==0), returns 3 if(GB0==1 && GB1==1), if it returns 2 -> the gain bits are read out the wrong way around (i.e. GB0 and GB1 have to be reversed!)
|
||||
\param data pointer to the memory
|
||||
\param ix coordinate in the x direction
|
||||
\param iy coordinate in the y direction
|
||||
\returns gain bits as int
|
||||
*/
|
||||
int getGainBits(char *data, int ix, int iy=0) {
|
||||
uint16_t d=getChannel(data, ix, iy);
|
||||
return ((d&0xc000)>>14);
|
||||
};
|
||||
//*/
|
||||
|
||||
|
||||
|
||||
|
||||
/** sets the output buffer crosstalk correction parameter
|
||||
\param c output buffer crosstalk correction parameter to be set
|
||||
\returns current value for the output buffer crosstalk correction parameter
|
||||
|
||||
*/
|
||||
double setXTalk(double c) {xtalk=c; return xtalk;}
|
||||
|
||||
|
||||
/** gets the output buffer crosstalk parameter
|
||||
\returns current value for the output buffer crosstalk correction parameter
|
||||
*/
|
||||
double getXTalk() {return xtalk;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
double xtalk; /**<output buffer crosstalk correction parameter */
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,217 +0,0 @@
|
||||
#ifndef JUNGFRAU10MODULEDATA_H
|
||||
#define JUNGFRAU10MODULEBDATA_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
|
||||
class jungfrau10ModuleData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
typedef struct {
|
||||
uint64_t frameNumber; /**< is the frame number */
|
||||
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
|
||||
uint32_t packetNumber; /**< is the packet number */
|
||||
uint64_t bunchId; /**< is the bunch id from beamline */
|
||||
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
|
||||
uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */
|
||||
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
|
||||
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
|
||||
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
|
||||
uint32_t debug; /**< is for debugging purposes */
|
||||
uint16_t roundRNumber; /**< is the round robin set number */
|
||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
uint8_t version; /**< is the version number of this structure format */
|
||||
} sls_detector_header;
|
||||
|
||||
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
|
||||
|
||||
jungfrau10ModuleData(int ns=16384): slsDetectorData<uint16_t>(256*4, 256*2, 256*256*8*2+48, NULL, NULL, NULL) , iframe(0) {
|
||||
|
||||
|
||||
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
int ichip;
|
||||
|
||||
// cout << sizeof(uint16_t) << endl;
|
||||
int ip=0;
|
||||
for (int iy=0; iy<256*2; iy++) {
|
||||
for (int ix=0; ix<256*4; ix++){
|
||||
dataMap[iy][ix]=ip*2+48;
|
||||
ip++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* for (iadc=0; iadc<nadc; iadc++) { */
|
||||
/* ichip=iadc/4; */
|
||||
|
||||
/* for (int i=0; i<sc_width*sc_height; i++) { */
|
||||
|
||||
/* if (ichip%2==0) { */
|
||||
/* row=sc_height+i/sc_width; */
|
||||
/* col=(ichip/2)*256+iadc%4*sc_width+(i%sc_width); */
|
||||
/* } else { */
|
||||
/* row=sc_height-1-i/sc_width; */
|
||||
/* col=((ichip/2)*256+iadc%4*sc_width)+sc_width-(i%sc_width)-1; */
|
||||
/* } */
|
||||
|
||||
|
||||
|
||||
/* /\* if (iadc<nadc/2) { *\/ */
|
||||
/* /\* row=sc_height+i/sc_width; *\/ */
|
||||
/* /\* col=iadc*sc_width+(i%sc_width); *\/ */
|
||||
/* /\* } else { *\/ */
|
||||
/* /\* row=sc_height-1-i/sc_width; *\/ */
|
||||
/* /\* col=(nx-1)-((iadc-16)*sc_width)-(i%sc_width); *\/ */
|
||||
/* /\* } *\/ */
|
||||
/* if (row<0 || row>=ny || col<0 || col>=nx) { */
|
||||
/* cout << "Wrong row, column " << row << " " << col << " " << iadc << " " << i << endl; */
|
||||
/* } else */
|
||||
/* dataMap[row][col]=(nadc*i+iadc)*2; */
|
||||
/* if (dataMap[row][col]<0 || dataMap[row][col]>=dataSize) */
|
||||
/* cout << "Error: pointer " << dataMap[row][col] << " out of range " << row << " " << col <<" " << iadc << " " << i << endl; */
|
||||
/* else { */
|
||||
/* xmap[nadc*i+iadc]=col; */
|
||||
/* ymap[nadc*i+iadc]=row; */
|
||||
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
// }
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
|
||||
int getFrameNumber(return (sls_detector_header*)buff)->frameNumber;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
virtual int getPacketNumber(char *buff)=0;
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors!
|
||||
\param filebin input file stream (binary)
|
||||
\returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete
|
||||
|
||||
*/
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[dataSize];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
// char *readNextFrame(ifstream &filebin){
|
||||
// int afifo_length=0;
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
char *retval=0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np=0;
|
||||
int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff>=0)
|
||||
fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize) ){
|
||||
ff=getFrameNumber(data);
|
||||
np=getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,246 +0,0 @@
|
||||
#ifndef MOENCH02CTB10GBDATA_H
|
||||
#define MOENCH02CTB10GBDATA_H
|
||||
#include <stdio.h>
|
||||
#include "slsDetectorData.h"
|
||||
#include "slsReceiverData.h"
|
||||
|
||||
|
||||
class moench02Ctb10GbData : public slsReceiverData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
// int *xmap, *ymap;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
|
||||
int maplength;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
|
||||
|
||||
moench02Ctb10GbData(int ns=6400): slsReceiverData<uint16_t>(160, 160, 50, 8208) , nadc(4), sc_width(40), sc_height(160) {
|
||||
|
||||
|
||||
int adc_nr[4]={120,0,80,40};
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
int i;
|
||||
int npackets=50;
|
||||
maplength = 8208*npackets;
|
||||
//this->setDataSize(maplength);
|
||||
/* maplength=this->getDataSize()/2; */
|
||||
|
||||
for (int ip=0; ip<npackets; ip++) {
|
||||
for (int is=0; is<128; is++) {
|
||||
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
i=128*ip+is;
|
||||
if (i<sc_width*sc_height) {
|
||||
col=adc_nr[iadc]+(i%sc_width);
|
||||
row=i/sc_width;
|
||||
dataMap[row][col]=(32*i+iadc+2)*2+16*(ip+1);
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=8208*npackets) {
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
int ibyte;
|
||||
int ii=0;
|
||||
|
||||
for (int ipacket=0; ipacket<npackets; ipacket++) {
|
||||
for (int ibyte=0; ibyte< 8208/2; ibyte++) {
|
||||
i=ipacket*8208/2+ibyte;
|
||||
if(ibyte<8){
|
||||
xmap[i]=-1;
|
||||
ymap[i]=-1;
|
||||
}else{
|
||||
isample=ii/32;
|
||||
iadc=ii%32;
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
if(iadc>=2 && iadc<=5){
|
||||
xmap[i]=adc_nr[iadc-2]+ix;
|
||||
ymap[i]=iy;
|
||||
}else{
|
||||
xmap[i]=-1;
|
||||
ymap[i]=-1;
|
||||
}
|
||||
ii++;
|
||||
}
|
||||
}//end loop on bytes
|
||||
}//end loop on packets
|
||||
|
||||
iframe=0;
|
||||
cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
void getPixel(int ip, int &x, int &y) {
|
||||
if(ip>=0 && ip<maplength){
|
||||
x=xmap[ip];
|
||||
y=ymap[ip];
|
||||
}else{
|
||||
cerr<<"WRONG ARRAY LENGTH"<<endl;
|
||||
cerr<<"Trying to access the "<<ip<<"-th element"<<endl;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
int getFrameNumber(char *buff){return *((int*)buff)&0xffffffff;};
|
||||
/* virtual int getFrameNumber(char *buff){(void)buff; return iframe;}; */
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
virtual int getPacketNumber(char *buff)=0;
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff){return ((*(((int*)(buff+4))))&0xff)+1;};
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
//virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors!
|
||||
\param filebin input file stream (binary)
|
||||
\returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete
|
||||
|
||||
*/
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* //cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[packetSize*nPackets];
|
||||
char *retval=0;
|
||||
int nd;
|
||||
np=0;
|
||||
int pn;
|
||||
char aa[8224]={0};
|
||||
char *packet=(char *)aa;
|
||||
int fnum = -1;
|
||||
if (ff>=0)
|
||||
fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
|
||||
|
||||
cout << "+";
|
||||
|
||||
while(filebin.read((char*)packet, 8208)){
|
||||
|
||||
pn=getPacketNumber(packet);
|
||||
if (fnum<0)
|
||||
fnum= getFrameNumber(packet);
|
||||
|
||||
|
||||
if (fnum>=0) {
|
||||
if (getFrameNumber(packet) !=fnum) {
|
||||
|
||||
if (np==0){
|
||||
cout << "-";
|
||||
delete [] data;
|
||||
return NULL;
|
||||
} else
|
||||
filebin.seekg(-8208,ios_base::cur);
|
||||
return data;
|
||||
}
|
||||
|
||||
memcpy(data+(pn-1)*packetSize, packet, packetSize);
|
||||
|
||||
np++;
|
||||
if (np==nPackets)
|
||||
break;
|
||||
if (pn==nPackets)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
cerr<<filebin<<" not open!!!"<<endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (np==0){
|
||||
cout << "?";
|
||||
delete [] data;
|
||||
return NULL;
|
||||
}// else if (np<nPackets)
|
||||
// cout << "Frame " << fnum << " lost " << nPackets-np << " packets " << endl;
|
||||
|
||||
|
||||
return data;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int fnum=-1, np;
|
||||
return readNextFrame(filebin, fnum, np);
|
||||
};
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,187 +0,0 @@
|
||||
#ifndef MOENCH02CTBDATADGS_H
|
||||
#define MOENCH02CTBDATADGS_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
|
||||
class moench02CtbData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
// int *xmap, *ymap;
|
||||
//int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
|
||||
int maplength;
|
||||
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
|
||||
|
||||
moench02CtbDataDGS(int ns=6400): slsDetectorData<uint16_t>(160, 160, ns*(2*32+8), NULL, NULL) , sc_width(40), sc_height(160) {
|
||||
|
||||
|
||||
int adc_off[4]={40,0,120,80};
|
||||
int adc_nr[4]={8,10,20,23};
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc, iiadc;
|
||||
int ix, iy;
|
||||
maplength=this->getDataSize()/2;
|
||||
//cout << maplength << endl;
|
||||
|
||||
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_off[iiadc]+(i%sc_width);
|
||||
row=i/sc_width;
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=0; i<maplength; i++) {
|
||||
//cout << i << endl;
|
||||
isample=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>=0){
|
||||
xmap[i]=adc_off[iadc]+ix;
|
||||
ymap[i]=iy;
|
||||
}else{
|
||||
xmap[i]=-1;
|
||||
ymap[i]=-1;
|
||||
}
|
||||
}
|
||||
iframe=0;
|
||||
cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
void getPixel(int ip, int &x, int &y) {
|
||||
if(ip>=0 && ip<maplength){
|
||||
x=xmap[ip];
|
||||
y=ymap[ip];
|
||||
}/*else{
|
||||
cerr<<"WRONG ARRAY LENGTH"<<endl;
|
||||
cerr<<"Trying to access the "<<ip<<"-th element"<<endl;
|
||||
}*/
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
Returns the gain for the selected pixel (at the moemnt only 3rd supercolumn)
|
||||
\param buff pointer to the dataset
|
||||
\param ix x coordinate
|
||||
\param iy y coordinate
|
||||
\returns gain value
|
||||
*/
|
||||
|
||||
int getGain(char *buff, int ix, int iy) {
|
||||
int isample=iy*sc_width+iy;
|
||||
if (ix<sc_width) return 0; //first supercolumn no gain switching - could return the static gain if wished
|
||||
if (ix<2*sc_width) return 0; //second supercolumn no gain switching - could return the static gain if wished
|
||||
if (ix<3*sc_width){
|
||||
if(*((long*)(buff+(32*2*isample+8*(isample-1)))&(1>>31)) return 1;
|
||||
return 0;
|
||||
}
|
||||
return 0; //not yet implemented for 4th supercolumn
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
|
||||
virtual int getFrameNumber(char *buff){(void)buff; return iframe;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
virtual int getPacketNumber(char *buff)=0;
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors!
|
||||
\param filebin input file stream (binary)
|
||||
\returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete
|
||||
|
||||
*/
|
||||
virtual char *readNextFrame(ifstream &filebin){
|
||||
// int afifo_length=0;
|
||||
uint16_t *afifo_cont;
|
||||
int ib=0;
|
||||
if (filebin.is_open()) {
|
||||
afifo_cont=new uint16_t[dataSize/2];
|
||||
while (filebin.read(((char*)afifo_cont)+ib,2)) {
|
||||
ib+=2;
|
||||
if (ib==dataSize) break;
|
||||
}
|
||||
if (ib>0) {
|
||||
iframe++;
|
||||
//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;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,137 +0,0 @@
|
||||
#ifndef MOENCH02MODULEDATA_H
|
||||
#define MOENCH02MODULEDATA_H
|
||||
#include "slsReceiverData.h"
|
||||
|
||||
|
||||
|
||||
class moench02ModuleData : public slsReceiverData<uint16_t> {
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
|
||||
|
||||
moench02ModuleData(double c=0): slsReceiverData<uint16_t>(160, 160, 40, 1286),
|
||||
xtalk(c) {
|
||||
|
||||
|
||||
|
||||
|
||||
uint16_t **dMask;
|
||||
int **dMap;
|
||||
int ix, iy;
|
||||
|
||||
|
||||
|
||||
dMask=new uint16_t*[160];
|
||||
dMap=new int*[160];
|
||||
for (int i = 0; i < 160; i++) {
|
||||
dMap[i] = new int[160];
|
||||
dMask[i] = new uint16_t[160];
|
||||
}
|
||||
|
||||
for (int isc=0; isc<4; isc++) {
|
||||
for (int ip=0; ip<10; ip++) {
|
||||
|
||||
for (int ir=0; ir<16; ir++) {
|
||||
for (int ic=0; ic<40; ic++) {
|
||||
|
||||
ix=isc*40+ic;
|
||||
iy=ip*16+ir;
|
||||
|
||||
dMap[iy][ix]=1286*(isc*10+ip)+2*ir*40+2*ic+4;
|
||||
// cout << ix << " " << iy << " " << dMap[ix][iy] << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ix=0; ix<120; ix++) {
|
||||
for (iy=0; iy<160; iy++)
|
||||
dMask[iy][ix]=0x3fff;
|
||||
}
|
||||
for (ix=120; ix<160; ix++) {
|
||||
for (iy=0; iy<160; iy++)
|
||||
dMask[iy][ix]=0x0;
|
||||
}
|
||||
|
||||
|
||||
setDataMap(dMap);
|
||||
setDataMask(dMask);
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
gets the packets number (last packet is labelled with 0 and is replaced with 40)
|
||||
\param buff pointer to the memory
|
||||
\returns packet number
|
||||
|
||||
*/
|
||||
|
||||
int getPacketNumber(char *buff){
|
||||
int np=(*(int*)buff)&0xff;
|
||||
if (np==0)
|
||||
np=40;
|
||||
return np;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
returns the pixel value as double correcting for the output buffer crosstalk
|
||||
\param data pointer to the memory
|
||||
\param ix coordinate in the x direction
|
||||
\param iy coordinate in the y direction
|
||||
\returns channel value as double
|
||||
|
||||
*/
|
||||
double getValue(char *data, int ix, int iy=0) {
|
||||
// cout << "##" << (void*)data << " " << ix << " " <<iy << endl;
|
||||
if (xtalk==0 || ix%40==0)
|
||||
return slsDetectorData<uint16_t>::getValue(data, ix, iy);
|
||||
else
|
||||
return slsDetectorData<uint16_t>::getValue(data, ix, iy)-xtalk*slsDetectorData<uint16_t>::getValue(data, ix-1, iy);
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** sets the output buffer crosstalk correction parameter
|
||||
\param c output buffer crosstalk correction parameter to be set
|
||||
\returns current value for the output buffer crosstalk correction parameter
|
||||
|
||||
*/
|
||||
double setXTalk(double c) {xtalk=c; return xtalk;}
|
||||
|
||||
|
||||
/** gets the output buffer crosstalk parameter
|
||||
\returns current value for the output buffer crosstalk correction parameter
|
||||
*/
|
||||
double getXTalk() {return xtalk;}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
double xtalk; /**<output buffer crosstalk correction parameter */
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,285 +0,0 @@
|
||||
#ifndef MOENCH03CTB10GBDATA_H
|
||||
#define MOENCH03CTB10GBDATA_H
|
||||
#include "slsReceiverData.h"
|
||||
|
||||
|
||||
|
||||
class moench03Ctb10GbData : public slsReceiverData<uint16_t> {
|
||||
|
||||
protected:
|
||||
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
|
||||
|
||||
// moench03Ctb10GbData(int ns=5000): slsDetectorData<uint16_t>(400, 400, 8208*40, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) {
|
||||
moench03Ctb10GbData(int ns=5000): slsReceiverData<uint16_t>(400, 400, 40, 8208), nadc(32), sc_width(25), sc_height(200) {
|
||||
|
||||
int adc_nr[32]={200,225,250,275,300,325,350,375,\
|
||||
0,25,50,75,100,125,150,175,\
|
||||
175,150,125,100,75,50,25,0,\
|
||||
375,350,325,300,275,250,225,200};
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
int npackets=40;
|
||||
int i;
|
||||
|
||||
|
||||
for (int ip=0; ip<npackets; ip++) {
|
||||
for (int is=0; is<128; is++) {
|
||||
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
i=128*ip+is;
|
||||
if (i<sc_width*sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=adc_nr[iadc]+(i%sc_width);
|
||||
if (iadc<16) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
dataMap[row][col]=(nadc*i+iadc)*2+16*(ip+1);
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=8208*40)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ipacket;
|
||||
int ibyte;
|
||||
int ii=0;
|
||||
for (int ipacket=0; ipacket<npackets; ipacket++) {
|
||||
for (int ibyte=0; ibyte< 8208/2; ibyte++) {
|
||||
i=ipacket*8208/2+ibyte;
|
||||
if (ibyte<8) {
|
||||
//header!
|
||||
xmap[i]=-1;
|
||||
ymap[i]=-1;
|
||||
} else {
|
||||
// ii=ibyte+128*32*ipacket;
|
||||
isample=ii/nadc;
|
||||
iadc=ii%nadc;
|
||||
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
if (iadc<(nadc/2)) {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2-1-iy;
|
||||
} else {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2+iy;
|
||||
}
|
||||
|
||||
ii++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
|
||||
int getFrameNumber(char *buff){return *((int*)buff)&0xffffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff){return ((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& fnum, char *data=NULL) {
|
||||
int dd=0;
|
||||
if (data==NULL) {
|
||||
data=new char[packetSize*nPackets];
|
||||
dd=1;
|
||||
}
|
||||
char *retval=0;
|
||||
int np=0, nd;
|
||||
fnum = -1;
|
||||
int pn;
|
||||
char aa[8224];
|
||||
char *packet=(char *)aa;
|
||||
int place;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
|
||||
|
||||
|
||||
place=filebin.tellg();
|
||||
while(filebin.read((char*)packet, 8208) && np<nPackets){
|
||||
pn=getPacketNumber(packet);
|
||||
if (pn==1 && fnum<0)
|
||||
fnum= getFrameNumber(packet);
|
||||
|
||||
// cout <<getFrameNumber(packet)<< " fn: " << fnum << "\t pn: " << pn << " np " << np << endl;
|
||||
if (fnum>=0) {
|
||||
if (getFrameNumber(packet) !=fnum) {
|
||||
cout << "-"<<endl;
|
||||
filebin.seekg(place);
|
||||
if (np==0){
|
||||
if (dd)
|
||||
delete [] data;
|
||||
return NULL;
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(data+(pn-1)*packetSize, packet, packetSize);
|
||||
np++;
|
||||
if (np==nPackets)
|
||||
return data;
|
||||
|
||||
}
|
||||
place=filebin.tellg();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (np==0){
|
||||
cout << "-"<<endl;
|
||||
filebin.seekg(place);
|
||||
if (dd)
|
||||
delete [] data;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//filebin.seekg(place);
|
||||
return data;
|
||||
};
|
||||
|
||||
/* virtual char *readNextFrame(ifstream &filebin, int& fnum) { */
|
||||
/* char *data=new char[packetSize*nPackets]; */
|
||||
/* char *retval=0; */
|
||||
/* int np=0, nd; */
|
||||
/* fnum = -1; */
|
||||
/* int pn; */
|
||||
/* char aa[8224]; */
|
||||
/* char *packet=(char *)aa; */
|
||||
|
||||
/* if (filebin.is_open()) { */
|
||||
|
||||
|
||||
|
||||
|
||||
/* while(filebin.read((char*)packet, 8208) && np<nPackets){ */
|
||||
/* pn=getPacketNumber(packet); */
|
||||
|
||||
/* if (pn==1 && fnum<0) */
|
||||
/* fnum= getFrameNumber(packet); */
|
||||
|
||||
/* // cout << "fn: " << fnum << "\t pn: " << pn << endl; */
|
||||
/* if (fnum>=0) { */
|
||||
/* if (getFrameNumber(packet) !=fnum) { */
|
||||
|
||||
/* if (np==0){ */
|
||||
/* delete [] data; */
|
||||
/* return NULL; */
|
||||
/* } else */
|
||||
/* return data; */
|
||||
/* } */
|
||||
|
||||
/* memcpy(data+(pn-1)*packetSize, packet, packetSize); */
|
||||
/* np++; */
|
||||
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* } */
|
||||
|
||||
/* if (np==0){ */
|
||||
/* delete [] data; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
|
||||
/* }; */
|
||||
|
||||
int getPacketNumber(int x, int y) {return dataMap[y][x]/8208;};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -2,7 +2,7 @@
|
||||
#define MOENCH03T1RECDATANEW_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
#define VERSION_V2
|
||||
//#define VERSION_V2
|
||||
/**
|
||||
@short structure for a Detector Packet or Image Header
|
||||
@li frameNumber is the frame number
|
||||
@ -33,7 +33,7 @@
|
||||
uint16_t roundRNumber; /**< is the round robin set number */
|
||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
uint8_t version; /**< is the version number of this structure format */
|
||||
#ifdef VERSION_V2
|
||||
#ifndef VERSION_V1
|
||||
uint64_t packetCaught[8]; /**< is the version number of this structure format */
|
||||
#endif
|
||||
|
||||
@ -100,6 +100,9 @@ class moench03T1ReceiverDataNew : public slsDetectorData<uint16_t> {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
|
||||
#ifdef HIGHZ
|
||||
dataMask[row][col]=0x3fff;
|
||||
#endif
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=nSamples*2*32)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
|
@ -34,6 +34,9 @@
|
||||
uint16_t roundRNumber; /**< is the round robin set number */
|
||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
uint8_t version; /**< is the version number of this structure format */
|
||||
#ifndef VERSION_V1
|
||||
uint64_t packetCaught[8]; /**< is the version number of this structure format */
|
||||
#endif
|
||||
} sls_detector_header;
|
||||
|
||||
|
||||
|
176
slsDetectorCalibration/dataStructures/moench03T1ReorderedData.h
Normal file
176
slsDetectorCalibration/dataStructures/moench03T1ReorderedData.h
Normal file
@ -0,0 +1,176 @@
|
||||
#ifndef MOENCH03T1REORDERED_H
|
||||
#define MOENCH03T1REORDERED_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
class moench03T1ReorderedData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
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
|
||||
*/
|
||||
moench03T1ReorderedData(): slsDetectorData<uint16_t>(400, 400, 2*400*400+2*8) {
|
||||
for (int iy=0; iy<400; iy++)
|
||||
for (int ix=0; ix<400; ix++)
|
||||
dataMap[iy][ix]=2*8+2*(iy*400+ix);
|
||||
|
||||
int ibyte;
|
||||
for (ibyte=0; ibyte<8; ibyte++){
|
||||
xmap[ibyte]=-1;
|
||||
ymap[ibyte]=-1;
|
||||
}
|
||||
for (ibyte=0; ibyte<400*400; ibyte++){
|
||||
xmap[ibyte+8]=ibyte%400;
|
||||
ymap[ibyte+8]=ibyte/400;
|
||||
}
|
||||
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
|
||||
|
||||
int getFrameNumber(char *buff){return *((int*)buff);};
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[dataSize];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
char *retval=0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np=0;
|
||||
int pn;
|
||||
|
||||
if (ff>=0)
|
||||
fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize) ){
|
||||
ff=getFrameNumber(data);
|
||||
np=40;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<dataSize) ndata=dsize;
|
||||
else ndata=dataSize;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -61,6 +61,9 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
dataMap[row][col]=(nadc*i+iadc)*2+offset;//+16*(ip+1);
|
||||
#ifdef HIGHZ
|
||||
dataMask[row][col]=0x3fff;
|
||||
#endif
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=dataSize)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
@ -201,15 +204,15 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
char *retval=0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
/* char *retval=0; */
|
||||
/* int nd; */
|
||||
/* int fnum = -1; */
|
||||
np=0;
|
||||
int pn;
|
||||
/* int pn; */
|
||||
|
||||
|
||||
if (ff>=0)
|
||||
fnum=ff;
|
||||
/* if (ff>=0) */
|
||||
/* fnum=ff; */
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, 32*2*nSamples) ){
|
||||
@ -218,7 +221,7 @@ class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
#ifndef MOENCH03CTB10GBT1DATA_H
|
||||
#define MOENCH03CTB10GBT1DATA_H
|
||||
#include "slsReceiverData.h"
|
||||
#ifndef MOENCH03T1ZMQNEWRECT_H
|
||||
#define MOENCH03T1ZMQNEWRECT_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
#define VERT 1
|
||||
|
||||
|
||||
|
||||
class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
|
||||
class moench03T1ZmqDataNew : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
@ -12,9 +14,12 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
public:
|
||||
const int nSamples;
|
||||
const int offset;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
/**
|
||||
@ -23,9 +28,16 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
moench03Ctb10GbT1Data(int ns=5000): slsReceiverData<uint16_t>(400, 400, 40, 8208), nadc(32), sc_width(25), sc_height(200) {
|
||||
|
||||
#ifdef HOR
|
||||
moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(800, 200, ns*2*32), nSamples(ns), offset(sizeof(int)) {
|
||||
#endif
|
||||
#ifdef VERT
|
||||
moench03T1ZmqDataNew(int ns=5000): slsDetectorData<uint16_t>(200, 800, ns*2*32), nSamples(ns), offset(sizeof(int)) {
|
||||
#endif
|
||||
|
||||
int nadc=32;
|
||||
int sc_width=25;
|
||||
int sc_height=200;
|
||||
|
||||
int adc_nr[32]={300,325,350,375,300,325,350,375, \
|
||||
200,225,250,275,200,225,250,275,\
|
||||
@ -38,9 +50,17 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
int npackets=40;
|
||||
int npackets=40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
int pix;
|
||||
|
||||
|
||||
int off=0;
|
||||
#ifdef OFF_1
|
||||
off=1;
|
||||
#endif
|
||||
cout << "This is a MOENCH with rectangular pixels!" << endl;
|
||||
|
||||
for (int ip=0; ip<npackets; ip++) {
|
||||
for (int is=0; is<128; is++) {
|
||||
@ -56,46 +76,67 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
dataMap[row][col]=(nadc*i+iadc)*2+16*(ip+1);
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=8208*40)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
pix=(nadc*i+iadc)*2+offset;//+16*(ip+1);
|
||||
if (pix<0 || pix>=nSamples*2*32)
|
||||
cout << "Error: pointer " << pix << " out of range "<< endl;
|
||||
ix=col;
|
||||
iy=row;
|
||||
//col and row have to do with data sequence
|
||||
//ix and iy have to do with implant position
|
||||
#ifdef HOR
|
||||
if (row%2==off) {
|
||||
ix=2*col;
|
||||
iy=row/2;
|
||||
} else {
|
||||
ix=2*col+1;
|
||||
iy=row/2;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VERT
|
||||
if (col%2==off) {
|
||||
ix=col/2;
|
||||
iy=row*2+1;
|
||||
} else {
|
||||
ix=col/2;
|
||||
iy=row*2;
|
||||
}
|
||||
#endif
|
||||
dataMap[iy][ix]=pix;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ipacket;
|
||||
int ibyte;
|
||||
int ii=0;
|
||||
for (int ipacket=0; ipacket<npackets; ipacket++) {
|
||||
for (int ibyte=0; ibyte< 8208/2; ibyte++) {
|
||||
i=ipacket*8208/2+ibyte;
|
||||
if (ibyte<8) {
|
||||
//header!
|
||||
xmap[i]=-1;
|
||||
ymap[i]=-1;
|
||||
} else {
|
||||
// ii=ibyte+128*32*ipacket;
|
||||
isample=ii/nadc;
|
||||
iadc=ii%nadc;
|
||||
adc4 = (int)iadc/4;
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
if (adc4%2==0) {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2-1-iy;
|
||||
} else {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2+iy;
|
||||
}
|
||||
|
||||
ii++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* int ipacket; */
|
||||
/* int ibyte; */
|
||||
/* int ii=0; */
|
||||
/* for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){ */
|
||||
/* xmap[ibyte]=-1; */
|
||||
/* ymap[ibyte]=-1; */
|
||||
/* } */
|
||||
/* int off=sizeof(sls_detector_header)/2; */
|
||||
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
|
||||
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
|
||||
/* i=ipacket*8208/2+ibyte; */
|
||||
/* isample=ii/nadc; */
|
||||
/* if (isample<nSamples) { */
|
||||
/* iadc=ii%nadc; */
|
||||
/* adc4 = (int)iadc/4; */
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (adc4%2==0) { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2-1-iy; */
|
||||
/* } else { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2+iy; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* ii++; */
|
||||
/* // } */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
@ -121,8 +162,7 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
|
||||
|
||||
|
||||
|
||||
// int getFrameNumber(char *buff){return *((int*)buff)&0xffffffff;};
|
||||
int getFrameNumber(char *buff){return *((int*)(buff+5))&0xffffff;};
|
||||
int getFrameNumber(char *buff){return *((int*)buff);};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
@ -133,7 +173,7 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff){return ((*(((int*)(buff+4))))&0xff)+1;};
|
||||
int getPacketNumber(char *buff){return 0;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* /\** */
|
||||
|
||||
@ -188,79 +228,63 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[packetSize*nPackets];
|
||||
char *data=new char[32*2*nSamples];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
char *retval=0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
/* char *retval=0; */
|
||||
/* int nd; */
|
||||
/* int fnum = -1; */
|
||||
np=0;
|
||||
int pn, po=0;
|
||||
char aa[8224];
|
||||
char *packet=(char *)aa;
|
||||
// cout << packetSize*nPackets << endl;
|
||||
if (ff>=0)
|
||||
fnum=ff;
|
||||
/* int pn; */
|
||||
|
||||
|
||||
/* if (ff>=0) */
|
||||
/* fnum=ff; */
|
||||
|
||||
if (filebin.is_open()) {
|
||||
|
||||
|
||||
|
||||
|
||||
while(filebin.read((char*)packet, 8208) ){
|
||||
pn=getPacketNumber(packet);
|
||||
|
||||
if (fnum<0)
|
||||
fnum= getFrameNumber(packet);
|
||||
|
||||
// cout << "fn: " << fnum << "\t pn: " << pn << endl;
|
||||
if (fnum>=0) {
|
||||
if (getFrameNumber(packet) !=fnum || pn<po) {
|
||||
|
||||
if (np==0){
|
||||
// delete [] data;
|
||||
return NULL;
|
||||
} else
|
||||
filebin.seekg(-8208,ios_base::cur);
|
||||
po =pn;
|
||||
return data;
|
||||
}
|
||||
if (pn>nPackets) {
|
||||
cout << "Bad packet number " << pn << endl;
|
||||
}
|
||||
|
||||
memcpy(data+(pn-1)*packetSize, packet, packetSize);
|
||||
np++;
|
||||
po =pn;
|
||||
|
||||
if (np==nPackets)
|
||||
break;
|
||||
|
||||
if (pn==nPackets)
|
||||
break;
|
||||
|
||||
}
|
||||
if (filebin.read(data, 32*2*nSamples) ){
|
||||
// iframe++;
|
||||
//ff=iframe;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (np==0){
|
||||
// delete [] data;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ff=fnum;
|
||||
return data;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<32*2*nSamples) ndata=dsize;
|
||||
else ndata=32*2*nSamples;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// virtual int setFrameNumber(int ff){iframe=ff};
|
||||
|
||||
|
||||
|
||||
@ -271,13 +295,7 @@ class moench03Ctb10GbT1Data : public slsReceiverData<uint16_t> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int getPacketNumber(int x, int y) {return dataMap[y][x]/8208;};
|
||||
|
||||
int getPacketNumber(int x, int y) {return 0;};
|
||||
|
||||
};
|
||||
|
||||
@ -285,3 +303,4 @@ int getPacketNumber(int x, int y) {return dataMap[y][x]/8208;};
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,285 +0,0 @@
|
||||
#ifndef MOENCH03TCTB10GBDATA_H
|
||||
#define MOENCH03TCTB10GBDATA_H
|
||||
#include "moench03Ctb10GbData.h"
|
||||
|
||||
|
||||
|
||||
class moench03TCtb10GbData : public moench03Ctb10GbData { //slsReceiverData<uint16_t> {
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
|
||||
|
||||
// moench03TCtb10GbData(int ns=5000): slsDetectorData<uint16_t>(400, 400, 8208*40, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) {
|
||||
moench03TCtb10GbData(int ns=5000): moench03Ctb10GbData(ns) {//slsReceiverData<uint16_t>(400, 400, 40, 8208), nadc(32), sc_width(25), sc_height(200) {
|
||||
// cout <<"constructor"<< endl;
|
||||
// nadc=32;
|
||||
int adc_nr[32]={300,325,350,375,300,325,350,375, \
|
||||
200,225,250,275,200,225,250,275,\
|
||||
100,125,150,175,100,125,150,175,\
|
||||
0,25,50,75,0,25,50,75};
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
int npackets=40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
|
||||
for (int ip=0; ip<npackets; ip++) {
|
||||
for (int is=0; is<128; is++) {
|
||||
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
i=128*ip+is;
|
||||
//cout << i << endl;
|
||||
adc4=(int)iadc/4;
|
||||
if (i<sc_width*sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=adc_nr[iadc]+(i%sc_width);
|
||||
if (adc4%2==0) {
|
||||
// if (iadc<(nadc/2)) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
dataMap[row][col]=(nadc*i+iadc)*2+16*(ip+1);
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=8208*40)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// cout <<"map"<< endl;
|
||||
int ipacket;
|
||||
int ibyte;
|
||||
int ii=0;
|
||||
for (int ipacket=0; ipacket<npackets; ipacket++) {
|
||||
for (int ibyte=0; ibyte< 8208/2; ibyte++) {
|
||||
i=ipacket*8208/2+ibyte;
|
||||
// cout << i << " ";
|
||||
if (ibyte<8) {
|
||||
//header!
|
||||
xmap[i]=-1;
|
||||
ymap[i]=-1;
|
||||
} else {
|
||||
// ii=ibyte+128*32*ipacket;
|
||||
// cout << nadc << endl;
|
||||
isample=ii/nadc;
|
||||
iadc=ii%nadc;
|
||||
|
||||
adc4 = (int)iadc/4;
|
||||
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
// cout << isample << " " << iadc << " " << ix << " " << iy ;//<< endl;
|
||||
if (adc4%2==0) {//iadc<(nadc/2)) {
|
||||
//if (iadc<(nadc/2)) {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2-1-iy;
|
||||
} else {
|
||||
xmap[i]=adc_nr[iadc]+ix;
|
||||
ymap[i]=ny/2+iy;
|
||||
}
|
||||
|
||||
ii++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* int ipacket; */
|
||||
/* int ibyte; */
|
||||
/* int ii=0; */
|
||||
|
||||
/* for (int ipacket=0; ipacket<npackets; ipacket++) { */
|
||||
/* for (int ibyte=0; ibyte< 8208/2; ibyte++) { */
|
||||
/* i=ipacket*8208/2+ibyte; */
|
||||
/* cout << i << endl; */
|
||||
/* if (ibyte<8) { */
|
||||
/* //header! */
|
||||
/* xmap[i]=-1; */
|
||||
/* ymap[i]=-1; */
|
||||
/* } else { */
|
||||
/* ii=ibyte+128*32*ipacket; */
|
||||
/* isample=ii/nadc; */
|
||||
/* iadc=ii%nadc; */
|
||||
/* adc4 = (int)iadc/4; */
|
||||
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (adc4%2==0) { */
|
||||
/* xmap[i]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i]=ny/2-1-iy; */
|
||||
|
||||
|
||||
|
||||
/* } else { */
|
||||
/* xmap[i]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i]=ny/2+iy; */
|
||||
|
||||
/* } */
|
||||
|
||||
/* ii++; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
|
||||
|
||||
// cout <<"done"<< endl;
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Returns the frame number for the given dataset. Purely virtual func. */
|
||||
/* \param buff pointer to the dataset */
|
||||
/* \returns frame number */
|
||||
|
||||
/* *\/ */
|
||||
|
||||
|
||||
/* int getFrameNumber(char *buff){return *((int*)buff)&0xffffffff;}; */
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Returns the packet number for the given dataset. purely virtual func */
|
||||
/* \param buff pointer to the dataset */
|
||||
/* \returns packet number number */
|
||||
|
||||
|
||||
|
||||
/* *\/ */
|
||||
/* int getPacketNumber(char *buff){return ((*(((int*)(buff+4))))&0xff)+1;}; */
|
||||
|
||||
/* /\* /\\** *\/ */
|
||||
|
||||
/* /\* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func *\/ */
|
||||
/* /\* \param data pointer to the memory to be analyzed *\/ */
|
||||
/* /\* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot *\/ */
|
||||
/* /\* \param dsize size of the memory slot to be analyzed *\/ */
|
||||
/* /\* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found *\/ */
|
||||
|
||||
/* /\* *\\/ *\/ */
|
||||
/* /\* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; *\/ */
|
||||
|
||||
|
||||
/* /\* /\\** *\/ */
|
||||
|
||||
/* /\* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! *\/ */
|
||||
/* /\* \param filebin input file stream (binary) *\/ */
|
||||
/* /\* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete *\/ */
|
||||
|
||||
/* /\* *\\/ *\/ */
|
||||
/* /\* virtual char *readNextFrame(ifstream &filebin){ *\/ */
|
||||
/* /\* // int afifo_length=0; *\/ */
|
||||
/* /\* uint16_t *afifo_cont; *\/ */
|
||||
/* /\* int ib=0; *\/ */
|
||||
/* /\* if (filebin.is_open()) { *\/ */
|
||||
/* /\* afifo_cont=new uint16_t[dataSize/2]; *\/ */
|
||||
/* /\* while (filebin.read(((char*)afifo_cont)+ib,2)) { *\/ */
|
||||
/* /\* ib+=2; *\/ */
|
||||
/* /\* if (ib==dataSize) break; *\/ */
|
||||
/* /\* } *\/ */
|
||||
/* /\* if (ib>0) { *\/ */
|
||||
/* /\* iframe++; *\/ */
|
||||
/* /\* // cout << ib << "-" << endl; *\/ */
|
||||
/* /\* return (char*)afifo_cont; *\/ */
|
||||
/* /\* } else { *\/ */
|
||||
/* /\* delete [] afifo_cont; *\/ */
|
||||
/* /\* return NULL; *\/ */
|
||||
/* /\* } *\/ */
|
||||
/* /\* } *\/ */
|
||||
/* /\* return NULL; *\/ */
|
||||
/* /\* }; *\/ */
|
||||
|
||||
|
||||
/* virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) { */
|
||||
/* char *data=new char[packetSize*nPackets]; */
|
||||
/* char *retval=0; */
|
||||
/* int nd; */
|
||||
/* np=0; */
|
||||
/* int pn; */
|
||||
/* char aa[8224]={0}; */
|
||||
/* char *packet=(char *)aa; */
|
||||
/* int fnum = -1; */
|
||||
|
||||
/* if (ff>=0) */
|
||||
/* fnum=ff; */
|
||||
|
||||
/* if (filebin.is_open()) { */
|
||||
|
||||
|
||||
/* cout << "+"; */
|
||||
|
||||
/* while(filebin.read((char*)packet, 8208)){ */
|
||||
|
||||
/* pn=getPacketNumber(packet); */
|
||||
|
||||
/* if (fnum<0) */
|
||||
/* fnum= getFrameNumber(packet); */
|
||||
|
||||
/* if (fnum>=0) { */
|
||||
/* if (getFrameNumber(packet) !=fnum) { */
|
||||
|
||||
/* if (np==0){ */
|
||||
/* cout << "-"; */
|
||||
/* delete [] data; */
|
||||
/* return NULL; */
|
||||
/* } else */
|
||||
/* filebin.seekg(-8208,ios_base::cur); */
|
||||
|
||||
/* return data; */
|
||||
/* } */
|
||||
|
||||
/* memcpy(data+(pn-1)*packetSize, packet, packetSize); */
|
||||
/* np++; */
|
||||
/* if (np==nPackets) */
|
||||
/* break; */
|
||||
/* if (pn==nPackets) */
|
||||
/* break; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* } */
|
||||
|
||||
/* if (np==0){ */
|
||||
/* cout << "?"; */
|
||||
/* delete [] data; */
|
||||
/* return NULL; */
|
||||
/* }// else if (np<nPackets) */
|
||||
/* // cout << "Frame " << fnum << " lost " << nPackets-np << " packets " << endl; */
|
||||
|
||||
/* return data; */
|
||||
|
||||
/* }; */
|
||||
|
||||
/* int getPacketNumber(int x, int y) {return dataMap[y][x]/8208;}; */
|
||||
|
||||
/* virtual char *readNextFrame(ifstream &filebin) { */
|
||||
/* int fnum=-1, np; */
|
||||
/* return readNextFrame(filebin, fnum, np); */
|
||||
/* }; */
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,294 @@
|
||||
#ifndef MOENCH04REC10GBDATA_H
|
||||
#define MOENCH04REC10GBDATA_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
//#define VERSION_V2
|
||||
/**
|
||||
@short structure for a Detector Packet or Image Header
|
||||
@li frameNumber is the frame number
|
||||
@li expLength is the subframe number (32 bit eiger) or real time exposure time in 100ns (others)
|
||||
@li packetNumber is the packet number
|
||||
@li bunchId is the bunch id from beamline
|
||||
@li timestamp is the time stamp with 10 MHz clock
|
||||
@li modId is the unique module id (unique even for left, right, top, bottom)
|
||||
@li xCoord is the x coordinate in the complete detector system
|
||||
@li yCoord is the y coordinate in the complete detector system
|
||||
@li zCoord is the z coordinate in the complete detector system
|
||||
@li debug is for debugging purposes
|
||||
@li roundRNumber is the round robin set number
|
||||
@li detType is the detector type see :: detectorType
|
||||
@li version is the version number of this structure format
|
||||
*/
|
||||
typedef struct {
|
||||
uint64_t frameNumber; /**< is the frame number */
|
||||
uint32_t expLength; /**< is the subframe number (32 bit eiger) or real time exposure time in 100ns (others) */
|
||||
uint32_t packetNumber; /**< is the packet number */
|
||||
uint64_t bunchId; /**< is the bunch id from beamline */
|
||||
uint64_t timestamp; /**< is the time stamp with 10 MHz clock */
|
||||
uint16_t modId; /**< is the unique module id (unique even for left, right, top, bottom) */
|
||||
uint16_t xCoord; /**< is the x coordinate in the complete detector system */
|
||||
uint16_t yCoord; /**< is the y coordinate in the complete detector system */
|
||||
uint16_t zCoord; /**< is the z coordinate in the complete detector system */
|
||||
uint32_t debug; /**< is for debugging purposes */
|
||||
uint16_t roundRNumber; /**< is the round robin set number */
|
||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
uint8_t version; /**< is the version number of this structure format */
|
||||
uint64_t packetCaught[8]; /**< is the version number of this structure format */
|
||||
|
||||
} sls_detector_header;
|
||||
|
||||
|
||||
|
||||
|
||||
class moench04CtbReceiver10GbData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int aSamples;
|
||||
const int dSamples;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
moench04CtbReceiver10GbData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, nas*2*32+sizeof(sls_detector_header)+nds*8), aSamples(nas), dSamples(nds) {
|
||||
|
||||
int nadc=32;
|
||||
int sc_width=25;
|
||||
int sc_height=200;
|
||||
|
||||
int adc_nr[32]={9, 8,11,10,13,12,15,14,1,0,3,2,5,4,7,6,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24 };
|
||||
|
||||
int row, col;
|
||||
|
||||
int isample;
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
int npackets=40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
|
||||
for (int ip=0; ip<npackets; ip++) {
|
||||
for (int is=0; is<128; is++) {
|
||||
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
i=128*ip+is;
|
||||
adc4=(int)iadc/4;
|
||||
if (i<sc_width*sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=(adc_nr[iadc]%16)*sc_width+(i%sc_width);
|
||||
// if (adc4%2==0) {
|
||||
if (iadc/16>0) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
if (nds>0)
|
||||
dataMap[row][col]=sizeof(sls_detector_header)+((nadc+4)*i+iadc)*2;//+16*(ip+1);
|
||||
else
|
||||
dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ipacket;
|
||||
int ibyte;
|
||||
int ii=0;
|
||||
for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){
|
||||
xmap[ibyte]=-1;
|
||||
ymap[ibyte]=-1;
|
||||
}
|
||||
/* int off=sizeof(sls_detector_header)/2; */
|
||||
|
||||
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
|
||||
|
||||
|
||||
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
|
||||
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
|
||||
/* i=ipacket*8208/2+ibyte; */
|
||||
/* isample=ii/nadc; */
|
||||
/* if (isample<nSamples) { */
|
||||
/* iadc=ii%nadc; */
|
||||
/* adc4 = (int)iadc/4; */
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (adc4%2==0) { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2-1-iy; */
|
||||
/* } else { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2+iy; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* ii++; */
|
||||
/* // } */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
|
||||
|
||||
int getFrameNumber(char *buff){return ((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[dataSize];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
char *retval=0;
|
||||
int nd;
|
||||
int fnum = -1;
|
||||
np=0;
|
||||
int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff>=0)
|
||||
fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize) ){
|
||||
ff=getFrameNumber(data);
|
||||
np=getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<dataSize) ndata=dsize;
|
||||
else ndata=dataSize;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,7 +1,8 @@
|
||||
#ifndef MOENCH03T1ZMQDATA_H
|
||||
#define MOENCH03T1ZMQDATA_H
|
||||
#ifndef MOENCH04RECDATA_H
|
||||
#define MOENCH04RECDATA_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
//#define VERSION_V2
|
||||
/**
|
||||
@short structure for a Detector Packet or Image Header
|
||||
@li frameNumber is the frame number
|
||||
@ -32,12 +33,14 @@
|
||||
uint16_t roundRNumber; /**< is the round robin set number */
|
||||
uint8_t detType; /**< is the detector type see :: detectorType */
|
||||
uint8_t version; /**< is the version number of this structure format */
|
||||
uint64_t packetCaught[8]; /**< is the version number of this structure format */
|
||||
|
||||
} sls_detector_header;
|
||||
|
||||
|
||||
|
||||
|
||||
class moench03T1ReceiverData : public slsDetectorData<uint16_t> {
|
||||
class moench04CtbReceiverData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
@ -45,8 +48,8 @@ class moench03T1ReceiverData : public slsDetectorData<uint16_t> {
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int nPackets; /**<number of UDP packets constituting one frame */
|
||||
const int packetSize; /**< size of a udp packet */
|
||||
const int aSamples;
|
||||
const int dSamples;
|
||||
|
||||
|
||||
public:
|
||||
@ -60,16 +63,13 @@ class moench03T1ReceiverData : public slsDetectorData<uint16_t> {
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
moench03T1ReceiverData(int npackets=40, int ps=8192): slsDetectorData<uint16_t>(400, 400, ps*npackets+sizeof(sls_detector_header)), packetSize(ps), nPackets(npackets) {
|
||||
moench04CtbReceiverData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, nas*2*32+sizeof(sls_detector_header)+nds*8), aSamples(nas), dSamples(nds) {
|
||||
|
||||
int nadc=32;
|
||||
int sc_width=25;
|
||||
int sc_height=200;
|
||||
|
||||
int adc_nr[32]={300,325,350,375,300,325,350,375, \
|
||||
200,225,250,275,200,225,250,275,\
|
||||
100,125,150,175,100,125,150,175,\
|
||||
0,25,50,75,0,25,50,75};
|
||||
int adc_nr[32]={9, 8,11,10,13,12,15,14,1,0,3,2,5,4,7,6,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24 };
|
||||
|
||||
int row, col;
|
||||
|
||||
@ -77,7 +77,7 @@ class moench03T1ReceiverData : public slsDetectorData<uint16_t> {
|
||||
int iadc;
|
||||
int ix, iy;
|
||||
|
||||
// int npackets=40;
|
||||
int npackets=40;
|
||||
int i;
|
||||
int adc4(0);
|
||||
|
||||
@ -89,14 +89,15 @@ class moench03T1ReceiverData : public slsDetectorData<uint16_t> {
|
||||
adc4=(int)iadc/4;
|
||||
if (i<sc_width*sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=adc_nr[iadc]+(i%sc_width);
|
||||
if (adc4%2==0) {
|
||||
col=(adc_nr[iadc]%16)*sc_width+(i%sc_width);
|
||||
// if (adc4%2==0) {
|
||||
if (iadc/16>0) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1);
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=8192*40)
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
}
|
||||
@ -110,27 +111,32 @@ class moench03T1ReceiverData : public slsDetectorData<uint16_t> {
|
||||
xmap[ibyte]=-1;
|
||||
ymap[ibyte]=-1;
|
||||
}
|
||||
int off=sizeof(sls_detector_header)/2;
|
||||
for (ipacket=0; ipacket<npackets; ipacket++) {
|
||||
for (ibyte=0; ibyte< 8192/2; ibyte++) {
|
||||
i=ipacket*8208/2+ibyte;
|
||||
isample=ii/nadc;
|
||||
iadc=ii%nadc;
|
||||
adc4 = (int)iadc/4;
|
||||
ix=isample%sc_width;
|
||||
iy=isample/sc_width;
|
||||
if (adc4%2==0) {
|
||||
xmap[i+off]=adc_nr[iadc]+ix;
|
||||
ymap[i+off]=ny/2-1-iy;
|
||||
} else {
|
||||
xmap[i+off]=adc_nr[iadc]+ix;
|
||||
ymap[i+off]=ny/2+iy;
|
||||
}
|
||||
|
||||
ii++;
|
||||
// }
|
||||
}
|
||||
}
|
||||
/* int off=sizeof(sls_detector_header)/2; */
|
||||
|
||||
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
|
||||
|
||||
|
||||
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
|
||||
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
|
||||
/* i=ipacket*8208/2+ibyte; */
|
||||
/* isample=ii/nadc; */
|
||||
/* if (isample<nSamples) { */
|
||||
/* iadc=ii%nadc; */
|
||||
/* adc4 = (int)iadc/4; */
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (adc4%2==0) { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2-1-iy; */
|
||||
/* } else { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2+iy; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* ii++; */
|
||||
/* // } */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
@ -167,7 +173,7 @@ class moench03T1ReceiverData : public slsDetectorData<uint16_t> {
|
||||
|
||||
|
||||
*/
|
||||
int getPacketNumber(char *buff){((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* /\** */
|
||||
|
||||
@ -275,7 +281,7 @@ class moench03T1ReceiverData : public slsDetectorData<uint16_t> {
|
||||
|
||||
|
||||
|
||||
int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
|
||||
};
|
||||
|
290
slsDetectorCalibration/dataStructures/moench04CtbZmq10GbData.h
Normal file
290
slsDetectorCalibration/dataStructures/moench04CtbZmq10GbData.h
Normal file
@ -0,0 +1,290 @@
|
||||
#ifndef MOENCH04ZMQ10GBDATA_H
|
||||
#define MOENCH04ZMQ10GBDATA_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int aSamples;
|
||||
const int dSamples;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
//moench04CtbZmq10GbData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, nas*2*32+nds*8), aSamples(nas), dSamples(nds), nadc(32), sc_width(25), sc_height(200) {
|
||||
moench04CtbZmq10GbData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, (nas > 0) && (nds>0) ? max(nas,nds)*(32*2+8) : nas*32*2+nds*8), nadc(32), sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) {
|
||||
|
||||
/* int ds; */
|
||||
/* if (nas && nds) */
|
||||
/* if (nds>nas) */
|
||||
/* ds=nds*(32*2+8); */
|
||||
/* else */
|
||||
/* ds=nas*(32*2+8); */
|
||||
/* else */
|
||||
/* ds=nas*32*2+nds*8; */
|
||||
|
||||
/* new slsDetectorData<uint16_t>(400, 400, ds); */
|
||||
|
||||
int adc_nr[32]={9, 8,11,10,13,12,15,14,1,0,3,2,5,4,7,6,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24 };
|
||||
|
||||
int row, col;
|
||||
|
||||
//int isample;
|
||||
int iadc;
|
||||
// int ix, iy;
|
||||
|
||||
// int npackets=40;
|
||||
int i;
|
||||
//int adc4(0);
|
||||
|
||||
for (int is=0; is<aSamples; is++) {
|
||||
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
i=is;
|
||||
// adc4=(int)iadc/4;
|
||||
if (i<sc_width*sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=(adc_nr[iadc]%16)*sc_width+(i%sc_width);
|
||||
// if (adc4%2==0) {
|
||||
if (iadc<16) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
if (nds>0)
|
||||
dataMap[row][col]=((nadc+4)*i+iadc)*2;//+16*(ip+1);
|
||||
else
|
||||
dataMap[row][col]=(nadc*i+iadc)*2;//+16*(ip+1);
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){ */
|
||||
/* xmap[ibyte]=-1; */
|
||||
/* ymap[ibyte]=-1; */
|
||||
/* } */
|
||||
/* int off=sizeof(sls_detector_header)/2; */
|
||||
|
||||
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
|
||||
|
||||
|
||||
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
|
||||
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
|
||||
/* i=ipacket*8208/2+ibyte; */
|
||||
/* isample=ii/nadc; */
|
||||
/* if (isample<nSamples) { */
|
||||
/* iadc=ii%nadc; */
|
||||
/* adc4 = (int)iadc/4; */
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (adc4%2==0) { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2-1-iy; */
|
||||
/* } else { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2+iy; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* ii++; */
|
||||
/* // } */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
}
|
||||
|
||||
int getGain(char *data, int x, int y) {
|
||||
// int aoff=aSamples*2*32;
|
||||
int irow;
|
||||
int isc=x/sc_width;
|
||||
int icol=x%sc_width;
|
||||
if (y<200) irow=sc_height-1-y;
|
||||
else {
|
||||
irow=y-sc_height;
|
||||
isc++;
|
||||
}
|
||||
int ibit[32]={-1,-1,-1,-1,-1,-1,1,3,5,7,-1,-1,-1,-1,-1,-1,62,60,58,56,54,52,50,48,63,61,59,57,55,53,51,49};
|
||||
int isample=irow*sc_width+icol;
|
||||
|
||||
uint64_t sample;
|
||||
char *ptr;
|
||||
if (isc<0 || isc>=32) return 0;
|
||||
if (ibit[isc]<0 || ibit[isc]>=64) return 0;
|
||||
if (dSamples>isample) {
|
||||
ptr=data+32*(isample+1)+8*isample;
|
||||
sample=*((uint64_t*)ptr);
|
||||
cout << isc << " " << ibit[isc] << " " << isample << hex << sample << dec << endl;
|
||||
if (sample & (1<<ibit[isc]))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
|
||||
|
||||
int getFrameNumber(char *buff){return iframe;};//((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
|
||||
*/
|
||||
//int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[dataSize];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
// char *retval=0;
|
||||
// int nd;
|
||||
// int fnum = -1;
|
||||
np=0;
|
||||
//int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff>=0)
|
||||
// fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize) ){
|
||||
ff=getFrameNumber(data);
|
||||
// np=getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<dataSize) ndata=dsize;
|
||||
else ndata=dataSize;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
276
slsDetectorCalibration/dataStructures/moench04CtbZmqData.h
Normal file
276
slsDetectorCalibration/dataStructures/moench04CtbZmqData.h
Normal file
@ -0,0 +1,276 @@
|
||||
#ifndef MOENCH04ZMQDATA_H
|
||||
#define MOENCH04ZMQDATA_H
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class moench04CtbZmqData : public slsDetectorData<uint16_t> {
|
||||
|
||||
private:
|
||||
|
||||
int iframe;
|
||||
int nadc;
|
||||
int sc_width;
|
||||
int sc_height;
|
||||
const int aSamples;
|
||||
const int dSamples;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Implements the slsReceiverData structure for the moench02 prototype read out by a module i.e. using the slsReceiver
|
||||
(160x160 pixels, 40 packets 1286 large etc.)
|
||||
\param c crosstalk parameter for the output buffer
|
||||
|
||||
*/
|
||||
moench04CtbZmqData(int nas=5000, int nds=0): slsDetectorData<uint16_t>(400, 400, nas*2*32+nds*8), nadc(32), sc_width(25), sc_height(200), aSamples(nas), dSamples(nds) {
|
||||
|
||||
|
||||
int adc_nr[32]={9, 8,11,10,13,12,15,14,1,0,3,2,5,4,7,6,23,22,21,20,19,18,17,16,31,30,29,28,27,26,25,24 };
|
||||
|
||||
int row, col;
|
||||
|
||||
//int isample;
|
||||
int iadc;
|
||||
//int ix, iy;
|
||||
|
||||
// int npackets=40;
|
||||
int i;
|
||||
//int adc4(0);
|
||||
|
||||
for (int is=0; is<aSamples; is++) {
|
||||
|
||||
for (iadc=0; iadc<nadc; iadc++) {
|
||||
i=is;
|
||||
// adc4=(int)iadc/4;
|
||||
if (i<sc_width*sc_height) {
|
||||
// for (int i=0; i<sc_width*sc_height; i++) {
|
||||
col=(adc_nr[iadc]%16)*sc_width+(i%sc_width);
|
||||
// if (adc4%2==0) {
|
||||
if (iadc<16) {
|
||||
row=199-i/sc_width;
|
||||
} else {
|
||||
row=200+i/sc_width;
|
||||
}
|
||||
dataMap[row][col]=(nadc*i+iadc)*2;//+16*(ip+1);
|
||||
if (dataMap[row][col]<0 || dataMap[row][col]>=aSamples*2*32)
|
||||
cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* for (ibyte=0; ibyte<sizeof(sls_detector_header)/2; ibyte++){ */
|
||||
/* xmap[ibyte]=-1; */
|
||||
/* ymap[ibyte]=-1; */
|
||||
/* } */
|
||||
/* int off=sizeof(sls_detector_header)/2; */
|
||||
|
||||
/* for (ibyte=0; ibyte<dataSize; ibyte++) { */
|
||||
|
||||
|
||||
/* for (ipacket=0; ipacket<npackets; ipacket++) { */
|
||||
/* for (ibyte=0; ibyte< 8192/2; ibyte++) { */
|
||||
/* i=ipacket*8208/2+ibyte; */
|
||||
/* isample=ii/nadc; */
|
||||
/* if (isample<nSamples) { */
|
||||
/* iadc=ii%nadc; */
|
||||
/* adc4 = (int)iadc/4; */
|
||||
/* ix=isample%sc_width; */
|
||||
/* iy=isample/sc_width; */
|
||||
/* if (adc4%2==0) { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2-1-iy; */
|
||||
/* } else { */
|
||||
/* xmap[i+off]=adc_nr[iadc]+ix; */
|
||||
/* ymap[i+off]=ny/2+iy; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* ii++; */
|
||||
/* // } */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
iframe=0;
|
||||
// cout << "data struct created" << endl;
|
||||
}
|
||||
|
||||
int getGain(char *data, int x, int y) {
|
||||
int aoff=aSamples*2*32;
|
||||
int irow;
|
||||
int isc=x/sc_width;
|
||||
int icol=x%sc_width;
|
||||
if (y<200) irow=sc_height-1-y;
|
||||
else {
|
||||
irow=y-sc_height;
|
||||
isc++;
|
||||
}
|
||||
int ibit[32]={-1,-1,-1,-1,-1,-1,1,3,5,7,-1,-1,-1,-1,-1,-1,62,60,58,56,54,52,50,48,63,61,59,57,55,53,51,49};
|
||||
int isample=irow*sc_width+icol;
|
||||
|
||||
uint64_t sample;
|
||||
char *ptr;
|
||||
if (isc<0 || isc>=32) return 0;
|
||||
if (ibit[isc]<0 || ibit[isc]>=64) return 0;
|
||||
if (dSamples>isample) {
|
||||
ptr=data+aoff+8*isample;
|
||||
sample=*((uint64_t*)ptr);
|
||||
cout << isc << " " << ibit[isc] << " " << isample << hex << sample << dec << endl;
|
||||
if (sample & (1<<ibit[isc]))
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Returns the frame number for the given dataset. Purely virtual func.
|
||||
\param buff pointer to the dataset
|
||||
\returns frame number
|
||||
|
||||
*/
|
||||
|
||||
/* class jfrau_packet_header_t { */
|
||||
/* public: */
|
||||
/* unsigned char reserved[4]; */
|
||||
/* unsigned char packetNumber[1]; */
|
||||
/* unsigned char frameNumber[3]; */
|
||||
/* unsigned char bunchid[8]; */
|
||||
/* }; */
|
||||
|
||||
|
||||
|
||||
int getFrameNumber(char *buff){return iframe;};//((sls_detector_header*)buff)->frameNumber;};//*((int*)(buff+5))&0xffffff;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the packet number for the given dataset. purely virtual func
|
||||
\param buff pointer to the dataset
|
||||
\returns packet number number
|
||||
|
||||
|
||||
|
||||
*/
|
||||
//int getPacketNumber(char *buff){return ((sls_detector_header*)buff)->packetNumber;}//((*(((int*)(buff+4))))&0xff)+1;};
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func */
|
||||
/* \param data pointer to the memory to be analyzed */
|
||||
/* \param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot */
|
||||
/* \param dsize size of the memory slot to be analyzed */
|
||||
/* \returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *findNextFrame(char *data, int &ndata, int dsize){ndata=dsize; setDataSize(dsize); return data;}; */
|
||||
|
||||
|
||||
/* /\** */
|
||||
|
||||
/* Loops over a file stream until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). Can be overloaded for different kind of detectors! */
|
||||
/* \param filebin input file stream (binary) */
|
||||
/* \returns pointer to the begin of the last good frame, NULL if no frame is found or last frame is incomplete */
|
||||
|
||||
/* *\/ */
|
||||
/* virtual char *readNextFrame(ifstream &filebin){ */
|
||||
/* // int afifo_length=0; */
|
||||
/* uint16_t *afifo_cont; */
|
||||
/* int ib=0; */
|
||||
/* if (filebin.is_open()) { */
|
||||
/* afifo_cont=new uint16_t[dataSize/2]; */
|
||||
/* while (filebin.read(((char*)afifo_cont)+ib,2)) { */
|
||||
/* ib+=2; */
|
||||
/* if (ib==dataSize) break; */
|
||||
/* } */
|
||||
/* if (ib>0) { */
|
||||
/* iframe++; */
|
||||
/* // cout << ib << "-" << endl; */
|
||||
/* return (char*)afifo_cont; */
|
||||
/* } else { */
|
||||
/* delete [] afifo_cont; */
|
||||
/* return NULL; */
|
||||
/* } */
|
||||
/* } */
|
||||
/* return NULL; */
|
||||
/* }; */
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin) {
|
||||
int ff=-1, np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int &ff) {
|
||||
int np=-1;
|
||||
return readNextFrame(filebin, ff, np);
|
||||
};
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np) {
|
||||
char *data=new char[dataSize];
|
||||
char *d=readNextFrame(filebin, ff, np, data);
|
||||
if (d==NULL) {delete [] data; data=NULL;}
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual char *readNextFrame(ifstream &filebin, int& ff, int &np, char *data) {
|
||||
// char *retval=0;
|
||||
//int nd;
|
||||
//int fnum = -1;
|
||||
np=0;
|
||||
//int pn;
|
||||
|
||||
// cout << dataSize << endl;
|
||||
if (ff>=0)
|
||||
// fnum=ff;
|
||||
|
||||
if (filebin.is_open()) {
|
||||
if (filebin.read(data, dataSize) ){
|
||||
ff=getFrameNumber(data);
|
||||
// np=getPacketNumber(data);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Loops over a memory slot until a complete frame is found (i.e. all packets 0 to nPackets, same frame number). purely virtual func
|
||||
\param data pointer to the memory to be analyzed
|
||||
\param ndata reference to the amount of data found for the frame, in case the frame is incomplete at the end of the memory slot
|
||||
\param dsize size of the memory slot to be analyzed
|
||||
\returns pointer to the beginning of the last good frame (might be incomplete if ndata smaller than dataSize), or NULL if no frame is found
|
||||
|
||||
*/
|
||||
virtual char *findNextFrame(char *data, int &ndata, int dsize){
|
||||
if (dsize<dataSize) ndata=dsize;
|
||||
else ndata=dataSize;
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -261,6 +261,8 @@ class slsDetectorData {
|
||||
return d^m;
|
||||
};
|
||||
|
||||
virtual int getGain(char *data, int ix, int iy=0){return 0;};
|
||||
|
||||
/**
|
||||
|
||||
Returns the value of the selected channel for the given dataset. Virtual function, can be overloaded.
|
@ -1,534 +0,0 @@
|
||||
#include "energyCalibration.h"
|
||||
|
||||
#ifdef __CINT
|
||||
#define MYROOT
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MYROOT
|
||||
#include <TMath.h>
|
||||
#include <TH1F.h>
|
||||
#include <TH2F.h>
|
||||
#include <TGraphErrors.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#define max(a,b) ((a) > (b) ? (a) : (b))
|
||||
#define min(a,b) ((a) < (b) ? (a) : (b))
|
||||
#define ELEM_SWAP(a,b) { register int t=(a);(a)=(b);(b)=t; }
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifdef MYROOT
|
||||
|
||||
Double_t energyCalibrationFunctions::pedestal(Double_t *x, Double_t *par) {
|
||||
return par[0]-par[1]*sign*x[0];
|
||||
}
|
||||
|
||||
|
||||
Double_t energyCalibrationFunctions::gaussChargeSharing(Double_t *x, Double_t *par) {
|
||||
Double_t f, arg=0;
|
||||
if (par[3]!=0) arg=sign*(x[0]-par[2])/par[3];
|
||||
f=TMath::Exp(-1*arg*arg/2.);
|
||||
f=f+par[5]/2.*(TMath::Erfc(arg/(TMath::Sqrt(2.))));
|
||||
return par[4]*f+pedestal(x,par);
|
||||
}
|
||||
|
||||
Double_t energyCalibrationFunctions::gaussChargeSharingPixel(Double_t *x, Double_t *par) {
|
||||
Double_t f;
|
||||
if (par[3]<=0 || par[2]*(*x)<=0 || par[5]<0 || par[4]<=0) return 0;
|
||||
|
||||
Double_t pp[3];
|
||||
|
||||
pp[0]=0;
|
||||
pp[1]=par[2];
|
||||
pp[2]=par[3];
|
||||
|
||||
|
||||
f=(par[5]-par[6]*(TMath::Log(*x/par[2])))*erfBox(x,pp);
|
||||
f+=par[4]*TMath::Gaus(*x, par[2], par[3], kTRUE);
|
||||
return f+pedestal(x,par);
|
||||
}
|
||||
|
||||
Double_t energyCalibrationFunctions::erfBox(Double_t *z, Double_t *par) {
|
||||
|
||||
|
||||
|
||||
Double_t m=par[0];
|
||||
Double_t M=par[1];
|
||||
|
||||
if (par[0]>par[1]) {
|
||||
m=par[1];
|
||||
M=par[0];
|
||||
}
|
||||
|
||||
if (m==M)
|
||||
return 0;
|
||||
|
||||
|
||||
if (par[2]<=0) {
|
||||
if (*z>=m && *z<=M)
|
||||
return 1./(M-m);
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
return (TMath::Erfc((z[0]-M)/par[2])-TMath::Erfc((z[0]-m)/par[2]))*0.5/(M-m);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// basic erf function
|
||||
Double_t energyCalibrationFunctions::erfFunction(Double_t *x, Double_t *par) {
|
||||
double arg=0;
|
||||
if (par[1]!=0) arg=(par[0]-x[0])/par[1];
|
||||
return ((par[2]/2.*(1+TMath::Erf(sign*arg/(TMath::Sqrt(2))))));
|
||||
};
|
||||
|
||||
|
||||
Double_t energyCalibrationFunctions::erfFunctionChargeSharing(Double_t *x, Double_t *par) {
|
||||
Double_t f;
|
||||
|
||||
f=erfFunction(x, par+2)*(1+par[5]*(par[2]-x[0]))+par[0]-par[1]*x[0]*sign;
|
||||
return f;
|
||||
};
|
||||
|
||||
|
||||
Double_t energyCalibrationFunctions::erfFuncFluo(Double_t *x, Double_t *par) {
|
||||
Double_t f;
|
||||
f=erfFunctionChargeSharing(x, par)+erfFunction(x, par+6)*(1+par[9]*(par[6]-x[0]));
|
||||
return f;
|
||||
};
|
||||
#endif
|
||||
|
||||
double energyCalibrationFunctions::median(double *x, int n){
|
||||
// sorts x into xmed array and returns median
|
||||
// n is number of values already in the xmed array
|
||||
double xmed[n];
|
||||
int k,i,j;
|
||||
|
||||
for (i=0; i<n; i++) {
|
||||
k=0;
|
||||
for (j=0; j<n; j++) {
|
||||
if(*(x+i)>*(x+j))
|
||||
k++;
|
||||
if (*(x+i)==*(x+j)) {
|
||||
if (i>j)
|
||||
k++;
|
||||
}
|
||||
}
|
||||
xmed[k]=*(x+i);
|
||||
}
|
||||
k=n/2;
|
||||
return xmed[k];
|
||||
}
|
||||
|
||||
|
||||
int energyCalibrationFunctions::quick_select(int arr[], int n){
|
||||
int low, high ;
|
||||
int median;
|
||||
int middle, ll, hh;
|
||||
|
||||
low = 0 ; high = n-1 ; median = (low + high) / 2;
|
||||
for (;;) {
|
||||
if (high <= low) /* One element only */
|
||||
return arr[median] ;
|
||||
|
||||
if (high == low + 1) { /* Two elements only */
|
||||
if (arr[low] > arr[high])
|
||||
ELEM_SWAP(arr[low], arr[high]) ;
|
||||
return arr[median] ;
|
||||
}
|
||||
|
||||
/* Find median of low, middle and high items; swap into position low */
|
||||
middle = (low + high) / 2;
|
||||
if (arr[middle] > arr[high]) ELEM_SWAP(arr[middle], arr[high]) ;
|
||||
if (arr[low] > arr[high]) ELEM_SWAP(arr[low], arr[high]) ;
|
||||
if (arr[middle] > arr[low]) ELEM_SWAP(arr[middle], arr[low]) ;
|
||||
|
||||
/* Swap low item (now in position middle) into position (low+1) */
|
||||
ELEM_SWAP(arr[middle], arr[low+1]) ;
|
||||
|
||||
/* Nibble from each end towards middle, swapping items when stuck */
|
||||
ll = low + 1;
|
||||
hh = high;
|
||||
for (;;) {
|
||||
do ll++; while (arr[low] > arr[ll]) ;
|
||||
do hh--; while (arr[hh] > arr[low]) ;
|
||||
|
||||
if (hh < ll)
|
||||
break;
|
||||
|
||||
ELEM_SWAP(arr[ll], arr[hh]) ;
|
||||
}
|
||||
|
||||
/* Swap middle item (in position low) back into correct position */
|
||||
ELEM_SWAP(arr[low], arr[hh]) ;
|
||||
|
||||
/* Re-set active partition */
|
||||
if (hh <= median)
|
||||
low = ll;
|
||||
if (hh >= median)
|
||||
high = hh - 1;
|
||||
}
|
||||
}
|
||||
|
||||
int energyCalibrationFunctions::kth_smallest(int *a, int n, int k){
|
||||
register int i,j,l,m ;
|
||||
register double x ;
|
||||
|
||||
l=0 ; m=n-1 ;
|
||||
while (l<m) {
|
||||
x=a[k] ;
|
||||
i=l ;
|
||||
j=m ;
|
||||
do {
|
||||
while (a[i]<x) i++ ;
|
||||
while (x<a[j]) j-- ;
|
||||
if (i<=j) {
|
||||
ELEM_SWAP(a[i],a[j]) ;
|
||||
i++ ; j-- ;
|
||||
}
|
||||
} while (i<=j) ;
|
||||
if (j<k) l=i ;
|
||||
if (k<i) m=j ;
|
||||
}
|
||||
return a[k] ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef MYROOT
|
||||
Double_t energyCalibrationFunctions::spectrum(Double_t *x, Double_t *par) {
|
||||
return gaussChargeSharing(x,par);
|
||||
}
|
||||
|
||||
Double_t energyCalibrationFunctions::spectrumPixel(Double_t *x, Double_t *par) {
|
||||
return gaussChargeSharingPixel(x,par);
|
||||
}
|
||||
|
||||
|
||||
Double_t energyCalibrationFunctions::scurve(Double_t *x, Double_t *par) {
|
||||
return erfFunctionChargeSharing(x,par);
|
||||
}
|
||||
|
||||
|
||||
Double_t energyCalibrationFunctions::scurveFluo(Double_t *x, Double_t *par) {
|
||||
return erfFuncFluo(x,par);
|
||||
}
|
||||
#endif
|
||||
|
||||
energyCalibration::energyCalibration() :
|
||||
#ifdef MYROOT
|
||||
fit_min(-1),
|
||||
fit_max(-1),
|
||||
bg_offset(-1),
|
||||
bg_slope(-1),
|
||||
flex(-1),
|
||||
noise(-1),
|
||||
ampl(-1),
|
||||
cs_slope(-1),
|
||||
fscurve(NULL),
|
||||
fspectrum(NULL),
|
||||
#endif
|
||||
funcs(NULL),
|
||||
plot_flag(1), // fit parameters output to screen
|
||||
cs_flag(1)
|
||||
{
|
||||
|
||||
#ifdef MYROOT
|
||||
funcs=new energyCalibrationFunctions();
|
||||
|
||||
fscurve=new TF1("fscurve",funcs,&energyCalibrationFunctions::scurve,0,1000,6,"energyCalibrationFunctions","scurve");
|
||||
fscurve->SetParNames("Background Offset","Background Slope","Inflection Point","Noise RMS", "Number of Photons","Charge Sharing Slope");
|
||||
|
||||
fspectrum=new TF1("fspectrum",funcs,&energyCalibrationFunctions::spectrum,0,1000,6,"energyCalibrationFunctions","spectrum");
|
||||
fspectrum->SetParNames("Background Pedestal","Background slope", "Peak position","Noise RMS", "Number of Photons","Charge Sharing Pedestal");
|
||||
|
||||
fspixel=new TF1("fspixel",funcs,&energyCalibrationFunctions::spectrumPixel,0,1000,7,"energyCalibrationFunctions","spectrumPixel");
|
||||
fspixel->SetParNames("Background Pedestal","Background slope", "Peak position","Noise RMS", "Number of Photons","Charge Sharing Pedestal","Corner");
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void energyCalibration::fixParameter(int ip, Double_t val){
|
||||
|
||||
fscurve->FixParameter(ip, val);
|
||||
fspectrum->FixParameter(ip, val);
|
||||
}
|
||||
|
||||
|
||||
void energyCalibration::releaseParameter(int ip){
|
||||
|
||||
fscurve->ReleaseParameter(ip);
|
||||
fspectrum->ReleaseParameter(ip);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
energyCalibration::~energyCalibration(){
|
||||
#ifdef MYROOT
|
||||
delete fscurve;
|
||||
delete fspectrum;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
#ifdef MYROOT
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TH1F* energyCalibration::createMedianHistogram(TH2F* h2, int ch0, int nch, int direction) {
|
||||
|
||||
if (h2==NULL || nch==0)
|
||||
return NULL;
|
||||
|
||||
double *x=new double[nch];
|
||||
TH1F *h1=NULL;
|
||||
|
||||
double val=-1;
|
||||
|
||||
if (direction==0) {
|
||||
h1=new TH1F("median","Median",h2->GetYaxis()->GetNbins(),h2->GetYaxis()->GetXmin(),h2->GetYaxis()->GetXmax());
|
||||
for (int ib=0; ib<h1->GetXaxis()->GetNbins(); ib++) {
|
||||
for (int ich=0; ich<nch; ich++) {
|
||||
x[ich]=h2->GetBinContent(ch0+ich+1,ib+1);
|
||||
}
|
||||
val=energyCalibrationFunctions::median(x, nch);
|
||||
h1->SetBinContent(ib+1,val);
|
||||
}
|
||||
} else if (direction==1) {
|
||||
h1=new TH1F("median","Median",h2->GetXaxis()->GetNbins(),h2->GetXaxis()->GetXmin(),h2->GetXaxis()->GetXmax());
|
||||
for (int ib=0; ib<h1->GetYaxis()->GetNbins(); ib++) {
|
||||
for (int ich=0; ich<nch; ich++) {
|
||||
x[ich]=h2->GetBinContent(ib+1,ch0+ich+1);
|
||||
}
|
||||
val=energyCalibrationFunctions::median(x, nch);
|
||||
h1->SetBinContent(ib+1,val);
|
||||
}
|
||||
}
|
||||
delete [] x;
|
||||
|
||||
return h1;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void energyCalibration::setStartParameters(Double_t *par){
|
||||
bg_offset=par[0];
|
||||
bg_slope=par[1];
|
||||
flex=par[2];
|
||||
noise=par[3];
|
||||
ampl=par[4];
|
||||
cs_slope=par[5];
|
||||
}
|
||||
|
||||
|
||||
void energyCalibration::getStartParameters(Double_t *par){
|
||||
par[0]=bg_offset;
|
||||
par[1]=bg_slope;
|
||||
par[2]=flex;
|
||||
par[3]=noise;
|
||||
par[4]=ampl;
|
||||
par[5]=cs_slope;
|
||||
}
|
||||
|
||||
#endif
|
||||
int energyCalibration::setChargeSharing(int p) {
|
||||
if (p>=0) {
|
||||
cs_flag=p;
|
||||
#ifdef MYROOT
|
||||
if (p) {
|
||||
fscurve->ReleaseParameter(5);
|
||||
fspectrum->ReleaseParameter(1);
|
||||
} else {
|
||||
fscurve->FixParameter(5,0);
|
||||
fspectrum->FixParameter(1,0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return cs_flag;
|
||||
}
|
||||
|
||||
|
||||
#ifdef MYROOT
|
||||
void energyCalibration::initFitFunction(TF1 *fun, TH1 *h1) {
|
||||
|
||||
Double_t min=fit_min, max=fit_max;
|
||||
|
||||
Double_t mypar[6];
|
||||
|
||||
if (max==-1)
|
||||
max=h1->GetXaxis()->GetXmax();
|
||||
|
||||
if (min==-1)
|
||||
min=h1->GetXaxis()->GetXmin();
|
||||
|
||||
|
||||
if (bg_offset==-1)
|
||||
mypar[0]=0;
|
||||
else
|
||||
mypar[0]=bg_offset;
|
||||
|
||||
|
||||
if (bg_slope==-1)
|
||||
mypar[1]=0;
|
||||
else
|
||||
mypar[1]=bg_slope;
|
||||
|
||||
|
||||
if (flex==-1)
|
||||
mypar[2]=(min+max)/2.;
|
||||
else
|
||||
mypar[2]=flex;
|
||||
|
||||
|
||||
if (noise==-1)
|
||||
mypar[3]=0.1;
|
||||
else
|
||||
mypar[3]=noise;
|
||||
|
||||
if (ampl==-1)
|
||||
mypar[4]=h1->GetBinContent(h1->GetXaxis()->FindBin(0.5*(max+min)));
|
||||
else
|
||||
mypar[4]=ampl;
|
||||
|
||||
if (cs_slope==-1)
|
||||
mypar[5]=0;
|
||||
else
|
||||
mypar[5]=cs_slope;
|
||||
|
||||
fun->SetParameters(mypar);
|
||||
|
||||
fun->SetRange(min,max);
|
||||
|
||||
}
|
||||
|
||||
|
||||
TF1* energyCalibration::fitFunction(TF1 *fun, TH1 *h1, Double_t *mypar, Double_t *emypar) {
|
||||
|
||||
|
||||
TF1* fitfun;
|
||||
|
||||
char fname[100];
|
||||
|
||||
strcpy(fname, fun->GetName());
|
||||
|
||||
if (plot_flag) {
|
||||
h1->Fit(fname,"R0Q");
|
||||
} else
|
||||
h1->Fit(fname,"R0Q");
|
||||
|
||||
|
||||
fitfun= h1->GetFunction(fname);
|
||||
fitfun->GetParameters(mypar);
|
||||
for (int ip=0; ip<6; ip++) {
|
||||
emypar[ip]=fitfun->GetParError(ip);
|
||||
}
|
||||
return fitfun;
|
||||
}
|
||||
|
||||
TF1* energyCalibration::fitSCurve(TH1 *h1, Double_t *mypar, Double_t *emypar) {
|
||||
initFitFunction(fscurve,h1);
|
||||
return fitFunction(fscurve, h1, mypar, emypar);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
TF1* energyCalibration::fitSpectrum(TH1 *h1, Double_t *mypar, Double_t *emypar) {
|
||||
initFitFunction(fspectrum,h1);
|
||||
return fitFunction(fspectrum, h1, mypar, emypar);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TF1* energyCalibration::fitSpectrumPixel(TH1 *h1, Double_t *mypar, Double_t *emypar) {
|
||||
initFitFunction(fspixel,h1);
|
||||
return fitFunction(fspixel, h1, mypar, emypar);
|
||||
}
|
||||
|
||||
|
||||
|
||||
TGraphErrors* energyCalibration::linearCalibration(int nscan, Double_t *en, Double_t *een, Double_t *fl, Double_t *efl, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff) {
|
||||
|
||||
TGraphErrors *gr;
|
||||
|
||||
Double_t mypar[2];
|
||||
|
||||
gr = new TGraphErrors(nscan,en,fl,een,efl);
|
||||
|
||||
if (plot_flag) {
|
||||
gr->Fit("pol1");
|
||||
gr->SetMarkerStyle(20);
|
||||
} else
|
||||
gr->Fit("pol1","0Q");
|
||||
|
||||
TF1 *fitfun= gr->GetFunction("pol1");
|
||||
fitfun->GetParameters(mypar);
|
||||
|
||||
egain=fitfun->GetParError(1);
|
||||
eoff=fitfun->GetParError(0);
|
||||
|
||||
gain=funcs->setScanSign()*mypar[1];
|
||||
|
||||
off=mypar[0];
|
||||
|
||||
return gr;
|
||||
}
|
||||
|
||||
|
||||
TGraphErrors* energyCalibration::calibrate(int nscan, Double_t *en, Double_t *een, TH1F **h1, Double_t &gain, Double_t &off, Double_t &egain, Double_t &eoff, int integral) {
|
||||
|
||||
TH1F *h;
|
||||
|
||||
Double_t mypar[6], emypar[6];
|
||||
Double_t fl[nscan], efl[nscan];
|
||||
|
||||
|
||||
for (int ien=0; ien<nscan; ien++) {
|
||||
h=h1[ien];
|
||||
if (integral)
|
||||
fitSCurve(h,mypar,emypar);
|
||||
else
|
||||
fitSpectrum(h,mypar,emypar);
|
||||
|
||||
fl[ien]=mypar[2];
|
||||
efl[ien]=emypar[2];
|
||||
}
|
||||
return linearCalibration(nscan,en,een,fl,efl,gain,off, egain, eoff);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
62
slsDetectorCalibration/ghostSummation.h
Normal file
62
slsDetectorCalibration/ghostSummation.h
Normal file
@ -0,0 +1,62 @@
|
||||
#ifndef GHOSTSUMMATION_H
|
||||
#define GHOSTSUMMATION_H
|
||||
|
||||
#include <cmath>
|
||||
#include "slsDetectorData.h"
|
||||
|
||||
template <class dataType> class ghostSummation {
|
||||
|
||||
/** @short virtual calss to handle ghosting*/
|
||||
|
||||
public:
|
||||
|
||||
/** constructor
|
||||
\param xt crosstalk
|
||||
*/
|
||||
ghostSummation(slsDetectorData<dataType> *d, double xt) : xtalk(xt),det(d) {
|
||||
if (det)
|
||||
det->getDetectorSize(nx,ny);
|
||||
ghost=new double[nx*ny];
|
||||
};
|
||||
|
||||
ghostSummation(ghostSummation *orig) {
|
||||
xtalk=orig->xtalk;
|
||||
det=orig->det;
|
||||
ghost=new double[nx*ny];
|
||||
|
||||
}
|
||||
~ghostSummation() {delete [] ghost;};
|
||||
|
||||
virtual ghostSummation *Clone() {
|
||||
return new ghostSummation(this);
|
||||
}
|
||||
|
||||
double getXTalk(){return xtalk;};
|
||||
void setXTalk(double g) {xtalk=g;};
|
||||
|
||||
virtual double calcGhost(char *data, int ix, int iy=1){ghost[iy*nx+ix]=0; return 0;};
|
||||
|
||||
virtual void calcGhost(char *data){
|
||||
for (int iy=0; iy<ny; iy++)
|
||||
for (int ix=0; ix<nx; ix++)
|
||||
ghost[iy*nx+ix]=calcGhost(data, ix, iy);
|
||||
}
|
||||
|
||||
virtual double getGhost(int ix, int iy) {
|
||||
if (ix<0 || ix>=nx || iy<0 || iy>=ny) return 0;
|
||||
return ghost[iy*nx+ix];
|
||||
}
|
||||
|
||||
protected:
|
||||
double xtalk;
|
||||
slsDetectorData<dataType> *det;
|
||||
double *ghost;
|
||||
int nx, ny;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,30 +0,0 @@
|
||||
#ifndef GOTTHARDDOUBLECOMMONMODESUBTRACTION_H
|
||||
#define GOTTHARDDOUBLECOMMONMODESUBTRACTION_H
|
||||
|
||||
|
||||
#include "commonModeSubtractionNew.h"
|
||||
|
||||
class gotthardDoubleModuleCommonModeSubtraction : public commonModeSubtraction {
|
||||
|
||||
/** @short class to calculate the common mode of the pedestals based on an approximated moving average*/
|
||||
|
||||
public:
|
||||
|
||||
/** constructor
|
||||
\param nn number of samples for the moving average to calculate the average common mode
|
||||
\param iroi number of regions on which one can calculate the common mode separately. Defaults to 1 i.e. whole detector
|
||||
|
||||
*/
|
||||
gotthardDoubleModuleCommonModeSubtraction(int ns=3) : commonModeSubtraction(2, ns) {};
|
||||
|
||||
/**
|
||||
gets the common mode ROI for pixel ix, iy
|
||||
*/
|
||||
virtual int getROI(int ix, int iy){return ix%2;};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,22 +0,0 @@
|
||||
|
||||
CBFLIBDIR=/afs/psi.ch/project/sls_det_software/CBFlib-0.9.5
|
||||
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o ../tiffIO.cpp
|
||||
ZMQLIB=../../slsReceiverSoftware/include
|
||||
INCDIR=-I.. -I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -I../interpolations -I../dataStructures
|
||||
LIBHDF5=-L$(CBFLIBDIR)/lib/ -lhdf5
|
||||
LDFLAG= -L/usr/lib64/ -lpthread
|
||||
#-L../../bin
|
||||
MAIN=gotthard25umZmqAnalysis.C
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: gotthard25umOnTheFlyAnalysis gotthard25umZmq
|
||||
|
||||
gotthard25umOnTheFlyAnalysis: $(MAIN) $(INCS) clean
|
||||
g++ -o gotthard25umOnTheAnalysis $(MAIN) -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
|
||||
|
||||
gotthard25umZmq: $(MAIN) $(INCS) clean
|
||||
g++ -o gotthard25umZmq $(MAIN) -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DZMQ -L$(ZMQLIB) -lzmq
|
||||
|
||||
clean:
|
||||
rm -f gotthard25umOnTheFlyAnalysis
|
@ -0,0 +1,40 @@
|
||||
detsizechan 2560 1
|
||||
|
||||
hostname bchip074+bchip075+
|
||||
#hostname bchip092+bchip093+
|
||||
|
||||
settingsdir settingsdir/gotthard
|
||||
angdir 1.000000
|
||||
caldir settingsdir/gotthard
|
||||
|
||||
0:extsig:0 trigger_in_rising_edge
|
||||
0:rx_tcpport 1954
|
||||
0:rx_udpport 50001
|
||||
0:vhighvoltage 0
|
||||
|
||||
#0:rx_zmqip pc8829
|
||||
#0:rx_zmqport 30003
|
||||
#0:zmqip pc8829
|
||||
#0:zmqport 40003
|
||||
|
||||
1:extsig:0 trigger_in_rising_edge
|
||||
1:rx_tcpport 1955
|
||||
1:rx_udpport 50002
|
||||
#1:detectorip 10.1.1.52
|
||||
1:vhighvoltage 0
|
||||
|
||||
#1:rx_zmqip pc8829
|
||||
#1:rx_zmqport 30004
|
||||
#1:zmqip pc8829
|
||||
#1:zmqport 40004
|
||||
|
||||
|
||||
r_readfreq 1
|
||||
rx_datastream 1
|
||||
|
||||
#rx_udpip 10.1.1.100
|
||||
rx_hostname pc8498
|
||||
rx_datastream 1
|
||||
outdir /tmp/
|
||||
angconv none
|
||||
threaded 1
|
@ -1,517 +0,0 @@
|
||||
#include "sls_receiver_defs.h"
|
||||
//#ifdef ZMQ
|
||||
#include "ZmqSocket.h"
|
||||
//#endif
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include <stdio.h>
|
||||
//#include <deque>
|
||||
//#include <list>
|
||||
//#include <queue>
|
||||
#include <fstream>
|
||||
#include <cstring>
|
||||
|
||||
//#define BCHIP074_BCHIP075
|
||||
|
||||
#include "gotthardModuleDataNew.h"
|
||||
#include "gotthardDoubleModuleDataNew.h"
|
||||
#include "gotthardDoubleModuleCommonModeSubtractionNew.h"
|
||||
|
||||
#include "singlePhotonDetector.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
//#include "linearInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#define NC 1280
|
||||
#define NR 1
|
||||
|
||||
//#include "tiffIO.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define SLS_DETECTOR_JSON_HEADER_VERSION 0x2
|
||||
int main(int argc, char *argv[]){
|
||||
//void *gotthardProcessFrame() {
|
||||
|
||||
|
||||
|
||||
int fifosize=1000;
|
||||
int nthreads=1;
|
||||
int nph, nph1;
|
||||
int etabins=550;
|
||||
double etamin=-1, etamax=2;
|
||||
int nsubpix=1;
|
||||
float *etah=new float[etabins*etabins];
|
||||
int *heta, *himage;
|
||||
int offset=48;
|
||||
#ifdef ZMQ
|
||||
offset=0;
|
||||
#endif
|
||||
#ifndef ZMQ
|
||||
offset=48;
|
||||
#endif
|
||||
|
||||
//commonModeSubtraction *cm=NULL;
|
||||
|
||||
gotthardDoubleModuleCommonModeSubtraction *cm=new gotthardDoubleModuleCommonModeSubtraction();
|
||||
gotthardModuleDataNew *decoder=new gotthardModuleDataNew();
|
||||
gotthardDoubleModuleDataNew *det=new gotthardDoubleModuleDataNew(offset);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, cm, 1000, 100);
|
||||
// analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det, 1, cm, 1000);
|
||||
// analogDetector<uint16_t> *filter_nocm=new analogDetector<uint16_t>(det, 1, NULL, 1000);
|
||||
filter->setROI(0,2560,0,1);
|
||||
char *buff;//[2*(48+1280*2)];
|
||||
char *buff0;
|
||||
char *buff1;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
mt->setFrameMode(eFrame);
|
||||
// mt->setFrameMode(eFrame);
|
||||
// mt->setFrameMode(ePedestal);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
buff0=buff;
|
||||
buff1=buff+offset*2+1280*2;
|
||||
int photons[1280*2];
|
||||
int nf=0;
|
||||
int ok=0;
|
||||
std::time_t end_time;
|
||||
//int16_t dout[1280*2];
|
||||
int iFrame=-1;
|
||||
int np=-1;
|
||||
nph=0;
|
||||
nph1=0;
|
||||
//int np;
|
||||
int iph;
|
||||
int data_ready=1;
|
||||
int *image;
|
||||
|
||||
|
||||
|
||||
int length;
|
||||
int nnx, nny,nns;
|
||||
int nix, niy,nis;
|
||||
// infinite loop
|
||||
int ix, iy, isx, isy;
|
||||
|
||||
filter->getImageSize(nnx, nny,nns);
|
||||
int16_t *dout=new int16_t [nnx*nny];
|
||||
|
||||
|
||||
|
||||
#ifdef ZMQ
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: %s [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number]\n",argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip=argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
int size = nnx*nny*2;
|
||||
|
||||
// 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;
|
||||
|
||||
|
||||
|
||||
// receive socket
|
||||
ZmqSocket* zmqsocket0 = new ZmqSocket(socketip,portnum);
|
||||
if (zmqsocket0->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket0;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
ZmqSocket* zmqsocket1 = new ZmqSocket(socketip,portnum+1);
|
||||
if (zmqsocket1->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum+1, socketip);
|
||||
delete zmqsocket1;
|
||||
delete zmqsocket0;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
zmqsocket0->Connect();
|
||||
printf("Zmq Client 0 at %s\n", zmqsocket0->GetZmqServerAddress());
|
||||
zmqsocket1->Connect();
|
||||
printf("Zmq Client 1 at %s\n", zmqsocket1->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
ZmqSocket* zmqsocket3 = 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 zmqsocket1;
|
||||
delete zmqsocket0;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
zmqsocket3 = new ZmqSocket(portnum2+1, socketip2);
|
||||
if (zmqsocket3->IsError()) {
|
||||
bprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2+1, socketip2);
|
||||
delete zmqsocket3;
|
||||
delete zmqsocket2;
|
||||
delete zmqsocket1;
|
||||
delete zmqsocket0;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
zmqsocket2->Connect();
|
||||
printf("Zmq Server 0 started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
zmqsocket3->Connect();
|
||||
printf("Zmq Server 1 started at %s\n", zmqsocket3->GetZmqServerAddress());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
uint64_t acqIndex1 = -1;
|
||||
uint64_t frameIndex1 = -1;
|
||||
uint32_t subframeIndex1 = -1;
|
||||
uint64_t fileindex1 = -1;
|
||||
string filename1 = "";
|
||||
|
||||
uint64_t acqIndex0 = -1;
|
||||
uint64_t frameIndex0 = -1;
|
||||
uint32_t subframeIndex0 = -1;
|
||||
uint64_t fileindex0 = -1;
|
||||
string filename0 = "";
|
||||
|
||||
|
||||
int eoa0=0;
|
||||
int eoa1=0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
char ofname[10000];
|
||||
char fn0[10000], fn1[10000];
|
||||
FILE *fout=NULL;
|
||||
FILE *fclust=NULL;
|
||||
for (int i=0; i<nnx; i++)
|
||||
dout[i]=0;
|
||||
char fname0[10000], fname1[10000];
|
||||
int irun;
|
||||
|
||||
#ifndef ZMQ
|
||||
|
||||
char ff[10000];
|
||||
if (argc < 6 ) {
|
||||
cprintf(RED, "Help: %s [indir] [fformat] [runmin] [runmax] [out file format]\n",argv[0]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
char *indir=argv[1];
|
||||
char *fformat=argv[2];
|
||||
int runmin=atoi(argv[3]);
|
||||
int runmax=atoi(argv[4]);
|
||||
char *outdir=argv[5];
|
||||
sprintf(ff,"%s/%s",indir,fformat);
|
||||
// strcpy(fformat,"/external_pool/gotthard_data/datadir_gotthardI/bchip074075/20170731/Xray/xray_15kV_200uA_5us_d%d_f000000000000_0.raw");
|
||||
// sprintf(fname0,fformat,0,0);
|
||||
// sprintf(fname1,fformat,1,1);
|
||||
|
||||
ifstream filebin0,filebin1;
|
||||
for (irun=runmin; irun<runmax; irun++) {
|
||||
|
||||
sprintf(fname0,ff,0,irun);
|
||||
sprintf(fname1,ff,1,irun);
|
||||
sprintf(ofname,outdir,irun);
|
||||
|
||||
filebin0.open((const char *)(fname0), ios::in | ios::binary);
|
||||
filebin1.open((const char *)(fname1), ios::in | ios::binary);
|
||||
if (filebin0.is_open() && filebin1.is_open()) {
|
||||
cout << "Opened file " << fname0<< endl;
|
||||
cout << "Opened file " << fname1<< endl;
|
||||
nf=0;
|
||||
iFrame=-1;
|
||||
while ((decoder->readNextFrame(filebin0, iFrame, np, buff0)) && (decoder->readNextFrame(filebin1, iFrame, np, buff1))) {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef ZMQ
|
||||
|
||||
int end_of_acquisition;
|
||||
while(1) {
|
||||
end_of_acquisition=0;
|
||||
eoa0=0;
|
||||
eoa1=0;
|
||||
|
||||
// cout << "Receive header " << nf << endl;
|
||||
if (!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) {
|
||||
|
||||
// cout << "************************************************************************** packet0!*****************************"<< endl;
|
||||
eoa0=1;
|
||||
end_of_acquisition++;
|
||||
}
|
||||
if (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1)) {
|
||||
//cout << "************************************************************************** packet1!*****************************"<< endl;
|
||||
eoa1=1;
|
||||
end_of_acquisition++;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// if ((!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) && (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1))){
|
||||
if (end_of_acquisition==0) {
|
||||
|
||||
if (acqIndex0!=acqIndex1)
|
||||
cout << "different acquisition indexes " << acqIndex0 << " and " << acqIndex1 << endl;
|
||||
if (frameIndex0!=frameIndex1)
|
||||
cout << "different frame indexes " << frameIndex0 << " and " << frameIndex1 << endl;
|
||||
|
||||
|
||||
while (frameIndex0<frameIndex1) {
|
||||
cout << "aligning det 0 " << endl;
|
||||
length = zmqsocket0->ReceiveData(0, buff0, size/2);
|
||||
if (!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) {
|
||||
end_of_acquisition++;
|
||||
eoa0=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (frameIndex1<frameIndex0) {
|
||||
cout << "aligning det 1 " << endl;
|
||||
length = zmqsocket1->ReceiveData(0, buff1, size/2);
|
||||
if (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1)) {
|
||||
end_of_acquisition++;
|
||||
eoa1=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (eoa0!=eoa1) {
|
||||
|
||||
while (eoa0<1) {
|
||||
length = zmqsocket0->ReceiveData(0, buff0, size/2);
|
||||
if (!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) {
|
||||
end_of_acquisition++;
|
||||
eoa0=1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
while (eoa1<1) {
|
||||
length = zmqsocket1->ReceiveData(0, buff1, size/2);
|
||||
if (!zmqsocket1->ReceiveHeader(0, acqIndex1, frameIndex1, subframeIndex1, filename1, fileindex1)) {
|
||||
end_of_acquisition++;
|
||||
eoa1=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (end_of_acquisition) {
|
||||
// cout << "************************************************************************** END OF FRAME" << end_of_acquisition << " !*****************************"<< endl;
|
||||
// return 0;
|
||||
|
||||
sprintf(ofname,"%s_%d.ph",fn0,irun);
|
||||
while (mt->isBusy()) {;}
|
||||
image=filter->getImage();
|
||||
if (image) {
|
||||
fout=fopen(ofname,"w");
|
||||
cout << nf << "*****************" << endl;
|
||||
for (int i=0; i<2560; i++) {
|
||||
fprintf(fout,"%d %d\n",i,image[i]);
|
||||
dout[i]=image[i];
|
||||
if (dout[i]<0)
|
||||
dout[i]=0;
|
||||
}
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
|
||||
if (send) {
|
||||
|
||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fn0, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
zmqsocket3->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fn1, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
|
||||
zmqsocket2->SendData((char*)dout,size/2);
|
||||
zmqsocket3->SendData(((char*)dout)+size/2,size/2);
|
||||
// // cprintf(GREEN, "Sent Data\n");
|
||||
|
||||
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
zmqsocket3->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
}
|
||||
|
||||
|
||||
//mt->setFrameMode(eFrame);
|
||||
filter->clearImage();
|
||||
// std::time(&end_time);
|
||||
// cout << std::ctime(&end_time) << " " << nf << endl;
|
||||
fclose(fclust);
|
||||
fclust=NULL;
|
||||
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fclust==NULL) {
|
||||
|
||||
strcpy(fn0,filename0.c_str());
|
||||
strcpy(fn1,filename1.c_str());
|
||||
sprintf(ofname,"%s_%d.clust",fn0,irun);
|
||||
fclust=fopen(ofname,"w");
|
||||
while (mt->isBusy()) {;}
|
||||
mt->setFilePointer(fclust);
|
||||
}
|
||||
|
||||
// strcpy(fn0,filename0.c_str());
|
||||
// strcpy(fn1,filename1.c_str());
|
||||
|
||||
// cout << "Receive data " << nf << endl;
|
||||
length = zmqsocket0->ReceiveData(0, buff0, size/2);
|
||||
length += zmqsocket1->ReceiveData(0, buff1, size/2);
|
||||
|
||||
irun=fileindex0;
|
||||
|
||||
|
||||
|
||||
// // if (nf>100)
|
||||
// // mt->setFrameMode(eFrame);
|
||||
// //filter->clearImage();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
// cout << "==" << nf << endl;
|
||||
|
||||
// while (mt->isBusy()) {;}
|
||||
// image=filter->getImage();
|
||||
// if (image) {
|
||||
// for (int i=0; i<2560; i++) {
|
||||
// // if (i<512)
|
||||
|
||||
// // fprintf(fout,"%d %d\n",i,image[i]);
|
||||
// dout[i]=filter->subtractPedestal(buff,i,0,1);//image[i];//filter->getPedestal(i,0);//
|
||||
// if (dout[i]<0)
|
||||
// dout[i]=0;
|
||||
// // cout << i << " " << image[i] << " " << dout[i] << endl;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// if (send) {
|
||||
// strcpy(fname0,filename0.c_str());
|
||||
// strcpy(fname1,filename1.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,fname0, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
// zmqsocket3->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname1, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
|
||||
// zmqsocket2->SendData((char*)dout,size/2);
|
||||
// zmqsocket3->SendData(((char*)dout)+size/2,size/2);
|
||||
// // cprintf(GREEN, "Sent Data\n");
|
||||
|
||||
|
||||
// // zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
// // zmqsocket3->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
|
||||
// // cprintf(RED, "Received %d frames\n", nf);
|
||||
|
||||
// }
|
||||
|
||||
|
||||
mt->popFree(buff);
|
||||
buff0=buff;
|
||||
buff1=buff+offset*2+1280*2;
|
||||
|
||||
|
||||
|
||||
nf++;
|
||||
|
||||
|
||||
|
||||
|
||||
#ifndef ZMQ
|
||||
|
||||
|
||||
|
||||
|
||||
while (mt->isBusy()) {;}
|
||||
image=filter->getImage();
|
||||
if (image) {
|
||||
fout=fopen(ofname,"w");
|
||||
//cout << nf << "*****************" << endl;
|
||||
for (int i=0; i<512; i++) {
|
||||
fprintf(fout,"%d %d\n",i,image[i]);
|
||||
}
|
||||
fclose(fout);
|
||||
}
|
||||
filter->clearImage();
|
||||
|
||||
|
||||
|
||||
iFrame=-1;
|
||||
}
|
||||
|
||||
filebin0.close();
|
||||
filebin1.close();
|
||||
}
|
||||
else
|
||||
cout << "Could not open file " << fname0<< " or " << fname1 << endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
return NULL;
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
slsReceiver --rx_tcpport 1954 &
|
||||
slsReceiver --rx_tcpport 1955 &
|
||||
|
||||
./gotthard25umZmq pc8829 30003 129.129.202.98 40003 &
|
||||
slsDetectorGui -f examples/bchip2modules_pc8829.config &
|
||||
|
||||
|
||||
sls_detector_put settings veryhighgain
|
||||
sls_detector_put exptime 0.000005
|
||||
sls_detector_put period 0.01
|
||||
|
||||
|
||||
sls_detector_put vhighvoltage 90
|
||||
|
@ -46,8 +46,8 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
int sign=1,
|
||||
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) {
|
||||
int nd=100, int nnx=-1, int nny=-1, double *gm=NULL, ghostSummation<uint16_t> *gs=NULL) :
|
||||
singlePhotonDetector(d, 3,nsigma,sign, cm, nped, nd, nnx, nny, gm, gs) , interp(inte), id(0) {
|
||||
//cout << "**"<< xmin << " " << xmax << " " << ymin << " " << ymax << endl;
|
||||
fi=new pthread_mutex_t ;
|
||||
|
||||
@ -139,8 +139,8 @@ class interpolatingDetector : public singlePhotonDetector {
|
||||
nph=addFrame(data,val,0);
|
||||
if (interp)
|
||||
return interp->getInterpolatedImage();
|
||||
else
|
||||
singlePhotonDetector::getImage();
|
||||
//else
|
||||
return singlePhotonDetector::getImage();
|
||||
//return NULL;
|
||||
};
|
||||
|
||||
@ -233,7 +233,7 @@ int addFrame(char *data, int *ph=NULL, int ff=0) {
|
||||
};
|
||||
|
||||
virtual slsInterpolation *setInterpolation(slsInterpolation *ii){
|
||||
int ok;
|
||||
// int ok;
|
||||
interp=ii;
|
||||
/* pthread_mutex_lock(fi);
|
||||
if (interp)
|
||||
|
Binary file not shown.
@ -1,403 +0,0 @@
|
||||
#ifndef ETA2_INTERPOLATION_BASE_H
|
||||
#define ETA2_INTERPOLATION_BASE_H
|
||||
|
||||
#ifdef MYROOT1
|
||||
#include <TObject.h>
|
||||
#include <TTree.h>
|
||||
#include <TH2D.h>
|
||||
#include <TH2F.h>
|
||||
#endif
|
||||
|
||||
#include "etaInterpolationBase.h"
|
||||
|
||||
class eta2InterpolationBase : public virtual etaInterpolationBase {
|
||||
|
||||
public:
|
||||
eta2InterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nb, emin, emax) {
|
||||
|
||||
/* if (etamin>=etamax) { */
|
||||
/* etamin=-1; */
|
||||
/* etamax=2; */
|
||||
/* // cout << ":" <<endl; */
|
||||
/* } */
|
||||
/* etastep=(etamax-etamin)/nbeta; */
|
||||
|
||||
};
|
||||
|
||||
eta2InterpolationBase(eta2InterpolationBase *orig): etaInterpolationBase(orig){ };
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////// /*It return position hit for the event in input */ //////////////
|
||||
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 *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 cc[2][2];
|
||||
int xoff, yoff;
|
||||
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]=cl[xoff+3*yoff];
|
||||
cc[1][0]=cl[xoff+3*(yoff+1)];
|
||||
cc[0][1]=cl[xoff+1+3*yoff];
|
||||
cc[1][1]=cl[xoff+1+3*(yoff+1)];
|
||||
calcEta(totquad,cc,etax,etay);
|
||||
}
|
||||
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y) {
|
||||
|
||||
double cc[2][2];
|
||||
int xoff, yoff;
|
||||
|
||||
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]=cl[xoff+3*yoff];
|
||||
cc[1][0]=cl[xoff+3*(yoff+1)];
|
||||
cc[0][1]=cl[xoff+1+3*yoff];
|
||||
cc[1][1]=cl[xoff+1+3*(xoff+1)];
|
||||
calcEta(totquad,cc,etax,etay);
|
||||
}
|
||||
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double etax, double etay, int corner, double &int_x, double &int_y)
|
||||
{
|
||||
|
||||
|
||||
double xpos_eta=0,ypos_eta=0;
|
||||
double dX,dY;
|
||||
int ex,ey;
|
||||
switch (corner)
|
||||
{
|
||||
case TOP_LEFT:
|
||||
dX=-1.;
|
||||
dY=0;
|
||||
break;
|
||||
case TOP_RIGHT:
|
||||
;
|
||||
dX=0;
|
||||
dY=0;
|
||||
break;
|
||||
case BOTTOM_LEFT:
|
||||
dX=-1.;
|
||||
dY=-1.;
|
||||
break;
|
||||
case BOTTOM_RIGHT:
|
||||
dX=0;
|
||||
dY=-1.;
|
||||
break;
|
||||
default:
|
||||
cout << "bad quadrant" << endl;
|
||||
dX=0.;
|
||||
dY=0.;
|
||||
}
|
||||
|
||||
|
||||
if (nSubPixels>2) {
|
||||
|
||||
ex=(etax-etamin)/etastep;
|
||||
ey=(etay-etamin)/etastep;
|
||||
if (ex<0) {
|
||||
cout << "x*"<< ex << endl;
|
||||
ex=0;
|
||||
}
|
||||
if (ex>=nbeta) {
|
||||
cout << "x?"<< ex << endl;
|
||||
ex=nbeta-1;
|
||||
}
|
||||
if (ey<0) {
|
||||
cout << "y*"<< ey << endl;
|
||||
ey=0;
|
||||
}
|
||||
if (ey>=nbeta) {
|
||||
cout << "y?"<< ey << endl;
|
||||
ey=nbeta-1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
xpos_eta=(((double)hhx[(ey*nbeta+ex)]))+dX ;///((double)nSubPixels);
|
||||
ypos_eta=(((double)hhy[(ey*nbeta+ex)]))+dY ;///((double)nSubPixels);
|
||||
|
||||
} else {
|
||||
xpos_eta=0.5*dX+0.25;
|
||||
ypos_eta=0.5*dY+0.25;
|
||||
}
|
||||
|
||||
int_x=((double)x) + xpos_eta+0.5;
|
||||
int_y=((double)y) + ypos_eta+0.5;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay) {
|
||||
double cc[2][2];
|
||||
int xoff, yoff;
|
||||
|
||||
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:
|
||||
;
|
||||
}
|
||||
cc[0][0]=cl[xoff+3*yoff];
|
||||
cc[1][0]=cl[xoff+3*(yoff+1)];
|
||||
cc[0][1]=cl[xoff+1+3*yoff];
|
||||
cc[1][1]=cl[xoff+1+3*(yoff+1)];
|
||||
|
||||
//calcMyEta(totquad,quad,cl,etax, etay);
|
||||
calcEta(totquad, cc,etax, etay);
|
||||
|
||||
// cout <<"******"<< etax << " " << etay << endl;
|
||||
|
||||
|
||||
return addToFlatField(etax,etay);
|
||||
}
|
||||
|
||||
virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay) {
|
||||
double cc[2][2];
|
||||
int xoff, yoff;
|
||||
|
||||
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:
|
||||
;
|
||||
}
|
||||
cc[0][0]=cl[xoff+3*yoff];
|
||||
cc[1][0]=cl[(yoff+1)*3+xoff];
|
||||
cc[0][1]=cl[yoff*3+xoff+1];
|
||||
cc[1][1]=cl[(yoff+1)*3+xoff+1];
|
||||
|
||||
/* cout << cl[0] << " " << cl[1] << " " << cl[2] << endl; */
|
||||
/* cout << cl[3] << " " << cl[4] << " " << cl[5] << endl; */
|
||||
/* cout << cl[6] << " " << cl[7] << " " << cl[8] << endl; */
|
||||
/* cout <<"******"<<totquad << " " << quad << endl; */
|
||||
/* cout << cc[0][0]<< " " << cc[0][1] << endl; */
|
||||
/* cout << cc[1][0]<< " " << cc[1][1] << endl; */
|
||||
//calcMyEta(totquad,quad,cl,etax, etay);
|
||||
calcEta(totquad, cc,etax, etay);
|
||||
|
||||
// cout <<"******"<< etax << " " << etay << endl;
|
||||
|
||||
|
||||
return addToFlatField(etax,etay);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual int addToFlatField(double *cluster, double &etax, double &etay){
|
||||
double sDum[2][2];
|
||||
double tot, totquad;
|
||||
int corner;
|
||||
corner=calcQuad(cluster, tot, totquad, sDum);
|
||||
|
||||
double xpos_eta,ypos_eta;
|
||||
double dX,dY;
|
||||
|
||||
|
||||
calcEta(totquad, sDum, etax, etay);
|
||||
|
||||
return addToFlatField(etax,etay);
|
||||
|
||||
};
|
||||
|
||||
virtual int addToFlatField(int *cluster, double &etax, double &etay){
|
||||
double sDum[2][2];
|
||||
double tot, totquad;
|
||||
int corner;
|
||||
corner=calcQuad(cluster, tot, totquad, sDum);
|
||||
|
||||
double xpos_eta,ypos_eta;
|
||||
double dX,dY;
|
||||
|
||||
|
||||
calcEta(totquad, sDum, etax, etay);
|
||||
|
||||
return addToFlatField(etax,etay);
|
||||
|
||||
};
|
||||
|
||||
|
||||
virtual int addToFlatField(double etax, double etay){
|
||||
#ifdef MYROOT1
|
||||
heta->Fill(etax,etay);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
int ex,ey;
|
||||
ex=(etax-etamin)/etastep;
|
||||
ey=(etay-etamin)/etastep;
|
||||
if (ey<nbeta && ex<nbeta && ex>=0 && ey>=0)
|
||||
heta[ey*nbeta+ex]++;
|
||||
#endif
|
||||
return 0;
|
||||
};
|
||||
|
||||
virtual int *getInterpolatedImage(){
|
||||
int ipx, ipy;
|
||||
// cout << "ff" << endl;
|
||||
calcDiff(1, hhx, hhy); //get flat
|
||||
double avg=0;
|
||||
for (ipx=0; ipx<nSubPixels; ipx++)
|
||||
for (ipy=0; ipy<nSubPixels; ipy++)
|
||||
avg+=flat[ipx+ipy*nSubPixels];
|
||||
avg/=nSubPixels*nSubPixels;
|
||||
|
||||
for (int ibx=0 ; ibx<nSubPixels*nPixelsX; ibx++) {
|
||||
ipx=ibx%nSubPixels-nSubPixels/2;
|
||||
if (ipx<0) ipx=nSubPixels+ipx;
|
||||
for (int iby=0 ; iby<nSubPixels*nPixelsY; iby++) {
|
||||
ipy=iby%nSubPixels-nSubPixels/2;
|
||||
if (ipy<0) ipy=nSubPixels+ipy;
|
||||
// cout << ipx << " " << ipy << " " << ibx << " " << iby << endl;
|
||||
if (flat[ipx+ipy*nSubPixels]>0)
|
||||
hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX]*(avg/flat[ipx+ipy*nSubPixels]);
|
||||
else
|
||||
hintcorr[ibx+iby*nSubPixels*nPixelsX]=hint[ibx+iby*nSubPixels*nPixelsX];
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return hintcorr;
|
||||
};
|
||||
|
||||
/* protected: */
|
||||
|
||||
/* #ifdef MYROOT1 */
|
||||
/* TH2D *heta; */
|
||||
/* TH2D *hhx; */
|
||||
/* TH2D *hhy; */
|
||||
/* #endif */
|
||||
/* #ifndef MYROOT1 */
|
||||
/* int *heta; */
|
||||
/* float *hhx; */
|
||||
/* float *hhy; */
|
||||
/* #endif */
|
||||
/* int nbeta; */
|
||||
/* double etamin, etamax, etastep; */
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -1,294 +0,0 @@
|
||||
#ifndef ETA3_INTERPOLATION_BASE_H
|
||||
#define ETA3_INTERPOLATION_BASE_H
|
||||
|
||||
#ifdef MYROOT1
|
||||
#include <TObject.h>
|
||||
#include <TTree.h>
|
||||
#include <TH2D.h>
|
||||
#include <TH2F.h>
|
||||
#endif
|
||||
|
||||
#include "etaInterpolationBase.h"
|
||||
|
||||
class eta3InterpolationBase : public virtual etaInterpolationBase {
|
||||
|
||||
public:
|
||||
eta3InterpolationBase(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx, ny, ns, nb, emin, emax) {
|
||||
// cout << "e3ib " << nb << " " << emin << " " << emax << endl;
|
||||
/* if (nbeta<=0) { */
|
||||
/* nbeta=nSubPixels*10; */
|
||||
/* } */
|
||||
if (etamin>=etamax) {
|
||||
etamin=-1;
|
||||
etamax=1;
|
||||
}
|
||||
|
||||
etastep=(etamax-etamin)/nbeta;
|
||||
#ifdef MYROOT1
|
||||
delete heta;
|
||||
delete hhx;
|
||||
delete hhy;
|
||||
heta=new TH2D("heta","heta",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
||||
hhx=new TH2D("hhx","hhx",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
||||
hhy=new TH2D("hhy","hhy",nbeta,etamin,etamax,nbeta,etamin,etamax);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
/* delete [] heta; */
|
||||
/* delete [] hhx; */
|
||||
/* delete [] hhy; */
|
||||
|
||||
/* heta=new int[nbeta*nbeta]; */
|
||||
/* hhx=new float[nbeta*nbeta]; */
|
||||
/* hhy=new float[nbeta*nbeta]; */
|
||||
|
||||
#endif
|
||||
// cout << nbeta << " " << etamin << " " << etamax << endl;
|
||||
};
|
||||
|
||||
eta3InterpolationBase(eta3InterpolationBase *orig): etaInterpolationBase(orig){ };
|
||||
|
||||
/* virtual eta3InterpolationBase* Clone()=0; */
|
||||
|
||||
|
||||
|
||||
|
||||
// virtual void prepareInterpolation(int &ok){};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////// /*It return position hit for the event in input */ //////////////
|
||||
virtual void getInterpolatedPosition(int x, int y, int *data, double &int_x, double &int_y)
|
||||
{
|
||||
double tot, totquad;
|
||||
double etax,etay;
|
||||
|
||||
int corner=calcEta3(data,etax,etay, totquad);
|
||||
|
||||
getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y);
|
||||
|
||||
return;
|
||||
};
|
||||
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y)
|
||||
{
|
||||
double sDum[2][2];
|
||||
double tot, totquad;
|
||||
double etax,etay;
|
||||
|
||||
int corner=calcEta3(data,etax,etay, totquad);
|
||||
|
||||
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 etax, etay;
|
||||
if (nSubPixels>2) {
|
||||
calcEta3(cl,etax,etay, totquad);
|
||||
}
|
||||
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double totquad,int quad,int *cl,double &int_x, double &int_y) {
|
||||
|
||||
|
||||
double etax, etay;
|
||||
if (nSubPixels>2) {
|
||||
calcEta3(cl,etax,etay, totquad);
|
||||
}
|
||||
return getInterpolatedPosition(x,y,etax, etay,quad,int_x,int_y);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void getInterpolatedPosition(int x, int y, double etax, double etay, int corner, double &int_x, double &int_y)
|
||||
{
|
||||
|
||||
|
||||
double xpos_eta=0,ypos_eta=0;
|
||||
int ex,ey;
|
||||
|
||||
if (nSubPixels>2) {
|
||||
|
||||
#ifdef MYROOT1
|
||||
xpos_eta=(hhx->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels);
|
||||
ypos_eta=(hhy->GetBinContent(hhx->GetXaxis()->FindBin(etax),hhy->GetYaxis()->FindBin(etay)))/((double)nSubPixels);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
ex=(etax-etamin)/etastep;
|
||||
ey=(etay-etamin)/etastep;
|
||||
if (ex<0) {
|
||||
/* cout << etax << " " << etamin << " "; */
|
||||
/* cout << "3x*"<< ex << endl; */
|
||||
ex=0;
|
||||
}
|
||||
if (ex>=nbeta) {
|
||||
/* cout << etax << " " << etamin << " "; */
|
||||
/* cout << "3x?"<< ex << endl; */
|
||||
ex=nbeta-1;
|
||||
}
|
||||
if (ey<0) {
|
||||
/* cout << etay << " " << etamin << " "; */
|
||||
/* cout << "3y*"<< ey << endl; */
|
||||
ey=0;
|
||||
}
|
||||
if (ey>=nbeta) {
|
||||
/* cout << etay << " " << etamin << " "; */
|
||||
/* cout << "3y?"<< ey << endl; */
|
||||
ey=nbeta-1;
|
||||
|
||||
}
|
||||
xpos_eta=(((double)hhx[(ey*nbeta+ex)]));///((double)nSubPixels);
|
||||
ypos_eta=(((double)hhy[(ey*nbeta+ex)]));///((double)nSubPixels);
|
||||
|
||||
#endif
|
||||
|
||||
} else {
|
||||
switch (corner) {
|
||||
case BOTTOM_LEFT:
|
||||
xpos_eta=-0.25;
|
||||
ypos_eta=-0.25;
|
||||
break;
|
||||
case BOTTOM_RIGHT:
|
||||
xpos_eta=0.25;
|
||||
ypos_eta=-0.25;
|
||||
break;
|
||||
case TOP_LEFT:
|
||||
xpos_eta=-0.25;
|
||||
ypos_eta=0.25;
|
||||
break;
|
||||
case TOP_RIGHT:
|
||||
xpos_eta=0.25;
|
||||
ypos_eta=0.25;
|
||||
break;
|
||||
default:
|
||||
xpos_eta=0;
|
||||
ypos_eta=0;
|
||||
}
|
||||
|
||||
}
|
||||
int_x=((double)x) + xpos_eta;
|
||||
int_y=((double)y) + ypos_eta;
|
||||
// int_x=5. + xpos_eta;
|
||||
// int_y=5. + ypos_eta;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* ///////////////////////////////////////////////////////////////////////////////////////////////// */
|
||||
/* virtual void getPositionETA3(int x, int y, double *data, double &int_x, double &int_y) */
|
||||
/* { */
|
||||
/* double sDum[2][2]; */
|
||||
/* double tot, totquad; */
|
||||
/* double eta3x,eta3y; */
|
||||
/* double ex,ey; */
|
||||
|
||||
/* calcQuad(data, tot, totquad, sDum); */
|
||||
/* calcEta3(data,eta3x, eta3y,tot); */
|
||||
|
||||
/* double xpos_eta,ypos_eta; */
|
||||
|
||||
/* #ifdef MYROOT1 */
|
||||
/* xpos_eta=((hhx->GetBinContent(hhx->GetXaxis()->FindBin(eta3x),hhy->GetYaxis()->FindBin(eta3y))))/((double)nSubPixels); */
|
||||
/* ypos_eta=((hhy->GetBinContent(hhx->GetXaxis()->FindBin(eta3x),hhy->GetYaxis()->FindBin(eta3y))))/((double)nSubPixels); */
|
||||
|
||||
/* #endif */
|
||||
/* #ifndef MYROOT1 */
|
||||
/* ex=(eta3x-etamin)/etastep; */
|
||||
/* ey=(eta3y-etamin)/etastep; */
|
||||
|
||||
/* if (ex<0) ex=0; */
|
||||
/* if (ex>=nbeta) ex=nbeta-1; */
|
||||
/* if (ey<0) ey=0; */
|
||||
/* if (ey>=nbeta) ey=nbeta-1; */
|
||||
|
||||
/* xpos_eta=(((double)hhx[(int)(ey*nbeta+ex)]))/((double)nSubPixels); */
|
||||
/* ypos_eta=(((double)hhy[(int)(ey*nbeta+ex)]))/((double)nSubPixels); */
|
||||
/* #endif */
|
||||
|
||||
/* int_x=((double)x) + xpos_eta; */
|
||||
/* int_y=((double)y) + ypos_eta; */
|
||||
|
||||
/* return; */
|
||||
/* }; */
|
||||
|
||||
virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay) {
|
||||
|
||||
calcEta3(cl, etax, etay, totquad);
|
||||
return addToFlatField(etax,etay);
|
||||
}
|
||||
|
||||
virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay) {
|
||||
|
||||
|
||||
calcEta3(cl, etax, etay, totquad);
|
||||
return addToFlatField(etax,etay);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////
|
||||
virtual int addToFlatField(double *cluster, double &etax, double &etay){
|
||||
double totquad;
|
||||
calcEta3(cluster, etax, etay, totquad);
|
||||
return addToFlatField(etax,etay);
|
||||
|
||||
};
|
||||
|
||||
virtual int addToFlatField(int *cluster, double &etax, double &etay){
|
||||
|
||||
double totquad;
|
||||
|
||||
calcEta3(cluster, etax, etay, totquad);
|
||||
return addToFlatField(etax,etay);
|
||||
|
||||
};
|
||||
|
||||
|
||||
virtual int addToFlatField(double etax, double etay){
|
||||
#ifdef MYROOT1
|
||||
heta->Fill(etax,etay);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
int ex,ey;
|
||||
ex=(etax-etamin)/etastep;
|
||||
ey=(etay-etamin)/etastep;
|
||||
if (ey<nbeta && ex<nbeta && ex>=0 && ey>=0)
|
||||
heta[ey*nbeta+ex]++;
|
||||
#endif
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
/* protected: */
|
||||
|
||||
/* #ifdef MYROOT1 */
|
||||
/* TH2D *heta; */
|
||||
/* TH2D *hhx; */
|
||||
/* TH2D *hhy; */
|
||||
/* #endif */
|
||||
/* #ifndef MYROOT1 */
|
||||
/* int *heta; */
|
||||
/* float *hhx; */
|
||||
/* float *hhy; */
|
||||
/* #endif */
|
||||
/* int nbeta; */
|
||||
/* double etamin, etamax, etastep; */
|
||||
|
||||
};
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -4,11 +4,11 @@
|
||||
|
||||
#include "etaInterpolationBase.h"
|
||||
|
||||
class etaInterpolationGlobal : public etaInterpolationBase{
|
||||
class etaInterpolationGlobal : public virtual etaInterpolationBase {
|
||||
public:
|
||||
globalEtaInterpolation(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax){};
|
||||
etaInterpolationGlobal(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns,nsy, nb, nby,emin,emax){};
|
||||
|
||||
|
||||
|
||||
|
||||
virtual void prepareInterpolation(int &ok)
|
||||
{
|
||||
@ -24,62 +24,106 @@ class etaInterpolationGlobal : public etaInterpolationBase{
|
||||
|
||||
|
||||
///*Eta Distribution Rebinning*///
|
||||
double bsize=1./nSubPixels; //precision
|
||||
// double bsizeX=1./nSubPixelsX; //precision
|
||||
// cout<<"nPixelsX = "<<nPixelsX<<" nPixelsY = "<<nPixelsY<<" nSubPixels = "<<nSubPixels<<endl;
|
||||
double tot_eta=0;
|
||||
for (int ip=0; ip<nbeta*nbeta; ip++)
|
||||
for (int ip=0; ip<nbetaX*nbetaY; ip++)
|
||||
tot_eta+=heta[ip];
|
||||
cout << "total eta entries is :"<< tot_eta << endl;
|
||||
if (tot_eta<=0) {ok=0; return;};
|
||||
|
||||
|
||||
double hx[nbeta]; //projection x
|
||||
double hy[nbeta]; //projection y
|
||||
double hx[nbetaX]; //projection x
|
||||
double hy[nbetaY]; //projection y
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
hx[ibx]=hx[ibx]+heta[ibx+iby*nbeta];
|
||||
hy[iby]=hx[iby]+heta[ibx+iby*nbeta];
|
||||
for (int ibx=0; ibx<nbetaX; ibx++) { hx[ibx]=0;}
|
||||
|
||||
for (int iby=0; iby<nbetaY; iby++) { hy[iby]=0;}
|
||||
|
||||
for (int ibx=0; ibx<nbetaX; ibx++) {
|
||||
for (int iby=0; iby<nbetaY; iby++) {
|
||||
hx[ibx]=hx[ibx]+heta[ibx+iby*nbetaX];
|
||||
hy[iby]=hy[iby]+heta[ibx+iby*nbetaX];
|
||||
}
|
||||
}
|
||||
double hix[nbeta]; //integral of projection x
|
||||
double hiy[nbeta]; //integral of projection y
|
||||
double hix[nbetaX]; //integral of projection x
|
||||
double hiy[nbetaY]; //integral of projection y
|
||||
hix[0]=hx[0];
|
||||
hiy[0]=hy[0];
|
||||
|
||||
for (int ib=1; ib<nbeta; ib++) {
|
||||
for (int ib=1; ib<nbetaX; ib++) {
|
||||
hix[ib]=hix[ib-1]+hx[ib];
|
||||
hiy[ib]=hiy[ib-1]+hx[ib];
|
||||
}
|
||||
|
||||
for (int ib=1; ib<nbetaY; ib++) {
|
||||
hiy[ib]=hiy[ib-1]+hy[ib];
|
||||
}
|
||||
double tot_x=hix[nbetaX-1]+1;
|
||||
double tot_y=hiy[nbetaY-1]+1;
|
||||
int ib=0;
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
if (hix[ibx]>(ib+1)*tot_eta*bsize) ib++;
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
#ifdef MYROOT1
|
||||
hhx->SetBinContent(ibx+1,iby+1,ib);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
hhx[ibx+iby*nbeta]=ib;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
ib=0;
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
if (hiy[iby]>(ib+1)*tot_eta*bsize) ib++;
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
#ifdef MYROOT1
|
||||
hhy->SetBinContent(ibx+1,iby+1,ib);
|
||||
#endif
|
||||
#ifndef MYROOT1
|
||||
hhy[ibx+iby*nbeta]=ib;
|
||||
#endif
|
||||
|
||||
for (int ibx=0; ibx<nbetaX; ibx++) {
|
||||
// if (hix[ibx]>(ib+1)*tot_eta*bsize) ib++;
|
||||
for (int iby=0; iby<nbetaY; iby++) {
|
||||
|
||||
if (tot_x>0)
|
||||
hhx[ibx+iby*nbetaX]=hix[ibx]/tot_x;
|
||||
else
|
||||
hhx[ibx+iby*nbetaX]=-1;
|
||||
|
||||
if (tot_y>0)
|
||||
hhy[ibx+iby*nbetaX]=hiy[iby]/tot_y;
|
||||
else
|
||||
hhy[ibx+iby*nbetaX]=-1;
|
||||
}
|
||||
}
|
||||
/* ib=0; */
|
||||
/* for (int iby=0; iby<nbeta; iby++) { */
|
||||
/* if (hiy[iby]>(ib+1)*tot_eta*bsize) ib++; */
|
||||
/* for (int ibx=0; ibx<nbeta; ibx++) { */
|
||||
/* #ifdef MYROOT1 */
|
||||
/* hhy->SetBinContent(ibx+1,iby+1,ib); */
|
||||
/* #endif */
|
||||
/* #ifndef MYROOT1 */
|
||||
/* hhy[ibx+iby*nbeta]=ib; */
|
||||
/* #endif */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
return ;
|
||||
};
|
||||
|
||||
etaInterpolationGlobal(etaInterpolationGlobal *orig): etaInterpolationBase(orig) {};
|
||||
|
||||
};
|
||||
|
||||
|
||||
//etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax),
|
||||
|
||||
class eta2InterpolationGlobal : public virtual eta2InterpolationBase, public virtual etaInterpolationGlobal {
|
||||
|
||||
public:
|
||||
eta2InterpolationGlobal(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : eta2InterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax), etaInterpolationGlobal(nx,ny, ns, nsy, nb, nby, emin, emax){
|
||||
cout << "e2pxy " << nbetaX << " " << nbetaY << etamin << " " << etamax << " " << nSubPixelsX<< " " << nSubPixelsY << endl;
|
||||
};
|
||||
|
||||
eta2InterpolationGlobal(eta2InterpolationGlobal *orig): etaInterpolationBase(orig), etaInterpolationGlobal(orig) {};
|
||||
|
||||
virtual eta2InterpolationGlobal* Clone() { return new eta2InterpolationGlobal(this);};
|
||||
|
||||
};
|
||||
|
||||
//etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax),
|
||||
|
||||
class eta3InterpolationGlobal : public virtual eta3InterpolationBase, public virtual etaInterpolationGlobal {
|
||||
public:
|
||||
eta3InterpolationGlobal(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : eta3InterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax), etaInterpolationGlobal(nx,ny, ns, nsy, nb, nby, emin, emax){
|
||||
cout << "e3pxy " << nbetaX << " " << nbetaY << etamin << " " << etamax << " " << nSubPixelsX<< " " << nSubPixelsY << endl;
|
||||
};
|
||||
|
||||
eta3InterpolationGlobal(eta3InterpolationGlobal *orig): etaInterpolationBase(orig), etaInterpolationGlobal(orig) {};
|
||||
|
||||
virtual eta3InterpolationGlobal* Clone() {return new eta3InterpolationGlobal(this);};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -4,12 +4,10 @@
|
||||
|
||||
//#include "tiffIO.h"
|
||||
#include "etaInterpolationBase.h"
|
||||
#include "eta2InterpolationBase.h"
|
||||
#include "eta3InterpolationBase.h"
|
||||
|
||||
class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
||||
public:
|
||||
etaInterpolationPosXY(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax){
|
||||
etaInterpolationPosXY(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax){
|
||||
// cout << "epxy " << nb << " " << emin << " " << emax << endl; cout << nbeta << " " << etamin << " " << etamax << endl;
|
||||
};
|
||||
|
||||
@ -24,124 +22,146 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
||||
virtual void prepareInterpolation(int &ok)
|
||||
{
|
||||
ok=1;
|
||||
#ifdef MYROOT1
|
||||
if (hhx) delete hhx;
|
||||
if (hhy) delete hhy;
|
||||
|
||||
hhx=new TH2D("hhx","hhx",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax());
|
||||
hhy=new TH2D("hhy","hhy",heta->GetNbinsX(),heta->GetXaxis()->GetXmin(),heta->GetXaxis()->GetXmax(), heta->GetNbinsY(),heta->GetYaxis()->GetXmin(),heta->GetYaxis()->GetXmax());
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
///*Eta Distribution Rebinning*///
|
||||
double bsize=1./nSubPixels; //precision
|
||||
// double bsize=1./nSubPixels; //precision
|
||||
// cout<<"nPixelsX = "<<nPixelsX<<" nPixelsY = "<<nPixelsY<<" nSubPixels = "<<nSubPixels<<endl;
|
||||
double tot_eta=0;
|
||||
double tot_eta_x=0;
|
||||
double tot_eta_y=0;
|
||||
for (int ip=0; ip<nbeta*nbeta; ip++)
|
||||
for (int ip=0; ip<nbetaX*nbetaY; ip++)
|
||||
tot_eta+=heta[ip];
|
||||
cout << "total eta entries is :"<< tot_eta << endl;
|
||||
if (tot_eta<=0) {ok=0; return;};
|
||||
|
||||
|
||||
double hx[nbeta]; //profile x
|
||||
double hy[nbeta]; //profile y
|
||||
double hix[nbeta]; //integral of projection x
|
||||
double hiy[nbeta]; //integral of projection y
|
||||
int ii=0;
|
||||
double hx[nbetaX]; //profile x
|
||||
double hy[nbetaY]; //profile y
|
||||
double hix[nbetaX]; //integral of projection x
|
||||
double hiy[nbetaY]; //integral of projection y
|
||||
// int ii=0;
|
||||
double etax, etay;
|
||||
for (int ib=0; ib<nbeta; ib++) {
|
||||
|
||||
for (int ib=0; ib<nbetaX; ib++) {
|
||||
//tot_eta_y=0;
|
||||
|
||||
tot_eta_x=0;
|
||||
tot_eta_y=0;
|
||||
|
||||
for (int iby=0; iby<nbeta; iby++) {
|
||||
etax=etamin+iby*etastep;
|
||||
for (int iby=0; iby<nbetaY; iby++) {
|
||||
etay=etamin+iby*etastepY;
|
||||
//cout << etax << endl;
|
||||
if (etax>=0 && etax<=1)
|
||||
hx[iby]=heta[iby+ib*nbeta];
|
||||
else {
|
||||
hx[iby]=0;
|
||||
}
|
||||
|
||||
// tot_eta_x+=hx[iby];
|
||||
if (etax>=0 && etax<=1)
|
||||
hy[iby]=heta[ib+iby*nbeta];
|
||||
else
|
||||
hy[iby]=0;
|
||||
// if (etay>=0 && etay<=1)
|
||||
hy[iby]=heta[ib+iby*nbetaX];
|
||||
// else
|
||||
// hy[iby]=0;
|
||||
// tot_eta_y+=hy[iby];
|
||||
}
|
||||
|
||||
hix[0]=hx[0];
|
||||
|
||||
hiy[0]=hy[0];
|
||||
|
||||
for (int iby=1; iby<nbeta; iby++) {
|
||||
hix[iby]=hix[iby-1]+hx[iby];
|
||||
for (int iby=1; iby<nbetaY; iby++) {
|
||||
hiy[iby]=hiy[iby-1]+hy[iby];
|
||||
}
|
||||
|
||||
ii=0;
|
||||
tot_eta_x=hix[nbeta-1]+1;
|
||||
tot_eta_y=hiy[nbeta-1]+1;
|
||||
tot_eta_y=hiy[nbetaY-1]+1;
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
if (tot_eta_x<=0) {
|
||||
hhx[ibx+ib*nbeta]=-1;
|
||||
//ii=(ibx)/nbeta;
|
||||
} else //if (hix[ibx]>(ii+1)*tot_eta_x*bsize)
|
||||
{
|
||||
//if (hix[ibx]>tot_eta_x*(ii+1)/nSubPixels) ii++;
|
||||
hhx[ibx+ib*nbeta]=hix[ibx]/tot_eta_x;
|
||||
}
|
||||
}
|
||||
/* if (ii!=(nSubPixels-1)) */
|
||||
/* cout << ib << " x " << tot_eta_x << " " << (ii+1)*tot_eta_x*bsize << " " << ii << " " << hix[nbeta-1]<< endl; */
|
||||
|
||||
ii=0;
|
||||
|
||||
for (int ibx=0; ibx<nbeta; ibx++) {
|
||||
if (tot_eta_y<=0) {
|
||||
hhy[ib+ibx*nbeta]=-1;
|
||||
for (int iby=0; iby<nbetaY; iby++) {
|
||||
if (tot_eta_y<=1) {
|
||||
hhy[ib+iby*nbetaX]=-1;
|
||||
//ii=(ibx*nSubPixels)/nbeta;
|
||||
} else {
|
||||
//if (hiy[ibx]>tot_eta_y*(ii+1)/nSubPixels) ii++;
|
||||
hhy[ib+ibx*nbeta]=hiy[ibx]/tot_eta_y;
|
||||
hhy[ib+iby*nbetaX]=hiy[iby]/tot_eta_y;
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << "hhy filled " << endl;
|
||||
|
||||
|
||||
int ibx, iby, ib;
|
||||
|
||||
iby=0;
|
||||
while (hhx[iby*nbeta+nbeta/2]<0) iby++;
|
||||
for (ib=0; ib<iby;ib++) {
|
||||
for (ibx=0; ibx<nbeta;ibx++)
|
||||
hhx[ibx+nbeta*ib]=hhx[ibx+nbeta*iby];
|
||||
}
|
||||
iby=nbeta-1;
|
||||
|
||||
while (hhx[iby*nbeta+nbeta/2]<0) iby--;
|
||||
for (ib=iby+1; ib<nbeta;ib++) {
|
||||
for (ibx=0; ibx<nbeta;ibx++)
|
||||
hhx[ibx+nbeta*ib]=hhx[ibx+nbeta*iby];
|
||||
}
|
||||
|
||||
iby=0;
|
||||
while (hhy[nbeta/2*nbeta+iby]<0) iby++;
|
||||
for (ib=0; ib<iby;ib++) {
|
||||
for (ibx=0; ibx<nbeta;ibx++)
|
||||
hhy[ib+nbeta*ibx]=hhy[iby+nbeta*ibx];
|
||||
}
|
||||
iby=nbeta-1;
|
||||
|
||||
while (hhy[nbeta/2*nbeta+iby]<0) iby--;
|
||||
for (ib=iby+1; ib<nbeta;ib++) {
|
||||
for (ibx=0; ibx<nbeta;ibx++)
|
||||
hhy[ib+nbeta*ibx]=hhy[iby+nbeta*ibx];
|
||||
}
|
||||
for (int ib=0; ib<nbetaY; ib++) {
|
||||
|
||||
for (int ibx=0; ibx<nbetaX; ibx++) {
|
||||
etax=etamin+ibx*etastepX;
|
||||
//cout << etax << endl;
|
||||
// if (etax>=0 && etax<=1)
|
||||
hx[ibx]=heta[ibx+ib*nbetaX];
|
||||
// else {
|
||||
// hx[ibx]=0;
|
||||
// }
|
||||
}
|
||||
hix[0]=hx[0];
|
||||
|
||||
for (int ibx=1; ibx<nbetaX; ibx++) {
|
||||
hix[ibx]=hix[ibx-1]+hx[ibx];
|
||||
}
|
||||
|
||||
|
||||
tot_eta_x=hix[nbetaX-1]+1;
|
||||
|
||||
for (int ibx=0; ibx<nbetaX; ibx++) {
|
||||
if (tot_eta_x<=1) {
|
||||
hhx[ibx+ib*nbetaX]=-1;
|
||||
}
|
||||
else {
|
||||
hhx[ibx+ib*nbetaX]=hix[ibx]/tot_eta_x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (int ibx=0; ibx<nbetaX; ibx++) {
|
||||
if (tot_eta_x<=0) {
|
||||
hhx[ibx+ib*nbetaX]=-1;
|
||||
} else {
|
||||
//if (hix[ibx]>tot_eta_x*(ii+1)/nSubPixels) ii++;
|
||||
hhx[ibx+ib*nbetaX]=hix[ibx]/tot_eta_x;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* cout << "hhx filled " << endl; */
|
||||
/* int ibx, iby, ib; */
|
||||
|
||||
/* iby=0; */
|
||||
/* while (hhx[iby*nbetaY+nbetaY/2]<0 && iby<nbetaY/2) iby++; */
|
||||
/* for (ib=0; ib<iby;ib++) { */
|
||||
/* for (ibx=0; ibx<nbetaX;ibx++) */
|
||||
/* hhx[ibx+nbetaX*ib]=hhx[ibx+nbetaX*iby]; */
|
||||
/* } */
|
||||
|
||||
/* cout << "hhx low optimized" << endl; */
|
||||
|
||||
/* iby=nbetaY-1; */
|
||||
/* while (hhx[iby*nbetaY+nbetaY/2]<0 && iby>0) iby--; */
|
||||
|
||||
/* for (ib=iby+1; ib<nbetaY;ib++) { */
|
||||
/* for (ibx=0; ibx<nbetaX;ibx++){ */
|
||||
/* cout << iby << " " << ib << " " << ibx << " " << ibx+nbetaX*ib << " " << ibx+nbetaX*iby << " " << nbetaX*nbetaY << endl; */
|
||||
/* hhx[ibx+nbetaX*ib]=hhx[ibx+nbetaX*iby]; */
|
||||
/* } */
|
||||
/* } */
|
||||
|
||||
/* cout << "hhx high optimized" << endl; */
|
||||
|
||||
/* iby=0; */
|
||||
/* while (hhy[nbetaX/2*nbetaX+iby]<0 && iby<nbetaX) iby++; */
|
||||
/* for (ib=0; ib<iby;ib++) { */
|
||||
/* for (ibx=0; ibx<nbetaY;ibx++) */
|
||||
/* hhy[ib+nbetaX*ibx]=hhy[iby+nbetaX*ibx]; */
|
||||
/* } */
|
||||
/* cout << "hhy low optimized" << endl; */
|
||||
|
||||
/* iby=nbetaX-1; */
|
||||
/* while (hhy[nbetaX/2*nbetaX+iby]<0 && iby>) iby--; */
|
||||
/* for (ib=iby+1; ib<nbetaX;ib++) { */
|
||||
/* for (ibx=0; ibx<nbetaY;ibx++) */
|
||||
/* hhy[ib+nbetaX*ibx]=hhy[iby+nbetaX*ibx]; */
|
||||
/* } */
|
||||
|
||||
/* cout << "hhy high optimized" << endl; */
|
||||
|
||||
|
||||
|
||||
@ -156,10 +176,17 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class eta2InterpolationPosXY : public virtual eta2InterpolationBase, public virtual etaInterpolationPosXY {
|
||||
public:
|
||||
eta2InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax),eta2InterpolationBase(nx,ny,ns, nb, emin,emax),etaInterpolationPosXY(nx,ny,ns, nb, emin,emax){
|
||||
// cout << "e2pxy " << nb << " " << emin << " " << emax << endl;
|
||||
eta2InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax),eta2InterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax),etaInterpolationPosXY(nx,ny, ns, nsy, nb, nby, emin, emax){
|
||||
cout << "e2pxy " << nbetaX << " " << nbetaY << etamin << " " << etamax << " " << nSubPixelsX<< " " << nSubPixelsY << endl;
|
||||
};
|
||||
|
||||
eta2InterpolationPosXY(eta2InterpolationPosXY *orig): etaInterpolationBase(orig), etaInterpolationPosXY(orig) {};
|
||||
@ -168,12 +195,12 @@ class eta2InterpolationPosXY : public virtual eta2InterpolationBase, public virt
|
||||
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
|
||||
class eta3InterpolationPosXY : public virtual eta3InterpolationBase, public virtual etaInterpolationPosXY {
|
||||
public:
|
||||
eta3InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nb=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny,ns, nb, emin,emax),eta3InterpolationBase(nx,ny,ns, nb, emin,emax), etaInterpolationPosXY(nx,ny,ns, nb, emin,emax){
|
||||
cout << "e3pxy " << nbeta << " " << etamin << " " << etamax << " " << nSubPixels<< endl;
|
||||
eta3InterpolationPosXY(int nx=400, int ny=400, int ns=25, int nsy=25, int nb=-1, int nby=-1, double emin=1, double emax=0) : etaInterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax), eta3InterpolationBase(nx,ny, ns, nsy, nb, nby, emin, emax), etaInterpolationPosXY(nx,ny, ns, nsy, nb, nby, emin, emax){
|
||||
cout << "e3pxy " << nbetaX << " " << nbetaY << etamin << " " << etamax << " " << nSubPixelsX<< " " << nSubPixelsY << endl;
|
||||
};
|
||||
|
||||
eta3InterpolationPosXY(eta3InterpolationPosXY *orig): etaInterpolationBase(orig), etaInterpolationPosXY(orig) {};
|
||||
|
@ -0,0 +1,52 @@
|
||||
#ifndef INTERPOLATION_ETAVEL_H
|
||||
#define INTERPOLATION_ETAVEL_H
|
||||
|
||||
#include <slsInterpolation.h>
|
||||
#include "EtaVEL.h"
|
||||
#include "TH2F.h"
|
||||
//#include "EtaVEL.cpp"
|
||||
//class EtaVEL;
|
||||
|
||||
class interpolation_EtaVEL: public slsInterpolation {
|
||||
|
||||
public:
|
||||
interpolation_EtaVEL(int nx=40, int ny=160, int ns=25, double etamin=-0.02, double etamax=1.02, int p=0);
|
||||
~interpolation_EtaVEL();
|
||||
|
||||
|
||||
//create eta distribution, eta rebinnining etc.
|
||||
//returns flat field image
|
||||
void prepareInterpolation(int &ok){prepareInterpolation(ok,10000);};
|
||||
void prepareInterpolation(int &ok, int maxit);
|
||||
|
||||
//create interpolated image
|
||||
//returns interpolated image
|
||||
|
||||
//return position inside the pixel for the given photon
|
||||
void getInterpolatedPosition(Int_t x, Int_t y, Double_t *data, Double_t &int_x, Double_t &int_y);
|
||||
void getInterpolatedBin(Double_t *cluster, Int_t &int_x, Int_t &int_y);
|
||||
|
||||
|
||||
|
||||
int addToFlatField(Double_t *cluster, Double_t &etax, Double_t &etay);
|
||||
int addToFlatField(Double_t etax, Double_t etay);
|
||||
int setPlot(int p=-1) {if (p>=0) plot=p; return plot;};
|
||||
int WriteH(){newEta->Write("newEta"); heta->Write("heta");};
|
||||
EtaVEL *setEta(EtaVEL *ev){if (ev) {delete newEta; newEta=ev;} return newEta;};
|
||||
TH2F *setEta(TH2F *ev){if (ev) {delete heta; heta=ev;} return heta;};
|
||||
void iterate();
|
||||
void DrawH();
|
||||
double getChiSq(){return newEta->getChiSq();};
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
EtaVEL *newEta;
|
||||
TH2F *heta;
|
||||
int plot;
|
||||
|
||||
// ClassDefNV(interpolation_EtaVEL,1);
|
||||
// #pragma link C++ class interpolation_EtaVEL-;
|
||||
};
|
||||
|
||||
#endif
|
@ -29,19 +29,21 @@ class slsInterpolation
|
||||
{
|
||||
|
||||
public:
|
||||
slsInterpolation(int nx=400, int ny=400, int ns=25) :nPixelsX(nx), nPixelsY(ny), nSubPixels(ns), id(0) {
|
||||
slsInterpolation(int nx=400, int ny=400, int ns=25, int nsy=-1) :nPixelsX(nx), nPixelsY(ny), nSubPixelsX(ns), nSubPixelsY(nsy),id(0) {
|
||||
|
||||
hint=new int[ns*nx*ns*ny];
|
||||
if (nSubPixelsY<=0) nSubPixelsY=nSubPixelsX;
|
||||
hint=new int[nSubPixelsX*nx*nSubPixelsY*ny];
|
||||
|
||||
};
|
||||
|
||||
slsInterpolation(slsInterpolation *orig){
|
||||
nPixelsX=orig->nPixelsX;
|
||||
nPixelsY=orig->nPixelsY;
|
||||
nSubPixels=orig->nSubPixels;
|
||||
nSubPixelsX=orig->nSubPixelsX;
|
||||
nSubPixelsY=orig->nSubPixelsY;
|
||||
|
||||
hint=new int[nSubPixels*nPixelsX*nSubPixels*nPixelsY];
|
||||
memcpy(hint, orig->hint,nSubPixels*nPixelsX*nSubPixels*nPixelsY*sizeof(int));
|
||||
hint=new int[nSubPixelsX*nPixelsX*nSubPixelsY*nPixelsY];
|
||||
memcpy(hint, orig->hint,nSubPixelsX*nPixelsX*nSubPixelsY*nPixelsY*sizeof(int));
|
||||
|
||||
};
|
||||
|
||||
@ -51,23 +53,37 @@ class slsInterpolation
|
||||
return new slsInterpolation(this);
|
||||
}*/
|
||||
|
||||
int getNSubPixels() {return nSubPixels;};
|
||||
int getNSubPixelsX() {return nSubPixelsX;};
|
||||
int getNSubPixelsY() {return nSubPixelsY;};
|
||||
int getNSubPixels() {if (nSubPixelsX==nSubPixelsY) return nSubPixelsX; else return 0;};
|
||||
void getNSubPixels(int &nsx, int &nsy) {nsx=nSubPixelsX; nsy=nsx=nSubPixelsY;}
|
||||
|
||||
|
||||
int setNSubPixels(int ns) {
|
||||
if (ns>0 && ns!=nSubPixels) {
|
||||
void setNSubPixels(int ns, int nsy=-1) {
|
||||
|
||||
delete [] hint;
|
||||
nSubPixels=ns;
|
||||
hint=new int[nSubPixels*nPixelsX*nSubPixels*nPixelsY];
|
||||
}
|
||||
return nSubPixels;
|
||||
nSubPixelsX=ns;
|
||||
if (nsy>0) nSubPixelsY=nsy;
|
||||
else nSubPixelsY=ns;
|
||||
|
||||
hint=new int[nSubPixelsX*nPixelsX*nSubPixelsY*nPixelsY];
|
||||
|
||||
//return nSubPixels;
|
||||
}
|
||||
|
||||
int getImageSize(int &nnx, int &nny, int &ns) {
|
||||
nnx=nSubPixels*nPixelsX;
|
||||
nny=nSubPixels*nPixelsY;
|
||||
ns=nSubPixels;
|
||||
return nSubPixels*nSubPixels*nPixelsX*nPixelsY;
|
||||
|
||||
|
||||
|
||||
int getImageSize(int &nnx, int &nny, int &nsx, int &nsy) {
|
||||
nnx=nSubPixelsX*nPixelsX;
|
||||
nny=nSubPixelsY*nPixelsY;
|
||||
nsx=nSubPixelsX;
|
||||
nsy=nSubPixelsY;
|
||||
return nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY;
|
||||
};
|
||||
|
||||
|
||||
int getImageSize() {
|
||||
return nSubPixelsX*nSubPixelsY*nPixelsX*nPixelsY;
|
||||
};
|
||||
|
||||
|
||||
@ -78,10 +94,7 @@ class slsInterpolation
|
||||
//create interpolated image
|
||||
//returns interpolated image
|
||||
virtual int *getInterpolatedImage(){
|
||||
// cout << "return interpolated image " << endl;
|
||||
/* for (int i=0; i<nSubPixels* nSubPixels* nPixelsX*nPixelsY; i++) { */
|
||||
/* cout << i << " " << hint[i] << endl; */
|
||||
/* } */
|
||||
//cout << "?" <<endl;
|
||||
return hint;
|
||||
};
|
||||
|
||||
@ -89,17 +102,21 @@ class slsInterpolation
|
||||
|
||||
|
||||
void *writeInterpolatedImage(const char * imgname) {
|
||||
//cout << "!" <<endl;
|
||||
float *gm=NULL;
|
||||
//cout << "!" <<endl;
|
||||
int *dummy=getInterpolatedImage();
|
||||
gm=new float[ nSubPixels* nSubPixels* nPixelsX*nPixelsY];
|
||||
cout << "got interpolated image " << endl;
|
||||
gm=new float[ nSubPixelsX* nSubPixelsY* nPixelsX*nPixelsY];
|
||||
cout << "created dummy " << endl;
|
||||
if (gm) {
|
||||
for (int ix=0; ix<nPixelsX*nSubPixels; ix++) {
|
||||
for (int iy=0; iy<nPixelsY*nSubPixels; iy++) {
|
||||
gm[iy*nPixelsX*nSubPixels+ix]=dummy[iy*nPixelsX*nSubPixels+ix];
|
||||
for (int ix=0; ix<nPixelsX*nSubPixelsX; ix++) {
|
||||
for (int iy=0; iy<nPixelsY*nSubPixelsY; iy++) {
|
||||
gm[iy*nPixelsX*nSubPixelsX+ix]=dummy[iy*nPixelsX*nSubPixelsX+ix];
|
||||
// cout << "++" << ix << " " << iy << " " << iy*nPixelsX*nSubPixelsX+ix << endl;
|
||||
}
|
||||
}
|
||||
WriteToTiff(gm, imgname,nSubPixels* nPixelsX ,nSubPixels* nPixelsY);
|
||||
WriteToTiff(gm, imgname,nSubPixelsX* nPixelsX ,nSubPixelsY* nPixelsY);
|
||||
// cout << "wrote to tiff " << endl;
|
||||
delete [] gm;
|
||||
} else cout << "Could not allocate float image " << endl;
|
||||
return NULL;
|
||||
@ -120,9 +137,9 @@ class slsInterpolation
|
||||
virtual void clearInterpolatedImage() {
|
||||
|
||||
|
||||
for (int ix=0; ix<nPixelsX*nSubPixels; ix++) {
|
||||
for (int iy=0; iy<nPixelsY*nSubPixels; iy++) {
|
||||
hint[iy*nPixelsX*nSubPixels+ix]=0;
|
||||
for (int ix=0; ix<nPixelsX*nSubPixelsX; ix++) {
|
||||
for (int iy=0; iy<nPixelsY*nSubPixelsY; iy++) {
|
||||
hint[iy*nPixelsX*nSubPixelsX+ix]=0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,11 +150,11 @@ class slsInterpolation
|
||||
|
||||
|
||||
virtual int *addToImage(double int_x, double int_y){
|
||||
int iy=((double)nSubPixels)*int_y;
|
||||
int ix=((double)nSubPixels)*int_x;
|
||||
if (ix>=0 && ix<(nPixelsX*nSubPixels) && iy<(nSubPixels*nPixelsY) && iy>=0 ){
|
||||
int iy=((double)nSubPixelsY)*int_y;
|
||||
int ix=((double)nSubPixelsX)*int_x;
|
||||
if (ix>=0 && ix<(nPixelsX*nSubPixelsX) && iy<(nSubPixelsY*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;
|
||||
(*(hint+ix+iy*nPixelsX*nSubPixelsX))+=1;
|
||||
// cout << " " << hint[ix+iy*nPixelsX*nSubPixels] << endl;
|
||||
}// else
|
||||
// cout << "bad! "<< int_x << " " << int_y << " " << " " << ix << " " << iy << " " << ix+iy*nPixelsX*nSubPixels << endl;
|
||||
@ -172,6 +189,7 @@ class slsInterpolation
|
||||
|
||||
|
||||
static int calcQuad(double *cl, double &sum, double &totquad, double sDum[2][2]){
|
||||
//cout << "2";
|
||||
|
||||
int corner = UNDEFINED_QUADRANT;
|
||||
/* double *cluster[3]; */
|
||||
@ -352,6 +370,7 @@ class slsInterpolation
|
||||
|
||||
|
||||
static int calcEta3(double *cl, double &etax, double &etay, double &sum) {
|
||||
// cout << "3";
|
||||
double l=0,r=0,t=0,b=0, val;
|
||||
sum=0;
|
||||
// int quad;
|
||||
@ -359,10 +378,10 @@ class slsInterpolation
|
||||
for (int iy=0; iy<3; iy++) {
|
||||
val=cl[ix+3*iy];
|
||||
sum+=val;
|
||||
if (iy==0) l+=val;
|
||||
if (iy==2) r+=val;
|
||||
if (ix==0) b+=val;
|
||||
if (ix==2) t+=val;
|
||||
if (ix==0) l+=val;
|
||||
if (ix==2) r+=val;
|
||||
if (iy==0) b+=val;
|
||||
if (iy==2) t+=val;
|
||||
}
|
||||
}
|
||||
if (sum>0) {
|
||||
@ -495,7 +514,7 @@ class slsInterpolation
|
||||
|
||||
protected:
|
||||
int nPixelsX, nPixelsY;
|
||||
int nSubPixels;
|
||||
int nSubPixelsX, nSubPixelsY;
|
||||
int id;
|
||||
int *hint;
|
||||
};
|
||||
|
@ -1,44 +1,60 @@
|
||||
#ifndef MOENCH03COMMONMODE_H
|
||||
#define MOENCH03COMMONMODE_H
|
||||
|
||||
#include "commonModeSubtraction.h"
|
||||
#include "commonModeSubtractionNew.h"
|
||||
|
||||
class moench03CommonMode : public commonModeSubtraction {
|
||||
class commonModeSubtractionColumn: public commonModeSubtraction{
|
||||
public:
|
||||
commonModeSubtractionColumn(int nr=200) : commonModeSubtraction(800), rows(nr) {};
|
||||
virtual int getROI(int ix, int iy){return ix+(iy/200)*400;};
|
||||
|
||||
virtual void addToCommonMode(double val, int ix=0, int iy=0) {
|
||||
if (iy<rows || iy>399-rows) {
|
||||
int iroi=getROI(ix,iy);
|
||||
// cout << iy << " " << ix << " " << iroi ;
|
||||
if (iroi>=0 && iroi<nROI) {
|
||||
mean[iroi]+=val;
|
||||
mean2[iroi]+=val*val;
|
||||
nCm[iroi]++;
|
||||
if (nCm[iroi]>rows) cout << "Too many pixels added " << nCm[iroi] << endl;
|
||||
/* if (ix==10 && iy<20) */
|
||||
/* cout << " ** "<<val << " " << mean[iroi] << " " << nCm[iroi] << " " << getCommonMode(ix, iy) << endl; */
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
virtual commonModeSubtractionColumn *Clone() {
|
||||
return new commonModeSubtractionColumn(this->rows);
|
||||
}
|
||||
|
||||
private:
|
||||
int rows;
|
||||
};
|
||||
|
||||
|
||||
class commonModeSubtractionSuperColumn: public commonModeSubtraction{
|
||||
public:
|
||||
commonModeSubtractionSuperColumn() : commonModeSubtraction(32) {};
|
||||
virtual int getROI(int ix, int iy){ return ix/25+(iy/200)*16;};
|
||||
};
|
||||
|
||||
|
||||
class commonModeSubtractionHalf: public commonModeSubtraction{
|
||||
public:
|
||||
commonModeSubtractionHalf() : commonModeSubtraction(2) {};
|
||||
virtual int getROI(int ix, int iy){ (void) ix; return iy/200;};
|
||||
};
|
||||
|
||||
|
||||
class moench03CommonMode : public commonModeSubtractionColumn {
|
||||
/** @short class to calculate the common mode noise for moench02 i.e. on 4 supercolumns separately */
|
||||
public:
|
||||
/** constructor - initalizes a commonModeSubtraction with 4 different regions of interest
|
||||
\param nn number of samples for the moving average
|
||||
*/
|
||||
moench03CommonMode(int nn=1000) : commonModeSubtraction(nn,32){} ;
|
||||
moench03CommonMode(int nr=20) : commonModeSubtractionColumn(nr){} ;
|
||||
|
||||
|
||||
/** add value to common mode as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each;
|
||||
\param val value to add to the common mode
|
||||
\param ix pixel coordinate in the x direction
|
||||
\param iy pixel coordinate in the y direction
|
||||
*/
|
||||
virtual void addToCommonMode(double val, int ix=0, int iy=0) {
|
||||
// (void) iy;
|
||||
int isc=ix/25+(iy/200)*16;
|
||||
if (isc>=0 && isc<nROI) {
|
||||
cmPed[isc]+=val;
|
||||
nCm[isc]++;
|
||||
}
|
||||
};
|
||||
/**returns common mode value as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each;
|
||||
\param ix pixel coordinate in the x direction
|
||||
\param iy pixel coordinate in the y direction
|
||||
\returns common mode value
|
||||
*/
|
||||
virtual double getCommonMode(int ix=0, int iy=0) {
|
||||
(void) iy;
|
||||
int isc=ix/25+(iy/200)*16;
|
||||
if (isc>=0 && isc<nROI) {
|
||||
if (nCm[isc]>0) return cmPed[isc]/nCm[isc]-cmStat[isc].Mean();
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
64
slsDetectorCalibration/moench03GhostSummation.h
Normal file
64
slsDetectorCalibration/moench03GhostSummation.h
Normal file
@ -0,0 +1,64 @@
|
||||
#ifndef MOENCH03GHOSTSUMMATION_H
|
||||
#define MOENCH03GHOSTSUMMATION_H
|
||||
|
||||
#include "ghostSummation.h"
|
||||
|
||||
class moench03GhostSummation : public ghostSummation<uint16_t> {
|
||||
|
||||
/** @short virtual calss to handle ghosting*/
|
||||
|
||||
public:
|
||||
|
||||
/** constructor
|
||||
\param xt crosstalk
|
||||
*/
|
||||
moench03GhostSummation(slsDetectorData<uint16_t> *d, double xt=0.0004) : ghostSummation<uint16_t>(d, xt) {}
|
||||
|
||||
virtual void calcGhost(char *data){
|
||||
for (int iy=0; iy<200; iy++){
|
||||
for (int ix=0; ix<25; ix++){
|
||||
calcGhost(data,ix,iy);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
moench03GhostSummation(moench03GhostSummation *orig) : ghostSummation(orig) {
|
||||
}
|
||||
|
||||
virtual moench03GhostSummation *Clone() {
|
||||
return new moench03GhostSummation(this);
|
||||
}
|
||||
|
||||
virtual double calcGhost(char *data, int x, int y=0){
|
||||
int ix=x%25;
|
||||
int iy=y;
|
||||
if (y>=200) iy=399-y;
|
||||
if (iy<0 || ix<0) return 0;
|
||||
double val=0;
|
||||
val=0;
|
||||
for (int isc=0; isc<16; isc++) {
|
||||
val+=det->getChannel(data,ix+25*isc,iy);
|
||||
// cout << val << " " ;
|
||||
val+=det->getChannel(data,ix+25*isc,399-iy);
|
||||
// cout << val << " " ;
|
||||
}
|
||||
ghost[iy*nx+ix]=xtalk*val;
|
||||
// if (ix==15 && iy==15) cout << ":" << ghost[iy*nx+ix] << " " << val << endl;
|
||||
return ghost[iy*nx+ix];
|
||||
};
|
||||
|
||||
|
||||
virtual double getGhost(int ix, int iy) {
|
||||
if (iy >=0 && iy<200) return ghost[iy*nx+(ix%25)];
|
||||
if (iy<400) return ghost[(399-iy)*nx+(ix%25)];
|
||||
return 0;
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,7 +1,7 @@
|
||||
#ifndef MOENCHCOMMONMODE_H
|
||||
#define MOENCHCOMMONMODE_H
|
||||
|
||||
#include "commonModeSubtraction.h"
|
||||
#include "commonModeSubtractionNew.h"
|
||||
|
||||
class moenchCommonMode : public commonModeSubtraction {
|
||||
/** @short class to calculate the common mode noise for moench02 i.e. on 4 supercolumns separately */
|
||||
@ -9,35 +9,36 @@ class moenchCommonMode : public commonModeSubtraction {
|
||||
/** constructor - initalizes a commonModeSubtraction with 4 different regions of interest
|
||||
\param nn number of samples for the moving average
|
||||
*/
|
||||
moenchCommonMode(int nn=1000) : commonModeSubtraction(nn,4){} ;
|
||||
|
||||
moenchCommonMode(int nn=0) : commonModeSubtraction(0){} ;
|
||||
|
||||
|
||||
/** add value to common mode as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each;
|
||||
\param val value to add to the common mode
|
||||
\param ix pixel coordinate in the x direction
|
||||
\param iy pixel coordinate in the y direction
|
||||
*/
|
||||
virtual void addToCommonMode(double val, int ix=0, int iy=0) {
|
||||
(void) iy;
|
||||
int isc=ix/40;
|
||||
if (isc>=0 && isc<nROI) {
|
||||
cmPed[isc]+=val;
|
||||
nCm[isc]++;
|
||||
}
|
||||
};
|
||||
/**returns common mode value as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each;
|
||||
\param ix pixel coordinate in the x direction
|
||||
\param iy pixel coordinate in the y direction
|
||||
\returns common mode value
|
||||
*/
|
||||
virtual double getCommonMode(int ix=0, int iy=0) {
|
||||
(void) iy;
|
||||
int isc=ix/40;
|
||||
if (isc>=0 && isc<nROI) {
|
||||
if (nCm[isc]>0) return cmPed[isc]/nCm[isc]-cmStat[isc].Mean();
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
/* /\** add value to common mode as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each; */
|
||||
/* \param val value to add to the common mode */
|
||||
/* \param ix pixel coordinate in the x direction */
|
||||
/* \param iy pixel coordinate in the y direction */
|
||||
/* *\/ */
|
||||
/* virtual void addToCommonMode(double val, int ix=0, int iy=0) { */
|
||||
/* (void) iy; */
|
||||
/* int isc=ix/40; */
|
||||
/* if (isc>=0 && isc<nROI) { */
|
||||
/* cmPed[isc]+=val; */
|
||||
/* nCm[isc]++; */
|
||||
/* } */
|
||||
/* }; */
|
||||
/* /\**returns common mode value as a function of the pixel value, subdividing the region of interest in the 4 supercolumns of 40 columns each; */
|
||||
/* \param ix pixel coordinate in the x direction */
|
||||
/* \param iy pixel coordinate in the y direction */
|
||||
/* \returns common mode value */
|
||||
/* *\/ */
|
||||
/* virtual double getCommonMode(int ix=0, int iy=0) { */
|
||||
/* (void) iy; */
|
||||
/* int isc=ix/40; */
|
||||
/* if (isc>=0 && isc<nROI) { */
|
||||
/* if (nCm[isc]>0) return cmPed[isc]/nCm[isc]-cmStat[isc].Mean(); */
|
||||
/* } */
|
||||
/* return 0; */
|
||||
/* }; */
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,39 +1,47 @@
|
||||
#module add CBFlib/0.9.5
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsSupportLib/include/ -I../../slsReceiverSoftware/include/
|
||||
|
||||
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -pthread -lrt -ltiff -O3 -std=c++11
|
||||
|
||||
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/
|
||||
#LIBHDF5=
|
||||
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff
|
||||
#-L$(ZMQLIB) -lzmq
|
||||
#-L../../bin
|
||||
MAIN=moench03ClusterFinder.cpp
|
||||
#-lhdf5
|
||||
#DESTDIR?=../bin
|
||||
|
||||
|
||||
all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
|
||||
|
||||
|
||||
|
||||
moenchClusterFinder: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DOLDDATA #-DNEWRECEIVER
|
||||
moenchClusterFinder: moench03ClusterFinder.cpp $(INCS) clean
|
||||
g++ -o moenchClusterFinder moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER
|
||||
|
||||
moenchMakeEta: moench03MakeEta.cpp $(INCS) clean
|
||||
g++ -o moenchMakeEta moench03MakeEta.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
moenchClusterFinderHighZ: moench03ClusterFinder.cpp $(INCS) clean
|
||||
g++ -o moenchClusterFinderHighZ moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER -DHIGHZ
|
||||
|
||||
|
||||
|
||||
|
||||
moenchMakeEta: moench03Interpolation.cpp $(INCS) clean
|
||||
g++ -o moenchMakeEta moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF
|
||||
|
||||
moenchInterpolation: moench03Interpolation.cpp $(INCS) clean
|
||||
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
|
||||
|
||||
moenchNoInterpolation: moench03NoInterpolation.cpp $(INCS) clean
|
||||
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
|
||||
|
||||
moenchPhotonCounter: moenchPhotonCounter.cpp $(INCS) clean
|
||||
g++ -o moenchPhotonCounter moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER
|
||||
g++ -o moenchPhotonCounter moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER
|
||||
|
||||
moenchAnalog: moenchPhotonCounter.cpp $(INCS) clean
|
||||
g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL -DNEWRECEIVER -DANALOG
|
||||
g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG
|
||||
|
||||
moenchPhotonCounterHighZ: moenchPhotonCounter.cpp $(INCS) clean
|
||||
g++ -o moenchPhotonCounterHighZ moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DHIGHZ
|
||||
|
||||
moenchAnalogHighZ: moenchPhotonCounter.cpp $(INCS) clean
|
||||
g++ -o moenchAnalogHighZ moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWRECEIVER -DANALOG -DHIGHZ
|
||||
|
||||
clean:
|
||||
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter
|
||||
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
|
||||
|
||||
|
||||
|
@ -0,0 +1,40 @@
|
||||
|
||||
#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/
|
||||
#LIBHDF5=
|
||||
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -ltiff
|
||||
#-L$(ZMQLIB) -lzmq -L$(CBFLIBDIR)/lib/
|
||||
#-L../../bin
|
||||
MAIN=moench03ClusterFinder.cpp
|
||||
#-lhdf5
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moenchClusterFinderRect moenchMakeEtaRect moenchInterpolationRect moenchNoInterpolationRect moenchPhotonCounterRect moenchAnalogRect
|
||||
|
||||
|
||||
|
||||
moenchClusterFinderRect: moench03ClusterFinder.cpp $(INCS) clean
|
||||
g++ -o moenchClusterFinderRect moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) -DSAVE_ALL -DNEWRECEIVER -DRECT
|
||||
|
||||
moenchMakeEtaRect: moench03Interpolation.cpp $(INCS) clean
|
||||
g++ -o moenchMakeEtaRect moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF -DRECT
|
||||
|
||||
moenchInterpolationRect: moench03Interpolation.cpp $(INCS) clean
|
||||
g++ -o moenchInterpolationRect moench03Interpolation.cpp $(LDFLAG) $(INCDIR) -DRECT
|
||||
|
||||
moenchNoInterpolationRect: moench03NoInterpolation.cpp $(INCS) clean
|
||||
g++ -o moenchNoInterpolationRect moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) -DRECT
|
||||
|
||||
moenchPhotonCounterRect: moenchPhotonCounter.cpp $(INCS) clean
|
||||
g++ -o moenchPhotonCounterRect moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $ -DNEWRECEIVER -DRECT
|
||||
|
||||
moenchAnalogRect: moenchPhotonCounter.cpp $(INCS) clean
|
||||
g++ -o moenchAnalogRect moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) -DNEWRECEIVER -DANALOG -DRECT
|
||||
|
||||
clean:
|
||||
rm -f moenchClusterFinderRect moenchMakeEtaRect moenchInterpolationRect moenchNoInterpolationRect moenchPhotonCounterRect moenchAnalogRect
|
||||
|
||||
|
@ -0,0 +1,40 @@
|
||||
|
||||
#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/
|
||||
#LIBHDF5=
|
||||
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -ltiff
|
||||
#-L$(ZMQLIB) -lzmq -L$(CBFLIBDIR)/lib/
|
||||
#-L../../bin
|
||||
MAIN=moench03ClusterFinder.cpp
|
||||
#-lhdf5
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
|
||||
|
||||
|
||||
|
||||
moenchClusterFinder : moench03ClusterFinder.cpp $(INCS) clean
|
||||
g++ -o moenchClusterFinder moench03ClusterFinder.cpp $(LDFLAG) $(INCDIR) -DSAVE_ALL -DNEWRECEIVER -DWRITE_QUAD
|
||||
|
||||
moenchMakeEta : moench03Interpolation.cpp $(INCS) clean
|
||||
g++ -o moenchMakeEta moench03Interpolation.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DFF -DWRITE_QUAD
|
||||
|
||||
moenchInterpolation : moench03Interpolation.cpp $(INCS) clean
|
||||
g++ -o moenchInterpolation moench03Interpolation.cpp $(LDFLAG) $(INCDIR) -DWRITE_QUAD
|
||||
|
||||
moenchNoInterpolation : moench03NoInterpolation.cpp $(INCS) clean
|
||||
g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) -DWRITE_QUAD
|
||||
|
||||
moenchPhotonCounter : moenchPhotonCounter.cpp $(INCS) clean
|
||||
g++ -o moenchPhotonCounter moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $ -DNEWRECEIVER -DWRITE_QUAD
|
||||
|
||||
moenchAnalog : moenchPhotonCounter.cpp $(INCS) clean
|
||||
g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) -DNEWRECEIVER -DANALOG -DWRITE_QUAD
|
||||
|
||||
clean:
|
||||
rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
|
||||
|
||||
|
@ -1,10 +1,15 @@
|
||||
#module add CBFlib/0.9.5
|
||||
INCDIR=-I. -I../ -I../interpolations -I../interpolations/etaVEL -I../dataStructures -I../../slsReceiverSoftware/include
|
||||
|
||||
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -pthread -lrt -ltiff -O3
|
||||
|
||||
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/
|
||||
#LIBHDF5=
|
||||
LDFLAG= ../tiffIO.cpp -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff
|
||||
#-L$(ZMQLIB) -lzmq
|
||||
#-L../../bin
|
||||
MAIN=moench03ClusterFinder.cpp
|
||||
|
||||
#-lhdf5
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog
|
||||
|
@ -1,20 +0,0 @@
|
||||
|
||||
CBFLIBDIR=/afs/psi.ch/project/sls_det_software/CBFlib-0.9.5
|
||||
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
INCDIR=-IslsDetectorCalibration -I../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -IetaVEL
|
||||
LIBHDF5=-L$(CBFLIBDIR)/lib/ -lhdf5
|
||||
LDFLAG= -L/usr/lib64/ -lpthread
|
||||
#-L../../bin
|
||||
MAIN=moench03OnTheFlyAnalysis.C
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moench03OnTheFlyAnalysis
|
||||
|
||||
|
||||
|
||||
moench03OnTheFlyAnalysis: $(MAIN) $(INCS) clean
|
||||
g++ -o moench03OnTheFlyAnalysis $(MAIN) -lm -ltiff -lstdc++ $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DSAVE_ALL
|
||||
|
||||
clean:
|
||||
rm -f moench03OnTheFlyAnalysis
|
@ -1,23 +0,0 @@
|
||||
|
||||
CBFLIBDIR= /home/l_msdetect/CBFlib-0.9.5
|
||||
ZMQLIB=../slsReceiverSoftware/include
|
||||
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
INCDIR=-IslsDetectorCalibration -I../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I.
|
||||
#-IetaVEL
|
||||
LIBHDF5=
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -L$(CBFLIBDIR)/lib/ -lhdf5 -ltiff -L$(ZMQLIB)
|
||||
#-L../../bin
|
||||
MAIN=moench03ClusterFinder.cpp
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moench03ClusterFinder
|
||||
|
||||
|
||||
|
||||
moench03ClusterFinder: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchClusterFinder $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) tiffIO.cpp -DSAVE_ALL
|
||||
|
||||
clean:
|
||||
rm -f moench03ClusterFinder
|
||||
|
@ -1,17 +0,0 @@
|
||||
|
||||
ZMQLIB=../../slsReceiverSoftware/include
|
||||
INCDIR= -I$(ZMQLIB) -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -L$(ZMQLIB) -O3 -g
|
||||
#-L../../bin -lhdf5 -L.
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moenchZmqProcess
|
||||
|
||||
moenchZmqProcess: moenchZmqProcess.cpp clean
|
||||
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP
|
||||
|
||||
clean:
|
||||
rm -f moenchZmqProcess
|
||||
|
||||
|
@ -1,12 +1,8 @@
|
||||
|
||||
CBFLIBDIR=/afs/psi.ch/project/sls_det_software/CBFlib-0.9.5
|
||||
CBFLIBDIR= /afs/psi.ch/project/sls_det_software/CBFlib-0.9.5/
|
||||
ZMQLIB=../../slsReceiverSoftware/include
|
||||
LIBRARYCBF=$(CBFLIBDIR)/lib/*.o
|
||||
INCDIR=-I../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/
|
||||
LIBHDF5=
|
||||
#-I../interpolations/etaVEL
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -lzmq -pthread -lrt -lhdf5 -ltiff -L$(ZMQLIB) -L$(CBFLIBDIR)/lib/ -O3
|
||||
#-L../../bin
|
||||
INCDIR= -I$(ZMQLIB) -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/ -I$(CBFLIBDIR)/include/
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -lrt -L$(CBFLIBDIR)/lib/ -ltiff -L$(ZMQLIB) -O3
|
||||
#-L../../bin -lhdf5 -L.
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
@ -14,7 +10,7 @@ aaa: moenchZmqProcess
|
||||
|
||||
all: moenchZmqClusterFinder moenchZmqInterpolating moenchZmqAnalog
|
||||
|
||||
moenchZmqProcess: moenchZmqProcess.cpp $(INCS) clean
|
||||
moenchZmqProcess: moenchZmqProcess.cpp clean
|
||||
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ
|
||||
|
||||
moenchZmqInterpolating: $(MAIN) $(INCS) clean
|
@ -1,24 +0,0 @@
|
||||
|
||||
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../../slsReceiverSoftware/include -I$(CBFLIBDIR)/include/ ../tiffIO.cpp -I../dataStructures
|
||||
#LIBHDF5=
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -L$(CBFLIBDIR)/lib/ -ltiff -lhdf5
|
||||
#-L$(ZMQLIB) -lzmq
|
||||
#-L../../bin
|
||||
MAIN=moench03ClusterFinderPhoenix.cpp
|
||||
#
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moenchClusterFinderPhoenix
|
||||
#moenchMakeEtaPhoenix moenchInterpolationPhoenix
|
||||
|
||||
|
||||
|
||||
moenchClusterFinderPhoenix: $(MAIN) $(INCS) clean
|
||||
g++ -o moenchClusterFinderPhoenix $(MAIN) $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF)
|
||||
|
||||
clean:
|
||||
rm -f moenchClusterFinderPhoenix
|
||||
|
@ -1,22 +0,0 @@
|
||||
|
||||
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
|
||||
|
||||
|
@ -1,27 +0,0 @@
|
||||
#INCSROOT= receiverGui.h
|
||||
#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$(ROOTSYS)/include
|
||||
#-I$(CBFLIBDIR)/include/
|
||||
#LIBHDF5=
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -L. -pthread -lrt -ltiff
|
||||
#-L$(CBFLIBDIR)/lib/ -lhdf5
|
||||
|
||||
MAIN=tiff_to_th2f.cpp
|
||||
|
||||
|
||||
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) ../tiffIO.cpp
|
||||
#$(LIBRARYCBF) $(LIBHDF5)
|
||||
clean:
|
||||
rm -f tiff_to_th2f
|
||||
|
24
slsDetectorCalibration/moenchExecutables/Makefile.zmq
Normal file
24
slsDetectorCalibration/moenchExecutables/Makefile.zmq
Normal file
@ -0,0 +1,24 @@
|
||||
|
||||
INCDIR= -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/ -I../../slsDetectorSoftware/commonFiles/ -I../../slsReceiverSoftware/include/
|
||||
LDFLAG= -L/usr/lib64/ -lpthread -lm -lstdc++ -lzmq -pthread -lrt -ltiff -O3 -g -std=c++11 -Wall
|
||||
#-L../../bin -lhdf5 -L.
|
||||
|
||||
#DESTDIR?=../bin
|
||||
|
||||
all: moenchZmqProcess moenchZmqProcessHighZ moenchZmqProcessRect
|
||||
|
||||
moenchZmqProcess: moenchZmqProcess.cpp clean
|
||||
g++ -o moenchZmqProcess moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP
|
||||
moenchZmqProcessRect: moenchZmqProcess.cpp clean
|
||||
g++ -o moenchZmqProcessRect moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DRECT
|
||||
|
||||
moenchZmqProcessHighZ: moenchZmqProcess.cpp clean
|
||||
g++ -o moenchZmqProcessHighZ moenchZmqProcess.cpp $(LDFLAG) $(INCDIR) $(LIBHDF5) $(LIBRARYCBF) -DNEWZMQ -DINTERP -DHIGHZ
|
||||
|
||||
|
||||
|
||||
clean:
|
||||
rm -f moenchZmqProcess moenchZmqProcessHighZ
|
||||
|
||||
|
||||
|
@ -22,6 +22,10 @@
|
||||
#include "moench03Ctb10GbT1Data.h"
|
||||
#endif
|
||||
|
||||
#ifdef REORDERED
|
||||
#include "moench03T1ReorderedData.h"
|
||||
#endif
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
@ -48,14 +52,14 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=24;
|
||||
int nthreads=1;
|
||||
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 nsigma=1;
|
||||
int nped=1000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
@ -83,6 +87,14 @@ int main(int argc, char *argv[]) {
|
||||
cout << "OLD RECEIVER DATA!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef REORDERED
|
||||
moench03T1ReorderedData *decoder=new moench03T1ReorderedData();
|
||||
cout << "REORDERED DATA!"<<endl;
|
||||
#endif
|
||||
|
||||
|
||||
decoder->getDetectorSize(nx,ny);
|
||||
cout << "nx " << nx << " ny " << ny << endl;
|
||||
|
||||
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
|
||||
@ -183,13 +195,21 @@ int main(int argc, char *argv[]) {
|
||||
// cout << "*"<<ifr++<<"*"<<ff<< endl;
|
||||
// cout << ff << " " << np << endl;
|
||||
// //push
|
||||
mt->pushData(buff);
|
||||
// // //pop
|
||||
mt->nextThread();
|
||||
// // // cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
ifr++;
|
||||
if (ifr%10000==0) cout << ifr << " " << ff << endl;
|
||||
// for (int ix=0; ix<400; ix++)
|
||||
// for (int iy=0; iy<400; iy++) {
|
||||
// if (decoder->getChannel(buff, ix, iy)<3000 || decoder->getChannel(buff, ix, iy)>8000) {
|
||||
// cout << ifr << " " << ff << " " << ix << " " << iy << " " << decoder->getChannel(buff, ix, iy) << endl ;
|
||||
// }
|
||||
// }
|
||||
if (np==40) {
|
||||
mt->pushData(buff);
|
||||
// // //pop
|
||||
mt->nextThread();
|
||||
// // // cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
ifr++;
|
||||
if (ifr%10000==0) cout << ifr << " " << ff << endl;
|
||||
}
|
||||
ff=-1;
|
||||
}
|
||||
cout << "--" << endl;
|
||||
|
@ -1,201 +0,0 @@
|
||||
//#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
//#include "moench03T1ReceiverData.h"
|
||||
|
||||
#include "moench03Ctb10GbT1Data.h"
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ctime>
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
if (argc<6) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname runmin runmax " << endl;
|
||||
return 0;
|
||||
}
|
||||
int ii=0;
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=5;
|
||||
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;
|
||||
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
|
||||
cout << "decoder" << endl;
|
||||
//moench03T1ReceiverData *decoder=new moench03T1ReceiverData();
|
||||
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 100);
|
||||
// char tit[10000];
|
||||
cout << "filter" << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
cout << "dataset" << endl;
|
||||
|
||||
int ff, np;
|
||||
int dsize=decoder->getDataSize();
|
||||
cout << " data size is " << dsize << endl;
|
||||
|
||||
|
||||
char data[dsize];
|
||||
|
||||
ifstream filebin;
|
||||
char *indir=argv[1];
|
||||
cout << "input directory is " << indir << endl;
|
||||
char *outdir=argv[2];
|
||||
cout << "output directory is " << outdir << endl;
|
||||
char *fformat=argv[3];
|
||||
cout << "fileformat is " << fformat << endl;
|
||||
int runmin=atoi(argv[4]);
|
||||
cout << "runmin : " << runmin << endl;
|
||||
int runmax=atoi(argv[5]);
|
||||
cout << "runmax : " << runmax << endl;
|
||||
|
||||
char fname[10000];
|
||||
char outfname[10000];
|
||||
char imgfname[10000];
|
||||
char pedfname[10000];
|
||||
char fn[10000];
|
||||
|
||||
std::time_t end_time;
|
||||
|
||||
FILE *of=NULL;
|
||||
|
||||
|
||||
cout << "time " << endl;
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
filter->setFrameMode(eFrame);
|
||||
// mt->setFrameMode(ePedestal);
|
||||
|
||||
|
||||
// for (int ix=0; ix<400; ix++)
|
||||
// for (int iy=0; iy<400; iy++)
|
||||
// cout << ix << " " << iy << " " << filter->getPedestal(ix,iy) << " " << filter->getPedestalRMS(ix,iy) << endl;
|
||||
|
||||
|
||||
char* buff;
|
||||
cout << "aa " << endl;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
cout << "mt " << endl;
|
||||
|
||||
// mt->setFrameMode(eFrame); //need to find a way to switch between flat and frames!
|
||||
// mt->prepareInterpolation(ok);
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
|
||||
int ifr=0;
|
||||
// //loop on files
|
||||
// mt->setFrameMode(eFrame);
|
||||
//mt->setFrameMode(eFlat);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (int irun=runmin; irun<runmax; irun++) {
|
||||
sprintf(fn,fformat,irun);
|
||||
sprintf(fname,"%s/%s.raw",indir,fn);
|
||||
sprintf(outfname,"%s/%s.clust",outdir,fn);
|
||||
sprintf(imgfname,"%s/%s.tiff",outdir,fn);
|
||||
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) {
|
||||
mt->setFilePointer(of);
|
||||
// cout << "file pointer set " << endl;
|
||||
} else {
|
||||
cout << "Could not open "<< outfname << " for writing " << endl;
|
||||
mt->setFilePointer(NULL);
|
||||
return 1;
|
||||
}
|
||||
// //while read frame
|
||||
ff=-1;
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
//cout << "*"<<ifr++<<"*"<<ff<< endl;
|
||||
//cout << ff << " " << np << endl;
|
||||
// //push
|
||||
mt->pushData(buff);
|
||||
// // //pop
|
||||
mt->nextThread();
|
||||
// // // cout << " " << (void*)buff;
|
||||
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();
|
||||
// //close file
|
||||
// //join threads
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
if (of)
|
||||
fclose(of);
|
||||
|
||||
mt->writeImage(imgfname);
|
||||
mt->clearImage();
|
||||
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
} else
|
||||
cout << "Could not open "<< fname << " for reading " << endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -0,0 +1,245 @@
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
//#define DOUBLE_SPH
|
||||
//#define MANYFILES
|
||||
|
||||
#ifdef DOUBLE_SPH
|
||||
#include "single_photon_hit_double.h"
|
||||
#endif
|
||||
|
||||
#ifndef DOUBLE_SPH
|
||||
#include "single_photon_hit.h"
|
||||
#endif
|
||||
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
#include "slsInterpolation.h"
|
||||
#include "Stat.h"
|
||||
//#include "etaInterpolationRandomBins.h"
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
#define MAX_EBINS 100
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
if (argc<7) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile outfile runmin runmax cmin cmax nb" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int iarg=4;
|
||||
char infname[10000];
|
||||
char fname[10000];
|
||||
char outfname[10000];
|
||||
|
||||
float img[NC*NR];
|
||||
iarg=3;
|
||||
|
||||
int runmin=atoi(argv[iarg++]);
|
||||
int runmax=atoi(argv[iarg++]);
|
||||
cout << "Run min: " << runmin << endl;
|
||||
cout << "Run max: " << runmax << endl;
|
||||
|
||||
|
||||
float cmin=atof(argv[iarg++]);
|
||||
float cmax=atof(argv[iarg++]);
|
||||
cout << "Energy min: " << cmin << endl;
|
||||
cout << "Energy max: " << cmax << endl;
|
||||
int n_ebins=1;
|
||||
if (argc>iarg)
|
||||
n_ebins=atoi(argv[iarg++]);
|
||||
//int etabins=500;
|
||||
int etabins=1000;//nsubpix*2*100;
|
||||
double etamin=-1, etamax=2;
|
||||
//double etamin=-0.1, etamax=1.1;
|
||||
double eta3min=-2, eta3max=2;
|
||||
int quad;
|
||||
double sum, totquad;
|
||||
double sDum[2][2];
|
||||
double etax, etay, int_x, int_y;
|
||||
double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y;
|
||||
int ok;
|
||||
int f0=-1;
|
||||
int ix, iy, isx, isy;
|
||||
int nframes=0, lastframe=-1;
|
||||
double d_x, d_y, res=5, xx, yy;
|
||||
int nph=0, badph=0, totph=0;
|
||||
FILE *f=NULL;
|
||||
|
||||
single_photon_hit cl(3,3);
|
||||
|
||||
|
||||
int iebin=0;
|
||||
double eb_size=(cmax-cmin)/n_ebins;
|
||||
|
||||
Stat *statsX=new Stat[(n_ebins+1)*NC*NR];
|
||||
Stat *statsY=new Stat[(n_ebins+1)*NC*NR];
|
||||
|
||||
|
||||
int irun;
|
||||
for (irun=runmin; irun<runmax; irun++) {
|
||||
sprintf(infname,argv[1],irun);
|
||||
|
||||
f=fopen(infname,"r");
|
||||
if (f) {
|
||||
cout << infname << endl;
|
||||
nframes=0;
|
||||
f0=-1;
|
||||
|
||||
while (cl.read(f)) {
|
||||
totph++;
|
||||
if (lastframe!=cl.iframe) {
|
||||
lastframe=cl.iframe;
|
||||
// cout << cl.iframe << endl;
|
||||
// f0=cl.iframe;
|
||||
if (nframes==0) f0=lastframe;
|
||||
nframes++;
|
||||
}
|
||||
slsInterpolation::calcEta(cl.get_cluster(), etax, etay, sum, totquad, sDum);
|
||||
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && sum<cmax ) {
|
||||
nph++;
|
||||
iebin=(sum-cmin)/eb_size;
|
||||
if (iebin>=0 && iebin<n_ebins && cl.x>=0 && cl.x<NC && cl.y>=0 && cl.y<NR) {
|
||||
statsX[iebin+cl.x*(n_ebins+1)+cl.y*(NC*(n_ebins+1))].Push(etax);
|
||||
statsY[iebin+cl.x*(n_ebins+1)+cl.y*(NC*(n_ebins+1))].Push(etay);
|
||||
statsX[n_ebins+cl.x*(n_ebins+1)+cl.y*(NC*(n_ebins+1))].Push(etax);
|
||||
statsY[n_ebins+cl.x*(n_ebins+1)+cl.y*(NC*(n_ebins+1))].Push(etay);
|
||||
}
|
||||
|
||||
if (nph%1000000==0) cout << nph << endl;
|
||||
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
} else
|
||||
cout << "could not open file " << infname << endl;
|
||||
|
||||
for (int ien=0; ien<n_ebins+1; ien++) {
|
||||
sprintf(outfname,"%s_abs_energy%d.tiff",argv[2],ien);
|
||||
for (int iy=0; iy<NR; iy++) {
|
||||
for (int ix=0; ix<NC; ix++) {
|
||||
img[ix+NC*iy]= statsX[ien+ix*(n_ebins+1)+iy*(NC*(n_ebins+1))].NumDataValues();
|
||||
}
|
||||
}
|
||||
WriteToTiff(img, outfname, NR, NC);
|
||||
}
|
||||
|
||||
|
||||
for (int ien=0; ien<n_ebins+1; ien++) {
|
||||
sprintf(outfname,"%s_etameanX_energy%d.tiff",argv[2],ien);
|
||||
for (int iy=0; iy<NR; iy++) {
|
||||
for (int ix=0; ix<NC; ix++) {
|
||||
img[ix+NC*iy]= statsX[ien+ix*(n_ebins+1)+iy*(NC*(n_ebins+1))].Mean();
|
||||
}
|
||||
}
|
||||
WriteToTiff(img, outfname, NR, NC);
|
||||
}
|
||||
|
||||
|
||||
for (int ien=0; ien<n_ebins+1; ien++) {
|
||||
sprintf(outfname,"%s_etarmsX_energy%d.tiff",argv[2],ien);
|
||||
for (int iy=0; iy<NR; iy++) {
|
||||
for (int ix=0; ix<NC; ix++) {
|
||||
img[ix+NC*iy]= statsX[ien+ix*(n_ebins+1)+iy*(NC*(n_ebins+1))].StandardDeviation();
|
||||
}
|
||||
}
|
||||
WriteToTiff(img, outfname, NR, NC);
|
||||
}
|
||||
|
||||
|
||||
for (int ien=0; ien<n_ebins+1; ien++) {
|
||||
sprintf(outfname,"%s_etameanY_energy%d.tiff",argv[2],ien);
|
||||
for (int iy=0; iy<NR; iy++) {
|
||||
for (int ix=0; ix<NC; ix++) {
|
||||
img[ix+NC*iy]= statsY[ien+ix*(n_ebins+1)+iy*(NC*(n_ebins+1))].Mean();
|
||||
}
|
||||
}
|
||||
WriteToTiff(img, outfname, NR, NC);
|
||||
}
|
||||
|
||||
|
||||
for (int ien=0; ien<n_ebins+1; ien++) {
|
||||
sprintf(outfname,"%s_etarmsY_energy%d.tiff",argv[2],ien);
|
||||
for (int iy=0; iy<NR; iy++) {
|
||||
for (int ix=0; ix<NC; ix++) {
|
||||
img[ix+NC*iy]= statsY[ien+ix*(n_ebins+1)+iy*(NC*(n_ebins+1))].StandardDeviation();
|
||||
}
|
||||
}
|
||||
WriteToTiff(img, outfname, NR, NC);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (int ien=0; ien<n_ebins+1; ien++) {
|
||||
sprintf(outfname,"%s_abs_energy%d.tiff",argv[2],ien);
|
||||
for (int iy=0; iy<NR; iy++) {
|
||||
for (int ix=0; ix<NC; ix++) {
|
||||
img[ix+NC*iy]= statsX[ien+ix*(n_ebins+1)+iy*(NC*(n_ebins+1))].NumDataValues();
|
||||
}
|
||||
}
|
||||
WriteToTiff(img, outfname, NR, NC);
|
||||
}
|
||||
|
||||
|
||||
for (int ien=0; ien<n_ebins+1; ien++) {
|
||||
sprintf(outfname,"%s_etameanX_energy%d.tiff",argv[2],ien);
|
||||
for (int iy=0; iy<NR; iy++) {
|
||||
for (int ix=0; ix<NC; ix++) {
|
||||
img[ix+NC*iy]= statsX[ien+ix*(n_ebins+1)+iy*(NC*(n_ebins+1))].Mean();
|
||||
}
|
||||
}
|
||||
WriteToTiff(img, outfname, NR, NC);
|
||||
}
|
||||
|
||||
|
||||
for (int ien=0; ien<n_ebins+1; ien++) {
|
||||
sprintf(outfname,"%s_etarmsX_energy%d.tiff",argv[2],ien);
|
||||
for (int iy=0; iy<NR; iy++) {
|
||||
for (int ix=0; ix<NC; ix++) {
|
||||
img[ix+NC*iy]= statsX[ien+ix*(n_ebins+1)+iy*(NC*(n_ebins+1))].StandardDeviation();
|
||||
}
|
||||
}
|
||||
WriteToTiff(img, outfname, NR, NC);
|
||||
}
|
||||
|
||||
|
||||
|
||||
for (int ien=0; ien<n_ebins+1; ien++) {
|
||||
sprintf(outfname,"%s_etameanY_energy%d.tiff",argv[2],ien);
|
||||
for (int iy=0; iy<NR; iy++) {
|
||||
for (int ix=0; ix<NC; ix++) {
|
||||
img[ix+NC*iy]= statsY[ien+ix*(n_ebins+1)+iy*(NC*(n_ebins+1))].Mean();
|
||||
}
|
||||
}
|
||||
WriteToTiff(img, outfname, NR, NC);
|
||||
}
|
||||
|
||||
|
||||
for (int ien=0; ien<n_ebins+1; ien++) {
|
||||
sprintf(outfname,"%s_etarmsY_energy%d.tiff",argv[2],ien);
|
||||
for (int iy=0; iy<NR; iy++) {
|
||||
for (int ix=0; ix<NC; ix++) {
|
||||
img[ix+NC*iy]= statsY[ien+ix*(n_ebins+1)+iy*(NC*(n_ebins+1))].StandardDeviation();
|
||||
}
|
||||
}
|
||||
WriteToTiff(img, outfname, NR, NC);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
cout << "Filled " << nph << " (/"<< totph <<") " << endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -14,13 +14,26 @@
|
||||
#include "single_photon_hit.h"
|
||||
#endif
|
||||
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
#ifdef RECT
|
||||
#include "etaInterpolationGlobal.h"
|
||||
#endif
|
||||
#ifndef RECT
|
||||
#include "etaInterpolationPosXY.h"
|
||||
#endif
|
||||
#include "noInterpolation.h"
|
||||
#include "etaInterpolationCleverAdaptiveBins.h"
|
||||
//#include "etaInterpolationCleverAdaptiveBins.h"
|
||||
//#include "etaInterpolationRandomBins.h"
|
||||
using namespace std;
|
||||
#ifndef RECT
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
#endif
|
||||
#ifdef RECT
|
||||
#define NC 200
|
||||
#define NR 800
|
||||
#endif
|
||||
|
||||
|
||||
#define MAX_ITERATIONS (nSubPixels*100)
|
||||
|
||||
#define XTALK
|
||||
@ -28,6 +41,7 @@ using namespace std;
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
#ifndef FF
|
||||
cout << "INTERPOLATING" << endl;
|
||||
if (argc<9) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile outfile runmin runmax ns cmin cmax" << endl;
|
||||
return 1;
|
||||
@ -35,6 +49,7 @@ int main(int argc, char *argv[]) {
|
||||
#endif
|
||||
|
||||
#ifdef FF
|
||||
cout << "CALC ETA" << endl;
|
||||
if (argc<7) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile runmin runmax cmin cmax" << endl;
|
||||
return 1;
|
||||
@ -66,10 +81,11 @@ int main(int argc, char *argv[]) {
|
||||
cout << "Energy min: " << cmin << endl;
|
||||
cout << "Energy max: " << cmax << endl;
|
||||
//int etabins=500;
|
||||
int etabins=1000;//nsubpix*2*100;
|
||||
double etamin=-1, etamax=2;
|
||||
int etabins=999;//nsubpix*2*100;
|
||||
int etabinsY=etabins;//nsubpix*2*100;
|
||||
double etamin=0, etamax=1;
|
||||
//double etamin=-0.1, etamax=1.1;
|
||||
double eta3min=-2, eta3max=2;
|
||||
double eta3min=-1, eta3max=1;
|
||||
int quad;
|
||||
double sum, totquad;
|
||||
double sDum[2][2];
|
||||
@ -83,6 +99,9 @@ int main(int argc, char *argv[]) {
|
||||
int nph=0, badph=0, totph=0;
|
||||
FILE *f=NULL;
|
||||
|
||||
|
||||
char fff[10000];
|
||||
|
||||
#ifdef DOUBLE_SPH
|
||||
single_photon_hit_double cl(3,3);
|
||||
#endif
|
||||
@ -90,14 +109,29 @@ int main(int argc, char *argv[]) {
|
||||
#ifndef DOUBLE_SPH
|
||||
single_photon_hit cl(3,3);
|
||||
#endif
|
||||
|
||||
int nSubPixels=nsubpix;
|
||||
int nSubPixelsY=nsubpix;
|
||||
#ifdef RECT
|
||||
nSubPixels=5; //might make more sense using 2?
|
||||
// etabins=5;
|
||||
#endif
|
||||
#ifndef NOINTERPOLATION
|
||||
eta2InterpolationPosXY *interp=new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
etaInterpolationBase *interp;
|
||||
#ifndef RECT
|
||||
interp=new eta2InterpolationPosXY(NC, NR, nSubPixels, nSubPixelsY, etabins, etabinsY, etamin, etamax);
|
||||
//eta2InterpolationCleverAdaptiveBins *interp=new eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
#endif
|
||||
#ifdef RECT
|
||||
interp=new eta2InterpolationGlobal(NC, NR, nSubPixels, nSubPixelsY, etabins, etabinsY, eta3min, eta3max);
|
||||
|
||||
// eta3InterpolationPosXY *interpOdd=new eta3InterpolationPosXY(NC, NR, nSubPixels, nSubPixelsY, etabins, etabinsY, eta3min, eta3max);
|
||||
//eta2InterpolationCleverAdaptiveBins *interp=new eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#ifdef NOINTERPOLATION
|
||||
noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
noInterpolation *interp=new noInterpolation(NC, NR, nsubpix, nSubPixelsY);
|
||||
#endif
|
||||
|
||||
|
||||
@ -106,8 +140,21 @@ int main(int argc, char *argv[]) {
|
||||
#ifndef NOINTERPOLATION
|
||||
cout << "read ff " << argv[2] << endl;
|
||||
sprintf(fname,"%s",argv[2]);
|
||||
interp->readFlatField(fname);
|
||||
//#ifndef RECT
|
||||
interp->readFlatField(fname, etamin, etamax);
|
||||
interp->prepareInterpolation(ok);//, MAX_ITERATIONS);
|
||||
interp->debugSaveAll(0);
|
||||
//#endif
|
||||
// #ifdef RECT
|
||||
// sprintf(fff,"%s.even",fname);
|
||||
// interpEven->readFlatField(fff, etamin, etamax);
|
||||
// interpEven->prepareInterpolation(ok);, MAX_ITERATIONS);
|
||||
// interpEven->debugSaveAll(1);
|
||||
// sprintf(fff,"%s.odd",fname);
|
||||
// interpOdd->readFlatField(fff, etamin, etamax);
|
||||
// interpOdd->prepareInterpolation(ok);, MAX_ITERATIONS);
|
||||
// interpOdd->debugSaveAll(2);
|
||||
// #endif
|
||||
#endif
|
||||
// return 0;
|
||||
#endif
|
||||
@ -116,12 +163,12 @@ int main(int argc, char *argv[]) {
|
||||
#endif
|
||||
|
||||
int *img;
|
||||
float *totimg=new float[NC*NR*nsubpix*nsubpix];
|
||||
float *totimg=new float[NC*NR*nSubPixels*nSubPixelsY];
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR; iy++) {
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]=0;
|
||||
for (isx=0; isx<nSubPixels; isx++) {
|
||||
for (isy=0; isy<nSubPixelsY; isy++) {
|
||||
totimg[ix*nSubPixels+isx+(iy*nSubPixelsY+isy)*(NC*nSubPixels)]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,6 +177,9 @@ int main(int argc, char *argv[]) {
|
||||
#ifdef FF
|
||||
sprintf(outfname,argv[2]);
|
||||
#endif
|
||||
|
||||
|
||||
int tl=0, tr=0, bl=0, br=0;
|
||||
|
||||
int irun;
|
||||
for (irun=runmin; irun<runmax; irun++) {
|
||||
@ -148,59 +198,83 @@ int main(int argc, char *argv[]) {
|
||||
totph++;
|
||||
if (lastframe!=cl.iframe) {
|
||||
lastframe=cl.iframe;
|
||||
// cout << cl.iframe << endl;
|
||||
// f0=cl.iframe;
|
||||
if (nframes==0) f0=lastframe;
|
||||
nframes++;
|
||||
}
|
||||
//quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
||||
#ifdef RECT
|
||||
// quad=interp->calcEta3(cl.get_cluster(), etax, etay, sum);
|
||||
quad=interp->calcEta(cl.get_cluster(), etax, etay, sum, totquad, sDum);
|
||||
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && sum<cmax ) {
|
||||
nph++;
|
||||
// if (sum>200 && sum<580) {
|
||||
// interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y);
|
||||
// #ifdef SOLEIL
|
||||
// if (cl.x>210 && cl.x<240 && cl.y>210 && cl.y<240) {
|
||||
// #endif
|
||||
#ifndef FF
|
||||
// interp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y);
|
||||
interp->getInterpolatedPosition(cl.x,cl.y, etax, etay, quad,int_x, int_y);
|
||||
// cout <<"**************"<< endl;
|
||||
// cout << cl.x << " " << cl.y << " " << sum << endl;
|
||||
// cl.print();
|
||||
// cout << int_x << " " << int_y << endl;
|
||||
// cout <<"**************"<< endl;
|
||||
// if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
|
||||
// if (cl.y%2==0)
|
||||
// if (etay>0)
|
||||
// interp=interpEven;
|
||||
// else
|
||||
// interp=interpOdd;
|
||||
// else
|
||||
// if (etay>0)
|
||||
// interp=interpOdd;
|
||||
// else
|
||||
// interp=interpEven;
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef RECT
|
||||
quad=interp->calcEta(cl.get_cluster(), etax, etay, sum, totquad, sDum);
|
||||
|
||||
|
||||
#endif
|
||||
switch(quad) {
|
||||
case TOP_LEFT:
|
||||
tl++;
|
||||
break;
|
||||
case TOP_RIGHT:
|
||||
tr++;
|
||||
break;
|
||||
case BOTTOM_LEFT:
|
||||
bl++;
|
||||
break;
|
||||
case BOTTOM_RIGHT:
|
||||
br++;
|
||||
break;
|
||||
}
|
||||
// if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && sum<cmax ) {
|
||||
if (sum>cmin && sum<cmax ) {
|
||||
nph++;
|
||||
#ifndef FF
|
||||
interp->getInterpolatedPosition(cl.x,cl.y, etax, etay, quad,int_x, int_y);
|
||||
interp->addToImage(int_x, int_y);
|
||||
if (int_x<0 || int_y<0 || int_x>400 || int_y>400) {
|
||||
cout <<"**************"<< endl;
|
||||
cout << cl.x << " " << cl.y << " " << sum << endl;
|
||||
cl.print();
|
||||
cout << int_x << " " << int_y << endl;
|
||||
cout <<"**************"<< endl;
|
||||
}
|
||||
#endif
|
||||
#ifdef FF
|
||||
// interp->addToFlatField(cl.get_cluster(), etax, etay);
|
||||
// #ifdef UCL
|
||||
// if (cl.x>50)
|
||||
// #endif
|
||||
// if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
|
||||
interp->addToFlatField(etax, etay);
|
||||
// if (etax==0 || etay==0) cout << cl.x << " " << cl.y << endl;
|
||||
|
||||
#endif
|
||||
// #ifdef SOLEIL
|
||||
// }
|
||||
// #endif
|
||||
|
||||
if (nph%1000000==0) cout << nph << endl;
|
||||
if (nph%10000000==0) {
|
||||
#ifndef FF
|
||||
interp->writeInterpolatedImage(outfname);
|
||||
|
||||
cout << "writing interpolated iamge" << endl;
|
||||
//#ifndef RECT
|
||||
interp->writeInterpolatedImage(outfname);
|
||||
//#endif
|
||||
// #ifdef RECT
|
||||
// sprintf(fff,"%s.even",outfname);
|
||||
// interpEven->writeInterpolatedImage(fff);
|
||||
// sprintf(fff,"%s.odd",outfname);
|
||||
// interpOdd->writeInterpolatedImage(fff);
|
||||
// #endif
|
||||
cout << "done" << endl;
|
||||
#endif
|
||||
#ifdef FF
|
||||
interp->writeFlatField(outfname);
|
||||
cout << "writing eta" << endl;
|
||||
//#ifndef RECT
|
||||
interp->writeFlatField(outfname);
|
||||
//#endif
|
||||
// #ifdef RECT
|
||||
// sprintf(fff,"%s.even",outfname);
|
||||
// interpEven->writeFlatField(fff);
|
||||
// sprintf(fff,"%s.odd",outfname);
|
||||
// interpOdd->writeFlatField(fff);
|
||||
// #endif
|
||||
cout << "done" << endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
@ -211,24 +285,64 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
fclose(f);
|
||||
#ifdef FF
|
||||
//#ifndef RECT
|
||||
interp->writeFlatField(outfname);
|
||||
// #endif
|
||||
// #ifdef RECT
|
||||
// sprintf(fff,"%s.even",outfname);
|
||||
// interpEven->writeFlatField(outfname);
|
||||
// sprintf(fff,"%s.odd",outfname);
|
||||
// interpOdd->writeFlatField(outfname);
|
||||
// #endif
|
||||
#endif
|
||||
|
||||
#ifndef FF
|
||||
//#ifndef RECT
|
||||
interp->writeInterpolatedImage(outfname);
|
||||
// #endif
|
||||
// #ifdef RECT
|
||||
// sprintf(fff,"%s.even",outfname);
|
||||
// interpEven->writeInterpolatedImage(fff);
|
||||
// sprintf(fff,"%s.odd",outfname);
|
||||
// interpOdd->writeInterpolatedImage(fff);
|
||||
// #endif
|
||||
|
||||
//#ifdef RECT
|
||||
//interp=interpEven;
|
||||
//#endif
|
||||
img=interp->getInterpolatedImage();
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR; iy++) {
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]+=img[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)];
|
||||
for (isx=0; isx<nSubPixels; isx++) {
|
||||
for (isy=0; isy<nSubPixelsY; isy++) {
|
||||
totimg[ix*nSubPixels+isx+(iy*nSubPixelsY+isy)*(NC*nSubPixels)]+=img[ix*nSubPixels+isx+(iy*nSubPixelsY+isy)*(NC*nSubPixels)];
|
||||
// cout << "--" << ix << " " << iy <<" " << ix*nSubPixels+isx+(iy*nSubPixelsY+isy)*(NC*nSubPixels) << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cout << "Read " << nframes << " frames (first frame: " << f0 << " last frame: " << lastframe << " delta:" << lastframe-f0 << ") nph="<< nph <<endl;
|
||||
cout << "Top-Left=" << tl << " " << " Top-Right=" << tr << " Bottom-Left="<< bl << " Bottom-Right=" << br << endl;
|
||||
interp->clearInterpolatedImage();
|
||||
// #ifdef RECT
|
||||
|
||||
// interp=interpOdd;
|
||||
// img=interp->getInterpolatedImage();
|
||||
// for (ix=0; ix<NC; ix++) {
|
||||
// for (iy=0; iy<NR; iy++) {
|
||||
// for (isx=0; isx<nSubPixels; isx++) {
|
||||
// for (isy=0; isy<nSubPixelsY; isy++) {
|
||||
// totimg[ix*nSubPixels+isx+(iy*nSubPixelsY+isy)*(NC*nSubPixels)]+=img[ix*nSubPixels+isx+(iy*nSubPixelsY+isy)*(NC*nSubPixels)];
|
||||
// // cout << "--" << ix << " " << iy <<" " << ix*nSubPixels+isx+(iy*nSubPixelsY+isy)*(NC*nSubPixels) << endl;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// interp->clearInterpolatedImage();
|
||||
// #endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
} else
|
||||
@ -236,11 +350,19 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
#ifndef FF
|
||||
sprintf(outfname,argv[3],11111);
|
||||
WriteToTiff(totimg, outfname,NC*nsubpix,NR*nsubpix);
|
||||
WriteToTiff(totimg, outfname,NC*nSubPixels,NR*nSubPixelsY);
|
||||
#endif
|
||||
|
||||
#ifdef FF
|
||||
//#ifndef RECT
|
||||
interp->writeFlatField(outfname);
|
||||
//#endif
|
||||
// #ifdef RECT
|
||||
// sprintf(fff,"%s.even",outfname);
|
||||
// interpEven->writeFlatField(fff);
|
||||
// sprintf(fff,"%s.odd",outfname);
|
||||
// interpOdd->writeFlatField(fff);
|
||||
// #endif
|
||||
#endif
|
||||
|
||||
cout << "Filled " << nph << " (/"<< totph <<") " << endl;
|
||||
|
@ -1,269 +0,0 @@
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
//#define DOUBLE_SPH
|
||||
//#define MANYFILES
|
||||
|
||||
#ifdef DOUBLE_SPH
|
||||
#include "single_photon_hit_double.h"
|
||||
#endif
|
||||
|
||||
#ifndef DOUBLE_SPH
|
||||
#include "single_photon_hit.h"
|
||||
#endif
|
||||
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
#include "noInterpolation.h"
|
||||
#include "etaInterpolationCleverAdaptiveBins.h"
|
||||
//#include "etaInterpolationRandomBins.h"
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
#define MAX_ITERATIONS (nSubPixels*100)
|
||||
#define MAX_EBINS 100
|
||||
#define XTALK
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
#ifndef FF
|
||||
if (argc<9) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile outfile runmin runmax ns cmin cmax" << endl;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FF
|
||||
if (argc<7) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile etafile runmin runmax cmin cmax" << endl;
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
int iarg=4;
|
||||
char infname[10000];
|
||||
char fname[10000];
|
||||
char outfname[10000];
|
||||
#ifndef FF
|
||||
iarg=4;
|
||||
#endif
|
||||
|
||||
#ifdef FF
|
||||
iarg=3;
|
||||
#endif
|
||||
int runmin=atoi(argv[iarg++]);
|
||||
int runmax=atoi(argv[iarg++]);
|
||||
cout << "Run min: " << runmin << endl;
|
||||
cout << "Run max: " << runmax << endl;
|
||||
|
||||
int nsubpix=4;
|
||||
#ifndef FF
|
||||
nsubpix=atoi(argv[iarg++]);
|
||||
cout << "Subpix: " << nsubpix << endl;
|
||||
#endif
|
||||
float cmin=atof(argv[iarg++]);
|
||||
float cmax=atof(argv[iarg++]);
|
||||
cout << "Energy min: " << cmin << endl;
|
||||
cout << "Energy max: " << cmax << endl;
|
||||
int n_ebins=1;
|
||||
if (argc>iarg)
|
||||
n_ebins=atoi(argv[iarg++]);
|
||||
//int etabins=500;
|
||||
int etabins=1000;//nsubpix*2*100;
|
||||
double etamin=-1, etamax=2;
|
||||
//double etamin=-0.1, etamax=1.1;
|
||||
double eta3min=-2, eta3max=2;
|
||||
int quad;
|
||||
double sum, totquad;
|
||||
double sDum[2][2];
|
||||
double etax, etay, int_x, int_y;
|
||||
double eta3x, eta3y, int3_x, int3_y, noint_x, noint_y;
|
||||
int ok;
|
||||
int f0=-1;
|
||||
int ix, iy, isx, isy;
|
||||
int nframes=0, lastframe=-1;
|
||||
double d_x, d_y, res=5, xx, yy;
|
||||
int nph=0, badph=0, totph=0;
|
||||
FILE *f=NULL;
|
||||
|
||||
#ifdef DOUBLE_SPH
|
||||
single_photon_hit_double cl(3,3);
|
||||
#endif
|
||||
|
||||
#ifndef DOUBLE_SPH
|
||||
single_photon_hit cl(3,3);
|
||||
#endif
|
||||
|
||||
int nSubPixels=nsubpix;
|
||||
|
||||
int iebin=0;
|
||||
double eb_size=(cmax-cmin)/n_ebins;
|
||||
#ifndef NOINTERPOLATION
|
||||
// eta2InterpolationPosXY *interp[MAX_EBINS];
|
||||
eta2InterpolationCleverAdaptiveBins *interp[MAX_EBINS];
|
||||
for (int i=0; i< n_ebins; i++) {
|
||||
//interp[i]=new eta2InterpolationPosXY(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
interp[i]=new eta2InterpolationCleverAdaptiveBins(NC, NR, nsubpix, etabins, etamin, etamax);
|
||||
}
|
||||
#endif
|
||||
#ifdef NOINTERPOLATION
|
||||
noInterpolation *interp=new noInterpolation(NC, NR, nsubpix);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef FF
|
||||
#ifndef NOINTERPOLATION
|
||||
cout << "read ff " << argv[2] << endl;
|
||||
for (int i=0; i< n_ebins; i++) {
|
||||
sprintf(fname,argv[2],i);
|
||||
interp[i]->readFlatField(fname);
|
||||
interp[i]->prepareInterpolation(ok);//, MAX_ITERATIONS);
|
||||
}
|
||||
#endif
|
||||
// return 0;
|
||||
#endif
|
||||
#ifdef FF
|
||||
cout << "Will write eta file " << argv[2] << endl;
|
||||
#endif
|
||||
|
||||
int *img;
|
||||
float *totimg=new float[NC*NR*nsubpix*nsubpix];
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR; iy++) {
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FF
|
||||
sprintf(outfname,argv[2]);
|
||||
#endif
|
||||
|
||||
int irun;
|
||||
for (irun=runmin; irun<runmax; irun++) {
|
||||
sprintf(infname,argv[1],irun);
|
||||
#ifndef FF
|
||||
sprintf(outfname,argv[3],irun);
|
||||
#endif
|
||||
|
||||
f=fopen(infname,"r");
|
||||
if (f) {
|
||||
cout << infname << endl;
|
||||
nframes=0;
|
||||
f0=-1;
|
||||
|
||||
while (cl.read(f)) {
|
||||
totph++;
|
||||
if (lastframe!=cl.iframe) {
|
||||
lastframe=cl.iframe;
|
||||
// cout << cl.iframe << endl;
|
||||
// f0=cl.iframe;
|
||||
if (nframes==0) f0=lastframe;
|
||||
nframes++;
|
||||
}
|
||||
//quad=interp->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
||||
quad=interp[0]->calcEta(cl.get_cluster(), etax, etay, sum, totquad, sDum);
|
||||
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && sum<cmax ) {
|
||||
nph++;
|
||||
iebin=(sum-cmin)/eb_size;
|
||||
if (iebin>=0 && iebin<n_ebins) {
|
||||
// if (sum>200 && sum<580) {
|
||||
// interp->getInterpolatedPosition(cl.x,cl.y, totquad,quad,cl.get_cluster(),int_x, int_y);
|
||||
// #ifdef SOLEIL
|
||||
// if (cl.x>210 && cl.x<240 && cl.y>210 && cl.y<240) {
|
||||
// #endif
|
||||
#ifndef FF
|
||||
// interp->getInterpolatedPosition(cl.x,cl.y, cl.get_cluster(),int_x, int_y);
|
||||
interp[iebin]->getInterpolatedPosition(cl.x,cl.y, etax, etay, quad,int_x, int_y);
|
||||
// cout <<"**************"<< endl;
|
||||
// cout << cl.x << " " << cl.y << " " << sum << endl;
|
||||
// cl.print();
|
||||
// cout << int_x << " " << int_y << endl;
|
||||
// cout <<"**************"<< endl;
|
||||
if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
|
||||
interp[iebin]->addToImage(int_x, int_y);
|
||||
#endif
|
||||
#ifdef FF
|
||||
// interp->addToFlatField(cl.get_cluster(), etax, etay);
|
||||
#ifdef UCL
|
||||
if (cl.x>50)
|
||||
#endif
|
||||
if (etax!=0 && etay!=0 && etax!=1 && etay!=1)
|
||||
interp[iebin]->addToFlatField(etax, etay);
|
||||
// if (etax==0 || etay==0) cout << cl.x << " " << cl.y << endl;
|
||||
|
||||
#endif
|
||||
// #ifdef SOLEIL
|
||||
// }
|
||||
// #endif
|
||||
|
||||
if (nph%1000000==0) cout << nph << endl;
|
||||
if (nph%10000000==0) {
|
||||
#ifndef FF
|
||||
for (int i=0; i<n_ebins; i++) {
|
||||
sprintf(outfname,argv[3],i);
|
||||
interp[i]->writeInterpolatedImage(outfname);
|
||||
}
|
||||
#endif
|
||||
#ifdef FF
|
||||
for (int i=0; i<n_ebins; i++) {
|
||||
sprintf(outfname,argv[2],i);
|
||||
cout << outfname << " " << argv[2] << " " << i << endl;
|
||||
interp[i]->writeFlatField(outfname);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
fclose(f);
|
||||
#ifdef FF
|
||||
for (int i=0; i<n_ebins; i++) {
|
||||
sprintf(outfname,argv[2],i);
|
||||
cout << outfname << " " << argv[2] << " " << i << endl;
|
||||
interp[i]->writeFlatField(outfname);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef FF
|
||||
for (int i=0; i<n_ebins; i++) {
|
||||
sprintf(outfname,argv[3],i,irun);
|
||||
interp[i]->writeInterpolatedImage(outfname);
|
||||
img=interp[i]->getInterpolatedImage();
|
||||
for (ix=0; ix<NC; ix++) {
|
||||
for (iy=0; iy<NR; iy++) {
|
||||
for (isx=0; isx<nsubpix; isx++) {
|
||||
for (isy=0; isy<nsubpix; isy++) {
|
||||
totimg[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)]+=img[ix*nsubpix+isx+(iy*nsubpix+isy)*(NC*nsubpix)];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//interp[i]->clearInterpolatedImage();
|
||||
}
|
||||
cout << "Read " << nframes << " frames (first frame: " << f0 << " last frame: " << lastframe << " delta:" << lastframe-f0 << ")"<<endl;
|
||||
#endif
|
||||
|
||||
} else
|
||||
cout << "could not open file " << infname << endl;
|
||||
}
|
||||
#ifndef FF
|
||||
sprintf(outfname,argv[3], 11111);
|
||||
WriteToTiff(totimg, outfname,NC*nsubpix,NR*nsubpix);
|
||||
#endif
|
||||
|
||||
#ifdef FF
|
||||
interp[iebin]->writeFlatField(outfname);
|
||||
#endif
|
||||
|
||||
cout << "Filled " << nph << " (/"<< totph <<") " << endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,114 +0,0 @@
|
||||
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
#include "single_photon_hit.h"
|
||||
|
||||
#include "etaInterpolationPosXY.h"
|
||||
|
||||
using namespace std;
|
||||
#define NC 400
|
||||
#define NR 400
|
||||
|
||||
#define XTALK
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
int nsubpix=10;
|
||||
int etabins=nsubpix*100;
|
||||
double etamin=-1, etamax=2;
|
||||
double eta3min=-2, eta3max=2;
|
||||
int quad;
|
||||
double sum, totquad;
|
||||
double sDum[2][2];
|
||||
char fname[10000];
|
||||
double etax, etay;
|
||||
int runmin, runmax;
|
||||
single_photon_hit cl(3,3);
|
||||
int iph=0;
|
||||
|
||||
if (argc<7) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile " << " outfile runmin runmax cmin cmax" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
eta2InterpolationPosXY *interp2=new eta2InterpolationPosXY(NR, NC, nsubpix, etabins, etamin, etamax);
|
||||
cout << "###########"<< endl;
|
||||
eta3InterpolationPosXY *interp3=new eta3InterpolationPosXY(NR, NC, nsubpix, etabins, eta3min, eta3max);
|
||||
// cout << eta3min << " " << eta3max << endl;
|
||||
runmin=atoi(argv[3]);
|
||||
runmax=atoi(argv[4]);
|
||||
double cmin=atof(argv[5]); //200
|
||||
double cmax=atof(argv[6]); //3000
|
||||
|
||||
#ifdef XTALK
|
||||
int old_val[3][3];
|
||||
int new_val[3][3];
|
||||
double xcorr=0.04;
|
||||
|
||||
// int ix=0;
|
||||
#endif
|
||||
|
||||
FILE *f;
|
||||
for (int i=runmin; i<runmax; i++) {
|
||||
sprintf(fname,argv[1],i);
|
||||
f=fopen(fname,"r");
|
||||
if (f) {
|
||||
cout << "*" << endl;
|
||||
while (cl.read(f)) {
|
||||
#ifdef XTALK
|
||||
if ((cl.x+1)%25!=0) {
|
||||
for (int ix=-1; ix<2; ix++) {
|
||||
for (int iy=-1; iy<2; iy++) {
|
||||
old_val[iy+1][ix+1]=cl.get_data(ix,iy);
|
||||
if (ix>=0) {
|
||||
new_val[iy+1][ix+1]=old_val[iy+1][ix+1]-old_val[iy+1][ix]*xcorr;
|
||||
cl.set_data(new_val[iy+1][ix+1],ix,iy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
quad=interp2->calcQuad(cl.get_cluster(), sum, totquad, sDum);
|
||||
|
||||
if (sum>cmin && totquad/sum>0.8 && totquad/sum<1.2 && totquad<cmax && quad<cmax) {
|
||||
/* Cross talk corrections !!! */
|
||||
// for (int ix=0; ix<2; ix++) {
|
||||
|
||||
|
||||
interp2->addToFlatField(cl.get_cluster(),etax, etay);
|
||||
// if (etax>0.49 && etax<0.51 && etay>0.49 && etay<0.51 ) {
|
||||
// cout << cl.y << " " << cl.x << " " << quad << " "<< totquad << " " <<sum << endl;
|
||||
|
||||
// }
|
||||
interp3->addToFlatField(cl.get_cluster(),etax, etay);
|
||||
iph++;
|
||||
if (iph%1000000==0) cout << iph << endl;
|
||||
if (iph%100000000==0) {
|
||||
sprintf(fname,"%s_eta2.tiff",argv[2]);
|
||||
interp2->writeFlatField(fname);
|
||||
sprintf(fname,"%s_eta3.tiff",argv[2]);
|
||||
interp3->writeFlatField(fname);
|
||||
}
|
||||
// if (iph>1E8) break;
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
fclose(f);
|
||||
|
||||
}
|
||||
else cout << "could not open file " << fname << endl;
|
||||
}
|
||||
|
||||
sprintf(fname,"%s_eta2.tiff",argv[2]);
|
||||
interp2->writeFlatField(fname);
|
||||
sprintf(fname,"%s_eta3.tiff",argv[2]);
|
||||
interp3->writeFlatField(fname);
|
||||
return 0;
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
#include "moench03T1ZmqData.h"
|
||||
#include "single_photon_hit.h"
|
||||
|
||||
#include "noInterpolation.h"
|
||||
|
@ -1,163 +0,0 @@
|
||||
//#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,242 +0,0 @@
|
||||
//#include "ansi.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
#ifdef NEWRECEIVER
|
||||
#include "moench03T1ReceiverDataNew.h"
|
||||
#endif
|
||||
#ifdef CSAXS_FP
|
||||
#include "moench03T1ReceiverData.h"
|
||||
#endif
|
||||
#ifdef OLDDATA
|
||||
#include "moench03Ctb10GbT1Data.h"
|
||||
#endif
|
||||
|
||||
// #include "interpolatingDetector.h"
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <ctime>
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
if (argc<4) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname [pedfile] [threshold]" << 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;
|
||||
|
||||
|
||||
|
||||
#ifdef NEWRECEIVER
|
||||
moench03T1ReceiverDataNew *decoder=new moench03T1ReceiverDataNew();
|
||||
cout << "RECEIVER DATA WITH ONE HEADER!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef CSAXS_FP
|
||||
moench03T1ReceiverData *decoder=new moench03T1ReceiverData();
|
||||
cout << "RECEIVER DATA WITH ALL HEADERS!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifdef OLDDATA
|
||||
moench03Ctb10GbT1Data *decoder=new moench03Ctb10GbT1Data();
|
||||
cout << "OLD RECEIVER DATA!"<<endl;
|
||||
#endif
|
||||
|
||||
#ifndef ANALOG
|
||||
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
|
||||
// char tit[10000];
|
||||
cout << "filter " << endl;
|
||||
#endif
|
||||
|
||||
#ifdef ANALOG
|
||||
//moench03T1ZmqData *decoder=new moench03T1ZmqData();
|
||||
analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(decoder, 1, 0, nped);
|
||||
// char tit[10000];
|
||||
cout << "filter " << endl;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// filter->readPedestals("/scratch/ped_100.tiff");
|
||||
// interp->readFlatField("/scratch/eta_100.tiff",etamin,etamax);
|
||||
// cout << "filter "<< endl;
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
int ff, np;
|
||||
int dsize=decoder->getDataSize();
|
||||
cout << " data size is " << dsize;
|
||||
|
||||
|
||||
char data[dsize];
|
||||
|
||||
ifstream filebin;
|
||||
char *indir=argv[1];
|
||||
char *outdir=argv[2];
|
||||
char *fformat=argv[3];
|
||||
char *pedfile=NULL;
|
||||
if (argc>=5) {
|
||||
pedfile=argv[4];
|
||||
}
|
||||
double thr=0;
|
||||
if (argc>=6) {
|
||||
thr=atoi(argv[5]);
|
||||
}
|
||||
|
||||
|
||||
char fname[10000];
|
||||
char imgfname[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 << "input file is " << fformat << endl;
|
||||
if (pedfile)
|
||||
cout << "pedestal file is " << pedfile << endl;
|
||||
if (thr>0) {
|
||||
cout << "threshold is " << thr << endl;
|
||||
filter->setThreshold(thr);
|
||||
}
|
||||
|
||||
filter->setROI(0,150,0,150);
|
||||
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
cout << "mt " << endl;
|
||||
|
||||
int ifr=0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (int irun=0; irun<2; irun++) {
|
||||
if (irun>0) {
|
||||
mt->setFrameMode(eFrame);
|
||||
// sprintf(fn,fformat,irun);
|
||||
sprintf(fname,"%s/%s.raw",indir,fformat);
|
||||
// sprintf(outfname,"%s/%s.clust",outdir,fn);
|
||||
sprintf(imgfname,"%s/%s.tiff",outdir,fformat);
|
||||
} else {
|
||||
mt->setFrameMode(ePedestal);
|
||||
// sprintf(fn,fformat,irun);
|
||||
sprintf(fname,"%s/%s.raw",indir,pedfile);
|
||||
// sprintf(outfname,"%s/%s.clust",outdir,fn);
|
||||
// sprintf(imgfname,"%s/%s.tiff",outdir,fn);
|
||||
}
|
||||
cout << fname << endl;
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
// cout << fname << " " << outfname << " " << imgfname << endl;
|
||||
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||
// //open file
|
||||
if (filebin.is_open()){
|
||||
// of=fopen(outfname,"w");
|
||||
// if (of) {
|
||||
// mt->setFilePointer(of);
|
||||
// // cout << "file pointer set " << endl;
|
||||
// } else {
|
||||
// cout << "Could not open "<< outfname << " for writing " << endl;
|
||||
// mt->setFilePointer(NULL);
|
||||
// return 1;
|
||||
// }
|
||||
// //while read frame
|
||||
ff=-1;
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
// cout << "*"<<ifr++<<"*"<<ff<< endl;
|
||||
// cout << ff << " " << np << endl;
|
||||
// //push
|
||||
mt->pushData(buff);
|
||||
// // //pop
|
||||
mt->nextThread();
|
||||
// // // cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
ifr++;
|
||||
if (ifr%10000==0) cout << ifr << " " << ff << endl;
|
||||
ff=-1;
|
||||
}
|
||||
cout << "--" << endl;
|
||||
filebin.close();
|
||||
// //close file
|
||||
// //join threads
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
// if (of)
|
||||
// fclose(of);
|
||||
if (irun>0) {
|
||||
cout << "Writing tiff to " << imgfname << endl;
|
||||
mt->writeImage(imgfname);
|
||||
// mt->clearImage();
|
||||
}
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
} else
|
||||
cout << "Could not open "<< fname << " for reading " << endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,7 +1,12 @@
|
||||
//#include "ansi.h"
|
||||
#include <iostream>
|
||||
#define CORR
|
||||
|
||||
#define C_GHOST 0.0004
|
||||
|
||||
#define CM_ROWS 50
|
||||
|
||||
//#define VERSION_V1
|
||||
|
||||
//#include "moench03T1ZmqData.h"
|
||||
#ifdef NEWRECEIVER
|
||||
@ -27,8 +32,11 @@
|
||||
//#include "etaInterpolationPosXY.h"
|
||||
// #include "linearInterpolation.h"
|
||||
// #include "noInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.h"
|
||||
#include "multiThreadedCountingDetector.h"
|
||||
//#include "multiThreadedAnalogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
#include "moench03GhostSummation.h"
|
||||
#include "moench03CommonMode.h"
|
||||
//#include "interpolatingDetector.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@ -44,7 +52,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
if (argc<4) {
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname [runmin] [runmax] [pedfile] [threshold] [nframes] [xmin xmax ymin ymax]" << endl;
|
||||
cout << "Usage is " << argv[0] << "indir outdir fname [runmin] [runmax] [pedfile] [threshold] [nframes] [xmin xmax ymin ymax] [gainmap]" << endl;
|
||||
cout << "threshold <0 means analog; threshold=0 means cluster finder; threshold>0 means photon counting" << endl;
|
||||
cout << "nframes <0 means sum everything; nframes=0 means one file per run; nframes>0 means one file every nframes" << endl;
|
||||
return 1;
|
||||
@ -52,14 +60,14 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
int p=10000;
|
||||
int fifosize=1000;
|
||||
int nthreads=8;
|
||||
int nthreads=10;
|
||||
int nsubpix=25;
|
||||
int etabins=nsubpix*10;
|
||||
double etamin=-1, etamax=2;
|
||||
int csize=3;
|
||||
int save=1;
|
||||
int nsigma=5;
|
||||
int nped=1000;
|
||||
int nped=10000;
|
||||
int ndark=100;
|
||||
int ok;
|
||||
int iprog=0;
|
||||
@ -88,21 +96,24 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
decoder->getDetectorSize(nx,ny);
|
||||
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200);
|
||||
int ncol_cm=CM_ROWS;
|
||||
double xt_ghost=C_GHOST;
|
||||
moench03CommonMode *cm=NULL;
|
||||
moench03GhostSummation *gs;
|
||||
double *gainmap=NULL;
|
||||
float *gm;
|
||||
|
||||
|
||||
|
||||
int size = 327680;////atoi(argv[3]);
|
||||
|
||||
int* image;
|
||||
//int* image =new int[327680/sizeof(int)];
|
||||
filter->newDataSet();
|
||||
|
||||
|
||||
int ff, np;
|
||||
int dsize=decoder->getDataSize();
|
||||
//cout << " data size is " << dsize;
|
||||
|
||||
|
||||
char data[dsize];
|
||||
|
||||
ifstream filebin;
|
||||
char *indir=argv[1];
|
||||
@ -129,7 +140,7 @@ int main(int argc, char *argv[]) {
|
||||
double thr1=1;
|
||||
|
||||
if (argc>=8) {
|
||||
thr=atoi(argv[7]);
|
||||
thr=atof(argv[7]);
|
||||
}
|
||||
|
||||
|
||||
@ -147,6 +158,12 @@ int main(int argc, char *argv[]) {
|
||||
}
|
||||
|
||||
|
||||
char *gainfname=NULL;
|
||||
if (argc>13) {
|
||||
gainfname=argv[13];
|
||||
cout << "Gain map file name is: " << gainfname << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -166,25 +183,74 @@ int main(int argc, char *argv[]) {
|
||||
cout << "runmax is " << runmax << endl;
|
||||
if (pedfile)
|
||||
cout << "pedestal file is " << pedfile << endl;
|
||||
if (thr>0)
|
||||
cout << "threshold is " << thr << endl;
|
||||
|
||||
uint32 nnx, nny;
|
||||
double *gmap;
|
||||
|
||||
// if (gainfname) {
|
||||
// gm=ReadFromTiff(gainfname, nny, nnx);
|
||||
// if (gm && nnx==nx && nny==ny) {
|
||||
// gmap=new double[nx*ny];
|
||||
// for (int i=0; i<nx*ny; i++) {
|
||||
// gmap[i]=gm[i];
|
||||
// }
|
||||
// delete gm;
|
||||
// } else
|
||||
// cout << "Could not open gain map " << gainfname << endl;
|
||||
// }
|
||||
|
||||
#ifdef CORR
|
||||
cout << "Applying common mode " << ncol_cm << endl;
|
||||
cm=new moench03CommonMode(ncol_cm);
|
||||
|
||||
|
||||
cout << "Applying ghost corrections " << xt_ghost << endl;
|
||||
gs=new moench03GhostSummation(decoder, xt_ghost);
|
||||
#endif
|
||||
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, cm, nped, 200, -1, -1, gainmap, gs);
|
||||
|
||||
if (gainfname) {
|
||||
|
||||
if (filter->readGainMap(gainfname))
|
||||
cout << "using gain map " << gainfname << endl;
|
||||
else
|
||||
cout << "Could not open gain map " << gainfname << endl;
|
||||
} else
|
||||
thr=0.15*thr;
|
||||
filter->newDataSet();
|
||||
int dsize=decoder->getDataSize();
|
||||
|
||||
|
||||
char data[dsize];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//#ifndef ANALOG
|
||||
if (thr>0) {
|
||||
cout << "threshold is " << thr << endl;
|
||||
//#ifndef ANALOG
|
||||
filter->setThreshold(thr);
|
||||
//#endif
|
||||
cf=0;
|
||||
|
||||
} else
|
||||
cf=1;
|
||||
//#endif
|
||||
|
||||
|
||||
filter->setROI(xmin,xmax,ymin,ymax);
|
||||
#ifdef SOLEIL
|
||||
filter->setROI(150,210,170,230);
|
||||
nframes=-1;
|
||||
#endif
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
|
||||
// multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize);
|
||||
#ifndef ANALOG
|
||||
mt->setDetectorMode(ePhotonCounting);
|
||||
cout << "Counting!" << endl;
|
||||
@ -197,8 +263,7 @@ int main(int argc, char *argv[]) {
|
||||
mt->setDetectorMode(eAnalog);
|
||||
cout << "Analog!" << endl;
|
||||
cf=0;
|
||||
// #ifdef ANALOG
|
||||
// thr1=thr;
|
||||
//thr1=thr;
|
||||
#endif
|
||||
// }
|
||||
|
||||
@ -209,51 +274,78 @@ int main(int argc, char *argv[]) {
|
||||
// cout << "mt " << endl;
|
||||
|
||||
int ifr=0;
|
||||
|
||||
|
||||
double ped[nx*ny], *ped1;
|
||||
|
||||
|
||||
if (pedfile) {
|
||||
cout << "PEDESTAL " ;
|
||||
sprintf(fname,"%s.raw",pedfile);
|
||||
cout << fname << endl ;
|
||||
sprintf(imgfname,"%s/pedestals.tiff",outdir,fformat);
|
||||
std::time(&end_time);
|
||||
cout << "aaa" << std::ctime(&end_time) << endl;
|
||||
|
||||
cout << "PEDESTAL " << endl;
|
||||
sprintf(imgfname,"%s/pedestals.tiff",outdir);
|
||||
|
||||
mt->setFrameMode(ePedestal);
|
||||
// sprintf(fn,fformat,irun);
|
||||
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||
// //open file
|
||||
if (filebin.is_open()){
|
||||
ff=-1;
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
ifr++;
|
||||
if (ifr%10000==0)
|
||||
cout << ifr << " " << ff << " " << np << endl;
|
||||
ff=-1;
|
||||
}
|
||||
filebin.close();
|
||||
while (mt->isBusy()) {;}
|
||||
mt->writePedestal(imgfname);
|
||||
if (string(pedfile).find(".tif")==std::string::npos){
|
||||
sprintf(fname,"%s.raw",pedfile);
|
||||
cout << fname << endl ;
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
cout << "aaa" << std::ctime(&end_time) << endl;
|
||||
|
||||
|
||||
mt->setFrameMode(ePedestal);
|
||||
// sprintf(fn,fformat,irun);
|
||||
filebin.open((const char *)(fname), ios::in | ios::binary);
|
||||
// //open file
|
||||
if (filebin.is_open()){
|
||||
ff=-1;
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
if (np==40) {
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
ifr++;
|
||||
if (ifr%100==0)
|
||||
cout << ifr << " " << ff << " " << np << endl;
|
||||
} else
|
||||
cout << ifr << " " << ff << " " << np << endl;
|
||||
ff=-1;
|
||||
}
|
||||
filebin.close();
|
||||
while (mt->isBusy()) {;}
|
||||
|
||||
} else
|
||||
cout << "Could not open "<< fname << " for reading " << endl;
|
||||
cout << "Could not open pedestal file "<< fname << " for reading " << endl;
|
||||
} else {
|
||||
float *pp=ReadFromTiff(pedfile, nny, nnx);
|
||||
if (pp && nnx==nx && nny==ny) {
|
||||
for (int i=0; i<nx*ny; i++) {
|
||||
ped[i]=pp[i];
|
||||
}
|
||||
delete [] pp;
|
||||
mt->setPedestal(ped);
|
||||
// ped1=mt->getPedestal();
|
||||
|
||||
// for (int i=0; i<nx*ny; i++) {
|
||||
|
||||
// cout << ped[i]<<"/"<<ped1[i] << " " ;
|
||||
// }
|
||||
cout << "Pedestal set from tiff file " << pedfile << endl;
|
||||
} else {
|
||||
cout << "Could not open pedestal tiff file "<< pedfile << " for reading " << endl;
|
||||
}
|
||||
}
|
||||
mt->writePedestal(imgfname);
|
||||
std::time(&end_time);
|
||||
cout << std::ctime(&end_time) << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ifr=0;
|
||||
int ifile=0;
|
||||
|
||||
mt->setFrameMode(eFrame);
|
||||
|
||||
for (int irun=runmin; irun<=runmax; irun++) {
|
||||
cout << "DATA " ;
|
||||
mt->setFrameMode(eFrame);
|
||||
// sprintf(fn,fformat,irun);
|
||||
sprintf(ffname,"%s/%s.raw",indir,fformat);
|
||||
sprintf(fname,ffname,irun);
|
||||
@ -270,8 +362,7 @@ int main(int argc, char *argv[]) {
|
||||
// //open file
|
||||
ifile=0;
|
||||
if (filebin.is_open()){
|
||||
if (thr<=0) {
|
||||
if (cf) {
|
||||
if (thr<=0 && cf!=0) { //cluster finder
|
||||
if (of==NULL) {
|
||||
of=fopen(cfname,"w");
|
||||
if (of) {
|
||||
@ -283,35 +374,40 @@ int main(int argc, char *argv[]) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// //while read frame
|
||||
ff=-1;
|
||||
ifr=0;
|
||||
while (decoder->readNextFrame(filebin, ff, np,buff)) {
|
||||
if (np==40) {
|
||||
// cout << "*"<<ifr++<<"*"<<ff<< endl;
|
||||
// cout << ff << " " << np << endl;
|
||||
// //push
|
||||
mt->pushData(buff);
|
||||
// // //pop
|
||||
mt->nextThread();
|
||||
// // // cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
ifr++;
|
||||
if (ifr%1000==0) cout << ifr << " " << ff << endl;
|
||||
if (nframes>0) {
|
||||
if (ifr%nframes==0) {
|
||||
//The name has an additional "_fXXXXX" at the end, where "XXXXX" is the initial frame number of the image (0,1000,2000...)
|
||||
|
||||
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
|
||||
sprintf(imgfname,ffname,irun);
|
||||
//cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
|
||||
mt->writeImage(imgfname, thr1);
|
||||
mt->clearImage();
|
||||
ifile++;
|
||||
}
|
||||
}
|
||||
mt->pushData(buff);
|
||||
// // //pop
|
||||
mt->nextThread();
|
||||
// // // cout << " " << (void*)buff;
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
|
||||
|
||||
ifr++;
|
||||
if (ifr%100==0) cout << ifr << " " << ff << endl;
|
||||
if (nframes>0) {
|
||||
if (ifr%nframes==0) {
|
||||
//The name has an additional "_fXXXXX" at the end, where "XXXXX" is the initial frame number of the image (0,1000,2000...)
|
||||
|
||||
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
|
||||
sprintf(imgfname,ffname,irun);
|
||||
//cout << "Writing tiff to " << imgfname << " " << thr1 << endl;
|
||||
mt->writeImage(imgfname, thr1);
|
||||
mt->clearImage();
|
||||
ifile++;
|
||||
}
|
||||
}
|
||||
} else
|
||||
cout << ifr << " " << ff << " " << np << endl;
|
||||
ff=-1;
|
||||
}
|
||||
cout << "--" << endl;
|
||||
@ -323,9 +419,10 @@ int main(int argc, char *argv[]) {
|
||||
if (nframes>0) {
|
||||
sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile);
|
||||
sprintf(imgfname,ffname,irun);
|
||||
} else {
|
||||
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
|
||||
sprintf(imgfname,ffname,irun);
|
||||
}
|
||||
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
|
||||
sprintf(imgfname,ffname,irun);
|
||||
cout << "Writing tiff to " << imgfname << " " << thr1 <<endl;
|
||||
mt->writeImage(imgfname, thr1);
|
||||
mt->clearImage();
|
||||
@ -340,6 +437,13 @@ int main(int argc, char *argv[]) {
|
||||
} else
|
||||
cout << "Could not open "<< fname << " for reading " << endl;
|
||||
}
|
||||
if (nframes<0){
|
||||
sprintf(ffname,"%s/%s.tiff",outdir,fformat);
|
||||
strcpy(imgfname,ffname);
|
||||
cout << "Writing tiff to " << imgfname << " " << thr1 <<endl;
|
||||
mt->writeImage(imgfname, thr1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
|
@ -1,394 +0,0 @@
|
||||
//#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;
|
||||
}
|
||||
|
@ -1,402 +0,0 @@
|
||||
#include "sls_receiver_defs.h"
|
||||
#include "ZmqSocket.h"
|
||||
#include "moench03T1ZmqDataNew.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include "tiffIO.h"
|
||||
|
||||
|
||||
//#define NEWZMQ
|
||||
#ifdef NEWZMQ
|
||||
#include <rapidjson/document.h> //json header in zmq stream
|
||||
#endif
|
||||
|
||||
#include<iostream>
|
||||
|
||||
//#include "analogDetector.h"
|
||||
#include "singlePhotonDetector.h"
|
||||
#include "multiThreadedAnalogDetector.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]
|
||||
*
|
||||
*/
|
||||
FILE *of=NULL;
|
||||
int fifosize=1000;
|
||||
int nthreads=20;
|
||||
// help
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number]\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// receive parameters
|
||||
bool send = false;
|
||||
char* socketip=argv[1];
|
||||
uint32_t portnum = atoi(argv[2]);
|
||||
int maxSize = 32*2*8192;//5000;//atoi(argv[3]);
|
||||
int size= 32*2*5000;
|
||||
int multisize=size;
|
||||
// send parameters if any
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
if (argc > 3) {
|
||||
send = true;
|
||||
socketip2 = argv[3];
|
||||
portnum2 = atoi(argv[4]);
|
||||
}
|
||||
cout << "\nrx socket ip : " << socketip <<
|
||||
"\nrx port num : " << portnum ;
|
||||
if (send) {
|
||||
cout << "\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);
|
||||
|
||||
|
||||
char* buff;
|
||||
multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize);
|
||||
mt->setFrameMode(eFrame);
|
||||
mt->StartThreads();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
ZmqSocket* zmqsocket=NULL;
|
||||
|
||||
#ifdef NEWZMQ
|
||||
// receive socket
|
||||
try{
|
||||
#endif
|
||||
|
||||
zmqsocket = new ZmqSocket(socketip,portnum);
|
||||
|
||||
|
||||
#ifdef NEWZMQ
|
||||
} catch (...) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEWZMQ
|
||||
if (zmqsocket->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket on port %d with ip %s\n", portnum, socketip);
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif
|
||||
if (zmqsocket->Connect()) {
|
||||
cprintf(RED, "Error: Could not connect to socket %s\n",
|
||||
zmqsocket->GetZmqServerAddress());
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
} else
|
||||
printf("Zmq Client at %s\n", zmqsocket->GetZmqServerAddress());
|
||||
|
||||
// send socket
|
||||
ZmqSocket* zmqsocket2 = 0;
|
||||
cout << "zmq2 " << endl;
|
||||
if (send) {
|
||||
#ifdef NEWZMQ
|
||||
// receive socket
|
||||
try{
|
||||
#endif
|
||||
zmqsocket2 = new ZmqSocket(portnum2, socketip2);
|
||||
|
||||
|
||||
|
||||
#ifdef NEWZMQ
|
||||
} catch (...) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
delete zmqsocket2;
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NEWZMQ
|
||||
if (zmqsocket2->IsError()) {
|
||||
cprintf(RED, "Error: Could not create Zmq socket server on port %d and ip %s\n", portnum2, socketip2);
|
||||
delete zmqsocket2;
|
||||
delete zmqsocket;
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
#endif
|
||||
if (zmqsocket2->Connect()) {
|
||||
cprintf(RED, "Error: Could not connect to socket %s\n",
|
||||
zmqsocket2->GetZmqServerAddress());
|
||||
delete zmqsocket2;
|
||||
return EXIT_FAILURE;
|
||||
} else
|
||||
printf("Zmq Client at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
|
||||
}
|
||||
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subFrameIndex = -1;
|
||||
uint64_t fileindex = -1;
|
||||
string filename = "";
|
||||
// char* image = new char[size];
|
||||
//int* image = new int[(size/sizeof(int))]();
|
||||
uint32_t flippedDataX = -1;
|
||||
int *nph;
|
||||
int iframe=0;
|
||||
char ofname[10000];
|
||||
|
||||
char fname[10000];
|
||||
int length;
|
||||
int *detimage;
|
||||
int nnx, nny,nns;
|
||||
uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0, dynamicRange = 0;
|
||||
filter->getImageSize(nnx, nny,nns);
|
||||
int16_t *dout=new int16_t [nnx*nny];
|
||||
// infinite loop
|
||||
uint32_t packetNumber = 0;
|
||||
uint64_t bunchId = 0;
|
||||
uint64_t timestamp = 0;
|
||||
int16_t modId = 0;
|
||||
uint16_t xCoord = 0;
|
||||
uint16_t yCoord = 0;
|
||||
uint16_t zCoord = 0;
|
||||
uint32_t debug = 0;
|
||||
uint32_t dr = 16;
|
||||
uint16_t roundRNumber = 0;
|
||||
uint8_t detType = 0;
|
||||
uint8_t version = 0;
|
||||
int* flippedData = 0;
|
||||
char* additionalJsonHeader = 0;
|
||||
|
||||
uint32_t threshold=0;
|
||||
|
||||
uint32_t xmin=0, xmax=400, ymin=0, ymax=400;
|
||||
|
||||
string frameMode_s, detectorMode_s;
|
||||
|
||||
int emin, emax;
|
||||
|
||||
|
||||
int newFrame=1;
|
||||
|
||||
while(1) {
|
||||
|
||||
|
||||
// cout << "+++++++++++++++++++++++++++++++LOOP" << endl;
|
||||
// get header, (if dummy, fail is on parse error or end of acquisition)
|
||||
#ifndef NEWZMQ
|
||||
if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)){
|
||||
#endif
|
||||
|
||||
#ifdef NEWZMQ
|
||||
rapidjson::Document doc;
|
||||
if (!zmqsocket->ReceiveHeader(0, doc, SLS_DETECTOR_JSON_HEADER_VERSION)) {
|
||||
zmqsocket->CloseHeaderMessage();
|
||||
|
||||
#endif
|
||||
// if (!zmqsocket->ReceiveHeader(0, acqIndex, frameIndex, subframeIndex, filename, fileindex)) {
|
||||
cprintf(RED, "Got Dummy\n");
|
||||
|
||||
|
||||
|
||||
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
|
||||
|
||||
detimage=mt->getImage(nnx,nny,nns);
|
||||
for (int ix=0; ix<nnx; ix++) {
|
||||
for (int iy=0; iy<nny; iy++) {
|
||||
dout[iy*nnx+ix]=detimage[iy*nnx+ix];
|
||||
}
|
||||
}
|
||||
|
||||
if (send) {
|
||||
strcpy(fname,filename.c_str());
|
||||
#ifdef NEWZMQ
|
||||
//zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dynamicRange, fileindex,
|
||||
// nnx, nny, nns*dynamicRange/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
|
||||
|
||||
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex,
|
||||
nnx, nny, nns*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NEWZMQ
|
||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
#endif
|
||||
|
||||
zmqsocket2->SendData((char*)dout,length);
|
||||
cprintf(GREEN, "Sent Data\n");
|
||||
}
|
||||
|
||||
|
||||
// stream dummy to socket2 to signal end of acquisition
|
||||
if (send) {
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
}
|
||||
mt->clearImage();
|
||||
if (of) {
|
||||
fclose(of);
|
||||
of=NULL;
|
||||
}
|
||||
|
||||
newFrame=1;
|
||||
continue; //continue to not get out
|
||||
}
|
||||
|
||||
#ifdef NEWZMQ
|
||||
if (newFrame) {
|
||||
// acqIndex, frameIndex, subframeIndex, filename, fileindex
|
||||
size = doc["size"].GetUint();
|
||||
multisize = size;// * zmqsocket->size();
|
||||
dynamicRange = doc["bitmode"].GetUint();
|
||||
nPixelsX = doc["shape"][0].GetUint();
|
||||
nPixelsY = doc["shape"][1].GetUint();
|
||||
filename = doc["fname"].GetString();
|
||||
acqIndex = doc["acqIndex"].GetUint64();
|
||||
frameIndex = doc["fIndex"].GetUint64();
|
||||
fileindex = doc["fileIndex"].GetUint64();
|
||||
subFrameIndex = doc["expLength"].GetUint();
|
||||
xCoord = doc["xCoord"].GetUint();
|
||||
yCoord = doc["yCoord"].GetUint();
|
||||
zCoord = doc["zCoord"].GetUint();
|
||||
flippedDataX=doc["flippedDataX"].GetUint();
|
||||
packetNumber=doc["packetNumber"].GetUint();
|
||||
bunchId=doc["bunchId"].GetUint();
|
||||
timestamp=doc["timestamp"].GetUint();
|
||||
modId=doc["modId"].GetUint();
|
||||
debug=doc["debug"].GetUint();
|
||||
roundRNumber=doc["roundRNumber"].GetUint();
|
||||
detType=doc["detType"].GetUint();
|
||||
version=doc["version"].GetUint();
|
||||
|
||||
|
||||
|
||||
cprintf(BLUE, "Header Info:\n"
|
||||
"size: %u\n"
|
||||
"multisize: %u\n"
|
||||
"dynamicRange: %u\n"
|
||||
"nPixelsX: %u\n"
|
||||
"nPixelsY: %u\n"
|
||||
"currentFileName: %s\n"
|
||||
"currentAcquisitionIndex: %lu\n"
|
||||
"currentFrameIndex: %lu\n"
|
||||
"currentFileIndex: %lu\n"
|
||||
"currentSubFrameIndex: %u\n"
|
||||
"xCoordX: %u\n"
|
||||
"yCoordY: %u\n"
|
||||
"zCoordZ: %u\n"
|
||||
"flippedDataX: %u\n"
|
||||
"packetNumber: %u\n"
|
||||
"bunchId: %u\n"
|
||||
"timestamp: %u\n"
|
||||
"modId: %u\n"
|
||||
"debug: %u\n"
|
||||
"roundRNumber: %u\n"
|
||||
"detType: %u\n"
|
||||
"version: %u\n",
|
||||
size, multisize, dynamicRange, nPixelsX, nPixelsY,
|
||||
filename.c_str(), acqIndex,
|
||||
frameIndex, fileindex, subFrameIndex,
|
||||
xCoord, yCoord,zCoord,
|
||||
flippedDataX, packetNumber, bunchId, timestamp, modId, debug, roundRNumber, detType, version);
|
||||
|
||||
|
||||
if (doc.HasMember("threshold")) {
|
||||
version=doc["threshold"].GetUint();
|
||||
|
||||
}
|
||||
|
||||
if (doc.HasMember("roi")) {
|
||||
xmin=doc["roi"][0].GetUint();
|
||||
xmax=doc["roi"][1].GetUint();
|
||||
ymin=doc["roi"][2].GetUint();
|
||||
ymax=doc["roi"][3].GetUint();
|
||||
|
||||
}
|
||||
|
||||
if (doc.HasMember("frameMode")) {
|
||||
frameMode_s=doc["frameMode"].GetString();
|
||||
|
||||
}
|
||||
|
||||
if (doc.HasMember("detectorMode")) {
|
||||
detectorMode_s=doc["detectorMode"].GetString();
|
||||
|
||||
}
|
||||
|
||||
if (doc.HasMember("energyRange")) {
|
||||
emin=doc["energyRange"][0].GetUint();
|
||||
emax=doc["energyRange"][0].GetUint();
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (doc.HasMember("dynamicRange")) {
|
||||
dr=doc["dynamicRange"].GetUint();
|
||||
}
|
||||
|
||||
if (doc.HasMember("nSubPixels")) {
|
||||
nsubPixels=doc["nSubPixels"].GetUint();
|
||||
}
|
||||
|
||||
|
||||
|
||||
newFrame=0;
|
||||
zmqsocket->CloseHeaderMessage();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (of==NULL) {
|
||||
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
|
||||
of=fopen(ofname,"w");
|
||||
if (of) {
|
||||
mt->setFilePointer(of);
|
||||
}else {
|
||||
cout << "Could not open "<< ofname << " for writing " << endl;
|
||||
mt->setFilePointer(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
// get data
|
||||
length = zmqsocket->ReceiveData(0, buff, size);
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
|
||||
|
||||
|
||||
|
||||
iframe++;
|
||||
} // exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
if (send)
|
||||
delete zmqsocket2;
|
||||
|
||||
|
||||
cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,292 +0,0 @@
|
||||
#include "sls_receiver_defs.h"
|
||||
#include "ZmqSocket.h"
|
||||
#include "moench03T1ZmqDataNew.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include "tiffIO.h"
|
||||
|
||||
#include<iostream>
|
||||
|
||||
//#include "analogDetector.h"
|
||||
#include "interpolatingDetector.h"
|
||||
#include "linearInterpolation.h"
|
||||
#include "multiThreadedAnalogDetector.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 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 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
|
||||
int size = 32*2*5000;//atoi(argv[3]);
|
||||
bool send = false;
|
||||
|
||||
|
||||
|
||||
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 << endl;
|
||||
|
||||
//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);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
zmqsocket->Connect();
|
||||
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;
|
||||
}
|
||||
zmqsocket2->Connect();
|
||||
printf("Zmq Server started at %s\n", zmqsocket2->GetZmqServerAddress());
|
||||
}
|
||||
|
||||
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subframeIndex = -1;
|
||||
uint64_t fileindex = -1;
|
||||
string filename = "";
|
||||
char ffname[10000];
|
||||
int ffindex;
|
||||
|
||||
char* image = new char[size];
|
||||
//int* image = new int[(size/sizeof(int))]();
|
||||
|
||||
int *nph;
|
||||
int iframe=0;
|
||||
char ofname[10000];
|
||||
|
||||
char fname[10000];
|
||||
int length;
|
||||
int *detimage;
|
||||
int nnx, nny,nns;
|
||||
int nix, niy,nis;
|
||||
filter->getImageSize(nnx, nny,nns);
|
||||
int16_t *dout=new int16_t [nnx*nny];
|
||||
// infinite loop
|
||||
int ix, iy, isx, isy;
|
||||
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 (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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} 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];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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);
|
||||
// cprintf(RED, "Sent Dummy\n");
|
||||
cprintf(RED, "Received %d frames\n", iframe);
|
||||
}
|
||||
mt->clearImage();
|
||||
if (of) {
|
||||
fclose(of);
|
||||
of=NULL;
|
||||
}
|
||||
iframe=0;
|
||||
continue; //continue to not get out
|
||||
}
|
||||
|
||||
|
||||
if (of==NULL) {
|
||||
while (mt->isBusy()) {;}
|
||||
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
|
||||
of=fopen(ofname,"w");
|
||||
if (of) {
|
||||
mt->setFilePointer(of);
|
||||
}else {
|
||||
cout << "Could not open "<< ofname << " for writing " << endl;
|
||||
mt->setFilePointer(NULL);
|
||||
}
|
||||
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
|
||||
length = zmqsocket->ReceiveData(0, buff, size);
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
|
||||
iframe++;
|
||||
} // exiting infinite loop
|
||||
|
||||
|
||||
|
||||
delete zmqsocket;
|
||||
if (send)
|
||||
delete zmqsocket2;
|
||||
|
||||
|
||||
// cout<<"Goodbye"<< endl;
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,8 +1,20 @@
|
||||
#define WRITE_QUAD
|
||||
#define MOENCH_BRANCH
|
||||
|
||||
#include "sls_receiver_defs.h"
|
||||
#define C_GHOST 0.0004
|
||||
|
||||
#define CM_ROWS 20
|
||||
|
||||
#include "sls_detector_defs.h"
|
||||
#include "ZmqSocket.h"
|
||||
#ifndef RECT
|
||||
#include "moench03T1ZmqDataNew.h"
|
||||
#endif
|
||||
#ifdef RECT
|
||||
#include "moench03T1ZmqDataNewRect.h"
|
||||
#endif
|
||||
#include "moench03GhostSummation.h"
|
||||
#include "moench03CommonMode.h"
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
@ -10,10 +22,7 @@
|
||||
#include <fstream>
|
||||
#include "tiffIO.h"
|
||||
|
||||
//#define NEWZMQ
|
||||
#ifdef NEWZMQ
|
||||
#include <rapidjson/document.h> //json header in zmq stream
|
||||
#endif
|
||||
|
||||
#include<iostream>
|
||||
|
||||
@ -47,9 +56,11 @@ int main(int argc, char *argv[]) {
|
||||
int fifosize=5000;
|
||||
int etabins=1000;//nsubpix*2*100;
|
||||
double etamin=-1, etamax=2;
|
||||
int nSubPixels=2;
|
||||
// int emin, emax;
|
||||
// help
|
||||
if (argc < 3 ) {
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number] [nthreads] [nsubpix] [etafile]\n");
|
||||
cprintf(RED, "Help: ./trial [receive socket ip] [receive starting port number] [send_socket ip] [send starting port number] [nthreads] [nsubpix] [gainmap] [etafile]\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
@ -61,6 +72,7 @@ int main(int argc, char *argv[]) {
|
||||
char* socketip2 = 0;
|
||||
uint32_t portnum2 = 0;
|
||||
|
||||
uint32_t nSigma=5;
|
||||
|
||||
int ok;
|
||||
|
||||
@ -86,17 +98,22 @@ int main(int argc, char *argv[]) {
|
||||
nthreads=atoi(argv[5]);
|
||||
|
||||
cout << "Number of threads is: " << nthreads << endl;
|
||||
int nSubPixels=2;
|
||||
if (argc>6)
|
||||
nSubPixels=atoi(argv[6]);
|
||||
cout << "Number of subpixels is: " << nSubPixels << endl;
|
||||
|
||||
char *etafname=NULL;
|
||||
|
||||
char *gainfname=NULL;
|
||||
if (argc>7) {
|
||||
etafname=argv[7];
|
||||
cout << "Eta file name is: " << etafname << endl;
|
||||
gainfname=argv[7];
|
||||
cout << "Gain map file name is: " << gainfname << endl;
|
||||
}
|
||||
|
||||
char *etafname=NULL;
|
||||
if (argc>8) {
|
||||
etafname=argv[8];
|
||||
cout << "Eta file name is: " << etafname << endl;
|
||||
}
|
||||
|
||||
//slsDetectorData *det=new moench03T1ZmqDataNew();
|
||||
moench03T1ZmqDataNew *det=new moench03T1ZmqDataNew();
|
||||
@ -104,21 +121,49 @@ int main(int argc, char *argv[]) {
|
||||
int npx, npy;
|
||||
det->getDetectorSize(npx, npy);
|
||||
|
||||
|
||||
int send_something=0;
|
||||
|
||||
|
||||
int maxSize = npx*npy*2;//32*2*8192;//5000;//atoi(argv[3]);
|
||||
int size= maxSize;//32*2*5000;
|
||||
int multisize=size;
|
||||
int dataSize=size;
|
||||
//int multisize=size;
|
||||
//int dataSize=size;
|
||||
|
||||
char dummybuff[size];
|
||||
|
||||
|
||||
int ncol_cm=CM_ROWS;
|
||||
double xt_ghost=C_GHOST;
|
||||
moench03CommonMode *cm=new moench03CommonMode(ncol_cm);
|
||||
moench03GhostSummation *gs=new moench03GhostSummation(det, xt_ghost);
|
||||
double *gainmap=NULL;
|
||||
float *gm;
|
||||
double *gmap=NULL;
|
||||
|
||||
uint32_t nnnx, nnny;
|
||||
if (gainfname) {
|
||||
gm=ReadFromTiff(gainfname, nnny, nnnx);
|
||||
if (gm && nnnx==(uint)npx && nnny==(uint)npy) {
|
||||
gmap=new double[npx*npy];
|
||||
for (int i=0; i<npx*npy; i++) {
|
||||
gmap[i]=gm[i];
|
||||
}
|
||||
delete [] gm;
|
||||
} else
|
||||
cout << "Could not open gain map " << gainfname << endl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//analogDetector<uint16_t> *filter=new analogDetector<uint16_t>(det,1,NULL,1000);
|
||||
#ifndef INTERP
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(det,3, 5, 1, 0, 1000, 10);
|
||||
singlePhotonDetector *filter=new singlePhotonDetector(det,3, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs);
|
||||
|
||||
multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize);
|
||||
|
||||
@ -129,7 +174,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
if (etafname) interp->readFlatField(etafname);
|
||||
|
||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, 5, 1, 0, 1000, 10);
|
||||
interpolatingDetector *filter=new interpolatingDetector(det,interp, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs);
|
||||
multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize);
|
||||
#endif
|
||||
|
||||
@ -220,21 +265,32 @@ int main(int argc, char *argv[]) {
|
||||
// header variables
|
||||
uint64_t acqIndex = -1;
|
||||
uint64_t frameIndex = -1;
|
||||
uint32_t subFrameIndex = -1;
|
||||
#ifdef MOENCH_BRANCH
|
||||
uint32_t subFrameIndex = -1;
|
||||
int* flippedData = 0;
|
||||
#endif
|
||||
|
||||
uint64_t subframes=0;
|
||||
//uint64_t isubframe=0;
|
||||
uint64_t insubframe=0;
|
||||
double subnorm=1;
|
||||
uint64_t f0=-1, nsubframes=0, nnsubframe=0;
|
||||
|
||||
uint64_t fileindex = -1;
|
||||
string filename = "";
|
||||
// char* image = new char[size];
|
||||
//int* image = new int[(size/sizeof(int))]();
|
||||
uint32_t flippedDataX = -1;
|
||||
int *nph;
|
||||
//uint32_t flippedDataX = -1;
|
||||
//int *nph;
|
||||
int iframe=0;
|
||||
char ofname[10000];
|
||||
|
||||
char fname[10000];
|
||||
int length;
|
||||
int *detimage;
|
||||
// int length;
|
||||
int *detimage=NULL;
|
||||
int nnx, nny,nns;
|
||||
uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0, dynamicRange = 0;
|
||||
//uint32_t imageSize = 0, nPixelsX = 0, nPixelsY = 0,
|
||||
//uint32_t dynamicRange = 0;
|
||||
// infinite loop
|
||||
uint32_t packetNumber = 0;
|
||||
uint64_t bunchId = 0;
|
||||
@ -248,11 +304,10 @@ int main(int argc, char *argv[]) {
|
||||
//int16_t *dout;//=new int16_t [nnx*nny];
|
||||
uint32_t dr = 32;
|
||||
int32_t *dout=NULL;//=new int32_t [nnx*nny];
|
||||
uint32_t nSigma=5;
|
||||
float *doutf=NULL;//=new int32_t [nnx*nny];
|
||||
uint16_t roundRNumber = 0;
|
||||
uint8_t detType = 0;
|
||||
uint8_t version = 0;
|
||||
int* flippedData = 0;
|
||||
char* additionalJsonHeader = 0;
|
||||
|
||||
int32_t threshold=0;
|
||||
@ -261,15 +316,14 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
string frameMode_s, detectorMode_s, intMode_s;
|
||||
|
||||
int emin, emax;
|
||||
int resetFlat=0;
|
||||
int resetPed=0;
|
||||
int nsubPixels=1;
|
||||
int isPedestal;
|
||||
int isFlat=0;
|
||||
// int resetFlat=0;
|
||||
//int resetPed=0;
|
||||
// int nsubPixels=1;
|
||||
//int isPedestal=0;
|
||||
//int isFlat=0;
|
||||
int newFrame=1;
|
||||
detectorMode dMode;
|
||||
frameMode fMode;
|
||||
detectorMode dMode=eAnalog;
|
||||
frameMode fMode=eFrame;
|
||||
double *ped;
|
||||
|
||||
filter->getImageSize(nnx, nny,nns);
|
||||
@ -313,28 +367,61 @@ int main(int argc, char *argv[]) {
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
}
|
||||
} else {
|
||||
if (fMode==ePedestal) {
|
||||
sprintf(ofname,"%s_%d_ped.tiff",fname,fileindex);
|
||||
mt->writePedestal(ofname);
|
||||
cout << "Writing pedestal to " << ofname << endl;
|
||||
}
|
||||
send_something=0;
|
||||
if (fMode==ePedestal) {
|
||||
sprintf(ofname,"%s_%ld_ped.tiff",fname,fileindex);
|
||||
mt->writePedestal(ofname);
|
||||
cout << "Writing pedestal to " << ofname << endl;
|
||||
send_something=1;
|
||||
}
|
||||
#ifdef INTERP
|
||||
else if (fMode==eFlat) {
|
||||
mt->prepareInterpolation(ok);
|
||||
sprintf(ofname,"%s_%d_eta.tiff",fname,fileindex);
|
||||
mt->writeFlatField(ofname);
|
||||
cout << "Writing eta to " << ofname << endl;
|
||||
}
|
||||
else if (fMode==eFlat) {
|
||||
mt->prepareInterpolation(ok);
|
||||
sprintf(ofname,"%s_%ld_eta.tiff",fname,fileindex);
|
||||
mt->writeFlatField(ofname);
|
||||
cout << "Writing eta to " << ofname << endl;
|
||||
send_something=1;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
sprintf(ofname,"%s_%d.tiff",fname,fileindex);
|
||||
mt->writeImage(ofname);
|
||||
cout << "Writing image to " << ofname << endl;
|
||||
}
|
||||
// cout << nns*nnx*nny*nns*dr/8 << " " << length << endl;
|
||||
else {
|
||||
if (subframes>0 ) {
|
||||
if (insubframe>0) {
|
||||
sprintf(ofname,"%s_sf%ld_%ld.tiff",fname,nnsubframe,fileindex);
|
||||
// mt->writeImage(ofname);
|
||||
doutf= new float[nnx*nny];
|
||||
if (subframes>0 && insubframe!=subframes && insubframe>0)
|
||||
subnorm=((double)subframes)/((double)insubframe);
|
||||
else
|
||||
subnorm=1.;
|
||||
for (int ix=0; ix<nnx*nny; ix++) {
|
||||
doutf[ix]=detimage[ix]*subnorm;
|
||||
if (doutf[ix]<0) doutf[ix]=0;
|
||||
}
|
||||
|
||||
cout << "Writing image to " << ofname << endl;
|
||||
|
||||
WriteToTiff(doutf,ofname ,nnx, nny);
|
||||
|
||||
if (doutf)
|
||||
delete [] doutf;
|
||||
doutf=NULL;
|
||||
|
||||
nsubframes++;
|
||||
insubframe=0;
|
||||
send_something=1;
|
||||
}
|
||||
} else {
|
||||
sprintf(ofname,"%s_%ld.tiff",fname,fileindex);
|
||||
mt->writeImage(ofname);
|
||||
send_something=1;
|
||||
}
|
||||
|
||||
cout << "Writing image to " << ofname << endl;
|
||||
}
|
||||
// cout << nns*nnx*nny*nns*dr/8 << " " << length << endl;
|
||||
|
||||
if (send) {
|
||||
|
||||
|
||||
if (fMode==ePedestal) {
|
||||
cprintf(MAGENTA,"Get pedestal!\n");
|
||||
nns=1;
|
||||
@ -356,7 +443,7 @@ int main(int argc, char *argv[]) {
|
||||
#ifdef INTERP
|
||||
else if (fMode==eFlat) {
|
||||
int nb;
|
||||
double emi, ema;
|
||||
double emi=0, ema=1;
|
||||
int *ff=mt->getFlatField(nb, emi, ema);
|
||||
nnx=nb;
|
||||
nny=nb;
|
||||
@ -376,6 +463,10 @@ int main(int argc, char *argv[]) {
|
||||
// nnx=nnx*nns;
|
||||
//nny=nny*nns;
|
||||
dout= new int32_t[nnx*nny];
|
||||
if (subframes>0 && insubframe!=subframes && insubframe>0)
|
||||
subnorm=((double)subframes)/((double)insubframe);
|
||||
else
|
||||
subnorm=1.;
|
||||
for (int ix=0; ix<nnx*nny; ix++) {
|
||||
// for (int iy=0; iy<nny*nns; iy++) {
|
||||
// for (int isx=0; isx<nns; isx++) {
|
||||
@ -387,34 +478,41 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// }
|
||||
// }
|
||||
dout[ix]=detimage[ix];
|
||||
dout[ix]=detimage[ix]*subnorm;
|
||||
if (dout[ix]<0) dout[ix]=0;
|
||||
// cout << ix << " " << dout[ix] << endl;
|
||||
// }
|
||||
}
|
||||
}
|
||||
//if ((insubframe>0 && subframes>0) || (subframes<=0) ){
|
||||
|
||||
|
||||
|
||||
#ifdef NEWZMQ
|
||||
cout << "Sending image size " << nnx << " " << nny << endl;
|
||||
if(send_something) {
|
||||
#ifndef DEVELOPER
|
||||
#ifndef MOENCH_BRANCH
|
||||
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, 0,0, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex,0 , packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, additionalJsonHeader);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef DEVELOPER
|
||||
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
|
||||
#endif
|
||||
#ifdef MOENCH_BRANCH
|
||||
|
||||
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef NEWZMQ
|
||||
zmqsocket2->SendHeaderData(0, false, SLS_DETECTOR_JSON_HEADER_VERSION,0,0,0,0,0, 0,0,fname, 0, 0,0,0,0,0,0,0,0,0,0,0,1);
|
||||
#endif
|
||||
|
||||
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
|
||||
cprintf(GREEN, "Sent Data\n");
|
||||
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
if (dout)
|
||||
delete [] dout;
|
||||
dout=NULL;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
|
||||
cprintf(GREEN, "Sent Data\n");
|
||||
}
|
||||
|
||||
zmqsocket2->SendHeaderData(0, true, SLS_DETECTOR_JSON_HEADER_VERSION);
|
||||
cprintf(RED, "Sent Dummy\n");
|
||||
if (dout)
|
||||
delete [] dout;
|
||||
dout=NULL;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -443,7 +541,7 @@ int main(int argc, char *argv[]) {
|
||||
// acqIndex, frameIndex, subframeIndex, filename, fileindex
|
||||
size = doc["size"].GetUint();
|
||||
// multisize = size;// * zmqsocket->size();
|
||||
dynamicRange = doc["bitmode"].GetUint();
|
||||
// dynamicRange = doc["bitmode"].GetUint();
|
||||
// nPixelsX = doc["shape"][0].GetUint();
|
||||
// nPixelsY = doc["shape"][1].GetUint();
|
||||
filename = doc["fname"].GetString();
|
||||
@ -460,7 +558,7 @@ int main(int argc, char *argv[]) {
|
||||
//detType=doc["detType"].GetUint();
|
||||
//version=doc["version"].GetUint();
|
||||
|
||||
dataSize=size;
|
||||
//dataSize=size;
|
||||
|
||||
strcpy(fname,filename.c_str());
|
||||
|
||||
@ -494,8 +592,8 @@ int main(int argc, char *argv[]) {
|
||||
// flippedDataX, packetNumber, bunchId, timestamp, modId, debug, roundRNumber, detType, version);
|
||||
|
||||
/* Analog detector commands */
|
||||
isPedestal=0;
|
||||
isFlat=0;
|
||||
//isPedestal=0;
|
||||
//isFlat=0;
|
||||
fMode=eFrame;
|
||||
frameMode_s="frame";
|
||||
cprintf(MAGENTA, "Frame mode: ");
|
||||
@ -504,28 +602,28 @@ int main(int argc, char *argv[]) {
|
||||
frameMode_s=doc["frameMode"].GetString();
|
||||
if (frameMode_s == "pedestal"){
|
||||
fMode=ePedestal;
|
||||
isPedestal=1;
|
||||
//isPedestal=1;
|
||||
} else if (frameMode_s == "newPedestal"){
|
||||
mt->newDataSet(); //resets pedestal
|
||||
// cprintf(MAGENTA, "Resetting pedestal\n");
|
||||
fMode=ePedestal;
|
||||
isPedestal=1;
|
||||
//isPedestal=1;
|
||||
}
|
||||
#ifdef INTERP
|
||||
else if (frameMode_s == "flatfield") {
|
||||
fMode=eFlat;
|
||||
isFlat=1;
|
||||
//isFlat=1;
|
||||
} else if (frameMode_s == "newFlatfield") {
|
||||
mt->resetFlatField();
|
||||
isFlat=1;
|
||||
//isFlat=1;
|
||||
cprintf(MAGENTA, "Resetting flatfield\n");
|
||||
fMode=eFlat;
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
fMode=eFrame;
|
||||
isPedestal=0;
|
||||
isFlat=0;
|
||||
//isPedestal=0;
|
||||
//isFlat=0;
|
||||
fMode=eFrame;
|
||||
frameMode_s="frame";
|
||||
}
|
||||
@ -648,6 +746,21 @@ int main(int argc, char *argv[]) {
|
||||
// mt->setNSubPixels(nSubPixels);
|
||||
// }
|
||||
|
||||
// threshold=0;
|
||||
cprintf(MAGENTA, "Subframes: ");
|
||||
subframes=0;
|
||||
//isubframe=0;
|
||||
insubframe=0;
|
||||
subnorm=1;
|
||||
f0=0;
|
||||
nnsubframe=0;
|
||||
if (doc.HasMember("subframes")) {
|
||||
if (doc["subframes"].IsInt()) {
|
||||
subframes=doc["subframes"].GetInt();
|
||||
}
|
||||
}
|
||||
cprintf(MAGENTA, "%ld\n", subframes);
|
||||
|
||||
|
||||
newFrame=0;
|
||||
/* zmqsocket->CloseHeaderMessage();*/
|
||||
@ -657,7 +770,12 @@ int main(int argc, char *argv[]) {
|
||||
// cout << "file" << endl;
|
||||
// cout << "data " << endl;
|
||||
if (of==NULL) {
|
||||
sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex);
|
||||
#ifdef WRITE_QUAD
|
||||
sprintf(ofname,"%s_%ld.clust2",filename.c_str(),fileindex);
|
||||
#endif
|
||||
#ifndef WRITE_QUAD
|
||||
sprintf(ofname,"%s_%ld.clust",filename.c_str(),fileindex);
|
||||
#endif
|
||||
of=fopen(ofname,"w");
|
||||
if (of) {
|
||||
mt->setFilePointer(of);
|
||||
@ -666,31 +784,109 @@ int main(int argc, char *argv[]) {
|
||||
mt->setFilePointer(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// cout << "data" << endl;
|
||||
// get data
|
||||
// acqIndex = doc["acqIndex"].GetUint64();
|
||||
|
||||
frameIndex = doc["fIndex"].GetUint64();
|
||||
|
||||
// subFrameIndex = doc["expLength"].GetUint();
|
||||
|
||||
// bunchId=doc["bunchId"].GetUint();
|
||||
// timestamp=doc["timestamp"].GetUint();
|
||||
packetNumber=doc["packetNumber"].GetUint();
|
||||
// cout << acqIndex << " " << frameIndex << " " << subFrameIndex << " "<< bunchId << " " << timestamp << " " << packetNumber << endl;
|
||||
if (packetNumber>=40) {
|
||||
//*((int*)buff)=frameIndex;
|
||||
memcpy(buff,&frameIndex,sizeof(int));
|
||||
length = zmqsocket->ReceiveData(0, buff+sizeof(int), size);
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
} else {
|
||||
cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber);
|
||||
length = zmqsocket->ReceiveData(0, dummybuff, size);
|
||||
packetNumber=doc["packetNumber"].GetUint();
|
||||
// cout << acqIndex << " " << frameIndex << " " << subFrameIndex << " "<< bunchId << " " << timestamp << " " << packetNumber << endl;
|
||||
if (packetNumber>=40) {
|
||||
//*((int*)buff)=frameIndex;
|
||||
if (insubframe==0) f0=frameIndex;
|
||||
memcpy(buff,&frameIndex,sizeof(int));
|
||||
//length =
|
||||
zmqsocket->ReceiveData(0, buff+sizeof(int), size);
|
||||
mt->pushData(buff);
|
||||
mt->nextThread();
|
||||
mt->popFree(buff);
|
||||
insubframe++;
|
||||
nsubframes=frameIndex+1-f0;
|
||||
} else {
|
||||
cprintf(RED, "Incomplete frame: received only %d packet\n", packetNumber);
|
||||
//length =
|
||||
zmqsocket->ReceiveData(0, dummybuff, size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (subframes>0 && insubframe>=subframes && fMode==eFrame) {
|
||||
while (mt->isBusy()) {;}//wait until all data are processed from the queues
|
||||
detimage=mt->getImage(nnx,nny,nns);
|
||||
cprintf(MAGENTA,"Get image!\n");
|
||||
dout= new int32_t[nnx*nny];
|
||||
doutf= new float[nnx*nny];
|
||||
if (subframes>0 && insubframe!=subframes && insubframe>0)
|
||||
subnorm=((double)subframes)/((double)insubframe);
|
||||
else
|
||||
subnorm=1.;
|
||||
for (int ix=0; ix<nnx*nny; ix++) {
|
||||
dout[ix]=detimage[ix]*subnorm;
|
||||
if (dout[ix]<0) dout[ix]=0;
|
||||
doutf[ix]=dout[ix];
|
||||
}
|
||||
sprintf(ofname,"%s_sf%ld_%ld.tiff",fname,nnsubframe,fileindex);
|
||||
|
||||
cout << "Writing image to " << ofname << endl;
|
||||
|
||||
WriteToTiff(doutf,ofname ,nnx, nny);
|
||||
nsubframes++;
|
||||
insubframe=0;
|
||||
nnsubframe++;
|
||||
|
||||
|
||||
#ifndef DEVELOPER
|
||||
#ifndef MOENCH_BRANCH
|
||||
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, 0,0, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex,0 , packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, additionalJsonHeader);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef DEVELOPER
|
||||
zmqsocket2->SendHeaderData (0, false,SLS_DETECTOR_JSON_HEADER_VERSION , dr, fileindex, 0,0,nnx,nny,nnx*nny*dr/8,acqIndex, frameIndex, fname,acqIndex,0 , packetNumber,bunchId, timestamp, modId,xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, 0,0, 0,additionalJsonHeader);
|
||||
#endif
|
||||
#ifdef MOENCH_BRANCH
|
||||
|
||||
zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
zmqsocket2->SendData((char*)dout,nnx*nny*dr/8);
|
||||
cprintf(GREEN, "Sent subdata\n");
|
||||
|
||||
|
||||
if (dout)
|
||||
delete [] dout;
|
||||
dout=NULL;
|
||||
|
||||
if (doutf)
|
||||
delete [] doutf;
|
||||
doutf=NULL;
|
||||
|
||||
mt->clearImage();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
iframe++;
|
||||
|
@ -1,57 +0,0 @@
|
||||
#include <TPaveText.h>
|
||||
#include <TLegend.h>
|
||||
#include <TF1.h>
|
||||
#include <TGraphErrors.h>
|
||||
#include <TH2F.h>
|
||||
#include <TASImage.h>
|
||||
#include <TImage.h>
|
||||
#include <TFile.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
#include "tiffIO.h"
|
||||
|
||||
#include<iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
/**
|
||||
* trial.o [socket ip] [starting port number] [outfname]
|
||||
*
|
||||
*/
|
||||
|
||||
if (argc<3) {
|
||||
cout << "Wrong usage! Should be: "<< argv[0] << " infile " << " outfile " << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
uint32 nx, ny;
|
||||
|
||||
float *data=ReadFromTiff(argv[1],nx, ny);
|
||||
|
||||
TH2F *h2=NULL;
|
||||
if (data) {
|
||||
TFile *fout=new TFile(argv[2],"RECREATE");
|
||||
if (fout) {
|
||||
h2=new TH2F("h2",argv[1],nx,0,nx,ny,0, ny);
|
||||
for (int ix=0; ix<nx ; ix++) {
|
||||
for (int iy=0; iy<ny ; iy++) {
|
||||
|
||||
h2->SetBinContent(ix+1, iy+1, data[ix+iy*nx]);
|
||||
}
|
||||
}
|
||||
h2->Write();
|
||||
fout->Close();
|
||||
}
|
||||
delete [] data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -32,11 +32,11 @@ class threadedAnalogDetector
|
||||
{
|
||||
public:
|
||||
threadedAnalogDetector(analogDetector<uint16_t> *d, int fs=10000) {
|
||||
char *mem, *mm;
|
||||
char *mm;//*mem,
|
||||
det=d;
|
||||
fifoFree=new CircularFifo<char>(fs);
|
||||
fifoData=new CircularFifo<char>(fs);
|
||||
|
||||
// mem==NULL;
|
||||
/* mem=(char*)calloc(fs, det->getDataSize()); */
|
||||
/* if (mem) */
|
||||
/* memset(mem,0, fs*det->getDataSize()); */
|
||||
@ -46,6 +46,7 @@ public:
|
||||
// mm=mem+i*det->getDataSize();
|
||||
// cout << i << endl;
|
||||
mm=(char*)calloc(1, det->getDataSize());
|
||||
|
||||
if (mm) {
|
||||
//memset(mm,0, det->getDataSize());
|
||||
fifoFree->push(mm);
|
||||
@ -60,7 +61,8 @@ public:
|
||||
fMode=eFrame;
|
||||
ff=NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
virtual int setFrameMode(int fm) {
|
||||
if (fm>=0) {
|
||||
@ -96,11 +98,14 @@ public:
|
||||
virtual int getImageSize(int &nnx, int &nny, int &ns) {return det->getImageSize(nnx, nny, ns);};
|
||||
virtual int getDetectorSize(int &nnx, int &nny) {return det->getDetectorSize(nnx, nny);};
|
||||
|
||||
~threadedAnalogDetector() {StopThread(); free(mem); delete fifoFree; delete fifoData;}
|
||||
virtual ~threadedAnalogDetector() {StopThread(); delete fifoFree; delete fifoData;}
|
||||
|
||||
/** Returns true if the thread was successfully started, false if there was an error starting the thread */
|
||||
virtual bool StartThread()
|
||||
{ stop=0;
|
||||
{ stop=0;
|
||||
cout << "Detector number " << det->getId() << endl;
|
||||
cout << "common mode is " << det->getCommonModeSubtraction()<< endl;
|
||||
cout << "ghost summation is " << det->getGhostSummation()<< endl;
|
||||
return (pthread_create(&_thread, NULL, processData, this) == 0);
|
||||
}
|
||||
|
||||
@ -111,14 +116,20 @@ public:
|
||||
|
||||
|
||||
virtual bool pushData(char* &ptr) {
|
||||
fifoData->push(ptr);
|
||||
return fifoData->push(ptr);
|
||||
}
|
||||
|
||||
virtual bool popFree(char* &ptr) {
|
||||
fifoFree->pop(ptr);
|
||||
return fifoFree->pop(ptr);
|
||||
}
|
||||
|
||||
virtual int isBusy() {return busy;}
|
||||
virtual int isBusy() {
|
||||
if (fifoData->isEmpty())
|
||||
busy=0;
|
||||
else
|
||||
busy=1;
|
||||
return busy;
|
||||
}
|
||||
|
||||
//protected:
|
||||
/** Implement this method in your subclass with the code you want your thread to run. */
|
||||
@ -182,16 +193,19 @@ FILE *getFilePointer(){return det->getFilePointer();};
|
||||
|
||||
void *writeFlatField(const char * imgname) {
|
||||
slsInterpolation *interp=(det)->getInterpolation();
|
||||
cout << "interp " << interp << endl;
|
||||
//cout << "interp " << interp << endl;
|
||||
if (interp) {
|
||||
cout << imgname << endl;
|
||||
interp->writeFlatField(imgname);
|
||||
return interp->writeFlatField(imgname);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){
|
||||
slsInterpolation *interp=(det)->getInterpolation();
|
||||
if (interp)
|
||||
interp->readFlatField(imgname, nb, emin, emax);
|
||||
return interp->readFlatField(imgname, nb, emin, emax);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
virtual int *getFlatField(int &nb, double emi, double ema){
|
||||
@ -213,10 +227,11 @@ FILE *getFilePointer(){return det->getFilePointer();};
|
||||
}
|
||||
|
||||
|
||||
virtual int setNSubPixels(int ns) {
|
||||
virtual void setNSubPixels(int ns, int nsy=-1) {
|
||||
slsInterpolation *interp=(det)->getInterpolation();
|
||||
if (interp) return interp->setNSubPixels(ns);
|
||||
else return 1;};
|
||||
if (interp) interp->setNSubPixels(ns, nsy);
|
||||
//else return 1;
|
||||
};
|
||||
|
||||
|
||||
virtual slsInterpolation *setInterpolation(slsInterpolation *f){
|
||||
@ -228,7 +243,6 @@ protected:
|
||||
int dMode;
|
||||
int *dataSize;
|
||||
pthread_t _thread;
|
||||
char *mem;
|
||||
CircularFifo<char> *fifoFree;
|
||||
CircularFifo<char> *fifoData;
|
||||
int stop;
|
||||
@ -242,13 +256,13 @@ protected:
|
||||
}
|
||||
|
||||
void * processData() {
|
||||
busy=1;
|
||||
// busy=1;
|
||||
while (!stop) {
|
||||
if (fifoData->isEmpty()) {
|
||||
busy=0;
|
||||
// busy=0;
|
||||
usleep(100);
|
||||
} else {
|
||||
busy=1;
|
||||
// busy=1;
|
||||
fifoData->pop(data); //blocking!
|
||||
det->processData(data);
|
||||
fifoFree->push(data);
|
||||
@ -292,15 +306,15 @@ public:
|
||||
StopThreads();
|
||||
for (int i=0; i<nThreads; i++)
|
||||
delete dets[i];
|
||||
for (int i=1; i<nThreads; i++)
|
||||
delete dd[i];
|
||||
/* for (int i=1; i<nThreads; i++) */
|
||||
/* delete dd[i]; */
|
||||
//delete [] image;
|
||||
}
|
||||
|
||||
|
||||
virtual int setFrameMode(int fm) { int ret; for (int i=0; i<nThreads; i++) { ret=dets[i]->setFrameMode(fm);} return ret;};
|
||||
virtual double setThreshold(int fm) { double ret; for (int i=0; i<nThreads; i++) ret=dets[i]->setThreshold(fm); return ret;};
|
||||
virtual int setDetectorMode(int dm) { int ret; for (int i=0; i<nThreads; i++) ret=dets[i]->setDetectorMode(dm); return ret;};
|
||||
virtual int setFrameMode(int fm) { int ret=dets[0]->setFrameMode(fm); for (int i=1; i<nThreads; i++) { dets[i]->setFrameMode(fm);} return ret;};
|
||||
virtual double setThreshold(int fm) { double ret=dets[0]->setThreshold(fm); for (int i=1; i<nThreads; i++) dets[i]->setThreshold(fm); return ret;};
|
||||
virtual int setDetectorMode(int dm) { int ret=dets[0]->setDetectorMode(dm);; for (int i=1; i<nThreads; i++) dets[i]->setDetectorMode(dm); return ret;};
|
||||
virtual void setROI(int xmin, int xmax, int ymin, int ymax) { for (int i=0; i<nThreads; i++) dets[i]->setROI(xmin, xmax,ymin,ymax);};
|
||||
|
||||
|
||||
@ -324,8 +338,11 @@ public:
|
||||
img=dets[ii]->getImage();
|
||||
for (int i=0; i<nn; i++) {
|
||||
if (ii==0)
|
||||
image[i]=img[i];
|
||||
else
|
||||
// if (img[i]>0)
|
||||
image[i]=img[i];
|
||||
// else
|
||||
// image[i]=0;
|
||||
else //if (img[i]>0)
|
||||
image[i]+=img[i];
|
||||
//if (img[i]) cout << "det " << ii << " pix " << i << " val " << img[i] << " " << image[i] << endl;
|
||||
}
|
||||
@ -359,11 +376,14 @@ public:
|
||||
float *gm=new float[nn];
|
||||
if (gm) {
|
||||
for (int ix=0; ix<nn; ix++) {
|
||||
if (t)
|
||||
gm[ix]=(image[ix])/t;
|
||||
else
|
||||
if (t) {
|
||||
if (image[ix]<0)
|
||||
gm[ix]=0;
|
||||
else
|
||||
gm[ix]=(image[ix])/t;
|
||||
} else
|
||||
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;
|
||||
@ -402,12 +422,12 @@ public:
|
||||
|
||||
|
||||
virtual bool pushData(char* &ptr) {
|
||||
dets[ithread]->pushData(ptr);
|
||||
return dets[ithread]->pushData(ptr);
|
||||
}
|
||||
|
||||
virtual bool popFree(char* &ptr) {
|
||||
// cout << ithread << endl;
|
||||
dets[ithread]->popFree(ptr);
|
||||
return dets[ithread]->popFree(ptr);
|
||||
}
|
||||
|
||||
virtual int nextThread() {
|
||||
@ -487,20 +507,21 @@ public:
|
||||
|
||||
virtual void *readPedestal(const char * imgname, int nb=-1, double emin=1, double emax=0){
|
||||
|
||||
int nx, ny;
|
||||
dets[0]->getDetectorSize(nx,ny);
|
||||
int nx, ny;
|
||||
dets[0]->getDetectorSize(nx,ny);
|
||||
uint32 nnx;
|
||||
uint32 nny;
|
||||
float *gm=ReadFromTiff(imgname, nnx, nny);
|
||||
if (ped) delete [] ped;
|
||||
if (nnx>nx) nx=nnx;
|
||||
if (nny>ny) ny=nny;
|
||||
if (nnx>(uint)nx) nx=nnx;
|
||||
if (nny>(uint)ny) ny=nny;
|
||||
ped=new double[nx*ny];
|
||||
|
||||
for (int ix=0; ix<nx*ny; ix++) {
|
||||
ped[ix]=gm[ix];
|
||||
}
|
||||
delete [] gm;
|
||||
|
||||
return setPedestal();
|
||||
|
||||
};
|
||||
|
@ -25,7 +25,7 @@ class multiThreadedCountingDetector : public multiThreadedAnalogDetector
|
||||
public:
|
||||
multiThreadedCountingDetector(singlePhotonDetector *d, int n, int fs=1000) : multiThreadedAnalogDetector(d,n,fs) { };
|
||||
|
||||
virtual double setNSigma(double n) {double ret; for (int i=0; i<nThreads; i++) ret=(dets[i])->setNSigma(n); return ret;};
|
||||
virtual double setNSigma(double n) {double ret=(dets[0])->setNSigma(n); for (int i=1; i<nThreads; i++) (dets[i])->setNSigma(n); return ret;};
|
||||
virtual void setEnergyRange(double emi, double ema) {for (int i=0; i<nThreads; i++) (dets[i])->setEnergyRange(emi,ema);};
|
||||
|
||||
};
|
||||
|
@ -37,12 +37,12 @@ public:
|
||||
};
|
||||
|
||||
void *writeFlatField(const char * imgname){
|
||||
dets[0]->writeFlatField(imgname);
|
||||
return dets[0]->writeFlatField(imgname);
|
||||
};
|
||||
|
||||
|
||||
void *readFlatField(const char * imgname, int nb=-1, double emin=1, double emax=0){
|
||||
(dets[0])->readFlatField(imgname, nb, emin, emax);
|
||||
return (dets[0])->readFlatField(imgname, nb, emin, emax);
|
||||
};
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ public:
|
||||
\returns current file pointer
|
||||
*/
|
||||
virtual slsInterpolation *setInterpolation(slsInterpolation *f){
|
||||
int ok;
|
||||
//int ok;
|
||||
for (int i=0; i<nThreads; i++)
|
||||
(dets[i])->setInterpolation(f);
|
||||
return (dets[0])->getInterpolation();
|
||||
|
@ -58,7 +58,7 @@ public analogDetector<uint16_t> {
|
||||
int sign=1,
|
||||
commonModeSubtraction *cm=NULL,
|
||||
int nped=1000,
|
||||
int nd=100, int nnx=-1, int nny=-1, double *gm=NULL) : analogDetector<uint16_t>(d, sign, cm, nped, nnx, nny, gm), nDark(nd), eventMask(NULL),nSigma (nsigma), clusterSize(csize), clusterSizeY(csize), clusters(NULL), quad(UNDEFINED_QUADRANT), tot(0), quadTot(0), eMin(-1), eMax(-1) {
|
||||
int nd=100, int nnx=-1, int nny=-1, double *gm=NULL, ghostSummation<uint16_t> *gs=NULL) : analogDetector<uint16_t>(d, sign, cm, nped, nnx, nny, gm, gs), nDark(nd), eventMask(NULL),nSigma (nsigma), eMin(-1), eMax(-1), clusterSize(csize), clusterSizeY(csize), clusters(NULL), quad(UNDEFINED_QUADRANT), tot(0), quadTot(0) {
|
||||
|
||||
|
||||
|
||||
@ -183,13 +183,13 @@ public analogDetector<uint16_t> {
|
||||
//nph=new int[nx*ny];
|
||||
|
||||
double rest[ny][nx];
|
||||
int cy=(clusterSizeY+1)/2; //quad size
|
||||
int cs=(clusterSize+1)/2; //quad size
|
||||
//int cy=(clusterSizeY+1)/2; //quad size
|
||||
//int cs=(clusterSize+1)/2; //quad size
|
||||
|
||||
int ccs=clusterSize; //cluster size
|
||||
int ccy=clusterSizeY; //cluster size
|
||||
//int ccs=clusterSize; //cluster size
|
||||
//int ccy=clusterSizeY; //cluster size
|
||||
|
||||
double g=1.;
|
||||
//double g=1.;
|
||||
|
||||
|
||||
double tthr=thr, tthr1, tthr2;
|
||||
@ -201,10 +201,10 @@ public analogDetector<uint16_t> {
|
||||
if (cmSub) cm=1;
|
||||
|
||||
if (thr>0) {
|
||||
cy=1;
|
||||
cs=1;
|
||||
ccs=1;
|
||||
ccy=1;
|
||||
//cy=1;
|
||||
//cs=1;
|
||||
//ccs=1;
|
||||
//ccy=1;
|
||||
}
|
||||
if (iframe<nDark) {
|
||||
// cout << "ped " << iframe << endl;
|
||||
@ -213,7 +213,7 @@ public analogDetector<uint16_t> {
|
||||
return nph;
|
||||
} else {
|
||||
if (thr>0) {
|
||||
newFrame();
|
||||
newFrame(data);
|
||||
if (cmSub) {
|
||||
cout << "add to common mode?"<< endl;
|
||||
addToCommonMode(data);
|
||||
@ -349,9 +349,9 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
double val[ny][nx];
|
||||
int cy=(clusterSizeY+1)/2;
|
||||
int cs=(clusterSize+1)/2;
|
||||
int ir, ic;
|
||||
//int ir, ic;
|
||||
|
||||
double max=0, tl=0, tr=0, bl=0,br=0, *v, vv;
|
||||
double max=0, tl=0, tr=0, bl=0,br=0, *v;
|
||||
int cm=0;
|
||||
int good=1;
|
||||
if (cmSub) cm=1;
|
||||
@ -362,7 +362,7 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
addToPedestal(data);
|
||||
return 0;
|
||||
}
|
||||
newFrame();
|
||||
newFrame(data);
|
||||
|
||||
|
||||
|
||||
@ -592,7 +592,7 @@ int *getClusters(char *data, int *ph=NULL) {
|
||||
switch(fMode) {
|
||||
case ePedestal:
|
||||
//cout <<"spc add to ped " << endl;
|
||||
addToPedestal(data);
|
||||
addToPedestal(data,1);
|
||||
break;
|
||||
default:
|
||||
switch (dMode) {
|
||||
|
@ -119,44 +119,44 @@ class single_photon_hit {
|
||||
if (fread((void*)qq, 1, 4*sizeof(int), myFile)) {
|
||||
|
||||
quad=TOP_RIGHT;
|
||||
int mm=qq[0];
|
||||
for (int i=1; i<4; i++) {
|
||||
if (qq[i]<mm) {
|
||||
switch (i) {
|
||||
case 1:
|
||||
quad=TOP_LEFT;
|
||||
break;
|
||||
case 2:
|
||||
quad=BOTTOM_RIGHT;
|
||||
break;
|
||||
case 3:
|
||||
quad=BOTTOM_LEFT;
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
/* int mm=qq[0]; */
|
||||
/* for (int i=1; i<4; i++) { */
|
||||
/* if (qq[i]>mm) { */
|
||||
/* switch (i) { */
|
||||
/* case 1: */
|
||||
/* quad=TOP_LEFT; */
|
||||
/* break; */
|
||||
/* case 2: */
|
||||
/* quad=BOTTOM_RIGHT; */
|
||||
/* break; */
|
||||
/* case 3: */
|
||||
/* quad=BOTTOM_LEFT; */
|
||||
/* break; */
|
||||
/* default: */
|
||||
/* ; */
|
||||
/* } */
|
||||
|
||||
}
|
||||
/* } */
|
||||
|
||||
}
|
||||
/* } */
|
||||
|
||||
|
||||
switch(quad) {
|
||||
case TOP_LEFT:
|
||||
data[0]=0;
|
||||
data[1]=0;
|
||||
data[2]=0;
|
||||
data[3]=qq[0];
|
||||
data[4]=qq[1];
|
||||
data[5]=0;
|
||||
data[6]=qq[2];
|
||||
data[7]=qq[3];
|
||||
data[8]=0;
|
||||
x=x+1;
|
||||
y=y;
|
||||
break;
|
||||
/* switch(quad) { */
|
||||
/* case TOP_LEFT: */
|
||||
/* data[0]=0; */
|
||||
/* data[1]=0; */
|
||||
/* data[2]=0; */
|
||||
/* data[3]=qq[0]; */
|
||||
/* data[4]=qq[1]; */
|
||||
/* data[5]=0; */
|
||||
/* data[6]=qq[2]; */
|
||||
/* data[7]=qq[3]; */
|
||||
/* data[8]=0; */
|
||||
/* x=x+1; */
|
||||
/* y=y; */
|
||||
/* break; */
|
||||
|
||||
case TOP_RIGHT:
|
||||
/* case TOP_RIGHT: */
|
||||
data[0]=0;
|
||||
data[1]=0;
|
||||
data[2]=0;
|
||||
@ -168,40 +168,40 @@ class single_photon_hit {
|
||||
data[8]=qq[3];
|
||||
x=x;
|
||||
y=y;
|
||||
break;
|
||||
/* break; */
|
||||
|
||||
|
||||
case BOTTOM_LEFT:
|
||||
data[0]=qq[0];
|
||||
data[1]=qq[1];
|
||||
data[2]=0;
|
||||
data[3]=qq[2];
|
||||
data[4]=qq[3];
|
||||
data[5]=0;
|
||||
data[6]=0;
|
||||
data[7]=0;
|
||||
data[8]=0;
|
||||
x=x+1;
|
||||
y=y+1;
|
||||
break;
|
||||
case BOTTOM_RIGHT:
|
||||
data[0]=0;
|
||||
data[1]=qq[0];
|
||||
data[2]=qq[1];
|
||||
data[3]=0;
|
||||
data[4]=qq[2];
|
||||
data[5]=qq[3];
|
||||
data[6]=0;
|
||||
data[7]=0;
|
||||
data[8]=0;
|
||||
x=x;
|
||||
y=y+1;
|
||||
break;
|
||||
/* case BOTTOM_LEFT: */
|
||||
/* data[0]=qq[0]; */
|
||||
/* data[1]=qq[1]; */
|
||||
/* data[2]=0; */
|
||||
/* data[3]=qq[2]; */
|
||||
/* data[4]=qq[3]; */
|
||||
/* data[5]=0; */
|
||||
/* data[6]=0; */
|
||||
/* data[7]=0; */
|
||||
/* data[8]=0; */
|
||||
/* x=x+1; */
|
||||
/* y=y+1; */
|
||||
/* break; */
|
||||
/* case BOTTOM_RIGHT: */
|
||||
/* data[0]=0; */
|
||||
/* data[1]=qq[0]; */
|
||||
/* data[2]=qq[1]; */
|
||||
/* data[3]=0; */
|
||||
/* data[4]=qq[2]; */
|
||||
/* data[5]=qq[3]; */
|
||||
/* data[6]=0; */
|
||||
/* data[7]=0; */
|
||||
/* data[8]=0; */
|
||||
/* x=x; */
|
||||
/* y=y+1; */
|
||||
/* break; */
|
||||
|
||||
|
||||
default:
|
||||
;
|
||||
}
|
||||
/* default: */
|
||||
/* ; */
|
||||
/* } */
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
@ -211,8 +211,8 @@ class single_photon_hit {
|
||||
|
||||
void print() {
|
||||
|
||||
int ix, iy;
|
||||
|
||||
// int ix, iy;
|
||||
printf("*** %d %d %d\n",iframe, x, y);
|
||||
for (int iy=0; iy<dy; iy++) {
|
||||
for (int ix=0; ix<dx; ix++) {
|
||||
printf("%d \t",data[ix+iy*dx]);
|
||||
@ -220,7 +220,7 @@ class single_photon_hit {
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
printf("***\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,98 +0,0 @@
|
||||
#ifndef SINGLE_PHOTON_HIT_H
|
||||
#define SINGLE_PHOTON_HIT_H
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
typedef int int32_t;
|
||||
|
||||
#ifndef DEF_QUAD
|
||||
#define DEF_QUAD
|
||||
enum quadrant {
|
||||
TOP_LEFT=0,
|
||||
TOP_RIGHT=1,
|
||||
BOTTOM_LEFT=2,
|
||||
BOTTOM_RIGHT=3,
|
||||
UNDEFINED_QUADRANT=-1
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
class single_photon_hit_double {
|
||||
|
||||
/** @short Structure for a single photon hit */
|
||||
|
||||
public:
|
||||
/** constructor, instantiates the data array -- all class elements are public!
|
||||
\param nx cluster size in x direction
|
||||
\param ny cluster size in y direction (defaults to 1 for 1D detectors)
|
||||
*/
|
||||
single_photon_hit_double(int nx=3, int ny=3): dx(nx), dy(ny) {
|
||||
data=new double[dx*dy];
|
||||
};
|
||||
|
||||
~single_photon_hit_double(){delete [] data;}; /**< destructor, deletes the data array */
|
||||
|
||||
/** binary write to file of all elements of the structure, except size of the cluster
|
||||
\param myFile file descriptor
|
||||
*/
|
||||
size_t write(FILE *myFile) {
|
||||
//fwrite((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile);
|
||||
if (fwrite((void*)this, 1, sizeof(int)+2*sizeof(int), myFile))
|
||||
return fwrite((void*)data, 1, dx*dy*sizeof(double), myFile);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
binary read from file of all elements of the structure, except size of the cluster. The structure is then filled with those args
|
||||
\param myFile file descriptor
|
||||
*/
|
||||
size_t read(FILE *myFile) {
|
||||
//fread((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile);
|
||||
|
||||
if (fread((void*)this, 1, sizeof(int)+2*sizeof(int), myFile))
|
||||
return fread((void*)data, 1, dx*dy*sizeof(double), myFile);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
assign the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0)
|
||||
\param v value to be set
|
||||
\param ix coordinate x within the cluster (center is (0,0))
|
||||
\param iy coordinate y within the cluster (center is (0,0))
|
||||
*/
|
||||
void set_data(double v, int ix, int iy=0){data[(iy+dy/2)*dx+ix+dx/2]=v;};
|
||||
|
||||
void set_cluster_size(int nx, int ny) {
|
||||
|
||||
if (nx>0) dx=nx; if (ny>0) dy=ny; delete [] data; data=new double[dx*dy];
|
||||
};
|
||||
void get_cluster_size(int &nx, int &ny) {nx=dx; ny=dy;};
|
||||
void get_pixel(int &x1, int &y1) {x1=x; y1=y;};
|
||||
|
||||
/**
|
||||
gets the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0)
|
||||
\param ix coordinate x within the cluster (center is (0,0))
|
||||
\param iy coordinate y within the cluster (center is (0,0))
|
||||
\returns value of the cluster element
|
||||
*/
|
||||
double get_data(int ix, int iy=0){return data[(iy+dy/2)*dx+ix+dx/2];};
|
||||
double *get_cluster() {return data;};
|
||||
|
||||
int iframe; /**< frame number */
|
||||
int x; /**< x-coordinate of the center of hit */
|
||||
int y; /**< x-coordinate of the center of hit */
|
||||
double rms; /**< noise of central pixel l -- at some point it can be removed*/
|
||||
double ped; /**< pedestal of the central pixel -- at some point it can be removed*/
|
||||
double tot; /**< sum of the 3x3 cluster */
|
||||
quadrant quad; /**< quadrant where the photon is located */
|
||||
double quadTot; /**< sum of the maximum 2x2cluster */
|
||||
int dx; /**< size of data cluster in x */
|
||||
int dy; /**< size of data cluster in y */
|
||||
double *data; /**< pointer to data */
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,93 +0,0 @@
|
||||
#ifndef SINGLE_PHOTON_HIT_H
|
||||
#define SINGLE_PHOTON_HIT_H
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef double double32_t;
|
||||
typedef float float32_t;
|
||||
typedef int int32_t;
|
||||
|
||||
#ifndef DEF_QUAD
|
||||
#define DEF_QUAD
|
||||
enum quadrant {
|
||||
TOP_LEFT=0,
|
||||
TOP_RIGHT=1,
|
||||
BOTTOM_LEFT=2,
|
||||
BOTTOM_RIGHT=3,
|
||||
UNDEFINED_QUADRANT=-1
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
class single_photon_hit {
|
||||
|
||||
/** @short Structure for a single photon hit */
|
||||
|
||||
public:
|
||||
/** constructor, instantiates the data array -- all class elements are public!
|
||||
\param nx cluster size in x direction
|
||||
\param ny cluster size in y direction (defaults to 1 for 1D detectors)
|
||||
*/
|
||||
single_photon_hit(int nx=3, int ny=3): dx(nx), dy(ny) {data=new int[dx*dy];};
|
||||
|
||||
~single_photon_hit(){delete [] data;}; /**< destructor, deletes the data array */
|
||||
|
||||
/** binary write to file of all elements of the structure, except size of the cluster
|
||||
\param myFile file descriptor
|
||||
*/
|
||||
size_t write(FILE *myFile) {
|
||||
//fwrite((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile);
|
||||
if (fwrite((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile))
|
||||
return fwrite((void*)data, 1, dx*dy*sizeof(int), myFile);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
binary read from file of all elements of the structure, except size of the cluster. The structure is then filled with those args
|
||||
\param myFile file descriptor
|
||||
*/
|
||||
size_t read(FILE *myFile) {
|
||||
//fread((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile);
|
||||
|
||||
if (fread((void*)this, 1, sizeof(int)+2*sizeof(int16_t), myFile))
|
||||
return fread((void*)data, 1, dx*dy*sizeof(int), myFile);
|
||||
return 0;
|
||||
};
|
||||
|
||||
/**
|
||||
assign the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0)
|
||||
\param v value to be set
|
||||
\param ix coordinate x within the cluster (center is (0,0))
|
||||
\param iy coordinate y within the cluster (center is (0,0))
|
||||
*/
|
||||
void set_data(double v, int ix, int iy=0){data[(iy+dy/2)*dx+ix+dx/2]=v;};
|
||||
|
||||
void set_cluster_size(int nx, int ny) {if (nx>0) dx=nx; if (ny>0) dy=ny; delete [] data; data=new int[dx*dy];};
|
||||
void get_cluster_size(int &nx, int &ny) {nx=dx; ny=dy;};
|
||||
void get_pixel(int &x1, int &y1) {x1=x; y1=y;};
|
||||
|
||||
/**
|
||||
gets the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0)
|
||||
\param ix coordinate x within the cluster (center is (0,0))
|
||||
\param iy coordinate y within the cluster (center is (0,0))
|
||||
\returns value of the cluster element
|
||||
*/
|
||||
double get_data(int ix, int iy=0){return data[(iy+dy/2)*dx+ix+dx/2];};
|
||||
int *get_cluster() {return data;};
|
||||
|
||||
int iframe; /**< frame number */
|
||||
int16_t x; /**< x-coordinate of the center of hit */
|
||||
int16_t y; /**< x-coordinate of the center of hit */
|
||||
double rms; /**< noise of central pixel l -- at some point it can be removed*/
|
||||
double ped; /**< pedestal of the central pixel -- at some point it can be removed*/
|
||||
double tot; /**< sum of the 3x3 cluster */
|
||||
quadrant quad; /**< quadrant where the photon is located */
|
||||
double quadTot; /**< sum of the maximum 2x2cluster */
|
||||
int dx; /**< size of data cluster in x */
|
||||
int dy; /**< size of data cluster in y */
|
||||
int *data; /**< pointer to data */
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -1,103 +0,0 @@
|
||||
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
|
||||
# documentation are documented, even if no documentation was available.
|
||||
# Private class members and static file members will be hidden unless
|
||||
# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES
|
||||
|
||||
EXTRACT_ALL = YES
|
||||
|
||||
# If the EXTRACT_PRIVATE tag is set to YES all private members of a class
|
||||
# will be included in the documentation.
|
||||
|
||||
EXTRACT_PRIVATE = NO
|
||||
|
||||
|
||||
|
||||
# If the EXTRACT_STATIC tag is set to YES all static members of a file
|
||||
# will be included in the documentation.
|
||||
|
||||
EXTRACT_STATIC = YES
|
||||
|
||||
# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs)
|
||||
# defined locally in source files will be included in the documentation.
|
||||
# If set to NO only classes defined in header files are included.
|
||||
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
|
||||
# This flag is only useful for Objective-C code. When set to YES local
|
||||
# methods, which are defined in the implementation section but not in
|
||||
# the interface are included in the documentation.
|
||||
# If set to NO (the default) only methods in the interface are included.
|
||||
|
||||
EXTRACT_LOCAL_METHODS = YES
|
||||
|
||||
# If this flag is set to YES, the members of anonymous namespaces will be
|
||||
# extracted and appear in the documentation as a namespace called
|
||||
# 'anonymous_namespace{file}', where file will be replaced with the base
|
||||
# name of the file that contains the anonymous namespace. By default
|
||||
# anonymous namespace are hidden.
|
||||
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
|
||||
# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all
|
||||
# undocumented members of documented classes, files or namespaces.
|
||||
# If set to NO (the default) these members will be included in the
|
||||
# various overviews, but no documentation section is generated.
|
||||
# This option has no effect if EXTRACT_ALL is enabled.
|
||||
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
|
||||
# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all
|
||||
# undocumented classes that are normally visible in the class hierarchy.
|
||||
# If set to NO (the default) these classes will be included in the various
|
||||
# overviews. This option has no effect if EXTRACT_ALL is enabled.
|
||||
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
|
||||
# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all
|
||||
# friend (class|struct|union) declarations.
|
||||
# If set to NO (the default) these declarations will be included in the
|
||||
# documentation.
|
||||
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
|
||||
INTERNAL_DOCS = NO
|
||||
|
||||
SHOW_INCLUDE_FILES = NO
|
||||
|
||||
SHOW_FILES = NO
|
||||
|
||||
SHOW_NAMESPACES = NO
|
||||
|
||||
COMPACT_LATEX = YES
|
||||
|
||||
PAPER_TYPE = a4
|
||||
|
||||
PDF_HYPERLINKS = YES
|
||||
|
||||
USE_PDFLATEX = YES
|
||||
|
||||
LATEX_HIDE_INDICES = YES
|
||||
|
||||
PREDEFINED = __cplusplus
|
||||
|
||||
INPUT = analogDetector.h \
|
||||
pedestalSubtraction.h \
|
||||
MovingStat.h \
|
||||
singlePhotonDetector.h \
|
||||
interpolatingDetector.h tiffIO.h \
|
||||
single_photon_hit.h \
|
||||
dataStructures/slsDetectorData.h \
|
||||
commonModeSubtraction.h \
|
||||
RunningStat.h \
|
||||
interpolations/etaInterpolationBase.h \
|
||||
interpolations/slsInterpolation.h \
|
||||
interpolations/etaInterpolationPosXY.h \
|
||||
interpolations/linearInterpolation.h \
|
||||
interpolations/noInterpolation.h \
|
||||
interpolations/etaInterpolationGlobal.h \
|
||||
multiThreadedAnalogDetector.h
|
||||
|
||||
|
||||
OUTPUT_DIRECTORY = slsDetectorCalibrationDocs
|
||||
|
||||
#moench03Ctb10GbT1Data.h moench03TCtbData.h moench03T1CtbData.h moench03CtbData.h moench03Ctb10GbData.h moench03TCtb10GbData.h Mythen3_01_jctbData.h adcSar2_jctbData.h eigerHalfModuleData.h energyCalibration.h slsReceiverData.h gotthardModuleData.h gotthardShortModuleData.h jungfrau02Data.h jungfrau10ModuleData.h moench02Ctb10GbData.h moench02CtbData.h moench02ModuleData.h moench03CommonMode.h moenchCommonMode.h chiptestBoardData.h interpolation/etaVEL/interpolation_EtaVEL.h interpolation/etaVEL/EtaVEL.h etaVEL/iterativeEtaInterpolation.h dataStructures/moench03T1ZmqData.h
|
@ -4,20 +4,20 @@
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
// #undef cbf_failnez
|
||||
// #define cbf_failnez(x) \
|
||||
// { \
|
||||
// int err; \
|
||||
// err = (x); \
|
||||
// if (err) { \
|
||||
// fprintf(stderr,"\nCBFlib fatal error %x \n",err); \
|
||||
// exit(-1); \
|
||||
// } \
|
||||
// #define cbf_failnez(x)
|
||||
// {
|
||||
// int err;
|
||||
// err = (x);
|
||||
// if (err) {
|
||||
// fprintf(stderr,"\nCBFlib fatal error %x \n",err);
|
||||
// exit(-1);
|
||||
// }
|
||||
// }
|
||||
|
||||
void *WriteToTiff(float * imgData, const char * imgname, int nrow, int ncol){
|
||||
void *WriteToTiff(float * imgData, const char * imgname, int ncol, int nrow){
|
||||
int sampleperpixel=1;
|
||||
// unsigned char * buff=NULL;
|
||||
tsize_t linebytes;
|
||||
//tsize_t linebytes;
|
||||
// cout << "--" <<endl;
|
||||
TIFF * tif = TIFFOpen(imgname,"w");
|
||||
if (tif) {
|
||||
@ -30,7 +30,7 @@ void *WriteToTiff(float * imgData, const char * imgname, int nrow, int ncol){
|
||||
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISBLACK);
|
||||
TIFFSetField(tif, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_IEEEFP);
|
||||
|
||||
linebytes = sampleperpixel*ncol;
|
||||
//linebytes = sampleperpixel*ncol;
|
||||
TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tif, ncol*sampleperpixel));
|
||||
for(int irow=0; irow<nrow; irow++){
|
||||
TIFFWriteScanline(tif,&imgData[irow*ncol],irow,0);
|
||||
@ -43,14 +43,14 @@ void *WriteToTiff(float * imgData, const char * imgname, int nrow, int ncol){
|
||||
return NULL;
|
||||
};
|
||||
|
||||
float *ReadFromTiff( const char * imgname, uint32 &nrow, uint32 &ncol){
|
||||
float *ReadFromTiff( const char * imgname, uint32 &ncol, uint32 &nrow){
|
||||
// unsigned char * buff=NULL;
|
||||
|
||||
TIFF * tif = TIFFOpen(imgname,"r");
|
||||
if (tif){
|
||||
uint32 bps;
|
||||
uint32 sampleperpixel=1;
|
||||
tsize_t linebytes;
|
||||
//tsize_t linebytes;
|
||||
|
||||
uint32 imagelength;
|
||||
|
||||
@ -61,9 +61,9 @@ float *ReadFromTiff( const char * imgname, uint32 &nrow, uint32 &ncol){
|
||||
TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &imagelength);
|
||||
|
||||
float * imgData=new float[ncol*nrow];
|
||||
linebytes = sampleperpixel*ncol;
|
||||
//linebytes = sampleperpixel*ncol;
|
||||
// TIFFSetField(tif, TIFFTAG_ROWSPERSTRIP, TIFFDefaultStripSize(tif, ncol*sampleperpixel));
|
||||
for(int irow=0; irow<nrow; irow++){
|
||||
for(uint32 irow=0; irow<nrow; irow++){
|
||||
//tiffreadscanline(tif, buf, row);
|
||||
TIFFReadScanline(tif,&imgData[irow*ncol],irow);
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ enum networkParameter {
|
||||
/**
|
||||
type of action performed (for text client)
|
||||
*/
|
||||
enum {GET_ACTION, PUT_ACTION, READOUT_ACTION, HELP_ACTION};
|
||||
enum {GET_ACTION, PUT_ACTION, READOUT_ACTION, HELP_ACTION, PROCESS_ACTION};
|
||||
|
||||
/** online flags enum \sa setOnline*/
|
||||
enum {GET_ONLINE_FLAG=-1, /**< returns wether the detector is in online or offline state */
|
||||
|
@ -8,10 +8,14 @@
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
int progressCallback(double f,void* arg) { cout << f << "%"<< endl; return 0;};
|
||||
int dummyAcquisitionFinished(double prog,int status,void* p){cout <<"Acquisition finished callback! " << prog << " " << status << endl; return 0;};
|
||||
int dummyMeasurementFinished(int im,int findex,void* p){cout <<"Measurement finished callback! " << im << " " << findex << endl; return 0;};
|
||||
|
||||
|
||||
int dummyCallback(detectorData* d, int p,void*) {
|
||||
cout << "got data " << p << endl;
|
||||
//int (*)(detectorData*, int, int, void*)
|
||||
int dummyCallback(detectorData*, int p , int p1, void*) {
|
||||
cout << p << endl;
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
@ -25,7 +29,8 @@ public:
|
||||
bool verify = true, update = true; \
|
||||
int del = 0; \
|
||||
char cmd[100] = ""; \
|
||||
|
||||
|
||||
|
||||
if (action==slsDetectorDefs::PUT_ACTION && argc<2) { \
|
||||
cout << "Wrong usage - should be: "<< argv[0] << \
|
||||
"[id-][pos:]channel arg" << endl; \
|
||||
@ -41,7 +46,9 @@ public:
|
||||
return; \
|
||||
}; \
|
||||
|
||||
if (action==slsDetectorDefs::READOUT_ACTION) { \
|
||||
|
||||
|
||||
if (action==slsDetectorDefs::READOUT_ACTION || action==slsDetectorDefs::PROCESS_ACTION) { \
|
||||
id = 0; \
|
||||
pos = -1; \
|
||||
if (argc) { \
|
||||
@ -125,6 +132,18 @@ public:
|
||||
del=1; \
|
||||
} \
|
||||
|
||||
|
||||
if (action==slsDetectorDefs::PROCESS_ACTION) {
|
||||
|
||||
|
||||
/* myDetector->registerAcquisitionFinishedCallback(&dummyAcquisitionFinished,NULL); */
|
||||
/* myDetector->registerMeasurementFinishedCallback(&dummyMeasurementFinished,NULL); */
|
||||
action=slsDetectorDefs::READOUT_ACTION;
|
||||
myDetector->registerDataCallback(&dummyCallback, NULL);
|
||||
|
||||
// myDetector->registerProgressCallback(&progressCallback, NULL);
|
||||
}
|
||||
|
||||
// call multi detector command line
|
||||
myCmd=new multiSlsDetectorCommand(myDetector); \
|
||||
try { \
|
||||
@ -142,9 +161,9 @@ public:
|
||||
} \
|
||||
if (action!=slsDetectorDefs::READOUT_ACTION) { \
|
||||
cout << argv[0] << " " ; \
|
||||
} \
|
||||
} \
|
||||
cout << answer<< endl; \
|
||||
delete myCmd; \
|
||||
delete myCmd; \
|
||||
if (del) delete myDetector; \
|
||||
};
|
||||
|
||||
|
@ -54,6 +54,20 @@ set_target_properties(sls_detector_acquire PROPERTIES
|
||||
COMPILE_DEFINITIONS READOUT=1
|
||||
)
|
||||
|
||||
add_executable(sls_detector_process
|
||||
${SOURCES}
|
||||
)
|
||||
target_link_libraries(sls_detector_process
|
||||
slsDetectorShared
|
||||
pthread
|
||||
zmq
|
||||
rt
|
||||
)
|
||||
set_target_properties(sls_detector_process PROPERTIES
|
||||
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
|
||||
COMPILE_DEFINITIONS PROCESS=1
|
||||
)
|
||||
|
||||
add_executable(sls_detector_help
|
||||
${SOURCES}
|
||||
)
|
||||
|
@ -24,7 +24,7 @@ all: clients
|
||||
|
||||
nonstatic: clients
|
||||
|
||||
clients: builddir lib $(DESTDIR)/sls_detector_put $(DESTDIR)/sls_detector_get $(DESTDIR)/sls_detector_acquire $(DESTDIR)/sls_detector_help
|
||||
clients: builddir lib $(DESTDIR)/sls_detector_put $(DESTDIR)/sls_detector_get $(DESTDIR)/sls_detector_acquire $(DESTDIR)/sls_detector_help $(DESTDIR)/sls_detector_process
|
||||
|
||||
static_clients: builddir lib $(DESTDIR)/ssls_detector_put $(DESTDIR)/ssls_detector_get $(DESTDIR)/ssls_detector_acquire $(DESTDIR)/ssls_detector_help
|
||||
|
||||
@ -89,6 +89,13 @@ $(DESTDIR)/sls_detector_acquire: $(SRC_CLNT) $(DESTDIR)/libSlsDetector.so $(DEST
|
||||
$(CXX) -o $(BIN)/sls_detector_acquire $(SRC_CLNT) $(FLAGS) $(INCLUDES) -DREADOUT $(LIBS) $(LDFLAG)
|
||||
$(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR))
|
||||
|
||||
$(DESTDIR)/sls_detector_process: $(SRC_CLNT) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a
|
||||
$(call colorecho,"#######################################")
|
||||
$(call colorecho,"# Compiling sls_detector_process #")
|
||||
$(call colorecho,"#######################################")
|
||||
$(CXX) -o $(BIN)/sls_detector_process $(SRC_CLNT) $(FLAGS) $(INCLUDES) -DREADOUT $(LIBS) $(LDFLAG) -DPROCESS
|
||||
$(shell test -d $(DESTDIR) || mkdir -p $(DESTDIR))
|
||||
|
||||
$(DESTDIR)/sls_detector_help: $(SRC_CLNT) $(DESTDIR)/libSlsDetector.so $(DESTDIR)/libSlsDetector.a
|
||||
$(call colorecho,"#######################################")
|
||||
$(call colorecho,"# Compiling sls_detector_help #")
|
||||
|
@ -4,6 +4,10 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
using namespace std;
|
||||
#ifdef PROCESS
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
||||
@ -15,31 +19,37 @@ int main(int argc, char *argv[])
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
int action=slsDetectorDefs::HELP_ACTION;
|
||||
#ifdef PUT
|
||||
int action=slsDetectorDefs::PUT_ACTION;
|
||||
action=slsDetectorDefs::PUT_ACTION;
|
||||
#endif
|
||||
|
||||
#ifdef GET
|
||||
int action=slsDetectorDefs::GET_ACTION;
|
||||
action=slsDetectorDefs::GET_ACTION;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef READOUT
|
||||
int action=slsDetectorDefs::READOUT_ACTION;
|
||||
action=slsDetectorDefs::READOUT_ACTION;
|
||||
#endif
|
||||
|
||||
#ifdef PROCESS
|
||||
action=slsDetectorDefs::PROCESS_ACTION;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HELP
|
||||
int action=slsDetectorDefs::HELP_ACTION;
|
||||
action=slsDetectorDefs::HELP_ACTION;
|
||||
#endif
|
||||
|
||||
multiSlsDetectorClient *cl;
|
||||
if (argc>1)
|
||||
cl=new multiSlsDetectorClient(argc-1, argv+1, action);
|
||||
else
|
||||
else {
|
||||
cl=new multiSlsDetectorClient(argc-1, argv, action);
|
||||
|
||||
|
||||
}
|
||||
delete cl;
|
||||
}
|
||||
|
||||
|
@ -557,11 +557,11 @@ uint32_t Listener::ListenToAnImage(char* buf) {
|
||||
lastCaughtFrameIndex = fnum;
|
||||
|
||||
|
||||
//#ifdef VERBOSE
|
||||
#ifdef VERBOSE
|
||||
//if (!index)
|
||||
cprintf(GREEN,"Listening %d: currentfindex:%lu, fnum:%lu, pnum:%u numpackets:%u\n",
|
||||
index,currentFrameIndex, fnum, pnum, numpackets);
|
||||
//#endif
|
||||
#endif
|
||||
if (!measurementStartedFlag)
|
||||
RecordFirstIndices(fnum);
|
||||
|
||||
|
Reference in New Issue
Block a user