[1437] | 1 | #include "rztoi.h"
|
---|
| 2 | #include "toimanager.h"
|
---|
| 3 | #include "pexceptions.h"
|
---|
| 4 | #include "fftpserver.h"
|
---|
| 5 | #include "timing.h"
|
---|
| 6 |
|
---|
| 7 | RzTOIProc::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 |
|
---|
| 15 | void RzTOIProc::init() {
|
---|
| 16 | cout << "RzTOIProc::init" << endl;
|
---|
| 17 | declareInput("signal");
|
---|
| 18 | declareOutput("sfout");
|
---|
| 19 | name = "rzproc";
|
---|
| 20 | upExtra = 1;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | void 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 |
|
---|
| 47 | Vector vin, vout;
|
---|
| 48 | TVector< complex<r_8> > vfft;
|
---|
| 49 |
|
---|
| 50 | for (int k=0; k<_nmax; k++) {
|
---|
| 51 | istart = snb + k*_width1;
|
---|
| 52 | // if (k>0) istart -= _width2;
|
---|
| 53 | iend = istart +_width1;
|
---|
| 54 | cout << " RzTOIProc::run() - Processing bloc k= " << k
|
---|
| 55 | << " istart= " << istart << " iend= " << iend << endl;
|
---|
| 56 | if (iend > sne) {
|
---|
| 57 | cout << " RzTOIProc::run() - iend > getMaxIn() -> break " << endl;
|
---|
| 58 | break;
|
---|
| 59 | }
|
---|
| 60 | // Vector vin = getData(0, istart, iend);
|
---|
| 61 | vin.ReSize(_width1);
|
---|
| 62 | jj = 0;
|
---|
| 63 | for(ii=istart; ii<iend; ii++)
|
---|
| 64 | vin(jj++) = getData(0, ii);
|
---|
| 65 |
|
---|
| 66 | cout << " End of getData() for bloc " << k << endl;
|
---|
| 67 |
|
---|
| 68 | vout.ReSize(vin.Size());
|
---|
| 69 | double vlast = 0.;
|
---|
| 70 | for(int i=0; i<vout.Size()-_width2; i++) {
|
---|
| 71 | vout(i) = vin(Range(i,-1,_width2)).Sum()/(r_8)_width2;
|
---|
| 72 | putData(0, i+istart, vout(i));
|
---|
| 73 | vlast = vout(i);
|
---|
| 74 | }
|
---|
| 75 |
|
---|
| 76 | for(int i=vout.Size()-_width2; i<vout.Size(); i++) {
|
---|
| 77 | vout(i) = vlast;
|
---|
| 78 | putData(0, i+istart, vout(i));
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | cout << " End of putData() for bloc " << k << " Mean vout= "
|
---|
| 82 | << vout.Sum()/vout.Size() << endl;
|
---|
| 83 |
|
---|
| 84 | vin -= vout;
|
---|
| 85 |
|
---|
| 86 | TVector< complex<r_8> > vfft;
|
---|
| 87 | ffts.FFTForward(vin, vfft);
|
---|
| 88 | ilast = iend;
|
---|
| 89 | /*
|
---|
| 90 | if (fgppf) {
|
---|
| 91 | string nom;
|
---|
| 92 | nom = "in" + (string)MuTyV(k);
|
---|
| 93 | ppo->PutObject(vin, nom);
|
---|
| 94 | nom = "out" + (string)MuTyV(k);
|
---|
| 95 | ppo->PutObject(vout, nom);
|
---|
| 96 | nom = "fft" + (string)MuTyV(k);
|
---|
| 97 | ppo->PutObject(vfft, nom);
|
---|
| 98 | }
|
---|
| 99 | */
|
---|
| 100 | if (fgppf && (nkv < nkvmx) ) {
|
---|
| 101 | vkin[nkv] = vin;
|
---|
| 102 | vkout[nkv] = vout;
|
---|
| 103 | vkfft[nkv] = vfft;
|
---|
| 104 | nkv++;
|
---|
| 105 | }
|
---|
| 106 | PrtTim("End of bloc");
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | if (fgppf) {
|
---|
| 110 | cout << " Writing to Out PPF ... " << endl;
|
---|
| 111 | POutPersist ppo(outppf);
|
---|
| 112 | for(int kkk=0; kkk<nkv; kkk++) {
|
---|
| 113 | string nom;
|
---|
| 114 | nom = "in" + (string)MuTyV(kkk);
|
---|
| 115 | ppo.PutObject(vkin[kkk], nom);
|
---|
| 116 | nom = "out" + (string)MuTyV(kkk);
|
---|
| 117 | ppo.PutObject(vkout[kkk], nom);
|
---|
| 118 | nom = "fft" + (string)MuTyV(kkk);
|
---|
| 119 | ppo.PutObject(vkfft[kkk], nom);
|
---|
| 120 | }
|
---|
| 121 | }
|
---|
| 122 |
|
---|
| 123 | cout << " Filling -9999 : putData(0, ii, -9999.) ii: "
|
---|
| 124 | << iend << " .. " << sne << endl;
|
---|
| 125 | double xxx;
|
---|
| 126 | for(ii=iend; ii<sne; ii++) {
|
---|
| 127 | if ((ii-iend)%1000 == 0)
|
---|
| 128 | cout << " RzTOIProc::run() - Processing sample ii= " << ii
|
---|
| 129 | << endl;
|
---|
| 130 | xxx=getData(0,ii);
|
---|
| 131 | putData(0,ii,xxx-9999.);
|
---|
| 132 | }
|
---|
| 133 |
|
---|
| 134 | }
|
---|
| 135 | catch (PException & e) {
|
---|
| 136 | cout << "RzTOIProc exception Msg= " << e.Msg() << endl;
|
---|
| 137 | }
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 |
|
---|
| 141 |
|
---|
| 142 | RzSimpleTOIProc::RzSimpleTOIProc(double fact, int npr)
|
---|
| 143 | {
|
---|
| 144 | cout << "RzSimpleTOIProc::RzSimpleTOIProc() factor= " << fact
|
---|
| 145 | << " npr=" << npr << endl;
|
---|
| 146 | _fact = fact;
|
---|
| 147 | _nprt = npr;
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | void RzSimpleTOIProc::init() {
|
---|
| 151 | cout << "RzSimpleTOIProc::init" << endl;
|
---|
| 152 | declareInput("signal");
|
---|
| 153 | declareOutput("sfout");
|
---|
| 154 | name = "rzsimpleproc";
|
---|
| 155 | upExtra = 1;
|
---|
| 156 | }
|
---|
| 157 |
|
---|
| 158 | void RzSimpleTOIProc::run() {
|
---|
| 159 | // TOIManager* mgr = TOIManager::getManager();
|
---|
| 160 | int snb = getMinIn();
|
---|
| 161 | int sne = getMaxIn();
|
---|
| 162 |
|
---|
| 163 | cout << " RzSimpleTOIProc::run(): snb=" << snb << " sne=" << sne << endl;
|
---|
| 164 |
|
---|
| 165 | double val;
|
---|
| 166 | try {
|
---|
| 167 | for (int k=snb; k<sne; k++) {
|
---|
| 168 | if ((k-snb)%_nprt == 0)
|
---|
| 169 | cout << " RzSimpleTOIProc::run() - Processing sample k= " << k
|
---|
| 170 | << endl;
|
---|
| 171 |
|
---|
| 172 | val = getData(0, k);
|
---|
| 173 | putData(0, k, val*_fact);
|
---|
| 174 | }
|
---|
| 175 | }
|
---|
| 176 | catch (PException & e) {
|
---|
| 177 | cout << "RzSimpleTOIProc exception Msg= " << e.Msg() << endl;
|
---|
| 178 | }
|
---|
| 179 | }
|
---|