Index: trunk/ArchTOIPipe/ProcWSophya/map2toi.cc
===================================================================
--- trunk/ArchTOIPipe/ProcWSophya/map2toi.cc	(revision 1463)
+++ trunk/ArchTOIPipe/ProcWSophya/map2toi.cc	(revision 1463)
@@ -0,0 +1,78 @@
+#include "toimanager.h"
+#include "pexceptions.h"
+#include "ctimer.h"
+#include "map2toi.h"
+
+////////////////////////////////////////////////////////////////////////
+Map2TOI::Map2TOI(SphereHEALPix<r_8>& sph)
+: mSph(sph)
+{
+}
+
+Map2TOI::~Map2TOI()
+{
+}
+
+////////////////////////////////////////////////////////////////////////
+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
+}
+
+////////////////////////////////////////////////////////////////////////
+void Map2TOI::run() {
+
+if(mSph.NbPixels()<1) {
+  cout<<"Map2TOI::Map2TOI() Bad number of pixels in sphere "<<mSph.NbPixels()<<endl;
+  throw ParmError("Map2TOI::Map2TOI() - Bad number of pixels in sphere");
+}
+
+long snb = getMinIn();
+long sne = getMaxIn();
+if(snb>sne) {
+  cout<<"Map2TOI::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
+  throw ParmError("Map2TOI::run() - Bad sample interval");
+}
+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!");
+}
+bool connected_AlphaOut = checkOutputTOIIndex(0);
+bool connected_DeltaOut = checkOutputTOIIndex(1);
+if(!checkOutputTOIIndex(2)) {
+  cout<<"Map2TOI::run() - Output TOI (BoloOut) not connected! "<<endl;
+  throw ParmError("Map2TOI::run() Output TOI (BoloOut) not connected!");
+}
+
+//---------------------------------------------------------
+try {
+
+for(int k=snb;k<=sne;k++) {
+
+  double alpha = getData(0,k); // alpha entre [0,24[ en heures
+  if(alpha<0. || alpha>=24.) continue;
+  double delta = getData(1,k); // delta entre [-90,90] en degres
+  if(delta<-90. || delta>90.) continue;
+
+  double phi   = alpha *M_PI/12.; // sphere phi entre [0,2*Pi] en radian
+  double teta  = (90.-delta) *M_PI/180.; // sphere teta entre [0,Pi] en radian
+
+  double bolo  = mSph(teta,phi);
+
+  if(connected_AlphaOut) putData(0,k,alpha,0);
+  if(connected_DeltaOut) putData(1,k,delta,0);
+  putData(2,k,bolo,0);
+}
+
+//---------------------------------------------------------
+} catch (PException & exc) {
+  cout<<"Map2TOI: Catched Exception "<<(string)typeid(exc).name()
+      <<"\n .... Msg= "<<exc.Msg()<<endl;
+}
+
+return;                                                                            
+}
Index: trunk/ArchTOIPipe/ProcWSophya/map2toi.h
===================================================================
--- trunk/ArchTOIPipe/ProcWSophya/map2toi.h	(revision 1463)
+++ trunk/ArchTOIPipe/ProcWSophya/map2toi.h	(revision 1463)
@@ -0,0 +1,34 @@
+// This may look like C code, but it is really -*- C++ -*-
+#ifndef MAP2TOI_H
+#define MAP2TOI_H
+
+#include "toiprocessor.h"
+#include "spherehealpix.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
+//
+// 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
+//                    -----------
+
+class Map2TOI : public TOIProcessor {
+public:
+                 Map2TOI(SphereHEALPix<r_8>& sph);
+  virtual	~Map2TOI();
+
+  virtual void	init(void);  
+  virtual void	run(void);
+  
+protected:
+  SphereHEALPix<r_8>& mSph;
+};
+
+#endif
Index: trunk/ArchTOIPipe/ProcWSophya/toi2map.cc
===================================================================
--- trunk/ArchTOIPipe/ProcWSophya/toi2map.cc	(revision 1463)
+++ trunk/ArchTOIPipe/ProcWSophya/toi2map.cc	(revision 1463)
@@ -0,0 +1,129 @@
+#include "machdefs.h"
+#include "toimanager.h"
+#include "pexceptions.h"
+#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), mActualYear(2001.)
+{
+ if(mSph->NbPixels()<1) {
+  cout<<"TOI2Map::TOI2Map() Bad number of pixels in sphere mSph "
+      <<mSph->NbPixels()<<endl;
+  throw ParmError("TOI2Map::TOI2Map() - Bad number of pixels in sphere");
+ }
+ mSph->SetPixels(0.);
+ int nlat = mSph->SizeIndex();
+
+ if(mWSph==NULL) {
+   mWSph = new SphereHEALPix<r_8>(nlat);
+   mWSphInternal = true;
+ } else {
+   mWSphInternal = false;
+   if(nlat != mWSph->SizeIndex()) mWSph->Resize(nlat);
+ }
+ if(mWSph->NbPixels()<1) {
+   cout<<"TOI2Map::TOI2Map() Bad number of pixels in sphere mWSph "
+       <<mWSph->NbPixels()<<endl;
+   throw ParmError("TOI2Map::TOI2Map() - Bad number of pixels in sphere");
+ }
+ mWSph->SetPixels(0);
+
+}
+
+TOI2Map::~TOI2Map()
+{
+ if(mWSph && !mWSphInternal) delete mWSph;
+}
+
+////////////////////////////////////////////////////////////////////////
+void TOI2Map::init() {
+  cout << "TOI2Map::init" << endl;
+  declareInput("AlphaIn");     // input index 0
+  declareInput("DeltaIn");     // input index 1
+  declareInput("BoloIn");      // input index 2
+}
+
+////////////////////////////////////////////////////////////////////////
+void TOI2Map::run()
+{
+long snb = getMinIn();
+long sne = getMaxIn();
+
+if(snb>sne) {
+  cout<<"TOI2Map::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
+  throw ParmError("TOI2Map::run() - Bad sample interval");
+}
+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!");
+}
+
+//---------------------------------------------------------
+#define NFILL 25
+try {
+
+int ii;
+uint_4 mNSnFill=0, mNpixFill=0, NFill[NFILL];
+for(ii=0;ii<NFILL;ii++) NFill[ii]=0;
+
+// Remplissage des spheres
+for(int s=snb;s<=sne;s++) {
+  int_4 fgbolo = 0; 
+
+  double alpha = getData(0,s); // alpha entre [0,24[ en heures
+  double delta = getData(1,s); // delta entre [-90,90] en degres
+  double bolo  = getData(2,s);
+  //fgbolo = getFlag(2,s);
+
+  if(delta<-90. || delta>90.)  fgbolo=1;
+  if(alpha<0.   || alpha>=24.) fgbolo=1;
+  if(bolo<-32767.) fgbolo=1;   // Bidouille Archeops
+
+  if(!fgbolo) {
+    // sphere phi entre [0,2*Pi] en radians
+    // sphere theta entre [0,Pi] en radians
+    double phi,theta;
+    if(mTypCoor) {
+      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.;
+    int_4 ipix = mSph->PixIndexSph(theta,phi);
+    (*mSph)(ipix) += bolo;
+    ((*mWSph)(ipix))++;
+    mNSnFill++;
+  }
+
+}
+
+// Remplissage des spheres
+ for(int_4 i=0;i<mSph->NbPixels();i++) {
+   r_8 wf = (*mWSph)(i);
+   if( wf > 0. ) {
+     mNpixFill++;
+     (*mSph)(i) /= wf;
+   }
+   int_4 nf = int_4(wf);
+   if(nf>=NFILL) nf=NFILL-1; NFill[nf]++;
+ }
+
+ cout<<"TOI2Map::run(): mNpixTot="<<mSph->NbPixels()
+     <<"  mNpixFill="<<mNpixFill
+     <<"  mNSnFill="<<mNSnFill<<endl
+     <<" --> FracSky="<<mNpixFill*100./(double)mSph->NbPixels()<<"%"<<endl
+     <<"NFill["<<NFILL<<"] = "<<endl;
+ for(ii=0;ii<NFILL;ii++) cout<<NFill[ii]<<" ";
+ cout<<endl;
+
+//---------------------------------------------------------
+} catch (PException & exc) {
+  cout<<"TOI2Map: Catched Exception "<<(string)typeid(exc).name()
+      <<"\n .... Msg= "<<exc.Msg()<<endl;
+}
+
+return;                                                                            
+}
Index: trunk/ArchTOIPipe/ProcWSophya/toi2map.h
===================================================================
--- trunk/ArchTOIPipe/ProcWSophya/toi2map.h	(revision 1463)
+++ trunk/ArchTOIPipe/ProcWSophya/toi2map.h	(revision 1463)
@@ -0,0 +1,40 @@
+// This may look like C code, but it is really -*- C++ -*-
+#ifndef TOI2MAP_H
+#define TOI2MAP_H
+
+#include "toiprocessor.h"
+#include "spherehealpix.h"
+
+//-- Un projecteur de TOI sur une sphere Healpix
+// Lecture de 3 TOI alpha,delta,boloMuV
+// Sortie rien
+//
+// Structure generale :
+// (les alpha[0,360[,delta[-90,90] sont en degres decimaux)
+//                         |---->Sphere
+//                         |
+//                    -----------
+//   toi AlphaIn ---> |         |
+//   toi DeltaIn ---> | TOI2Map |
+//   toi BoloIn  ---> |         |
+//                    -----------
+
+class TOI2Map : public TOIProcessor {
+public:
+                 TOI2Map(SphereHEALPix<r_8>* sph,SphereHEALPix<r_8>* wsph=NULL);
+  virtual	~TOI2Map();
+
+  virtual void	init(void);  
+  virtual void	run(void);
+  inline  void  SetCoorGal(bool fg=false,double actualyear=2000.)
+                          {mTypCoor = fg; mActualYear = actualyear;}
+  
+protected:
+  SphereHEALPix<r_8>* mSph;
+  SphereHEALPix<r_8>* mWSph;
+  bool mWSphInternal;
+  bool mTypCoor;
+  double mActualYear;
+};
+
+#endif
