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
This commit is contained in:
l_maliakal_d 2014-02-13 10:51:21 +00:00
parent c366c97023
commit 45a93e827f
3 changed files with 118 additions and 46 deletions

View File

@ -40,6 +40,9 @@
#define GOTTHARD_FRAME_INDEX_OFFSET 1 #define GOTTHARD_FRAME_INDEX_OFFSET 1
#define GOTTHARD_PACKET_INDEX_MASK 0x1 #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 #define MOENCH_FIFO_SIZE 2500 //cannot be less than max jobs per thread = 1000

View File

@ -6,7 +6,6 @@
#include "slsReceiverFunctionList.h" #include "slsReceiverFunctionList.h"
#include "moenchCommonMode.h"
#include <signal.h> // SIGINT #include <signal.h> // SIGINT
#include <sys/stat.h> // stat #include <sys/stat.h> // stat
@ -104,9 +103,12 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det):
strcpy(savefilename,""); strcpy(savefilename,"");
strcpy(filePath,""); strcpy(filePath,"");
strcpy(fileName,"run"); strcpy(fileName,"run");
cmSub = NULL;
for(int i=0;i<numWriterThreads;i++){ for(int i=0;i<numWriterThreads;i++){
singlePhotonDet[i] = NULL; singlePhotonDet[i] = NULL;
mdecoder[i] = NULL; mdecoder[i] = NULL;
gdecoder[i] = NULL;
#ifdef MYROOT1 #ifdef MYROOT1
myTree[i] = (NULL); myTree[i] = (NULL);
myFile[i] = (NULL); myFile[i] = (NULL);
@ -264,7 +266,9 @@ int slsReceiverFunctionList::setShortFrame(int i){
onePacketSize = bufferSize/packetsPerFrame; onePacketSize = bufferSize/packetsPerFrame;
/*setupFilter();*/ /** done only in the case that compression can be chosen only at the beginn of program exe */
if(dataCompression)
setupFilter();
return shortFrame; return shortFrame;
} }
@ -330,22 +334,36 @@ void slsReceiverFunctionList::setupFilter(){
delete mdecoder[i]; delete mdecoder[i];
mdecoder[i] = NULL; mdecoder[i] = NULL;
} }
if(gdecoder[i]){
delete gdecoder[i];
gdecoder[i] = NULL;
}
} }
if(dataCompression){ if(dataCompression){
if(myDetectorType == MOENCH){ double hc = 0;
double hc=0; double sigma = 5;
int sign=1; int sign = 1;
cmSub=NULL;
switch(myDetectorType){
case MOENCH:
moenchCommonMode *cmSub=NULL;
if (commonModeSubtractionEnable) if (commonModeSubtractionEnable)
cmSub=new moenchCommonMode(); cmSub=new moenchCommonMode();
for(int i=0;i<numWriterThreads;i++){ for(int i=0;i<numWriterThreads;i++){
mdecoder[i]=new moench02ModuleData(hc); mdecoder[i]=new moench02ModuleData(hc);
singlePhotonDet[i]=new singlePhotonDetector<uint16_t>(mdecoder[i], 3, 5, sign, cmSub); singlePhotonDet[i]=new singlePhotonDetector<uint16_t>(mdecoder[i], 3, sigma, sign, cmSub);
} }
break;
default:
for(int i=0;i<numWriterThreads;i++){
gdecoder[i]=new gotthardModuleData(hc,shortFrame);
singlePhotonDet[i]=new singlePhotonDetector<uint16_t>(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 slsReceiverFunctionList::createThreads(bool destroy){
int i; 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 */ myFile[ithr] = new TFile(savefilename,"RECREATE");/** later return error if it exists */
cout<<"File created: "<<savefilename<<endl; cout<<"File created: "<<savefilename<<endl;
//tree //tree
sprintf(savefilename, "%s_fxxx_%d_%d_",fileName,fileIndex,ithr); sprintf(savefilename, "%s_fxxx_%d_%d",fileName,fileIndex,ithr);
myTree[ithr]=singlePhotonDet[ithr]->initEventTree(savefilename, &iframe); myTree[ithr]=singlePhotonDet[ithr]->initEventTree(savefilename, &iframe);
//resets the pedestalSubtraction array and the commonModeSubtraction //resets the pedestalSubtraction array and the commonModeSubtraction
singlePhotonDet[ithr]->newDataSet(); singlePhotonDet[ithr]->newDataSet();
@ -1304,20 +1309,22 @@ int slsReceiverFunctionList::startWriting(){
//data compression //data compression
else{ else{
#ifdef MYROOT1 #ifdef MYROOT1
if(myDetectorType == MOENCH){
//while
eventType thisEvent = PEDESTAL; eventType thisEvent = PEDESTAL;
int ndata; int ndata;
char* buff = 0; char* buff = 0;
data = wbuf+ HEADER_SIZE_NUM_TOT_PACKETS; data = wbuf+ HEADER_SIZE_NUM_TOT_PACKETS;
int xmin = 1, ymin = 1, xmax = 159/*(NC)*/, ymax = 159/*NR*/, ix, iy;
int ir, ic; int ir, ic;
int remainingsize = numpackets * onePacketSize; int remainingsize = numpackets * onePacketSize;
int np; int np;
int once = 0; int once = 0;
double tot, tl, tr, bl, br, v; double tot, tl, tr, bl, br, v;
int xmin = 1, ymin = 1, xmax, ymax, ix, iy;
if(myDetectorType == MOENCH){
xmax = MOENCH_PIXELS_IN_ONE_ROW-1, ymax = MOENCH_PIXELS_IN_ONE_ROW-1;
while(buff = mdecoder[ithread]->findNextFrame(data,ndata,remainingsize )){/**need mutex??????????*/ while(buff = mdecoder[ithread]->findNextFrame(data,ndata,remainingsize )){/**need mutex??????????*/
np = ndata/onePacketSize; 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:"<<ithread <<":"<< ((((uint32_t)(*((uint32_t*)buff)))& (frameIndexMask)) >> frameIndexOffset)<<endl;
if ((np == packetsPerFrame) && (buff!=NULL)){
if(nf == 1000) cout << " pedestal done " << endl;
singlePhotonDet[ithread]->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:"<<ithread <<":"<< ((((uint32_t)(*((uint32_t*)buff)))& (frameIndexMask)) >> frameIndexOffset)<<endl;
once = 1;
}
}
remainingsize -= ((buff + ndata) - data);
data = buff + ndata;
if(data > (wbuf + HEADER_SIZE_NUM_TOT_PACKETS + numpackets * onePacketSize) )
cout <<" **************WE HAVE A PROBLEM!"<<endl;
//cout << "remaining size: " << remainingsize << endl;
}
}
while(!fifoFree->push(wbuf)); while(!fifoFree->push(wbuf));
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout<<"buf freed:"<<(void*)wbuf<<endl; cout<<"buf freed:"<<(void*)wbuf<<endl;

View File

@ -15,6 +15,8 @@
#include "singlePhotonDetector.h" #include "singlePhotonDetector.h"
#include "moench02ModuleData.h" #include "moench02ModuleData.h"
#include "gotthardModuleData.h"
#include "moenchCommonMode.h"
#ifdef MYROOT1 #ifdef MYROOT1
#include <TTree.h> #include <TTree.h>
@ -186,17 +188,6 @@ public:
*/ */
void readFrame(char* c,char** raw); 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 * Starts Receiver - starts to listen for packets
* @param message is the error message if there is an error * @param message is the error message if there is an error
@ -532,6 +523,10 @@ private:
moench02ModuleData *mdecoder[MAX_NUM_WRITER_THREADS]; moench02ModuleData *mdecoder[MAX_NUM_WRITER_THREADS];
gotthardModuleData *gdecoder[MAX_NUM_WRITER_THREADS];
moenchCommonMode *cmSub;
bool commonModeSubtractionEnable; bool commonModeSubtractionEnable;
public: public: