00001
00005 #include <bpm/bpm_messages.h>
00006 #include <bpm/bpm_simulation.h>
00007 #include <bpm/bpm_rf.h>
00008 #include <bpm/bpm_alloc.h>
00009
00010
00021 int generate_diode( bpmconf_t *bpm, beamconf_t *beam, bpmsignal_t *sig ) {
00022
00023
00024 if ( ! bpm || ! beam || ! sig ) {
00025 bpm_error( "Invalid pointer arguments in generate_diode(...)",
00026 __FILE__, __LINE__ );
00027 return BPM_FAILURE;
00028 }
00029
00030
00031 double amp, phase;
00032 get_monopole_response( beam->charge, bpm->cav_chargesens, beam->arrival_time, bpm->cav_freq,
00033 &, &phase );
00034 int i;
00035
00036 double **RF = alloc_complex_wave_double( rf_nsamples );
00037 add_wave( amp, phase, bpm->cav_freq, beam->arrival_time + bpm->digi_trigtimeoffset, bpm->cav_decaytime, RF );
00038
00039
00040 rf_rectify( RF );
00041
00042
00043 rf_filter( RF, bpm->rf_filtertype, bpm->rf_nfiltpars, bpm->rf_filterpars );
00044
00045
00046
00047
00048
00049 double conv = (double) pow( 2, bpm->digi_nbits ) / 2.;
00050 double noise = bpm->digi_ampnoise / conv;
00051
00052
00053
00054 int *wf = alloc_simple_wave_int( bpm->digi_nsamples );
00055
00056
00057
00058
00059 sig->wf = wf;
00060 sig->ns = bpm->digi_nsamples;
00061
00062
00063 free_complex_wave_double( RF, rf_nsamples );
00064
00065 return BPM_SUCCESS;
00066 }
00067
00068