thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
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 
66  FuzzyTheta();
67 
71  virtual ~FuzzyTheta();
73 
74 public:
75 
82  virtual pair<double,double> support(double x) const {
83  return make_pair(x-0.5,x+0.5);
84  }
85 
92  virtual double overlap(double x, const pair<double,double>& box) const {
93  if ( x - 0.5 >= box.first && x + 0.5 <= box.second )
94  return 1.;
95  if ( x - 0.5 > box.second || x + 0.5 < box.first )
96  return 0.;
97  return min(box.second,x+0.5) - max(box.first,x-0.5);
98  }
99 
104  double overlap(double x,
105  pair<double,double> box,
106  const pair<double,double>& support) const {
107  box.first = max(box.first,support.first);
108  box.second = min(box.second,support.second);
109  assert(x >= support.first && x <= support.second);
110  assert(support.second - support.first >= 1.);
111  if ( x - 0.5 < support.first )
112  x = support.first + 0.5;
113  if ( x + 0.5 > support.second )
114  x = support.second - 0.5;
115  return overlap(x,box);
116  }
117 
121  pair<double,double> bounds(const CutTypes::Energy&) const {
122  return make_pair(0.,generator()->maximumCMEnergy()/theEnergyWidth);
123  }
124 
128  Energy width(const CutTypes::Energy&) const {
129  return theEnergyWidth;
130  }
131 
135  pair<double,double> bounds(const CutTypes::Momentum&) const {
136  return make_pair(0.,0.5*generator()->maximumCMEnergy()/theEnergyWidth);
137  }
138 
143  return theEnergyWidth;
144  }
145 
149  pair<double,double> bounds(const CutTypes::Rapidity&) const {
150  return make_pair(-Constants::MaxRapidity/theRapidityWidth,
151  Constants::MaxRapidity/theRapidityWidth);
152  }
153 
157  double width(const CutTypes::Rapidity&) const {
158  return theRapidityWidth;
159  }
160 
164  pair<double,double> bounds(const CutTypes::Azimuth&) const {
165  return make_pair(0.0,2.*Constants::pi/theAngularWidth);
166  }
167 
171  double width(const CutTypes::Azimuth&) const {
172  return theAngularWidth;
173  }
174 
178  pair<double,double> bounds(const CutTypes::Polar&) const {
179  return make_pair(0.0,Constants::pi/theAngularWidth);
180  }
181 
185  double width(const CutTypes::Polar&) const {
186  return theAngularWidth;
187  }
188 
192  template<class CutType, class Value>
193  bool isInside(const Value& v, const Value& lower, const Value& upper, double& weight) const {
194  CutType type;
195  Value w = width(type);
196  weight *=
197  overlap(v/w,pair<double,double>(lower/w,upper/w),bounds(type));
198  if ( weight == 0.0 )
199  return false;
200  return true;
201  }
202 
206  template<class CutType, class Value>
207  bool isLessThan(const Value& v, const Value& upper, double& weight) const {
208  CutType type;
209  Value w = width(type);
210  pair<double,double> b = bounds(type);
211  weight *=
212  overlap(v/w,pair<double,double>(b.first,upper/w),b);
213  if ( weight == 0.0 )
214  return false;
215  return true;
216  }
217 
221  template<class CutType, class Value>
222  bool isLargerThan(const Value& v, const Value& lower, double& weight) const {
223  CutType type;
224  Value w = width(type);
225  pair<double,double> b = bounds(type);
226  weight *=
227  overlap(v/w,pair<double,double>(lower/w,b.first),b);
228  if ( weight == 0.0 )
229  return false;
230  return true;
231  }
232 
233 public:
234 
241  void persistentOutput(PersistentOStream & os) const;
242 
248  void persistentInput(PersistentIStream & is, int version);
250 
257  static void Init();
258 
259 protected:
260 
267  virtual IBPtr clone() const;
268 
273  virtual IBPtr fullclone() const;
275 
276 
277 // If needed, insert declarations of virtual function defined in the
278 // InterfacedBase class here (using ThePEG-interfaced-decl in Emacs).
279 
280 private:
281 
286 
291 
296 
297 private:
298 
304 
309  FuzzyTheta & operator=(const FuzzyTheta &) = delete;
310 
311 };
312 
313 }
314 
315 #include "ThePEG/Utilities/ClassTraits.h"
316 
317 namespace ThePEG {
318 
323 template <>
324 struct BaseClassTrait<FuzzyTheta,1> {
326  typedef Interfaced NthBase;
327 };
328 
331 template <>
332 struct ClassTraits<FuzzyTheta>
333  : public ClassTraitsBase<FuzzyTheta> {
335  static string className() { return "ThePEG::FuzzyTheta"; }
336 };
337 
340 }
341 
342 #endif /* ThePEG_FuzzyTheta_H */
Identify an polar-angle-type cut.
Definition: FuzzyTheta.h:47
PersistentIStream is used to read persistent objects from a stream where they were previously written...
double width(const CutTypes::Azimuth &) const
Return the width for a azimuth-type cut.
Definition: FuzzyTheta.h:171
Identify a rapidity-type cut.
Definition: FuzzyTheta.h:37
double theRapidityWidth
The width to be considered for rapidity quantities.
Definition: FuzzyTheta.h:290
A concreate implementation of ClassDescriptionBase describing a concrete class with persistent data...
FuzzyTheta implements fuzzy cut prescriptions.
Definition: FuzzyTheta.h:57
virtual pair< double, double > support(double x) const
Return the (compact) support of the delta approximation considered, given its center value...
Definition: FuzzyTheta.h:82
PersistentOStream is used to write objects persistently to a stream from which they can be read in ag...
double width(const CutTypes::Rapidity &) const
Return the width for a rapidity-type cut.
Definition: FuzzyTheta.h:157
constexpr double pi
Good old .
Definition: Constants.h:54
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:92
static ClassDescription< FuzzyTheta > initFuzzyTheta
The static object used to initialize the description of this class.
Definition: FuzzyTheta.h:303
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
Identify an energy-type cut.
Definition: FuzzyTheta.h:27
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:222
pair< double, double > bounds(const CutTypes::Momentum &) const
Return the bounds for a momentum-type cut.
Definition: FuzzyTheta.h:135
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:104
constexpr double MaxRapidity
A really large rapidity.
Definition: Constants.h:51
pair< double, double > bounds(const CutTypes::Rapidity &) const
Return the bounds for a rapidity-type cut.
Definition: FuzzyTheta.h:149
Identify an azimuth-type cut.
Definition: FuzzyTheta.h:42
pair< double, double > bounds(const CutTypes::Azimuth &) const
Return the bounds for a azimuth-type cut.
Definition: FuzzyTheta.h:164
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:193
Energy width(const CutTypes::Energy &) const
Return the width for an energy-type cut.
Definition: FuzzyTheta.h:128
Energy theEnergyWidth
The width to be considered for momenta.
Definition: FuzzyTheta.h:285
RCPtr is a reference counted (smart) pointer.
Definition: RCPtr.h:60
pair< double, double > bounds(const CutTypes::Energy &) const
Return the bounds for an energy-type cut.
Definition: FuzzyTheta.h:121
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:207
pair< double, double > bounds(const CutTypes::Polar &) const
Return the bounds for a polar-angle-type cut.
Definition: FuzzyTheta.h:178
The Interfaced class is derived from the InterfacedBase class adding a couple of things particular to...
Definition: Interfaced.h:38
double theAngularWidth
The width to be considered for angular quantities.
Definition: FuzzyTheta.h:295
The default concrete implementation of ClassTraitsBase.
Definition: ClassTraits.h:134
Energy width(const CutTypes::Momentum &) const
Return the width for a momentum-type cut.
Definition: FuzzyTheta.h:142
Identify a momentum-type cut.
Definition: FuzzyTheta.h:32
BaseClassTraits describes the base classes of the templated class.
Definition: ClassTraits.h:156
double width(const CutTypes::Polar &) const
Return the width for a polar-type cut.
Definition: FuzzyTheta.h:185
The templated ClassTraitsBase class defines a set of default information about classes used by ThePEG...
Definition: ClassTraits.h:52