|
[Rivet-svn] r3933 - branches/2012-06-aidarivet/testblackhole at projects.hepforge.org blackhole at projects.hepforge.orgMon Sep 24 10:03:31 BST 2012
Author: dgrell Date: Mon Sep 24 10:03:31 2012 New Revision: 3933 Log: NaN checks Added: branches/2012-06-aidarivet/test/testNaN.cc Modified: branches/2012-06-aidarivet/test/Makefile.am Modified: branches/2012-06-aidarivet/test/Makefile.am ============================================================================== --- branches/2012-06-aidarivet/test/Makefile.am Fri Sep 21 13:56:56 2012 (r3932) +++ branches/2012-06-aidarivet/test/Makefile.am Mon Sep 24 10:03:31 2012 (r3933) @@ -1,4 +1,4 @@ -check_PROGRAMS = testMath testMatVec testBoost testCmp testApi +check_PROGRAMS = testMath testMatVec testBoost testCmp testApi testNaN testBoost_SOURCES = testBoost.cc testBoost_CPPFLAGS = -I$(top_srcdir)/include $(AM_CPPFLAGS) @@ -17,6 +17,10 @@ testApi_CPPFLAGS = -I$(top_srcdir)/include $(AM_CPPFLAGS) testApi_LDADD = ../src/libRivet.la $(HEPMCLDFLAGS) $(HEPMCLDLIBS) +testNaN_SOURCES = testNaN.cc +testNaN_CPPFLAGS = -I$(top_srcdir)/include $(AM_CPPFLAGS) +testNaN_LDADD = ../src/libRivet.la $(HEPMCLDFLAGS) $(HEPMCLDLIBS) + TESTS_ENVIRONMENT = \ RIVET_REF_PATH=$(top_builddir)/data/refdata \ RIVET_INFO_PATH=$(top_builddir)/data/anainfo \ @@ -25,7 +29,7 @@ PYTHON_BUILD_DIR=$(top_builddir)/pyext/build \ PATH=$(top_builddir)/bin:$(PATH) -TESTS = testMath testMatVec testBoost testCmp testApi testCmdLine.sh +TESTS = testMath testMatVec testBoost testCmp testApi testNaN testCmdLine.sh EXTRA_DIST = testApi.hepmc testCmdLine.sh Added: branches/2012-06-aidarivet/test/testNaN.cc ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/2012-06-aidarivet/test/testNaN.cc Mon Sep 24 10:03:31 2012 (r3933) @@ -0,0 +1,55 @@ +#include "Rivet/AnalysisHandler.hh" +#include "HepMC/GenEvent.h" +#include "HepMC/IO_GenEvent.h" +#include "Rivet/Analysis.hh" +#include "Rivet/RivetAIDA.hh" + +using namespace std; + +class Test : public Rivet::Analysis { +public: + Test() : Analysis("Test") {} + + void init() { + _h_test = bookHistogram1D("test", 50, 66.0, 116.0); + } + + void analyze(const Rivet::Event & e) { + _h_test->fill(90.,1.); + _h_test->fill(1./0.,1.); + _h_test->fill(sqrt(-1.),1.); + _h_test->fill(30.,1.); + _h_test->fill(130.,1.); + } + +private: + AIDA::IHistogram1D * _h_test; +}; + +DECLARE_RIVET_PLUGIN(Test); + +int main() { + Rivet::AnalysisHandler rivet; + rivet.addAnalysis("Test"); + + std::istream* file = new std::fstream("testApi.hepmc", std::ios::in); + HepMC::IO_GenEvent hepmcio(*file); + HepMC::GenEvent* evt = hepmcio.read_next_event(); + double sum_of_weights = 0.0; + while (evt) { + // Analyse current event + rivet.analyze(*evt); + sum_of_weights += evt->weights()[0]; + + // Clean up and get next event + delete evt; evt = 0; + hepmcio >> evt; + } + delete file; file = 0; + + rivet.setCrossSection(1.0); + rivet.finalize(); + rivet.writeData("NaN.aida"); + + return 0; +}
More information about the Rivet-svn mailing list |