musrfit  1.9.2
PFitter Class Reference

#include <PFitter.h>

Collaboration diagram for PFitter:

Public Member Functions

 PFitter (PMsrHandler *runInfo, PRunListCollection *runListCollection, Bool_t chisq_only=false)
 
virtual ~PFitter ()
 
Bool_t IsValid ()
 
Bool_t IsScanOnly ()
 
Bool_t HasConverged ()
 
Bool_t DoFit ()
 

Private Member Functions

void GetPhaseParams ()
 
PIntVector GetParFromFun (const TString funStr)
 
PIntVector GetParFromMap (const TString mapStr)
 
Bool_t CheckCommands ()
 
Bool_t SetParameters ()
 
Bool_t ExecuteContours ()
 
Bool_t ExecuteFitRange (UInt_t lineNo)
 
Bool_t ExecuteFix (UInt_t lineNo)
 
Bool_t ExecuteHesse ()
 
Bool_t ExecuteMigrad ()
 
Bool_t ExecuteMinimize ()
 
Bool_t ExecuteMinos ()
 
Bool_t ExecutePlot ()
 
Bool_t ExecutePrintLevel (UInt_t lineNo)
 
Bool_t ExecuteRelease (UInt_t lineNo)
 
Bool_t ExecuteRestore ()
 
Bool_t ExecuteScan ()
 
Bool_t ExecuteSave (Bool_t first)
 
Bool_t ExecuteSimplex ()
 
void PrepareSector (PDoubleVector &param, PDoubleVector &error)
 
Bool_t ExecuteSector (std::ofstream &fout)
 
Double_t MilliTime ()
 

Private Attributes

Bool_t fIsValid
 flag. true: the fit is valid. More...
 
Bool_t fIsScanOnly
 flag. true: scan along some parameters (no fitting). More...
 
Bool_t fConverged
 flag. true: the fit has converged. More...
 
Bool_t fChisqOnly
 flag. true: calculate chi^2 only (no fitting). More...
 
Bool_t fUseChi2
 flag. true: chi^2 fit. false: log-max-likelihood More...
 
UInt_t fPrintLevel
 tag, showing the level of messages whished. 0=minimum, 1=standard, 2=maximum More...
 
UInt_t fStrategy
 fitting strategy (see minuit2 manual). More...
 
PMsrHandlerfRunInfo
 pointer to the msr-file handler More...
 
PRunListCollectionfRunListCollection
 pointer to the run list collection More...
 
PMsrParamList fParams
 msr-file parameters More...
 
PMsrLines fCmdLines
 all the Minuit commands from the msr-file More...
 
PIntPairVector fCmdList
 command list, first=cmd, second=cmd line index More...
 
std::unique_ptr< PFitterFcnfFitterFcn
 pointer to the fitter function object More...
 
ROOT::Minuit2::MnUserParameters fMnUserParams
 minuit2 input parameter list More...
 
std::unique_ptr< ROOT::Minuit2::FunctionMinimum > fFcnMin
 function minimum object More...
 
Bool_t fScanAll
 flag. false: single parameter scan, true: not implemented yet (see MnScan/MnContours in the minuit2 user manual) More...
 
UInt_t fScanParameter [2]
 scan parameter. idx=0: used for scan and contour, idx=1: used for contour (see MnScan/MnContours in the minuit2 user manual) More...
 
UInt_t fScanNoPoints
 number of points in a scan/contour (see MnScan/MnContours in the minuit2 user manual) More...
 
Double_t fScanLow
 scan range low. default=0.0 which means 2 std dev. (see MnScan/MnContours in the minuit2 user manual) More...
 
Double_t fScanHigh
 scan range high. default=0.0 which means 2 std dev. (see MnScan/MnContours in the minuit2 user manual) More...
 
PDoublePairVector fScanData
 keeps the scan/contour data More...
 
PDoublePairVector fOriginalFitRange
 keeps the original fit range in case there is a range command in the COMMAND block More...
 
PStringVector fElapsedTime
 
Bool_t fSectorFlag
 sector command present flag More...
 
std::vector< PSectorChisqfSector
 stores all chisq/maxLH sector information More...
 
std::vector< bool > fPhase
 flag array in which an entry is true if the related parameter value is a phase More...
 

Detailed Description

Interface class to minuit2.

Definition at line 111 of file PFitter.h.

Constructor & Destructor Documentation

◆ PFitter()

PFitter::PFitter ( PMsrHandler runInfo,
PRunListCollection runListCollection,
Bool_t  chisq_only = false 
)

