Index: /trunk/AddOn/TAcq/branap.cc
===================================================================
--- /trunk/AddOn/TAcq/branap.cc	(revision 3991)
+++ /trunk/AddOn/TAcq/branap.cc	(revision 3992)
@@ -43,4 +43,5 @@
 
   fgfreqfilter_=false; //JEC 1/2/11
+  medhalfwidth_=50;    //JEC 6/4/11
 
   gainfile_="";
@@ -137,5 +138,6 @@
     }
     else if (strcmp(arg[ka],"-freqfilter")==0) {
-      fgfreqfilter_=true;
+      fgfreqfilter_=true;  ka++;
+      if (strcmp(arg[ka],"-")!=0) medhalfwidth_=atof(arg[ka]); 
       ka++;
     }    
@@ -201,4 +203,5 @@
        << "                 [-prt lev,modulo] [-nvcal n] [-nthr n] [-nosfc]\n"
        << "                 [-singlechan] [-twochan] [-fftdata] [-rawdata] \n"
+       << "                 [-freqfilter medhw] [-gain filename] [-varcut min,max] [-nband nband,first,last] \n"
        << "                 [-freqfilter] [-gain filename] [-varcut min,max] [-nband nband,first,last] \n"
        << "                 [-tmproc hh:mm:ss,nseconds] [-filldt] [-tspwin wsz,extsz,nfiles] \n" 
@@ -232,5 +235,6 @@
        << " -tmproc hh:mm:ss,nseconds : processing time window definition \n"
        << " -filldt : force data table filling \n"
-       << " -freqfilter : force median filtering on the frequencies \n"
+       << " -freqfilter medhw: force median filtering on the frequencies \n"
+       << "   with half window width medhw (use - for default=" << medhalfwidth_ << ") \n"
        << " -gain filename : spectral response fits file name \n" 
        << " -tspwin wsz,extsz,nfiles : spectra time (paquet no) window (ex: -tspwin 120,4,5) \n"
@@ -283,5 +287,10 @@
        << " Bands: N=" <<  nbands_ << " First=" << bandfirst_ << " Last=" << bandlast_
        << endl;
-  cout << " force frequence median filtering (action gain)" << endl;
+  if (fgfreqfilter_) {
+    cout << " force frequence median filtering (action gain), half width =" << medhalfwidth_
+	 << endl;
+  } else {
+    cout<<" NO freq. filtering" << endl;
+  }
   cout << " Spectra TimeWindow (Nb.Paquets) Size=" << spec_win_sz_ << " ExtensionSize=" << spw_ext_sz_ 
        << " MaxNbFile=" << nbmax_specwfiles_ << endl; 
Index: /trunk/AddOn/TAcq/branap.h
===================================================================
--- /trunk/AddOn/TAcq/branap.h	(revision 3991)
+++ /trunk/AddOn/TAcq/branap.h	(revision 3992)
@@ -61,4 +61,5 @@
 
   bool fgfreqfilter_; // if true force median filtering on the frequencies
+  uint_4 medhalfwidth_; //half freq window for filtering
 
   string gainfile_;     // nom du fichier de gain (reponse spectrale)
Index: /trunk/AddOn/TAcq/brprocGain.cc
===================================================================
--- /trunk/AddOn/TAcq/brprocGain.cc	(revision 3991)
+++ /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
Index: /trunk/AddOn/TAcq/brprocGain.h
===================================================================
--- /trunk/AddOn/TAcq/brprocGain.h	(revision 3991)
+++ /trunk/AddOn/TAcq/brprocGain.h	(revision 3992)
@@ -28,5 +28,5 @@
 
   void SetOnMedianFreqFilt(){forceMedianFreqFilter_ = true;}  
-
+  void SetMedianFilterHalfWidth(uint_4 val){ medianFilterHalfWidth_ = val; }
 
 protected:
@@ -39,4 +39,6 @@
 
   bool forceMedianFreqFilter_; // if true force Median frequency filtering
+  uint_4 medianFilterHalfWidth_; //half freq window for filtering (default=50)
+
 
   TMatrix< r_4 > medfiltspecmtx_;    // Matrice des spectres filtres 
@@ -44,4 +46,5 @@
   uint_4 nummedianfile_; //index of the filtered spectra file 
 
+  TimeStamp  windowTime_; //time of the window of paquets
 }; 
 #endif
Index: /trunk/AddOn/TAcq/specmfib.cc
===================================================================
--- /trunk/AddOn/TAcq/specmfib.cc	(revision 3991)
+++ /trunk/AddOn/TAcq/specmfib.cc	(revision 3992)
@@ -93,5 +93,10 @@
 	new BRGainCalculator(mmgr, par.outpath_, par.nmean_, par.fgdatafft_, par.fgsinglechannel_);
       procgain_p->SetPrintLevel(par.prtlevel_,par.prtmodulo_);
-      if(par.fgfreqfilter_) procgain_p->SetOnMedianFreqFilt();
+      if(par.fgfreqfilter_){ 
+	procgain_p->SetOnMedianFreqFilt();
+	//add possibility to set the half width of the Freq. Median Filter
+	//default is 50 if par.fgfreqfilter_=true
+	if (par.medhalfwidth_>0) procgain_p->SetMedianFilterHalfWidth(par.medhalfwidth_);
+      }
       if(par.fgtimeselect_) procgain_p->SetProcTimeWindow(par.proctimestart_,par.proctimeend_);
     }
