Page MenuHomeHEPForge

No OneTemporary

diff --git a/include/RHEJ/Rivet_Analysis.hh b/include/RHEJ/RivetAnalysis.hh
similarity index 95%
rename from include/RHEJ/Rivet_Analysis.hh
rename to include/RHEJ/RivetAnalysis.hh
index 1b79ee3..c5f0983 100644
--- a/include/RHEJ/Rivet_Analysis.hh
+++ b/include/RHEJ/RivetAnalysis.hh
@@ -1,71 +1,71 @@
/** \file
* \brief Reversed HEJ interface to rivet analyses
*/
#pragma once
#include <memory>
#include <string>
#include <utility>
#include "RHEJ/Analysis.hh"
#include "RHEJ/HepMCInterface.hh"
namespace RHEJ {
class Event;
}
namespace Rivet {
class AnalysisHandler;
}
namespace YAML {
class Node;
}
namespace RHEJ {
/**
* @brief Class representing a Rivet analysis
*
* This class inherits from Analysis and can therefore be used
* like any other reversed HEJ analysis.
*/
- class Rivet_Analysis: public RHEJ::Analysis {
+ class RivetAnalysis: public RHEJ::Analysis {
public:
static std::unique_ptr<Analysis> create(YAML::Node const & config);
//! Constructor
/**
* @param config Configuration parameters
*
* config["analysis"] should be the name of a single Rivet analysis or
* a list of Rivet analyses. config["output"] is the prefix for
* the .yoda output files.
*/
- Rivet_Analysis(YAML::Node const & config);
+ RivetAnalysis(YAML::Node const & config);
//! Pass an event to the underlying Rivet analysis
void fill(RHEJ::Event const & event, RHEJ::Event const &) override;
bool pass_cuts(RHEJ::Event const &, RHEJ::Event const &) override
{return true;} //< no additional cuts are applied
void finalise() override;
private:
std::vector<std::string> analyses_names_;
const std::string output_name_;
/// struct to organise the infos per rivet run/scale setting
struct rivet_info {
std::unique_ptr<Rivet::AnalysisHandler> handler;
std::string name;
RHEJ::HepMCInterface hepmc;
};
std::vector<rivet_info> rivet_runs_;
/**
* \internal
* @brief Calculates the scale variation from the first event for the output file
* @note Name is wrong if multiple scale functions are choosen
* @TODO is there a better way of finding the scale factor?
*/
void init(RHEJ::Event const & event);
bool first_event_;
};
}
diff --git a/include/RHEJ/get_analysis.hh b/include/RHEJ/get_analysis.hh
index 12d3301..efff59b 100644
--- a/include/RHEJ/get_analysis.hh
+++ b/include/RHEJ/get_analysis.hh
@@ -1,30 +1,30 @@
/** \file
* \brief Contains the get_analysis function
*/
#pragma once
#include <memory>
#include <string>
#include "RHEJ/optional.hh"
#include "RHEJ/Analysis.hh"
namespace YAML{
class Node;
}
namespace RHEJ{
//! Load an analysis
/**
* @param parameters Analysis parameters
* @returns A pointer to an Analysis instance
*
* If parameters["plugin"] exists, an analysis (deriving from the
* \ref Analysis class) will be loaded from the library parameters["plugin"].
- * Otherwise, if parameters["rivet"] exists, the corresponding Rivet_Analysis
+ * Otherwise, if parameters["rivet"] exists, the corresponding RivetAnalysis
* will be loaded. If none of these parameters are specified, a pointer to
* the default EmptyAnalysis is returned.
*/
std::unique_ptr<Analysis> get_analysis(YAML::Node const & parameters);
}
diff --git a/src/Rivet_Analysis.cc b/src/RivetAnalysis.cc
similarity index 78%
rename from src/Rivet_Analysis.cc
rename to src/RivetAnalysis.cc
index df33c92..c995def 100644
--- a/src/Rivet_Analysis.cc
+++ b/src/RivetAnalysis.cc
@@ -1,109 +1,109 @@
-#include "RHEJ/Rivet_Analysis.hh"
+#include "RHEJ/RivetAnalysis.hh"
#ifdef RHEJ_BUILD_WITH_RIVET
#include <ostream>
#include "RHEJ/Event.hh"
#include "yaml-cpp/yaml.h"
#include "Rivet/AnalysisHandler.hh"
#endif
namespace RHEJ{
- std::unique_ptr<Analysis> Rivet_Analysis::create(YAML::Node const & config){
- return std::unique_ptr<Analysis>{new Rivet_Analysis{config}};
+ std::unique_ptr<Analysis> RivetAnalysis::create(YAML::Node const & config){
+ return std::unique_ptr<Analysis>{new RivetAnalysis{config}};
}
}
#ifdef RHEJ_BUILD_WITH_RIVET
namespace RHEJ {
- Rivet_Analysis::Rivet_Analysis(YAML::Node const & config):
+ 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 Rivet_Analysis::init(Event const & event){
+ void RivetAnalysis::init(Event const & event){
if(event.variations().empty()){
rivet_runs_.push_back(
{std::make_unique<Rivet::AnalysisHandler>(), "", HepMCInterface()}
);
rivet_runs_.back().handler->addAnalyses(analyses_names_);
}
else{
const auto & central = event.central();
for(size_t i = 0; i < event.variations().size(); ++i){
const auto & vari = event.variations(i);
std::ostringstream name;
// calculate name ratio of the scales and use them for the output file name
name << ".Scale" << i << "_MuR" << vari.mur/central.mur
<< "_MuF" << vari.muf/central.muf;
rivet_runs_.push_back(
{std::make_unique<Rivet::AnalysisHandler>(), name.str(), HepMCInterface()}
);
rivet_runs_.back().handler->addAnalyses(analyses_names_);
}
}
}
- void Rivet_Analysis::fill(Event const & event, Event const &){
+ void RivetAnalysis::fill(Event const & event, Event const &){
if(first_event_){
first_event_=false;
init(event);
}
for(auto & run: rivet_runs_){
run.handler->analyze(run.hepmc(event));
}
}
- void Rivet_Analysis::finalise(){
+ void RivetAnalysis::finalise(){
for(auto const & run: rivet_runs_){
run.handler->finalize();
run.handler->writeData(output_name_+run.name+std::string(".yoda"));
}
}
} // namespace RHEJ
#else // no rivet => create empty analysis
namespace Rivet {
class AnalysisHandler {};
}
namespace RHEJ {
- Rivet_Analysis::Rivet_Analysis(YAML::Node const &)
+ RivetAnalysis::RivetAnalysis(YAML::Node const &)
{
throw std::invalid_argument(
- "Failed to create Rivet_Analysis: "
+ "Failed to create RivetAnalysis: "
"Reversed HEJ was built without rivet support"
);
}
- void Rivet_Analysis::init(Event const &){}
- void Rivet_Analysis::fill(Event const &, Event const &){}
- void Rivet_Analysis::finalise(){}
+ void RivetAnalysis::init(Event const &){}
+ void RivetAnalysis::fill(Event const &, Event const &){}
+ void RivetAnalysis::finalise(){}
} // namespace RHEJ
#endif
diff --git a/src/get_analysis.cc b/src/get_analysis.cc
index c9a6718..aeb3689 100644
--- a/src/get_analysis.cc
+++ b/src/get_analysis.cc
@@ -1,32 +1,32 @@
#include "RHEJ/get_analysis.hh"
#include <dlfcn.h>
#include "yaml-cpp/yaml.h"
-#include "RHEJ/Rivet_Analysis.hh"
+#include "RHEJ/RivetAnalysis.hh"
#include "RHEJ/EmptyAnalysis.hh"
namespace RHEJ{
std::unique_ptr<Analysis> get_analysis(YAML::Node const & parameters){
if(!parameters["plugin"]){
if(parameters["rivet"])
- return Rivet_Analysis::create(parameters);
+ return RivetAnalysis::create(parameters);
return EmptyAnalysis::create(parameters);
}
using AnalysisMaker = std::unique_ptr<Analysis> (*)(YAML::Node);
const auto plugin_name = parameters["plugin"].as<std::string>();
auto 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);
return make_analysis(parameters);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Jan 20, 9:14 PM (22 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4242442
Default Alt Text
(8 KB)

Event Timeline