Index: /trunk/SophyaLib/Samba/spheregorski.cc
===================================================================
--- /trunk/SophyaLib/Samba/spheregorski.cc	(revision 723)
+++ /trunk/SophyaLib/Samba/spheregorski.cc	(revision 724)
@@ -211,4 +211,5 @@
   InitNul();
   Pixelize(m);
+  SetThetaSlices();
 }
 //++
@@ -268,4 +269,5 @@
   InitNul();
   Pixelize(m);
+  SetThetaSlices();
 }
 
@@ -322,10 +324,16 @@
 //++
 template<class T>
-int_4 SphereGorski<T>::NbThetaSlices() const 
+uint_4 SphereGorski<T>::NbThetaSlices() const 
 
 //    Return number of slices in theta direction on the  sphere
 //--
 {
-  return int(4*nSide_-1);
+  uint_4 nbslices = uint_4(4*nSide_-1);
+  if (nSide_<=0) 
+    {
+      nbslices = 0;
+      throw PException(" sphere not pixelized, NbSlice=0 ");
+    }
+  return nbslices;
 }
 
@@ -352,22 +360,8 @@
     }
 
-  int_4 iring= 0;
-  int_4 lring  = 0;
-  if(index < nSide_-1) 
-    {
-      iring= 2*index*(index+1);
-      lring= 4*(index+1);
-    }
-  else if(index < 3*nSide_) 
-    {
-      iring= 2*nSide_*(2*index-nSide_+1);
-      lring= 4*nSide_;
-    }
-  else
-    {
-      int_4 nc= 4*nSide_-1-index;
-      iring = nPix_-2*nc*(nc+1);
-      lring = 4*nc;
-    }
+
+  int_4 iring= sliceBeginIndex_(index);
+  int_4 lring  =  sliceLenght_(index);
+
 
   phi.ReSize(lring);
@@ -382,4 +376,66 @@
     }
   theta= TH;
+}
+//++
+//++
+
+template<class T>
+void SphereGorski<T>::GetThetaSlice(int_4 sliceIndex,double& theta, double& phi0, TVector<int>& pixelIndices,TVector<T>& value) const 
+
+//    For a theta-slice with index 'sliceIndex', return : 
+//
+//    the corresponding "theta" 
+//    the corresponding "phi" for first pixel of the slice 
+//
+//    a vector containing the indices of the pixels of the slice
+//    (equally distributed in phi)
+//
+//    a vector containing the corresponding values of pixels 
+//
+//--
+{
+
+  if (sliceIndex<0 || sliceIndex >= NbThetaSlices()) 
+    {
+      // THROW(out_of_range("SphereGorski::PIxVal Pixel index out of range")); 
+      cout << " SphereGorski::GetThetaSlice : Pixel index out of range" <<endl;
+      THROW(rangeCheckErr);
+    }
+
+  int_4 iring= sliceBeginIndex_(sliceIndex);
+  int_4 lring  =  sliceLenght_(sliceIndex);
+  pixelIndices.ReSize(lring);
+  value.ReSize(lring);
+  for(int_4 kk = 0; kk < lring;kk++) 
+    {
+      pixelIndices(kk)= kk+iring;
+      value(kk)= PixVal(kk+iring);
+    }
+  PixThetaPhi(iring, theta, phi0);
+}
+//++
+template<class T>
+void SphereGorski<T>::SetThetaSlices()  
+
+//--
+{
+  sliceBeginIndex_.ReSize(4*nSide_-1);
+  sliceLenght_.ReSize(4*nSide_-1);
+  for (int sliceIndex=0; sliceIndex<  nSide_-1; sliceIndex++)
+    {
+      sliceBeginIndex_(sliceIndex)  = 2*sliceIndex*(sliceIndex+1);
+      sliceLenght_(sliceIndex) = 4*(sliceIndex+1);
+    }
+  for (int sliceIndex= nSide_-1; sliceIndex<  3*nSide_; sliceIndex++)
+    {
+      sliceBeginIndex_(sliceIndex)  = 2*nSide_*(2*sliceIndex-nSide_+1);
+      sliceLenght_(sliceIndex) = 4*nSide_;
+    }
+  for (int sliceIndex= 3*nSide_; sliceIndex< 4*nSide_-1; sliceIndex++)
+    {
+      int_4 nc= 4*nSide_-1-sliceIndex;
+      sliceBeginIndex_(sliceIndex)  = nPix_-2*nc*(nc+1); 
+      sliceLenght_(sliceIndex) = 4*nc;
+    }
 }
 
