Index: /trunk/ArchTOIPipe/ProcWSophya/toi2map.cc
===================================================================
--- /trunk/ArchTOIPipe/ProcWSophya/toi2map.cc	(revision 1497)
+++ /trunk/ArchTOIPipe/ProcWSophya/toi2map.cc	(revision 1498)
@@ -8,5 +8,5 @@
 ////////////////////////////////////////////////////////////////////////
 TOI2Map::TOI2Map(SphereHEALPix<r_8>* sph,SphereHEALPix<r_8>* wsph)
-  : mSph(sph), mWSph(wsph), mWSphInternal(false), mTypCoor(false), mActualYear(2001.)
+  : mSph(sph), mWSph(wsph), mWSphInternal(false), mTypCoor(false), fTypCoor(false), mActualYear(2001.)
 {
  if(mSph->NbPixels()<1) {
@@ -42,6 +42,6 @@
 void TOI2Map::init() {
   cout << "TOI2Map::init" << endl;
-  declareInput("AlphaIn");     // input index 0
-  declareInput("DeltaIn");     // input index 1
+  declareInput("Coord1In");     // input index 0
+  declareInput("Coord2In");     // input index 1
   declareInput("BoloIn");      // input index 2
 }
@@ -58,6 +58,6 @@
 }
 if(!checkInputTOIIndex(0) || !checkInputTOIIndex(1) || !checkInputTOIIndex(2)) {
-  cout<<"TOI2Map::run() - Input TOI (AlphaIn or DeltaIn or BoloIn) not connected! "<<endl;
-  throw ParmError("TOI2Map::run() Output TOI (AlphaIn or DeltaIn or BoloIn) not connected!");
+  cout<<"TOI2Map::run() - Input TOI (Coord1In or Coord2In or BoloIn) not connected! "<<endl;
+  throw ParmError("TOI2Map::run() Output TOI (Coord1In or Coord2In or BoloIn) not connected!");
 }
 
@@ -75,24 +75,39 @@
   double bolo;
 
-  double alpha = getData(0,s); // alpha entre [0,24[ en heures
-  double delta = getData(1,s); // delta entre [-90,90] en degres
+  double coord1 = getData(0,s); // gLat ou delta entre [-90,90] en degres
+  double coord2 = getData(1,s); // gLon entre [0,360[ en degres ou alpha entre [0,24[ en heures
   getData(2,s,bolo,fgbolo);
 
-  if(delta<-90. || delta>90.)  fgbolo=1;
-  if(alpha<0.   || alpha>=24.) fgbolo=1;
+  if(coord2<-90. || coord2>90.) fgbolo=1; 
+  if((coord1<0.) || (!mTypCoor && coord1>=24.) || (mTypCoor && coord1>=360.) ) {fgbolo=1; 
+  cout << "!!!!!!!!" <<coord1 << endl;
+  }
+  
+  
+  
   if(bolo<-32767.) fgbolo=1;   // Bidouille Archeops
-
+  
   if(!fgbolo) {
+    // sphere phi entre [0,2*Pi] en radians
     // sphere phi entre [0,2*Pi] en radians
     // sphere theta entre [0,Pi] en radians
     double phi,theta;
-    if(mTypCoor) {
+    if(fTypCoor && !mTypCoor) { //on a alpha,delta et on veut l,b
       double mjd = MJDfrYear(mActualYear);
-      EqtoGal(mjd,alpha,delta,&alpha,&delta);
-      phi   = alpha * M_PI/180.;
-    } else phi = alpha * M_PI/12.;
-    theta = (90.-delta)*M_PI/180.;
+      EqtoGal(mjd,coord1,coord2,&coord1,&coord2);
+    } 
+
+    if(!fTypCoor && mTypCoor) { //on a l,b et on veut alpha,delta
+      double mjd = MJDfrYear(mActualYear);
+      GaltoEq(mjd,coord1,coord2,&coord1,&coord2);
+    }
+    
+    if(fTypCoor) phi = coord1 * M_PI/180.;
+    else  phi = coord1 * M_PI/12.;
+
+    theta = (90.-coord2)*M_PI/180.;
+
     int_4 ipix = mSph->PixIndexSph(theta,phi);
-    (*mSph)(ipix) += bolo;
+    (*mSph)(ipix) += bolo;    
     ((*mWSph)(ipix))++;
     mNSnFill++;
Index: /trunk/ArchTOIPipe/ProcWSophya/toi2map.h
===================================================================
--- /trunk/ArchTOIPipe/ProcWSophya/toi2map.h	(revision 1497)
+++ /trunk/ArchTOIPipe/ProcWSophya/toi2map.h	(revision 1498)
@@ -15,6 +15,6 @@
 //                         |
 //                    -----------
-//   toi AlphaIn ---> |         |
-//   toi DeltaIn ---> | TOI2Map |
+//   toi Coord1In ---> |         |
+//   toi Coord2In ---> | TOI2Map |
 //   toi BoloIn  ---> |         |
 //                    -----------
@@ -27,6 +27,6 @@
   virtual void	init(void);  
   virtual void	run(void);
-  inline  void  SetCoorGal(bool fg=false,double actualyear=2000.)
-                          {mTypCoor = fg; mActualYear = actualyear;}
+  inline  void  SetCoorGal(bool mfg=false,bool ffg=false,double actualyear=2000.)
+                          {mTypCoor = mfg; fTypCoor = ffg; mActualYear = actualyear;}
   
 protected:
@@ -35,4 +35,5 @@
   bool mWSphInternal;
   bool mTypCoor;
+  bool fTypCoor;
   double mActualYear;
 };
Index: /trunk/ArchTOIPipe/TestPipes/tsttoi2map.cc
===================================================================
--- /trunk/ArchTOIPipe/TestPipes/tsttoi2map.cc	(revision 1497)
+++ /trunk/ArchTOIPipe/TestPipes/tsttoi2map.cc	(revision 1498)
@@ -1,5 +1,6 @@
 #include <unistd.h>
 #include <stdexcept>
-
+#include <stdlib.h>
+#include <stdio.h>
 #include "toi.h"
 #include "toiprocessor.h"
@@ -17,6 +18,9 @@
 void usage(void) {
  cout<<"tsttoi2map [-h] [-p lp] [-s samplemin,samplemax] [-w data_window_size]"<<endl
-     <<"           [-a label_alpha] [-d label_delta] [-b label_bolomuv]"<<endl
-     <<"           [-n nlat] [-G] fitsin fitsphout fitsphwout"<<endl;
+     <<"           [-a label_coord1] [-d label_coord2] [-b label_bolomuv]"<<endl
+     <<"           [-n nlat] coord_ini coord_fin fitsin_bolo fitsin_point fitsphout fitsphwout"<<endl
+     <<" coord_ini[_fin] = G for Galactic coordinates"<<endl
+     <<"                 = Q for equatorial coordinates"<<endl
+     <<" coord1 = alpha or longitude ; coord2 = delta or latitude"<<endl;
  return;
 }
@@ -30,6 +34,5 @@
 int lp = 0, width = 8192;
 int nlat = 128;   // npixel = 12 * nlat^2
-char *label_alpha = "alpha", *label_delta = "delta", *label_bolomuv = "boloMuV";
-bool coorgal=false;
+char *label_coord1 = "coord1", *label_coord2 = "coord2", *label_bolomuv = "boloMuV";
 long sdeb,sfin;
 int c;
@@ -52,8 +55,8 @@
     break;
   case 'a' :
-    label_alpha = optarg;
+    label_coord1 = optarg;
     break;
   case 'd' :
-    label_delta = optarg;
+    label_coord2 = optarg;
     break;
   case 'b' :
@@ -64,7 +67,4 @@
     if(nlat<0) nlat=128;
     break;
-  case 'G' :
-    coorgal = true;
-    break;
   case 'h' :
     usage(); exit(-1);
@@ -74,16 +74,26 @@
   }
 }
