Index: /trunk/ArchTOIPipe/Kernel/fitstoirdr.cc
===================================================================
--- /trunk/ArchTOIPipe/Kernel/fitstoirdr.cc	(revision 1628)
+++ /trunk/ArchTOIPipe/Kernel/fitstoirdr.cc	(revision 1629)
@@ -11,4 +11,5 @@
   name = "rdr";
   fptr = NULL;
+  totnscount = 0;
 }
 
@@ -126,4 +127,5 @@
   cout << "reader reading... NRows=" << nrows << " firstSn= " 
        << firstSn << endl;
+
   for (int i=0; i<nrows; i++) {
     int anyNul;
@@ -149,4 +151,5 @@
       putData(k, sn, y, flg);
     }
+    totnscount++;
   }
   cout << "reader done reading... " << pthread_self() << endl;
Index: /trunk/ArchTOIPipe/Kernel/fitstoirdr.h
===================================================================
--- /trunk/ArchTOIPipe/Kernel/fitstoirdr.h	(revision 1628)
+++ /trunk/ArchTOIPipe/Kernel/fitstoirdr.h	(revision 1629)
@@ -19,5 +19,7 @@
 
   virtual void init();  
-  virtual void run();  
+  virtual void run(); 
+ 
+  inline int_8	ProcessedSampleCount() const { return totnscount; }
 
 protected:
@@ -43,4 +45,6 @@
   // le flag est alors en colonne+1
 
+  int_8 totnscount;   // Nombre total d'echantillon processe
+
 };
 
Index: /trunk/ArchTOIPipe/Kernel/fitstoiwtr.cc
===================================================================
--- /trunk/ArchTOIPipe/Kernel/fitstoiwtr.cc	(revision 1628)
+++ /trunk/ArchTOIPipe/Kernel/fitstoiwtr.cc	(revision 1629)
@@ -18,4 +18,6 @@
   fits_unlock();
   name = "wtr";
+
+  totnscount = 0;
 }
 
@@ -148,5 +150,5 @@
       //           if ((sn%2000 == 0) || (sn<snb+5)) 
       //      	cout << " DBG-C-FitsWriter::run()" << sn << " line=" << fitsLine << endl;
-      fitsLine++;
+      fitsLine++;  totnscount++;
     } catch (PException e) {
     cout << "fitstoiwtr exception " << e.Msg() << endl;
Index: /trunk/ArchTOIPipe/Kernel/fitstoiwtr.h
===================================================================
--- /trunk/ArchTOIPipe/Kernel/fitstoiwtr.h	(revision 1628)
+++ /trunk/ArchTOIPipe/Kernel/fitstoiwtr.h	(revision 1629)
@@ -22,5 +22,7 @@
   virtual void  addInput(string name, TOI* toi, bool withFlag);
 
-  virtual void  run();  
+  virtual void  run(); 
+ 
+  inline int_8	ProcessedSampleCount() const { return totnscount; }
   
 private:
@@ -32,4 +34,6 @@
   map<int,pair<int, bool> > colsinput; // iTOI -> (colonne, hasflag)
   // le flag est alors en colonne+1
+
+  int_8 totnscount;   // Nombre total d'echantillon processe
 };
 
Index: /trunk/ArchTOIPipe/Kernel/toimanager.cc
===================================================================
--- /trunk/ArchTOIPipe/Kernel/toimanager.cc	(revision 1628)
+++ /trunk/ArchTOIPipe/Kernel/toimanager.cc	(revision 1629)
@@ -43,2 +43,73 @@
   }
 }
