hej is hosted by Hepforge, IPPP Durham
HEJ 2 2.0
High energy resummation for hadron colliders
Loading...
Searching...
No Matches
utility.hh
Go to the documentation of this file.
1
10#pragma once
11
12#include <memory>
13
14#include <boost/core/demangle.hpp>
15
16#include "fastjet/PseudoJet.hh"
17
18namespace HEJ{
19
21
25 template<class T, class... Args>
26 std::unique_ptr<T> make_unique(Args&&... a){
27 return std::unique_ptr<T>{new T{std::forward<Args>(a)...}};
28 }
29
31 template<typename T, typename... U>
32 constexpr
33 std::array<T, 1 + sizeof...(U)> make_array(T t, U&&... rest){
34 return {{t, std::forward<U>(rest)...}};
35 }
36
37
38 inline
39 std::string join(
40 std::string const & /* delim */
41 ){
42 return "";
43 }
44
45 inline
46 std::string join(
47 std::string const & /* delim */, std::string const & str
48 ){
49 return str;
50 }
51
53
59 template<typename... Strings>
60 std::string join(
61 std::string const & delim,
62 std::string const & first, std::string const & second,
63 Strings&&... rest
64 ){
65 return join(delim, first + delim + second, std::forward<Strings>(rest)...);
66 }
67
69 template<typename T>
70 std::string type_string(T&&){
71 return boost::core::demangle(typeid(T).name());
72 }
73
75 template<typename... T>
76 constexpr void ignore(T&&...) {}
77
79 inline
80 bool nearby_ep(double a, double b, double ep){
81 assert(ep > 0);
82 return std::abs(a-b) < ep;
83 }
84
86 inline
88 fastjet::PseudoJet const & pa, fastjet::PseudoJet const & pb,
89 double ep
90 ){
91 assert(ep > 0);
92 for(size_t i = 0; i < 4; ++i){
93 if(!nearby_ep(pa[i], pb[i], ep)) return false;
94 }
95 return true;
96 }
97
98 inline
99 bool nearby(
100 fastjet::PseudoJet const & pa, fastjet::PseudoJet const & pb, double const norm = 1.
101 ){
102 return nearby_ep(pa, pb, 1e-7*norm);
103 }
104
105}
Main HEJ 2 Namespace.
Definition: mainpage.dox:1
constexpr void ignore(T &&...)
Eliminate compiler warnings for unused variables.
Definition: utility.hh:76
bool nearby_ep(double a, double b, double ep)
Check whether two doubles are closer than ep > 0 to each other.
Definition: utility.hh:80
std::string type_string(T &&)
Return the name of the argument's type.
Definition: utility.hh:70
constexpr std::array< T, 1+sizeof...(U)> make_array(T t, U &&... rest)
Create an array containing the passed arguments.
Definition: utility.hh:33
std::string join(std::string const &)
Definition: utility.hh:39
bool nearby(fastjet::PseudoJet const &pa, fastjet::PseudoJet const &pb, double const norm=1.)
Definition: utility.hh:99
std::unique_ptr< T > make_unique(Args &&... a)
Create a std::unique_ptr to a T object.
Definition: utility.hh:26