Ctbgui det (#58)

* WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* defs added

* ctb gui: tengiga bug fix

* WIP

* WIP
This commit is contained in:
Dhanya Thattil
2019-08-29 11:39:29 +02:00
committed by GitHub
parent 4f0634fe62
commit e23b3b0471
31 changed files with 795 additions and 1210 deletions

View File

@ -62,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, ghostSummation<dataType> *gs=NULL) : det(d), nx(nnx), ny(nny), stat(NULL), cmSub(cm), iframe(-1), dataSign(sign), gmap(gm), ghSum(gs), 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);
@ -880,7 +880,7 @@ 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];
@ -927,6 +927,7 @@ template <class dataType> class analogDetector {
#endif
return val;
}
return val;
};
@ -981,7 +982,7 @@ template <class dataType> class analogDetector {
*/
int *getNPhotons(char *data, int *nph=NULL) {
double val;
//double val;
if (nph==NULL)
nph=image;
newFrame(data);

View File

@ -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];
@ -28,7 +28,7 @@ class commonModeSubtraction {
/* } */
virtual commonModeSubtraction *Clone() {
new commonModeSubtraction(this->nROI, this->nsigma);
return new commonModeSubtraction(this->nROI, this->nsigma);
}
/** clears the moving average and the sum of pedestals calculation - virtual func*/

View File

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

View File

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

View File

@ -8,9 +8,9 @@ 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), dbitlist(dbl), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch) {};
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), dbitlist(dbl), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch) {};
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;};
@ -51,7 +51,7 @@ class deserializer : public slsDetectorData<int> {
static int* deserializeAll(char *ptr, std::vector <int> dbl, int dr=24, int nch=64*3, int off=5) {
// off=0;
int iarg;
//int iarg;
int64_t word, *wp;
int* val=new int[nch];
int ioff=0;
@ -107,10 +107,10 @@ class deserializer : public slsDetectorData<int> {
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 iarg;
// int64_t word;
int* val=new int[nch];
int ioff=0;
//int ioff=0;
int idr=0;
int ib=0;
int iw=0;
@ -129,7 +129,7 @@ class deserializer : public slsDetectorData<int> {
ib=0;
ich=0;
for (const auto &bit : dbl) {
ioff=off;
//ioff=off;
idr=0;
for (iw=0; iw<(nch*dr/nb)/8; iw++) {
val[ich]|=(*dval)<<idr;

View File

@ -29,7 +29,7 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
*/
//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), 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) */
@ -46,13 +46,13 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
int row, col;
int isample;
//int isample;
int iadc;
int ix, iy;
// int ix, iy;
int npackets=40;
// int npackets=40;
int i;
int adc4(0);
//int adc4(0);
for (int is=0; is<aSamples; is++) {
@ -115,7 +115,7 @@ class moench04CtbZmq10GbData : public slsDetectorData<uint16_t> {
}
int getGain(char *data, int x, int y) {
int aoff=aSamples*2*32;
// int aoff=aSamples*2*32;
int irow;
int isc=x/sc_width;
int icol=x%sc_width;
@ -237,15 +237,15 @@ class moench04CtbZmq10GbData : 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;
// cout << dataSize << endl;
if (ff>=0)
fnum=ff;
// fnum=ff;
if (filebin.is_open()) {
if (filebin.read(data, dataSize) ){

View File

@ -28,20 +28,20 @@ class moench04CtbZmqData : public slsDetectorData<uint16_t> {
\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), aSamples(nas), dSamples(nds), nadc(32), sc_width(25), sc_height(200) {
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 isample;
int iadc;
int ix, iy;
//int ix, iy;
int npackets=40;
// int npackets=40;
int i;
int adc4(0);
//int adc4(0);
for (int is=0; is<aSamples; is++) {
@ -223,15 +223,15 @@ class moench04CtbZmqData : 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;
// cout << dataSize << endl;
if (ff>=0)
fnum=ff;
// fnum=ff;
if (filebin.is_open()) {
if (filebin.read(data, dataSize) ){

View File

@ -28,13 +28,13 @@ template <class dataType> class ghostSummation {
~ghostSummation() {delete [] ghost;};
virtual ghostSummation *Clone() {
new ghostSummation(this);
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;};
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++)

View File

@ -58,7 +58,7 @@ public analogDetector<uint16_t> {
int sign=1,
commonModeSubtraction *cm=NULL,
int nped=1000,
int nd=100, int nnx=-1, int nny=-1, double *gm=NULL, ghostSummation<uint16_t> *gs=NULL) : analogDetector<uint16_t>(d, sign, cm, nped, nnx, nny, gm, gs), 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;
@ -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;

View File

@ -211,7 +211,7 @@ class single_photon_hit {
void print() {
int ix, iy;
// int ix, iy;
for (int iy=0; iy<dy; iy++) {
for (int ix=0; ix<dx; ix++) {

View File

@ -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){
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);
@ -50,7 +50,7 @@ float *ReadFromTiff( const char * imgname, uint32 &nrow, uint32 &ncol){
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);
}