Commit ebe31038 authored by Plaszczynski Stephane's avatar Plaszczynski Stephane
Browse files

start transition to user_par in Parser

parent ca790f94
package CAPTAINFLAM
package CAMEL
use class v2.4.3
#compiler options
macro cppflags " -O2 -pipe -ansi -Woverloaded-virtual "
#macro cpp "icpc"
#macro cppflags " -O2 -ip -ansi_alias -align -Wbrief "
macro cppflags " -O2 -pipe -ansi -Woverloaded-virtual -Wpedantic -Wunused -Wmaybe-uninitialized -Wno-deprecated -Wno-div-by-zero -Wno-variadic-macros"
#macro cppflags " -O2 -pipe -ansi"
macro cflags " -O2 -fopenmp "
#CLASS
macro_append cflags " -DHYREC "
macro_append CAPTAINFLAM_linkopts " -fopenmp -lm"
#CAMEL includes
include_dirs " ../src"
include_dirs "../src/camel"
include_dirs "../src/Minuit2-5.28.00/src"
include_dirs "../src/Minuit2-5.28.00/inc"
include_dirs "../src/class/include"
include_dirs "../src/class/hyrec"
include_dirs "../src/cxxsupport"
include_dirs "../src/AbsRand"
include_dirs "../src/camel/JLA"
include_dirs "../src/camel/JLA/jla_likelihood_v3/src"
#cfitio
include_dirs "" \
ccali-sl6 "$(HL2_USR_LOCAL)/cfitsio"
macro_append CAPTAINFLAM_linkopts " -lcfitsio" \
ccali-sl6 " $(HL2_USR_LOCAL)/cfitsio/libcfitsio.a "
#cfitsio
#include_dirs "$(CLIKDIR)/include"
#macro_append CAMEL_linkopts " -lcfitsio "
#lapack/cblas
#JLA :needs cblas/lapack
macro_append cppflags ' -DJLA '
#macro_append CAMEL_linkopts " -L$(MKLROOT)/lib/intel64 -lmkl_intel_lp64 -lmkl_core -lmkl_intel_thread -ljla "
include_dirs "/usr/include/atlas"
macro_append CAPTAINFLAM_linkopts " -L/usr/lib64/atlas -lcblas -llapack -ljla "
#CLIK
macro CLIKDIR "/home/plaszczy/planck/plc_2.1/plc-2.1b1"
include_dirs "$(CLIKDIR)/include"
include_dirs "$(CLIKDIR)/src"
macro_append cflags " -DCLIK ${CLIKCFLAGS}"
macro_append cppflags " -DCLIK ${CLIKCFLAGS}"
macro_append CAPTAINFLAM_linkopts " -L$(CLIKDIR)/lib -lclik "
path_append LD_LIBRARY_PATH "$(CLIKDIR)/lib"
#application clik_example_C -group=test -s=../src/camel test/clik_example_c.c
#application clik_example_CC -group=test -s=../src/camel test/clik_example_c.cc
application test_clik -group=test -s=../src/camel test/test_clik.cc
application test_lensing -group=test -s=../src/camel test/test_lensing.cc
macro_append CAMEL_linkopts " -L/usr/lib64/atlas -lcblas -llapack -ljla "
#PLANCK
macro_append cppflags " -DCLIK $(CLIKCFLAGS)"
macro_append cflags " -DCLIK $(CLIKCFLAGS)"
macro_append CAMEL_linkopts " $(CLIKLIBS) "
macro_append CAMEL_linkopts "-L$(CLIKDIR)/lib -lcfitsio -lclik "
#include_dirs "$(CLIKDIR)/include"
#include_dirs "$(CLIKDIR)/src"
#macro_append cppflags " -DCLIK "
#macro_append cflags " -DCLIK "
#macro_append CAMEL_linkopts "-L$(CLIKDIR)/lib -lclik "
#path_append LD_LIBRARY_PATH "$(CLIKDIR)/lib"
# PICO #still hardcoded
include_dirs "/usr/include/python2.7"
include_dirs "/usr/lib64/python2.7/site-packages/numpy/core/include"
include_dirs "/home/plaszczy/.local/lib/python2.7/site-packages/pypico"
macro_append CAMEL_linkopts " -L/home/plaszczy/softs/pypico-3.2.0/build/temp.linux-x86_64-2.7 -lpico -L/usr/lib64/python2.7/config -lpython2.7 "
macro_append cppflags ' -DPICODATA=\"$(PICO_DATA)\" '
#CAMEL LIBRARIES
library Minuit -no_share ../src/Minuit2-5.28.00/src/*.cxx
library Class -no_share ../src/class/source/*.c ../src/class/tools/*.c ../src/class/hyrec/*.c -x=source/trg.c
library Util -no_share -x=ddl.cc ../src/cxxsupport/*.cc
library AbsRand -no_share ../src/AbsRand/*.cc
library CLHEP -no_share ../src/CLHEP/src/*.cc
library jla -no_share ../src/camel/JLA/jla_likelihood_v3/src/ini.c ../src/camel/JLA/jla_likelihood_v3/src/jla.cc
macro tocompile "CMB/*.cc BAO/*.cc Lensing/*.cc pico/*.cc JLA/*.cc Class/*.cc Constraints/*.cc"
library MinuitFit -no_share -s=../src/camel *.cc $(tocompile)
macro camelsrc "*.cc CMB/*.cc BAO/*.cc Lensing/*.cc pico/*.cc JLA/*.cc Class/*.cc Constraints/*.cc"
library MinuitFit -no_share -s=../src/camel $(camelsrc)
library MCMC -no_share -s=../src/camel/MCMC *.cc
macro CAPTAINFLAM_linkopts "-L$(CAPTAINFLAM_root)/${CMTCONFIG} -lMinuitFit -lMinuit -lMCMC -lCLHEP -lClass -lAbsRand -lUtil "
macro CAMEL_linkopts "-L$(CAMEL_root)/${CMTCONFIG} -lMinuitFit -lMinuit -lMCMC -lCLHEP -lAbsRand -lUtil "
macro_append cppflags ' -DPARFILE=\"$(CAMELROOT)/par\" '
#JLA
include_dirs "../src/camel/JLA"
include_dirs "../src/camel/JLA/jla_likelihood_v3/src"
library jla -no_share ../src/camel/JLA/jla_likelihood_v3/src/ini.c ../src/camel/JLA/jla_likelihood_v3/src/jla.cc
application test_jla -group=test -s=../src/camel test/test_jla.cc
# PICO
include_dirs "/usr/include/python2.7"
include_dirs "/usr/lib64/python2.7/site-packages/numpy/core/include"
include_dirs "/home/plaszczy/.local/lib/python2.7/site-packages/pypico"
macro_append CAPTAINFLAM_linkopts " -L/home/plaszczy/softs/pypico-3.2.0/build/temp.linux-x86_64-2.7 -lpico -L/usr/lib64/python2.7/config -lpython2.7 "
macro_append cppflags ' -DPICODATA=\"/home/plaszczy/softs/pypico-3.2.0/pico3_tailmonty_v33.dat\" '
application testPico -group=test -s=../src/camel/pico/exec testPico.cc
#CAMEL applications
# pour relinker si changement: toutes les application du package
macro CAPTAINFLAM_stamps $(PACKAGE_ROOT)/$(CMTCONFIG)/MinuitFit.stamp
macro CAMEL_stamps $(PACKAGE_ROOT)/$(CMTCONFIG)/MinuitFit.stamp
macro application_suffix ""
#groupe exec
# dependencies
application Minimize -group=exec -s=../src/camel exec/Minimize.cc
application FitClassFromPico -group=exec -s=../src/camel exec/FitClassFromPico.cc
application ScanParam -group=exec -s=../src/camel exec/ScanParam.cc
application ScanParamTwice -group=exec -s=../src/camel exec/ScanParamTwice.cc
#application ScanParamAndRandom -group=exec -s=../src/camel exec/ScanParamAndRandom.cc
application ScanParam2D -group=exec -s=../src/camel exec/ScanParam2D.cc
#application ScanRandomParams -group=exec -s=../src/camel exec/ScanRandomParams.cc
application writeChi2 -group=exec -s=../src/camel exec/writeChi2.cc
application writeSpectra -group=exec -s=../src/camel exec/writeSpectra.cc
application genegauss -group=exec -s=../src/camel exec/genegauss.cc
application AddForegrounds -group=exec -s=../src/camel exec/AddForegrounds.cc
#MCMC
application Minimize -group=exec -s=../src/camel exec/Minimize.cc
application ScanParam -group=exec -s=../src/camel exec/ScanParam.cc
application mcmc -group=exec -s=../src/camel/MCMC exec/mainMCMC.cc
#tests
application class -group=test ../src/class/main/class.c
application testKlass -group=test -s=../src/camel test/testKlass.cc
application testCLHEP -group=test -s=../src/camel/test testCLHEP.cc
application testBAO -group=test -s=../src/camel/test testBAO.cc
application testHiLLiPOP -group=test -s=../src/camel/test testHiLLiPOP.cc
#FI
application fitFI -group=FI -s=../src/FI *.cc exec/fitFI.cc
application fitcl_txt -group=FI -s=../src/FI *.cc exec/fitcl_txt.cc
application test_clik -group=test -s=../src/camel test/test_clik.cc
application test_lensing -group=test -s=../src/camel test/test_lensing.cc
application test_jla -group=test -s=../src/camel test/test_jla.cc
application testPico -group=test -s=../src/camel/pico/exec testPico.cc
#lIST OF ALL DEPENDENCIES
macro_append Minimize_dependencies " MinuitFit "
macro_append FitClassFromPico_dependencies " MinuitFit "
macro_append ScanParam_dependencies " MinuitFit "
macro_append ScanParamTwice_dependencies " MinuitFit "
macro_append ScanParam2D_dependencies " MinuitFit "
macro_append writeChi2_dependencies " MinuitFit "
macro_append writeSpectra_dependencies " MinuitFit "
macro_append genegauss_dependencies " MinuitFit "
macro_append AddForegrounds_dependencies " MinuitFit "
macro_append mcmc_dependencies " MinuitFit MCMC"
macro_append class_dependencies " MinuitFit Class"
macro_append testKlass_dependencies " MinuitFit Class"
macro_append testKlass_dependencies " MinuitFit"
macro_append clik_example_CC_dependencies " MinuitFit "
macro_append test_clik_dependencies " MinuitFit "
macro_append test_lensing_dependencies " MinuitFit "
......@@ -131,3 +107,4 @@ macro_append testBAO_dependencies " MinuitFit "
macro_append testHiLLiPOP_dependencies " MinuitFit "
macro_append test_jla_dependencies " MinuitFit "
macro_append testPico_dependencies " MinuitFit "
......@@ -209,7 +209,5 @@ protected:
};
;
#endif
......@@ -40,7 +40,7 @@ double MCMC_adaptive::calc_alpha(const HepVector& x,const HepVector& y, pdf* tar
bool MCMC_adaptive::choose_next(const HepVector& x,const HepVector& y,double u,pdf* target_func, pdf* proposal_func)
{
pdf_gaussian* g=dynamic_cast<pdf_gaussian *>(proposal_func);
//pdf_gaussian* g=dynamic_cast<pdf_gaussian *>(proposal_func);
bool test=false; //the default keep previous
double alpha=calc_alpha(x,y,target_func, proposal_func);
......@@ -74,7 +74,7 @@ bool MCMC_adaptive::choose_next(const HepVector& x,const HepVector& y,double u,p
}
void MCMC_adaptive::fill_chain(pdf* target_func, pdf* proposal,int init_step,char* chain_run_name)
void MCMC_adaptive::fill_chain(pdf* target_func, pdf* proposal,int init_step, const char* chain_run_name)
{
post_planck* pl=dynamic_cast<post_planck *>(target_func);
......
......@@ -25,13 +25,11 @@ public:
MCMC_adaptive(int dim_in, int length_in, bool verbose);
void fill_chain(pdf* target_func,pdf* proposal,int init_step,char* chain_run_name);
virtual void fill_chain(pdf* target_func,pdf* proposal,int init_step,
const char* chain_run_name);
inline void Set_t0(double t0) {_t0=t0;}
inline void Set_ts(double ts) {_ts=ts;}
};
}
;
#endif
......@@ -47,7 +47,7 @@ bool MCMC_metrohast::choose_next(const HepVector& x,const HepVector& y,double u,
void MCMC_metrohast::fill_chain(pdf* target_func, pdf* proposal_func,int init_step,char* chain_run_name)
void MCMC_metrohast::fill_chain(pdf* target_func, pdf* proposal_func,int init_step, const char* chain_run_name)
{
......
......@@ -17,7 +17,7 @@ public:
//costruttore
MCMC_metrohast(int dim_in, int length_in, bool verbose);
void fill_chain(pdf* target_func,pdf* proposal,int init_step,char* chain_run_name );
virtual void fill_chain(pdf* target_func,pdf* proposal,int init_step, const char* chain_run_name );
protected:
......
......@@ -75,7 +75,7 @@ bool MCMC_metropolis::choose_next(const HepVector& x,const HepVector& y,double u
void MCMC_metropolis::fill_chain(pdf* target_func, pdf* proposal,int init_step,char* chain_run_name)
void MCMC_metropolis::fill_chain(pdf* target_func, pdf* proposal,int init_step,const char* chain_run_name)
{
......
......@@ -16,7 +16,7 @@ public:
MCMC_metropolis(int dim_in, int length_in, bool verbose);
void fill_chain(pdf* target_func,pdf* proposal,int init_step,char* chain_run_name);
virtual void fill_chain(pdf* target_func,pdf* proposal,int init_step,const char* chain_run_name);
protected:
......
......@@ -237,7 +237,8 @@ void MCMC_sampler::GR_test_conv(int num_chain,pdf* target_func,pdf* proposal_fu
}
Set_starting_point(start+_starting_point);
fill_chain(target_func,proposal_func,0,"running_chain.txt");
const char* fileout="running_chain.txt";
fill_chain(target_func,proposal_func,0,fileout);
chain_vec.push_back(_mychain); //is worth register everything?
for (int l=_length/2; l<_length; l++)
......@@ -390,25 +391,25 @@ void MCMC_sampler::set_par(const char* str, int dim)
void MCMC_sampler::set_par(Parser parser)
{
vector<bool> fix_par=parser.FixParam;
vector<bool> fix_par(parser.user_par.fixedParams());
int stop=fix_par.size();
HepVector size(_dim); //at this stage _dim is already defined
_starting_point=size;
_min_par=size;
_max_par=size;
_par_err=size;
vector<double> err=(parser.upar).Errors();
vector<double> err=(parser.user_par).Errors();
int j=0;
for(int i = 0; i < stop; i++)
{
if(fix_par[i]==0)
{
_min_par[j]=(parser.upar).Parameter(i).LowerLimit();
_max_par[j]=(parser.upar).Parameter(i).UpperLimit();
_starting_point[j]=(parser.upar).Parameter(i).Value();
_min_par[j]=(parser.user_par).Parameter(i).LowerLimit();
_max_par[j]=(parser.user_par).Parameter(i).UpperLimit();
_starting_point[j]=(parser.user_par).Parameter(i).Value();
_par_err[j]=err[i];
//setting par names
_par_name.push_back(parser.parNames[i]);
_par_name.push_back(parser.user_par.parNames()[i]);
j++;
}
......
......@@ -85,7 +85,8 @@ class MCMC_sampler{
//public methods
virtual void fill_chain(pdf* target_func,pdf* proposal_func,int init_step, char* chain_run_name)=0;
virtual void fill_chain(pdf* target_func,pdf* proposal_func,int init_step,
const char* chain_run_name)=0;
double acc_rate(int length_0, int length);
void rearrange_chain();
void write_chain(char* str);
......@@ -127,7 +128,7 @@ class MCMC_sampler{
//verbose
void Set_verbose(bool verbose) {_verbose=verbose;}
};
}
;
#endif
......@@ -170,8 +170,8 @@ void pdf_gaussian::set_cov(const char* cov_file)
cout << "using:"<< cov_file << endl;
ifstream file_in;
file_in.open(cov_file);
int row;
int col;
//int row;
//int col;
if(!file_in)
{
cout <<"file not found";
......
......@@ -7,11 +7,8 @@
using namespace std;
//default constructor
planck_lkh::planck_lkh(Chi2Combiner* chi2, Parser parser): _chi2(chi2), _parser(parser), _e(0)
planck_lkh::planck_lkh(Chi2Combiner* chi2, Parser parser): _chi2(chi2), _parser(parser), _e(0),_par(_parser.user_par.Params()),_fix_par(parser.user_par.fixedParams())
{
_par=(_parser.upar).Params();
_fix_par=_parser.FixParam;
if(_parser.add_par)
{
_derived_list=_parser.derived;
......
......@@ -30,7 +30,7 @@ void prior_beta::evaluate(const HepVector& value)
if(value[0]>_min && value[0]<_max)
{
double x=(value[0]-_min)/(_max-_min);
//double x=(value[0]-_min)/(_max-_min);
//beta distrib is not normalised!!!!
_func_value=pow(value[0],_m-1)*pow(1-value[0],_n-1);
}
......
......@@ -53,10 +53,27 @@ public:
const std::vector<bool>& nui(){return _nui;}
bool isNui(const unsigned& i) const {return _nui[i];}
//helper
//helpers
bool isFixed(const unsigned& i) const {
MnUserParameters::Parameters()[i].IsFixed();
}
inline std::vector<bool> fixedParams() const {
const size_t N=Params().size();
std::vector<bool> f(N);
for (size_t i=0;i<N;i++) f[i]=isFixed(i);
return f;
}
inline std::vector<std::string> parNames() const {
const size_t N=Params().size();
std::vector<std::string> n(N);
for (size_t i=0;i<N;i++) n[i]=GetName(i);
return n;
}
private:
std::vector<bool> _nui; //is it a nuisance parameter?
......
......@@ -53,11 +53,6 @@ public:
static std::string getParDir(const std::string& dirname);
//parameters
std::vector<string> parNames;
MnUserParameters upar;
std::vector<bool> nuisance;
std::vector<bool> FixParam;
Parameters user_par;
//derived par
......@@ -75,6 +70,14 @@ public:
//access to paramfile details: see cxxutils/paramfile
paramfile params;
private:
std::vector<bool> FixParam;
std::vector<string> parNames;
MnUserParameters upar;
std::vector<bool> nuisance;
};
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment