Index: /trunk/AddOn/TAcq/README
===================================================================
--- /trunk/AddOn/TAcq/README	(revision 3871)
+++ /trunk/AddOn/TAcq/README	(revision 3872)
@@ -29,7 +29,8 @@
   - racquproc.h racquproc.cc : la classe thread de traitement des donnees
 
-        ================ Remote ====================
+        
 
-5/ Ensemble de classes + programme test developpes en 2005, pour I/O PPF sur 
+5/  ================ Remote ==================== 
+  Ensemble de classes + programme test developpes en 2005, pour I/O PPF sur 
    stream IP - provenaant du repertoire Remote
   - swrapsock.h swrapsock.cc : Classes Socker ServerSocket ClientSocket 
@@ -50,5 +51,5 @@
    serverName : Name or IP adress of the machine where tsok S is running 
    NLoop,SizeX,SizeY: Number of transfers, 2D array size for OPEMsg=PPFSOCKET 
-
+   ================================================
 
 6/ --- Avril 2009 
@@ -65,2 +66,19 @@
      de plusieurs fibres dans un meme objet RAcqMemZoneMgr
    o Amelioration de la classe MiniFITSFile pour permettre l'ajout d'information ds l'entete FITS
+
+8/ --- Novembre/Decembre 2009 
+   o Introduction des classes lecteur fits multi-fibres ( BRMultiFitsReader ), classe de base 
+   thread de traitement (BRBaseProcessor) 
+   o Classe d'ecriture de cube de donnees fits multi-fibres FitsCubeWriter 
+   o Classe de calcul de visibilites BRVisibilityCalculator 
+   o Introduction du nouveau programme d'acquisition mfacq.cc  (Nov 2009) 
+
+9/ --- Avril/Mai 2010 
+   o Calcul parallele pour visibilites ( BRVisCalcGroup )  
+   o Programme de lecture multi-fibres (treadmfib) calcul des visibilites (vismfib) 
+   o Nouvelle structuire du programme d'acquisition pour echange sur ethernet 
+     Classes PCIEToEthernet , EthernetReader
+
+10/ --- Aout/Septembre 2010 
+   o Ajout processeur de calcul de TF sur donnees brutes ( BRFFTCalculator )
+   o Amelioration classe BRMeanSpecCalculator et ajout programme specmfib.cc
Index: /trunk/AddOn/TAcq/branap.cc
===================================================================
--- /trunk/AddOn/TAcq/branap.cc	(revision 3871)
+++ /trunk/AddOn/TAcq/branap.cc	(revision 3872)
@@ -25,4 +25,5 @@
   nzones_=nzon;
   npaqinzone_=npaqz;
+  fgdatafft_=false;  fgsinglechannel_=false;
   prtlevel_=0;
   nbcalgrp_=1;
@@ -150,5 +151,5 @@
   char flnm[1024];
   sprintf(flnm,"%s/signal%d.fits",dirlist_[0].c_str(),imin_);
-  return DecodeMiniFitsHeader(flnm,paqsize_, npaqinfile_); 
+  return DecodeMiniFitsHeader(flnm,paqsize_, npaqinfile_,fgdatafft_, fgsinglechannel_); 
 }
 
@@ -165,4 +166,6 @@
   cout << " PaqSize=" << paqsize_ << "  -  NZones=" << nzones_ << " NPaqZone=" << npaqinzone_ 
        << " PrtLevel=" << prtlevel_ << endl;
+  cout << " AcqMode: " << ((fgdatafft_)?" Data_FFT " : " Data_Raw " ) 
+       << ((fgsinglechannel_)?" SingleChannel " : " TwoChannels " ) << endl;
   cout << " NbVisibCalculator in Group: " <<  nbcalgrp_ << " with N//threads: " << nthreads_ << endl;
 
@@ -172,12 +175,16 @@
 
 /* --Fonction-- */
-int BRAnaParam::DecodeMiniFitsHeader(const char* filename, uint_4& paqsz, uint_4& npaq) 
+int BRAnaParam::DecodeMiniFitsHeader(const char* filename, uint_4& paqsz, uint_4& npaq, 
+                                     bool& fgdatafft, bool& fgsinglechannel) 
 {
   cout << " DecodeMiniFitsHeader - Opening file: " << filename << endl;
   MiniFITSFile mff(filename, MF_Read);
+  string acqmode=mff.GetKeyValue("ACQMODE");
   cout << "DecodeMiniFitsHeader()... Type=" << mff.DataTypeToString() << " NAxis1=" << mff.NAxis1() 
-       << " NAxis2=" << mff.NAxis2() << endl;
+       << " NAxis2=" << mff.NAxis2() << " AcqMode=" << acqmode << endl;
   paqsz = mff.NAxis1();
   npaq = mff.NAxis2();
+  if (acqmode.substr(0,3)=="fft") fgdatafft=true;
+  if (acqmode.find("1c") < acqmode.length()) fgsinglechannel=true;
   return 0;
 }
Index: /trunk/AddOn/TAcq/branap.h
===================================================================
--- /trunk/AddOn/TAcq/branap.h	(revision 3871)
+++ /trunk/AddOn/TAcq/branap.h	(revision 3872)
@@ -25,5 +25,6 @@
   ostream& Print(ostream& os);
 
-  static int DecodeMiniFitsHeader(const char* filename, uint_4& paqsz, uint_4& npaq);
+  static int DecodeMiniFitsHeader(const char* filename, uint_4& paqsz, uint_4& npaq, 
+                                  bool& fgdatafft, bool& fgsinglechannel);
 
   vector<string> dirlist_;
@@ -37,4 +38,6 @@
   uint_4 nzones_, npaqinzone_;
   uint_4 npaqinfile_;    // nombre de paquets dans un fichier p
+  bool fgdatafft_;  // true -> donnee FFT (provenant du firmware FFT)
+  bool fgsinglechannel_; // true -> un seul canal par fibre (par defaut=2 canaux/fibres)
   int prtlevel_;
   uint_4 nbcalgrp_;    // Nb d'objets/threads dans BRVisCalcGroup 
Index: /trunk/AddOn/TAcq/brbaseproc.cc
===================================================================
--- /trunk/AddOn/TAcq/brbaseproc.cc	(revision 3871)
+++ /trunk/AddOn/TAcq/brbaseproc.cc	(revision 3872)
@@ -18,5 +18,7 @@
 /* --Methode-- */
 BRBaseProcessor::BRBaseProcessor(RAcqMemZoneMgr& memgr, MemZaction mmact)
