thepeg
is hosted by
Hepforge
,
IPPP Durham
ThePEG
2.3.0
Cuts
FuzzyTheta.h
1
// -*- C++ -*-
2
//
3
// FuzzyTheta.h is a part of ThePEG - Toolkit for HEP Event Generation
4
// Copyright (C) 1999-2019 Leif Lonnblad
5
// Copyright (C) 2009-2019 Simon Platzer
6
//
7
// ThePEG is licenced under version 3 of the GPL, see COPYING for details.
8
// Please respect the MCnet academic guidelines, see GUIDELINES for details.
9
//
10
#ifndef ThePEG_FuzzyTheta_H
11
#define ThePEG_FuzzyTheta_H
12
//
13
// This is the declaration of the FuzzyTheta class.
14
//
15
16
#include "ThePEG/Interface/Interfaced.h"
17
#include "ThePEG/Repository/EventGenerator.h"
18
#include <cassert>
19
20
namespace
ThePEG
{
21
22
namespace
CutTypes {
23
27
struct
Energy
{};
28
32
struct
Momentum
{};
33
37
struct
Rapidity
{};
38
42
struct
Azimuth
{};
43
47
struct
Polar
{};
48
49
}
50
57
class
FuzzyTheta
:
public
Interfaced
{
58
59
public
:
60
64
FuzzyTheta
();
65
66
public
:
67
74
virtual
pair<double,double>
support
(
double
x)
const
{
75
return
make_pair(x-0.5,x+0.5);
76
}
77
84
virtual
double
overlap
(
double
x,
const
pair<double,double>& box)
const
{
85
if
( x - 0.5 >= box.first && x + 0.5 <= box.second )
86
return
1.;
87
if
( x - 0.5 > box.second || x + 0.5 < box.first )
88
return
0.;
89
return
min(box.second,x+0.5) - max(box.first,x-0.5);
90
}
91
96
double
overlap
(
double
x,
97
pair<double,double> box,
98
const
pair<double,double>&
support
)
const
{
99
box.first = max(box.first,
support
.first);
100
box.second = min(box.second,
support
.second);
101
assert(x >=
support
.first && x <=
support
.second);
102
assert(
support
.second -
support
.first >= 1.);
103
if
( x - 0.5 <
support
.first )
104
x =
support
.first + 0.5;
105
if
( x + 0.5 >
support
.second )
106
x =
support
.second - 0.5;
107
return
overlap
(x,box);
108
}
109
113
pair<double,double>
bounds
(
const
CutTypes::Energy
&)
const
{
114
return
make_pair(0.,
generator
()->maximumCMEnergy()/
theEnergyWidth
);
115
}
116
120
Energy
width
(
const
CutTypes::Energy
&)
const
{
121
return
theEnergyWidth
;
122
}
123
127
pair<double,double>
bounds
(
const
CutTypes::Momentum
&)
const
{
128
return
make_pair(0.,0.5*
generator
()->maximumCMEnergy()/
theEnergyWidth
);
129
}
130
134
Energy
width
(
const
CutTypes::Momentum
&)
const
{
135
return
theEnergyWidth
;
136
}
137
141
pair<double,double>
bounds
(
const
CutTypes::Rapidity
&)
const
{
142
return
make_pair(-
Constants::MaxRapidity
/
theRapidityWidth
,
143
Constants::MaxRapidity
/
theRapidityWidth
);
144
}
145
149
double
width
(
const
CutTypes::Rapidity
&)
const
{
150
return
theRapidityWidth
;
151
}
152
156
pair<double,double>
bounds
(
const
CutTypes::Azimuth
&)
const
{
157
return
make_pair(0.0,2.*
Constants::pi
/
theAngularWidth
);
158
}
159
163
double
width
(
const
CutTypes::Azimuth
&)
const
{
164
return
theAngularWidth
;
165
}
166
170
pair<double,double>
bounds
(
const
CutTypes::Polar
&)
const
{
171
return
make_pair(0.0,
Constants::pi
/
theAngularWidth
);
172
}
173
177
double
width
(
const
CutTypes::Polar
&)
const
{
178
return
theAngularWidth
;
179
}
180
184
template
<
class
CutType,
class
Value>
185
bool
isInside
(
const
Value& v,
const
Value& lower,
const
Value& upper,
double
& weight)
const
{
186
CutType type;
187
Value w =
width
(type);
188
weight *=
189
overlap
(v/w,pair<double,double>(lower/w,upper/w),
bounds
(type));
190
if
( weight == 0.0 )
191
return
false
;
192
return
true
;
193
}
194
198
template
<
class
CutType,
class
Value>
199
bool
isLessThan
(
const
Value& v,
const
Value& upper,
double
& weight)
const
{
200
CutType type;
201
Value w =
width
(type);
202
pair<double,double> b =
bounds
(type);
203
weight *=
204
overlap
(v/w,pair<double,double>(b.first,upper/w),b);
205
if
( weight == 0.0 )
206
return
false
;
207
return
true
;
208
}
209
213
template
<
class
CutType,
class
Value>
214
bool
isLargerThan
(
const
Value& v,
const
Value& lower,
double
& weight)
const
{
215
CutType type;
216
Value w =
width
(type);
217
pair<double,double> b =
bounds
(type);
218
weight *=
219
overlap
(v/w,pair<double,double>(lower/w,b.first),b);
220
if
( weight == 0.0 )
221
return
false
;
222
return
true
;
223
}
224
225
public
:
226
233
void
persistentOutput
(
PersistentOStream
& os)
const
;
234
240
void
persistentInput
(
PersistentIStream
& is,
int
version);
242
249
static
void
Init
();
250
251
protected
:
252
259
virtual
IBPtr
clone
()
const
;
260
265
virtual
IBPtr
fullclone
()
const
;
267
268
269
// If needed, insert declarations of virtual function defined in the
270
// InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
271
272
private
:
273
277
Energy
theEnergyWidth
;
278
282
double
theRapidityWidth
;
283
287
double
theAngularWidth
;
288
289
private
:
290
295
static
ClassDescription<FuzzyTheta>
initFuzzyTheta
;
296
301
FuzzyTheta
&
operator=
(
const
FuzzyTheta
&) =
delete
;
302
303
};
304
305
}
306
307
#include "ThePEG/Utilities/ClassTraits.h"
308
309
namespace
ThePEG
{
310
315
template
<>
316
struct
BaseClassTrait<FuzzyTheta,1> {
318
typedef
Interfaced
NthBase
;
319
};
320
323
template
<>
324
struct
ClassTraits<FuzzyTheta>
325
:
public
ClassTraitsBase<FuzzyTheta> {
327
static
string
className
() {
return
"ThePEG::FuzzyTheta"
; }
328
};
329
332
}
333
334
#endif
/* ThePEG_FuzzyTheta_H */
ThePEG::ClassDescription
A concreate implementation of ClassDescriptionBase describing a concrete class with persistent data.
Definition:
ClassDescription.h:333
ThePEG::FuzzyTheta
FuzzyTheta implements fuzzy cut prescriptions.
Definition:
FuzzyTheta.h:57
ThePEG::FuzzyTheta::theEnergyWidth
Energy theEnergyWidth
The width to be considered for momenta.
Definition:
FuzzyTheta.h:277
ThePEG::FuzzyTheta::isLessThan
bool isLessThan(const Value &v, const Value &upper, double &weight) const
Check for value inside the given bounds and update the weight.
Definition:
FuzzyTheta.h:199
ThePEG::FuzzyTheta::bounds
pair< double, double > bounds(const CutTypes::Azimuth &) const
Return the bounds for a azimuth-type cut.
Definition:
FuzzyTheta.h:156
ThePEG::FuzzyTheta::theRapidityWidth
double theRapidityWidth
The width to be considered for rapidity quantities.
Definition:
FuzzyTheta.h:282
ThePEG::FuzzyTheta::initFuzzyTheta
static ClassDescription< FuzzyTheta > initFuzzyTheta
The static object used to initialize the description of this class.
Definition:
FuzzyTheta.h:295
ThePEG::FuzzyTheta::overlap
virtual double overlap(double x, const pair< double, double > &box) const
Return the overlap integral of the delta approximation with the given box and center.
Definition:
FuzzyTheta.h:84
ThePEG::FuzzyTheta::theAngularWidth
double theAngularWidth
The width to be considered for angular quantities.
Definition:
FuzzyTheta.h:287
ThePEG::FuzzyTheta::persistentInput
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
ThePEG::FuzzyTheta::operator=
FuzzyTheta & operator=(const FuzzyTheta &)=delete
The assignment operator is private and must never be called.
ThePEG::FuzzyTheta::FuzzyTheta
FuzzyTheta()
The default constructor.
ThePEG::FuzzyTheta::width
Energy width(const CutTypes::Energy &) const
Return the width for an energy-type cut.
Definition:
FuzzyTheta.h:120
ThePEG::FuzzyTheta::bounds
pair< double, double > bounds(const CutTypes::Polar &) const
Return the bounds for a polar-angle-type cut.
Definition:
FuzzyTheta.h:170
ThePEG::FuzzyTheta::width
double width(const CutTypes::Rapidity &) const
Return the width for a rapidity-type cut.
Definition:
FuzzyTheta.h:149
ThePEG::FuzzyTheta::fullclone
virtual IBPtr fullclone() const
Make a clone of this object, possibly modifying the cloned object to make it sane.
ThePEG::FuzzyTheta::overlap
double overlap(double x, pair< double, double > box, const pair< double, double > &support) const
Return the overlap, optionally considering absolute lower and upper bounds.
Definition:
FuzzyTheta.h:96
ThePEG::FuzzyTheta::clone
virtual IBPtr clone() const
Make a simple clone of this object.
ThePEG::FuzzyTheta::isLargerThan
bool isLargerThan(const Value &v, const Value &lower, double &weight) const
Check for value inside the given bounds and update the weight.
Definition:
FuzzyTheta.h:214
ThePEG::FuzzyTheta::bounds
pair< double, double > bounds(const CutTypes::Rapidity &) const
Return the bounds for a rapidity-type cut.
Definition:
FuzzyTheta.h:141
ThePEG::FuzzyTheta::bounds
pair< double, double > bounds(const CutTypes::Energy &) const
Return the bounds for an energy-type cut.
Definition:
FuzzyTheta.h:113
ThePEG::FuzzyTheta::width
double width(const CutTypes::Azimuth &) const
Return the width for a azimuth-type cut.
Definition:
FuzzyTheta.h:163
ThePEG::FuzzyTheta::bounds
pair< double, double > bounds(const CutTypes::Momentum &) const
Return the bounds for a momentum-type cut.
Definition:
FuzzyTheta.h:127
ThePEG::FuzzyTheta::width
Energy width(const CutTypes::Momentum &) const
Return the width for a momentum-type cut.
Definition:
FuzzyTheta.h:134
ThePEG::FuzzyTheta::support
virtual pair< double, double > support(double x) const
Return the (compact) support of the delta approximation considered, given its center value.
Definition:
FuzzyTheta.h:74
ThePEG::FuzzyTheta::Init
static void Init()
The standard Init function used to initialize the interfaces.
ThePEG::FuzzyTheta::isInside
bool isInside(const Value &v, const Value &lower, const Value &upper, double &weight) const
Check for value inside the given bounds and update the weight.
Definition:
FuzzyTheta.h:185
ThePEG::FuzzyTheta::width
double width(const CutTypes::Polar &) const
Return the width for a polar-type cut.
Definition:
FuzzyTheta.h:177
ThePEG::FuzzyTheta::persistentOutput
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
ThePEG::Interfaced
The Interfaced class is derived from the InterfacedBase class adding a couple of things particular to...
Definition:
Interfaced.h:38
ThePEG::Interfaced::generator
tEGPtr generator() const
Return a pointer to the EventGenerator controlling the run.
Definition:
Interfaced.h:99
ThePEG::PersistentIStream
PersistentIStream is used to read persistent objects from a stream where they were previously written...
Definition:
PersistentIStream.h:48
ThePEG::PersistentOStream
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
Definition:
PersistentOStream.h:51
ThePEG::Pointer::RCPtr
RCPtr is a reference counted (smart) pointer.
Definition:
RCPtr.h:60
ThePEG::Qty< 0, 1, 0 >
ThePEG::Constants::pi
constexpr double pi
Good old .
Definition:
Constants.h:54
ThePEG::Constants::MaxRapidity
constexpr double MaxRapidity
A really large rapidity.
Definition:
Constants.h:51
ThePEG
This is the main namespace within which all identifiers in ThePEG are declared.
Definition:
FactoryBase.h:28
ThePEG::BaseClassTrait::NthBase
int NthBase
The type of the BaseN'th base class (int means there are no further base classes).
Definition:
ClassTraits.h:161
ThePEG::ClassTraitsBase::className
static string className()
Return the name of class T.
Definition:
ClassTraits.h:66
ThePEG::CutTypes::Azimuth
Identify an azimuth-type cut.
Definition:
FuzzyTheta.h:42
ThePEG::CutTypes::Energy
Identify an energy-type cut.
Definition:
FuzzyTheta.h:27
ThePEG::CutTypes::Momentum
Identify a momentum-type cut.
Definition:
FuzzyTheta.h:32
ThePEG::CutTypes::Polar
Identify an polar-angle-type cut.
Definition:
FuzzyTheta.h:47
ThePEG::CutTypes::Rapidity
Identify a rapidity-type cut.
Definition:
FuzzyTheta.h:37
Generated on Thu Jun 20 2024 14:47:00 for ThePEG by
1.9.6