From 52f74142b12afe1d6feb89067d84a516142590bd Mon Sep 17 00:00:00 2001 From: Anna Bergamaschi Date: Thu, 28 Mar 2019 13:29:12 +0100 Subject: [PATCH] Moench working version --- examples/moench03_T1_lab.config | 19 +++-- slsDetectorCalibration/analogDetector.h | 6 +- .../moench03T1ReceiverDataNew.h | 4 +- .../moench03ClusterFinder.cpp | 27 ++++++- .../moench03ReorderImage.cpp | 22 +++--- .../moenchExecutables/moenchPhotonCounter.cpp | 77 +++++++++++-------- .../multiThreadedAnalogDetector.h | 18 +++-- 7 files changed, 107 insertions(+), 66 deletions(-) diff --git a/examples/moench03_T1_lab.config b/examples/moench03_T1_lab.config index f2d309bf3..f56c01dca 100644 --- a/examples/moench03_T1_lab.config +++ b/examples/moench03_T1_lab.config @@ -1,4 +1,4 @@ -hostname bchip085+ +hostname bchip011+ patword 0000 0000000000000000 patword 0001 0000000000000000 @@ -416,27 +416,30 @@ patwaittime2 0 ####mcp2011 +#0:rx_tcpport 1955 #0:rx_udpip 10.1.1.102 #0:detectorip 10.1.1.19 -#0:rx_udpport 32410 +#0:rx_udpport 32411 ####gui listening to -#zmqip 129.129.202.131 -#zmqport 30001 +#zmqip 129.129.202.106 +#zmqport 50001 ####data streaming out of #rx_zmqip 10.1.2.103 -#rx_zmqport 30003 +#rx_zmqport 50003 + #0:rx_hostname mpc2011 -####mx-test-1 +####pcmoench01 +0:rx_tcpport 1977 0:rx_udpip 10.1.1.100 0:detectorip 10.1.1.19 0:rx_udpport 32410 ####gui listening to (on receiver pc) zmqip 129.129.202.92 -zmqport 30001 +zmqport 50001 ####data streaming out of rx_zmqip 10.1.1.100 -rx_zmqport 30003 +rx_zmqport 50003 0:rx_hostname pcmoench01 diff --git a/slsDetectorCalibration/analogDetector.h b/slsDetectorCalibration/analogDetector.h index 65eaa651c..49197f0a6 100644 --- a/slsDetectorCalibration/analogDetector.h +++ b/slsDetectorCalibration/analogDetector.h @@ -854,9 +854,11 @@ template class analogDetector { if (g==0) g=-1.; } - if (det) + if (det) { + /* if (det->getChannel(data, ix, iy)>=0x3fff) */ + /* cout << ix << " " << iy << " " << det->getChannel(data, ix, iy) <getValue(data, ix, iy)-getPedestal(ix,iy,cm))/g; - else + } else val= (((double*)data)[iy*nx+ix]-getPedestal(ix,iy))/g; #ifdef ROOTSPECTRUM diff --git a/slsDetectorCalibration/dataStructures/moench03T1ReceiverDataNew.h b/slsDetectorCalibration/dataStructures/moench03T1ReceiverDataNew.h index 9c904e67f..d3a5e55e1 100644 --- a/slsDetectorCalibration/dataStructures/moench03T1ReceiverDataNew.h +++ b/slsDetectorCalibration/dataStructures/moench03T1ReceiverDataNew.h @@ -2,7 +2,7 @@ #define MOENCH03T1RECDATANEW_H #include "slsDetectorData.h" -#define VERSION_V2 +//#define VERSION_V2 /** @short structure for a Detector Packet or Image Header @li frameNumber is the frame number @@ -33,7 +33,7 @@ uint16_t roundRNumber; /**< is the round robin set number */ uint8_t detType; /**< is the detector type see :: detectorType */ uint8_t version; /**< is the version number of this structure format */ -#ifdef VERSION_V2 +#ifndef VERSION_V1 uint64_t packetCaught[8]; /**< is the version number of this structure format */ #endif diff --git a/slsDetectorCalibration/moenchExecutables/moench03ClusterFinder.cpp b/slsDetectorCalibration/moenchExecutables/moench03ClusterFinder.cpp index d963e8726..e05f9d38b 100644 --- a/slsDetectorCalibration/moenchExecutables/moench03ClusterFinder.cpp +++ b/slsDetectorCalibration/moenchExecutables/moench03ClusterFinder.cpp @@ -22,6 +22,10 @@ #include "moench03Ctb10GbT1Data.h" #endif +#ifdef REORDERED +#include "moench03T1ReorderedData.h" +#endif + // #include "interpolatingDetector.h" //#include "etaInterpolationPosXY.h" // #include "linearInterpolation.h" @@ -48,7 +52,7 @@ int main(int argc, char *argv[]) { } int p=10000; int fifosize=1000; - int nthreads=24; + int nthreads=1; int nsubpix=25; int etabins=nsubpix*10; double etamin=-1, etamax=2; @@ -83,6 +87,14 @@ int main(int argc, char *argv[]) { cout << "OLD RECEIVER DATA!"<getDetectorSize(nx,ny); + cout << "nx " << nx << " ny " << ny << endl; //moench03T1ZmqData *decoder=new moench03T1ZmqData(); singlePhotonDetector *filter=new singlePhotonDetector(decoder,csize, nsigma, 1, 0, nped, 200); @@ -183,11 +195,18 @@ int main(int argc, char *argv[]) { // cout << "*"<pushData(buff); + // for (int ix=0; ix<400; ix++) + // for (int iy=0; iy<400; iy++) { + // if (decoder->getChannel(buff, ix, iy)<3000 || decoder->getChannel(buff, ix, iy)>8000) { + // cout << ifr << " " << ff << " " << ix << " " << iy << " " << decoder->getChannel(buff, ix, iy) << endl ; + // } + // } + + mt->pushData(buff); // // //pop - mt->nextThread(); + mt->nextThread(); // // // cout << " " << (void*)buff; - mt->popFree(buff); + mt->popFree(buff); ifr++; if (ifr%10000==0) cout << ifr << " " << ff << endl; ff=-1; diff --git a/slsDetectorCalibration/moenchExecutables/moench03ReorderImage.cpp b/slsDetectorCalibration/moenchExecutables/moench03ReorderImage.cpp index 69b9b20c8..f6f7c55bb 100644 --- a/slsDetectorCalibration/moenchExecutables/moench03ReorderImage.cpp +++ b/slsDetectorCalibration/moenchExecutables/moench03ReorderImage.cpp @@ -57,8 +57,6 @@ int main(int argc, char *argv[]) { uint16_t data[NY*NX]; - int size = 327680;////atoi(argv[3]); - int* image; int ff, np; @@ -76,8 +74,6 @@ int main(int argc, char *argv[]) { char fname[10000]; char outfname[10000]; - char imgfname[10000]; - char pedfname[10000]; // strcpy(pedfname,argv[6]); char fn[10000]; @@ -98,7 +94,7 @@ int main(int argc, char *argv[]) { - char* buff; + char buff[dsize]; @@ -112,7 +108,7 @@ int main(int argc, char *argv[]) { sprintf(outfname,"%s/%s_image.raw",outdir,fn); std::time(&end_time); cout << std::ctime(&end_time) << endl; - cout << fname << " " << outfname << " " << imgfname << endl; + // cout << fname << " " << outfname << " " << imgfname << endl; filebin.open((const char *)(fname), ios::in | ios::binary); // //open file if (filebin.is_open()){ @@ -126,10 +122,14 @@ int main(int argc, char *argv[]) { // //while read frame ff=-1; while (decoder->readNextFrame(filebin, ff, np,buff)) { - for (int ix=0; ix<400; ix++) - for (int iy=0; iy<400; iy++) - data[iy*NX+ix]=decoder->getChannel(buff,ix,iy); - + 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 @@ -138,7 +138,7 @@ int main(int argc, char *argv[]) { if (ifr%10000==0) cout << ifr << " " << ff << endl; ff=-1; - + // break; } cout << "--" << endl; filebin.close(); diff --git a/slsDetectorCalibration/moenchExecutables/moenchPhotonCounter.cpp b/slsDetectorCalibration/moenchExecutables/moenchPhotonCounter.cpp index 342f56a28..84d3ff865 100644 --- a/slsDetectorCalibration/moenchExecutables/moenchPhotonCounter.cpp +++ b/slsDetectorCalibration/moenchExecutables/moenchPhotonCounter.cpp @@ -2,6 +2,7 @@ #include +#define VERSION_V1 //#include "moench03T1ZmqData.h" #ifdef NEWRECEIVER @@ -52,14 +53,14 @@ int main(int argc, char *argv[]) { int p=10000; int fifosize=1000; - int nthreads=8; + int nthreads=1; int nsubpix=25; int etabins=nsubpix*10; double etamin=-1, etamax=2; int csize=3; int save=1; int nsigma=5; - int nped=1000; + int nped=10000; int ndark=100; int ok; int iprog=0; @@ -169,7 +170,11 @@ int main(int argc, char *argv[]) { //#ifndef ANALOG if (thr>0) { cout << "threshold is " << thr << endl; + + //#ifndef ANALOG filter->setThreshold(thr); + //#endif + } else cf=1; //#endif @@ -184,7 +189,9 @@ int main(int argc, char *argv[]) { cout << std::ctime(&end_time) << endl; char* buff; + multiThreadedAnalogDetector *mt=new multiThreadedAnalogDetector(filter,nthreads,fifosize); + #ifndef ANALOG mt->setDetectorMode(ePhotonCounting); cout << "Counting!" << endl; @@ -197,8 +204,7 @@ int main(int argc, char *argv[]) { mt->setDetectorMode(eAnalog); cout << "Analog!" << endl; cf=0; -// #ifdef ANALOG -// thr1=thr; + // thr1=thr; #endif // } @@ -229,11 +235,14 @@ int main(int argc, char *argv[]) { if (filebin.is_open()){ ff=-1; while (decoder->readNextFrame(filebin, ff, np,buff)) { - mt->pushData(buff); - mt->nextThread(); - mt->popFree(buff); - ifr++; - if (ifr%10000==0) + 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; } @@ -244,16 +253,18 @@ int main(int argc, char *argv[]) { cout << std::ctime(&end_time) << endl; } else - cout << "Could not open "<< fname << " for reading " << endl; + cout << "Could not open pedestal file "<< fname << " for reading " << endl; } + ifr=0; int ifile=0; + mt->setFrameMode(eFrame); + for (int irun=runmin; irun<=runmax; irun++) { cout << "DATA " ; - mt->setFrameMode(eFrame); // sprintf(fn,fformat,irun); sprintf(ffname,"%s/%s.raw",indir,fformat); sprintf(fname,ffname,irun); @@ -270,8 +281,7 @@ int main(int argc, char *argv[]) { // //open file ifile=0; if (filebin.is_open()){ - if (thr<=0) { - if (cf) { + if (thr<=0 && cf!=0) { //cluster finder if (of==NULL) { of=fopen(cfname,"w"); if (of) { @@ -283,35 +293,36 @@ int main(int argc, char *argv[]) { return 1; } } - } } // //while read frame ff=-1; ifr=0; while (decoder->readNextFrame(filebin, ff, np,buff)) { + if (np==40) { // cout << "*"<pushData(buff); - // // //pop - mt->nextThread(); - // // // cout << " " << (void*)buff; - mt->popFree(buff); - ifr++; - if (ifr%1000==0) cout << ifr << " " << ff << endl; - if (nframes>0) { - if (ifr%nframes==0) { - //The name has an additional "_fXXXXX" at the end, where "XXXXX" is the initial frame number of the image (0,1000,2000...) - - sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile); - sprintf(imgfname,ffname,irun); - //cout << "Writing tiff to " << imgfname << " " << thr1 << endl; - mt->writeImage(imgfname, thr1); - mt->clearImage(); - ifile++; + mt->pushData(buff); + // // //pop + mt->nextThread(); + // // // cout << " " << (void*)buff; + mt->popFree(buff); + ifr++; + if (ifr%1000==0) cout << ifr << " " << ff << endl; + if (nframes>0) { + if (ifr%nframes==0) { + //The name has an additional "_fXXXXX" at the end, where "XXXXX" is the initial frame number of the image (0,1000,2000...) + + sprintf(ffname,"%s/%s_f%05d.tiff",outdir,fformat,ifile); + sprintf(imgfname,ffname,irun); + //cout << "Writing tiff to " << imgfname << " " << thr1 << endl; + mt->writeImage(imgfname, thr1); + mt->clearImage(); + ifile++; + } } - } - + } else + cout << ifr << " " << ff << " " << np << endl; ff=-1; } cout << "--" << endl; diff --git a/slsDetectorCalibration/multiThreadedAnalogDetector.h b/slsDetectorCalibration/multiThreadedAnalogDetector.h index 1f400819d..d69fe033c 100644 --- a/slsDetectorCalibration/multiThreadedAnalogDetector.h +++ b/slsDetectorCalibration/multiThreadedAnalogDetector.h @@ -324,8 +324,11 @@ public: img=dets[ii]->getImage(); for (int i=0; i0) + image[i]=img[i]; + // else + // image[i]=0; + else //if (img[i]>0) image[i]+=img[i]; //if (img[i]) cout << "det " << ii << " pix " << i << " val " << img[i] << " " << image[i] << endl; } @@ -359,11 +362,14 @@ public: float *gm=new float[nn]; if (gm) { for (int ix=0; ix0 && ix/nnx<350) cout << ix/nnx << " " << ix%nnx << " " << image[ix]<< " " << gm[ix] << endl; } //cout << "image " << nnx << " " << nny << endl;