CosmoBolognaLib
Free Software C++/Python libraries for cosmological calculations
Modelling_NumberCounts1D_Redshift.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_NumberCounts1D_Redshift::set_model_NumberCounts_cosmology (const std::vector<cbl::cosmology::CosmologicalParameter> cosmo_param, const std::vector<statistics::PriorDistribution> cosmo_param_prior)
51 {
52  m_data_model.Cpar = cosmo_param;
53 
54  const size_t nParams = cosmo_param.size();
55  checkDim(cosmo_param, nParams, "cosmoPar_prior");
56 
57  vector<statistics::ParameterType> cosmoPar_type(nParams, statistics::ParameterType::_Base_);
58  vector<string> cosmoPar_string(nParams);
59 
60  for (size_t i=0; i<nParams; i++)
61  cosmoPar_string[i] = CosmologicalParameter_name(cosmo_param[i]);
62 
63  // input data used to construct the model
64  auto inputs = make_shared<STR_NC_data_model>(m_data_model);
65 
66  // set prior
67  m_set_prior(cosmo_param_prior);
68 
69  // construct the model
70  switch (m_HistogramType) {
71  case (glob::HistogramType::_N_V_):
72  m_model = make_shared<statistics::Model1D>(statistics::Model1D(&number_counts_redshift, nParams, cosmoPar_type, cosmoPar_string, inputs));
73  break;
74  case (glob::HistogramType::_n_V_):
75  m_model = make_shared<statistics::Model1D>(statistics::Model1D(&number_density_redshift, nParams, cosmoPar_type, cosmoPar_string, inputs));
76  break;
77  default:
78  ErrorCBL("no such a variable in the list!", "set_model_NumberCounts_cosmology", "Modelling_NumberCounts1D_Redshift.cpp");
79  }
80 }
Global functions to model number counts.
The class Modelling_NumberCounts1D_Redshift.
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 Model1D.
Definition: Model1D.h:60
std::string CosmologicalParameter_name(const CosmologicalParameter parameter)
name of the cosmological parameter
Definition: Cosmology.cpp:45
std::vector< double > number_counts_redshift(const std::vector< double > redshift, const std::shared_ptr< void > inputs, std::vector< double > &parameter)
compute the number counts as a function of redshift
std::vector< double > number_density_redshift(const std::vector< double > redshift, const std::shared_ptr< void > inputs, std::vector< double > &parameter)
compute the number density as a function of the 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