Unit test for util::FastAndPoorGauss
.
More...
#include <boost/test/unit_test.hpp>
#include <boost/test/tools/floating_point_comparison.hpp>
#include "icarusalg/Utilities/FastAndPoorGauss.h"
#include "larcorealg/CoreUtils/counter.h"
#include "TFile.h"
#include "TH1F.h"
#include "TF1.h"
#include "TFitResult.h"
Go to the source code of this file.
Unit test for util::FastAndPoorGauss
.
- Date
- February 15, 2020
- Author
- Gianluca Petrillo (petri.nosp@m.llo@.nosp@m.slac..nosp@m.stan.nosp@m.ford..nosp@m.edu)
- See Also
- `icarusalg/Utilities/FastAndPoorGauss.h
Definition in file FastAndPoorGauss_test.cc.
#define BOOST_TEST_MODULE FastAndPoorGauss |
BOOST_AUTO_TEST_CASE |
( |
TestCase |
| ) |
|
Definition at line 74 of file FastAndPoorGauss_test.cc.
76 TFile
F(
"FastAndPoorGauss_test.root",
"RECREATE");
78 Test< 1024U>(&
F,
false);
79 Test< 4096U>(&
F,
false);
80 Test< 8192U>(&
F,
false);
template<std::size_t NSamples>
void Test |
( |
TFile * |
pFile = nullptr , |
|
|
bool |
statChecks = true |
|
) |
| |
Definition at line 30 of file FastAndPoorGauss_test.cc.
32 constexpr
unsigned int NPoints = 1
'000'000U;
37 BOOST_TEST_MESSAGE(
"Testing sampling " << NSamples <<
" points.");
40 (
"HGaus" + NSamplesTag).c_str(),
41 (
"Distribution from util::FastAndPoorGauss<" + NSamplesTag +
">").c_str(),
44 HGaus.SetDirectory(pFile);
48 double const u = extract();
49 double const z = gauss(u);
53 TF1* pGaus =
new TF1((
"FGaus" + NSamplesTag).c_str(),
"gaus", -5.0, +5.0);
54 TFitResultPtr pFitRes = HGaus.Fit(pGaus,
"QS");
55 BOOST_CHECK(pFitRes->IsValid());
56 if (statChecks) BOOST_CHECK_LT(pFitRes->Chi2()/pFitRes->Ndf(), 5.0);
60 if (statChecks) BOOST_CHECK_SMALL(pFitRes->Parameter(1), 2.*pFitRes->Error(1));
61 if (statChecks) BOOST_CHECK_CLOSE(pFitRes->Parameter(2), 1.0, 1.0);
65 HGaus.SetDirectory(
nullptr);
process_name opflash particleana ie ie ie z
Translates a number u uniformly distributed between 0 and 1 into a Gaussian distributed one z...
auto counter(T begin, T end)
Returns an object to iterate values from begin to end in a range-for loop.
std::string to_string(WindowPattern const &pattern)