some more changes to receiver

git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@695 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
l_maliakal_d
2013-11-14 16:12:37 +00:00
parent eb69cabb3f
commit ff856d91a4
3 changed files with 28 additions and 25 deletions

View File

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

View File

@ -12,15 +12,16 @@
singlePhotonFilter::singlePhotonFilter(int nx, int ny, singlePhotonFilter::singlePhotonFilter(int nx, int ny,
int fmask, int pmask, int foffset, int poffset, int pperf, int iValue, int fmask, int pmask, int foffset, int poffset, int pperf, int iValue,
int16_t *m, int16_t *s, CircularFifo<char>* f, int d): int16_t *m, int16_t *s, CircularFifo<char>* f, int d):
#ifdef MYROOT #ifdef MYROOT1
myTree(NULL), myTree(NULL),
myFile(NULL), myFile(NULL),
#else #else
myFile(NULL), myFile(NULL),
nHitsPerFrame(0),
nHitsPerFile(0), nHitsPerFile(0),
nTotalHits(0), nTotalHits(0),
#endif #endif
nHitsPerFrame(0),
nChannelsX(nx), nChannelsX(nx),
nChannelsY(ny), nChannelsY(ny),
nClusterX(CLUSTER_SIZE), nClusterX(CLUSTER_SIZE),
@ -53,7 +54,7 @@ singlePhotonFilter::singlePhotonFilter(int nx, int ny,
fileIndex(0), fileIndex(0),
fifo(f){ fifo(f){
#ifndef MYROOT #ifndef MYROOT1
photonHitList = new single_photon_hit[nChannelsX*nChannelsY]; photonHitList = new single_photon_hit[nChannelsX*nChannelsY];
#endif #endif
//cluster //cluster
@ -115,7 +116,7 @@ singlePhotonFilter::~singlePhotonFilter(){
int singlePhotonFilter::enableCompression(bool enable){ int singlePhotonFilter::enableCompression(bool enable){
//#ifdef VERBOSE //#ifdef VERBOSE
cout << "Compression set to " << enable; cout << "Compression set to " << enable;
#ifdef MYROOT #ifdef MYROOT1
cout << " with root" << endl; cout << " with root" << endl;
#else #else
cout << " without root" << endl; cout << " without root" << endl;
@ -164,10 +165,10 @@ void* singlePhotonFilter::createThreads(void *this_pointer){
int singlePhotonFilter::initTree(){ int singlePhotonFilter::initTree(){
#ifdef MYROOT #ifdef MYROOT1
writeToFile(); writeToFile();
closeFile(); closeFile();
sprintf(savefilename, "%s/%s_f%012d_%d.root", filePath,fileName,nTotalHits,fileIndex); sprintf(savefilename, "%s/%s_%d_.root", filePath,fileName,fileIndex);
//file //file
myFile = new TFile(savefilename, "RECREATE"); /** later return error if it exists */ myFile = new TFile(savefilename, "RECREATE"); /** later return error if it exists */
@ -179,7 +180,7 @@ int singlePhotonFilter::initTree(){
sprintf(cdata,"data[%s][%s]/D",c1,c2); sprintf(cdata,"data[%s][%s]/D",c1,c2);
sprintf(savefilename, "%s_f%012d_%d", fileName,nTotalHits,fileIndex); sprintf(savefilename, "%s_%d_", fileName,fileIndex);
myTree = new TTree(savefilename, savefilename); myTree = new TTree(savefilename, savefilename);
myTree->Branch("iframe",&myPhotonHit->iframe,"iframe/I"); myTree->Branch("iframe",&myPhotonHit->iframe,"iframe/I");
myTree->Branch("x",&myPhotonHit->x,"x/I"); myTree->Branch("x",&myPhotonHit->x,"x/I");
@ -204,12 +205,13 @@ int singlePhotonFilter::initTree(){
int singlePhotonFilter::writeToFile(){ int singlePhotonFilter::writeToFile(){
if(nHitsPerFrame){ if(nHitsPerFrame){
#ifdef MYROOT #ifdef MYROOT1
if((myTree) && (myFile)){ if((myTree) && (myFile)){
myTree->Write(); myTree->Write();
return OK; nHitsPerFrame = 0;
}else return OK;
cout << "ERROR: Could not write to " << nHitsPerFrame << " hits to file as file or tree doesnt exist" << endl; }else
cout << "ERROR: Could not write to " << nHitsPerFrame << " hits to file as file or tree doesnt exist" << endl;
#else #else
if(myFile){ if(myFile){
/*cout<<"writing "<< nHitsPerFrame << " hits to file" << endl;*/ /*cout<<"writing "<< nHitsPerFrame << " hits to file" << endl;*/
@ -219,6 +221,7 @@ int singlePhotonFilter::writeToFile(){
return OK; return OK;
}else }else
cout << "ERROR: Could not write to " << nHitsPerFrame <<" hits to file as file doesnt exist" << endl; cout << "ERROR: Could not write to " << nHitsPerFrame <<" hits to file as file doesnt exist" << endl;
#endif #endif
} }
return FAIL; return FAIL;
@ -227,7 +230,7 @@ int singlePhotonFilter::writeToFile(){
int singlePhotonFilter::closeFile(){ int singlePhotonFilter::closeFile(){
#ifdef MYROOT #ifdef MYROOT1
if(myTree){ if(myTree){
if (myFile){ if (myFile){
myFile = myTree->GetCurrentFile(); myFile = myTree->GetCurrentFile();
@ -264,7 +267,7 @@ void singlePhotonFilter::setupAcquisitionParameters(char *outfpath, char* outfna
nHitStat->Clear(); nHitStat->Clear();
nHitStat->SetN(nbackground); nHitStat->SetN(nbackground);
#ifndef MYROOT #ifndef MYROOT1
nTotalHits = 0; nTotalHits = 0;
#endif #endif
} }
@ -497,7 +500,8 @@ void singlePhotonFilter::findHits(){
// this is an event and we are in the center // this is an event and we are in the center
else if (dum == 1){ else if (dum == 1){
pthread_mutex_lock(&write_mutex); pthread_mutex_lock(&write_mutex);
#ifdef MYROOT nHitsPerFrame++;
#ifdef MYROOT1
myTree->Fill(); myTree->Fill();
#else #else
photonHitList[nHitsPerFrame].data = clusterData; photonHitList[nHitsPerFrame].data = clusterData;
@ -507,7 +511,6 @@ void singlePhotonFilter::findHits(){
photonHitList[nHitsPerFrame].ped = clusterped; photonHitList[nHitsPerFrame].ped = clusterped;
photonHitList[nHitsPerFrame].iframe = clusteriframe; photonHitList[nHitsPerFrame].iframe = clusteriframe;
nHitsPerFrame++;
nHitsPerFile++; nHitsPerFile++;
nTotalHits++; nTotalHits++;
if(nHitsPerFile >= MAX_HITS_PER_FILE-1) if(nHitsPerFile >= MAX_HITS_PER_FILE-1)

View File

@ -9,11 +9,11 @@
#ifdef __CINT #ifdef __CINT
#define MYROOT #define MYROOT1
#endif #endif
#ifdef MYROOT #ifdef MYROOT1
#include <TFile.h> #include <TFile.h>
#include <TMath.h> #include <TMath.h>
#include <TTree.h> #include <TTree.h>
@ -99,7 +99,7 @@ public:
/** virtual destructor */ /** virtual destructor */
virtual ~singlePhotonFilter(); virtual ~singlePhotonFilter();
#ifdef MYROOT #ifdef MYROOT1
/** /**
* returns tree * returns tree
*/ */
@ -204,7 +204,7 @@ public:
private: private:
#ifdef MYROOT #ifdef MYROOT1
/** Tree where the hits are stored */ /** Tree where the hits are stored */
TTree *myTree; TTree *myTree;
@ -216,9 +216,6 @@ private:
/** pointer to array of structs when only using files */ /** pointer to array of structs when only using files */
single_photon_hit* photonHitList; single_photon_hit* photonHitList;
/** Number of Hits per frame*/
int nHitsPerFrame;
/** Number of Hits per file */ /** Number of Hits per file */
int nHitsPerFile; int nHitsPerFile;
@ -226,6 +223,9 @@ private:
int nTotalHits; int nTotalHits;
#endif #endif
/** Number of Hits per frame*/
int nHitsPerFrame;
/** Maximum Number of hits written to file */ /** Maximum Number of hits written to file */
const static int MAX_HITS_PER_FILE = 200000; const static int MAX_HITS_PER_FILE = 200000;