Index: trunk/ArchTOIPipe/TestPipes/simtst.cc
===================================================================
--- trunk/ArchTOIPipe/TestPipes/simtst.cc	(revision 1483)
+++ trunk/ArchTOIPipe/TestPipes/simtst.cc	(revision 1484)
@@ -2,6 +2,17 @@
 
 ----------------   Exemple d'appel  ---------------------
-csh> simtst -start 104385384 -end 104399964 -range -500,500 
-            -intoi boloMuV_26 -wtoi 8192 -wdegli 1024 inputbolo.fits degli.fits xx.ppf
+csh> simtst -start 104385384 -end 104399964 -range -500,500 \
+            -intoi boloMuV_26 -wtoi 8192 -wdegli 1024 \
+	    inputbolo.fits filt.fits xx.ppf
+# Avec Filtre de Fourier
+csh> simtst -start 104385384 -end 104399964 -range -500,500 \
+            -intoi boloMuV_26 -wtoi 8192 -wdegli 1024 \
+            -wfft 4096 -keepfft 5 -killfreq 15,4,2.5 \ 
+	    inputbolo.fits filtfft.fits spectre.ppf
+# Autre exemple b545k02
+cool> ./simtst -start 104389122 -end 104649122 -range -1000.,1000. -intoi boloMu
+V_23 -wtoi 8192 -wdegli 1024 -wfft 4096 -keepfft 5 -killfreq 15,4,2.5 Cmv/b545k02
+2_16.00_16.49.fits b545.fits b545.ppf
+
 */
 
@@ -28,10 +39,11 @@
   cout << endl;
   if (fgerr) {
-    cout << " simtst : Argument Error ! tstrztoi -h for usage " << endl; 
+    cout << " simtst : Argument Error ! simtst -h for usage " << endl; 
     exit(1);
   }
   else {
-    cout << "\n Usage : simtst [-dbg] [-start snb] [-end sne] \n" 
-	 << "         [-wtoi sz] [-wdegli sz] [-wfft sz] [-keepfft n] \n"
+    cout << "\n Usage : simtst [-intoi toiname] [-start snb] [-end sne] \n" 
+	 << "         [-dbg] [-wtoi sz] [-wdegli sz] [-range min,max] \n"
+	 <<"          [-wfft sz] [-keepfft n] [-killfreq bf,nharm,sigf \n"
 	 << "         inFitsName outFitsName  outPPFName \n" 
 	 << "   -dbg : sets TOISeqBuffered debug level to 1 \n"
@@ -45,4 +57,6 @@
 	 << "   -wfft sz : Activate Fourier filter and sets its width \n"
 	 << "   -keepfft n : Keeps n spectra (if Fourier filter activated) \n" 
+	 << "   -killfreq bf,nharm,sigf : kills nharm frequency, basefreq=bf \n"
+            "              with a gaussian with width=sigf \n" 
 	 << endl;
     exit(0);
@@ -72,4 +86,8 @@
   string intoi = "boloMuV_27";
   bool fg_f_filt = false;
+  bool fg_killfreq = false;
+  int bf_killfreq = 1;
+  int nharm_killfreq = 1;
+  double sigf_killfreq = 1.;
 
   if (narg < 4) Usage(true);
@@ -103,4 +121,10 @@
       keepfft = atoi(arg[ia+1]); ia++;
     }    
+    else if (strcmp(arg[ia],"-killfreq") == 0) {
+      if (ia == narg-1) Usage(true);
+      sscanf(arg[ia+1],"%d,%d,%lf",&bf_killfreq, &nharm_killfreq, &sigf_killfreq);
+      fg_killfreq = true;
+      ia++;
+    }    
     else if (strcmp(arg[ia],"-range") == 0) {
       if (ia == narg-1) Usage(true);
@@ -127,5 +151,5 @@
   InitTim();
 
-  cout << ">>>> tstrztoi: Infile= " << infile << " outFile=" 
+  cout << ">>>> simtst: Infile= " << infile << " outFile=" 
        << outfile << endl; 
   cout << ">>>> Window Size WTOI= " << wtoi << " WDEGLI= " << wdegli
@@ -150,5 +174,5 @@
 
     int w1 = wtoi;
-    int w2 = (fg_f_filt) ? 2*wfft+w1 : w1; 
+    int w2 = (fg_f_filt) ? wfft+w1 : w1; 
 
     //    char * colname[5] = {"MJD", "UTC","boloMuV_11","magnFlux","pivot"};
@@ -234,9 +258,20 @@
     filt.addOutput("incopie", toideglioffcopie);
 
-    Vector fcoef(wfft/2);
-    fcoef = RegularSequence(1., -2./wfft);
+    Vector fcoef(wfft/2+1);
+    //    fcoef = RegularSequence(1., -2./wfft);
+    fcoef = 1.;
+    for(int kfk=0; kfk<nharm_killfreq; kfk++) {
+      double cfreq = bf_killfreq*(kfk+1);
+      double xfreq = 0.;
+      for(int kfj=cfreq-3.*sigf_killfreq; kfj<= cfreq+3.*sigf_killfreq; kfj++) {
+	if ( (kfj < 0) || (kfj >= fcoef.Size() ) )  continue;
+	xfreq = (cfreq-kfj)/sigf_killfreq;
+	fcoef(kfj) -= exp(-xfreq*xfreq);
+      }
+    }
     cout << " Creating Fourier Filter ... " << endl;
     SimpleFourierFilter sfft(fcoef);
     sfft.KeepSpectra(outppfname, keepfft);
+    sfft.ComputeMeanSpectra(true);
     TOISeqBuffered * toifft = NULL;
     TOISeqBuffered * toifiltcopie = NULL;
@@ -259,5 +294,5 @@
       w.addInput("fftout", toifft);
     } 
-    else   w.addInput("out", toiout);
+    else   w.addInput("filtout", toiout);
     w.addInput("degli", toidegli1);
     w.addInput("deglioff", toideglioffcopie);
