![]() |
MaCh3
2.5.1
Reference Guide
|
A class that implements a NuDock server for cross-fitter communication. More...
#include <NuDock/NuDockServerBase.h>
Public Member Functions | |
| NuDockServerBase (Manager *const fitMan) | |
| Construct the NuDock server. More... | |
| virtual | ~NuDockServerBase () |
| Destructor. More... | |
| std::string | GetName () const |
| Return a human-readable identifier for this fitter. More... | |
| void | setup () |
| Perform one-time server setup. More... | |
| virtual double | getLogLikelihood () |
| Compute the total log-likelihood across all systematics and samples. More... | |
| virtual nlohmann::json | setParameters (const nlohmann::json &request) |
| Handle a "set_parameters" request. More... | |
| virtual nlohmann::json | getParametersNames (const nlohmann::json &request) |
| Handle a "get_parameter_names" request. More... | |
| virtual nlohmann::json | getParameters (const nlohmann::json &request) |
| Handle a "get_parameters" request. More... | |
| virtual nlohmann::json | get2NLL (const nlohmann::json &request) |
| Handle a "log_likelihood" request. More... | |
| virtual nlohmann::json | setAsimovPoint (const nlohmann::json &request) |
| Handle a "set_asimov" request. More... | |
| virtual nlohmann::json | getMCSpectrum (const nlohmann::json &request) |
| Handle a "get_mc_spectrum" request. More... | |
| virtual nlohmann::json | getDataSpectrum (const nlohmann::json &request) |
| Handle a "get_data_spectrum" request. More... | |
| void | RunMCMC () override |
| No-op implementation — the server does not run own MCMC. More... | |
Public Member Functions inherited from FitterBase | |
| FitterBase (Manager *const fitMan) | |
| Constructor. More... | |
| virtual | ~FitterBase () |
| Destructor for the FitterBase class. More... | |
| void | AddSampleHandler (SampleHandlerInterface *sample) |
| This function adds a sample PDF object to the analysis framework. The sample PDF object will be utilized in fitting procedures or likelihood scans. More... | |
| void | AddSystObj (ParameterHandlerBase *cov) |
| This function adds a Covariance object to the analysis framework. The Covariance object will be utilized in fitting procedures or likelihood scans. More... | |
| void | DragRace (const int NLaps=100) |
| Calculates the required time for each sample or covariance object in a drag race simulation. Inspired by Dan's feature. More... | |
| void | RunLLHScan () |
| Perform a 1D likelihood scan. More... | |
| void | RunLLHMap () |
| Perform a general multi-dimensional likelihood scan. More... | |
| void | GetStepScaleBasedOnLLHScan (const std::string &filename="") |
| LLH scan is good first estimate of step scale. More... | |
| void | Run2DLLHScan () |
| Perform a 2D likelihood scan. More... | |
| void | RunSigmaVar () |
| Perform a 1D/2D sigma var for all samples. More... | |
| virtual void | StartFromPreviousFit (const std::string &FitName) |
| Allow to start from previous fit/chain. More... | |
| std::string | GetName () const |
| Get name of class. More... | |
Protected Attributes | |
| bool | verbose |
| Flag controlling verbose logging of server operations. More... | |
| bool | add_prior_llh |
| If true, systematic prior likelihoods are added to the total LLH. More... | |
Protected Attributes inherited from FitterBase | |
| Manager * | fitMan |
| The manager for configuration handling. More... | |
| unsigned int | step |
| current state More... | |
| double | logLCurr |
| current likelihood More... | |
| double | logLProp |
| proposed likelihood More... | |
| double | accProb |
| current acceptance prob More... | |
| int | accCount |
| counts accepted steps More... | |
| unsigned int | stepStart |
| step start, by default 0 if we start from previous chain then it will be different More... | |
| std::vector< double > | sample_llh |
| store the llh breakdowns More... | |
| std::vector< double > | syst_llh |
| systematic llh breakdowns More... | |
| std::vector< SampleHandlerInterface * > | samples |
| Sample holder. More... | |
| unsigned int | TotalNSamples |
| Total number of samples used, single SampleHandler can store more than one analysis sample! More... | |
| std::vector< ParameterHandlerBase * > | systematics |
| Systematic holder. More... | |
| std::unique_ptr< TStopwatch > | clock |
| tells global time how long fit took More... | |
| std::unique_ptr< TStopwatch > | stepClock |
| tells how long single step/fit iteration took More... | |
| double | stepTime |
| Time of single step. More... | |
| std::unique_ptr< TRandom3 > | random |
| Random number. More... | |
| TFile * | outputFile |
| Output. More... | |
| TDirectory * | CovFolder |
| Output cov folder. More... | |
| TDirectory * | SampleFolder |
| Output sample folder. More... | |
| TTree * | outTree |
| Output tree with posteriors. More... | |
| int | auto_save |
| auto save every N steps More... | |
| bool | fTestLikelihood |
| Necessary for some fitting algorithms like PSO. More... | |
| bool | FileSaved |
| Checks if file saved not repeat some operations. More... | |
| bool | SettingsSaved |
| Checks if setting saved not repeat some operations. More... | |
| bool | OutputPrepared |
| Checks if output prepared not repeat some operations. More... | |
| std::string | AlgorithmName |
| Name of fitting algorithm that is being used. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from FitterBase | |
| void | ProcessMCMC () |
| Process MCMC output. More... | |
| void | PrepareOutput () |
| Prepare the output file. More... | |
| void | SaveOutput () |
| Save output and close files. More... | |
| void | SanitiseInputs () |
| Remove obsolete memory and make other checks before fit starts. More... | |
| void | SaveSettings () |
| Save the settings that the MCMC was run with. More... | |
| bool | GetScanRange (std::map< std::string, std::vector< double >> &scanRanges) const |
| YSP: Set up a mapping to store parameters with user-specified ranges, suggested by D. Barrow. More... | |
| void | GetParameterScanRange (const ParameterHandlerBase *cov, const int i, double &CentralValue, double &lower, double &upper, const int n_points, const std::string &suffix="") const |
| Helper function to get parameter scan range, central value. More... | |
| bool | CheckSkipParameter (const std::vector< std::string > &SkipVector, const std::string &ParamName) const |
| KS: Check whether we want to skip parameter using skip vector. More... | |
| void | CustomRange (const std::string &ParName, const double sigma, double &ParamShiftValue) const |
| For comparison with other fitting frameworks (like P-Theta) we usually have to apply different parameter values then usual 1, 3 sigma. More... | |
A class that implements a NuDock server for cross-fitter communication.
NuDockServerBase acts as the server-side adapter in the NuDock protocol. It inherits from FitterBase and translates incoming JSON requests into operations on MaCh3 systematic & sample objects (set/get parameters, compute likelihoods, set Asimov data, retrieve predicted spectra, etc.).
Experiment-specific servers should derive from this class and override the virtual handlers where custom behaviour is needed.
Definition at line 25 of file NuDockServerBase.h.
| NuDockServerBase::NuDockServerBase | ( | Manager *const | fitMan | ) |
Construct the NuDock server.
Construct the NuDock server.
| fitMan | Pointer to the MaCh3 manager that owns fit configuration. |
| fitMan | Pointer to the MaCh3 manager that owns fit configuration. |
Definition at line 7 of file NuDockServerBase.cpp.
|
virtual |
|
virtual |
Handle a "log_likelihood" request.
Handle a "log_likelihood" request.
Returns twice the log-likelihood (2NLL) to match NuDock convention.
| request | JSON object (unused). |
Returns twice the log-likelihood (2NLL) to match NuDock convention.
| request | JSON object (unused). |
Definition at line 334 of file NuDockServerBase.cpp.
|
virtual |
Handle a "get_data_spectrum" request.
Handle a "get_data_spectrum" request.
Retrieves data bin contents and bin edges from every registered SampleHandlerFD sample, supporting 1-D and 2-D histograms.
| request | JSON object (unused). |
| MaCh3Exception | if a sample does not derive from SampleHandlerFD. |
Retrieves data bin contents and bin edges from every registered SampleHandlerFD sample, supporting 1-D and 2-D histograms.
| request | JSON object (unused). |
| MaCh3Exception | if a sample does not derive from SampleHandlerFD. |
Definition at line 246 of file NuDockServerBase.cpp.
|
virtual |
Compute the total log-likelihood across all systematics and samples.
Compute the total log-likelihood across all systematics and samples.
The systematic prior likelihoods are optionally included (controlled by add_prior_llh). Sample likelihoods are always summed.
The systematic prior likelihoods are optionally included (controlled by add_prior_llh). Sample likelihoods are always summed.
Definition at line 30 of file NuDockServerBase.cpp.
|
virtual |
Handle a "get_mc_spectrum" request.
Handle a "get_mc_spectrum" request.
Retrieves predicted bin contents and bin edges from every registered SampleHandlerFD sample, supporting 1-D and 2-D histograms.
| request | JSON object (unused). |
| MaCh3Exception | if a sample does not derive from SampleHandlerFD. |
Retrieves predicted bin contents and bin edges from every registered SampleHandlerFD sample, supporting 1-D and 2-D histograms.
| request | JSON object (unused). |
| MaCh3Exception | if a sample does not derive from SampleHandlerFD. |
Definition at line 210 of file NuDockServerBase.cpp.
|
inline |
Return a human-readable identifier for this fitter.
Definition at line 35 of file NuDockServerBase.h.
|
virtual |
Handle a "get_parameters" request.
Handle a "get_parameters" request.
Returns current values of oscillation and systematic parameters.
| request | JSON object (unused). |
Returns current values of oscillation and systematic parameters.
| request | JSON object (unused). |
Definition at line 304 of file NuDockServerBase.cpp.
|
virtual |
Handle a "get_parameter_names" request.
Handle a "get_parameter_names" request.
Returns the names of all unfixed, non-oscillation systematic parameters.
| request | JSON object (unused). |
Returns the names of all unfixed, non-oscillation systematic parameters.
| request | JSON object (unused). |
Definition at line 282 of file NuDockServerBase.cpp.
|
inlineoverridevirtual |
No-op implementation — the server does not run own MCMC.
Implements FitterBase.
Definition at line 118 of file NuDockServerBase.h.
|
virtual |
Handle a "set_asimov" request.
Handle a "set_asimov" request.
Reweights all samples then clones the MC prediction as the "data". Prefit parameter central values are updated to match the current proposed values.
| request | JSON object (unused). |
Reweights all samples then clones the MC prediction as the "data". Prefit parameter central values are updated to match the current proposed values.
| request | JSON object (unused). |
Definition at line 119 of file NuDockServerBase.cpp.
|
virtual |
Handle a "set_parameters" request.
Handle a "set_parameters" request.
Expects the JSON payload to contain "sys_pars" and "osc_pars" maps. Oscillation parameters are converted from NuDock convention to MaCh3 convention before being applied. Samples are reweighted after all parameters are updated.
| request | JSON object with "sys_pars" and "osc_pars" entries. |
Expects the JSON payload to contain "sys_pars" and "osc_pars" maps. Oscillation parameters are converted from NuDock convention to MaCh3 convention before being applied. Samples are reweighted after all parameters are updated.
| request | JSON object with "sys_pars" and "osc_pars" entries. |
Definition at line 67 of file NuDockServerBase.cpp.
| void NuDockServerBase::setup | ( | ) |
Perform one-time server setup.
Perform one-time server setup.
Resizes internal likelihood storage vectors and reads the "Verbose" and "AddPriorLLH" flags from the NuDock configuration block.
Resizes internal likelihood storage vectors and reads the "Verbose" and "AddPriorLLH" flags from the NuDock configuration block.
Definition at line 19 of file NuDockServerBase.cpp.
|
protected |
If true, systematic prior likelihoods are added to the total LLH.
Definition at line 124 of file NuDockServerBase.h.
|
protected |
Flag controlling verbose logging of server operations.
Definition at line 122 of file NuDockServerBase.h.