Index: /trunk/AddOn/TAcq/brproc.cc
===================================================================
--- /trunk/AddOn/TAcq/brproc.cc	(revision 3646)
+++ /trunk/AddOn/TAcq/brproc.cc	(revision 3647)
@@ -10,4 +10,5 @@
 #include "tvector.h"
 #include "ntuple.h"
+#include "datatable.h"
 #include "fioarr.h"
 #include "timestamp.h"
@@ -78,5 +79,5 @@
 //    filog << " ... NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl;	
 
-// NTuple 
+/*----DELETE   NTuple 
     const char* nnames[8] = {"fcs","tts","s1","s2","s12","s12re","s12im","s12phi"};
     NTuple nt(8, nnames);
@@ -84,4 +85,5 @@
     uint_4 nmnt = 0;
     double ms1,ms2,ms12,ms12re,ms12im,ms12phi;
+----*/
 // Initialisation pour calcul FFT 
     TVector< complex<r_4> > cfour1;  // composant TF
@@ -113,4 +115,9 @@
     uint_4 ifile = 0;  			        
     uint_4 nzm = 0;  
+
+    uint_4 curfc=0;
+    uint_8 curtt=0;
+    uint_8 firsttt=0;
+    bool fgfirst=true;
     for (uint_4 kmz=0; kmz<nmax_; kmz++) {
       if (stop_) break;
@@ -126,9 +133,11 @@
         break;	
       }
-      nmnt=0;  ms1=ms2=ms12=ms12re=ms12im=ms12phi=0.;
+//---- DELETE      nmnt=0;  ms1=ms2=ms12=ms12re=ms12im=ms12phi=0.;
       for(uint_4 i=0; i<memgr.NbPaquets(); i++) {
   	    BRPaquet paq(NULL, buff+i*paqsz, paqsz); 
         if (!pcheck.Check(paq)) continue;   // on ne traite que les paquets OK
-        
+        if (fgfirst) { firsttt=paq.TimeTag(); fgfirst=false; } 
+        curfc=paq.FrameCounter();
+        curtt=paq.TimeTag()-firsttt;
 // Traitement voie 1  	    
   	    for(sa_size_t j=0; j<vx.Size(); j++) 
@@ -154,5 +163,14 @@
           visiV12(j)+=cfour1(j)*conj(cfour2(j));
 //        for(sa_size_t j=0; j<visiV12.Size(); j++) visiV12(j)+=zp1[j]*zp2[j];
+        if (nzm==0) {
+          spectreV1.Info()["StartFC"] = curfc;
+          spectreV2.Info()["StartFC"] = curfc;
+          visiV12.Info()["StartFC"] = curfc;
+          spectreV1.Info()["StartTT"] = curtt;
+          spectreV2.Info()["StartTT"] = curtt;
+          visiV12.Info()["StartTT"] = curtt;
+        }
         nzm++;   
+/*----DELETE
         if (nmnt==0)  { xnt[0]=paq.FrameCounter();  xnt[1]=paq.TimeTag(); }
         for(sa_size_t j=2700; j<2800; j++) { 
@@ -163,8 +181,11 @@
         } 
         nmnt++;    
+----*/
         totnbytesproc += paq.DataSize();
         totnbytesout += (2*sizeof(complex<r_4>)*cfour1.Size());
 
       } // Fin de boucle sur les paquets d'une zone
