diff --git a/bin/Makefile.am b/bin/Makefile.am --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -1,40 +1,40 @@ bin_SCRIPTS = rivet-config rivet-buildplugin dist_bin_SCRIPTS = make-plots EXTRA_DIST = RIVETPROGS = \ rivet \ rivet-mkanalysis \ rivet-findid rivet-which \ rivet-cmphistos rivet-mkhtml if ENABLE_PYEXT dist_bin_SCRIPTS += $(RIVETPROGS) else EXTRA_DIST += $(RIVETPROGS) endif ## bash completion if ENABLE_PYEXT dist_pkgdata_DATA = rivet-completion bashcomp_dir = $(DESTDIR)$(prefix)/etc/bash_completion.d install-data-local: if [[ -d "$(bashcomp_dir)" && -w "$(bashcomp_dir)" ]]; then \ $(install_sh_DATA) rivet-completion $(bashcomp_dir)/; fi uninstall-local: rm -f $(bashcomp_dir)/rivet-completion else EXTRA_DIST += rivet-completion endif ## No-Python Rivet program noinst_PROGRAMS = rivet-nopy rivet_nopy_SOURCES = rivet-nopy.cc rivet_nopy_CPPFLAGS = -I$(top_srcdir)/include $(AM_CPPFLAGS) $(CPPFLAGS) rivet_nopy_LDADD = $(top_builddir)/src/libRivet.la if ENABLE_HEPMC_3 rivet_nopy_LDFLAGS = -L$(HEPMC3LIBPATH) -rivet_nopy_LDADD += -lHepMC3 +rivet_nopy_LDADD += -lHepMC3 -lHepMC3search else rivet_nopy_LDFLAGS = -L$(HEPMCLIBPATH) rivet_nopy_LDADD += -lHepMC endif diff --git a/src/Makefile.am b/src/Makefile.am --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,25 +1,25 @@ SUBDIRS = Core Tools Projections AnalysisTools lib_LTLIBRARIES = libRivet.la libRivet_la_SOURCES = libRivet_la_LDFLAGS = -export-dynamic -avoid-version -L$(YODALIBPATH) libRivet_la_LIBADD = \ Core/libRivetCore.la \ Projections/libRivetProjections.la \ Tools/libRivetTools.la \ AnalysisTools/libRivetAnalysisTools.la \ -lYODA -ldl -lm \ $(FASTJETCONFIGLIBADD) \ $(GSL_LDFLAGS) if ENABLE_HEPMC_3 -libRivet_la_LIBADD += -lHepMC3 +libRivet_la_LIBADD += -lHepMC3 -lHepMC3search libRivet_la_LDFLAGS += -L$(HEPMC3LIBPATH) else libRivet_la_LIBADD += -lHepMC libRivet_la_LDFLAGS += -L$(HEPMCLIBPATH) endif diff --git a/src/Tools/RivetHepMC_3.cc b/src/Tools/RivetHepMC_3.cc --- a/src/Tools/RivetHepMC_3.cc +++ b/src/Tools/RivetHepMC_3.cc @@ -1,83 +1,91 @@ // -*- C++ -*- #include "Rivet/Tools/RivetHepMC.hh" #include "HepMC3/ReaderAscii.h" #include "HepMC3/ReaderAsciiHepMC2.h" namespace Rivet{ namespace HepMCUtils{ std::vector particles(ConstGenEventPtr ge){ return ge->particles(); } std::vector particles(const GenEvent *ge){ assert(ge); return ge->particles(); } std::vector vertices(ConstGenEventPtr ge){ return ge->vertices(); } std::vector vertices(const GenEvent *ge){ assert(ge); return ge->vertices(); } std::vector particles(ConstGenVertexPtr gv, const Relatives &relo){ return relo(gv); } std::vector particles(ConstGenParticlePtr gp, const Relatives &relo){ return relo(gp); } + int particles_size(ConstGenEventPtr ge){ + return particles(ge).size(); + } + + int particles_size(const GenEvent *ge){ + return particles(ge).size(); + } + int uniqueId(ConstGenParticlePtr gp){ return gp->id(); } std::vector beams(const GenEvent *ge){ return ge->beams(); } bool readEvent(std::shared_ptr io, std::shared_ptr evt){ io->read_event(*evt); return !io->failed(); } shared_ptr makeReader(std::istream &istr){ if(&istr == &std::cin) return make_shared(istr); istr.seekg(istr.beg); std::string line1, line2; while(line1.empty()){ std::getline(istr, line1); } while(line2.empty()){ std::getline(istr, line2); } istr.seekg(istr.beg); // if this is absent it doesn't appear to be a HepMC file :( if(line1.find("HepMC::Version") == std::string::npos) return nullptr; shared_ptr result; // Looks like the new HepMC 3 format! if(line2.find("HepMC::Asciiv3") != std::string::npos){ result = make_shared(istr); }else{ // assume old HepMC 2 format from here result = make_shared(istr); } if(result->failed()) result.reset((RivetHepMC::Reader*)nullptr); return result; } } } diff --git a/test/testApi.cc b/test/testApi.cc --- a/test/testApi.cc +++ b/test/testApi.cc @@ -1,35 +1,35 @@ #include "Rivet/AnalysisHandler.hh" #include "HepMC/GenEvent.h" -#include "HepMC/IO_GenEvent.h" +#include "Rivet/Tools/RivetHepMC.hh" using namespace std; int main() { Rivet::AnalysisHandler ah; Rivet::Log::setLevel("Rivet", Rivet::Log::TRACE); // Specify the analyses to be used ah.addAnalysis("EXAMPLE"); ah.addAnalyses({{ "MC_JETS", "EXAMPLE_CUTS", "EXAMPLE_SMEAR" }}); std::ifstream file("testApi.hepmc"); - HepMC::IO_GenEvent hepmcio(file); - HepMC::GenEvent* evt = hepmcio.read_next_event(); + shared_ptr reader = Rivet::HepMCUtils::makeReader(file); + std::shared_ptr evt; + Rivet::HepMCUtils::readEvent(reader, evt); double sum_of_weights = 0.0; while (evt) { // Analyse current event ah.analyze(*evt); sum_of_weights += evt->weights()[0]; // Clean up and get next event - delete evt; evt = nullptr; - hepmcio >> evt; + Rivet::HepMCUtils::readEvent(reader, evt); } file.close(); ah.setCrossSection(1.0); ah.finalize(); ah.writeData("out.yoda"); return 0; } diff --git a/test/testNaN.cc b/test/testNaN.cc --- a/test/testNaN.cc +++ b/test/testNaN.cc @@ -1,76 +1,76 @@ #include "Rivet/AnalysisHandler.hh" #include "Rivet/Analysis.hh" #include "Rivet/Tools/RivetYODA.hh" #include #include #include using namespace std; class Test : public Rivet::Analysis { public: Test() : Analysis("Test") {} void init() { _h_test = bookHisto1D("test", 50, 66.0, 116.0); } void analyze(const Rivet::Event & e) { cout << "Normal fill" << endl; _h_test->fill(90., 1.); cout << "Underflow fill" << endl; _h_test->fill(30.,1.); cout << "Overflow fill" << endl; _h_test->fill(130.,1.); cout << "Inf fill" << endl; try { _h_test->fill(numeric_limits::infinity(), 1.); } catch (YODA::RangeError e) { cerr << e.what() << '\n'; if ( string(e.what()) != string("X is Inf") ) throw; } cout << "NaN fill" << endl; try { _h_test->fill(numeric_limits::quiet_NaN(), 1.); } catch (YODA::RangeError e) { cerr << e.what() << '\n'; if ( string(e.what()) != string("X is NaN") ) throw; } } private: Rivet::Histo1DPtr _h_test; }; DECLARE_RIVET_PLUGIN(Test); int main() { Rivet::AnalysisHandler rivet; rivet.addAnalysis("Test"); std::ifstream file("testApi.hepmc"); - HepMC::IO_GenEvent hepmcio(file); - HepMC::GenEvent* evt = hepmcio.read_next_event(); + shared_ptr reader = Rivet::HepMCUtils::makeReader(file); + std::shared_ptr evt; + Rivet::HepMCUtils::readEvent(reader, evt); 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; + Rivet::HepMCUtils::readEvent(reader, evt); } - file.close(); + file.close(); rivet.setCrossSection(1.0); rivet.finalize(); rivet.writeData("NaN.aida"); return 0; }