Index: /trunk/Cosmo/SimLSS/cmvchkwhu.cc
===================================================================
--- /trunk/Cosmo/SimLSS/cmvchkwhu.cc	(revision 3347)
+++ /trunk/Cosmo/SimLSS/cmvchkwhu.cc	(revision 3348)
@@ -59,9 +59,9 @@
    double k = pow(10.,lnk);
    //if(fabs(lnk-log10(0.0186209))>1e-5) continue;
-   Tfull.SetReturnPart(0); double tf = Tfull(k);
+   Tfull.SetReturnPart(TransfertEisenstein::ALL); double tf = Tfull(k);
    double tfnw = Tnowig(k);
    double tfnb = Tnob(k);
-   Tfull.SetReturnPart(1); double tfc = Tfull(k);
-   Tfull.SetReturnPart(2); double tfb = Tfull(k);
+   Tfull.SetReturnPart(TransfertEisenstein::CDM); double tfc = Tfull(k);
+   Tfull.SetReturnPart(TransfertEisenstein::BARYON); double tfb = Tfull(k);
    double hutfc, hutfb;
    double hutf = TFfit_onek(k,&hutfb,&hutfc); 
Index: /trunk/Cosmo/SimLSS/cmvtvarspec.cc
===================================================================
--- /trunk/Cosmo/SimLSS/cmvtvarspec.cc	(revision 3347)
+++ /trunk/Cosmo/SimLSS/cmvtvarspec.cc	(revision 3348)
@@ -91,40 +91,40 @@
  //----
  cout<<endl<<"Filtrage top_hat"<<endl;
- VarianceSpectrum varpk_th(pkz,0);
- double kfind_th = varpk_th.FindMaximum(R,kmin,kmax,eps);
+ VarianceSpectrum varpk_th(pkz,R,VarianceSpectrum::TOPHAT);
+ double kfind_th = varpk_th.FindMaximum(kmin,kmax,eps);
  double pkmax_th = varpk_th(kfind_th);
  cout<<"kfind_th = "<<kfind_th<<" ("<<log10(kfind_th)<<"), integrand="<<pkmax_th<<endl;
  k1=kmin, k2=kmax;
- rc = varpk_th.FindLimits(R,pkmax_th*fracmax,k1,k2,eps);
+ rc = varpk_th.FindLimits(pkmax_th*fracmax,k1,k2,eps);
  cout<<"limit_th: rc="<<rc<<" : "<<k1<<" ("<<log10(k1)<<") , "<<k2<<" ("<<log10(k2)<<")"<<endl;
 
  varpk_th.SetInteg(0.01,dlk,-1.,4);
- cout<<"varpk_th="<<varpk_th.Variance(R,k1,k2)<<endl;
+ cout<<"varpk_th="<<varpk_th.Variance(k1,k2)<<endl;
 
  //----
  cout<<endl<<"Filtrage gaussien"<<endl;
- VarianceSpectrum varpk_ga(pkz,1);
- double kfind_ga = varpk_ga.FindMaximum(Rg,kmin,kmax,eps);
+ VarianceSpectrum varpk_ga(pkz,Rg,VarianceSpectrum::GAUSSIAN);
+ double kfind_ga = varpk_ga.FindMaximum(kmin,kmax,eps);
  double pkmax_ga = varpk_ga(kfind_ga);
  cout<<"kfind_ga = "<<kfind_ga<<" -> "<<log10(kfind_ga)<<", integrand="<<pkmax_ga<<endl;
  k1=kmin, k2=kmax;
- rc = varpk_ga.FindLimits(Rg,pkmax_ga*fracmax,k1,k2,eps);
+ rc = varpk_ga.FindLimits(pkmax_ga*fracmax,k1,k2,eps);
  cout<<"limit_ga: rc="<<rc<<" : "<<k1<<" ("<<log10(k1)<<") , "<<k2<<" ("<<log10(k2)<<")"<<endl;
 
  varpk_ga.SetInteg(0.01,dlk,-1.,4);
