source: Sophya/trunk/ArchTOIPipe/ProcWSophya/rztoi.cc@ 1462

Last change on this file since 1462 was 1462, checked in by cmv, 24 years ago

changement getData... intermediaire NE COMPILE PAS cmv+rz 10/4/2001

File size: 5.6 KB
Line 
1#include "array.h"
2#include "rztoi.h"
3#include "toimanager.h"
4#include "pexceptions.h"
5#include "fftpserver.h"
6#include "ctimer.h"
7
8RzTOIProc::RzTOIProc(int w1, int w2, int nmax)
9{
10 cout << "RzTOIProc::RzTOIProc() Width= " << w1 << "," << w2 << " NMax=" << nmax;
11 _width1 = w1;
12 _width2 = w2;
13 _nmax = nmax;
14}
15
16void RzTOIProc::init() {
17 cout << "RzTOIProc::init" << endl;
18 declareInput("in");
19 declareOutput("out");
20 name = "rzproc";
21 upExtra = 1;
22}
23
24void RzTOIProc::run() {
25 // TOIManager* mgr = TOIManager::getManager();
26 int snb = getMinIn();
27 int sne = getMaxIn();
28
29 int istart, iend;
30 int ilast;
31 ilast = istart = snb;
32 iend = sne;
33 int ii, jj;
34
35 try {
36 Timer tm("RzTOIProc::run()");
37
38 FFTPackServer ffts;
39
40 bool fgppf = false;
41 int nkv = 0;
42 // int nkvmx = 8;
43#define nkvmx 8
44 Vector vkin[nkvmx];
45 Vector vkout[nkvmx];
46 TVector< complex<r_8> > vkfft[nkvmx];
47 if (outppf.length() > 0) fgppf = true;
48
49 Vector vin, vout, vsave(_width2);
50 TVector< complex<r_8> > vfft;
51 double vlast = 0.;
52
53 for (int k=0; k<_nmax; k++) {
54 // istart = snb + k*_width1;
55 istart = snb + k*_width1 - k*_width2;
56 iend = istart +_width1;
57 cout << "---RzTOIProc::run() - Processing bloc k= " << k
58 << " istart= " << istart << " iend= " << iend << endl;
59 if (iend > sne) {
60 cout << " RzTOIProc::run() - iend > getMaxIn() -> break " << endl;
61 break;
62 }
63 // Vector vin = getData(0, istart, iend);
64 vin.ReSize(_width1);
65 if (k == 0) {
66 jj = 0;
67 for(ii=istart; ii<iend; ii++)
68 vin(jj++) = getData(0, ii);
69 }
70 else {
71 vin(Range(0,-1,_width2)) = vsave;
72 jj = _width2;
73 for(ii=istart+_width2; ii<iend; ii++)
74 vin(jj++) = getData(0, ii);
75 }
76
77 vsave = vin(Range(_width1-_width2, -1,_width2));
78 cout << "> End of getData() for bloc " << k << endl;
79
80 vout.ReSize(vin.Size());
81 // cout << " DBG : Bloc[" << k << "] FirstSN=" << istart
82 // << " LastSN= " << istart+vout.Size()-_width2-1 << endl;
83 for(int i=0; i<vout.Size()-_width2; i++) {
84 vout(i) = vin(Range(i,-1,_width2)).Sum()/(r_8)_width2;
85 putData(0, i+istart, vout(i));
86 vlast = vout(i);
87 }
88
89 for(int i=vout.Size()-_width2; i<vout.Size(); i++) {
90 vout(i) = vlast;
91 // putData(0, i+istart, vout(i));
92 }
93
94 cout << ">> End of putData() for bloc[" << k << "] FirstSN="
95 << istart << " LastSN= " << istart+vout.Size()-_width2-1
96 << " Mean vout= " << vout.Sum()/vout.Size() << endl;
97
98 vin -= vout;
99
100 TVector< complex<r_8> > vfft;
101 ffts.FFTForward(vin, vfft);
102 ilast = iend;
103 /*
104 if (fgppf) {
105 string nom;
106 nom = "in" + (string)MuTyV(k);
107 ppo->PutObject(vin, nom);
108 nom = "out" + (string)MuTyV(k);
109 ppo->PutObject(vout, nom);
110 nom = "fft" + (string)MuTyV(k);
111 ppo->PutObject(vfft, nom);
112 }
113 */
114 if (fgppf && (nkv < nkvmx) ) {
115 vkin[nkv] = vin;
116 vkout[nkv] = vout;
117 vkfft[nkv] = vfft;
118 nkv++;
119 }
120
121 tm.Split("End of bloc");
122 }
123
124 if (fgppf) {
125 cout << " Writing to Out PPF ... " << endl;
126 POutPersist ppo(outppf);
127 for(int kkk=0; kkk<nkv; kkk++) {
128 string nom;
129 nom = "in" + (string)MuTyV(kkk);
130 ppo.PutObject(vkin[kkk], nom);
131 nom = "out" + (string)MuTyV(kkk);
132 ppo.PutObject(vkout[kkk], nom);
133 nom = "fft" + (string)MuTyV(kkk);
134 ppo.PutObject(vkfft[kkk], nom);
135 }
136 }
137
138 cout << " Filling with flag!=0 : putData(0, ii, flag) ii: "
139 << iend << " .. " << sne << endl;
140 for(ii=iend-_width2; ii<iend; ii++) {
141 putData(0, ii, vlast, 1);
142 }
143
144 double xxx;
145 for(ii=iend; ii<sne; ii++) {
146 if ((ii-iend)%1000 == 0)
147 cout << " RzTOIProc::run() - Processing sample ii= " << ii
148 << endl;
149 xxx=getData(0,ii);
150 putData(0,ii,xxx,2);
151 }
152
153 }
154 catch (PException & e) {
155 cout << "RzTOIProc: Catched exception " << (string)typeid(e).name()
156 << "\n Msg= " << e.Msg() << endl;
157 }
158}
159
160
161
162RzSimpleTOIProc::RzSimpleTOIProc(int wsz, double fact)
163{
164 if (wsz < 4) wsz = 4;
165 cout << "RzSimpleTOIProc::RzSimpleTOIProc() factor= " << fact
166 << " WSize=" << wsz << endl;
167 _fact = fact;
168 _wsz = wsz;
169}
170
171void RzSimpleTOIProc::init() {
172 cout << "RzSimpleTOIProc::init" << endl;
173 declareInput("in");
174 declareOutput("out");
175 name = "rzsimpleproc";
176 upExtra = 1;
177}
178
179void RzSimpleTOIProc::run() {
180 // TOIManager* mgr = TOIManager::getManager();
181 int snb = getMinIn();
182 int sne = getMaxIn();
183
184 int nstot = sne-snb;
185 int nbloc = nstot/_wsz;
186 cout << " RzSimpleTOIProc::run(): snb=" << snb << " sne="
187 << sne << " NBloc=" << nbloc << endl;
188
189 double val;
190 int snlast = snb;
191 int istart,ii,kb;
192 try {
193 Timer tm("RzSimpleTOIProc::run()");
194 Vector vin(_wsz);
195 for (kb=0; kb<nbloc; kb++) {
196 istart = kb*_wsz+snb;
197 if (kb%2 == 0) { // On parcourt a l'envers
198 cout << " ... Processing bloc[" << kb << "] (Reverse) SampleNum="
199 << istart+_wsz << " ->" << istart << endl;
200 for(ii=_wsz-1; ii>=0; ii--)
201 vin(ii) = getData(0, ii+istart);
202 }
203 else { // On parcourt vers l'avant
204 cout << " ... Processing bloc[" << kb << "] SampleNum="
205 << istart << " ->" << istart+_wsz << endl;
206 for(ii=0; ii<_wsz; ii++)
207 vin(ii) = getData(0, ii+istart);
208 }
209 for(ii=0; ii<_wsz; ii++)
210 putData(0, ii+istart, vin(ii)*_fact);
211 snlast = istart+_wsz;
212 }
213 cout << " ... Processing remaining Samples - SN="
214 << snlast << " ->" << sne << endl;
215 for(ii=snlast; ii<=sne; ii++) {
216 val = getData(0, ii);
217 putData(0, ii, val*_fact);
218 }
219
220
221 }
222 catch (PException & e) {
223 cout << "RzSimpleTOIProc exception " << (string)typeid(e).name()
224 << "\n Msg= " << e.Msg() << endl;
225 }
226}
Note: See TracBrowser for help on using the repository browser.