CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
Modelling_NumberCounts2D_RedshiftMass.cpp
Go to the documentation of this file.
1 /********************************************************************
2  * Copyright (C) 2016 by Federico Marulli and Alfonso Veropalumbo *
3  * federico.marulli3@unibo.it *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License as *
7  * published by the Free Software Foundation; either version 2 of *
8  * the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public *
16  * License along with this program; if not, write to the Free *
17  * Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ********************************************************************/
20 
39 
40 using namespace std;
41 
42 using namespace cbl;
43 
44 using namespace modelling::numbercounts;
45 
46 
47 // ===========================================================================================
48 
49 
50 void cbl::modelling::numbercounts::Modelling_NumberCounts2D_RedshiftMass::set_model_NumberCounts_cosmology (const std::vector<cbl::cosmology::CosmologicalParameter> cosmo_param, const std::vector<statistics::PriorDistribution> cosmo_param_prior)
51 {
52  std::vector<cbl::cosmology::CosmologicalParameter> param = cosmo_param;
53 
54  // check if sigma8 is a free parameter
55  if (find(param.begin(), param.end(), cosmology::CosmologicalParameter::_sigma8_)!=param.end())
56  m_data_model.is_sigma8_free = true;
57 
58  if (!m_data_model.is_sigma8_free)
59  param.push_back(cosmology::CosmologicalParameter::_sigma8_);
60 
61  m_data_model.Cpar = param;
62 
63  const size_t nParams = param.size();
64  checkDim(param, nParams, "cosmoPar_prior");
65 
66  vector<statistics::ParameterType> cosmoPar_type((m_data_model.is_sigma8_free) ? nParams : nParams-1, statistics::ParameterType::_Base_);
67  if (!m_data_model.is_sigma8_free)
68  cosmoPar_type.push_back(statistics::ParameterType::_Derived_);
69 
70  vector<string> cosmoPar_string(nParams);
71 
72  for (size_t i=0; i<nParams; i++)
73  cosmoPar_string[i] = CosmologicalParameter_name(param[i]);
74 
75  // input data used to construct the model
76  auto inputs = make_shared<STR_NC_data_model>(m_data_model);
77 
78  // set prior
79  m_set_prior(cosmo_param_prior);
80 
81  // construct the model
82  switch (m_HistogramType) {
83  case (glob::HistogramType::_N_V_):
84  m_model = make_shared<statistics::Model2D>(statistics::Model2D(&number_counts_redshift_mass, nParams, cosmoPar_type, cosmoPar_string, inputs));
85  break;
86  case (glob::HistogramType::_n_V_):
87  m_model = make_shared<statistics::Model2D>(statistics::Model2D(&number_density_redshift_mass, nParams, cosmoPar_type, cosmoPar_string, inputs));
88  break;
89  case (glob::HistogramType::_dn_dV_):
90  m_model = make_shared<statistics::Model2D>(statistics::Model2D(&mass_function_redshift_mass, nParams, cosmoPar_type, cosmoPar_string, inputs));
91  break;
92  default:
93  ErrorCBL("no such a variable in the list!", "set_model_NumberCounts_cosmology", "Modelling_NumberCounts2D_RedshiftMass.cpp");
94  }
95 }
Global functions to model number counts.
The class Modelling_NumberCounts2D_RedshiftMass.
void set_model_NumberCounts_cosmology(const std::vector< cbl::cosmology::CosmologicalParameter > cosmo_param={}, const std::vector< statistics::PriorDistribution > cosmo_param_prior={})
set the cosmological parameters used to model the mass function
The class Model2D.
Definition: Model2D.h:60
std::string CosmologicalParameter_name(const CosmologicalParameter parameter)
name of the cosmological parameter
Definition: Cosmology.cpp:45
std::vector< std::vector< double > > mass_function_redshift_mass(const std::vector< double > redshift, const std::vector< double > mass, const std::shared_ptr< void > inputs, std::vector< double > &parameter)
compute the mass function as a function of the mass and redshift
std::vector< std::vector< double > > number_counts_redshift_mass(const std::vector< double > redshift, const std::vector< double > mass, const std::shared_ptr< void > inputs, std::vector< double > &parameter)
compute the number counts as a function of the mass and redshift
std::vector< std::vector< double > > number_density_redshift_mass(const std::vector< double > redshift, const std::vector< double > mass, const std::shared_ptr< void > inputs, std::vector< double > &parameter)
compute the number density as a function of the mass and redshift
The global namespace of the CosmoBolognaLib
Definition: CAMB.h:38
void checkDim(const std::vector< T > vect, const int val, const std::string vector, bool equal=true)
check if the dimension of a std::vector is equal/lower than an input value
Definition: Kernel.h:1532
int ErrorCBL(const std::string msg, const std::string functionCBL, const std::string fileCBL, const cbl::glob::ExitCode exitCode=cbl::glob::ExitCode::_error_)
throw an exception: it is used for handling exceptions inside the CosmoBolognaLib
Definition: Kernel.h:780