Skip to content

Commit

Permalink
Check that norms are correlated.
Browse files Browse the repository at this point in the history
The "Horrifying" fit has two parameters that are 100% anti-correlated.
The uncertainty won't be correct since the matrix is singular and the
matrix is conditioned.  HESSE should still find that the parameters
have a very large negative correlation.
  • Loading branch information
ClarkMcGrew committed Jan 14, 2025
1 parent b59f76b commit 3b41653
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions tests/regular-tests/900HorrifyingCovCheck.C
Original file line number Diff line number Diff line change
Expand Up @@ -86,35 +86,59 @@ int main() {
"/postFitErrors_TH1D"));
EXPECT("postFitErrors must exist", postFitErrorsHesse);
TMatrixD* cov
= dynamic_cast<TMatrixD*>(file->Get(
"FitterEngine"
"/postFit"
"/Hesse"
"/errors"
"/Horrifying"
"/matrices"
"/Covariance_TMatrixD"));
EXPECT("covariance must exist", cov);
// Don't try to continue if the data is missing from the file.
if (not postFitErrorsMigrad) return status;
if (not postFitErrorsHesse) return status;
if (not cov) return status;
cov->Print();
double correlation = (*cov)(0,1);
correlation /= std::sqrt((*cov)(0,0));
correlation /= std::sqrt((*cov)(1,1));
std::cout << "Correlation " << correlation << std::endl;
postFitErrorsMigrad->Draw();
gPad->Print("900HorrifyingCovCheck.pdf[");
postFitErrorsMigrad->Draw();
gPad->Print("900HorrifyingCovCheck.pdf");
postFitErrorsHesse->Draw();
gPad->Print("900HorrifyingCovCheck.pdf");
gPad->Print("900HorrifyingCovCheck.pdf]");
// Change this to set the expected absolute tolerance.
double tolerance = 1E-3;
double valueTolerance = 1E-3;
double correlationTolerance = 1E-3;
// The expected values are for the data generated by
// 100NormalizationTree.C. They need to be changed if that tree is
// changed.
TOLERANCE("Check MIGRAD value for #0_Norm_A",
postFitErrorsMigrad->GetBinContent(1), 1.0, tolerance);
postFitErrorsMigrad->GetBinContent(1), 1.0, valueTolerance);
TOLERANCE("Check HESSE value for #0_Norm_A",
postFitErrorsHesse->GetBinContent(1), 1.0, tolerance);
TOLERANCE("Check HESSE error for #0_Norm_A",
postFitErrorsHesse->GetBinError(1), 0.21213, 0.05);
postFitErrorsHesse->GetBinContent(1), 1.0, valueTolerance);
TOLERANCE("Check MIGRAD value for #1_Norm_B",
postFitErrorsMigrad->GetBinContent(2), 1.0, tolerance);
postFitErrorsMigrad->GetBinContent(2), 1.0, valueTolerance);
TOLERANCE("Check HESSE value for #1_Norm_B",
postFitErrorsHesse->GetBinContent(2), 1.0, tolerance);
TOLERANCE("Check HESSE error for #0_Norm_B",
postFitErrorsHesse->GetBinError(2), 0.21213, 0.05);
postFitErrorsHesse->GetBinContent(2), 1.0, valueTolerance);
TOLERANCE("Check HESSE correlation between #0_Norm_A and #0_Norm_B",
correlation, -1.0, correlationTolerance);
file->Close();
Expand Down

0 comments on commit 3b41653

Please sign in to comment.