- cout<<"varpk_ga="<<varpk_ga.Variance(Rg,k1,k2)<<endl;
+ cout<<"varpk_ga="<<varpk_ga.Variance(k1,k2)<<endl;
  
  //----
   cout<<endl<<"Filtrage 1 (integrale du spectre)"<<endl;
- VarianceSpectrum varpk_int(pkz,2);
- double kfind_int = varpk_int.FindMaximum(Rg,kmin,kmax,eps);
+ VarianceSpectrum varpk_int(pkz,Rg,VarianceSpectrum::NOFILTER);
+ double kfind_int = varpk_int.FindMaximum(kmin,kmax,eps);
  double pkmax_int = varpk_int(kfind_int);
  cout<<"kfind_int = "<<kfind_int<<" -> "<<log10(kfind_int)<<", integrand="<<pkmax_int<<endl;
  k1=kmin, k2=kmax;
- rc = varpk_int.FindLimits(Rg,pkmax_int*fracmax,k1,k2,eps);
+ rc = varpk_int.FindLimits(pkmax_int*fracmax,k1,k2,eps);
  cout<<"limit_int: rc="<<rc<<" : "<<k1<<" ("<<log10(k1)<<") , "<<k2<<" ("<<log10(k2)<<")"<<endl;
 
  varpk_int.SetInteg(0.01,dlk,-1.,4);
- cout<<"varpk_int="<<varpk_int.Variance(Rg,k1,k2)<<endl;
+ cout<<"varpk_int="<<varpk_int.Variance(k1,k2)<<endl;
  
 //-----------------------------------------------------------------
Index: /trunk/Cosmo/SimLSS/pkspectrum.cc
===================================================================
--- /trunk/Cosmo/SimLSS/pkspectrum.cc	(revision 3347)
+++ /trunk/Cosmo/SimLSS/pkspectrum.cc	(revision 3348)
@@ -52,5 +52,5 @@
   : lp_(lp)
   , Oc_(OmegaCDM0) , Ob_(OmegaBaryon0) , h_(h100) , tcmb_(tcmb)
-  , nobaryon_(nobaryon) , nooscenv_(0), retpart_(0)
+  , nobaryon_(nobaryon) , nooscenv_(0), retpart_(ALL)
 {
  zero_();
@@ -192,12 +192,11 @@
 }
 
-void TransfertEisenstein::SetReturnPart(unsigned short retpart)
+void TransfertEisenstein::SetReturnPart(ReturnPart retpart)
 // To return only baryon or CDM part part of transfert function
-// retpart = 1 : return only CDM part of transfert function
-// retpart = 2 : return only Baryon part of transfert function
-// retpart = anything else: return only full transfert function
+// retpart = ALL: return full transfert function
+//         = CDM : return only CDM part of transfert function
+//         = BARYON : return only Baryon part of transfert function
 // WARNING: only relevant for nobaryon_=false AND nooscenv!=2
 {
- if(retpart!=1 && retpart!=2) retpart = 0;
  retpart_ = retpart;
 }
@@ -244,5 +243,5 @@
   double f = 1. / (1. + pow(k*s_/5.4,4.));
   double Tc = f*T0tild(k,1.,betac_) + (1.-f)*T0tild(k,alphac_,betac_);
-  if(retpart_ == 1) return Tc; 
+  if(retpart_ == CDM) return Tc; 
 
   // --- Baryons
@@ -264,5 +263,5 @@
   Tb += alphab_/(1.+pow(betab_/(k*s_),3.)) * exp(-pow(k/ksilk_,1.4));
   Tb *= j0kst;
-  if(retpart_ == 2) return Tb;
+  if(retpart_ == BARYON) return Tb;
 
   // --- Total
@@ -413,5 +412,5 @@
 //------------------------------------
 PkSpectrumZ::PkSpectrumZ(PkSpectrum0& pk0,GrowthFactor& d1,double zref)