Constructor.

Parameters
runInfopointer of the msr-file handler
runListCollectionpointer of the run list collection (pre-processed historgrams)
chisq_onlyflag: true=calculate chisq only (no fitting)

Definition at line 267 of file PFitter.cpp.

References CheckCommands(), fCmdLines, fConverged, fFitterFcn, fIsScanOnly, fOriginalFitRange, fParams, fPrintLevel, fRunInfo, fScanAll, fScanHigh, fScanLow, fScanNoPoints, fScanParameter, fSectorFlag, fStrategy, fUseChi2, PMsrGlobalBlock::GetFitRange(), PMsrHandler::GetMsrCommands(), PMsrHandler::GetMsrGlobal(), PMsrHandler::GetMsrParamList(), PMsrHandler::GetMsrRunList(), GetPhaseParams(), and PMUSR_UNDEFINED.

◆ ~PFitter()

PFitter::~PFitter ( )
virtual

Destructor.

Definition at line 326 of file PFitter.cpp.

References fCmdList, fElapsedTime, and fScanData.

Member Function Documentation

◆ CheckCommands()

Bool_t PFitter::CheckCommands ( )
private

◆ DoFit()

◆ ExecuteContours()

Bool_t PFitter::ExecuteContours ( )
private

Execute the minuit2 contour command. Makes sure that a valid minuit2 minimum is present.

return: true if the contour command could be executed successfully, otherwise returns false.

Definition at line 1566 of file PFitter.cpp.

References fFcnMin, fFitterFcn, fScanData, fScanNoPoints, and fScanParameter.

Referenced by DoFit().

◆ ExecuteFitRange()

Bool_t PFitter::ExecuteFitRange ( UInt_t  lineNo)
private

Change the fit range via command block.

Parameters
lineNothe line number of the command block

return: true if done, otherwise returns false.

Definition at line 1601 of file PFitter.cpp.

References fCmdLines, fOriginalFitRange, fRunInfo, fRunListCollection, PMsrHandler::GetMsrRunList(), and PRunListCollection::SetFitRange().

Referenced by DoFit().

◆ ExecuteFix()

Bool_t PFitter::ExecuteFix ( UInt_t  lineNo)
private

Fix parameter list given at lineNo of the command block.

Parameters
lineNothe line number of the command block

return: true if done, otherwise returns false.

Definition at line 1672 of file PFitter.cpp.

References fCmdLines, and fMnUserParams.

Referenced by DoFit().

◆ ExecuteHesse()

Bool_t PFitter::ExecuteHesse ( )
private

Execute the minuit2 hesse command.

return: true if the hesse command could be executed successfully, otherwise returns false.

Definition at line 1710 of file PFitter.cpp.

References fElapsedTime, fFitterFcn, fMnUserParams, fParams, fPrintLevel, fRunInfo, MilliTime(), PMsrHandler::SetMsrParamPosErrorPresent(), and PMsrHandler::SetMsrParamStep().

Referenced by DoFit().

◆ ExecuteMigrad()

Bool_t PFitter::ExecuteMigrad ( )
private

Execute the minuit2 migrad command.

return: true if the migrad command could be executed successfully, otherwise returns false.

Definition at line 1759 of file PFitter.cpp.

References fConverged, fElapsedTime, fFcnMin, fFitterFcn, fIsValid, fMnUserParams, fParams, fPhase, fPrintLevel, fRunInfo, fStrategy, MilliTime(), PMsrHandler::SetMsrParamPosErrorPresent(), PMsrHandler::SetMsrParamStep(), PMsrHandler::SetMsrParamValue(), PMsrHandler::SetMsrStatisticMin(), and PMsrHandler::SetMsrStatisticNdf().

Referenced by DoFit().

◆ ExecuteMinimize()

Bool_t PFitter::ExecuteMinimize ( )
private

Execute the minuit2 minimize command.

return: true if the minimize command could be executed successfully, otherwise returns false.

Definition at line 1835 of file PFitter.cpp.

References fConverged, fElapsedTime, fFcnMin, fFitterFcn, fIsValid, fMnUserParams, fParams, fPhase, fPrintLevel, fRunInfo, fStrategy, MilliTime(), PMsrHandler::SetMsrParamPosErrorPresent(), PMsrHandler::SetMsrParamStep(), PMsrHandler::SetMsrParamValue(), PMsrHandler::SetMsrStatisticMin(), and PMsrHandler::SetMsrStatisticNdf().

