From 45a93e827f88895fc967583a259f9a99c175a8c0 Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Thu, 13 Feb 2014 10:51:21 +0000 Subject: [PATCH] included compression for gotthard, but doesnt get data git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@736 951219d9-93cf-4727-9268-0efd64621fa3 --- .../slsReceiver/receiver_defs.h | 3 + .../slsReceiver/slsReceiverFunctionList.cpp | 144 +++++++++++++----- .../slsReceiver/slsReceiverFunctionList.h | 17 +-- 3 files changed, 118 insertions(+), 46 deletions(-) diff --git a/slsDetectorSoftware/slsReceiver/receiver_defs.h b/slsDetectorSoftware/slsReceiver/receiver_defs.h index 6321b1529..4644183f5 100755 --- a/slsDetectorSoftware/slsReceiver/receiver_defs.h +++ b/slsDetectorSoftware/slsReceiver/receiver_defs.h @@ -40,6 +40,9 @@ #define GOTTHARD_FRAME_INDEX_OFFSET 1 #define GOTTHARD_PACKET_INDEX_MASK 0x1 +#define GOTTHARD_PIXELS_IN_ROW 1280 +#define GOTTHARD_PIXELS_IN_COL 1 + #define MOENCH_FIFO_SIZE 2500 //cannot be less than max jobs per thread = 1000 diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp index b5d32a709..100eeb4ad 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp +++ b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp @@ -6,7 +6,6 @@ #include "slsReceiverFunctionList.h" -#include "moenchCommonMode.h" #include // SIGINT #include // stat @@ -104,9 +103,12 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det): strcpy(savefilename,""); strcpy(filePath,""); strcpy(fileName,"run"); + cmSub = NULL; for(int i=0;i(mdecoder[i], 3, 5, sign, cmSub); + singlePhotonDet[i]=new singlePhotonDetector(mdecoder[i], 3, sigma, sign, cmSub); } + break; + + + default: + for(int i=0;i(gdecoder[i], 1, sigma, sign); + } + break; + } } } @@ -524,19 +542,6 @@ int slsReceiverFunctionList::createUDPSocket(){ -void slsReceiverFunctionList::freeFifoBufferCallBack (char* fbuffer, void *this_pointer){ - ((slsReceiverFunctionList*)this_pointer)->freeFifoBuffer(fbuffer); -} - - - -void slsReceiverFunctionList::freeFifoBuffer(char* fbuffer){ - fifoFree->push(fbuffer); -} - - - - int slsReceiverFunctionList::createThreads(bool destroy){ int i; @@ -702,7 +707,7 @@ int slsReceiverFunctionList::createCompressionFile(int ithr, int iframe){ myFile[ithr] = new TFile(savefilename,"RECREATE");/** later return error if it exists */ cout<<"File created: "<initEventTree(savefilename, &iframe); //resets the pedestalSubtraction array and the commonModeSubtraction singlePhotonDet[ithr]->newDataSet(); @@ -1304,20 +1309,22 @@ int slsReceiverFunctionList::startWriting(){ //data compression else{ #ifdef MYROOT1 + + eventType thisEvent = PEDESTAL; + int ndata; + char* buff = 0; + data = wbuf+ HEADER_SIZE_NUM_TOT_PACKETS; + int ir, ic; + int remainingsize = numpackets * onePacketSize; + int np; + int once = 0; + double tot, tl, tr, bl, br, v; + int xmin = 1, ymin = 1, xmax, ymax, ix, iy; + + if(myDetectorType == MOENCH){ - //while - eventType thisEvent = PEDESTAL; - int ndata; - char* buff = 0; - data = wbuf+ HEADER_SIZE_NUM_TOT_PACKETS; - int xmin = 1, ymin = 1, xmax = 159/*(NC)*/, ymax = 159/*NR*/, ix, iy; - int ir, ic; - int remainingsize = numpackets * onePacketSize; - int np; - int once = 0; - - double tot, tl, tr, bl, br, v; + xmax = MOENCH_PIXELS_IN_ONE_ROW-1, ymax = MOENCH_PIXELS_IN_ONE_ROW-1; while(buff = mdecoder[ithread]->findNextFrame(data,ndata,remainingsize )){/**need mutex??????????*/ np = ndata/onePacketSize; @@ -1382,6 +1389,73 @@ int slsReceiverFunctionList::startWriting(){ } + + + //gotthard + else{ + + + xmax = GOTTHARD_PIXELS_IN_ROW, ymax = GOTTHARD_PIXELS_IN_COL; + + + while(buff = gdecoder[ithread]->findNextFrame(data,ndata,remainingsize )){/**need mutex??????????*/ + np = ndata/onePacketSize; + + //cout<<"buff framnum:"<> frameIndexOffset)<newFrame(); + + for(ix = xmin - 1; ix < xmax + 1; ix++) + for(iy = ymin - 1; iy < ymax + 1; iy++){ + thisEvent=singlePhotonDet[ithread]->getEventType(buff, ix, iy, 0); + if (nf>1000) { + tot=0; + tl=0; + tr=0; + bl=0; + br=0; + if (thisEvent==PHOTON_MAX) { + + iFrame=gdecoder[ithread]->getFrameNumber(buff);/**need mutex??????????*/ + pthread_mutex_lock(&write_mutex); + myTree[ithread]->Fill(); + pthread_mutex_unlock(&write_mutex); + //cout << "Fill in event: frmNr: " << iFrame << " ix " << ix << " iy " << iy << " type " << thisEvent << endl; + } + } + } + + nf++; + + pthread_mutex_lock(&write_mutex); + + packetsInFile += packetsPerFrame; + packetsCaught += packetsPerFrame; + totalPacketsCaught += packetsPerFrame; + + pthread_mutex_unlock(&write_mutex); + if(!once){ + copyFrameToGui(buff); + //cout<<"buff framnum:"<> frameIndexOffset)< (wbuf + HEADER_SIZE_NUM_TOT_PACKETS + numpackets * onePacketSize) ) + cout <<" **************WE HAVE A PROBLEM!"<push(wbuf)); #ifdef VERYVERBOSE cout<<"buf freed:"<<(void*)wbuf< @@ -186,17 +188,6 @@ public: */ void readFrame(char* c,char** raw); - - /** free fifo buffer, called back from single photon filter - */ - static void freeFifoBufferCallBack (char* fbuffer, void *this_pointer); - - /** - * Call back from single photon filter to free writingfifo - * called from freeFifoBufferCallBack - */ - void freeFifoBuffer(char* fbuffer); - /** * Starts Receiver - starts to listen for packets * @param message is the error message if there is an error @@ -532,6 +523,10 @@ private: moench02ModuleData *mdecoder[MAX_NUM_WRITER_THREADS]; + gotthardModuleData *gdecoder[MAX_NUM_WRITER_THREADS]; + + moenchCommonMode *cmSub; + bool commonModeSubtractionEnable; public: