Index: /trunk/Poubelle/archTOI.old/archeopsfile.cc
===================================================================
--- /trunk/Poubelle/archTOI.old/archeopsfile.cc	(revision 393)
+++ /trunk/Poubelle/archTOI.old/archeopsfile.cc	(revision 394)
@@ -884,4 +884,12 @@
 }
 
+double ArcheopsFile::getSSTStarT(int istar, int imesure) {
+  return blockSet->sstHandler.getStarTime(imesure, istar);
+}
+
+double ArcheopsFile::getNumbStar(int imesure) {
+  return blockSet->sstHandler.getNumbStar(imesure);
+}
+
 long ArcheopsFile::getGyro(int igyro, int imesure) {   
   if (igyro<0 || igyro>2) return 0;
Index: /trunk/Poubelle/archTOI.old/archeopsfile.h
===================================================================
--- /trunk/Poubelle/archTOI.old/archeopsfile.h	(revision 393)
+++ /trunk/Poubelle/archTOI.old/archeopsfile.h	(revision 394)
@@ -138,4 +138,6 @@
   double getSSTStarZ(int iStar, int imesure);
   double getSSTStarF(int iStar, int imesure);
+  double getSSTStarT(int iStar, int imesure);
+  double getNumbStar(int imesure);
   
   int getGyroBlockNum();
Index: /trunk/Poubelle/archTOI.old/archparam.cc
===================================================================
--- /trunk/Poubelle/archTOI.old/archparam.cc	(revision 394)
+++ /trunk/Poubelle/archTOI.old/archparam.cc	(revision 394)
@@ -0,0 +1,37 @@
+// archparam.cc    parametres generaux...
+// Eric Aubourg         CEA/DAPNIA/SPP   septembre 1999
+
+#include "archparam.h"
+#include <iostream.h>
+
+ArchParam archParam;
+
+// constructeurs avec parametres par defaut adaptes au vol
+// TRAPANI 99
+
+ArchParam::AcqParam::AcqParam() 
+: tBlock0   (1376.8358818),
+  perEch    (0.005836818076)
+{}
+
+ArchParam::GeomParam::GeomParam() 
+{}
+
+ArchParam::SSTParam::SSTParam() 
+:  soustPente   (true),
+   analFine     (false)
+{}
+
+
+void ArchParam::Dump()
+{
+  cout << "***Archeops parameters\n";
+  cout << " **ACQ\n";
+  cout << "   tBlock0      " << acq.tBlock0    << "\n";
+  cout << "   perEch       " << acq.perEch     << "\n";
+  cout << " **GEOM\n";
+  cout << " **SST\n";
+  cout << "   soustPente   " << sst.soustPente << "\n";
+  cout << "   analFine     " << sst.analFine   << "\n";
+  cout << "***END" << endl;
+}
Index: /trunk/Poubelle/archTOI.old/archparam.h
===================================================================
--- /trunk/Poubelle/archTOI.old/archparam.h	(revision 394)
+++ /trunk/Poubelle/archTOI.old/archparam.h	(revision 394)
@@ -0,0 +1,34 @@
+// archparam.h    parametres generaux...
+// Eric Aubourg         CEA/DAPNIA/SPP   septembre 1999
+
+#ifndef ARCHPARAM_H
+#define ARCHPARAM_H
+
+struct ArchParam {
+  struct AcqParam {
+    double tBlock0;  // MJD du bloc numero zero...
+    double perEch;   // periode d''echantillonage en secondes 
+    AcqParam(); 
+  };
+  
+  struct GeomParam {
+    GeomParam(); 
+  };
+  
+  struct SSTParam {
+    bool soustPente;  // Decide que l'on soustrait une pente constante a la piste en cours
+    bool analFine;
+    SSTParam();  
+  };
+
+
+  AcqParam  acq;
+  GeomParam geo;
+  SSTParam  sst;
+  
+  void Dump();
+};
+
+extern ArchParam archParam;
+
+#endif
Index: /trunk/Poubelle/archTOI.old/archtoi.cc
===================================================================
--- /trunk/Poubelle/archTOI.old/archtoi.cc	(revision 393)
+++ /trunk/Poubelle/archTOI.old/archtoi.cc	(revision 394)
@@ -11,4 +11,5 @@
 #include "toisvr.h"
 #include "archtoi.h"
+#include "archparam.h"
 #include "asigps.h"
 
@@ -74,4 +75,5 @@
   else tsttoi(sstStarZ)
   else tsttoi(sstStarF)
+  else tsttoi(sstStarT)
   else tsttoi(gyroRaw)
   else tsttoi(gpsTime)
@@ -155,9 +157,9 @@
     double t0;
     sscanf(arg.c_str(), "%lg", &t0);
-    svr.SetMJD0(t0);
+    archParam.acq.tBlock0 = t0;
   } else if (key == "#PERECH") {
     double t0;
     sscanf(arg.c_str(), "%lg", &t0);
-    svr.SetPerEch(t0);
+    archParam.acq.perEch = t0;
   } else if (key == "#ASIGPS") {
     ASIGPS* gps = new ASIGPS(arg);
Index: /trunk/Poubelle/archTOI.old/dyffttools.cc
===================================================================
--- /trunk/Poubelle/archTOI.old/dyffttools.cc	(revision 394)
+++ /trunk/Poubelle/archTOI.old/dyffttools.cc	(revision 394)
@@ -0,0 +1,29 @@
+#include "dyffttools.h"
+
+
+//	Librairie FFTMayer enrobée pour etre utilisable facilement en C++
+// 	Un debut : D. Yvon 07/99
+
+
+// Fonction de fenetrage D. Yvon
+// Cut est la fraction du tableau ou l'on effectue le bizeau pour imposer 
+// par continuite une amplitude zero aux bornes :
+/*
+       ------------------
+      /                  \
+    /                      \
+  /                          \  
+/      Î     cuts       Î      \
+*/
+
+
+
+double DYWindow(double index, double indexMax) {
+	double temp;
+	double Cut=1./16.;
+	if(index<(indexMax/16.)) temp=index/indexMax*16.;
+	else if((indexMax-index)<(indexMax/16.)) temp=(indexMax-index)/indexMax*16.;
+	else temp=1.;
+	return temp;
+}
+
Index: /trunk/Poubelle/archTOI.old/dyffttools.h
===================================================================
--- /trunk/Poubelle/archTOI.old/dyffttools.h	(revision 394)
+++ /trunk/Poubelle/archTOI.old/dyffttools.h	(revision 394)
@@ -0,0 +1,6 @@
+#ifndef DYFFTTOOLS_SEEN
+#define DYFFTTOOLS
+double DYWindow(double index, double indexMax);
+
+
+#endif
Index: /trunk/Poubelle/archTOI.old/fft_mayer.cc
===================================================================
--- /trunk/Poubelle/archTOI.old/fft_mayer.cc	(revision 394)
+++ /trunk/Poubelle/archTOI.old/fft_mayer.cc	(revision 394)
@@ -0,0 +1,258 @@
+/*
+** FFT and FHT routines
+**  Copyright 1988, 1993; Ron Mayer
+**  
+**  fht(fz,n);
+**      Does a hartley transform of "n" points in the array "fz".
+**  fft(n,real,imag)
+**      Does a fourier transform of "n" points of the "real" and
+**      "imag" arrays.
+**  ifft(n,real,imag)
+**      Does an inverse fourier transform of "n" points of the "real"
+**      and "imag" arrays.
+**  realfft(n,real)
+**      Does a real-valued fourier transform of "n" points of the
+**      "real" array. The real part of the transform ends
+**      up in the first half of the array and the imaginary part of the
+**      transform ends up in the second half of the array.
+**  realifft(n,real)
+**      The inverse of the realfft() routine above.
+**      
+**      
+** NOTE: This routine uses at least 2 patented algorithms, and may be
+**       under the restrictions of a bunch of different organizations.
+**       Although I wrote it completely myself; it is kind of a derivative
+**       of a routine I once authored and released under the GPL, so it
+**       may fall under the free software foundation's restrictions;
+**       it was worked on as a Stanford Univ project, so they claim
+**       some rights to it; it was further optimized at work here, so
+**       I think this company claims parts of it.  The patents are
+**       held by R. Bracewell (the FHT algorithm) and O. Buneman (the
+**       trig generator), both at Stanford Univ.
+**       If it were up to me, I'd say go do whatever you want with it;
+**       but it would be polite to give credit to the following people
+**       if you use this anywhere:
+**           Euler     - probable inventor of the fourier transform.
+**           Gauss     - probable inventor of the FFT.
+**           Hartley   - probable inventor of the hartley transform.
+**           Buneman   - for a really cool trig generator
+**           Mayer(me) - for authoring this particular version and
+**                       including all the optimizations in one package.
+**       Thanks,
+**       Ron Mayer; mayer@acuson.com
+**
+*/
+
+#include "mayer_fft.h"
+
+#define GOOD_TRIG
+#include "trigtbl.h"
+
+char fht_version[] = "Brcwl-Hrtly-Ron-dbld";
+
+#define SQRT2_2   0.70710678118654752440084436210484
+#define SQRT2   2*0.70710678118654752440084436210484
+
+void fht(REAL *fz,int n)
+{
+ REAL a,b;
+ REAL c1,s1,s2,c2,s3,c3,s4,c4;
+ REAL f0,g0,f1,g1,f2,g2,f3,g3;
+ int i,k,k1,k2,k3,k4,kx;
+ REAL *fi,*fn,*gi;
+ TRIG_VARS;
+
+ for (k1=1,k2=0;k1<n;k1++)
+    {
+     REAL a;
+     for (k=n>>1; (!((k2^=k)&k)); k>>=1);
+     if (k1>k2)
+	{
+	     a=fz[k1];fz[k1]=fz[k2];fz[k2]=a;
+	}
+    }
+ for ( k=0 ; (1<<k)<n ; k++ );
+ k  &= 1;
+ if (k==0)
+    {
+	 for (fi=fz,fn=fz+n;fi<fn;fi+=4)
+	    {
+	     REAL f0,f1,f2,f3;
+	     f1     = fi[0 ]-fi[1 ];
+	     f0     = fi[0 ]+fi[1 ];
+	     f3     = fi[2 ]-fi[3 ];
+	     f2     = fi[2 ]+fi[3 ];
+	     fi[2 ] = (f0-f2);	
+	     fi[0 ] = (f0+f2);
+	     fi[3 ] = (f1-f3);	
+	     fi[1 ] = (f1+f3);
+	    }
+    }
+ else
+    {
+	 for (fi=fz,fn=fz+n,gi=fi+1;fi<fn;fi+=8,gi+=8)
+	    {
+	     REAL s1,c1,s2,c2,s3,c3,s4,c4,g0,f0,f1,g1,f2,g2,f3,g3;
+	     c1     = fi[0 ] - gi[0 ];
+	     s1     = fi[0 ] + gi[0 ];
+	     c2     = fi[2 ] - gi[2 ];
+	     s2     = fi[2 ] + gi[2 ];
+	     c3     = fi[4 ] - gi[4 ];
+	     s3     = fi[4 ] + gi[4 ];
+	     c4     = fi[6 ] - gi[6 ];
+	     s4     = fi[6 ] + gi[6 ];
+	     f1     = (s1 - s2);	
+	     f0     = (s1 + s2);
+	     g1     = (c1 - c2);	
+	     g0     = (c1 + c2);
+	     f3     = (s3 - s4);	
+	     f2     = (s3 + s4);
+	     g3     = SQRT2*c4;		
+	     g2     = SQRT2*c3;
+	     fi[4 ] = f0 - f2;
+	     fi[0 ] = f0 + f2;
+	     fi[6 ] = f1 - f3;
+	     fi[2 ] = f1 + f3;
+	     gi[4 ] = g0 - g2;
+	     gi[0 ] = g0 + g2;
+	     gi[6 ] = g1 - g3;
+	     gi[2 ] = g1 + g3;
+	    }
+    }
+ if (n<16) return;
+
+ do
+    {
+     REAL s1,c1;
+     k  += 2;
+     k1  = 1  << k;
+     k2  = k1 << 1;
+     k4  = k2 << 1;
+     k3  = k2 + k1;
+     kx  = k1 >> 1;
+	 fi  = fz;
+	 gi  = fi + kx;
+	 fn  = fz + n;
+	 do
+	    {
+	     REAL g0,f0,f1,g1,f2,g2,f3,g3;
+	     f1      = fi[0 ] - fi[k1];
+	     f0      = fi[0 ] + fi[k1];
+	     f3      = fi[k2] - fi[k3];
+	     f2      = fi[k2] + fi[k3];
+	     fi[k2]  = f0	  - f2;
+	     fi[0 ]  = f0	  + f2;
+	     fi[k3]  = f1	  - f3;
+	     fi[k1]  = f1	  + f3;
+	     g1      = gi[0 ] - gi[k1];
+	     g0      = gi[0 ] + gi[k1];
+	     g3      = SQRT2  * gi[k3];
+	     g2      = SQRT2  * gi[k2];
+	     gi[k2]  = g0	  - g2;
+	     gi[0 ]  = g0	  + g2;
+	     gi[k3]  = g1	  - g3;
+	     gi[k1]  = g1	  + g3;
+	     gi     += k4;
+	     fi     += k4;
+	    } while (fi<fn);
+     TRIG_INIT(k,c1,s1);
+     for (i=1;i<kx;i++)
+        {
+	 REAL c2,s2;
+         TRIG_NEXT(k,c1,s1);
+         c2 = c1*c1 - s1*s1;
+         s2 = 2*(c1*s1);
+	     fn = fz + n;
+	     fi = fz +i;
+	     gi = fz +k1-i;
+	     do
+		{
+		 REAL a,b,g0,f0,f1,g1,f2,g2,f3,g3;
+		 b       = s2*fi[k1] - c2*gi[k1];
+		 a       = c2*fi[k1] + s2*gi[k1];
+		 f1      = fi[0 ]    - a;
+		 f0      = fi[0 ]    + a;
+		 g1      = gi[0 ]    - b;
+		 g0      = gi[0 ]    + b;
+		 b       = s2*fi[k3] - c2*gi[k3];
+		 a       = c2*fi[k3] + s2*gi[k3];
+		 f3      = fi[k2]    - a;
+		 f2      = fi[k2]    + a;
+		 g3      = gi[k2]    - b;
+		 g2      = gi[k2]    + b;
+		 b       = s1*f2     - c1*g3;
+		 a       = c1*f2     + s1*g3;
+		 fi[k2]  = f0        - a;
+		 fi[0 ]  = f0        + a;
+		 gi[k3]  = g1        - b;
+		 gi[k1]  = g1        + b;
+		 b       = c1*g2     - s1*f3;
+		 a       = s1*g2     + c1*f3;
+		 gi[k2]  = g0        - a;
+		 gi[0 ]  = g0        + a;
+		 fi[k3]  = f1        - b;
+		 fi[k1]  = f1        + b;
+		 gi     += k4;
+		 fi     += k4;
+		} while (fi<fn);
+        }
+     TRIG_RESET(k,c1,s1);
+    } while (k4<n);
+}
+
+
+void ifft(int n, double *real, double *imag)
+{
+ double a,b,c,d;
+ double q,r,s,t;
+ int i,j,k;
+ fht(real,n);
+ fht(imag,n);
+ for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
+  a = real[i]; b = real[j];  q=a+b; r=a-b;
+  c = imag[i]; d = imag[j];  s=c+d; t=c-d;
+  imag[i] = (s+r)*0.5;  imag[j] = (s-r)*0.5;
+  real[i] = (q-t)*0.5;  real[j] = (q+t)*0.5;
+ }
+}
+
+void realfft(int n, double *real)
+{
+ double a,b,c,d;
+ int i,j,k;
+ fht(real,n);
+ for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
+  a = real[i];
+  b = real[j];
+  real[j] = (a-b)*0.5;
+  real[i] = (a+b)*0.5;
+ }
+}
+
+void fft(int n, double *real,double *imag)
+{
+ double a,b,c,d;
+ double q,r,s,t;
+ int i,j,k;
+ for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
+  a = real[i]; b = real[j];  q=a+b; r=a-b;
+  c = imag[i]; d = imag[j];  s=c+d; t=c-d;
+  real[i] = (q+t)*.5; real[j] = (q-t)*.5;
+  imag[i] = (s-r)*.5; imag[j] = (s+r)*.5;
+ }
+ fht(real,n);
+ fht(imag,n);
+}
+
+void realifft(int n,double *real)
+{
+ double a,b,c,d;
+ int i,j,k;
+ for (i=1,j=n-1,k=n/2;i<k;i++,j--) {
+  a = real[i];
+  b = real[j];
+  real[j] = (a-b);
+  real[i] = (a+b);
+ }
+ fht(real,n);
+}
Index: /trunk/Poubelle/archTOI.old/formepulse.cc
===================================================================
--- /trunk/Poubelle/archTOI.old/formepulse.cc	(revision 394)
+++ /trunk/Poubelle/archTOI.old/formepulse.cc	(revision 394)
@@ -0,0 +1,207 @@
+#include <iostream.h>
+#include <fstream.h>
+
+
+#include <math.h>
+#include "mayer_fft.h"
+#include "dyffttools.h"
+
+
+#include "transfelec.h"
+#include "formepulse.h"
+
+#include "ssthardware.h"
+
+
+#define LTab (2048)
+#define LSave (128)
+#define Tpas (5.e-4)
+//float PulseOptOrigin=LTab/16.*Tpas;
+float PulseOptOrigin=0.;
+
+//#define DYTestRun
+
+
+
+FormePulse::FormePulse(TransFuncElec TF) {
+
+	Dcomplex j(0.,1.);
+	double Fpas=1./(Tpas*LTab);
+	
+	double *PulseInReel=new double[LTab];
+	double *PulseInImg=new double[LTab];
+	double *PulseOut=new double[LTab];
+
+	Dcomplex* PulseFFT=new Dcomplex[LTab];
+	
+
+	for(long i=0; i<LTab; i++) PulseInReel[i]=pulseOptique(i*Tpas);
+	for(long i=0; i<LTab; i++) PulseInImg[i]=0.;
+	
+/*
+//	On fenetre le signal.
+	for(long i=0; i<LTab; i++) PulseInReel[i]=PulseInReel[i]*DYWindow(i,LTab);
+*/
+
+	ofstream dlout; // sert a sortir les print test
+	
+#ifdef DYTestRun
+		//On ecrit le signal entrant
+		char s[32]="WaveIn.txt";
+		dlout.open(s,ios::out | ios::trunc);
+		if (!dlout.is_open())
+		{	cerr<<"erreur a l'ouverture du fichier de resultats: "<<s<<endl;
+			exit(-1);
+		}
+		dlout<<"temps"<<"\tPartieReelle"<<"\tPartieImag"<<endl;
+		
+		for (long k=0; k<LTab; k++) {
+			dlout<<k*Tpas<<"\t"<<PulseInReel[k]<<"\t"<<PulseInImg[k]<<endl;
+		}
+		dlout.close();
+
+#endif
+
+// C'est la fft!
+	fft(LTab, PulseInReel, PulseInImg);
+
+
+// On Filtre dans l'espace des frequences
+	for (int i=0; i<LTab; i++) {
+		PulseFFT[i]=PulseInReel[i]+PulseInImg[i]*j;
+	//On applique le filtre Iici
+		PulseFFT[i]=TF.TsFunc(2*3.1416*i*Fpas)*PulseFFT[i];
+		PulseInReel[i]=real(PulseFFT[i]);
+		PulseInImg[i]=imag(PulseFFT[i]);
+	}
+	
+#ifdef DYTestRun	
+	// On écrit la FFT	
+		char s1[32]="PulseFFT.txt";
+		dlout.open(s1,ios::out | ios::trunc);
+		if (!dlout.is_open())
+		{	cerr<<"erreur a l'ouverture du fichier de resultats: "<<s1<<endl;
+			exit(-1);
+		}
+		dlout<<"Frequence"<<"\tPartieReelle"<<"\tPartieImag"<<endl;
+		
+		for (long k=0; k<LTab; k++) {
+			dlout<<k*Fpas<<"\t"<<PulseInReel[k]<<"\t"<<PulseInImg[k]<<endl;
+		}
+		dlout.close();
+#endif
+
+// FFT inverse
+	ifft(LTab,PulseInReel,PulseInImg);
+	for (int i=0; i<LTab; i++) {
+		PulseInReel[i]/=LTab;
+		PulseInImg[i]/=LTab;
+	}
+	
+
+// On recherche le maximum d'amplitude
+	double Max=0.;		//En volt
+	int MaxIndex=0;
+	
+	for(int i=0; i<LSave; i++) 
+		if(PulseInReel[i]>Max) {
+			Max=PulseInReel[i];
+			MaxIndex=i;
+		}
+		
+	gainElec=Max/SSTFPulseCourant;
+		//En Volt/ampere	
+		
+// On calcule la LMH
+
+	int HalfMaxInf;
+		for(HalfMaxInf=MaxIndex;HalfMaxInf>0;HalfMaxInf--)
+			if(fabs(PulseInReel[HalfMaxInf])<(Max/2.)) break;
+	int HalfMaxSup;	
+		for(HalfMaxSup=MaxIndex;HalfMaxSup<LTab;HalfMaxSup++)
+			if(fabs(PulseInReel[HalfMaxSup])<(Max/2.)) break;
+	
+	
+	FullwidthHalfMax=(HalfMaxSup-HalfMaxInf)*Tpas;
+		
+// On normalise à un Volt. Et on ecrit en memoire le resultat
+	ShapeArr=new double[LSave];
+	for(int i=0; i<LSave; i++)  ShapeArr[i]=PulseInReel[i]/Max;
+
+#ifdef DYTestRun	
+		//On ecrit le resultat dans un fichier 
+		char s2[32]="Resultatfiltrage.txt";
+		dlout.open(s2,ios::out | ios::trunc);
+		if (!dlout.is_open()){	
+			cerr<<"erreur a l'ouverture du fichier de resultats: "<<s2<<endl;
+			exit(-1);
+		}
+
+		dlout<<"Impulsion courant de: "<<SSTFPulseCourant<<" Ampères"<<endl;
+		dlout<<"Maximum d'amplitude: "<<max<< " Volts"<<endl;
+		dlout<<" gain chaine preampli: "<<gainElec<<endl<<endl;
+		dlout<<"Temps"<<"\tPartie Reelle"<<endl;
+
+		for (int k=0; k<LSave; k++) {
+			dlout<<k*Tpas<<"\t"<<ShapeArr[k]<<endl;
+		}	
+#endif
+
+
+	
+//On tue les tableaux de passage....
+	delete[] PulseInReel;
+	delete[] PulseInImg;
+	delete[] PulseOut;
+	delete[] PulseFFT;
+
+}
+
+FormePulse& FormePulse::operator =(const FormePulse& FPlse) {
+	ShapeArr=new double[LSave];
+	for(int i=0; i<LSave; i++) ShapeArr[i]=FPlse.ShapeArr[i];
+	return *this;
+}
+	
+FormePulse::~FormePulse() {
+	delete[] ShapeArr;
+}
+
+double FormePulse::TMax() {
+	double returnVal=LSave*Tpas;
+	return returnVal;
+}
+
+double FormePulse::PulseShape(double temps) {
+	int ientier=(int)(temps/Tpas);
+	double returnValue;
+	if (ientier<0) returnValue=0.;
+	else if (ientier>=LSave) returnValue= ShapeArr[127];
+	else {
+		double Min=ShapeArr[ientier];
+		double Max=ShapeArr[ientier+1];
+//		double test=temps/Tpas-ientier;
+		returnValue=Min+(Max-Min)*(temps/Tpas-ientier);
+	}
+	return returnValue;
+}
+
+
+double FormePulse::LongPulseOptique() {
+	double returnVal;
+	returnVal=SSTLongPhotDiode/SSTLongFocale*PeriodRotTeles/2/3.1415/sin(SSTTelesElevation);
+	//en secondes
+	return returnVal;
+}
+	
+double FormePulse::pulseOptique(double temps) {
+	double value;
+	if((temps>PulseOptOrigin)&&(temps<=PulseOptOrigin+LongPulseOptique()))  
+		value=SSTFPulseCourant;			 //	Amplitude: 1 nanoampère
+
+	else value=0.;
+//	for(long i=0; i<LTab; i++) value=sin(2*3.1416*temps/5.e-3); //pour test FFT
+	return value;
+}
+
+
Index: /trunk/Poubelle/archTOI.old/formepulse.h
===================================================================
--- /trunk/Poubelle/archTOI.old/formepulse.h	(revision 394)
+++ /trunk/Poubelle/archTOI.old/formepulse.h	(revision 394)
@@ -0,0 +1,31 @@
+#ifndef FORMEPULSE_SEEN
+#define FORMEPULSE_SEEN
+
+
+#define  SSTFPulseCourant 1.E-9 	
+	// Courant photodiode pour l'impulsion calculée
+	
+class TransFuncElec;
+
+
+class FormePulse {
+public:
+	FormePulse(TransFuncElec);
+	FormePulse& operator =(const FormePulse&);
+	~FormePulse();
+	double PulseShape(double temps); 	// Temps en secondes
+	double FWHM() {return FullwidthHalfMax;} // en secondes
+	double TMax ();
+	double GainElectrique() {  	//Volt/ampère de la chaine electronique
+		return gainElec; }		//Compte tenu de LongPulseOptique();	
+protected:
+	double* ShapeArr;
+	double LongPulseOptique();
+	double pulseOptique(double Temps);  
+		// Genère une impulsion de un ampère pendant LongPulseOptique()
+		// temps en secondes		
+	double gainElec;
+	double FullwidthHalfMax;						
+};
+
+#endif
Index: /trunk/Poubelle/archTOI.old/mayer_fft.h
===================================================================
--- /trunk/Poubelle/archTOI.old/mayer_fft.h	(revision 394)
+++ /trunk/Poubelle/archTOI.old/mayer_fft.h	(revision 394)
@@ -0,0 +1,54 @@
+/*
+** FFT and FHT routines
+**  Copyright 1988, 1993; Ron Mayer
+**  
+**  fht(fz,n);
+**      Does a hartley transform of "n" points in the array "fz".
+**  fft(n,real,imag)
+**      Does a fourier transform of "n" points of the "real" and
+**      "imag" arrays.
+**  ifft(n,real,imag)
+**      Does an inverse fourier transform of "n" points of the "real"
+**      and "imag" arrays.
+**  realfft(n,real)
+**      Does a real-valued fourier transform of "n" points of the
+**      "real" arrays.  The real part of the transform ends
+**      up in the first half of the array and the imaginary part of the
+**      transform ends up in the second half of the array.
+**  realifft(n,real)
+**      The inverse of the realfft() routine above.
+**      
+**      
+** NOTE: This routine uses at least 2 patented algorithms, and may be
+**       under the restrictions of a bunch of different organizations.
+**       Although I wrote it completely myself; it is kind of a derivative
+**       of a routine I once authored and released under the GPL, so it
+**       may fall under the free software foundation's restrictions;
+**       it was worked on as a Stanford Univ project, so they claim
+**       some rights to it; it was further optimized at work here, so
+**       I think this company claims parts of it.  The patents are
+**       held by R. Bracewell (the FHT algorithm) and O. Buneman (the
+**       trig generator), both at Stanford Univ.
+**       If it were up to me, I'd say go do whatever you want with it;
+**       but it would be polite to give credit to the following people
+**       if you use this anywhere:
+**           Euler     - probable inventor of the fourier transform.
+**           Gauss     - probable inventor of the FFT.
+**           Hartley   - probable inventor of the hartley transform.
+**           Buneman   - for a really cool trig generator
+**           Mayer(me) - for authoring this particular version and
+**                       including all the optimizations in one package.
+**       Thanks,
+**       Ron Mayer; mayer@acuson.com
+**
+*/
+
+#ifndef FFTMayer_SEEN
+#define FFTMayer_SEEN
+	void fht( double *fz,int n);
+	void ifft(int n, double *real, double *imag);	
+	void realfft(int n, double *real);
+	void fft(int n, double *real,double *imag);
+	void realifft(int n,double *real);
+	
+#endif
Index: /trunk/Poubelle/archTOI.old/pisteetoile.cc
===================================================================
--- /trunk/Poubelle/archTOI.old/pisteetoile.cc	(revision 394)
+++ /trunk/Poubelle/archTOI.old/pisteetoile.cc	(revision 394)
@@ -0,0 +1,375 @@
+#include "math.h"
+#include <new.h>
+#include "iostream.h"
+#include "archparam.h"
+#include "pisteetoile.h"
+ 
+TransFuncElec PisteEtoile::Trapani;
+FormePulse    PisteEtoile::FPulse(Trapani);
+
+
+
+int SSTnbPasFit= (int) (2*TFExcursion/TPasTFit);
+
+PisteEtoile::PisteEtoile(short NoPhotDiod) {
+	PasTempsEch=0.005836818076;			
+		//BUGG doit changer	!!!!! Doit etre extrait d'un serveur de param d'acquisition
+	NoPhDiod=NoPhotDiod;
+	DiodVivante=true;
+	AmplNorm=0.;
+//	On echantillonne dix fois plus fin pour avoir une bonne estimation de AmplNorm
+//	Eviter les systematiques
+	for(int i=0; i<SSTLongIndexEvt()*10; i++){
+		AmplNorm+=FPulse.PulseShape(i/10.*TPasTFit)*FPulse.PulseShape(i/10.*TPasTFit);
+	}
+	AmplNorm/=10.;
+	indexDebutPiste=0;
+	
+	PhDiodArray=new(nothrow) int[PhDiodTabLong];
+	PhDiodPiste=new(nothrow) double[PhDiodTabLong];
+	Ampl=new(nothrow) double[SSTnbPasFit];
+	X2=new(nothrow) double[SSTnbPasFit];
+	
+	if((X2==0)||(Ampl==0)||(PhDiodPiste==0)||(PhDiodArray==0)) {
+		cerr<<"Erreur a la reservation de memoire dans constructeur pisteetoile"<<endl;
+		exit(-1);
+	}
+}
+
+PisteEtoile& PisteEtoile::operator =(PisteEtoile const & x) {
+	PasTempsEch=x.PasTempsEch;		
+		//BUGG doit changer	!!!!! Doit etre extrait d'un serveur de param d'acquisition
+	NoPhDiod=x.NoPhDiod;
+	DiodVivante=x.DiodVivante;
+	indexDebutPiste=x.indexDebutPiste;
+	DiodVivante=x.DiodVivante;
+	AmplNorm=x.AmplNorm;
+
+	
+	for(int j=0; j<PhDiodTabLong;j++) PhDiodArray[j]=x.PhDiodArray[j];
+	for(int j=0; j<PhDiodTabLong;j++) PhDiodPiste[j]=x.PhDiodPiste[j];
+	
+	LastEtoile=x.LastEtoile;
+	
+	 gachette=x.gachette;
+	 Vrms=x.Vrms;
+	 MaxIndex=x.MaxIndex;			// Index de l'amplitude Max en analyse Trig()
+	 AmplMax=x.AmplMax;
+	 
+	 AmplRes=x.AmplRes;
+	 TIndex=x.TIndex;
+	 X2Min=x.X2Min;
+	 SuccesAFine=x.SuccesAFine;
+	 AmplNorm=x.AmplNorm;
+	 
+	 return *this;
+}
+
+PisteEtoile::PisteEtoile (PisteEtoile const & x) {
+	PasTempsEch=x.PasTempsEch;		
+	NoPhDiod=x.NoPhDiod;
+	DiodVivante=x.DiodVivante;
+	indexDebutPiste=x.indexDebutPiste;
+	DiodVivante=x.DiodVivante;
+	AmplNorm=x.AmplNorm;
+		
+	PhDiodArray=new(nothrow) int[PhDiodTabLong];
+	PhDiodPiste=new(nothrow) double[PhDiodTabLong];
+	Ampl=new(nothrow) double[SSTnbPasFit];
+	X2=new(nothrow) double[SSTnbPasFit];
+	
+	
+	if((X2==0)||(Ampl==0)||(PhDiodPiste==0)||(PhDiodArray==0)) {
+		cerr<<"Erreur a la reservation de memoire dans constructeur pisteetoile"<<endl;
+		exit(-1);
+	}
+	
+	for(int j=0; j<PhDiodTabLong;j++) PhDiodArray[j]=x.PhDiodArray[j];
+	for(int j=0; j<PhDiodTabLong;j++) PhDiodPiste[j]=x.PhDiodPiste[j];
+	
+	LastEtoile=x.LastEtoile;
+	
+	 gachette=x.gachette;
+	 Vrms=x.Vrms;
+	 MaxIndex=x.MaxIndex;			// Index de l'amplitude Max en analyse Trig()
+	 AmplMax=x.AmplMax;
+	 
+	 AmplRes=x.AmplRes;
+	 TIndex=x.TIndex;
+	 X2Min=x.X2Min;
+	 SuccesAFine=x.SuccesAFine;
+	 AmplNorm=x.AmplNorm;
+
+}
+
+
+
+PisteEtoile::~PisteEtoile() {
+	delete[] X2;
+	delete[] Ampl;
+	delete[] PhDiodPiste;
+	delete[] PhDiodArray;
+	
+}
+
+void PisteEtoile::fill(int* pData, int InDebutPiste, int nData) {
+//	if(!isAlive()) return;
+	indexDebutPiste=InDebutPiste;
+	int* PhDiod=PhDiodArray;
+	int* pDataC=pData;
+	for(int k=0;k<nData;k++,pDataC++, PhDiod++) (*PhDiod)=(*pDataC);
+	return;
+}
+
+void PisteEtoile::push(int* pData, int nbdata) {
+	int* PPhDiod=PhDiodArray;
+	int* PPhDiod2=PhDiodArray+nbdata;
+	int* pDataC=pData;
+	
+	for(int i=0; i<PhDiodTabLong-nbdata; i++, PPhDiod++, PPhDiod2++) *PPhDiod=(*PPhDiod2);
+	for(int i=0; i<nbdata; i++, PPhDiod++,pDataC++) *PPhDiod=(*pDataC);
+	indexDebutPiste+=nbdata; 
+	return;
+}
+
+bool PisteEtoile::traque() {
+	if(!isAlive()) return false;		//La diode est-elle morte?
+	
+	bool testEtoile=trig();
+	if(testEtoile) {			
+		//On a declenché sur une Etoile
+		if(archParam.sst.analFine) {
+			demasque();
+// Un second Filtre est possible
+			// if(!(fabs(AmplRes)>SeuilGachette*Vrms)&&SuccesAFine) testEtoile=false;
+			// Test rajouté pour filtrer le bruit en escalier des voies SST
+			// Le fit de forme tasse le bruit et permet un meilleur filtrage.
+		}
+
+// Troisième filtre possible:
+		// On tue les evenements trop larges
+		if (widthHalfMax>(FPulse.FWHM()/PasTempsEch+2.)) testEtoile=false;
+	
+		if(testEtoile) {
+		// On emballe une etoile.
+			LastEtoile.FitForme=SuccesAFine;
+			LastEtoile.X2Calc=X2Min;
+			LastEtoile.InpCurrNoisRMS=Vrms/FPulse.GainElectrique();
+			LastEtoile.TEchan=TIndex;
+			LastEtoile.InpCurrent= AmplRes/FPulse.GainElectrique();
+			LastEtoile.NoDiode=NoPhDiod;
+			LastEtoile.LargMiHauteur=widthHalfMax;
+		}
+	}
+	// On expedie	
+	return testEtoile;
+}
+
+bool PisteEtoile::trig() {	
+	MaxIndex=-1;
+	AmplMax=0.;
+	gachette=false;
+
+// Copie les données brutes sur la piste. Les met en Volt ADC 12 Bits-10 Volts
+	for(int i=0; i<PhDiodTabLong; i++) PhDiodPiste[i]=PhDiodArray[i]*SSTLsbVal;
+
+// Calcule Valeur Moy du prepulse
+	double Moy=0.;
+	for(int i=0; i<Prepulselong; i++) Moy+=PhDiodPiste[i];
+	Moy/=Prepulselong;
+
+// On soustrait la valeur Moy de la piste
+	for (int i=0; i<PhDiodTabLong; i++) PhDiodPiste[i]-=Moy;
+	
+	double pente=0.;
+	if (archParam.sst.soustPente==true) {
+	//	On calcule la pente du prepulse
+		double milprepulse=(Prepulselong-1.)/2.;
+		double SomCarre=0.;
+		for(int i=0; i<Prepulselong; i++) {
+			SomCarre+= (i-milprepulse)*(i-milprepulse);
+			pente+= (i-milprepulse)*PhDiodPiste[i];
+		}
+		pente=pente/SomCarre;
+
+	// On soustrait la pente sur la piste
+		for (int i=0; i<PhDiodTabLong; i++) PhDiodPiste[i]-=(i-milprepulse)*pente;
+	}
+	
+// On calcule le Vrms sur le prepulse
+	Vrms=0.;
+	for (int i=0; i<Prepulselong; i++) Vrms+=PhDiodPiste[i]*PhDiodPiste[i];
+	Vrms=sqrt(Vrms)/Prepulselong;
+	if(Vrms<SSTLsbVal) Vrms=SSTLsbVal;		// Pour eviter les VRMS=0.
+	
+// Declenche-t-on?
+	gachette=false;
+	short iSeuil=0;
+	double* pPiste =PhDiodPiste+Prepulselong;
+	
+// On demande deux échantillons à 2 Vrms
+	for (int i=0; i<(PhDiodTabLong-Prepulselong); i++, pPiste++) {
+		if (fabs(*pPiste)>(SeuilGachette*Vrms)) 
+			if (fabs(*(pPiste+1))>SeuilGachette*Vrms) {
+				gachette=true;
+				iSeuil=Prepulselong+i;
+				break;
+			}		
+	}
+
+	if (gachette==true) {
+// On trouve le maximum
+		MaxIndex=iSeuil;
+		AmplMax=fabs(PhDiodPiste[iSeuil]);
+		for (int i=iSeuil; i<PhDiodTabLong; i++) {
+			if (fabs(PhDiodPiste[i])>AmplMax) {
+				MaxIndex=i;
+				AmplMax=fabs(PhDiodPiste[i]);
+			}
+		}
+		if ((MaxIndex>=PhDiodTabLong-4)||(MaxIndex<Prepulselong+4)) gachette=false;
+// Cela sera traite a l'iteration suivante
+// Ou ca a du etre traite a l'iteration precedente	
+	}
+	if (gachette==true) {
+// On calcule la largeur a mi hauteur
+		int HalfMaxInf;
+		for(HalfMaxInf=MaxIndex;HalfMaxInf>Prepulselong;HalfMaxInf--)
+			if(fabs(PhDiodPiste[HalfMaxInf])<(AmplMax/2.)) break;
+				int HalfMaxSup;	
+		for(HalfMaxSup=MaxIndex;HalfMaxSup<PhDiodTabLong;HalfMaxSup++)
+			if(fabs(PhDiodPiste[HalfMaxSup])<(AmplMax/2.)) break;
+		widthHalfMax=HalfMaxSup-HalfMaxInf;
+		
+/*
+// On integre sur la larg a mi hauteur
+		integ=0.;
+		if((HalfMaxSup<PhDiodTabLong)&&(HalfMaxInf>Prepulselong))
+			for(int i=HalfMaxInf; i<=HalfMaxSup; i++) integ+=PhDiodPiste[i];
+*/
+
+
+// On fitte une parabole autour du maximum
+		double tmaxfit;
+		if (widthHalfMax>1) {
+			double ymax=PhDiodPiste[MaxIndex];
+			double yplus=PhDiodPiste[MaxIndex+1];
+			double ymoins=PhDiodPiste[MaxIndex-1];
+	// Estimation du temps
+			if(!(ymax==yplus)) {
+				double Y=(yplus-ymax)/(ymax-ymoins);
+				tmaxfit=0.5*(1.+Y)/(1-Y);
+			}
+			else tmaxfit=0.5;
+			
+	// Estimation de l'amplitude
+			double dtplus2=(1.+tmaxfit)*(1.+tmaxfit);
+			double dtmoins2=(1.-tmaxfit)*(1.-tmaxfit);
+			if(dtplus2==dtmoins2) AmplRes=PhDiodPiste[MaxIndex];
+			else AmplRes= (yplus*dtplus2-ymoins*dtmoins2) / (dtplus2-dtmoins2);
+		}
+		
+//	On stocke les resultats
+		TIndex=indexDebutPiste+Prepulselong+MaxIndex+tmaxfit;
+		
+		X2Min=0.;
+		SuccesAFine=false;
+	}
+	return gachette;	
+}
+
+void PisteEtoile::demasque() {
+// Maintenant que l'on se doute que il y a une etoile 
+// On veut connaitre son flux et son temps de passage
+// Nécessite d'avoir un ordre d'idee de la vitesse de rotation du ballon.
+
+		// BUGG devra etre extrait des headers acquisition. Ca peut changer!!!!!!
+
+	
+			
+	int IndexDebutEvt=MaxIndex-SSTLargEvtIndex();
+	
+	pFitArray0= PhDiodPiste+IndexDebutEvt; 
+		// Pointeur origine du tableau d'echantillon sur lequel sera calculé le fit
+	double DeltaTemps=0.;
+// Pour chaque decalage en temps, on estime un amplitude et calcule le X2
+	for(int k=0; k<SSTnbPasFit; k++) {
+		DeltaTemps=TFExcursion-k*TPasTFit;
+		pFitArray=pFitArray0;
+		double Som=0.;
+		for(int i=0; i<SSTLongIndexEvt(); i++, pFitArray++)	{
+//			cout<<(*pFitArray)<<'\t'<<FPulse.PulseShape(i*PasTempsEch-DeltaTemps)<<endl;
+			Som=Som+FPulse.PulseShape(i*PasTempsEch-DeltaTemps)*(*pFitArray);
+		}
+		Ampl[k]=Som/AmplNorm;
+		X2[k]=0.;
+		double X2Som=0.; double dum=0.;pFitArray=pFitArray0;
+		for(int i=0; i<SSTLongIndexEvt(); i++, pFitArray++) {
+			dum=(*pFitArray)-Ampl[k]*FPulse.PulseShape(i*PasTempsEch-DeltaTemps); 	// Différence
+			X2Som+=dum*dum;															// Au carré
+		}				
+		X2[k]=X2Som/(SSTLongIndexEvt()*Vrms*Vrms);
+	}
+	
+// On recherche le minimum du X2
+	X2Min=1.e99;
+	int X2MinIndex=-1;
+	for(int k=0; k<SSTnbPasFit; k++) 
+		if (X2[k]<X2Min) {
+			X2Min=X2[k];
+			X2MinIndex=k;
+		}
+
+	if((X2MinIndex>0)&&(X2MinIndex<(SSTnbPasFit-1))) {
+	
+// On fitte une parabole sur les trois X2 qui encadrent le min
+	double Di;	// Index (non entier) du minimum du X2
+		double X=(X2[X2MinIndex+1]-X2Min)/(X2Min-X2[X2MinIndex-1]);		
+		Di=0.5*(X+1)/(X-1);
+
+// On calcule l'amplitude estimee a ce temps
+		double Som1=0.; pFitArray=pFitArray0;
+		DeltaTemps=TFExcursion-(X2MinIndex-Di)*TPasTFit;
+		for(int i=0; i<SSTLongIndexEvt(); i++, pFitArray++) 
+			Som1+=(*pFitArray)*FPulse.PulseShape(i*PasTempsEch-DeltaTemps);
+		AmplRes=Som1/AmplNorm;
+		
+//Le X2 est mimimum pour le n° de pas de fit X2MinIndex+Di 
+
+#ifdef PEtoileDebug
+		double* PulseTrak=new double [SSTLongIndexEvt()];
+#endif
+
+		double X2Som1=0.; double dummy=0.;pFitArray=pFitArray0;
+		for(int i=0;i<SSTLongIndexEvt();i++,pFitArray++) {	
+#ifdef PEtoileDebug
+			PulseTrak[i]=FPulse.PulseShape(i*PasTempsEch-DeltaTemps);
+#endif
+			dummy=(*pFitArray)-AmplRes*FPulse.PulseShape(i*PasTempsEch-DeltaTemps); 	// Différence
+			X2Som1+=dummy*dummy;														// Au carré
+		}
+					
+		X2Min=X2Som1/(SSTLongIndexEvt()*Vrms*Vrms);
+	
+		TIndex=indexDebutPiste+IndexDebutEvt+DeltaTemps/PasTempsEch;
+					//Ouff!!!!
+		SuccesAFine=true;
+	}
+	else {				// Echec, c'est tres bizarre! On doit etre dans le bruit
+		X2Min=0.;		
+	}
+	return;
+} 
+
+int  PisteEtoile::SSTLargEvtIndex() {  		
+// Demi-largeur a 3 sigma de l'impulsion 
+	int dum=(int) (15.e-3/PasTempsEch+1.); 
+	return dum;
+}
+
+int  PisteEtoile::SSTLongIndexEvt() {		
+// Nombre d'echantillon sur lequel est calculé le fit de forme
+	int temp=2*SSTLargEvtIndex()+1;
+	return temp;
+}
+	
Index: /trunk/Poubelle/archTOI.old/pisteetoile.h
===================================================================
--- /trunk/Poubelle/archTOI.old/pisteetoile.h	(revision 394)
+++ /trunk/Poubelle/archTOI.old/pisteetoile.h	(revision 394)
@@ -0,0 +1,116 @@
+#ifndef PisteEtoileSeen
+#define PisteEtoileSeen
+#include "sstetoile.h"
+#include "transfelec.h"
+#include "formepulse.h"
+
+/*	// D. Yvon, CE Saclay, 08/99
+
+	// Analyse the Photodiode track to find star pulse.
+	// Caracterise the time and amplitude of the star Pulse
+
+	We analyse a set of 32 samples. The 16 first are considered as prepulse sample.
+	On the prepulse: 
+		We compute baseline and substract it. 
+		Then compute slope due to pile up and substract it
+		Then compute Vrms.
+		Look for trigger
+	If triggered :
+		Look for maximum. If max found 20< Max< 28
+		Iterate time fit on pulse area and compute amplitude and X2
+		Find best X2. 
+		Fit parabole arond the minimum of X2 to get the true minimum.
+		Build SSTStar.
+		
+	That's it. Test code tstpisteetoile.cc can be found in tstroutines folder.
+	When  done push the track eigth samples forward and iterate analysis. 
+*/
+
+class FormePulse;
+
+#define PEtoileDebug
+
+
+#define PhDiodTabLong (48)
+#define Prepulselong (32)
+#define Pousslong (8)
+
+
+// 	Parametrisation du Trigger 
+#define SeuilGachette (6.) 				// On déclenche à SeuilGachette sigmas
+#define SSTLsbVal (10./4096)
+
+//	Parametrisation Analyse Fine
+#define TFExcursion (15.e-3)			// Secondes: Excursion du fit autour de MaxIndex
+#define TPasTFit (2.5e-3)				// Secondes:
+			// Secondes:
+
+class PisteEtoile {
+public:
+	PisteEtoile(short NoPhotDiod=0);
+	PisteEtoile (PisteEtoile const & x);
+	~PisteEtoile();
+	PisteEtoile& operator = (PisteEtoile const & x);
+	void fill(int* pData, int inDebutPiste=0, int nData=PhDiodTabLong);
+	void push(int* pData, int nbdata=Pousslong); 
+		//"Pousse" les données dans PhDiodArray de nbdata
+	bool traque() ; 
+		// Traque l'etoile.	
+	bool trig(); 
+		//Trig sur les donnees? Si Oui declenche une analyse complète
+	void demasque();
+		// Met en Oeuvre un fit de forme pour determiner le temps et l'amplitude.
+
+	bool isAlive() 	{	return 	DiodVivante;}
+	void kill()		{	DiodVivante=false;}
+	void restore()	{	DiodVivante=true;}
+	
+	SSTEtoile DonneEtoile() {return LastEtoile;}
+		//Retourne la dernière Etoile détectee
+	inline int SSTLargEvtIndex(); 
+	inline int SSTLongIndexEvt();
+protected:
+	double PasTempsEch; 	//Secondes 
+// Idendificateur, repères et gestion 
+	short NoPhDiod;
+	int indexDebutPiste; 	// A actualiser dans push() et Fill()! BUGG!!!!
+	bool DiodVivante;		// Si false, On ne fait rien 
+	
+// Stocke donnees brutes et traitees
+	int* PhDiodArray;
+	double* PhDiodPiste;
+	
+// Derniere Etoile Vue
+	SSTEtoile LastEtoile;
+	
+// Variables d'analyse
+	bool gachette;
+	double Vrms;
+	short MaxIndex;			// Index de l'amplitude Max en analyse Trig()
+	double AmplMax;
+	int widthHalfMax;
+//	double integ;
+// Variables Resultat d'analyse fine
+	
+	double AmplRes;
+	double TIndex;
+	double X2Min;
+	bool SuccesAFine;
+	
+// Utilitaires de calcul analyse fine
+	double AmplNorm;
+		// Normalisation d'amplitude sur FPulse dans l'ajustement iteratif
+	double *pFitArray0;
+		// Pointeur origine du tableau d'echantillon sur lequel sera calculé le fit
+	double *pFitArray;
+		// Pointeur courant du tableau d'echantillon 
+	double* Ampl; 	//Tableau des amplitudes calculées
+
+	double* X2;		//Tableau des X2 calculés
+	
+	static TransFuncElec Trapani;
+	static FormePulse FPulse;
+	
+};
+
+#endif
Index: /trunk/Poubelle/archTOI.old/sstetoile.cc
===================================================================
--- /trunk/Poubelle/archTOI.old/sstetoile.cc	(revision 394)
+++ /trunk/Poubelle/archTOI.old/sstetoile.cc	(revision 394)
@@ -0,0 +1,14 @@
+#include "sstetoile.h"
+
+void SSTEtoile::print(ofstream& str) {
+	str<<setprecision(11);
+	str<<InpCurrent<<'\t'<<TEchan<<'\t'<<NoDiode<<'\t'<<LargMiHauteur;
+	str<<'\t'<<InpCurrNoisRMS<<endl;
+	//	<<'\t'<<X2Calc<<'\t'<<FitForme
+	return;
+}
+
+string SSTEtoile::printHeader() {
+	string a("InpCurrent\tTempsEchan\tNoDiode\tLarMiHauteur\tICurrRMS\tX2Calc\tFitForme");
+	return a;
+}
Index: /trunk/Poubelle/archTOI.old/sstetoile.h
===================================================================
--- /trunk/Poubelle/archTOI.old/sstetoile.h	(revision 394)
+++ /trunk/Poubelle/archTOI.old/sstetoile.h	(revision 394)
@@ -0,0 +1,25 @@
+#ifndef SSTEtoile_H
+#define SSTEtoile_H
+
+#include <stdio.h>
+#include <string>
+#include <fstream.h>
+#include <iomanip.h>
+
+
+class SSTEtoile{
+public:
+	double InpCurrent;		// En Ampère
+//	double IInteg;			// En Ampère
+	double TEchan;			// Temps en indexEchantillon
+	double InpCurrNoisRMS;	// Bruit en Ampère
+	double X2Calc;			// Sans dimension
+	int NoDiode;
+	bool FitForme;			// Fit de forme?
+	int LargMiHauteur;		// Comme son nom l'indique
+	
+	void print(ofstream& str);
+	string printHeader();
+};
+
+#endif
Index: /trunk/Poubelle/archTOI.old/ssthandler.cc
===================================================================
--- /trunk/Poubelle/archTOI.old/ssthandler.cc	(revision 393)
+++ /trunk/Poubelle/archTOI.old/ssthandler.cc	(revision 394)
@@ -13,5 +13,5 @@
 #include <math.h>
 #include "ssthandler.h"