-if(optind+1>=narg) {usage(); exit(-2);}
-char * fitsin          = arg[optind];
-string const fitsphout = arg[optind+1];
+if(optind+3>=narg) {usage(); exit(-2);}
+bool mcoorgal=true;
+bool fcoorgal=true;
+ 
+if ( strcmp(arg[optind],"Q") == 0) mcoorgal=false; 
+if ( strcmp(arg[optind+1],"Q") == 0) fcoorgal=false; 
+ 
+char * fitsin_bolo = arg[optind+2];
+char * fitsin_point = arg[optind+3];
+string const fitsphout = arg[optind+4];
 string fitsphwout = "";
-if(optind+2<narg) fitsphwout = arg[optind+2];
+if(optind+5<narg) fitsphwout = arg[optind+5];
 
 cout<<">>>> tsttoi2map:"<<endl
-    <<"Fits Infile(snum,alpha,delta,bolomuv)= "<<fitsin<<endl
-    <<"  ...label_alpha "<<label_alpha<<"  ,  label_delta "<<label_delta<<endl
+    <<"Fits Infile(snum,bolomuv)= "<<fitsin_bolo<<endl
+    <<"Fits Infile(snum,coord1,coord2)= "<<fitsin_point<<endl
+    <<"  ...label_coord1 "<<label_coord1<<"  ,  label_coord2 "<<label_coord2<<endl
+    <<"  with coordinates Gal "<<mcoorgal<<endl
     <<"  ...label_bolomuv "<<label_bolomuv<<endl
     <<"Fits Sphere Healpix"<<fitsphout<<endl
     <<"  ...nlat "<<nlat<<endl
