Index: trunk/ArchTOIPipe/Processors/Makefile.in
===================================================================
--- trunk/ArchTOIPipe/Processors/Makefile.in	(revision 2127)
+++ trunk/ArchTOIPipe/Processors/Makefile.in	(revision 2187)
@@ -48,5 +48,5 @@
 
 SRCFILES=toisqfilter.cc nooppr.cc correl.cc nrutil.c dlubksb.c dludcmp.c dtoeplz.c \
-	 wienerdecor.cc
+	 wienerdecor.cc toidelay.cc toimedfilter.cc
 FILES=$(patsubst %.c,%.o,$(SRCFILES:.cc=.o))
 
Index: trunk/ArchTOIPipe/Processors/toidelay.cc
===================================================================
--- trunk/ArchTOIPipe/Processors/toidelay.cc	(revision 2187)
+++ trunk/ArchTOIPipe/Processors/toidelay.cc	(revision 2187)
@@ -0,0 +1,47 @@
+// ArchTOIPipe           (C)     CEA/DAPNIA/SPP IN2P3/LAL
+//                               Eric Aubourg
+//                               Christophe Magneville
+//                               Reza Ansari
+// $Id: toidelay.cc,v 1.1 2002-09-09 15:33:15 aubourg Exp $
+
+#include "toimanager.h"
+#include "toidelay.h"
+
+TOIDelay::TOIDelay(int n) {
+  delay = n;
+  nskip = ndrop = 0;
+}
+
+void TOIDelay::init() {
+  declareInput("signal");
+  declareOutput("signal");
+  upExtra = delay + ndrop;
+  lowExtra = nskip;
+}
+
+#define BUFSZ 4096
+
+void TOIDelay::run() {
+  int snb = getMinIn()+nskip;
+  int sne = getMaxIn()-ndrop;
+
+
+  if(snb>sne) {
+    cout<<"TOIDelay::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
+    throw ParmError("TOIDelay::run() - Bad sample interval");
+  }
+
+  cout << "TOIDelay delay="<<delay<< " sn : " << snb << " - " << sne << endl;
+
+  double* buf = new double[BUFSZ];
+  
+  int sn = snb;
+  while (sn <= sne) {
+    int sn2 = sn + BUFSZ - 1;
+    if (sn2>sne) sn2=sne;
+    int nsamp = sn2-sn+1;
+    getData(0, sn+delay, nsamp, buf);
+    putData(0, sn, nsamp, buf);
+    sn += nsamp;
+  }
+}
Index: trunk/ArchTOIPipe/Processors/toidelay.h
===================================================================
--- trunk/ArchTOIPipe/Processors/toidelay.h	(revision 2187)
+++ trunk/ArchTOIPipe/Processors/toidelay.h	(revision 2187)
@@ -0,0 +1,31 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+// ArchTOIPipe           (C)     CEA/DAPNIA/SPP IN2P3/LAL
+//                               Eric Aubourg
+//                               Christophe Magneville
+//                               Reza Ansari
+// $Id: toidelay.h,v 1.1 2002-09-09 15:33:15 aubourg Exp $
+
+#ifndef TOIDELAY_H
+#define TOIDELAY_H
+
+#include "toiprocessor.h"
+
+class TOIDelay : public TOIProcessor {
+public:
+  TOIDelay(int delay);
+
+  void setSkipBegin(int nskip) {this->nskip = nskip;}
+  void setDropEnd(int ndrop) {this->ndrop = ndrop;}
+  
+  virtual void init();
+  virtual void run();
+protected:
+  int delay;
+  int nskip;
+  int ndrop;
+};
+
+
+#endif
+
Index: trunk/ArchTOIPipe/Processors/wienerdecor.cc
===================================================================
--- trunk/ArchTOIPipe/Processors/wienerdecor.cc	(revision 2127)
+++ trunk/ArchTOIPipe/Processors/wienerdecor.cc	(revision 2187)
@@ -11,4 +11,5 @@
   nsamples = n;
   lcorr = l;
+  doNotLookAt();
 }
 
@@ -35,4 +36,5 @@
   double* y = new double[lcorr+1];  // corr vector
   double* window = new double[lcorr];
