Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F7879481
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
6 KB
Subscribers
None
View Options
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1cf8b39..689df1d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,65 +1,68 @@
file(GLOB src_files *.cc)
## hej source
add_library(HEJ SHARED ${src_files})
set_target_properties(HEJ PROPERTIES OUTPUT_NAME "HEJ")
target_include_directories(HEJ PUBLIC ${HEJ_INCLUDE_DIR})
set(libraries ${CMAKE_DL_LIBS})
target_link_libraries(HEJ PRIVATE ${libraries})
## Dependencies
target_link_libraries(HEJ
PUBLIC
fastjet::fastjet
LHAPDF::LHAPDF
CLHEP::CLHEP
yaml-cpp
)
# Boost target seems to be unreliable and might requires specific versions of
# cmake to work see e.g. https://stackoverflow.com/a/42124857
# target_link_libraries(HEJ
# PUBLIC
# Boost::boost
# Boost::iostreams
# )
# link explicitly instead
target_include_directories(HEJ PUBLIC ${Boost_INCLUDE_DIRS})
target_link_libraries(HEJ PUBLIC ${Boost_LIBRARIES})
if(QCDloop_FOUND)
target_link_libraries(HEJ PRIVATE QCDloop::qcdloop quadmath)
target_compile_options( HEJ PUBLIC "-DHEJ_BUILD_WITH_QCDLOOP" )
endif()
if(HepMC_FOUND)
target_link_libraries(HEJ PRIVATE HepMC::HepMC)
target_compile_options( HEJ PUBLIC "-DHEJ_BUILD_WITH_HepMC2" )
endif()
if(HepMC3_FOUND)
# HepMC 3 doesn't export a target
target_link_libraries(HEJ PRIVATE ${HEPMC3_LIBRARIES})
target_include_directories(HEJ PRIVATE ${HEPMC3_INCLUDE_DIR})
target_compile_options( HEJ PUBLIC "-DHEJ_BUILD_WITH_HepMC3" )
endif()
if(rivet_FOUND)
target_link_libraries(HEJ PRIVATE rivet::rivet)
target_compile_options( HEJ PUBLIC "-DHEJ_BUILD_WITH_RIVET" )
+ if(rivet_VERSION VERSION_LESS 3)
+ target_compile_options(HEJ PRIVATE "-DHEJ_USE_RIVET2")
+ endif()
endif()
if(HighFive_FOUND)
target_link_libraries(HEJ PRIVATE HighFive)
target_compile_options( HEJ PUBLIC "-DHEJ_BUILD_WITH_HDF5" )
endif()
## install & export target
install(TARGETS HEJ
EXPORT HEJ-export
DESTINATION ${INSTALL_LIB_DIR}
)
install(EXPORT HEJ-export
FILE
hejTargets.cmake
NAMESPACE
HEJ::
DESTINATION
${INSTALL_CONFIG_DIR}
)
diff --git a/src/RivetAnalysis.cc b/src/RivetAnalysis.cc
index dd9ebd5..21fe34c 100644
--- a/src/RivetAnalysis.cc
+++ b/src/RivetAnalysis.cc
@@ -1,157 +1,165 @@
/**
* \authors The HEJ collaboration (see AUTHORS for details)
* \date 2019
* \copyright GPLv2 or later
*/
#include "HEJ/RivetAnalysis.hh"
#ifdef HEJ_BUILD_WITH_RIVET
#include <ostream>
#include <stddef.h>
#include "yaml-cpp/yaml.h"
#include "Rivet/AnalysisHandler.hh"
#include "Rivet/Config/RivetConfig.hh"
#ifdef RIVET_ENABLE_HEPMC_3
#include "HepMC3/GenEvent.h"
#include "HEJ/HepMC3Interface.hh"
#else // rivet with HepMC 2
#include "HepMC/GenEvent.h"
#include "HEJ/HepMC2Interface.hh"
#endif
#include "HEJ/Event.hh"
#include "HEJ/exceptions.hh"
#endif
namespace HEJ{
std::unique_ptr<Analysis> RivetAnalysis::create(YAML::Node const & config){
return std::unique_ptr<Analysis>{new RivetAnalysis{config}};
}
}
#ifdef HEJ_BUILD_WITH_RIVET
namespace HEJ {
#ifdef RIVET_ENABLE_HEPMC_3
using HepMCInterface=HepMC3Interface;
#else
using HepMCInterface=HepMC2Interface;
#endif
struct RivetAnalysis::rivet_info {
rivet_info(std::unique_ptr<Rivet::AnalysisHandler> && h,
std::string && s, HEJ::HepMCInterface && m):
handler{std::move(h)}, name{std::move(s)}, hepmc{std::move(m)}
{}
// AnalysisHandler doesn't allow a copy constructor -> use ptr
std::unique_ptr<Rivet::AnalysisHandler> handler;
std::string name;
HEJ::HepMCInterface hepmc;
};
RivetAnalysis::RivetAnalysis(YAML::Node const & config):
output_name_{config["output"].as<std::string>()},
first_event_(true)
{
// read in analyses
const auto & name_node = config["rivet"];
switch(name_node.Type()){
case YAML::NodeType::Scalar:
analyses_names_.push_back(name_node.as<std::string>());
break;
case YAML::NodeType::Sequence:
for(YAML::const_iterator it = name_node.begin(); it != name_node.end(); ++it){
analyses_names_.push_back(it->as<std::string>());
}
break;
default:
throw std::invalid_argument{
"No Analysis was provided to rivet. "
"Either give an analysis or deactivate rivet."
};
}
}
void RivetAnalysis::initialise(LHEF::HEPRUP const & heprup){
heprup_ = heprup;
}
// it is a bit ugly that we can't do this directly in `initialise`
void RivetAnalysis::init(Event const & event){
- //! @TODO only add variation for Rivet 3 and don't do the ugly rest
+#ifdef HEJ_USE_RIVET2
rivet_runs_.reserve(event.variations().size()+1);
+#else
+ (void) event; // shut up compiler
+#endif
rivet_runs_.emplace_back( std::make_unique<Rivet::AnalysisHandler>(),
std::string(""), HepMCInterface(heprup_)
);
rivet_runs_.back().handler->addAnalyses(analyses_names_);
- //! @TODO only add variation for Rivet 3 and don't do the ugly rest
+
+#ifdef HEJ_USE_RIVET2
+ //! scale variation in rivet 2 through multiple analyses
if( !event.variations().empty() ){
for(auto const & vari : event.variations()){
rivet_runs_.emplace_back( std::make_unique<Rivet::AnalysisHandler>(),
"."+to_simple_string(*vari.description), HepMCInterface(heprup_)
);
rivet_runs_.back().handler->addAnalyses(analyses_names_);
}
}
+#endif
}
void RivetAnalysis::fill(Event const & event, Event const &){
if(first_event_){
first_event_=false;
init(event);
}
auto hepmc_kin(rivet_runs_[0].hepmc(event));
rivet_runs_[0].handler->analyze(hepmc_kin);
- //! @TODO only add variation for Rivet 3 and don't do the ugly rest
+
+#ifdef HEJ_USE_RIVET2
for(size_t i = 1; i < rivet_runs_.size(); ++i){
auto & run = rivet_runs_[i];
run.hepmc.set_central(hepmc_kin, event, i-1);
run.handler->analyze(hepmc_kin);
}
+#endif
}
void RivetAnalysis::finalise(){
for(auto & run: rivet_runs_){
run.handler->finalize();
run.handler->writeData(output_name_+run.name+std::string(".yoda"));
}
}
} // namespace HEJ
#else // no rivet => create empty analysis
namespace Rivet {
class AnalysisHandler {};
}
namespace HEJ {
struct RivetAnalysis::rivet_info{};
RivetAnalysis::RivetAnalysis(YAML::Node const &)
{
throw std::invalid_argument(
"Failed to create RivetAnalysis: "
"HEJ 2 was built without rivet support"
);
}
void RivetAnalysis::initialise(LHEF::HEPRUP const &){}
void RivetAnalysis::init(Event const &){}
void RivetAnalysis::fill(Event const &, Event const &){}
void RivetAnalysis::finalise(){}
} // namespace HEJ
#endif
namespace HEJ {
RivetAnalysis::~RivetAnalysis() = default;
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Tue, Nov 19, 8:31 PM (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3799062
Default Alt Text
(6 KB)
Attached To
rHEJ HEJ
Event Timeline
Log In to Comment