diff --git a/slsDetectorCalibration/dataStructures/moench03T1ZmqDataNew.h b/slsDetectorCalibration/dataStructures/moench03T1ZmqDataNew.h index 479170ea1..5cdb74242 100644 --- a/slsDetectorCalibration/dataStructures/moench03T1ZmqDataNew.h +++ b/slsDetectorCalibration/dataStructures/moench03T1ZmqDataNew.h @@ -276,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/interpolatingDetector.h b/slsDetectorCalibration/interpolatingDetector.h index dc9002caa..a91fe5dbe 100644 --- a/slsDetectorCalibration/interpolatingDetector.h +++ b/slsDetectorCalibration/interpolatingDetector.h @@ -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/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 = "<popFree(buff); - while (mt->isBusy()) {;} + ifr++; diff --git a/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp b/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp index 2cd8db82e..6653dc4a1 100644 --- a/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp +++ b/slsDetectorCalibration/moenchExecutables/moenchZmqProcess.cpp @@ -1,4 +1,9 @@ #define WRITE_QUAD +#define DEVELOPER + +#define C_GHOST 0.0004 + +#define CM_ROWS 20 #include "sls_detector_defs.h" #include "ZmqSocket.h" @@ -46,6 +51,8 @@ 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] [gainmap] [etafile]\n"); @@ -60,6 +67,7 @@ int main(int argc, char *argv[]) { char* socketip2 = 0; uint32_t portnum2 = 0; + uint32_t nSigma=5; int ok; @@ -85,7 +93,6 @@ 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; @@ -114,22 +121,24 @@ 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=20; - double xt_ghost=0.0004; + + 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, npy, npx); - if (gm) { + 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, cm, 1000, 10, -1, -1, gainmap, gs); + singlePhotonDetector *filter=new singlePhotonDetector(det,3, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs); multiThreadedCountingDetector *mt=new multiThreadedCountingDetector(filter,nthreads,fifosize); @@ -160,7 +169,7 @@ int main(int argc, char *argv[]) { if (etafname) interp->readFlatField(etafname); - interpolatingDetector *filter=new interpolatingDetector(det,interp, 5, 1, cm, 1000, 10, -1, -1, gainmap, gs); + interpolatingDetector *filter=new interpolatingDetector(det,interp, nSigma, 1, cm, 1000, 10, -1, -1, gainmap, gs); multiThreadedInterpolatingDetector *mt=new multiThreadedInterpolatingDetector(filter,nthreads,fifosize); #endif @@ -251,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; @@ -279,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; @@ -292,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); @@ -345,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; } @@ -387,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; @@ -437,8 +445,47 @@ int main(int argc, char *argv[]) { // char* additionalJsonHeader = 0) { + // 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 + +#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"); @@ -477,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(); @@ -494,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()); @@ -528,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: "); @@ -538,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"; } @@ -692,10 +739,10 @@ int main(int argc, char *argv[]) { // cout << "data " << endl; if (of==NULL) { #ifdef WRITE_QUAD - sprintf(ofname,"%s_%d.clust2",filename.c_str(),fileindex); + sprintf(ofname,"%s_%ld.clust2",filename.c_str(),fileindex); #endif #ifndef WRITE_QUAD - sprintf(ofname,"%s_%d.clust",filename.c_str(),fileindex); + sprintf(ofname,"%s_%ld.clust",filename.c_str(),fileindex); #endif of=fopen(ofname,"w"); if (of) { @@ -720,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/multiThreadedAnalogDetector.h b/slsDetectorCalibration/multiThreadedAnalogDetector.h index 3f4d4982e..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,7 +98,7 @@ 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() @@ -114,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;} @@ -185,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){ @@ -231,7 +236,6 @@ protected: int dMode; int *dataSize; pthread_t _thread; - char *mem; CircularFifo *fifoFree; CircularFifo *fifoData; int stop; @@ -295,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);}; @@ -411,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() { @@ -496,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/single_photon_hit.h b/slsDetectorCalibration/single_photon_hit.h index 85cbd10f1..5c4c130e9 100644 --- a/slsDetectorCalibration/single_photon_hit.h +++ b/slsDetectorCalibration/single_photon_hit.h @@ -119,7 +119,7 @@ class single_photon_hit { if (fread((void*)qq, 1, 4*sizeof(int), myFile)) { quad=TOP_RIGHT; - int mm=qq[0]; + /* int mm=qq[0]; */ /* for (int i=1; i<4; i++) { */ /* if (qq[i]>mm) { */ /* switch (i) { */