removed all isnan's and nan(NAN)'s since it was a bad idea to use them in the first place
This commit is contained in:
parent
b53276419f
commit
4f66c78e4a
@ -89,6 +89,7 @@ short term:
|
|||||||
* PFitter.cpp: the value of the parabolic error in the MINUIT2.OUTPUT is wrong (only MIGRAD is
|
* PFitter.cpp: the value of the parabolic error in the MINUIT2.OUTPUT is wrong (only MIGRAD is
|
||||||
called and neither HESSE nor MINOS). Suspect the problem in the ExecuteSave() routine.
|
called and neither HESSE nor MINOS). Suspect the problem in the ExecuteSave() routine.
|
||||||
Needs to be checked.
|
Needs to be checked.
|
||||||
|
**DONE** 08-09-01
|
||||||
|
|
||||||
* PFitter.cpp: implement HESSE
|
* PFitter.cpp: implement HESSE
|
||||||
|
|
||||||
|
@ -134,8 +134,7 @@ bool PFitter::DoFit()
|
|||||||
cout << endl;
|
cout << endl;
|
||||||
break;
|
break;
|
||||||
case PMN_HESSE:
|
case PMN_HESSE:
|
||||||
cout << endl << "**WARNING** from PFitter::DoFit() : the command HESSE is not yet implemented.";
|
status = ExecuteHesse();
|
||||||
cout << endl;
|
|
||||||
break;
|
break;
|
||||||
case PMN_MACHINE_PRECISION:
|
case PMN_MACHINE_PRECISION:
|
||||||
cout << endl << "**WARNING** from PFitter::DoFit() : the command MACHINE_PRECISION is not yet implemented.";
|
cout << endl << "**WARNING** from PFitter::DoFit() : the command MACHINE_PRECISION is not yet implemented.";
|
||||||
@ -270,18 +269,17 @@ bool PFitter::CheckCommands()
|
|||||||
*/
|
*/
|
||||||
bool PFitter::SetParameters()
|
bool PFitter::SetParameters()
|
||||||
{
|
{
|
||||||
PMsrParamList::iterator it;
|
for (unsigned int i=0; i<fParams.size(); i++) {
|
||||||
|
|
||||||
for (it = fParams.begin(); it != fParams.end(); ++it) {
|
|
||||||
// check if parameter is fixed
|
// check if parameter is fixed
|
||||||
if (it->fStep == 0.0) { // add fixed parameter
|
if (fParams[i].fStep == 0.0) { // add fixed parameter
|
||||||
fMnUserParams.Add(it->fName.Data(), it->fValue);
|
fMnUserParams.Add(fParams[i].fName.Data(), fParams[i].fValue);
|
||||||
} else { // add free parameter
|
} else { // add free parameter
|
||||||
// check if boundaries are given
|
// check if boundaries are given
|
||||||
if (it->fNoOfParams > 5) { // boundaries given
|
if (fParams[i].fNoOfParams > 5) { // boundaries given
|
||||||
fMnUserParams.Add(it->fName.Data(), it->fValue, it->fStep, it->fLowerBoundary, it->fUpperBoundary);
|
fMnUserParams.Add(fParams[i].fName.Data(), fParams[i].fValue, fParams[i].fStep,
|
||||||
|
fParams[i].fLowerBoundary, fParams[i].fUpperBoundary);
|
||||||
} else { // no boundaries given
|
} else { // no boundaries given
|
||||||
fMnUserParams.Add(it->fName.Data(), it->fValue, it->fStep);
|
fMnUserParams.Add(fParams[i].fName.Data(), fParams[i].fValue, fParams[i].fStep);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -298,6 +296,24 @@ bool PFitter::SetParameters()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
// ExecuteHesse
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
bool PFitter::ExecuteHesse()
|
||||||
|
{
|
||||||
|
cout << "PFitter::ExecuteHesse(): will call hesse ..." << endl;
|
||||||
|
|
||||||
|
// if already some minimization is done use the minuit2 output as input
|
||||||
|
if (fFcnMin)
|
||||||
|
fMnUserParams = fFcnMin->UserParameters();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// ExecuteMigrad
|
// ExecuteMigrad
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
@ -534,7 +550,7 @@ bool PFitter::ExecuteSave()
|
|||||||
fout.setf(ios::left, ios::adjustfield);
|
fout.setf(ios::left, ios::adjustfield);
|
||||||
fout.precision(6);
|
fout.precision(6);
|
||||||
fout.width(11);
|
fout.width(11);
|
||||||
fout << fMnUserParams.Error(i);
|
fout << mnState.Error(i);
|
||||||
// write minos errors
|
// write minos errors
|
||||||
if (fParams[i].fPosErrorPresent) {
|
if (fParams[i].fPosErrorPresent) {
|
||||||
fout.setf(ios::left, ios::adjustfield);
|
fout.setf(ios::left, ios::adjustfield);
|
||||||
@ -554,7 +570,7 @@ bool PFitter::ExecuteSave()
|
|||||||
fout << "---";
|
fout << "---";
|
||||||
}
|
}
|
||||||
// write limits
|
// write limits
|
||||||
if (!isnan(fParams[i].fLowerBoundary)) {
|
if (fParams[i].fNoOfParams > 5) {
|
||||||
fout.setf(ios::left, ios::adjustfield);
|
fout.setf(ios::left, ios::adjustfield);
|
||||||
fout.width(7);
|
fout.width(7);
|
||||||
fout << fParams[i].fLowerBoundary;
|
fout << fParams[i].fLowerBoundary;
|
||||||
|
@ -506,15 +506,16 @@ int PMsrHandler::WriteMsrLogFile()
|
|||||||
CheckAndWriteComment(f, ++lineNo);
|
CheckAndWriteComment(f, ++lineNo);
|
||||||
}
|
}
|
||||||
// backgr.fix
|
// backgr.fix
|
||||||
if (!isnan(fRuns[i].fBkgFix[0])) {
|
if (fRuns[i].fBkgFixPresent[0]) {
|
||||||
f.width(15);
|
f.width(15);
|
||||||
f << endl << left << "backgr.fix";
|
f << endl << left << "backgr.fix";
|
||||||
for (unsigned int j=0; j<2; j++) {
|
|
||||||
if (!isnan(fRuns[i].fBkgFix[j])) {
|
|
||||||
f.precision(prec);
|
f.precision(prec);
|
||||||
f.width(12);
|
f.width(12);
|
||||||
f << left << fRuns[i].fBkgFix[j];
|
f << left << fRuns[i].fBkgFix[0];
|
||||||
}
|
if (fRuns[i].fBkgFixPresent[1]) {
|
||||||
|
f.precision(prec);
|
||||||
|
f.width(12);
|
||||||
|
f << left << fRuns[i].fBkgFix[1];
|
||||||
}
|
}
|
||||||
CheckAndWriteComment(f, ++lineNo);
|
CheckAndWriteComment(f, ++lineNo);
|
||||||
}
|
}
|
||||||
@ -830,20 +831,20 @@ bool PMsrHandler::HandleFitParameterEntry(PMsrLines &lines)
|
|||||||
TObjString *ostr;
|
TObjString *ostr;
|
||||||
TString str;
|
TString str;
|
||||||
|
|
||||||
|
// fill param structure
|
||||||
|
iter = lines.begin();
|
||||||
|
while ((iter != lines.end()) && !error) {
|
||||||
|
|
||||||
// init param structure
|
// init param structure
|
||||||
param.fNoOfParams = -1;
|
param.fNoOfParams = -1;
|
||||||
param.fNo = -1;
|
param.fNo = -1;
|
||||||
param.fName = TString("");
|
param.fName = TString("");
|
||||||
param.fValue = nan("NAN");
|
param.fValue = 0.0;
|
||||||
param.fStep = nan("NAN");
|
param.fStep = 0.0;
|
||||||
param.fPosErrorPresent = nan("NAN");
|
param.fPosErrorPresent = false;
|
||||||
param.fPosError = nan("NAN");
|
param.fPosError = 0.0;
|
||||||
param.fLowerBoundary = nan("NAN");
|
param.fLowerBoundary = 0.0;
|
||||||
param.fUpperBoundary = nan("NAN");
|
param.fUpperBoundary = 0.0;
|
||||||
|
|
||||||
// fill param structure
|
|
||||||
iter = lines.begin();
|
|
||||||
while ((iter != lines.end()) && !error) {
|
|
||||||
|
|
||||||
tokens = iter->fLine.Tokenize(" \t");
|
tokens = iter->fLine.Tokenize(" \t");
|
||||||
if (!tokens) {
|
if (!tokens) {
|
||||||
@ -991,6 +992,7 @@ bool PMsrHandler::HandleFitParameterEntry(PMsrLines &lines)
|
|||||||
cout << endl;
|
cout << endl;
|
||||||
} else { // everything is OK, therefore add the parameter to the parameter list
|
} else { // everything is OK, therefore add the parameter to the parameter list
|
||||||
fParam.push_back(param);
|
fParam.push_back(param);
|
||||||
|
cout << endl << ">> PMsrHandler::HandleFitParameterEntry: i=" << fParam.size() << ", param.fLowerBoundary=" << param.fLowerBoundary << ", param.fUpperBoundary=" << param.fUpperBoundary;
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
@ -1509,7 +1511,7 @@ bool PMsrHandler::HandleRunEntry(PMsrLines &lines)
|
|||||||
bool found;
|
bool found;
|
||||||
if (fRuns[i].fBkgFitParamNo >= 0) { // check if backgr.fit is given
|
if (fRuns[i].fBkgFitParamNo >= 0) { // check if backgr.fit is given
|
||||||
found = true;
|
found = true;
|
||||||
} else if (!isnan(fRuns[i].fBkgFix[0])) { // check if backgr.fix is given
|
} else if (fRuns[i].fBkgFixPresent[0]) { // check if backgr.fix is given
|
||||||
found = true;
|
found = true;
|
||||||
} else if (fRuns[i].fBkgRange[0] >= 0) { // check if background window is given
|
} else if (fRuns[i].fBkgRange[0] >= 0) { // check if background window is given
|
||||||
found = true;
|
found = true;
|
||||||
@ -1555,8 +1557,10 @@ void PMsrHandler::InitRunParameterStructure(PMsrRunStructure ¶m)
|
|||||||
param.fMap.clear(); // empty list
|
param.fMap.clear(); // empty list
|
||||||
param.fForwardHistoNo = -1;
|
param.fForwardHistoNo = -1;
|
||||||
param.fBackwardHistoNo = -1;
|
param.fBackwardHistoNo = -1;
|
||||||
for (int i=0; i<2; i++)
|
for (int i=0; i<2; i++) {
|
||||||
param.fBkgFix[i] = nan("NAN");
|
param.fBkgFixPresent[i] = false;
|
||||||
|
param.fBkgFix[i] = 0.0;
|
||||||
|
}
|
||||||
for (int i=0; i<4; i++)
|
for (int i=0; i<4; i++)
|
||||||
param.fBkgRange[i] = -1;
|
param.fBkgRange[i] = -1;
|
||||||
for (int i=0; i<4; i++)
|
for (int i=0; i<4; i++)
|
||||||
|
@ -594,7 +594,7 @@ void PMusrCanvas::UpdateInfoPad()
|
|||||||
// temperature if present
|
// temperature if present
|
||||||
tstr += TString("T=");
|
tstr += TString("T=");
|
||||||
dval = fRunList->GetTemp(runs[runNo].fRunName);
|
dval = fRunList->GetTemp(runs[runNo].fRunName);
|
||||||
if (isnan(dval)) {
|
if (dval == -9.9e99) {
|
||||||
tstr += TString("??,");
|
tstr += TString("??,");
|
||||||
} else {
|
} else {
|
||||||
sprintf(sval, "%0.2lf", dval);
|
sprintf(sval, "%0.2lf", dval);
|
||||||
@ -603,7 +603,7 @@ void PMusrCanvas::UpdateInfoPad()
|
|||||||
// field if present
|
// field if present
|
||||||
tstr += TString("B=");
|
tstr += TString("B=");
|
||||||
dval = fRunList->GetField(runs[runNo].fRunName);
|
dval = fRunList->GetField(runs[runNo].fRunName);
|
||||||
if (isnan(dval)) {
|
if (dval == -9.9e99) {
|
||||||
tstr += TString("??,");
|
tstr += TString("??,");
|
||||||
} else {
|
} else {
|
||||||
sprintf(sval, "%0.2lf", dval);
|
sprintf(sval, "%0.2lf", dval);
|
||||||
@ -612,7 +612,7 @@ void PMusrCanvas::UpdateInfoPad()
|
|||||||
// energy if present
|
// energy if present
|
||||||
tstr += TString("E=");
|
tstr += TString("E=");
|
||||||
dval = fRunList->GetEnergy(runs[runNo].fRunName);
|
dval = fRunList->GetEnergy(runs[runNo].fRunName);
|
||||||
if (isnan(dval)) {
|
if (dval == -9.9e99) {
|
||||||
tstr += TString("??,");
|
tstr += TString("??,");
|
||||||
} else {
|
} else {
|
||||||
sprintf(sval, "%0.2lf", dval);
|
sprintf(sval, "%0.2lf", dval);
|
||||||
|
@ -356,7 +356,7 @@ bool PRunAsymmetry::PrepareData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// subtract background from histogramms ------------------------------------------
|
// subtract background from histogramms ------------------------------------------
|
||||||
if (isnan(fRunInfo->fBkgFix[0])) { // no fixed background given
|
if (!fRunInfo->fBkgFixPresent[0]) { // no fixed background given
|
||||||
if (fRunInfo->fBkgRange[0] != 0) {
|
if (fRunInfo->fBkgRange[0] != 0) {
|
||||||
if (!SubtractEstimatedBkg())
|
if (!SubtractEstimatedBkg())
|
||||||
return false;
|
return false;
|
||||||
|
@ -488,10 +488,10 @@ bool PRunDataHandler::ReadNemuFile()
|
|||||||
runData.fRunName = TString("");
|
runData.fRunName = TString("");
|
||||||
runData.fRunTitle = TString("");
|
runData.fRunTitle = TString("");
|
||||||
runData.fSetup = TString("");
|
runData.fSetup = TString("");
|
||||||
runData.fField = nan("NAN");
|
runData.fField = -9.9e99;
|
||||||
runData.fTemp = nan("NAN");
|
runData.fTemp = -9.9e99;
|
||||||
runData.fEnergy = nan("NAN");
|
runData.fEnergy = -9.9e99;
|
||||||
runData.fTimeResolution = nan("NAN");
|
runData.fTimeResolution = 0.0;
|
||||||
|
|
||||||
// open file
|
// open file
|
||||||
ifstream f;
|
ifstream f;
|
||||||
@ -578,7 +578,7 @@ bool PRunDataHandler::ReadNemuFile()
|
|||||||
f.getline(instr, sizeof(instr));
|
f.getline(instr, sizeof(instr));
|
||||||
} while (headerInfo && !f.eof());
|
} while (headerInfo && !f.eof());
|
||||||
|
|
||||||
if ((groups == 0) || (channels == 0) || isnan(runData.fTimeResolution)) {
|
if ((groups == 0) || (channels == 0) || runData.fTimeResolution == 0.0) {
|
||||||
cout << endl << "PRunDataHandler::ReadNemuFile(): essential header informations are missing!";
|
cout << endl << "PRunDataHandler::ReadNemuFile(): essential header informations are missing!";
|
||||||
f.close();
|
f.close();
|
||||||
return false;
|
return false;
|
||||||
|
@ -119,7 +119,7 @@ double PRunSingleHisto::CalcChiSquare(const std::vector<double>& par)
|
|||||||
// get background
|
// get background
|
||||||
double bkg;
|
double bkg;
|
||||||
if (fRunInfo->fBkgFitParamNo == -1) { // bkg not fitted
|
if (fRunInfo->fBkgFitParamNo == -1) { // bkg not fitted
|
||||||
if (isnan(fRunInfo->fBkgFix[0])) { // no fixed background given (background interval)
|
if (!fRunInfo->fBkgFixPresent[0]) { // no fixed background given (background interval)
|
||||||
bkg = fBackground;
|
bkg = fBackground;
|
||||||
} else { // fixed bkg given
|
} else { // fixed bkg given
|
||||||
bkg = fRunInfo->fBkgFix[0];
|
bkg = fRunInfo->fBkgFix[0];
|
||||||
@ -185,7 +185,7 @@ double PRunSingleHisto::CalcMaxLikelihood(const std::vector<double>& par)
|
|||||||
// get background
|
// get background
|
||||||
double bkg;
|
double bkg;
|
||||||
if (fRunInfo->fBkgFitParamNo == -1) { // bkg not fitted
|
if (fRunInfo->fBkgFitParamNo == -1) { // bkg not fitted
|
||||||
if (isnan(fRunInfo->fBkgFix[0])) { // no fixed background given (background interval)
|
if (!fRunInfo->fBkgFixPresent[0]) { // no fixed background given (background interval)
|
||||||
bkg = fBackground;
|
bkg = fBackground;
|
||||||
} else { // fixed bkg given
|
} else { // fixed bkg given
|
||||||
bkg = fRunInfo->fBkgFix[0];
|
bkg = fRunInfo->fBkgFix[0];
|
||||||
@ -259,7 +259,7 @@ void PRunSingleHisto::CalcTheory()
|
|||||||
// get background
|
// get background
|
||||||
double bkg;
|
double bkg;
|
||||||
if (fRunInfo->fBkgFitParamNo == -1) { // bkg not fitted
|
if (fRunInfo->fBkgFitParamNo == -1) { // bkg not fitted
|
||||||
if (isnan(fRunInfo->fBkgFix[0])) { // no fixed background given (background interval)
|
if (!fRunInfo->fBkgFixPresent[0]) { // no fixed background given (background interval)
|
||||||
bkg = fBackground;
|
bkg = fBackground;
|
||||||
} else { // fixed bkg given
|
} else { // fixed bkg given
|
||||||
bkg = fRunInfo->fBkgFix[0];
|
bkg = fRunInfo->fBkgFix[0];
|
||||||
@ -412,7 +412,7 @@ bool PRunSingleHisto::PrepareFitData()
|
|||||||
// check how the background shall be handled
|
// check how the background shall be handled
|
||||||
if (fRunInfo->fBkgFitParamNo == -1) { // bkg shall **NOT** be fitted
|
if (fRunInfo->fBkgFitParamNo == -1) { // bkg shall **NOT** be fitted
|
||||||
// subtract background from histogramms ------------------------------------------
|
// subtract background from histogramms ------------------------------------------
|
||||||
if (isnan(fRunInfo->fBkgFix[0])) { // no fixed background given
|
if (!fRunInfo->fBkgFixPresent[0]) { // no fixed background given
|
||||||
if (fRunInfo->fBkgRange[0] != 0) {
|
if (fRunInfo->fBkgRange[0] != 0) {
|
||||||
if (!EstimateBkg(histoNo))
|
if (!EstimateBkg(histoNo))
|
||||||
return false;
|
return false;
|
||||||
@ -628,7 +628,7 @@ cout << endl << ">> data start time = " << fData.fDataTimeStart;
|
|||||||
// get background
|
// get background
|
||||||
double bkg;
|
double bkg;
|
||||||
if (fRunInfo->fBkgFitParamNo == -1) { // bkg not fitted
|
if (fRunInfo->fBkgFitParamNo == -1) { // bkg not fitted
|
||||||
if (isnan(fRunInfo->fBkgFix[0])) { // no fixed background given (background interval)
|
if (!fRunInfo->fBkgFixPresent[0]) { // no fixed background given (background interval)
|
||||||
if (!EstimateBkg(histoNo))
|
if (!EstimateBkg(histoNo))
|
||||||
return false;
|
return false;
|
||||||
bkg = fBackground;
|
bkg = fBackground;
|
||||||
@ -800,7 +800,7 @@ bool PRunSingleHisto::PrepareViewData()
|
|||||||
// get background
|
// get background
|
||||||
double bkg;
|
double bkg;
|
||||||
if (fRunInfo->fBkgFitParamNo == -1) { // bkg not fitted
|
if (fRunInfo->fBkgFitParamNo == -1) { // bkg not fitted
|
||||||
if (isnan(fRunInfo->fBkgFix[0])) { // no fixed background given (background interval)
|
if (!fRunInfo->fBkgFixPresent[0]) { // no fixed background given (background interval)
|
||||||
if (!EstimateBkg(histoNo))
|
if (!EstimateBkg(histoNo))
|
||||||
return false;
|
return false;
|
||||||
bkg = fBackground;
|
bkg = fBackground;
|
||||||
|
@ -87,6 +87,7 @@ class PFitter
|
|||||||
bool CheckCommands();
|
bool CheckCommands();
|
||||||
bool SetParameters();
|
bool SetParameters();
|
||||||
|
|
||||||
|
bool ExecuteHesse();
|
||||||
bool ExecuteMigrad();
|
bool ExecuteMigrad();
|
||||||
bool ExecuteMinimize();
|
bool ExecuteMinimize();
|
||||||
bool ExecuteMinos();
|
bool ExecuteMinos();
|
||||||
|
@ -234,6 +234,7 @@ typedef struct {
|
|||||||
PIntVector fMap; ///<
|
PIntVector fMap; ///<
|
||||||
int fForwardHistoNo; ///<
|
int fForwardHistoNo; ///<
|
||||||
int fBackwardHistoNo; ///<
|
int fBackwardHistoNo; ///<
|
||||||
|
bool fBkgFixPresent[2]; ///< flag showing if a fixed background is present
|
||||||
double fBkgFix[2]; ///<
|
double fBkgFix[2]; ///<
|
||||||
int fBkgRange[4]; ///<
|
int fBkgRange[4]; ///<
|
||||||
int fDataRange[4]; ///<
|
int fDataRange[4]; ///<
|
||||||
|
Loading…
x
Reference in New Issue
Block a user