Changeset 3157 in Sophya for trunk/Cosmo/SimLSS


Ignore:
Timestamp:
Jan 25, 2007, 6:04:48 PM (19 years ago)
Author:
cmv
Message:

intro du facteur de croissance dans la simul cmv 25/01/2007

Location:
trunk/Cosmo/SimLSS
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Cosmo/SimLSS/Makefile

    r3141 r3157  
    1919       $(EXE)cmvtstsch $(EXE)cmvtstblack $(EXE)cmvtvarspec \
    2020       $(EXE)cmvdefsurv $(EXE)cmvobserv3d $(EXE)cmvtintfun \
    21        $(EXE)cmvtpoisson $(EXE)cmvconcherr
     21       $(EXE)cmvtpoisson $(EXE)cmvconcherr $(EXE)cmvtinterp
    2222#$(EXE)cmvtluc
    2323 
     
    2525          $(OBJ)cmvtuniv.o $(OBJ)cmvtransf.o $(OBJ)cmvtgrowth.o $(OBJ)cmvtstpk.o \
    2626          $(OBJ)cmvtstsch.o $(OBJ)cmvtstblack.o $(OBJ)cmvtvarspec.o $(OBJ)cmvdefsurv.o \
    27           $(OBJ)cmvobserv3d.o $(OBJ)cmvtintfun.o \
     27          $(OBJ)cmvobserv3d.o $(OBJ)cmvtintfun.o $(OBJ)cmvtinterp.o \
    2828          $(OBJ)cmvtpoisson.o $(OBJ)cmvconcherr.o $(OBJ)cmvtluc.o
    2929 
     
    165165
    166166##############################################################################
     167cmvtinterp: $(EXE)cmvtinterp
     168        echo $@ " done"
     169$(EXE)cmvtinterp: $(OBJ)cmvtinterp.o $(LIB)libcmvsimbao.a
     170        $(CXXLINK) $(CXXREP) -o $@ $(OBJ)cmvtinterp.o $(MYLIB)
     171$(OBJ)cmvtinterp.o: cmvtinterp.cc
     172        $(CXXCOMPILE) $(CXXREP) -I$(MYEXTINC) -o $@ cmvtinterp.cc
     173
     174##############################################################################
    167175cmvtluc: $(EXE)cmvtluc
    168176        echo $@ " done"
  • trunk/Cosmo/SimLSS/cmvobserv3d.cc

    r3155 r3157  
    1212
    1313#include "constcosmo.h"
     14#include "cosmocalc.h"
    1415#include "schechter.h"
    1516#include "geneutils.h"
     
    2324     <<" -a : init auto de l aleatoire"<<endl
    2425     <<" -0 : use methode ComputeFourier0"<<endl
     26     <<" -G : compute Pk(z=0) and apply growth factor in real space"<<endl
    2527     <<" -x nx,dx : taille en x (npix,Mpc)"<<endl
    2628     <<" -y ny,dy : taille en y (npix,Mpc)"<<endl
     
    4648
    4749 // *** Cosmography definition   (WMAP)
     50 unsigned short flat = 0;
    4851 double ob0 = 0.0444356;
    4952 double h100=0.71, om0=0.267804, or0=7.9e-05, ol0=0.73,w0=-1.;
    5053 double zref = 0.5;
     54 double perc=0.01,dzinc=-1.,dzmax=5.; unsigned short glorder=4;
    5155
    5256 // *** Spectrum and variance definition
     
    7579 // *** type de generation
    7680 bool computefourier0=false;
     81 bool use_growth_factor = false;
    7782 unsigned short nthread=4;
    7883
     
    8691
    8792 char c;
    88  while((c = getopt(narg,arg,"ha0PWV2x:y:z:s:Z:")) != -1) {
     93 while((c = getopt(narg,arg,"ha0PWV2Gx:y:z:s:Z:")) != -1) {
    8994  switch (c) {
    9095  case 'a' :
     
    9398  case '0' :
    9499    computefourier0 = true;
     100    break;
     101  case 'G' :
     102    use_growth_factor = true;
    95103    break;
    96104  case 'x' :
     
    142150
    143151 //-----------------------------------------------------------------
    144  cout<<endl<<"\n--- Create Spectrum and mass function"<<endl;
     152 cout<<endl<<"\n--- Create Cosmology"<<endl;
     153
     154 CosmoCalc univ(flat,true,zref+1.);
     155 univ.SetInteg(perc,dzinc,dzmax,glorder);
     156 univ.SetDynParam(h100,om0,or0,ol0,w0);
     157 univ.Print();
     158 double loscomref = univ.Dloscom(zref);
     159 cout<<"zref = "<<zref<<" -> dloscom = "<<loscomref<<" Mpc"<<endl;
     160
     161 //-----------------------------------------------------------------
     162  cout<<endl<<"\n--- Create Spectrum and mass function"<<endl;
    145163
    146164 InitialSpectrum pkini(ns,as);
     
    149167 //tf.SetNoOscEnv(2);
    150168
    151  GrowthFactor d1(om0,ol0);
     169 GrowthFactor growth(om0,ol0);
    152170
    153171 PkSpectrum0 pk0(pkini,tf);
    154172
    155  PkSpectrumZ pkz(pk0,d1,zref);
     173 PkSpectrumZ pkz(pk0,growth,zref);
    156174 
    157175 Schechter sch(nstar,mstar,alpha);
     
    223241 cout<<endl<<"\n--- Initialisation de GeneFluct3D"<<endl;
    224242
    225  pkz.SetZ(zref);
    226243 TArray< complex<r_8> > pkgen;
    227244 GeneFluct3D fluct3d(pkgen);
     
    229246 fluct3d.SetNThread(nthread);
    230247 fluct3d.SetSize(nx,ny,nz,dx,dy,dz);
     248 fluct3d.SetObservator(zref,nz/2.);
     249 fluct3d.SetCosmology(univ);
     250 fluct3d.SetGrowthFactor(growth);
     251 fluct3d.LosComRedshift(0.001);
    231252 TArray<r_8>& rgen = fluct3d.GetRealArray();
    232  fluct3d.Print();
     253 cout<<endl; fluct3d.Print();
    233254
    234255 double dkmin = fluct3d.GetKincMin();
     
    246267     <<" max="<<ktnyqmax<<","<<kznyqmax<<" n="<<nherrt<<","<<nherrz<<endl;
    247268
     269 //-----------------------------------------------------------------
    248270 cout<<"\n--- Computing spectra variance up to Kmax at z="<<pkz.GetZ()<<endl;
    249271 // En fait on travaille sur un cube inscrit dans la sphere de rayon kmax:
     
    258280 PrtTim(">>>> End Initialisation de GeneFluct3D");
    259281
     282 //-----------------------------------------------------------------
    260283 cout<<"\n--- Computing a realization in Fourier space"<<endl;
     284 if(use_growth_factor) pkz.SetZ(0.); else pkz.SetZ(zref);
     285 cout<<"Power spectrum set at redshift: "<<pkz.GetZ()<<endl;
    261286 if(computefourier0) fluct3d.ComputeFourier0(pkz);
    262287   else              fluct3d.ComputeFourier(pkz);
     
    326351 }
    327352
     353 //-----------------------------------------------------------------
    328354 cout<<"\n--- Computing a realization in real space"<<endl;
    329355 fluct3d.ComputeReal();
    330356 double rmin,rmax; rgen.MinMax(rmin,rmax);
    331357 cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
    332    PrtTim(">>>> End Computing a realization in real space");
     358 PrtTim(">>>> End Computing a realization in real space");
     359
     360 if(use_growth_factor) {
     361   cout<<"\n--- Apply Growth factor"<<endl;
     362   cout<<"...D(z=0)="<<growth(0.)<<"  D(z="<<zref<<")="<<growth(zref)<<endl;
     363   fluct3d.ApplyGrowthFactor(-1);
     364   rmin,rmax; rgen.MinMax(rmin,rmax);
     365   cout<<"rgen.Min = "<<rmin<<" , Max="<<rmax<<endl;
     366   PrtTim(">>>> End Applying growth factor");
     367 }
    333368
    334369 if(wfits) {
  • trunk/Cosmo/SimLSS/genefluct3d.cc

    r3155 r3157  
    3232GeneFluct3D::GeneFluct3D(TArray< complex<r_8 > >& T)
    3333  : T_(T) , Nx_(0) , Ny_(0) , Nz_(0) , array_allocated_(false) , lp_(0)
    34   , redshref_(-999.) , kredshref_(-999.)
    35 {
     34  , redshref_(-999.) , kredshref_(0.) , cosmo_(NULL) , growth_(NULL)
     35  , loscom_ref_(-999.), loscom_min_(-999.), loscom_max_(-999.)
     36
     37
     38{
     39 xobs_[0] = xobs_[1] = xobs_[2] = 0.;
     40 zred_.resize(0);
     41 loscom_.resize(0);
    3642 SetNThread();
    3743}
     
    6470//     kredshref = indice (en double) correspondant a ce redshift
    6571//                 Si kredshref<0 alors kredshref=0
     72// Exemple: redshref=1.5 kredshref=250.75
     73//    -> Le pixel i=nx/2 j=ny/2 k=250.75 est au redshift 1.5
    6674{
    6775 if(redshref<0.) redshref = 0.;
    6876 if(kredshref<0.) kredshref = 0.;
    69  redshref_ = redshref;
     77 redshref_  = redshref;
    7078 kredshref_ = kredshref;
     79}
     80
     81void GeneFluct3D::SetCosmology(CosmoCalc& cosmo)
     82{
     83 cosmo_ = &cosmo;
     84 if(lp_>1) cosmo_->Print();
     85}
     86
     87void GeneFluct3D::SetGrowthFactor(GrowthFactor& growth)
     88{
     89 growth_ = &growth;
    7190}
    7291
     
    164183}
    165184
     185//-------------------------------------------------------
     186long GeneFluct3D::LosComRedshift(double zinc)
     187// Given a position of the cube relative to the observer
     188// and a cosmology
     189// (SetObservator() and SetCosmology() should have been called !)
     190// This routine filled:
     191//   the vector "zred_" of scanned redshift (by zinc increments)
     192//   the vector "loscom_" of corresponding los comoving distance
     193//
     194{
     195 if(zinc<=0.) zinc = 0.01;
     196 if(lp_>0) cout<<"--- LosComRedshift: zinc="<<zinc<<endl;
     197
     198 if(cosmo_ == NULL || redshref_<0.) {
     199   cout<<"GeneFluct3D::LosComRedshift_Error: set Observator and Cosmology first"<<endl;
     200   throw ParmError("");
     201 }
     202
     203 // On calcule les coordonnees de l'observateur
     204 // Il est sur un axe centre sur le milieu de la face Oxy
     205 double loscom_ref_ = cosmo_->Dloscom(redshref_);
     206 xobs_[0] = Nx_/2.*Dx_;
     207 xobs_[1] = Ny_/2.*Dy_;
     208 xobs_[2] = kredshref_*Dz_ - loscom_ref_;
     209
     210 // L'observateur est-il dans le cube?
     211 bool obs_in_cube = false;
     212 if(xobs_[2]>=0. && xobs_[2]<=Nz_*Dz_) obs_in_cube = true;
     213
     214 // Find MINIMUM los com distance to the observer:
     215 // c'est le centre de la face a k=0
     216 // (ou zero si l'observateur est dans le cube)
     217 loscom_min_ = 0.;
     218 if(!obs_in_cube) loscom_min_ = -xobs_[2];
     219
     220 // Find MAXIMUM los com distance to the observer:
     221 // ou que soit positionne l'observateur, la distance
     222 // maximal est sur un des coins du cube
     223 loscom_max_ = 0.;
     224 for(long i=0;i<=1;i++) {
     225   double dx2 = xobs_[0] - i*Nx_*Dx_; dx2 *= dx2;
     226   for(long j=0;j<=1;j++) {
     227     double dy2 = xobs_[1] - j*Ny_*Dy_; dy2 *= dy2;
     228     for(long k=0;k<=1;k++) {
     229       double dz2 = xobs_[2] - k*Nz_*Dz_; dz2 *= dz2;
     230       dz2 = sqrt(dx2+dy2+dz2);
     231       if(dz2>loscom_max_) loscom_max_ = dz2;
     232     }
     233   }
     234 }
     235 if(lp_>0) {
     236   cout<<"...zref="<<redshref_<<" kzref="<<kredshref_<<" losref="<<loscom_ref_<<" Mpc\n"
     237       <<"   xobs="<<xobs_[0]<<" , "<<xobs_[1]<<" , "<<xobs_[2]<<" Mpc "
     238       <<" in_cube="<<obs_in_cube
     239       <<" loscom_min="<<loscom_min_<<" loscom_max="<<loscom_max_<<" Mpc "<<endl;
     240 }
     241
     242 // Fill the corresponding vectors
     243 for(double z=0.; ; z+=zinc) {
     244   double dlc = cosmo_->Dloscom(z);
     245   if(dlc<loscom_min_) {zred_.resize(0); loscom_.resize(0);}
     246   zred_.push_back(z);
     247   loscom_.push_back(dlc);
     248   z += zinc;
     249   if(dlc>loscom_max_) break; // on break apres avoir stoque un dlc>dlcmax
     250 }
     251
     252 long n = zred_.size();
     253 if(lp_>0) {
     254   cout<<"...n="<<n;
     255   if(n>0) cout<<" z="<<zred_[0]<<" -> d="<<loscom_[0];
     256   if(n>1) cout<<" , z="<<zred_[n-1]<<" -> d="<<loscom_[n-1];
     257   cout<<endl;
     258 }
     259
     260 return n;
     261}
    166262
    167263//-------------------------------------------------------
     
    323419
    324420 // --- On remplit avec une realisation
    325  if(lp_>0) cout<<"...before Fourier realization filling ---"<<endl;
     421 if(lp_>0) cout<<"...before Fourier realization filling"<<endl;
    326422 T_(0,0,0) = complex<r_8>(0.);  // on coupe le continue et on l'initialise
    327423 long lmod = Nx_/10; if(lmod<1) lmod=1;
     
    529625
    530626//-------------------------------------------------------------------
     627void GeneFluct3D::ApplyGrowthFactor(long npoints)
     628// Apply Growth to real space
     629// Using the correspondance between redshift and los comoving distance
     630// describe in vector "zred_" "loscom_"
     631{
     632 if(npoints<3) npoints = zred_.size();
     633 if(lp_>0) cout<<"--- ApplyGrowthFactor ---  npoints="<<npoints<<endl;
     634 check_array_alloc();
     635
     636 if(growth_ == NULL) {
     637   cout<<"GeneFluct3D::ApplyGrowthFactor_Error: set GrowthFactor first"<<endl;
     638   throw ParmError("GeneFluct3D::ApplyGrowthFactor_Error: set GrowthFactor first");
     639 }
     640
     641 long n = zred_.size();
     642 InverseFunc invfun(zred_,loscom_);
     643 vector<double> invlos;
     644 invfun.ComputeParab(npoints,invlos);
     645
     646 InterpFunc interpinv(invfun.YMin(),invfun.YMax(),invlos);
     647 unsigned short ok;
     648
     649 //CHECK: Histo hgr(0.9*zred_[0],1.1*zred_[n-1],1000);
     650 for(long i=0;i<Nx_;i++) {
     651   double dx2 = xobs_[0] - i*Dx_; dx2 *= dx2;
     652   for(long j=0;j<Ny_;j++) {
     653     double dy2 = xobs_[1] - j*Dy_; dy2 *= dy2;
     654     for(long l=0;l<Nz_;l++) {
     655       double dz2 = xobs_[2] - l*Dz_; dz2 *= dz2;
     656       dz2 = sqrt(dx2+dy2+dz2);
     657       double z = interpinv(dz2);
     658       //CHECK: hgr.Add(z);
     659       double dzgr = (*growth_)(z);   // interpolation par morceau
     660       //double dzgr = growth_->Linear(z,ok);  // interpolation lineaire
     661       //double dzgr = growth_->Parab(z,ok);  // interpolation parabolique
     662       int_8 ip = IndexR(i,j,l);
     663       data_[ip] *= dzgr;
     664     }
     665   }
     666 }
     667
     668 //CHECK: {POutPersist pos("applygrowth.ppf"); string tag="hgr"; pos.PutObject(hgr,tag);}
     669
     670}
     671
     672//-------------------------------------------------------------------
    531673void GeneFluct3D::ComputeReal(void)
    532674// Calcule une realisation dans l'espace reel
  • trunk/Cosmo/SimLSS/genefluct3d.h

    r3154 r3157  
    1414#include <vector>
    1515
     16#include "cosmocalc.h"
    1617#include "pkspectrum.h"
    1718
     
    2728  void SetNThread(unsigned short nthread=0) {nthread_ = nthread;}
    2829  void SetSize(long nx,long ny,long nz,double dx,double dy,double dz);  // Mpc
    29   void SetObservator(double redshref=0.,double kredshref=-1.);
     30  void SetObservator(double redshref=0.,double kredshref=0.);
     31  void SetCosmology(CosmoCalc& cosmo);
     32  void SetGrowthFactor(GrowthFactor& growth);
     33  long LosComRedshift(double zinc=0.001);
    3034
    3135  TArray< complex<r_8> >& GetComplexArray(void) {return T_;}
     
    6771  int  ComputeSpectrum(HistoErr& herr);
    6872  int  ComputeSpectrum2D(Histo2DErr& herr);
     73  void ApplyGrowthFactor(long npoints=-1);
    6974
    7075  int_8 VarianceFrReal(double R,double& var);
     
    127132  // l'observateur
    128133  double redshref_,kredshref_;
     134  CosmoCalc *cosmo_;
     135  GrowthFactor *growth_;
     136  double xobs_[3];
     137  double loscom_ref_, loscom_min_, loscom_max_;
     138  vector<double> zred_, loscom_;
    129139};
    130140
  • trunk/Cosmo/SimLSS/geneutils.cc

    r3115 r3157  
    1919// Classe d'interpolation lineaire:
    2020// Le vecteur y a n elements y_i tels que y_i = f(x_i)
    21 // Les x_i sont regulierement espaces
    22 //   et x_0=xmin et x_{n-1}=xmax
     21//   ou les x_i sont regulierement espaces
     22//   et x_0=xmin et x_{n-1}=xmax   (xmax inclus!)
    2323InterpFunc::InterpFunc(double xmin,double xmax,vector<double>& y)
    2424  : _xmin(xmin), _xmax(xmax), _y(y)
     
    2929  }
    3030  _nm1   = _y.size()-1;
    31   _xlarg = _xmax-_xmin;
    32   _dx    = _xlarg/(double)_nm1;
     31  _dx    = (_xmax-_xmin)/(double)_nm1;
    3332}
    3433
     
    3736  ok=0; if(x<_xmin) ok=1; else if(x>_xmax) ok=2;
    3837  x -= _xmin;
    39   long i = long(x/_xlarg*_nm1);  // On prend le "i" juste en dessous
     38  long i = long(x/_dx);  // On prend le "i" juste en dessous
    4039  if(i<0) i=0; else if(i>=_nm1) i=_nm1-1;
    4140  return _y[i] + (_y[i+1]-_y[i])/_dx*(x-i*_dx);
     
    4645  ok=0; if(x<_xmin) ok=1; else if(x>_xmax) ok=2;
    4746  x -= _xmin;
    48   long i = long(x/_xlarg*_nm1+0.5);  // On prend le "i" le + proche
     47  long i = long(x/_dx+0.5);  // On prend le "i" le + proche
    4948  if(i<1) i=1; else if(i>=_nm1-1) i=_nm1-2;
    5049  double a = (_y[i+1]-2.*_y[i]+_y[i-1])/(2.*_dx*_dx);
    5150  double b = (_y[i+1]-_y[i-1])/(2.*_dx);
    5251  return _y[i] + (x-i*_dx)*(a*(x-i*_dx)+b);
     52}
     53
     54//-------------------------------------------------------------------
     55// Classe d'inversion d'une fonction STRICTEMENT MONOTONE CROISSANTE
     56// - Le vecteur y a "Nin" elements y_i tels que "y_i = f(x_i)"
     57// - On a x(i) < x(i+1) et y(i) < y(i+1)
     58// - La classe renvoie ymin=y(0) , ymax=y(Nin -1)
     59//   et le vecteur x = f^-1(y) de "Nout" elements
     60//   Les y_i sont regulierement espaces et ymin et ymax
     61//   La re-interpolation inverse est faite par lineaire
     62InverseFunc::InverseFunc(vector<double>& x,vector<double>& y)
     63  : _ymin(0.) , _ymax(0.) , _x(x) , _y(y)
     64{
     65  int_4 ns = _x.size();
     66  if(ns<3 || _y.size()<=0 || ns!=_y.size())
     67    throw ParmError("InverseFunc::InverseFunc_Error: bad array size");
     68
     69  // Check "x" strictement monotone croissant
     70  for(int_4 i=0;i<ns-1;i++)
     71    if(_x[i+1]<=_x[i]) {
     72      cout<<"InverseFunc::InverseFunc_Error: _x array not stricly growing"<<endl;
     73      throw ParmError("InverseFunc::InverseFunc_Error: _x array not stricly growing");
     74    }
     75
     76  // Check "y" monotone croissant
     77  for(int_4 i=0;i<ns-1;i++)
     78    if(_y[i+1]<_y[i]) {
     79      cout<<"InverseFunc::InverseFunc_Error: _y array not growing"<<endl;
     80      throw ParmError("InverseFunc::InverseFunc_Error: _y array not growing");
     81    }
     82
     83  // define limits
     84  _ymin = _y[0];
     85  _ymax = _y[ns-1];
     86
     87}
     88
     89InverseFunc::~InverseFunc(void)
     90{
     91}
     92
     93int InverseFunc::ComputeLinear(long n,vector<double>& xfcty)
     94{
     95  if(n<3) return -1;
     96
     97  xfcty.resize(n);
     98
     99  long i1,i2;
     100  double x;
     101  for(int_4 i=0;i<n;i++) {
     102    double y = _ymin + i*(_ymax-_ymin)/(n-1.);
     103    find_in_y(y,i1,i2);
     104    double dy = _y[i2]-_y[i1];
     105    if(dy==0.) {
     106      x = (_x[i2]+_x[i1])/2.; // la fct a inverser est plate!
     107    } else {
     108      x = _x[i1] + (_x[i2]-_x[i1])/dy * (y-_y[i1]);
     109    }
     110    xfcty[i] = x;
     111  }
     112
     113  return 0;
     114}
     115
     116int InverseFunc::ComputeParab(long n,vector<double>& xfcty)
     117{
     118  if(n<3) return -1;
     119
     120  xfcty.resize(n);
     121
     122  long i1,i2,i3;
     123  double x;
     124  for(int_4 i=0;i<n;i++) {
     125    double y = _ymin + i*(_ymax-_ymin)/(n-1.);
     126    find_in_y(y,i1,i2);
     127    // On cherche le 3ieme point selon la position de y / au 2 premiers
     128    double my = (_y[i1]+_y[i2])/2.;
     129    if(y<my) {i3=i2; i2=i1; i1--;} else {i3=i2+1;}
     130    // Protection
     131    if(i1<0) {i1++; i2++; i3++;}
     132    if(i3==_y.size()) {i1--; i2--; i3--;}
     133    // Interpolation parabolique
     134    double dy = _y[i3]-_y[i1];
     135    if(dy==0.) {
     136      x = (_x[i3]+_x[i1])/2.; // la fct a inverser est plate!
     137    } else {
     138      double X1=_x[i1]-_x[i2], X3=_x[i3]-_x[i2];
     139      double Y1=_y[i1]-_y[i2], Y3=_y[i3]-_y[i2];
     140      double den = Y1*Y3*dy;
     141      double a = (X3*Y1-X1*Y3)/den;
     142      double b = (X1*Y3*Y3-X3*Y1*Y1)/den;
     143      y -= _y[i2];
     144      x = (a*y+b)*y + _x[i2];
     145    }
     146    xfcty[i] = x;
     147  }
     148
     149  return 0;
    53150}
    54151
  • trunk/Cosmo/SimLSS/geneutils.h

    r3120 r3157  
    77#include "histos.h"
    88#include "tvector.h"
     9#include "cspline.h"
    910
    1011#include <vector>
     
    1213namespace SOPHYA {
    1314
     15//----------------------------------------------------
    1416class InterpFunc {
    1517public:
     
    1921  double XMin(void) {return _xmin;}
    2022  double XMax(void) {return _xmax;}
     23  inline double X(long i) {return _xmin + i*_dx;}
    2124
    2225  //! Retourne l'element le plus proche de f donnant y=f(x)
     
    2427         {
    2528         x -= _xmin;
    26          long i = long(x/_xlarg*_nm1+0.5);  // On prend le "i" le plus proche
     29         long i = long(x/_dx+0.5);  // On prend le "i" le plus proche
    2730         if(i<0) i=0; else if(i>=_nm1) i=_nm1-1;
    2831         return _y[i];
     
    4346
    4447protected:
    45   double _xmin,_xmax,_xlarg,_dx;
     48  double _xmin,_xmax,_dx;
     49  long _nm1;  // n-1
    4650  vector<double>& _y;
    47   long _nm1;  // n-1
     51};
     52
     53//----------------------------------------------------
     54class InverseFunc {
     55public:
     56  InverseFunc(vector<double>& x,vector<double>& y);
     57  virtual ~InverseFunc(void);
     58  int ComputeLinear(long n,vector<double>& xfcty);
     59  int ComputeParab(long n,vector<double>& xfcty);
     60  double YMin(void) {return _ymin;}
     61  double YMax(void) {return _ymax;}
     62protected:
     63  inline void find_in_y(double x,long& klo,long& khi)
     64    {
     65      long k;
     66      klo=0, khi=_y.size()-1;
     67      while (khi-klo > 1) {
     68        k = (khi+klo) >> 1;
     69        if (_y[k] > x) khi=k; else klo=k;
     70      }
     71    }
     72
     73  vector<double>& _x;
     74  vector<double>& _y;
     75  double _ymin,_ymax,_dy;
    4876};
    4977
    5078}
    5179
     80//----------------------------------------------------
    5281int FuncToHisto(GenericFunc& func,Histo& h,bool logaxex=false);
    5382int FuncToVec(GenericFunc& func,TVector<r_8>& h,double xmin,double xmax,bool logaxex=false);
    5483
     84//----------------------------------------------------
    5585double AngSol(double dtheta,double dphi,double theta0=M_PI/2.);
    5686double AngSol(double dtheta);
    5787
     88//----------------------------------------------------
    5889unsigned long PoissRandLimit(double mu,double mumax=10.);
    5990
Note: See TracChangeset for help on using the changeset viewer.