10 #include "CorrelatedGaussianObservables.h"
12 #include <boost/algorithm/string/predicate.hpp>
15 const std::string& ModelConf_i,
const int rank_i)
16 : myInputParser(ModelF, ThObsF),
19 std::vector<ModelParameter> ModPars;
20 boost::ptr_vector<Observable> Obs;
21 std::vector<Observable2D> Obs2D;
22 std::vector<CorrelatedGaussianObservables> CGO;
23 std::vector<CorrelatedGaussianParameters> CGP;
26 std::map<std::string, double> DP;
27 for (std::vector<ModelParameter>::iterator it = ModPars.begin(); it < ModPars.end(); it++) {
28 DP[it->getname()] = it->getave();
33 for (boost::ptr_vector<Observable>::iterator it = Obs.begin(); it < Obs.end(); it++) {
34 DObs.insert(std::pair<std::string, double> (it->getThname() , 0.));
35 DThObs.insert(std::pair<std::string, ThObservable*> (it->getThname() , it->getTho()));
37 for (std::vector<CorrelatedGaussianObservables>::iterator it1 = CGO.begin(); it1 < CGO.end(); it1++) {
38 std::vector<Observable> ObsInCGO = it1->getObs();
39 for (std::vector<Observable>::iterator it2 = ObsInCGO.begin(); it2 < ObsInCGO.end(); it2++) {
40 DObs.insert(std::pair<std::string, double> (it2->getThname() , 0.));
41 DThObs.insert(std::pair<std::string, ThObservable*> (it2->getThname() , it2->getTho()));
47 throw std::runtime_error(
"ERROR: Parameter(s) missing in model initialization.\n");
51 const std::string& ModelName_i, std::map<std::string, double> DPars_i,
const int rank_i)
52 : ModelName(ModelName_i),
53 myInputParser(ModelF, ThObsF),
56 for (std::map<std::string, double>::iterator it = DPars_i.begin(); it != DPars_i.end(); it++) {
63 if (
rank == 0) std::cout <<
"\nModel Initialized: " <<
ModelName << std::endl;
65 throw std::runtime_error(
"\nERROR: " +
ModelName +
" not initialized successfully.\n");
68 throw std::runtime_error(
"\nERROR: Model cannot be initialized initialization.\n");
77 for (std::map<std::string, std::string>::iterator it = DFlags_i.begin(); it != DFlags_i.end(); it++) {
78 if (!(boost::iequals(it->second,
"true")) && !(boost::iequals(it->second,
"false")) && !
Mod->
setFlagStr(it->first, it->second)) {
79 throw std::runtime_error(
"ERROR: setFlagStr error for " + it->first);
80 }
else if (boost::iequals(it->second,
"true") && !
Mod->
setFlag(it->first, 1)) {
81 throw std::runtime_error(
"ERROR: setFlag error for " + it->first);
82 }
else if (boost::iequals(it->second,
"false") && !
Mod->
setFlag(it->first, 0)) {
83 throw std::runtime_error(
"ERROR: setFlag error for " + it->first);
85 if (
rank == 0) std::cout <<
"set flag " << it->first <<
" = " << it->second << std::endl;
93 for (std::map<std::string, double>::iterator it = DP.begin(); it != DP.end(); it++) {
95 throw std::runtime_error(
"\nERROR: Incorrect parameter name passed to ComputeObservable");
99 for (std::map<std::string, double>::iterator it =
DObs.begin(); it !=
DObs.end(); it++) {
100 DObs[it->first] =
DThObs[it->first]->computeThValue();
107 if(
DObs.find(ObsName) ==
DObs.end())
108 throw std::runtime_error(
"\nERROR: Observable cannot be removed since it has not been added.\n");
111 throw std::runtime_error(
"\nERROR: ThObservable cannot be removed since it has not been added.\n");
118 DObs.insert(std::pair<std::string, double> (ObsName , 0.));
InputParser myInputParser
An object of the InputParser class.
virtual bool setFlagStr(const std::string name, const std::string value)
A method to set a flag of StandardModel.
StandardModel * CreateModel(const std::string &ModelName)
virtual bool Update(const std::map< std::string, double > &DPars)
The update method for StandardModel.
ComputeObservables(ModelFactory &ModelF, ThObsFactory &ThObsF, const std::string &ModelConf_i, const int rank_i=0)
Constructor.
std::string ModelName
Name of the Model to be used.
void AddObservable(std::string ObsName)
A method to remove an observable from the list of observables.
virtual bool InitializeModel()
A method to initialize the model.
std::map< std::string, double > DObs
Map of the observables to be computed.
ThObservable * CreateThMethod(const std::string &name, const StandardModel &model) const
This method checks for the existence of an observable of a specific name in the map thobs and returns...
std::map< std::string, double > DPars
Map of the parameters to be passed to Model.
bool IsModelInitialized() const
A method to check if the model is initialized.
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.
void setModelName(const std::string name)
A method to set the name of the model.
std::map< std::string, ThObservable * > DThObs
void RemoveObservable(std::string ObsName)
A method to add an observable to the list of observables.
StandardModel * Mod
Pointer to an object of the class StandardModel.
void addCustomObservableType(const std::string name, boost::function< Observable *() > funct)
std::map< std::string, double > compute(std::map< std::string, double > DP)
The method used to compute observables.
std::vector< std::string > paraNames
The vector of allowed parameter names.
const int rank
< Rank of the MPI process. Set to 0 for serial run.
virtual ~ComputeObservables()
The default destructor.
virtual bool setFlag(const std::string name, const bool value)
A method to set a flag of StandardModel.