Example #1
0
/*****************
 * DIFFERENT HOD PARAMETERIZATIONS: (1) Central galaxies
 *
 * This integer HOD.pdfc controls the parameterization of the central occupation.
 * (I realize 'pdf' is not the right acronym, but it's a holdover from old code.)
 *
 * For soft central cutoffs, the PDF is the nearest integer distribution, AKA
 * Bernoulli distribution.
 *
 * 0 = No galaxies, just halos. (always returns 1)
 * 1 = Hard cutoff at M_min. Unity above M_min. (DEFAULT)
 * 2 = Soft cutoff of the form 0.5*(1+erf((log10(m) - log10(HOD.M_min))/HOD.sigma_logM)
 * 3 = Soft cutoff of the form N_cen = exp(-HOD.M_min/m)
 * 4 = Hard cutoff, but N_cen -> 0 for M>M_min (i.e., blue galaxies) 
 *      MaxCen*exp(-(lgM-lgM_min)**2/2/(sigma_logM)**2)
 *      NB! -> The value of N_cen(M_min) can be < 1. (It will== MaxCen)
 * 5 = Hard Cutoff, Step function, but N_cen != 1, but some number < 1.
 * 6 = Same as 4, but symmetric Gaussian around M_min (This is for mag bins.)
 * 7 = A sqaure function. N_cen=1 for M_min <= m <= M_cen_max (for mag bin data)
 * 8 = A sqaure function (like case 7) but with Gaussian cutoffs on either edge
 *      instead of sharp cutoffs.
 *
 * 9 = Magnitude bin model, but the upper mass cutoff is defined by the lower
 *      mass cutoff of the next-highest bin. (see function in ml_minimization.c)
 *
 * M_low is a parameter created to keep the integrals from having to go to M=0 for
 * soft central cutoffs. N_cen(mlow) = 1.0E-3;
 * If the value of sigma_logM gets above 1 or so, then M_low can be rediculously 
 * small, so I have placed a lower limit on M_low of 1.0E+7 Msol/h
 */
double N_cen(double m)
{
  double x,f=1;

  //return(one_halo_from_file(m));

  if(HOD.color)
    f=central_blue_fraction(m);

  f = HOD.fredc;

  switch(HOD.pdfc) {
  case -1:
    return 0;
  case 0:
    return 1;
  case 1: 
    if(m<HOD.M_min)return(0);
    return(f*1.0);
    break;
  case 2:
    //return((1-0.3*0.5)*HOD.MaxCen*0.5*(1+erf((log10(m) - log10(HOD.M_min))/HOD.sigma_logM)));
    return(f*HOD.MaxCen*0.5*(1+erf((log10(m) - log10(HOD.M_min))/HOD.sigma_logM)));
    break;
  case 3:
    return(f*exp(-HOD.M_min/m));
    break;
  case 4:
    if(m<HOD.M_min)return(0);
    x = (log10(m) - log10(HOD.M_min))/HOD.sigma_logM;
    return(f*HOD.MaxCen*exp(-x*x/2));
  case 5:
    if(m<HOD.M_min)return(0);
    return(f*HOD.MaxCen);
  case 6:
    x = (log10(m) - log10(HOD.M_min))/HOD.sigma_logM;
    return(f*HOD.MaxCen*exp(-x*x/2));    
  case 7:
    if(m>=HOD.M_min && m<=HOD.M_cen_max)return(f);
    return(0);
  case 8:
    if(m>=HOD.M_min && m<=HOD.M_cen_max)return(f);
    if(m<HOD.M_low)return(0);
    if(m<HOD.M_min)
      x = (log10(m) - log10(HOD.M_min))/HOD.sigma_logM;
    else
      x = (log10(m) - log10(HOD.M_cen_max))/HOD.sigma_logM;
    return(f*exp(-x*x/2));    
  case 9:
    return(f*N_cen_i(m,HOD.i_wp));
  case 10: // for DRGs
    if(m<HOD.M_min)return 0;
    return(f*exp(-HOD.M_min*HOD.mass_shift/(m-HOD.M_min)));
    //return(f*exp(-pow(HOD.M_min*HOD.mass_shift/(m-HOD.M_min),HOD.shift_alpha)));
    break;
  case 11: // for 1-DRGs
    if(m<HOD.M_min)return 0;
    return 1 - (f*exp(-HOD.M_min*HOD.mass_shift/(m-HOD.M_min)));
    break;
  case 12:  //additional parameter to cover high-scatter cases
    //Set MaxCen=0.05 to reduce number of parameters
    x = f*0.5*(1+erf((log10(m) - log10(HOD.M_min))/HOD.sigma_logM))*
           (1.+HOD.MaxCen*log(m/HOD.M_cen_lin));   
    if(x>1) return 1.;
    if(x<0) return 0.;
    return x;
    break;
  case 13:  //Alternative general variant that fits Emeralda better
    if (m <= HOD.M_cen_lin) {
      x = 0.5*(1+erf((log10(m) - log10(HOD.M_min))/HOD.sigma_logM))*HOD.MaxCen;
    } else {
      double a, k;
      k = 0.5*(1+erf((log10(HOD.M_cen_lin) - log10(HOD.M_min))/HOD.sigma_logM));
      a = 1./HOD.sigma_logM/k/sqrt(PI)/log(10)*
	exp(-log10(HOD.M_cen_lin/HOD.M_min)*log10(HOD.M_cen_lin/HOD.M_min)
	    /HOD.sigma_logM/HOD.sigma_logM);
      x = k*HOD.MaxCen*pow(m/HOD.M_cen_lin,a);
    }
    if(x>1) return 1;
    return x;
    break;
  case 14:  //variant for testing with a sharp cutoff in mass but Ncen!=1
    if (m <= HOD.M_min) return 0;
    x = HOD.MaxCen*pow(m/HOD.M_min,HOD.M_cen_lin);
    if (x > 1) return 1;
    return x;
    break;
  case 101: 
    if(m<HOD.M_min)return 0;
    x = pow(m/HOD.M1,HOD.alpha);
    if(x>1)return 1;
    return x;
  default:
    endrun("Illegal value of HOD.pdfc.");
  }
  return 0;
}
/*****************
 * DIFFERENT HOD PARAMETERIZATIONS: (1) Central galaxies
 *
 * This integer HOD.pdfc controls the parameterization of the central occupation.
 * (I realize 'pdf' is not the right acronym, but it's a holdover from old code.)
 *
 * For soft central cutoffs, the PDF is the nearest integer distribution, AKA
 * Bernoulli distribution.
 *
 * 0 = No galaxies, just halos. (always returns 1)
 * 1 = Hard cutoff at M_min. Unity above M_min. (DEFAULT)
 * 2 = Soft cutoff of the form 0.5*(1+erf((log10(m) - log10(HOD.M_min))/HOD.sigma_logM)
 * 3 = Soft cutoff of the form N_cen = exp(-HOD.M_min/m)
 * 4 = Hard cutoff, but N_cen -> 0 for M>M_min (i.e., blue galaxies) 
 *      MaxCen*exp(-(lgM-lgM_min)**2/2/(sigma_logM)**2)
 *      NB! -> The value of N_cen(M_min) can be < 1. (It will== MaxCen)
 * 5 = Hard Cutoff, Step function, but N_cen != 1, but some number < 1.
 * 6 = Same as 4, but symmetric Gaussian around M_min (This is for mag bins.)
 * 7 = A sqaure function. N_cen=1 for M_min <= m <= M_cen_max (for mag bin data)
 * 8 = A sqaure function (like case 7) but with Gaussian cutoffs on either edge
 *      instead of sharp cutoffs.
 *
 * 9 = Magnitude bin model, but the upper mass cutoff is defined by the lower
 *      mass cutoff of the next-highest bin. (see function in ml_minimization.c)
 *
 * M_low is a parameter created to keep the integrals from having to go to M=0 for
 * soft central cutoffs. N_cen(mlow) = 1.0E-3;
 * If the value of sigma_logM gets above 1 or so, then M_low can be rediculously 
 * small, so I have placed a lower limit on M_low of 1.0E+7 Msol/h
 */
