bpmprocess/bpm_process.h

Go to the documentation of this file.
00001 
00012 #ifndef BPMPROCESS_H__
00013 #define BPMPROCESS_H__
00014 
00015 /* -----------------------------------------------------------------------------
00016 // includes
00017 // -------------------------------------------------------------------------- */
00018 #include <float.h>
00019 #include <math.h>
00020 #include <bpm/bpm_defs.h>
00021 #include <bpm/bpm_interface.h>
00022 
00023 
00024 /* -----------------------------------------------------------------------------
00025 // macro definitions
00026 // -------------------------------------------------------------------------- */
00027 #define  PROC_DEFAULT         0           
00028 #define  PROC_DO_FFT          0x00000001  
00029 #define  PROC_DO_FIT          0x00000002  
00030 #define  PROC_DO_DDC          0x00000004  
00031 #define  PROC_DDC_CALIBFREQ   0x00000008  
00032 #define  PROC_DDC_CALIBTDECAY 0x00000010  
00033 #define  PROC_DDC_FITFREQ     0x00000020  
00034 #define  PROC_DDC_FITTDECAY   0x00000040  
00035 #define  PROC_DDC_FFTFREQ     0x00000080  
00036 #define  PROC_DDC_FFTTDECAY   0x00000100  
00037 #define  PROC_DDC_STOREFULL   0x00000200  
00038 #define  PROC_FIT_DDC         0x00000400  
00039 
00040 /* -----------------------------------------------------------------------------
00041 // typedefs, enums and other declarations
00042 // -------------------------------------------------------------------------- */
00043 #ifdef __cplusplus
00044 extern "C" {
00045 #endif
00046 
00047 
00048 /* -----------------------------------------------------------------------------
00049 // function prototypes and declarations
00050 // -------------------------------------------------------------------------- */
00051 
00052   EXTERN int process_diode( bpmconf_t*, bpmsignal_t*, bpmproc_t* );
00053   // determines the t0 and stores in bpmproc_t
00054 
00055   EXTERN int process_waveform( enum bpmtype_t type, 
00056                                bpmconf_t *bpm, bpmcalib_t *cal, bpmsignal_t *sig, 
00057                                bpmproc_t *proc, bpmproc_t *trig, unsigned int mode );
00058   // general amplitude and phase determination according to the mode bit pattern
00059   // both process_monopole and process_dipole use this routine as core processing
00060 
00061   EXTERN int process_monopole( bpmconf_t *bpm, bpmcalib_t *cal, bpmsignal_t *sig, bpmproc_t *proc,
00062                                bpmproc_t *trig, unsigned int mode );
00063   // nothing more than a wrapper around process_waveform since there isn't much more to be
00064   // done
00065 
00066   EXTERN int process_dipole( bpmconf_t *bpm, bpmcalib_t *cal, bpmsignal_t *sig, bpmproc_t *proc, 
00067                              bpmproc_t *trig, bpmproc_t *ref, unsigned int mode );
00068   // processes the waveform and goes on to calcualte I,Q and postions and tilt
00069 
00070 
00071   // fitting routines
00072   EXTERN int fit_waveform( int *wf, int ns, double t0, double fs,
00073                            double i_freq, double i_tdecay, double i_amp, double i_phase,
00074                            double *freq, double *tdecay, double *amp, double *phase );
00075 
00076 
00077   EXTERN int fit_diodepulse( int *wf, int ns, double fs, double *t0 );
00078   // made obsolete by get_t0 ? ... yess ! implemented this routine as a wrapper around
00079   // get_t0 for name - consistency
00080 
00081 
00082   EXTERN int fit_ddc( double *ddc, int ns, double *tdecay );
00083   // fits the ddc to get the decay time, gets inital pars from ddc wf itself
00084 
00085 
00086   EXTERN int fit_fft_prepare( double **fft, int ns, double fs, int *n1, int *n2,
00087                               double *amp, double *freq, double *fwhm );
00088   // gets some initial parameters for the FFT fit...
00089 
00090 
00091   EXTERN int fit_fft( double **fft, int ns, double fs, double *freq, double *tdecay,
00092                       double *A, double *C );
00093   // fit the fft to get the frequency and the decay time
00094 
00095 
00096 
00097   // FFT routines
00098   EXTERN int fft_waveform( int *wf, int ns, double **fft );
00099   EXTERN int fft_waveform_double( double *wf, int ns, double **fft);
00100 
00101   // DDC routines
00102   EXTERN int handle_saturation( int *wf, int ns, int imax, int nbits, int threshold, 
00103                                 int *iunsat );
00104 
00105   EXTERN int downmix_waveform( double *wf, int ns, double fs, double freq, double t0, 
00106                                double **out );
00107 
00108   EXTERN int ddc_gaussfilter_step( double **ddc, int ns, double fs, int istart, int istop, 
00109                                    double tfilter, double filtBW, double *out );
00110 
00111   EXTERN int ddc_gaussfilter( double **ddc, int ns, double fs, double filtBW, double epsFilt,
00112                               double **out ); 
00113 
00114   EXTERN int ddc_waveform( int *wf, int ns,int nbits, double fs, double t0,
00115                            double freq, double tdecay, double filtBW, double epsFilt,
00116                            double **out );
00117   
00118   EXTERN int ddc_sample_waveform( int *wf, int ns, int nbits, double fs, 
00119                                   double t0, double t0Offset, 
00120                                   double freq, double tdecay, double filtBW, double epsFilt,
00121                                   double *amp, double *phase );
00122 
00123 
00124   // Here start the low - level routines...
00125   EXTERN int get_pedestal( int *wf, int ns, int range, double *offset, double *rms );
00126 
00127   EXTERN int basic_stats( int *wf, int ns, int range, int nbits, double *offset, double *rms , 
00128                           int *max, int *min, int *unsat_sample);
00129 
00130   EXTERN int int_to_double_waveform( double *wf_double, int *wf_int, int ns);
00131   EXTERN int copy_waveform( double *wf_src, double *wf_dst, int ns);
00132   
00133   EXTERN int add_scalar_waveform( double *wf, int ns, double add);
00134   EXTERN int mult_scalar_waveform( double *wf, int ns, double mult);
00135   EXTERN int mult_waveform( double *wf1, double *wf2, int ns);
00136   
00137   EXTERN int get_t0( int *wf, int ns, double fs, double *t0 );
00138 
00139   // some position, IQ routines...
00140   EXTERN int get_IQ( double amp, double phase, double refamp, double refphase,
00141                      double *Q, double *I );
00142   // gets the I and Q from the amp, phase and ref 
00143 
00144   EXTERN int get_pos( double Q, double I, double IQphase, double posscale,
00145                       double *pos );
00146   // returns the position given I,Q, IQphase and scale
00147   
00148   EXTERN int get_slope( double Q, double I, double IQphase, double slopescale,
00149                         double *slope );
00150   // returns the slope given I,Q, IQphase and scale
00151 
00152   // easy conversion between time/frequency and sample number
00153   EXTERN int time_to_sample( double fs, int ns, double t, int *iS );
00154   EXTERN int sample_to_time( double fs, int ns, int iS, double *t );
00155   EXTERN int freq_to_sample( double fs, int ns, double f, int *iS );
00156   EXTERN int sample_to_freq( double fs, int ns, int iS, double *f );
00157 
00158 
00159 #ifdef __cplusplus
00160 }
00161 #endif
00162 
00163 #endif /* #ifndef BPMINTERFACE_H__ */
00164 
00165 /* ================================ end of file ============================= */

Generated on Thu Jan 10 10:18:04 2008 for libbpm by  doxygen 1.5.1