GCpp general purpose C++ library  version 1.0
GExtremaFinder.hh
Go to the documentation of this file.
1 //======================================================================
2 /*! \file GExtremaFinder.hh
3  *
4  * Include file for the class GExtremaFinder.
5  */
6 //======================================================================
7 
8 #ifndef G_EXTREMA_FINDER_HH
9 #define G_EXTREMA_FINDER_HH
10 
11 //======================================================================
12 
13 #include "GRealSampleFFT.hh"
14 #include "GLogMessage.hh"
15 
16 //----------------------------------------------------------------------
17 /*! \class GExtremaFinder
18  *
19  * This class performs a maxima / minima search on a sample
20  * of real data.
21  *
22  * \par Extrema analysis
23  *
24  *
25  * \par Maxima analysis
26  *
27  * The maxima analysis is performed from the results of the extrema
28  * analysis (maxima and minima).
29  *
30  * The analysis selects the maxima and sets the corresponding information
31  * in dedicated arrays.
32  * The information is the following:
33  * - the number of maxima;
34  * - the raw data from maxima analysis:
35  * - <B>Values</B>: the signal amplitude at maxima positions;
36  * - <B>Positions</B>: the position of the maxima along signal axis;
37  * - <B>Bins</B>: the sample bins that contain a maximum;
38  * - a more detailed analysis of the maxima, analysing the signal over
39  * the full range from the preceeding to the following minimum:
40  * - <B>Centers</B>: total signal mean position for the maxima;
41  * - <B>Amplitudes</B>: integrated signal for the maxima;
42  * - <B>Averages</B>: average signal for the maxima;
43  * - the information about the maxima analysis zone: position and signal
44  * of the lower and upper limits of the zone asociated to the maxima.
45  *
46  * For the maxima analysis, it is also possible to set a low signal
47  * threshold below which the data are not considered:
48  * - a maximum below this threshold is ignored;
49  * - the local maxima zone for integration / average is limited to a
50  * region where the signal does not drop below this threshold.
51  *
52  */
54 {
55  //------------------------------------------------------------
56  /*! \object_doc */
58  //------------------------------------------------------------
59 
60  protected:
61  GRealSampleFFT * sample_ptr; ///< Pointer to the data sample to analyse
62  bool sample_local; ///< Whether the sample is allocated by the class
63  GRealSampleFFT * deriv_ptr; ///< Derivative of the data sample
64 
65  bool analyzed; ///< Whether the extrema have been analyzed
66 
67  u_int alloc_size; ///< Allocated size for arrays
68 
69  u_int extr_num; ///< Number of extrema
70  double * extr_val; ///< Array of extrema values
71  double * extr_pos; ///< Array of extrema positions
72  u_int * extr_bin; ///< Array of bins with extrema
73  bool * extr_max; ///< Array indicating if extrema are maxima (or minima)
74 
75  bool max_thr_use; ///< Use of a low signal threshold for maxima analysis
76  double max_thr_low; ///< Low signal threshold for maxima analysis
77  u_int max_num; ///< Number of maxima
78  double * max_val; ///< Array of maxima values
79  double * max_pos; ///< Array of maxima positions
80  u_int * max_bin; ///< Array of bins with maxima
81  double * max_ctr; ///< Array of maxima zone average positions
82  double * max_amp; ///< Array of maxima zone sum amplitude
83  double * max_avg; ///< Array of maxima zone average amplitude
84 
85  double * max_prev_min_val; ///< Array of values of the minimum before maxima
86  double * max_next_min_val; ///< Array of values of the minimum after maxima
87  double * max_prev_min_pos; ///< Array of positions of the minimum before maxima
88  double * max_next_min_pos; ///< Array of positions of the minimum after maxima
89  u_int * max_prev_min_bin; ///< Array of positions of the minimum before maxima
90  u_int * max_next_min_bin; ///< Array of positions of the minimum after maxima
91 
92  public:
93  /** @name Constructors, destructors, affectation */
94  //@{
95  // Constructors
96  GExtremaFinder ( u_int n = 0, double * data = NULL, double bin = 1. );
97  GExtremaFinder ( GRealSampleFFT * sptr );
99  GExtremaFinder ( const GExtremaFinder & original );
100 
101  // Affectation
102  GExtremaFinder & operator = ( const GExtremaFinder & original );
103 
104  // Destructors
105  virtual ~GExtremaFinder ( );
106  //@}
107 
108  //----------------------------------------------------------
109  /** @name Initialisation and setting functions */
110  //@{
111  protected:
112  virtual void CopyData ( const GExtremaFinder & original );
113 
114  public:
115  virtual int InitData ( u_int n, double * data, double bin = 1. );
116  virtual int InitData ( GRealSampleFFT * sptr );
117  virtual int InitData ( GRealSampleFFT & s );
118  virtual void ResetData ( );
119  virtual void ClearData ( );
120  //@}
121 
122  //----------------------------------------------------------
123  /** @name Access to data */
124  //@{
125  bool IsSampleLocal ( ) const; // inline
126  const GRealSampleFFT * GetSample ( ) const; // inline
127  GRealSampleFFT * GetSample ( ); // inline
128  const GRealSampleFFT * GetDerivativeSample ( ) const; // inline
129  GRealSampleFFT * GetDerivativeSample ( ); // inline
130 
131  u_int GetExtremaNum ( ) const; // inline
132  const double * GetExtremaValues ( ) const; // inline
133  double * GetExtremaValues ( ); // inline
134  const double * GetExtremaPositions ( ) const; // inline
135  double * GetExtremaPositions ( ); // inline
136  const u_int * GetExtremaBins ( ) const; // inline
137  u_int * GetExtremaBins ( ); // inline
138  const bool * GetExtremaMax ( ) const; // inline
139  bool * GetExtremaMax ( ); // inline
140 
141 
142  u_int GetMaximaNum ( ) const; // inline
143  const double * GetMaximaValues ( ) const; // inline
144  double * GetMaximaValues ( ); // inline
145  const double * GetMaximaPositions ( ) const; // inline
146  double * GetMaximaPositions ( ); // inline
147  const u_int * GetMaximaBins ( ) const; // inline
148  u_int * GetMaximaBins ( ); // inline
149  const double * GetMaximaCenters ( ) const; // inline
150  double * GetMaximaCenters ( ); // inline
151  const double * GetMaximaAmplitudes ( ) const; // inline
152  double * GetMaximaAmplitudes ( ); // inline
153  const double * GetMaximaAverages ( ) const; // inline
154  double * GetMaximaAverages ( ); // inline
155 
156  double GetMaxValue ( u_int i ) const; // inline
157  double GetMaxPosition ( u_int i ) const; // inline
158  u_int GetMaxBin ( u_int i ) const; // inline
159  double GetMaxCenter ( u_int i ) const; // inline
160  double GetMaxAmplitude ( u_int i ) const; // inline
161  double GetMaxAverage ( u_int i ) const; // inline
162 
163  u_int GetMaxPrevMinBin ( u_int i ) const; // inline
164  u_int GetMaxNextMinBin ( u_int i ) const; // inline
165  double GetMaxPrevMinPos ( u_int i ) const; // inline
166  double GetMaxNextMinPos ( u_int i ) const; // inline
167  double GetMaxPrevMinVal ( u_int i ) const; // inline
168  double GetMaxNextMinVal ( u_int i ) const; // inline
169  //@}
170 
171  //----------------------------------------------------------
172  /** @name Extrema analysis */
173  //@{
174  virtual int Analyse ( );
175  virtual int Analyse ( GRealSampleFFT * sptr );
176  virtual int Analyse ( GRealSampleFFT & s );
177 
178  virtual int DifferentialThreshold ( double thr );
179 
180  virtual void SetMaximaLowThreshold ( double thr ); // inline
181  virtual void UnsetMaximaLowThreshold ( ); // inline
182  virtual int AnalyseMaxima ( );
183  virtual int AnalyseMaxima ( GRealSampleFFT & s );
184  virtual int AnalyseMaxima ( GRealSampleFFT & s, double low_thr );
185  virtual int AnalyseMaxima ( GRealSampleFFT & s, double low_thr, double dif_thr );
186  //@}
187 };
188 
189 //======================================================================
190 // Inline functions
191 #include "icc/GExtremaFinder.icc"
192 
193 
194 //======================================================================
195 #endif
u_int * max_next_min_bin
Array of positions of the minimum after maxima.
Definition: GExtremaFinder.hh:90
u_int GetMaxPrevMinBin(u_int i) const
Definition: GExtremaFinder.icc:163
virtual int DifferentialThreshold(double thr)
Definition: GExtremaFinder.cpp:522
virtual void SetMaximaLowThreshold(double thr)
Definition: GExtremaFinder.icc:202
double GetMaxValue(u_int i) const
Definition: GExtremaFinder.icc:126
double * max_next_min_val
Array of values of the minimum after maxima.
Definition: GExtremaFinder.hh:86
double * max_pos
Array of maxima positions.
Definition: GExtremaFinder.hh:79
virtual void CopyData(const GExtremaFinder &original)
Definition: GExtremaFinder.cpp:245
u_int alloc_size
Allocated size for arrays.
Definition: GExtremaFinder.hh:67
u_int GetMaxNextMinBin(u_int i) const
Definition: GExtremaFinder.icc:169
GObjectV(GExtremaFinder)
double GetMaxPrevMinVal(u_int i) const
Definition: GExtremaFinder.icc:187
u_int max_num
Number of maxima.
Definition: GExtremaFinder.hh:77
const double * GetMaximaPositions() const
Definition: GExtremaFinder.icc:86
const u_int * GetMaximaBins() const
Definition: GExtremaFinder.icc:94
Definition: GRealSampleFFT.hh:20
double * extr_pos
Array of extrema positions.
Definition: GExtremaFinder.hh:71
double * max_amp
Array of maxima zone sum amplitude.
Definition: GExtremaFinder.hh:82
virtual int InitData(u_int n, double *data, double bin=1.)
Definition: GExtremaFinder.cpp:297
const double * GetMaximaValues() const
Definition: GExtremaFinder.icc:78
const double * GetMaximaCenters() const
Definition: GExtremaFinder.icc:102
const bool * GetExtremaMax() const
Definition: GExtremaFinder.icc:64
double GetMaxNextMinVal(u_int i) const
Definition: GExtremaFinder.icc:193
u_int GetMaxBin(u_int i) const
Definition: GExtremaFinder.icc:138
Definition: GExtremaFinder.hh:53
u_int * max_prev_min_bin
Array of positions of the minimum before maxima.
Definition: GExtremaFinder.hh:89
virtual ~GExtremaFinder()
Definition: GExtremaFinder.cpp:185
double * max_next_min_pos
Array of positions of the minimum after maxima.
Definition: GExtremaFinder.hh:88
const GRealSampleFFT * GetSample() const
Definition: GExtremaFinder.icc:22
virtual void UnsetMaximaLowThreshold()
Definition: GExtremaFinder.icc:207
u_int GetMaximaNum() const
Definition: GExtremaFinder.icc:70
bool * extr_max
Array indicating if extrema are maxima (or minima)
Definition: GExtremaFinder.hh:73
u_int GetExtremaNum() const
Definition: GExtremaFinder.icc:32
const double * GetMaximaAverages() const
Definition: GExtremaFinder.icc:118
bool analyzed
Whether the extrema have been analyzed.
Definition: GExtremaFinder.hh:65
GExtremaFinder(u_int n=0, double *data=NULL, double bin=1.)
Definition: GExtremaFinder.cpp:20
double GetMaxNextMinPos(u_int i) const
Definition: GExtremaFinder.icc:181
u_int * extr_bin
Array of bins with extrema.
Definition: GExtremaFinder.hh:72
GRealSampleFFT * deriv_ptr
Derivative of the data sample.
Definition: GExtremaFinder.hh:63
double * max_ctr
Array of maxima zone average positions.
Definition: GExtremaFinder.hh:81
virtual void ClearData()
Definition: GExtremaFinder.cpp:234
const u_int * GetExtremaBins() const
Definition: GExtremaFinder.icc:56
bool IsSampleLocal() const
Definition: GExtremaFinder.icc:10
GExtremaFinder & operator=(const GExtremaFinder &original)
Definition: GExtremaFinder.cpp:175
double GetMaxCenter(u_int i) const
Definition: GExtremaFinder.icc:144
const double * GetExtremaValues() const
Definition: GExtremaFinder.icc:40
GRealSampleFFT * sample_ptr
Pointer to the data sample to analyse.
Definition: GExtremaFinder.hh:61
double * max_avg
Array of maxima zone average amplitude.
Definition: GExtremaFinder.hh:83
double GetMaxPrevMinPos(u_int i) const
Definition: GExtremaFinder.icc:175
u_int extr_num
Number of extrema.
Definition: GExtremaFinder.hh:69
const GRealSampleFFT * GetDerivativeSample() const
Definition: GExtremaFinder.icc:26
virtual int AnalyseMaxima()
Definition: GExtremaFinder.cpp:682
double * max_val
Array of maxima values.
Definition: GExtremaFinder.hh:78
virtual void ResetData()
Definition: GExtremaFinder.cpp:196
unsigned int u_int
Definition: GTypes.hh:38
double GetMaxPosition(u_int i) const
Definition: GExtremaFinder.icc:132
u_int * max_bin
Array of bins with maxima.
Definition: GExtremaFinder.hh:80
double * max_prev_min_val
Array of values of the minimum before maxima.
Definition: GExtremaFinder.hh:85
double GetMaxAmplitude(u_int i) const
Definition: GExtremaFinder.icc:150
double * extr_val
Array of extrema values.
Definition: GExtremaFinder.hh:70
bool max_thr_use
Use of a low signal threshold for maxima analysis.
Definition: GExtremaFinder.hh:75
virtual int Analyse()
Definition: GExtremaFinder.cpp:398
double max_thr_low
Low signal threshold for maxima analysis.
Definition: GExtremaFinder.hh:76
double GetMaxAverage(u_int i) const
Definition: GExtremaFinder.icc:156
bool sample_local
Whether the sample is allocated by the class.
Definition: GExtremaFinder.hh:62
double * max_prev_min_pos
Array of positions of the minimum before maxima.
Definition: GExtremaFinder.hh:87
const double * GetExtremaPositions() const
Definition: GExtremaFinder.icc:48
const double * GetMaximaAmplitudes() const
Definition: GExtremaFinder.icc:110