1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2025-04-10 19:20:44 +01:00

Merge remote-tracking branch 'fork/develop' into develop

This commit is contained in:
AndrewYongZhenNing 2021-05-20 11:51:53 +01:00
commit a7d020e0f9
2 changed files with 15 additions and 2 deletions

View File

@ -244,9 +244,15 @@ void XYSampleData::checkChi2PerDof(double Chi2PerDof)
if(Chi2PerDof >= 2 or Chi2PerDof < 0 or isnan(Chi2PerDof)) if(Chi2PerDof >= 2 or Chi2PerDof < 0 or isnan(Chi2PerDof))
{ {
goodFit_ = false; goodFit_ = false;
cerr << "chi2PerDof = " << Chi2PerDof << ". Aborting fit now." << endl;
} }
}
void XYSampleData::checkChi2PerDof(double Chi2PerDof, unsigned int &counter)
{
if(Chi2PerDof >= 2 or Chi2PerDof < 0 or isnan(Chi2PerDof))
{
counter++;
}
} }
// get total fit variance matrix and its pseudo-inverse //////////////////////// // get total fit variance matrix and its pseudo-inverse ////////////////////////
@ -308,6 +314,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;
unsigned int badSampleFits = 0;
goodFit_ = true; goodFit_ = true;
FOR_STAT_ARRAY(result, s) FOR_STAT_ARRAY(result, s)
{ {
@ -325,7 +332,7 @@ SampleFitResult XYSampleData::fit(std::vector<Minimizer *> &minimizer,
{ {
sampleResult = data_.fit(*(minimizer.back()), initCopy, v); sampleResult = data_.fit(*(minimizer.back()), initCopy, v);
chi2PerDof = sampleResult.getChi2PerDof(); chi2PerDof = sampleResult.getChi2PerDof();
checkChi2PerDof(chi2PerDof); checkChi2PerDof(chi2PerDof, badSampleFits);
} }
result[s] = sampleResult; result[s] = sampleResult;
result.chi2_[s] = sampleResult.getChi2(); result.chi2_[s] = sampleResult.getChi2();
@ -335,6 +342,11 @@ SampleFitResult XYSampleData::fit(std::vector<Minimizer *> &minimizer,
result.model_[j][s] = sampleResult.getModel(j); result.model_[j][s] = sampleResult.getModel(j);
} }
if(badSampleFits > 0.25*nSample_)
{
goodFit_ = false;
cerr << "At least " << 0.25*nSample_ << " of the sample fits have bad chi2/dof. Aborting fit." << endl;
}
} }
} }
result.nPar_ = sampleResult.getNPar(); result.nPar_ = sampleResult.getNPar();

View File

@ -93,6 +93,7 @@ public:
DVec getYError(const Index j); DVec getYError(const Index j);
bool checkFit(); // check fit candidate based on chi2PerDof bool checkFit(); // check fit candidate based on chi2PerDof
void checkChi2PerDof(double Chi2PerDof); void checkChi2PerDof(double Chi2PerDof);
void checkChi2PerDof(double Chi2PerDof, unsigned int &counter);
// 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);
const DMat & getFitVarMatPInv(void); const DMat & getFitVarMatPInv(void);