00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef RandExponential_h
00037 #define RandExponential_h 1
00038
00039 #include "Random.h"
00040
00041 class RandExponential : public HepRandom {
00042
00043 public:
00044
00045 inline RandExponential ( HepRandomEngine& anEngine );
00046 inline RandExponential ( HepRandomEngine* anEngine );
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056 virtual ~RandExponential();
00057
00058
00059
00060
00061 static inline HepDouble shoot();
00062
00063 static inline HepDouble shoot( HepDouble mean );
00064
00065 static void shootArray ( const HepInt size, HepDouble* vect,
00066 HepDouble mean=1.0 );
00067 #ifndef ST_NO_TEMPLATE_DEF_ARGS
00068 static void shootArray ( vector<HepDouble>&,
00069 HepDouble mean=1.0 );
00070 #else
00071 static void shootArray ( vector<HepDouble, allocator<HepDouble> >&,
00072 HepDouble mean=1.0 );
00073 #endif
00074
00075
00076
00077 static inline HepDouble shoot( HepRandomEngine* anEngine );
00078
00079 static inline HepDouble shoot( HepRandomEngine* anEngine, HepDouble mean );
00080
00081 static void shootArray ( HepRandomEngine* anEngine, const HepInt size,
00082 HepDouble* vect, HepDouble mean=1.0 );
00083 #ifndef ST_NO_TEMPLATE_DEF_ARGS
00084 static void shootArray ( HepRandomEngine*,
00085 vector<HepDouble>&, HepDouble mean=1.0 );
00086 #else
00087 static void shootArray ( HepRandomEngine*,
00088 vector<HepDouble,allocator<HepDouble> >&, HepDouble mean=1.0 );
00089 #endif
00090
00091
00092
00093 inline HepDouble fire();
00094
00095 inline HepDouble fire( HepDouble mean );
00096
00097 void fireArray ( const HepInt size, HepDouble* vect, HepDouble mean=1.0 );
00098 #ifndef ST_NO_TEMPLATE_DEF_ARGS
00099 void fireArray ( vector<HepDouble>&, HepDouble mean=1.0 );
00100 #else
00101 void fireArray ( vector<HepDouble, allocator<HepDouble> >&, HepDouble mean=1.0 );
00102 #endif
00103 HepDouble operator()();
00104
00105 private:
00106
00107 HepRandomEngine* localEngine;
00108 HepBoolean deleteEngine;
00109
00110 };
00111
00112
00113
00114
00115
00116 inline RandExponential::RandExponential(HepRandomEngine & anEngine)
00117 : localEngine(&anEngine), deleteEngine(false) {}
00118
00119 inline RandExponential::RandExponential(HepRandomEngine * anEngine)
00120 : localEngine(anEngine), deleteEngine(true) {}
00121
00122 inline HepDouble RandExponential::shoot() {
00123 return -::log(HepRandom::getTheGenerator()->flat());
00124 }
00125
00126 inline HepDouble RandExponential::shoot(HepDouble mean) {
00127 return -::log(HepRandom::getTheGenerator()->flat())*mean;
00128 }
00129
00130
00131
00132 inline HepDouble RandExponential::shoot(HepRandomEngine* anEngine) {
00133 return -::log(anEngine->flat());
00134 }
00135
00136 inline HepDouble RandExponential::shoot(HepRandomEngine* anEngine,
00137 HepDouble mean) {
00138 return -::log(anEngine->flat())*mean;
00139 }
00140
00141
00142
00143 inline HepDouble RandExponential::fire() {
00144 return -::log(localEngine->flat());
00145 }
00146
00147 inline HepDouble RandExponential::fire(HepDouble mean) {
00148 return -::log(localEngine->flat())*mean;
00149 }
00150
00151 #endif