diff --git a/slsDetectorSoftware/Makefile b/slsDetectorSoftware/Makefile index 47945af3d..590185b92 100644 --- a/slsDetectorSoftware/Makefile +++ b/slsDetectorSoftware/Makefile @@ -1,21 +1,21 @@ CFLAGS= -DC_ONLY -fPIC #FLAGS+= #-DVERBOSE -DVERYVERBOSE -DFLAGS= -DDACS_INT -DTHIS_PATH='"$(shell pwd)"' -DSLS_RECEIVER_FUNCTION_LIST #$(shell root-config --cflags --glibs) -DMYROOT1 +DFLAGS= -DDACS_INT -DTHIS_PATH='"$(shell pwd)"' -DSLS_RECEIVER_FUNCTION_LIST #$(shell root-config --cflags --glibs) -DMYROOT1 #-DMYROOT1 `root-config --cflags --glibs` #ASM=$(shell echo "/lib/modules/`uname -r`/build/include") -INCLUDES?= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis -IslsReceiverInterface -IslsReceiver -I$(ASM) +INCLUDES?= -IcommonFiles -IslsDetector -IMySocketTCP -IusersFunctions -ImultiSlsDetector -IslsDetectorUtils -IslsDetectorCommand -IslsDetectorAnalysis -IslsReceiverInterface -IslsReceiver -I../slsDetectorCalibration -I$(ASM) #EPICSFLAGS=-D EPICS -I/usr/local/epics/base/include/ -I /usr/local/epics/base/include/os/Linux/ -L /usr/local/epics/base/lib/SL5-x86/ -Wl,-R/usr/local/epics/base/lib/SL5-x86 -lca -lCom CC=g++ -SRC_CLNT= slsDetectorAnalysis/fileIO.cpp MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/angularConversionStatic.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsDetector/slsDetectorUsers.cpp slsDetectorAnalysis/postProcessingFuncs.cpp slsReceiverInterface/receiverInterface.cpp slsReceiver/slsReceiverFunctionList.cpp slsReceiver/slsReceiver_funcs.cpp slsReceiver/slsReceiverUsers.cpp slsDetectorAnalysis/singlePhotonFilter.cpp +SRC_CLNT= slsDetectorAnalysis/fileIO.cpp MySocketTCP/MySocketTCP.cpp usersFunctions/usersFunctions.cpp slsDetector/slsDetectorUtils.cpp slsDetector/slsDetectorCommand.cpp slsDetectorAnalysis/angularConversion.cpp slsDetectorAnalysis/angularConversionStatic.cpp slsDetectorAnalysis/energyConversion.cpp slsDetector/slsDetectorActions.cpp slsDetectorAnalysis/postProcessing.cpp slsDetector/slsDetector.cpp multiSlsDetector/multiSlsDetector.cpp slsDetector/slsDetectorUsers.cpp slsDetectorAnalysis/postProcessingFuncs.cpp slsReceiverInterface/receiverInterface.cpp slsReceiver/slsReceiverFunctionList.cpp slsReceiver/slsReceiver_funcs.cpp slsReceiver/slsReceiverUsers.cpp OBJS = $(SRC_CLNT:.cpp=.o) -HEADERS = $(SRC_CLNT:.cpp=.h) commonFiles/sls_detector_defs.h slsDetectorAnalysis/detectorData.h slsDetector/slsDetectorBase.h multiSlsDetector/multiSlsDetectorCommand.h slsDetectorAnalysis/enCalLogClass.h slsDetectorAnalysis/angCalLogClass.h slsDetectorAnalysis/angleConversionConstant.h usersFunctions/angleFunction.h slsReceiverInterface/receiverInterface.h slsDetector/svnInfoLib.h slsReceiver/circularFifo.h slsReceiver/slsReceiver_funcs.h slsReceiver/svnInfoReceiverTmp.h slsReceiver/receiver_defs.h slsReceiver/slsReceiverFunctionList.h slsReceiver/slsReceiverUsers.h slsReceiver/svnInfoReceiver.h +HEADERS = $(SRC_CLNT:.cpp=.h) commonFiles/sls_detector_defs.h slsDetectorAnalysis/detectorData.h slsDetector/slsDetectorBase.h multiSlsDetector/multiSlsDetectorCommand.h slsDetectorAnalysis/enCalLogClass.h slsDetectorAnalysis/angCalLogClass.h slsDetectorAnalysis/angleConversionConstant.h usersFunctions/angleFunction.h slsReceiverInterface/receiverInterface.h slsDetector/svnInfoLib.h slsReceiver/circularFifo.h slsReceiver/slsReceiver_funcs.h slsReceiver/svnInfoReceiverTmp.h slsReceiver/receiver_defs.h slsReceiver/slsReceiverFunctionList.h slsReceiver/slsReceiverUsers.h slsReceiver/svnInfoReceiver.h #../slsDetectorCalibration/singlePhotonDetector.h ../slsDetectorCalibration/moenchCommonMode.h ../slsDetectorCalibration/moench02ModuleData.h ../slsDetectorCalibration/slsReceiverData.h diff --git a/slsDetectorSoftware/slsDetectorAnalysis/singlePhotonFilter.cpp b/slsDetectorSoftware/slsDetectorAnalysis/singlePhotonFilter.cpp index 9f55756d8..8731f36dc 100644 --- a/slsDetectorSoftware/slsDetectorAnalysis/singlePhotonFilter.cpp +++ b/slsDetectorSoftware/slsDetectorAnalysis/singlePhotonFilter.cpp @@ -65,7 +65,7 @@ singlePhotonFilter::singlePhotonFilter(int nx, int ny, #ifndef MYROOT1 //photonHitList=(single_photon_hit**) (new int*[nChannelsX*nChannelsY/(nClusterX*nClusterY)*1000]); - photonHitList=new single_photon_hit*[nChannelsX*nChannelsY/(nClusterX*nClusterY)*1000]; + photonHitList=new single_photon_hit*[nChannelsX*nChannelsY/(nClusterX*nClusterY)*1000]; for (int ii=0; ii // SIGINT #include // stat @@ -70,7 +71,10 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det): currentWriterThreadIndex(-1), totalListeningFrameCount(0), running(0), - filter(NULL), + singlePhotonDet(NULL), + mdecoder(NULL), + commonModeSubtractionEnable(false), + iFrame(0), startAcquisitionCallBack(NULL), pStartAcquisition(NULL), acquisitionFinishedCallBack(NULL), @@ -104,7 +108,6 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det): setupFifoStructure(); - setupFilter(); pthread_mutex_init(&dataReadyMutex,NULL); pthread_mutex_init(&status_mutex,NULL); @@ -116,6 +119,7 @@ slsReceiverFunctionList::slsReceiverFunctionList(detectorType det): exit (-1); } + } @@ -126,7 +130,6 @@ slsReceiverFunctionList::~slsReceiverFunctionList(){ if(latestData) delete [] latestData; if(guiFileName) delete [] guiFileName; if(mem0) free(mem0); - if(filter) delete filter; if(fifo) delete fifo; if(fifoFree) delete fifoFree; } @@ -230,9 +233,7 @@ int slsReceiverFunctionList::setShortFrame(int i){ onePacketSize = bufferSize/packetsPerFrame; - //if the filter is inititalized with the wrong readout - if(filter->getPacketsPerFrame() != packetsPerFrame) - setupFilter(); + /*setupFilter();*/ return shortFrame; } @@ -263,167 +264,28 @@ int64_t slsReceiverFunctionList::setAcquisitionPeriod(int64_t index){ return acquisitionPeriod; } -/* -void slsReceiverFunctionList::setupFilter(){ - char *fformat; - char *tit; - int runmin; - int runmax; - int nbins=1500; - int hmin=-500; - int hmax=1000; - int sign=1; - double hc=0; - int xmin=0; - int xmax = ?; - int ymin=0; - int ymax = ?; - int cmsub=0; - mdecoder = NULL; - gdecoder = NULL; - if(myDetectorType == MOENCH){ - mdecoder=new moench02ModuleData(hc); - xmax = 160; - ymax = 160; - }else{ - gdecoder = new gotthardModuleData(hc,shortFrame!=-1); - if(shortFrame){ - gdecoder = new gotthardModuleData(hc,true); - xmax = 1; - ymax = 256; - }else{ - gdecoder = new gotthardModuleData(hc,false); - xmax = 1; - ymax = 1280; +void slsReceiverFunctionList::setupFilter(){ +cout<<"************in set up filter"<(mdecoder, 3, 5, sign, cmSub); + cout<<"************filter created"<registerCallBackFreeFifo(&(freeFifoBufferCallBack),this); +/*******************/ } @@ -433,18 +295,15 @@ void slsReceiverFunctionList::setupFilter(){ /******************* need to look at exit strategy **************************/ void slsReceiverFunctionList::enableDataCompression(bool enable){ dataCompression = enable; - if(filter){ - if(filter->enableCompression(enable) == FAIL) - exit(-1); - else{ - createThreads(true); - if(enable) - numWriterThreads = MAX_NUM_WRITER_THREADS; - else - numWriterThreads = 1; - createThreads(); - } - } + + createThreads(true); + if(enable) + numWriterThreads = 1;//MAX_NUM_WRITER_THREADS; + else + numWriterThreads = 1; + createThreads(); + + setupFilter(); } @@ -787,13 +646,24 @@ int slsReceiverFunctionList::setupWriter(){ if(!dataCompression) return createNewFile(); else{ +#ifdef MYROOT1 + /**********************************/ //create file name for gui purposes, and set up acquistion parameters sprintf(savefilename, "%s/%s_fxxx_%d.raw", filePath,fileName,fileIndex); + + myTree=singlePhotonDet->initEventTree(savefilename, &iFrame); + + singlePhotonDet->newDataSet(); + /**********************************/ + /* + filter->setupAcquisitionParameters(filePath,fileName,fileIndex); // if(enableFileWrite && cbAction > DO_NOTHING) // This commented option doesnt exist as we save and do ebverything for data compression //create file - return filter->initTree(); + return filter->initTree();*/ +#endif + return OK; } } @@ -1187,6 +1057,7 @@ int slsReceiverFunctionList::startWriting(){ while(1){ + int nf = 0; while(receiver_threads_running){ @@ -1194,29 +1065,30 @@ int slsReceiverFunctionList::startWriting(){ //pop fifo->pop(wbuf); numpackets = (uint16_t)(*((uint16_t*)wbuf)); -#ifdef VERYDEBUG +//#ifdef VERYDEBUG cout << "numpackets:" << hex << numpackets << endl; cout << ithread << "*** popped from fifo " << numpackets << endl; -#endif +//#endif //last dummy packet if(numpackets == 0xFFFF){ -#ifdef VERYDEBUG +//#ifdef VERYDEBUG cout << "popped last dummy frame:" << (void*)wbuf << endl; -#endif +//#endif //data compression, check if jobs done if(dataCompression){ - while(!filter->checkIfJobsDone()) - usleep(50000); + /*while(!filter->checkIfJobsDone()) + usleep(50000);*/ + ; } //free fifo while(!fifoFree->push(wbuf)); -#ifdef VERYDEBUG +//#ifdef VERYDEBUG cout << "fifo freed:" << (void*)wbuf << endl; -#endif +//#endif //update status pthread_mutex_lock(&status_mutex); status = RUN_FINISHED; @@ -1256,9 +1128,9 @@ int slsReceiverFunctionList::startWriting(){ currframenum = tempframenum; pthread_mutex_unlock(&progress_mutex); } -#ifdef VERYDEBUG +//#ifdef VERYDEBUG cout << ithread << " tempframenum:" << dec << tempframenum << " curframenum:" << currframenum << endl; -#endif +//#endif //without datacompression: write datacall back, or write data, free fifo @@ -1273,15 +1145,103 @@ int slsReceiverFunctionList::startWriting(){ pthread_mutex_unlock(&progress_mutex); } while(!fifoFree->push(wbuf)); -#ifdef VERYVERBOSE +//#ifdef VERYVERBOSE cout<<"buf freed:"<<(void*)wbuf<findNextFrame(buff,ndata,numpackets * onePacketSize )){ + + singlePhotonDet->newFrame(); + + if(commonModeSubtractionEnable){ + for(ix = xmin - 1; ix < xmax + 1; ix++){ + for(iy = ymin - 1; iy < ymax + 1; iy++){ + thisEvent = singlePhotonDet->getEventType(buff, ix, iy, 0); + } + } + } + + + for(ix = xmin - 1; ix < xmax + 1; ix++) + for(iy = ymin - 1; iy < ymax + 1; iy++){ + thisEvent=singlePhotonDet->getEventType(buff, ix, iy, commonModeSubtractionEnable); + + if (nf>1000) { + tot=0; + tl=0; + tr=0; + bl=0; + br=0; + + if (thisEvent==PHOTON_MAX ) { + for (ir=-1; ir<2; ir++) { + for (ic=-1; ic<2; ic++) { + v=singlePhotonDet->getClusterElement(ic,ir); + + tot+=v; + if (ir<1) { + if (ic<1) + bl+=v; + if (ic>-1) + br+=v; + } + + if (ir>-1) { + if (ic<1) + tl+=v; + if (ic>-1) + tr+=v; + } + + } + } + + // if (bl>br && bl>tl && bl>tr) { + //h2->Fill(bl, iy+NR*ix); + //if (bl>0) { + // hetaX->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(0,-1))/bl,iy+NR*ix); + // hetaY->Fill((filter->getClusterElement(0,0)+filter->getClusterElement(-1,0))/bl,iy+NR*ix); + iFrame=mdecoder->getFrameNumber(buff); + myTree->Fill(); + } + } + } + + cout << "=" ; + nf++; + buff += bufferSize; + packetsInFile += packetsPerFrame; + packetsCaught += packetsPerFrame; + totalPacketsCaught += packetsPerFrame; + } + cout << endl; + myTree->Write(myTree->GetName(),TObject::kOverwrite); + cout << "Read " << nf << " frames" << endl; + } + + while(!fifoFree->push(wbuf)); +//#ifdef VERYVERBOSE + cout<<"buf freed:"<<(void*)wbuf< +#endif #include @@ -206,7 +212,7 @@ public: private: /** - * Constructs the singlePhotonFilter object + * Constructs the filter for single photon data */ void setupFilter(); @@ -288,7 +294,6 @@ private: - /** detector type */ detectorType myDetectorType; @@ -470,11 +475,18 @@ private: //filter - /** single photon filter */ - singlePhotonFilter *filter; + singlePhotonDetector *singlePhotonDet; + moench02ModuleData *mdecoder; + bool commonModeSubtractionEnable; + int iFrame; + +#ifdef MYROOT1 + /** Tree where the hits are stored */ + TTree *myTree; +#endif /** callback arguments are