9 #include <tst/Verify.h>
10 #include <cppunit/extensions/HelperMacros.h>
11 #include <utl/RandomSamplerFromPDF.h>
12 #include <utl/AugerException.h>
13 #include <utl/TabulatedFunction.h>
14 #include <CLHEP/Random/Randomize.h>
15 #include <boost/lexical_cast.hpp>
20 using boost::lexical_cast;
23 #define EQUAL(x, y) CPPUNIT_ASSERT(Verify<Equal>(x, y))
24 #define CLOSE(x, y) CPPUNIT_ASSERT(Verify<CloseTo>(x, y))
25 #define CLOSE_AT(x, y, eps) CPPUNIT_ASSERT(Verify<CloseTo>(x, y, eps))
35 CPPUNIT_TEST(TestTabulatedFunction);
41 CPPUNIT_TEST_SUITE_END();
51 vector<double> pdf(1, 0);
72 vector<double> pdf(3);
90 CLHEP::MTwistEngine rand;
93 for (
int i = 0; i < 1000; ++i) {
94 const double x = sLin.
shoot(rand);
95 CPPUNIT_ASSERT((-1 <= x && x <= 2) || (4 <= x && x <= 6) || (9 <= x && x <= 10));
98 -1, -0.5, 0, 0.5, 1, 1.5, 2, 4.5, 5, 5.5,
99 6, 9.5, 10, 4.75, 9.2, 4.8, 9.9
102 0, 0.0625, 0.25, 0.5625, 1, 1.375, 1.5, 1.5625, 1.75, 1.9375,
103 2, 2.375, 3.5, 1.64063, 2.06, 1.66, 3.215
105 const unsigned int n =
sizeof(x) /
sizeof(x[0]);
106 for (
unsigned int i = 0; i < n; ++i)
111 for (
int i = 0; i < 1000; ++i) {
112 const double x = sDis.
shoot(rand);
113 CPPUNIT_ASSERT(x == 1 || x == 5 || x == 10);
115 const double x[] = { -1, 1, 1, 1, 1, 5, 10 };
116 const double y[] = { 0, 0.1, 0.5, 0.9, 1, 1.1, 4.5 };
117 const unsigned int n =
sizeof(x) /
sizeof(x[0]);
118 for (
unsigned int i = 0; i < n; ++i)
123 for (
int i = 0; i < 1000; ++i) {
124 const double x = sSt.
shoot(rand);
125 CPPUNIT_ASSERT((1 <= x && x <= 2) || (5 <= x && x <= 6));
127 const double x[] = { 1.12, 1.93, 5.58 };
128 const double y[] = { 0.08, 0.62, 0.86 };
129 const unsigned int n =
sizeof(x) /
sizeof(x[0]);
130 for (
unsigned int i = 0; i < n; ++i)
void TestLinearTooShort()
Base class for exceptions arising because configuration data are not valid.
Class to hold collection (x,y) points and provide interpolation between them.
void PushBack(const double x, const double y)
double shoot(HepEngine &engine) const
Method to shoot random values using a given engine by-passing the static generator.
CPPUNIT_TEST_SUITE_REGISTRATION(testAiresShowerFile)
void TestDiscreteTooShort()
double GetInverseCDF(const double y) const
#define CLOSE_AT(x, y, eps)
void TestTabulatedFunction()