+  uint_8* fwind  = new uint_8[lcorr];
   double* filter = new double[lcorr];
   for (int i=0; i<lcorr; i++) filter[i]=0;
@@ -41,5 +43,5 @@
   int snstartcorr = -1;
   
-  while (sn < sne) {
+  while (sn <= sne) {
     if (snstartcorr < 0 || 
 	(snstartcorr + nsamples < sn && sn+nsamples < sne)) {
@@ -48,16 +50,27 @@
       corr.reset();
       autocorr.reset();
-      int i;
-      for (i=sn; i<sn+nsamples; i++) {
-	double sig = getData(0, i);
-	double prb = getData(1, i);
+      cout << "computing correl " << sn << " -> " << sn+nsamples << endl;
+      for (int i=sn; i<sn+nsamples; i++) {
+	uint_8 flag1, flag2;
+	double sig, prb;
+	getData(0, i, sig, flag1);
+	if (flag1 & flgNotLookAt) continue;
+	getData(1, i, prb, flag2);
+	if (flag2 & flgNotLookAt) continue;
+	if ((i-sn)%100 == 0) {
+	  //cout << " sig/prb : " << i << " : " << sig << " / " << prb 
+	  //     << hex << " " << flag1 << " " << flag2 << dec << endl;
+	}
 	corr.push(i, sig, prb);
 	autocorr.push(i, prb);
       }
       // correlation is recomputed, let's recompute the wiener filter from wiener equations
-      for (i=0; i<lcorr; i++) {
+      {for (int i=0; i<lcorr; i++) {
 	r[lcorr+i] = r[lcorr-i] = autocorr.correl(i);
 	y[i+1] = corr.correl(i);
-      }
+	//cout << "r " << lcorr+i << " " << lcorr -i << " = " << r[lcorr+i] 
+	//    << "\n"
+	//    << "y " << i+1 << " = " << y[i+1] << endl;
+      }}
       dtoeplz(r,w,y,lcorr);
       if (!isnan(w[1])) {
@@ -69,18 +82,20 @@
       }
       cout << "Wiener filter : " << sn << "\n ";
-      for (i=0; i<lcorr; i++) {
+      {for (int i=0; i<lcorr; i++) {
 	cout << filter[i] << " ";
-      }
+      }}
      cout << endl;
     }
 
     if (sn >= snb+lcorr-1) {
-      getData(1, sn-lcorr+1, lcorr, window);
+      getData(1, sn-lcorr+1, lcorr, window, fwind);
+      uint_8 flag = 0;
       double outSig = 0;
       for (int i=0; i<lcorr; i++) {
 	outSig += filter[i] * window[lcorr-1 - i];
+	flag |= fwind[lcorr-1 -i];
       }
-      putData(0, sn, getData(0, sn) - outSig);
-      putData(1, sn, outSig);
+      putData(0, sn, getData(0, sn) - outSig, flag);
+      putData(1, sn, outSig, flag);
     }
     sn++;
Index: trunk/ArchTOIPipe/Processors/wienerdecor.h
===================================================================
--- trunk/ArchTOIPipe/Processors/wienerdecor.h	(revision 2127)
+++ trunk/ArchTOIPipe/Processors/wienerdecor.h	(revision 2187)
@@ -5,5 +5,5 @@
 //                               Christophe Magneville
 //                               Reza Ansari
-// $Id: wienerdecor.h,v 1.1 2002-03-23 23:05:22 aubourg Exp $
+// $Id: wienerdecor.h,v 1.2 2002-09-09 15:33:15 aubourg Exp $
 
 #ifndef WIENERDECOR_H
@@ -20,10 +20,10 @@
   virtual void run();
 
-  //  inline void doNotLookAt(uint_8 flag=FlgToiAll) {flgNotLookAt = flag;}
+  inline void doNotLookAt(uint_8 flag=FlgToiAll) {flgNotLookAt = flag;}
 
 protected:  
   int nsamples;
   int lcorr;
-  // uint_8 flgNotLookAt;
+  uint_8 flgNotLookAt;
 };
 
