Index: /trunk/ArchTOIPipe/ProcWSophya/map2toi.cc
===================================================================
--- /trunk/ArchTOIPipe/ProcWSophya/map2toi.cc	(revision 1519)
+++ /trunk/ArchTOIPipe/ProcWSophya/map2toi.cc	(revision 1520)
@@ -8,4 +8,7 @@
 : mSph(sph)
 {
+ SetEquinox();
+ SetCoorIn();
+ SetCoorMap();
 }
 
@@ -17,9 +20,9 @@
 void Map2TOI::init() {
   cout << "Map2TOI::init" << endl;
-  declareInput("AlphaIn");     // input  index 0
-  declareInput("DeltaIn");     // input  index 1
-  declareOutput("AlphaOut");   // output index 0
-  declareOutput("DeltaOut");   // output index 1
-  declareOutput("BoloOut");    // output index 2
+  declareInput("Coord1In");     // input  index 0
+  declareInput("Coord2In");     // input  index 1
+  declareOutput("Coord1Out");   // output index 0
+  declareOutput("Coord2Out");   // output index 1
+  declareOutput("BoloOut");     // output index 2
 }
 
@@ -39,12 +42,20 @@
 }
 if(!checkInputTOIIndex(0) || !checkInputTOIIndex(1)) {
-  cout<<"Map2TOI::run() - Input TOI (AlphaIn or DeltaIn) not connected! "<<endl;
-  throw ParmError("Map2TOI::run() Output TOI (AlphaIn or DeltaIn) not connected!");
+  cout<<"Map2TOI::run() - Input TOI (Coord1In or Coord2In) not connected! "<<endl;
+  throw ParmError("Map2TOI::run() Output TOI (Coord1In or Coord2In) not connected!");
 }
-bool connected_AlphaOut = checkOutputTOIIndex(0);
-bool connected_DeltaOut = checkOutputTOIIndex(1);
+bool connected_Coord1Out = checkOutputTOIIndex(0);
+bool connected_Coord2Out = checkOutputTOIIndex(1);
 if(!checkOutputTOIIndex(2)) {
   cout<<"Map2TOI::run() - Output TOI (BoloOut) not connected! "<<endl;
   throw ParmError("Map2TOI::run() Output TOI (BoloOut) not connected!");
+}
+if( !(mTypCoorIn&TypCoordEq || mTypCoorIn&TypCoordGal) ) {
+  cout<<"Map2TOI::run() - CoordIn Coordinates not Eq or Gal! "<<endl;
+  throw ParmError("Map2TOI::run() - CoordIn Coordinates not Eq or Gal!");
+}
+if( !(mTypCoorMap&TypCoordEq || mTypCoorMap&TypCoordGal) ) {
+  cout<<"Map2TOI::run() - Sphere Coordinates not Eq or Gal! "<<endl;
+  throw ParmError("Map2TOI::run() - Sphere Coordinates not Eq or Gal!");
 }
 