-#include <iostream.h>
+#include "pisteetoile.h"
 
 // diodpermut[i] = channel de la diode i
@@ -25,17 +25,25 @@
 
 SSTHandler::SSTHandler()
+:sstchass("SSTChassLogFile")
 {
   diodeHistLength = nb_per_block*2+10;
   diodeT = new int[diodeHistLength*nb_photo_diodes];
   starHistLength = 300;
-  stars = new (vector<star>[starHistLength]);
+
   lastBlkNum = -1;
   
   //Has2Bars(false);
   prcTodo=0;
-  seuil=100;
-}
-
-SSTHandler::SSTHandler(SSTHandler const& x)
+  
+  pPiste = NULL;
+  LastBlockSSTNb = -2;
+  noStarDet = 0;
+  
+  findStarConstruct();
+  
+}
+
+SSTHandler::SSTHandler(SSTHandler const& x) 
+:sstchass("SSTChassLogFile")
 {
   diodeHistLength = x.diodeHistLength;
@@ -43,7 +51,24 @@
   memcpy(diodeT, x.diodeT, diodeHistLength*nb_photo_diodes);
   starHistLength = x.starHistLength;
-  stars = new (vector<star>[starHistLength]);
-  for (int i=0; i<starHistLength; i++)
-    stars[i] = x.stars[i];
+    
+  prcTodo    = x.prcTodo;
+ // has2bars   = x.has2bars;
+  lastBlkNum = x.lastBlkNum;
+  
+  pPiste = NULL;
+  LastBlockSSTNb = x.LastBlockSSTNb;
+  noStarDet = x.noStarDet;
+
+  findStarConstruct();
+  for(int i=0; i<NbPhotDiodBarette; i++) {
+  	*PisteBar[i]=*(x.PisteBar[i]);
+  }
+}
+
+SSTHandler& SSTHandler::operator = (SSTHandler const& x) {
+  delete[] diodeT; 
+  diodeHistLength = x.diodeHistLength;
+  diodeT = new int[diodeHistLength*nb_photo_diodes];
+  memcpy(diodeT, x.diodeT, diodeHistLength*nb_photo_diodes);
     
   prcTodo    = x.prcTodo;
@@ -51,31 +76,11 @@
  // elecOffset = x.elecOffset;
   lastBlkNum = x.lastBlkNum;
-  seuil      = x.seuil;
-}
-
-SSTHandler& SSTHandler::operator = (SSTHandler const& x) {
-  delete[] stars;
-  delete[] diodeT; 
-  diodeHistLength = x.diodeHistLength;
-  diodeT = new int[diodeHistLength*nb_photo_diodes];
-  memcpy(diodeT, x.diodeT, diodeHistLength*nb_photo_diodes);
-  starHistLength = x.starHistLength;
-  stars = new (vector<star>[starHistLength]);
-  for (int i=0; i<starHistLength; i++)
-    stars[i] = x.stars[i];
-    
-  prcTodo    = x.prcTodo;
- // has2bars   = x.has2bars;
- // elecOffset = x.elecOffset;
-  lastBlkNum = x.lastBlkNum;
-  seuil      = x.seuil;
-  
+  for(int i=0; i<NbPhotDiodBarette; i++) *PisteBar[i]=*(x.PisteBar[i]);
   return *this;
 }
 