-  : pk0_(pk0) , d1_(d1) , zref_(zref) , scale_(1.) , typspec_(0)
+  : pk0_(pk0) , d1_(d1) , zref_(zref) , scale_(1.) , typspec_(PK)
   , zold_(-1.) , d1old_(1.)
 {
@@ -419,5 +418,5 @@
 
 PkSpectrumZ::PkSpectrumZ(PkSpectrumZ& pkz)
-  : pk0_(pkz.pk0_) , d1_(pkz.d1_) , zref_(pkz.zref_) , scale_(pkz.scale_) , typspec_(0)
+  : pk0_(pkz.pk0_) , d1_(pkz.d1_) , zref_(pkz.zref_) , scale_(pkz.scale_) , typspec_(PK)
   , zold_(pkz.zold_) , d1old_(pkz.d1old_)
 {
@@ -428,12 +427,8 @@
 }
 
-void PkSpectrumZ::SetTypSpec(unsigned short typspec)
-  // typsec = 0 : compute Pk(k)
-  //        = 1 : compute Delta^2(k) = k^3*Pk(k)/2Pi^2
-{
-  if(typspec>1) {
-    cout<<"PkSpectrumZ::SetTypSpec: Error bad typspec value: "<<typspec<<endl;
-    throw ParmError("PkSpectrumZ::SetTypSpec: Error bad typspec value");
-  }
+void PkSpectrumZ::SetTypSpec(ReturnSpectrum typspec)
+// typsec = PK : compute Pk(k)
+//        = DELTA : compute Delta^2(k) = k^3*Pk(k)/2Pi^2
+{
   typspec_ = typspec;
 }
@@ -451,5 +446,5 @@
 
   double v = pk0_(k) * d1*d1;
-  if(typspec_) v *= k*k*k/(2.*M_PI*M_PI);
+  if(typspec_==DELTA) v *= k*k*k/(2.*M_PI*M_PI);
 
   return scale_ * v;
@@ -462,7 +457,8 @@
 ///////////////////////////////////////////////////////////
 
-VarianceSpectrum::VarianceSpectrum(GenericFunc& pk,unsigned short typfilter=0)
-  : pk_(pk) , R_(0.)
-{
+VarianceSpectrum::VarianceSpectrum(GenericFunc& pk,double R,TypeFilter typfilter)
+  : pk_(pk)
+{
+  SetRadius(R);
   SetFilter(typfilter);
 }
@@ -478,14 +474,22 @@
 }
 
+void VarianceSpectrum::SetRadius(double R)
+// R = taille du filter top-hat ou gaussien
+{
+ if(R<=0.) {
+    cout<<"VarianceSpectrum::SetRadius: Error R<=0"<<endl;
+    throw ParmError("VarianceSpectrum::SetRadius: Error R<=0");
+  }
+  R_ = R;
+}
+
 //------------------------------------
-void VarianceSpectrum::SetFilter(unsigned short typfilter)
-// typfilter = 0 : spherical 3D top-hat
-//           = 1 : spherical 3D gaussian
-//           = 2 : no filter juste integrate spectrum)
-{
-  if(typfilter>2) {
-    cout<<"VarianceSpectrum::SetFilter: Error bad value for type of filter"<<endl;
-    throw ParmError("VarianceSpectrum::SetFilter: Error bad value for type of filter");
-  }
+void VarianceSpectrum::SetFilter(TypeFilter typfilter)
+// typfilter = TOPHAT : spherical 3D top-hat
+//           = GAUSSIAN : spherical 3D gaussian
+//           = NOFILTER : no filter juste integrate spectrum)
+// Remarque:
+//   la meilleure approximation du filtre top-hat (R) est un filtre gaussien avec (Rg=R/sqrt(5))
+{
   typfilter_ = typfilter;
 }
@@ -507,5 +511,5 @@
 {
   // Just integrate the spectrum without filtering
-  if(typfilter_ == 2) return 1.;
+  if(typfilter_ == NOFILTER) return 1.;
 
   double x2 = x*x;
@@ -515,5 +519,5 @@
   //             DL(x) = 1-x^2*(1-x^2/2)
   //             pour x<0.01  |DL(x)-G(X)^2|<2.0e-13
-  if(typfilter_ == 1)
+  if(typfilter_ == GAUSSIAN)
     if(x<0.01) return 1.-x2*(1.-x2/2.); else return exp(-x2);
 
@@ -534,21 +538,18 @@
 }
 
-double VarianceSpectrum::Variance(double R,double kmin,double kmax)
+double VarianceSpectrum::Variance(double kmin,double kmax)
 // Compute variance of spectrum pk_ by integration
 // Input:
-//     R = taille du filter top-hat ou gaussien
 //     kmin,kmax = bornes en k de l'integrale pour calculer la variance
 // Return:
 //     valeur de la variance (sigma^2)
 // Remarque:
-//   la meilleure approximation du filtre top-hat (R) est un filtre gaussien avec (Rg=R/sqrt(5))
 //   la variance renvoyee est la variance de la masse
 {
-  if(R<=0. || kmin<=0 || kmax<=0. || kmin>=kmax) {
-    cout<<"VarianceSpectrum::Variance: Error R<=0 or kmin<=0 or kmax<=0 or kmin>=kmax"<<endl;
-    throw ParmError("VarianceSpectrum::Variance: Error R<=0 or kmin<=0 or kmax<=0 or kmin>=kmax");
-  }
-
-  R_ = R;
+  if(kmin<=0 || kmax<=0. || kmin>=kmax) {
+    cout<<"VarianceSpectrum::Variance: Error kmin<=0 or kmax<=0 or kmin>=kmax"<<endl;
+    throw ParmError("VarianceSpectrum::Variance: Error kmin<=0 or kmax<=0 or kmin>=kmax");
+  }
+
   double lkmin = log10(kmin), lkmax = log10(kmax);
 
@@ -559,9 +560,8 @@
 
 //------------------------------------
-double VarianceSpectrum::FindMaximum(double R,double kmin,double kmax,double eps)
+double VarianceSpectrum::FindMaximum(double kmin,double kmax,double eps)
 // Retourne le maximum de la fonction a integrer
 // La recherche a lieu entre [kmin,kmax] par pas logarithmiques
 // Input:
-//     R : taille du filter top-hat ou gaussien
 //     kmin,kmax : intervalle de recherche
 //     eps : precision requise sur les valeurs
@@ -569,10 +569,8 @@
 //     position (en k) du maximum
 {
-  if(R<=0. || kmin<=0 || kmax<=0. || kmin>=kmax) {
-    cout<<"VarianceSpectrum::FindMaximum: Error R<=0 or kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0"<<endl;
-    throw ParmError("VarianceSpectrum::FindMaximum: Error R<=0 or kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0");
-  }
-
-  R_ = R;
+  if(kmin<=0 || kmax<=0. || kmin>=kmax) {
+    cout<<"VarianceSpectrum::FindMaximum: Error kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0"<<endl;
+    throw ParmError("VarianceSpectrum::FindMaximum: Error kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0");
+  }
 
   int n = 10; // toujours >2
@@ -600,9 +598,8 @@
 }
 
-int VarianceSpectrum::FindLimits(double R,double high,double &kmin,double &kmax,double eps)
+int VarianceSpectrum::FindLimits(double high,double &kmin,double &kmax,double eps)
 // Retourne "[kmin,kmax]" tel que la fonction a integrer soit "f(k) <= high"
 //   La recherche a lieu entre [kmin,kmax] par pas logarithmiques
 // Input:
-//     R : taille du filter top-hat ou gaussien
 //     kmin,kmax : intervalle de recherche
 //     eps : precision requise sur les valeurs kmin et kmax
@@ -615,10 +612,9 @@
 //     rc |= 4 "f(k) < high pour tout k"   (bit2 =1)
 {
-  if(R<=0. || kmin<=0 || kmax<=0. || kmin>=kmax  || eps<=0.) {
-    cout<<"VarianceSpectrum::FindLimits: Error R<=0 or kmin<=0 or kmax<=0 or kmin>=kmax or eps<=0"<<endl;
-    throw ParmError("VarianceSpectrum::FindLimits: Error R<=0 or kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0");
-  }
-
-  R_ = R;
+  if(kmin<=0 || kmax<=0. || kmin>=kmax  || eps<=0.) {
+    cout<<"VarianceSpectrum::FindLimits: Error kmin<=0 or kmax<=0 or kmin>=kmax or eps<=0"<<endl;
+    throw ParmError("VarianceSpectrum::FindLimits: Error kmin<=0 or kmax<=0 or kmin>=kmax || eps<=0");
+  }
+
   int n = 10; // toujours >2
 
Index: /trunk/Cosmo/SimLSS/pkspectrum.h
===================================================================
--- /trunk/Cosmo/SimLSS/pkspectrum.h	(revision 3347)
+++ /trunk/Cosmo/SimLSS/pkspectrum.h	(revision 3348)
@@ -23,4 +23,7 @@
 class TransfertEisenstein : public GenericFunc {
 public:
+
+  typedef enum{ALL=0, CDM=1, BARYON=2} ReturnPart;
+
   TransfertEisenstein(double h100,double OmegaCDM0,double OmegaBaryon0,double tcmb,bool nobaryon=false,int lp=0);
   TransfertEisenstein(TransfertEisenstein& tf);
@@ -29,5 +32,5 @@
   double KPeak(void);
   void SetNoOscEnv(unsigned short nooscenv=0);
-  void SetReturnPart(unsigned short retpart=0);
+  void SetReturnPart(ReturnPart retpart=ALL);
 protected:
   int lp_;
@@ -39,5 +42,6 @@
 
   bool nobaryon_;
-  unsigned short nooscenv_, retpart_;
+  unsigned short nooscenv_;
+  ReturnPart retpart_;
 
   double T0tild(double k,double alphac,double betac);
@@ -94,4 +98,5 @@
 class PkSpectrumZ : public GenericFunc {
 public:
+  typedef enum {PK=0, DELTA=1} ReturnSpectrum;
   PkSpectrumZ(PkSpectrum0& pk0,GrowthFactor& d1,double zref=0.);
   PkSpectrumZ(PkSpectrumZ& pkz);
@@ -101,5 +106,5 @@
   inline void   SetZ(double z) {zref_ = z;}
   inline double GetZ(void) {return zref_;}
-  void SetTypSpec(unsigned short typspec=0);
+  void SetTypSpec(ReturnSpectrum typspec=PK);
   inline void SetScale(double scale=1.) {scale_=scale; zold_=-1.;}
   inline double GetScale(void) {return scale_;}
@@ -110,5 +115,5 @@
   GrowthFactor& d1_;
   double zref_, scale_;
-  unsigned short typspec_;
+  ReturnSpectrum typspec_;
   mutable double zold_, d1old_;
 };
@@ -117,12 +122,16 @@
 class VarianceSpectrum : public GenericFunc {
 public:
-  VarianceSpectrum(GenericFunc& pk,unsigned short typfilter);
+
+  typedef enum {TOPHAT=0, GAUSSIAN=1, NOFILTER=2} TypeFilter;
+
+  VarianceSpectrum(GenericFunc& pk,double R,TypeFilter typfilter);
   VarianceSpectrum(VarianceSpectrum& pkinf);
   virtual ~VarianceSpectrum(void);
 
-  void SetFilter(unsigned short typfilter=0);
+  void SetRadius(double R);
+  void SetFilter(TypeFilter typfilter=TOPHAT);
   void SetInteg(double dperc=0.1,double dlogkinc=-1.,double dlogkmax=-1.,unsigned short glorder=4);
 
-  double Variance(double R,double kmin,double kmax);
+  double Variance(double kmin,double kmax);
 
   // ATTENTION: La fonction a integrer est : f(k)dk = k^3*Pk(k)/(2Pi^2) *filter2(k*R) *dk/k
@@ -131,11 +140,11 @@
 
   // Aide a l'integration
-  double FindMaximum(double R,double kmin,double kmax,double eps=1.e-3);
-  int FindLimits(double R,double high,double &kmin,double &kmax,double eps=1.e-3);
+  double FindMaximum(double kmin,double kmax,double eps=1.e-3);
+  int FindLimits(double high,double &kmin,double &kmax,double eps=1.e-3);
 
 protected:
 
   GenericFunc& pk_;
-  unsigned short typfilter_;
+  TypeFilter typfilter_;
   double R_;
 
