File indexing completed on 2025-01-30 10:03:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 #ifndef RandFlat_h
0030 #define RandFlat_h 1
0031
0032 #include "CLHEP/Random/defs.h"
0033 #include "CLHEP/Random/Random.h"
0034 #include "CLHEP/Utility/memory.h"
0035 #include "CLHEP/Utility/thread_local.h"
0036
0037 namespace CLHEP {
0038
0039
0040
0041
0042
0043 class RandFlat : public HepRandom {
0044
0045 public:
0046
0047 inline RandFlat ( HepRandomEngine& anEngine );
0048 inline RandFlat ( HepRandomEngine& anEngine, double width );
0049 inline RandFlat ( HepRandomEngine& anEngine, double a, double b );
0050 inline RandFlat ( HepRandomEngine* anEngine );
0051 inline RandFlat ( HepRandomEngine* anEngine, double width );
0052 inline RandFlat ( HepRandomEngine* anEngine, double a, double b );
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 virtual ~RandFlat();
0063
0064
0065
0066
0067 static double shoot();
0068
0069 static inline double shoot( double width );
0070
0071 static inline double shoot( double a, double b );
0072
0073 static inline long shootInt( long n );
0074
0075 static inline long shootInt( long a1, long n );
0076
0077 static inline int shootBit();
0078
0079 static void shootArray ( const int size, double* vect );
0080
0081 static void shootArray ( const int size, double* vect,
0082 double lx, double dx );
0083
0084
0085
0086
0087 static inline double shoot ( HepRandomEngine* anEngine );
0088
0089 static inline double shoot( HepRandomEngine* anEngine, double width );
0090
0091 static inline double shoot( HepRandomEngine* anEngine,
0092 double a, double b );
0093 static inline long shootInt( HepRandomEngine* anEngine, long n );
0094
0095 static inline long shootInt( HepRandomEngine* anEngine, long a1, long n );
0096
0097 static inline int shootBit( HepRandomEngine* );
0098
0099 static inline void shootArray ( HepRandomEngine* anEngine,
0100 const int size, double* vect );
0101
0102 static void shootArray ( HepRandomEngine* anEngine,
0103 const int size, double* vect,
0104 double lx, double dx );
0105
0106
0107
0108
0109 inline double fire();
0110
0111 inline double fire( double width );
0112
0113 inline double fire( double a, double b );
0114
0115 inline long fireInt( long n );
0116
0117 inline long fireInt( long a1, long n );
0118
0119 inline int fireBit();
0120
0121 void fireArray (const int size, double* vect);
0122
0123 void fireArray (const int size, double* vect,
0124 double lx, double dx);
0125
0126 double operator()();
0127 double operator()( double width );
0128 double operator()( double a, double b );
0129
0130
0131
0132 std::ostream & put ( std::ostream & os ) const;
0133 std::istream & get ( std::istream & is );
0134
0135 std::string name() const;
0136 HepRandomEngine & engine();
0137
0138 static std::string distributionName() {return "RandFlat";}
0139
0140
0141
0142
0143
0144
0145
0146 static void saveEngineStatus( const char filename[] = "Config.conf" );
0147
0148
0149 static void restoreEngineStatus( const char filename[] = "Config.conf" );
0150
0151
0152 static std::ostream& saveFullState ( std::ostream & os );
0153
0154
0155 static std::istream& restoreFullState ( std::istream & is );
0156
0157
0158 static std::ostream& saveDistState ( std::ostream & os );
0159
0160
0161 static std::istream& restoreDistState ( std::istream & is );
0162
0163
0164
0165 protected:
0166
0167 #if 0
0168
0169 RandFlat(const RandFlat& d);
0170 #endif
0171
0172 private:
0173
0174
0175
0176
0177
0178 inline void fireBits();
0179 static inline void shootBits();
0180 static inline void shootBits(HepRandomEngine*);
0181
0182
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192 static const unsigned long MSB;
0193 static const int MSBBits;
0194
0195
0196 unsigned long randomInt;
0197 unsigned long firstUnusedBit;
0198 static CLHEP_THREAD_LOCAL unsigned long staticRandomInt;
0199 static CLHEP_THREAD_LOCAL unsigned long staticFirstUnusedBit;
0200
0201 std::shared_ptr<HepRandomEngine> localEngine;
0202 double defaultWidth;
0203 double defaultA;
0204 double defaultB;
0205
0206 };
0207
0208 }
0209
0210 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
0211
0212 using namespace CLHEP;
0213 #endif
0214
0215 #include "CLHEP/Random/RandFlat.icc"
0216
0217 #endif