@@ -1179,7 +1235,11 @@
   dobj->setParameters(nSide,nPix, Omega);
 
-// On lit le DataBlock;
+// On lit les DataBlocks;
   FIO_NDataBlock<T> fio_nd(&dobj->pixels_);
   fio_nd.Read(is);
+  FIO_NDataBlock<int> fio_ndi1(&dobj->sliceBeginIndex_);
+  fio_ndi1.Read(is);
+  FIO_NDataBlock<int> fio_ndi2(&dobj->sliceLenght_);
+  fio_ndi2.Read(is);
 }
 
@@ -1216,7 +1276,11 @@
   os.PutI4(nPix);
   os.PutR8(dobj->PixSolAngle());
-// On ecrit le dataBlock 
+// On ecrit les dataBlocks 
   FIO_NDataBlock<T> fio_nd(&dobj->pixels_);
   fio_nd.Write(os);
+  FIO_NDataBlock<int> fio_ndi1(&dobj->sliceBeginIndex_);
+  fio_ndi1.Write(os);
+  FIO_NDataBlock<int> fio_ndi2(&dobj->sliceLenght_);
+  fio_ndi2.Write(os);
 }
 
Index: /trunk/SophyaLib/Samba/spheregorski.h
===================================================================
--- /trunk/SophyaLib/Samba/spheregorski.h	(revision 723)
+++ /trunk/SophyaLib/Samba/spheregorski.h	(revision 724)
@@ -74,4 +74,6 @@
 virtual ~SphereGorski();
 
+/*! Setting blockdata to temporary (see ndatablock documentation) */
+inline virtual void SetTemp(bool temp=false) const {pixels_.SetTemp(temp);};
 // ------------------ Definition of PixelMap abstract methods
 
@@ -87,5 +89,5 @@
 /* Nombre de tranches en theta */ 
 /*!    Return number of slices in theta direction on the  sphere */
-int_4 NbThetaSlices() const;
+uint_4 NbThetaSlices() const;
 /*!   For a theta-slice with index 'index', return : 
 
@@ -97,4 +99,17 @@
 */
 void GetThetaSlice(int_4 index,double& theta,TVector<double>& phi,TVector<T>& value) const;
+/*!   For a theta-slice with index 'index', return : 
+
+   the corresponding "theta" 
+
+   the corresponding "phi" for first pixel of the slice 
+
+    a vector containing indices of the pixels of the slice
+
+   (equally distributed in phi)
+
+    a vector containing the corresponding values of pixels 
+*/
+ void GetThetaSlice(int_4 sliceIndex,double& theta, double& phi0, TVector<int>& pixelIndices,TVector<T>& value) const ;
 
 /* Return true if teta,phi in map  */
@@ -184,4 +199,5 @@
 // ------------- méthodes internes ----------------------
 void InitNul();
+ void SetThetaSlices(); 
 
 int_4  nest2ring(int_4 nside,int_4 ipnest) const;
@@ -200,4 +216,5 @@
 
 // ------------- variables internes -----------------------
+
 int_4 nSide_;
 int_4 nPix_;
@@ -205,4 +222,6 @@
 
 NDataBlock<T> pixels_;
+NDataBlock<int> sliceBeginIndex_;
+ NDataBlock<int> sliceLenght_;
 
 };
