Index: /trunk/SophyaExt/FitsIOServer/fitshistos.cc
===================================================================
--- /trunk/SophyaExt/FitsIOServer/fitshistos.cc	(revision 3058)
+++ /trunk/SophyaExt/FitsIOServer/fitshistos.cc	(revision 3059)
@@ -147,4 +147,5 @@
   }
 
+  return;
 }
 
@@ -232,4 +233,5 @@
   if(he) FitsBlockRW<r_8>::ReadColumnData(is,3,1,1,he->mNData,nbin);
 
+  return;
 }
 
@@ -265,5 +267,5 @@
 
   //--- Le type d'objet et son pointeur
-  Histo2D* h = dynamic_cast< Histo2D *> (dobj);
+  Histo2D* h2 = dynamic_cast< Histo2D *> (dobj);
 
   //--- Les noms de colonnes
@@ -275,5 +277,5 @@
   tunit.push_back("");
   // Les erreurs
-  if(h->mErr2) {
+  if(h2->mErr2) {
     if(tbltyp==ASCII_TBL) tform.push_back("D15.8"); else tform.push_back("D");
     colnames.push_back("e2");
@@ -286,8 +288,8 @@
 
   // Ecriture des donnees des colonnes
-  long n = h->mNxy;
+  long n = h2->mNxy;
   if(n>0) {
-    FitsBlockRW<r_8>::WriteColumnData(os,1,1,1,h->mData,n);
-    if(h->mErr2) FitsBlockRW<r_8>::WriteColumnData(os,2,1,1,h->mErr2,n);
+    FitsBlockRW<r_8>::WriteColumnData(os,1,1,1,h2->mData,n);
+    if(h2->mErr2) FitsBlockRW<r_8>::WriteColumnData(os,2,1,1,h2->mErr2,n);
   }
 
@@ -301,41 +303,104 @@
   os.WriteKey("CONTENT",mtv," name of SOPHYA object");
 
-  mtv = h->mNx;
+  mtv = h2->mNx;
   os.WriteKey("NBINX",mtv," number of bins in X");
-  mtv = h->mNy;
+  mtv = h2->mNy;
   os.WriteKey("NBINY",mtv," number of bins in Y");
-  mtv = h->mNxy;
+  mtv = h2->mNxy;
   os.WriteKey("NBINXY",mtv," number of elements");
 
-  mtv = h->mXmin;
+  mtv = h2->mXmin;
   os.WriteKey("XMIN",mtv," absc of beginning of 1srt bin in X");
-  mtv = h->mXmax;
+  mtv = h2->mXmax;
   os.WriteKey("XMAX",mtv," absc of end of last bin in X");
-  mtv = h->mYmin;
+  mtv = h2->mYmin;
   os.WriteKey("YMIN",mtv," absc of beginning of 1srt bin in Y");
-  mtv = h->mYmax;
+  mtv = h2->mYmax;
   os.WriteKey("YMAX",mtv," absc of end of last bin in Y");
 
-  mtv = h->mWBinx;
+  mtv = h2->mWBinx;
   os.WriteKey("WBINX",mtv," bin width in X");
-  mtv = h->mWBiny;
+  mtv = h2->mWBiny;
   os.WriteKey("WBINY",mtv," bin width in Y");
 
   for(int i=0;i<3;i++) for(int j=0;j<3;j++) {
     char str[16]; sprintf(str,"OUT%1d%1d",i,j);
-    mtv = h->mOver[i][j];
+    mtv = h2->mOver[i][j];
     os.WriteKey(str,mtv," under/over X/Y");
   }
 
-  mtv = h->nHist;
+  mtv = h2->nHist;
   os.WriteKey("NHIST",mtv," entries weighted somme");
 
-  mtv = h->nEntries;
+  mtv = h2->nEntries;
   os.WriteKey("NENTRIES",mtv," number of entries");
 
-  int_4 haserr =(h->mErr2) ? 1: 0;
+  int_4 haserr =(h2->mErr2) ? 1: 0;
   mtv = haserr;
   os.WriteKey("HASERR2",mtv," square errors associated");
 
+
+
+  //-------------------------------------------------------------
+  //------ Gestion des Histo1D de projx/y bandx/t slicex/y ------
+  //-------------------------------------------------------------
+
+  int_4 nrel = 0;
+  if(h2->HProjX()) {nrel++; mtv=nrel; os.WriteKey("PROJX",mtv," relative HDU with HProjX");}
+  if(h2->HProjY()) {nrel++; mtv=nrel; os.WriteKey("PROJY",mtv," relative HDU with HProjY");}
+  if(h2->NSliX()>0) {
+    mtv=h2->NSliX(); os.WriteKey("NSLICEX",mtv," number of SliX");
+    nrel++;
+    mtv=nrel; os.WriteKey("SLICEX",mtv," relative HDU with first SliX");
+    nrel += h2->NSliX()-1;
+  }
+  if(h2->NSliY()>0) {
+    mtv=h2->NSliY(); os.WriteKey("NSLICEY",mtv," number of SliY");
+    nrel++;
+    mtv=nrel; os.WriteKey("SLICEY",mtv," relative HDU with first SliY");
+    nrel += h2->NSliY()-1;
+  }
+  if(h2->NBandX()>0) {
+    mtv=h2->NBandX(); os.WriteKey("NBANDEX",mtv," number of BandX");
+    nrel++;
+    mtv=nrel; os.WriteKey("BANDEX",mtv," relative HDU with first BandX");
+    nrel += h2->NBandX()-1;
+    for(int i=0;i<h2->NBandX();i++) {
+      char str[32]; r_8 vmin,vmax;
+      h2->GetBandX(i,vmin,vmax);
+      sprintf(str,"BXL%d",i);
+      mtv = vmin; os.WriteKey(str,mtv," low Y limit for BandX");
+      sprintf(str,"BXH%d",i);
+      mtv = vmax; os.WriteKey(str,mtv," high Y limit for BandX");
+    }
+  }
+  if(h2->NBandY()>0) {
+    mtv=h2->NBandY(); os.WriteKey("NBANDEY",mtv," number of BandY");
+    nrel++;
+    mtv=nrel; os.WriteKey("BANDEY",mtv," relative HDU with first BandY");
+    nrel += h2->NBandY()-1;
+    for(int i=0;i<h2->NBandY();i++) {
+      char str[32]; r_8 vmin,vmax;
+      h2->GetBandY(i,vmin,vmax);
+      sprintf(str,"BYL%d",i);
+      mtv = vmin; os.WriteKey(str,mtv," low X limit for BandY");
+      sprintf(str,"BYH%d",i);
+      mtv = vmax; os.WriteKey(str,mtv," high X limit for BandY");
+    }
+  }
+  mtv=nrel; os.WriteKey("NH1ASS",mtv," number of associated Histo1D");
+
+  if(h2->HProjX()) {FitsHandler<Histo> fio(const_cast<Histo &>(*(h2->HProjX()))); fio.Write(os);}
+  if(h2->HProjY()) {FitsHandler<Histo> fio(const_cast<Histo &>(*(h2->HProjY()))); fio.Write(os);}
+  if(h2->NSliX()>0) for(int i=0;i<h2->NSliX();i++)
+    {FitsHandler<Histo> fio(const_cast<Histo &>(*(h2->HSliX(i)))); fio.Write(os);}
+  if(h2->NSliY()>0) for(int i=0;i<h2->NSliY();i++)
+    {FitsHandler<Histo> fio(const_cast<Histo &>(*(h2->HSliY(i)))); fio.Write(os);}
+  if(h2->NBandX()>0) for(int i=0;i<h2->NBandX();i++)
+    {FitsHandler<Histo> fio(const_cast<Histo &>(*(h2->HBandX(i)))); fio.Write(os);}
+  if(h2->NBandY()>0) for(int i=0;i<h2->NBandY();i++)
+    {FitsHandler<Histo> fio(const_cast<Histo &>(*(h2->HBandY(i)))); fio.Write(os);}
+
+  return;
 }
 
@@ -390,3 +455,110 @@
   if(dobj->mErr2) FitsBlockRW<r_8>::ReadColumnData(is,2,1,1,dobj->mErr2,nbinxy);
 
-}
+
+
+  //-------------------------------------------------------------
+  //------ Gestion des Histo1D de projx/y bandx/t slicex/y ------
+  //-------------------------------------------------------------
+
+  int_4 nh1ass = dvl.GetI("NH1ASS",-1);
+  if(nh1ass<=0) return;
+  int hducur = is.CurrentHDU();
+
+  try {  // ProjX
+    int_4 ipr = dvl.GetI("PROJX",-1);
+    is.MoveAbsToHDU(hducur+ipr);
+    dobj->SetProjX();
+    Histo *h = dobj->HProjX();
+    FitsHandler<Histo> fio(*h); fio.Read(is);
+    if(h->NBins()!=dobj->NBinX())
+      throw FitsIOException("unmatched bin number");
+  } catch (...) {
+    dobj->DelProjX();
+    cout<<"FitsHandler<Histo2D>::Read: Error reading PROJX"<<endl;
+  }
+
+  try {  // ProjY
+    int_4 ipr = dvl.GetI("PROJY",-1);
+    is.MoveAbsToHDU(hducur+ipr);
+    dobj->SetProjY();
+    Histo *h = dobj->HProjY();
+    FitsHandler<Histo> fio(*h); fio.Read(is);
+    if(h->NBins()!=dobj->NBinY())
+      throw FitsIOException("unmatched bin number");
+  } catch (...) {
+    dobj->DelProjY();
+    cout<<"FitsHandler<Histo2D>::Read: Error reading PROJY"<<endl;
+  }
+
+  try {  // SliX
+    int_4 nb = dvl.GetI("NSLICEX",-1);
+    int_4 ipr = dvl.GetI("SLICEX",-1);
+    dobj->SetSliX(nb);
+    for(int i=0;i<nb;i++) {
+      is.MoveAbsToHDU(hducur+ipr+i);
+      Histo *h = dobj->HSliX(i);
+      FitsHandler<Histo> fio(*h); fio.Read(is);
+      if(h->NBins()!=dobj->NBinX())
+        throw FitsIOException("unmatched bin number");
+    }
+  } catch (...) {
+    dobj->DelSliX();
+    cout<<"FitsHandler<Histo2D>::Read: Error reading SLICEX"<<endl;
+  }
+
+  try {  // SliY
+    int_4 nb = dvl.GetI("NSLICEY",-1);
+    int_4 ipr = dvl.GetI("SLICEY",-1);
+    dobj->SetSliY(nb);
+    for(int i=0;i<nb;i++) {
+      is.MoveAbsToHDU(hducur+ipr+i);
+      Histo *h = dobj->HSliY(i);
+      FitsHandler<Histo> fio(*h); fio.Read(is);
+      if(h->NBins()!=dobj->NBinY())
+        throw FitsIOException("unmatched bin number");
+    }
+  } catch (...) {
+    dobj->DelSliY();
+    cout<<"FitsHandler<Histo2D>::Read: Error reading SLICEY"<<endl;
+  }
+
+  try {  // BandeX
+    int_4 nb = dvl.GetI("NBANDEX",-1);
+    int_4 ipr = dvl.GetI("BANDEX",-1);
+    for(int i=0;i<nb;i++) {
+      char str[32];
+      sprintf(str,"BXL%d",i); r_8 vmin = dvl.GetD(str,0.);
+      sprintf(str,"BXH%d",i); r_8 vmax = dvl.GetD(str,0.);
+      dobj->SetBandX(vmin,vmax);
+      is.MoveAbsToHDU(hducur+ipr+i);
+      Histo *h = dobj->HBandX(i);
+      FitsHandler<Histo> fio(*h); fio.Read(is);
+      if(h->NBins()!=dobj->NBinX())
+        throw FitsIOException("unmatched bin number");
+    }
+  } catch (...) {
+    dobj->DelBandX();
+    cout<<"FitsHandler<Histo2D>::Read: Error reading BANDEX"<<endl;
+  }
+
+  try {  // BandeY
+    int_4 nb = dvl.GetI("NBANDEY",-1);
+    int_4 ipr = dvl.GetI("BANDEY",-1);
+    for(int i=0;i<nb;i++) {
+      char str[32];
+      sprintf(str,"BYL%d",i); r_8 vmin = dvl.GetD(str,0.);
+      sprintf(str,"BYH%d",i); r_8 vmax = dvl.GetD(str,0.);
+      dobj->SetBandY(vmin,vmax);
+      is.MoveAbsToHDU(hducur+ipr+i);
+      Histo *h = dobj->HBandY(i);
+      FitsHandler<Histo> fio(*h); fio.Read(is);
+      if(h->NBins()!=dobj->NBinY())
+        throw FitsIOException("unmatched bin number");
+    }
+  } catch (...) {
+    dobj->DelBandY();
+    cout<<"FitsHandler<Histo2D>::Read: Error reading BANDEY"<<endl;
+  }
+
+  return;
+}