-SSTHandler::~SSTHandler()
-{
-  delete[] stars;
+SSTHandler::~SSTHandler(){
   delete[] diodeT;
+  findStarDestruct();
 }
 
@@ -85,5 +90,5 @@
   if (prcTodo & findAxis)   prcTodo |= findPeriod;
   if (prcTodo & findPeriod) prcTodo |= findStars;
-  if (prcTodo & findStars)  prcTodo |= rmveOffset;
+  if (prcTodo & findStars)  prcTodo |= permDiode;
 }
 
@@ -96,19 +101,4 @@
   elecOffset = eo;
 }
-
-void SSTHandler::ProcessBlock(block_type_sst* blk)
-{
-  lastBlkNum = numero_block(blk);
-  for (int i = 0; i<nb_per_block*2; i++) {
-    DecodeTMBlock(blk, i, diodeRaw[i]);
-  }
-  if (prcTodo & rmveOffset) {
-    RemoveOffset();
-  }
-  if (prcTodo & findStars) {
-    FindStars();
-  }
-}
-
 
 void SSTHandler::DecodeTMBlock(block_type_sst* blk, int i, int* diod)
@@ -139,5 +129,5 @@
 
 
-void SSTHandler::RemoveOffset()
+void SSTHandler::PermutDiode()
 {
   int j0 = diodeHistLength-(nb_per_block*2);
@@ -187,66 +177,207 @@
 }
 
