#ifndef _daq_h_
#define _daq_h_
#define MAXCH 64
#define MAXPMT 16
#define NSTEPS 4790 // en krog je 4790 korakov
typedef struct {
float x[3];
} HVector3;
struct Module {
double r;
double phi;
};
struct Channel {
int ix;
int iy;
};
struct Config {
int nofcrystalsx;
int nofcrystalsy;
double crystalpitchx;
double crystalpitchy;
char *modules;
char *channels;
char *sumpedestals;
char *pedestals;
char *photopeak;
char *channelcalibration;
int adcthreshold;
double peakscaling;
struct Module module[16];
struct Channel channel[16];
float apedestals[MAXCH];
float apeak[MAXCH];
float rotation;
int write;
int coincidences; // stevilo koincidenc
} conf;
#define NUM_CHANNELS 1
#define PEDESTAL 255
#define SCAN_TYPE 1
#define RUNREC_ID 1
#define ENDREC_ID 2
#define POSREC_ID 3
#define EVTREC_ID 4
typedef struct {
unsigned int id,length;
unsigned int fver,time;
unsigned int num_events,num_channels,pedestal,xy;
int nx,x0,dx,ny,y0,dy;
} RUNREC;
typedef struct {
unsigned int id,length;
unsigned int time,dum;
} ENDREC;
typedef struct {
unsigned int id,length;
unsigned int time;
int num_iter_x,mikro_pos_x,set_pos_x;
int num_iter_y,mikro_pos_y,set_pos_y;
} POSREC;
int debug;
int fPedestal;
int fThresholdEnable;
int fStop;
int fMode;
int clear();
int end();
int event(unsigned int *, int,int *, int );
int init();
int vmconnect();
int vmdisconnect();
int vmacquire (int neve,FILE *fp, char *fpedname);
int HistogramsInit();
int HistogramsFill();
int HistogramsWrite(const char *fname);
int GetGlobalPosition(int ipmt, double angle, float cx, float cy, float *gposition);
int analyse(int nb, uint32_t *data);
//-----------------
int m_Adc[MAXCH];
int m_AdcCut[MAXCH];
int m_Adc_vs_Nhits[MAXCH];
int m_Adc_vs_Sum[MAXCH];
int m_Adc_vs_Sum_Uncorected[MAXCH];
int m_Nhits;
int m_AdcSum[MAXPMT];
int m_CenterOfGravity[MAXPMT];
int m_ReconstructedPosition[MAXPMT];
int m_CenterOfGravityforChAboveThreshold[MAXPMT];
int m_GlobalPosition;
int m_AdcSumCluster[MAXPMT];
int m_MaxAdc[MAXPMT];
int m_SumAdc[MAXPMT];
//-----------------
#endif