+
+
+// -----------------------------------------------------------------
+//    Classe pour affichage de l'avancement des TOIProcessors 
+//                         Reza 08/2001 
+// -----------------------------------------------------------------
+
+RzProcSampleCounter::RzProcSampleCounter()
+{
+  _msg = "SampleCounter/Info";
+  _rate = 50;
+}
+
+RzProcSampleCounter::~RzProcSampleCounter()
+{
+}
+
+long RzProcSampleCounter::PrintStats()
+{
+  int istart = 0;
+  int iend = 0;
+  long dns_print = 1000;
+  int dns_print_fac = _rate;
+  int nbmax_dns_print = 2;
+
+  TOIManager* mgr = TOIManager::getManager();
+  
+  istart = mgr->getRequestedBegin();
+  iend = mgr->getRequestedEnd();
+  
+  dns_print = (iend-istart)/dns_print_fac;
+  if (dns_print < 1000) dns_print = ((iend-istart) < 1000) ? (iend-istart) : 1000;
+  if (dns_print < 1) dns_print = 1;
+  nbmax_dns_print = (iend-istart)/dns_print;
+
+  cout << "RzProcSampleCounter::PrintStats() InfoMessage=" << _msg 
+       << "\n ... " << _msg << " istart=" 
+       << istart << " iend= " << iend << " dns_print= " << dns_print
+       << " nbmax_dns_print= " << nbmax_dns_print << endl;
+  // ------------------- Impression continu de stat ------------------------ 
+  long nb_dns_print = 0;
+  int nb_sleep = 0;
+  long last_sample_count = 0;
+  long processed_samples = 0;
+  long total_sample_count = dns_print*nbmax_dns_print;
+  bool alldone = false;
+  while (!alldone) {
+    processed_samples = ProcessedSampleCount();
+    if ( (processed_samples-last_sample_count > dns_print) || 
+	 (processed_samples > total_sample_count-10) ) {
+      last_sample_count = processed_samples;
+      if (nb_dns_print == 0) cout << "\n";
+      nb_dns_print++;
+      cout << ">>> " << _msg << ": ProcessedSampleCount()= " << last_sample_count 
+	   << " Frac done = " << processed_samples*100/total_sample_count << " %" << endl;
+      if (last_sample_count > total_sample_count-10)  alldone = true;
+      nb_sleep = 0;
+    }
+    else if ((nb_sleep+1)%5 == 0) 
+      cout << "> " << _msg << ": ProcSamples()= " <<  processed_samples 
+	   << " Done = " << " %" << processed_samples*100/total_sample_count
+	   << " NbSleep(1) = " << nb_sleep << endl;
+    
+    sleep(1);  nb_sleep++;
+  }
+  
+  // -----------------------------------------------------------------------
+  
+  return last_sample_count;
+
+}
Index: /trunk/ArchTOIPipe/Kernel/toimanager.h
===================================================================
--- /trunk/ArchTOIPipe/Kernel/toimanager.h	(revision 1628)
+++ /trunk/ArchTOIPipe/Kernel/toimanager.h	(revision 1629)
@@ -26,3 +26,32 @@
 };
 
+
+// -----------------------------------------------------------------
+//    Classe pour affichage de l'avancement des TOIProcessors 
+//                         Reza 08/2001 
+// -----------------------------------------------------------------
+
+class RzProcSampleCounter {
+public:
+                RzProcSampleCounter();
+  virtual       ~RzProcSampleCounter();
+  virtual long	ProcessedSampleCount() = 0;
+  virtual long  PrintStats();
+  inline int &  PrintRate(int pr) { return _rate; } 
+  inline string& InfoMessage() { return _msg; } 
+protected:
+  int _rate;
+  string _msg;
+};
+
+template <class T>
+class ProcSampleCounter : public RzProcSampleCounter {
+public:
+                ProcSampleCounter(const T & t) { _t = &t; } 
+  virtual long	ProcessedSampleCount()
+                      { return _t->ProcessedSampleCount(); }
+protected:
+  const T * _t;
+};
+
 #endif
Index: /trunk/ArchTOIPipe/Kernel/toiprocessor.cc
===================================================================
--- /trunk/ArchTOIPipe/Kernel/toiprocessor.cc	(revision 1628)
+++ /trunk/ArchTOIPipe/Kernel/toiprocessor.cc	(revision 1629)
@@ -235,4 +235,5 @@
   //  cout << p->name << " new thread running " << pthread_self() << endl;
   p->run();
+  pthread_exit(NULL);
   //  cout << p->name << " thread done " << pthread_self() << endl;
   return NULL;
Index: /trunk/ArchTOIPipe/ProcWSophya/toi2map.cc
===================================================================
--- /trunk/ArchTOIPipe/ProcWSophya/toi2map.cc	(revision 1628)
+++ /trunk/ArchTOIPipe/ProcWSophya/toi2map.cc	(revision 1629)
@@ -42,5 +42,5 @@
 TOI2Map::~TOI2Map()
 {
- if(mWSph && !mWSphInternal) delete mWSph;
+ if(mWSph && mWSphInternal) delete mWSph;
 }
 