-int SSTHandler::getStarZ(int imesure, int istar) // for last block
-{
-  int j0 = starHistLength-(nb_per_block*2);
-  if (imesure+j0<0 || imesure>=nb_per_block*2) return -99999;
-  if (istar < 0 || istar >= stars[imesure+j0].size()) return -99999;
-  return stars[imesure+j0][istar].z;
-}
-
-int SSTHandler::getStarF(int imesure, int istar) // for last block
-{
-  int j0 = starHistLength-(nb_per_block*2);
-  if (imesure+j0<0 || imesure>=nb_per_block*2) return -99999;
-  if (istar < 0 || istar >= stars[imesure+j0].size()) return -99999;
-  return stars[imesure+j0][istar].m;
-}
-
-
-void SSTHandler::FindStars()  // sur les 72 derniers echantillons dans diode.
-{
-  int js0 = starHistLength-(nb_per_block*2);
-  int jd0 = diodeHistLength-(nb_per_block*2);
-  // Decalage vers la gauche de la taille d'un bloc
-  for (int i=0; i<js0; i++) {
-    stars[i] = stars[i+(nb_per_block*2)];
-  }
-  
-  // Recherche d'etoiles
-  for (int i=0; i<(nb_per_block*2); i++) {
-    stars[js0+i].clear();
-    for (int idiode=0; idiode<46; idiode++) {
-      if (diode(jd0+i,idiode) < -seuil) {
-        if (has2bars) {
-          for (int j=-2; j>=-5; j--) {
-            if (diode(jd0+i+j,(idiode+elecOffset)%46) < -seuil) {
-              star s;
-              s.z = idiode;
-              s.m = -diode(jd0+i,idiode);
-              s.t = i; // $CHECK$ need absolute time...
-              stars[js0+i].push_back(s);
-              break;
-            } else if (idiode<45 && diode(jd0+i+j,(idiode+1+elecOffset)%46) > seuil) {
-              star s;
-              s.z = idiode+.5;
-              s.m = -diode(jd0+i,idiode);
-              s.t = i; // $CHECK$ need absolute time...
-              stars[js0+i].push_back(s);
-              break;
-            }
-          }
-        } else {
-          if (diode(jd0+i,idiode) > diode(jd0+i-1,idiode)) {
-            star s;
-            s.z = idiode;
-            s.m = -diode(jd0+i-1,idiode);
-            s.t = i; // $CHECK$ need absolute time...
-            stars[js0+i].push_back(s);
-          }
-        }
-      }
-    }
-  }
-
-
-}
+int SSTHandler::FindStars(block_type_sst* blk) {
+	NbStarInBlock=0;
+	LastBlockStarVec.clear();
+	
+	int NoFirstSpInBlock=FirstSplNb(blk);
+  	int jd0 = diodeHistLength-NbSampleBlock;
+
+	bool FlagLBlockPerdu=false;
+	int ThisBlockNumb=numero_block(blk);
+	
+	if ((LastBlockSSTNb+1)==ThisBlockNumb) LastBlockSSTNb++;
+	else {
+		FlagLBlockPerdu=true;
+		LastBlockSSTNb=ThisBlockNumb;
+	}
+
+//	On cherche les etoiles	
+	for(int NoDiode=0;NoDiode<NbPhotDiodBarette; NoDiode++) {	
+		pPiste=PisteBar[NoDiode];
+		
+	// Traitons une diode pendant un block
+		offseDataDiod=0;
+		for (int i=0; i<NbSampleBlock; i++) Diodedata[i]=diode(jd0+i,NoDiode);
+
+		if (FlagLBlockPerdu)  {
+			pPiste->fill(Diodedata+offseDataDiod,FirstSplNb(blk));
+			offseDataDiod+=PhDiodTabLong;
+		}
+		else {
+			pPiste->push(Diodedata);
+			offseDataDiod+=Pousslong;
+		}
+		
+	// Recherchons les etoiles
+		while (true) {
+			if (pPiste->traque()) {				// On a trouve!
+				LastStar=pPiste->DonneEtoile();
+/*				double dum= LastStar.TEchan;
+				pair<const double, SSTEtoile> unepaire=make_pair(dum,LastStar);
+				StarHistoryMap.insert(unepaire);	
+*/
+				StarHistoryMap[LastStar.TEchan]=LastStar;
+					//On empile sur la map.
+				NbStarInBlock++;
+#ifdef SST_DEBUG			
+			// On écrit les pistes ayant déclénchées
+				int NoDiodeEvt=LastStar.NoDiode;
+				if(pPisteDump[NoDiodeEvt]->is_open())	
+					for(int noSamp=0; noSamp<NbSampleBlock;noSamp++)
+						(*pPisteDump[NoDiodeEvt])<<noStarDet<<'\t'<<NoDiode<<'\t'<<NoFirstSpInBlock+noSamp<<'\t'<<Diodedata[noSamp]<<endl;
+#endif
+				noStarDet++;
+			}
+		// Est-on en bout de Piste?
+			if(offseDataDiod+Pousslong>=NbSampleBlock) break;
+			else {
+				pPiste->push(Diodedata+offseDataDiod);
+				offseDataDiod+=Pousslong;
+			}
+		}
+	}
+	
+//	On ne garde que les NbEtInSetMax dernières étoiles
+	int nbEtoileInMap=StarHistoryMap.size();
+	if(nbEtoileInMap>NbEtInMapMax) {
+		int nbErase=nbEtoileInMap-NbEtInMapMax;
+		StarHistIter StarIter=StarHistoryMap.begin();
+		for(int i=0;i<nbErase;i++){
+			StarHistoryMap.erase(StarIter);
+			StarIter++;
+		}
+		nbEtoileInMap-=nbErase;
+	}			
+	
+//	On stocke les etoiles du block dans LastBlockStarVec
+	map<double,SSTEtoile>::reverse_iterator StarHistReIter= StarHistoryMap.rbegin() ;
+	for(int i=0; i<NbStarInBlock; i++, StarHistReIter++) 
+		LastBlockStarVec.push_back((*StarHistReIter).second);
+	
+//#ifdef SST_DEBUG
+	if(NbStarInBlock>0) {
+			
+	// On écrit les étoiles detectées
+		vector<SSTEtoile>::reverse_iterator StarVecRevIter;
+		StarVecRevIter=LastBlockStarVec.rbegin();
+		for(int i=0; i<NbStarInBlock;i++,StarVecRevIter++) 
+			(*StarVecRevIter).print(sstchass);
+	}
+		
+//#endif
+
+	return NbStarInBlock;
+}
+
+void SSTHandler::findStarConstruct() {
+	PisteBar=new PisteEtoile*[NbPhotDiodBarette];
+	for(int i=0; i<NbPhotDiodBarette; i++) PisteBar[i]=new PisteEtoile(i);
+	StarHistoryMap.clear();
+	sstchass<<LastStar.printHeader()<<endl;
+	
+#ifdef SST_DEBUG	
+	char s[32];
+	string fileName;
+//	if(pPisteDump==NULL)
+		pPisteDump= new ofstream* [NbChanDump];
+	
+	for (int pistNumb=0; pistNumb<NbChanDump; pistNumb++) {
+		sprintf(s,"%i", pistNumb);	
+		string piste=s;
+		fileName="pisteno"+piste+"dump";
+/*		
+		if ((*pPisteDump[pistNumb]).is_open()) {
+			cerr<<"Erreur: le fichier "<<fileName<<" devrait être libre"<<endl;
+				//On libère
+			(*pPisteDump[pistNumb]).close();
+			delete pPisteDump[pistNumb];
+		}
+*/			
+		pPisteDump[pistNumb]=new ofstream(fileName.c_str(),ios::out|ios::trunc);
+		
+		if(!(*pPisteDump[pistNumb]).is_open()) {
+			cerr<<"Warning Echec à l'ouverture du fichier: "<<fileName<<endl;
+		}
+	}
+#endif
+	return;
+}
+
+void SSTHandler::findStarDestruct() {
+	for(int i=0; i<NbPhotDiodBarette; i++) {
+		delete PisteBar[i];
+	}
+	delete[] PisteBar;
+		
+#ifdef SST_DEBUG	
+	for (int pistNumb=0; pistNumb<NbChanDump; pistNumb++) {
+		pPisteDump[pistNumb]->close();
+		delete pPisteDump[pistNumb];
+	}
+	delete 	pPisteDump;
+#endif
+
+	return;
+}
+
+int SSTHandler::getNumbStar(int iSampl) {
+	StarHistIter IterLow=StarHistoryMap.lower_bound((double)iSampl);
+	StarHistIter IterHigh=StarHistoryMap.upper_bound((double)(iSampl+1.));
+	int Compteur=0;
+	while (!(IterLow==IterHigh)) {IterLow++; Compteur++;}
+	return Compteur;
+}
+
+double SSTHandler::getStarF(int iSampl, int istar){ 
+	if( (getNumbStar(iSampl)==0)||(getNumbStar(iSampl)<istar)) return -1;
+	else {
+		StarHistIter IterLow=StarHistoryMap.lower_bound((double)iSampl);
+		while(!(istar==0)) {
+			IterLow++;
+			istar--;
+		}
+	return (double) ((*IterLow).second).InpCurrent;
+	}
+}
+
+
+int SSTHandler::getStarZ(int iSampl, int istar) {
+	if( (getNumbStar(iSampl)==0)||(getNumbStar(iSampl)<istar)) return -1;
+	StarHistIter IterLow=StarHistoryMap.lower_bound((double)iSampl);
+	while(!(istar==0)) {
+		IterLow++;
+		istar--;
+	}
+	return ((*IterLow).second).NoDiode;
+}
+
+double SSTHandler::getStarTime(int iSampl, int istar) {
+	if( (getNumbStar(iSampl)==0)||(getNumbStar(iSampl)<istar)) return -1;
+	StarHistIter IterLow=StarHistoryMap.lower_bound((double)iSampl);
+	while(!(istar==0)) {
+		IterLow++;
+		istar--;
+	}
+	return ((*IterLow).second).TEchan;
+}
+
+int SSTHandler::FirstSplNb(block_type_sst* blk){
+	return NbSampleBlock*numero_block(blk);	// BUGG	A verifier
+}
+
+
+void SSTHandler::ProcessBlock(block_type_sst* blk)
+{
+  lastBlkNum = numero_block(blk);
+  for (int i = 0; i<nb_per_block*2; i++) {
+    DecodeTMBlock(blk, i, diodeRaw[i]);
+  }
+  if (prcTodo & permDiode) {
+    PermutDiode();
+  }
+  if (prcTodo & findStars) {
+    FindStars(blk);
+  }
+}
+
Index: /trunk/Poubelle/archTOI.old/ssthandler.h
===================================================================
--- /trunk/Poubelle/archTOI.old/ssthandler.h	(revision 393)
+++ /trunk/Poubelle/archTOI.old/ssthandler.h	(revision 394)
@@ -5,5 +5,7 @@
 #define SSTHANDLER_H
 
