Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
LikelihoodGradientJob.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_LikelihoodGradientJob
14#define ROOT_ROOFIT_TESTSTATISTICS_LikelihoodGradientJob
15
18
21#include "Minuit2/MnMatrix.h"
22
23#include <limits>
24#include <vector>
25
26namespace RooFit {
27namespace TestStatistics {
28
30public:
31 LikelihoodGradientJob(std::shared_ptr<RooAbsL> likelihood,
32 std::shared_ptr<WrapperCalculationCleanFlags> calculation_is_clean, std::size_t N_dim,
33 RooMinimizer *minimizer, SharedOffset offset);
34
35 void fillGradient(double *grad) override;
36 void fillGradientWithPrevResult(double *grad, double *previous_grad, double *previous_g2, double *previous_gstep,
37 double fValAtX) override;
38
39 void update_state() override;
40
42 bool isCalculating() override { return isCalculating_; };
43
44private:
45 void run_derivator(unsigned int i_component) const;
46
47 void synchronizeParameterSettingsImpl(const std::vector<ROOT::Fit::ParameterSettings> &parameter_settings) override;
48
49 void synchronizeWithMinimizer(const ROOT::Math::MinimizerOptions &options) override;
50 void setStrategy(int istrat);
51 void setStepTolerance(double step_tolerance) const;
52 void setGradTolerance(double grad_tolerance) const;
53 void setNCycles(unsigned int ncycles) const;
54 void setErrorLevel(double error_level) const;
55
56 void updateMinuitInternalParameterValues(const std::vector<double> &minuit_internal_x) override;
57
58 bool usesMinuitInternalValues() override;
59
60 // Job overrides:
61 void evaluate_task(std::size_t task) override;
62
68 void send_back_task_result_from_worker(std::size_t task) override;
70
73 void calculate_all();
74
75 // members
76
77 // mutables below are because ROOT::Math::IMultiGradFunction::DoDerivative is const
78 mutable std::vector<ROOT::Minuit2::DerivatorElement> grad_;
80
81 std::size_t N_tasks_ = 0;
82 std::size_t N_tasks_at_workers_ = 0;
83 std::vector<double> minuit_internal_x_;
84 /// Function value at minuit_internal_x_ as known by the master (NaN when unknown); broadcast
85 /// to workers so their NumericalDerivator setup can skip the central-point evaluation.
86 double fval_at_x_ = std::numeric_limits<double>::quiet_NaN();
87
88 mutable bool isCalculating_ = false;
89
91};
92
93} // namespace TestStatistics
94} // namespace RooFit
95
96#endif // ROOT_ROOFIT_LikelihoodGradientJob
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
interface class for defining the actual work that must be done
Definition Job.h:26
A contiguous byte buffer used as the unit of interprocess communication.
Definition Message.h:30
bool usesMinuitInternalValues() override
Implement usesMinuitInternalValues to return true when you want Minuit to send this class Minuit-inte...
void update_state() override
Virtual function to update any necessary state on workers.
std::vector< ROOT::Minuit2::DerivatorElement > grad_
void updateMinuitInternalParameterValues(const std::vector< double > &minuit_internal_x) override
Minuit passes in parameter values that may not conform to RooFit internal standards (like applying ra...
void run_derivator(unsigned int i_component) const
Calculation stuff (mostly duplicates of RooGradMinimizerFcn code):
double fval_at_x_
Function value at minuit_internal_x_ as known by the master (NaN when unknown); broadcast to workers ...
void send_back_task_result_from_worker(std::size_t task) override
void synchronizeWithMinimizer(const ROOT::Math::MinimizerOptions &options) override
Synchronize minimizer settings with calculators in child classes.
LikelihoodGradientJob(std::shared_ptr< RooAbsL > likelihood, std::shared_ptr< WrapperCalculationCleanFlags > calculation_is_clean, std::size_t N_dim, RooMinimizer *minimizer, SharedOffset offset)
void setStepTolerance(double step_tolerance) const
void setGradTolerance(double grad_tolerance) const
bool isCalculating() override
Reports whether or not the gradient is currently being calculated.
bool receive_task_result_on_master(const RooFit::MultiProcess::Message &message) override
void evaluate_task(std::size_t task) override
Job overrides:
void synchronizeParameterSettingsImpl(const std::vector< ROOT::Fit::ParameterSettings > &parameter_settings) override
void fillGradientWithPrevResult(double *grad, double *previous_grad, double *previous_g2, double *previous_gstep, double fValAtX) override
Virtual base class for implementation of likelihood gradient calculation strategies.
Wrapper class around ROOT::Math::Minimizer that provides a seamless interface between the minimizer f...
std::vector< ROOT::Math::KahanSum< double > > OffsetVec
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
Definition CodegenImpl.h:73