Page MenuHomeHEPForge

No OneTemporary

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a9405ca..904b136 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,207 +1,207 @@
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
project("Reversed HEJ" VERSION 0.0.1 LANGUAGES C CXX)
## Flags for the compiler. No warning allowed.
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
elseif (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /EHsc")
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 14)
## Create Version
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# Get the latest abbreviated commit hash of the working branch
execute_process(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE PROJECT_GIT_REVISION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Get the current working branch
execute_process(
COMMAND git rev-parse --abbrev-ref HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE PROJECT_GIT_BRANCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(INSTALL_INCLUDE_DIR "include/RHEJ/")
set(INSTALL_BIN_DIR "bin/")
set(INSTALL_LIB_DIR "lib/")
CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Templates/Version.hh.in
${PROJECT_BINARY_DIR}/include/RHEJ/Version.hh @ONLY )
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Templates/rHEJ-config.cc.in
${PROJECT_BINARY_DIR}/src/bin/rHEJ-config.cc @ONLY )
## Add directories and find dependences
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${PROJECT_BINARY_DIR}/include)
find_package(fastjet REQUIRED)
include_directories(${fastjet_INCLUDE_PATH})
find_package(clhep 2.3 REQUIRED)
include_directories(${clhep_INCLUDE_PATH})
find_package(lhapdf REQUIRED)
include_directories(${lhapdf_INCLUDE_PATH})
find_package(gsl REQUIRED)
include_directories(${gsl_INCLUDE_PATH})
find_package(Boost REQUIRED COMPONENTS iostreams)
include_directories(${Boost_INCLUDE_DIRS})
find_package(yaml-cpp)
include_directories(${YAML_CPP_INCLUDE_DIR})
find_package(HepMC 2)
if(${HepMC_FOUND})
message (STATUS "HepMC installation found: ${HepMC_INCLUDE_DIRS}")
set(
CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -DRHEJ_BUILD_WITH_HepMC_VERSION=${HepMC_VERSION_MAJOR}"
)
include_directories(${HepMC_INCLUDE_DIRS})
find_package(rivet)
if(${rivet_FOUND})
include_directories(${rivet_INCLUDE_PATH})
set(
CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -DRHEJ_BUILD_WITH_RIVET"
)
endif()
endif()
find_package(QCDloop 2)
if(${QCDloop_FOUND})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DRHEJ_BUILD_WITH_QCDLOOP")
include_directories(SYSTEM ${QCDloop_INCLUDE_DIRS})
endif()
add_subdirectory(src)
## define executable
add_executable(rHEJ src/bin/rHEJ.cc)
## link libraries
target_link_libraries(rHEJ rhej)
add_executable(rHEJ-config src/bin/rHEJ-config.cc)
file(GLOB rhej_headers ${CMAKE_CURRENT_SOURCE_DIR}/include/RHEJ/*.hh ${PROJECT_BINARY_DIR}/include/RHEJ/*.hh)
file(GLOB lhef_headers ${CMAKE_CURRENT_SOURCE_DIR}/include/LHEF/*.h)
install(FILES ${rhej_headers} DESTINATION ${INSTALL_INCLUDE_DIR})
install(FILES ${lhef_headers} DESTINATION include/LHEF/)
install(TARGETS rHEJ rHEJ-config DESTINATION ${INSTALL_BIN_DIR})
enable_testing()
set(tst_dir "${CMAKE_CURRENT_SOURCE_DIR}/t")
add_executable(test_Matrix ${tst_dir}/test_Matrix.cc)
add_executable(test_classify ${tst_dir}/test_classify.cc)
add_executable(test_psp ${tst_dir}/test_psp.cc)
add_executable(test_ME_h_3j ${tst_dir}/test_ME_h_3j.cc)
add_executable(test_ME_hjets_mt174 ${tst_dir}/test_ME_hjets_mt174.cc)
add_executable(check_res ${tst_dir}/check_res.cc)
add_executable(check_lhe ${tst_dir}/check_lhe.cc)
add_library(scales SHARED ${tst_dir}/scales.cc)
add_executable(test_scale_import ${tst_dir}/test_scale_import)
-add_executable(test_scale_names ${tst_dir}/test_scale_names)
+add_executable(test_descriptions ${tst_dir}/test_descriptions)
target_link_libraries(test_Matrix rhej)
target_link_libraries(test_classify rhej)
target_link_libraries(test_psp rhej)
target_link_libraries(test_ME_h_3j rhej)
target_link_libraries(test_ME_hjets_mt174 rhej)
target_link_libraries(check_res rhej)
target_link_libraries(check_lhe rhej)
target_link_libraries(test_scale_import rhej)
-target_link_libraries(test_scale_names rhej)
+target_link_libraries(test_descriptions rhej)
add_test(
NAME t_matrix
COMMAND test_Matrix
)
add_test(
NAME t_classify
COMMAND test_classify ${tst_dir}/classify.lhe.gz
)
add_test(
NAME t_psp
COMMAND test_psp ${tst_dir}/psp_gen.lhe.gz
)
add_test(
NAME t_ME
COMMAND test_ME_h_3j
)
if(${QCDloop_FOUND})
add_test(
NAME t_ME_mt174
COMMAND test_ME_hjets_mt174
)
endif()
add_test(
NAME t_2j
COMMAND check_res ${tst_dir}/2j.lhe.gz 3.382e7 752159
)
add_test(
NAME t_3j
COMMAND check_res ${tst_dir}/3j.lhe.gz 2.5019e+06 97075
)
add_test(
NAME t_4j
COMMAND check_res ${tst_dir}/4j.lhe.gz 479170 19203.9
)
add_test(
NAME t_h_3j
COMMAND check_res ${tst_dir}/h_3j.lhe.gz 0.793107 0.0479054
)
add_test(
NAME t_h_3j_uno
COMMAND check_res ${tst_dir}/h_3j_uno.lhe.gz 0.0260428 0.00129855 uno
)
if(${HepMC_FOUND})
file(READ "${tst_dir}/jet_config.yml" config)
file(WRITE "${tst_dir}/jet_config_withHepMC.yml" "${config} - tst.hepmc")
if(${rivet_FOUND})
file(READ "${tst_dir}/jet_config_withHepMC.yml" config)
file(WRITE "${tst_dir}/jet_config_withRivet.yml" "${config}\n\nanalysis:\n rivet: MC_XS\n output: tst")
add_test(
NAME t_main
COMMAND rHEJ ${tst_dir}/jet_config_withRivet.yml ${tst_dir}/2j.lhe.gz
)
else()
add_test(
NAME t_main
COMMAND rHEJ ${tst_dir}/jet_config_withHepMC.yml ${tst_dir}/2j.lhe.gz
)
endif()
if(${HepMC_VERSION_MAJOR} GREATER 2)
add_executable(check_hepmc ${tst_dir}/check_hepmc.cc)
target_link_libraries(check_hepmc rhej)
add_test(
NAME t_hepmc
COMMAND check_hepmc tst.hepmc
)
endif()
else()
add_test(
NAME t_main
COMMAND rHEJ ${tst_dir}/jet_config.yml ${tst_dir}/2j.lhe.gz
)
endif()
add_test(
NAME t_lhe
COMMAND check_lhe tst.lhe
)
add_test(
NAME t_scale_import
COMMAND test_scale_import ${tst_dir}/jet_config_with_import.yml
)
add_test(
- NAME t_scale_names
- COMMAND test_scale_names
+ NAME t_descriptions
+ COMMAND test_descriptions
)
diff --git a/include/RHEJ/Event.hh b/include/RHEJ/Event.hh
index 8fc6aa6..ab122f6 100644
--- a/include/RHEJ/Event.hh
+++ b/include/RHEJ/Event.hh
@@ -1,166 +1,186 @@
/** \file
* \brief Declares the Event class and helpers
*
*/
#pragma once
#include <string>
#include <memory>
#include <unordered_map>
#include "RHEJ/utility.hh"
#include "RHEJ/event_types.hh"
#include "LHEF/LHEF.h"
#include "fastjet/JetDefinition.hh"
#include "fastjet/ClusterSequence.hh"
namespace RHEJ{
+
+ struct ParameterDescription;
+
//! Event parameters
struct EventParameters{
double mur; /**< Value of the Renormalisation Scale */
double muf; /**< Value of the Factorisation Scale */
double weight; /**< Event Weight */
- //! Optional description (e.g. scale names)
- std::shared_ptr<std::string> description = nullptr;
+ //! Optional description
+ std::shared_ptr<ParameterDescription> description = nullptr;
+ };
+
+ //! Description of event parameters
+ struct ParameterDescription {
+ //! Name of central scale choice (e.g. "H_T/2")
+ std::string scale_name;
+ //! Actual renormalisation scale divided by central scale
+ double mur_factor;
+ //! Actual factorisation scale divided by central scale
+ double muf_factor;
+
+ ParameterDescription() = default;
+ ParameterDescription(
+ std::string scale_name, double mur_factor, double muf_factor
+ ):
+ scale_name{scale_name}, mur_factor{mur_factor}, muf_factor{muf_factor}
+ {};
};
//! An event before jet clustering
struct UnclusteredEvent{
//! Default Constructor
UnclusteredEvent() = default;
//! Constructor from LesHouches event information
UnclusteredEvent(LHEF::HEPEUP const & hepeup);
std::array<Particle, 2> incoming; /**< Incoming Particles */
std::vector<Particle> outgoing; /**< Outgoing Particles */
//! Particle decays in the format {outgoing index, decay products}
std::unordered_map<int, std::vector<Particle>> decays;
//! Central parameter (e.g. scale) choice
EventParameters central;
std::vector<EventParameters> variations; /**< For parameter variation */
};
/** An event with clustered jets
*
* This is the main reversed HEJ event class.
* It contains kinematic information including jet clustering,
* parameter (e.g. scale) settings and the event weight.
*/
class Event{
public:
//! Default Event Constructor
Event() = default;
//! Event Constructor adding jet clustering to an unclustered event
Event(
UnclusteredEvent ev,
fastjet::JetDefinition const & jet_def, double min_jet_pt
);
//! The jets formed by the outgoing partons
std::vector<fastjet::PseudoJet> jets() const;
//! The corresponding event before jet clustering
UnclusteredEvent const & unclustered() const {
return ev_;
}
//! Central parameter choice
EventParameters const & central() const{
return ev_.central;
}
//! Central parameter choice
EventParameters & central(){
return ev_.central;
}
//! Incoming particles
std::array<Particle, 2> const & incoming() const{
return ev_.incoming;
}
//! Outgoing particles
std::vector<Particle> const & outgoing() const{
return ev_.outgoing;
}
//! Particle decays
/**
* The key in the returned map corresponds to the index in the
* vector returned by outgoing()
*/
std::unordered_map<int, std::vector<Particle>> const & decays() const{
return ev_.decays;
}
//! Parameter (scale) variations
std::vector<EventParameters> const & variations() const{
return ev_.variations;
}
//! Parameter (scale) variations
std::vector<EventParameters> & variations(){
return ev_.variations;
}
//! Parameter (scale) variation
/**
* @param i Index of the requested variation
*/
EventParameters const & variations(size_t i) const{
return ev_.variations[i];
}
//! Parameter (scale) variation
/**
* @param i Index of the requested variation
*/
EventParameters & variations(size_t i){
return ev_.variations[i];
}
//! Indices of the jets the outgoing partons belong to
/**
* @param jets Jets to be tested
* @returns A vector containing, for each outgoing parton,
* the index in the vector of jets the considered parton
* belongs to. If the parton is not inside any of the
* passed jets, the corresponding index is set to -1.
*/
std::vector<int> particle_jet_indices(
std::vector<fastjet::PseudoJet> const & jets
) const{
return cs_.particle_jet_indices(jets);
}
//! Jet definition used for clustering
fastjet::JetDefinition const & jet_def() const{
return cs_.jet_def();
}
//! Minimum jet transverse momentum
double min_jet_pt() const{
return min_jet_pt_;
}
//! Event type
event_type::EventType type() const{
return type_;
}
private:
UnclusteredEvent ev_;
fastjet::ClusterSequence cs_;
double min_jet_pt_;
event_type::EventType type_;
};
//! Square of the partonic centre-of-mass energy
double shat(Event const & ev);
//! Convert an event to a LHEF::HEPEUP
LHEF::HEPEUP to_HEPEUP(Event const & event, LHEF::HEPRUP *);
}
diff --git a/include/RHEJ/ScaleFunction.hh b/include/RHEJ/ScaleFunction.hh
index c7de1b9..43c88c9 100644
--- a/include/RHEJ/ScaleFunction.hh
+++ b/include/RHEJ/ScaleFunction.hh
@@ -1,153 +1,155 @@
/** \file
* \brief Functions to calculate the (renormalisation and factorisation) scales for an event
*/
#pragma once
#include <functional>
#include <vector>
#include <string>
#include <memory>
namespace RHEJ{
class Event;
//! Class to calculate the scale associated with an event
class ScaleFunction {
public:
//! Constructor
/**
* @param name Name of the scale choice (e.g. H_T)
* @param fun Function used to calculate the scale
*/
ScaleFunction(std::string name, std::function<double(Event const &)> fun):
name_{std::move(name)},
fun_{std::move(fun)}
{}
//! Name of the scale choice
std::string const & name() const {
return name_;
}
//! Calculate the scale associated with an event
double operator()(Event const & ev) const {
return fun_(ev);
}
private:
friend ScaleFunction operator*(double factor, ScaleFunction base_scale);
friend ScaleFunction operator/(ScaleFunction base_scale, double denom);
std::string name_;
std::function<double(Event const &)> fun_;
};
//! Multiply a scale choice by a constant factor
/**
* For example, multiplying 0.5 and a scale function for H_T
* will result in a scale function for H_T/2.
*/
ScaleFunction operator*(double factor, ScaleFunction base_scale);
//! Divide a scale choice by a constant factor
/**
* For example, dividing a scale function for H_T by 2
* will result in a scale function for H_T/2.
*/
ScaleFunction operator/(ScaleFunction base_scale, double denom);
//! Calculate \f$H_T\f$ for the input event
/**
* \f$H_T\f$ is the sum of the (scalar) transverse momenta of all
* final-state particles
*/
double H_T(Event const &);
//! The maximum of all (scalar) jet transverse momentum
double max_jet_pt(Event const &);
//! The invariant mass of the sum of all jet momenta
double jet_invariant_mass(Event const &);
//! Invariant mass of the two hardest jets
double m_j1j2(Event const &);
//! Functor that returns a fixed scale regardless of the input event
class FixedScale {
public:
explicit FixedScale(double mu): mu_{mu} {}
double operator()(Event const &) const {
return mu_;
}
private:
double mu_;
};
+ class ParameterDescription;
+
//! Generate combinations of renormalisation and factorisation scales
class ScaleGenerator{
public:
ScaleGenerator() = default;
/** \brief Constructor
* @param scale_functions_begin Iterator to first base scale
* @param scale_functions_end Iterator past last base scale
* @param scale_factors_begin Iterator to first scale factor
* @param scale_factors_end Iterator past last scale factor
* @param max_scale_ratio Maximum ratio between renormalisation
* and factorisation scale
*/
template<class ScaleFunIterator, class FactorIterator>
ScaleGenerator(
ScaleFunIterator scale_functions_begin,
ScaleFunIterator scale_functions_end,
FactorIterator scale_factors_begin,
FactorIterator scale_factors_end,
double max_scale_ratio
):
scales_(scale_functions_begin, scale_functions_end),
scale_factors_(scale_factors_begin, scale_factors_end),
max_scale_ratio_{max_scale_ratio}
{
- gen_scale_names();
+ gen_descriptions();
}
/** \brief Constructor
* @param scales Base scales
* @param scale_factors Factors to multiply the base scales
* @param max_scale_ratio Maximum ratio between renormalisation
* and factorisation scale
*/
ScaleGenerator(
std::vector<ScaleFunction> scales,
std::vector<double> scale_factors,
double max_scale_ratio
):
scales_(std::move(scales)),
scale_factors_(std::move(scale_factors)),
max_scale_ratio_{max_scale_ratio}
{
- gen_scale_names();
+ gen_descriptions();
}
/** \brief Adjust event parameters, adding scale variation
*
* The central renormalisation and factorisation scale of the returned
* event is given be the first base scale passed to the constructor.
* The scale variation (stored in event.variation()) is constructed as
* follows: For each base scale according to the arguments of the
* constructor we add one variation where both renormalisation and
* factorisation scale are set according to the current base scale.
* Then, all combinations where the base renormalisation and factorisation
* scales are multiplied by one of the scale factors are added.
* The case were both scales are multiplied by one is skipped.
* Scale combinations where the ratio is larger than the maximum scale ratio
* set in the constructor are likewise discarded.
*/
Event operator()(Event event) const;
private:
- void gen_scale_names();
+ void gen_descriptions();
std::vector<ScaleFunction> scales_;
std::vector<double> scale_factors_;
- std::vector<std::shared_ptr<std::string>> scale_names_;
+ std::vector<std::shared_ptr<ParameterDescription>> descriptions_;
double max_scale_ratio_;
};
}
diff --git a/src/ScaleFunction.cc b/src/ScaleFunction.cc
index d6dc2ee..aaedef8 100644
--- a/src/ScaleFunction.cc
+++ b/src/ScaleFunction.cc
@@ -1,158 +1,144 @@
#include "RHEJ/ScaleFunction.hh"
#include <numeric>
#include <cassert>
#include "RHEJ/Event.hh"
namespace RHEJ{
double H_T(Event const & ev){
double result = 0.;
for(size_t i = 0; i < ev.outgoing().size(); ++i){
auto const decay_products = ev.decays().find(i);
if(decay_products == end(ev.decays())){
result += ev.outgoing()[i].perp();
}
else{
for(auto const & particle: decay_products->second){
result += particle.perp();
}
}
}
return result;
}
double max_jet_pt(Event const & ev) {
return sorted_by_pt(ev.jets()).front().pt();
}
double jet_invariant_mass(Event const & ev) {
fastjet::PseudoJet sum;
for(const auto & jet: ev.jets()) sum+=jet;
return sum.m();
}
double m_j1j2(Event const & ev) {
const auto jets = sorted_by_pt(ev.jets());
assert(jets.size() >= 2);
return (jets[0] + jets[1]).m();
}
ScaleFunction operator*(double factor, ScaleFunction base_scale) {
base_scale.name_.insert(0, std::to_string(factor) + '*');
auto new_fun =
[factor,fun{std::move(base_scale.fun_)}](RHEJ::Event const & ev) {
return factor*fun(ev);
};
base_scale.fun_ = std::move(new_fun);
return base_scale;
}
ScaleFunction operator/(ScaleFunction base_scale, double denom) {
base_scale.name_.append('/' + std::to_string(denom));
auto new_fun =
[denom,fun{std::move(base_scale.fun_)}](RHEJ::Event const & ev) {
return fun(ev)/denom;
};
base_scale.fun_ = std::move(new_fun);
return base_scale;
}
- namespace {
- std::shared_ptr<std::string> description(
- std::string const & mur_name, std::string const & muf_name
- ) {
- return std::make_shared<std::string>(
- "mur=" + mur_name + ", muf=" + muf_name
- );
- }
- }
-
// TODO: significant logic duplication with operator()
- void ScaleGenerator::gen_scale_names() {
- // stringstream gives nicer formatting for doubles than to_string
- std::stringstream str;
+ void ScaleGenerator::gen_descriptions() {
if(scales_.empty()) {
throw std::logic_error{"Need at least one scale"};
}
- scale_names_.emplace_back(
- description(scales_.front().name(), scales_.front().name())
+ descriptions_.emplace_back(
+ std::make_shared<ParameterDescription>(scales_.front().name(), 1., 1.)
);
for(auto & base_scale: scales_){
const auto base_name = base_scale.name();
- scale_names_.emplace_back(description(base_name, base_name));
+ descriptions_.emplace_back(
+ std::make_shared<ParameterDescription>(base_name, 1., 1.)
+ );
//multiplicative scale variation
for(double mur_factor: scale_factors_){
- std::string mur_name;
- str << mur_factor << '*' << base_name;
- str >> mur_name;
- str.clear();
for(double muf_factor: scale_factors_){
if(muf_factor == 1. && mur_factor == 1.) continue;
- std::string muf_name;
- str << muf_factor << '*' << base_name;
- str >> muf_name;
- str.clear();
if(
mur_factor/muf_factor < 1/max_scale_ratio_
|| mur_factor/muf_factor > max_scale_ratio_
) continue;
- scale_names_.emplace_back(description(mur_name, muf_name));
+ descriptions_.emplace_back(
+ std::make_shared<ParameterDescription>(
+ base_name, mur_factor, muf_factor
+ )
+ );
}
}
}
}
Event ScaleGenerator::operator()(Event ev) const {
if(! ev.variations().empty()) {
throw std::invalid_argument{"Input event already has scale variation"};
}
assert(!scales_.empty());
- assert(!scale_names_.empty());
+ assert(!descriptions_.empty());
- size_t name_idx = 0;
+ size_t descr_idx = 0;
const double mu_central = (scales_.front())(ev);
ev.central().mur = mu_central;
ev.central().muf = mu_central;
- assert(name_idx < scale_names_.size());
- assert(scale_names_[name_idx]);
- ev.central().description = scale_names_[name_idx++];
+ assert(descr_idx < descriptions_.size());
+ assert(descriptions_[descr_idx]);
+ ev.central().description = descriptions_[descr_idx++];
// check if we are doing scale variation at all
if(scales_.size() == 1 && scale_factors_.empty()) return ev;
for(auto & base_scale: scales_){
const double mu_base = base_scale(ev);
- assert(name_idx < scale_names_.size());
- assert(scale_names_[name_idx]);
+ assert(descr_idx < descriptions_.size());
+ assert(descriptions_[descr_idx]);
ev.variations().emplace_back(
EventParameters{
- mu_base, mu_base, ev.central().weight, scale_names_[name_idx++]
+ mu_base, mu_base, ev.central().weight, descriptions_[descr_idx++]
}
);
//multiplicative scale variation
for(double mur_factor: scale_factors_){
const double mur = mu_base*mur_factor;
for(double muf_factor: scale_factors_){
if(muf_factor == 1. && mur_factor == 1.) continue;
const double muf = mu_base*muf_factor;
if(
mur/muf < 1/max_scale_ratio_
|| mur/muf > max_scale_ratio_
) continue;
- assert(name_idx < scale_names_.size());
- assert(scale_names_[name_idx]);
+ assert(descr_idx < descriptions_.size());
+ assert(descriptions_[descr_idx]);
ev.variations().emplace_back(
EventParameters{
- mur, muf, ev.central().weight, scale_names_[name_idx++]
+ mur, muf, ev.central().weight, descriptions_[descr_idx++]
}
);
}
}
};
return ev;
}
}
diff --git a/t/test_descriptions.cc b/t/test_descriptions.cc
new file mode 100644
index 0000000..be6a61b
--- /dev/null
+++ b/t/test_descriptions.cc
@@ -0,0 +1,61 @@
+#include <iostream>
+#include <cstddef>
+
+#include "RHEJ/ScaleFunction.hh"
+#include "RHEJ/EventReweighter.hh"
+
+#define ASSERT(x) if(!(x)) { \
+ std::cerr << "Assertion '" #x "' failed.\n"; \
+ return EXIT_FAILURE; \
+ }
+
+int main() {
+ constexpr double mu = 125.;
+ RHEJ::ScaleFunction fun{"125", RHEJ::FixedScale{mu}};
+ ASSERT(fun.name() == "125");
+
+ RHEJ::ScaleGenerator scale_gen{
+ {std::move(fun)}, {0.5, 1, 2.}, 2.1
+ };
+ RHEJ::UnclusteredEvent tmp;
+ tmp.outgoing.push_back(
+ {RHEJ::ParticleID::gluon, fastjet::PtYPhiM(50., -1., 0.3, 0.)}
+ );
+ tmp.outgoing.push_back(
+ {RHEJ::ParticleID::gluon, fastjet::PtYPhiM(30., 1., -0.3, 0.)}
+ );
+ RHEJ::Event ev{
+ std::move(tmp),
+ fastjet::JetDefinition{fastjet::kt_algorithm, 0.4},
+ 20.
+ };
+
+ auto rescaled = scale_gen(std::move(ev));
+ ASSERT(rescaled.central().description->scale_name == "125");
+ for(auto const & var: rescaled.variations()) {
+ ASSERT(var.description->scale_name == "125");
+ }
+ ASSERT(rescaled.central().description->mur_factor == 1.);
+ ASSERT(rescaled.central().description->muf_factor == 1.);
+
+ ASSERT(rescaled.variations(0).description->mur_factor == 1.);
+ ASSERT(rescaled.variations(0).description->muf_factor == 1.);
+
+ ASSERT(rescaled.variations(1).description->mur_factor == 0.5);
+ ASSERT(rescaled.variations(1).description->muf_factor == 0.5);
+
+ ASSERT(rescaled.variations(2).description->mur_factor == 0.5);
+ ASSERT(rescaled.variations(2).description->muf_factor == 1.);
+
+ ASSERT(rescaled.variations(3).description->mur_factor == 1.);
+ ASSERT(rescaled.variations(3).description->muf_factor == 0.5);
+
+ ASSERT(rescaled.variations(4).description->mur_factor == 1.);
+ ASSERT(rescaled.variations(4).description->muf_factor == 2.);
+
+ ASSERT(rescaled.variations(5).description->mur_factor == 2.);
+ ASSERT(rescaled.variations(5).description->muf_factor == 1.);
+
+ ASSERT(rescaled.variations(6).description->mur_factor == 2.);
+ ASSERT(rescaled.variations(6).description->muf_factor == 2.);
+}
diff --git a/t/test_scale_names.cc b/t/test_scale_names.cc
deleted file mode 100644
index 29ccb0c..0000000
--- a/t/test_scale_names.cc
+++ /dev/null
@@ -1,42 +0,0 @@
-#include <iostream>
-#include <cstddef>
-
-#include "RHEJ/ScaleFunction.hh"
-#include "RHEJ/EventReweighter.hh"
-
-#define ASSERT(x) if(!(x)) { \
- std::cerr << "Assertion '" #x "' failed.\n"; \
- return EXIT_FAILURE; \
- }
-
-int main() {
- constexpr double mu = 125.;
- RHEJ::ScaleFunction fun{"125", RHEJ::FixedScale{mu}};
- ASSERT(fun.name() == "125");
-
- RHEJ::ScaleGenerator scale_gen{
- {std::move(fun)}, {0.5, 1, 2.}, 2.1
- };
- RHEJ::UnclusteredEvent tmp;
- tmp.outgoing.push_back(
- {RHEJ::ParticleID::gluon, fastjet::PtYPhiM(50., -1., 0.3, 0.)}
- );
- tmp.outgoing.push_back(
- {RHEJ::ParticleID::gluon, fastjet::PtYPhiM(30., 1., -0.3, 0.)}
- );
- RHEJ::Event ev{
- std::move(tmp),
- fastjet::JetDefinition{fastjet::kt_algorithm, 0.4},
- 20.
- };
-
- auto rescaled = scale_gen(std::move(ev));
- ASSERT(*rescaled.central().description == "mur=125, muf=125");
- ASSERT(*rescaled.variations(0).description == "mur=125, muf=125");
- ASSERT(*rescaled.variations(1).description == "mur=0.5*125, muf=0.5*125");
- ASSERT(*rescaled.variations(2).description == "mur=0.5*125, muf=1*125");
- ASSERT(*rescaled.variations(3).description == "mur=1*125, muf=0.5*125");
- ASSERT(*rescaled.variations(4).description == "mur=1*125, muf=2*125");
- ASSERT(*rescaled.variations(5).description == "mur=2*125, muf=1*125");
- ASSERT(*rescaled.variations(6).description == "mur=2*125, muf=2*125");
-}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Jan 20, 8:36 PM (12 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4242259
Default Alt Text
(27 KB)

Event Timeline