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

Last change on this file since 1738 was 1738, checked in by aubourg, 24 years ago

copyright

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