+
+/*---- DELETE
       if (nmnt>0)  {
       	double fnorm = (double)nmnt*(2800-2700); 
@@ -177,4 +198,5 @@
         nt.Fill(xnt);
       }
+----*/
       if ((nzm >= nmean_) || ((kmz==(nmax_-1))&&(nzm>1))) {
         spectreV1 /= (r_4)(nzm);
@@ -186,4 +208,10 @@
         spectreV2.Info()["NPaqMoy"] = nzm;
         visiV12.Info()["NPaqMoy"] = nzm;
+        spectreV1.Info()["EndFC"] = curfc;
+        spectreV2.Info()["EndFC"] = curfc;
+        visiV12.Info()["EndFC"] = curfc;
+        spectreV1.Info()["EndTT"] = curtt;
+        spectreV2.Info()["EndTT"] = curtt;
+        visiV12.Info()["EndTT"] = curtt;
 	    {
     	sprintf(fname,"%s_%d.ppf",path_.c_str(),(int)ifile);
@@ -214,5 +242,7 @@
   cout << " ------------  BRProcARaw2C::run() END " << card2name_(card_) 
        << " ------------ " << endl;
-  {     
+/*---- DELETE
+  {
+  nt.Info()["FirstTT"]=firsttt;     
   cout << nt;
   sprintf(fname,"%s_nt.ppf",path_.c_str());
@@ -220,5 +250,6 @@
   po << PPFNameTag("ntv12") << nt; 
   cout << " BRProcARaw2C::run() created NTuple file " << fname << card2name_(card_) << endl;
-  }     
+  }
+---- */ 
   ts.SetNow();
   tm.SplitQ();
@@ -320,4 +351,11 @@
          << " *8="  << szfour*8 << endl;
 
+    DataTable dt;
+    dt.AddLongColumn("fc1");
+    dt.AddLongColumn("fc2");
+    dt.AddLongColumn("tt1");
+    dt.AddLongColumn("tt2");
+    DataTableRow dtr = dt.EmptyRow();
+
     uint_4 nzm = 0;
     uint_4 totnoksfc = 0;
@@ -325,4 +363,12 @@
     uint_4 totnpaq = 0;
     uint_4 ifile = 0;
+
+    uint_4 curfc=0;
+    uint_8 curtt=0;
+    uint_4 curfc2=0;
+    uint_8 curtt2=0;
+    uint_8 firsttt=0;
+    uint_8 firsttt2=0;
+    bool fgfirst=true;
     for (uint_4 kmz=0; kmz<nmax_; kmz++) {
       uint_4 noksfc = 0;
@@ -377,4 +423,18 @@
         // Les deux framecounters sont identiques ...
         noksfc++;
+        curfc=paq1.FrameCounter();
+        curfc2=paq2.FrameCounter();
+        if (fgfirst) { 
+          firsttt=paq1.TimeTag();  firsttt=paq2.TimeTag(); 
+          cout << " BRProcBRaw4C()/Info First FC="<<curfc<<" , "<<curfc2<<" -> TT=" 
+               << firsttt<<" , "<<firsttt2 <<endl;
+          fgfirst=false; 
+        } 
+        curtt=paq1.TimeTag()-firsttt;
+        curtt2=paq2.TimeTag()-firsttt2;
+        dtr[0]=curfc;  dtr[1]=curtt;
+        dtr[2]=curfc2;  dtr[3]=curtt2;
+        dt.AddRow(dtr);
+
         complex<r_4>* zp1 = (complex<r_4>*)(procbuff1+i1*procpaqsz);
         complex<r_4>* zp2 = (complex<r_4>*)(procbuff1+i1*procpaqsz+procpaqsz/2);
@@ -387,4 +447,14 @@
           visiV24(j)+=zp2[j]*conj(zp4[j]);
         }
+        if (nzm==0) {
+          visiV13.Info()["StartFC"] = curfc;
+          visiV14.Info()["StartFC"] = curfc;
+          visiV23.Info()["StartFC"] = curfc;
+          visiV24.Info()["StartFC"] = curfc;
+          visiV13.Info()["StartTT"] = curtt;
+          visiV14.Info()["StartTT"] = curtt;
+          visiV23.Info()["StartTT"] = curtt;
+          visiV24.Info()["StartTT"] = curtt;
+        }
         nzm++;  i1++; i2++;
         totnbytesproc += 2*paq1.DataSize();
@@ -402,4 +472,12 @@
         visiV23.Info()["NPaqMoy"] = nzm;
         visiV24.Info()["NPaqMoy"] = nzm;
+        visiV13.Info()["EndFC"] = curfc;
+        visiV14.Info()["EndFC"] = curfc;
+        visiV23.Info()["EndFC"] = curfc;
+        visiV24.Info()["EndFC"] = curfc;
+        visiV13.Info()["EndTT"] = curtt;
+        visiV14.Info()["EndTT"] = curtt;
+        visiV23.Info()["EndTT"] = curtt;
+        visiV24.Info()["EndTT"] = curtt;
         char fname[512];
 	{
@@ -427,4 +505,14 @@
     }  // Fin de boucle sur les zones a traiter 
     cout << " ------------------  BRProcBRaw4C::run() END ----------------- " << endl;
+    {     
+    dt.Info()["FirstTT1"]=firsttt;     
+    dt.Info()["FirstTT2"]=firsttt2;     
+    cout << dt;
+    char fname[512];
+    sprintf(fname,"%s_fctt.ppf",path_.c_str());
+    POutPersist po(fname);
+    po << PPFNameTag("ttfc") << dt; 
+    cout << " BRProcBRaw4C::run() created TimeTag/FrameCounter file " << fname  << endl;
+    }     
     ts.SetNow();
     tm.SplitQ();
Index: /trunk/AddOn/TAcq/svv2mtx.cc
===================================================================
--- /trunk/AddOn/TAcq/svv2mtx.cc	(revision 3646)
+++ /trunk/AddOn/TAcq/svv2mtx.cc	(revision 3647)
@@ -40,5 +40,5 @@
 int Usage(bool fgshort=true);
 // Pour traitement (calcul FFT et visibilites (ProcA) 1 fibre, 2 voies RAW)
-int ProcSVFiles(string& inoutpath, int imin, int imax, int istep, int jf1, int jf2, int card=1);
+int ProcSVFiles(string& inoutpath, int imin, int imax, int istep, int jf1, int jf2, int nfreq, int card=1);
 
 //----------------------------------------------------
@@ -61,5 +61,6 @@
     int jf1=0;
     int jf2=0;
-    sscanf(arg[3],"%d,%d",&jf1,&jf2);
+    int nfreq=0;
+    sscanf(arg[3],"%d,%d,%d",&jf1,&jf2,&nfreq);
     cout << " ----- svv2mtx.cc Start - InOutPath= " << inoutpath << " IMin,Max,Step=" 
          << imin << "," << imax << "," << istep << " JF=" << jf1 << "," << jf2 << "  ------- " << endl;
@@ -94,17 +95,17 @@
 
 // Pour traitement (calcul FFT et visibilites (ProcA) 1 fibre, 2 voies RAW)
-int ProcSVFiles(string& inoutpath, int imin, int imax, int istep, int jf1, int jf2, int card)
+int ProcSVFiles(string& inoutpath, int imin, int imax, int istep, int jf1, int jf2, int nfreq, int card)
 {
   Timer tm("ProcSVFiles");
   char fname[512];
 // NTuple 
-  const char* nnames[8] = {"fcs","tts","s1","s2","s12","s12re","s12im","s12phi"};
-  NTuple nt(8, nnames);
-  double xnt[10];
+  const char* nnames[10] = {"fcsm","ttsm","jfreq","s1","s2","s12","s12re","s12im","s12phi","s12mod"};
+  NTuple nt(10, nnames);
+  double xnt[15];
   uint_4 nmnt = 0;
-  double ms1,ms2,ms12,ms12re,ms12im,ms12phi;
+  double ms1,ms2,ms12,ms12re,ms12im,ms12phi,ms12mod;
 
   TMatrix<r_4> s1, s2;
-  TMatrix<r_4> v12re, v12im, v12phi;
+  TMatrix<r_4> v12re, v12im, v12phi,v12mod;
   sa_size_t ncols = (imax-imin+1)/istep;
   sa_size_t nrows = 10;
@@ -143,4 +144,5 @@
       v12im.SetSize(nrows, ncols);
       v12phi.SetSize(nrows, ncols);
+      v12mod.SetSize(nrows, ncols);
     }
     s1.Column(kc) = sv1;
@@ -149,26 +151,38 @@
     v12im.Column(kc) = imag(vv12);
     v12phi.Column(kc) = phase(vv12);
-    nmnt=0;  ms1=ms2=ms12=ms12re=ms12im=ms12phi=0.;
-    for(sa_size_t jf=jf1; jf<=jf2; jf++) { 
-      ms1 += s1(jf,kc);
-      ms2 += s2(jf,kc);
-      ms12re += v12re(jf,kc);
-      ms12im += v12im(jf,kc);
-      ms12phi += v12phi(jf,kc);
-    }
-    nmnt = (jf2-jf1+1);
-    if (nmnt>0)  {
-      double fnorm = (double)nmnt; 
-      xnt[0] = kc;
-      xnt[1] = 0;
-      xnt[2] = ms1 /= fnorm;
-      xnt[3] = ms2 /= fnorm;
-      xnt[4] = ms12 /= fnorm;
-      xnt[5] = ms12re /= fnorm;
-      xnt[6] = ms12im /= fnorm;
-      xnt[7] = ms12phi /= fnorm;
-      nt.Fill(xnt);
-    }
-
+    v12mod.Column(kc) = module(vv12);
+
+// Calcul moyenne dans des bandes en frequence 
+    int deltajf=(jf2-jf1)/nfreq;
+    if (deltajf<1) deltajf=1; 
+    for(int kf=0; kf<nfreq; kf++) {
+      sa_size_t jfstart=jf1+kf*deltajf;
+      sa_size_t jfend=jfstart+deltajf;
+      if (jfend>jf2)  break;
+      nmnt=0;  ms1=ms2=ms12=ms12re=ms12im=ms12phi=ms12mod=0.;
+      for(sa_size_t jf=jfstart; jf<jfend; jf++) { 
+        ms1 += s1(jf,kc);
+        ms2 += s2(jf,kc);
+        ms12re += v12re(jf,kc);
+        ms12im += v12im(jf,kc);
+        ms12phi += v12phi(jf,kc);
+        ms12mod += v12mod(jf,kc);
+      }
+      nmnt = (jfend-jfstart);
+      if (nmnt>0)  {
+        double fnorm = (double)nmnt; 
+        xnt[0] = ((int_8)(sv1.Info()["StartFC"])+(int_8)(sv1.Info()["EndFC"]))*0.5;
+        xnt[1] = ((int_8)(sv1.Info()["StartTT"])+(int_8)(sv1.Info()["EndTT"]))*0.5;
+        xnt[2] = kf;
+        xnt[3] = ms1/fnorm;
+        xnt[4] = ms2/fnorm;
+        xnt[5] = ms12/fnorm;
+        xnt[6] = ms12re/fnorm;
+        xnt[7] = ms12im/fnorm;
+        xnt[8] = ms12phi/fnorm;
+        xnt[9] = ms12mod/fnorm;
+        nt.Fill(xnt);
+      }
+    }
     kc++;
 
@@ -213,5 +227,5 @@
 {
   cout << " --- svv2mtx.cc : Read PPF files produced by mcrd to make matrices BAORadio" << endl;
-  cout << " Usage:  mcrd InOutPath Imin,Imax,step NumFreq1,NumFreq2 [card=1]" << endl; 
+  cout << " Usage:  mcrd InOutPath Imin,Imax,step NumFreq1,NumFreq2,NBinFreq [card=1]" << endl; 
   if (fgshort) {
     cout << " mcrd -h for detailed instructions" << endl;
@@ -221,4 +235,5 @@
   cout << " Imin,Imax,IStep: Input PPF files sequence number \n"
        << "    FileNames=InOutPath/Ch12_II.fits Imin<=II<=Imax II+=IStep \n" 
+       << " NumFreq1,NumFreq2,NBinFreq: Freq Zone and number of frequency bins for ntuple\n"
        << " card=1 Ch12 , card=2 Ch34 " << endl;
   return 1;
