Index: /trunk/AddOn/TAcq/brproc.cc
===================================================================
--- /trunk/AddOn/TAcq/brproc.cc	(revision 3943)
+++ /trunk/AddOn/TAcq/brproc.cc	(revision 3944)
@@ -94,6 +94,6 @@
   
   //  cout << "(JEC) creation tuple de " << nchan*(1+numberOfBands_) << " doubles " << endl;
-  //  xnt_=new double[nchan*(1+numberOfBands_)];  // CHECK : ATTENTION la taille depend de nombre de colonne du NTuple !
-  xnt_=NULL;
+  // CHECK : ATTENTION , on alloue une taille minimum pour le tableau xnt, reallocation si DefineDataTable() appele
+  xnt_=new double[nchan*2];
 }
 
@@ -168,4 +168,5 @@
   //  xnt_=new double[nchan*2];  CHECK : faut-il reallouer ?
   cout << "(JEC) creation tuple de " << nchan*(1+numberOfBands_) << " doubles " << endl;
+  if (xnt_) delete[] xnt_;
   xnt_=new double[nchan*(1+numberOfBands_)];
   cout << "(JEC) BRMeanSpecCalculator::DefineDataTable END" << endl;
Index: /trunk/AddOn/TAcq/racquproc.cc
===================================================================
--- /trunk/AddOn/TAcq/racquproc.cc	(revision 3943)
+++ /trunk/AddOn/TAcq/racquproc.cc	(revision 3944)
@@ -155,9 +155,235 @@
 
 /* --Methode-- */