+#include <math.h>
 #include <vector>
+#include <map>
 
 #ifndef nb_max_bolo
@@ -15,4 +17,17 @@
 #endif
 
+class ArcheopsFile;
+
+// Zone findStar
+#include "sstetoile.h"
+#include "pisteetoile.h"
+
+//#define SST_DEBUG
+#define NbChanDump (10)
+#define	NbPhotDiodBarette (46)
+#define NbEtInMapMax 	(100)
+#define SSTChassLog (true)
+#define NbSampleBlock (2*nb_per_block)
+// Fin Zone findStar
 
 class SSTHandler {
@@ -23,5 +38,5 @@
   virtual ~SSTHandler();
   
-  enum process { rmveOffset = 1, 
+  enum process { permDiode = 1, 
          findStars  = 2,
          findPeriod = 4,
@@ -33,9 +48,17 @@
   static void Has2Bars(bool, int elecOffset=0); // elecOffset : which wired together
   
+  long getLastBlkNum() {return lastBlkNum;}
   int  getRawSignal(int imesure, int idiode); // for last block
   int  getSignal(int imesure, int idiode);    // for last block, imesure<0 -> history
-  int  getStarZ(int imesure, int istar);      // for last block, imesure<0 -> history
-  int  getStarF(int imesure, int istar);      // for last block, imesure<0 -> history
-  long getLastBlkNum() {return lastBlkNum;}
+  	
+  	//	Zone findStar 
+  int  getNumbStar(int iSampl);	
+  			// return number of star found in sample number iSampl	
+  int  getStarZ(int iSampl, int istar); 
+  			// return diode number of the star     
+  double getStarF(int iSampl, int istar);  
+  			// return star flux in Ampère
+  double getStarTime(int iSampl, int istar); 
+  			// return star time in this sample
 
 protected:
@@ -46,6 +69,6 @@
   int   starHistLength;
   long  lastBlkNum;
-  int   seuil;
   
+  	// Is there two photoDiod Arrays and how are they connected?
   static bool  has2bars;
   static int   elecOffset;
@@ -53,18 +76,39 @@
   inline int& diode(int iSamp, int iDiod) {return diodeT[iSamp*nb_photo_diodes+iDiod];}
   
-  struct star {
-    float z;
-    float m;
-    double t;
-  };
-
-  vector<star>* stars;
-  
+  static int  diodpermut[46]; // diodpermut[i] = channel de la diode i
   
   void DecodeTMBlock(block_type_sst*, int i, int* diodes); // mesure i -> diodes
-  void RemoveOffset(); // diodeRaw -> diode, avec decalage, 1 echantillon.
-  void FindStars(); // sur les 72 derniers echantillons dans diode.
+  void PermutDiode(); // diodeRaw -> diode, avec decalage, 1 echantillon.
+  int FindStars(block_type_sst* blk); 		// sur les 72 derniers echantillons dans diode.
+  						// return nmber of star found in last block
   
-  static int  diodpermut[46]; // diodpermut[i] = channel de la diode i
+  	// 	Zone findStar
+  int NbStarInBlock;
+
+  PisteEtoile** PisteBar; 
+  	
+#ifdef SST_DEBUG
+  	ofstream** pPisteDump;
+#endif
+
+  map<double,SSTEtoile> StarHistoryMap;	
+  		// On stocke les etoiles de manière ordonnée en temps
+  typedef  map<double,SSTEtoile>::iterator StarHistIter;
+  typedef  map<double,SSTEtoile>::const_iterator StarConstHistIter;
+  
+  vector<SSTEtoile> LastBlockStarVec;	
+  		// Vecteur des SSTEtoile du block classees en ordre de temps decroissant.
+  //vector<SSTEtoile> reverse_iterator StarVecRevIter LastBlockStarVec.rbegin();
+  SSTEtoile LastStar;
+  PisteEtoile* pPiste;		// Piste courante d'analyse
+  int Diodedata[NbSampleBlock];
+  int offseDataDiod;
+  int LastBlockSSTNb; // Gère la disparition des blocs défectueux
+  int noStarDet;
+  int FirstSplNb(block_type_sst* blk); // Calcule l'index du premier echantillon du block analysé
+  ofstream sstchass;
+  
+  void findStarConstruct();
+  void findStarDestruct();
 };
 
Index: /trunk/Poubelle/archTOI.old/ssthardware.h
===================================================================
--- /trunk/Poubelle/archTOI.old/ssthardware.h	(revision 394)
+++ /trunk/Poubelle/archTOI.old/ssthardware.h	(revision 394)
@@ -0,0 +1,16 @@
+#ifndef SSTHARDWARE_SEEN
+#define SSTHARDWARE_SEEN
+
+// Telescope SST
+#define SSTTelesElevation (41./180*3.1416)		// Elevation du boresigth telescope SST, radian
+#define SSTLongFocale (1.8)						// Longueur focale en metre
+#define SSTNbPhotDiod (46)						// Nombre de PhotoDiodes
+#define SSTLongPhotDiode (4.4e-3)					// Longueur Photdiode en metre
+#define SSTLargPhotDiode (1.e-3)					// Largueur Photdiode en metre
+
+
+// Paramètres du Vol
+#define PeriodRotTeles (20.)						// Periode de rotation du telescope en seconde
+
+
+#endif
Index: /trunk/Poubelle/archTOI.old/toiiter.cc
===================================================================
--- /trunk/Poubelle/archTOI.old/toiiter.cc	(revision 393)
+++ /trunk/Poubelle/archTOI.old/toiiter.cc	(revision 394)
@@ -5,4 +5,5 @@
 #include "toiiter.h"
 #include "toiinterpolator.h"
+#include "archparam.h"
 #include <dirent.h>
 #include <iostream.h>
@@ -27,9 +28,9 @@
  tEnd   = 9.e99;
  
- tBlock0 = -1;
- perEch = -1;
+ //tBlock0 = -1;
+ // perEch = -1;
  // Values for Trapani 99 = default values
- tBlock0 = 1376.8358818;
- perEch = 0.005836818076;
+ //tBlock0 = 1376.8358818;
+ //perEch = 0.005836818076;
  
  trigMask = 0;
@@ -53,6 +54,6 @@
   tStart = x.tStart;
   tEnd = x.tEnd;
-  tBlock0 = x.tBlock0;
-  perEch = x.perEch;
+  //tBlock0 = x.tBlock0;
+  //perEch = x.perEch;
   trigMask = x.trigMask;
   infos = x.infos;   
@@ -180,6 +181,6 @@
   // peu plus de details sur la facon dont le GPS est lu.
   
-  if (tBlock0 < 0) {
-    tBlock0 = file->getStartMJD();
+  if (archParam.acq.tBlock0 < 0) {
+    archParam.acq.tBlock0 = file->getStartMJD();
 
     file->pushMark();
@@ -187,7 +188,7 @@
       // le temps du bloc courant, en secondes
       double dt = file->blockNum() * file->perBlock();
-      tBlock0 = file->getGPSMJD() - dt/86400.;
+      archParam.acq.tBlock0 = file->getGPSMJD() - dt/86400.;
     } else { // pas de bloc GPS...
-      tBlock0 = file->getStartMJD();
+      archParam.acq.tBlock0 = file->getStartMJD();
     }
     file->popMark();
@@ -195,6 +196,6 @@
   tStart = oldTStart;  // on restaure
   
-  if (perEch < 0)
-    perEch = file->perEchant();
+  if (archParam.acq.perEch < 0)
+    archParam.acq.perEch = file->perEchant();
 
   bool hasInterp = false;
@@ -221,9 +222,10 @@
         case sstStarZ:
         case sstStarF:
+        case sstStarT:
           file->needSSTProcessMask(SSTHandler::findStars);
           trigMask |= block_sst_mask;
           break;
         case sstDiode:
-          file->needSSTProcessMask(SSTHandler::rmveOffset);
+          file->needSSTProcessMask(SSTHandler::permDiode);
           trigMask |= block_sst_mask;
           break;
@@ -284,5 +286,5 @@
   for (set<string>::iterator i = copy.begin(); i != copy.end(); i++) {
     double smp = file1stSamp[*i];
-    double t   = tBlock0 + smp * perEch/86400.;
+    double t   = archParam.acq.tBlock0 + smp * archParam.acq.perEch/86400.;
     if (t>tEnd) {  // premier echantillon apres tEnd
      files.erase(*i);
@@ -416,5 +418,9 @@
      case sstStarZ:
      case sstStarF:
-       return (file->lastSST() != NULL) && (file->getSSTStarZ(index, imes) >= 0);
+     case sstStarT:{
+       if (file->lastSST() == NULL) return false;
+       int n = file->getNumbStar(imes);
+       return (n > 0 && imes < n);
+       }
      case gyroRaw:
        return (file->lastGyro() != NULL);
@@ -472,5 +478,5 @@
        return getSampleIndex();
      case internalTime:
-       return getSampleIndex() * perEch;
+       return getSampleIndex() * archParam.acq.perEch;
      case mjd:
        return getMJD();
@@ -487,4 +493,6 @@
      case sstStarF:
        return file->getSSTStarF(index, imes);
+     case sstStarT:
+       return file->getSSTStarT(index, imes);
      case gyroRaw:
        return file->getGyro(index, imes);
@@ -535,4 +543,5 @@
      case sstStarZ:
      case sstStarF:
+     case sstStarT:
        return file->blockNum() == file->getSSTBlockNum();
      case gyroRaw:
@@ -616,5 +625,5 @@
   if (!initDone) Init();
   int sample = getSampleIndex();
-  return tBlock0 + sample*perEch/86400.;
+  return archParam.acq.tBlock0 + sample*archParam.acq.perEch/86400.;
 }
  
Index: /trunk/Poubelle/archTOI.old/toiiter.h
===================================================================
--- /trunk/Poubelle/archTOI.old/toiiter.h	(revision 393)
+++ /trunk/Poubelle/archTOI.old/toiiter.h	(revision 394)
@@ -25,4 +25,5 @@
   sstStarZ,   // numero de diode d''une eventuelle etoile,   i=etoile 0..n
   sstStarF,   // flux d''une eventuelle etoile,             <0 si moins de i+1 etoiles
+  sstStarT,   // temps d''une eventuelle etoile,            <0 si moins de i+1 etoiles
   gyroRaw,    // valeur brute du gyro, index = 0,1,2
   gpsTime,    // temps fourni par GPS
@@ -101,6 +102,6 @@
    double tStart, tEnd;
    
-   double tBlock0;  // MJD du bloc numero zero...
-   double perEch;   // periode d''echantillonage en secondes
+   //double tBlock0;  // MJD du bloc numero zero...
+   //double perEch;   // periode d''echantillonage en secondes
    
    struct info {
Index: /trunk/Poubelle/archTOI.old/toisvr.cc
===================================================================
--- /trunk/Poubelle/archTOI.old/toisvr.cc	(revision 393)
+++ /trunk/Poubelle/archTOI.old/toisvr.cc	(revision 394)
@@ -21,12 +21,4 @@
 }
 
-
-void TOISvr::SetMJD0(double t0) {
-  iter.tBlock0 = t0;
-}
-
-void TOISvr::SetPerEch(double t0) { // en secondes, periode d'echantillonnage
-  iter.perEch = t0;
-}
 
 void TOISvr::OnBoardRecorderFiles(bool x) {
Index: /trunk/Poubelle/archTOI.old/toisvr.h
===================================================================
--- /trunk/Poubelle/archTOI.old/toisvr.h	(revision 393)
+++ /trunk/Poubelle/archTOI.old/toisvr.h	(revision 394)
@@ -17,6 +17,4 @@
   void AddFile(string);
   void OnBoardRecorderFiles(bool);
-  void SetMJD0(double);
-  void SetPerEch(double);
   void UseAuxGPS(AuxGPS* gps);
   
Index: /trunk/Poubelle/archTOI.old/transfelec.cc
===================================================================
--- /trunk/Poubelle/archTOI.old/transfelec.cc	(revision 394)
+++ /trunk/Poubelle/archTOI.old/transfelec.cc	(revision 394)
@@ -0,0 +1,37 @@
+#include "transfelec.h"
+
+
+// Parametres du circuit electrique de lecture SST
+// Valeurs Importantes du circuit electrique: 4 filtres
+
+static double T1=0.15; 		static double C1=1.5e-9;	// Farad
+static double T2=5.e-4; 								// secondes
+static double R2=1.E9; 									// Ohm
+static double T3=4.7e-3; 								// secondes
+static double R4=1.e5; 		static double R3=1.8e3;		// Ohm
+static double T4=4.84e-3;
+
+
+Dcomplex TransFuncElec::TsFunc(double w){
+	Dcomplex tempComp= H1(w)*H2(w)*H3(w)*H4(w); 			// Omega en radian/s
+	return tempComp;
+}
+
+Dcomplex TransFuncElec::H1(double w) {
+	Dcomplex tempComp=jImagPur*T1*w/(1.+jImagPur*T1*w); 	// passe haut
+	return tempComp;
+}
+
+Dcomplex TransFuncElec::H2(double w) {
+	return R2/(1.+jImagPur*T2*w); 		// passe bas leger
+}
+		
+Dcomplex TransFuncElec::H3(double w) {
+	return 1.+ R4/(R3*(1.+jImagPur*T3*w));  // passe bas dominant n°1
+}
+		
+Dcomplex TransFuncElec::H4(double w) {
+	if (w==0.) return 0.;
+	else return 1./(1.+jImagPur*T4*w);		// passe bas dominant n°2
+}
+
Index: /trunk/Poubelle/archTOI.old/transfelec.h
===================================================================
--- /trunk/Poubelle/archTOI.old/transfelec.h	(revision 394)
+++ /trunk/Poubelle/archTOI.old/transfelec.h	(revision 394)
@@ -0,0 +1,33 @@
+#ifndef TRANSFELEC_SEEN
+#define TRANSFELEC_SEEN
+
+//#include <math.h>
+
+#ifdef __MWERKS__
+	#include <complex.h>
+#else	
+	#include <complex>
+#endif 
+
+
+typedef complex<double> Dcomplex;
+
+
+class TransFuncElec{
+public:
+	TransFuncElec() {
+		Dcomplex Imag((double)0.,(double)1.);
+		jImagPur=Imag;
+	}
+	~TransFuncElec(){ }
+	Dcomplex TsFunc(double Omega);
+			// Omega en radian/s	
+private:
+	Dcomplex H1(double w);
+	Dcomplex H2(double w);
+	Dcomplex H3(double w);
+	Dcomplex H4(double w);
+	Dcomplex jImagPur;
+};
+
+#endif
Index: /trunk/Poubelle/archTOI.old/trigtbl.h
===================================================================
--- /trunk/Poubelle/archTOI.old/trigtbl.h	(revision 394)
+++ /trunk/Poubelle/archTOI.old/trigtbl.h	(revision 394)
@@ -0,0 +1,164 @@
+/*
+** Please only distribute this with it's associated FHT routine.
+** This algorithm is apparently patented(!) and the code copyrighted. 
+** See the comment with the fht routine for more info.
+**   -Thanks,
+**   Ron Mayer
+*/
+
+#ifdef REAL
+#else
+#define REAL double
+#endif
+
+#ifdef GOOD_TRIG
+#else
+#define FAST_TRIG
+#endif
+
+#if defined(GOOD_TRIG)
+#define FHT_SWAP(a,b,t) {(t)=(a);(a)=(b);(b)=(t);}
+#define TRIG_VARS					         \
+      int t_lam=0;
+#define TRIG_INIT(k,c,s)					 \
+     {								 \
+      int i;							 \
+      for (i=2 ; i<=k ; i++)					 \
+          {coswrk[i]=costab[i];sinwrk[i]=sintab[i];}		 \
+      t_lam = 0;					         \
+      c = 1;							 \
+      s = 0;							 \
+     }
+#define TRIG_NEXT(k,c,s)					 \
+     {								 \
+	 int i,j;	                                         \
+         (t_lam)++;	  					 \
+         for (i=0 ; !((1<<i)&t_lam) ; i++);			 \
+         i = k-i;						 \
+         s = sinwrk[i];						 \
+         c = coswrk[i];						 \
+         if (i>1)   						 \
+            {	    						 \
+             for (j=k-i+2 ; (1<<j)&t_lam ; j++);		 \
+             j	       = k - j;					 \
+             sinwrk[i] = halsec[i] * (sinwrk[i-1] + sinwrk[j]);  \
+             coswrk[i] = halsec[i] * (coswrk[i-1] + coswrk[j]);  \
+            }                                                    \
+     }
+#define TRIG_RESET(k,c,s)
+#endif
+
+#if defined(FAST_TRIG)
+#define TRIG_VARS					 \
+      REAL t_c,t_s;
+#define TRIG_INIT(k,c,s)				 \
+    {				        		 \
+     t_c  = costab[k];				         \
+     t_s  = sintab[k];				         \
+     c    = 1;				    		 \
+     s    = 0;				    		 \
+    }
+#define TRIG_NEXT(k,c,s)				 \
+    {                                                    \
+     REAL t = c;                                         \
+     c   = t*t_c - s*t_s;				 \
+     s   = t*t_s + s*t_c;				 \
+    }
+#define TRIG_RESET(k,c,s)
+#endif
+
+static REAL halsec[20]=
+    {
+     0,
+     0,
+     .54119610014619698439972320536638942006107206337801,
+     .50979557910415916894193980398784391368261849190893,
+     .50241928618815570551167011928012092247859337193963,
+     .50060299823519630134550410676638239611758632599591,
+     .50015063602065098821477101271097658495974913010340,
+     .50003765191554772296778139077905492847503165398345,
+     .50000941253588775676512870469186533538523133757983,
+     .50000235310628608051401267171204408939326297376426,
+     .50000058827484117879868526730916804925780637276181,
+     .50000014706860214875463798283871198206179118093251,
+     .50000003676714377807315864400643020315103490883972,
+     .50000000919178552207366560348853455333939112569380,
+     .50000000229794635411562887767906868558991922348920,
+     .50000000057448658687873302235147272458812263401372
+    };
+static REAL costab[20]=
+    {
+     .00000000000000000000000000000000000000000000000000,
+     .70710678118654752440084436210484903928483593768847,
+     .92387953251128675612818318939678828682241662586364,
+     .98078528040323044912618223613423903697393373089333,
+     .99518472667219688624483695310947992157547486872985,
+     .99879545620517239271477160475910069444320361470461,
+     .99969881869620422011576564966617219685006108125772,
+     .99992470183914454092164649119638322435060646880221,
+     .99998117528260114265699043772856771617391725094433,
+     .99999529380957617151158012570011989955298763362218,
+     .99999882345170190992902571017152601904826792288976,
+     .99999970586288221916022821773876567711626389934930,
+     .99999992646571785114473148070738785694820115568892,
+     .99999998161642929380834691540290971450507605124278,
+     .99999999540410731289097193313960614895889430318945,
+     .99999999885102682756267330779455410840053741619428
+    };
+static REAL sintab[20]=
+    {
+     1.0000000000000000000000000000000000000000000000000,
+     .70710678118654752440084436210484903928483593768846,
+     .38268343236508977172845998403039886676134456248561,
+     .19509032201612826784828486847702224092769161775195,
+     .09801714032956060199419556388864184586113667316749,
+     .04906767432741801425495497694268265831474536302574,
+     .02454122852291228803173452945928292506546611923944,
+     .01227153828571992607940826195100321214037231959176,
+     .00613588464915447535964023459037258091705788631738,
+     .00306795676296597627014536549091984251894461021344,
+     .00153398018628476561230369715026407907995486457522,
+     .00076699031874270452693856835794857664314091945205,
+     .00038349518757139558907246168118138126339502603495,
+     .00019174759731070330743990956198900093346887403385,
+     .00009587379909597734587051721097647635118706561284,
+     .00004793689960306688454900399049465887274686668768
+    };
+static REAL coswrk[20]=
+    {
+     .00000000000000000000000000000000000000000000000000,
+     .70710678118654752440084436210484903928483593768847,
+     .92387953251128675612818318939678828682241662586364,
+     .98078528040323044912618223613423903697393373089333,
+     .99518472667219688624483695310947992157547486872985,
+     .99879545620517239271477160475910069444320361470461,
+     .99969881869620422011576564966617219685006108125772,
+     .99992470183914454092164649119638322435060646880221,
+     .99998117528260114265699043772856771617391725094433,
+     .99999529380957617151158012570011989955298763362218,
+     .99999882345170190992902571017152601904826792288976,
+     .99999970586288221916022821773876567711626389934930,
+     .99999992646571785114473148070738785694820115568892,
+     .99999998161642929380834691540290971450507605124278,
+     .99999999540410731289097193313960614895889430318945,
+     .99999999885102682756267330779455410840053741619428
+    };
+static REAL sinwrk[20]=
+    {
+     1.0000000000000000000000000000000000000000000000000,
+     .70710678118654752440084436210484903928483593768846,
+     .38268343236508977172845998403039886676134456248561,
+     .19509032201612826784828486847702224092769161775195,
+     .09801714032956060199419556388864184586113667316749,
+     .04906767432741801425495497694268265831474536302574,
+     .02454122852291228803173452945928292506546611923944,
+     .01227153828571992607940826195100321214037231959176,
+     .00613588464915447535964023459037258091705788631738,
+     .00306795676296597627014536549091984251894461021344,
+     .00153398018628476561230369715026407907995486457522,
+     .00076699031874270452693856835794857664314091945205,
+     .00038349518757139558907246168118138126339502603495,
+     .00019174759731070330743990956198900093346887403385,
+     .00009587379909597734587051721097647635118706561284,
+     .00004793689960306688454900399049465887274686668768
+    };
