Commit 953e2dde authored by Plaszczynski Stephane's avatar Plaszczynski Stephane
Browse files

fix execs with new naming

parent 761d9322
......@@ -91,7 +91,7 @@ void MCMC_adaptive::fill_chain(pdf* target_func, pdf* proposal,int init_step, co
_add_flag=false;
if(pl && (pl->_likelihood)->_parser.derived.size()!=0)
if(pl && (pl->_likelihood)->_parser.derivedVars().size()!=0)
{
_add_flag=true;
cout << "there will be derived par chain" << endl;
......
......@@ -92,7 +92,7 @@ void MCMC_metropolis::fill_chain(pdf* target_func, pdf* proposal,int init_step,c
for(int l=0;l<_par_name.size();l++) { chain_running << _par_name[l] << "\t";}
chain_running << endl;
_add_flag=false;
if(pl && (pl->_likelihood)->_parser.derived.size()!=0)
if(pl && (pl->_likelihood)->_parser.derivedVars().size()!=0)
{
_add_flag=true;
cout << "there will be derived par chain" << endl;
......
......@@ -415,7 +415,7 @@ void MCMC_sampler::set_par(Parser parser)
}
}
for(int l=0;l<parser.derived.size();l++) _par_name.push_back(parser.derived[l]);
for(int l=0;l<parser.derivedVars().size();l++) _par_name.push_back(parser.derivedVars()[l]);
for(int l=0;l<_par_name.size();l++) cout << _par_name[l] <<"\t";
cout << endl;
cout << _min_par << _max_par << _starting_point << _par_err <<endl;
......
......@@ -9,9 +9,9 @@ using namespace std;
//default constructor
planck_lkh::planck_lkh(Chi2Combiner* chi2, Parser parser): _chi2(chi2), _parser(parser), _e(0),_par(_parser.vars().Params()),_fix_par(parser.vars().fixedParams())
{
if(_parser.derived.size()!=0)
if(_parser.derivedVars().size()!=0)
{
_derived_list=_parser.derived;
_derived_list=_parser.derivedVars();
_derived_par.resize( _derived_list.size());
}
}
......@@ -51,7 +51,7 @@ void planck_lkh::evaluate(const HepVector& value)
_func_value=(*_chi2)(_par);
//need to treat cases where chi2 evaluation failed
_flag_fail_evaluate=!(_chi2->success());
if(_parser.derived.size()!=0 && !_flag_fail_evaluate){ //if extra parameters and not failed
if(_parser.derivedVars().size()!=0 && !_flag_fail_evaluate){ //if extra parameters and not failed
_e=(_chi2->getEngine());
for(int index=0; index<_derived_list.size();index++)
{
......
......@@ -54,7 +54,7 @@ public:
inline bool mnContours() {return params.find<bool>("computecontour",false);}
//MCMC related: derived par
std::vector<std::string> derived;
const std::vector<std::string>& derivedVars() const {return derived;}
//utlity to access filenames/dir: if not found build path relative to PARFILE dir (your par/ directory)
......@@ -72,6 +72,7 @@ private:
Variables user_par;
std::vector<std::string> cons;
std::vector<std::string> derived;
......
......@@ -50,7 +50,7 @@ void printVec(const vector<T>& v,unsigned n,const string & s){
void dumpMin(ostream& o,const FunctionMinimum& min1){
if(min1.HasReachedCallLimit()) o << "has reached call limits" << std::endl;
o << "HasValidVariables" << min1.HasValidVariables() << std::endl;
o << "HasValidParameters" << min1.HasValidParameters() << std::endl;
o << "HasCovariance " << min1.HasCovariance() << std::endl;
o << "HasValidCovariance" << min1.HasValidCovariance() << std::endl;
o << "HasAccurateCovar " << min1.HasAccurateCovar() << std::endl;
......@@ -70,63 +70,6 @@ void dumpMin(ostream& o,const FunctionMinimum& min1){
}
void AnaContour(FCNBase& fFCN, MnUserVariables upar, const FunctionMinimum& min,
vector<bool>& FixParam)
{
MnMinos Minos(fFCN, min);
{
std::cout<<"1-sigma Minos errors: "<<std::endl;
for(int i=0;i<(int)FixParam.size();i++){
if(!FixParam[i]){
std::pair<double,double> e0 = Minos(i);
std::cout<<"par0: "<<min.UserState().Value(upar.Name(i))<<" "<<e0.first<<" "<<e0.second<<std::endl;
}
}
}
{
fFCN.SetErrorDef(4.);
std::cout<<"2-sigma Minos errors: "<<std::endl;
for(int i=0;i<(int)FixParam.size();i++){
if(!FixParam[i]){
MinosError e0 = Minos.Minos(i);
std::cout<<e0<<std::endl;
}
}
}
MnContours contours(fFCN,min);
//70% confidence level for 2 parameters contour around the minimum
// (minimal interface)
for(int i=0;i<(int)FixParam.size();i++)
{
if(!FixParam[i]&&i+1<(int)FixParam.size()){
for(int j=i+1;j<(int)FixParam.size();j++){
if(!FixParam[j]){
std::cout << "Working on parameters::"<< upar.Name(i) << " " << upar.Name(j) << std::endl;
fFCN.SetErrorDef(2.41);
std::vector<std::pair<double,double> > cont = contours(i, j, 20);
//95% confidence level for 2 parameters contour
// (rich interface)
fFCN.SetErrorDef(5.99);
ContoursError cont4 = contours.Contour(i, j, 20);
// plot the contours
MnPlot plot;
cont.insert(cont.end(), cont4().begin(), cont4().end());
plot(min.UserState().Value(upar.Name(i)), min.UserState().Value(upar.Name(j)), cont);
// print out one contour
std::cout<<cont4<<std::endl;
}
}
}
}
};
int main(int argc,char** argv){
if (!(argc==3 || argc==4)) {
......@@ -167,7 +110,7 @@ int main(int argc,char** argv){
//minimisation
try{
MnUserVariables upar(parser.upar);
MnUserParameters upar(parser.vars());
MnMigrad migrad(*theChi2,upar,stra);
FunctionMinimum min1 = migrad(nitermax,tol);
dumpMin(cout,min1);
......@@ -177,7 +120,7 @@ int main(int argc,char** argv){
{
for (size_t i=0;i<migrad.Params().size();i++)
{
if (parser.nuisance[i]) { migrad.SetValue(i,firstpar[i]); }//migrad.Fix(i) ; cout << "fixing" << i << endl;}
if (parser.vars().isNui(i)) { migrad.SetValue(i,firstpar[i]); }//migrad.Fix(i) ; cout << "fixing" << i << endl;}
else { migrad.RemoveLimits(i); }
}
min1 = migrad(nitermax,tol);
......@@ -221,7 +164,7 @@ int main(int argc,char** argv){
sprintf(DeChi2,"%5.7f",chi2);
of << DeChi2 << " " << " " << valid << " " << min1.Edm() ;
of << " " << min1.HasReachedCallLimit()
<< " " << min1.HasValidVariables()
<< " " << min1.HasValidParameters()
<< " " << min1.HasCovariance()
<< " " << min1.HasValidCovariance()
<< " " << min1.HasAccurateCovar()
......
......@@ -43,7 +43,7 @@ using namespace ROOT::Minuit2;
void dumpMin(ostream& o,const FunctionMinimum& min1){
if(min1.HasReachedCallLimit()) o << "has reached call limits" << std::endl;
o << "HasValidVariables" << min1.HasValidVariables() << std::endl;
o << "HasValidParameters" << min1.HasValidParameters() << std::endl;
o << "HasCovariance " << min1.HasCovariance() << std::endl;
o << "HasValidCovariance" << min1.HasValidCovariance() << std::endl;
o << "HasAccurateCovar " << min1.HasAccurateCovar() << std::endl;
......@@ -92,9 +92,9 @@ int main(int argc,char** argv){
Chi2Combiner* theChi2=Chi2Factory::gimeChi2(parser);
theChi2->setVerbose(true);
MnUserVariables upar(parser.upar);
MnUserParameters upar(parser.vars());
std::vector<double> val=(parser.upar).Params();
std::vector<double> val=(parser.vars()).Params();
unsigned int iarg = upar.Index(parscan);
......@@ -111,7 +111,7 @@ int main(int argc,char** argv){
double chi2(-1.);
bool valid=0;
MnUserVariables upar(parser.upar);
MnUserParameters upar(parser.vars());
upar.SetValue(parscan,val[iarg]);
upar.Fix(parscan);
bool verbose=false;
......@@ -124,7 +124,7 @@ int main(int argc,char** argv){
for (size_t i=0;i<migrad.Params().size();i++)
{
if (parser.nuisance[i]) { migrad.SetValue(i,firstpar[i]); }//migrad.Fix(i) ; cout << "fixing" << i << endl;}
if (parser.vars().isNui(i)) { migrad.SetValue(i,firstpar[i]); }//migrad.Fix(i) ; cout << "fixing" << i << endl;}
else { migrad.RemoveLimits(i); }
}
......
......@@ -22,7 +22,7 @@ int main(int argc,char** argv){
theChi2->setVerbose(true);
//valeur chi2
vector<double> val=parser.upar.Params();
vector<double> val=parser.vars().Params();
double chi2=(*theChi2)(val);
cout << "******************************************************" << endl;
......
......@@ -25,7 +25,7 @@ int main(int argc,char** argv){
Engine *e;
if (engine=="pico") {
e=new MnPicoEngine(parser.user_par,lmax,PICODATA,true);
e=new MnPicoEngine(parser.vars(),lmax,PICODATA,true);
}
else{
......@@ -46,7 +46,7 @@ int main(int argc,char** argv){
cout << "CLASS \t--> precision parameters taken from file=" << pre << endl;
e=new MnClassEngine(parser.user_par,
e=new MnClassEngine(parser.vars(),
classparms,
pre);
......
......@@ -30,7 +30,7 @@ int main(int argc,char** argv){
Chi2Combiner* theChi2=Chi2Factory::gimeChi2(parser);
//valeur chi2
vector<double> val=parser.upar.Params();
vector<double> val=parser.vars().Params();
for(int i=0; i<val.size();i++)
{
cout <<"val= " << val[i] <<endl;
......
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