bpmprocess/process_dipole.c

Go to the documentation of this file.
00001 
00005 #include <stdio.h>
00006 #include <bpm/bpm_messages.h>
00007 #include <bpm/bpm_process.h>
00008 
00022 int process_dipole( bpmconf_t *bpm, bpmcalib_t *cal, bpmsignal_t *sig, bpmproc_t *proc,
00023                     bpmproc_t *trig, bpmproc_t *ref, unsigned int mode ) {
00024 
00025   double I,Q;
00026   char msg[128];
00027 
00028   if ( ! bpm || ! sig || ! proc || ! trig || ! ref ) {
00029     bpm_error( "Invalid pointer arguments in process_dipole(...)",
00030                __FILE__, __LINE__ );
00031     return BPM_FAILURE;
00032   }
00033     
00034   if ( process_waveform( dipole, bpm, cal, sig, proc, trig, mode ) == BPM_FAILURE ) {
00035     sprintf( msg, "Unable to process waveform for BPM %s in process_dipole(...)", bpm->name );
00036     bpm_error( msg, __FILE__, __LINE__ );
00037     return BPM_FAILURE;
00038   }
00039 
00040   // the structures should be filled now with amplitude and phases, let's compute
00041   // I,Q and the postion and tilts... for fit and ddc
00042   if ( proc->ddc_success && ref->ddc_success ) {
00043 
00044     I = Q = 0.;
00045 
00046     // process info for DDC
00047     if ( get_IQ( proc->ddc_amp, proc->ddc_phase, ref->ddc_amp, ref->ddc_phase, 
00048                  &Q, &I ) == BPM_FAILURE ) {
00049       sprintf( msg, "Could not calculated I and Q for BPM %s in process_dipole(...)", bpm->name );
00050       bpm_error( msg, __FILE__, __LINE__ );
00051       return BPM_FAILURE;
00052     } 
00053 
00054     proc->ddc_I = I;
00055     proc->ddc_Q = Q;
00056 
00057     if ( get_pos( Q, I, cal->IQphase, cal->posscale, &(proc->ddc_pos) ) == BPM_FAILURE ) {
00058       sprintf( msg, "Could not get ddc position for BPM %s in process_dipole(...)", bpm->name );
00059       bpm_error( msg, __FILE__, __LINE__ );
00060       return BPM_FAILURE;
00061     }
00062 
00063     if ( get_slope( Q, I, cal->IQphase, cal->slopescale, &(proc->ddc_slope) ) == BPM_FAILURE ) {
00064       sprintf( msg, "Could not get ddc slope for BPM %s in process_dipole(...)", bpm->name );
00065       bpm_error( msg, __FILE__, __LINE__ );
00066       return BPM_FAILURE;
00067     }
00068 
00069   } /* if ( proc->ddc_success ) */
00070   
00071   // repeat the excersice for the fit
00072   if( proc->fit_success && ref->fit_success ) {
00073 
00074     I = Q = 0.;
00075 
00076     // process info for fit
00077     if ( get_IQ( proc->fit_amp, proc->fit_phase, ref->fit_amp, ref->fit_phase, 
00078                  &Q, &I ) == BPM_FAILURE ) {
00079       sprintf( msg, "Could not calculated I and Q for BPM %s in process_dipole(...)", bpm->name );
00080       bpm_error( msg, __FILE__, __LINE__ );
00081       return BPM_FAILURE;
00082     } 
00083 
00084     proc->fit_I = I;
00085     proc->fit_Q = Q;
00086 
00087     if ( get_pos( Q, I, cal->IQphase, cal->posscale, &(proc->fit_pos) ) == BPM_FAILURE ) {
00088       sprintf( msg, "Could not get fit position for BPM %s in process_dipole(...)", bpm->name );
00089       bpm_error( msg, __FILE__, __LINE__ );
00090       return BPM_FAILURE;
00091     }
00092     
00093     if ( get_slope( Q, I, cal->IQphase, cal->slopescale, &(proc->fit_slope) ) == BPM_FAILURE ) {
00094       sprintf( msg, "Could not get fitted slope for BPM %s in process_dipole(...)", bpm->name );
00095       bpm_error( msg, __FILE__, __LINE__ );
00096       return BPM_FAILURE;
00097     }
00098     
00099   } /* if( proc->fit_success ) */
00100 
00101 
00102   return BPM_SUCCESS;
00103 }
00104 
00105 // end of file

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