Index: trunk/ArchTOIPipe/ProcWSophya/toi2map.cc
===================================================================
--- trunk/ArchTOIPipe/ProcWSophya/toi2map.cc	(revision 1514)
+++ trunk/ArchTOIPipe/ProcWSophya/toi2map.cc	(revision 1516)
@@ -4,10 +4,13 @@
 #include "ctimer.h"
 #include "toi2map.h"
-#include "xastropack.h"
 
 ////////////////////////////////////////////////////////////////////////
 TOI2Map::TOI2Map(SphereHEALPix<r_8>* sph,SphereHEALPix<r_8>* wsph)
-  : mSph(sph), mWSph(wsph), mWSphInternal(false), mTypCoor(false), fTypCoor(false), mActualYear(2001.)
+  : mSph(sph), mWSph(wsph), mWSphInternal(false)
 {
+ SetEquinox();
+ SetCoorIn();
+ SetCoorOut();
+
  if(mSph->NbPixels()<1) {
   cout<<"TOI2Map::TOI2Map() Bad number of pixels in sphere mSph "
@@ -44,5 +47,5 @@
   declareInput("Coord1In");     // input index 0
   declareInput("Coord2In");     // input index 1
-  declareInput("BoloIn");      // input index 2
+  declareInput("BoloIn");       // input index 2
 }
 
@@ -61,4 +64,12 @@
   throw ParmError("TOI2Map::run() Output TOI (Coord1In or Coord2In or BoloIn) not connected!");
 }
+if( !(mTypCoorIn&TypCoordEq || mTypCoorIn&TypCoordGal) ) {
+  cout<<"TOI2Map::run() - Input Coordinates not Eq or Gal! "<<endl;
+  throw ParmError("TOI2Map::run() - Input Coordinates not Eq or Gal!");
+}
+if( !(mTypCoorOut&TypCoordEq || mTypCoorOut&TypCoordGal) ) {
+  cout<<"TOI2Map::run() - Output Coordinates not Eq or Gal! "<<endl;
+  throw ParmError("TOI2Map::run() - Output Coordinates not Eq or Gal!");
+}
 
 //---------------------------------------------------------
@@ -69,48 +80,41 @@
 uint_4 mNSnFill=0, mNpixFill=0, NFill[NFILL];
 for(ii=0;ii<NFILL;ii++) NFill[ii]=0;
+double mjd = MJDfrYear(mActualYear);
 
 // Remplissage des spheres
 for(int s=snb;s<=sne;s++) {
-  int_8 fgbolo = 0; 
+  int_8 fgbolo = 0;
   double bolo;
+  //              Equatoriales   /   Galactiques
+  // coord1,2 =   alpha,delta    /   gLon,gLat
+  double coord1 = getData(0,s);
+  double coord2 = getData(1,s);
 
-  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(bolo<-32767.) continue; // Bidouille (A CORRIGER QUAND FGBOLO DISPO)
 
-  if(coord2<-90. || coord2>90.) fgbolo=1; 
-  if((coord1<0.) || (!mTypCoor && coord1>=24.) || (mTypCoor && coord1>=360.) ) {fgbolo=1; 
-  cout << "!!!!!!!!" <<coord1 << endl;
+  // sphere phi   entre [0,2*Pi] en radians
+  // sphere theta entre [0,Pi]   en radians
+  double phi,theta;
+  CoordConvertToStd(mTypCoorIn,coord1,coord2);
+  if(mTypCoorIn&TypCoordEq && mTypCoorOut&TypCoordGal) { // Eq -> Gal
+    EqtoGal(mjd,coord1,coord2,&coord1,&coord2);
+    phi   = coord1 * M_PI/180.;
+  } else if(mTypCoorIn&TypCoordGal && mTypCoorOut&TypCoordEq) { // Gal -> Eq
+    GaltoEq(mjd,coord1,coord2,&coord1,&coord2);
+    phi   = coord1 * M_PI/12.;
+  } else if(mTypCoorOut&TypCoordGal) { // Gal -> Gal
+    phi   = coord1 * M_PI/180.;
+  } else if(mTypCoorOut&TypCoordEq) { // Eq -> Eq
+    phi   = coord1 * M_PI/12.;
   }
-  
-  
-  
-  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(fTypCoor && !mTypCoor) { //on a alpha,delta et on veut l,b
-      double mjd = MJDfrYear(mActualYear);
-      EqtoGal(mjd,coord1,coord2,&coord1,&coord2);
-    } 
+  theta = (90.-coord2) * M_PI/180.;
+  if(phi<0.   || phi>=2*M_PI) continue;
+  if(theta<0. || theta>=M_PI) continue;
 
-    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;    
-    ((*mWSph)(ipix))++;
-    mNSnFill++;
-  }
+  int_4 ipix = mSph->PixIndexSph(theta,phi);
+  (*mSph)(ipix) += bolo;    
+  ((*mWSph)(ipix))++;
+  mNSnFill++;
 }
 
