Page MenuHomeHEPForge

No OneTemporary

diff --git a/.hgignore b/.hgignore
--- a/.hgignore
+++ b/.hgignore
@@ -1,96 +1,97 @@
Makefile$
Makefile\.in$
\.deps$
\.libs$
\.l[ao]$
\.so$
\.so\.
\.o$
~$
\.pyc$
\.codereplace$
\.orig$
\.tar\.(gz|bz2)$
^autom4te.cache$
^config.herwig$
^config.log$
^config.status$
^configure$
^include/Herwig\+\+$
^Config/config.guess$
^Config/config.h$
^Config/config.h.in$
^Config/config.sub$
^Config/depcomp$
^Config/compile$
^Config/install-sh$
^Config/missing$
^Config/stamp-h1$
^Config/ar-lib$
^Contrib/make_makefiles.sh$
^Doc/HerwigDefaults.in$
^Doc/refman-html$
^Doc/fixinterfaces.pl$
^Doc/refman.conf$
^Doc/refman.h$
^Doc/AllInterfaces.h$
^Doc/HerwigDefaults.rpo$
^Doc/Herwig\+\+-refman.tag$
^Doc/tagfileThePEG.tag$
^Doc/.*\.log$
^(src|Utilities)/version.tmp$
^(src|Utilities)/version.tmp.new$
^(src|Utilities)/versionstring.h$
^INSTALL$
^aclocal.m4$
^confdefs.h$
^conftest.c$
^conftest.err$
^include/done-all-links$
^libtool$
\.dirstamp$
^src/herwigopts.h$
^src/herwigopts.c$
^src/defaults/Analysis.in$
^src/herwig-config$
^src/.*\.(run|tex|out|log|rpo|spc|top|dump|dot|aux|pdf|ps|png|svg|hepmc|dvi)$
^src/Makefile-UserModules$
^lib/done-all-links$
^lib/apple-fixes$
^src/Herwig\+\+
^src/defaults/PDF.in$
^src/defaults/done-all-links$
^src/tune$
^src/Herwig$
^src/tests/.*\.(time|mult|Bmult|chisq)$
^Tests/.*/.*\.(top|ps|pyc|info|dat|pdf|png)$
^Tests/.*\.(top|ps|pyc|info|dat|pdf|png|log|out)$
^Tests/.*\.(top|run|tex|mult|Bmult|aida|yoda)$
^Tests/Rivet-.*$
^Tests/Rivet/(LEP|DIS)-(NoME|Powheg|Matchbox|Dipole)-.*\.in$
^Tests/Rivet/(LEP|DIS)-(..|...|91-nopi|e.*Q2|)\.in$
^Tests/plots$
^Tests/Herwig$
^Tests/.*index.html$
^Herwig\+\+\-
^Models/Feynrules/python/Makefile-FR$
^MatrixElement/Matchbox/External/MadGraph/mg2Matchbox.py$
^MatrixElement/Matchbox/Scales/MatchboxScale.cc$
^Utilities/Statistics/combineDistributions$
^Utilities/Statistics/combineRuns$
^Utilities/Statistics/makeDistributions$
^src/defaults/MatchboxDefaults.in$
^src/defaults/setup.gosam.in$
^src/Matchbox/LO-DefaultShower.in$
^src/Matchbox/LO-DipoleShower.in$
^src/Matchbox/LO-NoShower.in$
^src/Matchbox/MCatLO-DefaultShower.in$
^src/Matchbox/MCatLO-DipoleShower.in$
^src/Matchbox/MCatNLO-DefaultShower.in$
^src/Matchbox/MCatNLO-DipoleShower.in$
^src/Matchbox/NLO-NoShower.in$
^src/Matchbox/Powheg-DefaultShower.in$
^src/Matchbox/Powheg-DipoleShower.in$
^src/Matchbox/done-all-links$
^src/snippets/done-all-links$
^Utilities/XML/xml_test$
+^Utilities/utilities_test$
diff --git a/Utilities/Makefile.am b/Utilities/Makefile.am
--- a/Utilities/Makefile.am
+++ b/Utilities/Makefile.am
@@ -1,26 +1,31 @@
SUBDIRS = XML Statistics
noinst_LTLIBRARIES = libHwUtils.la
pkglib_LTLIBRARIES = libHwRunDirectories.la
libHwUtils_la_SOURCES = \
EnumParticles.h \
Interpolator.tcc Interpolator.h \
Kinematics.cc Kinematics.h \
Smearing.cc Smearing.h \
Maths.h Maths.cc \
StandardSelectors.cc StandardSelectors.h\
Histogram.cc Histogram.fh Histogram.h \
GaussianIntegrator.cc GaussianIntegrator.h \
GaussianIntegrator.tcc \
Statistic.h HerwigStrategy.cc HerwigStrategy.h \
GSLIntegrator.h GSLIntegrator.tcc \
GSLBisection.h GSLBisection.tcc GSLHelper.h
libHwRunDirectories_la_SOURCES = \
RunDirectories.h RunDirectories.cc
libHwUtils_la_LIBADD = \
XML/libHwXML.la \
Statistics/libHwStatistics.la
CLEANFILES=
include $(srcdir)/Makefile.am.versionstring
+
+check_PROGRAMS = utilities_test
+utilities_test_SOURCES = tests/utilitiesTests.cc
+utilities_test_LDADD = $(BOOST_FILESYSTEM_LIB) $(BOOST_SYSTEM_LIB) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) libHwUtils.la
+TESTS = utilities_test
diff --git a/Utilities/Statistic.h b/Utilities/Statistic.h
--- a/Utilities/Statistic.h
+++ b/Utilities/Statistic.h
@@ -1,137 +1,137 @@
// -*- C++ -*-
//
// Statistic.h is a part of Herwig++ - A multi-purpose Monte Carlo event generator
// Copyright (C) 2002-2011 The Herwig Collaboration
//
// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
//
#ifndef HERWIG_Statistic_H
#define HERWIG_Statistic_H
#include <cmath>
//
// This is the declaration of the Statistic class.
//
namespace Herwig {
/**
* The Statistic class is a simple class designed to
* store a variable for statistical analysis
*/
class Statistic {
public:
/**
* The default constructor.
*/
Statistic() : _n(0), _xsum(0.), _x2sum(0.),
_min(-1e100), _max(1e100) {}
/**
* The minimum value
*/
double minimum() const { return _min; }
/**
* The maximum value
*/
double maximum() const { return _max; }
/**
* Operator to add another point
*/
void operator+=(double input)
{
++_n;
_xsum += input;
_x2sum += input * input;
- if (_min > input) _min = input;
- if (_max < input) _max = input;
+ if (_min > input || _n == 1) _min = input;
+ if (_max < input || _n == 1) _max = input;
}
/**
* Number of points
*/
unsigned int numberOfPoints() const { return _n; }
/**
* Mean
*/
double mean() const
{
return _n > 0 ? _xsum / _n : 0.;
}
/**
* Error on the mean estimate. Needed for example for Profile
* histograms, where this should be used to compute a chi2
* or significance level of deviation to data, rather than stdDeV.
* This is obvious because the error on the estimate should go to
* zero for N -> infinity.
*/
double mean_stdDev() const { return std::sqrt(mean_var()); }
/**
* Variance on the mean estimate. Needed for example for Profile
* histograms, where this should be used to compute a chi2
* or significance level of deviation to data, rather than stdDeV
* This is obvious because the error on the estimate should go to
* zero for N -> infinity.
*/
double mean_var() const
{
return _n > 1 ? var() / _n : 0.;
}
/**
* Standard Deviation
*/
double stdDev() const { return std::sqrt(var()); }
/**
* Variance
*/
double var() const
{
return _n > 1 ? ( _x2sum - _xsum*_xsum/_n ) / ( _n - 1 ) : 0.;
}
/**
* Total entry
*/
double total() const { return _xsum; }
private:
/**
* Number of entries
*/
unsigned int _n;
/**
* Sum of the values
*/
double _xsum;
/**
* Sum of the squares of the values
*/
double _x2sum;
/**
* The minimum value
*/
double _min;
/**
* The maximum value
*/
double _max;
};
}
#endif /* HERWIG_Statistic_H */
diff --git a/Utilities/tests/utilitiesTests.cc b/Utilities/tests/utilitiesTests.cc
new file mode 100644
--- /dev/null
+++ b/Utilities/tests/utilitiesTests.cc
@@ -0,0 +1,160 @@
+// -*- C++ -*-
+//
+// utilitiesTest.cc is a part of Herwig++ - A multi-purpose Monte Carlo event generator
+// Copyright (C) 2002-2011 The Herwig Collaboration, 2015 Marco A. Harrendorf
+//
+// Herwig++ is licenced under version 2 of the GPL, see COPYING for details.
+// Please respect the MCnet academic guidelines, see GUIDELINES for details.
+//
+
+#include "Herwig++/Utilities/Maths.h"
+#include "Herwig++/Utilities/Statistic.h"
+#define BOOST_TEST_MODULE utilitiesTest
+#include <boost/test/included/unit_test.hpp>
+
+/*
+ * Start of boost unit tests for Maths.h
+ * @todo dilog function complex input
+ */
+BOOST_AUTO_TEST_SUITE(utilitiesMathsTest)
+
+/*
+ * Boost unit tests
+ *
+ */
+BOOST_AUTO_TEST_CASE(dilogFunction)
+{
+ BOOST_CHECK_EQUAL(Herwig::Math::Li2(0.), 0.);
+ BOOST_CHECK_CLOSE(Herwig::Math::Li2(-1).real(), -1./12. * M_PI * M_PI, 1e-5);
+ BOOST_CHECK_CLOSE(Herwig::Math::Li2(-1).imag(), 0., 1e-5);
+ BOOST_CHECK_CLOSE(Herwig::Math::Li2(1).real(), 1./6. * M_PI * M_PI, 1e-5);
+ BOOST_CHECK_CLOSE(Herwig::Math::Li2(1).imag(), 0., 1e-5);
+}
+
+BOOST_AUTO_TEST_CASE(realDilogFunction)
+{
+ BOOST_CHECK_EQUAL(Herwig::Math::ReLi2(0.), 0.);
+ BOOST_CHECK_CLOSE(Herwig::Math::ReLi2(-1), -1./12. * M_PI * M_PI, 1e-5);
+ BOOST_CHECK_CLOSE(Herwig::Math::ReLi2(1), 1./6. * M_PI * M_PI, 1e-5);
+}
+
+
+BOOST_AUTO_TEST_CASE(angleZeroTo2Pi)
+{
+ BOOST_CHECK_EQUAL(Herwig::Math::angleZeroTo2Pi(0.), 0.);
+ BOOST_CHECK_EQUAL(Herwig::Math::angleZeroTo2Pi(-0.5*M_PI), 1.5*M_PI);
+ BOOST_CHECK_EQUAL(Herwig::Math::angleZeroTo2Pi(-2.5*M_PI), 1.5*M_PI);
+ BOOST_CHECK_EQUAL(Herwig::Math::angleZeroTo2Pi( 2.5*M_PI), 0.5*M_PI);
+ BOOST_CHECK(Herwig::Math::angleZeroTo2Pi( 2.5*M_PI) != 1*M_PI);
+}
+
+BOOST_AUTO_TEST_CASE(angleMinusPiToPi)
+{
+ BOOST_CHECK_EQUAL(Herwig::Math::angleMinusPiToPi(0.), 0.);
+ BOOST_CHECK_EQUAL(Herwig::Math::angleMinusPiToPi(-0.5*M_PI), -0.5*M_PI);
+ BOOST_CHECK_EQUAL(Herwig::Math::angleMinusPiToPi(-2.5*M_PI), -0.5*M_PI);
+ BOOST_CHECK_EQUAL(Herwig::Math::angleMinusPiToPi( 2.5*M_PI), 0.5*M_PI);
+ BOOST_CHECK(Herwig::Math::angleMinusPiToPi( 2.5*M_PI) != 1*M_PI);
+}
+
+BOOST_AUTO_TEST_CASE(median)
+{
+ std::vector<double> medianTest1;
+ medianTest1.push_back(10);
+ medianTest1.push_back(-1);
+ medianTest1.push_back(5);
+ BOOST_CHECK_EQUAL(Herwig::Math::median<double>(medianTest1), 5);
+
+ std::vector<double> medianTest2;
+ medianTest2.push_back(-10);
+ medianTest2.push_back(-1);
+ medianTest2.push_back(-5);
+ medianTest2.push_back(-6);
+ BOOST_CHECK_EQUAL(Herwig::Math::median<double>(medianTest2), -6);
+}
+
+BOOST_AUTO_TEST_SUITE_END()
+
+//____________________________________________________________________________//
+
+/*
+ * Fixture which defines the common variables for testing Statistic class
+ */
+struct FixStatistic1 {
+ FixStatistic1() : statisticDefault(), statisticTest()
+ {BOOST_TEST_MESSAGE( "setup fixture for utilitiesStatisticTest" ); }
+
+ ~FixStatistic1() { BOOST_TEST_MESSAGE( "teardown fixture for utilitiesStatisticTest" ); }
+
+ Herwig::Statistic statisticDefault;
+ Herwig::Statistic statisticTest;
+};
+
+/*
+ * Start of boost unit tests for Statistic.h
+ *
+ */
+BOOST_FIXTURE_TEST_SUITE(utilitiesStatisticTest, FixStatistic1 )
+
+/*
+ * Boost unit tests
+ *
+ */
+BOOST_AUTO_TEST_CASE(defaultConstructor)
+{
+ BOOST_CHECK_EQUAL(statisticDefault.numberOfPoints(), static_cast<unsigned int>(0));
+ BOOST_CHECK_EQUAL(statisticDefault.total(), 0.);
+ BOOST_CHECK_EQUAL(statisticDefault.mean(), 0.);
+ BOOST_CHECK_EQUAL(statisticDefault.minimum(), -1e100);
+ BOOST_CHECK_EQUAL(statisticDefault.maximum(), 1e100);
+ BOOST_CHECK_EQUAL(statisticDefault.var(), 0);
+ BOOST_CHECK_EQUAL(statisticDefault.mean_var(), 0);
+}
+
+BOOST_AUTO_TEST_CASE(operations)
+{
+ statisticTest += 2;
+ BOOST_CHECK_EQUAL(statisticTest.minimum(), 2);
+ BOOST_CHECK_EQUAL(statisticTest.maximum(), 2);
+
+ statisticTest += -2;
+ BOOST_CHECK_EQUAL(statisticTest.numberOfPoints(), static_cast<unsigned int>(2));
+ BOOST_CHECK_EQUAL(statisticTest.total(), 0.);
+ BOOST_CHECK_EQUAL(statisticTest.mean(), 0.);
+ BOOST_CHECK_EQUAL(statisticTest.minimum(), -2);
+ BOOST_CHECK_EQUAL(statisticTest.maximum(), 2);
+ BOOST_CHECK_EQUAL(statisticTest.var(), 8);
+ BOOST_CHECK_EQUAL(statisticTest.stdDev(), sqrt(8));
+ BOOST_CHECK_EQUAL(statisticTest.mean_var(), 4);
+ BOOST_CHECK_EQUAL(statisticTest.mean_stdDev(), 2);
+
+ statisticTest += 2;
+ BOOST_CHECK_EQUAL(statisticTest.numberOfPoints(), static_cast<unsigned int>(3));
+ BOOST_CHECK_EQUAL(statisticTest.total(), 2.);
+ BOOST_CHECK_EQUAL(statisticTest.mean(), 2./3.);
+ BOOST_CHECK_EQUAL(statisticTest.minimum(), -2);
+ BOOST_CHECK_EQUAL(statisticTest.maximum(), 2);
+ BOOST_CHECK_EQUAL(statisticTest.var(), 16./3.);
+ BOOST_CHECK_EQUAL(statisticTest.stdDev(), sqrt(16./3.));
+ BOOST_CHECK_EQUAL(statisticTest.mean_var(), 16./9.);
+ BOOST_CHECK_EQUAL(statisticTest.mean_stdDev(), sqrt(16./9.));
+
+ statisticTest += 4.5;
+ BOOST_CHECK_EQUAL(statisticTest.minimum(), -2);
+ BOOST_CHECK_EQUAL(statisticTest.maximum(), 4.5);
+
+ statisticTest += -3.5;
+ BOOST_CHECK_EQUAL(statisticTest.minimum(), -3.5);
+ BOOST_CHECK_EQUAL(statisticTest.maximum(), 4.5);
+}
+
+BOOST_AUTO_TEST_CASE(fail)
+{
+ //BOOST_FAIL("Ende");
+}
+
+
+BOOST_AUTO_TEST_SUITE_END()
+
+//____________________________________________________________________________//
+

File Metadata

Mime Type
text/x-diff
Expires
Sun, Feb 23, 2:08 PM (2 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4486467
Default Alt Text
(12 KB)

Event Timeline