diff --git a/slsDetectorCalibration/.gitignore b/slsDetectorCalibration/.gitignore deleted file mode 100644 index 5f41dcb88..000000000 --- a/slsDetectorCalibration/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.o -*.*~ diff --git a/slsDetectorCalibration/MovingStat.h b/slsDetectorCalibration/MovingStat.h index 35249b1c9..46917c98e 100755 --- a/slsDetectorCalibration/MovingStat.h +++ b/slsDetectorCalibration/MovingStat.h @@ -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; } diff --git a/slsDetectorCalibration/analogDetector.h b/slsDetectorCalibration/analogDetector.h index 49197f0a6..d8b0e141f 100644 --- a/slsDetectorCalibration/analogDetector.h +++ b/slsDetectorCalibration/analogDetector.h @@ -6,7 +6,8 @@ #include #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 analogDetector { analogDetector(slsDetectorData *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 *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 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 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 analogDetector { if (gm) { if (gmap) delete [] gmap; gmap=new double[nnx*nny]; - for (int iy=0; iy 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 analogDetector { commonModeSubtraction *getCommonModeSubtraction() {return cmSub;}; + ghostSummation *getGhostSummation(){return ghSum;}; + ghostSummation *setGhostSummation(ghostSummation *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 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=0 && iy0) { 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 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; iy0) - 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 << " " <getChannel(data, ix, iy)>=0x3fff) */ + /* cout << ix << " " << iy << " " << det->getChannel(data, ix, iy) <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 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=0 && iy0) + virtual double getPedestal (int ix, int iy, int cm=0){ + if (ix>=0 && ix=0 && iy0) { 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 analogDetector { \returns pedestal rms */ virtual double getPedestalRMS(int ix, int iy){ - if (ix>=0 && ix=0 && iy=0 && ix=0 && iy=0 && ix=0 && iy class analogDetector { virtual double* getPedestal(double *ped){ if (ped==NULL) ped=new double[nx*ny]; - for (int iy=0; iy class analogDetector { */ virtual void setPedestal(double *ped, double *rms=NULL, int m=-1){ double rr=0; - for (int iy=ymin; iy 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 @@ -690,19 +764,24 @@ template 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; iyisGood(ix,iy)) { - addToPedestal(data,ix,iy,1); + // addToPedestal(data,ix,iy,1); + addToPedestal(data,ix,iy,cm); //if (ix==10 && iy==10) // cout < 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 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 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; iyisGood(ix,iy)) - val[iy*nx+ix]+=subtractPedestal(data, ix, iy,cm); + //calcGhost(data); + + for (int iy=ymin; iyisGood(ix,iy)) + val[iy*nx+ix]+=subtractPedestal(data, ix, iy,cm); } } return val; @@ -847,7 +929,7 @@ template 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=0 && iy class analogDetector { val= (dataSign*det->getValue(data, ix, iy)-getPedestal(ix,iy,cm))/g; } 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 @@ -892,6 +979,7 @@ template class analogDetector { #endif return val; } + return val; }; @@ -919,8 +1007,7 @@ template class analogDetector { int nph=0; double v; if (ix>=0 && ix=0 && iy 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; @@ -946,15 +1039,16 @@ template 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; iyisGood(ix,iy)) nph[iy*nx+ix]+=getNPhotons(data, ix, iy); } @@ -1032,13 +1126,16 @@ template class analogDetector { if (ymi<0) ymi=ymin; if (yma<0) yma=ymax; - for (int iy=ymi; iyisGood(ix,iy)) { if (ix>=0 && ix=0 && iy class analogDetector { switch(fMode) { case ePedestal: //cout << "analog ped " << endl; - addToPedestal(data); + addToPedestal(data,1); break; default: // cout << "analog " << endl; @@ -1140,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 *ghSum;/**< ghostSummation class */ int *image; int id; //int xmin, xmax, ymin, ymax; int xmin; /**< minimum x of the region of interest */ diff --git a/slsDetectorCalibration/commonModeSubtractionNew.h b/slsDetectorCalibration/commonModeSubtractionNew.h index 255500644..1add20cc2 100644 --- a/slsDetectorCalibration/commonModeSubtractionNew.h +++ b/slsDetectorCalibration/commonModeSubtractionNew.h @@ -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; i0) 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=0 && iroi0) + 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; /** { 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]; diff --git a/slsDetectorCalibration/dataStructures/Mythen3_02_jctbData.h b/slsDetectorCalibration/dataStructures/Mythen3_02_jctbData.h index a76e2cbaf..0719301ca 100644 --- a/slsDetectorCalibration/dataStructures/Mythen3_02_jctbData.h +++ b/slsDetectorCalibration/dataStructures/Mythen3_02_jctbData.h @@ -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; diff --git a/slsDetectorCalibration/dataStructures/deserializer.h b/slsDetectorCalibration/dataStructures/deserializer.h new file mode 100644 index 000000000..bf18b4335 --- /dev/null +++ b/slsDetectorCalibration/dataStructures/deserializer.h @@ -0,0 +1,171 @@ +#ifndef DESERIALIZER_H +#define DESERIALIZER_H +#include + +class deserializer : public slsDetectorData { + + + public: + + + deserializer( std::vector dbl, int nch=64*3,int dr=24, int off=2): slsDetectorData(nch,1,nch*dr*8+off*8,NULL,NULL,NULL), dynamicRange(dr), serialOffset(off), frameNumber(0), numberOfCounters(nch), dbitlist(dbl) {}; + + deserializer( std::vector dbl, int nch,int dr, int off, int ds): slsDetectorData(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 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 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=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 setDBitList(std::vector dbl) {dbitlist=dbl; return dbitlist;}; + virtual std::vector getDBitList() {return dbitlist;}; + + + private: + + int dynamicRange; + int serialOffset; + int frameNumber; + int numberOfCounters; + std::vector dbitlist; + + + +}; + +#endif diff --git a/slsDetectorCalibration/dataStructures/eigerHalfModuleData.h b/slsDetectorCalibration/dataStructures/eigerHalfModuleData.h deleted file mode 100644 index c9087e8a7..000000000 --- a/slsDetectorCalibration/dataStructures/eigerHalfModuleData.h +++ /dev/null @@ -1,470 +0,0 @@ -#ifndef EIGERMODULEDATA_H -#define EIGERMODULEDATA_H -#include "slsReceiverData.h" - - - -class eigerHalfModuleData : public slsReceiverData { -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(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= 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; irpacketnum)); - }; - - - - /** - 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 << " " <=0 && ix=0 && iy=0 && dataMap[iy][ix]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>(ipos*4))&0xf; //pick the right 4bit - dataout[ichan]=ival; - ichan++; - } - } - break; - case 8: - for (ichan=0; ichan { -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(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>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::getValue(data, ix, iy); - else - return slsDetectorData::getValue(data, ix, iy)-xtalk*slsDetectorData::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; /** { - - 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(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=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=0) - fnum=ff; - - if (filebin.is_open()) { - if (filebin.read(data, dataSize) ){ - ff=getFrameNumber(data); - np=getPacketNumber(data); - return data; - } - } - return NULL; - - - - }; - - - - -}; - - - - - -#endif diff --git a/slsDetectorCalibration/dataStructures/jungfrau02Data.h b/slsDetectorCalibration/dataStructures/jungfrau02Data.h deleted file mode 100644 index ebc18ed93..000000000 --- a/slsDetectorCalibration/dataStructures/jungfrau02Data.h +++ /dev/null @@ -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=0 && iy=0 && dataMap[iy][ix]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 << " " < 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; /** { - - 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(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=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 diff --git a/slsDetectorCalibration/dataStructures/moench02Ctb10GbData.h b/slsDetectorCalibration/dataStructures/moench02Ctb10GbData.h deleted file mode 100644 index a36090496..000000000 --- a/slsDetectorCalibration/dataStructures/moench02Ctb10GbData.h +++ /dev/null @@ -1,246 +0,0 @@ -#ifndef MOENCH02CTB10GBDATA_H -#define MOENCH02CTB10GBDATA_H -#include -#include "slsDetectorData.h" -#include "slsReceiverData.h" - - -class moench02Ctb10GbData : public slsReceiverData { - - 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(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=8208*npackets) { - cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; - } - - } - } - } - } - int ibyte; - int ii=0; - - for (int ipacket=0; ipacket=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 && ip0) { */ - /* 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< { - - 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(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=dataSize) { - cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; - } - - } - } - - for (int i=0; i=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>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 { - 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(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 << " " <::getValue(data, ix, iy); - else - return slsDetectorData::getValue(data, ix, iy)-xtalk*slsDetectorData::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; /** { - - 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(400, 400, 8208*40, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) { - moench03Ctb10GbData(int ns=5000): slsReceiverData(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=8208*40) - cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; - } - } - } - } - - int ipacket; - int ibyte; - int ii=0; - for (int ipacket=0; ipacket0) { */ -/* 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=0) { - if (getFrameNumber(packet) !=fnum) { - cout << "-"<=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 diff --git a/slsDetectorCalibration/dataStructures/moench03Ctb10GbT1Data.h b/slsDetectorCalibration/dataStructures/moench03Ctb10GbT1Data.h deleted file mode 100644 index 415bb82ac..000000000 --- a/slsDetectorCalibration/dataStructures/moench03Ctb10GbT1Data.h +++ /dev/null @@ -1,287 +0,0 @@ -#ifndef MOENCH03CTB10GBT1DATA_H -#define MOENCH03CTB10GBT1DATA_H -#include "slsReceiverData.h" - - - -class moench03Ctb10GbT1Data : public slsReceiverData { - - private: - - 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 - - */ - moench03Ctb10GbT1Data(int ns=5000): slsReceiverData(400, 400, 40, 8208), nadc(32), sc_width(25), 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 row, col; - - int isample; - int iadc; - int ix, iy; - - int npackets=40; - int i; - int adc4(0); - - for (int ip=0; ip=8208*40) - cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; - } - } - } - } - - int ipacket; - int ibyte; - int ii=0; - for (int ipacket=0; ipacket0) { */ -/* 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[packetSize*nPackets]; - 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, po=0; - char aa[8224]; - char *packet=(char *)aa; - // cout << packetSize*nPackets << endl; - 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 || pnnPackets) { - 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 (np==0){ - // delete [] data; - return NULL; - } - - ff=fnum; - return data; - - }; - - - - - - - - - - - - - - - - - - -int getPacketNumber(int x, int y) {return dataMap[y][x]/8208;}; - - -}; - - - - -#endif diff --git a/slsDetectorCalibration/dataStructures/moench03T1ReceiverDataNew.h b/slsDetectorCalibration/dataStructures/moench03T1ReceiverDataNew.h index d3a5e55e1..799fa0293 100644 --- a/slsDetectorCalibration/dataStructures/moench03T1ReceiverDataNew.h +++ b/slsDetectorCalibration/dataStructures/moench03T1ReceiverDataNew.h @@ -52,6 +52,7 @@ class moench03T1ReceiverDataNew : public slsDetectorData { int sc_height; const int nSamples; + double ghost[200][25]; public: @@ -64,7 +65,7 @@ class moench03T1ReceiverDataNew : public slsDetectorData { \param c crosstalk parameter for the output buffer */ - moench03T1ReceiverDataNew(int ns=5000): slsDetectorData(400, 400, ns*2*32+sizeof(sls_detector_header)), nSamples(ns) { + moench03T1ReceiverDataNew(int ns=5000): slsDetectorData(400, 400, ns*2*32+sizeof(sls_detector_header)), nSamples(ns) { int nadc=32; int sc_width=25; @@ -99,13 +100,21 @@ class moench03T1ReceiverDataNew : public slsDetectorData { } else { row=200+i/sc_width; } - dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1); + dataMap[row][col]=sizeof(sls_detector_header)+(nadc*i+iadc)*2;//+16*(ip+1); +#ifdef HIGHZ + dataMask[row][col]=0x3fff; //invert data +#endif if (dataMap[row][col]<0 || dataMap[row][col]>=nSamples*2*32) cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; } } } } + // double ghost[200][25]; + + for (int ix=0; ix<25; ix++) + for (int iy=0; iy<200; iy++) + ghost[iy][ix]=0.; int ipacket; int ibyte; @@ -142,6 +151,73 @@ class moench03T1ReceiverDataNew : public slsDetectorData { }; + + /** + Returns the value of the selected channel for the given dataset as double. + \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 as double + + */ + virtual double getValue(char *data, int ix, int iy=0) { + /* cout << " x "<< ix << " y"<< iy << " val " << getChannel(data, ix, iy)<< endl;*/ + /* double val=0, vout=getChannel(data, ix, iy); */ + /* int x1=ix%25; */ + /* for (int ix=0; ix<16; ix++) { */ + /* for (int ii=0; ii<2; ii++) { */ + /* val+=getChannel(data,x1+25*ix,iy); */ + /* val+=getChannel(data,x1+25*ix,399-iy); */ + /* } */ + /* } */ + /* vout+=0.0008*val-6224; */ + /* return vout; //(double)getChannel(data, ix, iy); + */ + uint16_t val=getChannel(data, ix, iy)&0x3fff; + return val; + }; + + + + virtual void calcGhost(char *data, int ix, int iy) { + double val=0; + /* for (int ix=0; ix<25; ix++){ */ + /* for (int iy=0; iy<200; iy++) { */ + val=0; + // cout << "** "; + for (int isc=0; isc<16; isc++) { + // for (int ii=0; ii<2; ii++) { + val+=getChannel(data,ix+25*isc,iy); + // cout << "(" << isc << "," << val << " " ; + val+=getChannel(data,ix+25*isc,399-iy); + // cout << val << " " ; + // } + } + ghost[iy][ix]=val;//-6224; + // cout << " --"<< endl; + /* } */ + /* } */ + // cout << "*" << endl; + + } + + + + virtual void calcGhost(char *data) { + for (int ix=0; ix<25; ix++){ + for (int iy=0; iy<200; iy++) { + calcGhost(data, ix,iy); + } + } + // cout << "*" << endl; + } + + + double getGhost(int ix, int iy) { + if (iy<200) return ghost[iy][ix%25]; + if (iy<400) return ghost[399-iy][ix%25]; + return 0; + }; /** @@ -278,8 +354,6 @@ class moench03T1ReceiverDataNew : public slsDetectorData { } - - //int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;}; }; diff --git a/slsDetectorCalibration/dataStructures/moench03T1ReorderedData.h b/slsDetectorCalibration/dataStructures/moench03T1ReorderedData.h new file mode 100644 index 000000000..d5f988922 --- /dev/null +++ b/slsDetectorCalibration/dataStructures/moench03T1ReorderedData.h @@ -0,0 +1,176 @@ +#ifndef MOENCH03T1REORDERED_H +#define MOENCH03T1REORDERED_H +#include "slsDetectorData.h" + + +class moench03T1ReorderedData : public slsDetectorData { + + 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(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 { const int nSamples; const int offset; + double ghost[200][25]; + double xtalk; + public: @@ -25,7 +28,7 @@ class moench03T1ZmqDataNew : public slsDetectorData { \param c crosstalk parameter for the output buffer */ - moench03T1ZmqDataNew(int ns=5000): slsDetectorData(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)) { + moench03T1ZmqDataNew(int ns=5000): slsDetectorData(400, 400, ns*32*2+sizeof(int)), nSamples(ns), offset(sizeof(int)), xtalk(0.00021) { int nadc=32; int sc_width=25; @@ -100,12 +103,84 @@ class moench03T1ZmqDataNew : public slsDetectorData { + for (int ix=0; ix<25; ix++) + for (int iy=0; iy<200; iy++) + ghost[iy][ix]=0.; + // iframe=0; // cout << "data struct created" << endl; }; + double getXTalk(){return xtalk;}; + void setXTalk(double g) {xtalk=g;}; + + /** + Returns the value of the selected channel for the given dataset as double. + \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 as double + + */ + virtual double getValue(char *data, int ix, int iy=0) { + /* cout << " x "<< ix << " y"<< iy << " val " << getChannel(data, ix, iy)<< endl;*/ + /* double val=0, vout=getChannel(data, ix, iy); */ + /* int x1=ix%25; */ + /* for (int ix=0; ix<16; ix++) { */ + /* for (int ii=0; ii<2; ii++) { */ + /* val+=getChannel(data,x1+25*ix,iy); */ + /* val+=getChannel(data,x1+25*ix,399-iy); */ + /* } */ + /* } */ + /* vout+=0.0008*val-6224; */ + /* return vout; //(double)getChannel(data, ix, iy); + */ + return ((double)getChannel(data, ix, iy))+xtalk*getGhost(iy,iy); + }; + + + + virtual void calcGhost(char *data, int ix, int iy) { + double val=0; + /* for (int ix=0; ix<25; ix++){ */ + /* for (int iy=0; iy<200; iy++) { */ + val=0; + for (int isc=0; isc<16; isc++) { + for (int ii=0; ii<2; ii++) { + val+=getChannel(data,ix+25*isc,iy); + // cout << val << " " ; + val+=getChannel(data,ix+25*isc,399-iy); + // cout << val << " " ; + } + } + ghost[iy][ix]=val;//-6224; + // cout << endl; + /* } */ + /* } */ + // cout << "*" << endl; + + } + + + + virtual void calcGhost(char *data) { + for (int ix=0; ix<25; ix++){ + for (int iy=0; iy<200; iy++) { + calcGhost(data, ix,iy); + } + } + // cout << "*" << endl; + } + + + double getGhost(int ix, int iy) { + if (iy<200) return ghost[iy][ix%25]; + if (iy<400) return ghost[399-iy][ix%25]; + return 0; + }; + /** @@ -201,15 +276,15 @@ class moench03T1ZmqDataNew : public slsDetectorData { 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) ){ diff --git a/slsDetectorCalibration/dataStructures/moench03TCtb10GbData.h b/slsDetectorCalibration/dataStructures/moench03TCtb10GbData.h deleted file mode 100644 index 989012991..000000000 --- a/slsDetectorCalibration/dataStructures/moench03TCtb10GbData.h +++ /dev/null @@ -1,285 +0,0 @@ -#ifndef MOENCH03TCTB10GBDATA_H -#define MOENCH03TCTB10GBDATA_H -#include "moench03Ctb10GbData.h" - - - -class moench03TCtb10GbData : public moench03Ctb10GbData { //slsReceiverData { - - - 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(400, 400, 8208*40, NULL, NULL) , nadc(32), sc_width(25), sc_height(200) { - moench03TCtb10GbData(int ns=5000): moench03Ctb10GbData(ns) {//slsReceiverData(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=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; ipacket0) { *\/ */ -/* /\* 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 { + + 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(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; ip0) { + 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; ibyteframeNumber;};//*((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 { +class moench04CtbReceiverData : public slsDetectorData { private: @@ -45,8 +48,8 @@ class moench03T1ReceiverData : public slsDetectorData { int nadc; int sc_width; int sc_height; - const int nPackets; /** { \param c crosstalk parameter for the output buffer */ - moench03T1ReceiverData(int npackets=40, int ps=8192): slsDetectorData(400, 400, ps*npackets+sizeof(sls_detector_header)), packetSize(ps), nPackets(npackets) { + moench04CtbReceiverData(int nas=5000, int nds=0): slsDetectorData(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 { int iadc; int ix, iy; - // int npackets=40; + int npackets=40; int i; int adc4(0); @@ -89,14 +89,15 @@ class moench03T1ReceiverData : public slsDetectorData { adc4=(int)iadc/4; if (i0) { 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 { xmap[ibyte]=-1; ymap[ibyte]=-1; } - int off=sizeof(sls_detector_header)/2; - for (ipacket=0; ipacket { */ - 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 { -int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;}; + //int getPacketNumber(int x, int y) {return dataMap[y][x]/packetSize;}; }; diff --git a/slsDetectorCalibration/dataStructures/moench04CtbZmq10GbData.h b/slsDetectorCalibration/dataStructures/moench04CtbZmq10GbData.h new file mode 100644 index 000000000..f897724aa --- /dev/null +++ b/slsDetectorCalibration/dataStructures/moench04CtbZmq10GbData.h @@ -0,0 +1,290 @@ +#ifndef MOENCH04ZMQ10GBDATA_H +#define MOENCH04ZMQ10GBDATA_H +#include "slsDetectorData.h" + + + + +class moench04CtbZmq10GbData : public slsDetectorData { + + 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(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(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(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; is0) + 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=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<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 { + + 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(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*2*32) + cout << "Error: pointer " << dataMap[row][col] << " out of range "<< endl; + } + } + } + + + /* for (ibyte=0; ibyte=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<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 -#include -#include -#include -#endif - -#include - -#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*(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 (lSetParNames("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; ibGetXaxis()->GetNbins(); ib++) { - for (int ich=0; ichGetBinContent(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; ibGetYaxis()->GetNbins(); ib++) { - for (int ich=0; ichGetBinContent(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 +#include "slsDetectorData.h" + +template class ghostSummation { + + /** @short virtual calss to handle ghosting*/ + + public: + + /** constructor + \param xt crosstalk + */ + ghostSummation(slsDetectorData *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=nx || iy<0 || iy>=ny) return 0; + return ghost[iy*nx+ix]; + } + + protected: + double xtalk; + slsDetectorData *det; + double *ghost; + int nx, ny; + +}; + + + + + +#endif diff --git a/slsDetectorCalibration/gotthardDoubleModuleCommonModeSubtractionNew.h b/slsDetectorCalibration/gotthardDoubleModuleCommonModeSubtractionNew.h deleted file mode 100644 index 2960cabd4..000000000 --- a/slsDetectorCalibration/gotthardDoubleModuleCommonModeSubtractionNew.h +++ /dev/null @@ -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 diff --git a/slsDetectorCalibration/gotthardExecutables/Makefile.onTheFly b/slsDetectorCalibration/gotthardExecutables/Makefile.onTheFly deleted file mode 100644 index da6e994ef..000000000 --- a/slsDetectorCalibration/gotthardExecutables/Makefile.onTheFly +++ /dev/null @@ -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 diff --git a/slsDetectorCalibration/gotthardExecutables/bchip2modules_pc8829.config b/slsDetectorCalibration/gotthardExecutables/bchip2modules_pc8829.config new file mode 100644 index 000000000..6fdc2f3eb --- /dev/null +++ b/slsDetectorCalibration/gotthardExecutables/bchip2modules_pc8829.config @@ -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 diff --git a/slsDetectorCalibration/gotthardExecutables/gotthard25umZmqAnalysis.C b/slsDetectorCalibration/gotthardExecutables/gotthard25umZmqAnalysis.C deleted file mode 100644 index 49987b07b..000000000 --- a/slsDetectorCalibration/gotthardExecutables/gotthard25umZmqAnalysis.C +++ /dev/null @@ -1,517 +0,0 @@ -#include "sls_receiver_defs.h" -//#ifdef ZMQ -#include "ZmqSocket.h" -//#endif -#include -#include -#include -#include -#include -#include -//#include -//#include -//#include -#include -#include - -//#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 - -#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 *filter=new analogDetector(det, 1, cm, 1000); - // analogDetector *filter_nocm=new analogDetector(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; ireadNextFrame(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 (frameIndex0ReceiveData(0, buff0, size/2); - if (!zmqsocket0->ReceiveHeader(0, acqIndex0, frameIndex0, subframeIndex0, filename0, fileindex0)) { - end_of_acquisition++; - eoa0=1; - break; - } - } - - while (frameIndex1ReceiveData(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; - - - -} diff --git a/slsDetectorCalibration/gotthardExecutables/howto_gotthatd_twomodules.txt b/slsDetectorCalibration/gotthardExecutables/howto_gotthatd_twomodules.txt new file mode 100644 index 000000000..edd3e257d --- /dev/null +++ b/slsDetectorCalibration/gotthardExecutables/howto_gotthatd_twomodules.txt @@ -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 + diff --git a/slsDetectorCalibration/interpolatingDetector.h b/slsDetectorCalibration/interpolatingDetector.h index f5ce437bd..a91fe5dbe 100644 --- a/slsDetectorCalibration/interpolatingDetector.h +++ b/slsDetectorCalibration/interpolatingDetector.h @@ -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 *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) diff --git a/slsDetectorCalibration/interpolations/.__afs3A48 b/slsDetectorCalibration/interpolations/.__afs3A48 deleted file mode 100755 index efa6b3d16..000000000 Binary files a/slsDetectorCalibration/interpolations/.__afs3A48 and /dev/null differ diff --git a/slsDetectorCalibration/interpolations/eta2InterpolationBase.h b/slsDetectorCalibration/interpolations/eta2InterpolationBase.h index d6c4a81dc..ed6f8dbad 100644 --- a/slsDetectorCalibration/interpolations/eta2InterpolationBase.h +++ b/slsDetectorCalibration/interpolations/eta2InterpolationBase.h @@ -33,7 +33,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { { double sDum[2][2]; double tot, totquad; - double etax,etay; + double etax=0,etay=0; int corner; corner=calcQuad(data, tot, totquad, sDum); @@ -49,7 +49,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { { double sDum[2][2]; double tot, totquad; - double etax,etay; + double etax=0,etay=0; int corner; corner=calcQuad(data, tot, totquad, sDum); @@ -71,7 +71,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { 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; + int xoff=0, yoff=0; switch (quad) { case BOTTOM_LEFT: xoff=0; @@ -92,7 +92,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { default: ; } - double etax, etay; + double etax=0, etay=0; if (nSubPixels>2) { cc[0][0]=cl[xoff+3*yoff]; cc[1][0]=cl[xoff+3*(yoff+1)]; @@ -100,6 +100,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { 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); } @@ -109,7 +110,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { 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; + int xoff=0, yoff=0; switch (quad) { case BOTTOM_LEFT: @@ -131,7 +132,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { default: ; } - double etax, etay; + double etax=0, etay=0; if (nSubPixels>2) { cc[0][0]=cl[xoff+3*yoff]; cc[1][0]=cl[xoff+3*(yoff+1)]; @@ -222,7 +223,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { virtual int addToFlatField(double totquad,int quad,int *cl,double &etax, double &etay) { double cc[2][2]; - int xoff, yoff; + int xoff=0, yoff=0; switch (quad) { case BOTTOM_LEFT: @@ -260,7 +261,7 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { virtual int addToFlatField(double totquad,int quad,double *cl,double &etax, double &etay) { double cc[2][2]; - int xoff, yoff; + int xoff=0, yoff=0; switch (quad) { case BOTTOM_LEFT: @@ -308,11 +309,12 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { virtual int addToFlatField(double *cluster, double &etax, double &etay){ double sDum[2][2]; double tot, totquad; - int corner; - corner=calcQuad(cluster, tot, totquad, sDum); + // int corner; + //corner= + calcQuad(cluster, tot, totquad, sDum); - double xpos_eta,ypos_eta; - double dX,dY; + //double xpos_eta,ypos_eta; + //double dX,dY; calcEta(totquad, sDum, etax, etay); @@ -324,11 +326,12 @@ class eta2InterpolationBase : public virtual etaInterpolationBase { virtual int addToFlatField(int *cluster, double &etax, double &etay){ double sDum[2][2]; double tot, totquad; - int corner; - corner=calcQuad(cluster, tot, totquad, sDum); + //int corner; + //corner= + calcQuad(cluster, tot, totquad, sDum); - double xpos_eta,ypos_eta; - double dX,dY; + // double xpos_eta,ypos_eta; + //double dX,dY; calcEta(totquad, sDum, etax, etay); diff --git a/slsDetectorCalibration/interpolations/eta3InterpolationBase.h b/slsDetectorCalibration/interpolations/eta3InterpolationBase.h index 516b4a535..4fe2ceb4e 100644 --- a/slsDetectorCalibration/interpolations/eta3InterpolationBase.h +++ b/slsDetectorCalibration/interpolations/eta3InterpolationBase.h @@ -59,10 +59,10 @@ class eta3InterpolationBase : public virtual etaInterpolationBase { //////////// /*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 tot; double etax,etay; - int corner=calcEta3(data,etax,etay, totquad); + int corner=calcEta3(data,etax,etay, tot); getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y); @@ -72,11 +72,11 @@ class eta3InterpolationBase : public virtual etaInterpolationBase { virtual void getInterpolatedPosition(int x, int y, double *data, double &int_x, double &int_y) { - double sDum[2][2]; - double tot, totquad; + //double sDum[2][2]; + double tot; double etax,etay; - int corner=calcEta3(data,etax,etay, totquad); + int corner=calcEta3(data,etax,etay, tot); getInterpolatedPosition(x,y,etax,etay,corner,int_x,int_y); diff --git a/slsDetectorCalibration/interpolations/etaInterpolationBase.h b/slsDetectorCalibration/interpolations/etaInterpolationBase.h index 500bbbe9b..e4bda2c5d 100644 --- a/slsDetectorCalibration/interpolations/etaInterpolationBase.h +++ b/slsDetectorCalibration/interpolations/etaInterpolationBase.h @@ -190,7 +190,7 @@ float *gethhx() void debugSaveAll(int ind=0) { - int ib, ibx, iby; + int ibx, iby; char tit[10000]; float tot_eta=0; @@ -204,7 +204,7 @@ float *gethhx() etah[ii]=heta[ii]; tot_eta+=heta[ii]; } - sprintf(tit,"/scratch/eta.tiff",ind); + sprintf(tit,"/scratch/eta_%d.tiff",ind); WriteToTiff(etah, tit, etabins, etabins); @@ -284,7 +284,7 @@ float *gethhx() double calcDiff(double avg, float *hx, float *hy) { //double p_tot=0; double diff=0, d; - double bsize=1./nSubPixels; + //double bsize=1./nSubPixels; int nbad=0; double p_tot_x[nSubPixels], p_tot_y[nSubPixels], p_tot[nSubPixels*nSubPixels]; double maxdiff=0, mindiff=avg*nSubPixels*nSubPixels; @@ -351,9 +351,9 @@ float *gethhx() return sqrt(diff); } - int *heta; float *hhx; float *hhy; + int *heta; int nbeta; double etamin, etamax, etastep; double rangeMin, rangeMax; diff --git a/slsDetectorCalibration/interpolations/etaInterpolationPosXY.h b/slsDetectorCalibration/interpolations/etaInterpolationPosXY.h index 1f775782d..dfe6772f3 100644 --- a/slsDetectorCalibration/interpolations/etaInterpolationPosXY.h +++ b/slsDetectorCalibration/interpolations/etaInterpolationPosXY.h @@ -35,7 +35,7 @@ class etaInterpolationPosXY : public virtual etaInterpolationBase{ ///*Eta Distribution Rebinning*/// - double bsize=1./nSubPixels; //precision + // double bsize=1./nSubPixels; //precision // cout<<"nPixelsX = "< +#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 diff --git a/slsDetectorCalibration/moench03CommonMode.h b/slsDetectorCalibration/moench03CommonMode.h index 7c950a9e4..0d21c884f 100644 --- a/slsDetectorCalibration/moench03CommonMode.h +++ b/slsDetectorCalibration/moench03CommonMode.h @@ -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 (iy399-rows) { + int iroi=getROI(ix,iy); + // cout << iy << " " << ix << " " << iroi ; + if (iroi>=0 && iroirows) cout << "Too many pixels added " << nCm[iroi] << endl; + /* if (ix==10 && iy<20) */ + /* cout << " ** "<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=0 && isc0) return cmPed[isc]/nCm[isc]-cmStat[isc].Mean(); - } - return 0; - }; - }; diff --git a/slsDetectorCalibration/moench03GhostSummation.h b/slsDetectorCalibration/moench03GhostSummation.h new file mode 100644 index 000000000..165e422d5 --- /dev/null +++ b/slsDetectorCalibration/moench03GhostSummation.h @@ -0,0 +1,64 @@ +#ifndef MOENCH03GHOSTSUMMATION_H +#define MOENCH03GHOSTSUMMATION_H + +#include "ghostSummation.h" + +class moench03GhostSummation : public ghostSummation { + + /** @short virtual calss to handle ghosting*/ + + public: + + /** constructor + \param xt crosstalk + */ + moench03GhostSummation(slsDetectorData *d, double xt=0.0004) : ghostSummation(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 diff --git a/slsDetectorCalibration/moenchCommonMode.h b/slsDetectorCalibration/moenchCommonMode.h index dba0df2b7..cddadd1bb 100644 --- a/slsDetectorCalibration/moenchCommonMode.h +++ b/slsDetectorCalibration/moenchCommonMode.h @@ -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=0 && isc0) 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=0 && isc0) return cmPed[isc]/nCm[isc]-cmStat[isc].Mean(); */ + /* } */ + /* return 0; */ + /* }; */ }; diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder b/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder index b8414b77f..c5eeca444 100644 --- a/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder +++ b/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder @@ -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 diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder_rect_rh7 b/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder_rect_rh7 new file mode 100644 index 000000000..7eb1d2c9f --- /dev/null +++ b/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder_rect_rh7 @@ -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 + + diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder_rh7 b/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder_rh7 new file mode 100644 index 000000000..64cd5d73e --- /dev/null +++ b/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder_rh7 @@ -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 + +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) + +moenchNoInterpolation : moench03NoInterpolation.cpp $(INCS) clean + g++ -o moenchNoInterpolation moench03NoInterpolation.cpp $(LDFLAG) $(INCDIR) + +moenchPhotonCounter : moenchPhotonCounter.cpp $(INCS) clean + g++ -o moenchPhotonCounter moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) $ -DNEWRECEIVER + +moenchAnalog : moenchPhotonCounter.cpp $(INCS) clean + g++ -o moenchAnalog moenchPhotonCounter.cpp $(LDFLAG) $(INCDIR) -DNEWRECEIVER -DANALOG + +clean: + rm -f moenchClusterFinder moenchMakeEta moenchInterpolation moenchNoInterpolation moenchPhotonCounter moenchAnalog + + diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder_ra b/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder_sl6 similarity index 78% rename from slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder_ra rename to slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder_sl6 index 2327809f2..eb9a59d73 100644 --- a/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder_ra +++ b/slsDetectorCalibration/moenchExecutables/Makefile.cluster_finder_sl6 @@ -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 diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.moench b/slsDetectorCalibration/moenchExecutables/Makefile.moench deleted file mode 100644 index b49a76212..000000000 --- a/slsDetectorCalibration/moenchExecutables/Makefile.moench +++ /dev/null @@ -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 diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.moench_eta b/slsDetectorCalibration/moenchExecutables/Makefile.moench_eta deleted file mode 100644 index 7f575d6cb..000000000 --- a/slsDetectorCalibration/moenchExecutables/Makefile.moench_eta +++ /dev/null @@ -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 - diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.moench_zmq b/slsDetectorCalibration/moenchExecutables/Makefile.moench_zmq_sl6 similarity index 65% rename from slsDetectorCalibration/moenchExecutables/Makefile.moench_zmq rename to slsDetectorCalibration/moenchExecutables/Makefile.moench_zmq_sl6 index c0b8ea708..623d7ead5 100644 --- a/slsDetectorCalibration/moenchExecutables/Makefile.moench_zmq +++ b/slsDetectorCalibration/moenchExecutables/Makefile.moench_zmq_sl6 @@ -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 diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.phoenix b/slsDetectorCalibration/moenchExecutables/Makefile.phoenix deleted file mode 100644 index 7379db1a7..000000000 --- a/slsDetectorCalibration/moenchExecutables/Makefile.phoenix +++ /dev/null @@ -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 - diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.reoder_image b/slsDetectorCalibration/moenchExecutables/Makefile.reoder_image deleted file mode 100644 index 2ad256370..000000000 --- a/slsDetectorCalibration/moenchExecutables/Makefile.reoder_image +++ /dev/null @@ -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 - - diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.tiff_to_th2f b/slsDetectorCalibration/moenchExecutables/Makefile.tiff_to_th2f deleted file mode 100644 index db51710b7..000000000 --- a/slsDetectorCalibration/moenchExecutables/Makefile.tiff_to_th2f +++ /dev/null @@ -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 - diff --git a/slsDetectorCalibration/moenchExecutables/Makefile.moench_zmq_rh7 b/slsDetectorCalibration/moenchExecutables/Makefile.zmq similarity index 65% rename from slsDetectorCalibration/moenchExecutables/Makefile.moench_zmq_rh7 rename to slsDetectorCalibration/moenchExecutables/Makefile.zmq index 89c794c17..2db6dbdda 100644 --- a/slsDetectorCalibration/moenchExecutables/Makefile.moench_zmq_rh7 +++ b/slsDetectorCalibration/moenchExecutables/Makefile.zmq @@ -1,7 +1,6 @@ -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 +INCDIR= -I. -I../dataStructures ../tiffIO.cpp -I../ -I../interpolations/ -I../../slsSupportLib/include/ -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 diff --git a/slsDetectorCalibration/moenchExecutables/moench03ClusterFinderPhoenix.cpp b/slsDetectorCalibration/moenchExecutables/moench03ClusterFinderPhoenix.cpp deleted file mode 100644 index 7ae1f4559..000000000 --- a/slsDetectorCalibration/moenchExecutables/moench03ClusterFinderPhoenix.cpp +++ /dev/null @@ -1,201 +0,0 @@ -//#include "ansi.h" -#include - -//#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 -#include -#include -#include - -#include -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; irunsetFilePointer(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 << "*"<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; -} - diff --git a/slsDetectorCalibration/moenchExecutables/moench03CodedApertureColor.cpp b/slsDetectorCalibration/moenchExecutables/moench03CodedApertureColor.cpp new file mode 100644 index 000000000..d62398449 --- /dev/null +++ b/slsDetectorCalibration/moenchExecutables/moench03CodedApertureColor.cpp @@ -0,0 +1,245 @@ + +#include "ansi.h" +#include +#include + +//#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; iruncmin && totquad/sum>0.8 && totquad/sum<1.2 && sum=0 && iebin=0 && cl.x=0 && cl.y - -//#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; ixcalcQuad(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=0 && iebin200 && 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; iwriteInterpolatedImage(outfname); - } -#endif -#ifdef FF - for (int i=0; iwriteFlatField(outfname); - } -#endif - - } - } - - } - - } - fclose(f); -#ifdef FF - for (int i=0; iwriteFlatField(outfname); - } -#endif - -#ifndef FF - for (int i=0; iwriteInterpolatedImage(outfname); - img=interp[i]->getInterpolatedImage(); - for (ix=0; ixclearInterpolatedImage(); - } - cout << "Read " << nframes << " frames (first frame: " << f0 << " last frame: " << lastframe << " delta:" << lastframe-f0 << ")"<writeFlatField(outfname); -#endif - - cout << "Filled " << nph << " (/"<< totph <<") " << endl; - return 0; -} - diff --git a/slsDetectorCalibration/moenchExecutables/moench03MakeEta.cpp b/slsDetectorCalibration/moenchExecutables/moench03MakeEta.cpp deleted file mode 100644 index c2f2f92cd..000000000 --- a/slsDetectorCalibration/moenchExecutables/moench03MakeEta.cpp +++ /dev/null @@ -1,114 +0,0 @@ - -#include "ansi.h" -#include - -#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=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 && totquadaddToFlatField(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 << " " <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; -} - diff --git a/slsDetectorCalibration/moenchExecutables/moench03NoInterpolation.cpp b/slsDetectorCalibration/moenchExecutables/moench03NoInterpolation.cpp index 9ff0ea900..8d880c509 100644 --- a/slsDetectorCalibration/moenchExecutables/moench03NoInterpolation.cpp +++ b/slsDetectorCalibration/moenchExecutables/moench03NoInterpolation.cpp @@ -2,7 +2,6 @@ #include "ansi.h" #include -#include "moench03T1ZmqData.h" #include "single_photon_hit.h" #include "noInterpolation.h" diff --git a/slsDetectorCalibration/moenchExecutables/moench03ReorderImage.cpp b/slsDetectorCalibration/moenchExecutables/moench03ReorderImage.cpp deleted file mode 100644 index f6f7c55bb..000000000 --- a/slsDetectorCalibration/moenchExecutables/moench03ReorderImage.cpp +++ /dev/null @@ -1,163 +0,0 @@ -//#include "ansi.h" -#include - - - -//#include "moench03T1ZmqData.h" - -#include "moench03T1ReceiverDataNew.h" - -// #include "interpolatingDetector.h" -//#include "etaInterpolationPosXY.h" -// #include "linearInterpolation.h" -// #include "noInterpolation.h" -//#include "interpolatingDetector.h" - -#include -#include -#include -#include - -#include - -#include -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* 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]; - // 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[dsize]; - - - - - int ifr=0; - - - for (int irun=runmin; irunreadNextFrame(filebin, ff, np,buff)) { - for (int ix=0; ix<400; ix++) { - for (int iy=0; iy<400; iy++) { - data[iy*400+ix]=decoder->getChannel(buff,ix,iy); - if (data[iy*NX+ix]<3000 || data[iy*NX+ix]>8000) { - cout << ifr << " " << ff << " " << ix << " " << iy << " " << data[iy*NX+ix] << " " << decoder->getChannel(buff,ix,iy) << endl; - } - } - } - 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; - // break; - } - 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; -} - diff --git a/slsDetectorCalibration/moenchExecutables/moenchAnalog.cpp b/slsDetectorCalibration/moenchExecutables/moenchAnalog.cpp deleted file mode 100644 index a6f65649c..000000000 --- a/slsDetectorCalibration/moenchExecutables/moenchAnalog.cpp +++ /dev/null @@ -1,242 +0,0 @@ -//#include "ansi.h" -#include - - - -//#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 -#include -#include -#include - -#include -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!"< *filter=new analogDetector(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 << "*"<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; -} - diff --git a/slsDetectorCalibration/moenchExecutables/moenchPhotonCounter.cpp b/slsDetectorCalibration/moenchExecutables/moenchPhotonCounter.cpp index 84d3ff865..22ed6fbc9 100644 --- a/slsDetectorCalibration/moenchExecutables/moenchPhotonCounter.cpp +++ b/slsDetectorCalibration/moenchExecutables/moenchPhotonCounter.cpp @@ -1,8 +1,12 @@ //#include "ansi.h" #include +#define CORR +#define C_GHOST 0.0004 -#define VERSION_V1 +#define CM_ROWS 50 + +//#define VERSION_V1 //#include "moench03T1ZmqData.h" #ifdef NEWRECEIVER @@ -28,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 @@ -45,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; @@ -53,7 +60,7 @@ int main(int argc, char *argv[]) { int p=10000; int fifosize=1000; - int nthreads=1; + int nthreads=10; int nsubpix=25; int etabins=nsubpix*10; double etamin=-1, etamax=2; @@ -89,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]; @@ -130,7 +140,7 @@ int main(int argc, char *argv[]) { double thr1=1; if (argc>=8) { - thr=atoi(argv[7]); + thr=atof(argv[7]); } @@ -148,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; + } + @@ -167,13 +183,60 @@ 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; ireadGainMap(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; @@ -181,17 +244,13 @@ int main(int argc, char *argv[]) { 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; @@ -204,7 +263,7 @@ int main(int argc, char *argv[]) { mt->setDetectorMode(eAnalog); cout << "Analog!" << endl; cf=0; - // thr1=thr; + //thr1=thr; #endif // } @@ -215,45 +274,67 @@ 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)) { - if (np==40) { - mt->pushData(buff); - mt->nextThread(); - mt->popFree(buff); - ifr++; - if (ifr%10000==0) - cout << ifr << " " << ff << " " << np << endl; - } else - 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 pedestal file "<< fname << " for reading " << endl; + } else { + float *pp=ReadFromTiff(pedfile, nny, nnx); + if (pp && nnx==nx && nny==ny) { + for (int i=0; isetPedestal(ped); + // ped1=mt->getPedestal(); + + // for (int i=0; iwritePedestal(imgfname); + std::time(&end_time); + cout << std::ctime(&end_time) << endl; } @@ -307,8 +388,12 @@ int main(int argc, char *argv[]) { mt->nextThread(); // // // cout << " " << (void*)buff; mt->popFree(buff); + + + + ifr++; - if (ifr%1000==0) cout << ifr << " " << ff << endl; + 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...) @@ -334,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 <writeImage(imgfname, thr1); mt->clearImage(); @@ -351,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 <writeImage(imgfname, thr1); + } + return 0; diff --git a/slsDetectorCalibration/moenchExecutables/moenchZmqAnalog.cpp b/slsDetectorCalibration/moenchExecutables/moenchZmqAnalog.cpp deleted file mode 100644 index 4cbee47d0..000000000 --- a/slsDetectorCalibration/moenchExecutables/moenchZmqAnalog.cpp +++ /dev/null @@ -1,394 +0,0 @@ -//#define ROOTSPECTRUM - -#include "multiThreadedAnalogDetector.h" - -#include "sls_receiver_defs.h" -#include "ZmqSocket.h" -#include "moench03T1ZmqDataNew.h" - -#ifdef ROOTSPECTRUM -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -#include -#include -#include -#include -#include -#include "tiffIO.h" - -#include - -//#include "analogDetector.h" -#include "singlePhotonDetector.h" -#include "ansi.h" -#include -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 *filter=new analogDetector(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; -} - diff --git a/slsDetectorCalibration/moenchExecutables/moenchZmqClusterFinder.cpp b/slsDetectorCalibration/moenchExecutables/moenchZmqClusterFinder.cpp deleted file mode 100644 index 276372245..000000000 --- a/slsDetectorCalibration/moenchExecutables/moenchZmqClusterFinder.cpp +++ /dev/null @@ -1,402 +0,0 @@ -#include "sls_receiver_defs.h" -#include "ZmqSocket.h" -#include "moench03T1ZmqDataNew.h" -#include -#include -#include -#include -#include -#include "tiffIO.h" - - -//#define NEWZMQ -#ifdef NEWZMQ -#include //json header in zmq stream -#endif - -#include - -//#include "analogDetector.h" -#include "singlePhotonDetector.h" -#include "multiThreadedAnalogDetector.h" -#include "ansi.h" -#include -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 *filter=new analogDetector(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; ixSendHeaderData (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; -} - diff --git a/slsDetectorCalibration/moenchExecutables/moenchZmqInterpolating.cpp b/slsDetectorCalibration/moenchExecutables/moenchZmqInterpolating.cpp deleted file mode 100644 index 2bd7e48f2..000000000 --- a/slsDetectorCalibration/moenchExecutables/moenchZmqInterpolating.cpp +++ /dev/null @@ -1,292 +0,0 @@ -#include "sls_receiver_defs.h" -#include "ZmqSocket.h" -#include "moench03T1ZmqDataNew.h" -#include -#include -#include -#include -#include -#include "tiffIO.h" - -#include - -//#include "analogDetector.h" -#include "interpolatingDetector.h" -#include "linearInterpolation.h" -#include "multiThreadedAnalogDetector.h" -#include "ansi.h" -#include -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; ixSendHeaderData(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; -} - diff --git a/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp b/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp index 19cd832b1..6653dc4a1 100644 --- a/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp +++ b/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp @@ -1,8 +1,15 @@ #define WRITE_QUAD +#define DEVELOPER -#include "sls_receiver_defs.h" +#define C_GHOST 0.0004 + +#define CM_ROWS 20 + +#include "sls_detector_defs.h" #include "ZmqSocket.h" #include "moench03T1ZmqDataNew.h" +#include "moench03GhostSummation.h" +#include "moench03CommonMode.h" #include #include #include @@ -10,10 +17,7 @@ #include #include "tiffIO.h" -//#define NEWZMQ -#ifdef NEWZMQ #include //json header in zmq stream -#endif #include @@ -47,9 +51,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 +67,7 @@ int main(int argc, char *argv[]) { char* socketip2 = 0; uint32_t portnum2 = 0; + uint32_t nSigma=5; int ok; @@ -86,17 +93,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(); @@ -109,16 +121,44 @@ int main(int argc, char *argv[]) { 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 *filter=new analogDetector(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 +169,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 +260,22 @@ int main(int argc, char *argv[]) { // header variables uint64_t acqIndex = -1; uint64_t frameIndex = -1; - uint32_t subFrameIndex = -1; + //uint32_t subFrameIndex = -1; uint64_t fileindex = -1; string filename = ""; // char* image = new char[size]; //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 length; int *detimage; 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 +289,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; uint16_t roundRNumber = 0; uint8_t detType = 0; uint8_t version = 0; - int* flippedData = 0; + // int* flippedData = 0; char* additionalJsonHeader = 0; int32_t threshold=0; @@ -261,15 +301,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); @@ -314,20 +353,20 @@ int main(int argc, char *argv[]) { } } else { if (fMode==ePedestal) { - sprintf(ofname,"%s_%d_ped.tiff",fname,fileindex); + sprintf(ofname,"%s_%ld_ped.tiff",fname,fileindex); mt->writePedestal(ofname); cout << "Writing pedestal to " << ofname << endl; } #ifdef INTERP else if (fMode==eFlat) { mt->prepareInterpolation(ok); - sprintf(ofname,"%s_%d_eta.tiff",fname,fileindex); + sprintf(ofname,"%s_%ld_eta.tiff",fname,fileindex); mt->writeFlatField(ofname); cout << "Writing eta to " << ofname << endl; } #endif else { - sprintf(ofname,"%s_%d.tiff",fname,fileindex); + sprintf(ofname,"%s_%ld.tiff",fname,fileindex); mt->writeImage(ofname); cout << "Writing image to " << ofname << endl; } @@ -356,7 +395,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; @@ -395,17 +434,59 @@ int main(int argc, char *argv[]) { } + //// int SendHeaderData ( int index, bool dummy, uint32_t jsonversion, uint32_t dynamicrange = 0, uint64_t fileIndex = 0, + // uint32_t ndetx = 0, uint32_t ndety = 0, uint32_t npixelsx = 0, uint32_t npixelsy = 0, uint32_t imageSize = 0, + // uint64_t acqIndex = 0, uint64_t fIndex = 0, const char* fname = NULL, + // uint64_t frameNumber = 0, uint32_t expLength = 0, uint32_t packetNumber = 0, + // uint64_t bunchId = 0, uint64_t timestamp = 0, + // uint16_t modId = 0, uint16_t row = 0, uint16_t column = 0, uint16_t reserved = 0, + // uint32_t debug = 0, uint16_t roundRNumber = 0, + // uint8_t detType = 0, uint8_t version = 0, int gapPixelsEnable = 0, int flippedDataX = 0, + // char* additionalJsonHeader = 0) { -#ifdef NEWZMQ - cout << "Sending image size " << nnx << " " << nny << endl; - 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); - + + + // cout << "Sending image size " << nnx << " " << nny << endl; + +#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 -#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 - +#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 + /* + int SendHeaderData ( int index, bool dummy, uint32_t jsonversion, uint32_t dynamicrange = 0, uint64_t fileIndex = 0, + uint32_t npixelsx = 0, uint32_t npixelsy = 0, uint32_t imageSize = 0, + uint64_t acqIndex = 0, uint64_t fIndex = 0, char* fname = NULL, + uint64_t frameNumber = 0, uint32_t expLength = 0, uint32_t packetNumber = 0, + uint64_t bunchId = 0, uint64_t timestamp = 0, + uint16_t modId = 0, uint16_t row = 0, uint16_t column = 0, uint16_t reserved = 0, + uint32_t debug = 0, uint16_t roundRNumber = 0, + uint8_t detType = 0, uint8_t version = 0, int* flippedData = 0, + char* additionalJsonHeader = 0) { +int ZmqSocket::SendHeaderData(int 0, bool false, uint32_t SLS_DETECTOR_JSON_HEADER_VERSION , uint32_t dr, uint64_t fileindex, uint32_t 0, uint32_t 0, uint32_t, uint64_t, uint64_t, char*, uint64_t, uint32_t, uint32_t, uint64_t, uint64_t, uint16_t, uint16_t, uint16_t, uint16_t, uint32_t, uint16_t, uint8_t, uint8_t, int*, char*) + + */ + //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,additionalJsonHeader); + zmqsocket2->SendHeaderData (0, false, SLS_DETECTOR_JSON_HEADER_VERSION, dr, fileindex, nnx, nny, nnx*nny*dr/8,acqIndex, frameIndex, fname, acqIndex, subFrameIndex, packetNumber,bunchId, timestamp, modId, xCoord, yCoord, zCoord,debug, roundRNumber, detType, version, flippedData, additionalJsonHeader); + + /* old + 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); + */ + /* + + + new + 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,additionalJsonHeader); + */ +#endif + + + zmqsocket2->SendData((char*)dout,nnx*nny*dr/8); cprintf(GREEN, "Sent Data\n"); @@ -443,7 +524,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 +541,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 +575,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 +585,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"; } @@ -657,7 +738,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); @@ -681,13 +767,15 @@ int main(int argc, char *argv[]) { if (packetNumber>=40) { //*((int*)buff)=frameIndex; memcpy(buff,&frameIndex,sizeof(int)); - length = zmqsocket->ReceiveData(0, buff+sizeof(int), size); + //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); + //length = + zmqsocket->ReceiveData(0, dummybuff, size); } diff --git a/slsDetectorCalibration/moenchExecutables/tiff_to_th2f.cpp b/slsDetectorCalibration/moenchExecutables/tiff_to_th2f.cpp deleted file mode 100644 index 3e248feaa..000000000 --- a/slsDetectorCalibration/moenchExecutables/tiff_to_th2f.cpp +++ /dev/null @@ -1,57 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "tiffIO.h" - -#include - -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; ixSetBinContent(ix+1, iy+1, data[ix+iy*nx]); - } - } - h2->Write(); - fout->Close(); - } - delete [] data; - } - - - - return 0; -} - diff --git a/slsDetectorCalibration/multiThreadedAnalogDetector.h b/slsDetectorCalibration/multiThreadedAnalogDetector.h index d69fe033c..5aaa31e51 100644 --- a/slsDetectorCalibration/multiThreadedAnalogDetector.h +++ b/slsDetectorCalibration/multiThreadedAnalogDetector.h @@ -32,11 +32,11 @@ class threadedAnalogDetector { public: threadedAnalogDetector(analogDetector *d, int fs=10000) { - char *mem, *mm; + char *mm;//*mem, det=d; fifoFree=new CircularFifo(fs); fifoData=new CircularFifo(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 << "ghos summation is " << det->getGhostSummation()<< endl; return (pthread_create(&_thread, NULL, processData, this) == 0); } @@ -111,11 +116,11 @@ 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;} @@ -182,16 +187,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){ @@ -228,7 +236,6 @@ protected: int dMode; int *dataSize; pthread_t _thread; - char *mem; CircularFifo *fifoFree; CircularFifo *fifoData; int stop; @@ -292,15 +299,15 @@ public: StopThreads(); for (int i=0; isetFrameMode(fm);} return ret;}; - virtual double setThreshold(int fm) { double ret; for (int i=0; isetThreshold(fm); return ret;}; - virtual int setDetectorMode(int dm) { int ret; for (int i=0; isetDetectorMode(dm); return ret;}; + virtual int setFrameMode(int fm) { int ret=dets[0]->setFrameMode(fm); for (int i=1; isetFrameMode(fm);} return ret;}; + virtual double setThreshold(int fm) { double ret=dets[0]->setThreshold(fm); for (int i=1; isetThreshold(fm); return ret;}; + virtual int setDetectorMode(int dm) { int ret=dets[0]->setDetectorMode(dm);; for (int i=1; isetDetectorMode(dm); return ret;}; virtual void setROI(int xmin, int xmax, int ymin, int ymax) { for (int i=0; isetROI(xmin, xmax,ymin,ymax);}; @@ -408,12 +415,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() { @@ -493,20 +500,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; ixsetNSigma(n); return ret;}; + virtual double setNSigma(double n) {double ret=(dets[0])->setNSigma(n); for (int i=1; isetNSigma(n); return ret;}; virtual void setEnergyRange(double emi, double ema) {for (int i=0; isetEnergyRange(emi,ema);}; }; diff --git a/slsDetectorCalibration/multiThreadedInterpolatingDetector.h b/slsDetectorCalibration/multiThreadedInterpolatingDetector.h index bda801afa..cf45f4c80 100644 --- a/slsDetectorCalibration/multiThreadedInterpolatingDetector.h +++ b/slsDetectorCalibration/multiThreadedInterpolatingDetector.h @@ -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; isetInterpolation(f); return (dets[0])->getInterpolation(); diff --git a/slsDetectorCalibration/singlePhotonDetector.h b/slsDetectorCalibration/singlePhotonDetector.h index 0ff15b03f..99554ab54 100644 --- a/slsDetectorCalibration/singlePhotonDetector.h +++ b/slsDetectorCalibration/singlePhotonDetector.h @@ -58,7 +58,7 @@ public analogDetector { int sign=1, commonModeSubtraction *cm=NULL, int nped=1000, - int nd=100, int nnx=-1, int nny=-1, double *gm=NULL) : analogDetector(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 *gs=NULL) : analogDetector(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 { //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 { 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 { 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) { diff --git a/slsDetectorCalibration/single_photon_hit.h b/slsDetectorCalibration/single_photon_hit.h index 7bb53120f..5c4c130e9 100644 --- a/slsDetectorCalibration/single_photon_hit.h +++ b/slsDetectorCalibration/single_photon_hit.h @@ -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: */ + /* ; */ + /* } */ - } + /* } */ - } + /* } */ - 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,7 +211,7 @@ class single_photon_hit { void print() { - int ix, iy; + // int ix, iy; for (int iy=0; iy -#include - -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 diff --git a/slsDetectorCalibration/single_photon_hit_old.h b/slsDetectorCalibration/single_photon_hit_old.h deleted file mode 100644 index 587a09c1f..000000000 --- a/slsDetectorCalibration/single_photon_hit_old.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef SINGLE_PHOTON_HIT_H -#define SINGLE_PHOTON_HIT_H -#include -#include - -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 diff --git a/slsDetectorCalibration/slsDetectorCalibration.doxy b/slsDetectorCalibration/slsDetectorCalibration.doxy deleted file mode 100644 index 4ea3784d3..000000000 --- a/slsDetectorCalibration/slsDetectorCalibration.doxy +++ /dev/null @@ -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 \ No newline at end of file diff --git a/slsDetectorCalibration/tiffIO.cpp b/slsDetectorCalibration/tiffIO.cpp index 00223918f..5b3d7b737 100644 --- a/slsDetectorCalibration/tiffIO.cpp +++ b/slsDetectorCalibration/tiffIO.cpp @@ -4,20 +4,20 @@ #include 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 << "--" <