Referenced by DoFit().

◆ ExecuteMinos()

Bool_t PFitter::ExecuteMinos ( )
private

Execute the minuit2 minos command.

return: true if the minos command could be executed successfully, otherwise returns false.

Definition at line 1912 of file PFitter.cpp.

References fElapsedTime, fFcnMin, fFitterFcn, fMnUserParams, fParams, fRunInfo, MilliTime(), PMsrHandler::ParameterInUse(), PMsrHandler::SetMsrParamPosError(), PMsrHandler::SetMsrParamPosErrorPresent(), and PMsrHandler::SetMsrParamStep().

Referenced by DoFit().

◆ ExecutePlot()

Bool_t PFitter::ExecutePlot ( )
private

Execute the minuit2 plot command.

return: true.

Definition at line 1981 of file PFitter.cpp.

References fScanData.

Referenced by DoFit().

◆ ExecutePrintLevel()

Bool_t PFitter::ExecutePrintLevel ( UInt_t  lineNo)
private

Set the print level.

Parameters
lineNothe line number of the command block

return: true if done, otherwise returns false.

Definition at line 2001 of file PFitter.cpp.

References fCmdLines, and fPrintLevel.

Referenced by DoFit().

◆ ExecuteRelease()

Bool_t PFitter::ExecuteRelease ( UInt_t  lineNo)
private

Release parameter list given at lineNo of the command block.

Parameters
lineNothe line number of the command block

return: true if done, otherwise returns false.

Definition at line 2059 of file PFitter.cpp.

References fCmdLines, and fMnUserParams.

Referenced by DoFit().

◆ ExecuteRestore()

Bool_t PFitter::ExecuteRestore ( )
private

Release all fixed parameters

return: true.

Definition at line 2101 of file PFitter.cpp.

References fMnUserParams.

Referenced by DoFit().

◆ ExecuteSave()

◆ ExecuteScan()

Bool_t PFitter::ExecuteScan ( )
private

Execute the minuit2 scan command.

return: true.

Definition at line 2123 of file PFitter.cpp.

References fConverged, fFitterFcn, fMnUserParams, fScanAll, fScanData, fScanHigh, fScanLow, fScanNoPoints, and fScanParameter.

Referenced by DoFit().

◆ ExecuteSector()

Bool_t PFitter::ExecuteSector ( std::ofstream &  fout)
private

Write all chisq/maxLH sector information to MINUIT.OUTPUT and dump it to stdout.

return: if the sector command was successful, otherwise return flase.

Definition at line 2726 of file PFitter.cpp.

References fSector, and fUseChi2.

Referenced by ExecuteSave().

◆ ExecuteSimplex()

Bool_t PFitter::ExecuteSimplex ( )
private

Execute the minuit2 simplex command.

return: true if the simplex command could be executed successfully, otherwise returns false.

Definition at line 2536 of file PFitter.cpp.

References fConverged, fElapsedTime, fFcnMin, fFitterFcn, fIsValid, fMnUserParams, fParams, fPhase, fPrintLevel, fRunInfo, fStrategy, MilliTime(), PMsrHandler::SetMsrParamPosErrorPresent(), PMsrHandler::SetMsrParamStep(), PMsrHandler::SetMsrParamValue(), PMsrHandler::SetMsrStatisticMin(), and PMsrHandler::SetMsrStatisticNdf().

Referenced by DoFit().

◆ GetParFromFun()

PIntVector PFitter::GetParFromFun ( const TString  funStr)
private

Extract from string funX the function number. Base on the function number the paramter numbers will be collected.

Parameters
funStrstring of the form funX, where X is the function number
Returns
a vector of all the parameter numbers related to funX

Definition at line 430 of file PFitter.cpp.

References fRunInfo, PMsrHandler::GetMsrFunctions(), and GetParFromMap().

Referenced by GetPhaseParams().

◆ GetParFromMap()

PIntVector PFitter::GetParFromMap ( const TString  mapStr)
private

Extract from string mapX the map number. Based on the map number the parameter numbers will be collected.

Parameters
mapStrstring of the form mapX, where X is the map number
Returns
a vector of all the parameter numbers related to mapX

Definition at line 497 of file PFitter.cpp.

References fRunInfo, and PMsrHandler::GetMsrRunList().

Referenced by GetParFromFun(), and GetPhaseParams().

◆ GetPhaseParams()

void PFitter::GetPhaseParams ( )
private

