included without root writing

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@749 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d 2014-03-07 12:07:21 +00:00
parent 7f22b3ff99
commit 583281b903
3 changed files with 46 additions and 62 deletions

View File

@ -1,7 +1,7 @@
CFLAGS= -g -DC_ONLY -fPIC CFLAGS= -g -DC_ONLY -fPIC
#FLAGS+= #-DVERBOSE -DVERYVERBOSE #FLAGS+= #-DVERBOSE -DVERYVERBOSE
DFLAGS= -g -DDACS_INT -DTHIS_PATH='"$(shell pwd)"' -DSLS_RECEIVER_FUNCTION_LIST $(shell root-config --cflags --glibs) -DMYROOT1 -DALLFILE #-DMYROOT1 `root-config --cflags --glibs` DFLAGS= -g -DDACS_INT -DTHIS_PATH='"$(shell pwd)"' -DSLS_RECEIVER_FUNCTION_LIST $(shell root-config --cflags --glibs) #-DALLFILE_DEBUG #-DMYROOT1 -DALLFILE #-DMYROOT1 `root-config --cflags --glibs`
#ASM=$(shell echo "/lib/modules/`uname -r`/build/include") #ASM=$(shell echo "/lib/modules/`uname -r`/build/include")

View File

@ -110,18 +110,17 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det):
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++){
#ifdef MYROOT1
commonModeSubtractionEnable = false; commonModeSubtractionEnable = false;
singlePhotonDet[i] = NULL; singlePhotonDet[i] = NULL;
receiverdata[i] = NULL; receiverdata[i] = NULL;
#ifdef MYROOT1
myTree[i] = (NULL); myTree[i] = (NULL);
myFile[i] = (NULL); myFile[i] = (NULL);
#endif #endif
} }
#ifdef MYROOT1
cmSub = NULL;
#endif
setupFifoStructure(); setupFifoStructure();
@ -170,14 +169,12 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det):
slsReceiverFunctionList::~slsReceiverFunctionList(){ slsReceiverFunctionList::~slsReceiverFunctionList(){
createListeningThreads(true); createListeningThreads(true);
createWriterThreads(true); createWriterThreads(true);
#ifdef MYROOT1
for(int i=0;i<numWriterThreads;i++){ for(int i=0;i<numWriterThreads;i++){
if(singlePhotonDet[i]) if(singlePhotonDet[i])
delete singlePhotonDet[i]; delete singlePhotonDet[i];
if(receiverdata[i]) if(receiverdata[i])
delete receiverdata[i]; delete receiverdata[i];
} }
#endif
if(udpSocket) delete udpSocket; if(udpSocket) delete udpSocket;
if(eth) delete [] eth; if(eth) delete [] eth;
if(latestData) delete [] latestData; if(latestData) delete [] latestData;
@ -323,10 +320,6 @@ int64_t slsReceiverFunctionList::setAcquisitionPeriod(int64_t index){
int slsReceiverFunctionList::enableDataCompression(bool enable){ int slsReceiverFunctionList::enableDataCompression(bool enable){
#ifndef MYROOT1
return FAIL;
#endif
cout << "Data compression "; cout << "Data compression ";
if(enable) if(enable)
cout << "enabled" << endl; cout << "enabled" << endl;
@ -364,10 +357,10 @@ int slsReceiverFunctionList::enableDataCompression(bool enable){
void slsReceiverFunctionList::deleteFilter(){ void slsReceiverFunctionList::deleteFilter(){
#ifdef MYROOT1 int i;
cmSub=NULL; cmSub=NULL;
for(int i=0;i<numWriterThreads;i++){ for(i=0;i<numWriterThreads;i++){
if(singlePhotonDet[i]){ if(singlePhotonDet[i]){
delete singlePhotonDet[i]; delete singlePhotonDet[i];
singlePhotonDet[i] = NULL; singlePhotonDet[i] = NULL;
@ -377,13 +370,11 @@ void slsReceiverFunctionList::deleteFilter(){
receiverdata[i] = NULL; receiverdata[i] = NULL;
} }
} }
#endif
} }
void slsReceiverFunctionList::setupFilter(){ void slsReceiverFunctionList::setupFilter(){
#ifdef MYROOT1
double hc = 0; double hc = 0;
double sigma = 5; double sigma = 5;
int sign = 1; int sign = 1;
@ -414,7 +405,6 @@ void slsReceiverFunctionList::setupFilter(){
for(i=0;i<numWriterThreads;i++) for(i=0;i<numWriterThreads;i++)
singlePhotonDet[i]=new singlePhotonDetector<uint16_t>(receiverdata[i], csize, sigma, sign, cmSub); singlePhotonDet[i]=new singlePhotonDetector<uint16_t>(receiverdata[i], csize, sigma, sign, cmSub);
#endif
} }
@ -764,6 +754,8 @@ int slsReceiverFunctionList::setupWriter(){
//creating first file //creating first file
//mask
pthread_mutex_lock(&status_mutex); pthread_mutex_lock(&status_mutex);
for(int i=0;i<numWriterThreads;i++) for(int i=0;i<numWriterThreads;i++)
createfile_mask|=(1<<i); createfile_mask|=(1<<i);
@ -774,11 +766,6 @@ int slsReceiverFunctionList::setupWriter(){
cout << i << " gonna post 1st sem" << endl; cout << i << " gonna post 1st sem" << endl;
#endif #endif
sem_post(&writersmp[i]); sem_post(&writersmp[i]);
//wait for each file to be created
/*while((1<<i)&createfile_mask){
cout<<"*"<<flush;
usleep(5000);
}*/
} }
//wait till its created //wait till its created
while(createfile_mask){ while(createfile_mask){
@ -788,8 +775,9 @@ int slsReceiverFunctionList::setupWriter(){
if (createfile_mask) if (createfile_mask)
cout <<"*********************************************sooo weird:"<<createfile_mask<<endl; cout <<"*********************************************sooo weird:"<<createfile_mask<<endl;
if(dataCompression){ if(dataCompression){
#ifdef ALLFILE #if (defined(MYROOT1) && defined(ALLFILE_DEBUG)) || !defined(MYROOT1)
if(ret_createfile != FAIL){ if(ret_createfile != FAIL){
int ret = createNewFile(); int ret = createNewFile();
if(ret == FAIL) if(ret == FAIL)
@ -858,7 +846,6 @@ int slsReceiverFunctionList::createNewFile(){
//setting buffer //setting buffer
setvbuf(sfilefd,NULL,_IOFBF,BUF_SIZE); setvbuf(sfilefd,NULL,_IOFBF,BUF_SIZE);
if(!dataCompression){
//printing packet losses and file names //printing packet losses and file names
if(!packetsCaught) if(!packetsCaught)
cout << savefilename << endl; cout << savefilename << endl;
@ -874,14 +861,6 @@ int slsReceiverFunctionList::createNewFile(){
} }
} }
//data compression and dvpr flag allfile
else{
#ifdef ALLFILE
cout << "File created:" << savefilename << endl;
#endif
}
}
//reset counters for each new file //reset counters for each new file
if(packetsCaught){ if(packetsCaught){
@ -903,8 +882,8 @@ void slsReceiverFunctionList::closeFile(int ithr){
#ifdef VERBOSE #ifdef VERBOSE
cout << "In closeFile for thread " << ithr << endl; cout << "In closeFile for thread " << ithr << endl;
#endif #endif
if(!dataCompression){ if(!dataCompression){
//close file
if(sfilefd){ if(sfilefd){
#ifdef VERBOSE #ifdef VERBOSE
cout << "sfield:" << (int)sfilefd << endl; cout << "sfield:" << (int)sfilefd << endl;
@ -913,13 +892,9 @@ void slsReceiverFunctionList::closeFile(int ithr){
sfilefd = NULL; sfilefd = NULL;
} }
} }
//compression
//datacompression
else{ else{
#ifdef MYROOT1 #if (defined(MYROOT1) && defined(ALLFILE_DEBUG)) || !defined(MYROOT1)
#ifdef ALLFILE
//close file
if(sfilefd){ if(sfilefd){
#ifdef VERBOSE #ifdef VERBOSE
cout << "sfield:" << (int)sfilefd << endl; cout << "sfield:" << (int)sfilefd << endl;
@ -928,6 +903,8 @@ void slsReceiverFunctionList::closeFile(int ithr){
sfilefd = NULL; sfilefd = NULL;
} }
#endif #endif
#ifdef MYROOT1
pthread_mutex_lock(&write_mutex); pthread_mutex_lock(&write_mutex);
//write to file //write to file
if(myTree[ithr] && myFile[ithr]){ if(myTree[ithr] && myFile[ithr]){
@ -952,9 +929,6 @@ void slsReceiverFunctionList::closeFile(int ithr){
#endif #endif
} }
#ifdef VERBOSE
cout << ithr << " out of close file" << endl;
#endif
} }
@ -1457,15 +1431,10 @@ int slsReceiverFunctionList::startWriting(){
//data compression //data compression
else{ else{
#if defined(MYROOT1) && defined(ALLFILE_DEBUG)
#ifdef ALLFILE
writeToFile_withoutCompression(wbuf, numpackets); writeToFile_withoutCompression(wbuf, numpackets);
#ifndef MYROOT1
copyFrameToGui(wbuf + HEADER_SIZE_NUM_TOT_PACKETS);
#endif
#endif #endif
#ifdef MYROOT1
eventType thisEvent = PEDESTAL; eventType thisEvent = PEDESTAL;
int ndata; int ndata;
char* buff = 0; char* buff = 0;
@ -1511,8 +1480,15 @@ int slsReceiverFunctionList::startWriting(){
if (thisEvent==PHOTON_MAX) { if (thisEvent==PHOTON_MAX) {
iFrame=receiverdata[ithread]->getFrameNumber(buff); iFrame=receiverdata[ithread]->getFrameNumber(buff);
#ifdef MYROOT1
myTree[ithread]->Fill(); myTree[ithread]->Fill();
//cout << "Fill in event: frmNr: " << iFrame << " ix " << ix << " iy " << iy << " type " << thisEvent << endl; //cout << "Fill in event: frmNr: " << iFrame << " ix " << ix << " iy " << iy << " type " << thisEvent << endl;
#else
pthread_mutex_lock(&write_mutex);
if((enableFileWrite) && (sfilefd))
singlePhotonDet[ithread]->writeCluster(sfilefd);
pthread_mutex_unlock(&write_mutex);
#endif
} }
} }
} }
@ -1523,7 +1499,10 @@ int slsReceiverFunctionList::startWriting(){
packetsInFile += packetsPerFrame; packetsInFile += packetsPerFrame;
packetsCaught += packetsPerFrame; packetsCaught += packetsPerFrame;
totalPacketsCaught += packetsPerFrame; totalPacketsCaught += packetsPerFrame;
if(packetsInFile >= maxPacketsPerFile)
createNewFile();
pthread_mutex_unlock(&progress_mutex); pthread_mutex_unlock(&progress_mutex);
#endif #endif
if(!once){ if(!once){
copyFrameToGui(buff); copyFrameToGui(buff);
@ -1537,7 +1516,7 @@ int slsReceiverFunctionList::startWriting(){
cout <<" **************ERROR SHOULD NOT COME HERE, Error 142536!"<<endl; cout <<" **************ERROR SHOULD NOT COME HERE, Error 142536!"<<endl;
} }
#endif
while(!fifoFree->push(wbuf)); while(!fifoFree->push(wbuf));
#ifdef VERYVERBOSE #ifdef VERYVERBOSE
cout<<"buf freed:"<<(void*)wbuf<<endl; cout<<"buf freed:"<<(void*)wbuf<<endl;
@ -1562,11 +1541,13 @@ int slsReceiverFunctionList::startWriting(){
if((1<<ithread)&createfile_mask){ if((1<<ithread)&createfile_mask){
if(dataCompression){ if(dataCompression){
#ifdef MYROOT1
pthread_mutex_lock(&write_mutex); pthread_mutex_lock(&write_mutex);
ret = createCompressionFile(ithread,0); ret = createCompressionFile(ithread,0);
pthread_mutex_unlock(&write_mutex); pthread_mutex_unlock(&write_mutex);
if(ret == FAIL) if(ret == FAIL)
ret_createfile = FAIL; ret_createfile = FAIL;
#endif
}else{ }else{
ret = createNewFile(); ret = createNewFile();
if(ret == FAIL) if(ret == FAIL)

View File

@ -13,10 +13,12 @@
#include "genericSocket.h" #include "genericSocket.h"
#include "circularFifo.h" #include "circularFifo.h"
#ifdef MYROOT1
#include "singlePhotonDetector.h" #include "singlePhotonDetector.h"
#include "slsReceiverData.h" #include "slsReceiverData.h"
#include "moenchCommonMode.h" #include "moenchCommonMode.h"
#ifdef MYROOT1
#include <TTree.h> #include <TTree.h>
#include <TFile.h> #include <TFile.h>
#endif #endif
@ -511,13 +513,13 @@ private:
/** File Descriptor */ /** File Descriptor */
FILE *sfilefd; FILE *sfilefd;
#ifdef MYROOT1
//filter //filter
singlePhotonDetector<uint16_t> *singlePhotonDet[MAX_NUM_WRITER_THREADS]; singlePhotonDetector<uint16_t> *singlePhotonDet[MAX_NUM_WRITER_THREADS];
slsReceiverData<uint16_t> *receiverdata[MAX_NUM_WRITER_THREADS]; slsReceiverData<uint16_t> *receiverdata[MAX_NUM_WRITER_THREADS];
moenchCommonMode *cmSub; moenchCommonMode *cmSub;
bool commonModeSubtractionEnable; bool commonModeSubtractionEnable;
#ifdef MYROOT1
/** Tree where the hits are stored */ /** Tree where the hits are stored */
TTree *myTree[MAX_NUM_WRITER_THREADS]; TTree *myTree[MAX_NUM_WRITER_THREADS];
@ -526,6 +528,7 @@ private:
#endif #endif
/** /**
callback arguments are callback arguments are
filepath filepath