StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RandBreitWigner.h
1 /***************************************************************************
2  *
3  * $Id: RandBreitWigner.h,v 1.1 1999/01/30 03:58:59 fisyak Exp $
4  *
5  * Author: Gabriele Cosmo - Created: 5th September 1995
6  * modified for SCL bl
7  ***************************************************************************
8  *
9  * Description:
10  * -----------------------------------------------------------------------
11  * HEP Random
12  * --- RandBreitWigner ---
13  * class header file
14  * -----------------------------------------------------------------------
15  * This file is part of Geant4 (simulation toolkit for HEP).
16  *
17  * Class defining methods for shooting numbers according to the
18  * Breit-Wigner distribution algorithms (plain or mean^2).
19  * Default values are set: mean=1, gamma=.2, cut=1.
20  * Plain algorithm is used for shootArray() and fireArray().
21  * Plain algorithm with default values is used for operator()().
22  *
23  ***************************************************************************
24  *
25  * $Log: RandBreitWigner.h,v $
26  * Revision 1.1 1999/01/30 03:58:59 fisyak
27  * Root Version of StarClassLibrary
28  *
29  * Revision 1.1 1999/01/23 00:27:35 ullrich
30  * Initial Revision
31  *
32  **************************************************************************/
33 #ifndef RandBreitWigner_h
34 #define RandBreitWigner_h 1
35 
36 #include "RandFlat.h"
37 
38 class RandBreitWigner : public HepRandom {
39 
40 public:
41 
42  inline RandBreitWigner ( HepRandomEngine& anEngine );
43  inline RandBreitWigner ( HepRandomEngine* anEngine );
44  // These constructors should be used to instantiate a RandBreitWigner
45  // distribution object defining a local engine for it.
46  // The static generator will be skeeped using the non-static methods
47  // defined below.
48  // If the engine is passed by pointer the corresponding engine object
49  // will be deleted by the RandBreitWigner destructor.
50  // If the engine is passed by reference the corresponding engine object
51  // will not be deleted by the RandBreitWigner destructor.
52 
53  virtual ~RandBreitWigner();
54  // Destructor
55 
56  // Static methods to shoot random values using the static generator
57 
58  static HepDouble shoot( HepDouble a=1.0, HepDouble b=0.2 );
59 
60  static HepDouble shoot( HepDouble a, HepDouble b, HepDouble c );
61 
62  static HepDouble shootM2( HepDouble a=1.0, HepDouble b=0.2 );
63 
64  static HepDouble shootM2( HepDouble a, HepDouble b, HepDouble c );
65 
66  static void shootArray ( const HepInt size, HepDouble* vect,
67  HepDouble a=1.0, HepDouble b=0.2, HepDouble c=1.0 );
68 
69 #ifndef ST_NO_TEMPLATE_DEF_ARGS
70  static void shootArray ( vector<HepDouble>& vec, HepDouble a=1.0,
71  HepDouble b=0.2, HepDouble c=1.0 );
72 #else
73  static void shootArray ( vector<HepDouble, allocator<HepDouble> >& vec,
74  HepDouble a=1.0,
75  HepDouble b=0.2, HepDouble c=1.0 );
76 #endif
77  // Static methods to shoot random values using a given engine
78  // by-passing the static generator.
79 
80  static HepDouble shoot( HepRandomEngine* anEngine, HepDouble a=1.0,
81  HepDouble=0.2 );
82  static HepDouble shoot( HepRandomEngine* anEngine, HepDouble a,
83  HepDouble b, HepDouble c );
84  static HepDouble shootM2( HepRandomEngine* anEngine, HepDouble a=1.0,
85  HepDouble b=0.2 );
86  static HepDouble shootM2( HepRandomEngine* anEngine, HepDouble a,
87  HepDouble b, HepDouble c );
88  static void shootArray ( HepRandomEngine* anEngine,
89  const HepInt size, HepDouble* vect,
90  HepDouble a=1.0, HepDouble b=0.2, HepDouble c=1.0 );
91 #ifndef ST_NO_TEMPLATE_DEF_ARGS
92  static void shootArray ( HepRandomEngine*,
93  vector<HepDouble>&, HepDouble a=1.0,
94  HepDouble b=0.2, HepDouble c=1.0 );
95 #else
96  static void shootArray ( HepRandomEngine*,
97  vector<HepDouble, allocator<HepDouble> >&,
98  HepDouble a=1.0,
99  HepDouble b=0.2, HepDouble c=1.0 );
100 #endif
101  // Methods using the localEngine to shoot random values, by-passing
102  // the static generator.
103 
104  HepDouble fire( HepDouble a=1.0, HepDouble b=0.2 );
105 
106  HepDouble fire( HepDouble a, HepDouble b, HepDouble c );
107 
108  HepDouble fireM2( HepDouble a=1.0, HepDouble b=0.2 );
109 
110  HepDouble fireM2( HepDouble a, HepDouble b, HepDouble c );
111 
112  void fireArray ( const HepInt size, HepDouble* vect,
113  HepDouble a=1.0, HepDouble b=0.2, HepDouble c=1.0 );
114 #ifndef ST_NO_TEMPLATE_DEF_ARGS
115  void fireArray ( vector<HepDouble>&,
116  HepDouble a=1.0, HepDouble b=0.2, HepDouble c=1.0 );
117 #else
118  void fireArray ( vector<HepDouble, allocator<HepDouble> >&,
119  HepDouble a=1.0, HepDouble b=0.2, HepDouble c=1.0 );
120 #endif
121  HepDouble operator()();
122 
123 private:
124 
125  HepRandomEngine* localEngine;
126  HepBoolean deleteEngine;
127 
128 };
129 
130 // ------------------
131 // Inlined functions
132 // ------------------
133 
134 inline RandBreitWigner::RandBreitWigner(HepRandomEngine & anEngine)
135 : localEngine(&anEngine), deleteEngine(false) {}
136 
137 inline RandBreitWigner::RandBreitWigner(HepRandomEngine * anEngine)
138 : localEngine(anEngine), deleteEngine(true) {}
139 
140 #endif