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.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/clhep/include/CLHEP/Random/RandGauss.h (Version 11.3.0) and /externals/clhep/include/CLHEP/Random/RandGauss.h (Version 10.2.p1)


                                                   >>   1 // $Id:$
  1 // -*- C++ -*-                                      2 // -*- C++ -*-
  2 //                                                  3 //
  3 // -------------------------------------------      4 // -----------------------------------------------------------------------
  4 //                             HEP Random           5 //                             HEP Random
  5 //                          --- RandGauss ---       6 //                          --- RandGauss ---
  6 //                          class header file       7 //                          class header file
  7 // -------------------------------------------      8 // -----------------------------------------------------------------------
  8 // This file is part of Geant4 (simulation too      9 // This file is part of Geant4 (simulation toolkit for HEP).
  9                                                    10 
 10 // Class defining methods for shooting gaussia     11 // Class defining methods for shooting gaussian distributed random values,
 11 // given a mean (default=0) or specifying also     12 // given a mean (default=0) or specifying also a deviation (default=1).
 12 // Gaussian random numbers are generated two a     13 // Gaussian random numbers are generated two at the time, so every
 13 // other time shoot is called the number retur     14 // other time shoot is called the number returned is the one generated the
 14 // time before.                                    15 // time before.
 15 // Default values are used for operator()().       16 // Default values are used for operator()().
 16                                                    17 
 17 // ===========================================     18 // =======================================================================
 18 // Gabriele Cosmo - Created: 5th September 199     19 // Gabriele Cosmo - Created: 5th September 1995
 19 //                - Minor corrections: 31st Oc     20 //                - Minor corrections: 31st October 1996
 20 //                - Added methods to shoot arr     21 //                - Added methods to shoot arrays: 28th July 1997
 21 // J.Marraffino   - Added default arguments as     22 // J.Marraffino   - Added default arguments as attributes and
 22 //                  operator() with arguments.     23 //                  operator() with arguments. Introduced method normal()
 23 //                  for computation in fire():     24 //                  for computation in fire(): 16th Feb 1998
 24 // Gabriele Cosmo - Relocated static data from     25 // Gabriele Cosmo - Relocated static data from HepRandom: 5th Jan 1999
 25 // M Fischler     - put and get to/from stream     26 // M Fischler     - put and get to/from streams 12/8/04
 26 // ===========================================     27 // =======================================================================
 27                                                    28 
 28 #ifndef RandGauss_h                                29 #ifndef RandGauss_h
 29 #define RandGauss_h 1                              30 #define RandGauss_h 1
 30                                                    31 
 31 #include "CLHEP/Random/Random.h"                   32 #include "CLHEP/Random/Random.h"
 32 #include "CLHEP/Utility/memory.h"                  33 #include "CLHEP/Utility/memory.h"
 33 #include "CLHEP/Utility/thread_local.h"            34 #include "CLHEP/Utility/thread_local.h"
 34                                                    35 
 35 namespace CLHEP {                                  36 namespace CLHEP {
 36                                                    37 
 37 /**                                                38 /**
 38  * @author                                         39  * @author
 39  * @ingroup random                                 40  * @ingroup random
 40  */                                                41  */
 41 class RandGauss : public HepRandom {               42 class RandGauss : public HepRandom {
 42                                                    43 
 43 public:                                            44 public:
 44                                                    45 
 45   inline RandGauss ( HepRandomEngine& anEngine     46   inline RandGauss ( HepRandomEngine& anEngine, double mean=0.0,
 46                                                    47                                                 double stdDev=1.0 );
 47   inline RandGauss ( HepRandomEngine* anEngine     48   inline RandGauss ( HepRandomEngine* anEngine, double mean=0.0,
 48                                                    49                                                 double stdDev=1.0 );
 49   // These constructors should be used to inst     50   // These constructors should be used to instantiate a RandGauss
 50   // distribution object defining a local engi     51   // distribution object defining a local engine for it.
 51   // The static generator will be skipped usin     52   // The static generator will be skipped using the non-static methods
 52   // defined below.                                53   // defined below.
 53   // If the engine is passed by pointer the co     54   // If the engine is passed by pointer the corresponding engine object
 54   // will be deleted by the RandGauss destruct     55   // will be deleted by the RandGauss destructor.
 55   // If the engine is passed by reference the      56   // If the engine is passed by reference the corresponding engine object
 56   // will not be deleted by the RandGauss dest     57   // will not be deleted by the RandGauss destructor.
 57                                                    58 
 58   virtual ~RandGauss();                            59   virtual ~RandGauss();
 59   // Destructor                                    60   // Destructor
 60                                                    61 
 61   // Static methods to shoot random values usi     62   // Static methods to shoot random values using the static generator
 62                                                    63 
 63   static  double shoot();                          64   static  double shoot();
 64                                                    65 
 65   static  inline double shoot( double mean, do     66   static  inline double shoot( double mean, double stdDev );
 66                                                    67 
 67   static  void shootArray ( const int size, do     68   static  void shootArray ( const int size, double* vect,
 68                             double mean=0.0, d     69                             double mean=0.0, double stdDev=1.0 );
 69                                                    70 
 70   //  Static methods to shoot random values us     71   //  Static methods to shoot random values using a given engine
 71   //  by-passing the static generator.             72   //  by-passing the static generator.
 72                                                    73 
 73   static  double shoot( HepRandomEngine* anEng     74   static  double shoot( HepRandomEngine* anEngine );
 74                                                    75 
 75   static  inline double shoot( HepRandomEngine     76   static  inline double shoot( HepRandomEngine* anEngine, 
 76                                   double mean,     77                                   double mean, double stdDev );
 77                                                    78 
 78   static  void shootArray ( HepRandomEngine* a     79   static  void shootArray ( HepRandomEngine* anEngine, const int size,
 79                             double* vect, doub     80                             double* vect, double mean=0.0,
 80                             double stdDev=1.0      81                             double stdDev=1.0 );
 81                                                    82 
 82   //  Methods using the localEngine to shoot r     83   //  Methods using the localEngine to shoot random values, by-passing
 83   //  the static generator.                        84   //  the static generator.
 84                                                    85 
 85   double fire();                                   86   double fire();
 86                                                    87 
 87   inline double fire( double mean, double stdD     88   inline double fire( double mean, double stdDev );
 88                                                    89   
 89   void fireArray ( const int size, double* vec     90   void fireArray ( const int size, double* vect);
 90   void fireArray ( const int size, double* vec     91   void fireArray ( const int size, double* vect,
 91                    double mean, double stdDev      92                    double mean, double stdDev );
 92                                                    93 
 93   virtual double operator()();                     94   virtual double operator()();
 94   virtual double operator()( double mean, doub     95   virtual double operator()( double mean, double stdDev );
 95                                                    96 
 96   std::string name() const;                        97   std::string name() const;
 97   HepRandomEngine & engine();                      98   HepRandomEngine & engine();
 98                                                    99 
 99   static std::string distributionName() {retur    100   static std::string distributionName() {return "RandGauss";}  
100   // Provides the name of this distribution cl    101   // Provides the name of this distribution class
101                                                   102     
102   // Save and restore to/from streams             103   // Save and restore to/from streams
103                                                   104   
104   std::ostream & put ( std::ostream & os ) con    105   std::ostream & put ( std::ostream & os ) const;
105   std::istream & get ( std::istream & is );       106   std::istream & get ( std::istream & is );
106                                                   107   
107   //  Methods setFlag(false) and setF(false) i    108   //  Methods setFlag(false) and setF(false) if invoked in the client
108   //  code before shoot/fire will force genera    109   //  code before shoot/fire will force generation of a new couple of
109   //  values.                                     110   //  values.
110                                                   111 
111   static  bool getFlag();                         112   static  bool getFlag();
112                                                   113 
113   static  void setFlag( bool val );               114   static  void setFlag( bool val );
114                                                   115 
115   bool getF() const {return set;}                 116   bool getF() const {return set;}
116                                                   117   
117   void setF( bool val ) {set = val;}              118   void setF( bool val ) {set = val;}
118                                                   119 
119   // Methods overriding the base class static     120   // Methods overriding the base class static saveEngineStatus ones,
120   // by adding extra data so that save in one     121   // by adding extra data so that save in one program, then further gaussians,
121   // will produce the identical sequence to re    122   // will produce the identical sequence to restore in another program, then 
122   // generating gaussian randoms there            123   // generating gaussian randoms there 
123                                                   124 
124   static void saveEngineStatus( const char fil    125   static void saveEngineStatus( const char filename[] = "Config.conf" );
125   // Saves to file the current status of the c    126   // Saves to file the current status of the current engine.
126                                                   127 
127   static void restoreEngineStatus( const char     128   static void restoreEngineStatus( const char filename[] = "Config.conf" );
128   // Restores a saved status (if any) for the     129   // Restores a saved status (if any) for the current engine.
129                                                   130 
130   static std::ostream& saveFullState ( std::os    131   static std::ostream& saveFullState ( std::ostream & os );
131   // Saves to stream the state of the engine a    132   // Saves to stream the state of the engine and cached data.
132                                                   133 
133   static std::istream& restoreFullState ( std:    134   static std::istream& restoreFullState ( std::istream & is );
134   // Restores from stream the state of the eng    135   // Restores from stream the state of the engine and cached data.
135                                                   136 
136   static std::ostream& saveDistState ( std::os    137   static std::ostream& saveDistState ( std::ostream & os );
137   // Saves to stream the state of the cached d    138   // Saves to stream the state of the cached data.
138                                                   139 
139   static std::istream& restoreDistState ( std:    140   static std::istream& restoreDistState ( std::istream & is );
140   // Restores from stream the state of the cac    141   // Restores from stream the state of the cached data.
141                                                   142 
142                                                   143 
143 protected:                                        144 protected:
144                                                   145 
145   static  double getVal();                        146   static  double getVal();
146                                                   147 
147   static  void setVal( double nextVal );          148   static  void setVal( double nextVal );
148                                                   149 
149   double normal();                                150   double normal();
150                                                   151 
151   double defaultMean;                             152   double defaultMean;
152   double defaultStdDev;                           153   double defaultStdDev;
153                                                   154 
154   std::shared_ptr<HepRandomEngine> localEngine    155   std::shared_ptr<HepRandomEngine> localEngine;
155                                                   156 
156 private:                                          157 private:
157                                                   158 
158   bool   set;                                     159   bool   set;
159   double nextGauss;                               160   double nextGauss;
160                                                   161 
161   // static data                                  162   // static data
162   static CLHEP_THREAD_LOCAL bool set_st;          163   static CLHEP_THREAD_LOCAL bool set_st;
163   static CLHEP_THREAD_LOCAL double nextGauss_s    164   static CLHEP_THREAD_LOCAL double nextGauss_st;
164                                                   165 
165 };                                                166 };
166                                                   167 
167 }  // namespace CLHEP                             168 }  // namespace CLHEP
168                                                   169 
169 #include "CLHEP/Random/RandGauss.icc"             170 #include "CLHEP/Random/RandGauss.icc"
170                                                   171 
171 #endif                                            172 #endif
172                                                   173