File indexing completed on 2025-01-18 09:54:38
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 RandGauss_h
0030 #define RandGauss_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 RandGauss : public HepRandom {
0044
0045 public:
0046
0047 inline RandGauss ( HepRandomEngine& anEngine, double mean=0.0,
0048 double stdDev=1.0 );
0049 inline RandGauss ( HepRandomEngine* anEngine, double mean=0.0,
0050 double stdDev=1.0 );
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060 virtual ~RandGauss();
0061
0062
0063
0064
0065 static double shoot();
0066
0067 static inline double shoot( double mean, double stdDev );
0068
0069 static void shootArray ( const int size, double* vect,
0070 double mean=0.0, double stdDev=1.0 );
0071
0072
0073
0074
0075 static double shoot( HepRandomEngine* anEngine );
0076
0077 static inline double shoot( HepRandomEngine* anEngine,
0078 double mean, double stdDev );
0079
0080 static void shootArray ( HepRandomEngine* anEngine, const int size,
0081 double* vect, double mean=0.0,
0082 double stdDev=1.0 );
0083
0084
0085
0086
0087 double fire();
0088
0089 inline double fire( double mean, double stdDev );
0090
0091 void fireArray ( const int size, double* vect);
0092 void fireArray ( const int size, double* vect,
0093 double mean, double stdDev );
0094
0095 virtual double operator()();
0096 virtual double operator()( double mean, double stdDev );
0097
0098 std::string name() const;
0099 HepRandomEngine & engine();
0100
0101 static std::string distributionName() {return "RandGauss";}
0102
0103
0104
0105
0106 std::ostream & put ( std::ostream & os ) const;
0107 std::istream & get ( std::istream & is );
0108
0109
0110
0111
0112
0113 static bool getFlag();
0114
0115 static void setFlag( bool val );
0116
0117 bool getF() const {return set;}
0118
0119 void setF( bool val ) {set = val;}
0120
0121
0122
0123
0124
0125
0126 static void saveEngineStatus( const char filename[] = "Config.conf" );
0127
0128
0129 static void restoreEngineStatus( const char filename[] = "Config.conf" );
0130
0131
0132 static std::ostream& saveFullState ( std::ostream & os );
0133
0134
0135 static std::istream& restoreFullState ( std::istream & is );
0136
0137
0138 static std::ostream& saveDistState ( std::ostream & os );
0139
0140
0141 static std::istream& restoreDistState ( std::istream & is );
0142
0143
0144
0145 protected:
0146
0147 static double getVal();
0148
0149 static void setVal( double nextVal );
0150
0151 double normal();
0152
0153 double defaultMean;
0154 double defaultStdDev;
0155
0156 std::shared_ptr<HepRandomEngine> localEngine;
0157
0158 private:
0159
0160 bool set;
0161 double nextGauss;
0162
0163
0164 static CLHEP_THREAD_LOCAL bool set_st;
0165 static CLHEP_THREAD_LOCAL double nextGauss_st;
0166
0167 };
0168
0169 }
0170
0171 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
0172
0173 using namespace CLHEP;
0174 #endif
0175
0176 #include "CLHEP/Random/RandGauss.icc"
0177
0178 #endif