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

Last change on this file since 1439 was 1439, checked in by ansari, 25 years ago

Correction bugs, protections, ameliorations - Reza 13/3/2001

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