Checks which parameters are phases. This information is needed to restrict the phases to the intervall -360 to +360 degrees.

Definition at line 342 of file PFitter.cpp.

References fPhase, fRunInfo, PMsrHandler::GetMsrTheory(), PMsrHandler::GetNoOfParams(), GetParFromFun(), and GetParFromMap().

Referenced by PFitter().

◆ HasConverged()

Bool_t PFitter::HasConverged ( )
inline

Definition at line 119 of file PFitter.h.

References fConverged.

◆ IsScanOnly()

Bool_t PFitter::IsScanOnly ( )
inline

Definition at line 118 of file PFitter.h.

References fIsScanOnly.

◆ IsValid()

Bool_t PFitter::IsValid ( )
inline

Definition at line 117 of file PFitter.h.

References fIsValid.

Referenced by DoFit().

◆ MilliTime()

Double_t PFitter::MilliTime ( )
private

return:

Definition at line 2782 of file PFitter.cpp.

Referenced by ExecuteHesse(), ExecuteMigrad(), ExecuteMinimize(), ExecuteMinos(), and ExecuteSimplex().

◆ PrepareSector()

void PFitter::PrepareSector ( PDoubleVector param,
PDoubleVector error 
)
private

Collect all the necessary chisq/maxLH sector information.

Parameters
paramparameter value vector of the converged fit.
errorstep value vector of the converged fit.

Definition at line 2613 of file PFitter.cpp.

References fFitterFcn, fRunInfo, fRunListCollection, fSector, fUseChi2, PMsrHandler::GetMsrRunList(), PMsrHandler::GetNoOfFitParameters(), PRunListCollection::GetSingleRunChisq(), PRunListCollection::GetSingleRunMaximumLikelihood(), and PRunListCollection::SetFitRange().

Referenced by ExecuteSave().

◆ SetParameters()

Bool_t PFitter::SetParameters ( )
private

Feeds the internal minuit2 fit parameters. It also makes sure that unused parameters are fixed.

return: true.

Definition at line 1518 of file PFitter.cpp.

References fMnUserParams, fParams, fRunInfo, and PMsrHandler::ParameterInUse().

Referenced by DoFit().

Member Data Documentation

◆ fChisqOnly

Bool_t PFitter::fChisqOnly
private

flag. true: calculate chi^2 only (no fitting).

Definition at line 126 of file PFitter.h.

Referenced by DoFit().

◆ fCmdLines

PMsrLines PFitter::fCmdLines
private

all the Minuit commands from the msr-file

Definition at line 137 of file PFitter.h.

Referenced by CheckCommands(), ExecuteFitRange(), ExecuteFix(), ExecutePrintLevel(), ExecuteRelease(), and PFitter().

◆ fCmdList

PIntPairVector PFitter::fCmdList
private

command list, first=cmd, second=cmd line index

Definition at line 138 of file PFitter.h.

Referenced by CheckCommands(), DoFit(), and ~PFitter().

◆ fConverged

Bool_t PFitter::fConverged
private

flag. true: the fit has converged.

Definition at line 125 of file PFitter.h.

Referenced by ExecuteMigrad(), ExecuteMinimize(), ExecuteScan(), ExecuteSimplex(), HasConverged(), and PFitter().

◆ fElapsedTime

PStringVector PFitter::fElapsedTime
private

◆ fFcnMin

std::unique_ptr<ROOT::Minuit2::FunctionMinimum> PFitter::fFcnMin
private

function minimum object

Definition at line 143 of file PFitter.h.

Referenced by ExecuteContours(), ExecuteMigrad(), ExecuteMinimize(), ExecuteMinos(), ExecuteSave(), and ExecuteSimplex().

◆ fFitterFcn

std::unique_ptr<PFitterFcn> PFitter::fFitterFcn
private

pointer to the fitter function object

Definition at line 140 of file PFitter.h.

Referenced by DoFit(), ExecuteContours(), ExecuteHesse(), ExecuteMigrad(), ExecuteMinimize(), ExecuteMinos(), ExecuteSave(), ExecuteScan(), ExecuteSimplex(), PFitter(), and PrepareSector().

◆ fIsScanOnly

Bool_t PFitter::fIsScanOnly
private

flag. true: scan along some parameters (no fitting).

Definition at line 124 of file PFitter.h.

Referenced by CheckCommands(), IsScanOnly(), and PFitter().

◆ fIsValid

Bool_t PFitter::fIsValid
private

flag. true: the fit is valid.

