source: Sophya/trunk/ArchTOIPipe/ProcWSophya/simtoipr.h@ 2078

Last change on this file since 2078 was 2008, checked in by ansari, 23 years ago

Correction bugs estimation offset par ajustement polynomial - Reza 16/5/2002

File size: 7.6 KB
Line 
1// This may look like C code, but it is really -*- C++ -*-
2
3// ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL
4// Eric Aubourg
5// Christophe Magneville
6// Reza Ansari
7// $Id: simtoipr.h,v 1.13 2002-05-16 13:13:00 ansari Exp $
8
9
10#ifndef SIMTOIPR_H
11#define SIMTOIPR_H
12
13#include "toiprocessor.h"
14#include "tvector.h"
15
16// --------- Un deglitcheur simple
17// Dans chaque fenetre de largeur de wsz
18// if (val > Mean(Window)+ns*Sigma(Window)) val = Mean(Window)
19// Si Pas plus de maxnpt points remplissants cette condition
20//
21// Structure generale :
22//
23// --------------------
24// toi in ---> | | ---> out (toi = in_deglitche)
25// | SimpleDeglitcher | ---> mean (toi - optionnel)
26// | | ---> sigma (toi - optionnel)
27// | | ---> incopie ( toi = in , optionnel)
28// | |
29// --------------------
30// Si pas de toi out connecte, seul mean et sigma sont calcule
31// les flags sont mis a jour pour le toi out en sortie
32
33class SimpleDeglitcher : public TOIProcessor {
34public:
35 SimpleDeglitcher(int wsz=64, double ns=3,
36 int maxnpt=5, int minnpt=2);
37 virtual ~SimpleDeglitcher();
38
39 inline void SetRange(double min, double max)
40 { range_min = min; range_max = max; }
41 inline void GetRange(double& min, double& max) const
42 { min = range_min; max = range_max; }
43
44 inline void SetWSize(int wsz)
45 { wsize = (wsz < 5) ? 5 : wsz; }
46
47
48 void SetDetectionParam(double ns, double ns2, int maxnpt,
49 int minnpt, int wszrec=0);
50
51 inline void RepBadSamples(bool gl_samples, bool out_range_samples, bool use_wrec=true)
52 { rec_gl_samples = gl_samples; rec_out_range_samples = out_range_samples;
53 rec_use_wrec = use_wrec; }
54
55 virtual void init();
56 virtual void run();
57
58 inline int WSize() const { return wsize; }
59 inline int WRecSize() const { return wrecsize; }
60 inline double NbSigmas() const { return nsig; }
61 inline double NbSigmas2() const { return nsig2; }
62 inline int MaxPoints() const { return maxpoints; }
63 inline int MinPoints() const { return minpoints; }
64
65 inline int_8 ProcessedSampleCount() const { return totnscount; }
66 inline int_8 GlitchCount() const { return glcount; }
67 inline int_8 GlitchSampleCount() const { return glnscount; }
68 inline int_8 SrcFgCount() const { return srcfgcount; }
69 inline int_8 SrcFgSampleCount() const { return srcfgnscount; }
70 inline int_8 OutOfRangeSampleCount() const { return out_range_nscount; }
71
72 virtual void PrintStatus(::ostream & os) ; // const plus tard
73
74protected:
75 int_8 totnscount; // Nombre total d'echantillon processe
76 int_8 glnscount; // Nombre total de glitch
77 int_8 glcount; // Nombre de glitch detecte
78 int_8 srcfgnscount; // Nombre total d'echantillons flagges source
79 int_8 srcfgcount; // Nombre de sections flaggees source
80 int_8 out_range_nscount; // Nombre de sample Out Of Range
81 bool deglitchdone; // Deglitch effectue
82
83 int wsize; // Taille de fenetre de travail
84 int wrecsize; // Taille de fenetre de calcul pour reconstruite les mauvaises valeur
85 // pour valeur de glitch
86 double nsig; // Seuil en nb de sigmas
87 double nsig2; // Seuil en nb de sigmas, pour les points suivants le 1er
88 int maxpoints; // Nb maxi de points > ns sigmas
89 int minpoints; // Nb mini de points > ns sigmas pour avoir un glitch
90 double range_min, range_max; // Range acceptable pour in
91
92 bool rec_gl_samples; // if true, replace glitch sample values
93 bool rec_out_range_samples; // if true, replace out of range sample values
94 bool rec_use_wrec; // if true, use Mean[Window(wrecsize)] to replace bad samples
95 // else use sliding mean value for
96
97};
98
99
100// Un filtre simple, dans le domaine temporel
101// remplace val -> Somme(val(i)*coeff(i)) ds Fenetre
102//
103// Structure generale :
104//
105// ------------------
106// toi in ---> | | ---> out (toi = in_filtre)
107// | SimpleFilter |
108// | | ---> incopie ( toi = in , optionnel)
109// | |
110// ------------------
111
112class SimpleFilter : public TOIProcessor {
113public:
114 enum FilterKind {
115 UserFilter=0, // User defined filter function
116 MeanFilter=1, // Replace sample by the window mean value (lowpass)
117 SumFilter=2, // Replace sample by the window sum (lowpass)
118 GaussFilter=3, // Apply a gaussian to the window samples
119 DiffFilter=4, // value -= MeanValue
120 };
121
122 static string FilterKind2String(FilterKind fk);
123 SimpleFilter(int wsz=128,
124 FilterKind fk=SimpleFilter::MeanFilter,
125 double a=1., double s=1.);
126 SimpleFilter(Vector const & vc);
127 ~SimpleFilter();
128
129 inline FilterKind Type() { return fkind; }
130
131 inline int WSize() const { return wsize; }
132 inline int_8 ProcessedSampleCount() const { return totnscount; }
133 Vector FilterCoefficients() const;
134
135 virtual void PrintStatus(::ostream & os) ; // const plus tard
136
137 virtual void init();
138 virtual void run();
139
140protected:
141 FilterKind fkind;
142 int_8 totnscount; // Nombre total d'echantillon processe
143 int wsize; // Taille de fenetre de travail
144 double* coef; // Coefficients du filtre
145
146};
147
148// Classe SimpleAdder
149// Calcule la sortie = Somme_Entree [ coeff[num] * entree[num] ]
150
151class SimpleAdder : public TOIProcessor {
152public:
153 SimpleAdder(int nbinput);
154 ~SimpleAdder();
155
156 void SetGain(int num, double g);
157 double Gain(int num);
158
159 inline int NbInput() const { return nb_input; }
160 inline int_8 ProcessedSampleCount() const { return totnscount; }
161
162 virtual void PrintStatus(::ostream & os) ; // const plus tard
163
164 virtual void init();
165 virtual void run();
166
167protected:
168 int nb_input;
169 Vector gains;
170 int_8 totnscount; // Nombre total d'echantillon processe
171};
172
173
174// Un filtre simple, dans le domaine de Fourier
175// InverseFFT ( FFT(Vecteur(in)) * FilterCoefficient )
176
177class SimpleFourierFilter : public TOIProcessor {
178public:
179 SimpleFourierFilter(Vector const & vc);
180 ~SimpleFourierFilter();
181
182 inline int WSize() const { return wsize; }
183 inline int_8 ProcessedSampleCount() const { return totnscount; }
184 inline Vector FilterCoefficients() const
185 { Vector rcv; rcv = ffcoef; return(rcv); }
186
187 virtual void PrintStatus(::ostream & os) ; // const plus tard
188
189 virtual void init();
190 virtual void run();
191
192 inline void KeepSpectra(string outname, int nb)
193 { outppfname = outname; nb_keep = nb; }
194 inline void ComputeMeanSpectra(bool fg)
195 { c_meanspectra = fg; }
196protected:
197 int_8 totnscount; // Nombre total d'echantillon processe
198 int_8 totnbblock; // Nombre total de blocs pour FFT
199 int wsize; // Taille de fenetre de travail
200 Vector ffcoef; // Coefficients du filtre
201 bool c_meanspectra;
202 int nb_keep;
203 string outppfname;
204};
205
206
207// Classe SimpleFanOut
208// Recopie chaque entree sur M lignes de sortie
209
210class SimpleFanOut : public TOIProcessor {
211public:
212 SimpleFanOut(int nbinput, int mfanout);
213 ~SimpleFanOut();
214
215 inline int NbInput() const { return nb_input; }
216 inline int MFanOut() const { return m_fanout; }
217 inline int_8 ProcessedSampleCount() const { return totnscount; }
218
219 virtual void PrintStatus(::ostream & os) ; // const plus tard
220
221 virtual void init();
222 virtual void run();
223
224protected:
225 int nb_input;
226 int m_fanout;
227 int_8 totnscount; // Nombre total d'echantillon processe
228};
229
230
231#endif
Note: See TracBrowser for help on using the repository browser.