+    <<"  with coordinates Gal "<<fcoorgal<<endl
     <<"Fits Sphere Healpix Error "<<fitsphwout<<endl;
 
@@ -96,8 +106,13 @@
 
  // FITS reader
- FITSTOIReader rfits(fitsin);
- int ncol = rfits.getNOut();
- cout<<"Number of columns in fits Infile : "<<ncol<<endl;
- if(ncol<3) exit(-3);
+ FITSTOIReader rfitsb(fitsin_bolo);
+ int ncolb = rfitsb.getNOut();
+ cout<<"Number of columns in fits Infile_bolo : "<<ncolb<<endl;
+ if(ncolb<1) exit(-3);
+
+ FITSTOIReader rfitsp(fitsin_point);
+ int ncolp = rfitsp.getNOut();
+ cout<<"Number of columns in fits Infile_point : "<<ncolp<<endl;
+ if(ncolp<2) exit(-3);
 
  // Creation de la sphere Healpix
@@ -117,33 +132,35 @@
  TOI2Map toi2m(sph,wsph);
  cout<<"TOI2Map created"<<endl;
- toi2m.SetCoorGal(coorgal,2000.);  // equinoxe de ref. 2000. (pour archtoi)
+ toi2m.SetCoorGal(mcoorgal,fcoorgal,2000.);  // equinoxe de ref. 2000. (pour archtoi)
 
  // Definition des tuyaux
- TOISeqBuffered * toialphain = new TOISeqBuffered("toi_alpha_in",width);
- if(lp) toialphain->setDebugLevel(1);
- rfits.addOutput(label_alpha,toialphain);
- toi2m.addInput("AlphaIn",toialphain);
-
- TOISeqBuffered * toideltain = new TOISeqBuffered("toi_delta_in",width);
- if(lp) toideltain->setDebugLevel(1);
- rfits.addOutput(label_delta,toideltain);
- toi2m.addInput("DeltaIn",toideltain);
-
+ TOISeqBuffered * toicoord1in = new TOISeqBuffered("toi_coord1_in",width);
+ if(lp) toicoord1in->setDebugLevel(1);
+ rfitsp.addOutput(label_coord1,toicoord1in);
+ toi2m.addInput("Coord1In",toicoord1in);
+
+ TOISeqBuffered * toicoord2in = new TOISeqBuffered("toi_coord2_in",width);
+ if(lp) toicoord2in->setDebugLevel(1);
+ rfitsp.addOutput(label_coord2,toicoord2in);
+ toi2m.addInput("Coord2In",toicoord2in);
+ 
  TOISeqBuffered * toibolin = new TOISeqBuffered("toi_bolo_in",width);
  if(lp) toibolin->setDebugLevel(1);
- rfits.addOutput(label_bolomuv,toibolin);
+ rfitsb.addOutput(label_bolomuv,toibolin);
  toi2m.addInput("BoloIn",toibolin);
 
  // Run
  cout<<"----- FITSReaderTOI::PrintStatus() : -----"<<endl;
- rfits.PrintStatus(cout);
+ rfitsp.PrintStatus(cout);
+ rfitsb.PrintStatus(cout);
 
  PrtTim("starting threads");
- rfits.start();
+ rfitsp.start();
+ rfitsb.start();
  toi2m.start();
 
  if(lp>1)
    for(int jjjj=0;jjjj<5;jjjj++) {
-     cout<<*toialphain; 
+     cout<<*toicoord1in; 
      cout<<*toibolin; 
      sleep(2);
