Index: trunk/ArchTOIPipe/Kernel/toisegment.cc
===================================================================
--- trunk/ArchTOIPipe/Kernel/toisegment.cc	(revision 1803)
+++ trunk/ArchTOIPipe/Kernel/toisegment.cc	(revision 1804)
@@ -3,5 +3,5 @@
 //                               Christophe Magneville
 //                               Reza Ansari
-// $Id: toisegment.cc,v 1.24 2001-11-16 14:23:54 aubourg Exp $
+// $Id: toisegment.cc,v 1.25 2001-11-30 21:07:16 aubourg Exp $
 
 #include "toisegment.h"
@@ -612,4 +612,8 @@
       cout << "waiting bufferview is waiting for " << (*i)->waitingFor 
 	   << " and still needs " << (*i)->firstNeeded << endl;
+      cout << "it has sn0= " << (*i)->sn0 << " nseg = " << (*i)->segments.size() 
+	   << " snlast = " << (*i)->sn0+(*i)->segments.size()*(*i)->segmentSize -1 
+	   << endl;
+	
       abort();
     }
Index: trunk/ArchTOIPipe/ProcWSophya/Makefile.in
===================================================================
--- trunk/ArchTOIPipe/ProcWSophya/Makefile.in	(revision 1803)
+++ trunk/ArchTOIPipe/ProcWSophya/Makefile.in	(revision 1804)
@@ -45,5 +45,5 @@
 
 
-SRCFILES=map2toi.cc toi2map.cc rztoi.cc simtoipr.cc ktoibad.cc smoothtoi.cc toi2gmap.cc
+SRCFILES=map2toi.cc toi2map.cc rztoi.cc simtoipr.cc ktoibad.cc smoothtoi.cc 
 
 FILES=$(patsubst %.c,%.o,$(SRCFILES:.cc=.o))
Index: trunk/ArchTOIPipe/ProcWSophya/toi2map.cc
===================================================================
--- trunk/ArchTOIPipe/ProcWSophya/toi2map.cc	(revision 1803)
+++ trunk/ArchTOIPipe/ProcWSophya/toi2map.cc	(revision 1804)
@@ -3,5 +3,5 @@
 //                               Christophe Magneville
 //                               Reza Ansari
-// $Id: toi2map.cc,v 1.19 2001-11-27 12:12:12 aubourg Exp $
+// $Id: toi2map.cc,v 1.20 2001-11-30 21:07:16 aubourg Exp $
 
 #include "machdefs.h"
@@ -9,9 +9,9 @@
 #include "pexceptions.h"
 #include "ctimer.h"
