bpmsimulation/generate_diode.c

Go to the documentation of this file.
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   // Compute the monopole response of the BPM
00031   double amp, phase;
00032   get_monopole_response( beam->charge, bpm->cav_chargesens, beam->arrival_time, bpm->cav_freq,
00033                          &amp, &phase );
00034   int i;
00035   // Generate the waveoform
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   // Rectify the waveform
00040   rf_rectify( RF );
00041 
00042   // Filter the signal
00043   rf_filter( RF, bpm->rf_filtertype, bpm->rf_nfiltpars, bpm->rf_filterpars );
00044   
00045   // Amplify
00046   //rf_amplify( RF, bpm->rf_gain );
00047 
00048   // Add some noise - currently assume ADC goes from -1V -> +1V
00049   double conv = (double) pow( 2, bpm->digi_nbits ) / 2.;
00050   double noise = bpm->digi_ampnoise / conv;
00051   //add_amplnoise( noise, RF );
00052 
00053   // digitise the waveform - currently assume ADC goes from -1V -> +1V
00054   int *wf = alloc_simple_wave_int( bpm->digi_nsamples );
00055   //digitise( RF, bpm->digi_nbits, bpm->digi_voltageoffset, bpm->digi_freq, conv, 
00056 //          bpm->digi_nsamples, wf);
00057 
00058   // Finally, store the waveform in the signal structure
00059   sig->wf = wf;
00060   sig->ns = bpm->digi_nsamples;
00061 
00062   // Clean up
00063   free_complex_wave_double( RF, rf_nsamples );
00064 
00065   return BPM_SUCCESS;
00066 }
00067 
00068 // end of file

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