@@ -52,27 +63,44 @@
 try {
 
+uint_4 mSnRead=0, mSnFilled=0;
+double mjd = MJDfrYear(mActualYear);
+
 for(int k=snb;k<=sne;k++) {
 
   int_8 flg = 0;
-  //  double alpha = getData(0,k); // alpha entre [0,24[ en heures
-  //  if(alpha<0. || alpha>=24.) flg=1;
-  // On passe l'angle en longitude en degres - de [0,360[ deg
-  double alpha = getData(0,k); // alpha entre [0,360[ en heures
-  if(alpha<0. || alpha>=360.) flg=1;
-  double delta = getData(1,k); // delta entre [-90,90] en degres
-  if(delta<-90. || delta>90.) flg=1;
-  double bolo = -99999.;
+  double coord1 = getData(0,k);
+  double coord2 = getData(1,k);
+  double c1 = coord1, c2=coord2, bolo = -99999.;
+  mSnRead++;
+
+  // Convert CoordIn to Standard
+  double phi=-1.,theta;
+  CoordConvertToStd(mTypCoorIn,c1,c2);
+  if(mTypCoorIn&TypCoordEq && mTypCoorMap&TypCoordGal) { // CIn=Eq  CMap=Gal
+    EqtoGal(mjd,c1,c2,&c1,&c2);
+    phi   = c1 * M_PI/180.;
+  } else if(mTypCoorIn&TypCoordGal && mTypCoorMap&TypCoordEq) { // CIn=Gal CMap=Eq
+    GaltoEq(mjd,c1,c2,&c1,&c2);
+    phi   = c1 * M_PI/12.;
+  } else if(mTypCoorMap&TypCoordGal) { // CIn=Gal CMap=Gal
+    phi   = c1 * M_PI/180.;
+  } else if(mTypCoorMap&TypCoordEq) { // CIn=Eq CMap=Eq
+    phi   = c1 * M_PI/12.;
+  }
+  theta = (90.-c2) * M_PI/180.;
+  if(phi<0.   || phi>=2*M_PI) flg=FlgToiOut;
+  if(theta<0. || theta>=M_PI) flg=FlgToiOut;
 
   if(!flg) {
-    //    double phi   = alpha *M_PI/12.; // sphere phi entre [0,2*Pi] en radian
-    double phi   = alpha *M_PI/180.; // sphere phi entre [0,2*Pi] en radian
-    double teta  = (90.-delta) *M_PI/180.; // sphere teta entre [0,Pi] en radian
-    bolo = mSph(teta,phi);
+    bolo = mSph(theta,phi);
+    mSnFilled++;
   }
 
-  if(connected_AlphaOut) putData(0,k,alpha,0);
-  if(connected_DeltaOut) putData(1,k,delta,0);
+  if(connected_Coord1Out) putData(0,k,coord1,flg);
+  if(connected_Coord2Out) putData(1,k,coord2,flg);
   putData(2,k,bolo,flg);
 }
+
+cout<<"TOI2Map::run: Samples Read "<<mSnRead<<" Filled "<<mSnFilled<<endl;
 
 //---------------------------------------------------------
Index: /trunk/ArchTOIPipe/ProcWSophya/map2toi.h
===================================================================
--- /trunk/ArchTOIPipe/ProcWSophya/map2toi.h	(revision 1519)
+++ /trunk/ArchTOIPipe/ProcWSophya/map2toi.h	(revision 1520)
@@ -5,18 +5,25 @@
 #include "toiprocessor.h"
 #include "spherehealpix.h"
+#include "flagtoidef.h"
+#include "xastropack.h"
 
-//-- Un generateur de TOI a partir d'une sphere et de 2 TOIs alpha,delta
-// Lecture de 2 TOI alpha,delta et d'une Sphere Healpix
-// Sortie de 3 TOI alpha,delta,boloMuV
+//-- Un generateur de TOI a partir d'une sphere et de 2 TOIs coordin1,coordin2
+// Lecture de 2 TOI coord1,coord2 et d'une Sphere Healpix
+// Sortie de 3 TOI coord1,coord2,boloMuV
 //
 // Structure generale :
-// (les alpha[0,360[,delta[-90,90] sont en degres decimaux)
 //             Sphere ---- |
 //                         |
-//                    -----------
-//   toi AlphaIn ---> |         | ---> toi AlphaOut
-//                    | Map2TOI | ---> toi DeltaOut
-//   toi DeltaIn ---> |         | ---> toi BoloOut
-//                    -----------
+//                     -----------
+//   toi CoordIn1 ---> |         | ---> toi CoordOut1
+//                     | Map2TOI | ---> toi CoordOut2
+//   toi CoordIn2 ---> |         | ---> toi BoloOut
+//                     -----------
+// Gestion du type de coordonnees :
+// Coord1In,Coord2In : soit Equatoriales (Alpha,Delta)
+//                     soit Galactiques  (GLong,GLat)
+// La sphere peut avoir des coordonnees differentes des CoordIn
+// Si les CoordIn et les CoordSphere sont equatoriales -> meme equinoxe!
+// La sortie CoordOut aura les MEMES coordonnees que les CoordIn
 
 class Map2TOI : public TOIProcessor {
@@ -25,9 +32,19 @@
   virtual	~Map2TOI();
 
-  virtual void	init(void);  
+  virtual void	init(void);
   virtual void	run(void);
-  
+
+  // Pour savoir si on a de HourDeg,DegDeg,RadRad
+  inline void SetEquinox(double actualyear=2000.)
+              {mActualYear = actualyear;}
+  inline void SetCoorIn(TypAstroCoord mfg=TypCoordGalStd)
+              {mTypCoorIn = mfg;}
+  inline void SetCoorMap(TypAstroCoord mfg=TypCoordGalStd)
+              {mTypCoorMap = mfg;}
+
 protected:
   SphereHEALPix<r_8>& mSph;
+  TypAstroCoord mTypCoorIn,mTypCoorMap;
+  double mActualYear;
 };
 
Index: /trunk/ArchTOIPipe/ProcWSophya/toi2map.cc
===================================================================
--- /trunk/ArchTOIPipe/ProcWSophya/toi2map.cc	(revision 1519)
+++ /trunk/ArchTOIPipe/ProcWSophya/toi2map.cc	(revision 1520)
@@ -96,5 +96,5 @@
   // sphere phi   entre [0,2*Pi] en radians
   // sphere theta entre [0,Pi]   en radians
-  double phi,theta;
+  double phi=-1.,theta;
   CoordConvertToStd(mTypCoorIn,coord1,coord2);
   if(mTypCoorIn&TypCoordEq && mTypCoorOut&TypCoordGal) { // Eq -> Gal
Index: /trunk/ArchTOIPipe/ProcWSophya/toi2map.h
===================================================================
--- /trunk/ArchTOIPipe/ProcWSophya/toi2map.h	(revision 1519)
+++ /trunk/ArchTOIPipe/ProcWSophya/toi2map.h	(revision 1520)
@@ -24,4 +24,5 @@
 //                     soit Galactiques  (GLong,GLat)
 // Sortie sur une sphere en coordonnees Equatoriales ou Galactiques
+// Si les CoordIn et les CoordOut sont equatoriales -> meme equinoxe!
 
 class TOI2Map : public TOIProcessor {
Index: /trunk/ArchTOIPipe/TestPipes/tstmap2toi.cc
===================================================================
--- /trunk/ArchTOIPipe/TestPipes/tstmap2toi.cc	(revision 1519)
+++ /trunk/ArchTOIPipe/TestPipes/tstmap2toi.cc	(revision 1520)
@@ -17,7 +17,35 @@
 void usage(void) {
  cout<<"tstmap2toi [-h] [-p lp] [-s samplemin,samplemax] [-w data_window_size]"<<endl
-     <<"           [-a label_alpha] [-d label_delta] [-b label_bolomuv]"<<endl
-     <<"           fitsin fitsphere fitsout"<<endl;
+     <<"           [-a label_coord1In] [-d label_coord2In] [-b label_bolomuv]"<<endl
+     <<"           [-i c,h] [-m c,h]"<<endl
+     <<"           fitsin_point fitsphere fitsout"<<endl
+     <<" -p lp : print level (def=0)"<<endl
+     <<" -s samplemin,samplemax : sample range to be treated (def=all)"<<endl
+     <<" -w data_window_size : window size for pipe (def=8192)"<<endl
+     <<" -a label_coord1 : label fits for alpha/gLong (def=coord1)"<<endl
+     <<" -d label_coord2 : label fits for delta/gLat (def=coord2)"<<endl
+     <<"          coord1 = alpha or gLong ; coord2 = delta or gLat"<<endl
+     <<" -b label_bolomuv : label fits for bolo value (def=boloMuV)"<<endl
+     <<" -i c,h : coordIn caracteristics (c=G/E h=H/D) (def=G,D)"<<endl
+     <<" -m c,h : idem -i for Sphere"<<endl
+     <<" fitsin_point : fits file for pointing"<<endl
+     <<" fitsphere : fits file for input Healpix sphere"<<endl
+     <<" fitsout : fits file for output"<<endl;
  return;
+}
+
+unsigned long typecoord(char typc=' ',char hd=' ');
+unsigned long typecoord(char typc,char hd)
+// typc : G=galactiques, E=equatoriales, autres=galactiques
+// hd : H=heure, D=degre, autres=(heure si typc==E, degre si typc==G)
+{
+  if(typc!='G' && typc!='E') typc='G';
+  if(hd!='H' && hd!='D') {if(typc=='E') hd='H'; else hd='D';}
+ unsigned long rc=TypCoordUndef;
+  if(typc=='G') rc |= TypCoordGal;
+    else        rc |= TypCoordEq;
+  if(hd=='D')   rc |= TypCoordDD;
+    else        rc |= TypCoordHD;
+  return rc;
 }
 
@@ -29,8 +57,9 @@
 //-- Decodage arguments
 int lp = 0, width = 8192;
-char *label_alpha = "alpha", *label_delta = "delta", *label_bolomuv = "boloMuV";
+char *label_coord1 = "coord1", *label_coord2 = "coord2", *label_bolomuv = "boloMuV";
 long sdeb,sfin;
-int c;
-while((c = getopt(narg,arg,"hp:s:w:a:d:b:")) != -1) {
+unsigned long tcoorin=typecoord(), tcoormap=typecoord();
+int c; char t=' ',h=' ';
+while((c = getopt(narg,arg,"hp:s:w:a:d:b:i:m:")) != -1) {
   switch (c) {
   case 's' :
@@ -38,5 +67,5 @@
     cout<<"Requested Samples from "<<sdeb<<" , "<<sfin<<endl;
     if(sfin>=sdeb) mgr->setRequestedSample(sdeb,sfin);
-    else {cout<<"Bad sample interval "<<endl; exit(-2);}
+    else {cout<<"Bad sample interval "<<endl; exit(1);}
     break;
   case 'w' :
@@ -50,30 +79,47 @@
     break;
   case 'a' :
-    label_alpha = optarg;
+    label_coord1 = optarg;
     break;
   case 'd' :
-    label_delta = optarg;
+    label_coord2 = optarg;
     break;
   case 'b' :
     label_bolomuv = optarg;
     break;
+  case 'i' :
+    sscanf(optarg,"%c,%c",&t,&h);
+    tcoorin=typecoord(t,h);
+    break;
+  case 'm' :
+    sscanf(optarg,"%c,%c",&t,&h);
+    tcoormap=typecoord(t,h);
+    break;
   case 'h' :
-    usage(); exit(-1);
-    break;
   default:
-    usage(); exit(-1);
+    usage(); exit(1);
   }
 }
-if(optind+2>=narg) {usage(); exit(-2);}
-char * fitsin          = arg[optind];
+if(optind+2>=narg) {usage(); exit(2);}
+char * fitsin_point    = arg[optind];
 string const fitsphere = arg[optind+1];
 char * fitsout         = arg[optind+2];
 
+{
+unsigned long tg,te,hd,dd;
 cout<<">>>> tstmap2toi:"<<endl
-    <<"Fits Infile(snum,alpha,delta)= "<<fitsin<<endl
-    <<"  ...label_alpha "<<label_alpha<<"  ,  label_delta "<<label_delta<<endl
-    <<"Fits Sphere Healpix"<<fitsphere<<endl
-    <<"Fits Outfile(snum,[alpha,delta],boloMuV)"<<fitsout<<endl
+    <<"Pipe Window Size "<<width<<endl
+    <<"Fits OutFile "<<fitsout<<endl
     <<"  ...label_bolomuv "<<label_bolomuv<<endl;
+tg = tcoorin&TypCoordGal; te = tcoorin&TypCoordEq;
+hd = tcoorin&TypCoordHD;  dd = tcoorin&TypCoordDD;
+cout<<"Fits Infile Pointing "<<fitsin_point<<endl
+    <<"  ...label_coord1 "<<label_coord1<<endl
+    <<"  ...label_coord2 "<<label_coord2<<endl
+    <<"  ...... Gal="<<tg<<" Eq="<<te<<"   hour="<<hd<<" deg="<<dd<<endl;
+tg = tcoormap&TypCoordGal; te = tcoormap&TypCoordEq;
+hd = tcoormap&TypCoordHD;  dd = tcoormap&TypCoordDD; 
+cout<<"Fits Healpix Sphere "<<fitsphere<<endl
+    <<"  ...... Gal="<<tg<<" Eq="<<te<<"   hour="<<hd<<" deg="<<dd<<endl;
+}
 
 SophyaInit();
@@ -85,8 +131,8 @@
 
  // FITS reader et writer
- FITSTOIReader rfits(fitsin);
+ FITSTOIReader rfits(fitsin_point);
  int ncol = rfits.getNOut();
- cout<<"Number of columns in fits Infile : "<<ncol<<endl;
- if(ncol<2) exit(-3);
+ cout<<"Number of columns in fits Infile Pointing : "<<ncol<<endl;
+ if(ncol<2) exit(3);
 
  FITSTOIWriter wfits(fitsout);
@@ -104,26 +150,29 @@
  Map2TOI m2toi(sph);
  cout<<"Map2TOI created"<<endl;
+ m2toi.SetEquinox(2000.);
+ m2toi.SetCoorIn((TypAstroCoord) tcoorin);
+ m2toi.SetCoorMap((TypAstroCoord) tcoormap);
 
  // Definition des tuyaux
- TOISeqBuffered * toialphain = new TOISeqBuffered("toi_alpha_in",width);
- if(lp) toialphain->setDebugLevel(1);
- rfits.addOutput(label_alpha,toialphain);
- m2toi.addInput("AlphaIn",toialphain);
-
- TOISeqBuffered * toialphaout = new TOISeqBuffered("toi_alpha_out",width);
- m2toi.addOutput("AlphaOut",toialphaout);
- wfits.addInput(label_alpha,toialphaout);
-
- TOISeqBuffered * toideltain = new TOISeqBuffered("toi_delta_in",width);
- if(lp) toideltain->setDebugLevel(1);
- rfits.addOutput(label_delta,toideltain);
- m2toi.addInput("DeltaIn",toideltain);
-
- TOISeqBuffered * toideltaout = new TOISeqBuffered("toi_delta_out",width);
- m2toi.addOutput("DeltaOut",toideltaout);
- wfits.addInput(label_delta,toideltaout);
+ TOISeqBuffered * toicoord1in = new TOISeqBuffered("toi_coord1_in",width);
+ // toicoord1in->setDebugLevel(1);
+ rfits.addOutput(label_coord1,toicoord1in);
+ m2toi.addInput("Coord1In",toicoord1in);
+
+ TOISeqBuffered * toicoord1out = new TOISeqBuffered("toi_coord1_out",width);
+ m2toi.addOutput("Coord1Out",toicoord1out);
+ wfits.addInput(label_coord1,toicoord1out);
+
+ TOISeqBuffered * toicoord2in = new TOISeqBuffered("toi_coord2_in",width);
+ // toicoord2in->setDebugLevel(1);
+ rfits.addOutput(label_coord2,toicoord2in);
+ m2toi.addInput("Coord2In",toicoord2in);
+
+ TOISeqBuffered * toicoord2out = new TOISeqBuffered("toi_coord2_out",width);
+ m2toi.addOutput("Coord2Out",toicoord2out);
+ wfits.addInput(label_coord2,toicoord2out);
 
  TOISeqBuffered * toibolout = new TOISeqBuffered("toi_bolo_out",width);
- if(lp) toibolout->setDebugLevel(1);
+ // toibolout->setDebugLevel(1);
  m2toi.addOutput("BoloOut",toibolout);
  wfits.addInput(label_bolomuv,toibolout);
@@ -142,5 +191,5 @@
  if(lp>1)
    for(int jjjj=0;jjjj<5;jjjj++) {
-     cout<<*toialphain; 
+     cout<<*toicoord1in; 
      cout<<*toibolout; 
      sleep(2);
Index: /trunk/ArchTOIPipe/TestPipes/tsttoi2map.cc
===================================================================
--- /trunk/ArchTOIPipe/TestPipes/tsttoi2map.cc	(revision 1519)
+++ /trunk/ArchTOIPipe/TestPipes/tsttoi2map.cc	(revision 1520)
@@ -29,6 +29,6 @@
      <<" -b label_bolomuv : label fits for bolo value (def=boloMuV)"<<endl
      <<" -n nlat : nlat for Healpix sphere (def=128)"<<endl
-     <<" -i c,h : coord1 caracteristics (c=G/E h=H/D) (def=G,D)"<<endl
-     <<" -o c,h : idem -i for coord2"<<endl
+     <<" -i c,h : coordIn caracteristics (c=G/E h=H/D) (def=G,D)"<<endl
+     <<" -o c,h : idem -i for coordOut"<<endl
      <<" fitsin_point : fits file for pointing"<<endl
      <<" fitsin_bolo : fits file for bolo values"<<endl
@@ -124,5 +124,6 @@
 tg = tcoorin&TypCoordGal; te = tcoorin&TypCoordEq;
 hd = tcoorin&TypCoordHD;  dd = tcoorin&TypCoordDD;
-cout<<"  ...label_coord1 "<<label_coord1<<endl
+cout<<"Fits Infile Pointing "<<fitsin_point<<endl
+    <<"  ...label_coord1 "<<label_coord1<<endl
     <<"  ...label_coord2 "<<label_coord2<<endl
     <<"  ...... Gal="<<tg<<" Eq="<<te<<"   hour="<<hd<<" deg="<<dd<<endl;
