Index: /trunk/AddOn/TAcq/branap.cc
===================================================================
--- /trunk/AddOn/TAcq/branap.cc	(revision 3887)
+++ /trunk/AddOn/TAcq/branap.cc	(revision 3888)
@@ -33,4 +33,5 @@
 
   vmin_=0.;  vmax_=9e99;
+  gainfile_="";
 }
 
@@ -91,4 +92,8 @@
     else if (strcmp(arg[ka],"-varcut")==0) {
       sscanf(arg[ka+1],"%lg,%lg",&vmin_,&vmax_);
+      ka+=2;
+    }
+    else if (strcmp(arg[ka],"-gain")==0) {
+      gainfile_=arg[ka+1];
       ka+=2;
     }
@@ -132,5 +137,6 @@
   cout << " Usage:  prgname [-act ACT] [-out OutPath] [-nmean NMean] [-zones NZones,nPaqinZone] \n" 
        << "                 [-nbloc NBloc] [-freq NumFreqMin,NumFreqMax,NBinFreq] \n" 
-       << "                 [-prt lev,modulo] [-nvcal n] [-nthr n] [-nosfc] [-varcut min,max] \n" 
+       << "                 [-prt lev,modulo] [-nvcal n] [-nthr n] [-nosfc] \n" 
+       << "                 [-gain filename] [-varcut min,max] \n" 
        << "         -in Imin,Imax,Istep InPath FiberList [InPath2 FiberList2 InPath3 FiberList3 ...] \n" << endl; 
   if (fgshort) {
@@ -152,4 +158,5 @@
        << " -nosfc : Don't force reading with SAME FrameCounter \n" 
        << " -varcut min,max : min-max cut on variance \n" 
+       << " -gain filename : spectral response fits file name \n" 
        << " -in : input files/directory definition : \n"
        << "       Imin,Imax,Istep: fits files signalII.fits Imin<=II<=Imax Istep=increment \n" 
@@ -179,5 +186,5 @@
   cout << " Action=" << action_ << "  NMean=" << nmean_ << " NBloc=" << nbloc_ << endl;
   cout << " FreqMin= " << freqmin_ << " FreqMax= " << freqmax_ << " NBinFreq= " << nbinfreq_ << endl;
-  cout << " VarianceMin= " << vmin_ << " VarianceMax= " << vmax_ << endl;
+  cout << " GainFileName=" << gainfile_ << " VarianceMin= " << vmin_ << " VarianceMax= " << vmax_ << endl;
   cout << " PaqSize=" << paqsize_ << "  -  NZones=" << nzones_ << " NPaqZone=" << npaqinzone_ 
        << " PrtLevel=" << prtlevel_ << " PrtCntModulo=" <<  prtmodulo_ << endl;
Index: /trunk/AddOn/TAcq/branap.h
===================================================================
--- /trunk/AddOn/TAcq/branap.h	(revision 3887)
+++ /trunk/AddOn/TAcq/branap.h	(revision 3888)
@@ -47,4 +47,5 @@
 
   double vmin_,vmax_;   // coupure min-max sur la variance 
+  string gainfile_;     // nom du fichier de gain (reponse spectrale)
 };
 
Index: /trunk/AddOn/TAcq/brproc.cc
===================================================================
--- /trunk/AddOn/TAcq/brproc.cc	(revision 3887)
+++ /trunk/AddOn/TAcq/brproc.cc	(revision 3888)
@@ -47,11 +47,15 @@
     mspecmtx_.SetSize(memgr_.NbFibres(), paq.DataSize()/2); 
     sigspecmtx_.SetSize(memgr_.NbFibres(), paq.DataSize()/2); 
+    sgain_.SetSize(memgr_.NbFibres(), paq.DataSize()/2); 
   }
   else {
     mspecmtx_.SetSize(2*memgr_.NbFibres(), paq.DataSize()/4); 
     sigspecmtx_.SetSize(2*memgr_.NbFibres(), paq.DataSize()/4); 
+    sgain_.SetSize(2*memgr_.NbFibres(), paq.DataSize()/4); 
   }
   mspecmtx_=(r_4)(0.);
   sigspecmtx_=(r_4)(0.);
+  sgain_=(r_4)(1.);    // Gain en fonction de la frequence, à 1 par defaut 
+
   numfile_=0;
   nbpaq4mean_=0;
