Index: trunk/ArchTOIPipe/TestPipes/simtst.cc
===================================================================
--- trunk/ArchTOIPipe/TestPipes/simtst.cc	(revision 1478)
+++ trunk/ArchTOIPipe/TestPipes/simtst.cc	(revision 1479)
@@ -33,5 +33,6 @@
   else {
     cout << "\n Usage : simtst [-dbg] [-start snb] [-end sne] \n" 
-	 << "         [-wtoi sz] [-w2 sz] inFitsName outFitsName ppfFileName \n" 
+	 << "         [-wtoi sz] [-wdegli sz] [-wfft sz] [-keepfft n] \n"
+	 << "         inFitsName outFitsName  \n" 
 	 << "   -dbg : sets TOISeqBuffered debug level to 1 \n"
 	 << "   -start snb : sets the start sample num \n"
@@ -42,4 +43,6 @@
 	 << "   -wtoi sz : sets TOISeqBuff buffer size (def= 8192)\n"
 	 << "   -wdegli sz : sets deglitcher window size (def= 512) \n"
+	 << "   -wfft sz : Activate Fourier filter and sets its width \n"
+	 << "   -keepfft n : Keeps n spectra (if Fourier filter activated) \n" 
 	 << endl;
     exit(0);
@@ -54,8 +57,10 @@
 
   bool fgdbg = false;
-  int w1 = 8192;
-  int w2 = 512;
+  int wtoi = 8192;
+  int wdegli = 512;
+  int wfft = 4096;
+  int keepfft = 0;
   int nmax = 10;
-  int istart = 104121000+w1*5;
+  int istart = 104121000+wtoi*5;
   int iend = 0;
   double range_min = -16000;
@@ -63,6 +68,6 @@
   string infile;
   string outfile;
-  string ppffile;
   string intoi = "boloMuV_27";
+  bool fg_f_filt = false;
 
   if (narg < 4) Usage(true);
@@ -80,9 +85,18 @@
     else if (strcmp(arg[ia],"-wtoi") == 0) {
       if (ia == narg-1) Usage(true);  
-      w1 = atoi(arg[ia+1]); ia++;
+      wtoi = atoi(arg[ia+1]); ia++;
     }    
     else if (strcmp(arg[ia],"-wdegli") == 0) {
       if (ia == narg-1) Usage(true);  
-      w2 = atoi(arg[ia+1]); ia++;
+      wdegli = atoi(arg[ia+1]); ia++;
+    }    
+    else if (strcmp(arg[ia],"-wfft") == 0) {
+      if (ia == narg-1) Usage(true);  
+      wfft = atoi(arg[ia+1]); ia++;
+      fg_f_filt = true;
+    }    
+    else if (strcmp(arg[ia],"-keepfft") == 0) {
+      if (ia == narg-1) Usage(true);  
+      keepfft = atoi(arg[ia+1]); ia++;
     }    
     else if (strcmp(arg[ia],"-range") == 0) {
@@ -100,9 +114,8 @@
   }
 
-  if (iend < istart) iend = istart+w1*(nmax+5);
-  if ((narg-ko) < 3)  Usage(true); 
+  if (iend < istart) iend = istart+wtoi*(nmax+5);
+  if ((narg-ko) < 2)  Usage(true); 
   infile = arg[ko];
   outfile = arg[ko+1];
-  ppffile = arg[ko+2];
 
   cout << " Initializing SOPHYA ... " << endl;
@@ -110,9 +123,10 @@
   InitTim();
 
-  cout << ">>>> tstrztoi: Infile= " << infile << " outFile=" << outfile 
-       << " ppfFile= " << ppffile << endl;
-  cout << ">>>> Window Size W1= " << w1 << " W2= " << w2
+  cout << ">>>> tstrztoi: Infile= " << infile << " outFile=" 
+       << outfile << endl; 
+  cout << ">>>> Window Size WTOI= " << wtoi << " WDEGLI= " << wdegli
        << "  iStart= " << istart << " iEnd= " << iend << endl;
   cout << ">>>> InTOIName= " << intoi << endl;
+
   try {
     TOIManager* mgr = TOIManager::getManager();
@@ -131,4 +145,7 @@
 
 
+    int w1 = wtoi;
+    int w2 = (fg_f_filt && (wfft > w1)) ? wfft : w1; 
+
     //    char * colname[5] = {"MJD", "UTC","boloMuV_11","magnFlux","pivot"};
     //    char * toiname[5] = {"MJD", "UTC","bolo11","magneto","pivot"};
@@ -139,5 +156,5 @@
     TOISeqBuffered * toimean = new TOISeqBuffered("mean", w1);
     if (fgdbg) toimean->setDebugLevel(1);
-    TOISeqBuffered * toisig = new TOISeqBuffered("sigma", w1);
+    TOISeqBuffered * toisig = new TOISeqBuffered("sigma", w2);
     if (fgdbg) toisig->setDebugLevel(1);
     TOISeqBuffered * toiincopie = new TOISeqBuffered("incopie", w1);
@@ -160,7 +177,9 @@
 
     cout << " Creating SimpleDeglitcher() " << endl;
-    SimpleDeglitcher degl(w2);
+    SimpleDeglitcher degl(wdegli);
+    degl.SetDetectionParam(3.,1.5, 4, 2, 10);
     cout << " Setting Range for deglitcher: " << range_min 
 	 << " - " << range_max << endl;
+
     degl.SetRange(range_min, range_max);
     degl.addInput("in", toiin);
@@ -174,9 +193,9 @@
     TOISeqBuffered * toidegli0 = new TOISeqBuffered("degli0", w1);
     if (fgdbg) toidegli0->setDebugLevel(1);
-    TOISeqBuffered * toidegli1 = new TOISeqBuffered("degli1", w1);
+    TOISeqBuffered * toidegli1 = new TOISeqBuffered("degli1", w2);
 
     TOISeqBuffered * toimean0 = new TOISeqBuffered("mean0", w1);
     if (fgdbg) toimean0->setDebugLevel(1);
-    TOISeqBuffered * toimean1 = new TOISeqBuffered("mean1", w1);
+    TOISeqBuffered * toimean1 = new TOISeqBuffered("mean1", w2);
     if (fgdbg) toimean1->setDebugLevel(1);
     
@@ -206,9 +225,25 @@
     TOISeqBuffered * toiout = new TOISeqBuffered("out", w1);
     if (fgdbg) toiout->setDebugLevel(1);
-    TOISeqBuffered * toideglioffcopie = new TOISeqBuffered("deglioffcopie", w1);
+    TOISeqBuffered * toideglioffcopie = new TOISeqBuffered("deglioffcopie", w2);
     if (fgdbg) toideglioffcopie->setDebugLevel(1);
     filt.addOutput("out", toiout);
     filt.addOutput("incopie", toideglioffcopie);
-    
+
+    Vector fcoef(wfft/2);
+    fcoef = RegularSequence(1., -2./wfft);
+    cout << " Creating Fourier Filter ... " << endl;
+    SimpleFourierFilter sfft(fcoef);
+    sfft.KeepSpectra(keepfft);
+    TOISeqBuffered * toifft = NULL;
+    TOISeqBuffered * toifiltcopie = NULL;
+
+    if (fg_f_filt) {
+      cout << " Connecting Fourier Filter ... " << endl;
+      toifft = new TOISeqBuffered("fftout", w1);
+      toifiltcopie = new TOISeqBuffered("filtcopie", w1);
+      sfft.addInput("in",toiout);
+      sfft.addOutput("out", toifft);
+      sfft.addOutput("incopie", toifiltcopie);
+    }
 
     cout << " Connecting to output (FitsWriter) " << endl;
@@ -216,5 +251,9 @@
     w.setOutFlags(true);
     w.addInput("in", toiincopie);
-    w.addInput("out", toiout);
+    if (fg_f_filt) {
+      w.addInput("filtout", toifiltcopie);
+      w.addInput("fftout", toifft);
+    } 
+    else   w.addInput("out", toiout);
     w.addInput("degli", toidegli1);
     w.addInput("deglioff", toideglioffcopie);
@@ -239,4 +278,5 @@
     adder.start();
     filt.start();
+    if (fg_f_filt) sfft.start();
     w.start();
 
@@ -268,4 +308,5 @@
     cout << filt;
     cout << adder;
+    if (fg_f_filt) cout << sfft ; 
 
   }
