mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2025-05-03 10:05:56 +01:00
XYSampleData throws Runtime exception error if central fit's chi2PerDof exceeds user-set/default bounds for chi2PerDof. This can be used to skip fits with bad fitranges.
This commit is contained in:
parent
6990d16ca0
commit
f0739047c3
@ -20,6 +20,7 @@
|
|||||||
#include <LatAnalyze/Statistics/XYSampleData.hpp>
|
#include <LatAnalyze/Statistics/XYSampleData.hpp>
|
||||||
#include <LatAnalyze/includes.hpp>
|
#include <LatAnalyze/includes.hpp>
|
||||||
#include <LatAnalyze/Core/Math.hpp>
|
#include <LatAnalyze/Core/Math.hpp>
|
||||||
|
// #include <LatAnalyze/Core/Exceptions.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace Latan;
|
using namespace Latan;
|
||||||
@ -234,22 +235,18 @@ DVec XYSampleData::getYError(const Index j)
|
|||||||
return data_.getYError(j);
|
return data_.getYError(j);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XYSampleData::setChi2PerDofBound(double upper_lim, double lower_lim)
|
void XYSampleData::setChi2PerDofBound(double uLim, double lLim)
|
||||||
{
|
{
|
||||||
chi2PerDofu_ = upper_lim;
|
chi2PerDofu_ = uLim;
|
||||||
chi2PerDofl_ = lower_lim;
|
chi2PerDofl_ = lLim;
|
||||||
}
|
|
||||||
|
|
||||||
bool XYSampleData::checkFit()
|
|
||||||
{
|
|
||||||
return goodFit_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XYSampleData::checkChi2PerDof(double Chi2PerDof)
|
void XYSampleData::checkChi2PerDof(double Chi2PerDof)
|
||||||
{
|
{
|
||||||
if(Chi2PerDof >= chi2PerDofu_ or Chi2PerDof < chi2PerDofl_ or isnan(Chi2PerDof))
|
if(Chi2PerDof >= chi2PerDofu_ or Chi2PerDof < chi2PerDofl_ or isnan(Chi2PerDof))
|
||||||
{
|
{
|
||||||
goodFit_ = false;
|
string msg = "central chi2perDof = " + to_string(Chi2PerDof) + " not within user-set bound of " + to_string(chi2PerDofl_) + " < chi2PerDof < " + to_string(chi2PerDofu_) ;
|
||||||
|
LATAN_ERROR(Runtime, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,10 +309,7 @@ SampleFitResult XYSampleData::fit(std::vector<Minimizer *> &minimizer,
|
|||||||
result.chi2_.resize(nSample_);
|
result.chi2_.resize(nSample_);
|
||||||
result.model_.resize(v.size());
|
result.model_.resize(v.size());
|
||||||
double chi2PerDof;
|
double chi2PerDof;
|
||||||
goodFit_ = true;
|
|
||||||
FOR_STAT_ARRAY(result, s)
|
FOR_STAT_ARRAY(result, s)
|
||||||
{
|
|
||||||
if(goodFit_)
|
|
||||||
{
|
{
|
||||||
setDataToSample(s);
|
setDataToSample(s);
|
||||||
if (s == central)
|
if (s == central)
|
||||||
@ -338,7 +332,6 @@ SampleFitResult XYSampleData::fit(std::vector<Minimizer *> &minimizer,
|
|||||||
result.model_[j][s] = sampleResult.getModel(j);
|
result.model_[j][s] = sampleResult.getModel(j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
result.nPar_ = sampleResult.getNPar();
|
result.nPar_ = sampleResult.getNPar();
|
||||||
result.nDof_ = sampleResult.nDof_;
|
result.nDof_ = sampleResult.nDof_;
|
||||||
result.parName_ = sampleResult.parName_;
|
result.parName_ = sampleResult.parName_;
|
||||||
|
@ -92,8 +92,7 @@ public:
|
|||||||
DVec getXError(const Index i);
|
DVec getXError(const Index i);
|
||||||
DVec getYError(const Index j);
|
DVec getYError(const Index j);
|
||||||
// fit criteria
|
// fit criteria
|
||||||
void setChi2PerDofBound(double upper_lim, double lower_lim);
|
void setChi2PerDofBound(double uLim, double lLim);
|
||||||
bool checkFit(); // check fit candidate based on chi2PerDof
|
|
||||||
void checkChi2PerDof(double Chi2PerDof);
|
void checkChi2PerDof(double Chi2PerDof);
|
||||||
// get total fit variance matrix and its pseudo-inverse
|
// get total fit variance matrix and its pseudo-inverse
|
||||||
const DMat & getFitVarMat(void);
|
const DMat & getFitVarMat(void);
|
||||||
@ -137,7 +136,6 @@ private:
|
|||||||
Index nSample_, dataSample_{central};
|
Index nSample_, dataSample_{central};
|
||||||
bool initData_{true}, computeVarMat_{true};
|
bool initData_{true}, computeVarMat_{true};
|
||||||
bool initXMap_{true};
|
bool initXMap_{true};
|
||||||
bool goodFit_{true}; // used to break minimisation if central sample chi2PerDof is bad
|
|
||||||
double chi2PerDofu_{1e10}, chi2PerDofl_{0};
|
double chi2PerDofu_{1e10}, chi2PerDofl_{0};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user