Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
LikelihoodGradientWrapper.h
Go to the documentation of this file.
1/*
2 * Project: RooFit
3 * Authors:
4 * PB, Patrick Bos, Netherlands eScience Center, p.bos@esciencecenter.nl
5 *
6 * Copyright (c) 2021, CERN
7 *
8 * Redistribution and use in source and binary forms,
9 * with or without modification, are permitted according to the terms
10 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)
11 */
12
13#ifndef ROOT_ROOFIT_TESTSTATISTICS_LikelihoodGradientWrapper
14#define ROOT_ROOFIT_TESTSTATISTICS_LikelihoodGradientWrapper
15
17
19#include <Math/IFunctionfwd.h>
21#include "Math/Util.h"
22
23#include <vector>
24#include <memory> // shared_ptr
25
26// forward declaration
27class RooMinimizer;
28
29namespace RooFit {
30namespace TestStatistics {
31
32// forward declaration
33class RooAbsL;
34struct WrapperCalculationCleanFlags;
35
37
39protected:
40 LikelihoodGradientWrapper(std::shared_ptr<RooAbsL> likelihood,
41 std::shared_ptr<WrapperCalculationCleanFlags> calculation_is_clean, std::size_t N_dim,
42 RooMinimizer *minimizer, SharedOffset offset);
43
44public:
45 virtual ~LikelihoodGradientWrapper() = default;
48
49 static std::unique_ptr<LikelihoodGradientWrapper>
50 create(LikelihoodGradientMode likelihoodGradientMode, std::shared_ptr<RooAbsL> likelihood,
51 std::shared_ptr<WrapperCalculationCleanFlags> calculationIsClean, std::size_t nDim, RooMinimizer *minimizer,
53
54 virtual void fillGradient(double *grad) = 0;
55 virtual void
56 fillGradientWithPrevResult(double *grad, double *previous_grad, double *previous_g2, double *previous_gstep) = 0;
57
58 /// Synchronize minimizer settings with calculators in child classes.
59 virtual void synchronizeWithMinimizer(const ROOT::Math::MinimizerOptions &options);
60 virtual void synchronizeParameterSettings(const std::vector<ROOT::Fit::ParameterSettings> &parameter_settings);
62 const std::vector<ROOT::Fit::ParameterSettings> &parameter_settings) = 0;
63 /// Minuit passes in parameter values that may not conform to RooFit internal standards (like applying range
64 /// clipping), but that the specific calculator does need. This function can be implemented to receive these
65 /// Minuit-internal values.
66 virtual void updateMinuitInternalParameterValues(const std::vector<double> &minuit_internal_x);
67 virtual void updateMinuitExternalParameterValues(const std::vector<double> &minuit_external_x);
68
69 /// \brief Implement usesMinuitInternalValues to return true when you want Minuit to send this class Minuit-internal
70 /// values, or return false when you want "regular" Minuit-external values.
71 ///
72 /// Minuit internally uses a transformed parameter space to graciously handle externally mandated parameter range
73 /// boundaries. Transformation from Minuit-internal to external (i.e. "regular") parameters is done using
74 /// trigonometric functions that in some cases can cause a few bits of precision loss with respect to the original
75 /// parameter values. To circumvent this, Minuit also allows external gradient providers (like
76 /// LikelihoodGradientWrapper) to take the Minuit-internal parameter values directly, without transformation. This
77 /// way, the gradient provider (e.g. the implementation of this class) can handle transformation manually, possibly
78 /// with higher precision.
79 virtual bool usesMinuitInternalValues() = 0;
80
81 /// Reports whether or not the gradient is currently being calculated.
82 ///
83 /// This is used in MinuitFcnGrad to switch between LikelihoodWrapper implementations
84 /// inside and outside of a LikelihoodGradientJob calculation when the LikelihoodWrapper
85 /// used is LikelihoodJob. This is to prevent Jobs from being started within Jobs.
86 virtual bool isCalculating() = 0;
87
88protected:
89 std::shared_ptr<RooAbsL> likelihood_;
91 std::shared_ptr<WrapperCalculationCleanFlags> calculation_is_clean_;
93};
94
95} // namespace TestStatistics
96} // namespace RooFit
97
98#endif // ROOT_ROOFIT_TESTSTATISTICS_LikelihoodGradientWrapper
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
Documentation for the abstract class IBaseFunctionMultiDim.
Definition IFunction.h:61
Virtual base class for implementation of likelihood gradient calculation strategies.
virtual bool usesMinuitInternalValues()=0
Implement usesMinuitInternalValues to return true when you want Minuit to send this class Minuit-inte...
virtual bool isCalculating()=0
Reports whether or not the gradient is currently being calculated.
std::shared_ptr< WrapperCalculationCleanFlags > calculation_is_clean_
virtual void synchronizeWithMinimizer(const ROOT::Math::MinimizerOptions &options)
Synchronize minimizer settings with calculators in child classes.
virtual void updateMinuitInternalParameterValues(const std::vector< double > &minuit_internal_x)
Minuit passes in parameter values that may not conform to RooFit internal standards (like applying ra...
LikelihoodGradientWrapper(const LikelihoodGradientWrapper &)=delete
virtual void synchronizeParameterSettings(ROOT::Math::IMultiGenFunction *function, const std::vector< ROOT::Fit::ParameterSettings > &parameter_settings)=0
virtual void synchronizeParameterSettings(const std::vector< ROOT::Fit::ParameterSettings > &parameter_settings)
LikelihoodGradientWrapper & operator=(const LikelihoodGradientWrapper &)=delete
static std::unique_ptr< LikelihoodGradientWrapper > create(LikelihoodGradientMode likelihoodGradientMode, std::shared_ptr< RooAbsL > likelihood, std::shared_ptr< WrapperCalculationCleanFlags > calculationIsClean, std::size_t nDim, RooMinimizer *minimizer, SharedOffset offset)
Factory method.
virtual void fillGradientWithPrevResult(double *grad, double *previous_grad, double *previous_g2, double *previous_gstep)=0
virtual void updateMinuitExternalParameterValues(const std::vector< double > &minuit_external_x)
Wrapper class around ROOT::Fit:Fitter that provides a seamless interface between the minimizer functi...
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition JSONIO.h:26