-  : memgr_(memgr), vpaq_(memgr.NbFibres()), vpchk_(memgr.NbFibres()), vfgok_(memgr.NbFibres()), 
+  : memgr_(memgr), fbuff_(memgr.NbFibres()), fprocbuff_(memgr.NbFibres()),
+    vpaq_(memgr.NbFibres()), vprocpaq_(memgr.NbFibres()),
+    vpchk_(memgr.NbFibres()), vfgok_(memgr.NbFibres()), 
     curfc_(memgr.NbFibres()), fcfirst_(memgr.NbFibres()), ttfirst_(memgr.NbFibres())
 {
@@ -24,6 +26,8 @@
   stop_ = false;
   for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  {
-    fbuff_.push_back(NULL);
+    fbuff_[fib]=NULL; 
+    fprocbuff_[fib]=NULL; 
     vpaq_[fib]=BRPaquet(NULL,memgr_.PaqSize());
+    vprocpaq_[fib]=NULL; 
     vpchk_[fib]=BRPaqChecker(true,0); 
     vfgok_[fib]=true;
@@ -75,8 +79,9 @@
   int rc=0;
   try {
-    cout << " BRBaseProcessor[" << bpid_ << "]::run() - Starting " << " NFibers=" << memgr_.NbFibres() 
-	 << " NChan=" << 2*memgr_.NbFibres() << endl;	
+    cout << "BRBaseProcessor[" << bpnom_ << "," << bpid_ << "]::run() - Starting " << " NFibers=" 
+	 << memgr_.NbFibres() << " NChan=" << 2*memgr_.NbFibres() << endl;	
 
     size_t paqsz=memgr_.PaqSize();
+    size_t procpaqsz=memgr_.ProcPaqSize();
     bool fgrun=true;
     while (fgrun) {
@@ -87,5 +92,5 @@
       //      if (buffg == NULL) {
       if (mid < 0) {
-	cout << "BRBaseProcessor[" << bpid_ << "]::run()/ERROR FindMemZoneId(" 
+	cout << "BRBaseProcessor[" << bpnom_ << "," << bpid_ << "]::run()/ERROR FindMemZoneId(" 
 	     << (int)mmact_ << ") ->" << mid << ") -> NULL" << endl;
 	setRC(7);      fgrun=false;		
@@ -95,5 +100,12 @@
 	fbuff_[fib] = memgr_.GetMemZone(mid,fib);
 	if (fbuff_[fib] == NULL) { // cela ne devrait pas arriver 
-	  cout << "BRBaseProcessor[" << bpid_ << "]::run()/ERROR memgr.GetMemZone(" << mid << "," << fib << ") -> NULL" << endl;
+	  cout << "BRBaseProcessor[" << bpnom_ << "," << bpid_ << "]::run()/ERROR memgr.GetMemZone(" 
+	       << mid << "," << fib << ") -> NULL" << endl;
+	  setRC(9);	  fgrun=false;		
+	  break;
+	}
+	if ((procpaqsz>0)&&((fprocbuff_[fib]=memgr_.GetProcMemZone(mid,fib))==NULL)) {   // cela ne devrait pas arriver non plus
+	  cout << "BRBaseProcessor[" << bpnom_ << "," << bpid_ << "]::run()/ERROR memgr.GetProcMemZone(" 
+	       << mid << "," << fib << ") -> NULL" << endl;
 	  setRC(9);	  fgrun=false;		
 	  break;
@@ -106,4 +118,5 @@
 	  vfgok_[fib] = vpchk_[fib].Check(vpaq_[fib],curfc_[fib]);
 	  if (!vfgok_[fib])  fgokallfibers_=false;
+	  if (procpaqsz>0)    vprocpaq_[fib] = fprocbuff_[fib]+jp*procpaqsz;
 	}
 	//--- Traitement 
@@ -124,5 +137,6 @@
     } // Fin de boucle sur les zones a traiter 
     //------------------------------------
-    cout << " ---- END BRBaseProcessor[" << bpid_ << "]::run() , TotNbProcPaq=" << totprocnpaq_ << endl;
+    cout << " ---- END BRBaseProcessor[" << bpnom_ << "," << bpid_ << "]::run() , TotNbProcPaq=" 
+	 << totprocnpaq_ << endl;
     /*
     for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  vpchk_[fib].Print();
@@ -131,10 +145,10 @@
   }
   catch (std::exception& exc) {
-    cout << " BRBaseProcessor[" << bpid_ << "]::run()/catched std::exception " << exc.what() << endl;
+    cout << "BRBaseProcessor[" << bpnom_ << "," << bpid_ << "]::run()/catched std::exception " << exc.what() << endl;
     setRC(98);	
     return; 
   }
   catch(...) {
-    cout << " BRBaseProcessor[" << bpid_ << "]::run()/catched unknown ... exception " << endl;
+    cout << "BRBaseProcessor[" << bpnom_ << "," << bpid_ << "]::run()/catched unknown ... exception " << endl;
     setRC(99);	
     return; 
Index: /trunk/AddOn/TAcq/brbaseproc.h
===================================================================
--- /trunk/AddOn/TAcq/brbaseproc.h	(revision 3871)
+++ /trunk/AddOn/TAcq/brbaseproc.h	(revision 3872)
@@ -46,5 +46,7 @@
   bool stop_;
   vector<Byte*> fbuff_;      // Vecteur de pointeur de zone memoire pour chaque fibre 
+  vector<Byte*> fprocbuff_;   // Vecteur de pointeur de proc_zone_mem pour chaque fibre 
   vector<BRPaquet> vpaq_;   // Vecteur de BRPaquet pour chaque fibre
+  vector<Byte*> vprocpaq_;  // Vecteur de pointeur de zone memoire pour donnees traitees de chaque paquet/fibre 
   vector<BRPaqChecker> vpchk_;
   vector<uint_8> vfgok_;    // Vecteur de flag si paquet OK pour chaque fibre
Index: /trunk/AddOn/TAcq/brproc.cc
===================================================================
--- /trunk/AddOn/TAcq/brproc.cc	(revision 3871)
+++ /trunk/AddOn/TAcq/brproc.cc	(revision 3872)
@@ -1,3 +1,6 @@
-#include "racquproc.h"
+//----------------------------------------------------------------
+// Projet BAORadio - (C) LAL/IRFU  2008-2010
+// Classes de threads de traitement pour BAORadio 
+//----------------------------------------------------------------
 
 #include <stdlib.h>
@@ -26,500 +29,4 @@
 #include "brproc.h"
 
-//---------------------------------------------------------------------
-// Classe de traitement - calcul de visibilite pour n fibres 
-//---------------------------------------------------------------------
-
-/* --Methode-- */
-BRVisibilityCalculator::BRVisibilityCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean, size_t nthr)
-  : BRBaseProcessor(memgr), paralex_(*this, nthr), nparthr_(nthr), 
-    outpath_(outpath), nmean_(nmean), nbcalc_(1), calcid_(0), vpdata_(2*memgr.NbFibres())
-    // , dtfos_(outpath+"visdt.fits", Fits_Create), visdt_(dtfos_, 1024, true);
-{  
-  DefineRank(1,0);
-
-  uint_4 maxnpairs = (2*memgr_.NbFibres()+1)*memgr_.NbFibres();
-  chanum_.SetSize(maxnpairs);
-  sa_size_t k=0;
-  for(size_t i=0; i<2*memgr_.NbFibres(); i++)  vpdata_[i]=NULL;
-  for(size_t i=0; i<2*memgr_.NbFibres(); i++) {
-    for(size_t j=i; j<2*memgr_.NbFibres(); j++) {
-      chanum_(k) = (i+1)*100+(j+1);  k++;
-    }
-  }
-  SelectPairs();
-
-  //  visdt_.AddFloatColumn("mfc");
-  visdt_.AddDoubleColumn("mfc");
-  visdt_.AddDoubleColumn("mtt");
-  visdt_.AddIntegerColumn("jfreq");
-  visdt_.AddIntegerColumn("numch");
-  visdt_.AddFloatColumn("vre");
-  visdt_.AddFloatColumn("vim");
-
-  if (nmean_ < 1)  nmean_=memgr_.NbPaquets();
-  if (nmean_ < 1)  nmean_=1;
-
-  cout << " BRVisibilityCalculator::/Info  nmean=" << nmean_ << endl;
-
-  totnbpaq_=0;
-  numfile_=0;
-  nb_flop_=0.;
-  moyfc_=moytt_=0.;
-
-  fgallfibok=NULL;
-  fgcktt_=false;
-  setNameId("viscalc", 0); 
-}
-
-/* --Methode-- */
-BRVisibilityCalculator::~BRVisibilityCalculator()
-{
-  cout << " BRVisibilityCalculator - Visibility Datatable : " << endl;
-  cout << visdt_;
-  string filename;
-  filename = outpath_+"visdt.ppf";
-  if (nbcalc_>1) {
-    char sbuff[32];
-    sprintf(sbuff,"visdt_%d",(int)calcid_);
-    filename = outpath_+sbuff;
-  }
-  POutPersist po(filename);
-  po << visdt_;
-  if (calcid_ == 0) {
-    POutPersist poc(outpath_+"chanum.ppf");
-    poc << chanum_;
-  
-    if (fgcktt_) {
-      cout << " BRVisibilityCalculator -  Check TimeTag done: TotNPaqProc= " << totnbpaq_ << endl;
-      for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  {
-	cout << " BRTTCheck-Fiber[" << fib << "] NBadTT=" << vbadtt_[fib] << " NDiffTT>5="
-	     << vndiff5tt_[fib] << "  NotSameTT=" << vnsamett_[fib] << endl; 
-      }
-      POutPersist pott(outpath_+"ttfcmtx.ppf");
-      pott << PPFNameTag("FC") << fcmtx_; 
-      pott << PPFNameTag("TT") << ttmtx_;     
-    }
-  }
-}
-
-/* --Methode-- */
-void BRVisibilityCalculator::DefineRank(uint_4 nbc, uint_4 cid)
-{
-  if ((nbc>6)||(cid>=nbc)) 
-    throw ParmError("BRVisibilityCalculator::DefineRank() NbCalc > 6 !");
-  nbcalc_=nbc;
-  calcid_=cid;
-  if (nbcalc_>1) {
-    uint_4 maxnpairs = (2*memgr_.NbFibres()+1)*memgr_.NbFibres();
-    uint_4 npairs=maxnpairs/nbcalc_;
-    if (calcid_==(nbcalc_-1)) 
-      SelectPairs(calcid_*npairs, maxnpairs-calcid_*npairs);
-    else 
-      SelectPairs(calcid_*npairs, npairs);
-    MemZaction mmzas[6]={MemZA_ProcA,MemZA_ProcB,MemZA_ProcC,MemZA_ProcD,MemZA_ProcE,MemZA_ProcF};
-    SetMemZAction(mmzas[calcid_]);
-    setNameId("viscalc_grp", calcid_); 
-  }
-  return ;
-}
-
-/* --Methode-- */
-uint_4 BRVisibilityCalculator::SelectPairs(uint_4 pair1, uint_4 nbpairs)
-{
-  BRPaquet paq(memgr_.PaqSize());
-  uint_4 maxnpairs = (2*memgr_.NbFibres()+1)*memgr_.NbFibres();
-
-  if (pair1 >= maxnpairs)  pair1=maxnpairs-1;
-  if (nbpairs > maxnpairs-pair1)  nbpairs=maxnpairs-pair1;
-  pairst_=pair1;
-  nbpairs_=nbpairs;
-  vismtx_.SetSize(nbpairs_, paq.DataSize()/4); 
-  return nbpairs_;
-}
-
-/* --Methode-- */
-int BRVisibilityCalculator::SelectFreqBinning(uint_4 freq1, uint_4 freq2, uint_4 nbfreq)
-{
-  jf1_=freq1; jf2_=freq2;
-  if ((jf1_<1)||(jf1_>=vismtx_.NCols()))  jf1_=1;
-  if ((jf2_<1)||(jf2_>=vismtx_.NCols())||(jf2_<jf1_))  jf2_=vismtx_.NCols()-1;
-  if (nbfreq<1) nbfreq=1;
-  djf_=(jf2_-jf1_)/nbfreq;
-  if (djf_<1) djf_=0;
-  cout << " BRVisibilityCalculator::SelectFreqBinning/Info  JF1=" << jf1_ 
-       << " JF2=" << jf2_ << " DJF=" << djf_ << endl;
-
-}
-
-
-/* --Methode-- */
-int BRVisibilityCalculator::ActivateTimeTagCheck(uint_8 maxnpaq)
-{
-  mindeltatt_=memgr_.PaqSize()/2;
-  if (mindeltatt_<1) mindeltatt_=1;
-  fcmtx_.SetSize(memgr_.NbFibres(), maxnpaq);
-  ttmtx_.SetSize(memgr_.NbFibres(), maxnpaq);
-  vlasttt_.resize(memgr_.NbFibres(), 0);
-  vbadtt_.resize(memgr_.NbFibres(), 0);
-  vnsamett_.resize(memgr_.NbFibres(), 0);
-  vndiff5tt_.resize(memgr_.NbFibres(), 0);
-
-  fgcktt_=true;
-  cout << " BRVisibilityCalculator::ActivateTimeTagCheck() - TT/Fc matrix NCols=" << maxnpaq 
-       << " MinDeltaTT=" << mindeltatt_ << endl;
-
-  return 0;
-}
-
-
-/* --Methode-- */
-void BRVisibilityCalculator::run()
-{
-  cout << " BRVisibilityCalculator[" << calcid_ << "/" << nbcalc_ 
-       << "]::run() - Starting " << " NFibers=" << memgr_.NbFibres() 
-       << " NChan=" << 2*memgr_.NbFibres() << " NPairs=" << nbpairs_ << " First:" << pairst_ << endl;	
-  
-  if (nparthr_ < 2)  return BRBaseProcessor::run();
-  // Execution multithread parallele
-  setRC(1);	
-  int rc=0;
-  try {
-    if ((nmean_%memgr_.NbPaquets())!=0) {
-      uint_4 mnmean = (nmean_/memgr_.NbPaquets()+1)*memgr_.NbPaquets();
-      cout << " BRVisibilityCalculator::run()/Info changing nmean=" << nmean_  << " to multiple of"
-	   << " memgr_.NbPaquets() -> " << mnmean << endl;
-      nmean_=mnmean;
-    }
-    paralex_.SetParallelTask(*this);
-    cout << " BRVisibilityCalculator::run()/Info : starting ParallelExecutor with nThreads=" 
-	 << paralex_.nThreads() << " ... " << endl;
-    paralex_.start();
-
-    fgallfibok = new bool[memgr_.NbPaquets()];
-
-    size_t paqsz=memgr_.PaqSize();
-    bool fgrun=true;
-    while (fgrun) {
-      if (stop_) break;
-      if (memgr_.GetRunState() == MemZR_Stopped) break;
-      int mid = memgr_.FindMemZoneId(mmact_);  // (MemZA_ProcA);
-      //      Byte* buffg = memgr_.GetMemZone(mid);
-      //      if (buffg == NULL) {
-      if (mid < 0) {
-	cout << "BRVisibilityCalculator[" << calcid_ << "]::run()/ERROR FindMemZoneId(" 
-	     << (int)mmact_ << ") ->" << mid << ") -> NULL" << endl;
-	setRC(7);      fgrun=false;		
-	break;	
-      }
-      for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
-	fbuff_[fib] = memgr_.GetMemZone(mid,fib);
-	if (fbuff_[fib] == NULL) { // cela ne devrait pas arriver 
-	  cout << "BRVisibilityCalculator[" << calcid_ << "]::run()/ERROR memgr.GetMemZone(" << mid << "," << fib << ") -> NULL" << endl;
-	  setRC(9);	  fgrun=false;		
-	  break;
-	}
-      }
-
-      if (totnbpaq_%nmean_ == 0) {
-	if (totnbpaq_ > 0) {
-	  moyfc_/=nmean_;
-	  moytt_/=nmean_;
-	  vismtx_.Info()["MeanFC"] = moyfc_;
-	  vismtx_.Info()["MeanTT"] = moytt_;
-	  vismtx_.Info()["NPAQSUM"] = nmean_;
-	  
-	  // ATTENTION : Matrice visibilites non moyennee 
-	  char nfile[48];
-	  if (nbcalc_==1) 
-	    sprintf(nfile,"vismtx%d.ppf",numfile_);
-	  else 
-	    sprintf(nfile,"vismtx_%d_%d.ppf",(int)calcid_,numfile_);
-	  string flnm=outpath_+nfile;
-	  POutPersist po(flnm);
-	  po << vismtx_;
-	  cout << numfile_ << "-BRVisibilityCalculator[" << calcid_ << "]::run() NPaqProc="
-	       << totnbpaq_ << "  -> Visibility Matrix in " << flnm << endl;
-	  FillVisibTable(moyfc_, moytt_);
-	  numfile_++;
-	}
-	vismtx_ = complex<r_4>((r_4)0.,(r_4)0.);
-	moyfc_=moytt_=0.;
-      }
-
-      for(size_t jp=0; jp<memgr_.NbPaquets(); jp++) {   // boucle sur les paquets d'une zone  
-	fgallfibok[jp]=fgokallfibers_=true;
-	for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
-	  vpaq_[fib].Set(fbuff_[fib]+jp*paqsz);
-	  vfgok_[fib] = vpchk_[fib].Check(vpaq_[fib],curfc_[fib]);
-	  if (!vfgok_[fib])  fgallfibok[jp]=fgokallfibers_=false;
-	}
-	if (fgokallfibers_)  {
-	  if (totprocnpaq_==0) {
-	    for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  {
-	      fcfirst_[fib]=curfc_[fib];
-	      ttfirst_[fib]=vpaq_[fib].TimeTag();
-	    }
-	  }
-	  totprocnpaq_++;
-	  moyfc_ += curfc_[0];
-	  moytt_ += (vpaq_[0].TimeTag()-ttfirst_[0]);
-	  if ((fgcktt_)&&(calcid_==0))  CheckTimeTag();
-	  totnbpaq_++;
-	}
-      }  // Fin de boucle sur les paquets 
-      
-      // Execution parallele  pour calcul des visibilites par bandes de frequence
-      int rcpex=paralex_.execute();
-      if (rcpex!=0)  cout << " BRVisibilityCalculator[" << calcid_ << "]::run() / Error Rc[paralex_.execute()]=" << rcpex << endl;
-
-      memgr_.FreeMemZone(mid, mmsta_);  // (MemZS_ProcA);
-    } // Fin de boucle sur les zones a traiter 
-    //------------------------------------
-    cout << " --------- END BRVisibilityCalculator[" << calcid_ << "]::run() , TotNbProcPaq=" << totprocnpaq_ << endl;
-    /*
-    for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  vpchk_[fib].Print();
-    cout << " ------------------------------------ " << endl;
-    */
-    delete[] fgallfibok;
-  }
-  catch (std::exception& exc) {
-    cout << " BRVisibilityCalculator[" << calcid_ << "]::run()/catched std::exception " << exc.what() << endl;
-    setRC(98);	
-    return; 
-  }
-  catch(...) {
-    cout << " BRVisibilityCalculator[" << calcid_ << "]::run()/catched unknown ... exception " << endl;
-    setRC(99);	
-    return; 
-  }
-  
-}
-
-/* --Methode-- */
-int BRVisibilityCalculator::Process()
-{
-    
-  for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
-    vpdata_[2*fib] = vpaq_[fib].Data1C();
-    vpdata_[2*fib+1] = vpaq_[fib].Data2C();
-  }
-  
-  if (totnbpaq_%nmean_ == 0) {
-    if (totnbpaq_ > 0) {
-      moyfc_/=nmean_;
-      moytt_/=nmean_;
-      vismtx_.Info()["MeanFC"] = moyfc_;
-      vismtx_.Info()["MeanTT"] = moytt_;
-      vismtx_.Info()["NPAQSUM"] = nmean_;
-
-      // ATTENTION : Matrice visibilites non moyennee 
-      char nfile[48];
-      if (nbcalc_==1) 
-	sprintf(nfile,"vismtx%d.ppf",numfile_);
-      else 
-	sprintf(nfile,"vismtx_%d_%d.ppf",(int)calcid_,numfile_);
-      string flnm=outpath_+nfile;
-      POutPersist po(flnm);
-      po << vismtx_;
-      cout << numfile_ << "-BRVisibilityCalculator::Process() NPaqProc="
-	   << totnbpaq_ << "  -> Visibility Matrix in " << flnm << endl;
-      FillVisibTable(moyfc_, moytt_);
-      numfile_++;
-    }
-    vismtx_ = complex<r_4>((r_4)0.,(r_4)0.);
-    moyfc_=moytt_=0.;
-  }
-
-  sa_size_t k=0;
-  for(size_t i=0; i<vpdata_.size(); i++) {
-    for(size_t j=i; j<vpdata_.size(); j++) {
-      size_t kpair=i*vpdata_.size()+j;
-      if (kpair<pairst_)  continue;
-      if (kpair>=(pairst_+nbpairs_))  break;
-      TVector< complex<r_4> > vis = vismtx_.Row(k);   k++;
-      for(sa_size_t f=1; f<vis.Size(); f++) {
-	vis(f) += complex<r_4>((r_4)vpdata_[i][f].realB(), (r_4)vpdata_[i][f].imagB()) * 
-	  complex<r_4>((r_4)vpdata_[j][f].realB(), -(r_4)vpdata_[j][f].imagB());
-      }
-      nb_flop_ += (7.*(r_8)vis.Size());
-    }
-  }
-
-  moyfc_ += curfc_[0];
-  moytt_ += (vpaq_[0].TimeTag()-ttfirst_[0]);
-  if ((fgcktt_)&&(calcid_==0))  CheckTimeTag();
-  totnbpaq_++;
-  return 0;
-}
-
-/* --Methode-- */
-int BRVisibilityCalculator::execute(int tid)
-{
-  vector<TwoByteComplex*>  pvpdata(2*memgr_.NbFibres());
-  size_t paqsz=memgr_.PaqSize();
-  BRPaquet ppaq(paqsz);
-
-  sa_size_t fdelt = vismtx_.NCols()/nparthr_;
-  sa_size_t fdeb = tid*fdelt;
-  sa_size_t ffin = (tid+1)*fdelt;
-
-  if (fdeb<1) fdeb=1;
-  if ((ffin>vismtx_.NCols())||(tid==(nparthr_-1))) ffin=vismtx_.NCols();
-
-  for(size_t jp=0; jp<memgr_.NbPaquets(); jp++) {   // boucle sur les paquets d'une zone  
-    if (!fgallfibok[jp])  continue;
-    for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
-      ppaq.Set(fbuff_[fib]+jp*paqsz);
-      pvpdata[2*fib] = ppaq.Data1C();
-      pvpdata[2*fib+1] = ppaq.Data2C();
-    }
-    sa_size_t k=0;
-    for(size_t i=0; i<vpdata_.size(); i++) {
-      for(size_t j=i; j<vpdata_.size(); j++) {
-	size_t kpair=i*vpdata_.size()+j;
-	if (kpair<pairst_)  continue;
-	if (kpair>=(pairst_+nbpairs_))  break;
-	TVector< complex<r_4> > vis = vismtx_.Row(k);   k++;
-	for(sa_size_t f=fdeb; f<ffin; f++) {
-	  vis(f) += complex<r_4>((r_4)pvpdata[i][f].realB(), (r_4)pvpdata[i][f].imagB()) * 
-	    complex<r_4>((r_4)pvpdata[j][f].realB(), -(r_4)pvpdata[j][f].imagB());
-	}
-	nb_flop_ += (7.*(r_8)(ffin-fdeb));
-      }
-    }
-
-  }  // Fin de boucle sur les paquets 
-  
-  return 0;
-}
-
-/* --Methode-- */
-int BRVisibilityCalculator::FillVisibTable(double fcm, double ttm)
-{
-  double xnt[10];
-  xnt[0]=fcm;  xnt[1]=ttm/1.25e8;
-
-  if (djf_<2) {
-    for(sa_size_t rv=0; rv<vismtx_.NRows(); rv++) {
-      for(sa_size_t jf=jf1_; jf<jf2_; jf++) {
-	xnt[2]=jf;
-	xnt[3]=chanum_(rv+pairst_);
-	xnt[4]=vismtx_(rv,jf).real()/(r_4)(nmean_);
-	xnt[5]=vismtx_(rv,jf).imag()/(r_4)(nmean_);
-	visdt_.AddRow(xnt);
-      }
-    }
-  }
-  else {
-    for(sa_size_t rv=0; rv<vismtx_.NRows(); rv++) {
-      for(sa_size_t jf=jf1_; jf<jf2_; jf+=djf_) {
-	r_4 moyreal=0.;
-	r_4 moyimag=0.;
-	sa_size_t jjfmx=jf+djf_;
-	if (jjfmx > vismtx_.NCols()) jjfmx=vismtx_.NCols();
-	for(sa_size_t jjf=jf; jjf<jjfmx; jjf++) {
-	  moyreal+=vismtx_(rv,jjf).real();
-	  moyimag+=vismtx_(rv,jjf).imag();
-	}
-	xnt[2]=jf+djf_/2;
-	xnt[3]=chanum_(rv+pairst_);
-	xnt[4]=moyreal/(r_4)(nmean_*djf_);
-	xnt[5]=moyimag/(r_4)(nmean_*djf_);
-	visdt_.AddRow(xnt);
-      }
-    }
-  }
-  return 0;
-}
-
-/* --Methode-- */
-int BRVisibilityCalculator::CheckTimeTag()
-{
-  if (totnbpaq_==0) {
-    for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  {
-      vlasttt_[fib]=ttfirst_[fib];
-      if (ttmtx_.NCols()>0) {
-	fcmtx_(fib,totnbpaq_) = curfc_[fib]; 
-	ttmtx_(fib,totnbpaq_) = vlasttt_[fib]; 
-      }
-    }
-    return 0;
-  }
-  for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
-    int_8 ld = (int_8)vpaq_[fib].TimeTag()-(int_8)vlasttt_[fib];
-    int_8 fd = (int_8)vpaq_[fib].TimeTag()-(int_8)ttfirst_[fib]-(int_8)vpaq_[0].TimeTag()+(int_8)ttfirst_[0];
-    /*    if ( (ld < mindeltatt_) || (fd<-5) || (fd>5)) { vbadtt_[fib]++; vnsamett_[fib]++; }
-    else {
-      if (fd!=0)  vnsamett_[fib]++;
-    }
-    */
-    if  (ld < mindeltatt_) vbadtt_[fib]++;
-    else {
-      if (fd != 0)  vnsamett_[fib]++;
-      if ((fd<-5)||(fd>5))  vndiff5tt_[fib]++;
-    }
-    vlasttt_[fib]=vpaq_[fib].TimeTag();
-    if (totnbpaq_<ttmtx_.NCols()) {
-      fcmtx_(fib,totnbpaq_) = curfc_[fib]; 
-      ttmtx_(fib,totnbpaq_) = vlasttt_[fib]; 
-    }
-  }
-  return 0;
-}
-
-//-------------------------------------------------------------------------------
-// Classe Groupe (ensemble) de Calculateur de Visibilites, tourant en parallele
-//-------------------------------------------------------------------------------
-
-/* --Methode-- */
-BRVisCalcGroup::BRVisCalcGroup(size_t nbcalc, RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean, size_t nthr)
-  : tm_(false)
-{
-  if ((nbcalc<1)||(nbcalc>6)) 
-    throw ParmError("BRVisCalcGroup::BRVisCalcGroup NbCalc > 6 !");
-  for(size_t i=0; i<nbcalc; i++) {
-    BRVisibilityCalculator * viscp=new BRVisibilityCalculator(memgr, outpath, nmean, nthr);
-    viscp->DefineRank(nbcalc, i);
-    viscalcp_.push_back(viscp); 
-  }
-}
-/* --Methode-- */
-BRVisCalcGroup::~BRVisCalcGroup()
-{
-  for(size_t i=0; i<viscalcp_.size(); i++) 
-    delete viscalcp_[i];
-}
-/* --Methode-- */
-int BRVisCalcGroup::SelectFreqBinning(uint_4 freq1, uint_4 freq2, uint_4 nbfreq)
-{
-  int rc=0;
-  for(size_t i=0; i<viscalcp_.size(); i++) 
-    rc=viscalcp_[i]->SelectFreqBinning(freq1, freq2, nbfreq);
-  return rc;
-}
-/* --Methode-- */
-void BRVisCalcGroup::start()
-{
-  for(size_t i=0; i<viscalcp_.size(); i++) 
-    viscalcp_[i]->start();
-  tm_.SplitQ();
-}
-/* --Methode-- */
-void BRVisCalcGroup::join()
-{
-  r_8 totflop=0.;
-  for(size_t i=0; i<viscalcp_.size(); i++) {
-    viscalcp_[i]->join();
-    totflop += viscalcp_[i]->TotNbFLOP();
-  }
-  tm_.SplitQ();
-  cout << "      ----------------------------------------------------------" << endl;
-  cout << " BRVisCalcGroup::join() : Finished , Elaspsed time: " << tm_.PartialElapsedTimems() 
-       << " ms (total:" << tm_.TotalElapsedTimems() << ")" << endl;
-  cout << " ... TotalMegaFLOP= " << totflop/(1024.e3) << " @ " 
-       << totflop/(r_8)tm_.PartialElapsedTimems()/(1024) << " MFLOP/s" << endl; 
-  cout << "      ----------------------------------------------------------" << endl;
-  return;
-}
 
 
@@ -528,10 +35,18 @@
 //---------------------------------------------------------------------
 /* --Methode-- */
