a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
myModel.cpp
/*
* Copyright (C) 2015 HEPfit Collaboration
* All rights reserved.
*
* For the licensing terms see doc/COPYING.
*/
#include "myModel.h"
/* Define mandatory model parameters here. */
const std::string myModel::myModelvars[NmyModelvars] = {"c1", "c2", "c3", "c4"};
{
/* Define all the parameters here and port them as observables too */
ModelParamMap.insert(std::make_pair("c1", std::cref(c1)));
ModelParamMap.insert(std::make_pair("c2", std::cref(c2)));
ModelParamMap.insert(std::make_pair("c3", std::cref(c3)));
ModelParamMap.insert(std::make_pair("c4", std::cref(c4)));
}
{
/* Destroy whatever you want, e.g. potentially dangerous pointers. */
}
}
/* Initialize model here */
{
condition = false;
return(true);
}
bool myModel::Init(const std::map<std::string, double>& DPars)
{
return(StandardModel::Init(DPars));
}
/* Do whatever is necessary before parameters are updated by the MCMC. */
{
if(!StandardModel::PreUpdate()) return (false);
return (true);
}
/* Model update method used be the MCMC to update the model parameters. */
bool myModel::Update(const std::map<std::string, double>& DPars)
{
if(!PreUpdate()) return (false);
UpdateError = false;
for (std::map<std::string, double>::const_iterator it = DPars.begin(); it != DPars.end(); it++)
setParameter(it->first, it->second);
if (UpdateError) return (false);
if(!PostUpdate()) return (false);
return (true);
return (true);
}
/* Postupdate method to update whatever is needed after the model parameters are updated */
{
if(!StandardModel::PostUpdate()) return (false);
return (true);
}
/* Model parameters and their derived quantities can be set here. */
void myModel::setParameter(const std::string name, const double& value)
{
if(name.compare("c1") == 0)
c1 = value;
else if(name.compare("c2") == 0)
c2 = value;
else if(name.compare("c3") == 0)
c3 = value;
else if(name.compare("c4") == 0)
c4 = value;
else
}
bool myModel::CheckParameters(const std::map<std::string, double>& DPars)
{
for (int i = 0; i < NmyModelvars; i++) {
if (DPars.find(myModelvars[i]) == DPars.end()) {
std::cout << "missing mandatory myModel parameter " << myModelvars[i] << std::endl;
return false;
}
}
}
/* Model Flags can be set here. */
bool myModel::setFlag(const std::string name, const bool value)
{
bool res = false;
if(name.compare("condition") == 0){
condition = value;
res = true;
} else {
}
return(res);
}
myModel::myModelvars
static const std::string myModelvars[NmyModelvars]
Definition: Doxygen/examples-src/myModel/src/myModel.h:21
myModel::myModel
myModel()
myModel constructor
Definition: Doxygen/examples-src/myModel/src/myModel.cpp:13
StandardModel::setParameter
virtual void setParameter(const std::string name, const double &value)
A method to set the value of a parameter of StandardModel.
Definition: StandardModel.cpp:231
myModel::c4
double c4
Definition: Doxygen/examples-src/myModel/src/myModel.h:100
myModel::c2
double c2
Definition: Doxygen/examples-src/myModel/src/myModel.h:100
StandardModel::CheckParameters
virtual bool CheckParameters(const std::map< std::string, double > &DPars)
A method to check if all the mandatory parameters for StandardModel have been provided in model initi...
Definition: StandardModel.cpp:313
myModel::c1
double c1
Definition: Doxygen/examples-src/myModel/src/myModel.h:100
myModel::PreUpdate
virtual bool PreUpdate()
Definition: Doxygen/examples-src/myModel/src/myModel.cpp:44
StandardModel
A model class for the Standard Model.
Definition: StandardModel.h:474
Model::UpdateError
bool UpdateError
A boolean set to false if update is successful.
Definition: Model.h:254
myModel::Update
virtual bool Update(const std::map< std::string, double > &DPars)
Definition: Doxygen/examples-src/myModel/src/myModel.cpp:51
StandardModel::setFlag
virtual bool setFlag(const std::string name, const bool value)
A method to set a flag of StandardModel.
Definition: StandardModel.cpp:378
myModel::PostUpdate
virtual bool PostUpdate()
Definition: Doxygen/examples-src/myModel/src/myModel.cpp:70
myModel::InitializeModel
virtual bool InitializeModel()
Definition: Doxygen/examples-src/myModel/src/myModel.cpp:31
StandardModel::Init
virtual bool Init(const std::map< std::string, double > &DPars)
A method to initialize the model parameters.
Definition: StandardModel.cpp:159
StandardModel::PreUpdate
virtual bool PreUpdate()
The pre-update method for StandardModel.
Definition: StandardModel.cpp:172
myModel::CheckParameters
virtual bool CheckParameters(const std::map< std::string, double > &DPars)
Definition: Doxygen/examples-src/myModel/src/myModel.cpp:92
myModel::setFlag
virtual bool setFlag(const std::string name, const bool value)
Definition: Doxygen/examples-src/myModel/src/myModel.cpp:105
StandardModel::PostUpdate
virtual bool PostUpdate()
The post-update method for StandardModel.
Definition: StandardModel.cpp:199
Model::IsModelInitialized
bool IsModelInitialized() const
A method to check if the model is initialized.
Definition: Model.h:136
myModel::condition
bool condition
Definition: Doxygen/examples-src/myModel/src/myModel.h:101
myModel::setParameter
virtual void setParameter(const std::string, const double &)
Definition: Doxygen/examples-src/myModel/src/myModel.cpp:78
StandardModel::InitializeModel
virtual bool InitializeModel()
A method to initialize the model.
Definition: StandardModel.cpp:140
myModel::c3
double c3
Definition: Doxygen/examples-src/myModel/src/myModel.h:100
myModel::Init
virtual bool Init(const std::map< std::string, double > &DPars)
Definition: Doxygen/examples-src/myModel/src/myModel.cpp:38
Model::name
std::string name
The name of the model.
Definition: Model.h:267
myModel::NmyModelvars
static const int NmyModelvars
Definition: Doxygen/examples-src/myModel/src/myModel.h:20
myModel::~myModel
~myModel()
myModel destructor
Definition: Doxygen/examples-src/myModel/src/myModel.cpp:23
Model::setModelInitialized
void setModelInitialized(bool ModelInitialized)
A set method to fix the failure or success of the initialization of the model.
Definition: Model.h:145