Index: /trunk/ArchTOIPipe/Kernel/fitsringwtr.cc
===================================================================
--- /trunk/ArchTOIPipe/Kernel/fitsringwtr.cc	(revision 2354)
+++ /trunk/ArchTOIPipe/Kernel/fitsringwtr.cc	(revision 2355)
@@ -4,5 +4,5 @@
 //                               Christophe Magneville
 //                               Reza Ansari
-// $Id: fitsringwtr.cc,v 1.5 2003-03-10 13:33:03 aubourg Exp $
+// $Id: fitsringwtr.cc,v 1.6 2003-03-28 16:06:40 cecile Exp $
 
 #include "fitsringwtr.h"
@@ -60,8 +60,9 @@
   fits_unlock();
   
+  char* ttype = "DATA";
+  char* tform = "1D";
+  char xname[100];
+  
   for (int ring = 0; ring<nRings; ring++) {
-    char* ttype = "DATA";
-    char* tform = "1D";
-    char xname[100];
     sprintf(xname, "CRING_%d", ring);
 
@@ -84,12 +85,12 @@
       fits_lock();
       fits_write_col(fptr, TDOUBLE, 1,i+1,1,1, &data, &fstatus);
-      fits_unlock();
+      fits_unlock();      
     }
-
-    fits_lock();
-    fits_close_file(fptr, &fstatus);
-    fits_report_error(stderr, fstatus);
-    fits_unlock();
   }
-
+  
+  fits_lock();
+  fits_close_file(fptr, &fstatus);
+  fits_report_error(stderr, fstatus);
+  fits_unlock();
+  cout << "fitsringwriter done " << endl;
 }
Index: /trunk/ArchTOIPipe/ProcWSophya/toi2ring.cc
===================================================================
--- /trunk/ArchTOIPipe/ProcWSophya/toi2ring.cc	(revision 2354)
+++ /trunk/ArchTOIPipe/ProcWSophya/toi2ring.cc	(revision 2355)
@@ -3,5 +3,5 @@
 //                               Christophe Magneville
 //                               Reza Ansari
-// $Id: toi2ring.cc,v 1.4 2003-02-24 14:47:10 cecile Exp $
+// $Id: toi2ring.cc,v 1.5 2003-03-28 16:06:17 cecile Exp $
 
 #include "toimanager.h"
@@ -61,5 +61,7 @@
  int_8 Nrings=0,i;
  
- double phi_prec=-1.;
+ double phi_prec=-1.,ctheta_prec,cphi_prec;
+ double phi,val,ctheta,cphi;
+
  double* r = new double[Nsamples];
  double* wr = new double[Nsamples];
@@ -69,5 +71,4 @@
  }
 
- 
  cout << "loop " << snb << " " << sne << endl;
  
@@ -75,8 +76,8 @@
 
   uint_8 flg = 0;
-  double ctheta = getData(0,k);
-  double cphi = getData(1,k);
-  double phi = getData(2,k);
-  double val = getData(3,k);
+  ctheta = getData(0,k);
+  cphi = getData(1,k);
+  phi = getData(2,k);
+  val = getData(3,k);
   mSnRead++;
 
@@ -85,31 +86,32 @@
   wr[i]++;
 
-  cout << k << " " << phi << " " << phi_prec << " " << Nrings <<endl;
   
   if(phi < phi_prec || k == sne){
+    
+    //  if (k==sne) { wfits.setNRings(Nrings); wwfits.setNRings(Nrings);}
     
     for(i=0;i<Nsamples;i++) {
       if(wr[i] == 0) r[i] = -999999.;
       else r[i] /= wr[i];
-      cout << "PUT " << i << " " << Nrings << " " << Nsamples << " " << ctheta << " " << cphi << " " << r[i]<< endl;
-      putData(0,Nrings*Nsamples+i,ctheta);
-      putData(1,Nrings*Nsamples+i,cphi);
+      
+      putData(0,Nrings*Nsamples+i,ctheta_prec);
+      putData(1,Nrings*Nsamples+i,cphi_prec);
       putData(2,Nrings*Nsamples+i,r[i]);
-      putData(3,Nrings*Nsamples+i,ctheta);
-      putData(4,Nrings*Nsamples+i,cphi);
+      putData(3,Nrings*Nsamples+i,ctheta_prec);
+      putData(4,Nrings*Nsamples+i,cphi_prec);
       putData(5,Nrings*Nsamples+i,wr[i]);
       wr[i]=0;
       r[i]=0.;
+    
     }
     
-    Nrings++;
-    return;
-    
+    Nrings++;    
+    cout <<" Ring "<< Nrings << " written " << endl;
   }
-  
-
   phi_prec=phi;
+  ctheta_prec=ctheta;
+  cphi_prec=cphi;
   totnscount++;
-}
+} 
 
 cout<<"RING2Toi::run: Samples Read "<<mSnRead
Index: /trunk/ArchTOIPipe/TestPipes/tsttoi2ring.cc
===================================================================
--- /trunk/ArchTOIPipe/TestPipes/tsttoi2ring.cc	(revision 2354)
+++ /trunk/ArchTOIPipe/TestPipes/tsttoi2ring.cc	(revision 2355)
@@ -23,5 +23,5 @@
 void usage(void) {
   cout<<"tsttoi2ring fitsin_phase fitsin_value fitsout_value fitsout_weight ";
-   cout<<" Nsamples SN_begin SN_last (all -f SN_last<SN_begin)"<<endl;
+   cout<<" Nsamples SN_begin SN_last Nring (all if SN_last<SN_begin)"<<endl;
  return;
 }
@@ -39,5 +39,5 @@
 bool snimplicit = false;
 
-if(narg != 8) {usage(); exit(2);}
+if(narg != 9) {usage(); exit(2);}
 char * fitsin_phase    = arg[1];
 char * fitsin_value    = arg[2];
@@ -47,4 +47,5 @@
  int_8 sdeb               = atoi(arg[6]);
  int_8 sfin              = atoi(arg[7]);
+ int_8 Nring             = atoi(arg[8]);
     cout<<"Requested Samples from "<<sdeb<<" , "<<sfin<<endl;
  
@@ -86,10 +87,7 @@
  wfits.setNSamples(Nsamples);
  wwfits.setNSamples(Nsamples);
- wfits.setNRings(1);
- wwfits.setNRings(1);
- 
+ wfits.setNRings(Nring);
+ wwfits.setNRings(Nring);
 
-
- cout << "fits writer created"<<endl;
 
 
@@ -115,5 +113,5 @@
  plombier.Connect(m2ring,"WCircTheta",wwfits,"CircTheta");
  plombier.Connect(m2ring,"WCircPhi",wwfits,"CircPhi");
- plombier.Connect(m2ring,"WRvalue",wwfits,"signal");
+ plombier.Connect(m2ring,"WRvalue",wwfits,"signal"); 
 
  // Run