-BRMeanSpecCalculator::BRMeanSpecCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean)
-  : BRBaseProcessor(memgr), outpath_(outpath), nmean_(nmean)
-{
+BRMeanSpecCalculator::BRMeanSpecCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean, 
+					   bool fgdatafft, bool fgsinglechan)
+  : BRBaseProcessor(memgr), outpath_(outpath), nmean_(nmean),
+    fgdatafft_(fgdatafft), fgsinglechannel_(fgsinglechan)
+{
+  setNameId("meanSpecCalc",1);
   BRPaquet paq(memgr_.PaqSize());
-  mspecmtx_.SetSize(2*memgr_.NbFibres(), paq.DataSize()/4); 
+  if (fgsinglechannel_) 
+    mspecmtx_.SetSize(memgr_.NbFibres(), paq.DataSize()/2); 
+  else
+    mspecmtx_.SetSize(2*memgr_.NbFibres(), paq.DataSize()/4); 
+  mspecmtx_=(r_8)(0.);
   numfile_=0;
+  nbpaq4mean_=0;
   totnbpaq_=0;
 }
@@ -540,6 +55,10 @@
 BRMeanSpecCalculator::~BRMeanSpecCalculator()
 {
-}
-
+  if (nbpaq4mean_>1)  SaveSpectra();
+}
+
+
+static inline r_4 Zmod2(complex<r_4> z) 
+{ return (z.real()*z.real()+z.imag()*z.imag()); }
 
 /* --Methode-- */
