thepeg is hosted by Hepforge, IPPP Durham
ThePEG 2.3.0
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
20namespace 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
57class FuzzyTheta: public Interfaced {
58
59public:
60
65
66public:
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
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
135 return theEnergyWidth;
136 }
137
141 pair<double,double> bounds(const CutTypes::Rapidity&) const {
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
225public:
226
234
240 void persistentInput(PersistentIStream & is, int version);
242
249 static void Init();
250
251protected:
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
272private:
273
278
283
288
289private:
290
296
301 FuzzyTheta & operator=(const FuzzyTheta &) = delete;
302
303};
304
305}
306
307#include "ThePEG/Utilities/ClassTraits.h"
308
309namespace ThePEG {
310
315template <>
316struct BaseClassTrait<FuzzyTheta,1> {
318 typedef Interfaced NthBase;
319};
320
323template <>
324struct ClassTraits<FuzzyTheta>
325 : public ClassTraitsBase<FuzzyTheta> {
327 static string className() { return "ThePEG::FuzzyTheta"; }
328};
329
332}
333
334#endif /* ThePEG_FuzzyTheta_H */
A concreate implementation of ClassDescriptionBase describing a concrete class with persistent data.
FuzzyTheta implements fuzzy cut prescriptions.
Definition: FuzzyTheta.h:57
Energy theEnergyWidth
The width to be considered for momenta.
Definition: FuzzyTheta.h:277
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
pair< double, double > bounds(const CutTypes::Azimuth &) const
Return the bounds for a azimuth-type cut.
Definition: FuzzyTheta.h:156
double theRapidityWidth
The width to be considered for rapidity quantities.
Definition: FuzzyTheta.h:282
static ClassDescription< FuzzyTheta > initFuzzyTheta
The static object used to initialize the description of this class.
Definition: FuzzyTheta.h:295
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
double theAngularWidth
The width to be considered for angular quantities.
Definition: FuzzyTheta.h:287
void persistentInput(PersistentIStream &is, int version)
Function used to read in object persistently.
FuzzyTheta & operator=(const FuzzyTheta &)=delete
The assignment operator is private and must never be called.
FuzzyTheta()
The default constructor.
Energy width(const CutTypes::Energy &) const
Return the width for an energy-type cut.
Definition: FuzzyTheta.h:120
pair< double, double > bounds(const CutTypes::Polar &) const
Return the bounds for a polar-angle-type cut.
Definition: FuzzyTheta.h:170
double width(const CutTypes::Rapidity &) const
Return the width for a rapidity-type cut.
Definition: FuzzyTheta.h:149
virtual IBPtr fullclone() const
Make a clone of this object, possibly modifying the cloned object to make it sane.
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
virtual IBPtr clone() const
Make a simple clone of this object.
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
pair< double, double > bounds(const CutTypes::Rapidity &) const
Return the bounds for a rapidity-type cut.
Definition: FuzzyTheta.h:141
pair< double, double > bounds(const CutTypes::Energy &) const
Return the bounds for an energy-type cut.
Definition: FuzzyTheta.h:113
double width(const CutTypes::Azimuth &) const
Return the width for a azimuth-type cut.
Definition: FuzzyTheta.h:163
pair< double, double > bounds(const CutTypes::Momentum &) const
Return the bounds for a momentum-type cut.
Definition: FuzzyTheta.h:127
Energy width(const CutTypes::Momentum &) const
Return the width for a momentum-type cut.
Definition: FuzzyTheta.h:134
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
static void Init()
The standard Init function used to initialize the interfaces.
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
double width(const CutTypes::Polar &) const
Return the width for a polar-type cut.
Definition: FuzzyTheta.h:177
void persistentOutput(PersistentOStream &os) const
Function used to write out object persistently.
The Interfaced class is derived from the InterfacedBase class adding a couple of things particular to...
Definition: Interfaced.h:38
tEGPtr generator() const
Return a pointer to the EventGenerator controlling the run.
Definition: Interfaced.h:99
PersistentIStream is used to read persistent objects from a stream where they were previously written...
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
constexpr double pi
Good old .
Definition: Constants.h:54
constexpr double MaxRapidity
A really large rapidity.
Definition: Constants.h:51
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
int NthBase
The type of the BaseN'th base class (int means there are no further base classes).
Definition: ClassTraits.h:161
static string className()
Return the name of class T.
Definition: ClassTraits.h:66
Identify an azimuth-type cut.
Definition: FuzzyTheta.h:42
Identify an energy-type cut.
Definition: FuzzyTheta.h:27
Identify a momentum-type cut.
Definition: FuzzyTheta.h:32
Identify an polar-angle-type cut.
Definition: FuzzyTheta.h:47
Identify a rapidity-type cut.
Definition: FuzzyTheta.h:37