Index: /trunk/AddOn/TAcq/corrcrtadc.cc
===================================================================
--- /trunk/AddOn/TAcq/corrcrtadc.cc	(revision 4004)
+++ /trunk/AddOn/TAcq/corrcrtadc.cc	(revision 4005)
@@ -1,13 +1,13 @@
-// Utilisation de SOPHYA pour faciliter les tests ...
+// Utilisation de SOPHYA ...
 #include "sopnamsp.h"
 #include "machdefs.h"
 
-/* ---------------------------------------------------------- 
-   Projet BAORadio - (C) LAL/IRFU  2008-2011
-
-   Programme de lecture des fichiers DUMP ADC du CRT (Pittsburgh) 
-   pour calcul de spectres / correlations 
+/* --------------------------------------------------------------- 
+   Projet BAORadio-21cm intensity mapping - (C) LAL/IRFU  2008-2011
+
+   CRT (Pittsburgh-CMU) DUMP ADC read/processing program to compute 
+   spectra and correlations du CRT
    R. Ansari, C. Magneville   -  LAL/Irfu - Juin 2011
-   ---------------------------------------------------------- */
+   --------------------------------------------------------------- */
 
 // include standard c/c++
@@ -20,4 +20,5 @@
 #include <string>
 
+// SOPHYA include files 
 #include "pexceptions.h"
 #include "tvector.h"
@@ -40,11 +41,13 @@
 
 
-//--------------------------- Fonctions de ce fichier   ------------------- 
+//--------------------------- Functions in this file  ------------------- 
 int Usage(bool fgshort=true);
 int DecodeProc(int narg, char* arg[]);
-int ProcessADCFiles(string& inoutpath, vector<int>& adcids, string& outname, int imin, int imax, int istep,  int jf1, int jf2, int nfreq);
-int ComputeCorrel(TMatrix< complex<r_4> >& cfour,  TMatrix< complex<r_8> >& correl, TMatrix< complex<r_8> >& autocorrel);
+int ProcessADCFiles(string& inoutpath, vector<int>& adcids, string& outname, bool fgcombiq, 
+		    int imin, int imax, int istep,  int jf1, int jf2, int nfreq);
+int ComputeCorrel(TMatrix< complex<r_4> >& cfour,  bool fgcombiq, 
+		  TMatrix< complex<r_8> >& correl, TMatrix< complex<r_8> >& autocorrel);
 int ADCFiles2Histo(string& inoutpath, vector<int>& adcids, string& outname, int imin, int imax, int istep);
-
+int CombineIQPairs(TMatrix< complex<r_4> >& cfour);
 //------------------------------------------------------------------------------------------------------------
 
@@ -53,10 +56,11 @@
 {
   cout << " --- corrcrtadc.cc : Read CRT-ADC dump files and process to produce correlation matrices \n"
-       << " Usage: corrcrtadc -corr/-hval InOutPath OutFile [AdcIds] [Imin,Imax,step]\n" << endl;
+       << " Usage: corrcrtadc -corr/-corciq/-hval InOutPath OutFile [AdcIds] [Imin,Imax,step]\n" << endl;
   if (fgshort) {
     cout << " corrcrtadc -h for detailed instructions" << endl;
     return 1;
   }
-  cout << " -corr/-hval : Compute correlations or Fill histograms for ADC sample values \n" 
+  cout << " -corr/-corciq/-hval : Compute correlations or Fill histograms for ADC sample values \n"
+       << "    -corciq : combine IQ pairs to separate side-bands ... \n" 
        << " InOutPath : Input/Output directory name \n" 
        << " ADCIds : ADC Id's to be processed (Example: 1,2,3,4, default=0,1)  \n" 
@@ -113,11 +117,13 @@
   string popt = arg[0];
   bool fillhis=false;
+  bool fgcomiq=false;
   if (popt=="-hval")  fillhis=true;
+  else if (popt=="-corciq")  fgcomiq=true;
   string inoutpath = arg[1];  
   string outname = arg[2];
-  int aids[4]={0,1,-1,-1};
-  if (narg>3) sscanf(arg[3],"%d,%d,%d,%d",aids,aids+1,aids+2,aids+3);
+  int aids[8]={0,1,-1,-1,-1,-1,-1,-1};
+  if (narg>3) sscanf(arg[3],"%d,%d,%d,%d,%d,%d,%d,%d",aids,aids+1,aids+2,aids+3,aids+4,aids+5,aids+6,aids+7);
   vector<int> adcids;
-  for(int ii=0;ii<4;ii++) 
+  for(int ii=0;ii<8;ii++) 
     if((aids[ii]>=0)&&(aids[ii]<16))  adcids.push_back(aids[ii]);
   int imin=0;
@@ -139,5 +145,5 @@
   int rc=0;
   if (fillhis) rc = ADCFiles2Histo(inoutpath, adcids, outname, imin, imax, istep);
-  else rc=ProcessADCFiles(inoutpath, adcids, outname, imin, imax, istep, jf1, jf2, nfreq);
+  else rc=ProcessADCFiles(inoutpath, adcids, outname, fgcomiq, imin, imax, istep, jf1, jf2, nfreq);
   
   return rc;
@@ -154,5 +160,5 @@
 // Pour traitement (calcul FFT et visibilites (ProcA) 1 fibre, 2 voies RAW)
 /* --Fonction-- */
-int ProcessADCFiles(string& inoutpath, vector<int>& adcids, string& outname, int imin, int imax, int istep, int jf1, int jf2, int nfreq) 
+int ProcessADCFiles(string& inoutpath, vector<int>& adcids, string& outname,  bool fgcombiq, int imin, int imax, int istep, int jf1, int jf2, int nfreq) 
 {
   Timer tm("ProcessADCFiles");  
@@ -210,5 +216,5 @@
 	}
       }
-      ComputeCorrel(cfour, correl, autocorrel);
+      ComputeCorrel(cfour, fgcombiq, correl, autocorrel);
       nsumcor++;
       if (m%PRTMODULO==0)  cout << " ProcessADCFiles/Info Done read+FFT+correl m=" << m << " / Max=" << ADCNREAD << endl;
@@ -255,6 +261,8 @@
 
 /* --Fonction-- */
-int ComputeCorrel(TMatrix< complex<r_4> >& cfour,  TMatrix< complex<r_8> >& correl, TMatrix< complex<r_8> >& autocorrel)
-{
+int ComputeCorrel(TMatrix< complex<r_4> >& cfour,  bool fgcombiq, 
+		  TMatrix< complex<r_8> >& correl, TMatrix< complex<r_8> >& autocorrel)
+{
+  if (fgcombiq)  CombineIQPairs(cfour);
   sa_size_t jcr=0;
   for(sa_size_t j1=0; j1<cfour.NRows(); j1++) {
@@ -266,4 +274,10 @@
     }
   }
+  return 0;
+}
+
+int CombineIQPairs(TMatrix< complex<r_4> >& cfour)
+{
+  // to be coded ...
   return 0;
 }