@@ -547,32 +66,150 @@
 {
       
-  if (totnbpaq_%nmean_ == 0) {
-    if (totnbpaq_ > 0) {
-      mspecmtx_.Info()["NPAQSUM"] = nmean_;
-      mspecmtx_ /= (double)nmean_;
-      char nfile[32];
-      sprintf(nfile,"mspecmtx%d.ppf",numfile_);
-      string flnm=outpath_+nfile;
-      POutPersist po(flnm);
-      po << mspecmtx_;
-      cout << numfile_ << "-BRMeanSpecCalculator::Process() NPaqProc="
-	   << totnbpaq_ << "  -> Mean spectra Matrix in " << flnm << endl;
-      numfile_++;
+  if (nbpaq4mean_==nmean_)  SaveSpectra();
+    
+  if (fgdatafft_) {  // Donnees firmware FFT 
+    for(sa_size_t i=0; i<(size_t)mspecmtx_.NRows(); i++) {
+      TwoByteComplex* zp=NULL;
+      if (fgsinglechannel_) {
+	zp=vpaq_[i].Data1C();
+      }
+      else {
+	zp=vpaq_[i/2].Data1C();
+	if (i%2==1)  zp=vpaq_[i/2].Data2C();
+      }
+      TVector< r_4 > spec = mspecmtx_.Row(i); 
+      for(sa_size_t f=1; f<spec.Size(); f++)  spec(f) += zp[f].module2F();
     }
-    mspecmtx_ = (r_8)(0.);
-  }
-
-  sa_size_t k=0;
-  for(size_t i=0; i<(size_t)2*memgr_.NbFibres(); i++) {
-    TwoByteComplex* zp=vpaq_[i/2].Data1C();
-    if (i%2==1)  zp=vpaq_[i/2].Data2C();
-    TVector< r_4 > spec = mspecmtx_.Row(k);   k++;
-    for(sa_size_t f=1; f<spec.Size(); f++) {
-      spec(f) += zp[f].module2F();
-      }
+  }
+  else {  // Donnees RAW qui ont du etre processe par BRFFTCalculator
+    for(sa_size_t i=0; i<(size_t)mspecmtx_.NRows(); i++) {
+      complex<ODT>* zp=NULL;
+      if (fgsinglechannel_) {
+	zp=reinterpret_cast< complex<ODT>* > (vprocpaq_[i]);
+      }
+      else {
+	zp=reinterpret_cast< complex<ODT>* > (vprocpaq_[i/2]);
+	if (i%2==1)  zp= reinterpret_cast< complex<ODT>* >(vprocpaq_[i/2]+memgr_.ProcPaqSize()/2) ;
+      }
+      TVector< r_4 > spec = mspecmtx_.Row(i); 
+      for(sa_size_t f=1; f<spec.Size(); f++)  spec(f) += Zmod2(zp[f]);
+      
     }
-
-  totnbpaq_++;
+  }
+  nbpaq4mean_++;   totnbpaq_++;
   return 0;
+}
+
+/* --Methode-- */
+void BRMeanSpecCalculator::SaveSpectra()
+{
+  mspecmtx_.Info()["NPAQSUM"] = nbpaq4mean_;
+  mspecmtx_ /= (double)nbpaq4mean_;
+  char nfile[32];
+  sprintf(nfile,"mspecmtx%d.ppf",numfile_);
+  string flnm=outpath_+nfile;
+  POutPersist po(flnm);
+  po << mspecmtx_;
+  cout << numfile_ << "-BRMeanSpecCalculator::SaveSpectra() NPaqProc="
+       << totnbpaq_ << "  -> Mean spectra Matrix in " << flnm << endl;
+  numfile_++;  nbpaq4mean_=0;
+  mspecmtx_ = (r_8)(0.);
+  return;
+}
+
+//---------------------------------------------------------------------
+// Classe de thread de calcul de FFT sur donnees RAW 
+//---------------------------------------------------------------------
+/* --Methode-- */
+BRFFTCalculator::BRFFTCalculator(RAcqMemZoneMgr& memgr, bool fgsinglechannel)
+  : BRBaseProcessor(memgr), fgsinglechannel_(fgsinglechannel), totnbfftpaq_(0)
+{
+  BRPaquet paq(memgr_.PaqSize());
+  setNameId("FFTCalc",2);
+  ffts_.SetInDataSize((fgsinglechannel_)?paq.DataSize():paq.DataSize()/2);
+}
+
+/* --Methode-- */
+BRFFTCalculator::~BRFFTCalculator()
+{
+}
+
+
+/* --Methode-- */
+int BRFFTCalculator::Process()
+{
+  for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
+    ffts_.DoFFT( reinterpret_cast<IDT *>(vpaq_[fib].Data1() ),  
+	         reinterpret_cast< complex<ODT>* > (vprocpaq_[fib]) );
+    totnbfftpaq_++;
+    if ( fgsinglechannel_ ) continue;
+    ffts_.DoFFT( reinterpret_cast<IDT *>(vpaq_[fib].Data2() ),  
+	         reinterpret_cast< complex<ODT>* > (vprocpaq_[fib]+memgr_.ProcPaqSize()/2) );
+    totnbfftpaq_++;
+  }    
+  return 0;
+}
+
+
+//-------------------------------------------------------------------------
+// Classe WBRFFT : Calcul de TF sur donnees brutes (firmware RAW)
+//-------------------------------------------------------------------------
+ZMutex* WBRFFT::mtx_fftwp_ = NULL;
+
+/* --Methode-- */
+WBRFFT::WBRFFT(uint_4 sz)
+  : sz_(sz)
+{
+  if (mtx_fftwp_ == NULL) mtx_fftwp_ = new ZMutex;
+  if (sz>0)  SetInDataSize(sz);
+}
+
+/* --Methode-- */
+WBRFFT::~WBRFFT()
+{
+}
+
+/* --Methode-- */
+void WBRFFT::SetInDataSize(uint_4 sz)
+{
+  sz_ = sz; 
+  if (sz_<1) return;
+  inp.SetSize(sz);
+  outfc.SetSize(sz/2+1);
+  mtx_fftwp_->lock();
+  myplan_ = fftwf_plan_dft_r2c_1d(inp.Size(), inp.Data(), 
+		       (fftwf_complex*)outfc.Data(), FFTW_ESTIMATE); 
+  mtx_fftwp_->unlock();
+}
+
+/* --Methode-- */
+void WBRFFT::DoFFT( IDT *indata, complex<ODT> * ofc)
+{
+  if (sz_<1) return;
+  for(uint_4 k=0; k<inp.Size(); k++)   inp(k)=(ODT)indata[k];
+  fftwf_execute(myplan_); 
+  for(uint_4 k=0; k<outfc.Size(); k++)   ofc[k]=outfc(k);
+  return;
+}
+
+/* --Methode-- */
+void WBRFFT::PrintData(IDT *indata,  complex<ODT> * ofc, uint_4 sz)
+{
+    cout << " --- WBRFFT::PrintData() size=" << sz << endl;
+  for(uint_4 k=0; k<sz; k+=8) {
+    IDT* in = indata+k;
+    cout << " Indata[" << k << "..." << k+8 << "]= ";
+    for(uint_4 i=0; i<8; i++)   cout << (IIDT)in[i] << "  ";
+    cout << endl;  
+  }
+  cout << endl;
+  for(uint_4 k=0; k<sz/2; k+=4) {
+    complex< ODT>* out = ofc+k;
+    cout << " OutFC[" << k << "..." << k+4 << "]= ";
+    for(uint_4 i=0; i<4; i++)   cout << out[i] << "  ";
+    cout << endl;  
+  }
+  return;
+
 }
 
@@ -580,4 +217,5 @@
 //---------------------------------------------------------------
 // Classe thread de traitement donnees ADC avec 2 voies par frame
+//         !!!! OBSOLETE  !!!!   
 //---------------------------------------------------------------
 
@@ -612,6 +250,5 @@
 
 
-static inline r_4 Zmod2(complex<r_4> z) 
-{ return (z.real()*z.real()+z.imag()*z.imag()); }
+
 
 static inline string card2name_(int card)
@@ -1004,6 +641,8 @@
 }   
 
+
 //---------------------------------------------------------------------
 // Classe thread de traitement 2 x 2 voies/frames (Apres BRProcA2C)
+//         !!!! OBSOLETE  !!!!   
 //---------------------------------------------------------------------
 
Index: /trunk/AddOn/TAcq/brproc.h
===================================================================
--- /trunk/AddOn/TAcq/brproc.h	(revision 3871)
+++ /trunk/AddOn/TAcq/brproc.h	(revision 3872)
@@ -5,4 +5,7 @@
 // Projet BAORadio - (C) LAL/IRFU  2008-2010
 // Classes de threads de traitememt donnees BAORadio 
+//  Principales classes utilisables 
+//  - BRMeanSpecCalculator (donnees FFT)
+//  - BRFFTCalculator (donnees RAW) 
 //----------------------------------------------------------------
 
@@ -19,116 +22,78 @@
 #include "ntuple.h"
 #include "datatable.h"
+#include "FFTW/fftw3.h"
 
 using namespace std;
 
 
-//---------------------------------------------------------------------
-// Classe de traitement - calcul de visibilite pour n fibres 
-//---------------------------------------------------------------------
-class BRVisibilityCalculator : public BRBaseProcessor, ParallelTaskInterface {
-public:	
-  BRVisibilityCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean=1000, size_t nthr=1);
-  virtual ~BRVisibilityCalculator(); // Fait le nettoyage final , sauvegarde des objets ...
-
-  // Pour definir le rang de l'objet lors d'un traitement avec plusieurs BRVisibilityCalculator en //
-  void DefineRank(uint_4 nbc, uint_4 cid);
-
-  // Pour limiter le calcul des visibilites a certaines fibres 
-  uint_4 SelectPairs(uint_4 pair1=0, uint_4 nbpairs=99999999);
-  // pour definir le binning en frequence pour la VisibDataTable 
-  int SelectFreqBinning(uint_4 freq1=0, uint_4 freq2=0, uint_4 nbfreq=1);
-
-  // Pour activer la verification des timetag
-  // Creation / sauvegarde d'une matrice de TimeTag / FrameCounter avec NCols=maxnpaq (nb de paquets/trigger)  
-  int ActivateTimeTagCheck(uint_8 maxnpaq);
-
-  // Methode d'execution standard du thread (on redefinit la methode de BRBaseProcessor)
-  virtual void run();  
-  // Methode de la classe ParallelTaskInterface 
-  virtual int    execute(int tid);
-
-  // Le nombre total d'operations effectuees
-  inline r_8 TotNbFLOP() { return nb_flop_; }
-
-protected:
-  virtual int Process(); 
-  virtual int FillVisibTable(double fcm, double ttm); 
-  virtual int CheckTimeTag(); 
-
-  ParallelExecutor paralex_;  // Pour l'execution en parallele  
-  size_t nparthr_;
-
-  uint_4 nmean_;  // Nombre de spectres pour le calcul des moyennes 
-  string outpath_;  // directory pour fichiers de sortie
-  uint_4 nbcalc_, calcid_;  // Nombre total de threads/objets BRVisibilityCalculator parallèles, l'identificateur de l'objet  
-
-  uint_4 pairst_, nbpairs_;   // Numero de la premiere paire, nombre de paires 
-  uint_4 jf1_,jf2_,djf_;  // binning en frequence pour la datatable
-
-  vector<TwoByteComplex*> vpdata_;
-  bool* fgallfibok;  
-
-  double moyfc_, moytt_;
-  TMatrix< complex<r_4> > vismtx_; 
-  TVector< uint_4 > chanum_;
-  //  FitsInOutFile dtfos_;
-  DataTable visdt_;
-
-  uint_4 numfile_;
-  uint_8 totnbpaq_;
-
-  r_8 nb_flop_;   // Nombre total d'operations effectuees
-
-  // Variables/objets pour la verifications des timetag
-  bool fgcktt_;  // true -> checktimetag 
-  int_8 mindeltatt_;       // difference minimum de deux timetag successifs 
-  TMatrix< uint_8 > fcmtx_; // matrices des framecounters
-  TMatrix< uint_8 > ttmtx_; // matrices des timetag 
-  vector< uint_8 > vlasttt_;  // dernieres valeurs de TimeTag / fibre
-  vector< uint_8 > vbadtt_;  // Number of bad TimeTag paquets per fiber 
-  vector< uint_8 > vnsamett_;  // Number of paquets having TimeTag <> TT_Fiber1 per fiber 
-  vector< uint_8 > vndiff5tt_;  // Number of paquets having |TimeTag-TT_Fiber1|>5 per fiber 
-
-};
-
-
-//-------------------------------------------------------------------------------
-// Classe Groupe (ensemble) de Calculateur de Visibilites, tourant en parallele
-//-------------------------------------------------------------------------------
-
-class BRVisCalcGroup {
-public:	
-  BRVisCalcGroup(size_t nbcalc, RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean=1000, size_t nthr=1);
-  ~BRVisCalcGroup();
-  int SelectFreqBinning(uint_4 freq1=0, uint_4 freq2=0, uint_4 nbfreq=1);
-  inline int ActivateTimeTagCheck(uint_8 maxnpaq)
-  { return viscalcp_[0]->ActivateTimeTagCheck(maxnpaq); }
-
-  void start();
-  void join();
-protected:
-  vector<BRVisibilityCalculator *> viscalcp_; 
-  Timer tm_;
-};
  
 //---------------------------------------------------------------------
 // Classe de traitement simple - calcul de spectres moyennes / voie
+// a partir de donnees de type FFT (firmware FFT)
 //---------------------------------------------------------------------
 class BRMeanSpecCalculator : public BRBaseProcessor
 {
 public:
-  BRMeanSpecCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean=1000);
+  BRMeanSpecCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean=1000, 
+		       bool fgdatafft=true, bool fgsinglechan=false);
   virtual ~BRMeanSpecCalculator(); // Fait le nettoyage final , sauvegarde des objets ...
 
 protected:
   virtual int Process(); 
+  virtual void SaveSpectra();
 
   uint_4 nmean_;  // Nombre de spectres pour le calcul des moyennes 
   string outpath_;  // directory pour fichiers de sortie
+  bool fgdatafft_;
+  bool fgsinglechannel_;
   uint_4 numfile_;
+  uint_8 nbpaq4mean_;
 
   uint_8 totnbpaq_;
   TMatrix< r_4 > mspecmtx_;    // Matrice des spectres moyennees 
 }; 
+
+//-------------------------------------------------------------------------
+// Classe WBRFFT : Calcul de TF sur donnees brutes (firmware RAW)
+//   en utilisant FFTW et en effectuant une copie ds tableau local
+//-------------------------------------------------------------------------
+typedef unsigned char IDT ;   // definition type de donnees en entree de WBRFFT
+typedef int_2  IIDT ;      // definition type de donnees intermediaire 
+typedef float  ODT;  // type de donnees en sortie (complex < ODT > )
+//----Classe WBRFFT----
+class WBRFFT {
+public:
+  WBRFFT(uint_4 sz=0);
+  virtual ~WBRFFT();
+
+  void SetInDataSize(uint_4 sz);
+  void DoFFT(IDT *indata, complex<ODT> * ofc);
+  static void PrintData(IDT *indata,  complex<ODT> * ofc, uint_4 sz);
+
+  uint_4 sz_;   // Taille tableau d'entree 
+  TVector< ODT > inp;
+  TVector< complex<ODT> > outfc;
+  fftwf_plan myplan_;
+  static ZMutex* mtx_fftwp_;  // Mutex de protection pour la creation du plan fftw 
+};
+//--------------------
+
+//---------------------------------------------------------------------
+// Classe de thread de calcul de FFT sur donnees RAW 
+//---------------------------------------------------------------------
+class BRFFTCalculator : public BRBaseProcessor
+{
+public:
+  BRFFTCalculator(RAcqMemZoneMgr& memgr, bool fgsinglechannel=false);
+  virtual ~BRFFTCalculator(); // Fait le nettoyage final , sauvegarde des objets ...
+
+protected:
+  virtual int Process(); 
+  
+  bool fgsinglechannel_;
+  uint_8 totnbfftpaq_;
+  WBRFFT ffts_;
+};
+
 
 //-------------------------------------------------------------------------
