1 /**
2    @file
3    @ingroup processing
4 */
5 #include <math.h>
6 
7 #include <bpm/bpm_messages.h>
8 #include <bpm/bpm_process.h>
9 
get_pedestal(doublewf_t * wf,int range,double * offset,double * rms)10 int get_pedestal( doublewf_t *wf, int range, double *offset, double *rms ) {
11 
12   wfstat_t s;
13   int i;
14 
15   if ( ! wf || ! offset ) {
16     bpm_error( "Invalid pointer argument in get_pedestal(...)",
17 	       __FILE__, __LINE__ );
18     return BPM_FAILURE;
19   }
20 
21   // get basic statistics from the waveform in the beginning
22   if ( doublewf_basic_stats( wf, 0, range, &s ) == BPM_FAILURE ) {
23     bpm_error( "Error retreiving basic stats in get_pedestal()", __FILE__, __LINE__ );
24     return BPM_FAILURE;
25   }
26 
27   *offset = s.mean;
28   *rms    = s.rms;
29 
30   return BPM_SUCCESS;
31 }
32