From 375b8fd038261403de535de76c5e9820d1dcb06f Mon Sep 17 00:00:00 2001
From: Andrew Zhen Ning Yong <andrew.yong@ed.ac.uk>
Date: Fri, 21 May 2021 15:29:24 +0100
Subject: [PATCH] Removed criteria of rejecting fits if sample fit chi2PerDof
 is bad.

---
 lib/Statistics/XYSampleData.cpp | 14 --------------
 lib/Statistics/XYSampleData.hpp |  1 -
 2 files changed, 15 deletions(-)

diff --git a/lib/Statistics/XYSampleData.cpp b/lib/Statistics/XYSampleData.cpp
index b336b62..1d9b0cb 100644
--- a/lib/Statistics/XYSampleData.cpp
+++ b/lib/Statistics/XYSampleData.cpp
@@ -247,14 +247,6 @@ void XYSampleData::checkChi2PerDof(double Chi2PerDof)
     }
 }
 
-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 ////////////////////////
 const DMat & XYSampleData::getFitVarMat(void)
 {
@@ -314,7 +306,6 @@ SampleFitResult XYSampleData::fit(std::vector<Minimizer *> &minimizer,
     result.chi2_.resize(nSample_);
     result.model_.resize(v.size());
     double chi2PerDof;
-    unsigned int badSampleFits = 0;
     goodFit_ = true;
     FOR_STAT_ARRAY(result, s)
     {
@@ -342,11 +333,6 @@ SampleFitResult XYSampleData::fit(std::vector<Minimizer *> &minimizer,
                 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();
diff --git a/lib/Statistics/XYSampleData.hpp b/lib/Statistics/XYSampleData.hpp
index c5c61b5..a66c9dd 100644
--- a/lib/Statistics/XYSampleData.hpp
+++ b/lib/Statistics/XYSampleData.hpp
@@ -93,7 +93,6 @@ public:
     DVec               getYError(const Index j);
     bool               checkFit(); // check fit candidate based on chi2PerDof
     void               checkChi2PerDof(double Chi2PerDof);
-    void               checkChi2PerDof(double Chi2PerDof, unsigned int &counter);
     // get total fit variance matrix and its pseudo-inverse
     const DMat & getFitVarMat(void);
     const DMat & getFitVarMatPInv(void);