@@ -151,5 +116,5 @@
   o card : numero de carte , juste pour les impressions 
 */
-class BRProcA2C : public ZThread {
+class BRProcA2C : public ZThread {   // !!!! OBSOLETE  !!!!
 public:	
   BRProcA2C(RAcqMemZoneMgr& mem, string& path, bool fgraw, 
@@ -174,4 +139,5 @@
 //---------------------------------------------------------------------
 // Classe thread de traitement 2 x 2 voies/paquet (Apres BRProcA2C)
+//         !!!! OBSOLETE  !!!!   
 //---------------------------------------------------------------------
 /*-- Arguments du constructeur : 
@@ -184,5 +150,6 @@
 */
 
-class BRProcB4C : public ZThread {
+class BRProcB4C : public ZThread {  //   !!!! OBSOLETE  !!!!   
+
 public:	
   BRProcB4C(RAcqMemZoneMgr& mem1, RAcqMemZoneMgr& mem2, string& path, 
Index: /trunk/AddOn/TAcq/brviscalc.cc
===================================================================
--- /trunk/AddOn/TAcq/brviscalc.cc	(revision 3872)
+++ /trunk/AddOn/TAcq/brviscalc.cc	(revision 3872)
@@ -0,0 +1,516 @@
+//----------------------------------------------------------------
+// Projet BAORadio - (C) LAL/IRFU  2008-2010
+// Classes de threads de calcul de visibilites pour BAORadio 
+//----------------------------------------------------------------
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <fstream>
+#include <signal.h>
+
+#include "pexceptions.h"
+#include "fioarr.h"
+#include "matharr.h"
+#include "timestamp.h"
+#include "ctimer.h"
+
+#include "brviscalc.h"
+
+
+//---------------------------------------------------------------------
+// Classe de traitement - calcul de visibilite pour n fibres 
+//---------------------------------------------------------------------
+
+/* --Methode-- */
+BRVisibilityCalculator::BRVisibilityCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean, size_t nthr)
+  : BRBaseProcessor(memgr), paralex_(*this, nthr), nparthr_(nthr), 
+    outpath_(outpath), nmean_(nmean), nbcalc_(1), calcid_(0), vpdata_(2*memgr.NbFibres())
+    // , dtfos_(outpath+"visdt.fits", Fits_Create), visdt_(dtfos_, 1024, true);
+{  
+  DefineRank(1,0);
+
+  uint_4 maxnpairs = (2*memgr_.NbFibres()+1)*memgr_.NbFibres();
+  chanum_.SetSize(maxnpairs);
+  sa_size_t k=0;
+  for(size_t i=0; i<2*memgr_.NbFibres(); i++)  vpdata_[i]=NULL;
+  for(size_t i=0; i<2*memgr_.NbFibres(); i++) {
+    for(size_t j=i; j<2*memgr_.NbFibres(); j++) {
+      chanum_(k) = (i+1)*100+(j+1);  k++;
+    }
+  }
+  SelectPairs();
+
+  //  visdt_.AddFloatColumn("mfc");
+  visdt_.AddDoubleColumn("mfc");
+  visdt_.AddDoubleColumn("mtt");
+  visdt_.AddIntegerColumn("jfreq");
+  visdt_.AddIntegerColumn("numch");
+  visdt_.AddFloatColumn("vre");
+  visdt_.AddFloatColumn("vim");
+
+  if (nmean_ < 1)  nmean_=memgr_.NbPaquets();
+  if (nmean_ < 1)  nmean_=1;
+
+  cout << " BRVisibilityCalculator::/Info  nmean=" << nmean_ << endl;
+
+  totnbpaq_=0;
+  numfile_=0;
+  nb_flop_=0.;
+  moyfc_=moytt_=0.;
+
+  fgallfibok=NULL;
+  fgcktt_=false;
+  setNameId("viscalc", 0); 
+}
+
+/* --Methode-- */
+BRVisibilityCalculator::~BRVisibilityCalculator()
+{
+  cout << " BRVisibilityCalculator - Visibility Datatable : " << endl;
+  cout << visdt_;
+  string filename;
+  filename = outpath_+"visdt.ppf";
+  if (nbcalc_>1) {
+    char sbuff[32];
+    sprintf(sbuff,"visdt_%d",(int)calcid_);
+    filename = outpath_+sbuff;
+  }
+  POutPersist po(filename);
+  po << visdt_;
+  if (calcid_ == 0) {
+    POutPersist poc(outpath_+"chanum.ppf");
+    poc << chanum_;
+  
+    if (fgcktt_) {
+      cout << " BRVisibilityCalculator -  Check TimeTag done: TotNPaqProc= " << totnbpaq_ << endl;
+      for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  {
+	cout << " BRTTCheck-Fiber[" << fib << "] NBadTT=" << vbadtt_[fib] << " NDiffTT>5="
+	     << vndiff5tt_[fib] << "  NotSameTT=" << vnsamett_[fib] << endl; 
+      }
+      POutPersist pott(outpath_+"ttfcmtx.ppf");
+      pott << PPFNameTag("FC") << fcmtx_; 
+      pott << PPFNameTag("TT") << ttmtx_;     
+    }
+  }
+}
+
+/* --Methode-- */
+void BRVisibilityCalculator::DefineRank(uint_4 nbc, uint_4 cid)
+{
+  if ((nbc>6)||(cid>=nbc)) 
+    throw ParmError("BRVisibilityCalculator::DefineRank() NbCalc > 6 !");
+  nbcalc_=nbc;
+  calcid_=cid;
+  if (nbcalc_>1) {
+    uint_4 maxnpairs = (2*memgr_.NbFibres()+1)*memgr_.NbFibres();
+    uint_4 npairs=maxnpairs/nbcalc_;
+    if (calcid_==(nbcalc_-1)) 
+      SelectPairs(calcid_*npairs, maxnpairs-calcid_*npairs);
+    else 
+      SelectPairs(calcid_*npairs, npairs);
+    MemZaction mmzas[6]={MemZA_ProcA,MemZA_ProcB,MemZA_ProcC,MemZA_ProcD,MemZA_ProcE,MemZA_ProcF};
+    SetMemZAction(mmzas[calcid_]);
+    setNameId("viscalc_grp", calcid_); 
+  }
+  return ;
+}
+
+/* --Methode-- */
+uint_4 BRVisibilityCalculator::SelectPairs(uint_4 pair1, uint_4 nbpairs)
+{
+  BRPaquet paq(memgr_.PaqSize());
+  uint_4 maxnpairs = (2*memgr_.NbFibres()+1)*memgr_.NbFibres();
+
+  if (pair1 >= maxnpairs)  pair1=maxnpairs-1;
+  if (nbpairs > maxnpairs-pair1)  nbpairs=maxnpairs-pair1;
+  pairst_=pair1;
+  nbpairs_=nbpairs;
+  vismtx_.SetSize(nbpairs_, paq.DataSize()/4); 
+  return nbpairs_;
+}
+
+/* --Methode-- */
+int BRVisibilityCalculator::SelectFreqBinning(uint_4 freq1, uint_4 freq2, uint_4 nbfreq)
+{
+  jf1_=freq1; jf2_=freq2;
+  if ((jf1_<1)||(jf1_>=vismtx_.NCols()))  jf1_=1;
+  if ((jf2_<1)||(jf2_>=vismtx_.NCols())||(jf2_<jf1_))  jf2_=vismtx_.NCols()-1;
+  if (nbfreq<1) nbfreq=1;
+  djf_=(jf2_-jf1_)/nbfreq;
+  if (djf_<1) djf_=0;
+  cout << " BRVisibilityCalculator::SelectFreqBinning/Info  JF1=" << jf1_ 
+       << " JF2=" << jf2_ << " DJF=" << djf_ << endl;
+
+}
+
+
+/* --Methode-- */
+int BRVisibilityCalculator::ActivateTimeTagCheck(uint_8 maxnpaq)
+{
+  mindeltatt_=memgr_.PaqSize()/2;
+  if (mindeltatt_<1) mindeltatt_=1;
+  fcmtx_.SetSize(memgr_.NbFibres(), maxnpaq);
+  ttmtx_.SetSize(memgr_.NbFibres(), maxnpaq);
+  vlasttt_.resize(memgr_.NbFibres(), 0);
+  vbadtt_.resize(memgr_.NbFibres(), 0);
+  vnsamett_.resize(memgr_.NbFibres(), 0);
+  vndiff5tt_.resize(memgr_.NbFibres(), 0);
+
+  fgcktt_=true;
+  cout << " BRVisibilityCalculator::ActivateTimeTagCheck() - TT/Fc matrix NCols=" << maxnpaq 
+       << " MinDeltaTT=" << mindeltatt_ << endl;
+
+  return 0;
+}
+
+
+/* --Methode-- */
+void BRVisibilityCalculator::run()
+{
+  cout << " BRVisibilityCalculator[" << calcid_ << "/" << nbcalc_ 
+       << "]::run() - Starting " << " NFibers=" << memgr_.NbFibres() 
+       << " NChan=" << 2*memgr_.NbFibres() << " NPairs=" << nbpairs_ << " First:" << pairst_ << endl;	
+  
+  if (nparthr_ < 2)  return BRBaseProcessor::run();
+  // Execution multithread parallele
+  setRC(1);	
+  int rc=0;
+  try {
+    if ((nmean_%memgr_.NbPaquets())!=0) {
+      uint_4 mnmean = (nmean_/memgr_.NbPaquets()+1)*memgr_.NbPaquets();
+      cout << " BRVisibilityCalculator::run()/Info changing nmean=" << nmean_  << " to multiple of"
+	   << " memgr_.NbPaquets() -> " << mnmean << endl;
+      nmean_=mnmean;
+    }
+    paralex_.SetParallelTask(*this);
+    cout << " BRVisibilityCalculator::run()/Info : starting ParallelExecutor with nThreads=" 
+	 << paralex_.nThreads() << " ... " << endl;
+    paralex_.start();
+
+    fgallfibok = new bool[memgr_.NbPaquets()];
+
+    size_t paqsz=memgr_.PaqSize();
+    bool fgrun=true;
+    while (fgrun) {
+      if (stop_) break;
+      if (memgr_.GetRunState() == MemZR_Stopped) break;
+      int mid = memgr_.FindMemZoneId(mmact_);  // (MemZA_ProcA);
+      //      Byte* buffg = memgr_.GetMemZone(mid);
+      //      if (buffg == NULL) {
+      if (mid < 0) {
+	cout << "BRVisibilityCalculator[" << calcid_ << "]::run()/ERROR FindMemZoneId(" 
+	     << (int)mmact_ << ") ->" << mid << ") -> NULL" << endl;
+	setRC(7);      fgrun=false;		
+	break;	
+      }
+      for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
+	fbuff_[fib] = memgr_.GetMemZone(mid,fib);
+	if (fbuff_[fib] == NULL) { // cela ne devrait pas arriver 
+	  cout << "BRVisibilityCalculator[" << calcid_ << "]::run()/ERROR memgr.GetMemZone(" << mid << "," << fib << ") -> NULL" << endl;
+	  setRC(9);	  fgrun=false;		
+	  break;
+	}
+      }
+
+      if (totnbpaq_%nmean_ == 0) {
+	if (totnbpaq_ > 0) {
+	  moyfc_/=nmean_;
+	  moytt_/=nmean_;
+	  vismtx_.Info()["MeanFC"] = moyfc_;
+	  vismtx_.Info()["MeanTT"] = moytt_;
+	  vismtx_.Info()["NPAQSUM"] = nmean_;
+	  
+	  // ATTENTION : Matrice visibilites non moyennee 
+	  char nfile[48];
+	  if (nbcalc_==1) 
+	    sprintf(nfile,"vismtx%d.ppf",numfile_);
+	  else 
+	    sprintf(nfile,"vismtx_%d_%d.ppf",(int)calcid_,numfile_);
+	  string flnm=outpath_+nfile;
+	  POutPersist po(flnm);
+	  po << vismtx_;
+	  cout << numfile_ << "-BRVisibilityCalculator[" << calcid_ << "]::run() NPaqProc="
+	       << totnbpaq_ << "  -> Visibility Matrix in " << flnm << endl;
+	  FillVisibTable(moyfc_, moytt_);
+	  numfile_++;
+	}
+	vismtx_ = complex<r_4>((r_4)0.,(r_4)0.);
+	moyfc_=moytt_=0.;
+      }
+
+      for(size_t jp=0; jp<memgr_.NbPaquets(); jp++) {   // boucle sur les paquets d'une zone  
+	fgallfibok[jp]=fgokallfibers_=true;
+	for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
+	  vpaq_[fib].Set(fbuff_[fib]+jp*paqsz);
+	  vfgok_[fib] = vpchk_[fib].Check(vpaq_[fib],curfc_[fib]);
+	  if (!vfgok_[fib])  fgallfibok[jp]=fgokallfibers_=false;
+	}
+	if (fgokallfibers_)  {
+	  if (totprocnpaq_==0) {
+	    for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  {
+	      fcfirst_[fib]=curfc_[fib];
+	      ttfirst_[fib]=vpaq_[fib].TimeTag();
+	    }
+	  }
+	  totprocnpaq_++;
+	  moyfc_ += curfc_[0];
+	  moytt_ += (vpaq_[0].TimeTag()-ttfirst_[0]);
+	  if ((fgcktt_)&&(calcid_==0))  CheckTimeTag();
+	  totnbpaq_++;
+	}
+      }  // Fin de boucle sur les paquets 
+      
+      // Execution parallele  pour calcul des visibilites par bandes de frequence
+      int rcpex=paralex_.execute();
+      if (rcpex!=0)  cout << " BRVisibilityCalculator[" << calcid_ << "]::run() / Error Rc[paralex_.execute()]=" << rcpex << endl;
+
+      memgr_.FreeMemZone(mid, mmsta_);  // (MemZS_ProcA);
+    } // Fin de boucle sur les zones a traiter 
+    //------------------------------------
+    cout << " --------- END BRVisibilityCalculator[" << calcid_ << "]::run() , TotNbProcPaq=" << totprocnpaq_ << endl;
+    /*
+    for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  vpchk_[fib].Print();
+    cout << " ------------------------------------ " << endl;
+    */
+    delete[] fgallfibok;
+  }
+  catch (std::exception& exc) {
+    cout << " BRVisibilityCalculator[" << calcid_ << "]::run()/catched std::exception " << exc.what() << endl;
+    setRC(98);	
+    return; 
+  }
+  catch(...) {
+    cout << " BRVisibilityCalculator[" << calcid_ << "]::run()/catched unknown ... exception " << endl;
+    setRC(99);	
+    return; 
+  }
+  
+}
+
+/* --Methode-- */
+int BRVisibilityCalculator::Process()
+{
+    
+  for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
+    vpdata_[2*fib] = vpaq_[fib].Data1C();
+    vpdata_[2*fib+1] = vpaq_[fib].Data2C();
+  }
+  
+  if (totnbpaq_%nmean_ == 0) {
+    if (totnbpaq_ > 0) {
+      moyfc_/=nmean_;
+      moytt_/=nmean_;
+      vismtx_.Info()["MeanFC"] = moyfc_;
+      vismtx_.Info()["MeanTT"] = moytt_;
+      vismtx_.Info()["NPAQSUM"] = nmean_;
+
+      // ATTENTION : Matrice visibilites non moyennee 
+      char nfile[48];
+      if (nbcalc_==1) 
+	sprintf(nfile,"vismtx%d.ppf",numfile_);
+      else 
+	sprintf(nfile,"vismtx_%d_%d.ppf",(int)calcid_,numfile_);
+      string flnm=outpath_+nfile;
+      POutPersist po(flnm);
+      po << vismtx_;
+      cout << numfile_ << "-BRVisibilityCalculator::Process() NPaqProc="
+	   << totnbpaq_ << "  -> Visibility Matrix in " << flnm << endl;
+      FillVisibTable(moyfc_, moytt_);
+      numfile_++;
+    }
+    vismtx_ = complex<r_4>((r_4)0.,(r_4)0.);
+    moyfc_=moytt_=0.;
+  }
+
+  sa_size_t k=0;
+  for(size_t i=0; i<vpdata_.size(); i++) {
+    for(size_t j=i; j<vpdata_.size(); j++) {
+      size_t kpair=i*vpdata_.size()+j;
+      if (kpair<pairst_)  continue;
+      if (kpair>=(pairst_+nbpairs_))  break;
+      TVector< complex<r_4> > vis = vismtx_.Row(k);   k++;
+      for(sa_size_t f=1; f<vis.Size(); f++) {
+	vis(f) += complex<r_4>((r_4)vpdata_[i][f].realB(), (r_4)vpdata_[i][f].imagB()) * 
+	  complex<r_4>((r_4)vpdata_[j][f].realB(), -(r_4)vpdata_[j][f].imagB());
+      }
+      nb_flop_ += (7.*(r_8)vis.Size());
+    }
+  }
+
+  moyfc_ += curfc_[0];
+  moytt_ += (vpaq_[0].TimeTag()-ttfirst_[0]);
+  if ((fgcktt_)&&(calcid_==0))  CheckTimeTag();
+  totnbpaq_++;
+  return 0;
+}
+
+/* --Methode-- */
+int BRVisibilityCalculator::execute(int tid)
+{
+  vector<TwoByteComplex*>  pvpdata(2*memgr_.NbFibres());
+  size_t paqsz=memgr_.PaqSize();
+  BRPaquet ppaq(paqsz);
+
+  sa_size_t fdelt = vismtx_.NCols()/nparthr_;
+  sa_size_t fdeb = tid*fdelt;
+  sa_size_t ffin = (tid+1)*fdelt;
+
+  if (fdeb<1) fdeb=1;
+  if ((ffin>vismtx_.NCols())||(tid==(nparthr_-1))) ffin=vismtx_.NCols();
+
+  for(size_t jp=0; jp<memgr_.NbPaquets(); jp++) {   // boucle sur les paquets d'une zone  
+    if (!fgallfibok[jp])  continue;
+    for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
+      ppaq.Set(fbuff_[fib]+jp*paqsz);
+      pvpdata[2*fib] = ppaq.Data1C();
+      pvpdata[2*fib+1] = ppaq.Data2C();
+    }
+    sa_size_t k=0;
+    for(size_t i=0; i<vpdata_.size(); i++) {
+      for(size_t j=i; j<vpdata_.size(); j++) {
+	size_t kpair=i*vpdata_.size()+j;
+	if (kpair<pairst_)  continue;
+	if (kpair>=(pairst_+nbpairs_))  break;
+	TVector< complex<r_4> > vis = vismtx_.Row(k);   k++;
+	for(sa_size_t f=fdeb; f<ffin; f++) {
+	  vis(f) += complex<r_4>((r_4)pvpdata[i][f].realB(), (r_4)pvpdata[i][f].imagB()) * 
+	    complex<r_4>((r_4)pvpdata[j][f].realB(), -(r_4)pvpdata[j][f].imagB());
+	}
+	nb_flop_ += (7.*(r_8)(ffin-fdeb));
+      }
+    }
+
+  }  // Fin de boucle sur les paquets 
+  
+  return 0;
+}
+
+/* --Methode-- */
+int BRVisibilityCalculator::FillVisibTable(double fcm, double ttm)
+{
+  double xnt[10];
+  xnt[0]=fcm;  xnt[1]=ttm/1.25e8;
+
+  if (djf_<2) {
+    for(sa_size_t rv=0; rv<vismtx_.NRows(); rv++) {
+      for(sa_size_t jf=jf1_; jf<jf2_; jf++) {
+	xnt[2]=jf;
+	xnt[3]=chanum_(rv+pairst_);
+	xnt[4]=vismtx_(rv,jf).real()/(r_4)(nmean_);
+	xnt[5]=vismtx_(rv,jf).imag()/(r_4)(nmean_);
+	visdt_.AddRow(xnt);
+      }
+    }
+  }
+  else {
+    for(sa_size_t rv=0; rv<vismtx_.NRows(); rv++) {
+      for(sa_size_t jf=jf1_; jf<jf2_; jf+=djf_) {
+	r_4 moyreal=0.;
+	r_4 moyimag=0.;
+	sa_size_t jjfmx=jf+djf_;
+	if (jjfmx > vismtx_.NCols()) jjfmx=vismtx_.NCols();
+	for(sa_size_t jjf=jf; jjf<jjfmx; jjf++) {
+	  moyreal+=vismtx_(rv,jjf).real();
+	  moyimag+=vismtx_(rv,jjf).imag();
+	}
+	xnt[2]=jf+djf_/2;
+	xnt[3]=chanum_(rv+pairst_);
+	xnt[4]=moyreal/(r_4)(nmean_*djf_);
+	xnt[5]=moyimag/(r_4)(nmean_*djf_);
+	visdt_.AddRow(xnt);
+      }
+    }
+  }
+  return 0;
+}
+
+/* --Methode-- */
+int BRVisibilityCalculator::CheckTimeTag()
+{
+  if (totnbpaq_==0) {
+    for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  {
+      vlasttt_[fib]=ttfirst_[fib];
+      if (ttmtx_.NCols()>0) {
+	fcmtx_(fib,totnbpaq_) = curfc_[fib]; 
+	ttmtx_(fib,totnbpaq_) = vlasttt_[fib]; 
+      }
+    }
+    return 0;
+  }
+  for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
+    int_8 ld = (int_8)vpaq_[fib].TimeTag()-(int_8)vlasttt_[fib];
+    int_8 fd = (int_8)vpaq_[fib].TimeTag()-(int_8)ttfirst_[fib]-(int_8)vpaq_[0].TimeTag()+(int_8)ttfirst_[0];
+    /*    if ( (ld < mindeltatt_) || (fd<-5) || (fd>5)) { vbadtt_[fib]++; vnsamett_[fib]++; }
+    else {
+      if (fd!=0)  vnsamett_[fib]++;
+    }
+    */
+    if  (ld < mindeltatt_) vbadtt_[fib]++;
+    else {
+      if (fd != 0)  vnsamett_[fib]++;
+      if ((fd<-5)||(fd>5))  vndiff5tt_[fib]++;
+    }
+    vlasttt_[fib]=vpaq_[fib].TimeTag();
+    if (totnbpaq_<ttmtx_.NCols()) {
+      fcmtx_(fib,totnbpaq_) = curfc_[fib]; 
+      ttmtx_(fib,totnbpaq_) = vlasttt_[fib]; 
+    }
+  }
+  return 0;
+}
+
+//-------------------------------------------------------------------------------
+// Classe Groupe (ensemble) de Calculateur de Visibilites, tournant en parallele
+//-------------------------------------------------------------------------------
+
+/* --Methode-- */
+BRVisCalcGroup::BRVisCalcGroup(size_t nbcalc, RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean, size_t nthr)
+  : tm_(false)
+{
+  if ((nbcalc<1)||(nbcalc>6)) 
+    throw ParmError("BRVisCalcGroup::BRVisCalcGroup NbCalc > 6 !");
+  for(size_t i=0; i<nbcalc; i++) {
+    BRVisibilityCalculator * viscp=new BRVisibilityCalculator(memgr, outpath, nmean, nthr);
+    viscp->DefineRank(nbcalc, i);
+    viscalcp_.push_back(viscp); 
+  }
+}
+/* --Methode-- */
+BRVisCalcGroup::~BRVisCalcGroup()
+{
+  for(size_t i=0; i<viscalcp_.size(); i++) 
+    delete viscalcp_[i];
+}
+/* --Methode-- */
+int BRVisCalcGroup::SelectFreqBinning(uint_4 freq1, uint_4 freq2, uint_4 nbfreq)
+{
+  int rc=0;
+  for(size_t i=0; i<viscalcp_.size(); i++) 
+    rc=viscalcp_[i]->SelectFreqBinning(freq1, freq2, nbfreq);
+  return rc;
+}
+/* --Methode-- */
+void BRVisCalcGroup::start()
+{
+  for(size_t i=0; i<viscalcp_.size(); i++) 
+    viscalcp_[i]->start();
+  tm_.SplitQ();
+}
+/* --Methode-- */
+void BRVisCalcGroup::join()
+{
+  r_8 totflop=0.;
+  for(size_t i=0; i<viscalcp_.size(); i++) {
+    viscalcp_[i]->join();
+    totflop += viscalcp_[i]->TotNbFLOP();
+  }
+  tm_.SplitQ();
+  cout << "      ----------------------------------------------------------" << endl;
+  cout << " BRVisCalcGroup::join() : Finished , Elaspsed time: " << tm_.PartialElapsedTimems() 
+       << " ms (total:" << tm_.TotalElapsedTimems() << ")" << endl;
+  cout << " ... TotalMegaFLOP= " << totflop/(1024.e3) << " @ " 
+       << totflop/(r_8)tm_.PartialElapsedTimems()/(1024) << " MFLOP/s" << endl; 
+  cout << "      ----------------------------------------------------------" << endl;
+  return;
+}
Index: /trunk/AddOn/TAcq/brviscalc.h
===================================================================
--- /trunk/AddOn/TAcq/brviscalc.h	(revision 3872)
+++ /trunk/AddOn/TAcq/brviscalc.h	(revision 3872)
@@ -0,0 +1,121 @@
+#ifndef  BRVISCALC_H_SEEN
+#define  BRVISCALC_H_SEEN
+
+//----------------------------------------------------------------
+// Projet BAORadio - (C) LAL/IRFU  2008-2010
+// Classes de threads de calcul de visibilites pour BAORadio 
+//  Principales classes utilisables 
+//  - BRVisibilityCalculator (donnees FFT)
+//  - BRVisCalcGroup  
+//----------------------------------------------------------------
+
+#include <string>
+#include <vector>
+#include <iostream>
+
+// --- include SOPHYA
+#include "machdefs.h"
+#include "sopnamsp.h"
+#include "tvector.h"
+#include "parlex.h"
+#include "datatable.h"
+#include "ctimer.h"
+
+//--- include BAORadio 
+#include "racqumem.h"
+#include "brpaqu.h"
+#include "brbaseproc.h"
+
+using namespace std;
+
+//---------------------------------------------------------------------
+// Classe de traitement - calcul de visibilite pour n fibres 
+//---------------------------------------------------------------------
+class BRVisibilityCalculator : public BRBaseProcessor, ParallelTaskInterface {
+public:	
+  BRVisibilityCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean=1000, size_t nthr=1);
+  virtual ~BRVisibilityCalculator(); // Fait le nettoyage final , sauvegarde des objets ...
+
+  // Pour definir le rang de l'objet lors d'un traitement avec plusieurs BRVisibilityCalculator en //
+  void DefineRank(uint_4 nbc, uint_4 cid);
+
+  // Pour limiter le calcul des visibilites a certaines fibres 
+  uint_4 SelectPairs(uint_4 pair1=0, uint_4 nbpairs=99999999);
+  // pour definir le binning en frequence pour la VisibDataTable 
+  int SelectFreqBinning(uint_4 freq1=0, uint_4 freq2=0, uint_4 nbfreq=1);
+
+  // Pour activer la verification des timetag
+  // Creation / sauvegarde d'une matrice de TimeTag / FrameCounter avec NCols=maxnpaq (nb de paquets/trigger)  
+  int ActivateTimeTagCheck(uint_8 maxnpaq);
+
+  // Methode d'execution standard du thread (on redefinit la methode de BRBaseProcessor)
+  virtual void run();  
+  // Methode de la classe ParallelTaskInterface 
+  virtual int    execute(int tid);
+
+  // Le nombre total d'operations effectuees
+  inline r_8 TotNbFLOP() { return nb_flop_; }
+
+protected:
+  virtual int Process(); 
+  virtual int FillVisibTable(double fcm, double ttm); 
+  virtual int CheckTimeTag(); 
+
+  ParallelExecutor paralex_;  // Pour l'execution en parallele  
+  size_t nparthr_;
+
+  uint_4 nmean_;  // Nombre de spectres pour le calcul des moyennes 
+  string outpath_;  // directory pour fichiers de sortie
+  uint_4 nbcalc_, calcid_;  // Nombre total de threads/objets BRVisibilityCalculator parallèles, l'identificateur de l'objet  
+
+  uint_4 pairst_, nbpairs_;   // Numero de la premiere paire, nombre de paires 
+  uint_4 jf1_,jf2_,djf_;  // binning en frequence pour la datatable
+
+  vector<TwoByteComplex*> vpdata_;
+  bool* fgallfibok;  
+
+  double moyfc_, moytt_;
+  TMatrix< complex<r_4> > vismtx_; 
+  TVector< uint_4 > chanum_;
+  //  FitsInOutFile dtfos_;
+  DataTable visdt_;
+
+  uint_4 numfile_;
+  uint_8 totnbpaq_;
+
+  r_8 nb_flop_;   // Nombre total d'operations effectuees
+
+  // Variables/objets pour la verifications des timetag
+  bool fgcktt_;  // true -> checktimetag 
+  int_8 mindeltatt_;       // difference minimum de deux timetag successifs 
+  TMatrix< uint_8 > fcmtx_; // matrices des framecounters
+  TMatrix< uint_8 > ttmtx_; // matrices des timetag 
+  vector< uint_8 > vlasttt_;  // dernieres valeurs de TimeTag / fibre
+  vector< uint_8 > vbadtt_;  // Number of bad TimeTag paquets per fiber 
+  vector< uint_8 > vnsamett_;  // Number of paquets having TimeTag <> TT_Fiber1 per fiber 
+  vector< uint_8 > vndiff5tt_;  // Number of paquets having |TimeTag-TT_Fiber1|>5 per fiber 
+
+};
+
+
+//-------------------------------------------------------------------------------
+// Classe Groupe (ensemble) de Calculateur de Visibilites, tourant en parallele
+//-------------------------------------------------------------------------------
+
+class BRVisCalcGroup {
+public:	
+  BRVisCalcGroup(size_t nbcalc, RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean=1000, size_t nthr=1);
+  ~BRVisCalcGroup();
+  int SelectFreqBinning(uint_4 freq1=0, uint_4 freq2=0, uint_4 nbfreq=1);
+  inline int ActivateTimeTagCheck(uint_8 maxnpaq)
+  { return viscalcp_[0]->ActivateTimeTagCheck(maxnpaq); }
+
+  void start();
+  void join();
+protected:
+  vector<BRVisibilityCalculator *> viscalcp_; 
+  Timer tm_;
+};
+
+
+#endif
Index: /trunk/AddOn/TAcq/makefile
===================================================================
--- /trunk/AddOn/TAcq/makefile	(revision 3871)
+++ /trunk/AddOn/TAcq/makefile	(revision 3872)
@@ -6,5 +6,5 @@
 # all : traidio  tmtfft tstminifits tbrpaq tpciew tmtacq tstrdfits mfits2spec tsok 
 # all : traidio  tmtfft tstminifits tmtacq tstrdfits mfits2spec tsok mcrd
