2 #include <unordered_map>
11 MACH3LOG_INFO(
"- Using NuDock sample config in this file {}", configFile);
13 SampleManager = std::make_unique<Manager>(configFile.c_str());
50 nlohmann::json request;
51 std::unordered_map<std::string, double> osc_params;
52 std::unordered_map<std::string, double> xsec_params;
58 xsec_params[paramName] = paramValue;
63 auto const& paramNameM3 = pair.first;
64 auto const& paramNameNuDock = pair.second;
70 osc_params[paramNameNuDock] = paramValue;
73 request[
"osc_pars"] = osc_params;
74 request[
"sys_pars"] = xsec_params;
76 auto response =
nudock_ptr->send_request(
"/set_parameters", request);
80 }
catch (
const std::exception &e) {
91 nlohmann::json request =
"";
92 double llh_value = 0.0;
93 auto response =
nudock_ptr->send_request(
"/log_likelihood", request);
95 llh_value = response[
"log_likelihood"].get<
double>();
98 }
catch (
const std::exception &e) {
99 MACH3LOG_ERROR(
"Error retrieving log-likelihood from NuDock response: {}", e.what());
const std::unordered_map< std::string, std::string > NuDockOscNameMap_r
Mapping from MaCh3 oscillation parameter names to NuDock names.
void FormatOscParsForNuDock(const std::string ¶m_name, double ¶m_value)
Convert an oscillation parameter value from MaCh3 convention to NuDock convention.
void InitialiseNuDockObj(Manager *man, std::unique_ptr< NuDock > &nudock_ptr)
Initialise a NuDock communication object from a manager configuration.
Factory utilities for creating and configuring NuDock communication objects.
@ kNorm
For normalisation parameters.
@ kSpline
For splined parameters (1D)
@ kFunc
For functional parameters.
Client-side sample handler that delegates reweighting and likelihood evaluation to a remote NuDock se...
Type GetFromManager(const YAML::Node &node, const Type defval, const std::string File="", const int Line=1)
Get content of config file if node is not found take default value specified.
Custom exception class used throughout MaCh3.
int GetParIndex(const std::string &name) const
Get index based on name.
std::string GetParFancyName(const int i) const
Get fancy name of the Parameter.
M3::float_t GetParProp(const int i) const
Get proposed parameter value.
Class responsible for handling of systematic error parameters with different types defined in the con...
const std::vector< int > GetParsIndexFromSampleName(const std::string &SampleName, const SystType Type) const
DB Grab the parameter indices for the relevant SampleName.
Class responsible for handling implementation of samples used in analysis, reweighting and returning ...
virtual ~SampleHandlerNuDockBase()
Destructor.
double GetLikelihood() const override
Retrieve the log-likelihood from the NuDock server.
void Reweight() override
Send current parameter values to the NuDock server.
std::vector< int > nudockParamInds
Cached indices into the ParameterHandler for parameters sent to the server.
std::unique_ptr< Manager > SampleManager
Manager owning the NuDockClient configuration.
bool verbose
Verbose logging flag, read from the NuDockClient config block.
ParameterHandlerGeneric * ParHandler
Non-owning pointer to the cross-section ParameterHandler.
std::unique_ptr< NuDock > nudock_ptr
Pointer to the NuDock client communication object.
void Init()
Initialise the NuDock client connection and cache parameter indices.
SampleHandlerNuDockBase(std::string configFile, ParameterHandlerGeneric *xsec_cov)
Construct the NuDock client sample handler.