Page MenuHomeHEPForge

get_analysis.cc
No OneTemporary

Size
1 KB
Referenced Files
None
Subscribers
None

get_analysis.cc

/**
* \authors The HEJ collaboration (see AUTHORS for details)
* \date 2019-2020
* \copyright GPLv2 or later
*/
#include "HEJ/get_analysis.hh"
#include <dlfcn.h>
#include <string>
#include "yaml-cpp/yaml.h"
#include "HEJ/EmptyAnalysis.hh"
#include "HEJ/RivetAnalysis.hh"
namespace HEJ {
std::unique_ptr<Analysis> get_analysis(
YAML::Node const & parameters, LHEF::HEPRUP const & heprup
){
if(!parameters["plugin"]){
if(parameters["rivet"].IsDefined())
return RivetAnalysis::create(parameters, heprup);
return EmptyAnalysis::create(parameters, heprup);
}
using AnalysisMaker = std::unique_ptr<Analysis> (*)(
YAML::Node const &, LHEF::HEPRUP const &);
const auto plugin_name = parameters["plugin"].as<std::string>();
void * handle = dlopen(plugin_name.c_str(), RTLD_NOW);
char * error = dlerror();
if(error != nullptr) throw std::runtime_error(error);
void * sym = dlsym(handle, "make_analysis");
error = dlerror();
if(error != nullptr) throw std::runtime_error(error);
auto make_analysis = reinterpret_cast<AnalysisMaker>(sym); // NOLINT
return make_analysis(parameters, heprup);
}
std::vector<std::unique_ptr<Analysis>> get_analyses(
std::vector<YAML::Node> const & parameters, LHEF::HEPRUP const & heprup
){
std::vector<std::unique_ptr<Analysis>> anas;
anas.reserve(parameters.size());
for(auto const & param: parameters){
anas.emplace_back(get_analysis(param, heprup));
}
return anas;
}
} // namespace HEJ

File Metadata

Mime Type
text/x-c
Expires
Tue, Sep 30, 4:40 AM (20 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
6480407
Default Alt Text
get_analysis.cc (1 KB)

Event Timeline