Index: trunk/ArchTOIPipe/ProcWSophya/simtoipr.cc
===================================================================
--- trunk/ArchTOIPipe/ProcWSophya/simtoipr.cc	(revision 1482)
+++ trunk/ArchTOIPipe/ProcWSophya/simtoipr.cc	(revision 1483)
@@ -615,5 +615,5 @@
   if (wsize < 16) 
     throw ParmError("SimpleFourierFilter::SimpleFourierFilter() WSize<16 !");
-  KeepSpectra(0);
+  KeepSpectra("spectra.ppf", 0);
 }
 
@@ -672,5 +672,5 @@
     Vector vout(wsize);
     TVector<int_8> vfg(wsize);
-    TVector< complex<r_8> > vfft;
+    TVector< complex<r_8> > vfft, vfftmean;
     TVector< complex<r_8> > zcoef(ffcoef.Size());
     zcoef = ffcoef;
@@ -679,10 +679,12 @@
     FFTPackServer ffts;
     ffts.setNormalize(true);
-    // Boucle sur les sampleNum
+
+    POutPersist pout(outppfname);
 
     int k,i,klast;
     int nks = 0;
-
+    int nblk = 0;
     klast = snb-1;
+    // Boucle sur les sampleNum
     // 1er partie, on traite par paquets de wsize
     for(k=snb;k<=sne-wsize+1;k+=wsize) {
@@ -690,8 +692,12 @@
 	getData(0, k+i, vin(i), vfg(i));
       ffts.FFTForward(vin, vfft);
+      if (nblk == 0)  vfftmean = vfft;
+      else vfftmean += vfft;
+      nblk++;
       if (nks < nb_keep) {
-	string dbgfile = "ffiltdbg" + (string)MuTyV(nks) + ".ppf";
-	POutPersist po(dbgfile);
-	po << vfft; 
+	TVector< complex<r_8> > vfftcopie;
+	vfftcopie = vfft;
+	string nomvfft = "spectra" + MuTyV(nks);
+	pout.PutObject(vfftcopie, nomvfft); 
 	nks++;
       }
@@ -719,4 +725,9 @@
 	totnscount++;
       }
+
+    
+    vfftmean /= complex<r_8>((r_8)nblk, 0.);    
+    pout.PutObject(vfftmean, "meanspectra");
+
     cout << " SimpleFourierFilter::run() - End of processing " << endl;
   }  // Bloc try 
Index: trunk/ArchTOIPipe/ProcWSophya/simtoipr.h
===================================================================
--- trunk/ArchTOIPipe/ProcWSophya/simtoipr.h	(revision 1482)
+++ trunk/ArchTOIPipe/ProcWSophya/simtoipr.h	(revision 1483)
@@ -158,6 +158,6 @@
   virtual void	run();
 
-  inline  void  KeepSpectra(int nb=0) 
-                { nb_keep = nb; }
+  inline  void  KeepSpectra(string outname, int nb) 
+                { outppfname = outname; nb_keep = nb; }
 protected:
   int_8 totnscount;   // Nombre total d'echantillon processe
@@ -165,4 +165,5 @@
   Vector ffcoef;     // Coefficients du filtre
   int nb_keep;
+  string outppfname;
 };
 
Index: trunk/ArchTOIPipe/TestPipes/simtst.cc
===================================================================
--- trunk/ArchTOIPipe/TestPipes/simtst.cc	(revision 1482)
+++ trunk/ArchTOIPipe/TestPipes/simtst.cc	(revision 1483)
@@ -34,5 +34,5 @@
     cout << "\n Usage : simtst [-dbg] [-start snb] [-end sne] \n" 
 	 << "         [-wtoi sz] [-wdegli sz] [-wfft sz] [-keepfft n] \n"
-	 << "         inFitsName outFitsName  \n" 
+	 << "         inFitsName outFitsName  outPPFName \n" 
 	 << "   -dbg : sets TOISeqBuffered debug level to 1 \n"
 	 << "   -start snb : sets the start sample num \n"
@@ -57,4 +57,5 @@
 
   bool fgdbg = false;
+  bool fgsetstart = false;
   int wtoi = 8192;
   int wdegli = 512;
@@ -62,5 +63,5 @@
   int keepfft = 0;
   int nmax = 10;
-  int istart = 104121000+wtoi*5;
+  int istart = 0;
   int iend = 0;
   double range_min = -16000;
@@ -68,4 +69,5 @@
   string infile;
   string outfile;
+  string outppfname;
   string intoi = "boloMuV_27";
   bool fg_f_filt = false;
@@ -78,4 +80,5 @@
       if (ia == narg-1) Usage(true);  // -start est suivi d'un argument 
       istart = atoi(arg[ia+1]); ia++;
+      fgsetstart = true;
     }    
     else if (strcmp(arg[ia],"-end") == 0) {
@@ -115,7 +118,8 @@
 
   if (iend < istart) iend = istart+wtoi*(nmax+5);
-  if ((narg-ko) < 2)  Usage(true); 
+  if ((narg-ko) < 3)  Usage(true); 
   infile = arg[ko];
   outfile = arg[ko+1];
+  outppfname = arg[ko+2];
 
   cout << " Initializing SOPHYA ... " << endl;
@@ -134,6 +138,6 @@
     //  mgr->setRequestedSample(11680920,11710584);
     //  mgr->setRequestedSample(104121000, 104946120);
-
-    mgr->setRequestedSample(istart, iend);
+    if (fgsetstart) 
+      mgr->setRequestedSample(istart, iend);
   
     //    FITSTOIReader r("/data/Archeops/bolo11.fits); 
@@ -146,5 +150,5 @@
 
     int w1 = wtoi;
-    int w2 = (fg_f_filt && (wfft > w1)) ? wfft : w1; 
+    int w2 = (fg_f_filt) ? 2*wfft+w1 : w1; 
 
     //    char * colname[5] = {"MJD", "UTC","boloMuV_11","magnFlux","pivot"};
@@ -158,5 +162,5 @@
     TOISeqBuffered * toisig = new TOISeqBuffered("sigma", w2);
     if (fgdbg) toisig->setDebugLevel(1);
-    TOISeqBuffered * toiincopie = new TOISeqBuffered("incopie", w1);
+    TOISeqBuffered * toiincopie = new TOISeqBuffered("incopie", w2);
     if (fgdbg) toiincopie->setDebugLevel(1);
     
@@ -234,5 +238,5 @@
     cout << " Creating Fourier Filter ... " << endl;
     SimpleFourierFilter sfft(fcoef);
-    sfft.KeepSpectra(keepfft);
+    sfft.KeepSpectra(outppfname, keepfft);
     TOISeqBuffered * toifft = NULL;
     TOISeqBuffered * toifiltcopie = NULL;