@@ -71,5 +75,9 @@
     dtp_->AddFloatColumn(cnom);    
   }
-  xnt_=new double[nchan];
+  for(int i=0; i<nchan; i++) {
+    sprintf(cnom,"varnorm%d",i);
+    dtp_->AddFloatColumn(cnom);    
+  }
+  xnt_=new double[nchan*2];
 }
 
@@ -91,4 +99,12 @@
 }
 
+/* --Methode-- */
+void BRMeanSpecCalculator::ReadGainFitsFile(string filename)
+{
+  cout << " BRMeanSpecCalculator::ReadGainFitsFile() - reading file " << filename;
+  FitsInOutFile fis(filename, FitsInOutFile::Fits_RO);
+  fis >> sgain_;
+  cout << " MeanGain=" << sgain_.Sum()/sgain_.Size() << endl;
+}
 
 static inline r_4 Zmod2(complex<r_4> z) 
@@ -159,9 +175,15 @@
       }
       double variance=0.;
-      for(sa_size_t f=1; f<mspecmtx_.NCols(); f++)   variance+=(double)zp[f].module2F();
+      double varnorm=0.;
+      for(sa_size_t f=1; f<mspecmtx_.NCols(); f++) {
+	double modsq=(double)zp[f].module2F();
+	variance+=modsq;
+	varnorm+=modsq/sgain_(i,f);
+      }
       xnt_[i]=variance;
+      xnt_[i+mspecmtx_.NRows()]=varnorm;
       clnflg_[i]=0;
-      if (variance<varmin_) clnflg_[i]=1;
-      else if (variance>varmax_) clnflg_[i]=2;
+      if (varnorm<varmin_) clnflg_[i]=1;
+      else if (varnorm>varmax_) clnflg_[i]=2;
     }
   }
@@ -177,9 +199,15 @@
       }
       double variance=0.;
-      for(sa_size_t f=1; f<mspecmtx_.NCols(); f++)   variance+=(double)Zmod2(zp[f]);
+      double varnorm=0.;
+      for(sa_size_t f=1; f<mspecmtx_.NCols(); f++) {
+	double modsq=(double)Zmod2(zp[f]);
+	variance+=modsq;
+	varnorm+=modsq/sgain_(i,f);
+      }
       xnt_[i]=variance;
+      xnt_[i+mspecmtx_.NRows()]=varnorm;
       clnflg_[i]=0;
-      if (variance<varmin_) clnflg_[i]=1;
-      else if (variance>varmax_) clnflg_[i]=2;     
+      if (varnorm<varmin_) clnflg_[i]=1;
+      else if (varnorm>varmax_) clnflg_[i]=2;
     }
   }
Index: /trunk/AddOn/TAcq/brproc.h
===================================================================
--- /trunk/AddOn/TAcq/brproc.h	(revision 3887)
+++ /trunk/AddOn/TAcq/brproc.h	(revision 3888)
@@ -43,4 +43,6 @@
      { varmin_=vmin;  varmax_=vmax; }
 
+  void ReadGainFitsFile(string filename);
+
 protected:
   virtual int Process(); 
@@ -59,4 +61,6 @@
   TMatrix< r_4 > mspecmtx_;    // Matrice des spectres moyennees 
   TMatrix< r_4 > sigspecmtx_;    // Matrice des sigmas des spectres  
+
+  TMatrix< r_4 > sgain_;   // gain en fonction de la frequence  
 
   vector<int> clnflg_;      // resultat de la routine "cleaner" 
Index: /trunk/AddOn/TAcq/specmfib.cc
===================================================================
--- /trunk/AddOn/TAcq/specmfib.cc	(revision 3887)
+++ /trunk/AddOn/TAcq/specmfib.cc	(revision 3888)
@@ -73,4 +73,6 @@
     BRMeanSpecCalculator procms(mmgr, par.outpath_, par.nmean_, par.fgdatafft_, par.fgsinglechannel_);
     procms.SetVarianceLimits(par.vmin_, par.vmax_);
+    if (par.gainfile_.length()>0) procms.ReadGainFitsFile(par.gainfile_);
+
     BRFFTCalculator procfft(mmgr, par.fgsinglechannel_);
     if (!par.fgdatafft_) procms.SetMemZAction(MemZA_ProcB);
