File indexing completed on 2025-01-18 10:10:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef ROOT_ROOFIT_TESTSTATISTICS_LikelihoodGradientWrapper
0014 #define ROOT_ROOFIT_TESTSTATISTICS_LikelihoodGradientWrapper
0015
0016 #include "RooFit/TestStatistics/SharedOffset.h"
0017
0018 #include <Fit/ParameterSettings.h>
0019 #include <Math/IFunctionfwd.h>
0020 #include "Math/MinimizerOptions.h"
0021 #include "Math/Util.h"
0022
0023 #include <vector>
0024 #include <memory> // shared_ptr
0025
0026
0027 class RooMinimizer;
0028
0029 namespace RooFit {
0030 namespace TestStatistics {
0031
0032
0033 class RooAbsL;
0034 struct WrapperCalculationCleanFlags;
0035
0036 enum class LikelihoodGradientMode { multiprocess };
0037
0038 class LikelihoodGradientWrapper {
0039 protected:
0040 LikelihoodGradientWrapper(std::shared_ptr<RooAbsL> likelihood,
0041 std::shared_ptr<WrapperCalculationCleanFlags> calculation_is_clean, std::size_t N_dim,
0042 RooMinimizer *minimizer, SharedOffset offset);
0043
0044 public:
0045 virtual ~LikelihoodGradientWrapper() = default;
0046 LikelihoodGradientWrapper(const LikelihoodGradientWrapper &) = delete;
0047 LikelihoodGradientWrapper &operator=(const LikelihoodGradientWrapper &) = delete;
0048
0049 static std::unique_ptr<LikelihoodGradientWrapper>
0050 create(LikelihoodGradientMode likelihoodGradientMode, std::shared_ptr<RooAbsL> likelihood,
0051 std::shared_ptr<WrapperCalculationCleanFlags> calculationIsClean, std::size_t nDim, RooMinimizer *minimizer,
0052 SharedOffset offset);
0053
0054 virtual void fillGradient(double *grad) = 0;
0055 virtual void
0056 fillGradientWithPrevResult(double *grad, double *previous_grad, double *previous_g2, double *previous_gstep) = 0;
0057
0058
0059 virtual void synchronizeWithMinimizer(const ROOT::Math::MinimizerOptions &options);
0060 virtual void synchronizeParameterSettings(const std::vector<ROOT::Fit::ParameterSettings> ¶meter_settings);
0061 virtual void synchronizeParameterSettings(ROOT::Math::IMultiGenFunction *function,
0062 const std::vector<ROOT::Fit::ParameterSettings> ¶meter_settings) = 0;
0063
0064
0065
0066 virtual void updateMinuitInternalParameterValues(const std::vector<double> &minuit_internal_x);
0067 virtual void updateMinuitExternalParameterValues(const std::vector<double> &minuit_external_x);
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079 virtual bool usesMinuitInternalValues() = 0;
0080
0081
0082
0083
0084
0085
0086 virtual bool isCalculating() = 0;
0087
0088 protected:
0089 std::shared_ptr<RooAbsL> likelihood_;
0090 RooMinimizer *minimizer_;
0091 std::shared_ptr<WrapperCalculationCleanFlags> calculation_is_clean_;
0092 SharedOffset shared_offset_;
0093 };
0094
0095 }
0096 }
0097
0098 #endif