Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TBackCompFitter.h
Go to the documentation of this file.
1// @(#)root/hist:$Id$
2// Author: L. Moneta 08/2008
3
4/**********************************************************************
5 * *
6 * Copyright (c) 2008 ROOT Foundation, CERN/PH-SFT *
7 * *
8 **********************************************************************/
9
10#ifndef ROOT_TBackCompFitter_H_
11#define ROOT_TBackCompFitter_H_
12
13#include "TVirtualFitter.h"
14#include "Fit/BasicFCN.h"
15#include "Fit/FitResult.h"
16#include "Fit/Fitter.h"
17#include "Math/IFunctionfwd.h"
18#include <vector>
19
20/*
21 TVirtualFitter backward compatibility implementation using new ROOT::Fit::Fitter
22*/
23
24class TGraph;
25class TFitResult;
26
27namespace ROOT {
28 namespace Fit {
29 class FitData;
30 }
31 namespace Math {
32 class Minimizer;
33 }
34}
35
36
38
39public:
40
41
42
44
45 //TBackCompFitter(ROOT::Fit::Fitter & fitter, ROOT::Fit::FitData * );
46 TBackCompFitter( const std::shared_ptr<ROOT::Fit::Fitter> & fitter, const std::shared_ptr<ROOT::Fit::FitData> & data );
47
48 ~TBackCompFitter() override;
49
50public:
51
53 kCanDeleteLast = BIT(9) // object can be deleted before creating a new one
54 };
55
56 // inherited interface
57 Double_t Chisquare(Int_t npar, Double_t *params) const override;
58 void Clear(Option_t *option="") override;
59 Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs) override;
60 void FixParameter(Int_t ipar) override;
61
62 void GetConfidenceIntervals(Int_t n, Int_t ndim, const Double_t *x, Double_t *ci, Double_t cl=0.95) override;
63 void GetConfidenceIntervals(TObject *obj, Double_t cl=0.95) override;
64
65 Double_t *GetCovarianceMatrix() const override;
67 Int_t GetErrors(Int_t ipar,Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &globcc) const override;
68 Int_t GetNumberTotalParameters() const override;
69 Int_t GetNumberFreeParameters() const override;
70
71 Double_t GetParError(Int_t ipar) const override;
72 Double_t GetParameter(Int_t ipar) const override;
73 Int_t GetParameter(Int_t ipar,char *name,Double_t &value,Double_t &verr,Double_t &vlow, Double_t &vhigh) const override;
74 const char *GetParName(Int_t ipar) const override;
75 Int_t GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const override;
76 Double_t GetSumLog(Int_t i) override;
77
78 Bool_t IsFixed(Int_t ipar) const override ;
79
80 void PrintResults(Int_t level, Double_t amin) const override;
81 void ReleaseParameter(Int_t ipar) override;
82 void SetFitMethod(const char *name) override;
83 Int_t SetParameter(Int_t ipar,const char *parname,Double_t value,Double_t verr,Double_t vlow, Double_t vhigh) override;
84
85 void SetFCN(void (*fcn)(Int_t &, Double_t *, Double_t &f, Double_t *, Int_t) ) override;
86
87 /// For using interpreted function passed by the user
88 virtual void SetMethodCall(TMethodCall * m) { fMethodCall = m; }
89
90 /// Get reference to Fit configuration (NOTE: it will be invalid when class is deleted)
91 ROOT::Fit::FitConfig & GetFitConfig() { return fFitter->Config(); }
92
93 /// Get reference to Fit Result object (NOTE: it will be invalid when class is deleted)
94 const ROOT::Fit::FitResult & GetFitResult() const { return fFitter->Result(); }
95
96 /// Get a copy of the Fit result returning directly a new TFitResult
97 TFitResult * GetTFitResult() const;
98
99 /// Get reference to Fit Data object (NOTE: it will be invalid when class is deleted)
100 const ROOT::Fit::FitData & GetFitData() const { return *fFitData; }
101
102 // Return pointer to last used minimizer
104
105 // Return pointer to last used objective function
107
108 // Scan likelihood value of parameter and fill the given graph.
109 bool Scan(unsigned int ipar, TGraph * gr, double xmin = 0, double xmax = 0);
110
111 // scan likelihood value for two parameters and fill the given graph.
112 // bool Scan2D(unsigned int ipar, unsigned int jpar, TGraph2D * gr,
113 // double xmin = 0, double xmax = 0, double ymin = 0, double ymax = 0);
114
115 // Create contour of two parameters around the minimum
116 // pass as option confidence level: default is a value of 0.683
117 bool Contour(unsigned int ipar, unsigned int jpar, TGraph * gr , double confLevel = 0.683);
118
119 // Set FCN using new interface
121
122 // Recreate minimizer and FCN for TMinuit fits and standard printout
123 void ReCreateMinimizer();
124
125
126protected:
127
128 bool ValidParameterIndex(int ipar) const;
129 void DoSetDimension();
130
131private:
132
133 //ROOT::Fit::FitData * fFitData;
134 std::shared_ptr<ROOT::Fit::FitData> fFitData; ///<! Data of the fit
135 std::shared_ptr<ROOT::Fit::Fitter> fFitter; ///<! Pointer to fitter object
139 mutable std::vector<double> fCovar; ///< Cached covariance matrix (NxN)
140
141
142
143 ClassDefOverride(TBackCompFitter,1) // Class providing backward compatibility for fitting by implementing the TVirtualFitter interface
144
145};
146
147
148
149#endif //ROOT_TBackCompFitter_H_
#define f(i)
Definition RSha256.hxx:104
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
double Double_t
Definition RtypesCore.h:59
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:85
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition TGX11.cxx:110
float xmin
float xmax
Class describing the configuration of the fit, options and parameter settings using the ROOT::Fit::Pa...
Definition FitConfig.h:47
Base class for all the fit data types: Stores the coordinates and the DataOptions.
Definition FitData.h:56
class containing the result of the fit and all the related information (fitted parameter values,...
Definition FitResult.h:47
Documentation for the abstract class IBaseFunctionMultiDim.
Definition IFunction.h:61
Abstract Minimizer class, defining the interface for the various minimizer (like Minuit2,...
Definition Minimizer.h:117
Backward compatible implementation of TVirtualFitter.
const ROOT::Fit::FitResult & GetFitResult() const
Get reference to Fit Result object (NOTE: it will be invalid when class is deleted)
const char * GetParName(Int_t ipar) const override
Return name of parameter ipar.
void GetConfidenceIntervals(Int_t n, Int_t ndim, const Double_t *x, Double_t *ci, Double_t cl=0.95) override
Computes point-by-point confidence intervals for the fitted function.
void ReleaseParameter(Int_t ipar) override
Release a fit parameter.
Double_t GetParError(Int_t ipar) const override
Parameter error.
virtual void SetMethodCall(TMethodCall *m)
For using interpreted function passed by the user.
ROOT::Math::Minimizer * fMinimizer
void DoSetDimension()
Private method to set dimension in objective function.
void SetFCN(void(*fcn)(Int_t &, Double_t *, Double_t &f, Double_t *, Int_t)) override
Override setFCN to use the Adapter to Minuit2 FCN interface To set the address of the minimization fu...
ROOT::Math::Minimizer * GetMinimizer() const
Return a pointer to the minimizer.
void Clear(Option_t *option="") override
Clear resources for consecutive fits.
void PrintResults(Int_t level, Double_t amin) const override
Print the fit result.
Int_t GetStats(Double_t &amin, Double_t &edm, Double_t &errdef, Int_t &nvpar, Int_t &nparx) const override
Get fit statistical information.
Int_t GetNumberFreeParameters() const override
ROOT::Fit::FitConfig & GetFitConfig()
Get reference to Fit configuration (NOTE: it will be invalid when class is deleted)
TBackCompFitter()
Constructor needed by TVirtualFitter interface.
void FixParameter(Int_t ipar) override
Fix the parameter.
void SetFitMethod(const char *name) override
Set fit method (chi2 or likelihood).
Double_t GetCovarianceMatrixElement(Int_t i, Int_t j) const override
Get error matrix element (return all zero if matrix is not available)
Bool_t IsFixed(Int_t ipar) const override
Query if parameter ipar is fixed.
std::shared_ptr< ROOT::Fit::FitData > fFitData
! Data of the fit
ROOT::Math::IParamMultiFunction * fModelFunc
Int_t GetNumberTotalParameters() const override
Number of total parameters.
Int_t ExecuteCommand(const char *command, Double_t *args, Int_t nargs) override
Execute the command (Fortran Minuit compatible interface)
TFitResult * GetTFitResult() const
Get a copy of the Fit result returning directly a new TFitResult.
void ReCreateMinimizer()
Recreate a minimizer instance using the function and data set objective function in minimizers functi...
std::shared_ptr< ROOT::Fit::Fitter > fFitter
! Pointer to fitter object
Int_t GetErrors(Int_t ipar, Double_t &eplus, Double_t &eminus, Double_t &eparab, Double_t &globcc) const override
Get fit errors.
std::vector< double > fCovar
Cached covariance matrix (NxN)
bool ValidParameterIndex(int ipar) const
Check if ipar is a valid parameter index.
bool Contour(unsigned int ipar, unsigned int jpar, TGraph *gr, double confLevel=0.683)
Create a 2D contour around the minimum for the parameter ipar and jpar if a minimum does not exist or...
Double_t GetSumLog(Int_t i) override
Sum of log (un-needed)
~TBackCompFitter() override
Destructor - delete the managed objects.
Double_t Chisquare(Int_t npar, Double_t *params) const override
Do chisquare calculations in case of likelihood fits Do evaluation a the minimum only.
const ROOT::Fit::FitData & GetFitData() const
Get reference to Fit Data object (NOTE: it will be invalid when class is deleted)
ROOT::Math::IMultiGenFunction * GetObjFunction() const
Return a pointer to the objective function (FCN) If fitting directly using TBackCompFitter the pointe...
virtual void SetObjFunction(ROOT::Math::IMultiGenFunction *f)
Set the objective function for fitting Needed if fitting directly using TBackCompFitter class The cla...
bool Scan(unsigned int ipar, TGraph *gr, double xmin=0, double xmax=0)
Scan parameter ipar between value of xmin and xmax A graph must be given which will be on return fill...
ROOT::Math::IMultiGenFunction * fObjFunc
Double_t GetParameter(Int_t ipar) const override
Parameter value.
Int_t SetParameter(Int_t ipar, const char *parname, Double_t value, Double_t verr, Double_t vlow, Double_t vhigh) override
Set (add) a new fit parameter passing initial value, step size (verr) and parameter limits if vlow > ...
Double_t * GetCovarianceMatrix() const override
Get the error matrix in a pointer to a NxN array.
Extends the ROOT::Fit::Result class with a TNamed inheritance providing easy possibility for I/O.
Definition TFitResult.h:34
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
Method or function calling interface.
Definition TMethodCall.h:37
Mother of all ROOT objects.
Definition TObject.h:41
Abstract Base Class for Fitting.
TMethodCall * fMethodCall
Pointer to MethodCall in case of interpreted function.
RooCmdArg Minimizer(const char *type, const char *alg=nullptr)
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
TGraphErrors * gr
Definition legend1.C:25
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
Definition HFitImpl.cxx:133
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
TMarker m
Definition textangle.C:8