-all :  mfacq vismfib treadmfib tmtacq mfits2spec mcrd svv2mtx svv2mtx2 tsok traidio tstminifits tbrpaq
+all :  mfacq vismfib specmfib treadmfib tmtacq mfits2spec mcrd svv2mtx svv2mtx2 tsok traidio tstminifits tbrpaq
 
 clean :
@@ -15,4 +15,13 @@
 	rm -f Objs/* *.ppf *.fits 
 
+PKGOLIST = $(OBJ)branap.o  $(OBJ)brparam.o $(OBJ)racqumem.o $(OBJ)brpaqu.o \
+           $(OBJ)brfitsrd.o $(OBJ)brdiskw.o  $(OBJ)minifits.o \
+           $(OBJ)brbaseproc.o $(OBJ)brproc.o $(OBJ)brviscalc.o \
+           $(OBJ)racqueth.o $(OBJ)racquproc.o $(OBJ)racqurw.o  $(OBJ)pciewrap.o \
+           $(OBJ)swrapsock.o $(OBJ)sockrawstream.o $(OBJ)burawstream.o 
+PKGHLIST = bracqvers.h branap.h brparam.h racqumem.h brpaqu.h brtypes.h \
+           brdiskw.h brfitsrd.h minifits.h brviscalc.h brbaseproc.h brproc.h \
+           mfacq.h  tmtacq.h racqueth.h  racquproc.h racqurw.h pciewrap.h  \
+           swrapsock.h burawstream.h sockrawstream.h tmtacq.h
 ########################################################
 
@@ -21,10 +30,8 @@
 	echo '---mfacq made'
 
-$(EXE)mfacq : $(OBJ)mfacq.o $(OBJ)brparam.o $(OBJ)racqumem.o $(OBJ)racqurw.o  $(OBJ)racqueth.o \
-	$(OBJ)racquproc.o $(OBJ)brpaqu.o $(OBJ)pciewrap.o $(OBJ)minifits.o $(OBJ)swrapsock.o
-	$(CXXLINK) -o $(EXE)mfacq $(OBJ)mfacq.o $(OBJ)brparam.o $(OBJ)racqumem.o $(OBJ)racqurw.o $(OBJ)racqueth.o \
-	      $(OBJ)racquproc.o $(OBJ)brpaqu.o $(OBJ)pciewrap.o $(OBJ)minifits.o $(OBJ)swrapsock.o $(SOPHYAALLSLBLIST)
-
-$(OBJ)mfacq.o : mfacq.cc brparam.h racquproc.h racqurw.h racqueth.h racqumem.h brpaqu.h
+$(EXE)mfacq : $(OBJ)mfacq.o $(PKGOLIST)
+	$(CXXLINK) -o $(EXE)mfacq $(OBJ)mfacq.o $(PKGOLIST) $(SOPHYAALLSLBLIST)
+
+$(OBJ)mfacq.o : mfacq.cc $(PKGHLIST)
 	$(CXXCOMPILE) -c -DNOPCIECARD -o $(OBJ)mfacq.o mfacq.cc 
 
@@ -33,25 +40,23 @@
 	echo '---tmtacq made'
 
-$(EXE)tmtacq : $(OBJ)tmtacq.o  $(OBJ)brparam.o $(OBJ)racqumem.o $(OBJ)racqurw.o $(OBJ)racquproc.o \
-               $(OBJ)brpaqu.o $(OBJ)pciewrap.o $(OBJ)minifits.o
-	$(CXXLINK) -o $(EXE)tmtacq $(OBJ)tmtacq.o $(OBJ)brparam.o $(OBJ)racqumem.o $(OBJ)racqurw.o \
-	       $(OBJ)racquproc.o $(OBJ)brpaqu.o $(OBJ)pciewrap.o $(OBJ)minifits.o $(SOPHYAALLSLBLIST)
-
-$(OBJ)tmtacq.o : tmtacq.cc racquproc.h racqurw.h racqumem.h brpaqu.h
+$(EXE)tmtacq : $(OBJ)tmtacq.o  $(PKGOLIST)
+	$(CXXLINK) -o $(EXE)tmtacq $(OBJ)tmtacq.o $(PKGOLIST) $(SOPHYAALLSLBLIST)
+
+$(OBJ)tmtacq.o : tmtacq.cc $(PKGHLIST)
 	$(CXXCOMPILE) -c -DNOPCIECARD -o $(OBJ)tmtacq.o tmtacq.cc 
 
-$(OBJ)brparam.o : brparam.cc brparam.h
+$(OBJ)brparam.o : brparam.cc $(PKGHLIST)
 	$(CXXCOMPILE) -c -o $(OBJ)brparam.o brparam.cc 
 
-$(OBJ)racqumem.o : racqumem.cc racqumem.h
+$(OBJ)racqumem.o : racqumem.cc $(PKGHLIST)
 	$(CXXCOMPILE) -c -o $(OBJ)racqumem.o racqumem.cc 
 
-$(OBJ)racqurw.o : racqurw.cc racqurw.h racqumem.h brpaqu.h
+$(OBJ)racqurw.o : racqurw.cc $(PKGHLIST)
 	$(CXXCOMPILE) -c -o $(OBJ)racqurw.o racqurw.cc 
 
-$(OBJ)racqueth.o : racqueth.cc racqueth.h racqurw.h racqumem.h brpaqu.h
+$(OBJ)racqueth.o : racqueth.cc $(PKGHLIST)
 	$(CXXCOMPILE) -c -o $(OBJ)racqueth.o racqueth.cc 
 
-$(OBJ)racquproc.o : racquproc.cc racquproc.h racqurw.h racqumem.h brpaqu.h
+$(OBJ)racquproc.o : racquproc.cc $(PKGHLIST)
 	$(CXXCOMPILE) -c -o $(OBJ)racquproc.o racquproc.cc 
 
@@ -61,29 +66,47 @@
 	echo '---vismfib made'
 
-$(EXE)vismfib : $(OBJ)vismfib.o  $(OBJ)branap.o $(OBJ)brdiskw.o $(OBJ)brparam.o $(OBJ)racqumem.o $(OBJ)brfitsrd.o $(OBJ)brproc.o $(OBJ)brbaseproc.o $(OBJ)racquproc.o $(OBJ)brpaqu.o \
-             $(OBJ)racqurw.o $(OBJ)pciewrap.o $(OBJ)minifits.o
-	$(CXXLINK) -o $(EXE)vismfib $(OBJ)vismfib.o $(OBJ)branap.o $(OBJ)brdiskw.o $(OBJ)brparam.o $(OBJ)racqumem.o $(OBJ)brfitsrd.o $(OBJ)brproc.o $(OBJ)brbaseproc.o $(OBJ)racquproc.o \
-                      $(OBJ)brpaqu.o $(OBJ)racqurw.o $(OBJ)pciewrap.o $(OBJ)minifits.o $(SOPHYAALLSLBLIST)
-
-$(OBJ)vismfib.o : vismfib.cc branap.h brfitsrd.h racqumem.h brproc.h brbaseproc.h racqurw.h
+$(EXE)vismfib : $(OBJ)vismfib.o $(PKGOLIST)
+	$(CXXLINK) -o $(EXE)vismfib $(OBJ)vismfib.o $(PKGOLIST) $(SOPHYAALLSLBLIST)
+
+$(OBJ)vismfib.o : vismfib.cc $(PKGHLIST)
 	$(CXXCOMPILE) -c  -o $(OBJ)vismfib.o vismfib.cc 
 
-
+#......
+specmfib : $(EXE)specmfib
+	echo '---specmfib made'
+
+$(EXE)specmfib : $(OBJ)specmfib.o $(PKGOLIST)
+	$(CXXLINK) -o $(EXE)specmfib $(OBJ)specmfib.o $(PKGOLIST) $(SOPHYAALLSLBLIST)
+
+$(OBJ)specmfib.o : specmfib.cc $(PKGHLIST)
+	$(CXXCOMPILE) -c  -o $(OBJ)specmfib.o specmfib.cc 
+
+#......
 treadmfib : $(EXE)treadmfib
 	echo '---treadmfib made'
 
-$(EXE)treadmfib : $(OBJ)treadmfib.o  $(OBJ)branap.o $(OBJ)brdiskw.o $(OBJ)brparam.o $(OBJ)racqumem.o $(OBJ)brfitsrd.o $(OBJ)brproc.o $(OBJ)brbaseproc.o $(OBJ)racquproc.o $(OBJ)brpaqu.o \
-             $(OBJ)racqurw.o $(OBJ)pciewrap.o $(OBJ)minifits.o
-	$(CXXLINK) -o $(EXE)treadmfib $(OBJ)treadmfib.o $(OBJ)branap.o $(OBJ)brdiskw.o $(OBJ)brparam.o $(OBJ)racqumem.o $(OBJ)brfitsrd.o $(OBJ)brproc.o $(OBJ)brbaseproc.o $(OBJ)racquproc.o \
-                      $(OBJ)brpaqu.o $(OBJ)racqurw.o $(OBJ)pciewrap.o $(OBJ)minifits.o $(SOPHYAALLSLBLIST)
-
-$(OBJ)treadmfib.o : treadmfib.cc branap.h brfitsrd.h racqumem.h brproc.h brbaseproc.h racqurw.h
+$(EXE)treadmfib : $(OBJ)treadmfib.o  $(PKGOLIST)
+	$(CXXLINK) -o $(EXE)treadmfib $(OBJ)treadmfib.o $(PKGOLIST) $(SOPHYAALLSLBLIST)
+
+$(OBJ)treadmfib.o : treadmfib.cc $(PKGHLIST)
 	$(CXXCOMPILE) -c  -o $(OBJ)treadmfib.o treadmfib.cc 
 
-$(OBJ)branap.o : branap.cc branap.h 
+$(OBJ)branap.o : branap.cc $(PKGHLIST)
 	$(CXXCOMPILE) -c  -o $(OBJ)branap.o branap.cc 
 
-$(OBJ)brdiskw.o : brdiskw.cc brdiskw.h 
+$(OBJ)brdiskw.o : brdiskw.cc $(PKGHLIST)
 	$(CXXCOMPILE) -c  -o $(OBJ)brdiskw.o brdiskw.cc 
+
+$(OBJ)brfitsrd.o : brfitsrd.cc $(PKGHLIST)
+	$(CXXCOMPILE) -c -o $(OBJ)brfitsrd.o brfitsrd.cc 
+
+$(OBJ)brviscalc.o : brviscalc.cc $(PKGHLIST)
+	$(CXXCOMPILE) -c  -o $(OBJ)brviscalc.o brviscalc.cc 
+
+$(OBJ)brproc.o : brproc.cc $(PKGHLIST)
+	$(CXXCOMPILE) -c  -o $(OBJ)brproc.o brproc.cc 
+
+$(OBJ)brbaseproc.o : brbaseproc.cc brbaseproc.h racqumem.h brpaqu.h
+	$(CXXCOMPILE) -c  -o $(OBJ)brbaseproc.o brbaseproc.cc 
 
 ##   --------------
@@ -91,20 +114,9 @@
 	echo '---mcrd made'
 
-$(EXE)mcrd : $(OBJ)mcrd.o  $(OBJ)brparam.o $(OBJ)racqumem.o $(OBJ)brfitsrd.o $(OBJ)brproc.o $(OBJ)brbaseproc.o $(OBJ)racquproc.o $(OBJ)brpaqu.o \
-             $(OBJ)racqurw.o $(OBJ)pciewrap.o $(OBJ)minifits.o
-	$(CXXLINK) -o $(EXE)mcrd $(OBJ)mcrd.o $(OBJ)brparam.o  $(OBJ)racqumem.o $(OBJ)brfitsrd.o $(OBJ)brproc.o $(OBJ)brbaseproc.o $(OBJ)racquproc.o \
-                      $(OBJ)brpaqu.o $(OBJ)racqurw.o $(OBJ)pciewrap.o $(OBJ)minifits.o $(SOPHYAALLSLBLIST)
-
-$(OBJ)mcrd.o : mcrd.cc brfitsrd.h racqumem.h brproc.h brbaseproc.h racqurw.h
+$(EXE)mcrd : $(OBJ)mcrd.o  $(PKGOLIST)
+	$(CXXLINK) -o $(EXE)mcrd $(OBJ)mcrd.o $(PKGOLIST) $(SOPHYAALLSLBLIST)
+
+$(OBJ)mcrd.o : mcrd.cc $(PKGHLIST)
 	$(CXXCOMPILE) -c  -o $(OBJ)mcrd.o mcrd.cc 
-
-$(OBJ)brfitsrd.o : brfitsrd.cc brfitsrd.h racqumem.h brpaqu.h
-	$(CXXCOMPILE) -c -o $(OBJ)brfitsrd.o brfitsrd.cc 
-
-$(OBJ)brproc.o : brproc.cc brproc.h  brbaseproc.h racqumem.h brpaqu.h
-	$(CXXCOMPILE) -c  -o $(OBJ)brproc.o brproc.cc 
-
-$(OBJ)brbaseproc.o : brbaseproc.cc brbaseproc.h racqumem.h brpaqu.h
-	$(CXXCOMPILE) -c  -o $(OBJ)brbaseproc.o brbaseproc.cc 
 
 ##   --------------
@@ -126,30 +138,4 @@
 $(OBJ)svv2mtx2.o : svv2mtx2.cc 
 	$(CXXCOMPILE) -o $(OBJ)svv2mtx2.o svv2mtx2.cc
-
-##   --------------
-tbrpaq : $(EXE)tbrpaq
-	echo '---tbrpaq made'
-
-$(EXE)tbrpaq : $(OBJ)tbrpaq.o $(OBJ)brpaqu.o 
-	$(CXXLINK) -o $(EXE)tbrpaq $(OBJ)tbrpaq.o $(OBJ)brpaqu.o  $(SOPHYAALLSLBLIST)
-
-$(OBJ)tbrpaq.o : tbrpaq.cc brpaqu.h
-	$(CXXCOMPILE) -c -o $(OBJ)tbrpaq.o tbrpaq.cc 
-
-$(OBJ)brpaqu.o : brpaqu.cc brpaqu.h
-	$(CXXCOMPILE) -c -o $(OBJ)brpaqu.o brpaqu.cc 
-
-##   --------------
-tpciew : $(EXE)tpciew
-	echo '---tpciew made'
-
-$(EXE)tpciew : $(OBJ)tpciew.o $(OBJ)pciewrap.o
-	$(CXXLINK) -o $(EXE)tpciew  $(OBJ)tpciew.o $(OBJ)pciewrap.o $(SOPHYAEXTSLBLIST)
-
-$(OBJ)tpciew.o : tpciew.cc pciewrap.h
-	$(CXXCOMPILE) -o $(OBJ)tpciew.o tpciew.cc
-
-$(OBJ)pciewrap.o : pciewrap.cc pciewrap.h
-	$(CXXCOMPILE) -o $(OBJ)pciewrap.o pciewrap.cc
 
 ##   --------------  Lecture minifits et calcul de spectre 
@@ -184,4 +170,33 @@
 $(OBJ)minifits.o : minifits.cc minifits.h
 	$(CXXCOMPILE) -o $(OBJ)minifits.o minifits.cc
+
+
+
+##   --------------
+tbrpaq : $(EXE)tbrpaq
+	echo '---tbrpaq made'
+
+$(EXE)tbrpaq : $(OBJ)tbrpaq.o $(OBJ)brpaqu.o 
+	$(CXXLINK) -o $(EXE)tbrpaq $(OBJ)tbrpaq.o $(OBJ)brpaqu.o  $(SOPHYAALLSLBLIST)
+
+$(OBJ)tbrpaq.o : tbrpaq.cc brpaqu.h
+	$(CXXCOMPILE) -c -o $(OBJ)tbrpaq.o tbrpaq.cc 
+
+$(OBJ)brpaqu.o : brpaqu.cc brpaqu.h
+	$(CXXCOMPILE) -c -o $(OBJ)brpaqu.o brpaqu.cc 
+
+##   --------------
+tpciew : $(EXE)tpciew
+	echo '---tpciew made'
+
+$(EXE)tpciew : $(OBJ)tpciew.o $(OBJ)pciewrap.o
+	$(CXXLINK) -o $(EXE)tpciew  $(OBJ)tpciew.o $(OBJ)pciewrap.o $(SOPHYAEXTSLBLIST)
+
+$(OBJ)tpciew.o : tpciew.cc pciewrap.h
+	$(CXXCOMPILE) -o $(OBJ)tpciew.o tpciew.cc
+
+$(OBJ)pciewrap.o : pciewrap.cc pciewrap.h
+	$(CXXCOMPILE) -o $(OBJ)pciewrap.o pciewrap.cc
+
 
 ##   -------------- Tests performances I/O et FFT multi-threads
Index: /trunk/AddOn/TAcq/specmfib.cc
===================================================================
--- /trunk/AddOn/TAcq/specmfib.cc	(revision 3872)
+++ /trunk/AddOn/TAcq/specmfib.cc	(revision 3872)
@@ -0,0 +1,111 @@
+// Utilisation de SOPHYA pour faciliter les tests ...
+#include "sopnamsp.h"
+#include "machdefs.h"
+
+/* ---------------------------------------------------------- 
+   Programme de lecture multifibres, calcul de spectres 
+   BAORadio -   LAL/IRFU      R. Ansari, C. Magneville
+   Septembre 2010 
+   ---------------------------------------------------------- */
+
+// include standard c/c++
+#include <iostream>
+#include <string>
+#include <exception>
+
+// include sophya mesure ressource CPU/memoire ...
+#include "resusage.h"
+#include "ctimer.h"
+#include "timing.h"
+#include "timestamp.h"
+#include "strutilxx.h"
+#include "tarrinit.h"
+#include "histinit.h"
+
+#include "brpaqu.h"
+#include "brfitsrd.h"
+#include "brproc.h"
+#include "brdiskw.h"
+
+#include "branap.h"
+
+
+
+//----------------------------------------------------
+//----------------------------------------------------
+int main(int narg, char* arg[])
+{
+
+  TArrayInitiator  _inia;
+
+  int rc = 0;
+  try {
+    // Decodage parametres 
+    BRAnaParam par;
+    par.action_="mspec";
+    cout << " ===> specmfib.cc: decoding command line arguments " << endl;
+    rc = par.DecodeArgs(narg, arg);
+    if (rc) return rc;
+    rc = par.PaqSizeFromFits();
+    if (rc) return rc;
+    par.Print(cout);
+    if ((par.action_!="cube3d")&&(par.action_!="mspec")) {
+      cout << " !!! specmfib.cc  BAD action = " << par.action_ << " possible values: mspec,cube3d" << endl;
+      return 5;
+    }   
+
+    cout << " ---------- specmfib.cc Start - Action= " << par.action_ << " ------------- " << endl;
+    ResourceUsage resu;
+    BRPaquet paq(par.paqsize_);
+    uint_4 procsz=sizeof(float)*(paq.DataSize()+4);
+    if ((par.fgdatafft_)||(par.action_=="cube3d")) procsz = 0;
+    cout << " specmfib: Creating MemZoneMgr/threads - PaqSz= " << par.paqsize_ 
+	 << " ProcPaqSz=" << procsz << endl;
+    RAcqMemZoneMgr mmgr(par.nzones_, par.dirlist_.size(), par.npaqinzone_, par.paqsize_, procsz);
+    if (par.action_ == "cube3d")  mmgr.SetFinalizedMask((uint_4)MemZS_Saved);
+    else {
+      if (par.fgdatafft_)  mmgr.SetFinalizedMask((uint_4)MemZS_ProcA);
+      else mmgr.SetFinalizedMask((uint_4)MemZS_ProcB);
+    }
+    BRMultiFitsReader reader(mmgr, par.dirlist_, false, par.imin_, par.imax_, par.istep_);
+    reader.SetPrintLevel(par.prtlevel_);
+
+    BRMeanSpecCalculator procms(mmgr, par.outpath_, par.nmean_, par.fgdatafft_, par.fgsinglechannel_);
+    BRFFTCalculator procfft(mmgr, par.fgsinglechannel_);
+    if (!par.fgdatafft_) procms.SetMemZAction(MemZA_ProcB);
+
+    FitsCubeWriter wrt(mmgr, par.outpath_, par.nbloc_);
+
+    cout << " specmfib: Starting threads (reader meanSpecCalculator ...) ... " << endl;
+    reader.start();
+    if (par.action_ == "cube3d")   wrt.start();
+    else {  // Calcul spectre moyenne 
+      if (!par.fgdatafft_)  procfft.start(); 
+      procms.start();
+    }
+    usleep(200000);
+    reader.join();
+    if (par.action_ == "cube3d")  wrt.join();
+    else {
+      if (!par.fgdatafft_)  procfft.join(); 
+      procms.join();
+    }
+    mmgr.Print(cout);
+    cout << resu ; 
+  }
+  catch (std::exception& sex) {
+    cerr << "\n specmfib.cc std::exception :"  << (string)typeid(sex).name() 
+	 << "\n msg= " << sex.what() << endl;
+    rc = 78;
+  }
+  catch (...) {
+    cerr << " specmfib.cc catched unknown (...) exception  " << endl; 
+    rc = 79; 
+  } 
+
+  cout << ">>>> specmfib.cc ------- END ----------- RC=" << rc << endl;
+  return rc;
+
+}
+
+
Index: /trunk/AddOn/TAcq/vismfib.cc
===================================================================
--- /trunk/AddOn/TAcq/vismfib.cc	(revision 3871)
+++ /trunk/AddOn/TAcq/vismfib.cc	(revision 3872)
@@ -26,4 +26,5 @@
 #include "brfitsrd.h"
 #include "brproc.h"
+#include "brviscalc.h"
 #include "brdiskw.h"
 
@@ -43,4 +44,5 @@
     // Decodage parametres 
     BRAnaParam par;
+    cout << " ===> visimfib.cc: decoding command line arguments " << endl;
     rc = par.DecodeArgs(narg, arg);
     if (rc) return rc;
