v1.0
|
a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models
|
|
Go to the documentation of this file.
12 #include <boost/algorithm/string/predicate.hpp>
15 const std::string& ModelConf_i,
const int rank_i)
16 : myInputParser(ModelF, ThObsF),
21 std::map<std::string, double> DP;
22 for (std::vector<ModelParameter>::iterator it =
ModPars.begin(); it <
ModPars.end(); it++) {
23 DP[it->getname()] = it->getave();
28 for (boost::ptr_vector<Observable>::iterator it =
Obs.begin(); it <
Obs.end(); it++) {
29 DObs.insert(std::pair<std::string, double> (it->getThname() , 0.));
30 DThObs.insert(std::pair<std::string, ThObservable*> (it->getThname() , it->getTho()));
32 for (std::vector<CorrelatedGaussianObservables>::iterator it1 =
CGO.begin(); it1 <
CGO.end(); it1++) {
33 std::vector<Observable> ObsInCGO = it1->getObs();
34 for (std::vector<Observable>::iterator it2 = ObsInCGO.begin(); it2 < ObsInCGO.end(); it2++) {
35 DObs.insert(std::pair<std::string, double> (it2->getThname() , 0.));
36 DThObs.insert(std::pair<std::string, ThObservable*> (it2->getThname() , it2->getTho()));
43 std::cout <<
"\nPlease set the following parameters in the model configuration files:\n" << std::endl;
45 std::cout <<
"ModelParameter\t" << *it << std::endl;
47 std::cout << std::endl;
50 throw std::runtime_error(
"ERROR: Parameter(s) missing in model initialization.\n");
55 std::cout <<
"\n" << std::endl;
57 std::cout <<
"WARNING: unknown parameter " << *it <<
" not added." << std::endl;
62 const std::string& ModelName_i, std::map<std::string, double> DPars_i, std::map<std::string, std::string> DFlags_i,
64 : ModelName(ModelName_i),
65 myInputParser(ModelF, ThObsF),
68 for (std::map<std::string, double>::iterator it = DPars_i.begin(); it != DPars_i.end(); it++) {
75 if (
rank == 0) std::cout <<
"\nModel Initialized: " <<
ModelName << std::endl;
77 throw std::runtime_error(
"\nERROR: " +
ModelName +
" not initialized successfully.\n");
82 std::cout <<
"\nPlease set the following parameters in the model configuration files:\n" << std::endl;
84 std::cout <<
"ModelParameter\t" << *it << std::endl;
86 std::cout << std::endl;
89 throw std::runtime_error(
"\nERROR: " +
ModelName +
" cannot be initialized.\n");
94 std::cout <<
"\n" << std::endl;
96 std::cout <<
"WARNING: unknown parameter " << *it <<
" not added to MCMC" << std::endl;
103 boost::ptr_vector<Observable>().swap(
Obs);
109 for (std::map<std::string, std::string>::iterator it = DFlags_i.begin(); it != DFlags_i.end(); it++) {
110 if (!(boost::iequals(it->second,
"true")) && !(boost::iequals(it->second,
"false")) && !
Mod->
setFlagStr(it->first, it->second)) {
111 throw std::runtime_error(
"ERROR: setFlagStr error for " + it->first);
112 }
else if (boost::iequals(it->second,
"true") && !
Mod->
setFlag(it->first, 1)) {
113 throw std::runtime_error(
"ERROR: setFlag error for " + it->first);
114 }
else if (boost::iequals(it->second,
"false") && !
Mod->
setFlag(it->first, 0)) {
115 throw std::runtime_error(
"ERROR: setFlag error for " + it->first);
117 if (
rank == 0) std::cout <<
"set flag " << it->first <<
" = " << it->second << std::endl;
125 for (std::map<std::string, double>::iterator it = DP.begin(); it != DP.end(); it++) {
127 throw std::runtime_error(
"\nERROR: Incorrect parameter name " + it->first +
" passed to ComputeObservable");
131 for (std::map<std::string, double>::iterator it =
DObs.begin(); it !=
DObs.end(); it++) {
132 DObs[it->first] =
DThObs[it->first]->computeThValue();
139 if(
DObs.find(ObsName) ==
DObs.end())
140 throw std::runtime_error(
"\nERROR: Observable cannot be removed since it has not been added.\n");
143 throw std::runtime_error(
"\nERROR: ThObservable cannot be removed since it has not been added.\n");
150 DObs.insert(std::pair<std::string, double> (ObsName , 0.));
virtual ~ComputeObservables()
The default destructor.
ComputeObservables(ModelFactory &ModelF, ThObsFactory &ThObsF, const std::string &ModelConf_i, const int rank_i=0)
Constructor.
boost::ptr_vector< Observable > Obs
std::vector< std::string > getmissingModelParameters()
std::string ModelName
Name of the Model to be used.
std::map< std::string, double > DObs
Map of the observables to be computed.
std::map< std::string, double > DPars
Map of the parameters to be passed to Model.
virtual bool setFlag(const std::string name, const bool value)
A method to set a flag of StandardModel.
std::vector< CorrelatedGaussianObservables > CGO
virtual bool Init(const std::map< std::string, double > &DPars)
A method to initialize the model parameters.
void setFlags(std::map< std::string, std::string > DFlags_i)
This method sets the necessary flag for the requested model.
StandardModel * Mod
Pointer to an object of the class StandardModel.
void RemoveObservable(std::string ObsName)
A method to add an observable to the list of observables.
virtual bool setFlagStr(const std::string name, const std::string value)
A method to set a flag of StandardModel.
bool IsModelInitialized() const
A method to check if the model is initialized.
const int rank
< Rank of the MPI process. Set to 0 for serial run.
void setModelName(const std::string name)
A method to set the name of the model.
std::vector< Observable2D > Obs2D
virtual bool InitializeModel()
A method to initialize the model.
StandardModel * CreateModel(const std::string &ModelName)
virtual bool Update(const std::map< std::string, double > &DPars)
The update method for StandardModel.
std::vector< CorrelatedGaussianParameters > CGP
std::map< std::string, ThObservable * > DThObs
std::map< std::string, double > compute(std::map< std::string, double > DP)
The method used to compute observables.
std::vector< ModelParameter > ModPars
std::vector< std::string > unknownParameters
void addCustomObservableType(const std::string name, boost::function< Observable *() > funct)
A method to add a user defined observable with a user defined likelihood.
InputParser myInputParser
An object of the InputParser class.
std::vector< std::string > getUnknownParameters()
A method to get the vector of the parameters that have been specified in the configuration file but n...
ThObservable * CreateThMethod(const std::string &name, StandardModel &model) const
This method checks for the existence of an observable of a specific name in the map thobs and returns...
void AddObservable(std::string ObsName)
A method to remove an observable from the list of observables.
std::vector< std::string > paraNames
The vector of allowed parameter names.