-int MonitorProc::procData1C(ofstream& logf)
-{
-  cout << " MonitorProc::procData1C() - NOT IMPLEMENTED -> Rc=67" << endl;
-  logf << " MonitorProc::procData1C() - NOT IMPLEMENTED -> Rc=67" << endl;
-  return 67;  
+int MonitorProc::procData1C(ofstream& filog)
+{
+  /*
+  if (par_.fgdatafft) {
+    cout << " MonitorProc::procData1C() - NOT IMPLEMENTED for 1 channel FFT data -> Rc=67" << endl;
+    filog << " MonitorProc::procData1C() - NOT IMPLEMENTED for 1 channel FFT data -> Rc=67" << endl;
+    return 67;  
+  }
+  */
+  BRPaqChecker pcheck[MAXNBFIB];  // Verification/comptage des paquets 
+// Initialisation pour calcul FFT 
+  uint_4 paqsz = memgr.PaqSize();
+  BRPaquet pq(paqsz); 
+  TVector<r_4> vx(pq.DataSize());
+  vx = (r_4)(0.);
+  TVector< complex<r_4> > cfour(pq.DataSize()/2+1);  // composant TF
+  
+  fftwf_plan plan = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(), 
+					  (fftwf_complex *)cfour.Data(), FFTW_ESTIMATE); 
+
+  // Histo pour valeurs des bytes dans les paquets 
+  Histo* phist[MAXNBFIB];
+  Histo2D* ph2[MAXNBFIB];
+  Histo* phexp[MAXNBFIB];
+  TMatrix<r_4>* psatur[MAXNBFIB];  
+  TVector<uint_4>* pvsatfreq[MAXNBFIB];
+  for(int ifib=0; ifib<MAXNBFIB; ifib++) {
+    phist[ifib]=NULL; ph2[ifib]=NULL; phexp[ifib]=NULL; psatur[ifib]=NULL;
+  }
+  if (par_.fgdatafft) {    // data de type FFT   
+    for(sa_size_t lc=0; lc<memgr.NbFibres(); lc++) {
+      phist[lc] = new Histo(-128.5,+128.5,257);
+      ph2[lc]   = new Histo2D(-128.5,+128.5,257, -128.5,+128.5,257);
+      phexp[lc] = new Histo(-128.5,+128.5,257);
+      psatur[lc] = new TMatrix<r_4>(3,3);
+      pvsatfreq[lc] = new TVector<uint_4>(spectre_.NCols());
+      *psatur[lc] = 0.;
+    }
+  }
+  else {
+    for(sa_size_t lc=0; lc<memgr.NbFibres(); lc++)  
+      phist[lc] = new Histo(-0.5,256.5,257);    
+  }
+
+  TimeStamp ts;   
+  char fname[512];
+  nfiles_ = 0;  			        
+  for (uint_4 kmz=0; kmz<nmax_; kmz++) {
+    if (stop_) break;
+    if (memgr.GetRunState() == MemZR_Stopped) break;
+
+    int mid = memgr.FindMemZoneId(mmact_);  // MemZA_Proc
+    Byte* buffg = memgr.GetMemZone(mid);
+    if (buffg == NULL) {
+      cout << " MonitorProc::procData1C()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
+      break;	
+    }
+    if ((step_>1)&&(kmz%step_ != 0))  {
+      memgr.FreeMemZone(mid, mmsta_);  //  MemZS_Proc);
+      continue;
+    }
+    sa_size_t lc=0;
+    Byte* fbuff[MAXNBFIB];
+    for(uint_4 fib=0; fib<memgr.NbFibres(); fib++)  {  // Boucle sur les fibres 
+      fbuff[fib] = memgr.GetMemZone(mid,fib);
+      if (fbuff[fib] == NULL) { // cela ne devrait pas arriver 
+	cout << " MonitorProc::procData1C()/ERROR memgr.GetMemZone(" << mid << "," << fib << ") -> NULL" << endl;
+	return 9;	
+      }
+    }
+
+    // DBG-ATTENTION : freq 0 pour expo full FFT si reordonne 
+    //    int idxexpo=(par_.fgfftshrink)?1023:0; // exposant FFT shrink 1024 freq, ou freq 0 pour full-FFT
+    int idxexpo=0;
+
+    cpaqok_ = (uint_1)0;
+    curfc_ = (uint_8)0;
+    for(uint_4 fib=0; fib<memgr.NbFibres(); fib++) {
+      for(uint_4 i=0; i<memgr.NbPaquets(); i++) {
+	BRPaquet paq(fbuff[fib]+i*paqsz, paqsz); 
+	bool pqok=pcheck[fib].Check(paq,curfc_(fib,i));   // Verification du paquet / FrameCounter 
+	if (!pqok)  continue;
+	cpaqok_(fib,i) = 1;
+	sa_size_t lc=fib;
+	if (par_.fgdatafft) {    // Traitement data de type FFT 
+	  TwoByteComplex* tbcp=paq.Data1C();
+
+	  //  exposant FFT 
+	  phexp[lc]->Add((r_4)tbcp[idxexpo].realD());
+
+	  for(sa_size_t j=1; j<spectre_.NCols(); j++) {
+	    phist[lc]->Add((r_4)tbcp[j].realD());
+	    phist[lc]->Add((r_4)tbcp[j].imagD());
+	    ph2[lc]->Add((r_4)tbcp[j].realD(), (r_4)tbcp[j].imagD());
+	    // comptage saturation 
+	    int sir=0, sii=0;  // saturation partie reelle, partie imaginaire
+	    if (tbcp[j].realI()==-128) sir=-1;
+	    else if (tbcp[j].realI()==127) sir=1;
+	    if (tbcp[j].imagI()==-128) sii=-1;
+	    else if (tbcp[j].imagI()==127) sii=1;
+	    (*psatur[lc])(sir+1,sii+1)+=1.;
+	    if ((sir!=0)||(sii!=0))  (*pvsatfreq[lc])(j)+=1;
+	    spectre_(lc,j) += Zmod2(tbcp[j]);
+	  }
+	  nzm_[lc]++;  	
+	}
+	else {   // Traitement RawData 
+	  for(sa_size_t j=0; j<vx.Size(); j++) {
+	    phist[lc]->Add((r_8)(*(paq.Data1()+j)));
+	    vx(j) = (r_4)(*(paq.Data1()+j))-127.5;
+	  }
+	  fftwf_execute(plan); 
+	  //   ffts_.FFTForward(vx, cfour_);
+	  for(sa_size_t j=0; j<spectre_.NCols(); j++) 
+	    spectre_(lc,j) += Zmod2(cfour(j+1));
+	  nzm_[lc]++;      lc++;
+	}	
+      }  // FIN de la boucle sur les paquets 
+    }   // Boucle sur les fibres 
+    memgr.FreeMemZone(mid, mmsta_);  // MemZS_Proc);
+    CheckFrameCounters();
+
+    nblocproc_ ++;   
+    totnprocpaq_ += memgr.NbPaquets();  nprocpaq_ += memgr.NbPaquets();
+    bool fgnzm=true;
+    for(int lc=0; lc<memgr.NbFibres(); lc++)  
+      if (nzm_[lc]<nmean_) fgnzm=false;
+    
+    if (fgnzm) {
+      char buff[32];
+      for(sa_size_t lc=0; lc<memgr.NbFibres(); lc++)  {
+	spectre_.Row(lc) /= (r_4)nzm_[lc];
+	sprintf(buff,"NPaqMoy%d",(int)lc);
+	spectre_.Info()[buff] = nzm_[lc];
+      }
+      sprintf(fname,"%s/meanspec%d.ppf",path_.c_str(),(int)nfiles_);
+      nfiles_++;
+      POutPersist po(fname);
+      po << PPFNameTag("spectre") << spectre_; 
+      spectre_ = (r_4)(0.);
+      char buftag[32];
+      for(int lc=0; lc<memgr.NbFibres(); lc++)  { 
+	sprintf(buftag,"hvalV%d",(int)lc);
+	po << PPFNameTag(buftag) << (*phist[lc]);
+	phist[lc]->Zero();
+	if (par_.fgdatafft) {    // data de type FFT   
+	  sprintf(buftag,"h2dV%d",(int)lc);
+	  po << PPFNameTag(buftag) << (*ph2[lc]);
+	  ph2[lc]->Zero();
+	  sprintf(buftag,"hexpV%d",(int)lc);
+	  po << PPFNameTag(buftag) << (*phexp[lc]);
+	  phexp[lc]->Zero();
+	  sprintf(buftag,"saturV%d",(int)lc);
+	  po << PPFNameTag(buftag) << (*psatur[lc]);
+	  (*psatur[lc])=0.;
+	  sprintf(buftag,"satfreqV%d",(int)lc);
+	  po << PPFNameTag(buftag) << (*pvsatfreq[lc]);
+	  (*pvsatfreq[lc])=0;
+	}
+	nzm_[lc]=0;
+      }
+      ts.SetNow();
+      // Calcul / impression fraction des paquets avec same-framecounter
+      int fracsame=0;
+      if (nprocpaq_>0)  fracsame=100*npaqsamefc_/nprocpaq_;
+      int totfracsame=0;
+      if (totnprocpaq_>0)  totfracsame=100*totnpaqsamefc_/totnprocpaq_;
+      filog << ts << " :  proc file (meanspectra) " << fname << endl;
+      filog << "  NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_
+	    << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ <<  " / " << nprocpaq_ 
+	    << " -> " << fracsame << " % )" << endl;
+      cout << " MonitorProc::procData1C() " << ts << " : created file  " << fname << endl;
+      cout << "  NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_
+	   << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ <<  " / " << nprocpaq_ 
+	   << " -> " << fracsame << " % )" << endl;
+      nprocpaq_=npaqsamefc_=0;
+    }
+  }   // Fin de boucle sur les kmz ( bloc MemZoneMgr  a traiter )
+
+  bool fgnzm=false;
+  for(int lc=0; lc<memgr.NbFibres(); lc++)  
+    if (nzm_[lc]>0) fgnzm=true;
+  
+  if (fgnzm) {
+    char buff[32];
+    for(sa_size_t lc=0; lc<memgr.NbFibres(); lc++)  {
+      if (nzm_[lc]>0)  spectre_.Row(lc) /= (r_4)nzm_[lc];
+      sprintf(buff,"NPaqMoy%d",(int)lc);
+      spectre_.Info()[buff] = nzm_[lc];
+    }
+    sprintf(fname,"%s/meanspec%d.ppf",path_.c_str(),(int)nfiles_);
+    POutPersist po(fname);
+    po << PPFNameTag("spectre") << spectre_; 
+    spectre_ = (r_4)(0.);
+    char buftag[32];
+    for(int lc=0; lc<memgr.NbFibres(); lc++)  { 
+      sprintf(buftag,"hvalV%d",(int)lc);
+      po << PPFNameTag(buftag) << (*phist[lc]);
+      delete phist[lc];
+      if (par_.fgdatafft) {    // data de type FFT   
+	sprintf(buftag,"h2dV%d",(int)lc);
+	po << PPFNameTag(buftag) << (*ph2[lc]);
+	delete ph2[lc];
+	sprintf(buftag,"hexpV%d",(int)lc);
+	po << PPFNameTag(buftag) << (*phexp[lc]);
+	delete phexp[lc];
+	sprintf(buftag,"saturV%d",(int)lc);
+	po << PPFNameTag(buftag) << (*psatur[lc]);
+	sprintf(buftag,"satfreqV%d",(int)lc);
+	po << PPFNameTag(buftag) << (*pvsatfreq[lc]);
+	delete psatur[lc]; 
+	delete pvsatfreq[lc];
+      }
+      nzm_[lc]=0;
+    }
+    ts.SetNow();
+    // Calcul / impression fraction des paquets avec same-framecounter
+    int fracsame=0;
+    if (nprocpaq_>0)  fracsame=100*npaqsamefc_/nprocpaq_;
+    int totfracsame=0;
+    if (totnprocpaq_>0)  totfracsame=100*totnpaqsamefc_/totnprocpaq_;
+    filog << ts << " :  proc file (meanspectra) " << fname << endl;		       
+    filog << "  NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_
+	  << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ <<  " / " << nprocpaq_ 
+	  << " -> " << fracsame << " % )" << endl;
+    cout << " MonitorProc::procData1C() " << ts << " : created file  " << fname << endl;
+    cout << "  NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_
+	 << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ <<  " / " << nprocpaq_ 
+	 << " -> " << fracsame << " % )" << endl;
+  }
+  return 0;
 }
 
