improved library structure for analog detectors and interpolation t.b.t.

This commit is contained in:
2017-09-21 15:03:43 +02:00
parent 1c14b146a2
commit d8803ca5e4
14 changed files with 1825 additions and 306 deletions

View File

@ -1,10 +1,21 @@
#ifndef SINGLE_PHOTON_HIT_H
#define SINGLE_PHOTON_HIT_h
#define SINGLE_PHOTON_HIT_H
typedef double double32_t;
typedef float float32_t;
typedef int int32_t;
#ifndef DEF_QUAD
#define DEF_QUAD
enum quadrant {
TOP_LEFT=0,
TOP_RIGHT=1,
BOTTOM_LEFT=2,
BOTTOM_RIGHT=3,
UNDEFINED_QUADRANT=-1
};
#endif
class single_photon_hit {
@ -15,20 +26,20 @@ class single_photon_hit {
\param nx cluster size in x direction
\param ny cluster size in y direction (defaults to 1 for 1D detectors)
*/
single_photon_hit(int nx, int ny=1): dx(nx), dy(ny) {data=new double[dx*dy];};
single_photon_hit(int nx=3, int ny=3): dx(nx), dy(ny) {data=new double[dx*dy];};
~single_photon_hit(){delete [] data;}; /**< destructor, deletes the data array */
/** binary write to file of all elements of the structure, except size of the cluster
\param myFile file descriptor
*/
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 write(FILE *myFile) {fwrite((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile); fwrite((void*)data, 1, dx*dy*sizeof(double), myFile);};
/**
binary read from file of all elements of the structure, except size of the cluster. The structure is then filled with those args
\param myFile file descriptor
*/
void read(FILE *myFile) {fread((void*)this, 1, 3*sizeof(int)+2*sizeof(double), myFile); fread((void*)data, 1, dx*dy*sizeof(double), myFile);};
void read(FILE *myFile) {fread((void*)this, 1, 3*sizeof(int)+4*sizeof(double)+sizeof(quad), myFile); fread((void*)data, 1, dx*dy*sizeof(double), myFile);};
/**
assign the value to the element of the cluster matrix, with relative coordinates where the center of the cluster is (0,0)
@ -52,9 +63,12 @@ class single_photon_hit {
double rms; /**< noise of central pixel l -- at some point it can be removed*/
double ped; /**< pedestal of the central pixel -- at some point it can be removed*/
int iframe; /**< frame number */
double *data; /**< pointer to data */
const int dx; /**< size of data cluster in x */
const int dy; /**< size of data cluster in y */
const int dy; /**< size of data cluster in y */
quadrant quad; /**< quadrant where the photon is located */
double tot; /**< sum of the 3x3 cluster */
double quadTot; /**< sum of the maximum 2x2cluster */
double *data; /**< pointer to data */
};