hej
is hosted by
Hepforge
,
IPPP Durham
HEJ
2.2.2
High energy resummation for hadron colliders
Loading...
Searching...
No Matches
include
HEJ
utility.hh
Go to the documentation of this file.
1
9
#pragma once
10
11
#include <array>
12
#include <memory>
13
#include <string>
14
15
#include "boost/core/demangle.hpp"
16
17
#include "fastjet/PseudoJet.hh"
18
19
namespace
HEJ
{
20
21
inline
22
std::string
join
(
23
std::string
const
&
/* delim */
24
){
25
return
""
;
26
}
27
28
inline
29
std::string
join
(
30
std::string
const
&
/* delim */
, std::string
const
& str
31
){
32
return
str;
33
}
34
36
42
template
<
typename
... Strings>
43
std::string
join
(
44
std::string
const
& delim,
45
std::string
const
& first, std::string
const
& second,
46
Strings&&... rest
47
){
48
return
join
(delim, first + delim + second, std::forward<Strings>(rest)...);
49
}
50
52
template
<
typename
T>
53
std::string
type_string
(T&&
/*unused*/
){
54
return
boost::core::demangle(
typeid
(T).name());
55
}
56
58
template
<
typename
... T>
59
constexpr
void
ignore
(T&&...
/*unused*/
) {}
60
62
inline
63
constexpr
bool
nearby_ep
(
double
a,
double
b,
double
ep){
64
assert(ep >= 0);
65
return
std::abs(a-b) < ep;
66
}
67
69
inline
70
bool
nearby_ep
(
71
fastjet::PseudoJet
const
& pa, fastjet::PseudoJet
const
& pb,
72
double
ep
73
){
74
assert(ep >= 0);
75
for
(
size_t
i = 0; i < 4; ++i){
76
if
(!
nearby_ep
(pa[i], pb[i], ep))
return
false
;
77
}
78
return
true
;
79
}
80
81
inline
82
bool
nearby
(
83
fastjet::PseudoJet
const
& pa, fastjet::PseudoJet
const
& pb,
84
double
const
norm = 1.
85
){
86
return
nearby_ep
(pa, pb, 1e-7*norm);
87
}
88
89
namespace
detail {
90
template
<
typename
T, std::size_t N, std::size_t... Ns>
91
struct
ArrayTag
{
92
using
type
=
typename
ArrayTag<std::array<T, N>
, Ns...>
::type
;
93
};
94
template
<
typename
T, std::
size_t
N>
95
struct
ArrayTag
<T, N> {
96
using
type
= std::array<T, N>;
97
};
98
}
99
// helper for multidimensional std::array, for example
100
// MultiArray<T, N1, N2> = std::array<std::array<T, N1>, N2>
101
template
<
typename
T, std::size_t N, std::size_t... Ns>
102
using
MultiArray
=
typename
detail::ArrayTag
<T, N, Ns...>::type;
103
105
template
<
class
Event>
106
bool
momentum_conserved
(
Event
const
&ev,
const
double
tolerance = 1e-7) {
107
fastjet::PseudoJet diff;
108
for
(
auto
const
&in : ev.
incoming
()) diff += in.p;
109
const
double
norm = diff.E();
110
for
(
auto
const
&out : ev.
outgoing
()) diff -= out.p;
111
return
nearby_ep
(diff, fastjet::PseudoJet{}, tolerance*norm);
112
}
113
114
}
// namespace HEJ
HEJ::Event
An event with clustered jets.
Definition:
Event.hh:51
HEJ::Event::incoming
std::array< Particle, 2 > const & incoming() const
Incoming particles.
Definition:
Event.hh:70
HEJ::Event::outgoing
std::vector< Particle > const & outgoing() const
Outgoing particles.
Definition:
Event.hh:74
HEJ
Main HEJ 2 Namespace.
Definition:
mainpage.dox:1
HEJ::ignore
constexpr void ignore(T &&...)
Eliminate compiler warnings for unused variables.
Definition:
utility.hh:59
HEJ::momentum_conserved
bool momentum_conserved(Event const &ev, const double tolerance=1e-7)
Check momentum conservation.
Definition:
utility.hh:106
HEJ::type_string
std::string type_string(T &&)
Return the name of the argument's type.
Definition:
utility.hh:53
HEJ::join
std::string join(std::string const &)
Definition:
utility.hh:22
HEJ::MultiArray
typename detail::ArrayTag< T, N, Ns... >::type MultiArray
Definition:
utility.hh:102
HEJ::nearby
bool nearby(fastjet::PseudoJet const &pa, fastjet::PseudoJet const &pb, double const norm=1.)
Definition:
utility.hh:82
HEJ::nearby_ep
constexpr bool nearby_ep(double a, double b, double ep)
Check whether two doubles are closer than ep >= 0 to each other.
Definition:
utility.hh:63
HEJ::detail::ArrayTag< T, N >::type
std::array< T, N > type
Definition:
utility.hh:96
HEJ::detail::ArrayTag
Definition:
utility.hh:91
HEJ::detail::ArrayTag::type
typename ArrayTag< std::array< T, N >, Ns... >::type type
Definition:
utility.hh:92
Generated by
1.9.5