|
Laura++
3.6.0
A maximum likelihood fitting package for performing Dalitz-plot analysis.
|
Go to the documentation of this file.
37 #include "TVirtualFitter.h"
49 extern void logLikeFun( Int_t& npar, Double_t* gin, Double_t& f, Double_t* par, Int_t iflag );
54 outputLevel_ { verbosity }
56 TVirtualFitter::SetDefaultFitter( "Minuit" );
57 minuit_ = TVirtualFitter::Fitter( nullptr, maxPar_ );
60 std::array<Double_t, 1> argL { static_cast<Double_t >( outputLevel_ ) };
61 minuit_->ExecuteCommand( "SET PRINT", argL.data(), argL.size() );
63 minuit_->ExecuteCommand( "SET NOWARNINGS", argL.data(), 0 );
72 std::cout << "INFO in LauMinuit::fit : We are going to calculate the asymmetric fit errors."
74 std::cout << " : This will, in general, significantly increase the CPU time required for fitting."
77 std::cout << "INFO in LauMinuit::fit : Only parabolic errors will be calculated."
87 minuit_->SetObjectFit( fitObj );
94 std::cout << "INFO in LauMinuit::initialise : Setting fit parameters" << std::endl;
95 std::cout << " : Total number of parameters = " << nParams_
100 const Double_t defaultError( 0.01 );
103 for ( UInt_t i = 0; i < nParams_; ++i ) {
105 Double_t initVal = params_[i]->initValue();
106 Double_t initErr = params_[i]->error();
108 if ( initErr == 0.0 ) {
109 if ( initVal == 0.0 ) {
110 initErr = defaultError;
111 } else if ( TMath::Abs( initErr / initVal ) < 1e-6 ) {
112 initErr = TMath::Abs( defaultError * initVal );
115 Double_t minVal = params_[i]->minValue();
116 Double_t maxVal = params_[i]->maxValue();
118 if ( this-> twoStageFit() && secondStage == kTRUE ) {
121 Bool_t fixVar = params_[i]->fixed();
124 std::cout << " : Setting parameter " << i << " called "
125 << name << " to have initial value " << initVal << ", error " << initErr
126 << " and range " << minVal << " to " << maxVal << std::endl;
128 minuit_->SetParameter( i, name, initVal, initErr, minVal, maxVal );
131 if ( fixVar == kTRUE ) {
133 std::cout << " : Fixing parameter " << i << std::endl;
147 std::array<Double_t, 1> argL { 0.5 };
161 std::array<Double_t, 2> arglist {
175 std::cerr << "ERROR in LauMinuit::minimise : Error in minimising loglike." << std::endl;
183 std::cout << "INFO in LauMinuit::minimise : Error matrix status after MIGRAD is: "
197 std::cerr << "ERROR in LauMinuit::minimise : Error in HESSE routine." << std::endl;
206 std::cout << "INFO in LauMinuit::minimise : Error matrix status after HESSE is: "
222 std::cerr << "ERROR in LauMinuit::minimise : Error in MINOS routine."
232 std::cout << "INFO in LauMinuit::minimise : Final error matrix status is: "
248 Double_t* covMatrix = minuit_->GetCovarianceMatrix();
259 for ( UInt_t i { 0 }; i < nParams_; ++i ) {
271 for ( UInt_t i { 0 }; i < nParams_; ++i ) {
274 minuit_->ReleaseParameter( i );
283 for ( UInt_t i { 0 }; i < nParams_; ++i ) {
286 Double_t error { 0.0 };
289 Double_t globalcc { 0.0 };
292 params_[i]->globalCorrelationCoeff( globalcc );
297 void logLikeFun( Int_t& npar, Double_t* , Double_t& f, Double_t* par, Int_t )
virtual Double_t getTotNegLogLikelihood()=0 Calculate the new value of the negative log likelihood.
File containing declaration of LauFitter class.
virtual void releaseSecondStageParameters() Release parameters marked as "second stage".
Struct to store fit status information.
Double_t value() const The value of the parameter.
File containing declaration of LauParamFixed class.
FitStatus fitStatus_ The status of the fit.
File containing declaration of LauParameter class.
virtual void initialise(LauFitObject *fitObj, const std::vector< LauParameter * > ¶meters) Initialise the fitter, setting the information on the parameters.
UInt_t nFreeParams_ The number of free parameters.
virtual LauFitObject * getFitObject() Get the object that controls the calculation of the likelihood.
virtual void setParsFromMinuit(Double_t *par, Int_t npar)=0 This function sets the parameter values from Minuit.
TMatrixD covMatrix_ The covariance matrix.
static LauAbsFitter & fitter() Method that provides access to the singleton fitter.
File containing declaration of LauMinuit class.
Bool_t secondStage() const Check whether the parameter should be floated only in the second stage of a two stage fit.
The abstract interface to the fitter.
Bool_t useAsymmFitErrors_ Option to use asymmetric errors.
virtual Bool_t twoStageFit() const Determine whether the two-stage fit is enabled.
virtual LauFitObject * getFitObject()=0 Get the object that controls the calculation of the likelihood.
Double_t posError() const The upper error on the parameter.
TVirtualFitter * minuit_ The interface to Minuit.
virtual const FitStatus & minimise() Perform the minimisation of the fit function.
const TString & name() const The parameter name.
Double_t NLL The negative log-likelihood.
std::vector< LauParameter * > params_ The fit parameters.
Predicate to allow counting of the number of fixed parameters.
Double_t error() const The error on the parameter.
LauOutputLevel Enumeration to define verbosity level for various printouts.
LauMinuit(const UInt_t maxPar=100, const LauOutputLevel verbosity=LauOutputLevel::Standard) Constructor.
UInt_t nParams_ The total number of parameters.
const LauOutputLevel outputLevel_ The verbosity level of the fitter.
virtual void withinAsymErrorCalc(const Bool_t inAsymErrCalc) Mark that the fit is calculating asymmetric errors.
The abstract interface for the objects that control the calculation of the likelihood.
Double_t EDM The estimated distance to the minimum.
Double_t negError() const The lower error on the parameter.
virtual void fixSecondStageParameters() Fix parameters marked as "second stage".
File containing declaration of LauFitObject class.
Int_t status The status code of the fit.
virtual void updateParameters() Update the values and errors of the parameters based on the fit minimum.
|