@@ -129,7 +133,7 @@
      <<"  mNpixFill="<<mNpixFill
      <<"  mNSnFill="<<mNSnFill<<endl
-     <<" --> FracSky="<<mNpixFill*100./(double)mSph->NbPixels()<<"%"<<endl
-     <<"NFill["<<NFILL<<"] = "<<endl;
- for(ii=0;ii<NFILL;ii++) cout<<NFill[ii]<<" ";
+     <<"  --> FracSky="<<mNpixFill*100./(double)mSph->NbPixels()<<"%"
+     <<"  NFill["<<NFILL<<"] ="<<endl;
+ for(ii=0;ii<NFILL;ii++) {cout<<NFill[ii]<<" "; if(ii%10==9) cout<<endl;}
  cout<<endl;
 
Index: trunk/ArchTOIPipe/ProcWSophya/toi2map.h
===================================================================
--- trunk/ArchTOIPipe/ProcWSophya/toi2map.h	(revision 1514)
+++ trunk/ArchTOIPipe/ProcWSophya/toi2map.h	(revision 1516)
@@ -5,18 +5,23 @@
 #include "toiprocessor.h"
 #include "spherehealpix.h"
+#include "flagtoidef.h"
+#include "xastropack.h"
 
 //-- Un projecteur de TOI sur une sphere Healpix
-// Lecture de 3 TOI alpha,delta,boloMuV
-// Sortie rien
+// Lecture de 3 TOI coord1,coord2,boloMuV
+// Sortie pas de TOI, une (2) sphere(s) Healpix
 //
 // Structure generale :
-// (les alpha[0,360[,delta[-90,90] sont en degres decimaux)
-//                         |---->Sphere
-//                         |
-//                    -----------
+//                          |---->Sphere
+//                          |
+//                     -----------
 //   toi Coord1In ---> |         |
 //   toi Coord2In ---> | TOI2Map |
-//   toi BoloIn  ---> |         |
-//                    -----------
+//   toi BoloIn   ---> |         |
+//                     -----------
+// Gestion du type de coordonnees :
+// Coord1In,Coord2In : soit Equatoriales (Alpha,Delta)
+//                     soit Galactiques  (GLong,GLat)
+// Sortie sur une sphere en coordonnees Equatoriales ou Galactiques
 
 class TOI2Map : public TOIProcessor {
@@ -25,15 +30,20 @@
   virtual	~TOI2Map();
 
-  virtual void	init(void);  
+  virtual void	init(void);
   virtual void	run(void);
-  inline  void  SetCoorGal(bool mfg=false,bool ffg=false,double actualyear=2000.)
-                          {mTypCoor = mfg; fTypCoor = ffg; mActualYear = actualyear;}
-  
+
+  // Coordonnees donnees en entree et en sortie
+  inline void SetEquinox(double actualyear=2000.)
+              {mActualYear = actualyear;}
+  inline void SetCoorIn(TypAstroCoord mfg=TypCoordGalStd)
+              {mTypCoorIn = mfg;}
+  inline void SetCoorOut(TypAstroCoord mfg=TypCoordGalStd)
+              {mTypCoorOut = mfg;}
+
 protected:
   SphereHEALPix<r_8>* mSph;
   SphereHEALPix<r_8>* mWSph;
   bool mWSphInternal;
-  bool mTypCoor;
-  bool fTypCoor;
+  TypAstroCoord mTypCoorIn, mTypCoorOut;
   double mActualYear;
 };
