00001 00006 #include <bpm/bpm_simulation.h> 00007 #include <math.h> 00008 00009 complex_t get_mode_amplitude( bpmconf_t *bpm, bpmmode_t *mode, beamconf_t *beam ) { 00010 00011 double k, L, sigma; 00012 complex_t z; 00013 int idx = ( mode->polarisation == horiz ? 0 : 1); 00014 00015 if ( mode->order == 0 ) { 00016 // monopole mode, sensititvity in Volt/C 00017 z.re = mode->sensitivity * beam->charge; 00018 z.im = 0.; 00019 00020 } else if ( mode->order == 1 ) { 00021 // dipole mode, sensitivity in Volt/m/C 00022 // need to include the bunch length effects properly!!! 00023 z.re = mode->sensitivity * beam->bpmhit[idx] * beam->charge; 00024 00025 // calulcate : 00026 // beam->bunchlength, bpm->cav_length, beam->bpmslope[idx] + beam->bpmtilt[idx] 00027 k = 2*PI / cLight * mode->frequency; 00028 L = bpm->cav_length; 00029 sigma = beam->bunchlength; 00030 00031 z.im = mode->sensitivity * beam->charge * 00032 // the slope term 00033 ( 1/k * ( 1 - (k*L/2) / sin (k*L/2) ) * beam->bpmslope[idx] 00034 // the tilt term 00035 + 2 * sigma * sin (k*sigma/2) ); 00036 00037 } else if (mode->order == 2 ) { 00038 // quadrupole mode 00039 z.re = 0.; 00040 z.im = 0.; 00041 bpm_warning( "Quadrupole modes are not implemented yet in libbpm...", __FILE__, __LINE__ ); 00042 00043 } else { 00044 bpm_warning( "HOM (O(>2) modes are not implemented yet in libbpm...", __FILE__, __LINE__ ); 00045 00046 } 00047 00048 return z; 00049 }