Page MenuHomeHEPForge

No OneTemporary

diff --git a/include/RHEJ/EventReweighter.hh b/include/RHEJ/EventReweighter.hh
index abccde6..105f68a 100644
--- a/include/RHEJ/EventReweighter.hh
+++ b/include/RHEJ/EventReweighter.hh
@@ -1,194 +1,193 @@
/** \file EventReweighter.hh
* \brief Main class for reweighting events according to the reversed HEJ method
*
- * EventReweighter Class is the main class used within RHEJ. It reweights the
+ * EventReweighter Class is the main class used within RHEJ. It reweights the
* resummation events.
*/
#pragma once
#include "fastjet/PseudoJet.hh"
#include "fastjet/ClusterSequence.hh"
#include "LHEF/LHEF.h"
#include "RHEJ/PDF.hh"
#include "RHEJ/utility.hh"
#include "RHEJ/Event.hh"
#include "RHEJ/event_classes.hh"
#include "RHEJ/config.hh"
#include "RHEJ/PhaseSpacePoint.hh"
#include "RHEJ/MatrixElement.hh"
namespace RHEJ{
class ScaleGenerator;
/** \struct Beam EventReweighter.hh "include/RHEJ/EventReweighter.hh"
* \brief Beam Struct. Contains beam energy and incoming particle content.
*
* Contains the value of the energy of the beam and the identity of the two incoming Particles
*/
struct Beam{
double E;
std::array<ParticleID, 2> type;
};
/** \class EventReweighter EventReweighter.hh "include/RHEJ/EventReweighter.hh"
* \brief EventReweighter Main class for reweighting events in RHEJ.
*
* This is the class which reweights the resummation phase space points once they have been
* generated by PhaseSpacePoint. This class also handles how many phase space points are generated
- * for every fixed order event which is processed.
+ * for every fixed order event which is processed.
*/
class EventReweighter{
using EventClass = event_class::EventClass;
public:
EventReweighter(
Beam beam, /**< Beam Energy */
int pdf_id, /**< PDF ID */
fastjet::JetDefinition jet_def, /**< Jet Definition */
double jetptmin, /**< Jet Pt minimum */
EventTreatMap treat, /**< Treat??? */
double extpartonptmin, /**< External Parton Pt Minimum */
double max_ext_soft_pt_fraction, /**< External Parton Pt Maximum */
bool log_corr /**< Log Correct On or Off */
);
EventReweighter(
LHEF::HEPRUP const & heprup, /**< HEPRUP???? */
fastjet::JetDefinition jet_def, /**< Jet Definition */
double jetptmin, /**< Jet Pt minimum */
EventTreatMap treat, /**< Treat??? */
double extpartonptmin, /**< External Parton Pt Minimum */
double max_ext_soft_pt_fraction, /**< External Parton Pt Maximum */
bool log_corr /**< Log Correct On or Off */
);
PDF const & pdf() const; /**< PDF Used */
-
+
std::vector<ClusteredEvent> reweight(
ClusteredEvent const & ev, /**< Clustered Event For Reweighing */
int num_events /**< Number of Events */
);
-
+
std::vector<ClusteredEvent> reweight(
ClusteredEvent const & ev, /**< Clustered Event For Reweighing */
int num_events, /**< Number of Events */
ScaleGenerator const & gen_scales /**< Generated Scales see config.hh */
);
- //! Constructor for last_event_class
+ //! Constructor for last_event_class
EventClass last_event_class() const;
private:
/** \struct EventFactors EventReweighter.hh "include/RHEJ/EventReweighter.hh"
* \brief EventFactors Struct containing central value and variations
*
- * Contains the Central Value and Variation around
+ * Contains the Central Value and Variation around
*/
struct EventFactors{
double central; /**< Central Value for the Factor */
std::vector<double> variations; /**< Vector of Variations from central value */
};
template<typename... T>
PDF const & pdf(T&& ...);
std::vector<ClusteredEvent> gen_res_events(
ClusteredEvent const & ev, int num_events
);
std::vector<ClusteredEvent> rescale(
- Event const & Born_ev, /**< */
- std::vector<ClusteredEvent> events
+ ClusteredEvent const & Born_ev, std::vector<ClusteredEvent> events
) const;
/**
* \brief Do the Jets pass the resummation Cuts?
*
* @param ev ClusteredEvent in Question
* @returns 0 or 1 depending on if ev passes Jet Cuts
*/
bool jets_pass_resummation_cuts(ClusteredEvent const & ev) const;
/**
* \brief pdf_factors Function
*
* @param ev Event in Question
* @returns EventFactor due to PDFs
*
- * Calculates the Central value and the variation due
+ * Calculates the Central value and the variation due
* to the PDF choice made.
*/
- EventFactors pdf_factors(Event const & ev) const;
+ EventFactors pdf_factors(ClusteredEvent const & ev) const;
/**
* \brief matrix_elements Function
*
* @param ev Event in question
* @returns EventFactor due to MatrixElements
*
- * Calculates the Central value and the variation due
+ * Calculates the Central value and the variation due
* to the Matrix Element.
*/
- EventFactors matrix_elements(Event const & ev) const;
+ EventFactors matrix_elements(ClusteredEvent const & ev) const;
/**
* \brief Scale-dependent part of fixed-order matrix element
*
* @param ev Event in question
* @returns EventFactor scale variation due to FO-ME.
*
* This is only called to compute the scale variation for events where
* we don't do resummation (e.g. non-FKL).
* Since at tree level the scale dependence is just due to alpha_s,
* it is enough to return the alpha_s(mur) factors in the matrix element.
* The rest drops out in the ratio of (output event ME)/(input event ME),
* so we never have to compute it.
*/
- EventFactors fixed_order_scale_ME(Event const & ev) const;
+ EventFactors fixed_order_scale_ME(ClusteredEvent const & ev) const;
/**
* \brief Computes the tree level matrix element
*
* @param ev Event in Question
* @returns HEJ approximation to Tree level Matrix Element
*
- * This computes the HEJ approximation to the tree level FO
+ * This computes the HEJ approximation to the tree level FO
* Matrix element which is used within the LO weighting process.
*/
- double tree_matrix_element(Event const & ev) const;
+ double tree_matrix_element(ClusteredEvent const & ev) const;
/**
* \brief Generation of Resummation Phase Space Points
*
* @param ev Event In Question
* @returns Resummation PhaseSpacePoint
*
* Where is this even called? I can't find it with a grep -r in top directory???
*/
PhaseSpacePoint gen_PhaseSpacePoint(Event const & ev) const;
-
+
EventClass last_event_class_; /**< Class of the last event */
-
+
double extpartonptmin_; /**< External Parton Minimum Pt */
double max_ext_soft_pt_fraction_; /**< External Parton Maximum Pt fraction */
double jetptmin_; /**< Jet Pt Minimum threshold */
double E_beam_; /**< Energy of Beam */
fastjet::JetDefinition jet_def_; /**< Jet Definition being used */
PDF pdf_; /**< Relevant PDF */
MatrixElement MEt2_; /**< Matrix Element Object */
EventTreatMap treat_;
};
template<typename... T>
PDF const & EventReweighter::pdf(T&&... t){
return pdf_ = PDF{std::forward<T>(t)...};
}
}
diff --git a/src/EventReweighter.cc b/src/EventReweighter.cc
index 6829ff2..bba3878 100644
--- a/src/EventReweighter.cc
+++ b/src/EventReweighter.cc
@@ -1,316 +1,316 @@
#include "RHEJ/EventReweighter.hh"
#include <string>
#include <unordered_map>
#include "RHEJ/PhaseSpacePoint.hh"
#include "RHEJ/PDG_codes.hh"
#include "RHEJ/config.hh" // ScaleGenerator definition
#include "RHEJ/debug.hh"
namespace RHEJ{
using EventClass = event_class::EventClass;
namespace {
static_assert(
std::numeric_limits<double>::has_quiet_NaN,
"no quiet NaN for double"
);
constexpr double NaN = std::numeric_limits<double>::quiet_NaN();
Event to_Event(PhaseSpacePoint const & psp){
Event result;
result.incoming = psp.incoming();
std::sort(
begin(result.incoming), end(result.incoming),
[](Sparticle o1, Sparticle o2){return o1.p.pz()<o2.p.pz();}
);
assert(result.incoming.size() == 2);
result.outgoing = psp.outgoing();
assert(
std::is_sorted(
begin(result.outgoing), end(result.outgoing),
rapidity_less{}
)
);
assert(result.outgoing.size() >= 2);
result.central.mur = NaN;
result.central.muf = NaN;
result.central.weight = psp.weight();
return result;
}
} // anonymous namespace
EventReweighter::EventReweighter(
LHEF::HEPRUP const & heprup,
fastjet::JetDefinition jet_def, double jetptmin,
EventTreatMap treat,
double extpartonptmin, double max_ext_soft_pt_fraction,
bool log_corr
):
EventReweighter{
RHEJ::Beam{
heprup.EBMUP.first,
{{
static_cast<RHEJ::ParticleID>(heprup.IDBMUP.first),
static_cast<RHEJ::ParticleID>(heprup.IDBMUP.second)
}}
},
heprup.PDFSUP.first,
jet_def, jetptmin,
std::move(treat),
extpartonptmin, max_ext_soft_pt_fraction,
log_corr
}
{
if(heprup.EBMUP.second != E_beam_){
throw std::invalid_argument(
"asymmetric beam: " + std::to_string(E_beam_)
+ " ---> <--- " + std::to_string(heprup.EBMUP.second)
);
};
if(heprup.PDFSUP.second != pdf_.id()){
throw std::invalid_argument(
"conflicting PDF ids: " + std::to_string(pdf_.id())
+ " vs. " + std::to_string(heprup.PDFSUP.second)
);
}
}
EventReweighter::EventReweighter(
Beam beam,
int pdf_id,
fastjet::JetDefinition jet_def, double jetptmin,
EventTreatMap treat,
double extpartonptmin, double max_ext_soft_pt_fraction,
bool log_corr
):
extpartonptmin_{extpartonptmin},
max_ext_soft_pt_fraction_{max_ext_soft_pt_fraction},
jetptmin_{jetptmin},
E_beam_{beam.E},
jet_def_{jet_def},
pdf_{pdf_id, beam.type.front(), beam.type.back()},
MEt2_{jet_def, jetptmin, log_corr},
treat_{std::move(treat)}
{}
PDF const & EventReweighter::pdf() const{
return pdf_;
}
EventClass EventReweighter::last_event_class() const{
return last_event_class_;
}
namespace{
static_assert(
std::numeric_limits<double>::has_infinity, "infinity not supported"
);
// there is no simple way to create a vector of move-only objects
// this is a clumsy work-around
ScaleGenerator make_identity(){
std::vector<std::unique_ptr<ScaleFunction>> scale_fun;
scale_fun.emplace_back(new InputScales);
return ScaleGenerator{
ScaleConfig{
std::move(scale_fun), {}, std::numeric_limits<double>::infinity()
}
};
}
const ScaleGenerator identity{make_identity()};
}
std::vector<ClusteredEvent> EventReweighter::reweight(
ClusteredEvent const & input_ev, int num_events
){
return reweight(input_ev, num_events, identity);
}
std::vector<ClusteredEvent> EventReweighter::reweight(
ClusteredEvent const & input_ev, int num_events,
ScaleGenerator const & gen_scales
){
auto res_events = gen_res_events(input_ev, num_events);
if(res_events.empty()) return {};
for(auto & event: res_events) event = gen_scales(event);
return rescale(input_ev, std::move(res_events));
}
// main generation/reweighting function
// generate phase space points and divide out Born factors
std::vector<ClusteredEvent> EventReweighter::gen_res_events(
ClusteredEvent const & ev,
int phase_space_points
){
assert(ev.variations().empty());
last_event_class_ = classify(ev);
switch(treat_.at(last_event_class_)){
case EventTreatment::discard: return {};
case EventTreatment::keep:
if(! jets_pass_resummation_cuts(ev)) return {};
else return {ev};
default:;
}
const double Born_shat = shat(ev);
std::vector<ClusteredEvent> resummation_events;
for(int psp_number = 0; psp_number < phase_space_points; ++psp_number){
PhaseSpacePoint psp{
ev,
jet_def_, jetptmin_,
extpartonptmin_, max_ext_soft_pt_fraction_
};
if(psp.weight() == 0.) continue;
resummation_events.emplace_back(
to_Event(std::move(psp)), jet_def_, jetptmin_
);
auto & new_event = resummation_events.back();
assert(new_event.variations().empty());
new_event.central().mur = ev.central().mur;
new_event.central().muf = ev.central().muf;
const double resum_shat = shat(new_event);
new_event.central().weight *= ev.central().weight*Born_shat*Born_shat/
(phase_space_points*resum_shat*resum_shat);
}
return resummation_events;
}
std::vector<ClusteredEvent> EventReweighter::rescale(
- Event const & Born_ev,
+ ClusteredEvent const & Born_ev,
std::vector<ClusteredEvent> events
) const{
const double Born_pdf = pdf_factors(Born_ev).central;
const double Born_ME = tree_matrix_element(Born_ev);
for(auto & cur_event: events){
const auto pdf = pdf_factors(cur_event);
assert(pdf.variations.size() == cur_event.variations().size());
const auto ME = matrix_elements(cur_event);
assert(ME.variations.size() == cur_event.variations().size());
cur_event.central().weight *= pdf.central*ME.central/(Born_pdf*Born_ME);
for(size_t i = 0; i < cur_event.variations().size(); ++i){
cur_event.variations(i).weight *=
pdf.variations[i]*ME.variations[i]/(Born_pdf*Born_ME);
}
}
return events;
};
bool EventReweighter::jets_pass_resummation_cuts(
ClusteredEvent const & ev
) const{
const auto out_as_PseudoJet = to_PseudoJet(filter_partons(ev.outgoing()));
fastjet::ClusterSequence cs{out_as_PseudoJet, jet_def_};
return cs.inclusive_jets(jetptmin_).size() == ev.jets().size();
}
-
+
EventReweighter::EventFactors
- EventReweighter::pdf_factors(Event const & ev) const{
- auto const & a = ev.incoming.front();
- auto const & b = ev.incoming.back();
+ EventReweighter::pdf_factors(ClusteredEvent const & ev) const{
+ auto const & a = ev.incoming().front();
+ auto const & b = ev.incoming().back();
const double xa = a.p.e()/E_beam_;
const double xb = b.p.e()/E_beam_;
EventFactors result;
std::unordered_map<double, double> known_pdf;
result.central =
- pdf_.pdfpt(0,xa,ev.central.muf,a.type)*
- pdf_.pdfpt(1,xb,ev.central.muf,b.type);
- known_pdf.emplace(ev.central.muf, result.central);
+ pdf_.pdfpt(0,xa,ev.central().muf,a.type)*
+ pdf_.pdfpt(1,xb,ev.central().muf,b.type);
+ known_pdf.emplace(ev.central().muf, result.central);
- result.variations.reserve(ev.variations.size());
- for(auto const & param: ev.variations){
+ result.variations.reserve(ev.variations().size());
+ for(auto const & param: ev.variations()){
const double muf = param.muf;
auto cur_pdf = known_pdf.find(muf);
if(cur_pdf == known_pdf.end()){
cur_pdf = known_pdf.emplace(
muf,
pdf_.pdfpt(0,xa,muf,a.type)*pdf_.pdfpt(1,xb,muf,b.type)
).first;
}
result.variations.emplace_back(cur_pdf->second);
}
- assert(result.variations.size() == ev.variations.size());
+ assert(result.variations.size() == ev.variations().size());
return result;
}
-
+
EventReweighter::EventFactors
- EventReweighter::matrix_elements(Event const & ev) const{
+ EventReweighter::matrix_elements(ClusteredEvent const & ev) const{
assert(treat_.count(last_event_class_) > 0);
if(treat_.find(last_event_class_)->second == EventTreatment::keep){
return fixed_order_scale_ME(ev);
}
// precompute overall kinematic factor
- const double ME_kin = MEt2_.tree_kin(ev.incoming, ev.outgoing, true);
+ const double ME_kin = MEt2_.tree_kin(ev.incoming(), ev.outgoing(), true);
EventFactors result;
std::unordered_map<double, double> known_ME;
result.central = MEt2_(
- pdf_.Halphas(ev.central.mur), ev.central.mur,
- ev.incoming, ev.outgoing,
+ pdf_.Halphas(ev.central().mur), ev.central().mur,
+ ev.incoming(), ev.outgoing(),
true
);
- known_ME.emplace(ev.central.mur, result.central);
+ known_ME.emplace(ev.central().mur, result.central);
- result.variations.reserve(ev.variations.size());
- for(auto const & param: ev.variations){
+ result.variations.reserve(ev.variations().size());
+ for(auto const & param: ev.variations()){
const double mur = param.mur;
auto cur_ME = known_ME.find(mur);
if(cur_ME == known_ME.end()){
const double alpha_s = pdf_.Halphas(mur);
const double ME = MEt2_.tree_param(
- alpha_s, mur, ev.incoming, ev.outgoing
+ alpha_s, mur, ev.incoming(), ev.outgoing()
)*ME_kin*MEt2_.virtual_corrections(
- alpha_s, mur, ev.incoming, ev.outgoing
+ alpha_s, mur, ev.incoming(), ev.outgoing()
);
cur_ME = known_ME.emplace(mur, ME).first;
}
result.variations.emplace_back(cur_ME->second);
}
- assert(result.variations.size() == ev.variations.size());
+ assert(result.variations.size() == ev.variations().size());
return result;
}
- double EventReweighter::tree_matrix_element(Event const & ev) const{
- assert(ev.variations.empty());
+ double EventReweighter::tree_matrix_element(ClusteredEvent const & ev) const{
+ assert(ev.variations().empty());
assert(treat_.count(last_event_class_) > 0);
if(treat_.find(last_event_class_)->second == EventTreatment::keep){
return fixed_order_scale_ME(ev).central;
}
return MEt2_.tree(
- pdf_.Halphas(ev.central.mur), ev.central.mur,
- ev.incoming, ev.outgoing,
+ pdf_.Halphas(ev.central().mur), ev.central().mur,
+ ev.incoming(), ev.outgoing(),
false
);
}
EventReweighter::EventFactors
- EventReweighter::fixed_order_scale_ME(Event const & ev) const{
+ EventReweighter::fixed_order_scale_ME(ClusteredEvent const & ev) const{
const int alpha_s_power = std::count_if(
- begin(ev.outgoing), end(ev.outgoing),
+ begin(ev.outgoing()), end(ev.outgoing()),
[](Sparticle const & p){ return is_parton(p); }
);
EventFactors result;
- result.central = pow(pdf_.Halphas(ev.central.mur), alpha_s_power);
- for(auto const & var: ev.variations){
+ result.central = pow(pdf_.Halphas(ev.central().mur), alpha_s_power);
+ for(auto const & var: ev.variations()){
result.variations.emplace_back(
pow(pdf_.Halphas(var.mur), alpha_s_power)
);
}
return result;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Tue, Nov 19, 2:40 PM (1 d, 12 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3804779
Default Alt Text
(19 KB)

Event Timeline