musrfit
1.9.2
|
#include <PFitter.h>
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 ¶m, 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... | |
PMsrHandler * | fRunInfo |
pointer to the msr-file handler More... | |
PRunListCollection * | fRunListCollection |
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< PFitterFcn > | fFitterFcn |
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< PSectorChisq > | fSector |
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... | |
PFitter::PFitter | ( | PMsrHandler * | runInfo, |
PRunListCollection * | runListCollection, | ||
Bool_t | chisq_only = false |
||
) |
Constructor.
runInfo | pointer of the msr-file handler |
runListCollection | pointer of the run list collection (pre-processed historgrams) |
chisq_only | flag: 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.
|
virtual |
Destructor.
Definition at line 326 of file PFitter.cpp.
References fCmdList, fElapsedTime, and fScanData.
|
private |
Check the msr-file COMMAND's, fill the command queue and make sure that given parameters (if present) do make any sense.
return: true if the commands are valid, otherwise returns false.
Definition at line 831 of file PFitter.cpp.
References PMsrStatisticStructure::fChisq, fCmdLines, fCmdList, fIsScanOnly, fIsValid, fOriginalFitRange, fParams, fRunInfo, fScanAll, fScanHigh, fScanLow, fScanNoPoints, fScanParameter, fSector, fSectorFlag, fStrategy, fUseChi2, PMsrHandler::GetMsrRunList(), PMsrHandler::GetMsrStatistic(), PMsrHandler::GetNoOfRuns(), PMN_CONTOURS, PMN_EIGEN, PMN_FIT_RANGE, PMN_FIX, PMN_HESSE, PMN_INTERACTIVE, PMN_MACHINE_PRECISION, PMN_MIGRAD, PMN_MINIMIZE, PMN_MINOS, PMN_PLOT, PMN_PRINT, PMN_RELEASE, PMN_RESTORE, PMN_SAVE, PMN_SCAN, PMN_SECTOR, PMN_SIMPLEX, PMN_USER_COVARIANCE, and PMN_USER_PARAM_STATE.
Referenced by PFitter().
Bool_t PFitter::DoFit | ( | ) |
Main calling routine to invoke minuit2, i.e. fitting etc.
return: true if all commands could be executed successfully, otherwise returns false.
Definition at line 546 of file PFitter.cpp.
References ExecuteContours(), ExecuteFitRange(), ExecuteFix(), ExecuteHesse(), ExecuteMigrad(), ExecuteMinimize(), ExecuteMinos(), ExecutePlot(), ExecutePrintLevel(), ExecuteRelease(), ExecuteRestore(), ExecuteSave(), ExecuteScan(), ExecuteSimplex(), fChisqOnly, fCmdList, fFitterFcn, fMnUserParams, fParams, fRunInfo, fRunListCollection, fSector, fSectorFlag, fUseChi2, PMsrStatisticStructure::fValid, PMsrHandler::GetMsrRunList(), PMsrHandler::GetMsrStatistic(), PMsrHandler::GetNoOfFitParameters(), PRunListCollection::GetSingleRunChisq(), PRunListCollection::GetSingleRunMaximumLikelihood(), IsValid(), PMN_CONTOURS, PMN_EIGEN, PMN_FIT_RANGE, PMN_FIX, PMN_HESSE, PMN_INTERACTIVE, PMN_MACHINE_PRECISION, PMN_MIGRAD, PMN_MINIMIZE, PMN_MINOS, PMN_PLOT, PMN_PRINT, PMN_RELEASE, PMN_RESTORE, PMN_SAVE, PMN_SCAN, PMN_SECTOR, PMN_SIMPLEX, PMN_USER_COVARIANCE, PMN_USER_PARAM_STATE, PRunListCollection::SetFitRange(), PMsrHandler::SetMsrParamPosErrorPresent(), SetParameters(), and status.
|
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().
|
private |
Change the fit range via command block.
lineNo | the 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().
|
private |
Fix parameter list given at lineNo of the command block.
lineNo | the 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().
|
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().
|
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().
|
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().
|
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().
|
private |
Execute the minuit2 plot command.
return: true.
Definition at line 1981 of file PFitter.cpp.
References fScanData.
Referenced by DoFit().
|
private |
Set the print level.
lineNo | the 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().
|
private |
Release parameter list given at lineNo of the command block.
lineNo | the 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().
|
private |
Release all fixed parameters
return: true.
Definition at line 2101 of file PFitter.cpp.
References fMnUserParams.
Referenced by DoFit().
|
private |
Execute the save command.
firstSave | flag indication if this is the first save call and hence write a fresh MINUIT2.OUTPUT |
return: true if the valid minuit2 state is found, otherwise returns false.
Definition at line 2150 of file PFitter.cpp.
References ExecuteSector(), fElapsedTime, fFcnMin, fFitterFcn, PMsrStatisticStructure::fMin, PMsrStatisticStructure::fMinExpected, PMsrStatisticStructure::fMinExpectedPerHisto, PMsrStatisticStructure::fMinPerHisto, fMnUserParams, PMsrStatisticStructure::fNdf, PMsrStatisticStructure::fNdfPerHisto, fParams, fRunInfo, fRunListCollection, fSectorFlag, fUseChi2, PMsrHandler::GetFileName(), PMsrGlobalBlock::GetFitRange(), PMsrHandler::GetMsrGlobal(), PMsrHandler::GetMsrParamList(), PMsrHandler::GetMsrRunList(), PMsrHandler::GetMsrStatistic(), PMsrHandler::GetNoOfFitParameters(), PRunListCollection::GetSingleRunChisq(), PRunListCollection::GetSingleRunMaximumLikelihood(), PMsrHandler::ParameterInUse(), PMUSR_UNDEFINED, and PrepareSector().
Referenced by DoFit().
|
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().
|
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().
|
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().
|
private |
Extract from string funX the function number. Base on the function number the paramter numbers will be collected.
funStr | string of the form funX, where X is the function number |
Definition at line 430 of file PFitter.cpp.
References fRunInfo, PMsrHandler::GetMsrFunctions(), and GetParFromMap().
Referenced by GetPhaseParams().
|
private |
Extract from string mapX the map number. Based on the map number the parameter numbers will be collected.
mapStr | string of the form mapX, where X is the map number |
Definition at line 497 of file PFitter.cpp.
References fRunInfo, and PMsrHandler::GetMsrRunList().
Referenced by GetParFromFun(), and 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().
|
inline |
Definition at line 119 of file PFitter.h.
References fConverged.
|
inline |
Definition at line 118 of file PFitter.h.
References fIsScanOnly.
|
inline |
|
private |
return:
Definition at line 2782 of file PFitter.cpp.
Referenced by ExecuteHesse(), ExecuteMigrad(), ExecuteMinimize(), ExecuteMinos(), and ExecuteSimplex().
|
private |
Collect all the necessary chisq/maxLH sector information.
param | parameter value vector of the converged fit. |
error | step 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().
|
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().
|
private |
|
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().
|
private |
command list, first=cmd, second=cmd line index
Definition at line 138 of file PFitter.h.
Referenced by CheckCommands(), DoFit(), and ~PFitter().
|
private |
flag. true: the fit has converged.
Definition at line 125 of file PFitter.h.
Referenced by ExecuteMigrad(), ExecuteMinimize(), ExecuteScan(), ExecuteSimplex(), HasConverged(), and PFitter().
|
private |
Definition at line 155 of file PFitter.h.
Referenced by ExecuteHesse(), ExecuteMigrad(), ExecuteMinimize(), ExecuteMinos(), ExecuteSave(), ExecuteSimplex(), and ~PFitter().
|
private |
function minimum object
Definition at line 143 of file PFitter.h.
Referenced by ExecuteContours(), ExecuteMigrad(), ExecuteMinimize(), ExecuteMinos(), ExecuteSave(), and ExecuteSimplex().
|
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().
|
private |
flag. true: scan along some parameters (no fitting).
Definition at line 124 of file PFitter.h.
Referenced by CheckCommands(), IsScanOnly(), and PFitter().
|
private |
flag. true: the fit is valid.
Definition at line 123 of file PFitter.h.
Referenced by CheckCommands(), ExecuteMigrad(), ExecuteMinimize(), ExecuteSimplex(), and IsValid().
|
private |
minuit2 input parameter list
Definition at line 142 of file PFitter.h.
Referenced by DoFit(), ExecuteFix(), ExecuteHesse(), ExecuteMigrad(), ExecuteMinimize(), ExecuteMinos(), ExecuteRelease(), ExecuteRestore(), ExecuteSave(), ExecuteScan(), ExecuteSimplex(), and SetParameters().
|
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().
|
private |
msr-file parameters
Definition at line 135 of file PFitter.h.
Referenced by CheckCommands(), DoFit(), ExecuteHesse(), ExecuteMigrad(), ExecuteMinimize(), ExecuteMinos(), ExecuteSave(), ExecuteSimplex(), PFitter(), and SetParameters().
|
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().
|
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().
|
private |
pointer to the msr-file handler
Definition at line 132 of file PFitter.h.
Referenced by CheckCommands(), DoFit(), ExecuteFitRange(), ExecuteHesse(), ExecuteMigrad(), ExecuteMinimize(), ExecuteMinos(), ExecuteSave(), ExecuteSimplex(), GetParFromFun(), GetParFromMap(), GetPhaseParams(), PFitter(), PrepareSector(), and SetParameters().
|
private |
pointer to the run list collection
Definition at line 133 of file PFitter.h.
Referenced by DoFit(), ExecuteFitRange(), ExecuteSave(), and PrepareSector().
|
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().
|
private |
keeps the scan/contour data
Definition at line 151 of file PFitter.h.
Referenced by ExecuteContours(), ExecutePlot(), ExecuteScan(), and ~PFitter().
|
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().
|
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().
|
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().
|
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().
|
private |
stores all chisq/maxLH sector information
Definition at line 158 of file PFitter.h.
Referenced by CheckCommands(), DoFit(), ExecuteSector(), and PrepareSector().
|
private |
sector command present flag
Definition at line 157 of file PFitter.h.
Referenced by CheckCommands(), DoFit(), ExecuteSave(), and PFitter().
|
private |
fitting strategy (see minuit2 manual).
Definition at line 130 of file PFitter.h.
Referenced by CheckCommands(), ExecuteMigrad(), ExecuteMinimize(), ExecuteSimplex(), and PFitter().
|
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().