From 506ca8d6b0ef4f12111073eacdf08ba5d8048dfe Mon Sep 17 00:00:00 2001 From: l_maliakal_d Date: Thu, 20 Feb 2014 13:24:40 +0000 Subject: [PATCH] gotthard works for short frame git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@740 951219d9-93cf-4727-9268-0efd64621fa3 --- .../slsReceiver/receiver_defs.h | 3 + .../slsReceiver/slsReceiverFunctionList.cpp | 278 ++++++++---------- .../slsReceiver/slsReceiverFunctionList.h | 12 +- 3 files changed, 127 insertions(+), 166 deletions(-) diff --git a/slsDetectorSoftware/slsReceiver/receiver_defs.h b/slsDetectorSoftware/slsReceiver/receiver_defs.h index 4644183f5..f8a0ec136 100755 --- a/slsDetectorSoftware/slsReceiver/receiver_defs.h +++ b/slsDetectorSoftware/slsReceiver/receiver_defs.h @@ -35,6 +35,9 @@ #define GOTTHARD_SHORT_FRAME_INDEX_MASK 0xFFFFFFFF #define GOTTHARD_SHORT_FRAME_INDEX_OFFSET 0 #define GOTTHARD_SHORT_PACKET_INDEX_MASK 0 +#define GOTTHARD_SHORT_PIXELS_IN_ROW 256 +#define GOTTHARD_SHORT_PIXELS_IN_COL 1 + #define GOTTHARD_FRAME_INDEX_MASK 0xFFFFFFFE #define GOTTHARD_FRAME_INDEX_OFFSET 1 diff --git a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp index 0465b061c..d5c2c018a 100644 --- a/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp +++ b/slsDetectorSoftware/slsReceiver/slsReceiverFunctionList.cpp @@ -7,6 +7,11 @@ #include "slsReceiverFunctionList.h" +#include "moench02ModuleData.h" +#include "gotthardModuleData.h" +#include "gotthardShortModuleData.h" + + #include // SIGINT #include // stat #include // socket(), bind(), listen(), accept(), shut down @@ -106,8 +111,7 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det): cmSub = NULL; for(int i=0;i(mdecoder[i], 3, sigma, sign, cmSub); - } - break; +} - default: - for(int i=0;i(gdecoder[i], 1, sigma, sign); - } - break; +void slsReceiverFunctionList::setupFilter(){ + double hc = 0; + double sigma = 5; + int sign = 1; + int csize; + int i; + + + if (commonModeSubtractionEnable) + cmSub=new moenchCommonMode(); + + + + switch(myDetectorType){ + case MOENCH: + csize = 3; + for(i=0;i(receiverdata[i], csize, sigma, sign, cmSub); + + } @@ -802,9 +819,7 @@ void slsReceiverFunctionList::closeFile(int ithr){ } else{ //write to file - /*if(packetsInFile){*/ if(myTree[ithr] && myFile[ithr]){ - /*if(tall->Write(tall->GetName(),TObject::kOverwrite);*/ myFile[ithr] = myTree[ithr]->GetCurrentFile(); if(myFile[ithr]->Write()) cout << "Thread " << ithr <<" wrote frames to file" << endl; @@ -812,8 +827,6 @@ void slsReceiverFunctionList::closeFile(int ithr){ cout << "Thread " << ithr << " could not write frames to file" << endl; }else cout << "Thread " << ithr << " could not write frames to file: No file or No Tree" << endl; - /* packetsInFile = 0; - }*/ //close file if(myTree[ithr] && myFile[ithr]) myFile[ithr] = myTree[ithr]->GetCurrentFile(); @@ -1179,11 +1192,26 @@ int slsReceiverFunctionList::startWriting(){ char* wbuf; char *data=new char[bufferSize]; int iFrame = 0; + int xmax=0,ymax=0; + while(1){ nf = 0; iFrame = 0; + if(myDetectorType == MOENCH){ + xmax = MOENCH_PIXELS_IN_ONE_ROW-1; + ymax = MOENCH_PIXELS_IN_ONE_ROW-1; + }else{ + if(shortFrame == -1){ + xmax = GOTTHARD_PIXELS_IN_ROW-1; + ymax = GOTTHARD_PIXELS_IN_COL-1; + }else{ + xmax = GOTTHARD_SHORT_PIXELS_IN_ROW-1; + ymax = GOTTHARD_SHORT_PIXELS_IN_COL-1; + } + } + while((1< 0){ - /*if(numWriterThreads >1) - pthread_mutex_lock(&progress_mutex);*/ writeToFile_withoutCompression(wbuf, numpackets); - /*if(numWriterThreads >1) - pthread_mutex_unlock(&progress_mutex);*/ } //copy to gui copyFrameToGui(wbuf + HEADER_SIZE_NUM_TOT_PACKETS); @@ -1317,138 +1341,70 @@ int slsReceiverFunctionList::startWriting(){ int np; int once = 0; double tot, tl, tr, bl, br, v; - int xmin = 1, ymin = 1, xmax, ymax, ix, iy; + int xmin = 1, ymin = 1, ix, iy; - if(myDetectorType == MOENCH){ + while(buff = receiverdata[ithread]->findNextFrame(data,ndata,remainingsize )){ + np = ndata/onePacketSize; - xmax = MOENCH_PIXELS_IN_ONE_ROW-1, ymax = MOENCH_PIXELS_IN_ONE_ROW-1; + //cout<<"buff framnum:"<> frameIndexOffset)<findNextFrame(data,ndata,remainingsize )){ - np = ndata/onePacketSize; - - //cout<<"buff framnum:"<> frameIndexOffset)<newFrame(); - if(commonModeSubtractionEnable){ - for(ix = xmin - 1; ix < xmax; ix++){ - for(iy = ymin - 1; iy < ymax; iy++){ - thisEvent = singlePhotonDet[ithread]->getEventType(buff, ix, iy, 0); - } + singlePhotonDet[ithread]->newFrame(); + + //only for moench + if(commonModeSubtractionEnable){ + for(ix = xmin - 1; ix < xmax+1; ix++){ + for(iy = ymin - 1; iy < ymax+1; iy++){ + thisEvent = singlePhotonDet[ithread]->getEventType(buff, ix, iy, 0); } } - for(ix = xmin - 1; ix < xmax; ix++) - for(iy = ymin - 1; iy < ymax; iy++){ - thisEvent=singlePhotonDet[ithread]->getEventType(buff, ix, iy, commonModeSubtractionEnable); - if (nf>1000) { - tot=0; - tl=0; - tr=0; - bl=0; - br=0; - if (thisEvent==PHOTON_MAX) { - - iFrame=mdecoder[ithread]->getFrameNumber(buff); - myTree[ithread]->Fill(); - //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!"<getEventType(buff, ix, iy, commonModeSubtractionEnable); + if (nf>1000) { + tot=0; + tl=0; + tr=0; + bl=0; + br=0; + if (thisEvent==PHOTON_MAX) { - } - - - - //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; ix++) - for(iy = ymin - 1; iy < ymax; 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); - myTree[ithread]->Fill(); - //cout << "Fill in event: frmNr: " << iFrame << " ix " << ix << " iy " << iy << " type " << thisEvent << endl; - } + iFrame=receiverdata[ithread]->getFrameNumber(buff); + myTree[ithread]->Fill(); + //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!"< (wbuf + HEADER_SIZE_NUM_TOT_PACKETS + numpackets * onePacketSize) ) + cout <<" **************ERROR SHOULD NOT COME HERE, Error 142536!"<push(wbuf)); #ifdef VERYVERBOSE cout<<"buf freed:"<<(void*)wbuf< *singlePhotonDet[MAX_NUM_WRITER_THREADS]; - moench02ModuleData *mdecoder[MAX_NUM_WRITER_THREADS]; - - gotthardModuleData *gdecoder[MAX_NUM_WRITER_THREADS]; + slsReceiverData *receiverdata[MAX_NUM_WRITER_THREADS]; moenchCommonMode *cmSub;