thepeg is hosted by Hepforge, IPPP Durham
ThePEG  2.2.1
HandlerBase.h
1 // -*- C++ -*-
2 //
3 // HandlerBase.h is a part of ThePEG - Toolkit for HEP Event Generation
4 // Copyright (C) 1999-2019 Leif Lonnblad
5 //
6 // ThePEG is licenced under version 3 of the GPL, see COPYING for details.
7 // Please respect the MCnet academic guidelines, see GUIDELINES for details.
8 //
9 #ifndef ThePEG_HandlerBase_H
10 #define ThePEG_HandlerBase_H
11 // This is the declaration of the HandlerBase class.
12 
13 #include "ThePEG/Interface/Interfaced.h"
14 #include "ThePEG/Repository/UseRandom.fh"
15 #include "ThePEG/Repository/EventGenerator.h"
16 #include <stdexcept>
17 
18 namespace ThePEG {
19 
20 template <typename T = UseRandom>
39 class HandlerBaseT: public Interfaced {
40 public:
41 
43  friend class HandlerBase;
44 
45 private:
46 
54 
55 public:
59  virtual ~HandlerBaseT() {}
61 
62 public:
63 
67  double rnd() const { return T::rnd(); }
68 
72  double rnd(double xu) const { return T::rnd(xu); }
73 
77  double rnd(double xl, double xu) const { return T::rnd(xl, xu); }
78 
82  bool rndbool() const { return T::rndbool(); }
83 
87  bool rndbool(double p) const { return T::rndbool(p); }
88 
92  bool rndbool(double p1, double p2) const { return T::rndbool(p1, p2); }
93 
97  int rndsign(double p1, double p2, double p3) const { return T::rndsign(p1, p2, p3); }
98 
102  int rnd2(double p0, double p1) const { return T::rnd2(p0, p1); }
103 
108  int rnd3(double p0, double p1, double p2) const { return T::rnd3(p0, p1, p2); }
109 
114  int rnd4(double p0, double p1, double p2, double p3) const { return T::rnd4(p0, p1, p2, p3); }
115 
119  long irnd(long xu = 2) const { return T::irnd(xu); }
120 
124  long irnd(long xl, long xu) const { return T::irnd(xl, xu); }
125 
130  const StandardModelBase & SM() const { return *standardModel(); }
131 
136  tSMPtr standardModel() const { return generator()->standardModel(); }
137 };
138 
151 class HandlerBase: public HandlerBaseT<UseRandom> {
152 
153 public:
154 
158  static void Init();
159 
160 private:
161 
166 
170  HandlerBase & operator=(const HandlerBase &) = delete;
171 
172 };
173 
180 template <>
181 struct BaseClassTrait<HandlerBase,1>: public ClassTraitsType {
184  typedef Interfaced NthBase;
185 };
186 
191 template <>
192 struct ClassTraits<HandlerBase>: public ClassTraitsBase<HandlerBase> {
194  static string className() { return "ThePEG::HandlerBase"; }
195 };
196 
199 }
200 
201 #endif /* ThePEG_HandlerBase_H */
double rnd() const
Return a simple flat random number in the range ]0,1[.
Definition: HandlerBase.h:67
StandardModelBase is used to handle standard model parameters in an EventGenerator.
static void Init()
Standard Init function.
ClassTraitsType is an empty, non-polymorphic, base class.
Definition: ClassTraits.h:30
int rnd3(double p0, double p1, double p2) const
Return an integer with probability p /(p0+p1+p2).
Definition: HandlerBase.h:108
TransientRCPtr is a simple wrapper around a bare pointer which can be assigned to and from an RCPtr a...
Definition: RCPtr.h:519
This is the main namespace within which all identifiers in ThePEG are declared.
Definition: FactoryBase.h:28
virtual ~HandlerBaseT()
Destructor.
Definition: HandlerBase.h:59
bool rndbool() const
Return true with 50% probability.
Definition: HandlerBase.h:82
Interfaced & operator=(const Interfaced &)=delete
Private and non-existent assignment operator.
bool rndbool(double p) const
Return a true with probability p.
Definition: HandlerBase.h:87
double rnd(double xl, double xu) const
Return a simple flat random number in the range ]xl,xu[.
Definition: HandlerBase.h:77
int rnd2(double p0, double p1) const
Return an integer with probability p /(p0+p1).
Definition: HandlerBase.h:102
double rnd(double xu) const
Return a simple flat random number in the range ]0,xu[.
Definition: HandlerBase.h:72
tEGPtr generator() const
Return a pointer to the EventGenerator controlling the run.
Definition: Interfaced.h:99
A concreate implementation of ClassDescriptionBase describing an abstract class without persistent da...
const StandardModelBase & SM() const
Return a reference to the object containing the standard model parameters for this run...
Definition: HandlerBase.h:130
long irnd(long xl, long xu) const
Return a simple flat random integrer number in the range [xl,xu[.
Definition: HandlerBase.h:124
HandlerBaseT()
Default constructor.
Definition: HandlerBase.h:53
HandlerBase is an abstract base class derived from the Interfaced class via the HandlerBaseT class ad...
Definition: HandlerBase.h:151
The Interfaced class is derived from the InterfacedBase class adding a couple of things particular to...
Definition: Interfaced.h:38
int rnd4(double p0, double p1, double p2, double p3) const
Return an integer/ with probability p (p0+p1+p2+p3).
Definition: HandlerBase.h:114
The default concrete implementation of ClassTraitsBase.
Definition: ClassTraits.h:134
HandlerBaseT is a dummy abstract templated class used as base class to HandlerBase.
Definition: HandlerBase.h:39
int rndsign(double p1, double p2, double p3) const
Return -1, 0, or 1 with relative probabilities p1, p2, p3.
Definition: HandlerBase.h:97
tSMPtr standardModel() const
Return a pointer to the object containing the standard model parameters for this run.
Definition: HandlerBase.h:136
BaseClassTraits describes the base classes of the templated class.
Definition: ClassTraits.h:156
static AbstractNoPIOClassDescription< HandlerBase > initHandlerBase
Describe an abstract class without persistent data.
Definition: HandlerBase.h:165
long irnd(long xu=2) const
Return a simple flat random integrer number in the range [0,xu[.
Definition: HandlerBase.h:119
The templated ClassTraitsBase class defines a set of default information about classes used by ThePEG...
Definition: ClassTraits.h:52
bool rndbool(double p1, double p2) const
Return a true with probability p1/(p1+p2).
Definition: HandlerBase.h:92