Definition at line 123 of file PFitter.h.

Referenced by CheckCommands(), ExecuteMigrad(), ExecuteMinimize(), ExecuteSimplex(), and IsValid().

◆ fMnUserParams

ROOT::Minuit2::MnUserParameters PFitter::fMnUserParams
private

◆ fOriginalFitRange

PDoublePairVector PFitter::fOriginalFitRange
private

keeps the original fit range in case there is a range command in the COMMAND block

Definition at line 153 of file PFitter.h.

Referenced by CheckCommands(), ExecuteFitRange(), and PFitter().

◆ fParams

PMsrParamList PFitter::fParams
private

◆ fPhase

std::vector<bool> PFitter::fPhase
private

flag array in which an entry is true if the related parameter value is a phase

Definition at line 160 of file PFitter.h.

Referenced by ExecuteMigrad(), ExecuteMinimize(), ExecuteSimplex(), and GetPhaseParams().

◆ fPrintLevel

UInt_t PFitter::fPrintLevel
private

tag, showing the level of messages whished. 0=minimum, 1=standard, 2=maximum

Definition at line 128 of file PFitter.h.

Referenced by ExecuteHesse(), ExecuteMigrad(), ExecuteMinimize(), ExecutePrintLevel(), ExecuteSimplex(), and PFitter().

◆ fRunInfo

◆ fRunListCollection

PRunListCollection* PFitter::fRunListCollection
private

pointer to the run list collection

Definition at line 133 of file PFitter.h.

Referenced by DoFit(), ExecuteFitRange(), ExecuteSave(), and PrepareSector().

◆ fScanAll

Bool_t PFitter::fScanAll
private

flag. false: single parameter scan, true: not implemented yet (see MnScan/MnContours in the minuit2 user manual)

Definition at line 146 of file PFitter.h.

Referenced by CheckCommands(), ExecuteScan(), and PFitter().

◆ fScanData

PDoublePairVector PFitter::fScanData
private

keeps the scan/contour data

Definition at line 151 of file PFitter.h.

Referenced by ExecuteContours(), ExecutePlot(), ExecuteScan(), and ~PFitter().

◆ fScanHigh

Double_t PFitter::fScanHigh
private

scan range high. default=0.0 which means 2 std dev. (see MnScan/MnContours in the minuit2 user manual)

Definition at line 150 of file PFitter.h.

Referenced by CheckCommands(), ExecuteScan(), and PFitter().

◆ fScanLow

Double_t PFitter::fScanLow
private

scan range low. default=0.0 which means 2 std dev. (see MnScan/MnContours in the minuit2 user manual)

Definition at line 149 of file PFitter.h.

Referenced by CheckCommands(), ExecuteScan(), and PFitter().

◆ fScanNoPoints

UInt_t PFitter::fScanNoPoints
private

number of points in a scan/contour (see MnScan/MnContours in the minuit2 user manual)

Definition at line 148 of file PFitter.h.

Referenced by CheckCommands(), ExecuteContours(), ExecuteScan(), and PFitter().

◆ fScanParameter

UInt_t PFitter::fScanParameter[2]
private

scan parameter. idx=0: used for scan and contour, idx=1: used for contour (see MnScan/MnContours in the minuit2 user manual)

Definition at line 147 of file PFitter.h.

Referenced by CheckCommands(), ExecuteContours(), ExecuteScan(), and PFitter().

◆ fSector

std::vector<PSectorChisq> PFitter::fSector
private

stores all chisq/maxLH sector information

Definition at line 158 of file PFitter.h.

Referenced by CheckCommands(), DoFit(), ExecuteSector(), and PrepareSector().

◆ fSectorFlag

Bool_t PFitter::fSectorFlag
private

sector command present flag

Definition at line 157 of file PFitter.h.

Referenced by CheckCommands(), DoFit(), ExecuteSave(), and PFitter().

◆ fStrategy

UInt_t PFitter::fStrategy
private

fitting strategy (see minuit2 manual).

Definition at line 130 of file PFitter.h.

Referenced by CheckCommands(), ExecuteMigrad(), ExecuteMinimize(), ExecuteSimplex(), and PFitter().

◆ fUseChi2

Bool_t PFitter::fUseChi2
private

flag. true: chi^2 fit. false: log-max-likelihood

Definition at line 127 of file PFitter.h.

Referenced by CheckCommands(), DoFit(), ExecuteSave(), ExecuteSector(), PFitter(), and PrepareSector().


The documentation for this class was generated from the following files: