Index: trunk/ArchTOIPipe/ProcWSophya/Makefile.in
===================================================================
--- trunk/ArchTOIPipe/ProcWSophya/Makefile.in	(revision 1836)
+++ trunk/ArchTOIPipe/ProcWSophya/Makefile.in	(revision 1859)
@@ -45,5 +45,6 @@
 
 
-SRCFILES=map2toi.cc toi2map.cc rztoi.cc simtoipr.cc ktoibad.cc smoothtoi.cc 
+SRCFILES=map2toi.cc toi2map.cc rztoi.cc simtoipr.cc ktoibad.cc smoothtoi.cc \
+         noisegen.cc meanvarestim.cc
 
 FILES=$(patsubst %.c,%.o,$(SRCFILES:.cc=.o))
Index: trunk/ArchTOIPipe/ProcWSophya/meanvarestim.cc
===================================================================
--- trunk/ArchTOIPipe/ProcWSophya/meanvarestim.cc	(revision 1859)
+++ trunk/ArchTOIPipe/ProcWSophya/meanvarestim.cc	(revision 1859)
@@ -0,0 +1,67 @@
+#include "meanvarestim.h"
+#include "toimanager.h"
+#include "slinparbuff.h"
+
+MeanVarEstimator::MeanVarEstimator(int n) {
+  nsamples = n;
+}
+
+void MeanVarEstimator::init() {
+  declareInput("signal");
+  declareOutput("mean");
+  declareOutput("variance");
+  name = "MeanEstimator";
+
+  neededHistory = nsamples;
+}
+
+void MeanVarEstimator::run() {
+  int snb = getMinIn();
+  int sne = getMaxIn();
+
+  cout << "MeanVarEstimator -- " << snb << " to " << sne << endl;
+
+  bool hasMean = checkOutputTOIIndex(0);
+  bool hasVar  = checkOutputTOIIndex(1);
+
+  if (snb>sne) {
+    cout<<"MeanVarEstimator::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
+    throw ParmError("MeanVarEstimator::run() - Bad sample interval");
+  }
+
+  if (!checkInputTOIIndex(0)) {
+    cout<<"MeanVarEstimator::run() - Input TOI (signal) not connected! "<<endl;
+    throw ParmError("MeanVarEstimator::run() Input TOI (signal) not connected!");
+  }
+
+
+  if (!hasMean && !hasVar) {
+    cerr << " MeanVarEstimator::run() - No Output TOI connected! "
+         << endl;
+    throw ParmError("MeanVarEstimator::run() No output TOI connected!");
+  }
+  
+  if (sne-snb < nsamples) {
+    cerr << "MeanVarEstimator::run() -  sne-snb < nsamples!" << endl;
+    throw ParmError("MeanVarEstimator::run() -  sne-snb < nsamples!");
+  }
+  
+  SLinParBuff slb(nsamples, 100, 0., 0., true);    
+  
+  for (int sn=snb; sn<=sne; sn++) {
+    r_8 sg; uint_8 fg=0;
+    getData(0,sn,sg,fg);
+    
+    if (fg&flgNotLookAt) slb.Pop();
+    else slb.Push((r_8)sn,sg);
+
+    r_8 mean;
+    r_8 sig = slb.Compute(mean);
+    
+    if (hasMean)
+      putData(0, sn, mean, fg);
+    if (hasVar)
+      putData(1, sn, sig*sig, fg);
+  }
+}
+
Index: trunk/ArchTOIPipe/ProcWSophya/meanvarestim.h
===================================================================
--- trunk/ArchTOIPipe/ProcWSophya/meanvarestim.h	(revision 1859)
+++ trunk/ArchTOIPipe/ProcWSophya/meanvarestim.h	(revision 1859)
@@ -0,0 +1,32 @@
+// 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: meanvarestim.h,v 1.1 2002-01-15 00:46:24 aubourg Exp $
+
+#ifndef MEANVARESTIM_H
+#define MEANVARESTIM_H
+
+#include "toiprocessor.h"
+#include "flagtoidef.h"
+
+class MeanVarEstimator : public TOIProcessor {
+public:
+  MeanVarEstimator(int nsamp);
+
+  virtual void init();
+  virtual void run();
+
+  inline void doNotLookAt(uint_8 flag=FlgToiAll) {flgNotLookAt = flag;}
+
+protected:
+  int nsamples;
+  uint_8 flgNotLookAt;
+};
+
+
+
+#endif
+
Index: trunk/ArchTOIPipe/files_pipes
===================================================================
--- trunk/ArchTOIPipe/files_pipes	(revision 1836)
+++ trunk/ArchTOIPipe/files_pipes	(revision 1859)
@@ -17,2 +17,3 @@
 tsttoi2map.cc
 tstktoibad.cc
+tstnoise.cc
Index: trunk/ArchTOIPipe/files_sophya
===================================================================
--- trunk/ArchTOIPipe/files_sophya	(revision 1836)
+++ trunk/ArchTOIPipe/files_sophya	(revision 1859)
@@ -12,2 +12,6 @@
 smoothtoi.h
 smoothtoi.cc
+noisegen.h
+noisegen.cc
+meanvarestim.h
+meanvarestim.cc