Index: /trunk/ArchTOIPipe/TestPipes/simtst.cc
===================================================================
--- /trunk/ArchTOIPipe/TestPipes/simtst.cc	(revision 1628)
+++ /trunk/ArchTOIPipe/TestPipes/simtst.cc	(revision 1629)
@@ -87,7 +87,4 @@
   int istart = 0;
   int iend = 0;
-  int_8 dns_print = 1000;
-  int dns_print_fac = 50;
-  int nbmax_dns_print = 2;
 
   double range_min = -16000;
@@ -207,10 +204,7 @@
     //  mgr->setRequestedSample(11680920,11710584);
     //  mgr->setRequestedSample(104121000, 104946120);
-    if (fgsetstart) {
+    if (fgsetstart) 
       mgr->setRequestedSample(istart, iend);
-      dns_print = (iend-istart)/dns_print_fac;
-      if (dns_print < 1000) dns_print = 1000;
-      nbmax_dns_print = (iend-istart)/dns_print;
-    }
+
     //    FITSTOIReader r("/data/Archeops/bolo11.fits); 
     FITSTOIReader r(infile); 
@@ -397,30 +391,7 @@
 
     // ------------------- Impression continu de stat ------------------------ 
-    int_8 nb_dns_print = 0;
-    int nb_sleep = 0;
-    int_8 last_sample_count = 0;
-    int_8 processed_samples = 0;
-    int_8 total_sample_count = dns_print*nbmax_dns_print;
-    bool alldone = false;
-    while (!alldone) {
-      processed_samples = filt.ProcessedSampleCount();
-      if ( (processed_samples-last_sample_count > dns_print) || 
-	   (processed_samples > total_sample_count-10) ) {
-	last_sample_count = processed_samples;
-	if (nb_dns_print == 0) cout << "\n";
-	nb_dns_print++;
-	cout << ">>> simtst/Info: ProcessedSampleCount()= " << last_sample_count 
-	     << " Frac done = " << processed_samples*100/total_sample_count << " %" << endl;
-	if (last_sample_count > total_sample_count-10)  alldone = true;
-	nb_sleep = 0;
-      }
-      else if ((nb_sleep+1)%5 == 0) 
-	cout << "> simtst/Info: ProcSamples()= " <<  processed_samples 
-	     << " Done = " << " %" << processed_samples*100/total_sample_count
-	     << " NbSleep(1) = " << nb_sleep << endl;
-	
-      sleep(1);  nb_sleep++;
-    }
-
+    ProcSampleCounter<SimpleFilter> stats(filt);
+    stats.InfoMessage() = "simtst/Info";
+    stats.PrintStats();
     // -----------------------------------------------------------------------
 
Index: /trunk/ArchTOIPipe/TestPipes/tsttoi2map.cc
===================================================================
--- /trunk/ArchTOIPipe/TestPipes/tsttoi2map.cc	(revision 1628)
+++ /trunk/ArchTOIPipe/TestPipes/tsttoi2map.cc	(revision 1629)
@@ -154,4 +154,5 @@
 //--------------------------------------------------------------------
 
+
  // FITS reader
  FITSTOIReader rfitsb(fitsin_bolo);
@@ -222,6 +223,13 @@
    }
 
+ //  Affichage de l'avancement des TOIProcessors 
+ ProcSampleCounter<FITSTOIReader>  stats(rfitsb);
+ stats.InfoMessage() = "tsttoi2map/Info";
+ stats.PrintStats();
+
+ // Fin des traitements des TOIProcessors  
  mgr->joinAll();
  PrtTim("End threads");
+
 
  // Ecriture de la sphere Healpix sur fits
@@ -240,6 +248,8 @@
 
  // Nettoyage
+ cout << "tsttoi2map: cleanup " << endl;
  delete sph;
  if(wsph) delete wsph;
+ cout << "tsttoi2map: ----------- End of job -------------- " << endl;
 
 //--------------------------------------------------------------------
