Index: trunk/AddOn/TAcq/brprocGain.cc
===================================================================
--- trunk/AddOn/TAcq/brprocGain.cc	(revision 3953)
+++ trunk/AddOn/TAcq/brprocGain.cc	(revision 3992)
@@ -41,5 +41,5 @@
 BRGainCalculator::BRGainCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean, 
 					   bool fgdatafft, bool fgsinglechan)
-  : BRMeanSpecCalculator(memgr,outpath,nmean,fgdatafft,fgsinglechan), forceMedianFreqFilter_(false),nbwin4mean_(nmean)
+  : BRMeanSpecCalculator(memgr,outpath,nmean,fgdatafft,fgsinglechan), forceMedianFreqFilter_(false), medianFilterHalfWidth_(50), nbwin4mean_(nmean)
 {
 
@@ -70,4 +70,5 @@
   nummedianfile_ = 0;
   nbtot_specwin_ = 0;
+  windowTime_ = TimeStamp(); //default
 
 }
@@ -88,16 +89,21 @@
 {
 
-//   cout << "(JEC): BRGainCalculator ProcSpecWin: "<<   nbtot_specwin_ 
-//        << " nbwin4mean = " << nbwin4mean_
-//        << endl;
-  
-  //  cout<< "(Spec_window info) Start" << endl;
-  //spec_window_.Show();
-  //cout<< "(Spec_window info) End" << endl;
+  //   cout << "(JEC): BRGainCalculator ProcSpecWin: "<<   nbtot_specwin_ 
+  //        << endl;
+  
+
 
   //JEC 13/12/10 save the filtered spectra
   if ( (nbtot_specwin_>0)&&(nbtot_specwin_%nbwin4mean_==0) ) SaveMedianSpectra();
 
-
+  // Get time of window
+  windowTime_ = getObsTime();
+
+ if (prtlev_>1)  {
+      cout << " BRGainCalculator::ProcSpecWin() num_win=" << nbtot_specwin_ << " numpaqstart=" << numpaqstart 
+	   << " numpaqend=" << numpaqend  << " nbwin4mean = " << nbwin4mean_ << endl;
+      cout << " (1) ObsTime=" << windowTime_ << " TimeTag=" << getCurTimeTagSeconds() << " s. FrameCounter=" 
+	   << getCurFrameCounter() << endl;
+  }  
   //DBG  cout << "BRGainCalculator::ProcSpecWin()/Debug: numpaqstart=" << numpaqstart 
   //DBG     << " numpaqend=" << numpaqend << endl;
@@ -124,5 +130,5 @@
       //perform a median filter on the frequencies
       TVector<r_4> medianFilterFreq = medfiltspecmtx_.Row(i);
-      sa_size_t hww = 50; //half freq window for filtering
+      sa_size_t hww = medianFilterHalfWidth_; //half freq window for filtering
       sa_size_t fMin = 0.;
       sa_size_t fMax = spec_window_.SizeX()-1;
@@ -164,35 +170,48 @@
        << " nbtot_specwin = " <<  nbtot_specwin_
        << endl;
-  
-    for(sa_size_t ir=0; ir< medfiltspecmtx_.NRows(); ir++){
-      char buff[32];
-      sprintf(buff,"NPAQSUM_%d",(int)ir);
-      medfiltspecmtx_.Info()["NPAQSUM"] = nbtot_specwin_;
-      medfiltspecmtx_.Info()[buff] = nbtot_specwin_;
-      if ( nbtot_specwin_ > 0) {
-	medfiltspecmtx_.Row(ir)  /= (r_4)nbtot_specwin_;
-      }
-    }//eo loop on channels
-    char nfile[64];
-    string flnm;
-    {
-      sprintf(nfile,"medfiltmtx%d.fits",nummedianfile_);
-      flnm="!"+outpath_+nfile;
-      FitsInOutFile fos(flnm,FitsInOutFile::Fits_Create);
-      fos << medfiltspecmtx_;
+  if (prtlev_>1)  {
+    cout << " BRGainCalculator:SaveMedianSpectra() nbwin4mean = " << nbwin4mean_ << endl
+	 << " (2) ObsTime=" << windowTime_ << " Total Intensity " << 0.5*medfiltspecmtx_.Sum() << endl;
+  }  
+  
+  //JEC compute power spectrum
+  
+
+
+
+  for(sa_size_t ir=0; ir< medfiltspecmtx_.NRows(); ir++){
+    char buff[32];
+    sprintf(buff,"NPAQSUM_%d",(int)ir);
+    medfiltspecmtx_.Info()["NPAQSUM"] = nbtot_specwin_;
+    medfiltspecmtx_.Info()[buff] = nbtot_specwin_;
+    //JEC timeStamp in the day @ millisec: faudra gerer le passage a minuit!
+    medfiltspecmtx_.Info()["TIMEWIN"] = (windowTime_.SecondsPart())*1000.;
+
+
+    if ( nbtot_specwin_ > 0) {
+      medfiltspecmtx_.Row(ir)  /= (r_4)nbtot_specwin_;
     }
+  }//eo loop on channels
+  char nfile[64];
+  string flnm;
+  {
+    sprintf(nfile,"medfiltmtx%d.fits",nummedianfile_);
+    flnm="!"+outpath_+nfile;
+    FitsInOutFile fos(flnm,FitsInOutFile::Fits_Create);
+    fos << medfiltspecmtx_;
     cout << nummedianfile_ << "-BRGainCalculator::ProcSpecWin() save filtered spectra matrix in " 
 	 << flnm << endl;
-
-    //increment the file index
-    nummedianfile_++;
+  }
+  
+  //increment the file index
+  nummedianfile_++;
     
-    //reset the matirx
-    medfiltspecmtx_ = (r_4)(0.);
-
-    //reset counter
-    nbtot_specwin_ = 0;
-
-    return;
+  //reset the matirx
+  medfiltspecmtx_ = (r_4)(0.);
+
+  //reset counter
+  nbtot_specwin_ = 0;
+
+  return;
 }
 //JEC 13/12/10 End
