fixes the inadequate attempt to use log max likelihood fit for asymmetry/non-muSR fit (MUSR-148)

This commit is contained in:
nemu 2010-11-12 09:30:18 +00:00
parent 81f59e3538
commit a1b94ae247
6 changed files with 36 additions and 24 deletions

View File

@ -6,6 +6,7 @@
changes since 0.8.0
===================================
FIXED fixes the inadequate attempt to use log max likelihood fit for asymmetry/non-muSR fit (MUSR-148)
CHANGED maximum possible run number for the use in msr2data to numeric_limits<unsigned int>::max() (MUSR-155)
musrfit 0.8.0 - changes since 0.7.0

View File

@ -23,7 +23,7 @@ PROJECT_NAME = musrfit
# This could be handy for archiving the generated documentation or
# if some version control system is used.
PROJECT_NUMBER = 0.99
PROJECT_NUMBER = 0.8.0
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
# base path where the generated documentation will be put.

View File

@ -282,6 +282,9 @@ Bool_t PFitter::CheckCommands()
{
fIsValid = true;
// check if chisq or log max likelihood fit
fUseChi2 = fRunInfo->GetMsrStatistic()->fChisq;
// walk through the msr-file COMMAND block
PIntPair cmd;
PMsrLines::iterator it;
@ -298,9 +301,9 @@ Bool_t PFitter::CheckCommands()
} else if (it->fLine.Contains("END RETURN", TString::kIgnoreCase)) { // needed for backward compatibility
continue;
} else if (it->fLine.Contains("CHI_SQUARE", TString::kIgnoreCase)) {
fUseChi2 = true;
continue;
} else if (it->fLine.Contains("MAX_LIKELIHOOD", TString::kIgnoreCase)) {
fUseChi2 = false;
continue;
} else if (it->fLine.Contains("INTERACTIVE", TString::kIgnoreCase)) {
cmd.first = PMN_INTERACTIVE;
cmd.second = cmdLineNo;
@ -805,8 +808,7 @@ Bool_t PFitter::CheckCommands()
cmd.second = cmdLineNo;
fCmdList.push_back(cmd);
} else { // unkown command
cerr << endl << ">> **FATAL ERROR**";
cerr << endl << ">> PFitter::CheckCommands(): In line " << it->fLineNo << " an unkown command is found:";
cerr << endl << ">> PFitter::CheckCommands(): **FATAL ERROR** in line " << it->fLineNo << " an unkown command is found:";
cerr << endl << ">> " << it->fLine.Data();
cerr << endl << ">> Will stop ...";
cerr << endl;

View File

@ -53,18 +53,6 @@ PFitterFcn::PFitterFcn(PRunListCollection *runList, Bool_t useChi2)
fUp = 0.5;
fRunListCollection = runList;
// check if max likelihood is used together with asymmetry/nonMusr data.
// if yes place a warning since this option is not implemented and a fall back
// to chi2 will be used.
if (!fUseChi2) {
if ((fRunListCollection->GetNoOfAsymmetry() > 0) ||
(fRunListCollection->GetNoOfNonMusr() > 0)) {
cerr << endl << "**WARNING**: Maximum Log Likelihood Fit is only implemented for Single Histogram Fit";
cerr << endl << " Will fall back to Chi Square Fit.";
cerr << endl;
}
}
}
//--------------------------------------------------------------------------
@ -99,13 +87,6 @@ Double_t PFitterFcn::operator()(const std::vector<Double_t>& par) const
value += fRunListCollection->GetNonMusrMaximumLikelihood(par);
}
// cout << endl;
// for (UInt_t i=0; i<par.size(); i++) {
// cout << par[i] << ", ";
// }
//cout << endl << "chisq = " << value;
// cout << endl << "------" << endl;
return value;
}

View File

@ -297,6 +297,10 @@ Int_t PMsrHandler::ReadMsrFile()
if (!CheckAddRunParameters())
result = PMUSR_MSR_SYNTAX_ERROR;
// check if the user wants to use max likelihood with asymmetry/non-muSR fit (which is not implemented)
if (result == PMUSR_SUCCESS)
CheckMaxLikelihood();
// clean up
fit_parameter.clear();
@ -4633,6 +4637,29 @@ Bool_t PMsrHandler::CheckAddRunParameters()
return result;
}
//--------------------------------------------------------------------------
// CheckMaxLikelihood (private)
//--------------------------------------------------------------------------
/**
* <p>If log max likelihood is requested, make sure that all run blocks are of single histogram type.
* If this is not the case, fall back to chisq, since for asymmetry/non-muSR fit, log max likelihood
* is not defined.
*/
void PMsrHandler::CheckMaxLikelihood()
{
if (!fStatistic.fChisq) {
for (UInt_t i=0; i<fRuns.size(); i++) {
if (fRuns[i].GetFitType() != MSR_FITTYPE_SINGLE_HISTO) {
cerr << endl << ">> PMsrHandler::CheckMaxLikelihood: **WARNING**: Maximum Log Likelihood Fit is only implemented";
cerr << endl << ">> for Single Histogram Fit. Will fall back to Chi Square Fit.";
cerr << endl << endl;
fStatistic.fChisq = true;
break;
}
}
}
}
//--------------------------------------------------------------------------
// NeededPrecision (private)
//--------------------------------------------------------------------------

View File

@ -102,6 +102,7 @@ class PMsrHandler
virtual Bool_t CheckFuncs();
virtual Bool_t CheckHistoGrouping();
virtual Bool_t CheckAddRunParameters();
virtual void CheckMaxLikelihood();
private:
TString fFileName; ///< file name of the msr-file