-#include "toi2map.h"
-
-////////////////////////////////////////////////////////////////////////
-TOI2Map::TOI2Map(SphereHEALPix<r_8>* sph,SphereHEALPix<r_8>* wsph)
-  : mSph(sph), mWSph(wsph), mWSphInternal(false)
+#include "toi2gmap.h"
+
+////////////////////////////////////////////////////////////////////////
+TOI2GMap::TOI2GMap(PixelMap<r_8>* map,PixelMap<r_8>* wmap)
+  : mMap(map), mWMap(map), mWMapInternal(false)
 {
  SetEquinox();
@@ -24,37 +24,49 @@
  mIsColat = false;
 
- 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;
+ if(mMap->NbPixels()<1) {
+  cout<<"TOI2GMap::TOI2GMap() Bad number of pixels in sphere mMap "
+      <<mMap->NbPixels()<<endl;
+  throw ParmError("TOI2GMap::TOI2GMap() - Bad number of pixels in sphere");
+ }
+ mMap->SetPixels(0.);
+ int nlat = mMap->SizeIndex();
+
+ if(mWMap==NULL) {
+   // We would need a cloning function in maps. $$TBD$$ $CHECK$
+   string typmap = mMap->TypeOfMap();
+   if (typmap == "LOCAL") {
+     mWMap = new LocalMap<r_8>(*(LocalMap<r_8>*)mMap);
+   } else if (typmap == "RING") {
+     mWMap = new SphereHEALPix<r_8>(nlat);
+   } else {
+     cout << "TOI2GMap::TOI2GMap() cannot handle map of type " << typmap << endl;
+     throw ParmError("TOI2GMap::TOI2GMap() - bad type of map");
+   }
+   mWMapInternal = 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::Print(::ostream & os)
-{
-  os<<"TOI2Map::Print -- Sphere NLat = "<<mSph->SizeIndex()<<endl
+   mWMapInternal = false;
+   if(nlat != mWMap->SizeIndex()) {
+     cout << "TOI2GMap::TOI2GMap() Bad size for sphere mWMap, does not "
+	  << "correspond to mMap : " << mMap->SizeIndex() << ", " << mWMap->SizeIndex() << endl;
+     throw ParmError("TOI2GMap::TOI2GMap() - Different sizes for map and wmap");
+   }
+ }
+ if(mWMap->NbPixels()<1) {
+   cout<<"TOI2GMap::TOI2GMap() Bad number of pixels in sphere mWMap "
+       <<mWMap->NbPixels()<<endl;
+   throw ParmError("TOI2GMap::TOI2GMap() - Bad number of pixels in sphere");
+ }
+ mWMap->SetPixels(0);
+}
+
+TOI2GMap::~TOI2GMap()
+{
+ if(mWMap && mWMapInternal) delete mWMap;
+}
+
+////////////////////////////////////////////////////////////////////////
+void TOI2GMap::Print(::ostream & os)
+{
+  os<<"TOI2GMap::Print -- Map type " << mMap->TypeOfMap() << " SizeIndex = "<<mMap->SizeIndex()<<endl
 
     <<"   - Equinoxe="<<mActualYear<<endl
@@ -78,6 +90,6 @@
 
 ////////////////////////////////////////////////////////////////////////
-void TOI2Map::init() {
-  cout << "TOI2Map::init" << endl;
+void TOI2GMap::init() {
+  cout << "TOI2GMap::init" << endl;
   declareInput("Coord1In");     // input index 0
   declareInput("Coord2In");     // input index 1
@@ -87,5 +99,5 @@
 ////////////////////////////////////////////////////////////////////////
 // define SANS_BUFFER
-void TOI2Map::run()
+void TOI2GMap::run()
 {
 long snb = getMinIn();
@@ -93,18 +105,18 @@
 
 if(snb>sne) {
-  cout<<"TOI2Map::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
-  throw ParmError("TOI2Map::run() - Bad sample interval");
+  cout<<"TOI2GMap::run() - Bad sample interval"<<snb<<" , "<<sne<<endl;
+  throw ParmError("TOI2GMap::run() - Bad sample interval");
 }
 if(!checkInputTOIIndex(0) || !checkInputTOIIndex(1) || !checkInputTOIIndex(2)) {
-  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!");
+  cout<<"TOI2GMap::run() - Input TOI (Coord1In or Coord2In or BoloIn) not connected! "<<endl;
+  throw ParmError("TOI2GMap::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!");
+  cout<<"TOI2GMap::run() - Input Coordinates not Eq or Gal! "<<endl;
+  throw ParmError("TOI2GMap::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!");
+  cout<<"TOI2GMap::run() - Output Coordinates not Eq or Gal! "<<endl;
+  throw ParmError("TOI2GMap::run() - Output Coordinates not Eq or Gal!");
 }
 
@@ -118,5 +130,5 @@
 double mjd = MJDfrYear(mActualYear);
 
-cout<<"TOI2Map::run() from "<<snb<<" to "<<sne;
+cout<<"TOI2GMap::run() from "<<snb<<" to "<<sne;
 #ifndef SANS_BUFFER
 int bufsz = 100;
@@ -189,18 +201,18 @@
   if(theta<0. || theta>=M_PI) continue;
 
-  int_4 ipix = mSph->PixIndexSph(theta,phi);
-  (*mSph)(ipix) += bolo;    
-  ((*mWSph)(ipix)) += 1;
+  int_4 ipix = mMap->PixIndexSph(theta,phi);
+  (*mMap)(ipix) += bolo;    
+  ((*mWMap)(ipix)) += 1;
   mNSnFill++;
 }
 
- cout<<"TOI2Map::run(): Fin de boucle sur les sampleNum"<<endl;
+ cout<<"TOI2GMap::run(): Fin de boucle sur les sampleNum"<<endl;
 
 // Remplissage des spheres
- for(int_4 i=0;i<mSph->NbPixels();i++) {
-   r_8 wf = (*mWSph)(i);
+ for(int_4 i=0;i<mMap->NbPixels();i++) {
+   r_8 wf = (*mWMap)(i);
    if( wf > 0. ) {
      mNpixFill++;
-     (*mSph)(i) /= wf;
+     (*mMap)(i) /= wf;
    }
    int_4 nf = int_4(wf);
@@ -208,8 +220,8 @@
  }
 
- cout<<"TOI2Map::run(): mNpixTot="<<mSph->NbPixels()
+ cout<<"TOI2GMap::run(): mNpixTot="<<mMap->NbPixels()
      <<"  mNpixFill="<<mNpixFill
      <<"  mNSnFill="<<mNSnFill<<endl
-     <<"  --> FracSky="<<mNpixFill*100./(double)mSph->NbPixels()<<"%"
+     <<"  --> FracSky="<<mNpixFill*100./(double)mMap->NbPixels()<<"%"
      <<"  NFill["<<NFILL<<"] ="<<endl;
  for(ii=0;ii<NFILL;ii++) {cout<<NFill[ii]<<" "; if(ii%10==9) cout<<endl;}
@@ -223,5 +235,5 @@
 //---------------------------------------------------------
 } catch (PException & exc) {
-  cout<<"TOI2Map: Catched Exception "<<(string)typeid(exc).name()
+  cout<<"TOI2GMap: Catched Exception "<<(string)typeid(exc).name()
       <<"\n .... Msg= "<<exc.Msg()<<endl;
 }
