Logo Coherent WaveBurst  
Reference Guide
Logo
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Window.hh
Go to the documentation of this file.
1 /***************************************************************************
2  Window.hh - description
3  -------------------
4  begin : Wen Dec 21 2011
5  copyright : (C) 2011 by Gabriele Vedovato
6  email : vedovato@lnl.infn.it
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef CWBWINDOW_H
19 #define CWBWINDOW_H
20 
21 
22 /**
23  *@author Gabriele Vedovato
24  */
25 
26 /* Reference:
27  * Oppenheim, A. V. and Schafer, R. W., ``Discrete-Time Signal Processing.''
28  * ISBN 0-13-216771-9, Prentice-Hall, Inc., 1989, pp. 447--448
29  *
30  * http://www.mathworks.com/access/helpdesk/help/toolbox/signal/signal.shtml
31  */
32 
33 /* this is a c++ porting of the window package in the "Sonic Flow" tool box
34  The homepage of Sonic Flow is at http://sonicflow.sourceforge.net/.
35  */
36 
37 #include <time.h>
38 #include <stdlib.h>
39 #include <math.h>
40 #include <ctype.h>
41 #include <string>
42 #include <iostream>
43 #include <fstream>
44 #include "TROOT.h"
45 #include "TObjArray.h"
46 #include "TObjString.h"
47 #include "TString.h"
48 
49 using namespace std;
50 
51 namespace CWB {
52 
53 class Window {
54 public:
55  Window(char* formula, unsigned n, double fParameter=0);
56  ~Window();
57 
58  TString GetVersion(char c='s') {
59  if(c=='s') return TString("window101");
60  if(c=='d') return TString("101");
61  else return TString("window-1.0.1");
62  }
63 
64  double GetValue(unsigned i);
65  double GetSize() {return size;}
66 
67 private:
68 
69  double* window;
70  unsigned size;
71  void Normalize (double* out_window, unsigned n);
72  double fParameter;
73 
74  /* Compute a modified Bartlett-Hann window.
75  * Like Bartlett, Hann, and Hamming windows, this window has a
76  * mainlobe at the origin and asymptotically decaying sidelobes on
77  * both sides. It is a linear combination of weighted Bartlett and
78  * Hann windows with near sidelobes lower than both Bartlett and Hann
79  * and with far sidelobes lower than both Bartlett and Hamming
80  * windows. The mainlobe width of the modified Bartlett-Hann window is
81  * not increased relative to either Bartlett or Hann window mainlobes.
82  */
83  void
84  barthann (double* out_window, unsigned n);
85 
86  /* Compute a Bartlett window.
87  * The Bartlett window is very similar to a triangular window as
88  * returned by the triangular function. The Bartlett
89  * window always ends with zeros at samples 0 and n -1, however,
90  * while the triangular window is nonzero at those points. For length
91  * odd, the center n-2 points of bartlett(,n) are equivalent
92  * to those of sf_window_triangular(,n-2).
93  */
94  void
95  bartlett (double* out_window, unsigned n);
96 
97  /* Compute a Blackman window
98  * Blackman windows have slightly wider central lobes and less sideband
99  * leakage than equivalent length Hamming and Hann windows.
100  */
101  void
102  blackman (double* out_window, unsigned n);
103 
104  /* Compute a minimum 4-term Blackman-harris window.
105  * The window is minimum in the sense that its maximum sidelobes are
106  * minimized.
107  */
108  void
109  blackmanharris (double* out_window, unsigned n);
110 
111  /* Compute a Bohman window.
112  * A Bohman window is the convolution of two half-duration cosine
113  * lobes. In the time domain, it is the product of a triangular window
114  * and a single cycle of a cosine with a term added to set the first
115  * derivative to zero at the boundary. Bohman windows fall off as 1/w^4.
116  */
117  void
118  bohman (double* out_window, unsigned n);
119 
120  /* [UNIMPLEMENTED] */
121  /* void */
122  /* chebyshev (double * out_window, unsigned n, */
123  /* double r = 100.0); */
124 
125  /* Compute a Flat Top weighted window
126  * Flat Top windows have very low passband ripple (< 0.01 dB) and are
127  * used primarily for calibration purposes. Their bandwidth is
128  * approximately 2.5 times wider than a Hann window.
129  */
130  void
131  flattop (double* out_window, unsigned n);
132 
133  /* Compute a Gaussian window where alpha >= 2 is the reciprocal of the
134  * standard deviation. The width of the window is inversely related to
135  * the value of alpha; a larger value of alpha produces a more narrow
136  * window. Default value for alpha : 2.5
137  */
138  void
139  gauss (double* out_window, unsigned n,
140  double alpha);
141 
142  /* Compute a Hamming window
143  */
144  void
145  hamming (double* out_window, unsigned n);
146 
147  /* Compute a Hann (Hanning) window
148  */
149  void
150  hann (double* out_window, unsigned n);
151 
152  /* [UNIMPLEMENTED] */
153  /* void */
154  /* kaiser (double * out_window, unsigned n, */
155  /* SF_Real beta = 0.5); */
156 
157  /* Compute a minimum 4-term Blackman-Harris window, as defined by Nuttall
158  * The window is minimum in the sense that its maximum sidelobes are
159  * minimized. The coefficients for this window differ from the
160  * Blackman-Harris window coefficients computed with
161  * blackmanharris and produce slightly lower sidelobes.
162  */
163  void
164  nuttall (double* out_window, unsigned n);
165 
166  /* [UNIMPLEMENTED] */
167  /* void */
168  /* parzen (double* out_window, unsigned n); */
169 
170  /* Compute a rectangular window
171  */
172  void
173  rectangular (double* out_window, unsigned n);
174 
175  /* [UNIMPLEMENTED] */
176  /* void */
177  /* saramaki (double* out_window, unsigned n); */
178 
179  /* [UNIMPLEMENTED] */
180  /* void */
181  /* transversal (double* out_window, unsigned n); */
182 
183  /* Compute a triangular window.
184  */
185  void
186  triangular (double* out_window, unsigned n);
187 
188  /* Compute a Tukey window
189  * Tukey windows are cosine-tapered windows. r is the ratio of taper to
190  * constant sections and is between 0 and 1. r <= 0 is a
191  * rectangular window and r>= 1 is a hann window.
192  * default value for r : 0.5
193  */
194  void
195  tuckey (double* out_window, unsigned n,
196  double r);
197 
198  /* Compute a welch window.
199  */
200  void
201  welch (double* out_window, unsigned n);
202 };
203 
204 } // end namespace
205 
206 #endif
207 
Definition: ced.hh:24
int n
Definition: cwb_net.C:10
TString("c")
STL namespace.
Long_t size
i drho i
TString GetVersion(char c='s')
Definition: Window.hh:58
double fParameter
Definition: Window.hh:72
unsigned size
Definition: Window.hh:70
regression r
Definition: Regression_H1.C:44
double GetSize()
Definition: Window.hh:65
char formula[256]
double * window
Definition: Window.hh:69