[1462] | 1 | #include "array.h"
|
---|
[1442] | 2 | #include "simtoipr.h"
|
---|
[1454] | 3 | #include <math.h>
|
---|
[1442] | 4 | #include "toimanager.h"
|
---|
| 5 | #include "pexceptions.h"
|
---|
| 6 | #include "ctimer.h"
|
---|
[1479] | 7 | #include "fftpserver.h"
|
---|
[1442] | 8 |
|
---|
[1479] | 9 | SimpleDeglitcher::SimpleDeglitcher(int wsz, double ns, int maxnpt, int minnpt)
|
---|
[1442] | 10 | {
|
---|
[1478] | 11 | SetWSize(wsz);
|
---|
[1479] | 12 | SetDetectionParam(ns, ns/2., maxnpt, minnpt);
|
---|
[1478] | 13 | SetRange(-9.e39, 9.e39);
|
---|
| 14 | RepBadSamples(true, true);
|
---|
[1442] | 15 |
|
---|
[1478] | 16 | totnscount = glnscount = glcount = out_range_nscount = 0;
|
---|
| 17 | deglitchdone = false;
|
---|
| 18 |
|
---|
[1442] | 19 | cout << "SimpleDeglitcher::SimpleDeglitcher() WSize= " << wsz
|
---|
| 20 | << " nSig=" << ns << " maxNPt=" << maxnpt << endl;
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | SimpleDeglitcher::~SimpleDeglitcher()
|
---|
| 24 | {
|
---|
| 25 | }
|
---|
| 26 |
|
---|
[1479] | 27 | void SimpleDeglitcher::SetDetectionParam(double ns, double ns2, int maxnpt,
|
---|
| 28 | int minnpt, int wszrec)
|
---|
[1478] | 29 | {
|
---|
| 30 | nsig = (ns > 0.01) ? ns : 1.;
|
---|
| 31 | nsig2 = (ns2 > 0.01) ? ns2 : nsig/2.;
|
---|
| 32 | maxpoints = ((maxnpt > 0) && (maxnpt <= wsize)) ? maxnpt : 5;
|
---|
[1479] | 33 | minpoints = ((minnpt > 0) && (minnpt <= maxpoints)) ? minnpt : maxpoints/2;
|
---|
[1478] | 34 | wrecsize = ((wszrec > 0) && (wszrec <= wsize)) ? wszrec : 2*maxpoints;
|
---|
| 35 | }
|
---|
[1454] | 36 |
|
---|
[1478] | 37 | inline char * _Bool2YesNo(bool fg)
|
---|
| 38 | {
|
---|
| 39 | if (fg) return "YES" ;
|
---|
| 40 | else return "NO" ;
|
---|
| 41 | }
|
---|
| 42 |
|
---|
[1443] | 43 | void SimpleDeglitcher::PrintStatus(ostream & os)
|
---|
| 44 | {
|
---|
| 45 | os << "\n ------------------------------------------------------ \n"
|
---|
| 46 | << " SimpleDeglitcher::PrintStatus() - WindowSize=" << WSize()
|
---|
[1479] | 47 | << " MaxPoints=" << MaxPoints() << " MinPoints=" << MinPoints() << endl;
|
---|
| 48 | os << " NbSigmas=" << NbSigmas()
|
---|
| 49 | << " NbSigmas2=" << NbSigmas2() << " WRecSize= " << WRecSize()
|
---|
[1478] | 50 | << " Range_Min= " << range_min << " Range_Max= " << range_max << endl;
|
---|
| 51 | os << " RepOutOfRangeSamples: " << _Bool2YesNo(rec_out_range_samples)
|
---|
| 52 | << " RepGlitchSamples: " << _Bool2YesNo(rec_gl_samples)
|
---|
| 53 | << " UseWRec: " << _Bool2YesNo(rec_use_wrec) << endl;
|
---|
[1443] | 54 | TOIProcessor::PrintStatus(os);
|
---|
| 55 | if (deglitchdone) os << " Deglitching performed " << endl;
|
---|
| 56 | else os << " NO deglitching done " << endl;
|
---|
[1454] | 57 | double nst = (ProcessedSampleCount() > 0) ? ProcessedSampleCount() : 1.;
|
---|
| 58 | os << " ProcessedSampleCount=" << ProcessedSampleCount()
|
---|
| 59 | << " OutOfRangeSampleCount=" << OutOfRangeSampleCount() << endl;
|
---|
| 60 | os << " GlitchCount= " << GlitchCount()
|
---|
| 61 | << " GlitchSampleCount=" << GlitchSampleCount()
|
---|
[1443] | 62 | << "( " << (double)GlitchSampleCount()*100./nst << " % )" << endl;
|
---|
| 63 | os << " ------------------------------------------------------ " << endl;
|
---|
| 64 | }
|
---|
| 65 |
|
---|
[1442] | 66 | void SimpleDeglitcher::init() {
|
---|
| 67 | cout << "SimpleDeglitcher::init" << endl;
|
---|
| 68 | declareInput("in");
|
---|
| 69 | declareOutput("out");
|
---|
| 70 | declareOutput("mean");
|
---|
| 71 | declareOutput("sigma");
|
---|
[1443] | 72 | declareOutput("incopie");
|
---|
[1442] | 73 | name = "SimpleDeglitcher";
|
---|
| 74 | // upExtra = 1; A quoi ca sert ?
|
---|
| 75 | }
|
---|
| 76 |
|
---|
[1478] | 77 |
|
---|
| 78 | #define FG_OUTOFRANGE 1
|
---|
| 79 | #define FG_GLITCH 2
|
---|
[1442] | 80 | void SimpleDeglitcher::run() {
|
---|
| 81 |
|
---|
| 82 | // TOIManager* mgr = TOIManager::getManager();
|
---|
| 83 | int snb = getMinIn();
|
---|
| 84 | int sne = getMaxIn();
|
---|
| 85 |
|
---|
| 86 | bool fgout = checkOutputTOIIndex(0);
|
---|
| 87 | bool fgmean = checkOutputTOIIndex(1);
|
---|
| 88 | bool fgsigma = checkOutputTOIIndex(2);
|
---|
[1443] | 89 | bool fgincopie = checkOutputTOIIndex(3);
|
---|
[1442] | 90 |
|
---|
| 91 | if (!checkInputTOIIndex(0)) {
|
---|
| 92 | cerr << " SimpleDeglitcher::run() - Input TOI (in) not connected! "
|
---|
| 93 | << endl;
|
---|
| 94 | throw ParmError("SimpleDeglitcher::run() Input TOI (in) not connected!");
|
---|
| 95 | }
|
---|
[1443] | 96 | if (!fgout && !fgmean && !fgsigma &&!fgincopie) {
|
---|
[1442] | 97 | cerr << " SimpleDeglitcher::run() - No Output TOI connected! "
|
---|
| 98 | << endl;
|
---|
| 99 | throw ParmError("SimpleDeglitcher::run() No output TOI connected!");
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | if (!fgout) {
|
---|
| 103 | cout << "Warning: SimpleDeglitcher::run() - No TOI connected to out \n"
|
---|
| 104 | << " No deglitching would be performed !" << endl;
|
---|
| 105 | }
|
---|
| 106 |
|
---|
[1443] | 107 | cout << " SimpleDeglitcher::run() SNRange=" << snb << " - " << sne << endl;
|
---|
[1442] | 108 | try {
|
---|
[1443] | 109 | Timer tm("SimpleDeglitcher::run()");
|
---|
[1442] | 110 | Vector vin(wsize);
|
---|
[1478] | 111 | Vector vas(wsize);
|
---|
[1467] | 112 |
|
---|
[1478] | 113 | int wrecsize = maxpoints*2;
|
---|
| 114 | Vector vrec(wrecsize);
|
---|
[1467] | 115 |
|
---|
[1532] | 116 | TVector<uint_8> vfg(wsize);
|
---|
[1467] | 117 | int wsz2 = wsize/2;
|
---|
| 118 | // Le debut
|
---|
[1442] | 119 | int k;
|
---|
[1467] | 120 | for(k=0; k<wsz2; k++)
|
---|
[1464] | 121 | getData(0, k+snb, vin(k), vfg(k));
|
---|
| 122 |
|
---|
[1479] | 123 | int nokdebut = 0;
|
---|
[1467] | 124 | double s = 0.;
|
---|
| 125 | double mean = 0.;
|
---|
| 126 | double s2 = 0.;
|
---|
| 127 | double sigma = 0.;
|
---|
| 128 | for(k=0; k<wsz2; k++) {
|
---|
| 129 | if ( vfg(k) != 0) continue;
|
---|
| 130 | if ( (vin(k) < range_min) || (vin(k) > range_max) ) continue;
|
---|
| 131 | s += vin(k);
|
---|
| 132 | s2 += vin(k)*vin(k);
|
---|
| 133 | nokdebut++;
|
---|
[1454] | 134 | }
|
---|
[1467] | 135 | if (nokdebut > 0) {
|
---|
| 136 | mean = s/nokdebut;
|
---|
| 137 | if (nokdebut > 1) sigma = sqrt(s2/nokdebut-mean*mean);
|
---|
| 138 | }
|
---|
| 139 | for(k=wsz2; k<wsize; k++) {
|
---|
| 140 | vin(k) = mean;
|
---|
| 141 | vfg(k) = 0;
|
---|
| 142 | }
|
---|
[1478] | 143 | for(k=0; k<wsize; k++) {
|
---|
| 144 | vas(k) = mean;
|
---|
| 145 | if ( vfg(k) != 0) continue;
|
---|
| 146 | if ( (vin(k) < range_min) || (vin(k) > range_max) ) continue;
|
---|
| 147 | vas(k) = vin(k);
|
---|
| 148 | }
|
---|
[1454] | 149 |
|
---|
[1478] | 150 | for(k=0; k<wrecsize; k++) {
|
---|
[1467] | 151 | if ( (vin(k) < range_min) || (vin(k) > range_max) ) vrec(k)=mean;
|
---|
| 152 | else vrec(k)=vin(k);
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | bool fgokdebut = false;
|
---|
| 156 |
|
---|
[1442] | 157 | int kgl = -1;
|
---|
| 158 | int ii,lastput;
|
---|
| 159 | bool fgglitch = false;
|
---|
| 160 | double valcur,valsub,valadd;
|
---|
[1467] | 161 | double lastvalok = mean;
|
---|
[1454] | 162 | uint_8 fgcur;
|
---|
[1467] | 163 | bool fgokcur=false;
|
---|
[1484] | 164 |
|
---|
| 165 | int sx_refresh_count = 0;
|
---|
| 166 | int sx_refresh_count_max = 16*wsize;
|
---|
| 167 |
|
---|
[1454] | 168 | // Boucle sur les sampleNum
|
---|
[1467] | 169 | int knext;
|
---|
| 170 | int kfin = sne-snb;
|
---|
| 171 | for(k=0;k<=kfin;k++) {
|
---|
[1442] | 172 | totnscount++;
|
---|
[1443] | 173 | // if (k%10000 == 0) cout << " DBG: K=" << k << endl;
|
---|
[1467] | 174 | knext = k+wsz2;
|
---|
[1442] | 175 | // Calcul mean-sigma
|
---|
[1467] | 176 | if (knext<=kfin) {
|
---|
[1478] | 177 | valsub = vas(knext%wsize);
|
---|
[1467] | 178 | getData(0, knext+snb, vin(knext%wsize), vfg(knext%wsize));
|
---|
| 179 | valadd = vin(knext%wsize);
|
---|
[1478] | 180 | if ( vfg(knext%wsize) ||
|
---|
| 181 | (valadd < range_min) || (valadd > range_max) ) {
|
---|
| 182 | vas(knext%wsize) = valadd = mean;
|
---|
[1467] | 183 | fgokcur = false;
|
---|
| 184 | }
|
---|
[1478] | 185 | else {
|
---|
| 186 | vas(knext%wsize) = valadd = vin(knext%wsize);
|
---|
| 187 | fgokcur = true;
|
---|
| 188 | }
|
---|
[1467] | 189 | if (!fgokdebut && fgokcur) {
|
---|
| 190 | s += valadd;
|
---|
| 191 | s2 += valadd*valadd;
|
---|
| 192 | nokdebut++;
|
---|
| 193 | mean = s/nokdebut;
|
---|
| 194 | if (nokdebut > 1) sigma = sqrt(s2/nokdebut-mean*mean);
|
---|
| 195 | if (nokdebut >= wsize) {
|
---|
| 196 | fgokdebut = true;
|
---|
| 197 | cout << " SimpleDeglitcher::DebugInfo - nokdebut=" << nokdebut
|
---|
| 198 | << " k=" << k << " knext=" << knext
|
---|
| 199 | << "\n ...DebugInfo mean=" << mean
|
---|
| 200 | << " sigma=" << sigma << " s=" << s << " s2=" << s2 << endl;
|
---|
| 201 | }
|
---|
| 202 | }
|
---|
| 203 | else {
|
---|
[1484] | 204 | if (sx_refresh_count >= sx_refresh_count_max) {
|
---|
| 205 | // On recalcule la somme
|
---|
| 206 | s = vas.Sum();
|
---|
| 207 | s2 = vas.SumX2();
|
---|
| 208 | sx_refresh_count = 0;
|
---|
| 209 | }
|
---|
| 210 | else {
|
---|
| 211 | s += (valadd-valsub);
|
---|
| 212 | s2 += (valadd*valadd-valsub*valsub);
|
---|
| 213 | sx_refresh_count++;
|
---|
| 214 | }
|
---|
[1467] | 215 | mean = s/wsize;
|
---|
| 216 | sigma = sqrt(s2/wsize-mean*mean);
|
---|
| 217 | }
|
---|
[1442] | 218 | }
|
---|
| 219 |
|
---|
[1467] | 220 |
|
---|
[1442] | 221 | // On gere les sorties Mean et Sigma
|
---|
| 222 | if (fgmean)
|
---|
| 223 | putData(1, k+snb, mean, 0);
|
---|
| 224 | if (fgsigma)
|
---|
| 225 | putData(2, k+snb, sigma, 0);
|
---|
[1454] | 226 | if (fgincopie)
|
---|
| 227 | putData(3, k+snb, vin(k%wsize), vfg(k%wsize));
|
---|
[1442] | 228 |
|
---|
[1478] | 229 | valcur = vin(k%wsize);
|
---|
[1454] | 230 | if ( (valcur < range_min) || (valcur > range_max) ) {
|
---|
[1478] | 231 | valcur = (rec_use_wrec) ? vrec.Sum()/wrecsize : mean;
|
---|
| 232 | if (rec_out_range_samples) vin(k%wsize) = valcur;
|
---|
| 233 | vfg(k%wsize) |= FG_OUTOFRANGE;
|
---|
[1454] | 234 | out_range_nscount++;
|
---|
| 235 | }
|
---|
[1467] | 236 | valcur = vin(k%wsize);
|
---|
| 237 | fgcur = vfg(k%wsize);
|
---|
[1443] | 238 |
|
---|
[1442] | 239 | if (!fgout) continue; // Pas de sortie out (deglitche)
|
---|
| 240 |
|
---|
[1443] | 241 |
|
---|
| 242 | // if (k<100) {
|
---|
| 243 | // cout << "DBG-A-Deglitch[" << k << "] mean="
|
---|
| 244 | // << mean << " sigma=" << sigma << " valcur="
|
---|
| 245 | // << valcur << " Kgl=" << kgl ;
|
---|
| 246 | // if (fgglitch) cout << " In Glitch" ;
|
---|
| 247 | // cout << endl;
|
---|
| 248 | // }
|
---|
[1442] | 249 |
|
---|
[1478] | 250 | double curnsig = (fgglitch) ? nsig2 : nsig;
|
---|
[1467] | 251 |
|
---|
| 252 | if (valcur < mean+curnsig*sigma) { // inferieur au seuil
|
---|
[1442] | 253 | if (fgglitch) {
|
---|
[1479] | 254 | if ( (k-kgl <= maxpoints) && (k-kgl >= minpoints) ) {
|
---|
| 255 | // On vient de detecter un glitch
|
---|
[1442] | 256 | glcount++;
|
---|
[1478] | 257 | if (rec_gl_samples) { // On change la valeur des samples
|
---|
| 258 | double recval = (rec_use_wrec) ? vrec.Sum()/wrecsize : mean;
|
---|
| 259 | for(ii=kgl; ii<k; ii++) {
|
---|
| 260 | putData(0, ii+snb, recval, vfg(ii%wsize)|FG_GLITCH);
|
---|
| 261 | glnscount++;
|
---|
| 262 | }
|
---|
[1442] | 263 | }
|
---|
[1478] | 264 | else { // On ne fait que flagger les echantillons
|
---|
| 265 | for(ii=kgl; ii<k; ii++) {
|
---|
| 266 | putData(0, ii+snb, vin(ii%wsize), vfg(ii%wsize)|FG_GLITCH);
|
---|
| 267 | glnscount++;
|
---|
| 268 | }
|
---|
| 269 | }
|
---|
[1442] | 270 | lastput = snb+k-1;
|
---|
[1478] | 271 | } // - Fin de detection de glitch
|
---|
[1479] | 272 | else { // Trop long ou trop court - ce n'est pas un glitch ...
|
---|
[1442] | 273 | for(ii=kgl; ii<k; ii++) {
|
---|
[1454] | 274 | putData(0, ii+snb, vin(ii%wsize), vfg(ii%wsize));
|
---|
[1442] | 275 | }
|
---|
| 276 | lastput = snb+k-1;
|
---|
| 277 | }
|
---|
| 278 | }
|
---|
[1478] | 279 | putData(0, k+snb, vin(k%wsize), vfg(k%wsize));
|
---|
[1442] | 280 | lastput = snb+k;
|
---|
| 281 | kgl = -1; fgglitch = false;
|
---|
[1478] | 282 | vrec(k%wrecsize) = lastvalok = valcur;
|
---|
[1442] | 283 | }
|
---|
| 284 | else { // Superieur au seuil
|
---|
| 285 | if (fgglitch) {
|
---|
[1479] | 286 | if (k-kgl+1 > maxpoints) { // serie de points > seuil
|
---|
[1442] | 287 | for(ii=kgl; ii<=k; ii++) // -> Donc pas glitch
|
---|
[1454] | 288 | putData(0, ii+snb, vin(ii%wsize), vfg(ii%wsize));
|
---|
[1442] | 289 | lastput = snb+k;
|
---|
| 290 | fgglitch = false;
|
---|
[1478] | 291 | vrec(k%wrecsize) = lastvalok = valcur;
|
---|
[1442] | 292 | }
|
---|
| 293 | }
|
---|
| 294 | else {
|
---|
| 295 | if (kgl < 0) { // debut possible de glitch
|
---|
| 296 | fgglitch = true; kgl = k;
|
---|
| 297 | }
|
---|
| 298 | else { // On est toujours dans une serie > seuil
|
---|
[1478] | 299 | putData(0, k+snb, vin(k%wsize), vfg(k%wsize));
|
---|
| 300 | lastput = snb+k; lastvalok = valcur;
|
---|
[1442] | 301 | }
|
---|
[1478] | 302 | vrec(k%wrecsize) = lastvalok;
|
---|
[1442] | 303 | }
|
---|
| 304 | }
|
---|
| 305 |
|
---|
[1443] | 306 | // if (k%5000 == 0) cout << " ---DBG2: K=" << k << " glcount="
|
---|
| 307 | // << glcount << " LastPut= " << lastput << endl;
|
---|
| 308 | } // Fin de Boucle sur les num-sample
|
---|
| 309 |
|
---|
| 310 | //DBG cout << " La fin lastput=" << lastput << " SNE=" << sne;
|
---|
| 311 | //DBG for(k=lastput-snb+1; k<sne-snb; k++)
|
---|
| 312 | //DBG putData(0, k+snb, vin(k%wsize), 0);
|
---|
| 313 | // cout << " DBG3- OUT of try bloc ! " << endl;
|
---|
| 314 | cout << " SimpleDeglitcher::run() - End of processing "
|
---|
[1454] | 315 | << " ProcessedSampleCount=" << ProcessedSampleCount()
|
---|
[1443] | 316 | << " GlitchCount= " << GlitchCount() << endl;
|
---|
| 317 | if (fgout) deglitchdone = true;
|
---|
[1442] | 318 | } // Bloc try
|
---|
| 319 | catch (PException & exc) {
|
---|
| 320 | cerr << "SimpleDeglitcher: Catched Exception " << (string)typeid(exc).name()
|
---|
| 321 | << "\n .... Msg= " << exc.Msg() << endl;
|
---|
| 322 | }
|
---|
| 323 | }
|
---|
| 324 |
|
---|
| 325 |
|
---|
[1454] | 326 | // -------------------------------------------------------------------
|
---|
| 327 | // Classe SimpleFilter : Filtre simple ds le domaine temporel
|
---|
| 328 | // -------------------------------------------------------------------
|
---|
[1442] | 329 |
|
---|
[1454] | 330 | string SimpleFilter::FilterKind2String(FilterKind fk)
|
---|
| 331 | {
|
---|
| 332 | switch (fk) {
|
---|
| 333 | case UserFilter :
|
---|
| 334 | return ("UserFilter");
|
---|
| 335 | break;
|
---|
| 336 | case MeanFilter :
|
---|
| 337 | return ("MeanFilter");
|
---|
| 338 | break;
|
---|
| 339 | case SumFilter :
|
---|
| 340 | return ("SumFilter");
|
---|
| 341 | break;
|
---|
| 342 | case GaussFilter :
|
---|
| 343 | return ("GaussFilter");
|
---|
| 344 | break;
|
---|
| 345 | case DiffFilter :
|
---|
| 346 | return ("DiffFilter");
|
---|
| 347 | break;
|
---|
| 348 | default :
|
---|
| 349 | return ("ErrorFilterKind");
|
---|
| 350 | break;
|
---|
| 351 | }
|
---|
| 352 | return("");
|
---|
| 353 | }
|
---|
| 354 |
|
---|
[1442] | 355 | SimpleFilter::SimpleFilter(int wsz, FilterKind fk, double a, double s)
|
---|
| 356 | {
|
---|
| 357 | if (wsz < 3) wsz = 3;
|
---|
| 358 | if (wsz%2 == 0) wsz++;
|
---|
| 359 | cout << "SimpleFilter::SimpleFilter() wsz= " << wsz
|
---|
[1454] | 360 | << " FilterKind=" << FilterKind2String(fk) << endl;
|
---|
[1442] | 361 | wsize = wsz;
|
---|
| 362 | totnscount = 0;
|
---|
| 363 | coef = new double[wsz];
|
---|
[1467] | 364 | for(int k=0; k<wsz; k++) coef[k] = 0.;
|
---|
[1476] | 365 | int kk;
|
---|
[1454] | 366 | switch (fk) {
|
---|
| 367 | case UserFilter :
|
---|
| 368 | throw ParmError("SimpleFilter: Error in filter Kind (UserFilter)!");
|
---|
[1467] | 369 | // break;
|
---|
[1454] | 370 | case MeanFilter :
|
---|
[1476] | 371 | for(kk=0; kk<wsz; kk++)
|
---|
[1454] | 372 | coef[kk] = a/wsize;
|
---|
| 373 | break;
|
---|
| 374 | case SumFilter :
|
---|
[1476] | 375 | for(kk=0; kk<wsz; kk++)
|
---|
[1454] | 376 | coef[kk] = a;
|
---|
| 377 | break;
|
---|
| 378 | case GaussFilter :
|
---|
[1476] | 379 | for(kk=-(wsz/2); kk<=(wsz/2); kk++)
|
---|
[1531] | 380 | coef[kk+(wsz/2)] = a*exp(-(double)(kk*kk)/(2*s*s));
|
---|
[1454] | 381 | break;
|
---|
| 382 | case DiffFilter :
|
---|
[1476] | 383 | for(kk=0; kk<wsz; kk++)
|
---|
[1454] | 384 | coef[kk] = -a/wsize;
|
---|
| 385 | coef[wsz/2+1] += 1.;
|
---|
| 386 | break;
|
---|
| 387 | default :
|
---|
| 388 | throw ParmError("SimpleFilter: Error in filter Kind (UnknownFilter)!");
|
---|
[1467] | 389 | // break;
|
---|
[1454] | 390 | }
|
---|
[1442] | 391 | }
|
---|
| 392 |
|
---|
[1454] | 393 | SimpleFilter::SimpleFilter(Vector const & vc)
|
---|
| 394 | {
|
---|
| 395 | int wsz = vc.Size();
|
---|
| 396 | if (wsz < 3) wsz = 3;
|
---|
| 397 | if (wsz%2 == 0) wsz++;
|
---|
| 398 | FilterKind fk = UserFilter;
|
---|
| 399 | cout << "SimpleFilter::SimpleFilter(Vector & vc) vc.Size()= "
|
---|
| 400 | << vc.Size() << " WSize=" << wsz
|
---|
| 401 | << " FilterKind=" << FilterKind2String(fk) << endl;
|
---|
| 402 | wsize = wsz;
|
---|
| 403 | totnscount = 0;
|
---|
| 404 | coef = new double[wsz];
|
---|
[1476] | 405 | int kk;
|
---|
| 406 | for(kk=0; kk<vc.Size(); kk++)
|
---|
[1454] | 407 | coef[kk] = vc(kk);
|
---|
[1476] | 408 | for(kk=vc.Size(); kk<wsz; kk++)
|
---|
[1454] | 409 | coef[kk] = 0.;
|
---|
| 410 | }
|
---|
| 411 |
|
---|
[1442] | 412 | SimpleFilter::~SimpleFilter()
|
---|
| 413 | {
|
---|
| 414 | delete[] coef;
|
---|
| 415 | }
|
---|
| 416 |
|
---|
[1443] | 417 | void SimpleFilter::PrintStatus(ostream & os)
|
---|
| 418 | {
|
---|
| 419 | os << "\n ------------------------------------------------------ \n"
|
---|
| 420 | << " SimpleFilter::PrintStatus() - WindowSize=" << WSize()
|
---|
| 421 | << " FilterKind= " << Type() << endl;
|
---|
| 422 | TOIProcessor::PrintStatus(os);
|
---|
| 423 | os << " Coeff= " ;
|
---|
| 424 | for(int k=0; k<wsize; k++) os << coef[k] << " " ;
|
---|
| 425 | os << endl;
|
---|
[1454] | 426 | os << " ProcessedSampleCount=" << ProcessedSampleCount() << endl;
|
---|
[1443] | 427 | os << " ------------------------------------------------------ " << endl;
|
---|
| 428 | }
|
---|
| 429 |
|
---|
[1442] | 430 | void SimpleFilter::init() {
|
---|
| 431 | cout << "SimpleFilter::init" << endl;
|
---|
| 432 | declareInput("in");
|
---|
| 433 | declareOutput("out");
|
---|
[1443] | 434 | declareOutput("incopie");
|
---|
[1442] | 435 | name = "SimpleFilter";
|
---|
| 436 | // upExtra = 1;
|
---|
| 437 | }
|
---|
| 438 |
|
---|
| 439 | void SimpleFilter::run() {
|
---|
| 440 | // TOIManager* mgr = TOIManager::getManager();
|
---|
| 441 | int snb = getMinIn();
|
---|
| 442 | int sne = getMaxIn();
|
---|
| 443 |
|
---|
| 444 | bool fgout = checkOutputTOIIndex(0);
|
---|
[1443] | 445 | bool fgincopie = checkOutputTOIIndex(1);
|
---|
[1442] | 446 |
|
---|
| 447 | if (!checkInputTOIIndex(0)) {
|
---|
| 448 | cerr << " SimpleFilter::run() - Input TOI (in) not connected! "
|
---|
| 449 | << endl;
|
---|
| 450 | throw ParmError("SimpleFilter::run() Input TOI (in) not connected!");
|
---|
| 451 | }
|
---|
| 452 | if (!fgout) {
|
---|
| 453 | cerr << " SimpleFilter::run() - No Output TOI connected! "
|
---|
| 454 | << endl;
|
---|
| 455 | throw ParmError("SimpleFilter::run() No output TOI connected!");
|
---|
| 456 | }
|
---|
[1443] | 457 |
|
---|
| 458 | cout << " SimpleFilter::run() SNRange=" << snb << " - " << sne << endl;
|
---|
[1442] | 459 |
|
---|
| 460 |
|
---|
| 461 | try {
|
---|
[1443] | 462 | Timer tm("SimpleFilter::run()");
|
---|
[1442] | 463 | // Le debut
|
---|
| 464 | int wsz2 = wsize/2;
|
---|
| 465 | Vector vin(wsize);
|
---|
[1532] | 466 | TVector<uint_8> vfg(wsize);
|
---|
[1442] | 467 | int k;
|
---|
[1464] | 468 | for(k=0; k<wsize; k++)
|
---|
| 469 | getData(0, k+snb, vin(k%wsize), vfg(k%wsize));
|
---|
| 470 |
|
---|
[1442] | 471 | double mean = vin.Sum()/wsize;
|
---|
[1454] | 472 | for(k=wsz2+1; k<wsize; k++) {
|
---|
| 473 | vin(k) = mean;
|
---|
| 474 | vfg(k) = 0;
|
---|
| 475 | }
|
---|
| 476 | int knext;
|
---|
| 477 | bool fgfin = false;
|
---|
| 478 | // Boucle sur les sampleNum
|
---|
[1443] | 479 | for(k=0;k<=sne-snb;k++) {
|
---|
[1442] | 480 | double sortie = 0;
|
---|
[1467] | 481 | for(int ii=-wsz2; ii<=wsz2; ii++) {
|
---|
| 482 | sortie += vin((ii+k+wsize)%wsize)*coef[ii+wsz2];
|
---|
[1442] | 483 | }
|
---|
[1454] | 484 | putData(0,k+snb,sortie,vfg(k%wsize));
|
---|
| 485 | if (fgincopie)
|
---|
| 486 | putData(1, k+snb, vin(k%wsize), vfg(k%wsize));
|
---|
| 487 | knext = k+wsz2+1;
|
---|
[1464] | 488 | if (knext<=(sne-snb))
|
---|
| 489 | getData(0, knext+snb, vin(knext%wsize), vfg(knext%wsize));
|
---|
| 490 |
|
---|
[1454] | 491 | else {
|
---|
| 492 | if (!fgfin) {
|
---|
| 493 | mean = vin.Sum()/wsize;
|
---|
| 494 | fgfin = true;
|
---|
| 495 | }
|
---|
| 496 | vin(knext%wsize) = mean;
|
---|
| 497 | vfg(knext%wsize) = 0;
|
---|
| 498 | }
|
---|
| 499 | totnscount++;
|
---|
[1442] | 500 | } // Boucle sur les num-sample
|
---|
[1443] | 501 | cout << " SimpleFilter::run() - End of processing " << endl;
|
---|
[1442] | 502 | } // Bloc try
|
---|
| 503 |
|
---|
| 504 | catch (PException & exc) {
|
---|
| 505 | cerr << "SimpleFilter: Catched Exception " << (string)typeid(exc).name()
|
---|
| 506 | << "\n .... Msg= " << exc.Msg() << endl;
|
---|
| 507 | }
|
---|
[1454] | 508 | }
|
---|
[1442] | 509 |
|
---|
[1454] | 510 | // ---------------------------------------------------------------
|
---|
| 511 | // -------------------- Classe SimpleAdder -----------------------
|
---|
| 512 | // ---------------------------------------------------------------
|
---|
[1442] | 513 |
|
---|
[1454] | 514 | SimpleAdder::SimpleAdder(int nbinput)
|
---|
| 515 | : gains(nbinput)
|
---|
| 516 | {
|
---|
| 517 | if (nbinput < 1)
|
---|
| 518 | throw ParmError("SimpleAdder::SimpleAdder() NbInput < 1 !");
|
---|
| 519 | nb_input = nbinput;
|
---|
| 520 | for(int k=0; k<nb_input; k++) gains(k) = 1.;
|
---|
| 521 | totnscount = 0;
|
---|
[1442] | 522 | }
|
---|
[1454] | 523 |
|
---|
| 524 | SimpleAdder::~SimpleAdder()
|
---|
| 525 | {
|
---|
| 526 | }
|
---|
| 527 |
|
---|
| 528 | void SimpleAdder::SetGain(int num, double g)
|
---|
| 529 | {
|
---|
| 530 | if ((num < 0) || (num >= nb_input))
|
---|
| 531 | throw RangeCheckError("SimpleAdder::SetGain() Out of range input number!");
|
---|
| 532 | gains(num) = g;
|
---|
| 533 | return;
|
---|
| 534 | }
|
---|
| 535 |
|
---|
| 536 | double SimpleAdder::Gain(int num)
|
---|
| 537 | {
|
---|
| 538 | if ((num < 0) || (num >= nb_input))
|
---|
| 539 | throw RangeCheckError("SimpleAdder::Gain() Out of range input number!");
|
---|
| 540 | return gains(num);
|
---|
| 541 | }
|
---|
| 542 |
|
---|
| 543 | void SimpleAdder::PrintStatus(ostream & os)
|
---|
| 544 | {
|
---|
| 545 | os << "\n ------------------------------------------------------ \n"
|
---|
| 546 | << " SimpleAdder::PrintStatus() - NbInput=" << NbInput() << endl;
|
---|
| 547 | TOIProcessor::PrintStatus(os);
|
---|
| 548 | os << " Gains= " ;
|
---|
| 549 | for(int k=0; k<nb_input; k++) os << gains(k) << " " ;
|
---|
| 550 | os << endl;
|
---|
| 551 | os << " ProcessedSampleCount=" << ProcessedSampleCount() << endl;
|
---|
| 552 | os << " ------------------------------------------------------ " << endl;
|
---|
| 553 | }
|
---|
| 554 |
|
---|
| 555 | void SimpleAdder::init() {
|
---|
| 556 | cout << "SimpleAdder::init NbInput=" << nb_input << endl;
|
---|
| 557 | char buff[32];
|
---|
| 558 | for(int k=0; k<nb_input; k++) {
|
---|
| 559 | sprintf(buff,"in%d", k);
|
---|
| 560 | declareInput(buff);
|
---|
| 561 | }
|
---|
| 562 |
|
---|
| 563 | declareOutput("out");
|
---|
| 564 | name = "SimpleAdder";
|
---|
| 565 | // upExtra = 1;
|
---|
| 566 | }
|
---|
| 567 |
|
---|
| 568 | void SimpleAdder::run() {
|
---|
| 569 | // TOIManager* mgr = TOIManager::getManager();
|
---|
| 570 | int snb = getMinIn();
|
---|
| 571 | int sne = getMaxIn();
|
---|
| 572 |
|
---|
| 573 | bool fgout = checkOutputTOIIndex(0);
|
---|
| 574 | string msg_err;
|
---|
| 575 | for(int ki=0;ki<nb_input;ki++) {
|
---|
| 576 | if (!checkInputTOIIndex(ki)) {
|
---|
| 577 | msg_err = "SimpleAdder::run() - Input TOI (" + getInName(ki) +
|
---|
| 578 | " not connected!";
|
---|
| 579 | cerr << msg_err << endl;
|
---|
| 580 | throw ParmError(msg_err);
|
---|
| 581 | }
|
---|
| 582 | }
|
---|
| 583 | if (!fgout) {
|
---|
| 584 | cerr << " SimpleAdder::run() - No Output TOI connected! "
|
---|
| 585 | << endl;
|
---|
| 586 | throw ParmError("SimpleAdder::run() No output TOI connected!");
|
---|
| 587 | }
|
---|
| 588 |
|
---|
| 589 | cout << " SimpleAdder::run() SNRange=" << snb << " - " << sne << endl;
|
---|
| 590 |
|
---|
| 591 |
|
---|
| 592 | try {
|
---|
| 593 | Timer tm("SimpleAdder::run()");
|
---|
| 594 | int k,i;
|
---|
| 595 | double out = 0.;
|
---|
[1464] | 596 | double valin = 0.;
|
---|
[1532] | 597 | uint_8 fgin = 0;
|
---|
| 598 | uint_8 fgout = 0;
|
---|
[1454] | 599 | for(k=snb;k<=sne;k++) {
|
---|
| 600 | out = 0;
|
---|
| 601 | fgout = 0;
|
---|
| 602 | for(i=0; i<nb_input; i++) {
|
---|
[1464] | 603 | getData(i, k, valin, fgin);
|
---|
| 604 | out += gains(i)*valin;
|
---|
| 605 | fgout = fgout | fgin;
|
---|
[1454] | 606 | }
|
---|
| 607 | putData(0,k,out,fgout);
|
---|
| 608 | totnscount++;
|
---|
| 609 | } // Boucle sur les num-sample
|
---|
| 610 | cout << " SimpleAdder::run() - End of processing " << endl;
|
---|
| 611 | } // Bloc try
|
---|
| 612 |
|
---|
| 613 | catch (PException & exc) {
|
---|
| 614 | cerr << "SimpleAdder: Catched Exception " << (string)typeid(exc).name()
|
---|
| 615 | << "\n .... Msg= " << exc.Msg() << endl;
|
---|
| 616 | }
|
---|
| 617 | }
|
---|
| 618 |
|
---|
[1479] | 619 | // ----------------------------------------------------------------------
|
---|
| 620 | // Classe SimpleFourierFilter : Filtre simple ds le domaine de Fourier
|
---|
| 621 | // ----------------------------------------------------------------------
|
---|
[1454] | 622 |
|
---|
[1479] | 623 | SimpleFourierFilter::SimpleFourierFilter(Vector const & vc)
|
---|
| 624 | {
|
---|
| 625 | ffcoef = vc;
|
---|
| 626 | wsize = (ffcoef.Size()-1)*2;
|
---|
| 627 | if (wsize < 16)
|
---|
| 628 | throw ParmError("SimpleFourierFilter::SimpleFourierFilter() WSize<16 !");
|
---|
[1483] | 629 | KeepSpectra("spectra.ppf", 0);
|
---|
[1484] | 630 | ComputeMeanSpectra(false);
|
---|
| 631 | totnscount = 0;
|
---|
| 632 | totnbblock = 0;
|
---|
[1479] | 633 | }
|
---|
| 634 |
|
---|
| 635 | SimpleFourierFilter::~SimpleFourierFilter()
|
---|
| 636 | {
|
---|
| 637 | }
|
---|
| 638 |
|
---|
| 639 |
|
---|
| 640 | void SimpleFourierFilter::PrintStatus(ostream & os)
|
---|
| 641 | {
|
---|
| 642 | os << "\n ------------------------------------------------------ \n"
|
---|
| 643 | << " SimpleFourierFilter::PrintStatus() - WindowSize="
|
---|
| 644 | << WSize() << endl;
|
---|
| 645 | TOIProcessor::PrintStatus(os);
|
---|
[1484] | 646 | os << " Coeff (Size= " << ffcoef.Size() << "): " << endl;
|
---|
| 647 | for(int i=0; i<16; i++) {
|
---|
| 648 | os << ffcoef(i) << " " ;
|
---|
| 649 | if (i == 7) os << endl;
|
---|
| 650 | }
|
---|
| 651 | os << " .... " << endl;
|
---|
| 652 | os << " ProcessedSampleCount=" << ProcessedSampleCount()
|
---|
| 653 | << " NbFFTBlocks= " << totnbblock << endl;
|
---|
[1479] | 654 | os << " ------------------------------------------------------ " << endl;
|
---|
| 655 | }
|
---|
| 656 |
|
---|
| 657 | void SimpleFourierFilter::init() {
|
---|
| 658 | cout << "SimpleFourierFFilter::init" << endl;
|
---|
| 659 | declareInput("in");
|
---|
| 660 | declareOutput("out");
|
---|
| 661 | declareOutput("incopie");
|
---|
| 662 | name = "SimpleFourierFilter";
|
---|
| 663 | // upExtra = 1;
|
---|
| 664 | }
|
---|
| 665 |
|
---|
| 666 |
|
---|
| 667 | void SimpleFourierFilter::run() {
|
---|
| 668 | // TOIManager* mgr = TOIManager::getManager();
|
---|
| 669 | int snb = getMinIn();
|
---|
| 670 | int sne = getMaxIn();
|
---|
| 671 |
|
---|
| 672 | bool fgout = checkOutputTOIIndex(0);
|
---|
| 673 | bool fgincopie = checkOutputTOIIndex(1);
|
---|
| 674 |
|
---|
| 675 | if (!checkInputTOIIndex(0)) {
|
---|
| 676 | cerr << " SimpleFourierFilter::run() - Input TOI (in) not connected! "
|
---|
| 677 | << endl;
|
---|
| 678 | throw ParmError("SimpleFourierFilter::run() Input TOI (in) not connected!");
|
---|
| 679 | }
|
---|
| 680 |
|
---|
[1484] | 681 | // ---- On peut utiliser cette classe pour calculer un spectre de Fourier ----
|
---|
| 682 | // if (!fgout) {
|
---|
| 683 | // cerr << " SimpleFourierFilter::run() - No Output TOI connected! "
|
---|
| 684 | // << endl;
|
---|
| 685 | // throw ParmError("SimpleFourierFilter::run() No output TOI connected!");
|
---|
| 686 | // }
|
---|
| 687 |
|
---|
[1479] | 688 | cout << " SimpleFourierFilter::run() SNRange=" << snb << " - " << sne << endl;
|
---|
| 689 |
|
---|
| 690 |
|
---|
| 691 | try {
|
---|
| 692 | Timer tm("SimpleFourierFilter::run()");
|
---|
| 693 | // Le debut
|
---|
| 694 | Vector vin(wsize);
|
---|
| 695 | Vector vout(wsize);
|
---|
[1532] | 696 | TVector<uint_8> vfg(wsize);
|
---|
[1483] | 697 | TVector< complex<r_8> > vfft, vfftmean;
|
---|
[1484] | 698 | Vector meanpowerspectra;
|
---|
[1479] | 699 | TVector< complex<r_8> > zcoef(ffcoef.Size());
|
---|
| 700 | zcoef = ffcoef;
|
---|
| 701 |
|
---|
| 702 |
|
---|
| 703 | FFTPackServer ffts;
|
---|
| 704 | ffts.setNormalize(true);
|
---|
| 705 |
|
---|
[1483] | 706 | POutPersist pout(outppfname);
|
---|
| 707 |
|
---|
[1479] | 708 | int k,i,klast;
|
---|
| 709 | int nks = 0;
|
---|
| 710 | klast = snb-1;
|
---|
[1484] | 711 | totnbblock = 0;
|
---|
[1483] | 712 | // Boucle sur les sampleNum
|
---|
[1479] | 713 | // 1er partie, on traite par paquets de wsize
|
---|
| 714 | for(k=snb;k<=sne-wsize+1;k+=wsize) {
|
---|
| 715 | for(i=0; i<wsize; i++)
|
---|
| 716 | getData(0, k+i, vin(i), vfg(i));
|
---|
| 717 | ffts.FFTForward(vin, vfft);
|
---|
[1484] | 718 | if (c_meanspectra) { // Compute mean-spectra
|
---|
| 719 | if (totnbblock == 0) {
|
---|
| 720 | vfftmean = vfft;
|
---|
| 721 | meanpowerspectra.ReSize(vfft.Size());
|
---|
| 722 | for(i=0; i<meanpowerspectra.Size(); i++)
|
---|
| 723 | meanpowerspectra(i) = sqrt(vfft(i).real()*vfft(i).real() +
|
---|
| 724 | vfft(i).imag()*vfft(i).imag() );
|
---|
| 725 | }
|
---|
| 726 | else {
|
---|
| 727 | vfftmean += vfft;
|
---|
| 728 | for(i=0; i<meanpowerspectra.Size(); i++)
|
---|
| 729 | meanpowerspectra(i) += sqrt(vfft(i).real()*vfft(i).real() +
|
---|
| 730 | vfft(i).imag()*vfft(i).imag() );
|
---|
| 731 | }
|
---|
| 732 | }
|
---|
| 733 | totnbblock++;
|
---|
[1479] | 734 | if (nks < nb_keep) {
|
---|
[1483] | 735 | TVector< complex<r_8> > vfftcopie;
|
---|
| 736 | vfftcopie = vfft;
|
---|
[1484] | 737 | string nomvfft = "spectra" + (string)MuTyV(nks);
|
---|
[1483] | 738 | pout.PutObject(vfftcopie, nomvfft);
|
---|
[1479] | 739 | nks++;
|
---|
| 740 | }
|
---|
[1484] | 741 | if (fgout) {
|
---|
| 742 | vfft.MulElt(zcoef);
|
---|
| 743 | ffts.FFTBackward(vfft, vout);
|
---|
| 744 | }
|
---|
| 745 | for(i=0; i<wsize; i++) {
|
---|
| 746 | if (fgout)
|
---|
| 747 | putData(0,k+i,vout(i),vfg(i));
|
---|
| 748 | if (fgincopie)
|
---|
[1479] | 749 | putData(1, k+i, vin(i), vfg(i));
|
---|
[1484] | 750 | }
|
---|
[1479] | 751 | klast+=wsize;
|
---|
| 752 | totnscount+=wsize;
|
---|
| 753 | }
|
---|
| 754 |
|
---|
| 755 |
|
---|
| 756 | // 2eme partie, on traite la fin du bloc d'echantillons si necessaire
|
---|
| 757 | double inval;
|
---|
[1532] | 758 | uint_8 inflg;
|
---|
[1479] | 759 | if (klast < sne)
|
---|
| 760 | for(k=klast+1; k<=sne; k++) {
|
---|
| 761 | getData(0, k, inval, inflg);
|
---|
[1484] | 762 | if (fgout) putData(0, k, inval, inflg);
|
---|
[1479] | 763 | if (fgincopie)
|
---|
| 764 | putData(1, k, inval, inflg);
|
---|
| 765 | totnscount++;
|
---|
| 766 | }
|
---|
[1483] | 767 |
|
---|
[1484] | 768 | if (c_meanspectra) {
|
---|
| 769 | vfftmean /= complex<r_8>((r_8)totnbblock, 0.);
|
---|
| 770 | pout.PutObject(vfftmean, "meanspectra");
|
---|
| 771 | meanpowerspectra /= (r_8)totnbblock;
|
---|
| 772 | pout.PutObject(vfftmean, "meanpowerspectra");
|
---|
| 773 | }
|
---|
| 774 | pout.PutObject(ffcoef, "fourierfilter");
|
---|
[1483] | 775 |
|
---|
[1484] | 776 | cout << " SimpleFourierFilter::run() - End of processing "
|
---|
| 777 | << " NbFFTBlocks= " << totnbblock << endl;
|
---|
[1479] | 778 | } // Bloc try
|
---|
| 779 |
|
---|
| 780 | catch (PException & exc) {
|
---|
| 781 | cerr << "SimpleFourierFilter: Catched Exception " << (string)typeid(exc).name()
|
---|
| 782 | << "\n .... Msg= " << exc.Msg() << endl;
|
---|
| 783 | }
|
---|
| 784 | }
|
---|
| 785 |
|
---|
[1467] | 786 | // ---------------------------------------------------------------
|
---|
| 787 | // -------------------- Classe SimpleFanOut -----------------------
|
---|
| 788 | // ---------------------------------------------------------------
|
---|
[1454] | 789 |
|
---|
[1467] | 790 | SimpleFanOut::SimpleFanOut(int nbinput, int mfanout)
|
---|
| 791 | {
|
---|
| 792 | if (nbinput < 1)
|
---|
| 793 | throw ParmError("SimpleFanOut::SimpleFanOut() NbInput < 1 !");
|
---|
| 794 | if (mfanout < 1)
|
---|
| 795 | throw ParmError("SimpleFanOut::SimpleFanOut() M_FanOut < 1 !");
|
---|
| 796 |
|
---|
| 797 | nb_input = nbinput;
|
---|
| 798 | m_fanout = mfanout;
|
---|
| 799 | totnscount = 0;
|
---|
| 800 | }
|
---|
| 801 |
|
---|
| 802 | SimpleFanOut::~SimpleFanOut()
|
---|
| 803 | {
|
---|
| 804 | }
|
---|
| 805 |
|
---|
| 806 |
|
---|
| 807 | void SimpleFanOut::PrintStatus(ostream & os)
|
---|
| 808 | {
|
---|
| 809 | os << "\n ------------------------------------------------------ \n"
|
---|
| 810 | << " SimpleFanOut::PrintStatus() - NbInput=" << NbInput()
|
---|
| 811 | << " M_FanOut=" << MFanOut() << endl;
|
---|
| 812 | TOIProcessor::PrintStatus(os);
|
---|
| 813 | os << endl;
|
---|
| 814 | os << " ProcessedSampleCount=" << ProcessedSampleCount() << endl;
|
---|
| 815 | os << " ------------------------------------------------------ " << endl;
|
---|
| 816 | }
|
---|
| 817 |
|
---|
| 818 | void SimpleFanOut::init() {
|
---|
| 819 | cout << "SimpleFanOut::init NbInput=" << nb_input << endl;
|
---|
| 820 | char buff[64];
|
---|
| 821 | for(int k=0; k<nb_input; k++) {
|
---|
| 822 | sprintf(buff,"in%d", k);
|
---|
| 823 | declareInput(buff);
|
---|
| 824 | for(int j=0; j<m_fanout; j++) {
|
---|
| 825 | sprintf(buff,"out%d_%d", k, j);
|
---|
| 826 | declareOutput(buff);
|
---|
| 827 | }
|
---|
| 828 | }
|
---|
| 829 |
|
---|
| 830 | name = "SimpleFanOut";
|
---|
| 831 | // upExtra = 1;
|
---|
| 832 | }
|
---|
| 833 |
|
---|
| 834 | void SimpleFanOut::run() {
|
---|
| 835 | // TOIManager* mgr = TOIManager::getManager();
|
---|
| 836 | int snb = getMinIn();
|
---|
| 837 | int sne = getMaxIn();
|
---|
| 838 |
|
---|
| 839 | TVector<int_4> in_index(nb_input);
|
---|
| 840 | TMatrix<int_4> out_index(nb_input, m_fanout);
|
---|
| 841 | in_index = -1;
|
---|
| 842 | out_index = -1;
|
---|
| 843 | int nbconin = 0;
|
---|
| 844 | char buff[64];
|
---|
| 845 | for(int ki=0;ki<nb_input;ki++) {
|
---|
| 846 | sprintf(buff,"in%d", ki);
|
---|
| 847 | int idx = getInputTOIIndex(buff);
|
---|
| 848 | if (!checkInputTOIIndex(idx)) continue;
|
---|
| 849 | nbconin++;
|
---|
| 850 | in_index(ki) = idx;
|
---|
| 851 | bool fgout = false;
|
---|
| 852 | for(int jo=0; jo<m_fanout; jo++) {
|
---|
| 853 | sprintf(buff,"out%d_%d", ki, jo);
|
---|
| 854 | int odx = getOutputTOIIndex(buff);
|
---|
| 855 | if (checkOutputTOIIndex(odx)) {
|
---|
| 856 | out_index(ki, jo) = odx;
|
---|
| 857 | fgout = true;
|
---|
| 858 | }
|
---|
| 859 | }
|
---|
| 860 | if (!fgout) {
|
---|
| 861 | string msg_err =
|
---|
| 862 | "SimpleFanOut::run() - No connected Output for Input TOI ("
|
---|
| 863 | + getInName(ki) + ") !";
|
---|
| 864 | cerr << msg_err << endl;
|
---|
| 865 | throw ParmError(msg_err);
|
---|
| 866 | }
|
---|
| 867 | }
|
---|
| 868 | if (nbconin == 0) {
|
---|
| 869 | cerr << " SimpleFanOut::run() - No Input TOI connected! "
|
---|
| 870 | << endl;
|
---|
| 871 | throw ParmError("SimpleFanOut::run() No Inout TOI connected!");
|
---|
| 872 | }
|
---|
| 873 |
|
---|
| 874 | /*
|
---|
| 875 | for(int ki=0;ki<nb_input;ki++) {
|
---|
| 876 | cout << " SimpleFanOut::run() In(" << ki << ") Index=" << in_index(ki)
|
---|
| 877 | << " Name=" << getInName(in_index(ki)) << endl;
|
---|
| 878 | for(int jo=0; jo<m_fanout; jo++)
|
---|
| 879 | cout << " .... Out(" << ki << "," << jo << ") Index=" << out_index(ki, jo)
|
---|
| 880 | << " Name=" << getOutName(out_index(ki, jo)) << endl;
|
---|
| 881 | }
|
---|
| 882 | */
|
---|
| 883 | cout << " SimpleFanOut::run() SNRange=" << snb << " - " << sne << endl;
|
---|
| 884 |
|
---|
| 885 |
|
---|
| 886 | try {
|
---|
| 887 | Timer tm("SimpleFanOut::run()");
|
---|
| 888 | double valin = 0.;
|
---|
[1532] | 889 | uint_8 fgin = 0;
|
---|
[1467] | 890 | for(int k=snb;k<=sne;k++) {
|
---|
| 891 | for(int i=0;i<nb_input;i++) {
|
---|
| 892 | if (in_index(i) < 0) continue;
|
---|
| 893 | valin = 0;
|
---|
| 894 | fgin = 0;
|
---|
| 895 | getData(in_index(i), k, valin, fgin);
|
---|
| 896 | for(int j=0; j<m_fanout; j++) {
|
---|
| 897 | if (out_index(i, j) < 0) continue;
|
---|
| 898 | putData(out_index(i, j), k, valin, fgin);
|
---|
| 899 | }
|
---|
| 900 | }
|
---|
| 901 | totnscount++;
|
---|
| 902 | } // Boucle sur les num-sample
|
---|
| 903 | cout << " SimpleFanOut::run() - End of processing "
|
---|
| 904 | << " ProcessedSampleCount=" << ProcessedSampleCount() << endl;
|
---|
| 905 | } // Bloc try
|
---|
| 906 |
|
---|
| 907 | catch (PException & exc) {
|
---|
| 908 | cerr << "SimpleFanOut: Catched Exception " << (string)typeid(exc).name()
|
---|
| 909 | << "\n .... Msg= " << exc.Msg() << endl;
|
---|
| 910 | }
|
---|
| 911 | }
|
---|
| 912 |
|
---|
| 913 |
|
---|
| 914 |
|
---|