mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-05-06 04:40:02 +02:00
single photon writer updated
git-svn-id: file:///afs/psi.ch/project/sls_det_software/svn/slsDetectorSoftware@706 951219d9-93cf-4727-9268-0efd64621fa3
This commit is contained in:
parent
04239872b6
commit
d2958eb0a4
@ -60,12 +60,15 @@ singlePhotonFilter::singlePhotonFilter(int nx, int ny,
|
|||||||
currentframenum(cframenum),
|
currentframenum(cframenum),
|
||||||
freeFifoCallBack(NULL),
|
freeFifoCallBack(NULL),
|
||||||
pFreeFifo(NULL){
|
pFreeFifo(NULL){
|
||||||
#ifndef MYROOT1
|
|
||||||
photonHitList = new single_photon_hit[nChannelsX*nChannelsY];
|
|
||||||
#endif
|
|
||||||
//cluster
|
//cluster
|
||||||
if (nChannelsX)
|
if (nChannelsX)
|
||||||
nClusterX = 1;
|
nClusterX = 1;
|
||||||
|
|
||||||
|
#ifndef MYROOT1
|
||||||
|
//photonHitList=(single_photon_hit**) (new int*[nChannelsX*nChannelsY/(nClusterX*nClusterY)*1000]);
|
||||||
|
photonHitList=new single_photon_hit*[nChannelsX*nChannelsY/(nClusterX*nClusterY)*1000];
|
||||||
|
#endif
|
||||||
|
|
||||||
sqrtCluster = sqrt(nClusterX*nClusterY);
|
sqrtCluster = sqrt(nClusterX*nClusterY);
|
||||||
deltaX = nClusterX/2;// 0 or 1
|
deltaX = nClusterX/2;// 0 or 1
|
||||||
clusterCenterPixel = (deltaX * nClusterY) + 1;
|
clusterCenterPixel = (deltaX * nClusterY) + 1;
|
||||||
@ -74,8 +77,8 @@ singlePhotonFilter::singlePhotonFilter(int nx, int ny,
|
|||||||
stat = new movingStat[nChannelsX*nChannelsY];
|
stat = new movingStat[nChannelsX*nChannelsY];
|
||||||
nHitStat = new movingStat();
|
nHitStat = new movingStat();
|
||||||
|
|
||||||
myPhotonHit = new single_photon_hit;
|
myPhotonHit = new single_photon_hit(nClusterX,nClusterY);
|
||||||
myPhotonHit->data = new double[nClusterX*nClusterY];
|
// myPhotonHit->data = new double[nClusterX*nClusterY];
|
||||||
myPhotonHit->x = 0;
|
myPhotonHit->x = 0;
|
||||||
myPhotonHit->y = 0;
|
myPhotonHit->y = 0;
|
||||||
myPhotonHit->rms = 0;
|
myPhotonHit->rms = 0;
|
||||||
@ -221,8 +224,16 @@ int singlePhotonFilter::writeToFile(){
|
|||||||
cout << "ERROR: Could not write to " << nHitsPerFrame << " hits to file as file or tree doesnt exist" << endl;
|
cout << "ERROR: Could not write to " << nHitsPerFrame << " hits to file as file or tree doesnt exist" << endl;
|
||||||
#else
|
#else
|
||||||
if(myFile){
|
if(myFile){
|
||||||
|
int ii;
|
||||||
/*cout<<"writing "<< nHitsPerFrame << " hits to file" << endl;*/
|
/*cout<<"writing "<< nHitsPerFrame << " hits to file" << endl;*/
|
||||||
fwrite((void*)(photonHitList), 1, sizeof(single_photon_hit)*nHitsPerFrame, myFile);
|
for (ii=0; ii<nHitsPerFrame; ii++) {
|
||||||
|
photonHitList[ii]->write(myFile);
|
||||||
|
delete photonHitList[ii];
|
||||||
|
}
|
||||||
|
delete photonHitList[ii];
|
||||||
|
|
||||||
|
|
||||||
|
// fwrite((void*)(photonHitList), 1, sizeof(single_photon_hit)*nHitsPerFrame, myFile);
|
||||||
/*framesInFile += nHitsPerFrame;*/
|
/*framesInFile += nHitsPerFrame;*/
|
||||||
nHitsPerFrame = 0;
|
nHitsPerFrame = 0;
|
||||||
//cout<<"Exiting writeToFile"<<endl;
|
//cout<<"Exiting writeToFile"<<endl;
|
||||||
@ -410,7 +421,9 @@ void singlePhotonFilter::findHits(){
|
|||||||
int currentIndex;
|
int currentIndex;
|
||||||
int pixelIndex;
|
int pixelIndex;
|
||||||
int clusterIndex;
|
int clusterIndex;
|
||||||
double* clusterData = new double[nClusterX*nClusterY];
|
// single_photon_hit *hit;
|
||||||
|
|
||||||
|
double* clusterData;// = hit.data;
|
||||||
double sigmarms;
|
double sigmarms;
|
||||||
double clusterrms;
|
double clusterrms;
|
||||||
double clusterped;
|
double clusterped;
|
||||||
@ -478,6 +491,10 @@ void singlePhotonFilter::findHits(){
|
|||||||
#endif
|
#endif
|
||||||
clusteriframe -= f0;
|
clusteriframe -= f0;
|
||||||
myData = (int16_t*)isData;
|
myData = (int16_t*)isData;
|
||||||
|
if (nHitsPerFrame==0)
|
||||||
|
photonHitList[nHitsPerFrame]=new single_photon_hit(nClusterX, nClusterY);
|
||||||
|
|
||||||
|
clusterData=photonHitList[nHitsPerFrame]->data;
|
||||||
|
|
||||||
//for each pixel
|
//for each pixel
|
||||||
for (ir=0; ir<nChannelsX; ++ir){
|
for (ir=0; ir<nChannelsX; ++ir){
|
||||||
@ -546,17 +563,19 @@ 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);
|
||||||
nHitsPerFrame++;
|
|
||||||
#ifdef MYROOT1
|
#ifdef MYROOT1
|
||||||
myTree->Fill();
|
myTree->Fill();
|
||||||
#else
|
#else
|
||||||
photonHitList[nHitsPerFrame].data = clusterData;
|
// photonHitList[nHitsPerFrame].data = clusterData;
|
||||||
photonHitList[nHitsPerFrame].x = ic;
|
photonHitList[nHitsPerFrame]->x = ic;
|
||||||
photonHitList[nHitsPerFrame].y = ir;
|
photonHitList[nHitsPerFrame]->y = ir;
|
||||||
photonHitList[nHitsPerFrame].rms = clusterrms;
|
photonHitList[nHitsPerFrame]->rms = clusterrms;
|
||||||
photonHitList[nHitsPerFrame].ped = clusterped;
|
photonHitList[nHitsPerFrame]->ped = clusterped;
|
||||||
photonHitList[nHitsPerFrame].iframe = clusteriframe;
|
photonHitList[nHitsPerFrame]->iframe = clusteriframe;
|
||||||
|
//hit.write(myFile);
|
||||||
|
|
||||||
|
nHitsPerFrame++;
|
||||||
|
photonHitList[nHitsPerFrame]=new single_photon_hit(nClusterX,nClusterY);
|
||||||
nHitsPerFile++;
|
nHitsPerFile++;
|
||||||
nTotalHits++;
|
nTotalHits++;
|
||||||
if(nHitsPerFile >= MAX_HITS_PER_FILE-1)
|
if(nHitsPerFile >= MAX_HITS_PER_FILE-1)
|
||||||
@ -575,9 +594,9 @@ void singlePhotonFilter::findHits(){
|
|||||||
//calulate the average hits per frame
|
//calulate the average hits per frame
|
||||||
nHitStat->Calc((double)nHitsPerFrame);
|
nHitStat->Calc((double)nHitsPerFrame);
|
||||||
//write for each frame, not packet
|
//write for each frame, not packet
|
||||||
|
|
||||||
pthread_mutex_lock(&write_mutex);
|
pthread_mutex_lock(&write_mutex);
|
||||||
writeToFile();
|
writeToFile();
|
||||||
//fifo->push(isData);
|
|
||||||
pthread_mutex_unlock(&write_mutex);
|
pthread_mutex_unlock(&write_mutex);
|
||||||
|
|
||||||
//increment offset
|
//increment offset
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "circularFifo.h"
|
#include "circularFifo.h"
|
||||||
#include "runningStat.h"
|
#include "runningStat.h"
|
||||||
#include "movingStat.h"
|
#include "movingStat.h"
|
||||||
|
#include "single_photon_hit.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
||||||
@ -48,17 +49,6 @@ enum {
|
|||||||
OK, /**< function succeeded */
|
OK, /**< function succeeded */
|
||||||
FAIL /**< function failed */
|
FAIL /**< function failed */
|
||||||
};
|
};
|
||||||
/**
|
|
||||||
@short structure for a single photon hit
|
|
||||||
*/
|
|
||||||
typedef struct{
|
|
||||||
double* data; /**< data size */
|
|
||||||
int x; /**< x-coordinate of the center of hit */
|
|
||||||
int y; /**< x-coordinate of the center of hit */
|
|
||||||
double rms; /**< noise of central pixel */
|
|
||||||
double ped; /**< pedestal of the central pixel */
|
|
||||||
int iframe; /**< frame number */
|
|
||||||
}single_photon_hit;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -241,7 +231,8 @@ private:
|
|||||||
FILE *myFile;
|
FILE *myFile;
|
||||||
|
|
||||||
/** 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;
|
||||||
|
single_photon_hit ** photonHitList;
|
||||||
|
|
||||||
/** Number of Hits per file */
|
/** Number of Hits per file */
|
||||||
int nHitsPerFile;
|
int nHitsPerFile;
|
||||||
|
43
slsDetectorSoftware/slsDetectorAnalysis/single_photon_hit.h
Normal file
43
slsDetectorSoftware/slsDetectorAnalysis/single_photon_hit.h
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#ifndef SINGLE_PHOTON_HIT_H
|
||||||
|
#define SINGLE_PHOTON_HIT_h
|
||||||
|
|
||||||
|
typedef double double32_t;
|
||||||
|
typedef float float32_t;
|
||||||
|
typedef int int32_t;
|
||||||
|
|
||||||
|
/* /\** */
|
||||||
|
/* @short structure for a single photon hit */
|
||||||
|
/* *\/ */
|
||||||
|
/* typedef struct{ */
|
||||||
|
/* double* data; /\**< data size *\/ */
|
||||||
|
/* int x; /\**< x-coordinate of the center of hit *\/ */
|
||||||
|
/* int y; /\**< x-coordinate of the center of hit *\/ */
|
||||||
|
/* double rms; /\**< noise of central pixel *\/ */
|
||||||
|
/* double ped; /\**< pedestal of the central pixel *\/ */
|
||||||
|
/* int iframe; /\**< frame number *\/ */
|
||||||
|
/* }single_photon_hit; */
|
||||||
|
|
||||||
|
|
||||||
|
class single_photon_hit {
|
||||||
|
|
||||||
|
public:
|
||||||
|
single_photon_hit(int nx, int ny): dx(nx), dy(ny) {data=new double[dx*dy];};
|
||||||
|
~single_photon_hit(){delete [] data;};
|
||||||
|
void write(FILE *myFile) {fwrite((void*)this, 1, 3*sizeof(int)+2*sizeof(double), myFile); fwrite((void*)data, 1, dx*dy*sizeof(double), myFile);};
|
||||||
|
void read(FILE *myFile) {fread((void*)this, 1, 3*sizeof(int)+2*sizeof(double), myFile); fread((void*)data, 1, dx*dy*sizeof(double), myFile);};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int x; /**< x-coordinate of the center of hit */
|
||||||
|
int y; /**< x-coordinate of the center of hit */
|
||||||
|
double rms; /**< noise of central pixel */
|
||||||
|
double ped; /**< pedestal of the central pixel */
|
||||||
|
int iframe; /**< frame number */
|
||||||
|
double *data; /**< data size */
|
||||||
|
const int dx;
|
||||||
|
const int dy;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user