double N_cen(double m)
{
  double x,f=1;

  //return(one_halo_from_file(m));

  if(HOD.color)
    f=central_blue_fraction(m);

  f = HOD.fredc;

  switch(HOD.pdfc) {
  case -1:
    return 0;
  case 0:
    return 1;
  case 1: 
    if(m<HOD.M_min)return(0);
    return(f*1.0);
    break;
  case 2:
    //return((1-0.3*0.5)*HOD.MaxCen*0.5*(1+erf((log10(m) - log10(HOD.M_min))/HOD.sigma_logM)));
    return(f*HOD.MaxCen*0.5*(1+erf((log10(m) - log10(HOD.M_min))/HOD.sigma_logM)));
    break;
  case 3:
    return(f*exp(-HOD.M_min/m));
    break;
  case 4:
    if(m<HOD.M_min)return(0);
    x = (log10(m) - log10(HOD.M_min))/HOD.sigma_logM;
    return(f*HOD.MaxCen*exp(-x*x/2));
  case 5:
    if(m<HOD.M_min)return(0);
    return(f*HOD.MaxCen);
  case 6:
    x = (log10(m) - log10(HOD.M_min))/HOD.sigma_logM;
    return(f*HOD.MaxCen*exp(-x*x/2));    
  case 7:
    if(m>=HOD.M_min && m<=HOD.M_cen_max)return(f);
    return(0);
  case 8:
    if(m>=HOD.M_min && m<=HOD.M_cen_max)return(f);
    if(m<HOD.M_low)return(0);
    if(m<HOD.M_min)
      x = (log10(m) - log10(HOD.M_min))/HOD.sigma_logM;
    else
      x = (log10(m) - log10(HOD.M_cen_max))/HOD.sigma_logM;
    return(f*exp(-x*x/2));    
  case 10: // for DRGs
    if(m<HOD.M_min)return 0;
    return(f*exp(-HOD.M_min*HOD.mass_shift/(m-HOD.M_min)));
    //return(f*exp(-pow(HOD.M_min*HOD.mass_shift/(m-HOD.M_min),HOD.shift_alpha)));
    break;
  case 11: // for 1-DRGs
    if(m<HOD.M_min)return 0;
    return 1 - (f*exp(-HOD.M_min*HOD.mass_shift/(m-HOD.M_min)));
    break;

  case 20: // for DRGs
    if(m<HOD.M_min*HOD.mshift2)return 0;
    return(f*exp(-HOD.M_min*HOD.mass_shift*HOD.mshift2/(m-HOD.M_min*HOD.mshift2)));
    //return(f*exp(-pow(HOD.M_min*HOD.mass_shift/(m-HOD.M_min),HOD.shift_alpha)));
    break;
  case 21: // for 1-DRGs
    if(m<HOD.M_min)return 0;
    if(m<HOD.M_min*HOD.mshift2)return 1;
    return 1 - (f*exp(-HOD.M_min*HOD.mass_shift*HOD.mshift2/(m-HOD.M_min*HOD.mshift2)));
    break;

  case 101:
    return Ncen_xigm(m);
    break;
  default:
    endrun("Illegal value of HOD.pdfc.");
  }
  return 0;
}